export interface ToolDef {
name: string;
description: string;
parameters: ToolParameterSchema;
execute: (args: Record<string, unknown>, ctx: RunContext) => Promise<string | ToolResult>;
/** Raw JSON Schema to send to the LLM, bypassing Zod-to-JSON conversion (used by MCP tools). */
rawJsonSchema?: Record<string, unknown>;
/** Enable result caching for this tool. */
cache?: ToolCacheConfig;
/** Run this tool in a sandboxed subprocess. Off by default. */
sandbox?: boolean | SandboxConfig;
/**
* Require approval before execution; no configured approval service denies the
* call. False overrides legacy approval defaults, never mandatory host policy.
*/
requiresApproval?: boolean | ((args: Record<string, unknown>) => boolean);
/** Enable strict mode for OpenAI Structured Outputs on tool calls. Guarantees valid JSON matching the schema. */
strict?: boolean;
/**
* Optional N-shot examples that demonstrate valid tool calls to the LLM.
* Each example is rendered into the tool's JSON Schema description.
*/
inputExamples?: Array<Record<string, unknown>>;
/**
* Optional async transformer applied to the tool result *after* execution but
* *before* the result is appended to the LLM context. Use to compress, summarize,
* redact, or otherwise reshape large outputs.
*/
toModelOutput?: (result: string | ToolResult, ctx: RunContext) => Promise<string | ToolResult>;
}