@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.
Files changed (127) hide show
  1. package/dist/client/index.cjs +9 -3
  2. package/dist/client/index.cjs.map +1 -1
  3. package/dist/client/index.d.cts +4 -4
  4. package/dist/client/index.d.ts +4 -4
  5. package/dist/client/index.js +9 -3
  6. package/dist/client/index.js.map +1 -1
  7. package/dist/index.cjs +55 -99
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +4 -4
  10. package/dist/index.d.ts +4 -4
  11. package/dist/index.js +57 -101
  12. package/dist/index.js.map +1 -1
  13. package/dist/{rest-B_GQITxM.d.cts → rest-BvOtq44O.d.cts} +3 -3
  14. package/dist/{rest-DgctQy2b.d.ts → rest-DAAEUWsa.d.ts} +3 -3
  15. package/dist/{session-DVGHbtan.d.cts → session-DKaSRkIo.d.cts} +19 -19
  16. package/dist/{session-DVGHbtan.d.ts → session-DKaSRkIo.d.ts} +19 -19
  17. package/dist/types/index.d.cts +3 -3
  18. package/dist/types/index.d.ts +3 -3
  19. package/dist/{verb-builder-tayDQ0fe.d.ts → verb-builder-CFPD9yWI.d.cts} +4 -4
  20. package/dist/{verb-builder-BCjmdgUX.d.cts → verb-builder-D5XRbTtu.d.ts} +4 -4
  21. package/dist/{verbs-B18Kazd9.d.cts → verbs-DKy6nGIH.d.cts} +6 -6
  22. package/dist/{verbs-B18Kazd9.d.ts → verbs-DKy6nGIH.d.ts} +6 -6
  23. package/dist/webhook/index.cjs +38 -88
  24. package/dist/webhook/index.cjs.map +1 -1
  25. package/dist/webhook/index.d.cts +2 -2
  26. package/dist/webhook/index.d.ts +2 -2
  27. package/dist/webhook/index.js +40 -90
  28. package/dist/webhook/index.js.map +1 -1
  29. package/dist/websocket/index.cjs +46 -96
  30. package/dist/websocket/index.cjs.map +1 -1
  31. package/dist/websocket/index.d.cts +7 -7
  32. package/dist/websocket/index.d.ts +7 -7
  33. package/dist/websocket/index.js +48 -98
  34. package/dist/websocket/index.js.map +1 -1
  35. package/package.json +4 -4
  36. package/schema/callbacks/amd.schema.json +0 -50
  37. package/schema/callbacks/base.schema.json +0 -29
  38. package/schema/callbacks/call-status.schema.json +0 -22
  39. package/schema/callbacks/conference-status.schema.json +0 -24
  40. package/schema/callbacks/conference-wait.schema.json +0 -11
  41. package/schema/callbacks/conference.schema.json +0 -11
  42. package/schema/callbacks/dequeue.schema.json +0 -19
  43. package/schema/callbacks/dial-dtmf.schema.json +0 -18
  44. package/schema/callbacks/dial-hold.schema.json +0 -22
  45. package/schema/callbacks/dial-refer.schema.json +0 -28
  46. package/schema/callbacks/dial.schema.json +0 -31
  47. package/schema/callbacks/enqueue-wait.schema.json +0 -17
  48. package/schema/callbacks/enqueue.schema.json +0 -27
  49. package/schema/callbacks/gather-partial.schema.json +0 -54
  50. package/schema/callbacks/gather.schema.json +0 -60
  51. package/schema/callbacks/listen.schema.json +0 -21
  52. package/schema/callbacks/llm.schema.json +0 -30
  53. package/schema/callbacks/message.schema.json +0 -35
  54. package/schema/callbacks/pipeline-turn.schema.json +0 -109
  55. package/schema/callbacks/play.schema.json +0 -36
  56. package/schema/callbacks/session-new.schema.json +0 -143
  57. package/schema/callbacks/session-reconnect.schema.json +0 -9
  58. package/schema/callbacks/session-redirect.schema.json +0 -38
  59. package/schema/callbacks/sip-refer-event.schema.json +0 -20
  60. package/schema/callbacks/sip-refer.schema.json +0 -22
  61. package/schema/callbacks/sip-request.schema.json +0 -27
  62. package/schema/callbacks/transcribe-translation.schema.json +0 -24
  63. package/schema/callbacks/transcribe.schema.json +0 -46
  64. package/schema/callbacks/tts-streaming-event.schema.json +0 -77
  65. package/schema/callbacks/verb-status.schema.json +0 -57
  66. package/schema/components/actionHook.schema.json +0 -36
  67. package/schema/components/actionHookDelayAction.schema.json +0 -37
  68. package/schema/components/amd.schema.json +0 -68
  69. package/schema/components/auth.schema.json +0 -18
  70. package/schema/components/bidirectionalAudio.schema.json +0 -22
  71. package/schema/components/fillerNoise.schema.json +0 -25
  72. package/schema/components/llm-base.schema.json +0 -94
  73. package/schema/components/recognizer-assemblyAiOptions.schema.json +0 -66
  74. package/schema/components/recognizer-awsOptions.schema.json +0 -52
  75. package/schema/components/recognizer-azureOptions.schema.json +0 -32
  76. package/schema/components/recognizer-cobaltOptions.schema.json +0 -34
  77. package/schema/components/recognizer-customOptions.schema.json +0 -27
  78. package/schema/components/recognizer-deepgramOptions.schema.json +0 -147
  79. package/schema/components/recognizer-elevenlabsOptions.schema.json +0 -39
  80. package/schema/components/recognizer-gladiaOptions.schema.json +0 -8
  81. package/schema/components/recognizer-googleOptions.schema.json +0 -35
  82. package/schema/components/recognizer-houndifyOptions.schema.json +0 -53
  83. package/schema/components/recognizer-ibmOptions.schema.json +0 -54
  84. package/schema/components/recognizer-nuanceOptions.schema.json +0 -150
  85. package/schema/components/recognizer-nvidiaOptions.schema.json +0 -39
  86. package/schema/components/recognizer-openaiOptions.schema.json +0 -59
  87. package/schema/components/recognizer-sonioxOptions.schema.json +0 -46
  88. package/schema/components/recognizer-speechmaticsOptions.schema.json +0 -100
  89. package/schema/components/recognizer-verbioOptions.schema.json +0 -46
  90. package/schema/components/recognizer.schema.json +0 -216
  91. package/schema/components/synthesizer.schema.json +0 -82
  92. package/schema/components/target.schema.json +0 -105
  93. package/schema/components/vad.schema.json +0 -48
  94. package/schema/jambonz-app.schema.json +0 -112
  95. package/schema/verbs/alert.schema.json +0 -34
  96. package/schema/verbs/answer.schema.json +0 -22
  97. package/schema/verbs/conference.schema.json +0 -107
  98. package/schema/verbs/config.schema.json +0 -218
  99. package/schema/verbs/deepgram_s2s.schema.json +0 -81
  100. package/schema/verbs/dequeue.schema.json +0 -51
  101. package/schema/verbs/dial.schema.json +0 -187
  102. package/schema/verbs/dialogflow.schema.json +0 -148
  103. package/schema/verbs/dtmf.schema.json +0 -49
  104. package/schema/verbs/dub.schema.json +0 -103
  105. package/schema/verbs/elevenlabs_s2s.schema.json +0 -81
  106. package/schema/verbs/enqueue.schema.json +0 -53
  107. package/schema/verbs/gather.schema.json +0 -188
  108. package/schema/verbs/google_s2s.schema.json +0 -42
  109. package/schema/verbs/hangup.schema.json +0 -36
  110. package/schema/verbs/leave.schema.json +0 -22
  111. package/schema/verbs/listen.schema.json +0 -127
  112. package/schema/verbs/llm.schema.json +0 -44
  113. package/schema/verbs/message.schema.json +0 -82
  114. package/schema/verbs/openai_s2s.schema.json +0 -42
  115. package/schema/verbs/pause.schema.json +0 -36
  116. package/schema/verbs/pipeline.schema.json +0 -240
  117. package/schema/verbs/play.schema.json +0 -96
  118. package/schema/verbs/redirect.schema.json +0 -34
  119. package/schema/verbs/s2s.schema.json +0 -39
  120. package/schema/verbs/say.schema.json +0 -107
  121. package/schema/verbs/sip-decline.schema.json +0 -58
  122. package/schema/verbs/sip-refer.schema.json +0 -58
  123. package/schema/verbs/sip-request.schema.json +0 -54
  124. package/schema/verbs/stream.schema.json +0 -103
  125. package/schema/verbs/tag.schema.json +0 -41
  126. package/schema/verbs/transcribe.schema.json +0 -57
  127. 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, resolve } from 'path';
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
- const candidates = [
83
- resolve(currentDir, "../../schema"),
84
- // from typescript/src/
85
- resolve(currentDir, "../schema")
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 schema directory. Ensure the schema/ directory is present alongside the typescript/ directory."
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
- for (const name of COMPONENT_SCHEMAS) {
111
- const schema = loadSchema(dir, `components/${name}.schema.json`);
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
- for (const name of VERB_SCHEMAS) {
115
- const schema = loadSchema(dir, `verbs/${name}.schema.json`);
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 pipeline with integrated turn detection. */
213
- pipeline(opts) {
214
- return this.addVerb({ verb: "pipeline", ...opts });
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 pipeline with integrated turn detection. */
530
- pipeline(opts) {
531
- this.builder.pipeline(opts);
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 pipeline conversation mid-call. */
777
- updatePipeline(data) {
726
+ /** Update an active agent conversation mid-call. */
727
+ updateAgent(data) {
778
728
  this.wsSend({
779
729
  type: "command",
780
- command: "pipeline:update",
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 "pipeline:event":
904
- case "pipeline:tool-call":
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 pipeline verb. */
1367
- async updatePipeline(callSid, data) {
1368
- return this.update(callSid, { pipeline_update: data });
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)}` : "";