@voctiv/agent-sdk 0.1.3 → 0.2.1

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,33 +1,46 @@
1
1
  import type { BehaviorSubject, Observable } from 'rxjs';
2
- import { MediaChannel } from './types/media-channel';
2
+ import type { MediaChannel } from './types/media-channel';
3
3
  import { ScriptLogger } from './types/logger';
4
4
  import type { NluExtractOptions, NluInferResult } from './types/nlu';
5
+ import type { LegacyGetRecordsParams, LegacyPhraseRecord } from './types/legacy-phrase';
5
6
  /**
6
7
  * NLU (Natural Language Understanding) API.
7
8
  *
8
- * Provides intent/entity extraction from user utterances.
9
- * Compatible with logic-executor `nn.extract()`.
9
+ * Provides intent/entity extraction through the legacy NLU v3 `/infer` endpoint.
10
+ * The current `apps/api` runtime only allows this API when `context.legacyV3Compat`
11
+ * is `true` and NLU runtime settings are configured (`NLU_V3_BASE_URL` plus a
12
+ * resolved numeric agent id). Calls fail fast with a descriptive error otherwise.
13
+ *
14
+ * Compatible with logic-executor `nn.extract()` request/response shape.
10
15
  */
11
16
  export interface NluScriptApi {
12
17
  /**
13
- * Extract intents and entities from text.
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
+ *
14
24
  * @param utterance - User input text to analyze.
15
- * @param options - Filter by specific intents/entities, add context, etc.
16
- * @returns Parsed NLU result with intents, entities, and confidence scores.
25
+ * @param options - Optional NLU filters and flags. `entities`, `intents`,
26
+ * `use_neuro_api`, and `use_synonyms` are forwarded by the current API runtime.
27
+ * @returns Raw parsed JSON response from the NLU `/infer` endpoint.
17
28
  */
18
29
  extract(utterance: string, options?: NluExtractOptions): Promise<NluInferResult>;
19
30
  /**
20
- * Same as {@link extract} but returns an RxJS Observable
21
- * (useful for streaming pipelines).
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.
22
35
  */
23
36
  extract$(utterance: string, options?: NluExtractOptions): Observable<NluInferResult>;
24
37
  }
25
38
  /**
26
- * Typed first-level dialog context passed to every script.
27
- * Contains all metadata about the current session: caller info,
28
- * script identity, routing params, and legacy compat fields.
39
+ * First-level **`context`** passed to every **`defineScript`** handler.
29
40
  *
30
- * Index signature allows arbitrary extra fields for forward compat.
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.
31
44
  */
32
45
  export interface ScriptDialogContext {
33
46
  /** Short language code, e.g. `"ru"`, `"en"`. */
@@ -50,34 +63,65 @@ export interface ScriptDialogContext {
50
63
  scriptName: string;
51
64
  /** Agent UUID from Omni platform (links script to an NLU agent). */
52
65
  agentUuid?: string;
53
- /** Numeric NLU agent ID used for extract() calls. */
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
+ */
54
74
  agentId: number;
55
- /** Original params snapshot at session start (immutable). */
56
- initialParams: Record<string, unknown>;
57
- /** Mutable merged params (channel + session + route). */
58
- params: Record<string, unknown>;
59
- /** Whether legacy V3 compatibility mode is active. */
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. */
60
96
  legacyV3Compat: boolean;
61
97
  /** `true` when the script runs without a real media channel (offline / queue / messaging). */
62
98
  headless: boolean;
63
99
  /**
64
- * Persisted dialog environment for this conversation. On each call the platform loads the
65
- * previous snapshot and seeds {@link env$}. On the first call the value is `undefined`.
100
+ * Persisted dialog environment for this conversation. The API runtime converts the
101
+ * plain persisted `env` snapshot into this `BehaviorSubject` before invoking the script.
102
+ * On the first call the value is `undefined`.
66
103
  *
67
104
  * **Read/write only via `env$`:** use `env$.getValue()`, `env$.next(partialOrNext)`, or
68
105
  * `env$.subscribe(...)`. Do not use a plain `context.env` — it is not provided.
69
106
  *
70
107
  * **Persistence:** On script completion (success or error), the runtime snapshots `env$` and
71
- * persists it; the script return value must not carry env (see {@link ScriptResult}).
108
+ * attaches it to the persisted result; the script return value must not carry env
109
+ * (see {@link ScriptResult}).
72
110
  *
73
- * Only active in legacy V3 compatibility mode.
111
+ * Session runners decide where that snapshot is stored. In Voctiv platform compatibility
112
+ * mode it is used as the LE-style dialog environment.
74
113
  */
75
114
  env$?: BehaviorSubject<Record<string, unknown> | undefined>;
76
- /** Raw `dialog` table row from legacy DB. */
115
+ /** Raw `dialog` table row from the Voctiv platform database. */
77
116
  dialogEntity?: Record<string, unknown>;
78
- /** Raw `call` table row from legacy DB. */
117
+ /** Raw `call` table row from the Voctiv platform database. */
79
118
  callEntity?: Record<string, unknown>;
80
- /** Available TTS/ASR media key identifiers (legacy compat). */
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
+ */
81
125
  availableMediaKeys?: string[];
82
126
  /** Script entry point for routing (e.g. `"on_recall"`, `"on_message_api_received"`). */
83
127
  entryPoint?: string;
@@ -89,13 +133,39 @@ export interface ScriptDialogContext {
89
133
  recallDelay?: number;
90
134
  /** Inbound message that triggered this headless session (messaging). */
91
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;
92
141
  /** @internal NLU runtime config — opaque to scripts. */
93
142
  _nlu?: unknown;
94
143
  [key: string]: unknown;
95
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
+ }
96
164
  /** Error info attached to {@link ScriptResult} when a script fails. */
97
165
  export interface ScriptError {
98
- /** Error category: `"script_error"` | `"server_error"` (mirrors old LE stat names). */
166
+ /**
167
+ * Machine-readable category, e.g. `script_error`, `script_load_failed`, `time_limit_exceeded`.
168
+ */
99
169
  code: string;
100
170
  /** Human-readable error description. */
101
171
  message: string;
@@ -113,7 +183,7 @@ export interface ScriptResult {
113
183
  error?: ScriptError;
114
184
  }
115
185
  /**
116
- * Result after the runtime attaches the final `env$` snapshot (legacy persistence).
186
+ * Result after the runtime attaches the final `env$` snapshot (Voctiv platform persistence).
117
187
  * Scripts never construct this type — use {@link ScriptResult} from `defineScript` handlers.
118
188
  */
119
189
  export interface PersistedScriptResult extends ScriptResult {
@@ -125,35 +195,46 @@ export interface ScheduleCallOptions {
125
195
  date?: string | Date;
126
196
  /** Deadline — don't call after this time. */
127
197
  dateEnd?: string | Date;
128
- /** Entry point to pass to the script when the call connects. */
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
+ */
129
203
  entryPoint?: string;
130
- /** Override script name/path for the outbound call. */
204
+ /**
205
+ * Legacy compatibility field for callers that schedule without a current `scriptId`.
206
+ *
207
+ * The current `apps/api` scheduler only uses this to allow validation when
208
+ * `scriptId` is missing; it does not resolve the script name/path itself.
209
+ */
131
210
  script?: string;
132
- /** SIP channel/trunk name override. */
211
+ /** Reserved SIP channel/trunk hint. The current `apps/api` scheduler does not persist it. */
133
212
  channel?: string;
134
- /** How many times to retry on failure. */
213
+ /** How many times to retry on failure. Stored as `recall_count` in call params. */
135
214
  recallCount?: number;
136
- /** Delay in seconds between retries. */
215
+ /** Delay in seconds between retries. Stored as `recall_delay` in call params. */
137
216
  recallDelay?: number;
138
- /** Entry point to use after a successful call. */
217
+ /** Entry point to use after a successful call. Stored as `on_success_call`. */
139
218
  onSuccessCall?: string;
140
- /** Entry point to use after a failed call. */
219
+ /** Entry point to use after a failed call. Stored as `on_failed_call`. */
141
220
  onFailedCall?: string;
142
221
  /** Call priority (higher = processed sooner by dialer). */
143
222
  priority?: number;
144
- /** Timezone offset (hours) for date interpretation. */
223
+ /** Timezone offset passed to the legacy call row as `timeZone`. */
145
224
  timezone?: number;
146
- /** Extra SIP headers or protocol-level params. */
225
+ /** Extra SIP headers or protocol-level params. Stored as `proto_additional` in call params. */
147
226
  protoAdditional?: Record<string, string>;
148
227
  }
149
228
  /**
150
229
  * Dialog state API — read and update dialog routing metadata.
151
230
  *
152
- * Setting `entryPoint` or `result` immediately persists the change
153
- * to the legacy DB (non-blocking, fire-and-forget).
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.
154
235
  */
155
236
  export interface DialogApi {
156
- /** Current script entry point (e.g. `"on_recall"`). Set to change routing for next call. */
237
+ /** Current script entry point (e.g. `"on_recall"`). Set to change routing for the next call. */
157
238
  entryPoint: string | undefined;
158
239
  /** Dialog outcome (e.g. `"done"`, `"busy"`, `"no_answer"`). Set to finalize dialog. */
159
240
  result: string | undefined;
@@ -164,11 +245,11 @@ export interface DialogApi {
164
245
  }
165
246
  /** Options for sending an outbound message via {@link MessagingApi.send}. */
166
247
  export interface SendMessageOptions {
167
- /** Sender identifier (your service ID or phone number). */
248
+ /** Sender identifier (service id, bot id, or phone number expected by the MA consumer). */
168
249
  src: string;
169
- /** Recipient identifier (phone number, user ID, etc.). */
250
+ /** Recipient identifier (phone number, user id, or channel-specific address). */
170
251
  destination: string;
171
- /** Text body of the message. */
252
+ /** Text body of the message. When present in legacy mode, it is also mirrored to dialog stats. */
172
253
  text?: string;
173
254
  /** URL of an attachment (image, document, etc.). */
174
255
  attachment?: string;
@@ -189,8 +270,10 @@ export interface InboundMessage {
189
270
  /**
190
271
  * Messaging API — send and receive messages through external channels.
191
272
  *
192
- * Messages are transported via Redis Streams (`ma_send` / `ma_receive`),
193
- * compatible with the old LE messaging architecture.
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.
194
277
  */
195
278
  export interface MessagingApi {
196
279
  /**
@@ -206,14 +289,15 @@ export interface MessagingApi {
206
289
  readonly message$: Observable<InboundMessage>;
207
290
  }
208
291
  /**
209
- * Platform API — legacy-compatible operations available to scripts.
292
+ * Platform API — Voctiv platform–compatible operations available to scripts.
210
293
  *
211
294
  * Provides access to NLU, dialog state management, outbound call scheduling,
212
- * and messaging. Only functional in legacy V3 compatibility mode
213
- * (except `nlu` which is always available).
295
+ * phrase records, and messaging. These operations are legacy-platform backed:
296
+ * the current `apps/api` runtime requires `context.legacyV3Compat === true` for
297
+ * NLU, `call`, `dialog` writes, messaging sends, and `getRecords`.
214
298
  */
215
299
  export interface PlatformApi {
216
- /** NLU intent/entity extraction API. */
300
+ /** NLU intent/entity extraction API; throws outside legacy V3 compatibility mode. */
217
301
  readonly nlu: NluScriptApi;
218
302
  /** Dialog state — read/write entry point and result. */
219
303
  readonly dialog: DialogApi;
@@ -226,6 +310,13 @@ export interface PlatformApi {
226
310
  * @param options - Scheduling, routing, and retry options.
227
311
  */
228
312
  call(msisdn: string, options?: ScheduleCallOptions): Promise<void>;
313
+ /**
314
+ * Voctiv platform only: load `record_phrase` / `record_phrase_file` rows from the LE PostgreSQL database
315
+ * (same filters as old `RecordPhrase.get_records`). Returns playable phrase record objects.
316
+ * Requires numeric `agent_id` on the dialog (params or `NLU_DEFAULT_AGENT_ID`) and
317
+ * `LEGACY_V3_RECORD_PHRASE_ROOT` pointing at the phrase file storage root.
318
+ */
319
+ getRecords?(params: LegacyGetRecordsParams): Promise<LegacyPhraseRecord[]>;
229
320
  }
230
321
  /**
231
322
  * Top-level context passed to every script function.
@@ -257,7 +348,7 @@ export interface ScriptContext {
257
348
  channel: MediaChannel;
258
349
  /** Structured logger — writes to system log and optionally to `dialog_stats` DB table. */
259
350
  logger: ScriptLogger;
260
- /** Dialog context with session metadata, routing params, and legacy fields. */
351
+ /** Dialog context with session metadata, routing params, and Voctiv platform fields. */
261
352
  context: ScriptDialogContext;
262
353
  /** Platform API — NLU, dialog state, messaging, outbound calls. */
263
354
  platform: PlatformApi;
@@ -268,15 +359,27 @@ export interface ScriptContext {
268
359
  */
269
360
  export type ScriptFn = (ctx: ScriptContext) => void | ScriptResult | Promise<void | ScriptResult>;
270
361
  /**
271
- * Define a script entry point.
272
- * Wrap your script function with this to enable type checking and runtime registration.
362
+ * Mark the default export as a typed script entry point (identity wrapper; no runtime transform).
363
+ *
364
+ * The host loads this module, invokes the function with {@link ScriptContext}, and persists
365
+ * {@link ScriptResult} / {@link ScriptDialogContext.env$} according to Voctiv platform rules.
366
+ *
367
+ * @param fn - Handler receiving **`{ channel, logger, context, platform }`**.
368
+ * - Use **`channel`** for ASR/TTS (see {@link import('./types/asr-handle').AsrConfig.name},
369
+ * {@link import('./types/mixer').PlayOptions.name} for LE **`key_storage.name`** selection).
370
+ * - Use **`context.dialogParams`** / **`context.dialogUuid`** for routing; **`platform`** for NLU, calls, messaging.
371
+ * @returns The same **`fn`** reference.
273
372
  *
274
373
  * @example
275
374
  * ```ts
276
375
  * import { defineScript } from '@lib/scripting-sdk';
277
376
  *
278
377
  * export default defineScript(async ({ channel, logger, context, platform }) => {
279
- * // your script logic here
378
+ * const asr = await channel.createAsr({
379
+ * name: 'my-yandex-key',
380
+ * vendor: 'Y',
381
+ * language: 'ru-RU',
382
+ * });
280
383
  * });
281
384
  * ```
282
385
  */
@@ -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,EAAE,YAAY,EAAE,MAAM,uBAAuB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AC,GAAG,EAAE,YAAY,CAAC;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,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;;;;;OAKG;IACH,UAAU,CAAC,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CAC5E;AAED;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAEnD"}
@@ -2,15 +2,27 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defineScript = defineScript;
4
4
  /**
5
- * Define a script entry point.
6
- * Wrap your script function with this to enable type checking and runtime registration.
5
+ * Mark the default export as a typed script entry point (identity wrapper; no runtime transform).
6
+ *
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.
9
+ *
10
+ * @param fn - Handler receiving **`{ channel, logger, context, platform }`**.
11
+ * - Use **`channel`** for ASR/TTS (see {@link import('./types/asr-handle').AsrConfig.name},
12
+ * {@link import('./types/mixer').PlayOptions.name} for LE **`key_storage.name`** selection).
13
+ * - Use **`context.dialogParams`** / **`context.dialogUuid`** for routing; **`platform`** for NLU, calls, messaging.
14
+ * @returns The same **`fn`** reference.
7
15
  *
8
16
  * @example
9
17
  * ```ts
10
18
  * import { defineScript } from '@lib/scripting-sdk';
11
19
  *
12
20
  * export default defineScript(async ({ channel, logger, context, platform }) => {
13
- * // your script logic here
21
+ * const asr = await channel.createAsr({
22
+ * name: 'my-yandex-key',
23
+ * vendor: 'Y',
24
+ * language: 'ru-RU',
25
+ * });
14
26
  * });
15
27
  * ```
16
28
  */
@@ -1 +1 @@
1
- {"version":3,"file":"define-script.js","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":";;AA4TA,oCAEC;AAfD;;;;;;;;;;;;GAYG;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":";;AAwaA,oCAEC;AA3BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,YAAY,CAAC,EAAY;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,34 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * **Agent scripting SDK** for `node-asr-tts-connector`: typed **`defineScript`** context,
4
+ * {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and Voctiv platform (LE-compat) helpers.
5
+ * These exports are types plus the `defineScript` identity helper; behavior is provided by
6
+ * the `apps/api` scripting runtime that loads and executes your script.
7
+ *
8
+ * ### Selecting ASR/TTS credentials by `key_storage.name` (Voctiv platform)
9
+ *
10
+ * When the host enables Voctiv platform PostgreSQL key auth, **`channel.params.authentication_data`**
11
+ * may contain:
12
+ * - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
13
+ * - **`legacyTtsKeysByName`**: same for TTS
14
+ *
15
+ * Rows are scoped to **this dialog’s agent and company** (no agent UUID in the script). Use:
16
+ * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
17
+ * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
18
+ *
19
+ * Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
20
+ *
21
+ * Legacy platform APIs (`platform.nlu`, `platform.call`, messaging sends, dialog writes, and phrase
22
+ * records) require `context.legacyV3Compat === true` in the current API runtime.
23
+ */
1
24
  export { defineScript } from './define-script';
2
- export type { ScriptContext, ScriptDialogContext, ScriptResult, PersistedScriptResult, ScriptError, ScriptFn, NluScriptApi, PlatformApi, DialogApi, ScheduleCallOptions, SendMessageOptions, InboundMessage, MessagingApi, } from './define-script';
25
+ export type { ScriptContext, ScriptDialogContext, ScriptRunTime, ScriptResult, PersistedScriptResult, ScriptError, ScriptFn, NluScriptApi, PlatformApi, DialogApi, ScheduleCallOptions, SendMessageOptions, InboundMessage, MessagingApi, } from './define-script';
3
26
  export type { ScriptLogger } from './types/logger';
4
- export type { MediaChannel, ChannelAudio, ChannelEvents, ChannelLlm, ChannelSip, LlmOptions, LlmStreamChunk, ExtractOptions, PersistentLlmStreamHandle, } from './types/media-channel';
27
+ export type { MediaChannel, ChannelAudio, ChannelEvents, ChannelLlm, ChannelSip, SipState, SipProgressEvent, LlmOptions, LlmStreamChunk, ExtractOptions, PersistentLlmStreamHandle, } from './types/media-channel';
5
28
  export type { AsrHandle, AsrConfig, AsrVadConfig, AsrSmartTurnConfig } from './types/asr-handle';
6
29
  export type { MixerQueueControl, PlayOptions, TtsStrategy, TtsVendor } from './types/mixer';
30
+ export type { LegacyPhraseRecord, LegacyGetRecordsParams, LegacySavePhraseOptions, } from './types/legacy-phrase';
31
+ export { LEGACY_PHRASE_RECORD_BRAND, isLegacyPhraseRecord, } from './types/legacy-phrase';
7
32
  export type { TextInput } from './types/text-input';
8
33
  export type { DtmfEvent, SipInfo, SipSignal, DataMessage, } from './types/events';
9
34
  export type { NluExtractOptions, NluInferResult } from './types/nlu';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,YAAY,EACV,aAAa,EACb,mBAAmB,EACnB,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,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,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"}
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,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
@@ -1,6 +1,32 @@
1
1
  "use strict";
2
+ /**
3
+ * @packageDocumentation
4
+ * **Agent scripting SDK** for `node-asr-tts-connector`: typed **`defineScript`** context,
5
+ * {@link import('./types/media-channel').MediaChannel}, ASR/TTS, LLM, SIP, and Voctiv platform (LE-compat) helpers.
6
+ * These exports are types plus the `defineScript` identity helper; behavior is provided by
7
+ * the `apps/api` scripting runtime that loads and executes your script.
8
+ *
9
+ * ### Selecting ASR/TTS credentials by `key_storage.name` (Voctiv platform)
10
+ *
11
+ * When the host enables Voctiv platform PostgreSQL key auth, **`channel.params.authentication_data`**
12
+ * may contain:
13
+ * - **`legacyAsrKeysByName`**: map **`name`** → `{ platform, flat }` for ASR
14
+ * - **`legacyTtsKeysByName`**: same for TTS
15
+ *
16
+ * Rows are scoped to **this dialog’s agent and company** (no agent UUID in the script). Use:
17
+ * - {@link import('./types/asr-handle').AsrConfig.name} or **`data.name`** on **`createAsr`**
18
+ * - {@link import('./types/mixer').PlayOptions.name} or **`ttsConfig.name`** on **`say`/`play`/`presay`**
19
+ *
20
+ * Channel defaults **`defaultAsrName`** / **`defaultTtsName`** apply when **`name`** is omitted.
21
+ *
22
+ * Legacy platform APIs (`platform.nlu`, `platform.call`, messaging sends, dialog writes, and phrase
23
+ * records) require `context.legacyV3Compat === true` in the current API runtime.
24
+ */
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defineScript = void 0;
26
+ exports.isLegacyPhraseRecord = exports.LEGACY_PHRASE_RECORD_BRAND = exports.defineScript = void 0;
4
27
  var define_script_1 = require("./define-script");
5
28
  Object.defineProperty(exports, "defineScript", { enumerable: true, get: function () { return define_script_1.defineScript; } });
29
+ var legacy_phrase_1 = require("./types/legacy-phrase");
30
+ Object.defineProperty(exports, "LEGACY_PHRASE_RECORD_BRAND", { enumerable: true, get: function () { return legacy_phrase_1.LEGACY_PHRASE_RECORD_BRAND; } });
31
+ Object.defineProperty(exports, "isLegacyPhraseRecord", { enumerable: true, get: function () { return legacy_phrase_1.isLegacyPhraseRecord; } });
6
32
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
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"}