@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/websocket/index.js
CHANGED
|
@@ -2,99 +2,47 @@ import http from 'http';
|
|
|
2
2
|
import { WebSocketServer } from 'ws';
|
|
3
3
|
import { EventEmitter } from 'events';
|
|
4
4
|
import Ajv from 'ajv';
|
|
5
|
-
import { readFileSync } from 'fs';
|
|
6
|
-
import { dirname,
|
|
5
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
6
|
+
import { resolve, dirname, basename } from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
+
import { createRequire } from 'module';
|
|
8
9
|
|
|
9
10
|
// src/websocket/endpoint.ts
|
|
10
|
-
var COMPONENT_SCHEMAS = [
|
|
11
|
-
"auth",
|
|
12
|
-
"actionHook",
|
|
13
|
-
"actionHookDelayAction",
|
|
14
|
-
"amd",
|
|
15
|
-
"bidirectionalAudio",
|
|
16
|
-
"fillerNoise",
|
|
17
|
-
"recognizer",
|
|
18
|
-
"recognizer-assemblyAiOptions",
|
|
19
|
-
"recognizer-awsOptions",
|
|
20
|
-
"recognizer-azureOptions",
|
|
21
|
-
"recognizer-cobaltOptions",
|
|
22
|
-
"recognizer-customOptions",
|
|
23
|
-
"recognizer-deepgramOptions",
|
|
24
|
-
"recognizer-elevenlabsOptions",
|
|
25
|
-
"recognizer-gladiaOptions",
|
|
26
|
-
"recognizer-googleOptions",
|
|
27
|
-
"recognizer-houndifyOptions",
|
|
28
|
-
"recognizer-ibmOptions",
|
|
29
|
-
"recognizer-nuanceOptions",
|
|
30
|
-
"recognizer-nvidiaOptions",
|
|
31
|
-
"recognizer-openaiOptions",
|
|
32
|
-
"recognizer-sonioxOptions",
|
|
33
|
-
"recognizer-speechmaticsOptions",
|
|
34
|
-
"recognizer-verbioOptions",
|
|
35
|
-
"llm-base",
|
|
36
|
-
"synthesizer",
|
|
37
|
-
"target",
|
|
38
|
-
"vad"
|
|
39
|
-
];
|
|
40
|
-
var VERB_SCHEMAS = [
|
|
41
|
-
"answer",
|
|
42
|
-
"alert",
|
|
43
|
-
"config",
|
|
44
|
-
"say",
|
|
45
|
-
"play",
|
|
46
|
-
"gather",
|
|
47
|
-
"dial",
|
|
48
|
-
"listen",
|
|
49
|
-
"stream",
|
|
50
|
-
"llm",
|
|
51
|
-
"s2s",
|
|
52
|
-
"openai_s2s",
|
|
53
|
-
"google_s2s",
|
|
54
|
-
"elevenlabs_s2s",
|
|
55
|
-
"deepgram_s2s",
|
|
56
|
-
"ultravox_s2s",
|
|
57
|
-
"dialogflow",
|
|
58
|
-
"pipeline",
|
|
59
|
-
"conference",
|
|
60
|
-
"transcribe",
|
|
61
|
-
"enqueue",
|
|
62
|
-
"dequeue",
|
|
63
|
-
"dtmf",
|
|
64
|
-
"dub",
|
|
65
|
-
"hangup",
|
|
66
|
-
"leave",
|
|
67
|
-
"message",
|
|
68
|
-
"pause",
|
|
69
|
-
"redirect",
|
|
70
|
-
"tag",
|
|
71
|
-
"sip-decline",
|
|
72
|
-
"sip-request",
|
|
73
|
-
"sip-refer"
|
|
74
|
-
];
|
|
75
|
-
function loadSchema(schemaDir, relativePath) {
|
|
76
|
-
const fullPath = resolve(schemaDir, relativePath);
|
|
77
|
-
return JSON.parse(readFileSync(fullPath, "utf-8"));
|
|
78
|
-
}
|
|
79
11
|
function findSchemaDir() {
|
|
12
|
+
try {
|
|
13
|
+
const req = createRequire(import.meta.url);
|
|
14
|
+
const schemaIndex = req.resolve("@jambonz/schema");
|
|
15
|
+
const dir2 = resolve(schemaIndex, "..");
|
|
16
|
+
if (existsSync(resolve(dir2, "jambonz-app.schema.json"))) {
|
|
17
|
+
return dir2;
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
80
21
|
const currentDir = typeof __dirname !== "undefined" ? __dirname : dirname(fileURLToPath(import.meta.url));
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
resolve(
|
|
85
|
-
// from dist/ (tsup bundles to package-root/dist/)
|
|
86
|
-
];
|
|
87
|
-
for (const candidate of candidates) {
|
|
88
|
-
try {
|
|
89
|
-
readFileSync(resolve(candidate, "jambonz-app.schema.json"), "utf-8");
|
|
22
|
+
let dir = currentDir;
|
|
23
|
+
for (let i = 0; i < 10; i++) {
|
|
24
|
+
const candidate = resolve(dir, "node_modules", "@jambonz", "schema");
|
|
25
|
+
if (existsSync(resolve(candidate, "jambonz-app.schema.json"))) {
|
|
90
26
|
return candidate;
|
|
91
|
-
} catch {
|
|
92
27
|
}
|
|
28
|
+
const parent = dirname(dir);
|
|
29
|
+
if (parent === dir) break;
|
|
30
|
+
dir = parent;
|
|
93
31
|
}
|
|
94
32
|
throw new Error(
|
|
95
|
-
"Could not find jambonz
|
|
33
|
+
"Could not find @jambonz/schema package. Ensure it is installed as a dependency."
|
|
96
34
|
);
|
|
97
35
|
}
|
|
36
|
+
function discoverSchemas(dir) {
|
|
37
|
+
try {
|
|
38
|
+
return readdirSync(dir).filter((f) => f.endsWith(".schema.json")).map((f) => basename(f, ".schema.json"));
|
|
39
|
+
} catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function loadSchema(filePath) {
|
|
44
|
+
return JSON.parse(readFileSync(filePath, "utf-8"));
|
|
45
|
+
}
|
|
98
46
|
var JambonzValidator = class {
|
|
99
47
|
validateApp;
|
|
100
48
|
ajv;
|
|
@@ -106,15 +54,17 @@ var JambonzValidator = class {
|
|
|
106
54
|
validateSchema: false,
|
|
107
55
|
logger: false
|
|
108
56
|
});
|
|
109
|
-
|
|
110
|
-
|
|
57
|
+
const componentsDir = resolve(dir, "components");
|
|
58
|
+
for (const name of discoverSchemas(componentsDir)) {
|
|
59
|
+
const schema = loadSchema(resolve(componentsDir, `${name}.schema.json`));
|
|
111
60
|
this.ajv.addSchema(schema);
|
|
112
61
|
}
|
|
113
|
-
|
|
114
|
-
|
|
62
|
+
const verbsDir = resolve(dir, "verbs");
|
|
63
|
+
for (const name of discoverSchemas(verbsDir)) {
|
|
64
|
+
const schema = loadSchema(resolve(verbsDir, `${name}.schema.json`));
|
|
115
65
|
this.ajv.addSchema(schema);
|
|
116
66
|
}
|
|
117
|
-
const appSchema = loadSchema(dir, "jambonz-app.schema.json");
|
|
67
|
+
const appSchema = loadSchema(resolve(dir, "jambonz-app.schema.json"));
|
|
118
68
|
this.validateApp = this.ajv.compile(appSchema);
|
|
119
69
|
}
|
|
120
70
|
/** Validate a complete verb array (a jambonz application). */
|
|
@@ -201,9 +151,9 @@ var VerbBuilder = class {
|
|
|
201
151
|
dialogflow(opts) {
|
|
202
152
|
return this.addVerb({ verb: "dialogflow", ...opts });
|
|
203
153
|
}
|
|
204
|
-
/** Voice AI
|
|
205
|
-
|
|
206
|
-
return this.addVerb({ verb: "
|
|
154
|
+
/** Voice AI agent with integrated turn detection. */
|
|
155
|
+
agent(opts) {
|
|
156
|
+
return this.addVerb({ verb: "agent", ...opts });
|
|
207
157
|
}
|
|
208
158
|
/** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */
|
|
209
159
|
listen(opts) {
|
|
@@ -452,9 +402,9 @@ var Session = class extends EventEmitter {
|
|
|
452
402
|
this.builder.dialogflow(opts);
|
|
453
403
|
return this;
|
|
454
404
|
}
|
|
455
|
-
/** Voice AI
|
|
456
|
-
|
|
457
|
-
this.builder.
|
|
405
|
+
/** Voice AI agent with integrated turn detection. */
|
|
406
|
+
agent(opts) {
|
|
407
|
+
this.builder.agent(opts);
|
|
458
408
|
return this;
|
|
459
409
|
}
|
|
460
410
|
/** Stream real-time call audio to a WebSocket endpoint. Supports bidirectional audio. */
|
|
@@ -699,11 +649,11 @@ var Session = class extends EventEmitter {
|
|
|
699
649
|
data
|
|
700
650
|
});
|
|
701
651
|
}
|
|
702
|
-
/** Update an active
|
|
703
|
-
|
|
652
|
+
/** Update an active agent conversation mid-call. */
|
|
653
|
+
updateAgent(data) {
|
|
704
654
|
this.wsSend({
|
|
705
655
|
type: "command",
|
|
706
|
-
command: "
|
|
656
|
+
command: "agent:update",
|
|
707
657
|
data
|
|
708
658
|
});
|
|
709
659
|
}
|
|
@@ -826,8 +776,8 @@ var Session = class extends EventEmitter {
|
|
|
826
776
|
break;
|
|
827
777
|
case "llm:event":
|
|
828
778
|
case "llm:tool-call":
|
|
829
|
-
case "
|
|
830
|
-
case "
|
|
779
|
+
case "agent:event":
|
|
780
|
+
case "agent:tool-call":
|
|
831
781
|
if (hook) {
|
|
832
782
|
this.emit(hook, data);
|
|
833
783
|
}
|