langchain 1.2.35 → 1.3.0-dev-1773962633795
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 +0 -40
- package/dist/agents/ReactAgent.cjs +8 -26
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +1 -1
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +1 -1
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +8 -26
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/nodes/ToolNode.cjs +0 -2
- package/dist/agents/nodes/ToolNode.cjs.map +1 -1
- package/dist/agents/nodes/ToolNode.js +0 -2
- package/dist/agents/nodes/ToolNode.js.map +1 -1
- package/dist/agents/types.d.cts +4 -12
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +4 -12
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/browser.cjs +3 -7
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +3 -2
- package/dist/browser.d.ts +3 -2
- package/dist/browser.js +2 -1
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +3 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/load/import_map.cjs +3 -1
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +3 -1
- package/dist/load/import_map.js.map +1 -1
- package/dist/tools/headless.cjs +113 -0
- package/dist/tools/headless.cjs.map +1 -0
- package/dist/tools/headless.d.cts +122 -0
- package/dist/tools/headless.d.cts.map +1 -0
- package/dist/tools/headless.d.ts +122 -0
- package/dist/tools/headless.d.ts.map +1 -0
- package/dist/tools/headless.js +112 -0
- package/dist/tools/headless.js.map +1 -0
- package/dist/tools/index.cjs +15 -0
- package/dist/tools/index.cjs.map +1 -0
- package/dist/tools/index.d.cts +2 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -0
- package/package.json +16 -5
- package/chat_models/universal.cjs +0 -1
- package/chat_models/universal.d.cts +0 -1
- package/chat_models/universal.d.ts +0 -1
- package/chat_models/universal.js +0 -1
- package/hub/node.cjs +0 -1
- package/hub/node.d.cts +0 -1
- package/hub/node.d.ts +0 -1
- package/hub/node.js +0 -1
- package/hub.cjs +0 -1
- package/hub.d.cts +0 -1
- package/hub.d.ts +0 -1
- package/hub.js +0 -1
- package/load/serializable.cjs +0 -1
- package/load/serializable.d.cts +0 -1
- package/load/serializable.d.ts +0 -1
- package/load/serializable.js +0 -1
- package/load.cjs +0 -1
- package/load.d.cts +0 -1
- package/load.d.ts +0 -1
- package/load.js +0 -1
- package/storage/encoder_backed.cjs +0 -1
- package/storage/encoder_backed.d.cts +0 -1
- package/storage/encoder_backed.d.ts +0 -1
- package/storage/encoder_backed.js +0 -1
- package/storage/file_system.cjs +0 -1
- package/storage/file_system.d.cts +0 -1
- package/storage/file_system.d.ts +0 -1
- package/storage/file_system.js +0 -1
- package/storage/in_memory.cjs +0 -1
- package/storage/in_memory.d.cts +0 -1
- package/storage/in_memory.d.ts +0 -1
- package/storage/in_memory.js +0 -1
package/dist/agents/types.d.ts
CHANGED
|
@@ -647,18 +647,10 @@ type CreateAgentParams<StructuredResponseType extends Record<string, any> = Reco
|
|
|
647
647
|
* Determines the version of the graph to create.
|
|
648
648
|
*
|
|
649
649
|
* Can be one of
|
|
650
|
-
* - `"v1"`: The tool node processes
|
|
651
|
-
*
|
|
652
|
-
*
|
|
653
|
-
*
|
|
654
|
-
* LangGraph's per-task checkpoint serialisation.
|
|
655
|
-
*
|
|
656
|
-
* - `"v2"`: Each tool call is dispatched as an independent graph task using the Send API.
|
|
657
|
-
* Tasks are scheduled in parallel by LangGraph, but when tools invoke sub-graphs
|
|
658
|
-
* the underlying checkpoint writes can cause effective serialisation, making
|
|
659
|
-
* concurrent tool calls execute sequentially. v2 is the better choice when you
|
|
660
|
-
* need per-tool-call checkpointing, independent fault isolation, or `interrupt()`
|
|
661
|
-
* support inside individual tool calls.
|
|
650
|
+
* - `"v1"`: The tool node processes a single message. All tool calls in the message are
|
|
651
|
+
* executed in parallel within the tool node.
|
|
652
|
+
* - `"v2"`: The tool node processes a single tool call. Tool calls are distributed across
|
|
653
|
+
* multiple instances of the tool node using the Send API.
|
|
662
654
|
*
|
|
663
655
|
* @default `"v2"`
|
|
664
656
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/agents/types.ts"],"mappings":";;;;;;;;;;;;;;;AAwFA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAiB,eAAA,mBACG,MAAA,gBAAsB,uBAAA,GACpC,MAAA,gBACA,uBAAA,iBACW,mBAAA,eACX,mBAAA,+BAEa,iBAAA,GAAoB,gBAAA,GACjC,iBAAA,GACA,gBAAA,+BACyB,eAAA,cAA6B,eAAA,6BACjC,UAAA,GAAa,UAAA,gBAClC,UAAA,GACA,UAAA;EAJA;EAQJ,QAAA,EAAU,SAAA;EAPmB;EAS7B,KAAA,EAAO,MAAA;EARP;EAUA,OAAA,EAAS,QAAA;EAV6B;EAYtC,UAAA,EAAY,WAAA;EAVR;EAYJ,KAAA,EAAO,MAAA;AAAA;;;;;UAOQ,sBAAA,SAA+B,eAAA;EAC9C,QAAA,EAAU,MAAA;EACV,KAAA;EACA,OAAA,EAAS,iBAAA;EACT,UAAA,WAAqB,eAAA;EACrB,KAAA,YAAiB,UAAA,GAAa,UAAA;AAAA;;;;;KAOpB,oBAAA,WAA+B,eAAA,IACzC,CAAA,SAAU,eAAA,gCACN,MAAA,mBAAyB,UAAA,GAAa,UAAA,MACpC,MAAA;;;;;KAQI,yBAAA,oBAA6C,eAAA,MACvD,CAAA,qCAEI,CAAA,iDACE,KAAA,SAA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;;;;AAkB5B;;;;;;;;;;EA6IE,KAAA,IAAS,UAAA,GAAa,UAAA;EA3IpB;;;;;;AAOJ;;;;;;;;;;;;AA0BA;;;;;;;;;AAkBA;;;;;AAKA;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;;;;;;;;;;;EAuIE,YAAA,YAAwB,aAAA;EAvEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqHtB,WAAA,GAAc,YAAA;EAAA;;;;;;;;;;;;;;;;;;;AAqJhB;;;;;;;;;;;;;;EAnHE,aAAA,GAAgB,aAAA;EAoHI;;;;EA/GpB,YAAA,GAAe,mBAAA;EAiHT;;;;EA5GN,KAAA,GAAQ,SAAA;EA6GD;AAGT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA1DE,cAAA,GAAiB,kBAAA;;;;;;;EAQjB,UAAA,YAAsB,eAAA;;;;EAKtB,IAAA;;;;;EAMA,WAAA;;;;;;;EAQA,gBAAA;;;;EAKA,MAAA,GAAS,WAAA;;;;;;;;;;;;EAaT,OAAA;AAAA;;;;KAMU,oBAAA,oBAAwC,cAAA,WAClD,CAAA,mBAAoB,cAAA,4BAChB,IAAA,kBAAsB,cAAA,UACpB,CAAA,GAAI,oBAAA,CAAqB,IAAA,IACzB,CAAA;AAAA,KAGI,mBAAA,4BACV,KAAA,SAAc,UAAA,mEASV,UAAA,CAAW,EAAA,EAAI,CAAA,EAAG,CAAA,EAAG,CAAA,GAAI,CAAA,EAAG,CAAA,EAAG,CAAA,EAAG,CAAA"}
|
package/dist/browser.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_chat_models_universal = require("./chat_models/universal.cjs");
|
|
4
|
+
const require_headless = require("./tools/headless.cjs");
|
|
4
5
|
let _langchain_core_messages = require("@langchain/core/messages");
|
|
5
6
|
let _langchain_core_tools = require("@langchain/core/tools");
|
|
6
7
|
let _langchain_core_utils_context = require("@langchain/core/utils/context");
|
|
@@ -30,7 +31,7 @@ var browser_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
30
31
|
filterMessages: () => _langchain_core_messages.filterMessages,
|
|
31
32
|
initChatModel: () => require_chat_models_universal.initChatModel,
|
|
32
33
|
langchainMatchers: () => _langchain_core_testing.langchainMatchers,
|
|
33
|
-
tool: () =>
|
|
34
|
+
tool: () => require_headless.tool,
|
|
34
35
|
trimMessages: () => _langchain_core_messages.trimMessages
|
|
35
36
|
});
|
|
36
37
|
//#endregion
|
|
@@ -161,12 +162,7 @@ Object.defineProperty(exports, "langchainMatchers", {
|
|
|
161
162
|
return _langchain_core_testing.langchainMatchers;
|
|
162
163
|
}
|
|
163
164
|
});
|
|
164
|
-
|
|
165
|
-
enumerable: true,
|
|
166
|
-
get: function() {
|
|
167
|
-
return _langchain_core_tools.tool;
|
|
168
|
-
}
|
|
169
|
-
});
|
|
165
|
+
exports.tool = require_headless.tool;
|
|
170
166
|
Object.defineProperty(exports, "trimMessages", {
|
|
171
167
|
enumerable: true,
|
|
172
168
|
get: function() {
|
package/dist/browser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.cjs","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * LangChain browser exports\n */\n\n/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n
|
|
1
|
+
{"version":3,"file":"browser.cjs","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * LangChain browser exports\n */\n\n/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain tool primitive (supports both normal and headless tools)\n */\nexport {\n tool,\n type HeadlessTool,\n type HeadlessToolFields,\n type HeadlessToolImplementation,\n} from \"./tools/headless.js\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { initChatModel } from "./chat_models/universal.cjs";
|
|
2
|
+
import { HeadlessTool, HeadlessToolFields, HeadlessToolImplementation, tool } from "./tools/headless.cjs";
|
|
2
3
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ContentBlock, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
3
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime
|
|
4
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime } from "@langchain/core/tools";
|
|
4
5
|
import { context } from "@langchain/core/utils/context";
|
|
5
6
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
6
7
|
import { Document, DocumentInput } from "@langchain/core/documents";
|
|
7
8
|
import { LangChainMatchers, fakeModel, langchainMatchers } from "@langchain/core/testing";
|
|
8
|
-
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, type ContentBlock, Document, type DocumentInput, DynamicStructuredTool, DynamicTool, HumanMessage, HumanMessageChunk, InMemoryStore, type LangChainMatchers, StructuredTool, SystemMessage, SystemMessageChunk, Tool, ToolMessage, ToolMessageChunk, type ToolRuntime, context, fakeModel, filterMessages, initChatModel, langchainMatchers, tool, trimMessages };
|
|
9
|
+
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, type ContentBlock, Document, type DocumentInput, DynamicStructuredTool, DynamicTool, type HeadlessTool, type HeadlessToolFields, type HeadlessToolImplementation, HumanMessage, HumanMessageChunk, InMemoryStore, type LangChainMatchers, StructuredTool, SystemMessage, SystemMessageChunk, Tool, ToolMessage, ToolMessageChunk, type ToolRuntime, context, fakeModel, filterMessages, initChatModel, langchainMatchers, tool, trimMessages };
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { initChatModel } from "./chat_models/universal.js";
|
|
2
|
+
import { HeadlessTool, HeadlessToolFields, HeadlessToolImplementation, tool } from "./tools/headless.js";
|
|
2
3
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ContentBlock, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
3
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime
|
|
4
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime } from "@langchain/core/tools";
|
|
4
5
|
import { context } from "@langchain/core/utils/context";
|
|
5
6
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
6
7
|
import { Document, DocumentInput } from "@langchain/core/documents";
|
|
7
8
|
import { LangChainMatchers, fakeModel, langchainMatchers } from "@langchain/core/testing";
|
|
8
|
-
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, type ContentBlock, Document, type DocumentInput, DynamicStructuredTool, DynamicTool, HumanMessage, HumanMessageChunk, InMemoryStore, type LangChainMatchers, StructuredTool, SystemMessage, SystemMessageChunk, Tool, ToolMessage, ToolMessageChunk, type ToolRuntime, context, fakeModel, filterMessages, initChatModel, langchainMatchers, tool, trimMessages };
|
|
9
|
+
export { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, type ContentBlock, Document, type DocumentInput, DynamicStructuredTool, DynamicTool, type HeadlessTool, type HeadlessToolFields, type HeadlessToolImplementation, HumanMessage, HumanMessageChunk, InMemoryStore, type LangChainMatchers, StructuredTool, SystemMessage, SystemMessageChunk, Tool, ToolMessage, ToolMessageChunk, type ToolRuntime, context, fakeModel, filterMessages, initChatModel, langchainMatchers, tool, trimMessages };
|
package/dist/browser.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { initChatModel } from "./chat_models/universal.js";
|
|
3
|
+
import { tool } from "./tools/headless.js";
|
|
3
4
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
4
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool
|
|
5
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool } from "@langchain/core/tools";
|
|
5
6
|
import { context } from "@langchain/core/utils/context";
|
|
6
7
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
7
8
|
import { Document } from "@langchain/core/documents";
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * LangChain browser exports\n */\n\n/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n
|
|
1
|
+
{"version":3,"file":"browser.js","names":[],"sources":["../src/browser.ts"],"sourcesContent":["/**\n * LangChain browser exports\n */\n\n/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain tool primitive (supports both normal and headless tools)\n */\nexport {\n tool,\n type HeadlessTool,\n type HeadlessToolFields,\n type HeadlessToolImplementation,\n} from \"./tools/headless.js\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_chat_models_universal = require("./chat_models/universal.cjs");
|
|
4
|
+
const require_headless = require("./tools/headless.cjs");
|
|
4
5
|
const require_errors = require("./agents/errors.cjs");
|
|
5
6
|
const require_responses = require("./agents/responses.cjs");
|
|
6
7
|
const require_utils = require("./agents/middleware/utils.cjs");
|
|
@@ -91,7 +92,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
91
92
|
resolveRedactionRule: () => require_pii.resolveRedactionRule,
|
|
92
93
|
summarizationMiddleware: () => require_summarization.summarizationMiddleware,
|
|
93
94
|
todoListMiddleware: () => require_todoListMiddleware.todoListMiddleware,
|
|
94
|
-
tool: () =>
|
|
95
|
+
tool: () => require_headless.tool,
|
|
95
96
|
toolCallLimitMiddleware: () => require_toolCallLimit.toolCallLimitMiddleware,
|
|
96
97
|
toolEmulatorMiddleware: () => require_toolEmulator.toolEmulatorMiddleware,
|
|
97
98
|
toolRetryMiddleware: () => require_toolRetry.toolRetryMiddleware,
|
|
@@ -263,12 +264,7 @@ Object.defineProperty(exports, "src_exports", {
|
|
|
263
264
|
});
|
|
264
265
|
exports.summarizationMiddleware = require_summarization.summarizationMiddleware;
|
|
265
266
|
exports.todoListMiddleware = require_todoListMiddleware.todoListMiddleware;
|
|
266
|
-
|
|
267
|
-
enumerable: true,
|
|
268
|
-
get: function() {
|
|
269
|
-
return _langchain_core_tools.tool;
|
|
270
|
-
}
|
|
271
|
-
});
|
|
267
|
+
exports.tool = require_headless.tool;
|
|
272
268
|
exports.toolCallLimitMiddleware = require_toolCallLimit.toolCallLimitMiddleware;
|
|
273
269
|
exports.toolEmulatorMiddleware = require_toolEmulator.toolEmulatorMiddleware;
|
|
274
270
|
exports.toolRetryMiddleware = require_toolRetry.toolRetryMiddleware;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n tool,\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Agents\n */\nexport * from \"./agents/index.js\";\n\n/**\n * `createAgent` pre-built middleware\n */\nexport * from \"./agents/middleware/index.js\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools with support for headless tools\n */\nexport {\n tool,\n type HeadlessTool,\n type HeadlessToolFields,\n type HeadlessToolImplementation,\n} from \"./tools/headless.js\";\n\n/**\n * LangChain Core Tool Primitives\n */\nexport {\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Agents\n */\nexport * from \"./agents/index.js\";\n\n/**\n * `createAgent` pre-built middleware\n */\nexport * from \"./agents/middleware/index.js\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { initChatModel } from "./chat_models/universal.cjs";
|
|
2
|
+
import { HeadlessTool, HeadlessToolFields, HeadlessToolImplementation, tool } from "./tools/headless.cjs";
|
|
2
3
|
import { MiddlewareError, MultipleStructuredOutputsError, MultipleToolsBoundError, StructuredOutputParsingError, ToolInvocationError } from "./agents/errors.cjs";
|
|
3
4
|
import { ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy, providerStrategy, toolStrategy } from "./agents/responses.cjs";
|
|
4
5
|
import { JumpToTarget } from "./agents/constants.cjs";
|
|
@@ -28,9 +29,9 @@ import { OpenAIModerationMiddlewareOptions, openAIModerationMiddleware } from ".
|
|
|
28
29
|
import { PromptCachingMiddlewareConfig, anthropicPromptCachingMiddleware } from "./agents/middleware/provider/anthropic/promptCaching.cjs";
|
|
29
30
|
import { countTokensApproximately } from "./agents/middleware/utils.cjs";
|
|
30
31
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ContentBlock, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
31
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime
|
|
32
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime } from "@langchain/core/tools";
|
|
32
33
|
import { context } from "@langchain/core/utils/context";
|
|
33
34
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
34
35
|
import { Document, DocumentInput } from "@langchain/core/documents";
|
|
35
36
|
import { LangChainMatchers, fakeModel, langchainMatchers } from "@langchain/core/testing";
|
|
36
|
-
export { AIMessage, AIMessageChunk, Action, ActionRequest, AfterAgentHook, AfterModelHook, AgentMiddleware, AgentTypeConfig, AnyAnnotationRoot, ApproveDecision, BaseMessage, BaseMessageChunk, BeforeAgentHook, BeforeModelHook, BuiltInPIIType, BuiltInState, ClearToolUsesEdit, ClearToolUsesEditConfig, CombineTools, type ContentBlock, ContextEdit, ContextEditingMiddlewareConfig, CreateAgentParams, Decision, DecisionType, DefaultAgentTypeConfig, DefaultMiddlewareTypeConfig, DescriptionFactory, Document, type DocumentInput, DynamicStructuredTool, DynamicSystemPromptMiddlewareConfig, DynamicTool, EditDecision, ExecutedToolCall, ExtractZodArrayTypes, FakeToolCallingModel, HITLRequest, HITLResponse, HumanInTheLoopMiddlewareConfig, HumanMessage, HumanMessageChunk, InMemoryStore, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareTools, InferMiddlewareToolsArray, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, InferSchemaUpdateType, InferSchemaValue, InferSchemaValueType, Interrupt, InterruptOnConfig, JumpTo, JumpToTarget, LLMToolSelectorConfig, type LangChainMatchers, MIDDLEWARE_BRAND, MiddlewareError, MiddlewareResult, MiddlewareTypeConfig, ModelCallLimitMiddlewareConfig, ModelRequest, ModelRetryMiddlewareConfig, MultipleStructuredOutputsError, MultipleToolsBoundError, N, NormalizedSchemaInput, NormalizedSchemaUpdate, OpenAIModerationMiddlewareOptions, PIIDetectionError, PIIDetector, PIIMatch, PIIMiddlewareConfig, PIIRedactionMiddlewareConfig, PIIStrategy, PromptCachingMiddlewareConfig, ProviderStrategy, ReactAgent, RedactionRuleConfig, RejectDecision, ResolveAgentTypeConfig, ResolveMiddlewareTypeConfig, ResolvedRedactionRule, ResponseFormat, ResponseFormatUndefined, ReviewConfig, Runtime, StructuredOutputParsingError, StructuredTool, SummarizationMiddlewareConfig, SystemMessage, SystemMessageChunk, TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT, ToAnnotationRoot, Todo, TodoListMiddlewareOptions, TokenCounter, Tool, ToolCall, ToolCallHandler, ToolCallLimitConfig, ToolCallLimitExceededError, ToolCallRequest, ToolEmulatorOptions, ToolInvocationError, ToolMessage, ToolMessageChunk, ToolResult, ToolRetryMiddlewareConfig, type ToolRuntime, ToolStrategy, ToolsToMessageToolSet, TypedToolStrategy, UserInput, WithStateGraphNodes, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook, anthropicPromptCachingMiddleware, applyStrategy, context, contextEditingMiddleware, countTokensApproximately, createAgent, createMiddleware, detectCreditCard, detectEmail, detectIP, detectMacAddress, detectUrl, dynamicSystemPromptMiddleware, fakeModel, filterMessages, humanInTheLoopMiddleware, initChatModel, langchainMatchers, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, modelRetryMiddleware, openAIModerationMiddleware, piiMiddleware, piiRedactionMiddleware, providerStrategy, resolveRedactionRule, summarizationMiddleware, todoListMiddleware, tool, toolCallLimitMiddleware, toolEmulatorMiddleware, toolRetryMiddleware, toolStrategy, trimMessages };
|
|
37
|
+
export { AIMessage, AIMessageChunk, Action, ActionRequest, AfterAgentHook, AfterModelHook, AgentMiddleware, AgentTypeConfig, AnyAnnotationRoot, ApproveDecision, BaseMessage, BaseMessageChunk, BeforeAgentHook, BeforeModelHook, BuiltInPIIType, BuiltInState, ClearToolUsesEdit, ClearToolUsesEditConfig, CombineTools, type ContentBlock, ContextEdit, ContextEditingMiddlewareConfig, CreateAgentParams, Decision, DecisionType, DefaultAgentTypeConfig, DefaultMiddlewareTypeConfig, DescriptionFactory, Document, type DocumentInput, DynamicStructuredTool, DynamicSystemPromptMiddlewareConfig, DynamicTool, EditDecision, ExecutedToolCall, ExtractZodArrayTypes, FakeToolCallingModel, HITLRequest, HITLResponse, type HeadlessTool, type HeadlessToolFields, type HeadlessToolImplementation, HumanInTheLoopMiddlewareConfig, HumanMessage, HumanMessageChunk, InMemoryStore, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareTools, InferMiddlewareToolsArray, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, InferSchemaUpdateType, InferSchemaValue, InferSchemaValueType, Interrupt, InterruptOnConfig, JumpTo, JumpToTarget, LLMToolSelectorConfig, type LangChainMatchers, MIDDLEWARE_BRAND, MiddlewareError, MiddlewareResult, MiddlewareTypeConfig, ModelCallLimitMiddlewareConfig, ModelRequest, ModelRetryMiddlewareConfig, MultipleStructuredOutputsError, MultipleToolsBoundError, N, NormalizedSchemaInput, NormalizedSchemaUpdate, OpenAIModerationMiddlewareOptions, PIIDetectionError, PIIDetector, PIIMatch, PIIMiddlewareConfig, PIIRedactionMiddlewareConfig, PIIStrategy, PromptCachingMiddlewareConfig, ProviderStrategy, ReactAgent, RedactionRuleConfig, RejectDecision, ResolveAgentTypeConfig, ResolveMiddlewareTypeConfig, ResolvedRedactionRule, ResponseFormat, ResponseFormatUndefined, ReviewConfig, Runtime, StructuredOutputParsingError, StructuredTool, SummarizationMiddlewareConfig, SystemMessage, SystemMessageChunk, TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT, ToAnnotationRoot, Todo, TodoListMiddlewareOptions, TokenCounter, Tool, ToolCall, ToolCallHandler, ToolCallLimitConfig, ToolCallLimitExceededError, ToolCallRequest, ToolEmulatorOptions, ToolInvocationError, ToolMessage, ToolMessageChunk, ToolResult, ToolRetryMiddlewareConfig, type ToolRuntime, ToolStrategy, ToolsToMessageToolSet, TypedToolStrategy, UserInput, WithStateGraphNodes, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook, anthropicPromptCachingMiddleware, applyStrategy, context, contextEditingMiddleware, countTokensApproximately, createAgent, createMiddleware, detectCreditCard, detectEmail, detectIP, detectMacAddress, detectUrl, dynamicSystemPromptMiddleware, fakeModel, filterMessages, humanInTheLoopMiddleware, initChatModel, langchainMatchers, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, modelRetryMiddleware, openAIModerationMiddleware, piiMiddleware, piiRedactionMiddleware, providerStrategy, resolveRedactionRule, summarizationMiddleware, todoListMiddleware, tool, toolCallLimitMiddleware, toolEmulatorMiddleware, toolRetryMiddleware, toolStrategy, trimMessages };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { initChatModel } from "./chat_models/universal.js";
|
|
2
|
+
import { HeadlessTool, HeadlessToolFields, HeadlessToolImplementation, tool } from "./tools/headless.js";
|
|
2
3
|
import { MiddlewareError, MultipleStructuredOutputsError, MultipleToolsBoundError, StructuredOutputParsingError, ToolInvocationError } from "./agents/errors.js";
|
|
3
4
|
import { ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy, providerStrategy, toolStrategy } from "./agents/responses.js";
|
|
4
5
|
import { JumpToTarget } from "./agents/constants.js";
|
|
@@ -28,9 +29,9 @@ import { OpenAIModerationMiddlewareOptions, openAIModerationMiddleware } from ".
|
|
|
28
29
|
import { PromptCachingMiddlewareConfig, anthropicPromptCachingMiddleware } from "./agents/middleware/provider/anthropic/promptCaching.js";
|
|
29
30
|
import { countTokensApproximately } from "./agents/middleware/utils.js";
|
|
30
31
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, ContentBlock, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
31
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime
|
|
32
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool, ToolRuntime } from "@langchain/core/tools";
|
|
32
33
|
import { context } from "@langchain/core/utils/context";
|
|
33
34
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
34
35
|
import { Document, DocumentInput } from "@langchain/core/documents";
|
|
35
36
|
import { LangChainMatchers, fakeModel, langchainMatchers } from "@langchain/core/testing";
|
|
36
|
-
export { AIMessage, AIMessageChunk, Action, ActionRequest, AfterAgentHook, AfterModelHook, AgentMiddleware, AgentTypeConfig, AnyAnnotationRoot, ApproveDecision, BaseMessage, BaseMessageChunk, BeforeAgentHook, BeforeModelHook, BuiltInPIIType, BuiltInState, ClearToolUsesEdit, ClearToolUsesEditConfig, CombineTools, type ContentBlock, ContextEdit, ContextEditingMiddlewareConfig, CreateAgentParams, Decision, DecisionType, DefaultAgentTypeConfig, DefaultMiddlewareTypeConfig, DescriptionFactory, Document, type DocumentInput, DynamicStructuredTool, DynamicSystemPromptMiddlewareConfig, DynamicTool, EditDecision, ExecutedToolCall, ExtractZodArrayTypes, FakeToolCallingModel, HITLRequest, HITLResponse, HumanInTheLoopMiddlewareConfig, HumanMessage, HumanMessageChunk, InMemoryStore, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareTools, InferMiddlewareToolsArray, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, InferSchemaUpdateType, InferSchemaValue, InferSchemaValueType, Interrupt, InterruptOnConfig, JumpTo, JumpToTarget, LLMToolSelectorConfig, type LangChainMatchers, MIDDLEWARE_BRAND, MiddlewareError, MiddlewareResult, MiddlewareTypeConfig, ModelCallLimitMiddlewareConfig, ModelRequest, ModelRetryMiddlewareConfig, MultipleStructuredOutputsError, MultipleToolsBoundError, N, NormalizedSchemaInput, NormalizedSchemaUpdate, OpenAIModerationMiddlewareOptions, PIIDetectionError, PIIDetector, PIIMatch, PIIMiddlewareConfig, PIIRedactionMiddlewareConfig, PIIStrategy, PromptCachingMiddlewareConfig, ProviderStrategy, ReactAgent, RedactionRuleConfig, RejectDecision, ResolveAgentTypeConfig, ResolveMiddlewareTypeConfig, ResolvedRedactionRule, ResponseFormat, ResponseFormatUndefined, ReviewConfig, Runtime, StructuredOutputParsingError, StructuredTool, SummarizationMiddlewareConfig, SystemMessage, SystemMessageChunk, TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT, ToAnnotationRoot, Todo, TodoListMiddlewareOptions, TokenCounter, Tool, ToolCall, ToolCallHandler, ToolCallLimitConfig, ToolCallLimitExceededError, ToolCallRequest, ToolEmulatorOptions, ToolInvocationError, ToolMessage, ToolMessageChunk, ToolResult, ToolRetryMiddlewareConfig, type ToolRuntime, ToolStrategy, ToolsToMessageToolSet, TypedToolStrategy, UserInput, WithStateGraphNodes, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook, anthropicPromptCachingMiddleware, applyStrategy, context, contextEditingMiddleware, countTokensApproximately, createAgent, createMiddleware, detectCreditCard, detectEmail, detectIP, detectMacAddress, detectUrl, dynamicSystemPromptMiddleware, fakeModel, filterMessages, humanInTheLoopMiddleware, initChatModel, langchainMatchers, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, modelRetryMiddleware, openAIModerationMiddleware, piiMiddleware, piiRedactionMiddleware, providerStrategy, resolveRedactionRule, summarizationMiddleware, todoListMiddleware, tool, toolCallLimitMiddleware, toolEmulatorMiddleware, toolRetryMiddleware, toolStrategy, trimMessages };
|
|
37
|
+
export { AIMessage, AIMessageChunk, Action, ActionRequest, AfterAgentHook, AfterModelHook, AgentMiddleware, AgentTypeConfig, AnyAnnotationRoot, ApproveDecision, BaseMessage, BaseMessageChunk, BeforeAgentHook, BeforeModelHook, BuiltInPIIType, BuiltInState, ClearToolUsesEdit, ClearToolUsesEditConfig, CombineTools, type ContentBlock, ContextEdit, ContextEditingMiddlewareConfig, CreateAgentParams, Decision, DecisionType, DefaultAgentTypeConfig, DefaultMiddlewareTypeConfig, DescriptionFactory, Document, type DocumentInput, DynamicStructuredTool, DynamicSystemPromptMiddlewareConfig, DynamicTool, EditDecision, ExecutedToolCall, ExtractZodArrayTypes, FakeToolCallingModel, HITLRequest, HITLResponse, type HeadlessTool, type HeadlessToolFields, type HeadlessToolImplementation, HumanInTheLoopMiddlewareConfig, HumanMessage, HumanMessageChunk, InMemoryStore, InferAgentContext, InferAgentContextSchema, InferAgentMiddleware, InferAgentResponse, InferAgentState, InferAgentStateSchema, InferAgentTools, InferAgentType, InferChannelType, InferContextInput, InferMergedInputState, InferMergedState, InferMiddlewareContext, InferMiddlewareContextInput, InferMiddlewareContextInputs, InferMiddlewareContextSchema, InferMiddlewareContexts, InferMiddlewareFullContext, InferMiddlewareInputState, InferMiddlewareInputStates, InferMiddlewareSchema, InferMiddlewareState, InferMiddlewareStates, InferMiddlewareTools, InferMiddlewareToolsArray, InferMiddlewareToolsFromConfig, InferMiddlewareType, InferSchemaInput, InferSchemaUpdateType, InferSchemaValue, InferSchemaValueType, Interrupt, InterruptOnConfig, JumpTo, JumpToTarget, LLMToolSelectorConfig, type LangChainMatchers, MIDDLEWARE_BRAND, MiddlewareError, MiddlewareResult, MiddlewareTypeConfig, ModelCallLimitMiddlewareConfig, ModelRequest, ModelRetryMiddlewareConfig, MultipleStructuredOutputsError, MultipleToolsBoundError, N, NormalizedSchemaInput, NormalizedSchemaUpdate, OpenAIModerationMiddlewareOptions, PIIDetectionError, PIIDetector, PIIMatch, PIIMiddlewareConfig, PIIRedactionMiddlewareConfig, PIIStrategy, PromptCachingMiddlewareConfig, ProviderStrategy, ReactAgent, RedactionRuleConfig, RejectDecision, ResolveAgentTypeConfig, ResolveMiddlewareTypeConfig, ResolvedRedactionRule, ResponseFormat, ResponseFormatUndefined, ReviewConfig, Runtime, StructuredOutputParsingError, StructuredTool, SummarizationMiddlewareConfig, SystemMessage, SystemMessageChunk, TODO_LIST_MIDDLEWARE_SYSTEM_PROMPT, ToAnnotationRoot, Todo, TodoListMiddlewareOptions, TokenCounter, Tool, ToolCall, ToolCallHandler, ToolCallLimitConfig, ToolCallLimitExceededError, ToolCallRequest, ToolEmulatorOptions, ToolInvocationError, ToolMessage, ToolMessageChunk, ToolResult, ToolRetryMiddlewareConfig, type ToolRuntime, ToolStrategy, ToolsToMessageToolSet, TypedToolStrategy, UserInput, WithStateGraphNodes, WrapModelCallHandler, WrapModelCallHook, WrapToolCallHook, anthropicPromptCachingMiddleware, applyStrategy, context, contextEditingMiddleware, countTokensApproximately, createAgent, createMiddleware, detectCreditCard, detectEmail, detectIP, detectMacAddress, detectUrl, dynamicSystemPromptMiddleware, fakeModel, filterMessages, humanInTheLoopMiddleware, initChatModel, langchainMatchers, llmToolSelectorMiddleware, modelCallLimitMiddleware, modelFallbackMiddleware, modelRetryMiddleware, openAIModerationMiddleware, piiMiddleware, piiRedactionMiddleware, providerStrategy, resolveRedactionRule, summarizationMiddleware, todoListMiddleware, tool, toolCallLimitMiddleware, toolEmulatorMiddleware, toolRetryMiddleware, toolStrategy, trimMessages };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { initChatModel } from "./chat_models/universal.js";
|
|
3
|
+
import { tool } from "./tools/headless.js";
|
|
3
4
|
import { MiddlewareError, MultipleStructuredOutputsError, MultipleToolsBoundError, StructuredOutputParsingError, ToolInvocationError } from "./agents/errors.js";
|
|
4
5
|
import { ProviderStrategy, ToolStrategy, providerStrategy, toolStrategy } from "./agents/responses.js";
|
|
5
6
|
import { countTokensApproximately } from "./agents/middleware/utils.js";
|
|
@@ -25,7 +26,7 @@ import { openAIModerationMiddleware } from "./agents/middleware/provider/openai/
|
|
|
25
26
|
import { anthropicPromptCachingMiddleware } from "./agents/middleware/provider/anthropic/promptCaching.js";
|
|
26
27
|
import "./agents/middleware/index.js";
|
|
27
28
|
import { AIMessage, AIMessageChunk, BaseMessage, BaseMessageChunk, HumanMessage, HumanMessageChunk, SystemMessage, SystemMessageChunk, ToolMessage, ToolMessageChunk, filterMessages, trimMessages } from "@langchain/core/messages";
|
|
28
|
-
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool
|
|
29
|
+
import { DynamicStructuredTool, DynamicTool, StructuredTool, Tool } from "@langchain/core/tools";
|
|
29
30
|
import { context } from "@langchain/core/utils/context";
|
|
30
31
|
import { InMemoryStore } from "@langchain/core/stores";
|
|
31
32
|
import { Document } from "@langchain/core/documents";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools\n */\nexport {\n tool,\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Agents\n */\nexport * from \"./agents/index.js\";\n\n/**\n * `createAgent` pre-built middleware\n */\nexport * from \"./agents/middleware/index.js\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["/**\n * LangChain Messages\n */\nexport {\n BaseMessage,\n BaseMessageChunk,\n AIMessage,\n AIMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n type ContentBlock,\n filterMessages,\n trimMessages,\n} from \"@langchain/core/messages\";\n\n/**\n * Universal Chat Model\n */\nexport { initChatModel } from \"./chat_models/universal.js\";\n\n/**\n * LangChain Tools with support for headless tools\n */\nexport {\n tool,\n type HeadlessTool,\n type HeadlessToolFields,\n type HeadlessToolImplementation,\n} from \"./tools/headless.js\";\n\n/**\n * LangChain Core Tool Primitives\n */\nexport {\n Tool,\n type ToolRuntime,\n DynamicTool,\n StructuredTool,\n DynamicStructuredTool,\n} from \"@langchain/core/tools\";\n\n/**\n * LangChain utilities\n */\nexport { context } from \"@langchain/core/utils/context\";\n\n/**\n * LangChain Agents\n */\nexport * from \"./agents/index.js\";\n\n/**\n * `createAgent` pre-built middleware\n */\nexport * from \"./agents/middleware/index.js\";\n\n/**\n * LangChain Stores\n */\nexport { InMemoryStore } from \"@langchain/core/stores\";\n\n/**\n * LangChain Documents\n */\nexport { type DocumentInput, Document } from \"@langchain/core/documents\";\n\n/**\n * LangChain Testing Utilities\n */\nexport {\n langchainMatchers,\n type LangChainMatchers,\n fakeModel,\n} from \"@langchain/core/testing\";\n"],"mappings":""}
|
package/dist/load/import_map.cjs
CHANGED
|
@@ -2,6 +2,7 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
|
2
2
|
const require_chat_models_universal = require("../chat_models/universal.cjs");
|
|
3
3
|
const require_index = require("../index.cjs");
|
|
4
4
|
const require_browser = require("../browser.cjs");
|
|
5
|
+
const require_tools_index = require("../tools/index.cjs");
|
|
5
6
|
const require_load_serializable = require("./serializable.cjs");
|
|
6
7
|
const require_storage_encoder_backed = require("../storage/encoder_backed.cjs");
|
|
7
8
|
const require_storage_file_system = require("../storage/file_system.cjs");
|
|
@@ -27,7 +28,8 @@ var import_map_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
27
28
|
schema__runnable: () => schema__runnable,
|
|
28
29
|
storage__encoder_backed: () => require_storage_encoder_backed.encoder_backed_exports,
|
|
29
30
|
storage__file_system: () => require_storage_file_system.file_system_exports,
|
|
30
|
-
storage__in_memory: () => require_storage_in_memory.in_memory_exports
|
|
31
|
+
storage__in_memory: () => require_storage_in_memory.in_memory_exports,
|
|
32
|
+
tools: () => require_tools_index.tools_exports
|
|
31
33
|
});
|
|
32
34
|
const prompts__prompt = { PromptTemplate: _langchain_core_prompts.PromptTemplate };
|
|
33
35
|
const schema = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_map.cjs","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as browser from \"../browser.js\";\nexport * as chat_models__universal from \"../chat_models/universal.js\";\nexport * as index from \"../index.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as storage__encoder_backed from \"../storage/encoder_backed.js\";\nexport * as storage__file_system from \"../storage/file_system.js\";\nexport * as storage__in_memory from \"../storage/in_memory.js\";\nimport {\n PromptTemplate,\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n ImagePromptTemplate,\n PipelinePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n} from \"@langchain/core/messages\";\nimport { StringPromptValue } from \"@langchain/core/prompt_values\";\nimport {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n} from \"@langchain/core/runnables\";\nimport { ChatGenerationChunk, GenerationChunk } from \"@langchain/core/outputs\";\nconst prompts__prompt = {\n PromptTemplate,\n};\nexport { prompts__prompt };\nconst schema = {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n};\nexport { schema };\nconst prompts__chat = {\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n};\nexport { prompts__chat };\nconst prompts__image = {\n ImagePromptTemplate,\n};\nexport { prompts__image };\nconst prompts__pipeline = {\n PipelinePromptTemplate,\n};\nexport { prompts__pipeline };\nconst prompts__base = {\n StringPromptValue,\n};\nexport { prompts__base };\nconst schema__runnable = {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n};\nexport { schema__runnable };\nconst schema__output = {\n ChatGenerationChunk,\n GenerationChunk,\n};\nexport { schema__output };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import_map.cjs","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as browser from \"../browser.js\";\nexport * as chat_models__universal from \"../chat_models/universal.js\";\nexport * as index from \"../index.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as storage__encoder_backed from \"../storage/encoder_backed.js\";\nexport * as storage__file_system from \"../storage/file_system.js\";\nexport * as storage__in_memory from \"../storage/in_memory.js\";\nexport * as tools from \"../tools/index.js\";\nimport {\n PromptTemplate,\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n ImagePromptTemplate,\n PipelinePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n} from \"@langchain/core/messages\";\nimport { StringPromptValue } from \"@langchain/core/prompt_values\";\nimport {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n} from \"@langchain/core/runnables\";\nimport { ChatGenerationChunk, GenerationChunk } from \"@langchain/core/outputs\";\nconst prompts__prompt = {\n PromptTemplate,\n};\nexport { prompts__prompt };\nconst schema = {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n};\nexport { schema };\nconst prompts__chat = {\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n};\nexport { prompts__chat };\nconst prompts__image = {\n ImagePromptTemplate,\n};\nexport { prompts__image };\nconst prompts__pipeline = {\n PipelinePromptTemplate,\n};\nexport { prompts__pipeline };\nconst prompts__base = {\n StringPromptValue,\n};\nexport { prompts__base };\nconst schema__runnable = {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n};\nexport { schema__runnable };\nconst schema__output = {\n ChatGenerationChunk,\n GenerationChunk,\n};\nexport { schema__output };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,kBAAkB,EACtB,gBAAA,wBAAA,gBACD;AAED,MAAM,SAAS;CACb,WAAA,yBAAA;CACA,gBAAA,yBAAA;CACA,aAAA,yBAAA;CACA,kBAAA,yBAAA;CACA,aAAA,yBAAA;CACA,kBAAA,yBAAA;CACA,iBAAA,yBAAA;CACA,sBAAA,yBAAA;CACA,cAAA,yBAAA;CACA,mBAAA,yBAAA;CACA,eAAA,yBAAA;CACA,oBAAA,yBAAA;CACA,aAAA,yBAAA;CACA,kBAAA,yBAAA;CACD;AAED,MAAM,gBAAgB;CACpB,yBAAA,wBAAA;CACA,2BAAA,wBAAA;CACA,oBAAA,wBAAA;CACA,4BAAA,wBAAA;CACA,qBAAA,wBAAA;CACA,6BAAA,wBAAA;CACD;AAED,MAAM,iBAAiB,EACrB,qBAAA,wBAAA,qBACD;AAED,MAAM,oBAAoB,EACxB,wBAAA,wBAAA,wBACD;AAED,MAAM,gBAAgB,EACpB,mBAAA,8BAAA,mBACD;AAED,MAAM,mBAAmB;CACvB,gBAAA,0BAAA;CACA,gBAAA,0BAAA;CACA,iBAAA,0BAAA;CACA,gBAAA,0BAAA;CACA,cAAA,0BAAA;CACA,aAAA,0BAAA;CACA,kBAAA,0BAAA;CACA,qBAAA,0BAAA;CACA,cAAA,0BAAA;CACA,eAAA,0BAAA;CACA,kBAAA,0BAAA;CACA,uBAAA,0BAAA;CACA,4BAAA,0BAAA;CACD;AAED,MAAM,iBAAiB;CACrB,qBAAA,wBAAA;CACA,iBAAA,wBAAA;CACD"}
|
package/dist/load/import_map.js
CHANGED
|
@@ -2,6 +2,7 @@ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { universal_exports } from "../chat_models/universal.js";
|
|
3
3
|
import { src_exports } from "../index.js";
|
|
4
4
|
import { browser_exports } from "../browser.js";
|
|
5
|
+
import { tools_exports } from "../tools/index.js";
|
|
5
6
|
import { serializable_exports } from "./serializable.js";
|
|
6
7
|
import { encoder_backed_exports } from "../storage/encoder_backed.js";
|
|
7
8
|
import { file_system_exports } from "../storage/file_system.js";
|
|
@@ -27,7 +28,8 @@ var import_map_exports = /* @__PURE__ */ __exportAll({
|
|
|
27
28
|
schema__runnable: () => schema__runnable,
|
|
28
29
|
storage__encoder_backed: () => encoder_backed_exports,
|
|
29
30
|
storage__file_system: () => file_system_exports,
|
|
30
|
-
storage__in_memory: () => in_memory_exports
|
|
31
|
+
storage__in_memory: () => in_memory_exports,
|
|
32
|
+
tools: () => tools_exports
|
|
31
33
|
});
|
|
32
34
|
const prompts__prompt = { PromptTemplate };
|
|
33
35
|
const schema = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as browser from \"../browser.js\";\nexport * as chat_models__universal from \"../chat_models/universal.js\";\nexport * as index from \"../index.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as storage__encoder_backed from \"../storage/encoder_backed.js\";\nexport * as storage__file_system from \"../storage/file_system.js\";\nexport * as storage__in_memory from \"../storage/in_memory.js\";\nimport {\n PromptTemplate,\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n ImagePromptTemplate,\n PipelinePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n} from \"@langchain/core/messages\";\nimport { StringPromptValue } from \"@langchain/core/prompt_values\";\nimport {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n} from \"@langchain/core/runnables\";\nimport { ChatGenerationChunk, GenerationChunk } from \"@langchain/core/outputs\";\nconst prompts__prompt = {\n PromptTemplate,\n};\nexport { prompts__prompt };\nconst schema = {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n};\nexport { schema };\nconst prompts__chat = {\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n};\nexport { prompts__chat };\nconst prompts__image = {\n ImagePromptTemplate,\n};\nexport { prompts__image };\nconst prompts__pipeline = {\n PipelinePromptTemplate,\n};\nexport { prompts__pipeline };\nconst prompts__base = {\n StringPromptValue,\n};\nexport { prompts__base };\nconst schema__runnable = {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n};\nexport { schema__runnable };\nconst schema__output = {\n ChatGenerationChunk,\n GenerationChunk,\n};\nexport { schema__output };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"import_map.js","names":[],"sources":["../../src/load/import_map.ts"],"sourcesContent":["/** Auto-generated by import-map plugin. Do not edit manually */\n\nexport * as browser from \"../browser.js\";\nexport * as chat_models__universal from \"../chat_models/universal.js\";\nexport * as index from \"../index.js\";\nexport * as load__serializable from \"../load/serializable.js\";\nexport * as storage__encoder_backed from \"../storage/encoder_backed.js\";\nexport * as storage__file_system from \"../storage/file_system.js\";\nexport * as storage__in_memory from \"../storage/in_memory.js\";\nexport * as tools from \"../tools/index.js\";\nimport {\n PromptTemplate,\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n ImagePromptTemplate,\n PipelinePromptTemplate,\n} from \"@langchain/core/prompts\";\nimport {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n} from \"@langchain/core/messages\";\nimport { StringPromptValue } from \"@langchain/core/prompt_values\";\nimport {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n} from \"@langchain/core/runnables\";\nimport { ChatGenerationChunk, GenerationChunk } from \"@langchain/core/outputs\";\nconst prompts__prompt = {\n PromptTemplate,\n};\nexport { prompts__prompt };\nconst schema = {\n AIMessage,\n AIMessageChunk,\n BaseMessage,\n BaseMessageChunk,\n ChatMessage,\n ChatMessageChunk,\n FunctionMessage,\n FunctionMessageChunk,\n HumanMessage,\n HumanMessageChunk,\n SystemMessage,\n SystemMessageChunk,\n ToolMessage,\n ToolMessageChunk,\n};\nexport { schema };\nconst prompts__chat = {\n AIMessagePromptTemplate,\n ChatMessagePromptTemplate,\n ChatPromptTemplate,\n HumanMessagePromptTemplate,\n MessagesPlaceholder,\n SystemMessagePromptTemplate,\n};\nexport { prompts__chat };\nconst prompts__image = {\n ImagePromptTemplate,\n};\nexport { prompts__image };\nconst prompts__pipeline = {\n PipelinePromptTemplate,\n};\nexport { prompts__pipeline };\nconst prompts__base = {\n StringPromptValue,\n};\nexport { prompts__base };\nconst schema__runnable = {\n RouterRunnable,\n RunnableAssign,\n RunnableBinding,\n RunnableBranch,\n RunnableEach,\n RunnableMap,\n RunnableParallel,\n RunnablePassthrough,\n RunnablePick,\n RunnableRetry,\n RunnableSequence,\n RunnableWithFallbacks,\n RunnableWithMessageHistory,\n};\nexport { schema__runnable };\nconst schema__output = {\n ChatGenerationChunk,\n GenerationChunk,\n};\nexport { schema__output };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,MAAM,kBAAkB,EACtB,gBACD;AAED,MAAM,SAAS;CACb;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,iBAAiB,EACrB,qBACD;AAED,MAAM,oBAAoB,EACxB,wBACD;AAED,MAAM,gBAAgB,EACpB,mBACD;AAED,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAM,iBAAiB;CACrB;CACA;CACD"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let _langchain_core_tools = require("@langchain/core/tools");
|
|
3
|
+
//#region src/tools/headless.ts
|
|
4
|
+
/**
|
|
5
|
+
* Unified Tool Primitive for LangChain Agents
|
|
6
|
+
*
|
|
7
|
+
* This module re-exports the `tool` primitive from `@langchain/core/tools` with
|
|
8
|
+
* an additional overload: when called without an implementation function, it
|
|
9
|
+
* creates a **headless tool** that interrupts agent execution and delegates the
|
|
10
|
+
* implementation to the client (e.g. via `useStream({ tools: [...] })`).
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
function createHeadlessTool(fields) {
|
|
15
|
+
const { name, description, schema } = fields;
|
|
16
|
+
const wrappedTool = (0, _langchain_core_tools.tool)(async (args, config) => {
|
|
17
|
+
const { interrupt } = await import("@langchain/langgraph");
|
|
18
|
+
return interrupt({
|
|
19
|
+
type: "tool",
|
|
20
|
+
toolCall: {
|
|
21
|
+
id: config?.toolCall?.id,
|
|
22
|
+
name,
|
|
23
|
+
args
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}, {
|
|
27
|
+
name,
|
|
28
|
+
description,
|
|
29
|
+
schema,
|
|
30
|
+
metadata: { headlessTool: true }
|
|
31
|
+
});
|
|
32
|
+
const headlessTool = Object.assign(wrappedTool, { implement: (execute) => ({
|
|
33
|
+
tool: headlessTool,
|
|
34
|
+
execute
|
|
35
|
+
}) });
|
|
36
|
+
return headlessTool;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Unified tool primitive for LangChain agents.
|
|
40
|
+
*
|
|
41
|
+
* Enhances the `tool` function from `@langchain/core/tools` with a headless
|
|
42
|
+
* overload: when called **without** an implementation function, the tool
|
|
43
|
+
* interrupts agent execution and lets the client supply the implementation.
|
|
44
|
+
*
|
|
45
|
+
* ---
|
|
46
|
+
*
|
|
47
|
+
* **Normal tool** — pass an implementation function as the first argument:
|
|
48
|
+
*
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { tool } from "langchain/tools";
|
|
51
|
+
* import { z } from "zod";
|
|
52
|
+
*
|
|
53
|
+
* const getWeather = tool(
|
|
54
|
+
* async ({ city }) => `The weather in ${city} is sunny.`,
|
|
55
|
+
* {
|
|
56
|
+
* name: "get_weather",
|
|
57
|
+
* description: "Get the weather for a city",
|
|
58
|
+
* schema: z.object({ city: z.string() }),
|
|
59
|
+
* }
|
|
60
|
+
* );
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* ---
|
|
64
|
+
*
|
|
65
|
+
* **Headless tool** — omit the implementation; the client provides it later:
|
|
66
|
+
*
|
|
67
|
+
* ```typescript
|
|
68
|
+
* import { tool } from "langchain/tools";
|
|
69
|
+
* import { z } from "zod";
|
|
70
|
+
*
|
|
71
|
+
* // Server: define the tool shape — no implementation needed
|
|
72
|
+
* export const getLocation = tool({
|
|
73
|
+
* name: "get_location",
|
|
74
|
+
* description: "Get the user's current GPS location",
|
|
75
|
+
* schema: z.object({
|
|
76
|
+
* highAccuracy: z.boolean().optional().describe("Request high accuracy GPS"),
|
|
77
|
+
* }),
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Server: register with the agent
|
|
81
|
+
* const agent = createAgent({
|
|
82
|
+
* model: "openai:gpt-4o",
|
|
83
|
+
* tools: [getLocation],
|
|
84
|
+
* });
|
|
85
|
+
*
|
|
86
|
+
* // Client: provide the implementation in useStream
|
|
87
|
+
* const stream = useStream({
|
|
88
|
+
* assistantId: "agent",
|
|
89
|
+
* tools: [
|
|
90
|
+
* getLocation.implement(async ({ highAccuracy }) => {
|
|
91
|
+
* return new Promise((resolve, reject) => {
|
|
92
|
+
* navigator.geolocation.getCurrentPosition(
|
|
93
|
+
* (pos) => resolve({
|
|
94
|
+
* latitude: pos.coords.latitude,
|
|
95
|
+
* longitude: pos.coords.longitude,
|
|
96
|
+
* }),
|
|
97
|
+
* (err) => reject(new Error(err.message)),
|
|
98
|
+
* { enableHighAccuracy: highAccuracy }
|
|
99
|
+
* );
|
|
100
|
+
* });
|
|
101
|
+
* }),
|
|
102
|
+
* ],
|
|
103
|
+
* });
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
const tool = ((funcOrFields, fields) => {
|
|
107
|
+
if (typeof funcOrFields !== "function") return createHeadlessTool(funcOrFields);
|
|
108
|
+
return (0, _langchain_core_tools.tool)(funcOrFields, fields);
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
exports.tool = tool;
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=headless.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless.cjs","names":[],"sources":["../../src/tools/headless.ts"],"sourcesContent":["/**\n * Unified Tool Primitive for LangChain Agents\n *\n * This module re-exports the `tool` primitive from `@langchain/core/tools` with\n * an additional overload: when called without an implementation function, it\n * creates a **headless tool** that interrupts agent execution and delegates the\n * implementation to the client (e.g. via `useStream({ tools: [...] })`).\n *\n * @module\n */\n\nimport {\n tool as coreTool,\n DynamicStructuredTool,\n type ToolRunnableConfig,\n} from \"@langchain/core/tools\";\nimport type {\n InteropZodObject,\n InferInteropZodInput,\n InferInteropZodOutput,\n} from \"@langchain/core/utils/types\";\n\n/**\n * Configuration fields for creating a headless tool.\n */\nexport type HeadlessToolFields<\n SchemaT extends InteropZodObject,\n NameT extends string = string,\n> = {\n /** The name of the tool. Used by the client to match implementations. */\n name: NameT;\n /** Description of what the tool does. */\n description: string;\n /** The Zod schema defining the tool's input. */\n schema: SchemaT;\n};\n\n/**\n * A tool implementation that pairs a headless tool with its execution function.\n *\n * Created by calling `.implement()` on a {@link HeadlessTool}.\n * Pass to `useStream({ tools: [...] })` on the client side.\n */\nexport type HeadlessToolImplementation<\n SchemaT extends InteropZodObject = InteropZodObject,\n OutputT = unknown,\n NameT extends string = string,\n> = {\n tool: HeadlessTool<SchemaT, NameT>;\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;\n};\n\n/**\n * A headless tool that always interrupts agent execution on the server.\n *\n * The implementation is provided separately on the client via\n * `useStream({ tools: [...] })` using `.implement()`.\n */\nexport type HeadlessTool<\n SchemaT extends InteropZodObject = InteropZodObject,\n NameT extends string = string,\n> = DynamicStructuredTool<\n SchemaT,\n InferInteropZodOutput<SchemaT>,\n InferInteropZodInput<SchemaT>,\n unknown,\n unknown,\n NameT\n> & {\n /**\n * Pairs this headless tool with a client-side implementation.\n *\n * The returned object should be passed to `useStream({ tools: [...] })`.\n * The SDK matches the implementation to the tool by name and calls\n * `execute` with the typed arguments from the interrupt payload.\n *\n * @param execute - The function that implements the tool on the client\n */\n implement: <OutputT>(\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>\n ) => HeadlessToolImplementation<SchemaT, OutputT, NameT>;\n};\n\nfunction createHeadlessTool<\n SchemaT extends InteropZodObject,\n NameT extends string,\n>(fields: HeadlessToolFields<SchemaT, NameT>): HeadlessTool<SchemaT, NameT> {\n const { name, description, schema } = fields;\n\n const wrappedTool = coreTool(\n async (\n args: InferInteropZodOutput<SchemaT>,\n config?: ToolRunnableConfig\n ) => {\n const { interrupt } = await import(\"@langchain/langgraph\");\n return interrupt({\n type: \"tool\",\n toolCall: {\n id: config?.toolCall?.id,\n name,\n args,\n },\n });\n },\n {\n name,\n description,\n schema,\n metadata: {\n headlessTool: true,\n },\n }\n );\n\n const headlessTool: HeadlessTool<SchemaT, NameT> = Object.assign(\n wrappedTool,\n {\n implement: <OutputT>(\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>\n ): HeadlessToolImplementation<SchemaT, OutputT, NameT> => ({\n tool: headlessTool,\n execute,\n }),\n }\n ) as HeadlessTool<SchemaT, NameT>;\n\n return headlessTool;\n}\n\n/**\n * The headless overload signature added to the core `tool` function.\n *\n * When called **without** an implementation function — just `tool({ name, description, schema })` —\n * returns a {@link HeadlessTool} that interrupts on every agent invocation.\n * The client provides the implementation via `useStream({ tools: [...] })`.\n */\ntype HeadlessToolOverload = {\n <SchemaT extends InteropZodObject, NameT extends string>(\n fields: HeadlessToolFields<SchemaT, NameT>\n ): HeadlessTool<SchemaT, NameT>;\n};\n\n/**\n * Unified tool primitive for LangChain agents.\n *\n * Enhances the `tool` function from `@langchain/core/tools` with a headless\n * overload: when called **without** an implementation function, the tool\n * interrupts agent execution and lets the client supply the implementation.\n *\n * ---\n *\n * **Normal tool** — pass an implementation function as the first argument:\n *\n * ```typescript\n * import { tool } from \"langchain/tools\";\n * import { z } from \"zod\";\n *\n * const getWeather = tool(\n * async ({ city }) => `The weather in ${city} is sunny.`,\n * {\n * name: \"get_weather\",\n * description: \"Get the weather for a city\",\n * schema: z.object({ city: z.string() }),\n * }\n * );\n * ```\n *\n * ---\n *\n * **Headless tool** — omit the implementation; the client provides it later:\n *\n * ```typescript\n * import { tool } from \"langchain/tools\";\n * import { z } from \"zod\";\n *\n * // Server: define the tool shape — no implementation needed\n * export const getLocation = tool({\n * name: \"get_location\",\n * description: \"Get the user's current GPS location\",\n * schema: z.object({\n * highAccuracy: z.boolean().optional().describe(\"Request high accuracy GPS\"),\n * }),\n * });\n *\n * // Server: register with the agent\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getLocation],\n * });\n *\n * // Client: provide the implementation in useStream\n * const stream = useStream({\n * assistantId: \"agent\",\n * tools: [\n * getLocation.implement(async ({ highAccuracy }) => {\n * return new Promise((resolve, reject) => {\n * navigator.geolocation.getCurrentPosition(\n * (pos) => resolve({\n * latitude: pos.coords.latitude,\n * longitude: pos.coords.longitude,\n * }),\n * (err) => reject(new Error(err.message)),\n * { enableHighAccuracy: highAccuracy }\n * );\n * });\n * }),\n * ],\n * });\n * ```\n */\nexport const tool: HeadlessToolOverload & typeof coreTool = ((\n funcOrFields: unknown,\n fields?: unknown\n) => {\n if (typeof funcOrFields !== \"function\") {\n return createHeadlessTool(\n funcOrFields as HeadlessToolFields<InteropZodObject, string>\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return (coreTool as any)(funcOrFields, fields);\n}) as HeadlessToolOverload & typeof coreTool;\n"],"mappings":";;;;;;;;;;;;;AAmFA,SAAS,mBAGP,QAA0E;CAC1E,MAAM,EAAE,MAAM,aAAa,WAAW;CAEtC,MAAM,eAAA,GAAA,sBAAA,MACJ,OACE,MACA,WACG;EACH,MAAM,EAAE,cAAc,MAAM,OAAO;AACnC,SAAO,UAAU;GACf,MAAM;GACN,UAAU;IACR,IAAI,QAAQ,UAAU;IACtB;IACA;IACD;GACF,CAAC;IAEJ;EACE;EACA;EACA;EACA,UAAU,EACR,cAAc,MACf;EACF,CACF;CAED,MAAM,eAA6C,OAAO,OACxD,aACA,EACE,YACE,aACyD;EACzD,MAAM;EACN;EACD,GACF,CACF;AAED,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFT,MAAa,SACX,cACA,WACG;AACH,KAAI,OAAO,iBAAiB,WAC1B,QAAO,mBACL,aACD;AAGH,SAAA,GAAA,sBAAA,MAAyB,cAAc,OAAO"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { DynamicStructuredTool, tool } from "@langchain/core/tools";
|
|
2
|
+
import { InferInteropZodInput, InferInteropZodOutput, InteropZodObject } from "@langchain/core/utils/types";
|
|
3
|
+
|
|
4
|
+
//#region src/tools/headless.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Configuration fields for creating a headless tool.
|
|
7
|
+
*/
|
|
8
|
+
type HeadlessToolFields<SchemaT extends InteropZodObject, NameT extends string = string> = {
|
|
9
|
+
/** The name of the tool. Used by the client to match implementations. */name: NameT; /** Description of what the tool does. */
|
|
10
|
+
description: string; /** The Zod schema defining the tool's input. */
|
|
11
|
+
schema: SchemaT;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A tool implementation that pairs a headless tool with its execution function.
|
|
15
|
+
*
|
|
16
|
+
* Created by calling `.implement()` on a {@link HeadlessTool}.
|
|
17
|
+
* Pass to `useStream({ tools: [...] })` on the client side.
|
|
18
|
+
*/
|
|
19
|
+
type HeadlessToolImplementation<SchemaT extends InteropZodObject = InteropZodObject, OutputT = unknown, NameT extends string = string> = {
|
|
20
|
+
tool: HeadlessTool<SchemaT, NameT>;
|
|
21
|
+
execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A headless tool that always interrupts agent execution on the server.
|
|
25
|
+
*
|
|
26
|
+
* The implementation is provided separately on the client via
|
|
27
|
+
* `useStream({ tools: [...] })` using `.implement()`.
|
|
28
|
+
*/
|
|
29
|
+
type HeadlessTool<SchemaT extends InteropZodObject = InteropZodObject, NameT extends string = string> = DynamicStructuredTool<SchemaT, InferInteropZodOutput<SchemaT>, InferInteropZodInput<SchemaT>, unknown, unknown, NameT> & {
|
|
30
|
+
/**
|
|
31
|
+
* Pairs this headless tool with a client-side implementation.
|
|
32
|
+
*
|
|
33
|
+
* The returned object should be passed to `useStream({ tools: [...] })`.
|
|
34
|
+
* The SDK matches the implementation to the tool by name and calls
|
|
35
|
+
* `execute` with the typed arguments from the interrupt payload.
|
|
36
|
+
*
|
|
37
|
+
* @param execute - The function that implements the tool on the client
|
|
38
|
+
*/
|
|
39
|
+
implement: <OutputT>(execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>) => HeadlessToolImplementation<SchemaT, OutputT, NameT>;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The headless overload signature added to the core `tool` function.
|
|
43
|
+
*
|
|
44
|
+
* When called **without** an implementation function — just `tool({ name, description, schema })` —
|
|
45
|
+
* returns a {@link HeadlessTool} that interrupts on every agent invocation.
|
|
46
|
+
* The client provides the implementation via `useStream({ tools: [...] })`.
|
|
47
|
+
*/
|
|
48
|
+
type HeadlessToolOverload = {
|
|
49
|
+
<SchemaT extends InteropZodObject, NameT extends string>(fields: HeadlessToolFields<SchemaT, NameT>): HeadlessTool<SchemaT, NameT>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Unified tool primitive for LangChain agents.
|
|
53
|
+
*
|
|
54
|
+
* Enhances the `tool` function from `@langchain/core/tools` with a headless
|
|
55
|
+
* overload: when called **without** an implementation function, the tool
|
|
56
|
+
* interrupts agent execution and lets the client supply the implementation.
|
|
57
|
+
*
|
|
58
|
+
* ---
|
|
59
|
+
*
|
|
60
|
+
* **Normal tool** — pass an implementation function as the first argument:
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import { tool } from "langchain/tools";
|
|
64
|
+
* import { z } from "zod";
|
|
65
|
+
*
|
|
66
|
+
* const getWeather = tool(
|
|
67
|
+
* async ({ city }) => `The weather in ${city} is sunny.`,
|
|
68
|
+
* {
|
|
69
|
+
* name: "get_weather",
|
|
70
|
+
* description: "Get the weather for a city",
|
|
71
|
+
* schema: z.object({ city: z.string() }),
|
|
72
|
+
* }
|
|
73
|
+
* );
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* ---
|
|
77
|
+
*
|
|
78
|
+
* **Headless tool** — omit the implementation; the client provides it later:
|
|
79
|
+
*
|
|
80
|
+
* ```typescript
|
|
81
|
+
* import { tool } from "langchain/tools";
|
|
82
|
+
* import { z } from "zod";
|
|
83
|
+
*
|
|
84
|
+
* // Server: define the tool shape — no implementation needed
|
|
85
|
+
* export const getLocation = tool({
|
|
86
|
+
* name: "get_location",
|
|
87
|
+
* description: "Get the user's current GPS location",
|
|
88
|
+
* schema: z.object({
|
|
89
|
+
* highAccuracy: z.boolean().optional().describe("Request high accuracy GPS"),
|
|
90
|
+
* }),
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* // Server: register with the agent
|
|
94
|
+
* const agent = createAgent({
|
|
95
|
+
* model: "openai:gpt-4o",
|
|
96
|
+
* tools: [getLocation],
|
|
97
|
+
* });
|
|
98
|
+
*
|
|
99
|
+
* // Client: provide the implementation in useStream
|
|
100
|
+
* const stream = useStream({
|
|
101
|
+
* assistantId: "agent",
|
|
102
|
+
* tools: [
|
|
103
|
+
* getLocation.implement(async ({ highAccuracy }) => {
|
|
104
|
+
* return new Promise((resolve, reject) => {
|
|
105
|
+
* navigator.geolocation.getCurrentPosition(
|
|
106
|
+
* (pos) => resolve({
|
|
107
|
+
* latitude: pos.coords.latitude,
|
|
108
|
+
* longitude: pos.coords.longitude,
|
|
109
|
+
* }),
|
|
110
|
+
* (err) => reject(new Error(err.message)),
|
|
111
|
+
* { enableHighAccuracy: highAccuracy }
|
|
112
|
+
* );
|
|
113
|
+
* });
|
|
114
|
+
* }),
|
|
115
|
+
* ],
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
declare const tool$1: HeadlessToolOverload & typeof tool;
|
|
120
|
+
//#endregion
|
|
121
|
+
export { HeadlessTool, HeadlessToolFields, HeadlessToolImplementation, tool$1 as tool };
|
|
122
|
+
//# sourceMappingURL=headless.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headless.d.cts","names":[],"sources":["../../src/tools/headless.ts"],"mappings":";;;;;;;KAyBY,kBAAA,iBACM,gBAAA;EAIV,yEAAN,IAAA,EAAM,KAAA,EAIN;EAFA,WAAA,UAEe;EAAf,MAAA,EAAQ,OAAA;AAAA;;;;;;;KASE,0BAAA,iBACM,gBAAA,GAAmB,gBAAA;EAInC,IAAA,EAAM,YAAA,CAAa,OAAA,EAAS,KAAA;EAC5B,OAAA,GAAU,IAAA,EAAM,qBAAA,CAAsB,OAAA,MAAa,OAAA,CAAQ,OAAA;AAAA;;;;;;;KASjD,YAAA,iBACM,gBAAA,GAAmB,gBAAA,mCAEjC,qBAAA,CACF,OAAA,EACA,qBAAA,CAAsB,OAAA,GACtB,oBAAA,CAAqB,OAAA,qBAGrB,KAAA;EArBA;;;;;;;;;EAgCA,SAAA,YACE,OAAA,GAAU,IAAA,EAAM,qBAAA,CAAsB,OAAA,MAAa,OAAA,CAAQ,OAAA,MACxD,0BAAA,CAA2B,OAAA,EAAS,OAAA,EAAS,KAAA;AAAA;;;AAtBpD;;;;;KA8EK,oBAAA;EAAA,iBACc,gBAAA,wBACf,MAAA,EAAQ,kBAAA,CAAmB,OAAA,EAAS,KAAA,IACnC,YAAA,CAAa,OAAA,EAAS,KAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA1DzB;;;;;;;;;;;;;;;;;;;;;;;;AAiIF;;;;;cAAa,MAAA,EAAM,oBAAA,UAA8B,IAAA"}
|