@vellumai/assistant 0.10.5-dev.202607031059.a49225a → 0.10.5-dev.202607031246.eae4811

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/eslint-rules/cli-no-daemon-internals.js +3 -0
  2. package/package.json +1 -1
  3. package/src/__tests__/call-controller.test.ts +34 -31
  4. package/src/__tests__/config-schema.test.ts +2 -4
  5. package/src/__tests__/secret-routes-platform-proxy.test.ts +5 -2
  6. package/src/__tests__/telephony-tts-guard.test.ts +14 -21
  7. package/src/__tests__/voice-quality.test.ts +19 -51
  8. package/src/calls/call-speech-output.ts +1 -2
  9. package/src/calls/resolve-call-tts-provider.ts +1 -1
  10. package/src/calls/tts-call-strategy.ts +22 -78
  11. package/src/calls/voice-quality.ts +24 -47
  12. package/src/cli/commands/keys.ts +86 -83
  13. package/src/config/loader.ts +0 -2
  14. package/src/config/schemas/tts.ts +7 -6
  15. package/src/daemon/lifecycle.ts +0 -12
  16. package/src/live-voice/__tests__/live-voice-tts.test.ts +10 -10
  17. package/src/live-voice/live-voice-tts.ts +1 -1
  18. package/src/providers/provider-availability.ts +11 -4
  19. package/src/runtime/routes/secret-routes.ts +14 -9
  20. package/src/tts/__tests__/provider-adapters.test.ts +28 -65
  21. package/src/tts/__tests__/provider-resolution.test.ts +83 -0
  22. package/src/tts/provider-catalog.ts +111 -262
  23. package/src/tts/provider-definition.ts +206 -0
  24. package/src/tts/providers/deepgram-provider.ts +41 -0
  25. package/src/tts/providers/elevenlabs-provider.ts +89 -0
  26. package/src/tts/providers/fish-audio-provider.ts +42 -0
  27. package/src/tts/providers/xai-provider.ts +41 -0
  28. package/src/tts/synthesize-text.ts +1 -1
  29. package/src/tts/types.ts +32 -9
  30. package/src/tts/__tests__/provider-registry.test.ts +0 -90
  31. package/src/tts/provider-registry.ts +0 -73
  32. package/src/tts/providers/index.ts +0 -44
  33. package/src/tts/providers/register-builtins.ts +0 -130
@@ -78,6 +78,9 @@ const ALLOWED_PREFIXES = {
78
78
  // Secure key storage (keys.ts) needs direct security module access —
79
79
  // by design, the secure-key helpers run in-process (not over IPC).
80
80
  "../../security/",
81
+ // Canonical API-key provider list (keys.ts help text + validation) —
82
+ // a static metadata catalog with no daemon state.
83
+ "../../providers/provider-secret-catalog",
81
84
  // CES bridge (credential-execution.ts) speaks to the CES sidecar via
82
85
  // service-contracts RPC; daemon is not involved.
83
86
  "../../credential-execution/",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.10.5-dev.202607031059.a49225a",
3
+ "version": "0.10.5-dev.202607031246.eae4811",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -194,19 +194,20 @@ mock.module("../calls/voice-session-bridge.js", () => {
194
194
  };
195
195
  });
196
196
 
197
- // ── TTS provider registry setup ──────────────────────────────────────
198
- // Register test providers so call-controller can resolve the TTS provider
199
- // abstraction. ElevenLabs is the default native provider (no streaming),
200
- // while Fish Audio is a synthesized provider (streaming).
197
+ // ── TTS provider override setup ──────────────────────────────────────
198
+ // Install test adapters that shadow the static catalog adapters so
199
+ // call-controller resolves stubs instead of real HTTP-backed providers.
200
+ // ElevenLabs is the default native provider (no streaming), while Fish
201
+ // Audio is a synthesized provider (streaming).
201
202
 
202
203
  import {
203
- _resetTtsProviderRegistry,
204
- registerTtsProvider,
205
- } from "../tts/provider-registry.js";
204
+ _resetTtsProviderOverridesForTests,
205
+ _setTtsProviderForTests,
206
+ } from "../tts/provider-catalog.js";
206
207
  import type { TtsProvider } from "../tts/types.js";
207
208
 
208
209
  function registerTestTtsProviders(): void {
209
- _resetTtsProviderRegistry();
210
+ _resetTtsProviderOverridesForTests();
210
211
 
211
212
  const elevenlabs: TtsProvider = {
212
213
  id: "elevenlabs",
@@ -215,7 +216,7 @@ function registerTestTtsProviders(): void {
215
216
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
216
217
  },
217
218
  };
218
- registerTtsProvider(elevenlabs);
219
+ _setTtsProviderForTests(elevenlabs);
219
220
 
220
221
  const fishAudio: TtsProvider = {
221
222
  id: "fish-audio",
@@ -230,7 +231,7 @@ function registerTestTtsProviders(): void {
230
231
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
231
232
  },
232
233
  };
233
- registerTtsProvider(fishAudio);
234
+ _setTtsProviderForTests(fishAudio);
234
235
 
235
236
  const deepgram: TtsProvider = {
236
237
  id: "deepgram",
@@ -245,7 +246,7 @@ function registerTestTtsProviders(): void {
245
246
  };
246
247
  },
247
248
  };
248
- registerTtsProvider(deepgram);
249
+ _setTtsProviderForTests(deepgram);
249
250
  }
250
251
 
251
252
  // Register providers immediately so they're available for all tests
@@ -2693,7 +2694,7 @@ describe("call-controller", () => {
2693
2694
  cfg.services.tts.provider = "fish-audio";
2694
2695
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-123";
2695
2696
 
2696
- _resetTtsProviderRegistry();
2697
+ _resetTtsProviderOverridesForTests();
2697
2698
  const elevenlabs: TtsProvider = {
2698
2699
  id: "elevenlabs",
2699
2700
  capabilities: { supportsStreaming: false, supportedFormats: ["mp3"] },
@@ -2701,7 +2702,7 @@ describe("call-controller", () => {
2701
2702
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
2702
2703
  },
2703
2704
  };
2704
- registerTtsProvider(elevenlabs);
2705
+ _setTtsProviderForTests(elevenlabs);
2705
2706
 
2706
2707
  const fishAudioFailing: TtsProvider = {
2707
2708
  id: "fish-audio",
@@ -2716,7 +2717,7 @@ describe("call-controller", () => {
2716
2717
  throw new Error("fish-audio stream failure");
2717
2718
  },
2718
2719
  };
2719
- registerTtsProvider(fishAudioFailing);
2720
+ _setTtsProviderForTests(fishAudioFailing);
2720
2721
 
2721
2722
  mockStartVoiceTurn.mockImplementation(
2722
2723
  createMockVoiceTurn(["Hello from synthesized path"]),
@@ -2743,7 +2744,7 @@ describe("call-controller", () => {
2743
2744
  cfg.services.tts.provider = "fish-audio";
2744
2745
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-123";
2745
2746
 
2746
- _resetTtsProviderRegistry();
2747
+ _resetTtsProviderOverridesForTests();
2747
2748
  // elevenlabs present so native fallback is available for fish-audio.
2748
2749
  const elevenlabs: TtsProvider = {
2749
2750
  id: "elevenlabs",
@@ -2752,7 +2753,7 @@ describe("call-controller", () => {
2752
2753
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
2753
2754
  },
2754
2755
  };
2755
- registerTtsProvider(elevenlabs);
2756
+ _setTtsProviderForTests(elevenlabs);
2756
2757
 
2757
2758
  let releaseSynth: (() => void) | undefined;
2758
2759
  const synthGate = new Promise<void>((resolve) => {
@@ -2774,7 +2775,7 @@ describe("call-controller", () => {
2774
2775
  throw new Error("fish-audio stream failure");
2775
2776
  },
2776
2777
  };
2777
- registerTtsProvider(fishAudioGatedFailing);
2778
+ _setTtsProviderForTests(fishAudioGatedFailing);
2778
2779
 
2779
2780
  mockStartVoiceTurn.mockImplementation(
2780
2781
  createMockVoiceTurn(["Stale synthesized response"]),
@@ -2803,7 +2804,7 @@ describe("call-controller", () => {
2803
2804
  cfg.services.tts.provider = "fish-audio";
2804
2805
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-123";
2805
2806
 
2806
- _resetTtsProviderRegistry();
2807
+ _resetTtsProviderOverridesForTests();
2807
2808
  const fishAudioStreaming: TtsProvider = {
2808
2809
  id: "fish-audio",
2809
2810
  capabilities: {
@@ -2824,7 +2825,7 @@ describe("call-controller", () => {
2824
2825
  };
2825
2826
  },
2826
2827
  };
2827
- registerTtsProvider(fishAudioStreaming);
2828
+ _setTtsProviderForTests(fishAudioStreaming);
2828
2829
 
2829
2830
  mockStartVoiceTurn.mockImplementation(
2830
2831
  createMockVoiceTurn(["Hello from synthesized path."]),
@@ -2846,7 +2847,7 @@ describe("call-controller", () => {
2846
2847
  cfg.services.tts.provider = "fish-audio";
2847
2848
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-123";
2848
2849
 
2849
- _resetTtsProviderRegistry();
2850
+ _resetTtsProviderOverridesForTests();
2850
2851
  let releaseChunk: (() => void) | undefined;
2851
2852
  const chunkGate = new Promise<void>((resolve) => {
2852
2853
  releaseChunk = resolve;
@@ -2870,7 +2871,7 @@ describe("call-controller", () => {
2870
2871
  };
2871
2872
  },
2872
2873
  };
2873
- registerTtsProvider(fishAudioStreaming);
2874
+ _setTtsProviderForTests(fishAudioStreaming);
2874
2875
 
2875
2876
  mockStartVoiceTurn.mockImplementation(
2876
2877
  createMockVoiceTurn(["Hello from synthesized path."]),
@@ -2902,7 +2903,7 @@ describe("call-controller", () => {
2902
2903
  cfg.services.tts.provider = "fish-audio";
2903
2904
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-123";
2904
2905
 
2905
- _resetTtsProviderRegistry();
2906
+ _resetTtsProviderOverridesForTests();
2906
2907
  let releaseChunk: (() => void) | undefined;
2907
2908
  const chunkGate = new Promise<void>((resolve) => {
2908
2909
  releaseChunk = resolve;
@@ -2923,7 +2924,7 @@ describe("call-controller", () => {
2923
2924
  return { audio: Buffer.from("stale-audio"), contentType: "audio/mpeg" };
2924
2925
  },
2925
2926
  };
2926
- registerTtsProvider(fishAudioStreaming);
2927
+ _setTtsProviderForTests(fishAudioStreaming);
2927
2928
 
2928
2929
  mockStartVoiceTurn.mockImplementation(
2929
2930
  createMockVoiceTurn(["Hello from synthesized path."]),
@@ -2962,7 +2963,7 @@ describe("call-controller", () => {
2962
2963
  const cfg = loadConfig();
2963
2964
  cfg.services.tts.provider = "deepgram";
2964
2965
 
2965
- _resetTtsProviderRegistry();
2966
+ _resetTtsProviderOverridesForTests();
2966
2967
  const elevenlabs: TtsProvider = {
2967
2968
  id: "elevenlabs",
2968
2969
  capabilities: { supportsStreaming: false, supportedFormats: ["mp3"] },
@@ -2970,7 +2971,7 @@ describe("call-controller", () => {
2970
2971
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
2971
2972
  },
2972
2973
  };
2973
- registerTtsProvider(elevenlabs);
2974
+ _setTtsProviderForTests(elevenlabs);
2974
2975
 
2975
2976
  const deepgramFailing: TtsProvider = {
2976
2977
  id: "deepgram",
@@ -2984,7 +2985,7 @@ describe("call-controller", () => {
2984
2985
  throw err;
2985
2986
  },
2986
2987
  };
2987
- registerTtsProvider(deepgramFailing);
2988
+ _setTtsProviderForTests(deepgramFailing);
2988
2989
 
2989
2990
  mockStartVoiceTurn.mockImplementation(
2990
2991
  createMockVoiceTurn(["Hello from deepgram path"]),
@@ -3011,7 +3012,7 @@ describe("call-controller", () => {
3011
3012
  cfg.services.tts.provider = "fish-audio";
3012
3013
  cfg.services.tts.providers["fish-audio"].referenceId = "fish-ref-abc";
3013
3014
 
3014
- _resetTtsProviderRegistry();
3015
+ _resetTtsProviderOverridesForTests();
3015
3016
  const elevenlabs: TtsProvider = {
3016
3017
  id: "elevenlabs",
3017
3018
  capabilities: { supportsStreaming: false, supportedFormats: ["mp3"] },
@@ -3019,7 +3020,7 @@ describe("call-controller", () => {
3019
3020
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
3020
3021
  },
3021
3022
  };
3022
- registerTtsProvider(elevenlabs);
3023
+ _setTtsProviderForTests(elevenlabs);
3023
3024
 
3024
3025
  const fishAudioFailing: TtsProvider = {
3025
3026
  id: "fish-audio",
@@ -3034,7 +3035,7 @@ describe("call-controller", () => {
3034
3035
  throw new Error("fish-audio stream failure");
3035
3036
  },
3036
3037
  };
3037
- registerTtsProvider(fishAudioFailing);
3038
+ _setTtsProviderForTests(fishAudioFailing);
3038
3039
 
3039
3040
  mockStartVoiceTurn.mockImplementation(
3040
3041
  createMockVoiceTurn(["Hello from fish path"]),
@@ -3108,8 +3109,10 @@ describe("call-controller", () => {
3108
3109
  expect(result.audioFormat).toBe("mp3");
3109
3110
  });
3110
3111
 
3111
- test("returns fallback when provider registry is empty", async () => {
3112
- _resetTtsProviderRegistry();
3112
+ test("returns fallback when the configured provider is not in the catalog", async () => {
3113
+ const cfg = loadConfig();
3114
+ cfg.services.tts.provider = "not-a-real-provider";
3115
+
3113
3116
  const result = await resolveCallTtsProvider();
3114
3117
  expect(result.provider).toBeNull();
3115
3118
  expect(result.useSynthesizedPath).toBe(false);
@@ -49,10 +49,7 @@ mock.module("../util/logger.js", () => ({
49
49
  getLogger: () => makeLoggerStub(),
50
50
  }));
51
51
 
52
- import {
53
- buildElevenLabsVoiceSpec,
54
- resolveVoiceQualityProfile,
55
- } from "../calls/voice-quality.js";
52
+ import { resolveVoiceQualityProfile } from "../calls/voice-quality.js";
56
53
  import { invalidateConfigCache, loadConfig } from "../config/loader.js";
57
54
  import {
58
55
  AssistantConfigSchema,
@@ -65,6 +62,7 @@ import {
65
62
  } from "../config/schemas/tts.js";
66
63
  import type { AssistantConfig } from "../config/types.js";
67
64
  import { listCatalogProviderIds } from "../tts/provider-catalog.js";
65
+ import { buildElevenLabsVoiceSpec } from "../tts/providers/elevenlabs-provider.js";
68
66
  import { resolveTtsConfig } from "../tts/tts-config-resolver.js";
69
67
  import { setStorePathForTesting } from "./encrypted-store-test-helpers.js";
70
68
 
@@ -78,6 +78,11 @@ mock.module("../config/env.js", () => ({
78
78
  }));
79
79
 
80
80
  mock.module("../config/loader.js", () => ({
81
+ getConfig: () => mockConfig,
82
+ invalidateConfigCache: () => {},
83
+ }));
84
+
85
+ mock.module("../providers/provider-secret-catalog.js", () => ({
81
86
  API_KEY_PROVIDERS: [
82
87
  "anthropic",
83
88
  "openai",
@@ -85,8 +90,6 @@ mock.module("../config/loader.js", () => ({
85
90
  "fireworks",
86
91
  "openrouter",
87
92
  ],
88
- getConfig: () => mockConfig,
89
- invalidateConfigCache: () => {},
90
93
  }));
91
94
 
92
95
  mock.module("../security/secure-keys.js", () => ({
@@ -49,9 +49,6 @@ const realConfigLoaderModule = { ...(await import("../config/loader.js")) };
49
49
  const realSecureKeysModule = {
50
50
  ...(await import("../security/secure-keys.js")),
51
51
  };
52
- const realProviderRegistryModule = {
53
- ...(await import("../tts/provider-registry.js")),
54
- };
55
52
  const realAudioStoreModule = { ...(await import("../calls/audio-store.js")) };
56
53
  const realPublicIngressUrlsModule = {
57
54
  ...(await import("../inbound/public-ingress-urls.js")),
@@ -103,6 +100,10 @@ const fakeCatalog: FakeCatalogEntry[] = [
103
100
  makeEntry("compressed-only", "synthesized-play", "none", false),
104
101
  ];
105
102
 
103
+ // The catalog is also the adapter-resolution point (`getTtsProvider`), so the
104
+ // fake registry of stub adapters is served through the same module mock.
105
+ const registeredProviders = new Map<string, unknown>();
106
+
106
107
  mock.module("../tts/provider-catalog.js", () => ({
107
108
  ...realProviderCatalogModule,
108
109
  listCatalogProviders: () =>
@@ -123,6 +124,16 @@ mock.module("../tts/provider-catalog.js", () => ({
123
124
  }
124
125
  return entry;
125
126
  },
127
+ getTtsProvider: (id: string) => {
128
+ if (!guardMocksActive) {
129
+ return realProviderCatalogModule.getTtsProvider(id);
130
+ }
131
+ const provider = registeredProviders.get(id);
132
+ if (!provider) {
133
+ throw new Error(`Unknown TTS provider "${id}".`);
134
+ }
135
+ return provider;
136
+ },
126
137
  }));
127
138
 
128
139
  // -- Mutable config ------------------------------------------------------------
@@ -167,24 +178,6 @@ mock.module("../security/secure-keys.js", () => ({
167
178
  : realSecureKeysModule.getSecureKeyAsync(key),
168
179
  }));
169
180
 
170
- // -- Mutable provider registry ---------------------------------------------------
171
-
172
- const registeredProviders = new Map<string, unknown>();
173
-
174
- mock.module("../tts/provider-registry.js", () => ({
175
- ...realProviderRegistryModule,
176
- getTtsProvider: (id: string) => {
177
- if (!guardMocksActive) {
178
- return realProviderRegistryModule.getTtsProvider(id);
179
- }
180
- const provider = registeredProviders.get(id);
181
- if (!provider) {
182
- throw new Error(`Unknown TTS provider "${id}".`);
183
- }
184
- return provider;
185
- },
186
- }));
187
-
188
181
  // -- Audio store + ingress URL (used by call-speech-output) ---------------------
189
182
 
190
183
  const finalizeCalls: string[] = [];
@@ -29,23 +29,20 @@ mock.module("../config/loader.js", () => ({
29
29
  loadConfig: () => mockConfig,
30
30
  }));
31
31
 
32
- // -- Call strategy voice-spec registry setup --------------------------------
32
+ // -- Stub adapter overrides --------------------------------------------------
33
+ // The native Twilio voice specs come from the static provider catalog; only
34
+ // the runtime adapters are stubbed (availability checks must not hit real
35
+ // provider HTTP APIs).
33
36
 
34
37
  import {
35
- _resetNativeTwilioVoiceSpecRegistry,
36
- registerNativeTwilioVoiceSpec,
37
- } from "../calls/tts-call-strategy.js";
38
- import {
39
- _resetTtsProviderRegistry,
40
- registerTtsProvider,
41
- } from "../tts/provider-registry.js";
38
+ _resetTtsProviderOverridesForTests,
39
+ _setTtsProviderForTests,
40
+ } from "../tts/provider-catalog.js";
42
41
  import type { TtsProvider } from "../tts/types.js";
43
42
 
44
43
  function registerTestVoiceSpecs(): void {
45
- _resetNativeTwilioVoiceSpecRegistry();
46
- _resetTtsProviderRegistry();
44
+ _resetTtsProviderOverridesForTests();
47
45
 
48
- // Register runtime TTS providers (needed for availability checks).
49
46
  const elevenlabs: TtsProvider = {
50
47
  id: "elevenlabs",
51
48
  capabilities: { supportsStreaming: false, supportedFormats: ["mp3"] },
@@ -53,7 +50,7 @@ function registerTestVoiceSpecs(): void {
53
50
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
54
51
  },
55
52
  };
56
- registerTtsProvider(elevenlabs);
53
+ _setTtsProviderForTests(elevenlabs);
57
54
 
58
55
  const fishAudio: TtsProvider = {
59
56
  id: "fish-audio",
@@ -68,7 +65,7 @@ function registerTestVoiceSpecs(): void {
68
65
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
69
66
  },
70
67
  };
71
- registerTtsProvider(fishAudio);
68
+ _setTtsProviderForTests(fishAudio);
72
69
 
73
70
  const deepgram: TtsProvider = {
74
71
  id: "deepgram",
@@ -80,38 +77,14 @@ function registerTestVoiceSpecs(): void {
80
77
  return { audio: Buffer.from(""), contentType: "audio/mpeg" };
81
78
  },
82
79
  };
83
- registerTtsProvider(deepgram);
84
-
85
- // Register the ElevenLabs native Twilio voice-spec builder (mirrors
86
- // the production registration in register-builtins.ts).
87
- registerNativeTwilioVoiceSpec("elevenlabs", {
88
- twilioProviderName: "ElevenLabs",
89
- buildVoiceSpec: (providerConfig) => {
90
- const cfg = providerConfig as {
91
- voiceId?: string;
92
- voiceModelId?: string;
93
- speed?: number;
94
- stability?: number;
95
- similarityBoost?: number;
96
- };
97
- return buildElevenLabsVoiceSpec({
98
- voiceId: cfg.voiceId ?? "",
99
- voiceModelId: cfg.voiceModelId,
100
- speed: cfg.speed,
101
- stability: cfg.stability,
102
- similarityBoost: cfg.similarityBoost,
103
- });
104
- },
105
- });
80
+ _setTtsProviderForTests(deepgram);
106
81
  }
107
82
 
108
83
  // -- Import subjects after mocks ------------------------------------------
109
84
 
110
- import {
111
- buildElevenLabsVoiceSpec,
112
- resolveVoiceQualityProfile,
113
- } from "../calls/voice-quality.js";
85
+ import { resolveVoiceQualityProfile } from "../calls/voice-quality.js";
114
86
  import { DEFAULT_ELEVENLABS_VOICE_ID } from "../config/schemas/elevenlabs.js";
87
+ import { buildElevenLabsVoiceSpec } from "../tts/providers/elevenlabs-provider.js";
115
88
 
116
89
  // -- Tests ----------------------------------------------------------------
117
90
 
@@ -195,7 +168,7 @@ describe("resolveVoiceQualityProfile", () => {
195
168
  expect(profile.ttsProvider).toBe("ElevenLabs");
196
169
  });
197
170
 
198
- test("voice spec comes from registered NativeTwilioVoiceSpec builder", () => {
171
+ test("voice spec comes from the catalog NativeTwilioVoiceSpec builder", () => {
199
172
  mockConfig = {
200
173
  calls: {
201
174
  voice: {
@@ -487,7 +460,7 @@ describe("resolveVoiceQualityProfile", () => {
487
460
  expect(profile.voice).toBe(DEFAULT_ELEVENLABS_VOICE_ID);
488
461
  });
489
462
 
490
- test("native-twilio strategy delegates voice-spec to registered builder", () => {
463
+ test("native-twilio strategy delegates voice-spec to the catalog builder", () => {
491
464
  // The catalog declares elevenlabs as native-twilio. The voice spec
492
465
  // is built by the registered NativeTwilioVoiceSpec builder, not by
493
466
  // hardcoded branching in resolveVoiceQualityProfile.
@@ -519,10 +492,7 @@ describe("resolveVoiceQualityProfile", () => {
519
492
  expect(profile.voice).toBe("test-voice-model-x-1.1_0.6_0.8");
520
493
  });
521
494
 
522
- test("falls back to ElevenLabs config when voice-spec builder is not registered", () => {
523
- // Clear the voice-spec registry to simulate missing builder.
524
- _resetNativeTwilioVoiceSpecRegistry();
525
-
495
+ test("builds a bare voiceId spec from the elevenlabs config block", () => {
526
496
  mockConfig = {
527
497
  calls: {
528
498
  voice: {
@@ -541,15 +511,13 @@ describe("resolveVoiceQualityProfile", () => {
541
511
  },
542
512
  };
543
513
  const profile = resolveVoiceQualityProfile();
544
- // Falls back to reading from the elevenlabs config block directly.
545
514
  expect(profile.ttsProvider).toBe("ElevenLabs");
546
515
  expect(profile.voice).toBe("some-voice");
547
516
  });
548
517
 
549
- test("falls back to default voice ID when no config or builder available", () => {
550
- // Clear the voice-spec registry and omit elevenlabs config.
551
- _resetNativeTwilioVoiceSpecRegistry();
552
-
518
+ test("falls back to default voice ID when the elevenlabs config block is missing", () => {
519
+ // The catalog voice spec resolves to an empty voice without an elevenlabs
520
+ // config block; the profile must not carry it (Twilio 64106).
553
521
  mockConfig = {
554
522
  calls: {
555
523
  voice: {
@@ -17,8 +17,7 @@
17
17
 
18
18
  import { loadConfig } from "../config/loader.js";
19
19
  import { getPublicBaseUrl } from "../inbound/public-ingress-urls.js";
20
- import { getCatalogProvider } from "../tts/provider-catalog.js";
21
- import { getTtsProvider } from "../tts/provider-registry.js";
20
+ import { getCatalogProvider, getTtsProvider } from "../tts/provider-catalog.js";
22
21
  import type { TtsProvider, TtsProviderId } from "../tts/types.js";
23
22
  import { getLogger } from "../util/logger.js";
24
23
  import { createStreamingEntry } from "./audio-store.js";
@@ -10,9 +10,9 @@
10
10
  import { loadConfig } from "../config/loader.js";
11
11
  import {
12
12
  getCatalogProvider,
13
+ getTtsProvider,
13
14
  listCatalogProviderIds,
14
15
  } from "../tts/provider-catalog.js";
15
- import { getTtsProvider } from "../tts/provider-registry.js";
16
16
  import { resolveTtsConfig } from "../tts/tts-config-resolver.js";
17
17
  import type { TtsProvider, TtsProviderId } from "../tts/types.js";
18
18
  import { getLogger } from "../util/logger.js";
@@ -12,7 +12,8 @@
12
12
  * `sendTextToken()`, which the media-stream transport re-synthesizes
13
13
  * through daemon TTS. The profile carries a real `ttsProvider` name
14
14
  * (e.g. `"ElevenLabs"`) and a provider-specific voice spec string built
15
- * by a registered {@link NativeTwilioVoiceSpecBuilder}.
15
+ * by the {@link NativeTwilioVoiceSpecBuilder} the provider declares in
16
+ * its catalog definition.
16
17
  *
17
18
  * - **synthesized-play** -- The assistant synthesises audio via the
18
19
  * provider API and streams it through the audio store / `sendPlayUrl()`
@@ -24,85 +25,41 @@
24
25
  */
25
26
 
26
27
  import type { AssistantConfig } from "../config/types.js";
27
- import { getCatalogProvider } from "../tts/provider-catalog.js";
28
+ import {
29
+ getCatalogProvider,
30
+ getProviderDefinition,
31
+ } from "../tts/provider-catalog.js";
32
+ import type { NativeTwilioVoiceSpec } from "../tts/provider-definition.js";
28
33
  import { resolveTtsConfig } from "../tts/tts-config-resolver.js";
29
34
  import type { TtsCallMode, TtsProviderId } from "../tts/types.js";
30
35
 
36
+ export type {
37
+ NativeTwilioVoiceSpec,
38
+ NativeTwilioVoiceSpecBuilder,
39
+ } from "../tts/provider-definition.js";
40
+
31
41
  // ---------------------------------------------------------------------------
32
- // Native Twilio voice-spec builder registry
42
+ // Native Twilio voice-spec lookup
33
43
  // ---------------------------------------------------------------------------
34
44
 
35
45
  /**
36
- * Builds the provider-specific voice spec string for a native Twilio
37
- * provider.
38
- *
39
- * The returned string is used as Twilio's TTS `voice` attribute. Its
40
- * format is provider-specific -- e.g. ElevenLabs uses
41
- * `voiceId-modelId-speed_stability_similarity`.
42
- *
43
- * @param providerConfig - Provider-specific config block from
44
- * `services.tts.providers.<id>`.
45
- * @returns The voice spec string for Twilio's TTS `voice` attribute, or
46
- * an empty string if the provider has no voice to specify.
47
- */
48
- export type NativeTwilioVoiceSpecBuilder = (
49
- providerConfig: Record<string, unknown>,
50
- ) => string;
51
-
52
- /**
53
- * Metadata returned by a native Twilio voice-spec builder registration.
54
- */
55
- export interface NativeTwilioVoiceSpec {
56
- /** The Twilio `ttsProvider` attribute value (e.g. `"ElevenLabs"`). */
57
- readonly twilioProviderName: string;
58
-
59
- /** Builds the `voice` attribute string from provider config. */
60
- readonly buildVoiceSpec: NativeTwilioVoiceSpecBuilder;
61
- }
62
-
63
- /** Internal registry keyed by provider ID. */
64
- const nativeVoiceSpecRegistry = new Map<TtsProviderId, NativeTwilioVoiceSpec>();
65
-
66
- /**
67
- * Register a native Twilio voice-spec builder for a provider.
68
- *
69
- * Called at startup alongside provider adapter registration. This is
70
- * the extension point that allows new native Twilio providers to be
71
- * added without modifying core call routing logic.
72
- *
73
- * @throws if a builder for the same provider ID is already registered.
74
- */
75
- export function registerNativeTwilioVoiceSpec(
76
- providerId: TtsProviderId,
77
- spec: NativeTwilioVoiceSpec,
78
- ): void {
79
- if (nativeVoiceSpecRegistry.has(providerId)) {
80
- throw new Error(
81
- `Native Twilio voice spec for "${providerId}" is already registered. ` +
82
- "Duplicate registrations are not allowed.",
83
- );
84
- }
85
- nativeVoiceSpecRegistry.set(providerId, spec);
86
- }
87
-
88
- /**
89
- * Look up a registered native Twilio voice-spec builder.
46
+ * Look up the native Twilio voice-spec builder a provider declares in its
47
+ * catalog definition.
90
48
  *
91
- * @throws if no builder has been registered for the given provider.
49
+ * @throws if the provider is not in the catalog, or is not a
50
+ * `native-twilio` provider (synthesized-play providers have no spec).
92
51
  */
93
52
  export function getNativeTwilioVoiceSpec(
94
53
  providerId: TtsProviderId,
95
54
  ): NativeTwilioVoiceSpec {
96
- const spec = nativeVoiceSpecRegistry.get(providerId);
97
- if (!spec) {
98
- const known = [...nativeVoiceSpecRegistry.keys()];
99
- const knownList =
100
- known.length > 0 ? ` Registered: ${known.join(", ")}` : "";
55
+ const definition = getProviderDefinition(providerId);
56
+ if (definition.callMode !== "native-twilio") {
101
57
  throw new Error(
102
- `No native Twilio voice spec registered for "${providerId}".${knownList}`,
58
+ `No native Twilio voice spec for "${providerId}" — its call mode is ` +
59
+ `"${definition.callMode}", not "native-twilio".`,
103
60
  );
104
61
  }
105
- return spec;
62
+ return definition.nativeTwilioVoiceSpec;
106
63
  }
107
64
 
108
65
  // ---------------------------------------------------------------------------
@@ -145,16 +102,3 @@ export function resolveCallStrategy(config: AssistantConfig): TtsCallStrategy {
145
102
  };
146
103
  }
147
104
  }
148
-
149
- // ---------------------------------------------------------------------------
150
- // Test helpers
151
- // ---------------------------------------------------------------------------
152
-
153
- /**
154
- * Clear all registered native Twilio voice spec builders.
155
- *
156
- * **Test-only** -- must not be called in production code.
157
- */
158
- export function _resetNativeTwilioVoiceSpecRegistry(): void {
159
- nativeVoiceSpecRegistry.clear();
160
- }