@voice-ai-labs/web-sdk 0.9.2 → 1.0.0
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.
- package/README.md +156 -24
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +6 -0
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/base.d.ts +8 -2
- package/dist/client/base.d.ts.map +1 -1
- package/dist/client/base.js +31 -13
- package/dist/client/base.js.map +1 -1
- package/dist/client/index.d.ts +1 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/managed-tools.d.ts +17 -0
- package/dist/client/managed-tools.d.ts.map +1 -0
- package/dist/client/managed-tools.js +24 -0
- package/dist/client/managed-tools.js.map +1 -0
- package/dist/client/tts.d.ts +1 -1
- package/dist/client/tts.js +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +781 -46
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +798 -45
- package/dist/index.js.map +1 -1
- package/dist/managed-tools/google.d.ts +29 -0
- package/dist/managed-tools/google.d.ts.map +1 -0
- package/dist/managed-tools/google.js +178 -0
- package/dist/managed-tools/google.js.map +1 -0
- package/dist/managed-tools/iana-timezones.d.ts +10 -0
- package/dist/managed-tools/iana-timezones.d.ts.map +1 -0
- package/dist/managed-tools/iana-timezones.js +470 -0
- package/dist/managed-tools/iana-timezones.js.map +1 -0
- package/dist/types.d.ts +78 -10
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ The SDK provides a unified interface for:
|
|
|
35
35
|
- [**Real-time Voice**](#real-time-voice) — Connect to voice agents with live transcription
|
|
36
36
|
- [**Text-to-Speech**](#text-to-speech) — Generate speech and manage voices
|
|
37
37
|
- [**Agent Management**](#agent-management) — Create, update, deploy, and manage agents
|
|
38
|
+
- [**Managed Tools**](#managed-tools) — Connect first-party managed integrations such as Google Calendar, Sheets, and Gmail
|
|
38
39
|
- [**Knowledge Base**](#knowledge-base) — Manage RAG documents for your agents
|
|
39
40
|
- [**Phone Numbers**](#phone-numbers) — Search and manage phone numbers
|
|
40
41
|
- [**Analytics**](#analytics) — Access call history, transcripts, and recordings
|
|
@@ -167,7 +168,7 @@ const audio = await voiceai.tts.synthesize({
|
|
|
167
168
|
// List all available voices
|
|
168
169
|
const voices = await voiceai.tts.listVoices();
|
|
169
170
|
|
|
170
|
-
// Clone a voice from audio file (MP3/WAV/
|
|
171
|
+
// Clone a voice from audio file (MP3/WAV/M4A, max 7.5MB)
|
|
171
172
|
const voice = await voiceai.tts.cloneVoice({
|
|
172
173
|
file: audioFile,
|
|
173
174
|
name: 'My Voice',
|
|
@@ -279,6 +280,126 @@ await voiceai.agents.createOutboundCall({
|
|
|
279
280
|
});
|
|
280
281
|
```
|
|
281
282
|
|
|
283
|
+
## Managed Tools
|
|
284
|
+
|
|
285
|
+
The managed tools surface is generic. Today it covers Google Calendar, Google Sheets, and Gmail.
|
|
286
|
+
|
|
287
|
+
Managed tools are exposed under `voiceai.managedTools`.
|
|
288
|
+
|
|
289
|
+
Today the SDK includes one Google entry:
|
|
290
|
+
|
|
291
|
+
- `voiceai.managedTools.google`
|
|
292
|
+
- Use it to start OAuth, check status, and disconnect Google managed tools for an agent
|
|
293
|
+
- Pass the individual managed tool configs under `managedTools.google_calendar`, `managedTools.google_sheets`, and `managedTools.google_gmail`
|
|
294
|
+
|
|
295
|
+
Use the managed Google surface to connect an agent to Google Calendar, Sheets, or Gmail.
|
|
296
|
+
|
|
297
|
+
```typescript
|
|
298
|
+
import VoiceAI, {
|
|
299
|
+
GOOGLE_CALENDAR_OPERATION_OPTIONS,
|
|
300
|
+
IANA_TIMEZONE_OPTIONS,
|
|
301
|
+
getGoogleReconnectState,
|
|
302
|
+
hasEnabledGoogleManagedTools,
|
|
303
|
+
} from '@voice-ai-labs/web-sdk';
|
|
304
|
+
|
|
305
|
+
const voiceai = new VoiceAI({ apiKey: 'vk_your_api_key' });
|
|
306
|
+
|
|
307
|
+
const start = await voiceai.managedTools.google.startOAuth('agent-123', {
|
|
308
|
+
returnUrl: window.location.href,
|
|
309
|
+
managedTools: {
|
|
310
|
+
google_calendar: {
|
|
311
|
+
enabled: true,
|
|
312
|
+
timezone: 'America/Los_Angeles',
|
|
313
|
+
selected_operations: ['google_calendar_check_availability', 'google_calendar_create_event'],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
window.open(start.auth_url, 'google-oauth', 'popup,width=540,height=720');
|
|
319
|
+
|
|
320
|
+
const status = await voiceai.managedTools.google.getStatus('agent-123');
|
|
321
|
+
const reconnect = getGoogleReconnectState(
|
|
322
|
+
{
|
|
323
|
+
google_calendar: {
|
|
324
|
+
enabled: true,
|
|
325
|
+
selected_operations: ['google_calendar_check_availability', 'google_calendar_create_event'],
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
status
|
|
329
|
+
);
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Connection flow:
|
|
333
|
+
|
|
334
|
+
1. Call `startOAuth(...)` with the agent ID, `returnUrl`, and the individual Google managed tool configs you want enabled.
|
|
335
|
+
2. Open the returned `auth_url` in a popup or browser tab.
|
|
336
|
+
3. Google redirects to the VoiceAI backend callback.
|
|
337
|
+
4. The backend completes OAuth and then returns the user to your `returnUrl`.
|
|
338
|
+
5. Refresh or poll `voiceai.managedTools.google.getStatus(agentId)` to confirm the connection state.
|
|
339
|
+
|
|
340
|
+
Connection semantics:
|
|
341
|
+
|
|
342
|
+
- `startOAuth(...)` manages Google managed-tools access for the agent
|
|
343
|
+
- `managedTools.google_calendar`, `managedTools.google_sheets`, and `managedTools.google_gmail` decide which Google capabilities should be available
|
|
344
|
+
- enabling more Google operations later can require reconnecting to grant additional access
|
|
345
|
+
- `disconnect(...)` removes Google managed-tools access for that agent
|
|
346
|
+
|
|
347
|
+
Available helpers:
|
|
348
|
+
|
|
349
|
+
- `voiceai.managedTools.google.startOAuth(agentId, { returnUrl, managedTools })`
|
|
350
|
+
- `voiceai.managedTools.google.getStatus(agentId)`
|
|
351
|
+
- `voiceai.managedTools.google.disconnect(agentId)`
|
|
352
|
+
- `GOOGLE_CALENDAR_OPERATION_OPTIONS`, `GOOGLE_SHEETS_OPERATION_OPTIONS`, `GOOGLE_GMAIL_OPERATION_OPTIONS`
|
|
353
|
+
- `getManagedToolSelectedOperations(...)`, `toggleManagedToolOperation(...)`
|
|
354
|
+
- `getRequiredGoogleScopes(...)`, `getGoogleReconnectState(...)`, `hasEnabledGoogleManagedTools(...)`
|
|
355
|
+
- `IANA_TIMEZONE_OPTIONS` for timezone selectors. Each option includes `{ value, label, offsetMinutes }`, where `value` is the canonical IANA timezone like `America/Los_Angeles`
|
|
356
|
+
|
|
357
|
+
Managed tool config fields:
|
|
358
|
+
|
|
359
|
+
- `google_calendar`
|
|
360
|
+
- `enabled: boolean`
|
|
361
|
+
- `default_calendar_id?: string`
|
|
362
|
+
- `timezone?: string`
|
|
363
|
+
- `selected_operations?: GoogleCalendarOperation[]`
|
|
364
|
+
- `google_sheets`
|
|
365
|
+
- `enabled: boolean`
|
|
366
|
+
- `spreadsheet_id?: string`
|
|
367
|
+
- `sheet_name?: string`
|
|
368
|
+
- `selected_operations?: GoogleSheetsOperation[]`
|
|
369
|
+
- `google_gmail`
|
|
370
|
+
- `enabled: boolean`
|
|
371
|
+
- `selected_operations?: GoogleGmailOperation[]`
|
|
372
|
+
|
|
373
|
+
Supported Calendar operations:
|
|
374
|
+
|
|
375
|
+
- `google_calendar_check_availability` — Check whether a calendar is free during a time window
|
|
376
|
+
- `google_calendar_list_upcoming_events` — Read the next upcoming events from the calendar
|
|
377
|
+
- `google_calendar_create_event` — Create a new calendar event
|
|
378
|
+
- `google_calendar_update_event` — Modify an existing calendar event
|
|
379
|
+
- `google_calendar_cancel_event` — Cancel or delete an existing calendar event
|
|
380
|
+
|
|
381
|
+
Supported Sheets operations:
|
|
382
|
+
|
|
383
|
+
- `google_sheets_append_row` — Write a new row into a spreadsheet
|
|
384
|
+
- `google_sheets_list_sheets` — List worksheet tabs and spreadsheet metadata
|
|
385
|
+
- `google_sheets_read_rows` — Read rows from a worksheet range
|
|
386
|
+
|
|
387
|
+
Supported Gmail operations:
|
|
388
|
+
|
|
389
|
+
- `google_gmail_search_messages` — Search Gmail and return readable message summaries
|
|
390
|
+
- `google_gmail_get_message` — Fetch a specific Gmail message by ID
|
|
391
|
+
- `google_gmail_send_email` — Send an email from the connected Gmail account
|
|
392
|
+
|
|
393
|
+
Notes:
|
|
394
|
+
|
|
395
|
+
- Google Calendar, Sheets, and Gmail all use the `voiceai.managedTools.google` surface.
|
|
396
|
+
- If you enable additional Google operations later, `getStatus()` / `getGoogleReconnectState(...)` may report `reconnect_required` until you reconnect and grant the additional access.
|
|
397
|
+
- `voiceai.managedTools.google.disconnect(agentId)` removes Google managed-tools access for the agent.
|
|
398
|
+
- `returnUrl` is your app/frontend return target after the VoiceAI backend callback completes. It is not the Google-registered OAuth redirect URI.
|
|
399
|
+
- Calendar `timezone` should be an IANA timezone like `America/Los_Angeles`
|
|
400
|
+
- If `selected_operations` is omitted, the SDK helpers treat that managed tool config as “all supported operations selected”
|
|
401
|
+
- If `selected_operations` is an empty array, the managed tool config remains present but requests no additional provider scopes
|
|
402
|
+
|
|
282
403
|
> **Outbound access control:** `POST /api/v1/calls/outbound` is restricted to approved accounts.
|
|
283
404
|
> If you need outbound enabled for your account/workspace, please contact Voice.ai support.
|
|
284
405
|
|
|
@@ -365,7 +486,10 @@ await voiceai.phoneNumbers.release('+14155551234');
|
|
|
365
486
|
const history = await voiceai.analytics.getCallHistory({
|
|
366
487
|
page: 1,
|
|
367
488
|
limit: 20,
|
|
368
|
-
agent_ids: ['agent-123']
|
|
489
|
+
agent_ids: ['agent-123'],
|
|
490
|
+
agent_name: 'support',
|
|
491
|
+
sort_by: 'duration',
|
|
492
|
+
sort_dir: 'desc'
|
|
369
493
|
});
|
|
370
494
|
|
|
371
495
|
// Get transcript URL
|
|
@@ -385,9 +509,9 @@ const stats = await voiceai.analytics.getStatsSummary();
|
|
|
385
509
|
|
|
386
510
|
Configure webhooks when creating or updating an agent.
|
|
387
511
|
|
|
388
|
-
`webhooks.events`, `webhooks.inbound_call`, and `webhooks.tools` use different contracts:
|
|
512
|
+
`webhooks.events[]`, `webhooks.inbound_call`, and `webhooks.tools` use different contracts:
|
|
389
513
|
|
|
390
|
-
- `webhooks.events` supports `secret` (write-only on create/update) and `has_secret` (read-only on fetch).
|
|
514
|
+
- `webhooks.events[]` supports `secret` (write-only on create/update) and `has_secret` (read-only on fetch), with fan-out across enabled endpoints.
|
|
391
515
|
- `webhooks.inbound_call` supports `secret` (write-only on create/update) and `has_secret` (read-only on fetch).
|
|
392
516
|
- `webhooks.tools` define outbound API calls and do not use `secret`.
|
|
393
517
|
|
|
@@ -400,13 +524,15 @@ const agent = await voiceai.agents.create({
|
|
|
400
524
|
config: {
|
|
401
525
|
prompt: 'You are a helpful support agent.',
|
|
402
526
|
webhooks: {
|
|
403
|
-
events:
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
527
|
+
events: [
|
|
528
|
+
{
|
|
529
|
+
url: 'https://your-server.com/webhooks/voice-events',
|
|
530
|
+
secret: 'your-hmac-secret', // Event webhook signing secret
|
|
531
|
+
events: ['call.started', 'call.completed'], // Or omit for all events
|
|
532
|
+
timeout: 5,
|
|
533
|
+
enabled: true
|
|
534
|
+
}
|
|
535
|
+
],
|
|
410
536
|
inbound_call: {
|
|
411
537
|
url: 'https://your-server.com/webhooks/inbound-call',
|
|
412
538
|
secret: 'your-inbound-call-secret', // Inbound call webhook signing secret
|
|
@@ -446,11 +572,13 @@ const agent = await voiceai.agents.create({
|
|
|
446
572
|
await voiceai.agents.update(agentId, {
|
|
447
573
|
config: {
|
|
448
574
|
webhooks: {
|
|
449
|
-
events:
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
575
|
+
events: [
|
|
576
|
+
{
|
|
577
|
+
url: 'https://your-server.com/webhooks',
|
|
578
|
+
events: ['call.completed'], // Only receive call.completed
|
|
579
|
+
enabled: true
|
|
580
|
+
}
|
|
581
|
+
],
|
|
454
582
|
tools: [
|
|
455
583
|
{
|
|
456
584
|
name: 'search_knowledge_base',
|
|
@@ -476,10 +604,12 @@ await voiceai.agents.update(agentId, {
|
|
|
476
604
|
|
|
477
605
|
### Webhook configuration requiredness
|
|
478
606
|
|
|
479
|
-
- `webhooks.events`
|
|
480
|
-
- Required: `url`
|
|
481
|
-
- Optional: `secret`, `events`, `timeout` (default `5`), `enabled` (default `true`)
|
|
482
|
-
- On update: omit `events` to preserve the
|
|
607
|
+
- `webhooks.events[]`
|
|
608
|
+
- Required per endpoint: `url`
|
|
609
|
+
- Optional per endpoint: `secret`, `events`, `timeout` (default `5`), `enabled` (default `true`)
|
|
610
|
+
- On update: omit `webhooks.events` to preserve the current list, set `webhooks.events: null` to remove it, or pass a full array to replace the list
|
|
611
|
+
- When replacing the array: omitted `secret` values are preserved only for entries whose `url` exactly matches an existing endpoint, `secret: null` clears the signing secret for that endpoint, and duplicate URLs are invalid
|
|
612
|
+
- Use `events: []` on an endpoint to receive all event types
|
|
483
613
|
- `webhooks.inbound_call`
|
|
484
614
|
- Required: `url`
|
|
485
615
|
- Optional: `secret`, `timeout` (default `5`), `enabled` (default `true`)
|
|
@@ -520,8 +650,10 @@ interface WebhookEvent {
|
|
|
520
650
|
|
|
521
651
|
For webhook tools, Voice.ai makes outbound HTTP requests directly to each tool `url`.
|
|
522
652
|
|
|
523
|
-
- `method: 'GET'`: tool arguments are sent as query parameters.
|
|
524
|
-
- `method: 'POST' | 'PUT' | 'PATCH'
|
|
653
|
+
- `method: 'GET' | 'DELETE'`: tool arguments are sent as query parameters.
|
|
654
|
+
- `method: 'POST' | 'PUT' | 'PATCH'`: tool arguments are sent as JSON body.
|
|
655
|
+
- For body methods, Voice.ai always sends `Content-Type: application/json`.
|
|
656
|
+
- If you configure a `Content-Type` header in `headers`, it is ignored for webhook tools.
|
|
525
657
|
- Metadata headers are always sent:
|
|
526
658
|
- `X-VoiceAI-Request-Id`
|
|
527
659
|
- `X-VoiceAI-Tool-Name`
|
|
@@ -552,7 +684,7 @@ X-VoiceAI-Call-Id: call_123
|
|
|
552
684
|
- `auth_type: 'none'`: no auth headers added.
|
|
553
685
|
- `auth_type: 'bearer_token'`: sends `Authorization: Bearer <auth_token>`.
|
|
554
686
|
- `auth_type: 'api_key'`: sends `X-API-Key: <auth_token>`.
|
|
555
|
-
- `auth_type: 'custom_headers'`: sends your configured `headers` map.
|
|
687
|
+
- `auth_type: 'custom_headers'`: sends your configured `headers` map, except `Content-Type`, which is agent-managed for body methods.
|
|
556
688
|
|
|
557
689
|
### Webhook Tool Response Behavior
|
|
558
690
|
|
|
@@ -561,7 +693,7 @@ X-VoiceAI-Call-Id: call_123
|
|
|
561
693
|
|
|
562
694
|
### Signature Verification (Event Webhooks)
|
|
563
695
|
|
|
564
|
-
If you configure `webhooks.events.secret`, verify the HMAC-SHA256 signature:
|
|
696
|
+
If you configure `webhooks.events[].secret`, verify the HMAC-SHA256 signature:
|
|
565
697
|
|
|
566
698
|
```typescript
|
|
567
699
|
import crypto from 'crypto';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,MAAM,EAAE,gBAAgB;IAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACtD,OAAO,KAAK,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EAC1B,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,MAAM,EAAE,gBAAgB;IAIpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACG,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,4BAA4B,CAAC;IAe5F;;;;;;;;;;;;;OAaG;IACG,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAInE;;;;;;;;;;;;;;OAcG;IACG,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIjE;;;;;;;;;;;;;OAaG;IACG,eAAe,IAAI,OAAO,CAAC,yBAAyB,CAAC;CAG5D"}
|
package/dist/client/analytics.js
CHANGED
|
@@ -56,6 +56,12 @@ export class AnalyticsClient extends BaseClient {
|
|
|
56
56
|
params.end_date = options.end_date;
|
|
57
57
|
if (options?.agent_ids)
|
|
58
58
|
params.agent_ids = options.agent_ids;
|
|
59
|
+
if (options?.agent_name)
|
|
60
|
+
params.agent_name = options.agent_name;
|
|
61
|
+
if (options?.sort_by)
|
|
62
|
+
params.sort_by = options.sort_by;
|
|
63
|
+
if (options?.sort_dir)
|
|
64
|
+
params.sort_dir = options.sort_dir;
|
|
59
65
|
return this.get('/agent/call-history', params);
|
|
60
66
|
}
|
|
61
67
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAoB,MAAM,QAAQ,CAAC;AAStD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,CAAC,cAAc,CAAC,OAA+B;QAClD,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,IAAI,OAAO,EAAE,IAAI,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAC5D,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC/D,IAAI,OAAO,EAAE,UAAU;YAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QAChE,IAAI,OAAO,EAAE,QAAQ;YAAE,MAAM,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAC1D,IAAI,OAAO,EAAE,SAAS;YAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAoB,MAAM,QAAQ,CAAC;AAStD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;IACH,KAAK,CAAC,cAAc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C,CAAC;IACrE,CAAC;CACF"}
|
package/dist/client/base.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* - Error handling and response parsing
|
|
7
7
|
* - Common HTTP methods (GET, POST, PUT, PATCH, DELETE)
|
|
8
8
|
*/
|
|
9
|
+
import type { AuthTokenProvider } from '../types';
|
|
9
10
|
/** Error thrown by Voice.ai API client */
|
|
10
11
|
export declare class VoiceAIError extends Error {
|
|
11
12
|
readonly status?: number | undefined;
|
|
@@ -15,7 +16,9 @@ export declare class VoiceAIError extends Error {
|
|
|
15
16
|
}
|
|
16
17
|
/** Configuration for BaseClient */
|
|
17
18
|
export interface BaseClientConfig {
|
|
18
|
-
apiKey
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
authToken?: string;
|
|
21
|
+
getAuthToken?: AuthTokenProvider;
|
|
19
22
|
apiUrl: string;
|
|
20
23
|
}
|
|
21
24
|
/**
|
|
@@ -23,12 +26,15 @@ export interface BaseClientConfig {
|
|
|
23
26
|
*/
|
|
24
27
|
export declare class BaseClient {
|
|
25
28
|
protected readonly apiKey: string;
|
|
29
|
+
protected readonly authToken?: string;
|
|
30
|
+
protected readonly getAuthToken?: AuthTokenProvider;
|
|
26
31
|
protected readonly apiUrl: string;
|
|
27
32
|
constructor(config: BaseClientConfig);
|
|
33
|
+
protected resolveBearerToken(): Promise<string>;
|
|
28
34
|
/**
|
|
29
35
|
* Build headers with authentication
|
|
30
36
|
*/
|
|
31
|
-
protected getHeaders(contentType?: string): Record<string, string
|
|
37
|
+
protected getHeaders(contentType?: string): Promise<Record<string, string>>;
|
|
32
38
|
/**
|
|
33
39
|
* Handle API response and parse errors
|
|
34
40
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/client/base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/client/base.ts"],"names":[],"mapp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AAC,CAAC;IAuB9E;;OAEG;cACa,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAsCrF;;OAEG;cACa,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAU7D;;OAEG;cACa,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC;IAe7E;;OAEG;cACa,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAU5D;;OAEG;cACa,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC;IAU9D;;OAEG;cACa,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IASvD;;OAEG;cACa,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BpE;;OAEG;cACa,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,QAAQ,CAAC;CAyB3E"}
|
package/dist/client/base.js
CHANGED
|
@@ -21,15 +21,33 @@ export class VoiceAIError extends Error {
|
|
|
21
21
|
*/
|
|
22
22
|
export class BaseClient {
|
|
23
23
|
constructor(config) {
|
|
24
|
-
this.apiKey = config.apiKey;
|
|
24
|
+
this.apiKey = config.apiKey || '';
|
|
25
|
+
this.authToken = config.authToken;
|
|
26
|
+
this.getAuthToken = config.getAuthToken;
|
|
25
27
|
this.apiUrl = config.apiUrl;
|
|
26
28
|
}
|
|
29
|
+
async resolveBearerToken() {
|
|
30
|
+
if (this.apiKey) {
|
|
31
|
+
return this.apiKey;
|
|
32
|
+
}
|
|
33
|
+
if (this.authToken) {
|
|
34
|
+
return this.authToken;
|
|
35
|
+
}
|
|
36
|
+
if (this.getAuthToken) {
|
|
37
|
+
const resolvedToken = await this.getAuthToken();
|
|
38
|
+
if (typeof resolvedToken === 'string' && resolvedToken.trim()) {
|
|
39
|
+
return resolvedToken;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
throw new VoiceAIError('Authentication required. Configure apiKey, authToken, or getAuthToken.', 401, 'UNAUTHORIZED');
|
|
43
|
+
}
|
|
27
44
|
/**
|
|
28
45
|
* Build headers with authentication
|
|
29
46
|
*/
|
|
30
|
-
getHeaders(contentType = 'application/json') {
|
|
47
|
+
async getHeaders(contentType = 'application/json') {
|
|
48
|
+
const bearerToken = await this.resolveBearerToken();
|
|
31
49
|
const headers = {
|
|
32
|
-
'Authorization': `Bearer ${
|
|
50
|
+
'Authorization': `Bearer ${bearerToken}`,
|
|
33
51
|
};
|
|
34
52
|
if (contentType) {
|
|
35
53
|
headers['Content-Type'] = contentType;
|
|
@@ -59,7 +77,7 @@ export class BaseClient {
|
|
|
59
77
|
}
|
|
60
78
|
// Handle specific error codes
|
|
61
79
|
if (response.status === 401) {
|
|
62
|
-
throw new VoiceAIError('Authentication failed. Please check your API key.', 401, 'UNAUTHORIZED');
|
|
80
|
+
throw new VoiceAIError('Authentication failed. Please check your API key or auth token.', 401, 'UNAUTHORIZED');
|
|
63
81
|
}
|
|
64
82
|
if (response.status === 403) {
|
|
65
83
|
const detail = errorData?.detail || errorData?.error;
|
|
@@ -100,7 +118,7 @@ export class BaseClient {
|
|
|
100
118
|
}
|
|
101
119
|
const response = await fetch(url.toString(), {
|
|
102
120
|
method: 'GET',
|
|
103
|
-
headers: this.getHeaders(),
|
|
121
|
+
headers: await this.getHeaders(),
|
|
104
122
|
});
|
|
105
123
|
return this.handleResponse(response);
|
|
106
124
|
}
|
|
@@ -123,7 +141,7 @@ export class BaseClient {
|
|
|
123
141
|
}
|
|
124
142
|
const response = await fetch(url.toString(), {
|
|
125
143
|
method: 'GET',
|
|
126
|
-
headers: this.getHeaders(),
|
|
144
|
+
headers: await this.getHeaders(),
|
|
127
145
|
});
|
|
128
146
|
if (!response.ok) {
|
|
129
147
|
let errorData = null;
|
|
@@ -143,7 +161,7 @@ export class BaseClient {
|
|
|
143
161
|
async post(path, body) {
|
|
144
162
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
145
163
|
method: 'POST',
|
|
146
|
-
headers: this.getHeaders(),
|
|
164
|
+
headers: await this.getHeaders(),
|
|
147
165
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
148
166
|
});
|
|
149
167
|
return this.handleResponse(response);
|
|
@@ -154,7 +172,7 @@ export class BaseClient {
|
|
|
154
172
|
async postFormData(path, formData) {
|
|
155
173
|
// Don't set Content-Type header - browser will set it with boundary
|
|
156
174
|
const headers = {
|
|
157
|
-
'Authorization': `Bearer ${this.
|
|
175
|
+
'Authorization': `Bearer ${await this.resolveBearerToken()}`,
|
|
158
176
|
};
|
|
159
177
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
160
178
|
method: 'POST',
|
|
@@ -169,7 +187,7 @@ export class BaseClient {
|
|
|
169
187
|
async put(path, body) {
|
|
170
188
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
171
189
|
method: 'PUT',
|
|
172
|
-
headers: this.getHeaders(),
|
|
190
|
+
headers: await this.getHeaders(),
|
|
173
191
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
174
192
|
});
|
|
175
193
|
return this.handleResponse(response);
|
|
@@ -180,7 +198,7 @@ export class BaseClient {
|
|
|
180
198
|
async patch(path, body) {
|
|
181
199
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
182
200
|
method: 'PATCH',
|
|
183
|
-
headers: this.getHeaders(),
|
|
201
|
+
headers: await this.getHeaders(),
|
|
184
202
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
185
203
|
});
|
|
186
204
|
return this.handleResponse(response);
|
|
@@ -191,7 +209,7 @@ export class BaseClient {
|
|
|
191
209
|
async httpDelete(path) {
|
|
192
210
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
193
211
|
method: 'DELETE',
|
|
194
|
-
headers: this.getHeaders(),
|
|
212
|
+
headers: await this.getHeaders(),
|
|
195
213
|
});
|
|
196
214
|
return this.handleResponse(response);
|
|
197
215
|
}
|
|
@@ -201,7 +219,7 @@ export class BaseClient {
|
|
|
201
219
|
async postForBlob(path, body) {
|
|
202
220
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
203
221
|
method: 'POST',
|
|
204
|
-
headers: this.getHeaders(),
|
|
222
|
+
headers: await this.getHeaders(),
|
|
205
223
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
206
224
|
});
|
|
207
225
|
if (!response.ok) {
|
|
@@ -223,7 +241,7 @@ export class BaseClient {
|
|
|
223
241
|
async postForStream(path, body) {
|
|
224
242
|
const response = await fetch(`${this.apiUrl}${path}`, {
|
|
225
243
|
method: 'POST',
|
|
226
|
-
headers: this.getHeaders(),
|
|
244
|
+
headers: await this.getHeaders(),
|
|
227
245
|
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
228
246
|
});
|
|
229
247
|
if (!response.ok) {
|
package/dist/client/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/client/base.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0CAA0C;AAC1C,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YACE,OAAe,EACC,MAAe,EACf,IAAa,EACb,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,WAAM,GAAN,MAAM,CAAS;QACf,SAAI,GAAJ,IAAI,CAAS;QACb,WAAM,GAAN,MAA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G,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,EAAE,EAAE;YACpD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,MAAM,IAAI,CAAC,UAAU,EAAE;YAChC,IAAI,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;SAC5D,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,+BAA+B;YAC/B,IAAI,SAAS,GAAyB,IAAI,CAAC;YAC3C,IAAI,CAAC;gBACH,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACpC,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YAED,MAAM,IAAI,YAAY,CACpB,SAAS,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,IAAI,8BAA8B,QAAQ,CAAC,MAAM,EAAE,EACxF,QAAQ,CAAC,MAAM,EACf,SAAS,EAAE,IAAI,CAChB,CAAC;QACJ,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export { VoiceAIError } from './base';
|
|
|
7
7
|
export { AgentClient } from './agents';
|
|
8
8
|
export { AnalyticsClient } from './analytics';
|
|
9
9
|
export { KnowledgeBaseClient } from './knowledge-base';
|
|
10
|
+
export { ManagedToolsClient } from './managed-tools';
|
|
10
11
|
export { PhoneNumberClient } from './phone-numbers';
|
|
11
12
|
export { TTSClient } from './tts';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { VoiceAIError } from './base';
|
|
|
7
7
|
export { AgentClient } from './agents';
|
|
8
8
|
export { AnalyticsClient } from './analytics';
|
|
9
9
|
export { KnowledgeBaseClient } from './knowledge-base';
|
|
10
|
+
export { ManagedToolsClient } from './managed-tools';
|
|
10
11
|
export { PhoneNumberClient } from './phone-numbers';
|
|
11
12
|
export { TTSClient } from './tts';
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/dist/client/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseClient, type BaseClientConfig } from './base';
|
|
2
|
+
import type { GoogleConnectionStatus, GoogleOAuthStartOptions, GoogleOAuthStartResponse } from '../types';
|
|
3
|
+
declare class GoogleManagedToolsClient extends BaseClient {
|
|
4
|
+
constructor(config: BaseClientConfig);
|
|
5
|
+
startOAuth(agentId: string, options?: GoogleOAuthStartOptions): Promise<GoogleOAuthStartResponse>;
|
|
6
|
+
getStatus(agentId: string): Promise<GoogleConnectionStatus>;
|
|
7
|
+
disconnect(agentId: string): Promise<{
|
|
8
|
+
disconnected: boolean;
|
|
9
|
+
agent_id: string;
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare class ManagedToolsClient {
|
|
13
|
+
readonly google: GoogleManagedToolsClient;
|
|
14
|
+
constructor(config: BaseClientConfig);
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=managed-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-tools.d.ts","sourceRoot":"","sources":["../../src/client/managed-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAC3D,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,UAAU,CAAC;AAElB,cAAM,wBAAyB,SAAQ,UAAU;gBACnC,MAAM,EAAE,gBAAgB;IAI9B,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAUrG,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAI3D,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAGxF;AAED,qBAAa,kBAAkB;IAC7B,SAAgB,MAAM,EAAE,wBAAwB,CAAC;gBAErC,MAAM,EAAE,gBAAgB;CAGrC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseClient } from './base';
|
|
2
|
+
class GoogleManagedToolsClient extends BaseClient {
|
|
3
|
+
constructor(config) {
|
|
4
|
+
super(config);
|
|
5
|
+
}
|
|
6
|
+
async startOAuth(agentId, options = {}) {
|
|
7
|
+
return this.post(`/google/${encodeURIComponent(agentId)}/oauth/start`, {
|
|
8
|
+
return_path: options.returnUrl,
|
|
9
|
+
managed_tools: options.managedTools,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async getStatus(agentId) {
|
|
13
|
+
return this.get(`/google/${encodeURIComponent(agentId)}/status`);
|
|
14
|
+
}
|
|
15
|
+
async disconnect(agentId) {
|
|
16
|
+
return this.httpDelete(`/google/${encodeURIComponent(agentId)}/disconnect`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class ManagedToolsClient {
|
|
20
|
+
constructor(config) {
|
|
21
|
+
this.google = new GoogleManagedToolsClient(config);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=managed-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"managed-tools.js","sourceRoot":"","sources":["../../src/client/managed-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAyB,MAAM,QAAQ,CAAC;AAO3D,MAAM,wBAAyB,SAAQ,UAAU;IAC/C,YAAY,MAAwB;QAClC,KAAK,CAAC,MAAM,CAAC,CAAC;IAChB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe,EAAE,UAAmC,EAAE;QACrE,OAAO,IAAI,CAAC,IAAI,CACd,WAAW,kBAAkB,CAAC,OAAO,CAAC,cAAc,EACpD;YACE,WAAW,EAAE,OAAO,CAAC,SAAS;YAC9B,aAAa,EAAE,OAAO,CAAC,YAAY;SACpC,CACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,OAAe;QAC7B,OAAO,IAAI,CAAC,GAAG,CAAyB,WAAW,kBAAkB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,OAAe;QAC9B,OAAO,IAAI,CAAC,UAAU,CAA8C,WAAW,kBAAkB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC3H,CAAC;CACF;AAED,MAAM,OAAO,kBAAkB;IAG7B,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,wBAAwB,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;CACF"}
|
package/dist/client/tts.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export declare class TTSClient extends BaseClient {
|
|
|
148
148
|
/**
|
|
149
149
|
* Clone a voice from a reference audio file
|
|
150
150
|
*
|
|
151
|
-
* Accepts an audio file (MP3, WAV, or
|
|
151
|
+
* Accepts an audio file (MP3, WAV, or M4A, max 7.5MB) and creates
|
|
152
152
|
* a cloned voice. The voice starts in PENDING status and moves to
|
|
153
153
|
* PROCESSING, then AVAILABLE once ready.
|
|
154
154
|
*
|
package/dist/client/tts.js
CHANGED
|
@@ -163,7 +163,7 @@ export class TTSClient extends BaseClient {
|
|
|
163
163
|
/**
|
|
164
164
|
* Clone a voice from a reference audio file
|
|
165
165
|
*
|
|
166
|
-
* Accepts an audio file (MP3, WAV, or
|
|
166
|
+
* Accepts an audio file (MP3, WAV, or M4A, max 7.5MB) and creates
|
|
167
167
|
* a cloned voice. The voice starts in PENDING status and moves to
|
|
168
168
|
* PROCESSING, then AVAILABLE once ready.
|
|
169
169
|
*
|