@langchain/langgraph 0.3.0 → 0.3.2

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 (41) hide show
  1. package/dist/func/index.cjs +10 -5
  2. package/dist/func/index.d.ts +3 -3
  3. package/dist/func/index.js +10 -5
  4. package/dist/func/index.js.map +1 -1
  5. package/dist/graph/messages_annotation.cjs +2 -2
  6. package/dist/graph/messages_annotation.d.ts +2 -2
  7. package/dist/graph/messages_annotation.js +1 -1
  8. package/dist/graph/messages_annotation.js.map +1 -1
  9. package/dist/graph/state.cjs +46 -21
  10. package/dist/graph/state.d.ts +22 -15
  11. package/dist/graph/state.js +46 -21
  12. package/dist/graph/state.js.map +1 -1
  13. package/dist/graph/zod/index.cjs +5 -3
  14. package/dist/graph/zod/index.d.ts +2 -1
  15. package/dist/graph/zod/index.js +2 -1
  16. package/dist/graph/zod/index.js.map +1 -1
  17. package/dist/graph/zod/meta.cjs +180 -0
  18. package/dist/graph/zod/meta.d.ts +110 -0
  19. package/dist/graph/zod/meta.js +175 -0
  20. package/dist/graph/zod/meta.js.map +1 -0
  21. package/dist/graph/zod/plugin.cjs +30 -27
  22. package/dist/graph/zod/plugin.d.ts +16 -3
  23. package/dist/graph/zod/plugin.js +31 -28
  24. package/dist/graph/zod/plugin.js.map +1 -1
  25. package/dist/graph/zod/schema.cjs +45 -19
  26. package/dist/graph/zod/schema.d.ts +7 -8
  27. package/dist/graph/zod/schema.js +45 -19
  28. package/dist/graph/zod/schema.js.map +1 -1
  29. package/dist/graph/zod/zod-registry.cjs +49 -0
  30. package/dist/graph/zod/zod-registry.d.ts +24 -0
  31. package/dist/graph/zod/zod-registry.js +45 -0
  32. package/dist/graph/zod/zod-registry.js.map +1 -0
  33. package/dist/prebuilt/react_agent_executor.d.ts +3 -3
  34. package/dist/pregel/types.d.ts +1 -1
  35. package/dist/web.d.ts +1 -1
  36. package/dist/web.js.map +1 -1
  37. package/package.json +7 -7
  38. package/dist/graph/zod/state.cjs +0 -135
  39. package/dist/graph/zod/state.d.ts +0 -39
  40. package/dist/graph/zod/state.js +0 -125
  41. package/dist/graph/zod/state.js.map +0 -1
@@ -59,18 +59,23 @@ const write_js_1 = require("../pregel/write.cjs");
59
59
  * ```
60
60
  */
61
61
  function task(optionsOrName, func) {
62
- const { name, retry, cache: userCache, } = typeof optionsOrName === "string"
63
- ? { name: optionsOrName, retry: undefined, cache: undefined }
62
+ const options = typeof optionsOrName === "string"
63
+ ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }
64
64
  : optionsOrName;
65
+ const { name, retry } = options;
65
66
  if ((0, utils_js_1.isAsyncGeneratorFunction)(func) || (0, utils_js_1.isGeneratorFunction)(func)) {
66
67
  throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");
67
68
  }
69
+ const cachePolicy = options.cachePolicy ??
70
+ // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,
71
+ // TODO: remove in 1.x
72
+ ("cache" in options ? options.cache : undefined);
68
73
  let cache;
69
- if (typeof userCache === "boolean") {
70
- cache = userCache ? {} : undefined;
74
+ if (typeof cachePolicy === "boolean") {
75
+ cache = cachePolicy ? {} : undefined;
71
76
  }
72
77
  else {
73
- cache = userCache;
78
+ cache = cachePolicy;
74
79
  }
75
80
  return (...args) => {
76
81
  return (0, call_js_1.call)({ func, name, retry, cache }, ...args);
@@ -9,7 +9,7 @@ import { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFun
9
9
  /**
10
10
  * Options for the {@link task} function
11
11
  */
12
- export type TaskOptions = {
12
+ export interface TaskOptions {
13
13
  /**
14
14
  * The name of the task, analogous to the node name in {@link StateGraph}.
15
15
  */
@@ -22,8 +22,8 @@ export type TaskOptions = {
22
22
  /**
23
23
  * The cache policy for the task. Configures how the task should be cached.
24
24
  */
25
- cache?: CachePolicy | boolean;
26
- };
25
+ cachePolicy?: CachePolicy;
26
+ }
27
27
  /**
28
28
  * Define a LangGraph task using the `task` function.
29
29
  *
@@ -54,18 +54,23 @@ import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
54
54
  * ```
55
55
  */
56
56
  export function task(optionsOrName, func) {
57
- const { name, retry, cache: userCache, } = typeof optionsOrName === "string"
58
- ? { name: optionsOrName, retry: undefined, cache: undefined }
57
+ const options = typeof optionsOrName === "string"
58
+ ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }
59
59
  : optionsOrName;
60
+ const { name, retry } = options;
60
61
  if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {
61
62
  throw new Error("Generators are disallowed as tasks. For streaming responses, use config.write.");
62
63
  }
64
+ const cachePolicy = options.cachePolicy ??
65
+ // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,
66
+ // TODO: remove in 1.x
67
+ ("cache" in options ? options.cache : undefined);
63
68
  let cache;
64
- if (typeof userCache === "boolean") {
65
- cache = userCache ? {} : undefined;
69
+ if (typeof cachePolicy === "boolean") {
70
+ cache = cachePolicy ? {} : undefined;
66
71
  }
67
72
  else {
68
- cache = userCache;
73
+ cache = cachePolicy;
69
74
  }
70
75
  return (...args) => {
71
76
  return call({ func, name, retry, cache }, ...args);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/func/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAC;AAChF,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EACL,yBAAyB,EACzB,GAAG,EACH,QAAQ,EACR,KAAK,EACL,UAAU,GACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAStD,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CAAC,EAAE,IAAI,SAAS,EAA8B;YAClD,CAAC,QAAQ,CAAC,EAAE,IAAI,SAAS,EAAiC;SAC3D;QACD,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,GAAG;QACnB,cAAc,EAAE,GAAG;QACnB,UAAU;QACV,KAAK;QACL,KAAK;KACN,CAAC,CAAC;AACL,CAAuB,CAAC;AAExB,iDAAiD;AACjD,UAAU,CAAC,KAAK,GAAG,SAAS,KAAK,CAAgB,EAC/C,KAAK,EACL,IAAI,GAIL;IACC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;AACtD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,MAAM,GACV,kCAAkC,CAAC,iBAAiB,EAAE,CAAC;IACzD,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC,yBAAyB,CAAW,CAAC;AACpE,CAAC"}
@@ -5,7 +5,7 @@ exports.MessagesZodState = exports.MessagesAnnotation = void 0;
5
5
  const zod_1 = require("zod");
6
6
  const annotation_js_1 = require("./annotation.cjs");
7
7
  const message_js_1 = require("./message.cjs");
8
- const state_js_1 = require("./zod/state.cjs");
8
+ const meta_js_1 = require("./zod/meta.cjs");
9
9
  /**
10
10
  * Prebuilt state annotation that combines returned messages.
11
11
  * Can handle standard messages and special modifiers like {@link RemoveMessage}
@@ -87,7 +87,7 @@ exports.MessagesAnnotation = annotation_js_1.Annotation.Root({
87
87
  * ```
88
88
  */
89
89
  exports.MessagesZodState = zod_1.z.object({
90
- messages: (0, state_js_1.withLangGraph)(zod_1.z.custom(), {
90
+ messages: (0, meta_js_1.withLangGraph)(zod_1.z.custom(), {
91
91
  reducer: {
92
92
  schema: zod_1.z.custom(),
93
93
  fn: message_js_1.messagesStateReducer,
@@ -79,9 +79,9 @@ export declare const MessagesAnnotation: import("./annotation.js").AnnotationRoo
79
79
  * ```
80
80
  */
81
81
  export declare const MessagesZodState: z.ZodObject<{
82
- messages: z.ZodType<BaseMessage[], z.ZodTypeDef, Messages>;
82
+ messages: import("./zod/meta.js").ReducedZodChannel<z.ZodType<BaseMessage[], z.ZodTypeDef, BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<Messages>>;
83
83
  }, "strip", z.ZodTypeAny, {
84
84
  messages: BaseMessage[];
85
85
  }, {
86
- messages: Messages;
86
+ messages: BaseMessage[];
87
87
  }>;
@@ -2,7 +2,7 @@
2
2
  import { z } from "zod";
3
3
  import { Annotation } from "./annotation.js";
4
4
  import { messagesStateReducer } from "./message.js";
5
- import { withLangGraph } from "./zod/state.js";
5
+ import { withLangGraph } from "./zod/meta.js";
6
6
  /**
7
7
  * Prebuilt state annotation that combines returned messages.
8
8
  * Can handle standard messages and special modifiers like {@link RemoveMessage}
@@ -1 +1 @@
1
- {"version":3,"file":"messages_annotation.js","sourceRoot":"","sources":["../../src/graph/messages_annotation.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAG1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAY,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,IAAI,CAAC;IAChD,QAAQ,EAAE,UAAU,CAA0B;QAC5C,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAAiB,EAAE;QACjD,OAAO,EAAE;YACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAY;YAC5B,EAAE,EAAE,oBAAoB;SACzB;QACD,eAAe,EAAE;YACf,cAAc,EAAE,UAAU;SAC3B;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC"}
1
+ {"version":3,"file":"messages_annotation.js","sourceRoot":"","sources":["../../src/graph/messages_annotation.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAG1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAY,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,UAAU,CAAC,IAAI,CAAC;IAChD,QAAQ,EAAE,UAAU,CAA0B;QAC5C,OAAO,EAAE,oBAAoB;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,MAAM,EAAiB,EAAE;QACjD,OAAO,EAAE;YACP,MAAM,EAAE,CAAC,CAAC,MAAM,EAAY;YAC5B,EAAE,EAAE,oBAAoB;SACzB;QACD,eAAe,EAAE;YACf,cAAc,EAAE,UAAU;SAC3B;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC"}
@@ -4,6 +4,7 @@ exports.CompiledStateGraph = exports.StateGraph = void 0;
4
4
  exports.typedNode = typedNode;
5
5
  /* eslint-disable @typescript-eslint/no-use-before-define */
6
6
  const runnables_1 = require("@langchain/core/runnables");
7
+ const types_1 = require("@langchain/core/utils/types");
7
8
  const base_js_1 = require("../channels/base.cjs");
8
9
  const graph_js_1 = require("./graph.cjs");
9
10
  const write_js_1 = require("../pregel/write.cjs");
@@ -16,8 +17,8 @@ const errors_js_1 = require("../errors.cjs");
16
17
  const annotation_js_1 = require("./annotation.cjs");
17
18
  const base_js_2 = require("../managed/base.cjs");
18
19
  const subgraph_js_1 = require("../pregel/utils/subgraph.cjs");
19
- const state_js_1 = require("./zod/state.cjs");
20
20
  const last_value_js_1 = require("../channels/last_value.cjs");
21
+ const meta_js_1 = require("./zod/meta.cjs");
21
22
  const ROOT = "__root__";
22
23
  const PartialStateSchema = Symbol.for("langgraph.state.partial");
23
24
  /**
@@ -150,6 +151,13 @@ class StateGraph extends graph_js_1.Graph {
150
151
  writable: true,
151
152
  value: new Map()
152
153
  });
154
+ /** @internal */
155
+ Object.defineProperty(this, "_metaRegistry", {
156
+ enumerable: true,
157
+ configurable: true,
158
+ writable: true,
159
+ value: meta_js_1.schemaMetaRegistry
160
+ });
153
161
  /** @internal Used only for typing. */
154
162
  Object.defineProperty(this, "_configSchema", {
155
163
  enumerable: true,
@@ -165,9 +173,13 @@ class StateGraph extends graph_js_1.Graph {
165
173
  value: void 0
166
174
  });
167
175
  if (isZodStateGraphArgsWithStateSchema(fields)) {
168
- const stateDef = (0, state_js_1.getChannelsFromZod)(fields.state);
169
- const inputDef = fields.input != null ? (0, state_js_1.getChannelsFromZod)(fields.input) : stateDef;
170
- const outputDef = fields.output != null ? (0, state_js_1.getChannelsFromZod)(fields.output) : stateDef;
176
+ const stateDef = this._metaRegistry.getChannelsForSchema(fields.state);
177
+ const inputDef = fields.input != null
178
+ ? this._metaRegistry.getChannelsForSchema(fields.input)
179
+ : stateDef;
180
+ const outputDef = fields.output != null
181
+ ? this._metaRegistry.getChannelsForSchema(fields.output)
182
+ : stateDef;
171
183
  this._schemaDefinition = stateDef;
172
184
  this._schemaRuntimeDefinition = fields.state;
173
185
  this._inputDefinition = inputDef;
@@ -175,8 +187,8 @@ class StateGraph extends graph_js_1.Graph {
175
187
  this._outputDefinition = outputDef;
176
188
  this._outputRuntimeDefinition = fields.output ?? fields.state;
177
189
  }
178
- else if ((0, state_js_1.isAnyZodObject)(fields)) {
179
- const stateDef = (0, state_js_1.getChannelsFromZod)(fields);
190
+ else if ((0, types_1.isInteropZodObject)(fields)) {
191
+ const stateDef = this._metaRegistry.getChannelsForSchema(fields);
180
192
  this._schemaDefinition = stateDef;
181
193
  this._schemaRuntimeDefinition = fields;
182
194
  this._inputDefinition = stateDef;
@@ -212,8 +224,8 @@ class StateGraph extends graph_js_1.Graph {
212
224
  this._addSchema(this._schemaDefinition);
213
225
  this._addSchema(this._inputDefinition);
214
226
  this._addSchema(this._outputDefinition);
215
- if ((0, state_js_1.isAnyZodObject)(configSchema)) {
216
- this._configRuntimeSchema = configSchema.passthrough();
227
+ if ((0, types_1.isInteropZodObject)(configSchema)) {
228
+ this._configRuntimeSchema = configSchema;
217
229
  }
218
230
  }
219
231
  get allEdges() {
@@ -287,8 +299,8 @@ class StateGraph extends graph_js_1.Graph {
287
299
  }
288
300
  let inputSpec = this._schemaDefinition;
289
301
  if (options?.input !== undefined) {
290
- if ((0, state_js_1.isAnyZodObject)(options.input)) {
291
- inputSpec = (0, state_js_1.getChannelsFromZod)(options.input);
302
+ if ((0, types_1.isInteropZodObject)(options.input)) {
303
+ inputSpec = this._metaRegistry.getChannelsForSchema(options.input);
292
304
  }
293
305
  else if (options.input.spec !== undefined) {
294
306
  inputSpec = options.input.spec;
@@ -461,6 +473,16 @@ function _getChannels(schema) {
461
473
  * instance method.
462
474
  */
463
475
  class CompiledStateGraph extends graph_js_1.CompiledGraph {
476
+ constructor() {
477
+ super(...arguments);
478
+ /** @internal */
479
+ Object.defineProperty(this, "_metaRegistry", {
480
+ enumerable: true,
481
+ configurable: true,
482
+ writable: true,
483
+ value: meta_js_1.schemaMetaRegistry
484
+ });
485
+ }
464
486
  attachNode(key, node) {
465
487
  let outputKeys;
466
488
  if (key === constants_js_1.START) {
@@ -643,28 +665,31 @@ class CompiledStateGraph extends graph_js_1.CompiledGraph {
643
665
  const apply = (schema) => {
644
666
  if (schema == null)
645
667
  return undefined;
646
- return (0, state_js_1.applyZodPlugin)(schema, { reducer: true });
668
+ return this._metaRegistry.getExtendedChannelSchemas(schema, {
669
+ withReducerSchema: true,
670
+ });
647
671
  };
648
- if ((0, state_js_1.isAnyZodObject)(input))
672
+ if ((0, types_1.isInteropZodObject)(input))
649
673
  return apply(input);
650
- if (input === PartialStateSchema)
651
- return apply(schema)?.partial();
674
+ if (input === PartialStateSchema) {
675
+ return (0, types_1.interopZodObjectPartial)(apply(schema));
676
+ }
652
677
  return undefined;
653
678
  })();
654
679
  if ((0, constants_js_1.isCommand)(input)) {
655
680
  const parsedInput = input;
656
681
  if (input.update && schema != null)
657
- parsedInput.update = schema.parse(input.update);
682
+ parsedInput.update = (0, types_1.interopParse)(schema, input.update);
658
683
  return parsedInput;
659
684
  }
660
685
  if (schema != null)
661
- return schema.parse(input);
686
+ return (0, types_1.interopParse)(schema, input);
662
687
  return input;
663
688
  }
664
689
  async _validateConfigurable(config) {
665
690
  const configSchema = this.builder._configRuntimeSchema;
666
- if ((0, state_js_1.isAnyZodObject)(configSchema))
667
- configSchema.parse(config);
691
+ if ((0, types_1.isInteropZodObject)(configSchema))
692
+ (0, types_1.interopParse)(configSchema, config);
668
693
  return config;
669
694
  }
670
695
  }
@@ -704,13 +729,13 @@ function isZodStateGraphArgsWithStateSchema(value) {
704
729
  if (typeof value !== "object" || value == null) {
705
730
  return false;
706
731
  }
707
- if (!("state" in value) || !(0, state_js_1.isAnyZodObject)(value.state)) {
732
+ if (!("state" in value) || !(0, types_1.isInteropZodObject)(value.state)) {
708
733
  return false;
709
734
  }
710
- if ("input" in value && !(0, state_js_1.isAnyZodObject)(value.input)) {
735
+ if ("input" in value && !(0, types_1.isInteropZodObject)(value.input)) {
711
736
  return false;
712
737
  }
713
- if ("output" in value && !(0, state_js_1.isAnyZodObject)(value.output)) {
738
+ if ("output" in value && !(0, types_1.isInteropZodObject)(value.output)) {
714
739
  return false;
715
740
  }
716
741
  return true;
@@ -1,5 +1,6 @@
1
1
  import { RunnableLike } from "@langchain/core/runnables";
2
2
  import { All, type BaseCache, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
3
+ import { type InteropZodObject } from "@langchain/core/utils/types";
3
4
  import { BaseChannel } from "../channels/base.js";
4
5
  import { CompiledGraph, Graph, Branch, AddNodeOptions, NodeSpec } from "./graph.js";
5
6
  import { Command, END, START } from "../constants.js";
@@ -7,7 +8,7 @@ import { AnnotationRoot, SingleReducer, StateDefinition, StateType, UpdateType }
7
8
  import type { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
8
9
  import { ManagedValueSpec } from "../managed/base.js";
9
10
  import type { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
10
- import { AnyZodObject, ZodToStateDefinition } from "./zod/state.js";
11
+ import { type SchemaMetaRegistry, InteropZodToStateDefinition } from "./zod/meta.js";
11
12
  export type ChannelReducers<Channels extends object> = {
12
13
  [K in keyof Channels]: SingleReducer<Channels[K], any>;
13
14
  };
@@ -26,7 +27,7 @@ export type StateGraphNodeSpec<RunInput, RunOutput> = NodeSpec<RunInput, RunOutp
26
27
  export type StateGraphAddNodeOptions<Nodes extends string = string> = {
27
28
  retryPolicy?: RetryPolicy;
28
29
  cachePolicy?: CachePolicy | boolean;
29
- input?: AnnotationRoot<any> | AnyZodObject;
30
+ input?: AnnotationRoot<any> | InteropZodObject;
30
31
  } & AddNodeOptions<Nodes>;
31
32
  export type StateGraphArgsWithStateSchema<SD extends StateDefinition, I extends StateDefinition, O extends StateDefinition> = {
32
33
  stateSchema: AnnotationRoot<SD>;
@@ -37,13 +38,13 @@ export type StateGraphArgsWithInputOutputSchemas<SD extends StateDefinition, O e
37
38
  input: AnnotationRoot<SD>;
38
39
  output: AnnotationRoot<O>;
39
40
  };
40
- type ZodStateGraphArgsWithStateSchema<SD extends AnyZodObject, I extends SDZod, O extends SDZod> = {
41
+ type ZodStateGraphArgsWithStateSchema<SD extends InteropZodObject, I extends SDZod, O extends SDZod> = {
41
42
  state: SD;
42
43
  input?: I;
43
44
  output?: O;
44
45
  };
45
- type SDZod = StateDefinition | AnyZodObject;
46
- type ToStateDefinition<T> = T extends AnyZodObject ? ZodToStateDefinition<T> : T extends StateDefinition ? T : never;
46
+ type SDZod = StateDefinition | InteropZodObject;
47
+ type ToStateDefinition<T> = T extends InteropZodObject ? InteropZodToStateDefinition<T> : T extends StateDefinition ? T : never;
47
48
  type NodeAction<S, U, C extends SDZod> = RunnableLike<S, U extends object ? U & Record<string, any> : U, // eslint-disable-line @typescript-eslint/no-explicit-any
48
49
  LangGraphRunnableConfig<StateType<ToStateDefinition<C>>>>;
49
50
  declare const PartialStateSchema: unique symbol;
@@ -116,27 +117,29 @@ export declare class StateGraph<SD extends SDZod | unknown, S = SD extends SDZod
116
117
  /** @internal */
117
118
  _schemaDefinition: StateDefinition;
118
119
  /** @internal */
119
- _schemaRuntimeDefinition: AnyZodObject | undefined;
120
+ _schemaRuntimeDefinition: InteropZodObject | undefined;
120
121
  /** @internal */
121
122
  _inputDefinition: I;
122
123
  /** @internal */
123
- _inputRuntimeDefinition: AnyZodObject | PartialStateSchema | undefined;
124
+ _inputRuntimeDefinition: InteropZodObject | PartialStateSchema | undefined;
124
125
  /** @internal */
125
126
  _outputDefinition: O;
126
127
  /** @internal */
127
- _outputRuntimeDefinition: AnyZodObject | undefined;
128
+ _outputRuntimeDefinition: InteropZodObject | undefined;
128
129
  /**
129
130
  * Map schemas to managed values
130
131
  * @internal
131
132
  */
132
133
  _schemaDefinitions: Map<any, any>;
134
+ /** @internal */
135
+ _metaRegistry: SchemaMetaRegistry;
133
136
  /** @internal Used only for typing. */
134
137
  _configSchema: ToStateDefinition<C> | undefined;
135
138
  /** @internal */
136
- _configRuntimeSchema: AnyZodObject | undefined;
139
+ _configRuntimeSchema: InteropZodObject | undefined;
137
140
  constructor(fields: SD extends StateDefinition ? StateGraphArgsWithInputOutputSchemas<SD, ToStateDefinition<O>> : never, configSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
138
141
  constructor(fields: SD extends StateDefinition ? SD | AnnotationRoot<SD> | StateGraphArgs<S> | StateGraphArgsWithStateSchema<SD, ToStateDefinition<I>, ToStateDefinition<O>> : StateGraphArgs<S>, configSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
139
- constructor(fields: SD extends AnyZodObject ? SD | ZodStateGraphArgsWithStateSchema<SD, I, O> : never, configSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
142
+ constructor(fields: SD extends InteropZodObject ? SD | ZodStateGraphArgsWithStateSchema<SD, I, O> : never, configSchema?: C | AnnotationRoot<ToStateDefinition<C>>);
140
143
  get allEdges(): Set<[string, string]>;
141
144
  _addSchema(stateDefinition: SDZod): void;
142
145
  addNode<K extends string>(nodes: Record<K, NodeAction<S, U, C>> | [
@@ -168,6 +171,8 @@ export declare class StateGraph<SD extends SDZod | unknown, S = SD extends SDZod
168
171
  */
169
172
  export declare class CompiledStateGraph<S, U, N extends string = typeof START, I extends SDZod = StateDefinition, O extends SDZod = StateDefinition, C extends SDZod = StateDefinition> extends CompiledGraph<N, S, U, StateType<ToStateDefinition<C>>, UpdateType<ToStateDefinition<I>>, StateType<ToStateDefinition<O>>> {
170
173
  builder: StateGraph<unknown, S, U, N, I, O, C>;
174
+ /** @internal */
175
+ _metaRegistry: SchemaMetaRegistry;
171
176
  attachNode(key: typeof START, node?: never): void;
172
177
  attachNode(key: N, node: StateGraphNodeSpec<S, U>): void;
173
178
  attachEdge(starts: N | N[] | "__start__", end: N | "__end__"): void;
@@ -177,11 +182,13 @@ export declare class CompiledStateGraph<S, U, N extends string = typeof START, I
177
182
  protected _validateInput(input: UpdateType<ToStateDefinition<I>>): Promise<UpdateType<ToStateDefinition<I>>>;
178
183
  protected _validateConfigurable(config: Partial<LangGraphRunnableConfig["configurable"]>): Promise<LangGraphRunnableConfig["configurable"]>;
179
184
  }
180
- type TypedNodeAction<SD extends StateDefinition, Nodes extends string> = (state: StateType<SD>, config: LangGraphRunnableConfig) => UpdateType<SD> | Command<unknown, UpdateType<SD>, Nodes>;
181
- export declare function typedNode<SD extends SDZod, Nodes extends string>(_state: SD extends StateDefinition ? AnnotationRoot<SD> : never, _options?: {
185
+ type TypedNodeAction<SD extends StateDefinition, Nodes extends string, C extends StateDefinition = StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Command<unknown, UpdateType<SD>, Nodes>, LangGraphRunnableConfig<StateType<C>>>;
186
+ export declare function typedNode<SD extends SDZod, Nodes extends string, C extends SDZod = StateDefinition>(_state: SD extends StateDefinition ? AnnotationRoot<SD> : never, _options?: {
182
187
  nodes?: Nodes[];
183
- }): (func: TypedNodeAction<ToStateDefinition<SD>, Nodes>, options?: StateGraphAddNodeOptions<Nodes>) => TypedNodeAction<ToStateDefinition<SD>, Nodes>;
184
- export declare function typedNode<SD extends SDZod, Nodes extends string>(_state: SD extends AnyZodObject ? SD : never, _options?: {
188
+ config?: C extends StateDefinition ? AnnotationRoot<C> : never;
189
+ }): (func: TypedNodeAction<ToStateDefinition<SD>, Nodes, ToStateDefinition<C>>, options?: StateGraphAddNodeOptions<Nodes>) => TypedNodeAction<ToStateDefinition<SD>, Nodes, ToStateDefinition<C>>;
190
+ export declare function typedNode<SD extends SDZod, Nodes extends string, C extends SDZod = StateDefinition>(_state: SD extends InteropZodObject ? SD : never, _options?: {
185
191
  nodes?: Nodes[];
186
- }): (func: TypedNodeAction<ToStateDefinition<SD>, Nodes>, options?: StateGraphAddNodeOptions<Nodes>) => TypedNodeAction<ToStateDefinition<SD>, Nodes>;
192
+ config?: C extends InteropZodObject ? C : never;
193
+ }): (func: TypedNodeAction<ToStateDefinition<SD>, Nodes, ToStateDefinition<C>>, options?: StateGraphAddNodeOptions<Nodes>) => TypedNodeAction<ToStateDefinition<SD>, Nodes, ToStateDefinition<C>>;
187
194
  export {};
@@ -1,5 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-use-before-define */
2
2
  import { _coerceToRunnable, Runnable, } from "@langchain/core/runnables";
3
+ import { interopParse, interopZodObjectPartial, isInteropZodObject, } from "@langchain/core/utils/types";
3
4
  import { isBaseChannel } from "../channels/base.js";
4
5
  import { CompiledGraph, Graph, Branch, } from "./graph.js";
5
6
  import { ChannelWrite, PASSTHROUGH, } from "../pregel/write.js";
@@ -12,8 +13,8 @@ import { InvalidUpdateError, ParentCommand } from "../errors.js";
12
13
  import { getChannel, } from "./annotation.js";
13
14
  import { isConfiguredManagedValue } from "../managed/base.js";
14
15
  import { isPregelLike } from "../pregel/utils/subgraph.js";
15
- import { getChannelsFromZod, applyZodPlugin, isAnyZodObject, } from "./zod/state.js";
16
16
  import { LastValueAfterFinish } from "../channels/last_value.js";
17
+ import { schemaMetaRegistry, } from "./zod/meta.js";
17
18
  const ROOT = "__root__";
18
19
  const PartialStateSchema = Symbol.for("langgraph.state.partial");
19
20
  /**
@@ -146,6 +147,13 @@ export class StateGraph extends Graph {
146
147
  writable: true,
147
148
  value: new Map()
148
149
  });
150
+ /** @internal */
151
+ Object.defineProperty(this, "_metaRegistry", {
152
+ enumerable: true,
153
+ configurable: true,
154
+ writable: true,
155
+ value: schemaMetaRegistry
156
+ });
149
157
  /** @internal Used only for typing. */
150
158
  Object.defineProperty(this, "_configSchema", {
151
159
  enumerable: true,
@@ -161,9 +169,13 @@ export class StateGraph extends Graph {
161
169
  value: void 0
162
170
  });
163
171
  if (isZodStateGraphArgsWithStateSchema(fields)) {
164
- const stateDef = getChannelsFromZod(fields.state);
165
- const inputDef = fields.input != null ? getChannelsFromZod(fields.input) : stateDef;
166
- const outputDef = fields.output != null ? getChannelsFromZod(fields.output) : stateDef;
172
+ const stateDef = this._metaRegistry.getChannelsForSchema(fields.state);
173
+ const inputDef = fields.input != null
174
+ ? this._metaRegistry.getChannelsForSchema(fields.input)
175
+ : stateDef;
176
+ const outputDef = fields.output != null
177
+ ? this._metaRegistry.getChannelsForSchema(fields.output)
178
+ : stateDef;
167
179
  this._schemaDefinition = stateDef;
168
180
  this._schemaRuntimeDefinition = fields.state;
169
181
  this._inputDefinition = inputDef;
@@ -171,8 +183,8 @@ export class StateGraph extends Graph {
171
183
  this._outputDefinition = outputDef;
172
184
  this._outputRuntimeDefinition = fields.output ?? fields.state;
173
185
  }
174
- else if (isAnyZodObject(fields)) {
175
- const stateDef = getChannelsFromZod(fields);
186
+ else if (isInteropZodObject(fields)) {
187
+ const stateDef = this._metaRegistry.getChannelsForSchema(fields);
176
188
  this._schemaDefinition = stateDef;
177
189
  this._schemaRuntimeDefinition = fields;
178
190
  this._inputDefinition = stateDef;
@@ -208,8 +220,8 @@ export class StateGraph extends Graph {
208
220
  this._addSchema(this._schemaDefinition);
209
221
  this._addSchema(this._inputDefinition);
210
222
  this._addSchema(this._outputDefinition);
211
- if (isAnyZodObject(configSchema)) {
212
- this._configRuntimeSchema = configSchema.passthrough();
223
+ if (isInteropZodObject(configSchema)) {
224
+ this._configRuntimeSchema = configSchema;
213
225
  }
214
226
  }
215
227
  get allEdges() {
@@ -283,8 +295,8 @@ export class StateGraph extends Graph {
283
295
  }
284
296
  let inputSpec = this._schemaDefinition;
285
297
  if (options?.input !== undefined) {
286
- if (isAnyZodObject(options.input)) {
287
- inputSpec = getChannelsFromZod(options.input);
298
+ if (isInteropZodObject(options.input)) {
299
+ inputSpec = this._metaRegistry.getChannelsForSchema(options.input);
288
300
  }
289
301
  else if (options.input.spec !== undefined) {
290
302
  inputSpec = options.input.spec;
@@ -456,6 +468,16 @@ function _getChannels(schema) {
456
468
  * instance method.
457
469
  */
458
470
  export class CompiledStateGraph extends CompiledGraph {
471
+ constructor() {
472
+ super(...arguments);
473
+ /** @internal */
474
+ Object.defineProperty(this, "_metaRegistry", {
475
+ enumerable: true,
476
+ configurable: true,
477
+ writable: true,
478
+ value: schemaMetaRegistry
479
+ });
480
+ }
459
481
  attachNode(key, node) {
460
482
  let outputKeys;
461
483
  if (key === START) {
@@ -638,28 +660,31 @@ export class CompiledStateGraph extends CompiledGraph {
638
660
  const apply = (schema) => {
639
661
  if (schema == null)
640
662
  return undefined;
641
- return applyZodPlugin(schema, { reducer: true });
663
+ return this._metaRegistry.getExtendedChannelSchemas(schema, {
664
+ withReducerSchema: true,
665
+ });
642
666
  };
643
- if (isAnyZodObject(input))
667
+ if (isInteropZodObject(input))
644
668
  return apply(input);
645
- if (input === PartialStateSchema)
646
- return apply(schema)?.partial();
669
+ if (input === PartialStateSchema) {
670
+ return interopZodObjectPartial(apply(schema));
671
+ }
647
672
  return undefined;
648
673
  })();
649
674
  if (isCommand(input)) {
650
675
  const parsedInput = input;
651
676
  if (input.update && schema != null)
652
- parsedInput.update = schema.parse(input.update);
677
+ parsedInput.update = interopParse(schema, input.update);
653
678
  return parsedInput;
654
679
  }
655
680
  if (schema != null)
656
- return schema.parse(input);
681
+ return interopParse(schema, input);
657
682
  return input;
658
683
  }
659
684
  async _validateConfigurable(config) {
660
685
  const configSchema = this.builder._configRuntimeSchema;
661
- if (isAnyZodObject(configSchema))
662
- configSchema.parse(config);
686
+ if (isInteropZodObject(configSchema))
687
+ interopParse(configSchema, config);
663
688
  return config;
664
689
  }
665
690
  }
@@ -698,13 +723,13 @@ function isZodStateGraphArgsWithStateSchema(value) {
698
723
  if (typeof value !== "object" || value == null) {
699
724
  return false;
700
725
  }
701
- if (!("state" in value) || !isAnyZodObject(value.state)) {
726
+ if (!("state" in value) || !isInteropZodObject(value.state)) {
702
727
  return false;
703
728
  }
704
- if ("input" in value && !isAnyZodObject(value.input)) {
729
+ if ("input" in value && !isInteropZodObject(value.input)) {
705
730
  return false;
706
731
  }
707
- if ("output" in value && !isAnyZodObject(value.output)) {
732
+ if ("output" in value && !isInteropZodObject(value.output)) {
708
733
  return false;
709
734
  }
710
735
  return true;