agora-agents 2.6.0 → 2.7.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 (99) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/agentkit/Agent.d.ts +2 -2
  3. package/dist/cjs/agentkit/Agent.js +11 -2
  4. package/dist/cjs/agentkit/AgentSession.d.ts +27 -0
  5. package/dist/cjs/agentkit/AgentSession.js +95 -23
  6. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +2 -2
  7. package/dist/cjs/agentkit/__tests__/preview-types.test.d.ts +7 -0
  8. package/dist/cjs/agentkit/__tests__/preview-types.test.js +57 -0
  9. package/dist/cjs/agentkit/__tests__/readme-examples.test.js +3 -3
  10. package/dist/cjs/agentkit/__tests__/type-safety.test.js +1 -1
  11. package/dist/cjs/agentkit/debug.d.ts +33 -0
  12. package/dist/cjs/agentkit/debug.js +134 -0
  13. package/dist/cjs/agentkit/index.d.ts +4 -1
  14. package/dist/cjs/agentkit/index.js +16 -3
  15. package/dist/cjs/agentkit/preview/client.d.ts +58 -0
  16. package/dist/cjs/agentkit/preview/client.js +89 -0
  17. package/dist/cjs/agentkit/preview/index.d.ts +11 -0
  18. package/dist/cjs/agentkit/preview/index.js +20 -0
  19. package/dist/cjs/agentkit/preview/vendors.d.ts +72 -0
  20. package/dist/cjs/agentkit/preview/vendors.js +53 -0
  21. package/dist/cjs/agentkit/token.js +32 -3
  22. package/dist/cjs/agentkit/types.d.ts +42 -1
  23. package/dist/cjs/agentkit/vendors/stt.d.ts +12 -4
  24. package/dist/cjs/agentkit/vendors/stt.js +7 -3
  25. package/dist/cjs/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.d.ts +9 -0
  26. package/dist/cjs/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.js +6 -0
  27. package/dist/cjs/api/resources/agents/client/Client.js +17 -1
  28. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +49 -4
  29. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +9 -0
  30. package/dist/cjs/api/types/AresAsr.d.ts +2 -0
  31. package/dist/cjs/api/types/AresAsrParams.d.ts +1 -6
  32. package/dist/cjs/api/types/FengmingAsr.d.ts +2 -0
  33. package/dist/cjs/api/types/FengmingAsrParams.d.ts +1 -6
  34. package/dist/cjs/api/types/Llm.d.ts +12 -0
  35. package/dist/cjs/api/types/LlmTool.d.ts +14 -0
  36. package/dist/cjs/api/types/LlmTool.js +3 -0
  37. package/dist/cjs/api/types/LlmToolExecution.d.ts +9 -0
  38. package/dist/cjs/api/types/LlmToolExecution.js +3 -0
  39. package/dist/cjs/api/types/LlmToolFunction.d.ts +28 -0
  40. package/dist/cjs/api/types/LlmToolFunction.js +3 -0
  41. package/dist/cjs/api/types/LlmToolServer.d.ts +42 -0
  42. package/dist/cjs/api/types/LlmToolServer.js +12 -0
  43. package/dist/cjs/api/types/SpeechmaticsAsrParams.d.ts +12 -3
  44. package/dist/cjs/api/types/index.d.ts +4 -0
  45. package/dist/cjs/api/types/index.js +4 -0
  46. package/dist/cjs/index.d.ts +2 -2
  47. package/dist/cjs/index.js +13 -3
  48. package/dist/cjs/version.d.ts +1 -1
  49. package/dist/cjs/version.js +1 -1
  50. package/dist/esm/BaseClient.mjs +2 -2
  51. package/dist/esm/agentkit/Agent.d.mts +2 -2
  52. package/dist/esm/agentkit/Agent.mjs +11 -2
  53. package/dist/esm/agentkit/AgentSession.d.mts +27 -0
  54. package/dist/esm/agentkit/AgentSession.mjs +95 -23
  55. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +2 -2
  56. package/dist/esm/agentkit/__tests__/preview-types.test.d.mts +7 -0
  57. package/dist/esm/agentkit/__tests__/preview-types.test.mjs +55 -0
  58. package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +3 -3
  59. package/dist/esm/agentkit/__tests__/type-safety.test.mjs +1 -1
  60. package/dist/esm/agentkit/debug.d.mts +33 -0
  61. package/dist/esm/agentkit/debug.mjs +129 -0
  62. package/dist/esm/agentkit/index.d.mts +4 -1
  63. package/dist/esm/agentkit/index.mjs +2 -0
  64. package/dist/esm/agentkit/preview/client.d.mts +58 -0
  65. package/dist/esm/agentkit/preview/client.mjs +83 -0
  66. package/dist/esm/agentkit/preview/index.d.mts +11 -0
  67. package/dist/esm/agentkit/preview/index.mjs +9 -0
  68. package/dist/esm/agentkit/preview/vendors.d.mts +72 -0
  69. package/dist/esm/agentkit/preview/vendors.mjs +49 -0
  70. package/dist/esm/agentkit/token.mjs +32 -3
  71. package/dist/esm/agentkit/types.d.mts +42 -1
  72. package/dist/esm/agentkit/vendors/stt.d.mts +12 -4
  73. package/dist/esm/agentkit/vendors/stt.mjs +7 -3
  74. package/dist/esm/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.d.mts +9 -0
  75. package/dist/esm/api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs +6 -0
  76. package/dist/esm/api/resources/agents/client/Client.mjs +17 -1
  77. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +49 -4
  78. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +9 -0
  79. package/dist/esm/api/types/AresAsr.d.mts +2 -0
  80. package/dist/esm/api/types/AresAsrParams.d.mts +1 -6
  81. package/dist/esm/api/types/FengmingAsr.d.mts +2 -0
  82. package/dist/esm/api/types/FengmingAsrParams.d.mts +1 -6
  83. package/dist/esm/api/types/Llm.d.mts +12 -0
  84. package/dist/esm/api/types/LlmTool.d.mts +14 -0
  85. package/dist/esm/api/types/LlmTool.mjs +2 -0
  86. package/dist/esm/api/types/LlmToolExecution.d.mts +9 -0
  87. package/dist/esm/api/types/LlmToolExecution.mjs +2 -0
  88. package/dist/esm/api/types/LlmToolFunction.d.mts +28 -0
  89. package/dist/esm/api/types/LlmToolFunction.mjs +2 -0
  90. package/dist/esm/api/types/LlmToolServer.d.mts +42 -0
  91. package/dist/esm/api/types/LlmToolServer.mjs +9 -0
  92. package/dist/esm/api/types/SpeechmaticsAsrParams.d.mts +12 -3
  93. package/dist/esm/api/types/index.d.mts +4 -0
  94. package/dist/esm/api/types/index.mjs +4 -0
  95. package/dist/esm/index.d.mts +2 -2
  96. package/dist/esm/index.mjs +3 -3
  97. package/dist/esm/version.d.mts +1 -1
  98. package/dist/esm/version.mjs +1 -1
  99. package/package.json +1 -1
@@ -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.6.0",
45
- "User-Agent": "agora-agents/v2.6.0",
44
+ "X-Fern-SDK-Version": "v2.7.0",
45
+ "User-Agent": "agora-agents/v2.7.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);
@@ -138,14 +138,14 @@ export declare class Agent<TTSSampleRate extends number = number, TArea extends
138
138
  /**
139
139
  * Returns a new Agent with the specified STT vendor.
140
140
  *
141
- * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ apiKey: '...', language: 'en' }))
141
+ * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ key: '...', language: 'en' }))
142
142
  *
143
143
  * @example
144
144
  * ```typescript
145
145
  * import { SpeechmaticsSTT } from 'agora-agents';
146
146
  *
147
147
  * agent.withStt(new SpeechmaticsSTT({
148
- * apiKey: 'your-key',
148
+ * key: 'your-key',
149
149
  * language: 'en',
150
150
  * }));
151
151
  * ```
@@ -150,14 +150,14 @@ class Agent {
150
150
  /**
151
151
  * Returns a new Agent with the specified STT vendor.
152
152
  *
153
- * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ apiKey: '...', language: 'en' }))
153
+ * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ key: '...', language: 'en' }))
154
154
  *
155
155
  * @example
156
156
  * ```typescript
157
157
  * import { SpeechmaticsSTT } from 'agora-agents';
158
158
  *
159
159
  * agent.withStt(new SpeechmaticsSTT({
160
- * apiKey: 'your-key',
160
+ * key: 'your-key',
161
161
  * language: 'en',
162
162
  * }));
163
163
  * ```
@@ -643,6 +643,11 @@ class Agent {
643
643
  if (mllmConfig) {
644
644
  // Vendor config wins: only apply agent-level values when the vendor hasn't already set them.
645
645
  // Consistent with Python (setdefault) and Go (!exists) semantics.
646
+ //
647
+ // These are production wire spellings. A route that spells one of them
648
+ // differently needs a rename entry in `preview/client.ts`, or the value
649
+ // lands in a field the provider ignores and fails silently. See
650
+ // docs/guides/preview-endpoint.md#the-vendor-class-is-not-the-whole-wire-shape.
646
651
  const c = mllmConfig;
647
652
  if (this._greeting !== undefined && c.greeting_message === undefined) {
648
653
  c.greeting_message = this._greeting;
@@ -724,6 +729,10 @@ class Agent {
724
729
  : {
725
730
  vendor: this._client.area === index_js_1.Area.CN ? "fengming" : "ares",
726
731
  };
732
+ // Unconditional: turn detection is the single source of truth for the
733
+ // interaction language, so a vendor-level `language` would be silently
734
+ // discarded here. Do not add one to a vendor class — see
735
+ // docs/guides/preview-endpoint.md#the-vendor-class-is-not-the-whole-wire-shape.
727
736
  asrConfig.language = turnDetectionConfig.language;
728
737
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
729
738
  }
@@ -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,19 @@ 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
+ * These carry the preview `agora-feature` gate, which the generated client
141
+ * merges in below the SDK's view — so without this the header that decides
142
+ * whether a request reaches a preview provider is invisible in debug output.
143
+ * Reaches into `_options` the same way `authMode` is read in the constructor;
144
+ * supplier-valued headers are skipped rather than resolved, since debug
145
+ * logging must not trigger side effects.
146
+ */
147
+ private _clientDefaultHeaders;
130
148
  /**
131
149
  * The current agent ID (null if not started).
132
150
  */
@@ -171,6 +189,15 @@ export declare class AgentSession {
171
189
  * Returns true when the agent is configured for MLLM (multimodal end-to-end audio).
172
190
  */
173
191
  private _isMllmMode;
192
+ /**
193
+ * Warns when agent-level `instructions` would be silently discarded.
194
+ *
195
+ * `instructions` is only serialized into `llm.system_messages`, which does
196
+ * not exist in an MLLM pipeline — the Go and Python SDKs drop it the same
197
+ * way. Without this warning the agent starts with no system prompt at all
198
+ * and the only symptom is off-persona replies.
199
+ */
200
+ private _warnOnDroppedMllmInstructions;
174
201
  /**
175
202
  * Validates avatar and TTS configuration before starting.
176
203
  *
@@ -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
+ * These carry the preview `agora-feature` gate, which the generated client
124
+ * merges in below the SDK's view — so without this the header that decides
125
+ * whether a request reaches a preview provider is invisible in debug output.
126
+ * Reaches into `_options` the same way `authMode` is read in the constructor;
127
+ * supplier-valued headers are skipped rather than resolved, since debug
128
+ * logging must not trigger side effects.
129
+ */
130
+ _clientDefaultHeaders() {
131
+ var _a;
132
+ const headers = (_a = this._client._options) === null || _a === void 0 ? void 0 : _a.headers;
133
+ if (!headers) {
134
+ return {};
135
+ }
136
+ const result = {};
137
+ for (const [key, value] of Object.entries(headers)) {
138
+ if (typeof value === "string") {
139
+ result[key] = value;
140
+ }
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
  /**
@@ -11,7 +11,7 @@ const tts_js_1 = require("../vendors/tts.js");
11
11
  const client = new AgoraPoolClient_js_1.AgoraClient({
12
12
  area: index_js_1.Area.US,
13
13
  appId: "app-id",
14
- appCertificate: "app-certificate",
14
+ appCertificate: "app-certificate-0123456789abcdef",
15
15
  });
16
16
  new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
17
17
  .withStt(new stt_js_1.DeepgramSTT({ model: "nova-3", language: "en-US" }))
@@ -46,7 +46,7 @@ const _invalidGlobalMllm = new mllm_js_1.QwenOmni({
46
46
  const client = new AgoraPoolClient_js_1.AgoraClient({
47
47
  area: index_js_1.Area.CN,
48
48
  appId: "app-id",
49
- appCertificate: "app-certificate",
49
+ appCertificate: "app-certificate-0123456789abcdef",
50
50
  });
51
51
  new Agent_js_1.Agent({ client, turnDetection: { language: "zh-CN" } })
52
52
  .withStt(new cn_js_1.FengmingSTT())
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Compile-time type checks for the preview providers.
3
+ *
4
+ * This file is type-checked by `tsc` (it is under `src`), not executed by
5
+ * vitest. A regression here fails `pnpm build`.
6
+ */
7
+ export {};
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Compile-time type checks for the preview providers.
4
+ *
5
+ * This file is type-checked by `tsc` (it is under `src`), not executed by
6
+ * vitest. A regression here fails `pnpm build`.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const AgoraPoolClient_js_1 = require("../../AgoraPoolClient.js");
10
+ const index_js_1 = require("../../core/domain/index.js");
11
+ const Agent_js_1 = require("../Agent.js");
12
+ const index_js_2 = require("../preview/index.js");
13
+ const CLIENT = new AgoraPoolClient_js_1.AgoraClient({
14
+ area: index_js_1.Area.US,
15
+ appId: "test-app-id",
16
+ appCertificate: "test-app-certificate-01234567890",
17
+ });
18
+ // ============================================
19
+ // ✅ VALID CONFIGURATIONS
20
+ // ============================================
21
+ function _validTranscribeStt() {
22
+ return new Agent_js_1.Agent({ client: CLIENT }).withStt(new index_js_2.GeminiSTT({
23
+ apiKey: "test",
24
+ model: "gemini-3.5-transcribe-live",
25
+ languageCodes: ["en-US"],
26
+ customVocabulary: ["Agora"],
27
+ sampleRate: 16000,
28
+ wordTimestamp: false,
29
+ }));
30
+ }
31
+ /** The preview ASR variant is part of `SttConfig`, so hand-written configs type-check too. */
32
+ const _handWrittenAsr = {
33
+ vendor: "gemini",
34
+ language: "en-US",
35
+ params: {
36
+ api_key: "test",
37
+ model: "gemini-3.5-transcribe-live",
38
+ sample_rate: 16000,
39
+ language_codes: ["en-US"],
40
+ custom_vocabulary: ["Agora"],
41
+ word_timestamp: false,
42
+ },
43
+ };
44
+ // ============================================
45
+ // ❌ INVALID CONFIGURATIONS
46
+ // ============================================
47
+ /** The API key is required — it is the only credential these providers accept. */
48
+ function _transcribeRequiresApiKey() {
49
+ // @ts-expect-error - apiKey is required
50
+ return new index_js_2.GeminiSTT({ languageCodes: ["en-US"] });
51
+ }
52
+ /** ASR params must carry a model; the preview gateway rejects a bare vendor. */
53
+ // @ts-expect-error - params.model is required
54
+ const _asrRequiresModel = {
55
+ vendor: "gemini",
56
+ params: { api_key: "test" },
57
+ };
@@ -13,7 +13,7 @@ const SUPPORT_PROMPT = "You are a concise support assistant.";
13
13
  const client = new AgoraPoolClient_js_1.AgoraClient({
14
14
  area: index_js_1.Area.US,
15
15
  appId: "app-id",
16
- appCertificate: "app-certificate",
16
+ appCertificate: "app-certificate-0123456789abcdef",
17
17
  });
18
18
  new Agent_js_1.Agent({
19
19
  client,
@@ -73,7 +73,7 @@ new Agent_js_1.Agent({
73
73
  const client = new AgoraPoolClient_js_1.AgoraClient({
74
74
  area: index_js_1.Area.CN,
75
75
  appId: "app-id",
76
- appCertificate: "app-certificate",
76
+ appCertificate: "app-certificate-0123456789abcdef",
77
77
  });
78
78
  new Agent_js_1.Agent({
79
79
  client,
@@ -101,7 +101,7 @@ new Agent_js_1.Agent({
101
101
  const client = new AgoraPoolClient_js_1.AgoraClient({
102
102
  area: index_js_1.Area.US,
103
103
  appId: "app-id",
104
- appCertificate: "app-certificate",
104
+ appCertificate: "app-certificate-0123456789abcdef",
105
105
  });
106
106
  new Agent_js_1.Agent({ client, turnDetection: { language: "en-US" } })
107
107
  .withStt(new stt_js_1.DeepgramSTT({
@@ -23,7 +23,7 @@ const tts_js_1 = require("../vendors/tts.js");
23
23
  const TEST_AGENT_CLIENT = new AgoraPoolClient_js_1.AgoraClient({
24
24
  area: index_js_1.Area.US,
25
25
  appId: "test-app-id",
26
- appCertificate: "test-app-certificate",
26
+ appCertificate: "test-app-certificate-01234567890",
27
27
  });
28
28
  // ============================================
29
29
  // ✅ VALID CONFIGURATIONS
@@ -0,0 +1,33 @@
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
+ * `agora-feature` and the SDK identification headers are kept — they are what
29
+ * makes a preview request identifiable, and no header carries a secret except
30
+ * the authorization scheme's credential, whose scheme name is preserved so the
31
+ * active auth mode stays visible.
32
+ */
33
+ export declare function redactHeadersForDebug(headers: Record<string, string>): Record<string, string>;