@langchain/langgraph 1.1.1 → 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.
Files changed (100) hide show
  1. package/dist/channels/index.cjs +1 -0
  2. package/dist/errors.d.cts.map +1 -1
  3. package/dist/errors.d.ts.map +1 -1
  4. package/dist/graph/annotation.cjs +3 -0
  5. package/dist/graph/annotation.cjs.map +1 -1
  6. package/dist/graph/annotation.d.cts +1 -0
  7. package/dist/graph/annotation.d.cts.map +1 -1
  8. package/dist/graph/annotation.d.ts +1 -0
  9. package/dist/graph/annotation.d.ts.map +1 -1
  10. package/dist/graph/annotation.js +3 -0
  11. package/dist/graph/annotation.js.map +1 -1
  12. package/dist/graph/graph.cjs +3 -3
  13. package/dist/graph/graph.cjs.map +1 -1
  14. package/dist/graph/graph.js +3 -3
  15. package/dist/graph/graph.js.map +1 -1
  16. package/dist/graph/message.d.cts +2 -2
  17. package/dist/graph/message.d.cts.map +1 -1
  18. package/dist/graph/message.d.ts +2 -2
  19. package/dist/graph/message.d.ts.map +1 -1
  20. package/dist/graph/messages_annotation.d.cts +5 -5
  21. package/dist/graph/messages_annotation.d.cts.map +1 -1
  22. package/dist/graph/messages_annotation.d.ts +5 -5
  23. package/dist/graph/messages_annotation.d.ts.map +1 -1
  24. package/dist/graph/state.cjs +98 -78
  25. package/dist/graph/state.cjs.map +1 -1
  26. package/dist/graph/state.d.cts +68 -35
  27. package/dist/graph/state.d.cts.map +1 -1
  28. package/dist/graph/state.d.ts +68 -35
  29. package/dist/graph/state.d.ts.map +1 -1
  30. package/dist/graph/state.js +99 -79
  31. package/dist/graph/state.js.map +1 -1
  32. package/dist/graph/types.cjs +41 -0
  33. package/dist/graph/types.cjs.map +1 -0
  34. package/dist/graph/types.d.cts +247 -18
  35. package/dist/graph/types.d.cts.map +1 -1
  36. package/dist/graph/types.d.ts +247 -18
  37. package/dist/graph/types.d.ts.map +1 -1
  38. package/dist/graph/types.js +40 -0
  39. package/dist/graph/types.js.map +1 -0
  40. package/dist/graph/zod/index.cjs +1 -0
  41. package/dist/graph/zod/meta.cjs +7 -7
  42. package/dist/graph/zod/meta.cjs.map +1 -1
  43. package/dist/graph/zod/meta.d.cts +3 -3
  44. package/dist/graph/zod/meta.d.cts.map +1 -1
  45. package/dist/graph/zod/meta.d.ts +3 -3
  46. package/dist/graph/zod/meta.d.ts.map +1 -1
  47. package/dist/graph/zod/meta.js +7 -7
  48. package/dist/graph/zod/meta.js.map +1 -1
  49. package/dist/graph/zod/schema.cjs +1 -0
  50. package/dist/graph/zod/schema.cjs.map +1 -1
  51. package/dist/hash.cjs +1 -1
  52. package/dist/hash.cjs.map +1 -1
  53. package/dist/hash.js +1 -1
  54. package/dist/hash.js.map +1 -1
  55. package/dist/index.cjs +1 -0
  56. package/dist/index.cjs.map +1 -1
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/prebuilt/agent_executor.d.cts +5 -5
  60. package/dist/prebuilt/agent_executor.d.cts.map +1 -1
  61. package/dist/prebuilt/agent_executor.d.ts +5 -5
  62. package/dist/prebuilt/agent_executor.d.ts.map +1 -1
  63. package/dist/prebuilt/index.cjs +1 -0
  64. package/dist/prebuilt/react_agent_executor.cjs +12 -12
  65. package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
  66. package/dist/prebuilt/react_agent_executor.d.cts +3 -3
  67. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  68. package/dist/prebuilt/react_agent_executor.d.ts +3 -3
  69. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  70. package/dist/prebuilt/react_agent_executor.js +12 -12
  71. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  72. package/dist/prebuilt/tool_node.cjs +1 -1
  73. package/dist/prebuilt/tool_node.cjs.map +1 -1
  74. package/dist/prebuilt/tool_node.js +1 -1
  75. package/dist/prebuilt/tool_node.js.map +1 -1
  76. package/dist/pregel/debug.cjs +9 -9
  77. package/dist/pregel/debug.cjs.map +1 -1
  78. package/dist/pregel/debug.js +9 -9
  79. package/dist/pregel/debug.js.map +1 -1
  80. package/dist/pregel/index.cjs +45 -44
  81. package/dist/pregel/index.cjs.map +1 -1
  82. package/dist/pregel/index.js +44 -44
  83. package/dist/pregel/index.js.map +1 -1
  84. package/dist/pregel/loop.cjs +1 -1
  85. package/dist/pregel/loop.cjs.map +1 -1
  86. package/dist/pregel/loop.js +1 -1
  87. package/dist/pregel/loop.js.map +1 -1
  88. package/dist/pregel/utils/subgraph.cjs +2 -2
  89. package/dist/pregel/utils/subgraph.cjs.map +1 -1
  90. package/dist/pregel/utils/subgraph.js +2 -2
  91. package/dist/pregel/utils/subgraph.js.map +1 -1
  92. package/dist/remote.cjs +1 -0
  93. package/dist/state/schema.cjs +2 -2
  94. package/dist/state/schema.cjs.map +1 -1
  95. package/dist/state/schema.js +2 -2
  96. package/dist/state/schema.js.map +1 -1
  97. package/dist/web.cjs +1 -0
  98. package/dist/web.d.cts +2 -2
  99. package/dist/web.d.ts +2 -2
  100. package/package.json +3 -3
@@ -1,3 +1,4 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
  const require_base = require('./base.cjs');
2
3
  const require_binop = require('./binop.cjs');
3
4
  const require_last_value = require('./last_value.cjs');
@@ -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,CA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AAA,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"}
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,CAA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X;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"}
@@ -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,EAA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,CAAA,EAAoBL,MAAAA;AAC5D;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"}
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,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BP,MAAa,CAAbA,EAGhBH,wBAH6B;EAChDW,WAAAA,iBAAgB,CAAA,CAAoBL,EAAAA,MAAAA;AAC5D;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"}
@@ -11,6 +11,9 @@ var AnnotationRoot = class {
11
11
  constructor(s) {
12
12
  this.spec = s;
13
13
  }
14
+ static isInstance(value) {
15
+ return typeof value === "object" && value !== null && "lc_graph_name" in value && value.lc_graph_name === "AnnotationRoot";
16
+ }
14
17
  };
15
18
  /**
16
19
  * Helper that instantiates channels within a StateGraph state.
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.cjs","names":["LastValue","BinaryOperatorAggregate"],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EhB,MAAa,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC,WAAW;KAGpD,QAAO,IAAIA,8BAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAIC,sCAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAIA,sCAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAID,8BAAc"}
1
+ {"version":3,"file":"annotation.cjs","names":["LastValue","BinaryOperatorAggregate"],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n\n static isInstance(value: unknown): value is AnnotationRoot<StateDefinition> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"lc_graph_name\" in value &&\n (value as { lc_graph_name: unknown }).lc_graph_name === \"AnnotationRoot\"\n );\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;CAGd,OAAO,WAAW,OAA0D;AAC1E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,mBAAmB,SAClB,MAAqC,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4E9D,MAAa,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC,WAAW;KAGpD,QAAO,IAAIA,8BAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAIC,sCAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAIA,sCAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAID,8BAAc"}
@@ -38,6 +38,7 @@ declare class AnnotationRoot<SD extends StateDefinition> {
38
38
  Node: NodeType<SD>;
39
39
  spec: SD;
40
40
  constructor(s: SD);
41
+ static isInstance(value: unknown): value is AnnotationRoot<StateDefinition>;
41
42
  }
42
43
  /**
43
44
  * Helper that instantiates channels within a StateGraph state.
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.d.cts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,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C,CAAAA,CAAAA,EAuBjFG,EAvBiFH;;AACpG;;;;;;;;AAGA;;;;;;;;AAGA;;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
1
+ {"version":3,"file":"annotation.d.cts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n static isInstance(value: unknown): value is AnnotationRoot<StateDefinition>;\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAKDa,EALCb,GAKIQ,gBALJR,CAKqBa,EALrBb,CAKwBc,GALxBd,CAAAA,CAAAA;AAAgC,KA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;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;AAgFA;;;;;;;;;;;;;;cAAqBa,YAAYH"}
@@ -38,6 +38,7 @@ declare class AnnotationRoot<SD extends StateDefinition> {
38
38
  Node: NodeType<SD>;
39
39
  spec: SD;
40
40
  constructor(s: SD);
41
+ static isInstance(value: unknown): value is AnnotationRoot<StateDefinition>;
41
42
  }
42
43
  /**
43
44
  * Helper that instantiates channels within a StateGraph state.
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.d.ts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAK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A;;;;;;;;;;;;AA+EA;;;;;;;;;;;;;;;cAAqBU,YAAYH"}
1
+ {"version":3,"file":"annotation.d.ts","names":["RunnableLike","BaseChannel","BinaryOperator","BinaryOperatorAggregate","LastValue","SingleReducer","ValueType","UpdateType","StateDefinition","ExtractValueType","C","ReturnType","ExtractUpdateType","StateType","SD","key","NodeType","Partial","AnnotationFunction","S","AnnotationRoot","Annotation","getChannel","V","U"],"sources":["../../src/graph/annotation.d.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nexport type SingleReducer<ValueType, UpdateType = ValueType> = {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n} | null;\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\ntype ExtractValueType<C> = C extends BaseChannel ? C[\"ValueType\"] : C extends () => BaseChannel ? ReturnType<C>[\"ValueType\"] : never;\ntype ExtractUpdateType<C> = C extends BaseChannel ? C[\"UpdateType\"] : C extends () => BaseChannel ? ReturnType<C>[\"UpdateType\"] : never;\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\nexport type NodeType<SD extends StateDefinition> = RunnableLike<StateType<SD>, UpdateType<SD> | Partial<StateType<SD>>>;\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(annotation: SingleReducer<ValueType, UpdateType>): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport declare class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name: string;\n State: StateType<SD>;\n Update: UpdateType<SD>;\n Node: NodeType<SD>;\n spec: SD;\n constructor(s: SD);\n static isInstance(value: unknown): value is AnnotationRoot<StateDefinition>;\n}\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport declare const Annotation: AnnotationFunction;\nexport declare function getChannel<V, U = V>(reducer: SingleReducer<V, U>): BaseChannel<V, U>;\nexport {};\n"],"mappings":";;;;;;KAIYK,sCAAsCC;WACrCJ,eAAeI,WAAWC;EAD3BF,OAAAA,CAAAA,EAAAA,GAAAA,GAEQC,SAFK;CAAA,GAAA;;;;OACZJ,EAMFA,cANEA,CAMaI,SANbJ,EAMwBK,UANxBL,CAAAA;SACOI,CAAAA,EAAAA,GAAAA,GAMAA,SANAA;QAKMA;AAAWC,UAGpBC,eAAAA,CAHoBD;MAA1BL,EAAAA,MAAAA,CAAAA,EAIQD,WAJRC,GAAAA,CAAAA,GAAAA,GAI6BD,WAJ7BC,CAAAA;;KAMNO,gBALwB,CAAA,CAAA,CAAA,GAKFC,CALE,SAKQT,WALR,GAKsBS,CALtB,CAAA,WAAA,CAAA,GAKuCA,CALvC,UAAA,GAAA,GAKuDT,WALvD,IAKqEU,UALrE,CAKgFD,CALhF,CAAA,CAAA,WAAA,CAAA,GAAA,KAAA;AAE7B,KAIKE,iBAJ2B,CAAA,CAAA,CAAA,GAIJF,CAJI,SAIMT,WAJN,GAIoBS,CAJpB,CAAA,YAAA,CAAA,GAIsCA,CAJtC,UAAA,GAAA,GAIsDT,WAJtD,IAIoEU,UAJpE,CAI+ED,CAJ/E,CAAA,CAAA,YAAA,CAAA,GAAA,KAAA;AAAA,KAKpBG,SALoB,CAAA,WAKCL,eALD,CAAA,GAAA,UACbP,MAKDa,EALCb,GAKIQ,gBALJR,CAKqBa,EALrBb,CAKwBc,GALxBd,CAAAA,CAAAA;AAAgC,KAOvCM,UAPuC,CAAA,WAOjBC,eAPiB,CAAA,GAAA,UAE9CC,MAMaK,EANbL,IAMmBG,iBANH,CAMqBE,EANrB,CAMwBC,GANxB,C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class {
11
11
  constructor(s) {
12
12
  this.spec = s;
13
13
  }
14
+ static isInstance(value) {
15
+ return typeof value === "object" && value !== null && "lc_graph_name" in value && value.lc_graph_name === "AnnotationRoot";
16
+ }
14
17
  };
15
18
  /**
16
19
  * Helper that instantiates channels within a StateGraph state.
@@ -1 +1 @@
1
- {"version":3,"file":"annotation.js","names":[],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EhB,MAAa,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC,WAAW;KAGpD,QAAO,IAAI,WAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAI,wBAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAI,wBAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAI,WAAc"}
1
+ {"version":3,"file":"annotation.js","names":[],"sources":["../../src/graph/annotation.ts"],"sourcesContent":["import { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { BinaryOperator, BinaryOperatorAggregate } from \"../channels/binop.js\";\nimport { LastValue } from \"../channels/last_value.js\";\n\nexport type SingleReducer<ValueType, UpdateType = ValueType> =\n | {\n reducer: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | {\n /**\n * @deprecated Use `reducer` instead\n */\n value: BinaryOperator<ValueType, UpdateType>;\n default?: () => ValueType;\n }\n | null;\n\nexport interface StateDefinition {\n [key: string]: BaseChannel | (() => BaseChannel);\n}\n\ntype ExtractValueType<C> = C extends BaseChannel\n ? C[\"ValueType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"ValueType\"]\n : never;\n\ntype ExtractUpdateType<C> = C extends BaseChannel\n ? C[\"UpdateType\"]\n : C extends () => BaseChannel\n ? ReturnType<C>[\"UpdateType\"]\n : never;\n\nexport type StateType<SD extends StateDefinition> = {\n [key in keyof SD]: ExtractValueType<SD[key]>;\n};\n\nexport type UpdateType<SD extends StateDefinition> = {\n [key in keyof SD]?: ExtractUpdateType<SD[key]>;\n};\n\nexport type NodeType<SD extends StateDefinition> = RunnableLike<\n StateType<SD>,\n UpdateType<SD> | Partial<StateType<SD>>\n>;\n\n/** @ignore */\nexport interface AnnotationFunction {\n <ValueType>(): LastValue<ValueType>;\n <ValueType, UpdateType = ValueType>(\n annotation: SingleReducer<ValueType, UpdateType>\n ): BinaryOperatorAggregate<ValueType, UpdateType>;\n Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;\n}\n\n/**\n * Should not be instantiated directly. See {@link Annotation}.\n */\nexport class AnnotationRoot<SD extends StateDefinition> {\n lc_graph_name = \"AnnotationRoot\";\n\n declare State: StateType<SD>;\n\n declare Update: UpdateType<SD>;\n\n declare Node: NodeType<SD>;\n\n spec: SD;\n\n constructor(s: SD) {\n this.spec = s;\n }\n\n static isInstance(value: unknown): value is AnnotationRoot<StateDefinition> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"lc_graph_name\" in value &&\n (value as { lc_graph_name: unknown }).lc_graph_name === \"AnnotationRoot\"\n );\n }\n}\n\n/**\n * Helper that instantiates channels within a StateGraph state.\n *\n * Can be used as a field in an {@link Annotation.Root} wrapper in one of two ways:\n * 1. **Directly**: Creates a channel that stores the most recent value returned from a node.\n * 2. **With a reducer**: Creates a channel that applies the reducer on a node's return value.\n *\n * @example\n * ```ts\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single string key named \"currentOutput\"\n * const SimpleAnnotation = Annotation.Root({\n * currentOutput: Annotation<string>,\n * });\n *\n * const graphBuilder = new StateGraph(SimpleAnnotation);\n *\n * // A node in the graph that returns an object with a \"currentOutput\" key\n * // replaces the value in the state. You can get the state type as shown below:\n * const myNode = (state: typeof SimpleAnnotation.State) => {\n * return {\n * currentOutput: \"some_new_value\",\n * };\n * }\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n *\n * @example\n * ```ts\n * import { type BaseMessage, AIMessage } from \"@langchain/core/messages\";\n * import { StateGraph, Annotation } from \"@langchain/langgraph\";\n *\n * // Define a state with a single key named \"messages\" that will\n * // combine a returned BaseMessage or arrays of BaseMessages\n * const AnnotationWithReducer = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * // Different types are allowed for updates\n * reducer: (left: BaseMessage[], right: BaseMessage | BaseMessage[]) => {\n * if (Array.isArray(right)) {\n * return left.concat(right);\n * }\n * return left.concat([right]);\n * },\n * default: () => [],\n * }),\n * });\n *\n * const graphBuilder = new StateGraph(AnnotationWithReducer);\n *\n * // A node in the graph that returns an object with a \"messages\" key\n * // will update the state by combining the existing value with the returned one.\n * const myNode = (state: typeof AnnotationWithReducer.State) => {\n * return {\n * messages: [new AIMessage(\"Some new response\")],\n * };\n * };\n *\n * const graph = graphBuilder\n * .addNode(\"myNode\", myNode)\n * ...\n * .compile();\n * ```\n * @namespace\n * @property Root\n * Helper function that instantiates a StateGraph state. See {@link Annotation} for usage.\n */\nexport const Annotation: AnnotationFunction = function <\n ValueType,\n UpdateType = ValueType\n>(\n annotation?: SingleReducer<ValueType, UpdateType>\n): BaseChannel<ValueType, UpdateType> {\n if (annotation) {\n return getChannel<ValueType, UpdateType>(annotation);\n } else {\n // @ts-expect-error - Annotation without reducer\n return new LastValue<ValueType>();\n }\n} as AnnotationFunction;\n\nAnnotation.Root = <S extends StateDefinition>(sd: S) => new AnnotationRoot(sd);\n\nexport function getChannel<V, U = V>(\n reducer: SingleReducer<V, U>\n): BaseChannel<V, U> {\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"reducer\" in reducer &&\n reducer.reducer\n ) {\n return new BinaryOperatorAggregate(reducer.reducer, reducer.default);\n }\n if (\n typeof reducer === \"object\" &&\n reducer &&\n \"value\" in reducer &&\n reducer.value\n ) {\n return new BinaryOperatorAggregate(reducer.value, reducer.default);\n }\n // @ts-expect-error - Annotation without reducer\n return new LastValue<V>();\n}\n"],"mappings":";;;;;;;AA4DA,IAAa,iBAAb,MAAwD;CACtD,gBAAgB;CAQhB;CAEA,YAAY,GAAO;AACjB,OAAK,OAAO;;CAGd,OAAO,WAAW,OAA0D;AAC1E,SACE,OAAO,UAAU,YACjB,UAAU,QACV,mBAAmB,SAClB,MAAqC,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4E9D,MAAa,aAAiC,SAI5C,YACoC;AACpC,KAAI,WACF,QAAO,WAAkC,WAAW;KAGpD,QAAO,IAAI,WAAsB;;AAIrC,WAAW,QAAmC,OAAU,IAAI,eAAe,GAAG;AAE9E,SAAgB,WACd,SACmB;AACnB,KACE,OAAO,YAAY,YACnB,WACA,aAAa,WACb,QAAQ,QAER,QAAO,IAAI,wBAAwB,QAAQ,SAAS,QAAQ,QAAQ;AAEtE,KACE,OAAO,YAAY,YACnB,WACA,WAAW,WACX,QAAQ,MAER,QAAO,IAAI,wBAAwB,QAAQ,OAAO,QAAQ,QAAQ;AAGpE,QAAO,IAAI,WAAc"}
@@ -66,8 +66,8 @@ var Graph = class {
66
66
  return this.edges;
67
67
  }
68
68
  addNode(...args) {
69
- function isMutlipleNodes(args$1) {
70
- return args$1.length >= 1 && typeof args$1[0] !== "string";
69
+ function isMutlipleNodes(args) {
70
+ return args.length >= 1 && typeof args[0] !== "string";
71
71
  }
72
72
  const nodes = isMutlipleNodes(args) ? Array.isArray(args[0]) ? args[0] : Object.entries(args[0]) : [[
73
73
  args[0],
@@ -150,7 +150,7 @@ var Graph = class {
150
150
  });
151
151
  for (const [key, node] of Object.entries(this.nodes)) compiled.attachNode(key, node);
152
152
  for (const [start, end] of this.edges) compiled.attachEdge(start, end);
153
- for (const [start, branches] of Object.entries(this.branches)) for (const [name$1, branch] of Object.entries(branches)) compiled.attachBranch(start, name$1, branch);
153
+ for (const [start, branches] of Object.entries(this.branches)) for (const [name, branch] of Object.entries(branches)) compiled.attachBranch(start, name, branch);
154
154
  return compiled.validate();
155
155
  }
156
156
  validate(interrupt) {
@@ -1 +1 @@
1
- {"version":3,"file":"graph.cjs","names":["Runnable","ChannelWrite","RunnableCallable","NodeInterrupt","_isSend","END","InvalidUpdateError","args","CHECKPOINT_NAMESPACE_SEPARATOR","CHECKPOINT_NAMESPACE_END","isPregelLike","START","EphemeralValue","name","UnreachableNodeError","Pregel","PregelNode","PASSTHROUGH","TAG_HIDDEN","Channel","DrawableGraph","z","gatherIterator","gatherIteratorSync"],"sources":["../../src/graph/graph.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n _coerceToRunnable,\n Runnable,\n RunnableConfig,\n RunnableInterface,\n RunnableIOSchema,\n type RunnableLike as LangChainRunnableLike,\n} from \"@langchain/core/runnables\";\nimport {\n Node as DrawableGraphNode,\n Graph as DrawableGraph,\n} from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { z } from \"zod/v4\";\nimport { validate as isUuid } from \"uuid\";\nimport type {\n RunnableLike,\n LangGraphRunnableConfig,\n} from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Channel, Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\nimport {\n _isSend,\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n END,\n Send,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport {\n gatherIterator,\n gatherIteratorSync,\n RunnableCallable,\n} from \"../utils.js\";\nimport {\n InvalidUpdateError,\n NodeInterrupt,\n UnreachableNodeError,\n} from \"../errors.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nimport { isPregelLike } from \"../pregel/utils/subgraph.js\";\n\nexport interface BranchOptions<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\n\nexport type BranchPathReturnValue =\n | string\n | Send\n | (string | Send)[]\n | Promise<string | Send | (string | Send)[]>;\n\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<\n S,\n U extends object ? U & Record<string, any> : U, // eslint-disable-line @typescript-eslint/no-explicit-any\n LangGraphRunnableConfig<StateType<C>>\n>;\n\nexport class Branch<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n path: Runnable<IO, BranchPathReturnValue, CallOptions>;\n\n ends?: Record<string, N | typeof END>;\n\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">) {\n if (Runnable.isRunnable(options.path)) {\n this.path = options.path as Runnable<\n IO,\n BranchPathReturnValue,\n CallOptions\n >;\n } else {\n this.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n IO,\n BranchPathReturnValue,\n CallOptions\n >\n ).withConfig({ runName: `Branch` } as CallOptions);\n }\n this.ends = Array.isArray(options.pathMap)\n ? options.pathMap.reduce((acc, n) => {\n acc[n] = n;\n return acc;\n }, {} as Record<string, N | typeof END>)\n : options.pathMap;\n }\n\n run(\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n ) {\n return ChannelWrite.registerWriter(\n new RunnableCallable({\n name: \"<branch_run>\",\n trace: false,\n func: async (input: IO, config: CallOptions) => {\n try {\n return await this._route(input, config, writer, reader);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Detect & warn if NodeInterrupt is thrown in a conditional edge\n if (e.name === NodeInterrupt.unminifiable_name) {\n console.warn(\n \"[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.\\n\" +\n \"NodeInterrupt should only be thrown inside a node, not in edge conditions.\"\n );\n }\n throw e;\n }\n },\n })\n );\n }\n\n async _route(\n input: IO,\n config: CallOptions,\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<Runnable | any> {\n let result = await this.path.invoke(\n reader ? reader(config) : input,\n config\n );\n if (!Array.isArray(result)) {\n result = [result];\n }\n\n let destinations: (string | Send)[];\n if (this.ends) {\n destinations = result.map((r) => (_isSend(r) ? r : this.ends![r]));\n } else {\n destinations = result;\n }\n if (destinations.some((dest) => !dest)) {\n throw new Error(\"Branch condition returned unknown or null destination\");\n }\n if (destinations.filter(_isSend).some((packet) => packet.node === END)) {\n throw new InvalidUpdateError(\"Cannot send a packet to the END node\");\n }\n const writeResult = await writer(destinations, config);\n return writeResult ?? input;\n }\n}\n\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\n\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\n\nexport class Graph<\n N extends string = typeof START | typeof END,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<\n RunInput,\n RunOutput\n >,\n C extends StateDefinition = StateDefinition\n> {\n nodes: Record<N, NodeSpecType>;\n\n edges: Set<[N | typeof START, N | typeof END]>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n\n entryPoint?: string;\n\n compiled = false;\n\n constructor() {\n this.nodes = {} as Record<N, NodeSpecType>;\n this.edges = new Set();\n this.branches = {};\n }\n\n protected warnIfCompiled(message: string): void {\n if (this.compiled) {\n console.warn(message);\n }\n }\n\n get allEdges(): Set<[string, string]> {\n return this.edges;\n }\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n ...args:\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ]\n | [\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ]\n ): Graph<N | K, RunInput, RunOutput> {\n function isMutlipleNodes(\n args: unknown[]\n ): args is [\n nodes:\n | Record<K, NodeAction<NodeInput, RunOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, RunOutput, C>,\n options?: AddNodeOptions\n ][],\n options?: AddNodeOptions\n ] {\n return args.length >= 1 && typeof args[0] !== \"string\";\n }\n\n const nodes = (\n isMutlipleNodes(args) // eslint-disable-line no-nested-ternary\n ? Array.isArray(args[0])\n ? args[0]\n : Object.entries(args[0])\n : [[args[0], args[1], args[2]]]\n ) as [K, NodeAction<NodeInput, RunOutput, C>, AddNodeOptions][];\n\n if (nodes.length === 0) {\n throw new Error(\"No nodes provided in `addNode`\");\n }\n\n for (const [key, action, options] of nodes) {\n for (const reservedChar of [\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CHECKPOINT_NAMESPACE_END,\n ]) {\n if (key.includes(reservedChar)) {\n throw new Error(\n `\"${reservedChar}\" is a reserved character and is not allowed in node names.`\n );\n }\n }\n this.warnIfCompiled(\n `Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (key in this.nodes) {\n throw new Error(`Node \\`${key}\\` already present.`);\n }\n if (key === END) {\n throw new Error(`Node \\`${key}\\` is reserved.`);\n }\n\n const runnable = _coerceToRunnable<RunInput, RunOutput>(\n // Account for arbitrary state due to Send API\n action as RunnableLike<RunInput, RunOutput>\n );\n\n this.nodes[key as unknown as N] = {\n runnable,\n metadata: options?.metadata,\n subgraphs: isPregelLike(runnable) ? [runnable] : options?.subgraphs,\n ends: options?.ends,\n } as NodeSpecType;\n }\n\n return this as Graph<N | K, RunInput, RunOutput, NodeSpecType>;\n }\n\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this {\n this.warnIfCompiled(\n `Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (startKey === END) {\n throw new Error(\"END cannot be a start node\");\n }\n if (endKey === START) {\n throw new Error(\"START cannot be an end node\");\n }\n if (\n Array.from(this.edges).some(([start]) => start === startKey) &&\n !(\"channels\" in this)\n ) {\n throw new Error(\n `Already found path for ${startKey}. For multiple edges, use StateGraph.`\n );\n }\n\n this.edges.add([startKey, endKey]);\n\n return this;\n }\n\n addConditionalEdges(\n source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>\n ): this;\n\n addConditionalEdges(\n source: N,\n path: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this;\n\n addConditionalEdges(\n source:\n | N\n | BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>,\n path?: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this {\n const options: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n > = typeof source === \"object\" ? source : { source, path: path!, pathMap };\n\n this.warnIfCompiled(\n \"Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n if (!Runnable.isRunnable(options.path)) {\n const pathDisplayValues = Array.isArray(options.pathMap)\n ? options.pathMap.join(\",\")\n : Object.keys(options.pathMap ?? {}).join(\",\");\n options.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >\n ).withConfig({\n runName: `Branch<${options.source}${\n pathDisplayValues !== \"\" ? `,${pathDisplayValues}` : \"\"\n }>`.slice(0, 63),\n });\n }\n // find a name for condition\n const name =\n options.path.getName() === \"RunnableLambda\"\n ? \"condition\"\n : options.path.getName();\n // validate condition\n if (this.branches[options.source] && this.branches[options.source][name]) {\n throw new Error(\n `Condition \\`${name}\\` already present for node \\`${source}\\``\n );\n }\n // save it\n this.branches[options.source] ??= {};\n this.branches[options.source][name] = new Branch(options);\n return this;\n }\n\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(START, key);\n }\n\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(key, END);\n }\n\n compile({\n checkpointer,\n interruptBefore,\n interruptAfter,\n name,\n }: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n } = {}): CompiledGraph<N> {\n // validate the graph\n this.validate([\n ...(Array.isArray(interruptBefore) ? interruptBefore : []),\n ...(Array.isArray(interruptAfter) ? interruptAfter : []),\n ]);\n\n // create empty compiled graph\n const compiled = new CompiledGraph({\n builder: this,\n checkpointer,\n interruptAfter,\n interruptBefore,\n autoValidate: false,\n nodes: {} as Record<N | typeof START, PregelNode<RunInput, RunOutput>>,\n channels: {\n [START]: new EphemeralValue(),\n [END]: new EphemeralValue(),\n } as Record<N | typeof START | typeof END | string, BaseChannel>,\n inputChannels: START,\n outputChannels: END,\n streamChannels: [] as N[],\n streamMode: \"values\",\n name,\n });\n\n // attach nodes, edges and branches\n for (const [key, node] of Object.entries<NodeSpec<RunInput, RunOutput>>(\n this.nodes\n )) {\n compiled.attachNode(key as N, node);\n }\n for (const [start, end] of this.edges) {\n compiled.attachEdge(start, end);\n }\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const [name, branch] of Object.entries(branches)) {\n compiled.attachBranch(start as N, name, branch);\n }\n }\n\n return compiled.validate();\n }\n\n validate(interrupt?: string[]): void {\n // assemble sources\n const allSources = new Set([...this.allEdges].map(([src, _]) => src));\n for (const [start] of Object.entries(this.branches)) {\n allSources.add(start);\n }\n\n // validate sources\n for (const source of allSources) {\n if (source !== START && !(source in this.nodes)) {\n throw new Error(`Found edge starting at unknown node \\`${source}\\``);\n }\n }\n\n // assemble targets\n const allTargets = new Set([...this.allEdges].map(([_, target]) => target));\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const branch of Object.values(branches)) {\n if (branch.ends != null) {\n for (const end of Object.values(branch.ends)) {\n allTargets.add(end);\n }\n } else {\n allTargets.add(END);\n for (const node of Object.keys(this.nodes)) {\n if (node !== start) {\n allTargets.add(node);\n }\n }\n }\n }\n }\n for (const node of Object.values<NodeSpecType>(this.nodes)) {\n for (const target of node.ends ?? []) {\n allTargets.add(target);\n }\n }\n // validate targets\n for (const node of Object.keys(this.nodes)) {\n if (!allTargets.has(node)) {\n throw new UnreachableNodeError(\n [\n `Node \\`${node}\\` is not reachable.`,\n \"\",\n \"If you are returning Command objects from your node,\",\n 'make sure you are passing names of potential destination nodes as an \"ends\" array',\n 'into \".addNode(..., { ends: [\"node1\", \"node2\"] })\".',\n ].join(\"\\n\"),\n {\n lc_error_code: \"UNREACHABLE_NODE\",\n }\n );\n }\n }\n for (const target of allTargets) {\n if (target !== END && !(target in this.nodes)) {\n throw new Error(`Found edge ending at unknown node \\`${target}\\``);\n }\n }\n\n // validate interrupts\n if (interrupt) {\n for (const node of interrupt) {\n if (!(node in this.nodes)) {\n throw new Error(`Interrupt node \\`${node}\\` is not present`);\n }\n }\n }\n\n this.compiled = true;\n }\n}\n\nexport class CompiledGraph<\n N extends string,\n State = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Update = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n OutputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n NodeReturnType = unknown,\n CommandType = unknown,\n StreamCustomType = any // eslint-disable-line @typescript-eslint/no-explicit-any\n> extends Pregel<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>,\n ContextType & Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType,\n OutputType,\n InputType,\n OutputType,\n NodeReturnType,\n CommandType,\n StreamCustomType\n> {\n declare \"~NodeType\": N;\n\n declare \"~NodeReturnType\": NodeReturnType;\n\n declare \"~RunInput\": Update;\n\n declare \"~RunOutput\": State;\n\n builder: Graph<N, State, Update>;\n\n constructor({\n builder,\n ...rest\n }: { builder: Graph<N, State, Update> } & PregelParams<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>\n >) {\n super(rest);\n this.builder = builder;\n }\n\n attachNode(key: N, node: NodeSpec<State, Update>): void {\n this.channels[key] = new EphemeralValue();\n this.nodes[key] = new PregelNode({\n channels: [],\n triggers: [],\n metadata: node.metadata,\n subgraphs: node.subgraphs,\n ends: node.ends,\n })\n .pipe(node.runnable)\n .pipe(\n new ChannelWrite([{ channel: key, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n (this.streamChannels as N[]).push(key);\n }\n\n attachEdge(start: N | typeof START, end: N | typeof END): void {\n if (end === END) {\n if (start === START) {\n throw new Error(\"Cannot have an edge from START to END\");\n }\n this.nodes[start].writers.push(\n new ChannelWrite([{ channel: END, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n } else {\n this.nodes[end].triggers.push(start);\n (this.nodes[end].channels as string[]).push(start);\n }\n }\n\n attachBranch(\n start: N | typeof START,\n name: string,\n branch: Branch<State, N>\n ) {\n // add hidden start node\n if (start === START && !this.nodes[START]) {\n this.nodes[START] = Channel.subscribeTo(START, { tags: [TAG_HIDDEN] });\n }\n\n // attach branch writer\n this.nodes[start].pipe(\n branch.run((dests) => {\n const writes = dests.map((dest) => {\n if (_isSend(dest)) {\n return dest;\n }\n return {\n channel: dest === END ? END : `branch:${start}:${name}:${dest}`,\n value: PASSTHROUGH,\n };\n });\n return new ChannelWrite(writes, [TAG_HIDDEN]);\n })\n );\n\n // attach branch readers\n const ends = branch.ends\n ? Object.values(branch.ends)\n : (Object.keys(this.nodes) as N[]);\n for (const end of ends) {\n if (end !== END) {\n const channelName = `branch:${start}:${name}:${end}`;\n (this.channels as Record<string, BaseChannel>)[channelName] =\n new EphemeralValue();\n this.nodes[end].triggers.push(channelName);\n (this.nodes[end].channels as string[]).push(channelName);\n }\n }\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n */\n override async getGraphAsync(\n config?: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph> {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode({ schema: z.any() }, START),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n (await gatherIterator(this.getSubgraphsAsync())).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n if (startNodes[start] === undefined) {\n return;\n }\n if (endNodes[end] === undefined) {\n throw new Error(`End node ${end} not found!`);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? await subgraphs[key].getGraphAsync({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n for (const [key, node] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n if (node.ends !== undefined) {\n for (const end of node.ends) {\n addEdge(\n _escapeMermaidKeywords(key),\n _escapeMermaidKeywords(end),\n undefined,\n true\n );\n }\n }\n }\n return graph;\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n override getGraph(\n config?: RunnableConfig & { xray?: boolean | number }\n ): DrawableGraph {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode(\n {\n schema: z.any(),\n },\n START\n ),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n gatherIteratorSync(this.getSubgraphs()).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? subgraphs[key].getGraph({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n return graph;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isCompiledGraph(x: unknown): x is CompiledGraph<any> {\n return (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachNode === \"function\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachEdge === \"function\"\n );\n}\n\nfunction _escapeMermaidKeywords(key: string) {\n if (key === \"subgraph\") {\n return `\"${key}\"`;\n }\n return key;\n}\n"],"mappings":";;;;;;;;;;;;;;AAsEA,IAAa,SAAb,MAIE;CACA;CAEA;CAEA,YAAY,SAA4D;AACtE,MAAIA,mCAAS,WAAW,QAAQ,KAAK,CACnC,MAAK,OAAO,QAAQ;MAMpB,MAAK,wDACH,QAAQ,KAKT,CAAC,WAAW,EAAE,SAAS,UAAU,CAAgB;AAEpD,OAAK,OAAO,MAAM,QAAQ,QAAQ,QAAQ,GACtC,QAAQ,QAAQ,QAAQ,KAAK,MAAM;AACjC,OAAI,KAAK;AACT,UAAO;KACN,EAAE,CAAmC,GACxC,QAAQ;;CAGd,IACE,QAIA,QACA;AACA,SAAOC,2BAAa,eAClB,IAAIC,+BAAiB;GACnB,MAAM;GACN,OAAO;GACP,MAAM,OAAO,OAAW,WAAwB;AAC9C,QAAI;AACF,YAAO,MAAM,KAAK,OAAO,OAAO,QAAQ,QAAQ,OAAO;aAEhD,GAAQ;AAEf,SAAI,EAAE,SAASC,6BAAc,kBAC3B,SAAQ,KACN,qLAED;AAEH,WAAM;;;GAG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AAO,SAAS,OAClB,QAAO,OAAO;QAEd,QAAO;AAET,SAAK,MAAM,CAAC,OAAO,QAAQ,OAAO,QAAQ,KAAK,CAC7C,SACE,uBAAuB,MAAM,EAC7B,uBAAuB,IAAI,EAC3B,OACA,KACD;;;AAIP,SAAO;;;AAKX,SAAS,gBAAgB,GAAqC;AAC5D,QAEE,OAAQ,EAAyB,eAAe,cAEhD,OAAQ,EAAyB,eAAe;;AAIpD,SAAS,uBAAuB,KAAa;AAC3C,KAAI,QAAQ,WACV,QAAO,IAAI,IAAI;AAEjB,QAAO"}
1
+ {"version":3,"file":"graph.cjs","names":["Runnable","ChannelWrite","RunnableCallable","NodeInterrupt","_isSend","END","InvalidUpdateError","CHECKPOINT_NAMESPACE_SEPARATOR","CHECKPOINT_NAMESPACE_END","isPregelLike","START","EphemeralValue","UnreachableNodeError","Pregel","PregelNode","PASSTHROUGH","TAG_HIDDEN","Channel","DrawableGraph","z","gatherIterator","gatherIteratorSync"],"sources":["../../src/graph/graph.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-use-before-define */\nimport {\n _coerceToRunnable,\n Runnable,\n RunnableConfig,\n RunnableInterface,\n RunnableIOSchema,\n type RunnableLike as LangChainRunnableLike,\n} from \"@langchain/core/runnables\";\nimport {\n Node as DrawableGraphNode,\n Graph as DrawableGraph,\n} from \"@langchain/core/runnables/graph\";\nimport { All, BaseCheckpointSaver } from \"@langchain/langgraph-checkpoint\";\nimport { z } from \"zod/v4\";\nimport { validate as isUuid } from \"uuid\";\nimport type {\n RunnableLike,\n LangGraphRunnableConfig,\n} from \"../pregel/runnable_types.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { Channel, Pregel } from \"../pregel/index.js\";\nimport type { PregelParams } from \"../pregel/types.js\";\nimport { BaseChannel } from \"../channels/base.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\nimport {\n _isSend,\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n END,\n Send,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport {\n gatherIterator,\n gatherIteratorSync,\n RunnableCallable,\n} from \"../utils.js\";\nimport {\n InvalidUpdateError,\n NodeInterrupt,\n UnreachableNodeError,\n} from \"../errors.js\";\nimport { StateDefinition, StateType } from \"./annotation.js\";\nimport { isPregelLike } from \"../pregel/utils/subgraph.js\";\n\nexport interface BranchOptions<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n source: N;\n path: RunnableLike<IO, BranchPathReturnValue, CallOptions>;\n pathMap?: Record<string, N | typeof END> | (N | typeof END)[];\n}\n\nexport type BranchPathReturnValue =\n | string\n | Send\n | (string | Send)[]\n | Promise<string | Send | (string | Send)[]>;\n\ntype NodeAction<S, U, C extends StateDefinition> = RunnableLike<\n S,\n U extends object ? U & Record<string, any> : U, // eslint-disable-line @typescript-eslint/no-explicit-any\n LangGraphRunnableConfig<StateType<C>>\n>;\n\nexport class Branch<\n IO,\n N extends string,\n CallOptions extends LangGraphRunnableConfig = LangGraphRunnableConfig\n> {\n path: Runnable<IO, BranchPathReturnValue, CallOptions>;\n\n ends?: Record<string, N | typeof END>;\n\n constructor(options: Omit<BranchOptions<IO, N, CallOptions>, \"source\">) {\n if (Runnable.isRunnable(options.path)) {\n this.path = options.path as Runnable<\n IO,\n BranchPathReturnValue,\n CallOptions\n >;\n } else {\n this.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n IO,\n BranchPathReturnValue,\n CallOptions\n >\n ).withConfig({ runName: `Branch` } as CallOptions);\n }\n this.ends = Array.isArray(options.pathMap)\n ? options.pathMap.reduce((acc, n) => {\n acc[n] = n;\n return acc;\n }, {} as Record<string, N | typeof END>)\n : options.pathMap;\n }\n\n run(\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n ) {\n return ChannelWrite.registerWriter(\n new RunnableCallable({\n name: \"<branch_run>\",\n trace: false,\n func: async (input: IO, config: CallOptions) => {\n try {\n return await this._route(input, config, writer, reader);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n // Detect & warn if NodeInterrupt is thrown in a conditional edge\n if (e.name === NodeInterrupt.unminifiable_name) {\n console.warn(\n \"[WARN]: 'NodeInterrupt' thrown in conditional edge. This is likely a bug in your graph implementation.\\n\" +\n \"NodeInterrupt should only be thrown inside a node, not in edge conditions.\"\n );\n }\n throw e;\n }\n },\n })\n );\n }\n\n async _route(\n input: IO,\n config: CallOptions,\n writer: (\n dests: (string | Send)[],\n config: LangGraphRunnableConfig\n ) => Runnable | void | Promise<void>,\n reader?: (config: CallOptions) => IO\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ): Promise<Runnable | any> {\n let result = await this.path.invoke(\n reader ? reader(config) : input,\n config\n );\n if (!Array.isArray(result)) {\n result = [result];\n }\n\n let destinations: (string | Send)[];\n if (this.ends) {\n destinations = result.map((r) => (_isSend(r) ? r : this.ends![r]));\n } else {\n destinations = result;\n }\n if (destinations.some((dest) => !dest)) {\n throw new Error(\"Branch condition returned unknown or null destination\");\n }\n if (destinations.filter(_isSend).some((packet) => packet.node === END)) {\n throw new InvalidUpdateError(\"Cannot send a packet to the END node\");\n }\n const writeResult = await writer(destinations, config);\n return writeResult ?? input;\n }\n}\n\nexport type NodeSpec<RunInput, RunOutput> = {\n runnable: Runnable<RunInput, RunOutput>;\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: string[];\n defer?: boolean;\n};\n\nexport type AddNodeOptions<Nodes extends string = string> = {\n metadata?: Record<string, unknown>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n subgraphs?: Pregel<any, any>[];\n ends?: Nodes[];\n defer?: boolean;\n};\n\nexport class Graph<\n N extends string = typeof START | typeof END,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunInput = any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n RunOutput = any,\n NodeSpecType extends NodeSpec<RunInput, RunOutput> = NodeSpec<\n RunInput,\n RunOutput\n >,\n C extends StateDefinition = StateDefinition\n> {\n nodes: Record<N, NodeSpecType>;\n\n edges: Set<[N | typeof START, N | typeof END]>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n branches: Record<string, Record<string, Branch<RunInput, N, any>>>;\n\n entryPoint?: string;\n\n compiled = false;\n\n constructor() {\n this.nodes = {} as Record<N, NodeSpecType>;\n this.edges = new Set();\n this.branches = {};\n }\n\n protected warnIfCompiled(message: string): void {\n if (this.compiled) {\n console.warn(message);\n }\n }\n\n get allEdges(): Set<[string, string]> {\n return this.edges;\n }\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ): Graph<N | K, RunInput, RunOutput>;\n\n addNode<K extends string, NodeInput = RunInput, NodeOutput = RunOutput>(\n ...args:\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ]\n | [\n nodes:\n | Record<K, NodeAction<NodeInput, NodeOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, NodeOutput, C>,\n options?: AddNodeOptions\n ][]\n ]\n ): Graph<N | K, RunInput, RunOutput> {\n function isMutlipleNodes(\n args: unknown[]\n ): args is [\n nodes:\n | Record<K, NodeAction<NodeInput, RunOutput, C>>\n | [\n key: K,\n action: NodeAction<NodeInput, RunOutput, C>,\n options?: AddNodeOptions\n ][],\n options?: AddNodeOptions\n ] {\n return args.length >= 1 && typeof args[0] !== \"string\";\n }\n\n const nodes = (\n isMutlipleNodes(args) // eslint-disable-line no-nested-ternary\n ? Array.isArray(args[0])\n ? args[0]\n : Object.entries(args[0])\n : [[args[0], args[1], args[2]]]\n ) as [K, NodeAction<NodeInput, RunOutput, C>, AddNodeOptions][];\n\n if (nodes.length === 0) {\n throw new Error(\"No nodes provided in `addNode`\");\n }\n\n for (const [key, action, options] of nodes) {\n for (const reservedChar of [\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CHECKPOINT_NAMESPACE_END,\n ]) {\n if (key.includes(reservedChar)) {\n throw new Error(\n `\"${reservedChar}\" is a reserved character and is not allowed in node names.`\n );\n }\n }\n this.warnIfCompiled(\n `Adding a node to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (key in this.nodes) {\n throw new Error(`Node \\`${key}\\` already present.`);\n }\n if (key === END) {\n throw new Error(`Node \\`${key}\\` is reserved.`);\n }\n\n const runnable = _coerceToRunnable<RunInput, RunOutput>(\n // Account for arbitrary state due to Send API\n action as RunnableLike<RunInput, RunOutput>\n );\n\n this.nodes[key as unknown as N] = {\n runnable,\n metadata: options?.metadata,\n subgraphs: isPregelLike(runnable) ? [runnable] : options?.subgraphs,\n ends: options?.ends,\n } as NodeSpecType;\n }\n\n return this as Graph<N | K, RunInput, RunOutput, NodeSpecType>;\n }\n\n addEdge(startKey: N | typeof START, endKey: N | typeof END): this {\n this.warnIfCompiled(\n `Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.`\n );\n\n if (startKey === END) {\n throw new Error(\"END cannot be a start node\");\n }\n if (endKey === START) {\n throw new Error(\"START cannot be an end node\");\n }\n if (\n Array.from(this.edges).some(([start]) => start === startKey) &&\n !(\"channels\" in this)\n ) {\n throw new Error(\n `Already found path for ${startKey}. For multiple edges, use StateGraph.`\n );\n }\n\n this.edges.add([startKey, endKey]);\n\n return this;\n }\n\n addConditionalEdges(\n source: BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>\n ): this;\n\n addConditionalEdges(\n source: N,\n path: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this;\n\n addConditionalEdges(\n source:\n | N\n | BranchOptions<RunInput, N, LangGraphRunnableConfig<StateType<C>>>,\n path?: RunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >,\n pathMap?: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n >[\"pathMap\"]\n ): this {\n const options: BranchOptions<\n RunInput,\n N,\n LangGraphRunnableConfig<StateType<C>>\n > = typeof source === \"object\" ? source : { source, path: path!, pathMap };\n\n this.warnIfCompiled(\n \"Adding an edge to a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n if (!Runnable.isRunnable(options.path)) {\n const pathDisplayValues = Array.isArray(options.pathMap)\n ? options.pathMap.join(\",\")\n : Object.keys(options.pathMap ?? {}).join(\",\");\n options.path = _coerceToRunnable(\n options.path as LangChainRunnableLike<\n RunInput,\n BranchPathReturnValue,\n LangGraphRunnableConfig<StateType<C>>\n >\n ).withConfig({\n runName: `Branch<${options.source}${\n pathDisplayValues !== \"\" ? `,${pathDisplayValues}` : \"\"\n }>`.slice(0, 63),\n });\n }\n // find a name for condition\n const name =\n options.path.getName() === \"RunnableLambda\"\n ? \"condition\"\n : options.path.getName();\n // validate condition\n if (this.branches[options.source] && this.branches[options.source][name]) {\n throw new Error(\n `Condition \\`${name}\\` already present for node \\`${source}\\``\n );\n }\n // save it\n this.branches[options.source] ??= {};\n this.branches[options.source][name] = new Branch(options);\n return this;\n }\n\n /**\n * @deprecated use `addEdge(START, key)` instead\n */\n setEntryPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting the entry point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(START, key);\n }\n\n /**\n * @deprecated use `addEdge(key, END)` instead\n */\n setFinishPoint(key: N): this {\n this.warnIfCompiled(\n \"Setting a finish point of a graph that has already been compiled. This will not be reflected in the compiled graph.\"\n );\n\n return this.addEdge(key, END);\n }\n\n compile({\n checkpointer,\n interruptBefore,\n interruptAfter,\n name,\n }: {\n checkpointer?: BaseCheckpointSaver | false;\n interruptBefore?: N[] | All;\n interruptAfter?: N[] | All;\n name?: string;\n } = {}): CompiledGraph<N> {\n // validate the graph\n this.validate([\n ...(Array.isArray(interruptBefore) ? interruptBefore : []),\n ...(Array.isArray(interruptAfter) ? interruptAfter : []),\n ]);\n\n // create empty compiled graph\n const compiled = new CompiledGraph({\n builder: this,\n checkpointer,\n interruptAfter,\n interruptBefore,\n autoValidate: false,\n nodes: {} as Record<N | typeof START, PregelNode<RunInput, RunOutput>>,\n channels: {\n [START]: new EphemeralValue(),\n [END]: new EphemeralValue(),\n } as Record<N | typeof START | typeof END | string, BaseChannel>,\n inputChannels: START,\n outputChannels: END,\n streamChannels: [] as N[],\n streamMode: \"values\",\n name,\n });\n\n // attach nodes, edges and branches\n for (const [key, node] of Object.entries<NodeSpec<RunInput, RunOutput>>(\n this.nodes\n )) {\n compiled.attachNode(key as N, node);\n }\n for (const [start, end] of this.edges) {\n compiled.attachEdge(start, end);\n }\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const [name, branch] of Object.entries(branches)) {\n compiled.attachBranch(start as N, name, branch);\n }\n }\n\n return compiled.validate();\n }\n\n validate(interrupt?: string[]): void {\n // assemble sources\n const allSources = new Set([...this.allEdges].map(([src, _]) => src));\n for (const [start] of Object.entries(this.branches)) {\n allSources.add(start);\n }\n\n // validate sources\n for (const source of allSources) {\n if (source !== START && !(source in this.nodes)) {\n throw new Error(`Found edge starting at unknown node \\`${source}\\``);\n }\n }\n\n // assemble targets\n const allTargets = new Set([...this.allEdges].map(([_, target]) => target));\n for (const [start, branches] of Object.entries(this.branches)) {\n for (const branch of Object.values(branches)) {\n if (branch.ends != null) {\n for (const end of Object.values(branch.ends)) {\n allTargets.add(end);\n }\n } else {\n allTargets.add(END);\n for (const node of Object.keys(this.nodes)) {\n if (node !== start) {\n allTargets.add(node);\n }\n }\n }\n }\n }\n for (const node of Object.values<NodeSpecType>(this.nodes)) {\n for (const target of node.ends ?? []) {\n allTargets.add(target);\n }\n }\n // validate targets\n for (const node of Object.keys(this.nodes)) {\n if (!allTargets.has(node)) {\n throw new UnreachableNodeError(\n [\n `Node \\`${node}\\` is not reachable.`,\n \"\",\n \"If you are returning Command objects from your node,\",\n 'make sure you are passing names of potential destination nodes as an \"ends\" array',\n 'into \".addNode(..., { ends: [\"node1\", \"node2\"] })\".',\n ].join(\"\\n\"),\n {\n lc_error_code: \"UNREACHABLE_NODE\",\n }\n );\n }\n }\n for (const target of allTargets) {\n if (target !== END && !(target in this.nodes)) {\n throw new Error(`Found edge ending at unknown node \\`${target}\\``);\n }\n }\n\n // validate interrupts\n if (interrupt) {\n for (const node of interrupt) {\n if (!(node in this.nodes)) {\n throw new Error(`Interrupt node \\`${node}\\` is not present`);\n }\n }\n }\n\n this.compiled = true;\n }\n}\n\nexport class CompiledGraph<\n N extends string,\n State = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Update = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n ContextType extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n OutputType = any, // eslint-disable-line @typescript-eslint/no-explicit-any\n NodeReturnType = unknown,\n CommandType = unknown,\n StreamCustomType = any // eslint-disable-line @typescript-eslint/no-explicit-any\n> extends Pregel<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>,\n ContextType & Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any\n InputType,\n OutputType,\n InputType,\n OutputType,\n NodeReturnType,\n CommandType,\n StreamCustomType\n> {\n declare \"~NodeType\": N;\n\n declare \"~NodeReturnType\": NodeReturnType;\n\n declare \"~RunInput\": Update;\n\n declare \"~RunOutput\": State;\n\n builder: Graph<N, State, Update>;\n\n constructor({\n builder,\n ...rest\n }: { builder: Graph<N, State, Update> } & PregelParams<\n Record<N | typeof START, PregelNode<State, Update>>,\n Record<N | typeof START | typeof END | string, BaseChannel>\n >) {\n super(rest);\n this.builder = builder;\n }\n\n attachNode(key: N, node: NodeSpec<State, Update>): void {\n this.channels[key] = new EphemeralValue();\n this.nodes[key] = new PregelNode({\n channels: [],\n triggers: [],\n metadata: node.metadata,\n subgraphs: node.subgraphs,\n ends: node.ends,\n })\n .pipe(node.runnable)\n .pipe(\n new ChannelWrite([{ channel: key, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n (this.streamChannels as N[]).push(key);\n }\n\n attachEdge(start: N | typeof START, end: N | typeof END): void {\n if (end === END) {\n if (start === START) {\n throw new Error(\"Cannot have an edge from START to END\");\n }\n this.nodes[start].writers.push(\n new ChannelWrite([{ channel: END, value: PASSTHROUGH }], [TAG_HIDDEN])\n );\n } else {\n this.nodes[end].triggers.push(start);\n (this.nodes[end].channels as string[]).push(start);\n }\n }\n\n attachBranch(\n start: N | typeof START,\n name: string,\n branch: Branch<State, N>\n ) {\n // add hidden start node\n if (start === START && !this.nodes[START]) {\n this.nodes[START] = Channel.subscribeTo(START, { tags: [TAG_HIDDEN] });\n }\n\n // attach branch writer\n this.nodes[start].pipe(\n branch.run((dests) => {\n const writes = dests.map((dest) => {\n if (_isSend(dest)) {\n return dest;\n }\n return {\n channel: dest === END ? END : `branch:${start}:${name}:${dest}`,\n value: PASSTHROUGH,\n };\n });\n return new ChannelWrite(writes, [TAG_HIDDEN]);\n })\n );\n\n // attach branch readers\n const ends = branch.ends\n ? Object.values(branch.ends)\n : (Object.keys(this.nodes) as N[]);\n for (const end of ends) {\n if (end !== END) {\n const channelName = `branch:${start}:${name}:${end}`;\n (this.channels as Record<string, BaseChannel>)[channelName] =\n new EphemeralValue();\n this.nodes[end].triggers.push(channelName);\n (this.nodes[end].channels as string[]).push(channelName);\n }\n }\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n */\n override async getGraphAsync(\n config?: RunnableConfig & { xray?: boolean | number }\n ): Promise<DrawableGraph> {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode({ schema: z.any() }, START),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n (await gatherIterator(this.getSubgraphsAsync())).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n if (startNodes[start] === undefined) {\n return;\n }\n if (endNodes[end] === undefined) {\n throw new Error(`End node ${end} not found!`);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? await subgraphs[key].getGraphAsync({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n for (const [key, node] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n if (node.ends !== undefined) {\n for (const end of node.ends) {\n addEdge(\n _escapeMermaidKeywords(key),\n _escapeMermaidKeywords(end),\n undefined,\n true\n );\n }\n }\n }\n return graph;\n }\n\n /**\n * Returns a drawable representation of the computation graph.\n *\n * @deprecated Use getGraphAsync instead. The async method will be the default in the next minor core release.\n */\n override getGraph(\n config?: RunnableConfig & { xray?: boolean | number }\n ): DrawableGraph {\n const xray = config?.xray;\n const graph = new DrawableGraph();\n const startNodes: Record<string, DrawableGraphNode> = {\n [START]: graph.addNode(\n {\n schema: z.any(),\n },\n START\n ),\n };\n const endNodes: Record<string, DrawableGraphNode> = {};\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let subgraphs: Record<string, CompiledGraph<any>> = {};\n if (xray) {\n subgraphs = Object.fromEntries(\n gatherIteratorSync(this.getSubgraphs()).filter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (x): x is [string, CompiledGraph<any>] => isCompiledGraph(x[1])\n )\n );\n }\n\n function addEdge(\n start: string,\n end: string,\n label?: string,\n conditional = false\n ) {\n if (end === END && endNodes[END] === undefined) {\n endNodes[END] = graph.addNode({ schema: z.any() }, END);\n }\n return graph.addEdge(\n startNodes[start],\n endNodes[end],\n label !== end ? label : undefined,\n conditional\n );\n }\n\n for (const [key, nodeSpec] of Object.entries(this.builder.nodes) as [\n N,\n NodeSpec<State, Update>\n ][]) {\n const displayKey = _escapeMermaidKeywords(key);\n const node = nodeSpec.runnable;\n const metadata = nodeSpec.metadata ?? {};\n if (\n this.interruptBefore?.includes(key) &&\n this.interruptAfter?.includes(key)\n ) {\n metadata.__interrupt = \"before,after\";\n } else if (this.interruptBefore?.includes(key)) {\n metadata.__interrupt = \"before\";\n } else if (this.interruptAfter?.includes(key)) {\n metadata.__interrupt = \"after\";\n }\n if (xray) {\n const newXrayValue = typeof xray === \"number\" ? xray - 1 : xray;\n const drawableSubgraph =\n subgraphs[key] !== undefined\n ? subgraphs[key].getGraph({\n ...config,\n xray: newXrayValue,\n })\n : node.getGraph(config);\n drawableSubgraph.trimFirstNode();\n drawableSubgraph.trimLastNode();\n if (Object.keys(drawableSubgraph.nodes).length > 1) {\n const [e, s] = graph.extend(drawableSubgraph, displayKey);\n if (e === undefined) {\n throw new Error(\n `Could not extend subgraph \"${key}\" due to missing entrypoint.`\n );\n }\n\n // TODO: Remove default name once we stop supporting core 0.2.0\n // eslint-disable-next-line no-inner-declarations\n function _isRunnableInterface(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n thing: any\n ): thing is RunnableInterface {\n return thing ? thing.lc_runnable : false;\n }\n // eslint-disable-next-line no-inner-declarations\n function _nodeDataStr(\n id: string | undefined,\n data: RunnableInterface | RunnableIOSchema\n ): string {\n if (id !== undefined && !isUuid(id)) {\n return id;\n } else if (_isRunnableInterface(data)) {\n try {\n let dataStr = data.getName();\n dataStr = dataStr.startsWith(\"Runnable\")\n ? dataStr.slice(\"Runnable\".length)\n : dataStr;\n return dataStr;\n } catch (error) {\n return data.getName();\n }\n } else {\n return data.name ?? \"UnknownSchema\";\n }\n }\n // TODO: Remove casts when we stop supporting core 0.2.0\n if (s !== undefined) {\n startNodes[displayKey] = {\n name: _nodeDataStr(s.id, s.data),\n ...s,\n } as DrawableGraphNode;\n }\n endNodes[displayKey] = {\n name: _nodeDataStr(e.id, e.data),\n ...e,\n } as DrawableGraphNode;\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n } else {\n // TODO: Remove when we stop supporting core 0.2.0\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n const newNode = graph.addNode(node, displayKey, metadata);\n startNodes[displayKey] = newNode;\n endNodes[displayKey] = newNode;\n }\n }\n const sortedEdges = [...this.builder.allEdges].sort(([a], [b]) => {\n if (a < b) {\n return -1;\n } else if (b > a) {\n return 1;\n } else {\n return 0;\n }\n });\n for (const [start, end] of sortedEdges) {\n addEdge(_escapeMermaidKeywords(start), _escapeMermaidKeywords(end));\n }\n for (const [start, branches] of Object.entries(this.builder.branches)) {\n const defaultEnds: Record<string, string> = {\n ...Object.fromEntries(\n Object.keys(this.builder.nodes)\n .filter((k) => k !== start)\n .map((k) => [_escapeMermaidKeywords(k), _escapeMermaidKeywords(k)])\n ),\n [END]: END,\n };\n for (const branch of Object.values(branches)) {\n let ends;\n if (branch.ends !== undefined) {\n ends = branch.ends;\n } else {\n ends = defaultEnds;\n }\n for (const [label, end] of Object.entries(ends)) {\n addEdge(\n _escapeMermaidKeywords(start),\n _escapeMermaidKeywords(end),\n label,\n true\n );\n }\n }\n }\n return graph;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isCompiledGraph(x: unknown): x is CompiledGraph<any> {\n return (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachNode === \"function\" &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (x as CompiledGraph<any>).attachEdge === \"function\"\n );\n}\n\nfunction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;;UAEpB;IAIL,MAAM,UAAU,MAAM,QAAQ,MAAM,YAAY,SAAS;AACzD,eAAW,cAAc;AACzB,aAAS,cAAc;;;EAG3B,MAAM,cAAc,CAAC,GAAG,KAAK,QAAQ,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO;AAChE,OAAI,IAAI,EACN,QAAO;YACE,IAAI,EACb,QAAO;OAEP,QAAO;IAET;AACF,OAAK,MAAM,CAAC,OAAO,QAAQ,YACzB,SAAQ,uBAAuB,MAAM,EAAE,uBAAuB,IAAI,CAAC;AAErE,OAAK,MAAM,CAAC,OAAO,aAAa,OAAO,QAAQ,KAAK,QAAQ,SAAS,EAAE;GACrE,MAAM,cAAsC;IAC1C,GAAG,OAAO,YACR,OAAO,KAAK,KAAK,QAAQ,MAAM,CAC5B,QAAQ,MAAM,MAAM,MAAM,CAC1B,KAAK,MAAM,CAAC,uBAAuB,EAAE,EAAE,uBAAuB,EAAE,CAAC,CAAC,CACtE;KACAA,wBAAMA;IACR;AACD,QAAK,MAAM,UAAU,OAAO,OAAO,SAAS,EAAE;IAC5C,IAAI;AACJ,QAAI,OAAO,SAAS,OAClB,QAAO,OAAO;QAEd,QAAO;AAET,SAAK,MAAM,CAAC,OAAO,QAAQ,OAAO,QAAQ,KAAK,CAC7C,SACE,uBAAuB,MAAM,EAC7B,uBAAuB,IAAI,EAC3B,OACA,KACD;;;AAIP,SAAO;;;AAKX,SAAS,gBAAgB,GAAqC;AAC5D,QAEE,OAAQ,EAAyB,eAAe,cAEhD,OAAQ,EAAyB,eAAe;;AAIpD,SAAS,uBAAuB,KAAa;AAC3C,KAAI,QAAQ,WACV,QAAO,IAAI,IAAI;AAEjB,QAAO"}
@@ -66,8 +66,8 @@ var Graph$1 = class {
66
66
  return this.edges;
67
67
  }
68
68
  addNode(...args) {
69
- function isMutlipleNodes(args$1) {
70
- return args$1.length >= 1 && typeof args$1[0] !== "string";
69
+ function isMutlipleNodes(args) {
70
+ return args.length >= 1 && typeof args[0] !== "string";
71
71
  }
72
72
  const nodes = isMutlipleNodes(args) ? Array.isArray(args[0]) ? args[0] : Object.entries(args[0]) : [[
73
73
  args[0],
@@ -150,7 +150,7 @@ var Graph$1 = class {
150
150
  });
151
151
  for (const [key, node] of Object.entries(this.nodes)) compiled.attachNode(key, node);
152
152
  for (const [start, end] of this.edges) compiled.attachEdge(start, end);
153
- for (const [start, branches] of Object.entries(this.branches)) for (const [name$1, branch] of Object.entries(branches)) compiled.attachBranch(start, name$1, branch);
153
+ for (const [start, branches] of Object.entries(this.branches)) for (const [name, branch] of Object.entries(branches)) compiled.attachBranch(start, name, branch);
154
154
  return compiled.validate();
155
155
  }
156
156
  validate(interrupt) {