mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-28 14:55:34 +08:00
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.
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
import { executeModelsCommand } from '../commands.js';
|
|
|
|
test('models command returns available models only for the active provider', async () => {
|
|
const result = await executeModelsCommand([], {
|
|
provider: 'codex',
|
|
model: 'gpt-5.4',
|
|
});
|
|
|
|
assert.equal(result.type, 'builtin');
|
|
assert.equal(result.action, 'models');
|
|
assert.equal(result.data.current.provider, 'codex');
|
|
assert.equal(result.data.current.model, 'gpt-5.4');
|
|
assert.deepEqual(Object.keys(result.data.available), ['codex']);
|
|
assert.deepEqual(result.data.available.codex, result.data.availableModels);
|
|
assert.ok(result.data.availableModels.includes('gpt-5.4'));
|
|
assert.equal(result.data.available.claude, undefined);
|
|
assert.equal(result.data.available.cursor, undefined);
|
|
});
|
|
|
|
test('models command falls back to claude for unsupported providers', async () => {
|
|
const result = await executeModelsCommand([], {
|
|
provider: 'unknown-provider',
|
|
});
|
|
|
|
assert.equal(result.data.current.provider, 'claude');
|
|
assert.deepEqual(Object.keys(result.data.available), ['claude']);
|
|
});
|