UNPKG

@code-yeongyu/senpi

Version:

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

63 lines • 3.68 kB
import type { Api, Model } from "@earendil-works/pi-ai"; import type { CircuitFailure } from "./controller-types.ts"; import type { SelectorCooldowns } from "./cooldown.ts"; import type { AccountLimits } from "../subscription-limits/limit-store.ts"; /** A once-per-provider check of a limit that named no family (senpi#5596). */ export type UsageLimitScopeProbe = { readonly provider: string; readonly heldFamily: string; readonly probeFamily: string; readonly outcome: "served" | "widened"; }; /** * Chain entries this session has seen refuse to serve for a reason retrying cannot * fix within the cooldown: an account-wide usage limit or billing failure (every * model on that provider is out) or a model-scoped limit/exhaustion (that entry is * out). Backed by the session's selector cooldowns under namespaced keys, so it is * runtime-only and expires on the same injected clock as every other suppression. */ export declare class UnusableEntries { private readonly cooldowns; private readonly accountErrors; /** Wall-clock time each provider's account hold began: only usage reported after it can lift it (senpi#6536). */ private readonly accountHeldSince; /** Providers whose limit named no family: the family it hit, awaiting one request on another family. */ private readonly pendingProbes; private readonly widenedFamilies; private readonly familyErrors; constructor(cooldowns: SelectorCooldowns); note(model: Model<Api>, failure: CircuitFailure): UsageLimitScopeProbe | undefined; /** A response served on `model`: a pending family probe on another family resolves as served. */ noteServed(model: Pick<Model<Api>, "provider" | "id">): UsageLimitScopeProbe | undefined; /** The weekly-limit family hold on `model`, while it lasts (senpi#5596). */ heldFamily(model: Model<Api>): { readonly family: string; readonly errorMessage: string; } | undefined; /** The two families a no-family limit was confirmed on before it widened to the account. */ widenedFamiliesOf(provider: string): readonly string[] | undefined; isProviderSpent(provider: string): boolean; accountError(provider: string): string | undefined; /** Wall-clock time the provider said its account limit resets; undefined when the hold is a guessed default. */ accountResetAt(provider: string): number | undefined; /** * Drops an account hold whose length was a guessed default, so the next request asks the provider again * (senpi#5568). A hold with a reset the provider stated is kept. Returns whether a hold was dropped. */ releaseGuessedAccountHold(provider: string): boolean; /** * Drops the provider's account hold when usage one of its accounts reported after the hold began shows it can * serve again: the provider lifted the limit before the reset it stated (senpi#6536). Returns whether one was dropped. */ releaseAccountHoldShownServable(provider: string, usage: readonly AccountLimits[]): boolean; /** Drops the provider's account hold, whatever its length; returns whether one was held (senpi#5590). */ releaseAccountHold(provider: string): boolean; isUnusable(model: Model<Api>): boolean; clear(model: Model<Api>): void; /** The provider's accounts changed (a login, an added or re-authorized account): every hold it earned is stale. */ clearProvider(provider: string, models: readonly Model<Api>[]): void; private noteAccount; /** A family hold and its pending probe go wherever the provider's own holds go (senpi#5596). */ private clearFamilyHolds; } //# sourceMappingURL=unusable.d.ts.map