/** * Shared wall-clock/cancellation envelope for one-shot lane completions (research and delegated workers). * Composes an optional external abort signal with an internal wall-clock timeout, executes the * injected completion, and maps every failure to a stable status/reasonCode pair. Never throws. */ export interface BoundedCompletion { text: string; costUsd: number; stopReason: string; } export type BoundedCompletionFailureStatus = "canceled" | "timeout" | "failed" | "budget_exhausted"; /** * Typed failure crossing the executor boundary. Policy owners use this instead of forcing the * completion envelope to infer a bounded denial from human-readable error text. */ export declare class BoundedCompletionFailureError extends Error { readonly status: BoundedCompletionFailureStatus; readonly reasonCode: string; /** * `cause`, when the error wraps an upstream failure (e.g. an exhausted provider retry ladder), * preserves the original error's identity/type/stack for callers that need to inspect it — * wrapping otherwise launders it down to a message string, which the redacted `detail` extracted * by {@link boundedFailureDetail} intentionally is not a substitute for. */ constructor(status: BoundedCompletionFailureStatus, reasonCode: string, message: string, cause?: unknown); } export interface BoundedCompletionOutcome { /** Present when the executor settled; may coexist with `failure` when an abort raced the result. */ completion?: BoundedCompletion; failure?: { status: BoundedCompletionFailureStatus; reasonCode: string; detail?: string; }; } /** * Preserve the executor's actual error alongside the stable reason code. A bare * `completion_error` is undiagnosable from lane records alone (field lesson: workers dying * on provider socket drops and budget denials all flattened to the same code). */ export declare function boundedFailureDetail(error: unknown): string | undefined; export declare function runBoundedCompletion(args: { /** Wall-clock budget in milliseconds; 0 disables. */ maxWallClockMs: number; /** External cancellation (e.g. session disposal). */ signal?: AbortSignal; execute: (signal: AbortSignal) => Promise; }): Promise; //# sourceMappingURL=bounded-completion.d.ts.map