import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
import { collectSessionModels } from './collect-session-models';
const assistantMsg = (overrides = {}) => (Object.assign({ role: 'assistant', content: '' }, overrides));
const statusEntry = (name, model, provider) => ({
    name,
    isDefault: false,
    status: { model, provider },
});
const suite = createLogicSuite('collectSessionModels');
suite('collects unique models from assistant messages', () => {
    var _a, _b, _c, _d;
    const models = collectSessionModels([
        assistantMsg({ model: 'claude-sonnet-4-6' }),
        assistantMsg({ model: 'claude-haiku-4-5-20251001' }),
        assistantMsg({ model: 'claude-sonnet-4-6', provider: 'anthropic' }),
        assistantMsg({ model: 'gemini-2.5-pro', providerName: 'high', provider: 'gemini' }),
    ], []);
    assert.is(models.length, 3);
    assert.is((_a = models[0]) === null || _a === void 0 ? void 0 : _a.model, 'claude-sonnet-4-6');
    assert.is((_b = models[0]) === null || _b === void 0 ? void 0 : _b.provider, 'anthropic');
    assert.is((_c = models[2]) === null || _c === void 0 ? void 0 : _c.model, 'gemini-2.5-pro');
    assert.is((_d = models[2]) === null || _d === void 0 ? void 0 : _d.provider, 'gemini');
});
suite('resolves vendor from providerStatuses when messages lack provider', () => {
    var _a;
    const models = collectSessionModels([assistantMsg({ model: 'gemini-3.1-flash-lite', providerName: 'low' })], [statusEntry('low', 'gemini-3.1-flash-lite', 'gemini')]);
    assert.is(models.length, 1);
    assert.is((_a = models[0]) === null || _a === void 0 ? void 0 : _a.provider, 'gemini');
});
suite('does not persist registry tier names as provider', () => {
    var _a, _b;
    const models = collectSessionModels([assistantMsg({ model: 'gemini-3.1-flash-lite', providerName: 'low' })], []);
    assert.is((_a = models[0]) === null || _a === void 0 ? void 0 : _a.provider, undefined);
    assert.is('providerName' in ((_b = models[0]) !== null && _b !== void 0 ? _b : {}), false);
});
suite('includes models from sub-agent traces', () => {
    var _a;
    const models = collectSessionModels([
        assistantMsg({
            toolCalls: [
                {
                    id: 'tc1',
                    name: 'spawn',
                    args: {},
                    subAgentTrace: [assistantMsg({ model: 'claude-haiku-4-5-20251001' })],
                },
            ],
        }),
    ], []);
    assert.is(models.length, 1);
    assert.is((_a = models[0]) === null || _a === void 0 ? void 0 : _a.model, 'claude-haiku-4-5-20251001');
});
suite.run();
