@framers/agentos 0.1.110 → 0.1.111

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 (90) hide show
  1. package/dist/api/agency.d.ts.map +1 -1
  2. package/dist/api/agency.js +38 -2
  3. package/dist/api/agency.js.map +1 -1
  4. package/dist/api/agent.js +1 -1
  5. package/dist/api/agent.js.map +1 -1
  6. package/dist/api/strategies/debate.d.ts.map +1 -1
  7. package/dist/api/strategies/debate.js.map +1 -1
  8. package/dist/api/strategies/graph.d.ts.map +1 -1
  9. package/dist/api/strategies/graph.js +1 -2
  10. package/dist/api/strategies/graph.js.map +1 -1
  11. package/dist/api/strategies/hierarchical.d.ts.map +1 -1
  12. package/dist/api/strategies/hierarchical.js +1 -2
  13. package/dist/api/strategies/hierarchical.js.map +1 -1
  14. package/dist/api/strategies/index.d.ts +1 -9
  15. package/dist/api/strategies/index.d.ts.map +1 -1
  16. package/dist/api/strategies/index.js +1 -11
  17. package/dist/api/strategies/index.js.map +1 -1
  18. package/dist/api/strategies/parallel.d.ts.map +1 -1
  19. package/dist/api/strategies/parallel.js +23 -4
  20. package/dist/api/strategies/parallel.js.map +1 -1
  21. package/dist/api/strategies/review-loop.d.ts.map +1 -1
  22. package/dist/api/strategies/review-loop.js.map +1 -1
  23. package/dist/api/strategies/sequential.d.ts.map +1 -1
  24. package/dist/api/strategies/sequential.js +1 -2
  25. package/dist/api/strategies/sequential.js.map +1 -1
  26. package/dist/api/strategies/shared.d.ts +8 -0
  27. package/dist/api/strategies/shared.d.ts.map +1 -1
  28. package/dist/api/strategies/shared.js +10 -1
  29. package/dist/api/strategies/shared.js.map +1 -1
  30. package/dist/api/types.d.ts +6 -0
  31. package/dist/api/types.d.ts.map +1 -1
  32. package/dist/api/types.js.map +1 -1
  33. package/dist/memory/AgentMemory.d.ts +2 -1
  34. package/dist/memory/AgentMemory.d.ts.map +1 -1
  35. package/dist/memory/AgentMemory.js +1 -1
  36. package/dist/memory/AgentMemory.js.map +1 -1
  37. package/dist/memory/CognitiveMemoryManager.d.ts.map +1 -1
  38. package/dist/memory/CognitiveMemoryManager.js +7 -2
  39. package/dist/memory/CognitiveMemoryManager.js.map +1 -1
  40. package/dist/memory/facade/Memory.d.ts.map +1 -1
  41. package/dist/memory/facade/Memory.js +6 -9
  42. package/dist/memory/facade/Memory.js.map +1 -1
  43. package/dist/memory/store/MemoryStore.d.ts +9 -0
  44. package/dist/memory/store/MemoryStore.d.ts.map +1 -1
  45. package/dist/memory/store/MemoryStore.js +66 -6
  46. package/dist/memory/store/MemoryStore.js.map +1 -1
  47. package/dist/memory/store/SqliteMemoryGraph.d.ts.map +1 -1
  48. package/dist/memory/store/SqliteMemoryGraph.js +27 -13
  49. package/dist/memory/store/SqliteMemoryGraph.js.map +1 -1
  50. package/dist/speech/FallbackProxy.d.ts +194 -41
  51. package/dist/speech/FallbackProxy.d.ts.map +1 -1
  52. package/dist/speech/FallbackProxy.js +155 -32
  53. package/dist/speech/FallbackProxy.js.map +1 -1
  54. package/dist/speech/SpeechProviderResolver.d.ts +278 -36
  55. package/dist/speech/SpeechProviderResolver.d.ts.map +1 -1
  56. package/dist/speech/SpeechProviderResolver.js +306 -40
  57. package/dist/speech/SpeechProviderResolver.js.map +1 -1
  58. package/dist/speech/providers/AssemblyAISTTProvider.d.ts +119 -19
  59. package/dist/speech/providers/AssemblyAISTTProvider.d.ts.map +1 -1
  60. package/dist/speech/providers/AssemblyAISTTProvider.js +153 -25
  61. package/dist/speech/providers/AssemblyAISTTProvider.js.map +1 -1
  62. package/dist/speech/providers/AzureSpeechSTTProvider.d.ts +121 -17
  63. package/dist/speech/providers/AzureSpeechSTTProvider.d.ts.map +1 -1
  64. package/dist/speech/providers/AzureSpeechSTTProvider.js +122 -14
  65. package/dist/speech/providers/AzureSpeechSTTProvider.js.map +1 -1
  66. package/dist/speech/providers/AzureSpeechTTSProvider.d.ts +130 -15
  67. package/dist/speech/providers/AzureSpeechTTSProvider.d.ts.map +1 -1
  68. package/dist/speech/providers/AzureSpeechTTSProvider.js +163 -18
  69. package/dist/speech/providers/AzureSpeechTTSProvider.js.map +1 -1
  70. package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts +159 -0
  71. package/dist/speech/providers/BuiltInAdaptiveVadProvider.d.ts.map +1 -1
  72. package/dist/speech/providers/BuiltInAdaptiveVadProvider.js +119 -0
  73. package/dist/speech/providers/BuiltInAdaptiveVadProvider.js.map +1 -1
  74. package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts +102 -16
  75. package/dist/speech/providers/DeepgramBatchSTTProvider.d.ts.map +1 -1
  76. package/dist/speech/providers/DeepgramBatchSTTProvider.js +108 -13
  77. package/dist/speech/providers/DeepgramBatchSTTProvider.js.map +1 -1
  78. package/dist/speech/providers/ElevenLabsTextToSpeechProvider.d.ts +149 -0
  79. package/dist/speech/providers/ElevenLabsTextToSpeechProvider.d.ts.map +1 -1
  80. package/dist/speech/providers/ElevenLabsTextToSpeechProvider.js +137 -2
  81. package/dist/speech/providers/ElevenLabsTextToSpeechProvider.js.map +1 -1
  82. package/dist/speech/providers/OpenAITextToSpeechProvider.d.ts +125 -0
  83. package/dist/speech/providers/OpenAITextToSpeechProvider.d.ts.map +1 -1
  84. package/dist/speech/providers/OpenAITextToSpeechProvider.js +128 -4
  85. package/dist/speech/providers/OpenAITextToSpeechProvider.js.map +1 -1
  86. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts +110 -0
  87. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.d.ts.map +1 -1
  88. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js +115 -0
  89. package/dist/speech/providers/OpenAIWhisperSpeechToTextProvider.js.map +1 -1
  90. package/package.json +1 -1
@@ -4,37 +4,129 @@ import { findSpeechProviderCatalogEntry } from './providerCatalog.js';
4
4
  /**
5
5
  * Central resolver for speech providers (STT, TTS, VAD, wake-word).
6
6
  *
7
- * Providers are registered with a kind, priority, and catalog metadata.
8
- * Resolution filters by `isConfigured`, applies {@link ProviderRequirements},
9
- * and optionally wraps multiple candidates in a {@link FallbackSTTProxy} or
10
- * {@link FallbackTTSProxy} when fallback mode is enabled in the config.
7
+ * ## Resolution Algorithm
11
8
  *
12
- * Emits:
13
- * - `provider_registered` when a new provider is registered via {@link register}.
9
+ * 1. **Registration** — Providers are registered via {@link register} with a
10
+ * unique `id`, a `kind` (stt/tts/vad/wake-word), a numeric `priority`,
11
+ * and a boolean `isConfigured` flag.
12
+ *
13
+ * 2. **Filtering** — When a consumer calls {@link resolveSTT}, {@link resolveTTS},
14
+ * {@link resolveVAD}, or {@link resolveWakeWord}, the resolver filters
15
+ * registrations by `kind` and `isConfigured === true`.
16
+ *
17
+ * 3. **Requirements matching** — Optional {@link ProviderRequirements} further
18
+ * filter by `streaming`, `local`, and `features` capabilities from the
19
+ * provider's catalog entry.
20
+ *
21
+ * 4. **Priority ordering** — Remaining candidates are sorted by ascending
22
+ * `priority` (lower number = tried first). Core providers default to 100,
23
+ * extensions to 200, and user-preferred providers get boosted to 50+.
24
+ *
25
+ * 5. **Fallback wrapping** — When `config.stt.fallback` or `config.tts.fallback`
26
+ * is `true` and multiple candidates survive, they are wrapped in a
27
+ * {@link FallbackSTTProxy} or {@link FallbackTTSProxy} that tries each in
28
+ * order, emitting `provider_fallback` events on failure.
29
+ *
30
+ * ## Priority Tiers
31
+ *
32
+ * | Tier | Priority Range | Source |
33
+ * |------|---------------|--------|
34
+ * | User-preferred | 50–59 | `config.stt.preferred` / `config.tts.preferred` |
35
+ * | Core | 100 | Built-in provider catalog |
36
+ * | Extension | 200 | Discovered via ExtensionManager |
37
+ *
38
+ * ## Events
39
+ *
40
+ * | Event | Payload | When |
41
+ * |-------|---------|------|
42
+ * | `provider_registered` | `{ id, kind, source }` | A provider is registered via {@link register} |
43
+ *
44
+ * @see {@link FallbackSTTProxy} for the STT fallback chain implementation
45
+ * @see {@link FallbackTTSProxy} for the TTS fallback chain implementation
46
+ * @see {@link ProviderRequirements} for available filtering criteria
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * const resolver = new SpeechProviderResolver(
51
+ * { stt: { preferred: ['deepgram-batch'], fallback: true } },
52
+ * process.env,
53
+ * );
54
+ * await resolver.refresh();
55
+ * const stt = resolver.resolveSTT({ features: ['diarization'] });
56
+ * ```
14
57
  */
15
58
  export class SpeechProviderResolver extends EventEmitter {
16
59
  /**
17
- * @param config Optional resolver configuration (preferred providers, fallback mode).
18
- * @param env Environment variable map used to check provider availability.
60
+ * Creates a new SpeechProviderResolver.
61
+ *
62
+ * @param config - Optional resolver configuration controlling preferred
63
+ * providers and fallback behaviour for each provider kind.
64
+ * @param env - Environment variable map used to check whether a provider's
65
+ * required API keys are present. Defaults to `process.env` so unit tests
66
+ * can inject a controlled map without polluting the real environment.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * // Production: use real env vars
71
+ * const resolver = new SpeechProviderResolver({ stt: { fallback: true } });
72
+ *
73
+ * // Testing: inject controlled env
74
+ * const resolver = new SpeechProviderResolver(undefined, { OPENAI_API_KEY: 'test' });
75
+ * ```
19
76
  */
20
77
  constructor(config, env = process.env) {
21
78
  super();
22
79
  this.config = config;
23
80
  this.env = env;
24
- /** All registered providers keyed by id. */
81
+ /**
82
+ * Internal registry of all providers keyed by their unique string id.
83
+ * Overwrites are allowed — re-registering with the same id replaces the
84
+ * previous entry, which lets hot-reload and extension refresh work seamlessly.
85
+ */
25
86
  this.registrations = new Map();
26
87
  }
27
88
  /**
28
- * Register a provider. Overwrites any existing registration with the same id.
29
- * Emits a `provider_registered` event with `{ id, kind, source }`.
89
+ * Register a provider, overwriting any existing registration with the same id.
90
+ *
91
+ * Emits a `provider_registered` event with `{ id, kind, source }` so that
92
+ * listeners (e.g. UI dashboards, logging middleware) can track what's available.
93
+ *
94
+ * @param reg - The full registration object including the provider instance,
95
+ * catalog entry, priority, and configuration status.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * resolver.register({
100
+ * id: 'custom-stt',
101
+ * kind: 'stt',
102
+ * provider: myCustomProvider,
103
+ * catalogEntry: { id: 'custom-stt', kind: 'stt', label: 'Custom', envVars: [], local: false, description: '' },
104
+ * isConfigured: true,
105
+ * priority: 150,
106
+ * source: 'extension',
107
+ * });
108
+ * ```
30
109
  */
31
110
  register(reg) {
32
111
  this.registrations.set(reg.id, reg);
33
112
  this.emit('provider_registered', { id: reg.id, kind: reg.kind, source: reg.source });
34
113
  }
35
114
  /**
36
- * List all registrations for a given kind, sorted ascending by priority
37
- * (lower number = higher priority).
115
+ * List all registrations for a given provider kind, sorted ascending by
116
+ * priority (lower number = higher priority = tried first).
117
+ *
118
+ * This returns both configured and unconfigured providers — use
119
+ * `.filter(r => r.isConfigured)` if you only want usable ones.
120
+ *
121
+ * @param kind - The provider kind to filter by.
122
+ * @returns A new array of registrations sorted by ascending priority.
123
+ *
124
+ * @example
125
+ * ```ts
126
+ * const allSTT = resolver.listProviders('stt');
127
+ * const configured = allSTT.filter(r => r.isConfigured);
128
+ * console.log(`${configured.length} of ${allSTT.length} STT providers ready`);
129
+ * ```
38
130
  */
39
131
  listProviders(kind) {
40
132
  return [...this.registrations.values()]
@@ -44,16 +136,37 @@ export class SpeechProviderResolver extends EventEmitter {
44
136
  /**
45
137
  * Resolve the best STT provider matching optional {@link ProviderRequirements}.
46
138
  *
47
- * When `config.stt.fallback` is true and multiple candidates exist, wraps them
48
- * in a {@link FallbackSTTProxy}. Otherwise returns the single best match.
139
+ * When `config.stt.fallback` is `true` and multiple candidates exist, wraps
140
+ * them in a {@link FallbackSTTProxy} that tries providers in priority order.
141
+ * Otherwise returns the single highest-priority match.
49
142
  *
50
- * @throws When no configured STT provider matches requirements.
143
+ * @param requirements - Optional filtering criteria (streaming, local, features,
144
+ * preferredIds).
145
+ * @returns The resolved STT provider, possibly wrapped in a FallbackSTTProxy.
146
+ * @throws {Error} When no configured STT provider matches the requirements.
147
+ *
148
+ * @see {@link FallbackSTTProxy} for fallback chain behaviour
149
+ * @see {@link ProviderRequirements} for available filter options
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * // Simple: best available
154
+ * const stt = resolver.resolveSTT();
155
+ *
156
+ * // With requirements
157
+ * const stt = resolver.resolveSTT({ streaming: true, features: ['diarization'] });
158
+ *
159
+ * // With explicit preference ordering
160
+ * const stt = resolver.resolveSTT({ preferredIds: ['deepgram-batch', 'openai-whisper'] });
161
+ * ```
51
162
  */
52
163
  resolveSTT(requirements) {
53
164
  const candidates = this.resolveByKind('stt', requirements);
54
165
  if (candidates.length === 0) {
55
166
  throw new Error('No configured STT provider matches requirements');
56
167
  }
168
+ // Wrap in a fallback proxy when the user has opted into fallback mode
169
+ // and there are multiple viable providers to chain together.
57
170
  if (this.config?.stt?.fallback && candidates.length > 1) {
58
171
  return new FallbackSTTProxy(candidates.map((r) => r.provider), this);
59
172
  }
@@ -62,16 +175,30 @@ export class SpeechProviderResolver extends EventEmitter {
62
175
  /**
63
176
  * Resolve the best TTS provider matching optional {@link ProviderRequirements}.
64
177
  *
65
- * When `config.tts.fallback` is true and multiple candidates exist, wraps them
66
- * in a {@link FallbackTTSProxy}. Otherwise returns the single best match.
178
+ * When `config.tts.fallback` is `true` and multiple candidates exist, wraps
179
+ * them in a {@link FallbackTTSProxy} that tries providers in priority order.
180
+ * Otherwise returns the single highest-priority match.
181
+ *
182
+ * @param requirements - Optional filtering criteria (streaming, local, features,
183
+ * preferredIds).
184
+ * @returns The resolved TTS provider, possibly wrapped in a FallbackTTSProxy.
185
+ * @throws {Error} When no configured TTS provider matches the requirements.
186
+ *
187
+ * @see {@link FallbackTTSProxy} for fallback chain behaviour
188
+ * @see {@link ProviderRequirements} for available filter options
67
189
  *
68
- * @throws When no configured TTS provider matches requirements.
190
+ * @example
191
+ * ```ts
192
+ * const tts = resolver.resolveTTS();
193
+ * const result = await tts.synthesize('Hello!');
194
+ * ```
69
195
  */
70
196
  resolveTTS(requirements) {
71
197
  const candidates = this.resolveByKind('tts', requirements);
72
198
  if (candidates.length === 0) {
73
199
  throw new Error('No configured TTS provider matches requirements');
74
200
  }
201
+ // Same fallback wrapping logic as STT — see resolveSTT for commentary.
75
202
  if (this.config?.tts?.fallback && candidates.length > 1) {
76
203
  return new FallbackTTSProxy(candidates.map((r) => r.provider), this);
77
204
  }
@@ -80,7 +207,18 @@ export class SpeechProviderResolver extends EventEmitter {
80
207
  /**
81
208
  * Resolve the highest-priority configured VAD provider.
82
209
  *
83
- * @throws When no VAD provider is registered and configured.
210
+ * VAD providers don't support fallback chains because voice activity detection
211
+ * is a real-time frame-by-frame operation where mid-session provider switching
212
+ * would cause state inconsistency.
213
+ *
214
+ * @returns The resolved VAD provider instance.
215
+ * @throws {Error} When no VAD provider is registered and configured.
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const vad = resolver.resolveVAD();
220
+ * const decision = vad.processFrame(audioFrame);
221
+ * ```
84
222
  */
85
223
  resolveVAD() {
86
224
  const vads = this.listProviders('vad').filter((r) => r.isConfigured);
@@ -92,6 +230,19 @@ export class SpeechProviderResolver extends EventEmitter {
92
230
  /**
93
231
  * Resolve the highest-priority configured wake-word provider, or `null`
94
232
  * when none is registered.
233
+ *
234
+ * Returns `null` instead of throwing because wake-word detection is an
235
+ * optional feature — many deployments operate without it.
236
+ *
237
+ * @returns The resolved wake-word provider, or `null` if none is available.
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * const wakeWord = resolver.resolveWakeWord();
242
+ * if (wakeWord) {
243
+ * const detection = await wakeWord.detect(frame, sampleRate);
244
+ * }
245
+ * ```
95
246
  */
96
247
  resolveWakeWord() {
97
248
  const wakeWords = this.listProviders('wake-word').filter((r) => r.isConfigured);
@@ -101,11 +252,28 @@ export class SpeechProviderResolver extends EventEmitter {
101
252
  // Bulk registration helpers
102
253
  // ---------------------------------------------------------------------------
103
254
  /**
104
- * Register core providers from the static catalog and optionally discover
105
- * extension providers from an ExtensionManager-like object. Also applies
106
- * user-configured preferred priorities afterwards.
255
+ * Populate the resolver by registering core providers from the static catalog,
256
+ * optionally discovering extension providers, and applying user-configured
257
+ * preferred priorities.
258
+ *
259
+ * The three-phase refresh sequence is:
260
+ * 1. {@link registerCoreProviders} — register all built-in providers from the
261
+ * static catalog, marking each as configured/unconfigured based on env vars.
262
+ * 2. {@link discoverExtensionProviders} — if an ExtensionManager is provided,
263
+ * discover and register any additional speech providers from extensions.
264
+ * 3. {@link applyPreferredPriorities} — boost priority for providers listed in
265
+ * the user's `config.stt.preferred` / `config.tts.preferred` arrays.
107
266
  *
108
- * @param extensionManager Optional object exposing `getDescriptorsByKind(kind)`.
267
+ * @param extensionManager - Optional object exposing `getDescriptorsByKind(kind)`.
268
+ * Uses `any` type because the ExtensionManager interface is defined in the
269
+ * extensions package and importing it here would create a circular dependency.
270
+ *
271
+ * @example
272
+ * ```ts
273
+ * const resolver = new SpeechProviderResolver(config, process.env);
274
+ * await resolver.refresh(extensionManager);
275
+ * // Now all providers are registered and ready to resolve.
276
+ * ```
109
277
  */
110
278
  async refresh(extensionManager) {
111
279
  this.registerCoreProviders();
@@ -120,11 +288,31 @@ export class SpeechProviderResolver extends EventEmitter {
120
288
  /**
121
289
  * Core resolution algorithm shared by {@link resolveSTT} and {@link resolveTTS}.
122
290
  *
123
- * When `requirements.preferredIds` is provided, returns matches in that order.
124
- * Otherwise returns all configured providers matching requirements, sorted by
125
- * priority (ascending).
291
+ * ## Algorithm
292
+ *
293
+ * **Path A — Preferred IDs provided:**
294
+ * When `requirements.preferredIds` is set, iterate through the IDs in the
295
+ * caller's specified order. For each ID, look up the registration and include
296
+ * it only if it matches the kind, is configured, and satisfies all other
297
+ * requirements. This preserves the caller's explicit ordering preference.
298
+ *
299
+ * **Path B — No preferred IDs:**
300
+ * Return all configured providers of the requested kind that match the
301
+ * requirements, sorted by ascending priority (lower = better). This is the
302
+ * default path for most callers.
303
+ *
304
+ * @param kind - The provider kind to resolve ('stt', 'tts', etc.).
305
+ * @param requirements - Optional filtering criteria.
306
+ * @returns An ordered array of matching registrations (best first).
307
+ *
308
+ * @example
309
+ * ```ts
310
+ * // Internal usage — called by resolveSTT/resolveTTS:
311
+ * const candidates = this.resolveByKind('stt', { streaming: true });
312
+ * ```
126
313
  */
127
314
  resolveByKind(kind, requirements) {
315
+ // Path A: explicit preferred ordering from the caller
128
316
  if (requirements?.preferredIds?.length) {
129
317
  const results = [];
130
318
  for (const id of requirements.preferredIds) {
@@ -135,21 +323,42 @@ export class SpeechProviderResolver extends EventEmitter {
135
323
  }
136
324
  return results;
137
325
  }
326
+ // Path B: all matching providers sorted by priority
138
327
  return this.listProviders(kind)
139
328
  .filter((r) => r.isConfigured)
140
329
  .filter((r) => this.matchesRequirements(r, requirements));
141
330
  }
142
331
  /**
143
- * Check whether a registration satisfies the given requirements
144
- * (streaming, local, features).
332
+ * Check whether a registration satisfies the given requirements.
333
+ *
334
+ * Each requirement field is independently checked. A `undefined` requirement
335
+ * field means "no constraint" — only explicitly set fields are enforced.
336
+ * All specified fields must match for the provider to qualify.
337
+ *
338
+ * @param reg - The provider registration to test.
339
+ * @param req - The requirements to match against. If `undefined`, all
340
+ * providers match.
341
+ * @returns `true` if the registration satisfies all specified requirements.
342
+ *
343
+ * @example
344
+ * ```ts
345
+ * // Matches: streaming=true required, provider has streaming=true
346
+ * this.matchesRequirements(reg, { streaming: true }); // true
347
+ *
348
+ * // Fails: feature 'diarization' required but provider only has ['cloud']
349
+ * this.matchesRequirements(reg, { features: ['diarization'] }); // false
350
+ * ```
145
351
  */
146
352
  matchesRequirements(reg, req) {
147
353
  if (!req)
148
354
  return true;
355
+ // Check streaming capability match
149
356
  if (req.streaming !== undefined && reg.catalogEntry.streaming !== req.streaming)
150
357
  return false;
358
+ // Check local/cloud deployment match
151
359
  if (req.local !== undefined && reg.catalogEntry.local !== req.local)
152
360
  return false;
361
+ // Check that the provider supports ALL requested features (AND semantics)
153
362
  if (req.features?.length) {
154
363
  const providerFeatures = reg.catalogEntry.features ?? [];
155
364
  if (!req.features.every((f) => providerFeatures.includes(f)))
@@ -158,11 +367,30 @@ export class SpeechProviderResolver extends EventEmitter {
158
367
  return true;
159
368
  }
160
369
  /**
161
- * Register providers from the static core list. Each provider is marked
162
- * `isConfigured` based on whether the required environment variables are set.
163
- * Providers with `available === false` in the catalog are skipped.
370
+ * Register providers from the static core catalog.
371
+ *
372
+ * Each provider is marked `isConfigured` based on whether ALL of its required
373
+ * environment variables are set (non-empty). Providers with `available === false`
374
+ * in the catalog are skipped entirely — they represent planned but not yet
375
+ * implemented backends (e.g. NVIDIA NeMo, Bark).
376
+ *
377
+ * Core providers are registered with `priority: 100` and `source: 'core'`.
378
+ * The `provider` field is set to `null` (lazy instantiation) — actual provider
379
+ * instances are created on first use by the SpeechRuntime.
380
+ *
381
+ * @example
382
+ * ```ts
383
+ * // Called internally by refresh():
384
+ * this.registerCoreProviders();
385
+ * ```
164
386
  */
165
387
  registerCoreProviders() {
388
+ /**
389
+ * Static list of core provider definitions. Each entry maps a provider id
390
+ * to its kind and the environment variables required for configuration.
391
+ * Order here does not determine resolution order — that is controlled by
392
+ * the priority system.
393
+ */
166
394
  const coreProviders = [
167
395
  { id: 'openai-whisper', kind: 'stt', envVars: ['OPENAI_API_KEY'] },
168
396
  { id: 'deepgram-batch', kind: 'stt', envVars: ['DEEPGRAM_API_KEY'] },
@@ -175,15 +403,19 @@ export class SpeechProviderResolver extends EventEmitter {
175
403
  ];
176
404
  for (const def of coreProviders) {
177
405
  const catalogEntry = findSpeechProviderCatalogEntry(def.id);
406
+ // Skip providers not found in the catalog (should not happen, but defensive)
178
407
  if (!catalogEntry)
179
408
  continue;
409
+ // Skip providers explicitly marked as unavailable (planned but unimplemented)
180
410
  if (catalogEntry.available === false)
181
411
  continue;
412
+ // A provider is configured when it has no required env vars (e.g. local VAD)
413
+ // or when ALL required env vars are present and non-empty.
182
414
  const isConfigured = def.envVars.length === 0 || def.envVars.every((v) => Boolean(this.env[v]));
183
415
  this.register({
184
416
  id: def.id,
185
417
  kind: def.kind,
186
- provider: null, // Lazy — actual provider instance created on first use.
418
+ provider: null, // Lazy — actual provider instance created on first use by SpeechRuntime.
187
419
  catalogEntry,
188
420
  isConfigured,
189
421
  priority: 100,
@@ -193,11 +425,31 @@ export class SpeechProviderResolver extends EventEmitter {
193
425
  }
194
426
  /**
195
427
  * Discover speech providers exposed by an ExtensionManager via
196
- * `getDescriptorsByKind()`. Extension providers default to priority 200
197
- * (lower than core's 100) unless the user overrides via preferred config.
428
+ * `getDescriptorsByKind()`.
429
+ *
430
+ * Extension providers are registered with `priority: 200` (lower than core's
431
+ * 100) so they serve as fallbacks unless the user explicitly boosts them via
432
+ * `config.stt.preferred` / `config.tts.preferred`.
433
+ *
434
+ * The `extensionManager` parameter uses `any` because the ExtensionManager
435
+ * type lives in the extensions package — importing it would create a circular
436
+ * dependency. We only rely on the `getDescriptorsByKind` method signature.
437
+ *
438
+ * @param extensionManager - Object exposing `getDescriptorsByKind(kind)` that
439
+ * returns an array of `{ id: string; payload: unknown }` descriptors.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * // Called internally by refresh():
444
+ * this.discoverExtensionProviders(extensionManager);
445
+ * ```
198
446
  */
199
447
  discoverExtensionProviders(extensionManager) {
200
- /** Maps extension descriptor kinds to {@link SpeechProviderKind}. */
448
+ /**
449
+ * Maps extension descriptor kind strings to the normalized
450
+ * {@link SpeechProviderKind} used internally. Extensions use hyphenated
451
+ * kind names with a `-provider` suffix.
452
+ */
201
453
  const kindMap = {
202
454
  'stt-provider': 'stt',
203
455
  'tts-provider': 'tts',
@@ -207,11 +459,13 @@ export class SpeechProviderResolver extends EventEmitter {
207
459
  for (const descriptorKind of Object.keys(kindMap)) {
208
460
  const descriptors = extensionManager.getDescriptorsByKind?.(descriptorKind) ?? [];
209
461
  for (const desc of descriptors) {
462
+ // Try to find a catalog entry for known extensions; fall back to a
463
+ // synthetic entry for unknown/third-party extensions.
210
464
  const catalogEntry = findSpeechProviderCatalogEntry(desc.id);
211
465
  const isConfigured = catalogEntry
212
466
  ? catalogEntry.envVars.length === 0 ||
213
467
  catalogEntry.envVars.every((v) => Boolean(this.env[v]))
214
- : true;
468
+ : true; // Unknown extensions are assumed configured since we can't check
215
469
  this.register({
216
470
  id: desc.id,
217
471
  kind: kindMap[descriptorKind] ?? 'stt',
@@ -225,7 +479,7 @@ export class SpeechProviderResolver extends EventEmitter {
225
479
  description: '',
226
480
  },
227
481
  isConfigured,
228
- priority: 200,
482
+ priority: 200, // Extensions rank below core by default
229
483
  source: 'extension',
230
484
  });
231
485
  }
@@ -233,8 +487,20 @@ export class SpeechProviderResolver extends EventEmitter {
233
487
  }
234
488
  /**
235
489
  * Boost priority for providers listed in `config.stt.preferred` /
236
- * `config.tts.preferred`. Earlier entries get lower (= higher priority)
237
- * numbers starting at 50.
490
+ * `config.tts.preferred`.
491
+ *
492
+ * Earlier entries in the preferred array get lower priority numbers
493
+ * (= higher priority). The sequence starts at 50, so the first preferred
494
+ * provider gets priority 50, second gets 51, etc. This places them above
495
+ * all core (100) and extension (200) providers but still allows the
496
+ * priority to be numerically distinguished.
497
+ *
498
+ * @example
499
+ * ```ts
500
+ * // config.stt.preferred = ['assemblyai', 'openai-whisper']
501
+ * // Result: assemblyai.priority = 50, openai-whisper.priority = 51
502
+ * this.applyPreferredPriorities();
503
+ * ```
238
504
  */
239
505
  applyPreferredPriorities() {
240
506
  if (this.config?.stt?.preferred) {
@@ -1 +1 @@
1
- {"version":3,"file":"SpeechProviderResolver.js","sourceRoot":"","sources":["../../src/speech/SpeechProviderResolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAWtC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;GAUG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IAItD;;;OAGG;IACH,YACmB,MAA6B,EAC7B,MAA0C,OAAO,CAAC,GAAG;QA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