/**
 * IPC-mode interrupt handling for subprocess execution.
 * When AGENCY_IPC=1 is set, interrupts are sent to the parent process
 * over Node's built-in IPC channel instead of being returned as Interrupt[].
 */
import { type ResultFailure } from "./result.js";
/** Resolved filesystem path to the subprocess bootstrap script. */
export declare const subprocessBootstrapPath: string;
export declare function isIpcMode(): boolean;
export type RunLimits = {
    wallClock: number;
    memory: number;
    ipcPayload: number;
    stdout: number;
};
export declare function clampLimits(input: RunLimits): RunLimits;
/**
 * Build a structured limit-exceeded Result.failure that the Agency-side
 * `try _run(...)` will pass through (without converting to an Error string).
 * `limit` is the canonical name (e.g. "wall_clock", "memory", "ipc_payload",
 * "stdout"). `threshold` is the configured cap; `value` is what was observed
 * when the violation was detected. `extras` carries optional fields like
 * `samplePrefix` for IPC payload violations.
 */
export declare function makeLimitFailure(limit: string, threshold: number, value: number, extras?: Record<string, any>): ResultFailure;
export declare function ipcLog(direction: "send" | "recv", msg: any): void;
export type SubprocessVotes = {
    propagated: boolean;
};
export type IpcInterruptMessage = {
    type: "interrupt";
    interrupt: {
        kind: string;
        message: string;
        data: any;
        origin: string;
    };
    subprocessVotes: SubprocessVotes;
};
export type IpcResultMessage = {
    type: "result";
    value: any;
};
export type IpcErrorMessage = {
    type: "error";
    error: string;
};
export type IpcDecisionMessage = {
    type: "decision";
    approved: boolean;
    value: any;
};
export type SubprocessToParent = IpcInterruptMessage | IpcResultMessage | IpcErrorMessage;
export type ParentToSubprocess = IpcDecisionMessage;
/**
 * Send an interrupt to the parent process and await the decision.
 * The parent always sends back a final approve or reject — never propagate.
 */
export declare function sendInterruptToParent(interruptData: {
    kind: string;
    message: string;
    data: any;
    origin: string;
}, votes: SubprocessVotes): Promise<{
    type: "approve";
    value?: any;
} | {
    type: "reject";
    value?: any;
}>;
/**
 * Fork a compiled Agency program as a subprocess and manage the IPC protocol.
 * Relays subprocess interrupts through the parent's handler chain via interruptWithHandlers.
 */
export declare function _run(compiled: {
    path: string;
    moduleId: string;
}, node: string, args: Record<string, any>, wallClock: number, memory: number, ipcPayload: number, stdout: number): Promise<any>;
