feat(compute): 新增近期模型并更新预设数据至 v140 (#133)

新增13个精确规格和11条接入,保留既有默认兜底顺序;完善官方来源与兼容边界。175项测试、来源校验、冻结Schema、目录对照和远端安全检查通过。
This commit is contained in:
yige authored and GitHub committed 2026-11-17 01:03:51 +08:00
1 parent 2a042fa1c2
commit 5f08ae8648
88 files changed
+7768 -110

No files matched your search

+130
View File
@@ -0,0 +1,130 @@
import test from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { resolveEffectiveModel } from '../scripts/catalog-v2/effective-model.mjs'
const read = file => JSON.parse(readFileSync(new URL(`../${file}`, import.meta.url), 'utf8'))
const catalog = read('catalog/v2/catalog.json')
const ids = [
'qwen4-max', 'qwen4-max-preview', 'glm-5.3-flashx-legal', 'hy4', 'hy4-flash', 'claude-fable-5-2',
'gemini-4-carbon', 'gemini-4-hydrogen', 'gpt-image-2.6-flare', 'gpt-image-2.6-sunburst',
'gemini-omni-1.1-flash', 'gemini-omni-1.2-flash', 'gemini-nano-banana-2.1',
]
const findSpec = id => catalog.specs.find(s => s.identity.canonicalModelId === id)
const providerModel = (provider, id) => read(`compute/providers/${provider}.json`).models.find(m => m.modelName === id)
const effective = (file, id) => {
const access = catalog.accesses.find(a => a.metadata.sourceFile === file)
const model = access.models.find(m => m.apiModelId === id)
return resolveEffectiveModel(catalog.specs.find(s => s.modelRef === model.modelRef), model, {
publicationState: 'published', requiredClientVersion: '0.0.0', clientVersion: '999.0.0',
now: '2026-11-16T00:00:00Z', connection: access.connection,
})
}
test('新增条目不改变仅指定供应商时首个对话模型的兜底选择', () => {
for (const [file, expected] of [
['compute/providers/dashscope.json', 'qwen3.8-omni-flash'],
['compute/providers/google.json', 'gemini-4-argon'],
['compute/providers/openrouter.json', 'mistralai/mistral-large-4-0'],
['compute/coding-plans/dashscope-token-plan.json', 'deepseek-v4.1-flash'],
]) {
const first = read(file).models.find(model => model.serviceType === 'chat' || model.serviceType?.includes('chat'))
assert.equal(first?.modelName, expected, file)
}
})
test('十一月新规格精确绑定且不扩展默认自动路由', () => {
for (const id of ids) {
const spec = findSpec(id)
assert.ok(spec, id)
assert.notEqual(spec.routing.eligibleForAgent, true, id)
assert.notEqual(spec.routing.defaultReference, true, id)
assert.equal(spec.metadata.legacyIdentity.match.patterns, undefined, id)
for (const a of catalog.accesses) for (const m of a.models.filter(m => m.modelRef === spec.modelRef)) {
assert.equal(m.binding.kind, 'exact', m.apiModelId)
const result = effective(a.metadata.sourceFile, m.apiModelId)
assert.equal(result.eligibleForCall, true, m.apiModelId)
assert.equal(result.eligibleForAutoRouting, false, m.apiModelId)
assert.deepEqual(result.pendingOverrides, [], m.apiModelId)
}
}
assert.equal(catalog.publication.state, 'candidate')
assert.equal(catalog.publication.requiredClientVersion, null)
})
test('Qwen 正式版的模式上限与 API、套餐、聚合价格分开', () => {
const spec = findSpec('qwen4-max')
assert.equal(spec.facts.maxInputTokens, 983616)
assert.equal(spec.facts.maxOutputTokens, 262144)
assert.equal(spec.metadata.legacyIdentity.match.exact.includes('qwen4-max-preview'), false)
const native = providerModel('dashscope', 'qwen4-max')
assert.deepEqual([native.contextWindow, native.maxOutputTokens, native.inputPrice, native.outputPrice], [1000000, 131072, 10, 30])
assert.deepEqual(native.extra.reasoning.supportedEfforts, ['none', 'high'])
const plan = read('compute/coding-plans/dashscope-token-plan.json').models.find(m => m.modelName === 'qwen4-max')
assert.equal(plan.maxOutputTokens, 131072)
assert.equal(plan.inputPrice, undefined)
assert.equal(plan.outputPrice, undefined)
assert.deepEqual(plan.extra.reasoning.supportedEfforts, ['none', 'high'])
const hosted = providerModel('openrouter', 'qwen/qwen4-max')
assert.deepEqual([hosted.inputPrice, hosted.outputPrice, hosted.extra.cachedInputPrice], [1.5, 4.5, 0.075])
})
test('Preview 精确规格阻止旧客户端剥离后继承正式版合同', () => {
const preview = findSpec('qwen4-max-preview')
const formal = findSpec('qwen4-max')
assert.deepEqual(preview.metadata.legacyIdentity.match.exact, ['qwen4-max-preview', 'qwen4.0-max-preview'])
for (const alias of preview.metadata.legacyIdentity.match.exact) {
assert.equal(catalog.specs.filter(s => s.metadata.legacyIdentity.match?.exact?.includes(alias)).length, 1)
assert.equal(formal.metadata.legacyIdentity.match.exact.includes(alias), false)
}
assert.deepEqual([preview.facts.maxOutputTokens, formal.facts.maxOutputTokens], [393216, 262144])
assert.equal(preview.metadata.previewPeriod.endsAt, '2026-11-25T16:00:00Z')
assert.equal(preview.lifecycle.retiredAt, undefined)
assert.equal(catalog.accesses.some(a => a.models.some(m => m.modelRef === preview.modelRef)), false)
})
test('Gemini 原生单次输出、平台长输出及默认思考档位不串用', () => {
const carbon = providerModel('google', 'gemini-4-carbon')
const hydrogen = providerModel('google', 'gemini-4-hydrogen')
assert.deepEqual([carbon.maxOutputTokens, hydrogen.maxOutputTokens], [32768, 65536])
assert.equal(findSpec('gemini-4-carbon').facts.maxOutputTokens, 65536)
assert.ok(findSpec('gemini-4-hydrogen').routing.reasoning.supportedModes.includes('xhigh'))
assert.equal(hydrogen.extra.reasoning.supportedEfforts.includes('xhigh'), false)
assert.equal(hydrogen.extra.reasoning.defaultEffort, 'high')
assert.match(carbon.extra.pricingNotes, /2026-12-01/)
for (const id of ['gemini-4-carbon', 'gemini-4-hydrogen']) {
assert.equal(providerModel('openrouter', `google/${id}`).maxOutputTokens, 943718)
assert.equal(effective('compute/providers/openrouter.json', `google/${id}`).facts.maxOutputTokens, 943718)
}
const hosted = providerModel('openrouter', 'google/gemini-4-hydrogen')
assert.equal(hosted.extra.reasoning.defaultEffort, 'medium')
assert.ok(hosted.extra.reasoning.supportedEfforts.includes('xhigh'))
})
test('未适配型号不写入原厂接入,媒体输入输出不冒充总窗口', () => {
for (const id of ['claude-fable-5-2', 'hy4-flash', 'gpt-image-2.6-flare', 'gpt-image-2.6-sunburst', 'gemini-omni-1.1-flash', 'gemini-omni-1.2-flash', 'gemini-nano-banana-2.1']) {
const ref = findSpec(id).modelRef
assert.equal(catalog.accesses.some(a => a.models.some(m => m.modelRef === ref)), false, id)
}
assert.equal(providerModel('tencent', 'hy4'), undefined)
assert.equal(providerModel('zhipu', 'glm-5.3-flashx-legal'), undefined)
for (const id of ['gemini-omni-1.1-flash', 'gemini-omni-1.2-flash', 'gemini-nano-banana-2.1']) {
assert.equal(findSpec(id).facts.contextWindow, undefined)
assert.equal(findSpec(id).facts.maxInputTokens, 131072)
}
})
test('百度托管国际与免费 ID 保持平台局部合同,不继承国内规格', () => {
for (const id of ['baidu/ernie-5.5-flash-preview:free', 'baidu/ernie-light-dt-1.0-intl']) {
const result = effective('compute/providers/openrouter.json', id)
assert.equal(result.identity, null)
assert.equal(result.manualOnly, true)
assert.equal(result.eligibleForCall, true)
assert.equal(result.eligibleForAutoRouting, false)
assert.equal(result.facts.contextWindow, 1024000)
}
const free = providerModel('openrouter', 'baidu/ernie-5.5-flash-preview:free')
assert.deepEqual([free.inputPrice, free.outputPrice], [0, 0])
const paid = providerModel('openrouter', 'baidu/ernie-light-dt-1.0-intl')
assert.deepEqual([paid.inputPrice, paid.outputPrice, paid.extra.cachedInputPrice], [1.13, 3.94, 0.113])
})
+6
View File
@@ -67,6 +67,12 @@ test('订阅专属模型文档只接受对应供应商的精确官网域名', ()
assert.ok(sourceUrlError('anthropic', 'https://www.kimi.com/code/docs/en/'))
})
test('Google 新文档入口仅接受精确 AI Studio 官方域名', () => {
assert.equal(sourceUrlError('google', 'https://aistudio.google.com/docs/models/gemini-4-hydrogen.md'), null)
assert.ok(sourceUrlError('google', 'https://aistudio.google.com.example.org/docs/models'))
assert.ok(sourceUrlError('openai', 'https://aistudio.google.com/docs/models'))
})
test('端点变化也必须复核来源,即使模型参数完全未变', () => fixture(({ root, provider, dataPath }) => {
assert.equal(validateSources(root).errors.length, 0)
provider.baseUrl = 'https://api.openai.com/v1'
+1 -1
View File
@@ -105,7 +105,7 @@ describe('真实数据全量校验', () => {
if (spec.routing) routed.push(spec)
}
}
assert.equal(routed.length, 67)
assert.equal(routed.length, 73)
assert.equal(routed.every((spec) => spec.routing.reasoning.supportedModes.includes(spec.routing.reasoning.defaultMode)), true)
assert.equal(routed.every((spec) => Array.isArray(spec.spec.capabilities)), true)
})