/** * Model route resolution (issue #67). The `(provider, model)` pair is a * single value: every source either supplies the WHOLE route or is skipped, * a historical cordis.yml `provider`-only pin can never merge with the * model half of the persisted `/model` choice into a route no adapter * recognizes. Startup, `/clear`, resume and the status line all resolve through * these helpers so the displayed route is the route requests actually take. */ import type { ModelPref } from './modelPrefs.js'; /** One complete model route. */ export interface ModelRoute { provider: string; model: string; } /** Minimal provider registry surface needed to choose a configured route. */ export interface ModelCatalog { listProviders(): readonly { id: string; }[]; listModels(provider: string): Promise; } /** Legacy fallback for bare embedders; integrated profiles replace it with an advertised route. */ export declare const DEFAULT_MODEL_ROUTE: ModelRoute; /** No model selected: the UI can open, but must not submit model requests. */ export declare const UNCONFIGURED_MODEL_ROUTE: ModelRoute; /** Managed provider selected by an environment-token desktop launch. */ export declare const CHATCODE_CODING_PLAN_PROVIDER = "chatcode-codingplan"; /** * The route cordis.yml pins explicitly — only when it names BOTH halves. A * half-pinned config counts as unset here so it cannot override half of the * persisted preference (issue #67). * @param configured - Raw `provider`/`model` keys from cordis.yml. * @returns The configured route, or undefined when either half is missing. */ export declare function explicitModelRoute(configured: { provider?: string; model?: string; }): ModelRoute | undefined; /** * Resolve the effective route atomically: a complete cordis.yml route wins * whole; otherwise the persisted `/model` choice wins whole; otherwise the * defaults win whole — a half-pinned config is IGNORED rather than merged * with the defaults' other half, so no source ever contributes just one * half of the final route. * @param configured - Raw `provider`/`model` keys from cordis.yml. * @param pref - The persisted `/model` choice, if any. * @param defaults - Final fallback route (the channel's startup route for * `/clear`, the harness default at boot). * @returns The resolved route. */ export declare function resolveModelRoute(configured: { provider?: string; model?: string; }, pref: ModelPref | undefined, defaults?: ModelRoute): ModelRoute; /** * Resolve a fresh-session route. A desktop-token launch retains a shared * ChatCode preference, but ignores non-ChatCode defaults and preferences so * it cannot silently escape to another account/provider. The caller validates * the chosen route against the active catalog. */ export declare function resolveStartupModelRoute(configured: { provider?: string; model?: string; }, pref: ModelPref | undefined, defaults?: ModelRoute, tokenCodingPlanRoute?: ModelRoute): ModelRoute; /** * Pick the first model actually advertised by the mounted provider registry. * This is used only as a fallback when a stale/default route is unavailable; * provider and model always come from the same catalog observation. */ export declare function firstAvailableModelRoute(llm: ModelCatalog | undefined): Promise; /** Pick the first model advertised by one exact provider. */ export declare function firstAvailableModelRouteForProvider(llm: ModelCatalog | undefined, provider: string): Promise; /** * Wait briefly for a sibling provider bundle to finish publishing its * catalog. Cordis applies independent Loader entries concurrently, so a * service (for example ChatCode auth) can already exist while that same * entry is still reading its model source before registerAdapter(). */ export declare function waitForFirstAvailableModelRoute(catalog: () => ModelCatalog | undefined, options?: { timeoutMs?: number; pollMs?: number; }): Promise; /** Wait for one provider without accepting an earlier model from another bundle. */ export declare function waitForModelRouteForProvider(catalog: () => ModelCatalog | undefined, provider: string, options?: { timeoutMs?: number; pollMs?: number; }): Promise; /** * The latest durable model selection or request route. A selection made * after the last request also survives resume before another turn is sent. * A complete cordis.yml override still takes precedence at the caller. * @param events - The session's durable event log. * @returns The last recorded route, or undefined when the log has none. */ export declare function recordedModelRoute(events: readonly { type: string; data?: unknown; }[]): ModelRoute | undefined; /** * Best-effort combination check (issue #67): when the llm runtime advertises * a non-empty catalog for the route's provider and the model is not in it, * reject the whole route in favor of `fallback` so a stale persisted choice * surfaces at startup instead of as a server-side model-name error. * * Uncertainty trusts the route — no llm service, an empty catalog, a catalog * read that failed for transport or adapter-internal reasons. An explicitly * unconfigured fallback keeps an empty catalog unconfigured instead. An unregistered * PROVIDER is not uncertainty: no adapter owns the name, so the route is * proven unusable and falls back exactly like an unknown model does. Trusting * it does not keep startup alive either — agent creation dies a few frames * later inside the preset setup hook, reported as `refusing to compose an * unscoped context`, which names neither the provider nor the stale * preference that chose it. * @param llm - The llm runtime seam, when mounted. * @param route - The resolved route to check. * @param fallback - Route to adopt when the check rejects. * @returns The adopted route plus the rejected one (for a warning), if any. */ export declare function validateModelRoute(llm: { listModels(provider: string): Promise; } | undefined, route: ModelRoute, fallback?: ModelRoute): Promise<{ route: ModelRoute; rejected?: ModelRoute; }>; /** * Resolve and validate the route used to resume a persisted session. A * complete runtime configuration wins over the route recorded in the log; * when neither exists, leave agentOptions unset so the agent runtime can * apply its native bare-session behavior. Crucially, recorded routes pass * through the same adapter/catalog validation as fresh sessions — otherwise * an old `chatcode-maas` session can resume successfully and fail only when * its next turn asks the now-unregistered provider for an adapter. */ export declare function validateResumeModelRoute(llm: { listModels(provider: string): Promise; } | undefined, configured: ModelRoute | undefined, recorded: ModelRoute | undefined, fallback: ModelRoute): Promise<{ route?: ModelRoute; rejected?: ModelRoute; }>; //# sourceMappingURL=modelRoute.d.ts.map