/** * Fire-and-forget usage telemetry from a subprocess to its parent, so * parent-side cost guards see child LLM spend live AND the parent's * per-invocation usage meter (the serve cost seam) accrues the child's full * cost/token/attribution breakdown (see * docs/superpowers/specs/2026-08-04-full-cost-token-breakdown-design.md). * * Deliberately dependency-light (the subprocessRunInfo.ts layering pattern): * the runtime imports are subprocessRunInfo and the default host, whose * `system.parentChannel()` is the IPC channel; `NormalizedDelta` is a * type-only import (erased at runtime), so this stays a leaf module. The recordPaidUsage * sink calls the sender here on every accounted delta; stateStack / accounting * must not import ipc.ts. * * Never blocks and never throws: there is no reply, no listener, and a dead * channel is swallowed — the bootstrap disconnect watchdog is about to reap * this process anyway. */ import type { RootLog } from "../statelogClient.js"; import type { NormalizedDelta } from "./invocationUsage.js"; /** The UNTRUSTED wire shape a parent receives on `invocationUsage`. Every field * is `unknown`: a version-skewed or malicious child may send anything, so the * parent recovers it field-by-field via `normalizeIpcUsageDelta` before it * reaches the accounting sink. The trusted SEND-side payload is a * `NormalizedDelta` (this message minus `type`). */ export type IpcInvocationUsageMessage = { type: "invocationUsage"; cost?: unknown; tokens?: unknown; unpricedCallCount?: unknown; entry?: unknown; attributionLost?: unknown; }; /** Relayed once when a process can no longer guarantee that all of its (or a * descendant's) usage telemetry was delivered — makes the owning invocation's * usage a trusted lower bound. Carries no cost. */ export type IpcInvocationUsageIncompleteMessage = { type: "invocationUsageIncomplete"; }; export type IpcUsageMessage = IpcInvocationUsageMessage | IpcInvocationUsageIncompleteMessage; /** Relay a full normalized usage delta to the parent, once. Sends the complete * nested breakdown (`cost`, `tokens`, `entry`, `unpricedCallCount`, * `attributionLost`). Skips an all-zero delta. */ export declare function sendInvocationUsageToParent(delta: NormalizedDelta, log: RootLog | undefined): void; /** Relay the incompleteness marker to the parent, once. */ export declare function sendInvocationUsageIncompleteToParent(log: RootLog | undefined): void;