@voctiv/agent-sdk 0.2.11 → 0.2.12
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 +297 -50
- package/dist/index.d.ts +11 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -12
- package/dist/index.js.map +1 -1
- package/dist/types/media-channel.d.ts +1 -1
- package/dist/types/mixer.d.ts +2 -1
- package/dist/types/mixer.d.ts.map +1 -1
- package/dist/types/script-context.d.ts +3 -2
- package/dist/types/script-context.d.ts.map +1 -1
- package/dist/types/script-context.js.map +1 -1
- package/dist/types/sip.d.ts +2 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @voctiv/agent-sdk
|
|
2
2
|
|
|
3
|
-
TypeScript SDK for
|
|
3
|
+
TypeScript SDK for voice and dialog scripts.
|
|
4
4
|
|
|
5
|
-
The package exports
|
|
5
|
+
The package exports `defineScript()` and types for media channels, SIP, ASR, TTS, LLM, dialog context, logging, and platform APIs.
|
|
6
6
|
|
|
7
|
-
The SDK
|
|
7
|
+
The SDK describes the objects injected into your script by the host runtime; it does not open calls or run services itself.
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
@@ -121,7 +121,7 @@ For inbound calls, the script controls this explicitly:
|
|
|
121
121
|
3. Use `channel.audio.say()`, `channel.audio.play()`, `channel.createAsr()`, or `channel.sip.sendDtmf()` normally.
|
|
122
122
|
4. Call `channel.sip.answer()` when you want to send the final `200 OK`.
|
|
123
123
|
|
|
124
|
-
For outbound calls, pre-answer is controlled by the remote side. If the remote endpoint sends `183 Session Progress` with SDP,
|
|
124
|
+
For outbound calls, pre-answer is controlled by the remote side. If the remote endpoint sends `183 Session Progress` with SDP, the host runtime moves the call to `early`. If it answers directly, `waitForEarly()` resolves when the call becomes `active`.
|
|
125
125
|
|
|
126
126
|
`early` is a media-ready state, not a final answer state. `answer()` is still the explicit transition that sends final `200 OK` for inbound calls. External billing behavior depends on the carrier.
|
|
127
127
|
|
|
@@ -186,7 +186,37 @@ If the call terminates before media becomes available, deferred audio resolves a
|
|
|
186
186
|
- `makeCall()` to create an outbound SIP B-leg from the main SIP channel.
|
|
187
187
|
- `bridge(other)` to cross-connect two SIP channels.
|
|
188
188
|
|
|
189
|
-
`makeCall()` and `bridge()` are supported
|
|
189
|
+
`makeCall()` and `bridge()` are supported on SIP channels. The returned B-leg is a full
|
|
190
|
+
`MediaChannel` with the same API as the main channel. WS and headless channels do not create real SIP legs.
|
|
191
|
+
|
|
192
|
+
### `channel.sip` Reference
|
|
193
|
+
|
|
194
|
+
SIP-only unless noted. WS/headless: most methods are no-ops; `state` behaves as synthetic `active`.
|
|
195
|
+
|
|
196
|
+
| Member | Description |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| `state` | Sync getter: `idle` \| `ringing` \| `early` \| `active` \| `holding` \| `terminated` |
|
|
199
|
+
| `isAnswered` | `true` after 200 OK (outbound received / inbound sent via `answer()`) |
|
|
200
|
+
| `state$` | Emits on every state transition |
|
|
201
|
+
| `progress$` | SIP 1xx provisional responses (`SipProgressEvent`) |
|
|
202
|
+
| `early$` | Emits once when RTP is up before final answer |
|
|
203
|
+
| `answered$` | Emits once on 200 OK |
|
|
204
|
+
| `dtmf$` | Remote DTMF digits (`DtmfEvent`: `digit`, `duration`) |
|
|
205
|
+
| `sipInfo$` | Raw SIP INFO messages (`SipInfo`) |
|
|
206
|
+
| `sipSignal$` | Low-level SIP stack events (`SipSignal`) |
|
|
207
|
+
| `sendProgress()` | Inbound: send 183 Session Progress → `early` |
|
|
208
|
+
| `waitForEarly()` | Await `early` or `active` (Promise) |
|
|
209
|
+
| `waitForAnswer()` | Await final 200 OK (Promise) |
|
|
210
|
+
| `answer()` | Inbound: send final 200 OK → `active` |
|
|
211
|
+
| `sendDtmf(digit, duration?)` | Send DTMF tone |
|
|
212
|
+
| `sendInfo(contentType, body)` | Send SIP INFO |
|
|
213
|
+
| `hold()` / `unhold()` | SIP hold |
|
|
214
|
+
| `mute()` / `unmute()` | Suppress local outgoing audio |
|
|
215
|
+
| `hangup()` | Terminate call |
|
|
216
|
+
| `makeCall(opts)` | Outbound B-leg (`MediaChannel`); `sipUri` or `msisdn` |
|
|
217
|
+
| `bridge(other)` | Cross-connect two SIP calls; returns teardown `() => void` |
|
|
218
|
+
|
|
219
|
+
Prefer `dtmf$` over `sipInfo$` for DTMF. Prefer `state$` / `early$` / `answered$` over raw `sipSignal$` unless you need low-level SIP details.
|
|
190
220
|
|
|
191
221
|
### SIP Bridge
|
|
192
222
|
|
|
@@ -204,7 +234,7 @@ await bLeg.sip.waitForAnswer();
|
|
|
204
234
|
const teardown = channel.sip.bridge(bLeg);
|
|
205
235
|
```
|
|
206
236
|
|
|
207
|
-
|
|
237
|
+
You can pass only `msisdn` instead of `sipUri`. The host resolves the SIP URI from agent and trunk settings and applies trunk caller-id options when configured.
|
|
208
238
|
|
|
209
239
|
```ts
|
|
210
240
|
const bLeg = await channel.sip.makeCall({
|
|
@@ -215,7 +245,7 @@ await bLeg.sip.waitForAnswer();
|
|
|
215
245
|
const teardown = channel.sip.bridge(bLeg);
|
|
216
246
|
```
|
|
217
247
|
|
|
218
|
-
|
|
248
|
+
Pass `channel` as a trunk-name override when selecting which outbound trunk to use:
|
|
219
249
|
|
|
220
250
|
```ts
|
|
221
251
|
const bLeg = await channel.sip.makeCall({
|
|
@@ -304,7 +334,7 @@ const asr = await channel.createAsr({
|
|
|
304
334
|
`AsrHandle` exposes:
|
|
305
335
|
|
|
306
336
|
- `result$`: finalized utterances.
|
|
307
|
-
- `partial$`: streaming partial hypotheses
|
|
337
|
+
- `partial$`: streaming partial hypotheses as `{ text, isFinal }`.
|
|
308
338
|
- `speechStart$` / `speechEnd$`: VAD speech boundaries.
|
|
309
339
|
- `interrupt$`: barge-in / interrupt events where the host supports them.
|
|
310
340
|
- `vadProbability$`: normalized VAD probability when available.
|
|
@@ -349,9 +379,9 @@ Each vendor connector accepts its native parameter names:
|
|
|
349
379
|
|
|
350
380
|
All vendors also accept the env-style names (`AZURE_SPEECH_KEY`, `ELEVENLABS_API_KEY`, etc.) for backwards compatibility, but vendor-native names are checked first and are preferred.
|
|
351
381
|
|
|
352
|
-
###
|
|
382
|
+
### Platform ASR Key Selection
|
|
353
383
|
|
|
354
|
-
|
|
384
|
+
When platform credential catalogs are enabled, select ASR keys by **`name`**:
|
|
355
385
|
|
|
356
386
|
```ts
|
|
357
387
|
const asr = await channel.createAsr({
|
|
@@ -360,12 +390,26 @@ const asr = await channel.createAsr({
|
|
|
360
390
|
});
|
|
361
391
|
```
|
|
362
392
|
|
|
363
|
-
The
|
|
393
|
+
The host resolves credentials from `channel.params.authentication_data` for the current dialog agent and company. If `name` is omitted, `channel.params.defaultAsrName` may be used.
|
|
364
394
|
|
|
365
395
|
When both `name` (platform key) and explicit `data` are provided, `data` values win — they are applied last and override anything resolved from the platform.
|
|
366
396
|
|
|
367
397
|
## TTS, Playback, And Mixer Queues
|
|
368
398
|
|
|
399
|
+
All audio playback goes through **`channel.audio`** (`ChannelAudio`). There are no top-level
|
|
400
|
+
`channel.say()` / `channel.play()` shortcuts on `MediaChannel`.
|
|
401
|
+
|
|
402
|
+
| Method | Purpose |
|
|
403
|
+
| --- | --- |
|
|
404
|
+
| `channel.audio.say(textOrObservable, options?)` | Synthesize text with TTS and play on a mixer queue |
|
|
405
|
+
| `channel.audio.play(source, options?)` | Play raw audio (URL, path, or platform phrase record) |
|
|
406
|
+
| `channel.audio.presay(text, options?)` | Pre-synthesize TTS into the host cache (no playback) |
|
|
407
|
+
| `channel.audio.preload(source, options?)` | Decode/warm a raw audio source (no playback) |
|
|
408
|
+
| `channel.audio.queue(index)` | Per-queue control handle (`MixerQueueControl`) |
|
|
409
|
+
| `channel.audio.remove(alias, queue?)` | Remove one queued item by alias |
|
|
410
|
+
| `channel.audio.stop(queue)` | Clear a queue **and** abort in-flight sentence TTS for it |
|
|
411
|
+
| `channel.audio.stopAll()` | Clear every queue (WS clients also get an audio interrupt) |
|
|
412
|
+
|
|
369
413
|
`channel.audio.say(textOrObservable, options?)` synthesizes text and plays it through the mixer.
|
|
370
414
|
|
|
371
415
|
```ts
|
|
@@ -384,11 +428,11 @@ await channel.audio.say('Please wait while I check that.', {
|
|
|
384
428
|
});
|
|
385
429
|
```
|
|
386
430
|
|
|
387
|
-
Use full vendor names for `ttsVendor`. Dedicated TTS vendors include `"elevenlabs"`, `"google"`, and `"voctiv"`. The default TTS path can also accept compatible aliases such as `"azure"` or `"neuro_v3"`, depending on how
|
|
431
|
+
Use full vendor names for `ttsVendor`. Dedicated TTS vendors include `"elevenlabs"`, `"google"`, and `"voctiv"`. The default TTS path can also accept compatible aliases such as `"azure"` or `"neuro_v3"`, depending on how the host runtime is configured.
|
|
388
432
|
|
|
389
433
|
Vendor-native parameter names (`api_key`, `voice_id`, `model_id`, `base_url`) are passed directly to the connector and override any platform defaults. See [TTS Credentials And Vendor Parameters](#tts-credentials-and-vendor-parameters) for the full list of accepted keys per vendor.
|
|
390
434
|
|
|
391
|
-
`channel.audio.play(source, options?)` plays raw audio from a URL/path or a `
|
|
435
|
+
`channel.audio.play(source, options?)` plays raw audio from a URL/path or a phrase record from `platform.getRecords()`.
|
|
392
436
|
|
|
393
437
|
```ts
|
|
394
438
|
await channel.audio.play('/opt/prompts/welcome.wav', {
|
|
@@ -397,9 +441,40 @@ await channel.audio.play('/opt/prompts/welcome.wav', {
|
|
|
397
441
|
});
|
|
398
442
|
```
|
|
399
443
|
|
|
400
|
-
|
|
444
|
+
### Pre-synthesis And Preload
|
|
401
445
|
|
|
402
|
-
`channel.audio.
|
|
446
|
+
`channel.audio.presay(text, options?)` runs TTS ahead of time and stores PCM in the host TTS
|
|
447
|
+
cache. Later `say()` calls with the same resolved TTS config and text can reuse the cached file.
|
|
448
|
+
Playback does **not** start. If the cache is unavailable, the runtime logs a warning and resolves
|
|
449
|
+
without throwing.
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
await channel.audio.presay('Your balance is one hundred dollars.', {
|
|
453
|
+
ttsVendor: 'elevenlabs',
|
|
454
|
+
ttsConfig: { voice_id: 'bBLRWT6MSWBFAm76ZWXY' },
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
// Later — cache hit, faster playback:
|
|
458
|
+
await channel.audio.say('Your balance is one hundred dollars.', {
|
|
459
|
+
alias: 'balance',
|
|
460
|
+
ttsVendor: 'elevenlabs',
|
|
461
|
+
ttsConfig: { voice_id: 'bBLRWT6MSWBFAm76ZWXY' },
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
`PresayOptions` accepts `ttsVendor`, `name`, `ttsConfig`, `ttsStrategy`, and optional `cache`
|
|
466
|
+
overrides (same shape as `PlayOptions.cache`).
|
|
467
|
+
|
|
468
|
+
`channel.audio.preload(source, options?)` downloads/decodes a **raw audio** source through the
|
|
469
|
+
audio player path. It does **not** synthesize TTS and does **not** populate the TTS cache used
|
|
470
|
+
by `presay()`. Use it to warm the decoder before `play()`.
|
|
471
|
+
|
|
472
|
+
```ts
|
|
473
|
+
await channel.audio.preload('/opt/prompts/welcome.wav');
|
|
474
|
+
await channel.audio.play('/opt/prompts/welcome.wav', { alias: 'welcome' });
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
When phrase persistence is enabled, `preload()` can store decoded audio for later playback via `platform.getRecords()`. Pass `options.cache` to override phrase name, flag, or language.
|
|
403
478
|
|
|
404
479
|
### TTS Strategies
|
|
405
480
|
|
|
@@ -413,24 +488,77 @@ When using an `Observable<string>` input, WS clients also receive text progress
|
|
|
413
488
|
|
|
414
489
|
### Mixer Queues
|
|
415
490
|
|
|
416
|
-
The mixer has queues
|
|
491
|
+
The mixer has queues **`0` through `4`**. Use separate queues for main speech, earcons, hold
|
|
492
|
+
music, or background audio so barge-in on one queue does not cut unrelated audio.
|
|
493
|
+
|
|
494
|
+
Obtain a per-queue handle with **`channel.audio.queue(index)`** (`MixerQueueControl`):
|
|
495
|
+
|
|
496
|
+
| Member | Description |
|
|
497
|
+
| --- | --- |
|
|
498
|
+
| `index` | Queue index **0–4** |
|
|
499
|
+
| `volume` | Linear gain **0.0–1.0** for the entire queue (get/set) |
|
|
500
|
+
| `itemStarted$` | Emits item **`alias`** when playback starts |
|
|
501
|
+
| `itemFinished$` | Emits **`alias`** when an item finishes, is removed, or is skipped by clear |
|
|
502
|
+
| `queueEmpty$` | Emits when the queue is empty after all PCM has been mixed out |
|
|
503
|
+
| `remove(alias)` | Drop one item on this queue |
|
|
504
|
+
| `clear()` | Drop all items on this queue (does **not** abort in-flight TTS generation) |
|
|
505
|
+
|
|
506
|
+
Top-level helpers on **`channel.audio`**:
|
|
507
|
+
|
|
508
|
+
- **`remove(alias, queue?)`** — when `queue` is omitted, searches all five queues; when set, only that queue is checked.
|
|
509
|
+
- **`stop(queue)`** — same as `clear()` **plus** aborts in-flight sentence TTS for that queue.
|
|
510
|
+
- **`stopAll()`** — `stop()` on every queue; WS clients also receive an audio interrupt signal.
|
|
417
511
|
|
|
418
512
|
```ts
|
|
513
|
+
const tts = channel.audio.queue(0);
|
|
419
514
|
const music = channel.audio.queue(2);
|
|
515
|
+
|
|
516
|
+
tts.itemStarted$.subscribe((alias) => logger.log('TTS started', { alias }));
|
|
517
|
+
tts.queueEmpty$.subscribe(() => logger.log('Agent queue idle'));
|
|
518
|
+
|
|
420
519
|
music.volume = 0.25;
|
|
421
520
|
|
|
422
521
|
await channel.audio.play('/opt/audio/hold.wav', {
|
|
423
522
|
queue: 2,
|
|
424
523
|
alias: 'hold-music',
|
|
425
524
|
loop: true,
|
|
525
|
+
loopDelayMs: 500,
|
|
426
526
|
});
|
|
427
527
|
|
|
428
|
-
|
|
528
|
+
// Remove one earcon without touching TTS:
|
|
529
|
+
channel.audio.remove('hold-music', 2);
|
|
530
|
+
|
|
531
|
+
// Barge-in: stop agent speech and abort pending sentence synthesis:
|
|
532
|
+
channel.audio.stop(0);
|
|
533
|
+
|
|
534
|
+
// Or clear music only (no TTS abort on queue 0):
|
|
535
|
+
music.clear();
|
|
429
536
|
```
|
|
430
537
|
|
|
431
|
-
`PlayOptions.volume` changes the whole queue volume, not just one item.
|
|
538
|
+
`PlayOptions.volume` changes the whole queue volume, not just one item.
|
|
539
|
+
|
|
540
|
+
For sentence-split TTS, queue item aliases are suffixed as `alias-0`, `alias-1`, and so on. Raw
|
|
541
|
+
`play()` and direct streaming TTS use the alias exactly. Pass the suffixed alias to
|
|
542
|
+
`remove()` when cancelling a single synthesized sentence.
|
|
543
|
+
|
|
544
|
+
### PlayOptions Reference
|
|
432
545
|
|
|
433
|
-
|
|
546
|
+
Shared by `say()`, `play()`, and (where noted) `presay()`:
|
|
547
|
+
|
|
548
|
+
| Field | Type | Applies to | Description |
|
|
549
|
+
| --- | --- | --- | --- |
|
|
550
|
+
| `queue` | `number?` | `say`, `play` | Mixer queue **0–4** (default **0**). |
|
|
551
|
+
| `alias` | `string?` | `say`, `play` | Stable item id for `remove()` and queue events. |
|
|
552
|
+
| `loop` | `boolean?` | `say`, `play` | Restart after finish until stopped/removed. |
|
|
553
|
+
| `loopDelayMs` | `number?` | `say`, `play` | Silence between loop iterations. |
|
|
554
|
+
| `volume` | `number?` | `say`, `play` | Sets **whole queue** gain **0.0–1.0** (not per-item). |
|
|
555
|
+
| `ttsStrategy` | `TtsStrategy?` | `say`, `presay` | `sentence` \| `streaming` \| `full`. |
|
|
556
|
+
| `ttsVendor` | `TtsVendor?` | `say`, `presay` | Override `channel.params.ttsVendor`. |
|
|
557
|
+
| `name` | `string?` | `say`, `presay` | Platform TTS credential **`name`** (key catalog selector). |
|
|
558
|
+
| `ttsConfig` | `Record<string, unknown>?` | `say`, `presay` | Vendor params; `name` key is stripped before send. |
|
|
559
|
+
| `cache` | `true \| CacheOptions?` | `say`, `presay` | TTS file cache; optional platform phrase persist. |
|
|
560
|
+
|
|
561
|
+
`play()` ignores `tts*` and `cache` for raw audio. `preload()` only accepts `cache` overrides.
|
|
434
562
|
|
|
435
563
|
## TTS Credentials And Vendor Parameters
|
|
436
564
|
|
|
@@ -460,9 +588,9 @@ Each TTS vendor connector accepts its native parameter names:
|
|
|
460
588
|
|
|
461
589
|
All vendors also accept the env-style names (`ELEVENLABS_API_KEY`, `ELEVENLABS_VOICE_ID`, etc.) for backwards compatibility, but vendor-native names are checked first and are preferred.
|
|
462
590
|
|
|
463
|
-
###
|
|
591
|
+
### Platform TTS Key Selection
|
|
464
592
|
|
|
465
|
-
|
|
593
|
+
TTS credentials can also be selected by `PlayOptions.name` or `ttsConfig.name`:
|
|
466
594
|
|
|
467
595
|
```ts
|
|
468
596
|
await channel.audio.say('Здравствуйте!', {
|
|
@@ -473,14 +601,14 @@ await channel.audio.say('Здравствуйте!', {
|
|
|
473
601
|
});
|
|
474
602
|
```
|
|
475
603
|
|
|
476
|
-
The
|
|
604
|
+
The host resolves credentials from `channel.params.authentication_data` for the current agent and company. If `name` is omitted, `channel.params.defaultTtsName` may be used.
|
|
477
605
|
|
|
478
606
|
When both `name` (platform key) and explicit `ttsConfig` values are provided, `ttsConfig` values win — they are applied last and override anything resolved from the platform.
|
|
479
607
|
|
|
480
608
|
`cache` enables TTS result caching for `say()` and `presay()`:
|
|
481
609
|
|
|
482
|
-
- **`cache: true`** — read/write TTS file cache
|
|
483
|
-
- **`cache: { phraseName, flag?, language? }`** — TTS cache **plus** persist
|
|
610
|
+
- **`cache: true`** — read/write host TTS file cache.
|
|
611
|
+
- **`cache: { phraseName, flag?, language? }`** — TTS cache **plus** persist as a platform phrase so `platform.getRecords()` can retrieve the audio later.
|
|
484
612
|
|
|
485
613
|
```ts
|
|
486
614
|
// Cache only (no platform persist):
|
|
@@ -506,7 +634,7 @@ if (records?.[0]) {
|
|
|
506
634
|
}
|
|
507
635
|
```
|
|
508
636
|
|
|
509
|
-
|
|
637
|
+
Phrase persistence requires platform phrase storage and TTS cache to be enabled on the host.
|
|
510
638
|
|
|
511
639
|
## Error Handling
|
|
512
640
|
|
|
@@ -582,14 +710,56 @@ channel.events.error$.subscribe((err) => {
|
|
|
582
710
|
| `code` | `number \| string?` | HTTP status, gRPC status, provider code, or WebSocket close code. |
|
|
583
711
|
| `vendor` | `string?` | Vendor identifier, e.g. `"yandex"`, `"elevenlabs"`, `"azure"`. |
|
|
584
712
|
| `details` | `unknown?` | Arbitrary provider-specific payload. |
|
|
585
|
-
| `cause` | `unknown?` | Original
|
|
713
|
+
| `cause` | `unknown?` | Original underlying error when available. |
|
|
586
714
|
|
|
587
715
|
Subscribing to `error$` is optional. Old scripts that do not subscribe are not affected — the observables simply go unobserved.
|
|
588
716
|
|
|
717
|
+
## Channel Events
|
|
718
|
+
|
|
719
|
+
`channel.events` exposes session-level observables that are **not** tied to a single ASR handle:
|
|
720
|
+
|
|
721
|
+
| Observable | Emits when |
|
|
722
|
+
| --- | --- |
|
|
723
|
+
| `speechStart$` | User started speaking (VAD, socket event, or synthetic text input). |
|
|
724
|
+
| `speechEnd$` | User stopped speaking (VAD end, ASR final, or synthetic text input). |
|
|
725
|
+
| `interrupt$` | Barge-in: user speech interrupted bot audio (may be inert without VAD). |
|
|
726
|
+
| `terminated$` | Session ending — hangup, WS disconnect, or `channel.destroy()`. |
|
|
727
|
+
| `message$` | Structured WS data messages (`DataMessage`: `{ event, payload }`). |
|
|
728
|
+
| `error$` | Unified media/runtime errors (see [Error Handling](#error-handling)). |
|
|
729
|
+
|
|
730
|
+
```ts
|
|
731
|
+
channel.events.speechStart$.subscribe(() => {
|
|
732
|
+
channel.audio.stop(0); // barge-in on agent TTS queue
|
|
733
|
+
});
|
|
734
|
+
|
|
735
|
+
channel.events.message$.subscribe(({ event, payload }) => {
|
|
736
|
+
logger.log('WS client event', { event, payload });
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
channel.events.terminated$.subscribe(() => {
|
|
740
|
+
asr.destroy();
|
|
741
|
+
channel.destroy();
|
|
742
|
+
});
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
**ASR vs channel events:** `AsrHandle.speechStart$` / `speechEnd$` / `interrupt$` are scoped to one
|
|
746
|
+
recognizer instance. `channel.events.*` aggregates session-level signals (useful when you do not
|
|
747
|
+
create ASR or want one subscription for the whole channel).
|
|
748
|
+
|
|
589
749
|
## LLM API
|
|
590
750
|
|
|
591
751
|
`channel.llm` talks to the Omni LLM backend.
|
|
592
752
|
|
|
753
|
+
| Method | Returns | Description |
|
|
754
|
+
| --- | --- | --- |
|
|
755
|
+
| `ask(message, options?)` | `Promise<string>` | Single-shot completion (consumes SSE stream). |
|
|
756
|
+
| `stream(message, options?)` | `Observable<LlmStreamChunk>` | Token/chunk stream; use `chunk.content` for TTS. |
|
|
757
|
+
| `extract(options?)` | `Promise<Record<string, any>>` | Structured extraction via Omni extract API. |
|
|
758
|
+
| `makePersistentStream(options?)` | `PersistentLlmStreamHandle` | Long-lived stream for multi-turn chat. |
|
|
759
|
+
|
|
760
|
+
Common `LlmOptions`: `dialogUuid`, `agentUuid`, `role`, `hidden`, `name` (LLM speaker label — **not**
|
|
761
|
+
the TTS credential `name`), `payload`, `debug`, `agentAliasFilter`, `currentAgentAlias`.
|
|
762
|
+
|
|
593
763
|
```ts
|
|
594
764
|
const answer = await channel.llm.ask('Summarize the user request', {
|
|
595
765
|
role: 'assistant',
|
|
@@ -603,6 +773,8 @@ await channel.audio.say(answer);
|
|
|
603
773
|
For streaming:
|
|
604
774
|
|
|
605
775
|
```ts
|
|
776
|
+
import { map } from 'rxjs';
|
|
777
|
+
|
|
606
778
|
const stream$ = channel.llm.stream('Answer briefly', {
|
|
607
779
|
role: 'assistant',
|
|
608
780
|
});
|
|
@@ -613,13 +785,70 @@ await channel.audio.say(
|
|
|
613
785
|
);
|
|
614
786
|
```
|
|
615
787
|
|
|
616
|
-
|
|
788
|
+
Structured extraction:
|
|
789
|
+
|
|
790
|
+
```ts
|
|
791
|
+
const fields = await channel.llm.extract({
|
|
792
|
+
prompt: 'Extract appointment date and time from the dialog.',
|
|
793
|
+
temperature: 0.2,
|
|
794
|
+
});
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
Persistent multi-turn stream:
|
|
798
|
+
|
|
799
|
+
```ts
|
|
800
|
+
const chat = channel.llm.makePersistentStream({
|
|
801
|
+
agentUuid: context.agentUuid,
|
|
802
|
+
dialogUuid: context.dialogUuid,
|
|
803
|
+
});
|
|
804
|
+
|
|
805
|
+
chat.stream$.pipe(map((c) => c.content)).subscribe((text) => logger.debug('LLM chunk', { text }));
|
|
806
|
+
|
|
807
|
+
chat.send('What is my balance?');
|
|
808
|
+
chat.send('And my last payment date?');
|
|
809
|
+
chat.disconnect();
|
|
810
|
+
```
|
|
811
|
+
|
|
812
|
+
## Script Return Value
|
|
813
|
+
|
|
814
|
+
Scripts may return `void` or a **`ScriptResult`**:
|
|
815
|
+
|
|
816
|
+
```ts
|
|
817
|
+
return {
|
|
818
|
+
output: { intent: 'reschedule', score: 0.92 },
|
|
819
|
+
};
|
|
820
|
+
```
|
|
821
|
+
|
|
822
|
+
- **`output`** — stored in dialog stats / host persistence.
|
|
823
|
+
- **`error`** — optional; usually auto-populated on crash, but scripts may set it explicitly.
|
|
824
|
+
|
|
825
|
+
**Do not** return `env` from the script. Persist state via `context.env$`; the runtime snapshots it
|
|
826
|
+
after completion into **`PersistedScriptResult.env`**.
|
|
827
|
+
|
|
828
|
+
Use **`getScriptPhase(context)`** to branch on lifecycle (`online`, `messaging`, `recall`, etc.):
|
|
829
|
+
|
|
830
|
+
```ts
|
|
831
|
+
import { defineScript, getScriptPhase } from '@voctiv/agent-sdk';
|
|
832
|
+
|
|
833
|
+
export default defineScript(async ({ context }) => {
|
|
834
|
+
switch (getScriptPhase(context)) {
|
|
835
|
+
case 'online':
|
|
836
|
+
// live call
|
|
837
|
+
break;
|
|
838
|
+
case 'messaging':
|
|
839
|
+
// inbound message handling
|
|
840
|
+
break;
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
```
|
|
617
844
|
|
|
618
845
|
## Platform API
|
|
619
846
|
|
|
620
|
-
`platform` exposes
|
|
847
|
+
`platform` exposes platform operations.
|
|
848
|
+
|
|
849
|
+
`platform.nlu.extract(utterance, options?)` runs intent/entity extraction. If `options.context` is omitted, current dialog params are serialized and used as NLU context.
|
|
621
850
|
|
|
622
|
-
`platform.nlu.extract(
|
|
851
|
+
`platform.nlu.extract$()` is an Observable wrapper — one `extract()` call per subscription, not a streaming NLU session.
|
|
623
852
|
|
|
624
853
|
```ts
|
|
625
854
|
const result = await platform.nlu.extract('I want to reschedule', {
|
|
@@ -629,7 +858,7 @@ const result = await platform.nlu.extract('I want to reschedule', {
|
|
|
629
858
|
});
|
|
630
859
|
```
|
|
631
860
|
|
|
632
|
-
Platform APIs
|
|
861
|
+
Platform APIs (`platform.nlu`, `platform.call`, dialog writes, messaging, phrase records) are available when the host enables platform integration.
|
|
633
862
|
|
|
634
863
|
### Dialog State
|
|
635
864
|
|
|
@@ -638,7 +867,7 @@ platform.dialog.entryPoint = 'on_recall';
|
|
|
638
867
|
platform.dialog.result = 'done';
|
|
639
868
|
```
|
|
640
869
|
|
|
641
|
-
Setters update the local value immediately and
|
|
870
|
+
Setters update the local value immediately and persist to the platform asynchronously. They are not awaitable and should not be used as transactional writes.
|
|
642
871
|
|
|
643
872
|
### Platform-Scheduled Calls
|
|
644
873
|
|
|
@@ -650,7 +879,7 @@ The destination number should be E.164 formatted.
|
|
|
650
879
|
await platform.call('+12025551234');
|
|
651
880
|
```
|
|
652
881
|
|
|
653
|
-
When options are omitted, the host fills scheduling and routing defaults from agent
|
|
882
|
+
When options are omitted, the host fills scheduling and routing defaults from agent and dialog settings. Explicit `options` always win.
|
|
654
883
|
|
|
655
884
|
By default, the platform schedules the call for immediate processing. Use `date` to schedule it for the future:
|
|
656
885
|
|
|
@@ -715,7 +944,7 @@ await platform.messaging.send({
|
|
|
715
944
|
});
|
|
716
945
|
```
|
|
717
946
|
|
|
718
|
-
|
|
947
|
+
`platform.messaging.message$` replays the inbound message that started a headless messaging script; it is not a live subscription to all future messages.
|
|
719
948
|
|
|
720
949
|
## Offline / Headless Logic
|
|
721
950
|
|
|
@@ -740,11 +969,7 @@ export default defineScript(async ({ channel, context, logger, platform }) => {
|
|
|
740
969
|
});
|
|
741
970
|
```
|
|
742
971
|
|
|
743
|
-
Headless sessions can be started by host
|
|
744
|
-
|
|
745
|
-
- a platform dialog queue worker that loads pending dialogs;
|
|
746
|
-
- an inbound messaging worker, usually with `context.entryPoint === 'on_message_api_received'`;
|
|
747
|
-
- an HTTP/API request that asks ScriptEngine to run a script without media.
|
|
972
|
+
Headless sessions can be started by the host for background processing, inbound messaging, or API-triggered runs without media.
|
|
748
973
|
|
|
749
974
|
### What Works In Headless
|
|
750
975
|
|
|
@@ -752,7 +977,7 @@ These APIs are available and are the intended tools for offline scripts:
|
|
|
752
977
|
|
|
753
978
|
- `context.dialogParams`, `context.initialData`, `context.dialogEntity`, and `context.callEntity` for platform data.
|
|
754
979
|
- `context.env$` for persisted per-dialog state.
|
|
755
|
-
- `platform.nlu.extract()` for text NLU when
|
|
980
|
+
- `platform.nlu.extract()` for text NLU when platform integration is enabled.
|
|
756
981
|
- `platform.messaging.send()` for outbound messages through the configured platform messaging transport.
|
|
757
982
|
- `platform.call()` for scheduling outbound platform-managed calls.
|
|
758
983
|
- `platform.dialog.entryPoint` and `platform.dialog.result` for updating dialog routing and outcome.
|
|
@@ -831,7 +1056,7 @@ context.env$?.next({
|
|
|
831
1056
|
});
|
|
832
1057
|
```
|
|
833
1058
|
|
|
834
|
-
Do not return `env` from the script.
|
|
1059
|
+
Do not return `env` from the script. The runtime snapshots `context.env$` after completion and persists it for the dialog.
|
|
835
1060
|
|
|
836
1061
|
### Combining Voice And Offline In One Script
|
|
837
1062
|
|
|
@@ -860,6 +1085,36 @@ export default defineScript(async ({ channel, context, platform }) => {
|
|
|
860
1085
|
|
|
861
1086
|
`context` includes identity, telephony fields, params, routing metadata, and runtime helpers.
|
|
862
1087
|
|
|
1088
|
+
### Agent env and storage
|
|
1089
|
+
|
|
1090
|
+
When the host exposes agent identity, `context.agent` provides agent-scoped global variables:
|
|
1091
|
+
|
|
1092
|
+
```ts
|
|
1093
|
+
// Read all agent env keys
|
|
1094
|
+
const all = await context.agent?.env?.();
|
|
1095
|
+
|
|
1096
|
+
// Read one key
|
|
1097
|
+
const counter = await context.agent?.env?.<number>('visitCount');
|
|
1098
|
+
|
|
1099
|
+
// Write with optional TTL (days)
|
|
1100
|
+
await context.agent?.env?.('visitCount', 42, { expire: 30 });
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
`context.storage('key1', 'key2')` reads CMS/global variables from agent settings, then company-level
|
|
1104
|
+
fallback. Always returns an object with every requested key (value or `null`).
|
|
1105
|
+
|
|
1106
|
+
### Execution budget (`runTime`)
|
|
1107
|
+
|
|
1108
|
+
Long-running async scripts can check and extend their time budget:
|
|
1109
|
+
|
|
1110
|
+
```ts
|
|
1111
|
+
if ((context.runTime?.remainingMs() ?? Infinity) < 5000) {
|
|
1112
|
+
context.runTime?.extend(30_000);
|
|
1113
|
+
}
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
`budgetMs` and `maxExtendMs` are fixed for the session; `extend()` grants up to the remaining quota.
|
|
1117
|
+
|
|
863
1118
|
Important fields:
|
|
864
1119
|
|
|
865
1120
|
- `context.dialogUuid`: current dialog UUID.
|
|
@@ -895,7 +1150,7 @@ logger.log('ASR result received', { text });
|
|
|
895
1150
|
logger.warn('Low confidence intent', { confidence });
|
|
896
1151
|
```
|
|
897
1152
|
|
|
898
|
-
`logger.enableDebug(endpoint)` streams logs from the current script instance to a remote debug endpoint. `logger.breakpoint(label, snapshot?)` pauses only when an active debug session is connected; otherwise it resolves immediately.
|
|
1153
|
+
`logger.enableDebug(endpoint)` streams logs from the current script instance to a remote debug endpoint. `logger.disableDebug()` stops streaming. `logger.breakpoint(label, snapshot?)` pauses only when an active debug session is connected; otherwise it resolves immediately.
|
|
899
1154
|
|
|
900
1155
|
## WS And Headless Behavior
|
|
901
1156
|
|
|
@@ -930,15 +1185,7 @@ This is mainly for WS debug clients and automated tests. Unknown ASR ids are ign
|
|
|
930
1185
|
|
|
931
1186
|
## Package Notes
|
|
932
1187
|
|
|
933
|
-
The package
|
|
934
|
-
|
|
935
|
-
Build locally with:
|
|
936
|
-
|
|
937
|
-
```bash
|
|
938
|
-
npm run build
|
|
939
|
-
```
|
|
940
|
-
|
|
941
|
-
The package exports only the public SDK entry point:
|
|
1188
|
+
The package ships as CommonJS with TypeScript declarations. Import from `@voctiv/agent-sdk`:
|
|
942
1189
|
|
|
943
1190
|
```ts
|
|
944
1191
|
import { defineScript, type MediaChannel, type AsrHandle, type MediaError } from '@voctiv/agent-sdk';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @packageDocumentation
|
|
3
|
-
* **Agent scripting SDK
|
|
4
|
-
* {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and
|
|
5
|
-
*
|
|
6
|
-
*
|
|
3
|
+
* **Agent scripting SDK**: typed **`defineScript`** context,
|
|
4
|
+
* {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and platform helpers.
|
|
5
|
+
*
|
|
6
|
+
* Full API reference: **`README.md`** in this package (`@voctiv/agent-sdk` on npm).
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* These exports are types plus the `defineScript` identity helper; runtime behavior is
|
|
9
|
+
* provided by the host when it loads and executes your script.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
* may contain:
|
|
12
|
-
* - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
|
|
13
|
-
* - **`legacyTtsKeysByName`**: same for TTS
|
|
11
|
+
* ### Selecting ASR/TTS credentials by name (platform key catalog)
|
|
14
12
|
*
|
|
15
|
-
*
|
|
13
|
+
* When the host loads platform credential catalogs, **`channel.params.authentication_data`**
|
|
14
|
+
* may contain named ASR/TTS key rows for the current dialog agent and company. Use:
|
|
16
15
|
* - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
|
|
17
16
|
* - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
|
|
18
17
|
*
|
|
19
18
|
* Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
|
|
20
19
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Platform APIs (`platform.nlu`, `platform.call`, messaging, dialog writes, phrase records)
|
|
21
|
+
* are available when the host enables platform integration.
|
|
23
22
|
*/
|
|
24
23
|
export { defineScript } from './define-script';
|
|
25
24
|
export type { ScriptContext, ScriptFn } from './define-script';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;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;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,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,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"}
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* @packageDocumentation
|
|
4
|
-
* **Agent scripting SDK
|
|
5
|
-
* {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* **Agent scripting SDK**: typed **`defineScript`** context,
|
|
5
|
+
* {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and platform helpers.
|
|
6
|
+
*
|
|
7
|
+
* Full API reference: **`README.md`** in this package (`@voctiv/agent-sdk` on npm).
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* These exports are types plus the `defineScript` identity helper; runtime behavior is
|
|
10
|
+
* provided by the host when it loads and executes your script.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
* may contain:
|
|
13
|
-
* - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
|
|
14
|
-
* - **`legacyTtsKeysByName`**: same for TTS
|
|
12
|
+
* ### Selecting ASR/TTS credentials by name (platform key catalog)
|
|
15
13
|
*
|
|
16
|
-
*
|
|
14
|
+
* When the host loads platform credential catalogs, **`channel.params.authentication_data`**
|
|
15
|
+
* may contain named ASR/TTS key rows for the current dialog agent and company. Use:
|
|
17
16
|
* - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
|
|
18
17
|
* - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
|
|
19
18
|
*
|
|
20
19
|
* Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* Platform APIs (`platform.nlu`, `platform.call`, messaging, dialog writes, phrase records)
|
|
22
|
+
* are available when the host enables platform integration.
|
|
24
23
|
*/
|
|
25
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
25
|
exports.isLegacyPhraseRecord = exports.LEGACY_PHRASE_RECORD_BRAND = exports.getScriptPhase = exports.defineScript = void 0;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAEH,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAerB,yDAAwD;AAA/C,gHAAA,cAAc,OAAA;AA0CvB,uDAG+B;AAF7B,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA"}
|
|
@@ -92,7 +92,7 @@ export interface ChannelAudio {
|
|
|
92
92
|
* suffixed as `alias-0`, `alias-1`, etc.; remove the concrete suffix if you need to
|
|
93
93
|
* cancel one synthesized sentence.
|
|
94
94
|
* @param alias - **`PlayOptions.alias`** of the item to drop.
|
|
95
|
-
* @param queue -
|
|
95
|
+
* @param queue - When set, only this queue index is searched; when omitted, all five queues are searched.
|
|
96
96
|
*/
|
|
97
97
|
remove(alias: string, queue?: number): void;
|
|
98
98
|
/**
|
package/dist/types/mixer.d.ts
CHANGED
|
@@ -137,7 +137,8 @@ export interface MixerQueueControl {
|
|
|
137
137
|
readonly itemStarted$: Observable<string>;
|
|
138
138
|
/** Emits **`alias`** when an item finishes, is removed, or is skipped by queue clear. */
|
|
139
139
|
readonly itemFinished$: Observable<string>;
|
|
140
|
-
/** Emits whenever the queue becomes empty after all pending/current items are gone
|
|
140
|
+
/** Emits whenever the queue becomes empty after all pending/current items are gone
|
|
141
|
+
* and their PCM has been emitted to the mixer output (not merely dequeued). */
|
|
141
142
|
readonly queueEmpty$: Observable<void>;
|
|
142
143
|
/**
|
|
143
144
|
* Remove a single item by **`alias`**.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mixer.d.ts","sourceRoot":"","sources":["../../src/types/mixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,MAAM,CAAC;AAE5D;;;;;;;;GAQG;AACH,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,MAAM,GACN,SAAS,GACT,QAAQ,GACR,OAAO,GACP,UAAU,GACV,UAAU,GACV,eAAe,GACf,aAAa,GACb,KAAK,GACL,CAAC,MAAM,G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AC,EAAE,IAAI,GAAG,YAAY,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,mFAAmF;IACnF,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,mFAAmF;IACnF,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,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"}
|
|
@@ -107,8 +107,9 @@ export interface ScriptDialogContext {
|
|
|
107
107
|
* attaches it to the persisted result; the script return value must not carry env
|
|
108
108
|
* (see {@link ScriptResult}).
|
|
109
109
|
*
|
|
110
|
-
* Session runners
|
|
111
|
-
*
|
|
110
|
+
* Session runners load the previous snapshot from Redis (`dialog:{uuid}`) at start and
|
|
111
|
+
* persist the final `env$` snapshot after every run (SIP, WebSocket, headless). Same key
|
|
112
|
+
* as legacy logic-executor `nn.env`.
|
|
112
113
|
*/
|
|
113
114
|
env$?: BehaviorSubject<Record<string, unknown> | undefined>;
|
|
114
115
|
/** Raw `dialog` table row from the Voctiv platform database. */
|
|
@@ -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,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,GAAG,CAAC,EAAE;QACJ,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;QACnD,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QAC3E,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAChF,CAAC;CACH;AAED,iFAAiF;AACjF,MAAM,MAAM,iBAAiB,GAAG,CAC9B,GAAG,IAAI,EAAE,MAAM,EAAE,KACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,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yF;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,CAaxE;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;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,4CAA4C;IAC5C,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-context.js","sourceRoot":"","sources":["../../src/types/script-context.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"script-context.js","sourceRoot":"","sources":["../../src/types/script-context.ts"],"names":[],"mappings":";;AA8NA,wCAaC;AAnCD,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;QAAE,OAAO,WAAW,CAAC;IAEnF,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,MAAM,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,aAAa,CAAC;IAEnE,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
package/dist/types/sip.d.ts
CHANGED
|
@@ -444,8 +444,8 @@ export interface ChannelSip {
|
|
|
444
444
|
* `waitForEarly()` on the B-leg before sending audio.
|
|
445
445
|
*
|
|
446
446
|
* Supported by SIP channels. In worker isolation mode the host proxies the returned
|
|
447
|
-
* B-leg, including media operations, ASR, SIP control, LLM, and `bridge()`. WS
|
|
448
|
-
*
|
|
447
|
+
* B-leg, including media operations, ASR, SIP control, LLM, and `bridge()`. WS channels
|
|
448
|
+
* dial the B-leg via the host SIP stack and bridge client PCM to RTP. Headless channels throw.
|
|
449
449
|
*
|
|
450
450
|
* @param opts.sipUri - Full SIP URI, e.g. `"sip:+12025551234@trunk.carrier.com"`.
|
|
451
451
|
* @param opts.msisdn - Legacy-mode phone number. The host resolves the SIP URI from the selected trunk.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voctiv/agent-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Voctiv TypeScript agent SDK: defineScript and platform types for the voice/dialog scripting runtime.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
|
-
"dist"
|
|
25
|
+
"dist",
|
|
26
|
+
"README.md"
|
|
26
27
|
],
|
|
27
28
|
"scripts": {
|
|
28
29
|
"build": "tsc -p tsconfig.build.json",
|