feat: load models through provider adapters

Provider model selection had outgrown a single hardcoded service.

The old service mixed shared caching with provider catalogs and CLI lookup details.

That made stale model lists more likely as providers changed on separate schedules.

Move model discovery behind each provider so lookup lives next to the integration.

The shared service now focuses on provider resolution, caching, persistence, and dedupe.

Return cache metadata and add bypassCache because model availability changes outside the app.

The UI and /models command can show freshness and let users force a provider refresh.

Surface model descriptions while keeping fallback catalogs for unavailable CLIs or SDKs.
This commit is contained in:
Haileyesus
2026-05-18 12:40:24 +03:00
parent ffaef395e4
commit 556cbd1a03
28 changed files with 1125 additions and 483 deletions

View File

@@ -7,6 +7,7 @@ import type {
ProviderSkill,
ProviderSkillListOptions,
ProviderAuthStatus,
ProviderModelsDefinition,
ProviderMcpServer,
UpsertProviderMcpServerInput,
} from '@/shared/types.js';
@@ -20,6 +21,7 @@ import type {
*/
export interface IProvider {
readonly id: LLMProvider;
readonly models: IProviderModels;
readonly mcp: IProviderMcp;
readonly auth: IProviderAuth;
readonly skills: IProviderSkills;
@@ -27,6 +29,24 @@ export interface IProvider {
readonly sessionSynchronizer: IProviderSessionSynchronizer;
}
// ---------------------------
//----------------- PROVIDER MODEL INTERFACE ------------
/**
* Model catalog contract for one provider.
*
* Implementations are responsible for resolving the provider's currently
* supported models and converting them into the shared
* `ProviderModelsDefinition` shape used by backend routes and frontend model
* pickers. The `DEFAULT` field should be the most appropriate default selection
* for that provider at the time the catalog is read.
*/
export interface IProviderModels {
/**
* Returns the provider's currently supported model catalog.
*/
getSupportedModels(): Promise<ProviderModelsDefinition>;
}
// ---------------------------
//----------------- PROVIDER AUTH INTERFACE ------------
/**