import assert from 'node:assert/strict' import test from 'node:test' import { getSupportedThinkingLevels } from '@earendil-works/pi-ai' import { GEEK2API_MODELS, GEEK2API_MODEL_IDS, modelForHost } from '../src/catalog.js' import { DEFAULT_API_HOST, DEFAULT_REASONING_LEVEL, PROVIDER } from '../src/constants.js' const byId = id => GEEK2API_MODELS.find(model => model.id === id) const GPT = ['gpt-6.1-sol', 'gpt-6.2-sol', 'gpt-6.2-astra'] const DEEPSEEK = ['deepseek-v4.1-flash', 'deepseek-v4-pro'] test('ships only the requested GPT and DeepSeek models', () => { assert.deepEqual([...GEEK2API_MODEL_IDS], [...GPT, ...DEEPSEEK]) assert.equal(new Set(GEEK2API_MODEL_IDS).size, GEEK2API_MODEL_IDS.length) for (const model of GEEK2API_MODELS) { assert.equal(model.provider, PROVIDER) assert.ok(model.input.includes('text'), model.id) assert.ok(model.contextWindow > 0 && model.maxTokens > 0, model.id) } }) test('uses the InfStarAPI root and each model protocol', () => { for (const id of GPT) { assert.equal(byId(id).api, 'openai-responses', id) assert.equal(byId(id).baseUrl, `${DEFAULT_API_HOST}/v1`, id) } for (const id of DEEPSEEK) { assert.equal(byId(id).api, 'openai-completions', id) assert.equal(byId(id).baseUrl, `${DEFAULT_API_HOST}/v1`, id) } assert.equal(DEFAULT_API_HOST, 'https://sub.infstar.org') }) test('preserves known DeepSeek capabilities and reasoning levels', () => { assert.deepEqual([...byId('deepseek-v4-pro').input], ['text']) assert.deepEqual(getSupportedThinkingLevels(byId('deepseek-v4.1-flash')), ['off', 'low', 'high', 'max']) assert.deepEqual(getSupportedThinkingLevels(byId('deepseek-v4-pro')), ['off', 'low', 'high', 'max']) }) test('every reasoning model accepts the route default effort', () => { for (const model of GEEK2API_MODELS.filter(item => item.reasoning)) { assert.ok(getSupportedThinkingLevels(model).includes(DEFAULT_REASONING_LEVEL), `${model.id} must support ${DEFAULT_REASONING_LEVEL}`) } }) test('re-roots model base URLs without changing model IDs', () => { const gpt = byId('gpt-6.1-sol') assert.equal(modelForHost(gpt, 'https://backup.example').baseUrl, 'https://backup.example/v1') assert.equal(modelForHost(gpt, 'https://backup.example').id, 'gpt-6.1-sol') assert.equal(gpt.baseUrl, `${DEFAULT_API_HOST}/v1`) assert.equal(modelForHost(gpt, DEFAULT_API_HOST), gpt) assert.equal(modelForHost(gpt, undefined), gpt) assert.equal(modelForHost(undefined, 'https://x.example'), undefined) })