/**
 * Generic tool-error retry harness.
 *
 * Lifts the `verification_result`-only schema-retry pattern from
 * `verification-harness.ts` (`buildJsonRetryPrompt` + `tool_execution_end`
 * listeners) into a reusable, instance-per-session helper that observes
 * every session and re-emits a targeted nudge when any tool call
 * returns a deterministic JSON / structured-input validation error.
 *
 * Coverage classes:
 *   - `isError === true` matching `detectJsonValidationError` (V8/Node
 *     SyntaxError family + "Validation failed for tool").
 *   - `isError === false` with an `ok({ error })` body whose text starts
 *     with `ask_user_choices: questions[` or `propose_*:` — these are
 *     successful tool invocations whose extension returned a structured
 *     validation error.
 *
 * Retries are dispatched via `rpcClient.prompt(nudge)` — the same path
 * verification reminders use. Never `_dispatchSteer`, never
 * `enqueuePrompt`. Per-`tool_use_id` cap (default 2). The harness never
 * writes a user-visible message.
 *
 * Verification harness coordination: the verification harness adds the
 * `tool_use_id` it's about to retry to `session._verificationOwnedToolUses`;
 * this harness skips any `tool_use_id` already in that set.
 *
 * See `docs/design/tool-retry-harness.md` for the full design.
 */
export type RetryClassifier = "schema" | "domain" | "ignore";
/**
 * Subset of `tool_execution_end` event fields the harness reads. The real
 * pi-coding-agent event carries more — we're deliberately narrow so unit
 * tests can synthesise events without dragging in the SDK.
 */
export interface ToolExecutionEndEvent {
    type: "tool_execution_end" | string;
    toolCallId?: string;
    toolName?: string;
    isError?: boolean;
    result?: unknown;
}
export interface RpcClientLike {
    onEvent(cb: (event: any) => void): () => void;
    prompt(text: string): Promise<unknown>;
}
export interface SessionLike {
    id: string;
    rpcClient: RpcClientLike;
    /**
     * Tool-use IDs whose retry is owned by `verification-harness.ts`.
     * The generic harness defers to the verification path on these IDs.
     */
    _verificationOwnedToolUses?: Set<string>;
}
export interface ToolRetryMetadataDelta {
    count: number;
    lastReason: string;
}
export interface ToolRetryHarnessOptions {
    session: SessionLike;
    maxRetries?: number;
    /**
     * Optional callback invoked after each retry-nudge dispatch; lets the
     * caller persist `{count, lastReason}` to session metadata.
     */
    onMetadata?: (delta: ToolRetryMetadataDelta) => void;
    /**
     * Optional debug hook. The default is the temporary
     * `console.debug("[tool-retry] ...")` line described in the goal's
     * instrumentation plan.
     */
    debug?: (msg: string, info: Record<string, unknown>) => void;
}
/** Best-effort extract of a readable string from an agent tool result. */
export declare function extractToolResultText(result: unknown): string;
/**
 * Inspect a successful (`isError===false`) tool result for a structured
 * `{ error: "..." }` validation message. Returns the error string or null.
 */
export declare function detectStructuredValidationError(text: string): string | null;
export declare function buildToolRetryNudge(toolName: string, quotedError: string): string;
export declare class ToolRetryHarness {
    private readonly session;
    private readonly maxRetries;
    private readonly onMetadata?;
    private readonly debug;
    private unsub;
    private retries;
    /** Total nudges issued in this session. Used for the metadata `count` field. */
    private totalRetries;
    constructor(opts: ToolRetryHarnessOptions);
    start(): void;
    stop(): void;
    /**
     * Public for tests — classify a `tool_execution_end` event into one of
     * `"schema" | "domain" | "ignore"`.
     */
    classify(event: ToolExecutionEndEvent): RetryClassifier;
    /** Public for tests. */
    buildNudge(toolName: string, quotedError: string): string;
    private _handleEvent;
}
//# sourceMappingURL=tool-retry-harness.d.ts.map