@voctiv/agent-sdk 0.1.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/dist/define-script.d.ts +294 -0
- package/dist/define-script.d.ts.map +1 -0
- package/dist/define-script.js +20 -0
- package/dist/define-script.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/asr-handle.d.ts +80 -0
- package/dist/types/asr-handle.d.ts.map +1 -0
- package/dist/types/asr-handle.js +3 -0
- package/dist/types/asr-handle.js.map +1 -0
- package/dist/types/events.d.ts +33 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +3 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/logger.d.ts +38 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +3 -0
- package/dist/types/logger.js.map +1 -0
- package/dist/types/media-channel.d.ts +181 -0
- package/dist/types/media-channel.d.ts.map +1 -0
- package/dist/types/media-channel.js +3 -0
- package/dist/types/media-channel.js.map +1 -0
- package/dist/types/mixer.d.ts +42 -0
- package/dist/types/mixer.d.ts.map +1 -0
- package/dist/types/mixer.js +3 -0
- package/dist/types/mixer.js.map +1 -0
- package/dist/types/nlu.d.ts +23 -0
- package/dist/types/nlu.d.ts.map +1 -0
- package/dist/types/nlu.js +3 -0
- package/dist/types/nlu.js.map +1 -0
- package/dist/types/text-input.d.ts +9 -0
- package/dist/types/text-input.d.ts.map +1 -0
- package/dist/types/text-input.js +3 -0
- package/dist/types/text-input.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import type { Observable } from 'rxjs';
|
|
2
|
+
import { MediaChannel } from './types/media-channel';
|
|
3
|
+
import { ScriptLogger } from './types/logger';
|
|
4
|
+
import type { NluExtractOptions, NluInferResult } from './types/nlu';
|
|
5
|
+
/**
|
|
6
|
+
* NLU (Natural Language Understanding) API.
|
|
7
|
+
*
|
|
8
|
+
* Provides intent/entity extraction from user utterances.
|
|
9
|
+
* Compatible with logic-executor `nn.extract()`.
|
|
10
|
+
*/
|
|
11
|
+
export interface NluScriptApi {
|
|
12
|
+
/**
|
|
13
|
+
* Extract intents and entities from text.
|
|
14
|
+
* @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.
|
|
17
|
+
*/
|
|
18
|
+
extract(utterance: string, options?: NluExtractOptions): Promise<NluInferResult>;
|
|
19
|
+
/**
|
|
20
|
+
* Same as {@link extract} but returns an RxJS Observable
|
|
21
|
+
* (useful for streaming pipelines).
|
|
22
|
+
*/
|
|
23
|
+
extract$(utterance: string, options?: NluExtractOptions): Observable<NluInferResult>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
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.
|
|
29
|
+
*
|
|
30
|
+
* Index signature allows arbitrary extra fields for forward compat.
|
|
31
|
+
*/
|
|
32
|
+
export interface ScriptDialogContext {
|
|
33
|
+
/** Short language code, e.g. `"ru"`, `"en"`. */
|
|
34
|
+
lang: string;
|
|
35
|
+
/** Full BCP-47 language tag, e.g. `"ru-RU"`, `"en-US"`. */
|
|
36
|
+
language: string;
|
|
37
|
+
/** Business flag for routing (e.g. `"default"`, `"vip"`). */
|
|
38
|
+
flag: string;
|
|
39
|
+
/** Unique dialog identifier (UUID). */
|
|
40
|
+
dialogUuid: string;
|
|
41
|
+
/** Caller phone number or messaging source ID. */
|
|
42
|
+
msisdn: string;
|
|
43
|
+
/** Inbound caller ID (same as msisdn for inbound calls). */
|
|
44
|
+
callerId: string;
|
|
45
|
+
/** Called number (DID / destination for inbound calls). */
|
|
46
|
+
destinationNumber: string;
|
|
47
|
+
/** Script record ID in the system. */
|
|
48
|
+
scriptId: string;
|
|
49
|
+
/** Human-readable script name. */
|
|
50
|
+
scriptName: string;
|
|
51
|
+
/** Agent UUID from Omni platform (links script to an NLU agent). */
|
|
52
|
+
agentUuid?: string;
|
|
53
|
+
/** Numeric NLU agent ID used for extract() calls. */
|
|
54
|
+
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. */
|
|
60
|
+
legacyV3Compat: boolean;
|
|
61
|
+
/** `true` when the script runs without a real media channel (offline / queue / messaging). */
|
|
62
|
+
headless: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Persisted script environment — survives between calls within the same dialog.
|
|
65
|
+
*
|
|
66
|
+
* **Reading:** On each call the system loads `env` from Redis (`dialog:{uuid}`, TTL 7 days)
|
|
67
|
+
* and injects it here. On the very first call `env` is `undefined`.
|
|
68
|
+
*
|
|
69
|
+
* **Writing (success path):** Return `{ env: { ... } }` from the script to persist
|
|
70
|
+
* a new snapshot:
|
|
71
|
+
* ```ts
|
|
72
|
+
* return { env: { step: 2, collected: true } };
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
75
|
+
* **Writing (mutation):** You can also mutate `context.env` directly during execution.
|
|
76
|
+
* If the script crashes or doesn't return an explicit `env`, the system reads the
|
|
77
|
+
* current value of `context.env` and persists it anyway — so partial progress is never lost.
|
|
78
|
+
*
|
|
79
|
+
* **Priority:** Explicit `return { env }` wins over mutations to `context.env`.
|
|
80
|
+
*
|
|
81
|
+
* **On error:** `env` is still saved (both mutation and return value are respected),
|
|
82
|
+
* and the {@link ScriptResult.error} field is populated alongside it.
|
|
83
|
+
*
|
|
84
|
+
* **Storage:** Redis key `dialog:{dialogUuid}`, JSON-serialized, TTL 7 days.
|
|
85
|
+
* Only active in legacy V3 compatibility mode.
|
|
86
|
+
*/
|
|
87
|
+
env?: Record<string, unknown>;
|
|
88
|
+
/** Raw `dialog` table row from legacy DB. */
|
|
89
|
+
dialogEntity?: Record<string, unknown>;
|
|
90
|
+
/** Raw `call` table row from legacy DB. */
|
|
91
|
+
callEntity?: Record<string, unknown>;
|
|
92
|
+
/** Available TTS/ASR media key identifiers (legacy compat). */
|
|
93
|
+
availableMediaKeys?: string[];
|
|
94
|
+
/** Script entry point for routing (e.g. `"on_recall"`, `"on_message_api_received"`). */
|
|
95
|
+
entryPoint?: string;
|
|
96
|
+
/** Current recall attempt number (starts at 0). */
|
|
97
|
+
attempt?: number;
|
|
98
|
+
/** Max recall attempts configured for this dialog. */
|
|
99
|
+
recallCount?: number;
|
|
100
|
+
/** Delay in seconds between recall attempts. */
|
|
101
|
+
recallDelay?: number;
|
|
102
|
+
/** Inbound message that triggered this headless session (messaging). */
|
|
103
|
+
inboundMessage?: InboundMessage;
|
|
104
|
+
/** @internal NLU runtime config — opaque to scripts. */
|
|
105
|
+
_nlu?: unknown;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
}
|
|
108
|
+
/** Error info attached to {@link ScriptResult} when a script fails. */
|
|
109
|
+
export interface ScriptError {
|
|
110
|
+
/** Error category: `"script_error"` | `"server_error"` (mirrors old LE stat names). */
|
|
111
|
+
code: string;
|
|
112
|
+
/** Human-readable error description. */
|
|
113
|
+
message: string;
|
|
114
|
+
/** Stack trace (when available). */
|
|
115
|
+
stack?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Value returned by a script function.
|
|
119
|
+
*
|
|
120
|
+
* - `env` — persisted in Redis between calls within the same dialog (legacy compat).
|
|
121
|
+
* - `output` — written to `dialog_stats` (equivalent of old LE `nn.dump`).
|
|
122
|
+
* - `error` — set automatically when the script throws; can also be set manually.
|
|
123
|
+
*/
|
|
124
|
+
export interface ScriptResult {
|
|
125
|
+
/** Script environment to persist for the next call in this dialog. */
|
|
126
|
+
env?: Record<string, unknown>;
|
|
127
|
+
/** Output data to store in dialog_stats. */
|
|
128
|
+
output?: Record<string, unknown>;
|
|
129
|
+
/** Error details (auto-populated on script crash, or set manually). */
|
|
130
|
+
error?: ScriptError;
|
|
131
|
+
}
|
|
132
|
+
/** Options for scheduling an outbound call via {@link PlatformApi.call}. */
|
|
133
|
+
export interface ScheduleCallOptions {
|
|
134
|
+
/** When to place the call. Defaults to now. */
|
|
135
|
+
date?: string | Date;
|
|
136
|
+
/** Deadline — don't call after this time. */
|
|
137
|
+
dateEnd?: string | Date;
|
|
138
|
+
/** Entry point to pass to the script when the call connects. */
|
|
139
|
+
entryPoint?: string;
|
|
140
|
+
/** Override script name/path for the outbound call. */
|
|
141
|
+
script?: string;
|
|
142
|
+
/** SIP channel/trunk name override. */
|
|
143
|
+
channel?: string;
|
|
144
|
+
/** How many times to retry on failure. */
|
|
145
|
+
recallCount?: number;
|
|
146
|
+
/** Delay in seconds between retries. */
|
|
147
|
+
recallDelay?: number;
|
|
148
|
+
/** Entry point to use after a successful call. */
|
|
149
|
+
onSuccessCall?: string;
|
|
150
|
+
/** Entry point to use after a failed call. */
|
|
151
|
+
onFailedCall?: string;
|
|
152
|
+
/** Call priority (higher = processed sooner by dialer). */
|
|
153
|
+
priority?: number;
|
|
154
|
+
/** Timezone offset (hours) for date interpretation. */
|
|
155
|
+
timezone?: number;
|
|
156
|
+
/** Extra SIP headers or protocol-level params. */
|
|
157
|
+
protoAdditional?: Record<string, string>;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Dialog state API — read and update dialog routing metadata.
|
|
161
|
+
*
|
|
162
|
+
* Setting `entryPoint` or `result` immediately persists the change
|
|
163
|
+
* to the legacy DB (non-blocking, fire-and-forget).
|
|
164
|
+
*/
|
|
165
|
+
export interface DialogApi {
|
|
166
|
+
/** Current script entry point (e.g. `"on_recall"`). Set to change routing for next call. */
|
|
167
|
+
entryPoint: string | undefined;
|
|
168
|
+
/** Dialog outcome (e.g. `"done"`, `"busy"`, `"no_answer"`). Set to finalize dialog. */
|
|
169
|
+
result: string | undefined;
|
|
170
|
+
/** Dialog UUID (read-only). */
|
|
171
|
+
readonly uuid: string;
|
|
172
|
+
/** Caller msisdn (read-only). */
|
|
173
|
+
readonly msisdn: string;
|
|
174
|
+
}
|
|
175
|
+
/** Options for sending an outbound message via {@link MessagingApi.send}. */
|
|
176
|
+
export interface SendMessageOptions {
|
|
177
|
+
/** Sender identifier (your service ID or phone number). */
|
|
178
|
+
src: string;
|
|
179
|
+
/** Recipient identifier (phone number, user ID, etc.). */
|
|
180
|
+
destination: string;
|
|
181
|
+
/** Text body of the message. */
|
|
182
|
+
text?: string;
|
|
183
|
+
/** URL of an attachment (image, document, etc.). */
|
|
184
|
+
attachment?: string;
|
|
185
|
+
/** Quick-reply button labels. */
|
|
186
|
+
buttons?: string[];
|
|
187
|
+
}
|
|
188
|
+
/** Inbound message received from an external messaging channel. */
|
|
189
|
+
export interface InboundMessage {
|
|
190
|
+
/** Sender identifier (who sent the message). */
|
|
191
|
+
src: string;
|
|
192
|
+
/** Recipient identifier (your service endpoint). */
|
|
193
|
+
dst: string;
|
|
194
|
+
/** Channel type, e.g. `"api"`. */
|
|
195
|
+
channelType: string;
|
|
196
|
+
/** Full raw payload from the messaging transport. */
|
|
197
|
+
payload: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Messaging API — send and receive messages through external channels.
|
|
201
|
+
*
|
|
202
|
+
* Messages are transported via Redis Streams (`ma_send` / `ma_receive`),
|
|
203
|
+
* compatible with the old LE messaging architecture.
|
|
204
|
+
*/
|
|
205
|
+
export interface MessagingApi {
|
|
206
|
+
/**
|
|
207
|
+
* Send an outbound message.
|
|
208
|
+
* Published to Redis stream for delivery by external consumer.
|
|
209
|
+
*/
|
|
210
|
+
send(options: SendMessageOptions): Promise<void>;
|
|
211
|
+
/**
|
|
212
|
+
* Observable of inbound messages.
|
|
213
|
+
* Emits the triggering message when the script is started by an incoming message
|
|
214
|
+
* (entry point `on_message_api_received`).
|
|
215
|
+
*/
|
|
216
|
+
readonly message$: Observable<InboundMessage>;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Platform API — legacy-compatible operations available to scripts.
|
|
220
|
+
*
|
|
221
|
+
* Provides access to NLU, dialog state management, outbound call scheduling,
|
|
222
|
+
* and messaging. Only functional in legacy V3 compatibility mode
|
|
223
|
+
* (except `nlu` which is always available).
|
|
224
|
+
*/
|
|
225
|
+
export interface PlatformApi {
|
|
226
|
+
/** NLU intent/entity extraction API. */
|
|
227
|
+
readonly nlu: NluScriptApi;
|
|
228
|
+
/** Dialog state — read/write entry point and result. */
|
|
229
|
+
readonly dialog: DialogApi;
|
|
230
|
+
/** Messaging API — send and receive external messages. */
|
|
231
|
+
readonly messaging: MessagingApi;
|
|
232
|
+
/**
|
|
233
|
+
* Schedule an outbound call.
|
|
234
|
+
* Creates a record in the `call` table; the dialer picks it up and originates the SIP call.
|
|
235
|
+
* @param msisdn - Destination phone number (E.164).
|
|
236
|
+
* @param options - Scheduling, routing, and retry options.
|
|
237
|
+
*/
|
|
238
|
+
call(msisdn: string, options?: ScheduleCallOptions): Promise<void>;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Top-level context passed to every script function.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```ts
|
|
245
|
+
* export default defineScript(async ({ channel, logger, context, platform }) => {
|
|
246
|
+
* logger.log('Script started', { dialog: context.dialogUuid });
|
|
247
|
+
*
|
|
248
|
+
* // Voice interaction
|
|
249
|
+
* await channel.audio.say('Hello!');
|
|
250
|
+
*
|
|
251
|
+
* // NLU
|
|
252
|
+
* const result = await platform.nlu.extract('I want to buy');
|
|
253
|
+
*
|
|
254
|
+
* // Messaging
|
|
255
|
+
* await platform.messaging.send({ src: 'bot', destination: '+7900...', text: 'Hi' });
|
|
256
|
+
*
|
|
257
|
+
* // Schedule a callback
|
|
258
|
+
* await platform.call('+7900...', { date: new Date(Date.now() + 3600000) });
|
|
259
|
+
* });
|
|
260
|
+
* ```
|
|
261
|
+
*/
|
|
262
|
+
export interface ScriptContext {
|
|
263
|
+
/**
|
|
264
|
+
* Media channel for voice/audio interaction (TTS, ASR, SIP, LLM).
|
|
265
|
+
* In headless mode most audio methods are no-ops.
|
|
266
|
+
*/
|
|
267
|
+
channel: MediaChannel;
|
|
268
|
+
/** Structured logger — writes to system log and optionally to `dialog_stats` DB table. */
|
|
269
|
+
logger: ScriptLogger;
|
|
270
|
+
/** Dialog context with session metadata, routing params, and legacy fields. */
|
|
271
|
+
context: ScriptDialogContext;
|
|
272
|
+
/** Platform API — NLU, dialog state, messaging, outbound calls. */
|
|
273
|
+
platform: PlatformApi;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Script function signature.
|
|
277
|
+
* Return {@link ScriptResult} to persist env/output, or void.
|
|
278
|
+
*/
|
|
279
|
+
export type ScriptFn = (ctx: ScriptContext) => void | ScriptResult | Promise<void | ScriptResult>;
|
|
280
|
+
/**
|
|
281
|
+
* Define a script entry point.
|
|
282
|
+
* Wrap your script function with this to enable type checking and runtime registration.
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* ```ts
|
|
286
|
+
* import { defineScript } from '@lib/scripting-sdk';
|
|
287
|
+
*
|
|
288
|
+
* export default defineScript(async ({ channel, logger, context, platform }) => {
|
|
289
|
+
* // your script logic here
|
|
290
|
+
* });
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
export declare function defineScript(fn: ScriptFn): ScriptFn;
|
|
294
|
+
//# sourceMappingURL=define-script.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-script.d.ts","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAg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object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineScript = defineScript;
|
|
4
|
+
/**
|
|
5
|
+
* Define a script entry point.
|
|
6
|
+
* Wrap your script function with this to enable type checking and runtime registration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineScript } from '@lib/scripting-sdk';
|
|
11
|
+
*
|
|
12
|
+
* export default defineScript(async ({ channel, logger, context, platform }) => {
|
|
13
|
+
* // your script logic here
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function defineScript(fn) {
|
|
18
|
+
return fn;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=define-script.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-script.js","sourceRoot":"","sources":["../src/define-script.ts"],"names":[],"mappings":";;AAqUA,oCAEC;AAfD;;;;;;;;;;;;GAYG;AACH,SAAgB,YAAY,CAAC,EAAY;IACvC,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { defineScript } from './define-script';
|
|
2
|
+
export type { ScriptContext, ScriptDialogContext, ScriptResult, ScriptError, ScriptFn, NluScriptApi, PlatformApi, DialogApi, ScheduleCallOptions, SendMessageOptions, InboundMessage, MessagingApi, } from './define-script';
|
|
3
|
+
export type { ScriptLogger } from './types/logger';
|
|
4
|
+
export type { MediaChannel, ChannelAudio, ChannelEvents, ChannelLlm, ChannelSip, LlmOptions, LlmStreamChunk, ExtractOptions, } from './types/media-channel';
|
|
5
|
+
export type { AsrHandle, AsrConfig, AsrVadConfig, AsrSmartTurnConfig } from './types/asr-handle';
|
|
6
|
+
export type { MixerQueueControl, PlayOptions, TtsStrategy, TtsVendor } from './types/mixer';
|
|
7
|
+
export type { TextInput } from './types/text-input';
|
|
8
|
+
export type { DtmfEvent, SipInfo, SipSignal, DataMessage, } from './types/events';
|
|
9
|
+
export type { NluExtractOptions, NluInferResult } from './types/nlu';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,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,GACf,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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.defineScript = void 0;
|
|
4
|
+
var define_script_1 = require("./define-script");
|
|
5
|
+
Object.defineProperty(exports, "defineScript", { enumerable: true, get: function () { return define_script_1.defineScript; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/** Voice Activity Detection (VAD) tuning parameters. */
|
|
3
|
+
export interface AsrVadConfig {
|
|
4
|
+
/** Energy threshold to start speech detection (0.0–1.0). */
|
|
5
|
+
positiveThreshold?: number;
|
|
6
|
+
/** Energy threshold to end speech detection (0.0–1.0). */
|
|
7
|
+
negativeThreshold?: number;
|
|
8
|
+
/** Minimum consecutive speech frames to confirm speech start. */
|
|
9
|
+
minSpeechFrames?: number;
|
|
10
|
+
/** Noise floor energy level. */
|
|
11
|
+
energyFloor?: number;
|
|
12
|
+
/** Smoothing factor for noise floor estimation (0.0–1.0). */
|
|
13
|
+
noiseFloorAlpha?: number;
|
|
14
|
+
/** Frames of audio to include before detected speech start. */
|
|
15
|
+
preSpeechFrames?: number;
|
|
16
|
+
/** Silence frames after speech before confirming end-of-speech. */
|
|
17
|
+
postSpeechFrames?: number;
|
|
18
|
+
}
|
|
19
|
+
/** Smart turn-taking configuration — controls when to finalize ASR during conversation. */
|
|
20
|
+
export interface AsrSmartTurnConfig {
|
|
21
|
+
/** Enable smart turn-taking (default: false). */
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/** Frames of speech before starting a turn. */
|
|
24
|
+
triggerFrames?: number;
|
|
25
|
+
/** Frames to wait before retrying after a short pause. */
|
|
26
|
+
retryFrames?: number;
|
|
27
|
+
/** Max silence frames before force-finalizing the turn. */
|
|
28
|
+
maxSilenceFrames?: number;
|
|
29
|
+
/** Milliseconds to wait for confirmation after potential end-of-turn. */
|
|
30
|
+
confirmMs?: number;
|
|
31
|
+
/** Hard timeout: finalize after this many ms of silence regardless. */
|
|
32
|
+
silenceTimeoutMs?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Configuration for creating an ASR (speech recognition) handle. */
|
|
35
|
+
export interface AsrConfig {
|
|
36
|
+
/** ASR vendor / engine identifier. */
|
|
37
|
+
vendor?: string;
|
|
38
|
+
/** Recognition language (BCP-47, e.g. `"ru-RU"`). */
|
|
39
|
+
language?: string;
|
|
40
|
+
/** Vendor-specific configuration parameters. */
|
|
41
|
+
data?: Record<string, unknown>;
|
|
42
|
+
/** VAD tuning. */
|
|
43
|
+
vad?: AsrVadConfig;
|
|
44
|
+
/** Smart turn-taking tuning. */
|
|
45
|
+
smartTurn?: AsrSmartTurnConfig;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* ASR handle — a live speech recognition session.
|
|
49
|
+
*
|
|
50
|
+
* Created via `channel.createAsr(config)`. Emits partial and final
|
|
51
|
+
* recognition results as Observables. Must be destroyed when no longer needed.
|
|
52
|
+
*/
|
|
53
|
+
export interface AsrHandle {
|
|
54
|
+
/** Unique handle identifier. */
|
|
55
|
+
readonly id: string;
|
|
56
|
+
/** Emits final recognition results (complete utterances). */
|
|
57
|
+
readonly result$: Observable<string>;
|
|
58
|
+
/** Emits partial (intermediate) recognition results. `isFinal` = true on last partial. */
|
|
59
|
+
readonly partial$: Observable<{
|
|
60
|
+
text: string;
|
|
61
|
+
isFinal: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
/** Fires when speech is detected in the audio stream. */
|
|
64
|
+
readonly speechStart$: Observable<void>;
|
|
65
|
+
/** Fires when speech ends. */
|
|
66
|
+
readonly speechEnd$: Observable<void>;
|
|
67
|
+
/** Fires when ASR determines the user is interrupting (barge-in). */
|
|
68
|
+
readonly interrupt$: Observable<void>;
|
|
69
|
+
/** VAD probability stream (0.0–1.0) — useful for visualization. */
|
|
70
|
+
readonly vadProbability$: Observable<number>;
|
|
71
|
+
/** Temporarily pause recognition (audio is still buffered). */
|
|
72
|
+
pause(): void;
|
|
73
|
+
/** Resume recognition after pause. */
|
|
74
|
+
resume(): void;
|
|
75
|
+
/** Force-finalize the current utterance (trigger result$ immediately). */
|
|
76
|
+
finalize(): void;
|
|
77
|
+
/** Destroy this ASR handle and release all resources. */
|
|
78
|
+
destroy(): void;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=asr-handle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asr-handle.d.ts","sourceRoot":"","sources":["../../src/types/asr-handle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,wDAAwD;AACxD,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,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,2FAA2F;AAC3F,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qEAAqE;AACrE,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,kBAAkB;IAClB,GAAG,CAAC,EAAE,YAAY,CAAC;IACnB,gCAAgC;IAChC,SAAS,CAAC,EAAE,kBAAkB,CAAC;CAChC;AAED;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IACrC,0FAA0F;IAC1F,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IAClE,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACxC,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IACtC,mEAAmE;IACnE,QAAQ,CAAC,eAAe,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC7C,+DAA+D;IAC/D,KAAK,IAAI,IAAI,CAAC;IACd,sCAAsC;IACtC,MAAM,IAAI,IAAI,CAAC;IACf,0EAA0E;IAC1E,QAAQ,IAAI,IAAI,CAAC;IACjB,yDAAyD;IACzD,OAAO,IAAI,IAAI,CAAC;CACjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asr-handle.js","sourceRoot":"","sources":["../../src/types/asr-handle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** DTMF digit event from the remote party. */
|
|
2
|
+
export interface DtmfEvent {
|
|
3
|
+
/** The pressed digit (`"0"`–`"9"`, `"*"`, `"#"`). */
|
|
4
|
+
digit: string;
|
|
5
|
+
/** Duration of the tone in milliseconds. */
|
|
6
|
+
duration: number;
|
|
7
|
+
}
|
|
8
|
+
/** Incoming SIP INFO message. */
|
|
9
|
+
export interface SipInfo {
|
|
10
|
+
/** MIME content type (e.g. `"application/dtmf-relay"`). */
|
|
11
|
+
contentType: string;
|
|
12
|
+
/** Message body. */
|
|
13
|
+
body: string;
|
|
14
|
+
}
|
|
15
|
+
/** SIP call state change signal. */
|
|
16
|
+
export interface SipSignal {
|
|
17
|
+
/** Call state (e.g. `"ringing"`, `"confirmed"`, `"terminated"`). */
|
|
18
|
+
state: string;
|
|
19
|
+
/** SIP response status code (e.g. `200`, `486`). */
|
|
20
|
+
statusCode?: number;
|
|
21
|
+
/** SIP response reason phrase. */
|
|
22
|
+
statusPhrase?: string;
|
|
23
|
+
/** SDP body (for media negotiation events). */
|
|
24
|
+
sdp?: string;
|
|
25
|
+
}
|
|
26
|
+
/** Arbitrary data message (used for WS data channel communication). */
|
|
27
|
+
export interface DataMessage {
|
|
28
|
+
/** Event name / type identifier. */
|
|
29
|
+
event: string;
|
|
30
|
+
/** Event payload (any JSON-serializable data). */
|
|
31
|
+
payload: unknown;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=events.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAC9C,MAAM,WAAW,SAAS;IACxB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,iCAAiC;AACjC,MAAM,WAAW,OAAO;IACtB,2DAA2D;IAC3D,WAAW,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,oCAAoC;AACpC,MAAM,WAAW,SAAS;IACxB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,uEAAuE;AACvE,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/types/events.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured logger available to scripts.
|
|
3
|
+
*
|
|
4
|
+
* In legacy compat mode, log entries are also batch-written
|
|
5
|
+
* to the `dialog_stats` DB table (equivalent of old LE `nn.log`).
|
|
6
|
+
*/
|
|
7
|
+
export interface ScriptLogger {
|
|
8
|
+
/** Info-level log entry. */
|
|
9
|
+
log(message: string, data?: Record<string, unknown>): void;
|
|
10
|
+
/** Warning-level log entry. */
|
|
11
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
12
|
+
/** Error-level log entry. */
|
|
13
|
+
error(message: string, data?: Record<string, unknown>): void;
|
|
14
|
+
/** Debug-level log entry (not written to DB, only to stdout). */
|
|
15
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Enable real-time log streaming to a remote debug endpoint.
|
|
18
|
+
* Opens a Socket.IO connection from this API pod to the debug server.
|
|
19
|
+
* Only logs from THIS script instance will be sent.
|
|
20
|
+
*
|
|
21
|
+
* @param endpoint - Debug URL from script-manager, e.g. "http://script-manager:3007#TOKEN"
|
|
22
|
+
*/
|
|
23
|
+
enableDebug(endpoint: string): void;
|
|
24
|
+
/** Stop streaming logs and disconnect from the debug endpoint. */
|
|
25
|
+
disableDebug(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Virtual breakpoint — pauses script execution and sends a snapshot
|
|
28
|
+
* of the provided variables to the debug UI. Execution resumes when
|
|
29
|
+
* the developer clicks "Continue" in the UI.
|
|
30
|
+
*
|
|
31
|
+
* If no debug session is active, resolves immediately (no-op).
|
|
32
|
+
*
|
|
33
|
+
* @param label - Human-readable label, e.g. "after ASR result"
|
|
34
|
+
* @param snapshot - Object with variables to inspect, e.g. { text, intent, score }
|
|
35
|
+
*/
|
|
36
|
+
breakpoint(label: string, snapshot?: Record<string, unknown>): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC3D,+BAA+B;IAC/B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5D,6BAA6B;IAC7B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC7D,iEAAiE;IACjE,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAE7D;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpC,kEAAkE;IAClE,YAAY,IAAI,IAAI,CAAC;IAErB;;;;;;;;;OASG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/types/logger.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
import { AsrConfig, AsrHandle } from './asr-handle';
|
|
3
|
+
import { DtmfEvent, SipInfo, SipSignal, DataMessage } from './events';
|
|
4
|
+
import { MixerQueueControl, PlayOptions } from './mixer';
|
|
5
|
+
import { TextInput } from './text-input';
|
|
6
|
+
/**
|
|
7
|
+
* Audio playback API — TTS synthesis, file playback, and queue management.
|
|
8
|
+
*
|
|
9
|
+
* Audio is routed through a multi-queue mixer. Each queue can play items
|
|
10
|
+
* independently with its own volume. Default queue index is 0.
|
|
11
|
+
*/
|
|
12
|
+
export interface ChannelAudio {
|
|
13
|
+
/**
|
|
14
|
+
* Synthesize text via TTS and play it.
|
|
15
|
+
* Accepts a plain string or an RxJS Observable of string chunks (for streaming TTS).
|
|
16
|
+
* Resolves when playback finishes.
|
|
17
|
+
*/
|
|
18
|
+
say(input: string | Observable<string>, options?: PlayOptions): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Play a pre-recorded audio file from URL or local path.
|
|
21
|
+
* Resolves when playback finishes.
|
|
22
|
+
*/
|
|
23
|
+
play(source: string, options?: PlayOptions): Promise<void>;
|
|
24
|
+
/** Download, decode and cache audio (URL or file path) as PCM for instant playback. */
|
|
25
|
+
preload(source: string): Promise<void>;
|
|
26
|
+
/** Pre-synthesize text via TTS and store in file cache for instant `say()` playback. */
|
|
27
|
+
presay(text: string, options?: PlayOptions): Promise<void>;
|
|
28
|
+
/** Access a specific mixer queue by index (0–4). */
|
|
29
|
+
queue(index: number): MixerQueueControl;
|
|
30
|
+
/** Remove a specific item by alias from a queue. */
|
|
31
|
+
remove(alias: string, queue?: number): void;
|
|
32
|
+
/** Stop and clear all items in a specific queue. */
|
|
33
|
+
stop(queue: number): void;
|
|
34
|
+
/** Stop and clear all queues. */
|
|
35
|
+
stopAll(): void;
|
|
36
|
+
}
|
|
37
|
+
/** Observables for channel-level events (speech detection, termination, data messages). */
|
|
38
|
+
export interface ChannelEvents {
|
|
39
|
+
/** Fires when the caller starts speaking (VAD-based). */
|
|
40
|
+
readonly speechStart$: Observable<void>;
|
|
41
|
+
/** Fires when the caller stops speaking. */
|
|
42
|
+
readonly speechEnd$: Observable<void>;
|
|
43
|
+
/** Fires when caller speech interrupts bot playback. */
|
|
44
|
+
readonly interrupt$: Observable<void>;
|
|
45
|
+
/** Fires when the session ends (hangup, timeout, or explicit destroy). */
|
|
46
|
+
readonly terminated$: Observable<void>;
|
|
47
|
+
/** Fires on incoming data messages (e.g. from WS client). */
|
|
48
|
+
readonly message$: Observable<DataMessage>;
|
|
49
|
+
}
|
|
50
|
+
/** Options for LLM `ask()` and `stream()` calls. */
|
|
51
|
+
export interface LlmOptions {
|
|
52
|
+
/** Override dialog UUID for LLM context tracking. */
|
|
53
|
+
dialogUuid?: string;
|
|
54
|
+
/** System role hint (e.g. `"assistant"`, `"user"`). */
|
|
55
|
+
role?: string;
|
|
56
|
+
/** If `true`, the message is added to history but not displayed. */
|
|
57
|
+
hidden?: boolean;
|
|
58
|
+
/** Speaker name for multi-turn dialogs. */
|
|
59
|
+
name?: string;
|
|
60
|
+
/** Override agent UUID for routing to a specific LLM agent. */
|
|
61
|
+
agentUuid?: string;
|
|
62
|
+
/** Current agent alias for multi-agent scenarios. */
|
|
63
|
+
currentAgentAlias?: string;
|
|
64
|
+
/** Arbitrary payload forwarded to the LLM backend. */
|
|
65
|
+
payload?: Record<string, any>;
|
|
66
|
+
/** Enable debug logging for this request. */
|
|
67
|
+
debug?: boolean;
|
|
68
|
+
/** Restrict response to specific agent aliases. */
|
|
69
|
+
agentAliasFilter?: string[];
|
|
70
|
+
}
|
|
71
|
+
/** Options for LLM structured extraction. */
|
|
72
|
+
export interface ExtractOptions {
|
|
73
|
+
/** Override dialog UUID. */
|
|
74
|
+
dialogUuid?: string;
|
|
75
|
+
/** Extraction prompt / instruction. */
|
|
76
|
+
prompt?: string;
|
|
77
|
+
/** LLM model name. */
|
|
78
|
+
model?: string;
|
|
79
|
+
/** Top-p (nucleus) sampling parameter. */
|
|
80
|
+
topP?: number;
|
|
81
|
+
/** Temperature sampling parameter. */
|
|
82
|
+
temperature?: number;
|
|
83
|
+
/** Custom model configuration. */
|
|
84
|
+
customModel?: Record<string, any>;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
/** A single chunk from an LLM streaming response. */
|
|
88
|
+
export interface LlmStreamChunk {
|
|
89
|
+
/** Request ID. */
|
|
90
|
+
id: string;
|
|
91
|
+
/** Sequential chunk number. */
|
|
92
|
+
chunkId: number;
|
|
93
|
+
/** Text content of this chunk. */
|
|
94
|
+
content: string;
|
|
95
|
+
/** Non-null when the stream is done (e.g. `"stop"`, `"length"`). */
|
|
96
|
+
finishReason: string | null;
|
|
97
|
+
/** Raw SSE event data. */
|
|
98
|
+
event: any;
|
|
99
|
+
/** Tool call messages (function calling). */
|
|
100
|
+
toolMessages?: any[];
|
|
101
|
+
/** Full raw response object. */
|
|
102
|
+
raw: Record<string, any>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* LLM (Large Language Model) API — text generation and structured extraction.
|
|
106
|
+
*/
|
|
107
|
+
export interface ChannelLlm {
|
|
108
|
+
/** Send a message and get a complete response. */
|
|
109
|
+
ask(message: string, options?: LlmOptions): Promise<string>;
|
|
110
|
+
/** Send a message and get a streaming response (Observable of chunks). */
|
|
111
|
+
stream(message: string, options?: LlmOptions): Observable<LlmStreamChunk>;
|
|
112
|
+
/** Structured data extraction using LLM (e.g. filling a form from conversation). */
|
|
113
|
+
extract(options?: ExtractOptions): Promise<Record<string, any>>;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* SIP telephony controls — DTMF, call control, bridging.
|
|
117
|
+
*/
|
|
118
|
+
export interface ChannelSip {
|
|
119
|
+
/** Observable of DTMF digit events. */
|
|
120
|
+
readonly dtmf$: Observable<DtmfEvent>;
|
|
121
|
+
/** Observable of SIP INFO messages. */
|
|
122
|
+
readonly sipInfo$: Observable<SipInfo>;
|
|
123
|
+
/** Observable of SIP call state changes (e.g. ringing, confirmed, terminated). */
|
|
124
|
+
readonly sipSignal$: Observable<SipSignal>;
|
|
125
|
+
/** Send a DTMF digit to the remote party. */
|
|
126
|
+
sendDtmf(digit: string, duration?: number): void;
|
|
127
|
+
/** Send a SIP INFO message. */
|
|
128
|
+
sendInfo(contentType: string, body: string): void;
|
|
129
|
+
/** Put the call on hold. */
|
|
130
|
+
hold(): void;
|
|
131
|
+
/** Resume a held call. */
|
|
132
|
+
unhold(): void;
|
|
133
|
+
/** Mute outgoing audio. */
|
|
134
|
+
mute(): void;
|
|
135
|
+
/** Unmute outgoing audio. */
|
|
136
|
+
unmute(): void;
|
|
137
|
+
/** Hang up the call. */
|
|
138
|
+
hangup(): void;
|
|
139
|
+
/** Answer an incoming call. */
|
|
140
|
+
answer(): void;
|
|
141
|
+
/** Originate a new outbound SIP call and return its media channel. */
|
|
142
|
+
makeCall(opts: {
|
|
143
|
+
sipUri: string;
|
|
144
|
+
fromUri?: string;
|
|
145
|
+
}): Promise<MediaChannel>;
|
|
146
|
+
/** Bridge two channels together (conference). Returns a teardown function. */
|
|
147
|
+
bridge(other: MediaChannel): () => void;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Media channel — the main interface for voice, audio, SIP, and LLM interaction.
|
|
151
|
+
*
|
|
152
|
+
* Every script receives a `channel` object. In headless mode,
|
|
153
|
+
* audio and SIP methods are no-ops or stubs.
|
|
154
|
+
*/
|
|
155
|
+
export interface MediaChannel {
|
|
156
|
+
/** Channel transport type: `"sip"` for phone calls, `"ws"` for WebSocket sessions. */
|
|
157
|
+
readonly type: 'sip' | 'ws';
|
|
158
|
+
/** Inbound caller ID (phone number or WS client ID). */
|
|
159
|
+
readonly callerId: string;
|
|
160
|
+
/** Called number / destination DID. */
|
|
161
|
+
readonly calledNumber: string;
|
|
162
|
+
/** Channel-level params (merged from route, agent defaults, etc.). */
|
|
163
|
+
readonly params: Record<string, unknown>;
|
|
164
|
+
/** Create a new ASR (speech recognition) handle with optional config. */
|
|
165
|
+
createAsr(config?: AsrConfig): Promise<AsrHandle>;
|
|
166
|
+
/** Virtual text input for testing — push text as if ASR recognized it. */
|
|
167
|
+
readonly textInput: TextInput;
|
|
168
|
+
/** Audio playback and TTS. */
|
|
169
|
+
readonly audio: ChannelAudio;
|
|
170
|
+
/** Channel events (speech, termination, data messages). */
|
|
171
|
+
readonly events: ChannelEvents;
|
|
172
|
+
/** LLM text generation and extraction. */
|
|
173
|
+
readonly llm: ChannelLlm;
|
|
174
|
+
/** SIP telephony controls. */
|
|
175
|
+
readonly sip: ChannelSip;
|
|
176
|
+
/** Send a data message to the remote party (WS). */
|
|
177
|
+
sendMessage(data: DataMessage): void;
|
|
178
|
+
/** Terminate the channel and release all resources. */
|
|
179
|
+
destroy(): void;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=media-channel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-channel.d.ts","sourceRoot":"","sources":["../../src/types/media-channel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;;;;GAKG;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|
|
|
1
|
+
import { Observable } from 'rxjs';
|
|
2
|
+
/** TTS synthesis strategy. */
|
|
3
|
+
export type TtsStrategy = 'sentence' | 'streaming' | 'chunk';
|
|
4
|
+
/** TTS vendor identifier. */
|
|
5
|
+
export type TtsVendor = 'A' | 'E' | 'ES' | 'V' | 'G';
|
|
6
|
+
/** Options for `say()` and `play()` calls. */
|
|
7
|
+
export interface PlayOptions {
|
|
8
|
+
/** Target mixer queue index (0–4). Default: 0. */
|
|
9
|
+
queue?: number;
|
|
10
|
+
/** Unique alias for this item — used to remove or track it. */
|
|
11
|
+
alias?: string;
|
|
12
|
+
/** Loop playback until explicitly stopped. */
|
|
13
|
+
loop?: boolean;
|
|
14
|
+
/** Delay in milliseconds between loop iterations. */
|
|
15
|
+
loopDelayMs?: number;
|
|
16
|
+
/** Queue volume 0.0 (silent) – 1.0 (full). Applied to the target queue for this call. */
|
|
17
|
+
volume?: number;
|
|
18
|
+
/** TTS synthesis strategy override. */
|
|
19
|
+
ttsStrategy?: TtsStrategy;
|
|
20
|
+
/** TTS vendor override. */
|
|
21
|
+
ttsVendor?: TtsVendor;
|
|
22
|
+
/** Vendor-specific TTS config (voice name, speed, pitch, etc.). */
|
|
23
|
+
ttsConfig?: Record<string, string>;
|
|
24
|
+
}
|
|
25
|
+
/** Control interface for a single mixer queue. */
|
|
26
|
+
export interface MixerQueueControl {
|
|
27
|
+
/** Queue index (0–4). */
|
|
28
|
+
readonly index: number;
|
|
29
|
+
/** Current volume (0.0–1.0). Set to change. */
|
|
30
|
+
volume: number;
|
|
31
|
+
/** Fires when an item starts playing (emits alias). */
|
|
32
|
+
readonly itemStarted$: Observable<string>;
|
|
33
|
+
/** Fires when an item finishes playing (emits alias). */
|
|
34
|
+
readonly itemFinished$: Observable<string>;
|
|
35
|
+
/** Fires when the queue becomes empty. */
|
|
36
|
+
readonly queueEmpty$: Observable<void>;
|
|
37
|
+
/** Remove a specific item from this queue by alias. */
|
|
38
|
+
remove(alias: string): void;
|
|
39
|
+
/** Clear all items from this queue. */
|
|
40
|
+
clear(): void;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=mixer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixer.d.ts","sourceRoot":"","sources":["../../src/types/mixer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,8BAA8B;AAC9B,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC;AAE7D,6BAA6B;AAC7B,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;AAErD,8CAA8C;AAC9C,MAAM,WAAW,WAAW;IAC1B,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,2BAA2B;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,mEAAmE;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,kDAAkD;AAClD,MAAM,WAAW,iBAAiB;IAChC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IAEf,uDAAuD;IACvD,QAAQ,CAAC,YAAY,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC1C,yDAAyD;IACzD,QAAQ,CAAC,aAAa,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;IAEvC,uDAAuD;IACvD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,uCAAuC;IACvC,KAAK,IAAI,IAAI,CAAC;CACf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mixer.js","sourceRoot":"","sources":["../../src/types/mixer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for NLU extraction.
|
|
3
|
+
* Compatible with logic-executor `NeuroNluRecognitionRequest`.
|
|
4
|
+
*/
|
|
5
|
+
export interface NluExtractOptions {
|
|
6
|
+
/** Include only these entity types (e.g. `"date"`, `"phone"`). */
|
|
7
|
+
entities?: string | string[] | null;
|
|
8
|
+
/** Exclude these entity types from extraction. */
|
|
9
|
+
entities_exclude?: string | string[] | null;
|
|
10
|
+
/** Include only these intent names. */
|
|
11
|
+
intents?: string | string[] | null;
|
|
12
|
+
/** Exclude these intent names. */
|
|
13
|
+
intents_exclude?: string | string[] | null;
|
|
14
|
+
/** Additional context for disambiguation (string, array, or object). */
|
|
15
|
+
context?: string | unknown[] | Record<string, unknown> | null;
|
|
16
|
+
/** Force NLU API backend (default: true). */
|
|
17
|
+
use_neuro_api?: boolean;
|
|
18
|
+
/** Enable synonym expansion before extraction. */
|
|
19
|
+
use_synonyms?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Raw JSON response from NLU v3 `/infer` endpoint. */
|
|
22
|
+
export type NluInferResult = Record<string, unknown>;
|
|
23
|
+
//# sourceMappingURL=nlu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nlu.d.ts","sourceRoot":"","sources":["../../src/types/nlu.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACpC,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAC5C,uCAAuC;IACvC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACnC,kCAAkC;IAClC,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAC3C,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC9D,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nlu.js","sourceRoot":"","sources":["../../src/types/nlu.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Virtual text input — pushes text directly into an AsrHandle's streams
|
|
3
|
+
* as if ASR recognized it. For automated testing via WS API without real audio.
|
|
4
|
+
*/
|
|
5
|
+
export interface TextInput {
|
|
6
|
+
pushResult(asrId: string, text: string): void;
|
|
7
|
+
pushPartial(asrId: string, text: string, isFinal?: boolean): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=text-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-input.d.ts","sourceRoot":"","sources":["../../src/types/text-input.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-input.js","sourceRoot":"","sources":["../../src/types/text-input.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@voctiv/agent-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Voctiv TypeScript agent SDK: defineScript and platform types for the voice/dialog scripting runtime.",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"author": "",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"voctiv",
|
|
9
|
+
"agent",
|
|
10
|
+
"sdk",
|
|
11
|
+
"voice",
|
|
12
|
+
"dialog",
|
|
13
|
+
"defineScript"
|
|
14
|
+
],
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"require": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc -p tsconfig.build.json",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"rxjs": "^7.8.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"rxjs": {
|
|
36
|
+
"optional": false
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"publishConfig": {
|
|
43
|
+
"access": "public"
|
|
44
|
+
}
|
|
45
|
+
}
|