Files
rea/src/browser/BrowserScenarioSessionPort.ts
T
morluto 57a23f0a2d fix(browser)!: expose capture budgets and queue admitted content reads
BREAKING CHANGE: Browser capture results require resolved limits, event families, and omission facts. Caller-selected budgets replace hidden retention ceilings; admitted content reads queue behind bounded concurrency.
2026-10-15 03:43:29 +08:00

48 lines
1.7 KiB
TypeScript

import type { BrowserScenario } from "../domain/browserScenario.js";
import type { BrowserScenarioAction } from "../domain/browserScenarioValues.js";
import type {
BrowserScenarioEvent,
BrowserScenarioEventOmissions,
BrowserStepArtifacts,
} from "../domain/browserScenarioCaptureValues.js";
import type { SanitizedBrowserUrl } from "../domain/browserObservation.js";
type SnapshotKind = BrowserScenario["capture"]["after_each_step"][number];
export interface BrowserScenarioSessionPort {
readonly mode: "launch" | "connect";
readonly processOwnership: "provider-owned" | "external";
readonly product: string;
readonly version: string;
readonly initialUrl: string;
currentUrl(): string;
sanitizeUrl(value: string): SanitizedBrowserUrl;
setStep(index: number): void;
nextEventSequence(): number;
lastEventSequence(): number;
events(): {
readonly retained: number;
readonly dropped: number;
readonly items: readonly BrowserScenarioEvent[];
readonly omissions: BrowserScenarioEventOmissions;
};
/** Gaps in selected event families that prevent complete capture claims. */
eventLimitations?(): readonly string[];
perform(action: BrowserScenarioAction, signal?: AbortSignal): Promise<void>;
capture(
requested: ReadonlySet<SnapshotKind>,
signal?: AbortSignal,
): Promise<BrowserStepArtifacts>;
close(): Promise<"terminated-owned-process" | "disconnected-external">;
redactError(error: unknown): string;
}
/** Acquire one scenario session whose lifecycle the caller owns. */
export type BrowserScenarioSessionOpener = (
scenario: BrowserScenario,
options: {
readonly signal?: AbortSignal;
readonly retainCleanup?: (close: () => Promise<unknown>) => void;
},
) => Promise<BrowserScenarioSessionPort>;