/** * account-plan — the rail's plan card, read from the Sapiom CORE surface so it * can never disagree with the dashboard's own billing views. * * Three reads, folded into one `AccountPlanView`: * * - `GET /v1/dashboard/plan` → plan name + status * - `GET /v1/spending-rules/spend-limit-summary` → today's settled spend vs * the org's spend-limit rule — the exact "$used / $cap" pair the dashboard's * balance card renders (JSON:API envelope; all-null attributes when no rule) * - `GET /v1/accounts/spend` → `availableBalanceUsd`, * the prepaid fallback when no limit rule exists * * Same auth contract as template-catalog.ts (and verified there): core takes * `Authorization: Bearer`, NOT the agents surface's `x-sapiom-api-key`, and * every path is prefixed `/v1`. The key stays server-side; a 401/403 triggers * exactly one credential refresh + retry. * * These endpoints are excluded from core's public OpenAPI surface, so their * shapes are contracts by observation, not by document. Every field is * narrowed defensively and any drift degrades the readout to `none` (or the * whole view to `fallback`) rather than throwing — a broken billing read must * never take the rail down. */ import type { AccountPlanView } from "../shared/types.js"; import { type ApiKeyProvider } from "./api-key-provider.js"; export interface AccountPlanReader { /** The assembled card view. Never throws: signed-out and unreachable both * come back as `source: "fallback"` with an honest empty readout. */ view(): Promise; } /** `{ data: { plan: { name, status } | null } }` → the card's plan line. */ export declare function extractPlan(body: unknown): AccountPlanView["plan"]; /** JSON:API `{ data: { attributes: { limitUsd, windowSpendUsd } } }` → the * "$used / $cap" pair, or null when no qualifying rule exists (all-null * attributes is that endpoint's documented "no rule" answer, not an error). */ export declare function extractLimit(body: unknown): { usedUsd: number; limitUsd: number; } | null; /** `{ data: { availableBalanceUsd } }` → the prepaid balance, or null. */ export declare function extractBalance(body: unknown): number | null; export declare function createAccountPlanReader(opts: { /** Accepts a provider (preferred — enables refresh-on-401) or a bare key. */ apiKey: string | null | ApiKeyProvider; /** Override the core base URL (resolved from env by default). Test seam. */ baseUrl?: string; /** Injectable fetch. Test seam. */ fetchImpl?: typeof fetch; }): AccountPlanReader; //# sourceMappingURL=account-plan.d.ts.map