{"version":3,"file":"code_execution.cjs","names":[],"sources":["../../src/tools/code_execution.ts"],"sourcesContent":["/**\n * xAI Code Execution tool type constant.\n * Note: The Responses API uses \"code_interpreter\" as the type name.\n */\nexport const XAI_CODE_EXECUTION_TOOL_TYPE = \"code_interpreter\";\n\n/**\n * xAI's built-in code execution tool interface.\n * Enables the model to write and execute Python code in real-time.\n *\n * This tool is part of xAI's agentic tool calling API and allows for:\n * - Mathematical computations\n * - Data analysis\n * - Financial modeling\n * - Scientific computing\n * - Code generation and testing\n */\nexport interface XAICodeExecutionTool {\n  /**\n   * The type of the tool. Must be \"code_interpreter\".\n   */\n  type: typeof XAI_CODE_EXECUTION_TOOL_TYPE;\n}\n\n/**\n * Creates an xAI code execution tool.\n * Enables the model to write and execute Python code in real-time for\n * calculations, data analysis, and complex computations.\n *\n * This tool is executed server-side by the xAI API in a secure, sandboxed\n * Python environment with common libraries pre-installed (NumPy, Pandas,\n * Matplotlib, SciPy).\n *\n * @returns An XAICodeExecutionTool object to pass to the model\n *\n * @example Basic usage\n * ```typescript\n * import { ChatXAIResponses, tools } from \"@langchain/xai\";\n *\n * const llm = new ChatXAIResponses({\n *   model: \"grok-4-1-fast\",\n * });\n *\n * const codeExecution = tools.xaiCodeExecution();\n * const result = await llm.invoke(\n *   \"Calculate the compound interest for $10,000 at 5% annually for 10 years\",\n *   { tools: [codeExecution] }\n * );\n * ```\n *\n * @example Combining with search tools\n * ```typescript\n * const webSearch = tools.xaiWebSearch();\n * const codeExecution = tools.xaiCodeExecution();\n *\n * const result = await llm.invoke(\n *   \"Find the current stock price of AAPL and calculate what it would be worth with 10% annual growth over 5 years\",\n *   { tools: [webSearch, codeExecution] }\n * );\n * ```\n */\nexport function xaiCodeExecution(): XAICodeExecutionTool {\n  return {\n    type: XAI_CODE_EXECUTION_TOOL_TYPE,\n  };\n}\n"],"mappings":";;;;;AAIA,MAAa,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD5C,SAAgB,mBAAyC;AACvD,QAAO,EACL,MAAM,8BACP"}