Vendor OpenClaw source as Adolf fork baseline
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
This commit is contained in:
267
extensions/azure-speech/speech-provider.test.ts
Normal file
267
extensions/azure-speech/speech-provider.test.ts
Normal file
@@ -0,0 +1,267 @@
|
||||
// Azure Speech tests cover speech provider plugin behavior.
|
||||
import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const { azureSpeechTTSMock, listAzureSpeechVoicesMock } = vi.hoisted(() => ({
|
||||
azureSpeechTTSMock: vi.fn(async () => Buffer.from("audio-bytes")),
|
||||
listAzureSpeechVoicesMock: vi.fn(async () => [{ id: "en-US-JennyNeural", name: "Jenny" }]),
|
||||
}));
|
||||
|
||||
vi.mock("./tts.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("./tts.js")>();
|
||||
return {
|
||||
...actual,
|
||||
azureSpeechTTS: azureSpeechTTSMock,
|
||||
listAzureSpeechVoices: listAzureSpeechVoicesMock,
|
||||
};
|
||||
});
|
||||
|
||||
import { buildAzureSpeechProvider } from "./speech-provider.js";
|
||||
|
||||
describe("buildAzureSpeechProvider", () => {
|
||||
const envKeys = [
|
||||
"AZURE_SPEECH_KEY",
|
||||
"AZURE_SPEECH_API_KEY",
|
||||
"AZURE_SPEECH_REGION",
|
||||
"AZURE_SPEECH_ENDPOINT",
|
||||
"SPEECH_KEY",
|
||||
"SPEECH_REGION",
|
||||
] as const;
|
||||
|
||||
beforeEach(() => {
|
||||
for (const key of envKeys) {
|
||||
vi.stubEnv(key, undefined);
|
||||
}
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs();
|
||||
azureSpeechTTSMock.mockClear();
|
||||
listAzureSpeechVoicesMock.mockClear();
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
vi.doUnmock("./tts.js");
|
||||
vi.resetModules();
|
||||
});
|
||||
|
||||
it("reports configured only when key plus region or endpoint is available", () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
|
||||
expect(provider.isConfigured({ providerConfig: {}, timeoutMs: 30_000 })).toBe(false);
|
||||
expect(provider.isConfigured({ providerConfig: { apiKey: "key" }, timeoutMs: 30_000 })).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
provider.isConfigured({
|
||||
providerConfig: { apiKey: "key", region: "eastus" },
|
||||
timeoutMs: 30_000,
|
||||
}),
|
||||
).toBe(true);
|
||||
|
||||
vi.stubEnv("AZURE_SPEECH_KEY", "env-key");
|
||||
vi.stubEnv("AZURE_SPEECH_REGION", "eastus");
|
||||
expect(provider.isConfigured({ providerConfig: {}, timeoutMs: 30_000 })).toBe(true);
|
||||
});
|
||||
|
||||
it("normalizes provider-owned config under canonical and alias keys", () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
const canonical = provider.resolveConfig?.({
|
||||
cfg: {} as never,
|
||||
timeoutMs: 30_000,
|
||||
rawConfig: {
|
||||
providers: {
|
||||
"azure-speech": {
|
||||
apiKey: "key",
|
||||
region: "eastus",
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "en-US",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const alias = provider.resolveConfig?.({
|
||||
cfg: {} as never,
|
||||
timeoutMs: 30_000,
|
||||
rawConfig: {
|
||||
providers: {
|
||||
azure: {
|
||||
apiKey: "alias-key",
|
||||
endpoint: "https://westus.tts.speech.microsoft.com/cognitiveservices/v1",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(canonical).toEqual({
|
||||
apiKey: "key",
|
||||
region: "eastus",
|
||||
endpoint: undefined,
|
||||
baseUrl: "https://eastus.tts.speech.microsoft.com",
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "en-US",
|
||||
outputFormat: "audio-24khz-48kbitrate-mono-mp3",
|
||||
voiceNoteOutputFormat: "ogg-24khz-16bit-mono-opus",
|
||||
timeoutMs: undefined,
|
||||
});
|
||||
expect(alias).toEqual({
|
||||
apiKey: "alias-key",
|
||||
region: undefined,
|
||||
endpoint: "https://westus.tts.speech.microsoft.com/cognitiveservices/v1",
|
||||
baseUrl: "https://westus.tts.speech.microsoft.com",
|
||||
voice: "en-US-JennyNeural",
|
||||
lang: "en-US",
|
||||
outputFormat: "audio-24khz-48kbitrate-mono-mp3",
|
||||
voiceNoteOutputFormat: "ogg-24khz-16bit-mono-opus",
|
||||
timeoutMs: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("parses provider-specific TTS directives", () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
const policy = {
|
||||
enabled: true,
|
||||
allowText: true,
|
||||
allowProvider: true,
|
||||
allowVoice: true,
|
||||
allowModelId: true,
|
||||
allowVoiceSettings: true,
|
||||
allowNormalization: true,
|
||||
allowSeed: true,
|
||||
};
|
||||
|
||||
expect(provider.parseDirectiveToken?.({ key: "azure_voice", value: "v", policy })).toEqual({
|
||||
handled: true,
|
||||
overrides: { voice: "v" },
|
||||
});
|
||||
expect(provider.parseDirectiveToken?.({ key: "azure_lang", value: "en-US", policy })).toEqual({
|
||||
handled: true,
|
||||
overrides: { lang: "en-US" },
|
||||
});
|
||||
expect(
|
||||
provider.parseDirectiveToken?.({ key: "azure_output_format", value: "ogg", policy }),
|
||||
).toEqual({
|
||||
handled: true,
|
||||
overrides: { outputFormat: "ogg" },
|
||||
});
|
||||
});
|
||||
|
||||
it("uses native Ogg/Opus for voice-note output", async () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
const result = await provider.synthesize({
|
||||
text: "hello",
|
||||
cfg: {} as never,
|
||||
providerConfig: {
|
||||
apiKey: "key",
|
||||
region: "eastus",
|
||||
voice: "en-US-JennyNeural",
|
||||
},
|
||||
providerOverrides: {
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "en-US",
|
||||
},
|
||||
target: "voice-note",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
|
||||
expect(azureSpeechTTSMock).toHaveBeenCalledWith({
|
||||
text: "hello",
|
||||
apiKey: "key",
|
||||
baseUrl: "https://eastus.tts.speech.microsoft.com",
|
||||
endpoint: undefined,
|
||||
region: "eastus",
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "en-US",
|
||||
outputFormat: "ogg-24khz-16bit-mono-opus",
|
||||
timeoutMs: 30_000,
|
||||
maxBytes: 16 * 1024 * 1024,
|
||||
});
|
||||
expect(result).toEqual({
|
||||
audioBuffer: Buffer.from("audio-bytes"),
|
||||
outputFormat: "ogg-24khz-16bit-mono-opus",
|
||||
fileExtension: ".ogg",
|
||||
voiceCompatible: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("honors voice and language overrides for telephony output", async () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
const result = await provider.synthesizeTelephony?.({
|
||||
text: "hello",
|
||||
cfg: {} as never,
|
||||
providerConfig: {
|
||||
apiKey: "key",
|
||||
region: "eastus",
|
||||
voice: "en-US-JennyNeural",
|
||||
lang: "en-US",
|
||||
},
|
||||
providerOverrides: {
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "es-US",
|
||||
},
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
|
||||
expect(azureSpeechTTSMock).toHaveBeenCalledWith({
|
||||
text: "hello",
|
||||
apiKey: "key",
|
||||
baseUrl: "https://eastus.tts.speech.microsoft.com",
|
||||
endpoint: undefined,
|
||||
region: "eastus",
|
||||
voice: "en-US-AriaNeural",
|
||||
lang: "es-US",
|
||||
outputFormat: "raw-8khz-8bit-mono-mulaw",
|
||||
timeoutMs: 30_000,
|
||||
maxBytes: 16 * 1024 * 1024,
|
||||
});
|
||||
expect(result).toEqual({
|
||||
audioBuffer: Buffer.from("audio-bytes"),
|
||||
outputFormat: "raw-8khz-8bit-mono-mulaw",
|
||||
sampleRate: 8_000,
|
||||
});
|
||||
});
|
||||
|
||||
it("applies the configured media byte cap to synthesis requests", async () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
|
||||
await provider.synthesize({
|
||||
text: "hello",
|
||||
cfg: {
|
||||
agents: {
|
||||
defaults: {
|
||||
mediaMaxMb: 2,
|
||||
},
|
||||
},
|
||||
} as never,
|
||||
providerConfig: {
|
||||
apiKey: "key",
|
||||
region: "eastus",
|
||||
voice: "en-US-JennyNeural",
|
||||
},
|
||||
target: "audio-file",
|
||||
timeoutMs: 30_000,
|
||||
});
|
||||
|
||||
expect(azureSpeechTTSMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
maxBytes: 2 * 1024 * 1024,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("lists voices through config or explicit request auth", async () => {
|
||||
const provider = buildAzureSpeechProvider();
|
||||
const voices = await provider.listVoices?.({
|
||||
providerConfig: { apiKey: "key", region: "eastus" },
|
||||
});
|
||||
|
||||
expect(voices).toEqual([{ id: "en-US-JennyNeural", name: "Jenny" }]);
|
||||
expect(listAzureSpeechVoicesMock).toHaveBeenCalledWith({
|
||||
apiKey: "key",
|
||||
baseUrl: "https://eastus.tts.speech.microsoft.com",
|
||||
endpoint: undefined,
|
||||
region: "eastus",
|
||||
timeoutMs: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user