Subscribe to a scoped messages stream.
Contract:
target, or a static target that resolves to
the root namespace) returns a handle whose .current delegates
to stream.messages — the always-on root projection. No extra
subscription is opened.messages subscription scoped to that namespace. The
subscription is released automatically when the owning
component teardown fires (and the registry closes the
underlying server subscription when the last consumer leaves).target (getter form) re-binds the subscription on
change. A getter that flips between root and scoped is
supported: the root case short-circuits to the initial value
because dynamic root delegation isn't meaningful — pass a
static undefined/null target for root handles.Messages are always BaseMessage class instances from
@langchain/core/messages.
useMessages(
stream: AnyStream,
target: ValueOrGetter<SelectorTarget>
): ReactiveValue<BaseMessage<MessageStructure<MessageToolSet>, MessageType>[]>| Name | Type | Description |
|---|---|---|
stream* | AnyStream | |
target | ValueOrGetter<SelectorTarget> |