/** * Builtin "execute_code" tool — registers as a tool the agent can call, * dispatches the script through executeCode(), returns the script's * result back to the agent loop. * * The tool's args: * { script: string, profile?: "tight"|"read-only"|"standard"|"broad" } * * The tool's result: * { ok: boolean, result?: unknown, error?: string, durationMs: number, * logs: ScriptLogEntry[], stdout?: string, stderr?: string } * * The tool runner is constructed per-call so it has access to the live * driver registry. Subagent tool calls (from inside the script) get * dispatched through the driver's tool broker via a thin adapter. * * This module does NOT auto-register on import — the caller chooses * when (and which subset of profiles) to expose. Registration goes * through the driver's allowedTools list so the model can only invoke * execute_code when the harness explicitly enables it. */ import { type ExecuteCodeResult } from "./execute-code.js"; import { type SecurityProfileName } from "./security-policy.js"; import type { ToolRunner } from "./tools-rpc-server.js"; export interface ExecuteCodeBuiltinArgs { script: string; profile?: SecurityProfileName; /** Optional per-call overrides to the chosen profile. */ overrides?: { timeoutMs?: number; memoryMb?: number; }; } export interface ExecuteCodeBuiltinDeps { /** * Returns a ToolRunner for the resolved tool surface. The runner's * .run(ctx) translates a script-side tool call into whatever the * host wants (typically: dispatch through the driver's broker). */ buildRunner(allowedToolNames: readonly string[]): ToolRunner; /** Optional default profile when the caller doesn't pass one. */ defaultProfile?: SecurityProfileName; /** Optional callback when the script wants approval (broad profile). */ requestApproval?: (preview: { script: string; profile: SecurityProfileName; }) => Promise; } export declare const EXECUTE_CODE_TOOL_NAME = "execute_code"; export declare function dispatchExecuteCode(args: ExecuteCodeBuiltinArgs, deps: ExecuteCodeBuiltinDeps): Promise; /** * Convenience: a ToolRunner factory that simply maps tool name to a * caller-supplied async function. Useful for tests and for very * targeted hosts that don't want to plug in the full broker. */ export declare function makeFunctionRunner(handlers: Record unknown | Promise>): ToolRunner;