/** * Tool execution interceptor — wraps tool.execute() for tools in mockTools. * * For mocked tools, we: * 1. Fire extension tool_call hooks (which can block execution) * 2. Return mock results instead of calling the real tool * 3. Fire extension tool_result hooks (which can modify results) * * This preserves the full extension hook chain while avoiding real tool execution. */ import type { AgentTool } from "@earendil-works/pi-agent-core"; import type { ExtensionRunner } from "@earendil-works/pi-coding-agent"; import type { MockToolHandler, ToolResultRecord } from "./types.js"; import type { PlaybookState } from "./playbook.js"; /** * Thrown when an extension hook blocks a tool call. * Used instead of plain Error so wrapForCollection can reliably detect blocks * without fragile message-string matching. */ export declare class ToolBlockedError extends Error { readonly toolBlocked: true; constructor(reason: string); } /** * Returns true if `err` represents a hook-based tool block. * * Two sources produce block errors: * 1. The harness's own mock path → throws `ToolBlockedError` (instanceof check). * 2. Pi's native `wrapToolsWithExtensions` hook chain → throws a plain `Error` * with a message containing known block phrases. We keep message-string * fallback detection for these until pi exports a typed error class. */ export declare function isBlockedError(err: unknown): boolean; /** * Intercept tool execution for mocked tools. * Returns the modified tools array (original tools wrapped where needed). * * When an extensionRunner is provided, mocked tools fire tool_call/tool_result * hooks so that extension blocking (e.g., plan mode) works correctly. */ export declare function interceptToolExecution(tools: AgentTool[], mockTools: Record, toolResults: ToolResultRecord[], playbookState: PlaybookState, propagateErrors: boolean, extensionRunner?: ExtensionRunner): AgentTool[]; //# sourceMappingURL=mock-tools.d.ts.map