import type { PromptResult } from "smoltalk"; import type { RuntimeContext } from "./state/context.js"; import type { StateStack } from "./state/stateStack.js"; import type { GraphState } from "./types.js"; import { type NormalizedDelta, type ProviderUsageKind, type UsageObservation } from "./invocationUsage.js"; /** Record one domain observation (a provider outcome or a manual charge) against * an explicit branch target. Normalizes exactly once, then submits to the sink. */ export declare function recordUsage(ctx: RuntimeContext, stack: StateStack, observation: UsageObservation): void; /** Account one LLM completion (the prompt completion site) as a provider * observation. */ export declare function recordCompletionUsage(ctx: RuntimeContext, stack: StateStack, completion: Pick, configuredModel: string | null | undefined, kind?: ProviderUsageKind): void; /** Record one UNRESOLVED provider attempt: a request that was dispatched to the * provider but never resolved to a priced result (timeout / cancel / a * post-dispatch provider error — possible spend, no price metadata). Adds one * to `unpricedCallCount` (no cost, no tokens). A failure PROVEN before dispatch never calls this. */ export declare function recordUnresolvedAttempt(ctx: RuntimeContext, stack: StateStack, kind: ProviderUsageKind): void; /** The narrow IPC entry point into the sink. The delta was ALREADY recovered by * `normalizeIpcUsageDelta`, so this must not normalize again and must not * enforce guards (the IPC handler enforces live-session guards afterward). */ export declare function recordNormalizedUsageDelta(ctx: RuntimeContext, stack: StateStack, delta: NormalizedDelta): void; /** Run one provider dispatch as a metered attempt (serve cost seam; each retry * is a fresh attempt). A resolved dispatch is priced later at its completion * site; a dispatched-but-UNRESOLVED attempt records one unresolved attempt so * `unpricedCallCount` goes up. A pre-dispatch failure never enters here. * * Returns the dispatch promise UNCHANGED (not wrapped in await/then): the * attempt record is a fire-and-forget side effect on rejection, so this adds no * microtask tick to the caller's timing. That matters — race() determinism * (which loser calls complete before the abort fires) is timing-sensitive, and * wrapping the dispatch would shift it. */ export declare function meteredDispatch(ctx: RuntimeContext, stack: StateStack, kind: ProviderUsageKind, dispatch: () => Promise): Promise; /** Mark this invocation's usage as no longer guaranteed complete (an abnormal * subprocess termination). Relays the marker upward once, only on the first * transition, so a mid-tier process forwards a descendant's incompleteness * without spamming. */ export declare function markInvocationUsageIncompleteAt(ctx: RuntimeContext): void;