[Init] Initial commit - NetMesh terminal manager
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
This commit is contained in:
136
infrastructure/ai/cattyProviderModels.test.ts
Normal file
136
infrastructure/ai/cattyProviderModels.test.ts
Normal file
@@ -0,0 +1,136 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import {
|
||||
clearProviderModelCatalogCache,
|
||||
fetchProviderModelCatalog,
|
||||
providerModelCacheKey,
|
||||
resolveProviderDiscoveryBaseURL,
|
||||
seedProviderModelCatalog,
|
||||
} from './cattyProviderModels';
|
||||
import type { ProviderConfig } from './types';
|
||||
|
||||
const provider: ProviderConfig = {
|
||||
id: 'p1',
|
||||
providerId: 'deepseek',
|
||||
name: 'DeepSeek',
|
||||
defaultModel: 'deepseek-chat',
|
||||
baseURL: 'https://api.deepseek.com/v1',
|
||||
apiKey: 'test-key',
|
||||
enabled: true,
|
||||
};
|
||||
|
||||
test('resolveProviderDiscoveryBaseURL falls back to the built-in preset host', () => {
|
||||
assert.equal(
|
||||
resolveProviderDiscoveryBaseURL({
|
||||
id: 'openai-1',
|
||||
providerId: 'openai',
|
||||
name: 'OpenAI',
|
||||
enabled: true,
|
||||
}),
|
||||
'https://api.openai.com/v1',
|
||||
);
|
||||
assert.equal(
|
||||
resolveProviderDiscoveryBaseURL({
|
||||
id: 'ollama-1',
|
||||
providerId: 'ollama',
|
||||
name: 'Ollama',
|
||||
enabled: true,
|
||||
baseURL: 'https://ollama.com',
|
||||
}),
|
||||
'https://ollama.com/v1',
|
||||
);
|
||||
});
|
||||
|
||||
test('fetchProviderModelCatalog discovers models when baseURL is omitted', async () => {
|
||||
clearProviderModelCatalogCache();
|
||||
const requested: string[] = [];
|
||||
const catalog = await fetchProviderModelCatalog(
|
||||
{
|
||||
id: 'openai-legacy',
|
||||
providerId: 'openai',
|
||||
name: 'OpenAI',
|
||||
defaultModel: 'gpt-4o',
|
||||
apiKey: 'sk-test',
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
aiFetch: async (url) => {
|
||||
requested.push(url);
|
||||
return {
|
||||
ok: true,
|
||||
data: JSON.stringify({ data: [{ id: 'gpt-4o' }, { id: 'gpt-5.5', context_length: 200000 }] }),
|
||||
};
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.deepEqual(requested, ['https://api.openai.com/v1/models']);
|
||||
assert.equal(catalog.fetched, true);
|
||||
assert.ok(catalog.models.some((model) => model.id === 'gpt-5.5'));
|
||||
assert.equal(catalog.models.find((model) => model.id === 'gpt-5.5')?.contextWindow, 200000);
|
||||
});
|
||||
|
||||
test('providerModelCacheKey changes when the stored API key changes', () => {
|
||||
const base = { ...provider };
|
||||
const before = providerModelCacheKey({ ...base, apiKey: 'enc-old' });
|
||||
const after = providerModelCacheKey({ ...base, apiKey: 'enc-new' });
|
||||
const empty = providerModelCacheKey({ ...base, apiKey: undefined });
|
||||
assert.notEqual(before, after);
|
||||
assert.notEqual(before, empty);
|
||||
});
|
||||
|
||||
test('seedProviderModelCatalog includes the default and curated models', () => {
|
||||
const seed = seedProviderModelCatalog(provider);
|
||||
assert.equal(seed.fetched, false);
|
||||
assert.ok(seed.models.some((model) => model.id === 'deepseek-chat'));
|
||||
assert.ok(seed.models.some((model) => model.id === 'deepseek-v4-pro'));
|
||||
});
|
||||
|
||||
test('fetchProviderModelCatalog merges discovered models and caches them', async () => {
|
||||
clearProviderModelCatalogCache();
|
||||
const catalog = await fetchProviderModelCatalog(provider, {
|
||||
aiFetch: async () => ({
|
||||
ok: true,
|
||||
data: JSON.stringify({ data: [{ id: 'deepseek-reasoner', name: 'Reasoner' }] }),
|
||||
}),
|
||||
});
|
||||
assert.equal(catalog.fetched, true);
|
||||
assert.ok(catalog.models.some((model) => model.id === 'deepseek-reasoner'));
|
||||
assert.ok(catalog.models.some((model) => model.id === 'deepseek-chat'));
|
||||
|
||||
const cached = await fetchProviderModelCatalog(provider, {
|
||||
aiFetch: async () => {
|
||||
throw new Error('should not refetch');
|
||||
},
|
||||
});
|
||||
assert.equal(cached.fetched, true);
|
||||
assert.ok(cached.models.some((model) => model.id === 'deepseek-reasoner'));
|
||||
});
|
||||
|
||||
test('fetchProviderModelCatalog appends /v1 when listing Ollama Cloud from a bare origin', async () => {
|
||||
clearProviderModelCatalogCache();
|
||||
const requested: string[] = [];
|
||||
const catalog = await fetchProviderModelCatalog(
|
||||
{
|
||||
id: 'ollama-cloud',
|
||||
providerId: 'ollama',
|
||||
name: 'Ollama',
|
||||
defaultModel: 'deepseek-v4-flash:0731',
|
||||
baseURL: 'https://ollama.com',
|
||||
apiKey: 'cloud-key',
|
||||
enabled: true,
|
||||
},
|
||||
{
|
||||
aiFetch: async (url) => {
|
||||
requested.push(url);
|
||||
return {
|
||||
ok: true,
|
||||
data: JSON.stringify({ data: [{ id: 'deepseek-v4-flash:0731' }] }),
|
||||
};
|
||||
},
|
||||
},
|
||||
);
|
||||
assert.deepEqual(requested, ['https://ollama.com/v1/models']);
|
||||
assert.equal(catalog.fetched, true);
|
||||
assert.ok(catalog.models.some((model) => model.id === 'deepseek-v4-flash:0731'));
|
||||
});
|
||||
Reference in New Issue
Block a user