@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
@@ -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, resolve } from 'path';
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
- const candidates = [
82
- resolve(currentDir, "../../schema"),
83
- // from typescript/src/
84
- resolve(currentDir, "../schema")
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 schema directory. Ensure the schema/ directory is present alongside the typescript/ directory."
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
- for (const name of COMPONENT_SCHEMAS) {
110
- const schema = loadSchema(dir, `components/${name}.schema.json`);
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
- for (const name of VERB_SCHEMAS) {
114
- const schema = loadSchema(dir, `verbs/${name}.schema.json`);
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 pipeline with integrated turn detection. */
205
- pipeline(opts) {
206
- return this.addVerb({ verb: "pipeline", ...opts });
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 pipeline with integrated turn detection. */
456
- pipeline(opts) {
457
- this.builder.pipeline(opts);
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 pipeline conversation mid-call. */
703
- updatePipeline(data) {
652
+ /** Update an active agent conversation mid-call. */
653
+ updateAgent(data) {
704
654
  this.wsSend({
705
655
  type: "command",
706
- command: "pipeline:update",
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 "pipeline:event":
830
- case "pipeline:tool-call":
779
+ case "agent:event":
780
+ case "agent:tool-call":
831
781
  if (hook) {
832
782
  this.emit(hook, data);
833
783
  }