@voctiv/agent-sdk 0.2.6 → 0.2.8

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.
@@ -1,322 +1,7 @@
1
- import type { BehaviorSubject, Observable } from 'rxjs';
2
1
  import type { MediaChannel } from './types/media-channel';
3
- import { ScriptLogger } from './types/logger';
4
- import type { NluExtractOptions, NluInferResult } from './types/nlu';
5
- import type { LegacyGetRecordsParams, LegacyPhraseRecord } from './types/legacy-phrase';
6
- /**
7
- * NLU (Natural Language Understanding) API.
8
- *
9
- * Provides intent/entity extraction through the legacy NLU v3 `/infer` endpoint.
10
- * ScriptEngine allows this API when `context.legacyV3Compat` is `true` and NLU
11
- * runtime settings are configured (`NLU_V3_BASE_URL` plus a resolved numeric
12
- * agent id). Calls fail fast with a descriptive error otherwise.
13
- *
14
- * Compatible with logic-executor `nn.extract()` request/response shape.
15
- */
16
- export interface NluScriptApi {
17
- /**
18
- * Extract intents and entities from one user utterance.
19
- *
20
- * The runtime sends `{ phrase, context, agent_id }` to NLU v3. If
21
- * `options.context` is omitted, it serializes the current dialog params
22
- * (`context.dialogParams`, then legacy fallbacks) as the request context.
23
- *
24
- * @param utterance - User input text to analyze.
25
- * @param options - Optional NLU filters and flags. `entities`, `intents`,
26
- * `use_neuro_api`, and `use_synonyms` are forwarded by ScriptEngine.
27
- * @returns Raw parsed JSON response from the NLU `/infer` endpoint.
28
- */
29
- extract(utterance: string, options?: NluExtractOptions): Promise<NluInferResult>;
30
- /**
31
- * Observable wrapper around {@link extract}.
32
- *
33
- * This is not a streaming NLU session: every subscription performs one
34
- * `extract()` call and emits exactly one result or one error.
35
- */
36
- extract$(utterance: string, options?: NluExtractOptions): Observable<NluInferResult>;
37
- }
38
- /**
39
- * First-level **`context`** passed to every **`defineScript`** handler.
40
- *
41
- * Combines **identity** (dialog, script, agent), **telephony** (caller/destination),
42
- * **payload** (**`initialData`** vs **`dialogParams`**), **Voctiv platform** rows (**`dialogEntity`**),
43
- * and **runtime** (**`env$`**, **`runTime`**). The index signature allows extra host-specific keys.
44
- */
45
- export interface ScriptDialogContext {
46
- /** Short language code, e.g. `"ru"`, `"en"`. */
47
- lang: string;
48
- /** Full BCP-47 language tag, e.g. `"ru-RU"`, `"en-US"`. */
49
- language: string;
50
- /** Business flag for routing (e.g. `"default"`, `"vip"`). */
51
- flag: string;
52
- /** Unique dialog identifier (UUID). */
53
- dialogUuid: string;
54
- /** Caller phone number or messaging source ID. */
55
- msisdn: string;
56
- /** Inbound caller ID (same as msisdn for inbound calls). */
57
- callerId: string;
58
- /** Called number (DID / destination for inbound calls). */
59
- destinationNumber: string;
60
- /** Script record ID in the system. */
61
- scriptId: string;
62
- /** Human-readable script name. */
63
- scriptName: string;
64
- /** Agent UUID from Omni platform (links script to an NLU agent). */
65
- agentUuid?: string;
66
- /**
67
- * Numeric NLU agent id used for `platform.nlu.extract()` and legacy DB operations.
68
- *
69
- * Resolved by the server from Omni/LE mapping or env (`NLU_DEFAULT_AGENT_ID` /
70
- * `AGENT_ID`). Client/session params named `agent_id`, `agentId`, `agentUuid`,
71
- * and `agent_uuid` are stripped before context construction and cannot spoof it.
72
- * May be `0` when no agent id is configured; NLU and `platform.call()` will then fail.
73
- */
74
- agentId: number;
75
- /**
76
- * **Snapshot** of dialog/session payload when the script run started.
77
- *
78
- * Shallow copy of the merge **`channelParams` + `sessionParams`** after the server removes
79
- * untrusted keys (e.g. client cannot spoof **`agentUuid`** here). **Do not mutate** — use
80
- * **`dialogParams`** for the live map. Compare with **`dialogParams`** to see what changed
81
- * during the call (if the host updates the live object).
82
- */
83
- initialData: Record<string, unknown>;
84
- /**
85
- * **Live** dialog/session parameter map for this run (same merge as **`initialData`** at start).
86
- *
87
- * The host may add or overwrite keys while the session progresses. For media scripts this
88
- * aligns with {@link import('./types/media-channel').MediaChannel.params} (Omni defaults, route,
89
- * Voctiv platform ASR/TTS: **`defaultAsrName`**, **`defaultTtsName`**, **`asrVendor`**, **`ttsVendor`**,
90
- * **`asrConfig`**, **`ttsConfig`**, **`authentication_data`**, **`legacyAsrKeysByName`** /
91
- * **`legacyTtsKeysByName`**, etc.). **Read/write** according to your integration; scripts should
92
- * treat unknown keys as opaque.
93
- */
94
- dialogParams: Record<string, unknown>;
95
- /** Whether Voctiv platform compatibility mode is active. */
96
- legacyV3Compat: boolean;
97
- /** `true` when the script runs without a real media channel (offline / queue / messaging). */
98
- headless: boolean;
99
- /**
100
- * Persisted dialog environment for this conversation. ScriptEngine converts the
101
- * plain persisted `env` snapshot into this `BehaviorSubject` before invoking the script.
102
- * On the first call the value is `undefined`.
103
- *
104
- * **Read/write only via `env$`:** use `env$.getValue()`, `env$.next(partialOrNext)`, or
105
- * `env$.subscribe(...)`. Do not use a plain `context.env` — it is not provided.
106
- *
107
- * **Persistence:** On script completion (success or error), the runtime snapshots `env$` and
108
- * attaches it to the persisted result; the script return value must not carry env
109
- * (see {@link ScriptResult}).
110
- *
111
- * Session runners decide where that snapshot is stored. In Voctiv platform compatibility
112
- * mode it is used as the LE-style dialog environment.
113
- */
114
- env$?: BehaviorSubject<Record<string, unknown> | undefined>;
115
- /** Raw `dialog` table row from the Voctiv platform database. */
116
- dialogEntity?: Record<string, unknown>;
117
- /** Raw `call` table row from the Voctiv platform database. */
118
- callEntity?: Record<string, unknown>;
119
- /**
120
- * Optional catalog of media keys exposed to the script (Voctiv platform / Omni), e.g. UUIDs or labels
121
- * for UI or logging. **Credentials** still come from **`dialogParams.authentication_data`**
122
- * (and the channel mirror); use **`name`** on {@link import('./types/asr-handle').AsrConfig} /
123
- * {@link import('./types/mixer').PlayOptions} to select **`key_storage.name`** when LE credential maps exist.
124
- */
125
- availableMediaKeys?: string[];
126
- /** Script entry point for routing (e.g. `"on_recall"`, `"on_message_api_received"`). */
127
- entryPoint?: string;
128
- /** Current recall attempt number (starts at 0). */
129
- attempt?: number;
130
- /** Max recall attempts configured for this dialog. */
131
- recallCount?: number;
132
- /** Delay in seconds between recall attempts. */
133
- recallDelay?: number;
134
- /** Inbound message that triggered this headless session (messaging). */
135
- inboundMessage?: InboundMessage;
136
- /**
137
- * Async-phase execution budget: remaining time, extension pool, {@link ScriptRunTime.extend}.
138
- * Injected by the runtime; absent only in tests or non-standard hosts.
139
- */
140
- runTime?: ScriptRunTime;
141
- /** Opaque NLU runtime config managed by ScriptEngine. */
142
- _nlu?: unknown;
143
- [key: string]: unknown;
144
- }
145
- /**
146
- * Time budget for the script async phase (after VM load). Lets scripts check remaining time
147
- * and request limited extensions (capped by the runtime).
148
- */
149
- export interface ScriptRunTime {
150
- /** Initial budget in ms before any {@link extend}. */
151
- readonly budgetMs: number;
152
- /** Maximum total extra ms grantable across all {@link extend} calls for this session. */
153
- readonly maxExtendMs: number;
154
- /** Milliseconds left until the runtime stops the async script phase. */
155
- remainingMs(): number;
156
- /** Extension quota not yet granted (ms). */
157
- remainingExtendMs(): number;
158
- /**
159
- * Grants up to `requestedMs` additional runtime, limited by remaining extension quota.
160
- * @returns Granted milliseconds (0 if nothing could be granted).
161
- */
162
- extend(requestedMs: number): number;
163
- }
164
- /** Error info attached to {@link ScriptResult} when a script fails. */
165
- export interface ScriptError {
166
- /**
167
- * Machine-readable category, e.g. `script_error`, `script_load_failed`, `time_limit_exceeded`.
168
- */
169
- code: string;
170
- /** Human-readable error description. */
171
- message: string;
172
- /** Stack trace (when available). */
173
- stack?: string;
174
- }
175
- /**
176
- * Value returned by a script function. Only `output` and `error` are valid fields.
177
- * Session state is updated via `context.env$`; the runtime snapshots it separately.
178
- */
179
- export interface ScriptResult {
180
- /** Output data to store in dialog_stats. */
181
- output?: Record<string, unknown>;
182
- /** Error details (auto-populated on script crash, or set manually). */
183
- error?: ScriptError;
184
- }
185
- /**
186
- * Result after the runtime attaches the final `env$` snapshot (Voctiv platform persistence).
187
- * Scripts never construct this type — use {@link ScriptResult} from `defineScript` handlers.
188
- */
189
- export interface PersistedScriptResult extends ScriptResult {
190
- env?: Record<string, unknown>;
191
- }
192
- /** Options for scheduling an outbound call via {@link PlatformApi.call}. */
193
- export interface ScheduleCallOptions {
194
- /** When to place the call. Defaults to now. */
195
- date?: string | Date;
196
- /** Deadline — don't call after this time. */
197
- dateEnd?: string | Date;
198
- /**
199
- * Entry point to pass to the script when the call connects.
200
- *
201
- * Stored in the created call params as `entry_point`.
202
- */
203
- entryPoint?: string;
204
- /**
205
- * Legacy compatibility field for callers that schedule without a current `scriptId`.
206
- *
207
- * ScriptEngine uses this to allow scheduling when the current script id is not
208
- * available. It does not resolve script names or paths from this field.
209
- */
210
- script?: string;
211
- /** Reserved SIP channel/trunk hint. Not used by the default ScriptEngine scheduler. */
212
- channel?: string;
213
- /** How many times to retry on failure. Stored as `recall_count` in call params. */
214
- recallCount?: number;
215
- /** Delay in seconds between retries. Stored as `recall_delay` in call params. */
216
- recallDelay?: number;
217
- /** Entry point to use after a successful call. Stored as `on_success_call`. */
218
- onSuccessCall?: string;
219
- /** Entry point to use after a failed call. Stored as `on_failed_call`. */
220
- onFailedCall?: string;
221
- /** Call priority (higher = processed sooner by dialer). */
222
- priority?: number;
223
- /** Timezone offset passed to the legacy call row as `timeZone`. */
224
- timezone?: number;
225
- /** Extra SIP headers or protocol-level params. Stored as `proto_additional` in call params. */
226
- protoAdditional?: Record<string, string>;
227
- }
228
- /**
229
- * Dialog state API — read and update dialog routing metadata.
230
- *
231
- * Setting `entryPoint` or `result` updates the local value immediately and asks
232
- * the Voctiv platform database to persist the change asynchronously. In worker
233
- * sessions the setter sends an RPC to the main thread; in direct sessions errors
234
- * are logged. There is no awaitable setter, so do not use it for transactional flow.
235
- */
236
- export interface DialogApi {
237
- /** Current script entry point (e.g. `"on_recall"`). Set to change routing for the next call. */
238
- entryPoint: string | undefined;
239
- /** Dialog outcome (e.g. `"done"`, `"busy"`, `"no_answer"`). Set to finalize dialog. */
240
- result: string | undefined;
241
- /** Dialog UUID (read-only). */
242
- readonly uuid: string;
243
- /** Caller msisdn (read-only). */
244
- readonly msisdn: string;
245
- }
246
- /** Options for sending an outbound message via {@link MessagingApi.send}. */
247
- export interface SendMessageOptions {
248
- /** Sender identifier (service id, bot id, or phone number expected by the MA consumer). */
249
- src: string;
250
- /** Recipient identifier (phone number, user id, or channel-specific address). */
251
- destination: string;
252
- /** Text body of the message. When present in legacy mode, it is also mirrored to dialog stats. */
253
- text?: string;
254
- /** URL of an attachment (image, document, etc.). */
255
- attachment?: string;
256
- /** Quick-reply button labels. */
257
- buttons?: string[];
258
- }
259
- /** Inbound message received from an external messaging channel. */
260
- export interface InboundMessage {
261
- /** Sender identifier (who sent the message). */
262
- src: string;
263
- /** Recipient identifier (your service endpoint). */
264
- dst: string;
265
- /** Channel type, e.g. `"api"`. */
266
- channelType: string;
267
- /** Full raw payload from the messaging transport. */
268
- payload: Record<string, unknown>;
269
- }
270
- /**
271
- * Messaging API — send and receive messages through external channels.
272
- *
273
- * Outbound messages are transported via Redis Streams (`ma_send` / `ma_receive`),
274
- * compatible with the old LE messaging architecture. `message$` is currently a
275
- * one-shot replay of the inbound message that started a headless messaging script,
276
- * not a live subscription to all future Redis messages.
277
- */
278
- export interface MessagingApi {
279
- /**
280
- * Send an outbound message.
281
- * Published to Redis stream for delivery by external consumer.
282
- */
283
- send(options: SendMessageOptions): Promise<void>;
284
- /**
285
- * Observable of inbound messages.
286
- * Emits the triggering message when the script is started by an incoming message
287
- * (entry point `on_message_api_received`).
288
- */
289
- readonly message$: Observable<InboundMessage>;
290
- }
291
- /**
292
- * Platform API — Voctiv platform–compatible operations available to scripts.
293
- *
294
- * Provides access to NLU, dialog state management, outbound call scheduling,
295
- * phrase records, and messaging. These operations are legacy-platform backed and
296
- * require `context.legacyV3Compat === true`.
297
- */
298
- export interface PlatformApi {
299
- /** NLU intent/entity extraction API; throws outside legacy V3 compatibility mode. */
300
- readonly nlu: NluScriptApi;
301
- /** Dialog state — read/write entry point and result. */
302
- readonly dialog: DialogApi;
303
- /** Messaging API — send and receive external messages. */
304
- readonly messaging: MessagingApi;
305
- /**
306
- * Schedule an outbound call.
307
- * Creates a record in the `call` table; the dialer picks it up and originates the SIP call.
308
- * @param msisdn - Destination phone number (E.164).
309
- * @param options - Scheduling, routing, and retry options.
310
- */
311
- call(msisdn: string, options?: ScheduleCallOptions): Promise<void>;
312
- /**
313
- * Voctiv platform only: load `record_phrase` / `record_phrase_file` rows from the LE PostgreSQL database
314
- * (same filters as old `RecordPhrase.get_records`). Returns playable phrase record objects.
315
- * Requires numeric `agent_id` on the dialog (params or `NLU_DEFAULT_AGENT_ID`) and
316
- * `LEGACY_V3_RECORD_PHRASE_ROOT` pointing at the phrase file storage root.
317
- */
318
- getRecords?(params: LegacyGetRecordsParams): Promise<LegacyPhraseRecord[]>;
319
- }
2
+ import type { ScriptLogger } from './types/logger';
3
+ import type { ScriptDialogContext, ScriptResult } from './types/script-context';
4
+ import type { PlatformApi } from './types/platform';
320
5
  /**
321
6
  * Top-level context passed to every script function.
322
7
  *
@@ -361,7 +46,8 @@ export type ScriptFn = (ctx: ScriptContext) => void | ScriptResult | Promise<voi
361
46
  * Mark the default export as a typed script entry point (identity wrapper; no runtime transform).
362
47
  *
363
48
  * The host loads this module, invokes the function with {@link ScriptContext}, and persists
364
- * {@link ScriptResult} / {@link ScriptDialogContext.env$} according to Voctiv platform rules.
49
+ * {@link ScriptResult} / {@link import('./types/script-context').ScriptDialogContext.env$}
50
+ * according to Voctiv platform rules.
365
51
  *
366
52
  * @param fn - Handler receiving **`{ channel, logger, context, platform }`**.
367
53
  * - Use **`channel`** for ASR/TTS (see {@link import('./types/asr-handle').AsrConfig.name},
@@ -371,12 +57,12 @@ export type ScriptFn = (ctx: ScriptContext) => void | ScriptResult | Promise<voi
371
57
  *
372
58
  * @example
373
59
  * ```ts
374
- * import { defineScript } from '@lib/scripting-sdk';
60
+ * import { defineScript } from '@voctiv/agent-sdk';
375
61
  *
376
62
  * export default defineScript(async ({ channel, logger, context, platform }) => {
377
63
  * const asr = await channel.createAsr({
378
64
  * name: 'my-yandex-key',
379
- * vendor: 'Y',
65
+ * vendor: 'yandex',
380
66
  * language: 'ru-RU',
381
67
  * });
382
68
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"define-script.d.ts","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;GASG;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;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,SAAS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;;;;GAqBG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,OAAO,EAAE,YAAY,CAAC;IACtB,0FAA0F;IAC1F,MAAM,EAAE,YAAY,CAAC;IACrB,wFAAwF;IACxF,OAAO,EAAE,mBAAmB,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,CACrB,GAAG,EAAE,aAAa,KACf,IAAI,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAEnD"}
@@ -5,7 +5,8 @@ exports.defineScript = defineScript;
5
5
  * Mark the default export as a typed script entry point (identity wrapper; no runtime transform).
6
6
  *
7
7
  * The host loads this module, invokes the function with {@link ScriptContext}, and persists
8
- * {@link ScriptResult} / {@link ScriptDialogContext.env$} according to Voctiv platform rules.
8
+ * {@link ScriptResult} / {@link import('./types/script-context').ScriptDialogContext.env$}
9
+ * according to Voctiv platform rules.
9
10
  *
10
11
  * @param fn - Handler receiving **`{ channel, logger, context, platform }`**.
11
12
  * - Use **`channel`** for ASR/TTS (see {@link import('./types/asr-handle').AsrConfig.name},
@@ -15,12 +16,12 @@ exports.defineScript = defineScript;
15
16
  *
16
17
  * @example
17
18
  * ```ts
18
- * import { defineScript } from '@lib/scripting-sdk';
19
+ * import { defineScript } from '@voctiv/agent-sdk';
19
20
  *
20
21
  * export default defineScript(async ({ channel, logger, context, platform }) => {
21
22
  * const asr = await channel.createAsr({
22
23
  * name: 'my-yandex-key',
23
- * vendor: 'Y',
24
+ * vendor: 'yandex',
24
25
  * language: 'ru-RU',
25
26
  * });
26
27
  * });
@@ -1 +1 @@
1
- {"version":3,"file":"define-script.js","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":";;AAuaA,oCAEC;AA3BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,YAAY,CAAC,EAAY;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
1
+ {"version":3,"file":"define-script.js","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":";;AA2EA,oCAEC;AA5BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,YAAY,CAAC,EAAY;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@
12
12
  * - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
13
13
  * - **`legacyTtsKeysByName`**: same for TTS
14
14
  *
15
- * Rows are scoped to **this dialogs agent and company** (no agent UUID in the script). Use:
15
+ * Rows are scoped to **this dialog's agent and company** (no agent UUID in the script). Use:
16
16
  * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
17
17
  * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
18
18
  *
@@ -22,9 +22,14 @@
22
22
  * records) require `context.legacyV3Compat === true`.
23
23
  */
24
24
  export { defineScript } from './define-script';
25
- export type { ScriptContext, ScriptDialogContext, ScriptRunTime, ScriptResult, PersistedScriptResult, ScriptError, ScriptFn, NluScriptApi, PlatformApi, DialogApi, ScheduleCallOptions, SendMessageOptions, InboundMessage, MessagingApi, } from './define-script';
25
+ export type { ScriptContext, ScriptFn } from './define-script';
26
+ export type { ScriptDialogContext, ScriptRunTime, ScriptResult, PersistedScriptResult, ScriptError, } from './types/script-context';
27
+ export type { NluScriptApi, PlatformApi, DialogApi, ScheduleCallOptions, SendMessageOptions, InboundMessage, MessagingApi, } from './types/platform';
26
28
  export type { ScriptLogger } from './types/logger';
27
- export type { MediaChannel, ChannelAudio, ChannelEvents, ChannelLlm, ChannelSip, SipState, SipProgressEvent, LlmOptions, LlmStreamChunk, ExtractOptions, PersistentLlmStreamHandle, } from './types/media-channel';
29
+ export type { MediaChannel, ChannelAudio, ChannelEvents, } from './types/media-channel';
30
+ export type { ChannelLlm, LlmOptions, LlmStreamChunk, ExtractOptions, PersistentLlmStreamHandle, } from './types/llm';
31
+ export type { ChannelSip, SipState, SipProgressEvent, } from './types/sip';
32
+ export type { MediaError } from './types/errors';
28
33
  export type { AsrHandle, AsrConfig, AsrVadConfig, AsrSmartTurnConfig } from './types/asr-handle';
29
34
  export type { MixerQueueControl, PlayOptions, TtsStrategy, TtsVendor } from './types/mixer';
30
35
  export type { LegacyPhraseRecord, LegacyGetRecordsParams, LegacySavePhraseOptions, } from './types/legacy-phrase';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,UAAU,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,cAAc,EACd,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACjG,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,uBAA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AS,EAAE,MAAM,eAAe,CAAC;AAC5F,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,GACxB,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
@@ -13,7 +13,7 @@
13
13
  * - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
14
14
  * - **`legacyTtsKeysByName`**: same for TTS
15
15
  *
16
- * Rows are scoped to **this dialogs agent and company** (no agent UUID in the script). Use:
16
+ * Rows are scoped to **this dialog's agent and company** (no agent UUID in the script). Use:
17
17
  * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
18
18
  * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
19
19
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAuCrB,uDAG+B;AAF7B,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,iDAA+C;AAAtC,6GAAA,YAAY,OAAA;AAmDrB,uDAG+B;AAF7B,2HAAA,0BAA0B,OAAA;AAC1B,qHAAA,oBAAoB,OAAA"}
@@ -1,4 +1,5 @@
1
- import { Observable } from 'rxjs';
1
+ import type { Observable } from 'rxjs';
2
+ import type { MediaError } from './errors';
2
3
  /**
3
4
  * Voice Activity Detection (VAD) tuning.
4
5
  *
@@ -35,7 +36,7 @@ export interface AsrVadConfig {
35
36
  export interface AsrSmartTurnConfig {
36
37
  /** When `true`, turn-taking heuristics are applied (defaults vary by host). */
37
38
  enabled?: boolean;
38
- /** Frames of speech that must be seen before a turn can start. */
39
+ /** Frames of speech that must be seen before a "turn" can start. */
39
40
  triggerFrames?: number;
40
41
  /** Frames to wait before retrying after a short pause inside an utterance. */
41
42
  retryFrames?: number;
@@ -51,9 +52,9 @@ export interface AsrSmartTurnConfig {
51
52
  *
52
53
  * ### Voctiv platform + logic-executor `key_storage`
53
54
  *
54
- * When Voctiv platform compatibility is on and the connector loaded credentials from PostgreSQL, the sessions
55
+ * When Voctiv platform compatibility is on and the connector loaded credentials from PostgreSQL, the session's
55
56
  * `authentication_data` includes **`legacyAsrKeysByName`**: a map from **`key_storage.name`**
56
- * (string) to flat connector parameters (`api_key`, `base_url`, …) for **this dialogs agent
57
+ * (string) to flat connector parameters (`api_key`, `base_url`, …) for **this dialog's agent
57
58
  * and company**. You do **not** pass agent UUID in the script — the dialog already belongs to an agent.
58
59
  *
59
60
  * - **`name`**: pick which row from that map to use (same value as in LE admin for the key).
@@ -66,18 +67,18 @@ export interface AsrSmartTurnConfig {
66
67
  *
67
68
  * ### Vendor
68
69
  *
69
- * **`vendor`** is resolved via ScriptEngine vendor aliases (`"yandex"`, `"Y"`, `"neuro_v3"`, …). If you set
70
- * **`name`** but omit **`vendor`**, the runtime may infer vendor from the key rows **`platform`**
70
+ * **`vendor`** is resolved via ScriptEngine vendor aliases (`"yandex"`, `"deepgram"`, `"neuro_v3"`, …). If you set
71
+ * **`name`** but omit **`vendor`**, the runtime may infer vendor from the key row's **`platform`**
71
72
  * in the catalog.
72
73
  */
73
74
  export interface AsrConfig {
74
75
  /**
75
- * ASR vendor / engine hint: single-letter code (`"Y"`, `"D"`, …) or legacy name
76
- * (`"yandex"`, `"neuro_v3"`, …). See host `media-vendor-aliases` mapping.
76
+ * ASR vendor / engine hint, e.g. `"yandex"`, `"deepgram"`, `"google"`,
77
+ * `"azure"`, `"voctiv"`, or `"neuro_v3"`.
77
78
  */
78
79
  vendor?: string;
79
80
  /**
80
- * logic-executor **`key_storage.name`** for this dialogs agent + company. Selects credentials
81
+ * logic-executor **`key_storage.name`** for this dialog's agent + company. Selects credentials
81
82
  * from **`authentication_data.legacyAsrKeysByName[name]`** when Voctiv platform PostgreSQL key auth is enabled.
82
83
  * Overrides channel **`defaultAsrName`**.
83
84
  */
@@ -89,7 +90,7 @@ export interface AsrConfig {
89
90
  * Merged last over channel defaults and catalog credentials so the script can override
90
91
  * per call. Primitives are stringified; objects and arrays are JSON-serialized.
91
92
  *
92
- * Do not rely on **`name`** here for third-party model name fields — the runtime consumes
93
+ * Do not rely on **`name`** here for third-party "model name" fields — the runtime consumes
93
94
  * it as the storage row selector and removes it before vendor config is built.
94
95
  */
95
96
  data?: Record<string, unknown>;
@@ -132,6 +133,18 @@ export interface AsrHandle {
132
133
  readonly interrupt$: Observable<void>;
133
134
  /** Normalized voice-activity probability 0–1 when the host exposes it; else may be inert. */
134
135
  readonly vadProbability$: Observable<number>;
136
+ /**
137
+ * Runtime errors from the ASR provider (gRPC disconnect, auth failures, quota exceeded, etc.).
138
+ *
139
+ * A degraded handle (returned when connector creation itself failed) has an inert `error$`
140
+ * that never emits — the creation failure is reported on {@link import('./media-channel').ChannelEvents.error$} instead.
141
+ *
142
+ * ```ts
143
+ * const asr = await channel.createAsr({ name: 'yandex-asr-test' });
144
+ * asr.error$.subscribe(err => console.log('ASR error:', err.message));
145
+ * ```
146
+ */
147
+ readonly error$: Observable<MediaError>;
135
148
  /** Pause forwarding new audio frames to the recognizer; skipped audio is not replayed. */
136
149
  pause(): void;
137
150
  /** Resume after {@link pause}. */
@@ -1 +1 @@
1
- {"version":3,"file":"asr-handle.d.ts","sourceRoot":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QAAE,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"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Structured error emitted on {@link import('./media-channel').ChannelEvents.error$} and {@link import('./asr-handle').AsrHandle.error$}.
3
+ *
4
+ * Scripts can subscribe to these observables to detect ASR/TTS/SIP failures at runtime
5
+ * without relying on server-side logs.
6
+ */
7
+ export interface MediaError {
8
+ /** Which subsystem produced the error. */
9
+ source: 'asr' | 'tts' | 'sip' | 'channel';
10
+ /** Human-readable description (same string that appears in server logs). */
11
+ message: string;
12
+ /** HTTP status code, gRPC status, or WebSocket close code when available. */
13
+ code?: number;
14
+ /** Vendor/engine identifier, e.g. `"yandex"`, `"elevenlabs"`, `"azure"`. */
15
+ vendor?: string;
16
+ /** Arbitrary provider-specific payload for advanced diagnostics. */
17
+ details?: unknown;
18
+ }
19
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,0CAA0C;IAC1C,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC;IAC1C,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ import type { Observable } from 'rxjs';
2
+ /** Options for **`channel.llm.ask`** / **`stream`** / **`makePersistentStream`**. */
3
+ export interface LlmOptions {
4
+ /** Override dialog UUID for Omni/LLM tracing (defaults to script dialog). */
5
+ dialogUuid?: string;
6
+ /** Chat role sent with the message, e.g. **`"assistant"`**, **`"user"`**. */
7
+ role?: string;
8
+ /** When `true`, message may be hidden from user-visible transcript (host-dependent). */
9
+ hidden?: boolean;
10
+ /**
11
+ * **LLM-only**: speaker / persona label in multi-party chat. **Not** related to
12
+ * {@link import('./mixer').PlayOptions.name} (TTS **`key_storage.name`**).
13
+ */
14
+ name?: string;
15
+ /** Route the request to a specific Omni agent profile (UUID). */
16
+ agentUuid?: string;
17
+ /** Multi-agent: current alias for routing. */
18
+ currentAgentAlias?: string;
19
+ /** Opaque payload forwarded to the Omni LLM backend. */
20
+ payload?: Record<string, any>;
21
+ /** Verbose logging on the LLM path. */
22
+ debug?: boolean;
23
+ /** Restrict which agent aliases may handle the request. */
24
+ agentAliasFilter?: string[];
25
+ }
26
+ /** Options for **`channel.llm.extract`**. All fields except `dialogUuid` are forwarded to Omni extract. */
27
+ export interface ExtractOptions {
28
+ /** Override dialog UUID for extraction context; defaults to the current script dialog. */
29
+ dialogUuid?: string;
30
+ /** Optional extraction prompt/instruction forwarded to Omni. */
31
+ prompt?: string;
32
+ /** Model name or id understood by the Omni backend. */
33
+ model?: string;
34
+ /** Nucleus sampling value forwarded to Omni. */
35
+ topP?: number;
36
+ /** Temperature forwarded to Omni. */
37
+ temperature?: number;
38
+ /** Custom model descriptor forwarded as-is. */
39
+ customModel?: Record<string, any>;
40
+ [key: string]: unknown;
41
+ }
42
+ /** One chunk from **`channel.llm.stream`**. */
43
+ export interface LlmStreamChunk {
44
+ id: string;
45
+ chunkId: number;
46
+ content: string;
47
+ finishReason: string | null;
48
+ event: any;
49
+ toolMessages?: any[];
50
+ raw: Record<string, any>;
51
+ }
52
+ /**
53
+ * Long-lived LLM Socket.IO stream — amortizes connection setup across many user turns.
54
+ */
55
+ export interface PersistentLlmStreamHandle {
56
+ readonly stream$: Observable<LlmStreamChunk>;
57
+ /** Send one user/assistant turn over the existing stream; options override defaults for this send only. */
58
+ send(message: string, options?: LlmOptions): void;
59
+ /** Close the underlying Socket.IO stream without destroying the handle object. */
60
+ disconnect(): void;
61
+ /** Re-open the underlying Socket.IO stream after {@link disconnect}. */
62
+ reconnect(): void;
63
+ }
64
+ /** LLM facade on the media channel. */
65
+ export interface ChannelLlm {
66
+ /** Single-shot completion for **`message`**; consumes the Omni SSE stream and returns concatenated text. */
67
+ ask(message: string, options?: LlmOptions): Promise<string>;
68
+ /** Token/chunk stream for **`message`** parsed from Omni SSE `data:` events. */
69
+ stream(message: string, options?: LlmOptions): Observable<LlmStreamChunk>;
70
+ /** Structured extraction / JSON-style fill from conversation context via Omni extract. */
71
+ extract(options?: ExtractOptions): Promise<Record<string, any>>;
72
+ /**
73
+ * Open a persistent Omni chat stream.
74
+ * @param options - Default **`agentUuid`**, **`dialogUuid`**, etc.; per-**`send`** overrides allowed.
75
+ */
76
+ makePersistentStream(options?: LlmOptions): PersistentLlmStreamHandle;
77
+ }
78
+ //# sourceMappingURL=llm.d.ts.map