@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
@@ -1,39 +1,42 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const zod_1 = require("zod");
4
- const state_js_1 = require("./state.cjs");
4
+ const v3_1 = require("zod/v3");
5
+ const types_1 = require("@langchain/core/utils/types");
6
+ const meta_js_1 = require("./meta.cjs");
5
7
  const metaSymbol = Symbol.for("langgraph-zod");
6
8
  if (!(metaSymbol in globalThis)) {
7
9
  globalThis[metaSymbol] = new WeakSet();
8
10
  }
9
- try {
11
+ function applyPluginPrototype(prototype) {
10
12
  const cache = globalThis[metaSymbol];
11
- if (!cache?.has(zod_1.z.ZodType.prototype)) {
12
- Object.defineProperty(zod_1.z.ZodType.prototype, "langgraph", {
13
- get() {
14
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
- const zodThis = this;
16
- return {
17
- metadata(jsonSchemaExtra) {
18
- (0, state_js_1.extendMeta)(zodThis, (meta) => ({ ...meta, jsonSchemaExtra }));
19
- return zodThis;
20
- },
21
- reducer(fn, schema) {
22
- const defaultFn = (0, state_js_1.isZodDefault)(zodThis)
23
- ? // @ts-expect-error Due to `_def` being `any`
24
- zodThis._def.defaultValue
25
- : undefined;
26
- (0, state_js_1.extendMeta)(zodThis, (meta) => ({
27
- ...meta,
28
- default: defaultFn ?? meta?.default,
29
- reducer: { schema, fn },
30
- }));
31
- return zodThis;
32
- },
33
- };
34
- },
35
- });
13
+ if (cache.has(prototype)) {
14
+ return; // Already applied
36
15
  }
16
+ Object.defineProperty(prototype, "langgraph", {
17
+ get() {
18
+ // Return type is any, actual type provided by module augmentation
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ const zodThis = this;
21
+ return {
22
+ metadata(jsonSchemaExtra) {
23
+ return (0, meta_js_1.withLangGraph)(zodThis, { jsonSchemaExtra });
24
+ },
25
+ reducer(fn, schema) {
26
+ const defaultFn = (0, types_1.getInteropZodDefaultGetter)(zodThis);
27
+ return (0, meta_js_1.withLangGraph)(zodThis, {
28
+ default: defaultFn,
29
+ reducer: { schema, fn },
30
+ });
31
+ },
32
+ };
33
+ },
34
+ });
35
+ cache.add(prototype);
36
+ }
37
+ try {
38
+ applyPluginPrototype(v3_1.z.ZodType.prototype);
39
+ applyPluginPrototype(zod_1.z.ZodType.prototype);
37
40
  }
38
41
  catch (error) {
39
42
  throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
@@ -1,6 +1,6 @@
1
- import { z } from "zod";
2
- interface ZodLangGraphTypes<T extends z.ZodTypeAny, Output> {
3
- reducer<Input = z.output<T>>(transform: (a: Output, arg: Input) => Output, options?: z.ZodType<Input>): z.ZodType<Output, z.ZodEffectsDef<T>, Input>;
1
+ import { z as zd } from "zod";
2
+ interface ZodLangGraphTypes<T extends zd.ZodTypeAny, Output> {
3
+ reducer<Input = zd.output<T>>(transform: (a: Output, arg: Input) => Output, options?: zd.ZodType<Input>): zd.ZodType<Output, zd.ZodEffectsDef<T>, Input>;
4
4
  metadata(payload: {
5
5
  langgraph_nodes?: string[];
6
6
  langgraph_type?: "prompt";
@@ -9,6 +9,19 @@ interface ZodLangGraphTypes<T extends z.ZodTypeAny, Output> {
9
9
  }
10
10
  declare module "zod" {
11
11
  interface ZodType<Output> {
12
+ /**
13
+ * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions
14
+ * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}
15
+ */
16
+ langgraph: ZodLangGraphTypes<this, Output>;
17
+ }
18
+ }
19
+ declare module "zod/v3" {
20
+ interface ZodType<Output> {
21
+ /**
22
+ * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions
23
+ * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}
24
+ */
12
25
  langgraph: ZodLangGraphTypes<this, Output>;
13
26
  }
14
27
  }
@@ -1,37 +1,40 @@
1
- import { z } from "zod";
2
- import { extendMeta, isZodDefault } from "./state.js";
1
+ import { z as zd } from "zod";
2
+ import { z as z3 } from "zod/v3";
3
+ import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
4
+ import { withLangGraph } from "./meta.js";
3
5
  const metaSymbol = Symbol.for("langgraph-zod");
4
6
  if (!(metaSymbol in globalThis)) {
5
7
  globalThis[metaSymbol] = new WeakSet();
6
8
  }
7
- try {
9
+ function applyPluginPrototype(prototype) {
8
10
  const cache = globalThis[metaSymbol];
9
- if (!cache?.has(z.ZodType.prototype)) {
10
- Object.defineProperty(z.ZodType.prototype, "langgraph", {
11
- get() {
12
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
- const zodThis = this;
14
- return {
15
- metadata(jsonSchemaExtra) {
16
- extendMeta(zodThis, (meta) => ({ ...meta, jsonSchemaExtra }));
17
- return zodThis;
18
- },
19
- reducer(fn, schema) {
20
- const defaultFn = isZodDefault(zodThis)
21
- ? // @ts-expect-error Due to `_def` being `any`
22
- zodThis._def.defaultValue
23
- : undefined;
24
- extendMeta(zodThis, (meta) => ({
25
- ...meta,
26
- default: defaultFn ?? meta?.default,
27
- reducer: { schema, fn },
28
- }));
29
- return zodThis;
30
- },
31
- };
32
- },
33
- });
11
+ if (cache.has(prototype)) {
12
+ return; // Already applied
34
13
  }
14
+ Object.defineProperty(prototype, "langgraph", {
15
+ get() {
16
+ // Return type is any, actual type provided by module augmentation
17
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
+ const zodThis = this;
19
+ return {
20
+ metadata(jsonSchemaExtra) {
21
+ return withLangGraph(zodThis, { jsonSchemaExtra });
22
+ },
23
+ reducer(fn, schema) {
24
+ const defaultFn = getInteropZodDefaultGetter(zodThis);
25
+ return withLangGraph(zodThis, {
26
+ default: defaultFn,
27
+ reducer: { schema, fn },
28
+ });
29
+ },
30
+ };
31
+ },
32
+ });
33
+ cache.add(prototype);
34
+ }
35
+ try {
36
+ applyPluginPrototype(z3.ZodType.prototype);
37
+ applyPluginPrototype(zd.ZodType.prototype);
35
38
  }
36
39
  catch (error) {
37
40
  throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/graph/zod/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAa,MAAM,YAAY,CAAC;AAEjE,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AA0B/C,IAAI,CAAC,CAAC,UAAU,IAAI,UAAU,CAAC,EAAE,CAAC;IAC/B,UAA+B,CAAC,UAAU,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;AAC/D,CAAC;AAED,IAAI,CAAC;IACH,MAAM,KAAK,GAAI,UAA+B,CAAC,UAAU,CAAC,CAAC;IAE3D,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;QACrC,MAAM,CAAC,cAAc,CACnB,CAAC,CAAC,OAAO,CAAC,SAAS,EACnB,WAAqC,EACrC;YACE,GAAG;gBACD,8DAA8D;gBAC9D,MAAM,OAAO,GAAG,IAAiD,CAAC;gBAGlE,OAAO;oBACL,QAAQ,CAAC,eAAwD;wBAC/D,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;wBAC9D,OAAO,OAAO,CAAC;oBACjB,CAAC;oBACD,OAAO,CACL,EAAqC,EACrC,MAAyB;wBAEzB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;4BACrC,CAAC,CA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,CAAC,cAAc,CACnB,SAAS,EACT,WAA6C,EAC7C;QACE,GAAG;YACD,kEAAkE;YAClE,8DAA8D;YAC9D,MAAM,OAAO,GAAG,IAAqB,CAAC;YAGtC,OAAO;gBACL,QAAQ,CACN,eAA8D;oBAE9D,OAAO,aAAa,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,CACL,EAAqC,EACrC,MAA0B;oBAE1B,MAAM,SAAS,GAAG,0BAA0B,CAAC,OAAO,CAAC,CAAC;oBACtD,OAAO,aAAa,CAAC,OAAO,EAAE;wBAC5B,OAAO,EAAE,SAAS;wBAClB,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;qBACxB,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;KACF,CACF,CAAC;IACF,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACvB,CAAC;AAED,IAAI,CAAC;IACH,oBAAoB,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3C,oBAAoB,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAC7C,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CACb,oKAAoK,EACpK,EAAE,KAAK,EAAE,KAAK,EAAE,CACjB,CAAC;AACJ,CAAC"}
@@ -5,8 +5,8 @@ exports.getUpdateTypeSchema = getUpdateTypeSchema;
5
5
  exports.getInputTypeSchema = getInputTypeSchema;
6
6
  exports.getOutputTypeSchema = getOutputTypeSchema;
7
7
  exports.getConfigTypeSchema = getConfigTypeSchema;
8
- const zod_to_json_schema_1 = require("zod-to-json-schema");
9
- const state_js_1 = require("./state.cjs");
8
+ const json_schema_1 = require("@langchain/core/utils/json_schema");
9
+ const meta_js_1 = require("./meta.cjs");
10
10
  const PartialStateSchema = Symbol.for("langgraph.state.partial");
11
11
  function isGraphWithZodLike(graph) {
12
12
  if (!graph || typeof graph !== "object")
@@ -18,37 +18,59 @@ function isGraphWithZodLike(graph) {
18
18
  }
19
19
  return true;
20
20
  }
21
+ function applyJsonSchemaExtrasFromDescription(schema) {
22
+ if (Array.isArray(schema)) {
23
+ return schema.map(applyJsonSchemaExtrasFromDescription);
24
+ }
25
+ if (typeof schema === "object" && schema != null) {
26
+ const output = Object.fromEntries(Object.entries(schema).map(([key, value]) => [
27
+ key,
28
+ applyJsonSchemaExtrasFromDescription(value),
29
+ ]));
30
+ if ("description" in output &&
31
+ typeof output.description === "string" &&
32
+ output.description.startsWith(meta_js_1.META_EXTRAS_DESCRIPTION_PREFIX)) {
33
+ const strMeta = output.description.slice(meta_js_1.META_EXTRAS_DESCRIPTION_PREFIX.length);
34
+ delete output.description;
35
+ Object.assign(output, JSON.parse(strMeta));
36
+ }
37
+ return output;
38
+ }
39
+ return schema;
40
+ }
21
41
  function toJsonSchema(schema) {
22
- return (0, state_js_1.applyExtraFromDescription)((0, zod_to_json_schema_1.zodToJsonSchema)(schema));
42
+ return applyJsonSchemaExtrasFromDescription((0, json_schema_1.toJsonSchema)(schema));
23
43
  }
24
44
  /**
25
45
  * Get the state schema for a graph.
26
46
  * @param graph - The graph to get the state schema for.
27
47
  * @returns The state schema for the graph.
28
48
  */
29
- function getStateTypeSchema(graph) {
49
+ function getStateTypeSchema(graph, registry = meta_js_1.schemaMetaRegistry) {
30
50
  if (!isGraphWithZodLike(graph))
31
51
  return undefined;
32
52
  const schemaDef = graph.builder._schemaRuntimeDefinition;
33
53
  if (!schemaDef)
34
54
  return undefined;
35
- return toJsonSchema((0, state_js_1.applyZodPlugin)(schemaDef, { jsonSchemaExtra: true }));
55
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
56
+ withJsonSchemaExtrasAsDescription: true,
57
+ }));
36
58
  }
37
59
  /**
38
60
  * Get the update schema for a graph.
39
61
  * @param graph - The graph to get the update schema for.
40
62
  * @returns The update schema for the graph.
41
63
  */
42
- function getUpdateTypeSchema(graph) {
64
+ function getUpdateTypeSchema(graph, registry = meta_js_1.schemaMetaRegistry) {
43
65
  if (!isGraphWithZodLike(graph))
44
66
  return undefined;
45
67
  const schemaDef = graph.builder._schemaRuntimeDefinition;
46
68
  if (!schemaDef)
47
69
  return undefined;
48
- return toJsonSchema((0, state_js_1.applyZodPlugin)(schemaDef, {
49
- reducer: true,
50
- jsonSchemaExtra: true,
51
- partial: true,
70
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
71
+ withReducerSchema: true,
72
+ withJsonSchemaExtrasAsDescription: true,
73
+ asPartial: true,
52
74
  }));
53
75
  }
54
76
  /**
@@ -56,7 +78,7 @@ function getUpdateTypeSchema(graph) {
56
78
  * @param graph - The graph to get the input schema for.
57
79
  * @returns The input schema for the graph.
58
80
  */
59
- function getInputTypeSchema(graph) {
81
+ function getInputTypeSchema(graph, registry = meta_js_1.schemaMetaRegistry) {
60
82
  if (!isGraphWithZodLike(graph))
61
83
  return undefined;
62
84
  let schemaDef = graph.builder._inputRuntimeDefinition;
@@ -66,10 +88,10 @@ function getInputTypeSchema(graph) {
66
88
  }
67
89
  if (!schemaDef)
68
90
  return undefined;
69
- return toJsonSchema((0, state_js_1.applyZodPlugin)(schemaDef, {
70
- reducer: true,
71
- jsonSchemaExtra: true,
72
- partial: true,
91
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
92
+ withReducerSchema: true,
93
+ withJsonSchemaExtrasAsDescription: true,
94
+ asPartial: true,
73
95
  }));
74
96
  }
75
97
  /**
@@ -77,25 +99,29 @@ function getInputTypeSchema(graph) {
77
99
  * @param graph - The graph to get the output schema for.
78
100
  * @returns The output schema for the graph.
79
101
  */
80
- function getOutputTypeSchema(graph) {
102
+ function getOutputTypeSchema(graph, registry = meta_js_1.schemaMetaRegistry) {
81
103
  if (!isGraphWithZodLike(graph))
82
104
  return undefined;
83
105
  const schemaDef = graph.builder._outputRuntimeDefinition;
84
106
  if (!schemaDef)
85
107
  return undefined;
86
- return toJsonSchema((0, state_js_1.applyZodPlugin)(schemaDef, { jsonSchemaExtra: true }));
108
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
109
+ withJsonSchemaExtrasAsDescription: true,
110
+ }));
87
111
  }
88
112
  /**
89
113
  * Get the config schema for a graph.
90
114
  * @param graph - The graph to get the config schema for.
91
115
  * @returns The config schema for the graph.
92
116
  */
93
- function getConfigTypeSchema(graph) {
117
+ function getConfigTypeSchema(graph, registry = meta_js_1.schemaMetaRegistry) {
94
118
  if (!isGraphWithZodLike(graph))
95
119
  return undefined;
96
120
  const configDef = graph.builder._configRuntimeSchema;
97
121
  if (!configDef)
98
122
  return undefined;
99
- return toJsonSchema((0, state_js_1.applyZodPlugin)(configDef, { jsonSchemaExtra: true }));
123
+ return toJsonSchema(registry.getExtendedChannelSchemas(configDef, {
124
+ withJsonSchemaExtrasAsDescription: true,
125
+ }));
100
126
  }
101
127
  //# sourceMappingURL=schema.js.map
@@ -1,33 +1,32 @@
1
- import { zodToJsonSchema as _zodToJsonSchema } from "zod-to-json-schema";
2
- type JsonSchema = ReturnType<typeof _zodToJsonSchema>;
1
+ import { type JSONSchema } from "@langchain/core/utils/json_schema";
2
+ import { SchemaMetaRegistry } from "./meta.js";
3
3
  /**
4
4
  * Get the state schema for a graph.
5
5
  * @param graph - The graph to get the state schema for.
6
6
  * @returns The state schema for the graph.
7
7
  */
8
- export declare function getStateTypeSchema(graph: unknown): JsonSchema | undefined;
8
+ export declare function getStateTypeSchema(graph: unknown, registry?: SchemaMetaRegistry): JSONSchema | undefined;
9
9
  /**
10
10
  * Get the update schema for a graph.
11
11
  * @param graph - The graph to get the update schema for.
12
12
  * @returns The update schema for the graph.
13
13
  */
14
- export declare function getUpdateTypeSchema(graph: unknown): JsonSchema | undefined;
14
+ export declare function getUpdateTypeSchema(graph: unknown, registry?: SchemaMetaRegistry): JSONSchema | undefined;
15
15
  /**
16
16
  * Get the input schema for a graph.
17
17
  * @param graph - The graph to get the input schema for.
18
18
  * @returns The input schema for the graph.
19
19
  */
20
- export declare function getInputTypeSchema(graph: unknown): JsonSchema | undefined;
20
+ export declare function getInputTypeSchema(graph: unknown, registry?: SchemaMetaRegistry): JSONSchema | undefined;
21
21
  /**
22
22
  * Get the output schema for a graph.
23
23
  * @param graph - The graph to get the output schema for.
24
24
  * @returns The output schema for the graph.
25
25
  */
26
- export declare function getOutputTypeSchema(graph: unknown): JsonSchema | undefined;
26
+ export declare function getOutputTypeSchema(graph: unknown, registry?: SchemaMetaRegistry): JSONSchema | undefined;
27
27
  /**
28
28
  * Get the config schema for a graph.
29
29
  * @param graph - The graph to get the config schema for.
30
30
  * @returns The config schema for the graph.
31
31
  */
32
- export declare function getConfigTypeSchema(graph: unknown): JsonSchema | undefined;
33
- export {};
32
+ export declare function getConfigTypeSchema(graph: unknown, registry?: SchemaMetaRegistry): JSONSchema | undefined;
@@ -1,5 +1,5 @@
1
- import { zodToJsonSchema as _zodToJsonSchema } from "zod-to-json-schema";
2
- import { applyZodPlugin, applyExtraFromDescription } from "./state.js";
1
+ import { toJsonSchema as interopToJsonSchema, } from "@langchain/core/utils/json_schema";
2
+ import { META_EXTRAS_DESCRIPTION_PREFIX, schemaMetaRegistry, } from "./meta.js";
3
3
  const PartialStateSchema = Symbol.for("langgraph.state.partial");
4
4
  function isGraphWithZodLike(graph) {
5
5
  if (!graph || typeof graph !== "object")
@@ -11,37 +11,59 @@ function isGraphWithZodLike(graph) {
11
11
  }
12
12
  return true;
13
13
  }
14
+ function applyJsonSchemaExtrasFromDescription(schema) {
15
+ if (Array.isArray(schema)) {
16
+ return schema.map(applyJsonSchemaExtrasFromDescription);
17
+ }
18
+ if (typeof schema === "object" && schema != null) {
19
+ const output = Object.fromEntries(Object.entries(schema).map(([key, value]) => [
20
+ key,
21
+ applyJsonSchemaExtrasFromDescription(value),
22
+ ]));
23
+ if ("description" in output &&
24
+ typeof output.description === "string" &&
25
+ output.description.startsWith(META_EXTRAS_DESCRIPTION_PREFIX)) {
26
+ const strMeta = output.description.slice(META_EXTRAS_DESCRIPTION_PREFIX.length);
27
+ delete output.description;
28
+ Object.assign(output, JSON.parse(strMeta));
29
+ }
30
+ return output;
31
+ }
32
+ return schema;
33
+ }
14
34
  function toJsonSchema(schema) {
15
- return applyExtraFromDescription(_zodToJsonSchema(schema));
35
+ return applyJsonSchemaExtrasFromDescription(interopToJsonSchema(schema));
16
36
  }
17
37
  /**
18
38
  * Get the state schema for a graph.
19
39
  * @param graph - The graph to get the state schema for.
20
40
  * @returns The state schema for the graph.
21
41
  */
22
- export function getStateTypeSchema(graph) {
42
+ export function getStateTypeSchema(graph, registry = schemaMetaRegistry) {
23
43
  if (!isGraphWithZodLike(graph))
24
44
  return undefined;
25
45
  const schemaDef = graph.builder._schemaRuntimeDefinition;
26
46
  if (!schemaDef)
27
47
  return undefined;
28
- return toJsonSchema(applyZodPlugin(schemaDef, { jsonSchemaExtra: true }));
48
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
49
+ withJsonSchemaExtrasAsDescription: true,
50
+ }));
29
51
  }
30
52
  /**
31
53
  * Get the update schema for a graph.
32
54
  * @param graph - The graph to get the update schema for.
33
55
  * @returns The update schema for the graph.
34
56
  */
35
- export function getUpdateTypeSchema(graph) {
57
+ export function getUpdateTypeSchema(graph, registry = schemaMetaRegistry) {
36
58
  if (!isGraphWithZodLike(graph))
37
59
  return undefined;
38
60
  const schemaDef = graph.builder._schemaRuntimeDefinition;
39
61
  if (!schemaDef)
40
62
  return undefined;
41
- return toJsonSchema(applyZodPlugin(schemaDef, {
42
- reducer: true,
43
- jsonSchemaExtra: true,
44
- partial: true,
63
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
64
+ withReducerSchema: true,
65
+ withJsonSchemaExtrasAsDescription: true,
66
+ asPartial: true,
45
67
  }));
46
68
  }
47
69
  /**
@@ -49,7 +71,7 @@ export function getUpdateTypeSchema(graph) {
49
71
  * @param graph - The graph to get the input schema for.
50
72
  * @returns The input schema for the graph.
51
73
  */
52
- export function getInputTypeSchema(graph) {
74
+ export function getInputTypeSchema(graph, registry = schemaMetaRegistry) {
53
75
  if (!isGraphWithZodLike(graph))
54
76
  return undefined;
55
77
  let schemaDef = graph.builder._inputRuntimeDefinition;
@@ -59,10 +81,10 @@ export function getInputTypeSchema(graph) {
59
81
  }
60
82
  if (!schemaDef)
61
83
  return undefined;
62
- return toJsonSchema(applyZodPlugin(schemaDef, {
63
- reducer: true,
64
- jsonSchemaExtra: true,
65
- partial: true,
84
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
85
+ withReducerSchema: true,
86
+ withJsonSchemaExtrasAsDescription: true,
87
+ asPartial: true,
66
88
  }));
67
89
  }
68
90
  /**
@@ -70,25 +92,29 @@ export function getInputTypeSchema(graph) {
70
92
  * @param graph - The graph to get the output schema for.
71
93
  * @returns The output schema for the graph.
72
94
  */
73
- export function getOutputTypeSchema(graph) {
95
+ export function getOutputTypeSchema(graph, registry = schemaMetaRegistry) {
74
96
  if (!isGraphWithZodLike(graph))
75
97
  return undefined;
76
98
  const schemaDef = graph.builder._outputRuntimeDefinition;
77
99
  if (!schemaDef)
78
100
  return undefined;
79
- return toJsonSchema(applyZodPlugin(schemaDef, { jsonSchemaExtra: true }));
101
+ return toJsonSchema(registry.getExtendedChannelSchemas(schemaDef, {
102
+ withJsonSchemaExtrasAsDescription: true,
103
+ }));
80
104
  }
81
105
  /**
82
106
  * Get the config schema for a graph.
83
107
  * @param graph - The graph to get the config schema for.
84
108
  * @returns The config schema for the graph.
85
109
  */
86
- export function getConfigTypeSchema(graph) {
110
+ export function getConfigTypeSchema(graph, registry = schemaMetaRegistry) {
87
111
  if (!isGraphWithZodLike(graph))
88
112
  return undefined;
89
113
  const configDef = graph.builder._configRuntimeSchema;
90
114
  if (!configDef)
91
115
  return undefined;
92
- return toJsonSchema(applyZodPlugin(configDef, { jsonSchemaExtra: true }));
116
+ return toJsonSchema(registry.getExtendedChannelSchemas(configDef, {
117
+ withJsonSchemaExtrasAsDescription: true,
118
+ }));
93
119
  }
94
120
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/graph/zod/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,IAAI,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAEvE,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAcjE,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACtD,IACE,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC;QACrB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,KAAK,CAAC,OAAO,IAAI,IAAI,EACrB,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,YAAY,CAAC,MAAiB;IACrC,OAAO,yBAAyB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAe,CAAC;AAC3E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACjD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,wBAAwB,CAAC;IACzD,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IACjC,OAAO,YAAY,CAAC,cAAc,CAAC,SAAS,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,C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K,CAAC;QAAE,OAAO,SAAS,CAAC;IACjD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC;IACrD,IAAI,CAAC,SAAS;QAAE,OAAO,SAAS,CAAC;IAEjC,OAAO,YAAY,CACjB,QAAQ,CAAC,yBAAyB,CAAC,SAAS,EAAE;QAC5C,iCAAiC,EAAE,IAAI;KACxC,CAAC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registry = exports.LanggraphZodMetaRegistry = void 0;
4
+ const types_1 = require("@langchain/core/utils/types");
5
+ const core_1 = require("zod/v4/core");
6
+ const meta_js_1 = require("./meta.cjs");
7
+ /**
8
+ * A Zod v4-compatible meta registry that extends the base registry.
9
+ *
10
+ * This registry allows you to associate and retrieve metadata for Zod schemas,
11
+ * leveraging the base registry for storage. It is compatible with Zod v4 and
12
+ * interoperates with the base registry to ensure consistent metadata management
13
+ * across different Zod versions.
14
+ *
15
+ * @template Meta - The type of metadata associated with each schema.
16
+ * @template Schema - The Zod schema type.
17
+ */
18
+ class LanggraphZodMetaRegistry extends core_1.$ZodRegistry {
19
+ /**
20
+ * Creates a new LanggraphZodMetaRegistry instance.
21
+ *
22
+ * @param parent - The base SchemaMetaRegistry to use for metadata storage.
23
+ */
24
+ constructor(parent) {
25
+ super();
26
+ Object.defineProperty(this, "parent", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: parent
31
+ });
32
+ // Use the parent's map for metadata storage
33
+ this._map = this.parent._map;
34
+ }
35
+ add(schema, ..._meta) {
36
+ const firstMeta = _meta[0];
37
+ if (firstMeta && !firstMeta?.default) {
38
+ const defaultValueGetter = (0, types_1.getInteropZodDefaultGetter)(schema);
39
+ if (defaultValueGetter != null) {
40
+ // eslint-disable-next-line no-param-reassign
41
+ firstMeta.default = defaultValueGetter;
42
+ }
43
+ }
44
+ return super.add(schema, ..._meta);
45
+ }
46
+ }
47
+ exports.LanggraphZodMetaRegistry = LanggraphZodMetaRegistry;
48
+ exports.registry = new LanggraphZodMetaRegistry(meta_js_1.schemaMetaRegistry);
49
+ //# sourceMappingURL=zod-registry.js.map
@@ -0,0 +1,24 @@
1
+ import { $ZodType, $ZodRegistry, $replace } from "zod/v4/core";
2
+ import { SchemaMeta, SchemaMetaRegistry } from "./meta.js";
3
+ /**
4
+ * A Zod v4-compatible meta registry that extends the base registry.
5
+ *
6
+ * This registry allows you to associate and retrieve metadata for Zod schemas,
7
+ * leveraging the base registry for storage. It is compatible with Zod v4 and
8
+ * interoperates with the base registry to ensure consistent metadata management
9
+ * across different Zod versions.
10
+ *
11
+ * @template Meta - The type of metadata associated with each schema.
12
+ * @template Schema - The Zod schema type.
13
+ */
14
+ export declare class LanggraphZodMetaRegistry<Meta extends SchemaMeta = SchemaMeta, Schema extends $ZodType = $ZodType> extends $ZodRegistry<Meta, Schema> {
15
+ protected parent: SchemaMetaRegistry;
16
+ /**
17
+ * Creates a new LanggraphZodMetaRegistry instance.
18
+ *
19
+ * @param parent - The base SchemaMetaRegistry to use for metadata storage.
20
+ */
21
+ constructor(parent: SchemaMetaRegistry);
22
+ add<S extends Schema>(schema: S, ..._meta: undefined extends Meta ? [$replace<Meta, S>?] : [$replace<Meta, S>]): this;
23
+ }
24
+ export declare const registry: LanggraphZodMetaRegistry<SchemaMeta<any, any>, $ZodType<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>;
@@ -0,0 +1,45 @@
1
+ import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
2
+ import { $ZodRegistry } from "zod/v4/core";
3
+ import { schemaMetaRegistry } from "./meta.js";
4
+ /**
5
+ * A Zod v4-compatible meta registry that extends the base registry.
6
+ *
7
+ * This registry allows you to associate and retrieve metadata for Zod schemas,
8
+ * leveraging the base registry for storage. It is compatible with Zod v4 and
9
+ * interoperates with the base registry to ensure consistent metadata management
10
+ * across different Zod versions.
11
+ *
12
+ * @template Meta - The type of metadata associated with each schema.
13
+ * @template Schema - The Zod schema type.
14
+ */
15
+ export class LanggraphZodMetaRegistry extends $ZodRegistry {
16
+ /**
17
+ * Creates a new LanggraphZodMetaRegistry instance.
18
+ *
19
+ * @param parent - The base SchemaMetaRegistry to use for metadata storage.
20
+ */
21
+ constructor(parent) {
22
+ super();
23
+ Object.defineProperty(this, "parent", {
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true,
27
+ value: parent
28
+ });
29
+ // Use the parent's map for metadata storage
30
+ this._map = this.parent._map;
31
+ }
32
+ add(schema, ..._meta) {
33
+ const firstMeta = _meta[0];
34
+ if (firstMeta && !firstMeta?.default) {
35
+ const defaultValueGetter = getInteropZodDefaultGetter(schema);
36
+ if (defaultValueGetter != null) {
37
+ // eslint-disable-next-line no-param-reassign
38
+ firstMeta.default = defaultValueGetter;
39
+ }
40
+ }
41
+ return super.add(schema, ..._meta);
42
+ }
43
+ }
44
+ export const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);
45
+ //# sourceMappingURL=zod-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"zod-registry.js","sourceRoot":"","sources":["../../../src/graph/zod/zod-registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAY,YAAY,EAAY,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAkC,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,OAAO,wBAGX,SAAQ,YAA0B;IAClC;;;;OAIG;IACH,YAAsB,MAA0B;QAC9C,KAAK,EAAE,CAAC;QADE;;;;mBAAU,MAAM;WAAoB;QAE9C,4CAA4C;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAA+C,CAAC;IAC1E,CAAC;IAED,GAAG,CACD,MAAS,EACT,GAAG,KAEoB;QAEvB,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAC3B,IAAI,SAAS,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,CAAC;YACrC,MAAM,kBAAkB,GAAG,0BAA0B,CAAC,MAAM,CAAC,CAAC;YAC9D,IAAI,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC/B,6CAA6C;gBAC7C,SAAS,CAAC,OAAO,GAAG,kBAAkB,CAAC;YACzC,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC;IACrC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,wBAAwB,CAAC,kBAAkB,CAAC,CAAC"}