@librechat/agents 3.1.24 → 3.1.26

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.
@@ -1,5 +1,6 @@
1
1
  import { DynamicStructuredTool } from '@langchain/core/tools';
2
2
  import type * as t from '@/types';
3
+ import { Constants } from '@/common';
3
4
  export declare const imageExtRegex: RegExp;
4
5
  export declare const getCodeBaseURL: () => string;
5
6
  export declare const CodeExecutionToolSchema: {
@@ -24,5 +25,33 @@ export declare const CodeExecutionToolSchema: {
24
25
  };
25
26
  readonly required: readonly ["lang", "code"];
26
27
  };
28
+ export declare const CodeExecutionToolDescription: string;
29
+ export declare const CodeExecutionToolName = Constants.EXECUTE_CODE;
30
+ export declare const CodeExecutionToolDefinition: {
31
+ readonly name: Constants.EXECUTE_CODE;
32
+ readonly description: string;
33
+ readonly schema: {
34
+ readonly type: "object";
35
+ readonly properties: {
36
+ readonly lang: {
37
+ readonly type: "string";
38
+ readonly enum: readonly ["py", "js", "ts", "c", "cpp", "java", "php", "rs", "go", "d", "f90", "r"];
39
+ readonly description: "The programming language or runtime to execute the code in.";
40
+ };
41
+ readonly code: {
42
+ readonly type: "string";
43
+ readonly description: "The complete, self-contained code to execute, without any truncation or minimization.\n- The environment is stateless; variables and imports don't persist between executions.\n- Generated files from previous executions are automatically available in \"/mnt/data/\".\n- Files from previous executions are automatically available and can be modified in place.\n- Input code **IS ALREADY** displayed to the user, so **DO NOT** repeat it in your response unless asked.\n- Output code **IS NOT** displayed to the user, so **DO** write all desired output explicitly.\n- IMPORTANT: You MUST explicitly print/output ALL results you want the user to see.\n- py: This is not a Jupyter notebook environment. Use `print()` for all outputs.\n- py: Matplotlib: Use `plt.savefig()` to save plots as files.\n- js: use the `console` or `process` methods for all outputs.\n- r: IMPORTANT: No X11 display available. ALL graphics MUST use Cairo library (library(Cairo)).\n- Other languages: use appropriate output functions.";
44
+ };
45
+ readonly args: {
46
+ readonly type: "array";
47
+ readonly items: {
48
+ readonly type: "string";
49
+ };
50
+ readonly description: "Additional arguments to execute the code with. This should only be used if the input code requires additional arguments to run.";
51
+ };
52
+ };
53
+ readonly required: readonly ["lang", "code"];
54
+ };
55
+ };
27
56
  declare function createCodeExecutionTool(params?: t.CodeExecutionToolParams): DynamicStructuredTool;
28
57
  export { createCodeExecutionTool };
@@ -64,3 +64,40 @@ export declare const WebSearchToolSchema: {
64
64
  };
65
65
  readonly required: readonly ["query"];
66
66
  };
67
+ export declare const WebSearchToolName = "web_search";
68
+ export declare const WebSearchToolDescription = "Real-time search. Results have required citation anchors.\n\nNote: Use ONCE per reply unless instructed otherwise.\n\nAnchors:\n- \\ue202turnXtypeY\n- X = turn idx, type = 'search' | 'news' | 'image' | 'ref', Y = item idx\n\nSpecial Markers:\n- \\ue203...\\ue204 \u2014 highlight start/end of cited text (for Standalone or Group citations)\n- \\ue200...\\ue201 \u2014 group block (e.g. \\ue200\\ue202turn0search1\\ue202turn0news2\\ue201)\n\n**CITE EVERY NON-OBVIOUS FACT/QUOTE:**\nUse anchor marker(s) immediately after the statement:\n- Standalone: \"Pure functions produce same output. \\ue202turn0search0\"\n- Standalone (multiple): \"Today's News \\ue202turn0search0\\ue202turn0news0\"\n- Highlight: \"\\ue203Highlight text.\\ue204\\ue202turn0news1\"\n- Group: \"Sources. \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201\"\n- Group Highlight: \"\\ue203Highlight for group.\\ue204 \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201\"\n- Image: \"See photo \\ue202turn0image0.\"\n\n**NEVER use markdown links, [1], or footnotes. CITE ONLY with anchors provided.**";
69
+ export declare const WebSearchToolDefinition: {
70
+ readonly name: "web_search";
71
+ readonly description: "Real-time search. Results have required citation anchors.\n\nNote: Use ONCE per reply unless instructed otherwise.\n\nAnchors:\n- \\ue202turnXtypeY\n- X = turn idx, type = 'search' | 'news' | 'image' | 'ref', Y = item idx\n\nSpecial Markers:\n- \\ue203...\\ue204 — highlight start/end of cited text (for Standalone or Group citations)\n- \\ue200...\\ue201 — group block (e.g. \\ue200\\ue202turn0search1\\ue202turn0news2\\ue201)\n\n**CITE EVERY NON-OBVIOUS FACT/QUOTE:**\nUse anchor marker(s) immediately after the statement:\n- Standalone: \"Pure functions produce same output. \\ue202turn0search0\"\n- Standalone (multiple): \"Today's News \\ue202turn0search0\\ue202turn0news0\"\n- Highlight: \"\\ue203Highlight text.\\ue204\\ue202turn0news1\"\n- Group: \"Sources. \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201\"\n- Group Highlight: \"\\ue203Highlight for group.\\ue204 \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201\"\n- Image: \"See photo \\ue202turn0image0.\"\n\n**NEVER use markdown links, [1], or footnotes. CITE ONLY with anchors provided.**";
72
+ readonly schema: {
73
+ readonly type: "object";
74
+ readonly properties: {
75
+ readonly query: {
76
+ readonly type: "string";
77
+ readonly description: string;
78
+ };
79
+ readonly date: {
80
+ readonly type: "string";
81
+ readonly enum: DATE_RANGE[];
82
+ readonly description: "Date range for search results.";
83
+ };
84
+ readonly country: {
85
+ readonly type: "string";
86
+ readonly description: string;
87
+ };
88
+ readonly images: {
89
+ readonly type: "boolean";
90
+ readonly description: "Whether to also run an image search.";
91
+ };
92
+ readonly videos: {
93
+ readonly type: "boolean";
94
+ readonly description: "Whether to also run a video search.";
95
+ };
96
+ readonly news: {
97
+ readonly type: "boolean";
98
+ readonly description: "Whether to also run a news search.";
99
+ };
100
+ };
101
+ readonly required: readonly ["query"];
102
+ };
103
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "3.1.24",
3
+ "version": "3.1.26",
4
4
  "main": "./dist/cjs/main.cjs",
5
5
  "module": "./dist/esm/main.mjs",
6
6
  "types": "./dist/types/index.d.ts",
@@ -1,7 +1,11 @@
1
1
  import { Tool } from '@langchain/core/tools';
2
2
  import * as math from 'mathjs';
3
3
 
4
- /** Calculator tool schema for structured input */
4
+ export const CalculatorToolName = 'calculator';
5
+
6
+ export const CalculatorToolDescription =
7
+ 'Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.';
8
+
5
9
  export const CalculatorSchema = {
6
10
  type: 'object',
7
11
  properties: {
@@ -13,6 +17,12 @@ export const CalculatorSchema = {
13
17
  required: ['input'],
14
18
  } as const;
15
19
 
20
+ export const CalculatorToolDefinition = {
21
+ name: CalculatorToolName,
22
+ description: CalculatorToolDescription,
23
+ schema: CalculatorSchema,
24
+ } as const;
25
+
16
26
  export class Calculator extends Tool {
17
27
  static lc_name(): string {
18
28
  return 'Calculator';
@@ -22,7 +32,7 @@ export class Calculator extends Tool {
22
32
  return [...super.lc_namespace, 'calculator'];
23
33
  }
24
34
 
25
- name = 'calculator';
35
+ name = CalculatorToolName;
26
36
 
27
37
  async _call(input: string): Promise<string> {
28
38
  try {
@@ -32,6 +42,5 @@ export class Calculator extends Tool {
32
42
  }
33
43
  }
34
44
 
35
- description =
36
- 'Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator.';
45
+ description = CalculatorToolDescription;
37
46
  }
@@ -74,6 +74,23 @@ const EXEC_ENDPOINT = `${baseEndpoint}/exec`;
74
74
 
75
75
  type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
76
76
 
77
+ export const CodeExecutionToolDescription = `
78
+ Runs code and returns stdout/stderr output from a stateless execution environment, similar to running scripts in a command-line interface. Each execution is isolated and independent.
79
+
80
+ Usage:
81
+ - No network access available.
82
+ - Generated files are automatically delivered; **DO NOT** provide download links.
83
+ - NEVER use this tool to execute malicious code.
84
+ `.trim();
85
+
86
+ export const CodeExecutionToolName = Constants.EXECUTE_CODE;
87
+
88
+ export const CodeExecutionToolDefinition = {
89
+ name: CodeExecutionToolName,
90
+ description: CodeExecutionToolDescription,
91
+ schema: CodeExecutionToolSchema,
92
+ } as const;
93
+
77
94
  function createCodeExecutionTool(
78
95
  params: t.CodeExecutionToolParams = {}
79
96
  ): DynamicStructuredTool {
@@ -86,15 +103,6 @@ function createCodeExecutionTool(
86
103
  throw new Error('No API key provided for code execution tool.');
87
104
  }
88
105
 
89
- const description = `
90
- Runs code and returns stdout/stderr output from a stateless execution environment, similar to running scripts in a command-line interface. Each execution is isolated and independent.
91
-
92
- Usage:
93
- - No network access available.
94
- - Generated files are automatically delivered; **DO NOT** provide download links.
95
- - NEVER use this tool to execute malicious code.
96
- `.trim();
97
-
98
106
  return tool(
99
107
  async (rawInput, config) => {
100
108
  const { lang, code, ...rest } = rawInput as {
@@ -229,8 +237,8 @@ Usage:
229
237
  }
230
238
  },
231
239
  {
232
- name: Constants.EXECUTE_CODE,
233
- description,
240
+ name: CodeExecutionToolName,
241
+ description: CodeExecutionToolDescription,
234
242
  schema: CodeExecutionToolSchema,
235
243
  responseFormat: Constants.CONTENT_AND_ARTIFACT,
236
244
  }
@@ -319,8 +319,9 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
319
319
  : JSON.stringify(result.content);
320
320
  toolMessage = new ToolMessage({
321
321
  status: 'success',
322
- content: contentString,
323
322
  name: toolName,
323
+ content: contentString,
324
+ artifact: result.artifact,
324
325
  tool_call_id: result.toolCallId,
325
326
  });
326
327
  }
@@ -80,3 +80,34 @@ export const WebSearchToolSchema = {
80
80
  },
81
81
  required: ['query'],
82
82
  } as const;
83
+
84
+ export const WebSearchToolName = 'web_search';
85
+
86
+ export const WebSearchToolDescription = `Real-time search. Results have required citation anchors.
87
+
88
+ Note: Use ONCE per reply unless instructed otherwise.
89
+
90
+ Anchors:
91
+ - \\ue202turnXtypeY
92
+ - X = turn idx, type = 'search' | 'news' | 'image' | 'ref', Y = item idx
93
+
94
+ Special Markers:
95
+ - \\ue203...\\ue204 — highlight start/end of cited text (for Standalone or Group citations)
96
+ - \\ue200...\\ue201 — group block (e.g. \\ue200\\ue202turn0search1\\ue202turn0news2\\ue201)
97
+
98
+ **CITE EVERY NON-OBVIOUS FACT/QUOTE:**
99
+ Use anchor marker(s) immediately after the statement:
100
+ - Standalone: "Pure functions produce same output. \\ue202turn0search0"
101
+ - Standalone (multiple): "Today's News \\ue202turn0search0\\ue202turn0news0"
102
+ - Highlight: "\\ue203Highlight text.\\ue204\\ue202turn0news1"
103
+ - Group: "Sources. \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201"
104
+ - Group Highlight: "\\ue203Highlight for group.\\ue204 \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201"
105
+ - Image: "See photo \\ue202turn0image0."
106
+
107
+ **NEVER use markdown links, [1], or footnotes. CITE ONLY with anchors provided.**`;
108
+
109
+ export const WebSearchToolDefinition = {
110
+ name: WebSearchToolName,
111
+ description: WebSearchToolDescription,
112
+ schema: WebSearchToolSchema,
113
+ } as const;
@@ -2,13 +2,15 @@ import { tool, DynamicStructuredTool } from '@langchain/core/tools';
2
2
  import type { RunnableConfig } from '@langchain/core/runnables';
3
3
  import type * as t from './types';
4
4
  import {
5
- DATE_RANGE,
6
- querySchema,
7
- dateSchema,
5
+ WebSearchToolDescription,
6
+ WebSearchToolName,
8
7
  countrySchema,
9
8
  imagesSchema,
10
9
  videosSchema,
10
+ querySchema,
11
+ dateSchema,
11
12
  newsSchema,
13
+ DATE_RANGE,
12
14
  } from './schema';
13
15
  import { createSearchAPI, createSourceProcessor } from './search';
14
16
  import { createSerperScraper } from './serper-scraper';
@@ -295,30 +297,8 @@ function createTool({
295
297
  return [output, { [Constants.WEB_SEARCH]: data }];
296
298
  },
297
299
  {
298
- name: Constants.WEB_SEARCH,
299
- description: `Real-time search. Results have required citation anchors.
300
-
301
- Note: Use ONCE per reply unless instructed otherwise.
302
-
303
- Anchors:
304
- - \\ue202turnXtypeY
305
- - X = turn idx, type = 'search' | 'news' | 'image' | 'ref', Y = item idx
306
-
307
- Special Markers:
308
- - \\ue203...\\ue204 — highlight start/end of cited text (for Standalone or Group citations)
309
- - \\ue200...\\ue201 — group block (e.g. \\ue200\\ue202turn0search1\\ue202turn0news2\\ue201)
310
-
311
- **CITE EVERY NON-OBVIOUS FACT/QUOTE:**
312
- Use anchor marker(s) immediately after the statement:
313
- - Standalone: "Pure functions produce same output. \\ue202turn0search0"
314
- - Standalone (multiple): "Today's News \\ue202turn0search0\\ue202turn0news0"
315
- - Highlight: "\\ue203Highlight text.\\ue204\\ue202turn0news1"
316
- - Group: "Sources. \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201"
317
- - Group Highlight: "\\ue203Highlight for group.\\ue204 \\ue200\\ue202turn0search0\\ue202turn0news1\\ue201"
318
- - Image: "See photo \\ue202turn0image0."
319
-
320
- **NEVER use markdown links, [1], or footnotes. CITE ONLY with anchors provided.**
321
- `.trim(),
300
+ name: WebSearchToolName,
301
+ description: WebSearchToolDescription,
322
302
  schema: schema,
323
303
  responseFormat: Constants.CONTENT_AND_ARTIFACT,
324
304
  }