@jambonz/sdk 0.1.32 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.cjs +9 -3
- package/dist/client/index.cjs.map +1 -1
- package/dist/client/index.d.cts +4 -4
- package/dist/client/index.d.ts +4 -4
- package/dist/client/index.js +9 -3
- package/dist/client/index.js.map +1 -1
- package/dist/index.cjs +55 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +57 -101
- package/dist/index.js.map +1 -1
- package/dist/{rest-B_GQITxM.d.cts → rest-BvOtq44O.d.cts} +3 -3
- package/dist/{rest-DgctQy2b.d.ts → rest-DAAEUWsa.d.ts} +3 -3
- package/dist/{session-DVGHbtan.d.cts → session-DKaSRkIo.d.cts} +19 -19
- package/dist/{session-DVGHbtan.d.ts → session-DKaSRkIo.d.ts} +19 -19
- package/dist/types/index.d.cts +3 -3
- package/dist/types/index.d.ts +3 -3
- package/dist/{verb-builder-tayDQ0fe.d.ts → verb-builder-CFPD9yWI.d.cts} +4 -4
- package/dist/{verb-builder-BCjmdgUX.d.cts → verb-builder-D5XRbTtu.d.ts} +4 -4
- package/dist/{verbs-B18Kazd9.d.cts → verbs-DKy6nGIH.d.cts} +6 -6
- package/dist/{verbs-B18Kazd9.d.ts → verbs-DKy6nGIH.d.ts} +6 -6
- package/dist/webhook/index.cjs +38 -88
- package/dist/webhook/index.cjs.map +1 -1
- package/dist/webhook/index.d.cts +2 -2
- package/dist/webhook/index.d.ts +2 -2
- package/dist/webhook/index.js +40 -90
- package/dist/webhook/index.js.map +1 -1
- package/dist/websocket/index.cjs +46 -96
- package/dist/websocket/index.cjs.map +1 -1
- package/dist/websocket/index.d.cts +7 -7
- package/dist/websocket/index.d.ts +7 -7
- package/dist/websocket/index.js +48 -98
- package/dist/websocket/index.js.map +1 -1
- package/package.json +4 -4
- package/schema/callbacks/amd.schema.json +0 -50
- package/schema/callbacks/base.schema.json +0 -29
- package/schema/callbacks/call-status.schema.json +0 -22
- package/schema/callbacks/conference-status.schema.json +0 -24
- package/schema/callbacks/conference-wait.schema.json +0 -11
- package/schema/callbacks/conference.schema.json +0 -11
- package/schema/callbacks/dequeue.schema.json +0 -19
- package/schema/callbacks/dial-dtmf.schema.json +0 -18
- package/schema/callbacks/dial-hold.schema.json +0 -22
- package/schema/callbacks/dial-refer.schema.json +0 -28
- package/schema/callbacks/dial.schema.json +0 -31
- package/schema/callbacks/enqueue-wait.schema.json +0 -17
- package/schema/callbacks/enqueue.schema.json +0 -27
- package/schema/callbacks/gather-partial.schema.json +0 -54
- package/schema/callbacks/gather.schema.json +0 -60
- package/schema/callbacks/listen.schema.json +0 -21
- package/schema/callbacks/llm.schema.json +0 -30
- package/schema/callbacks/message.schema.json +0 -35
- package/schema/callbacks/pipeline-turn.schema.json +0 -109
- package/schema/callbacks/play.schema.json +0 -36
- package/schema/callbacks/session-new.schema.json +0 -143
- package/schema/callbacks/session-reconnect.schema.json +0 -9
- package/schema/callbacks/session-redirect.schema.json +0 -38
- package/schema/callbacks/sip-refer-event.schema.json +0 -20
- package/schema/callbacks/sip-refer.schema.json +0 -22
- package/schema/callbacks/sip-request.schema.json +0 -27
- package/schema/callbacks/transcribe-translation.schema.json +0 -24
- package/schema/callbacks/transcribe.schema.json +0 -46
- package/schema/callbacks/tts-streaming-event.schema.json +0 -77
- package/schema/callbacks/verb-status.schema.json +0 -57
- package/schema/components/actionHook.schema.json +0 -36
- package/schema/components/actionHookDelayAction.schema.json +0 -37
- package/schema/components/amd.schema.json +0 -68
- package/schema/components/auth.schema.json +0 -18
- package/schema/components/bidirectionalAudio.schema.json +0 -22
- package/schema/components/fillerNoise.schema.json +0 -25
- package/schema/components/llm-base.schema.json +0 -94
- package/schema/components/recognizer-assemblyAiOptions.schema.json +0 -66
- package/schema/components/recognizer-awsOptions.schema.json +0 -52
- package/schema/components/recognizer-azureOptions.schema.json +0 -32
- package/schema/components/recognizer-cobaltOptions.schema.json +0 -34
- package/schema/components/recognizer-customOptions.schema.json +0 -27
- package/schema/components/recognizer-deepgramOptions.schema.json +0 -147
- package/schema/components/recognizer-elevenlabsOptions.schema.json +0 -39
- package/schema/components/recognizer-gladiaOptions.schema.json +0 -8
- package/schema/components/recognizer-googleOptions.schema.json +0 -35
- package/schema/components/recognizer-houndifyOptions.schema.json +0 -53
- package/schema/components/recognizer-ibmOptions.schema.json +0 -54
- package/schema/components/recognizer-nuanceOptions.schema.json +0 -150
- package/schema/components/recognizer-nvidiaOptions.schema.json +0 -39
- package/schema/components/recognizer-openaiOptions.schema.json +0 -59
- package/schema/components/recognizer-sonioxOptions.schema.json +0 -46
- package/schema/components/recognizer-speechmaticsOptions.schema.json +0 -100
- package/schema/components/recognizer-verbioOptions.schema.json +0 -46
- package/schema/components/recognizer.schema.json +0 -216
- package/schema/components/synthesizer.schema.json +0 -82
- package/schema/components/target.schema.json +0 -105
- package/schema/components/vad.schema.json +0 -48
- package/schema/jambonz-app.schema.json +0 -112
- package/schema/verbs/alert.schema.json +0 -34
- package/schema/verbs/answer.schema.json +0 -22
- package/schema/verbs/conference.schema.json +0 -107
- package/schema/verbs/config.schema.json +0 -218
- package/schema/verbs/deepgram_s2s.schema.json +0 -81
- package/schema/verbs/dequeue.schema.json +0 -51
- package/schema/verbs/dial.schema.json +0 -187
- package/schema/verbs/dialogflow.schema.json +0 -148
- package/schema/verbs/dtmf.schema.json +0 -49
- package/schema/verbs/dub.schema.json +0 -103
- package/schema/verbs/elevenlabs_s2s.schema.json +0 -81
- package/schema/verbs/enqueue.schema.json +0 -53
- package/schema/verbs/gather.schema.json +0 -188
- package/schema/verbs/google_s2s.schema.json +0 -42
- package/schema/verbs/hangup.schema.json +0 -36
- package/schema/verbs/leave.schema.json +0 -22
- package/schema/verbs/listen.schema.json +0 -127
- package/schema/verbs/llm.schema.json +0 -44
- package/schema/verbs/message.schema.json +0 -82
- package/schema/verbs/openai_s2s.schema.json +0 -42
- package/schema/verbs/pause.schema.json +0 -36
- package/schema/verbs/pipeline.schema.json +0 -240
- package/schema/verbs/play.schema.json +0 -96
- package/schema/verbs/redirect.schema.json +0 -34
- package/schema/verbs/s2s.schema.json +0 -39
- package/schema/verbs/say.schema.json +0 -107
- package/schema/verbs/sip-decline.schema.json +0 -58
- package/schema/verbs/sip-refer.schema.json +0 -58
- package/schema/verbs/sip-request.schema.json +0 -54
- package/schema/verbs/stream.schema.json +0 -103
- package/schema/verbs/tag.schema.json +0 -41
- package/schema/verbs/transcribe.schema.json +0 -57
- package/schema/verbs/ultravox_s2s.schema.json +0 -41
package/dist/index.js
CHANGED
|
@@ -1,101 +1,49 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
|
-
import { readFileSync } from 'fs';
|
|
3
|
-
import { dirname,
|
|
2
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
3
|
+
import { resolve, dirname, basename } from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
+
import { createRequire } from 'module';
|
|
5
6
|
import { createHmac, timingSafeEqual } from 'crypto';
|
|
6
7
|
import http from 'http';
|
|
7
8
|
import { WebSocketServer } from 'ws';
|
|
8
9
|
import { EventEmitter } from 'events';
|
|
9
10
|
|
|
10
11
|
// src/validator.ts
|
|
11
|
-
var COMPONENT_SCHEMAS = [
|
|
12
|
-
"auth",
|
|
13
|
-
"actionHook",
|
|
14
|
-
"actionHookDelayAction",
|
|
15
|
-
"amd",
|
|
16
|
-
"bidirectionalAudio",
|
|
17
|
-
"fillerNoise",
|
|
18
|
-
"recognizer",
|
|
19
|
-
"recognizer-assemblyAiOptions",
|
|
20
|
-
"recognizer-awsOptions",
|
|
21
|
-
"recognizer-azureOptions",
|
|
22
|
-
"recognizer-cobaltOptions",
|
|
23
|
-
"recognizer-customOptions",
|
|
24
|
-
"recognizer-deepgramOptions",
|
|
25
|
-
"recognizer-elevenlabsOptions",
|
|
26
|
-
"recognizer-gladiaOptions",
|
|
27
|
-
"recognizer-googleOptions",
|
|
28
|
-
"recognizer-houndifyOptions",
|
|
29
|
-
"recognizer-ibmOptions",
|
|
30
|
-
"recognizer-nuanceOptions",
|
|
31
|
-
"recognizer-nvidiaOptions",
|
|
32
|
-
"recognizer-openaiOptions",
|
|
33
|
-
"recognizer-sonioxOptions",
|
|
34
|
-
"recognizer-speechmaticsOptions",
|
|
35
|
-
"recognizer-verbioOptions",
|
|
36
|
-
"llm-base",
|
|
37
|
-
"synthesizer",
|
|
38
|
-
"target",
|
|
39
|
-
"vad"
|
|
40
|
-
];
|
|
41
|
-
var VERB_SCHEMAS = [
|
|
42
|
-
"answer",
|
|
43
|
-
"alert",
|
|
44
|
-
"config",
|
|
45
|
-
"say",
|
|
46
|
-
"play",
|
|
47
|
-
"gather",
|
|
48
|
-
"dial",
|
|
49
|
-
"listen",
|
|
50
|
-
"stream",
|
|
51
|
-
"llm",
|
|
52
|
-
"s2s",
|
|
53
|
-
"openai_s2s",
|
|
54
|
-
"google_s2s",
|
|
55
|
-
"elevenlabs_s2s",
|
|
56
|
-
"deepgram_s2s",
|
|
57
|
-
"ultravox_s2s",
|
|
58
|
-
"dialogflow",
|
|
59
|
-
"pipeline",
|
|
60
|
-
"conference",
|
|
61
|
-
"transcribe",
|
|
62
|
-
"enqueue",
|
|
63
|
-
"dequeue",
|
|
64
|
-
"dtmf",
|
|
65
|
-
"dub",
|
|
66
|
-
"hangup",
|
|
67
|
-
"leave",
|
|
68
|
-
"message",
|
|
69
|
-
"pause",
|
|
70
|
-
"redirect",
|
|
71
|
-
"tag",
|
|
72
|
-
"sip-decline",
|
|
73
|
-
"sip-request",
|
|
74
|
-
"sip-refer"
|
|
75
|
-
];
|
|
76
|
-
function loadSchema(schemaDir, relativePath) {
|
|
77
|
-
const fullPath = resolve(schemaDir, relativePath);
|
|
78
|
-
return JSON.parse(readFileSync(fullPath, "utf-8"));
|
|
79
|
-
}
|
|
80
12
|
function findSchemaDir() {
|
|
13
|
+
try {
|
|
14
|
+
const req = createRequire(import.meta.url);
|
|
15
|
+
const schemaIndex = req.resolve("@jambonz/schema");
|
|
16
|
+
const dir2 = resolve(schemaIndex, "..");
|
|
17
|
+
if (existsSync(resolve(dir2, "jambonz-app.schema.json"))) {
|
|
18
|
+
return dir2;
|
|
19
|
+
}
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
81
22
|
const currentDir = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
resolve(
|
|
86
|
-
// from dist/ (tsup bundles to package-root/dist/)
|
|
87
|
-
];
|
|
88
|
-
for (const candidate of candidates) {
|
|
89
|
-
try {
|
|
90
|
-
readFileSync(resolve(candidate, "jambonz-app.schema.json"), "utf-8");
|
|
23
|
+
let dir = currentDir;
|
|
24
|
+
for (let i = 0; i < 10; i++) {
|
|
25
|
+
const candidate = resolve(dir, "node_modules", "@jambonz", "schema");
|
|
26
|
+
if (existsSync(resolve(candidate, "jambonz-app.schema.json"))) {
|
|
91
27
|
return candidate;
|
|
92
|
-
} catch {
|
|
93
28
|
}
|
|
29
|
+
const parent = dirname(dir);
|
|
30
|
+
if (parent === dir) break;
|
|
31
|
+
dir = parent;
|
|
94
32
|
}
|
|
95
33
|
throw new Error(
|
|
96
|
-
"Could not find jambonz
|
|
34
|
+
"Could not find @jambonz/schema package. Ensure it is installed as a dependency."
|
|
97
35
|
);
|
|
98
36
|
}
|
|
37
|
+
function discoverSchemas(dir) {
|
|
38
|
+
try {
|
|
39
|
+
return readdirSync(dir).filter((f) => f.endsWith(".schema.json")).map((f) => basename(f, ".schema.json"));
|
|
40
|
+
} catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function loadSchema(filePath) {
|
|
45
|
+
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
46
|
+
}
|
|
99
47
|
var JambonzValidator = class {
|
|
100
48
|
validateApp;
|
|
101
49
|
ajv;
|
|
@@ -107,15 +55,17 @@ var JambonzValidator = class {
|
|
|
107
55
|
validateSchema: false,
|
|
108
56
|
logger: false
|
|
109
57
|
});
|
|
110
|
-
|
|
111
|
-
|
|
58
|
+
const componentsDir = resolve(dir, "components");
|
|
59
|
+
for (const name of discoverSchemas(componentsDir)) {
|
|
60
|
+
const schema = loadSchema(resolve(componentsDir, `${name}.schema.json`));
|
|
112
61
|
this.ajv.addSchema(schema);
|
|
113
62
|
}
|
|
114
|
-
|
|
115
|
-
|
|
63
|
+
const verbsDir = resolve(dir, "verbs");
|
|
64
|
+
for (const name of discoverSchemas(verbsDir)) {
|
|
65
|
+
const schema = loadSchema(resolve(verbsDir, `${name}.schema.json`));
|
|
116
66
|
this.ajv.addSchema(schema);
|
|
117
67
|
}
|
|
118
|
-
const appSchema = loadSchema(dir, "jambonz-app.schema.json");
|
|
68
|
+
const appSchema = loadSchema(resolve(dir, "jambonz-app.schema.json"));
|
|
119
69
|
this.validateApp = this.ajv.compile(appSchema);
|
|
120
70
|
}
|
|
121
71
|
/** Validate a complete verb array (a jambonz application). */
|
|
@@ -209,9 +159,9 @@ var VerbBuilder = class {
|
|
|
209
159
|
dialogflow(opts) {
|
|
210
160
|
return this.addVerb({ verb: "dialogflow", ...opts });
|
|
211
161
|
}
|
|
212
|
-
/** Voice AI
|
|
213
|
-
|
|
214
|
-
return this.addVerb({ verb: "
|
|
162
|
+
/** Voice AI agent with integrated turn detection. */
|
|
163
|
+
agent(opts) {
|
|
164
|
+
return this.addVerb({ verb: "agent", ...opts });
|
|
215
165
|
}
|
|
216
166
|
/** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */
|
|
217
167
|
listen(opts) {
|
|
@@ -526,9 +476,9 @@ var Session = class extends EventEmitter {
|
|
|
526
476
|
this.builder.dialogflow(opts);
|
|
527
477
|
return this;
|
|
528
478
|
}
|
|
529
|
-
/** Voice AI
|
|
530
|
-
|
|
531
|
-
this.builder.
|
|
479
|
+
/** Voice AI agent with integrated turn detection. */
|
|
480
|
+
agent(opts) {
|
|
481
|
+
this.builder.agent(opts);
|
|
532
482
|
return this;
|
|
533
483
|
}
|
|
534
484
|
/** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */
|
|
@@ -773,11 +723,11 @@ var Session = class extends EventEmitter {
|
|
|
773
723
|
data
|
|
774
724
|
});
|
|
775
725
|
}
|
|
776
|
-
/** Update an active
|
|
777
|
-
|
|
726
|
+
/** Update an active agent conversation mid-call. */
|
|
727
|
+
updateAgent(data) {
|
|
778
728
|
this.wsSend({
|
|
779
729
|
type: "command",
|
|
780
|
-
command: "
|
|
730
|
+
command: "agent:update",
|
|
781
731
|
data
|
|
782
732
|
});
|
|
783
733
|
}
|
|
@@ -900,8 +850,8 @@ var Session = class extends EventEmitter {
|
|
|
900
850
|
break;
|
|
901
851
|
case "llm:event":
|
|
902
852
|
case "llm:tool-call":
|
|
903
|
-
case "
|
|
904
|
-
case "
|
|
853
|
+
case "agent:event":
|
|
854
|
+
case "agent:tool-call":
|
|
905
855
|
if (hook) {
|
|
906
856
|
this.emit(hook, data);
|
|
907
857
|
}
|
|
@@ -1306,6 +1256,8 @@ var CallsResource = class {
|
|
|
1306
1256
|
this.http = http2;
|
|
1307
1257
|
this.accountSid = accountSid;
|
|
1308
1258
|
}
|
|
1259
|
+
http;
|
|
1260
|
+
accountSid;
|
|
1309
1261
|
/** Create a new outbound call. */
|
|
1310
1262
|
async create(opts) {
|
|
1311
1263
|
const result = await this.http.post(
|
|
@@ -1363,9 +1315,9 @@ var CallsResource = class {
|
|
|
1363
1315
|
async mute(callSid, status) {
|
|
1364
1316
|
return this.update(callSid, { mute_status: status });
|
|
1365
1317
|
}
|
|
1366
|
-
/** Send a mid-conversation update to an active
|
|
1367
|
-
async
|
|
1368
|
-
return this.update(callSid, {
|
|
1318
|
+
/** Send a mid-conversation update to an active agent verb. */
|
|
1319
|
+
async updateAgent(callSid, data) {
|
|
1320
|
+
return this.update(callSid, { agent_update: data });
|
|
1369
1321
|
}
|
|
1370
1322
|
/** Enable or disable server-side noise isolation. */
|
|
1371
1323
|
async noiseIsolation(callSid, status, opts) {
|
|
@@ -1382,6 +1334,8 @@ var ConferencesResource = class {
|
|
|
1382
1334
|
this.http = http2;
|
|
1383
1335
|
this.accountSid = accountSid;
|
|
1384
1336
|
}
|
|
1337
|
+
http;
|
|
1338
|
+
accountSid;
|
|
1385
1339
|
/** List active conferences. */
|
|
1386
1340
|
async list() {
|
|
1387
1341
|
return this.http.get(
|
|
@@ -1394,6 +1348,8 @@ var QueuesResource = class {
|
|
|
1394
1348
|
this.http = http2;
|
|
1395
1349
|
this.accountSid = accountSid;
|
|
1396
1350
|
}
|
|
1351
|
+
http;
|
|
1352
|
+
accountSid;
|
|
1397
1353
|
/** List active queues. */
|
|
1398
1354
|
async list(search) {
|
|
1399
1355
|
const qs = search ? `?search=${encodeURIComponent(search)}` : "";
|