@langchain/langgraph 1.0.0-alpha.2 → 1.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/graph/message.cjs +3 -4
- package/dist/graph/message.cjs.map +1 -1
- package/dist/graph/message.js +3 -4
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/zod/zod-registry.d.cts.map +1 -1
- package/dist/pregel/index.cjs +28 -10
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts +2 -2
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts +2 -2
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +29 -11
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/stream.cjs +107 -0
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.js +107 -1
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.d.cts +10 -2
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts +10 -2
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/package.json +1 -12
- package/dist/ui/index.cjs +0 -4
- package/dist/ui/index.d.cts +0 -5
- package/dist/ui/index.d.ts +0 -5
- package/dist/ui/index.js +0 -3
- package/dist/ui/stream.cjs +0 -145
- package/dist/ui/stream.cjs.map +0 -1
- package/dist/ui/stream.d.cts +0 -25
- package/dist/ui/stream.d.cts.map +0 -1
- package/dist/ui/stream.d.ts +0 -25
- package/dist/ui/stream.d.ts.map +0 -1
- package/dist/ui/stream.js +0 -143
- package/dist/ui/stream.js.map +0 -1
- package/dist/ui/types.infer.d.cts +0 -53
- package/dist/ui/types.infer.d.cts.map +0 -1
- package/dist/ui/types.infer.d.ts +0 -53
- package/dist/ui/types.infer.d.ts.map +0 -1
- package/dist/ui/types.message.d.cts +0 -95
- package/dist/ui/types.message.d.cts.map +0 -1
- package/dist/ui/types.message.d.ts +0 -95
- package/dist/ui/types.message.d.ts.map +0 -1
- package/dist/ui/types.schema.d.cts +0 -228
- package/dist/ui/types.schema.d.cts.map +0 -1
- package/dist/ui/types.schema.d.ts +0 -228
- package/dist/ui/types.schema.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @langchain/langgraph
|
|
2
2
|
|
|
3
|
+
## 1.0.0-alpha.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 05619e2: Add `stream.encoding` option to emit LangGraph API events as Server-Sent Events. This allows for sending events through the wire by piping the stream to a `Response` object.
|
|
8
|
+
- 14cb042: Fix `stateKey` property in `pushMessage` being ignored when RunnableConfig is automatically inherited
|
|
9
|
+
|
|
3
10
|
## 1.0.0-alpha.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/dist/graph/message.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_config = require('../pregel/utils/config.cjs');
|
|
2
3
|
const require_state = require('./state.cjs');
|
|
3
|
-
const __langchain_core_singletons = require_rolldown_runtime.__toESM(require("@langchain/core/singletons"));
|
|
4
4
|
const uuid = require_rolldown_runtime.__toESM(require("uuid"));
|
|
5
5
|
const __langchain_core_messages = require_rolldown_runtime.__toESM(require("@langchain/core/messages"));
|
|
6
6
|
|
|
@@ -70,9 +70,8 @@ var MessageGraph = class extends require_state.StateGraph {
|
|
|
70
70
|
* @param options RunnableConfig / Runtime coming from node context.
|
|
71
71
|
*/
|
|
72
72
|
function pushMessage(message, options) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const { stateKey: userStateKey,...config } = rawOptions;
|
|
73
|
+
const { stateKey: userStateKey,...userConfig } = options ?? {};
|
|
74
|
+
const config = require_config.ensureLangGraphConfig(userConfig);
|
|
76
75
|
let stateKey = userStateKey ?? "messages";
|
|
77
76
|
if (userStateKey === null) stateKey = void 0;
|
|
78
77
|
const validMessage = (0, __langchain_core_messages.coerceMessageLikeToMessage)(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.cjs","names":["coerceMessageLikeToMessage","removeAllIdx: number | undefined","StateGraph","
|
|
1
|
+
{"version":3,"file":"message.cjs","names":["coerceMessageLikeToMessage","removeAllIdx: number | undefined","StateGraph","ensureLangGraphConfig","stateKey: string | undefined"],"sources":["../../src/graph/message.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n} from \"@langchain/core/messages\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { v4 } from \"uuid\";\nimport { StateGraph } from \"./state.js\";\nimport { ensureLangGraphConfig } from \"../pregel/utils/config.js\";\nimport type { StreamMessagesHandler } from \"../pregel/messages.js\";\n\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Prebuilt reducer that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n // coerce to message\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n // assign missing ids\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n if (m.getType() === \"remove\" && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // merge\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n if (m.getType() === \"remove\") {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n if (m.getType() === \"remove\") {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/** @ignore */\nexport class MessageGraph extends StateGraph<\n BaseMessage[],\n BaseMessage[],\n Messages\n> {\n constructor() {\n super({\n channels: {\n __root__: {\n reducer: messagesStateReducer,\n default: () => [],\n },\n },\n });\n }\n}\n\n/**\n * Manually push a message to a message stream.\n *\n * This is useful when you need to push a manually created message before the node\n * has finished executing.\n *\n * When a message is pushed, it will be automatically persisted to the state after the node has finished executing.\n * To disable persisting, set `options.stateKey` to `null`.\n *\n * @param message The message to push. The message must have an ID set, otherwise an error will be thrown.\n * @param options RunnableConfig / Runtime coming from node context.\n */\nexport function pushMessage(\n message: BaseMessage | BaseMessageLike,\n options?: RunnableConfig & {\n /**\n * The key of the state to push the message to. Set to `null` to avoid persisting.\n * @default \"messages\"\n */\n stateKey?: string | null;\n }\n) {\n const { stateKey: userStateKey, ...userConfig } = options ?? {};\n const config = ensureLangGraphConfig(userConfig);\n\n let stateKey: string | undefined = userStateKey ?? \"messages\";\n if (userStateKey === null) stateKey = undefined;\n\n // coerce to message\n const validMessage = coerceMessageLikeToMessage(message);\n if (!validMessage.id) throw new Error(\"Message ID is required.\");\n\n const callbacks = (() => {\n if (Array.isArray(config.callbacks)) {\n return config.callbacks;\n }\n\n if (typeof config.callbacks !== \"undefined\") {\n return config.callbacks.handlers;\n }\n\n return [];\n })();\n\n const messagesHandler = callbacks.find(\n (cb): cb is StreamMessagesHandler =>\n \"name\" in cb && cb.name === \"StreamMessagesHandler\"\n );\n\n if (messagesHandler) {\n const metadata = config.metadata ?? {};\n const namespace = (\n (metadata.langgraph_checkpoint_ns ?? \"\") as string\n ).split(\"|\");\n\n messagesHandler._emit(\n [namespace, metadata],\n validMessage,\n undefined,\n false\n );\n }\n\n if (stateKey) {\n config.configurable?.__pregel_send?.([[stateKey, validMessage]]);\n }\n\n return validMessage;\n}\n"],"mappings":";;;;;;;AAWA,MAAa,sBAAsB;;;;;;AAYnC,SAAgB,qBACd,MACA,OACe;CACf,MAAM,YAAY,MAAM,QAAQ,QAAQ,OAAO,CAAC;CAChD,MAAM,aAAa,MAAM,QAAQ,SAAS,QAAQ,CAAC;CAEnD,MAAM,eAAgB,UAAgC,IACpDA;CAEF,MAAM,gBAAiB,WAAiC,IACtDA;AAGF,MAAK,MAAM,KAAK,aACd,KAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,QAAW;AACvC,IAAE;AACF,IAAE,UAAU,KAAK,EAAE;;CAIvB,IAAIC;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK,GAAG;EAChD,MAAM,IAAI,cAAc;AACxB,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,QAAW;AACvC,KAAE;AACF,KAAE,UAAU,KAAK,EAAE;;AAGrB,MAAI,EAAE,cAAc,YAAY,EAAE,OAAO,oBACvC,gBAAe;;AAInB,KAAI,gBAAgB,KAAM,QAAO,cAAc,MAAM,eAAe;CAGpE,MAAM,SAAS,CAAC,GAAG;CACnB,MAAM,aAAa,IAAI,IAAI,OAAO,KAAK,GAAG,MAAM,CAAC,EAAE,IAAI;CACvD,MAAM,8BAAc,IAAI;AACxB,MAAK,MAAM,KAAK,eAAe;EAC7B,MAAM,cAAc,WAAW,IAAI,EAAE;AACrC,MAAI,gBAAgB,OAClB,KAAI,EAAE,cAAc,SAClB,aAAY,IAAI,EAAE;OACb;AACL,eAAY,OAAO,EAAE;AACrB,UAAO,eAAe;;OAEnB;AACL,OAAI,EAAE,cAAc,SAClB,OAAM,IAAI,MACR,kEAAkE,EAAE,GAAG;AAG3E,cAAW,IAAI,EAAE,IAAI,OAAO;AAC5B,UAAO,KAAK;;;AAGhB,QAAO,OAAO,QAAQ,MAAM,CAAC,YAAY,IAAI,EAAE;;;AAIjD,IAAa,eAAb,cAAkCC,yBAIhC;CACA,cAAc;AACZ,QAAM,EACJ,UAAU,EACR,UAAU;GACR,SAAS;GACT,eAAe;;;;;;;;;;;;;;;;AAmBzB,SAAgB,YACd,SACA,SAOA;CACA,MAAM,EAAE,UAAU,aAAc,GAAG,eAAe,WAAW;CAC7D,MAAM,SAASC,qCAAsB;CAErC,IAAIC,WAA+B,gBAAgB;AACnD,KAAI,iBAAiB,KAAM,YAAW;CAGtC,MAAM,yEAA0C;AAChD,KAAI,CAAC,aAAa,GAAI,OAAM,IAAI,MAAM;CAEtC,MAAM,mBAAmB;AACvB,MAAI,MAAM,QAAQ,OAAO,WACvB,QAAO,OAAO;AAGhB,MAAI,OAAO,OAAO,cAAc,YAC9B,QAAO,OAAO,UAAU;AAG1B,SAAO;;CAGT,MAAM,kBAAkB,UAAU,MAC/B,OACC,UAAU,MAAM,GAAG,SAAS;AAGhC,KAAI,iBAAiB;EACnB,MAAM,WAAW,OAAO,YAAY;EACpC,MAAM,aACH,SAAS,2BAA2B,IACrC,MAAM;AAER,kBAAgB,MACd,CAAC,WAAW,WACZ,cACA,QACA;;AAIJ,KAAI,SACF,QAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU;AAGnD,QAAO"}
|
package/dist/graph/message.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ensureLangGraphConfig } from "../pregel/utils/config.js";
|
|
1
2
|
import { StateGraph } from "./state.js";
|
|
2
|
-
import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
|
|
3
3
|
import { v4 } from "uuid";
|
|
4
4
|
import { coerceMessageLikeToMessage } from "@langchain/core/messages";
|
|
5
5
|
|
|
@@ -69,9 +69,8 @@ var MessageGraph = class extends StateGraph {
|
|
|
69
69
|
* @param options RunnableConfig / Runtime coming from node context.
|
|
70
70
|
*/
|
|
71
71
|
function pushMessage(message, options) {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const { stateKey: userStateKey,...config } = rawOptions;
|
|
72
|
+
const { stateKey: userStateKey,...userConfig } = options ?? {};
|
|
73
|
+
const config = ensureLangGraphConfig(userConfig);
|
|
75
74
|
let stateKey = userStateKey ?? "messages";
|
|
76
75
|
if (userStateKey === null) stateKey = void 0;
|
|
77
76
|
const validMessage = coerceMessageLikeToMessage(message);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","names":["removeAllIdx: number | undefined","
|
|
1
|
+
{"version":3,"file":"message.js","names":["removeAllIdx: number | undefined","stateKey: string | undefined"],"sources":["../../src/graph/message.ts"],"sourcesContent":["import {\n BaseMessage,\n BaseMessageLike,\n coerceMessageLikeToMessage,\n} from \"@langchain/core/messages\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { v4 } from \"uuid\";\nimport { StateGraph } from \"./state.js\";\nimport { ensureLangGraphConfig } from \"../pregel/utils/config.js\";\nimport type { StreamMessagesHandler } from \"../pregel/messages.js\";\n\nexport const REMOVE_ALL_MESSAGES = \"__remove_all__\";\n\nexport type Messages =\n | Array<BaseMessage | BaseMessageLike>\n | BaseMessage\n | BaseMessageLike;\n\n/**\n * Prebuilt reducer that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n */\nexport function messagesStateReducer(\n left: Messages,\n right: Messages\n): BaseMessage[] {\n const leftArray = Array.isArray(left) ? left : [left];\n const rightArray = Array.isArray(right) ? right : [right];\n // coerce to message\n const leftMessages = (leftArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n const rightMessages = (rightArray as BaseMessageLike[]).map(\n coerceMessageLikeToMessage\n );\n // assign missing ids\n for (const m of leftMessages) {\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n }\n\n let removeAllIdx: number | undefined;\n for (let i = 0; i < rightMessages.length; i += 1) {\n const m = rightMessages[i];\n if (m.id === null || m.id === undefined) {\n m.id = v4();\n m.lc_kwargs.id = m.id;\n }\n\n if (m.getType() === \"remove\" && m.id === REMOVE_ALL_MESSAGES) {\n removeAllIdx = i;\n }\n }\n\n if (removeAllIdx != null) return rightMessages.slice(removeAllIdx + 1);\n\n // merge\n const merged = [...leftMessages];\n const mergedById = new Map(merged.map((m, i) => [m.id, i]));\n const idsToRemove = new Set();\n for (const m of rightMessages) {\n const existingIdx = mergedById.get(m.id);\n if (existingIdx !== undefined) {\n if (m.getType() === \"remove\") {\n idsToRemove.add(m.id);\n } else {\n idsToRemove.delete(m.id);\n merged[existingIdx] = m;\n }\n } else {\n if (m.getType() === \"remove\") {\n throw new Error(\n `Attempting to delete a message with an ID that doesn't exist ('${m.id}')`\n );\n }\n mergedById.set(m.id, merged.length);\n merged.push(m);\n }\n }\n return merged.filter((m) => !idsToRemove.has(m.id));\n}\n\n/** @ignore */\nexport class MessageGraph extends StateGraph<\n BaseMessage[],\n BaseMessage[],\n Messages\n> {\n constructor() {\n super({\n channels: {\n __root__: {\n reducer: messagesStateReducer,\n default: () => [],\n },\n },\n });\n }\n}\n\n/**\n * Manually push a message to a message stream.\n *\n * This is useful when you need to push a manually created message before the node\n * has finished executing.\n *\n * When a message is pushed, it will be automatically persisted to the state after the node has finished executing.\n * To disable persisting, set `options.stateKey` to `null`.\n *\n * @param message The message to push. The message must have an ID set, otherwise an error will be thrown.\n * @param options RunnableConfig / Runtime coming from node context.\n */\nexport function pushMessage(\n message: BaseMessage | BaseMessageLike,\n options?: RunnableConfig & {\n /**\n * The key of the state to push the message to. Set to `null` to avoid persisting.\n * @default \"messages\"\n */\n stateKey?: string | null;\n }\n) {\n const { stateKey: userStateKey, ...userConfig } = options ?? {};\n const config = ensureLangGraphConfig(userConfig);\n\n let stateKey: string | undefined = userStateKey ?? \"messages\";\n if (userStateKey === null) stateKey = undefined;\n\n // coerce to message\n const validMessage = coerceMessageLikeToMessage(message);\n if (!validMessage.id) throw new Error(\"Message ID is required.\");\n\n const callbacks = (() => {\n if (Array.isArray(config.callbacks)) {\n return config.callbacks;\n }\n\n if (typeof config.callbacks !== \"undefined\") {\n return config.callbacks.handlers;\n }\n\n return [];\n })();\n\n const messagesHandler = callbacks.find(\n (cb): cb is StreamMessagesHandler =>\n \"name\" in cb && cb.name === \"StreamMessagesHandler\"\n );\n\n if (messagesHandler) {\n const metadata = config.metadata ?? {};\n const namespace = (\n (metadata.langgraph_checkpoint_ns ?? \"\") as string\n ).split(\"|\");\n\n messagesHandler._emit(\n [namespace, metadata],\n validMessage,\n undefined,\n false\n );\n }\n\n if (stateKey) {\n config.configurable?.__pregel_send?.([[stateKey, validMessage]]);\n }\n\n return validMessage;\n}\n"],"mappings":";;;;;;AAWA,MAAa,sBAAsB;;;;;;AAYnC,SAAgB,qBACd,MACA,OACe;CACf,MAAM,YAAY,MAAM,QAAQ,QAAQ,OAAO,CAAC;CAChD,MAAM,aAAa,MAAM,QAAQ,SAAS,QAAQ,CAAC;CAEnD,MAAM,eAAgB,UAAgC,IACpD;CAEF,MAAM,gBAAiB,WAAiC,IACtD;AAGF,MAAK,MAAM,KAAK,aACd,KAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,QAAW;AACvC,IAAE,KAAK;AACP,IAAE,UAAU,KAAK,EAAE;;CAIvB,IAAIA;AACJ,MAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KAAK,GAAG;EAChD,MAAM,IAAI,cAAc;AACxB,MAAI,EAAE,OAAO,QAAQ,EAAE,OAAO,QAAW;AACvC,KAAE,KAAK;AACP,KAAE,UAAU,KAAK,EAAE;;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ACpC,MAAM,aACH,SAAS,2BAA2B,IACrC,MAAM;AAER,kBAAgB,MACd,CAAC,WAAW,WACZ,cACA,QACA;;AAIJ,KAAI,SACF,QAAO,cAAc,gBAAgB,CAAC,CAAC,UAAU;AAGnD,QAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.d.cts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","
|
|
1
|
+
{"version":3,"file":"zod-registry.d.cts","names":["core","$ZodType","$ZodRegistry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","_0","Output","Input","$ZodTypeInternals","Internals","output","input","TOutput","TInput","R","TInternals","ZodType","sideEffect","ZodMiniType","registry"],"sources":["../../../src/graph/zod/zod-registry.d.ts"],"sourcesContent":["import type * as core from \"zod/v4/core\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport { type ReducedZodChannel, type SchemaMeta, type SchemaMetaRegistry } from \"./meta.js\";\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport declare class LanggraphZodMetaRegistry<Meta extends SchemaMeta = SchemaMeta, Schema extends $ZodType = $ZodType> extends $ZodRegistry<Meta & {\n [key: string]: unknown;\n}, Schema> {\n protected parent: SchemaMetaRegistry;\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(parent: SchemaMetaRegistry);\n add<S extends Schema>(schema: S, ..._meta: undefined extends Meta & {\n [key: string]: unknown;\n } ? [$replace<Meta & {\n [key: string]: unknown;\n }, S>?] : [$replace<Meta & {\n [key: string]: unknown;\n }, S>]): this;\n}\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n interface ZodType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\ndeclare module \"zod/v4-mini\" {\n interface ZodMiniType<out Output = unknown, out Input = unknown, out Internals extends core.$ZodTypeInternals<Output, Input> = core.$ZodTypeInternals<Output, Input>> extends core.$ZodType<Output, Input, Internals> {\n register<R extends LanggraphZodMetaRegistry, TOutput = core.output<this>, TInput = core.input<this>, TInternals extends core.$ZodTypeInternals<TOutput, TInput> = core.$ZodTypeInternals<TOutput, TInput>>(registry: R, meta: SchemaMeta<TOutput, TInput>): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\nexport declare const registry: LanggraphZodMetaRegistry<SchemaMeta<any, any>, $ZodType<unknown, unknown, core.$ZodTypeInternals<unknown, unknown>>>;\n"],"mappings":";;;;;;;;AAcA;;;;;;;;;AASwBM,cATHC,wBASGD,CAAAA,aATmCD,UASnCC,GATgDD,UAShDC,EAAAA,eAT2EL,QAS3EK,GATsFL,QAStFK,CAAAA,SATwGJ,YASxGI,CATqHE,IASrHF,GAAAA;MACNG,EAAAA,MAAAA,CAAAA,EAAAA,OAAAA;GARfA,MAQ+BC,CAAAA,CAAAA;YAA+BF,MAAAA,EAP3CF,kBAO2CE;;;;;;aAIlDL,CAAAA,MAAAA,EALSG,kBAKTH;KAdiHD,CAAAA,UAU9GO,MAV8GP,CAAAA,CAAAA,MAAAA,EAU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;eAC3GE,aAAAA,CAAAA;YAAuDC,WAAAA,CAAAA,aAAAA,OAAAA,EAAAA,YAAAA,OAAAA,EAAAA,sBAI5DlB,IAAAA,CAAKc,iBAJuDI,CAIrCN,MAJqCM,EAI7BL,KAJ6BK,CAAAA,GAIpBlB,IAAAA,CAAKc,iBAJeI,CAIGN,MAJHM,EAIWL,KAJXK,CAAAA,CAAAA,SAI2BlB,IAAAA,CAAKC,QAJhCiB,CAIyCN,MAJzCM,EAIiDL,KAJjDK,EAIwDH,SAJxDG,CAAAA,CAAAA;IAASC,QAAAA,CAAAA,UAKrIZ,wBALqIY,EAAAA,UAKjGnB,IAAAA,CAAKgB,MAL4FG,CAAAA,IAAAA,CAAAA,EAAAA,SAKrEnB,IAAAA,CAAKiB,KALgEE,CAAAA,IAAAA,CAAAA,EAAAA,mBAKhCnB,IAAAA,CAAKc,iBAL2BK,CAKTD,OALSC,EAKAA,MALAA,CAAAA,GAKUnB,IAAAA,CAAKc,iBALfK,CAKiCD,OALjCC,EAK0CA,MAL1CA,CAAAA,CAAAA,CAAAA,QAAAA,EAK6DC,CAL7DD,EAAAA,IAAAA,EAKsEd,UALtEc,CAKiFD,OALjFC,EAK0FA,MAL1FA,CAAAA,CAAAA,EAKoGf,iBALpGe,CAAAA,IAAAA,EAK4HK,WAL5HL,CAKwID,OALxIC,EAKiJA,MALjJA,EAKyJE,UALzJF,CAAAA,CAAAA;;;AAA0CA,cAQrLM,QARqLN,EAQ3KZ,wBAR2KY,CAQlJd,UARkJc,CAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAQ5HlB,QAR4HkB,CAAAA,OAAAA,EAAAA,OAAAA,EAQjGnB,IAAAA,CAAKc,iBAR4FK,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA"}
|
package/dist/pregel/index.cjs
CHANGED
|
@@ -905,7 +905,8 @@ var Pregel = class extends PartialRunnable {
|
|
|
905
905
|
...options,
|
|
906
906
|
signal: require_index.combineAbortSignals(options?.signal, abortController.signal).signal
|
|
907
907
|
};
|
|
908
|
-
|
|
908
|
+
const stream = await super.stream(input, config);
|
|
909
|
+
return new require_stream.IterableReadableStreamWithAbortSignal(options?.encoding === "text/event-stream" ? require_stream.toEventStream(stream) : stream, abortController);
|
|
909
910
|
}
|
|
910
911
|
streamEvents(input, options, streamOptions) {
|
|
911
912
|
const abortController = new AbortController();
|
|
@@ -945,6 +946,7 @@ var Pregel = class extends PartialRunnable {
|
|
|
945
946
|
* @internal
|
|
946
947
|
*/
|
|
947
948
|
async *_streamIterator(input, options) {
|
|
949
|
+
const streamEncoding = "version" in (options ?? {}) ? void 0 : options?.encoding ?? void 0;
|
|
948
950
|
const streamSubgraphs = options?.subgraphs;
|
|
949
951
|
const inputConfig = require_config.ensureLangGraphConfig(this.config, options);
|
|
950
952
|
if (inputConfig.recursionLimit === void 0 || inputConfig.recursionLimit < 1) throw new Error(`Passed "recursionLimit" must be at least 1.`);
|
|
@@ -1050,14 +1052,29 @@ var Pregel = class extends PartialRunnable {
|
|
|
1050
1052
|
for await (const chunk of stream) {
|
|
1051
1053
|
if (chunk === void 0) throw new Error("Data structure error.");
|
|
1052
1054
|
const [namespace, mode, payload] = chunk;
|
|
1053
|
-
if (streamMode.includes(mode))
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1055
|
+
if (streamMode.includes(mode)) {
|
|
1056
|
+
if (streamEncoding === "text/event-stream") {
|
|
1057
|
+
if (streamSubgraphs) yield [
|
|
1058
|
+
namespace,
|
|
1059
|
+
mode,
|
|
1060
|
+
payload
|
|
1061
|
+
];
|
|
1062
|
+
else yield [
|
|
1063
|
+
null,
|
|
1064
|
+
mode,
|
|
1065
|
+
payload
|
|
1066
|
+
];
|
|
1067
|
+
continue;
|
|
1068
|
+
}
|
|
1069
|
+
if (streamSubgraphs && !streamModeSingle) yield [
|
|
1070
|
+
namespace,
|
|
1071
|
+
mode,
|
|
1072
|
+
payload
|
|
1073
|
+
];
|
|
1074
|
+
else if (!streamModeSingle) yield [mode, payload];
|
|
1075
|
+
else if (streamSubgraphs) yield [namespace, payload];
|
|
1076
|
+
else yield payload;
|
|
1077
|
+
}
|
|
1061
1078
|
}
|
|
1062
1079
|
} catch (e) {
|
|
1063
1080
|
await runManager?.handleChainError(loopError);
|
|
@@ -1077,7 +1094,8 @@ var Pregel = class extends PartialRunnable {
|
|
|
1077
1094
|
const config = {
|
|
1078
1095
|
...options,
|
|
1079
1096
|
outputKeys: options?.outputKeys ?? this.outputChannels,
|
|
1080
|
-
streamMode
|
|
1097
|
+
streamMode,
|
|
1098
|
+
encoding: void 0
|
|
1081
1099
|
};
|
|
1082
1100
|
const chunks = [];
|
|
1083
1101
|
const stream = await this.stream(input, config);
|