import type { CustomAction } from "./core/ports.js"; import type { CustomChecks } from "./adapters/critics/assertion.js"; import type { TraceScope } from "./core/trace.js"; import type { ActionPolicy } from "./core/discover/index.js"; import type { PerceptionAdapter, TraceSink } from "./core/ports.js"; import type { ContextProvider, Critic, Driver, LlmClient, Reporter, StepHeal } from "./core/ports.js"; import type { Heal } from "./adapters/drivers/self-heal.js"; import type { Result, Scenario, StepProgress } from "./core/types.js"; export interface RunScenarioOptions { driver?: Driver; /** Default: LlmCritic if the scenario has `expect`, else AssertionCritic. */ critic?: Critic; context?: ContextProvider; reporter?: Reporter; llm?: LlmClient; /** * Repair broken replays with the LLM (invariant #4 sanctioned use). Two layers, both only when set: * a `SelfHealingDriver` fixes a step whose target no longer resolves, and — if the run still fails * its assertions (a "passed-the-steps-but-wrong-outcome" break that locator-heal can't catch) — * the scenario is re-discovered from the start. A green replay triggers neither (stays LLM-free). */ heal?: boolean; /** Fired on each self-heal — a host's signal that the frozen scenario is aging. */ onHeal?: (heal: Heal) => void; model?: string; /** Abort the run between steps (a host's Stop button). */ signal?: AbortSignal; /** Per-step progress, for a live timeline. */ onStep?: (progress: StepProgress) => void; /** Capture a screenshot after each step — delivered to `onStep`, and stored as a trace * attachment when the sink keeps bytes (#160). Nothing to store it → nothing is captured. */ screenshots?: boolean; /** Product-defined checks for `{ kind: "custom", name }` assertions — the host defines success. */ custom?: CustomChecks; /** URL substrings whose 4xx/5xx is product noise (e.g. analytics), excluded from `no-failed-requests`. */ benign?: string[]; /** Console-text substrings that are product noise (e.g. i18n warnings), excluded from `no-console-errors`. */ benignConsole?: string[]; /** First-path-segment prefixes URL matching may strip as locales (fallback only, #86); default is * a small conservative built-in list. Applies to both step `expect` matching and the `navigated` * verdict, so a run's replay checks and its final assertion agree on the same URL. `[]` disables. */ localePrefixes?: readonly string[]; /** Product-defined handlers for `{ kind: "custom", name }` steps — the host defines interactions. */ actions?: Record; /** How long a step's `expect` is polled (readiness) before it counts as diverged. Default 2000ms. */ expectTimeoutMs?: number; /** Gate for the outcome-heal re-discovery — the same ActionPolicy `discover()` takes, so an * unattended repair can't run actions the authoring policy would have blocked (#76). */ policy?: ActionPolicy; /** Correct perceived element state for widgets that expose it outside a11y (a11y-native perception * seam) — threaded into an outcome-heal re-discovery so it perceives the app the same way. */ perceive?: PerceptionAdapter; /** Lifecycle event stream (spec/core/trace.md). A bare run opens its own trace: header, * one implicit case (`caseRef` = scenario name), case-end, run-end. */ trace?: TraceSink; /** @internal The suite's per-case scope — when set, the suite owns header/case events and this * run emits only its step/assertion/heal kinds into it. Wins over `trace`. */ traceScope?: TraceScope; } export interface RunScenarioResult { result: Result; /** Locator substitutions self-heal made (empty unless `heal` was set and a target broke). */ heals: Heal[]; /** Surgical step repairs (empty unless `heal` was set and a step's `expect` diverged). */ stepHeals: StepHeal[]; /** Scenario rewritten with healed targets/steps, ready to re-freeze. Undefined if no heals. */ healedScenario?: Scenario; } export declare function needsLlmCritic(scenario: Scenario): boolean; /** Rewrite a scenario's targets with the (re-located) targets self-heal substituted, for re-freezing. * Keyed by the original target's object identity — which flows unchanged from the step through the * driver into the Heal — so two steps sharing a label don't rewrite together (#39). */ export declare function applyHeals(scenario: Scenario, heals: Heal[]): Scenario; /** Replace surgically-healed steps in place (keyed by index, so same-label steps don't collide). */ export declare function applyStepHeals(scenario: Scenario, heals: StepHeal[]): Scenario; export declare function runScenario(scenario: Scenario, opts?: RunScenarioOptions): Promise;