@librechat/agents 1.5.5 → 1.5.7
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/dist/cjs/tools/CodeExecutor.cjs +2 -2
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +2 -2
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/types/tools/CodeExecutor.d.ts +1 -0
- package/package.json +1 -1
- package/src/tools/CodeExecutor.ts +3 -2
|
@@ -29,7 +29,7 @@ const CodeExecutionToolSchema = zod.z.object({
|
|
|
29
29
|
.describe('Additional arguments to execute the code with.'),
|
|
30
30
|
});
|
|
31
31
|
function createCodeExecutionTool(params = {}) {
|
|
32
|
-
const apiKey = params.apiKey ?? env.getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
32
|
+
const apiKey = params.LIBRECHAT_CODE_API_KEY ?? params.apiKey ?? env.getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
33
33
|
if (!apiKey) {
|
|
34
34
|
throw new Error('No API key provided for code execution tool.');
|
|
35
35
|
}
|
|
@@ -77,7 +77,7 @@ function createCodeExecutionTool(params = {}) {
|
|
|
77
77
|
}
|
|
78
78
|
}, {
|
|
79
79
|
name: 'execute_code',
|
|
80
|
-
description: 'Executes code in various programming languages, returning stdout/stderr output.',
|
|
80
|
+
description: 'Executes code in various programming languages, returning stdout/stderr output. The code used as input is automatically displayed to the user in a formatted block, so don\'t repeat it in your response unless specifically asked to do so.',
|
|
81
81
|
schema: CodeExecutionToolSchema,
|
|
82
82
|
responseFormat: 'content_and_artifact',
|
|
83
83
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeExecutor.cjs","sources":["../../../src/tools/CodeExecutor.ts"],"sourcesContent":["import { z } from 'zod';\nimport { config } from 'dotenv';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\n\nconfig();\n\nconst EXEC_ENDPOINT = 'https://api.librechat.ai/exec';\n\nexport type CodeExecutionToolParams = undefined | {\n session_id?: string;\n user_id?: string;\n apiKey?: string;\n}\n\nexport type FileRef = {\n id: string;\n name: string;\n path?: string;\n};\n\nexport type FileRefs = FileRef[];\n\nexport type ExecuteResult = {\n session_id: string;\n stdout: string;\n stderr: string;\n files?: FileRefs;\n};\n\nconst CodeExecutionToolSchema = z.object({\n lang: z.enum([\n 'py',\n 'js',\n 'ts',\n 'c',\n 'cpp',\n 'java',\n 'php',\n 'rs',\n 'go',\n 'bash',\n 'd',\n 'f90',\n ])\n .describe('The programming language or runtime to execute the code in.'),\n code: z.string()\n .describe('The complete, self-contained code to execute, without any truncation or minimization.'),\n args: z.array(z.string()).optional()\n .describe('Additional arguments to execute the code with.'),\n});\n\nfunction createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicStructuredTool<typeof CodeExecutionToolSchema> {\n const apiKey = params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';\n if (!apiKey) {\n throw new Error('No API key provided for code execution tool.');\n }\n return tool<typeof CodeExecutionToolSchema>(\n async ({ lang, code, ...rest }) => {\n const postData = {\n lang,\n code,\n ...rest,\n ...params,\n };\n\n try {\n const response = await fetch(EXEC_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': 'LibreChat/1.0',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(postData),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const result: ExecuteResult = await response.json();\n let formattedOutput = '';\n if (result.stdout) formattedOutput += `stdout:\\n${result.stdout}\\n`;\n if (result.stderr) formattedOutput += `stderr:\\n${result.stderr}\\n`;\n if (result.files && result.files.length > 0) {\n formattedOutput += 'Generated files:\\n';\n result.files.forEach((file: FileRef) => {\n formattedOutput += `${file.name}`;\n });\n return [formattedOutput.trim(), result.files];\n }\n\n return [formattedOutput.trim(), undefined];\n } catch (error) {\n return `Calling tool with arguments:\\n\\n${JSON.stringify({\n lang,\n code,\n ...rest,\n })}\\n\\nraised the following error:\\n\\n${(error as Error | undefined)?.message}`;\n }\n },\n {\n name: 'execute_code',\n description: 'Executes code in various programming languages, returning stdout/stderr output.',\n schema: CodeExecutionToolSchema,\n responseFormat: 'content_and_artifact',\n }\n );\n}\n\nexport { createCodeExecutionTool };"],"names":["config","z","getEnvironmentVariable","tool"],"mappings":";;;;;;;AAKAA,aAAM,EAAE,CAAC;AAET,MAAM,aAAa,GAAG,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeExecutor.cjs","sources":["../../../src/tools/CodeExecutor.ts"],"sourcesContent":["import { z } from 'zod';\nimport { config } from 'dotenv';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\n\nconfig();\n\nconst EXEC_ENDPOINT = 'https://api.librechat.ai/exec';\n\nexport type CodeExecutionToolParams = undefined | {\n session_id?: string;\n user_id?: string;\n apiKey?: string;\n LIBRECHAT_CODE_API_KEY?: string;\n}\n\nexport type FileRef = {\n id: string;\n name: string;\n path?: string;\n};\n\nexport type FileRefs = FileRef[];\n\nexport type ExecuteResult = {\n session_id: string;\n stdout: string;\n stderr: string;\n files?: FileRefs;\n};\n\nconst CodeExecutionToolSchema = z.object({\n lang: z.enum([\n 'py',\n 'js',\n 'ts',\n 'c',\n 'cpp',\n 'java',\n 'php',\n 'rs',\n 'go',\n 'bash',\n 'd',\n 'f90',\n ])\n .describe('The programming language or runtime to execute the code in.'),\n code: z.string()\n .describe('The complete, self-contained code to execute, without any truncation or minimization.'),\n args: z.array(z.string()).optional()\n .describe('Additional arguments to execute the code with.'),\n});\n\nfunction createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicStructuredTool<typeof CodeExecutionToolSchema> {\n const apiKey = params.LIBRECHAT_CODE_API_KEY ?? params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';\n if (!apiKey) {\n throw new Error('No API key provided for code execution tool.');\n }\n return tool<typeof CodeExecutionToolSchema>(\n async ({ lang, code, ...rest }) => {\n const postData = {\n lang,\n code,\n ...rest,\n ...params,\n };\n\n try {\n const response = await fetch(EXEC_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': 'LibreChat/1.0',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(postData),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const result: ExecuteResult = await response.json();\n let formattedOutput = '';\n if (result.stdout) formattedOutput += `stdout:\\n${result.stdout}\\n`;\n if (result.stderr) formattedOutput += `stderr:\\n${result.stderr}\\n`;\n if (result.files && result.files.length > 0) {\n formattedOutput += 'Generated files:\\n';\n result.files.forEach((file: FileRef) => {\n formattedOutput += `${file.name}`;\n });\n return [formattedOutput.trim(), result.files];\n }\n\n return [formattedOutput.trim(), undefined];\n } catch (error) {\n return `Calling tool with arguments:\\n\\n${JSON.stringify({\n lang,\n code,\n ...rest,\n })}\\n\\nraised the following error:\\n\\n${(error as Error | undefined)?.message}`;\n }\n },\n {\n name: 'execute_code',\n description: 'Executes code in various programming languages, returning stdout/stderr output. The code used as input is automatically displayed to the user in a formatted block, so don\\'t repeat it in your response unless specifically asked to do so.',\n schema: CodeExecutionToolSchema,\n responseFormat: 'content_and_artifact',\n }\n );\n}\n\nexport { createCodeExecutionTool };"],"names":["config","z","getEnvironmentVariable","tool"],"mappings":";;;;;;;AAKAA,aAAM,EAAE,CAAC;AAET,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAwBtD,MAAM,uBAAuB,GAAGC,KAAC,CAAC,MAAM,CAAC;AACvC,IAAA,IAAI,EAAEA,KAAC,CAAC,IAAI,CAAC;QACX,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,GAAG;QACH,KAAK;QACL,MAAM;QACN,KAA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odeExecutionToolSchema = z.object({
|
|
|
27
27
|
.describe('Additional arguments to execute the code with.'),
|
|
28
28
|
});
|
|
29
29
|
function createCodeExecutionTool(params = {}) {
|
|
30
|
-
const apiKey = params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
30
|
+
const apiKey = params.LIBRECHAT_CODE_API_KEY ?? params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
31
31
|
if (!apiKey) {
|
|
32
32
|
throw new Error('No API key provided for code execution tool.');
|
|
33
33
|
}
|
|
@@ -75,7 +75,7 @@ function createCodeExecutionTool(params = {}) {
|
|
|
75
75
|
}
|
|
76
76
|
}, {
|
|
77
77
|
name: 'execute_code',
|
|
78
|
-
description: 'Executes code in various programming languages, returning stdout/stderr output.',
|
|
78
|
+
description: 'Executes code in various programming languages, returning stdout/stderr output. The code used as input is automatically displayed to the user in a formatted block, so don\'t repeat it in your response unless specifically asked to do so.',
|
|
79
79
|
schema: CodeExecutionToolSchema,
|
|
80
80
|
responseFormat: 'content_and_artifact',
|
|
81
81
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeExecutor.mjs","sources":["../../../src/tools/CodeExecutor.ts"],"sourcesContent":["import { z } from 'zod';\nimport { config } from 'dotenv';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\n\nconfig();\n\nconst EXEC_ENDPOINT = 'https://api.librechat.ai/exec';\n\nexport type CodeExecutionToolParams = undefined | {\n session_id?: string;\n user_id?: string;\n apiKey?: string;\n}\n\nexport type FileRef = {\n id: string;\n name: string;\n path?: string;\n};\n\nexport type FileRefs = FileRef[];\n\nexport type ExecuteResult = {\n session_id: string;\n stdout: string;\n stderr: string;\n files?: FileRefs;\n};\n\nconst CodeExecutionToolSchema = z.object({\n lang: z.enum([\n 'py',\n 'js',\n 'ts',\n 'c',\n 'cpp',\n 'java',\n 'php',\n 'rs',\n 'go',\n 'bash',\n 'd',\n 'f90',\n ])\n .describe('The programming language or runtime to execute the code in.'),\n code: z.string()\n .describe('The complete, self-contained code to execute, without any truncation or minimization.'),\n args: z.array(z.string()).optional()\n .describe('Additional arguments to execute the code with.'),\n});\n\nfunction createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicStructuredTool<typeof CodeExecutionToolSchema> {\n const apiKey = params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';\n if (!apiKey) {\n throw new Error('No API key provided for code execution tool.');\n }\n return tool<typeof CodeExecutionToolSchema>(\n async ({ lang, code, ...rest }) => {\n const postData = {\n lang,\n code,\n ...rest,\n ...params,\n };\n\n try {\n const response = await fetch(EXEC_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': 'LibreChat/1.0',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(postData),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const result: ExecuteResult = await response.json();\n let formattedOutput = '';\n if (result.stdout) formattedOutput += `stdout:\\n${result.stdout}\\n`;\n if (result.stderr) formattedOutput += `stderr:\\n${result.stderr}\\n`;\n if (result.files && result.files.length > 0) {\n formattedOutput += 'Generated files:\\n';\n result.files.forEach((file: FileRef) => {\n formattedOutput += `${file.name}`;\n });\n return [formattedOutput.trim(), result.files];\n }\n\n return [formattedOutput.trim(), undefined];\n } catch (error) {\n return `Calling tool with arguments:\\n\\n${JSON.stringify({\n lang,\n code,\n ...rest,\n })}\\n\\nraised the following error:\\n\\n${(error as Error | undefined)?.message}`;\n }\n },\n {\n name: 'execute_code',\n description: 'Executes code in various programming languages, returning stdout/stderr output.',\n schema: CodeExecutionToolSchema,\n responseFormat: 'content_and_artifact',\n }\n );\n}\n\nexport { createCodeExecutionTool };"],"names":[],"mappings":";;;;;AAKA,MAAM,EAAE,CAAC;AAET,MAAM,aAAa,GAAG,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"CodeExecutor.mjs","sources":["../../../src/tools/CodeExecutor.ts"],"sourcesContent":["import { z } from 'zod';\nimport { config } from 'dotenv';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\n\nconfig();\n\nconst EXEC_ENDPOINT = 'https://api.librechat.ai/exec';\n\nexport type CodeExecutionToolParams = undefined | {\n session_id?: string;\n user_id?: string;\n apiKey?: string;\n LIBRECHAT_CODE_API_KEY?: string;\n}\n\nexport type FileRef = {\n id: string;\n name: string;\n path?: string;\n};\n\nexport type FileRefs = FileRef[];\n\nexport type ExecuteResult = {\n session_id: string;\n stdout: string;\n stderr: string;\n files?: FileRefs;\n};\n\nconst CodeExecutionToolSchema = z.object({\n lang: z.enum([\n 'py',\n 'js',\n 'ts',\n 'c',\n 'cpp',\n 'java',\n 'php',\n 'rs',\n 'go',\n 'bash',\n 'd',\n 'f90',\n ])\n .describe('The programming language or runtime to execute the code in.'),\n code: z.string()\n .describe('The complete, self-contained code to execute, without any truncation or minimization.'),\n args: z.array(z.string()).optional()\n .describe('Additional arguments to execute the code with.'),\n});\n\nfunction createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicStructuredTool<typeof CodeExecutionToolSchema> {\n const apiKey = params.LIBRECHAT_CODE_API_KEY ?? params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';\n if (!apiKey) {\n throw new Error('No API key provided for code execution tool.');\n }\n return tool<typeof CodeExecutionToolSchema>(\n async ({ lang, code, ...rest }) => {\n const postData = {\n lang,\n code,\n ...rest,\n ...params,\n };\n\n try {\n const response = await fetch(EXEC_ENDPOINT, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'User-Agent': 'LibreChat/1.0',\n 'X-API-Key': apiKey,\n },\n body: JSON.stringify(postData),\n });\n\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const result: ExecuteResult = await response.json();\n let formattedOutput = '';\n if (result.stdout) formattedOutput += `stdout:\\n${result.stdout}\\n`;\n if (result.stderr) formattedOutput += `stderr:\\n${result.stderr}\\n`;\n if (result.files && result.files.length > 0) {\n formattedOutput += 'Generated files:\\n';\n result.files.forEach((file: FileRef) => {\n formattedOutput += `${file.name}`;\n });\n return [formattedOutput.trim(), result.files];\n }\n\n return [formattedOutput.trim(), undefined];\n } catch (error) {\n return `Calling tool with arguments:\\n\\n${JSON.stringify({\n lang,\n code,\n ...rest,\n })}\\n\\nraised the following error:\\n\\n${(error as Error | undefined)?.message}`;\n }\n },\n {\n name: 'execute_code',\n description: 'Executes code in various programming languages, returning stdout/stderr output. The code used as input is automatically displayed to the user in a formatted block, so don\\'t repeat it in your response unless specifically asked to do so.',\n schema: CodeExecutionToolSchema,\n responseFormat: 'content_and_artifact',\n }\n );\n}\n\nexport { createCodeExecutionTool };"],"names":[],"mappings":";;;;;AAKA,MAAM,EAAE,CAAC;AAET,MAAM,aAAa,GAAG,+BAA+B,CAAC;AAwBtD,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;AACvC,IAAA,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC;QACX,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,GAAG;QACH,KAAK;QACL,MAAM;QACN,KAAK;QACL,IAAI;QACJ,IAAI;QACJ,MAAM;QACN,GAAG;QACH,KAAK;KACN,CAAC;SACC,QAAQ,CAAC,6DAA6D,CAAC;AAC1E,IAAA,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACb,QAAQ,CAAC,uFAAuF,CAAC;AACpG,IAAA,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;SACjC,QAAQ,CAAC,gDAAgD,CAAC;AAC9D,CAAA,CAAC,CAAC;AAEH,SAAS,uBAAuB,CAAC,MAAA,GAAkC,EAAE,EAAA;AACnE,IAAA,MAAM,MAAM,GAA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CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3C,eAAe,IAAI,oBAAoB,CAAC;gBACxC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAa,KAAI;AACrC,oBAAA,eAAe,IAAI,CAAG,EAAA,IAAI,CAAC,IAAI,EAAE,CAAC;AACpC,iBAAC,CAAC,CAAC;gBACH,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;aAC/C;YAED,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,SAAS,CAAC,CAAC;SAC5C;QAAC,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,CAAmC,gCAAA,EAAA,IAAI,CAAC,SAAS,CAAC;gBACvD,IAAI;gBACJ,IAAI;AACJ,gBAAA,GAAG,IAAI;AACR,aAAA,CAAC,CAAuC,mCAAA,EAAA,KAA2B,EAAE,OAAO,EAAE,CAAC;SACjF;AACH,KAAC,EACD;AACE,QAAA,IAAI,EAAE,cAAc;AACpB,QAAA,WAAW,EAAE,8OAA8O;AAC3P,QAAA,MAAM,EAAE,uBAAuB;AAC/B,QAAA,cAAc,EAAE,sBAAsB;AACvC,KAAA,CACF,CAAC;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -11,6 +11,7 @@ export type CodeExecutionToolParams = undefined | {
|
|
|
11
11
|
session_id?: string;
|
|
12
12
|
user_id?: string;
|
|
13
13
|
apiKey?: string;
|
|
14
|
+
LIBRECHAT_CODE_API_KEY?: string;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export type FileRef = {
|
|
@@ -51,7 +52,7 @@ const CodeExecutionToolSchema = z.object({
|
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
function createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicStructuredTool<typeof CodeExecutionToolSchema> {
|
|
54
|
-
const apiKey = params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
55
|
+
const apiKey = params.LIBRECHAT_CODE_API_KEY ?? params.apiKey ?? getEnvironmentVariable('LIBRECHAT_CODE_API_KEY') ?? '';
|
|
55
56
|
if (!apiKey) {
|
|
56
57
|
throw new Error('No API key provided for code execution tool.');
|
|
57
58
|
}
|
|
@@ -102,7 +103,7 @@ function createCodeExecutionTool(params: CodeExecutionToolParams = {}): DynamicS
|
|
|
102
103
|
},
|
|
103
104
|
{
|
|
104
105
|
name: 'execute_code',
|
|
105
|
-
description: 'Executes code in various programming languages, returning stdout/stderr output.',
|
|
106
|
+
description: 'Executes code in various programming languages, returning stdout/stderr output. The code used as input is automatically displayed to the user in a formatted block, so don\'t repeat it in your response unless specifically asked to do so.',
|
|
106
107
|
schema: CodeExecutionToolSchema,
|
|
107
108
|
responseFormat: 'content_and_artifact',
|
|
108
109
|
}
|