Files
rea/src/browser/CdpCaptureEventState.ts
T
morluto 8ced814b96 fix(browser): unify script and context attribution facts
Centralize CDP script/context declarations and frame-claim interpretation across web capture, Electron, V8, active runtime and storage seeding. Preserve each workflow's admission, provenance and retention policies while removing superseded helpers and schemas.

Malformed or conflicting frame claims now leave passive scripts unattributed. Reused context IDs replace future frame authority without rebinding earlier scripts, and source readers reject empty script IDs.

Validation: 153 focused tests and check:fast passed; 13 regression failures reproduced on the prior commit. Real Chrome script export and runtime CLI/MCP verifiers passed, including correctly reported uncertain cleanup after intentional target closure. Electron regression coverage used simulated CDP.
2026-10-27 02:30:04 +08:00

47 lines
2.1 KiB
TypeScript

import type { CdpContextFrameClaim } from "./CdpScriptContextFacts.js";
import type { InspectWebPageInput } from "../domain/browserObservation.js";
import type { WebPageInspection } from "../domain/browserObservationSchemas.js";
import type { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
import type { CapturedScript, NetworkState } from "./CdpCaptureEventTypes.js";
export interface CdpCaptureEventsState {
readonly input: InspectWebPageInput;
readonly allowedOrigins: ReadonlySet<string>;
readonly scripts: Map<string, CapturedScript>;
readonly scriptMetadataBudgetOmissionsById: Map<string, true>;
rejectedScriptMetadataBudgetCount: number;
rejectedSourceMapMetadataBudgetCount: number;
readonly scriptMetadataBytesById: Map<string, number>;
retainedScriptMetadataBytes: number;
/** Console, websocket-frame and selected request/response shape outputs share one allowance. */
retainedEventBytes: number;
readonly bodyShapeBytesByRequestId: Map<
string,
{ readonly request: number; readonly response: number }
>;
readonly executionContextFrames: Map<string, CdpContextFrameClaim>;
readonly network: Map<string, NetworkState>;
readonly networkRequestTimestamps: Map<string, number>;
readonly malformedRedirectRequestIds: Set<string>;
/** Requests whose selected JSON request-body shape was expected but not obtained. */
readonly missingRequestBodyShapeIds: Set<string>;
readonly webSocketConnectionsById: Map<
string,
WebPageInspection["network"]["websocket_connections"][number]
>;
console: WebPageInspection["console"]["events"];
responseMetadata: WebPageInspection["metadata"]["responses"];
agentHints: WebPageInspection["metadata"]["agent_hints"];
readonly completeness: CdpCaptureCompleteness;
originViolation: boolean;
navigationDuringCapture: boolean;
unknownRootIdentity: boolean;
mainFrameId: string | undefined;
/**
* Identity of the document last observed in the main frame. `frameNavigated`
* re-fires for the same document, so this is what distinguishes a real
* document change from a duplicate event.
*/
committedDocument: string | undefined;
}