chore: bootstrap hermes-ui skeleton from 0.6.29 snapshot
Build / build (push) Canceled after 0s
NPM Lockfile Check / npm ci --ignore-scripts (push) Canceled after 0s
Playwright / e2e (push) Canceled after 0s

Import the client, server, skills, tests, and build scripts as the starting
point for the rebuild, then trim the surfaces this project does not ship:
Electron desktop packaging, the marketing website, and the ESP32 firmware
tree. CI keeps the web build, e2e, lockfile, release, and Docker workflows.

Rename the package and CLI entry points to hermes-ui, drop the prepare hook so
npm ci no longer triggers a build, and drop the removed tsconfig and nodemon
references. Rewrite AGENTS.md, ARCHITECTURE.md, DEVELOPMENT.md, and the READMEs
so the documented package map and hard rules match this repository.

reference_code/ is ignored: it is a read-only snapshot, not an input to the build.
This commit is contained in:
2026-10-16 10:34:35 +08:00
commit 1e9ea89d86
912 changed files with 287328 additions and 0 deletions
+128
View File
@@ -0,0 +1,128 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { doubaoTtsProvider } from '../../packages/server/src/services/hermes/tts-providers/doubao'
const mockFetch = vi.fn()
vi.stubGlobal('fetch', mockFetch)
function textResponse(body: string, init: { status?: number; contentType?: string } = {}) {
return {
ok: (init.status ?? 200) >= 200 && (init.status ?? 200) < 300,
status: init.status ?? 200,
statusText: 'OK',
headers: {
get(name: string) {
if (name.toLowerCase() === 'content-type') return init.contentType || 'application/json'
return null
},
},
async text() {
return body
},
async arrayBuffer() {
return Buffer.from(body)
},
}
}
function getJsonBody() {
const [, init] = mockFetch.mock.calls[0] as [string, RequestInit]
expect(init?.body).toBeTypeOf('string')
return JSON.parse(init.body as string)
}
describe('doubaoTtsProvider', () => {
beforeEach(() => {
mockFetch.mockReset()
})
it('defaults to mp3 at 24kHz for browser playback compatibility', async () => {
const audio = Buffer.from('mp3-audio')
mockFetch.mockResolvedValueOnce(textResponse(JSON.stringify({
data: audio.toString('base64'),
})))
const result = await doubaoTtsProvider.synthesize(
{ text: '你好' },
{
apiKey: 'secret',
},
)
expect(result).toEqual({
audio,
contentType: 'audio/mpeg',
engine: 'doubao',
provider: 'doubao',
})
expect(getJsonBody().req_params.audio_params).toEqual({
format: 'mp3',
sample_rate: 24000,
})
})
it('overrides audio format and sample rate when requested for MCU playback', async () => {
const pcm = Buffer.from('pcm-audio')
mockFetch.mockResolvedValueOnce(textResponse(JSON.stringify({
data: pcm.toString('base64'),
})))
const result = await doubaoTtsProvider.synthesize(
{ text: '已经找到设备。' },
{
apiKey: 'secret',
format: 'pcm',
sampleRate: 16000,
},
)
expect(result).toEqual({
audio: pcm,
contentType: 'audio/x-pcm',
engine: 'doubao',
provider: 'doubao',
})
expect(getJsonBody().req_params.audio_params).toEqual({
format: 'pcm',
sample_rate: 16000,
})
})
it('defaults to PCM at 24kHz when requested for MCU playback', async () => {
const pcm = Buffer.from('pcm-audio')
mockFetch.mockResolvedValueOnce(textResponse(JSON.stringify({
data: pcm.toString('base64'),
})))
const result = await doubaoTtsProvider.synthesize(
{ text: '已经找到设备。' },
{
apiKey: 'secret',
mcuPlayback: true,
},
)
expect(result).toEqual({
audio: pcm,
contentType: 'audio/x-pcm',
engine: 'doubao',
provider: 'doubao',
})
expect(getJsonBody().req_params.audio_params).toEqual({
format: 'pcm',
sample_rate: 24000,
})
})
it('rejects unsupported formats before calling Doubao', async () => {
await expect(doubaoTtsProvider.synthesize(
{ text: 'hello' },
{
apiKey: 'secret',
format: 'flac',
},
)).rejects.toThrow('Doubao TTS format must be one of')
expect(mockFetch).not.toHaveBeenCalled()
})
})