mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 04:15:52 +00:00
feat(cliproxy): source model pickers from upstream catalogs
- fetch live provider model definitions through /api/cliproxy/catalog - overlay CCS preset metadata without keeping UI dropdowns as the source of truth - wire /cliproxy and quick setup to the upstream-backed catalog path
This commit is contained in:
1 parent
db8f955a95
commit
7bbf32ae9a
16 files changed
+425
-92
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import {
|
||||
buildUiCatalogs,
|
||||
MODEL_CATALOGS,
|
||||
findCatalogModel,
|
||||
getResolvedCatalogModels,
|
||||
@@ -24,6 +25,16 @@ describe('claude preset utils', () => {
|
||||
it('applies the default claude preset from the catalog default model mapping', async () => {
|
||||
const fetchMock = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
catalogs: {
|
||||
claude: MODEL_CATALOGS.claude,
|
||||
},
|
||||
source: 'live',
|
||||
cache: { synced: true, age: '0m ago' },
|
||||
}),
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
ok: true,
|
||||
json: async () => ({ apiKey: { value: 'managed-key' } }),
|
||||
@@ -36,7 +47,7 @@ describe('claude preset utils', () => {
|
||||
|
||||
expect(result).toEqual({ success: true, presetName: 'Claude Sonnet 4.6' });
|
||||
|
||||
const [, requestInit] = fetchMock.mock.calls[1] ?? [];
|
||||
const [, requestInit] = fetchMock.mock.calls[2] ?? [];
|
||||
const body = JSON.parse(String(requestInit?.body));
|
||||
|
||||
expect(body.settings.env).toMatchObject({
|
||||
@@ -47,6 +58,37 @@ describe('claude preset utils', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('builds UI catalogs from upstream provider models without requiring static dropdown edits', () => {
|
||||
const liveCatalogs = {
|
||||
gemini: {
|
||||
provider: 'gemini',
|
||||
displayName: 'Gemini',
|
||||
defaultModel: 'gemini-3.9-pro-preview',
|
||||
models: [
|
||||
{ id: 'gemini-3.9-pro-preview', name: 'Gemini 3.9 Pro Preview' },
|
||||
{ id: 'gemini-3-9-flash-preview', name: 'Gemini 3.9 Flash Preview' },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
const catalogs = buildUiCatalogs(liveCatalogs);
|
||||
const resolvedGeminiModels = getResolvedCatalogModels(catalogs.gemini, [
|
||||
{ id: 'gemini-3.9-pro-preview', owned_by: 'google' },
|
||||
{ id: 'gemini-3-9-flash-preview', owned_by: 'google' },
|
||||
]);
|
||||
|
||||
expect(catalogs.gemini?.defaultModel).toBe('gemini-3.9-pro-preview');
|
||||
expect(resolvedGeminiModels.find((model) => model.id === 'gemini-3.9-pro-preview')).toEqual(
|
||||
expect.objectContaining({
|
||||
name: 'Gemini 3.9 Pro Preview',
|
||||
presetMapping: expect.objectContaining({
|
||||
default: 'gemini-3.9-pro-preview',
|
||||
haiku: 'gemini-3-9-flash-preview',
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('keeps Gemini presets on 3.1 Pro while resolving 3/3.1 alias variants', () => {
|
||||
const geminiCatalog = MODEL_CATALOGS.gemini;
|
||||
const latestPro = geminiCatalog.models.find((model) => model.id === 'gemini-3.1-pro-preview');
|
||||
|
||||
Reference in new issue
Block a user