@langchain/langgraph 1.1.2 → 1.1.3
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/dist/channels/index.cjs +1 -0
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts.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/index.cjs +1 -0
- package/dist/graph/zod/meta.cjs +3 -3
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.d.cts +3 -3
- package/dist/graph/zod/meta.d.cts.map +1 -1
- package/dist/graph/zod/meta.d.ts +3 -3
- package/dist/graph/zod/meta.d.ts.map +1 -1
- package/dist/graph/zod/meta.js +3 -3
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/schema.cjs +1 -0
- package/dist/graph/zod/schema.cjs.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/index.cjs +1 -0
- package/dist/index.cjs.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/index.cjs +1 -0
- 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/pregel/index.cjs +1 -0
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/remote.cjs +1 -0
- package/dist/state/schema.cjs +2 -2
- package/dist/state/schema.cjs.map +1 -1
- package/dist/state/schema.js +2 -2
- package/dist/state/schema.js.map +1 -1
- package/dist/web.cjs +1 -0
- package/package.json +3 -3
package/dist/channels/index.cjs
CHANGED
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","StateGraphInputError","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport declare class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBK,cAAAA,cAAAA,SAAuBH,aAAAA,CAAT;EAAA,UAAA,EACnBJ,SADmB,EAAA;aACnBA,CAAAA,UAAAA,CAAAA,EACaA,SADbA,EAAAA,EAAAA,MAAAA,CAAAA,EACmCC,wBADnCD;aACaA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAF4B,cAMpCQ,aAAAA,SAAsBD,cAAAA,CANc;EAMpCC,WAAAA,CAAAA,OAAa,EAAA,GAAA,EAAA,MAAA,CAAA,EACKP,wBADL;EAAA,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;;AAASM,cAItBE,aAAAA,SAAsBL,aAAAA,CAJAG;EAAc,OAAA,EAK5CR,OAL4C;EAIpCU,WAAAA,CAAAA,OAAa,EAETV,OAFS;EAAA,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;;AAETA,iBAGDW,eAAAA,CAHCX,CAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IAGkCU,aAHlCV;AAFkBK,iBAMnBO,eAAAA,CANmBP,CAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IAMgBA,aANhBA;AAAa,iBAOhCQ,gBAAAA,CAPgC,CAAA,CAAA,EAAA,OAAA,CAAA,EAAA,CAAA,IAOIL,cAPJ;AAKhCG,cAGHG,eAAAA,SAAwBX,kBAAAA,CAH2B;EAChDS,WAAAA,CAAAA,OAAe,CAAA,EAAA,MAAA,EAAoBP,MAAa,CAAbA,EAGhBH,wBAH6B;EAChDW,WAAAA,iBAAgB,CAAA,
|
|
1
|
+
{"version":3,"file":"errors.d.cts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","StateGraphInputError","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport declare class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBK,cAAAA,cAAAA,SAAuBH,aAAAA,CAAT;EAAA,UAAA,EACnBJ,SADmB,EAAA;aACnBA,CAAAA,UAAAA,CAAAA,EACaA,SADbA,EAAAA,EAAAA,MAAAA,CAAAA,EACmCC,wBADnCD;aACaA,i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AAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAQLD,wBARKC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAOlE;AAA2C,cAItBe,oBAAAA,SAA6Bf,kBAAAA,CAJP;aACAD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAIAA,wBAJAA;aADSC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIpD;;;AAAkDA,cAO7BgB,eAAAA,SAAwBhB,kBAAAA,CAPKA;EAAkB,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAQzBD,wBARyB;EAO/CiB,WAAAA,iBAAe,CAAA,CAAA,EAAA,MAAA;;;;;AAqBpC;;;;;AAeA;;;;;;;;;cAfqBC,oBAAAA,SAA6BjB,kBAAAA;;;;;;yCAMPD;;;;;;;;;cAStBmB"}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","StateGraphInputError","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport declare class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBK,cAAAA,cAAAA,SAAuBH,aAAAA,CAAT;EAAA,UAAA,EACnBJ,SADmB,EAAA;aACnBA,CAAAA,UAAAA,CAAAA,EACaA,SADbA,EAAAA,EAAAA,MAAAA,CAAAA,EACmCC,wBADnCD;aACaA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAF4B,cAMpCQ,aAAAA,SAAsBD,cAAAA,CANc;EAMpCC,WAAAA,CAAAA,OAAa,EAAA,GAAA,EAAA,MAAA,CAAA,EACKP,wBADL;EAAA,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;;AAASM,cAItBE,aAAAA,SAAsBL,aAAAA,CAJAG;EAAc,OAAA,EAK5CR,OAL4C;EAIpCU,WAAAA,CAAAA,OAAa,EAETV,OAFS;EAAA,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;;AAETA,iBAGDW,eAAAA,CAHCX,CAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IAGkCU,aAHlCV;AAFkBK,iBAMnBO,eAAAA,CANmBP,CAAAA,CAAAA,EAAAA,OAAAA,CAAAA,EAAAA,CAAAA,IAMgBA,aANhBA;AAAa,iBAOhCQ,gBAAAA,CAPgC,CAAA,CAAA,EAAA,OAAA,CAAA,EAAA,CAAA,IAOIL,cAPJ;AAKhCG,cAGHG,eAAAA,SAAwBX,kBAAAA,CAH2B;EAChDS,WAAAA,CAAAA,OAAe,CAAA,EAAA,MAAA,EAAoBP,MAAa,CAAbA,EAGhBH,wBAH6B;EAChDW,WAAAA,iBAAgB,CAAA,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","StateGraphInputError","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\nexport type BaseLangGraphErrorFields = {\n lc_error_code?: \"GRAPH_RECURSION_LIMIT\" | \"INVALID_CONCURRENT_GRAPH_UPDATE\" | \"INVALID_GRAPH_NODE_RETURN_VALUE\" | \"MISSING_CHECKPOINTER\" | \"MULTIPLE_SUBGRAPHS\" | \"UNREACHABLE_NODE\";\n};\n/** @category Errors */\nexport declare class BaseLangGraphError extends Error {\n lc_error_code?: string;\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n}\nexport declare class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up(): boolean;\n}\nexport declare class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/** Raised by a node to interrupt execution. */\nexport declare class NodeInterrupt extends GraphInterrupt {\n constructor(message: any, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class ParentCommand extends GraphBubbleUp {\n command: Command;\n constructor(command: Command);\n static get unminifiable_name(): string;\n}\nexport declare function isParentCommand(e?: unknown): e is ParentCommand;\nexport declare function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp;\nexport declare function isGraphInterrupt(e?: unknown): e is GraphInterrupt;\nexport declare class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport declare class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\nexport declare class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport declare class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n static get unminifiable_name(): string;\n}\n/**\n * Error thrown when invalid input is provided to a StateGraph.\n *\n * This typically means that the input to the StateGraph constructor or builder\n * did not match the required types. A valid input should be a\n * StateDefinition, an Annotation.Root, or a Zod schema.\n *\n * @example\n * // Example of incorrect usage:\n * try {\n * new StateGraph({ foo: \"bar\" }); // Not a valid input\n * } catch (err) {\n * if (err instanceof StateGraphInputError) {\n * console.error(err.message);\n * }\n * }\n */\nexport declare class StateGraphInputError extends BaseLangGraphError {\n /**\n * Create a new StateGraphInputError.\n * @param message - Optional custom error message.\n * @param fields - Optional additional error fields.\n */\n constructor(message?: string, fields?: BaseLangGraphErrorFields);\n /**\n * The unminifiable (static, human-readable) error name for this error class.\n */\n static get unminifiable_name(): string;\n}\n/**\n * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA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AAAoC,cAIfO,iBAAAA,SAA0BZ,kBAAAA,CAJX;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAIAA,wBAJAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBY,cAIAC,kBAAAA,SAA2Bb,kBAAAA,CAJV;EAAA,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAKKD,wBALL;aACKA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAG3C;;AAC2CA,cAMtBe,sBAAAA,SAA+Bd,kBAAAA,CANTD;aADKC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAQLD,wBARKC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAOlE;AAA2C,cAItBe,oBAAAA,SAA6Bf,kBAAAA,CAJP;aACAD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAIAA,wBAJAA;aADSC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIpD;;;AAAkDA,cAO7BgB,eAAAA,SAAwBhB,kBAAAA,CAPKA;EAAkB,WAAA,CAAA,OAAA,CAAA,EAAA,MAAA,EAAA,MAAA,CAAA,EAQzBD,wBARyB;EAO/CiB,WAAAA,iBAAe,CAAA,CAAA,EAAA,MAAA;;;;;AAqBpC;;;;;AAeA;;;;;;;;;cAfqBC,oBAAAA,SAA6BjB,kBAAAA;;;;;;yCAMPD;;;;;;;;;cAStBmB"}
|
package/dist/graph/message.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StateGraph } from "./state.cjs";
|
|
2
2
|
import { Messages } from "./messages_reducer.cjs";
|
|
3
3
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
5
5
|
import { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
|
|
6
6
|
|
|
7
7
|
//#region src/graph/message.d.ts
|
|
@@ -27,7 +27,7 @@ declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: R
|
|
|
27
27
|
* @default "messages"
|
|
28
28
|
*/
|
|
29
29
|
stateKey?: string | null;
|
|
30
|
-
}): BaseMessage<
|
|
30
|
+
}): BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { MessageGraph, pushMessage };
|
|
33
33
|
//# sourceMappingURL=message.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.cts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","Messages","MessageGraph","pushMessage","
|
|
1
|
+
{"version":3,"file":"message.d.cts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","Messages","MessageGraph","pushMessage","_langchain_core_messages0","MessageToolSet","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\";\nimport { type Messages } from \"./messages_reducer.js\";\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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n"],"mappings":";;;;;;;;cAKqBK,YAAAA,SAAqBF,WAAWH,eAAeA,eAAeI;;AAAnF;;;;;;;AAeA;;;;;;AAMqHG,iBAN7FD,WAAAA,CAM2BG,OAAAA,EANNT,WAMMS,GANQR,eAMRQ,EAAAA,QAAAA,EANmCP,cAMnCO,GAAAA;;;;;;IAA/CT,YAAiHO,yBAAAA,CAAlEE,iBANiDF,yBAAAA,CAMGC,cAAAA,GAApCD,yBAAAA,CAAwFG,WAAAA"}
|
package/dist/graph/message.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { StateGraph } from "./state.js";
|
|
2
2
|
import { Messages } from "./messages_reducer.js";
|
|
3
3
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _langchain_core_messages14 from "@langchain/core/messages";
|
|
5
5
|
import { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
|
|
6
6
|
|
|
7
7
|
//#region src/graph/message.d.ts
|
|
@@ -27,7 +27,7 @@ declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: R
|
|
|
27
27
|
* @default "messages"
|
|
28
28
|
*/
|
|
29
29
|
stateKey?: string | null;
|
|
30
|
-
}): BaseMessage<
|
|
30
|
+
}): BaseMessage<_langchain_core_messages14.MessageStructure<_langchain_core_messages14.MessageToolSet>, _langchain_core_messages14.MessageType>;
|
|
31
31
|
//#endregion
|
|
32
32
|
export { MessageGraph, pushMessage };
|
|
33
33
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","Messages","MessageGraph","pushMessage","
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","Messages","MessageGraph","pushMessage","_langchain_core_messages14","MessageToolSet","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\";\nimport { type Messages } from \"./messages_reducer.js\";\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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>;\n"],"mappings":";;;;;;;;cAKqBK,YAAAA,SAAqBF,WAAWH,eAAeA,eAAeI;;AAAnF;;;;;;;AAeA;;;;;;AAMqHG,iBAN7FD,WAAAA,CAM2BG,OAAAA,EANNT,WAMMS,GANQR,eAMRQ,EAAAA,QAAAA,EANmCP,cAMnCO,GAAAA;;;;;;IAA/CT,YAAiHO,0BAAAA,CAAlEE,iBANiDF,0BAAAA,CAMGC,cAAAA,GAApCD,0BAAAA,CAAwFG,WAAAA"}
|
|
@@ -4,7 +4,7 @@ import { AnnotationRoot } from "./annotation.cjs";
|
|
|
4
4
|
import { Messages } from "./messages_reducer.cjs";
|
|
5
5
|
import { z } from "zod/v3";
|
|
6
6
|
import * as _langchain_core_utils_types0 from "@langchain/core/utils/types";
|
|
7
|
-
import * as
|
|
7
|
+
import * as _langchain_core_messages29 from "@langchain/core/messages";
|
|
8
8
|
import { BaseMessage } from "@langchain/core/messages";
|
|
9
9
|
|
|
10
10
|
//#region src/graph/messages_annotation.d.ts
|
|
@@ -45,7 +45,7 @@ import { BaseMessage } from "@langchain/core/messages";
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
48
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages29.MessageStructure<_langchain_core_messages29.MessageToolSet>, _langchain_core_messages29.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_messages29.MessageStructure<_langchain_core_messages29.MessageToolSet>, _langchain_core_messages29.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages29.MessageStructure<_langchain_core_messages29.MessageToolSet>, _langchain_core_messages29.MessageType>[]>, _langchain_core_utils_types0.InteropZodType<Messages>>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
messages: BaseMessage<
|
|
106
|
+
messages: BaseMessage<_langchain_core_messages29.MessageStructure<_langchain_core_messages29.MessageToolSet>, _langchain_core_messages29.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages29.MessageStructure<_langchain_core_messages29.MessageToolSet>, _langchain_core_messages29.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_js7","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","_langchain_core_messages29","MessageToolSet","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./messages_reducer.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\").MessageToolSet>, 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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, 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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;AAC4dE,cAzDvcM,kBAyDgbW,EAxD5YlB,cAwD4YkB,CAAAA;UAAchB,EAxD1OH,uBAwD0OG,CAxDzZC,WAwDyZD,CAxDxSM,0BAAAA,CAAlEE,gBAwD0WR,CAvDjdM,0BAAAA,CAD2JC,cAAAA,CAwDsTP,EAxD1VM,0BAAAA,CAAwFG,WAAAA,CAwDkQT,EAAAA,EAxDlPG,QAwDkPH,CAAAA;;;;;;;;;;;;;;;cAzC9bY,iBAAiBR,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CU,kBAAkBX,CAAAA,CAAEiB;YAC0anB,kBAA3ZE,CAAAA,CAAEa,QAAQd,YAAiHK,0BAAAA,CAAlEE,iBAK/GF,0BAAAA,CALmKC,cAAAA,GAApCD,0BAAAA,CAAwFG,WAAAA,KAAgBP,CAAAA,CAAEY,YAAYb,YAAiHK,0BAAAA,CAAlEE,iBAAjDF,0BAAAA,CAAqGC,cAAAA,GAApCD,0BAAAA,CAAwFG,WAAAA,MAA8EV,4BAAAA,CAAvBiB,eAAeb;YACxcD,CAAAA,CAAEgB;YACAjB,YAAiHK,0BAAAA,CAAlEE,iBADrCF,0BAAAA,CACyFC,cAAAA,GAApCD,0BAAAA,CAAwFG,WAAAA;;YAEvJR,YAAiHK,0BAAAA,CAAlEE,iBAFpCF,0BAAAA,CAEwFC,cAAAA,GAApCD,0BAAAA,CAAwFG,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 "./messages_reducer.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as _langchain_core_messages0 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_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _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.MessageToolSet>, _langchain_core_messages0.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _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.MessageToolSet>, _langchain_core_messages0.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[];
|
|
109
109
|
}>;
|
|
110
110
|
//#endregion
|
|
111
111
|
export { MessagesAnnotation, MessagesZodMeta, MessagesZodState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.ts","names":["
|
|
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_messages0","MessageToolSet","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./messages_reducer.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\").MessageToolSet>, 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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, 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\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure<import(\"@langchain/core/messages\").MessageToolSet>, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA;;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;AAC4dE,cAzDvcM,kBAyDgbW,EAxD5YlB,cAwD4YkB,CAAAA;UAAchB,EAxD1OH,uBAwD0OG,CAxDzZC,WAwDyZD,CAxDxSM,yBAAAA,CAAlEE,gBAwD0WR,CAvDjdM,yBAAAA,CAD2JC,cAAAA,CAwDsTP,EAxD1VM,yBAAAA,CAAwFG,WAAAA,CAwDkQT,EAAAA,EAxDlPG,QAwDkPH,CAAAA;;;;;;;;;;;;;;;cAzC9bY,iBAAiBR,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CU,kBAAkBX,CAAAA,CAAEiB;YAC0anB,kBAA3ZE,CAAAA,CAAEa,QAAQd,YAAiHK,yBAAAA,CAAlEE,iBAK/GF,yBAAAA,CALmKC,cAAAA,GAApCD,yBAAAA,CAAwFG,WAAAA,KAAgBP,CAAAA,CAAEY,YAAYb,YAAiHK,yBAAAA,CAAlEE,iBAAjDF,yBAAAA,CAAqGC,cAAAA,GAApCD,yBAAAA,CAAwFG,WAAAA,MAA8EV,4BAAAA,CAAvBiB,eAAeb;YACxcD,CAAAA,CAAEgB;YACAjB,YAAiHK,yBAAAA,CAAlEE,iBADrCF,yBAAAA,CACyFC,cAAAA,GAApCD,yBAAAA,CAAwFG,WAAAA;;YAEvJR,YAAiHK,yBAAAA,CAAlEE,iBAFpCF,yBAAAA,CAEwFC,cAAAA,GAApCD,yBAAAA,CAAwFG,WAAAA"}
|
package/dist/graph/zod/index.cjs
CHANGED
package/dist/graph/zod/meta.cjs
CHANGED
|
@@ -13,9 +13,9 @@ var SchemaMetaRegistry = class {
|
|
|
13
13
|
* Internal map storing schema metadata.
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
_map = /* @__PURE__ */ new
|
|
16
|
+
_map = /* @__PURE__ */ new Map();
|
|
17
17
|
/**
|
|
18
|
-
* Cache for extended
|
|
18
|
+
* Cache for extended schemas.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
_extensionCache = /* @__PURE__ */ new Map();
|
|
@@ -94,7 +94,7 @@ var SchemaMetaRegistry = class {
|
|
|
94
94
|
getExtendedChannelSchemas(schema, effects) {
|
|
95
95
|
if (Object.keys(effects).length === 0) return schema;
|
|
96
96
|
const cacheKey = Object.entries(effects).filter(([, v]) => v === true).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
|
|
97
|
-
const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new
|
|
97
|
+
const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new Map();
|
|
98
98
|
if (cache.has(schema)) return cache.get(schema);
|
|
99
99
|
let modifiedSchema = schema;
|
|
100
100
|
if (effects.withReducerSchema || effects.withJsonSchemaExtrasAsDescription) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new 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,SAAqC;;;;;CAMhD,kCAAkB,IAAI,KAAsD;;;;;;;;CAS5E,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,I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AAO,CAAC,KAAK,aAAa;KAC1B;AACF,4EACE,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,sDAAkB,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,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,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
@@ -31,12 +31,12 @@ declare class SchemaMetaRegistry {
|
|
|
31
31
|
* Internal map storing schema metadata.
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
_map:
|
|
34
|
+
_map: Map<InteropZodType, SchemaMeta<any, any>>;
|
|
35
35
|
/**
|
|
36
|
-
* Cache for extended
|
|
36
|
+
* Cache for extended schemas.
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
|
-
_extensionCache: Map<string,
|
|
39
|
+
_extensionCache: Map<string, Map<InteropZodType, InteropZodType>>;
|
|
40
40
|
/**
|
|
41
41
|
* Retrieves the metadata associated with a given schema.
|
|
42
42
|
* @template TValue The value type of the schema.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.cts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","
|
|
1
|
+
{"version":3,"file":"meta.d.cts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","Map","schemaMetaRegistry","withLangGraph","TSchema"],"sources":["../../../src/graph/zod/meta.d.ts"],"sourcesContent":["import { InteropZodObject, InteropZodType, InteropZodObjectShape } from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nexport declare const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n/** @internal */\nexport type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n/** @internal */\nexport type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never;\n};\nexport type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never;\n};\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 * 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 declare class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map: Map<InteropZodType, SchemaMeta<any, any>>;\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache: Map<string, Map<InteropZodType, InteropZodType>>;\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>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;\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>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;\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 /**\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 /**\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>(schema: T): InteropZodToStateDefinition<T>;\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>(schema: T, 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 }): InteropZodObject;\n}\nexport declare const schemaMetaRegistry: SchemaMetaRegistry;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {\n reducer?: undefined;\n}): TSchema;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\n"],"mappings":";;;;cAEqBI,8BAAAA;;AAAAA,KAETC,iBAFSD,CAAAA,UAEmBH,cAFW,EAAA,uBAE4BA,cAF5B,CAAA,GAE8CK,CAF9C,GAAA;EAEvCD,iBAAAA,EACWE,cADM;CAAA;;AAAkDN,KAInEO,2BAJmEP,CAAAA,UAI7BD,gBAJ6BC,EAAAA,SAIFC,qBAJED,CAIoBK,CAJpBL,CAAAA,CAAAA,GAAAA,UAAkBK,MAK/EG,MAL+EH,GAKtEG,MALsEH,CAK/DI,GAL+DJ,CAAAA,SAKlDD,iBALkDC,CAAAA,KAAAA,OAAAA,EAAAA,KAAAA,cAAAA,CAAAA,GAKKK,MALLL,SAKoBL,cALpBK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8CM,aAL9CN,SAKoEL,cALpEK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8FH,WAL9FG,CAK0GO,CAL1GP,EAK6GQ,CAL7GR,CAAAA,GAAAA,KAAAA,GAAAA,KAAAA,GAKkIG,MALlIH,CAKyII,GALzIJ,CAAAA,SAKsJL,cALtJK,CAAAA,KAAAA,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ALHvB,gBAKG;AACX;AAAqC,cAJhBqB,kBAIgB,EAJIF,kBAIJ;AAAiDF,iBAH9DK,aAG8DL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAHfhB,cAGegB,CAHAA,MAGAA,CAAAA,CAAAA,CAAAA,MAAAA,EAHiBM,OAGjBN,EAAAA,IAAAA,EAHgCD,UAGhCC,CAH2CA,MAG3CA,EAHmDC,OAGnDD,CAAAA,GAAAA;SAAfhB,CAAAA,EAAAA,SAAAA;IADnEsB,OACmGA;AAA0BN,iBAAzGK,aAAyGL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAA1DhB,cAA0DgB,CAA3CA,MAA2CA,CAAAA,CAAAA,CAAAA,MAAAA,EAA1BM,OAA0BN,EAAAA,IAAAA,EAAXD,UAAWC,CAAAA,MAAAA,EAAQC,OAARD,CAAAA,CAAAA,EAAmBZ,iBAAnBY,CAAqCM,OAArCN,EAA8ChB,cAA9CgB,CAA6DC,OAA7DD,CAAAA,CAAAA"}
|
package/dist/graph/zod/meta.d.ts
CHANGED
|
@@ -31,12 +31,12 @@ declare class SchemaMetaRegistry {
|
|
|
31
31
|
* Internal map storing schema metadata.
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
_map:
|
|
34
|
+
_map: Map<InteropZodType, SchemaMeta<any, any>>;
|
|
35
35
|
/**
|
|
36
|
-
* Cache for extended
|
|
36
|
+
* Cache for extended schemas.
|
|
37
37
|
* @internal
|
|
38
38
|
*/
|
|
39
|
-
_extensionCache: Map<string,
|
|
39
|
+
_extensionCache: Map<string, Map<InteropZodType, InteropZodType>>;
|
|
40
40
|
/**
|
|
41
41
|
* Retrieves the metadata associated with a given schema.
|
|
42
42
|
* @template TValue The value type of the schema.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","
|
|
1
|
+
{"version":3,"file":"meta.d.ts","names":["InteropZodObject","InteropZodType","InteropZodObjectShape","BaseChannel","META_EXTRAS_DESCRIPTION_PREFIX","ReducedZodChannel","T","TReducerSchema","InteropZodToStateDefinition","TShape","key","Schema","ReducerSchema","V","U","UpdateType","SchemaMeta","TValue","TUpdate","SchemaMetaRegistry","Map","schemaMetaRegistry","withLangGraph","TSchema"],"sources":["../../../src/graph/zod/meta.d.ts"],"sourcesContent":["import { InteropZodObject, InteropZodType, InteropZodObjectShape } from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nexport declare const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n/** @internal */\nexport type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZodType> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n/** @internal */\nexport type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never;\n};\nexport type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<unknown> ? ReducerSchema extends InteropZodType<infer U> ? U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never;\n};\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 * 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 declare class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map: Map<InteropZodType, SchemaMeta<any, any>>;\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache: Map<string, Map<InteropZodType, InteropZodType>>;\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>(schema: InteropZodType<TValue>): SchemaMeta<TValue, TUpdate> | undefined;\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>(schema: InteropZodType<TValue>, predicate: (meta: SchemaMeta<TValue, TUpdate> | undefined) => SchemaMeta<TValue, TUpdate>): void;\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 /**\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 /**\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>(schema: T): InteropZodToStateDefinition<T>;\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>(schema: T, 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 }): InteropZodObject;\n}\nexport declare const schemaMetaRegistry: SchemaMetaRegistry;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate> & {\n reducer?: undefined;\n}): TSchema;\nexport declare function withLangGraph<TValue, TUpdate, TSchema extends InteropZodType<TValue>>(schema: TSchema, meta: SchemaMeta<TValue, TUpdate>): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\n"],"mappings":";;;;cAEqBI,8BAAAA;;AAAAA,KAETC,iBAFSD,CAAAA,UAEmBH,cAFW,EAAA,uBAE4BA,cAF5B,CAAA,GAE8CK,CAF9C,GAAA;EAEvCD,iBAAAA,EACWE,cADM;CAAA;;AAAkDN,KAInEO,2BAJmEP,CAAAA,UAI7BD,gBAJ6BC,EAAAA,SAIFC,qBAJED,CAIoBK,CAJpBL,CAAAA,CAAAA,GAAAA,UAAkBK,MAK/EG,MAL+EH,GAKtEG,MALsEH,CAK/DI,GAL+DJ,CAAAA,SAKlDD,iBALkDC,CAAAA,KAAAA,OAAAA,EAAAA,KAAAA,cAAAA,CAAAA,GAKKK,MALLL,SAKoBL,cALpBK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8CM,aAL9CN,SAKoEL,cALpEK,CAAAA,KAAAA,EAAAA,CAAAA,GAK8FH,WAL9FG,CAK0GO,CAL1GP,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A,OAAA;IAAA;;;IAAkEC,iCAAAA,CAAAA,EAAAA,OAAAA;IAA0BN;;;IAE7HM,SAAAA,CAAAA,EAAAA,OAAAA;EAAO,CAAA,CAAA,EALHvB,gBAKG;AACX;AAAqC,cAJhBqB,kBAIgB,EAJIF,kBAIJ;AAAiDF,iBAH9DK,aAG8DL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAHfhB,cAGegB,CAHAA,MAGAA,CAAAA,CAAAA,CAAAA,MAAAA,EAHiBM,OAGjBN,EAAAA,IAAAA,EAHgCD,UAGhCC,CAH2CA,MAG3CA,EAHmDC,OAGnDD,CAAAA,GAAAA;SAAfhB,CAAAA,EAAAA,SAAAA;IADnEsB,OACmGA;AAA0BN,iBAAzGK,aAAyGL,CAAAA,MAAAA,EAAAA,OAAAA,EAAAA,gBAA1DhB,cAA0DgB,CAA3CA,MAA2CA,CAAAA,CAAAA,CAAAA,MAAAA,EAA1BM,OAA0BN,EAAAA,IAAAA,EAAXD,UAAWC,CAAAA,MAAAA,EAAQC,OAARD,CAAAA,CAAAA,EAAmBZ,iBAAnBY,CAAqCM,OAArCN,EAA8ChB,cAA9CgB,CAA6DC,OAA7DD,CAAAA,CAAAA"}
|
package/dist/graph/zod/meta.js
CHANGED
|
@@ -13,9 +13,9 @@ var SchemaMetaRegistry = class {
|
|
|
13
13
|
* Internal map storing schema metadata.
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
16
|
-
_map = /* @__PURE__ */ new
|
|
16
|
+
_map = /* @__PURE__ */ new Map();
|
|
17
17
|
/**
|
|
18
|
-
* Cache for extended
|
|
18
|
+
* Cache for extended schemas.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
21
|
_extensionCache = /* @__PURE__ */ new Map();
|
|
@@ -94,7 +94,7 @@ var SchemaMetaRegistry = class {
|
|
|
94
94
|
getExtendedChannelSchemas(schema, effects) {
|
|
95
95
|
if (Object.keys(effects).length === 0) return schema;
|
|
96
96
|
const cacheKey = Object.entries(effects).filter(([, v]) => v === true).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}:${v}`).join("|");
|
|
97
|
-
const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new
|
|
97
|
+
const cache = this._extensionCache.get(cacheKey) ?? /* @__PURE__ */ new Map();
|
|
98
98
|
if (cache.has(schema)) return cache.get(schema);
|
|
99
99
|
let modifiedSchema = schema;
|
|
100
100
|
if (effects.withReducerSchema || effects.withJsonSchemaExtrasAsDescription) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","names":[],"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,SAAqC;;;;;CAMhD,kCAAkB,IAAI,KAAsD;;;;;;;;CAS5E,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAI,UAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0B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,MAAM,qBAAqB,2BAA2B,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAgBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAI,wBAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAI,UAAU,MAAM,QAAQ;;AAGhD,SAAO;;;;;;;;;;;;;;;;CAiBT,0BACE,QACA,SAckB;AAElB,MAAI,OAAO,KAAK,QAAQ,CAAC,WAAW,EAClC,QAAO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