@pellux/goodvibes-sdk 0.25.7 → 0.25.10

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 (130) hide show
  1. package/README.md +4 -0
  2. package/dist/_internal/contracts/artifacts/operator-contract.json +100 -4
  3. package/dist/_internal/contracts/generated/foundation-metadata.d.ts +2 -2
  4. package/dist/_internal/contracts/generated/foundation-metadata.js +2 -2
  5. package/dist/_internal/contracts/generated/operator-contract.d.ts.map +1 -1
  6. package/dist/_internal/contracts/generated/operator-contract.js +100 -4
  7. package/dist/_internal/contracts/generated/operator-method-ids.d.ts +1 -1
  8. package/dist/_internal/contracts/generated/operator-method-ids.d.ts.map +1 -1
  9. package/dist/_internal/contracts/generated/operator-method-ids.js +1 -0
  10. package/dist/_internal/daemon/context.d.ts +1 -0
  11. package/dist/_internal/daemon/context.d.ts.map +1 -1
  12. package/dist/_internal/daemon/media-route-types.d.ts +10 -0
  13. package/dist/_internal/daemon/media-route-types.d.ts.map +1 -1
  14. package/dist/_internal/daemon/media-routes.d.ts +1 -1
  15. package/dist/_internal/daemon/media-routes.d.ts.map +1 -1
  16. package/dist/_internal/daemon/media-routes.js +91 -10
  17. package/dist/_internal/daemon/operator.d.ts +1 -1
  18. package/dist/_internal/daemon/operator.d.ts.map +1 -1
  19. package/dist/_internal/daemon/operator.js +2 -0
  20. package/dist/_internal/platform/adapters/ntfy/index.js +13 -2
  21. package/dist/_internal/platform/adapters/types.d.ts +2 -0
  22. package/dist/_internal/platform/adapters/types.d.ts.map +1 -1
  23. package/dist/_internal/platform/batch/index.d.ts +4 -0
  24. package/dist/_internal/platform/batch/index.d.ts.map +1 -0
  25. package/dist/_internal/platform/batch/index.js +2 -0
  26. package/dist/_internal/platform/batch/manager.d.ts +41 -0
  27. package/dist/_internal/platform/batch/manager.d.ts.map +1 -0
  28. package/dist/_internal/platform/batch/manager.js +404 -0
  29. package/dist/_internal/platform/batch/types.d.ts +89 -0
  30. package/dist/_internal/platform/batch/types.d.ts.map +1 -0
  31. package/dist/_internal/platform/batch/types.js +10 -0
  32. package/dist/_internal/platform/channels/builtin/plugins.d.ts.map +1 -1
  33. package/dist/_internal/platform/channels/builtin/plugins.js +1 -0
  34. package/dist/_internal/platform/channels/reply-pipeline.d.ts +9 -1
  35. package/dist/_internal/platform/channels/reply-pipeline.d.ts.map +1 -1
  36. package/dist/_internal/platform/channels/reply-pipeline.js +156 -6
  37. package/dist/_internal/platform/cloudflare/client.d.ts +3 -0
  38. package/dist/_internal/platform/cloudflare/client.d.ts.map +1 -0
  39. package/dist/_internal/platform/cloudflare/client.js +9 -0
  40. package/dist/_internal/platform/cloudflare/config.d.ts +8 -0
  41. package/dist/_internal/platform/cloudflare/config.d.ts.map +1 -0
  42. package/dist/_internal/platform/cloudflare/config.js +48 -0
  43. package/dist/_internal/platform/cloudflare/constants.d.ts +18 -0
  44. package/dist/_internal/platform/cloudflare/constants.d.ts.map +1 -0
  45. package/dist/_internal/platform/cloudflare/constants.js +36 -0
  46. package/dist/_internal/platform/cloudflare/discovery.d.ts +23 -0
  47. package/dist/_internal/platform/cloudflare/discovery.d.ts.map +1 -0
  48. package/dist/_internal/platform/cloudflare/discovery.js +57 -0
  49. package/dist/_internal/platform/cloudflare/index.d.ts +6 -0
  50. package/dist/_internal/platform/cloudflare/index.d.ts.map +1 -0
  51. package/dist/_internal/platform/cloudflare/index.js +4 -0
  52. package/dist/_internal/platform/cloudflare/manager.d.ts +30 -0
  53. package/dist/_internal/platform/cloudflare/manager.d.ts.map +1 -0
  54. package/dist/_internal/platform/cloudflare/manager.js +671 -0
  55. package/dist/_internal/platform/cloudflare/resources.d.ts +79 -0
  56. package/dist/_internal/platform/cloudflare/resources.d.ts.map +1 -0
  57. package/dist/_internal/platform/cloudflare/resources.js +353 -0
  58. package/dist/_internal/platform/cloudflare/types.d.ts +689 -0
  59. package/dist/_internal/platform/cloudflare/types.d.ts.map +1 -0
  60. package/dist/_internal/platform/cloudflare/types.js +10 -0
  61. package/dist/_internal/platform/cloudflare/utils.d.ts +14 -0
  62. package/dist/_internal/platform/cloudflare/utils.d.ts.map +1 -0
  63. package/dist/_internal/platform/cloudflare/utils.js +222 -0
  64. package/dist/_internal/platform/cloudflare/worker-source.d.ts +2 -0
  65. package/dist/_internal/platform/cloudflare/worker-source.d.ts.map +1 -0
  66. package/dist/_internal/platform/cloudflare/worker-source.js +165 -0
  67. package/dist/_internal/platform/config/schema-domain-core.d.ts +6 -0
  68. package/dist/_internal/platform/config/schema-domain-core.d.ts.map +1 -1
  69. package/dist/_internal/platform/config/schema-domain-core.js +30 -0
  70. package/dist/_internal/platform/config/schema-domain-runtime.d.ts +43 -0
  71. package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
  72. package/dist/_internal/platform/config/schema-domain-runtime.js +287 -0
  73. package/dist/_internal/platform/config/schema-types.d.ts +57 -2
  74. package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
  75. package/dist/_internal/platform/config/schema.d.ts.map +1 -1
  76. package/dist/_internal/platform/config/schema.js +3 -0
  77. package/dist/_internal/platform/control-plane/method-catalog-media.d.ts.map +1 -1
  78. package/dist/_internal/platform/control-plane/method-catalog-media.js +17 -0
  79. package/dist/_internal/platform/control-plane/routes/operator.d.ts +1 -1
  80. package/dist/_internal/platform/control-plane/routes/operator.d.ts.map +1 -1
  81. package/dist/_internal/platform/control-plane/routes/operator.js +2 -0
  82. package/dist/_internal/platform/daemon/facade-composition.d.ts +2 -0
  83. package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
  84. package/dist/_internal/platform/daemon/facade-composition.js +10 -0
  85. package/dist/_internal/platform/daemon/http/batch-routes.d.ts +8 -0
  86. package/dist/_internal/platform/daemon/http/batch-routes.d.ts.map +1 -0
  87. package/dist/_internal/platform/daemon/http/batch-routes.js +113 -0
  88. package/dist/_internal/platform/daemon/http/cloudflare-routes.d.ts +7 -0
  89. package/dist/_internal/platform/daemon/http/cloudflare-routes.d.ts.map +1 -0
  90. package/dist/_internal/platform/daemon/http/cloudflare-routes.js +201 -0
  91. package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
  92. package/dist/_internal/platform/daemon/http/router-route-contexts.js +1 -0
  93. package/dist/_internal/platform/daemon/http/router.d.ts +5 -1
  94. package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
  95. package/dist/_internal/platform/daemon/http/router.js +30 -0
  96. package/dist/_internal/platform/daemon/http/runtime-route-types.d.ts +2 -0
  97. package/dist/_internal/platform/daemon/http/runtime-route-types.d.ts.map +1 -1
  98. package/dist/_internal/platform/daemon/surface-actions.d.ts +6 -0
  99. package/dist/_internal/platform/daemon/surface-actions.d.ts.map +1 -1
  100. package/dist/_internal/platform/daemon/surface-actions.js +13 -0
  101. package/dist/_internal/platform/daemon/surface-delivery.d.ts +3 -0
  102. package/dist/_internal/platform/daemon/surface-delivery.d.ts.map +1 -1
  103. package/dist/_internal/platform/daemon/surface-delivery.js +42 -6
  104. package/dist/_internal/platform/daemon/types.d.ts +2 -0
  105. package/dist/_internal/platform/daemon/types.d.ts.map +1 -1
  106. package/dist/_internal/platform/providers/anthropic.d.ts +13 -1
  107. package/dist/_internal/platform/providers/anthropic.d.ts.map +1 -1
  108. package/dist/_internal/platform/providers/anthropic.js +219 -1
  109. package/dist/_internal/platform/providers/interface.d.ts +48 -0
  110. package/dist/_internal/platform/providers/interface.d.ts.map +1 -1
  111. package/dist/_internal/platform/providers/openai.d.ts +13 -1
  112. package/dist/_internal/platform/providers/openai.d.ts.map +1 -1
  113. package/dist/_internal/platform/providers/openai.js +189 -1
  114. package/dist/_internal/platform/version.js +1 -1
  115. package/dist/_internal/platform/voice/index.d.ts +1 -1
  116. package/dist/_internal/platform/voice/index.d.ts.map +1 -1
  117. package/dist/_internal/platform/voice/providers/elevenlabs.d.ts.map +1 -1
  118. package/dist/_internal/platform/voice/providers/elevenlabs.js +150 -4
  119. package/dist/_internal/platform/voice/service.d.ts +2 -1
  120. package/dist/_internal/platform/voice/service.d.ts.map +1 -1
  121. package/dist/_internal/platform/voice/service.js +7 -0
  122. package/dist/_internal/platform/voice/types.d.ts +18 -1
  123. package/dist/_internal/platform/voice/types.d.ts.map +1 -1
  124. package/dist/index.d.ts +2 -0
  125. package/dist/index.d.ts.map +1 -1
  126. package/dist/index.js +1 -0
  127. package/dist/workers.d.ts +43 -0
  128. package/dist/workers.d.ts.map +1 -0
  129. package/dist/workers.js +156 -0
  130. package/package.json +6 -1
@@ -48,6 +48,7 @@ export interface ProviderRuntimeMetadata {
48
48
  readonly toolCalling: boolean;
49
49
  readonly parallelTools: boolean;
50
50
  readonly promptCaching?: boolean;
51
+ readonly batch?: ProviderBatchRuntimeMetadata;
51
52
  readonly cost?: ProviderUsageCostMetadata;
52
53
  readonly notes?: readonly string[];
53
54
  };
@@ -83,10 +84,57 @@ export interface ProviderEmbeddingResult {
83
84
  readonly modelId?: string;
84
85
  readonly metadata?: Record<string, unknown>;
85
86
  }
87
+ export interface ProviderBatchRuntimeMetadata {
88
+ readonly supported: boolean;
89
+ readonly discount?: string;
90
+ readonly completionWindow?: string;
91
+ readonly endpoints?: readonly string[];
92
+ readonly maxRequestsPerProviderBatch?: number;
93
+ readonly maxInputBytes?: number;
94
+ readonly notes?: readonly string[];
95
+ }
96
+ export type ProviderBatchStatus = 'queued' | 'submitted' | 'running' | 'completed' | 'failed' | 'cancelled' | 'expired';
97
+ export interface ProviderBatchChatRequest {
98
+ readonly customId: string;
99
+ readonly params: Omit<ChatRequest, 'signal' | 'onDelta'>;
100
+ }
101
+ export interface ProviderBatchCreateInput {
102
+ readonly requests: readonly ProviderBatchChatRequest[];
103
+ readonly metadata?: Record<string, string>;
104
+ readonly completionWindow?: '24h';
105
+ }
106
+ export interface ProviderBatchCreateResult {
107
+ readonly providerBatchId: string;
108
+ readonly status: ProviderBatchStatus;
109
+ readonly raw?: unknown;
110
+ }
111
+ export interface ProviderBatchPollResult extends ProviderBatchCreateResult {
112
+ readonly resultAvailable: boolean;
113
+ }
114
+ export interface ProviderBatchResult {
115
+ readonly customId: string;
116
+ readonly status: 'succeeded' | 'failed' | 'cancelled' | 'expired';
117
+ readonly response?: ChatResponse;
118
+ readonly error?: {
119
+ readonly message: string;
120
+ readonly code?: string;
121
+ readonly raw?: unknown;
122
+ };
123
+ readonly raw?: unknown;
124
+ }
125
+ export interface ProviderBatchAdapter {
126
+ readonly kind: 'provider-batch';
127
+ readonly endpoints: readonly string[];
128
+ createChatBatch(input: ProviderBatchCreateInput): Promise<ProviderBatchCreateResult>;
129
+ retrieveBatch(providerBatchId: string): Promise<ProviderBatchPollResult>;
130
+ cancelBatch?(providerBatchId: string): Promise<ProviderBatchPollResult>;
131
+ getResults(providerBatchId: string): Promise<readonly ProviderBatchResult[]>;
132
+ }
86
133
  /** Contract all LLM providers must implement. */
87
134
  export interface LLMProvider {
88
135
  readonly name: string;
89
136
  readonly models: string[];
137
+ readonly batch?: ProviderBatchAdapter;
90
138
  /**
91
139
  * Optional self-declared capability overrides for this provider instance.
92
140
  * When present, these take precedence over the built-in `PROVIDER_DEFAULTS`
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/providers/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKvD,CAAC;AAEF,iFAAiF;AACjF,MAAM,MAAM,yBAAyB,GACjC,SAAS,GACT,YAAY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MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { LLMProvider, ChatRequest, ChatResponse, ProviderEmbeddingRequest, ProviderEmbeddingResult, ProviderRuntimeMetadata, ProviderRuntimeMetadataDeps } from './interface.js';
1
+ import type { LLMProvider, ChatRequest, ChatResponse, ProviderEmbeddingRequest, ProviderEmbeddingResult, ProviderBatchAdapter, ProviderRuntimeMetadata, ProviderRuntimeMetadataDeps } from './interface.js';
2
2
  import type { CacheHitTracker } from './cache-strategy.js';
3
3
  /**
4
4
  * OpenAIProvider — wraps the official `openai` npm package.
@@ -7,12 +7,24 @@ import type { CacheHitTracker } from './cache-strategy.js';
7
7
  export declare class OpenAIProvider implements LLMProvider {
8
8
  readonly name = "openai";
9
9
  readonly models: string[];
10
+ readonly batch: ProviderBatchAdapter;
10
11
  private client;
12
+ private readonly apiKey;
11
13
  private readonly embeddingModel;
12
14
  private readonly cacheHitTracker;
13
15
  constructor(apiKey: string, cacheHitTracker?: Pick<CacheHitTracker, 'recordTurn'>);
14
16
  chat(params: ChatRequest): Promise<ChatResponse>;
15
17
  embed(request: ProviderEmbeddingRequest): Promise<ProviderEmbeddingResult>;
18
+ isConfigured(): boolean;
16
19
  describeRuntime(deps: ProviderRuntimeMetadataDeps): Promise<ProviderRuntimeMetadata>;
20
+ private createChatBatch;
21
+ private retrieveBatch;
22
+ private cancelBatch;
23
+ private getBatchResults;
24
+ private toOpenAIBatchChatBody;
25
+ private mapOpenAIBatchStatus;
26
+ private readOpenAIBatchResultFile;
27
+ private parseOpenAIBatchResult;
28
+ private openAIBatchBodyToChatResponse;
17
29
  }
18
30
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/providers/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ3D;;;GAGG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAE/B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsC;gBAE1D,MAAM,EAAE,MAAM,EAAE,eAAe,GAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAA0B;IAKnG,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA4HhD,KAAK,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA8B1E,eAAe,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAqC3F"}
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/providers/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,YAAY,EAEZ,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EAKpB,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQ3D;;;GAGG;AACH,qBAAa,cAAe,YAAW,WAAW;IAChD,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAC/B,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IAErC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA4B;IAC3D,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsC;gBAE1D,MAAM,EAAE,MAAM,EAAE,eAAe,GAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAA0B;IAcnG,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC;IA4HhD,KAAK,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IA8BhF,YAAY,IAAI,OAAO;IAIjB,eAAe,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,uBAAuB,CAAC;YA+C5E,eAAe;YAyBf,aAAa;YAUb,WAAW;YAUX,eAAe;IAY7B,OAAO,CAAC,qBAAqB;IAY7B,OAAO,CAAC,oBAAoB;YASd,yBAAyB;IAuBvC,OAAO,CAAC,sBAAsB;IA2B9B,OAAO,CAAC,6BAA6B;CAkCtC"}
@@ -1,4 +1,4 @@
1
- import OpenAI from 'openai';
1
+ import OpenAI, { toFile } from 'openai';
2
2
  import { mapOpenAIStopReason } from './stop-reason-maps.js';
3
3
  import { ProviderError } from '../types/errors.js';
4
4
  import { withRetry } from '../utils/retry.js';
@@ -15,12 +15,23 @@ const NOOP_CACHE_HIT_TRACKER = {
15
15
  export class OpenAIProvider {
16
16
  name = 'openai';
17
17
  models = [];
18
+ batch;
18
19
  client;
20
+ apiKey;
19
21
  embeddingModel = 'text-embedding-3-small';
20
22
  cacheHitTracker;
21
23
  constructor(apiKey, cacheHitTracker = NOOP_CACHE_HIT_TRACKER) {
24
+ this.apiKey = apiKey;
22
25
  this.client = new OpenAI({ apiKey });
23
26
  this.cacheHitTracker = cacheHitTracker;
27
+ this.batch = {
28
+ kind: 'provider-batch',
29
+ endpoints: ['/v1/chat/completions'],
30
+ createChatBatch: (input) => this.createChatBatch(input),
31
+ retrieveBatch: (providerBatchId) => this.retrieveBatch(providerBatchId),
32
+ cancelBatch: (providerBatchId) => this.cancelBatch(providerBatchId),
33
+ getResults: (providerBatchId) => this.getBatchResults(providerBatchId),
34
+ };
24
35
  }
25
36
  async chat(params) {
26
37
  const { messages, tools, model, maxTokens, signal, systemPrompt, onDelta, reasoningEffort: _reasoningEffort } = params;
@@ -163,6 +174,9 @@ export class OpenAIProvider {
163
174
  },
164
175
  };
165
176
  }
177
+ isConfigured() {
178
+ return this.apiKey.trim().length > 0;
179
+ }
166
180
  async describeRuntime(deps) {
167
181
  const configured = Boolean(process.env.OPENAI_API_KEY || process.env.OPENAI_KEY);
168
182
  const { buildStandardProviderAuthRoutes } = await import('./runtime-metadata.js');
@@ -189,6 +203,15 @@ export class OpenAIProvider {
189
203
  streaming: true,
190
204
  toolCalling: true,
191
205
  parallelTools: true,
206
+ batch: {
207
+ supported: true,
208
+ discount: 'Provider-side Batch API pricing is discounted versus live API pricing where OpenAI offers the discount.',
209
+ completionWindow: '24h',
210
+ endpoints: ['/v1/chat/completions'],
211
+ maxRequestsPerProviderBatch: 50_000,
212
+ maxInputBytes: 200 * 1024 * 1024,
213
+ notes: ['Batch requests are asynchronous and non-streaming. Results are correlated by custom_id.'],
214
+ },
192
215
  notes: ['Embeddings use the OpenAI embeddings API.'],
193
216
  },
194
217
  policy: {
@@ -200,4 +223,169 @@ export class OpenAIProvider {
200
223
  },
201
224
  };
202
225
  }
226
+ async createChatBatch(input) {
227
+ const lines = input.requests.map((request) => JSON.stringify({
228
+ custom_id: request.customId,
229
+ method: 'POST',
230
+ url: '/v1/chat/completions',
231
+ body: this.toOpenAIBatchChatBody(request.params),
232
+ })).join('\n') + '\n';
233
+ const file = await this.client.files.create({
234
+ file: await toFile(new Blob([lines], { type: 'application/jsonl' }), 'goodvibes-openai-chat-batch.jsonl'),
235
+ purpose: 'batch',
236
+ });
237
+ const metadata = input.metadata && Object.keys(input.metadata).length > 0 ? input.metadata : undefined;
238
+ const batch = await this.client.batches.create({
239
+ input_file_id: file.id,
240
+ endpoint: '/v1/chat/completions',
241
+ completion_window: input.completionWindow ?? '24h',
242
+ ...(metadata ? { metadata } : {}),
243
+ });
244
+ return {
245
+ providerBatchId: batch.id,
246
+ status: this.mapOpenAIBatchStatus(batch.status),
247
+ raw: batch,
248
+ };
249
+ }
250
+ async retrieveBatch(providerBatchId) {
251
+ const batch = await this.client.batches.retrieve(providerBatchId);
252
+ return {
253
+ providerBatchId: batch.id,
254
+ status: this.mapOpenAIBatchStatus(batch.status),
255
+ resultAvailable: typeof batch.output_file_id === 'string' || typeof batch.error_file_id === 'string',
256
+ raw: batch,
257
+ };
258
+ }
259
+ async cancelBatch(providerBatchId) {
260
+ const batch = await this.client.batches.cancel(providerBatchId);
261
+ return {
262
+ providerBatchId: batch.id,
263
+ status: this.mapOpenAIBatchStatus(batch.status),
264
+ resultAvailable: typeof batch.output_file_id === 'string' || typeof batch.error_file_id === 'string',
265
+ raw: batch,
266
+ };
267
+ }
268
+ async getBatchResults(providerBatchId) {
269
+ const batch = await this.client.batches.retrieve(providerBatchId);
270
+ const results = [];
271
+ if (typeof batch.output_file_id === 'string' && batch.output_file_id.length > 0) {
272
+ results.push(...await this.readOpenAIBatchResultFile(batch.output_file_id, false));
273
+ }
274
+ if (typeof batch.error_file_id === 'string' && batch.error_file_id.length > 0) {
275
+ results.push(...await this.readOpenAIBatchResultFile(batch.error_file_id, true));
276
+ }
277
+ return results;
278
+ }
279
+ toOpenAIBatchChatBody(params) {
280
+ const openaiMessages = toOpenAIMessages(params.messages, params.systemPrompt);
281
+ const openaiTools = params.tools && params.tools.length > 0 ? toOpenAITools(params.tools) : undefined;
282
+ return {
283
+ model: params.model,
284
+ messages: openaiMessages,
285
+ ...(openaiTools ? { tools: openaiTools } : {}),
286
+ ...(params.maxTokens ? { max_tokens: params.maxTokens } : {}),
287
+ stream: false,
288
+ };
289
+ }
290
+ mapOpenAIBatchStatus(status) {
291
+ if (status === 'completed')
292
+ return 'completed';
293
+ if (status === 'failed')
294
+ return 'failed';
295
+ if (status === 'cancelled' || status === 'cancelling')
296
+ return 'cancelled';
297
+ if (status === 'expired')
298
+ return 'expired';
299
+ if (status === 'in_progress' || status === 'finalizing')
300
+ return 'running';
301
+ return 'submitted';
302
+ }
303
+ async readOpenAIBatchResultFile(fileId, forceFailed) {
304
+ const response = await this.client.files.content(fileId);
305
+ const text = await response.text();
306
+ const lines = text.split('\n').map((line) => line.trim()).filter(Boolean);
307
+ const results = [];
308
+ for (const line of lines) {
309
+ try {
310
+ const parsed = JSON.parse(line);
311
+ results.push(this.parseOpenAIBatchResult(parsed, forceFailed));
312
+ }
313
+ catch (error) {
314
+ results.push({
315
+ customId: `unparseable:${crypto.randomUUID()}`,
316
+ status: 'failed',
317
+ error: {
318
+ message: `Unable to parse OpenAI batch result line: ${summarizeError(error)}`,
319
+ },
320
+ raw: line,
321
+ });
322
+ }
323
+ }
324
+ return results;
325
+ }
326
+ parseOpenAIBatchResult(parsed, forceFailed) {
327
+ const customId = typeof parsed['custom_id'] === 'string' ? parsed['custom_id'] : `unknown:${crypto.randomUUID()}`;
328
+ const response = toRecord(parsed['response']);
329
+ const statusCode = typeof response['status_code'] === 'number' ? response['status_code'] : 0;
330
+ const body = toRecord(response['body']);
331
+ const error = parsed['error'] ?? body['error'];
332
+ if (forceFailed || statusCode >= 400 || error !== undefined) {
333
+ const errorRecord = toRecord(error);
334
+ return {
335
+ customId,
336
+ status: 'failed',
337
+ error: {
338
+ message: typeof errorRecord['message'] === 'string' ? errorRecord['message'] : `OpenAI batch request failed${statusCode ? ` with status ${statusCode}` : ''}`,
339
+ ...(typeof errorRecord['code'] === 'string' ? { code: errorRecord['code'] } : {}),
340
+ raw: error ?? parsed,
341
+ },
342
+ raw: parsed,
343
+ };
344
+ }
345
+ return {
346
+ customId,
347
+ status: 'succeeded',
348
+ response: this.openAIBatchBodyToChatResponse(body),
349
+ raw: parsed,
350
+ };
351
+ }
352
+ openAIBatchBodyToChatResponse(body) {
353
+ const choices = Array.isArray(body['choices']) ? body['choices'] : [];
354
+ const firstChoice = toRecord(choices[0]);
355
+ const message = toRecord(firstChoice['message']);
356
+ const content = message['content'];
357
+ const responseText = typeof content === 'string'
358
+ ? content
359
+ : Array.isArray(content)
360
+ ? content.map((part) => {
361
+ const record = toRecord(part);
362
+ return typeof record['text'] === 'string' ? record['text'] : '';
363
+ }).join('')
364
+ : '';
365
+ const rawToolCalls = Array.isArray(message['tool_calls'])
366
+ ? message['tool_calls'].map((entry) => toRecord(entry))
367
+ : [];
368
+ const usage = toRecord(body['usage']);
369
+ const promptDetails = toRecord(usage['prompt_tokens_details']);
370
+ const rawFinishReason = typeof firstChoice['finish_reason'] === 'string' ? firstChoice['finish_reason'] : undefined;
371
+ const stopReason = rawFinishReason ? mapOpenAIStopReason(rawFinishReason) : (responseText ? 'completed' : 'unknown');
372
+ return {
373
+ content: responseText,
374
+ toolCalls: rawToolCalls.length > 0 ? fromOpenAIToolCalls(rawToolCalls) : [],
375
+ usage: {
376
+ inputTokens: typeof usage['prompt_tokens'] === 'number' ? usage['prompt_tokens'] : 0,
377
+ outputTokens: typeof usage['completion_tokens'] === 'number' ? usage['completion_tokens'] : 0,
378
+ ...(typeof promptDetails['cached_tokens'] === 'number' && promptDetails['cached_tokens'] > 0
379
+ ? { cacheReadTokens: promptDetails['cached_tokens'] }
380
+ : {}),
381
+ },
382
+ stopReason,
383
+ ...(rawFinishReason ? { providerStopReason: rawFinishReason } : {}),
384
+ };
385
+ }
386
+ }
387
+ function toRecord(value) {
388
+ return value !== null && typeof value === 'object' && !Array.isArray(value)
389
+ ? value
390
+ : {};
203
391
  }
@@ -1,6 +1,6 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- let version = '0.25.7';
3
+ let version = '0.25.10';
4
4
  try {
5
5
  const pkg = JSON.parse(readFileSync(join(import.meta.dir, '..', '..', 'package.json'), 'utf-8'));
6
6
  version = pkg.version ?? version;
@@ -1,4 +1,4 @@
1
- export type { VoiceAudioArtifact, VoiceAudioFormat, VoiceDescriptor, VoiceProvider, VoiceProviderCapability, VoiceProviderState, VoiceProviderStatus, VoiceRealtimeSession, VoiceRealtimeSessionRequest, VoiceSynthesisRequest, VoiceSynthesisResult, VoiceTranscriptionRequest, VoiceTranscriptionResult, } from './types.js';
1
+ export type { VoiceAudioArtifact, VoiceAudioChunk, VoiceAudioFormat, VoiceDescriptor, VoiceProvider, VoiceProviderCapability, VoiceProviderState, VoiceProviderStatus, VoiceRealtimeSession, VoiceRealtimeSessionRequest, VoiceSynthesisRequest, VoiceSynthesisResult, VoiceSynthesisStreamResult, VoiceTranscriptionRequest, VoiceTranscriptionResult, } from './types.js';
2
2
  export { VoiceProviderRegistry } from './provider-registry.js';
3
3
  export type { VoiceProviderDescriptor } from './provider-registry.js';
4
4
  export { VoiceService } from './service.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/voice/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/voice/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,GACzB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/voice/providers/elevenlabs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,aAAa,CAAC;AAsGrB,wBAAgB,wBAAwB,IAAI,aAAa,CAkSxD"}
1
+ {"version":3,"file":"elevenlabs.d.ts","sourceRoot":"","sources":["../../../../../src/_internal/platform/voice/providers/elevenlabs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,aAAa,EAKd,MAAM,aAAa,CAAC;AA0LrB,wBAAgB,wBAAwB,IAAI,aAAa,CAgWxD"}
@@ -2,6 +2,9 @@ import { asRecord, buildStatus, estimateConfidenceFromAvgLogprob, inferFilename,
2
2
  import { instrumentedFetch } from '../../utils/fetch-with-timeout.js';
3
3
  const DEFAULT_ELEVENLABS_STT_MODEL = 'scribe_v2';
4
4
  const DEFAULT_ELEVENLABS_REALTIME_MODEL = 'scribe_v2_realtime';
5
+ const DEFAULT_ELEVENLABS_TTS_MODEL = 'eleven_multilingual_v2';
6
+ const DEFAULT_ELEVENLABS_VOICE = 'pMsXgVXv3BLzUgSXRplE';
7
+ const DEFAULT_ELEVENLABS_OUTPUT_FORMAT = 'mp3_44100_128';
5
8
  const ELEVENLABS_SINGLE_USE_TOKEN_TTL_MS = 15 * 60 * 1000;
6
9
  function normalizeBooleanString(value) {
7
10
  return typeof value === 'boolean' ? String(value) : undefined;
@@ -14,6 +17,86 @@ function asStringArray(value) {
14
17
  .map((entry) => entry.trim());
15
18
  return values.length > 0 ? values : undefined;
16
19
  }
20
+ function resolveElevenLabsOutputFormat(format) {
21
+ const normalized = format?.trim().toLowerCase();
22
+ if (!normalized)
23
+ return DEFAULT_ELEVENLABS_OUTPUT_FORMAT;
24
+ if (normalized.includes('_'))
25
+ return normalized;
26
+ switch (normalized) {
27
+ case 'mp3':
28
+ return DEFAULT_ELEVENLABS_OUTPUT_FORMAT;
29
+ case 'pcm':
30
+ case 'pcm16':
31
+ return 'pcm_16000';
32
+ case 'ulaw':
33
+ case 'mulaw':
34
+ return 'ulaw_8000';
35
+ case 'opus':
36
+ case 'ogg':
37
+ case 'webm':
38
+ return 'opus_48000_32';
39
+ default:
40
+ return DEFAULT_ELEVENLABS_OUTPUT_FORMAT;
41
+ }
42
+ }
43
+ function mimeTypeForElevenLabsOutputFormat(outputFormat) {
44
+ if (outputFormat.startsWith('pcm_'))
45
+ return 'audio/pcm';
46
+ if (outputFormat.startsWith('ulaw_'))
47
+ return 'audio/basic';
48
+ if (outputFormat.startsWith('opus_'))
49
+ return 'audio/ogg';
50
+ return 'audio/mpeg';
51
+ }
52
+ function artifactFormatForElevenLabsOutputFormat(outputFormat) {
53
+ if (outputFormat.startsWith('pcm_'))
54
+ return 'pcm16';
55
+ if (outputFormat.startsWith('ulaw_'))
56
+ return 'ulaw';
57
+ if (outputFormat.startsWith('opus_'))
58
+ return 'ogg';
59
+ return 'mp3';
60
+ }
61
+ function readVoiceSetting(metadata, camelKey, snakeKey, fallback) {
62
+ const value = metadata?.[camelKey] ?? metadata?.[snakeKey];
63
+ return typeof value === 'number' && Number.isFinite(value) ? value : fallback;
64
+ }
65
+ function readSpeakerBoost(metadata) {
66
+ const value = metadata?.['useSpeakerBoost'] ?? metadata?.['use_speaker_boost'];
67
+ return typeof value === 'boolean' ? value : true;
68
+ }
69
+ async function* streamResponseAudioChunks(response, input) {
70
+ const reader = response.body?.getReader();
71
+ if (!reader)
72
+ throw new Error('ElevenLabs streaming synthesis returned no response body');
73
+ let sequence = 0;
74
+ let completed = false;
75
+ try {
76
+ while (true) {
77
+ const { done, value } = await reader.read();
78
+ if (done) {
79
+ completed = true;
80
+ break;
81
+ }
82
+ if (!value || value.byteLength === 0)
83
+ continue;
84
+ sequence += 1;
85
+ yield {
86
+ data: value,
87
+ sequence,
88
+ mimeType: input.mimeType,
89
+ format: input.format,
90
+ metadata: input.metadata,
91
+ };
92
+ }
93
+ }
94
+ finally {
95
+ if (!completed)
96
+ await reader.cancel().catch(() => undefined);
97
+ reader.releaseLock();
98
+ }
99
+ }
17
100
  function parseElevenLabsTranscript(payload) {
18
101
  const text = trimToUndefined(payload.text);
19
102
  if (!text)
@@ -60,15 +143,17 @@ export function createElevenLabsProvider() {
60
143
  return {
61
144
  id: 'elevenlabs',
62
145
  label: 'ElevenLabs',
63
- capabilities: ['tts', 'stt', 'realtime', 'voice-list'],
146
+ capabilities: ['tts', 'tts-stream', 'stt', 'realtime', 'voice-list'],
64
147
  status() {
65
148
  const configured = readFirstEnv(envVars) !== null;
66
- return buildStatus('elevenlabs', 'ElevenLabs', ['tts', 'stt', 'realtime', 'voice-list'], configured, configured
149
+ return buildStatus('elevenlabs', 'ElevenLabs', ['tts', 'tts-stream', 'stt', 'realtime', 'voice-list'], configured, configured
67
150
  ? 'ElevenLabs speech, transcription, and realtime APIs are available.'
68
151
  : 'Set ELEVENLABS_API_KEY or XI_API_KEY to enable ElevenLabs speech and transcription.', {
69
152
  baseUrl: normalizeBaseUrl(readFirstEnv(baseUrlEnvVars), 'https://api.elevenlabs.io'),
153
+ defaultTtsModel: DEFAULT_ELEVENLABS_TTS_MODEL,
70
154
  defaultSttModel: DEFAULT_ELEVENLABS_STT_MODEL,
71
155
  defaultRealtimeModel: DEFAULT_ELEVENLABS_REALTIME_MODEL,
156
+ defaultOutputFormat: DEFAULT_ELEVENLABS_OUTPUT_FORMAT,
72
157
  });
73
158
  },
74
159
  async listVoices() {
@@ -98,7 +183,7 @@ export function createElevenLabsProvider() {
98
183
  if (!apiKey)
99
184
  throw new Error('ElevenLabs API key missing');
100
185
  const baseUrl = normalizeBaseUrl(readFirstEnv(baseUrlEnvVars), 'https://api.elevenlabs.io');
101
- const voiceId = request.voiceId?.trim() || 'pMsXgVXv3BLzUgSXRplE';
186
+ const voiceId = request.voiceId?.trim() || DEFAULT_ELEVENLABS_VOICE;
102
187
  const response = await instrumentedFetch(`${baseUrl}/v1/text-to-speech/${voiceId}`, {
103
188
  method: 'POST',
104
189
  headers: {
@@ -108,7 +193,7 @@ export function createElevenLabsProvider() {
108
193
  },
109
194
  body: JSON.stringify({
110
195
  text: request.text,
111
- model_id: request.modelId?.trim() || 'eleven_multilingual_v2',
196
+ model_id: request.modelId?.trim() || DEFAULT_ELEVENLABS_TTS_MODEL,
112
197
  voice_settings: {
113
198
  stability: 0.5,
114
199
  similarity_boost: 0.75,
@@ -133,6 +218,67 @@ export function createElevenLabsProvider() {
133
218
  metadata: { voiceId, baseUrl },
134
219
  };
135
220
  },
221
+ async synthesizeStream(request) {
222
+ const apiKey = readFirstEnv(envVars);
223
+ if (!apiKey)
224
+ throw new Error('ElevenLabs API key missing');
225
+ const baseUrl = normalizeBaseUrl(readFirstEnv(baseUrlEnvVars), 'https://api.elevenlabs.io');
226
+ const metadata = asRecord(request.metadata);
227
+ const voiceId = request.voiceId?.trim() || DEFAULT_ELEVENLABS_VOICE;
228
+ const modelId = request.modelId?.trim() || DEFAULT_ELEVENLABS_TTS_MODEL;
229
+ const outputFormat = resolveElevenLabsOutputFormat(request.format);
230
+ const mimeType = mimeTypeForElevenLabsOutputFormat(outputFormat);
231
+ const format = artifactFormatForElevenLabsOutputFormat(outputFormat);
232
+ const url = new URL(`${baseUrl}/v1/text-to-speech/${voiceId}/stream`);
233
+ url.searchParams.set('output_format', outputFormat);
234
+ if (metadata?.['enableLogging'] === false) {
235
+ url.searchParams.set('enable_logging', 'false');
236
+ }
237
+ const languageCode = trimToUndefined(metadata?.['languageCode']);
238
+ const body = {
239
+ text: request.text,
240
+ model_id: modelId,
241
+ voice_settings: {
242
+ stability: readVoiceSetting(metadata, 'stability', 'stability', 0.5),
243
+ similarity_boost: readVoiceSetting(metadata, 'similarityBoost', 'similarity_boost', 0.75),
244
+ style: readVoiceSetting(metadata, 'style', 'style', 0),
245
+ use_speaker_boost: readSpeakerBoost(metadata),
246
+ speed: request.speed ?? readVoiceSetting(metadata, 'speed', 'speed', 1),
247
+ },
248
+ ...(languageCode ? { language_code: languageCode } : {}),
249
+ };
250
+ const response = await instrumentedFetch(url, {
251
+ method: 'POST',
252
+ headers: {
253
+ 'xi-api-key': apiKey,
254
+ 'Content-Type': 'application/json',
255
+ Accept: mimeType,
256
+ },
257
+ signal: request.signal,
258
+ body: JSON.stringify(body),
259
+ });
260
+ if (!response.ok) {
261
+ const errorText = await response.text().catch(() => '');
262
+ throw new Error(`ElevenLabs streaming synthesis failed: HTTP ${response.status}${errorText ? `: ${errorText}` : ''}`);
263
+ }
264
+ const resultMetadata = {
265
+ baseUrl,
266
+ voiceId,
267
+ modelId,
268
+ outputFormat,
269
+ };
270
+ return {
271
+ providerId: 'elevenlabs',
272
+ mimeType,
273
+ format,
274
+ chunks: streamResponseAudioChunks(response, {
275
+ mimeType,
276
+ format,
277
+ metadata: resultMetadata,
278
+ }),
279
+ metadata: resultMetadata,
280
+ };
281
+ },
136
282
  async transcribe(request) {
137
283
  const apiKey = readFirstEnv(envVars);
138
284
  if (!apiKey)
@@ -1,5 +1,5 @@
1
1
  import { VoiceProviderRegistry } from './provider-registry.js';
2
- import type { VoiceDescriptor, VoiceRealtimeSession, VoiceRealtimeSessionRequest, VoiceSynthesisRequest, VoiceSynthesisResult, VoiceTranscriptionRequest, VoiceTranscriptionResult } from './types.js';
2
+ import type { VoiceDescriptor, VoiceRealtimeSession, VoiceRealtimeSessionRequest, VoiceSynthesisRequest, VoiceSynthesisResult, VoiceSynthesisStreamResult, VoiceTranscriptionRequest, VoiceTranscriptionResult } from './types.js';
3
3
  export interface VoiceServiceStatus {
4
4
  readonly enabled: boolean;
5
5
  readonly providerCount: number;
@@ -12,6 +12,7 @@ export declare class VoiceService {
12
12
  getStatus(enabled: boolean): Promise<VoiceServiceStatus>;
13
13
  listVoices(providerId?: string): Promise<readonly VoiceDescriptor[]>;
14
14
  synthesize(providerId: string | undefined, request: VoiceSynthesisRequest): Promise<VoiceSynthesisResult>;
15
+ synthesizeStream(providerId: string | undefined, request: VoiceSynthesisRequest): Promise<VoiceSynthesisStreamResult>;
15
16
  transcribe(providerId: string | undefined, request: VoiceTranscriptionRequest): Promise<VoiceTranscriptionResult>;
16
17
  openRealtimeSession(providerId: string | undefined, request: VoiceRealtimeSessionRequest): Promise<VoiceRealtimeSession>;
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../src/_internal/platform/voice/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IA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;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,YAAY;IACX,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,qBAAqB;IAEtD,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAUxD,UAAU,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC;IAYpE,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQzG,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAQrH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAQjH,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,2BAA2B,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAO/H"}
@@ -32,6 +32,13 @@ export class VoiceService {
32
32
  }
33
33
  return provider.synthesize(request);
34
34
  }
35
+ async synthesizeStream(providerId, request) {
36
+ const provider = this.registry.findProvider('tts-stream', providerId);
37
+ if (!provider?.synthesizeStream) {
38
+ throw new Error(providerId ? `Voice streaming TTS provider unavailable: ${providerId}` : 'No streaming voice TTS provider is registered');
39
+ }
40
+ return provider.synthesizeStream(request);
41
+ }
35
42
  async transcribe(providerId, request) {
36
43
  const provider = this.registry.findProvider('stt', providerId);
37
44
  if (!provider?.transcribe) {