@langchain/langgraph 1.1.5 → 1.2.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 (128) hide show
  1. package/dist/channels/binop.cjs +13 -2
  2. package/dist/channels/binop.cjs.map +1 -1
  3. package/dist/channels/binop.d.cts +4 -2
  4. package/dist/channels/binop.d.cts.map +1 -1
  5. package/dist/channels/binop.d.ts +4 -2
  6. package/dist/channels/binop.d.ts.map +1 -1
  7. package/dist/channels/binop.js +14 -3
  8. package/dist/channels/binop.js.map +1 -1
  9. package/dist/constants.cjs +78 -0
  10. package/dist/constants.cjs.map +1 -1
  11. package/dist/constants.d.cts +49 -1
  12. package/dist/constants.d.cts.map +1 -1
  13. package/dist/constants.d.ts +49 -1
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/constants.js +76 -1
  16. package/dist/constants.js.map +1 -1
  17. package/dist/func/index.cjs +1 -1
  18. package/dist/func/index.d.cts +1 -1
  19. package/dist/func/index.d.ts +1 -1
  20. package/dist/func/index.js +1 -1
  21. package/dist/graph/annotation.cjs.map +1 -1
  22. package/dist/graph/annotation.d.cts +3 -2
  23. package/dist/graph/annotation.d.cts.map +1 -1
  24. package/dist/graph/annotation.d.ts +3 -2
  25. package/dist/graph/annotation.d.ts.map +1 -1
  26. package/dist/graph/annotation.js.map +1 -1
  27. package/dist/graph/graph.cjs +3 -6
  28. package/dist/graph/graph.cjs.map +1 -1
  29. package/dist/graph/graph.d.cts +2 -2
  30. package/dist/graph/graph.d.cts.map +1 -1
  31. package/dist/graph/graph.d.ts +2 -2
  32. package/dist/graph/graph.d.ts.map +1 -1
  33. package/dist/graph/graph.js +3 -6
  34. package/dist/graph/graph.js.map +1 -1
  35. package/dist/graph/index.cjs +1 -1
  36. package/dist/graph/index.d.ts +1 -1
  37. package/dist/graph/index.js +1 -1
  38. package/dist/graph/messages_annotation.d.cts +3 -2
  39. package/dist/graph/messages_annotation.d.cts.map +1 -1
  40. package/dist/graph/messages_annotation.d.ts +3 -2
  41. package/dist/graph/messages_annotation.d.ts.map +1 -1
  42. package/dist/graph/state.cjs +1 -1
  43. package/dist/graph/state.d.cts +1 -1
  44. package/dist/graph/state.d.ts +1 -1
  45. package/dist/graph/state.js +1 -1
  46. package/dist/graph/types.cjs +1 -1
  47. package/dist/graph/types.d.cts +1 -1
  48. package/dist/graph/types.d.ts +1 -1
  49. package/dist/graph/types.js +1 -1
  50. package/dist/graph/zod/meta.cjs.map +1 -1
  51. package/dist/graph/zod/meta.d.cts +3 -2
  52. package/dist/graph/zod/meta.d.cts.map +1 -1
  53. package/dist/graph/zod/meta.d.ts +3 -2
  54. package/dist/graph/zod/meta.d.ts.map +1 -1
  55. package/dist/graph/zod/meta.js.map +1 -1
  56. package/dist/index.cjs +2 -1
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.js +2 -2
  60. package/dist/interrupt.cjs +1 -1
  61. package/dist/interrupt.js +1 -1
  62. package/dist/prebuilt/react_agent_executor.cjs +1 -1
  63. package/dist/prebuilt/react_agent_executor.d.cts +5 -5
  64. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  65. package/dist/prebuilt/react_agent_executor.d.ts +5 -5
  66. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  67. package/dist/prebuilt/react_agent_executor.js +1 -1
  68. package/dist/prebuilt/tool_node.cjs +1 -1
  69. package/dist/prebuilt/tool_node.d.cts +1 -1
  70. package/dist/prebuilt/tool_node.d.ts +1 -1
  71. package/dist/prebuilt/tool_node.js +1 -1
  72. package/dist/pregel/algo.cjs +1 -1
  73. package/dist/pregel/algo.d.ts +1 -1
  74. package/dist/pregel/algo.js +1 -1
  75. package/dist/pregel/index.cjs +13 -1
  76. package/dist/pregel/index.cjs.map +1 -1
  77. package/dist/pregel/index.d.cts +2 -1
  78. package/dist/pregel/index.d.cts.map +1 -1
  79. package/dist/pregel/index.d.ts +2 -1
  80. package/dist/pregel/index.d.ts.map +1 -1
  81. package/dist/pregel/index.js +14 -2
  82. package/dist/pregel/index.js.map +1 -1
  83. package/dist/pregel/io.cjs +1 -1
  84. package/dist/pregel/io.js +1 -1
  85. package/dist/pregel/loop.cjs +1 -1
  86. package/dist/pregel/loop.js +1 -1
  87. package/dist/pregel/read.cjs +4 -1
  88. package/dist/pregel/read.cjs.map +1 -1
  89. package/dist/pregel/read.d.cts.map +1 -1
  90. package/dist/pregel/read.d.ts.map +1 -1
  91. package/dist/pregel/read.js +4 -1
  92. package/dist/pregel/read.js.map +1 -1
  93. package/dist/pregel/remote.cjs +1 -1
  94. package/dist/pregel/remote.js +1 -1
  95. package/dist/pregel/retry.cjs +1 -1
  96. package/dist/pregel/retry.js +1 -1
  97. package/dist/pregel/runner.cjs +1 -1
  98. package/dist/pregel/runner.js +1 -1
  99. package/dist/pregel/stream.cjs +81 -0
  100. package/dist/pregel/stream.cjs.map +1 -1
  101. package/dist/pregel/stream.d.ts +2 -1
  102. package/dist/pregel/stream.js +81 -1
  103. package/dist/pregel/stream.js.map +1 -1
  104. package/dist/pregel/types.cjs.map +1 -1
  105. package/dist/pregel/types.d.cts +27 -2
  106. package/dist/pregel/types.d.cts.map +1 -1
  107. package/dist/pregel/types.d.ts +27 -2
  108. package/dist/pregel/types.d.ts.map +1 -1
  109. package/dist/pregel/types.js.map +1 -1
  110. package/dist/pregel/write.cjs +2 -1
  111. package/dist/pregel/write.cjs.map +1 -1
  112. package/dist/pregel/write.d.cts +1 -1
  113. package/dist/pregel/write.d.cts.map +1 -1
  114. package/dist/pregel/write.d.ts +1 -1
  115. package/dist/pregel/write.d.ts.map +1 -1
  116. package/dist/pregel/write.js +2 -1
  117. package/dist/pregel/write.js.map +1 -1
  118. package/dist/state/schema.cjs.map +1 -1
  119. package/dist/state/schema.d.cts +3 -2
  120. package/dist/state/schema.d.cts.map +1 -1
  121. package/dist/state/schema.d.ts +3 -2
  122. package/dist/state/schema.d.ts.map +1 -1
  123. package/dist/state/schema.js.map +1 -1
  124. package/dist/web.cjs +2 -1
  125. package/dist/web.d.cts +2 -2
  126. package/dist/web.d.ts +2 -2
  127. package/dist/web.js +2 -2
  128. package/package.json +4 -4
@@ -1,9 +1,9 @@
1
1
  import { BaseChannel } from "../channels/base.js";
2
+ import { END, START, Send } from "../constants.js";
2
3
  import { LangGraphRunnableConfig, RunnableLike as RunnableLike$1 } from "../pregel/runnable_types.js";
3
4
  import { StateDefinition, StateType } from "./annotation.js";
4
5
  import { RunnableCallable } from "../utils.js";
5
6
  import { PregelNode } from "../pregel/read.js";
6
- import { END, START, Send } from "../constants.js";
7
7
  import { PregelParams } from "../pregel/types.js";
8
8
  import { Pregel } from "../pregel/index.js";
9
9
  import { All, BaseCheckpointSaver } from "@langchain/langgraph-checkpoint";
@@ -19,7 +19,7 @@ interface BranchOptions<IO, N extends string, CallOptions extends LangGraphRunna
19
19
  type BranchPathReturnValue = string | Send | (string | Send)[] | Promise<string | Send | (string | Send)[]>;
20
20
  type NodeAction<S, U, C extends StateDefinition> = RunnableLike$1<S, U extends object ? U & Record<string, any> : U, LangGraphRunnableConfig<StateType<C>>>;
21
21
  declare class Branch<IO, N extends string, CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig> {
22
- path: Runnable<IO, BranchPathReturnValue, CallOptions>;
22
+ path: Runnable<IO, BranchPathReturnValue>;
23
23
  ends?: Record<string, N | typeof END>;
24
24
  constructor(options: Omit<BranchOptions<IO, N, CallOptions>, "source">);
25
25
  run(writer: (dests: (string | Send)[], config: LangGraphRunnableConfig) => Runnable | void | Promise<void>, reader?: (config: CallOptions) => IO): RunnableCallable<unknown, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","names":[],"sources":["../../src/graph/graph.ts"],"mappings":";;;;;;;;;;;;;UAgDiB,aAAA,2CAGK,uBAAA,GAA0B,uBAAA;EAE9C,MAAA,EAAQ,CAAA;EACR,IAAA,EAAM,cAAA,CAAa,EAAA,EAAI,qBAAA,EAAuB,WAAA;E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AAA,EACA,UAAA,EACA,cAAA,EACA,WAAA,EACA,gBAAA;EAAA,aAEqB,CAAA;EAAA,mBAEM,cAAA;EAAA,aAEN,MAAA;EAAA,cAEC,KAAA;EAEtB,OAAA,EAAS,OAAA,CAAM,CAAA,EAAG,KAAA,EAAO,MAAA;EAEzB,WAAA,CAAA;IACE,OAAA;IAAA,GACG;EAAA;IACA,OAAA,EAAS,OAAA,CAAM,CAAA,EAAG,KAAA,EAAO,MAAA;EAAA,IAAY,YAAA,CACxC,MAAA,CAAO,CAAA,UAAW,KAAA,EAAO,UAAA,CAAW,KAAA,EAAO,MAAA,IAC3C,MAAA,CAAO,CAAA,UAAW,KAAA,UAAe,GAAA,WAAc,WAAA;EAMjD,UAAA,CAAW,GAAA,EAAK,CAAA,EAAG,IAAA,EAAM,QAAA,CAAS,KAAA,EAAO,MAAA;EAgBzC,UAAA,CAAW,KAAA,EAAO,CAAA,UAAW,KAAA,EAAO,GAAA,EAAK,CAAA,UAAW,GAAA;EAcpD,YAAA,CACE,KAAA,EAAO,CAAA,UAAW,KAAA,EAClB,IAAA,UACA,MAAA,EAAQ,MAAA,CAAO,KAAA,EAAO,CAAA;EApjBJ;;;EA6lBL,aAAA,CACb,MAAA,GAAS,cAAA;IAAmB,IAAA;EAAA,IAC3B,OAAA,CAAQ,KAAA;EA7lBY;;;;;EAkyBd,QAAA,CACP,MAAA,GAAS,cAAA;IAAmB,IAAA;EAAA,IAC3B,KAAA;AAAA"}
@@ -1,5 +1,5 @@
1
- import { InvalidUpdateError, NodeInterrupt, UnreachableNodeError } from "../errors.js";
2
1
  import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, END, START, TAG_HIDDEN, _isSend } from "../constants.js";
2
+ import { InvalidUpdateError, NodeInterrupt, UnreachableNodeError } from "../errors.js";
3
3
  import { RunnableCallable, gatherIterator, gatherIteratorSync } from "../utils.js";
4
4
  import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
5
5
  import { PregelNode } from "../pregel/read.js";
@@ -17,7 +17,7 @@ var Branch = class {
17
17
  ends;
18
18
  constructor(options) {
19
19
  if (Runnable.isRunnable(options.path)) this.path = options.path;
20
- else this.path = _coerceToRunnable(options.path).withConfig({ runName: `Branch` });
20
+ else this.path = _coerceToRunnable(options.path);
21
21
  this.ends = Array.isArray(options.pathMap) ? options.pathMap.reduce((acc, n) => {
22
22
  acc[n] = n;
23
23
  return acc;
@@ -105,10 +105,7 @@ var Graph$1 = class {
105
105
  pathMap
106
106
  };
107
107
  this.warnIfCompiled("Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.");
108
- if (!Runnable.isRunnable(options.path)) {
109
- const pathDisplayValues = Array.isArray(options.pathMap) ? options.pathMap.join(",") : Object.keys(options.pathMap ?? {}).join(",");
110
- options.path = _coerceToRunnable(options.path).withConfig({ runName: `Branch<${options.source}${pathDisplayValues !== "" ? `,${pathDisplayValues}` : ""}>`.slice(0, 63) });
111
- }
108
+ if (!Runnable.isRunnable(options.path)) options.path = _coerceToRunnable(options.path);
112
109
  const name = options.path.getName() === "RunnableLambda" ? "condition" : options.path.getName();
113
110
  if (this.branches[options.source] && this.branches[options.source][name]) throw new Error(`Condition \`${name}\` already present for node \`${source}\``);
114
111
  this.branches[options.source] ??= {};
@@ -1 +1 @@
1
- {"version":3,"file":"graph.js","names":["Graph","DrawableGraph","isUuid"],"sources":["../../src/graph/graph.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n _coerceToRunnable,\n Runnable,\n RunnableConfig,\n RunnableInterface,\n RunnableIOSchema,\n type RunnableLike as LangChainRunnableLike,\n} from \"@langchain/core/runnables\";\nimport {\n Node as DrawableGraphNode,\n Graph as DrawableGraph,\n} from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { z } from \"zod/v4\";\nimport { validate as isUuid } from \"uuid\";\nimport type {\n RunnableLike,\n LangGraphRunnableConfig,\n} from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Channel, Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\nimport {\n _isSend,\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n END,\n Send,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport {\n gatherIterator,\n gatherIteratorSync,\n RunnableCallable,\n} from \"../utils.js\";\nimport {\n InvalidUpdateError,\n NodeInterrupt,\n UnreachableNodeError,\n} from \"../errors.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nimport { isPregelLike } from \"../pregel/utils/subgraph.js\";\n\nexport interface BranchOptions<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\n\nexport type BranchPathReturnValue =\n | string\n | Send\n | (string | Send)[]\n | Promise<string | Send | (string | Send)[]>;\n\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<\n S,\n U extends object ? U & Record<string, any> : U, // eslint-disable-line @typescript-eslint/no-explicit-any\n LangGraphRunnableConfig<StateType<C>>\n>;\n\nexport class Branch<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n path: Runnable<IO, BranchPathReturnValue, CallOptions>;\n\n ends?: Record<string, N | typeof END>;\n\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">) {\n if (Runnable.isRunnable(options.path)) {\n this.path = options.path as Runnable<\n IO,\n BranchPathReturnValue,\n CallOptions\n >;\n } else {\n this.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n IO,\n BranchPathReturnValue,\n CallOptions\n >\n ).withConfig({ runName: `Branch` } as CallOptions);\n }\n this.ends = Array.isArray(options.pathMap)\n ? options.pathMap.reduce((acc, n) => {\n acc[n] = n;\n return acc;\n }, {} as Record<string, N | typeof END>)\n : options.pathMap;\n }\n\n run(\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n ) {\n return ChannelWrite.registerWriter(\n new RunnableCallable({\n name: \"<branch_run>\",\n trace: false,\n func: async (input: IO, config: CallOptions) => {\n try {\n return await this._route(input, config, writer, reader);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Detect & warn if NodeInterrupt is thrown in a conditional edge\n if (e.name === NodeInterrupt.unminifiable_name) {\n console.warn(\n \"[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.\\n\" +\n \"NodeInterrupt should only be thrown inside a node, not in edge conditions.\"\n );\n }\n throw e;\n }\n },\n })\n );\n }\n\n async _route(\n input: IO,\n config: CallOptions,\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<Runnable | any> {\n let result = await this.path.invoke(\n reader ? reader(config) : input,\n config\n );\n if (!Array.isArray(result)) {\n result = [result];\n }\n\n let destinations: (string | Send)[];\n if (this.ends) {\n destinations = result.map((r) => (_isSend(r) ? r : this.ends![r]));\n } else {\n destinations = result;\n }\n if (destinations.some((dest) => !dest)) {\n throw new Error(\"Branch condition returned unknown or null destination\");\n }\n if (destinations.filter(_isSend).some((packet) => packet.node === END)) {\n throw new InvalidUpdateError(\"Cannot send a packet to the END node\");\n }\n const writeResult = await writer(destinations, config);\n return writeResult ?? input;\n }\n}\n\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\n\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\n\nexport class Graph<\n N extends string = typeof START | typeof END,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<\n RunInput,\n RunOutput\n >,\n C extends StateDefinition = StateDefinition\n> {\n nodes: Record<N, NodeSpecType>;\n\n edges: Set<[N | typeof START, N | typeof END]>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n\n entryPoint?: string;\n\n compiled = false;\n\n constructor() {\n this.nodes = {} as Record<N, NodeSpecType>;\n this.edges = new Set();\n this.branches = {};\n }\n\n protected warnIfCompiled(message: string): void {\n if (this.compiled) {\n console.warn(message);\n }\n }\n\n get allEdges(): Set<[string, string]> {\n return this.edges;\n }\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n ...args:\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ]\n | [\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ]\n ): Graph<N | K, RunInput, RunOutput> {\n function isMutlipleNodes(\n args: unknown[]\n ): args is [\n nodes:\n | Record<K, NodeAction<NodeInput, RunOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, RunOutput, C>,\n options?: AddNodeOptions\n ][],\n options?: AddNodeOptions\n ] {\n return args.length >= 1 && typeof args[0] !== \"string\";\n }\n\n const nodes = (\n isMutlipleNodes(args) // eslint-disable-line no-nested-ternary\n ? Array.isArray(args[0])\n ? args[0]\n : Object.entries(args[0])\n : [[args[0], args[1], args[2]]]\n ) as [K, NodeAction<NodeInput, RunOutput, C>, AddNodeOptions][];\n\n if (nodes.length === 0) {\n throw new Error(\"No nodes provided in `addNode`\");\n }\n\n for (const [key, action, options] of nodes) {\n for (const reservedChar of [\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CHECKPOINT_NAMESPACE_END,\n ]) {\n if (key.includes(reservedChar)) {\n throw new Error(\n `\"${reservedChar}\" is a reserved character and is not allowed in node names.`\n );\n }\n }\n this.warnIfCompiled(\n `Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (key in this.nodes) {\n throw new Error(`Node \\`${key}\\` already present.`);\n }\n if (key === END) {\n throw new Error(`Node \\`${key}\\` is reserved.`);\n }\n\n const runnable = _coerceToRunnable<RunInput, RunOutput>(\n // Account for arbitrary state due to Send API\n action as RunnableLike<RunInput, RunOutput>\n );\n\n this.nodes[key as unknown as N] = {\n runnable,\n metadata: options?.metadata,\n subgraphs: isPregelLike(runnable) ? [runnable] : options?.subgraphs,\n ends: options?.ends,\n } as NodeSpecType;\n }\n\n return this as Graph<N | K, RunInput, RunOutput, NodeSpecType>;\n }\n\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this {\n this.warnIfCompiled(\n `Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (startKey === END) {\n throw new Error(\"END cannot be a start node\");\n }\n if (endKey === START) {\n throw new Error(\"START cannot be an end node\");\n }\n if (\n Array.from(this.edges).some(([start]) => start === startKey) &&\n !(\"channels\" in this)\n ) {\n throw new Error(\n `Already found path for ${startKey}. For multiple edges, use StateGraph.`\n );\n }\n\n this.edges.add([startKey, endKey]);\n\n return this;\n }\n\n addConditionalEdges(\n source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>\n ): this;\n\n addConditionalEdges(\n source: N,\n path: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this;\n\n addConditionalEdges(\n source:\n | N\n | BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>,\n path?: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this {\n const options: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n > = typeof source === \"object\" ? source : { source, path: path!, pathMap };\n\n this.warnIfCompiled(\n \"Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n if (!Runnable.isRunnable(options.path)) {\n const pathDisplayValues = Array.isArray(options.pathMap)\n ? options.pathMap.join(\",\")\n : Object.keys(options.pathMap ?? {}).join(\",\");\n options.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >\n ).withConfig({\n runName: `Branch<${options.source}${\n pathDisplayValues !== \"\" ? `,${pathDisplayValues}` : \"\"\n }>`.slice(0, 63),\n });\n }\n // find a name for condition\n const name =\n options.path.getName() === \"RunnableLambda\"\n ? \"condition\"\n : options.path.getName();\n // validate condition\n if (this.branches[options.source] && this.branches[options.source][name]) {\n throw new Error(\n `Condition \\`${name}\\` already present for node \\`${source}\\``\n );\n }\n // save it\n this.branches[options.source] ??= {};\n this.branches[options.source][name] = new Branch(options);\n return this;\n }\n\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(START, key);\n }\n\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(key, END);\n }\n\n compile({\n checkpointer,\n interruptBefore,\n interruptAfter,\n name,\n }: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n } = {}): CompiledGraph<N> {\n // validate the graph\n this.validate([\n ...(Array.isArray(interruptBefore) ? interruptBefore : []),\n ...(Array.isArray(interruptAfter) ? interruptAfter : []),\n ]);\n\n // create empty compiled graph\n const compiled = new CompiledGraph({\n builder: this,\n checkpointer,\n interruptAfter,\n interruptBefore,\n autoValidate: false,\n nodes: {} as Record<N | typeof START, PregelNode<RunInput, RunOutput>>,\n channels: {\n [START]: new EphemeralValue(),\n [END]: new EphemeralValue(),\n } as Record<N | typeof START | typeof END | string, BaseChannel>,\n inputChannels: START,\n outputChannels: END,\n streamChannels: [] as N[],\n streamMode: \"values\",\n name,\n });\n\n // attach nodes, edges and branches\n for (const [key, node] of Object.entries<NodeSpec<RunInput, RunOutput>>(\n this.nodes\n )) {\n compiled.attachNode(key as N, node);\n }\n for (const [start, end] of this.edges) {\n compiled.attachEdge(start, end);\n }\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const [name, branch] of Object.entries(branches)) {\n compiled.attachBranch(start as N, name, branch);\n }\n }\n\n return compiled.validate();\n }\n\n validate(interrupt?: string[]): void {\n // assemble sources\n const allSources = new Set([...this.allEdges].map(([src, _]) => src));\n for (const [start] of Object.entries(this.branches)) {\n allSources.add(start);\n }\n\n // validate sources\n for (const source of allSources) {\n if (source !== START && !(source in this.nodes)) {\n throw new Error(`Found edge starting at unknown node \\`${source}\\``);\n }\n }\n\n // assemble targets\n const allTargets = new Set([...this.allEdges].map(([_, target]) => target));\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const branch of Object.values(branches)) {\n if (branch.ends != null) {\n for (const end of Object.values(branch.ends)) {\n allTargets.add(end);\n }\n } else {\n allTargets.add(END);\n for (const node of Object.keys(this.nodes)) {\n if (node !== start) {\n allTargets.add(node);\n }\n }\n }\n }\n }\n for (const node of Object.values<NodeSpecType>(this.nodes)) {\n for (const target of node.ends ?? []) {\n allTargets.add(target);\n }\n }\n // validate targets\n for (const node of Object.keys(this.nodes)) {\n if (!allTargets.has(node)) {\n throw new UnreachableNodeError(\n [\n `Node \\`${node}\\` is not reachable.`,\n \"\",\n \"If you are returning Command objects from your node,\",\n 'make sure you are passing names of potential destination nodes as an \"ends\" array',\n 'into \".addNode(..., { ends: [\"node1\", \"node2\"] })\".',\n ].join(\"\\n\"),\n {\n lc_error_code: \"UNREACHABLE_NODE\",\n }\n );\n }\n }\n for (const target of allTargets) {\n if (target !== END && !(target in this.nodes)) {\n throw new Error(`Found edge ending at unknown node \\`${target}\\``);\n }\n }\n\n // validate interrupts\n if (interrupt) {\n for (const node of interrupt) {\n if (!(node in this.nodes)) {\n throw new Error(`Interrupt node \\`${node}\\` is not present`);\n }\n }\n }\n\n this.compiled = true;\n }\n}\n\nexport class CompiledGraph<\n N extends string,\n State = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Update = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n OutputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n NodeReturnType = unknown,\n CommandType = unknown,\n StreamCustomType = any // eslint-disable-line @typescript-eslint/no-explicit-any\n> extends Pregel<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>,\n ContextType & Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType,\n OutputType,\n InputType,\n OutputType,\n NodeReturnType,\n CommandType,\n StreamCustomType\n> {\n declare \"~NodeType\": N;\n\n declare \"~NodeReturnType\": NodeReturnType;\n\n declare \"~RunInput\": Update;\n\n declare \"~RunOutput\": State;\n\n builder: Graph<N, State, Update>;\n\n constructor({\n builder,\n ...rest\n }: { builder: Graph<N, State, Update> } & PregelParams<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>\n >) {\n super(rest);\n this.builder = builder;\n }\n\n attachNode(key: N, node: NodeSpec<State, Update>): void {\n this.channels[key] = new EphemeralValue();\n this.nodes[key] = new PregelNode({\n channels: [],\n triggers: [],\n metadata: node.metadata,\n subgraphs: node.subgraphs,\n ends: node.ends,\n })\n .pipe(node.runnable)\n .pipe(\n new ChannelWrite([{ channel: key, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n (this.streamChannels as N[]).push(key);\n }\n\n attachEdge(start: N | typeof START, end: N | typeof END): void {\n if (end === END) {\n if (start === START) {\n throw new Error(\"Cannot have an edge from START to END\");\n }\n this.nodes[start].writers.push(\n new ChannelWrite([{ channel: END, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n } else {\n this.nodes[end].triggers.push(start);\n (this.nodes[end].channels as string[]).push(start);\n }\n }\n\n attachBranch(\n start: N | typeof START,\n name: string,\n branch: Branch<State, N>\n ) {\n // add hidden start node\n if (start === START && !this.nodes[START]) {\n this.nodes[START] = Channel.subscribeTo(START, { tags: [TAG_HIDDEN] });\n }\n\n // attach branch writer\n this.nodes[start].pipe(\n branch.run((dests) => {\n const writes = dests.map((dest) => {\n if (_isSend(dest)) {\n return dest;\n }\n return {\n channel: dest === END ? END : `branch:${start}:${name}:${dest}`,\n value: PASSTHROUGH,\n };\n });\n return new ChannelWrite(writes, [TAG_HIDDEN]);\n })\n );\n\n // attach branch readers\n const ends = branch.ends\n ? Object.values(branch.ends)\n : (Object.keys(this.nodes) as N[]);\n for (const end of ends) {\n if (end !== END) {\n const channelName = `branch:${start}:${name}:${end}`;\n (this.channels as Record<string, BaseChannel>)[channelName] =\n new EphemeralValue();\n this.nodes[end].triggers.push(channelName);\n (this.nodes[end].channels as string[]).push(channelName);\n }\n }\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n */\n override async getGraphAsync(\n config?: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph> {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode({ schema: z.any() }, START),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n (await gatherIterator(this.getSubgraphsAsync())).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n if (startNodes[start] === undefined) {\n return;\n }\n if (endNodes[end] === undefined) {\n throw new Error(`End node ${end} not found!`);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? await subgraphs[key].getGraphAsync({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n for (const [key, node] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n if (node.ends !== undefined) {\n for (const end of node.ends) {\n addEdge(\n _escapeMermaidKeywords(key),\n _escapeMermaidKeywords(end),\n undefined,\n true\n );\n }\n }\n }\n return graph;\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n override getGraph(\n config?: RunnableConfig & { xray?: boolean | number }\n ): DrawableGraph {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode(\n {\n schema: z.any(),\n },\n START\n ),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n gatherIteratorSync(this.getSubgraphs()).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? subgraphs[key].getGraph({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n return graph;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isCompiledGraph(x: unknown): x is CompiledGraph<any> {\n return (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachNode === \"function\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachEdge === \"function\"\n );\n}\n\nfunction _escapeMermaidKeywords(key: string) {\n if (key === \"subgraph\") {\n return `\"${key}\"`;\n }\n return key;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsEA,IAAa,SAAb,MAIE;CACA;CAEA;CAEA,YAAY,SAA4D;AACtE,MAAI,SAAS,WAAW,QAAQ,KAAK,CACnC,MAAK,OAAO,QAAQ;MAMpB,MAAK,OAAO,kBACV,QAAQ,KAKT,CAAC,WAAW,EAAE,SAAS,UAAU,CAAgB;AAEpD,OAAK,OAAO,MAAM,QAAQ,QAAQ,QAAQ,GACtC,QAAQ,QAAQ,QAAQ,KAAK,MAAM;AACjC,OAAI,KAAK;AACT,UAAO;KACN,EAAE,CAAmC,GACxC,QAAQ;;CAGd,IACE,QAIA,QACA;AACA,SAAO,aAAa,eAClB,IAAI,iBAAiB;GACnB,MAAM;GACN,OAAO;GACP,MAAM,OAAO,OAAW,WAAwB;AAC9C,QAAI;AACF,YAAO,MAAM,KAAK,OAAO,OAAO,QAAQ,QAAQ,OAAO;aAEhD,GAAQ;AAEf,SAAI,EAAE,SAAS,cAAc,kBAC3B,SAAQ,KACN,qLAED;AAEH,WAAM;;;GAGX,CAAC,CACH;;CAGH,MAAM,OACJ,OACA,QACA,QAIA,QAEyB;EACzB,IAAI,SAAS,MAAM,KAAK,KAAK,OAC3B,SAAS,OAAO,OAAO,GAAG,OAC1B,OACD;AACD,MAAI,CAAC,MAAM,QAAQ,OAAO,CACxB,UAAS,CAAC,OAAO;EAGnB,IAAI;AACJ,MAAI,KAAK,KACP,gBAAe,OAAO,KAAK,MAAO,QAAQ,EAAE,GA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Graph","isUuid"],"sources":["../../src/graph/graph.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n _coerceToRunnable,\n Runnable,\n RunnableConfig,\n RunnableInterface,\n RunnableIOSchema,\n type RunnableLike as LangChainRunnableLike,\n} from \"@langchain/core/runnables\";\nimport {\n Node as DrawableGraphNode,\n Graph as DrawableGraph,\n} from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { z } from \"zod/v4\";\nimport { validate as isUuid } from \"uuid\";\nimport type {\n RunnableLike,\n LangGraphRunnableConfig,\n} from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Channel, Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\nimport {\n _isSend,\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n END,\n Send,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport {\n gatherIterator,\n gatherIteratorSync,\n RunnableCallable,\n} from \"../utils.js\";\nimport {\n InvalidUpdateError,\n NodeInterrupt,\n UnreachableNodeError,\n} from \"../errors.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nimport { isPregelLike } from \"../pregel/utils/subgraph.js\";\n\nexport interface BranchOptions<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\n\nexport type BranchPathReturnValue =\n | string\n | Send\n | (string | Send)[]\n | Promise<string | Send | (string | Send)[]>;\n\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<\n S,\n U extends object ? U & Record<string, any> : U, // eslint-disable-line @typescript-eslint/no-explicit-any\n LangGraphRunnableConfig<StateType<C>>\n>;\n\nexport class Branch<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n path: Runnable<IO, BranchPathReturnValue>;\n\n ends?: Record<string, N | typeof END>;\n\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">) {\n if (Runnable.isRunnable(options.path)) {\n this.path = options.path as Runnable<IO, BranchPathReturnValue>;\n } else {\n this.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<IO, BranchPathReturnValue>\n );\n }\n this.ends = Array.isArray(options.pathMap)\n ? options.pathMap.reduce((acc, n) => {\n acc[n] = n;\n return acc;\n }, {} as Record<string, N | typeof END>)\n : options.pathMap;\n }\n\n run(\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n ) {\n return ChannelWrite.registerWriter(\n new RunnableCallable({\n name: \"<branch_run>\",\n trace: false,\n func: async (input: IO, config: CallOptions) => {\n try {\n return await this._route(input, config, writer, reader);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Detect & warn if NodeInterrupt is thrown in a conditional edge\n if (e.name === NodeInterrupt.unminifiable_name) {\n console.warn(\n \"[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.\\n\" +\n \"NodeInterrupt should only be thrown inside a node, not in edge conditions.\"\n );\n }\n throw e;\n }\n },\n })\n );\n }\n\n async _route(\n input: IO,\n config: CallOptions,\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<Runnable | any> {\n let result = await this.path.invoke(\n reader ? reader(config) : input,\n config\n );\n if (!Array.isArray(result)) {\n result = [result];\n }\n\n let destinations: (string | Send)[];\n if (this.ends) {\n destinations = result.map((r) => (_isSend(r) ? r : this.ends![r]));\n } else {\n destinations = result;\n }\n if (destinations.some((dest) => !dest)) {\n throw new Error(\"Branch condition returned unknown or null destination\");\n }\n if (destinations.filter(_isSend).some((packet) => packet.node === END)) {\n throw new InvalidUpdateError(\"Cannot send a packet to the END node\");\n }\n const writeResult = await writer(destinations, config);\n return writeResult ?? input;\n }\n}\n\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\n\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\n\nexport class Graph<\n N extends string = typeof START | typeof END,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<\n RunInput,\n RunOutput\n >,\n C extends StateDefinition = StateDefinition\n> {\n nodes: Record<N, NodeSpecType>;\n\n edges: Set<[N | typeof START, N | typeof END]>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n\n entryPoint?: string;\n\n compiled = false;\n\n constructor() {\n this.nodes = {} as Record<N, NodeSpecType>;\n this.edges = new Set();\n this.branches = {};\n }\n\n protected warnIfCompiled(message: string): void {\n if (this.compiled) {\n console.warn(message);\n }\n }\n\n get allEdges(): Set<[string, string]> {\n return this.edges;\n }\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n ...args:\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ]\n | [\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ]\n ): Graph<N | K, RunInput, RunOutput> {\n function isMutlipleNodes(\n args: unknown[]\n ): args is [\n nodes:\n | Record<K, NodeAction<NodeInput, RunOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, RunOutput, C>,\n options?: AddNodeOptions\n ][],\n options?: AddNodeOptions\n ] {\n return args.length >= 1 && typeof args[0] !== \"string\";\n }\n\n const nodes = (\n isMutlipleNodes(args) // eslint-disable-line no-nested-ternary\n ? Array.isArray(args[0])\n ? args[0]\n : Object.entries(args[0])\n : [[args[0], args[1], args[2]]]\n ) as [K, NodeAction<NodeInput, RunOutput, C>, AddNodeOptions][];\n\n if (nodes.length === 0) {\n throw new Error(\"No nodes provided in `addNode`\");\n }\n\n for (const [key, action, options] of nodes) {\n for (const reservedChar of [\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CHECKPOINT_NAMESPACE_END,\n ]) {\n if (key.includes(reservedChar)) {\n throw new Error(\n `\"${reservedChar}\" is a reserved character and is not allowed in node names.`\n );\n }\n }\n this.warnIfCompiled(\n `Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (key in this.nodes) {\n throw new Error(`Node \\`${key}\\` already present.`);\n }\n if (key === END) {\n throw new Error(`Node \\`${key}\\` is reserved.`);\n }\n\n const runnable = _coerceToRunnable<RunInput, RunOutput>(\n // Account for arbitrary state due to Send API\n action as RunnableLike<RunInput, RunOutput>\n );\n\n this.nodes[key as unknown as N] = {\n runnable,\n metadata: options?.metadata,\n subgraphs: isPregelLike(runnable) ? [runnable] : options?.subgraphs,\n ends: options?.ends,\n } as NodeSpecType;\n }\n\n return this as Graph<N | K, RunInput, RunOutput, NodeSpecType>;\n }\n\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this {\n this.warnIfCompiled(\n `Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (startKey === END) {\n throw new Error(\"END cannot be a start node\");\n }\n if (endKey === START) {\n throw new Error(\"START cannot be an end node\");\n }\n if (\n Array.from(this.edges).some(([start]) => start === startKey) &&\n !(\"channels\" in this)\n ) {\n throw new Error(\n `Already found path for ${startKey}. For multiple edges, use StateGraph.`\n );\n }\n\n this.edges.add([startKey, endKey]);\n\n return this;\n }\n\n addConditionalEdges(\n source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>\n ): this;\n\n addConditionalEdges(\n source: N,\n path: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this;\n\n addConditionalEdges(\n source:\n | N\n | BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>,\n path?: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this {\n const options: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n > = typeof source === \"object\" ? source : { source, path: path!, pathMap };\n\n this.warnIfCompiled(\n \"Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n if (!Runnable.isRunnable(options.path)) {\n options.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<RunInput, BranchPathReturnValue>\n );\n }\n // find a name for condition\n const name =\n options.path.getName() === \"RunnableLambda\"\n ? \"condition\"\n : options.path.getName();\n // validate condition\n if (this.branches[options.source] && this.branches[options.source][name]) {\n throw new Error(\n `Condition \\`${name}\\` already present for node \\`${source}\\``\n );\n }\n // save it\n this.branches[options.source] ??= {};\n this.branches[options.source][name] = new Branch(options);\n return this;\n }\n\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(START, key);\n }\n\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(key, END);\n }\n\n compile({\n checkpointer,\n interruptBefore,\n interruptAfter,\n name,\n }: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n } = {}): CompiledGraph<N> {\n // validate the graph\n this.validate([\n ...(Array.isArray(interruptBefore) ? interruptBefore : []),\n ...(Array.isArray(interruptAfter) ? interruptAfter : []),\n ]);\n\n // create empty compiled graph\n const compiled = new CompiledGraph({\n builder: this,\n checkpointer,\n interruptAfter,\n interruptBefore,\n autoValidate: false,\n nodes: {} as Record<N | typeof START, PregelNode<RunInput, RunOutput>>,\n channels: {\n [START]: new EphemeralValue(),\n [END]: new EphemeralValue(),\n } as Record<N | typeof START | typeof END | string, BaseChannel>,\n inputChannels: START,\n outputChannels: END,\n streamChannels: [] as N[],\n streamMode: \"values\",\n name,\n });\n\n // attach nodes, edges and branches\n for (const [key, node] of Object.entries<NodeSpec<RunInput, RunOutput>>(\n this.nodes\n )) {\n compiled.attachNode(key as N, node);\n }\n for (const [start, end] of this.edges) {\n compiled.attachEdge(start, end);\n }\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const [name, branch] of Object.entries(branches)) {\n compiled.attachBranch(start as N, name, branch);\n }\n }\n\n return compiled.validate();\n }\n\n validate(interrupt?: string[]): void {\n // assemble sources\n const allSources = new Set([...this.allEdges].map(([src, _]) => src));\n for (const [start] of Object.entries(this.branches)) {\n allSources.add(start);\n }\n\n // validate sources\n for (const source of allSources) {\n if (source !== START && !(source in this.nodes)) {\n throw new Error(`Found edge starting at unknown node \\`${source}\\``);\n }\n }\n\n // assemble targets\n const allTargets = new Set([...this.allEdges].map(([_, target]) => target));\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const branch of Object.values(branches)) {\n if (branch.ends != null) {\n for (const end of Object.values(branch.ends)) {\n allTargets.add(end);\n }\n } else {\n allTargets.add(END);\n for (const node of Object.keys(this.nodes)) {\n if (node !== start) {\n allTargets.add(node);\n }\n }\n }\n }\n }\n for (const node of Object.values<NodeSpecType>(this.nodes)) {\n for (const target of node.ends ?? []) {\n allTargets.add(target);\n }\n }\n // validate targets\n for (const node of Object.keys(this.nodes)) {\n if (!allTargets.has(node)) {\n throw new UnreachableNodeError(\n [\n `Node \\`${node}\\` is not reachable.`,\n \"\",\n \"If you are returning Command objects from your node,\",\n 'make sure you are passing names of potential destination nodes as an \"ends\" array',\n 'into \".addNode(..., { ends: [\"node1\", \"node2\"] })\".',\n ].join(\"\\n\"),\n {\n lc_error_code: \"UNREACHABLE_NODE\",\n }\n );\n }\n }\n for (const target of allTargets) {\n if (target !== END && !(target in this.nodes)) {\n throw new Error(`Found edge ending at unknown node \\`${target}\\``);\n }\n }\n\n // validate interrupts\n if (interrupt) {\n for (const node of interrupt) {\n if (!(node in this.nodes)) {\n throw new Error(`Interrupt node \\`${node}\\` is not present`);\n }\n }\n }\n\n this.compiled = true;\n }\n}\n\nexport class CompiledGraph<\n N extends string,\n State = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Update = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n OutputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n NodeReturnType = unknown,\n CommandType = unknown,\n StreamCustomType = any // eslint-disable-line @typescript-eslint/no-explicit-any\n> extends Pregel<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>,\n ContextType & Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType,\n OutputType,\n InputType,\n OutputType,\n NodeReturnType,\n CommandType,\n StreamCustomType\n> {\n declare \"~NodeType\": N;\n\n declare \"~NodeReturnType\": NodeReturnType;\n\n declare \"~RunInput\": Update;\n\n declare \"~RunOutput\": State;\n\n builder: Graph<N, State, Update>;\n\n constructor({\n builder,\n ...rest\n }: { builder: Graph<N, State, Update> } & PregelParams<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>\n >) {\n super(rest);\n this.builder = builder;\n }\n\n attachNode(key: N, node: NodeSpec<State, Update>): void {\n this.channels[key] = new EphemeralValue();\n this.nodes[key] = new PregelNode({\n channels: [],\n triggers: [],\n metadata: node.metadata,\n subgraphs: node.subgraphs,\n ends: node.ends,\n })\n .pipe(node.runnable)\n .pipe(\n new ChannelWrite([{ channel: key, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n (this.streamChannels as N[]).push(key);\n }\n\n attachEdge(start: N | typeof START, end: N | typeof END): void {\n if (end === END) {\n if (start === START) {\n throw new Error(\"Cannot have an edge from START to END\");\n }\n this.nodes[start].writers.push(\n new ChannelWrite([{ channel: END, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n } else {\n this.nodes[end].triggers.push(start);\n (this.nodes[end].channels as string[]).push(start);\n }\n }\n\n attachBranch(\n start: N | typeof START,\n name: string,\n branch: Branch<State, N>\n ) {\n // add hidden start node\n if (start === START && !this.nodes[START]) {\n this.nodes[START] = Channel.subscribeTo(START, { tags: [TAG_HIDDEN] });\n }\n\n // attach branch writer\n this.nodes[start].pipe(\n branch.run((dests) => {\n const writes = dests.map((dest) => {\n if (_isSend(dest)) {\n return dest;\n }\n return {\n channel: dest === END ? END : `branch:${start}:${name}:${dest}`,\n value: PASSTHROUGH,\n };\n });\n return new ChannelWrite(writes, [TAG_HIDDEN]);\n })\n );\n\n // attach branch readers\n const ends = branch.ends\n ? Object.values(branch.ends)\n : (Object.keys(this.nodes) as N[]);\n for (const end of ends) {\n if (end !== END) {\n const channelName = `branch:${start}:${name}:${end}`;\n (this.channels as Record<string, BaseChannel>)[channelName] =\n new EphemeralValue();\n this.nodes[end].triggers.push(channelName);\n (this.nodes[end].channels as string[]).push(channelName);\n }\n }\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n */\n override async getGraphAsync(\n config?: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph> {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode({ schema: z.any() }, START),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n (await gatherIterator(this.getSubgraphsAsync())).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n if (startNodes[start] === undefined) {\n return;\n }\n if (endNodes[end] === undefined) {\n throw new Error(`End node ${end} not found!`);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? await subgraphs[key].getGraphAsync({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n for (const [key, node] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n if (node.ends !== undefined) {\n for (const end of node.ends) {\n addEdge(\n _escapeMermaidKeywords(key),\n _escapeMermaidKeywords(end),\n undefined,\n true\n );\n }\n }\n }\n return graph;\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n override getGraph(\n config?: RunnableConfig & { xray?: boolean | number }\n ): DrawableGraph {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode(\n {\n schema: z.any(),\n },\n START\n ),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n gatherIteratorSync(this.getSubgraphs()).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? subgraphs[key].getGraph({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n return graph;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isCompiledGraph(x: unknown): x is CompiledGraph<any> {\n return (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachNode === \"function\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachEdge === \"function\"\n );\n}\n\nfunction _escapeMermaidKeywords(key: string) {\n if (key === \"subgraph\") {\n return `\"${key}\"`;\n }\n return key;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsEA,IAAa,SAAb,MAIE;CACA;CAEA;CAEA,YAAY,SAA4D;AACtE,MAAI,SAAS,WAAW,QAAQ,KAAK,CACnC,MAAK,OAAO,QAAQ;MAEpB,MAAK,OAAO,kBACV,QAAQ,KACT;AAEH,OAAK,OAAO,MAAM,QAAQ,QAAQ,QAAQ,GACtC,QAAQ,QAAQ,QAAQ,KAAK,MAAM;AACjC,OAAI,KAAK;AACT,UAAO;KACN,EAAE,CAAmC,GACxC,QAAQ;;CAGd,IACE,QAIA,QACA;AACA,SAAO,aAAa,eAClB,IAAI,iBAAiB;GACnB,MAAM;GACN,OAAO;GACP,MAAM,OAAO,OAAW,WAAwB;AAC9C,QAAI;AACF,YAAO,MAAM,KAAK,OAAO,OAAO,QAAQ,QAAQ,OAAO;aAEhD,GAAQ;AAEf,SAAI,EAAE,SAAS,cAAc,kBAC3B,SAAQ,KACN,qLAED;AAEH,WAAM;;;GAGX,CAAC,CACH;;CAGH,MAAM,OACJ,OACA,QACA,QAIA,QAEyB;EACzB,IAAI,SAAS,MAAM,KAAK,KAAK,OAC3B,SAAS,OAAO,OAAO,GAAG,OAC1B,OACD;AACD,MAAI,CAAC,MAAM,QAAQ,OAAO,CACxB,UAAS,CAAC,OAAO;EAGnB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AM,YAAY,SAAS;AACzD,eAAW,cAAc;AACzB,aAAS,cAAc;;;EAG3B,MAAM,cAAc,CAAC,GAAG,KAAK,QAAQ,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;AAChE,OAAI,IAAI,EACN,QAAO;YACE,IAAI,EACb,QAAO;OAEP,QAAO;IAET;AACF,OAAK,MAAM,CAAC,OAAO,QAAQ,YACzB,SAAQ,uBAAuB,MAAM,EAAE,uBAAuB,IAAI,CAAC;AAErE,OAAK,MAAM,CAAC,OAAO,aAAa,OAAO,QAAQ,KAAK,QAAQ,SAAS,EAAE;GACrE,MAAM,cAAsC;IAC1C,GAAG,OAAO,YACR,OAAO,KAAK,KAAK,QAAQ,MAAM,CAC5B,QAAQ,MAAM,MAAM,MAAM,CAC1B,KAAK,MAAM,CAAC,uBAAuB,EAAE,EAAE,uBAAuB,EAAE,CAAC,CAAC,CACtE;KACA,MAAM;IACR;AACD,QAAK,MAAM,UAAU,OAAO,OAAO,SAAS,EAAE;IAC5C,IAAI;AACJ,QAAI,OAAO,SAAS,OAClB,QAAO,OAAO;QAEd,QAAO;AAET,SAAK,MAAM,CAAC,OAAO,QAAQ,OAAO,QAAQ,KAAK,CAC7C,SACE,uBAAuB,MAAM,EAC7B,uBAAuB,IAAI,EAC3B,OACA,KACD;;;AAIP,SAAO;;;AAKX,SAAS,gBAAgB,GAAqC;AAC5D,QAEE,OAAQ,EAAyB,eAAe,cAEhD,OAAQ,EAAyB,eAAe;;AAIpD,SAAS,uBAAuB,KAAa;AAC3C,KAAI,QAAQ,WACV,QAAO,IAAI,IAAI;AAEjB,QAAO"}
@@ -1,5 +1,5 @@
1
- const require_annotation = require('./annotation.cjs');
2
1
  const require_constants = require('../constants.cjs');
2
+ const require_annotation = require('./annotation.cjs');
3
3
  const require_graph = require('./graph.cjs');
4
4
  const require_messages_reducer = require('./messages_reducer.cjs');
5
5
  const require_state = require('./state.cjs');
@@ -1,5 +1,5 @@
1
- import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./annotation.js";
2
1
  import { CommandInstance, CommandParams } from "../constants.js";
2
+ import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./annotation.js";
3
3
  import { CompiledGraph, Graph } from "./graph.js";
4
4
  import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions } from "./types.js";
5
5
  import { CompiledStateGraph, StateGraph, StateGraphArgs } from "./state.js";
@@ -1,5 +1,5 @@
1
- import { Annotation, AnnotationRoot } from "./annotation.js";
2
1
  import { CommandInstance } from "../constants.js";
2
+ import { Annotation, AnnotationRoot } from "./annotation.js";
3
3
  import { Graph } from "./graph.js";
4
4
  import { REMOVE_ALL_MESSAGES, messagesStateReducer } from "./messages_reducer.js";
5
5
  import { CompiledStateGraph, StateGraph } from "./state.js";
@@ -1,4 +1,5 @@
1
- import { BinaryOperatorAggregate } from "../channels/binop.cjs";
1
+ import { BaseChannel } from "../channels/base.cjs";
2
+ import { OverwriteValue } from "../constants.cjs";
2
3
  import { ReducedZodChannel, SchemaMeta } from "./zod/meta.cjs";
3
4
  import { AnnotationRoot } from "./annotation.cjs";
4
5
  import { Messages } from "./messages_reducer.cjs";
@@ -44,7 +45,7 @@ import { BaseMessage } from "@langchain/core/messages";
44
45
  * ```
45
46
  */
46
47
  declare const MessagesAnnotation: AnnotationRoot<{
47
- messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
48
+ messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
48
49
  }>;
49
50
  /**
50
51
  * Prebuilt schema meta for Zod state definition.
@@ -1 +1 @@
1
- {"version":3,"file":"messages_annotation.d.cts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;cApBa,kBAAA;2FAKX,yBAAA,CAAA,cAAA;;;;;AA4DF;;;;;;;;;;cA7Ca,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6C3C,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
1
+ {"version":3,"file":"messages_annotation.d.cts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,kBAAA;+EAKX,yBAAA,CAAA,cAAA;;;AAeF;;;;;;;;;;;;cAAa,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAa,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
@@ -1,4 +1,5 @@
1
- import { BinaryOperatorAggregate } from "../channels/binop.js";
1
+ import { BaseChannel } from "../channels/base.js";
2
+ import { OverwriteValue } from "../constants.js";
2
3
  import { ReducedZodChannel, SchemaMeta } from "./zod/meta.js";
3
4
  import { AnnotationRoot } from "./annotation.js";
4
5
  import { Messages } from "./messages_reducer.js";
@@ -45,7 +46,7 @@ import { z } from "zod/v3";
45
46
  * ```
46
47
  */
47
48
  declare const MessagesAnnotation: AnnotationRoot<{
48
- messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], Messages>;
49
+ messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
49
50
  }>;
50
51
  /**
51
52
  * Prebuilt schema meta for Zod state definition.
@@ -1 +1 @@
1
- {"version":3,"file":"messages_annotation.d.ts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;cApBa,kBAAA;2FAKX,yBAAA,CAAA,cAAA;;;;;;AA4DF;;;;;;;;;cA7Ca,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA6C3C,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
1
+ {"version":3,"file":"messages_annotation.d.ts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,kBAAA;+EAKX,yBAAA,CAAA,cAAA;;;;AAeF;;;;;;;;;;;cAAa,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
@@ -1,7 +1,7 @@
1
+ const require_constants = require('../constants.cjs');
1
2
  const require_errors = require('../errors.cjs');
2
3
  const require_last_value = require('../channels/last_value.cjs');
3
4
  const require_annotation = require('./annotation.cjs');
4
- const require_constants = require('../constants.cjs');
5
5
  const require_utils = require('../utils.cjs');
6
6
  const require_write = require('../pregel/write.cjs');
7
7
  const require_read = require('../pregel/read.cjs');
@@ -1,9 +1,9 @@
1
1
  import { BaseChannel } from "../channels/base.cjs";
2
+ import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.cjs";
2
3
  import { SchemaMetaRegistry } from "./zod/meta.cjs";
3
4
  import { RunnableLike, Runtime } from "../pregel/runnable_types.cjs";
4
5
  import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.cjs";
5
6
  import { CachePolicy, RetryPolicy } from "../pregel/utils/index.cjs";
6
- import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.cjs";
7
7
  import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.cjs";
8
8
  import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.cjs";
9
9
  import { InferWriterType } from "../writer.cjs";
@@ -1,9 +1,9 @@
1
1
  import { BaseChannel } from "../channels/base.js";
2
+ import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.js";
2
3
  import { SchemaMetaRegistry } from "./zod/meta.js";
3
4
  import { RunnableLike, Runtime } from "../pregel/runnable_types.js";
4
5
  import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.js";
5
6
  import { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
6
- import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.js";
7
7
  import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.js";
8
8
  import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.js";
9
9
  import { InferWriterType } from "../writer.js";
@@ -1,7 +1,7 @@
1
+ import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, Command, END, SELF, START, TAG_HIDDEN, _isSend, isCommand, isInterrupted } from "../constants.js";
1
2
  import { InvalidUpdateError, ParentCommand, StateGraphInputError } from "../errors.js";
2
3
  import { LastValueAfterFinish } from "../channels/last_value.js";
3
4
  import { AnnotationRoot, getChannel } from "./annotation.js";
4
- import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, Command, END, SELF, START, TAG_HIDDEN, _isSend, isCommand, isInterrupted } from "../constants.js";
5
5
  import { RunnableCallable } from "../utils.js";
6
6
  import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
7
7
  import { ChannelRead, PregelNode } from "../pregel/read.js";
@@ -1,5 +1,5 @@
1
- const require_base = require('../channels/base.cjs');
2
1
  const require_constants = require('../constants.cjs');
2
+ const require_base = require('../channels/base.cjs');
3
3
  const require_schema = require('../state/schema.cjs');
4
4
  let _langchain_core_utils_types = require("@langchain/core/utils/types");
5
5
 
@@ -1,7 +1,7 @@
1
+ import { CommandInstance, END, Send } from "../constants.cjs";
1
2
  import { InteropZodToStateDefinition } from "./zod/meta.cjs";
2
3
  import { LangGraphRunnableConfig } from "../pregel/runnable_types.cjs";
3
4
  import { AnnotationRoot, StateDefinition, StateType, UpdateType } from "./annotation.cjs";
4
- import { CommandInstance, END, Send } from "../constants.cjs";
5
5
  import { AnyStateSchema, StateSchema, StateSchemaFieldsToStateDefinition } from "../state/schema.cjs";
6
6
  import { InteropZodObject } from "@langchain/core/utils/types";
7
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -1,7 +1,7 @@
1
+ import { CommandInstance, END, Send } from "../constants.js";
1
2
  import { InteropZodToStateDefinition } from "./zod/meta.js";
2
3
  import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
3
4
  import { AnnotationRoot, StateDefinition, StateType, UpdateType } from "./annotation.js";
4
- import { CommandInstance, END, Send } from "../constants.js";
5
5
  import { AnyStateSchema, StateSchema, StateSchemaFieldsToStateDefinition } from "../state/schema.js";
6
6
  import { InteropZodObject } from "@langchain/core/utils/types";
7
7
  import { StandardSchemaV1 } from "@standard-schema/spec";
@@ -1,5 +1,5 @@
1
- import { isBaseChannel } from "../channels/base.js";
2
1
  import { END } from "../constants.js";
2
+ import { isBaseChannel } from "../channels/base.js";
3
3
  import { StateSchema } from "../state/schema.js";
4
4
  import { isInteropZodObject } from "@langchain/core/utils/types";
5
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,kEAAiC,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAIA,sCAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAIC,6BAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,QAAQ,CACrC,QAAQ,GAAG,OAAO,MAAM,KAAK,CAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;EAEZ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":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,kEAAiC,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAIA,sCAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAIC,6BAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,QAAQ,CACrC,QAAQ,GAAG,OAAO,MAAM,KAAK,CAC7B,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC,CACtC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,IAAI,CAC5B,KAAK,IAAI;EAEZ,MAAM,QAAQ,KAAK,gBAAgB,IAAI,SAAS,oBAAI,IAAI,KAAK;AAC7D,MAAI,MAAM,IAAI,OAAO,CAAE,QAAO,MAAM,IAAI,OAAO;EAE/C,IAAI,iBAAmC;AAEvC,MACE,QAAQ,qBACR,QAAQ,mCACR;GACA,MAAM,kBAAkB,OAAO,kEACJ,OAAO,CACjC,CAAC,KAAK,CAAC,KAAK,YAAY;IACvB,MAAM,OAAO,KAAK,IAAI,OAAO;IAC7B,IAAI,eAAe,QAAQ,oBACvB,MAAM,SAAS,UAAU,SACzB;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,oEACiB,aAAa,0DAAyB,OAAO;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,4EACE,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,sDAAkB,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "../../channels/base.cjs";
2
+ import { OverwriteValue } from "../../constants.cjs";
2
3
  import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
3
4
 
4
5
  //#region src/graph/zod/meta.d.ts
@@ -8,8 +9,8 @@ type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZ
8
9
  lg_reducer_schema: TReducerSchema;
9
10
  };
10
11
  /** @internal */
11
- type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
12
- type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
12
+ type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, OverwriteValue<V> | U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
13
+ type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? OverwriteValue<V> | U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
13
14
  interface SchemaMeta<TValue = any, TUpdate = TValue> {
14
15
  jsonSchemaExtra?: {
15
16
  langgraph_nodes?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.cts","names":[],"sources":["../../../src/graph/zod/meta.ts"],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;;;;AAIN;;;;;;;;;EA4IE,yBAAA,WAAoC,gBAAA,CAAA,CAClC,MAAA,EAAQ,CAAA,EACR,OAAA;IAtIiB;;;IA0If,iBAAA;IAxIwB;;;IA4IxB,iCAAA;IAzIkC;;;IA6IlC,SAAA;EAAA,IAED,gBAAA;AAAA;AAAA,cA+DQ,kBAAA,EAAkB,kBAAA;AAAA,iBAEf,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA;EAAa,OAAA;AAAA,IACrC,OAAA;AAAA,iBACa,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA,IACxB,iBAAA,CAAkB,OAAA,EAAS,cAAA,CAAe,OAAA"}
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "../../channels/base.js";
2
+ import { OverwriteValue } from "../../constants.js";
2
3
  import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
3
4
 
4
5
  //#region src/graph/zod/meta.d.ts
@@ -8,8 +9,8 @@ type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZ
8
9
  lg_reducer_schema: TReducerSchema;
9
10
  };
10
11
  /** @internal */
11
- type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
12
- type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
12
+ type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, OverwriteValue<V> | U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
13
+ type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? OverwriteValue<V> | U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
13
14
  interface SchemaMeta<TValue = any, TUpdate = TValue> {
14
15
  jsonSchemaExtra?: {
15
16
  langgraph_nodes?: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":";;;;cAgBa,8BAAA;;KAGD,iBAAA,WACA,cAAA,yBACa,cAAA,IACrB,CAAA;EACF,iBAAA,EAAmB,cAAA;AAAA;;KAIT,2BAAA,WACA,gBAAA,WACD,qBAAA,CAAsB,CAAA,qBAEjB,MAAA,GAAS,MAAA,CAAO,GAAA,UAAa,iBAAA,sCAIvC,MAAA,SAAe,cAAA,YACb,aAAA,SAAsB,cAAA,YACpB,WAAA,CAAY,CAAA,EAAG,CAAA,oBAGnB,MAAA,CAAO,GAAA,UAAa,cAAA,qBACpB,WAAA,CAAY,CAAA,EAAG,CAAA;AAAA,KAIT,UAAA,WACA,gBAAA,WACD,qBAAA,CAAsB,CAAA,qBAEjB,MAAA,IAAU,MAAA,CAAO,GAAA,UAAa,iBAAA,sCAIxC,MAAA,SAAe,cAAA,YACb,aAAA,SAAsB,cAAA,YACpB,CAAA,mBAGJ,MAAA,CAAO,GAAA,UAAa,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