@langchain/langgraph 1.0.7 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels/any_value.cjs.map +1 -1
- package/dist/channels/any_value.d.cts +0 -1
- package/dist/channels/any_value.d.cts.map +1 -1
- package/dist/channels/any_value.d.ts +0 -1
- package/dist/channels/any_value.d.ts.map +1 -1
- package/dist/channels/any_value.js.map +1 -1
- package/dist/channels/base.cjs +2 -3
- package/dist/channels/base.cjs.map +1 -1
- package/dist/channels/base.d.cts.map +1 -1
- package/dist/channels/base.d.ts.map +1 -1
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/binop.cjs.map +1 -1
- package/dist/channels/binop.d.cts.map +1 -1
- package/dist/channels/binop.d.ts.map +1 -1
- package/dist/channels/binop.js.map +1 -1
- package/dist/channels/dynamic_barrier_value.cjs +0 -1
- package/dist/channels/dynamic_barrier_value.cjs.map +1 -1
- package/dist/channels/dynamic_barrier_value.d.cts +1 -3
- package/dist/channels/dynamic_barrier_value.d.cts.map +1 -1
- package/dist/channels/dynamic_barrier_value.d.ts +1 -3
- package/dist/channels/dynamic_barrier_value.d.ts.map +1 -1
- package/dist/channels/dynamic_barrier_value.js +0 -1
- package/dist/channels/dynamic_barrier_value.js.map +1 -1
- package/dist/channels/ephemeral_value.cjs.map +1 -1
- package/dist/channels/ephemeral_value.d.cts +0 -1
- package/dist/channels/ephemeral_value.d.cts.map +1 -1
- package/dist/channels/ephemeral_value.d.ts +0 -1
- package/dist/channels/ephemeral_value.d.ts.map +1 -1
- package/dist/channels/ephemeral_value.js.map +1 -1
- package/dist/channels/last_value.cjs.map +1 -1
- package/dist/channels/last_value.d.cts +0 -2
- package/dist/channels/last_value.d.cts.map +1 -1
- package/dist/channels/last_value.d.ts +0 -2
- package/dist/channels/last_value.d.ts.map +1 -1
- package/dist/channels/last_value.js.map +1 -1
- package/dist/channels/named_barrier_value.cjs +0 -2
- package/dist/channels/named_barrier_value.cjs.map +1 -1
- package/dist/channels/named_barrier_value.d.cts +2 -4
- package/dist/channels/named_barrier_value.d.cts.map +1 -1
- package/dist/channels/named_barrier_value.d.ts +2 -4
- package/dist/channels/named_barrier_value.d.ts.map +1 -1
- package/dist/channels/named_barrier_value.js +0 -2
- package/dist/channels/named_barrier_value.js.map +1 -1
- package/dist/channels/topic.cjs.map +1 -1
- package/dist/channels/topic.d.cts.map +1 -1
- package/dist/channels/topic.d.ts.map +1 -1
- package/dist/channels/topic.js.map +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +2 -6
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +2 -6
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +0 -4
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.ts +0 -4
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +2 -4
- package/dist/func/index.cjs.map +1 -1
- package/dist/func/index.d.cts +1 -6
- package/dist/func/index.d.cts.map +1 -1
- package/dist/func/index.d.ts +1 -6
- package/dist/func/index.d.ts.map +1 -1
- package/dist/func/index.js +1 -2
- package/dist/func/index.js.map +1 -1
- package/dist/func/types.d.cts +2 -4
- package/dist/func/types.d.cts.map +1 -1
- package/dist/func/types.d.ts +2 -4
- package/dist/func/types.d.ts.map +1 -1
- package/dist/graph/annotation.cjs.map +1 -1
- package/dist/graph/annotation.d.cts.map +1 -1
- package/dist/graph/annotation.d.ts.map +1 -1
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +15 -18
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.d.cts +4 -28
- package/dist/graph/graph.d.cts.map +1 -1
- package/dist/graph/graph.d.ts +4 -28
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +4 -6
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/message.cjs +8 -10
- package/dist/graph/message.cjs.map +1 -1
- package/dist/graph/message.d.cts +2 -2
- package/dist/graph/message.d.cts.map +1 -1
- package/dist/graph/message.d.ts +2 -2
- package/dist/graph/message.d.ts.map +1 -1
- package/dist/graph/message.js +3 -4
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/messages_annotation.cjs +1 -2
- package/dist/graph/messages_annotation.cjs.map +1 -1
- package/dist/graph/messages_annotation.d.cts +5 -5
- package/dist/graph/messages_annotation.d.cts.map +1 -1
- package/dist/graph/messages_annotation.d.ts +5 -5
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/messages_annotation.js.map +1 -1
- package/dist/graph/state.cjs +23 -30
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.d.cts +2 -9
- package/dist/graph/state.d.cts.map +1 -1
- package/dist/graph/state.d.ts +2 -9
- package/dist/graph/state.d.ts.map +1 -1
- package/dist/graph/state.js +6 -12
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/zod/meta.cjs +8 -9
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.d.cts +0 -1
- package/dist/graph/zod/meta.d.cts.map +1 -1
- package/dist/graph/zod/meta.d.ts +0 -1
- package/dist/graph/zod/meta.d.ts.map +1 -1
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/plugin.cjs +4 -6
- package/dist/graph/zod/plugin.cjs.map +1 -1
- package/dist/graph/zod/plugin.js +1 -2
- package/dist/graph/zod/plugin.js.map +1 -1
- package/dist/graph/zod/schema.cjs +2 -3
- package/dist/graph/zod/schema.cjs.map +1 -1
- package/dist/graph/zod/schema.d.cts.map +1 -1
- package/dist/graph/zod/schema.d.ts.map +1 -1
- package/dist/graph/zod/schema.js.map +1 -1
- package/dist/graph/zod/zod-registry.cjs +3 -4
- package/dist/graph/zod/zod-registry.cjs.map +1 -1
- package/dist/graph/zod/zod-registry.d.cts +0 -2
- package/dist/graph/zod/zod-registry.d.cts.map +1 -1
- package/dist/graph/zod/zod-registry.d.ts +0 -2
- package/dist/graph/zod/zod-registry.d.ts.map +1 -1
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/hash.cjs +4 -10
- package/dist/hash.cjs.map +1 -1
- package/dist/hash.js +4 -10
- package/dist/hash.js.map +1 -1
- package/dist/index.cjs +8 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interrupt.cjs +4 -7
- package/dist/interrupt.cjs.map +1 -1
- package/dist/interrupt.d.cts +1 -4
- package/dist/interrupt.d.cts.map +1 -1
- package/dist/interrupt.d.ts +1 -4
- package/dist/interrupt.d.ts.map +1 -1
- package/dist/interrupt.js +2 -4
- package/dist/interrupt.js.map +1 -1
- package/dist/prebuilt/agentName.cjs +14 -19
- package/dist/prebuilt/agentName.cjs.map +1 -1
- package/dist/prebuilt/agentName.js +6 -10
- package/dist/prebuilt/agentName.js.map +1 -1
- package/dist/prebuilt/agent_executor.cjs +4 -7
- package/dist/prebuilt/agent_executor.cjs.map +1 -1
- package/dist/prebuilt/agent_executor.d.cts +5 -5
- package/dist/prebuilt/agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/agent_executor.d.ts +5 -5
- package/dist/prebuilt/agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/agent_executor.js +4 -7
- package/dist/prebuilt/agent_executor.js.map +1 -1
- package/dist/prebuilt/chat_agent_executor.cjs +11 -17
- package/dist/prebuilt/chat_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/chat_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/chat_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/chat_agent_executor.js +7 -12
- package/dist/prebuilt/chat_agent_executor.js.map +1 -1
- package/dist/prebuilt/interrupt.d.cts +0 -1
- package/dist/prebuilt/interrupt.d.cts.map +1 -1
- package/dist/prebuilt/interrupt.d.ts +0 -1
- package/dist/prebuilt/interrupt.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.cjs +35 -40
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts +8 -27
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +8 -27
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.js +8 -12
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_executor.cjs +4 -9
- package/dist/prebuilt/tool_executor.cjs.map +1 -1
- package/dist/prebuilt/tool_executor.d.cts +0 -2
- package/dist/prebuilt/tool_executor.d.cts.map +1 -1
- package/dist/prebuilt/tool_executor.d.ts +0 -2
- package/dist/prebuilt/tool_executor.d.ts.map +1 -1
- package/dist/prebuilt/tool_executor.js +1 -5
- package/dist/prebuilt/tool_executor.js.map +1 -1
- package/dist/prebuilt/tool_node.cjs +7 -8
- package/dist/prebuilt/tool_node.cjs.map +1 -1
- package/dist/prebuilt/tool_node.d.cts +0 -2
- package/dist/prebuilt/tool_node.d.cts.map +1 -1
- package/dist/prebuilt/tool_node.d.ts +0 -2
- package/dist/prebuilt/tool_node.d.ts.map +1 -1
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/dist/pregel/algo.cjs +33 -41
- package/dist/pregel/algo.cjs.map +1 -1
- package/dist/pregel/algo.d.cts.map +1 -1
- package/dist/pregel/algo.d.ts.map +1 -1
- package/dist/pregel/algo.js +22 -29
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/call.cjs +11 -14
- package/dist/pregel/call.cjs.map +1 -1
- package/dist/pregel/call.js +7 -9
- package/dist/pregel/call.js.map +1 -1
- package/dist/pregel/debug.cjs +6 -9
- package/dist/pregel/debug.cjs.map +1 -1
- package/dist/pregel/debug.js +6 -9
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/index.cjs +28 -35
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts +6 -54
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts +6 -54
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +10 -16
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/io.cjs.map +1 -1
- package/dist/pregel/io.js.map +1 -1
- package/dist/pregel/loop.cjs +9 -12
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +2 -4
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages.cjs +13 -14
- package/dist/pregel/messages.cjs.map +1 -1
- package/dist/pregel/messages.js.map +1 -1
- package/dist/pregel/read.cjs +7 -8
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.cts +0 -6
- package/dist/pregel/read.d.cts.map +1 -1
- package/dist/pregel/read.d.ts +0 -6
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js +1 -1
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs +24 -32
- package/dist/pregel/remote.cjs.map +1 -1
- package/dist/pregel/remote.d.cts +1 -6
- package/dist/pregel/remote.d.cts.map +1 -1
- package/dist/pregel/remote.d.ts +1 -6
- package/dist/pregel/remote.d.ts.map +1 -1
- package/dist/pregel/remote.js +12 -19
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/retry.cjs +1 -2
- package/dist/pregel/retry.cjs.map +1 -1
- package/dist/pregel/retry.js +1 -2
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runnable_types.d.cts +2 -8
- package/dist/pregel/runnable_types.d.cts.map +1 -1
- package/dist/pregel/runnable_types.d.ts +2 -8
- package/dist/pregel/runnable_types.d.ts.map +1 -1
- package/dist/pregel/runner.cjs +1 -1
- package/dist/pregel/runner.cjs.map +1 -1
- package/dist/pregel/runner.js +1 -1
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/stream.cjs +4 -6
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.js +1 -2
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.d.cts +5 -18
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts +5 -18
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/utils/config.cjs +6 -7
- package/dist/pregel/utils/config.cjs.map +1 -1
- package/dist/pregel/utils/config.d.cts.map +1 -1
- package/dist/pregel/utils/config.d.ts.map +1 -1
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +1 -2
- package/dist/pregel/utils/index.cjs.map +1 -1
- package/dist/pregel/utils/index.d.cts +1 -1
- package/dist/pregel/utils/index.d.cts.map +1 -1
- package/dist/pregel/utils/index.d.ts +1 -1
- package/dist/pregel/utils/index.d.ts.map +1 -1
- package/dist/pregel/utils/index.js +1 -2
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/pregel/utils/subgraph.cjs +0 -1
- package/dist/pregel/utils/subgraph.cjs.map +1 -1
- package/dist/pregel/utils/subgraph.js +0 -1
- package/dist/pregel/utils/subgraph.js.map +1 -1
- package/dist/pregel/validate.cjs.map +1 -1
- package/dist/pregel/validate.js.map +1 -1
- package/dist/pregel/write.cjs +2 -3
- package/dist/pregel/write.cjs.map +1 -1
- package/dist/pregel/write.d.cts +1 -5
- package/dist/pregel/write.d.cts.map +1 -1
- package/dist/pregel/write.d.ts +1 -5
- package/dist/pregel/write.d.ts.map +1 -1
- package/dist/pregel/write.js.map +1 -1
- package/dist/setup/async_local_storage.cjs +3 -4
- package/dist/setup/async_local_storage.cjs.map +1 -1
- package/dist/setup/async_local_storage.js.map +1 -1
- package/dist/utils.cjs +9 -11
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +1 -8
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.ts +1 -8
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -2
- package/dist/utils.js.map +1 -1
- package/dist/web.cjs +8 -9
- package/dist/writer.cjs +2 -3
- package/dist/writer.cjs.map +1 -1
- package/dist/writer.d.cts +1 -2
- package/dist/writer.d.cts.map +1 -1
- package/dist/writer.d.ts +1 -2
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js.map +1 -1
- package/package.json +7 -7
- package/CHANGELOG.md +0 -286
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":["PendingWrite","START","END","INPUT","COPY","ERROR","CACHE_NS_WRITES","CONFIG_KEY_SEND","CONFIG_KEY_CALL","CONFIG_KEY_READ","CONFIG_KEY_CHECKPOINTER","CONFIG_KEY_RESUMING","CONFIG_KEY_TASK_ID","CONFIG_KEY_STREAM","CONFIG_KEY_RESUME_VALUE","CONFIG_KEY_RESUME_MAP","CONFIG_KEY_SCRATCHPAD","CONFIG_KEY_PREVIOUS_STATE","CONFIG_KEY_DURABILITY","CONFIG_KEY_CHECKPOINT_ID","CONFIG_KEY_CHECKPOINT_NS","CONFIG_KEY_NODE_FINISHED","CONFIG_KEY_CHECKPOINT_MAP","CONFIG_KEY_ABORT_SIGNALS","INTERRUPT","RESUME","NO_WRITES","RETURN","PREVIOUS","RUNTIME_PLACEHOLDER","RECURSION_LIMIT_DEFAULT","TAG_HIDDEN","TAG_NOSTREAM","SELF","TASKS","PUSH","PULL","TASK_NAMESPACE","NULL_TASK_ID","RESERVED","CHECKPOINT_NAMESPACE_SEPARATOR","CHECKPOINT_NAMESPACE_END","COMMAND_SYMBOL","CommandInstance","Record","Resume","Update","Nodes","CommandParams","SendInterface","Node","Args","_isSendInterface","Send","_isSend","Interrupt","Value","isInterrupted","Command","Omit","isCommand","_deserializeCommandSendObjectGraph","Map"],"sources":["../src/constants.d.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n/** Special reserved node name denoting the start of a graph. */\nexport declare const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport declare const END = \"__end__\";\nexport declare const INPUT = \"__input__\";\nexport declare const COPY = \"__copy__\";\nexport declare const ERROR = \"__error__\";\n/** Special reserved cache namespaces */\nexport declare const CACHE_NS_WRITES = \"__pregel_ns_writes\";\nexport declare const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport declare const CONFIG_KEY_CALL = \"__pregel_call\";\nexport declare const CONFIG_KEY_READ = \"__pregel_read\";\nexport declare const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport declare const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport declare const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport declare const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport declare const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport declare const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport declare const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport declare const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport declare const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport declare const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport declare const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\nexport declare const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n// this one is part of public API\nexport declare const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\nexport declare const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n/** Special channel reserved for graph interrupts */\nexport declare const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport declare const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport declare const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport declare const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport declare const PREVIOUS = \"__previous__\";\nexport declare const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport declare const RECURSION_LIMIT_DEFAULT = 25;\nexport declare const TAG_HIDDEN = \"langsmith:hidden\";\nexport declare const TAG_NOSTREAM = \"langsmith:nostream\";\nexport declare const SELF = \"__self__\";\nexport declare const TASKS = \"__pregel_tasks\";\nexport declare const PUSH = \"__pregel_push\";\nexport declare const PULL = \"__pregel_pull\";\nexport declare const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport declare const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\nexport declare const RESERVED: string[];\nexport declare const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport declare const CHECKPOINT_NAMESPACE_END = \":\";\n/** @internal */\ndeclare const COMMAND_SYMBOL: unique symbol;\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport declare class CommandInstance<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n constructor(args: CommandParams<Resume, Update, Nodes>);\n}\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\nexport declare function _isSendInterface(x: unknown): x is SendInterface;\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare class Send<Node extends string = string, Args = any> implements SendInterface<Node, Args> {\n lg_name: string;\n node: Node;\n args: Args;\n constructor(node: Node, args: Args);\n toJSON(): {\n lg_name: string;\n node: Node;\n args: Args;\n };\n}\nexport declare function _isSend(x: unknown): x is Send;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport declare function isInterrupted<Value = unknown>(values: unknown): values is {\n [INTERRUPT]: Interrupt<Value>[];\n};\nexport type CommandParams<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?: Nodes | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n *\n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n *\n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport declare class Command<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name: string;\n lc_direct_tool_output: boolean;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[];\n static PARENT: string;\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">);\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[];\n toJSON(): {\n lg_name: string;\n update: Update | [string, unknown][] | undefined;\n resume: Resume | undefined;\n goto: Nodes | (Nodes | {\n lg_name: string;\n node: Nodes;\n args: any;\n })[] | {\n lg_name: string;\n node: Nodes;\n args: any;\n } | undefined;\n };\n}\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport declare function isCommand(x: unknown): x is Command;\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport declare function _deserializeCommandSendObjectGraph(x: unknown, seen?: Map<object, unknown>): unknown;\nexport {};\n"],"mappings":";;;;cAEqBC,KAAAA;AAArB;AAEqBC,cAAAA,GAAAA,GAAG,SAAA;;AAuHdgD,cA5FW1B,SAAAA,GA4FX0B,eAAAA;;;;AAWEK,cA/FS3B,QAAAA,GAiGT4B,cAAAA;;cAlFEd,cAqIKO,EAAAA,OAAAA,MAAAA;;;;;AAiEnB;;;;;AAAgLH,cA5L3JH,eA4L2JG,CAAAA,SAAAA,OAAAA,EAAAA,eA5L1GF,MA4L0GE,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GA5LhFF,MA4LgFE,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,cAAAA,MAAAA,GAAAA,MAAAA,CAAAA,CAAAA;GA3L3KJ,cAAAA,CA2LmLK,EA3LlKC,aA2LkKD,CA3LpJF,MA2LoJE,EA3L5ID,MA2L4IC,EA3LpIA,KA2LoIA,CAAAA;aAc3KD,CAAAA,IAAAA,EAxMSE,aAwMTF,CAxMuBD,MAwMvBC,EAxM+BA,MAwM/BA,EAxMuCC,KAwMvCD,CAAAA;;;AAYWC,UAjNPE,aAiNOF,CAAAA,aAAAA,MAAAA,GAAAA,MAAAA,EAAAA,OAAAA,GAAAA,CAAAA,CAAAA;MAALM,EAhNTH,IAgNSG;MAAeN,EA/MxBI,IA+MwBJ;;;;;;;;;;;;;;;;AAgClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA7LqBM,0DAA0DJ,cAAcC,MAAMC;;QAEzFD;QACAC;oBACYD,YAAYC;;;UAGpBD;UACAC;;;;KAKFI;;UAEAC;;;;;;;;;;;;;;;;;;iBAkBYC;GACnBjC,SAAAA,GAAY+B,UAAUC;;KAEfR,+CAA+CJ,0BAA0BA;;;;;;;;;;;WAWxEC;;;;;;;;;;;WAWAC;;;;;;;;SAQFC,QAAQE,cAAcF;KACzBA,QAAQE,cAAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgETW,yCAAyCd,0BAA0BA,gEAAgED,gBAAgBE,QAAQC,QAAQC;;;;;;;;;;;;;;WAc3KD;;;;WAIAD;;;;;;;;SAQFE,QAAQM,KAAKN,UAAUA,QAAQM,KAAKN;;oBAEzBY,KAAKX,cAAcH,QAAQC,QAAQC;;;;;;qBAMlC/C;;;YAGP8C;YACAD;UACFE,SAASA;;YAELA;;;;YAIAA;;;;;;;;;;;;;iBAaMa,SAAAA,mBAA4BF"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":["PendingWrite","START","END","INPUT","COPY","ERROR","CACHE_NS_WRITES","CONFIG_KEY_SEND","CONFIG_KEY_CALL","CONFIG_KEY_READ","CONFIG_KEY_CHECKPOINTER","CONFIG_KEY_RESUMING","CONFIG_KEY_TASK_ID","CONFIG_KEY_STREAM","CONFIG_KEY_RESUME_VALUE","CONFIG_KEY_RESUME_MAP","CONFIG_KEY_SCRATCHPAD","CONFIG_KEY_PREVIOUS_STATE","CONFIG_KEY_DURABILITY","CONFIG_KEY_CHECKPOINT_ID","CONFIG_KEY_CHECKPOINT_NS","CONFIG_KEY_NODE_FINISHED","CONFIG_KEY_CHECKPOINT_MAP","CONFIG_KEY_ABORT_SIGNALS","INTERRUPT","RESUME","NO_WRITES","RETURN","PREVIOUS","RUNTIME_PLACEHOLDER","RECURSION_LIMIT_DEFAULT","TAG_HIDDEN","TAG_NOSTREAM","SELF","TASKS","PUSH","PULL","TASK_NAMESPACE","NULL_TASK_ID","RESERVED","CHECKPOINT_NAMESPACE_SEPARATOR","CHECKPOINT_NAMESPACE_END","COMMAND_SYMBOL","CommandInstance","Record","Resume","Update","Nodes","CommandParams","SendInterface","Node","Args","_isSendInterface","Send","_isSend","Interrupt","Value","isInterrupted","Command","Omit","isCommand","_deserializeCommandSendObjectGraph","Map"],"sources":["../src/constants.d.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n/** Special reserved node name denoting the start of a graph. */\nexport declare const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport declare const END = \"__end__\";\nexport declare const INPUT = \"__input__\";\nexport declare const COPY = \"__copy__\";\nexport declare const ERROR = \"__error__\";\n/** Special reserved cache namespaces */\nexport declare const CACHE_NS_WRITES = \"__pregel_ns_writes\";\nexport declare const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport declare const CONFIG_KEY_CALL = \"__pregel_call\";\nexport declare const CONFIG_KEY_READ = \"__pregel_read\";\nexport declare const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport declare const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport declare const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport declare const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport declare const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport declare const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport declare const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport declare const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport declare const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport declare const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport declare const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\nexport declare const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\nexport declare const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\nexport declare const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n/** Special channel reserved for graph interrupts */\nexport declare const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport declare const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport declare const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport declare const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport declare const PREVIOUS = \"__previous__\";\nexport declare const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport declare const RECURSION_LIMIT_DEFAULT = 25;\nexport declare const TAG_HIDDEN = \"langsmith:hidden\";\nexport declare const TAG_NOSTREAM = \"langsmith:nostream\";\nexport declare const SELF = \"__self__\";\nexport declare const TASKS = \"__pregel_tasks\";\nexport declare const PUSH = \"__pregel_push\";\nexport declare const PULL = \"__pregel_pull\";\nexport declare const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport declare const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\nexport declare const RESERVED: string[];\nexport declare const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport declare const CHECKPOINT_NAMESPACE_END = \":\";\n/** @internal */\ndeclare const COMMAND_SYMBOL: unique symbol;\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport declare class CommandInstance<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n constructor(args: CommandParams<Resume, Update, Nodes>);\n}\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\nexport declare function _isSendInterface(x: unknown): x is SendInterface;\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\nexport declare class Send<Node extends string = string, Args = any> implements SendInterface<Node, Args> {\n lg_name: string;\n node: Node;\n args: Args;\n constructor(node: Node, args: Args);\n toJSON(): {\n lg_name: string;\n node: Node;\n args: Args;\n };\n}\nexport declare function _isSend(x: unknown): x is Send;\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport declare function isInterrupted<Value = unknown>(values: unknown): values is {\n [INTERRUPT]: Interrupt<Value>[];\n};\nexport type CommandParams<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?: Nodes | SendInterface<Nodes> | (Nodes | SendInterface<Nodes>)[];\n};\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n *\n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n *\n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport declare class Command<Resume = unknown, Update extends Record<string, unknown> = Record<string, unknown>, Nodes extends string = string> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n lc_direct_tool_output: boolean;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[];\n static PARENT: string;\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">);\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[];\n toJSON(): {\n lg_name: string;\n update: Update | [string, unknown][] | undefined;\n resume: Resume | undefined;\n goto: Nodes | (Nodes | {\n lg_name: string;\n node: Nodes;\n args: any;\n })[] | {\n lg_name: string;\n node: Nodes;\n args: any;\n } | undefined;\n };\n}\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport declare function isCommand(x: unknown): x is Command;\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport declare function _deserializeCommandSendObjectGraph(x: unknown, seen?: Map<object, unknown>): unknown;\nexport {};\n"],"mappings":";;;;cAEqBC,KAAAA;AAArB;AAEqBC,cAAAA,GAAAA,GAAG,SAAA;;AAkH2EiD,cAxF9E3B,SAAAA,GAwF8E2B,eAAAA;;;;AAAP,cAhFvEvB,QAAAA,GAgFuE,cAAA;;cAjE9Ec,cAkImBK,EAAAA,OAAAA,MAAAA;;;;;;AAgEjC;;;;AAAwKF,cAxLnJF,eAwLmJE,CAAAA,SAAAA,OAAAA,EAAAA,eAxLlGD,MAwLkGC,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,GAxLxED,MAwLwEC,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA,EAAAA,cAAAA,MAAAA,GAAAA,MAAAA,CAAAA,CAAAA;GAvLnKH,cAAAA,CAuL2KI,EAvL1JE,aAuL0JF,CAvL5ID,MAuL4IC,EAvLpIA,MAuLoIA,EAvL5HC,KAuL4HD,CAAAA;aAAQC,CAAAA,IAAAA,EAtLlKC,aAsLkKD,CAtLpJF,MAsLoJE,EAtL5ID,MAsL4IC,EAtLpIA,KAsLoIA,CAAAA;;AAkB3KF,UAtMII,aAsMJJ,CAAAA,aAAAA,MAAAA,GAAAA,MAAAA,EAAAA,OAAAA,GAAAA,CAAAA,CAAAA;MAQFE,EA7MDG,IA6MCH;MAAaA,EA5MdI,IA4McJ;;;;;;;;;;;;;;;;;;AAgCxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA3LqBM,0DAA0DJ,cAAcC,MAAMC;;QAEzFD;QACAC;oBACYD,YAAYC;;;UAGpBD;UACAC;;;KAIFI;;UAEAC;;;;;;;;;;;;;;;;;;iBAkBYC;GACnBjC,SAAAA,GAAY+B,UAAUC;;KAEfR,+CAA+CJ,0BAA0BA;;;;;;;;;;;WAWxEC;;;;;;;;;;;WAWAC;;;;;;;;SAQFC,QAAQE,cAAcF,UAAUA,QAAQE,cAAcF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAgE5CW,yCAAyCd,0BAA0BA,gEAAgED,gBAAgBE,QAAQC,QAAQC;;;;;;;;;;;;;;WAc3KD;;;;WAIAD;;;;;;;;SAQFE,QAAQM,KAAKN,UAAUA,QAAQM,KAAKN;;oBAEzBY,KAAKX,cAAcH,QAAQC,QAAQC;;;;;;qBAMlC/C;;;YAGP8C;YACAD;UACFE,SAASA;;YAELA;;;;YAIAA;;;;;;;;;;;;;iBAaMa,SAAAA,mBAA4BF"}
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["result: unknown"],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/** @internal */\nconst COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<Node extends string = string, Args = any>\n implements SendInterface<Node, Args>\n{\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (isCommand(x) && !(x instanceof Command)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x) && !(x instanceof Send)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (isCommand(x) || _isSend(x)) {\n result = x;\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;AAGA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;AAGrB,MAAa,kBAAkB;AAE/B,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;;AAErC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B;AACxC,MAAa,2BAA2B;AAExC,MAAa,2BAA2B;AAGxC,MAAa,4BAA4B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AI,KAAK,IAAI,GACX,QAAO,KAAK,IAAI;EAGlB,IAAIA;AAEJ,MAAI,MAAM,QAAQ,IAAI;AAEpB,YAAS;AAET,QAAK,IAAI,GAAG;AAGZ,KAAE,SAAS,MAAM,UAAU;AACzB,IAAC,OAAqB,SAAS,mCAC7B,MACA;;aAIK,UAAU,MAAM,EAAE,aAAa,UAAU;AAClD,YAAS,IAAI,QAAQ;AACrB,QAAK,IAAI,GAAG;aAEH,iBAAiB,MAAM,EAAE,aAAa,OAAO;AACtD,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE;AAC5B,QAAK,IAAI,GAAG;aACH,UAAU,MAAM,QAAQ,IAAI;AACrC,YAAS;AACT,QAAK,IAAI,GAAG;aACH,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG;SACP;AAEL,YAAS;AAET,QAAK,IAAI,GAAG;AAGZ,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,GACxC,CAAC,OAAmC,OAClC,mCAAmC,OAAO;;AAIhD,SAAO;;AAET,QAAO"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\n\n/** Special reserved node name denoting the start of a graph. */\nexport const START = \"__start__\";\n/** Special reserved node name denoting the end of a graph. */\nexport const END = \"__end__\";\nexport const INPUT = \"__input__\";\nexport const COPY = \"__copy__\";\nexport const ERROR = \"__error__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\nexport const CONFIG_KEY_SEND = \"__pregel_send\";\n/** config key containing function used to call a node (push task) */\nexport const CONFIG_KEY_CALL = \"__pregel_call\";\nexport const CONFIG_KEY_READ = \"__pregel_read\";\nexport const CONFIG_KEY_CHECKPOINTER = \"__pregel_checkpointer\";\nexport const CONFIG_KEY_RESUMING = \"__pregel_resuming\";\nexport const CONFIG_KEY_TASK_ID = \"__pregel_task_id\";\nexport const CONFIG_KEY_STREAM = \"__pregel_stream\";\nexport const CONFIG_KEY_RESUME_VALUE = \"__pregel_resume_value\";\nexport const CONFIG_KEY_RESUME_MAP = \"__pregel_resume_map\";\nexport const CONFIG_KEY_SCRATCHPAD = \"__pregel_scratchpad\";\n/** config key containing state from previous invocation of graph for the given thread */\nexport const CONFIG_KEY_PREVIOUS_STATE = \"__pregel_previous\";\nexport const CONFIG_KEY_DURABILITY = \"__pregel_durability\";\nexport const CONFIG_KEY_CHECKPOINT_ID = \"checkpoint_id\";\nexport const CONFIG_KEY_CHECKPOINT_NS = \"checkpoint_ns\";\n\nexport const CONFIG_KEY_NODE_FINISHED = \"__pregel_node_finished\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_ABORT_SIGNALS = \"__pregel_abort_signals\";\n\n/** Special channel reserved for graph interrupts */\nexport const INTERRUPT = \"__interrupt__\";\n/** Special channel reserved for graph resume */\nexport const RESUME = \"__resume__\";\n/** Special channel reserved for cases when a task exits without any writes */\nexport const NO_WRITES = \"__no_writes__\";\n/** Special channel reserved for graph return */\nexport const RETURN = \"__return__\";\n/** Special channel reserved for graph previous state */\nexport const PREVIOUS = \"__previous__\";\nexport const RUNTIME_PLACEHOLDER = \"__pregel_runtime_placeholder__\";\nexport const RECURSION_LIMIT_DEFAULT = 25;\n\nexport const TAG_HIDDEN = \"langsmith:hidden\";\nexport const TAG_NOSTREAM = \"langsmith:nostream\";\nexport const SELF = \"__self__\";\n\nexport const TASKS = \"__pregel_tasks\";\nexport const PUSH = \"__pregel_push\";\nexport const PULL = \"__pregel_pull\";\n\nexport const TASK_NAMESPACE = \"6ba7b831-9dad-11d1-80b4-00c04fd430c8\";\nexport const NULL_TASK_ID = \"00000000-0000-0000-0000-000000000000\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n NO_WRITES,\n\n // reserved config.configurable keys\n CONFIG_KEY_SEND,\n CONFIG_KEY_READ,\n CONFIG_KEY_CHECKPOINTER,\n CONFIG_KEY_DURABILITY,\n CONFIG_KEY_STREAM,\n CONFIG_KEY_RESUMING,\n CONFIG_KEY_TASK_ID,\n CONFIG_KEY_CALL,\n CONFIG_KEY_RESUME_VALUE,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_PREVIOUS_STATE,\n CONFIG_KEY_CHECKPOINT_MAP,\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_CHECKPOINT_ID,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/** @internal */\nconst COMMAND_SYMBOL = Symbol.for(\"langgraph.command\");\n\n/**\n * Instance of a {@link Command} class.\n *\n * This is used to avoid IntelliSense suggesting public fields\n * of {@link Command} class when a plain object is expected.\n *\n * @see {@link Command}\n * @internal\n */\nexport class CommandInstance<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> {\n [COMMAND_SYMBOL]: CommandParams<Resume, Update, Nodes>;\n\n constructor(args: CommandParams<Resume, Update, Nodes>) {\n this[COMMAND_SYMBOL] = args;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SendInterface<Node extends string = string, Args = any> {\n node: Node;\n args: Args;\n}\n\nexport function _isSendInterface(x: unknown): x is SendInterface {\n const operation = x as SendInterface;\n return (\n operation !== null &&\n operation !== undefined &&\n typeof operation.node === \"string\" &&\n operation.args !== undefined\n );\n}\n\n/**\n *\n * A message or packet to send to a specific node in the graph.\n *\n * The `Send` class is used within a `StateGraph`'s conditional edges to\n * dynamically invoke a node with a custom state at the next step.\n *\n * Importantly, the sent state can differ from the core graph's state,\n * allowing for flexible and dynamic workflow management.\n *\n * One such example is a \"map-reduce\" workflow where your graph invokes\n * the same node multiple times in parallel with different states,\n * before aggregating the results back into the main graph's state.\n *\n * @example\n * ```typescript\n * import { Annotation, Send, StateGraph } from \"@langchain/langgraph\";\n *\n * const ChainState = Annotation.Root({\n * subjects: Annotation<string[]>,\n * jokes: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * }),\n * });\n *\n * const continueToJokes = async (state: typeof ChainState.State) => {\n * return state.subjects.map((subject) => {\n * return new Send(\"generate_joke\", { subjects: [subject] });\n * });\n * };\n *\n * const graph = new StateGraph(ChainState)\n * .addNode(\"generate_joke\", (state) => ({\n * jokes: [`Joke about ${state.subjects}`],\n * }))\n * .addConditionalEdges(\"__start__\", continueToJokes)\n * .addEdge(\"generate_joke\", \"__end__\")\n * .compile();\n *\n * const res = await graph.invoke({ subjects: [\"cats\", \"dogs\"] });\n * console.log(res);\n *\n * // Invoking with two subjects results in a generated joke for each\n * // { subjects: [\"cats\", \"dogs\"], jokes: [`Joke about cats`, `Joke about dogs`] }\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Send<Node extends string = string, Args = any>\n implements SendInterface<Node, Args>\n{\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n constructor(node: Node, args: Args) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n }\n\n toJSON() {\n return { lg_name: this.lg_name, node: this.node, args: this.args };\n }\n}\n\nexport function _isSend(x: unknown): x is Send {\n // eslint-disable-next-line no-instanceof/no-instanceof\n return x instanceof Send;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Interrupt<Value = any> = {\n id?: string;\n value?: Value;\n};\n\n/**\n * Checks if the given graph invoke / stream chunk contains interrupt.\n *\n * @example\n * ```ts\n * import { INTERRUPT, isInterrupted } from \"@langchain/langgraph\";\n *\n * const values = await graph.invoke({ foo: \"bar\" });\n * if (isInterrupted<string>(values)) {\n * const interrupt = values[INTERRUPT][0].value;\n * }\n * ```\n *\n * @param values - The values to check.\n * @returns `true` if the values contain an interrupt, `false` otherwise.\n */\nexport function isInterrupted<Value = unknown>(\n values: unknown\n): values is { [INTERRUPT]: Interrupt<Value>[] } {\n if (!values || typeof values !== \"object\") return false;\n if (!(INTERRUPT in values)) return false;\n return Array.isArray(values[INTERRUPT]);\n}\n\nexport type CommandParams<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> = {\n /**\n * A discriminator field used to identify the type of object. Must be populated when serializing.\n *\n * Optional because it's not required to specify this when directly constructing a {@link Command}\n * object.\n */\n lg_name?: \"Command\";\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - `Send` object (to execute a node with the input provided)\n * - sequence of `Send` objects\n */\n goto?:\n | Nodes\n | SendInterface<Nodes> // eslint-disable-line @typescript-eslint/no-explicit-any\n | (Nodes | SendInterface<Nodes>)[]; // eslint-disable-line @typescript-eslint/no-explicit-any\n};\n\n/**\n * One or more commands to update the graph's state and send messages to nodes.\n * Can be used to combine routing logic with state updates in lieu of conditional edges\n *\n * @example\n * ```ts\n * import { Annotation, Command } from \"@langchain/langgraph\";\n *\n * // Define graph state\n * const StateAnnotation = Annotation.Root({\n * foo: Annotation<string>,\n * });\n *\n * // Define the nodes\n * const nodeA = async (_state: typeof StateAnnotation.State) => {\n * console.log(\"Called A\");\n * // this is a replacement for a real conditional edge function\n * const goto = Math.random() > .5 ? \"nodeB\" : \"nodeC\";\n * // note how Command allows you to BOTH update the graph state AND route to the next node\n * return new Command({\n * // this is the state update\n * update: {\n * foo: \"a\",\n * },\n * // this is a replacement for an edge\n * goto,\n * });\n * };\n *\n * // Nodes B and C are unchanged\n * const nodeB = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called B\");\n * return {\n * foo: state.foo + \"|b\",\n * };\n * }\n *\n * const nodeC = async (state: typeof StateAnnotation.State) => {\n * console.log(\"Called C\");\n * return {\n * foo: state.foo + \"|c\",\n * };\n * }\n * \n * import { StateGraph } from \"@langchain/langgraph\";\n\n * // NOTE: there are no edges between nodes A, B and C!\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(\"nodeA\", nodeA, {\n * ends: [\"nodeB\", \"nodeC\"],\n * })\n * .addNode(\"nodeB\", nodeB)\n * .addNode(\"nodeC\", nodeC)\n * .addEdge(\"__start__\", \"nodeA\")\n * .compile();\n * \n * await graph.invoke({ foo: \"\" });\n *\n * // Randomly oscillates between\n * // { foo: 'a|c' } and { foo: 'a|b' }\n * ```\n */\nexport class Command<\n Resume = unknown,\n Update extends Record<string, unknown> = Record<string, unknown>,\n Nodes extends string = string\n> extends CommandInstance<Resume, Update, Nodes> {\n readonly lg_name = \"Command\";\n\n lc_direct_tool_output = true;\n\n /**\n * Graph to send the command to. Supported values are:\n * - None: the current graph (default)\n * - The specific name of the graph to send the command to\n * - {@link Command.PARENT}: closest parent graph (only supported when returned from a node in a subgraph)\n */\n graph?: string;\n\n /**\n * Update to apply to the graph's state as a result of executing the node that is returning the command.\n * Written to the state as if the node had simply returned this value instead of the Command object.\n */\n update?: Update | [string, unknown][];\n\n /**\n * Value to resume execution with. To be used together with {@link interrupt}.\n */\n resume?: Resume;\n\n /**\n * Can be one of the following:\n * - name of the node to navigate to next (any node that belongs to the specified `graph`)\n * - sequence of node names to navigate to next\n * - {@link Send} object (to execute a node with the exact input provided in the {@link Send} object)\n * - sequence of {@link Send} objects\n */\n goto?: Nodes | Send<Nodes> | (Nodes | Send<Nodes>)[] = [];\n\n static PARENT = \"__parent__\";\n\n constructor(args: Omit<CommandParams<Resume, Update, Nodes>, \"lg_name\">) {\n super(args);\n this.resume = args.resume;\n this.graph = args.graph;\n this.update = args.update;\n if (args.goto) {\n type ValidArg = Nodes | Send<Nodes, Update>;\n\n this.goto = Array.isArray(args.goto)\n ? (_deserializeCommandSendObjectGraph(args.goto) as ValidArg[])\n : [_deserializeCommandSendObjectGraph(args.goto) as ValidArg];\n }\n }\n\n /**\n * Convert the update field to a list of {@link PendingWrite} tuples\n * @returns List of {@link PendingWrite} tuples of the form `[channelKey, value]`.\n * @internal\n */\n _updateAsTuples(): PendingWrite[] {\n if (\n this.update &&\n typeof this.update === \"object\" &&\n !Array.isArray(this.update)\n ) {\n return Object.entries(this.update);\n } else if (\n Array.isArray(this.update) &&\n this.update.every(\n (t): t is [string, unknown] =>\n Array.isArray(t) && t.length === 2 && typeof t[0] === \"string\"\n )\n ) {\n return this.update;\n } else {\n return [[\"__root__\", this.update]];\n }\n }\n\n toJSON() {\n let serializedGoto;\n if (typeof this.goto === \"string\") {\n serializedGoto = this.goto;\n } else if (_isSend(this.goto)) {\n serializedGoto = this.goto.toJSON();\n } else {\n serializedGoto = this.goto?.map((innerGoto) => {\n if (typeof innerGoto === \"string\") {\n return innerGoto;\n } else {\n return innerGoto.toJSON();\n }\n });\n }\n return {\n lg_name: this.lg_name,\n update: this.update,\n resume: this.resume,\n goto: serializedGoto,\n };\n }\n}\n\n/**\n * A type guard to check if the given value is a {@link Command}.\n *\n * Useful for type narrowing when working with the {@link Command} object.\n *\n * @param x - The value to check.\n * @returns `true` if the value is a {@link Command}, `false` otherwise.\n */\nexport function isCommand(x: unknown): x is Command {\n if (typeof x !== \"object\") {\n return false;\n }\n\n if (x === null || x === undefined) {\n return false;\n }\n\n if (\"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Reconstructs Command and Send objects from a deeply nested tree of anonymous objects\n * matching their interfaces.\n *\n * This is only exported for testing purposes. It is NOT intended to be used outside of\n * the Command and Send classes.\n *\n * @internal\n *\n * @param x - The command send tree to convert.\n * @param seen - A map of seen objects to avoid infinite loops.\n * @returns The converted command send tree.\n */\nexport function _deserializeCommandSendObjectGraph(\n x: unknown,\n seen: Map<object, unknown> = new Map()\n): unknown {\n if (x !== undefined && x !== null && typeof x === \"object\") {\n // If we've already processed this object, return the transformed version\n if (seen.has(x)) {\n return seen.get(x);\n }\n\n let result: unknown;\n\n if (Array.isArray(x)) {\n // Create the array first, then populate it\n result = [];\n // Add to seen map before processing elements to handle self-references\n seen.set(x, result);\n\n // Now populate the array\n x.forEach((item, index) => {\n (result as unknown[])[index] = _deserializeCommandSendObjectGraph(\n item,\n seen\n );\n });\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (isCommand(x) && !(x instanceof Command)) {\n result = new Command(x);\n seen.set(x, result);\n // eslint-disable-next-line no-instanceof/no-instanceof\n } else if (_isSendInterface(x) && !(x instanceof Send)) {\n result = new Send(x.node, x.args);\n seen.set(x, result);\n } else if (isCommand(x) || _isSend(x)) {\n result = x;\n seen.set(x, result);\n } else if (\"lc_serializable\" in x && x.lc_serializable) {\n result = x;\n seen.set(x, result);\n } else {\n // Create empty object first\n result = {};\n // Add to seen map before processing properties to handle self-references\n seen.set(x, result);\n\n // Now populate the object\n for (const [key, value] of Object.entries(x)) {\n (result as Record<string, unknown>)[key] =\n _deserializeCommandSendObjectGraph(value, seen);\n }\n }\n\n return result;\n }\n return x;\n}\n"],"mappings":";;AAGA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;AAGrB,MAAa,kBAAkB;AAE/B,MAAa,kBAAkB;;AAE/B,MAAa,kBAAkB;AAC/B,MAAa,kBAAkB;AAC/B,MAAa,0BAA0B;AACvC,MAAa,sBAAsB;AACnC,MAAa,qBAAqB;AAClC,MAAa,oBAAoB;AACjC,MAAa,0BAA0B;AACvC,MAAa,wBAAwB;AACrC,MAAa,wBAAwB;;AAErC,MAAa,4BAA4B;AACzC,MAAa,wBAAwB;AACrC,MAAa,2BAA2B;AACxC,MAAa,2BAA2B;AAExC,MAAa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EAAE,YAAY,UAClC,QAAO;AAGT,QAAO;;;;;;;;;;;;;;;AAgBT,SAAgB,mCACd,GACA,uBAA6B,IAAI,KAAK,EAC7B;AACT,KAAI,MAAM,UAAa,MAAM,QAAQ,OAAO,MAAM,UAAU;AAE1D,MAAI,KAAK,IAAI,EAAE,CACb,QAAO,KAAK,IAAI,EAAE;EAGpB,IAAI;AAEJ,MAAI,MAAM,QAAQ,EAAE,EAAE;AAEpB,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,KAAE,SAAS,MAAM,UAAU;AACzB,IAAC,OAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,UAAU,EAAE,IAAI,EAAE,aAAa,UAAU;AAClD,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aAEV,iBAAiB,EAAE,IAAI,EAAE,aAAa,OAAO;AACtD,YAAS,IAAI,KAAK,EAAE,MAAM,EAAE,KAAK;AACjC,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,IAAI,QAAQ,EAAE,EAAE;AACrC,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,qBAAqB,KAAK,EAAE,iBAAiB;AACtD,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;SACd;AAEL,YAAS,EAAE;AAEX,QAAK,IAAI,GAAG,OAAO;AAGnB,QAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,EAAE,CAC1C,CAAC,OAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
|
package/dist/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM;
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM,aAAa;AACnB,OAAK,gBAAgB,QAAQ;;;AAIjC,IAAa,gBAAb,cAAmC,mBAAmB;CACpD,IAAI,eAAe;AACjB,SAAO;;;AAIX,IAAa,sBAAb,cAAyC,mBAAmB;CAC1D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,iBAAb,cAAoC,cAAc;CAChD;CAEA,YAAY,YAA0B,QAAmC;AACvE,QAAM,KAAK,UAAU,YAAY,MAAM,EAAE,EAAE,OAAO;AAClD,OAAK,OAAO;AACZ,OAAK,aAAa,cAAc,EAAE;;CAGpC,WAAW,oBAAoB;AAC7B,SAAO;;;;AAKX,IAAa,gBAAb,cAAmC,eAAe;CAEhD,YAAY,SAAc,QAAmC;AAC3D,QAAM,CAAC,EAAE,OAAO,SAAS,CAAC,EAAE,OAAO;AACnC,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,gBAAb,cAAmC,cAAc;CAC/C;CAEA,YAAY,SAAkB;A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G,WAAmB,OAAO,IAAI,4BAA4B,MAAM,OAGjE,CAAC,WAAmB,OAAO,IAAI,4BAA4B,oBAAI,IAAI,KAAK;AAG1E,QAAQ,WAAmB,OAAO,IAAI,4BAA4B"}
|
package/dist/errors.d.cts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Command, Interrupt } from "./constants.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
|
-
// When editing, make sure to update the index found here:
|
|
5
|
-
// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/
|
|
6
4
|
type BaseLangGraphErrorFields = {
|
|
7
5
|
lc_error_code?: "GRAPH_RECURSION_LIMIT" | "INVALID_CONCURRENT_GRAPH_UPDATE" | "INVALID_GRAPH_NODE_RETURN_VALUE" | "MISSING_CHECKPOINTER" | "MULTIPLE_SUBGRAPHS" | "UNREACHABLE_NODE";
|
|
8
6
|
};
|
|
9
|
-
// TODO: Merge with base LangChain error class when we drop support for core@0.2.0
|
|
10
7
|
/** @category Errors */
|
|
11
8
|
declare class BaseLangGraphError extends Error {
|
|
12
9
|
lc_error_code?: string;
|
|
@@ -30,7 +27,6 @@ declare class GraphInterrupt extends GraphBubbleUp {
|
|
|
30
27
|
}
|
|
31
28
|
/** Raised by a node to interrupt execution. */
|
|
32
29
|
declare class NodeInterrupt extends GraphInterrupt {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
30
|
constructor(message: any, fields?: BaseLangGraphErrorFields);
|
|
35
31
|
static get unminifiable_name(): string;
|
|
36
32
|
}
|
package/dist/errors.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.cts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\
|
|
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","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 * 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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0BZ,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;;;;;AAOfC,cAAAA,mBAA8B,EAAA,GAAA,GAAA,GAAA"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Command, Interrupt } from "./constants.js";
|
|
2
2
|
|
|
3
3
|
//#region src/errors.d.ts
|
|
4
|
-
// When editing, make sure to update the index found here:
|
|
5
|
-
// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/
|
|
6
4
|
type BaseLangGraphErrorFields = {
|
|
7
5
|
lc_error_code?: "GRAPH_RECURSION_LIMIT" | "INVALID_CONCURRENT_GRAPH_UPDATE" | "INVALID_GRAPH_NODE_RETURN_VALUE" | "MISSING_CHECKPOINTER" | "MULTIPLE_SUBGRAPHS" | "UNREACHABLE_NODE";
|
|
8
6
|
};
|
|
9
|
-
// TODO: Merge with base LangChain error class when we drop support for core@0.2.0
|
|
10
7
|
/** @category Errors */
|
|
11
8
|
declare class BaseLangGraphError extends Error {
|
|
12
9
|
lc_error_code?: string;
|
|
@@ -30,7 +27,6 @@ declare class GraphInterrupt extends GraphBubbleUp {
|
|
|
30
27
|
}
|
|
31
28
|
/** Raised by a node to interrupt execution. */
|
|
32
29
|
declare class NodeInterrupt extends GraphInterrupt {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
30
|
constructor(message: any, fields?: BaseLangGraphErrorFields);
|
|
35
31
|
static get unminifiable_name(): string;
|
|
36
32
|
}
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","names":["Command","Interrupt","BaseLangGraphErrorFields","BaseLangGraphError","Error","GraphBubbleUp","GraphRecursionError","GraphValueError","GraphInterrupt","NodeInterrupt","ParentCommand","isParentCommand","isGraphBubbleUp","isGraphInterrupt","EmptyInputError","EmptyChannelError","InvalidUpdateError","MultipleSubgraphsError","UnreachableNodeError","RemoteException","getSubgraphsSeenSet"],"sources":["../src/errors.d.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\
|
|
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","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 * Used for subgraph detection.\n */\nexport declare const getSubgraphsSeenSet: () => any;\n"],"mappings":";;;KACYE,wBAAAA;;AAAZ,CAAA;AAIA;AAAuC,cAAlBC,kBAAAA,SAA2BC,KAAAA,CAAT;eAEIF,CAAAA,EAAAA,MAAAA;aAFKE,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAELF,wBAFKE;;AAI3BC,cAAAA,aAAAA,SAAsBF,kBAAAA,CAAkB;EAGxCG,IAAAA,YAAAA,CAAAA,CAAAA,EAAAA,OAAmB;;AACGJ,cADtBI,mBAAAA,SAA4BH,kBAAAA,CACND;aADMC,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EACND,wBADMC;EAAkB,WAAA,iBAAA,CAAA,CAAA,EAAA,MAAA;AAInE;AAAoC,cAAfI,eAAAA,SAAwBJ,kBAAAA,CAAT;aACOD,CAAAA,OAAAA,CAAAA,EAAAA,MAAAA,EAAAA,MAAAA,CAAAA,EAAAA,wBAAAA;aADEC,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;AAIxBK,cAAAA,cAAAA,SAAuBH,aAAAA,CAAT;EAAA,UAAA,EACnBJ,SADmB,EAAA;aACnBA,CAAAA,UAAAA,CAAAA,EACaA,SADbA,EAAAA,EAAAA,MAAAA,CAAAA,EACmCC,wBADnCD;aACaA,iBAAAA,CAAAA,CAAAA,EAAAA,MAAAA;;;AAF4B,cAMpCQ,aAAAA,SAAsBD,cAAAA,CANc;EAMp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A,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;;;;;AAOfC,cAAAA,mBAA8B,EAAA,GAAA,GAAA,GAAA"}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM;
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { Command, Interrupt } from \"./constants.js\";\n\n// When editing, make sure to update the index found here:\n// https://langchain-ai.github.io/langgraphjs/troubleshooting/errors/\nexport type BaseLangGraphErrorFields = {\n lc_error_code?:\n | \"GRAPH_RECURSION_LIMIT\"\n | \"INVALID_CONCURRENT_GRAPH_UPDATE\"\n | \"INVALID_GRAPH_NODE_RETURN_VALUE\"\n | \"MISSING_CHECKPOINTER\"\n | \"MULTIPLE_SUBGRAPHS\"\n | \"UNREACHABLE_NODE\";\n};\n\n// TODO: Merge with base LangChain error class when we drop support for core@0.2.0\n/** @category Errors */\nexport class BaseLangGraphError extends Error {\n lc_error_code?: string;\n\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n let finalMessage = message ?? \"\";\n if (fields?.lc_error_code) {\n finalMessage = `${finalMessage}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langgraph/${fields.lc_error_code}/\\n`;\n }\n super(finalMessage);\n this.lc_error_code = fields?.lc_error_code;\n }\n}\n\nexport class GraphBubbleUp extends BaseLangGraphError {\n get is_bubble_up() {\n return true;\n }\n}\n\nexport class GraphRecursionError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphRecursionError\";\n }\n\n static get unminifiable_name() {\n return \"GraphRecursionError\";\n }\n}\n\nexport class GraphValueError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"GraphValueError\";\n }\n\n static get unminifiable_name() {\n return \"GraphValueError\";\n }\n}\n\nexport class GraphInterrupt extends GraphBubbleUp {\n interrupts: Interrupt[];\n\n constructor(interrupts?: Interrupt[], fields?: BaseLangGraphErrorFields) {\n super(JSON.stringify(interrupts, null, 2), fields);\n this.name = \"GraphInterrupt\";\n this.interrupts = interrupts ?? [];\n }\n\n static get unminifiable_name() {\n return \"GraphInterrupt\";\n }\n}\n\n/** Raised by a node to interrupt execution. */\nexport class NodeInterrupt extends GraphInterrupt {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n constructor(message: any, fields?: BaseLangGraphErrorFields) {\n super([{ value: message }], fields);\n this.name = \"NodeInterrupt\";\n }\n\n static get unminifiable_name() {\n return \"NodeInterrupt\";\n }\n}\n\nexport class ParentCommand extends GraphBubbleUp {\n command: Command;\n\n constructor(command: Command) {\n super();\n this.name = \"ParentCommand\";\n this.command = command;\n }\n\n static get unminifiable_name() {\n return \"ParentCommand\";\n }\n}\n\nexport function isParentCommand(e?: unknown): e is ParentCommand {\n return (\n e !== undefined &&\n (e as ParentCommand).name === ParentCommand.unminifiable_name\n );\n}\n\nexport function isGraphBubbleUp(e?: unknown): e is GraphBubbleUp {\n return e !== undefined && (e as GraphBubbleUp).is_bubble_up === true;\n}\n\nexport function isGraphInterrupt(e?: unknown): e is GraphInterrupt {\n return (\n e !== undefined &&\n [\n GraphInterrupt.unminifiable_name,\n NodeInterrupt.unminifiable_name,\n ].includes((e as Error).name)\n );\n}\n\nexport class EmptyInputError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyInputError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyInputError\";\n }\n}\n\nexport class EmptyChannelError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"EmptyChannelError\";\n }\n\n static get unminifiable_name() {\n return \"EmptyChannelError\";\n }\n}\n\nexport class InvalidUpdateError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"InvalidUpdateError\";\n }\n\n static get unminifiable_name() {\n return \"InvalidUpdateError\";\n }\n}\n\n/**\n * @deprecated This exception type is no longer thrown.\n */\nexport class MultipleSubgraphsError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"MultipleSubgraphError\";\n }\n\n static get unminifiable_name() {\n return \"MultipleSubgraphError\";\n }\n}\n\nexport class UnreachableNodeError extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"UnreachableNodeError\";\n }\n\n static get unminifiable_name() {\n return \"UnreachableNodeError\";\n }\n}\n\n/**\n * Exception raised when an error occurs in the remote graph.\n */\nexport class RemoteException extends BaseLangGraphError {\n constructor(message?: string, fields?: BaseLangGraphErrorFields) {\n super(message, fields);\n this.name = \"RemoteException\";\n }\n\n static get unminifiable_name() {\n return \"RemoteException\";\n }\n}\n\n/**\n * Used for subgraph detection.\n */\nexport const getSubgraphsSeenSet = () => {\n if (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] === undefined\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")] = new Set();\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (globalThis as any)[Symbol.for(\"LG_CHECKPOINT_SEEN_NS_SET\")];\n};\n"],"mappings":";;AAgBA,IAAa,qBAAb,cAAwC,MAAM;CAC5C;CAEA,YAAY,SAAkB,QAAmC;EAC/D,IAAI,eAAe,WAAW;AAC9B,MAAI,QAAQ,cACV,gBAAe,GAAG,aAAa,+EAA+E,OAAO,cAAc;AAErI,QAAM,aAAa;AACnB,OAAK,gBAAgB,QAAQ;;;AAIjC,IAAa,gBAAb,cAAmC,mBAAmB;CACpD,IAAI,eAAe;AACjB,SAAO;;;AAIX,IAAa,sBAAb,cAAyC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AmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,qBAAb,cAAwC,mBAAmB;CACzD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,IAAa,yBAAb,cAA4C,mBAAmB;CAC7D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;AAIX,IAAa,uBAAb,cAA0C,mBAAmB;CAC3D,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,IAAa,kBAAb,cAAqC,mBAAmB;CACtD,YAAY,SAAkB,QAAmC;AAC/D,QAAM,SAAS,OAAO;AACtB,OAAK,OAAO;;CAGd,WAAW,oBAAoB;AAC7B,SAAO;;;;;;AAOX,MAAa,4BAA4B;AACvC,KAEG,WAAmB,OAAO,IAAI,4BAA4B,MAAM,OAGjE,CAAC,WAAmB,OAAO,IAAI,4BAA4B,oBAAI,IAAI,KAAK;AAG1E,QAAQ,WAAmB,OAAO,IAAI,4BAA4B"}
|
package/dist/func/index.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
1
|
const require_last_value = require('../channels/last_value.cjs');
|
|
3
2
|
const require_constants = require('../constants.cjs');
|
|
4
3
|
const require_utils = require('../utils.cjs');
|
|
@@ -7,7 +6,7 @@ const require_read = require('../pregel/read.cjs');
|
|
|
7
6
|
const require_call = require('../pregel/call.cjs');
|
|
8
7
|
const require_pregel_index = require('../pregel/index.cjs');
|
|
9
8
|
const require_ephemeral_value = require('../channels/ephemeral_value.cjs');
|
|
10
|
-
|
|
9
|
+
let _langchain_core_singletons = require("@langchain/core/singletons");
|
|
11
10
|
|
|
12
11
|
//#region src/func/index.ts
|
|
13
12
|
/**
|
|
@@ -290,8 +289,7 @@ entrypoint.final = function final({ value, save }) {
|
|
|
290
289
|
* @category Functional API
|
|
291
290
|
*/
|
|
292
291
|
function getPreviousState() {
|
|
293
|
-
|
|
294
|
-
return config.configurable?.[require_constants.CONFIG_KEY_PREVIOUS_STATE];
|
|
292
|
+
return _langchain_core_singletons.AsyncLocalStorageProviderSingleton.getRunnableConfig().configurable?.[require_constants.CONFIG_KEY_PREVIOUS_STATE];
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
//#endregion
|
package/dist/func/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isAsyncGeneratorFunction","isGeneratorFunction","cache: CachePolicy | undefined","call","entrypoint","getRunnableForEntrypoint","RunnableCallable","PregelNode","START","ChannelWrite","END","PASSTHROUGH","PREVIOUS","TAG_HIDDEN","Pregel","EphemeralValue","LastValue","config: LangGraphRunnableConfig","AsyncLocalStorageProviderSingleton","CONFIG_KEY_PREVIOUS_STATE"],"sources":["../../src/func/index.ts"],"sourcesContent":["import {\n BaseCache,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport {\n CONFIG_KEY_PREVIOUS_STATE,\n END,\n PREVIOUS,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { call, getRunnableForEntrypoint } from \"../pregel/call.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport {\n EntrypointFinal,\n EntrypointReturnT,\n EntrypointFinalSaveT,\n EntrypointFunc,\n TaskFunc,\n} from \"./types.js\";\nimport { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport {\n RunnableCallable,\n isAsyncGeneratorFunction,\n isGeneratorFunction,\n} from \"../utils.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\n\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport function task<ArgsT extends unknown[], OutputT>(\n optionsOrName: TaskOptions | string,\n func: TaskFunc<ArgsT, OutputT>\n): (...args: ArgsT) => Promise<OutputT> {\n const options =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }\n : optionsOrName;\n\n const { name, retry } = options;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as tasks. For streaming responses, use config.write.\"\n );\n }\n\n const cachePolicy =\n options.cachePolicy ??\n // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,\n // TODO: remove in 1.x\n (\"cache\" in options ? (options.cache as CachePolicy) : undefined);\n\n let cache: CachePolicy | undefined;\n if (typeof cachePolicy === \"boolean\") {\n cache = cachePolicy ? {} : undefined;\n } else {\n cache = cachePolicy;\n }\n\n return (...args: ArgsT) => {\n return call({ func, name, retry, cache }, ...args);\n };\n}\n\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n ): Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>,\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n },\n Record<string, unknown>,\n InputT,\n EntrypointReturnT<OutputT>,\n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>\n >;\n\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport const entrypoint = function entrypoint<InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n) {\n const { name, checkpointer, store, cache } =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, checkpointer: undefined, store: undefined }\n : optionsOrName;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as entrypoints. For streaming responses, use config.write.\"\n );\n }\n const streamMode = \"updates\";\n const bound = getRunnableForEntrypoint(name, func);\n\n // Helper to check if a value is an EntrypointFinal\n function isEntrypointFinal(\n value: unknown\n ): value is EntrypointFinal<unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"__pregel_final\"\n );\n }\n\n // Helper function to pluck the return value from EntrypointFinal or passthrough\n const pluckReturnValue = new RunnableCallable({\n name: \"pluckReturnValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.value : value;\n },\n });\n\n // Helper function to pluck the save value from EntrypointFinal or passthrough\n const pluckSaveValue = new RunnableCallable({\n name: \"pluckSaveValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.save : value;\n },\n });\n\n const entrypointNode = new PregelNode<InputT, EntrypointReturnT<OutputT>>({\n bound,\n triggers: [START],\n channels: [START],\n writers: [\n new ChannelWrite(\n [\n { channel: END, value: PASSTHROUGH, mapper: pluckReturnValue },\n { channel: PREVIOUS, value: PASSTHROUGH, mapper: pluckSaveValue },\n ],\n [TAG_HIDDEN]\n ),\n ],\n });\n\n return new Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, // node types\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, // channel types\n Record<string, unknown>, // configurable types\n InputT, // input type\n EntrypointReturnT<OutputT> // output type\n >({\n name,\n checkpointer,\n nodes: {\n [name]: entrypointNode,\n },\n channels: {\n [START]: new EphemeralValue<InputT>(),\n [END]: new LastValue<EntrypointReturnT<OutputT>>(),\n [PREVIOUS]: new LastValue<EntrypointFinalSaveT<OutputT>>(),\n },\n inputChannels: START,\n outputChannels: END,\n streamChannels: END,\n streamMode,\n store,\n cache,\n });\n} as EntrypointFunction;\n\n// documented by the EntrypointFunction interface\nentrypoint.final = function final<ValueT, SaveT>({\n value,\n save,\n}: {\n value?: ValueT;\n save?: SaveT;\n}): EntrypointFinal<ValueT, SaveT> {\n return { value, save, __lg_type: \"__pregel_final\" };\n};\n\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport function getPreviousState<StateT>(): StateT {\n const config: LangGraphRunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE] as StateT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,KACd,eACA,MACsC;CACtC,MAAM,UACJ,OAAO,kBAAkB,WACrB;EAAE,MAAM;EAAe,OAAO;EAAW,aAAa;KACtD;CAEN,MAAM,EAAE,MAAM,UAAU;AACxB,KAAIA,uCAAyB,SAASC,kCAAoB,MACxD,OAAM,IAAI,MACR;CAIJ,MAAM,cAC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IAAIO;IACZL,wBAAM,IAAIM;IACVJ,6BAAW,IAAII;;EAElB,eAAeR;EACf,gBAAgBE;EAChB,gBAAgBA;EAChB;EACA;EACA;;;AAKJ,WAAW,QAAQ,SAAS,MAAqB,EAC/C,OACA,QAIiC;AACjC,QAAO;EAAE;EAAO;EAAM,WAAW;;;;;;;;;;;;;;;;;;;;AAoBnC,SAAgB,mBAAmC;CACjD,MAAMO,SACJC,+DAAmC;AACrC,QAAO,OAAO,eAAeC"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isAsyncGeneratorFunction","isGeneratorFunction","call","entrypoint","getRunnableForEntrypoint","RunnableCallable","PregelNode","START","ChannelWrite","END","PASSTHROUGH","PREVIOUS","TAG_HIDDEN","Pregel","EphemeralValue","LastValue","AsyncLocalStorageProviderSingleton","CONFIG_KEY_PREVIOUS_STATE"],"sources":["../../src/func/index.ts"],"sourcesContent":["import {\n BaseCache,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport {\n CONFIG_KEY_PREVIOUS_STATE,\n END,\n PREVIOUS,\n START,\n TAG_HIDDEN,\n} from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport { call, getRunnableForEntrypoint } from \"../pregel/call.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport {\n EntrypointFinal,\n EntrypointReturnT,\n EntrypointFinalSaveT,\n EntrypointFunc,\n TaskFunc,\n} from \"./types.js\";\nimport { LangGraphRunnableConfig } from \"../pregel/runnable_types.js\";\nimport {\n RunnableCallable,\n isAsyncGeneratorFunction,\n isGeneratorFunction,\n} from \"../utils.js\";\nimport { ChannelWrite, PASSTHROUGH } from \"../pregel/write.js\";\n\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport function task<ArgsT extends unknown[], OutputT>(\n optionsOrName: TaskOptions | string,\n func: TaskFunc<ArgsT, OutputT>\n): (...args: ArgsT) => Promise<OutputT> {\n const options =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, retry: undefined, cachePolicy: undefined }\n : optionsOrName;\n\n const { name, retry } = options;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as tasks. For streaming responses, use config.write.\"\n );\n }\n\n const cachePolicy =\n options.cachePolicy ??\n // `cache` was mistakingly used as an alias for `cachePolicy` in v0.3.x,\n // TODO: remove in 1.x\n (\"cache\" in options ? (options.cache as CachePolicy) : undefined);\n\n let cache: CachePolicy | undefined;\n if (typeof cachePolicy === \"boolean\") {\n cache = cachePolicy ? {} : undefined;\n } else {\n cache = cachePolicy;\n }\n\n return (...args: ArgsT) => {\n return call({ func, name, retry, cache }, ...args);\n };\n}\n\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n ): Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>,\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n },\n Record<string, unknown>,\n InputT,\n EntrypointReturnT<OutputT>,\n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>\n >;\n\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport const entrypoint = function entrypoint<InputT, OutputT>(\n optionsOrName: EntrypointOptions | string,\n func: EntrypointFunc<InputT, OutputT>\n) {\n const { name, checkpointer, store, cache } =\n typeof optionsOrName === \"string\"\n ? { name: optionsOrName, checkpointer: undefined, store: undefined }\n : optionsOrName;\n if (isAsyncGeneratorFunction(func) || isGeneratorFunction(func)) {\n throw new Error(\n \"Generators are disallowed as entrypoints. For streaming responses, use config.write.\"\n );\n }\n const streamMode = \"updates\";\n const bound = getRunnableForEntrypoint(name, func);\n\n // Helper to check if a value is an EntrypointFinal\n function isEntrypointFinal(\n value: unknown\n ): value is EntrypointFinal<unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"__lg_type\" in value &&\n value.__lg_type === \"__pregel_final\"\n );\n }\n\n // Helper function to pluck the return value from EntrypointFinal or passthrough\n const pluckReturnValue = new RunnableCallable({\n name: \"pluckReturnValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.value : value;\n },\n });\n\n // Helper function to pluck the save value from EntrypointFinal or passthrough\n const pluckSaveValue = new RunnableCallable({\n name: \"pluckSaveValue\",\n func: (value: unknown) => {\n return isEntrypointFinal(value) ? value.save : value;\n },\n });\n\n const entrypointNode = new PregelNode<InputT, EntrypointReturnT<OutputT>>({\n bound,\n triggers: [START],\n channels: [START],\n writers: [\n new ChannelWrite(\n [\n { channel: END, value: PASSTHROUGH, mapper: pluckReturnValue },\n { channel: PREVIOUS, value: PASSTHROUGH, mapper: pluckSaveValue },\n ],\n [TAG_HIDDEN]\n ),\n ],\n });\n\n return new Pregel<\n Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, // node types\n {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, // channel types\n Record<string, unknown>, // configurable types\n InputT, // input type\n EntrypointReturnT<OutputT> // output type\n >({\n name,\n checkpointer,\n nodes: {\n [name]: entrypointNode,\n },\n channels: {\n [START]: new EphemeralValue<InputT>(),\n [END]: new LastValue<EntrypointReturnT<OutputT>>(),\n [PREVIOUS]: new LastValue<EntrypointFinalSaveT<OutputT>>(),\n },\n inputChannels: START,\n outputChannels: END,\n streamChannels: END,\n streamMode,\n store,\n cache,\n });\n} as EntrypointFunction;\n\n// documented by the EntrypointFunction interface\nentrypoint.final = function final<ValueT, SaveT>({\n value,\n save,\n}: {\n value?: ValueT;\n save?: SaveT;\n}): EntrypointFinal<ValueT, SaveT> {\n return { value, save, __lg_type: \"__pregel_final\" };\n};\n\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport function getPreviousState<StateT>(): StateT {\n const config: LangGraphRunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n return config.configurable?.[CONFIG_KEY_PREVIOUS_STATE] as StateT;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqGA,SAAgB,KACd,eACA,MACsC;CACtC,MAAM,UACJ,OAAO,kBAAkB,WACrB;EAAE,MAAM;EAAe,OAAO;EAAW,aAAa;EAAW,GACjE;CAEN,MAAM,EAAE,MAAM,UAAU;AACxB,KAAIA,uCAAyB,KAAK,IAAIC,kCAAoB,KAAK,CAC7D,OAAM,IAAI,MACR,iFACD;CAGH,MAAM,cACJ,QAAQ,gBAGP,WAAW,UAAW,QAAQ,QAAwB;CAEzD,IAAI;AACJ,KAAI,OAAO,gBAAgB,UACzB,SAAQ,cAAc,EAAE,GAAG;KAE3B,SAAQ;AAGV,SAAQ,GAAG,SAAgB;AACzB,SAAOC,kBA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AM,IAAIM,8BAAuC;IACjDJ,6BAAW,IAAII,8BAA0C;GAC3D;EACD,eAAeR;EACf,gBAAgBE;EAChB,gBAAgBA;EAChB;EACA;EACA;EACD,CAAC;;AAIJ,WAAW,QAAQ,SAAS,MAAqB,EAC/C,OACA,QAIiC;AACjC,QAAO;EAAE;EAAO;EAAM,WAAW;EAAkB;;;;;;;;;;;;;;;;;;;AAoBrD,SAAgB,mBAAmC;AAGjD,QADEO,8DAAmC,mBAAmB,CAC1C,eAAeC"}
|
package/dist/func/index.d.cts
CHANGED
|
@@ -107,12 +107,7 @@ interface EntrypointFunction {
|
|
|
107
107
|
[START]: EphemeralValue<InputT>;
|
|
108
108
|
[END]: LastValue<EntrypointReturnT<OutputT>>;
|
|
109
109
|
[PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;
|
|
110
|
-
}, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>,
|
|
111
|
-
// Because the update type is an return type union of tasks + entrypoint,
|
|
112
|
-
// thus we can't type it properly.
|
|
113
|
-
any,
|
|
114
|
-
// eslint-disable-line @typescript-eslint/no-explicit-any
|
|
115
|
-
Awaited<EntrypointReturnT<OutputT>>>;
|
|
110
|
+
}, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, any, Awaited<EntrypointReturnT<OutputT>>>;
|
|
116
111
|
/**
|
|
117
112
|
* A helper utility for use with the functional API that returns a value to the caller,
|
|
118
113
|
* as well as a separate state value to persist to the checkpoint. This allows workflows
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, \n // Because the update type is an return type union of tasks + entrypoint,\n // thus we can't type it properly.\n any, // eslint-disable-line @typescript-eslint/no-explicit-any\n Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA8DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EArD9FN,WAqD8FM;;;;gBAjDxFP;AAqDlB;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsKA;AAkBA;;;;;iBApNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;;UAMKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO;;;;;EAItDM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBdO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsIXC,YAAYN;;;;;;;;;;;;;;;;;;iBAkBTO,4BAA4BC"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["BaseCache","BaseCheckpointSaver","BaseStore","Pregel","PregelNode","END","PREVIOUS","START","EphemeralValue","CachePolicy","RetryPolicy","LastValue","EntrypointFinal","EntrypointReturnT","EntrypointFinalSaveT","EntrypointFunc","TaskFunc","TaskOptions","task","ArgsT","OutputT","Promise","EntrypointOptions","EntrypointFunction","InputT","Record","Awaited","ValueT","SaveT","entrypoint","getPreviousState","StateT"],"sources":["../../src/func/index.d.ts"],"sourcesContent":["import { BaseCache, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { Pregel } from \"../pregel/index.js\";\nimport { PregelNode } from \"../pregel/read.js\";\nimport { END, PREVIOUS, START } from \"../constants.js\";\nimport { EphemeralValue } from \"../channels/ephemeral_value.js\";\nimport type { CachePolicy, RetryPolicy } from \"../pregel/utils/index.js\";\nimport { LastValue } from \"../channels/last_value.js\";\nimport { EntrypointFinal, EntrypointReturnT, EntrypointFinalSaveT, EntrypointFunc, TaskFunc } from \"./types.js\";\n/**\n * Options for the {@link task} function\n */\nexport interface TaskOptions {\n /**\n * The name of the task, analogous to the node name in {@link StateGraph}.\n */\n name: string;\n /**\n * The retry policy for the task. Configures how many times and under what conditions\n * the task should be retried if it fails.\n */\n retry?: RetryPolicy;\n /**\n * The cache policy for the task. Configures how the task should be cached.\n */\n cachePolicy?: CachePolicy;\n}\n/**\n * Define a LangGraph task using the `task` function.\n *\n * Tasks can only be called from within an {@link entrypoint} or from within a StateGraph.\n * A task can be called like a regular function with the following differences:\n *\n * - When a checkpointer is enabled, the function inputs and outputs must be serializable.\n * - The wrapped function can only be called from within an entrypoint or StateGraph.\n * - Calling the function produces a promise. This makes it easy to parallelize tasks.\n *\n * @typeParam ArgsT - The type of arguments the task function accepts\n * @typeParam OutputT - The type of value the task function returns\n * @param optionsOrName - Either an {@link TaskOptions} object, or a string for the name of the task\n * @param func - The function that executes this task\n * @returns A proxy function that accepts the same arguments as the original and always returns the result as a Promise\n *\n * @example basic example\n * ```typescript\n * const addOne = task(\"add\", async (a: number) => a + 1);\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n *\n * // Call the entrypoint\n * await workflow.invoke([1, 2, 3]); // Returns [2, 3, 4]\n * ```\n *\n * @example using a retry policy\n * ```typescript\n * const addOne = task({\n * name: \"add\",\n * retry: { maxAttempts: 3 }\n * },\n * async (a: number) => a + 1\n * );\n *\n * const workflow = entrypoint(\"example\", async (numbers: number[]) => {\n * const promises = numbers.map(n => addOne(n));\n * const results = await Promise.all(promises);\n * return results;\n * });\n * ```\n * @category Functional API\n */\nexport declare function task<ArgsT extends unknown[], OutputT>(optionsOrName: TaskOptions | string, func: TaskFunc<ArgsT, OutputT>): (...args: ArgsT) => Promise<OutputT>;\n/**\n * Options for the {@link entrypoint} function\n */\nexport type EntrypointOptions = {\n /**\n * The name of the {@link entrypoint}, analogous to the node name in {@link StateGraph}.\n * This name is used for logging, debugging, and checkpoint identification.\n */\n name: string;\n /**\n * The checkpointer for the {@link entrypoint}. Used to save and restore state between\n * invocations of the workflow.\n */\n checkpointer?: BaseCheckpointSaver;\n /**\n * The store for the {@link entrypoint}. Used to persist data across workflow runs.\n */\n store?: BaseStore;\n /**\n * The cache for the {@link entrypoint}. Used to cache values between workflow runs.\n */\n cache?: BaseCache;\n};\n/**\n * Type declaration for the entrypoint function with its properties\n * @category Functional API\n */\nexport interface EntrypointFunction {\n <InputT, OutputT>(optionsOrName: EntrypointOptions | string, func: EntrypointFunc<InputT, OutputT>): Pregel<Record<string, PregelNode<InputT, EntrypointReturnT<OutputT>>>, {\n [START]: EphemeralValue<InputT>;\n [END]: LastValue<EntrypointReturnT<OutputT>>;\n [PREVIOUS]: LastValue<EntrypointFinalSaveT<OutputT>>;\n }, Record<string, unknown>, InputT, EntrypointReturnT<OutputT>, any, Awaited<EntrypointReturnT<OutputT>>>;\n /**\n * A helper utility for use with the functional API that returns a value to the caller,\n * as well as a separate state value to persist to the checkpoint. This allows workflows\n * to maintain state between runs while returning different values to the caller.\n *\n * @typeParam ValueT - The type of the value to return to the caller\n * @typeParam SaveT - The type of the state to save to the checkpoint\n * @param options.value - The value to return to the caller\n * @param options.save - The value to save to the checkpoint\n * @returns An object with the value and save properties\n *\n * @example\n * ```typescript\n * return entrypoint.final({\n * value: \"result for caller\",\n * save: { counter: currentCount + 1 }\n * });\n * ```\n */\n final<ValueT, SaveT>(options: {\n value?: ValueT;\n save?: SaveT;\n }): EntrypointFinal<ValueT, SaveT>;\n}\n/**\n * Define a LangGraph workflow using the `entrypoint` function.\n *\n * ### Function signature\n *\n * The wrapped function must accept at most **two parameters**. The first parameter\n * is the input to the function. The second (optional) parameter is a\n * {@link LangGraphRunnableConfig} object. If you wish to pass multiple parameters to\n * the function, you can pass them as an object.\n *\n * ### Helper functions\n *\n * #### Streaming\n * To write data to the \"custom\" stream, use the {@link getWriter} function, or the\n * {@link LangGraphRunnableConfig.writer} property.\n *\n * #### State management\n * The {@link getPreviousState} function can be used to access the previous state\n * that was returned from the last invocation of the entrypoint on the same thread id.\n *\n * If you wish to save state other than the return value, you can use the\n * {@link entrypoint.final} function.\n *\n * @typeParam InputT - The type of input the entrypoint accepts\n * @typeParam OutputT - The type of output the entrypoint produces\n * @param optionsOrName - Either an {@link EntrypointOptions} object, or a string for the name of the entrypoint\n * @param func - The function that executes this entrypoint\n * @returns A {@link Pregel} instance that can be run to execute the workflow\n *\n * @example Using entrypoint and tasks\n * ```typescript\n * import { task, entrypoint } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n * import { interrupt, Command } from \"@langchain/langgraph\";\n *\n * const composeEssay = task(\"compose\", async (topic: string) => {\n * await new Promise(r => setTimeout(r, 1000)); // Simulate slow operation\n * return `An essay about ${topic}`;\n * });\n *\n * const reviewWorkflow = entrypoint({\n * name: \"review\",\n * checkpointer: new MemorySaver()\n * }, async (topic: string) => {\n * const essay = await composeEssay(topic);\n * const humanReview = await interrupt({\n * question: \"Please provide a review\",\n * essay\n * });\n * return {\n * essay,\n * review: humanReview\n * };\n * });\n *\n * // Example configuration for the workflow\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * // Topic for the essay\n * const topic = \"cats\";\n *\n * // Stream the workflow to generate the essay and await human review\n * for await (const result of reviewWorkflow.stream(topic, config)) {\n * console.log(result);\n * }\n *\n * // Example human review provided after the interrupt\n * const humanReview = \"This essay is great.\";\n *\n * // Resume the workflow with the provided human review\n * for await (const result of reviewWorkflow.stream(new Command({ resume: humanReview }), config)) {\n * console.log(result);\n * }\n * ```\n *\n * @example Accessing the previous return value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const accumulator = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (input: string) => {\n * const previous = getPreviousState<number>();\n * return previous !== undefined ? `${previous } ${input}` : input;\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n * await accumulator.invoke(\"hello\", config); // returns \"hello\"\n * await accumulator.invoke(\"world\", config); // returns \"hello world\"\n * ```\n *\n * @example Using entrypoint.final to save a value\n * ```typescript\n * import { entrypoint, getPreviousState } from \"@langchain/langgraph\";\n * import { MemorySaver } from \"@langchain/langgraph-checkpoint\";\n *\n * const myWorkflow = entrypoint({\n * name: \"accumulator\",\n * checkpointer: new MemorySaver()\n * }, async (num: number) => {\n * const previous = getPreviousState<number>();\n *\n * // This will return the previous value to the caller, saving\n * // 2 * num to the checkpoint, which will be used in the next invocation\n * // for the `previous` parameter.\n * return entrypoint.final({\n * value: previous ?? 0,\n * save: 2 * num\n * });\n * });\n *\n * const config = {\n * configurable: {\n * thread_id: \"some_thread\"\n * }\n * };\n *\n * await myWorkflow.invoke(3, config); // 0 (previous was undefined)\n * await myWorkflow.invoke(1, config); // 6 (previous was 3 * 2 from the previous invocation)\n * ```\n * @category Functional API\n */\nexport declare const entrypoint: EntrypointFunction;\n/**\n * A helper utility function for use with the functional API that returns the previous\n * state from the checkpoint from the last invocation of the current thread.\n *\n * This function allows workflows to access state that was saved in previous runs\n * using {@link entrypoint.final}.\n *\n * @typeParam StateT - The type of the state that was previously saved\n * @returns The previous saved state from the last invocation of the current thread\n *\n * @example\n * ```typescript\n * const previousState = getPreviousState<{ counter: number }>();\n * const newCount = (previousState?.counter ?? 0) + 1;\n * ```\n * @category Functional API\n */\nexport declare function getPreviousState<StateT>(): StateT;\n"],"mappings":";;;;;;;;;;;;;AAWA;AAA4B,UAAXiB,WAAAA,CAAW;;;;EA8DJC,IAAAA,EAAAA,MAAI;EAAA;;;;OAA8EF,CAAAA,EArD9FN,WAqD8FM;;;;EAAsD,WAAA,CAAA,EAjD9IP,WAiD8I;AAIhK;;;;;;AAwBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkKA;AAkBA;;;;;iBAhNwBS,sDAAsDD,4BAA4BD,SAASG,OAAOC,qBAAqBD,UAAUE,QAAQD;;;;KAIrJE,iBAAAA;;;;;;;;;;iBAUOrB;;;;UAIPC;;;;UAIAF;;;;;;UAMKuB,kBAAAA;mCACoBD,kCAAkCP,eAAeS,QAAQJ,WAAWjB,OAAOsB,eAAerB,WAAWoB,QAAQX,kBAAkBO;KAC3Jb,KAAAA,GAAQC,eAAegB;KACvBnB,GAAAA,GAAMM,UAAUE,kBAAkBO;KAClCd,QAAAA,GAAWK,UAAUG,qBAAqBM;KAC5CK,yBAAyBD,QAAQX,kBAAkBO,eAAeM,QAAQb,kBAAkBO;;;;;;;;;;;;;;;;;;;;;YAqBnFO;WACDC;MACPhB,gBAAgBe,QAAQC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAsIXC,YAAYN;;;;;;;;;;;;;;;;;;iBAkBTO,4BAA4BC"}
|