@voctiv/agent-sdk 0.2.15 → 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 +176 -23
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/asr-handle.d.ts +6 -2
- package/dist/types/asr-handle.d.ts.map +1 -1
- package/dist/types/events.d.ts +9 -2
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/media-channel.d.ts +24 -3
- package/dist/types/media-channel.d.ts.map +1 -1
- package/dist/types/mixer.d.ts +14 -0
- package/dist/types/mixer.d.ts.map +1 -1
- package/dist/types/nlu.d.ts +5 -3
- package/dist/types/nlu.d.ts.map +1 -1
- package/dist/types/platform.d.ts +51 -17
- package/dist/types/platform.d.ts.map +1 -1
- package/dist/types/script-context.d.ts +29 -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 +20 -11
- package/dist/types/sip.d.ts.map +1 -1
- package/dist/types/tts-handle.d.ts +194 -0
- package/dist/types/tts-handle.d.ts.map +1 -0
- package/dist/types/tts-handle.js +3 -0
- package/dist/types/tts-handle.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -116,6 +116,14 @@ const maxAttempts = parseRecallCount(context.dialogParams?.recall_count);
|
|
|
116
116
|
|
|
117
117
|
`defineScript(fn)` marks the default export as the script entry point. It returns the same function and exists to give TypeScript the correct `ScriptContext` shape.
|
|
118
118
|
|
|
119
|
+
**Three different “context” names:**
|
|
120
|
+
|
|
121
|
+
| Name | Meaning |
|
|
122
|
+
| --- | --- |
|
|
123
|
+
| `ScriptContext` | Top-level injection: `{ channel, logger, context, platform }` |
|
|
124
|
+
| `context` (`ScriptDialogContext`) | Dialog identity, params, routing snapshot, `env$`, headless — see [Dialog Context](#dialog-context-and-persisted-env) |
|
|
125
|
+
| `options.context` on `platform.nlu.extract` | Opaque NLU disambiguation string/JSON — **not** dialog context |
|
|
126
|
+
|
|
119
127
|
`ScriptContext` is the top-level object passed to a script:
|
|
120
128
|
|
|
121
129
|
- `channel` is the media channel for SIP, WS, ASR, TTS, audio playback, LLM, and structured data messages.
|
|
@@ -128,7 +136,8 @@ const maxAttempts = parseRecallCount(context.dialogParams?.recall_count);
|
|
|
128
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.
|
|
129
137
|
- `channel.params` is the merged runtime parameter map. Treat unknown keys as host-specific.
|
|
130
138
|
- `channel.createAsr()` creates an ASR handle.
|
|
131
|
-
- `channel.
|
|
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.
|
|
132
141
|
- `channel.sip` controls SIP state, pre-answer media, DTMF, hold/mute/hangup, outbound calls, and bridging.
|
|
133
142
|
- `channel.llm` talks to the Omni LLM backend.
|
|
134
143
|
- `channel.events` exposes speech, interrupt, termination, WS data message, and media error observables.
|
|
@@ -220,19 +229,43 @@ If the call terminates before media becomes available, deferred audio resolves a
|
|
|
220
229
|
On **SIP channels**, `channel.sip` exposes raw signalling beyond call state — useful for
|
|
221
230
|
carrier routing, diversion chains, and vendor SDP attributes.
|
|
222
231
|
|
|
232
|
+
#### When to use what
|
|
233
|
+
|
|
234
|
+
| Need | API | When |
|
|
235
|
+
| --- | --- | --- |
|
|
236
|
+
| Routing / identity / locale from the **inbound INVITE** (`Diversion`, `X-Trunk-Id`, `X-Neuro-UUID`, `X-language`, …) | `channel.sip.inviteSipHeaders` | Call **start** only (snapshot) |
|
|
237
|
+
| Peer signal **during** the call (e.g. mid-call language in INFO body) | `channel.sip.sipInfo$` | After subscribe; each INFO |
|
|
238
|
+
| DTMF digits | `channel.sip.dtmf$` | Prefer over parsing INFO |
|
|
239
|
+
| SDP / codec / connection | `remoteSdp` / `getRemoteSdpDetails()` | May change (183 / 200 / re-INVITE) |
|
|
240
|
+
| SIP response code / phrase (180, 486, …) | `sipSignal$` | Low-level; **no** response headers |
|
|
241
|
+
| Live SIP headers on 200 / re-INVITE / BYE | — | **Not exposed** |
|
|
242
|
+
|
|
243
|
+
Decision guide:
|
|
244
|
+
|
|
245
|
+
- Value from the inbound INVITE at call start → `inviteSipHeaders`
|
|
246
|
+
- Mid-call signal from peer INFO → `sipInfo$` (`contentType` + `body` only)
|
|
247
|
+
- DTMF → `dtmf$`
|
|
248
|
+
- Media description → `remoteSdp` / `getRemoteSdpDetails()`
|
|
249
|
+
- Live SIP response headers → not available (`sipSignal$` has status/SDP only)
|
|
250
|
+
|
|
251
|
+
**Locale pattern:** read start language from `inviteSipHeaders` (e.g. `X-language`). Mid-call changes only work if the peer puts the language in the INFO **body** — INFO SIP headers are not forwarded. Monolingual agents can ignore both and use `context.language` / config.
|
|
252
|
+
|
|
253
|
+
Outbound INVITE headers you **send** go through `platform.call({ protoAdditional })` or `makeCall` options — not `inviteSipHeaders` (read-only inbound snapshot). SIP metadata does not auto-update `context` or `platform.dialog`.
|
|
254
|
+
|
|
223
255
|
#### INVITE headers (`inviteSipHeaders`)
|
|
224
256
|
|
|
225
257
|
Snapshot of SIP headers from an **inbound INVITE** at call setup. Includes standard and
|
|
226
|
-
extension headers (`Diversion`, `P-Asserted-Identity`, `X-Trunk-Id`, `X-Neuro-UUID`, …).
|
|
258
|
+
extension headers (`Diversion`, `P-Asserted-Identity`, `X-Trunk-Id`, `X-Neuro-UUID`, `X-language`, …).
|
|
227
259
|
|
|
228
260
|
| Property | Updates during call? |
|
|
229
261
|
| --- | --- |
|
|
230
|
-
| `inviteSipHeaders` | **No** — INVITE snapshot only; outbound B-legs usually `undefined` |
|
|
262
|
+
| `inviteSipHeaders` | **No** — INVITE snapshot only; outbound B-legs / WS / headless usually `undefined` |
|
|
231
263
|
|
|
232
264
|
```ts
|
|
233
265
|
const h = channel.sip.inviteSipHeaders;
|
|
234
266
|
const diversion = h?.Diversion; // string | string[] when multiple hops
|
|
235
267
|
const trunkId = h?.['X-Trunk-Id'];
|
|
268
|
+
const lang = h?.['X-language'];
|
|
236
269
|
```
|
|
237
270
|
|
|
238
271
|
Header names match what the host stack exposes (case-sensitive). Duplicate headers become
|
|
@@ -259,7 +292,9 @@ attributes. It is not a full SDP validator — use `remoteSdp` when you need the
|
|
|
259
292
|
|
|
260
293
|
#### SIP INFO (`sipInfo$`)
|
|
261
294
|
|
|
262
|
-
Live stream of incoming SIP INFO messages
|
|
295
|
+
Live stream of incoming SIP INFO messages. Each event is `{ contentType, body }` only —
|
|
296
|
+
**INFO request headers are not exposed**. Prefer `dtmf$` for DTMF. Does not update
|
|
297
|
+
`inviteSipHeaders`.
|
|
263
298
|
|
|
264
299
|
```ts
|
|
265
300
|
channel.sip.sipInfo$.subscribe(({ contentType, body }) => {
|
|
@@ -293,11 +328,14 @@ the per-event `sdp` on `sipSignal$`.
|
|
|
293
328
|
- `bridge(other)` to cross-connect two SIP channels.
|
|
294
329
|
|
|
295
330
|
`makeCall()` and `bridge()` are supported on SIP channels. The returned B-leg is a full
|
|
296
|
-
`MediaChannel` with the same API as the main channel. WS and headless channels
|
|
331
|
+
`MediaChannel` with the same API as the main channel. WS and headless channels cannot create real SIP
|
|
332
|
+
legs, so both methods **throw** there rather than returning an inert leg you could talk into
|
|
333
|
+
unnoticed. Guard them with `context.headless` or `channel.type` when a script runs in both modes.
|
|
297
334
|
|
|
298
335
|
### `channel.sip` Reference
|
|
299
336
|
|
|
300
|
-
SIP-only unless noted. WS/headless: most methods are no-ops
|
|
337
|
+
SIP-only unless noted. WS/headless: most methods are no-ops and `state` behaves as synthetic
|
|
338
|
+
`active`, except `makeCall()` and `bridge()`, which throw.
|
|
301
339
|
|
|
302
340
|
| Member | Description |
|
|
303
341
|
| --- | --- |
|
|
@@ -308,10 +346,10 @@ SIP-only unless noted. WS/headless: most methods are no-ops; `state` behaves as
|
|
|
308
346
|
| `early$` | Emits once when RTP is up before final answer |
|
|
309
347
|
| `answered$` | Emits once on 200 OK |
|
|
310
348
|
| `dtmf$` | Remote DTMF digits (`DtmfEvent`: `digit`, `duration`) |
|
|
311
|
-
| `sipInfo$` |
|
|
312
|
-
| `sipSignal$` | Low-level
|
|
349
|
+
| `sipInfo$` | Mid-call SIP INFO (`contentType` + `body` only; INFO headers not exposed) |
|
|
350
|
+
| `sipSignal$` | Low-level stack events (`statusCode` / `statusPhrase` / optional `sdp`; no headers) |
|
|
313
351
|
| `remoteSdp` | Latest negotiated remote SDP body; updates when new SDP arrives |
|
|
314
|
-
| `inviteSipHeaders` |
|
|
352
|
+
| `inviteSipHeaders` | Start-of-call inbound INVITE header snapshot; does not update |
|
|
315
353
|
| `getRemoteSdpDetails()` | Parse `remoteSdp` → `ParsedSdpDetails` (session + `a=` attributes) |
|
|
316
354
|
| `sendProgress()` | Inbound: send 183 Session Progress → `early` |
|
|
317
355
|
| `waitForEarly()` | Await `early` or `active` (Promise) |
|
|
@@ -327,8 +365,8 @@ SIP-only unless noted. WS/headless: most methods are no-ops; `state` behaves as
|
|
|
327
365
|
|
|
328
366
|
Prefer `dtmf$` over `sipInfo$` for DTMF. Prefer `state$` / `early$` / `answered$` over raw
|
|
329
367
|
`sipSignal$` for call lifecycle. Use `remoteSdp` / `getRemoteSdpDetails()` for negotiated
|
|
330
|
-
media description; use `inviteSipHeaders` for
|
|
331
|
-
See **SIP Signalling Metadata
|
|
368
|
+
media description; use `inviteSipHeaders` for start-of-call INVITE headers and `sipInfo$`
|
|
369
|
+
for mid-call INFO body. See **When to use what** under SIP Signalling Metadata above.
|
|
332
370
|
|
|
333
371
|
### SIP Bridge
|
|
334
372
|
|
|
@@ -423,7 +461,9 @@ While a bridge is active, `channel.audio.say()` still sends audio only to the A-
|
|
|
423
461
|
|
|
424
462
|
## ASR, VAD, And Smart Turn
|
|
425
463
|
|
|
426
|
-
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.
|
|
427
467
|
|
|
428
468
|
```ts
|
|
429
469
|
const asr = await channel.createAsr({
|
|
@@ -453,7 +493,7 @@ const asr = await channel.createAsr({
|
|
|
453
493
|
- `error$`: runtime errors from the ASR provider (see [Error Handling](#error-handling)).
|
|
454
494
|
- `pause()` / `resume()` to stop or resume forwarding new audio frames.
|
|
455
495
|
- `finalize()` to force the current utterance to flush.
|
|
456
|
-
- `destroy()` to close connector
|
|
496
|
+
- `destroy()` to close the warm TCP/WS connector and subscriptions.
|
|
457
497
|
|
|
458
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.
|
|
459
499
|
|
|
@@ -511,8 +551,70 @@ When both `name` (platform key) and explicit `data` are provided, `data` values
|
|
|
511
551
|
All audio playback goes through **`channel.audio`** (`ChannelAudio`). There are no top-level
|
|
512
552
|
`channel.say()` / `channel.play()` shortcuts on `MediaChannel`.
|
|
513
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
|
+
|
|
514
612
|
| Method | Purpose |
|
|
515
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 |
|
|
516
618
|
| `channel.audio.say(textOrObservable, options?)` | Synthesize text with TTS and play on a mixer queue |
|
|
517
619
|
| `channel.audio.play(source, options?)` | Play raw audio (URL, path, or platform phrase record) |
|
|
518
620
|
| `channel.audio.presay(text, options?)` | Pre-synthesize TTS into the host cache (no playback) |
|
|
@@ -592,7 +694,7 @@ When phrase persistence is enabled, `preload()` can store decoded audio for late
|
|
|
592
694
|
|
|
593
695
|
`ttsStrategy` controls how text is chunked:
|
|
594
696
|
|
|
595
|
-
- `sentence`: split on sentence boundaries and synthesize each sentence. This is the default.
|
|
697
|
+
- `sentence`: split on sentence boundaries and synthesize each sentence. This is the default. Only one sentence is synthesized at a time; when synthesis of N finishes, N+1 starts immediately while N continues playing from the mixer queue. Sentence N is fired as soon as its text is complete — it never waits for sentence N+1. For ElevenLabs HTTP TTS, each request gets `previous_text` / `next_text` when those neighbor texts are already available (e.g. full string already split); on an LLM stream typically only `previous_text` is known at fire time. Scripts do not need to set these fields. `eleven_v3` does not support those fields (API 400), so they are omitted for that model. The TTS cache key is still the sentence text only (neighbors are not part of the key), so cache hits may replay audio synthesized under a different neighbor context.
|
|
596
698
|
- `streaming`: send chunks incrementally for streaming-capable vendors.
|
|
597
699
|
- `full`: accumulate the whole input and synthesize it as one segment after the input completes.
|
|
598
700
|
|
|
@@ -813,7 +915,7 @@ channel.events.error$.subscribe((err) => {
|
|
|
813
915
|
| --- | --- | --- |
|
|
814
916
|
| `source` | `'asr' \| 'tts' \| 'sip' \| 'channel' \| 'llm'` | Which subsystem produced the error. |
|
|
815
917
|
| `phase` | `'create' \| 'start' \| 'stream' \| 'playback' \| 'finalize' \| 'destroy'?` | Lifecycle phase where the error happened. |
|
|
816
|
-
| `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`. |
|
|
817
919
|
| `recoverable` | `boolean?` | Whether the runtime can keep the session alive after this error. |
|
|
818
920
|
| `handleId` | `string?` | ASR handle id when the error belongs to a recognizer instance. |
|
|
819
921
|
| `queue` | `number?` | Mixer queue index when the error belongs to an audio operation. |
|
|
@@ -931,7 +1033,7 @@ return {
|
|
|
931
1033
|
};
|
|
932
1034
|
```
|
|
933
1035
|
|
|
934
|
-
- **`output`** — stored in dialog stats / host persistence.
|
|
1036
|
+
- **`output`** — stored in dialog stats / host persistence. This is **not** the LE `dialog.result` lifecycle column — that is `platform.dialog.result` (see [Dialog State](#dialog-state)).
|
|
935
1037
|
- **`error`** — optional; usually auto-populated on crash, but scripts may set it explicitly.
|
|
936
1038
|
|
|
937
1039
|
**Do not** return `env` from the script. Persist state via `context.env$`; the runtime snapshots it
|
|
@@ -947,6 +1049,8 @@ messaging, etc.
|
|
|
947
1049
|
**`context.headless === true` only means “no live SIP/media”.** It does **not** tell you whether
|
|
948
1050
|
the run is before or after a call. For that, use `getScriptPhase`.
|
|
949
1051
|
|
|
1052
|
+
The return value is the `ScriptPhase` union — one of the phases in the table below.
|
|
1053
|
+
|
|
950
1054
|
| Phase | `context.headless` | When | Typical `context.entryPoint` |
|
|
951
1055
|
|-------|-------------------|------|--------------------------------|
|
|
952
1056
|
| `before_call` | `true` | Dialog queue / bulk outbound **before** the first platform call (often schedules `platform.call`) | empty, `main`, `default` |
|
|
@@ -1013,7 +1117,7 @@ export default defineScript(async ({ channel, context, logger, platform }) => {
|
|
|
1013
1117
|
|
|
1014
1118
|
`platform` exposes platform operations.
|
|
1015
1119
|
|
|
1016
|
-
`platform.nlu.extract(utterance, options?)` runs intent/entity extraction. If `options.context` is omitted
|
|
1120
|
+
`platform.nlu.extract(utterance, options?)` runs intent/entity extraction. If `options.context` is omitted or `null`, the runtime sends **no** NLU context — there is no auto-fill from dialog params or `flag`. Pass it explicitly when needed (logic-executor scripts usually pass `context.flag`). Default NLU language comes from the LE agent (`_nlu.language`), not `context.lang`.
|
|
1017
1121
|
|
|
1018
1122
|
`platform.nlu.extract$()` is an Observable wrapper — one `extract()` call per subscription, not a streaming NLU session.
|
|
1019
1123
|
|
|
@@ -1021,20 +1125,64 @@ export default defineScript(async ({ channel, context, logger, platform }) => {
|
|
|
1021
1125
|
const result = await platform.nlu.extract('I want to reschedule', {
|
|
1022
1126
|
intents: ['reschedule', 'cancel'],
|
|
1023
1127
|
entities: ['date', 'time'],
|
|
1128
|
+
context: context.flag,
|
|
1024
1129
|
use_synonyms: true,
|
|
1025
1130
|
});
|
|
1026
1131
|
```
|
|
1027
1132
|
|
|
1028
|
-
Platform APIs (`platform.nlu`, `platform.call`, dialog writes, messaging, phrase records) are available when the host enables platform integration.
|
|
1133
|
+
Platform APIs (`platform.nlu`, `platform.call`, dialog writes, messaging, phrase records) are available when the host enables platform integration (`context.legacyV3Compat`).
|
|
1029
1134
|
|
|
1030
1135
|
### Dialog State
|
|
1031
1136
|
|
|
1137
|
+
`platform.dialog` reads and writes the LE **dialog row** — not SIP media and not the script return value.
|
|
1138
|
+
|
|
1139
|
+
#### What `platform.dialog.result` is
|
|
1140
|
+
|
|
1141
|
+
`platform.dialog.result` maps to the PostgreSQL column **`dialog.result`**: the **lifecycle status** of the dialog entity in the CMS / offline queue (in queue, in progress, closed). It is **not** the outcome of a SIP leg.
|
|
1142
|
+
|
|
1143
|
+
| Value | Meaning |
|
|
1144
|
+
| --- | --- |
|
|
1145
|
+
| `null` | Often after-call continuation: dialog re-enters queue-api, then becomes `queued` |
|
|
1146
|
+
| `queued` | In the offline queue, not yet claimed |
|
|
1147
|
+
| `pending` | In progress (live SIP/WS or claimed queue row) |
|
|
1148
|
+
| `done` | Dialog closed successfully (terminal for the pipeline) |
|
|
1149
|
+
| `error` | Dialog closed with a logic/runtime error |
|
|
1150
|
+
|
|
1151
|
+
The **host** also moves these statuses (live session → `pending`; shutdown without continuation → often `done` / `error`; automatic recall → `pending`; after-call chain → `null` + `entry_point` in params). Scripts set `platform.dialog.result` when they want to **explicitly** fix the LE dialog status (commonly `'done'` in a headless after-call handler). That does **not** replace `channel.sip.hangup()`.
|
|
1152
|
+
|
|
1153
|
+
#### Do not confuse
|
|
1154
|
+
|
|
1155
|
+
| API | Layer | Does | Does not |
|
|
1156
|
+
| --- | --- | --- | --- |
|
|
1157
|
+
| `platform.dialog.result` | LE `dialog` row | Lifecycle status (`done`, `pending`, …) | Hang up SIP; equal `call.result`; equal `ScriptResult.output` |
|
|
1158
|
+
| `platform.dialog.entryPoint` | LE `dialog.params` | Persist routing hint for later headless/queue runs | Change SIP state; select another script export |
|
|
1159
|
+
| `context.entryPoint` | `ScriptDialogContext` | **Snapshot** of `entry_point` at script start (`getScriptPhase`) | Persist if you assign it — write via `platform.dialog.entryPoint` |
|
|
1160
|
+
| `return { output }` / `ScriptResult` | Script return | dialog_stats / host dump | LE `dialog.result` column |
|
|
1161
|
+
| `channel.sip.hangup()` / `terminated$` | Media leg | End or observe SIP/WS media | Set `platform.dialog.result` by itself |
|
|
1162
|
+
| `call.result` (LE call row) | Per-call | SIP terminal code/phrase for CMS logs | Same as `dialog.result` |
|
|
1163
|
+
|
|
1164
|
+
There is no `context.result` field — read/write dialog lifecycle only through `platform.dialog.result`.
|
|
1165
|
+
|
|
1166
|
+
#### `entryPoint` write vs read
|
|
1167
|
+
|
|
1168
|
+
```ts
|
|
1169
|
+
// Persist routing for the next offline run (dialog.params.entry_point)
|
|
1170
|
+
platform.dialog.entryPoint = 'on_recall';
|
|
1171
|
+
|
|
1172
|
+
// Snapshot for this run — use with getScriptPhase(context)
|
|
1173
|
+
logger.log('branch', { entryPoint: context.entryPoint });
|
|
1174
|
+
```
|
|
1175
|
+
|
|
1176
|
+
`ScheduleCallOptions.entryPoint` on `platform.call()` is stored on the **call** row at schedule time — different from assigning `platform.dialog.entryPoint` mid-script.
|
|
1177
|
+
|
|
1178
|
+
#### Example
|
|
1179
|
+
|
|
1032
1180
|
```ts
|
|
1033
1181
|
platform.dialog.entryPoint = 'on_recall';
|
|
1034
1182
|
platform.dialog.result = 'done';
|
|
1035
1183
|
```
|
|
1036
1184
|
|
|
1037
|
-
Setters update the local value immediately and persist
|
|
1185
|
+
Setters update the local value immediately and persist asynchronously. They are not awaitable and should not be used as transactional writes. See [examples/after-call-continuation.ts](./examples/after-call-continuation.ts).
|
|
1038
1186
|
|
|
1039
1187
|
### Platform-Scheduled Calls
|
|
1040
1188
|
|
|
@@ -1350,7 +1498,7 @@ Agents with both CMS contact-rules and diagram `on_failed_call` handlers use the
|
|
|
1350
1498
|
recall fields on `context` are informational unless your script passes them explicitly.
|
|
1351
1499
|
|
|
1352
1500
|
`context.attempt` is the current recall attempt counter from `dialog.params.attempt` (starts at 0).
|
|
1353
|
-
`context.entryPoint` is the routing branch for this run (
|
|
1501
|
+
`context.entryPoint` is the routing branch **snapshot** for this run (from `dialog.params.entry_point` at start). To persist a new value, assign `platform.dialog.entryPoint` — see [Dialog State](#dialog-state).
|
|
1354
1502
|
|
|
1355
1503
|
```ts
|
|
1356
1504
|
// Use effective values when scheduling the next outbound leg
|
|
@@ -1393,11 +1541,12 @@ Important fields:
|
|
|
1393
1541
|
- `context.dialogUuid`: current dialog UUID.
|
|
1394
1542
|
- `context.callerId` / `context.msisdn`: caller identity.
|
|
1395
1543
|
- `context.destinationNumber`: called number.
|
|
1544
|
+
- `context.trunkId` / `context.trunkName`: LE trunk for this dialog/call (snapshot; name from `trunk` table).
|
|
1396
1545
|
- `context.language` / `context.lang`: language selected for the run.
|
|
1397
1546
|
- `context.flag`: business flag.
|
|
1398
1547
|
- `context.initialData`: shallow snapshot of params at script start.
|
|
1399
1548
|
- `context.dialogParams`: live param map for the run.
|
|
1400
|
-
- `context.entryPoint`:
|
|
1549
|
+
- `context.entryPoint`: routing entry point **snapshot** at script start (see [Script Lifecycle](#script-lifecycle-getscriptphase)); persist changes via `platform.dialog.entryPoint`.
|
|
1401
1550
|
- `context.attempt`: current recall attempt number (`dialog.params.attempt`; use with `phase === 'online'`).
|
|
1402
1551
|
- `context.recallCount` / `context.recallDelay`: effective recall settings for this dialog/call.
|
|
1403
1552
|
- `context.agent?.recallCount` / `context.agent?.recallDelay`: CMS agent defaults (immutable snapshot).
|
|
@@ -1405,6 +1554,8 @@ Important fields:
|
|
|
1405
1554
|
- `context.runTime`: async execution budget helper.
|
|
1406
1555
|
- `context.env$`: persisted dialog environment as an RxJS `BehaviorSubject`.
|
|
1407
1556
|
|
|
1557
|
+
Dialog lifecycle status (`dialog.result`) is **not** on `context` — use `platform.dialog.result` ([Dialog State](#dialog-state)).
|
|
1558
|
+
|
|
1408
1559
|
Use `env$` for persisted script state:
|
|
1409
1560
|
|
|
1410
1561
|
```ts
|
|
@@ -1440,8 +1591,10 @@ WS channels behave like active media channels:
|
|
|
1440
1591
|
Headless channels are for offline, queue, or messaging sessions:
|
|
1441
1592
|
|
|
1442
1593
|
- Audio methods are no-ops that log warnings.
|
|
1443
|
-
- SIP methods are
|
|
1444
|
-
-
|
|
1594
|
+
- SIP methods are no-ops, except `makeCall()` and `bridge()`, which throw: there is no real leg to
|
|
1595
|
+
create, and a silent no-op would hide the mistake.
|
|
1596
|
+
- `createAsr()` returns an inert handle whose observables complete immediately.
|
|
1597
|
+
- `createTts()` returns an inert handle (no vendor connection is opened).
|
|
1445
1598
|
- LLM, NLU, messaging, platform calls, dialog state, and `env$` still work.
|
|
1446
1599
|
|
|
1447
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';
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,Y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,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
|
|
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.
|
|
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;IAC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AE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAClE,kEAAkE;IAClE,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,gFAAgF;IAChF,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,6FAA6F;IAC7F,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAE7C;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAExC,0FAA0F;IAC1F,KAAK,IAAI,IAAI,CAAC;IACd,kCAAkC;IAClC,MAAM,IAAI,IAAI,CAAC;IACf,kFAAkF;IAClF,QAAQ,IAAI,IAAI,CAAC;IACjB,8FAA8F;IAC9F,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types/events.d.ts
CHANGED
|
@@ -5,11 +5,18 @@ export interface DtmfEvent {
|
|
|
5
5
|
/** Duration of the tone in milliseconds, normalized by the channel when available. */
|
|
6
6
|
duration: number;
|
|
7
7
|
}
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Incoming SIP INFO on a live call leg — mid-call signalling only.
|
|
10
|
+
*
|
|
11
|
+
* The host exposes **`contentType` + `body` only**. SIP headers on the INFO
|
|
12
|
+
* request (e.g. `X-language`) are **not** forwarded. Prefer
|
|
13
|
+
* {@link import('./sip').ChannelSip.dtmf$} for DTMF. Start-of-call INVITE
|
|
14
|
+
* headers are {@link import('./sip').ChannelSip.inviteSipHeaders}, not this type.
|
|
15
|
+
*/
|
|
9
16
|
export interface SipInfo {
|
|
10
17
|
/** MIME content type (e.g. `"application/dtmf-relay"`, `"application/xml"`). */
|
|
11
18
|
contentType: string;
|
|
12
|
-
/** Raw message body as received from the stack. */
|
|
19
|
+
/** Raw message body as received from the stack (not INFO SIP headers). */
|
|
13
20
|
body: string;
|
|
14
21
|
}
|
|
15
22
|
/** Low-level Sofia SIP stack state-change event (see also {@link import('./sip').SipState}). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAC;IACd,sFAAsF;IACtF,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,gGAAgG;AAChG,MAAM,WAAW,SAAS;IACxB,sGAAsG;IACtG,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Observable } from 'rxjs';
|
|
2
2
|
import type { AsrConfig, AsrHandle } 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,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6GAA6G;IAC7G,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,wFAAwF;IACxF,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
package/dist/types/mixer.d.ts
CHANGED
|
@@ -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":["../../src/types/mixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
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;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;;;;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,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wFAAwF;IACxF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0DAA0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IAAI,IAAI,CAAC;CACf"}
|
package/dist/types/nlu.d.ts
CHANGED
|
@@ -21,10 +21,12 @@ export interface NluExtractOptions {
|
|
|
21
21
|
/** Legacy compatibility field; mapped to exclude policy on nlu-engine. */
|
|
22
22
|
intents_exclude?: string | string[] | null;
|
|
23
23
|
/**
|
|
24
|
-
*
|
|
24
|
+
* Opaque NLU disambiguation context (not {@link import('./script-context').ScriptDialogContext}).
|
|
25
25
|
*
|
|
26
|
-
* Objects and arrays are JSON-stringified before sending. When omitted
|
|
27
|
-
*
|
|
26
|
+
* Objects and arrays are JSON-stringified before sending. When omitted or `null`,
|
|
27
|
+
* the runtime sends **no** NLU context (`null`) — there is no auto-fill from dialog
|
|
28
|
+
* params or `flag`. Pass explicitly when needed (logic-executor scripts usually pass
|
|
29
|
+
* `context.flag`).
|
|
28
30
|
*/
|
|
29
31
|
context?: string | unknown[] | Record<string, unknown> | null;
|
|
30
32
|
/**
|
package/dist/types/nlu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nlu.d.ts","sourceRoot":"","sources":["../../src/types/nlu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,0EAA0E;IAC1E,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3C
|
|
1
|
+
{"version":3,"file":"nlu.d.ts","sourceRoot":"","sources":["../../src/types/nlu.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,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CAAC,CAAC;IACnC,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAAC;IACxE,uBAAuB,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI,CAAC;IACxE,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACjE,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAChE,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,SAAS,IAAI,MAAM,CAAC;CACrB"}
|
package/dist/types/platform.d.ts
CHANGED
|
@@ -42,12 +42,15 @@ export interface ScheduleCallOptions {
|
|
|
42
42
|
/** Deadline — don't call after this time. */
|
|
43
43
|
dateEnd?: string | Date;
|
|
44
44
|
/**
|
|
45
|
-
* Optional label stored
|
|
45
|
+
* Optional label stored on the **call** row as `call.params.entry_point` (LE DB compatibility)
|
|
46
|
+
* at schedule time. This is not the same as assigning {@link DialogApi.entryPoint} mid-script
|
|
47
|
+
* (that writes `dialog.params.entry_point`).
|
|
46
48
|
*
|
|
47
49
|
* The host always runs your single `defineScript` export — it does **not** invoke a
|
|
48
50
|
* separate function by this name (unlike logic-executor Python `run_unit(entry_point=...)`).
|
|
49
51
|
* Use {@link import('./script-context').ScriptDialogContext.entryPoint} inside the handler
|
|
50
|
-
* if you branch manually (e.g. headless after-call via
|
|
52
|
+
* if you branch manually (e.g. headless after-call via
|
|
53
|
+
* {@link import('./script-context').getScriptPhase}).
|
|
51
54
|
*/
|
|
52
55
|
entryPoint?: string;
|
|
53
56
|
/**
|
|
@@ -85,16 +88,21 @@ export interface ScheduleCallOptions {
|
|
|
85
88
|
* Mutually exclusive with {@link onFailedCall}.
|
|
86
89
|
*/
|
|
87
90
|
recallDelay?: number;
|
|
88
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Headless handler name after a successful call. Stored as `on_success_call`.
|
|
93
|
+
* On shutdown the host may set `dialog.result = null` and `dialog.params.entry_point` to this
|
|
94
|
+
* value so the dialog re-enters the offline queue for continuation.
|
|
95
|
+
*/
|
|
89
96
|
onSuccessCall?: string;
|
|
90
97
|
/**
|
|
91
98
|
* Headless handler after a failed outbound. Stored as `on_failed_call`.
|
|
92
99
|
*
|
|
93
|
-
* Activates **after-call continuation**: the host sets `dialog.params.entry_point` and
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
100
|
+
* Activates **after-call continuation**: the host sets `dialog.params.entry_point` (and typically
|
|
101
|
+
* `dialog.result = null`) and re-runs this script with
|
|
102
|
+
* {@link import('./script-context').getScriptPhase} → `after_call_failed`. Mutually exclusive
|
|
103
|
+
* with automatic recall ({@link recallCount} + {@link recallDelay}) on the same `platform.call()`.
|
|
104
|
+
* If both are present, the host keeps this option and drops recall. When set (including via Omni
|
|
105
|
+
* `scheduleOutbound` defaults), CMS recall is not auto-copied onto the `call` row.
|
|
98
106
|
*/
|
|
99
107
|
onFailedCall?: string;
|
|
100
108
|
/** Call priority (higher = processed sooner by dialer). */
|
|
@@ -115,21 +123,44 @@ export interface ScheduleCallOptions {
|
|
|
115
123
|
bulkUuid?: string;
|
|
116
124
|
}
|
|
117
125
|
/**
|
|
118
|
-
*
|
|
126
|
+
* LE **dialog row** helpers — lifecycle status (`result`) and routing (`entryPoint`).
|
|
119
127
|
*
|
|
128
|
+
* These fields map to the Voctiv platform `dialog` table, not to SIP media.
|
|
120
129
|
* Setting `entryPoint` or `result` updates the local value immediately and asks
|
|
121
|
-
* the
|
|
122
|
-
*
|
|
123
|
-
*
|
|
130
|
+
* the database to persist asynchronously (worker RPC or direct session). Setters
|
|
131
|
+
* are not awaitable — do not use them for transactional flow.
|
|
132
|
+
*
|
|
133
|
+
* Do **not** confuse with {@link import('./sip').ChannelSip.hangup}, SIP
|
|
134
|
+
* `call.result`, or {@link import('./script-context').ScriptResult}.
|
|
124
135
|
*/
|
|
125
136
|
export interface DialogApi {
|
|
126
|
-
/**
|
|
137
|
+
/**
|
|
138
|
+
* Writable routing hint persisted as `dialog.params.entry_point`.
|
|
139
|
+
*
|
|
140
|
+
* Distinct from the read-only snapshot
|
|
141
|
+
* {@link import('./script-context').ScriptDialogContext.entryPoint} taken at
|
|
142
|
+
* script start. Assigning here does **not** select a different script export —
|
|
143
|
+
* the host always runs the same `defineScript` handler; branch with
|
|
144
|
+
* {@link import('./script-context').getScriptPhase} / `context.entryPoint`.
|
|
145
|
+
*/
|
|
127
146
|
entryPoint: string | undefined;
|
|
128
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Lifecycle status of the LE **`dialog.result`** column (queue / CMS), not the
|
|
149
|
+
* SIP call outcome.
|
|
150
|
+
*
|
|
151
|
+
* Typical values: `"pending"` (in progress), `"queued"` (offline queue),
|
|
152
|
+
* `"done"` / `"error"` (terminal), or `null` (e.g. after-call continuation so
|
|
153
|
+
* the dialog re-enters the queue). The host also sets these on live session
|
|
154
|
+
* start and shutdown.
|
|
155
|
+
*
|
|
156
|
+
* Does **not** hang up SIP or change `channel.sip.state`. Not
|
|
157
|
+
* {@link import('./script-context').ScriptResult}, not `call.result` (per-leg
|
|
158
|
+
* SIP code/phrase for CMS logs).
|
|
159
|
+
*/
|
|
129
160
|
result: string | undefined;
|
|
130
|
-
/**
|
|
161
|
+
/** Same dialog UUID as {@link import('./script-context').ScriptDialogContext.dialogUuid}. */
|
|
131
162
|
readonly uuid: string;
|
|
132
|
-
/**
|
|
163
|
+
/** Same caller identity as {@link import('./script-context').ScriptDialogContext.msisdn}. */
|
|
133
164
|
readonly msisdn: string;
|
|
134
165
|
}
|
|
135
166
|
/** Options for sending an outbound message via {@link MessagingApi.send}. */
|
|
@@ -191,7 +222,10 @@ export interface MessagingApi {
|
|
|
191
222
|
export interface PlatformApi {
|
|
192
223
|
/** NLU intent/entity extraction API; throws outside legacy V3 compatibility mode. */
|
|
193
224
|
readonly nlu: NluScriptApi;
|
|
194
|
-
/**
|
|
225
|
+
/**
|
|
226
|
+
* LE dialog lifecycle and routing ({@link DialogApi.result}, {@link DialogApi.entryPoint}).
|
|
227
|
+
* Not SIP hangup / media — see {@link import('./sip').ChannelSip}.
|
|
228
|
+
*/
|
|
195
229
|
readonly dialog: DialogApi;
|
|
196
230
|
/** Messaging API — send and receive external messages. */
|
|
197
231
|
readonly messaging: MessagingApi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/types/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;;;;;OAWG;IACH,OAAO,CACL,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CACN,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,UAAU,CAAC,cAAc,CAAC,CAAC;CAC/B;AAED,4EAA4E;AAC5E,MAAM,WAAW,mBAAmB;IAClC,+CAA+C;IAC/C,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/types/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,K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C,MAAM,EAAE,SAAS,CAAC;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC;IACjC;;;;;OAKG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnE;;;;;;OAMG;IACH,UAAU,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CAC5E"}
|
|
@@ -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. */
|
|
@@ -145,7 +160,13 @@ export interface ScriptDialogContext {
|
|
|
145
160
|
* {@link import('./mixer').PlayOptions} to select **`key_storage.name`** when LE credential maps exist.
|
|
146
161
|
*/
|
|
147
162
|
availableMediaKeys?: string[];
|
|
148
|
-
/**
|
|
163
|
+
/**
|
|
164
|
+
* Routing hint from `dialog.params.entry_point` **at script start** (snapshot).
|
|
165
|
+
*
|
|
166
|
+
* Use with {@link getScriptPhase} to branch inside the same `defineScript` export.
|
|
167
|
+
* Assigning this property does **not** persist — write via
|
|
168
|
+
* {@link import('./platform').DialogApi.entryPoint} (`platform.dialog.entryPoint`).
|
|
169
|
+
*/
|
|
149
170
|
entryPoint?: string;
|
|
150
171
|
/** Current recall attempt number for this dialog (from `dialog.params.attempt`, starts at 0). */
|
|
151
172
|
attempt?: number;
|
|
@@ -237,9 +258,15 @@ export interface ScriptError {
|
|
|
237
258
|
/**
|
|
238
259
|
* Value returned by a script function. Only `output` and `error` are valid fields.
|
|
239
260
|
* Session state is updated via `context.env$`; the runtime snapshots it separately.
|
|
261
|
+
*
|
|
262
|
+
* This is **not** the LE `dialog.result` lifecycle column — that is
|
|
263
|
+
* {@link import('./platform').DialogApi.result} (`platform.dialog.result`).
|
|
240
264
|
*/
|
|
241
265
|
export interface ScriptResult {
|
|
242
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Output data for dialog_stats / host persistence.
|
|
268
|
+
* Not {@link import('./platform').DialogApi.result}.
|
|
269
|
+
*/
|
|
243
270
|
output?: Record<string, unknown>;
|
|
244
271
|
/** Error details (auto-populated on script crash, or set manually). */
|
|
245
272
|
error?: ScriptError;
|
|
@@ -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,uFAAuF;AACvF,MAAM,WAAW,YAAY;IAC3B,4DAA4D;IAC5D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IAC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AE,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 +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":";;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"}
|
package/dist/types/sip.d.ts
CHANGED
|
@@ -133,15 +133,15 @@ export interface SipProgressEvent {
|
|
|
133
133
|
* call state (e.g. create ASR only after media is available).
|
|
134
134
|
*/
|
|
135
135
|
/**
|
|
136
|
-
* SIP headers captured from an **inbound INVITE** at call setup.
|
|
136
|
+
* SIP headers captured from an **inbound INVITE** at call setup (start-of-call only).
|
|
137
137
|
*
|
|
138
|
-
* Keys use the on-wire header name (`Diversion`, `P-Asserted-Identity`, `X-Trunk-Id`,
|
|
139
|
-
* Values are a single string or a string array when the same header
|
|
140
|
-
* (e.g. several `Diversion` hops).
|
|
138
|
+
* Keys use the on-wire header name (`Diversion`, `P-Asserted-Identity`, `X-Trunk-Id`,
|
|
139
|
+
* `X-language`, …). Values are a single string or a string array when the same header
|
|
140
|
+
* appears multiple times (e.g. several `Diversion` hops).
|
|
141
141
|
*
|
|
142
|
-
* **Snapshot only** — does not update on 180/200, re-INVITE, or BYE. Outbound B-legs
|
|
143
|
-
* typically have no
|
|
144
|
-
*
|
|
142
|
+
* **Snapshot only** — does not update on 180/200, re-INVITE, or BYE. Outbound B-legs /
|
|
143
|
+
* WS / headless typically have no snapshot (`undefined`). For mid-call peer signals use
|
|
144
|
+
* {@link ChannelSip.sipInfo$} (body/contentType only). Casing matches what Sofia exposes.
|
|
145
145
|
*/
|
|
146
146
|
export type SipInviteHeaders = Record<string, string | string[]>;
|
|
147
147
|
/**
|
|
@@ -187,10 +187,13 @@ export interface ChannelSip {
|
|
|
187
187
|
*/
|
|
188
188
|
readonly dtmf$: Observable<DtmfEvent>;
|
|
189
189
|
/**
|
|
190
|
-
*
|
|
190
|
+
* Mid-call SIP INFO stream — use when the peer signals **during** the call
|
|
191
|
+
* (language change, vendor payload, etc.).
|
|
191
192
|
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
193
|
+
* Each event is {@link SipInfo}: **`contentType` + `body` only**. Headers on
|
|
194
|
+
* the INFO request are not exposed. This does **not** update
|
|
195
|
+
* {@link inviteSipHeaders}. Prefer {@link dtmf$} for DTMF.
|
|
196
|
+
* **Hot stream** — events before subscribe are not replayed.
|
|
194
197
|
*
|
|
195
198
|
* ```ts
|
|
196
199
|
* sip.sipInfo$.subscribe(({ contentType, body }) => {
|
|
@@ -216,7 +219,13 @@ export interface ChannelSip {
|
|
|
216
219
|
*/
|
|
217
220
|
readonly remoteSdp?: string;
|
|
218
221
|
/**
|
|
219
|
-
*
|
|
222
|
+
* **Start-of-call** snapshot of SIP headers from the **inbound INVITE**
|
|
223
|
+
* (routing, `X-Trunk-Id`, `X-Neuro-UUID`, `X-language`, …). See {@link SipInviteHeaders}.
|
|
224
|
+
*
|
|
225
|
+
* Does **not** update on 180/200/re-INVITE/BYE. Outbound B-legs, WS, and headless
|
|
226
|
+
* usually have `undefined`. For mid-call peer signals use {@link sipInfo$}
|
|
227
|
+
* (body/contentType only — INFO headers are not available). Live response
|
|
228
|
+
* headers are not exposed; {@link sipSignal$} has status code/phrase/SDP only.
|
|
220
229
|
*
|
|
221
230
|
* ```ts
|
|
222
231
|
* const h = channel.sip.inviteSipHeaders;
|
package/dist/types/sip.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sip.d.ts","sourceRoot":"","sources":["../../src/types/sip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,SAAS,GACT,OAAO,GACP,QAAQ,GACR,SAAS,GACT,YAAY,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG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QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACzC,mBAAmB,CAAC,EAAE;YACpB,SAAS,EAAE,MAAM,CAAC;YAClB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC1C,CAAC;KACH,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1B;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,IAAI,CAAC;CACzC"}
|
|
@@ -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,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,IA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;;;;;;;;;;;;;;;;;;;;;;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 @@
|
|
|
1
|
+
{"version":3,"file":"tts-handle.js","sourceRoot":"","sources":["../../src/types/tts-handle.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED