langchain 1.2.2 → 1.2.3-dev-1766775128110

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.
Files changed (69) hide show
  1. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  2. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  3. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  4. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  5. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  6. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  7. package/dist/agents/middleware/llmToolSelector.d.ts +4 -4
  8. package/dist/agents/middleware/llmToolSelector.d.ts.map +1 -1
  9. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -1
  10. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -1
  11. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  12. package/dist/agents/middleware/summarization.d.ts +7 -7
  13. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  14. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
  15. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
  16. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  17. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  18. package/dist/agents/middleware/types.d.cts.map +1 -1
  19. package/dist/agents/middleware/utils.d.cts.map +1 -1
  20. package/dist/agents/middleware/utils.d.ts.map +1 -1
  21. package/dist/agents/responses.d.cts.map +1 -1
  22. package/dist/agents/types.d.cts.map +1 -1
  23. package/dist/index.cjs +3 -0
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +2 -1
  26. package/dist/index.d.ts +2 -1
  27. package/dist/index.js +3 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/tools/browser.cjs +84 -0
  30. package/dist/tools/browser.cjs.map +1 -0
  31. package/dist/tools/browser.d.cts +77 -0
  32. package/dist/tools/browser.d.cts.map +1 -0
  33. package/dist/tools/browser.d.ts +77 -0
  34. package/dist/tools/browser.d.ts.map +1 -0
  35. package/dist/tools/browser.js +83 -0
  36. package/dist/tools/browser.js.map +1 -0
  37. package/package.json +4 -4
  38. package/chat_models/universal.cjs +0 -1
  39. package/chat_models/universal.d.cts +0 -1
  40. package/chat_models/universal.d.ts +0 -1
  41. package/chat_models/universal.js +0 -1
  42. package/hub/node.cjs +0 -1
  43. package/hub/node.d.cts +0 -1
  44. package/hub/node.d.ts +0 -1
  45. package/hub/node.js +0 -1
  46. package/hub.cjs +0 -1
  47. package/hub.d.cts +0 -1
  48. package/hub.d.ts +0 -1
  49. package/hub.js +0 -1
  50. package/load/serializable.cjs +0 -1
  51. package/load/serializable.d.cts +0 -1
  52. package/load/serializable.d.ts +0 -1
  53. package/load/serializable.js +0 -1
  54. package/load.cjs +0 -1
  55. package/load.d.cts +0 -1
  56. package/load.d.ts +0 -1
  57. package/load.js +0 -1
  58. package/storage/encoder_backed.cjs +0 -1
  59. package/storage/encoder_backed.d.cts +0 -1
  60. package/storage/encoder_backed.d.ts +0 -1
  61. package/storage/encoder_backed.js +0 -1
  62. package/storage/file_system.cjs +0 -1
  63. package/storage/file_system.d.cts +0 -1
  64. package/storage/file_system.d.ts +0 -1
  65. package/storage/file_system.js +0 -1
  66. package/storage/in_memory.cjs +0 -1
  67. package/storage/in_memory.d.cts +0 -1
  68. package/storage/in_memory.d.ts +0 -1
  69. package/storage/in_memory.js +0 -1
@@ -0,0 +1,77 @@
1
+ import { DynamicStructuredTool, ToolWrapperParams } from "@langchain/core/tools";
2
+ import { InferInteropZodOutput, InteropZodObject } from "@langchain/core/utils/types";
3
+
4
+ //#region src/tools/browser.d.ts
5
+
6
+ /**
7
+ * Configuration fields for creating a browser tool.
8
+ */
9
+ type BrowserToolFields<SchemaT extends InteropZodObject> = ToolWrapperParams<SchemaT> & Required<Pick<ToolWrapperParams<SchemaT>, "description" | "schema">>;
10
+ /**
11
+ * A browser tool that can be used in both server and client environments.
12
+ *
13
+ * On the server, it returns a Command that interrupts execution.
14
+ * On the client, it executes the tool directly.
15
+ */
16
+ type BrowserTool<SchemaT extends InteropZodObject = InteropZodObject, OutputT = unknown> = DynamicStructuredTool<SchemaT> & {
17
+ /**
18
+ * The execute function for client-side use.
19
+ * Called by `useStream` when the interrupt is received.
20
+ */
21
+ execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;
22
+ };
23
+ /**
24
+ * Creates a browser tool that interrupts on the server and executes on the client.
25
+ *
26
+ * Browser tools are defined once and work in both environments:
27
+ * - **Server**: Returns a `Command` that interrupts with the tool call details
28
+ * - **Browser**: Executes the tool directly using browser APIs
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { browserTool } from "langchain/tools/browser";
33
+ * import { z } from "zod";
34
+ *
35
+ * export const getLocation = browserTool(
36
+ * async ({ highAccuracy }) => {
37
+ * return new Promise((resolve, reject) => {
38
+ * navigator.geolocation.getCurrentPosition(
39
+ * (pos) => resolve({
40
+ * latitude: pos.coords.latitude,
41
+ * longitude: pos.coords.longitude,
42
+ * }),
43
+ * (err) => reject(new Error(err.message)),
44
+ * { enableHighAccuracy: highAccuracy }
45
+ * );
46
+ * });
47
+ * },
48
+ * {
49
+ * name: "get_location",
50
+ * description: "Get the user's current GPS location",
51
+ * schema: z.object({
52
+ * highAccuracy: z.boolean().optional().describe("Request high accuracy GPS"),
53
+ * }),
54
+ * }
55
+ * );
56
+ *
57
+ * // Use in createAgent (server)
58
+ * const agent = createAgent({
59
+ * model: "openai:gpt-4o",
60
+ * tools: [getLocation],
61
+ * });
62
+ *
63
+ * // Use in useStream (client)
64
+ * const stream = useStream({
65
+ * assistantId: "agent",
66
+ * browserTools: [getLocation],
67
+ * });
68
+ * ```
69
+ *
70
+ * @param execute - The function that executes the tool in the browser
71
+ * @param fields - The tool configuration (name, description, schema)
72
+ * @returns A browser tool that can be used in both environments
73
+ */
74
+ declare function browserTool<SchemaT extends InteropZodObject, OutputT = unknown>(execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>, fields: BrowserToolFields<SchemaT>): BrowserTool<SchemaT, OutputT>;
75
+ //#endregion
76
+ export { BrowserTool, BrowserToolFields, browserTool };
77
+ //# sourceMappingURL=browser.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.cts","names":["DynamicStructuredTool","ToolWrapperParams","InteropZodObject","InferInteropZodOutput","BrowserToolFields","SchemaT","Pick","Required","BrowserTool","OutputT","Promise","browserTool"],"sources":["../../src/tools/browser.d.ts"],"sourcesContent":["/**\n * Browser Tools for LangChain Agents\n *\n * This module provides the `browserTool` primitive for creating tools that\n * execute in the browser while the agent runs on the server.\n *\n * @module\n */\nimport { DynamicStructuredTool, type ToolWrapperParams } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InferInteropZodOutput } from \"@langchain/core/utils/types\";\n/**\n * Configuration fields for creating a browser tool.\n */\nexport type BrowserToolFields<SchemaT extends InteropZodObject> = ToolWrapperParams<SchemaT> & Required<Pick<ToolWrapperParams<SchemaT>, \"description\" | \"schema\">>;\n/**\n * A browser tool that can be used in both server and client environments.\n *\n * On the server, it returns a Command that interrupts execution.\n * On the client, it executes the tool directly.\n */\nexport type BrowserTool<SchemaT extends InteropZodObject = InteropZodObject, OutputT = unknown> = DynamicStructuredTool<SchemaT> & {\n /**\n * The execute function for client-side use.\n * Called by `useStream` when the interrupt is received.\n */\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;\n};\n/**\n * Creates a browser tool that interrupts on the server and executes on the client.\n *\n * Browser tools are defined once and work in both environments:\n * - **Server**: Returns a `Command` that interrupts with the tool call details\n * - **Browser**: Executes the tool directly using browser APIs\n *\n * @example\n * ```typescript\n * import { browserTool } from \"langchain/tools/browser\";\n * import { z } from \"zod\";\n *\n * export const getLocation = browserTool(\n * 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 * 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 *\n * // Use in createAgent (server)\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getLocation],\n * });\n *\n * // Use in useStream (client)\n * const stream = useStream({\n * assistantId: \"agent\",\n * browserTools: [getLocation],\n * });\n * ```\n *\n * @param execute - The function that executes the tool in the browser\n * @param fields - The tool configuration (name, description, schema)\n * @returns A browser tool that can be used in both environments\n */\nexport declare function browserTool<SchemaT extends InteropZodObject, OutputT = unknown>(execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>, fields: BrowserToolFields<SchemaT>): BrowserTool<SchemaT, OutputT>;\n//# sourceMappingURL=browser.d.ts.map"],"mappings":";;;;;;;AAauG;AAO3FQ,KAPAJ,iBAOWC,CAAAA,gBAPuBH,gBAOvB,CAAA,GAP2CD,iBAO3C,CAP6DI,OAO7D,CAAA,GAPwEE,QAOxE,CAPiFD,IAOjF,CAPsFL,iBAOtF,CAPwGI,OAOxG,CAAA,EAAA,aAAA,GAAA,QAAA,CAAA,CAAA;;;;;;;AAKwCI,KALnDD,WAKmDC,CAAAA,gBALvBP,gBAKuBO,GALJP,gBAKIO,EAAAA,UAAAA,OAAAA,CAAAA,GALmCT,qBAKnCS,CALyDJ,OAKzDI,CAAAA,GAAAA;EAARC;AAAO;AAqD9D;;EAA+HL,OAAAA,EAAAA,CAAAA,IAAAA,EArD3GF,qBAqD2GE,CArDrFA,OAqDqFA,CAAAA,EAAAA,GArDxEK,OAqDwEL,CArDhEI,OAqDgEJ,CAAAA;CAAtBF;;;;;;;;AAAqG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtLQ,4BAA4BT,qDAAqDC,sBAAsBE,aAAaK,QAAQD,kBAAkBL,kBAAkBC,WAAWG,YAAYH,SAASI"}
@@ -0,0 +1,77 @@
1
+ import { DynamicStructuredTool, ToolWrapperParams } from "@langchain/core/tools";
2
+ import { InferInteropZodOutput, InteropZodObject } from "@langchain/core/utils/types";
3
+
4
+ //#region src/tools/browser.d.ts
5
+
6
+ /**
7
+ * Configuration fields for creating a browser tool.
8
+ */
9
+ type BrowserToolFields<SchemaT extends InteropZodObject> = ToolWrapperParams<SchemaT> & Required<Pick<ToolWrapperParams<SchemaT>, "description" | "schema">>;
10
+ /**
11
+ * A browser tool that can be used in both server and client environments.
12
+ *
13
+ * On the server, it returns a Command that interrupts execution.
14
+ * On the client, it executes the tool directly.
15
+ */
16
+ type BrowserTool<SchemaT extends InteropZodObject = InteropZodObject, OutputT = unknown> = DynamicStructuredTool<SchemaT> & {
17
+ /**
18
+ * The execute function for client-side use.
19
+ * Called by `useStream` when the interrupt is received.
20
+ */
21
+ execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;
22
+ };
23
+ /**
24
+ * Creates a browser tool that interrupts on the server and executes on the client.
25
+ *
26
+ * Browser tools are defined once and work in both environments:
27
+ * - **Server**: Returns a `Command` that interrupts with the tool call details
28
+ * - **Browser**: Executes the tool directly using browser APIs
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * import { browserTool } from "langchain/tools/browser";
33
+ * import { z } from "zod";
34
+ *
35
+ * export const getLocation = browserTool(
36
+ * async ({ highAccuracy }) => {
37
+ * return new Promise((resolve, reject) => {
38
+ * navigator.geolocation.getCurrentPosition(
39
+ * (pos) => resolve({
40
+ * latitude: pos.coords.latitude,
41
+ * longitude: pos.coords.longitude,
42
+ * }),
43
+ * (err) => reject(new Error(err.message)),
44
+ * { enableHighAccuracy: highAccuracy }
45
+ * );
46
+ * });
47
+ * },
48
+ * {
49
+ * name: "get_location",
50
+ * description: "Get the user's current GPS location",
51
+ * schema: z.object({
52
+ * highAccuracy: z.boolean().optional().describe("Request high accuracy GPS"),
53
+ * }),
54
+ * }
55
+ * );
56
+ *
57
+ * // Use in createAgent (server)
58
+ * const agent = createAgent({
59
+ * model: "openai:gpt-4o",
60
+ * tools: [getLocation],
61
+ * });
62
+ *
63
+ * // Use in useStream (client)
64
+ * const stream = useStream({
65
+ * assistantId: "agent",
66
+ * browserTools: [getLocation],
67
+ * });
68
+ * ```
69
+ *
70
+ * @param execute - The function that executes the tool in the browser
71
+ * @param fields - The tool configuration (name, description, schema)
72
+ * @returns A browser tool that can be used in both environments
73
+ */
74
+ declare function browserTool<SchemaT extends InteropZodObject, OutputT = unknown>(execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>, fields: BrowserToolFields<SchemaT>): BrowserTool<SchemaT, OutputT>;
75
+ //#endregion
76
+ export { BrowserTool, BrowserToolFields, browserTool };
77
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","names":["DynamicStructuredTool","ToolWrapperParams","InteropZodObject","InferInteropZodOutput","BrowserToolFields","SchemaT","Pick","Required","BrowserTool","OutputT","Promise","browserTool"],"sources":["../../src/tools/browser.d.ts"],"sourcesContent":["/**\n * Browser Tools for LangChain Agents\n *\n * This module provides the `browserTool` primitive for creating tools that\n * execute in the browser while the agent runs on the server.\n *\n * @module\n */\nimport { DynamicStructuredTool, type ToolWrapperParams } from \"@langchain/core/tools\";\nimport type { InteropZodObject, InferInteropZodOutput } from \"@langchain/core/utils/types\";\n/**\n * Configuration fields for creating a browser tool.\n */\nexport type BrowserToolFields<SchemaT extends InteropZodObject> = ToolWrapperParams<SchemaT> & Required<Pick<ToolWrapperParams<SchemaT>, \"description\" | \"schema\">>;\n/**\n * A browser tool that can be used in both server and client environments.\n *\n * On the server, it returns a Command that interrupts execution.\n * On the client, it executes the tool directly.\n */\nexport type BrowserTool<SchemaT extends InteropZodObject = InteropZodObject, OutputT = unknown> = DynamicStructuredTool<SchemaT> & {\n /**\n * The execute function for client-side use.\n * Called by `useStream` when the interrupt is received.\n */\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;\n};\n/**\n * Creates a browser tool that interrupts on the server and executes on the client.\n *\n * Browser tools are defined once and work in both environments:\n * - **Server**: Returns a `Command` that interrupts with the tool call details\n * - **Browser**: Executes the tool directly using browser APIs\n *\n * @example\n * ```typescript\n * import { browserTool } from \"langchain/tools/browser\";\n * import { z } from \"zod\";\n *\n * export const getLocation = browserTool(\n * 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 * 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 *\n * // Use in createAgent (server)\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getLocation],\n * });\n *\n * // Use in useStream (client)\n * const stream = useStream({\n * assistantId: \"agent\",\n * browserTools: [getLocation],\n * });\n * ```\n *\n * @param execute - The function that executes the tool in the browser\n * @param fields - The tool configuration (name, description, schema)\n * @returns A browser tool that can be used in both environments\n */\nexport declare function browserTool<SchemaT extends InteropZodObject, OutputT = unknown>(execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>, fields: BrowserToolFields<SchemaT>): BrowserTool<SchemaT, OutputT>;\n//# sourceMappingURL=browser.d.ts.map"],"mappings":";;;;;;;AAauG;AAO3FQ,KAPAJ,iBAOWC,CAAAA,gBAPuBH,gBAOvB,CAAA,GAP2CD,iBAO3C,CAP6DI,OAO7D,CAAA,GAPwEE,QAOxE,CAPiFD,IAOjF,CAPsFL,iBAOtF,CAPwGI,OAOxG,CAAA,EAAA,aAAA,GAAA,QAAA,CAAA,CAAA;;;;;;;AAKwCI,KALnDD,WAKmDC,CAAAA,gBALvBP,gBAKuBO,GALJP,gBAKIO,EAAAA,UAAAA,OAAAA,CAAAA,GALmCT,qBAKnCS,CALyDJ,OAKzDI,CAAAA,GAAAA;EAARC;AAAO;AAqD9D;;EAA+HL,OAAAA,EAAAA,CAAAA,IAAAA,EArD3GF,qBAqD2GE,CArDrFA,OAqDqFA,CAAAA,EAAAA,GArDxEK,OAqDwEL,CArDhEI,OAqDgEJ,CAAAA;CAAtBF;;;;;;;;AAAqG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAtLQ,4BAA4BT,qDAAqDC,sBAAsBE,aAAaK,QAAQD,kBAAkBL,kBAAkBC,WAAWG,YAAYH,SAASI"}
@@ -0,0 +1,83 @@
1
+ import { tool } from "@langchain/core/tools";
2
+ import { interrupt } from "@langchain/langgraph";
3
+
4
+ //#region src/tools/browser.ts
5
+ /**
6
+ * Check if we're running in a browser environment.
7
+ */
8
+ const isBrowserEnvironment = () => typeof window !== "undefined" && typeof navigator !== "undefined" && typeof document !== "undefined";
9
+ /**
10
+ * Creates a browser tool that interrupts on the server and executes on the client.
11
+ *
12
+ * Browser tools are defined once and work in both environments:
13
+ * - **Server**: Returns a `Command` that interrupts with the tool call details
14
+ * - **Browser**: Executes the tool directly using browser APIs
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { browserTool } from "langchain/tools/browser";
19
+ * import { z } from "zod";
20
+ *
21
+ * export const getLocation = browserTool(
22
+ * async ({ highAccuracy }) => {
23
+ * return new Promise((resolve, reject) => {
24
+ * navigator.geolocation.getCurrentPosition(
25
+ * (pos) => resolve({
26
+ * latitude: pos.coords.latitude,
27
+ * longitude: pos.coords.longitude,
28
+ * }),
29
+ * (err) => reject(new Error(err.message)),
30
+ * { enableHighAccuracy: highAccuracy }
31
+ * );
32
+ * });
33
+ * },
34
+ * {
35
+ * name: "get_location",
36
+ * description: "Get the user's current GPS location",
37
+ * schema: z.object({
38
+ * highAccuracy: z.boolean().optional().describe("Request high accuracy GPS"),
39
+ * }),
40
+ * }
41
+ * );
42
+ *
43
+ * // Use in createAgent (server)
44
+ * const agent = createAgent({
45
+ * model: "openai:gpt-4o",
46
+ * tools: [getLocation],
47
+ * });
48
+ *
49
+ * // Use in useStream (client)
50
+ * const stream = useStream({
51
+ * assistantId: "agent",
52
+ * browserTools: [getLocation],
53
+ * });
54
+ * ```
55
+ *
56
+ * @param execute - The function that executes the tool in the browser
57
+ * @param fields - The tool configuration (name, description, schema)
58
+ * @returns A browser tool that can be used in both environments
59
+ */
60
+ function browserTool(execute, fields) {
61
+ const { name, description, schema } = fields;
62
+ const wrappedTool = tool(async (args, config) => {
63
+ if (isBrowserEnvironment()) return execute(args);
64
+ return interrupt({
65
+ type: "browser_tool",
66
+ toolCall: {
67
+ id: config?.toolCall?.id,
68
+ name,
69
+ args
70
+ }
71
+ });
72
+ }, {
73
+ name,
74
+ description,
75
+ schema,
76
+ metadata: { browserTool: true }
77
+ });
78
+ return Object.assign(wrappedTool, { execute });
79
+ }
80
+
81
+ //#endregion
82
+ export { browserTool };
83
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","names":["execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>","fields: BrowserToolFields<SchemaT>","coreTool","args: InferInteropZodOutput<SchemaT>","config?: ToolRunnableConfig"],"sources":["../../src/tools/browser.ts"],"sourcesContent":["/**\n * Browser Tools for LangChain Agents\n *\n * This module provides the `browserTool` primitive for creating tools that\n * execute in the browser while the agent runs on the server.\n *\n * @module\n */\n\nimport {\n tool as coreTool,\n DynamicStructuredTool,\n type ToolRunnableConfig,\n type ToolWrapperParams,\n} from \"@langchain/core/tools\";\nimport type {\n InteropZodObject,\n InferInteropZodOutput,\n} from \"@langchain/core/utils/types\";\nimport { interrupt } from \"@langchain/langgraph\";\n\n/**\n * Check if we're running in a browser environment.\n */\nconst isBrowserEnvironment = (): boolean =>\n typeof window !== \"undefined\" &&\n typeof navigator !== \"undefined\" &&\n typeof document !== \"undefined\";\n\n/**\n * Configuration fields for creating a browser tool.\n */\nexport type BrowserToolFields<SchemaT extends InteropZodObject> =\n ToolWrapperParams<SchemaT> &\n Required<Pick<ToolWrapperParams<SchemaT>, \"description\" | \"schema\">>;\n\n/**\n * A browser tool that can be used in both server and client environments.\n *\n * On the server, it returns a Command that interrupts execution.\n * On the client, it executes the tool directly.\n */\nexport type BrowserTool<\n SchemaT extends InteropZodObject = InteropZodObject,\n OutputT = unknown\n> = DynamicStructuredTool<SchemaT> & {\n /**\n * The execute function for client-side use.\n * Called by `useStream` when the interrupt is received.\n */\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>;\n};\n\n/**\n * Creates a browser tool that interrupts on the server and executes on the client.\n *\n * Browser tools are defined once and work in both environments:\n * - **Server**: Returns a `Command` that interrupts with the tool call details\n * - **Browser**: Executes the tool directly using browser APIs\n *\n * @example\n * ```typescript\n * import { browserTool } from \"langchain/tools/browser\";\n * import { z } from \"zod\";\n *\n * export const getLocation = browserTool(\n * 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 * 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 *\n * // Use in createAgent (server)\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getLocation],\n * });\n *\n * // Use in useStream (client)\n * const stream = useStream({\n * assistantId: \"agent\",\n * browserTools: [getLocation],\n * });\n * ```\n *\n * @param execute - The function that executes the tool in the browser\n * @param fields - The tool configuration (name, description, schema)\n * @returns A browser tool that can be used in both environments\n */\nexport function browserTool<\n SchemaT extends InteropZodObject,\n OutputT = unknown\n>(\n execute: (args: InferInteropZodOutput<SchemaT>) => Promise<OutputT>,\n fields: BrowserToolFields<SchemaT>\n): BrowserTool<SchemaT, OutputT> {\n const { name, description, schema } = fields;\n\n // Create the underlying tool using @langchain/core's tool function\n const wrappedTool = coreTool(\n async (\n args: InferInteropZodOutput<SchemaT>,\n config?: ToolRunnableConfig\n ) => {\n // In browser: execute the tool directly\n if (isBrowserEnvironment()) {\n return execute(args);\n }\n\n // On server: interrupt and wait for client to execute\n // The interrupt value contains the tool call details for the client\n return interrupt({\n type: \"browser_tool\",\n toolCall: {\n id: config?.toolCall?.id,\n name,\n args,\n },\n });\n },\n {\n name,\n description,\n schema,\n // Mark as browser tool in metadata for detection\n metadata: {\n browserTool: true,\n },\n }\n );\n\n // Attach the execute function for explicit client-side use (e.g., in useStream)\n return Object.assign(wrappedTool, { execute }) as BrowserTool<\n SchemaT,\n OutputT\n >;\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,uBAAuB,MAC3B,OAAO,WAAW,eAClB,OAAO,cAAc,eACrB,OAAO,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6EtB,SAAgB,YAIdA,SACAC,QAC+B;CAC/B,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;CAGtC,MAAM,cAAcC,KAClB,OACEC,MACAC,WACG;AAEH,MAAI,sBAAsB,CACxB,QAAO,QAAQ,KAAK;AAKtB,SAAO,UAAU;GACf,MAAM;GACN,UAAU;IACR,IAAI,QAAQ,UAAU;IACtB;IACA;GACD;EACF,EAAC;CACH,GACD;EACE;EACA;EACA;EAEA,UAAU,EACR,aAAa,KACd;CACF,EACF;AAGD,QAAO,OAAO,OAAO,aAAa,EAAE,QAAS,EAAC;AAI/C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langchain",
3
- "version": "1.2.2",
3
+ "version": "1.2.3-dev-1766775128110",
4
4
  "description": "Typescript bindings for langchain",
5
5
  "author": "LangChain",
6
6
  "license": "MIT",
@@ -53,15 +53,15 @@
53
53
  "typescript": "~5.8.3",
54
54
  "vitest": "^3.2.4",
55
55
  "yaml": "^2.8.1",
56
- "@langchain/anthropic": "1.3.2",
56
+ "@langchain/anthropic": "1.3.3-dev-1766775128110",
57
57
  "@langchain/cohere": "1.0.1",
58
- "@langchain/core": "1.1.7",
58
+ "@langchain/core": "1.1.8-dev-1766775128110",
59
59
  "@langchain/eslint": "0.1.1",
60
60
  "@langchain/openai": "1.2.0",
61
61
  "@langchain/tsconfig": "0.0.1"
62
62
  },
63
63
  "peerDependencies": {
64
- "@langchain/core": "1.1.7"
64
+ "@langchain/core": "1.1.8-dev-1766775128110"
65
65
  },
66
66
  "dependencies": {
67
67
  "@langchain/langgraph": "^1.0.0",
@@ -1 +0,0 @@
1
- module.exports = require("../dist/chat_models/universal.cjs");
@@ -1 +0,0 @@
1
- export * from "../dist/chat_models/universal.js";
@@ -1 +0,0 @@
1
- export * from "../dist/chat_models/universal.js";
@@ -1 +0,0 @@
1
- export * from "../dist/chat_models/universal.js";
package/hub/node.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = require("../dist/hub/node.cjs");
package/hub/node.d.cts DELETED
@@ -1 +0,0 @@
1
- export * from "../dist/hub/node.js";
package/hub/node.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "../dist/hub/node.js";
package/hub/node.js DELETED
@@ -1 +0,0 @@
1
- export * from "../dist/hub/node.js";
package/hub.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = require("./dist/hub/index.cjs");
package/hub.d.cts DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/hub/index.js";
package/hub.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/hub/index.js";
package/hub.js DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/hub/index.js";
@@ -1 +0,0 @@
1
- module.exports = require("../dist/load/serializable.cjs");
@@ -1 +0,0 @@
1
- export * from "../dist/load/serializable.js";
@@ -1 +0,0 @@
1
- export * from "../dist/load/serializable.js";
@@ -1 +0,0 @@
1
- export * from "../dist/load/serializable.js";
package/load.cjs DELETED
@@ -1 +0,0 @@
1
- module.exports = require("./dist/load/index.cjs");
package/load.d.cts DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/load/index.js";
package/load.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/load/index.js";
package/load.js DELETED
@@ -1 +0,0 @@
1
- export * from "./dist/load/index.js";
@@ -1 +0,0 @@
1
- module.exports = require("../dist/storage/encoder_backed.cjs");
@@ -1 +0,0 @@
1
- export * from "../dist/storage/encoder_backed.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/encoder_backed.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/encoder_backed.js";
@@ -1 +0,0 @@
1
- module.exports = require("../dist/storage/file_system.cjs");
@@ -1 +0,0 @@
1
- export * from "../dist/storage/file_system.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/file_system.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/file_system.js";
@@ -1 +0,0 @@
1
- module.exports = require("../dist/storage/in_memory.cjs");
@@ -1 +0,0 @@
1
- export * from "../dist/storage/in_memory.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/in_memory.js";
@@ -1 +0,0 @@
1
- export * from "../dist/storage/in_memory.js";