@langchain/langgraph 1.0.0 → 1.0.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 +12 -0
- package/dist/graph/message.d.ts +2 -2
- package/dist/graph/message.d.ts.map +1 -1
- package/dist/graph/messages_annotation.d.cts +5 -5
- package/dist/graph/messages_annotation.d.cts.map +1 -1
- package/dist/graph/messages_annotation.d.ts +5 -5
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/zod/zod-registry.d.cts.map +1 -1
- package/dist/graph/zod/zod-registry.d.ts.map +1 -1
- package/dist/prebuilt/agent_executor.d.cts +5 -5
- package/dist/prebuilt/agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/agent_executor.d.ts +5 -5
- package/dist/prebuilt/agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/interrupt.d.cts +0 -12
- package/dist/prebuilt/interrupt.d.cts.map +1 -1
- package/dist/prebuilt/interrupt.d.ts +0 -12
- package/dist/prebuilt/interrupt.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts +3 -3
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +3 -3
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/tool_node.cjs +0 -3
- package/dist/prebuilt/tool_node.cjs.map +1 -1
- package/dist/prebuilt/tool_node.d.cts +0 -3
- package/dist/prebuilt/tool_node.d.cts.map +1 -1
- package/dist/prebuilt/tool_node.d.ts +0 -3
- package/dist/prebuilt/tool_node.d.ts.map +1 -1
- package/dist/prebuilt/tool_node.js +0 -3
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
package/dist/graph/message.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { StateGraph } from "./state.js";
|
|
2
2
|
import { RunnableConfig } from "@langchain/core/runnables";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _langchain_core_messages0 from "@langchain/core/messages";
|
|
4
4
|
import { BaseMessage, BaseMessageLike } from "@langchain/core/messages";
|
|
5
5
|
|
|
6
6
|
//#region src/graph/message.d.ts
|
|
@@ -34,7 +34,7 @@ declare function pushMessage(message: BaseMessage | BaseMessageLike, options?: R
|
|
|
34
34
|
* @default "messages"
|
|
35
35
|
*/
|
|
36
36
|
stateKey?: string | null;
|
|
37
|
-
}): BaseMessage<
|
|
37
|
+
}): BaseMessage<_langchain_core_messages0.MessageStructure, _langchain_core_messages0.MessageType>;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { MessageGraph, Messages, REMOVE_ALL_MESSAGES, messagesStateReducer, pushMessage };
|
|
40
40
|
//# sourceMappingURL=message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","
|
|
1
|
+
{"version":3,"file":"message.d.ts","names":["BaseMessage","BaseMessageLike","RunnableConfig","StateGraph","REMOVE_ALL_MESSAGES","Messages","Array","messagesStateReducer","MessageGraph","pushMessage","_langchain_core_messages0","MessageStructure","MessageType"],"sources":["../../src/graph/message.d.ts"],"sourcesContent":["import { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\nimport type { RunnableConfig } from \"@langchain/core/runnables\";\nimport { StateGraph } from \"./state.js\";\nexport declare const REMOVE_ALL_MESSAGES = \"__remove_all__\";\nexport type Messages = Array<BaseMessage | BaseMessageLike> | BaseMessage | BaseMessageLike;\n/**\n * Prebuilt reducer that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n */\nexport declare function messagesStateReducer(left: Messages, right: Messages): BaseMessage[];\n/** @ignore */\nexport declare class MessageGraph extends StateGraph<BaseMessage[], BaseMessage[], Messages> {\n constructor();\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 declare function pushMessage(message: BaseMessage | BaseMessageLike, 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}): BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>;\n"],"mappings":";;;;;;cAGqBI,mBAAAA;KACTC,QAAAA,GAAWC,MAAMN,cAAcC,mBAAmBD,cAAcC;;AAD5E;AACA;;;AAA2CA,iBAMnBM,oBAAAA,CANmBN,IAAAA,EAMQI,QANRJ,EAAAA,KAAAA,EAMyBI,QANzBJ,CAAAA,EAMoCD,WANpCC,EAAAA;;AAAmBD,cAQzCQ,YAAAA,SAAqBL,UARoBH,CAQTA,WARSA,EAAAA,EAQMA,WARNA,EAAAA,EAQqBK,QARrBL,CAAAA,CAAAA;aAAcC,CAAAA;;AAM5E;;;;;;AAEA;;;;;;iBAewBQ,WAAAA,UAAqBT,cAAcC,2BAA2BC;EAA9DO;;;;UAA8DP,CAAAA,EAAAA,MAAAA,GAAAA,IAAAA;IAMlFF,WANgGU,CAAAA,yBAAAA,CAMjDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CAArDD"}
|
|
@@ -3,7 +3,7 @@ import { ReducedZodChannel, SchemaMeta } from "./zod/meta.cjs";
|
|
|
3
3
|
import { AnnotationRoot } from "./annotation.cjs";
|
|
4
4
|
import { Messages } from "./message.cjs";
|
|
5
5
|
import * as _langchain_core_utils_types0 from "@langchain/core/utils/types";
|
|
6
|
-
import * as
|
|
6
|
+
import * as _langchain_core_messages1 from "@langchain/core/messages";
|
|
7
7
|
import { BaseMessage } from "@langchain/core/messages";
|
|
8
8
|
import { z } from "zod/v3";
|
|
9
9
|
|
|
@@ -45,7 +45,7 @@ import { z } from "zod/v3";
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
48
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[], Messages>;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
51
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -101,11 +101,11 @@ declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
declare const MessagesZodState: z.ZodObject<{
|
|
104
|
-
messages: ReducedZodChannel<z.ZodType<BaseMessage<
|
|
104
|
+
messages: ReducedZodChannel<z.ZodType<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[]>, _langchain_core_utils_types0.InteropZodType<Messages>>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
messages: BaseMessage<
|
|
106
|
+
messages: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[];
|
|
109
109
|
}>;
|
|
110
110
|
//#endregion
|
|
111
111
|
export { MessagesAnnotation, MessagesZodMeta, MessagesZodState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.cts","names":["
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.cts","names":["___web_js0","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","_langchain_core_messages1","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./message.js\";\nimport { SchemaMeta } from \"./zod/meta.js\";\n/**\n * Prebuilt state annotation that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n *\n * Specifically, importing and using the prebuilt MessagesAnnotation like this:\n *\n * @example\n * ```ts\n * import { MessagesAnnotation, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(...)\n * ...\n * ```\n *\n * Is equivalent to initializing your state manually like this:\n *\n * @example\n * ```ts\n * import { BaseMessage } from \"@langchain/core/messages\";\n * import { Annotation, StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n *\n * export const StateAnnotation = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * reducer: messagesStateReducer,\n * default: () => [],\n * }),\n * });\n *\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesAnnotation: import(\"./annotation.js\").AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n/**\n * Prebuilt schema meta for Zod state definition.\n *\n * @example\n * ```ts\n * import { z } from \"zod/v4-mini\";\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const AgentState = z.object({\n * messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),\n * });\n * ```\n */\nexport declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;\n/**\n * Prebuilt state object that uses Zod to combine returned messages.\n * This utility is synonymous with the `MessagesAnnotation` annotation,\n * but uses Zod as the way to express messages state.\n *\n * You can use import and use this prebuilt schema like this:\n *\n * @example\n * ```ts\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesZodState)\n * .addNode(...)\n * ...\n * ```\n *\n * Which is equivalent to initializing the schema object manually like this:\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import type { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\n * import { StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n * import \"@langchain/langgraph/zod\";\n *\n * const AgentState = z.object({\n * messages: z\n * .custom<BaseMessage[]>()\n * .default(() => [])\n * .langgraph.reducer(\n * messagesStateReducer,\n * z.custom<BaseMessageLike | BaseMessageLike[]>()\n * ),\n * });\n * const graph = new StateGraph(AgentState)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesZodState: z.ZodObject<{\n messages: import(\"./zod/meta.js\").ReducedZodChannel<z.ZodType<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>, import(\"@langchain/core/utils/types\").InteropZodType<Messages>>;\n}, \"strip\", z.ZodTypeAny, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;;;AAG6ES,cA3DxDD,kBA2D6FG,gBAAAA,CAAAA;UAApGP,yBAAAA,CA1D4CA,WA0D5CA,CAzDZK,yBAAAA,CADuGC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CA0DhJP,EAAAA,EA1DgKE,QA0DhKF,CAAAA;;;;;;;;;;;;;;;cA3COU,iBAAiBP,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CS,kBAAkBV,CAAAA,CAAEgB;8BACehB,CAAAA,CAAEY,QAAQb,YAKhEK,yBAAAA,CAL+GC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,KAAgBN,CAAAA,CAAEW,YAAYZ,YAAFK,yBAAAA,CAAiDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,MAA8ET,4BAAAA,CAAvBgB,eAAeZ;YAClWD,CAAAA,CAAEe;YACAhB,YADUK,yBAAAA,CACqCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA;;YAEpGP,YAFWK,yBAAAA,CAEoCC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA"}
|
|
@@ -2,7 +2,7 @@ import { BinaryOperatorAggregate } from "../channels/binop.js";
|
|
|
2
2
|
import { ReducedZodChannel, SchemaMeta } from "./zod/meta.js";
|
|
3
3
|
import { AnnotationRoot } from "./annotation.js";
|
|
4
4
|
import { Messages } from "./message.js";
|
|
5
|
-
import * as
|
|
5
|
+
import * as _langchain_core_messages19 from "@langchain/core/messages";
|
|
6
6
|
import { BaseMessage } from "@langchain/core/messages";
|
|
7
7
|
import * as _langchain_core_utils_types0 from "@langchain/core/utils/types";
|
|
8
8
|
import { z } from "zod/v3";
|
|
@@ -45,7 +45,7 @@ import { z } from "zod/v3";
|
|
|
45
45
|
* ```
|
|
46
46
|
*/
|
|
47
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
48
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages19.MessageStructure, _langchain_core_messages19.MessageType>[], Messages>;
|
|
49
49
|
}>;
|
|
50
50
|
/**
|
|
51
51
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -101,11 +101,11 @@ declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;
|
|
|
101
101
|
* ```
|
|
102
102
|
*/
|
|
103
103
|
declare const MessagesZodState: z.ZodObject<{
|
|
104
|
-
messages: ReducedZodChannel<z.ZodType<BaseMessage<
|
|
104
|
+
messages: ReducedZodChannel<z.ZodType<BaseMessage<_langchain_core_messages19.MessageStructure, _langchain_core_messages19.MessageType>[], z.ZodTypeDef, BaseMessage<_langchain_core_messages19.MessageStructure, _langchain_core_messages19.MessageType>[]>, _langchain_core_utils_types0.InteropZodType<Messages>>;
|
|
105
105
|
}, "strip", z.ZodTypeAny, {
|
|
106
|
-
messages: BaseMessage<
|
|
106
|
+
messages: BaseMessage<_langchain_core_messages19.MessageStructure, _langchain_core_messages19.MessageType>[];
|
|
107
107
|
}, {
|
|
108
|
-
messages: BaseMessage<
|
|
108
|
+
messages: BaseMessage<_langchain_core_messages19.MessageStructure, _langchain_core_messages19.MessageType>[];
|
|
109
109
|
}>;
|
|
110
110
|
//#endregion
|
|
111
111
|
export { MessagesAnnotation, MessagesZodMeta, MessagesZodState };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.ts","names":["
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.ts","names":["___web_js7","__annotation_js0","_langchain_core_utils_types0","__zod_meta_js0","BaseMessage","z","Messages","SchemaMeta","MessagesAnnotation","_langchain_core_messages19","MessageStructure","MessageType","BinaryOperatorAggregate","AnnotationRoot","MessagesZodMeta","MessagesZodState","ZodTypeDef","ZodType","InteropZodType","ReducedZodChannel","ZodTypeAny","ZodObject"],"sources":["../../src/graph/messages_annotation.d.ts"],"sourcesContent":["/* __LC_ALLOW_ENTRYPOINT_SIDE_EFFECTS__ */\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod/v3\";\nimport { Messages } from \"./message.js\";\nimport { SchemaMeta } from \"./zod/meta.js\";\n/**\n * Prebuilt state annotation that combines returned messages.\n * Can handle standard messages and special modifiers like {@link RemoveMessage}\n * instances.\n *\n * Specifically, importing and using the prebuilt MessagesAnnotation like this:\n *\n * @example\n * ```ts\n * import { MessagesAnnotation, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(...)\n * ...\n * ```\n *\n * Is equivalent to initializing your state manually like this:\n *\n * @example\n * ```ts\n * import { BaseMessage } from \"@langchain/core/messages\";\n * import { Annotation, StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n *\n * export const StateAnnotation = Annotation.Root({\n * messages: Annotation<BaseMessage[]>({\n * reducer: messagesStateReducer,\n * default: () => [],\n * }),\n * });\n *\n * const graph = new StateGraph(StateAnnotation)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesAnnotation: import(\"./annotation.js\").AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\n/**\n * Prebuilt schema meta for Zod state definition.\n *\n * @example\n * ```ts\n * import { z } from \"zod/v4-mini\";\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const AgentState = z.object({\n * messages: z.custom<BaseMessage[]>().register(registry, MessagesZodMeta),\n * });\n * ```\n */\nexport declare const MessagesZodMeta: SchemaMeta<BaseMessage[], Messages>;\n/**\n * Prebuilt state object that uses Zod to combine returned messages.\n * This utility is synonymous with the `MessagesAnnotation` annotation,\n * but uses Zod as the way to express messages state.\n *\n * You can use import and use this prebuilt schema like this:\n *\n * @example\n * ```ts\n * import { MessagesZodState, StateGraph } from \"@langchain/langgraph\";\n *\n * const graph = new StateGraph(MessagesZodState)\n * .addNode(...)\n * ...\n * ```\n *\n * Which is equivalent to initializing the schema object manually like this:\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import type { BaseMessage, BaseMessageLike } from \"@langchain/core/messages\";\n * import { StateGraph, messagesStateReducer } from \"@langchain/langgraph\";\n * import \"@langchain/langgraph/zod\";\n *\n * const AgentState = z.object({\n * messages: z\n * .custom<BaseMessage[]>()\n * .default(() => [])\n * .langgraph.reducer(\n * messagesStateReducer,\n * z.custom<BaseMessageLike | BaseMessageLike[]>()\n * ),\n * });\n * const graph = new StateGraph(AgentState)\n * .addNode(...)\n * ...\n * ```\n */\nexport declare const MessagesZodState: z.ZodObject<{\n messages: import(\"./zod/meta.js\").ReducedZodChannel<z.ZodType<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], z.ZodTypeDef, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[]>, import(\"@langchain/core/utils/types\").InteropZodType<Messages>>;\n}, \"strip\", z.ZodTypeAny, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}, {\n messages: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[];\n}>;\n"],"mappings":";;;;;;;;;;;;;;;;AAwCA;;;;;;;;;AAgBA;;;;;;AAwCA;;;;;;;;;;;;;;;AAG6ES,cA3DxDD,kBA2D6FG,gBAAAA,CAAAA;UAApGP,yBAAAA,CA1D4CA,WA0D5CA,CAzDZK,0BAAAA,CADuGC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,CA0DhJP,EAAAA,EA1DgKE,QA0DhKF,CAAAA;;;;;;;;;;;;;;;cA3COU,iBAAiBP,WAAWH,eAAeE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwC3CS,kBAAkBV,CAAAA,CAAEgB;8BACehB,CAAAA,CAAEY,QAAQb,YAKhEK,0BAAAA,CAL+GC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,KAAgBN,CAAAA,CAAEW,YAAYZ,YAAFK,0BAAAA,CAAiDC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,MAA8ET,4BAAAA,CAAvBgB,eAAeZ;YAClWD,CAAAA,CAAEe;YACAhB,YADUK,0BAAAA,CACqCC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA;;YAEpGP,YAFWK,0BAAAA,CAEoCC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA"}
|
|
@@ -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,CA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Registry","$replace","ReducedZodChannel","SchemaMeta","SchemaMetaRegistry","LanggraphZodMetaRegistry","Meta","Schema","S","
|
|
1
|
+
{"version":3,"file":"zod-registry.d.ts","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,EAU9FQ,CAV8FR,EAAAA,GAAAA,KAAAA,EAAAA,SAAAA,SAU/DM,IAV+DN,GAAAA;;EAiB/HS,CAAAA,GAAAA,CALQR,QAKR,CALiBK,IAKjB,GAAA;IAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;KAHME,CAOuGE,CAAAA,CAAAA,CAAAA,GAAAA,CAP/FT,QAO+F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AAA,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"}
|
|
@@ -3,7 +3,7 @@ import { StateDefinition } from "../graph/annotation.cjs";
|
|
|
3
3
|
import { CompiledStateGraph } from "../graph/state.cjs";
|
|
4
4
|
import { ToolExecutor } from "./tool_executor.cjs";
|
|
5
5
|
import { Runnable } from "@langchain/core/runnables";
|
|
6
|
-
import * as
|
|
6
|
+
import * as _langchain_core_messages17 from "@langchain/core/messages";
|
|
7
7
|
import { BaseMessage } from "@langchain/core/messages";
|
|
8
8
|
import { AgentAction, AgentFinish } from "@langchain/core/agents";
|
|
9
9
|
import { Tool } from "@langchain/core/tools";
|
|
@@ -31,22 +31,22 @@ declare function createAgentExecutor({
|
|
|
31
31
|
agentOutcome?: AgentAction | AgentFinish | undefined;
|
|
32
32
|
steps: Step[];
|
|
33
33
|
input: string;
|
|
34
|
-
chatHistory?: BaseMessage<
|
|
34
|
+
chatHistory?: BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined;
|
|
35
35
|
}, {
|
|
36
36
|
agentOutcome?: AgentAction | AgentFinish | undefined;
|
|
37
37
|
steps?: Step[] | undefined;
|
|
38
38
|
input?: string | undefined;
|
|
39
|
-
chatHistory?: BaseMessage<
|
|
39
|
+
chatHistory?: BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined;
|
|
40
40
|
}, "__start__" | "action" | "agent", {
|
|
41
41
|
agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
|
|
42
42
|
steps: BaseChannel<Step[], Step[], unknown>;
|
|
43
43
|
input: BaseChannel<string, string, unknown>;
|
|
44
|
-
chatHistory?: BaseChannel<BaseMessage<
|
|
44
|
+
chatHistory?: BaseChannel<BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined, BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined, unknown> | undefined;
|
|
45
45
|
}, {
|
|
46
46
|
agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
|
|
47
47
|
steps: BaseChannel<Step[], Step[], unknown>;
|
|
48
48
|
input: BaseChannel<string, string, unknown>;
|
|
49
|
-
chatHistory?: BaseChannel<BaseMessage<
|
|
49
|
+
chatHistory?: BaseChannel<BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined, BaseMessage<_langchain_core_messages17.MessageStructure, _langchain_core_messages17.MessageType>[] | undefined, unknown> | undefined;
|
|
50
50
|
}, StateDefinition, {
|
|
51
51
|
action: Partial<AgentExecutorState>;
|
|
52
52
|
agent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_executor.d.cts","names":["
|
|
1
|
+
{"version":3,"file":"agent_executor.d.cts","names":["___web_js6","AgentAction","AgentFinish","BaseMessage","Runnable","Tool","ToolExecutor","BaseChannel","Step","AgentExecutorState","Array","createAgentExecutor","agentRunnable","tools","_langchain_core_messages17","MessageStructure","MessageType","StateDefinition","Partial","CompiledStateGraph"],"sources":["../../src/prebuilt/agent_executor.d.ts"],"sourcesContent":["import { AgentAction, AgentFinish } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport type { BaseChannel } from \"../channels/base.js\";\ninterface Step {\n action: AgentAction | AgentFinish;\n observation: unknown;\n}\n/** @ignore */\nexport interface AgentExecutorState {\n agentOutcome?: AgentAction | AgentFinish;\n steps: Array<Step>;\n input: string;\n chatHistory?: BaseMessage[];\n}\n/** @ignore */\nexport declare function createAgentExecutor({ agentRunnable, tools }: {\n agentRunnable: Runnable;\n tools: Array<Tool> | ToolExecutor;\n}): import(\"../web.js\").CompiledStateGraph<{\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps: Step[];\n input: string;\n chatHistory?: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined;\n}, {\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps?: Step[] | undefined;\n input?: string | undefined;\n chatHistory?: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined;\n}, \"__start__\" | \"action\" | \"agent\", {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, unknown> | undefined;\n}, {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, unknown> | undefined;\n}, import(\"../web.js\").StateDefinition, {\n action: Partial<AgentExecutorState>;\n agent: {\n agentOutcome: any;\n };\n}, unknown, unknown>;\nexport {};\n"],"mappings":";;;;;;;;;;;UAMUQ,IAAAA;UACEP,cAAcC;;;;AADhBM,UAKOC,kBAAAA,CALH;EAAA,YAAA,CAAA,EAMKR,WANL,GAMmBC,WANnB;OACFD,EAMDS,KANCT,CAMKO,IANLP,CAAAA;OAAcC,EAAAA,MAAAA;gBAQRC;AAJlB;;AACmBF,iBAMKU,mBAAAA,CANLV;EAAAA,aAAAA;EAAAA;CAAAA,EAAAA;eAAcC,EAOdE,QAPcF;OAChBM,EAONE,KAPMF,CAOAH,IAPAG,CAAAA,GAOQF,YAPRE;sBAANE,CAAAA;cAEOP,CAAAA,EAOCF,WAPDE,GAOeD,WAPfC,GAAAA,SAAAA;SAQPK;EALaG,KAAAA,EAAAA,MAAAA;EAAmB,WAAA,CAAA,EAOzBR,WAPyB,CAK5BW,0BAAAA,CAEkDC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,CAP3E,EAAA,GAAA,SAAA;;cAAkBH,CAAAA,EAS1CZ,WAT0CY,GAS5BX,WAT4BW,GAAAA,SAAAA;OAC1CT,CAAAA,E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A,CACuDC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,CAZtHR,EAAAA,GAAAA,SAAAA,EAYkJL,WAZlJK,CAY6BM,0BAAAA,CAAoKC,gBAAAA,EAAgBD,0BAAAA,CAAqCE,WAAAA,CAZtPR,EAAAA,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;oBAEqDO;QAAgBD,EAYrEI,OAZqEJ,CAY7DL,kBAZkGO,CAAAA;OAApGb,EAAAA;IAEaF,YAAAA,EAAAA,GAAAA;;UAAuCA,EAAAA,OAAAA,CAAAA"}
|
|
@@ -3,7 +3,7 @@ import { StateDefinition } from "../graph/annotation.js";
|
|
|
3
3
|
import { CompiledStateGraph } from "../graph/state.js";
|
|
4
4
|
import { ToolExecutor } from "./tool_executor.js";
|
|
5
5
|
import { Runnable } from "@langchain/core/runnables";
|
|
6
|
-
import * as
|
|
6
|
+
import * as _langchain_core_messages1 from "@langchain/core/messages";
|
|
7
7
|
import { BaseMessage } from "@langchain/core/messages";
|
|
8
8
|
import { AgentAction, AgentFinish } from "@langchain/core/agents";
|
|
9
9
|
import { Tool } from "@langchain/core/tools";
|
|
@@ -31,22 +31,22 @@ declare function createAgentExecutor({
|
|
|
31
31
|
agentOutcome?: AgentAction | AgentFinish | undefined;
|
|
32
32
|
steps: Step[];
|
|
33
33
|
input: string;
|
|
34
|
-
chatHistory?: BaseMessage<
|
|
34
|
+
chatHistory?: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined;
|
|
35
35
|
}, {
|
|
36
36
|
agentOutcome?: AgentAction | AgentFinish | undefined;
|
|
37
37
|
steps?: Step[] | undefined;
|
|
38
38
|
input?: string | undefined;
|
|
39
|
-
chatHistory?: BaseMessage<
|
|
39
|
+
chatHistory?: BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined;
|
|
40
40
|
}, "__start__" | "action" | "agent", {
|
|
41
41
|
agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
|
|
42
42
|
steps: BaseChannel<Step[], Step[], unknown>;
|
|
43
43
|
input: BaseChannel<string, string, unknown>;
|
|
44
|
-
chatHistory?: BaseChannel<BaseMessage<
|
|
44
|
+
chatHistory?: BaseChannel<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined, BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined, unknown> | undefined;
|
|
45
45
|
}, {
|
|
46
46
|
agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;
|
|
47
47
|
steps: BaseChannel<Step[], Step[], unknown>;
|
|
48
48
|
input: BaseChannel<string, string, unknown>;
|
|
49
|
-
chatHistory?: BaseChannel<BaseMessage<
|
|
49
|
+
chatHistory?: BaseChannel<BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined, BaseMessage<_langchain_core_messages1.MessageStructure, _langchain_core_messages1.MessageType>[] | undefined, unknown> | undefined;
|
|
50
50
|
}, StateDefinition, {
|
|
51
51
|
action: Partial<AgentExecutorState>;
|
|
52
52
|
agent: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent_executor.d.ts","names":["___web_js0","AgentAction","AgentFinish","BaseMessage","Runnable","Tool","ToolExecutor","BaseChannel","Step","AgentExecutorState","Array","createAgentExecutor","agentRunnable","tools","
|
|
1
|
+
{"version":3,"file":"agent_executor.d.ts","names":["___web_js0","AgentAction","AgentFinish","BaseMessage","Runnable","Tool","ToolExecutor","BaseChannel","Step","AgentExecutorState","Array","createAgentExecutor","agentRunnable","tools","_langchain_core_messages1","MessageStructure","MessageType","StateDefinition","Partial","CompiledStateGraph"],"sources":["../../src/prebuilt/agent_executor.d.ts"],"sourcesContent":["import { AgentAction, AgentFinish } from \"@langchain/core/agents\";\nimport { BaseMessage } from \"@langchain/core/messages\";\nimport { Runnable } from \"@langchain/core/runnables\";\nimport { Tool } from \"@langchain/core/tools\";\nimport { ToolExecutor } from \"./tool_executor.js\";\nimport type { BaseChannel } from \"../channels/base.js\";\ninterface Step {\n action: AgentAction | AgentFinish;\n observation: unknown;\n}\n/** @ignore */\nexport interface AgentExecutorState {\n agentOutcome?: AgentAction | AgentFinish;\n steps: Array<Step>;\n input: string;\n chatHistory?: BaseMessage[];\n}\n/** @ignore */\nexport declare function createAgentExecutor({ agentRunnable, tools }: {\n agentRunnable: Runnable;\n tools: Array<Tool> | ToolExecutor;\n}): import(\"../web.js\").CompiledStateGraph<{\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps: Step[];\n input: string;\n chatHistory?: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined;\n}, {\n agentOutcome?: AgentAction | AgentFinish | undefined;\n steps?: Step[] | undefined;\n input?: string | undefined;\n chatHistory?: BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined;\n}, \"__start__\" | \"action\" | \"agent\", {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, unknown> | undefined;\n}, {\n agentOutcome?: BaseChannel<AgentAction | AgentFinish | undefined, AgentAction | AgentFinish | undefined, unknown> | undefined;\n steps: BaseChannel<Step[], Step[], unknown>;\n input: BaseChannel<string, string, unknown>;\n chatHistory?: BaseChannel<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[] | undefined, unknown> | undefined;\n}, import(\"../web.js\").StateDefinition, {\n action: Partial<AgentExecutorState>;\n agent: {\n agentOutcome: any;\n };\n}, unknown, unknown>;\nexport {};\n"],"mappings":";;;;;;;;;;;UAMUQ,IAAAA;UACEP,cAAcC;;;;AADhBM,UAKOC,kBAAAA,CALH;EAAA,YAAA,CAAA,EAMKR,WANL,GAMmBC,WANnB;OACFD,EAMDS,KANCT,CAMKO,IANLP,CAAAA;OAAcC,EAAAA,MAAAA;gBAQRC;AAJlB;;AACmBF,iBAMKU,mBAAAA,CANLV;EAAAA,aAAAA;EAAAA;CAAAA,EAAAA;eAAcC,EAOdE,QAPcF;OAChBM,EAONE,KAPMF,CAOAH,IAPAG,CAAAA,GAOQF,YAPRE;sBAANE,CAAAA;cAEOP,CAAAA,EAOCF,WAPDE,GAOeD,WAPfC,GAAAA,SAAAA;SAQPK;EALaG,KAAAA,EAAAA,MAAAA;EAAmB,WAAA,CAAA,EAOzBR,WAPyB,CAK5BW,yBAAAA,CAEkDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CAP3E,EAAA,GAAA,SAAA;;cAAkBH,CAAAA,EAS1CZ,WAT0CY,GAS5BX,WAT4BW,GAAAA,SAAAA;OAC1CT,CAAAA,EASPI,IATOJ,EAAAA,GAAAA,SAAAA;OACFC,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;aAANK,CAAAA,EAUOP,WAVPO,CAQKI,yBAAAA,CAEiDC,gBAAAA,EAAgBD,yBAAAA,CAAqCE,WAAAA,CAV3GN,EAAAA,GAAAA,SAAAA;cAAcJ,GAAAA,QAAAA,GAAAA,OAAAA,EAAAA;cAENL,CAAAA,EAUAM,WAVAN,CAUYA,WAVZA,GAU0BC,WAV1BD,GAAAA,SAAAA,EAUmDA,WAVnDA,GAUiEC,WAVjED,GAAAA,SAAAA,EAAAA,OAAAA,CAAAA,GAAAA,SAAAA;OAAcC,E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Configuration interface that defines what actions are allowed for a human interrupt.
|
|
4
4
|
* This controls the available interaction options when the graph is paused for human input.
|
|
5
5
|
*
|
|
6
|
-
* @deprecated Use `HumanInterruptConfig` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
7
|
-
* Update your import to `import { HumanInterruptConfig } from "langchain";`
|
|
8
|
-
*
|
|
9
6
|
* @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step
|
|
10
7
|
* @property {boolean} allow_respond - Whether the human can provide a text response/feedback
|
|
11
8
|
* @property {boolean} allow_edit - Whether the human can edit the provided content/state
|
|
@@ -21,9 +18,6 @@ interface HumanInterruptConfig {
|
|
|
21
18
|
* Represents a request for human action within the graph execution.
|
|
22
19
|
* Contains the action type and any associated arguments needed for the action.
|
|
23
20
|
*
|
|
24
|
-
* @deprecated Use `ActionRequest` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
25
|
-
* Update your import to `import { ActionRequest } from "langchain/prebuilt/interrupt";`
|
|
26
|
-
*
|
|
27
21
|
* @property {string} action - The type or name of action being requested (e.g., "Approve XYZ action")
|
|
28
22
|
* @property {Record<string, any>} args - Key-value pairs of arguments needed for the action
|
|
29
23
|
*/
|
|
@@ -36,9 +30,6 @@ interface ActionRequest {
|
|
|
36
30
|
* Represents an interrupt triggered by the graph that requires human intervention.
|
|
37
31
|
* This is passed to the `interrupt` function when execution is paused for human input.
|
|
38
32
|
*
|
|
39
|
-
* @deprecated Use `HumanInterrupt` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
40
|
-
* Update your import to `import { HumanInterrupt } from "langchain/prebuilt/interrupt";`
|
|
41
|
-
*
|
|
42
33
|
* @property {ActionRequest} action_request - The specific action being requested from the human
|
|
43
34
|
* @property {HumanInterruptConfig} config - Configuration defining what actions are allowed
|
|
44
35
|
* @property {string} [description] - Optional detailed description of what input is needed
|
|
@@ -51,9 +42,6 @@ interface HumanInterrupt {
|
|
|
51
42
|
/**
|
|
52
43
|
* The response provided by a human to an interrupt, which is returned when graph execution resumes.
|
|
53
44
|
*
|
|
54
|
-
* @deprecated Use `HumanResponse` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
55
|
-
* Update your import to `import { HumanResponse } from "langchain/prebuilt/interrupt";`
|
|
56
|
-
*
|
|
57
45
|
* @property {("accept"|"ignore"|"response"|"edit")} type - The type of response:
|
|
58
46
|
* - "accept": Approves the current state without changes
|
|
59
47
|
* - "ignore": Skips/ignores the current step
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.d.cts","names":["HumanInterruptConfig","ActionRequest","Record","HumanInterrupt","HumanResponse"],"sources":["../../src/prebuilt/interrupt.d.ts"],"sourcesContent":["/**\n * Configuration interface that defines what actions are allowed for a human interrupt.\n * This controls the available interaction options when the graph is paused for human input.\n *\n * @
|
|
1
|
+
{"version":3,"file":"interrupt.d.cts","names":["HumanInterruptConfig","ActionRequest","Record","HumanInterrupt","HumanResponse"],"sources":["../../src/prebuilt/interrupt.d.ts"],"sourcesContent":["/**\n * Configuration interface that defines what actions are allowed for a human interrupt.\n * This controls the available interaction options when the graph is paused for human input.\n *\n * @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step\n * @property {boolean} allow_respond - Whether the human can provide a text response/feedback\n * @property {boolean} allow_edit - Whether the human can edit the provided content/state\n * @property {boolean} allow_accept - Whether the human can accept/approve the current state\n */\nexport interface HumanInterruptConfig {\n allow_ignore: boolean;\n allow_respond: boolean;\n allow_edit: boolean;\n allow_accept: boolean;\n}\n/**\n * Represents a request for human action within the graph execution.\n * Contains the action type and any associated arguments needed for the action.\n *\n * @property {string} action - The type or name of action being requested (e.g., \"Approve XYZ action\")\n * @property {Record<string, any>} args - Key-value pairs of arguments needed for the action\n */\nexport interface ActionRequest {\n action: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: Record<string, any>;\n}\n/**\n * Represents an interrupt triggered by the graph that requires human intervention.\n * This is passed to the `interrupt` function when execution is paused for human input.\n *\n * @property {ActionRequest} action_request - The specific action being requested from the human\n * @property {HumanInterruptConfig} config - Configuration defining what actions are allowed\n * @property {string} [description] - Optional detailed description of what input is needed\n */\nexport interface HumanInterrupt {\n action_request: ActionRequest;\n config: HumanInterruptConfig;\n description?: string;\n}\n/**\n * The response provided by a human to an interrupt, which is returned when graph execution resumes.\n *\n * @property {(\"accept\"|\"ignore\"|\"response\"|\"edit\")} type - The type of response:\n * - \"accept\": Approves the current state without changes\n * - \"ignore\": Skips/ignores the current step\n * - \"response\": Provides text feedback or instructions\n * - \"edit\": Modifies the current state/content\n * @property {null|string|ActionRequest} args - The response payload:\n * - null: For ignore/accept actions\n * - string: For text responses\n * - ActionRequest: For edit actions with updated content\n */\nexport type HumanResponse = {\n type: \"accept\" | \"ignore\" | \"response\" | \"edit\";\n args: null | string | ActionRequest;\n};\n"],"mappings":";;AASA;AAaA;AAaA;;;;;AAkBA;UA5CiBA,oBAAAA;;;;;;;;;;;;;UAaAC,aAAAA;;;QAGPC;;;;;;;;;;UAUOC,cAAAA;kBACGF;UACRD;;;;;;;;;;;;;;;;KAgBAI,aAAAA;;wBAEcH"}
|
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
* Configuration interface that defines what actions are allowed for a human interrupt.
|
|
4
4
|
* This controls the available interaction options when the graph is paused for human input.
|
|
5
5
|
*
|
|
6
|
-
* @deprecated Use `HumanInterruptConfig` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
7
|
-
* Update your import to `import { HumanInterruptConfig } from "langchain";`
|
|
8
|
-
*
|
|
9
6
|
* @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step
|
|
10
7
|
* @property {boolean} allow_respond - Whether the human can provide a text response/feedback
|
|
11
8
|
* @property {boolean} allow_edit - Whether the human can edit the provided content/state
|
|
@@ -21,9 +18,6 @@ interface HumanInterruptConfig {
|
|
|
21
18
|
* Represents a request for human action within the graph execution.
|
|
22
19
|
* Contains the action type and any associated arguments needed for the action.
|
|
23
20
|
*
|
|
24
|
-
* @deprecated Use `ActionRequest` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
25
|
-
* Update your import to `import { ActionRequest } from "langchain/prebuilt/interrupt";`
|
|
26
|
-
*
|
|
27
21
|
* @property {string} action - The type or name of action being requested (e.g., "Approve XYZ action")
|
|
28
22
|
* @property {Record<string, any>} args - Key-value pairs of arguments needed for the action
|
|
29
23
|
*/
|
|
@@ -36,9 +30,6 @@ interface ActionRequest {
|
|
|
36
30
|
* Represents an interrupt triggered by the graph that requires human intervention.
|
|
37
31
|
* This is passed to the `interrupt` function when execution is paused for human input.
|
|
38
32
|
*
|
|
39
|
-
* @deprecated Use `HumanInterrupt` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
40
|
-
* Update your import to `import { HumanInterrupt } from "langchain/prebuilt/interrupt";`
|
|
41
|
-
*
|
|
42
33
|
* @property {ActionRequest} action_request - The specific action being requested from the human
|
|
43
34
|
* @property {HumanInterruptConfig} config - Configuration defining what actions are allowed
|
|
44
35
|
* @property {string} [description] - Optional detailed description of what input is needed
|
|
@@ -51,9 +42,6 @@ interface HumanInterrupt {
|
|
|
51
42
|
/**
|
|
52
43
|
* The response provided by a human to an interrupt, which is returned when graph execution resumes.
|
|
53
44
|
*
|
|
54
|
-
* @deprecated Use `HumanResponse` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
55
|
-
* Update your import to `import { HumanResponse } from "langchain/prebuilt/interrupt";`
|
|
56
|
-
*
|
|
57
45
|
* @property {("accept"|"ignore"|"response"|"edit")} type - The type of response:
|
|
58
46
|
* - "accept": Approves the current state without changes
|
|
59
47
|
* - "ignore": Skips/ignores the current step
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.d.ts","names":["HumanInterruptConfig","ActionRequest","Record","HumanInterrupt","HumanResponse"],"sources":["../../src/prebuilt/interrupt.d.ts"],"sourcesContent":["/**\n * Configuration interface that defines what actions are allowed for a human interrupt.\n * This controls the available interaction options when the graph is paused for human input.\n *\n * @
|
|
1
|
+
{"version":3,"file":"interrupt.d.ts","names":["HumanInterruptConfig","ActionRequest","Record","HumanInterrupt","HumanResponse"],"sources":["../../src/prebuilt/interrupt.d.ts"],"sourcesContent":["/**\n * Configuration interface that defines what actions are allowed for a human interrupt.\n * This controls the available interaction options when the graph is paused for human input.\n *\n * @property {boolean} allow_ignore - Whether the human can choose to ignore/skip the current step\n * @property {boolean} allow_respond - Whether the human can provide a text response/feedback\n * @property {boolean} allow_edit - Whether the human can edit the provided content/state\n * @property {boolean} allow_accept - Whether the human can accept/approve the current state\n */\nexport interface HumanInterruptConfig {\n allow_ignore: boolean;\n allow_respond: boolean;\n allow_edit: boolean;\n allow_accept: boolean;\n}\n/**\n * Represents a request for human action within the graph execution.\n * Contains the action type and any associated arguments needed for the action.\n *\n * @property {string} action - The type or name of action being requested (e.g., \"Approve XYZ action\")\n * @property {Record<string, any>} args - Key-value pairs of arguments needed for the action\n */\nexport interface ActionRequest {\n action: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n args: Record<string, any>;\n}\n/**\n * Represents an interrupt triggered by the graph that requires human intervention.\n * This is passed to the `interrupt` function when execution is paused for human input.\n *\n * @property {ActionRequest} action_request - The specific action being requested from the human\n * @property {HumanInterruptConfig} config - Configuration defining what actions are allowed\n * @property {string} [description] - Optional detailed description of what input is needed\n */\nexport interface HumanInterrupt {\n action_request: ActionRequest;\n config: HumanInterruptConfig;\n description?: string;\n}\n/**\n * The response provided by a human to an interrupt, which is returned when graph execution resumes.\n *\n * @property {(\"accept\"|\"ignore\"|\"response\"|\"edit\")} type - The type of response:\n * - \"accept\": Approves the current state without changes\n * - \"ignore\": Skips/ignores the current step\n * - \"response\": Provides text feedback or instructions\n * - \"edit\": Modifies the current state/content\n * @property {null|string|ActionRequest} args - The response payload:\n * - null: For ignore/accept actions\n * - string: For text responses\n * - ActionRequest: For edit actions with updated content\n */\nexport type HumanResponse = {\n type: \"accept\" | \"ignore\" | \"response\" | \"edit\";\n args: null | string | ActionRequest;\n};\n"],"mappings":";;AASA;AAaA;AAaA;;;;;AAkBA;UA5CiBA,oBAAAA;;;;;;;;;;;;;UAaAC,aAAAA;;;QAGPC;;;;;;;;;;UAUOC,cAAAA;kBACGF;UACRD;;;;;;;;;;;;;;;;KAgBAI,aAAAA;;wBAEcH"}
|
|
@@ -11,7 +11,7 @@ import { ToolNode } from "./tool_node.cjs";
|
|
|
11
11
|
import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
12
12
|
import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
|
|
13
13
|
import { Runnable, RunnableBinding, RunnableLike, RunnableToolLike } from "@langchain/core/runnables";
|
|
14
|
-
import * as
|
|
14
|
+
import * as _langchain_core_messages11 from "@langchain/core/messages";
|
|
15
15
|
import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
|
|
16
16
|
import { DynamicTool, StructuredToolInterface } from "@langchain/core/tools";
|
|
17
17
|
import { LanguageModelLike } from "@langchain/core/language_models/base";
|
|
@@ -50,7 +50,7 @@ type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => Ba
|
|
|
50
50
|
declare const createReactAgentAnnotation: <
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
52
|
T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
53
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
53
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages11.MessageStructure, _langchain_core_messages11.MessageType>[], Messages>;
|
|
54
54
|
structuredResponse: {
|
|
55
55
|
(): LastValue<T>;
|
|
56
56
|
(annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
|
|
@@ -58,7 +58,7 @@ T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
|
58
58
|
};
|
|
59
59
|
}>;
|
|
60
60
|
declare const PreHookAnnotation: AnnotationRoot<{
|
|
61
|
-
llmInputMessages: BinaryOperatorAggregate<BaseMessage<
|
|
61
|
+
llmInputMessages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages11.MessageStructure, _langchain_core_messages11.MessageType>[], Messages>;
|
|
62
62
|
}>;
|
|
63
63
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_agent_executor.d.cts","names":["_langchain_core_messages13","_langchain_core_language_models_chat_models0","___web_js1","BaseChatModel","LanguageModelLike","BaseMessage","BaseMessageLike","SystemMessage","Runnable","RunnableToolLike","RunnableSequence","RunnableBinding","RunnableLike","DynamicTool","StructuredToolInterface","InteropZodObject","InteropZodType","All","BaseCheckpointSaver","BaseStore","CompiledStateGraph","AnnotationRoot","MessagesAnnotation","ToolNode","LangGraphRunnableConfig","Runtime","Messages","START","InteropZodToStateDefinition","AgentState","Record","StructuredResponseType","N","StructuredResponseSchemaOptions","ServerTool","ClientTool","ConfigurableModelInterface","Promise","_shouldBindTools","_bindTools","_langchain_core_language_models_base0","BaseLanguageModelInput","MessageStructure","AIMessageChunk","BaseChatModelCallOptions","_getModel","Prompt","State","StateModifier","MessageModifier","createReactAgentAnnotation","MessageType","BinaryOperatorAggregate","T","LastValue","SingleReducer","StateDefinition","S","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","A","CreateReactAgentParams","C","createReactAgent","StructuredResponseFormat","spec","ReturnType"],"sources":["../../src/prebuilt/react_agent_executor.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { BaseMessage, BaseMessageLike, SystemMessage } from \"@langchain/core/messages\";\nimport { Runnable, RunnableToolLike, RunnableSequence, RunnableBinding, type RunnableLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { type CompiledStateGraph, AnnotationRoot } from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Messages } from \"../graph/message.js\";\nimport { START } from \"../constants.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\nexport type N = typeof START | \"agent\" | \"tools\";\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n strict?: boolean;\n [key: string]: unknown;\n};\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\nexport declare function _shouldBindTools(llm: LanguageModelLike, tools: (ClientTool | ServerTool)[]): Promise<boolean>;\nexport declare function _bindTools(llm: LanguageModelLike, toolClasses: (ClientTool | ServerTool)[]): Promise<Runnable<import(\"@langchain/core/language_models/base\").BaseLanguageModelInput, import(\"@langchain/core/messages\").AIMessageChunk<import(\"@langchain/core/messages\").MessageStructure>, import(\"@langchain/core/language_models/chat_models\").BaseChatModelCallOptions> | RunnableBinding<any, any, any> | RunnableSequence<any, any>>;\nexport declare function _getModel(llm: LanguageModelLike | ConfigurableModelInterface): Promise<LanguageModelLike>;\nexport type Prompt = SystemMessage | string | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => BaseMessageLike[]) | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => Promise<BaseMessageLike[]>) | Runnable;\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;\nexport declare const createReactAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n structuredResponse: {\n (): import(\"../web.js\").LastValue<T>;\n (annotation: import(\"../web.js\").SingleReducer<T, T>): import(\"../web.js\").BinaryOperatorAggregate<T, T>;\n Root: <S extends import(\"../web.js\").StateDefinition>(sd: S) => AnnotationRoot<S>;\n };\n}>;\ndeclare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\ntype PreHookAnnotation = typeof PreHookAnnotation;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm: LanguageModelLike | ((state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike);\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: InteropZodType<StructuredResponseType> | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n \n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"], LangGraphRunnableConfig>;\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], LangGraphRunnableConfig>;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport declare function createReactAgent<A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseFormat extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<A, StructuredResponseFormat, C>): CompiledStateGraph<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"], ReturnType<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,GAAAA,CAAAA;;;;MAGVb,CAAAA,EAAAA,MAAAA;;;;;aAqBLW,CAAAA,EAAAA,MAAAA,GAAAA,SAAAA;;;;;;;kBAsBYlB,CAAAA,EAAAA,QAAAA,GAAAA,SAAAA;;;;;cAK2EY,CAAAA,EAL3EZ,YAK2EY,CAL9DoC,gBAK8DpC,CAL7CqC,CAK6CrC,CAAAA,CAAAA,OAAAA,CAAAA,GAL/BkC,iBAK+BlC,CAAAA,OAAAA,CAAAA,EALHoC,gBAKGpC,CALcqC,CAKdrC,CAAAA,CAAAA,QAAAA,CAAAA,GAL6BkC,iBAK7BlC,CAAAA,QAAAA,CAAAA,EAL0DA,uBAK1DA,CAAAA;;;AA2D9F;;eAAmDmC,CAAAA,EA3D/B/C,YA2D+B+C,CA3DlBC,gBA2DkBD,CA3DDE,CA2DCF,CAAAA,CAAAA,OAAAA,CAAAA,EA3DYC,gBA2DZD,CA3D6BE,CA2D7BF,CAAAA,CAAAA,QAAAA,CAAAA,EA3D2CnC,uBA2D3CmC,CAAAA;;;;;;;;;;;;SAEkME,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAF7NG,2BAA2BL,oBAAoB5C,0BAA0BO;;iCAEhEQ,sBAAsBA,+BAA+B6B,oBAAoB5C,mBAAmB4C,2BAA2BG,uBAAuBD,GAAGI,0BAA0BF,KAAK3C,mBAAmBwC,iBAAiBC,aAAaD,iBAAiBC;;YAEvQvC,kBAAAA,CAAmB4C,OAAON,iBAAiBC,YAAYM,kBAAkBjB,2BAA2Be,qCAAqCL,iBAAiBC"}
|
|
1
|
+
{"version":3,"file":"react_agent_executor.d.cts","names":["_langchain_core_messages11","_langchain_core_language_models_chat_models0","___web_js0","BaseChatModel","LanguageModelLike","BaseMessage","BaseMessageLike","SystemMessage","Runnable","RunnableToolLike","RunnableSequence","RunnableBinding","RunnableLike","DynamicTool","StructuredToolInterface","InteropZodObject","InteropZodType","All","BaseCheckpointSaver","BaseStore","CompiledStateGraph","AnnotationRoot","MessagesAnnotation","ToolNode","LangGraphRunnableConfig","Runtime","Messages","START","InteropZodToStateDefinition","AgentState","Record","StructuredResponseType","N","StructuredResponseSchemaOptions","ServerTool","ClientTool","ConfigurableModelInterface","Promise","_shouldBindTools","_bindTools","_langchain_core_language_models_base0","BaseLanguageModelInput","MessageStructure","AIMessageChunk","BaseChatModelCallOptions","_getModel","Prompt","State","StateModifier","MessageModifier","createReactAgentAnnotation","MessageType","BinaryOperatorAggregate","T","LastValue","SingleReducer","StateDefinition","S","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","A","CreateReactAgentParams","C","createReactAgent","StructuredResponseFormat","spec","ReturnType"],"sources":["../../src/prebuilt/react_agent_executor.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { BaseMessage, BaseMessageLike, SystemMessage } from \"@langchain/core/messages\";\nimport { Runnable, RunnableToolLike, RunnableSequence, RunnableBinding, type RunnableLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { type CompiledStateGraph, AnnotationRoot } from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Messages } from \"../graph/message.js\";\nimport { START } from \"../constants.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\nexport type N = typeof START | \"agent\" | \"tools\";\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n strict?: boolean;\n [key: string]: unknown;\n};\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\nexport declare function _shouldBindTools(llm: LanguageModelLike, tools: (ClientTool | ServerTool)[]): Promise<boolean>;\nexport declare function _bindTools(llm: LanguageModelLike, toolClasses: (ClientTool | ServerTool)[]): Promise<Runnable<import(\"@langchain/core/language_models/base\").BaseLanguageModelInput, import(\"@langchain/core/messages\").AIMessageChunk<import(\"@langchain/core/messages\").MessageStructure>, import(\"@langchain/core/language_models/chat_models\").BaseChatModelCallOptions> | RunnableBinding<any, any, any> | RunnableSequence<any, any>>;\nexport declare function _getModel(llm: LanguageModelLike | ConfigurableModelInterface): Promise<LanguageModelLike>;\nexport type Prompt = SystemMessage | string | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => BaseMessageLike[]) | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => Promise<BaseMessageLike[]>) | Runnable;\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;\nexport declare const createReactAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n structuredResponse: {\n (): import(\"../web.js\").LastValue<T>;\n (annotation: import(\"../web.js\").SingleReducer<T, T>): import(\"../web.js\").BinaryOperatorAggregate<T, T>;\n Root: <S extends import(\"../web.js\").StateDefinition>(sd: S) => AnnotationRoot<S>;\n };\n}>;\ndeclare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\ntype PreHookAnnotation = typeof PreHookAnnotation;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm: LanguageModelLike | ((state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike);\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: InteropZodType<StructuredResponseType> | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n \n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"], LangGraphRunnableConfig>;\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], LangGraphRunnableConfig>;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport declare function createReactAgent<A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseFormat extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<A, StructuredResponseFormat, C>): CompiledStateGraph<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"], ReturnType<typeof createReactAgentAnnotation<StructuredResponseFormat>>[\"spec\"] & ToAnnotationRoot<A>[\"spec\"]>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAkBiB6B;AAAjB;+BAE+BC,MAFJ,CAAA,MAAA,EAAA,GAAA,CAAA,GAE0BA,MAF1B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;UAEIA,EACjBzB,WADiByB,EAAAA;;;;;EASnBE;EACPC,kBAAAA,EAHmBF,sBAGY;;AAETA,KAHfC,CAAAA,GAGeD,OAHJJ,KAGII,GAAAA,OAAAA,GAAAA,OAAAA;KAFtBE,+BAEOjB,CAAAA,sBAAAA,CAAAA,GAAAA;;UAAAA,eAAee,0BAA0BD;EAKhDI,MAAAA,CAAAA,EAAAA,M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C,gBA2DkBD,CA3DDE,CA2DCF,CAAAA,CAAAA,OAAAA,CAAAA,EA3DYC,gBA2DZD,CA3D6BE,CA2D7BF,CAAAA,CAAAA,QAAAA,CAAAA,EA3D2CnC,uBA2D3CmC,CAAAA;;;;;;;;;;;;SAEkME,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAF7NG,2BAA2BL,oBAAoB5C,0BAA0BO;;iCAEhEQ,sBAAsBA,+BAA+B6B,oBAAoB5C,mBAAmB4C,2BAA2BG,uBAAuBD,GAAGI,0BAA0BF,KAAK3C,mBAAmBwC,iBAAiBC,aAAaD,iBAAiBC;;YAEvQvC,kBAAAA,CAAmB4C,OAAON,iBAAiBC,YAAYM,kBAAkBjB,2BAA2Be,qCAAqCL,iBAAiBC"}
|
|
@@ -10,7 +10,7 @@ import { MessagesAnnotation } from "../graph/messages_annotation.js";
|
|
|
10
10
|
import { ToolNode } from "./tool_node.js";
|
|
11
11
|
import { All, BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
12
12
|
import { Runnable, RunnableBinding, RunnableLike, RunnableSequence, RunnableToolLike } from "@langchain/core/runnables";
|
|
13
|
-
import * as
|
|
13
|
+
import * as _langchain_core_messages13 from "@langchain/core/messages";
|
|
14
14
|
import { BaseMessage, BaseMessageLike, SystemMessage } from "@langchain/core/messages";
|
|
15
15
|
import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
|
|
16
16
|
import { DynamicTool, StructuredToolInterface } from "@langchain/core/tools";
|
|
@@ -50,7 +50,7 @@ type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => Ba
|
|
|
50
50
|
declare const createReactAgentAnnotation: <
|
|
51
51
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
52
|
T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
53
|
-
messages: BinaryOperatorAggregate<BaseMessage<
|
|
53
|
+
messages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages13.MessageStructure, _langchain_core_messages13.MessageType>[], Messages>;
|
|
54
54
|
structuredResponse: {
|
|
55
55
|
(): LastValue<T>;
|
|
56
56
|
(annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
|
|
@@ -58,7 +58,7 @@ T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
|
58
58
|
};
|
|
59
59
|
}>;
|
|
60
60
|
declare const PreHookAnnotation: AnnotationRoot<{
|
|
61
|
-
llmInputMessages: BinaryOperatorAggregate<BaseMessage<
|
|
61
|
+
llmInputMessages: BinaryOperatorAggregate<BaseMessage<_langchain_core_messages13.MessageStructure, _langchain_core_messages13.MessageType>[], Messages>;
|
|
62
62
|
}>;
|
|
63
63
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_agent_executor.d.ts","names":["_langchain_core_messages23","_langchain_core_language_models_chat_models0","___web_js2","BaseChatModel","LanguageModelLike","BaseMessage","BaseMessageLike","SystemMessage","Runnable","RunnableToolLike","RunnableSequence","RunnableBinding","RunnableLike","DynamicTool","StructuredToolInterface","InteropZodObject","InteropZodType","All","BaseCheckpointSaver","BaseStore","CompiledStateGraph","AnnotationRoot","MessagesAnnotation","ToolNode","LangGraphRunnableConfig","Runtime","Messages","START","InteropZodToStateDefinition","AgentState","Record","StructuredResponseType","N","StructuredResponseSchemaOptions","ServerTool","ClientTool","ConfigurableModelInterface","Promise","_shouldBindTools","_bindTools","_langchain_core_language_models_base0","BaseLanguageModelInput","MessageStructure","AIMessageChunk","BaseChatModelCallOptions","_getModel","Prompt","State","StateModifier","MessageModifier","createReactAgentAnnotation","MessageType","BinaryOperatorAggregate","T","LastValue","SingleReducer","StateDefinition","S","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","A","CreateReactAgentParams","C","createReactAgent","StructuredResponseFormat","spec","ReturnType"],"sources":["../../src/prebuilt/react_agent_executor.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { BaseMessage, BaseMessageLike, SystemMessage } from \"@langchain/core/messages\";\nimport { Runnable, RunnableToolLike, RunnableSequence, RunnableBinding, type RunnableLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { type CompiledStateGraph, AnnotationRoot } from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Messages } from \"../graph/message.js\";\nimport { START } from \"../constants.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\nexport type N = typeof START | \"agent\" | \"tools\";\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n strict?: boolean;\n [key: string]: unknown;\n};\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\nexport declare function _shouldBindTools(llm: LanguageModelLike, tools: (ClientTool | ServerTool)[]): Promise<boolean>;\nexport declare function _bindTools(llm: LanguageModelLike, toolClasses: (ClientTool | ServerTool)[]): Promise<Runnable<import(\"@langchain/core/language_models/base\").BaseLanguageModelInput, import(\"@langchain/core/messages\").AIMessageChunk<import(\"@langchain/core/messages\").MessageStructure>, import(\"@langchain/core/language_models/chat_models\").BaseChatModelCallOptions> | RunnableBinding<any, any, any> | RunnableSequence<any, any>>;\nexport declare function _getModel(llm: LanguageModelLike | ConfigurableModelInterface): Promise<LanguageModelLike>;\nexport type Prompt = SystemMessage | string | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => BaseMessageLike[]) | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => Promise<BaseMessageLike[]>) | Runnable;\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;\nexport declare const createReactAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n structuredResponse: {\n (): import(\"../web.js\").LastValue<T>;\n (annotation: import(\"../web.js\").SingleReducer<T, T>): import(\"../web.js\").BinaryOperatorAggregate<T, T>;\n Root: <S extends import(\"../web.js\").StateDefinition>(sd: S) => AnnotationRoot<S>;\n };\n}>;\ndeclare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\ntype PreHookAnnotation = typeof PreHookAnnotation;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm: LanguageModelLike | ((state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike);\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: InteropZodType<StructuredResponseType> | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n \n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"], LangGraphRunnableConfig>;\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], LangGraphRunnableConfig>;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport declare function createReactAgent<A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseFormat extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<A, StructuredResponseFormat, C>): CompiledStateGraph<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"], ReturnType<typeof createReactAgentAnnotation<StructuredResponseFormat>>[\"spec\"] & ToAnnotationRoot<A>[\"spec\"]>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAkBiB6B;AAAjB;+BAE+BC,MAFJ,CAAA,MAAA,EAAA,GAAA,CAAA,GAE0BA,MAF1B,CAAA,MAAA,EAAA,GAAA,CAAA,CAAA,CAAA;UAEIA,EACjBzB,WADiByB,EAAAA;;;;;EASnBE;EACPC,kBAAAA,EAHmBF,sBAGY;;AAETA,KAHfC,CAAAA,GAGeD,OAHJJ,KAGII,GAAAA,OAAAA,GAAAA,OAAAA;KAFtBE,+BAEOjB,CAAAA,sBAAAA,CAAAA,GAAAA;;UAAAA,eAAee,0BAA0BD;EAKhDI,MAAAA,CAAAA,EAAAA,MAAU;EACVC,MAAAA,CAAAA,EAAAA,OAAU;EAAA,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;KADVD,UAAAA,GAAaJ,MAC0BjB,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;KAAvCsB,UAAAA,GAAarB,uBAAwCL,GAAdI,WAAcJ,GAAAA,gBAAAA;AASyIe,KAAvLsB,MAAAA,GAASvC,aAA8KiB,GAAAA,MAAAA,GAAAA,CAAAA,CAAAA,KAAAA,EAAAA,OAArIF,kBAAAA,CAAmByB,KAAkHvB,EAAAA,MAAAA,EAAnGA,uBAAmGA,EAAAA,GAAvElB,eAAuEkB,EAAAA,CAAAA,GAAAA,CA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AAaD,iBAAiBC;;YAEvQvC,kBAAAA,CAAmB4C,OAAON,iBAAiBC,YAAYM,kBAAkBjB,2BAA2Be,qCAAqCL,iBAAiBC"}
|
|
1
|
+
{"version":3,"file":"react_agent_executor.d.ts","names":["_langchain_core_messages13","_langchain_core_language_models_chat_models0","___web_js1","BaseChatModel","LanguageModelLike","BaseMessage","BaseMessageLike","SystemMessage","Runnable","RunnableToolLike","RunnableSequence","RunnableBinding","RunnableLike","DynamicTool","StructuredToolInterface","InteropZodObject","InteropZodType","All","BaseCheckpointSaver","BaseStore","CompiledStateGraph","AnnotationRoot","MessagesAnnotation","ToolNode","LangGraphRunnableConfig","Runtime","Messages","START","InteropZodToStateDefinition","AgentState","Record","StructuredResponseType","N","StructuredResponseSchemaOptions","ServerTool","ClientTool","ConfigurableModelInterface","Promise","_shouldBindTools","_bindTools","_langchain_core_language_models_base0","BaseLanguageModelInput","MessageStructure","AIMessageChunk","BaseChatModelCallOptions","_getModel","Prompt","State","StateModifier","MessageModifier","createReactAgentAnnotation","MessageType","BinaryOperatorAggregate","T","LastValue","SingleReducer","StateDefinition","S","PreHookAnnotation","AnyAnnotationRoot","ToAnnotationRoot","A","CreateReactAgentParams","C","createReactAgent","StructuredResponseFormat","spec","ReturnType"],"sources":["../../src/prebuilt/react_agent_executor.d.ts"],"sourcesContent":["import { BaseChatModel } from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport { BaseMessage, BaseMessageLike, SystemMessage } from \"@langchain/core/messages\";\nimport { Runnable, RunnableToolLike, RunnableSequence, RunnableBinding, type RunnableLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { All, BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport { type CompiledStateGraph, AnnotationRoot } from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Messages } from \"../graph/message.js\";\nimport { START } from \"../constants.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\nexport type N = typeof START | \"agent\" | \"tools\";\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n strict?: boolean;\n [key: string]: unknown;\n};\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\nexport declare function _shouldBindTools(llm: LanguageModelLike, tools: (ClientTool | ServerTool)[]): Promise<boolean>;\nexport declare function _bindTools(llm: LanguageModelLike, toolClasses: (ClientTool | ServerTool)[]): Promise<Runnable<import(\"@langchain/core/language_models/base\").BaseLanguageModelInput, import(\"@langchain/core/messages\").AIMessageChunk<import(\"@langchain/core/messages\").MessageStructure>, import(\"@langchain/core/language_models/chat_models\").BaseChatModelCallOptions> | RunnableBinding<any, any, any> | RunnableSequence<any, any>>;\nexport declare function _getModel(llm: LanguageModelLike | ConfigurableModelInterface): Promise<LanguageModelLike>;\nexport type Prompt = SystemMessage | string | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => BaseMessageLike[]) | ((state: typeof MessagesAnnotation.State, config: LangGraphRunnableConfig) => Promise<BaseMessageLike[]>) | Runnable;\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;\nexport declare const createReactAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n messages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n structuredResponse: {\n (): import(\"../web.js\").LastValue<T>;\n (annotation: import(\"../web.js\").SingleReducer<T, T>): import(\"../web.js\").BinaryOperatorAggregate<T, T>;\n Root: <S extends import(\"../web.js\").StateDefinition>(sd: S) => AnnotationRoot<S>;\n };\n}>;\ndeclare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: import(\"../web.js\").BinaryOperatorAggregate<BaseMessage<import(\"@langchain/core/messages\").MessageStructure, import(\"@langchain/core/messages\").MessageType>[], Messages>;\n}>;\ntype PreHookAnnotation = typeof PreHookAnnotation;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseType extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm: LanguageModelLike | ((state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>) => Promise<LanguageModelLike> | LanguageModelLike);\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: InteropZodType<StructuredResponseType> | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n \n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"], ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"], LangGraphRunnableConfig>;\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], LangGraphRunnableConfig>;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport declare function createReactAgent<A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nStructuredResponseFormat extends Record<string, any> = Record<string, any>, C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<A, StructuredResponseFormat, C>): CompiledStateGraph<ToAnnotationRoot<A>[\"State\"], ToAnnotationRoot<A>[\"Update\"], \n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nany, typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"], ReturnType<typeof createReactAgentAnnotation<StructuredResponseFormat>>[\"spec\"] & ToAnnotationRoot<A>[\"spec\"]>;\nexport {};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAkBiB6B;AAAjB;+BAE+BC,MAFJ,CAAA,MAAA,EAAA,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A,EAL3EZ,YAK2EY,CAL9DoC,gBAK8DpC,CAL7CqC,CAK6CrC,CAAAA,CAAAA,OAAAA,CAAAA,GAL/BkC,iBAK+BlC,CAAAA,OAAAA,CAAAA,EALHoC,gBAKGpC,CALcqC,CAKdrC,CAAAA,CAAAA,QAAAA,CAAAA,GAL6BkC,iBAK7BlC,CAAAA,QAAAA,CAAAA,EAL0DA,uBAK1DA,CAAAA;;;AA2D9F;;eAAmDmC,CAAAA,EA3D/B/C,YA2D+B+C,CA3DlBC,gBA2DkBD,CA3DDE,CA2DCF,CAAAA,CAAAA,OAAAA,CAAAA,EA3DYC,gBA2DZD,CA3D6BE,CA2D7BF,CAAAA,CAAAA,QAAAA,CAAAA,EA3D2CnC,uBA2D3CmC,CAAAA;;;;;;;;;;;;SAEkME,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAF7NG,2BAA2BL,oBAAoB5C,0BAA0BO;;iCAEhEQ,sBAAsBA,+BAA+B6B,oBAAoB5C,mBAAmB4C,2BAA2BG,uBAAuBD,GAAGI,0BAA0BF,KAAK3C,mBAAmBwC,iBAAiBC,aAAaD,iBAAiBC;;YAEvQvC,kBAAAA,CAAmB4C,OAAON,iBAAiBC,YAAYM,kBAAkBjB,2BAA2Be,qCAAqCL,iBAAiBC"}
|
|
@@ -9,9 +9,6 @@ const isBaseMessageArray = (input) => Array.isArray(input) && input.every(__lang
|
|
|
9
9
|
const isMessagesState = (input) => typeof input === "object" && input != null && "messages" in input && isBaseMessageArray(input.messages);
|
|
10
10
|
const isSendInput = (input) => typeof input === "object" && input != null && "lg_tool_call" in input;
|
|
11
11
|
/**
|
|
12
|
-
* @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
13
|
-
* Update your import to `import { ToolNode } from "langchain";`
|
|
14
|
-
*
|
|
15
12
|
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
16
13
|
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
17
14
|
* tool calls are requested, they will be run in parallel. The output will be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool_node.cjs","names":["isBaseMessage","RunnableCallable","tool","isCommand","ToolMessage","e: any","isGraphInterrupt","outputs: (ToolMessage | Command)[]","messages: BaseMessage[]","toolMessageIds: Set<string>","aiMessage: AIMessage | undefined","combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[]","parentCommand: Command | null","Command","_isSend","END"],"sources":["../../src/prebuilt/tool_node.ts"],"sourcesContent":["import {\n BaseMessage,\n ToolMessage,\n AIMessage,\n isBaseMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { isGraphInterrupt } from \"../errors.js\";\nimport { END, isCommand, Command, _isSend, Send } from \"../constants.js\";\n\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n\nconst isBaseMessageArray = (input: unknown): input is BaseMessage[] =>\n Array.isArray(input) && input.every(isBaseMessage);\n\nconst isMessagesState = (\n input: unknown\n): input is { messages: BaseMessage[] } =>\n typeof input === \"object\" &&\n input != null &&\n \"messages\" in input &&\n isBaseMessageArray(input.messages);\n\nconst isSendInput = (input: unknown): input is { lg_tool_call: ToolCall } =>\n typeof input === \"object\" && input != null && \"lg_tool_call\" in input;\n\n/**\n * @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { ToolNode } from \"langchain\";`\n *\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n\n handleToolErrors = true;\n\n trace = false;\n\n constructor(\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[],\n options?: ToolNodeOptions\n ) {\n const { name, tags, handleToolErrors } = options ?? {};\n super({ name, tags, func: (input, config) => this.run(input, config) });\n this.tools = tools;\n this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;\n }\n\n protected async runTool(\n call: ToolCall,\n config: RunnableConfig\n ): Promise<ToolMessage | Command> {\n const tool = this.tools.find((tool) => tool.name === call.name);\n try {\n if (tool === undefined) {\n throw new Error(`Tool \"${call.name}\" not found.`);\n }\n const output = await tool.invoke({ ...call, type: \"tool_call\" }, config);\n\n if (\n (isBaseMessage(output) && output.getType() === \"tool\") ||\n isCommand(output)\n ) {\n return output as ToolMessage | Command;\n }\n\n return new ToolMessage({\n status: \"success\",\n name: tool.name,\n content: typeof output === \"string\" ? output : JSON.stringify(output),\n tool_call_id: call.id!,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (!this.handleToolErrors) throw e;\n\n if (isGraphInterrupt(e)) {\n // `NodeInterrupt` errors are a breakpoint to bring a human into the loop.\n // As such, they are not recoverable by the agent and shouldn't be fed\n // back. Instead, re-throw these errors even when `handleToolErrors = true`.\n throw e;\n }\n\n return new ToolMessage({\n status: \"error\",\n content: `Error: ${e.message}\\n Please fix your mistakes.`,\n name: call.name,\n tool_call_id: call.id ?? \"\",\n });\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async run(input: unknown, config: RunnableConfig): Promise<T> {\n let outputs: (ToolMessage | Command)[];\n\n if (isSendInput(input)) {\n outputs = [await this.runTool(input.lg_tool_call, config)];\n } else {\n let messages: BaseMessage[];\n if (isBaseMessageArray(input)) {\n messages = input;\n } else if (isMessagesState(input)) {\n messages = input.messages;\n } else {\n throw new Error(\n \"ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.\"\n );\n }\n\n const toolMessageIds: Set<string> = new Set(\n messages\n .filter((msg) => msg.getType() === \"tool\")\n .map((msg) => (msg as ToolMessage).tool_call_id)\n );\n\n let aiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n aiMessage = message;\n break;\n }\n }\n\n if (aiMessage == null || !isAIMessage(aiMessage)) {\n throw new Error(\"ToolNode only accepts AIMessages as input.\");\n }\n\n outputs = await Promise.all(\n aiMessage.tool_calls\n ?.filter((call) => call.id == null || !toolMessageIds.has(call.id))\n .map((call) => this.runTool(call, config)) ?? []\n );\n }\n\n // Preserve existing behavior for non-command tool outputs for backwards compatibility\n if (!outputs.some(isCommand)) {\n return (Array.isArray(input) ? outputs : { messages: outputs }) as T;\n }\n\n // Handle mixed Command and non-Command outputs\n const combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[] = [];\n let parentCommand: Command | null = null;\n\n for (const output of outputs) {\n if (isCommand(output)) {\n if (\n output.graph === Command.PARENT &&\n Array.isArray(output.goto) &&\n output.goto.every((send) => _isSend(send))\n ) {\n if (parentCommand) {\n (parentCommand.goto as Send[]).push(...(output.goto as Send[]));\n } else {\n parentCommand = new Command({\n graph: Command.PARENT,\n goto: output.goto,\n });\n }\n } else {\n combinedOutputs.push(output);\n }\n } else {\n combinedOutputs.push(\n Array.isArray(input) ? [output] : { messages: [output] }\n );\n }\n }\n\n if (parentCommand) {\n combinedOutputs.push(parentCommand);\n }\n\n return combinedOutputs as T;\n }\n}\n\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport function toolsCondition(\n state: BaseMessage[] | typeof MessagesAnnotation.State\n): \"tools\" | typeof END {\n const message = Array.isArray(state)\n ? state[state.length - 1]\n : state.messages[state.messages.length - 1];\n\n if (\n message !== undefined &&\n \"tool_calls\" in message &&\n ((message as AIMessage).tool_calls?.length ?? 0) > 0\n ) {\n return \"tools\";\n } else {\n return END;\n }\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,sBAAsB,UAC1B,MAAM,QAAQ,UAAU,MAAM,MAAMA;AAEtC,MAAM,mBACJ,UAEA,OAAO,UAAU,YACjB,SAAS,QACT,cAAc,SACd,mBAAmB,MAAM;AAE3B,MAAM,eAAe,UACnB,OAAO,UAAU,YAAY,SAAS,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HlE,IAAa,WAAb,cAAuCC,+BAAuB;CAC5D;CAEA,mBAAmB;CAEnB,QAAQ;CAER,YACE,OACA,SACA;EACA,MAAM,EAAE,MAAM,MAAM,qBAAqB,WAAW;AACpD,QAAM;GAAE;GAA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AAGlB,aAAU,MAAM,QAAQ,IACtB,UAAU,YACN,QAAQ,SAAS,KAAK,MAAM,QAAQ,CAAC,eAAe,IAAI,KAAK,KAC9D,KAAK,SAAS,KAAK,QAAQ,MAAM,YAAY;;AAKpD,MAAI,CAAC,QAAQ,KAAKP,6BAChB,QAAQ,MAAM,QAAQ,SAAS,UAAU,EAAE,UAAU;EAIvD,MAAMQ,kBAIA;EACN,IAAIC,gBAAgC;AAEpC,OAAK,MAAM,UAAU,QACnB,KAAIT,4BAAU,QACZ,KACE,OAAO,UAAUU,0BAAQ,UACzB,MAAM,QAAQ,OAAO,SACrB,OAAO,KAAK,OAAO,SAASC,0BAAQ,OAEpC,KAAI,cACF,CAAC,cAAc,KAAgB,KAAK,GAAI,OAAO;MAE/C,iBAAgB,IAAID,0BAAQ;GAC1B,OAAOA,0BAAQ;GACf,MAAM,OAAO;;MAIjB,iBAAgB,KAAK;MAGvB,iBAAgB,KACd,MAAM,QAAQ,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;AAKrD,MAAI,cACF,iBAAgB,KAAK;AAGvB,SAAO;;;;;;AAOX,SAAgB,eACd,OACsB;CACtB,MAAM,UAAU,MAAM,QAAQ,SAC1B,MAAM,MAAM,SAAS,KACrB,MAAM,SAAS,MAAM,SAAS,SAAS;AAE3C,KACE,YAAY,UACZ,gBAAgB,YACd,QAAsB,YAAY,UAAU,KAAK,EAEnD,QAAO;KAEP,QAAOE"}
|
|
1
|
+
{"version":3,"file":"tool_node.cjs","names":["isBaseMessage","RunnableCallable","tool","isCommand","ToolMessage","e: any","isGraphInterrupt","outputs: (ToolMessage | Command)[]","messages: BaseMessage[]","toolMessageIds: Set<string>","aiMessage: AIMessage | undefined","combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[]","parentCommand: Command | null","Command","_isSend","END"],"sources":["../../src/prebuilt/tool_node.ts"],"sourcesContent":["import {\n BaseMessage,\n ToolMessage,\n AIMessage,\n isBaseMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { isGraphInterrupt } from \"../errors.js\";\nimport { END, isCommand, Command, _isSend, Send } from \"../constants.js\";\n\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n\nconst isBaseMessageArray = (input: unknown): input is BaseMessage[] =>\n Array.isArray(input) && input.every(isBaseMessage);\n\nconst isMessagesState = (\n input: unknown\n): input is { messages: BaseMessage[] } =>\n typeof input === \"object\" &&\n input != null &&\n \"messages\" in input &&\n isBaseMessageArray(input.messages);\n\nconst isSendInput = (input: unknown): input is { lg_tool_call: ToolCall } =>\n typeof input === \"object\" && input != null && \"lg_tool_call\" in input;\n\n/**\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n\n handleToolErrors = true;\n\n trace = false;\n\n constructor(\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[],\n options?: ToolNodeOptions\n ) {\n const { name, tags, handleToolErrors } = options ?? {};\n super({ name, tags, func: (input, config) => this.run(input, config) });\n this.tools = tools;\n this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;\n }\n\n protected async runTool(\n call: ToolCall,\n config: RunnableConfig\n ): Promise<ToolMessage | Command> {\n const tool = this.tools.find((tool) => tool.name === call.name);\n try {\n if (tool === undefined) {\n throw new Error(`Tool \"${call.name}\" not found.`);\n }\n const output = await tool.invoke({ ...call, type: \"tool_call\" }, config);\n\n if (\n (isBaseMessage(output) && output.getType() === \"tool\") ||\n isCommand(output)\n ) {\n return output as ToolMessage | Command;\n }\n\n return new ToolMessage({\n status: \"success\",\n name: tool.name,\n content: typeof output === \"string\" ? output : JSON.stringify(output),\n tool_call_id: call.id!,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (!this.handleToolErrors) throw e;\n\n if (isGraphInterrupt(e)) {\n // `NodeInterrupt` errors are a breakpoint to bring a human into the loop.\n // As such, they are not recoverable by the agent and shouldn't be fed\n // back. Instead, re-throw these errors even when `handleToolErrors = true`.\n throw e;\n }\n\n return new ToolMessage({\n status: \"error\",\n content: `Error: ${e.message}\\n Please fix your mistakes.`,\n name: call.name,\n tool_call_id: call.id ?? \"\",\n });\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async run(input: unknown, config: RunnableConfig): Promise<T> {\n let outputs: (ToolMessage | Command)[];\n\n if (isSendInput(input)) {\n outputs = [await this.runTool(input.lg_tool_call, config)];\n } else {\n let messages: BaseMessage[];\n if (isBaseMessageArray(input)) {\n messages = input;\n } else if (isMessagesState(input)) {\n messages = input.messages;\n } else {\n throw new Error(\n \"ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.\"\n );\n }\n\n const toolMessageIds: Set<string> = new Set(\n messages\n .filter((msg) => msg.getType() === \"tool\")\n .map((msg) => (msg as ToolMessage).tool_call_id)\n );\n\n let aiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n aiMessage = message;\n break;\n }\n }\n\n if (aiMessage == null || !isAIMessage(aiMessage)) {\n throw new Error(\"ToolNode only accepts AIMessages as input.\");\n }\n\n outputs = await Promise.all(\n aiMessage.tool_calls\n ?.filter((call) => call.id == null || !toolMessageIds.has(call.id))\n .map((call) => this.runTool(call, config)) ?? []\n );\n }\n\n // Preserve existing behavior for non-command tool outputs for backwards compatibility\n if (!outputs.some(isCommand)) {\n return (Array.isArray(input) ? outputs : { messages: outputs }) as T;\n }\n\n // Handle mixed Command and non-Command outputs\n const combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[] = [];\n let parentCommand: Command | null = null;\n\n for (const output of outputs) {\n if (isCommand(output)) {\n if (\n output.graph === Command.PARENT &&\n Array.isArray(output.goto) &&\n output.goto.every((send) => _isSend(send))\n ) {\n if (parentCommand) {\n (parentCommand.goto as Send[]).push(...(output.goto as Send[]));\n } else {\n parentCommand = new Command({\n graph: Command.PARENT,\n goto: output.goto,\n });\n }\n } else {\n combinedOutputs.push(output);\n }\n } else {\n combinedOutputs.push(\n Array.isArray(input) ? [output] : { messages: [output] }\n );\n }\n }\n\n if (parentCommand) {\n combinedOutputs.push(parentCommand);\n }\n\n return combinedOutputs as T;\n }\n}\n\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport function toolsCondition(\n state: BaseMessage[] | typeof MessagesAnnotation.State\n): \"tools\" | typeof END {\n const message = Array.isArray(state)\n ? state[state.length - 1]\n : state.messages[state.messages.length - 1];\n\n if (\n message !== undefined &&\n \"tool_calls\" in message &&\n ((message as AIMessage).tool_calls?.length ?? 0) > 0\n ) {\n return \"tools\";\n } else {\n return END;\n }\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,sBAAsB,UAC1B,MAAM,QAAQ,UAAU,MAAM,MAAMA;AAEtC,MAAM,mBACJ,UAEA,OAAO,UAAU,YACjB,SAAS,QACT,cAAc,SACd,mBAAmB,MAAM;AAE3B,MAAM,eAAe,UACnB,OAAO,UAAU,YAAY,SAAS,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHlE,IAAa,WAAb,cAAuCC,+BAAuB;CAC5D;CAEA,mBAAmB;CAEnB,QAAQ;CAER,YACE,OACA,SACA;EACA,MAAM,EAAE,MAAM,MAAM,qBAAqB,WAAW;AACpD,QAAM;GAAE;GAAM;GAAM,OAAO,OAAO,WAAW,KAAK,IAAI,OAAO;;AAC7D,OAAK,QAAQ;AACb,OAAK,mBAAmB,oBAAoB,KAAK;;CAGnD,MAAgB,QACd,MACA,QACgC;EAChC,MAAM,OAAO,KAAK,MAAM,MAAM,WAASC,OAAK,SAAS,KAAK;AAC1D,MAAI;AACF,OAAI,SAAS,OACX,OAAM,IAAI,MAAM,SAAS,KAAK,KAAK;GAErC,MAAM,SAAS,MAAM,KAAK,OAAO;IAAE,GAAG;IAAM,MAAM;MAAe;AAEjE,oDACiB,WAAW,OAAO,cAAc,UAC/CC,4BAAU,QAEV,QAAO;AAGT,UAAO,IAAIC,sCAAY;IACrB,QAAQ;IACR,MAAM,KAAK;IACX,SAAS,OAAO,WAAW,WAAW,SAAS,KAAK,UAAU;IAC9D,cAAc,KAAK;;WAGdC,GAAQ;AACf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AAM,OAAO;;MAIjB,iBAAgB,KAAK;MAGvB,iBAAgB,KACd,MAAM,QAAQ,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;AAKrD,MAAI,cACF,iBAAgB,KAAK;AAGvB,SAAO;;;;;;AAOX,SAAgB,eACd,OACsB;CACtB,MAAM,UAAU,MAAM,QAAQ,SAC1B,MAAM,MAAM,SAAS,KACrB,MAAM,SAAS,MAAM,SAAS,SAAS;AAE3C,KACE,YAAY,UACZ,gBAAgB,YACd,QAAsB,YAAY,UAAU,KAAK,EAEnD,QAAO;KAEP,QAAOE"}
|
|
@@ -13,9 +13,6 @@ type ToolNodeOptions = {
|
|
|
13
13
|
handleToolErrors?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
17
|
-
* Update your import to `import { ToolNode } from "langchain";`
|
|
18
|
-
*
|
|
19
16
|
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
20
17
|
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
21
18
|
* tool calls are requested, they will be run in parallel. The output will be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool_node.d.cts","names":["BaseMessage","ToolMessage","RunnableConfig","RunnableToolLike","DynamicTool","StructuredToolInterface","ToolCall","RunnableCallable","MessagesAnnotation","END","Command","ToolNodeOptions","ToolNode","T","Promise","toolsCondition","State"],"sources":["../../src/prebuilt/tool_node.d.ts"],"sourcesContent":["import { BaseMessage, ToolMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { END, Command } from \"../constants.js\";\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n/**\n *
|
|
1
|
+
{"version":3,"file":"tool_node.d.cts","names":["BaseMessage","ToolMessage","RunnableConfig","RunnableToolLike","DynamicTool","StructuredToolInterface","ToolCall","RunnableCallable","MessagesAnnotation","END","Command","ToolNodeOptions","ToolNode","T","Promise","toolsCondition","State"],"sources":["../../src/prebuilt/tool_node.d.ts"],"sourcesContent":["import { BaseMessage, ToolMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { END, Command } from \"../constants.js\";\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n/**\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n handleToolErrors: boolean;\n trace: boolean;\n constructor(tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[], options?: ToolNodeOptions);\n protected runTool(call: ToolCall, config: RunnableConfig): Promise<ToolMessage | Command>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected run(input: unknown, config: RunnableConfig): Promise<T>;\n}\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport declare function toolsCondition(state: BaseMessage[] | typeof MessagesAnnotation.State): \"tools\" | typeof END;\n"],"mappings":";;;;;;;;;KAOYW,eAAAA;;EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EA2HSC,gBAAQ,CAAA,EAAA,OAAA;CAAA;;;;;;;;;;;;;;;;;;;;AAY7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAZqBA,0BAA0BL,iBAAiBM,GAAGA;UACvDR,0BAA0BD,cAAcD;;;sBAG5BE,0BAA0BD,cAAcD,+BAA+BQ;0BACnEL,kBAAkBJ,iBAAiBY,QAAQb,cAAcS;;wCAE3CR,iBAAiBY,QAAQD;;;;;iBAK3CE,cAAAA,QAAsBf,uBAAuBQ,kBAAAA,CAAmBQ,yBAAyBP"}
|
|
@@ -13,9 +13,6 @@ type ToolNodeOptions = {
|
|
|
13
13
|
handleToolErrors?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
17
|
-
* Update your import to `import { ToolNode } from "langchain";`
|
|
18
|
-
*
|
|
19
16
|
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
20
17
|
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
21
18
|
* tool calls are requested, they will be run in parallel. The output will be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool_node.d.ts","names":["BaseMessage","ToolMessage","RunnableConfig","RunnableToolLike","DynamicTool","StructuredToolInterface","ToolCall","RunnableCallable","MessagesAnnotation","END","Command","ToolNodeOptions","ToolNode","T","Promise","toolsCondition","State"],"sources":["../../src/prebuilt/tool_node.d.ts"],"sourcesContent":["import { BaseMessage, ToolMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { END, Command } from \"../constants.js\";\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n/**\n *
|
|
1
|
+
{"version":3,"file":"tool_node.d.ts","names":["BaseMessage","ToolMessage","RunnableConfig","RunnableToolLike","DynamicTool","StructuredToolInterface","ToolCall","RunnableCallable","MessagesAnnotation","END","Command","ToolNodeOptions","ToolNode","T","Promise","toolsCondition","State"],"sources":["../../src/prebuilt/tool_node.d.ts"],"sourcesContent":["import { BaseMessage, ToolMessage } from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { END, Command } from \"../constants.js\";\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n/**\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport declare class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n handleToolErrors: boolean;\n trace: boolean;\n constructor(tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[], options?: ToolNodeOptions);\n protected runTool(call: ToolCall, config: RunnableConfig): Promise<ToolMessage | Command>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected run(input: unknown, config: RunnableConfig): Promise<T>;\n}\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport declare function toolsCondition(state: BaseMessage[] | typeof MessagesAnnotation.State): \"tools\" | typeof END;\n"],"mappings":";;;;;;;;;KAOYW,eAAAA;;EAAAA,IAAAA,CAAAA,EAAAA,MAAAA,EAAAA;EA2HSC,gBAAQ,CAAA,EAAA,OAAA;CAAA;;;;;;;;;;;;;;;;;;;;AAY7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAZqBA,0BAA0BL,iBAAiBM,GAAGA;UACvDR,0BAA0BD,cAAcD;;;sBAG5BE,0BAA0BD,cAAcD,+BAA+BQ;0BACnEL,kBAAkBJ,iBAAiBY,QAAQb,cAAcS;;wCAE3CR,iBAAiBY,QAAQD;;;;;iBAK3CE,cAAAA,QAAsBf,uBAAuBQ,kBAAAA,CAAmBQ,yBAAyBP"}
|
|
@@ -8,9 +8,6 @@ const isBaseMessageArray = (input) => Array.isArray(input) && input.every(isBase
|
|
|
8
8
|
const isMessagesState = (input) => typeof input === "object" && input != null && "messages" in input && isBaseMessageArray(input.messages);
|
|
9
9
|
const isSendInput = (input) => typeof input === "object" && input != null && "lg_tool_call" in input;
|
|
10
10
|
/**
|
|
11
|
-
* @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.
|
|
12
|
-
* Update your import to `import { ToolNode } from "langchain";`
|
|
13
|
-
*
|
|
14
11
|
* A node that runs the tools requested in the last AIMessage. It can be used
|
|
15
12
|
* either in StateGraph with a "messages" key or in MessageGraph. If multiple
|
|
16
13
|
* tool calls are requested, they will be run in parallel. The output will be
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool_node.js","names":["tool","e: any","outputs: (ToolMessage | Command)[]","messages: BaseMessage[]","toolMessageIds: Set<string>","aiMessage: AIMessage | undefined","combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[]","parentCommand: Command | null"],"sources":["../../src/prebuilt/tool_node.ts"],"sourcesContent":["import {\n BaseMessage,\n ToolMessage,\n AIMessage,\n isBaseMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { isGraphInterrupt } from \"../errors.js\";\nimport { END, isCommand, Command, _isSend, Send } from \"../constants.js\";\n\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n\nconst isBaseMessageArray = (input: unknown): input is BaseMessage[] =>\n Array.isArray(input) && input.every(isBaseMessage);\n\nconst isMessagesState = (\n input: unknown\n): input is { messages: BaseMessage[] } =>\n typeof input === \"object\" &&\n input != null &&\n \"messages\" in input &&\n isBaseMessageArray(input.messages);\n\nconst isSendInput = (input: unknown): input is { lg_tool_call: ToolCall } =>\n typeof input === \"object\" && input != null && \"lg_tool_call\" in input;\n\n/**\n * @deprecated `ToolNode` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { ToolNode } from \"langchain\";`\n *\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n\n handleToolErrors = true;\n\n trace = false;\n\n constructor(\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[],\n options?: ToolNodeOptions\n ) {\n const { name, tags, handleToolErrors } = options ?? {};\n super({ name, tags, func: (input, config) => this.run(input, config) });\n this.tools = tools;\n this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;\n }\n\n protected async runTool(\n call: ToolCall,\n config: RunnableConfig\n ): Promise<ToolMessage | Command> {\n const tool = this.tools.find((tool) => tool.name === call.name);\n try {\n if (tool === undefined) {\n throw new Error(`Tool \"${call.name}\" not found.`);\n }\n const output = await tool.invoke({ ...call, type: \"tool_call\" }, config);\n\n if (\n (isBaseMessage(output) && output.getType() === \"tool\") ||\n isCommand(output)\n ) {\n return output as ToolMessage | Command;\n }\n\n return new ToolMessage({\n status: \"success\",\n name: tool.name,\n content: typeof output === \"string\" ? output : JSON.stringify(output),\n tool_call_id: call.id!,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (!this.handleToolErrors) throw e;\n\n if (isGraphInterrupt(e)) {\n // `NodeInterrupt` errors are a breakpoint to bring a human into the loop.\n // As such, they are not recoverable by the agent and shouldn't be fed\n // back. Instead, re-throw these errors even when `handleToolErrors = true`.\n throw e;\n }\n\n return new ToolMessage({\n status: \"error\",\n content: `Error: ${e.message}\\n Please fix your mistakes.`,\n name: call.name,\n tool_call_id: call.id ?? \"\",\n });\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async run(input: unknown, config: RunnableConfig): Promise<T> {\n let outputs: (ToolMessage | Command)[];\n\n if (isSendInput(input)) {\n outputs = [await this.runTool(input.lg_tool_call, config)];\n } else {\n let messages: BaseMessage[];\n if (isBaseMessageArray(input)) {\n messages = input;\n } else if (isMessagesState(input)) {\n messages = input.messages;\n } else {\n throw new Error(\n \"ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.\"\n );\n }\n\n const toolMessageIds: Set<string> = new Set(\n messages\n .filter((msg) => msg.getType() === \"tool\")\n .map((msg) => (msg as ToolMessage).tool_call_id)\n );\n\n let aiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n aiMessage = message;\n break;\n }\n }\n\n if (aiMessage == null || !isAIMessage(aiMessage)) {\n throw new Error(\"ToolNode only accepts AIMessages as input.\");\n }\n\n outputs = await Promise.all(\n aiMessage.tool_calls\n ?.filter((call) => call.id == null || !toolMessageIds.has(call.id))\n .map((call) => this.runTool(call, config)) ?? []\n );\n }\n\n // Preserve existing behavior for non-command tool outputs for backwards compatibility\n if (!outputs.some(isCommand)) {\n return (Array.isArray(input) ? outputs : { messages: outputs }) as T;\n }\n\n // Handle mixed Command and non-Command outputs\n const combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[] = [];\n let parentCommand: Command | null = null;\n\n for (const output of outputs) {\n if (isCommand(output)) {\n if (\n output.graph === Command.PARENT &&\n Array.isArray(output.goto) &&\n output.goto.every((send) => _isSend(send))\n ) {\n if (parentCommand) {\n (parentCommand.goto as Send[]).push(...(output.goto as Send[]));\n } else {\n parentCommand = new Command({\n graph: Command.PARENT,\n goto: output.goto,\n });\n }\n } else {\n combinedOutputs.push(output);\n }\n } else {\n combinedOutputs.push(\n Array.isArray(input) ? [output] : { messages: [output] }\n );\n }\n }\n\n if (parentCommand) {\n combinedOutputs.push(parentCommand);\n }\n\n return combinedOutputs as T;\n }\n}\n\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport function toolsCondition(\n state: BaseMessage[] | typeof MessagesAnnotation.State\n): \"tools\" | typeof END {\n const message = Array.isArray(state)\n ? state[state.length - 1]\n : state.messages[state.messages.length - 1];\n\n if (\n message !== undefined &&\n \"tool_calls\" in message &&\n ((message as AIMessage).tool_calls?.length ?? 0) > 0\n ) {\n return \"tools\";\n } else {\n return END;\n }\n}\n"],"mappings":";;;;;;AAqBA,MAAM,sBAAsB,UAC1B,MAAM,QAAQ,UAAU,MAAM,MAAM;AAEtC,MAAM,mBACJ,UAEA,OAAO,UAAU,YACjB,SAAS,QACT,cAAc,SACd,mBAAmB,MAAM;AAE3B,MAAM,eAAe,UACnB,OAAO,UAAU,YAAY,SAAS,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2HlE,IAAa,WAAb,cAAuC,iBAAuB;CAC5D;CAEA,mBAAmB;CAEnB,QAAQ;CAER,YACE,OACA,SACA;EACA,MAAM,EAAE,MAAM,MAAM,qBAAqB,WAAW;AACpD,QAAM;GAAE;GAAM;GAAM,OAAO,OAAO,WAAW,KAAK,IAAI,OAAO;;AAC7D,OAAK,QAAQ;AACb,OAAK,mBAAmB,oBAAoB,KAAK;;CAGnD,MAAgB,QACd,MACA,QACgC;EAChC,MAAM,OAAO,KAAK,MAAM,MAAM,WAASA,OAAK,SAAS,KAAK;AAC1D,MAAI;AACF,OAAI,SAAS,OACX,OAAM,IAAI,MAAM,SAAS,KAAK,KAAK;GAErC,MAAM,SAAS,MAAM,KAAK,OAAO;IAAE,GAAG;IAAM,MAAM;MAAe;AAEjE,OACG,cAAc,WAAW,OAAO,cAAc,UAC/C,UAAU,QAEV,QAAO;AAGT,UAAO,IAAI,YAAY;IACrB,QAAQ;IACR,MAAM,KAAK;IACX,SAAS,OAAO,WAAW,WAAW,SAAS,KAAK,UAAU;IAC9D,cAAc,KAAK;;WAGdC,GAAQ;AACf,OAAI,CAAC,KAAK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,KAAK;MAGvB,iBAAgB,KACd,MAAM,QAAQ,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;AAKrD,MAAI,cACF,iBAAgB,KAAK;AAGvB,SAAO;;;;;;AAOX,SAAgB,eACd,OACsB;CACtB,MAAM,UAAU,MAAM,QAAQ,SAC1B,MAAM,MAAM,SAAS,KACrB,MAAM,SAAS,MAAM,SAAS,SAAS;AAE3C,KACE,YAAY,UACZ,gBAAgB,YACd,QAAsB,YAAY,UAAU,KAAK,EAEnD,QAAO;KAEP,QAAO"}
|
|
1
|
+
{"version":3,"file":"tool_node.js","names":["tool","e: any","outputs: (ToolMessage | Command)[]","messages: BaseMessage[]","toolMessageIds: Set<string>","aiMessage: AIMessage | undefined","combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[]","parentCommand: Command | null"],"sources":["../../src/prebuilt/tool_node.ts"],"sourcesContent":["import {\n BaseMessage,\n ToolMessage,\n AIMessage,\n isBaseMessage,\n isAIMessage,\n} from \"@langchain/core/messages\";\nimport { RunnableConfig, RunnableToolLike } from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\nimport { RunnableCallable } from \"../utils.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { isGraphInterrupt } from \"../errors.js\";\nimport { END, isCommand, Command, _isSend, Send } from \"../constants.js\";\n\nexport type ToolNodeOptions = {\n name?: string;\n tags?: string[];\n handleToolErrors?: boolean;\n};\n\nconst isBaseMessageArray = (input: unknown): input is BaseMessage[] =>\n Array.isArray(input) && input.every(isBaseMessage);\n\nconst isMessagesState = (\n input: unknown\n): input is { messages: BaseMessage[] } =>\n typeof input === \"object\" &&\n input != null &&\n \"messages\" in input &&\n isBaseMessageArray(input.messages);\n\nconst isSendInput = (input: unknown): input is { lg_tool_call: ToolCall } =>\n typeof input === \"object\" && input != null && \"lg_tool_call\" in input;\n\n/**\n * A node that runs the tools requested in the last AIMessage. It can be used\n * either in StateGraph with a \"messages\" key or in MessageGraph. If multiple\n * tool calls are requested, they will be run in parallel. The output will be\n * a list of ToolMessages, one for each tool call.\n *\n * @example\n * ```ts\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { AIMessage } from \"@langchain/core/messages\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const toolNode = new ToolNode(tools);\n *\n * const messageWithSingleToolCall = new AIMessage({\n * content: \"\",\n * tool_calls: [\n * {\n * name: \"get_weather\",\n * args: { location: \"sf\" },\n * id: \"tool_call_id\",\n * type: \"tool_call\",\n * }\n * ]\n * })\n *\n * await toolNode.invoke({ messages: [messageWithSingleToolCall] });\n * // Returns tool invocation responses as:\n * // { messages: ToolMessage[] }\n * ```\n *\n * @example\n * ```ts\n * import {\n * StateGraph,\n * MessagesAnnotation,\n * } from \"@langchain/langgraph\";\n * import { ToolNode } from \"@langchain/langgraph/prebuilt\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { ChatAnthropic } from \"@langchain/anthropic\";\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * }),\n * });\n *\n * const tools = [getWeather];\n * const modelWithTools = new ChatAnthropic({\n * model: \"claude-3-haiku-20240307\",\n * temperature: 0\n * }).bindTools(tools);\n *\n * const toolNodeForGraph = new ToolNode(tools)\n *\n * const shouldContinue = (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const lastMessage = messages[messages.length - 1];\n * if (\"tool_calls\" in lastMessage && Array.isArray(lastMessage.tool_calls) && lastMessage.tool_calls?.length) {\n * return \"tools\";\n * }\n * return \"__end__\";\n * }\n *\n * const callModel = async (state: typeof MessagesAnnotation.State) => {\n * const { messages } = state;\n * const response = await modelWithTools.invoke(messages);\n * return { messages: response };\n * }\n *\n * const graph = new StateGraph(MessagesAnnotation)\n * .addNode(\"agent\", callModel)\n * .addNode(\"tools\", toolNodeForGraph)\n * .addEdge(\"__start__\", \"agent\")\n * .addConditionalEdges(\"agent\", shouldContinue)\n * .addEdge(\"tools\", \"agent\")\n * .compile();\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await graph.stream(inputs, {\n * streamMode: \"values\",\n * });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ToolNode<T = any> extends RunnableCallable<T, T> {\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[];\n\n handleToolErrors = true;\n\n trace = false;\n\n constructor(\n tools: (StructuredToolInterface | DynamicTool | RunnableToolLike)[],\n options?: ToolNodeOptions\n ) {\n const { name, tags, handleToolErrors } = options ?? {};\n super({ name, tags, func: (input, config) => this.run(input, config) });\n this.tools = tools;\n this.handleToolErrors = handleToolErrors ?? this.handleToolErrors;\n }\n\n protected async runTool(\n call: ToolCall,\n config: RunnableConfig\n ): Promise<ToolMessage | Command> {\n const tool = this.tools.find((tool) => tool.name === call.name);\n try {\n if (tool === undefined) {\n throw new Error(`Tool \"${call.name}\" not found.`);\n }\n const output = await tool.invoke({ ...call, type: \"tool_call\" }, config);\n\n if (\n (isBaseMessage(output) && output.getType() === \"tool\") ||\n isCommand(output)\n ) {\n return output as ToolMessage | Command;\n }\n\n return new ToolMessage({\n status: \"success\",\n name: tool.name,\n content: typeof output === \"string\" ? output : JSON.stringify(output),\n tool_call_id: call.id!,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (e: any) {\n if (!this.handleToolErrors) throw e;\n\n if (isGraphInterrupt(e)) {\n // `NodeInterrupt` errors are a breakpoint to bring a human into the loop.\n // As such, they are not recoverable by the agent and shouldn't be fed\n // back. Instead, re-throw these errors even when `handleToolErrors = true`.\n throw e;\n }\n\n return new ToolMessage({\n status: \"error\",\n content: `Error: ${e.message}\\n Please fix your mistakes.`,\n name: call.name,\n tool_call_id: call.id ?? \"\",\n });\n }\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected async run(input: unknown, config: RunnableConfig): Promise<T> {\n let outputs: (ToolMessage | Command)[];\n\n if (isSendInput(input)) {\n outputs = [await this.runTool(input.lg_tool_call, config)];\n } else {\n let messages: BaseMessage[];\n if (isBaseMessageArray(input)) {\n messages = input;\n } else if (isMessagesState(input)) {\n messages = input.messages;\n } else {\n throw new Error(\n \"ToolNode only accepts BaseMessage[] or { messages: BaseMessage[] } as input.\"\n );\n }\n\n const toolMessageIds: Set<string> = new Set(\n messages\n .filter((msg) => msg.getType() === \"tool\")\n .map((msg) => (msg as ToolMessage).tool_call_id)\n );\n\n let aiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n aiMessage = message;\n break;\n }\n }\n\n if (aiMessage == null || !isAIMessage(aiMessage)) {\n throw new Error(\"ToolNode only accepts AIMessages as input.\");\n }\n\n outputs = await Promise.all(\n aiMessage.tool_calls\n ?.filter((call) => call.id == null || !toolMessageIds.has(call.id))\n .map((call) => this.runTool(call, config)) ?? []\n );\n }\n\n // Preserve existing behavior for non-command tool outputs for backwards compatibility\n if (!outputs.some(isCommand)) {\n return (Array.isArray(input) ? outputs : { messages: outputs }) as T;\n }\n\n // Handle mixed Command and non-Command outputs\n const combinedOutputs: (\n | { messages: BaseMessage[] }\n | BaseMessage[]\n | Command\n )[] = [];\n let parentCommand: Command | null = null;\n\n for (const output of outputs) {\n if (isCommand(output)) {\n if (\n output.graph === Command.PARENT &&\n Array.isArray(output.goto) &&\n output.goto.every((send) => _isSend(send))\n ) {\n if (parentCommand) {\n (parentCommand.goto as Send[]).push(...(output.goto as Send[]));\n } else {\n parentCommand = new Command({\n graph: Command.PARENT,\n goto: output.goto,\n });\n }\n } else {\n combinedOutputs.push(output);\n }\n } else {\n combinedOutputs.push(\n Array.isArray(input) ? [output] : { messages: [output] }\n );\n }\n }\n\n if (parentCommand) {\n combinedOutputs.push(parentCommand);\n }\n\n return combinedOutputs as T;\n }\n}\n\n/**\n * @deprecated Use new `ToolNode` from {@link https://www.npmjs.com/package/langchain langchain} package instead.\n */\nexport function toolsCondition(\n state: BaseMessage[] | typeof MessagesAnnotation.State\n): \"tools\" | typeof END {\n const message = Array.isArray(state)\n ? state[state.length - 1]\n : state.messages[state.messages.length - 1];\n\n if (\n message !== undefined &&\n \"tool_calls\" in message &&\n ((message as AIMessage).tool_calls?.length ?? 0) > 0\n ) {\n return \"tools\";\n } else {\n return END;\n }\n}\n"],"mappings":";;;;;;AAqBA,MAAM,sBAAsB,UAC1B,MAAM,QAAQ,UAAU,MAAM,MAAM;AAEtC,MAAM,mBACJ,UAEA,OAAO,UAAU,YACjB,SAAS,QACT,cAAc,SACd,mBAAmB,MAAM;AAE3B,MAAM,eAAe,UACnB,OAAO,UAAU,YAAY,SAAS,QAAQ,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHlE,IAAa,WAAb,cAAuC,iBAAuB;CAC5D;CAEA,mBAAmB;CAEnB,QAAQ;CAER,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ACxB,iBAAY;AACZ;;;AAIJ,OAAI,aAAa,QAAQ,CAAC,YAAY,WACpC,OAAM,IAAI,MAAM;AAGlB,aAAU,MAAM,QAAQ,IACtB,UAAU,YACN,QAAQ,SAAS,KAAK,MAAM,QAAQ,CAAC,eAAe,IAAI,KAAK,KAC9D,KAAK,SAAS,KAAK,QAAQ,MAAM,YAAY;;AAKpD,MAAI,CAAC,QAAQ,KAAK,WAChB,QAAQ,MAAM,QAAQ,SAAS,UAAU,EAAE,UAAU;EAIvD,MAAMC,kBAIA;EACN,IAAIC,gBAAgC;AAEpC,OAAK,MAAM,UAAU,QACnB,KAAI,UAAU,QACZ,KACE,OAAO,UAAU,QAAQ,UACzB,MAAM,QAAQ,OAAO,SACrB,OAAO,KAAK,OAAO,SAAS,QAAQ,OAEpC,KAAI,cACF,CAAC,cAAc,KAAgB,KAAK,GAAI,OAAO;MAE/C,iBAAgB,IAAI,QAAQ;GAC1B,OAAO,QAAQ;GACf,MAAM,OAAO;;MAIjB,iBAAgB,KAAK;MAGvB,iBAAgB,KACd,MAAM,QAAQ,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;AAKrD,MAAI,cACF,iBAAgB,KAAK;AAGvB,SAAO;;;;;;AAOX,SAAgB,eACd,OACsB;CACtB,MAAM,UAAU,MAAM,QAAQ,SAC1B,MAAM,MAAM,SAAS,KACrB,MAAM,SAAS,MAAM,SAAS,SAAS;AAE3C,KACE,YAAY,UACZ,gBAAgB,YACd,QAAsB,YAAY,UAAU,KAAK,EAEnD,QAAO;KAEP,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/langgraph",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "LangGraph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -76,13 +76,13 @@
|
|
|
76
76
|
"eslint-plugin-prettier": "^4.2.1",
|
|
77
77
|
"langchain": "^1.0.0-alpha",
|
|
78
78
|
"pg": "^8.13.0",
|
|
79
|
-
"playwright": "^1.
|
|
79
|
+
"playwright": "^1.55.1",
|
|
80
80
|
"prettier": "^2.8.3",
|
|
81
81
|
"rollup": "^4.37.0",
|
|
82
82
|
"tsx": "^4.19.3",
|
|
83
83
|
"typescript": "^4.9.5 || ^5.4.5",
|
|
84
84
|
"vite-plugin-node-polyfills": "^0.23.0",
|
|
85
|
-
"vitest": "^3.
|
|
85
|
+
"vitest": "^3.2.4",
|
|
86
86
|
"zod-to-json-schema": "^3.22.4"
|
|
87
87
|
},
|
|
88
88
|
"publishConfig": {
|