import assert from 'node:assert/strict' import test from 'node:test' import { install } from '../../ds-bot/src/host/models.js' function harness(missing) { const ctx = { on() {}, get() { return undefined }, llm: { listProviders: () => [{ id: 'p', name: 'P' }], listModels: async () => [{ id: 'm1' }, { id: 'm2' }], resolveModelInfo: async () => undefined, }, } const rt = { ctx, state: { bots: {} }, warn() {}, missingKeys: () => missing, save: async () => {} } install(rt) return rt } test('Q13/R4-04:真实 catalog 的 needsKey 不再被 availabilityOf 当可用', async () => { const missing = new Set(['p']) const rt = harness(missing) const unavailable = await rt.availabilityOf('p/m1') assert.equal(unavailable.available, false) assert.equal(unavailable.needsKey, true) assert.match(unavailable.reason, /凭据/) const other = await rt.availabilityOf('p/nope') assert.equal(other.available, false) missing.clear() rt.dropCatalog() assert.equal((await rt.availabilityOf('p/m1')).available, true) })