langchain 1.3.0 → 1.3.2
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 +14 -0
- package/dist/agents/ReactAgent.cjs +5 -11
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +5 -11
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/nodes/AfterAgentNode.cjs +2 -2
- package/dist/agents/nodes/AfterAgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AfterAgentNode.js +2 -2
- package/dist/agents/nodes/AfterAgentNode.js.map +1 -1
- package/dist/agents/nodes/AfterModelNode.cjs +2 -2
- package/dist/agents/nodes/AfterModelNode.cjs.map +1 -1
- package/dist/agents/nodes/AfterModelNode.js +2 -2
- package/dist/agents/nodes/AfterModelNode.js.map +1 -1
- package/dist/agents/nodes/AgentNode.cjs +2 -3
- package/dist/agents/nodes/AgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AgentNode.js +2 -3
- package/dist/agents/nodes/AgentNode.js.map +1 -1
- package/dist/agents/nodes/BeforeAgentNode.cjs +2 -2
- package/dist/agents/nodes/BeforeAgentNode.cjs.map +1 -1
- package/dist/agents/nodes/BeforeAgentNode.js +2 -2
- package/dist/agents/nodes/BeforeAgentNode.js.map +1 -1
- package/dist/agents/nodes/BeforeModelNode.cjs +2 -2
- package/dist/agents/nodes/BeforeModelNode.cjs.map +1 -1
- package/dist/agents/nodes/BeforeModelNode.js +2 -2
- package/dist/agents/nodes/BeforeModelNode.js.map +1 -1
- package/dist/agents/nodes/middleware.cjs +1 -4
- package/dist/agents/nodes/middleware.cjs.map +1 -1
- package/dist/agents/nodes/middleware.js +1 -4
- package/dist/agents/nodes/middleware.js.map +1 -1
- package/package.json +5 -5
- package/dist/agents/state.cjs +0 -43
- package/dist/agents/state.cjs.map +0 -1
- package/dist/agents/state.js +0 -43
- package/dist/agents/state.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.cjs","names":["RunnableCallable","
|
|
1
|
+
{"version":3,"file":"middleware.cjs","names":["RunnableCallable","getHookConstraint","derivePrivateState"],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v4\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>\n | { jumpTo?: JumpToTarget };\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>,\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>\n ) {\n super(fields);\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n invokeState: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n const state: TStateSchema = {\n ...invokeState,\n /**\n * don't overwrite possible outdated messages from other middleware nodes\n */\n messages: invokeState.messages,\n };\n\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n store: config?.store,\n configurable: config?.configurable,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n\n /**\n * If result is undefined, the hook made no state changes — return\n * only the jumpTo sentinel so we don't re-emit every input key as\n * a state update.\n */\n if (!result) {\n return { jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo: result.jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo: result.jumpTo };\n }\n\n get nodeOptions() {\n return {\n input: derivePrivateState(this.middleware.stateSchema),\n };\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAM,eAAN,MAAmB;AACnB,IAAM,eAAN,MAAmB;AAOnB,IAAsB,iBAAtB,cAGUA,yBAAAA,iBAAyD;CAMjE,YACE,QACA;AACA,QAAM,OAAO;;CAQf,MAAM,iBACJ,aACA,QACmC;;;;EAInC,IAAI,kBAAkB,EAAE;;;;AAIxB,MAAI,KAAK,WAAW,eAAe;;;;GAIjC,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAM,kBAA2C,EAAE;IACnD,MAAM,gBAAgB,QAAQ,WAAW,EAAE;AAC3C,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,cACT,iBAAgB,OAAO,cAAc;;;;;AAOzC,uBAAA,GAAA,4BAAA,cACE,KAAK,WAAW,eAChB,gBACD;;;EAIL,MAAM,QAAsB;GAC1B,GAAG;GAIH,UAAU,YAAY;GACvB;EAED,MAAM,UAAmC;GACvC,SAAS;GACT,OAAO,QAAQ;GACf,cAAc,QAAQ;GACtB,QAAQ,QAAQ;GAChB,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GACjB;EAED,MAAM,SAAS,MAAM,KAAK;GACxB;;;;;GAKA,OAAO,OACL,OAAO,OAAO,IAAI,cAAc,EAAE;IAChC,GAAG;IACH,SAAS,OAAO,OACd,OAAO,OAAO,IAAI,cAAc,EAAE,gBAAgB,CACnD;IACF,CAAC,CACH;GACF;;;;;;AAOD,MAAI,CAAC,OACH,QAAO,EAAE,QAAQ,KAAA,GAAW;;;;EAM9B,IAAI;EACJ,IAAI;AAEJ,MAAI,KAAK,MAAM,WAAW,mBAAmB,EAAE;AAC7C,sBAAmBC,gBAAAA,kBAAkB,KAAK,WAAW,YAAY;AACjE,gBAAa;aACJ,KAAK,MAAM,WAAW,mBAAmB,EAAE;AACpD,sBAAmBA,gBAAAA,kBAAkB,KAAK,WAAW,YAAY;AACjE,gBAAa;aACJ,KAAK,MAAM,WAAW,kBAAkB,EAAE;AACnD,sBAAmBA,gBAAAA,kBAAkB,KAAK,WAAW,WAAW;AAChE,gBAAa;aACJ,KAAK,MAAM,WAAW,kBAAkB,EAAE;AACnD,sBAAmBA,gBAAAA,kBAAkB,KAAK,WAAW,WAAW;AAChE,gBAAa;;AAGf,MACE,OAAO,OAAO,WAAW,YACzB,CAAC,kBAAkB,SAAS,OAAO,OAAuB,EAC1D;GACA,MAAM,aACJ,oBAAoB,iBAAiB,SAAS,IAC1C,mBAAmB,kBAAkB,KAAK,KAAK,CAAC,KAChD,aACE,MAAM,WAAW,yBAAyB,KAAK,WAAW,SAC1D;AACR,SAAM,IAAI,MAAM,wBAAwB,OAAO,OAAO,IAAI,WAAW,GAAG;;;;;AAM1E,MAAI,OAAO,WAAW,YAAY,UAAU,QAAQ;AAElD,OAAI,OAAO,SAAS,aAAa;AAC/B,QAAI,OAAO,MACT,OAAM,OAAO;AAEf,WAAO;KACL,GAAG;KACH,GAAI,OAAO,UAAU,EAAE;KACvB,QAAQ,OAAO;KAChB;;AAGH,SAAM,IAAI,MAAM,2BAA2B,KAAK,UAAU,OAAO,GAAG;;;;;AAMtE,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ,QAAQ,OAAO;GAAQ;;CAGvD,IAAI,cAAc;AAChB,SAAO,EACL,OAAOC,cAAAA,mBAAmB,KAAK,WAAW,YAAY,EACvD"}
|
|
@@ -9,10 +9,8 @@ import { interopParse } from "@langchain/core/utils/types";
|
|
|
9
9
|
var AgentContext = class {};
|
|
10
10
|
var AgentRuntime = class {};
|
|
11
11
|
var MiddlewareNode = class extends RunnableCallable {
|
|
12
|
-
|
|
13
|
-
constructor(fields, options) {
|
|
12
|
+
constructor(fields) {
|
|
14
13
|
super(fields);
|
|
15
|
-
this.#options = options;
|
|
16
14
|
}
|
|
17
15
|
async invokeMiddleware(invokeState, config) {
|
|
18
16
|
/**
|
|
@@ -39,7 +37,6 @@ var MiddlewareNode = class extends RunnableCallable {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
const state = {
|
|
42
|
-
...this.#options.getState(),
|
|
43
40
|
...invokeState,
|
|
44
41
|
messages: invokeState.messages
|
|
45
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","names":[
|
|
1
|
+
{"version":3,"file":"middleware.js","names":[],"sources":["../../../src/agents/nodes/middleware.ts"],"sourcesContent":["/* oxlint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v4\";\nimport { LangGraphRunnableConfig, Command } from \"@langchain/langgraph\";\nimport { interopParse } from \"@langchain/core/utils/types\";\n\nimport { RunnableCallable, RunnableCallableArgs } from \"../RunnableCallable.js\";\nimport type { JumpToTarget } from \"../constants.js\";\nimport type { Runtime } from \"../runtime.js\";\nimport type { AgentMiddleware, MiddlewareResult } from \"../middleware/types.js\";\nimport { derivePrivateState } from \"./utils.js\";\nimport { getHookConstraint } from \"../middleware/utils.js\";\n\n/**\n * Named class for context objects to provide better error messages\n */\nclass AgentContext {}\nclass AgentRuntime {}\n\ntype NodeOutput<TStateSchema extends Record<string, any>> =\n | TStateSchema\n | Command<any, TStateSchema, string>\n | { jumpTo?: JumpToTarget };\n\nexport abstract class MiddlewareNode<\n TStateSchema extends Record<string, any>,\n TContextSchema extends Record<string, any>,\n> extends RunnableCallable<TStateSchema, NodeOutput<TStateSchema>> {\n abstract middleware: AgentMiddleware<\n z.ZodObject<z.ZodRawShape>,\n z.ZodObject<z.ZodRawShape>\n >;\n\n constructor(\n fields: RunnableCallableArgs<TStateSchema, NodeOutput<TStateSchema>>\n ) {\n super(fields);\n }\n\n abstract runHook(\n state: TStateSchema,\n config?: Runtime<TContextSchema>\n ): Promise<MiddlewareResult<TStateSchema>> | MiddlewareResult<TStateSchema>;\n\n async invokeMiddleware(\n invokeState: TStateSchema,\n config?: LangGraphRunnableConfig\n ): Promise<NodeOutput<TStateSchema>> {\n /**\n * Filter context based on middleware's contextSchema\n */\n let filteredContext = {} as TContextSchema;\n /**\n * Parse context using middleware's contextSchema to apply defaults and validation\n */\n if (this.middleware.contextSchema) {\n /**\n * Extract only the fields relevant to this middleware's schema\n */\n const schemaShape = this.middleware.contextSchema?.shape;\n if (schemaShape) {\n const relevantContext: Record<string, unknown> = {};\n const invokeContext = config?.context || {};\n for (const key of Object.keys(schemaShape)) {\n if (key in invokeContext) {\n relevantContext[key] = invokeContext[key];\n }\n }\n /**\n * Parse to apply defaults and validation, even if relevantContext is empty\n * This will throw if required fields are missing and no defaults exist\n */\n filteredContext = interopParse(\n this.middleware.contextSchema,\n relevantContext\n ) as TContextSchema;\n }\n }\n\n const state: TStateSchema = {\n ...invokeState,\n /**\n * don't overwrite possible outdated messages from other middleware nodes\n */\n messages: invokeState.messages,\n };\n\n const runtime: Runtime<TContextSchema> = {\n context: filteredContext,\n store: config?.store,\n configurable: config?.configurable,\n writer: config?.writer,\n interrupt: config?.interrupt,\n signal: config?.signal,\n };\n\n const result = await this.runHook(\n state,\n /**\n * assign runtime and context values into empty named class\n * instances to create a better error message.\n */\n Object.freeze(\n Object.assign(new AgentRuntime(), {\n ...runtime,\n context: Object.freeze(\n Object.assign(new AgentContext(), filteredContext)\n ),\n })\n )\n );\n\n /**\n * If result is undefined, the hook made no state changes — return\n * only the jumpTo sentinel so we don't re-emit every input key as\n * a state update.\n */\n if (!result) {\n return { jumpTo: undefined };\n }\n\n /**\n * Verify that the jump target is allowed for the middleware\n */\n let jumpToConstraint: JumpToTarget[] | undefined;\n let constraint: string | undefined;\n\n if (this.name?.startsWith(\"BeforeAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeAgent);\n constraint = \"beforeAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"BeforeModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.beforeModel);\n constraint = \"beforeModel.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterAgentNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterAgent);\n constraint = \"afterAgent.canJumpTo\";\n } else if (this.name?.startsWith(\"AfterModelNode_\")) {\n jumpToConstraint = getHookConstraint(this.middleware.afterModel);\n constraint = \"afterModel.canJumpTo\";\n }\n\n if (\n typeof result.jumpTo === \"string\" &&\n !jumpToConstraint?.includes(result.jumpTo as JumpToTarget)\n ) {\n const suggestion =\n jumpToConstraint && jumpToConstraint.length > 0\n ? `must be one of: ${jumpToConstraint?.join(\", \")}.`\n : constraint\n ? `no ${constraint} defined in middleware ${this.middleware.name}`\n : \"\";\n throw new Error(`Invalid jump target: ${result.jumpTo}, ${suggestion}.`);\n }\n\n /**\n * If result is a control action, handle it\n */\n if (typeof result === \"object\" && \"type\" in result) {\n // Handle control actions\n if (result.type === \"terminate\") {\n if (result.error) {\n throw result.error;\n }\n return {\n ...state,\n ...(result.result || {}),\n jumpTo: result.jumpTo,\n };\n }\n\n throw new Error(`Invalid control action: ${JSON.stringify(result)}`);\n }\n\n /**\n * If result is a state update, merge it with current state\n */\n return { ...state, ...result, jumpTo: result.jumpTo };\n }\n\n get nodeOptions() {\n return {\n input: derivePrivateState(this.middleware.stateSchema),\n };\n }\n}\n"],"mappings":";;;;;;;;AAeA,IAAM,eAAN,MAAmB;AACnB,IAAM,eAAN,MAAmB;AAOnB,IAAsB,iBAAtB,cAGU,iBAAyD;CAMjE,YACE,QACA;AACA,QAAM,OAAO;;CAQf,MAAM,iBACJ,aACA,QACmC;;;;EAInC,IAAI,kBAAkB,EAAE;;;;AAIxB,MAAI,KAAK,WAAW,eAAe;;;;GAIjC,MAAM,cAAc,KAAK,WAAW,eAAe;AACnD,OAAI,aAAa;IACf,MAAM,kBAA2C,EAAE;IACnD,MAAM,gBAAgB,QAAQ,WAAW,EAAE;AAC3C,SAAK,MAAM,OAAO,OAAO,KAAK,YAAY,CACxC,KAAI,OAAO,cACT,iBAAgB,OAAO,cAAc;;;;;AAOzC,sBAAkB,aAChB,KAAK,WAAW,eAChB,gBACD;;;EAIL,MAAM,QAAsB;GAC1B,GAAG;GAIH,UAAU,YAAY;GACvB;EAED,MAAM,UAAmC;GACvC,SAAS;GACT,OAAO,QAAQ;GACf,cAAc,QAAQ;GACtB,QAAQ,QAAQ;GAChB,WAAW,QAAQ;GACnB,QAAQ,QAAQ;GACjB;EAED,MAAM,SAAS,MAAM,KAAK;GACxB;;;;;GAKA,OAAO,OACL,OAAO,OAAO,IAAI,cAAc,EAAE;IAChC,GAAG;IACH,SAAS,OAAO,OACd,OAAO,OAAO,IAAI,cAAc,EAAE,gBAAgB,CACnD;IACF,CAAC,CACH;GACF;;;;;;AAOD,MAAI,CAAC,OACH,QAAO,EAAE,QAAQ,KAAA,GAAW;;;;EAM9B,IAAI;EACJ,IAAI;AAEJ,MAAI,KAAK,MAAM,WAAW,mBAAmB,EAAE;AAC7C,sBAAmB,kBAAkB,KAAK,WAAW,YAAY;AACjE,gBAAa;aACJ,KAAK,MAAM,WAAW,mBAAmB,EAAE;AACpD,sBAAmB,kBAAkB,KAAK,WAAW,YAAY;AACjE,gBAAa;aACJ,KAAK,MAAM,WAAW,kBAAkB,EAAE;AACnD,sBAAmB,kBAAkB,KAAK,WAAW,WAAW;AAChE,gBAAa;aACJ,KAAK,MAAM,WAAW,kBAAkB,EAAE;AACnD,sBAAmB,kBAAkB,KAAK,WAAW,WAAW;AAChE,gBAAa;;AAGf,MACE,OAAO,OAAO,WAAW,YACzB,CAAC,kBAAkB,SAAS,OAAO,OAAuB,EAC1D;GACA,MAAM,aACJ,oBAAoB,iBAAiB,SAAS,IAC1C,mBAAmB,kBAAkB,KAAK,KAAK,CAAC,KAChD,aACE,MAAM,WAAW,yBAAyB,KAAK,WAAW,SAC1D;AACR,SAAM,IAAI,MAAM,wBAAwB,OAAO,OAAO,IAAI,WAAW,GAAG;;;;;AAM1E,MAAI,OAAO,WAAW,YAAY,UAAU,QAAQ;AAElD,OAAI,OAAO,SAAS,aAAa;AAC/B,QAAI,OAAO,MACT,OAAM,OAAO;AAEf,WAAO;KACL,GAAG;KACH,GAAI,OAAO,UAAU,EAAE;KACvB,QAAQ,OAAO;KAChB;;AAGH,SAAM,IAAI,MAAM,2BAA2B,KAAK,UAAU,OAAO,GAAG;;;;;AAMtE,SAAO;GAAE,GAAG;GAAO,GAAG;GAAQ,QAAQ,OAAO;GAAQ;;CAGvD,IAAI,cAAc;AAChB,SAAO,EACL,OAAO,mBAAmB,KAAK,WAAW,YAAY,EACvD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"author": "LangChain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
"typescript": "~5.8.3",
|
|
51
51
|
"vitest": "^4.1.2",
|
|
52
52
|
"yaml": "^2.8.3",
|
|
53
|
-
"@langchain/anthropic": "1.3.26",
|
|
54
53
|
"@langchain/core": "^1.1.39",
|
|
55
|
-
"@langchain/
|
|
56
|
-
"@langchain/
|
|
54
|
+
"@langchain/anthropic": "1.3.26",
|
|
55
|
+
"@langchain/fireworks": "0.1.2",
|
|
56
|
+
"@langchain/openai": "1.4.4",
|
|
57
57
|
"@langchain/tsconfig": "0.0.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@langchain/core": "^1.1.39"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@langchain/langgraph": "^1.2.
|
|
63
|
+
"@langchain/langgraph": "^1.2.8",
|
|
64
64
|
"@langchain/langgraph-checkpoint": "^1.0.1",
|
|
65
65
|
"langsmith": ">=0.5.0 <1.0.0",
|
|
66
66
|
"uuid": "^11.1.0",
|
package/dist/agents/state.cjs
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/agents/state.ts
|
|
2
|
-
/**
|
|
3
|
-
* The StateManager is responsible for managing the state of the agent.
|
|
4
|
-
* The `createAgent` maintains different nodes with their own state. For the user
|
|
5
|
-
* however, they only see the combined state of all nodes. This class is helps
|
|
6
|
-
* to share the state between different nodes.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
var StateManager = class {
|
|
11
|
-
#nodes = /* @__PURE__ */ new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Add node to middleware group.
|
|
14
|
-
* @param name - The name of the middleware group.
|
|
15
|
-
* @param node - The node to add.
|
|
16
|
-
*/
|
|
17
|
-
addNode(middleware, node) {
|
|
18
|
-
this.#nodes.set(middleware.name, [...this.#nodes.get(middleware.name) ?? [], node]);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the state of a middleware group.
|
|
22
|
-
* @param name - The name of the middleware group.
|
|
23
|
-
* @returns The state of the middleware group.
|
|
24
|
-
*/
|
|
25
|
-
getState(name) {
|
|
26
|
-
const state = (this.#nodes.get(name) ?? []).reduce((prev, node) => {
|
|
27
|
-
return {
|
|
28
|
-
...prev,
|
|
29
|
-
...node.getState() ?? {}
|
|
30
|
-
};
|
|
31
|
-
}, {});
|
|
32
|
-
/**
|
|
33
|
-
* we internally reset the jumpTo property and shouldn't propagate this value
|
|
34
|
-
* to the middleware hooks.
|
|
35
|
-
*/
|
|
36
|
-
delete state.jumpTo;
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
exports.StateManager = StateManager;
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=state.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.cjs","names":["#nodes"],"sources":["../../src/agents/state.ts"],"sourcesContent":["import type { InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { RunnableCallable } from \"./RunnableCallable.js\";\nimport type { AgentMiddleware } from \"./middleware/types.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AgentNode = RunnableCallable<any, any>;\n\n/**\n * The StateManager is responsible for managing the state of the agent.\n * The `createAgent` maintains different nodes with their own state. For the user\n * however, they only see the combined state of all nodes. This class is helps\n * to share the state between different nodes.\n *\n * @internal\n */\nexport class StateManager {\n #nodes = new Map<string, AgentNode[]>();\n\n /**\n * Add node to middleware group.\n * @param name - The name of the middleware group.\n * @param node - The node to add.\n */\n addNode(\n middleware: AgentMiddleware<InteropZodObject | undefined>,\n node: AgentNode\n ) {\n this.#nodes.set(middleware.name, [\n ...(this.#nodes.get(middleware.name) ?? []),\n node,\n ]);\n }\n\n /**\n * Get the state of a middleware group.\n * @param name - The name of the middleware group.\n * @returns The state of the middleware group.\n */\n getState(name: string) {\n const middlewareNodes = this.#nodes.get(name) ?? [];\n const state = middlewareNodes.reduce(\n (prev, node) => {\n return {\n ...prev,\n ...((node.getState() as Record<string, unknown>) ?? {}),\n };\n },\n {} as Record<string, unknown>\n );\n\n /**\n * we internally reset the jumpTo property and shouldn't propagate this value\n * to the middleware hooks.\n */\n delete state.jumpTo;\n\n return state;\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,eAAb,MAA0B;CACxB,yBAAS,IAAI,KAA0B;;;;;;CAOvC,QACE,YACA,MACA;AACA,QAAA,MAAY,IAAI,WAAW,MAAM,CAC/B,GAAI,MAAA,MAAY,IAAI,WAAW,KAAK,IAAI,EAAE,EAC1C,KACD,CAAC;;;;;;;CAQJ,SAAS,MAAc;EAErB,MAAM,SADkB,MAAA,MAAY,IAAI,KAAK,IAAI,EAAE,EACrB,QAC3B,MAAM,SAAS;AACd,UAAO;IACL,GAAG;IACH,GAAK,KAAK,UAAU,IAAgC,EAAE;IACvD;KAEH,EAAE,CACH;;;;;AAMD,SAAO,MAAM;AAEb,SAAO"}
|
package/dist/agents/state.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//#region src/agents/state.ts
|
|
2
|
-
/**
|
|
3
|
-
* The StateManager is responsible for managing the state of the agent.
|
|
4
|
-
* The `createAgent` maintains different nodes with their own state. For the user
|
|
5
|
-
* however, they only see the combined state of all nodes. This class is helps
|
|
6
|
-
* to share the state between different nodes.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
var StateManager = class {
|
|
11
|
-
#nodes = /* @__PURE__ */ new Map();
|
|
12
|
-
/**
|
|
13
|
-
* Add node to middleware group.
|
|
14
|
-
* @param name - The name of the middleware group.
|
|
15
|
-
* @param node - The node to add.
|
|
16
|
-
*/
|
|
17
|
-
addNode(middleware, node) {
|
|
18
|
-
this.#nodes.set(middleware.name, [...this.#nodes.get(middleware.name) ?? [], node]);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Get the state of a middleware group.
|
|
22
|
-
* @param name - The name of the middleware group.
|
|
23
|
-
* @returns The state of the middleware group.
|
|
24
|
-
*/
|
|
25
|
-
getState(name) {
|
|
26
|
-
const state = (this.#nodes.get(name) ?? []).reduce((prev, node) => {
|
|
27
|
-
return {
|
|
28
|
-
...prev,
|
|
29
|
-
...node.getState() ?? {}
|
|
30
|
-
};
|
|
31
|
-
}, {});
|
|
32
|
-
/**
|
|
33
|
-
* we internally reset the jumpTo property and shouldn't propagate this value
|
|
34
|
-
* to the middleware hooks.
|
|
35
|
-
*/
|
|
36
|
-
delete state.jumpTo;
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
41
|
-
export { StateManager };
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=state.js.map
|
package/dist/agents/state.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"state.js","names":["#nodes"],"sources":["../../src/agents/state.ts"],"sourcesContent":["import type { InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { RunnableCallable } from \"./RunnableCallable.js\";\nimport type { AgentMiddleware } from \"./middleware/types.js\";\n\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\ntype AgentNode = RunnableCallable<any, any>;\n\n/**\n * The StateManager is responsible for managing the state of the agent.\n * The `createAgent` maintains different nodes with their own state. For the user\n * however, they only see the combined state of all nodes. This class is helps\n * to share the state between different nodes.\n *\n * @internal\n */\nexport class StateManager {\n #nodes = new Map<string, AgentNode[]>();\n\n /**\n * Add node to middleware group.\n * @param name - The name of the middleware group.\n * @param node - The node to add.\n */\n addNode(\n middleware: AgentMiddleware<InteropZodObject | undefined>,\n node: AgentNode\n ) {\n this.#nodes.set(middleware.name, [\n ...(this.#nodes.get(middleware.name) ?? []),\n node,\n ]);\n }\n\n /**\n * Get the state of a middleware group.\n * @param name - The name of the middleware group.\n * @returns The state of the middleware group.\n */\n getState(name: string) {\n const middlewareNodes = this.#nodes.get(name) ?? [];\n const state = middlewareNodes.reduce(\n (prev, node) => {\n return {\n ...prev,\n ...((node.getState() as Record<string, unknown>) ?? {}),\n };\n },\n {} as Record<string, unknown>\n );\n\n /**\n * we internally reset the jumpTo property and shouldn't propagate this value\n * to the middleware hooks.\n */\n delete state.jumpTo;\n\n return state;\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,eAAb,MAA0B;CACxB,yBAAS,IAAI,KAA0B;;;;;;CAOvC,QACE,YACA,MACA;AACA,QAAA,MAAY,IAAI,WAAW,MAAM,CAC/B,GAAI,MAAA,MAAY,IAAI,WAAW,KAAK,IAAI,EAAE,EAC1C,KACD,CAAC;;;;;;;CAQJ,SAAS,MAAc;EAErB,MAAM,SADkB,MAAA,MAAY,IAAI,KAAK,IAAI,EAAE,EACrB,QAC3B,MAAM,SAAS;AACd,UAAO;IACL,GAAG;IACH,GAAK,KAAK,UAAU,IAAgC,EAAE;IACvD;KAEH,EAAE,CACH;;;;;AAMD,SAAO,MAAM;AAEb,SAAO"}
|