/** * Gateway budget admission (spec §5, §12.2). Order: caller auth → ingress → * finite ceiling → in-process quote → admit (reserve) → plan pinned to the * quote → attempts → one settlement. Refusals raised here are pre-acquisition: * no account is prepared and no byte is emitted before `admit` resolves. */ import { type RoutePlanner, type RouteQuote, type RouteQuoteInput, type RouteUsageCeiling, type VerifiedRoutingSubject } from '@sentropic/llm-mesh'; import type { CanonicalIngressResult } from './canonical-ingress.js'; import type { GatewayWire } from './ports/dispatch.js'; import type { CostContext } from './ports/cost-context.js'; import { type GatewayBudgetOptions, type RouteBudgetOverrun } from './ports/budget.js'; import type { SettleUsage } from './flow.js'; export interface AdmittedRoute { readonly requestId: string; readonly holdRef: string; readonly quote: RouteQuote; /** Candidate refs whose dispatch marker succeeded (provider call allowed). */ readonly dispatched: Set; } /** Construction guard: a configured budget can never run without an in-process quote. */ export declare const assertBudgetRouteDeps: (routePlanner: RoutePlanner | undefined, hasMetering: boolean, budget: GatewayBudgetOptions | undefined) => void; /** `Retry-After = min(60, max(1, ceil((resetAtMs - nowMs) / 1000)))`. */ export declare const budgetRetryAfterSeconds: (resetAtMs: number, nowMs: number) => number; /** * Budget path only: a request without max tokens is sent with the host default * output ceiling, so the provider enforces exactly what the hold reserved. */ export declare const boundRouteOutputCeiling: (canonical: CanonicalIngressResult, budget: GatewayBudgetOptions) => CanonicalIngressResult; /** Minimum input-token allowance per image, file or tool-result media attachment. */ export declare const BUDGET_ATTACHMENT_INPUT_TOKENS = 4096; /** * Finite per-attempt ceiling: estimated input and the request (or default) * output limit. Attachments count as `imageUnits` and add a conservative * per-attachment input allowance; the input side stays an estimate. */ export declare const routeUsageCeiling: (canonical: CanonicalIngressResult, budget: GatewayBudgetOptions) => RouteUsageCeiling; type QuoteRouteFields = Omit; export declare const admitRoute: (input: { readonly budget: GatewayBudgetOptions; readonly routePlanner: RoutePlanner; readonly requestId: string; readonly cost: CostContext; /** Owner-scoped subject, for per-transport availability on empty quotes (Lot 7). */ readonly subject: VerifiedRoutingSubject; readonly wire: GatewayWire; readonly requestedModel: string; readonly canonical: CanonicalIngressResult; readonly route: QuoteRouteFields; }) => Promise; /** Raised when the durable dispatch marker fails: the provider is never called. */ export declare class BudgetDispatchMarkError extends Error { constructor(); } export declare const markRouteDispatched: (budget: GatewayBudgetOptions | undefined, admission: AdmittedRoute | undefined, candidateRef: string, attemptIndex: number) => Promise; interface AttemptView { readonly candidateRef: string; readonly providerId: string; readonly modelId: string; readonly transportProviderId: string; readonly usage: SettleUsage; } /** * Charged usage per attempt: a dispatched attempt without measured usage is * charged at least its quoted allowance, never an estimated zero. Overruns * record dispatched attempts whose measured usage exceeded the allowance. */ export declare const chargeAdmittedAttempts: (admission: AdmittedRoute, attempts: readonly T[]) => { readonly attempts: T[]; readonly overrun: RouteBudgetOverrun[]; }; export {}; //# sourceMappingURL=admission.d.ts.map