Transfer canonical leases through opening, session and storage boundaries. Keep response deadlines separate from actual completion, drain independent owners, and join late opening failure cleanup before confirming recovery. Remove error copies in favor of canonical primary/cleanup composition. Preserve exact caller reasons, completed observations and independent physical failures through final-close cancellation and retry. Closes #4869. Validation:155 tests pass across15 focused source, service, CLI subprocess and MCP files; static/docs/discovery1551 pass. Two original-revision controls fail as expected. Bounded authored-session public CLI comparison preserves equivalent Evidence and1282 reply token estimates; no real Chromium qualification or forced-termination recovery claim (#4659).
50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import type { AnalysisCleanupLease } from "../artifacts/AnalysisCleanupLease.js";
|
|
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>;
|
|
readonly cleanupLease: AnalysisCleanupLease;
|
|
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?: (lease: AnalysisCleanupLease) => void;
|
|
},
|
|
) => Promise<BrowserScenarioSessionPort>;
|