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
package/dist/cjs/index.js CHANGED
@@ -36,9 +36,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
36
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.GoogleTTS = exports.GoogleSTT = exports.Geofence = exports.GenericTTS = exports.GenericAvatar = exports.GeminiLive = exports.Gemini = exports.FishAudioTTS = exports.FillerWordsSelectionRule = exports.FengmingSTT = exports.ExpiresIn = exports.ElevenLabsTTS = exports.Dify = exports.DeepSeekLLM = exports.DeepgramTTS = exports.DeepgramSTT = exports.DataChannel = exports.CustomLLM = exports.CredentialMode = exports.CosyVoiceTTS = exports.CartesiaTTS = exports.BytedanceTTS = exports.BytedanceLLM = exports.BytedanceDuplexTTS = exports.BaseTTS = exports.BaseSTT = exports.BaseMLLM = exports.BaseLLM = exports.BaseCNTTS = exports.BaseCNSTT = exports.BaseCNMLLM = exports.BaseCNLLM = exports.BaseCNAvatar = exports.BaseAvatar = exports.AzureOpenAIRealtime = exports.AzureOpenAI = exports.AudioScenario = exports.AssemblyAISTT = exports.AresSTT = exports.Anthropic = exports.AnamAvatar = exports.AmazonTTS = exports.AmazonSTT = exports.AmazonBedrock = exports.AliyunLLM = exports.AkoolAvatar = exports.AgentSession = exports.AgentPresets = exports.Agent = exports.AgoraClient = void 0;
40
- exports.SpeakPriorityInterrupt = exports.SpeakPriorityIgnore = exports.SpeakPriorityAppend = exports.SpatiusAvatar = exports.SilenceActionValues = exports.SensetimeAvatar = exports.SarvamTTS = exports.SarvamSTT = exports.SalModeValues = exports.RimeTTS = exports.QwenOmni = exports.OpenAITTS = exports.OpenAISTT = exports.OpenAIRealtime = exports.OpenAI = exports.normalizePresetInput = exports.MurfTTS = exports.MllmTurnDetectionModeValues = exports.MllmTurnDetectionModeServerVad = exports.MllmTurnDetectionModeSemanticVad = exports.MllmTurnDetectionModeAgoraVad = exports.MistralTTS = exports.MiniMaxTTS = exports.MiniMaxCNTTS = exports.MicrosoftTTS = exports.MicrosoftSTT = exports.MicrosoftCNTTS = exports.MicrosoftCNSTT = exports.MAX_EXPIRY_SECONDS = exports.LiveAvatarAvatar = exports.isSpatiusAvatar = exports.isSensetimeAvatar = exports.isLiveAvatarAvatar = exports.isHeyGenAvatar = exports.isGenericAvatar = exports.isAvatarTokenManaged = exports.isAnamAvatar = exports.isAkoolAvatar = exports.InterruptionModeValues = exports.InterruptionModeStartOfSpeech = exports.InterruptionModeKeywords = exports.InterruptionDisabledStrategyIgnore = exports.InterruptionDisabledStrategyAppend = exports.InterruptionDisabledStrategy = exports.HumeAITTS = exports.HeyGenAvatar = exports.generateRtcToken = exports.generateConvoAIToken = exports.Groq = exports.GradiumTTS = void 0;
41
- exports.AgoraTimeoutError = exports.AgoraError = exports.AgoraEnvironment = exports.Area = exports.Agora = exports.XfyunSTT = exports.XfyunDialectSTT = exports.XfyunBigModelSTT = exports.XaiGrok = exports.XAiTTS = exports.XAiSTT = exports.validateTtsSampleRate = exports.validateAvatarConfig = exports.VertexAILLM = exports.VertexAI = exports.toBaseAvatarConfig = exports.TypecastTTS = exports.TurnDetectionTypeValues = exports.ThinkOnThinkingActionInterrupt = exports.ThinkOnThinkingActionIgnore = exports.ThinkOnSpeakingActionInterrupt = exports.ThinkOnSpeakingActionIgnore = exports.ThinkOnListeningActionInterrupt = exports.ThinkOnListeningActionInject = exports.ThinkOnListeningActionIgnore = exports.TencentTTS = exports.TencentSTT = exports.TencentLLM = exports.StepFunTTS = exports.SpeechmaticsSTT = exports.SpeakPriorityValues = void 0;
39
+ exports.GenericTTS = exports.GenericAvatar = exports.GeminiSTTModels = exports.GeminiSTT = exports.GeminiLive = exports.Gemini = exports.FishAudioTTS = exports.FillerWordsSelectionRule = exports.FengmingSTT = exports.ExpiresIn = exports.ElevenLabsTTS = exports.Dify = exports.DeepSeekLLM = exports.DeepgramTTS = exports.DeepgramSTT = exports.DataChannel = exports.createPreviewRoute = exports.CustomLLM = exports.CredentialMode = exports.CosyVoiceTTS = exports.CartesiaTTS = exports.BytedanceTTS = exports.BytedanceLLM = exports.BytedanceDuplexTTS = exports.BaseTTS = exports.BaseSTT = exports.BaseMLLM = exports.BaseLLM = exports.BaseCNTTS = exports.BaseCNSTT = exports.BaseCNMLLM = exports.BaseCNLLM = exports.BaseCNAvatar = exports.BaseAvatar = exports.AzureOpenAIRealtime = exports.AzureOpenAI = exports.AudioScenario = exports.AssemblyAISTT = exports.AresSTT = exports.Anthropic = exports.AnamAvatar = exports.AmazonTTS = exports.AmazonSTT = exports.AmazonBedrock = exports.AliyunLLM = exports.AkoolAvatar = exports.AgentSession = exports.AgentPresets = exports.Agent = exports.AgoraClient = void 0;
40
+ exports.redactHeadersForDebug = exports.RimeTTS = exports.REDACTED = exports.QwenOmni = exports.previewRequestHeaders = exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.OpenAITTS = exports.OpenAISTT = exports.OpenAIRealtime = exports.OpenAI = exports.normalizePresetInput = exports.MurfTTS = exports.MllmTurnDetectionModeValues = exports.MllmTurnDetectionModeServerVad = exports.MllmTurnDetectionModeSemanticVad = exports.MllmTurnDetectionModeAgoraVad = exports.MistralTTS = exports.MiniMaxTTS = exports.MiniMaxCNTTS = exports.MicrosoftTTS = exports.MicrosoftSTT = exports.MicrosoftCNTTS = exports.MicrosoftCNSTT = exports.MAX_EXPIRY_SECONDS = exports.LiveAvatarAvatar = exports.isSpatiusAvatar = exports.isSensetimeAvatar = exports.isLiveAvatarAvatar = exports.isHeyGenAvatar = exports.isGenericAvatar = exports.isAvatarTokenManaged = exports.isAnamAvatar = exports.isAkoolAvatar = exports.InterruptionModeValues = exports.InterruptionModeStartOfSpeech = exports.InterruptionModeKeywords = exports.InterruptionDisabledStrategyIgnore = exports.InterruptionDisabledStrategyAppend = exports.InterruptionDisabledStrategy = exports.HumeAITTS = exports.HeyGenAvatar = exports.generateRtcToken = exports.generateConvoAIToken = exports.Groq = exports.GradiumTTS = exports.GoogleTTS = exports.GoogleSTT = exports.Geofence = void 0;
41
+ exports.AgoraTimeoutError = exports.AgoraError = exports.AgoraEnvironment = exports.Area = exports.Agora = exports.XfyunSTT = exports.XfyunDialectSTT = exports.XfyunBigModelSTT = exports.XaiGrok = exports.XAiTTS = exports.XAiSTT = exports.validateTtsSampleRate = exports.validateAvatarConfig = exports.VertexAILLM = exports.VertexAI = exports.toBaseAvatarConfig = exports.TypecastTTS = exports.TurnDetectionTypeValues = exports.ThinkOnThinkingActionInterrupt = exports.ThinkOnThinkingActionIgnore = exports.ThinkOnSpeakingActionInterrupt = exports.ThinkOnSpeakingActionIgnore = exports.ThinkOnListeningActionInterrupt = exports.ThinkOnListeningActionInject = exports.ThinkOnListeningActionIgnore = exports.TencentTTS = exports.TencentSTT = exports.TencentLLM = exports.StepFunTTS = exports.SpeechmaticsSTT = exports.SpeakPriorityValues = exports.SpeakPriorityInterrupt = exports.SpeakPriorityIgnore = exports.SpeakPriorityAppend = exports.SpatiusAvatar = exports.SilenceActionValues = exports.SensetimeAvatar = exports.SarvamTTS = exports.SarvamSTT = exports.SalModeValues = exports.redactSecrets = void 0;
42
42
  var AgoraPoolClient_js_1 = require("./AgoraPoolClient.js");
43
43
  Object.defineProperty(exports, "AgoraClient", { enumerable: true, get: function () { return AgoraPoolClient_js_1.AgoraClient; } });
44
44
  // Agentkit layer exports - clean, ergonomic API
@@ -76,6 +76,7 @@ Object.defineProperty(exports, "CartesiaTTS", { enumerable: true, get: function
76
76
  Object.defineProperty(exports, "CosyVoiceTTS", { enumerable: true, get: function () { return index_js_1.CosyVoiceTTS; } });
77
77
  Object.defineProperty(exports, "CredentialMode", { enumerable: true, get: function () { return index_js_1.CredentialMode; } });
78
78
  Object.defineProperty(exports, "CustomLLM", { enumerable: true, get: function () { return index_js_1.CustomLLM; } });
79
+ Object.defineProperty(exports, "createPreviewRoute", { enumerable: true, get: function () { return index_js_1.createPreviewRoute; } });
79
80
  Object.defineProperty(exports, "DataChannel", { enumerable: true, get: function () { return index_js_1.DataChannel; } });
80
81
  Object.defineProperty(exports, "DeepgramSTT", { enumerable: true, get: function () { return index_js_1.DeepgramSTT; } });
81
82
  Object.defineProperty(exports, "DeepgramTTS", { enumerable: true, get: function () { return index_js_1.DeepgramTTS; } });
@@ -89,6 +90,8 @@ Object.defineProperty(exports, "FillerWordsSelectionRule", { enumerable: true, g
89
90
  Object.defineProperty(exports, "FishAudioTTS", { enumerable: true, get: function () { return index_js_1.FishAudioTTS; } });
90
91
  Object.defineProperty(exports, "Gemini", { enumerable: true, get: function () { return index_js_1.Gemini; } });
91
92
  Object.defineProperty(exports, "GeminiLive", { enumerable: true, get: function () { return index_js_1.GeminiLive; } });
93
+ Object.defineProperty(exports, "GeminiSTT", { enumerable: true, get: function () { return index_js_1.GeminiSTT; } });
94
+ Object.defineProperty(exports, "GeminiSTTModels", { enumerable: true, get: function () { return index_js_1.GeminiSTTModels; } });
92
95
  Object.defineProperty(exports, "GenericAvatar", { enumerable: true, get: function () { return index_js_1.GenericAvatar; } });
93
96
  Object.defineProperty(exports, "GenericTTS", { enumerable: true, get: function () { return index_js_1.GenericTTS; } });
94
97
  Object.defineProperty(exports, "Geofence", { enumerable: true, get: function () { return index_js_1.Geofence; } });
@@ -136,8 +139,15 @@ Object.defineProperty(exports, "OpenAI", { enumerable: true, get: function () {
136
139
  Object.defineProperty(exports, "OpenAIRealtime", { enumerable: true, get: function () { return index_js_1.OpenAIRealtime; } });
137
140
  Object.defineProperty(exports, "OpenAISTT", { enumerable: true, get: function () { return index_js_1.OpenAISTT; } });
138
141
  Object.defineProperty(exports, "OpenAITTS", { enumerable: true, get: function () { return index_js_1.OpenAITTS; } });
142
+ Object.defineProperty(exports, "PREVIEW_API_BASE_URL", { enumerable: true, get: function () { return index_js_1.PREVIEW_API_BASE_URL; } });
143
+ Object.defineProperty(exports, "PREVIEW_FEATURE_HEADER", { enumerable: true, get: function () { return index_js_1.PREVIEW_FEATURE_HEADER; } });
144
+ Object.defineProperty(exports, "PreviewFeatures", { enumerable: true, get: function () { return index_js_1.PreviewFeatures; } });
145
+ Object.defineProperty(exports, "previewRequestHeaders", { enumerable: true, get: function () { return index_js_1.previewRequestHeaders; } });
139
146
  Object.defineProperty(exports, "QwenOmni", { enumerable: true, get: function () { return index_js_1.QwenOmni; } });
147
+ Object.defineProperty(exports, "REDACTED", { enumerable: true, get: function () { return index_js_1.REDACTED; } });
140
148
  Object.defineProperty(exports, "RimeTTS", { enumerable: true, get: function () { return index_js_1.RimeTTS; } });
149
+ Object.defineProperty(exports, "redactHeadersForDebug", { enumerable: true, get: function () { return index_js_1.redactHeadersForDebug; } });
150
+ Object.defineProperty(exports, "redactSecrets", { enumerable: true, get: function () { return index_js_1.redactSecrets; } });
141
151
  Object.defineProperty(exports, "SalModeValues", { enumerable: true, get: function () { return index_js_1.SalModeValues; } });
142
152
  Object.defineProperty(exports, "SarvamSTT", { enumerable: true, get: function () { return index_js_1.SarvamSTT; } });
143
153
  Object.defineProperty(exports, "SarvamTTS", { enumerable: true, get: function () { return index_js_1.SarvamTTS; } });
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "v2.6.0";
1
+ export declare const SDK_VERSION = "v2.7.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "v2.6.0";
4
+ exports.SDK_VERSION = "v2.7.0";
@@ -5,8 +5,8 @@ export function normalizeClientOptions(options) {
5
5
  const headers = mergeHeaders({
6
6
  "X-Fern-Language": "JavaScript",
7
7
  "X-Fern-SDK-Name": "agora-agents",
8
- "X-Fern-SDK-Version": "v2.6.0",
9
- "User-Agent": "agora-agents/v2.6.0",
8
+ "X-Fern-SDK-Version": "v2.7.0",
9
+ "User-Agent": "agora-agents/v2.7.0",
10
10
  "X-Fern-Runtime": core.RUNTIME.type,
11
11
  "X-Fern-Runtime-Version": core.RUNTIME.version,
12
12
  }, 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
  * ```
@@ -147,14 +147,14 @@ export class Agent {
147
147
  /**
148
148
  * Returns a new Agent with the specified STT vendor.
149
149
  *
150
- * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ apiKey: '...', language: 'en' }))
150
+ * @param vendor - STT vendor instance (e.g., new SpeechmaticsSTT({ key: '...', language: 'en' }))
151
151
  *
152
152
  * @example
153
153
  * ```typescript
154
154
  * import { SpeechmaticsSTT } from 'agora-agents';
155
155
  *
156
156
  * agent.withStt(new SpeechmaticsSTT({
157
- * apiKey: 'your-key',
157
+ * key: 'your-key',
158
158
  * language: 'en',
159
159
  * }));
160
160
  * ```
@@ -640,6 +640,11 @@ export class Agent {
640
640
  if (mllmConfig) {
641
641
  // Vendor config wins: only apply agent-level values when the vendor hasn't already set them.
642
642
  // Consistent with Python (setdefault) and Go (!exists) semantics.
643
+ //
644
+ // These are production wire spellings. A route that spells one of them
645
+ // differently needs a rename entry in `preview/client.ts`, or the value
646
+ // lands in a field the provider ignores and fails silently. See
647
+ // docs/guides/preview-endpoint.md#the-vendor-class-is-not-the-whole-wire-shape.
643
648
  const c = mllmConfig;
644
649
  if (this._greeting !== undefined && c.greeting_message === undefined) {
645
650
  c.greeting_message = this._greeting;
@@ -721,6 +726,10 @@ export class Agent {
721
726
  : {
722
727
  vendor: this._client.area === Area.CN ? "fengming" : "ares",
723
728
  };
729
+ // Unconditional: turn detection is the single source of truth for the
730
+ // interaction language, so a vendor-level `language` would be silently
731
+ // discarded here. Do not add one to a vendor class — see
732
+ // docs/guides/preview-endpoint.md#the-vendor-class-is-not-the-whole-wire-shape.
724
733
  asrConfig.language = turnDetectionConfig.language;
725
734
  return Object.keys(asrConfig).length > 0 ? asrConfig : undefined;
726
735
  }
@@ -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
  *
@@ -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
+ * These carry the preview `agora-feature` gate, which the generated client
121
+ * merges in below the SDK's view — so without this the header that decides
122
+ * whether a request reaches a preview provider is invisible in debug output.
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
+ 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
  /**
@@ -9,7 +9,7 @@ import { GenericTTS, MiniMaxTTS } from "../vendors/tts.mjs";
9
9
  const client = new AgoraClient({
10
10
  area: Area.US,
11
11
  appId: "app-id",
12
- appCertificate: "app-certificate",
12
+ appCertificate: "app-certificate-0123456789abcdef",
13
13
  });
14
14
  new Agent({ client, turnDetection: { language: "en-US" } })
15
15
  .withStt(new DeepgramSTT({ model: "nova-3", language: "en-US" }))
@@ -44,7 +44,7 @@ const _invalidGlobalMllm = new QwenOmni({
44
44
  const client = new AgoraClient({
45
45
  area: Area.CN,
46
46
  appId: "app-id",
47
- appCertificate: "app-certificate",
47
+ appCertificate: "app-certificate-0123456789abcdef",
48
48
  });
49
49
  new Agent({ client, turnDetection: { language: "zh-CN" } })
50
50
  .withStt(new 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,55 @@
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
+ import { AgoraClient } from "../../AgoraPoolClient.mjs";
8
+ import { Area } from "../../core/domain/index.mjs";
9
+ import { Agent } from "../Agent.mjs";
10
+ import { GeminiSTT } from "../preview/index.mjs";
11
+ const CLIENT = new AgoraClient({
12
+ area: Area.US,
13
+ appId: "test-app-id",
14
+ appCertificate: "test-app-certificate-01234567890",
15
+ });
16
+ // ============================================
17
+ // ✅ VALID CONFIGURATIONS
18
+ // ============================================
19
+ function _validTranscribeStt() {
20
+ return new Agent({ client: CLIENT }).withStt(new GeminiSTT({
21
+ apiKey: "test",
22
+ model: "gemini-3.5-transcribe-live",
23
+ languageCodes: ["en-US"],
24
+ customVocabulary: ["Agora"],
25
+ sampleRate: 16000,
26
+ wordTimestamp: false,
27
+ }));
28
+ }
29
+ /** The preview ASR variant is part of `SttConfig`, so hand-written configs type-check too. */
30
+ const _handWrittenAsr = {
31
+ vendor: "gemini",
32
+ language: "en-US",
33
+ params: {
34
+ api_key: "test",
35
+ model: "gemini-3.5-transcribe-live",
36
+ sample_rate: 16000,
37
+ language_codes: ["en-US"],
38
+ custom_vocabulary: ["Agora"],
39
+ word_timestamp: false,
40
+ },
41
+ };
42
+ // ============================================
43
+ // ❌ INVALID CONFIGURATIONS
44
+ // ============================================
45
+ /** The API key is required — it is the only credential these providers accept. */
46
+ function _transcribeRequiresApiKey() {
47
+ // @ts-expect-error - apiKey is required
48
+ return new GeminiSTT({ languageCodes: ["en-US"] });
49
+ }
50
+ /** ASR params must carry a model; the preview gateway rejects a bare vendor. */
51
+ // @ts-expect-error - params.model is required
52
+ const _asrRequiresModel = {
53
+ vendor: "gemini",
54
+ params: { api_key: "test" },
55
+ };
@@ -11,7 +11,7 @@ const SUPPORT_PROMPT = "You are a concise support assistant.";
11
11
  const client = new AgoraClient({
12
12
  area: Area.US,
13
13
  appId: "app-id",
14
- appCertificate: "app-certificate",
14
+ appCertificate: "app-certificate-0123456789abcdef",
15
15
  });
16
16
  new Agent({
17
17
  client,
@@ -71,7 +71,7 @@ new Agent({
71
71
  const client = new AgoraClient({
72
72
  area: Area.CN,
73
73
  appId: "app-id",
74
- appCertificate: "app-certificate",
74
+ appCertificate: "app-certificate-0123456789abcdef",
75
75
  });
76
76
  new Agent({
77
77
  client,
@@ -99,7 +99,7 @@ new Agent({
99
99
  const client = new AgoraClient({
100
100
  area: Area.US,
101
101
  appId: "app-id",
102
- appCertificate: "app-certificate",
102
+ appCertificate: "app-certificate-0123456789abcdef",
103
103
  });
104
104
  new Agent({ client, turnDetection: { language: "en-US" } })
105
105
  .withStt(new DeepgramSTT({
@@ -21,7 +21,7 @@ import { CartesiaTTS, ElevenLabsTTS, MicrosoftTTS, MiniMaxTTS, OpenAITTS } from
21
21
  const TEST_AGENT_CLIENT = new AgoraClient({
22
22
  area: Area.US,
23
23
  appId: "test-app-id",
24
- appCertificate: "test-app-certificate",
24
+ appCertificate: "test-app-certificate-01234567890",
25
25
  });
26
26
  // ============================================
27
27
  // ✅ 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>;