UNPKG

@code-yeongyu/senpi

Version:

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

38 lines • 1.66 kB
import { canonicalizeFallbackChains } from "../../../retry-fallback/chains.js"; /** * `/fallback` shows what the user can act on. A bare default expands across every * first-party provider of the model's vendor in the builtin catalog, so canonicalizing * against the full registry listed chains for providers the user cannot select * (no credentials). Scope the display to selectable models; the runtime keeps * using the full registry so a chain still resolves for the active model. */ function displayLookup(models) { if (Array.isArray(models)) return models; const registry = models; if (typeof registry.getAvailable !== "function") return models; const available = registry.getAvailable(); return { getAll: () => (available.length > 0 ? available : registry.getAll()), isUsingOAuth: (model) => registry.isUsingOAuth?.(model) === true, hasConfiguredAuth: (model) => registry.hasConfiguredAuth?.(model) === true, }; } function withAvailableChains(settings, models) { return { ...settings, chains: canonicalizeFallbackChains(settings.chains, displayLookup(models)), }; } export function loadFallbackSettings(settings, models) { return withAvailableChains(settings.getRetryFallbackSettings(), models); } export async function updateFallbackSettings(settings, models, update) { await update(settings); return withAvailableChains(settings.getRetryFallbackSettings(), models); } export function isModelFallbackDisabled(flag, environment = process.env) { return flag === true || environment.SENPI_NO_FALLBACK === "1"; } //# sourceMappingURL=settings.js.map