import { z } from 'zod'; /** * Model usage — the kernel-owned half of "the governance is kernel, the model is not" * (master plan §5.7 / D-18, built as #1054). * * Every call a host makes to a language model on the platform's behalf yields exactly one * of these. It is provider-neutral by construction: quantities come from the AI SDK usage * shape whichever provider ran, and `listUsd` is computed on OUR side from the generated * rate card — a provider's own cost field is a reconciliation source, never the ledger. * * `attribution` is FIXED at five keys, because the smallest per-request metadata limit * among the providers we route through is five. Pick once, never drift: a sixth key * silently drops on the wire and the reconciliation join breaks for that provider only. */ export declare const modelAttribution: z.ZodObject<{ tenant: z.core.$ZodBranded; scope: z.core.$ZodBranded; vertical: z.ZodString; version: z.ZodString; operation: z.ZodString; }, z.core.$strict>; export type ModelAttribution = z.infer; declare const modelUsageLineFields: z.ZodObject<{ attribution: z.ZodObject<{ tenant: z.core.$ZodBranded; scope: z.core.$ZodBranded; vertical: z.ZodString; version: z.ZodString; operation: z.ZodString; }, z.core.$strict>; model: z.ZodString; provider: z.ZodString; modelId: z.ZodString; reported: z.ZodBoolean; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; cachedInputTokens: z.ZodNumber; cacheWriteTokens: z.ZodNumber; listUsd: z.ZodNullable; at: z.core.$ZodBranded; elapsedMs: z.ZodNumber; }, z.core.$strip>; /** * `reported: false` means the provider reported NO usage — so the counts are zero and * there is nothing to price. * * Enforced rather than merely documented because this payload is parsed from a VERTICAL * at the platform boundary: without the check, `{ reported: false, inputTokens: 9_000_000 }` * is a well-formed line and the ledger would take it. That is an estimate becoming a * bill, which is the single thing the `reported` flag exists to prevent. */ export declare const unreportedIsEmpty: (line: z.infer) => boolean; export declare const UNREPORTED_MESSAGE = "reported: false means the provider reported no usage \u2014 every token count must be 0 and listUsd null"; /** The line's own fields, unrefined — for schemas that extend it (a refined schema cannot). */ export { modelUsageLineFields }; export declare const modelUsageLine: z.ZodObject<{ attribution: z.ZodObject<{ tenant: z.core.$ZodBranded; scope: z.core.$ZodBranded; vertical: z.ZodString; version: z.ZodString; operation: z.ZodString; }, z.core.$strict>; model: z.ZodString; provider: z.ZodString; modelId: z.ZodString; reported: z.ZodBoolean; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; cachedInputTokens: z.ZodNumber; cacheWriteTokens: z.ZodNumber; listUsd: z.ZodNullable; at: z.core.$ZodBranded; elapsedMs: z.ZodNumber; }, z.core.$strip>; export type ModelUsageLine = z.infer; /** * The platform intent a vertical raises to hand a line to the platform's ledger * (`ctx.requestPlatform({ kind: MODEL_USAGE_KIND, payload: line })`). The drain parses * the payload as `modelUsageLine`, refuses a line whose attribution names a different * tenant or scope than the one being drained, and records it under the intent's own id * — which is what makes a retried drain write nothing twice. */ export declare const MODEL_USAGE_KIND = "model-usage"; /** A line as the platform's ledger holds it: the line plus the platform's two stamps. */ export declare const modelUsageEntry: z.ZodObject<{ attribution: z.ZodObject<{ tenant: z.core.$ZodBranded; scope: z.core.$ZodBranded; vertical: z.ZodString; version: z.ZodString; operation: z.ZodString; }, z.core.$strict>; model: z.ZodString; provider: z.ZodString; modelId: z.ZodString; reported: z.ZodBoolean; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; cachedInputTokens: z.ZodNumber; cacheWriteTokens: z.ZodNumber; listUsd: z.ZodNullable; at: z.core.$ZodBranded; elapsedMs: z.ZodNumber; id: z.ZodString; requestId: z.ZodString; }, z.core.$strip>; export type ModelUsageEntry = z.infer; /** * Meter 3, at last computable — for model usage. D-30 said meters 3 and 4 were * uncomputable because the outbox has no cross-tenant fan-in; a line drained into the * directory is exactly that fan-in, for this one kind of usage. * * One row per (tenant, vertical, model). Token sums are integers; money is folded with * `addDecimal`, never floated, and `billedUsd` is `listUsd × marginFactor(marginPercent)` * — the platform's rate applied at READ time, so a margin change re-prices history * consistently rather than leaving two rates in one table. `unpriced` counts calls whose * model the rate card did not know: shown beside the money, never folded into it as $0. */ export declare const modelUsageSummaryRow: z.ZodObject<{ tenantId: z.core.$ZodBranded; vertical: z.ZodString; model: z.ZodString; provider: z.ZodString; modelId: z.ZodString; calls: z.ZodNumber; unpriced: z.ZodNumber; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; cachedInputTokens: z.ZodNumber; cacheWriteTokens: z.ZodNumber; listUsd: z.ZodString; billedUsd: z.ZodString; }, z.core.$strip>; export type ModelUsageSummaryRow = z.infer; export declare const modelUsageSummary: z.ZodObject<{ readAt: z.core.$ZodBranded; since: z.core.$ZodBranded; until: z.core.$ZodBranded; marginPercent: z.ZodNumber; rows: z.ZodArray; vertical: z.ZodString; model: z.ZodString; provider: z.ZodString; modelId: z.ZodString; calls: z.ZodNumber; unpriced: z.ZodNumber; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; cachedInputTokens: z.ZodNumber; cacheWriteTokens: z.ZodNumber; listUsd: z.ZodString; billedUsd: z.ZodString; }, z.core.$strip>>; totals: z.ZodObject<{ calls: z.ZodNumber; unpriced: z.ZodNumber; inputTokens: z.ZodNumber; outputTokens: z.ZodNumber; listUsd: z.ZodString; billedUsd: z.ZodString; }, z.core.$strip>; }, z.core.$strip>; export type ModelUsageSummary = z.infer; /** * `20` → `'1.2'`, `7` → `'1.07'`, `125` → `'2.25'`: a whole-percent margin as the exact * decimal factor `mulDecimal` takes. Whole percents only — a fractional margin would need * a factor the 6-dp decimal scale cannot always carry, and nobody prices at 12.5%. */ export declare function marginFactor(percent: number): string; //# sourceMappingURL=model-usage.d.ts.map