/** * Fire-and-forget forwarding of lifecycle callbacks from a subprocess to its * parent, so a parent's registered AgencyCallbacks fire for events that happen * inside a std::agency run() child (see the "Callback forwarding" section of * docs/dev/subprocess-ipc.md). * * Dependency-light leaf (mirrors costTelemetry.ts): the only runtime import is * subprocessRunInfo.ts (for isIpcMode + the shared ipcChildDebug). invokeCallbacks * (hooks.ts) calls sendCallbackToParent on every event; hooks.ts must not import * ipc.ts, so the wire type + sender live here. * * Never blocks, never throws, and never kills the run: no reply, no listener; a * dead channel or an over-limit / unserializable payload is swallowed — the * event is observational, so dropping it is always safe. * * Forwarding is UNCONDITIONAL: the child cannot know which callbacks the parent * registered, so every event (except the NON_FORWARDABLE_CALLBACKS denylist) is * serialized and sent on every occurrence, even when no parent callback exists. * Payloads can be large (full messages arrays, run results). Accepted v1 * tradeoff — see the plan's "Scope & design tradeoffs". */ import type { CallbackName } from "../types/function.js"; export type IpcCallbackMessage = { type: "callback"; name: CallbackName; data: any; }; /** Skip threshold for a forwarded callback payload. Matches the default * ipcPayload limit (ipc.ts DEFAULT_LIMITS) so the child's skip and the parent's * drop agree. Purely defensive: real callback payloads are KB-MB, far under it. */ export declare const CALLBACK_PAYLOAD_LIMIT: number; /** Callbacks that MUST NOT be forwarded. onStream and onOAuthRequired carry * function / Promise fields (cancel, complete) whose semantics require a live * local channel; JSON forwarding would strip them and fire a broken callback in * the parent. Neither currently reaches this function (onStream dispatches * outside invokeCallbacks; onOAuthRequired is never fired), so this is a * defensive guard against a future refactor routing them through the choke * point. onTrace is function-free and simply never fires today, so it is * excluded by non-existence rather than listed here. See the plan's * "Scope & design tradeoffs" section. Exported so the parent-side handler * (ipc.ts) rejects the same names — the guard should match its intent even under * parent/child version skew. */ export declare const NON_FORWARDABLE_CALLBACKS: readonly CallbackName[]; /** Forward one lifecycle event to the parent. No-op unless this process is a * forked Agency subprocess with a live IPC channel. `maxBytes` is overridable * only so tests can exercise the oversize-skip without a gigabyte payload. */ export declare function sendCallbackToParent(name: CallbackName, data: unknown, maxBytes?: number): void;