@langchain/langgraph 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/dist/graph/graph.cjs +6 -2
  2. package/dist/graph/graph.cjs.map +1 -1
  3. package/dist/graph/graph.d.cts +58 -7
  4. package/dist/graph/graph.d.cts.map +1 -1
  5. package/dist/graph/graph.d.ts +58 -7
  6. package/dist/graph/graph.d.ts.map +1 -1
  7. package/dist/graph/graph.js +6 -2
  8. package/dist/graph/graph.js.map +1 -1
  9. package/dist/graph/index.d.ts +1 -1
  10. package/dist/graph/state.cjs +3 -2
  11. package/dist/graph/state.cjs.map +1 -1
  12. package/dist/graph/state.d.cts +13 -5
  13. package/dist/graph/state.d.cts.map +1 -1
  14. package/dist/graph/state.d.ts +13 -5
  15. package/dist/graph/state.d.ts.map +1 -1
  16. package/dist/graph/state.js +3 -2
  17. package/dist/graph/state.js.map +1 -1
  18. package/dist/index.cjs +34 -5
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +12 -2
  21. package/dist/index.d.ts +12 -2
  22. package/dist/index.js +10 -1
  23. package/dist/index.js.map +1 -1
  24. package/dist/prebuilt/agent_executor.d.cts +1 -1
  25. package/dist/prebuilt/agent_executor.d.ts +1 -1
  26. package/dist/pregel/index.cjs +69 -25
  27. package/dist/pregel/index.cjs.map +1 -1
  28. package/dist/pregel/index.d.cts +25 -3
  29. package/dist/pregel/index.d.cts.map +1 -1
  30. package/dist/pregel/index.d.ts +25 -3
  31. package/dist/pregel/index.d.ts.map +1 -1
  32. package/dist/pregel/index.js +69 -25
  33. package/dist/pregel/index.js.map +1 -1
  34. package/dist/pregel/loop.cjs +51 -10
  35. package/dist/pregel/loop.cjs.map +1 -1
  36. package/dist/pregel/loop.js +51 -10
  37. package/dist/pregel/loop.js.map +1 -1
  38. package/dist/pregel/messages-v2.cjs +231 -0
  39. package/dist/pregel/messages-v2.cjs.map +1 -0
  40. package/dist/pregel/messages-v2.js +231 -0
  41. package/dist/pregel/messages-v2.js.map +1 -0
  42. package/dist/pregel/stream.cjs.map +1 -1
  43. package/dist/pregel/stream.d.cts +30 -0
  44. package/dist/pregel/stream.d.cts.map +1 -0
  45. package/dist/pregel/stream.d.ts +30 -1
  46. package/dist/pregel/stream.d.ts.map +1 -0
  47. package/dist/pregel/stream.js.map +1 -1
  48. package/dist/pregel/types.cjs.map +1 -1
  49. package/dist/pregel/types.d.cts +8 -1
  50. package/dist/pregel/types.d.cts.map +1 -1
  51. package/dist/pregel/types.d.ts +8 -1
  52. package/dist/pregel/types.d.ts.map +1 -1
  53. package/dist/pregel/types.js.map +1 -1
  54. package/dist/stream/convert.cjs +207 -0
  55. package/dist/stream/convert.cjs.map +1 -0
  56. package/dist/stream/convert.d.cts +69 -0
  57. package/dist/stream/convert.d.cts.map +1 -0
  58. package/dist/stream/convert.d.ts +69 -0
  59. package/dist/stream/convert.d.ts.map +1 -0
  60. package/dist/stream/convert.js +206 -0
  61. package/dist/stream/convert.js.map +1 -0
  62. package/dist/stream/index.cjs +11 -0
  63. package/dist/stream/index.d.cts +12 -0
  64. package/dist/stream/index.d.ts +12 -0
  65. package/dist/stream/index.js +12 -0
  66. package/dist/stream/mux.cjs +350 -0
  67. package/dist/stream/mux.cjs.map +1 -0
  68. package/dist/stream/mux.d.cts +160 -0
  69. package/dist/stream/mux.d.cts.map +1 -0
  70. package/dist/stream/mux.d.ts +160 -0
  71. package/dist/stream/mux.d.ts.map +1 -0
  72. package/dist/stream/mux.js +345 -0
  73. package/dist/stream/mux.js.map +1 -0
  74. package/dist/stream/run-stream.cjs +439 -0
  75. package/dist/stream/run-stream.cjs.map +1 -0
  76. package/dist/stream/run-stream.d.cts +286 -0
  77. package/dist/stream/run-stream.d.cts.map +1 -0
  78. package/dist/stream/run-stream.d.ts +285 -0
  79. package/dist/stream/run-stream.d.ts.map +1 -0
  80. package/dist/stream/run-stream.js +434 -0
  81. package/dist/stream/run-stream.js.map +1 -0
  82. package/dist/stream/stream-channel.cjs +208 -0
  83. package/dist/stream/stream-channel.cjs.map +1 -0
  84. package/dist/stream/stream-channel.d.cts +129 -0
  85. package/dist/stream/stream-channel.d.cts.map +1 -0
  86. package/dist/stream/stream-channel.d.ts +129 -0
  87. package/dist/stream/stream-channel.d.ts.map +1 -0
  88. package/dist/stream/stream-channel.js +207 -0
  89. package/dist/stream/stream-channel.js.map +1 -0
  90. package/dist/stream/transformers/index.cjs +4 -0
  91. package/dist/stream/transformers/index.d.ts +5 -0
  92. package/dist/stream/transformers/index.js +5 -0
  93. package/dist/stream/transformers/lifecycle.cjs +326 -0
  94. package/dist/stream/transformers/lifecycle.cjs.map +1 -0
  95. package/dist/stream/transformers/lifecycle.d.cts +53 -0
  96. package/dist/stream/transformers/lifecycle.d.cts.map +1 -0
  97. package/dist/stream/transformers/lifecycle.d.ts +53 -0
  98. package/dist/stream/transformers/lifecycle.d.ts.map +1 -0
  99. package/dist/stream/transformers/lifecycle.js +325 -0
  100. package/dist/stream/transformers/lifecycle.js.map +1 -0
  101. package/dist/stream/transformers/messages.cjs +94 -0
  102. package/dist/stream/transformers/messages.cjs.map +1 -0
  103. package/dist/stream/transformers/messages.d.cts +23 -0
  104. package/dist/stream/transformers/messages.d.cts.map +1 -0
  105. package/dist/stream/transformers/messages.d.ts +23 -0
  106. package/dist/stream/transformers/messages.d.ts.map +1 -0
  107. package/dist/stream/transformers/messages.js +94 -0
  108. package/dist/stream/transformers/messages.js.map +1 -0
  109. package/dist/stream/transformers/subgraphs.cjs +125 -0
  110. package/dist/stream/transformers/subgraphs.cjs.map +1 -0
  111. package/dist/stream/transformers/subgraphs.d.cts +95 -0
  112. package/dist/stream/transformers/subgraphs.d.cts.map +1 -0
  113. package/dist/stream/transformers/subgraphs.d.ts +95 -0
  114. package/dist/stream/transformers/subgraphs.d.ts.map +1 -0
  115. package/dist/stream/transformers/subgraphs.js +124 -0
  116. package/dist/stream/transformers/subgraphs.js.map +1 -0
  117. package/dist/stream/transformers/types.d.cts +89 -0
  118. package/dist/stream/transformers/types.d.cts.map +1 -0
  119. package/dist/stream/transformers/types.d.ts +89 -0
  120. package/dist/stream/transformers/types.d.ts.map +1 -0
  121. package/dist/stream/transformers/values.cjs +39 -0
  122. package/dist/stream/transformers/values.cjs.map +1 -0
  123. package/dist/stream/transformers/values.d.cts +21 -0
  124. package/dist/stream/transformers/values.d.cts.map +1 -0
  125. package/dist/stream/transformers/values.d.ts +21 -0
  126. package/dist/stream/transformers/values.d.ts.map +1 -0
  127. package/dist/stream/transformers/values.js +39 -0
  128. package/dist/stream/transformers/values.js.map +1 -0
  129. package/dist/stream/types.cjs +11 -0
  130. package/dist/stream/types.cjs.map +1 -0
  131. package/dist/stream/types.d.cts +255 -0
  132. package/dist/stream/types.d.cts.map +1 -0
  133. package/dist/stream/types.d.ts +255 -0
  134. package/dist/stream/types.d.ts.map +1 -0
  135. package/dist/stream/types.js +11 -0
  136. package/dist/stream/types.js.map +1 -0
  137. package/dist/web.cjs +39 -9
  138. package/dist/web.d.cts +12 -2
  139. package/dist/web.d.ts +12 -2
  140. package/dist/web.js +10 -1
  141. package/package.json +9 -8
@@ -3,6 +3,7 @@ import { Interrupt } from "../constants.cjs";
3
3
  import { LangGraphRunnableConfig } from "./runnable_types.cjs";
4
4
  import { CachePolicy, RetryPolicy } from "./utils/index.cjs";
5
5
  import { PregelNode } from "./read.cjs";
6
+ import { StreamTransformer } from "../stream/types.cjs";
6
7
  import { All, BaseCache, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointMetadata, PendingWrite } from "@langchain/langgraph-checkpoint";
7
8
  import { Runnable, RunnableConfig } from "@langchain/core/runnables";
8
9
  import { Graph } from "@langchain/core/runnables/graph";
@@ -263,7 +264,7 @@ interface PregelInterface<Nodes extends StrRecord<string, PregelNode>, Channels
263
264
  * Parameters for creating a Pregel graph.
264
265
  * @internal
265
266
  */
266
- type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>> = {
267
+ type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>, TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []> = {
267
268
  /**
268
269
  * The name of the graph. @see {@link Runnable.name}
269
270
  */
@@ -349,6 +350,12 @@ type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends
349
350
  * @internal
350
351
  */
351
352
  userInterrupt?: unknown;
353
+ /**
354
+ * Stream transformer factories registered at compile time. These run
355
+ * automatically for every `streamEvents(..., { version: "v3" })` call,
356
+ * before any call-site transformers.
357
+ */
358
+ streamTransformers?: TStreamTransformers;
352
359
  };
353
360
  interface PregelTaskDescription {
354
361
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/pregel/types.ts"],"mappings":";;;;;;;;;;;;;;AAsBA;KAAY,UAAA;AAAA,KAUA,UAAA;AAAA,KAGA,eAAA;AAAA,KAGA,gBAAA;AAAA,KAGP,mBAAA,IAAuB,WAAA,EAAa,MAAA;AAAA,KAGpC,iBAAA,GAAoB,MAAA;AAAA,KAEpB,uBAAA;EACH,MAAA,EAAQ,YAAA;EACR,IAAA;EACA,MAAA,EAAQ,cAAA;EACR,QAAA,GAAW,kBAAA;EACX,YAAA,GAAe,cAAA;EACf,KAAA,EAAO,qBAAA;AAAA;AAAA,UAGC,qBAAA;EACR,EAAA;EACA,IAAA;EACA,UAAA,EAAY,SAAA;AAAA;AAAA,UAGJ,uBAAA,uBAA8C,qBAAA;EACtD,KAAA,EAAO,YAAA;EACP,QAAA;AAAA;AAAA,UAGQ,uBAAA,8BAGA,qBAAA;EACR,MAAA,GAAS,IAAA,EAAM,aAAA;AAAA;AAAA,KAGZ,iBAAA,gDACD,uBAAA,CAAwB,YAAA,IACxB,uBAAA,CAAwB,KAAA,EAAO,aAAA;AAAA,KAEvB,iBAAA;EAEN,KAAA;EACA,UAAA;EACA,IAAA;EACA,KAAA;AAAA;EAGA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WAAA;EACR,KAAA,GAAQ,WAAA;EACR,SAAA;AAAA;AAAA,cAGW,IAAA;EACX,IAAA,MAAU,IAAA,0BAA8B,OAAA;EAExC,IAAA;EAEA,KAAA;EAEA,KAAA,GAAQ,WAAA;EAER,KAAA,GAAQ,WAAA;EAER,SAAA;EAAA,SAES,SAAA;EAET,WAAA,CAAA;IAAc,IAAA;IAAM,IAAA;IAAM,KAAA;IAAO,KAAA;IAAO,KAAA;IAAO;EAAA,GAAa,WAAA;AAAA;AAAA,KAmBlD,cAAA;AAAA,KACA,gBAAA;AAAA,KACA,YAAA,oCACyB,IAAA,aACxB,QAAA,0BAAkC,IAAA;AAAA,KACnC,QAAA,GAAW,cAAA,GAAiB,YAAA,GAAe,gBAAA"}
@@ -3,6 +3,7 @@ import { Interrupt } from "../constants.js";
3
3
  import { LangGraphRunnableConfig } from "./runnable_types.js";
4
4
  import { CachePolicy, RetryPolicy } from "./utils/index.js";
5
5
  import { PregelNode } from "./read.js";
6
+ import { StreamTransformer } from "../stream/types.js";
6
7
  import { All, BaseCache, BaseCheckpointSaver, BaseStore, CheckpointListOptions, CheckpointMetadata, PendingWrite } from "@langchain/langgraph-checkpoint";
7
8
  import { Runnable, RunnableConfig } from "@langchain/core/runnables";
8
9
  import { Graph } from "@langchain/core/runnables/graph";
@@ -263,7 +264,7 @@ interface PregelInterface<Nodes extends StrRecord<string, PregelNode>, Channels
263
264
  * Parameters for creating a Pregel graph.
264
265
  * @internal
265
266
  */
266
- type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>> = {
267
+ type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends StrRecord<string, BaseChannel>, TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = []> = {
267
268
  /**
268
269
  * The name of the graph. @see {@link Runnable.name}
269
270
  */
@@ -349,6 +350,12 @@ type PregelParams<Nodes extends StrRecord<string, PregelNode>, Channels extends
349
350
  * @internal
350
351
  */
351
352
  userInterrupt?: unknown;
353
+ /**
354
+ * Stream transformer factories registered at compile time. These run
355
+ * automatically for every `streamEvents(..., { version: "v3" })` call,
356
+ * before any call-site transformers.
357
+ */
358
+ streamTransformers?: TStreamTransformers;
352
359
  };
353
360
  interface PregelTaskDescription {
354
361
  readonly id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/pregel/types.ts"],"mappings":";;;;;;;;;;;;;;AAsBA;KAAY,UAAA;AAAA,KAUA,UAAA;AAAA,KAGA,eAAA;AAAA,KAGA,gBAAA;AAAA,KAGP,mBAAA,IAAuB,WAAA,EAAa,MAAA;AAAA,KAGpC,iBAAA,GAAoB,MAAA;AAAA,KAEpB,uBAAA;EACH,MAAA,EAAQ,YAAA;EACR,IAAA;EACA,MAAA,EAAQ,cAAA;EACR,QAAA,GAAW,kBAAA;EACX,YAAA,GAAe,cAAA;EACf,KAAA,EAAO,qBAAA;AAAA;AAAA,UAGC,qBAAA;EACR,EAAA;EACA,IAAA;EACA,UAAA,EAAY,SAAA;AAAA;AAAA,UAGJ,uBAAA,uBAA8C,qBAAA;EACtD,KAAA,EAAO,YAAA;EACP,QAAA;AAAA;AAAA,UAGQ,uBAAA,8BAGA,qBAAA;EACR,MAAA,GAAS,IAAA,EAAM,aAAA;AAAA;AAAA,KAGZ,iBAAA,gDACD,uBAAA,CAAwB,YAAA,IACxB,uBAAA,CAAwB,KAAA,EAAO,aAAA;AAAA,KAEvB,iBAAA;EAEN,KAAA;EACA,UAAA;EACA,IAAA;EACA,KAAA;AAAA;EAGA,KAAA;EACA,UAAA;EACA,IAAA;EACA,IAAA;AAAA;EAGA,KAAA;EACA,UAAA;EACA,IAAA;EACA,MAAA;AAAA;EAGA,KAAA;EACA,UAAA;EACA,IAAA;EACA,KAAA;AAAA;AAAA,KAGD,iBAAA;AAAA,KAEO,aAAA,OAAoB,CAAA,iEACG,CAAA;AAAA,KAKvB,eAAA,qBACU,UAAA,GAAa,UAAA,yKASjC,aAAA,CAA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AAO,KAAA;IAAO;EAAA,GAAa,WAAA;AAAA;AAAA,KAmBlD,cAAA;AAAA,KACA,gBAAA;AAAA,KACA,YAAA,oCACyB,IAAA,aACxB,QAAA,0BAAkC,IAAA;AAAA,KACnC,QAAA,GAAW,cAAA,GAAiB,YAAA,GAAe,gBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/pregel/types.ts"],"sourcesContent":["import type { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n All,\n PendingWrite,\n CheckpointMetadata,\n BaseCheckpointSaver,\n BaseStore,\n CheckpointListOptions,\n BaseCache,\n} from \"@langchain/langgraph-checkpoint\";\nimport { Graph as DrawableGraph } from \"@langchain/core/runnables/graph\";\nimport { IterableReadableStream } from \"@langchain/core/utils/stream\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseChannel } from \"../channels/base.js\";\nimport type { PregelNode } from \"./read.js\";\nimport type { Interrupt } from \"../constants.js\";\nimport { CachePolicy, RetryPolicy } from \"./utils/index.js\";\nimport { LangGraphRunnableConfig } from \"./runnable_types.js\";\n\n/**\n * Selects the type of output you'll receive when streaming from the graph. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.\n */\nexport type StreamMode =\n | \"values\"\n | \"updates\"\n | \"debug\"\n | \"messages\"\n | \"checkpoints\"\n | \"tasks\"\n | \"custom\"\n | \"tools\";\n\nexport type Durability = \"exit\" | \"async\" | \"sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PregelInputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PregelOutputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamMessageOutput = [BaseMessage, Record<string, any>];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamDebugOutput = Record<string, any>;\n\ntype StreamCheckpointsOutput<StreamValues> = {\n values: StreamValues;\n next: string[];\n config: RunnableConfig;\n metadata?: CheckpointMetadata;\n parentConfig?: RunnableConfig | undefined;\n tasks: PregelTaskDescription[];\n};\n\ninterface StreamTasksOutputBase {\n id: string;\n name: string;\n interrupts: Interrupt[];\n}\n\ninterface StreamTasksCreateOutput<StreamValues> extends StreamTasksOutputBase {\n input: StreamValues;\n triggers: string[];\n}\n\ninterface StreamTasksResultOutput<\n Keys,\n StreamUpdates,\n> extends StreamTasksOutputBase {\n result: [Keys, StreamUpdates][];\n}\n\ntype StreamTasksOutput<StreamUpdates, StreamValues, Nodes = string> =\n | StreamTasksCreateOutput<StreamValues>\n | StreamTasksResultOutput<Nodes, StreamUpdates>;\n\nexport type StreamToolsOutput =\n | {\n event: \"on_tool_start\";\n toolCallId?: string;\n name: string;\n input: unknown;\n }\n | {\n event: \"on_tool_event\";\n toolCallId?: string;\n name: string;\n data: unknown;\n }\n | {\n event: \"on_tool_end\";\n toolCallId?: string;\n name: string;\n output: unknown;\n }\n | {\n event: \"on_tool_error\";\n toolCallId?: string;\n name: string;\n error: unknown;\n };\n\ntype DefaultStreamMode = \"updates\";\n\nexport type IsEventStream<T> = [T] extends [\"text/event-stream\"]\n ? [\"text/event-stream\"] extends [T]\n ? true\n : false\n : false;\n\nexport type StreamOutputMap<\n TStreamMode extends StreamMode | StreamMode[] | undefined,\n TStreamSubgraphs extends boolean,\n StreamUpdates,\n StreamValues,\n Nodes,\n NodeReturnType,\n StreamCustom,\n TEncoding extends \"text/event-stream\" | undefined,\n> =\n IsEventStream<TEncoding> extends true\n ? Uint8Array\n : (\n undefined extends TStreamMode\n ? []\n : StreamMode | StreamMode[] extends TStreamMode\n ? TStreamMode extends StreamMode[]\n ? TStreamMode[number]\n : TStreamMode\n : TStreamMode extends StreamMode[]\n ? TStreamMode[number]\n : []\n ) extends infer Multiple extends StreamMode\n ? [TStreamSubgraphs] extends [true]\n ? {\n values: [string[], \"values\", StreamValues];\n updates: [\n string[],\n \"updates\",\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>,\n ];\n messages: [string[], \"messages\", StreamMessageOutput];\n custom: [string[], \"custom\", StreamCustom];\n checkpoints: [\n string[],\n \"checkpoints\",\n StreamCheckpointsOutput<StreamValues>,\n ];\n tasks: [\n string[],\n \"tasks\",\n StreamTasksOutput<StreamUpdates, StreamValues>,\n ];\n tools: [string[], \"tools\", StreamToolsOutput];\n debug: [string[], \"debug\", StreamDebugOutput];\n }[Multiple]\n : {\n values: [\"values\", StreamValues];\n updates: [\n \"updates\",\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>,\n ];\n messages: [\"messages\", StreamMessageOutput];\n custom: [\"custom\", StreamCustom];\n checkpoints: [\"checkpoints\", StreamCheckpointsOutput<StreamValues>];\n tasks: [\n \"tasks\",\n StreamTasksOutput<StreamUpdates, StreamValues, Nodes>,\n ];\n tools: [\"tools\", StreamToolsOutput];\n debug: [\"debug\", StreamDebugOutput];\n }[Multiple]\n : (\n undefined extends TStreamMode ? DefaultStreamMode : TStreamMode\n ) extends infer Single extends StreamMode\n ? [TStreamSubgraphs] extends [true]\n ? {\n values: [string[], StreamValues];\n updates: [\n string[],\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<\n Nodes extends string ? Nodes : string,\n StreamUpdates\n >,\n ];\n messages: [string[], StreamMessageOutput];\n custom: [string[], StreamCustom];\n checkpoints: [string[], StreamCheckpointsOutput<StreamValues>];\n tasks: [\n string[],\n StreamTasksOutput<StreamUpdates, StreamValues, Nodes>,\n ];\n tools: [string[], StreamToolsOutput];\n debug: [string[], StreamDebugOutput];\n }[Single]\n : {\n values: StreamValues;\n updates: NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>;\n messages: StreamMessageOutput;\n custom: StreamCustom;\n checkpoints: StreamCheckpointsOutput<StreamValues>;\n tasks: StreamTasksOutput<StreamUpdates, StreamValues, Nodes>;\n tools: StreamToolsOutput;\n debug: StreamDebugOutput;\n }[Single]\n : never;\n\n/**\n * Configuration options for executing a Pregel graph.\n * These options control how the graph executes, what data is streamed, and how interrupts are handled.\n *\n * @typeParam Nodes - Mapping of node names to their {@link PregelNode} implementations\n * @typeParam Channels - Mapping of channel names to their {@link BaseChannel} implementations\n * @typeParam ContextType - Type of context that can be passed to the graph\n */\nexport interface PregelOptions<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>,\n TStreamMode extends StreamMode | StreamMode[] | undefined =\n | StreamMode\n | StreamMode[]\n | undefined,\n TSubgraphs extends boolean = boolean,\n TEncoding extends \"text/event-stream\" | undefined =\n | \"text/event-stream\"\n | undefined,\n> extends RunnableConfig<ContextType> {\n /**\n * Controls what information is streamed during graph execution.\n * Multiple modes can be enabled simultaneously.\n *\n * Supported modes:\n * - \"values\": Streams complete state after each step\n * - \"updates\": Streams only state changes after each step\n * - \"messages\": Streams messages from within nodes\n * - \"custom\": Streams custom events from within nodes\n * - \"debug\": Streams detailed execution events for tracing & debugging\n *\n * @example\n * ```typescript\n * // Stream only values\n * streamMode: \"values\"\n *\n * // Stream both values and debug info\n * streamMode: [\"values\", \"debug\"]\n * ```\n *\n * @default [\"values\"]\n */\n streamMode?: TStreamMode;\n\n /**\n * Specifies which channel keys to retrieve from the checkpoint when resuming execution.\n * This is an advanced option that you generally don't need to set manually.\n * The graph will automatically determine the appropriate input keys based on its configuration.\n */\n inputKeys?: keyof Channels | Array<keyof Channels>;\n\n /**\n * Specifies which channel keys to include in the output stream and final result.\n * Use this to filter which parts of the graph state you want to observe.\n *\n * @example\n * ```typescript\n * // Stream only the 'result' channel\n * outputKeys: \"result\"\n *\n * // Stream multiple channels\n * outputKeys: [\"result\", \"intermediateState\"]\n * ```\n */\n outputKeys?: keyof Channels | Array<keyof Channels>;\n\n /**\n * List of nodes where execution should be interrupted BEFORE the node runs.\n * Can be used for debugging and advanced state manipulation use cases. For\n * human-in-the-loop workflows, developers should prefer the\n * @link {interrupt} function instead.\n *\n * When interrupted, a resume @link {Command} must be provided to continue\n * execution.\n *\n * @example\n * ```typescript\n * // Interrupt before specific nodes\n * interruptBefore: [\"humanReview\", \"qualityCheck\"]\n *\n * // Interrupt before all nodes\n * interruptBefore: \"all\"\n * ```\n */\n interruptBefore?: All | Array<keyof Nodes>;\n\n /**\n * List of nodes where execution should be interrupted AFTER the node runs.\n * Similar to interruptBefore, but interrupts after node completion.\n * Useful when the node's output needs to be reviewed before proceeding.\n *\n * @example\n * ```typescript\n * // Interrupt after specific nodes\n * interruptAfter: [\"generateContent\", \"analyze\"]\n *\n * // Interrupt after all nodes\n * interruptAfter: \"all\"\n * ```\n */\n interruptAfter?: All | Array<keyof Nodes>;\n\n /**\n * Enables detailed debug logging during graph execution.\n * When enabled, prints information about:\n * - Task execution\n * - Channel updates\n * - Checkpoint writes\n *\n * @default false\n */\n debug?: boolean;\n\n /**\n * Whether to include subgraph execution details in the stream.\n * When true, state updates from nested graphs will also be streamed.\n *\n * @default false\n */\n subgraphs?: TSubgraphs;\n\n /**\n * Whether to checkpoint intermediate steps, defaults to `true`.\n * If `false`, only the final checkpoint is saved.\n * @deprecated Use `durability` instead.\n */\n checkpointDuring?: boolean;\n\n /**\n * Whether to checkpoint during the run (or only at the end/interruption).\n * - `\"async\"`: Save checkpoint asynchronously while the next step executes (default).\n * - `\"sync\"`: Save checkpoint synchronously before the next step starts.\n * - `\"exit\"`: Save checkpoint only when the graph exits.\n * @default \"async\"\n */\n durability?: Durability;\n\n /**\n * A shared value store that allows you to store and retrieve state across\n * threads. Useful for implementing long-term memory patterns.\n */\n store?: BaseStore;\n\n /**\n * Optional cache for the graph, useful for caching tasks.\n */\n cache?: BaseCache;\n\n /**\n * Static context for the graph run, like `userId`, `dbConnection` etc.\n */\n context?: ContextType;\n\n /**\n * The encoding to use for the stream.\n * - `undefined`: Use the default format.\n * - `\"text/event-stream\"`: Use the Server-Sent Events format.\n * @default undefined\n */\n encoding?: TEncoding;\n}\n\n/**\n * Construct a type with a set of properties K of type T\n */\ntype StrRecord<K extends string, T> = {\n [P in K]: T;\n};\n\nexport interface PregelInterface<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = StrRecord<string, any>,\n> {\n lg_is_pregel: boolean;\n\n withConfig(config: RunnableConfig): PregelInterface<Nodes, Channels>;\n\n getGraphAsync(\n config: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph>;\n\n /** @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release. */\n getSubgraphs(\n namespace?: string,\n recurse?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Generator<[string, PregelInterface<any, any>]>;\n\n getSubgraphsAsync(\n namespace?: string,\n recurse?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): AsyncGenerator<[string, PregelInterface<any, any>]>;\n\n getState(\n config: RunnableConfig,\n options?: { subgraphs?: boolean }\n ): Promise<StateSnapshot>;\n\n getStateHistory(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncIterableIterator<StateSnapshot>;\n\n updateState(\n inputConfig: LangGraphRunnableConfig,\n values: Record<string, unknown> | unknown,\n asNode?: keyof Nodes | string\n ): Promise<RunnableConfig>;\n\n stream(\n input: PregelInputType,\n options?: Partial<PregelOptions<Nodes, Channels, ContextType>>\n ): Promise<IterableReadableStream<PregelOutputType>>;\n\n invoke(\n input: PregelInputType,\n options?: Partial<PregelOptions<Nodes, Channels, ContextType>>\n ): Promise<PregelOutputType>;\n}\n\n/**\n * Parameters for creating a Pregel graph.\n * @internal\n */\nexport type PregelParams<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n> = {\n /**\n * The name of the graph. @see {@link Runnable.name}\n */\n name?: string;\n\n /**\n * The nodes in the graph.\n */\n nodes: Nodes;\n\n /**\n * The channels in the graph.\n */\n channels: Channels;\n\n /**\n * Whether to validate the graph.\n *\n * @default true\n */\n autoValidate?: boolean;\n\n /**\n * The stream mode for the graph run. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.\n *\n * @default [\"values\"]\n */\n streamMode?: StreamMode | StreamMode[];\n\n /**\n * The input channels for the graph run.\n */\n inputChannels: keyof Channels | Array<keyof Channels>;\n\n /**\n * The output channels for the graph run.\n */\n outputChannels: keyof Channels | Array<keyof Channels>;\n\n /**\n * After processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.\n * @default []\n */\n interruptAfter?: Array<keyof Nodes> | All;\n\n /**\n * Before processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.\n * @default []\n */\n interruptBefore?: Array<keyof Nodes> | All;\n\n /**\n * The channels to stream from the graph run.\n * @default []\n */\n streamChannels?: keyof Channels | Array<keyof Channels>;\n\n /**\n * @default undefined\n */\n stepTimeout?: number;\n\n /**\n * @default false\n */\n debug?: boolean;\n\n /**\n * The {@link BaseCheckpointSaver | checkpointer} to use for the graph run.\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n\n /**\n * The default retry policy for this graph. For defaults, see {@link RetryPolicy}.\n */\n retryPolicy?: RetryPolicy;\n\n /**\n * The configuration for the graph run.\n */\n config?: LangGraphRunnableConfig;\n\n /**\n * External key-value store.\n */\n store?: BaseStore;\n\n /**\n * Storage used for node caching.\n */\n cache?: BaseCache;\n\n /**\n * The trigger to node mapping for the graph run.\n * @internal\n */\n triggerToNodes?: Record<string, string[]>;\n\n /**\n * Interrupt helper function.\n * @internal\n */\n userInterrupt?: unknown;\n};\n\nexport interface PregelTaskDescription {\n readonly id: string;\n readonly name: string;\n readonly error?: unknown;\n readonly interrupts: Interrupt[];\n readonly state?: LangGraphRunnableConfig | StateSnapshot;\n readonly path?: TaskPath;\n readonly result?: unknown;\n}\n\ninterface CacheKey {\n ns: string[];\n key: string;\n ttl?: number;\n}\n\nexport interface PregelExecutableTask<\n NodeKey extends PropertyKey,\n ChannelKey extends PropertyKey,\n> {\n readonly name: NodeKey;\n readonly input: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly proc: Runnable<any, any, LangGraphRunnableConfig>;\n readonly writes: PendingWrite<ChannelKey>[];\n readonly config?: LangGraphRunnableConfig;\n readonly triggers: Array<string>;\n readonly retry_policy?: RetryPolicy;\n readonly cache_key?: CacheKey;\n readonly id: string;\n readonly path?: TaskPath;\n readonly subgraphs?: Runnable[];\n readonly writers: Runnable[];\n}\n\nexport interface StateSnapshot {\n /**\n * Current values of channels\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly values: Record<string, any> | any;\n /**\n * Nodes to execute in the next step, if any\n */\n readonly next: Array<string>;\n /**\n * Config used to fetch this snapshot\n */\n readonly config: RunnableConfig;\n /**\n * Metadata about the checkpoint\n */\n readonly metadata?: CheckpointMetadata;\n /**\n * Time when the snapshot was created\n */\n readonly createdAt?: string;\n /**\n * Config used to fetch the parent snapshot, if any\n * @default undefined\n */\n readonly parentConfig?: RunnableConfig | undefined;\n /**\n * Tasks to execute in this step. If already attempted, may contain an error.\n */\n readonly tasks: PregelTaskDescription[];\n}\n\n/**\n * Options for subscribing to multiple channels.\n */\nexport type MultipleChannelSubscriptionOptions = {\n /**\n * Optional tags to associate with the subscription.\n */\n tags?: string[];\n};\n\n/**\n * Options for subscribing to a single channel.\n */\nexport type SingleChannelSubscriptionOptions = {\n /**\n * When specified, the channel mapping will be an object with this key pointing\n * to the array of channels to subscribe to. Otherwise, the channel mapping\n * will be an array of channels.\n */\n key?: string;\n /**\n * Optional tags to associate with the subscription.\n */\n tags?: string[];\n};\n\n/**\n * Options for getting the state of the graph.\n */\nexport type GetStateOptions = {\n /**\n * Whether to include subgraph states.\n * @default false\n */\n subgraphs?: boolean;\n};\n\n/**\n * Used for storing/retrieving internal execution state.\n *\n * @internal\n */\nexport type PregelScratchpad<Resume = unknown> = {\n /** Counter for tracking call invocations */\n callCounter: number;\n /** Counter for tracking interrupts */\n interruptCounter: number;\n /** List of resume values */\n resume: Resume[];\n /** Single resume value for null task ID */\n nullResume: Resume;\n\n consumeNullResume: () => Resume | undefined;\n /** Counter for tracking subgraph invocations */\n subgraphCounter: number;\n\n /** The input to the currently executing task */\n currentTaskInput: unknown;\n};\n\n/**\n * @internal\n */\nexport type PregelAbortSignals = {\n /** Aborts when the user calls `stream.cancel()` or aborts the {@link AbortSignal} that they passed in via the `signal` option */\n externalAbortSignal?: AbortSignal;\n\n /**\n * Aborts when the currently executing task throws any error other than a {@link GraphBubbleUp}\n */\n timeoutAbortSignal?: AbortSignal;\n\n /**\n * A reference to the AbortSignal that is passed to the node. Aborts on step timeout, stream cancel, or when an error is thrown.\n */\n composedAbortSignal?: AbortSignal;\n};\n\nexport type CallOptions = {\n func: (...args: unknown[]) => unknown | Promise<unknown>;\n name: string;\n input: unknown;\n cache?: CachePolicy;\n retry?: RetryPolicy;\n callbacks?: unknown;\n};\n\nexport class Call {\n func: (...args: unknown[]) => unknown | Promise<unknown>;\n\n name: string;\n\n input: unknown;\n\n retry?: RetryPolicy;\n\n cache?: CachePolicy;\n\n callbacks?: unknown;\n\n readonly __lg_type = \"call\";\n\n constructor({ func, name, input, retry, cache, callbacks }: CallOptions) {\n this.func = func;\n this.name = name;\n this.input = input;\n this.retry = retry;\n this.cache = cache;\n this.callbacks = callbacks;\n }\n}\n\nexport function isCall(value: unknown): value is Call {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"call\"\n );\n}\n\nexport type SimpleTaskPath = [string, string | number];\nexport type VariadicTaskPath = [string, ...(string | number)[], boolean];\nexport type CallTaskPath =\n | [string, ...(string | number)[], Call]\n | [string, TaskPath, ...(string | number)[], Call];\nexport type TaskPath = SimpleTaskPath | CallTaskPath | VariadicTaskPath;\n"],"mappings":";AAqsBA,IAAa,OAAb,MAAkB;CAChB;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAqB;CAErB,YAAY,EAAE,MAAM,MAAM,OAAO,OAAO,OAAO,aAA0B;AACvE,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,QAAQ;AACb,OAAK,QAAQ;AACb,OAAK,QAAQ;AACb,OAAK,YAAY;;;AAIrB,SAAgB,OAAO,OAA+B;AACpD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAc"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/pregel/types.ts"],"sourcesContent":["import type { Runnable, RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n All,\n PendingWrite,\n CheckpointMetadata,\n BaseCheckpointSaver,\n BaseStore,\n CheckpointListOptions,\n BaseCache,\n} from \"@langchain/langgraph-checkpoint\";\nimport { Graph as DrawableGraph } from \"@langchain/core/runnables/graph\";\nimport { IterableReadableStream } from \"@langchain/core/utils/stream\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseChannel } from \"../channels/base.js\";\nimport type { PregelNode } from \"./read.js\";\nimport type { Interrupt } from \"../constants.js\";\nimport type { StreamTransformer } from \"../stream/types.js\";\nimport { CachePolicy, RetryPolicy } from \"./utils/index.js\";\nimport { LangGraphRunnableConfig } from \"./runnable_types.js\";\n\n/**\n * Selects the type of output you'll receive when streaming from the graph. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.\n */\nexport type StreamMode =\n | \"values\"\n | \"updates\"\n | \"debug\"\n | \"messages\"\n | \"checkpoints\"\n | \"tasks\"\n | \"custom\"\n | \"tools\";\n\nexport type Durability = \"exit\" | \"async\" | \"sync\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PregelInputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PregelOutputType = any;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamMessageOutput = [BaseMessage, Record<string, any>];\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype StreamDebugOutput = Record<string, any>;\n\ntype StreamCheckpointsOutput<StreamValues> = {\n values: StreamValues;\n next: string[];\n config: RunnableConfig;\n metadata?: CheckpointMetadata;\n parentConfig?: RunnableConfig | undefined;\n tasks: PregelTaskDescription[];\n};\n\ninterface StreamTasksOutputBase {\n id: string;\n name: string;\n interrupts: Interrupt[];\n}\n\ninterface StreamTasksCreateOutput<StreamValues> extends StreamTasksOutputBase {\n input: StreamValues;\n triggers: string[];\n}\n\ninterface StreamTasksResultOutput<\n Keys,\n StreamUpdates,\n> extends StreamTasksOutputBase {\n result: [Keys, StreamUpdates][];\n}\n\ntype StreamTasksOutput<StreamUpdates, StreamValues, Nodes = string> =\n | StreamTasksCreateOutput<StreamValues>\n | StreamTasksResultOutput<Nodes, StreamUpdates>;\n\nexport type StreamToolsOutput =\n | {\n event: \"on_tool_start\";\n toolCallId?: string;\n name: string;\n input: unknown;\n }\n | {\n event: \"on_tool_event\";\n toolCallId?: string;\n name: string;\n data: unknown;\n }\n | {\n event: \"on_tool_end\";\n toolCallId?: string;\n name: string;\n output: unknown;\n }\n | {\n event: \"on_tool_error\";\n toolCallId?: string;\n name: string;\n error: unknown;\n };\n\ntype DefaultStreamMode = \"updates\";\n\nexport type IsEventStream<T> = [T] extends [\"text/event-stream\"]\n ? [\"text/event-stream\"] extends [T]\n ? true\n : false\n : false;\n\nexport type StreamOutputMap<\n TStreamMode extends StreamMode | StreamMode[] | undefined,\n TStreamSubgraphs extends boolean,\n StreamUpdates,\n StreamValues,\n Nodes,\n NodeReturnType,\n StreamCustom,\n TEncoding extends \"text/event-stream\" | undefined,\n> =\n IsEventStream<TEncoding> extends true\n ? Uint8Array\n : (\n undefined extends TStreamMode\n ? []\n : StreamMode | StreamMode[] extends TStreamMode\n ? TStreamMode extends StreamMode[]\n ? TStreamMode[number]\n : TStreamMode\n : TStreamMode extends StreamMode[]\n ? TStreamMode[number]\n : []\n ) extends infer Multiple extends StreamMode\n ? [TStreamSubgraphs] extends [true]\n ? {\n values: [string[], \"values\", StreamValues];\n updates: [\n string[],\n \"updates\",\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>,\n ];\n messages: [string[], \"messages\", StreamMessageOutput];\n custom: [string[], \"custom\", StreamCustom];\n checkpoints: [\n string[],\n \"checkpoints\",\n StreamCheckpointsOutput<StreamValues>,\n ];\n tasks: [\n string[],\n \"tasks\",\n StreamTasksOutput<StreamUpdates, StreamValues>,\n ];\n tools: [string[], \"tools\", StreamToolsOutput];\n debug: [string[], \"debug\", StreamDebugOutput];\n }[Multiple]\n : {\n values: [\"values\", StreamValues];\n updates: [\n \"updates\",\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>,\n ];\n messages: [\"messages\", StreamMessageOutput];\n custom: [\"custom\", StreamCustom];\n checkpoints: [\"checkpoints\", StreamCheckpointsOutput<StreamValues>];\n tasks: [\n \"tasks\",\n StreamTasksOutput<StreamUpdates, StreamValues, Nodes>,\n ];\n tools: [\"tools\", StreamToolsOutput];\n debug: [\"debug\", StreamDebugOutput];\n }[Multiple]\n : (\n undefined extends TStreamMode ? DefaultStreamMode : TStreamMode\n ) extends infer Single extends StreamMode\n ? [TStreamSubgraphs] extends [true]\n ? {\n values: [string[], StreamValues];\n updates: [\n string[],\n NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<\n Nodes extends string ? Nodes : string,\n StreamUpdates\n >,\n ];\n messages: [string[], StreamMessageOutput];\n custom: [string[], StreamCustom];\n checkpoints: [string[], StreamCheckpointsOutput<StreamValues>];\n tasks: [\n string[],\n StreamTasksOutput<StreamUpdates, StreamValues, Nodes>,\n ];\n tools: [string[], StreamToolsOutput];\n debug: [string[], StreamDebugOutput];\n }[Single]\n : {\n values: StreamValues;\n updates: NodeReturnType extends Record<string, unknown>\n ? { [K in keyof NodeReturnType]?: NodeReturnType[K] }\n : Record<Nodes extends string ? Nodes : string, StreamUpdates>;\n messages: StreamMessageOutput;\n custom: StreamCustom;\n checkpoints: StreamCheckpointsOutput<StreamValues>;\n tasks: StreamTasksOutput<StreamUpdates, StreamValues, Nodes>;\n tools: StreamToolsOutput;\n debug: StreamDebugOutput;\n }[Single]\n : never;\n\n/**\n * Configuration options for executing a Pregel graph.\n * These options control how the graph executes, what data is streamed, and how interrupts are handled.\n *\n * @typeParam Nodes - Mapping of node names to their {@link PregelNode} implementations\n * @typeParam Channels - Mapping of channel names to their {@link BaseChannel} implementations\n * @typeParam ContextType - Type of context that can be passed to the graph\n */\nexport interface PregelOptions<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>,\n TStreamMode extends StreamMode | StreamMode[] | undefined =\n | StreamMode\n | StreamMode[]\n | undefined,\n TSubgraphs extends boolean = boolean,\n TEncoding extends \"text/event-stream\" | undefined =\n | \"text/event-stream\"\n | undefined,\n> extends RunnableConfig<ContextType> {\n /**\n * Controls what information is streamed during graph execution.\n * Multiple modes can be enabled simultaneously.\n *\n * Supported modes:\n * - \"values\": Streams complete state after each step\n * - \"updates\": Streams only state changes after each step\n * - \"messages\": Streams messages from within nodes\n * - \"custom\": Streams custom events from within nodes\n * - \"debug\": Streams detailed execution events for tracing & debugging\n *\n * @example\n * ```typescript\n * // Stream only values\n * streamMode: \"values\"\n *\n * // Stream both values and debug info\n * streamMode: [\"values\", \"debug\"]\n * ```\n *\n * @default [\"values\"]\n */\n streamMode?: TStreamMode;\n\n /**\n * Specifies which channel keys to retrieve from the checkpoint when resuming execution.\n * This is an advanced option that you generally don't need to set manually.\n * The graph will automatically determine the appropriate input keys based on its configuration.\n */\n inputKeys?: keyof Channels | Array<keyof Channels>;\n\n /**\n * Specifies which channel keys to include in the output stream and final result.\n * Use this to filter which parts of the graph state you want to observe.\n *\n * @example\n * ```typescript\n * // Stream only the 'result' channel\n * outputKeys: \"result\"\n *\n * // Stream multiple channels\n * outputKeys: [\"result\", \"intermediateState\"]\n * ```\n */\n outputKeys?: keyof Channels | Array<keyof Channels>;\n\n /**\n * List of nodes where execution should be interrupted BEFORE the node runs.\n * Can be used for debugging and advanced state manipulation use cases. For\n * human-in-the-loop workflows, developers should prefer the\n * @link {interrupt} function instead.\n *\n * When interrupted, a resume @link {Command} must be provided to continue\n * execution.\n *\n * @example\n * ```typescript\n * // Interrupt before specific nodes\n * interruptBefore: [\"humanReview\", \"qualityCheck\"]\n *\n * // Interrupt before all nodes\n * interruptBefore: \"all\"\n * ```\n */\n interruptBefore?: All | Array<keyof Nodes>;\n\n /**\n * List of nodes where execution should be interrupted AFTER the node runs.\n * Similar to interruptBefore, but interrupts after node completion.\n * Useful when the node's output needs to be reviewed before proceeding.\n *\n * @example\n * ```typescript\n * // Interrupt after specific nodes\n * interruptAfter: [\"generateContent\", \"analyze\"]\n *\n * // Interrupt after all nodes\n * interruptAfter: \"all\"\n * ```\n */\n interruptAfter?: All | Array<keyof Nodes>;\n\n /**\n * Enables detailed debug logging during graph execution.\n * When enabled, prints information about:\n * - Task execution\n * - Channel updates\n * - Checkpoint writes\n *\n * @default false\n */\n debug?: boolean;\n\n /**\n * Whether to include subgraph execution details in the stream.\n * When true, state updates from nested graphs will also be streamed.\n *\n * @default false\n */\n subgraphs?: TSubgraphs;\n\n /**\n * Whether to checkpoint intermediate steps, defaults to `true`.\n * If `false`, only the final checkpoint is saved.\n * @deprecated Use `durability` instead.\n */\n checkpointDuring?: boolean;\n\n /**\n * Whether to checkpoint during the run (or only at the end/interruption).\n * - `\"async\"`: Save checkpoint asynchronously while the next step executes (default).\n * - `\"sync\"`: Save checkpoint synchronously before the next step starts.\n * - `\"exit\"`: Save checkpoint only when the graph exits.\n * @default \"async\"\n */\n durability?: Durability;\n\n /**\n * A shared value store that allows you to store and retrieve state across\n * threads. Useful for implementing long-term memory patterns.\n */\n store?: BaseStore;\n\n /**\n * Optional cache for the graph, useful for caching tasks.\n */\n cache?: BaseCache;\n\n /**\n * Static context for the graph run, like `userId`, `dbConnection` etc.\n */\n context?: ContextType;\n\n /**\n * The encoding to use for the stream.\n * - `undefined`: Use the default format.\n * - `\"text/event-stream\"`: Use the Server-Sent Events format.\n * @default undefined\n */\n encoding?: TEncoding;\n}\n\n/**\n * Construct a type with a set of properties K of type T\n */\ntype StrRecord<K extends string, T> = {\n [P in K]: T;\n};\n\nexport interface PregelInterface<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = StrRecord<string, any>,\n> {\n lg_is_pregel: boolean;\n\n withConfig(config: RunnableConfig): PregelInterface<Nodes, Channels>;\n\n getGraphAsync(\n config: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph>;\n\n /** @deprecated Use getSubgraphsAsync instead. The async method will become the default in the next minor release. */\n getSubgraphs(\n namespace?: string,\n recurse?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Generator<[string, PregelInterface<any, any>]>;\n\n getSubgraphsAsync(\n namespace?: string,\n recurse?: boolean\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): AsyncGenerator<[string, PregelInterface<any, any>]>;\n\n getState(\n config: RunnableConfig,\n options?: { subgraphs?: boolean }\n ): Promise<StateSnapshot>;\n\n getStateHistory(\n config: RunnableConfig,\n options?: CheckpointListOptions\n ): AsyncIterableIterator<StateSnapshot>;\n\n updateState(\n inputConfig: LangGraphRunnableConfig,\n values: Record<string, unknown> | unknown,\n asNode?: keyof Nodes | string\n ): Promise<RunnableConfig>;\n\n stream(\n input: PregelInputType,\n options?: Partial<PregelOptions<Nodes, Channels, ContextType>>\n ): Promise<IterableReadableStream<PregelOutputType>>;\n\n invoke(\n input: PregelInputType,\n options?: Partial<PregelOptions<Nodes, Channels, ContextType>>\n ): Promise<PregelOutputType>;\n}\n\n/**\n * Parameters for creating a Pregel graph.\n * @internal\n */\nexport type PregelParams<\n Nodes extends StrRecord<string, PregelNode>,\n Channels extends StrRecord<string, BaseChannel>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n TStreamTransformers extends ReadonlyArray<() => StreamTransformer<any>> = [],\n> = {\n /**\n * The name of the graph. @see {@link Runnable.name}\n */\n name?: string;\n\n /**\n * The nodes in the graph.\n */\n nodes: Nodes;\n\n /**\n * The channels in the graph.\n */\n channels: Channels;\n\n /**\n * Whether to validate the graph.\n *\n * @default true\n */\n autoValidate?: boolean;\n\n /**\n * The stream mode for the graph run. See [Streaming](/langgraphjs/how-tos/#streaming) for more details.\n *\n * @default [\"values\"]\n */\n streamMode?: StreamMode | StreamMode[];\n\n /**\n * The input channels for the graph run.\n */\n inputChannels: keyof Channels | Array<keyof Channels>;\n\n /**\n * The output channels for the graph run.\n */\n outputChannels: keyof Channels | Array<keyof Channels>;\n\n /**\n * After processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.\n * @default []\n */\n interruptAfter?: Array<keyof Nodes> | All;\n\n /**\n * Before processing one of the nodes named in this list, the graph will be interrupted and a resume {@link Command} must be provided to proceed with the execution of this thread.\n * @default []\n */\n interruptBefore?: Array<keyof Nodes> | All;\n\n /**\n * The channels to stream from the graph run.\n * @default []\n */\n streamChannels?: keyof Channels | Array<keyof Channels>;\n\n /**\n * @default undefined\n */\n stepTimeout?: number;\n\n /**\n * @default false\n */\n debug?: boolean;\n\n /**\n * The {@link BaseCheckpointSaver | checkpointer} to use for the graph run.\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n\n /**\n * The default retry policy for this graph. For defaults, see {@link RetryPolicy}.\n */\n retryPolicy?: RetryPolicy;\n\n /**\n * The configuration for the graph run.\n */\n config?: LangGraphRunnableConfig;\n\n /**\n * External key-value store.\n */\n store?: BaseStore;\n\n /**\n * Storage used for node caching.\n */\n cache?: BaseCache;\n\n /**\n * The trigger to node mapping for the graph run.\n * @internal\n */\n triggerToNodes?: Record<string, string[]>;\n\n /**\n * Interrupt helper function.\n * @internal\n */\n userInterrupt?: unknown;\n\n /**\n * Stream transformer factories registered at compile time. These run\n * automatically for every `streamEvents(..., { version: \"v3\" })` call,\n * before any call-site transformers.\n */\n streamTransformers?: TStreamTransformers;\n};\n\nexport interface PregelTaskDescription {\n readonly id: string;\n readonly name: string;\n readonly error?: unknown;\n readonly interrupts: Interrupt[];\n readonly state?: LangGraphRunnableConfig | StateSnapshot;\n readonly path?: TaskPath;\n readonly result?: unknown;\n}\n\ninterface CacheKey {\n ns: string[];\n key: string;\n ttl?: number;\n}\n\nexport interface PregelExecutableTask<\n NodeKey extends PropertyKey,\n ChannelKey extends PropertyKey,\n> {\n readonly name: NodeKey;\n readonly input: unknown;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly proc: Runnable<any, any, LangGraphRunnableConfig>;\n readonly writes: PendingWrite<ChannelKey>[];\n readonly config?: LangGraphRunnableConfig;\n readonly triggers: Array<string>;\n readonly retry_policy?: RetryPolicy;\n readonly cache_key?: CacheKey;\n readonly id: string;\n readonly path?: TaskPath;\n readonly subgraphs?: Runnable[];\n readonly writers: Runnable[];\n}\n\nexport interface StateSnapshot {\n /**\n * Current values of channels\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n readonly values: Record<string, any> | any;\n /**\n * Nodes to execute in the next step, if any\n */\n readonly next: Array<string>;\n /**\n * Config used to fetch this snapshot\n */\n readonly config: RunnableConfig;\n /**\n * Metadata about the checkpoint\n */\n readonly metadata?: CheckpointMetadata;\n /**\n * Time when the snapshot was created\n */\n readonly createdAt?: string;\n /**\n * Config used to fetch the parent snapshot, if any\n * @default undefined\n */\n readonly parentConfig?: RunnableConfig | undefined;\n /**\n * Tasks to execute in this step. If already attempted, may contain an error.\n */\n readonly tasks: PregelTaskDescription[];\n}\n\n/**\n * Options for subscribing to multiple channels.\n */\nexport type MultipleChannelSubscriptionOptions = {\n /**\n * Optional tags to associate with the subscription.\n */\n tags?: string[];\n};\n\n/**\n * Options for subscribing to a single channel.\n */\nexport type SingleChannelSubscriptionOptions = {\n /**\n * When specified, the channel mapping will be an object with this key pointing\n * to the array of channels to subscribe to. Otherwise, the channel mapping\n * will be an array of channels.\n */\n key?: string;\n /**\n * Optional tags to associate with the subscription.\n */\n tags?: string[];\n};\n\n/**\n * Options for getting the state of the graph.\n */\nexport type GetStateOptions = {\n /**\n * Whether to include subgraph states.\n * @default false\n */\n subgraphs?: boolean;\n};\n\n/**\n * Used for storing/retrieving internal execution state.\n *\n * @internal\n */\nexport type PregelScratchpad<Resume = unknown> = {\n /** Counter for tracking call invocations */\n callCounter: number;\n /** Counter for tracking interrupts */\n interruptCounter: number;\n /** List of resume values */\n resume: Resume[];\n /** Single resume value for null task ID */\n nullResume: Resume;\n\n consumeNullResume: () => Resume | undefined;\n /** Counter for tracking subgraph invocations */\n subgraphCounter: number;\n\n /** The input to the currently executing task */\n currentTaskInput: unknown;\n};\n\n/**\n * @internal\n */\nexport type PregelAbortSignals = {\n /** Aborts when the user calls `stream.cancel()` or aborts the {@link AbortSignal} that they passed in via the `signal` option */\n externalAbortSignal?: AbortSignal;\n\n /**\n * Aborts when the currently executing task throws any error other than a {@link GraphBubbleUp}\n */\n timeoutAbortSignal?: AbortSignal;\n\n /**\n * A reference to the AbortSignal that is passed to the node. Aborts on step timeout, stream cancel, or when an error is thrown.\n */\n composedAbortSignal?: AbortSignal;\n};\n\nexport type CallOptions = {\n func: (...args: unknown[]) => unknown | Promise<unknown>;\n name: string;\n input: unknown;\n cache?: CachePolicy;\n retry?: RetryPolicy;\n callbacks?: unknown;\n};\n\nexport class Call {\n func: (...args: unknown[]) => unknown | Promise<unknown>;\n\n name: string;\n\n input: unknown;\n\n retry?: RetryPolicy;\n\n cache?: CachePolicy;\n\n callbacks?: unknown;\n\n readonly __lg_type = \"call\";\n\n constructor({ func, name, input, retry, cache, callbacks }: CallOptions) {\n this.func = func;\n this.name = name;\n this.input = input;\n this.retry = retry;\n this.cache = cache;\n this.callbacks = callbacks;\n }\n}\n\nexport function isCall(value: unknown): value is Call {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"call\"\n );\n}\n\nexport type SimpleTaskPath = [string, string | number];\nexport type VariadicTaskPath = [string, ...(string | number)[], boolean];\nexport type CallTaskPath =\n | [string, ...(string | number)[], Call]\n | [string, TaskPath, ...(string | number)[], Call];\nexport type TaskPath = SimpleTaskPath | CallTaskPath | VariadicTaskPath;\n"],"mappings":";AA+sBA,IAAa,OAAb,MAAkB;CAChB;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA,YAAqB;CAErB,YAAY,EAAE,MAAM,MAAM,OAAO,OAAO,OAAO,aAA0B;AACvE,OAAK,OAAO;AACZ,OAAK,OAAO;AACZ,OAAK,QAAQ;AACb,OAAK,QAAQ;AACb,OAAK,QAAQ;AACb,OAAK,YAAY;;;AAIrB,SAAgB,OAAO,OAA+B;AACpD,QACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe,SACf,MAAM,cAAc"}
@@ -0,0 +1,207 @@
1
+ //#region src/stream/convert.ts
2
+ /**
3
+ * The set of stream modes requested by
4
+ * `streamEvents(..., { version: "v3" })` — every mode the protocol maps
5
+ * to a channel.
6
+ *
7
+ * The verbose `"debug"` mode is intentionally excluded: it was a thin
8
+ * re-wrap of `checkpoints` + `tasks` carrying no new information.
9
+ *
10
+ * The `"checkpoints"` mode is likewise excluded from the stream-mode
11
+ * request because the protocol's `checkpoints` channel carries only a
12
+ * lightweight envelope (`id`, `parent_id`, `step`, `source`) derived from
13
+ * {@link StreamChunkMeta.checkpoint} on the adjacent `values` chunk — not
14
+ * the full-state shape that Pregel's `checkpoints` stream mode produces.
15
+ * `convertToProtocolEvent` emits a companion `checkpoints` protocol event
16
+ * next to each `values` event when meta is present, so clients can build
17
+ * branching/time-travel UIs without a full-state `checkpoints` subscription.
18
+ */
19
+ const STREAM_EVENTS_V3_MODES = [
20
+ "values",
21
+ "updates",
22
+ "messages",
23
+ "tools",
24
+ "custom",
25
+ "tasks"
26
+ ];
27
+ function unwrapMessagesPayload(payload) {
28
+ if (!Array.isArray(payload) || payload.length !== 2) return { data: payload };
29
+ const [data, metadata] = payload;
30
+ if (metadata == null || typeof metadata !== "object") return { data: payload };
31
+ const record = metadata;
32
+ const node = typeof record.langgraph_node === "string" ? record.langgraph_node : void 0;
33
+ const runId = typeof record.run_id === "string" ? record.run_id : void 0;
34
+ return {
35
+ data: runId != null && data != null && typeof data === "object" ? {
36
+ ...data,
37
+ run_id: runId
38
+ } : data,
39
+ node
40
+ };
41
+ }
42
+ function convertToProtocolEvent({ namespace: ns, mode, payload, seq, meta }) {
43
+ const timestamp = Date.now();
44
+ const base = { type: "event" };
45
+ switch (mode) {
46
+ case "messages": {
47
+ const { data, node } = unwrapMessagesPayload(payload);
48
+ return [{
49
+ ...base,
50
+ seq,
51
+ method: "messages",
52
+ params: {
53
+ namespace: ns,
54
+ timestamp,
55
+ ...node ? { node } : {},
56
+ data
57
+ }
58
+ }];
59
+ }
60
+ case "tools": return [{
61
+ ...base,
62
+ seq,
63
+ method: "tools",
64
+ params: {
65
+ namespace: ns,
66
+ timestamp,
67
+ data: convertToolsPayload(payload)
68
+ }
69
+ }];
70
+ case "values": {
71
+ const events = [];
72
+ if (meta?.checkpoint != null) events.push({
73
+ ...base,
74
+ seq,
75
+ method: "checkpoints",
76
+ params: {
77
+ namespace: ns,
78
+ timestamp,
79
+ data: meta.checkpoint
80
+ }
81
+ });
82
+ events.push({
83
+ ...base,
84
+ seq: meta?.checkpoint != null ? seq + 1 : seq,
85
+ method: "values",
86
+ params: {
87
+ namespace: ns,
88
+ timestamp,
89
+ data: payload
90
+ }
91
+ });
92
+ return events;
93
+ }
94
+ case "updates": {
95
+ const data = convertUpdatesPayload(payload);
96
+ return [{
97
+ ...base,
98
+ seq,
99
+ method: "updates",
100
+ params: {
101
+ namespace: ns,
102
+ timestamp,
103
+ ...typeof data.node === "string" ? { node: data.node } : {},
104
+ data
105
+ }
106
+ }];
107
+ }
108
+ case "custom": {
109
+ const data = typeof payload === "object" && payload !== null && !Array.isArray(payload) && "name" in payload ? payload : { payload };
110
+ return [{
111
+ ...base,
112
+ seq,
113
+ method: "custom",
114
+ params: {
115
+ namespace: ns,
116
+ timestamp,
117
+ data
118
+ }
119
+ }];
120
+ }
121
+ case "tasks": return [{
122
+ ...base,
123
+ seq,
124
+ method: "tasks",
125
+ params: {
126
+ namespace: ns,
127
+ timestamp,
128
+ data: payload
129
+ }
130
+ }];
131
+ default: return [];
132
+ }
133
+ }
134
+ /**
135
+ * Normalises a raw tools-mode payload into a typed {@link ToolsEventData}
136
+ * discriminated union, mapping internal lifecycle events (`on_tool_start`,
137
+ * `on_tool_end`, etc.) to their protocol counterparts.
138
+ *
139
+ * @param payload - The raw payload from a `"tools"` stream chunk.
140
+ * @returns A {@link ToolsEventData} object with the appropriate `event`
141
+ * discriminant and associated fields.
142
+ */
143
+ function convertToolsPayload(payload) {
144
+ if (typeof payload !== "object" || payload === null) return {
145
+ event: "tool-error",
146
+ tool_call_id: "",
147
+ message: "Unexpected tools payload shape"
148
+ };
149
+ const p = payload;
150
+ const tool_call_id = String(p.toolCallId ?? "");
151
+ switch (p.event) {
152
+ case "on_tool_start": return {
153
+ event: "tool-started",
154
+ tool_call_id,
155
+ tool_name: String(p.name ?? "unknown"),
156
+ input: p.input
157
+ };
158
+ case "on_tool_event": return {
159
+ event: "tool-output-delta",
160
+ tool_call_id,
161
+ delta: typeof p.data === "string" ? p.data : JSON.stringify(p.data ?? "")
162
+ };
163
+ case "on_tool_end": return {
164
+ event: "tool-finished",
165
+ tool_call_id,
166
+ output: p.output
167
+ };
168
+ case "on_tool_error": {
169
+ const err = p.error;
170
+ return {
171
+ event: "tool-error",
172
+ tool_call_id,
173
+ message: typeof err === "object" && err !== null && "message" in err && typeof err.message === "string" ? err.message : String(err ?? "unknown error")
174
+ };
175
+ }
176
+ default: return {
177
+ event: "tool-error",
178
+ tool_call_id: "",
179
+ message: `Unknown tool event: ${String(p.event)}`
180
+ };
181
+ }
182
+ }
183
+ /**
184
+ * Extracts the first `{node: delta}` entry from an updates-mode payload and
185
+ * reshapes it into an {@link UpdatesEventData} with explicit `node` and
186
+ * `values` fields. Non-object payloads are coerced to `{ values: {} }`.
187
+ *
188
+ * @param payload - The raw payload from an `"updates"` stream chunk,
189
+ * expected to be a `Record<string, unknown>` keyed by node name.
190
+ * @returns An {@link UpdatesEventData} containing the extracted node name
191
+ * and its associated delta values.
192
+ */
193
+ function convertUpdatesPayload(payload) {
194
+ if (typeof payload !== "object" || payload === null) return { values: {} };
195
+ const entries = Object.entries(payload);
196
+ if (entries.length === 0) return { values: {} };
197
+ const [node, values] = entries[0];
198
+ return {
199
+ node,
200
+ values: typeof values === "object" && values !== null ? values : { value: values }
201
+ };
202
+ }
203
+ //#endregion
204
+ exports.STREAM_EVENTS_V3_MODES = STREAM_EVENTS_V3_MODES;
205
+ exports.convertToProtocolEvent = convertToProtocolEvent;
206
+
207
+ //# sourceMappingURL=convert.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.cjs","names":[],"sources":["../../src/stream/convert.ts"],"sourcesContent":["/**\n * Protocol event conversion — maps raw `[ns, mode, payload, meta?]` stream\n * chunks from graph.stream() to CDDL-aligned ProtocolEvents.\n */\n\nimport type { StreamMode } from \"../pregel/types.js\";\nimport type { StreamChunkMeta } from \"../pregel/stream.js\";\nimport type {\n Namespace,\n ProtocolEvent,\n ToolsEventData,\n UpdatesEventData,\n} from \"./types.js\";\n\n/**\n * The set of stream modes requested by\n * `streamEvents(..., { version: \"v3\" })` — every mode the protocol maps\n * to a channel.\n *\n * The verbose `\"debug\"` mode is intentionally excluded: it was a thin\n * re-wrap of `checkpoints` + `tasks` carrying no new information.\n *\n * The `\"checkpoints\"` mode is likewise excluded from the stream-mode\n * request because the protocol's `checkpoints` channel carries only a\n * lightweight envelope (`id`, `parent_id`, `step`, `source`) derived from\n * {@link StreamChunkMeta.checkpoint} on the adjacent `values` chunk — not\n * the full-state shape that Pregel's `checkpoints` stream mode produces.\n * `convertToProtocolEvent` emits a companion `checkpoints` protocol event\n * next to each `values` event when meta is present, so clients can build\n * branching/time-travel UIs without a full-state `checkpoints` subscription.\n */\nexport const STREAM_EVENTS_V3_MODES: StreamMode[] = [\n \"values\",\n \"updates\",\n \"messages\",\n \"tools\",\n \"custom\",\n \"tasks\",\n];\n\n/**\n * Converts a raw `[ns, mode, payload, meta?]` stream chunk emitted by\n * `graph.stream()` into one or more CDDL-aligned {@link ProtocolEvent}s.\n *\n * Most modes produce a single event. `values` chunks carrying\n * {@link StreamChunkMeta.checkpoint} additionally produce a companion\n * `checkpoints` event immediately after the `values` event, so clients\n * that subscribe only to `checkpoints` can build a branching timeline\n * without also paying for full-state `values` payloads, and clients that\n * subscribe to both can correlate the pair by `(namespace, step)` or by\n * adjacent `seq` numbers.\n *\n * Returns an empty array for stream modes that have no protocol mapping.\n *\n * @param options - Conversion inputs for a single raw stream chunk.\n * @param options.namespace - Hierarchical namespace path identifying the\n * source in the agent tree.\n * @param options.mode - The stream mode that produced this chunk (e.g.\n * `\"messages\"`, `\"tools\"`).\n * @param options.payload - The raw payload emitted by the stream for this\n * mode.\n * @param options.seq - Monotonically increasing sequence number assigned to\n * the first returned event; the companion `checkpoints` event (when\n * emitted) uses `seq + 1`.\n * @param options.meta - Optional chunk-level metadata (e.g. the checkpoint\n * envelope paired with a `values` chunk).\n * @returns An ordered list of {@link ProtocolEvent}s ready for downstream\n * reducers. Callers advance their `seq` counter by `result.length`.\n */\nexport interface ConvertToProtocolEventOptions {\n namespace: Namespace;\n mode: StreamMode;\n payload: unknown;\n seq: number;\n meta?: StreamChunkMeta;\n}\n\nfunction unwrapMessagesPayload(payload: unknown) {\n if (!Array.isArray(payload) || payload.length !== 2) {\n return { data: payload };\n }\n\n const [data, metadata] = payload;\n if (metadata == null || typeof metadata !== \"object\") {\n return { data: payload };\n }\n\n const record = metadata as Record<string, unknown>;\n const node =\n typeof record.langgraph_node === \"string\"\n ? record.langgraph_node\n : undefined;\n const runId = typeof record.run_id === \"string\" ? record.run_id : undefined;\n const dataWithRunId =\n runId != null && data != null && typeof data === \"object\"\n ? { ...(data as Record<string, unknown>), run_id: runId }\n : data;\n\n return { data: dataWithRunId, node };\n}\n\nexport function convertToProtocolEvent({\n namespace: ns,\n mode,\n payload,\n seq,\n meta,\n}: ConvertToProtocolEventOptions): ProtocolEvent[] {\n const timestamp = Date.now();\n const base = { type: \"event\" as const };\n\n switch (mode) {\n case \"messages\": {\n const { data, node } = unwrapMessagesPayload(payload);\n return [\n {\n ...base,\n seq,\n method: \"messages\",\n params: { namespace: ns, timestamp, ...(node ? { node } : {}), data },\n },\n ];\n }\n\n case \"tools\":\n return [\n {\n ...base,\n seq,\n method: \"tools\",\n params: {\n namespace: ns,\n timestamp,\n data: convertToolsPayload(payload),\n },\n },\n ];\n\n case \"values\": {\n // Emit the `checkpoints` event immediately BEFORE its companion\n // `values` event so clients subscribed to both channels have the\n // envelope buffered by the time the values payload arrives. This\n // lets the SDK attach `parentCheckpointId` to messages extracted\n // from the values snapshot without waiting for a second pass.\n const events: ProtocolEvent[] = [];\n if (meta?.checkpoint != null) {\n events.push({\n ...base,\n seq,\n method: \"checkpoints\",\n params: { namespace: ns, timestamp, data: meta.checkpoint },\n });\n }\n events.push({\n ...base,\n seq: meta?.checkpoint != null ? seq + 1 : seq,\n method: \"values\",\n params: { namespace: ns, timestamp, data: payload },\n });\n return events;\n }\n\n case \"updates\": {\n const data = convertUpdatesPayload(payload);\n return [\n {\n ...base,\n seq,\n method: \"updates\",\n params: {\n namespace: ns,\n timestamp,\n // Surface the completed node at the top level of `params` so\n // transformers (notably `LifecycleTransformer`) can attribute\n // a finished task to its child namespace without re-parsing\n // the payload. The same value is retained inside `data` for\n // downstream consumers that inspect the event body.\n ...(typeof data.node === \"string\" ? { node: data.node } : {}),\n data,\n },\n },\n ];\n }\n\n case \"custom\": {\n const data =\n typeof payload === \"object\" &&\n payload !== null &&\n !Array.isArray(payload) &&\n \"name\" in payload\n ? payload\n : { payload };\n return [\n {\n ...base,\n seq,\n method: \"custom\",\n params: { namespace: ns, timestamp, data },\n },\n ];\n }\n\n case \"tasks\":\n return [\n {\n ...base,\n seq,\n method: \"tasks\",\n params: { namespace: ns, timestamp, data: payload },\n },\n ];\n\n default:\n return [];\n }\n}\n\n/**\n * Normalises a raw tools-mode payload into a typed {@link ToolsEventData}\n * discriminated union, mapping internal lifecycle events (`on_tool_start`,\n * `on_tool_end`, etc.) to their protocol counterparts.\n *\n * @param payload - The raw payload from a `\"tools\"` stream chunk.\n * @returns A {@link ToolsEventData} object with the appropriate `event`\n * discriminant and associated fields.\n */\nfunction convertToolsPayload(payload: unknown): ToolsEventData {\n if (typeof payload !== \"object\" || payload === null) {\n return {\n event: \"tool-error\",\n tool_call_id: \"\",\n message: \"Unexpected tools payload shape\",\n };\n }\n\n const p = payload as Record<string, unknown>;\n const tool_call_id = String(p.toolCallId ?? \"\");\n\n switch (p.event) {\n case \"on_tool_start\":\n return {\n event: \"tool-started\",\n tool_call_id,\n tool_name: String(p.name ?? \"unknown\"),\n input: p.input,\n };\n\n case \"on_tool_event\": {\n const delta =\n typeof p.data === \"string\" ? p.data : JSON.stringify(p.data ?? \"\");\n return {\n event: \"tool-output-delta\",\n tool_call_id,\n delta,\n };\n }\n\n case \"on_tool_end\":\n return {\n event: \"tool-finished\",\n tool_call_id,\n output: p.output,\n };\n\n case \"on_tool_error\": {\n const err = p.error;\n const errMessage =\n typeof err === \"object\" &&\n err !== null &&\n \"message\" in err &&\n typeof (err as { message: unknown }).message === \"string\"\n ? (err as { message: string }).message\n : String(err ?? \"unknown error\");\n return {\n event: \"tool-error\",\n tool_call_id,\n message: errMessage,\n };\n }\n\n default:\n return {\n event: \"tool-error\",\n tool_call_id: \"\",\n message: `Unknown tool event: ${String(p.event)}`,\n };\n }\n}\n\n/**\n * Extracts the first `{node: delta}` entry from an updates-mode payload and\n * reshapes it into an {@link UpdatesEventData} with explicit `node` and\n * `values` fields. Non-object payloads are coerced to `{ values: {} }`.\n *\n * @param payload - The raw payload from an `\"updates\"` stream chunk,\n * expected to be a `Record<string, unknown>` keyed by node name.\n * @returns An {@link UpdatesEventData} containing the extracted node name\n * and its associated delta values.\n */\nfunction convertUpdatesPayload(payload: unknown): UpdatesEventData {\n if (typeof payload !== \"object\" || payload === null) {\n return { values: {} };\n }\n\n const entries = Object.entries(payload as Record<string, unknown>);\n if (entries.length === 0) {\n return { values: {} };\n }\n\n const [node, values] = entries[0];\n return {\n node,\n values: (typeof values === \"object\" && values !== null\n ? values\n : { value: values }) as Record<string, unknown>,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,MAAa,yBAAuC;CAClD;CACA;CACA;CACA;CACA;CACA;CACD;AAuCD,SAAS,sBAAsB,SAAkB;AAC/C,KAAI,CAAC,MAAM,QAAQ,QAAQ,IAAI,QAAQ,WAAW,EAChD,QAAO,EAAE,MAAM,SAAS;CAG1B,MAAM,CAAC,MAAM,YAAY;AACzB,KAAI,YAAY,QAAQ,OAAO,aAAa,SAC1C,QAAO,EAAE,MAAM,SAAS;CAG1B,MAAM,SAAS;CACf,MAAM,OACJ,OAAO,OAAO,mBAAmB,WAC7B,OAAO,iBACP,KAAA;CACN,MAAM,QAAQ,OAAO,OAAO,WAAW,WAAW,OAAO,SAAS,KAAA;AAMlE,QAAO;EAAE,MAJP,SAAS,QAAQ,QAAQ,QAAQ,OAAO,SAAS,WAC7C;GAAE,GAAI;GAAkC,QAAQ;GAAO,GACvD;EA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AAS,OAAO,WAAW,YAAY,WAAW,OAC9C,SACA,EAAE,OAAO,QAAQ;EACtB"}
@@ -0,0 +1,69 @@
1
+ import { Namespace, ProtocolEvent } from "./types.cjs";
2
+ import { StreamMode } from "../pregel/types.cjs";
3
+ import { StreamChunkMeta } from "../pregel/stream.cjs";
4
+
5
+ //#region src/stream/convert.d.ts
6
+ /**
7
+ * The set of stream modes requested by
8
+ * `streamEvents(..., { version: "v3" })` — every mode the protocol maps
9
+ * to a channel.
10
+ *
11
+ * The verbose `"debug"` mode is intentionally excluded: it was a thin
12
+ * re-wrap of `checkpoints` + `tasks` carrying no new information.
13
+ *
14
+ * The `"checkpoints"` mode is likewise excluded from the stream-mode
15
+ * request because the protocol's `checkpoints` channel carries only a
16
+ * lightweight envelope (`id`, `parent_id`, `step`, `source`) derived from
17
+ * {@link StreamChunkMeta.checkpoint} on the adjacent `values` chunk — not
18
+ * the full-state shape that Pregel's `checkpoints` stream mode produces.
19
+ * `convertToProtocolEvent` emits a companion `checkpoints` protocol event
20
+ * next to each `values` event when meta is present, so clients can build
21
+ * branching/time-travel UIs without a full-state `checkpoints` subscription.
22
+ */
23
+ declare const STREAM_EVENTS_V3_MODES: StreamMode[];
24
+ /**
25
+ * Converts a raw `[ns, mode, payload, meta?]` stream chunk emitted by
26
+ * `graph.stream()` into one or more CDDL-aligned {@link ProtocolEvent}s.
27
+ *
28
+ * Most modes produce a single event. `values` chunks carrying
29
+ * {@link StreamChunkMeta.checkpoint} additionally produce a companion
30
+ * `checkpoints` event immediately after the `values` event, so clients
31
+ * that subscribe only to `checkpoints` can build a branching timeline
32
+ * without also paying for full-state `values` payloads, and clients that
33
+ * subscribe to both can correlate the pair by `(namespace, step)` or by
34
+ * adjacent `seq` numbers.
35
+ *
36
+ * Returns an empty array for stream modes that have no protocol mapping.
37
+ *
38
+ * @param options - Conversion inputs for a single raw stream chunk.
39
+ * @param options.namespace - Hierarchical namespace path identifying the
40
+ * source in the agent tree.
41
+ * @param options.mode - The stream mode that produced this chunk (e.g.
42
+ * `"messages"`, `"tools"`).
43
+ * @param options.payload - The raw payload emitted by the stream for this
44
+ * mode.
45
+ * @param options.seq - Monotonically increasing sequence number assigned to
46
+ * the first returned event; the companion `checkpoints` event (when
47
+ * emitted) uses `seq + 1`.
48
+ * @param options.meta - Optional chunk-level metadata (e.g. the checkpoint
49
+ * envelope paired with a `values` chunk).
50
+ * @returns An ordered list of {@link ProtocolEvent}s ready for downstream
51
+ * reducers. Callers advance their `seq` counter by `result.length`.
52
+ */
53
+ interface ConvertToProtocolEventOptions {
54
+ namespace: Namespace;
55
+ mode: StreamMode;
56
+ payload: unknown;
57
+ seq: number;
58
+ meta?: StreamChunkMeta;
59
+ }
60
+ declare function convertToProtocolEvent({
61
+ namespace: ns,
62
+ mode,
63
+ payload,
64
+ seq,
65
+ meta
66
+ }: ConvertToProtocolEventOptions): ProtocolEvent[];
67
+ //#endregion
68
+ export { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent };
69
+ //# sourceMappingURL=convert.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.cts","names":[],"sources":["../../src/stream/convert.ts"],"mappings":";;;;;;;;AAqEA;;;;;;;;;;;;;;cAtCa,sBAAA,EAAwB,UAAA;;;;AAsErC;;;;;;;;;;;;;;;;;;;;;;;;;;UAhCiB,6BAAA;EACf,SAAA,EAAW,SAAA;EACX,IAAA,EAAM,UAAA;EACN,OAAA;EACA,GAAA;EACA,IAAA,GAAO,eAAA;AAAA;AAAA,iBA2BO,sBAAA,CAAA;EACd,SAAA,EAAW,EAAA;EACX,IAAA;EACA,OAAA;EACA,GAAA;EACA;AAAA,GACC,6BAAA,GAAgC,aAAA"}
@@ -0,0 +1,69 @@
1
+ import { Namespace, ProtocolEvent } from "./types.js";
2
+ import { StreamMode } from "../pregel/types.js";
3
+ import { StreamChunkMeta } from "../pregel/stream.js";
4
+
5
+ //#region src/stream/convert.d.ts
6
+ /**
7
+ * The set of stream modes requested by
8
+ * `streamEvents(..., { version: "v3" })` — every mode the protocol maps
9
+ * to a channel.
10
+ *
11
+ * The verbose `"debug"` mode is intentionally excluded: it was a thin
12
+ * re-wrap of `checkpoints` + `tasks` carrying no new information.
13
+ *
14
+ * The `"checkpoints"` mode is likewise excluded from the stream-mode
15
+ * request because the protocol's `checkpoints` channel carries only a
16
+ * lightweight envelope (`id`, `parent_id`, `step`, `source`) derived from
17
+ * {@link StreamChunkMeta.checkpoint} on the adjacent `values` chunk — not
18
+ * the full-state shape that Pregel's `checkpoints` stream mode produces.
19
+ * `convertToProtocolEvent` emits a companion `checkpoints` protocol event
20
+ * next to each `values` event when meta is present, so clients can build
21
+ * branching/time-travel UIs without a full-state `checkpoints` subscription.
22
+ */
23
+ declare const STREAM_EVENTS_V3_MODES: StreamMode[];
24
+ /**
25
+ * Converts a raw `[ns, mode, payload, meta?]` stream chunk emitted by
26
+ * `graph.stream()` into one or more CDDL-aligned {@link ProtocolEvent}s.
27
+ *
28
+ * Most modes produce a single event. `values` chunks carrying
29
+ * {@link StreamChunkMeta.checkpoint} additionally produce a companion
30
+ * `checkpoints` event immediately after the `values` event, so clients
31
+ * that subscribe only to `checkpoints` can build a branching timeline
32
+ * without also paying for full-state `values` payloads, and clients that
33
+ * subscribe to both can correlate the pair by `(namespace, step)` or by
34
+ * adjacent `seq` numbers.
35
+ *
36
+ * Returns an empty array for stream modes that have no protocol mapping.
37
+ *
38
+ * @param options - Conversion inputs for a single raw stream chunk.
39
+ * @param options.namespace - Hierarchical namespace path identifying the
40
+ * source in the agent tree.
41
+ * @param options.mode - The stream mode that produced this chunk (e.g.
42
+ * `"messages"`, `"tools"`).
43
+ * @param options.payload - The raw payload emitted by the stream for this
44
+ * mode.
45
+ * @param options.seq - Monotonically increasing sequence number assigned to
46
+ * the first returned event; the companion `checkpoints` event (when
47
+ * emitted) uses `seq + 1`.
48
+ * @param options.meta - Optional chunk-level metadata (e.g. the checkpoint
49
+ * envelope paired with a `values` chunk).
50
+ * @returns An ordered list of {@link ProtocolEvent}s ready for downstream
51
+ * reducers. Callers advance their `seq` counter by `result.length`.
52
+ */
53
+ interface ConvertToProtocolEventOptions {
54
+ namespace: Namespace;
55
+ mode: StreamMode;
56
+ payload: unknown;
57
+ seq: number;
58
+ meta?: StreamChunkMeta;
59
+ }
60
+ declare function convertToProtocolEvent({
61
+ namespace: ns,
62
+ mode,
63
+ payload,
64
+ seq,
65
+ meta
66
+ }: ConvertToProtocolEventOptions): ProtocolEvent[];
67
+ //#endregion
68
+ export { ConvertToProtocolEventOptions, STREAM_EVENTS_V3_MODES, convertToProtocolEvent };
69
+ //# sourceMappingURL=convert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert.d.ts","names":[],"sources":["../../src/stream/convert.ts"],"mappings":";;;;;;;;AAqEA;;;;;;;;;;;;;;cAtCa,sBAAA,EAAwB,UAAA;;;;AAsErC;;;;;;;;;;;;;;;;;;;;;;;;;;UAhCiB,6BAAA;EACf,SAAA,EAAW,SAAA;EACX,IAAA,EAAM,UAAA;EACN,OAAA;EACA,GAAA;EACA,IAAA,GAAO,eAAA;AAAA;AAAA,iBA2BO,sBAAA,CAAA;EACd,SAAA,EAAW,EAAA;EACX,IAAA;EACA,OAAA;EACA,GAAA;EACA;AAAA,GACC,6BAAA,GAAgC,aAAA"}