/** * @file Build a `BillingContext` for the route-heuristic WITHOUT privileged * lookups. A normal user has no Admin key (`sk-ant-admin01-`), so we cannot * read org spend / quota — the Anthropic Cost API is admin-gated — and that * is an accepted limitation, not something to engineer around. So this layer * does NO network call and NO privileged probe. It uses only what a user * actually has: which provider credentials resolve (the same env → keychain * check that builds `RouteContext.keyed`, non-admin), tags each with its * INHERENT billing kind (a metered API, a flat-rate plan, a subscription seat * — the provider's nature, overridable by config), and leaves `headroom` * undefined. Undefined headroom means the heuristic routes REACTIVELY: it * falls over on a 429 / quota error at spawn time (`isQuotaExhausted` in * `spawn.mts`), rather than predicting a cap it has no privilege to read. A * caller that DOES have a non-privileged quota endpoint (e.g. Synthetic * `/v2/quotas` with the ordinary key) may pass best-effort `headroom` in — * but nothing here requires it, and no privileged reader is built or wired. */ import type { CredentialProvider } from './credentials.js'; import type { BillingContext, BillingHeadroom, BillingKind, RoutingEnv } from './route-heuristic.js'; /** * Inherent billing model per provider — the provider's NATURE, not anyone's * account or limit. A metered pay-per-token API (`anthropic` with an API key, * `fireworks`, `xai`), a flat-rate plan (`synthetic`), or a subscription seat * (`openai` via a ChatGPT/Codex seat). These are DEFAULTS only: a caller * overrides per provider via the `kinds` option — e.g. a user whose Anthropic * access is a Claude Max seat (no API key) marks `anthropic` as `subscription`. * No dollar figures here; only the kind, which decides dollars-vs-headroom. */ export declare const DEFAULT_PROVIDER_KIND: Readonly>; export interface BillingFromKeyedOptions { readonly keyed: ReadonlySet; readonly kinds?: Readonly>> | undefined; readonly headroom?: Readonly>> | undefined; readonly local?: boolean | undefined; } /** * Turn an already-probed set of keyed providers into a `BillingContext`, * tagging each with its kind (config override → inherent default) and any * caller-supplied best-effort headroom. Pure: no I/O, no privileged lookup. A * provider with no known kind is skipped rather than given an undefined kind. */ export declare function billingFromKeyed(options: BillingFromKeyedOptions): BillingContext; /** * Detect whether routing runs in locked-down CI (restricted to the secrets * actually present, under the four-flag lockdown) or in local dev, which has * full freedom. CI when the standard `CI` env var is set; `local` otherwise. */ export declare function detectRoutingEnv(): RoutingEnv; export interface DiscoverBillingOptions { readonly allowEnvOnly?: boolean | undefined; readonly env?: RoutingEnv | undefined; readonly headroom?: Readonly>> | undefined; readonly kinds?: Readonly>> | undefined; } /** * Discover a `BillingContext` end-to-end with no privileged lookup: probe which * provider credentials resolve (env → keychain, the non-admin check), then tag * them via `billingFromKeyed`. Headroom defaults to undefined (reactive). In CI * the credential probe is env-only and never prompts for the keychain; locally * it allows the keychain. Convenience over calling `discoverKeyedProviders` + * `billingFromKeyed`. * * @unused No internal or Socket consumers; exercised only by its unit tests. */ export declare function discoverBilling(options?: DiscoverBillingOptions | undefined): Promise; export interface DiscoverKeyedProvidersOptions { readonly allowEnvOnly?: boolean | undefined; } /** * The set of providers with a resolvable credential, probed via the same * non-admin env → keychain resolver `RouteContext.keyed` uses. No network, no * privilege. Pass `allowEnvOnly: true` in headless contexts to skip the * keychain entirely. */ export declare function discoverKeyedProviders(options?: DiscoverKeyedProvidersOptions | undefined): Promise>;