/** * The model picker. * * Selection is a mutable ref the agent's scoped prompt assembly reads * (`installModelSelection`): assembly snapshots it when a step enters, so a * switch made mid-turn takes effect on the NEXT step rather than splitting a * request across two models. Writing `ref.current` is therefore the whole * mechanism — there is no separate apply step to get wrong. * @module dshline/model */ import type { Context } from '@deepseek-ai/cordis'; import type { ModelSelectionRef } from '@deepseek-ai/dsh-agent'; import type { LocalCommandChoice } from './local-commands.ts'; import type { SelectionOutcome } from './selection.ts'; /** One offered model, kept beside its choice so nothing has to be parsed back. */ export interface ModelOption { /** Provider ROUTE key, the value `GenerateOptions.provider` takes. */ provider: string; /** Provider-owned model id. */ model: string; } /** * One `/model` completion discovery: the values to offer, and whether every * route answered. * * `complete` is false when some route could not be listed. The values are still * usable — an unreachable route must not hide the ones that work — but they are * partial, so a caller that cached them would keep the failed route missing * until the next Harness event. The completion catalog caches only a reading it * can stand behind, and retries an incomplete one on the next ask, which is what * the uncached path always did. */ export interface ModelCompletionReading { /** The offered values, in discovery order. */ readonly values: readonly LocalCommandChoice[]; /** Whether every advertised route answered. */ readonly complete: boolean; } /** * Discover `/model`'s completion values and whether the reading is complete. * @param ctx - context carrying the llm registry. * @returns the values, and whether any route could not be listed. */ export declare function readModelCompletion(ctx: Context): Promise; /** * Canonical completion candidates for `/model`'s argument. * * A value is `provider/model`, the exact route the row names, and the bare model * id is carried as a search alias rather than as the inserted text. Built from * the same discovery pass the picker uses, so the metadata costs no second round * of `listModels` reads. * @param ctx - context carrying the llm registry. * @returns each route and model, in the order the picker lists them. */ export declare function modelCompletionValues(ctx: Context): Promise; /** * The option an argument names, if any. * * A bare model id is enough when only one route serves it, which is the case * worth optimizing for: `provider/model` is accepted too, and is the only way to * say which one when a gateway and a direct route both offer the same id. * @param argument - the text after the command name. * @param options - every model on offer. * @returns the matching option, or undefined when nothing matched. */ export declare function resolveModel(argument: string, options: readonly ModelOption[]): ModelOption | undefined; /** * What the `/model` command may attach to the picker it opens. * * A command's authority is separate from the shared state it edits. Window-owned * startup callers omit attachment lifetime controls; the auxiliary key remains * an owner-provided action rather than part of the generic select overlay. */ export interface PickModelOptions { /** Whether this gesture still has authority to mount UI or edit window state. */ readonly mayAct?: () => boolean; /** Withdraw this gesture's picker and ask exact-model resolution to stop. */ readonly signal?: AbortSignal; /** Refresh window-owned metadata at an admitted live change, before persistence waits. */ readonly onApplied?: () => void; /** * Open the subagent-model authorization editor. * * This is the bare `/model` picker's `ctrl-k`. `/setup` passes no callback, * so `ctrl-k` is inert there and the setup flow can never reach the Host * setting. The editor is a separate overlay stacked on top of the picker, * so dismissing it returns to the picker rather than to this command. */ readonly onSubagentModels?: () => void; } /** * Prompt for a model and apply the choice to `selection`. * @param ctx - context carrying the llm registry and the slot registry. * @param selection - the agent's mutable selection ref. * @param argument - the text after `/model`; empty opens the picker. * @param options - the gesture's authority, cancellation, and auxiliary picker key; * window-owned callers may omit attachment lifetime options. * @returns a typed line to report, or undefined on picker dismissal or retirement * before the shared selection/default save is admitted. */ export declare function pickModel(ctx: Context, selection: ModelSelectionRef, argument?: string, options?: PickModelOptions): Promise; //# sourceMappingURL=model.d.ts.map