@langchain/langgraph 1.4.20 → 1.5.0
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/base.cjs +113 -8
- package/dist/channels/base.cjs.map +1 -1
- package/dist/channels/base.d.cts +26 -4
- package/dist/channels/base.d.cts.map +1 -1
- package/dist/channels/base.d.ts +26 -4
- package/dist/channels/base.d.ts.map +1 -1
- package/dist/channels/base.js +110 -10
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/index.cjs +2 -0
- package/dist/channels/index.d.cts +2 -2
- package/dist/channels/index.d.ts +2 -2
- package/dist/channels/index.js +2 -2
- package/dist/constants.cjs +16 -2
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +15 -3
- package/dist/constants.js.map +1 -1
- package/dist/graph/index.cjs +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/graph/messages_reducer.cjs +7 -0
- package/dist/graph/messages_reducer.cjs.map +1 -1
- package/dist/graph/messages_reducer.js +7 -1
- package/dist/graph/messages_reducer.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/pregel/algo.cjs +46 -45
- 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 +47 -47
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/checkpoint.cjs +70 -0
- package/dist/pregel/checkpoint.cjs.map +1 -0
- package/dist/pregel/checkpoint.js +67 -0
- package/dist/pregel/checkpoint.js.map +1 -0
- package/dist/pregel/index.cjs +87 -34
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +91 -38
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/loop.cjs +325 -109
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +330 -115
- package/dist/pregel/loop.js.map +1 -1
- package/dist/state/prebuilt/messages.cjs +1 -1
- package/dist/state/prebuilt/messages.js +1 -1
- package/dist/web.cjs +1 -1
- package/dist/web.js +1 -1
- package/package.json +5 -5
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport {\n coerceTimeoutPolicy,\n type TimeoutPolicy,\n} from \"./pregel/utils/timeout.js\";\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 write key recording the name of the node whose execution\n * failed, so node-level error handlers see the same failure provenance after a\n * checkpoint resume. Value format in pending writes:\n * `[taskId, ERROR_SOURCE_NODE, nodeName: string]`.\n */\nexport const ERROR_SOURCE_NODE = \"__error_source_node__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\n/**\n * System-wide upper bound on how many supersteps a {@link DeltaChannel} may go\n * without writing a {@link DeltaSnapshot} blob. Once a channel's\n * supersteps-since-snapshot counter reaches this value, a snapshot is forced\n * even if the channel's own `snapshotFrequency` has not been reached — this\n * prevents unbounded ancestor walks on threads where a delta channel exists\n * but is no longer being updated.\n *\n * Overridable via the `LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`\n * environment variable. Read lazily so test/runtime overrides take effect.\n *\n * @remarks Beta.\n */\nexport function getDeltaMaxSuperstepsSinceSnapshot(): number {\n const raw =\n typeof process !== \"undefined\"\n ? process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT\n : undefined;\n if (raw !== undefined && raw !== \"\") {\n const parsed = Number.parseInt(raw, 10);\n if (Number.isFinite(parsed) && parsed > 0) return parsed;\n }\n return 5000;\n}\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/**\n * Config key holding a {@link NodeError} (failed source node + error) for the\n * current node-level error handler invocation. Injected when an error handler\n * task is prepared after the failing node's retry policy is exhausted.\n */\nexport const CONFIG_KEY_NODE_ERROR = \"__pregel_node_error\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_REPLAY_STATE = \"__pregel_replay_state\";\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 ERROR_SOURCE_NODE,\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 CONFIG_KEY_REPLAY_STATE,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const 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 = 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 * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task.\n */\n timeout?: TimeoutPolicy;\n}\n\n/** Keyword options for {@link Send}. */\nexport type SendOptions = {\n /**\n * Per-task timeout policy overriding the target node's timeout for this\n * pushed task. A bare number is treated as `runTimeout` (milliseconds).\n */\n timeout?: number | TimeoutPolicy;\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 * @remarks\n * A per-task timeout can be supplied via the third argument's `timeout` option\n * to override the target node's configured timeout for this specific pushed task:\n *\n * ```typescript\n * new Send(\"generate_joke\", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });\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<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task. A bare number is treated as a hard\n * `runTimeout` (in milliseconds).\n */\n public timeout?: TimeoutPolicy;\n\n constructor(node: Node, args: Args, options?: SendOptions) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n this.timeout = coerceTimeoutPolicy(options?.timeout);\n }\n\n toJSON() {\n return {\n lg_name: this.lg_name,\n node: this.node,\n args: this.args,\n timeout: this.timeout,\n };\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\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - If the value is the discriminator form ({ type: OVERWRITE, value }) that\n * results from JSON-serializing a typed `Overwrite` in another runtime (e.g.\n * a Python dataclass routed through the LangGraph API server, where the typed\n * instance is erased), extract it. Keeps Overwrite semantics intact across\n * cross-runtime JSON boundaries.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null) {\n if (OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n const rec = value as Record<string, unknown>;\n if (rec.type === OVERWRITE && \"value\" in rec) {\n return [true, rec.value as ValueType];\n }\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\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 * JSON Schema for the value expected when resuming this interrupt,\n * if the graph provided one via `interrupt(value, { responseSchema })`.\n */\n response_schema?: JSONSchema;\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 = 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\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\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 (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (isCommand(x)) {\n result = new Command(x);\n seen.set(x, result);\n } else if (_isSendInterface(x)) {\n result = new Send(\n x.node,\n x.args,\n x.timeout !== undefined ? { timeout: x.timeout } : undefined\n );\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":";;;AAQA,MAAa,QAAQ;;AAErB,MAAa,MAAM;AACnB,MAAa,QAAQ;AACrB,MAAa,OAAO;AACpB,MAAa,QAAQ;;;;;;;AAOrB,MAAa,oBAAoB;;AAGjC,MAAa,kBAAkB;;;;;;;;;;;;;;AAe/B,SAAgB,qCAA6C;CAC3D,MAAM,MACJ,OAAO,YAAY,cACf,QAAQ,KAAK,gDACb,KAAA;AACN,KAAI,QAAQ,KAAA,KAAa,QAAQ,IAAI;EACnC,MAAM,SAAS,OAAO,SAAS,KAAK,GAAG;AACvC,MAAI,OAAO,SAAS,OAAO,IAAI,SAAS,EAAG,QAAO;;AAEpD,QAAO;;AAGT,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;;;;;;AAOxC,MAAa,wBAAwB;AAGrC,MAAa,4BAA4B;AAEzC,MAAa,0BAA0B;AAEvC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,UAAU;AACxB,WAAqB,SAAS,mCAC7B,MACA,KACD;KACD;aAEO,aAAa,WAAW,aAAa,QAAQ,CAAC,cAAc,EAAE,EAAE;AACzE,YAAS;AACT,QAAK,IAAI,GAAG,OAAO;aACV,UAAU,EAAE,EAAE;AACvB,YAAS,IAAI,QAAQ,EAAE;AACvB,QAAK,IAAI,GAAG,OAAO;aACV,iBAAiB,EAAE,EAAE;AAC9B,YAAS,IAAI,KACX,EAAE,MACF,EAAE,MACF,EAAE,YAAY,KAAA,IAAY,EAAE,SAAS,EAAE,SAAS,GAAG,KAAA,EACpD;AACD,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,CACzC,QAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { PendingWrite } from \"@langchain/langgraph-checkpoint\";\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport {\n coerceTimeoutPolicy,\n type TimeoutPolicy,\n} from \"./pregel/utils/timeout.js\";\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 write key recording the name of the node whose execution\n * failed, so node-level error handlers see the same failure provenance after a\n * checkpoint resume. Value format in pending writes:\n * `[taskId, ERROR_SOURCE_NODE, nodeName: string]`.\n */\nexport const ERROR_SOURCE_NODE = \"__error_source_node__\";\n\n/** Special reserved cache namespaces */\nexport const CACHE_NS_WRITES = \"__pregel_ns_writes\";\n\n/**\n * System-wide upper bound on how many supersteps a {@link DeltaChannel} may go\n * without writing a {@link DeltaSnapshot} blob. Once a channel's\n * supersteps-since-snapshot counter reaches this value, a snapshot is forced\n * even if the channel's own `snapshotFrequency` has not been reached — this\n * prevents unbounded ancestor walks on threads where a delta channel exists\n * but is no longer being updated.\n *\n * Overridable via the `LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT`\n * environment variable. Read lazily so test/runtime overrides take effect.\n *\n * @remarks Beta.\n */\nexport function getDeltaMaxSuperstepsSinceSnapshot(): number {\n const raw =\n typeof process !== \"undefined\"\n ? process.env?.LANGGRAPH_DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT\n : undefined;\n if (raw !== undefined && raw !== \"\") {\n const parsed = Number.parseInt(raw, 10);\n if (Number.isFinite(parsed) && parsed > 0) return parsed;\n }\n return 5000;\n}\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/**\n * Config key holding a {@link NodeError} (failed source node + error) for the\n * current node-level error handler invocation. Injected when an error handler\n * task is prepared after the failing node's retry policy is exhausted.\n */\nexport const CONFIG_KEY_NODE_ERROR = \"__pregel_node_error\";\n\n// this one is part of public API\nexport const CONFIG_KEY_CHECKPOINT_MAP = \"checkpoint_map\";\n\nexport const CONFIG_KEY_REPLAY_STATE = \"__pregel_replay_state\";\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/**\n * `versions_seen` key recording which entries a snapshot-only version bump\n * advanced, and the versions those nodes really read.\n */\nexport const SNAPSHOT_BUMPS = \"__snapshot_bumps__\";\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/**\n * Stands in for `NULL_TASK_ID` as an exit-mode delta write's synthetic id (see\n * `exitDeltaTaskId`). No task's synthetic id can equal it: those keep the task\n * id's third group, and task ids are uuid5, so that group starts with 5.\n */\nexport const EXIT_DELTA_NULL_TASK_ID = \"00000000-0000-0000-0000-000000000001\";\n\nexport const RESERVED = [\n TAG_HIDDEN,\n INPUT,\n INTERRUPT,\n RESUME,\n ERROR,\n ERROR_SOURCE_NODE,\n NO_WRITES,\n SNAPSHOT_BUMPS,\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 CONFIG_KEY_REPLAY_STATE,\n];\n\nexport const CHECKPOINT_NAMESPACE_SEPARATOR = \"|\";\nexport const CHECKPOINT_NAMESPACE_END = \":\";\n\n/**\n * Symbol used internally to identify Command instances.\n * Exported to support cross-version type compatibility.\n * @internal\n */\nexport const 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 = 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 * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task.\n */\n timeout?: TimeoutPolicy;\n}\n\n/** Keyword options for {@link Send}. */\nexport type SendOptions = {\n /**\n * Per-task timeout policy overriding the target node's timeout for this\n * pushed task. A bare number is treated as `runTimeout` (milliseconds).\n */\n timeout?: number | TimeoutPolicy;\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 * @remarks\n * A per-task timeout can be supplied via the third argument's `timeout` option\n * to override the target node's configured timeout for this specific pushed task:\n *\n * ```typescript\n * new Send(\"generate_joke\", { subjects: [subject] }, { timeout: { idleTimeout: 5000 } });\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<\n Node extends string = string,\n Args = any,\n> implements SendInterface<Node, Args> {\n lg_name = \"Send\";\n\n public node: Node;\n\n public args: Args;\n\n /**\n * Optional per-task timeout policy that overrides the target node's timeout\n * for this specific pushed task. A bare number is treated as a hard\n * `runTimeout` (in milliseconds).\n */\n public timeout?: TimeoutPolicy;\n\n constructor(node: Node, args: Args, options?: SendOptions) {\n this.node = node;\n this.args = _deserializeCommandSendObjectGraph(args) as Args;\n this.timeout = coerceTimeoutPolicy(options?.timeout);\n }\n\n toJSON() {\n return {\n lg_name: this.lg_name,\n node: this.node,\n args: this.args,\n timeout: this.timeout,\n };\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\nexport const OVERWRITE = \"__overwrite__\";\n\n/**\n * An object representing a direct overwrite of a value for a channel.\n * Used to signal that the channel value should be replaced with the given value,\n * bypassing any reducer or binary operator logic.\n *\n * @template ValueType - The type of the value being overwritten.\n * @property {ValueType} [OVERWRITE] - The value to directly set.\n *\n * @example\n * const overwriteObj: OverwriteValue<number> = { __overwrite__: 123 };\n */\nexport interface OverwriteValue<ValueType> {\n [OVERWRITE]: ValueType;\n}\n\n/**\n * Bypass a reducer and write the wrapped value directly to a\n * {@link BinaryOperatorAggregate} channel.\n *\n * Receiving multiple `Overwrite` values for the same channel in a single\n * super-step will raise an {@link InvalidUpdateError}.\n *\n * @example\n * ```typescript\n * import { Annotation, StateGraph, Overwrite } from \"@langchain/langgraph\";\n *\n * const State = Annotation.Root({\n * messages: Annotation<string[]>({\n * reducer: (a, b) => a.concat(b),\n * default: () => [],\n * }),\n * });\n *\n * const replaceMessages = (_state: typeof State.State) => {\n * return { messages: new Overwrite([\"replacement\"]) };\n * };\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class Overwrite<ValueType = any> implements OverwriteValue<ValueType> {\n lg_name = \"Overwrite\";\n\n readonly [OVERWRITE]: ValueType;\n\n constructor(value: ValueType) {\n this[OVERWRITE] = value;\n }\n\n get value(): ValueType {\n return this[OVERWRITE];\n }\n\n toJSON() {\n return { [OVERWRITE]: this[OVERWRITE] };\n }\n\n static isInstance<ValueType>(value: unknown): value is Overwrite<ValueType> {\n if (!value || typeof value !== \"object\") return false;\n if (OVERWRITE in value) return true;\n if (\"lg_name\" in value && value.lg_name === \"Overwrite\") return true;\n return false;\n }\n}\n\n/**\n * Helper function to detect and extract the value from an Overwrite wrapper,\n * supporting both the Overwrite class instance and the serialized object format.\n *\n * Use to check if a provided value represents an Overwrite: returns the\n * unwrapped value if so, or undefined otherwise.\n *\n * - If the value is an Overwrite instance (preferred API), return its `.value`.\n * - If the value is a wire-format object ({ [OVERWRITE]: value }), extract it.\n * - If the value is the discriminator form ({ type: OVERWRITE, value }) that\n * results from JSON-serializing a typed `Overwrite` in another runtime (e.g.\n * a Python dataclass routed through the LangGraph API server, where the typed\n * instance is erased), extract it. Keeps Overwrite semantics intact across\n * cross-runtime JSON boundaries.\n * - Otherwise, returns undefined.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns The unwrapped value if value is an Overwrite, or undefined otherwise.\n * @internal\n */\nexport function _getOverwriteValue<ValueType>(\n value: unknown\n): [true, ValueType] | [false, undefined] {\n if (typeof value === \"object\" && value !== null) {\n if (OVERWRITE in value) {\n return [true, (value as Record<string, ValueType>)[OVERWRITE]];\n }\n const rec = value as Record<string, unknown>;\n if (rec.type === OVERWRITE && \"value\" in rec) {\n return [true, rec.value as ValueType];\n }\n }\n return [false, undefined];\n}\n\n/**\n * Type guard to check if a value is an Overwrite value -- either the class\n * instance or the wire format object.\n *\n * @template ValueType - The expected type of the Overwrite value.\n * @param value - The value to check (may be anything).\n * @returns `true` if the value is an Overwrite value, `false` otherwise.\n * @internal\n */\nexport function _isOverwriteValue<ValueType>(\n value: unknown\n): value is OverwriteValue<ValueType> {\n return _getOverwriteValue<ValueType>(value)[0];\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 * JSON Schema for the value expected when resuming this interrupt,\n * if the graph provided one via `interrupt(value, { responseSchema })`.\n */\n response_schema?: JSONSchema;\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 = 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 // Not `instanceof`: a Command built by another copy of this package must\n // still pass. Plain objects are rejected so JSON input cannot forge one.\n if (!isPlainObject(x) && \"lg_name\" in x && x.lg_name === \"Command\") {\n return true;\n }\n\n return false;\n}\n\nfunction isPlainObject(value: object): value is Record<string, unknown> {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\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 (x instanceof Command || x instanceof Send || !isPlainObject(x)) {\n result = x;\n seen.set(x, result);\n } else if (\"lg_name\" in x && x.lg_name === \"Command\") {\n result = new Command(x as CommandParams);\n seen.set(x, result);\n } else if (_isSendInterface(x)) {\n result = new Send(\n x.node,\n x.args,\n x.timeout !== undefined ? { timeout: x.timeout } : undefined\n );\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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AE,YAAY,KAAA,IAAY,EAAE,SAAS,EAAE,SAAS,GAAG,KAAA,EACpD;AACD,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,CACzC,QAAmC,OAClC,mCAAmC,OAAO,KAAK;;AAIrD,SAAO;;AAET,QAAO"}
|
package/dist/graph/index.cjs
CHANGED
package/dist/graph/index.js
CHANGED
|
@@ -139,8 +139,15 @@ function messagesDeltaReducer(state, writes) {
|
|
|
139
139
|
}
|
|
140
140
|
return result.filter((m) => m !== null);
|
|
141
141
|
}
|
|
142
|
+
const MESSAGES_DELTA_REDUCER = Symbol.for("langgraph.messages_delta_reducer");
|
|
143
|
+
Object.defineProperty(messagesDeltaReducer, MESSAGES_DELTA_REDUCER, { value: true });
|
|
144
|
+
/** @internal */
|
|
145
|
+
function isMessagesDeltaReducer(reducer) {
|
|
146
|
+
return typeof reducer === "function" && reducer[MESSAGES_DELTA_REDUCER] === true;
|
|
147
|
+
}
|
|
142
148
|
//#endregion
|
|
143
149
|
exports.REMOVE_ALL_MESSAGES = REMOVE_ALL_MESSAGES;
|
|
150
|
+
exports.isMessagesDeltaReducer = isMessagesDeltaReducer;
|
|
144
151
|
exports.messagesDeltaReducer = messagesDeltaReducer;
|
|
145
152
|
exports.messagesStateReducer = messagesStateReducer;
|
|
146
153
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_reducer.cjs","names":["coerceMessageLikeToMessage","RemoveMessage","BaseMessage"],"sources":["../../src/graph/messages_reducer.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n RemoveMessage,\n} from \"@langchain/core/messages\";\nimport { v4 } from \"@langchain/core/utils/uuid\";\n\n/**\n * Special value that signifies the intent to remove all previous messages in the state reducer.\n * Used as the unique identifier for a `RemoveMessage` instance which, when encountered,\n * causes all prior messages to be discarded, leaving only those following this marker.\n */\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\n/**\n * Type that represents an acceptable input for the messages state reducer.\n *\n * - Can be a single `BaseMessage` or `BaseMessageLike`.\n * - Can be an array of `BaseMessage` or `BaseMessageLike`.\n */\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Reducer function for combining two sets of messages in LangGraph's state system.\n *\n * This reducer handles several tasks:\n * 1. Normalizes both `left` and `right` message inputs to arrays.\n * 2. Coerces any message-like objects into real `BaseMessage` instances.\n * 3. Ensures all messages have unique, stable IDs by generating missing ones.\n * 4. If a `RemoveMessage` instance is encountered in `right` with the ID `REMOVE_ALL_MESSAGES`,\n * all previous messages are discarded and only the subsequent messages in `right` are returned.\n * 5. Otherwise, merges `left` and `right` messages together following these rules:\n * - If a message in `right` shares an ID with a message in `left`:\n * - If it is a `RemoveMessage`, that message (by ID) is marked for removal.\n * - If it is a normal message, it replaces the message with the same ID from `left`.\n * - If a message in `right` **does not exist** in `left`:\n * - If it is a `RemoveMessage`, this is considered an error (cannot remove non-existent ID).\n * - Otherwise, the message is appended.\n * - Messages flagged for removal are omitted from the final output.\n *\n * @param left - The existing array (or single message) of messages from current state.\n * @param right - The new array (or single message) of messages to be applied.\n * @returns A new array of `BaseMessage` objects representing the updated state.\n *\n * @throws Error if a `RemoveMessage` is used to delete a message with an ID that does not exist in the merged list.\n *\n * @example\n * ```ts\n * const msg1 = new AIMessage(\"hello\");\n * const msg2 = new HumanMessage(\"hi\");\n * const removal = new RemoveMessage({ id: msg1.id });\n * const newState = messagesStateReducer([msg1], [msg2, removal]);\n * // newState will only contain msg2 (msg1 is removed)\n * ```\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n // Ensure both left and right are arrays\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n\n // Convert all input to BaseMessage instances\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n\n // Assign missing IDs to any message in the left array\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n // Assign missing IDs and check for \"remove all\" marker in right array\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n // If RemoveMessage with special REMOVE_ALL_MESSAGES id is found\n if (RemoveMessage.isInstance(m) && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n // If remove-all is present, all previous messages are wiped; return only subsequent ones\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // Begin normal merging logic\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n // Case: updating or removing an existing message by id\n if (RemoveMessage.isInstance(m)) {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n // Case: inserting a completely new message\n if (RemoveMessage.isInstance(m)) {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n\n // Remove any messages whose IDs are marked for removal\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/**\n * **Experimental.** Batch reducer for use with `DeltaChannel`.\n *\n * Processes all writes in one pass — dedup by ID and `RemoveMessage`\n * tombstoning — without calling {@link messagesStateReducer}.\n *\n * This reducer is batching-invariant, as required by `DeltaChannel`:\n * `reducer(reducer(state, xs), ys) === reducer(state, xs.concat(ys))`.\n *\n * A `RemoveMessage` carrying the {@link REMOVE_ALL_MESSAGES} sentinel id\n * clears all messages accumulated so far (prior state plus earlier writes in\n * the same batch) and keeps only the messages that follow it, mirroring\n * {@link messagesStateReducer}. Clearing happens in the same single linear\n * pass, so the batching-invariant still holds.\n *\n * Raw object / string inputs are coerced to typed `BaseMessage` objects so\n * that HTTP-driven graphs work without a separate coercion step. This is not\n * full {@link messagesStateReducer} parity — unknown-id `RemoveMessage`\n * errors and missing-id UUID assignment are not handled here.\n *\n * @param state - The current accumulated list of messages.\n * @param writes - Batch of writes, each a single message-like or an array.\n * @returns The new accumulated list of messages.\n *\n * @example\n * ```typescript\n * import { DeltaChannel, messagesDeltaReducer } from \"@langchain/langgraph\";\n *\n * const channel = new DeltaChannel(messagesDeltaReducer);\n * ```\n */\nexport function messagesDeltaReducer(\n state: BaseMessage[],\n writes: Messages[]\n): BaseMessage[] {\n // Each write is either an array of message-likes or a single message-like.\n // Only arrays flatten; everything else is one message.\n const flat: BaseMessageLike[] = [];\n for (const w of writes) {\n if (Array.isArray(w)) {\n flat.push(...(w as BaseMessageLike[]));\n } else {\n flat.push(w as BaseMessageLike);\n }\n }\n\n // Steady state: the reducer's own output is already typed, so skip coercion\n // on state when the first element is a BaseMessage. Only raw input (initial\n // objects, deserialized blobs) hits the slow path.\n const stateMsgs: BaseMessage[] =\n state.length > 0 && BaseMessage.isInstance(state[0])\n ? state\n : (state as BaseMessageLike[]).map(coerceMessageLikeToMessage);\n const msgs: BaseMessage[] = flat.map(coerceMessageLikeToMessage);\n\n const index = new Map<string, number>();\n for (let i = 0; i < stateMsgs.length; i += 1) {\n const mid = stateMsgs[i].id;\n if (mid != null) index.set(mid, i);\n }\n\n const result: (BaseMessage | null)[] = [...stateMsgs];\n for (const msg of msgs) {\n const mid = msg.id;\n if (RemoveMessage.isInstance(msg) && mid === REMOVE_ALL_MESSAGES) {\n // Discard everything accumulated so far (prior state and earlier writes\n // in this batch); only messages following the sentinel are kept. Doing\n // this inline keeps the reducer batching-invariant.\n result.length = 0;\n index.clear();\n } else if (mid == null) {\n result.push(msg);\n } else if (RemoveMessage.isInstance(msg)) {\n if (index.has(mid)) {\n result[index.get(mid)!] = null;\n index.delete(mid);\n }\n } else if (index.has(mid)) {\n result[index.get(mid)!] = msg;\n } else {\n index.set(mid, result.length);\n result.push(msg);\n }\n }\n return result.filter((m): m is BaseMessage => m !== null);\n}\n"],"mappings":";;;;;;;;AAaA,MAAa,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CnC,SAAgB,qBACd,MACA,OACe;CAEf,MAAM,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;CACrD,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAGzD,MAAM,eAAgB,UAAgC,IACpDA,yBAAAA,2BACD;CACD,MAAM,gBAAiB,WAAiC,IACtDA,yBAAAA,2BACD;AAGD,MAAK,MAAM,KAAK,aACd,KAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAA,GAAW;AACvC,IAAE,MAAA,GAAA,2BAAA,KAAS;AACX,IAAE,UAAU,KAAK,EAAE;;CAKvB,IAAI;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK,GAAG;EAChD,MAAM,IAAI,cAAc;AACxB,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAA,GAAW;AACvC,KAAE,MAAA,GAAA,2BAAA,KAAS;AACX,KAAE,UAAU,KAAK,EAAE;;AAIrB,MAAIC,yBAAAA,cAAc,WAAW,EAAE,IAAI,EAAE,OAAA,iBACnC,gBAAe;;AAKnB,KAAI,gBAAgB,KAAM,QAAO,cAAc,MAAM,eAAe,EAAE;CAGtE,MAAM,SAAS,CAAC,GAAG,aAAa;CAChC,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,GAAG,MAAM,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hE,UAAO,SAAS;AAChB,SAAM,OAAO;aACJ,OAAO,KAChB,QAAO,KAAK,IAAI;WACPA,yBAAAA,cAAc,WAAW,IAAI;OAClC,MAAM,IAAI,IAAI,EAAE;AAClB,WAAO,MAAM,IAAI,IAAI,IAAK;AAC1B,UAAM,OAAO,IAAI;;aAEV,MAAM,IAAI,IAAI,CACvB,QAAO,MAAM,IAAI,IAAI,IAAK;OACrB;AACL,SAAM,IAAI,KAAK,OAAO,OAAO;AAC7B,UAAO,KAAK,IAAI;;;AAGpB,QAAO,OAAO,QAAQ,MAAwB,MAAM,KAAK"}
|
|
1
|
+
{"version":3,"file":"messages_reducer.cjs","names":["coerceMessageLikeToMessage","RemoveMessage","BaseMessage"],"sources":["../../src/graph/messages_reducer.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n RemoveMessage,\n} from \"@langchain/core/messages\";\nimport { v4 } from \"@langchain/core/utils/uuid\";\n\n/**\n * Special value that signifies the intent to remove all previous messages in the state reducer.\n * Used as the unique identifier for a `RemoveMessage` instance which, when encountered,\n * causes all prior messages to be discarded, leaving only those following this marker.\n */\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\n/**\n * Type that represents an acceptable input for the messages state reducer.\n *\n * - Can be a single `BaseMessage` or `BaseMessageLike`.\n * - Can be an array of `BaseMessage` or `BaseMessageLike`.\n */\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Reducer function for combining two sets of messages in LangGraph's state system.\n *\n * This reducer handles several tasks:\n * 1. Normalizes both `left` and `right` message inputs to arrays.\n * 2. Coerces any message-like objects into real `BaseMessage` instances.\n * 3. Ensures all messages have unique, stable IDs by generating missing ones.\n * 4. If a `RemoveMessage` instance is encountered in `right` with the ID `REMOVE_ALL_MESSAGES`,\n * all previous messages are discarded and only the subsequent messages in `right` are returned.\n * 5. Otherwise, merges `left` and `right` messages together following these rules:\n * - If a message in `right` shares an ID with a message in `left`:\n * - If it is a `RemoveMessage`, that message (by ID) is marked for removal.\n * - If it is a normal message, it replaces the message with the same ID from `left`.\n * - If a message in `right` **does not exist** in `left`:\n * - If it is a `RemoveMessage`, this is considered an error (cannot remove non-existent ID).\n * - Otherwise, the message is appended.\n * - Messages flagged for removal are omitted from the final output.\n *\n * @param left - The existing array (or single message) of messages from current state.\n * @param right - The new array (or single message) of messages to be applied.\n * @returns A new array of `BaseMessage` objects representing the updated state.\n *\n * @throws Error if a `RemoveMessage` is used to delete a message with an ID that does not exist in the merged list.\n *\n * @example\n * ```ts\n * const msg1 = new AIMessage(\"hello\");\n * const msg2 = new HumanMessage(\"hi\");\n * const removal = new RemoveMessage({ id: msg1.id });\n * const newState = messagesStateReducer([msg1], [msg2, removal]);\n * // newState will only contain msg2 (msg1 is removed)\n * ```\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n // Ensure both left and right are arrays\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n\n // Convert all input to BaseMessage instances\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n\n // Assign missing IDs to any message in the left array\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n // Assign missing IDs and check for \"remove all\" marker in right array\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n // If RemoveMessage with special REMOVE_ALL_MESSAGES id is found\n if (RemoveMessage.isInstance(m) && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n // If remove-all is present, all previous messages are wiped; return only subsequent ones\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // Begin normal merging logic\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n // Case: updating or removing an existing message by id\n if (RemoveMessage.isInstance(m)) {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n // Case: inserting a completely new message\n if (RemoveMessage.isInstance(m)) {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n\n // Remove any messages whose IDs are marked for removal\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/**\n * **Experimental.** Batch reducer for use with `DeltaChannel`.\n *\n * Processes all writes in one pass — dedup by ID and `RemoveMessage`\n * tombstoning — without calling {@link messagesStateReducer}.\n *\n * This reducer is batching-invariant, as required by `DeltaChannel`:\n * `reducer(reducer(state, xs), ys) === reducer(state, xs.concat(ys))`.\n *\n * A `RemoveMessage` carrying the {@link REMOVE_ALL_MESSAGES} sentinel id\n * clears all messages accumulated so far (prior state plus earlier writes in\n * the same batch) and keeps only the messages that follow it, mirroring\n * {@link messagesStateReducer}. Clearing happens in the same single linear\n * pass, so the batching-invariant still holds.\n *\n * Raw object / string inputs are coerced to typed `BaseMessage` objects so\n * that HTTP-driven graphs work without a separate coercion step. This is not\n * full {@link messagesStateReducer} parity — unknown-id `RemoveMessage`\n * errors and missing-id UUID assignment are not handled here.\n *\n * @param state - The current accumulated list of messages.\n * @param writes - Batch of writes, each a single message-like or an array.\n * @returns The new accumulated list of messages.\n *\n * @example\n * ```typescript\n * import { DeltaChannel, messagesDeltaReducer } from \"@langchain/langgraph\";\n *\n * const channel = new DeltaChannel(messagesDeltaReducer);\n * ```\n */\nexport function messagesDeltaReducer(\n state: BaseMessage[],\n writes: Messages[]\n): BaseMessage[] {\n // Each write is either an array of message-likes or a single message-like.\n // Only arrays flatten; everything else is one message.\n const flat: BaseMessageLike[] = [];\n for (const w of writes) {\n if (Array.isArray(w)) {\n flat.push(...(w as BaseMessageLike[]));\n } else {\n flat.push(w as BaseMessageLike);\n }\n }\n\n // Steady state: the reducer's own output is already typed, so skip coercion\n // on state when the first element is a BaseMessage. Only raw input (initial\n // objects, deserialized blobs) hits the slow path.\n const stateMsgs: BaseMessage[] =\n state.length > 0 && BaseMessage.isInstance(state[0])\n ? state\n : (state as BaseMessageLike[]).map(coerceMessageLikeToMessage);\n const msgs: BaseMessage[] = flat.map(coerceMessageLikeToMessage);\n\n const index = new Map<string, number>();\n for (let i = 0; i < stateMsgs.length; i += 1) {\n const mid = stateMsgs[i].id;\n if (mid != null) index.set(mid, i);\n }\n\n const result: (BaseMessage | null)[] = [...stateMsgs];\n for (const msg of msgs) {\n const mid = msg.id;\n if (RemoveMessage.isInstance(msg) && mid === REMOVE_ALL_MESSAGES) {\n // Discard everything accumulated so far (prior state and earlier writes\n // in this batch); only messages following the sentinel are kept. Doing\n // this inline keeps the reducer batching-invariant.\n result.length = 0;\n index.clear();\n } else if (mid == null) {\n result.push(msg);\n } else if (RemoveMessage.isInstance(msg)) {\n if (index.has(mid)) {\n result[index.get(mid)!] = null;\n index.delete(mid);\n }\n } else if (index.has(mid)) {\n result[index.get(mid)!] = msg;\n } else {\n index.set(mid, result.length);\n result.push(msg);\n }\n }\n return result.filter((m): m is BaseMessage => m !== null);\n}\n\n// A brand rather than reference equality, so the reducer is still recognized\n// from another copy of this package (its ESM and CJS builds both loaded, or a\n// copy nested under another package).\nconst MESSAGES_DELTA_REDUCER = Symbol.for(\"langgraph.messages_delta_reducer\");\nObject.defineProperty(messagesDeltaReducer, MESSAGES_DELTA_REDUCER, {\n value: true,\n});\n\n/** @internal */\nexport function isMessagesDeltaReducer(reducer: unknown): boolean {\n return (\n typeof reducer === \"function\" &&\n (reducer as unknown as Record<symbol, unknown>)[MESSAGES_DELTA_REDUCER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O;AAC7B,UAAO,KAAK,IAAI;;;AAGpB,QAAO,OAAO,QAAQ,MAAwB,MAAM,KAAK;;AAM3D,MAAM,yBAAyB,OAAO,IAAI,mCAAmC;AAC7E,OAAO,eAAe,sBAAsB,wBAAwB,EAClE,OAAO,MACR,CAAC;;AAGF,SAAgB,uBAAuB,SAA2B;AAChE,QACE,OAAO,YAAY,cAClB,QAA+C,4BAC9C"}
|
|
@@ -139,7 +139,13 @@ function messagesDeltaReducer(state, writes) {
|
|
|
139
139
|
}
|
|
140
140
|
return result.filter((m) => m !== null);
|
|
141
141
|
}
|
|
142
|
+
const MESSAGES_DELTA_REDUCER = Symbol.for("langgraph.messages_delta_reducer");
|
|
143
|
+
Object.defineProperty(messagesDeltaReducer, MESSAGES_DELTA_REDUCER, { value: true });
|
|
144
|
+
/** @internal */
|
|
145
|
+
function isMessagesDeltaReducer(reducer) {
|
|
146
|
+
return typeof reducer === "function" && reducer[MESSAGES_DELTA_REDUCER] === true;
|
|
147
|
+
}
|
|
142
148
|
//#endregion
|
|
143
|
-
export { REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer };
|
|
149
|
+
export { REMOVE_ALL_MESSAGES, isMessagesDeltaReducer, messagesDeltaReducer, messagesStateReducer };
|
|
144
150
|
|
|
145
151
|
//# sourceMappingURL=messages_reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_reducer.js","names":[],"sources":["../../src/graph/messages_reducer.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n RemoveMessage,\n} from \"@langchain/core/messages\";\nimport { v4 } from \"@langchain/core/utils/uuid\";\n\n/**\n * Special value that signifies the intent to remove all previous messages in the state reducer.\n * Used as the unique identifier for a `RemoveMessage` instance which, when encountered,\n * causes all prior messages to be discarded, leaving only those following this marker.\n */\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\n/**\n * Type that represents an acceptable input for the messages state reducer.\n *\n * - Can be a single `BaseMessage` or `BaseMessageLike`.\n * - Can be an array of `BaseMessage` or `BaseMessageLike`.\n */\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Reducer function for combining two sets of messages in LangGraph's state system.\n *\n * This reducer handles several tasks:\n * 1. Normalizes both `left` and `right` message inputs to arrays.\n * 2. Coerces any message-like objects into real `BaseMessage` instances.\n * 3. Ensures all messages have unique, stable IDs by generating missing ones.\n * 4. If a `RemoveMessage` instance is encountered in `right` with the ID `REMOVE_ALL_MESSAGES`,\n * all previous messages are discarded and only the subsequent messages in `right` are returned.\n * 5. Otherwise, merges `left` and `right` messages together following these rules:\n * - If a message in `right` shares an ID with a message in `left`:\n * - If it is a `RemoveMessage`, that message (by ID) is marked for removal.\n * - If it is a normal message, it replaces the message with the same ID from `left`.\n * - If a message in `right` **does not exist** in `left`:\n * - If it is a `RemoveMessage`, this is considered an error (cannot remove non-existent ID).\n * - Otherwise, the message is appended.\n * - Messages flagged for removal are omitted from the final output.\n *\n * @param left - The existing array (or single message) of messages from current state.\n * @param right - The new array (or single message) of messages to be applied.\n * @returns A new array of `BaseMessage` objects representing the updated state.\n *\n * @throws Error if a `RemoveMessage` is used to delete a message with an ID that does not exist in the merged list.\n *\n * @example\n * ```ts\n * const msg1 = new AIMessage(\"hello\");\n * const msg2 = new HumanMessage(\"hi\");\n * const removal = new RemoveMessage({ id: msg1.id });\n * const newState = messagesStateReducer([msg1], [msg2, removal]);\n * // newState will only contain msg2 (msg1 is removed)\n * ```\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n // Ensure both left and right are arrays\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n\n // Convert all input to BaseMessage instances\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n\n // Assign missing IDs to any message in the left array\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n // Assign missing IDs and check for \"remove all\" marker in right array\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n // If RemoveMessage with special REMOVE_ALL_MESSAGES id is found\n if (RemoveMessage.isInstance(m) && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n // If remove-all is present, all previous messages are wiped; return only subsequent ones\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // Begin normal merging logic\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n // Case: updating or removing an existing message by id\n if (RemoveMessage.isInstance(m)) {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n // Case: inserting a completely new message\n if (RemoveMessage.isInstance(m)) {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n\n // Remove any messages whose IDs are marked for removal\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/**\n * **Experimental.** Batch reducer for use with `DeltaChannel`.\n *\n * Processes all writes in one pass — dedup by ID and `RemoveMessage`\n * tombstoning — without calling {@link messagesStateReducer}.\n *\n * This reducer is batching-invariant, as required by `DeltaChannel`:\n * `reducer(reducer(state, xs), ys) === reducer(state, xs.concat(ys))`.\n *\n * A `RemoveMessage` carrying the {@link REMOVE_ALL_MESSAGES} sentinel id\n * clears all messages accumulated so far (prior state plus earlier writes in\n * the same batch) and keeps only the messages that follow it, mirroring\n * {@link messagesStateReducer}. Clearing happens in the same single linear\n * pass, so the batching-invariant still holds.\n *\n * Raw object / string inputs are coerced to typed `BaseMessage` objects so\n * that HTTP-driven graphs work without a separate coercion step. This is not\n * full {@link messagesStateReducer} parity — unknown-id `RemoveMessage`\n * errors and missing-id UUID assignment are not handled here.\n *\n * @param state - The current accumulated list of messages.\n * @param writes - Batch of writes, each a single message-like or an array.\n * @returns The new accumulated list of messages.\n *\n * @example\n * ```typescript\n * import { DeltaChannel, messagesDeltaReducer } from \"@langchain/langgraph\";\n *\n * const channel = new DeltaChannel(messagesDeltaReducer);\n * ```\n */\nexport function messagesDeltaReducer(\n state: BaseMessage[],\n writes: Messages[]\n): BaseMessage[] {\n // Each write is either an array of message-likes or a single message-like.\n // Only arrays flatten; everything else is one message.\n const flat: BaseMessageLike[] = [];\n for (const w of writes) {\n if (Array.isArray(w)) {\n flat.push(...(w as BaseMessageLike[]));\n } else {\n flat.push(w as BaseMessageLike);\n }\n }\n\n // Steady state: the reducer's own output is already typed, so skip coercion\n // on state when the first element is a BaseMessage. Only raw input (initial\n // objects, deserialized blobs) hits the slow path.\n const stateMsgs: BaseMessage[] =\n state.length > 0 && BaseMessage.isInstance(state[0])\n ? state\n : (state as BaseMessageLike[]).map(coerceMessageLikeToMessage);\n const msgs: BaseMessage[] = flat.map(coerceMessageLikeToMessage);\n\n const index = new Map<string, number>();\n for (let i = 0; i < stateMsgs.length; i += 1) {\n const mid = stateMsgs[i].id;\n if (mid != null) index.set(mid, i);\n }\n\n const result: (BaseMessage | null)[] = [...stateMsgs];\n for (const msg of msgs) {\n const mid = msg.id;\n if (RemoveMessage.isInstance(msg) && mid === REMOVE_ALL_MESSAGES) {\n // Discard everything accumulated so far (prior state and earlier writes\n // in this batch); only messages following the sentinel are kept. Doing\n // this inline keeps the reducer batching-invariant.\n result.length = 0;\n index.clear();\n } else if (mid == null) {\n result.push(msg);\n } else if (RemoveMessage.isInstance(msg)) {\n if (index.has(mid)) {\n result[index.get(mid)!] = null;\n index.delete(mid);\n }\n } else if (index.has(mid)) {\n result[index.get(mid)!] = msg;\n } else {\n index.set(mid, result.length);\n result.push(msg);\n }\n }\n return result.filter((m): m is BaseMessage => m !== null);\n}\n"],"mappings":";;;;;;;;AAaA,MAAa,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CnC,SAAgB,qBACd,MACA,OACe;CAEf,MAAM,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;CACrD,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAGzD,MAAM,eAAgB,UAAgC,IACpD,2BACD;CACD,MAAM,gBAAiB,WAAiC,IACtD,2BACD;AAGD,MAAK,MAAM,KAAK,aACd,KAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAA,GAAW;AACvC,IAAE,KAAK,IAAI;AACX,IAAE,UAAU,KAAK,EAAE;;CAKvB,IAAI;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK,GAAG;EAChD,MAAM,IAAI,cAAc;AACxB,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,KAAA,GAAW;AACvC,KAAE,KAAK,IAAI;AACX,KAAE,UAAU,KAAK,EAAE;;AAIrB,MAAI,cAAc,WAAW,EAAE,IAAI,EAAE,OAAA,iBACnC,gBAAe;;AAKnB,KAAI,gBAAgB,KAAM,QAAO,cAAc,MAAM,eAAe,EAAE;CAGtE,MAAM,SAAS,CAAC,GAAG,aAAa;CAChC,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,GAAG,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;CAC3D,MAAM,8BAAc,IAAI,KAAK;AAE7B,MAAK,MAAM,KAAK,eAAe;EAC7B,MAAM,cAAc,WAAW,IAAI,EAAE,GAAG;AACxC,MAAI,gBAAgB,KAAA,EAElB,KAAI,cAAc,WAAW,EAAE,CAC7B,aAAY,IAAI,EAAE,GAAG;OAChB;AACL,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KAAK,IAAI;;;AAGpB,QAAO,OAAO,QAAQ,MAAwB,MAAM,KAAK"}
|
|
1
|
+
{"version":3,"file":"messages_reducer.js","names":[],"sources":["../../src/graph/messages_reducer.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n RemoveMessage,\n} from \"@langchain/core/messages\";\nimport { v4 } from \"@langchain/core/utils/uuid\";\n\n/**\n * Special value that signifies the intent to remove all previous messages in the state reducer.\n * Used as the unique identifier for a `RemoveMessage` instance which, when encountered,\n * causes all prior messages to be discarded, leaving only those following this marker.\n */\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\n/**\n * Type that represents an acceptable input for the messages state reducer.\n *\n * - Can be a single `BaseMessage` or `BaseMessageLike`.\n * - Can be an array of `BaseMessage` or `BaseMessageLike`.\n */\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Reducer function for combining two sets of messages in LangGraph's state system.\n *\n * This reducer handles several tasks:\n * 1. Normalizes both `left` and `right` message inputs to arrays.\n * 2. Coerces any message-like objects into real `BaseMessage` instances.\n * 3. Ensures all messages have unique, stable IDs by generating missing ones.\n * 4. If a `RemoveMessage` instance is encountered in `right` with the ID `REMOVE_ALL_MESSAGES`,\n * all previous messages are discarded and only the subsequent messages in `right` are returned.\n * 5. Otherwise, merges `left` and `right` messages together following these rules:\n * - If a message in `right` shares an ID with a message in `left`:\n * - If it is a `RemoveMessage`, that message (by ID) is marked for removal.\n * - If it is a normal message, it replaces the message with the same ID from `left`.\n * - If a message in `right` **does not exist** in `left`:\n * - If it is a `RemoveMessage`, this is considered an error (cannot remove non-existent ID).\n * - Otherwise, the message is appended.\n * - Messages flagged for removal are omitted from the final output.\n *\n * @param left - The existing array (or single message) of messages from current state.\n * @param right - The new array (or single message) of messages to be applied.\n * @returns A new array of `BaseMessage` objects representing the updated state.\n *\n * @throws Error if a `RemoveMessage` is used to delete a message with an ID that does not exist in the merged list.\n *\n * @example\n * ```ts\n * const msg1 = new AIMessage(\"hello\");\n * const msg2 = new HumanMessage(\"hi\");\n * const removal = new RemoveMessage({ id: msg1.id });\n * const newState = messagesStateReducer([msg1], [msg2, removal]);\n * // newState will only contain msg2 (msg1 is removed)\n * ```\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n // Ensure both left and right are arrays\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n\n // Convert all input to BaseMessage instances\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n\n // Assign missing IDs to any message in the left array\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n // Assign missing IDs and check for \"remove all\" marker in right array\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n // If RemoveMessage with special REMOVE_ALL_MESSAGES id is found\n if (RemoveMessage.isInstance(m) && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n // If remove-all is present, all previous messages are wiped; return only subsequent ones\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // Begin normal merging logic\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n // Case: updating or removing an existing message by id\n if (RemoveMessage.isInstance(m)) {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n // Case: inserting a completely new message\n if (RemoveMessage.isInstance(m)) {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n\n // Remove any messages whose IDs are marked for removal\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/**\n * **Experimental.** Batch reducer for use with `DeltaChannel`.\n *\n * Processes all writes in one pass — dedup by ID and `RemoveMessage`\n * tombstoning — without calling {@link messagesStateReducer}.\n *\n * This reducer is batching-invariant, as required by `DeltaChannel`:\n * `reducer(reducer(state, xs), ys) === reducer(state, xs.concat(ys))`.\n *\n * A `RemoveMessage` carrying the {@link REMOVE_ALL_MESSAGES} sentinel id\n * clears all messages accumulated so far (prior state plus earlier writes in\n * the same batch) and keeps only the messages that follow it, mirroring\n * {@link messagesStateReducer}. Clearing happens in the same single linear\n * pass, so the batching-invariant still holds.\n *\n * Raw object / string inputs are coerced to typed `BaseMessage` objects so\n * that HTTP-driven graphs work without a separate coercion step. This is not\n * full {@link messagesStateReducer} parity — unknown-id `RemoveMessage`\n * errors and missing-id UUID assignment are not handled here.\n *\n * @param state - The current accumulated list of messages.\n * @param writes - Batch of writes, each a single message-like or an array.\n * @returns The new accumulated list of messages.\n *\n * @example\n * ```typescript\n * import { DeltaChannel, messagesDeltaReducer } from \"@langchain/langgraph\";\n *\n * const channel = new DeltaChannel(messagesDeltaReducer);\n * ```\n */\nexport function messagesDeltaReducer(\n state: BaseMessage[],\n writes: Messages[]\n): BaseMessage[] {\n // Each write is either an array of message-likes or a single message-like.\n // Only arrays flatten; everything else is one message.\n const flat: BaseMessageLike[] = [];\n for (const w of writes) {\n if (Array.isArray(w)) {\n flat.push(...(w as BaseMessageLike[]));\n } else {\n flat.push(w as BaseMessageLike);\n }\n }\n\n // Steady state: the reducer's own output is already typed, so skip coercion\n // on state when the first element is a BaseMessage. Only raw input (initial\n // objects, deserialized blobs) hits the slow path.\n const stateMsgs: BaseMessage[] =\n state.length > 0 && BaseMessage.isInstance(state[0])\n ? state\n : (state as BaseMessageLike[]).map(coerceMessageLikeToMessage);\n const msgs: BaseMessage[] = flat.map(coerceMessageLikeToMessage);\n\n const index = new Map<string, number>();\n for (let i = 0; i < stateMsgs.length; i += 1) {\n const mid = stateMsgs[i].id;\n if (mid != null) index.set(mid, i);\n }\n\n const result: (BaseMessage | null)[] = [...stateMsgs];\n for (const msg of msgs) {\n const mid = msg.id;\n if (RemoveMessage.isInstance(msg) && mid === REMOVE_ALL_MESSAGES) {\n // Discard everything accumulated so far (prior state and earlier writes\n // in this batch); only messages following the sentinel are kept. Doing\n // this inline keeps the reducer batching-invariant.\n result.length = 0;\n index.clear();\n } else if (mid == null) {\n result.push(msg);\n } else if (RemoveMessage.isInstance(msg)) {\n if (index.has(mid)) {\n result[index.get(mid)!] = null;\n index.delete(mid);\n }\n } else if (index.has(mid)) {\n result[index.get(mid)!] = msg;\n } else {\n index.set(mid, result.length);\n result.push(msg);\n }\n }\n return result.filter((m): m is BaseMessage => m !== null);\n}\n\n// A brand rather than reference equality, so the reducer is still recognized\n// from another copy of this package (its ESM and CJS builds both loaded, or a\n// copy nested under another package).\nconst MESSAGES_DELTA_REDUCER = Symbol.for(\"langgraph.messages_delta_reducer\");\nObject.defineProperty(messagesDeltaReducer, MESSAGES_DELTA_REDUCER, {\n value: true,\n});\n\n/** @internal */\nexport function isMessagesDeltaReducer(reducer: unknown): boolean {\n return (\n typeof reducer === \"function\" &&\n (reducer as unknown as Record<symbol, unknown>)[MESSAGES_DELTA_REDUCER] ===\n true\n );\n}\n"],"mappings":";;;;;;;;AAaA,MAAa,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CnC,SAAgB,qBACd,MACA,OACe;CAEf,MAAM,YAAY,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;CACrD,MAAM,aAAa,MAAM,QAAQ,MAAM,GAAG,QAAQ,CAAC,MAAM;CAGzD,MAAM,eAAgB,UAAgC,IACpD,2BACD;CACD,MAAM,gBAAiB,WAAiC,IACtD,2BACD;AAGD,MAAK,MAAM,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C,MAAK,KAAK,EAAqB;CAOnC,MAAM,YACJ,MAAM,SAAS,KAAK,YAAY,WAAW,MAAM,GAAG,GAChD,QACC,MAA4B,IAAI,2BAA2B;CAClE,MAAM,OAAsB,KAAK,IAAI,2BAA2B;CAEhE,MAAM,wBAAQ,IAAI,KAAqB;AACvC,MAAK,IAAI,IAAI,GAAG,IAAI,UAAU,QAAQ,KAAK,GAAG;EAC5C,MAAM,MAAM,UAAU,GAAG;AACzB,MAAI,OAAO,KAAM,OAAM,IAAI,KAAK,EAAE;;CAGpC,MAAM,SAAiC,CAAC,GAAG,UAAU;AACrD,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,MAAM,IAAI;AAChB,MAAI,cAAc,WAAW,IAAI,IAAI,QAAA,kBAA6B;AAIhE,UAAO,SAAS;AAChB,SAAM,OAAO;aACJ,OAAO,KAChB,QAAO,KAAK,IAAI;WACP,cAAc,WAAW,IAAI;OAClC,MAAM,IAAI,IAAI,EAAE;AAClB,WAAO,MAAM,IAAI,IAAI,IAAK;AAC1B,UAAM,OAAO,IAAI;;aAEV,MAAM,IAAI,IAAI,CACvB,QAAO,MAAM,IAAI,IAAI,IAAK;OACrB;AACL,SAAM,IAAI,KAAK,OAAO,OAAO;AAC7B,UAAO,KAAK,IAAI;;;AAGpB,QAAO,OAAO,QAAQ,MAAwB,MAAM,KAAK;;AAM3D,MAAM,yBAAyB,OAAO,IAAI,mCAAmC;AAC7E,OAAO,eAAe,sBAAsB,wBAAwB,EAClE,OAAO,MACR,CAAC;;AAGF,SAAgB,uBAAuB,SAA2B;AAChE,QACE,OAAO,YAAY,cAClB,QAA+C,4BAC9C"}
|
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,7 @@ const require_annotation = require("./graph/annotation.cjs");
|
|
|
8
8
|
const require_config = require("./pregel/utils/config.cjs");
|
|
9
9
|
const require_callbacks = require("./callbacks.cjs");
|
|
10
10
|
const require_runtime = require("./pregel/runtime.cjs");
|
|
11
|
+
const require_messages_reducer = require("./graph/messages_reducer.cjs");
|
|
11
12
|
const require_convert = require("./stream/convert.cjs");
|
|
12
13
|
const require_stream_channel = require("./stream/stream-channel.cjs");
|
|
13
14
|
const require_lifecycle = require("./stream/transformers/lifecycle.cjs");
|
|
@@ -26,7 +27,6 @@ const require_reduced = require("./state/values/reduced.cjs");
|
|
|
26
27
|
const require_untracked = require("./state/values/untracked.cjs");
|
|
27
28
|
const require_delta$1 = require("./state/values/delta.cjs");
|
|
28
29
|
const require_schema = require("./state/schema.cjs");
|
|
29
|
-
const require_messages_reducer = require("./graph/messages_reducer.cjs");
|
|
30
30
|
const require_messages$1 = require("./state/prebuilt/messages.cjs");
|
|
31
31
|
const require_state = require("./graph/state.cjs");
|
|
32
32
|
const require_message = require("./graph/message.cjs");
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { Annotation } from "./graph/annotation.js";
|
|
|
7
7
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
8
8
|
import { GraphCallbackHandler } from "./callbacks.js";
|
|
9
9
|
import { RunControl } from "./pregel/runtime.js";
|
|
10
|
+
import { REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
|
|
10
11
|
import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
|
|
11
12
|
import { StreamChannel } from "./stream/stream-channel.js";
|
|
12
13
|
import { createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
|
|
@@ -26,7 +27,6 @@ import { ReducedValue } from "./state/values/reduced.js";
|
|
|
26
27
|
import { UntrackedValue } from "./state/values/untracked.js";
|
|
27
28
|
import { DeltaValue } from "./state/values/delta.js";
|
|
28
29
|
import { StateSchema } from "./state/schema.js";
|
|
29
|
-
import { REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
|
|
30
30
|
import { MessagesDeltaValue, MessagesValue } from "./state/prebuilt/messages.js";
|
|
31
31
|
import { CompiledStateGraph, StateGraph } from "./graph/state.js";
|
|
32
32
|
import { MessageGraph, pushMessage } from "./graph/message.js";
|
package/dist/pregel/algo.cjs
CHANGED
|
@@ -12,6 +12,28 @@ let _langchain_core_runnables = require("@langchain/core/runnables");
|
|
|
12
12
|
const increment = (current) => {
|
|
13
13
|
return current !== void 0 ? current + 1 : 1;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Serialize a task path to the string stored with its writes, matching
|
|
17
|
+
* Python's `task_path_str` byte for byte:
|
|
18
|
+
*
|
|
19
|
+
* - arrays (nested paths included) become `"~"` + their serialized elements
|
|
20
|
+
* joined by `", "` — so the empty path is `"~"`;
|
|
21
|
+
* - booleans format as ints (Python's `isinstance(x, int)` is true for
|
|
22
|
+
* `bool` there): `true` → `"0000000001"`, `false` → `"0000000000"`;
|
|
23
|
+
* - ints are zero-padded to 10 digits, sign-aware: `-1` → `"-000000001"`;
|
|
24
|
+
* - anything else (node names) is used as-is.
|
|
25
|
+
*
|
|
26
|
+
* This is the `taskPath` passed to `BaseCheckpointSaver.putWrites` and the
|
|
27
|
+
* first component of `writesSortKey`, so the stored string and its sort
|
|
28
|
+
* order are identical across the JS and Python runtimes.
|
|
29
|
+
*/
|
|
30
|
+
function taskPathStr(path) {
|
|
31
|
+
if (Array.isArray(path)) return `~${path.map(taskPathStr).join(", ")}`;
|
|
32
|
+
if (typeof path === "boolean") return path ? "0000000001" : "0000000000";
|
|
33
|
+
if (typeof path === "number") return path < 0 ? `-${String(-path).padStart(9, "0")}` : String(path).padStart(10, "0");
|
|
34
|
+
if (path === void 0 || path === null) return "~";
|
|
35
|
+
return String(path);
|
|
36
|
+
}
|
|
15
37
|
function triggersNextStep(updatedChannels, triggerToNodes) {
|
|
16
38
|
if (triggerToNodes == null) return false;
|
|
17
39
|
for (const chan of updatedChannels) if (triggerToNodes[chan]) return true;
|
|
@@ -87,17 +109,9 @@ const IGNORE = new Set([
|
|
|
87
109
|
]);
|
|
88
110
|
const RESERVED_SET = new Set(require_constants.RESERVED);
|
|
89
111
|
function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNodes) {
|
|
90
|
-
const
|
|
91
|
-
for (const task of tasks)
|
|
92
|
-
tasks.sort((a, b) =>
|
|
93
|
-
const aPath = pathCache.get(a);
|
|
94
|
-
const bPath = pathCache.get(b);
|
|
95
|
-
for (let i = 0; i < Math.min(aPath.length, bPath.length); i += 1) {
|
|
96
|
-
if (aPath[i] < bPath[i]) return -1;
|
|
97
|
-
if (aPath[i] > bPath[i]) return 1;
|
|
98
|
-
}
|
|
99
|
-
return aPath.length - bPath.length;
|
|
100
|
-
});
|
|
112
|
+
const sortKeys = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const task of tasks) sortKeys.set(task, (0, _langchain_langgraph_checkpoint.writesSortKey)(taskPathStr(task.path)));
|
|
114
|
+
tasks.sort((a, b) => (0, _langchain_langgraph_checkpoint.compareWritesSortKeys)(sortKeys.get(a), sortKeys.get(b)));
|
|
101
115
|
const onlyChannels = require_base.getOnlyChannels(channels);
|
|
102
116
|
let bumpStep = false;
|
|
103
117
|
const channelsToConsume = /* @__PURE__ */ new Set();
|
|
@@ -110,36 +124,20 @@ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNode
|
|
|
110
124
|
}
|
|
111
125
|
}
|
|
112
126
|
let maxVersion = maxChannelMapVersion(checkpoint.channel_versions);
|
|
113
|
-
let
|
|
127
|
+
let consumedVersion;
|
|
114
128
|
for (const chan of channelsToConsume) if (chan in onlyChannels && onlyChannels[chan].consume()) {
|
|
115
129
|
if (getNextVersion !== void 0) {
|
|
116
|
-
|
|
117
|
-
|
|
130
|
+
consumedVersion ??= getNextVersion(maxVersion);
|
|
131
|
+
checkpoint.channel_versions[chan] = consumedVersion;
|
|
118
132
|
}
|
|
119
133
|
}
|
|
120
134
|
const pendingWritesByChannel = {};
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
for (const [chan, val] of task.writes) if (IGNORE.has(chan)) {} else if (chan in onlyChannels) {
|
|
125
|
-
pendingWritesByChannel[chan] ??= [];
|
|
126
|
-
pendingWritesByChannel[chan].push(val);
|
|
127
|
-
pendingWriteTaskIdsByChannel[chan] ??= [];
|
|
128
|
-
pendingWriteTaskIdsByChannel[chan].push(taskId);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
for (const [chan, vals] of Object.entries(pendingWritesByChannel)) {
|
|
132
|
-
if (vals.length < 2) continue;
|
|
133
|
-
if (onlyChannels[chan]?.lc_graph_name !== "DeltaChannel") continue;
|
|
134
|
-
const taskIds = pendingWriteTaskIdsByChannel[chan];
|
|
135
|
-
const paired = vals.map((val, i) => ({
|
|
136
|
-
val,
|
|
137
|
-
taskId: taskIds[i]
|
|
138
|
-
}));
|
|
139
|
-
paired.sort((a, b) => a.taskId < b.taskId ? -1 : a.taskId > b.taskId ? 1 : 0);
|
|
140
|
-
pendingWritesByChannel[chan] = paired.map((p) => p.val);
|
|
135
|
+
for (const task of tasks) for (const [chan, val] of task.writes) if (IGNORE.has(chan)) {} else if (chan in onlyChannels) {
|
|
136
|
+
pendingWritesByChannel[chan] ??= [];
|
|
137
|
+
pendingWritesByChannel[chan].push(val);
|
|
141
138
|
}
|
|
142
|
-
if (maxVersion != null &&
|
|
139
|
+
if (maxVersion != null && consumedVersion !== void 0) maxVersion = consumedVersion;
|
|
140
|
+
const nextVersion = getNextVersion?.(maxVersion);
|
|
143
141
|
const updatedChannels = /* @__PURE__ */ new Set();
|
|
144
142
|
for (const [chan, vals] of Object.entries(pendingWritesByChannel)) if (chan in onlyChannels) {
|
|
145
143
|
const channel = onlyChannels[chan];
|
|
@@ -154,7 +152,7 @@ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNode
|
|
|
154
152
|
} else throw e;
|
|
155
153
|
}
|
|
156
154
|
if (updated && getNextVersion !== void 0) {
|
|
157
|
-
checkpoint.channel_versions[chan] =
|
|
155
|
+
checkpoint.channel_versions[chan] = nextVersion;
|
|
158
156
|
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
159
157
|
}
|
|
160
158
|
}
|
|
@@ -163,7 +161,7 @@ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNode
|
|
|
163
161
|
const channel = onlyChannels[chan];
|
|
164
162
|
if (channel.isAvailable() && !updatedChannels.has(chan)) {
|
|
165
163
|
if (channel.update([]) && getNextVersion !== void 0) {
|
|
166
|
-
checkpoint.channel_versions[chan] =
|
|
164
|
+
checkpoint.channel_versions[chan] = nextVersion;
|
|
167
165
|
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
168
166
|
}
|
|
169
167
|
}
|
|
@@ -172,7 +170,7 @@ function _applyWrites(checkpoint, channels, tasks, getNextVersion, triggerToNode
|
|
|
172
170
|
if (!Object.prototype.hasOwnProperty.call(onlyChannels, chan)) continue;
|
|
173
171
|
const channel = onlyChannels[chan];
|
|
174
172
|
if (channel.finish() && getNextVersion !== void 0) {
|
|
175
|
-
checkpoint.channel_versions[chan] =
|
|
173
|
+
checkpoint.channel_versions[chan] = nextVersion;
|
|
176
174
|
if (channel.isAvailable()) updatedChannels.add(chan);
|
|
177
175
|
}
|
|
178
176
|
}
|
|
@@ -373,11 +371,12 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
|
|
|
373
371
|
index.toString()
|
|
374
372
|
]), checkpoint.id);
|
|
375
373
|
const taskCheckpointNamespace = `${checkpointNamespace}:${taskId}`;
|
|
374
|
+
const translatedTaskPath = [...taskPath.slice(0, 3), false];
|
|
376
375
|
let metadata = {
|
|
377
376
|
langgraph_step: step,
|
|
378
377
|
langgraph_node: packet.node,
|
|
379
378
|
langgraph_triggers: triggers,
|
|
380
|
-
langgraph_path:
|
|
379
|
+
langgraph_path: translatedTaskPath,
|
|
381
380
|
langgraph_checkpoint_ns: taskCheckpointNamespace,
|
|
382
381
|
checkpoint_ns: taskCheckpointNamespace
|
|
383
382
|
};
|
|
@@ -419,7 +418,7 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
|
|
|
419
418
|
name: packet.node,
|
|
420
419
|
writes,
|
|
421
420
|
triggers,
|
|
422
|
-
path:
|
|
421
|
+
path: translatedTaskPath
|
|
423
422
|
}, select_, fresh_),
|
|
424
423
|
[require_constants.CONFIG_KEY_CHECKPOINTER]: checkpointer ?? configurable["__pregel_checkpointer"],
|
|
425
424
|
[require_constants.CONFIG_KEY_CHECKPOINT_MAP]: {
|
|
@@ -453,7 +452,7 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
|
|
|
453
452
|
ttl: proc.cachePolicy.ttl
|
|
454
453
|
} : void 0,
|
|
455
454
|
id: taskId,
|
|
456
|
-
path:
|
|
455
|
+
path: translatedTaskPath,
|
|
457
456
|
writers: proc.getWriters(),
|
|
458
457
|
timeout: packet.timeout ?? proc.timeout
|
|
459
458
|
};
|
|
@@ -462,7 +461,7 @@ function _prepareSingleTask(taskPath, checkpoint, pendingWrites, processes, chan
|
|
|
462
461
|
id: taskId,
|
|
463
462
|
name: packet.node,
|
|
464
463
|
interrupts: [],
|
|
465
|
-
path:
|
|
464
|
+
path: translatedTaskPath
|
|
466
465
|
};
|
|
467
466
|
} else if (taskPath[0] === "__pregel_pull") {
|
|
468
467
|
const name = taskPath[1].toString();
|
|
@@ -624,10 +623,11 @@ function _prepareNodeErrorHandlerTask(failedTask, handlerNodeName, error, checkp
|
|
|
624
623
|
failedTask.id
|
|
625
624
|
]), checkpoint.id);
|
|
626
625
|
const taskCheckpointNamespace = `${checkpointNamespace}:${taskId}`;
|
|
626
|
+
const failedPath = failedTask.path?.slice(0, 3) ?? [];
|
|
627
627
|
const taskPath = [
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
628
|
+
failedPath[0] ?? "__pregel_push",
|
|
629
|
+
...failedPath.slice(1),
|
|
630
|
+
"node_error_handler",
|
|
631
631
|
false
|
|
632
632
|
];
|
|
633
633
|
let metadata = {
|
|
@@ -793,5 +793,6 @@ exports._prepareSingleTask = _prepareSingleTask;
|
|
|
793
793
|
exports.increment = increment;
|
|
794
794
|
exports.sanitizeUntrackedValuesInSend = sanitizeUntrackedValuesInSend;
|
|
795
795
|
exports.shouldInterrupt = shouldInterrupt;
|
|
796
|
+
exports.taskPathStr = taskPathStr;
|
|
796
797
|
|
|
797
798
|
//# sourceMappingURL=algo.cjs.map
|