feat: publish HoloLake model-native living system source

This commit is contained in:
冰朔 2026-08-03 10:04:41 +08:00
commit c395dd3a99
2467 changed files with 615073 additions and 0 deletions

View file

@ -0,0 +1,43 @@
import { describe, expect, it, vi } from 'vitest'
import {
FIFTH_DOMAIN_DISCOVERY_URL,
fetchFifthDomainDiscovery,
parseFifthDomainDiscovery,
} from './fifthDomainDiscovery'
const validDiscovery = {
schema: 'guanghu.ai-discovery/v1',
name: '光湖语言世界 · 第五域',
canonical_repository: 'https://guanghulab.com/fifth-domain/bingshuo/fifth-domain',
repository_map: 'https://guanghulab.com/api/ai/v1/repositories',
server_node_map: 'https://guanghulab.com/api/ai/v1/nodes',
search_api: 'https://guanghulab.com/api/ai/v1/search?q={query}',
resolve_api: 'https://guanghulab.com/api/ai/v1/resolve?id={NUMBER}',
access: 'public-read-only',
}
describe('Fifth Domain discovery', () => {
it('accepts the canonical public read-only discovery document', () => {
expect(parseFifthDomainDiscovery(validDiscovery)).toMatchObject({
access: 'public-read-only',
canonicalRepository: validDiscovery.canonical_repository,
nodeMap: validDiscovery.server_node_map,
})
})
it('rejects a document that claims write access', () => {
expect(() => parseFifthDomainDiscovery({ ...validDiscovery, access: 'write' }))
.toThrow('public-read-only')
})
it('loads the well-known endpoint without sending credentials', async () => {
const fetcher = vi.fn().mockResolvedValue({ ok: true, json: () => Promise.resolve(validDiscovery) })
await fetchFifthDomainDiscovery(fetcher)
expect(fetcher).toHaveBeenCalledWith(FIFTH_DOMAIN_DISCOVERY_URL, {
cache: 'no-store',
credentials: 'omit',
signal: undefined,
})
})
})