import type { Sandbox, ScriptLanguage } from './types.js'; import type { RegisteredTool } from '../tool/types.js'; /** 代码执行结构化结果 */ export interface CodeExecutionResult { /** 标准输出 */ stdout: string; /** 标准错误输出 */ stderr: string; /** 进程退出码(0 = 成功) */ exitCode: number; /** 执行过程中产生/修改的文件列表(相对路径) */ files: string[]; /** 生成的图表标识列表(如 plot 文件名或 chart ID) */ charts?: string[]; /** 执行耗时(毫秒) */ duration: number; } /** * 代码执行沙箱接口 * * 扩展 Sandbox,在 runScript 基础上增加 execute 方法, * 返回结构化的执行结果(stdout / stderr / exitCode / files / charts / duration)。 */ export interface CodeSandbox extends Sandbox { /** * 执行代码并返回结构化结果 * @param code 代码内容 * @param lang 脚本语言 * @param timeout 执行超时 (ms) */ execute(code: string, lang: ScriptLanguage, timeout?: number): Promise; /** * 执行已物化的脚本文件(已注入 sb preamble,无需再次 prepareScript)。 * * 用于 skill 整包执行:prepareScriptInPackage 物化入口后直接运行该文件, * cwd 设为包根目录,使 `from lib import` / `from config import` 等包内依赖 * 正确解析(Python 会将脚本所在目录加入 sys.path)。 * * @param filePath 已物化的脚本文件绝对路径 * @param lang 脚本语言 * @param opts { timeout?, cwd?, args? } */ executeFile(filePath: string, lang: ScriptLanguage, opts?: { timeout?: number; cwd?: string; args?: string[]; }): Promise; } /** * 创建代码执行工具(RegisteredTool 格式) * * 供 Agent 通过 function calling 在沙箱中执行代码, * 返回结构化结果(stdout / stderr / exitCode / files / charts / duration)。 * * @param sandbox CodeSandbox 实例 */ export declare function createCodeExecutionTool(sandbox: CodeSandbox): RegisteredTool; //# sourceMappingURL=code-sandbox.d.ts.map