nexus-ai-pro 2.20.2 → 2.22.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 (233) hide show
  1. package/API_STABILITY.md +93 -0
  2. package/CHANGELOG.md +208 -1
  3. package/README.md +11 -6
  4. package/SECURITY.md +16 -2
  5. package/dist/adapter-kit/gather.d.ts +76 -0
  6. package/dist/adapter-kit/gather.js +147 -0
  7. package/dist/adapter-kit/index.d.ts +1 -0
  8. package/dist/adapter-kit/index.js +1 -0
  9. package/dist/adapter-kit/record.d.ts +3 -1
  10. package/dist/adapter-kit/record.js +20 -5
  11. package/dist/agent/openapi.d.ts +94 -8
  12. package/dist/agent/openapi.js +528 -32
  13. package/dist/cli/adapters.d.ts +4 -3
  14. package/dist/cli/adapters.js +71 -2
  15. package/dist/cli/doctor.js +3 -0
  16. package/dist/cli.js +3 -1
  17. package/dist/core/config-builder.d.ts +1 -0
  18. package/dist/core/config-builder.js +1 -0
  19. package/dist/core/defaults.d.ts +34 -0
  20. package/dist/core/defaults.js +39 -0
  21. package/dist/core/secure-stream.js +4 -1
  22. package/dist/decisions/completion.d.ts +10 -7
  23. package/dist/decisions/completion.js +82 -8
  24. package/dist/decisions/core.d.ts +88 -43
  25. package/dist/decisions/core.js +115 -28
  26. package/dist/decisions/errors.d.ts +25 -0
  27. package/dist/decisions/errors.js +12 -0
  28. package/dist/decisions/index.d.ts +6 -5
  29. package/dist/decisions/index.js +2 -1
  30. package/dist/decisions/integrations.d.ts +14 -5
  31. package/dist/decisions/integrations.js +16 -1
  32. package/dist/decisions/mock.d.ts +5 -3
  33. package/dist/decisions/mock.js +4 -1
  34. package/dist/decisions/pictures.d.ts +43 -0
  35. package/dist/decisions/pictures.js +103 -0
  36. package/dist/decisions/typesafe.d.ts +33 -5
  37. package/dist/decisions/typesafe.js +121 -8
  38. package/dist/doctor/index.d.ts +6 -9
  39. package/dist/doctor/index.js +41 -0
  40. package/dist/embeddings/adapters.d.ts +1 -1
  41. package/dist/embeddings/adapters.js +3 -3
  42. package/dist/embeddings/batch-google.d.ts +27 -8
  43. package/dist/embeddings/batch-google.js +112 -36
  44. package/dist/embeddings/batch-mock.js +1 -1
  45. package/dist/embeddings/batch.js +10 -4
  46. package/dist/embeddings/engine.js +14 -13
  47. package/dist/embeddings/index.d.ts +1 -1
  48. package/dist/embeddings/inputs.d.ts +26 -3
  49. package/dist/embeddings/inputs.js +84 -5
  50. package/dist/embeddings/mock.js +1 -1
  51. package/dist/embeddings/models.js +39 -4
  52. package/dist/loaders/csv.d.ts +23 -1
  53. package/dist/loaders/csv.js +125 -72
  54. package/dist/loaders/index.d.ts +7 -2
  55. package/dist/loaders/input.d.ts +6 -0
  56. package/dist/loaders/input.js +42 -1
  57. package/dist/loaders/json.d.ts +14 -3
  58. package/dist/loaders/json.js +171 -20
  59. package/dist/loaders/web.d.ts +55 -0
  60. package/dist/loaders/web.js +20 -1
  61. package/dist/mcp/client.d.ts +54 -5
  62. package/dist/mcp/client.js +171 -20
  63. package/dist/mcp/http.d.ts +45 -0
  64. package/dist/mcp/http.js +233 -0
  65. package/dist/mcp/index.d.ts +4 -2
  66. package/dist/mcp/index.js +3 -1
  67. package/dist/mcp/protocol.d.ts +107 -0
  68. package/dist/mcp/sampling.d.ts +41 -0
  69. package/dist/mcp/sampling.js +52 -0
  70. package/dist/mcp/server.d.ts +96 -14
  71. package/dist/mcp/server.js +274 -59
  72. package/dist/models/data.js +20 -1
  73. package/dist/operations/adapters.d.ts +1 -0
  74. package/dist/operations/adapters.js +3 -1
  75. package/dist/protocols/a2a-grpc.js +10 -3
  76. package/dist/protocols/a2a-signing.d.ts +65 -0
  77. package/dist/protocols/a2a-signing.js +133 -0
  78. package/dist/protocols/a2a.d.ts +14 -0
  79. package/dist/protocols/a2a.js +60 -5
  80. package/dist/providers/cohere.js +16 -2
  81. package/dist/providers/google.js +7 -1
  82. package/dist/providers/ollama.d.ts +1 -1
  83. package/dist/providers/ollama.js +35 -27
  84. package/dist/providers/openai.js +19 -2
  85. package/dist/rag/pinecone.d.ts +63 -2
  86. package/dist/rag/pinecone.js +80 -0
  87. package/dist/realtime/conversation.js +18 -0
  88. package/dist/realtime/gemini-live.transport.d.ts +28 -3
  89. package/dist/realtime/gemini-live.transport.js +170 -32
  90. package/dist/realtime/session.d.ts +2 -0
  91. package/dist/realtime/session.js +19 -4
  92. package/dist/realtime/types.d.ts +35 -3
  93. package/dist/security/output-guard.js +4 -1
  94. package/dist/server/auth.d.ts +263 -2
  95. package/dist/server/auth.js +432 -5
  96. package/dist/server/deployments.d.ts +3 -2
  97. package/dist/server/deployments.js +6 -1
  98. package/dist/telephony/index.d.ts +1 -1
  99. package/dist/telephony/manager.d.ts +8 -1
  100. package/dist/telephony/manager.js +13 -0
  101. package/dist/telephony/providers/telnyx.d.ts +18 -5
  102. package/dist/telephony/providers/telnyx.js +44 -7
  103. package/dist/telephony/providers/twilio.d.ts +3 -1
  104. package/dist/telephony/providers/twilio.js +16 -0
  105. package/dist/tracing/stores.d.ts +2 -0
  106. package/dist/tracing/stores.js +1 -0
  107. package/dist/tracing/tracer.d.ts +5 -2
  108. package/dist/tracing/tracer.js +6 -3
  109. package/dist/types/embeddings.d.ts +47 -5
  110. package/dist/types/messages.d.ts +7 -0
  111. package/dist/types/principal.d.ts +1 -1
  112. package/dist/types/response.d.ts +5 -0
  113. package/dist/types/telephony.d.ts +38 -0
  114. package/dist/types/tracing.d.ts +6 -0
  115. package/dist/version.d.ts +1 -1
  116. package/dist/version.js +1 -1
  117. package/dist/voice/providers/google.d.ts +44 -0
  118. package/dist/voice/providers/google.js +215 -0
  119. package/dist-cjs/adapter-kit/gather.d.ts +76 -0
  120. package/dist-cjs/adapter-kit/gather.js +152 -0
  121. package/dist-cjs/adapter-kit/index.d.ts +1 -0
  122. package/dist-cjs/adapter-kit/index.js +4 -1
  123. package/dist-cjs/adapter-kit/record.d.ts +3 -1
  124. package/dist-cjs/adapter-kit/record.js +20 -5
  125. package/dist-cjs/agent/openapi.d.ts +94 -8
  126. package/dist-cjs/agent/openapi.js +530 -32
  127. package/dist-cjs/cli/adapters.d.ts +4 -3
  128. package/dist-cjs/cli/adapters.js +70 -1
  129. package/dist-cjs/cli/doctor.js +3 -0
  130. package/dist-cjs/core/config-builder.d.ts +1 -0
  131. package/dist-cjs/core/config-builder.js +5 -1
  132. package/dist-cjs/core/defaults.d.ts +34 -0
  133. package/dist-cjs/core/defaults.js +44 -0
  134. package/dist-cjs/core/secure-stream.js +4 -1
  135. package/dist-cjs/decisions/completion.d.ts +10 -7
  136. package/dist-cjs/decisions/completion.js +81 -7
  137. package/dist-cjs/decisions/core.d.ts +88 -43
  138. package/dist-cjs/decisions/core.js +134 -46
  139. package/dist-cjs/decisions/errors.d.ts +25 -0
  140. package/dist-cjs/decisions/errors.js +16 -0
  141. package/dist-cjs/decisions/index.d.ts +6 -5
  142. package/dist-cjs/decisions/index.js +5 -1
  143. package/dist-cjs/decisions/integrations.d.ts +14 -5
  144. package/dist-cjs/decisions/integrations.js +16 -1
  145. package/dist-cjs/decisions/mock.d.ts +5 -3
  146. package/dist-cjs/decisions/mock.js +4 -1
  147. package/dist-cjs/decisions/pictures.d.ts +43 -0
  148. package/dist-cjs/decisions/pictures.js +109 -0
  149. package/dist-cjs/decisions/typesafe.d.ts +33 -5
  150. package/dist-cjs/decisions/typesafe.js +126 -13
  151. package/dist-cjs/doctor/index.d.ts +6 -9
  152. package/dist-cjs/doctor/index.js +41 -0
  153. package/dist-cjs/embeddings/adapters.d.ts +1 -1
  154. package/dist-cjs/embeddings/adapters.js +3 -3
  155. package/dist-cjs/embeddings/batch-google.d.ts +27 -8
  156. package/dist-cjs/embeddings/batch-google.js +112 -36
  157. package/dist-cjs/embeddings/batch-mock.js +1 -1
  158. package/dist-cjs/embeddings/batch.js +9 -3
  159. package/dist-cjs/embeddings/engine.js +13 -12
  160. package/dist-cjs/embeddings/index.d.ts +1 -1
  161. package/dist-cjs/embeddings/inputs.d.ts +26 -3
  162. package/dist-cjs/embeddings/inputs.js +89 -5
  163. package/dist-cjs/embeddings/mock.js +1 -1
  164. package/dist-cjs/embeddings/models.js +39 -4
  165. package/dist-cjs/loaders/csv.d.ts +23 -1
  166. package/dist-cjs/loaders/csv.js +126 -71
  167. package/dist-cjs/loaders/index.d.ts +7 -2
  168. package/dist-cjs/loaders/input.d.ts +6 -0
  169. package/dist-cjs/loaders/input.js +43 -1
  170. package/dist-cjs/loaders/json.d.ts +14 -3
  171. package/dist-cjs/loaders/json.js +170 -19
  172. package/dist-cjs/loaders/web.d.ts +55 -0
  173. package/dist-cjs/loaders/web.js +21 -1
  174. package/dist-cjs/mcp/client.d.ts +54 -5
  175. package/dist-cjs/mcp/client.js +171 -20
  176. package/dist-cjs/mcp/http.d.ts +45 -0
  177. package/dist-cjs/mcp/http.js +236 -0
  178. package/dist-cjs/mcp/index.d.ts +4 -2
  179. package/dist-cjs/mcp/index.js +5 -1
  180. package/dist-cjs/mcp/protocol.d.ts +107 -0
  181. package/dist-cjs/mcp/sampling.d.ts +41 -0
  182. package/dist-cjs/mcp/sampling.js +55 -0
  183. package/dist-cjs/mcp/server.d.ts +96 -14
  184. package/dist-cjs/mcp/server.js +273 -58
  185. package/dist-cjs/models/data.js +20 -1
  186. package/dist-cjs/operations/adapters.d.ts +1 -0
  187. package/dist-cjs/operations/adapters.js +3 -1
  188. package/dist-cjs/protocols/a2a-grpc.js +10 -3
  189. package/dist-cjs/protocols/a2a-signing.d.ts +65 -0
  190. package/dist-cjs/protocols/a2a-signing.js +140 -0
  191. package/dist-cjs/protocols/a2a.d.ts +14 -0
  192. package/dist-cjs/protocols/a2a.js +65 -6
  193. package/dist-cjs/providers/cohere.js +16 -2
  194. package/dist-cjs/providers/google.js +7 -1
  195. package/dist-cjs/providers/ollama.d.ts +1 -1
  196. package/dist-cjs/providers/ollama.js +35 -27
  197. package/dist-cjs/providers/openai.js +19 -2
  198. package/dist-cjs/rag/pinecone.d.ts +63 -2
  199. package/dist-cjs/rag/pinecone.js +81 -0
  200. package/dist-cjs/realtime/conversation.js +18 -0
  201. package/dist-cjs/realtime/gemini-live.transport.d.ts +28 -3
  202. package/dist-cjs/realtime/gemini-live.transport.js +170 -32
  203. package/dist-cjs/realtime/session.d.ts +2 -0
  204. package/dist-cjs/realtime/session.js +19 -4
  205. package/dist-cjs/realtime/types.d.ts +35 -3
  206. package/dist-cjs/security/output-guard.js +4 -1
  207. package/dist-cjs/server/auth.d.ts +263 -2
  208. package/dist-cjs/server/auth.js +437 -5
  209. package/dist-cjs/server/deployments.d.ts +3 -2
  210. package/dist-cjs/server/deployments.js +6 -1
  211. package/dist-cjs/telephony/index.d.ts +1 -1
  212. package/dist-cjs/telephony/manager.d.ts +8 -1
  213. package/dist-cjs/telephony/manager.js +13 -0
  214. package/dist-cjs/telephony/providers/telnyx.d.ts +18 -5
  215. package/dist-cjs/telephony/providers/telnyx.js +44 -7
  216. package/dist-cjs/telephony/providers/twilio.d.ts +3 -1
  217. package/dist-cjs/telephony/providers/twilio.js +16 -0
  218. package/dist-cjs/tracing/stores.d.ts +2 -0
  219. package/dist-cjs/tracing/stores.js +1 -0
  220. package/dist-cjs/tracing/tracer.d.ts +5 -2
  221. package/dist-cjs/tracing/tracer.js +6 -3
  222. package/dist-cjs/types/embeddings.d.ts +47 -5
  223. package/dist-cjs/types/messages.d.ts +7 -0
  224. package/dist-cjs/types/principal.d.ts +1 -1
  225. package/dist-cjs/types/response.d.ts +5 -0
  226. package/dist-cjs/types/telephony.d.ts +38 -0
  227. package/dist-cjs/types/tracing.d.ts +6 -0
  228. package/dist-cjs/version.d.ts +1 -1
  229. package/dist-cjs/version.js +1 -1
  230. package/dist-cjs/voice/providers/google.d.ts +44 -0
  231. package/dist-cjs/voice/providers/google.js +252 -0
  232. package/llms.txt +1 -1
  233. package/package.json +17 -1
@@ -65,9 +65,6 @@ class TelnyxTelephonyProvider {
65
65
  if (request.redirectUrl) {
66
66
  throw new errors_js_1.TelephonyProviderError('Telnyx calls are controlled by command, not redirected to a webhook', 'telnyx');
67
67
  }
68
- if (request.gather?.input && !request.gather.input.includes('dtmf')) {
69
- throw new errors_js_1.TelephonyProviderError('Telnyx gathers keypad digits, not speech', 'telnyx');
70
- }
71
68
  const sent = [];
72
69
  const run = async (action, body) => {
73
70
  sent.push({ action, body });
@@ -86,15 +83,27 @@ class TelnyxTelephonyProvider {
86
83
  }
87
84
  if (request.gather) {
88
85
  const gather = request.gather;
86
+ const input = gather.input ?? ['dtmf'];
87
+ if (input.includes('speech')) {
88
+ await run('transcription_start', {
89
+ language: voice.language,
90
+ transcription_tracks: 'inbound',
91
+ ...(this.config.transcriptionEngine ? { transcription_engine: this.config.transcriptionEngine } : {}),
92
+ });
93
+ }
89
94
  const digits = {
90
95
  ...(gather.numDigits !== undefined ? { minimum_digits: 1, maximum_digits: gather.numDigits } : {}),
91
96
  ...(gather.timeoutSeconds !== undefined ? { timeout_millis: gather.timeoutSeconds * 1_000 } : {}),
92
97
  ...(gather.finishOnKey ? { terminating_digit: gather.finishOnKey } : {}),
93
98
  };
94
- if (gather.prompts?.length)
95
- await run('gather_using_speak', { payload: gather.prompts.join(' '), ...voice, ...digits });
96
- else
97
- await run('gather', digits);
99
+ if (input.includes('dtmf')) {
100
+ if (gather.prompts?.length)
101
+ await run('gather_using_speak', { payload: gather.prompts.join(' '), ...voice, ...digits });
102
+ else
103
+ await run('gather', digits);
104
+ }
105
+ else if (gather.prompts?.length)
106
+ await run('speak', { payload: gather.prompts.join(' '), ...voice });
98
107
  }
99
108
  if (request.dial?.conference) {
100
109
  await this.joinConference({
@@ -410,6 +419,34 @@ class TelnyxTelephonyProvider {
410
419
  async stopRecording(request, context) {
411
420
  await this.command(request.callId, 'record_stop', {}, request.signal, context);
412
421
  }
422
+ parseGatherResult(body) {
423
+ const event = webhookEvent(body);
424
+ if (!event)
425
+ return undefined;
426
+ const { type, payload } = event;
427
+ const callId = stringValue(payload.call_control_id) ?? '';
428
+ if (type === 'call.gather.ended') {
429
+ return { providerUsed: 'telnyx', callId, digits: stringValue(payload.digits) ?? '', final: true, raw: event.raw };
430
+ }
431
+ if (type !== 'call.transcription')
432
+ return undefined;
433
+ const data = objectValue(payload.transcription_data);
434
+ const speech = stringValue(data.transcript);
435
+ if (speech === undefined)
436
+ return undefined;
437
+ const confidence = numberValue(data.confidence);
438
+ return {
439
+ providerUsed: 'telnyx',
440
+ callId,
441
+ speech,
442
+ ...(confidence !== undefined ? { confidence } : {}),
443
+ final: data.is_final === true,
444
+ raw: event.raw,
445
+ };
446
+ }
447
+ async endGather(request, context) {
448
+ await this.command(request.callId, 'transcription_stop', {}, request.signal, context);
449
+ }
413
450
  parseRecordingCallback(body) {
414
451
  const event = webhookEvent(body);
415
452
  if (event?.type !== 'call.recording.saved')
@@ -1,5 +1,5 @@
1
1
  import type { ProviderCallContext } from '../../types/lifecycle.js';
2
- import type { CreateCallRequest, CreateCallResponse, DeleteRecordingRequest, DownloadRecordingRequest, EndCallRequest, GetCallRequest, JoinConferenceRequest, ListPhoneNumbersRequest, SendMessageRequest, StartRecordingRequest, StopRecordingRequest, TelephonyCallDetails, TelephonyConferenceJoin, TelephonyMessage, TelephonyRecording, TelephonyRecordingAudio, TelephonyRecordingStarted, TelephonyTransfer, TransferCallRequest, TelephonyMediaStreamEvent, TelephonyOutboundAudioMessage, TelephonyPhoneNumber, TelephonyProvider, TelephonyProviderInfo, TelephonyResponseRequest, TelephonyStatusCallback, TelephonyWebhookResponse, TelephonyWebhookValidationRequest, UpdatePhoneNumberRequest } from '../../types/telephony.js';
2
+ import type { CreateCallRequest, CreateCallResponse, DeleteRecordingRequest, DownloadRecordingRequest, EndCallRequest, GetCallRequest, JoinConferenceRequest, ListPhoneNumbersRequest, SendMessageRequest, StartRecordingRequest, StopRecordingRequest, TelephonyCallDetails, TelephonyConferenceJoin, TelephonyMessage, TelephonyRecording, TelephonyRecordingAudio, TelephonyRecordingStarted, TelephonyTransfer, TransferCallRequest, TelephonyMediaStreamEvent, TelephonyOutboundAudioMessage, TelephonyPhoneNumber, TelephonyProvider, TelephonyProviderInfo, TelephonyResponseRequest, TelephonyStatusCallback, TelephonyWebhookResponse, TelephonyWebhookValidationRequest, UpdatePhoneNumberRequest, TelephonyGatherResult } from '../../types/telephony.js';
3
3
  /** Options for the Twilio telephony provider. */
4
4
  export interface TwilioTelephonyProviderConfig {
5
5
  /** Twilio account SID. Required for REST calls. */
@@ -34,6 +34,8 @@ export declare class TwilioTelephonyProvider implements TelephonyProvider {
34
34
  endCall(request: EndCallRequest, context?: ProviderCallContext): Promise<TelephonyCallDetails>;
35
35
  /** Parses a status callback into neutral call details. */
36
36
  parseStatusCallback(body: string | URLSearchParams | Record<string, string | number | boolean | undefined>): TelephonyStatusCallback | undefined;
37
+ /** Parses what a `<Gather>` posted to its action: `SpeechResult` with its `Confidence`, and `Digits`. */
38
+ parseGatherResult(body: string | URLSearchParams | Record<string, unknown>): TelephonyGatherResult | undefined;
37
39
  /** Lists the account's phone numbers. */
38
40
  listPhoneNumbers(request?: ListPhoneNumbersRequest, context?: ProviderCallContext): Promise<TelephonyPhoneNumber[]>;
39
41
  /** Changes where a phone number sends its calls and status callbacks. */
@@ -137,6 +137,22 @@ class TwilioTelephonyProvider {
137
137
  raw: params,
138
138
  };
139
139
  }
140
+ parseGatherResult(body) {
141
+ const params = toParamRecord(body);
142
+ const callId = params.CallSid;
143
+ if (!callId || (params.SpeechResult === undefined && params.Digits === undefined))
144
+ return undefined;
145
+ const confidence = numberValue(params.Confidence);
146
+ return {
147
+ providerUsed: 'twilio',
148
+ callId,
149
+ ...(params.SpeechResult !== undefined ? { speech: params.SpeechResult } : {}),
150
+ ...(confidence !== undefined ? { confidence } : {}),
151
+ ...(params.Digits !== undefined ? { digits: params.Digits } : {}),
152
+ final: true,
153
+ raw: params,
154
+ };
155
+ }
140
156
  async listPhoneNumbers(request = {}, context) {
141
157
  const query = new URLSearchParams();
142
158
  if (request.phoneNumber)
@@ -13,6 +13,8 @@ export interface MemoryTraceStoreOptions {
13
13
  * runs. Bounded, like every other in-memory store here.
14
14
  */
15
15
  export declare class MemoryTraceStore implements TraceStore {
16
+ /** Not durable: its runs live only in this process. */
17
+ readonly durable = false;
16
18
  private readonly runs;
17
19
  private readonly maxRuns;
18
20
  constructor(options?: MemoryTraceStoreOptions);
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "assembleTree", { enumerable: true, get: function
14
14
  Object.defineProperty(exports, "isAfterCursor", { enumerable: true, get: function () { return query_js_1.isAfterCursor; } });
15
15
  Object.defineProperty(exports, "runCursor", { enumerable: true, get: function () { return query_js_1.runCursor; } });
16
16
  class MemoryTraceStore {
17
+ durable = false;
17
18
  runs = new Map();
18
19
  maxRuns;
19
20
  constructor(options = {}) {
@@ -33,7 +33,8 @@ export interface TracerOptions {
33
33
  * run stays in the store with every run that finished, and a run in progress can be watched.
34
34
  * Sampling is then decided when the root starts. A trace not sampled is still held in memory and
35
35
  * written at the end when tail sampling keeps it, so `keepErrors` still shows every failure.
36
- * Defaults to false, which writes at the end, as before.
36
+ * Defaults to false, which writes at the end, as before; under 3.0's defaults, `useDefaults('3.0')`,
37
+ * to true on a durable store, one whose `durable` is not `false`.
37
38
  */
38
39
  incremental?: boolean;
39
40
  /**
@@ -139,10 +140,12 @@ export declare class Tracer {
139
140
  /** Runs that finished, whose events are closed. Weak, so a run never finished is never held. */
140
141
  private readonly closed;
141
142
  private readonly now;
143
+ /** Whether runs are written as they start and finish: as asked, or as the defaults in effect say. */
144
+ private readonly writesAsItRuns;
142
145
  constructor(options: TracerOptions);
143
146
  /** Where runs are written. */
144
147
  get store(): TraceStore;
145
- /** Whether runs are written as they start and finish, as `incremental` asks. */
148
+ /** Whether runs are written as they start and finish, as `incremental` asks, or 3.0's defaults do. */
146
149
  get incremental(): boolean;
147
150
  /** The run currently in scope, if any. */
148
151
  current(): {
@@ -4,6 +4,7 @@ exports.Tracer = void 0;
4
4
  exports.w3cTraceId = w3cTraceId;
5
5
  exports.w3cSpanId = w3cSpanId;
6
6
  exports.stripFields = stripFields;
7
+ const defaults_js_1 = require("../core/defaults.js");
7
8
  const ids_js_1 = require("../utils/ids.js");
8
9
  const node_async_hooks_1 = require("node:async_hooks");
9
10
  const DEFAULT_MAX_EVENTS = 128;
@@ -15,15 +16,17 @@ class Tracer {
15
16
  scopes = new WeakMap();
16
17
  closed = new WeakSet();
17
18
  now;
19
+ writesAsItRuns;
18
20
  constructor(options) {
19
21
  this.options = options;
20
22
  this.now = options.now ?? (() => new Date());
23
+ this.writesAsItRuns = options.incremental ?? ((0, defaults_js_1.nexusDefaults)() === '3.0' && options.store?.durable !== false);
21
24
  }
22
25
  get store() {
23
26
  return this.options.store;
24
27
  }
25
28
  get incremental() {
26
- return this.options.incremental === true;
29
+ return this.writesAsItRuns;
27
30
  }
28
31
  current() {
29
32
  const active = this.context.getStore();
@@ -59,7 +62,7 @@ class Tracer {
59
62
  metadata: { ...this.options.metadata, ...options.metadata },
60
63
  ...(options.links?.length ? { links: linksOf(options.links) } : {}),
61
64
  };
62
- if (this.options.incremental && sampled) {
65
+ if (this.writesAsItRuns && sampled) {
63
66
  this.enqueue(run.traceId, () => this.options.store.save(this.prepare(run)));
64
67
  }
65
68
  else {
@@ -152,7 +155,7 @@ class Tracer {
152
155
  ...(options.provider ? { provider: options.provider } : {}),
153
156
  metadata: { ...run.metadata, ...options.metadata },
154
157
  };
155
- if (this.options.incremental && sampled) {
158
+ if (this.writesAsItRuns && sampled) {
156
159
  await this.enqueue(run.traceId, async () => {
157
160
  const prepared = this.prepare(finished);
158
161
  await this.options.store.save(prepared);
@@ -2,7 +2,7 @@ import type { ProviderCallContext } from './lifecycle.js';
2
2
  import type { CacheConfig, RateLimitConfig, RetryConfig } from './config.js';
3
3
  import type { ModelStatus } from './providers.js';
4
4
  import type { ResponseCost, TokenUsage } from './response.js';
5
- import type { AudioContent, DocumentContent, ImageContent, TextContent } from './messages.js';
5
+ import type { AudioContent, BinaryBuffer, DocumentContent, ImageContent, TextContent } from './messages.js';
6
6
  /**
7
7
  * What the vector will be used for.
8
8
  *
@@ -16,12 +16,33 @@ export type EmbeddingEncodingFormat = 'float' | 'base64';
16
16
  /** How an input longer than the model's limit is handled. */
17
17
  export type EmbeddingTruncateMode = 'none' | 'start' | 'end';
18
18
  /** What an embedding input can hold besides text. */
19
- export type EmbeddingModality = 'text' | 'image' | 'audio' | 'document';
19
+ export type EmbeddingModality = 'text' | 'image' | 'audio' | 'video' | 'document';
20
20
  /**
21
- * A part of an embedding input: the same text, image, audio, and document parts a message takes.
22
- * Media must hold its content, as bytes, base64, or a URL; a path or a transcript is refused.
21
+ * A video to embed, by its content. A message's video part names a file on disk, which a provider
22
+ * cannot be sent, so an embedding takes the video itself: its bytes or base64, with its container,
23
+ * such as `mp4` or `mov`, or a URL a provider reads, such as a Files API URI Google embeds from.
23
24
  */
24
- export type EmbeddingPart = TextContent | ImageContent | AudioContent | DocumentContent;
25
+ export interface EmbeddingVideoPart {
26
+ /** Discriminates this part. */
27
+ type: 'video';
28
+ /** The video. */
29
+ source: {
30
+ buffer: BinaryBuffer;
31
+ format?: string;
32
+ } | {
33
+ base64: string;
34
+ format?: string;
35
+ } | {
36
+ url: string;
37
+ format?: string;
38
+ };
39
+ }
40
+ /**
41
+ * A part of an embedding input: the same text, image, audio, and document parts a message takes, and
42
+ * a video by its content. Media must hold its content, as bytes, base64, or a URL; a path or a
43
+ * transcript is refused.
44
+ */
45
+ export type EmbeddingPart = TextContent | ImageContent | AudioContent | DocumentContent | EmbeddingVideoPart;
25
46
  /**
26
47
  * One input made of parts, such as an image with its caption, embedded as one vector in the same
27
48
  * space as text. Only a model that takes each part's kind is sent it; any other is refused.
@@ -132,6 +153,11 @@ export interface EmbeddingMeta {
132
153
  usage: TokenUsage;
133
154
  /** What it cost, from the model's price. */
134
155
  cost: ResponseCost;
156
+ /**
157
+ * Audio and video parts whose length could not be read from their bytes, such as one given by URL,
158
+ * and so are not in `cost` for a model that prices them by length.
159
+ */
160
+ unpricedMedia?: number;
135
161
  /** True when every input was served from cache and no provider call was made. */
136
162
  cacheHit: boolean;
137
163
  /** Inputs served from cache when only part of the batch was. */
@@ -308,6 +334,22 @@ export interface EmbeddingModelCapabilities {
308
334
  costPer1kInput: number;
309
335
  /** Price per image embedded, in US dollars, for a model that takes images. */
310
336
  costPerImage?: number;
337
+ /** Price per second of audio embedded, in US dollars, its length read from the audio's own headers. */
338
+ costPerAudioSecond?: number;
339
+ /** Price per frame the model takes from a video, in US dollars. */
340
+ costPerVideoFrame?: number;
341
+ /**
342
+ * How many frames the model takes from a video, which `costPerVideoFrame` prices: `perSecond`, and
343
+ * at most `max`. Defaults to one a second, with no most.
344
+ */
345
+ videoFrames?: {
346
+ perSecond: number;
347
+ max?: number;
348
+ };
349
+ /** The longest audio part it takes, in seconds. A longer one is refused before it is sent. */
350
+ maxAudioSeconds?: number;
351
+ /** The longest video part it takes, in seconds. A longer one is refused before it is sent. */
352
+ maxVideoSeconds?: number;
311
353
  /** What its inputs can hold. Text only when absent. */
312
354
  inputModalities?: readonly EmbeddingModality[];
313
355
  /** True when the model already returns unit-length vectors. */
@@ -1,3 +1,4 @@
1
+ import type { McpCallerRequests } from '../mcp/protocol.js';
1
2
  import type { CacheTtl, ReasoningEffort } from './providers.js';
2
3
  import type { GraphEvent } from './graph.js';
3
4
  import type { AssetInput } from './images.js';
@@ -244,6 +245,12 @@ export interface ToolContext {
244
245
  * subgraph events, so a tool calls it as `context.forward?.()`.
245
246
  */
246
247
  forward?: (event: GraphEvent, namespace: readonly string[]) => void;
248
+ /**
249
+ * When an MCP server runs the tool, what it may ask the client that called it: a completion from
250
+ * its model, an answer from its person, and its roots. Absent elsewhere, so a tool calls it as
251
+ * `context.mcp?.createMessage()`.
252
+ */
253
+ mcp?: McpCallerRequests;
247
254
  }
248
255
  /** What a tool returned, correlated with the call that asked for it. */
249
256
  export interface ToolCallResult {
@@ -14,7 +14,7 @@ export interface Principal {
14
14
  scopes?: readonly string[];
15
15
  /** The caller's roles, for policies and tools that decide by role rather than by scope. */
16
16
  roles?: readonly string[];
17
- /** How the caller was authenticated: `jwt`, `api-key`, `proxy`, or a name of your own. */
17
+ /** How the caller was authenticated: `jwt`, `api-key`, `session`, `proxy`, or a name of your own. */
18
18
  method?: string;
19
19
  /** The verified claims or attributes the principal was built from, for anything the fields above leave out. */
20
20
  claims?: Readonly<Record<string, unknown>>;
@@ -193,6 +193,11 @@ export interface StreamChunk {
193
193
  meta?: Partial<ResponseMeta>;
194
194
  /** What went wrong, for an `error` chunk. */
195
195
  error?: string;
196
+ /**
197
+ * For a `text` chunk, its tokens' log probabilities, in order, when the request asked for
198
+ * `logprobs` and the provider streams them: the chunks' together are the response's.
199
+ */
200
+ logprobs?: TokenLogprob[];
196
201
  }
197
202
  /** A streamed completion: iterate it for chunks, or abort it. */
198
203
  export interface NexusStream extends AsyncIterable<StreamChunk> {
@@ -76,6 +76,37 @@ export interface TelephonyGatherConfig {
76
76
  /** Text spoken to the caller while listening. */
77
77
  prompts?: string[];
78
78
  }
79
+ /** What a caller gave a gather: what they said, the keys they pressed, or both. */
80
+ export interface TelephonyGatherResult {
81
+ /** Provider that collected it. */
82
+ providerUsed: string;
83
+ /** The provider's id for the call. */
84
+ callId: string;
85
+ /** What the caller said, as transcribed. */
86
+ speech?: string;
87
+ /** How sure the transcription is, from 0 to 1, when the provider says. */
88
+ confidence?: number;
89
+ /** The keys the caller pressed. */
90
+ digits?: string;
91
+ /**
92
+ * False for speech still being transcribed, which a later result replaces; true for what the
93
+ * caller finished saying, and for keys.
94
+ */
95
+ final: boolean;
96
+ /** The webhook, unmodified. */
97
+ raw?: unknown;
98
+ }
99
+ /** Stops a gather still listening: on Telnyx, the transcription a speech gather started. */
100
+ export interface EndGatherRequest {
101
+ /** Provider the call belongs to. */
102
+ provider?: string;
103
+ /** The provider's id for the call. */
104
+ callId: string;
105
+ /** The tenant it is for: its credentials, regions, and budget apply. */
106
+ tenantId?: string;
107
+ /** Aborts the request. */
108
+ signal?: AbortSignal;
109
+ }
79
110
  /** A conference a call joins, created by the first call to join it. */
80
111
  export interface TelephonyConferenceConfig {
81
112
  /** The conference's name: every call that joins the same name meets in it. */
@@ -747,6 +778,13 @@ export interface TelephonyProvider {
747
778
  downloadRecording?(request: DownloadRecordingRequest, context?: ProviderCallContext): Promise<TelephonyRecordingAudio>;
748
779
  /** Deletes a recording at the provider. */
749
780
  deleteRecording?(request: DeleteRecordingRequest, context?: ProviderCallContext): Promise<void>;
781
+ /**
782
+ * Parses what a gather collected, from the webhook that carries it, or returns `undefined` for a
783
+ * body that is not one.
784
+ */
785
+ parseGatherResult?(body: string | URLSearchParams | Record<string, unknown>): TelephonyGatherResult | undefined;
786
+ /** Stops a gather still listening, on a provider whose gather does not end by itself. */
787
+ endGather?(request: EndGatherRequest, context?: ProviderCallContext): Promise<void>;
750
788
  /** Sends a text message. */
751
789
  sendMessage?(request: SendMessageRequest, context?: ProviderCallContext): Promise<TelephonyMessage>;
752
790
  /**
@@ -176,6 +176,12 @@ export interface TraceStore {
176
176
  addFeedback?(runId: string, feedback: RunFeedback): Promise<void> | void;
177
177
  /** Removes runs older than a cutoff, returning how many went. */
178
178
  prune?(before: string): Promise<number> | number;
179
+ /**
180
+ * `false` for a store whose runs live only in this process, such as `MemoryTraceStore`, where a
181
+ * trace written as it runs outlives nothing. Any other store is durable, which 3.0's defaults write to
182
+ * incrementally.
183
+ */
184
+ readonly durable?: boolean;
179
185
  }
180
186
  /**
181
187
  * Receives every finished run a tracer keeps, after redaction, to send somewhere else: an
@@ -2,4 +2,4 @@
2
2
  * This package's version, recorded where provenance matters, such as on every experiment. A test
3
3
  * keeps it equal to `package.json`.
4
4
  */
5
- export declare const NEXUS_VERSION = "2.20.2";
5
+ export declare const NEXUS_VERSION = "2.22.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NEXUS_VERSION = void 0;
4
- exports.NEXUS_VERSION = '2.20.2';
4
+ exports.NEXUS_VERSION = '2.22.0';
@@ -0,0 +1,44 @@
1
+ import type { ProviderCallContext } from '../../types/lifecycle.js';
2
+ import type { SpeechRequest, SpeechResponse, TranscriptionRequest, TranscriptionResponse, VoiceProvider, VoiceProviderInfo } from '../../types/voice.js';
3
+ /** Options for the Gemini voice provider. */
4
+ export interface GoogleVoiceProviderConfig {
5
+ /** Gemini API key, sent as `x-goog-api-key`. */
6
+ apiKey: string;
7
+ /** API base URL. Defaults to `https://generativelanguage.googleapis.com/v1beta`. */
8
+ baseUrl?: string;
9
+ /** The model that transcribes. Defaults to `gemini-3.8-flash`. */
10
+ transcriptionModel?: string;
11
+ /** The model that speaks. Defaults to `gemini-3.8-flash-tts`. */
12
+ speechModel?: string;
13
+ /** Voice used when a request names none, one of Gemini's prebuilt voices. Defaults to `Kore`. */
14
+ defaultVoice?: string;
15
+ /** Headers added to every request. */
16
+ headers?: Record<string, string>;
17
+ /** Replaces the global `fetch`. */
18
+ fetch?: typeof fetch;
19
+ }
20
+ /**
21
+ * Gemini speech-to-text and text-to-speech, through `generateContent`: a text model transcribes audio
22
+ * it hears, and a speech model speaks text in one of Gemini's voices, as WAV or raw PCM. Experimental
23
+ * until a live run is recorded.
24
+ */
25
+ export declare class GoogleVoiceProvider implements VoiceProvider {
26
+ private readonly config;
27
+ /** Always `google`, with transcription and speech. */
28
+ readonly info: VoiceProviderInfo;
29
+ constructor(config: GoogleVoiceProviderConfig);
30
+ /**
31
+ * Transcribes audio: its words, in the language spoken, and nothing else. `language` and `prompt`
32
+ * guide the model; a request for timings is refused, since Gemini's transcript has none.
33
+ */
34
+ transcribe(request: TranscriptionRequest, context?: ProviderCallContext): Promise<TranscriptionResponse>;
35
+ /**
36
+ * Speaks text in one of Gemini's voices, as WAV, the default, or raw 16-bit PCM. `instructions`, and a
37
+ * `speed` other than 1, direct the delivery as a system instruction, never spoken.
38
+ */
39
+ speak(request: SpeechRequest, context?: ProviderCallContext): Promise<SpeechResponse>;
40
+ /** The audio as a part of the request: a Files API URI by reference, anything else read and sent inline. */
41
+ private audioPart;
42
+ private read;
43
+ private generate;
44
+ }