mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-14 21:43:22 +08:00
重构主控编排与运行时预热链路,统一工作区提示词/专家调度协议并补齐 wiki 记忆注入与写回闭环。
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
This commit is contained in:
parent
4a23b715a2
commit
dbbe3add6a
14438 changed files with 2693620 additions and 2546 deletions
74
openclaw/extensions/vydra/speech-provider.test.ts
Normal file
74
openclaw/extensions/vydra/speech-provider.test.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { installPinnedHostnameTestHooks } from "openclaw/plugin-sdk/testing";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { buildVydraSpeechProvider } from "./speech-provider.js";
|
||||
|
||||
describe("vydra speech provider", () => {
|
||||
installPinnedHostnameTestHooks();
|
||||
|
||||
const provider = buildVydraSpeechProvider();
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it("exposes the default voice and model", async () => {
|
||||
expect(provider.models).toEqual(["elevenlabs/tts"]);
|
||||
const voices = await provider.listVoices?.({});
|
||||
expect(voices).toEqual([
|
||||
{
|
||||
id: "21m00Tcm4TlvDq8ikWAM",
|
||||
name: "Rachel",
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("posts to the tts endpoint and downloads the audio", async () => {
|
||||
const fetchMock = vi
|
||||
.fn()
|
||||
.mockResolvedValueOnce(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
audioUrl: "https://cdn.vydra.ai/generated/test.mp3",
|
||||
}),
|
||||
{
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
},
|
||||
),
|
||||
)
|
||||
.mockResolvedValueOnce(
|
||||
new Response(Buffer.from("mp3-data"), {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "audio/mpeg" },
|
||||
}),
|
||||
);
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const result = await provider.synthesize({
|
||||
text: "OpenClaw test",
|
||||
cfg: {} as never,
|
||||
providerConfig: { apiKey: "vydra-test-key" },
|
||||
target: "audio-file",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
|
||||
expect(fetchMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
"https://www.vydra.ai/api/v1/models/elevenlabs/tts",
|
||||
expect.objectContaining({
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
text: "OpenClaw test",
|
||||
voice_id: "21m00Tcm4TlvDq8ikWAM",
|
||||
}),
|
||||
}),
|
||||
);
|
||||
const [, init] = fetchMock.mock.calls[0] as [string, RequestInit];
|
||||
const headers = new Headers(init.headers);
|
||||
expect(headers.get("authorization")).toBe("Bearer vydra-test-key");
|
||||
expect(result.outputFormat).toBe("mp3");
|
||||
expect(result.fileExtension).toBe(".mp3");
|
||||
expect(result.audioBuffer).toEqual(Buffer.from("mp3-data"));
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue