@librechat/agents 3.0.36 → 3.0.40
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/agents/AgentContext.cjs +71 -2
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +2 -0
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/events.cjs +3 -0
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +5 -1
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/main.cjs +12 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +329 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +34 -3
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearchRegex.cjs +455 -0
- package/dist/cjs/tools/ToolSearchRegex.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +71 -2
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +2 -0
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/events.mjs +4 -1
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +5 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/main.mjs +2 -0
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +324 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +34 -3
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearchRegex.mjs +448 -0
- package/dist/esm/tools/ToolSearchRegex.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +25 -1
- package/dist/types/common/enum.d.ts +2 -0
- package/dist/types/graphs/Graph.d.ts +2 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/test/mockTools.d.ts +28 -0
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +86 -0
- package/dist/types/tools/ToolNode.d.ts +7 -1
- package/dist/types/tools/ToolSearchRegex.d.ts +80 -0
- package/dist/types/types/graph.d.ts +7 -1
- package/dist/types/types/tools.d.ts +136 -0
- package/package.json +5 -1
- package/src/agents/AgentContext.ts +86 -0
- package/src/common/enum.ts +2 -0
- package/src/events.ts +5 -1
- package/src/graphs/Graph.ts +6 -0
- package/src/index.ts +2 -0
- package/src/scripts/code_exec_ptc.ts +277 -0
- package/src/scripts/programmatic_exec.ts +396 -0
- package/src/scripts/programmatic_exec_agent.ts +231 -0
- package/src/scripts/tool_search_regex.ts +162 -0
- package/src/test/mockTools.ts +366 -0
- package/src/tools/ProgrammaticToolCalling.ts +423 -0
- package/src/tools/ToolNode.ts +38 -4
- package/src/tools/ToolSearchRegex.ts +535 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +318 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +613 -0
- package/src/tools/__tests__/ToolSearchRegex.integration.test.ts +161 -0
- package/src/tools/__tests__/ToolSearchRegex.test.ts +232 -0
- package/src/types/graph.ts +7 -1
- package/src/types/tools.ts +166 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolSearchRegex.mjs","sources":["../../../src/tools/ToolSearchRegex.ts"],"sourcesContent":["// src/tools/ToolSearchRegex.ts\nimport { z } from 'zod';\nimport { config } from 'dotenv';\nimport fetch, { RequestInit } from 'node-fetch';\nimport { HttpsProxyAgent } from 'https-proxy-agent';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport type * as t from '@/types';\nimport { getCodeBaseURL } from './CodeExecutor';\nimport { EnvVar, Constants } from '@/common';\n\nconfig();\n\n/** Maximum allowed regex pattern length */\nconst MAX_PATTERN_LENGTH = 200;\n\n/** Maximum allowed regex nesting depth */\nconst MAX_REGEX_COMPLEXITY = 5;\n\n/** Default search timeout in milliseconds */\nconst SEARCH_TIMEOUT = 5000;\n\nconst ToolSearchRegexSchema = z.object({\n query: z\n .string()\n .min(1)\n .max(MAX_PATTERN_LENGTH)\n .describe(\n 'Regex pattern to search tool names and descriptions. Special regex characters will be sanitized for safety.'\n ),\n fields: z\n .array(z.enum(['name', 'description', 'parameters']))\n .optional()\n .default(['name', 'description'])\n .describe('Which fields to search. Default: name and description'),\n max_results: z\n .number()\n .int()\n .min(1)\n .max(50)\n .optional()\n .default(10)\n .describe('Maximum number of matching tools to return'),\n});\n\n/**\n * Escapes special regex characters in a string to use as a literal pattern.\n * @param pattern - The string to escape\n * @returns The escaped string safe for use in a RegExp\n */\nfunction escapeRegexSpecialChars(pattern: string): string {\n return pattern.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Counts the maximum nesting depth of groups in a regex pattern.\n * @param pattern - The regex pattern to analyze\n * @returns The maximum nesting depth\n */\nfunction countNestedGroups(pattern: string): number {\n let maxDepth = 0;\n let currentDepth = 0;\n\n for (let i = 0; i < pattern.length; i++) {\n if (pattern[i] === '(' && (i === 0 || pattern[i - 1] !== '\\\\')) {\n currentDepth++;\n maxDepth = Math.max(maxDepth, currentDepth);\n } else if (pattern[i] === ')' && (i === 0 || pattern[i - 1] !== '\\\\')) {\n currentDepth = Math.max(0, currentDepth - 1);\n }\n }\n\n return maxDepth;\n}\n\n/**\n * Detects nested quantifiers that can cause catastrophic backtracking.\n * Patterns like (a+)+, (a*)*, (a+)*, etc.\n * @param pattern - The regex pattern to check\n * @returns True if nested quantifiers are detected\n */\nfunction hasNestedQuantifiers(pattern: string): boolean {\n const nestedQuantifierPattern = /\\([^)]*[+*][^)]*\\)[+*?]/;\n return nestedQuantifierPattern.test(pattern);\n}\n\n/**\n * Checks if a regex pattern contains potentially dangerous constructs.\n * @param pattern - The regex pattern to validate\n * @returns True if the pattern is dangerous\n */\nfunction isDangerousPattern(pattern: string): boolean {\n if (hasNestedQuantifiers(pattern)) {\n return true;\n }\n\n if (countNestedGroups(pattern) > MAX_REGEX_COMPLEXITY) {\n return true;\n }\n\n const dangerousPatterns = [\n /\\.\\{1000,\\}/, // Excessive wildcards\n /\\(\\?=\\.\\{100,\\}\\)/, // Runaway lookaheads\n /\\([^)]*\\|\\s*\\){20,}/, // Excessive alternation (rough check)\n /\\(\\.\\*\\)\\+/, // (.*)+\n /\\(\\.\\+\\)\\+/, // (.+)+\n /\\(\\.\\*\\)\\*/, // (.*)*\n /\\(\\.\\+\\)\\*/, // (.+)*\n ];\n\n for (const dangerous of dangerousPatterns) {\n if (dangerous.test(pattern)) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Sanitizes a regex pattern for safe execution.\n * If the pattern is dangerous, it will be escaped to a literal string search.\n * @param pattern - The regex pattern to sanitize\n * @returns Object containing the safe pattern and whether it was escaped\n */\nfunction sanitizeRegex(pattern: string): { safe: string; wasEscaped: boolean } {\n if (isDangerousPattern(pattern)) {\n return {\n safe: escapeRegexSpecialChars(pattern),\n wasEscaped: true,\n };\n }\n\n try {\n new RegExp(pattern);\n return { safe: pattern, wasEscaped: false };\n } catch {\n return {\n safe: escapeRegexSpecialChars(pattern),\n wasEscaped: true,\n };\n }\n}\n\n/**\n * Simplifies tool parameters for search purposes.\n * Extracts only the essential structure needed for parameter name searching.\n * @param parameters - The tool's JSON schema parameters\n * @returns Simplified parameters object\n */\nfunction simplifyParametersForSearch(\n parameters?: t.JsonSchemaType\n): t.JsonSchemaType | undefined {\n if (!parameters) {\n return undefined;\n }\n\n if (parameters.properties) {\n return {\n type: parameters.type,\n properties: Object.fromEntries(\n Object.entries(parameters.properties).map(([key, value]) => [\n key,\n { type: (value as t.JsonSchemaType).type },\n ])\n ),\n } as t.JsonSchemaType;\n }\n\n return { type: parameters.type };\n}\n\n/**\n * Generates the JavaScript search script to be executed in the sandbox.\n * Uses plain JavaScript for maximum compatibility with the Code API.\n * @param deferredTools - Array of tool metadata to search through\n * @param fields - Which fields to search\n * @param maxResults - Maximum number of results to return\n * @param sanitizedPattern - The sanitized regex pattern\n * @returns The JavaScript code string\n */\nfunction generateSearchScript(\n deferredTools: t.ToolMetadata[],\n fields: string[],\n maxResults: number,\n sanitizedPattern: string\n): string {\n const lines = [\n '// Tool definitions (injected)',\n 'var tools = ' + JSON.stringify(deferredTools) + ';',\n 'var searchFields = ' + JSON.stringify(fields) + ';',\n 'var maxResults = ' + maxResults + ';',\n 'var pattern = ' + JSON.stringify(sanitizedPattern) + ';',\n '',\n '// Compile regex (pattern is sanitized client-side)',\n 'var regex;',\n 'try {',\n ' regex = new RegExp(pattern, \\'i\\');',\n '} catch (e) {',\n ' regex = new RegExp(pattern.replace(/[.*+?^${}()[\\\\]\\\\\\\\|]/g, \"\\\\\\\\$&\"), \"i\");',\n '}',\n '',\n '// Search logic',\n 'var results = [];',\n '',\n 'for (var j = 0; j < tools.length; j++) {',\n ' var tool = tools[j];',\n ' var bestScore = 0;',\n ' var matchedField = \\'\\';',\n ' var snippet = \\'\\';',\n '',\n ' // Search name (highest priority)',\n ' if (searchFields.indexOf(\\'name\\') >= 0 && regex.test(tool.name)) {',\n ' bestScore = 0.95;',\n ' matchedField = \\'name\\';',\n ' snippet = tool.name;',\n ' }',\n '',\n ' // Search description (medium priority)',\n ' if (searchFields.indexOf(\\'description\\') >= 0 && tool.description && regex.test(tool.description)) {',\n ' if (bestScore === 0) {',\n ' bestScore = 0.75;',\n ' matchedField = \\'description\\';',\n ' snippet = tool.description.substring(0, 100);',\n ' }',\n ' }',\n '',\n ' // Search parameter names (lower priority)',\n ' if (searchFields.indexOf(\\'parameters\\') >= 0 && tool.parameters && tool.parameters.properties) {',\n ' var paramNames = Object.keys(tool.parameters.properties).join(\\' \\');',\n ' if (regex.test(paramNames)) {',\n ' if (bestScore === 0) {',\n ' bestScore = 0.60;',\n ' matchedField = \\'parameters\\';',\n ' snippet = paramNames;',\n ' }',\n ' }',\n ' }',\n '',\n ' if (bestScore > 0) {',\n ' results.push({',\n ' tool_name: tool.name,',\n ' match_score: bestScore,',\n ' matched_field: matchedField,',\n ' snippet: snippet',\n ' });',\n ' }',\n '}',\n '',\n '// Sort by score (descending) and limit results',\n 'results.sort(function(a, b) { return b.match_score - a.match_score; });',\n 'var topResults = results.slice(0, maxResults);',\n '',\n '// Output as JSON',\n 'console.log(JSON.stringify({',\n ' tool_references: topResults.map(function(r) {',\n ' return {',\n ' tool_name: r.tool_name,',\n ' match_score: r.match_score,',\n ' matched_field: r.matched_field,',\n ' snippet: r.snippet',\n ' };',\n ' }),',\n ' total_tools_searched: tools.length,',\n ' pattern_used: pattern',\n '}));',\n ];\n return lines.join('\\n');\n}\n\n/**\n * Parses the search results from stdout JSON.\n * @param stdout - The stdout string containing JSON results\n * @returns Parsed search response\n */\nfunction parseSearchResults(stdout: string): t.ToolSearchResponse {\n const jsonMatch = stdout.trim();\n const parsed = JSON.parse(jsonMatch) as t.ToolSearchResponse;\n return parsed;\n}\n\n/**\n * Formats search results into a human-readable string.\n * @param searchResponse - The parsed search response\n * @returns Formatted string for LLM consumption\n */\nfunction formatSearchResults(searchResponse: t.ToolSearchResponse): string {\n const { tool_references, total_tools_searched, pattern_used } =\n searchResponse;\n\n if (tool_references.length === 0) {\n return `No tools matched the pattern \"${pattern_used}\".\\nTotal tools searched: ${total_tools_searched}`;\n }\n\n let response = `Found ${tool_references.length} matching tools:\\n\\n`;\n\n for (const ref of tool_references) {\n response += `- ${ref.tool_name} (score: ${ref.match_score.toFixed(2)})\\n`;\n response += ` Matched in: ${ref.matched_field}\\n`;\n response += ` Snippet: ${ref.snippet}\\n\\n`;\n }\n\n response += `Total tools searched: ${total_tools_searched}\\n`;\n response += `Pattern used: ${pattern_used}`;\n\n return response;\n}\n\n/**\n * Creates a Tool Search Regex tool for discovering tools from a large registry.\n *\n * This tool enables AI agents to dynamically discover tools from a large library\n * without loading all tool definitions into the LLM context window. The agent\n * can search for relevant tools on-demand using regex patterns.\n *\n * The tool registry can be provided either:\n * 1. At initialization time via params.toolRegistry\n * 2. At runtime via config.configurable.toolRegistry when invoking\n *\n * @param params - Configuration parameters for the tool (toolRegistry is optional)\n * @returns A LangChain DynamicStructuredTool for tool searching\n *\n * @example\n * // Option 1: Registry at initialization\n * const tool = createToolSearchRegexTool({ apiKey, toolRegistry });\n * await tool.invoke({ query: 'expense' });\n *\n * @example\n * // Option 2: Registry at runtime\n * const tool = createToolSearchRegexTool({ apiKey });\n * await tool.invoke(\n * { query: 'expense' },\n * { configurable: { toolRegistry, onlyDeferred: true } }\n * );\n */\nfunction createToolSearchRegexTool(\n initParams: t.ToolSearchRegexParams = {}\n): DynamicStructuredTool<typeof ToolSearchRegexSchema> {\n const apiKey: string =\n (initParams[EnvVar.CODE_API_KEY] as string | undefined) ??\n initParams.apiKey ??\n getEnvironmentVariable(EnvVar.CODE_API_KEY) ??\n '';\n\n if (!apiKey) {\n throw new Error('No API key provided for tool search regex tool.');\n }\n\n const baseEndpoint = initParams.baseUrl ?? getCodeBaseURL();\n const EXEC_ENDPOINT = `${baseEndpoint}/exec`;\n const defaultOnlyDeferred = initParams.onlyDeferred ?? true;\n\n const description = `\nSearches through available tools to find ones matching your query pattern.\n\nUsage:\n- Provide a regex pattern to search tool names and descriptions.\n- Use this when you need to discover tools for a specific task.\n- Results include tool names, match quality scores, and snippets showing where the match occurred.\n- Higher scores (0.9+) indicate name matches, medium scores (0.7+) indicate description matches.\n`.trim();\n\n return tool<typeof ToolSearchRegexSchema>(\n async (params, config) => {\n const {\n query,\n fields = ['name', 'description'],\n max_results = 10,\n } = params;\n\n // Extra params injected by ToolNode (follows web_search pattern)\n const {\n toolRegistry: paramToolRegistry,\n onlyDeferred: paramOnlyDeferred,\n } = config.toolCall ?? {};\n\n const { safe: sanitizedPattern, wasEscaped } = sanitizeRegex(query);\n\n let warningMessage = '';\n if (wasEscaped) {\n warningMessage =\n 'Note: The provided pattern was converted to a literal search for safety.\\n\\n';\n }\n\n // Priority: ToolNode injection (via config.toolCall) > initialization params\n const toolRegistry = paramToolRegistry ?? initParams.toolRegistry;\n const onlyDeferred =\n paramOnlyDeferred !== undefined\n ? paramOnlyDeferred\n : defaultOnlyDeferred;\n\n if (toolRegistry == null) {\n return [\n `${warningMessage}Error: No tool registry provided. Configure toolRegistry at agent level or initialization.`,\n {\n tool_references: [],\n metadata: {\n total_searched: 0,\n pattern: sanitizedPattern,\n error: 'No tool registry provided',\n },\n },\n ];\n }\n\n const toolsArray: t.LCTool[] = Array.from(toolRegistry.values());\n\n const deferredTools: t.ToolMetadata[] = toolsArray\n .filter((lcTool) => {\n if (onlyDeferred === true) {\n return lcTool.defer_loading === true;\n }\n return true;\n })\n .map((lcTool) => ({\n name: lcTool.name,\n description: lcTool.description ?? '',\n parameters: simplifyParametersForSearch(lcTool.parameters),\n }));\n\n if (deferredTools.length === 0) {\n return [\n `${warningMessage}No tools available to search. The tool registry is empty or no deferred tools are registered.`,\n {\n tool_references: [],\n metadata: {\n total_searched: 0,\n pattern: sanitizedPattern,\n },\n },\n ];\n }\n\n const searchScript = generateSearchScript(\n deferredTools,\n fields,\n max_results,\n sanitizedPattern\n );\n\n const postData = {\n lang: 'js',\n code: searchScript,\n timeout: SEARCH_TIMEOUT,\n };\n\n try {\n const fetchOptions: RequestInit = {\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 (process.env.PROXY != null && process.env.PROXY !== '') {\n fetchOptions.agent = new HttpsProxyAgent(process.env.PROXY);\n }\n\n const response = await fetch(EXEC_ENDPOINT, fetchOptions);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n\n const result: t.ExecuteResult = await response.json();\n\n if (result.stderr && result.stderr.trim()) {\n // eslint-disable-next-line no-console\n console.warn('[ToolSearchRegex] stderr:', result.stderr);\n }\n\n if (!result.stdout || !result.stdout.trim()) {\n return [\n `${warningMessage}No tools matched the pattern \"${sanitizedPattern}\".\\nTotal tools searched: ${deferredTools.length}`,\n {\n tool_references: [],\n metadata: {\n total_searched: deferredTools.length,\n pattern: sanitizedPattern,\n },\n },\n ];\n }\n\n const searchResponse = parseSearchResults(result.stdout);\n const formattedOutput = `${warningMessage}${formatSearchResults(searchResponse)}`;\n\n return [\n formattedOutput,\n {\n tool_references: searchResponse.tool_references,\n metadata: {\n total_searched: searchResponse.total_tools_searched,\n pattern: searchResponse.pattern_used,\n },\n },\n ];\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('[ToolSearchRegex] Error:', error);\n\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n return [\n `Tool search failed: ${errorMessage}\\n\\nSuggestion: Try a simpler search pattern or search for specific tool names.`,\n {\n tool_references: [],\n metadata: {\n total_searched: 0,\n pattern: sanitizedPattern,\n error: errorMessage,\n },\n },\n ];\n }\n },\n {\n name: Constants.TOOL_SEARCH_REGEX,\n description,\n schema: ToolSearchRegexSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport {\n createToolSearchRegexTool,\n sanitizeRegex,\n escapeRegexSpecialChars,\n isDangerousPattern,\n countNestedGroups,\n hasNestedQuantifiers,\n};\n"],"names":[],"mappings":";;;;;;;;;AAAA;AAWA,MAAM,EAAE;AAER;AACA,MAAM,kBAAkB,GAAG,GAAG;AAE9B;AACA,MAAM,oBAAoB,GAAG,CAAC;AAE9B;AACA,MAAM,cAAc,GAAG,IAAI;AAE3B,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;AACrC,IAAA,KAAK,EAAE;AACJ,SAAA,MAAM;SACN,GAAG,CAAC,CAAC;SACL,GAAG,CAAC,kBAAkB;SACtB,QAAQ,CACP,6GAA6G,CAC9G;AACH,IAAA,MAAM,EAAE;AACL,SAAA,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAA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B;AACzB,wBAAA,KAAK,EAAE,YAAY;AACpB,qBAAA;AACF,iBAAA;aACF;;AAEL,KAAC,EACD;QACE,IAAI,EAAE,SAAS,CAAC,iBAAiB;QACjC,WAAW;AACX,QAAA,MAAM,EAAE,qBAAqB;QAC7B,cAAc,EAAE,SAAS,CAAC,oBAAoB;AAC/C,KAAA,CACF;AACH;;;;"}
|
|
@@ -38,6 +38,11 @@ export declare class AgentContext {
|
|
|
38
38
|
tools?: t.GraphTools;
|
|
39
39
|
/** Tool map for this agent */
|
|
40
40
|
toolMap?: t.ToolMap;
|
|
41
|
+
/**
|
|
42
|
+
* Tool definitions registry (includes deferred and programmatic tool metadata).
|
|
43
|
+
* Used for tool search and programmatic tool calling.
|
|
44
|
+
*/
|
|
45
|
+
toolRegistry?: t.LCToolRegistry;
|
|
41
46
|
/** Instructions for this agent */
|
|
42
47
|
instructions?: string;
|
|
43
48
|
/** Additional instructions for this agent */
|
|
@@ -58,7 +63,7 @@ export declare class AgentContext {
|
|
|
58
63
|
tokenCalculationPromise?: Promise<void>;
|
|
59
64
|
/** Format content blocks as strings (for legacy compatibility) */
|
|
60
65
|
useLegacyContent: boolean;
|
|
61
|
-
constructor({ agentId, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, instructions, additionalInstructions, reasoningKey, toolEnd, instructionTokens, useLegacyContent, }: {
|
|
66
|
+
constructor({ agentId, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, toolRegistry, instructions, additionalInstructions, reasoningKey, toolEnd, instructionTokens, useLegacyContent, }: {
|
|
62
67
|
agentId: string;
|
|
63
68
|
provider: Providers;
|
|
64
69
|
clientOptions?: t.ClientOptions;
|
|
@@ -67,6 +72,7 @@ export declare class AgentContext {
|
|
|
67
72
|
tokenCounter?: t.TokenCounter;
|
|
68
73
|
tools?: t.GraphTools;
|
|
69
74
|
toolMap?: t.ToolMap;
|
|
75
|
+
toolRegistry?: t.LCToolRegistry;
|
|
70
76
|
instructions?: string;
|
|
71
77
|
additionalInstructions?: string;
|
|
72
78
|
reasoningKey?: 'reasoning_content' | 'reasoning';
|
|
@@ -91,4 +97,22 @@ export declare class AgentContext {
|
|
|
91
97
|
* Note: System message tokens are calculated during systemRunnable creation
|
|
92
98
|
*/
|
|
93
99
|
calculateInstructionTokens(tokenCounter: t.TokenCounter): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Gets a map of tools that allow programmatic (code_execution) calling.
|
|
102
|
+
* Filters toolMap based on toolRegistry's allowed_callers settings.
|
|
103
|
+
* @returns ToolMap containing only tools that allow code_execution
|
|
104
|
+
*/
|
|
105
|
+
getProgrammaticToolMap(): t.ToolMap;
|
|
106
|
+
/**
|
|
107
|
+
* Gets tool definitions for tools that allow programmatic calling.
|
|
108
|
+
* Used to send to the Code API for stub generation.
|
|
109
|
+
* @returns Array of LCTool definitions for programmatic tools
|
|
110
|
+
*/
|
|
111
|
+
getProgrammaticToolDefs(): t.LCTool[];
|
|
112
|
+
/**
|
|
113
|
+
* Gets the tool registry for deferred tools (for tool search).
|
|
114
|
+
* @param onlyDeferred If true, only returns tools with defer_loading=true
|
|
115
|
+
* @returns LCToolRegistry with tool definitions
|
|
116
|
+
*/
|
|
117
|
+
getDeferredToolRegistry(onlyDeferred?: boolean): t.LCToolRegistry;
|
|
94
118
|
}
|
|
@@ -114,6 +114,8 @@ export declare enum Callback {
|
|
|
114
114
|
export declare enum Constants {
|
|
115
115
|
OFFICIAL_CODE_BASEURL = "https://api.librechat.ai/v1",
|
|
116
116
|
EXECUTE_CODE = "execute_code",
|
|
117
|
+
TOOL_SEARCH_REGEX = "tool_search_regex",
|
|
118
|
+
PROGRAMMATIC_TOOL_CALLING = "programmatic_code_execution",
|
|
117
119
|
WEB_SEARCH = "web_search",
|
|
118
120
|
CONTENT_AND_ARTIFACT = "content_and_artifact",
|
|
119
121
|
LC_TRANSFER_TO_ = "lc_transfer_to_"
|
|
@@ -91,9 +91,10 @@ export declare class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode>
|
|
|
91
91
|
instructions?: string;
|
|
92
92
|
additional_instructions?: string;
|
|
93
93
|
}): t.SystemRunnable | undefined;
|
|
94
|
-
initializeTools({ currentTools, currentToolMap, }: {
|
|
94
|
+
initializeTools({ currentTools, currentToolMap, agentContext, }: {
|
|
95
95
|
currentTools?: t.GraphTools;
|
|
96
96
|
currentToolMap?: t.ToolMap;
|
|
97
|
+
agentContext?: AgentContext;
|
|
97
98
|
}): CustomToolNode<t.BaseGraphState> | ToolNode<t.BaseGraphState>;
|
|
98
99
|
initializeModel({ provider, tools, clientOptions, }: {
|
|
99
100
|
provider: Providers;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ export * from './messages';
|
|
|
6
6
|
export * from './graphs';
|
|
7
7
|
export * from './tools/Calculator';
|
|
8
8
|
export * from './tools/CodeExecutor';
|
|
9
|
+
export * from './tools/ProgrammaticToolCalling';
|
|
10
|
+
export * from './tools/ToolSearchRegex';
|
|
9
11
|
export * from './tools/handlers';
|
|
10
12
|
export * from './tools/search';
|
|
11
13
|
export * from './common';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
2
|
+
import type { LCToolRegistry } from '@/types';
|
|
3
|
+
/**
|
|
4
|
+
* Mock get_team_members tool - returns list of team members
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGetTeamMembersTool(): StructuredToolInterface;
|
|
7
|
+
/**
|
|
8
|
+
* Mock get_expenses tool - returns expense records for a user
|
|
9
|
+
*/
|
|
10
|
+
export declare function createGetExpensesTool(): StructuredToolInterface;
|
|
11
|
+
/**
|
|
12
|
+
* Mock get_weather tool - returns weather data for a city
|
|
13
|
+
*/
|
|
14
|
+
export declare function createGetWeatherTool(): StructuredToolInterface;
|
|
15
|
+
/**
|
|
16
|
+
* Mock calculator tool - evaluates mathematical expressions
|
|
17
|
+
*/
|
|
18
|
+
export declare function createCalculatorTool(): StructuredToolInterface;
|
|
19
|
+
/**
|
|
20
|
+
* Creates a tool registry for programmatic tool calling tests.
|
|
21
|
+
* Tools are configured with allowed_callers to demonstrate classification.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createProgrammaticToolRegistry(): LCToolRegistry;
|
|
24
|
+
/**
|
|
25
|
+
* Creates a sample tool registry for tool search tests.
|
|
26
|
+
* Includes mix of deferred and non-deferred tools.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createToolSearchToolRegistry(): LCToolRegistry;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
declare const ProgrammaticToolCallingSchema: z.ZodObject<{
|
|
5
|
+
code: z.ZodString;
|
|
6
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
description: z.ZodOptional<z.ZodString>;
|
|
9
|
+
parameters: z.ZodAny;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name: string;
|
|
12
|
+
description?: string | undefined;
|
|
13
|
+
parameters?: any;
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
parameters?: any;
|
|
18
|
+
}>, "many">>;
|
|
19
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
20
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
code: string;
|
|
23
|
+
timeout: number;
|
|
24
|
+
tools?: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string | undefined;
|
|
27
|
+
parameters?: any;
|
|
28
|
+
}[] | undefined;
|
|
29
|
+
session_id?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
code: string;
|
|
32
|
+
tools?: {
|
|
33
|
+
name: string;
|
|
34
|
+
description?: string | undefined;
|
|
35
|
+
parameters?: any;
|
|
36
|
+
}[] | undefined;
|
|
37
|
+
timeout?: number | undefined;
|
|
38
|
+
session_id?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
/**
|
|
41
|
+
* Makes an HTTP request to the Code API.
|
|
42
|
+
* @param endpoint - The API endpoint URL
|
|
43
|
+
* @param apiKey - The API key for authentication
|
|
44
|
+
* @param body - The request body
|
|
45
|
+
* @param proxy - Optional HTTP proxy URL
|
|
46
|
+
* @returns The parsed API response
|
|
47
|
+
*/
|
|
48
|
+
export declare function makeRequest(endpoint: string, apiKey: string, body: Record<string, unknown>, proxy?: string): Promise<t.ProgrammaticExecutionResponse>;
|
|
49
|
+
/**
|
|
50
|
+
* Executes tools in parallel when requested by the API.
|
|
51
|
+
* Uses Promise.all for parallel execution, catching individual errors.
|
|
52
|
+
* @param toolCalls - Array of tool calls from the API
|
|
53
|
+
* @param toolMap - Map of tool names to executable tools
|
|
54
|
+
* @returns Array of tool results
|
|
55
|
+
*/
|
|
56
|
+
export declare function executeTools(toolCalls: t.PTCToolCall[], toolMap: t.ToolMap): Promise<t.PTCToolResult[]>;
|
|
57
|
+
/**
|
|
58
|
+
* Formats the completed response for the agent.
|
|
59
|
+
* @param response - The completed API response
|
|
60
|
+
* @returns Tuple of [formatted string, artifact]
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse): [string, t.ProgrammaticExecutionArtifact];
|
|
63
|
+
/**
|
|
64
|
+
* Creates a Programmatic Tool Calling tool for complex multi-tool workflows.
|
|
65
|
+
*
|
|
66
|
+
* This tool enables AI agents to write Python code that orchestrates multiple
|
|
67
|
+
* tool calls programmatically, reducing LLM round-trips and token usage.
|
|
68
|
+
*
|
|
69
|
+
* The tool map must be provided at runtime via config.configurable.toolMap.
|
|
70
|
+
*
|
|
71
|
+
* @param params - Configuration parameters (apiKey, baseUrl, maxRoundTrips, proxy)
|
|
72
|
+
* @returns A LangChain DynamicStructuredTool for programmatic tool calling
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* const ptcTool = createProgrammaticToolCallingTool({
|
|
76
|
+
* apiKey: process.env.CODE_API_KEY,
|
|
77
|
+
* maxRoundTrips: 20
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* const [output, artifact] = await ptcTool.invoke(
|
|
81
|
+
* { code, tools },
|
|
82
|
+
* { configurable: { toolMap } }
|
|
83
|
+
* );
|
|
84
|
+
*/
|
|
85
|
+
export declare function createProgrammaticToolCallingTool(initParams?: t.ProgrammaticToolCallingParams): DynamicStructuredTool<typeof ProgrammaticToolCallingSchema>;
|
|
86
|
+
export {};
|
|
@@ -13,7 +13,13 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
13
13
|
toolCallStepIds?: Map<string, string>;
|
|
14
14
|
errorHandler?: t.ToolNodeConstructorParams['errorHandler'];
|
|
15
15
|
private toolUsageCount;
|
|
16
|
-
|
|
16
|
+
/** Tools available for programmatic code execution */
|
|
17
|
+
private programmaticToolMap?;
|
|
18
|
+
/** Tool definitions for programmatic code execution (sent to Code API) */
|
|
19
|
+
private programmaticToolDefs?;
|
|
20
|
+
/** Tool registry for tool search (deferred tools) */
|
|
21
|
+
private toolRegistry?;
|
|
22
|
+
constructor({ tools, toolMap, name, tags, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, programmaticToolMap, programmaticToolDefs, toolRegistry, }: t.ToolNodeConstructorParams);
|
|
17
23
|
/**
|
|
18
24
|
* Returns a snapshot of the current tool usage counts.
|
|
19
25
|
* @returns A ReadonlyMap where keys are tool names and values are their usage counts.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
declare const ToolSearchRegexSchema: z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
fields: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<["name", "description", "parameters"]>, "many">>>;
|
|
7
|
+
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
fields: ("name" | "description" | "parameters")[];
|
|
11
|
+
max_results: number;
|
|
12
|
+
}, {
|
|
13
|
+
query: string;
|
|
14
|
+
fields?: ("name" | "description" | "parameters")[] | undefined;
|
|
15
|
+
max_results?: number | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Escapes special regex characters in a string to use as a literal pattern.
|
|
19
|
+
* @param pattern - The string to escape
|
|
20
|
+
* @returns The escaped string safe for use in a RegExp
|
|
21
|
+
*/
|
|
22
|
+
declare function escapeRegexSpecialChars(pattern: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Counts the maximum nesting depth of groups in a regex pattern.
|
|
25
|
+
* @param pattern - The regex pattern to analyze
|
|
26
|
+
* @returns The maximum nesting depth
|
|
27
|
+
*/
|
|
28
|
+
declare function countNestedGroups(pattern: string): number;
|
|
29
|
+
/**
|
|
30
|
+
* Detects nested quantifiers that can cause catastrophic backtracking.
|
|
31
|
+
* Patterns like (a+)+, (a*)*, (a+)*, etc.
|
|
32
|
+
* @param pattern - The regex pattern to check
|
|
33
|
+
* @returns True if nested quantifiers are detected
|
|
34
|
+
*/
|
|
35
|
+
declare function hasNestedQuantifiers(pattern: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a regex pattern contains potentially dangerous constructs.
|
|
38
|
+
* @param pattern - The regex pattern to validate
|
|
39
|
+
* @returns True if the pattern is dangerous
|
|
40
|
+
*/
|
|
41
|
+
declare function isDangerousPattern(pattern: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Sanitizes a regex pattern for safe execution.
|
|
44
|
+
* If the pattern is dangerous, it will be escaped to a literal string search.
|
|
45
|
+
* @param pattern - The regex pattern to sanitize
|
|
46
|
+
* @returns Object containing the safe pattern and whether it was escaped
|
|
47
|
+
*/
|
|
48
|
+
declare function sanitizeRegex(pattern: string): {
|
|
49
|
+
safe: string;
|
|
50
|
+
wasEscaped: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Tool Search Regex tool for discovering tools from a large registry.
|
|
54
|
+
*
|
|
55
|
+
* This tool enables AI agents to dynamically discover tools from a large library
|
|
56
|
+
* without loading all tool definitions into the LLM context window. The agent
|
|
57
|
+
* can search for relevant tools on-demand using regex patterns.
|
|
58
|
+
*
|
|
59
|
+
* The tool registry can be provided either:
|
|
60
|
+
* 1. At initialization time via params.toolRegistry
|
|
61
|
+
* 2. At runtime via config.configurable.toolRegistry when invoking
|
|
62
|
+
*
|
|
63
|
+
* @param params - Configuration parameters for the tool (toolRegistry is optional)
|
|
64
|
+
* @returns A LangChain DynamicStructuredTool for tool searching
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Option 1: Registry at initialization
|
|
68
|
+
* const tool = createToolSearchRegexTool({ apiKey, toolRegistry });
|
|
69
|
+
* await tool.invoke({ query: 'expense' });
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Option 2: Registry at runtime
|
|
73
|
+
* const tool = createToolSearchRegexTool({ apiKey });
|
|
74
|
+
* await tool.invoke(
|
|
75
|
+
* { query: 'expense' },
|
|
76
|
+
* { configurable: { toolRegistry, onlyDeferred: true } }
|
|
77
|
+
* );
|
|
78
|
+
*/
|
|
79
|
+
declare function createToolSearchRegexTool(initParams?: t.ToolSearchRegexParams): DynamicStructuredTool<typeof ToolSearchRegexSchema>;
|
|
80
|
+
export { createToolSearchRegexTool, sanitizeRegex, escapeRegexSpecialChars, isDangerousPattern, countNestedGroups, hasNestedQuantifiers, };
|
|
@@ -4,7 +4,7 @@ import type { BaseMessage, AIMessageChunk, SystemMessage } from '@langchain/core
|
|
|
4
4
|
import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
|
|
5
5
|
import type { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
6
6
|
import type { GoogleAIToolType } from '@langchain/google-common';
|
|
7
|
-
import type { ToolMap, ToolEndEvent, GenericTool } from '@/types/tools';
|
|
7
|
+
import type { ToolMap, ToolEndEvent, GenericTool, LCTool } from '@/types/tools';
|
|
8
8
|
import type { Providers, Callback, GraphNodeKeys } from '@/common';
|
|
9
9
|
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
10
10
|
import type { ClientOptions } from '@/types/llm';
|
|
@@ -248,4 +248,10 @@ export interface AgentInputs {
|
|
|
248
248
|
reasoningKey?: 'reasoning_content' | 'reasoning';
|
|
249
249
|
/** Format content blocks as strings (for legacy compatibility i.e. Ollama/Azure Serverless) */
|
|
250
250
|
useLegacyContent?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Tool definitions for all tools, including deferred and programmatic.
|
|
253
|
+
* Used for tool search and programmatic tool calling.
|
|
254
|
+
* Maps tool name to LCTool definition.
|
|
255
|
+
*/
|
|
256
|
+
toolRegistry?: Map<string, LCTool>;
|
|
251
257
|
}
|
|
@@ -25,6 +25,12 @@ export type ToolNodeOptions = {
|
|
|
25
25
|
loadRuntimeTools?: ToolRefGenerator;
|
|
26
26
|
toolCallStepIds?: Map<string, string>;
|
|
27
27
|
errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => Promise<void>;
|
|
28
|
+
/** Tools available for programmatic code execution (allowed_callers includes 'code_execution') */
|
|
29
|
+
programmaticToolMap?: ToolMap;
|
|
30
|
+
/** Tool definitions for programmatic code execution (sent to Code API for stub generation) */
|
|
31
|
+
programmaticToolDefs?: LCTool[];
|
|
32
|
+
/** Tool registry for tool search (deferred tool definitions) */
|
|
33
|
+
toolRegistry?: LCToolRegistry;
|
|
28
34
|
};
|
|
29
35
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
30
36
|
export type ToolEndEvent = {
|
|
@@ -59,3 +65,133 @@ export type ExecuteResult = {
|
|
|
59
65
|
stderr: string;
|
|
60
66
|
files?: FileRefs;
|
|
61
67
|
};
|
|
68
|
+
/** JSON Schema type definition for tool parameters */
|
|
69
|
+
export type JsonSchemaType = {
|
|
70
|
+
type: 'string' | 'number' | 'integer' | 'float' | 'boolean' | 'array' | 'object';
|
|
71
|
+
enum?: string[];
|
|
72
|
+
items?: JsonSchemaType;
|
|
73
|
+
properties?: Record<string, JsonSchemaType>;
|
|
74
|
+
required?: string[];
|
|
75
|
+
description?: string;
|
|
76
|
+
additionalProperties?: boolean | JsonSchemaType;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Specifies which contexts can invoke a tool (inspired by Anthropic's allowed_callers)
|
|
80
|
+
* - 'direct': Only callable directly by the LLM (default if omitted)
|
|
81
|
+
* - 'code_execution': Only callable from within programmatic code execution
|
|
82
|
+
*/
|
|
83
|
+
export type AllowedCaller = 'direct' | 'code_execution';
|
|
84
|
+
/** Tool definition with optional deferred loading and caller restrictions */
|
|
85
|
+
export type LCTool = {
|
|
86
|
+
name: string;
|
|
87
|
+
description?: string;
|
|
88
|
+
parameters?: JsonSchemaType;
|
|
89
|
+
/** When true, tool is not loaded into context initially (for tool search) */
|
|
90
|
+
defer_loading?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Which contexts can invoke this tool.
|
|
93
|
+
* Default: ['direct'] (only callable directly by LLM)
|
|
94
|
+
* Options: 'direct', 'code_execution'
|
|
95
|
+
*/
|
|
96
|
+
allowed_callers?: AllowedCaller[];
|
|
97
|
+
};
|
|
98
|
+
/** Map of tool names to tool definitions */
|
|
99
|
+
export type LCToolRegistry = Map<string, LCTool>;
|
|
100
|
+
/** Parameters for creating a Tool Search Regex tool */
|
|
101
|
+
export type ToolSearchRegexParams = {
|
|
102
|
+
apiKey?: string;
|
|
103
|
+
toolRegistry?: LCToolRegistry;
|
|
104
|
+
onlyDeferred?: boolean;
|
|
105
|
+
baseUrl?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
/** Simplified tool metadata for search purposes */
|
|
109
|
+
export type ToolMetadata = {
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
parameters?: JsonSchemaType;
|
|
113
|
+
};
|
|
114
|
+
/** Individual search result for a matching tool */
|
|
115
|
+
export type ToolSearchResult = {
|
|
116
|
+
tool_name: string;
|
|
117
|
+
match_score: number;
|
|
118
|
+
matched_field: string;
|
|
119
|
+
snippet: string;
|
|
120
|
+
};
|
|
121
|
+
/** Response from the tool search operation */
|
|
122
|
+
export type ToolSearchResponse = {
|
|
123
|
+
tool_references: ToolSearchResult[];
|
|
124
|
+
total_tools_searched: number;
|
|
125
|
+
pattern_used: string;
|
|
126
|
+
};
|
|
127
|
+
/** Artifact returned alongside the formatted search results */
|
|
128
|
+
export type ToolSearchArtifact = {
|
|
129
|
+
tool_references: ToolSearchResult[];
|
|
130
|
+
metadata: {
|
|
131
|
+
total_searched: number;
|
|
132
|
+
pattern: string;
|
|
133
|
+
error?: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Tool call requested by the Code API during programmatic execution
|
|
138
|
+
*/
|
|
139
|
+
export type PTCToolCall = {
|
|
140
|
+
/** Unique ID like "call_001" */
|
|
141
|
+
id: string;
|
|
142
|
+
/** Tool name */
|
|
143
|
+
name: string;
|
|
144
|
+
/** Input parameters */
|
|
145
|
+
input: Record<string, any>;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Tool result sent back to the Code API
|
|
149
|
+
*/
|
|
150
|
+
export type PTCToolResult = {
|
|
151
|
+
/** Matches PTCToolCall.id */
|
|
152
|
+
call_id: string;
|
|
153
|
+
/** Tool execution result (any JSON-serializable value) */
|
|
154
|
+
result: any;
|
|
155
|
+
/** Whether tool execution failed */
|
|
156
|
+
is_error: boolean;
|
|
157
|
+
/** Error details if is_error=true */
|
|
158
|
+
error_message?: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Response from the Code API for programmatic execution
|
|
162
|
+
*/
|
|
163
|
+
export type ProgrammaticExecutionResponse = {
|
|
164
|
+
status: 'tool_call_required' | 'completed' | 'error' | unknown;
|
|
165
|
+
session_id?: string;
|
|
166
|
+
/** Present when status='tool_call_required' */
|
|
167
|
+
continuation_token?: string;
|
|
168
|
+
tool_calls?: PTCToolCall[];
|
|
169
|
+
/** Present when status='completed' */
|
|
170
|
+
stdout?: string;
|
|
171
|
+
stderr?: string;
|
|
172
|
+
files?: FileRefs;
|
|
173
|
+
/** Present when status='error' */
|
|
174
|
+
error?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Artifact returned by the PTC tool
|
|
178
|
+
*/
|
|
179
|
+
export type ProgrammaticExecutionArtifact = {
|
|
180
|
+
session_id?: string;
|
|
181
|
+
files?: FileRefs;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Initialization parameters for the PTC tool
|
|
185
|
+
*/
|
|
186
|
+
export type ProgrammaticToolCallingParams = {
|
|
187
|
+
/** Code API key (or use CODE_API_KEY env var) */
|
|
188
|
+
apiKey?: string;
|
|
189
|
+
/** Code API base URL (or use CODE_BASEURL env var) */
|
|
190
|
+
baseUrl?: string;
|
|
191
|
+
/** Safety limit for round-trips (default: 20) */
|
|
192
|
+
maxRoundTrips?: number;
|
|
193
|
+
/** HTTP proxy URL */
|
|
194
|
+
proxy?: string;
|
|
195
|
+
/** Environment variable key for API key */
|
|
196
|
+
[key: string]: unknown;
|
|
197
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@librechat/agents",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.40",
|
|
4
4
|
"main": "./dist/cjs/main.cjs",
|
|
5
5
|
"module": "./dist/esm/main.mjs",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -53,6 +53,10 @@
|
|
|
53
53
|
"memory": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/memory.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
54
54
|
"tool": "node --trace-warnings -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider 'openrouter' --name 'Jo' --location 'New York, NY'",
|
|
55
55
|
"search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/search.ts --provider 'bedrock' --name 'Jo' --location 'New York, NY'",
|
|
56
|
+
"tool_search_regex": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tool_search_regex.ts",
|
|
57
|
+
"programmatic_exec": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/programmatic_exec.ts",
|
|
58
|
+
"code_exec_ptc": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_ptc.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
59
|
+
"programmatic_exec_agent": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/programmatic_exec_agent.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
56
60
|
"ant_web_search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search.ts --name 'Jo' --location 'New York, NY'",
|
|
57
61
|
"ant_web_search_edge_case": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search_edge_case.ts --name 'Jo' --location 'New York, NY'",
|
|
58
62
|
"ant_web_search_error_edge_case": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search_error_edge_case.ts --name 'Jo' --location 'New York, NY'",
|