@langchain/langgraph 1.4.13 → 1.4.15-rc.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/func/index.cjs +1 -1
- package/dist/func/index.js +1 -1
- package/dist/graph/message.cjs +7 -4
- package/dist/graph/message.cjs.map +1 -1
- package/dist/graph/message.d.cts.map +1 -1
- package/dist/graph/message.d.ts.map +1 -1
- package/dist/graph/message.js +7 -4
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/state.cjs +3 -1
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.d.cts +4 -2
- package/dist/graph/state.d.cts.map +1 -1
- package/dist/graph/state.d.ts +4 -2
- package/dist/graph/state.d.ts.map +1 -1
- package/dist/graph/state.js +3 -1
- package/dist/graph/state.js.map +1 -1
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pregel/algo.cjs +1 -1
- package/dist/pregel/algo.js +1 -1
- package/dist/pregel/index.cjs +1 -1
- package/dist/pregel/index.js +1 -1
- package/dist/pregel/loop.cjs +1 -1
- package/dist/pregel/loop.js +1 -1
- package/dist/pregel/messages-v2.cjs +6 -0
- package/dist/pregel/messages-v2.cjs.map +1 -1
- package/dist/pregel/messages-v2.js +6 -0
- package/dist/pregel/messages-v2.js.map +1 -1
- package/dist/pregel/read.cjs +18 -7
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.cts +3 -1
- package/dist/pregel/read.d.cts.map +1 -1
- package/dist/pregel/read.d.ts +3 -1
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js +18 -7
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/runnable.cjs +103 -0
- package/dist/pregel/runnable.cjs.map +1 -0
- package/dist/pregel/runnable.js +103 -0
- package/dist/pregel/runnable.js.map +1 -0
- package/dist/pregel/runner.cjs +1 -1
- package/dist/pregel/runner.js +1 -1
- package/dist/pregel/utils/config.cjs +3 -2
- package/dist/pregel/utils/config.cjs.map +1 -1
- package/dist/pregel/utils/config.d.cts.map +1 -1
- package/dist/pregel/utils/config.d.ts.map +1 -1
- package/dist/pregel/utils/config.js +3 -2
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +8 -0
- package/dist/pregel/utils/index.cjs.map +1 -1
- package/dist/pregel/utils/index.d.cts +37 -1
- package/dist/pregel/utils/index.d.cts.map +1 -1
- package/dist/pregel/utils/index.d.ts +37 -1
- package/dist/pregel/utils/index.d.ts.map +1 -1
- package/dist/pregel/utils/index.js +8 -1
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/web.cjs +6 -4
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +2 -1
- package/package.json +7 -7
|
@@ -91,9 +91,10 @@ function mergeCallbacks(base, provided) {
|
|
|
91
91
|
for (const callback of base) manager.addHandler(ensureHandler(callback), true);
|
|
92
92
|
return manager;
|
|
93
93
|
}
|
|
94
|
+
const dedupeHandlers = (handlers) => handlers.filter((handler, index) => handlers.findIndex((candidate) => candidate === handler || candidate.name === "StreamMessagesHandler" && handler.name === "StreamMessagesHandler") === index);
|
|
94
95
|
return new CallbackManager(provided._parentRunId, {
|
|
95
|
-
handlers:
|
|
96
|
-
inheritableHandlers:
|
|
96
|
+
handlers: dedupeHandlers(base.handlers.concat(provided.handlers)),
|
|
97
|
+
inheritableHandlers: dedupeHandlers(base.inheritableHandlers.concat(provided.inheritableHandlers)),
|
|
97
98
|
tags: Array.from(new Set(base.tags.concat(provided.tags))),
|
|
98
99
|
inheritableTags: Array.from(new Set(base.inheritableTags.concat(provided.inheritableTags))),
|
|
99
100
|
metadata: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":[],"sources":["../../../src/pregel/utils/config.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport {\n CallbackManager,\n ensureHandler,\n type Callbacks,\n} from \"@langchain/core/callbacks/manager\";\nimport { BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { LangGraphRunnableConfig } from \"../runnable_types.js\";\nimport {\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CONFIG_KEY_READ,\n CONFIG_KEY_SCRATCHPAD,\n} from \"../../constants.js\";\n\nconst COPIABLE_KEYS = [\"tags\", \"metadata\", \"callbacks\", \"configurable\"];\n\nconst CONFIG_KEYS = [\n \"tags\",\n \"metadata\",\n \"callbacks\",\n \"runName\",\n \"maxConcurrency\",\n \"recursionLimit\",\n \"configurable\",\n \"runId\",\n \"outputKeys\",\n \"streamMode\",\n \"store\",\n \"writer\",\n \"interrupt\",\n \"context\",\n \"interruptBefore\",\n \"interruptAfter\",\n \"checkpointDuring\",\n \"durability\",\n \"signal\",\n \"heartbeat\",\n \"executionInfo\",\n \"serverInfo\",\n \"control\",\n];\n\nconst DEFAULT_RECURSION_LIMIT = 25;\nexport const PROPAGATE_TO_METADATA = new Set([\n \"thread_id\",\n \"checkpoint_id\",\n \"checkpoint_ns\",\n \"task_id\",\n \"run_id\",\n \"assistant_id\",\n \"graph_id\",\n]);\n\nexport function propagateConfigurableToMetadata(\n configurable?: Record<string, unknown>,\n metadata?: Record<string, unknown>\n): Record<string, unknown> | undefined {\n if (!configurable) {\n return metadata;\n }\n const result = metadata ?? {};\n for (const key of PROPAGATE_TO_METADATA) {\n if (key in result) {\n continue;\n }\n const value = configurable[key];\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/**\n * Drop langgraph's internal `seq:step*` bookkeeping tags.\n *\n * `seq:step:N` tags are added internally to mark sequence steps; everything\n * else (user-supplied tags and any other framework tags) is kept. Returns the\n * surviving tags, or `undefined` if none remain. Shared by the stream handlers\n * (e.g. {@link mapDebugTasks}) so the same tag set is surfaced consistently.\n */\nexport function filterToUserTags(\n tags: readonly string[] | undefined\n): string[] | undefined {\n if (tags == null || tags.length === 0) return undefined;\n const filtered = tags.filter((tag) => !tag.startsWith(\"seq:step\"));\n return filtered.length > 0 ? filtered : undefined;\n}\n\n/**\n * Merge two `callbacks` values across configs.\n *\n * A `callbacks` value may be `undefined`, an array of handlers, or a\n * {@link CallbackManager}, so merging two of them has six cases. This\n * mirrors the callbacks branch of langchain-core's `mergeConfigs` and\n * langgraph's `_merge_callbacks`, so a handler bound via\n * `.withConfig({ callbacks: [...] })` is preserved when a later config\n * (e.g. `streamEvents` injecting its own internal handler) is merged on\n * top instead of overwriting it.\n */\nfunction mergeCallbacks(\n base: Callbacks | undefined,\n provided: Callbacks | undefined\n): Callbacks | undefined {\n if (provided === undefined) return base;\n if (base === undefined) {\n return Array.isArray(provided) ? [...provided] : provided.copy();\n }\n if (Array.isArray(provided)) {\n if (Array.isArray(base)) return base.concat(provided);\n // base is a manager\n const manager = base.copy();\n for (const callback of provided) {\n manager.addHandler(ensureHandler(callback), true);\n }\n return manager;\n }\n // provided is a manager\n if (Array.isArray(base)) {\n const manager = provided.copy();\n for (const callback of base) {\n manager.addHandler(ensureHandler(callback), true);\n }\n return manager;\n }\n // both are managers\n return new CallbackManager(provided._parentRunId, {\n handlers: Array.from(new Set(base.handlers.concat(provided.handlers))),\n inheritableHandlers: Array.from(\n new Set(base.inheritableHandlers.concat(provided.inheritableHandlers))\n ),\n tags: Array.from(new Set(base.tags.concat(provided.tags))),\n inheritableTags: Array.from(\n new Set(base.inheritableTags.concat(provided.inheritableTags))\n ),\n metadata: { ...base.metadata, ...provided.metadata },\n inheritableMetadata: {\n ...base.inheritableMetadata,\n ...provided.inheritableMetadata,\n },\n });\n}\n\n/**\n * True when the caller is starting a fresh top-level run (invoke-time\n * `thread_id`, no active nesting keys). In that case the ambient `configurable`\n * from `AsyncLocalStorage` cannot be trusted per-key — it may belong to another\n * concurrent invocation on a shared singleton agent (scratchpad/task-input as\n * well as arbitrary user keys like `tenant_id`/`user_id`). The whole ambient\n * `configurable` is therefore ignored; any value the caller actually wants for\n * this run arrives through the explicit (bound + invoke-time) configs instead.\n *\n * Only the last caller-supplied config is treated as invoke-time options.\n * Earlier entries are graph-bound defaults from `.withConfig()` / compile and\n * must not count — a child graph bound with `thread_id` and invoked from a\n * parent task without a fresh config still needs ambient nesting keys from ALS.\n */\nfunction isRootLevelExplicitInvoke(\n configs: (LangGraphRunnableConfig | undefined)[]\n): boolean {\n let invokeConfig: LangGraphRunnableConfig | undefined;\n for (let i = configs.length - 1; i >= 0; i -= 1) {\n if (configs[i] !== undefined) {\n invokeConfig = configs[i];\n break;\n }\n }\n const hasInvokeTimeThreadId =\n invokeConfig?.configurable?.thread_id !== undefined;\n\n const hasExplicitNesting = configs.some(\n (c) => c?.configurable?.[CONFIG_KEY_READ] !== undefined\n );\n\n const ambientConfigurable =\n AsyncLocalStorageProviderSingleton.getRunnableConfig()?.configurable;\n const hasAmbientNesting =\n ambientConfigurable?.[CONFIG_KEY_READ] !== undefined;\n\n return hasInvokeTimeThreadId && !hasExplicitNesting && !hasAmbientNesting;\n}\n\nexport function ensureLangGraphConfig(\n ...configs: (LangGraphRunnableConfig | undefined)[]\n): RunnableConfig {\n const empty: LangGraphRunnableConfig = {\n tags: [],\n metadata: {},\n callbacks: undefined,\n recursionLimit: DEFAULT_RECURSION_LIMIT,\n configurable: {},\n };\n\n const skipImplicitConfigurable = isRootLevelExplicitInvoke(configs);\n\n const implicitConfig: RunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (implicitConfig !== undefined) {\n for (const [k, v] of Object.entries(implicitConfig)) {\n if (v !== undefined) {\n // Stale-ALS root invoke: ignore the ambient `configurable` entirely,\n // since its keys may belong to another concurrent invocation.\n if (k === \"configurable\" && skipImplicitConfigurable) {\n continue;\n }\n if (COPIABLE_KEYS.includes(k)) {\n let copiedValue;\n if (Array.isArray(v)) {\n copiedValue = [...v];\n } else if (typeof v === \"object\") {\n if (\n k === \"callbacks\" &&\n \"copy\" in v &&\n typeof v.copy === \"function\"\n ) {\n copiedValue = v.copy();\n } else {\n copiedValue = { ...v };\n }\n } else {\n copiedValue = v;\n }\n empty[k as keyof RunnableConfig] = copiedValue;\n } else {\n empty[k as keyof RunnableConfig] = v;\n }\n }\n }\n }\n\n for (const config of configs) {\n if (config === undefined) {\n continue;\n }\n\n for (const [k, v] of Object.entries(config)) {\n if (v === undefined || !CONFIG_KEYS.includes(k)) {\n continue;\n }\n\n // Merge (rather than overwrite) the fields that compose across\n // multiple configs, matching langgraph's `merge_configs` /\n // langchain-core's `mergeConfigs`. Without this, a value bound via\n // `.withConfig({...})` is silently dropped whenever a later config\n // (e.g. invoke-time, or `streamEvents`' internal handler) supplies\n // any other key in the same field. Later configs still win per key\n // on collision.\n if (k === \"configurable\") {\n empty.configurable = {\n ...(empty.configurable as Record<string, unknown> | undefined),\n ...(v as Record<string, unknown>),\n };\n } else if (k === \"metadata\") {\n empty.metadata = {\n ...(empty.metadata as Record<string, unknown> | undefined),\n ...(v as Record<string, unknown>),\n };\n } else if (k === \"tags\") {\n // Plain concat (matches langgraph's `merge_configs`): no dedup,\n // no sort.\n empty.tags = [\n ...((empty.tags as string[] | undefined) ?? []),\n ...(v as string[]),\n ];\n } else if (k === \"callbacks\") {\n empty.callbacks = mergeCallbacks(empty.callbacks, v as Callbacks);\n } else {\n empty[k as keyof LangGraphRunnableConfig] = v;\n }\n }\n }\n\n empty.metadata =\n propagateConfigurableToMetadata(\n empty.configurable as Record<string, unknown> | undefined,\n empty.metadata as Record<string, unknown> | undefined\n ) ?? {};\n return empty;\n}\n\n/**\n * A helper utility function that returns the {@link BaseStore} that was set when the graph was initialized\n *\n * @returns a reference to the {@link BaseStore} that was set when the graph was initialized\n */\nexport function getStore(\n config?: LangGraphRunnableConfig\n): BaseStore | undefined {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getStore` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n return runConfig?.store;\n}\n\n/**\n * A helper utility function that returns the {@link LangGraphRunnableConfig#writer} if \"custom\" stream mode is enabled, otherwise undefined.\n *\n * @returns a reference to the {@link LangGraphRunnableConfig#writer} if \"custom\" stream mode is enabled, otherwise undefined\n */\nexport function getWriter(\n config?: LangGraphRunnableConfig\n): ((chunk: unknown) => void) | undefined {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getWriter` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n return runConfig?.writer || runConfig?.configurable?.writer;\n}\n\n/**\n * A helper utility function that returns the {@link LangGraphRunnableConfig} that was set when the graph was initialized.\n *\n * Note: This only works when running in an environment that supports node:async_hooks and AsyncLocalStorage. If you're running this in a\n * web environment, access the LangGraphRunnableConfig from the node function directly.\n *\n * @returns the {@link LangGraphRunnableConfig} that was set when the graph was initialized\n */\nexport function getConfig(): LangGraphRunnableConfig {\n return AsyncLocalStorageProviderSingleton.getRunnableConfig();\n}\n\n/**\n * A helper utility function that returns the input for the currently executing\n * task.\n *\n * Note: When called without arguments, this relies on `node:async_hooks` /\n * `AsyncLocalStorage`, which is available in many JavaScript environments\n * (Node.js, Deno, Cloudflare Workers) but not in web browsers. In environments\n * without `AsyncLocalStorage` support, pass the `config` that your node/tool\n * function receives directly, e.g. `getCurrentTaskInput(config)`.\n *\n * Tip: Inside a tool run by a `ToolNode`, prefer reading graph state from\n * `runtime.state` on the second tool argument (typed as `ToolRuntime` from\n * `@langchain/core/tools`). It works in every runtime, including web browsers.\n *\n * @param config - Optional {@link LangGraphRunnableConfig} to read the task\n * input from. Provide this when running in an environment without\n * `AsyncLocalStorage` support (e.g. web browsers).\n * @returns the input for the currently executing task\n */\nexport function getCurrentTaskInput<T = unknown>(\n config?: LangGraphRunnableConfig\n): T {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n if (\n runConfig.configurable?.[CONFIG_KEY_SCRATCHPAD]?.currentTaskInput ===\n undefined\n ) {\n throw new Error(\"BUG: internal scratchpad not initialized.\");\n }\n\n return runConfig!.configurable![CONFIG_KEY_SCRATCHPAD]!.currentTaskInput as T;\n}\n\nexport function recastCheckpointNamespace(namespace: string): string {\n return namespace\n .split(CHECKPOINT_NAMESPACE_SEPARATOR)\n .filter((part) => !part.match(/^\\d+$/))\n .map((part) => part.split(CHECKPOINT_NAMESPACE_END)[0])\n .join(CHECKPOINT_NAMESPACE_SEPARATOR);\n}\n\nexport function getParentCheckpointNamespace(namespace: string): string {\n const parts = namespace.split(CHECKPOINT_NAMESPACE_SEPARATOR);\n while (parts.length > 1 && parts[parts.length - 1].match(/^\\d+$/)) {\n parts.pop();\n }\n return parts.slice(0, -1).join(CHECKPOINT_NAMESPACE_SEPARATOR);\n}\n"],"mappings":";;;;AAgBA,MAAM,gBAAgB;CAAC;CAAQ;CAAY;CAAa;CAAe;AAEvE,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,0BAA0B;AAChC,MAAa,wBAAwB,IAAI,IAAI;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SA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AEA,OAAM,IAAI,MAAM,4CAA4C;AAG9D,QAAO,UAAW,aAAc,uBAAwB;;AAG1D,SAAgB,0BAA0B,WAA2B;AACnE,QAAO,UACJ,MAAA,IAAqC,CACrC,QAAQ,SAAS,CAAC,KAAK,MAAM,QAAQ,CAAC,CACtC,KAAK,SAAS,KAAK,MAAA,IAA+B,CAAC,GAAG,CACtD,KAAA,IAAoC;;AAGzC,SAAgB,6BAA6B,WAA2B;CACtE,MAAM,QAAQ,UAAU,MAAA,IAAqC;AAC7D,QAAO,MAAM,SAAS,KAAK,MAAM,MAAM,SAAS,GAAG,MAAM,QAAQ,CAC/D,OAAM,KAAK;AAEb,QAAO,MAAM,MAAM,GAAG,GAAG,CAAC,KAAA,IAAoC"}
|
|
1
|
+
{"version":3,"file":"config.js","names":[],"sources":["../../../src/pregel/utils/config.ts"],"sourcesContent":["import { RunnableConfig } from \"@langchain/core/runnables\";\nimport { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport {\n CallbackManager,\n ensureHandler,\n type Callbacks,\n} from \"@langchain/core/callbacks/manager\";\nimport { BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { LangGraphRunnableConfig } from \"../runnable_types.js\";\nimport {\n CHECKPOINT_NAMESPACE_END,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n CONFIG_KEY_READ,\n CONFIG_KEY_SCRATCHPAD,\n} from \"../../constants.js\";\n\nconst COPIABLE_KEYS = [\"tags\", \"metadata\", \"callbacks\", \"configurable\"];\n\nconst CONFIG_KEYS = [\n \"tags\",\n \"metadata\",\n \"callbacks\",\n \"runName\",\n \"maxConcurrency\",\n \"recursionLimit\",\n \"configurable\",\n \"runId\",\n \"outputKeys\",\n \"streamMode\",\n \"store\",\n \"writer\",\n \"interrupt\",\n \"context\",\n \"interruptBefore\",\n \"interruptAfter\",\n \"checkpointDuring\",\n \"durability\",\n \"signal\",\n \"heartbeat\",\n \"executionInfo\",\n \"serverInfo\",\n \"control\",\n];\n\nconst DEFAULT_RECURSION_LIMIT = 25;\nexport const PROPAGATE_TO_METADATA = new Set([\n \"thread_id\",\n \"checkpoint_id\",\n \"checkpoint_ns\",\n \"task_id\",\n \"run_id\",\n \"assistant_id\",\n \"graph_id\",\n]);\n\nexport function propagateConfigurableToMetadata(\n configurable?: Record<string, unknown>,\n metadata?: Record<string, unknown>\n): Record<string, unknown> | undefined {\n if (!configurable) {\n return metadata;\n }\n const result = metadata ?? {};\n for (const key of PROPAGATE_TO_METADATA) {\n if (key in result) {\n continue;\n }\n const value = configurable[key];\n if (value !== undefined) {\n result[key] = value;\n }\n }\n return result;\n}\n\n/**\n * Drop langgraph's internal `seq:step*` bookkeeping tags.\n *\n * `seq:step:N` tags are added internally to mark sequence steps; everything\n * else (user-supplied tags and any other framework tags) is kept. Returns the\n * surviving tags, or `undefined` if none remain. Shared by the stream handlers\n * (e.g. {@link mapDebugTasks}) so the same tag set is surfaced consistently.\n */\nexport function filterToUserTags(\n tags: readonly string[] | undefined\n): string[] | undefined {\n if (tags == null || tags.length === 0) return undefined;\n const filtered = tags.filter((tag) => !tag.startsWith(\"seq:step\"));\n return filtered.length > 0 ? filtered : undefined;\n}\n\n/**\n * Merge two `callbacks` values across configs.\n *\n * A `callbacks` value may be `undefined`, an array of handlers, or a\n * {@link CallbackManager}, so merging two of them has six cases. This\n * mirrors the callbacks branch of langchain-core's `mergeConfigs` and\n * langgraph's `_merge_callbacks`, so a handler bound via\n * `.withConfig({ callbacks: [...] })` is preserved when a later config\n * (e.g. `streamEvents` injecting its own internal handler) is merged on\n * top instead of overwriting it.\n */\nfunction mergeCallbacks(\n base: Callbacks | undefined,\n provided: Callbacks | undefined\n): Callbacks | undefined {\n if (provided === undefined) return base;\n if (base === undefined) {\n return Array.isArray(provided) ? [...provided] : provided.copy();\n }\n if (Array.isArray(provided)) {\n if (Array.isArray(base)) return base.concat(provided);\n // base is a manager\n const manager = base.copy();\n for (const callback of provided) {\n manager.addHandler(ensureHandler(callback), true);\n }\n return manager;\n }\n // provided is a manager\n if (Array.isArray(base)) {\n const manager = provided.copy();\n for (const callback of base) {\n manager.addHandler(ensureHandler(callback), true);\n }\n return manager;\n }\n // both are managers\n const dedupeHandlers = (\n handlers: CallbackManager[\"handlers\"]\n ): CallbackManager[\"handlers\"] =>\n handlers.filter(\n (handler, index) =>\n handlers.findIndex(\n (candidate) =>\n candidate === handler ||\n (candidate.name === \"StreamMessagesHandler\" &&\n handler.name === \"StreamMessagesHandler\")\n ) === index\n );\n return new CallbackManager(provided._parentRunId, {\n handlers: dedupeHandlers(base.handlers.concat(provided.handlers)),\n inheritableHandlers: dedupeHandlers(\n base.inheritableHandlers.concat(provided.inheritableHandlers)\n ),\n tags: Array.from(new Set(base.tags.concat(provided.tags))),\n inheritableTags: Array.from(\n new Set(base.inheritableTags.concat(provided.inheritableTags))\n ),\n metadata: { ...base.metadata, ...provided.metadata },\n inheritableMetadata: {\n ...base.inheritableMetadata,\n ...provided.inheritableMetadata,\n },\n });\n}\n\n/**\n * True when the caller is starting a fresh top-level run (invoke-time\n * `thread_id`, no active nesting keys). In that case the ambient `configurable`\n * from `AsyncLocalStorage` cannot be trusted per-key — it may belong to another\n * concurrent invocation on a shared singleton agent (scratchpad/task-input as\n * well as arbitrary user keys like `tenant_id`/`user_id`). The whole ambient\n * `configurable` is therefore ignored; any value the caller actually wants for\n * this run arrives through the explicit (bound + invoke-time) configs instead.\n *\n * Only the last caller-supplied config is treated as invoke-time options.\n * Earlier entries are graph-bound defaults from `.withConfig()` / compile and\n * must not count — a child graph bound with `thread_id` and invoked from a\n * parent task without a fresh config still needs ambient nesting keys from ALS.\n */\nfunction isRootLevelExplicitInvoke(\n configs: (LangGraphRunnableConfig | undefined)[]\n): boolean {\n let invokeConfig: LangGraphRunnableConfig | undefined;\n for (let i = configs.length - 1; i >= 0; i -= 1) {\n if (configs[i] !== undefined) {\n invokeConfig = configs[i];\n break;\n }\n }\n const hasInvokeTimeThreadId =\n invokeConfig?.configurable?.thread_id !== undefined;\n\n const hasExplicitNesting = configs.some(\n (c) => c?.configurable?.[CONFIG_KEY_READ] !== undefined\n );\n\n const ambientConfigurable =\n AsyncLocalStorageProviderSingleton.getRunnableConfig()?.configurable;\n const hasAmbientNesting =\n ambientConfigurable?.[CONFIG_KEY_READ] !== undefined;\n\n return hasInvokeTimeThreadId && !hasExplicitNesting && !hasAmbientNesting;\n}\n\nexport function ensureLangGraphConfig(\n ...configs: (LangGraphRunnableConfig | undefined)[]\n): RunnableConfig {\n const empty: LangGraphRunnableConfig = {\n tags: [],\n metadata: {},\n callbacks: undefined,\n recursionLimit: DEFAULT_RECURSION_LIMIT,\n configurable: {},\n };\n\n const skipImplicitConfigurable = isRootLevelExplicitInvoke(configs);\n\n const implicitConfig: RunnableConfig =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (implicitConfig !== undefined) {\n for (const [k, v] of Object.entries(implicitConfig)) {\n if (v !== undefined) {\n // Stale-ALS root invoke: ignore the ambient `configurable` entirely,\n // since its keys may belong to another concurrent invocation.\n if (k === \"configurable\" && skipImplicitConfigurable) {\n continue;\n }\n if (COPIABLE_KEYS.includes(k)) {\n let copiedValue;\n if (Array.isArray(v)) {\n copiedValue = [...v];\n } else if (typeof v === \"object\") {\n if (\n k === \"callbacks\" &&\n \"copy\" in v &&\n typeof v.copy === \"function\"\n ) {\n copiedValue = v.copy();\n } else {\n copiedValue = { ...v };\n }\n } else {\n copiedValue = v;\n }\n empty[k as keyof RunnableConfig] = copiedValue;\n } else {\n empty[k as keyof RunnableConfig] = v;\n }\n }\n }\n }\n\n for (const config of configs) {\n if (config === undefined) {\n continue;\n }\n\n for (const [k, v] of Object.entries(config)) {\n if (v === undefined || !CONFIG_KEYS.includes(k)) {\n continue;\n }\n\n // Merge (rather than overwrite) the fields that compose across\n // multiple configs, matching langgraph's `merge_configs` /\n // langchain-core's `mergeConfigs`. Without this, a value bound via\n // `.withConfig({...})` is silently dropped whenever a later config\n // (e.g. invoke-time, or `streamEvents`' internal handler) supplies\n // any other key in the same field. Later configs still win per key\n // on collision.\n if (k === \"configurable\") {\n empty.configurable = {\n ...(empty.configurable as Record<string, unknown> | undefined),\n ...(v as Record<string, unknown>),\n };\n } else if (k === \"metadata\") {\n empty.metadata = {\n ...(empty.metadata as Record<string, unknown> | undefined),\n ...(v as Record<string, unknown>),\n };\n } else if (k === \"tags\") {\n // Plain concat (matches langgraph's `merge_configs`): no dedup,\n // no sort.\n empty.tags = [\n ...((empty.tags as string[] | undefined) ?? []),\n ...(v as string[]),\n ];\n } else if (k === \"callbacks\") {\n empty.callbacks = mergeCallbacks(empty.callbacks, v as Callbacks);\n } else {\n empty[k as keyof LangGraphRunnableConfig] = v;\n }\n }\n }\n\n empty.metadata =\n propagateConfigurableToMetadata(\n empty.configurable as Record<string, unknown> | undefined,\n empty.metadata as Record<string, unknown> | undefined\n ) ?? {};\n return empty;\n}\n\n/**\n * A helper utility function that returns the {@link BaseStore} that was set when the graph was initialized\n *\n * @returns a reference to the {@link BaseStore} that was set when the graph was initialized\n */\nexport function getStore(\n config?: LangGraphRunnableConfig\n): BaseStore | undefined {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getStore` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n return runConfig?.store;\n}\n\n/**\n * A helper utility function that returns the {@link LangGraphRunnableConfig#writer} if \"custom\" stream mode is enabled, otherwise undefined.\n *\n * @returns a reference to the {@link LangGraphRunnableConfig#writer} if \"custom\" stream mode is enabled, otherwise undefined\n */\nexport function getWriter(\n config?: LangGraphRunnableConfig\n): ((chunk: unknown) => void) | undefined {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getWriter` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n return runConfig?.writer || runConfig?.configurable?.writer;\n}\n\n/**\n * A helper utility function that returns the {@link LangGraphRunnableConfig} that was set when the graph was initialized.\n *\n * Note: This only works when running in an environment that supports node:async_hooks and AsyncLocalStorage. If you're running this in a\n * web environment, access the LangGraphRunnableConfig from the node function directly.\n *\n * @returns the {@link LangGraphRunnableConfig} that was set when the graph was initialized\n */\nexport function getConfig(): LangGraphRunnableConfig {\n return AsyncLocalStorageProviderSingleton.getRunnableConfig();\n}\n\n/**\n * A helper utility function that returns the input for the currently executing\n * task.\n *\n * Note: When called without arguments, this relies on `node:async_hooks` /\n * `AsyncLocalStorage`, which is available in many JavaScript environments\n * (Node.js, Deno, Cloudflare Workers) but not in web browsers. In environments\n * without `AsyncLocalStorage` support, pass the `config` that your node/tool\n * function receives directly, e.g. `getCurrentTaskInput(config)`.\n *\n * Tip: Inside a tool run by a `ToolNode`, prefer reading graph state from\n * `runtime.state` on the second tool argument (typed as `ToolRuntime` from\n * `@langchain/core/tools`). It works in every runtime, including web browsers.\n *\n * @param config - Optional {@link LangGraphRunnableConfig} to read the task\n * input from. Provide this when running in an environment without\n * `AsyncLocalStorage` support (e.g. web browsers).\n * @returns the input for the currently executing task\n */\nexport function getCurrentTaskInput<T = unknown>(\n config?: LangGraphRunnableConfig\n): T {\n const runConfig: LangGraphRunnableConfig =\n config ?? AsyncLocalStorageProviderSingleton.getRunnableConfig();\n\n if (runConfig === undefined) {\n throw new Error(\n [\n \"Config not retrievable. This is likely because you are running in an environment without support for AsyncLocalStorage.\",\n \"If you're running `getCurrentTaskInput` in such environment, pass the `config` from the node function directly.\",\n ].join(\"\\n\")\n );\n }\n\n if (\n runConfig.configurable?.[CONFIG_KEY_SCRATCHPAD]?.currentTaskInput ===\n undefined\n ) {\n throw new Error(\"BUG: internal scratchpad not initialized.\");\n }\n\n return runConfig!.configurable![CONFIG_KEY_SCRATCHPAD]!.currentTaskInput as T;\n}\n\nexport function recastCheckpointNamespace(namespace: string): string {\n return namespace\n .split(CHECKPOINT_NAMESPACE_SEPARATOR)\n .filter((part) => !part.match(/^\\d+$/))\n .map((part) => part.split(CHECKPOINT_NAMESPACE_END)[0])\n .join(CHECKPOINT_NAMESPACE_SEPARATOR);\n}\n\nexport function getParentCheckpointNamespace(namespace: string): string {\n const parts = namespace.split(CHECKPOINT_NAMESPACE_SEPARATOR);\n while (parts.length > 1 && parts[parts.length - 1].match(/^\\d+$/)) {\n parts.pop();\n }\n return parts.slice(0, -1).join(CHECKPOINT_NAMESPACE_SEPARATOR);\n}\n"],"mappings":";;;;AAgBA,MAAM,gBAAgB;CAAC;CAAQ;CAAY;CAAa;CAAe;AAEvE,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,0BAA0B;AAChC,MAAa,wBAAwB,IAAI,IAAI;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,SAAgB,gCACd,cACA,UACqC;AACrC,KAAI,CAAC,aACH,QAAO;CAET,MAAM,SAAS,YAAY,EAAE;AAC7B,MAAK,MAAM,OAAO,uBAAuB;AACvC,MAAI,OAAO,OACT;EAEF,MAAM,QAAQ,aAAa;AAC3B,MAAI,UAAU,KAAA,EACZ,QAAO,OAAO;;AAGlB,QAAO;;;;;;;;;;AAWT,SAAgB,iBACd,MACsB;AACtB,KAAI,QAAQ,QAAQ,KAAK,WAAW,EAAG,QAAO,KAAA;CAC9C,MAAM,WAAW,KAAK,QAAQ,QAAQ,CAAC,IAAI,WAAW,WAAW,CAAC;AAClE,QAAO,SAAS,SAAS,IAAI,WAAW,KAAA;;;;;;;;;;;;;AAc1C,SAAS,eACP,MACA,UACuB;AACvB,KAAI,aAAa,KAAA,EAAW,QAA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AM,GAAG,GAAG,CAAC,KAAA,IAAoC"}
|
|
@@ -22,6 +22,13 @@ function getNewChannelVersions(previousVersions, currentVersions) {
|
|
|
22
22
|
function _coerceToDict(value, defaultKey) {
|
|
23
23
|
return value && !Array.isArray(value) && !(value instanceof Date) && typeof value === "object" ? value : { [defaultKey]: value };
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Record an empty trace payload while retaining the node's span and timing.
|
|
27
|
+
* Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.
|
|
28
|
+
*/
|
|
29
|
+
function omitPayload(_value) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
25
32
|
function patchConfigurable(config, patch) {
|
|
26
33
|
if (config === null) return { configurable: patch };
|
|
27
34
|
else if (config?.configurable === void 0) return {
|
|
@@ -80,6 +87,7 @@ exports._coerceToDict = _coerceToDict;
|
|
|
80
87
|
exports.combineAbortSignals = combineAbortSignals;
|
|
81
88
|
exports.getNewChannelVersions = getNewChannelVersions;
|
|
82
89
|
exports.getNullChannelVersion = getNullChannelVersion;
|
|
90
|
+
exports.omitPayload = omitPayload;
|
|
83
91
|
exports.patchCheckpointMap = patchCheckpointMap;
|
|
84
92
|
exports.patchConfigurable = patchConfigurable;
|
|
85
93
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["START","CONFIG_KEY_CHECKPOINT_MAP"],"sources":["../../../src/pregel/utils/index.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n ChannelVersions,\n CheckpointMetadata,\n} from \"@langchain/langgraph-checkpoint\";\nimport { CONFIG_KEY_CHECKPOINT_MAP, START } from \"../../constants.js\";\n\nexport function getNullChannelVersion(currentVersions: ChannelVersions) {\n // Short circuit for commonly used channels such as __start__\n // (used by StateGraph)\n const startVersion = typeof currentVersions[START];\n if (startVersion === \"number\") return 0;\n if (startVersion === \"string\") return \"\";\n\n // Defer back to obtaining a first key from channel versions\n for (const key in currentVersions) {\n if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;\n const versionType = typeof currentVersions[key];\n if (versionType === \"number\") return 0;\n if (versionType === \"string\") return \"\";\n break;\n }\n\n return undefined;\n}\n\nexport function getNewChannelVersions(\n previousVersions: ChannelVersions,\n currentVersions: ChannelVersions\n): ChannelVersions {\n // Get new channel versions\n if (Object.keys(previousVersions).length > 0) {\n const nullVersion = getNullChannelVersion(currentVersions);\n return Object.fromEntries(\n Object.entries(currentVersions).filter(\n ([k, v]) => v > (previousVersions[k] ?? nullVersion)\n )\n );\n } else {\n return currentVersions;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value: any, defaultKey: string) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n\nexport type RetryPolicy = {\n /**\n * Amount of time that must elapse before the first retry occurs in milliseconds.\n * @default 500\n */\n initialInterval?: number;\n\n /**\n * Multiplier by which the interval increases after each retry.\n * @default 2\n */\n backoffFactor?: number;\n\n /**\n * Maximum amount of time that may elapse between retries in milliseconds.\n * @default 128000\n */\n maxInterval?: number;\n\n /**\n * Maximum amount of time that may elapse between retries.\n * @default 3\n */\n maxAttempts?: number;\n\n /**\n * Whether to add random jitter to the interval between retries.\n * @default true\n */\n jitter?: boolean;\n\n /** A function that returns True for exceptions that should trigger a retry. */\n retryOn?: (e: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /** Whether to log a warning when a retry is attempted. Defaults to true. */\n logWarning?: boolean;\n};\n\nexport type { TimeoutPolicy } from \"./timeout.js\";\nexport { coerceTimeoutPolicy } from \"./timeout.js\";\n\n/**\n * Configuration for caching nodes.\n */\nexport type CachePolicy = {\n /**\n * A function used to generate a cache key from node's input.\n * @returns A key for the cache.\n */\n keyFunc?: (args: unknown[]) => string;\n\n /**\n * The time to live for the cache in seconds.\n * If not defined, the entry will never expire.\n */\n ttl?: number;\n};\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (config === null) {\n return { configurable: patch };\n } else if (config?.configurable === undefined) {\n return { ...config, configurable: patch };\n } else {\n return {\n ...config,\n configurable: { ...config.configurable, ...patch },\n };\n }\n}\n\nexport function patchCheckpointMap(\n config: RunnableConfig,\n metadata?: CheckpointMetadata\n): RunnableConfig {\n const parents = metadata?.parents ?? {};\n\n if (Object.keys(parents).length > 0) {\n return patchConfigurable(config, {\n [CONFIG_KEY_CHECKPOINT_MAP]: {\n ...parents,\n [config.configurable?.checkpoint_ns ?? \"\"]:\n config.configurable?.checkpoint_id,\n },\n });\n } else {\n return config;\n }\n}\n\n/**\n * Combine multiple abort signals into a single abort signal.\n * @param signals - The abort signals to combine.\n * @returns A combined abort signal and a dispose function to remove the abort listener if unused.\n */\nexport function combineAbortSignals(...x: (AbortSignal | undefined)[]): {\n signal: AbortSignal | undefined;\n dispose?: () => void;\n} {\n const signals = [...new Set(x.filter(Boolean))] as AbortSignal[];\n\n if (signals.length === 0) {\n return { signal: undefined, dispose: undefined };\n }\n\n if (signals.length === 1) {\n return { signal: signals[0], dispose: undefined };\n }\n\n const combinedController = new AbortController();\n const listener = () => {\n const reason = signals.find((s) => s.aborted)?.reason;\n combinedController.abort(reason);\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n };\n\n signals.forEach((s) => s.addEventListener(\"abort\", listener, { once: true }));\n\n const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);\n if (hasAlreadyAbortedSignal) {\n combinedController.abort(hasAlreadyAbortedSignal.reason);\n }\n\n return {\n signal: combinedController.signal,\n dispose: () => {\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n },\n };\n}\n\n/**\n * Combine multiple callbacks into a single callback.\n * @param callback1 - The first callback to combine.\n * @param callback2 - The second callback to combine.\n * @returns A single callback that is a combination of the input callbacks.\n */\nexport const combineCallbacks = (\n callback1?: Callbacks,\n callback2?: Callbacks\n): Callbacks | undefined => {\n if (!callback1 && !callback2) {\n return undefined;\n }\n\n if (!callback1) {\n return callback2;\n }\n\n if (!callback2) {\n return callback1;\n }\n if (Array.isArray(callback1) && Array.isArray(callback2)) {\n return [...callback1, ...callback2];\n }\n if (Array.isArray(callback1)) {\n return [...callback1, callback2] as Callbacks;\n }\n if (Array.isArray(callback2)) {\n return [callback1, ...callback2];\n }\n return [callback1, callback2] as Callbacks;\n};\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,iBAAkC;CAGtE,MAAM,eAAe,OAAO,gBAAgBA,kBAAAA;AAC5C,KAAI,iBAAiB,SAAU,QAAO;AACtC,KAAI,iBAAiB,SAAU,QAAO;AAGtC,MAAK,MAAM,OAAO,iBAAiB;AACjC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,iBAAiB,IAAI,CAAE;EACjE,MAAM,cAAc,OAAO,gBAAgB;AAC3C,MAAI,gBAAgB,SAAU,QAAO;AACrC,MAAI,gBAAgB,SAAU,QAAO;AACrC;;;AAMJ,SAAgB,sBACd,kBACA,iBACiB;AAEjB,KAAI,OAAO,KAAK,iBAAiB,CAAC,SAAS,GAAG;EAC5C,MAAM,cAAc,sBAAsB,gBAAgB;AAC1D,SAAO,OAAO,YACZ,OAAO,QAAQ,gBAAgB,CAAC,QAC7B,CAAC,GAAG,OAAO,KAAK,iBAAiB,MAAM,aACzC,CACF;OAED,QAAO;;AAKX,SAAgB,cAAc,OAAY,YAAoB;AAC5D,QAAO,SACL,CAAC,MAAM,QAAQ,MAAM,IAErB,EAAE,iBAAiB,SACnB,OAAO,UAAU,WACf,QACA,GAAG,aAAa,OAAO;;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["START","CONFIG_KEY_CHECKPOINT_MAP"],"sources":["../../../src/pregel/utils/index.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n ChannelVersions,\n CheckpointMetadata,\n} from \"@langchain/langgraph-checkpoint\";\nimport { CONFIG_KEY_CHECKPOINT_MAP, START } from \"../../constants.js\";\n\nexport function getNullChannelVersion(currentVersions: ChannelVersions) {\n // Short circuit for commonly used channels such as __start__\n // (used by StateGraph)\n const startVersion = typeof currentVersions[START];\n if (startVersion === \"number\") return 0;\n if (startVersion === \"string\") return \"\";\n\n // Defer back to obtaining a first key from channel versions\n for (const key in currentVersions) {\n if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;\n const versionType = typeof currentVersions[key];\n if (versionType === \"number\") return 0;\n if (versionType === \"string\") return \"\";\n break;\n }\n\n return undefined;\n}\n\nexport function getNewChannelVersions(\n previousVersions: ChannelVersions,\n currentVersions: ChannelVersions\n): ChannelVersions {\n // Get new channel versions\n if (Object.keys(previousVersions).length > 0) {\n const nullVersion = getNullChannelVersion(currentVersions);\n return Object.fromEntries(\n Object.entries(currentVersions).filter(\n ([k, v]) => v > (previousVersions[k] ?? nullVersion)\n )\n );\n } else {\n return currentVersions;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value: any, defaultKey: string) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n\nexport type RetryPolicy = {\n /**\n * Amount of time that must elapse before the first retry occurs in milliseconds.\n * @default 500\n */\n initialInterval?: number;\n\n /**\n * Multiplier by which the interval increases after each retry.\n * @default 2\n */\n backoffFactor?: number;\n\n /**\n * Maximum amount of time that may elapse between retries in milliseconds.\n * @default 128000\n */\n maxInterval?: number;\n\n /**\n * Maximum amount of time that may elapse between retries.\n * @default 3\n */\n maxAttempts?: number;\n\n /**\n * Whether to add random jitter to the interval between retries.\n * @default true\n */\n jitter?: boolean;\n\n /** A function that returns True for exceptions that should trigger a retry. */\n retryOn?: (e: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /** Whether to log a warning when a retry is attempted. Defaults to true. */\n logWarning?: boolean;\n};\n\nexport type { TimeoutPolicy } from \"./timeout.js\";\nexport { coerceTimeoutPolicy } from \"./timeout.js\";\n\n/**\n * Configuration for caching nodes.\n */\nexport type CachePolicy = {\n /**\n * A function used to generate a cache key from node's input.\n * @returns A key for the cache.\n */\n keyFunc?: (args: unknown[]) => string;\n\n /**\n * The time to live for the cache in seconds.\n * If not defined, the entry will never expire.\n */\n ttl?: number;\n};\n\n/**\n * Controls the input and output payloads recorded on a node's own trace run.\n * The graph's root run and child runs created by traced runnables are unaffected.\n * Plain function nodes do not create an additional child run.\n *\n * Processors are synchronous and receive raw values, before callback payload\n * normalization. They run even without tracing callbacks. If a processor throws,\n * the original payload is recorded instead. Avoid mutating the supplied values:\n * they are also used for execution and are not copied.\n *\n * These transforms also affect chain callbacks, including `streamEvents` and\n * message streaming. Omitting outputs can suppress messages returned directly\n * by nodes; omitting inputs can affect message deduplication.\n *\n * This policy is intended to reduce trace payload sizes, not redact secrets.\n * For redaction across all runs, configure the LangSmith client instead.\n *\n * @example\n * ```ts\n * graph.addNode(\"before_model\", beforeModel, {\n * tracePolicy: {\n * processInputs: omitPayload,\n * processOutputs: omitPayload,\n * },\n * });\n * ```\n */\nexport type TracePolicy = {\n /** Transform the raw node input recorded on its trace run. */\n processInputs?: (value: unknown) => unknown;\n /** Transform the raw node output recorded on its trace run. */\n processOutputs?: (value: unknown) => unknown;\n};\n\n/**\n * Record an empty trace payload while retaining the node's span and timing.\n * Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.\n */\nexport function omitPayload(_value: unknown): Record<string, never> {\n return {};\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (config === null) {\n return { configurable: patch };\n } else if (config?.configurable === undefined) {\n return { ...config, configurable: patch };\n } else {\n return {\n ...config,\n configurable: { ...config.configurable, ...patch },\n };\n }\n}\n\nexport function patchCheckpointMap(\n config: RunnableConfig,\n metadata?: CheckpointMetadata\n): RunnableConfig {\n const parents = metadata?.parents ?? {};\n\n if (Object.keys(parents).length > 0) {\n return patchConfigurable(config, {\n [CONFIG_KEY_CHECKPOINT_MAP]: {\n ...parents,\n [config.configurable?.checkpoint_ns ?? \"\"]:\n config.configurable?.checkpoint_id,\n },\n });\n } else {\n return config;\n }\n}\n\n/**\n * Combine multiple abort signals into a single abort signal.\n * @param signals - The abort signals to combine.\n * @returns A combined abort signal and a dispose function to remove the abort listener if unused.\n */\nexport function combineAbortSignals(...x: (AbortSignal | undefined)[]): {\n signal: AbortSignal | undefined;\n dispose?: () => void;\n} {\n const signals = [...new Set(x.filter(Boolean))] as AbortSignal[];\n\n if (signals.length === 0) {\n return { signal: undefined, dispose: undefined };\n }\n\n if (signals.length === 1) {\n return { signal: signals[0], dispose: undefined };\n }\n\n const combinedController = new AbortController();\n const listener = () => {\n const reason = signals.find((s) => s.aborted)?.reason;\n combinedController.abort(reason);\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n };\n\n signals.forEach((s) => s.addEventListener(\"abort\", listener, { once: true }));\n\n const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);\n if (hasAlreadyAbortedSignal) {\n combinedController.abort(hasAlreadyAbortedSignal.reason);\n }\n\n return {\n signal: combinedController.signal,\n dispose: () => {\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n },\n };\n}\n\n/**\n * Combine multiple callbacks into a single callback.\n * @param callback1 - The first callback to combine.\n * @param callback2 - The second callback to combine.\n * @returns A single callback that is a combination of the input callbacks.\n */\nexport const combineCallbacks = (\n callback1?: Callbacks,\n callback2?: Callbacks\n): Callbacks | undefined => {\n if (!callback1 && !callback2) {\n return undefined;\n }\n\n if (!callback1) {\n return callback2;\n }\n\n if (!callback2) {\n return callback1;\n }\n if (Array.isArray(callback1) && Array.isArray(callback2)) {\n return [...callback1, ...callback2];\n }\n if (Array.isArray(callback1)) {\n return [...callback1, callback2] as Callbacks;\n }\n if (Array.isArray(callback2)) {\n return [callback1, ...callback2];\n }\n return [callback1, callback2] as Callbacks;\n};\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,iBAAkC;CAGtE,MAAM,eAAe,OAAO,gBAAgBA,kBAAAA;AAC5C,KAAI,iBAAiB,SAAU,QAAO;AACtC,KAAI,iBAAiB,SAAU,QAAO;AAGtC,MAAK,MAAM,OAAO,iBAAiB;AACjC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,iBAAiB,IAAI,CAAE;EACjE,MAAM,cAAc,OAAO,gBAAgB;AAC3C,MAAI,gBAAgB,SAAU,QAAO;AACrC,MAAI,gBAAgB,SAAU,QAAO;AACrC;;;AAMJ,SAAgB,sBACd,kBACA,iBACiB;AAEjB,KAAI,OAAO,KAAK,iBAAiB,CAAC,SAAS,GAAG;EAC5C,MAAM,cAAc,sBAAsB,gBAAgB;AAC1D,SAAO,OAAO,YACZ,OAAO,QAAQ,gBAAgB,CAAC,QAC7B,CAAC,GAAG,OAAO,KAAK,iBAAiB,MAAM,aACzC,CACF;OAED,QAAO;;AAKX,SAAgB,cAAc,OAAY,YAAoB;AAC5D,QAAO,SACL,CAAC,MAAM,QAAQ,MAAM,IAErB,EAAE,iBAAiB,SACnB,OAAO,UAAU,WACf,QACA,GAAG,aAAa,OAAO;;;;;;AAmG7B,SAAgB,YAAY,QAAwC;AAClE,QAAO,EAAE;;AAGX,SAAgB,kBACd,QAEA,OACgB;AAChB,KAAI,WAAW,KACb,QAAO,EAAE,cAAc,OAAO;UACrB,QAAQ,iBAAiB,KAAA,EAClC,QAAO;EAAE,GAAG;EAAQ,cAAc;EAAO;KAEzC,QAAO;EACL,GAAG;EACH,cAAc;GAAE,GAAG,OAAO;GAAc,GAAG;GAAO;EACnD;;AAIL,SAAgB,mBACd,QACA,UACgB;CAChB,MAAM,UAAU,UAAU,WAAW,EAAE;AAEvC,KAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,EAChC,QAAO,kBAAkB,QAAQ,GAC9BC,kBAAAA,4BAA4B;EAC3B,GAAG;GACF,OAAO,cAAc,iBAAiB,KACrC,OAAO,cAAc;EACxB,EACF,CAAC;KAEF,QAAO;;;;;;;AASX,SAAgB,oBAAoB,GAAG,GAGrC;CACA,MAAM,UAAU,CAAC,GAAG,IAAI,IAAI,EAAE,OAAO,QAAQ,CAAC,CAAC;AAE/C,KAAI,QAAQ,WAAW,EACrB,QAAO;EAAE,QAAQ,KAAA;EAAW,SAAS,KAAA;EAAW;AAGlD,KAAI,QAAQ,WAAW,EACrB,QAAO;EAAE,QAAQ,QAAQ;EAAI,SAAS,KAAA;EAAW;CAGnD,MAAM,qBAAqB,IAAI,iBAAiB;CAChD,MAAM,iBAAiB;EACrB,MAAM,SAAS,QAAQ,MAAM,MAAM,EAAE,QAAQ,EAAE;AAC/C,qBAAmB,MAAM,OAAO;AAChC,UAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS,SAAS,CAAC;;AAGlE,SAAQ,SAAS,MAAM,EAAE,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC,CAAC;CAE7E,MAAM,0BAA0B,QAAQ,MAAM,MAAM,EAAE,QAAQ;AAC9D,KAAI,wBACF,oBAAmB,MAAM,wBAAwB,OAAO;AAG1D,QAAO;EACL,QAAQ,mBAAmB;EAC3B,eAAe;AACb,WAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS,SAAS,CAAC;;EAEnE"}
|
|
@@ -47,6 +47,42 @@ type CachePolicy = {
|
|
|
47
47
|
*/
|
|
48
48
|
ttl?: number;
|
|
49
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Controls the input and output payloads recorded on a node's own trace run.
|
|
52
|
+
* The graph's root run and child runs created by traced runnables are unaffected.
|
|
53
|
+
* Plain function nodes do not create an additional child run.
|
|
54
|
+
*
|
|
55
|
+
* Processors are synchronous and receive raw values, before callback payload
|
|
56
|
+
* normalization. They run even without tracing callbacks. If a processor throws,
|
|
57
|
+
* the original payload is recorded instead. Avoid mutating the supplied values:
|
|
58
|
+
* they are also used for execution and are not copied.
|
|
59
|
+
*
|
|
60
|
+
* These transforms also affect chain callbacks, including `streamEvents` and
|
|
61
|
+
* message streaming. Omitting outputs can suppress messages returned directly
|
|
62
|
+
* by nodes; omitting inputs can affect message deduplication.
|
|
63
|
+
*
|
|
64
|
+
* This policy is intended to reduce trace payload sizes, not redact secrets.
|
|
65
|
+
* For redaction across all runs, configure the LangSmith client instead.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* graph.addNode("before_model", beforeModel, {
|
|
70
|
+
* tracePolicy: {
|
|
71
|
+
* processInputs: omitPayload,
|
|
72
|
+
* processOutputs: omitPayload,
|
|
73
|
+
* },
|
|
74
|
+
* });
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
type TracePolicy = {
|
|
78
|
+
/** Transform the raw node input recorded on its trace run. */processInputs?: (value: unknown) => unknown; /** Transform the raw node output recorded on its trace run. */
|
|
79
|
+
processOutputs?: (value: unknown) => unknown;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Record an empty trace payload while retaining the node's span and timing.
|
|
83
|
+
* Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.
|
|
84
|
+
*/
|
|
85
|
+
declare function omitPayload(_value: unknown): Record<string, never>;
|
|
50
86
|
//#endregion
|
|
51
|
-
export { CachePolicy, RetryPolicy };
|
|
87
|
+
export { CachePolicy, RetryPolicy, TracePolicy, omitPayload };
|
|
52
88
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/pregel/utils/index.ts"],"mappings":";;;;;KAuDY,WAAA;;;;;EAKV,eAAA;EAkBA;;;;EAZA,aAAA;EAwBU;;AASZ;;EA3BE,WAAA;EA2BqB;;;;EArBrB,WAAA;EAgCG
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../../src/pregel/utils/index.ts"],"mappings":";;;;;KAuDY,WAAA;;;;;EAKV,eAAA;EAkBA;;;;EAZA,aAAA;EAwBU;;AASZ;;EA3BE,WAAA;EA2BqB;;;;EArBrB,WAAA;EAgCG;AA8BL;;;EAxDE,MAAA,YA0DA;EAvDA,OAAA,IAAW,CAAA,mBAyDX;EAtDA,UAAA;AAAA;;;;KASU,WAAA;;;;;EAKV,OAAA,IAAW,IAAA;;;;;EAMX,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BU,WAAA;gEAEV,aAAA,IAAiB,KAAA;EAEjB,cAAA,IAAkB,KAAA;AAAA;;;;;iBAOJ,WAAA,CAAY,MAAA,YAAkB,MAAA"}
|
|
@@ -46,6 +46,42 @@ type CachePolicy = {
|
|
|
46
46
|
*/
|
|
47
47
|
ttl?: number;
|
|
48
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Controls the input and output payloads recorded on a node's own trace run.
|
|
51
|
+
* The graph's root run and child runs created by traced runnables are unaffected.
|
|
52
|
+
* Plain function nodes do not create an additional child run.
|
|
53
|
+
*
|
|
54
|
+
* Processors are synchronous and receive raw values, before callback payload
|
|
55
|
+
* normalization. They run even without tracing callbacks. If a processor throws,
|
|
56
|
+
* the original payload is recorded instead. Avoid mutating the supplied values:
|
|
57
|
+
* they are also used for execution and are not copied.
|
|
58
|
+
*
|
|
59
|
+
* These transforms also affect chain callbacks, including `streamEvents` and
|
|
60
|
+
* message streaming. Omitting outputs can suppress messages returned directly
|
|
61
|
+
* by nodes; omitting inputs can affect message deduplication.
|
|
62
|
+
*
|
|
63
|
+
* This policy is intended to reduce trace payload sizes, not redact secrets.
|
|
64
|
+
* For redaction across all runs, configure the LangSmith client instead.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* graph.addNode("before_model", beforeModel, {
|
|
69
|
+
* tracePolicy: {
|
|
70
|
+
* processInputs: omitPayload,
|
|
71
|
+
* processOutputs: omitPayload,
|
|
72
|
+
* },
|
|
73
|
+
* });
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
type TracePolicy = {
|
|
77
|
+
/** Transform the raw node input recorded on its trace run. */processInputs?: (value: unknown) => unknown; /** Transform the raw node output recorded on its trace run. */
|
|
78
|
+
processOutputs?: (value: unknown) => unknown;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Record an empty trace payload while retaining the node's span and timing.
|
|
82
|
+
* Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.
|
|
83
|
+
*/
|
|
84
|
+
declare function omitPayload(_value: unknown): Record<string, never>;
|
|
49
85
|
//#endregion
|
|
50
|
-
export { CachePolicy, RetryPolicy };
|
|
86
|
+
export { CachePolicy, RetryPolicy, TracePolicy, omitPayload };
|
|
51
87
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/pregel/utils/index.ts"],"mappings":";;;;KAuDY,WAAA;EAAW;;;;EAKrB,eAAA;EAYA;;;;EANA,aAAA;EAwBA;;;AASF;EA3BE,WAAA;;;;;EAMA,WAAA;EAgCG
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/pregel/utils/index.ts"],"mappings":";;;;KAuDY,WAAA;EAAW;;;;EAKrB,eAAA;EAYA;;;;EANA,aAAA;EAwBA;;;AASF;EA3BE,WAAA;;;;;EAMA,WAAA;EAgCG;;AA8BL;;EAxDE,MAAA,YAwDqB;EArDrB,OAAA,IAAW,CAAA,mBAuDM;EApDjB,UAAA;AAAA;AA6DF;;;AAAA,KApDY,WAAA;EAoDwC;;;;EA/ClD,OAAA,IAAW,IAAA;;;;;EAMX,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA8BU,WAAA;gEAEV,aAAA,IAAiB,KAAA;EAEjB,cAAA,IAAkB,KAAA;AAAA;;;;;iBAOJ,WAAA,CAAY,MAAA,YAAkB,MAAA"}
|
|
@@ -22,6 +22,13 @@ function getNewChannelVersions(previousVersions, currentVersions) {
|
|
|
22
22
|
function _coerceToDict(value, defaultKey) {
|
|
23
23
|
return value && !Array.isArray(value) && !(value instanceof Date) && typeof value === "object" ? value : { [defaultKey]: value };
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Record an empty trace payload while retaining the node's span and timing.
|
|
27
|
+
* Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.
|
|
28
|
+
*/
|
|
29
|
+
function omitPayload(_value) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
25
32
|
function patchConfigurable(config, patch) {
|
|
26
33
|
if (config === null) return { configurable: patch };
|
|
27
34
|
else if (config?.configurable === void 0) return {
|
|
@@ -76,6 +83,6 @@ function combineAbortSignals(...x) {
|
|
|
76
83
|
};
|
|
77
84
|
}
|
|
78
85
|
//#endregion
|
|
79
|
-
export { _coerceToDict, combineAbortSignals, getNewChannelVersions, getNullChannelVersion, patchCheckpointMap, patchConfigurable };
|
|
86
|
+
export { _coerceToDict, combineAbortSignals, getNewChannelVersions, getNullChannelVersion, omitPayload, patchCheckpointMap, patchConfigurable };
|
|
80
87
|
|
|
81
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/pregel/utils/index.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n ChannelVersions,\n CheckpointMetadata,\n} from \"@langchain/langgraph-checkpoint\";\nimport { CONFIG_KEY_CHECKPOINT_MAP, START } from \"../../constants.js\";\n\nexport function getNullChannelVersion(currentVersions: ChannelVersions) {\n // Short circuit for commonly used channels such as __start__\n // (used by StateGraph)\n const startVersion = typeof currentVersions[START];\n if (startVersion === \"number\") return 0;\n if (startVersion === \"string\") return \"\";\n\n // Defer back to obtaining a first key from channel versions\n for (const key in currentVersions) {\n if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;\n const versionType = typeof currentVersions[key];\n if (versionType === \"number\") return 0;\n if (versionType === \"string\") return \"\";\n break;\n }\n\n return undefined;\n}\n\nexport function getNewChannelVersions(\n previousVersions: ChannelVersions,\n currentVersions: ChannelVersions\n): ChannelVersions {\n // Get new channel versions\n if (Object.keys(previousVersions).length > 0) {\n const nullVersion = getNullChannelVersion(currentVersions);\n return Object.fromEntries(\n Object.entries(currentVersions).filter(\n ([k, v]) => v > (previousVersions[k] ?? nullVersion)\n )\n );\n } else {\n return currentVersions;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value: any, defaultKey: string) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n\nexport type RetryPolicy = {\n /**\n * Amount of time that must elapse before the first retry occurs in milliseconds.\n * @default 500\n */\n initialInterval?: number;\n\n /**\n * Multiplier by which the interval increases after each retry.\n * @default 2\n */\n backoffFactor?: number;\n\n /**\n * Maximum amount of time that may elapse between retries in milliseconds.\n * @default 128000\n */\n maxInterval?: number;\n\n /**\n * Maximum amount of time that may elapse between retries.\n * @default 3\n */\n maxAttempts?: number;\n\n /**\n * Whether to add random jitter to the interval between retries.\n * @default true\n */\n jitter?: boolean;\n\n /** A function that returns True for exceptions that should trigger a retry. */\n retryOn?: (e: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /** Whether to log a warning when a retry is attempted. Defaults to true. */\n logWarning?: boolean;\n};\n\nexport type { TimeoutPolicy } from \"./timeout.js\";\nexport { coerceTimeoutPolicy } from \"./timeout.js\";\n\n/**\n * Configuration for caching nodes.\n */\nexport type CachePolicy = {\n /**\n * A function used to generate a cache key from node's input.\n * @returns A key for the cache.\n */\n keyFunc?: (args: unknown[]) => string;\n\n /**\n * The time to live for the cache in seconds.\n * If not defined, the entry will never expire.\n */\n ttl?: number;\n};\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (config === null) {\n return { configurable: patch };\n } else if (config?.configurable === undefined) {\n return { ...config, configurable: patch };\n } else {\n return {\n ...config,\n configurable: { ...config.configurable, ...patch },\n };\n }\n}\n\nexport function patchCheckpointMap(\n config: RunnableConfig,\n metadata?: CheckpointMetadata\n): RunnableConfig {\n const parents = metadata?.parents ?? {};\n\n if (Object.keys(parents).length > 0) {\n return patchConfigurable(config, {\n [CONFIG_KEY_CHECKPOINT_MAP]: {\n ...parents,\n [config.configurable?.checkpoint_ns ?? \"\"]:\n config.configurable?.checkpoint_id,\n },\n });\n } else {\n return config;\n }\n}\n\n/**\n * Combine multiple abort signals into a single abort signal.\n * @param signals - The abort signals to combine.\n * @returns A combined abort signal and a dispose function to remove the abort listener if unused.\n */\nexport function combineAbortSignals(...x: (AbortSignal | undefined)[]): {\n signal: AbortSignal | undefined;\n dispose?: () => void;\n} {\n const signals = [...new Set(x.filter(Boolean))] as AbortSignal[];\n\n if (signals.length === 0) {\n return { signal: undefined, dispose: undefined };\n }\n\n if (signals.length === 1) {\n return { signal: signals[0], dispose: undefined };\n }\n\n const combinedController = new AbortController();\n const listener = () => {\n const reason = signals.find((s) => s.aborted)?.reason;\n combinedController.abort(reason);\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n };\n\n signals.forEach((s) => s.addEventListener(\"abort\", listener, { once: true }));\n\n const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);\n if (hasAlreadyAbortedSignal) {\n combinedController.abort(hasAlreadyAbortedSignal.reason);\n }\n\n return {\n signal: combinedController.signal,\n dispose: () => {\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n },\n };\n}\n\n/**\n * Combine multiple callbacks into a single callback.\n * @param callback1 - The first callback to combine.\n * @param callback2 - The second callback to combine.\n * @returns A single callback that is a combination of the input callbacks.\n */\nexport const combineCallbacks = (\n callback1?: Callbacks,\n callback2?: Callbacks\n): Callbacks | undefined => {\n if (!callback1 && !callback2) {\n return undefined;\n }\n\n if (!callback1) {\n return callback2;\n }\n\n if (!callback2) {\n return callback1;\n }\n if (Array.isArray(callback1) && Array.isArray(callback2)) {\n return [...callback1, ...callback2];\n }\n if (Array.isArray(callback1)) {\n return [...callback1, callback2] as Callbacks;\n }\n if (Array.isArray(callback2)) {\n return [callback1, ...callback2];\n }\n return [callback1, callback2] as Callbacks;\n};\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,iBAAkC;CAGtE,MAAM,eAAe,OAAO,gBAAgB;AAC5C,KAAI,iBAAiB,SAAU,QAAO;AACtC,KAAI,iBAAiB,SAAU,QAAO;AAGtC,MAAK,MAAM,OAAO,iBAAiB;AACjC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,iBAAiB,IAAI,CAAE;EACjE,MAAM,cAAc,OAAO,gBAAgB;AAC3C,MAAI,gBAAgB,SAAU,QAAO;AACrC,MAAI,gBAAgB,SAAU,QAAO;AACrC;;;AAMJ,SAAgB,sBACd,kBACA,iBACiB;AAEjB,KAAI,OAAO,KAAK,iBAAiB,CAAC,SAAS,GAAG;EAC5C,MAAM,cAAc,sBAAsB,gBAAgB;AAC1D,SAAO,OAAO,YACZ,OAAO,QAAQ,gBAAgB,CAAC,QAC7B,CAAC,GAAG,OAAO,KAAK,iBAAiB,MAAM,aACzC,CACF;OAED,QAAO;;AAKX,SAAgB,cAAc,OAAY,YAAoB;AAC5D,QAAO,SACL,CAAC,MAAM,QAAQ,MAAM,IAErB,EAAE,iBAAiB,SACnB,OAAO,UAAU,WACf,QACA,GAAG,aAAa,OAAO;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/pregel/utils/index.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport type {\n ChannelVersions,\n CheckpointMetadata,\n} from \"@langchain/langgraph-checkpoint\";\nimport { CONFIG_KEY_CHECKPOINT_MAP, START } from \"../../constants.js\";\n\nexport function getNullChannelVersion(currentVersions: ChannelVersions) {\n // Short circuit for commonly used channels such as __start__\n // (used by StateGraph)\n const startVersion = typeof currentVersions[START];\n if (startVersion === \"number\") return 0;\n if (startVersion === \"string\") return \"\";\n\n // Defer back to obtaining a first key from channel versions\n for (const key in currentVersions) {\n if (!Object.prototype.hasOwnProperty.call(currentVersions, key)) continue;\n const versionType = typeof currentVersions[key];\n if (versionType === \"number\") return 0;\n if (versionType === \"string\") return \"\";\n break;\n }\n\n return undefined;\n}\n\nexport function getNewChannelVersions(\n previousVersions: ChannelVersions,\n currentVersions: ChannelVersions\n): ChannelVersions {\n // Get new channel versions\n if (Object.keys(previousVersions).length > 0) {\n const nullVersion = getNullChannelVersion(currentVersions);\n return Object.fromEntries(\n Object.entries(currentVersions).filter(\n ([k, v]) => v > (previousVersions[k] ?? nullVersion)\n )\n );\n } else {\n return currentVersions;\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function _coerceToDict(value: any, defaultKey: string) {\n return value &&\n !Array.isArray(value) &&\n // eslint-disable-next-line no-instanceof/no-instanceof\n !(value instanceof Date) &&\n typeof value === \"object\"\n ? value\n : { [defaultKey]: value };\n}\n\nexport type RetryPolicy = {\n /**\n * Amount of time that must elapse before the first retry occurs in milliseconds.\n * @default 500\n */\n initialInterval?: number;\n\n /**\n * Multiplier by which the interval increases after each retry.\n * @default 2\n */\n backoffFactor?: number;\n\n /**\n * Maximum amount of time that may elapse between retries in milliseconds.\n * @default 128000\n */\n maxInterval?: number;\n\n /**\n * Maximum amount of time that may elapse between retries.\n * @default 3\n */\n maxAttempts?: number;\n\n /**\n * Whether to add random jitter to the interval between retries.\n * @default true\n */\n jitter?: boolean;\n\n /** A function that returns True for exceptions that should trigger a retry. */\n retryOn?: (e: any) => boolean; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n /** Whether to log a warning when a retry is attempted. Defaults to true. */\n logWarning?: boolean;\n};\n\nexport type { TimeoutPolicy } from \"./timeout.js\";\nexport { coerceTimeoutPolicy } from \"./timeout.js\";\n\n/**\n * Configuration for caching nodes.\n */\nexport type CachePolicy = {\n /**\n * A function used to generate a cache key from node's input.\n * @returns A key for the cache.\n */\n keyFunc?: (args: unknown[]) => string;\n\n /**\n * The time to live for the cache in seconds.\n * If not defined, the entry will never expire.\n */\n ttl?: number;\n};\n\n/**\n * Controls the input and output payloads recorded on a node's own trace run.\n * The graph's root run and child runs created by traced runnables are unaffected.\n * Plain function nodes do not create an additional child run.\n *\n * Processors are synchronous and receive raw values, before callback payload\n * normalization. They run even without tracing callbacks. If a processor throws,\n * the original payload is recorded instead. Avoid mutating the supplied values:\n * they are also used for execution and are not copied.\n *\n * These transforms also affect chain callbacks, including `streamEvents` and\n * message streaming. Omitting outputs can suppress messages returned directly\n * by nodes; omitting inputs can affect message deduplication.\n *\n * This policy is intended to reduce trace payload sizes, not redact secrets.\n * For redaction across all runs, configure the LangSmith client instead.\n *\n * @example\n * ```ts\n * graph.addNode(\"before_model\", beforeModel, {\n * tracePolicy: {\n * processInputs: omitPayload,\n * processOutputs: omitPayload,\n * },\n * });\n * ```\n */\nexport type TracePolicy = {\n /** Transform the raw node input recorded on its trace run. */\n processInputs?: (value: unknown) => unknown;\n /** Transform the raw node output recorded on its trace run. */\n processOutputs?: (value: unknown) => unknown;\n};\n\n/**\n * Record an empty trace payload while retaining the node's span and timing.\n * Use as `processInputs` and/or `processOutputs` in a {@link TracePolicy}.\n */\nexport function omitPayload(_value: unknown): Record<string, never> {\n return {};\n}\n\nexport function patchConfigurable(\n config: RunnableConfig | undefined,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n patch: Record<string, any>\n): RunnableConfig {\n if (config === null) {\n return { configurable: patch };\n } else if (config?.configurable === undefined) {\n return { ...config, configurable: patch };\n } else {\n return {\n ...config,\n configurable: { ...config.configurable, ...patch },\n };\n }\n}\n\nexport function patchCheckpointMap(\n config: RunnableConfig,\n metadata?: CheckpointMetadata\n): RunnableConfig {\n const parents = metadata?.parents ?? {};\n\n if (Object.keys(parents).length > 0) {\n return patchConfigurable(config, {\n [CONFIG_KEY_CHECKPOINT_MAP]: {\n ...parents,\n [config.configurable?.checkpoint_ns ?? \"\"]:\n config.configurable?.checkpoint_id,\n },\n });\n } else {\n return config;\n }\n}\n\n/**\n * Combine multiple abort signals into a single abort signal.\n * @param signals - The abort signals to combine.\n * @returns A combined abort signal and a dispose function to remove the abort listener if unused.\n */\nexport function combineAbortSignals(...x: (AbortSignal | undefined)[]): {\n signal: AbortSignal | undefined;\n dispose?: () => void;\n} {\n const signals = [...new Set(x.filter(Boolean))] as AbortSignal[];\n\n if (signals.length === 0) {\n return { signal: undefined, dispose: undefined };\n }\n\n if (signals.length === 1) {\n return { signal: signals[0], dispose: undefined };\n }\n\n const combinedController = new AbortController();\n const listener = () => {\n const reason = signals.find((s) => s.aborted)?.reason;\n combinedController.abort(reason);\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n };\n\n signals.forEach((s) => s.addEventListener(\"abort\", listener, { once: true }));\n\n const hasAlreadyAbortedSignal = signals.find((s) => s.aborted);\n if (hasAlreadyAbortedSignal) {\n combinedController.abort(hasAlreadyAbortedSignal.reason);\n }\n\n return {\n signal: combinedController.signal,\n dispose: () => {\n signals.forEach((s) => s.removeEventListener(\"abort\", listener));\n },\n };\n}\n\n/**\n * Combine multiple callbacks into a single callback.\n * @param callback1 - The first callback to combine.\n * @param callback2 - The second callback to combine.\n * @returns A single callback that is a combination of the input callbacks.\n */\nexport const combineCallbacks = (\n callback1?: Callbacks,\n callback2?: Callbacks\n): Callbacks | undefined => {\n if (!callback1 && !callback2) {\n return undefined;\n }\n\n if (!callback1) {\n return callback2;\n }\n\n if (!callback2) {\n return callback1;\n }\n if (Array.isArray(callback1) && Array.isArray(callback2)) {\n return [...callback1, ...callback2];\n }\n if (Array.isArray(callback1)) {\n return [...callback1, callback2] as Callbacks;\n }\n if (Array.isArray(callback2)) {\n return [callback1, ...callback2];\n }\n return [callback1, callback2] as Callbacks;\n};\n"],"mappings":";;;AAQA,SAAgB,sBAAsB,iBAAkC;CAGtE,MAAM,eAAe,OAAO,gBAAgB;AAC5C,KAAI,iBAAiB,SAAU,QAAO;AACtC,KAAI,iBAAiB,SAAU,QAAO;AAGtC,MAAK,MAAM,OAAO,iBAAiB;AACjC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,iBAAiB,IAAI,CAAE;EACjE,MAAM,cAAc,OAAO,gBAAgB;AAC3C,MAAI,gBAAgB,SAAU,QAAO;AACrC,MAAI,gBAAgB,SAAU,QAAO;AACrC;;;AAMJ,SAAgB,sBACd,kBACA,iBACiB;AAEjB,KAAI,OAAO,KAAK,iBAAiB,CAAC,SAAS,GAAG;EAC5C,MAAM,cAAc,sBAAsB,gBAAgB;AAC1D,SAAO,OAAO,YACZ,OAAO,QAAQ,gBAAgB,CAAC,QAC7B,CAAC,GAAG,OAAO,KAAK,iBAAiB,MAAM,aACzC,CACF;OAED,QAAO;;AAKX,SAAgB,cAAc,OAAY,YAAoB;AAC5D,QAAO,SACL,CAAC,MAAM,QAAQ,MAAM,IAErB,EAAE,iBAAiB,SACnB,OAAO,UAAU,WACf,QACA,GAAG,aAAa,OAAO;;;;;;AAmG7B,SAAgB,YAAY,QAAwC;AAClE,QAAO,EAAE;;AAGX,SAAgB,kBACd,QAEA,OACgB;AAChB,KAAI,WAAW,KACb,QAAO,EAAE,cAAc,OAAO;UACrB,QAAQ,iBAAiB,KAAA,EAClC,QAAO;EAAE,GAAG;EAAQ,cAAc;EAAO;KAEzC,QAAO;EACL,GAAG;EACH,cAAc;GAAE,GAAG,OAAO;GAAc,GAAG;GAAO;EACnD;;AAIL,SAAgB,mBACd,QACA,UACgB;CAChB,MAAM,UAAU,UAAU,WAAW,EAAE;AAEvC,KAAI,OAAO,KAAK,QAAQ,CAAC,SAAS,EAChC,QAAO,kBAAkB,QAAQ,GAC9B,4BAA4B;EAC3B,GAAG;GACF,OAAO,cAAc,iBAAiB,KACrC,OAAO,cAAc;EACxB,EACF,CAAC;KAEF,QAAO;;;;;;;AASX,SAAgB,oBAAoB,GAAG,GAGrC;CACA,MAAM,UAAU,CAAC,GAAG,IAAI,IAAI,EAAE,OAAO,QAAQ,CAAC,CAAC;AAE/C,KAAI,QAAQ,WAAW,EACrB,QAAO;EAAE,QAAQ,KAAA;EAAW,SAAS,KAAA;EAAW;AAGlD,KAAI,QAAQ,WAAW,EACrB,QAAO;EAAE,QAAQ,QAAQ;EAAI,SAAS,KAAA;EAAW;CAGnD,MAAM,qBAAqB,IAAI,iBAAiB;CAChD,MAAM,iBAAiB;EACrB,MAAM,SAAS,QAAQ,MAAM,MAAM,EAAE,QAAQ,EAAE;AAC/C,qBAAmB,MAAM,OAAO;AAChC,UAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS,SAAS,CAAC;;AAGlE,SAAQ,SAAS,MAAM,EAAE,iBAAiB,SAAS,UAAU,EAAE,MAAM,MAAM,CAAC,CAAC;CAE7E,MAAM,0BAA0B,QAAQ,MAAM,MAAM,EAAE,QAAQ;AAC9D,KAAI,wBACF,oBAAmB,MAAM,wBAAwB,OAAO;AAG1D,QAAO;EACL,QAAQ,mBAAmB;EAC3B,eAAe;AACb,WAAQ,SAAS,MAAM,EAAE,oBAAoB,SAAS,SAAS,CAAC;;EAEnE"}
|
package/dist/web.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const require_base = require("./channels/base.cjs");
|
|
|
5
5
|
const require_binop = require("./channels/binop.cjs");
|
|
6
6
|
const require_annotation = require("./graph/annotation.cjs");
|
|
7
7
|
const require_config = require("./pregel/utils/config.cjs");
|
|
8
|
+
const require_index = require("./pregel/utils/index.cjs");
|
|
8
9
|
const require_runtime = require("./pregel/runtime.cjs");
|
|
9
10
|
const require_convert = require("./stream/convert.cjs");
|
|
10
11
|
const require_stream_channel = require("./stream/stream-channel.cjs");
|
|
@@ -32,7 +33,7 @@ require("./state/index.cjs");
|
|
|
32
33
|
const require_state = require("./graph/state.cjs");
|
|
33
34
|
const require_message = require("./graph/message.cjs");
|
|
34
35
|
require("./graph/index.cjs");
|
|
35
|
-
const require_index$
|
|
36
|
+
const require_index$4 = require("./func/index.cjs");
|
|
36
37
|
const require_messages_annotation = require("./graph/messages_annotation.cjs");
|
|
37
38
|
const require_writer = require("./writer.cjs");
|
|
38
39
|
let _langchain_langgraph_checkpoint = require("@langchain/langgraph-checkpoint");
|
|
@@ -142,13 +143,13 @@ Object.defineProperty(exports, "emptyCheckpoint", {
|
|
|
142
143
|
return _langchain_langgraph_checkpoint.emptyCheckpoint;
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
|
-
exports.entrypoint = require_index$
|
|
146
|
+
exports.entrypoint = require_index$4.entrypoint;
|
|
146
147
|
exports.filterLifecycleEntries = require_lifecycle.filterLifecycleEntries;
|
|
147
148
|
exports.filterSubgraphHandles = require_subgraphs.filterSubgraphHandles;
|
|
148
149
|
exports.getConfig = require_config.getConfig;
|
|
149
150
|
exports.getCurrentTaskInput = require_config.getCurrentTaskInput;
|
|
150
151
|
exports.getJsonSchemaFromSchema = require_adapter.getJsonSchemaFromSchema;
|
|
151
|
-
exports.getPreviousState = require_index$
|
|
152
|
+
exports.getPreviousState = require_index$4.getPreviousState;
|
|
152
153
|
exports.getSchemaDefaultGetter = require_adapter.getSchemaDefaultGetter;
|
|
153
154
|
exports.getStore = require_config.getStore;
|
|
154
155
|
exports.getSubgraphsSeenSet = require_errors.getSubgraphsSeenSet;
|
|
@@ -168,6 +169,7 @@ exports.isSerializableSchema = require_types$1.isSerializableSchema;
|
|
|
168
169
|
exports.isStandardSchema = require_types$1.isStandardSchema;
|
|
169
170
|
exports.messagesDeltaReducer = require_messages_reducer.messagesDeltaReducer;
|
|
170
171
|
exports.messagesStateReducer = require_messages_reducer.messagesStateReducer;
|
|
172
|
+
exports.omitPayload = require_index.omitPayload;
|
|
171
173
|
exports.pushMessage = require_message.pushMessage;
|
|
172
|
-
exports.task = require_index$
|
|
174
|
+
exports.task = require_index$4.task;
|
|
173
175
|
exports.writer = require_writer.writer;
|
package/dist/web.d.cts
CHANGED
|
@@ -13,7 +13,7 @@ import { UntrackedValueChannel } from "./channels/untracked_value.cjs";
|
|
|
13
13
|
import { RunControl } from "./pregel/runtime.cjs";
|
|
14
14
|
import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.cjs";
|
|
15
15
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
|
|
16
|
-
import { CachePolicy, RetryPolicy } from "./pregel/utils/index.cjs";
|
|
16
|
+
import { CachePolicy, RetryPolicy, TracePolicy, omitPayload } from "./pregel/utils/index.cjs";
|
|
17
17
|
import { PregelNode } from "./pregel/read.cjs";
|
|
18
18
|
import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.cjs";
|
|
19
19
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.cjs";
|
|
@@ -46,4 +46,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
46
46
|
import { MessagesDeltaValue, MessagesValue } from "./state/prebuilt/messages.cjs";
|
|
47
47
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
|
|
48
48
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
|
|
49
|
-
export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, DeltaValue, DeltaValueInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesDeltaValue, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
|
|
49
|
+
export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, DeltaValue, DeltaValueInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesDeltaValue, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, type TracePolicy, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, omitPayload, pushMessage, task, writer };
|
package/dist/web.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ import { UntrackedValueChannel } from "./channels/untracked_value.js";
|
|
|
13
13
|
import { RunControl } from "./pregel/runtime.js";
|
|
14
14
|
import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.js";
|
|
15
15
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
|
|
16
|
-
import { CachePolicy, RetryPolicy } from "./pregel/utils/index.js";
|
|
16
|
+
import { CachePolicy, RetryPolicy, TracePolicy, omitPayload } from "./pregel/utils/index.js";
|
|
17
17
|
import { PregelNode } from "./pregel/read.js";
|
|
18
18
|
import { AgentStatus, ChatModelStream, InferExtensions, InterruptPayload, LifecycleCause, LifecycleData, MessagesEventData, Namespace, NativeStreamTransformer, ProtocolEvent, StreamEmitter, StreamTransformer, ToolCallStatus, ToolCallStream, ToolsEventData, UpdatesEventData, UsageInfo, isNativeTransformer } from "./stream/types.js";
|
|
19
19
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
|
|
@@ -46,4 +46,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
46
46
|
import { MessagesDeltaValue, MessagesValue } from "./state/prebuilt/messages.js";
|
|
47
47
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
48
48
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
|
|
49
|
-
export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, DeltaValue, DeltaValueInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesDeltaValue, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
|
|
49
|
+
export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, DeltaValue, DeltaValueInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesDeltaValue, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, type TracePolicy, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, omitPayload, pushMessage, task, writer };
|
package/dist/web.js
CHANGED
|
@@ -4,6 +4,7 @@ import { BaseChannel } from "./channels/base.js";
|
|
|
4
4
|
import { BinaryOperatorAggregate } from "./channels/binop.js";
|
|
5
5
|
import { Annotation } from "./graph/annotation.js";
|
|
6
6
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
7
|
+
import { omitPayload } from "./pregel/utils/index.js";
|
|
7
8
|
import { RunControl } from "./pregel/runtime.js";
|
|
8
9
|
import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
|
|
9
10
|
import { StreamChannel } from "./stream/stream-channel.js";
|
|
@@ -35,4 +36,4 @@ import { entrypoint, getPreviousState, task } from "./func/index.js";
|
|
|
35
36
|
import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
|
|
36
37
|
import { writer } from "./writer.js";
|
|
37
38
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, MemorySaver, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
|
|
38
|
-
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, DeltaChannel, DeltaValue, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesDeltaValue, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, RunControl, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
|
|
39
|
+
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, DeltaChannel, DeltaValue, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesDeltaValue, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, RunControl, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, omitPayload, pushMessage, task, writer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.15-rc.0",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -16,19 +16,19 @@
|
|
|
16
16
|
"author": "LangChain",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@langchain/protocol": "^0.0.
|
|
19
|
+
"@langchain/protocol": "^0.0.19",
|
|
20
20
|
"@standard-schema/spec": "1.1.0",
|
|
21
21
|
"@langchain/langgraph-checkpoint": "^1.1.5",
|
|
22
|
-
"@langchain/langgraph-sdk": "~1.10.0"
|
|
22
|
+
"@langchain/langgraph-sdk": "~1.10.3-rc.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"@langchain/core": "^1.1.48",
|
|
26
26
|
"zod": "^3.25.32 || ^4.2.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@langchain/anthropic": "^1.5.
|
|
30
|
-
"@langchain/core": "^1.2.
|
|
31
|
-
"@langchain/openai": "^1.5.
|
|
29
|
+
"@langchain/anthropic": "^1.5.8",
|
|
30
|
+
"@langchain/core": "^1.2.9",
|
|
31
|
+
"@langchain/openai": "^1.5.10",
|
|
32
32
|
"@langchain/scripts": ">=0.1.3 <0.2.0",
|
|
33
33
|
"@langchain/tavily": "^1.0.0",
|
|
34
34
|
"@swc/core": "^1.3.90",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"cheerio": "1.0.0-rc.12",
|
|
42
42
|
"dotenv": "^16.3.1",
|
|
43
43
|
"dpdm": "^3.12.0",
|
|
44
|
-
"langchain": "^1.5.
|
|
44
|
+
"langchain": "^1.5.10",
|
|
45
45
|
"pg": "^8.13.0",
|
|
46
46
|
"playwright": "^1.55.1",
|
|
47
47
|
"rollup": "^4.62.3",
|