@langchain/vue 1.0.17 → 1.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -79,8 +79,13 @@ function useValues(stream, target, options) {
79
79
  return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.valuesProjection)(namespace, messagesKey), key, void 0);
80
80
  }
81
81
  /**
82
- * Subscribe to a `custom:<name>` stream extension — most-recent
82
+ * Subscribe to a `custom:<name>` stream extension — the most-recent
83
83
  * payload emitted by the transformer, scoped to the target namespace.
84
+ *
85
+ * Returns only the latest value and resumes across serial runs, so it is
86
+ * ideal for "current state" panels (progress, score, status). When you
87
+ * need the full history of events rather than just the latest payload,
88
+ * use {@link useChannel} instead.
84
89
  */
85
90
  function useExtension(stream, name, target) {
86
91
  const namespace = resolveNamespace(target);
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.cjs","names":["STREAM_CONTROLLER","NAMESPACE_SEPARATOR","useProjection","getRegistry"],"sources":["../src/selectors.ts"],"sourcesContent":["import {\n computed,\n onScopeDispose,\n readonly,\n shallowRef,\n toValue,\n watchEffect,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from \"vue\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport {\n NAMESPACE_SEPARATOR,\n audioProjection,\n channelProjection,\n extensionProjection,\n filesProjection,\n imagesProjection,\n messagesProjection,\n toolCallsProjection,\n valuesProjection,\n videoProjection,\n type AssembledToolCall,\n type AudioMedia,\n type Channel,\n type ChannelProjectionOptions,\n type Event,\n type FileMedia,\n type ImageMedia,\n type InferToolCalls,\n type InferStateType,\n type MessageMetadata,\n type MessageMetadataMap,\n type SubagentDiscoverySnapshot,\n type SubgraphDiscoverySnapshot,\n type SubmissionQueueEntry,\n type SubmissionQueueSnapshot,\n type VideoMedia,\n} from \"@langchain/langgraph-sdk/stream\";\nimport {\n getRegistry,\n STREAM_CONTROLLER,\n type AnyStream,\n type UseStreamReturn,\n} from \"./use-stream.js\";\nimport { useProjection } from \"./use-projection.js\";\n\n/**\n * Selector composables don't need to carry `InterruptType` /\n * `ConfigurableType`. Parameterising on `StateType` alone lets\n * callers with a full `useStream<S, I, C>()` handle pass it in without\n * redeclaring those generics at every call site.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamHandle<StateType extends object> = UseStreamReturn<\n StateType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * What a selector composable can be targeted at. Callers can pass:\n * - `undefined` / `null` — root namespace (served by the always-on\n * root store — no extra subscription);\n * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);\n * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);\n * - an explicit `{ namespace: string[] }`;\n * - a raw `string[]` escape hatch.\n */\nexport type SelectorTarget =\n | undefined\n | null\n | readonly string[]\n | { namespace: readonly string[] }\n | SubagentDiscoverySnapshot\n | SubgraphDiscoverySnapshot;\n\nconst EMPTY_NAMESPACE: readonly string[] = [];\n\nfunction resolveNamespace(target: SelectorTarget): readonly string[] {\n if (target == null) return EMPTY_NAMESPACE;\n if (Array.isArray(target)) return target as readonly string[];\n const obj = target as { namespace?: readonly string[] };\n return obj.namespace ?? EMPTY_NAMESPACE;\n}\n\nfunction isRoot(namespace: readonly string[]): boolean {\n return namespace.length === 0;\n}\n\n/**\n * If `target` is a subagent snapshot still on its default\n * `tools:<toolCallId>` namespace, return that tool-call id. See the\n * React selectors for the rationale (deep-agent subagents execute under\n * a distinct `tools:<uuid>` namespace resolved lazily from history).\n */\nfunction subagentNeedingNamespace(target: SelectorTarget): string | null {\n if (target == null || Array.isArray(target)) return null;\n const obj = target as { id?: unknown; namespace?: readonly string[] };\n if (typeof obj.id !== \"string\" || !Array.isArray(obj.namespace)) return null;\n if (obj.namespace.length === 1 && obj.namespace[0] === `tools:${obj.id}`) {\n return obj.id;\n }\n return null;\n}\n\n/**\n * Lazily resolve a subagent's execution namespace on first scoped use.\n * Re-evaluates if `target` changes; the controller de-dupes and skips\n * already-promoted ids so this is cheap to call from every consumer.\n */\nfunction useResolveSubagentNamespace(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): void {\n const controller = stream[STREAM_CONTROLLER];\n watchEffect(() => {\n const id = subagentNeedingNamespace(toValue(target));\n if (id != null) void controller.resolveSubagentNamespace(id);\n });\n}\n\nfunction namespaceKey(namespace: readonly string[]): string {\n return namespace.join(NAMESPACE_SEPARATOR);\n}\n\n/**\n * Subscribe to a scoped `messages` stream.\n *\n * Contract:\n * - At the root (no `target`) this returns `stream.messages` — the\n * always-on root projection; no extra subscription is opened.\n * - For any non-root namespace, mount triggers a ref-counted\n * `messages` subscription scoped to that namespace. The\n * subscription is released automatically when the calling scope\n * disappears (and the registry closes the underlying server\n * subscription when the last consumer leaves).\n *\n * Messages are always `BaseMessage` class instances from\n * `@langchain/core/messages`.\n */\nexport function useMessages(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<BaseMessage[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.messages;\n const key = computed(() => `messages|${namespaceKey(namespace.value)}`);\n return useProjection<BaseMessage[]>(\n getRegistry(stream),\n () => messagesProjection(namespace.value),\n key,\n EMPTY_MESSAGES\n );\n}\n\nconst EMPTY_MESSAGES: BaseMessage[] = [];\n\n/**\n * Subscribe to a scoped `tools` (tool-call) stream. Same target and\n * lifecycle rules as {@link useMessages}; at the root this returns\n * `stream.toolCalls` directly.\n */\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>>;\nexport function useToolCalls<T>(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<InferToolCalls<T>[]>>;\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.toolCalls;\n const key = computed(() => `toolCalls|${namespaceKey(namespace.value)}`);\n return useProjection<AssembledToolCall[]>(\n getRegistry(stream),\n () => toolCallsProjection(namespace.value),\n key,\n EMPTY_TOOLCALLS\n );\n}\n\nconst EMPTY_TOOLCALLS: AssembledToolCall[] = [];\n\n/**\n * Subscribe to a scoped `values` stream — the most recent state\n * payload for a namespace. At the root returns `stream.values`.\n *\n * Typing:\n * - **Root** (`useValues(stream)`): returns the `StateType` declared\n * on `useStream<State>()` — non-nullable (the root snapshot always\n * has values, falling back to `initialValues ?? {}`).\n * - **Scoped** (`useValues(stream, target)`): scoped payloads can\n * differ from the root state; callers should annotate the\n * expected shape explicitly (`useValues<SubagentState>(stream,\n * sub)`). Defaults to `unknown` when not annotated.\n */\nexport function useValues<StateType extends object>(\n stream: StreamHandle<StateType>\n): Readonly<ShallowRef<StateType>>;\nexport function useValues<T>(\n stream: AnyStream\n): Readonly<ShallowRef<InferStateType<T>>>;\nexport function useValues<T = unknown>(\n stream: AnyStream,\n target: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<T | undefined>>;\nexport function useValues(\n stream: AnyStream,\n target?: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<unknown>> {\n const namespace = resolveNamespace(target);\n if (isRoot(namespace)) return stream.values as Readonly<ShallowRef<unknown>>;\n const messagesKey = options?.messagesKey ?? \"messages\";\n const key = `values|${messagesKey}|${namespaceKey(namespace)}`;\n return useProjection<unknown>(\n getRegistry(stream),\n () => valuesProjection<unknown>(namespace, messagesKey),\n key,\n undefined\n );\n}\n\n/**\n * Subscribe to a `custom:<name>` stream extension — most-recent\n * payload emitted by the transformer, scoped to the target namespace.\n */\nexport function useExtension<T = unknown>(\n stream: AnyStream,\n name: string,\n target?: SelectorTarget\n): Readonly<ShallowRef<T | undefined>> {\n const namespace = resolveNamespace(target);\n const key = `extension|${name}|${namespaceKey(namespace)}`;\n return useProjection<T | undefined>(\n getRegistry(stream),\n () => extensionProjection<T>(name, namespace),\n key,\n undefined\n );\n}\n\n/**\n * Raw-events escape hatch. Subscribes to one or more channels at a\n * namespace and returns a bounded buffer of raw protocol events.\n * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}\n * for the common cases.\n */\nexport type UseChannelOptions = ChannelProjectionOptions;\n\nexport function useChannel(\n stream: AnyStream,\n channels: readonly Channel[],\n target?: SelectorTarget,\n options?: UseChannelOptions\n): Readonly<ShallowRef<Event[]>> {\n const namespace = resolveNamespace(target);\n const sortedChannels = [...channels].sort().join(\",\");\n const key = `channel|${options?.bufferSize ?? \"default\"}|${(options?.replay ?? true) ? \"replay\" : \"live\"}|${sortedChannels}|${namespaceKey(namespace)}`;\n return useProjection<Event[]>(\n getRegistry(stream),\n () => channelProjection(channels, namespace, options),\n key,\n EMPTY_EVENTS\n );\n}\n\nconst EMPTY_EVENTS: Event[] = [];\n\n/**\n * Subscribe to a scoped audio-media stream. Each handle is yielded\n * on its first matching `content-block-start`, exposes\n * `.partialBytes` for live access, settles `.blob` / `.objectURL` /\n * `.transcript` on `message-finish`, and surfaces errors via\n * `.error`.\n */\nexport function useAudio(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<AudioMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `audio|${namespaceKey(namespace)}`;\n return useProjection<AudioMedia[]>(\n getRegistry(stream),\n () => audioProjection(namespace),\n key,\n EMPTY_AUDIO\n );\n}\n\nconst EMPTY_AUDIO: AudioMedia[] = [];\n\n/**\n * Subscribe to a scoped image-media stream. Pair with\n * {@link useMediaURL} for `<img src>`.\n */\nexport function useImages(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<ImageMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `images|${namespaceKey(namespace)}`;\n return useProjection<ImageMedia[]>(\n getRegistry(stream),\n () => imagesProjection(namespace),\n key,\n EMPTY_IMAGES\n );\n}\n\nconst EMPTY_IMAGES: ImageMedia[] = [];\n\n/**\n * Subscribe to a scoped video-media stream. Pair with\n * {@link useMediaURL} for `<video src>`.\n */\nexport function useVideo(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<VideoMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `video|${namespaceKey(namespace)}`;\n return useProjection<VideoMedia[]>(\n getRegistry(stream),\n () => videoProjection(namespace),\n key,\n EMPTY_VIDEO\n );\n}\n\nconst EMPTY_VIDEO: VideoMedia[] = [];\n\n/**\n * Subscribe to a scoped file-media stream. Pair with\n * {@link useMediaURL} for an `<a download href>` target.\n */\nexport function useFiles(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<FileMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `files|${namespaceKey(namespace)}`;\n return useProjection<FileMedia[]>(\n getRegistry(stream),\n () => filesProjection(namespace),\n key,\n EMPTY_FILES\n );\n}\n\nconst EMPTY_FILES: FileMedia[] = [];\n\n/**\n * Read metadata recorded for a specific message id — today exposes\n * `parentCheckpointId`, the checkpoint the message was first seen on.\n * Designed for fork / edit flows:\n *\n * ```ts\n * const meta = useMessageMetadata(stream, () => msg.id);\n * // meta.value?.parentCheckpointId\n * ```\n *\n * `messageId` accepts a raw string, a `Ref<string | undefined>`, or\n * a getter — the binding re-evaluates whenever the id changes.\n */\nexport function useMessageMetadata(\n stream: AnyStream,\n messageId: MaybeRefOrGetter<string | undefined>\n): ComputedRef<MessageMetadata | undefined> {\n const store = stream[STREAM_CONTROLLER].messageMetadataStore;\n const mapRef = shallowRef<MessageMetadataMap>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n mapRef.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return computed<MessageMetadata | undefined>(() => {\n const key = toValue(messageId);\n if (key == null) return undefined;\n return mapRef.value.get(key);\n });\n}\n\n/**\n * Reactive handle on the server-side submission queue.\n *\n * Populated when `submit()` is invoked with\n * `multitaskStrategy: \"enqueue\"` while another run is in flight. The\n * returned refs are shared per call — safe to pass into `v-for`.\n */\nexport interface UseSubmissionQueueReturn<\n StateType extends object = Record<string, unknown>,\n> {\n readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;\n readonly size: ComputedRef<number>;\n cancel(id: string): Promise<boolean>;\n clear(): Promise<void>;\n}\n\nexport function useSubmissionQueue<StateType extends object>(\n stream: StreamHandle<StateType>\n): UseSubmissionQueueReturn<StateType>;\nexport function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;\nexport function useSubmissionQueue(\n stream: AnyStream\n): UseSubmissionQueueReturn {\n const controller = stream[STREAM_CONTROLLER];\n const store = controller.queueStore;\n const entries = shallowRef<SubmissionQueueSnapshot>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n entries.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return {\n entries: readonly(entries) as Readonly<ShallowRef<SubmissionQueueSnapshot>>,\n size: computed(() => entries.value.length),\n cancel: (id) => controller.cancelQueued(id),\n clear: () => controller.clearQueue(),\n };\n}\n\nexport type { SubmissionQueueEntry, SubmissionQueueSnapshot };\n"],"mappings":";;;;;AAgFA,MAAM,kBAAqC,EAAE;AAE7C,SAAS,iBAAiB,QAA2C;AACnE,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAElC,QADY,OACD,aAAa;;AAG1B,SAAS,OAAO,WAAuC;AACrD,QAAO,UAAU,WAAW;;;;;;;;AAS9B,SAAS,yBAAyB,QAAuC;AACvE,KAAI,UAAU,QAAQ,MAAM,QAAQ,OAAO,CAAE,QAAO;CACpD,MAAM,MAAM;AACZ,KAAI,OAAO,IAAI,O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yB;AAE3B,QAAO;EACL,UAAA,GAAA,IAAA,UAAkB,QAAQ;EAC1B,OAAA,GAAA,IAAA,gBAAqB,QAAQ,MAAM,OAAO;EAC1C,SAAS,OAAO,WAAW,aAAa,GAAG;EAC3C,aAAa,WAAW,YAAY;EACrC"}
1
+ {"version":3,"file":"selectors.cjs","names":["STREAM_CONTROLLER","NAMESPACE_SEPARATOR","useProjection","getRegistry"],"sources":["../src/selectors.ts"],"sourcesContent":["import {\n computed,\n onScopeDispose,\n readonly,\n shallowRef,\n toValue,\n watchEffect,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from \"vue\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport {\n NAMESPACE_SEPARATOR,\n audioProjection,\n channelProjection,\n extensionProjection,\n filesProjection,\n imagesProjection,\n messagesProjection,\n toolCallsProjection,\n valuesProjection,\n videoProjection,\n type AssembledToolCall,\n type AudioMedia,\n type Channel,\n type ChannelProjectionOptions,\n type Event,\n type FileMedia,\n type ImageMedia,\n type InferToolCalls,\n type InferStateType,\n type MessageMetadata,\n type MessageMetadataMap,\n type SubagentDiscoverySnapshot,\n type SubgraphDiscoverySnapshot,\n type SubmissionQueueEntry,\n type SubmissionQueueSnapshot,\n type VideoMedia,\n} from \"@langchain/langgraph-sdk/stream\";\nimport {\n getRegistry,\n STREAM_CONTROLLER,\n type AnyStream,\n type UseStreamReturn,\n} from \"./use-stream.js\";\nimport { useProjection } from \"./use-projection.js\";\n\n/**\n * Selector composables don't need to carry `InterruptType` /\n * `ConfigurableType`. Parameterising on `StateType` alone lets\n * callers with a full `useStream<S, I, C>()` handle pass it in without\n * redeclaring those generics at every call site.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamHandle<StateType extends object> = UseStreamReturn<\n StateType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * What a selector composable can be targeted at. Callers can pass:\n * - `undefined` / `null` — root namespace (served by the always-on\n * root store — no extra subscription);\n * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);\n * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);\n * - an explicit `{ namespace: string[] }`;\n * - a raw `string[]` escape hatch.\n */\nexport type SelectorTarget =\n | undefined\n | null\n | readonly string[]\n | { namespace: readonly string[] }\n | SubagentDiscoverySnapshot\n | SubgraphDiscoverySnapshot;\n\nconst EMPTY_NAMESPACE: readonly string[] = [];\n\nfunction resolveNamespace(target: SelectorTarget): readonly string[] {\n if (target == null) return EMPTY_NAMESPACE;\n if (Array.isArray(target)) return target as readonly string[];\n const obj = target as { namespace?: readonly string[] };\n return obj.namespace ?? EMPTY_NAMESPACE;\n}\n\nfunction isRoot(namespace: readonly string[]): boolean {\n return namespace.length === 0;\n}\n\n/**\n * If `target` is a subagent snapshot still on its default\n * `tools:<toolCallId>` namespace, return that tool-call id. See the\n * React selectors for the rationale (deep-agent subagents execute under\n * a distinct `tools:<uuid>` namespace resolved lazily from history).\n */\nfunction subagentNeedingNamespace(target: SelectorTarget): string | null {\n if (target == null || Array.isArray(target)) return null;\n const obj = target as { id?: unknown; namespace?: readonly string[] };\n if (typeof obj.id !== \"string\" || !Array.isArray(obj.namespace)) return null;\n if (obj.namespace.length === 1 && obj.namespace[0] === `tools:${obj.id}`) {\n return obj.id;\n }\n return null;\n}\n\n/**\n * Lazily resolve a subagent's execution namespace on first scoped use.\n * Re-evaluates if `target` changes; the controller de-dupes and skips\n * already-promoted ids so this is cheap to call from every consumer.\n */\nfunction useResolveSubagentNamespace(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): void {\n const controller = stream[STREAM_CONTROLLER];\n watchEffect(() => {\n const id = subagentNeedingNamespace(toValue(target));\n if (id != null) void controller.resolveSubagentNamespace(id);\n });\n}\n\nfunction namespaceKey(namespace: readonly string[]): string {\n return namespace.join(NAMESPACE_SEPARATOR);\n}\n\n/**\n * Subscribe to a scoped `messages` stream.\n *\n * Contract:\n * - At the root (no `target`) this returns `stream.messages` — the\n * always-on root projection; no extra subscription is opened.\n * - For any non-root namespace, mount triggers a ref-counted\n * `messages` subscription scoped to that namespace. The\n * subscription is released automatically when the calling scope\n * disappears (and the registry closes the underlying server\n * subscription when the last consumer leaves).\n *\n * Messages are always `BaseMessage` class instances from\n * `@langchain/core/messages`.\n */\nexport function useMessages(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<BaseMessage[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.messages;\n const key = computed(() => `messages|${namespaceKey(namespace.value)}`);\n return useProjection<BaseMessage[]>(\n getRegistry(stream),\n () => messagesProjection(namespace.value),\n key,\n EMPTY_MESSAGES\n );\n}\n\nconst EMPTY_MESSAGES: BaseMessage[] = [];\n\n/**\n * Subscribe to a scoped `tools` (tool-call) stream. Same target and\n * lifecycle rules as {@link useMessages}; at the root this returns\n * `stream.toolCalls` directly.\n */\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>>;\nexport function useToolCalls<T>(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<InferToolCalls<T>[]>>;\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.toolCalls;\n const key = computed(() => `toolCalls|${namespaceKey(namespace.value)}`);\n return useProjection<AssembledToolCall[]>(\n getRegistry(stream),\n () => toolCallsProjection(namespace.value),\n key,\n EMPTY_TOOLCALLS\n );\n}\n\nconst EMPTY_TOOLCALLS: AssembledToolCall[] = [];\n\n/**\n * Subscribe to a scoped `values` stream — the most recent state\n * payload for a namespace. At the root returns `stream.values`.\n *\n * Typing:\n * - **Root** (`useValues(stream)`): returns the `StateType` declared\n * on `useStream<State>()` — non-nullable (the root snapshot always\n * has values, falling back to `initialValues ?? {}`).\n * - **Scoped** (`useValues(stream, target)`): scoped payloads can\n * differ from the root state; callers should annotate the\n * expected shape explicitly (`useValues<SubagentState>(stream,\n * sub)`). Defaults to `unknown` when not annotated.\n */\nexport function useValues<StateType extends object>(\n stream: StreamHandle<StateType>\n): Readonly<ShallowRef<StateType>>;\nexport function useValues<T>(\n stream: AnyStream\n): Readonly<ShallowRef<InferStateType<T>>>;\nexport function useValues<T = unknown>(\n stream: AnyStream,\n target: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<T | undefined>>;\nexport function useValues(\n stream: AnyStream,\n target?: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<unknown>> {\n const namespace = resolveNamespace(target);\n if (isRoot(namespace)) return stream.values as Readonly<ShallowRef<unknown>>;\n const messagesKey = options?.messagesKey ?? \"messages\";\n const key = `values|${messagesKey}|${namespaceKey(namespace)}`;\n return useProjection<unknown>(\n getRegistry(stream),\n () => valuesProjection<unknown>(namespace, messagesKey),\n key,\n undefined\n );\n}\n\n/**\n * Subscribe to a `custom:<name>` stream extension — the most-recent\n * payload emitted by the transformer, scoped to the target namespace.\n *\n * Returns only the latest value and resumes across serial runs, so it is\n * ideal for \"current state\" panels (progress, score, status). When you\n * need the full history of events rather than just the latest payload,\n * use {@link useChannel} instead.\n */\nexport function useExtension<T = unknown>(\n stream: AnyStream,\n name: string,\n target?: SelectorTarget\n): Readonly<ShallowRef<T | undefined>> {\n const namespace = resolveNamespace(target);\n const key = `extension|${name}|${namespaceKey(namespace)}`;\n return useProjection<T | undefined>(\n getRegistry(stream),\n () => extensionProjection<T>(name, namespace),\n key,\n undefined\n );\n}\n\n/**\n * Raw-events escape hatch. Subscribes to one or more channels at a\n * namespace and returns a bounded buffer of raw protocol events.\n *\n * The buffer keeps accumulating across serial runs for the lifetime of\n * the thread, so this is the hook to use for an event log / stream of a\n * custom channel (e.g. `[\"custom:redaction-stats\"]`). When you only need\n * the latest payload of a single `custom:<name>` channel, prefer\n * {@link useExtension}. For the common message/tool/value cases prefer\n * {@link useMessages} / {@link useToolCalls} / {@link useValues}.\n */\nexport type UseChannelOptions = ChannelProjectionOptions;\n\nexport function useChannel(\n stream: AnyStream,\n channels: readonly Channel[],\n target?: SelectorTarget,\n options?: UseChannelOptions\n): Readonly<ShallowRef<Event[]>> {\n const namespace = resolveNamespace(target);\n const sortedChannels = [...channels].sort().join(\",\");\n const key = `channel|${options?.bufferSize ?? \"default\"}|${(options?.replay ?? true) ? \"replay\" : \"live\"}|${sortedChannels}|${namespaceKey(namespace)}`;\n return useProjection<Event[]>(\n getRegistry(stream),\n () => channelProjection(channels, namespace, options),\n key,\n EMPTY_EVENTS\n );\n}\n\nconst EMPTY_EVENTS: Event[] = [];\n\n/**\n * Subscribe to a scoped audio-media stream. Each handle is yielded\n * on its first matching `content-block-start`, exposes\n * `.partialBytes` for live access, settles `.blob` / `.objectURL` /\n * `.transcript` on `message-finish`, and surfaces errors via\n * `.error`.\n */\nexport function useAudio(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<AudioMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `audio|${namespaceKey(namespace)}`;\n return useProjection<AudioMedia[]>(\n getRegistry(stream),\n () => audioProjection(namespace),\n key,\n EMPTY_AUDIO\n );\n}\n\nconst EMPTY_AUDIO: AudioMedia[] = [];\n\n/**\n * Subscribe to a scoped image-media stream. Pair with\n * {@link useMediaURL} for `<img src>`.\n */\nexport function useImages(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<ImageMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `images|${namespaceKey(namespace)}`;\n return useProjection<ImageMedia[]>(\n getRegistry(stream),\n () => imagesProjection(namespace),\n key,\n EMPTY_IMAGES\n );\n}\n\nconst EMPTY_IMAGES: ImageMedia[] = [];\n\n/**\n * Subscribe to a scoped video-media stream. Pair with\n * {@link useMediaURL} for `<video src>`.\n */\nexport function useVideo(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<VideoMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `video|${namespaceKey(namespace)}`;\n return useProjection<VideoMedia[]>(\n getRegistry(stream),\n () => videoProjection(namespace),\n key,\n EMPTY_VIDEO\n );\n}\n\nconst EMPTY_VIDEO: VideoMedia[] = [];\n\n/**\n * Subscribe to a scoped file-media stream. Pair with\n * {@link useMediaURL} for an `<a download href>` target.\n */\nexport function useFiles(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<FileMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `files|${namespaceKey(namespace)}`;\n return useProjection<FileMedia[]>(\n getRegistry(stream),\n () => filesProjection(namespace),\n key,\n EMPTY_FILES\n );\n}\n\nconst EMPTY_FILES: FileMedia[] = [];\n\n/**\n * Read metadata recorded for a specific message id — today exposes\n * `parentCheckpointId`, the checkpoint the message was first seen on.\n * Designed for fork / edit flows:\n *\n * ```ts\n * const meta = useMessageMetadata(stream, () => msg.id);\n * // meta.value?.parentCheckpointId\n * ```\n *\n * `messageId` accepts a raw string, a `Ref<string | undefined>`, or\n * a getter — the binding re-evaluates whenever the id changes.\n */\nexport function useMessageMetadata(\n stream: AnyStream,\n messageId: MaybeRefOrGetter<string | undefined>\n): ComputedRef<MessageMetadata | undefined> {\n const store = stream[STREAM_CONTROLLER].messageMetadataStore;\n const mapRef = shallowRef<MessageMetadataMap>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n mapRef.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return computed<MessageMetadata | undefined>(() => {\n const key = toValue(messageId);\n if (key == null) return undefined;\n return mapRef.value.get(key);\n });\n}\n\n/**\n * Reactive handle on the server-side submission queue.\n *\n * Populated when `submit()` is invoked with\n * `multitaskStrategy: \"enqueue\"` while another run is in flight. The\n * returned refs are shared per call — safe to pass into `v-for`.\n */\nexport interface UseSubmissionQueueReturn<\n StateType extends object = Record<string, unknown>,\n> {\n readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;\n readonly size: ComputedRef<number>;\n cancel(id: string): Promise<boolean>;\n clear(): Promise<void>;\n}\n\nexport function useSubmissionQueue<StateType extends object>(\n stream: StreamHandle<StateType>\n): UseSubmissionQueueReturn<StateType>;\nexport function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;\nexport function useSubmissionQueue(\n stream: AnyStream\n): UseSubmissionQueueReturn {\n const controller = stream[STREAM_CONTROLLER];\n const store = controller.queueStore;\n const entries = shallowRef<SubmissionQueueSnapshot>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n entries.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return {\n entries: readonly(entries) as Readonly<ShallowRef<SubmissionQueueSnapshot>>,\n size: computed(() => entries.value.length),\n cancel: (id) => controller.cancelQueued(id),\n clear: () => controller.clearQueue(),\n };\n}\n\nexport type { SubmissionQueueEntry, SubmissionQueueSnapshot };\n"],"mappings":";;;;;AAgFA,MAAM,kBAAqC,EAAE;AAE7C,SAAS,iBAAiB,QAA2C;AACnE,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAElC,QADY,OACD,aAAa;;AAG1B,SAAS,OAAO,WAAuC;AACrD,QAAO,UAAU,WAAW;;;;;;;;AAS9B,SAAS,yBAAyB,QAAuC;AACvE,KAAI,UAAU,QAAQ,MAAM,QAAQ,OAAO,CAAE,QAAO;CACpD,MAAM,MAAM;AACZ,KAAI,OAAO,IAAI,OAAO,YAAY,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAE,QAAO;AACxE,KAAI,IAAI,UAAU,WAAW,KAAK,IAAI,UAAU,OAAO,SAAS,IAAI,KA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AAS,OAAO,WAAW,aAAa,GAAG;EAC3C,aAAa,WAAW,YAAY;EACrC"}
@@ -65,15 +65,25 @@ declare function useValues<T = unknown>(stream: AnyStream, target: SelectorTarge
65
65
  messagesKey?: string;
66
66
  }): Readonly<ShallowRef<T | undefined>>;
67
67
  /**
68
- * Subscribe to a `custom:<name>` stream extension — most-recent
68
+ * Subscribe to a `custom:<name>` stream extension — the most-recent
69
69
  * payload emitted by the transformer, scoped to the target namespace.
70
+ *
71
+ * Returns only the latest value and resumes across serial runs, so it is
72
+ * ideal for "current state" panels (progress, score, status). When you
73
+ * need the full history of events rather than just the latest payload,
74
+ * use {@link useChannel} instead.
70
75
  */
71
76
  declare function useExtension<T = unknown>(stream: AnyStream, name: string, target?: SelectorTarget): Readonly<ShallowRef<T | undefined>>;
72
77
  /**
73
78
  * Raw-events escape hatch. Subscribes to one or more channels at a
74
79
  * namespace and returns a bounded buffer of raw protocol events.
75
- * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}
76
- * for the common cases.
80
+ *
81
+ * The buffer keeps accumulating across serial runs for the lifetime of
82
+ * the thread, so this is the hook to use for an event log / stream of a
83
+ * custom channel (e.g. `["custom:redaction-stats"]`). When you only need
84
+ * the latest payload of a single `custom:<name>` channel, prefer
85
+ * {@link useExtension}. For the common message/tool/value cases prefer
86
+ * {@link useMessages} / {@link useToolCalls} / {@link useValues}.
77
87
  */
78
88
  type UseChannelOptions = ChannelProjectionOptions;
79
89
  declare function useChannel(stream: AnyStream, channels: readonly Channel[], target?: SelectorTarget, options?: UseChannelOptions): Readonly<ShallowRef<Event[]>>;
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.cts","names":[],"sources":["../src/selectors.ts"],"mappings":";;;;;;;;AA6CyB;;;;KAUpB,YAAA,6BAAyC,eAAA,CAC5C,SAAA;;;;;AAgBF;;;;;KAAY,cAAA;EAIN,SAAA;AAAA,IACF,yBAAA,GACA,yBAAA;;AAkEJ;;;;;;;;;;;;;;iBAAgB,WAA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BACY,MAAA;EAAA,SAElB,OAAA,EAAS,QAAA,CAAS,UAAA,CAAW,uBAAA,CAAwB,SAAA;EAAA,SACrD,IAAA,EAAM,WAAA;EACf,MAAA,CAAO,EAAA,WAAa,OAAA;EACpB,KAAA,IAAS,OAAA;AAAA;AAAA,iBAGK,kBAAA,0BAAA,CACd,MAAA,EAAQ,YAAA,CAAa,SAAA,IACpB,wBAAA,CAAyB,SAAA;AAAA,iBACZ,kBAAA,CAAmB,MAAA,EAAQ,SAAA,GAAY,wBAAA"}
@@ -65,15 +65,25 @@ declare function useValues<T = unknown>(stream: AnyStream, target: SelectorTarge
65
65
  messagesKey?: string;
66
66
  }): Readonly<ShallowRef<T | undefined>>;
67
67
  /**
68
- * Subscribe to a `custom:<name>` stream extension — most-recent
68
+ * Subscribe to a `custom:<name>` stream extension — the most-recent
69
69
  * payload emitted by the transformer, scoped to the target namespace.
70
+ *
71
+ * Returns only the latest value and resumes across serial runs, so it is
72
+ * ideal for "current state" panels (progress, score, status). When you
73
+ * need the full history of events rather than just the latest payload,
74
+ * use {@link useChannel} instead.
70
75
  */
71
76
  declare function useExtension<T = unknown>(stream: AnyStream, name: string, target?: SelectorTarget): Readonly<ShallowRef<T | undefined>>;
72
77
  /**
73
78
  * Raw-events escape hatch. Subscribes to one or more channels at a
74
79
  * namespace and returns a bounded buffer of raw protocol events.
75
- * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}
76
- * for the common cases.
80
+ *
81
+ * The buffer keeps accumulating across serial runs for the lifetime of
82
+ * the thread, so this is the hook to use for an event log / stream of a
83
+ * custom channel (e.g. `["custom:redaction-stats"]`). When you only need
84
+ * the latest payload of a single `custom:<name>` channel, prefer
85
+ * {@link useExtension}. For the common message/tool/value cases prefer
86
+ * {@link useMessages} / {@link useToolCalls} / {@link useValues}.
77
87
  */
78
88
  type UseChannelOptions = ChannelProjectionOptions;
79
89
  declare function useChannel(stream: AnyStream, channels: readonly Channel[], target?: SelectorTarget, options?: UseChannelOptions):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AAA,CAAS,UAAA,CAAW,UAAA;;;;;iBAiBP,QAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,GAAS,cAAA,GACR,QAAA,CAAS,UAAA,CAAW,SAAA;;;;;;;;;;;;;;iBA0BP,kBAAA,CACd,MAAA,EAAQ,SAAA,EACR,SAAA,EAAW,gBAAA,uBACV,WAAA,CAAY,eAAA;;;;;AAjLf;;;UAuMiB,wBAAA,4BACY,MAAA;EAAA,SAElB,OAAA,EAAS,QAAA,CAAS,UAAA,CAAW,uBAAA,CAAwB,SAAA;EAAA,SACrD,IAAA,EAAM,WAAA;EACf,MAAA,CAAO,EAAA,WAAa,OAAA;EACpB,KAAA,IAAS,OAAA;AAAA;AAAA,iBAGK,kBAAA,0BAAA,CACd,MAAA,EAAQ,YAAA,CAAa,SAAA,IACpB,wBAAA,CAAyB,SAAA;AAAA,iBACZ,kBAAA,CAAmB,MAAA,EAAQ,SAAA,GAAY,wBAAA"}
package/dist/selectors.js CHANGED
@@ -79,8 +79,13 @@ function useValues(stream, target, options) {
79
79
  return useProjection(getRegistry(stream), () => valuesProjection(namespace, messagesKey), key, void 0);
80
80
  }
81
81
  /**
82
- * Subscribe to a `custom:<name>` stream extension — most-recent
82
+ * Subscribe to a `custom:<name>` stream extension — the most-recent
83
83
  * payload emitted by the transformer, scoped to the target namespace.
84
+ *
85
+ * Returns only the latest value and resumes across serial runs, so it is
86
+ * ideal for "current state" panels (progress, score, status). When you
87
+ * need the full history of events rather than just the latest payload,
88
+ * use {@link useChannel} instead.
84
89
  */
85
90
  function useExtension(stream, name, target) {
86
91
  const namespace = resolveNamespace(target);
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.js","names":[],"sources":["../src/selectors.ts"],"sourcesContent":["import {\n computed,\n onScopeDispose,\n readonly,\n shallowRef,\n toValue,\n watchEffect,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from \"vue\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport {\n NAMESPACE_SEPARATOR,\n audioProjection,\n channelProjection,\n extensionProjection,\n filesProjection,\n imagesProjection,\n messagesProjection,\n toolCallsProjection,\n valuesProjection,\n videoProjection,\n type AssembledToolCall,\n type AudioMedia,\n type Channel,\n type ChannelProjectionOptions,\n type Event,\n type FileMedia,\n type ImageMedia,\n type InferToolCalls,\n type InferStateType,\n type MessageMetadata,\n type MessageMetadataMap,\n type SubagentDiscoverySnapshot,\n type SubgraphDiscoverySnapshot,\n type SubmissionQueueEntry,\n type SubmissionQueueSnapshot,\n type VideoMedia,\n} from \"@langchain/langgraph-sdk/stream\";\nimport {\n getRegistry,\n STREAM_CONTROLLER,\n type AnyStream,\n type UseStreamReturn,\n} from \"./use-stream.js\";\nimport { useProjection } from \"./use-projection.js\";\n\n/**\n * Selector composables don't need to carry `InterruptType` /\n * `ConfigurableType`. Parameterising on `StateType` alone lets\n * callers with a full `useStream<S, I, C>()` handle pass it in without\n * redeclaring those generics at every call site.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamHandle<StateType extends object> = UseStreamReturn<\n StateType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * What a selector composable can be targeted at. Callers can pass:\n * - `undefined` / `null` — root namespace (served by the always-on\n * root store — no extra subscription);\n * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);\n * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);\n * - an explicit `{ namespace: string[] }`;\n * - a raw `string[]` escape hatch.\n */\nexport type SelectorTarget =\n | undefined\n | null\n | readonly string[]\n | { namespace: readonly string[] }\n | SubagentDiscoverySnapshot\n | SubgraphDiscoverySnapshot;\n\nconst EMPTY_NAMESPACE: readonly string[] = [];\n\nfunction resolveNamespace(target: SelectorTarget): readonly string[] {\n if (target == null) return EMPTY_NAMESPACE;\n if (Array.isArray(target)) return target as readonly string[];\n const obj = target as { namespace?: readonly string[] };\n return obj.namespace ?? EMPTY_NAMESPACE;\n}\n\nfunction isRoot(namespace: readonly string[]): boolean {\n return namespace.length === 0;\n}\n\n/**\n * If `target` is a subagent snapshot still on its default\n * `tools:<toolCallId>` namespace, return that tool-call id. See the\n * React selectors for the rationale (deep-agent subagents execute under\n * a distinct `tools:<uuid>` namespace resolved lazily from history).\n */\nfunction subagentNeedingNamespace(target: SelectorTarget): string | null {\n if (target == null || Array.isArray(target)) return null;\n const obj = target as { id?: unknown; namespace?: readonly string[] };\n if (typeof obj.id !== \"string\" || !Array.isArray(obj.namespace)) return null;\n if (obj.namespace.length === 1 && obj.namespace[0] === `tools:${obj.id}`) {\n return obj.id;\n }\n return null;\n}\n\n/**\n * Lazily resolve a subagent's execution namespace on first scoped use.\n * Re-evaluates if `target` changes; the controller de-dupes and skips\n * already-promoted ids so this is cheap to call from every consumer.\n */\nfunction useResolveSubagentNamespace(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): void {\n const controller = stream[STREAM_CONTROLLER];\n watchEffect(() => {\n const id = subagentNeedingNamespace(toValue(target));\n if (id != null) void controller.resolveSubagentNamespace(id);\n });\n}\n\nfunction namespaceKey(namespace: readonly string[]): string {\n return namespace.join(NAMESPACE_SEPARATOR);\n}\n\n/**\n * Subscribe to a scoped `messages` stream.\n *\n * Contract:\n * - At the root (no `target`) this returns `stream.messages` — the\n * always-on root projection; no extra subscription is opened.\n * - For any non-root namespace, mount triggers a ref-counted\n * `messages` subscription scoped to that namespace. The\n * subscription is released automatically when the calling scope\n * disappears (and the registry closes the underlying server\n * subscription when the last consumer leaves).\n *\n * Messages are always `BaseMessage` class instances from\n * `@langchain/core/messages`.\n */\nexport function useMessages(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<BaseMessage[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.messages;\n const key = computed(() => `messages|${namespaceKey(namespace.value)}`);\n return useProjection<BaseMessage[]>(\n getRegistry(stream),\n () => messagesProjection(namespace.value),\n key,\n EMPTY_MESSAGES\n );\n}\n\nconst EMPTY_MESSAGES: BaseMessage[] = [];\n\n/**\n * Subscribe to a scoped `tools` (tool-call) stream. Same target and\n * lifecycle rules as {@link useMessages}; at the root this returns\n * `stream.toolCalls` directly.\n */\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>>;\nexport function useToolCalls<T>(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<InferToolCalls<T>[]>>;\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.toolCalls;\n const key = computed(() => `toolCalls|${namespaceKey(namespace.value)}`);\n return useProjection<AssembledToolCall[]>(\n getRegistry(stream),\n () => toolCallsProjection(namespace.value),\n key,\n EMPTY_TOOLCALLS\n );\n}\n\nconst EMPTY_TOOLCALLS: AssembledToolCall[] = [];\n\n/**\n * Subscribe to a scoped `values` stream — the most recent state\n * payload for a namespace. At the root returns `stream.values`.\n *\n * Typing:\n * - **Root** (`useValues(stream)`): returns the `StateType` declared\n * on `useStream<State>()` — non-nullable (the root snapshot always\n * has values, falling back to `initialValues ?? {}`).\n * - **Scoped** (`useValues(stream, target)`): scoped payloads can\n * differ from the root state; callers should annotate the\n * expected shape explicitly (`useValues<SubagentState>(stream,\n * sub)`). Defaults to `unknown` when not annotated.\n */\nexport function useValues<StateType extends object>(\n stream: StreamHandle<StateType>\n): Readonly<ShallowRef<StateType>>;\nexport function useValues<T>(\n stream: AnyStream\n): Readonly<ShallowRef<InferStateType<T>>>;\nexport function useValues<T = unknown>(\n stream: AnyStream,\n target: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<T | undefined>>;\nexport function useValues(\n stream: AnyStream,\n target?: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<unknown>> {\n const namespace = resolveNamespace(target);\n if (isRoot(namespace)) return stream.values as Readonly<ShallowRef<unknown>>;\n const messagesKey = options?.messagesKey ?? \"messages\";\n const key = `values|${messagesKey}|${namespaceKey(namespace)}`;\n return useProjection<unknown>(\n getRegistry(stream),\n () => valuesProjection<unknown>(namespace, messagesKey),\n key,\n undefined\n );\n}\n\n/**\n * Subscribe to a `custom:<name>` stream extension — most-recent\n * payload emitted by the transformer, scoped to the target namespace.\n */\nexport function useExtension<T = unknown>(\n stream: AnyStream,\n name: string,\n target?: SelectorTarget\n): Readonly<ShallowRef<T | undefined>> {\n const namespace = resolveNamespace(target);\n const key = `extension|${name}|${namespaceKey(namespace)}`;\n return useProjection<T | undefined>(\n getRegistry(stream),\n () => extensionProjection<T>(name, namespace),\n key,\n undefined\n );\n}\n\n/**\n * Raw-events escape hatch. Subscribes to one or more channels at a\n * namespace and returns a bounded buffer of raw protocol events.\n * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}\n * for the common cases.\n */\nexport type UseChannelOptions = ChannelProjectionOptions;\n\nexport function useChannel(\n stream: AnyStream,\n channels: readonly Channel[],\n target?: SelectorTarget,\n options?: UseChannelOptions\n): Readonly<ShallowRef<Event[]>> {\n const namespace = resolveNamespace(target);\n const sortedChannels = [...channels].sort().join(\",\");\n const key = `channel|${options?.bufferSize ?? \"default\"}|${(options?.replay ?? true) ? \"replay\" : \"live\"}|${sortedChannels}|${namespaceKey(namespace)}`;\n return useProjection<Event[]>(\n getRegistry(stream),\n () => channelProjection(channels, namespace, options),\n key,\n EMPTY_EVENTS\n );\n}\n\nconst EMPTY_EVENTS: Event[] = [];\n\n/**\n * Subscribe to a scoped audio-media stream. Each handle is yielded\n * on its first matching `content-block-start`, exposes\n * `.partialBytes` for live access, settles `.blob` / `.objectURL` /\n * `.transcript` on `message-finish`, and surfaces errors via\n * `.error`.\n */\nexport function useAudio(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<AudioMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `audio|${namespaceKey(namespace)}`;\n return useProjection<AudioMedia[]>(\n getRegistry(stream),\n () => audioProjection(namespace),\n key,\n EMPTY_AUDIO\n );\n}\n\nconst EMPTY_AUDIO: AudioMedia[] = [];\n\n/**\n * Subscribe to a scoped image-media stream. Pair with\n * {@link useMediaURL} for `<img src>`.\n */\nexport function useImages(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<ImageMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `images|${namespaceKey(namespace)}`;\n return useProjection<ImageMedia[]>(\n getRegistry(stream),\n () => imagesProjection(namespace),\n key,\n EMPTY_IMAGES\n );\n}\n\nconst EMPTY_IMAGES: ImageMedia[] = [];\n\n/**\n * Subscribe to a scoped video-media stream. Pair with\n * {@link useMediaURL} for `<video src>`.\n */\nexport function useVideo(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<VideoMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `video|${namespaceKey(namespace)}`;\n return useProjection<VideoMedia[]>(\n getRegistry(stream),\n () => videoProjection(namespace),\n key,\n EMPTY_VIDEO\n );\n}\n\nconst EMPTY_VIDEO: VideoMedia[] = [];\n\n/**\n * Subscribe to a scoped file-media stream. Pair with\n * {@link useMediaURL} for an `<a download href>` target.\n */\nexport function useFiles(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<FileMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `files|${namespaceKey(namespace)}`;\n return useProjection<FileMedia[]>(\n getRegistry(stream),\n () => filesProjection(namespace),\n key,\n EMPTY_FILES\n );\n}\n\nconst EMPTY_FILES: FileMedia[] = [];\n\n/**\n * Read metadata recorded for a specific message id — today exposes\n * `parentCheckpointId`, the checkpoint the message was first seen on.\n * Designed for fork / edit flows:\n *\n * ```ts\n * const meta = useMessageMetadata(stream, () => msg.id);\n * // meta.value?.parentCheckpointId\n * ```\n *\n * `messageId` accepts a raw string, a `Ref<string | undefined>`, or\n * a getter — the binding re-evaluates whenever the id changes.\n */\nexport function useMessageMetadata(\n stream: AnyStream,\n messageId: MaybeRefOrGetter<string | undefined>\n): ComputedRef<MessageMetadata | undefined> {\n const store = stream[STREAM_CONTROLLER].messageMetadataStore;\n const mapRef = shallowRef<MessageMetadataMap>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n mapRef.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return computed<MessageMetadata | undefined>(() => {\n const key = toValue(messageId);\n if (key == null) return undefined;\n return mapRef.value.get(key);\n });\n}\n\n/**\n * Reactive handle on the server-side submission queue.\n *\n * Populated when `submit()` is invoked with\n * `multitaskStrategy: \"enqueue\"` while another run is in flight. The\n * returned refs are shared per call — safe to pass into `v-for`.\n */\nexport interface UseSubmissionQueueReturn<\n StateType extends object = Record<string, unknown>,\n> {\n readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;\n readonly size: ComputedRef<number>;\n cancel(id: string): Promise<boolean>;\n clear(): Promise<void>;\n}\n\nexport function useSubmissionQueue<StateType extends object>(\n stream: StreamHandle<StateType>\n): UseSubmissionQueueReturn<StateType>;\nexport function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;\nexport function useSubmissionQueue(\n stream: AnyStream\n): UseSubmissionQueueReturn {\n const controller = stream[STREAM_CONTROLLER];\n const store = controller.queueStore;\n const entries = shallowRef<SubmissionQueueSnapshot>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n entries.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return {\n entries: readonly(entries) as Readonly<ShallowRef<SubmissionQueueSnapshot>>,\n size: computed(() => entries.value.length),\n cancel: (id) => controller.cancelQueued(id),\n clear: () => controller.clearQueue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,aAAa,GAAG;EAC3C,aAAa,WAAW,YAAY;EACrC"}
1
+ {"version":3,"file":"selectors.js","names":[],"sources":["../src/selectors.ts"],"sourcesContent":["import {\n computed,\n onScopeDispose,\n readonly,\n shallowRef,\n toValue,\n watchEffect,\n type ComputedRef,\n type MaybeRefOrGetter,\n type ShallowRef,\n} from \"vue\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport {\n NAMESPACE_SEPARATOR,\n audioProjection,\n channelProjection,\n extensionProjection,\n filesProjection,\n imagesProjection,\n messagesProjection,\n toolCallsProjection,\n valuesProjection,\n videoProjection,\n type AssembledToolCall,\n type AudioMedia,\n type Channel,\n type ChannelProjectionOptions,\n type Event,\n type FileMedia,\n type ImageMedia,\n type InferToolCalls,\n type InferStateType,\n type MessageMetadata,\n type MessageMetadataMap,\n type SubagentDiscoverySnapshot,\n type SubgraphDiscoverySnapshot,\n type SubmissionQueueEntry,\n type SubmissionQueueSnapshot,\n type VideoMedia,\n} from \"@langchain/langgraph-sdk/stream\";\nimport {\n getRegistry,\n STREAM_CONTROLLER,\n type AnyStream,\n type UseStreamReturn,\n} from \"./use-stream.js\";\nimport { useProjection } from \"./use-projection.js\";\n\n/**\n * Selector composables don't need to carry `InterruptType` /\n * `ConfigurableType`. Parameterising on `StateType` alone lets\n * callers with a full `useStream<S, I, C>()` handle pass it in without\n * redeclaring those generics at every call site.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamHandle<StateType extends object> = UseStreamReturn<\n StateType,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * What a selector composable can be targeted at. Callers can pass:\n * - `undefined` / `null` — root namespace (served by the always-on\n * root store — no extra subscription);\n * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);\n * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);\n * - an explicit `{ namespace: string[] }`;\n * - a raw `string[]` escape hatch.\n */\nexport type SelectorTarget =\n | undefined\n | null\n | readonly string[]\n | { namespace: readonly string[] }\n | SubagentDiscoverySnapshot\n | SubgraphDiscoverySnapshot;\n\nconst EMPTY_NAMESPACE: readonly string[] = [];\n\nfunction resolveNamespace(target: SelectorTarget): readonly string[] {\n if (target == null) return EMPTY_NAMESPACE;\n if (Array.isArray(target)) return target as readonly string[];\n const obj = target as { namespace?: readonly string[] };\n return obj.namespace ?? EMPTY_NAMESPACE;\n}\n\nfunction isRoot(namespace: readonly string[]): boolean {\n return namespace.length === 0;\n}\n\n/**\n * If `target` is a subagent snapshot still on its default\n * `tools:<toolCallId>` namespace, return that tool-call id. See the\n * React selectors for the rationale (deep-agent subagents execute under\n * a distinct `tools:<uuid>` namespace resolved lazily from history).\n */\nfunction subagentNeedingNamespace(target: SelectorTarget): string | null {\n if (target == null || Array.isArray(target)) return null;\n const obj = target as { id?: unknown; namespace?: readonly string[] };\n if (typeof obj.id !== \"string\" || !Array.isArray(obj.namespace)) return null;\n if (obj.namespace.length === 1 && obj.namespace[0] === `tools:${obj.id}`) {\n return obj.id;\n }\n return null;\n}\n\n/**\n * Lazily resolve a subagent's execution namespace on first scoped use.\n * Re-evaluates if `target` changes; the controller de-dupes and skips\n * already-promoted ids so this is cheap to call from every consumer.\n */\nfunction useResolveSubagentNamespace(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): void {\n const controller = stream[STREAM_CONTROLLER];\n watchEffect(() => {\n const id = subagentNeedingNamespace(toValue(target));\n if (id != null) void controller.resolveSubagentNamespace(id);\n });\n}\n\nfunction namespaceKey(namespace: readonly string[]): string {\n return namespace.join(NAMESPACE_SEPARATOR);\n}\n\n/**\n * Subscribe to a scoped `messages` stream.\n *\n * Contract:\n * - At the root (no `target`) this returns `stream.messages` — the\n * always-on root projection; no extra subscription is opened.\n * - For any non-root namespace, mount triggers a ref-counted\n * `messages` subscription scoped to that namespace. The\n * subscription is released automatically when the calling scope\n * disappears (and the registry closes the underlying server\n * subscription when the last consumer leaves).\n *\n * Messages are always `BaseMessage` class instances from\n * `@langchain/core/messages`.\n */\nexport function useMessages(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<BaseMessage[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.messages;\n const key = computed(() => `messages|${namespaceKey(namespace.value)}`);\n return useProjection<BaseMessage[]>(\n getRegistry(stream),\n () => messagesProjection(namespace.value),\n key,\n EMPTY_MESSAGES\n );\n}\n\nconst EMPTY_MESSAGES: BaseMessage[] = [];\n\n/**\n * Subscribe to a scoped `tools` (tool-call) stream. Same target and\n * lifecycle rules as {@link useMessages}; at the root this returns\n * `stream.toolCalls` directly.\n */\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>>;\nexport function useToolCalls<T>(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<InferToolCalls<T>[]>>;\nexport function useToolCalls(\n stream: AnyStream,\n target?: MaybeRefOrGetter<SelectorTarget>\n): Readonly<ShallowRef<AssembledToolCall[]>> {\n useResolveSubagentNamespace(stream, target);\n const namespace = computed(() => resolveNamespace(toValue(target)));\n if (isRoot(namespace.value)) return stream.toolCalls;\n const key = computed(() => `toolCalls|${namespaceKey(namespace.value)}`);\n return useProjection<AssembledToolCall[]>(\n getRegistry(stream),\n () => toolCallsProjection(namespace.value),\n key,\n EMPTY_TOOLCALLS\n );\n}\n\nconst EMPTY_TOOLCALLS: AssembledToolCall[] = [];\n\n/**\n * Subscribe to a scoped `values` stream — the most recent state\n * payload for a namespace. At the root returns `stream.values`.\n *\n * Typing:\n * - **Root** (`useValues(stream)`): returns the `StateType` declared\n * on `useStream<State>()` — non-nullable (the root snapshot always\n * has values, falling back to `initialValues ?? {}`).\n * - **Scoped** (`useValues(stream, target)`): scoped payloads can\n * differ from the root state; callers should annotate the\n * expected shape explicitly (`useValues<SubagentState>(stream,\n * sub)`). Defaults to `unknown` when not annotated.\n */\nexport function useValues<StateType extends object>(\n stream: StreamHandle<StateType>\n): Readonly<ShallowRef<StateType>>;\nexport function useValues<T>(\n stream: AnyStream\n): Readonly<ShallowRef<InferStateType<T>>>;\nexport function useValues<T = unknown>(\n stream: AnyStream,\n target: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<T | undefined>>;\nexport function useValues(\n stream: AnyStream,\n target?: SelectorTarget,\n options?: { messagesKey?: string }\n): Readonly<ShallowRef<unknown>> {\n const namespace = resolveNamespace(target);\n if (isRoot(namespace)) return stream.values as Readonly<ShallowRef<unknown>>;\n const messagesKey = options?.messagesKey ?? \"messages\";\n const key = `values|${messagesKey}|${namespaceKey(namespace)}`;\n return useProjection<unknown>(\n getRegistry(stream),\n () => valuesProjection<unknown>(namespace, messagesKey),\n key,\n undefined\n );\n}\n\n/**\n * Subscribe to a `custom:<name>` stream extension — the most-recent\n * payload emitted by the transformer, scoped to the target namespace.\n *\n * Returns only the latest value and resumes across serial runs, so it is\n * ideal for \"current state\" panels (progress, score, status). When you\n * need the full history of events rather than just the latest payload,\n * use {@link useChannel} instead.\n */\nexport function useExtension<T = unknown>(\n stream: AnyStream,\n name: string,\n target?: SelectorTarget\n): Readonly<ShallowRef<T | undefined>> {\n const namespace = resolveNamespace(target);\n const key = `extension|${name}|${namespaceKey(namespace)}`;\n return useProjection<T | undefined>(\n getRegistry(stream),\n () => extensionProjection<T>(name, namespace),\n key,\n undefined\n );\n}\n\n/**\n * Raw-events escape hatch. Subscribes to one or more channels at a\n * namespace and returns a bounded buffer of raw protocol events.\n *\n * The buffer keeps accumulating across serial runs for the lifetime of\n * the thread, so this is the hook to use for an event log / stream of a\n * custom channel (e.g. `[\"custom:redaction-stats\"]`). When you only need\n * the latest payload of a single `custom:<name>` channel, prefer\n * {@link useExtension}. For the common message/tool/value cases prefer\n * {@link useMessages} / {@link useToolCalls} / {@link useValues}.\n */\nexport type UseChannelOptions = ChannelProjectionOptions;\n\nexport function useChannel(\n stream: AnyStream,\n channels: readonly Channel[],\n target?: SelectorTarget,\n options?: UseChannelOptions\n): Readonly<ShallowRef<Event[]>> {\n const namespace = resolveNamespace(target);\n const sortedChannels = [...channels].sort().join(\",\");\n const key = `channel|${options?.bufferSize ?? \"default\"}|${(options?.replay ?? true) ? \"replay\" : \"live\"}|${sortedChannels}|${namespaceKey(namespace)}`;\n return useProjection<Event[]>(\n getRegistry(stream),\n () => channelProjection(channels, namespace, options),\n key,\n EMPTY_EVENTS\n );\n}\n\nconst EMPTY_EVENTS: Event[] = [];\n\n/**\n * Subscribe to a scoped audio-media stream. Each handle is yielded\n * on its first matching `content-block-start`, exposes\n * `.partialBytes` for live access, settles `.blob` / `.objectURL` /\n * `.transcript` on `message-finish`, and surfaces errors via\n * `.error`.\n */\nexport function useAudio(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<AudioMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `audio|${namespaceKey(namespace)}`;\n return useProjection<AudioMedia[]>(\n getRegistry(stream),\n () => audioProjection(namespace),\n key,\n EMPTY_AUDIO\n );\n}\n\nconst EMPTY_AUDIO: AudioMedia[] = [];\n\n/**\n * Subscribe to a scoped image-media stream. Pair with\n * {@link useMediaURL} for `<img src>`.\n */\nexport function useImages(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<ImageMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `images|${namespaceKey(namespace)}`;\n return useProjection<ImageMedia[]>(\n getRegistry(stream),\n () => imagesProjection(namespace),\n key,\n EMPTY_IMAGES\n );\n}\n\nconst EMPTY_IMAGES: ImageMedia[] = [];\n\n/**\n * Subscribe to a scoped video-media stream. Pair with\n * {@link useMediaURL} for `<video src>`.\n */\nexport function useVideo(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<VideoMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `video|${namespaceKey(namespace)}`;\n return useProjection<VideoMedia[]>(\n getRegistry(stream),\n () => videoProjection(namespace),\n key,\n EMPTY_VIDEO\n );\n}\n\nconst EMPTY_VIDEO: VideoMedia[] = [];\n\n/**\n * Subscribe to a scoped file-media stream. Pair with\n * {@link useMediaURL} for an `<a download href>` target.\n */\nexport function useFiles(\n stream: AnyStream,\n target?: SelectorTarget\n): Readonly<ShallowRef<FileMedia[]>> {\n const namespace = resolveNamespace(target);\n const key = `files|${namespaceKey(namespace)}`;\n return useProjection<FileMedia[]>(\n getRegistry(stream),\n () => filesProjection(namespace),\n key,\n EMPTY_FILES\n );\n}\n\nconst EMPTY_FILES: FileMedia[] = [];\n\n/**\n * Read metadata recorded for a specific message id — today exposes\n * `parentCheckpointId`, the checkpoint the message was first seen on.\n * Designed for fork / edit flows:\n *\n * ```ts\n * const meta = useMessageMetadata(stream, () => msg.id);\n * // meta.value?.parentCheckpointId\n * ```\n *\n * `messageId` accepts a raw string, a `Ref<string | undefined>`, or\n * a getter — the binding re-evaluates whenever the id changes.\n */\nexport function useMessageMetadata(\n stream: AnyStream,\n messageId: MaybeRefOrGetter<string | undefined>\n): ComputedRef<MessageMetadata | undefined> {\n const store = stream[STREAM_CONTROLLER].messageMetadataStore;\n const mapRef = shallowRef<MessageMetadataMap>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n mapRef.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return computed<MessageMetadata | undefined>(() => {\n const key = toValue(messageId);\n if (key == null) return undefined;\n return mapRef.value.get(key);\n });\n}\n\n/**\n * Reactive handle on the server-side submission queue.\n *\n * Populated when `submit()` is invoked with\n * `multitaskStrategy: \"enqueue\"` while another run is in flight. The\n * returned refs are shared per call — safe to pass into `v-for`.\n */\nexport interface UseSubmissionQueueReturn<\n StateType extends object = Record<string, unknown>,\n> {\n readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;\n readonly size: ComputedRef<number>;\n cancel(id: string): Promise<boolean>;\n clear(): Promise<void>;\n}\n\nexport function useSubmissionQueue<StateType extends object>(\n stream: StreamHandle<StateType>\n): UseSubmissionQueueReturn<StateType>;\nexport function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;\nexport function useSubmissionQueue(\n stream: AnyStream\n): UseSubmissionQueueReturn {\n const controller = stream[STREAM_CONTROLLER];\n const store = controller.queueStore;\n const entries = shallowRef<SubmissionQueueSnapshot>(store.getSnapshot());\n const unsubscribe = store.subscribe(() => {\n entries.value = store.getSnapshot();\n });\n onScopeDispose(unsubscribe);\n\n return {\n entries: readonly(entries) as Readonly<ShallowRef<SubmissionQueueSnapshot>>,\n size: computed(() => entries.value.length),\n cancel: (id) => controller.cancelQueued(id),\n clear: () => controller.clearQueue(),\n };\n}\n\nexport type { SubmissionQueueEntry, SubmissionQueueSnapshot };\n"],"mappings":";;;;;AAgFA,MAAM,kBAAqC,EAAE;AAE7C,SAAS,iBAAiB,QAA2C;AACnE,KAAI,UAAU,KAAM,QAAO;AAC3B,KAAI,MAAM,QAAQ,OAAO,CAAE,QAAO;AAElC,QADY,OACD,aAAa;;AAG1B,SAAS,OAAO,WAAuC;AACrD,QAAO,UAAU,WAAW;;;;;;;;AAS9B,SAAS,yBAAyB,QAAuC;AACvE,KAAI,UAAU,QAAQ,MAAM,QAAQ,OAAO,CAAE,QAAO;CACpD,MAAM,MAAM;AACZ,KAAI,OAAO,IAAI,OAAO,YAAY,CAAC,MAAM,QAAQ,IAAI,UAAU,CAAE,QAAO;AACxE,KAAI,IAAI,UAAU,WAAW,KAAK,IAAI,UAAU,OAAO,SAAS,IAAI,KAClE,QAAO,IAAI;AAEb,QAAO;;;;;;;AAQT,SAAS,4BACP,QACA,QACM;CACN,MAAM,aAAa,OAAO;AAC1B,mBAAkB;EAChB,MAAM,KAAK,yBAAyB,QAAQ,OAAO,CAAC;AACpD,MAAI,MAAM,KAAW,YAAW,yBAA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B,MAAM,aAAa,CAAC;AAIlE,gBAHoB,MAAM,gBAAgB;AACxC,SAAO,QAAQ,MAAM,aAAa;GAClC,CACyB;AAE3B,QAAO,eAA4C;EACjD,MAAM,MAAM,QAAQ,UAAU;AAC9B,MAAI,OAAO,KAAM,QAAO,KAAA;AACxB,SAAO,OAAO,MAAM,IAAI,IAAI;GAC5B;;AAuBJ,SAAgB,mBACd,QAC0B;CAC1B,MAAM,aAAa,OAAO;CAC1B,MAAM,QAAQ,WAAW;CACzB,MAAM,UAAU,WAAoC,MAAM,aAAa,CAAC;AAIxE,gBAHoB,MAAM,gBAAgB;AACxC,UAAQ,QAAQ,MAAM,aAAa;GACnC,CACyB;AAE3B,QAAO;EACL,SAAS,SAAS,QAAQ;EAC1B,MAAM,eAAe,QAAQ,MAAM,OAAO;EAC1C,SAAS,OAAO,WAAW,aAAa,GAAG;EAC3C,aAAa,WAAW,YAAY;EACrC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/vue",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "Vue integration for LangGraph & LangChain",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  "directory": "libs/sdk-vue"
11
11
  },
12
12
  "dependencies": {
13
- "@langchain/langgraph-sdk": "1.9.17"
13
+ "@langchain/langgraph-sdk": "1.9.18"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@hono/node-server": "^1.19.13",