@langchain/langgraph 1.3.5 → 1.3.7

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 (37) hide show
  1. package/dist/stream/index.cjs +1 -0
  2. package/dist/stream/index.d.cts +2 -1
  3. package/dist/stream/index.d.ts +2 -1
  4. package/dist/stream/index.js +1 -0
  5. package/dist/stream/mux.cjs +13 -3
  6. package/dist/stream/mux.cjs.map +1 -1
  7. package/dist/stream/mux.d.cts +2 -2
  8. package/dist/stream/mux.d.cts.map +1 -1
  9. package/dist/stream/mux.d.ts +2 -2
  10. package/dist/stream/mux.d.ts.map +1 -1
  11. package/dist/stream/mux.js +13 -3
  12. package/dist/stream/mux.js.map +1 -1
  13. package/dist/stream/stream-channel.cjs +3 -3
  14. package/dist/stream/stream-channel.cjs.map +1 -1
  15. package/dist/stream/stream-channel.d.cts +12 -4
  16. package/dist/stream/stream-channel.d.cts.map +1 -1
  17. package/dist/stream/stream-channel.d.ts +12 -4
  18. package/dist/stream/stream-channel.d.ts.map +1 -1
  19. package/dist/stream/stream-channel.js +3 -3
  20. package/dist/stream/stream-channel.js.map +1 -1
  21. package/dist/stream/subscription.cjs +136 -0
  22. package/dist/stream/subscription.cjs.map +1 -0
  23. package/dist/stream/subscription.d.cts +94 -0
  24. package/dist/stream/subscription.d.cts.map +1 -0
  25. package/dist/stream/subscription.d.ts +94 -0
  26. package/dist/stream/subscription.d.ts.map +1 -0
  27. package/dist/stream/subscription.js +131 -0
  28. package/dist/stream/subscription.js.map +1 -0
  29. package/dist/stream/types.cjs.map +1 -1
  30. package/dist/stream/types.d.cts +3 -3
  31. package/dist/stream/types.d.ts +3 -3
  32. package/dist/stream/types.js.map +1 -1
  33. package/dist/stream.cjs +16 -0
  34. package/dist/stream.d.cts +5 -0
  35. package/dist/stream.d.ts +5 -0
  36. package/dist/stream.js +4 -0
  37. package/package.json +16 -4
@@ -68,8 +68,8 @@ type InferExtensions<T extends ReadonlyArray<() => StreamTransformer<any>>> = T
68
68
  * over WebSocket / SSE), create a named channel with
69
69
  * `StreamChannel.remote(name)`. The {@link StreamMux} detects named
70
70
  * `StreamChannel` instances in the `init()` return and auto-forwards every
71
- * `push()` as a {@link ProtocolEvent} on the channel's named method. Remote
72
- * clients subscribe via `session.subscribe("custom:<name>")`.
71
+ * `push()` as a {@link ProtocolEvent} on `custom:<name>`. Remote clients
72
+ * subscribe via `session.subscribe("custom:<name>")`.
73
73
  *
74
74
  * `finalize` and `fail` are optional. When a transformer uses
75
75
  * `StreamChannel`, the mux auto-closes/fails the channels on run
@@ -251,5 +251,5 @@ interface InterruptPayload<TPayload = unknown> {
251
251
  payload: TPayload;
252
252
  }
253
253
  //#endregion
254
- export { type AgentStatus$1 as AgentStatus, ChatModelStream$1 as ChatModelStream, ChatModelStreamHandle, InferExtensions, InterruptPayload, type LifecycleCause, type LifecycleData$1 as LifecycleData, type MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
254
+ export { type AgentStatus$1 as AgentStatus, ChatModelStream$1 as ChatModelStream, ChatModelStreamHandle, InferExtensions, InterruptPayload, type LifecycleCause, type LifecycleData$1 as LifecycleData, type MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, ProtocolMethod, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
255
255
  //# sourceMappingURL=types.d.cts.map
@@ -68,8 +68,8 @@ type InferExtensions<T extends ReadonlyArray<() => StreamTransformer<any>>> = T
68
68
  * over WebSocket / SSE), create a named channel with
69
69
  * `StreamChannel.remote(name)`. The {@link StreamMux} detects named
70
70
  * `StreamChannel` instances in the `init()` return and auto-forwards every
71
- * `push()` as a {@link ProtocolEvent} on the channel's named method. Remote
72
- * clients subscribe via `session.subscribe("custom:<name>")`.
71
+ * `push()` as a {@link ProtocolEvent} on `custom:<name>`. Remote clients
72
+ * subscribe via `session.subscribe("custom:<name>")`.
73
73
  *
74
74
  * `finalize` and `fail` are optional. When a transformer uses
75
75
  * `StreamChannel`, the mux auto-closes/fails the channels on run
@@ -251,5 +251,5 @@ interface InterruptPayload<TPayload = unknown> {
251
251
  payload: TPayload;
252
252
  }
253
253
  //#endregion
254
- export { type AgentStatus$1 as AgentStatus, ChatModelStream$1 as ChatModelStream, ChatModelStreamHandle, InferExtensions, InterruptPayload, type LifecycleCause, type LifecycleData$1 as LifecycleData, type MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
254
+ export { type AgentStatus$1 as AgentStatus, ChatModelStream$1 as ChatModelStream, ChatModelStreamHandle, InferExtensions, InterruptPayload, type LifecycleCause, type LifecycleData$1 as LifecycleData, type MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, ProtocolMethod, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
255
255
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/stream/types.ts"],"sourcesContent":["/**\n * Core type definitions for the v2 streaming interface.\n *\n * Channel event data types (`MessagesEventData`, `ToolsEventData`,\n * `UpdatesEventData`, `UsageInfo`, `Checkpoint`, `CheckpointSource`) are\n * re-exported from `@langchain/protocol` — the generated TypeScript\n * bindings for the canonical CDDL schema. Stream-specific types\n * (`StreamTransformer`, `ChatModelStream`, `ToolCallStream`,\n * `InterruptPayload`) are defined here.\n */\n\nimport type { ChatModelStream as CoreChatModelStream } from \"@langchain/core/language_models/stream\";\nimport type { ChatModelStreamEvent as CoreChatModelStreamEvent } from \"@langchain/core/language_models/event\";\nimport type { StreamMode } from \"../pregel/types.js\";\n\n/**\n * Re-exports from `@langchain/protocol`.\n *\n * These are the canonical wire-format types generated from `protocol.cddl`.\n * They are re-exported with local aliases so that consumers of this module\n * do not need a direct dependency on `@langchain/protocol`.\n */\nexport type {\n MessagesData as MessagesEventData,\n ToolsData as ToolsEventData,\n UpdatesData as UpdatesEventData,\n UsageInfo,\n MessageStartData,\n ContentBlockStartData,\n ContentBlockDeltaData,\n ContentBlockFinishData,\n MessageFinishData,\n MessageErrorData,\n ToolStartedData,\n ToolOutputDeltaData,\n ToolFinishedData,\n ToolErrorData,\n Checkpoint,\n CheckpointSource,\n AgentStatus,\n LifecycleData,\n LifecycleCause,\n} from \"@langchain/protocol\";\n\n/**\n * Hierarchical path identifying a position in the agent tree.\n *\n * Each element is one segment; longer arrays mean deeper nesting (e.g.\n * subgraph or multi-agent scopes).\n */\nexport type Namespace = string[];\n\n/**\n * Channels that can appear on a protocol event. Beyond the raw\n * {@link StreamMode} channels emitted by the Pregel stream, the v2\n * protocol layer synthesizes additional channels (e.g. `lifecycle`,\n * `input`) via built-in {@link StreamTransformer}s and exposes\n * user-defined channels created with {@link StreamChannel}.\n */\nexport type ProtocolMethod = StreamMode | \"lifecycle\" | \"input\" | (string & {});\n\n/**\n * Single envelope for a streaming protocol emission: sequence, channel\n * (`method`), and payload (`params`).\n */\nexport interface ProtocolEvent {\n /** Discriminator; always `\"event\"` for this shape. */\n readonly type: \"event\";\n\n /** Monotonic sequence number for ordering and deduplication within a run. */\n readonly seq: number;\n\n /**\n * Logical stream channel. Built-in channels match {@link StreamMode}\n * (e.g. `messages`, `updates`); transformer-synthesized channels\n * include `lifecycle` and `input`; user-defined channels carry their\n * {@link StreamChannel.channelName}.\n */\n readonly method: ProtocolMethod;\n\n /** Channel-specific payload and routing metadata. */\n readonly params: {\n /** Namespace of the node or scope that emitted this event. */\n readonly namespace: Namespace;\n\n /** Wall-clock or logical timestamp for the emission (milliseconds). */\n readonly timestamp: number;\n\n /**\n * Graph node id when the engine can attribute the event to a single node;\n * omitted for run-level or ambiguous emissions.\n */\n readonly node?: string;\n\n /** Opaque channel payload; shape depends on `method`. */\n readonly data: unknown;\n };\n}\n\n/**\n * Infers the merged extensions type from a tuple of transformer factory functions.\n *\n * Given `[() => StreamTransformer<{ a: number }>, () => StreamTransformer<{ b: string }>]`,\n * produces `{ a: number } & { b: string }`.\n */\nexport type InferExtensions<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReadonlyArray<() => StreamTransformer<any>>,\n> = T extends readonly []\n ? Record<string, never>\n : T extends readonly [\n () => StreamTransformer<infer P>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...infer Rest extends ReadonlyArray<() => StreamTransformer<any>>,\n ]\n ? P & InferExtensions<Rest>\n : Record<string, unknown>;\n\n/**\n * Observes {@link ProtocolEvent}s during a graph run and builds typed derived\n * projections (secondary event logs, promises, etc.).\n *\n * Data is surfaced to consumers through **projections** returned from\n * `init()`. Projections are merged into `GraphRunStream.extensions` for\n * in-process consumers. Use {@link StreamChannel.local} for local streaming\n * values, {@link StreamChannel.remote} for values that should also be visible\n * to remote clients, or `Promise<T>` for final values.\n *\n * To make projection data available to **remote** clients (SDK consumers\n * over WebSocket / SSE), create a named channel with\n * `StreamChannel.remote(name)`. The {@link StreamMux} detects named\n * `StreamChannel` instances in the `init()` return and auto-forwards every\n * `push()` as a {@link ProtocolEvent} on the channel's named method. Remote\n * clients subscribe via `session.subscribe(\"custom:<name>\")`.\n *\n * `finalize` and `fail` are optional. When a transformer uses\n * `StreamChannel`, the mux auto-closes/fails the channels on run\n * completion — no manual lifecycle management needed. Implement\n * `finalize`/`fail` only for non-channel teardown (e.g. resolving a\n * `Promise`).\n *\n * @typeParam TProjection - Shape returned by {@link init}, merged into\n * `GraphRunStream.extensions`.\n */\nexport interface StreamTransformer<TProjection = unknown> {\n /**\n * Called once before the run starts.\n *\n * @returns Initial projection merged into `GraphRunStream.extensions`.\n * Any named {@link StreamChannel} instances in the return value are\n * automatically wired to the protocol event stream by the mux. Unnamed\n * channels stay in-process-only.\n */\n init(): TProjection;\n\n /**\n * Optional hook invoked by {@link StreamMux.addTransformer} immediately\n * after the transformer is attached to the mux. Receives a limited\n * handle that exposes only {@link StreamEmitter.push} — enough for\n * the transformer to emit synthesized {@link ProtocolEvent}s on any\n * namespace it chooses (e.g. a deepagents `SubagentTransformer`\n * fabricating `lifecycle`/`messages`/`values` events under a\n * `[\"tools:<tool_call_id>\"]` namespace when a `task` tool starts).\n *\n * Transformers that do not synthesize events can omit this hook.\n *\n * The {@link StreamEmitter} handle is only safe to call *from within*\n * {@link StreamTransformer.process}. Emitting from an unrelated async\n * context (e.g. after `process` has returned, from a `setTimeout`,\n * etc.) races with the mux's close/fail cycle and may land events in\n * an already-closed log.\n */\n onRegister?(emitter: StreamEmitter): void;\n\n /**\n * Called for each {@link ProtocolEvent} before it is appended to the main log.\n *\n * @param event - Next protocol envelope for this run.\n * @returns `false` to drop the original event from the main log (use\n * sparingly; prefer keeping events visible and adding derived data\n * alongside).\n */\n process(event: ProtocolEvent): boolean;\n\n /**\n * Called once when the underlying Pregel run completes without throwing.\n * Optional — only needed for non-channel teardown (e.g. resolving promises).\n *\n * May return a `PromiseLike<void>` to defer the main event log close\n * until the async work (e.g. emitting terminal lifecycle events) has\n * completed. The mux awaits all returned promises before closing its\n * event log.\n */\n finalize?(): void | PromiseLike<void>;\n\n /**\n * Called once when the run fails; `err` is the rejection or error value.\n * Optional — only needed for non-channel teardown (e.g. rejecting promises).\n *\n * @param err - Failure reason from the engine or user code.\n */\n fail?(err: unknown): void;\n}\n\n/**\n * Narrow capability handle passed to\n * {@link StreamTransformer.onRegister}. Exposes only the minimal mux\n * surface required for synthetic event emission — intentionally does\n * not expose close/fail/register/etc. to keep the transformer contract\n * small and tamper-resistant.\n */\nexport interface StreamEmitter {\n /**\n * Injects a new {@link ProtocolEvent} into the mux pipeline. The\n * event is routed through every registered transformer (including\n * the emitting transformer — implementers must guard against\n * re-entrant self-processing) and, if not suppressed, appended to\n * the main event log.\n *\n * @param ns - Target namespace for the synthetic event.\n * @param event - The event envelope to inject. ``event.seq`` is\n * overwritten by the mux; callers can pass any placeholder.\n */\n push(ns: Namespace, event: ProtocolEvent): void;\n}\n\nexport type ChatModelStream = Omit<\n CoreChatModelStream,\n typeof Symbol.asyncIterator\n> & {\n /** Namespace of the graph node that produced this stream. */\n readonly namespace: Namespace;\n\n /** Graph node id for this stream, if the runtime attributed it. */\n readonly node: string | undefined;\n\n /**\n * Low-level async iteration over message lifecycle events.\n *\n * @returns Iterator yielding Core-compatible chat model stream events.\n */\n [Symbol.asyncIterator](): AsyncIterator<CoreChatModelStreamEvent>;\n};\n\n/**\n * Public view yielded by `run.messages`.\n *\n * `ChatModelStream` is PromiseLike to mirror Core, but TypeScript applies\n * `Awaited<T>` to values produced by `for await`. Exposing a non-thenable view\n * keeps loop variables typed as the streaming handle instead of `AIMessage`.\n */\nexport type ChatModelStreamHandle = Omit<ChatModelStream, \"then\">;\n\n/**\n * High-level outcome of a single tool call for UI or aggregators.\n */\nexport type ToolCallStatus =\n /** Invocation in flight or output still streaming. */\n | \"running\"\n /** Completed without error. */\n | \"finished\"\n /** Failed or aborted; see {@link ToolCallStream.error}. */\n | \"error\";\n\n/**\n * Stable handle for one tool call: name, arguments, and async results.\n *\n * Emitted when `content-block-finish` delivers a finalized `tool_call` block.\n *\n * @typeParam TName - Registered tool name.\n * @typeParam TInput - Parsed or raw input type for the call.\n * @typeParam TOutput - Successful result type after the tool returns.\n */\nexport interface ToolCallStream<\n TName extends string = string,\n TInput = unknown,\n TOutput = unknown,\n> {\n /** Tool identifier as registered on the graph or model schema. */\n readonly name: TName;\n\n /** Correlates with protocol `toolCallId` when the runtime provides one. */\n readonly callId: string;\n\n /** Arguments passed to the tool (finalized when the call is observable). */\n readonly input: TInput;\n\n /**\n * Resolves to the tool return value on success.\n *\n * @remarks\n * Rejection or hang semantics depend on the runner; pairing with\n * {@link ToolCallStream.status} and {@link ToolCallStream.error} is recommended.\n */\n readonly output: Promise<TOutput>;\n\n /**\n * Resolves to {@link ToolCallStatus} when the call leaves the running state.\n */\n readonly status: Promise<ToolCallStatus>;\n\n /**\n * Resolves to an error message string if {@link ToolCallStream.status} is\n * `\"error\"`, otherwise `undefined`.\n */\n readonly error: Promise<string | undefined>;\n}\n\n/**\n * Marker interface for transformers provided by internal LangChain products\n * (e.g. ReactAgent's ToolCallTransformer, DeepAgent's SubagentTransformer).\n *\n * Native transformers differ from user-defined extension transformers in\n * where their projection lands on the run stream:\n *\n * - **Native** — projections become direct getters on a\n * `GraphRunStream` subclass (e.g. `run.toolCalls`, `run.subagents`).\n * They emit events on protocol-defined channels (`tools`, `lifecycle`,\n * `tasks`, etc.).\n *\n * - **Extension** (user-defined) — projections are merged into\n * `run.extensions`. Events emitted via `emit()` use an\n * application-chosen method name (e.g. `emit(\"a2a\", data)`) and are\n * accessible to remote clients via `session.subscribe(\"custom:<name>\")`.\n *\n * The `__native` brand is used by downstream stream factory functions\n * to distinguish native transformers from extension transformers at\n * registration time. See `docs/native-stream-transformers.md` for the\n * full pattern.\n */\nexport interface NativeStreamTransformer<\n TProjection = unknown,\n> extends StreamTransformer<TProjection> {\n readonly __native: true;\n}\n\n/**\n * Type guard that tests whether a transformer is a {@link NativeStreamTransformer}.\n */\nexport function isNativeTransformer(\n t: StreamTransformer<unknown>\n): t is NativeStreamTransformer {\n return \"__native\" in t && (t as NativeStreamTransformer).__native === true;\n}\n\n/**\n * Human-in-the-loop interrupt: stable id plus opaque payload for resume UIs.\n */\nexport interface InterruptPayload<TPayload = unknown> {\n /** Idempotent key for this interrupt instance within the run. */\n interruptId: string;\n\n /** Arbitrary data supplied by the graph (e.g. questions, draft state). */\n payload: TPayload;\n}\n"],"mappings":";;;;AAmVA,SAAgB,oBACd,GAC8B;AAC9B,QAAO,cAAc,KAAM,EAA8B,aAAa"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/stream/types.ts"],"sourcesContent":["/**\n * Core type definitions for the v2 streaming interface.\n *\n * Channel event data types (`MessagesEventData`, `ToolsEventData`,\n * `UpdatesEventData`, `UsageInfo`, `Checkpoint`, `CheckpointSource`) are\n * re-exported from `@langchain/protocol` — the generated TypeScript\n * bindings for the canonical CDDL schema. Stream-specific types\n * (`StreamTransformer`, `ChatModelStream`, `ToolCallStream`,\n * `InterruptPayload`) are defined here.\n */\n\nimport type { ChatModelStream as CoreChatModelStream } from \"@langchain/core/language_models/stream\";\nimport type { ChatModelStreamEvent as CoreChatModelStreamEvent } from \"@langchain/core/language_models/event\";\nimport type { StreamMode } from \"../pregel/types.js\";\n\n/**\n * Re-exports from `@langchain/protocol`.\n *\n * These are the canonical wire-format types generated from `protocol.cddl`.\n * They are re-exported with local aliases so that consumers of this module\n * do not need a direct dependency on `@langchain/protocol`.\n */\nexport type {\n MessagesData as MessagesEventData,\n ToolsData as ToolsEventData,\n UpdatesData as UpdatesEventData,\n UsageInfo,\n MessageStartData,\n ContentBlockStartData,\n ContentBlockDeltaData,\n ContentBlockFinishData,\n MessageFinishData,\n MessageErrorData,\n ToolStartedData,\n ToolOutputDeltaData,\n ToolFinishedData,\n ToolErrorData,\n Checkpoint,\n CheckpointSource,\n AgentStatus,\n LifecycleData,\n LifecycleCause,\n} from \"@langchain/protocol\";\n\n/**\n * Hierarchical path identifying a position in the agent tree.\n *\n * Each element is one segment; longer arrays mean deeper nesting (e.g.\n * subgraph or multi-agent scopes).\n */\nexport type Namespace = string[];\n\n/**\n * Channels that can appear on a protocol event. Beyond the raw\n * {@link StreamMode} channels emitted by the Pregel stream, the v2\n * protocol layer synthesizes additional channels (e.g. `lifecycle`,\n * `input`) via built-in {@link StreamTransformer}s and exposes\n * user-defined channels created with {@link StreamChannel}.\n */\nexport type ProtocolMethod = StreamMode | \"lifecycle\" | \"input\" | (string & {});\n\n/**\n * Single envelope for a streaming protocol emission: sequence, channel\n * (`method`), and payload (`params`).\n */\nexport interface ProtocolEvent {\n /** Discriminator; always `\"event\"` for this shape. */\n readonly type: \"event\";\n\n /** Monotonic sequence number for ordering and deduplication within a run. */\n readonly seq: number;\n\n /**\n * Logical stream channel. Built-in channels match {@link StreamMode}\n * (e.g. `messages`, `updates`); transformer-synthesized channels\n * include `lifecycle` and `input`; user-defined channels carry their\n * {@link StreamChannel.channelName}.\n */\n readonly method: ProtocolMethod;\n\n /** Channel-specific payload and routing metadata. */\n readonly params: {\n /** Namespace of the node or scope that emitted this event. */\n readonly namespace: Namespace;\n\n /** Wall-clock or logical timestamp for the emission (milliseconds). */\n readonly timestamp: number;\n\n /**\n * Graph node id when the engine can attribute the event to a single node;\n * omitted for run-level or ambiguous emissions.\n */\n readonly node?: string;\n\n /** Opaque channel payload; shape depends on `method`. */\n readonly data: unknown;\n };\n}\n\n/**\n * Infers the merged extensions type from a tuple of transformer factory functions.\n *\n * Given `[() => StreamTransformer<{ a: number }>, () => StreamTransformer<{ b: string }>]`,\n * produces `{ a: number } & { b: string }`.\n */\nexport type InferExtensions<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends ReadonlyArray<() => StreamTransformer<any>>,\n> = T extends readonly []\n ? Record<string, never>\n : T extends readonly [\n () => StreamTransformer<infer P>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ...infer Rest extends ReadonlyArray<() => StreamTransformer<any>>,\n ]\n ? P & InferExtensions<Rest>\n : Record<string, unknown>;\n\n/**\n * Observes {@link ProtocolEvent}s during a graph run and builds typed derived\n * projections (secondary event logs, promises, etc.).\n *\n * Data is surfaced to consumers through **projections** returned from\n * `init()`. Projections are merged into `GraphRunStream.extensions` for\n * in-process consumers. Use {@link StreamChannel.local} for local streaming\n * values, {@link StreamChannel.remote} for values that should also be visible\n * to remote clients, or `Promise<T>` for final values.\n *\n * To make projection data available to **remote** clients (SDK consumers\n * over WebSocket / SSE), create a named channel with\n * `StreamChannel.remote(name)`. The {@link StreamMux} detects named\n * `StreamChannel` instances in the `init()` return and auto-forwards every\n * `push()` as a {@link ProtocolEvent} on `custom:<name>`. Remote clients\n * subscribe via `session.subscribe(\"custom:<name>\")`.\n *\n * `finalize` and `fail` are optional. When a transformer uses\n * `StreamChannel`, the mux auto-closes/fails the channels on run\n * completion — no manual lifecycle management needed. Implement\n * `finalize`/`fail` only for non-channel teardown (e.g. resolving a\n * `Promise`).\n *\n * @typeParam TProjection - Shape returned by {@link init}, merged into\n * `GraphRunStream.extensions`.\n */\nexport interface StreamTransformer<TProjection = unknown> {\n /**\n * Called once before the run starts.\n *\n * @returns Initial projection merged into `GraphRunStream.extensions`.\n * Any named {@link StreamChannel} instances in the return value are\n * automatically wired to the protocol event stream by the mux. Unnamed\n * channels stay in-process-only.\n */\n init(): TProjection;\n\n /**\n * Optional hook invoked by {@link StreamMux.addTransformer} immediately\n * after the transformer is attached to the mux. Receives a limited\n * handle that exposes only {@link StreamEmitter.push} — enough for\n * the transformer to emit synthesized {@link ProtocolEvent}s on any\n * namespace it chooses (e.g. a deepagents `SubagentTransformer`\n * fabricating `lifecycle`/`messages`/`values` events under a\n * `[\"tools:<tool_call_id>\"]` namespace when a `task` tool starts).\n *\n * Transformers that do not synthesize events can omit this hook.\n *\n * The {@link StreamEmitter} handle is only safe to call *from within*\n * {@link StreamTransformer.process}. Emitting from an unrelated async\n * context (e.g. after `process` has returned, from a `setTimeout`,\n * etc.) races with the mux's close/fail cycle and may land events in\n * an already-closed log.\n */\n onRegister?(emitter: StreamEmitter): void;\n\n /**\n * Called for each {@link ProtocolEvent} before it is appended to the main log.\n *\n * @param event - Next protocol envelope for this run.\n * @returns `false` to drop the original event from the main log (use\n * sparingly; prefer keeping events visible and adding derived data\n * alongside).\n */\n process(event: ProtocolEvent): boolean;\n\n /**\n * Called once when the underlying Pregel run completes without throwing.\n * Optional — only needed for non-channel teardown (e.g. resolving promises).\n *\n * May return a `PromiseLike<void>` to defer the main event log close\n * until the async work (e.g. emitting terminal lifecycle events) has\n * completed. The mux awaits all returned promises before closing its\n * event log.\n */\n finalize?(): void | PromiseLike<void>;\n\n /**\n * Called once when the run fails; `err` is the rejection or error value.\n * Optional — only needed for non-channel teardown (e.g. rejecting promises).\n *\n * @param err - Failure reason from the engine or user code.\n */\n fail?(err: unknown): void;\n}\n\n/**\n * Narrow capability handle passed to\n * {@link StreamTransformer.onRegister}. Exposes only the minimal mux\n * surface required for synthetic event emission — intentionally does\n * not expose close/fail/register/etc. to keep the transformer contract\n * small and tamper-resistant.\n */\nexport interface StreamEmitter {\n /**\n * Injects a new {@link ProtocolEvent} into the mux pipeline. The\n * event is routed through every registered transformer (including\n * the emitting transformer — implementers must guard against\n * re-entrant self-processing) and, if not suppressed, appended to\n * the main event log.\n *\n * @param ns - Target namespace for the synthetic event.\n * @param event - The event envelope to inject. ``event.seq`` is\n * overwritten by the mux; callers can pass any placeholder.\n */\n push(ns: Namespace, event: ProtocolEvent): void;\n}\n\nexport type ChatModelStream = Omit<\n CoreChatModelStream,\n typeof Symbol.asyncIterator\n> & {\n /** Namespace of the graph node that produced this stream. */\n readonly namespace: Namespace;\n\n /** Graph node id for this stream, if the runtime attributed it. */\n readonly node: string | undefined;\n\n /**\n * Low-level async iteration over message lifecycle events.\n *\n * @returns Iterator yielding Core-compatible chat model stream events.\n */\n [Symbol.asyncIterator](): AsyncIterator<CoreChatModelStreamEvent>;\n};\n\n/**\n * Public view yielded by `run.messages`.\n *\n * `ChatModelStream` is PromiseLike to mirror Core, but TypeScript applies\n * `Awaited<T>` to values produced by `for await`. Exposing a non-thenable view\n * keeps loop variables typed as the streaming handle instead of `AIMessage`.\n */\nexport type ChatModelStreamHandle = Omit<ChatModelStream, \"then\">;\n\n/**\n * High-level outcome of a single tool call for UI or aggregators.\n */\nexport type ToolCallStatus =\n /** Invocation in flight or output still streaming. */\n | \"running\"\n /** Completed without error. */\n | \"finished\"\n /** Failed or aborted; see {@link ToolCallStream.error}. */\n | \"error\";\n\n/**\n * Stable handle for one tool call: name, arguments, and async results.\n *\n * Emitted when `content-block-finish` delivers a finalized `tool_call` block.\n *\n * @typeParam TName - Registered tool name.\n * @typeParam TInput - Parsed or raw input type for the call.\n * @typeParam TOutput - Successful result type after the tool returns.\n */\nexport interface ToolCallStream<\n TName extends string = string,\n TInput = unknown,\n TOutput = unknown,\n> {\n /** Tool identifier as registered on the graph or model schema. */\n readonly name: TName;\n\n /** Correlates with protocol `toolCallId` when the runtime provides one. */\n readonly callId: string;\n\n /** Arguments passed to the tool (finalized when the call is observable). */\n readonly input: TInput;\n\n /**\n * Resolves to the tool return value on success.\n *\n * @remarks\n * Rejection or hang semantics depend on the runner; pairing with\n * {@link ToolCallStream.status} and {@link ToolCallStream.error} is recommended.\n */\n readonly output: Promise<TOutput>;\n\n /**\n * Resolves to {@link ToolCallStatus} when the call leaves the running state.\n */\n readonly status: Promise<ToolCallStatus>;\n\n /**\n * Resolves to an error message string if {@link ToolCallStream.status} is\n * `\"error\"`, otherwise `undefined`.\n */\n readonly error: Promise<string | undefined>;\n}\n\n/**\n * Marker interface for transformers provided by internal LangChain products\n * (e.g. ReactAgent's ToolCallTransformer, DeepAgent's SubagentTransformer).\n *\n * Native transformers differ from user-defined extension transformers in\n * where their projection lands on the run stream:\n *\n * - **Native** — projections become direct getters on a\n * `GraphRunStream` subclass (e.g. `run.toolCalls`, `run.subagents`).\n * They emit events on protocol-defined channels (`tools`, `lifecycle`,\n * `tasks`, etc.).\n *\n * - **Extension** (user-defined) — projections are merged into\n * `run.extensions`. Events emitted via `emit()` use an\n * application-chosen method name (e.g. `emit(\"a2a\", data)`) and are\n * accessible to remote clients via `session.subscribe(\"custom:<name>\")`.\n *\n * The `__native` brand is used by downstream stream factory functions\n * to distinguish native transformers from extension transformers at\n * registration time. See `docs/native-stream-transformers.md` for the\n * full pattern.\n */\nexport interface NativeStreamTransformer<\n TProjection = unknown,\n> extends StreamTransformer<TProjection> {\n readonly __native: true;\n}\n\n/**\n * Type guard that tests whether a transformer is a {@link NativeStreamTransformer}.\n */\nexport function isNativeTransformer(\n t: StreamTransformer<unknown>\n): t is NativeStreamTransformer {\n return \"__native\" in t && (t as NativeStreamTransformer).__native === true;\n}\n\n/**\n * Human-in-the-loop interrupt: stable id plus opaque payload for resume UIs.\n */\nexport interface InterruptPayload<TPayload = unknown> {\n /** Idempotent key for this interrupt instance within the run. */\n interruptId: string;\n\n /** Arbitrary data supplied by the graph (e.g. questions, draft state). */\n payload: TPayload;\n}\n"],"mappings":";;;;AAmVA,SAAgB,oBACd,GAC8B;AAC9B,QAAO,cAAc,KAAM,EAA8B,aAAa"}
@@ -0,0 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_convert = require("./stream/convert.cjs");
3
+ const require_stream_channel = require("./stream/stream-channel.cjs");
4
+ const require_subscription = require("./stream/subscription.cjs");
5
+ exports.EventLog = require_stream_channel.StreamChannel;
6
+ exports.STREAM_EVENTS_V3_MODES = require_convert.STREAM_EVENTS_V3_MODES;
7
+ exports.SUPPORTED_CHANNELS = require_subscription.SUPPORTED_CHANNELS;
8
+ exports.StreamChannel = require_stream_channel.StreamChannel;
9
+ exports.convertToProtocolEvent = require_convert.convertToProtocolEvent;
10
+ exports.inferChannel = require_subscription.inferChannel;
11
+ exports.isCheckpointEnvelope = require_convert.isCheckpointEnvelope;
12
+ exports.isPrefixMatch = require_subscription.isPrefixMatch;
13
+ exports.isStreamChannel = require_stream_channel.isStreamChannel;
14
+ exports.isSupportedChannel = require_subscription.isSupportedChannel;
15
+ exports.matchesSubscription = require_subscription.matchesSubscription;
16
+ exports.normalizeNamespaceSegment = require_subscription.normalizeNamespaceSegment;
@@ -0,0 +1,5 @@
1
+ import { Namespace, ProtocolEvent, ProtocolMethod } from "./stream/types.cjs";
2
+ import { StreamChannel, isStreamChannel } from "./stream/stream-channel.cjs";
3
+ import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.cjs";
4
+ import { MatchableEvent, SUPPORTED_CHANNELS, inferChannel, isPrefixMatch, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment } from "./stream/subscription.cjs";
5
+ export { type ConvertToProtocolEventOptions, StreamChannel as EventLog, type MatchableEvent, type Namespace, type ProtocolEvent, type ProtocolMethod, STREAM_EVENTS_V3_MODES, SUPPORTED_CHANNELS, StreamChannel, convertToProtocolEvent, inferChannel, isCheckpointEnvelope, isPrefixMatch, isStreamChannel, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment };
@@ -0,0 +1,5 @@
1
+ import { Namespace, ProtocolEvent, ProtocolMethod } from "./stream/types.js";
2
+ import { StreamChannel, isStreamChannel } from "./stream/stream-channel.js";
3
+ import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
4
+ import { MatchableEvent, SUPPORTED_CHANNELS, inferChannel, isPrefixMatch, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment } from "./stream/subscription.js";
5
+ export { type ConvertToProtocolEventOptions, StreamChannel as EventLog, type MatchableEvent, type Namespace, type ProtocolEvent, type ProtocolMethod, STREAM_EVENTS_V3_MODES, SUPPORTED_CHANNELS, StreamChannel, convertToProtocolEvent, inferChannel, isCheckpointEnvelope, isPrefixMatch, isStreamChannel, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment };
package/dist/stream.js ADDED
@@ -0,0 +1,4 @@
1
+ import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
2
+ import { StreamChannel, isStreamChannel } from "./stream/stream-channel.js";
3
+ import { SUPPORTED_CHANNELS, inferChannel, isPrefixMatch, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment } from "./stream/subscription.js";
4
+ export { StreamChannel as EventLog, STREAM_EVENTS_V3_MODES, SUPPORTED_CHANNELS, StreamChannel, convertToProtocolEvent, inferChannel, isCheckpointEnvelope, isPrefixMatch, isStreamChannel, isSupportedChannel, matchesSubscription, normalizeNamespaceSegment };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -20,7 +20,7 @@
20
20
  "@standard-schema/spec": "1.1.0",
21
21
  "uuid": "^14.0.0",
22
22
  "@langchain/langgraph-checkpoint": "^1.0.4",
23
- "@langchain/langgraph-sdk": "~1.9.16"
23
+ "@langchain/langgraph-sdk": "~1.9.19"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@langchain/core": "^1.1.48",
@@ -56,10 +56,10 @@
56
56
  "tsx": "^4.19.3",
57
57
  "typescript": "^4.9.5 || ^5.4.5",
58
58
  "vite-plugin-node-polyfills": "^0.28.0",
59
- "vitest": "^4.1.8",
59
+ "vitest": "^4.1.0",
60
60
  "zod-to-json-schema": "^3.22.4",
61
61
  "@langchain/langgraph-checkpoint-postgres": "1.0.2",
62
- "@langchain/langgraph-checkpoint-sqlite": "1.0.1"
62
+ "@langchain/langgraph-checkpoint-sqlite": "1.0.2"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public",
@@ -139,6 +139,18 @@
139
139
  "default": "./dist/remote.cjs"
140
140
  }
141
141
  },
142
+ "./stream": {
143
+ "input": "./src/stream.ts",
144
+ "typedoc": "./src/stream.ts",
145
+ "import": {
146
+ "types": "./dist/stream.d.ts",
147
+ "default": "./dist/stream.js"
148
+ },
149
+ "require": {
150
+ "types": "./dist/stream.d.cts",
151
+ "default": "./dist/stream.cjs"
152
+ }
153
+ },
142
154
  "./zod": {
143
155
  "input": "./src/graph/zod/index.ts",
144
156
  "typedoc": "./src/graph/zod/index.ts",