UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

69 lines • 2.93 kB
export declare const COOLDOWN_BASE_MS = 60000; export declare const COOLDOWN_CAP_MS: number; export declare const RETRY_SAME_MAX_ATTEMPTS = 2; /** * Carried by every refusal a provider that runs its own account pool (Anthropic Subscription) makes * before sending anything, because the accounts it may use are blocked. That pool already holds each * account's real reason and deadline, so the refusal is a verdict on the pool, not on the outer slot * this attempt happened to run on: classifying it per slot persisted one account's auth error against * every slot until re-login (senpi#2081). */ export declare const ACCOUNT_POOL_REFUSAL_NOTE = "No request was sent: the account pool refused it locally."; export type CredentialBlock = { reason: "auth_error"; } | { reason: "account_disabled"; } | { reason: "rate_limit"; cooldownMs: number; retryAfterWasCapped: boolean; /** Where the wait came from, for the local block log (senpi#3216). */ resetSource?: RateLimitResetSource; /** SIWC quota pause: cooldown is a probe policy, not the provider's reset time. */ usageLimit?: true; /** Set when the limit names the one model family it binds ("Fable limit"). */ modelFamily?: string; }; /** * `retry_after`: the server's Retry-After header (the adapter's marker); `reset_field`: a reset time the provider's * structured diagnostic carried; `reset_prose`: a wait or reset time read from the response text; `default_backoff`: none. */ export type RateLimitResetSource = "retry_after" | "reset_field" | "reset_prose" | "default_backoff"; export type CredentialAction = { kind: "failover"; block: CredentialBlock; } | { kind: "retry_same"; maxAttempts: typeof RETRY_SAME_MAX_ATTEMPTS; } | { kind: "fail_request"; }; /** * Per-slot exponential cooldown with the server hint as a FLOOR, never an * override: a hint can only lengthen the wait the failure count already earned. * The guessed backoff stops growing at GUESSED_BACKOFF_CAP_MS; everything caps at * 48 hours with the capping recorded. */ export declare function rateLimitCooldown(failureCount: number, serverHintMs?: number, policy?: { baseMs?: number; capMs?: number; }): { cooldownMs: number; retryAfterWasCapped: boolean; }; /** The cooldown of a spent account whose limit names a future reset: exactly until that reset, capped. */ export declare function usageLimitCooldown(resetMs: number, policy?: { capMs?: number; }): { cooldownMs: number; retryAfterWasCapped: boolean; }; /** The provider's answer as one text, the same text the classifier reads. */ export declare function credentialFailureText(error: unknown): string; export declare function classifyCredentialFailure(error: unknown, context?: { failureCount?: number; cooldownBaseMs?: number; cooldownCapMs?: number; nowMs?: number; }): CredentialAction; //# sourceMappingURL=classify.d.ts.map