import type { RuntimeContext } from "./state/context.js"; import type { GraphState } from "./types.js"; import type { ServedInvocationOutcome } from "./invocationUsage.js"; /** A bare value-or-error, before the usage snapshot is attached. */ export type RawOutcome = { status: "returned"; value: T; } | { status: "threw"; error: unknown; }; /** * Close a served invocation's lifecycle: run cleanup, then snapshot the meter. * * - The FIRST execution error wins as the outcome error. A later cleanup error * is logged, not substituted, so the real cause is never hidden. * - If execution SUCCEEDED but cleanup failed, the cleanup error becomes the * outcome (a failed teardown is a real failure). * - The meter snapshot is taken AFTER cleanup, so paid work incurred during * cleanup (e.g. memory persistence) is counted. */ export declare function finishServedInvocation(execCtx: RuntimeContext, outcome: RawOutcome, cleanup: () => Promise): Promise>;