evOo-local/packages/adapters/src/deployment-model.ts
cynarAI b3f20967db
Preselect the recommended model while none is connected (#150)
Without a model key the settings opened on the keyless deployment default
(OpenRouter). The connect flow now opens on Claude Opus 5, so a new user
only adds a key or signs in. A connected credential, an owner-chosen
default, or a deployment key still decides as before.


Claude-Session: https://claude.ai/code/session_01KWEAjTw26eRf3ZXTXfRjmD

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-05 10:17:33 +02:00

31 lines
1.3 KiB
TypeScript

export const DEFAULT_OPENROUTER_MODEL_ID = "openai/gpt-5.6-luna";
/** What the connect flow preselects while no model is connected: the user only adds a key or signs in. */
export const RECOMMENDED_MODEL = { provider: "anthropic", model: "claude-opus-5" } as const;
/**
* The deployment-wide model default: which provider a run falls back to when no user
* credential applies, and the key for that provider.
*
* Vendor env names and model ids live here, in the adapter layer, not in core.
*/
export function resolveDeploymentModel(env: NodeJS.ProcessEnv = process.env) {
const provider = env.PI_DEFAULT_PROVIDER?.trim() || "openrouter";
// A row per provider that ships a deployment key. A third one adds a row here, not a
// branch at each call site — and an unknown provider gets no key rather than another
// vendor's, which a ternary on one provider would not give.
const keys: Record<string, string | undefined> = {
openrouter: env.OPENROUTER_API_KEY,
anthropic: env.ANTHROPIC_API_KEY,
};
const models: Record<string, string> = {
openrouter: DEFAULT_OPENROUTER_MODEL_ID,
anthropic: "claude-sonnet-5",
};
return {
provider,
model: env.PI_DEFAULT_MODEL?.trim() || models[provider] || models.openrouter!,
key: keys[provider],
};
}