import type { WorkerPool } from '../workers/pool.ts'; import type { FailureCategory, WorkerInboundMessage, WorkerOutboundMessage } from './types.ts'; import type { WorkerCheckpointResumeState } from './worker-checkpoint-resume-state.ts'; import type { WorkerExecutionOwnership } from './worker-execution-ownership.ts'; import type { WorkerListenerRegistry } from './worker-listener-registry.ts'; import type { ForwardedLogGate } from './worker-log-abuse-counter.ts'; import type { WorkerProtocolGuard } from './worker-protocol-guard.ts'; import type { WorkerRealmReadiness } from './worker-realm-readiness.ts'; import type { WorkerTurnState, WorkerTurnWatchdog } from './worker-turn-watchdog.ts'; export interface WorkerFaultHandlerDependencies { ownership: WorkerExecutionOwnership; checkpointResumeState: WorkerCheckpointResumeState; turnWatchdog: WorkerTurnWatchdog; forwardedLogGate: ForwardedLogGate; realmReadiness: WorkerRealmReadiness | null; workerListeners: WorkerListenerRegistry; protocolGuard: WorkerProtocolGuard; pool: WorkerPool; emit: (message: WorkerOutboundMessage) => void; /** * Forget a workflow's captured revision (WFT-20), mirroring * `#settleTerminalWorkerMessage`'s real-terminal-message cleanup. Every * fault path here (protocol violation, turn timeout, worker crash, log * abuse, realm-ready failure) synthesizes a `failed` message directly * rather than routing through that settle path, so without this callback * `WorkerExecutionStrategy#workflowRevisions` would keep an entry per * faulted workflow ID for the life of the strategy. */ forgetWorkflowRevision: (workflowId: string) => void; } export interface WorkerDiscardOptions { targetWorkflowId?: string; targetCategory?: FailureCategory; targetError?: string; skipTarget?: boolean; otherCategory: FailureCategory; otherError: string; } /** * Owns every path that ends in a worker being discarded and its owned * workflows failed: protocol violations, turn timeouts, worker crashes, and * (WFT-28) realm-ready handshake failures. Extracted from * {@link WorkerExecutionStrategy} to keep that file under the repository's * file-size ceiling; every method here previously lived as a private method * on that class and is unchanged in behavior. */ export declare class WorkerFaultHandler { #private; constructor(dependencies: WorkerFaultHandlerDependencies); assertHostToWorkerMessageWithinLimit(workflowId: string, message: WorkerInboundMessage, worker?: Worker): boolean; acceptWorkerMessage(worker: Worker, message: unknown): message is WorkerOutboundMessage; handleTurnTimeout(turn: WorkerTurnState): void; handleWorkerError(worker: Worker, errorEvent: ErrorEvent): void; discardWorkerAndFailWorkflows(worker: Worker, options: WorkerDiscardOptions): void; }