import type { AccountTransportAuthMaterial, AccountTransportProviderId, AuthDescriptor } from './auth.js'; import type { ModelId, ProviderId } from './providers.js'; export type AccountTransportAccountStatus = 'active' | 'cooldown' | 'reauth_required' | 'disabled'; export type AccountTransportOutcomeStatus = 'success' | 'failed' | 'rate_limited' | 'auth_failed'; export interface AccountTransportAccount { accountId: string; ownerScopeRef?: string; accountLabel?: string | null; targetProviderId: ProviderId | (string & {}); transportProviderId: AccountTransportProviderId | (string & {}); accessToken: string; refreshToken?: string | null; expiresAt?: string | null; status?: AccountTransportAccountStatus; modelIds?: readonly (ModelId | (string & {}))[]; priority?: number; weight?: number; cooldownUntil?: Date | string | null; headers?: Record; metadata?: Record; enrollmentCompletedAt?: string; } export interface AccountTransportAcquireInput { /** Mesh-internal exact candidate binding; never sourced from gateway ingress. */ accountId?: string; ownerScopeRef?: string; targetProviderId: ProviderId | (string & {}); transportProviderId: AccountTransportProviderId | (string & {}); modelId?: ModelId | (string & {}) | null; workspaceId?: string | null; userId?: string | null; affinityKey?: string | null; requestId?: string | null; reservationTtlMs?: number; now?: Date | string | number; metadata?: Record; } export interface AccountTransportReservation { reservationId: string; accountId: string; leaseId: string; expiresAt: string; } export interface AccountTransportLease { leaseId: string; accountId: string; affinityKey?: string | null; stableSessionId: string; createdAt: string; } export interface AccountTransportOutcome { status: AccountTransportOutcomeStatus; requestId?: string | null; providerStatusCode?: number; retryAfterMs?: number | null; quota?: Record; errorCode?: string | null; finishedAt?: Date | string | number; } export interface AccountTransportAcquisition { material: AccountTransportAuthMaterial; descriptor: AuthDescriptor; lease: AccountTransportLease; reservation: AccountTransportReservation; runtime: { stableSessionId: string; headers?: Record; metadata?: Record; }; recordOutcome(outcome: AccountTransportOutcome): Promise; /** Releases an unfinished reservation without changing account health. */ release?(): Promise; } /** * Coordinator that manages account selection, leasing, and cooldown lifecycle. * Implementations MUST expire cooldowns (transition `cooldown → active` when * `cooldownUntil` has passed) atomically before eligibility checks in `acquire()`. */ export interface AccountTransportCoordinator { acquire(input: AccountTransportAcquireInput): Promise; } export declare class AccountTransportAcquireError extends Error { readonly code: 'no_account' | 'no_active_account'; constructor(message: string, code: 'no_account' | 'no_active_account'); } export declare class InMemoryAccountTransportCoordinator implements AccountTransportCoordinator { private readonly accounts; private readonly leases; private readonly reservations; private leaseSequence; private reservationSequence; constructor(accounts?: readonly AccountTransportAccount[]); addAccount(account: AccountTransportAccount): AccountTransportAccount; removeAccount(accountId: string): boolean; /** * Advance time-based lifecycle state without acquiring an account. * Returns account ids whose cooldown expired so a durable host can persist * the transition before exposing route inventory. */ refreshLifecycle(nowInput?: Date | string | number): readonly string[]; acquire(input: AccountTransportAcquireInput): Promise; private getLeasedAccount; private selectAccount; private isEligible; private createLease; private createReservation; private countReservations; private releaseExpiredReservations; private expireCooldowns; private applyOutcome; } //# sourceMappingURL=account-transports.d.ts.map