agora-agents 2.6.1 → 2.8.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 (88) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/agentkit/Agent.d.ts +1 -1
  4. package/dist/cjs/agentkit/Agent.js +28 -4
  5. package/dist/cjs/agentkit/AgentSession.d.ts +24 -0
  6. package/dist/cjs/agentkit/AgentSession.js +95 -23
  7. package/dist/cjs/agentkit/debug.d.ts +31 -0
  8. package/dist/cjs/agentkit/debug.js +143 -0
  9. package/dist/cjs/agentkit/index.d.ts +8 -3
  10. package/dist/cjs/agentkit/index.js +19 -3
  11. package/dist/cjs/agentkit/preview/client.d.ts +59 -0
  12. package/dist/cjs/agentkit/preview/client.js +94 -0
  13. package/dist/cjs/agentkit/preview/index.d.ts +12 -0
  14. package/dist/cjs/agentkit/preview/index.js +22 -0
  15. package/dist/cjs/agentkit/preview/vendors.d.ts +74 -0
  16. package/dist/cjs/agentkit/preview/vendors.js +88 -0
  17. package/dist/cjs/agentkit/token.js +32 -3
  18. package/dist/cjs/agentkit/types.d.ts +27 -6
  19. package/dist/cjs/agentkit/vendors/base.d.ts +6 -2
  20. package/dist/cjs/agentkit/vendors/base.js +4 -0
  21. package/dist/cjs/agentkit/vendors/cn.js +7 -5
  22. package/dist/cjs/agentkit/vendors/llm.js +8 -1
  23. package/dist/cjs/agentkit/vendors/stt.d.ts +45 -2
  24. package/dist/cjs/agentkit/vendors/stt.js +53 -5
  25. package/dist/cjs/agentkit/vendors/tts.js +1 -1
  26. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +12 -20
  27. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +1 -1
  28. package/dist/cjs/api/types/Asr.d.ts +4 -1
  29. package/dist/cjs/api/types/GeminiAsr.d.ts +10 -0
  30. package/dist/cjs/api/types/GeminiAsr.js +3 -0
  31. package/dist/cjs/api/types/GeminiAsrParams.d.ts +33 -0
  32. package/dist/cjs/api/types/GeminiAsrParams.js +12 -0
  33. package/dist/cjs/api/types/index.d.ts +2 -0
  34. package/dist/cjs/api/types/index.js +2 -0
  35. package/dist/cjs/index.d.ts +2 -2
  36. package/dist/cjs/index.js +15 -3
  37. package/dist/cjs/version.d.ts +1 -1
  38. package/dist/cjs/version.js +1 -1
  39. package/dist/esm/BaseClient.mjs +2 -2
  40. package/dist/esm/agentkit/Agent.d.mts +1 -1
  41. package/dist/esm/agentkit/Agent.mjs +28 -4
  42. package/dist/esm/agentkit/AgentSession.d.mts +24 -0
  43. package/dist/esm/agentkit/AgentSession.mjs +95 -23
  44. package/dist/esm/agentkit/debug.d.mts +31 -0
  45. package/dist/esm/agentkit/debug.mjs +138 -0
  46. package/dist/esm/agentkit/index.d.mts +8 -3
  47. package/dist/esm/agentkit/index.mjs +4 -1
  48. package/dist/esm/agentkit/preview/client.d.mts +59 -0
  49. package/dist/esm/agentkit/preview/client.mjs +88 -0
  50. package/dist/esm/agentkit/preview/index.d.mts +12 -0
  51. package/dist/esm/agentkit/preview/index.mjs +9 -0
  52. package/dist/esm/agentkit/preview/vendors.d.mts +74 -0
  53. package/dist/esm/agentkit/preview/vendors.mjs +83 -0
  54. package/dist/esm/agentkit/token.mjs +32 -3
  55. package/dist/esm/agentkit/types.d.mts +27 -6
  56. package/dist/esm/agentkit/vendors/base.d.mts +6 -2
  57. package/dist/esm/agentkit/vendors/base.mjs +4 -0
  58. package/dist/esm/agentkit/vendors/cn.mjs +7 -5
  59. package/dist/esm/agentkit/vendors/llm.mjs +8 -1
  60. package/dist/esm/agentkit/vendors/stt.d.mts +45 -2
  61. package/dist/esm/agentkit/vendors/stt.mjs +51 -4
  62. package/dist/esm/agentkit/vendors/tts.mjs +1 -1
  63. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +12 -20
  64. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +1 -1
  65. package/dist/esm/api/types/Asr.d.mts +4 -1
  66. package/dist/esm/api/types/GeminiAsr.d.mts +10 -0
  67. package/dist/esm/api/types/GeminiAsr.mjs +2 -0
  68. package/dist/esm/api/types/GeminiAsrParams.d.mts +33 -0
  69. package/dist/esm/api/types/GeminiAsrParams.mjs +9 -0
  70. package/dist/esm/api/types/index.d.mts +2 -0
  71. package/dist/esm/api/types/index.mjs +2 -0
  72. package/dist/esm/index.d.mts +2 -2
  73. package/dist/esm/index.mjs +4 -4
  74. package/dist/esm/version.d.mts +1 -1
  75. package/dist/esm/version.mjs +1 -1
  76. package/package.json +4 -2
  77. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +0 -1
  78. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +0 -87
  79. package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +0 -1
  80. package/dist/cjs/agentkit/__tests__/readme-examples.test.js +0 -126
  81. package/dist/cjs/agentkit/__tests__/type-safety.test.d.ts +0 -14
  82. package/dist/cjs/agentkit/__tests__/type-safety.test.js +0 -321
  83. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +0 -1
  84. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +0 -85
  85. package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +0 -1
  86. package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +0 -124
  87. package/dist/esm/agentkit/__tests__/type-safety.test.d.mts +0 -14
  88. package/dist/esm/agentkit/__tests__/type-safety.test.mjs +0 -319
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Agora Conversational AI TypeScript SDK
2
2
 
3
- [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FAgoraIO-Conversational-AI%2Fagent-server-sdk-ts)
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FAgoraIO%2Fagora-agents-ts)
4
4
  [![npm shield](https://img.shields.io/npm/v/agora-agents)](https://www.npmjs.com/package/agora-agents)
5
- [![ci](https://github.com/AgoraIO-Conversational-AI/agent-server-sdk-ts/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/AgoraIO-Conversational-AI/agent-server-sdk-ts/actions/workflows/ci.yml)
6
- [![coverage](https://codecov.io/gh/AgoraIO-Conversational-AI/agent-server-sdk-ts/branch/main/graph/badge.svg)](https://codecov.io/gh/AgoraIO-Conversational-AI/agent-server-sdk-ts/branch/main)
5
+ [![ci](https://github.com/AgoraIO/agora-agents-ts/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/AgoraIO/agora-agents-ts/actions/workflows/ci.yml)
6
+ [![coverage](https://codecov.io/gh/AgoraIO/agora-agents-ts/branch/main/graph/badge.svg)](https://codecov.io/gh/AgoraIO/agora-agents-ts/branch/main)
7
7
 
8
8
  The Agora Agents SDK for TypeScript lets you build real-time voice agents on Agora Conversational AI with a high-level `Agent` / `AgentSession` API and a generated REST client.
9
9
 
@@ -41,8 +41,8 @@ function normalizeClientOptions(options) {
41
41
  const headers = (0, headers_js_1.mergeHeaders)({
42
42
  "X-Fern-Language": "JavaScript",
43
43
  "X-Fern-SDK-Name": "agora-agents",
44
- "X-Fern-SDK-Version": "v2.7.0",
45
- "User-Agent": "agora-agents/v2.7.0",
44
+ "X-Fern-SDK-Version": "v2.8.0",
45
+ "User-Agent": "agora-agents/v2.8.0",
46
46
  "X-Fern-Runtime": core.RUNTIME.type,
47
47
  "X-Fern-Runtime-Version": core.RUNTIME.version,
48
48
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -246,7 +246,7 @@ export declare class Agent<TTSSampleRate extends number = number, TArea extends
246
246
  */
247
247
  withAdvancedFeatures(features: AdvancedFeatures): Agent<TTSSampleRate, TArea>;
248
248
  /**
249
- * Returns a new Agent with MCP tool invocation enabled or disabled.
249
+ * Returns a new Agent with MCP and inline REST tool invocation enabled or disabled.
250
250
  */
251
251
  withTools(enabled?: boolean): Agent<TTSSampleRate, TArea>;
252
252
  /**
@@ -11,8 +11,14 @@ exports.Agent = void 0;
11
11
  const index_js_1 = require("../core/domain/index.js");
12
12
  const AgentSession_js_1 = require("./AgentSession.js");
13
13
  const constants_js_1 = require("./constants.js");
14
+ const vendors_js_1 = require("./preview/vendors.js");
14
15
  const token_js_1 = require("./token.js");
15
16
  const DEFAULT_TURN_DETECTION_LANGUAGE = "en-US";
17
+ function toGeneratedMllm(config) {
18
+ // The preview vendor predates its generated schema enum. Keep the assertion at
19
+ // this wire boundary so the public and builder APIs remain accurately typed.
20
+ return config;
21
+ }
16
22
  const INTERACTION_LANGUAGES = new Set([
17
23
  "ar-EG",
18
24
  "ar-JO",
@@ -306,7 +312,7 @@ class Agent {
306
312
  return newAgent;
307
313
  }
308
314
  /**
309
- * Returns a new Agent with MCP tool invocation enabled or disabled.
315
+ * Returns a new Agent with MCP and inline REST tool invocation enabled or disabled.
310
316
  */
311
317
  withTools(enabled = true) {
312
318
  const newAgent = this._clone();
@@ -627,7 +633,7 @@ class Agent {
627
633
  remote_rtc_uids: opts.remoteUids,
628
634
  idle_timeout: opts.idleTimeout,
629
635
  enable_string_uid: opts.enableStringUid,
630
- mllm: this._mllm,
636
+ mllm: toGeneratedMllm(this._mllm),
631
637
  interruption: this._interruption,
632
638
  sal: this._sal,
633
639
  avatar: this._avatar,
@@ -639,10 +645,11 @@ class Agent {
639
645
  filler_words: this._fillerWords,
640
646
  };
641
647
  if (isMllmMode) {
642
- const mllmConfig = this._mllm ? Object.assign({}, this._mllm) : undefined;
648
+ const mllmConfig = toGeneratedMllm(this._mllm ? Object.assign({}, this._mllm) : undefined);
643
649
  if (mllmConfig) {
644
650
  // Vendor config wins: only apply agent-level values when the vendor hasn't already set them.
645
651
  // Consistent with Python (setdefault) and Go (!exists) semantics.
652
+ //
646
653
  const c = mllmConfig;
647
654
  if (this._greeting !== undefined && c.greeting_message === undefined) {
648
655
  c.greeting_message = this._greeting;
@@ -651,7 +658,14 @@ class Agent {
651
658
  c.failure_message = this._failureMessage;
652
659
  }
653
660
  }
654
- return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
661
+ const isOpenAIGPTLive = (0, vendors_js_1.isOpenAIGPTLiveConfig)(mllmConfig);
662
+ if (isOpenAIGPTLive && this._turnDetection !== undefined) {
663
+ console.warn("GPT Live v3 ignores agent-level turn_detection; endpointing is internal");
664
+ }
665
+ return Object.assign(Object.assign(Object.assign({}, base), { mllm: mllmConfig }), (!isOpenAIGPTLive &&
666
+ this._turnDetection !== undefined && {
667
+ turn_detection: this._turnDetection,
668
+ }));
655
669
  }
656
670
  const skipCategories = new Set((_c = opts.skipVendorValidationCategories) !== null && _c !== void 0 ? _c : []);
657
671
  const allowMissingCategories = new Set((_d = opts.allowMissingVendorCategories) !== null && _d !== void 0 ? _d : []);
@@ -724,6 +738,16 @@ class Agent {
724
738
  : {
725
739
  vendor: this._client.area === index_js_1.Area.CN ? "fengming" : "ares",
726
740
  };
741
+ if (asrConfig.vendor === "gemini" && asrConfig.params !== undefined) {
742
+ const params = Object.assign({}, asrConfig.params);
743
+ if (params.language_hints === undefined && params.language_codes !== undefined) {
744
+ params.language_hints = params.language_codes;
745
+ }
746
+ delete params.language_codes;
747
+ asrConfig.params = params;
748
+ }
749
+ // Turn detection is the single source of truth for the top-level
750
+ // interaction language. Provider-specific languages remain in params.
727
751
  asrConfig.language = turnDetectionConfig.language;
728
752
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
729
753
  }
@@ -113,11 +113,16 @@ export declare class AgentSession {
113
113
  private readonly _expiresIn?;
114
114
  private readonly _debug?;
115
115
  private readonly _authMode;
116
+ private _agentsClient;
117
+ private _agentManagementClient;
118
+ private _previewFeatures;
119
+ private _sessionBaseUrl?;
116
120
  private _agentId;
117
121
  private _status;
118
122
  private _eventHandlers;
119
123
  private readonly _warn;
120
124
  constructor(options: AgentSessionOptions);
125
+ private _clientCurrentUrl;
121
126
  /**
122
127
  * Builds per-request headers for app-credentials auth mode.
123
128
  *
@@ -127,6 +132,16 @@ export declare class AgentSession {
127
132
  * Returns undefined for basic and pre-built-token modes (the client handles those).
128
133
  */
129
134
  private _convoAIHeaders;
135
+ /** Auth plus the route gate, with the gate pinned last. */
136
+ private _requestHeaders;
137
+ /**
138
+ * Client-level default headers, for debug logging only.
139
+ *
140
+ * Reaches into `_options` the same way `authMode` is read in the constructor;
141
+ * supplier-valued headers are skipped rather than resolved, since debug
142
+ * logging must not trigger side effects.
143
+ */
144
+ private _clientDefaultHeaders;
130
145
  /**
131
146
  * The current agent ID (null if not started).
132
147
  */
@@ -171,6 +186,15 @@ export declare class AgentSession {
171
186
  * Returns true when the agent is configured for MLLM (multimodal end-to-end audio).
172
187
  */
173
188
  private _isMllmMode;
189
+ /**
190
+ * Warns when agent-level `instructions` would be silently discarded.
191
+ *
192
+ * `instructions` is only serialized into `llm.system_messages`, which does
193
+ * not exist in an MLLM pipeline — the Go and Python SDKs drop it the same
194
+ * way. Without this warning the agent starts with no system prompt at all
195
+ * and the only symptom is off-persona replies.
196
+ */
197
+ private _warnOnDroppedMllmInstructions;
174
198
  /**
175
199
  * Validates avatar and TTS configuration before starting.
176
200
  *
@@ -18,7 +18,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.AgentSession = void 0;
19
19
  const index_js_1 = require("../errors/index.js");
20
20
  const avatar_types_js_1 = require("./avatar-types.js");
21
+ const debug_js_1 = require("./debug.js");
21
22
  const presets_js_1 = require("./presets.js");
23
+ const client_js_1 = require("./preview/client.js");
22
24
  const token_js_1 = require("./token.js");
23
25
  /**
24
26
  * AgentSession class for managing agent lifecycle and interactions.
@@ -56,6 +58,7 @@ const token_js_1 = require("./token.js");
56
58
  class AgentSession {
57
59
  constructor(options) {
58
60
  var _a, _b;
61
+ this._previewFeatures = [];
59
62
  this._agentId = null;
60
63
  this._status = "idle";
61
64
  this._eventHandlers = new Map();
@@ -77,6 +80,13 @@ class AgentSession {
77
80
  this._warn = (_a = options.warn) !== null && _a !== void 0 ? _a : ((msg) => console.warn(msg));
78
81
  // Read authMode from pool client if available, else fall back to basic
79
82
  this._authMode = (_b = options.client.authMode) !== null && _b !== void 0 ? _b : "basic";
83
+ this._agentsClient = options.client.agents;
84
+ this._agentManagementClient = options.client.agentManagement;
85
+ this._sessionBaseUrl = this._clientCurrentUrl();
86
+ }
87
+ _clientCurrentUrl() {
88
+ const getCurrentURL = this._client.getCurrentURL;
89
+ return typeof getCurrentURL === "function" ? getCurrentURL.call(this._client) : undefined;
80
90
  }
81
91
  /**
82
92
  * Builds per-request headers for app-credentials auth mode.
@@ -102,6 +112,35 @@ class AgentSession {
102
112
  });
103
113
  return { Authorization: `agora token=${token}` };
104
114
  }
115
+ /** Auth plus the route gate, with the gate pinned last. */
116
+ _requestHeaders() {
117
+ const headers = this._convoAIHeaders();
118
+ return this._previewFeatures.length > 0 ? (0, client_js_1.previewRequestHeaders)(this._previewFeatures, headers) : headers;
119
+ }
120
+ /**
121
+ * Client-level default headers, for debug logging only.
122
+ *
123
+ * Reaches into `_options` the same way `authMode` is read in the constructor;
124
+ * supplier-valued headers are skipped rather than resolved, since debug
125
+ * logging must not trigger side effects.
126
+ */
127
+ _clientDefaultHeaders() {
128
+ var _a;
129
+ const headers = (_a = this._client._options) === null || _a === void 0 ? void 0 : _a.headers;
130
+ if (!headers) {
131
+ return {};
132
+ }
133
+ const result = {};
134
+ for (const [key, value] of Object.entries(headers)) {
135
+ if (typeof value === "string") {
136
+ result[key] = value;
137
+ }
138
+ }
139
+ if (this._previewFeatures.length > 0) {
140
+ return (0, client_js_1.previewRequestHeaders)(this._previewFeatures, result);
141
+ }
142
+ return result;
143
+ }
105
144
  /**
106
145
  * The current agent ID (null if not started).
107
146
  */
@@ -146,13 +185,13 @@ class AgentSession {
146
185
  * ```
147
186
  */
148
187
  get raw() {
149
- return this._client.agents;
188
+ return this._agentsClient;
150
189
  }
151
190
  /**
152
191
  * Direct access to the underlying Fern-generated AgentManagement client.
153
192
  */
154
193
  get rawAgentManagement() {
155
- return this._client.agentManagement;
194
+ return this._agentManagementClient;
156
195
  }
157
196
  /**
158
197
  * Returns true when the agent is configured for MLLM (multimodal end-to-end audio).
@@ -164,6 +203,26 @@ class AgentSession {
164
203
  }
165
204
  return mllm !== undefined;
166
205
  }
206
+ /**
207
+ * Warns when agent-level `instructions` would be silently discarded.
208
+ *
209
+ * `instructions` is only serialized into `llm.system_messages`, which does
210
+ * not exist in an MLLM pipeline — the Go and Python SDKs drop it the same
211
+ * way. Without this warning the agent starts with no system prompt at all
212
+ * and the only symptom is off-persona replies.
213
+ */
214
+ _warnOnDroppedMllmInstructions() {
215
+ var _a;
216
+ if (!this._isMllmMode() || this._agent.instructions === undefined) {
217
+ return;
218
+ }
219
+ const params = (_a = this._agent.mllm) === null || _a === void 0 ? void 0 : _a.params;
220
+ if (typeof (params === null || params === void 0 ? void 0 : params.instructions) === "string" && params.instructions.length > 0) {
221
+ return;
222
+ }
223
+ this._warn("Warning: agent-level `instructions` is ignored in MLLM mode and this agent will start with no " +
224
+ "system prompt. Pass `instructions` to the MLLM vendor instead (it serializes to mllm.params.instructions).");
225
+ }
167
226
  /**
168
227
  * Validates avatar and TTS configuration before starting.
169
228
  *
@@ -347,6 +406,7 @@ class AgentSession {
347
406
  }
348
407
  // Validate avatar configuration before starting
349
408
  this._validateAvatarConfig();
409
+ this._warnOnDroppedMllmInstructions();
350
410
  // Validate that we can generate a token if one is not provided
351
411
  if (!this._token && !this._appCertificate) {
352
412
  throw new Error("Cannot auto-generate RTC token: appCertificate is required when a pre-built token is not provided. " +
@@ -376,6 +436,18 @@ class AgentSession {
376
436
  });
377
437
  const enrichedProperties = this._enrichAvatarParams(resolved.properties, expiresIn);
378
438
  this._validateEnrichedAvatarConfig(enrichedProperties);
439
+ this._previewFeatures = (0, client_js_1.requiredPreviewFeatures)(enrichedProperties);
440
+ if (this._previewFeatures.length > 0) {
441
+ const route = (0, client_js_1.createPreviewRoute)(this._client, this._previewFeatures);
442
+ this._agentsClient = route.agents;
443
+ this._agentManagementClient = route.agentManagement;
444
+ this._sessionBaseUrl = route.baseUrl;
445
+ }
446
+ else {
447
+ this._agentsClient = this._client.agents;
448
+ this._agentManagementClient = this._client.agentManagement;
449
+ this._sessionBaseUrl = this._clientCurrentUrl();
450
+ }
379
451
  const request = {
380
452
  appid: this._appId,
381
453
  name: this._name,
@@ -383,14 +455,14 @@ class AgentSession {
383
455
  pipeline_id: pipelineId,
384
456
  properties: enrichedProperties,
385
457
  };
458
+ const requestHeaders = this._requestHeaders();
386
459
  if (this._debug) {
387
460
  console.log("[Agora Debug] Starting agent session...");
388
- if ("getCurrentURL" in this._client && typeof this._client.getCurrentURL === "function") {
389
- console.log("[Agora Debug] API Endpoint:", this._client.getCurrentURL());
390
- }
391
- console.log("[Agora Debug] Request:", JSON.stringify(request, null, 2));
461
+ console.log("[Agora Debug] API Endpoint:", this._sessionBaseUrl);
462
+ console.log("[Agora Debug] Headers:", JSON.stringify((0, debug_js_1.redactHeadersForDebug)(Object.assign(Object.assign({}, this._clientDefaultHeaders()), requestHeaders)), null, 2));
463
+ console.log("[Agora Debug] Request:", JSON.stringify((0, debug_js_1.redactSecrets)(request), null, 2));
392
464
  }
393
- const response = yield this._client.agents.start(request, { headers: this._convoAIHeaders() });
465
+ const response = yield this._agentsClient.start(request, { headers: requestHeaders });
394
466
  this._agentId = (_b = response.agent_id) !== null && _b !== void 0 ? _b : null;
395
467
  this._status = "running";
396
468
  this._emit("started", { agentId: this._agentId });
@@ -419,10 +491,10 @@ class AgentSession {
419
491
  }
420
492
  this._status = "stopping";
421
493
  try {
422
- yield this._client.agents.stop({
494
+ yield this._agentsClient.stop({
423
495
  appid: this._appId,
424
496
  agentId: this._agentId,
425
- }, { headers: this._convoAIHeaders() });
497
+ }, { headers: this._requestHeaders() });
426
498
  this._status = "stopped";
427
499
  this._emit("stopped", { agentId: this._agentId });
428
500
  }
@@ -453,13 +525,13 @@ class AgentSession {
453
525
  if (!this._agentId) {
454
526
  throw new Error("No agent ID available");
455
527
  }
456
- yield this._client.agents.speak({
528
+ yield this._agentsClient.speak({
457
529
  appid: this._appId,
458
530
  agentId: this._agentId,
459
531
  text,
460
532
  priority: options === null || options === void 0 ? void 0 : options.priority,
461
533
  interruptable: options === null || options === void 0 ? void 0 : options.interruptable,
462
- }, { headers: this._convoAIHeaders() });
534
+ }, { headers: this._requestHeaders() });
463
535
  });
464
536
  }
465
537
  /**
@@ -473,10 +545,10 @@ class AgentSession {
473
545
  if (!this._agentId) {
474
546
  throw new Error("No agent ID available");
475
547
  }
476
- yield this._client.agents.interrupt({
548
+ yield this._agentsClient.interrupt({
477
549
  appid: this._appId,
478
550
  agentId: this._agentId,
479
- }, { headers: this._convoAIHeaders() });
551
+ }, { headers: this._requestHeaders() });
480
552
  });
481
553
  }
482
554
  /**
@@ -490,7 +562,7 @@ class AgentSession {
490
562
  if (!this._agentId) {
491
563
  throw new Error("No agent ID available");
492
564
  }
493
- return this._client.agentManagement.agentThink({
565
+ return this._agentManagementClient.agentThink({
494
566
  appid: this._appId,
495
567
  agentId: this._agentId,
496
568
  text,
@@ -499,7 +571,7 @@ class AgentSession {
499
571
  on_speaking_action: options === null || options === void 0 ? void 0 : options.on_speaking_action,
500
572
  interruptable: options === null || options === void 0 ? void 0 : options.interruptable,
501
573
  metadata: options === null || options === void 0 ? void 0 : options.metadata,
502
- }, { headers: this._convoAIHeaders() });
574
+ }, { headers: this._requestHeaders() });
503
575
  });
504
576
  }
505
577
  /**
@@ -515,11 +587,11 @@ class AgentSession {
515
587
  if (!this._agentId) {
516
588
  throw new Error("No agent ID available");
517
589
  }
518
- yield this._client.agents.update({
590
+ yield this._agentsClient.update({
519
591
  appid: this._appId,
520
592
  agentId: this._agentId,
521
593
  properties: config,
522
- }, { headers: this._convoAIHeaders() });
594
+ }, { headers: this._requestHeaders() });
523
595
  });
524
596
  }
525
597
  /**
@@ -532,10 +604,10 @@ class AgentSession {
532
604
  if (!this._agentId) {
533
605
  throw new Error("No agent ID available");
534
606
  }
535
- return this._client.agents.getHistory({
607
+ return this._agentsClient.getHistory({
536
608
  appid: this._appId,
537
609
  agentId: this._agentId,
538
- }, { headers: this._convoAIHeaders() });
610
+ }, { headers: this._requestHeaders() });
539
611
  });
540
612
  }
541
613
  /**
@@ -548,12 +620,12 @@ class AgentSession {
548
620
  if (!this._agentId) {
549
621
  throw new Error("No agent ID available");
550
622
  }
551
- return this._client.agents.getTurns({
623
+ return this._agentsClient.getTurns({
552
624
  appid: this._appId,
553
625
  agentId: this._agentId,
554
626
  page_index: options === null || options === void 0 ? void 0 : options.page_index,
555
627
  page_size: options === null || options === void 0 ? void 0 : options.page_size,
556
- }, { headers: this._convoAIHeaders() });
628
+ }, { headers: this._requestHeaders() });
557
629
  });
558
630
  }
559
631
  /**
@@ -608,10 +680,10 @@ class AgentSession {
608
680
  if (!this._agentId) {
609
681
  throw new Error("No agent ID available");
610
682
  }
611
- return this._client.agents.get({
683
+ return this._agentsClient.get({
612
684
  appid: this._appId,
613
685
  agentId: this._agentId,
614
- }, { headers: this._convoAIHeaders() });
686
+ }, { headers: this._requestHeaders() });
615
687
  });
616
688
  }
617
689
  /**
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Redaction for `debug: true` session logging.
3
+ *
4
+ * The debug dump is routinely pasted into issues and chat threads, so it must
5
+ * never carry a usable credential. The generated fetcher redacts headers, query
6
+ * params, and URLs, but nothing redacts the request body — which is where
7
+ * vendor API keys and RTC tokens live.
8
+ *
9
+ * Uses the same `[REDACTED]` marker as `core/fetcher/Fetcher.ts` for
10
+ * consistency, but is deliberately independent of it: that file is generated by
11
+ * Fern and its helpers are module-local.
12
+ */
13
+ /** Marker substituted for a redacted value. Matches the generated fetcher. */
14
+ export declare const REDACTED = "[REDACTED]";
15
+ /**
16
+ * Deep-copies `value`, replacing credential fields with {@link REDACTED}.
17
+ *
18
+ * Empty strings are left visible on purpose: `""` is the signature of an unset
19
+ * environment variable, and hiding it behind `[REDACTED]` would disguise the
20
+ * exact misconfiguration the debug output exists to surface.
21
+ *
22
+ * Never mutates the input — the request that goes on the wire is untouched.
23
+ */
24
+ export declare function redactSecrets(value: unknown): unknown;
25
+ /**
26
+ * Redacts request headers for debug logging.
27
+ *
28
+ * Non-authorization headers are kept. The authorization credential is removed,
29
+ * while its scheme name stays visible so the active auth mode can be diagnosed.
30
+ */
31
+ export declare function redactHeadersForDebug(headers: Record<string, string>): Record<string, string>;
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * Redaction for `debug: true` session logging.
4
+ *
5
+ * The debug dump is routinely pasted into issues and chat threads, so it must
6
+ * never carry a usable credential. The generated fetcher redacts headers, query
7
+ * params, and URLs, but nothing redacts the request body — which is where
8
+ * vendor API keys and RTC tokens live.
9
+ *
10
+ * Uses the same `[REDACTED]` marker as `core/fetcher/Fetcher.ts` for
11
+ * consistency, but is deliberately independent of it: that file is generated by
12
+ * Fern and its helpers are module-local.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.REDACTED = void 0;
16
+ exports.redactSecrets = redactSecrets;
17
+ exports.redactHeadersForDebug = redactHeadersForDebug;
18
+ /** Marker substituted for a redacted value. Matches the generated fetcher. */
19
+ exports.REDACTED = "[REDACTED]";
20
+ /**
21
+ * Body fields whose values are credentials or account identifiers.
22
+ *
23
+ * Compared case-insensitively, and matched on both snake_case and camelCase
24
+ * spellings so this keeps working if a caller hand-builds a config.
25
+ */
26
+ const SENSITIVE_BODY_KEYS = new Set([
27
+ // Vendor credentials
28
+ "api_key",
29
+ "apikey",
30
+ "key",
31
+ "secret",
32
+ "api_secret",
33
+ "apisecret",
34
+ "password",
35
+ "access_key_id",
36
+ "accesskeyid",
37
+ "secret_access_key",
38
+ "secretaccesskey",
39
+ "adc_credentials_string",
40
+ "adccredentialsstring",
41
+ "credentials",
42
+ "subscription_key",
43
+ "subscriptionkey",
44
+ // Agora credentials and account identifiers
45
+ "token",
46
+ "agora_token",
47
+ "agoratoken",
48
+ "authorization",
49
+ "headers",
50
+ "x-api-key",
51
+ "cookie",
52
+ "set-cookie",
53
+ "appid",
54
+ "app_id",
55
+ "agora_appid",
56
+ "agoraappid",
57
+ "app_certificate",
58
+ "appcertificate",
59
+ "customer_secret",
60
+ "customersecret",
61
+ ]);
62
+ function isSensitiveKey(key) {
63
+ return SENSITIVE_BODY_KEYS.has(key.toLowerCase());
64
+ }
65
+ function redactQueryKeys(value) {
66
+ let parsed;
67
+ try {
68
+ parsed = new URL(value);
69
+ }
70
+ catch (_a) {
71
+ return value;
72
+ }
73
+ let changed = false;
74
+ for (const key of [...parsed.searchParams.keys()]) {
75
+ if (!isSensitiveKey(key)) {
76
+ continue;
77
+ }
78
+ const current = parsed.searchParams.getAll(key);
79
+ if (current.some((item) => item.length > 0)) {
80
+ parsed.searchParams.delete(key);
81
+ for (const item of current) {
82
+ parsed.searchParams.append(key, item.length > 0 ? exports.REDACTED : item);
83
+ }
84
+ changed = true;
85
+ }
86
+ }
87
+ return changed ? parsed.toString() : value;
88
+ }
89
+ /**
90
+ * Deep-copies `value`, replacing credential fields with {@link REDACTED}.
91
+ *
92
+ * Empty strings are left visible on purpose: `""` is the signature of an unset
93
+ * environment variable, and hiding it behind `[REDACTED]` would disguise the
94
+ * exact misconfiguration the debug output exists to surface.
95
+ *
96
+ * Never mutates the input — the request that goes on the wire is untouched.
97
+ */
98
+ function redactSecrets(value) {
99
+ if (Array.isArray(value)) {
100
+ return value.map((item) => redactSecrets(item));
101
+ }
102
+ if (value === null || typeof value !== "object") {
103
+ return value;
104
+ }
105
+ const result = {};
106
+ for (const [key, item] of Object.entries(value)) {
107
+ if (isSensitiveKey(key) && typeof item === "string" && item.length > 0) {
108
+ result[key] = exports.REDACTED;
109
+ }
110
+ else if (typeof item === "string") {
111
+ result[key] = redactQueryKeys(item);
112
+ }
113
+ else {
114
+ result[key] = redactSecrets(item);
115
+ }
116
+ }
117
+ return result;
118
+ }
119
+ /**
120
+ * Redacts request headers for debug logging.
121
+ *
122
+ * Non-authorization headers are kept. The authorization credential is removed,
123
+ * while its scheme name stays visible so the active auth mode can be diagnosed.
124
+ */
125
+ function redactHeadersForDebug(headers) {
126
+ const result = {};
127
+ for (const [key, value] of Object.entries(headers)) {
128
+ const normalized = key.toLowerCase();
129
+ const sensitive = isSensitiveKey(normalized) ||
130
+ ["authorization", "api-key", "api_key", "token", "secret", "credential", "cookie"].some((marker) => normalized.includes(marker));
131
+ if (!sensitive || value.length === 0) {
132
+ result[key] = value;
133
+ continue;
134
+ }
135
+ if (normalized !== "authorization") {
136
+ result[key] = exports.REDACTED;
137
+ continue;
138
+ }
139
+ const scheme = value.split(/[\s=]/, 1)[0];
140
+ result[key] = scheme && scheme !== value ? `${scheme} ${exports.REDACTED}` : exports.REDACTED;
141
+ }
142
+ return result;
143
+ }
@@ -26,12 +26,17 @@ export { AgentSession } from "./AgentSession.js";
26
26
  export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, SensetimeAvatarConfig, SpatiusAvatarConfig, StrictAvatarConfig, } from "./avatar-types.js";
27
27
  export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.js";
28
28
  export { AudioScenario, CredentialMode, DataChannel, FillerWordsSelectionRule, Geofence, InterruptionDisabledStrategy, InterruptionDisabledStrategyAppend, InterruptionDisabledStrategyIgnore, InterruptionModeKeywords, InterruptionModeStartOfSpeech, InterruptionModeValues, MllmTurnDetectionModeAgoraVad, MllmTurnDetectionModeSemanticVad, MllmTurnDetectionModeServerVad, MllmTurnDetectionModeValues, SalModeValues, SilenceActionValues, SpeakPriorityAppend, SpeakPriorityIgnore, SpeakPriorityInterrupt, SpeakPriorityValues, ThinkOnListeningActionIgnore, ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnSpeakingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnThinkingActionInterrupt, TurnDetectionTypeValues, } from "./constants.js";
29
+ export { REDACTED, redactHeadersForDebug, redactSecrets } from "./debug.js";
29
30
  export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetCategory, PresetInput, TtsPreset, } from "./presets.js";
30
31
  export { AgentPresets, normalizePresetInput } from "./presets.js";
32
+ export type { PreviewFeature, PreviewRoute } from "./preview/client.js";
33
+ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/client.js";
34
+ export type { OpenAIGPTLiveOptions } from "./preview/vendors.js";
35
+ export { OpenAIGPTLive } from "./preview/vendors.js";
31
36
  export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.js";
32
37
  export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.js";
33
38
  export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.js";
34
- export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AsrVendorName, AvatarConfig, AvatarWireVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GenericTts, GenericTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, GradiumTts, GradiumTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MistralTts, MistralTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SpatiusAvatarParams, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, TypecastTts, TypecastTtsParams, XAiAsr, XAiAsrParams, XAiTts, XAiTtsParams, } from "./types.js";
39
+ export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AmazonTts, AmazonTtsParams, AsrConfig, AsrVendorName, AvatarConfig, AvatarWireVendor, CartesiaTts, CartesiaTtsParams, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, Eagerness, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FillerWordsConfig, FillerWordsContent, FillerWordsContentGeneratedConfig, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsGeneratedLlmProvider, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTts, FishAudioTtsParams, GeminiAsrParams, GenericTts, GenericTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GoogleTts, GoogleTtsParams, GradiumTts, GradiumTtsParams, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmStyle, LlmTool, LlmToolExecution, LlmToolFunction, LlmToolServer, McpServersItem, MicrosoftTts, MicrosoftTtsParams, MinimaxTts, MinimaxTtsParams, MistralTts, MistralTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTts, MurfTtsParams, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, RimeTts, RimeTtsParams, RtcConfig, SalConfig, SalMode, SarvamTts, SarvamTtsParams, SayOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SpatiusAvatarParams, SpeakPriority, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, SttConfig, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, TypecastTts, TypecastTtsParams, XAiAsr, XAiAsrParams, XAiTts, XAiTtsParams, } from "./types.js";
35
40
  export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.js";
36
41
  export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.js";
37
42
  export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.js";
@@ -42,7 +47,7 @@ export type { AmazonBedrockOptions, AnthropicOptions, AzureOpenAIOptions, Custom
42
47
  export { AmazonBedrock, Anthropic, AzureOpenAI, CustomLLM, Dify, Gemini, Groq, OpenAI, VertexAILLM, } from "./vendors/llm.js";
43
48
  export type { AzureOpenAIRealtimeOptions, AzureOpenAIRealtimeParams, GeminiLiveOptions, OpenAIRealtimeOptions, QwenOmniOptions, VertexAIOptions, XaiGrokOptions, } from "./vendors/mllm.js";
44
49
  export { AzureOpenAIRealtime, GeminiLive, OpenAIRealtime, QwenOmni, VertexAI, XaiGrok, } from "./vendors/mllm.js";
45
- export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, XAiSTTOptions, } from "./vendors/stt.js";
46
- export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.js";
50
+ export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GeminiSTTModel, GeminiSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, XAiSTTOptions, } from "./vendors/stt.js";
51
+ export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.js";
47
52
  export type { AmazonTTSOptions, CartesiaTTSOptions, DeepgramTTSOptions, ElevenLabsTTSOptions, FishAudioTTSOptions, GenericTTSOptions, GoogleTTSOptions, GradiumTTSOptions, HumeAITTSOptions, MicrosoftTTSOptions, MiniMaxTTSOptions, MistralTTSOptions, MurfTTSOptions, OpenAITTSOptions, RimeTTSOptions, SarvamTTSOptions, TypecastTTSOptions, XAiTTSOptions, } from "./vendors/tts.js";
48
53
  export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GenericTTS, GoogleTTS, GradiumTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MistralTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, TypecastTTS, XAiTTS, } from "./vendors/tts.js";