UNPKG

@code-yeongyu/senpi

Version:

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

44 lines • 2.73 kB
import { type SlotHasher } from "@earendil-works/pi-ai/auth/pool/select"; import type { AccountLimits } from "../subscription-limits/limit-store.ts"; import type { RotationSlot, RotationSources } from "./rotation-slots.ts"; import { type AccountStrategy } from "./selection-order.ts"; /** Reported usage the pick prefers headroom from (omo#9234); a preference, never a block. */ type SlotHeadroom = { providerId: string; limits: readonly AccountLimits[]; now: number; /** The account an earlier headroom skip moved this session to. */ remembered?: string; }; export type SlotPickPolicy = { affinityKey: string; useAffinity: boolean; hasher: SlotHasher; /** The pool's user account order, applied after the pin (senpi#3591). */ order?: readonly string[]; /** The configured account strategy (omo#10146); cache-affine when absent. */ strategy?: AccountStrategy; /** This session's round-robin start, from roundRobinState. */ roundRobinOffset?: number; headroom?: SlotHeadroom; }; /** The account a headroom skip moved this session to, so the stream and auxiliary requests read the same one. */ export declare function rememberedHeadroomAccount(repository: RotationSources["repository"], providerId: string, affinityKey: string): string | undefined; export declare function rememberHeadroomAccount(repository: RotationSources["repository"], providerId: string, affinityKey: string, account: string): void; /** The strategy's order with the user's order applied, before the pin and before any headroom preference. */ export declare function orderRotationSlots<TSlot extends RotationSlot>(candidates: readonly TSlot[], policy: SlotPickPolicy): readonly TSlot[]; /** * The pin when present, else the first account of the affinity order with the user's order applied, * preferring an account with headroom when the policy carries limit readings. */ export declare function pickRotationSlot<TSlot extends RotationSlot>(candidates: readonly TSlot[], policy: SlotPickPolicy): TSlot | undefined; /** * The account a session's next streamed request starts on, for callers that send a resolved key * outside the rotation stream (compaction, /btw, look-at, cache keepalive). It is the stream's own * first pick: the same candidates (unblocked accounts, else the rate-limited one due back first) and * the same order. When the stream would refuse, this throws the stream's refusal, so an auxiliary * request never authenticates as an account the stream would not use. */ export declare function selectSessionSlot<TSlot extends RotationSlot>(slots: readonly TSlot[], policy: SlotPickPolicy, now: number): TSlot | undefined; export {}; //# sourceMappingURL=session-slot.d.ts.map