import type { ScopedField } from "./alwaysScope.js"; import type { IpcCallbackMessage } from "./callbackForwarding.js"; import type { IpcInvocationUsageMessage } from "./costTelemetry.js"; import type { HandlerChainOutcome } from "./interrupts.js"; import type { WithLockOptions, LockRelease } from "./lock.js"; export type IpcInterruptMessage = { type: "interrupt"; /** The child's interrupt-level id, preserved verbatim end-to-end: it keys * the decision reply and both processes' statelog events, and — when the * interrupt ultimately surfaces to the user — the resume response. */ interruptId: string; interrupt: { effect: string; message: string; data: any; origin: string; expectsValue?: boolean; /** The fields an "approve always here" rule pins for this effect, from * its declaration. The child always sends it; the parent may never have * imported that module. The receiver treats a missing scope as empty. */ alwaysScope?: ScopedField[]; }; }; export type IpcResultMessage = { type: "result"; value: any; }; /** An interrupt as it travels over IPC: the per-interrupt checkpoint fields * are stripped — the batch-level checkpoint travels once, at the message * level (see IpcInterruptedMessage). */ export type SerializedInterrupt = { type: "interrupt"; interruptId: string; runId: string; effect: string; message: string; data: any; origin: string; }; /** Terminal message for a child that paused itself: its unresolved * interrupts plus the shared checkpoint they all resume from. A third * terminal outcome alongside `result` and `error`. */ export type IpcInterruptedMessage = { type: "interrupted"; interrupts: SerializedInterrupt[]; checkpoint: any; subprocessSessionId: string; }; /** Convert a child's final Interrupt[] into the `interrupted` terminal * message: strip each interrupt's checkpoint fields and hoist the shared * batch checkpoint (every interrupt in a batch carries the same one). */ export declare function serializeInterruptsForIpc(interrupts: any[]): IpcInterruptedMessage; export type IpcErrorMessage = { type: "error"; error: string; }; /** The parent's reply to a relayed interrupt: its handler chain OUTCOME, * not a verdict. The child merges this with its own local outcome and * decides (see `mergeChainOutcomes` in interrupts.ts). */ export type IpcDecisionMessage = { type: "decision"; interruptId: string; outcome: HandlerChainOutcome; }; export type IpcLockAcquireMessage = { type: "lockAcquire"; requestId: string; name: string; ownerId?: string; timeoutMs?: number; warnAfterMs?: number; }; export type IpcLockGrantedMessage = { type: "lockGranted"; requestId: string; error?: string; }; export type IpcLockReleaseMessage = { type: "lockRelease"; requestId: string; name: string; ownerId?: string; }; export type SubprocessToParent = IpcInterruptMessage | IpcResultMessage | IpcInterruptedMessage | IpcErrorMessage | IpcLockAcquireMessage | IpcLockReleaseMessage | IpcInvocationUsageMessage | { type: "invocationUsageIncomplete"; } | IpcCallbackMessage; export type ParentToSubprocess = IpcDecisionMessage | IpcLockGrantedMessage; export declare function setSubprocessIpcPayloadLimit(limit: number): void; export declare function serializedByteLength(value: any): { ok: true; serialized: string; byteLength: number; } | { ok: false; error: string; }; export declare const ipcRole: string; export declare function ipcLog(direction: "send" | "recv", msg: any): void; /** * Send an interrupt to the parent process and await the parent's handler * chain OUTCOME (not a verdict — the child merges and decides). The parent * always replies explicitly; the child never infers from silence. * `interruptId` is the child's interrupt-level id, used verbatim as the * message id so decision routing and statelog correlation share one key. */ export declare function sendInterruptToParent(interruptData: IpcInterruptMessage["interrupt"], interruptId: string): Promise; export declare function sendLockAcquireToParent(name: string, opts?: WithLockOptions): Promise;