/** * The execution body: Context → Plan → Execute → Judge → Report. Every variable behavior * is injected (invariant #2); with a fixed-scenario Planner + deterministic Critic, no LLM * runs (invariant #4). */ import type { CustomAction, Harness, StepHandler, StepHealer } from "./ports.js"; import type { AssertionResult, ExecutedAction, Result, RunUsage, StepProgress, Verdict } from "./types.js"; import type { TraceScope } from "./trace.js"; /** * Seams a host (CLI, desktop app, CI) plugs into — the engine emits/accepts, the host * decides what to do. `onStep` for a live timeline, `captureScreenshots` for visual * replay, `signal` for a Stop button, `actions` for product-defined interactions. None of * these put UI in the engine. */ export interface RunHarnessOptions { signal?: AbortSignal; onStep?: (progress: StepProgress) => void; captureScreenshots?: boolean; /** Product-defined interactions for `{ kind: "custom", name }` steps, registered by name. */ actions?: Record; /** Replace the Execute-stage dispatch chain entirely (advanced); defaults to built-ins + `actions`. */ stepHandlers?: StepHandler[]; /** Repair a step whose `expect` fails (surgical self-heal); absent → a diverged step just fails. */ stepHealer?: StepHealer; /** How long a step's `expect` is polled (readiness) before it counts as diverged. Default 2000ms. */ expectTimeoutMs?: number; /** Snapshot of the run's LLM usage, taken after Judge and attached as `result.usage` — so every * report carries its own cost proof (a clean replay shows `llmCalls: 0`). */ usage?: () => RunUsage; /** First-path-segment prefixes URL matching may strip as locales (fallback only, #86). Which * segments are locales is an app trait the consumer declares — the engine default is a small * conservative list (`DEFAULT_LOCALE_PREFIXES`); override it when the app serves other locales * or has real routes that look like locales (`/my`, `/tv`). `[]` disables stripping. */ localePrefixes?: readonly string[]; /** Per-event trace scope (spec/core/trace.md) — `step`/`assertion`/`heal` kinds; absent → no emission. */ trace?: TraceScope; } /** * Fold step completion into the verdict: assertions only prove evidence that was *collected*, and a * blocked run stopped collecting partway — trailing steps never executed, so assertions satisfied by * the executed prefix must not read as a green (#90; same fail-closed stance as the empty-assertion * rule, #69). `detail` says which step blocked and why, so a CI gate can tell "run didn't finish" * apart from "assertions failed". A healed step is recorded ok, so a healed run is not penalized. */ /** * How the run that produced the evidence ended. A replay is a fixed step list, so completion is * "every step ran"; a re-discovery (outcome-heal) is a loop, so completion is "the loop reached * `done`, not the step cap". Both feed one finalizer so a rule added there applies to both paths. */ export declare function blockedReason(actions: ExecutedAction[], totalSteps: number): string | undefined; /** * The failures a re-discovery could conceivably repair: the goal assertions (`navigated`, * `request-status`, `custom`, `expect`), not the app-health guards. A 500 or a console error is * not a broken path — re-discovering cannot fix it, and a repair that reached the goal is still * the right path when a guard tripped on the way. Used on both ends of outcome-heal (#186): to * decide whether to re-discover at all, and whether to hand the repair back. */ export declare function goalFailures(verdict: Verdict): AssertionResult[]; /** * The last word on a verdict, shared by replay and outcome-heal (#186). The critic judges the * assertions; `incomplete` is what the assertions cannot see about the run itself — a replay that * blocked (`blockedReason`, #90) or a re-discovery that ended before `done` — and either one means * the evidence stopped partway, so assertions satisfied by the prefix must not read as green. A * rule of that shape belongs here, not at a call site: the heal path once returned the critic's * verdict raw and silently skipped every rule the replay path applied. */ export declare function finalizeVerdict(judged: Verdict, incomplete?: string): Verdict; export declare function runHarness(harness: Harness, task: string, opts?: RunHarnessOptions): Promise;