import type { ContextOperationRequest } from './context.ts'; import type { FailureCategory, OperationRequest, WorkerOutboundMessage } from './types.ts'; import { type WorkerReplayOperationSignature } from './types/checkpoint.ts'; export { WORKER_REPLAY_SIGNATURE_FORMAT, type WorkerReplayOperationSignature, } from './types/checkpoint.ts'; /** * Bumped 1 -> 2 for the realm-ready handshake (WFT-28): a worker realm must * now send a `ready` message before its first turn, a required pre-turn * message the wire semantics didn't previously have. Host and worker are * always built from the same package version — there is no independent peer * to stay backward compatible with — so this is a clean-break bump, the same * reasoning the RemoteWorker protocol v2 -> v3 bump used. */ export declare const WORKER_PROTOCOL_VERSION = 2; export declare const DEFAULT_WORKER_TURN_TIMEOUT_MS = 1000; export declare const DEFAULT_WORKER_PROTOCOL_MESSAGE_BYTES = 1048576; export declare const MIN_WORKER_PROTOCOL_MESSAGE_BYTES = 4096; /** * Default bound (ms) on how long the host waits for a freshly acquired * worker's `ready` handshake message before discarding it (WFT-28). Worker boot * is module load plus evaluation with no I/O, but a cold Bun Worker spinning * up a large bundled module graph can take meaningfully longer than a single * workflow turn, so this is deliberately more generous than * {@link DEFAULT_WORKER_TURN_TIMEOUT_MS}. */ export declare const DEFAULT_WORKER_REALM_READY_TIMEOUT_MS = 5000; /** * Default fixed-window length (ms) for the forwarded-log flood budget (#545). Paired * with {@link DEFAULT_FORWARDED_LOG_FLOOD_THRESHOLD} over this window. */ export declare const DEFAULT_FORWARDED_LOG_FLOOD_WINDOW_MS = 60000; /** * Default maximum forwarded-log arrivals per worker within * {@link DEFAULT_FORWARDED_LOG_FLOOD_WINDOW_MS} before the worker is discarded for * flooding (#545). This budget is AGGREGATE per (pooled) worker, across every workflow * the worker currently owns — not per workflow. Set deliberately high (~83 arrivals/sec * sustained) because the harm is asymmetric: a false discard fails ALL of that worker's * in-flight workflows, while a real flood from a compromised worker runs at thousands per * second and still trips comfortably. Honest high-log workflows stay well under it. */ export declare const DEFAULT_FORWARDED_LOG_FLOOD_THRESHOLD = 5000; /** * Cumulative lifetime anomalous (oversize OR structurally invalid) forwarded-log * records tolerated per worker before discard (#545). A small constant — a well-behaved * worker-side logger never emits oversize or malformed records, so a few in a worker's * whole lifetime already signal abuse, and there is no legitimate-traffic reason to make * this configurable. Not window-scoped and never reset. */ export declare const FORWARDED_LOG_STRIKE_THRESHOLD = 5; export declare class WorkerProtocolError extends Error { constructor(message: string); } export declare class WorkerProtocolMessageSizeError extends WorkerProtocolError { readonly actualBytes: number; readonly maxBytes: number; constructor(actualBytes: number, maxBytes: number); } export declare function createBoundedWorkerFailureMessage(parameters: { workflowId: string; error: string; failureCategory: FailureCategory; turnId?: number; /** * Echo of the active turn's captured revision (WFT-20). Required whenever the * caller has one, so a bounded fallback for an oversized checkpoint/terminal * message still passes the host's strict revision check instead of being * discarded as a protocol violation. */ workflowRevision?: string; }): WorkerOutboundMessage; export declare function estimateWorkerProtocolMessageBytes(message: unknown): number; export declare function assertWorkerProtocolMessageWithinLimit(message: unknown, maxBytes: number | undefined): number; export declare function assertWorkerOutboundMessageShape(message: unknown): asserts message is WorkerOutboundMessage; export declare function createWorkerReplayOperationSignature(operation: OperationRequest | ContextOperationRequest, maxStableFieldsBytes: number): Promise; export declare function workerReplayOperationSignaturesEqual(left: WorkerReplayOperationSignature, right: WorkerReplayOperationSignature): boolean;