import type { Money } from './money.js'; import type { Consumption, EntitlementType } from './domain.js'; import type { StipendPricing, SingleModelPricing } from './pricing.js'; /** * Input to the authorization decision. */ export interface AuthorizationContext { readonly accountId: string; readonly service: string; readonly toolName: string; readonly idempotencyKey: string; readonly pricing: StipendPricing | null; /** Optional structured arguments โ€” Stipend never inspects these for pricing, but providers may log them. */ readonly callArguments?: unknown; /** * When true, run candidate selection without performing the atomic * `checkAndConsume` โ€” i.e. report what *would* happen without mutating * state. Used by the proxy's virtual `stipend/check` tool (TDD ยง3.2). * * In dryRun mode the engine never returns `allow.replay`: dryRun is * always a fresh evaluation and never reads or writes the consumption * ledger. An `allow` decision returned with dryRun=true carries * `consumed.consumption` set to a synthetic (not-persisted) marker so * the caller can inspect which entitlement would have been used. */ readonly dryRun?: boolean; } export interface ConsumptionRecord { readonly entitlementId: string; readonly entitlementType: EntitlementType; readonly consumption: Consumption; /** Best-effort dollar amount drawn, when applicable (balance only). */ readonly amount?: Money; } export interface AllowDecision { readonly kind: 'allow'; readonly consumed?: ConsumptionRecord; /** True if this allow was the result of replaying a prior consumption with the same idempotency key. */ readonly replay?: boolean; /** True if this allow was produced by a `dryRun: true` context โ€” no state was modified. */ readonly dryRun?: boolean; } export interface DenyDecision { readonly kind: 'deny'; readonly reason: string; } export interface PaymentRequiredDecision { readonly kind: 'payment_required'; readonly service: string; readonly tool: string; readonly accepts: readonly SingleModelPricing[]; } export type AuthorizationDecision = AllowDecision | DenyDecision | PaymentRequiredDecision; //# sourceMappingURL=authorization.d.ts.map