@langchain/langgraph 1.3.3 → 1.3.5

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 (67) hide show
  1. package/dist/graph/state.cjs +5 -1
  2. package/dist/graph/state.cjs.map +1 -1
  3. package/dist/graph/state.d.cts.map +1 -1
  4. package/dist/graph/state.d.ts.map +1 -1
  5. package/dist/graph/state.js +5 -1
  6. package/dist/graph/state.js.map +1 -1
  7. package/dist/index.cjs +4 -3
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +3 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/{setup/async_local_storage.cjs → node.cjs} +2 -2
  14. package/dist/node.cjs.map +1 -0
  15. package/dist/{setup/async_local_storage.js → node.js} +2 -2
  16. package/dist/node.js.map +1 -0
  17. package/dist/pregel/index.cjs +13 -12
  18. package/dist/pregel/index.cjs.map +1 -1
  19. package/dist/pregel/index.d.cts.map +1 -1
  20. package/dist/pregel/index.d.ts.map +1 -1
  21. package/dist/pregel/index.js +13 -12
  22. package/dist/pregel/index.js.map +1 -1
  23. package/dist/pregel/loop.cjs +19 -33
  24. package/dist/pregel/loop.cjs.map +1 -1
  25. package/dist/pregel/loop.js +19 -33
  26. package/dist/pregel/loop.js.map +1 -1
  27. package/dist/pregel/remote.cjs +1 -1
  28. package/dist/pregel/remote.cjs.map +1 -1
  29. package/dist/pregel/remote.d.cts +4 -3
  30. package/dist/pregel/remote.d.cts.map +1 -1
  31. package/dist/pregel/remote.d.ts +4 -3
  32. package/dist/pregel/remote.d.ts.map +1 -1
  33. package/dist/pregel/remote.js +1 -1
  34. package/dist/pregel/remote.js.map +1 -1
  35. package/dist/pregel/stream.cjs +12 -0
  36. package/dist/pregel/stream.cjs.map +1 -1
  37. package/dist/pregel/stream.d.cts +2 -24
  38. package/dist/pregel/stream.d.cts.map +1 -1
  39. package/dist/pregel/stream.d.ts +2 -24
  40. package/dist/pregel/stream.d.ts.map +1 -1
  41. package/dist/pregel/stream.js +12 -1
  42. package/dist/pregel/stream.js.map +1 -1
  43. package/dist/stream/convert.cjs +29 -23
  44. package/dist/stream/convert.cjs.map +1 -1
  45. package/dist/stream/convert.d.cts +9 -38
  46. package/dist/stream/convert.d.cts.map +1 -1
  47. package/dist/stream/convert.d.ts +9 -38
  48. package/dist/stream/convert.d.ts.map +1 -1
  49. package/dist/stream/convert.js +29 -24
  50. package/dist/stream/convert.js.map +1 -1
  51. package/dist/stream/index.cjs +1 -1
  52. package/dist/stream/index.d.cts +1 -1
  53. package/dist/stream/index.d.ts +1 -1
  54. package/dist/stream/index.js +1 -1
  55. package/dist/stream/mux.cjs +3 -4
  56. package/dist/stream/mux.cjs.map +1 -1
  57. package/dist/stream/mux.js +3 -4
  58. package/dist/stream/mux.js.map +1 -1
  59. package/dist/stream/types.d.cts +2 -2
  60. package/dist/stream/types.d.ts +2 -2
  61. package/dist/web.cjs +2 -1
  62. package/dist/web.d.cts +2 -2
  63. package/dist/web.d.ts +2 -2
  64. package/dist/web.js +2 -2
  65. package/package.json +11 -10
  66. package/dist/setup/async_local_storage.cjs.map +0 -1
  67. package/dist/setup/async_local_storage.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mux.js","names":["#transformers","#channels","#streamMap","#latestValues","#interrupts","#finalValues","#closed","#error","#nextEmitSeq","#currentNamespace","#interrupted"],"sources":["../../src/stream/mux.ts"],"sourcesContent":["/**\n * StreamMux — central dispatcher with transformer pipeline.\n *\n * Routes raw stream chunks through registered StreamTransformers, then appends\n * the resulting ProtocolEvents to the main local channel. Also tracks\n * namespace discovery for SubgraphRunStream creation.\n *\n * lifecycle:\n * graph.streamEvents(input, { version: \"v3\" })\n * ├─ StreamMux starts pumping from graph.stream(…, { subgraphs: true })\n * ├─ For each ProtocolEvent:\n * │ ├─ transformer_1.process(event)\n * │ ├─ transformer_2.process(event)\n * │ └─ event appended to _events (unless suppressed)\n * └─ On close: transformer_n.finalize() called in registration order\n */\n\nimport type { StreamChunk } from \"../pregel/stream.js\";\nimport { INTERRUPT, isInterrupted, type Interrupt } from \"../constants.js\";\nimport { convertToProtocolEvent, STREAM_EVENTS_V3_MODES } from \"./convert.js\";\nimport { StreamChannel, isStreamChannel } from \"./stream-channel.js\";\nimport type {\n InterruptPayload,\n Namespace,\n ProtocolEvent,\n StreamEmitter,\n StreamTransformer,\n} from \"./types.js\";\n\nexport { STREAM_EVENTS_V3_MODES };\n\n/**\n * Structural `PromiseLike<T>` predicate — true for thenables including\n * native promises, user-constructed `{ then }` objects, and helper\n * wrappers. Used by {@link StreamMux.wireChannels} to detect final-value\n * projections distinctly from streaming `StreamChannel` values.\n */\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return (\n value != null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/**\n * Symbol key used by {@link StreamMux} to resolve the values promise on a\n * stream handle. Using a symbol keeps this off the public autocomplete surface.\n */\nexport const RESOLVE_VALUES: unique symbol = Symbol(\"resolveValues\");\n\n/**\n * Symbol key used by {@link StreamMux} to reject the values promise on a\n * stream handle. Using a symbol keeps this off the public autocomplete surface.\n */\nexport const REJECT_VALUES: unique symbol = Symbol(\"rejectValues\");\n\n/**\n * Minimal interface that {@link StreamMux} requires from stream handles\n * for lifecycle resolution. This avoids a direct dependency on\n * `GraphRunStream` / `SubgraphRunStream`.\n */\nexport interface StreamHandle {\n [RESOLVE_VALUES](values: unknown): void;\n [REJECT_VALUES](err: unknown): void;\n}\n\n/**\n * Factory function that creates a subgraph stream handle for a newly\n * discovered namespace.\n *\n * Historically consumed by {@link StreamMux} at construction time;\n * today factories are consumed by\n * `createSubgraphDiscoveryTransformer` (via its `createStream`\n * option). This shape is retained for consumers that still thread a\n * mux reference through the factory — the narrower transformer\n * option omits `mux` because it captures the mux in a closure.\n */\nexport type SubgraphStreamFactory = (\n path: Namespace,\n mux: StreamMux,\n discoveryStart: number,\n eventStart: number\n) => StreamHandle;\n\n/**\n * A discovered subgraph namespace paired with its run stream handle.\n */\nexport type SubgraphDiscovery = {\n ns: Namespace;\n stream: StreamHandle;\n};\n\n/**\n * Central event dispatcher that routes {@link ProtocolEvent}s through a\n * pipeline of {@link StreamTransformer}s, manages namespace discovery for\n * subgraph streams, and exposes async iteration over filtered event\n * sequences.\n *\n * One `StreamMux` instance exists per top-level\n * `streamEvents(..., { version: \"v3\" })` invocation.\n */\nexport class StreamMux {\n /** @internal All protocol events in arrival order (after reducer pipeline). */\n readonly _events = StreamChannel.local<ProtocolEvent>();\n\n /** @internal New-namespace discovery notifications. */\n readonly _discoveries = StreamChannel.local<SubgraphDiscovery>();\n\n /** Monotonic counter for auto-forwarded channel events. */\n #nextEmitSeq = 0;\n\n /** Whether the mux has been closed or failed. */\n #closed = false;\n\n /** The error passed to {@link fail}, if any. */\n #error: unknown;\n\n /** Whether the run was interrupted. */\n #interrupted = false;\n\n /**\n * Namespace of the event currently being processed by\n * {@link push}. Read by {@link StreamChannel} wiring callbacks so\n * auto-forwarded events inherit the triggering event's namespace.\n */\n #currentNamespace: Namespace = [];\n\n readonly #transformers: StreamTransformer<unknown>[] = [];\n readonly #channels: StreamChannel<unknown>[] = [];\n readonly #streamMap = new Map<string, StreamHandle>();\n readonly #latestValues = new Map<string, Record<string, unknown>>();\n readonly #interrupts: InterruptPayload[] = [];\n\n /**\n * Final-value projection keys tracked for remote surfacing. Populated\n * by {@link wireChannels} when a transformer's projection contains a\n * `PromiseLike` value. Each entry is flushed as a `custom:<name>`\n * protocol event during {@link close} so that remote clients can\n * observe final-value transformers via `thread.extensions.<name>`.\n */\n readonly #finalValues: Array<{ name: string; promise: Promise<unknown> }> =\n [];\n\n /**\n * Associates a pre-existing stream handle with a namespace so that\n * {@link close} can resolve its values promise later.\n *\n * @param path - The namespace path to register.\n * @param stream - The run stream handle for that namespace.\n */\n register(path: Namespace, stream: StreamHandle): void {\n this.#streamMap.set(nsKey(path), stream);\n }\n\n /**\n * Registers a transformer and replays all buffered events through it so\n * it catches up with events already processed by the mux. When the event\n * log is empty (typical at construction time) the replay is a no-op.\n *\n * The transformer must already have been initialised (i.e. `init()` called\n * and any projection wired). The sequence is:\n *\n * 1. Snapshot the current event log length.\n * 2. Append the transformer so future {@link push} calls reach it.\n * 3. Replay events `[0, snapshot)` through `process()`.\n * 4. If the mux is already closed, call `finalize()` (or `fail()`)\n * immediately so the transformer's log/channel terminates cleanly.\n *\n * @param transformer - An already-initialised transformer to register.\n */\n addTransformer(transformer: StreamTransformer<unknown>): void {\n const snapshot = this._events.size;\n this.#transformers.push(transformer);\n\n // Hand the transformer a narrow emitter handle *before* replay so\n // synthetic-emission transformers (e.g. deepagents\n // `SubagentTransformer`) can inject events into the mux during\n // their own `process()` calls — including the initial replay\n // triggered just below.\n if (transformer.onRegister) {\n const emitter: StreamEmitter = {\n // Transformer-originated events use a placeholder `seq` of\n // `0`. `push()` is the single authority for sequence numbers\n // and will re-stamp this event with the next monotonically\n // increasing value.\n push: (ns, event) => this.push(ns, event),\n };\n transformer.onRegister(emitter);\n }\n\n for (let i = 0; i < snapshot; i += 1) {\n transformer.process(this._events.get(i));\n }\n\n if (this.#closed) {\n if (this.#error !== undefined) {\n transformer.fail?.(this.#error);\n } else {\n transformer.finalize?.();\n }\n }\n }\n\n /**\n * Scans a transformer projection for streaming and final-value primitives.\n * Remote stream channels are wired to auto-forward to the protocol event\n * stream; local stream channels are tracked for lifecycle only.\n *\n * Two projection shapes are recognised:\n *\n * - {@link StreamChannel} values — named channels forward each `push()`\n * immediately as a protocol event on the channel's declared\n * `channelName` method. Unnamed channels remain in-process-only.\n *\n * - `PromiseLike<unknown>` values — tracked as final-value\n * projections and flushed on {@link close} as a single\n * `custom:<key>` event, where `<key>` is the projection key.\n * This mirrors the in-process `await run.extensions.<key>`\n * ergonomics on remote clients via\n * `await thread.extensions.<key>`.\n *\n * Plain values that are neither are ignored — they remain in-process-only,\n * matching prior behaviour.\n *\n * @param projection - The object returned by `transformer.init()`.\n */\n wireChannels(projection: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(projection)) {\n if (isStreamChannel(value)) {\n this.#channels.push(value);\n if (typeof value.channelName !== \"string\") {\n continue;\n }\n value._wire((item: unknown) => {\n this._events.push({\n type: \"event\",\n seq: this.#nextEmitSeq++,\n method: value.channelName as ProtocolEvent[\"method\"],\n params: {\n namespace: this.#currentNamespace,\n timestamp: Date.now(),\n data: item,\n },\n });\n });\n continue;\n }\n if (isPromiseLike(value)) {\n this.#finalValues.push({\n name: key,\n promise: Promise.resolve(value),\n });\n }\n }\n }\n\n /**\n * Distributes an event through the transformer pipeline, then appends it to\n * the main event log.\n *\n * Subgraph discovery (materializing a {@link StreamHandle} for each\n * newly observed top-level namespace) is handled by the\n * {@link createSubgraphDiscoveryTransformer} when installed, not here.\n *\n * @param ns - The namespace path that produced the event.\n * @param event - The protocol event to process and store.\n */\n push(ns: Namespace, event: ProtocolEvent): void {\n if (event.method === \"values\") {\n this.#latestValues.set(\n nsKey(ns),\n event.params.data as Record<string, unknown>\n );\n }\n\n // Save the outer namespace so re-entrant `push()` calls (e.g. from\n // `StreamTransformer.onRegister` emitters synthesizing events\n // inside a transformer's `process()`) can set their own namespace\n // without clobbering the outer scope's `StreamChannel` routing\n // when control returns to the outer transformer loop.\n const outerNamespace = this.#currentNamespace;\n this.#currentNamespace = ns;\n\n let keep = true;\n for (const transformer of this.#transformers) {\n if (!transformer.process(event)) {\n keep = false;\n }\n }\n\n this.#currentNamespace = outerNamespace;\n\n if (keep) {\n // The mux is the single authority for sequence numbers. Callers\n // (the `pump`, transformer emitters, channel forwarders) pass a\n // placeholder `seq`; we re-stamp every event here so the log is\n // strictly monotonic across all origination paths. Stamping\n // happens *after* `process()` so that any channel-forwarded\n // events pushed during processing get earlier sequence numbers\n // than the triggering event, matching their in-order appearance\n // in `_events`.\n this._events.push({ ...event, seq: this.#nextEmitSeq++ });\n }\n }\n\n /**\n * Gracefully ends the stream: resolves values promises on all known\n * streams, finalizes every transformer, auto-closes streaming\n * channels, flushes any final-value projections as `custom:<name>`\n * events, and closes both event logs.\n *\n * When final-value projections are present, `_events.close()` is\n * deferred until every tracked projection promise has settled so\n * remote consumers observe the flushed values before their event\n * stream ends. Callers do not need to await — `close()` returns\n * synchronously and any downstream consumer iterating\n * {@link _events} naturally waits for the final events.\n */\n close(): void {\n this.#closed = true;\n for (const [key, values] of this.#latestValues.entries()) {\n const ns = key ? key.split(\"\\x00\") : [];\n const stream = this.#streamMap.get(nsKey(ns));\n stream?.[RESOLVE_VALUES](values);\n }\n\n const finalizePromises: PromiseLike<void>[] = [];\n for (const transformer of this.#transformers) {\n const result = transformer.finalize?.();\n if (\n result != null &&\n typeof (result as PromiseLike<void>).then === \"function\"\n ) {\n finalizePromises.push(result as PromiseLike<void>);\n }\n }\n\n for (const channel of this.#channels) {\n channel._close();\n }\n\n const finalValues = this.#finalValues;\n if (finalValues.length === 0 && finalizePromises.length === 0) {\n this._events.close();\n this._discoveries.close();\n } else {\n void Promise.allSettled([\n ...finalizePromises,\n ...finalValues.map(async ({ name, promise }) => {\n try {\n const resolved = await promise;\n if (!this._events.done) {\n this._events.push({\n type: \"event\",\n seq: this.#nextEmitSeq++,\n method: \"custom\",\n params: {\n namespace: [],\n timestamp: Date.now(),\n data: { name, payload: resolved },\n },\n });\n }\n } catch {\n // Rejected final-value projections are intentionally dropped\n // so a single failing extension can't poison the protocol\n // stream. The corresponding in-process Promise still\n // surfaces the rejection to its direct awaiters via the\n // transformer's own `fail()` hook.\n }\n }),\n ]).then(() => {\n this._events.close();\n this._discoveries.close();\n });\n }\n\n for (const stream of this.#streamMap.values()) {\n stream[RESOLVE_VALUES](undefined);\n }\n }\n\n /**\n * Propagates a failure to all transformers, channels, event logs, and\n * stream handles.\n *\n * @param err - The error that caused the run to fail.\n */\n fail(err: unknown): void {\n this.#closed = true;\n this.#error = err;\n for (const transformer of this.#transformers) {\n transformer.fail?.(err);\n }\n for (const channel of this.#channels) {\n channel._fail(err);\n }\n this._events.fail(err);\n this._discoveries.fail(err);\n for (const stream of this.#streamMap.values()) {\n stream[REJECT_VALUES](err);\n }\n }\n\n /**\n * Records that the run was interrupted, appending the supplied payloads\n * for later retrieval.\n *\n * @param interrupts - The interrupt payloads to store.\n */\n markInterrupted(interrupts: InterruptPayload[]): void {\n this.#interrupted = true;\n this.#interrupts.push(...interrupts);\n }\n\n /**\n * Whether the run ended due to an interrupt.\n *\n * @returns `true` if {@link markInterrupted} was called.\n */\n get interrupted(): boolean {\n return this.#interrupted;\n }\n\n /**\n * All interrupt payloads collected during the run.\n *\n * @returns A readonly view of the accumulated interrupt payloads.\n */\n get interrupts(): readonly InterruptPayload[] {\n return this.#interrupts;\n }\n\n /**\n * Returns an async iterator that yields only events whose namespace\n * starts with {@link path}.\n *\n * @param path - Namespace prefix to filter on.\n * @param startAt - Zero-based index into the event log to begin from.\n * @returns An async iterator over matching {@link ProtocolEvent}s.\n */\n subscribeEvents(path: Namespace, startAt = 0): AsyncIterator<ProtocolEvent> {\n const base = this._events.iterate(startAt);\n return {\n async next(): Promise<IteratorResult<ProtocolEvent>> {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await base.next();\n if (result.done) return result;\n if (hasPrefix(result.value.params.namespace, path)) {\n return result;\n }\n }\n },\n };\n }\n}\n\n/**\n * Background consumer that drains a raw `graph.stream()` source into a\n * {@link StreamMux}. Converts each chunk to a {@link ProtocolEvent} and\n * pushes it; calls {@link StreamMux.close} on normal completion or\n * {@link StreamMux.fail} on error.\n *\n * @param source - The async iterable of raw stream chunks from the engine.\n * @param mux - The mux instance to feed.\n * @returns A promise that resolves when the source is fully consumed.\n */\nexport async function pump(\n source: AsyncIterable<StreamChunk>,\n mux: StreamMux\n): Promise<void> {\n let seq = 0;\n try {\n for await (const chunk of source) {\n const [ns, mode, payload, meta] = chunk;\n\n // Detect interrupt payloads attached to values-mode chunks.\n if (mode === \"values\" && isInterrupted(payload)) {\n const interrupts = (payload as { [INTERRUPT]: Interrupt[] })[INTERRUPT];\n mux.markInterrupted(\n interrupts.map((i) => ({\n interruptId: i.id ?? \"\",\n payload: i.value,\n }))\n );\n }\n\n const events = convertToProtocolEvent({\n namespace: ns,\n mode,\n payload,\n seq,\n meta,\n });\n seq += events.length;\n for (const event of events) {\n mux.push(ns, event);\n }\n }\n } catch (err) {\n mux.fail(err);\n return;\n }\n mux.close();\n}\n\n/**\n * Serialises a {@link Namespace} array into a single string key using the\n * null byte (`\\x00`) as separator, suitable for `Map`/`Set` lookups.\n *\n * @param ns - The namespace segments to join.\n * @returns A null-byte-joined string key.\n */\nexport function nsKey(ns: Namespace): string {\n return ns.join(\"\\x00\");\n}\n\n/**\n * Tests whether {@link ns} starts with every segment in {@link prefix}.\n *\n * @param ns - The full namespace to check.\n * @param prefix - The prefix to match against.\n * @returns `true` if `ns` begins with `prefix` segment-by-segment.\n */\nexport function hasPrefix(ns: Namespace, prefix: Namespace): boolean {\n if (prefix.length > ns.length) return false;\n for (let i = 0; i < prefix.length; i += 1) {\n if (ns[i] !== prefix[i]) return false;\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAS,cAAc,OAA+C;AACpE,QACE,SAAS,SACR,OAAO,UAAU,YAAY,OAAO,UAAU,eAC/C,OAAQ,MAA6B,SAAS;;;;;;AAQlD,MAAa,iBAAgC,OAAO,gBAAgB;;;;;AAMpE,MAAa,gBAA+B,OAAO,eAAe;;;;;;;;;;AA+ClE,IAAa,YAAb,MAAuB;;CAErB,UAAmB,cAAc,OAAsB;;CAGvD,eAAwB,cAAc,OAA0B;;CAGhE,eAAe;;CAGf,UAAU;;CAGV;;CAGA,eAAe;;;;;;CAOf,oBAA+B,EAAE;CAEjC,gBAAuD,EAAE;CACzD,YAA+C,EAAE;CACjD,6BAAsB,IAAI,KAA2B;CACrD,gCAAyB,IAAI,KAAsC;CACnE,cAA2C,EAAE;;;;;;;;CAS7C,eACE,EAAE;;;;;;;;C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,OAAO;;;;;;;;;AAUb,SAAgB,MAAM,IAAuB;AAC3C,QAAO,GAAG,KAAK,KAAO;;;;;;;;;AAUxB,SAAgB,UAAU,IAAe,QAA4B;AACnE,KAAI,OAAO,SAAS,GAAG,OAAQ,QAAO;AACtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,EACtC,KAAI,GAAG,OAAO,OAAO,GAAI,QAAO;AAElC,QAAO"}
1
+ {"version":3,"file":"mux.js","names":["#transformers","#channels","#streamMap","#latestValues","#interrupts","#finalValues","#closed","#error","#nextEmitSeq","#currentNamespace","#interrupted"],"sources":["../../src/stream/mux.ts"],"sourcesContent":["/**\n * StreamMux — central dispatcher with transformer pipeline.\n *\n * Routes raw stream chunks through registered StreamTransformers, then appends\n * the resulting ProtocolEvents to the main local channel. Also tracks\n * namespace discovery for SubgraphRunStream creation.\n *\n * lifecycle:\n * graph.streamEvents(input, { version: \"v3\" })\n * ├─ StreamMux starts pumping from graph.stream(…, { subgraphs: true })\n * ├─ For each ProtocolEvent:\n * │ ├─ transformer_1.process(event)\n * │ ├─ transformer_2.process(event)\n * │ └─ event appended to _events (unless suppressed)\n * └─ On close: transformer_n.finalize() called in registration order\n */\n\nimport type { StreamChunk } from \"../pregel/stream.js\";\nimport { INTERRUPT, isInterrupted, type Interrupt } from \"../constants.js\";\nimport { convertToProtocolEvent, STREAM_EVENTS_V3_MODES } from \"./convert.js\";\nimport { StreamChannel, isStreamChannel } from \"./stream-channel.js\";\nimport type {\n InterruptPayload,\n Namespace,\n ProtocolEvent,\n StreamEmitter,\n StreamTransformer,\n} from \"./types.js\";\n\nexport { STREAM_EVENTS_V3_MODES };\n\n/**\n * Structural `PromiseLike<T>` predicate — true for thenables including\n * native promises, user-constructed `{ then }` objects, and helper\n * wrappers. Used by {@link StreamMux.wireChannels} to detect final-value\n * projections distinctly from streaming `StreamChannel` values.\n */\nfunction isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return (\n value != null &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n typeof (value as { then?: unknown }).then === \"function\"\n );\n}\n\n/**\n * Symbol key used by {@link StreamMux} to resolve the values promise on a\n * stream handle. Using a symbol keeps this off the public autocomplete surface.\n */\nexport const RESOLVE_VALUES: unique symbol = Symbol(\"resolveValues\");\n\n/**\n * Symbol key used by {@link StreamMux} to reject the values promise on a\n * stream handle. Using a symbol keeps this off the public autocomplete surface.\n */\nexport const REJECT_VALUES: unique symbol = Symbol(\"rejectValues\");\n\n/**\n * Minimal interface that {@link StreamMux} requires from stream handles\n * for lifecycle resolution. This avoids a direct dependency on\n * `GraphRunStream` / `SubgraphRunStream`.\n */\nexport interface StreamHandle {\n [RESOLVE_VALUES](values: unknown): void;\n [REJECT_VALUES](err: unknown): void;\n}\n\n/**\n * Factory function that creates a subgraph stream handle for a newly\n * discovered namespace.\n *\n * Historically consumed by {@link StreamMux} at construction time;\n * today factories are consumed by\n * `createSubgraphDiscoveryTransformer` (via its `createStream`\n * option). This shape is retained for consumers that still thread a\n * mux reference through the factory — the narrower transformer\n * option omits `mux` because it captures the mux in a closure.\n */\nexport type SubgraphStreamFactory = (\n path: Namespace,\n mux: StreamMux,\n discoveryStart: number,\n eventStart: number\n) => StreamHandle;\n\n/**\n * A discovered subgraph namespace paired with its run stream handle.\n */\nexport type SubgraphDiscovery = {\n ns: Namespace;\n stream: StreamHandle;\n};\n\n/**\n * Central event dispatcher that routes {@link ProtocolEvent}s through a\n * pipeline of {@link StreamTransformer}s, manages namespace discovery for\n * subgraph streams, and exposes async iteration over filtered event\n * sequences.\n *\n * One `StreamMux` instance exists per top-level\n * `streamEvents(..., { version: \"v3\" })` invocation.\n */\nexport class StreamMux {\n /** @internal All protocol events in arrival order (after reducer pipeline). */\n readonly _events = StreamChannel.local<ProtocolEvent>();\n\n /** @internal New-namespace discovery notifications. */\n readonly _discoveries = StreamChannel.local<SubgraphDiscovery>();\n\n /** Monotonic counter for auto-forwarded channel events. */\n #nextEmitSeq = 0;\n\n /** Whether the mux has been closed or failed. */\n #closed = false;\n\n /** The error passed to {@link fail}, if any. */\n #error: unknown;\n\n /** Whether the run was interrupted. */\n #interrupted = false;\n\n /**\n * Namespace of the event currently being processed by\n * {@link push}. Read by {@link StreamChannel} wiring callbacks so\n * auto-forwarded events inherit the triggering event's namespace.\n */\n #currentNamespace: Namespace = [];\n\n readonly #transformers: StreamTransformer<unknown>[] = [];\n readonly #channels: StreamChannel<unknown>[] = [];\n readonly #streamMap = new Map<string, StreamHandle>();\n readonly #latestValues = new Map<string, Record<string, unknown>>();\n readonly #interrupts: InterruptPayload[] = [];\n\n /**\n * Final-value projection keys tracked for remote surfacing. Populated\n * by {@link wireChannels} when a transformer's projection contains a\n * `PromiseLike` value. Each entry is flushed as a `custom:<name>`\n * protocol event during {@link close} so that remote clients can\n * observe final-value transformers via `thread.extensions.<name>`.\n */\n readonly #finalValues: Array<{ name: string; promise: Promise<unknown> }> =\n [];\n\n /**\n * Associates a pre-existing stream handle with a namespace so that\n * {@link close} can resolve its values promise later.\n *\n * @param path - The namespace path to register.\n * @param stream - The run stream handle for that namespace.\n */\n register(path: Namespace, stream: StreamHandle): void {\n this.#streamMap.set(nsKey(path), stream);\n }\n\n /**\n * Registers a transformer and replays all buffered events through it so\n * it catches up with events already processed by the mux. When the event\n * log is empty (typical at construction time) the replay is a no-op.\n *\n * The transformer must already have been initialised (i.e. `init()` called\n * and any projection wired). The sequence is:\n *\n * 1. Snapshot the current event log length.\n * 2. Append the transformer so future {@link push} calls reach it.\n * 3. Replay events `[0, snapshot)` through `process()`.\n * 4. If the mux is already closed, call `finalize()` (or `fail()`)\n * immediately so the transformer's log/channel terminates cleanly.\n *\n * @param transformer - An already-initialised transformer to register.\n */\n addTransformer(transformer: StreamTransformer<unknown>): void {\n const snapshot = this._events.size;\n this.#transformers.push(transformer);\n\n // Hand the transformer a narrow emitter handle *before* replay so\n // synthetic-emission transformers (e.g. deepagents\n // `SubagentTransformer`) can inject events into the mux during\n // their own `process()` calls — including the initial replay\n // triggered just below.\n if (transformer.onRegister) {\n const emitter: StreamEmitter = {\n // Transformer-originated events use a placeholder `seq` of\n // `0`. `push()` is the single authority for sequence numbers\n // and will re-stamp this event with the next monotonically\n // increasing value.\n push: (ns, event) => this.push(ns, event),\n };\n transformer.onRegister(emitter);\n }\n\n for (let i = 0; i < snapshot; i += 1) {\n transformer.process(this._events.get(i));\n }\n\n if (this.#closed) {\n if (this.#error !== undefined) {\n transformer.fail?.(this.#error);\n } else {\n transformer.finalize?.();\n }\n }\n }\n\n /**\n * Scans a transformer projection for streaming and final-value primitives.\n * Remote stream channels are wired to auto-forward to the protocol event\n * stream; local stream channels are tracked for lifecycle only.\n *\n * Two projection shapes are recognised:\n *\n * - {@link StreamChannel} values — named channels forward each `push()`\n * immediately as a protocol event on the channel's declared\n * `channelName` method. Unnamed channels remain in-process-only.\n *\n * - `PromiseLike<unknown>` values — tracked as final-value\n * projections and flushed on {@link close} as a single\n * `custom:<key>` event, where `<key>` is the projection key.\n * This mirrors the in-process `await run.extensions.<key>`\n * ergonomics on remote clients via\n * `await thread.extensions.<key>`.\n *\n * Plain values that are neither are ignored — they remain in-process-only,\n * matching prior behaviour.\n *\n * @param projection - The object returned by `transformer.init()`.\n */\n wireChannels(projection: Record<string, unknown>): void {\n for (const [key, value] of Object.entries(projection)) {\n if (isStreamChannel(value)) {\n this.#channels.push(value);\n if (typeof value.channelName !== \"string\") {\n continue;\n }\n value._wire((item: unknown) => {\n this._events.push({\n type: \"event\",\n seq: this.#nextEmitSeq++,\n method: value.channelName as ProtocolEvent[\"method\"],\n params: {\n namespace: this.#currentNamespace,\n timestamp: Date.now(),\n data: item,\n },\n });\n });\n continue;\n }\n if (isPromiseLike(value)) {\n this.#finalValues.push({\n name: key,\n promise: Promise.resolve(value),\n });\n }\n }\n }\n\n /**\n * Distributes an event through the transformer pipeline, then appends it to\n * the main event log.\n *\n * Subgraph discovery (materializing a {@link StreamHandle} for each\n * newly observed top-level namespace) is handled by the\n * {@link createSubgraphDiscoveryTransformer} when installed, not here.\n *\n * @param ns - The namespace path that produced the event.\n * @param event - The protocol event to process and store.\n */\n push(ns: Namespace, event: ProtocolEvent): void {\n if (event.method === \"values\") {\n this.#latestValues.set(\n nsKey(ns),\n event.params.data as Record<string, unknown>\n );\n }\n\n // Save the outer namespace so re-entrant `push()` calls (e.g. from\n // `StreamTransformer.onRegister` emitters synthesizing events\n // inside a transformer's `process()`) can set their own namespace\n // without clobbering the outer scope's `StreamChannel` routing\n // when control returns to the outer transformer loop.\n const outerNamespace = this.#currentNamespace;\n this.#currentNamespace = ns;\n\n let keep = true;\n for (const transformer of this.#transformers) {\n if (!transformer.process(event)) {\n keep = false;\n }\n }\n\n this.#currentNamespace = outerNamespace;\n\n if (keep) {\n // The mux is the single authority for sequence numbers. Callers\n // (the `pump`, transformer emitters, channel forwarders) pass a\n // placeholder `seq`; we re-stamp every event here so the log is\n // strictly monotonic across all origination paths. Stamping\n // happens *after* `process()` so that any channel-forwarded\n // events pushed during processing get earlier sequence numbers\n // than the triggering event, matching their in-order appearance\n // in `_events`.\n this._events.push({ ...event, seq: this.#nextEmitSeq++ });\n }\n }\n\n /**\n * Gracefully ends the stream: resolves values promises on all known\n * streams, finalizes every transformer, auto-closes streaming\n * channels, flushes any final-value projections as `custom:<name>`\n * events, and closes both event logs.\n *\n * When final-value projections are present, `_events.close()` is\n * deferred until every tracked projection promise has settled so\n * remote consumers observe the flushed values before their event\n * stream ends. Callers do not need to await — `close()` returns\n * synchronously and any downstream consumer iterating\n * {@link _events} naturally waits for the final events.\n */\n close(): void {\n this.#closed = true;\n for (const [key, values] of this.#latestValues.entries()) {\n const ns = key ? key.split(\"\\x00\") : [];\n const stream = this.#streamMap.get(nsKey(ns));\n stream?.[RESOLVE_VALUES](values);\n }\n\n const finalizePromises: PromiseLike<void>[] = [];\n for (const transformer of this.#transformers) {\n const result = transformer.finalize?.();\n if (\n result != null &&\n typeof (result as PromiseLike<void>).then === \"function\"\n ) {\n finalizePromises.push(result as PromiseLike<void>);\n }\n }\n\n for (const channel of this.#channels) {\n channel._close();\n }\n\n const finalValues = this.#finalValues;\n if (finalValues.length === 0 && finalizePromises.length === 0) {\n this._events.close();\n this._discoveries.close();\n } else {\n void Promise.allSettled([\n ...finalizePromises,\n ...finalValues.map(async ({ name, promise }) => {\n try {\n const resolved = await promise;\n if (!this._events.done) {\n this._events.push({\n type: \"event\",\n seq: this.#nextEmitSeq++,\n method: \"custom\",\n params: {\n namespace: [],\n timestamp: Date.now(),\n data: { name, payload: resolved },\n },\n });\n }\n } catch {\n // Rejected final-value projections are intentionally dropped\n // so a single failing extension can't poison the protocol\n // stream. The corresponding in-process Promise still\n // surfaces the rejection to its direct awaiters via the\n // transformer's own `fail()` hook.\n }\n }),\n ]).then(() => {\n this._events.close();\n this._discoveries.close();\n });\n }\n\n for (const stream of this.#streamMap.values()) {\n stream[RESOLVE_VALUES](undefined);\n }\n }\n\n /**\n * Propagates a failure to all transformers, channels, event logs, and\n * stream handles.\n *\n * @param err - The error that caused the run to fail.\n */\n fail(err: unknown): void {\n this.#closed = true;\n this.#error = err;\n for (const transformer of this.#transformers) {\n transformer.fail?.(err);\n }\n for (const channel of this.#channels) {\n channel._fail(err);\n }\n this._events.fail(err);\n this._discoveries.fail(err);\n for (const stream of this.#streamMap.values()) {\n stream[REJECT_VALUES](err);\n }\n }\n\n /**\n * Records that the run was interrupted, appending the supplied payloads\n * for later retrieval.\n *\n * @param interrupts - The interrupt payloads to store.\n */\n markInterrupted(interrupts: InterruptPayload[]): void {\n this.#interrupted = true;\n this.#interrupts.push(...interrupts);\n }\n\n /**\n * Whether the run ended due to an interrupt.\n *\n * @returns `true` if {@link markInterrupted} was called.\n */\n get interrupted(): boolean {\n return this.#interrupted;\n }\n\n /**\n * All interrupt payloads collected during the run.\n *\n * @returns A readonly view of the accumulated interrupt payloads.\n */\n get interrupts(): readonly InterruptPayload[] {\n return this.#interrupts;\n }\n\n /**\n * Returns an async iterator that yields only events whose namespace\n * starts with {@link path}.\n *\n * @param path - Namespace prefix to filter on.\n * @param startAt - Zero-based index into the event log to begin from.\n * @returns An async iterator over matching {@link ProtocolEvent}s.\n */\n subscribeEvents(path: Namespace, startAt = 0): AsyncIterator<ProtocolEvent> {\n const base = this._events.iterate(startAt);\n return {\n async next(): Promise<IteratorResult<ProtocolEvent>> {\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const result = await base.next();\n if (result.done) return result;\n if (hasPrefix(result.value.params.namespace, path)) {\n return result;\n }\n }\n },\n };\n }\n}\n\n/**\n * Background consumer that drains a raw `graph.stream()` source into a\n * {@link StreamMux}. Converts each chunk to a {@link ProtocolEvent} and\n * pushes it; calls {@link StreamMux.close} on normal completion or\n * {@link StreamMux.fail} on error.\n *\n * @param source - The async iterable of raw stream chunks from the engine.\n * @param mux - The mux instance to feed.\n * @returns A promise that resolves when the source is fully consumed.\n */\nexport async function pump(\n source: AsyncIterable<StreamChunk>,\n mux: StreamMux\n): Promise<void> {\n let seq = 0;\n try {\n for await (const chunk of source) {\n const [ns, mode, payload] = chunk;\n\n // Detect interrupt payloads attached to values-mode chunks.\n if (mode === \"values\" && isInterrupted(payload)) {\n const interrupts = (payload as { [INTERRUPT]: Interrupt[] })[INTERRUPT];\n mux.markInterrupted(\n interrupts.map((i) => ({\n interruptId: i.id ?? \"\",\n payload: i.value,\n }))\n );\n }\n\n const events = convertToProtocolEvent({\n namespace: ns,\n mode,\n payload,\n seq,\n });\n seq += events.length;\n for (const event of events) {\n mux.push(ns, event);\n }\n }\n } catch (err) {\n mux.fail(err);\n return;\n }\n mux.close();\n}\n\n/**\n * Serialises a {@link Namespace} array into a single string key using the\n * null byte (`\\x00`) as separator, suitable for `Map`/`Set` lookups.\n *\n * @param ns - The namespace segments to join.\n * @returns A null-byte-joined string key.\n */\nexport function nsKey(ns: Namespace): string {\n return ns.join(\"\\x00\");\n}\n\n/**\n * Tests whether {@link ns} starts with every segment in {@link prefix}.\n *\n * @param ns - The full namespace to check.\n * @param prefix - The prefix to match against.\n * @returns `true` if `ns` begins with `prefix` segment-by-segment.\n */\nexport function hasPrefix(ns: Namespace, prefix: Namespace): boolean {\n if (prefix.length > ns.length) return false;\n for (let i = 0; i < prefix.length; i += 1) {\n if (ns[i] !== prefix[i]) return false;\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;AAqCA,SAAS,cAAc,OAA+C;AACpE,QACE,SAAS,SACR,OAAO,UAAU,YAAY,OAAO,UAAU,eAC/C,OAAQ,MAA6B,SAAS;;;;;;AAQlD,MAAa,iBAAgC,OAAO,gBAAgB;;;;;AAMpE,MAAa,gBAA+B,OAAO,eAAe;;;;;;;;;;AA+ClE,IAAa,YAAb,MAAuB;;CAErB,UAAmB,cAAc,OAAsB;;CAGvD,eAAwB,cAAc,OAA0B;;CAGhE,eAAe;;CAGf,UAAU;;CAGV;;CAGA,eAAe;;;;;;CAOf,oBAA+B,EAAE;CAEjC,gBAAuD,EAAE;CACzD,YAA+C,EAAE;CACjD,6BAAsB,IAAI,KAA2B;CACrD,gCAAyB,IAAI,KAAsC;CACnE,cAA2C,EAAE;;;;;;;;CAS7C,eACE,EAAE;;;;;;;;CASJ,SAAS,MAAiB,QAA4B;AACpD,QAAA,UAAgB,IAAI,MAAM,KAAK,EAAE,OAAO;;;;;;;;;;;;;;;;;;CAmB1C,eAAe,aAA+C;EAC5D,MAAM,WAAW,KAAK,QAAQ;AAC9B,QAAA,aAAmB,KAAK,YAAY;AAOpC,MAAI,YAAY,WAQd,aAAY,WAPmB,EAK7B,OAAO,IAAI,UAAU,KAAK,KAAK,IAAI,MAAM,EAC1C,CAC8B;AAGjC,OAAK,IAAI,IAAI,GAAG,IAAI,UAAU,KAAK,EACjC,aAAY,QAAQ,KAAK,QAAQ,IAAI,EAAE,CAAC;AAG1C,MAAI,MAAA,OACF,KAAI,MAAA,UAAgB,KAAA,EAClB,aAAY,OAAO,MAAA,MAAY;MAE/B,aAAY,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;CA4B9B,aAAa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Q,QAAQ,QAAQ;AAC1C,SAAO,EACL,MAAM,OAA+C;AAEnD,UAAO,MAAM;IACX,MAAM,SAAS,MAAM,KAAK,MAAM;AAChC,QAAI,OAAO,KAAM,QAAO;AACxB,QAAI,UAAU,OAAO,MAAM,OAAO,WAAW,KAAK,CAChD,QAAO;;KAId;;;;;;;;;;;;;AAcL,eAAsB,KACpB,QACA,KACe;CACf,IAAI,MAAM;AACV,KAAI;AACF,aAAW,MAAM,SAAS,QAAQ;GAChC,MAAM,CAAC,IAAI,MAAM,WAAW;AAG5B,OAAI,SAAS,YAAY,cAAc,QAAQ,EAAE;IAC/C,MAAM,aAAc,QAAyC;AAC7D,QAAI,gBACF,WAAW,KAAK,OAAO;KACrB,aAAa,EAAE,MAAM;KACrB,SAAS,EAAE;KACZ,EAAE,CACJ;;GAGH,MAAM,SAAS,uBAAuB;IACpC,WAAW;IACX;IACA;IACA;IACD,CAAC;AACF,UAAO,OAAO;AACd,QAAK,MAAM,SAAS,OAClB,KAAI,KAAK,IAAI,MAAM;;UAGhB,KAAK;AACZ,MAAI,KAAK,IAAI;AACb;;AAEF,KAAI,OAAO;;;;;;;;;AAUb,SAAgB,MAAM,IAAuB;AAC3C,QAAO,GAAG,KAAK,KAAO;;;;;;;;;AAUxB,SAAgB,UAAU,IAAe,QAA4B;AACnE,KAAI,OAAO,SAAS,GAAG,OAAQ,QAAO;AACtC,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,EACtC,KAAI,GAAG,OAAO,OAAO,GAAI,QAAO;AAElC,QAAO"}
@@ -1,7 +1,7 @@
1
1
  import { StreamMode } from "../pregel/types.cjs";
2
2
  import { ChatModelStream } from "@langchain/core/language_models/stream";
3
3
  import { ChatModelStreamEvent } from "@langchain/core/language_models/event";
4
- import { AgentStatus as AgentStatus$1, Checkpoint, LifecycleCause, LifecycleData as LifecycleData$1, MessagesData as MessagesEventData, ToolsData as ToolsEventData, UpdatesData as UpdatesEventData, UsageInfo } from "@langchain/protocol";
4
+ import { AgentStatus as AgentStatus$1, LifecycleCause, LifecycleData as LifecycleData$1, MessagesData as MessagesEventData, ToolsData as ToolsEventData, UpdatesData as UpdatesEventData, UsageInfo } from "@langchain/protocol";
5
5
 
6
6
  //#region src/stream/types.d.ts
7
7
  /**
@@ -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, type Checkpoint, 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, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
255
255
  //# sourceMappingURL=types.d.cts.map
@@ -1,7 +1,7 @@
1
1
  import { StreamMode } from "../pregel/types.js";
2
2
  import { ChatModelStream } from "@langchain/core/language_models/stream";
3
3
  import { ChatModelStreamEvent } from "@langchain/core/language_models/event";
4
- import { AgentStatus as AgentStatus$1, Checkpoint, LifecycleCause, LifecycleData as LifecycleData$1, MessagesData as MessagesEventData, ToolsData as ToolsEventData, UpdatesData as UpdatesEventData, UsageInfo } from "@langchain/protocol";
4
+ import { AgentStatus as AgentStatus$1, LifecycleCause, LifecycleData as LifecycleData$1, MessagesData as MessagesEventData, ToolsData as ToolsEventData, UpdatesData as UpdatesEventData, UsageInfo } from "@langchain/protocol";
5
5
 
6
6
  //#region src/stream/types.d.ts
7
7
  /**
@@ -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, type Checkpoint, 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, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, type ToolsEventData, type UpdatesEventData, type UsageInfo, isNativeTransformer };
255
255
  //# sourceMappingURL=types.d.ts.map
package/dist/web.cjs CHANGED
@@ -5,8 +5,8 @@ const require_base = require("./channels/base.cjs");
5
5
  const require_binop = require("./channels/binop.cjs");
6
6
  const require_annotation = require("./graph/annotation.cjs");
7
7
  const require_config = require("./pregel/utils/config.cjs");
8
- const require_stream_channel = require("./stream/stream-channel.cjs");
9
8
  const require_convert = require("./stream/convert.cjs");
9
+ const require_stream_channel = require("./stream/stream-channel.cjs");
10
10
  const require_lifecycle = require("./stream/transformers/lifecycle.cjs");
11
11
  const require_messages = require("./stream/transformers/messages.cjs");
12
12
  const require_subgraphs = require("./stream/transformers/subgraphs.cjs");
@@ -144,6 +144,7 @@ exports.getStore = require_config.getStore;
144
144
  exports.getSubgraphsSeenSet = require_errors.getSubgraphsSeenSet;
145
145
  exports.getWriter = require_config.getWriter;
146
146
  exports.interrupt = require_interrupt.interrupt;
147
+ exports.isCheckpointEnvelope = require_convert.isCheckpointEnvelope;
147
148
  exports.isCommand = require_constants.isCommand;
148
149
  exports.isGraphBubbleUp = require_errors.isGraphBubbleUp;
149
150
  exports.isGraphInterrupt = require_errors.isGraphInterrupt;
package/dist/web.d.cts CHANGED
@@ -15,7 +15,7 @@ import { PregelNode } from "./pregel/read.cjs";
15
15
  import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.cjs";
16
16
  import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.cjs";
17
17
  import { StreamChannel } from "./stream/stream-channel.cjs";
18
- import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.cjs";
18
+ import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.cjs";
19
19
  import { LifecycleEntry, LifecycleTransformerOptions } from "./stream/transformers/types.cjs";
20
20
  import { LifecycleProjection, createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.cjs";
21
21
  import { createMessagesTransformer } from "./stream/transformers/messages.cjs";
@@ -42,4 +42,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
42
42
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
43
43
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
44
44
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
45
- export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
45
+ export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
package/dist/web.d.ts CHANGED
@@ -15,7 +15,7 @@ import { PregelNode } from "./pregel/read.js";
15
15
  import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.js";
16
16
  import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
17
17
  import { StreamChannel } from "./stream/stream-channel.js";
18
- import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.js";
18
+ import { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
19
19
  import { LifecycleEntry, LifecycleTransformerOptions } from "./stream/transformers/types.js";
20
20
  import { LifecycleProjection, createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
21
21
  import { createMessagesTransformer } from "./stream/transformers/messages.js";
@@ -42,4 +42,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
42
42
  import { MessagesValue } from "./state/prebuilt/messages.js";
43
43
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
44
44
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
45
- export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
45
+ export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
package/dist/web.js CHANGED
@@ -4,8 +4,8 @@ import { BaseChannel } from "./channels/base.js";
4
4
  import { BinaryOperatorAggregate } from "./channels/binop.js";
5
5
  import { Annotation } from "./graph/annotation.js";
6
6
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
7
+ import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
7
8
  import { StreamChannel } from "./stream/stream-channel.js";
8
- import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent } from "./stream/convert.js";
9
9
  import { createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
10
10
  import { createMessagesTransformer } from "./stream/transformers/messages.js";
11
11
  import { createSubgraphDiscoveryTransformer, filterSubgraphHandles } from "./stream/transformers/subgraphs.js";
@@ -32,4 +32,4 @@ import { entrypoint, getPreviousState, task } from "./func/index.js";
32
32
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
33
33
  import { writer } from "./writer.js";
34
34
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, MemorySaver, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
35
- export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
35
+ export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -20,10 +20,10 @@
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.11"
23
+ "@langchain/langgraph-sdk": "~1.9.16"
24
24
  },
25
25
  "peerDependencies": {
26
- "@langchain/core": "^1.1.44",
26
+ "@langchain/core": "^1.1.48",
27
27
  "zod": "^3.25.32 || ^4.2.0",
28
28
  "zod-to-json-schema": "^3.x"
29
29
  },
@@ -33,9 +33,9 @@
33
33
  }
34
34
  },
35
35
  "devDependencies": {
36
- "@langchain/anthropic": "^1.3.28",
37
- "@langchain/core": "^1.1.44",
38
- "@langchain/openai": "^1.4.5",
36
+ "@langchain/anthropic": "^1.4.0",
37
+ "@langchain/core": "^1.1.48",
38
+ "@langchain/openai": "^1.4.7",
39
39
  "@langchain/scripts": ">=0.1.3 <0.2.0",
40
40
  "@langchain/tavily": "^1.0.0",
41
41
  "@swc/core": "^1.3.90",
@@ -43,19 +43,20 @@
43
43
  "@tsconfig/recommended": "^1.0.3",
44
44
  "@types/pg": "^8",
45
45
  "@types/uuid": "^10",
46
- "@vitest/browser": "^3.0.8",
46
+ "@vitest/browser": "^4.1.8",
47
+ "@vitest/browser-playwright": "^4.1.8",
47
48
  "@xenova/transformers": "^2.17.2",
48
49
  "cheerio": "1.0.0-rc.12",
49
50
  "dotenv": "^16.3.1",
50
51
  "dpdm": "^3.12.0",
51
- "langchain": "^1.3.5",
52
+ "langchain": "^1.4.4",
52
53
  "pg": "^8.13.0",
53
54
  "playwright": "^1.55.1",
54
55
  "rollup": "^4.37.0",
55
56
  "tsx": "^4.19.3",
56
57
  "typescript": "^4.9.5 || ^5.4.5",
57
- "vite-plugin-node-polyfills": "^0.23.0",
58
- "vitest": "^3.2.4",
58
+ "vite-plugin-node-polyfills": "^0.28.0",
59
+ "vitest": "^4.1.8",
59
60
  "zod-to-json-schema": "^3.22.4",
60
61
  "@langchain/langgraph-checkpoint-postgres": "1.0.2",
61
62
  "@langchain/langgraph-checkpoint-sqlite": "1.0.1"
@@ -1 +0,0 @@
1
- {"version":3,"file":"async_local_storage.cjs","names":["AsyncLocalStorage"],"sources":["../../src/setup/async_local_storage.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\nexport function initializeAsyncLocalStorageSingleton() {\n AsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n );\n}\n"],"mappings":";;;AAGA,SAAgB,uCAAuC;AACrD,4BAAA,mCAAmC,yBACjC,IAAIA,iBAAAA,mBAAmB,CACxB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"async_local_storage.js","names":[],"sources":["../../src/setup/async_local_storage.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { AsyncLocalStorage } from \"node:async_hooks\";\n\nexport function initializeAsyncLocalStorageSingleton() {\n AsyncLocalStorageProviderSingleton.initializeGlobalInstance(\n new AsyncLocalStorage()\n );\n}\n"],"mappings":";;;AAGA,SAAgB,uCAAuC;AACrD,oCAAmC,yBACjC,IAAI,mBAAmB,CACxB"}