@voctiv/agent-sdk 0.2.16 → 0.3.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 CHANGED
@@ -136,7 +136,8 @@ const maxAttempts = parseRecallCount(context.dialogParams?.recall_count);
136
136
  - `channel.type` is `"sip"` for telephony and `"ws"` for WebSocket/script-manager sessions. Headless sessions currently expose a synthetic `"ws"` channel; check `context.headless` to detect them.
137
137
  - `channel.params` is the merged runtime parameter map. Treat unknown keys as host-specific.
138
138
  - `channel.createAsr()` creates an ASR handle.
139
- - `channel.audio` controls TTS, raw playback, pre-synthesis, and mixer queues.
139
+ - `channel.createTts()` returns a TTS handle (`tts.say` / `tts.say$` / `tts.presay`) with a reused SSL / WebSocket connection.
140
+ - `channel.audio` controls channel-level TTS, raw playback, pre-synthesis, and mixer queues.
140
141
  - `channel.sip` controls SIP state, pre-answer media, DTMF, hold/mute/hangup, outbound calls, and bridging.
141
142
  - `channel.llm` talks to the Omni LLM backend.
142
143
  - `channel.events` exposes speech, interrupt, termination, WS data message, and media error observables.
@@ -460,7 +461,9 @@ While a bridge is active, `channel.audio.say()` still sends audio only to the A-
460
461
 
461
462
  ## ASR, VAD, And Smart Turn
462
463
 
463
- Create ASR with `channel.createAsr(config?)`.
464
+ Create ASR with `channel.createAsr(config?)`. Prefer creating it once at dialog start so the
465
+ host can warm the ASR TCP/WebSocket (one SSL handshake). A later `createAsr` with the same
466
+ resolved vendor/credentials reuses that channel; `destroy()` closes it.
464
467
 
465
468
  ```ts
466
469
  const asr = await channel.createAsr({
@@ -490,7 +493,7 @@ const asr = await channel.createAsr({
490
493
  - `error$`: runtime errors from the ASR provider (see [Error Handling](#error-handling)).
491
494
  - `pause()` / `resume()` to stop or resume forwarding new audio frames.
492
495
  - `finalize()` to force the current utterance to flush.
493
- - `destroy()` to close connector streams and subscriptions.
496
+ - `destroy()` to close the warm TCP/WS connector and subscriptions.
494
497
 
495
498
  SIP sessions use the call-level telephony VAD when it is available. WS sessions create one VAD/SmartTurn instance for the socket session on the first `createAsr()` call. Headless sessions return an inert ASR handle with empty observables.
496
499
 
@@ -548,8 +551,70 @@ When both `name` (platform key) and explicit `data` are provided, `data` values
548
551
  All audio playback goes through **`channel.audio`** (`ChannelAudio`). There are no top-level
549
552
  `channel.say()` / `channel.play()` shortcuts on `MediaChannel`.
550
553
 
554
+ Create a reusable TTS session with `channel.createTts(config?)` — same pattern as `createAsr`.
555
+ Call `tts.say` / `tts.say$` / `tts.presay` on the handle so synthesis reuses the warmed SSL / streaming WebSocket.
556
+
557
+ ```ts
558
+ const tts = await channel.createTts({
559
+ vendor: 'elevenlabs',
560
+ name: 'elevenlabs-main',
561
+ });
562
+
563
+ await tts.say('Hello', {
564
+ ttsStrategy: 'streaming',
565
+ alias: 'greeting',
566
+ });
567
+
568
+ // Track queue / speaking / done per sentence for one say$ call:
569
+ tts.say$('One. Two.', { alias: 'reply', queue: 0 }).subscribe({
570
+ next: (e) => {
571
+ if (e.state === 'queued') {
572
+ // e.text — full utterance (string) or '' until stream tokens arrive
573
+ }
574
+ if (e.state === 'speaking') {
575
+ // e.sentenceText / e.sentenceIndex — sentence starting playback
576
+ // e.itemAlias — e.g. reply-0
577
+ }
578
+ if (e.state === 'done') {
579
+ // that sentence finished; e.sentenceText / e.sentenceIndex / e.itemAlias
580
+ }
581
+ if (e.state === 'cancelled') {
582
+ // audio.stop / destroy; e.text so far
583
+ }
584
+ },
585
+ complete: () => {
586
+ // whole say$ finished (all sentences)
587
+ },
588
+ error: (err) => {
589
+ // MediaError — synthesis/playback failed
590
+ },
591
+ });
592
+
593
+ // Later turns reuse the same WebSocket:
594
+ await tts.say(tokenStream, {
595
+ ttsStrategy: 'streaming',
596
+ alias: 'reply-2',
597
+ });
598
+
599
+ tts.destroy();
600
+ ```
601
+
602
+ `tts.say()` stays a `Promise` (await until finished). `tts.say$()` returns an `Observable`
603
+ of utterance lifecycle events for that call only (`queued` → (`speaking` → `done`)×N /
604
+ `cancelled`, then complete). `done` is per sentence/phrase finishing playback; use the
605
+ Observable `complete` callback for the end of the whole `say$` call. Synthesis failures
606
+ terminate the Observable via **error** (`MediaError`), and are also mirrored on
607
+ `tts.error$` / `channel.events.error$`. `channel.audio.say` remains Promise-only.
608
+
609
+ You can still use `channel.audio.say(..., { tts })` if you prefer the channel API; a matching
610
+ pre-warmed session is also reused when vendor+config align.
611
+
551
612
  | Method | Purpose |
552
613
  | --- | --- |
614
+ | `channel.createTts(config?)` | Pre-warm a TTS connector / streaming socket; returns `TtsHandle` |
615
+ | `tts.say(textOrObservable, options?)` | Synthesize via the handle's cached connection (`Promise`) |
616
+ | `tts.say$(textOrObservable, options?)` | Same path with per-utterance status events (`Observable`) |
617
+ | `tts.presay(text, options?)` | Pre-synthesize into the host TTS cache via the handle |
553
618
  | `channel.audio.say(textOrObservable, options?)` | Synthesize text with TTS and play on a mixer queue |
554
619
  | `channel.audio.play(source, options?)` | Play raw audio (URL, path, or platform phrase record) |
555
620
  | `channel.audio.presay(text, options?)` | Pre-synthesize TTS into the host cache (no playback) |
@@ -850,7 +915,7 @@ channel.events.error$.subscribe((err) => {
850
915
  | --- | --- | --- |
851
916
  | `source` | `'asr' \| 'tts' \| 'sip' \| 'channel' \| 'llm'` | Which subsystem produced the error. |
852
917
  | `phase` | `'create' \| 'start' \| 'stream' \| 'playback' \| 'finalize' \| 'destroy'?` | Lifecycle phase where the error happened. |
853
- | `operation` | `string?` | Public SDK operation, e.g. `createAsr`, `audio.say`, or `audio.play`. |
918
+ | `operation` | `string?` | Public SDK operation, e.g. `createAsr`, `createTts`, `audio.say`, or `audio.play`. |
854
919
  | `recoverable` | `boolean?` | Whether the runtime can keep the session alive after this error. |
855
920
  | `handleId` | `string?` | ASR handle id when the error belongs to a recognizer instance. |
856
921
  | `queue` | `number?` | Mixer queue index when the error belongs to an audio operation. |
@@ -1476,6 +1541,7 @@ Important fields:
1476
1541
  - `context.dialogUuid`: current dialog UUID.
1477
1542
  - `context.callerId` / `context.msisdn`: caller identity.
1478
1543
  - `context.destinationNumber`: called number.
1544
+ - `context.trunkId` / `context.trunkName`: LE trunk for this dialog/call (snapshot; name from `trunk` table).
1479
1545
  - `context.language` / `context.lang`: language selected for the run.
1480
1546
  - `context.flag`: business flag.
1481
1547
  - `context.initialData`: shallow snapshot of params at script start.
@@ -1528,6 +1594,7 @@ Headless channels are for offline, queue, or messaging sessions:
1528
1594
  - SIP methods are no-ops, except `makeCall()` and `bridge()`, which throw: there is no real leg to
1529
1595
  create, and a silent no-op would hide the mistake.
1530
1596
  - `createAsr()` returns an inert handle whose observables complete immediately.
1597
+ - `createTts()` returns an inert handle (no vendor connection is opened).
1531
1598
  - LLM, NLU, messaging, platform calls, dialog state, and `env$` still work.
1532
1599
 
1533
1600
  Use `context.headless` plus `getScriptPhase(context)` when a script must behave differently without a
package/dist/index.d.ts CHANGED
@@ -13,6 +13,7 @@
13
13
  * When the host loads platform credential catalogs, **`channel.params.authentication_data`**
14
14
  * may contain named ASR/TTS key rows for the current dialog agent and company. Use:
15
15
  * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
16
+ * - {@link import('./types/tts-handle').TtsConfig.name} or **`data.name`** on **`createTts`**
16
17
  * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
17
18
  *
18
19
  * Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
@@ -39,6 +40,7 @@ export type { ChannelLlm, LlmOptions, LlmStreamChunk, ExtractOptions, Persistent
39
40
  export type { ChannelSip, SipState, SipProgressEvent, SipInviteHeaders, ParsedSdpDetails, } from './types/sip';
40
41
  export type { MediaError } from './types/errors';
41
42
  export type { AsrHandle, AsrConfig, AsrVadConfig, AsrSmartTurnConfig } from './types/asr-handle';
43
+ export type { TtsHandle, TtsConfig, TtsSayOptions, TtsPresayOptions, TtsUtteranceEvent, TtsUtteranceCancelReason, } from './types/tts-handle';
42
44
  export type { MixerQueueControl, PlayOptions, PresayOptions, PreloadOptions, TtsStrategy, TtsVendor } from './types/mixer';
43
45
  export type { LegacyPhraseRecord, LegacyGetRecordsParams, CacheOptions, } from './types/legacy-phrase';
44
46
  export { LEGACY_PHRASE_RECORD_BRAND, isLegacyPhraseRecord, } from './types/legacy-phrase';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE/D,YAAY,EACV,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,YAAY,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,kBAAkB,CAAC;AAE1B,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAA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YAAY,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,GACd,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,UAAU,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACjG,YAAY,EACV,SAAS,EACT,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3H,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,YAAY,EACV,SAAS,EACT,OAAO,EACP,SAAS,EACT,WAAW,GACZ,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@
14
14
  * When the host loads platform credential catalogs, **`channel.params.authentication_data`**
15
15
  * may contain named ASR/TTS key rows for the current dialog agent and company. Use:
16
16
  * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
17
+ * - {@link import('./types/tts-handle').TtsConfig.name} or **`data.name`** on **`createTts`**
17
18
  * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
18
19
  *
19
20
  * Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAEH,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAerB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AAavB,yCAAmD;AAA1C,2GAAA,iBAAiB,OAAA;AAgC1B,uDAG+B;AAF7B,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA;AAUtB,+CAA2E;AAAlE,gHAAA,gBAAgB,OAAA;AAAE,uHAAA,uBAAuB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAEH,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAerB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AAavB,yCAAmD;AAA1C,2GAAA,iBAAiB,OAAA;AAwC1B,uDAG+B;AAF7B,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA;AAUtB,+CAA2E;AAAlE,gHAAA,gBAAgB,OAAA;AAAE,uHAAA,uBAAuB,OAAA"}
@@ -102,9 +102,13 @@ export interface AsrConfig {
102
102
  /**
103
103
  * Live speech recognition session returned by {@link import('./media-channel').MediaChannel.createAsr}.
104
104
  *
105
+ * Call **`createAsr` early** to warm the ASR TCP/WebSocket (SSL handshake once per
106
+ * dialog + vendor + credentials). A second `createAsr` with the same resolved config
107
+ * reuses that channel instead of opening another socket. Call **`destroy()`** when done
108
+ * (e.g. on `channel.events.terminated$`) to release the connector.
109
+ *
105
110
  * Subscribe to **`partial$`** / **`result$`** for transcripts; wire **`speechStart$`** /
106
- * **`speechEnd$`** / **`interrupt$`** for barge-in and UI. Call **`destroy()`** when done
107
- * (e.g. on `channel.events.terminated$`) to release connector and subscriptions.
111
+ * **`speechEnd$`** / **`interrupt$`** for barge-in and UI.
108
112
  *
109
113
  * If connector creation fails, SIP/WS return a degraded handle: VAD observables still
110
114
  * mirror the channel where possible, but `partial$` and `result$` do not emit real STT.
@@ -1 +1 @@
1
- {"version":3,"file":"asr-handle.d.ts","sourceRoot":"","sources":["../../src/types/asr-handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,0DAA0D;IAC1D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,oGAAoG;IACpG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,8EAA8E;IAC9E,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IACjC,+EAA+E;IAC/E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAC;I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le } from './asr-handle';
3
+ import type { TtsConfig, TtsHandle } from './tts-handle';
3
4
  import type { DataMessage } from './events';
4
5
  import type { MixerQueueControl, PlayOptions, PresayOptions, PreloadOptions } from './mixer';
5
6
  import type { LegacyPhraseRecord } from './legacy-phrase';
@@ -153,7 +154,7 @@ export interface MediaChannel {
153
154
  * Relevant to ASR/TTS when **Voctiv platform** compatibility is on (host-dependent keys), for example:
154
155
  * - **`asrVendor`**, **`ttsVendor`**, **`asrConfig`**, **`ttsConfig`**
155
156
  * - **`defaultAsrName`**, **`defaultTtsName`**: default **`key_storage.name`** when the script
156
- * omits **`name`** on {@link AsrConfig} / {@link PlayOptions}
157
+ * omits **`name`** on {@link AsrConfig} / {@link TtsConfig} / {@link PlayOptions}
157
158
  * - **`authentication_data`**: may include **`legacyAsrKeysByName`**, **`legacyTtsKeysByName`**
158
159
  * (built from LE DB for this dialog's agent + company)
159
160
  *
@@ -161,11 +162,13 @@ export interface MediaChannel {
161
162
  */
162
163
  readonly params: Record<string, unknown>;
163
164
  /**
164
- * Create a speech recognizer for this session.
165
+ * Create (or warm) a speech recognizer for this session so recognition can reuse one
166
+ * TCP/WebSocket (one SSL handshake) for the dialog + vendor + credentials.
165
167
  *
166
168
  * SIP channels feed remote RTP audio. WS channels feed socket `audio` frames and can
167
169
  * create a per-session VAD on first ASR creation. Headless channels return an inert
168
- * handle with empty observables.
170
+ * handle with empty observables. A second call with the same resolved config returns
171
+ * the existing warm handle.
169
172
  *
170
173
  * @param config - Optional {@link AsrConfig}: **`vendor`**, **`name`** (storage row), **`language`**,
171
174
  * **`data`** overlays, VAD / smart-turn tuning.
@@ -173,6 +176,24 @@ export interface MediaChannel {
173
176
  * If connector creation fails, SIP/WS return a degraded handle with VAD observables but no STT results.
174
177
  */
175
178
  createAsr(config?: AsrConfig): Promise<AsrHandle>;
179
+ /**
180
+ * Create (or warm) a TTS connector for this session so later `audio.say` / `audio.presay`
181
+ * can reuse the SSL / WebSocket connection.
182
+ *
183
+ * For streaming-capable vendors (e.g. ElevenLabs with `ttsStrategy: 'streaming'`), the host
184
+ * opens the streaming socket during this call. For batch HTTP vendors, the connector instance
185
+ * is registered in the dialog-scoped factory (keep-alive pool).
186
+ *
187
+ * Prefer calling {@link TtsHandle.say} / {@link TtsHandle.presay} on the returned handle
188
+ * (same pattern as {@link AsrHandle}). You may also pass the handle as {@link PlayOptions.tts}
189
+ * to `channel.audio.say` / `presay`, or omit it when a later `say` resolves to the same
190
+ * vendor+config — the host will reuse a matching session.
191
+ *
192
+ * @param config - Optional {@link TtsConfig}: **`vendor`**, **`name`** (storage row), **`data`** overlays.
193
+ * @returns A handle you should {@link TtsHandle.destroy} when you no longer need the connection.
194
+ * If connector creation fails, SIP/WS return a degraded handle (synthesis falls back to ephemeral).
195
+ */
196
+ createTts(config?: TtsConfig): Promise<TtsHandle>;
176
197
  /** Push synthetic ASR results (testing / WS debug). No-op on headless channels. */
177
198
  readonly textInput: TextInput;
178
199
  readonly audio: ChannelAudio;
@@ -1 +1 @@
1
- {"version":3,"file":"media-channel.d.ts","sourceRoot":"","sources":["../../src/types/media-channel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,M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,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IAEzB,6GAA6G;IAC7G,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,wFAAwF;IACxF,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -1,5 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import type { CacheOptions } from './legacy-phrase';
3
+ import type { TtsHandle } from './tts-handle';
3
4
  /**
4
5
  * How TTS audio is chunked and fed to the mixer.
5
6
  *
@@ -74,8 +75,16 @@ export interface PlayOptions {
74
75
  /**
75
76
  * Force a specific TTS vendor for this call, overriding **`channel.params.ttsVendor`**.
76
77
  * Ignored for **`play()`** when the source is raw audio (no synthesis).
78
+ * When {@link tts} is set, the handle's resolved vendor/config take precedence.
77
79
  */
78
80
  ttsVendor?: TtsVendor;
81
+ /**
82
+ * Pre-warmed TTS session from {@link import('./media-channel').MediaChannel.createTts}.
83
+ * Reuses the cached connector / streaming WebSocket so synthesis skips a fresh SSL handshake.
84
+ * When set, the handle's resolved vendor and connector config are used (overrides
85
+ * {@link ttsVendor} / {@link name} / {@link ttsConfig} for credential resolution).
86
+ */
87
+ tts?: TtsHandle;
79
88
  /**
80
89
  * logic-executor **`key_storage.name`**: use **`authentication_data.legacyTtsKeysByName[name]`**
81
90
  * for credentials. Overrides **`defaultTtsName`** on the channel.
@@ -107,6 +116,11 @@ export interface PlayOptions {
107
116
  */
108
117
  export interface PresayOptions {
109
118
  ttsVendor?: TtsVendor;
119
+ /**
120
+ * Pre-warmed TTS session from {@link import('./media-channel').MediaChannel.createTts}.
121
+ * Same reuse semantics as {@link PlayOptions.tts}.
122
+ */
123
+ tts?: TtsHandle;
110
124
  name?: string;
111
125
  ttsConfig?: Record<string, unknown>;
112
126
  ttsStrategy?: TtsStrategy;
@@ -1 +1 @@
1
- {"version":3,"file":"mixer.d.ts","sourceRoot":"","sources":["../../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7D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAC;IAEf,mEAAmE;IACnE,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,yFAAyF;IACzF,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3C;oFACgF;IAChF,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAEvC;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,uDAAuD;IACvD,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -59,6 +59,21 @@ export interface ScriptDialogContext {
59
59
  callerId: string;
60
60
  /** Called number (DID / destination for inbound calls). */
61
61
  destinationNumber: string;
62
+ /**
63
+ * LE trunk id for this dialog/call — snapshot at script start.
64
+ *
65
+ * Resolved from `call.trunk_id`, inbound `X-Trunk-Id`, `dialog.params.trunk_id`,
66
+ * then `agent.trunk_id`. Omitted when no trunk is configured.
67
+ */
68
+ trunkId?: number;
69
+ /**
70
+ * LE `trunk.name` for {@link trunkId}, resolved by the host at script start.
71
+ *
72
+ * Available in online and headless runs when the platform trunk table is reachable.
73
+ * Not a SIP wire header — for inbound id-only signalling use
74
+ * `channel.sip.inviteSipHeaders['X-Trunk-Id']`.
75
+ */
76
+ trunkName?: string;
62
77
  /** Script record ID in the system. */
63
78
  scriptId: string;
64
79
  /** Human-readable script name. */
@@ -1 +1 @@
1
- {"version":3,"file":"script-context.d.ts","sourceRoot":"","sources":["../../src/types/script-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM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AE,aAAa,CAAC;IAExB,yDAAyD;IACzD,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,wEAAwE;IACxE,WAAW,IAAI,MAAM,CAAC;IACtB,4CAA4C;IAC5C,iBAAiB,IAAI,MAAM,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB,aAAa,GACb,QAAQ,GACR,oBAAoB,GACpB,mBAAmB,GACnB,WAAW,GACX,QAAQ,GACR,gBAAgB,CAAC;AAarB;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,WAAW,CAcxE;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,uEAAuE;IACvE,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,YAAY;IACzD,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B"}
1
+ {"version":3,"file":"script-context.d.ts","sourceRoot":"","sources":["../../src/types/script-context.ts"],"names":[],"mappings":"AAAA,OAAO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AAC;AAC1B,CAAC"}
1
+ {"version":3,"file":"script-context.js","sourceRoot":"","sources":["../../src/types/script-context.ts"],"names":[],"mappings":";;AA4RA,wCAcC;AApCD,MAAM,+BAA+B,GAAG,IAAI,GAAG,CAAC;IAC9C,iBAAiB;IACjB,oBAAoB;IACpB,cAAc;CACf,CAAC,CAAC;AACH,MAAM,8BAA8B,GAAG,IAAI,GAAG,CAAC;IAC7C,gBAAgB;IAChB,mBAAmB;CACpB,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE7D;;;;;;;;;;GAUG;AACH,SAAgB,cAAc,CAAC,OAA4B;IACzD,IAAI,CAAC,OAAO,CAAC,QAAQ;QAAE,OAAO,QAAQ,CAAC;IAEvC,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;IAE1D,IAAI,+BAA+B,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,oBAAoB,CAAC;IACzE,IAAI,8BAA8B,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,mBAAmB,CAAC;IACvE,IAAI,mBAAmB,CAAC,GAAG,CAAC,EAAE,CAAC;QAAE,OAAO,QAAQ,CAAC;IACjD,IAAI,EAAE,KAAK,yBAAyB,IAAI,OAAO,CAAC,cAAc;QAC5D,OAAO,WAAW,CAAC;IAErB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IAEnE,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,194 @@
1
+ import type { Observable } from 'rxjs';
2
+ import type { MediaError } from './errors';
3
+ import type { PlayOptions, PresayOptions } from './mixer';
4
+ /**
5
+ * Arguments for {@link import('./media-channel').MediaChannel.createTts}.
6
+ *
7
+ * Mirrors {@link import('./asr-handle').AsrConfig} credential selection for TTS:
8
+ * when Voctiv platform compatibility is on, **`name`** selects a row from
9
+ * **`authentication_data.legacyTtsKeysByName`**. You may also set the same selector
10
+ * as **`data.name`** (stripped before vendor params are built).
11
+ *
12
+ * Call **`createTts`** early in the dialog to open / warm the vendor connection
13
+ * (HTTP keep-alive pool or streaming WebSocket) so later {@link TtsHandle.say}
14
+ * / {@link TtsHandle.say$} / {@link TtsHandle.presay} calls reuse it instead of
15
+ * paying SSL handshake latency on every utterance.
16
+ */
17
+ export interface TtsConfig {
18
+ /**
19
+ * TTS vendor / engine hint, e.g. `"elevenlabs"`, `"google"`, `"azure"`, `"voctiv"`.
20
+ * Resolved via ScriptEngine vendor aliases. If you set **`name`** but omit **`vendor`**,
21
+ * the runtime may infer vendor from the key row's **`platform`** in the catalog.
22
+ */
23
+ vendor?: string;
24
+ /**
25
+ * logic-executor **`key_storage.name`** for this dialog's agent + company. Selects credentials
26
+ * from **`authentication_data.legacyTtsKeysByName[name]`** when Voctiv platform PostgreSQL key auth is enabled.
27
+ * Overrides channel **`defaultTtsName`**.
28
+ */
29
+ name?: string;
30
+ /**
31
+ * Vendor-specific connection parameters (voice id, model, `output_format`, nested JSON, …).
32
+ * Merged last over channel defaults and catalog credentials so the script can override
33
+ * per session. Primitives are stringified; objects and arrays are JSON-serialized.
34
+ *
35
+ * Do not rely on **`name`** here for third-party "model name" fields — the runtime consumes
36
+ * it as the storage row selector and removes it before vendor config is built.
37
+ */
38
+ data?: Record<string, unknown>;
39
+ }
40
+ /**
41
+ * Playback options for {@link TtsHandle.say} / {@link TtsHandle.say$}.
42
+ *
43
+ * Vendor / credentials come from {@link import('./media-channel').MediaChannel.createTts};
44
+ * only mixer and strategy fields apply here.
45
+ */
46
+ export type TtsSayOptions = Omit<PlayOptions, 'tts' | 'ttsVendor' | 'name' | 'ttsConfig'>;
47
+ /**
48
+ * Options for {@link TtsHandle.presay}.
49
+ *
50
+ * Vendor / credentials come from {@link import('./media-channel').MediaChannel.createTts}.
51
+ */
52
+ export type TtsPresayOptions = Omit<PresayOptions, 'tts' | 'ttsVendor' | 'name' | 'ttsConfig'>;
53
+ /** Why a tracked utterance was cancelled before natural completion. */
54
+ export type TtsUtteranceCancelReason = 'stop' | 'destroy';
55
+ /**
56
+ * Lifecycle events for one {@link TtsHandle.say$} invocation.
57
+ *
58
+ * Typical sequence (sentence strategy):
59
+ * `queued` → (`speaking` → `done`)×N then Observable **complete**.
60
+ * `done` means one sentence/phrase finished playback (not the whole `say$` call).
61
+ * Single-item / streaming strategy: one `speaking` → one `done` then **complete**.
62
+ * On barge-in / `audio.stop`: `queued` → (`speaking`?) → `cancelled` then **complete**.
63
+ * On synthesis failure: `queued` → (`speaking`?) then the Observable **errors** with
64
+ * {@link MediaError} (also mirrored on {@link TtsHandle.error$} / `channel.events.error$`).
65
+ */
66
+ export type TtsUtteranceEvent = {
67
+ state: 'queued';
68
+ alias: string;
69
+ queue: number;
70
+ /**
71
+ * Full utterance text known so far.
72
+ * Plain string input: complete text. Token stream: grows as chunks arrive
73
+ * (initial `queued` may have `text: ''`).
74
+ */
75
+ text: string;
76
+ } | {
77
+ state: 'speaking';
78
+ alias: string;
79
+ queue: number;
80
+ /** Full utterance text accumulated so far (stream) or the whole input (string). */
81
+ text: string;
82
+ /**
83
+ * Text of the sentence/segment currently starting playback when the host
84
+ * uses sentence-split aliases (`alias-0`, `alias-1`, …).
85
+ * For a single-item utterance (streaming strategy / exact alias) this equals {@link text}.
86
+ */
87
+ sentenceText: string;
88
+ /** Index of the sentence segment (`0` for `alias-0`), when applicable. */
89
+ sentenceIndex?: number;
90
+ /** Concrete mixer item alias (may be `alias-0` for sentence-split TTS). */
91
+ itemAlias?: string;
92
+ } | {
93
+ state: 'done';
94
+ alias: string;
95
+ queue: number;
96
+ /** Full utterance text accumulated so far (stream) or the whole input (string). */
97
+ text: string;
98
+ /**
99
+ * Text of the sentence/segment that just finished playback.
100
+ * Same rules as {@link TtsUtteranceEvent} `speaking.sentenceText`.
101
+ */
102
+ sentenceText: string;
103
+ /** Index of the sentence segment (`0` for `alias-0`), when applicable. */
104
+ sentenceIndex?: number;
105
+ /** Concrete mixer item alias that finished. */
106
+ itemAlias?: string;
107
+ } | {
108
+ state: 'cancelled';
109
+ alias: string;
110
+ queue: number;
111
+ reason: TtsUtteranceCancelReason;
112
+ /** Accumulated text at cancel time. */
113
+ text: string;
114
+ };
115
+ /**
116
+ * Pre-warmed TTS session returned by {@link import('./media-channel').MediaChannel.createTts}.
117
+ *
118
+ * Use **`say`** / **`say$`** / **`presay`** on this handle (same idea as
119
+ * {@link import('./asr-handle').AsrHandle} methods) so synthesis reuses the cached
120
+ * connector / streaming WebSocket. Call **`destroy()`** when done
121
+ * (e.g. on `channel.events.terminated$`) to release the session.
122
+ *
123
+ * You may still pass the handle as {@link import('./mixer').PlayOptions.tts} to
124
+ * `channel.audio.say` / `presay` if needed.
125
+ *
126
+ * If connector creation fails, SIP/WS return a degraded handle: `say`/`say$`/`presay` fall back
127
+ * to an ephemeral connection, and the creation failure is reported on
128
+ * {@link import('./media-channel').ChannelEvents.error$}.
129
+ *
130
+ * ```ts
131
+ * const tts = await channel.createTts({ name: 'elevenlabs-main' });
132
+ * tts.error$.subscribe(err => console.log('TTS error:', err.message));
133
+ *
134
+ * await tts.say('Hello', { alias: 'greeting' });
135
+ *
136
+ * tts.say$('Next', { alias: 'reply' }).subscribe({
137
+ * next: (e) => { if (e.state === 'speaking') console.log('now playing', e.alias); },
138
+ * error: (err) => console.log('TTS failed', err.message),
139
+ * });
140
+ *
141
+ * tts.destroy();
142
+ * ```
143
+ */
144
+ export interface TtsHandle {
145
+ /** Opaque id for this pre-warmed TTS session. */
146
+ readonly id: string;
147
+ /**
148
+ * Runtime errors from the TTS provider for this session (auth failures, disconnects, etc.).
149
+ *
150
+ * A degraded handle (returned when connector creation itself failed) has an inert `error$`
151
+ * that never emits — the creation failure is reported on {@link import('./media-channel').ChannelEvents.error$} instead.
152
+ */
153
+ readonly error$: Observable<MediaError>;
154
+ /**
155
+ * Synthesize and play text on a mixer queue, reusing this session's connector.
156
+ *
157
+ * Resolves when playback of this invocation has finished (or was aborted).
158
+ * For per-utterance lifecycle (`queued` / `speaking` / `done` / …) use {@link say$}.
159
+ */
160
+ say(input: string | Observable<string>, options?: TtsSayOptions): Promise<void>;
161
+ /**
162
+ * Same synthesis path as {@link say}, but emits {@link TtsUtteranceEvent} for this utterance.
163
+ *
164
+ * Only available on handles from {@link import('./media-channel').MediaChannel.createTts}
165
+ * (not on `channel.audio.say`). Emits `done` per finished sentence; Observable **completes**
166
+ * when the whole call ends (or after `cancelled`). Synthesis failures go to the Observable
167
+ * **error** channel as {@link MediaError}.
168
+ *
169
+ * ```ts
170
+ * tts.say$('One. Two.', { alias: 'greet', queue: 0 }).subscribe({
171
+ * next: (e) => {
172
+ * switch (e.state) {
173
+ * case 'queued': break; // e.text — full string (or '' for live stream)
174
+ * case 'speaking': break; // e.sentenceText — sentence starting playback
175
+ * case 'done': break; // e.sentenceText — that sentence finished
176
+ * case 'cancelled': break; // stop / destroy
177
+ * }
178
+ * },
179
+ * complete: () => {}, // whole say$ finished
180
+ * error: (err: MediaError) => console.log('TTS failed', err.message),
181
+ * });
182
+ * ```
183
+ */
184
+ say$(input: string | Observable<string>, options?: TtsSayOptions): Observable<TtsUtteranceEvent>;
185
+ /**
186
+ * Pre-synthesize text into the host TTS cache using this session's connector.
187
+ *
188
+ * Same behaviour as {@link import('./media-channel').ChannelAudio.presay}.
189
+ */
190
+ presay(text: string, options?: TtsPresayOptions): Promise<void>;
191
+ /** Tear down the cached connector / streaming socket. Idempotent-safe on well-behaved hosts. */
192
+ destroy(): void;
193
+ }
194
+ //# sourceMappingURL=tts-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts-handle.d.ts","sourceRoot":"","sources":["../../src/types/tts-handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,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AM,CAAC;IACd,mFAAmF;IACnF,IAAI,EAAE,MAAM,CAAC;IACb;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACD;IACE,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,wBAAwB,CAAC;IACjC,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;CACd,CAAA;AAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,SAAS;IACxB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAExC;;;;;OAKG;IACH,GAAG,CACD,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CACF,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,aAAa,GACtB,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAEjC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE,gGAAgG;IAChG,OAAO,IAAI,IAAI,CAAC;CACjB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=tts-handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tts-handle.js","sourceRoot":"","sources":["../../src/types/tts-handle.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voctiv/agent-sdk",
3
- "version": "0.2.16",
3
+ "version": "0.3.0",
4
4
  "description": "Voctiv TypeScript agent SDK: defineScript and platform types for the voice/dialog scripting runtime.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "",