@langchain/langgraph 1.0.4 → 1.0.6
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.
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/dist/channels/last_value.cjs +6 -1
- package/dist/channels/last_value.cjs.map +1 -1
- package/dist/channels/last_value.d.cts +2 -0
- package/dist/channels/last_value.d.cts.map +1 -1
- package/dist/channels/last_value.d.ts +2 -0
- package/dist/channels/last_value.d.ts.map +1 -1
- package/dist/channels/last_value.js +6 -1
- package/dist/channels/last_value.js.map +1 -1
- package/dist/graph/message.d.cts +2 -2
- package/dist/graph/message.d.cts.map +1 -1
- package/dist/graph/message.d.ts +2 -2
- package/dist/graph/message.d.ts.map +1 -1
- package/dist/graph/messages_annotation.d.cts +5 -5
- package/dist/graph/messages_annotation.d.cts.map +1 -1
- package/dist/graph/messages_annotation.d.ts +5 -5
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/zod/meta.cjs +1 -1
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.js +1 -1
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/zod-registry.d.cts.map +1 -1
- package/dist/graph/zod/zod-registry.d.ts.map +1 -1
- package/dist/prebuilt/agent_executor.d.cts +5 -5
- package/dist/prebuilt/agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/agent_executor.d.ts +5 -5
- package/dist/prebuilt/agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts +3 -3
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +3 -3
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/tool_node.cjs +35 -1
- package/dist/prebuilt/tool_node.cjs.map +1 -1
- package/dist/prebuilt/tool_node.d.cts +35 -1
- package/dist/prebuilt/tool_node.d.cts.map +1 -1
- package/dist/prebuilt/tool_node.d.ts +35 -1
- package/dist/prebuilt/tool_node.d.ts.map +1 -1
- package/dist/prebuilt/tool_node.js +35 -1
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @langchain/langgraph
|
|
2
2
|
|
|
3
|
+
## 1.0.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- de1454a: undeprecate toolsCondition
|
|
8
|
+
- 2340a54: respect meta defaults in `LastValue`
|
|
9
|
+
|
|
10
|
+
## 1.0.5
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [1497df9]
|
|
15
|
+
- @langchain/langgraph-sdk@1.3.0
|
|
16
|
+
|
|
3
17
|
## 1.0.4
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://github.com/langchain-ai/langgraphjs/issues)
|
|
7
7
|
|
|
8
8
|
> [!NOTE]
|
|
9
|
-
> Looking for the Python version? See the [Python repo](https://github.com/langchain-ai/langgraph) and the [Python docs](https://langchain
|
|
9
|
+
> Looking for the Python version? See the [Python repo](https://github.com/langchain-ai/langgraph) and the [Python docs](https://docs.langchain.com/oss/python/langgraph/overview).
|
|
10
10
|
|
|
11
11
|
LangGraph — used by Replit, Uber, LinkedIn, GitLab and more — is a low-level orchestration framework for building controllable agents. While langchain provides integrations and composable components to streamline LLM application development, the LangGraph library enables agent orchestration — offering customizable architectures, long-term memory, and human-in-the-loop to reliably handle complex tasks.
|
|
12
12
|
|
|
@@ -13,8 +13,13 @@ const require_base = require('./base.cjs');
|
|
|
13
13
|
var LastValue = class LastValue extends require_base.BaseChannel {
|
|
14
14
|
lc_graph_name = "LastValue";
|
|
15
15
|
value = [];
|
|
16
|
+
constructor(initialValueFactory) {
|
|
17
|
+
super();
|
|
18
|
+
this.initialValueFactory = initialValueFactory;
|
|
19
|
+
if (initialValueFactory) this.value = [initialValueFactory()];
|
|
20
|
+
}
|
|
16
21
|
fromCheckpoint(checkpoint) {
|
|
17
|
-
const empty = new LastValue();
|
|
22
|
+
const empty = new LastValue(this.initialValueFactory);
|
|
18
23
|
if (typeof checkpoint !== "undefined") empty.value = [checkpoint];
|
|
19
24
|
return empty;
|
|
20
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.cjs","names":["BaseChannel","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyBA,yBAAiC;CACrE,gBAAgB;CAGhB,QAAsB;CAEtB,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"file":"last_value.cjs","names":["BaseChannel","initialValueFactory?: () => Value","InvalidUpdateError","EmptyChannelError"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyBA,yBAAiC;CACrE,gBAAgB;CAGhB,QAAsB;CAEtB,YAAY,AAAUC,qBAAmC;AACvD;EADoB;AAEpB,MAAI,oBACF,MAAK,QAAQ,CAAC;;CAIlB,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB,KAAK;AACxC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC;AAGjB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAET,MAAI,OAAO,WAAW,EACpB,OAAM,IAAIC,kCACR,kDACA,EAAE,eAAe;AAKrB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIC;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAIA;AAEZ,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW;;;;;;;AAQjC,IAAa,uBAAb,MAAa,6BAAoCH,yBAI/C;CACA,gBAAgB;CAGhB,QAAsB;CAEtB,WAAoB;CAEpB,eAAe,YAA+B;EAC5C,MAAM,QAAQ,IAAI;AAClB,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,OAAO,YAAY;AAC1B,SAAM,QAAQ,CAAC;AACf,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,WAAW;AAEhB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,KAAK,CAAC,KAAK,SACnC,OAAM,IAAIG;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAA2C;AACzC,MAAI,KAAK,MAAM,WAAW,EAAG,QAAO;AACpC,SAAO,CAAC,KAAK,MAAM,IAAI,KAAK;;CAG9B,UAAmB;AACjB,MAAI,KAAK,UAAU;AACjB,QAAK,WAAW;AAChB,QAAK,QAAQ;AACb,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,KAAK,MAAM,SAAS,GAAG;AAC3C,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW,KAAK,KAAK"}
|
|
@@ -11,9 +11,11 @@ import { BaseChannel } from "./base.cjs";
|
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {
|
|
14
|
+
protected initialValueFactory?: (() => Value) | undefined;
|
|
14
15
|
lc_graph_name: string;
|
|
15
16
|
// value is an array so we don't misinterpret an update to undefined as no write
|
|
16
17
|
value: [Value] | [];
|
|
18
|
+
constructor(initialValueFactory?: (() => Value) | undefined);
|
|
17
19
|
fromCheckpoint(checkpoint?: Value): this;
|
|
18
20
|
update(values: Value[]): boolean;
|
|
19
21
|
get(): Value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.d.cts","names":["BaseChannel","LastValue","Value","LastValueAfterFinish"],"sources":["../../src/channels/last_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport declare class LastValueAfterFinish<Value> extends BaseChannel<Value, Value, [\n Value,\n boolean\n]> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n finished: boolean;\n fromCheckpoint(checkpoint?: [Value, boolean]): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): [Value, boolean] | undefined;\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AASA;;;;;;
|
|
1
|
+
{"version":3,"file":"last_value.d.cts","names":["BaseChannel","LastValue","Value","LastValueAfterFinish"],"sources":["../../src/channels/last_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n protected initialValueFactory?: (() => Value) | undefined;\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n constructor(initialValueFactory?: (() => Value) | undefined);\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport declare class LastValueAfterFinish<Value> extends BaseChannel<Value, Value, [\n Value,\n boolean\n]> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n finished: boolean;\n fromCheckpoint(checkpoint?: [Value, boolean]): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): [Value, boolean] | undefined;\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AASA;;;;;;AAIYE,cAJSD,SAITC,CAAAA,KAAAA,CAAAA,SAJkCF,WAIlCE,CAJ8CA,KAI9CA,EAJqDA,KAIrDA,EAJ4DA,KAI5DA,CAAAA,CAAAA;YACiCA,mBAAAA,CAAAA,EAAAA,CAAAA,GAAAA,GAJFA,KAIEA,CAAAA,GAAAA,SAAAA;eACbA,EAAAA,MAAAA;;OAErBA,EAAAA,CAJCA,KAIDA,CAAAA,GAAAA,EAAAA;aACOA,CAAAA,mBAAAA,CAAAA,EAAAA,CAAAA,GAAAA,GAJ2BA,KAI3BA,CAAAA,GAAAA,SAAAA;gBAT4BF,CAAAA,UAAAA,CAAAA,EAMdE,KANcF,CAAAA,EAAAA,IAAAA;iBAO3BE;EASEC,GAAAA,CAAAA,CAAAA,EARVD,KAQUC;EAAoB,UAAA,CAAA,CAAA,EAPvBD,KAOuB;aAA4BA,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;AAU1DA,cAVUC,oBAUVD,CAAAA,KAAAA,CAAAA,SAV8CF,WAU9CE,CAV0DA,KAU1DA,EAViEA,KAUjEA,EAAAA,CATPA,KAUeA,SAXsCF;;;UAM7CE;;+BAEqBA;iBACdA;SACRA;iBACQA"}
|
|
@@ -11,9 +11,11 @@ import { BaseChannel } from "./base.js";
|
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
13
|
declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {
|
|
14
|
+
protected initialValueFactory?: (() => Value) | undefined;
|
|
14
15
|
lc_graph_name: string;
|
|
15
16
|
// value is an array so we don't misinterpret an update to undefined as no write
|
|
16
17
|
value: [Value] | [];
|
|
18
|
+
constructor(initialValueFactory?: (() => Value) | undefined);
|
|
17
19
|
fromCheckpoint(checkpoint?: Value): this;
|
|
18
20
|
update(values: Value[]): boolean;
|
|
19
21
|
get(): Value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.d.ts","names":["BaseChannel","LastValue","Value","LastValueAfterFinish"],"sources":["../../src/channels/last_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport declare class LastValueAfterFinish<Value> extends BaseChannel<Value, Value, [\n Value,\n boolean\n]> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n finished: boolean;\n fromCheckpoint(checkpoint?: [Value, boolean]): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): [Value, boolean] | undefined;\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AASA;;;;;;
|
|
1
|
+
{"version":3,"file":"last_value.d.ts","names":["BaseChannel","LastValue","Value","LastValueAfterFinish"],"sources":["../../src/channels/last_value.d.ts"],"sourcesContent":["import { BaseChannel } from \"./base.js\";\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport declare class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n protected initialValueFactory?: (() => Value) | undefined;\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n constructor(initialValueFactory?: (() => Value) | undefined);\n fromCheckpoint(checkpoint?: Value): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): Value;\n isAvailable(): boolean;\n}\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport declare class LastValueAfterFinish<Value> extends BaseChannel<Value, Value, [\n Value,\n boolean\n]> {\n lc_graph_name: string;\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [];\n finished: boolean;\n fromCheckpoint(checkpoint?: [Value, boolean]): this;\n update(values: Value[]): boolean;\n get(): Value;\n checkpoint(): [Value, boolean] | undefined;\n consume(): boolean;\n finish(): boolean;\n isAvailable(): boolean;\n}\n"],"mappings":";;;;;;AASA;;;;;;AAIYE,cAJSD,SAITC,CAAAA,KAAAA,CAAAA,SAJkCF,WAIlCE,CAJ8CA,KAI9CA,EAJqDA,KAIrDA,EAJ4DA,KAI5DA,CAAAA,CAAAA;YACiCA,mBAAAA,CAAAA,EAAAA,CAAAA,GAAAA,GAJFA,KAIEA,CAAAA,GAAAA,SAAAA;eACbA,EAAAA,MAAAA;;OAErBA,EAAAA,CAJCA,KAIDA,CAAAA,GAAAA,EAAAA;aACOA,CAAAA,mBAAAA,CAAAA,EAAAA,CAAAA,GAAAA,GAJ2BA,KAI3BA,CAAAA,GAAAA,SAAAA;gBAT4BF,CAAAA,UAAAA,CAAAA,EAMdE,KANcF,CAAAA,EAAAA,IAAAA;iBAO3BE;EASEC,GAAAA,CAAAA,CAAAA,EARVD,KAQUC;EAAoB,UAAA,CAAA,CAAA,EAPvBD,KAOuB;aAA4BA,CAAAA,CAAAA,EAAAA,OAAAA;;;;;;AAU1DA,cAVUC,oBAUVD,CAAAA,KAAAA,CAAAA,SAV8CF,WAU9CE,CAV0DA,KAU1DA,EAViEA,KAUjEA,EAAAA,CATPA,KAUeA,SAXsCF;;;UAM7CE;;+BAEqBA;iBACdA;SACRA;iBACQA"}
|
|
@@ -13,8 +13,13 @@ import { BaseChannel } from "./base.js";
|
|
|
13
13
|
var LastValue = class LastValue extends BaseChannel {
|
|
14
14
|
lc_graph_name = "LastValue";
|
|
15
15
|
value = [];
|
|
16
|
+
constructor(initialValueFactory) {
|
|
17
|
+
super();
|
|
18
|
+
this.initialValueFactory = initialValueFactory;
|
|
19
|
+
if (initialValueFactory) this.value = [initialValueFactory()];
|
|
20
|
+
}
|
|
16
21
|
fromCheckpoint(checkpoint) {
|
|
17
|
-
const empty = new LastValue();
|
|
22
|
+
const empty = new LastValue(this.initialValueFactory);
|
|
18
23
|
if (typeof checkpoint !== "undefined") empty.value = [checkpoint];
|
|
19
24
|
return empty;
|
|
20
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last_value.js","names":[],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>();\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyB,YAAiC;CACrE,gBAAgB;CAGhB,QAAsB;CAEtB,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"file":"last_value.js","names":["initialValueFactory?: () => Value"],"sources":["../../src/channels/last_value.ts"],"sourcesContent":["import { EmptyChannelError, InvalidUpdateError } from \"../errors.js\";\nimport { BaseChannel } from \"./base.js\";\n\n/**\n * Stores the last value received, can receive at most one value per step.\n *\n * Since `update` is only called once per step and value can only be of length 1,\n * LastValue always stores the last value of a single node. If multiple nodes attempt to\n * write to this channel in a single step, an error will be thrown.\n * @internal\n */\nexport class LastValue<Value> extends BaseChannel<Value, Value, Value> {\n lc_graph_name = \"LastValue\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n constructor(protected initialValueFactory?: () => Value) {\n super();\n if (initialValueFactory) {\n this.value = [initialValueFactory()];\n }\n }\n\n fromCheckpoint(checkpoint?: Value) {\n const empty = new LastValue<Value>(this.initialValueFactory);\n if (typeof checkpoint !== \"undefined\") {\n empty.value = [checkpoint];\n }\n\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n if (values.length !== 1) {\n throw new InvalidUpdateError(\n \"LastValue can only receive one value per step.\",\n { lc_error_code: \"INVALID_CONCURRENT_GRAPH_UPDATE\" }\n );\n }\n\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): Value {\n if (this.value.length === 0) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0;\n }\n}\n\n/**\n * Stores the last value received, but only made available after finish().\n * Once made available, clears the value.\n */\nexport class LastValueAfterFinish<Value> extends BaseChannel<\n Value,\n Value,\n [Value, boolean]\n> {\n lc_graph_name = \"LastValueAfterFinish\";\n\n // value is an array so we don't misinterpret an update to undefined as no write\n value: [Value] | [] = [];\n\n finished: boolean = false;\n\n fromCheckpoint(checkpoint?: [Value, boolean]) {\n const empty = new LastValueAfterFinish<Value>();\n if (typeof checkpoint !== \"undefined\") {\n const [value, finished] = checkpoint;\n empty.value = [value];\n empty.finished = finished;\n }\n return empty as this;\n }\n\n update(values: Value[]): boolean {\n if (values.length === 0) {\n return false;\n }\n\n this.finished = false;\n // eslint-disable-next-line prefer-destructuring\n this.value = [values[values.length - 1]];\n return true;\n }\n\n get(): Value {\n if (this.value.length === 0 || !this.finished) {\n throw new EmptyChannelError();\n }\n return this.value[0];\n }\n\n checkpoint(): [Value, boolean] | undefined {\n if (this.value.length === 0) return undefined;\n return [this.value[0], this.finished];\n }\n\n consume(): boolean {\n if (this.finished) {\n this.finished = false;\n this.value = [];\n return true;\n }\n return false;\n }\n\n finish(): boolean {\n if (!this.finished && this.value.length > 0) {\n this.finished = true;\n return true;\n }\n return false;\n }\n\n isAvailable(): boolean {\n return this.value.length !== 0 && this.finished;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,YAAb,MAAa,kBAAyB,YAAiC;CACrE,gBAAgB;CAGhB,QAAsB;CAEtB,YAAY,AAAUA,qBAAmC;AACvD;EADoB;AAEpB,MAAI,oBACF,MAAK,QAAQ,CAAC;;CAIlB,eAAe,YAAoB;EACjC,MAAM,QAAQ,IAAI,UAAiB,KAAK;AACxC,MAAI,OAAO,eAAe,YACxB,OAAM,QAAQ,CAAC;AAGjB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAET,MAAI,OAAO,WAAW,EACpB,OAAM,IAAI,mBACR,kDACA,EAAE,eAAe;AAKrB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAAoB;AAClB,MAAI,KAAK,MAAM,WAAW,EACxB,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW;;;;;;;AAQjC,IAAa,uBAAb,MAAa,6BAAoC,YAI/C;CACA,gBAAgB;CAGhB,QAAsB;CAEtB,WAAoB;CAEpB,eAAe,YAA+B;EAC5C,MAAM,QAAQ,IAAI;AAClB,MAAI,OAAO,eAAe,aAAa;GACrC,MAAM,CAAC,OAAO,YAAY;AAC1B,SAAM,QAAQ,CAAC;AACf,SAAM,WAAW;;AAEnB,SAAO;;CAGT,OAAO,QAA0B;AAC/B,MAAI,OAAO,WAAW,EACpB,QAAO;AAGT,OAAK,WAAW;AAEhB,OAAK,QAAQ,CAAC,OAAO,OAAO,SAAS;AACrC,SAAO;;CAGT,MAAa;AACX,MAAI,KAAK,MAAM,WAAW,KAAK,CAAC,KAAK,SACnC,OAAM,IAAI;AAEZ,SAAO,KAAK,MAAM;;CAGpB,aAA2C;AACzC,MAAI,KAAK,MAAM,WAAW,EAAG,QAAO;AACpC,SAAO,CAAC,KAAK,MAAM,IAAI,KAAK;;CAG9B,UAAmB;AACjB,MAAI,KAAK,UAAU;AACjB,QAAK,WAAW;AAChB,QAAK,QAAQ;AACb,UAAO;;AAET,SAAO;;CAGT,SAAkB;AAChB,MAAI,CAAC,KAAK,YAAY,KAAK,MAAM,SAAS,GAAG;AAC3C,QAAK,WAAW;AAChB,UAAO;;AAET,SAAO;;CAGT,cAAuB;AACrB,SAAO,KAAK,MAAM,WAAW,KAAK,KAAK"}
|
package/dist/graph/message.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateGraph } from "./state.cjs";
|
|
2
2
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _langchain_core_messages27 from "@langchain/core/messages";
|
|
4
4
|
import { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
|
|
5
5
|
|
|
6
6
|
//#region src/graph/message.d.ts
|
|
@@ -34,7 +34,7 @@ declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: R
|
|
|
34
34
|
* @default "messages"
|
|
35
35
|
*/
|
|
36
36
|
stateKey?: string | null;
|
|
37
|
-
}): BaseMessage<
|
|
37
|
+
}): BaseMessage<_langchain_core_messages27.MessageStructure, _langchain_core_messages27.MessageType>;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { MessageGraph, Messages, REMOVE_ALL_MESSAGES, messagesStateReducer, pushMessage };
|
|
40
40
|
//# sourceMappingURL=message.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.cts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","
|
|
1
|
+
{"version":3,"file":"message.d.cts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","_langchain_core_messages27","MessageStructure","MessageType"],"sources":["../../src/graph/message.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { StateGraph } from \"./state.js\";\nexport declare const REMOVE_ALL_MESSAGES = \"__remove_all__\";\nexport type Messages = Array<BaseMessage | BaseMessageLike> | BaseMessage | BaseMessageLike;\n/**\n * Prebuilt reducer that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n */\nexport declare function messagesStateReducer(left: Messages, right: Messages): BaseMessage[];\n/** @ignore */\nexport declare class MessageGraph extends StateGraph<BaseMessage[], BaseMessage[], Messages> {\n constructor();\n}\n/**\n * Manually push a message to a message stream.\n *\n * This is useful when you need to push a manually created message before the node\n * has finished executing.\n *\n * When a message is pushed, it will be automatically persisted to the state after the node has finished executing.\n * To disable persisting, set `options.stateKey` to `null`.\n *\n * @param message The message to push. The message must have an ID set, otherwise an error will be thrown.\n * @param options RunnableConfig / Runtime coming from node context.\n */\nexport declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: RunnableConfig & {\n /**\n * The key of the state to push the message to. Set to `null` to avoid persisting.\n * @default \"messages\"\n */\n stateKey?: string | null;\n}): BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>;\n"],"mappings":";;;;;;cAGqBI,mBAAAA;KACTC,QAAAA,GAAWC,MAAMN,cAAcC,mBAAmBD,cAAcC;;AAD5E;AACA;;;AAA2CA,iBAMnBM,oBAAAA,CANmBN,IAAAA,EAMQI,QANRJ,EAAAA,KAAAA,EAMyBI,QANzBJ,CAAAA,EAMoCD,WANpCC,EAAAA;;AAAmBD,cAQzCQ,YAAAA,SAAqBL,UARoBH,CAQTA,WARSA,EAAAA,EAQMA,WARNA,EAAAA,EAQqBK,QARrBL,CAAAA,CAAAA;aAAcC,CAAAA;;AAM5E;;;;;;AAEA;;;;;;iBAewBQ,WAAAA,UAAqBT,cAAcC,2BAA2BC;EAA9DO;;;;UAA8DP,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;IAMlFF,WANgGU,CAAAA,0BAAAA,CAMjDC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,CAArDD"}
|
package/dist/graph/message.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateGraph } from "./state.js";
|
|
2
2
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
4
4
|
import { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
|
|
5
5
|
|
|
6
6
|
//#region src/graph/message.d.ts
|
|
@@ -34,7 +34,7 @@ declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: R
|
|
|
34
34
|
* @default "messages"
|
|
35
35
|
*/
|
|
36
36
|
stateKey?: string | null;
|
|
37
|
-
}): BaseMessage<
|
|
37
|
+
}): BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { MessageGraph, Messages, REMOVE_ALL_MESSAGES, messagesStateReducer, pushMessage };
|
|
40
40
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","_langchain_core_messages0","MessageStructure","MessageType"],"sources":["../../src/graph/message.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { StateGraph } from \"./state.js\";\nexport declare const REMOVE_ALL_MESSAGES = \"__remove_all__\";\nexport type Messages = Array<BaseMessage | BaseMessageLike> | BaseMessage | BaseMessageLike;\n/**\n * Prebuilt reducer that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n */\nexport declare function messagesStateReducer(left: Messages, right: Messages): BaseMessage[];\n/** @ignore */\nexport declare class MessageGraph extends StateGraph<BaseMessage[], BaseMessage[], Messages> {\n constructor();\n}\n/**\n * Manually push a message to a message stream.\n *\n * This is useful when you need to push a manually created message before the node\n * has finished executing.\n *\n * When a message is pushed, it will be automatically persisted to the state after the node has finished executing.\n * To disable persisting, set `options.stateKey` to `null`.\n *\n * @param message The message to push. The message must have an ID set, otherwise an error will be thrown.\n * @param options RunnableConfig / Runtime coming from node context.\n */\nexport declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: RunnableConfig & {\n /**\n * The key of the state to push the message to. Set to `null` to avoid persisting.\n * @default \"messages\"\n */\n stateKey?: string | null;\n}): BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>;\n"],"mappings":";;;;;;cAGqBI,mBAAAA;KACTC,QAAAA,GAAWC,MAAMN,cAAcC,mBAAmBD,cAAcC;;AAD5E;AACA;;;AAA2CA,iBAMnBM,oBAAAA,CANmBN,IAAAA,EAMQI,QANRJ,EAAAA,KAAAA,EAMyBI,QANzBJ,CAAAA,EAMoCD,WANpCC,EAAAA;;AAAmBD,cAQzCQ,YAAAA,SAAqBL,UARoBH,CAQTA,WARSA,EAAAA,EAQMA,WARNA,EAAAA,EAQqBK,QARrBL,CAAAA,CAAAA;aAAcC,CAAAA;;AAM5E;;;;;;AAEA;;;;;;iBAewBQ,WAAAA,UAAqBT,cAAcC,2BAA2BC;EAA9DO;;;;UAA8DP,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;IAMlFF,WANgGU,CAAAA,yBAAAA,CAMjDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CAArDD"}
|
|
@@ -3,7 +3,7 @@ import { ReducedZodChannel, SchemaMeta } from "./zod/meta.cjs";
|
|
|
3
3
|
import { AnnotationRoot } from "./annotation.cjs";
|
|
4
4
|
import { Messages } from "./message.cjs";
|
|
5
5
|
import * as _langchain_core_utils_types0 from "@langchain/core/utils/types";
|
|
6
|
-
import * as
|
|
6
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
7
7
|
import { BaseMessage } from "@langchain/core/messages";
|
|
8
8
|
import { z } from "zod/v3";
|
|
9
9
|
|
|
@@ -45,7 +45,7 @@ import { z } from "zod/v3";
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
48
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[], Messages>;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
51
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -101,11 +101,11 @@ declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
declare const MessagesZodState: z.ZodObject<{
|
|
104
|
-
messages: ReducedZodChannel<z.ZodType<BaseMessage<
|
|
104
|
+
messages: ReducedZodChannel<z.ZodType<BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[]>, _langchain_core_utils_types0.InteropZodType<Messages>>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
messages: BaseMessage<
|
|
106
|
+
messages: BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>[];
|
|
109
109
|
}>;
|
|
110
110
|
//#endregion
|
|
111
111
|
export { MessagesAnnotation, MessagesZodMeta, MessagesZodState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.cts","names":["
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.cts","names":["___web_js0","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","_langchain_core_messages0","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./message.js\";\nimport { SchemaMeta } from \"./zod/meta.js\";\n/**\n * Prebuilt state annotation that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n *\n * Specifically, importing and using the prebuilt MessagesAnnotation like this:\n *\n * @example\n * ```ts\n * import { MessagesAnnotation, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(...)\n * ...\n * ```\n *\n * Is equivalent to initializing your state manually like this:\n *\n * @example\n * ```ts\n * import { BaseMessage } from \"@langchain/core/messages\";\n * import { Annotation, StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n *\n * export const StateAnnotation = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * reducer: messagesStateReducer,\n * default: () => [],\n * }),\n * });\n *\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesAnnotation: import(\"./annotation.js\").AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n/**\n * Prebuilt schema meta for Zod state definition.\n *\n * @example\n * ```ts\n * import { z } from \"zod/v4-mini\";\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const AgentState = z.object({\n * messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),\n * });\n * ```\n */\nexport declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;\n/**\n * Prebuilt state object that uses Zod to combine returned messages.\n * This utility is synonymous with the `MessagesAnnotation` annotation,\n * but uses Zod as the way to express messages state.\n *\n * You can use import and use this prebuilt schema like this:\n *\n * @example\n * ```ts\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesZodState)\n * .addNode(...)\n * ...\n * ```\n *\n * Which is equivalent to initializing the schema object manually like this:\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import type { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\n * import { StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n * import \"@langchain/langgraph/zod\";\n *\n * const AgentState = z.object({\n * messages: z\n * .custom<BaseMessage[]>()\n * .default(() => [])\n * .langgraph.reducer(\n * messagesStateReducer,\n * z.custom<BaseMessageLike | BaseMessageLike[]>()\n * ),\n * });\n * const graph = new StateGraph(AgentState)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesZodState: z.ZodObject<{\n messages: import(\"./zod/meta.js\").ReducedZodChannel<z.ZodType<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>, import(\"@langchain/core/utils/types\").InteropZodType<Messages>>;\n}, \"strip\", z.ZodTypeAny, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;;;AAG6ES,cA3DxDD,kBA2D6FG,gBAAAA,CAAAA;UAApGP,yBAAAA,CA1D4CA,WA0D5CA,CAzDZK,yBAAAA,CADuGC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CA0DhJP,EAAAA,EA1DgKE,QA0DhKF,CAAAA;;;;;;;;;;;;;;;cA3COU,iBAAiBP,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CS,kBAAkBV,CAAAA,CAAEgB;8BACehB,CAAAA,CAAEY,QAAQb,YAKhEK,yBAAAA,CAL+GC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,KAAgBN,CAAAA,CAAEW,YAAYZ,YAAFK,yBAAAA,CAAiDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,MAA8ET,4BAAAA,CAAvBgB,eAAeZ;YAClWD,CAAAA,CAAEe;YACAhB,YADUK,yBAAAA,CACqCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA;;YAEpGP,YAFWK,yBAAAA,CAEoCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA"}
|
|
@@ -2,7 +2,7 @@ import { BinaryOperatorAggregate } from "../channels/binop.js";
|
|
|
2
2
|
import { ReducedZodChannel, SchemaMeta } from "./zod/meta.js";
|
|
3
3
|
import { AnnotationRoot } from "./annotation.js";
|
|
4
4
|
import { Messages } from "./message.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as _langchain_core_messages1 from "@langchain/core/messages";
|
|
6
6
|
import { BaseMessage } from "@langchain/core/messages";
|
|
7
7
|
import * as _langchain_core_utils_types0 from "@langchain/core/utils/types";
|
|
8
8
|
import { z } from "zod/v3";
|
|
@@ -45,7 +45,7 @@ import { z } from "zod/v3";
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
48
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[], Messages>;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
51
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -101,11 +101,11 @@ declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
declare const MessagesZodState: z.ZodObject<{
|
|
104
|
-
messages: ReducedZodChannel<z.ZodType<BaseMessage<
|
|
104
|
+
messages: ReducedZodChannel<z.ZodType<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[]>, _langchain_core_utils_types0.InteropZodType<Messages>>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
messages: BaseMessage<
|
|
106
|
+
messages: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[];
|
|
109
109
|
}>;
|
|
110
110
|
//#endregion
|
|
111
111
|
export { MessagesAnnotation, MessagesZodMeta, MessagesZodState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.ts","names":["___web_js0","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.ts","names":["___web_js0","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","_langchain_core_messages1","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./message.js\";\nimport { SchemaMeta } from \"./zod/meta.js\";\n/**\n * Prebuilt state annotation that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n *\n * Specifically, importing and using the prebuilt MessagesAnnotation like this:\n *\n * @example\n * ```ts\n * import { MessagesAnnotation, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(...)\n * ...\n * ```\n *\n * Is equivalent to initializing your state manually like this:\n *\n * @example\n * ```ts\n * import { BaseMessage } from \"@langchain/core/messages\";\n * import { Annotation, StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n *\n * export const StateAnnotation = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * reducer: messagesStateReducer,\n * default: () => [],\n * }),\n * });\n *\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesAnnotation: import(\"./annotation.js\").AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n/**\n * Prebuilt schema meta for Zod state definition.\n *\n * @example\n * ```ts\n * import { z } from \"zod/v4-mini\";\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const AgentState = z.object({\n * messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),\n * });\n * ```\n */\nexport declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;\n/**\n * Prebuilt state object that uses Zod to combine returned messages.\n * This utility is synonymous with the `MessagesAnnotation` annotation,\n * but uses Zod as the way to express messages state.\n *\n * You can use import and use this prebuilt schema like this:\n *\n * @example\n * ```ts\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesZodState)\n * .addNode(...)\n * ...\n * ```\n *\n * Which is equivalent to initializing the schema object manually like this:\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import type { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\n * import { StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n * import \"@langchain/langgraph/zod\";\n *\n * const AgentState = z.object({\n * messages: z\n * .custom<BaseMessage[]>()\n * .default(() => [])\n * .langgraph.reducer(\n * messagesStateReducer,\n * z.custom<BaseMessageLike | BaseMessageLike[]>()\n * ),\n * });\n * const graph = new StateGraph(AgentState)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesZodState: z.ZodObject<{\n messages: import(\"./zod/meta.js\").ReducedZodChannel<z.ZodType<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>, import(\"@langchain/core/utils/types\").InteropZodType<Messages>>;\n}, \"strip\", z.ZodTypeAny, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;;;AAG6ES,cA3DxDD,kBA2D6FG,gBAAAA,CAAAA;UAApGP,yBAAAA,CA1D4CA,WA0D5CA,CAzDZK,yBAAAA,CADuGC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CA0DhJP,EAAAA,EA1DgKE,QA0DhKF,CAAAA;;;;;;;;;;;;;;;cA3COU,iBAAiBP,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CS,kBAAkBV,CAAAA,CAAEgB;8BACehB,CAAAA,CAAEY,QAAQb,YAKhEK,yBAAAA,CAL+GC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,KAAgBN,CAAAA,CAAEW,YAAYZ,YAAFK,yBAAAA,CAAiDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,MAA8ET,4BAAAA,CAAvBgB,eAAeZ;YAClWD,CAAAA,CAAEe;YACAhB,YADUK,yBAAAA,CACqCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA;;YAEpGP,YAFWK,yBAAAA,CAEoCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA"}
|
package/dist/graph/zod/meta.cjs
CHANGED
|
@@ -74,7 +74,7 @@ var SchemaMetaRegistry = class {
|
|
|
74
74
|
for (const [key, channelSchema] of Object.entries(shape)) {
|
|
75
75
|
const meta = this.get(channelSchema);
|
|
76
76
|
if (meta?.reducer) channels[key] = new require_binop.BinaryOperatorAggregate(meta.reducer.fn, meta.default);
|
|
77
|
-
else channels[key] = new require_last_value.LastValue();
|
|
77
|
+
else channels[key] = new require_last_value.LastValue(meta?.default);
|
|
78
78
|
}
|
|
79
79
|
return channels;
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue","modifiedSchema: InteropZodObject","schema"],"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 WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<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();\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 WeakMap();\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;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB;AAC/C,OAAK,KAAK,IAAI,QAAQ,UAAU;;;;;;;CAQlC,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO;AACjB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;;;;CAavB,qBACE,QACgC;EAChC,MAAM,WAAW;EACjB,MAAM,mEAAiC;AACvC,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;GACxD,MAAM,OAAO,KAAK,IAAI;AACtB,OAAI,MAAM,QACR,UAAS,OAAO,IAAIA,sCAElB,KAAK,QAAQ,IAAI,KAAK;OAExB,UAAS,OAAO,IAAIC;;AAGxB,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,SAAS,WAAW,EAClC,QAAO;EAIT,MAAM,WAAW,OAAO,QAAQ,SAC7B,QAAQ,GAAG,OAAO,MAAM,MACxB,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,IACnC,KAAK,CAAC,GAAG,OAAO,GAAG,EAAE,GAAG,KACxB,KAAK;EAER,MAAM,QAAQ,KAAK,gBAAgB,IAAI,6BAAa,IAAI;AACxD,MAAI,MAAM,IAAI,QAAS,QAAO,MAAM,IAAI;EAExC,IAAIC,iBAAmC;AAEvC,MACE,QAAQ,qBACR,QAAQ,mCACR;GACA,MAAM,kBAAkB,OAAO,mEACJ,SACzB,KAAK,CAAC,KAAKC,cAAY;IACvB,MAAM,OAAO,KAAK,IAAIA;IACtB,IAAI,eAAe,QAAQ,oBACvB,MAAM,SAAS,UAAUA,WACzBA;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,qEACiB,wEAAsCA;KAC7D,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;;AAEF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC;;AAGxC,WAAO,CAAC,KAAK;;AAEf,6EACE,QACA,OAAO,YAAY;AAErB,uDAAkB,gBAChB,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,4EAAyC;AAG3C,QAAM,IAAI,QAAQ;AAClB,OAAK,gBAAgB,IAAI,UAAU;AACnC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI;AAkBtC,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,kFAAgD;AACtD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue","modifiedSchema: InteropZodObject","schema"],"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 WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<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 WeakMap();\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;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK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AAa,SAC1B,GAAG,iCAAiC;;AAGxC,WAAO,CAAC,KAAK;;AAEf,6EACE,QACA,OAAO,YAAY;AAErB,uDAAkB,gBAChB,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,4EAAyC;AAG3C,QAAM,IAAI,QAAQ;AAClB,OAAK,gBAAgB,IAAI,UAAU;AACnC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI;AAkBtC,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,kFAAgD;AACtD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
|
package/dist/graph/zod/meta.js
CHANGED
|
@@ -73,7 +73,7 @@ var SchemaMetaRegistry = class {
|
|
|
73
73
|
for (const [key, channelSchema] of Object.entries(shape)) {
|
|
74
74
|
const meta = this.get(channelSchema);
|
|
75
75
|
if (meta?.reducer) channels[key] = new BinaryOperatorAggregate(meta.reducer.fn, meta.default);
|
|
76
|
-
else channels[key] = new LastValue();
|
|
76
|
+
else channels[key] = new LastValue(meta?.default);
|
|
77
77
|
}
|
|
78
78
|
return channels;
|
|
79
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","names":["modifiedSchema: InteropZodObject","schema"],"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 WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<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();\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 WeakMap();\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;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA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iC;;AAGxC,WAAO,CAAC,KAAK;;AAEf,oBAAiB,uBACf,QACA,OAAO,YAAY;AAErB,OAAI,cAAc,gBAChB,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,kBAAiB,wBAAwB;AAG3C,QAAM,IAAI,QAAQ;AAClB,OAAK,gBAAgB,IAAI,UAAU;AACnC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI;AAkBtC,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B;AACtD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":["modifiedSchema: InteropZodObject","schema"],"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 WeakMap<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schfemas.\n * @internal\n */\n _extensionCache = new Map<string, WeakMap<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 WeakMap();\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;;;;;CAMX,kCAAkB,IAAI;;;;;;;;CAStB,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;CAUvB,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB;AAC/C,OAAK,KAAK,IAAI,QAAQ,UAAU;;;;;;;CAQlC,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO;AACjB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI;;;;;;;;;;;;CAavB,qBACE,QACgC;EAChC,MAAM,WAAW;EACjB,MAAM,QAAQ,yBAAyB;AACvC,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,QAAQ;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,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B;AACtD,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU;AAE7C,qBAAmB,OAAO,yBAAyB;AACnD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc;AACxC,SAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.d.cts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","
|
|
1
|
+
{"version":3,"file":"zod-registry.d.cts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","_1","Output","Input","$ZodTypeInternals","Internals","output","input","TOutput","TInput","R","TInternals","ZodType","sideEffect","_2","ZodMiniType","registry"],"sources":["../../../src/graph/zod/zod-registry.d.ts"],"sourcesContent":["import type * as core from \"zod/v4/core\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport { type ReducedZodChannel, type SchemaMeta, type SchemaMetaRegistry } from \"./meta.js\";\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport declare class LanggraphZodMetaRegistry<Meta extends SchemaMeta = SchemaMeta, Schema extends $ZodType = $ZodType> extends $ZodRegistry<Meta & {\n [key: string]: unknown;\n}, Schema> {\n protected parent: SchemaMetaRegistry;\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(parent: SchemaMetaRegistry);\n add<S extends Schema>(schema: S, ..._meta: undefined extends Meta & {\n [key: string]: unknown;\n } ? [$replace<Meta & {\n [key: string]: unknown;\n }, S>?] : [$replace<Meta & {\n [key: string]: unknown;\n }, S>]): this;\n}\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\ndeclare module \"zod/v4-mini\" {\n interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\nexport declare const registry: LanggraphZodMetaRegistry<SchemaMeta<any, any>, $ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;\n"],"mappings":";;;;;;;;AAcA;;;;;;;;;AASwBM,cATHC,wBASGD,CAAAA,aATmCD,UASnCC,GATgDD,UAShDC,EAAAA,eAT2EL,QAS3EK,GATsFL,QAStFK,CAAAA,SATwGJ,YASxGI,CATqHE,IASrHF,GAAAA;MACNG,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;GARfA,MAQ+BC,CAAAA,CAAAA;YAA+BF,MAAAA,EAP3CF,k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 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.d.ts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","
|
|
1
|
+
{"version":3,"file":"zod-registry.d.ts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","_1","Output","Input","$ZodTypeInternals","Internals","output","input","TOutput","TInput","R","TInternals","ZodType","sideEffect","_2","ZodMiniType","registry"],"sources":["../../../src/graph/zod/zod-registry.d.ts"],"sourcesContent":["import type * as core from \"zod/v4/core\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport { type ReducedZodChannel, type SchemaMeta, type SchemaMetaRegistry } from \"./meta.js\";\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport declare class LanggraphZodMetaRegistry<Meta extends SchemaMeta = SchemaMeta, Schema extends $ZodType = $ZodType> extends $ZodRegistry<Meta & {\n [key: string]: unknown;\n}, Schema> {\n protected parent: SchemaMetaRegistry;\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(parent: SchemaMetaRegistry);\n add<S extends Schema>(schema: S, ..._meta: undefined extends Meta & {\n [key: string]: unknown;\n } ? [$replace<Meta & {\n [key: string]: unknown;\n }, S>?] : [$replace<Meta & {\n [key: string]: unknown;\n }, S>]): this;\n}\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\ndeclare module \"zod/v4-mini\" {\n interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\nexport declare const registry: LanggraphZodMetaRegistry<SchemaMeta<any, any>, $ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;\n"],"mappings":";;;;;;;;AAcA;;;;;;;;;AASwBM,cATHC,wBASGD,CAAAA,aATmCD,UASnCC,GATgDD,UAShDC,EAAAA,eAT2EL,QAS3EK,GATsFL,QAStFK,CAAAA,SATwGJ,YASxGI,CATqHE,IASrHF,GAAAA;MACNG,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;GARfA,MAQ+BC,CAAAA,CAAAA;YAA+BF,MAAAA,EAP3CF,kBAO2CE;;;;;;aAIlDL,CAAAA,MAAAA,EALSG,kBAKTH;KAdiHD,CAAAA,UAU9GO,MAV8GP,CAAAA,CAAAA,MAAAA,EAU9FQ,CAV8FR,EAAAA,GAAAA,KAAAA,EAAAA,SAAAA,SAU/DM,IAV+DN,GAAAA;;EAiB/HS,CAAAA,GAAAA,CALQR,QAKR,CALiBK,IAKjB,GAAA;IAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAA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