UNPKG

@code-yeongyu/senpi

Version:

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

60 lines • 3.32 kB
import type { ThinkingLevel } from "@earendil-works/pi-agent-core"; import type { Api, Model } from "@earendil-works/pi-ai"; export interface FallbackSelector { raw: string; provider: string; id: string; thinkingLevel?: ThinkingLevel; } export type FallbackChains = Readonly<Record<string, readonly string[]>>; export type FallbackModelLookup = readonly Model<Api>[] | { getAll(): Model<Api>[]; isUsingOAuth?(model: Model<Api>): boolean; hasConfiguredAuth?(model: Model<Api>): boolean; isFallbackEligible?(model: Model<Api>): boolean; }; /** An empty entry list is the documented opt-out; it survives as a tombstone. */ export declare function isChainTombstone(entries: readonly string[] | undefined): boolean; /** * Resolves only complete provider/model selectors. The full input is resolved first * so colons belonging to a model id remain part of that id; aliases then resolve * against the model-id portion while retaining the explicitly selected provider. */ export declare function parseFallbackSelector(raw: string, lookup: FallbackModelLookup): FallbackSelector | undefined; export declare function formatSelector(model: Model<Api>, thinkingLevel?: ThinkingLevel): string; export declare function baseSelector(selector: Pick<FallbackSelector, "provider" | "id">): string; /** * A rung's identity: the model plus the thinking level it runs at. An entry * without an explicit level inherits the running level, so it names the rung in * flight rather than a second rung of that model. */ export declare function rungSelector(selector: Pick<FallbackSelector, "provider" | "id" | "thinkingLevel">): string; /** * Converts validated configuration to canonical selector strings for runtime lookup. * * A bare key or entry (no provider prefix) is a model-family policy: it expands * only to that model vendor's first-party providers (see `FIRST_PARTY_PROVIDERS`), * so a chain shipped for `claude-fable-5` applies on both Anthropic lanes and * never lands a rung on a reseller the user did not name. * Provider-qualified keys and entries keep exact semantics, and an explicit key * always overrides the expansion it collides with. */ /** * Chain key matched when no exact or base key resolves for the current model. * Exists so a model without its own configured chain still has an escape lane: * without it, a hard-failing upstream wedges the session terminal even though * healthy fallback targets exist (desktop thread 487d7c29, 2026-08-28: nine * consecutive upstream 500s, zero fallback attempts, terminal error). * Users disable it with the `"*": []` tombstone. */ export declare function canonicalizeFallbackChains(chains: FallbackChains, lookup: FallbackModelLookup): FallbackChains; export declare function resolveChainKey(currentModel: Model<Api>, currentThinking: ThinkingLevel | undefined, chains: FallbackChains, options?: { allowWildcard?: boolean; fastSibling?: Model<Api>; }): string | undefined; /** * Returns entries after the current fallback. A primary or unknown selector starts * from the beginning, which also makes re-entry after stale runtime state safe. */ export declare function candidatesAfter(chainEntries: readonly string[], currentSelector: FallbackSelector | string): readonly string[]; //# sourceMappingURL=chains.d.ts.map