/** * One-shot model calls the GATEWAY ITSELF makes (task 179). * * Distinct from a turn: no thread, no conversation, no history, no tools — one * prompt in, one string out. The stall classifier (task 164/165) was the first * of these and this module is its execution half, lifted out verbatim so the * task-179 worker runs a model the same single way rather than growing a second * copy of the CLI/HTTP branch (Rule #8). * * Two branches, one contract: * * - a Claude CLI sub-model runs as `claude --print --model ` with a * scrubbed env and a timeout; * - any other catalog model runs as a one-shot HTTP `chat()` through whatever * provider `resolveModelProvider` names — the same resolver every real turn * uses, so there is no second notion of "how do I run a non-Claude model". * * Both FAIL CLOSED to `null`: any spawn error, non-zero exit, timeout, provider * throw or empty answer is indistinguishable to the caller, because every caller * here is an optional facility that must degrade rather than break a turn. * * There is NO implicit model (task 184). A setting that is unset, blank, or names * nothing in either catalog means the facility is OFF, and this module says so by * returning `null` without spawning anything. It used to substitute the bare CLI * alias `"haiku"` — a model in no catalog, chosen by nobody, and unreachable on an * install with no authenticated `claude` binary — which turned "you have not * configured this" into a silent per-call failure while the settings screen * claimed the feature was running. */ /** * Everything a one-shot call needs to decide WHICH provider runs the configured * model and HOW to reach it. Mirrors the fields `server.ts` already threads into * every turn's `sendMessage`, so a gateway-owned call resolves its model exactly * the way a turn does. */ export interface OneShotModelContext { /** Direct-provider catalog (HF / OpenAI / custom entries). */ models?: Array<{ id: string; provider?: string; contextWindow?: number; }>; /** Claude CLI sub-model catalog (Opus / Sonnet / Haiku variants). */ claudeModels?: Array<{ id: string; }>; hfApiKey?: string; openaiApiKey?: string; customProviders?: Array<{ id: string; baseUrl: string; apiKey?: string; }>; } export interface OneShotModelOptions { /** * The configured model id. When no `context` is supplied this is used directly * as a Claude CLI sub-model — the behaviour callers and tests that don't care * about provider routing rely on. */ model?: string; /** * Full provider-resolution context. When present, `model` is routed through * `resolveModelProvider` and run on whatever provider that names. */ context?: OneShotModelContext; timeoutMs?: number; /** * Output budget for the HTTP branch. On both HTTP providers this bounds * REASONING + CONTENT together, so it must hold a reasoning model's thinking * pass as well as the answer (task 167). Ignored on the CLI branch, which has * no equivalent flag. */ maxTokens?: number; /** Reasoning effort for the HTTP branch. Omit to leave the provider's default. */ reasoningEffort?: 'low' | 'medium' | 'high'; } /** * Resolve a configured gateway-owned model id against BOTH catalogs. * * An id naming a `claudeModels[]` entry runs as a Claude CLI sub-model; an id * naming a `models[]` entry runs on that entry's direct provider (task 165). * * `null` means NOT CONFIGURED (task 184) — the setting is absent, blank, or has * gone stale against a catalog edit. It is a real state, not an error: the * facility is simply off until an operator picks a model. Substituting one here * is what this function used to do, and it is precisely the bug — the only ids * this gateway may run are ids the config actually names. */ export declare function resolveGatewayModel(configured: string | undefined, claudeModels?: Array<{ id: string; }>, models?: Array<{ id: string; }>): string | null; /** Test seam — the warn-once memory is process-lifetime state. */ export declare function resetOneShotWarnings(): void; /** * Run one prompt on the configured gateway model and return its raw text. * * `null` means the call did not produce an answer — no model configured, a * closed credential gate, spawn failure, non-zero exit, timeout, or a provider * throw. Callers must treat `null` as "no result", never as an empty result. * A caller that needs to TELL a person why (the Refresh button does) should ask * `resolveGatewayModel` first rather than reading a reason out of the `null`. */ export declare function runOneShotModel(prompt: string, opts?: OneShotModelOptions): Promise; //# sourceMappingURL=one-shot-model.d.ts.map