@langchain/vue 0.4.7 → 1.0.0

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.
Files changed (74) hide show
  1. package/README.md +84 -364
  2. package/dist/context.cjs +2 -2
  3. package/dist/context.cjs.map +1 -1
  4. package/dist/context.d.cts +4 -5
  5. package/dist/context.d.cts.map +1 -1
  6. package/dist/context.d.ts +4 -5
  7. package/dist/context.d.ts.map +1 -1
  8. package/dist/context.js +1 -1
  9. package/dist/context.js.map +1 -1
  10. package/dist/index.cjs +30 -222
  11. package/dist/index.d.cts +10 -24
  12. package/dist/index.d.ts +10 -24
  13. package/dist/index.js +9 -198
  14. package/dist/selectors.cjs +170 -0
  15. package/dist/selectors.cjs.map +1 -0
  16. package/dist/selectors.d.cts +133 -0
  17. package/dist/selectors.d.cts.map +1 -0
  18. package/dist/selectors.d.ts +133 -0
  19. package/dist/selectors.d.ts.map +1 -0
  20. package/dist/selectors.js +160 -0
  21. package/dist/selectors.js.map +1 -0
  22. package/dist/use-audio-player.cjs +591 -0
  23. package/dist/use-audio-player.cjs.map +1 -0
  24. package/dist/use-audio-player.d.cts +69 -0
  25. package/dist/use-audio-player.d.cts.map +1 -0
  26. package/dist/use-audio-player.d.ts +69 -0
  27. package/dist/use-audio-player.d.ts.map +1 -0
  28. package/dist/use-audio-player.js +591 -0
  29. package/dist/use-audio-player.js.map +1 -0
  30. package/dist/use-media-url.cjs +51 -0
  31. package/dist/use-media-url.cjs.map +1 -0
  32. package/dist/use-media-url.d.cts +29 -0
  33. package/dist/use-media-url.d.cts.map +1 -0
  34. package/dist/use-media-url.d.ts +29 -0
  35. package/dist/use-media-url.d.ts.map +1 -0
  36. package/dist/use-media-url.js +51 -0
  37. package/dist/use-media-url.js.map +1 -0
  38. package/dist/use-projection.cjs +66 -0
  39. package/dist/use-projection.cjs.map +1 -0
  40. package/dist/use-projection.d.cts +39 -0
  41. package/dist/use-projection.d.cts.map +1 -0
  42. package/dist/use-projection.d.ts +39 -0
  43. package/dist/use-projection.d.ts.map +1 -0
  44. package/dist/use-projection.js +66 -0
  45. package/dist/use-projection.js.map +1 -0
  46. package/dist/use-stream.cjs +169 -0
  47. package/dist/use-stream.cjs.map +1 -0
  48. package/dist/use-stream.d.cts +118 -0
  49. package/dist/use-stream.d.cts.map +1 -0
  50. package/dist/use-stream.d.ts +118 -0
  51. package/dist/use-stream.d.ts.map +1 -0
  52. package/dist/use-stream.js +167 -0
  53. package/dist/use-stream.js.map +1 -0
  54. package/dist/use-video-player.cjs +212 -0
  55. package/dist/use-video-player.cjs.map +1 -0
  56. package/dist/use-video-player.d.cts +57 -0
  57. package/dist/use-video-player.d.cts.map +1 -0
  58. package/dist/use-video-player.d.ts +57 -0
  59. package/dist/use-video-player.d.ts.map +1 -0
  60. package/dist/use-video-player.js +212 -0
  61. package/dist/use-video-player.js.map +1 -0
  62. package/package.json +10 -8
  63. package/dist/index.cjs.map +0 -1
  64. package/dist/index.d.cts.map +0 -1
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/index.js.map +0 -1
  67. package/dist/stream.custom.cjs +0 -133
  68. package/dist/stream.custom.cjs.map +0 -1
  69. package/dist/stream.custom.js +0 -133
  70. package/dist/stream.custom.js.map +0 -1
  71. package/dist/subagents.cjs +0 -76
  72. package/dist/subagents.cjs.map +0 -1
  73. package/dist/subagents.js +0 -76
  74. package/dist/subagents.js.map +0 -1
@@ -0,0 +1,170 @@
1
+ const require_use_stream = require("./use-stream.cjs");
2
+ const require_use_projection = require("./use-projection.cjs");
3
+ let vue = require("vue");
4
+ let _langchain_langgraph_sdk_stream = require("@langchain/langgraph-sdk/stream");
5
+ //#region src/selectors.ts
6
+ const EMPTY_NAMESPACE = [];
7
+ function resolveNamespace(target) {
8
+ if (target == null) return EMPTY_NAMESPACE;
9
+ if (Array.isArray(target)) return target;
10
+ return target.namespace ?? EMPTY_NAMESPACE;
11
+ }
12
+ function isRoot(namespace) {
13
+ return namespace.length === 0;
14
+ }
15
+ function namespaceKey(namespace) {
16
+ return namespace.join(_langchain_langgraph_sdk_stream.NAMESPACE_SEPARATOR);
17
+ }
18
+ /**
19
+ * Subscribe to a scoped `messages` stream.
20
+ *
21
+ * Contract:
22
+ * - At the root (no `target`) this returns `stream.messages` — the
23
+ * always-on root projection; no extra subscription is opened.
24
+ * - For any non-root namespace, mount triggers a ref-counted
25
+ * `messages` subscription scoped to that namespace. The
26
+ * subscription is released automatically when the calling scope
27
+ * disappears (and the registry closes the underlying server
28
+ * subscription when the last consumer leaves).
29
+ *
30
+ * Messages are always `BaseMessage` class instances from
31
+ * `@langchain/core/messages`.
32
+ */
33
+ function useMessages(stream, target) {
34
+ const namespace = (0, vue.computed)(() => resolveNamespace((0, vue.toValue)(target)));
35
+ if (isRoot(namespace.value)) return stream.messages;
36
+ const key = (0, vue.computed)(() => `messages|${namespaceKey(namespace.value)}`);
37
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.messagesProjection)(namespace.value), key, EMPTY_MESSAGES);
38
+ }
39
+ const EMPTY_MESSAGES = [];
40
+ /**
41
+ * Subscribe to a scoped `tools` (tool-call) stream. Same target and
42
+ * lifecycle rules as {@link useMessages}; at the root this returns
43
+ * `stream.toolCalls` directly.
44
+ */
45
+ function useToolCalls(stream, target) {
46
+ const namespace = (0, vue.computed)(() => resolveNamespace((0, vue.toValue)(target)));
47
+ if (isRoot(namespace.value)) return stream.toolCalls;
48
+ const key = (0, vue.computed)(() => `toolCalls|${namespaceKey(namespace.value)}`);
49
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.toolCallsProjection)(namespace.value), key, EMPTY_TOOLCALLS);
50
+ }
51
+ const EMPTY_TOOLCALLS = [];
52
+ function useValues(stream, target, options) {
53
+ const namespace = resolveNamespace(target);
54
+ if (isRoot(namespace)) return stream.values;
55
+ const messagesKey = options?.messagesKey ?? "messages";
56
+ const key = `values|${messagesKey}|${namespaceKey(namespace)}`;
57
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.valuesProjection)(namespace, messagesKey), key, void 0);
58
+ }
59
+ /**
60
+ * Subscribe to a `custom:<name>` stream extension — most-recent
61
+ * payload emitted by the transformer, scoped to the target namespace.
62
+ */
63
+ function useExtension(stream, name, target) {
64
+ const namespace = resolveNamespace(target);
65
+ const key = `extension|${name}|${namespaceKey(namespace)}`;
66
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.extensionProjection)(name, namespace), key, void 0);
67
+ }
68
+ function useChannel(stream, channels, target, options) {
69
+ const namespace = resolveNamespace(target);
70
+ const sortedChannels = [...channels].sort().join(",");
71
+ const key = `channel|${options?.bufferSize ?? "default"}|${options?.replay ?? true ? "replay" : "live"}|${sortedChannels}|${namespaceKey(namespace)}`;
72
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.channelProjection)(channels, namespace, options), key, EMPTY_EVENTS);
73
+ }
74
+ const EMPTY_EVENTS = [];
75
+ /**
76
+ * Subscribe to a scoped audio-media stream. Each handle is yielded
77
+ * on its first matching `content-block-start`, exposes
78
+ * `.partialBytes` for live access, settles `.blob` / `.objectURL` /
79
+ * `.transcript` on `message-finish`, and surfaces errors via
80
+ * `.error`.
81
+ */
82
+ function useAudio(stream, target) {
83
+ const namespace = resolveNamespace(target);
84
+ const key = `audio|${namespaceKey(namespace)}`;
85
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.audioProjection)(namespace), key, EMPTY_AUDIO);
86
+ }
87
+ const EMPTY_AUDIO = [];
88
+ /**
89
+ * Subscribe to a scoped image-media stream. Pair with
90
+ * {@link useMediaURL} for `<img src>`.
91
+ */
92
+ function useImages(stream, target) {
93
+ const namespace = resolveNamespace(target);
94
+ const key = `images|${namespaceKey(namespace)}`;
95
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.imagesProjection)(namespace), key, EMPTY_IMAGES);
96
+ }
97
+ const EMPTY_IMAGES = [];
98
+ /**
99
+ * Subscribe to a scoped video-media stream. Pair with
100
+ * {@link useMediaURL} for `<video src>`.
101
+ */
102
+ function useVideo(stream, target) {
103
+ const namespace = resolveNamespace(target);
104
+ const key = `video|${namespaceKey(namespace)}`;
105
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.videoProjection)(namespace), key, EMPTY_VIDEO);
106
+ }
107
+ const EMPTY_VIDEO = [];
108
+ /**
109
+ * Subscribe to a scoped file-media stream. Pair with
110
+ * {@link useMediaURL} for an `<a download href>` target.
111
+ */
112
+ function useFiles(stream, target) {
113
+ const namespace = resolveNamespace(target);
114
+ const key = `files|${namespaceKey(namespace)}`;
115
+ return require_use_projection.useProjection(require_use_stream.getRegistry(stream), () => (0, _langchain_langgraph_sdk_stream.filesProjection)(namespace), key, EMPTY_FILES);
116
+ }
117
+ const EMPTY_FILES = [];
118
+ /**
119
+ * Read metadata recorded for a specific message id — today exposes
120
+ * `parentCheckpointId`, the checkpoint the message was first seen on.
121
+ * Designed for fork / edit flows:
122
+ *
123
+ * ```ts
124
+ * const meta = useMessageMetadata(stream, () => msg.id);
125
+ * // meta.value?.parentCheckpointId
126
+ * ```
127
+ *
128
+ * `messageId` accepts a raw string, a `Ref<string | undefined>`, or
129
+ * a getter — the binding re-evaluates whenever the id changes.
130
+ */
131
+ function useMessageMetadata(stream, messageId) {
132
+ const store = stream[require_use_stream.STREAM_CONTROLLER].messageMetadataStore;
133
+ const mapRef = (0, vue.shallowRef)(store.getSnapshot());
134
+ (0, vue.onScopeDispose)(store.subscribe(() => {
135
+ mapRef.value = store.getSnapshot();
136
+ }));
137
+ return (0, vue.computed)(() => {
138
+ const key = (0, vue.toValue)(messageId);
139
+ if (key == null) return void 0;
140
+ return mapRef.value.get(key);
141
+ });
142
+ }
143
+ function useSubmissionQueue(stream) {
144
+ const controller = stream[require_use_stream.STREAM_CONTROLLER];
145
+ const store = controller.queueStore;
146
+ const entries = (0, vue.shallowRef)(store.getSnapshot());
147
+ (0, vue.onScopeDispose)(store.subscribe(() => {
148
+ entries.value = store.getSnapshot();
149
+ }));
150
+ return {
151
+ entries: (0, vue.readonly)(entries),
152
+ size: (0, vue.computed)(() => entries.value.length),
153
+ cancel: (id) => controller.cancelQueued(id),
154
+ clear: () => controller.clearQueue()
155
+ };
156
+ }
157
+ //#endregion
158
+ exports.useAudio = useAudio;
159
+ exports.useChannel = useChannel;
160
+ exports.useExtension = useExtension;
161
+ exports.useFiles = useFiles;
162
+ exports.useImages = useImages;
163
+ exports.useMessageMetadata = useMessageMetadata;
164
+ exports.useMessages = useMessages;
165
+ exports.useSubmissionQueue = useSubmissionQueue;
166
+ exports.useToolCalls = useToolCalls;
167
+ exports.useValues = useValues;
168
+ exports.useVideo = useVideo;
169
+
170
+ //# sourceMappingURL=selectors.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.cjs","names":["NAMESPACE_SEPARATOR","useProjection","getRegistry","STREAM_CONTROLLER"],"sources":["../src/selectors.ts"],"sourcesContent":["import {\n computed,\n onScopeDispose,\n readonly,\n shallowRef,\n toValue,\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 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\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 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[]>> {\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.cancel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,SAAS,OAAO,WAAW,aAAa,GAAG;EAC3C,aAAa,WAAW,YAAY;EACrC"}
@@ -0,0 +1,133 @@
1
+ import { AnyStream, UseStreamReturn } from "./use-stream.cjs";
2
+ import { ComputedRef, MaybeRefOrGetter, ShallowRef } from "vue";
3
+ import { BaseMessage } from "@langchain/core/messages";
4
+ import { AssembledToolCall, AudioMedia, Channel, ChannelProjectionOptions, Event, FileMedia, ImageMedia, InferStateType, MessageMetadata, SubagentDiscoverySnapshot, SubgraphDiscoverySnapshot, SubmissionQueueEntry, SubmissionQueueSnapshot, VideoMedia } from "@langchain/langgraph-sdk/stream";
5
+
6
+ //#region src/selectors.d.ts
7
+ /**
8
+ * Selector composables don't need to carry `InterruptType` /
9
+ * `ConfigurableType`. Parameterising on `StateType` alone lets
10
+ * callers with a full `useStream<S, I, C>()` handle pass it in without
11
+ * redeclaring those generics at every call site.
12
+ */
13
+ type StreamHandle<StateType extends object> = UseStreamReturn<StateType, any, any>;
14
+ /**
15
+ * What a selector composable can be targeted at. Callers can pass:
16
+ * - `undefined` / `null` — root namespace (served by the always-on
17
+ * root store — no extra subscription);
18
+ * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);
19
+ * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);
20
+ * - an explicit `{ namespace: string[] }`;
21
+ * - a raw `string[]` escape hatch.
22
+ */
23
+ type SelectorTarget = undefined | null | readonly string[] | {
24
+ namespace: readonly string[];
25
+ } | SubagentDiscoverySnapshot | SubgraphDiscoverySnapshot;
26
+ /**
27
+ * Subscribe to a scoped `messages` stream.
28
+ *
29
+ * Contract:
30
+ * - At the root (no `target`) this returns `stream.messages` — the
31
+ * always-on root projection; no extra subscription is opened.
32
+ * - For any non-root namespace, mount triggers a ref-counted
33
+ * `messages` subscription scoped to that namespace. The
34
+ * subscription is released automatically when the calling scope
35
+ * disappears (and the registry closes the underlying server
36
+ * subscription when the last consumer leaves).
37
+ *
38
+ * Messages are always `BaseMessage` class instances from
39
+ * `@langchain/core/messages`.
40
+ */
41
+ declare function useMessages(stream: AnyStream, target?: MaybeRefOrGetter<SelectorTarget>): Readonly<ShallowRef<BaseMessage[]>>;
42
+ /**
43
+ * Subscribe to a scoped `tools` (tool-call) stream. Same target and
44
+ * lifecycle rules as {@link useMessages}; at the root this returns
45
+ * `stream.toolCalls` directly.
46
+ */
47
+ declare function useToolCalls(stream: AnyStream, target?: MaybeRefOrGetter<SelectorTarget>): Readonly<ShallowRef<AssembledToolCall[]>>;
48
+ /**
49
+ * Subscribe to a scoped `values` stream — the most recent state
50
+ * payload for a namespace. At the root returns `stream.values`.
51
+ *
52
+ * Typing:
53
+ * - **Root** (`useValues(stream)`): returns the `StateType` declared
54
+ * on `useStream<State>()` — non-nullable (the root snapshot always
55
+ * has values, falling back to `initialValues ?? {}`).
56
+ * - **Scoped** (`useValues(stream, target)`): scoped payloads can
57
+ * differ from the root state; callers should annotate the
58
+ * expected shape explicitly (`useValues<SubagentState>(stream,
59
+ * sub)`). Defaults to `unknown` when not annotated.
60
+ */
61
+ declare function useValues<StateType extends object>(stream: StreamHandle<StateType>): Readonly<ShallowRef<StateType>>;
62
+ declare function useValues<T>(stream: AnyStream): Readonly<ShallowRef<InferStateType<T>>>;
63
+ declare function useValues<T = unknown>(stream: AnyStream, target: SelectorTarget, options?: {
64
+ messagesKey?: string;
65
+ }): Readonly<ShallowRef<T | undefined>>;
66
+ /**
67
+ * Subscribe to a `custom:<name>` stream extension — most-recent
68
+ * payload emitted by the transformer, scoped to the target namespace.
69
+ */
70
+ declare function useExtension<T = unknown>(stream: AnyStream, name: string, target?: SelectorTarget): Readonly<ShallowRef<T | undefined>>;
71
+ /**
72
+ * Raw-events escape hatch. Subscribes to one or more channels at a
73
+ * namespace and returns a bounded buffer of raw protocol events.
74
+ * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}
75
+ * for the common cases.
76
+ */
77
+ type UseChannelOptions = ChannelProjectionOptions;
78
+ declare function useChannel(stream: AnyStream, channels: readonly Channel[], target?: SelectorTarget, options?: UseChannelOptions): Readonly<ShallowRef<Event[]>>;
79
+ /**
80
+ * Subscribe to a scoped audio-media stream. Each handle is yielded
81
+ * on its first matching `content-block-start`, exposes
82
+ * `.partialBytes` for live access, settles `.blob` / `.objectURL` /
83
+ * `.transcript` on `message-finish`, and surfaces errors via
84
+ * `.error`.
85
+ */
86
+ declare function useAudio(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<AudioMedia[]>>;
87
+ /**
88
+ * Subscribe to a scoped image-media stream. Pair with
89
+ * {@link useMediaURL} for `<img src>`.
90
+ */
91
+ declare function useImages(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<ImageMedia[]>>;
92
+ /**
93
+ * Subscribe to a scoped video-media stream. Pair with
94
+ * {@link useMediaURL} for `<video src>`.
95
+ */
96
+ declare function useVideo(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<VideoMedia[]>>;
97
+ /**
98
+ * Subscribe to a scoped file-media stream. Pair with
99
+ * {@link useMediaURL} for an `<a download href>` target.
100
+ */
101
+ declare function useFiles(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<FileMedia[]>>;
102
+ /**
103
+ * Read metadata recorded for a specific message id — today exposes
104
+ * `parentCheckpointId`, the checkpoint the message was first seen on.
105
+ * Designed for fork / edit flows:
106
+ *
107
+ * ```ts
108
+ * const meta = useMessageMetadata(stream, () => msg.id);
109
+ * // meta.value?.parentCheckpointId
110
+ * ```
111
+ *
112
+ * `messageId` accepts a raw string, a `Ref<string | undefined>`, or
113
+ * a getter — the binding re-evaluates whenever the id changes.
114
+ */
115
+ declare function useMessageMetadata(stream: AnyStream, messageId: MaybeRefOrGetter<string | undefined>): ComputedRef<MessageMetadata | undefined>;
116
+ /**
117
+ * Reactive handle on the server-side submission queue.
118
+ *
119
+ * Populated when `submit()` is invoked with
120
+ * `multitaskStrategy: "enqueue"` while another run is in flight. The
121
+ * returned refs are shared per call — safe to pass into `v-for`.
122
+ */
123
+ interface UseSubmissionQueueReturn<StateType extends object = Record<string, unknown>> {
124
+ readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;
125
+ readonly size: ComputedRef<number>;
126
+ cancel(id: string): Promise<boolean>;
127
+ clear(): Promise<void>;
128
+ }
129
+ declare function useSubmissionQueue<StateType extends object>(stream: StreamHandle<StateType>): UseSubmissionQueueReturn<StateType>;
130
+ declare function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;
131
+ //#endregion
132
+ export { SelectorTarget, type SubmissionQueueEntry, type SubmissionQueueSnapshot, UseSubmissionQueueReturn, useAudio, useChannel, useExtension, useFiles, useImages, useMessageMetadata, useMessages, useSubmissionQueue, useToolCalls, useValues, useVideo };
133
+ //# sourceMappingURL=selectors.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.cts","names":[],"sources":["../src/selectors.ts"],"mappings":";;;;;;;;AA2CyB;;;;KAUpB,YAAA,6BAAyC,eAAA,CAC5C,SAAA;;;;;AAgBF;;;;;KAAY,cAAA;EAIN,SAAA;AAAA,IACF,yBAAA,GACA,yBAAA;;AAkCJ;;;;;;;;;;;;;;iBAAgB,WAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,GAAS,gBAAA,CAAiB,cAAA,IACzB,QAAA,CAAS,UAAA,CAAW,WAAA;;;;;;iBAmBP,YAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,GAAS,gBAAA,CAAiB,cAAA,IACzB,QAAA,CAAS,UAAA,CAAW,iBAAA;AAHvB;;;;;;;;;;;;;AAAA,iBA8BgB,SAAA,0BAAA,CACd,MAAA,EAAQ,YAAA,CAAa,SAAA,IACpB,QAAA,CAAS,UAAA,CAAW,SAAA;AAAA,iBACP,SAAA,GAAA,CACd,MAAA,EAAQ,SAAA,GACP,QAAA,CAAS,UAAA,CAAW,cAAA,CAAe,CAAA;AAAA,iBACtB,SAAA,aAAA,CACd,MAAA,EAAQ,SAAA,E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AAA,CAAmB,MAAA,EAAQ,SAAA,GAAY,wBAAA"}
@@ -0,0 +1,133 @@
1
+ import { AnyStream, UseStreamReturn } from "./use-stream.js";
2
+ import { ComputedRef, MaybeRefOrGetter, ShallowRef } from "vue";
3
+ import { AssembledToolCall, AudioMedia, Channel, ChannelProjectionOptions, Event, FileMedia, ImageMedia, InferStateType, MessageMetadata, SubagentDiscoverySnapshot, SubgraphDiscoverySnapshot, SubmissionQueueEntry, SubmissionQueueSnapshot, VideoMedia } from "@langchain/langgraph-sdk/stream";
4
+ import { BaseMessage } from "@langchain/core/messages";
5
+
6
+ //#region src/selectors.d.ts
7
+ /**
8
+ * Selector composables don't need to carry `InterruptType` /
9
+ * `ConfigurableType`. Parameterising on `StateType` alone lets
10
+ * callers with a full `useStream<S, I, C>()` handle pass it in without
11
+ * redeclaring those generics at every call site.
12
+ */
13
+ type StreamHandle<StateType extends object> = UseStreamReturn<StateType, any, any>;
14
+ /**
15
+ * What a selector composable can be targeted at. Callers can pass:
16
+ * - `undefined` / `null` — root namespace (served by the always-on
17
+ * root store — no extra subscription);
18
+ * - a {@link SubagentDiscoverySnapshot} (`stream.subagents.value.get(...)`);
19
+ * - a {@link SubgraphDiscoverySnapshot} (`stream.subgraphs.value.get(...)`);
20
+ * - an explicit `{ namespace: string[] }`;
21
+ * - a raw `string[]` escape hatch.
22
+ */
23
+ type SelectorTarget = undefined | null | readonly string[] | {
24
+ namespace: readonly string[];
25
+ } | SubagentDiscoverySnapshot | SubgraphDiscoverySnapshot;
26
+ /**
27
+ * Subscribe to a scoped `messages` stream.
28
+ *
29
+ * Contract:
30
+ * - At the root (no `target`) this returns `stream.messages` — the
31
+ * always-on root projection; no extra subscription is opened.
32
+ * - For any non-root namespace, mount triggers a ref-counted
33
+ * `messages` subscription scoped to that namespace. The
34
+ * subscription is released automatically when the calling scope
35
+ * disappears (and the registry closes the underlying server
36
+ * subscription when the last consumer leaves).
37
+ *
38
+ * Messages are always `BaseMessage` class instances from
39
+ * `@langchain/core/messages`.
40
+ */
41
+ declare function useMessages(stream: AnyStream, target?: MaybeRefOrGetter<SelectorTarget>): Readonly<ShallowRef<BaseMessage[]>>;
42
+ /**
43
+ * Subscribe to a scoped `tools` (tool-call) stream. Same target and
44
+ * lifecycle rules as {@link useMessages}; at the root this returns
45
+ * `stream.toolCalls` directly.
46
+ */
47
+ declare function useToolCalls(stream: AnyStream, target?: MaybeRefOrGetter<SelectorTarget>): Readonly<ShallowRef<AssembledToolCall[]>>;
48
+ /**
49
+ * Subscribe to a scoped `values` stream — the most recent state
50
+ * payload for a namespace. At the root returns `stream.values`.
51
+ *
52
+ * Typing:
53
+ * - **Root** (`useValues(stream)`): returns the `StateType` declared
54
+ * on `useStream<State>()` — non-nullable (the root snapshot always
55
+ * has values, falling back to `initialValues ?? {}`).
56
+ * - **Scoped** (`useValues(stream, target)`): scoped payloads can
57
+ * differ from the root state; callers should annotate the
58
+ * expected shape explicitly (`useValues<SubagentState>(stream,
59
+ * sub)`). Defaults to `unknown` when not annotated.
60
+ */
61
+ declare function useValues<StateType extends object>(stream: StreamHandle<StateType>): Readonly<ShallowRef<StateType>>;
62
+ declare function useValues<T>(stream: AnyStream): Readonly<ShallowRef<InferStateType<T>>>;
63
+ declare function useValues<T = unknown>(stream: AnyStream, target: SelectorTarget, options?: {
64
+ messagesKey?: string;
65
+ }): Readonly<ShallowRef<T | undefined>>;
66
+ /**
67
+ * Subscribe to a `custom:<name>` stream extension — most-recent
68
+ * payload emitted by the transformer, scoped to the target namespace.
69
+ */
70
+ declare function useExtension<T = unknown>(stream: AnyStream, name: string, target?: SelectorTarget): Readonly<ShallowRef<T | undefined>>;
71
+ /**
72
+ * Raw-events escape hatch. Subscribes to one or more channels at a
73
+ * namespace and returns a bounded buffer of raw protocol events.
74
+ * Prefer {@link useMessages} / {@link useToolCalls} / {@link useValues}
75
+ * for the common cases.
76
+ */
77
+ type UseChannelOptions = ChannelProjectionOptions;
78
+ declare function useChannel(stream: AnyStream, channels: readonly Channel[], target?: SelectorTarget, options?: UseChannelOptions): Readonly<ShallowRef<Event[]>>;
79
+ /**
80
+ * Subscribe to a scoped audio-media stream. Each handle is yielded
81
+ * on its first matching `content-block-start`, exposes
82
+ * `.partialBytes` for live access, settles `.blob` / `.objectURL` /
83
+ * `.transcript` on `message-finish`, and surfaces errors via
84
+ * `.error`.
85
+ */
86
+ declare function useAudio(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<AudioMedia[]>>;
87
+ /**
88
+ * Subscribe to a scoped image-media stream. Pair with
89
+ * {@link useMediaURL} for `<img src>`.
90
+ */
91
+ declare function useImages(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<ImageMedia[]>>;
92
+ /**
93
+ * Subscribe to a scoped video-media stream. Pair with
94
+ * {@link useMediaURL} for `<video src>`.
95
+ */
96
+ declare function useVideo(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<VideoMedia[]>>;
97
+ /**
98
+ * Subscribe to a scoped file-media stream. Pair with
99
+ * {@link useMediaURL} for an `<a download href>` target.
100
+ */
101
+ declare function useFiles(stream: AnyStream, target?: SelectorTarget): Readonly<ShallowRef<FileMedia[]>>;
102
+ /**
103
+ * Read metadata recorded for a specific message id — today exposes
104
+ * `parentCheckpointId`, the checkpoint the message was first seen on.
105
+ * Designed for fork / edit flows:
106
+ *
107
+ * ```ts
108
+ * const meta = useMessageMetadata(stream, () => msg.id);
109
+ * // meta.value?.parentCheckpointId
110
+ * ```
111
+ *
112
+ * `messageId` accepts a raw string, a `Ref<string | undefined>`, or
113
+ * a getter — the binding re-evaluates whenever the id changes.
114
+ */
115
+ declare function useMessageMetadata(stream: AnyStream, messageId: MaybeRefOrGetter<string | undefined>): ComputedRef<MessageMetadata | undefined>;
116
+ /**
117
+ * Reactive handle on the server-side submission queue.
118
+ *
119
+ * Populated when `submit()` is invoked with
120
+ * `multitaskStrategy: "enqueue"` while another run is in flight. The
121
+ * returned refs are shared per call — safe to pass into `v-for`.
122
+ */
123
+ interface UseSubmissionQueueReturn<StateType extends object = Record<string, unknown>> {
124
+ readonly entries: Readonly<ShallowRef<SubmissionQueueSnapshot<StateType>>>;
125
+ readonly size: ComputedRef<number>;
126
+ cancel(id: string): Promise<boolean>;
127
+ clear(): Promise<void>;
128
+ }
129
+ declare function useSubmissionQueue<StateType extends object>(stream: StreamHandle<StateType>): UseSubmissionQueueReturn<StateType>;
130
+ declare function useSubmissionQueue(stream: AnyStream): UseSubmissionQueueReturn;
131
+ //#endregion
132
+ export { SelectorTarget, type SubmissionQueueEntry, type SubmissionQueueSnapshot, UseSubmissionQueueReturn, useAudio, useChannel, useExtension, useFiles, useImages, useMessageMetadata, useMessages, useSubmissionQueue, useToolCalls, useValues, useVideo };
133
+ //# sourceMappingURL=selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.ts","names":[],"sources":["../src/selectors.ts"],"mappings":";;;;;;;;AA2CyB;;;;KAUpB,YAAA,6BAAyC,eAAA,CAC5C,SAAA;;;;;AAgBF;;;;;KAAY,cAAA;EAIN,SAAA;AAAA,IACF,yBAAA,GACA,yBAAA;;AAkCJ;;;;;;;;;;;;;;iBAAgB,WAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,GAAS,gBAAA,CAAiB,cAAA,IACzB,QAAA,CAAS,UAAA,CAAW,WAAA;;;;;;iBAmBP,YAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,GAAS,gBAAA,CAAiB,cAAA,IACzB,QAAA,CAAS,UAAA,CAAW,iBAAA;AAHvB;;;;;;;;;;;;;AAAA,iBA8BgB,SAAA,0BAAA,CACd,MAAA,EAAQ,YAAA,CAAa,SAAA,IACpB,QAAA,CAAS,UAAA,CAAW,SAAA;AAAA,iBACP,SAAA,GAAA,CACd,MAAA,EAAQ,SAAA,GACP,QAAA,CAAS,UAAA,CAAW,cAAA,CAAe,CAAA;AAAA,iBACtB,SAAA,aAAA,CACd,MAAA,EAAQ,SAAA,EACR,MAAA,EAAQ,cAA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AQ,SAAA,GAAY,wBAAA"}
@@ -0,0 +1,160 @@
1
+ import { STREAM_CONTROLLER, getRegistry } from "./use-stream.js";
2
+ import { useProjection } from "./use-projection.js";
3
+ import { computed, onScopeDispose, readonly, shallowRef, toValue } from "vue";
4
+ import { NAMESPACE_SEPARATOR, audioProjection, channelProjection, extensionProjection, filesProjection, imagesProjection, messagesProjection, toolCallsProjection, valuesProjection, videoProjection } from "@langchain/langgraph-sdk/stream";
5
+ //#region src/selectors.ts
6
+ const EMPTY_NAMESPACE = [];
7
+ function resolveNamespace(target) {
8
+ if (target == null) return EMPTY_NAMESPACE;
9
+ if (Array.isArray(target)) return target;
10
+ return target.namespace ?? EMPTY_NAMESPACE;
11
+ }
12
+ function isRoot(namespace) {
13
+ return namespace.length === 0;
14
+ }
15
+ function namespaceKey(namespace) {
16
+ return namespace.join(NAMESPACE_SEPARATOR);
17
+ }
18
+ /**
19
+ * Subscribe to a scoped `messages` stream.
20
+ *
21
+ * Contract:
22
+ * - At the root (no `target`) this returns `stream.messages` — the
23
+ * always-on root projection; no extra subscription is opened.
24
+ * - For any non-root namespace, mount triggers a ref-counted
25
+ * `messages` subscription scoped to that namespace. The
26
+ * subscription is released automatically when the calling scope
27
+ * disappears (and the registry closes the underlying server
28
+ * subscription when the last consumer leaves).
29
+ *
30
+ * Messages are always `BaseMessage` class instances from
31
+ * `@langchain/core/messages`.
32
+ */
33
+ function useMessages(stream, target) {
34
+ const namespace = computed(() => resolveNamespace(toValue(target)));
35
+ if (isRoot(namespace.value)) return stream.messages;
36
+ const key = computed(() => `messages|${namespaceKey(namespace.value)}`);
37
+ return useProjection(getRegistry(stream), () => messagesProjection(namespace.value), key, EMPTY_MESSAGES);
38
+ }
39
+ const EMPTY_MESSAGES = [];
40
+ /**
41
+ * Subscribe to a scoped `tools` (tool-call) stream. Same target and
42
+ * lifecycle rules as {@link useMessages}; at the root this returns
43
+ * `stream.toolCalls` directly.
44
+ */
45
+ function useToolCalls(stream, target) {
46
+ const namespace = computed(() => resolveNamespace(toValue(target)));
47
+ if (isRoot(namespace.value)) return stream.toolCalls;
48
+ const key = computed(() => `toolCalls|${namespaceKey(namespace.value)}`);
49
+ return useProjection(getRegistry(stream), () => toolCallsProjection(namespace.value), key, EMPTY_TOOLCALLS);
50
+ }
51
+ const EMPTY_TOOLCALLS = [];
52
+ function useValues(stream, target, options) {
53
+ const namespace = resolveNamespace(target);
54
+ if (isRoot(namespace)) return stream.values;
55
+ const messagesKey = options?.messagesKey ?? "messages";
56
+ const key = `values|${messagesKey}|${namespaceKey(namespace)}`;
57
+ return useProjection(getRegistry(stream), () => valuesProjection(namespace, messagesKey), key, void 0);
58
+ }
59
+ /**
60
+ * Subscribe to a `custom:<name>` stream extension — most-recent
61
+ * payload emitted by the transformer, scoped to the target namespace.
62
+ */
63
+ function useExtension(stream, name, target) {
64
+ const namespace = resolveNamespace(target);
65
+ const key = `extension|${name}|${namespaceKey(namespace)}`;
66
+ return useProjection(getRegistry(stream), () => extensionProjection(name, namespace), key, void 0);
67
+ }
68
+ function useChannel(stream, channels, target, options) {
69
+ const namespace = resolveNamespace(target);
70
+ const sortedChannels = [...channels].sort().join(",");
71
+ const key = `channel|${options?.bufferSize ?? "default"}|${options?.replay ?? true ? "replay" : "live"}|${sortedChannels}|${namespaceKey(namespace)}`;
72
+ return useProjection(getRegistry(stream), () => channelProjection(channels, namespace, options), key, EMPTY_EVENTS);
73
+ }
74
+ const EMPTY_EVENTS = [];
75
+ /**
76
+ * Subscribe to a scoped audio-media stream. Each handle is yielded
77
+ * on its first matching `content-block-start`, exposes
78
+ * `.partialBytes` for live access, settles `.blob` / `.objectURL` /
79
+ * `.transcript` on `message-finish`, and surfaces errors via
80
+ * `.error`.
81
+ */
82
+ function useAudio(stream, target) {
83
+ const namespace = resolveNamespace(target);
84
+ const key = `audio|${namespaceKey(namespace)}`;
85
+ return useProjection(getRegistry(stream), () => audioProjection(namespace), key, EMPTY_AUDIO);
86
+ }
87
+ const EMPTY_AUDIO = [];
88
+ /**
89
+ * Subscribe to a scoped image-media stream. Pair with
90
+ * {@link useMediaURL} for `<img src>`.
91
+ */
92
+ function useImages(stream, target) {
93
+ const namespace = resolveNamespace(target);
94
+ const key = `images|${namespaceKey(namespace)}`;
95
+ return useProjection(getRegistry(stream), () => imagesProjection(namespace), key, EMPTY_IMAGES);
96
+ }
97
+ const EMPTY_IMAGES = [];
98
+ /**
99
+ * Subscribe to a scoped video-media stream. Pair with
100
+ * {@link useMediaURL} for `<video src>`.
101
+ */
102
+ function useVideo(stream, target) {
103
+ const namespace = resolveNamespace(target);
104
+ const key = `video|${namespaceKey(namespace)}`;
105
+ return useProjection(getRegistry(stream), () => videoProjection(namespace), key, EMPTY_VIDEO);
106
+ }
107
+ const EMPTY_VIDEO = [];
108
+ /**
109
+ * Subscribe to a scoped file-media stream. Pair with
110
+ * {@link useMediaURL} for an `<a download href>` target.
111
+ */
112
+ function useFiles(stream, target) {
113
+ const namespace = resolveNamespace(target);
114
+ const key = `files|${namespaceKey(namespace)}`;
115
+ return useProjection(getRegistry(stream), () => filesProjection(namespace), key, EMPTY_FILES);
116
+ }
117
+ const EMPTY_FILES = [];
118
+ /**
119
+ * Read metadata recorded for a specific message id — today exposes
120
+ * `parentCheckpointId`, the checkpoint the message was first seen on.
121
+ * Designed for fork / edit flows:
122
+ *
123
+ * ```ts
124
+ * const meta = useMessageMetadata(stream, () => msg.id);
125
+ * // meta.value?.parentCheckpointId
126
+ * ```
127
+ *
128
+ * `messageId` accepts a raw string, a `Ref<string | undefined>`, or
129
+ * a getter — the binding re-evaluates whenever the id changes.
130
+ */
131
+ function useMessageMetadata(stream, messageId) {
132
+ const store = stream[STREAM_CONTROLLER].messageMetadataStore;
133
+ const mapRef = shallowRef(store.getSnapshot());
134
+ onScopeDispose(store.subscribe(() => {
135
+ mapRef.value = store.getSnapshot();
136
+ }));
137
+ return computed(() => {
138
+ const key = toValue(messageId);
139
+ if (key == null) return void 0;
140
+ return mapRef.value.get(key);
141
+ });
142
+ }
143
+ function useSubmissionQueue(stream) {
144
+ const controller = stream[STREAM_CONTROLLER];
145
+ const store = controller.queueStore;
146
+ const entries = shallowRef(store.getSnapshot());
147
+ onScopeDispose(store.subscribe(() => {
148
+ entries.value = store.getSnapshot();
149
+ }));
150
+ return {
151
+ entries: readonly(entries),
152
+ size: computed(() => entries.value.length),
153
+ cancel: (id) => controller.cancelQueued(id),
154
+ clear: () => controller.clearQueue()
155
+ };
156
+ }
157
+ //#endregion
158
+ export { useAudio, useChannel, useExtension, useFiles, useImages, useMessageMetadata, useMessages, useSubmissionQueue, useToolCalls, useValues, useVideo };
159
+
160
+ //# sourceMappingURL=selectors.js.map