import type { AuthorizationContext, AuthorizationDecision } from './authorization.js'; import type { EntitlementType } from './domain.js'; import type { Signer } from './signing.js'; import type { EntitlementStore } from './store.js'; import type { PaymentProvider } from './provider.js'; export interface StipendPolicy { /** * Order in which candidate entitlements are tried when more than one * covers a call. Default: subscription before quota before balance * before one_time (the "cheapest-for-agent-first" heuristic from * PDD §11). */ readonly consumptionOrder?: readonly EntitlementType[]; } export interface StipendConfig { readonly store: EntitlementStore; readonly provider?: PaymentProvider; readonly signer?: Signer; readonly policy?: StipendPolicy; /** Override clock for deterministic tests. */ readonly now?: () => string; } export declare class Stipend { readonly store: EntitlementStore; readonly provider: PaymentProvider | undefined; readonly signer: Signer | undefined; private readonly consumptionOrder; private readonly now; constructor(config: StipendConfig); /** * Run the authorization algorithm (TDD §4) against the current store * state. * * Returns one of: * - `allow` (call may proceed; the engine has already recorded the * consumption side-effect atomically via the store); * - `payment_required` (no candidate entitlement covers the call; the * `accepts` array tells the agent how to purchase access); * - `deny` (call refused for a non-payment reason; rare in v1). * * Free tools — those with no `_stipend` metadata — are pre-authorized * before reaching this method (`pricing: null` ⇒ `allow`). */ authorize(ctx: AuthorizationContext): Promise; private orderIndex; private paymentRequired; /** * Is this entitlement currently usable for a call against the given * pricing? Caller has already confirmed scope coverage via * listEntitlements; this is the *type-aware* validity check. * * The atomic checkAndConsume in the store re-checks all of these under * lock — this method is only the candidate filter that selects which * row to lock. */ private canCoverCall; /** * Produce the consumption amount for this entitlement against the * current call. * * - subscription, quota, one_time: shape is fixed. * - balance: derive the amount from the tool's per_call or balance * pricing entry matching the entitlement's currency; pick the * smallest (cheapest-for-agent) when multiple match. * * Returns null if no usable amount can be derived (e.g. balance with no * matching-currency price entry). */ private amountFor; private priceForBalance; } //# sourceMappingURL=stipend.d.ts.map