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
@@ -8,8 +8,14 @@
8
8
  import { Area } from "../core/domain/index.mjs";
9
9
  import { AgentSession } from "./AgentSession.mjs";
10
10
  import { AudioScenario } from "./constants.mjs";
11
+ import { isOpenAIGPTLiveConfig } from "./preview/vendors.mjs";
11
12
  import { generateConvoAIToken } from "./token.mjs";
12
13
  const DEFAULT_TURN_DETECTION_LANGUAGE = "en-US";
14
+ function toGeneratedMllm(config) {
15
+ // The preview vendor predates its generated schema enum. Keep the assertion at
16
+ // this wire boundary so the public and builder APIs remain accurately typed.
17
+ return config;
18
+ }
13
19
  const INTERACTION_LANGUAGES = new Set([
14
20
  "ar-EG",
15
21
  "ar-JO",
@@ -303,7 +309,7 @@ export class Agent {
303
309
  return newAgent;
304
310
  }
305
311
  /**
306
- * Returns a new Agent with MCP tool invocation enabled or disabled.
312
+ * Returns a new Agent with MCP and inline REST tool invocation enabled or disabled.
307
313
  */
308
314
  withTools(enabled = true) {
309
315
  const newAgent = this._clone();
@@ -624,7 +630,7 @@ export class Agent {
624
630
  remote_rtc_uids: opts.remoteUids,
625
631
  idle_timeout: opts.idleTimeout,
626
632
  enable_string_uid: opts.enableStringUid,
627
- mllm: this._mllm,
633
+ mllm: toGeneratedMllm(this._mllm),
628
634
  interruption: this._interruption,
629
635
  sal: this._sal,
630
636
  avatar: this._avatar,
@@ -636,10 +642,11 @@ export class Agent {
636
642
  filler_words: this._fillerWords,
637
643
  };
638
644
  if (isMllmMode) {
639
- const mllmConfig = this._mllm ? Object.assign({}, this._mllm) : undefined;
645
+ const mllmConfig = toGeneratedMllm(this._mllm ? Object.assign({}, this._mllm) : undefined);
640
646
  if (mllmConfig) {
641
647
  // Vendor config wins: only apply agent-level values when the vendor hasn't already set them.
642
648
  // Consistent with Python (setdefault) and Go (!exists) semantics.
649
+ //
643
650
  const c = mllmConfig;
644
651
  if (this._greeting !== undefined && c.greeting_message === undefined) {
645
652
  c.greeting_message = this._greeting;
@@ -648,7 +655,14 @@ export class Agent {
648
655
  c.failure_message = this._failureMessage;
649
656
  }
650
657
  }
651
- return Object.assign(Object.assign({}, base), { mllm: mllmConfig, turn_detection: this._turnDetection });
658
+ const isOpenAIGPTLive = isOpenAIGPTLiveConfig(mllmConfig);
659
+ if (isOpenAIGPTLive && this._turnDetection !== undefined) {
660
+ console.warn("GPT Live v3 ignores agent-level turn_detection; endpointing is internal");
661
+ }
662
+ return Object.assign(Object.assign(Object.assign({}, base), { mllm: mllmConfig }), (!isOpenAIGPTLive &&
663
+ this._turnDetection !== undefined && {
664
+ turn_detection: this._turnDetection,
665
+ }));
652
666
  }
653
667
  const skipCategories = new Set((_c = opts.skipVendorValidationCategories) !== null && _c !== void 0 ? _c : []);
654
668
  const allowMissingCategories = new Set((_d = opts.allowMissingVendorCategories) !== null && _d !== void 0 ? _d : []);
@@ -721,6 +735,16 @@ export class Agent {
721
735
  : {
722
736
  vendor: this._client.area === Area.CN ? "fengming" : "ares",
723
737
  };
738
+ if (asrConfig.vendor === "gemini" && asrConfig.params !== undefined) {
739
+ const params = Object.assign({}, asrConfig.params);
740
+ if (params.language_hints === undefined && params.language_codes !== undefined) {
741
+ params.language_hints = params.language_codes;
742
+ }
743
+ delete params.language_codes;
744
+ asrConfig.params = params;
745
+ }
746
+ // Turn detection is the single source of truth for the top-level
747
+ // interaction language. Provider-specific languages remain in params.
724
748
  asrConfig.language = turnDetectionConfig.language;
725
749
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
726
750
  }
@@ -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
  *
@@ -15,7 +15,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
15
15
  };
16
16
  import { AgoraError } from "../errors/index.mjs";
17
17
  import { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
18
+ import { redactHeadersForDebug, redactSecrets } from "./debug.mjs";
18
19
  import { getPresetCategory, inferAsrPreset, inferLlmPreset, inferTtsPreset, normalizePresetInput, resolveSessionPresets, } from "./presets.mjs";
20
+ import { createPreviewRoute, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/client.mjs";
19
21
  import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs";
20
22
  /**
21
23
  * AgentSession class for managing agent lifecycle and interactions.
@@ -53,6 +55,7 @@ import { ExpiresIn as ExpiresInHelper, generateConvoAIToken } from "./token.mjs"
53
55
  export class AgentSession {
54
56
  constructor(options) {
55
57
  var _a, _b;
58
+ this._previewFeatures = [];
56
59
  this._agentId = null;
57
60
  this._status = "idle";
58
61
  this._eventHandlers = new Map();
@@ -74,6 +77,13 @@ export class AgentSession {
74
77
  this._warn = (_a = options.warn) !== null && _a !== void 0 ? _a : ((msg) => console.warn(msg));
75
78
  // Read authMode from pool client if available, else fall back to basic
76
79
  this._authMode = (_b = options.client.authMode) !== null && _b !== void 0 ? _b : "basic";
80
+ this._agentsClient = options.client.agents;
81
+ this._agentManagementClient = options.client.agentManagement;
82
+ this._sessionBaseUrl = this._clientCurrentUrl();
83
+ }
84
+ _clientCurrentUrl() {
85
+ const getCurrentURL = this._client.getCurrentURL;
86
+ return typeof getCurrentURL === "function" ? getCurrentURL.call(this._client) : undefined;
77
87
  }
78
88
  /**
79
89
  * Builds per-request headers for app-credentials auth mode.
@@ -99,6 +109,35 @@ export class AgentSession {
99
109
  });
100
110
  return { Authorization: `agora token=${token}` };
101
111
  }
112
+ /** Auth plus the route gate, with the gate pinned last. */
113
+ _requestHeaders() {
114
+ const headers = this._convoAIHeaders();
115
+ return this._previewFeatures.length > 0 ? previewRequestHeaders(this._previewFeatures, headers) : headers;
116
+ }
117
+ /**
118
+ * Client-level default headers, for debug logging only.
119
+ *
120
+ * Reaches into `_options` the same way `authMode` is read in the constructor;
121
+ * supplier-valued headers are skipped rather than resolved, since debug
122
+ * logging must not trigger side effects.
123
+ */
124
+ _clientDefaultHeaders() {
125
+ var _a;
126
+ const headers = (_a = this._client._options) === null || _a === void 0 ? void 0 : _a.headers;
127
+ if (!headers) {
128
+ return {};
129
+ }
130
+ const result = {};
131
+ for (const [key, value] of Object.entries(headers)) {
132
+ if (typeof value === "string") {
133
+ result[key] = value;
134
+ }
135
+ }
136
+ if (this._previewFeatures.length > 0) {
137
+ return previewRequestHeaders(this._previewFeatures, result);
138
+ }
139
+ return result;
140
+ }
102
141
  /**
103
142
  * The current agent ID (null if not started).
104
143
  */
@@ -143,13 +182,13 @@ export class AgentSession {
143
182
  * ```
144
183
  */
145
184
  get raw() {
146
- return this._client.agents;
185
+ return this._agentsClient;
147
186
  }
148
187
  /**
149
188
  * Direct access to the underlying Fern-generated AgentManagement client.
150
189
  */
151
190
  get rawAgentManagement() {
152
- return this._client.agentManagement;
191
+ return this._agentManagementClient;
153
192
  }
154
193
  /**
155
194
  * Returns true when the agent is configured for MLLM (multimodal end-to-end audio).
@@ -161,6 +200,26 @@ export class AgentSession {
161
200
  }
162
201
  return mllm !== undefined;
163
202
  }
203
+ /**
204
+ * Warns when agent-level `instructions` would be silently discarded.
205
+ *
206
+ * `instructions` is only serialized into `llm.system_messages`, which does
207
+ * not exist in an MLLM pipeline — the Go and Python SDKs drop it the same
208
+ * way. Without this warning the agent starts with no system prompt at all
209
+ * and the only symptom is off-persona replies.
210
+ */
211
+ _warnOnDroppedMllmInstructions() {
212
+ var _a;
213
+ if (!this._isMllmMode() || this._agent.instructions === undefined) {
214
+ return;
215
+ }
216
+ const params = (_a = this._agent.mllm) === null || _a === void 0 ? void 0 : _a.params;
217
+ if (typeof (params === null || params === void 0 ? void 0 : params.instructions) === "string" && params.instructions.length > 0) {
218
+ return;
219
+ }
220
+ this._warn("Warning: agent-level `instructions` is ignored in MLLM mode and this agent will start with no " +
221
+ "system prompt. Pass `instructions` to the MLLM vendor instead (it serializes to mllm.params.instructions).");
222
+ }
164
223
  /**
165
224
  * Validates avatar and TTS configuration before starting.
166
225
  *
@@ -344,6 +403,7 @@ export class AgentSession {
344
403
  }
345
404
  // Validate avatar configuration before starting
346
405
  this._validateAvatarConfig();
406
+ this._warnOnDroppedMllmInstructions();
347
407
  // Validate that we can generate a token if one is not provided
348
408
  if (!this._token && !this._appCertificate) {
349
409
  throw new Error("Cannot auto-generate RTC token: appCertificate is required when a pre-built token is not provided. " +
@@ -373,6 +433,18 @@ export class AgentSession {
373
433
  });
374
434
  const enrichedProperties = this._enrichAvatarParams(resolved.properties, expiresIn);
375
435
  this._validateEnrichedAvatarConfig(enrichedProperties);
436
+ this._previewFeatures = requiredPreviewFeatures(enrichedProperties);
437
+ if (this._previewFeatures.length > 0) {
438
+ const route = createPreviewRoute(this._client, this._previewFeatures);
439
+ this._agentsClient = route.agents;
440
+ this._agentManagementClient = route.agentManagement;
441
+ this._sessionBaseUrl = route.baseUrl;
442
+ }
443
+ else {
444
+ this._agentsClient = this._client.agents;
445
+ this._agentManagementClient = this._client.agentManagement;
446
+ this._sessionBaseUrl = this._clientCurrentUrl();
447
+ }
376
448
  const request = {
377
449
  appid: this._appId,
378
450
  name: this._name,
@@ -380,14 +452,14 @@ export class AgentSession {
380
452
  pipeline_id: pipelineId,
381
453
  properties: enrichedProperties,
382
454
  };
455
+ const requestHeaders = this._requestHeaders();
383
456
  if (this._debug) {
384
457
  console.log("[Agora Debug] Starting agent session...");
385
- if ("getCurrentURL" in this._client && typeof this._client.getCurrentURL === "function") {
386
- console.log("[Agora Debug] API Endpoint:", this._client.getCurrentURL());
387
- }
388
- console.log("[Agora Debug] Request:", JSON.stringify(request, null, 2));
458
+ console.log("[Agora Debug] API Endpoint:", this._sessionBaseUrl);
459
+ console.log("[Agora Debug] Headers:", JSON.stringify(redactHeadersForDebug(Object.assign(Object.assign({}, this._clientDefaultHeaders()), requestHeaders)), null, 2));
460
+ console.log("[Agora Debug] Request:", JSON.stringify(redactSecrets(request), null, 2));
389
461
  }
390
- const response = yield this._client.agents.start(request, { headers: this._convoAIHeaders() });
462
+ const response = yield this._agentsClient.start(request, { headers: requestHeaders });
391
463
  this._agentId = (_b = response.agent_id) !== null && _b !== void 0 ? _b : null;
392
464
  this._status = "running";
393
465
  this._emit("started", { agentId: this._agentId });
@@ -416,10 +488,10 @@ export class AgentSession {
416
488
  }
417
489
  this._status = "stopping";
418
490
  try {
419
- yield this._client.agents.stop({
491
+ yield this._agentsClient.stop({
420
492
  appid: this._appId,
421
493
  agentId: this._agentId,
422
- }, { headers: this._convoAIHeaders() });
494
+ }, { headers: this._requestHeaders() });
423
495
  this._status = "stopped";
424
496
  this._emit("stopped", { agentId: this._agentId });
425
497
  }
@@ -450,13 +522,13 @@ export class AgentSession {
450
522
  if (!this._agentId) {
451
523
  throw new Error("No agent ID available");
452
524
  }
453
- yield this._client.agents.speak({
525
+ yield this._agentsClient.speak({
454
526
  appid: this._appId,
455
527
  agentId: this._agentId,
456
528
  text,
457
529
  priority: options === null || options === void 0 ? void 0 : options.priority,
458
530
  interruptable: options === null || options === void 0 ? void 0 : options.interruptable,
459
- }, { headers: this._convoAIHeaders() });
531
+ }, { headers: this._requestHeaders() });
460
532
  });
461
533
  }
462
534
  /**
@@ -470,10 +542,10 @@ export class AgentSession {
470
542
  if (!this._agentId) {
471
543
  throw new Error("No agent ID available");
472
544
  }
473
- yield this._client.agents.interrupt({
545
+ yield this._agentsClient.interrupt({
474
546
  appid: this._appId,
475
547
  agentId: this._agentId,
476
- }, { headers: this._convoAIHeaders() });
548
+ }, { headers: this._requestHeaders() });
477
549
  });
478
550
  }
479
551
  /**
@@ -487,7 +559,7 @@ export class AgentSession {
487
559
  if (!this._agentId) {
488
560
  throw new Error("No agent ID available");
489
561
  }
490
- return this._client.agentManagement.agentThink({
562
+ return this._agentManagementClient.agentThink({
491
563
  appid: this._appId,
492
564
  agentId: this._agentId,
493
565
  text,
@@ -496,7 +568,7 @@ export class AgentSession {
496
568
  on_speaking_action: options === null || options === void 0 ? void 0 : options.on_speaking_action,
497
569
  interruptable: options === null || options === void 0 ? void 0 : options.interruptable,
498
570
  metadata: options === null || options === void 0 ? void 0 : options.metadata,
499
- }, { headers: this._convoAIHeaders() });
571
+ }, { headers: this._requestHeaders() });
500
572
  });
501
573
  }
502
574
  /**
@@ -512,11 +584,11 @@ export class AgentSession {
512
584
  if (!this._agentId) {
513
585
  throw new Error("No agent ID available");
514
586
  }
515
- yield this._client.agents.update({
587
+ yield this._agentsClient.update({
516
588
  appid: this._appId,
517
589
  agentId: this._agentId,
518
590
  properties: config,
519
- }, { headers: this._convoAIHeaders() });
591
+ }, { headers: this._requestHeaders() });
520
592
  });
521
593
  }
522
594
  /**
@@ -529,10 +601,10 @@ export class AgentSession {
529
601
  if (!this._agentId) {
530
602
  throw new Error("No agent ID available");
531
603
  }
532
- return this._client.agents.getHistory({
604
+ return this._agentsClient.getHistory({
533
605
  appid: this._appId,
534
606
  agentId: this._agentId,
535
- }, { headers: this._convoAIHeaders() });
607
+ }, { headers: this._requestHeaders() });
536
608
  });
537
609
  }
538
610
  /**
@@ -545,12 +617,12 @@ export class AgentSession {
545
617
  if (!this._agentId) {
546
618
  throw new Error("No agent ID available");
547
619
  }
548
- return this._client.agents.getTurns({
620
+ return this._agentsClient.getTurns({
549
621
  appid: this._appId,
550
622
  agentId: this._agentId,
551
623
  page_index: options === null || options === void 0 ? void 0 : options.page_index,
552
624
  page_size: options === null || options === void 0 ? void 0 : options.page_size,
553
- }, { headers: this._convoAIHeaders() });
625
+ }, { headers: this._requestHeaders() });
554
626
  });
555
627
  }
556
628
  /**
@@ -605,10 +677,10 @@ export class AgentSession {
605
677
  if (!this._agentId) {
606
678
  throw new Error("No agent ID available");
607
679
  }
608
- return this._client.agents.get({
680
+ return this._agentsClient.get({
609
681
  appid: this._appId,
610
682
  agentId: this._agentId,
611
- }, { headers: this._convoAIHeaders() });
683
+ }, { headers: this._requestHeaders() });
612
684
  });
613
685
  }
614
686
  /**
@@ -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,138 @@
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 const REDACTED = "[REDACTED]";
15
+ /**
16
+ * Body fields whose values are credentials or account identifiers.
17
+ *
18
+ * Compared case-insensitively, and matched on both snake_case and camelCase
19
+ * spellings so this keeps working if a caller hand-builds a config.
20
+ */
21
+ const SENSITIVE_BODY_KEYS = new Set([
22
+ // Vendor credentials
23
+ "api_key",
24
+ "apikey",
25
+ "key",
26
+ "secret",
27
+ "api_secret",
28
+ "apisecret",
29
+ "password",
30
+ "access_key_id",
31
+ "accesskeyid",
32
+ "secret_access_key",
33
+ "secretaccesskey",
34
+ "adc_credentials_string",
35
+ "adccredentialsstring",
36
+ "credentials",
37
+ "subscription_key",
38
+ "subscriptionkey",
39
+ // Agora credentials and account identifiers
40
+ "token",
41
+ "agora_token",
42
+ "agoratoken",
43
+ "authorization",
44
+ "headers",
45
+ "x-api-key",
46
+ "cookie",
47
+ "set-cookie",
48
+ "appid",
49
+ "app_id",
50
+ "agora_appid",
51
+ "agoraappid",
52
+ "app_certificate",
53
+ "appcertificate",
54
+ "customer_secret",
55
+ "customersecret",
56
+ ]);
57
+ function isSensitiveKey(key) {
58
+ return SENSITIVE_BODY_KEYS.has(key.toLowerCase());
59
+ }
60
+ function redactQueryKeys(value) {
61
+ let parsed;
62
+ try {
63
+ parsed = new URL(value);
64
+ }
65
+ catch (_a) {
66
+ return value;
67
+ }
68
+ let changed = false;
69
+ for (const key of [...parsed.searchParams.keys()]) {
70
+ if (!isSensitiveKey(key)) {
71
+ continue;
72
+ }
73
+ const current = parsed.searchParams.getAll(key);
74
+ if (current.some((item) => item.length > 0)) {
75
+ parsed.searchParams.delete(key);
76
+ for (const item of current) {
77
+ parsed.searchParams.append(key, item.length > 0 ? REDACTED : item);
78
+ }
79
+ changed = true;
80
+ }
81
+ }
82
+ return changed ? parsed.toString() : value;
83
+ }
84
+ /**
85
+ * Deep-copies `value`, replacing credential fields with {@link REDACTED}.
86
+ *
87
+ * Empty strings are left visible on purpose: `""` is the signature of an unset
88
+ * environment variable, and hiding it behind `[REDACTED]` would disguise the
89
+ * exact misconfiguration the debug output exists to surface.
90
+ *
91
+ * Never mutates the input — the request that goes on the wire is untouched.
92
+ */
93
+ export function redactSecrets(value) {
94
+ if (Array.isArray(value)) {
95
+ return value.map((item) => redactSecrets(item));
96
+ }
97
+ if (value === null || typeof value !== "object") {
98
+ return value;
99
+ }
100
+ const result = {};
101
+ for (const [key, item] of Object.entries(value)) {
102
+ if (isSensitiveKey(key) && typeof item === "string" && item.length > 0) {
103
+ result[key] = REDACTED;
104
+ }
105
+ else if (typeof item === "string") {
106
+ result[key] = redactQueryKeys(item);
107
+ }
108
+ else {
109
+ result[key] = redactSecrets(item);
110
+ }
111
+ }
112
+ return result;
113
+ }
114
+ /**
115
+ * Redacts request headers for debug logging.
116
+ *
117
+ * Non-authorization headers are kept. The authorization credential is removed,
118
+ * while its scheme name stays visible so the active auth mode can be diagnosed.
119
+ */
120
+ export function redactHeadersForDebug(headers) {
121
+ const result = {};
122
+ for (const [key, value] of Object.entries(headers)) {
123
+ const normalized = key.toLowerCase();
124
+ const sensitive = isSensitiveKey(normalized) ||
125
+ ["authorization", "api-key", "api_key", "token", "secret", "credential", "cookie"].some((marker) => normalized.includes(marker));
126
+ if (!sensitive || value.length === 0) {
127
+ result[key] = value;
128
+ continue;
129
+ }
130
+ if (normalized !== "authorization") {
131
+ result[key] = REDACTED;
132
+ continue;
133
+ }
134
+ const scheme = value.split(/[\s=]/, 1)[0];
135
+ result[key] = scheme && scheme !== value ? `${scheme} ${REDACTED}` : REDACTED;
136
+ }
137
+ return result;
138
+ }
@@ -26,12 +26,17 @@ export { AgentSession } from "./AgentSession.mjs";
26
26
  export type { AkoolAvatarConfig, AnamAvatarConfig, GenericAvatarConfig, HeyGenAvatarConfig, LiveAvatarAvatarConfig, SensetimeAvatarConfig, SpatiusAvatarConfig, StrictAvatarConfig, } from "./avatar-types.mjs";
27
27
  export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
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.mjs";
29
+ export { REDACTED, redactHeadersForDebug, redactSecrets } from "./debug.mjs";
29
30
  export type { AgentPreset, AsrPreset, DeepgramPresetModel, LlmPreset, MiniMaxPresetModel, OpenAIPresetModel, OpenAITtsPresetModel, PresetCategory, PresetInput, TtsPreset, } from "./presets.mjs";
30
31
  export { AgentPresets, normalizePresetInput } from "./presets.mjs";
32
+ export type { PreviewFeature, PreviewRoute } from "./preview/client.mjs";
33
+ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/client.mjs";
34
+ export type { OpenAIGPTLiveOptions } from "./preview/vendors.mjs";
35
+ export { OpenAIGPTLive } from "./preview/vendors.mjs";
31
36
  export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.mjs";
32
37
  export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.mjs";
33
38
  export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.mjs";
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.mjs";
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.mjs";
35
40
  export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.mjs";
36
41
  export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.mjs";
37
42
  export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.mjs";
@@ -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.mjs";
43
48
  export type { AzureOpenAIRealtimeOptions, AzureOpenAIRealtimeParams, GeminiLiveOptions, OpenAIRealtimeOptions, QwenOmniOptions, VertexAIOptions, XaiGrokOptions, } from "./vendors/mllm.mjs";
44
49
  export { AzureOpenAIRealtime, GeminiLive, OpenAIRealtime, QwenOmni, VertexAI, XaiGrok, } from "./vendors/mllm.mjs";
45
- export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, XAiSTTOptions, } from "./vendors/stt.mjs";
46
- export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
50
+ export type { AmazonSTTOptions, AresSTTOptions, AssemblyAISTTOptions, DeepgramSTTOptions, GeminiSTTModel, GeminiSTTOptions, GoogleSTTOptions, MicrosoftSTTOptions, OpenAISTTOptions, SarvamSTTOptions, SpeechmaticsSTTOptions, XAiSTTOptions, } from "./vendors/stt.mjs";
51
+ export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
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.mjs";
48
53
  export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GenericTTS, GoogleTTS, GradiumTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MistralTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, TypecastTTS, XAiTTS, } from "./vendors/tts.mjs";
@@ -24,7 +24,10 @@ export { AgentSession } from "./AgentSession.mjs";
24
24
  export { isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, toBaseAvatarConfig, validateAvatarConfig, validateTtsSampleRate, } from "./avatar-types.mjs";
25
25
  // Type-safe constants
26
26
  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.mjs";
27
+ export { REDACTED, redactHeadersForDebug, redactSecrets } from "./debug.mjs";
27
28
  export { AgentPresets, normalizePresetInput } from "./presets.mjs";
29
+ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/client.mjs";
30
+ export { OpenAIGPTLive } from "./preview/vendors.mjs";
28
31
  // Token generation
29
32
  export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.mjs";
30
33
  // Avatar vendor classes
@@ -37,6 +40,6 @@ export { AmazonBedrock, Anthropic, AzureOpenAI, CustomLLM, Dify, Gemini, Groq, O
37
40
  // MLLM vendor classes
38
41
  export { AzureOpenAIRealtime, GeminiLive, OpenAIRealtime, QwenOmni, VertexAI, XaiGrok, } from "./vendors/mllm.mjs";
39
42
  // STT vendor classes
40
- export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
43
+ export { AmazonSTT, AresSTT, AssemblyAISTT, DeepgramSTT, GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode, GoogleSTT, MicrosoftSTT, OpenAISTT, SarvamSTT, SpeechmaticsSTT, XAiSTT, } from "./vendors/stt.mjs";
41
44
  // TTS vendor classes
42
45
  export { AmazonTTS, CartesiaTTS, DeepgramTTS, ElevenLabsTTS, FishAudioTTS, GenericTTS, GoogleTTS, GradiumTTS, HumeAITTS, MicrosoftTTS, MiniMaxTTS, MistralTTS, MurfTTS, OpenAITTS, RimeTTS, SarvamTTS, TypecastTTS, XAiTTS, } from "./vendors/tts.mjs";