/** * Billing capture — makes credit consumption visible to whoever ran the skill. * * Credits are deducted server-side and used to be invisible here: a run printed * its image/video URL and nothing else, so the first time a user noticed the * credit system at all was the `insufficient_credits` error after the balance * had already run out. ab-api now attaches a `billing` object to the envelope of * every response that charged something (see core.Success / credits_billing.go); * this module accumulates those across all the calls a single skill run makes — * a gen-image run polls, a gen-video run polls, and each may charge once — and * renders one footer at the end. * * Two outputs, two audiences, both on stdout: * - a human-readable footer, which is what the agent relays to the user. * - one `__progress__` line (phase `billing`) — the existing machine protocol, * already parsed by ab-agent's executor and skipped by the line-scanning * parsers in render_video.py, so a nested pipeline caller can aggregate a * whole run's spend without a new stdout contract. * * Both go to stdout rather than stderr (where the auth footer lives) because * ab-agent hands the LLM `result.stdout || result.stderr` (mcp-tools.ts) — a * stderr-only footer would be invisible in the hosted agent, visible only when * a local host like codex shows both streams. Adding stdout lines is safe: * emitProgress already writes NDJSON there, so no consumer can be treating * stdout as a single JSON document. */ export interface BillingItem { credits: number; bizType?: string; detail?: string; } /** The `billing` object ab-api attaches to a charged response. */ export interface Billing { credits: number; balance: number; items?: BillingItem[]; } /** Accumulate one response's billing object; no-ops on responses that charged nothing. */ export declare function recordBilling(billing: Billing | undefined | null): void; /** Everything charged so far in this process, or null when nothing was. */ export declare function billingSummary(): Billing | null; export declare function emitBillingFooter(): void; /** Test seam — resets the accumulator between runs in-process. */ export declare function resetBilling(): void;