From 01acfa96b92be4725ab519c8281e1f571df7c70b Mon Sep 17 00:00:00 2001 From: AgentKV Date: Sat, 1 Aug 2026 12:12:40 +0000 Subject: [PATCH] feat: mirror the platform's UsageBlock breakdown and expiring_soon fields Additive optional fields the backend now emits for composite ops (AgentRAG ask+ingest): breakdown[] itemizes additional charge legs (total = price_usd + sum of breakdown), and expiring_soon marks a collection inside its final 24h. Field-for-field lockstep with platform/src/platform/usage.ts; closes the client-parity drift. Claude-Session: https://claude.ai/code/session_01L7ZjNFsUX3aKZ6Zc7FDsVz --- src/usage.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/usage.ts b/src/usage.ts index a0bdc41..17ba218 100644 --- a/src/usage.ts +++ b/src/usage.ts @@ -26,4 +26,18 @@ export interface UsageBlock { /** Prepaid credits debited from the ledger for this op (0 on the x402 pay-per-op path). */ credits_charged: number; cache_hit?: boolean; + /** + * Composite-op itemization: additional charge legs beyond the primary verb + * (e.g. an AgentRAG ask that also ingested pages). The top-level `price_usd` + * is the PRIMARY verb's price on the taken path; the request's total cost is + * `price_usd` + the sum of `breakdown[].price_usd`. Absent on single-leg ops + * — never an empty array on the wire. + */ + breakdown?: Array<{ op: string; units: number; price_usd: number }>; + /** + * Present (always literal `true`, never `false`) when the collection named + * by this response is inside the final 24h of its lifetime — the caller's + * cue to query it (sliding the expiry) or extend it. Omitted otherwise. + */ + expiring_soon?: true; }