fix: enable verified ModelScope speech downloads

Selecting ModelScope could leave supported speech models unavailable because their fixed targets were incomplete and the official LFS redirect host was not allowed. Speech models now resolve complete per-source artifact fingerprints while preserving integrity checks, ZIP compatibility, and source isolation.

Release note: 修复选择 ModelScope 后部分语音模型仍无法下载的问题;六个语音模型现均可从已验证的固定 ModelScope 来源下载。
This commit is contained in:
mesalogo
2026-08-20 23:57:38 +08:00
parent aa339a73d6
commit a0977645a3
13 changed files with 663 additions and 133 deletions
+45
View File
@@ -1,4 +1,5 @@
import { describe, expect, it } from 'vitest'
import { modelArtifactTargetsSchema } from './model-download-contracts'
import {
speechModelCatalogEntrySchema,
speechModelLocalDirectoryInputSchema,
@@ -173,6 +174,50 @@ describe('speech model contracts', () => {
).toBe(false)
})
it('allows only the declared ModelScope CDN redirect host', () => {
const modelscopeRepositoryUrl =
'https://modelscope.cn/models/example/test-speech-model'
const target = {
url:
`${modelscopeRepositoryUrl}/resolve/${revision}/` +
'model.onnx',
repositoryUrl: modelscopeRepositoryUrl,
revision,
redirectHosts: ['cdn-lfs-cn-1.modelscope.cn']
}
expect(
modelArtifactTargetsSchema.safeParse({
modelscope: target
}).success
).toBe(true)
expect(
modelArtifactTargetsSchema.safeParse({
modelscope: {
...target,
size: 13,
sha256: 'b'.repeat(64)
}
}).success
).toBe(true)
expect(
modelArtifactTargetsSchema.safeParse({
modelscope: {
...target,
size: 13
}
}).success
).toBe(false)
expect(
modelArtifactTargetsSchema.safeParse({
modelscope: {
...target,
redirectHosts: ['untrusted.example']
}
}).success
).toBe(false)
})
it('keeps repository links consistent with source targets', () => {
expect(
speechModelCatalogEntrySchema.safeParse({