{"version":3,"file":"BashProgrammaticToolCalling.mjs","sources":["../../../src/tools/BashProgrammaticToolCalling.ts"],"sourcesContent":["import { config } from 'dotenv';\nimport { getEnvironmentVariable } from '@langchain/core/utils/env';\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\nimport type { ToolCall } from '@langchain/core/messages/tool';\nimport type * as t from '@/types';\nimport {\n  makeRequest,\n  executeTools,\n  fetchSessionFiles,\n  formatCompletedResponse,\n} from './ProgrammaticToolCalling';\nimport { getCodeBaseURL } from './CodeExecutor';\nimport { Constants, EnvVar } from '@/common';\n\nconfig();\n\n// ============================================================================\n// Constants\n// ============================================================================\n\nconst DEFAULT_MAX_ROUND_TRIPS = 20;\nconst DEFAULT_TIMEOUT = 60000;\n\n/** Bash reserved words that get `_tool` suffix when used as function names */\nconst BASH_RESERVED = new Set([\n  'if',\n  'then',\n  'else',\n  'elif',\n  'fi',\n  'case',\n  'esac',\n  'for',\n  'while',\n  'until',\n  'do',\n  'done',\n  'in',\n  'function',\n  'select',\n  'time',\n  'coproc',\n  'declare',\n  'typeset',\n  'local',\n  'readonly',\n  'export',\n  'unset',\n]);\n\n// ============================================================================\n// Description Components\n// ============================================================================\n\nconst STATELESS_WARNING = `CRITICAL - STATELESS EXECUTION:\nEach call is a fresh bash shell. Variables and state do NOT persist between calls.\nYou MUST complete your entire workflow in ONE code block.\nDO NOT split work across multiple calls expecting to reuse variables.`;\n\nconst CORE_RULES = `Rules:\n- EVERYTHING in one call—no state persists between executions\n- Tools are pre-defined as bash functions—DO NOT redefine them\n- Each tool function accepts a JSON string argument\n- Only echo/printf output returns to the model\n- Generated files are automatically available in /mnt/data/ for subsequent executions`;\n\nconst ADDITIONAL_RULES =\n  '- Tool names normalized: hyphens→underscores, reserved words get `_tool` suffix';\n\nconst EXAMPLES = `Example (Complete workflow in one call):\n  # Query data and process\n  data=$(query_database '{\"sql\": \"SELECT * FROM users\"}')\n  echo \"$data\" | jq '.[] | .name'\n\nExample (Parallel calls):\n  web_search '{\"query\": \"SF weather\"}' > /tmp/sf.txt &\n  web_search '{\"query\": \"NY weather\"}' > /tmp/ny.txt &\n  wait\n  echo \"SF: $(cat /tmp/sf.txt)\"\n  echo \"NY: $(cat /tmp/ny.txt)\"`;\n\nconst CODE_PARAM_DESCRIPTION = `Bash code that calls tools programmatically. Tools are available as bash functions.\n\n${STATELESS_WARNING}\n\nEach tool function accepts a JSON string as its argument.\nExample: tool_name '{\"key\": \"value\"}'\n\n${EXAMPLES}\n\n${CORE_RULES}`;\n\n// ============================================================================\n// Schema\n// ============================================================================\n\nexport const BashProgrammaticToolCallingSchema = {\n  type: 'object',\n  properties: {\n    code: {\n      type: 'string',\n      minLength: 1,\n      description: CODE_PARAM_DESCRIPTION,\n    },\n    timeout: {\n      type: 'integer',\n      minimum: 1000,\n      maximum: 300000,\n      default: DEFAULT_TIMEOUT,\n      description:\n        'Maximum execution time in milliseconds. Default: 60 seconds. Max: 5 minutes.',\n    },\n  },\n  required: ['code'],\n} as const;\n\nexport const BashProgrammaticToolCallingName =\n  Constants.BASH_PROGRAMMATIC_TOOL_CALLING;\n\nexport const BashProgrammaticToolCallingDescription = `\nRun tools via bash code. Tools are available as bash functions that accept JSON string arguments.\n\n${STATELESS_WARNING}\n\n${CORE_RULES}\n${ADDITIONAL_RULES}\n\nWhen to use: shell pipelines, parallel execution (& and wait), file processing, text manipulation.\n\n${EXAMPLES}\n`.trim();\n\nexport const BashProgrammaticToolCallingDefinition = {\n  name: BashProgrammaticToolCallingName,\n  description: BashProgrammaticToolCallingDescription,\n  schema: BashProgrammaticToolCallingSchema,\n} as const;\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Normalizes a tool name to a valid bash function identifier.\n * 1. Replace hyphens, spaces, dots with underscores\n * 2. Remove any other invalid characters\n * 3. Prefix with underscore if starts with number\n * 4. Append `_tool` if it's a bash reserved word\n */\nexport function normalizeToBashIdentifier(name: string): string {\n  let normalized = name.replace(/[-\\s.]/g, '_');\n  normalized = normalized.replace(/[^a-zA-Z0-9_]/g, '');\n\n  if (/^[0-9]/.test(normalized)) {\n    normalized = '_' + normalized;\n  }\n\n  if (BASH_RESERVED.has(normalized)) {\n    normalized = normalized + '_tool';\n  }\n\n  return normalized;\n}\n\n/**\n * Extracts tool names that are actually called in the bash code.\n * Bash functions are invoked as commands (no parentheses), so we match\n * the normalized name as a word boundary.\n */\nexport function extractUsedBashToolNames(\n  code: string,\n  toolNameMap: Map<string, string>\n): Set<string> {\n  const usedTools = new Set<string>();\n\n  for (const [bashName, originalName] of toolNameMap) {\n    const escapedName = bashName.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n    const pattern = new RegExp(`\\\\b${escapedName}\\\\b`, 'g');\n\n    if (pattern.test(code)) {\n      usedTools.add(originalName);\n    }\n  }\n\n  return usedTools;\n}\n\n/**\n * Filters tool definitions to only include tools actually used in the bash code.\n */\nexport function filterBashToolsByUsage(\n  toolDefs: t.LCTool[],\n  code: string,\n  debug = false\n): t.LCTool[] {\n  const toolNameMap = new Map<string, string>();\n  for (const def of toolDefs) {\n    const bashName = normalizeToBashIdentifier(def.name);\n    toolNameMap.set(bashName, def.name);\n  }\n\n  const usedToolNames = extractUsedBashToolNames(code, toolNameMap);\n\n  if (debug) {\n    // eslint-disable-next-line no-console\n    console.log(\n      `[BashPTC Debug] Tool filtering: found ${usedToolNames.size}/${toolDefs.length} tools in code`\n    );\n    if (usedToolNames.size > 0) {\n      // eslint-disable-next-line no-console\n      console.log(\n        `[BashPTC Debug] Matched tools: ${Array.from(usedToolNames).join(', ')}`\n      );\n    }\n  }\n\n  if (usedToolNames.size === 0) {\n    if (debug) {\n      // eslint-disable-next-line no-console\n      console.log(\n        '[BashPTC Debug] No tools detected in code - sending all tools as fallback'\n      );\n    }\n    return toolDefs;\n  }\n\n  return toolDefs.filter((def) => usedToolNames.has(def.name));\n}\n\n// ============================================================================\n// Tool Factory\n// ============================================================================\n\n/**\n * Creates a Bash Programmatic Tool Calling tool for multi-tool orchestration.\n *\n * This tool enables AI agents to write bash scripts that orchestrate multiple\n * tool calls programmatically via the remote Code API, reducing LLM round-trips.\n *\n * The tool map must be provided at runtime via config.toolCall (injected by ToolNode).\n */\nexport function createBashProgrammaticToolCallingTool(\n  initParams: t.BashProgrammaticToolCallingParams = {}\n): DynamicStructuredTool {\n  const apiKey =\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(\n      'No API key provided for bash programmatic tool calling. ' +\n        'Set CODE_API_KEY environment variable or pass apiKey in initParams.'\n    );\n  }\n\n  const baseUrl = initParams.baseUrl ?? getCodeBaseURL();\n  const maxRoundTrips = initParams.maxRoundTrips ?? DEFAULT_MAX_ROUND_TRIPS;\n  const proxy = initParams.proxy ?? process.env.PROXY;\n  const debug = initParams.debug ?? process.env.BASH_PTC_DEBUG === 'true';\n  const EXEC_ENDPOINT = `${baseUrl}/exec/programmatic`;\n\n  return tool(\n    async (rawParams, config) => {\n      const params = rawParams as { code: string; timeout?: number };\n      const { code, timeout = DEFAULT_TIMEOUT } = params;\n\n      const { toolMap, toolDefs, session_id, _injected_files } =\n        (config.toolCall ?? {}) as ToolCall &\n          Partial<t.ProgrammaticCache> & {\n            session_id?: string;\n            _injected_files?: t.CodeEnvFile[];\n          };\n\n      if (toolMap == null || toolMap.size === 0) {\n        throw new Error(\n          'No toolMap provided. ' +\n            'ToolNode should inject this from AgentContext when invoked through the graph.'\n        );\n      }\n\n      if (toolDefs == null || toolDefs.length === 0) {\n        throw new Error(\n          'No tool definitions provided. ' +\n            'Either pass tools in the input or ensure ToolNode injects toolDefs.'\n        );\n      }\n\n      let roundTrip = 0;\n\n      try {\n        // ====================================================================\n        // Phase 1: Filter tools and make initial request\n        // ====================================================================\n\n        const effectiveTools = filterBashToolsByUsage(toolDefs, code, debug);\n\n        if (debug) {\n          // eslint-disable-next-line no-console\n          console.log(\n            `[BashPTC Debug] Sending ${effectiveTools.length} tools to API ` +\n              `(filtered from ${toolDefs.length})`\n          );\n        }\n\n        let files: t.CodeEnvFile[] | undefined;\n        if (_injected_files && _injected_files.length > 0) {\n          files = _injected_files;\n        } else if (session_id != null && session_id.length > 0) {\n          files = await fetchSessionFiles(baseUrl, apiKey, session_id, proxy);\n        }\n\n        let response = await makeRequest(\n          EXEC_ENDPOINT,\n          apiKey,\n          {\n            lang: 'bash',\n            code,\n            tools: effectiveTools,\n            session_id,\n            timeout,\n            ...(files && files.length > 0 ? { files } : {}),\n          },\n          proxy\n        );\n\n        // ====================================================================\n        // Phase 2: Handle response loop\n        // ====================================================================\n\n        while (response.status === 'tool_call_required') {\n          roundTrip++;\n\n          if (roundTrip > maxRoundTrips) {\n            throw new Error(\n              `Exceeded maximum round trips (${maxRoundTrips}). ` +\n                'This may indicate an infinite loop, excessive tool calls, ' +\n                'or a logic error in your code.'\n            );\n          }\n\n          if (debug) {\n            // eslint-disable-next-line no-console\n            console.log(\n              `[BashPTC Debug] Round trip ${roundTrip}: ${response.tool_calls?.length ?? 0} tool(s) to execute`\n            );\n          }\n\n          const toolResults = await executeTools(\n            response.tool_calls ?? [],\n            toolMap\n          );\n\n          response = await makeRequest(\n            EXEC_ENDPOINT,\n            apiKey,\n            {\n              continuation_token: response.continuation_token,\n              tool_results: toolResults,\n            },\n            proxy\n          );\n        }\n\n        // ====================================================================\n        // Phase 3: Handle final state\n        // ====================================================================\n\n        if (response.status === 'completed') {\n          return formatCompletedResponse(response);\n        }\n\n        if (response.status === 'error') {\n          throw new Error(\n            `Execution error: ${response.error}` +\n              (response.stderr != null && response.stderr !== ''\n                ? `\\n\\nStderr:\\n${response.stderr}`\n                : '')\n          );\n        }\n\n        throw new Error(`Unexpected response status: ${response.status}`);\n      } catch (error) {\n        throw new Error(\n          `Bash programmatic execution failed: ${(error as Error).message}`\n        );\n      }\n    },\n    {\n      name: Constants.BASH_PROGRAMMATIC_TOOL_CALLING,\n      description: BashProgrammaticToolCallingDescription,\n      schema: BashProgrammaticToolCallingSchema,\n      responseFormat: Constants.CONTENT_AND_ARTIFACT,\n    }\n  );\n}\n"],"names":[],"mappings":";;;;;;;;AAcA,MAAM,EAAE;AAER;AACA;AACA;AAEA,MAAM,uBAAuB,GAAG,EAAE;AAClC,MAAM,eAAe,GAAG,KAAK;AAE7B;AACA,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;IACP,OAAO;IACP,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,UAAU;IACV,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,SAAS;IACT,SAAS;IACT,OAAO;IACP,UAAU;IACV,QAAQ;IACR,OAAO;AACR,CAAA,CAAC;AAEF;AACA;AACA;AAEA,MAAM,iBAAiB,GAAG,CAAA;;;sEAG4C;AAEtE,MAAM,UAAU,GAAG,CAAA;;;;;sFAKmE;AAEtF,MAAM,gBAAgB,GACpB,iFAAiF;AAEnF,MAAM,QAAQ,GAAG,CAAA;;;;;;;;;;gCAUe;AAEhC,MAAM,sBAAsB,GAAG,CAAA;;EAE7B,iBAAiB;;;;;EAKjB,QAAQ;;AAER,EAAA,UAAU,EAAE;AAEd;AACA;AACA;AAEO,MAAM,iCAAiC,GAAG;AAC/C,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,UAAU,EAAE;AACV,QAAA,IAAI,EAAE;AACJ,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,SAAS,EAAE,CAAC;AACZ,YAAA,WAAW,EAAE,sBAAsB;AACpC,SAAA;AACD,QAAA,OAAO,EAAE;AACP,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,OAAO,EAAE,IAAI;AACb,YAAA,OAAO,EAAE,MAAM;AACf,YAAA,OAAO,EAAE,eAAe;AACxB,YAAA,WAAW,EACT,8EAA8E;AACjF,SAA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