import { i as OpenClawConfig } from "./types.openclaw-FkxG7fk3.js"; import { a as AuthProfileFailureReason, c as OAuthCredential, i as AuthProfileCredential, o as AuthProfileIdRepairResult, r as AuthProfileBlockedSource, s as AuthProfileStore } from "./types-qgn2mJGT.js"; //#region src/agents/auth-profiles/constants.d.ts /** @deprecated Anthropic provider-owned CLI profile id; do not use from third-party plugins. */ declare const CLAUDE_CLI_PROFILE_ID = "anthropic:claude-cli"; /** @deprecated OpenAI Codex provider-owned CLI profile id; do not use from third-party plugins. */ declare const CODEX_CLI_PROFILE_ID = "openai-codex:codex-cli"; //#endregion //#region src/agents/auth-profiles/credential-state.d.ts type AuthCredentialReasonCode = "ok" | "missing_credential" | "invalid_expires" | "expired" | "unresolved_ref"; declare const DEFAULT_OAUTH_REFRESH_MARGIN_MS: number; type TokenExpiryState = "missing" | "valid" | "expiring" | "expired" | "invalid_expires"; declare function hasUsableOAuthCredential(credential: OAuthCredential | undefined, opts?: { now?: number; refreshMarginMs?: number; }): boolean; //#endregion //#region src/agents/auth-profiles/order.d.ts type AuthProfileEligibilityReasonCode = AuthCredentialReasonCode | "profile_missing" | "provider_mismatch" | "mode_mismatch"; type AuthProfileEligibility = { eligible: boolean; reasonCode: AuthProfileEligibilityReasonCode; }; declare function resolveAuthProfileEligibility(params: { cfg?: OpenClawConfig; store: AuthProfileStore; provider: string; profileId: string; now?: number; }): AuthProfileEligibility; declare function resolveAuthProfileOrder(params: { cfg?: OpenClawConfig; store: AuthProfileStore; provider: string; preferredProfile?: string; }): string[]; //#endregion //#region src/agents/auth-profiles/display.d.ts declare function resolveAuthProfileDisplayLabel(params: { cfg?: OpenClawConfig; store: AuthProfileStore; profileId: string; }): string; //#endregion //#region src/agents/auth-profiles/doctor.d.ts declare function formatAuthDoctorHint(params: { cfg?: OpenClawConfig; store: AuthProfileStore; provider: string; profileId?: string; }): Promise; //#endregion //#region src/agents/auth-profiles/oauth.d.ts type ResolveApiKeyForProfileResult = { apiKey: string; provider: string; email?: string; profileId: string; profileType: AuthProfileCredential["type"]; }; type ResolveApiKeyForProfileParams = { cfg?: OpenClawConfig; store: AuthProfileStore; profileId: string; agentDir?: string; forceRefresh?: boolean; }; declare function refreshOAuthCredentialForRuntime(params: { credential: OAuthCredential; }): Promise; declare function resolveApiKeyForProfile(params: ResolveApiKeyForProfileParams): Promise; //#endregion //#region src/agents/auth-profiles/profile-list.d.ts declare function dedupeProfileIds(profileIds: string[]): string[]; declare function listProfilesForProvider(store: AuthProfileStore, provider: string): string[]; //#endregion //#region src/agents/auth-profiles/profiles.d.ts declare function setAuthProfileOrder(params: { agentDir?: string; provider: string; order?: string[] | null; }): Promise; declare function upsertAuthProfile(params: { profileId: string; credential: AuthProfileCredential; agentDir?: string; }): void; declare function upsertAuthProfileWithLock(params: { profileId: string; credential: AuthProfileCredential; agentDir?: string; }): Promise; declare function removeProviderAuthProfilesWithLock(params: { provider: string; agentDir?: string; }): Promise; declare function markAuthProfileSuccess(params: { store: AuthProfileStore; provider: string; profileId: string; agentDir?: string; }): Promise; //#endregion //#region src/agents/auth-profiles/repair.d.ts declare function suggestOAuthProfileIdForLegacyDefault(params: { cfg?: OpenClawConfig; store: AuthProfileStore; provider: string; legacyProfileId: string; }): string | null; declare function repairOAuthProfileIdMismatch(params: { cfg: OpenClawConfig; store: AuthProfileStore; provider: string; legacyProfileId?: string; }): AuthProfileIdRepairResult; //#endregion //#region src/agents/auth-profiles/usage-state.d.ts /** * Check if a profile is currently in cooldown (due to rate limits, overload, or other transient failures). */ declare function isProfileInCooldown(store: AuthProfileStore, profileId: string, now?: number, forModel?: string): boolean; /** * Return the soonest `unusableUntil` timestamp (ms epoch) among the given * profiles, or `null` when no profile has a recorded cooldown. Note: the * returned timestamp may be in the past if the cooldown has already expired. */ declare function getSoonestCooldownExpiry(store: AuthProfileStore, profileIds: string[], options?: { now?: number; forModel?: string; }): number | null; /** * Clear expired cooldowns from all profiles in the store. * * When `cooldownUntil` or `disabledUntil` has passed, the corresponding fields * are removed and error counters are reset so the profile gets a fresh start * (circuit-breaker half-open -> closed). Without this, a stale `errorCount` * causes the *next* transient failure to immediately escalate to a much longer * cooldown -- the root cause of profiles appearing "stuck" after rate limits. * * `cooldownUntil` and `disabledUntil` are handled independently: if a profile * has both and only one has expired, only that field is cleared. * * Mutates the in-memory store; disk persistence happens lazily on the next * store write (e.g. `markAuthProfileSuccess` / `markAuthProfileFailure`), which * matches the existing save pattern throughout the auth-profiles module. * * @returns `true` if any profile was modified. */ declare function clearExpiredCooldowns(store: AuthProfileStore, now?: number): boolean; //#endregion //#region src/agents/auth-profiles/usage.d.ts /** * Infer the most likely reason all candidate profiles are currently unavailable. * * We prefer explicit active `disabledReason` values (for example billing/auth) * over generic cooldown buckets, then fall back to failure-count signals. */ declare function resolveProfilesUnavailableReason(params: { store: AuthProfileStore; profileIds: string[]; now?: number; }): AuthProfileFailureReason | null; declare function calculateAuthProfileCooldownMs(errorCount: number): number; declare function resolveProfileUnusableUntilForDisplay(store: AuthProfileStore, profileId: string): number | null; /** * Mark a profile as failed for a specific reason. Billing and permanent-auth * failures are treated as "disabled" (longer backoff) vs the regular cooldown * window. */ declare function markAuthProfileFailure(params: { store: AuthProfileStore; profileId: string; reason: AuthProfileFailureReason; cfg?: OpenClawConfig; agentDir?: string; runId?: string; modelId?: string; }): Promise; declare function markAuthProfileBlockedUntil(params: { store: AuthProfileStore; profileId: string; blockedUntil: number; source: AuthProfileBlockedSource; agentDir?: string; runId?: string; modelId?: string; }): Promise; /** * Mark a profile as transiently failed. Applies stepped backoff cooldown. * Cooldown times: 30s, 1min, 5min (capped). * Uses store lock to avoid overwriting concurrent usage updates. */ declare function markAuthProfileCooldown(params: { store: AuthProfileStore; profileId: string; agentDir?: string; runId?: string; }): Promise; /** * Clear cooldown for a profile (e.g., manual reset). * Uses store lock to avoid overwriting concurrent usage updates. */ declare function clearAuthProfileCooldown(params: { store: AuthProfileStore; profileId: string; agentDir?: string; }): Promise; //#endregion export { hasUsableOAuthCredential as A, resolveAuthProfileDisplayLabel as C, AuthCredentialReasonCode as D, resolveAuthProfileOrder as E, CODEX_CLI_PROFILE_ID as M, DEFAULT_OAUTH_REFRESH_MARGIN_MS as O, formatAuthDoctorHint as S, resolveAuthProfileEligibility as T, upsertAuthProfileWithLock as _, markAuthProfileFailure as a, refreshOAuthCredentialForRuntime as b, clearExpiredCooldowns as c, repairOAuthProfileIdMismatch as d, suggestOAuthProfileIdForLegacyDefault as f, upsertAuthProfile as g, setAuthProfileOrder as h, markAuthProfileCooldown as i, CLAUDE_CLI_PROFILE_ID as j, TokenExpiryState as k, getSoonestCooldownExpiry as l, removeProviderAuthProfilesWithLock as m, clearAuthProfileCooldown as n, resolveProfileUnusableUntilForDisplay as o, markAuthProfileSuccess as p, markAuthProfileBlockedUntil as r, resolveProfilesUnavailableReason as s, calculateAuthProfileCooldownMs as t, isProfileInCooldown as u, dedupeProfileIds as v, AuthProfileEligibilityReasonCode as w, resolveApiKeyForProfile as x, listProfilesForProvider as y };