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
@@ -0,0 +1,129 @@
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
+ "appid",
45
+ "app_id",
46
+ "agora_appid",
47
+ "agoraappid",
48
+ "app_certificate",
49
+ "appcertificate",
50
+ "customer_secret",
51
+ "customersecret",
52
+ ]);
53
+ function isSensitiveKey(key) {
54
+ return SENSITIVE_BODY_KEYS.has(key.toLowerCase());
55
+ }
56
+ function redactQueryKeys(value) {
57
+ let parsed;
58
+ try {
59
+ parsed = new URL(value);
60
+ }
61
+ catch (_a) {
62
+ return value;
63
+ }
64
+ let changed = false;
65
+ for (const key of [...parsed.searchParams.keys()]) {
66
+ if (key.toLowerCase() !== "key") {
67
+ continue;
68
+ }
69
+ const current = parsed.searchParams.getAll(key);
70
+ if (current.some((item) => item.length > 0)) {
71
+ parsed.searchParams.delete(key);
72
+ for (const item of current) {
73
+ parsed.searchParams.append(key, item.length > 0 ? REDACTED : item);
74
+ }
75
+ changed = true;
76
+ }
77
+ }
78
+ return changed ? parsed.toString() : value;
79
+ }
80
+ /**
81
+ * Deep-copies `value`, replacing credential fields with {@link REDACTED}.
82
+ *
83
+ * Empty strings are left visible on purpose: `""` is the signature of an unset
84
+ * environment variable, and hiding it behind `[REDACTED]` would disguise the
85
+ * exact misconfiguration the debug output exists to surface.
86
+ *
87
+ * Never mutates the input — the request that goes on the wire is untouched.
88
+ */
89
+ export function redactSecrets(value) {
90
+ if (Array.isArray(value)) {
91
+ return value.map((item) => redactSecrets(item));
92
+ }
93
+ if (value === null || typeof value !== "object") {
94
+ return value;
95
+ }
96
+ const result = {};
97
+ for (const [key, item] of Object.entries(value)) {
98
+ if (isSensitiveKey(key) && typeof item === "string" && item.length > 0) {
99
+ result[key] = REDACTED;
100
+ }
101
+ else if (typeof item === "string") {
102
+ result[key] = redactQueryKeys(item);
103
+ }
104
+ else {
105
+ result[key] = redactSecrets(item);
106
+ }
107
+ }
108
+ return result;
109
+ }
110
+ /**
111
+ * Redacts request headers for debug logging.
112
+ *
113
+ * `agora-feature` and the SDK identification headers are kept — they are what
114
+ * makes a preview request identifiable, and no header carries a secret except
115
+ * the authorization scheme's credential, whose scheme name is preserved so the
116
+ * active auth mode stays visible.
117
+ */
118
+ export function redactHeadersForDebug(headers) {
119
+ const result = {};
120
+ for (const [key, value] of Object.entries(headers)) {
121
+ if (key.toLowerCase() !== "authorization") {
122
+ result[key] = value;
123
+ continue;
124
+ }
125
+ const scheme = value.split(/[\s=]/, 1)[0];
126
+ result[key] = scheme && scheme !== value ? `${scheme} ${REDACTED}` : REDACTED;
127
+ }
128
+ return result;
129
+ }
@@ -26,12 +26,15 @@ 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 { GeminiSTTModel, GeminiSTTOptions, PreviewFeature, PreviewRoute, } from "./preview/index.mjs";
33
+ export { createPreviewRoute, GeminiSTT, GeminiSTTModels, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/index.mjs";
31
34
  export type { AvatarVendor, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, LlmVendor, SttVendor, TtsVendor, } from "./region-vendors.mjs";
32
35
  export type { GenerateConvoAITokenOptions, GenerateTokenOptions, } from "./token.mjs";
33
36
  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";
37
+ 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, GeminiAsrParams, 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";
35
38
  export type { AkoolAvatarOptions, AnamAvatarOptions, GenericAvatarOptions, HeyGenAvatarOptions, LiveAvatarAvatarOptions, } from "./vendors/avatar.mjs";
36
39
  export { AkoolAvatar, AnamAvatar, GenericAvatar, HeyGenAvatar, LiveAvatarAvatar, } from "./vendors/avatar.mjs";
37
40
  export type { AkoolSampleRate, CartesiaSampleRate, ElevenLabsSampleRate, HeyGenSampleRate, LiveAvatarSampleRate, MicrosoftSampleRate, SampleRate, } from "./vendors/base.mjs";
@@ -24,7 +24,9 @@ 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, GeminiSTT, GeminiSTTModels, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./preview/index.mjs";
28
30
  // Token generation
29
31
  export { ExpiresIn, generateConvoAIToken, generateRtcToken, MAX_EXPIRY_SECONDS, } from "./token.mjs";
30
32
  // Avatar vendor classes
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Preview endpoint routing.
3
+ *
4
+ * Preview providers are not served by the production Conversational AI gateway.
5
+ * They live behind a single partner host and are gated by an `agora-feature`
6
+ * header. AgentSession detects preview providers from its resolved request body
7
+ * and binds that session to the preview host while ordinary AgoraClient calls
8
+ * remain on the regional production endpoint.
9
+ *
10
+ * Everything under `agentkit/preview/` is temporary. When these providers ship
11
+ * on the production gateway, delete this directory and move the vendor classes
12
+ * into `vendors/stt.ts`.
13
+ */
14
+ import type { AgoraClient } from "../../AgoraPoolClient.mjs";
15
+ import type * as Agora from "../../api/index.mjs";
16
+ import { AgentManagementClient } from "../../api/resources/agentManagement/client/Client.mjs";
17
+ import { AgentsClient } from "../../api/resources/agents/client/Client.mjs";
18
+ /** Base URL that serves the preview providers. */
19
+ export declare const PREVIEW_API_BASE_URL = "https://partner.ai.agora.io/preview/api/conversational-ai-agent";
20
+ /**
21
+ * Request header that opts a request into a preview provider family.
22
+ *
23
+ * This is the header the preview gateway routes on. A request that reaches the
24
+ * gateway without it is not rejected — it is routed to the production
25
+ * environment, where the preview providers do not exist.
26
+ */
27
+ export declare const PREVIEW_FEATURE_HEADER = "agora-feature";
28
+ /**
29
+ * Preview provider families. Each value is one entry in the
30
+ * {@link PREVIEW_FEATURE_HEADER} header and gates a set of vendors on the
31
+ * preview endpoint.
32
+ */
33
+ export declare const PreviewFeatures: {
34
+ /** Gemini 3.5 Transcribe ASR. */
35
+ readonly GeminiLive: "gemini-live";
36
+ };
37
+ /** A preview provider family (`"gemini-live"`). */
38
+ export type PreviewFeature = (typeof PreviewFeatures)[keyof typeof PreviewFeatures];
39
+ /** Session-scoped clients bound to one resolved route. */
40
+ export interface PreviewRoute {
41
+ readonly agents: AgentsClient;
42
+ readonly agentManagement: AgentManagementClient;
43
+ readonly baseUrl: string;
44
+ readonly features: readonly PreviewFeature[];
45
+ }
46
+ /**
47
+ * Pins the gate after any caller headers. This is also used for per-call auth
48
+ * headers so a custom `agora-feature` value can never blank the session gate.
49
+ */
50
+ export declare function previewRequestHeaders(features: readonly PreviewFeature[], headers?: Record<string, string>): Record<string, string>;
51
+ /** Build generated resource clients for one preview session. */
52
+ export declare function createPreviewRoute(client: AgoraClient, features: readonly PreviewFeature[]): PreviewRoute;
53
+ /**
54
+ * Returns the preview features a start request needs, derived from the request
55
+ * body rather than from the vendor classes — so hand-written configs are
56
+ * covered too.
57
+ */
58
+ export declare function requiredPreviewFeatures(properties: Agora.StartAgentsRequest.Properties): PreviewFeature[];
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Preview endpoint routing.
3
+ *
4
+ * Preview providers are not served by the production Conversational AI gateway.
5
+ * They live behind a single partner host and are gated by an `agora-feature`
6
+ * header. AgentSession detects preview providers from its resolved request body
7
+ * and binds that session to the preview host while ordinary AgoraClient calls
8
+ * remain on the regional production endpoint.
9
+ *
10
+ * Everything under `agentkit/preview/` is temporary. When these providers ship
11
+ * on the production gateway, delete this directory and move the vendor classes
12
+ * into `vendors/stt.ts`.
13
+ */
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ import { AgentManagementClient } from "../../api/resources/agentManagement/client/Client.mjs";
24
+ import { AgentsClient } from "../../api/resources/agents/client/Client.mjs";
25
+ /** Base URL that serves the preview providers. */
26
+ export const PREVIEW_API_BASE_URL = "https://partner.ai.agora.io/preview/api/conversational-ai-agent";
27
+ /**
28
+ * Request header that opts a request into a preview provider family.
29
+ *
30
+ * This is the header the preview gateway routes on. A request that reaches the
31
+ * gateway without it is not rejected — it is routed to the production
32
+ * environment, where the preview providers do not exist.
33
+ */
34
+ export const PREVIEW_FEATURE_HEADER = "agora-feature";
35
+ /**
36
+ * Preview provider families. Each value is one entry in the
37
+ * {@link PREVIEW_FEATURE_HEADER} header and gates a set of vendors on the
38
+ * preview endpoint.
39
+ */
40
+ export const PreviewFeatures = {
41
+ /** Gemini 3.5 Transcribe ASR. */
42
+ GeminiLive: "gemini-live",
43
+ };
44
+ /**
45
+ * Pins the gate after any caller headers. This is also used for per-call auth
46
+ * headers so a custom `agora-feature` value can never blank the session gate.
47
+ */
48
+ export function previewRequestHeaders(features, headers) {
49
+ return Object.assign(Object.assign({}, headers), { [PREVIEW_FEATURE_HEADER]: features.join(",") });
50
+ }
51
+ /** Build generated resource clients for one preview session. */
52
+ export function createPreviewRoute(client, features) {
53
+ var _a;
54
+ const clientOptions = client._options;
55
+ const fetchFn = (_a = clientOptions.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch;
56
+ const options = Object.assign(Object.assign({}, clientOptions), { baseUrl: PREVIEW_API_BASE_URL, headers: previewRequestHeaders(features, clientOptions.headers), fetch: (input, init) => __awaiter(this, void 0, void 0, function* () {
57
+ const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
58
+ headers.set(PREVIEW_FEATURE_HEADER, features.join(","));
59
+ return fetchFn(input, Object.assign(Object.assign({}, init), { headers }));
60
+ }) });
61
+ return {
62
+ agents: new AgentsClient(options),
63
+ agentManagement: new AgentManagementClient(options),
64
+ baseUrl: PREVIEW_API_BASE_URL,
65
+ features: [...features],
66
+ };
67
+ }
68
+ /** ASR vendor served only by the preview endpoint. */
69
+ const PREVIEW_ASR_VENDORS = new Set(["gemini"]);
70
+ /**
71
+ * Returns the preview features a start request needs, derived from the request
72
+ * body rather than from the vendor classes — so hand-written configs are
73
+ * covered too.
74
+ */
75
+ export function requiredPreviewFeatures(properties) {
76
+ var _a;
77
+ const features = new Set();
78
+ const asrVendor = (_a = properties.asr) === null || _a === void 0 ? void 0 : _a.vendor;
79
+ if (asrVendor !== undefined && PREVIEW_ASR_VENDORS.has(asrVendor)) {
80
+ features.add(PreviewFeatures.GeminiLive);
81
+ }
82
+ return [...features];
83
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Preview provider surface.
3
+ *
4
+ * Self-contained on purpose: when these providers ship on the production
5
+ * gateway, this directory is deleted and the vendor classes move into
6
+ * `vendors/stt.ts`.
7
+ */
8
+ export type { PreviewFeature, PreviewRoute } from "./client.mjs";
9
+ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./client.mjs";
10
+ export type { GeminiSTTModel, GeminiSTTOptions } from "./vendors.mjs";
11
+ export { GeminiSTT, GeminiSTTModels } from "./vendors.mjs";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Preview provider surface.
3
+ *
4
+ * Self-contained on purpose: when these providers ship on the production
5
+ * gateway, this directory is deleted and the vendor classes move into
6
+ * `vendors/stt.ts`.
7
+ */
8
+ export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./client.mjs";
9
+ export { GeminiSTT, GeminiSTTModels } from "./vendors.mjs";
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Preview provider vendor classes.
3
+ *
4
+ * These follow the same shape as the GA vendor classes in `vendors/` —
5
+ * camelCase constructor options in, snake_case wire config out — so they drop
6
+ * into `agent.withStt()` unchanged. They only work against the preview
7
+ * endpoint; AgentSession routes it automatically.
8
+ */
9
+ import type { SttConfig, TurnDetectionLanguage } from "../types.mjs";
10
+ import type { SampleRate } from "../vendors/base.mjs";
11
+ import { BaseSTT } from "../vendors/base.mjs";
12
+ /** Gemini preview transcription models. */
13
+ export declare const GeminiSTTModels: {
14
+ readonly Transcribe35Live: "gemini-3.5-transcribe-live";
15
+ };
16
+ /**
17
+ * A Gemini preview transcription model. Known model names autocomplete; any
18
+ * string is accepted so a newly published preview model can be used before this
19
+ * SDK is updated.
20
+ */
21
+ export type GeminiSTTModel = (typeof GeminiSTTModels)[keyof typeof GeminiSTTModels] | (string & {});
22
+ /** Constructor options for {@link GeminiSTT}. */
23
+ export interface GeminiSTTOptions {
24
+ /** Google API key. */
25
+ apiKey: string;
26
+ /** Model name. Defaults to `gemini-3.5-transcribe-live`. */
27
+ model?: GeminiSTTModel;
28
+ /**
29
+ * Languages the model should transcribe, sent as `params.language_codes`.
30
+ *
31
+ * Omitted from the request when unset, which is how the provider spells
32
+ * auto-detect — the SDK does not pin a language the caller never asked for.
33
+ * Pass one code to commit to a language, several to let the model choose
34
+ * between them, or an explicit empty array to request auto-detect
35
+ * outright.
36
+ *
37
+ * This is the only language setting on this vendor. The top-level
38
+ * `asr.language` is supplied by `Agent` from `turnDetection.language`, as
39
+ * it is for every STT vendor.
40
+ */
41
+ languageCodes?: readonly TurnDetectionLanguage[];
42
+ /**
43
+ * Words and phrases to bias recognition toward — product names, jargon,
44
+ * proper nouns the model would otherwise mis-hear.
45
+ */
46
+ customVocabulary?: readonly string[];
47
+ /** Audio sample rate in Hz. Defaults to 16000. */
48
+ sampleRate?: SampleRate;
49
+ /**
50
+ * Emit per-word timestamps in transcription results. Omitted unless
51
+ * explicitly set; cannot be `true` when `customVocabulary` is set.
52
+ */
53
+ wordTimestamp?: boolean;
54
+ /** Additional vendor-specific parameters. */
55
+ additionalParams?: Record<string, unknown>;
56
+ }
57
+ /**
58
+ * Gemini 3.5 Transcribe ASR vendor (preview).
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const agent = new Agent({ client }).withStt(new GeminiSTT({
63
+ * apiKey: process.env.GOOGLE_API_KEY!,
64
+ * languageCodes: ['en-US'],
65
+ * }));
66
+ * ```
67
+ */
68
+ export declare class GeminiSTT extends BaseSTT {
69
+ private readonly options;
70
+ constructor(options: GeminiSTTOptions);
71
+ toConfig(): SttConfig;
72
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Preview provider vendor classes.
3
+ *
4
+ * These follow the same shape as the GA vendor classes in `vendors/` —
5
+ * camelCase constructor options in, snake_case wire config out — so they drop
6
+ * into `agent.withStt()` unchanged. They only work against the preview
7
+ * endpoint; AgentSession routes it automatically.
8
+ */
9
+ import { BaseSTT } from "../vendors/base.mjs";
10
+ // =============================================================================
11
+ // Gemini 3.5 Transcribe (ASR)
12
+ // =============================================================================
13
+ /** Gemini preview transcription models. */
14
+ export const GeminiSTTModels = {
15
+ Transcribe35Live: "gemini-3.5-transcribe-live",
16
+ };
17
+ /**
18
+ * Gemini 3.5 Transcribe ASR vendor (preview).
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const agent = new Agent({ client }).withStt(new GeminiSTT({
23
+ * apiKey: process.env.GOOGLE_API_KEY!,
24
+ * languageCodes: ['en-US'],
25
+ * }));
26
+ * ```
27
+ */
28
+ export class GeminiSTT extends BaseSTT {
29
+ constructor(options) {
30
+ super();
31
+ if (!options.apiKey) {
32
+ throw new Error("GeminiSTT requires apiKey");
33
+ }
34
+ this.options = options;
35
+ }
36
+ toConfig() {
37
+ const { apiKey, model = GeminiSTTModels.Transcribe35Live, languageCodes, customVocabulary, sampleRate = 16000, wordTimestamp, additionalParams, } = this.options;
38
+ const params = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, model, sample_rate: sampleRate }), (languageCodes && { language_codes: [...languageCodes] })), (customVocabulary && { custom_vocabulary: [...customVocabulary] })), (wordTimestamp !== undefined && { word_timestamp: wordTimestamp }));
39
+ if ("custom_vocabulary" in params && params.word_timestamp === true) {
40
+ throw new Error("customVocabulary cannot be used with wordTimestamp=true");
41
+ }
42
+ // No top-level `language`: `Agent` sets it from `turnDetection.language`,
43
+ // the same as every other STT vendor.
44
+ return {
45
+ vendor: "gemini",
46
+ params,
47
+ };
48
+ }
49
+ }
@@ -11,6 +11,35 @@
11
11
  import agoraToken from "agora-token";
12
12
  const DEFAULT_EXPIRY_SECONDS = 86400;
13
13
  export const MAX_EXPIRY_SECONDS = 86400;
14
+ /**
15
+ * Length `agora-token` requires of both the app ID and the app certificate.
16
+ * Either one being a different length yields an empty token.
17
+ */
18
+ const AGORA_CREDENTIAL_LENGTH = 32;
19
+ /**
20
+ * Rejects the empty string `agora-token` returns for a malformed credential.
21
+ *
22
+ * The builders validate nothing and never throw — they hand back `""` whenever
23
+ * `appId` or `appCertificate` is not exactly {@link AGORA_CREDENTIAL_LENGTH}
24
+ * characters. That empty token is then sent as `token: ""`, and the failure
25
+ * surfaces as an opaque gateway auth error naming neither field. A value pasted
26
+ * with a trailing newline or a stray space is enough to trigger it, so fail
27
+ * here, where the cause is still visible.
28
+ *
29
+ * Credential values are never included in the message — only their lengths.
30
+ */
31
+ function _requireBuiltToken(token, appId, appCertificate) {
32
+ if (token) {
33
+ return token;
34
+ }
35
+ const wrong = [["appId", appId], ["appCertificate", appCertificate]].filter(([, value]) => value.length !== AGORA_CREDENTIAL_LENGTH);
36
+ const detail = wrong.length > 0
37
+ ? wrong.map(([name, value]) => `${name} is ${value.length} characters`).join(" and ")
38
+ : "both are the right length, so the values themselves were rejected";
39
+ throw new Error(`Failed to build an Agora token: appId and appCertificate must each be exactly ` +
40
+ `${AGORA_CREDENTIAL_LENGTH} characters (${detail}). ` +
41
+ "Check the values for stray whitespace or a truncated paste.");
42
+ }
14
43
  /**
15
44
  * Convenience helpers for specifying token expiry durations.
16
45
  *
@@ -82,7 +111,7 @@ function _validateExpiresIn(secs) {
82
111
  export function generateRtcToken(opts) {
83
112
  var _a, _b;
84
113
  const expiry = (_a = opts.expirySeconds) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRY_SECONDS;
85
- return agoraToken.RtcTokenBuilder.buildTokenWithUid(opts.appId, opts.appCertificate, opts.channel, opts.uid, (_b = opts.role) !== null && _b !== void 0 ? _b : agoraToken.RtcRole.PUBLISHER, expiry, expiry);
114
+ return _requireBuiltToken(agoraToken.RtcTokenBuilder.buildTokenWithUid(opts.appId, opts.appCertificate, opts.channel, opts.uid, (_b = opts.role) !== null && _b !== void 0 ? _b : agoraToken.RtcRole.PUBLISHER, expiry, expiry), opts.appId, opts.appCertificate);
86
115
  }
87
116
  /**
88
117
  * Builds a short-lived RTC token for a string UID (user account).
@@ -96,7 +125,7 @@ export function generateRtcToken(opts) {
96
125
  export function generateRtcTokenWithAccount(opts) {
97
126
  var _a, _b;
98
127
  const expiry = (_a = opts.expirySeconds) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRY_SECONDS;
99
- return agoraToken.RtcTokenBuilder.buildTokenWithUserAccount(opts.appId, opts.appCertificate, opts.channel, opts.account, (_b = opts.role) !== null && _b !== void 0 ? _b : agoraToken.RtcRole.PUBLISHER, expiry, expiry);
128
+ return _requireBuiltToken(agoraToken.RtcTokenBuilder.buildTokenWithUserAccount(opts.appId, opts.appCertificate, opts.channel, opts.account, (_b = opts.role) !== null && _b !== void 0 ? _b : agoraToken.RtcRole.PUBLISHER, expiry, expiry), opts.appId, opts.appCertificate);
100
129
  }
101
130
  /**
102
131
  * Builds a combined RTC + RTM token for ConvoAI REST API authentication.
@@ -114,7 +143,7 @@ export function generateConvoAIToken(opts) {
114
143
  const configuredPrivilegeExpire = (_b = opts.privilegeExpire) !== null && _b !== void 0 ? _b : 0;
115
144
  const privilegeExpire = configuredPrivilegeExpire === 0 ? tokenExpire : configuredPrivilegeExpire;
116
145
  const account = _uidToAccount(opts.uid);
117
- return agoraToken.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agoraToken.RtcRole.PUBLISHER, tokenExpire, privilegeExpire);
146
+ return _requireBuiltToken(agoraToken.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agoraToken.RtcRole.PUBLISHER, tokenExpire, privilegeExpire), opts.appId, opts.appCertificate);
118
147
  }
119
148
  function _uidToAccount(uid) {
120
149
  if (!Number.isInteger(uid)) {
@@ -72,6 +72,10 @@ export type SttConfig = {
72
72
  vendor: "xai";
73
73
  language?: TurnDetectionLanguage;
74
74
  params: XAiAsrParams;
75
+ } | {
76
+ vendor: "gemini";
77
+ language?: TurnDetectionLanguage;
78
+ params: GeminiAsrParams;
75
79
  } | Asr;
76
80
  /** ASR configuration — alias for {@link SttConfig} (wire field: `asr`). */
77
81
  export type AsrConfig = SttConfig;
@@ -409,7 +413,9 @@ export type LlmConfig = (BaseLlmConfig & {
409
413
  */
410
414
  export interface SpeechmaticsParams {
411
415
  /** Speechmatics API key for authentication (required) */
412
- api_key: string;
416
+ key: string;
417
+ /** @deprecated The REST API expects `key`; use `key` instead. */
418
+ api_key?: string;
413
419
  /** Language code for transcription (e.g., 'en', 'es', 'fr') (required) */
414
420
  language: string;
415
421
  /** Speechmatics streaming WebSocket URL */
@@ -540,6 +546,41 @@ export interface SarvamAsrParams {
540
546
  */
541
547
  export type XAiAsr = XAiAsrType;
542
548
  export type XAiAsrParams = XAiAsrParamsType;
549
+ /**
550
+ * Gemini STT parameters (preview).
551
+ *
552
+ * Served only by the preview endpoint and routed automatically by AgentSession.
553
+ * Not part of the generated `Asr` union, so the variant
554
+ * is declared here until the provider ships on the production gateway.
555
+ */
556
+ export interface GeminiAsrParams {
557
+ /** Google API key */
558
+ api_key: string;
559
+ /** Model name (e.g., 'gemini-3.5-transcribe-live') */
560
+ model: string;
561
+ /** Audio sample rate in Hz */
562
+ sample_rate?: number;
563
+ /**
564
+ * Languages to transcribe (e.g., `['en-US']`).
565
+ *
566
+ * Omit the field or send `[]` to let the model auto-detect. Note this is
567
+ * `language_codes` — an array — not the singular `language` other ASR
568
+ * vendors take.
569
+ */
570
+ language_codes?: string[];
571
+ /**
572
+ * Words and phrases to bias recognition toward (e.g., product names,
573
+ * jargon). Optional.
574
+ */
575
+ custom_vocabulary?: string[];
576
+ /**
577
+ * Emit per-word timestamps in transcription results. Cannot be `true`
578
+ * when `custom_vocabulary` is set.
579
+ */
580
+ word_timestamp?: boolean;
581
+ /** Additional Gemini-specific parameters */
582
+ [key: string]: unknown;
583
+ }
543
584
  export type MicrosoftTts = MicrosoftTtsType;
544
585
  export type MicrosoftTtsParams = MicrosoftTtsParamsType;
545
586
  export type ElevenLabsTts = ElevenLabsTtsType;
@@ -7,9 +7,7 @@ import { BaseSTT } from "./base.mjs";
7
7
  /**
8
8
  * Constructor options for Speechmatics STT.
9
9
  */
10
- export interface SpeechmaticsSTTOptions {
11
- /** Speechmatics API key */
12
- apiKey: string;
10
+ interface SpeechmaticsSTTCommonOptions {
13
11
  /** Language code (e.g., 'en', 'es', 'fr') */
14
12
  language: string;
15
13
  /** Model name */
@@ -19,13 +17,23 @@ export interface SpeechmaticsSTTOptions {
19
17
  /** Additional vendor-specific parameters */
20
18
  additionalParams?: Record<string, unknown>;
21
19
  }
20
+ export type SpeechmaticsSTTOptions = SpeechmaticsSTTCommonOptions & ({
21
+ /** Speechmatics API key */
22
+ key: string;
23
+ /** @deprecated Use `key` instead. This alias is normalized to the REST API's `key` field. */
24
+ apiKey?: string;
25
+ } | {
26
+ key?: undefined;
27
+ /** @deprecated Use `key` instead. This alias is normalized to the REST API's `key` field. */
28
+ apiKey: string;
29
+ });
22
30
  /**
23
31
  * Speechmatics STT vendor.
24
32
  *
25
33
  * @example
26
34
  * ```typescript
27
35
  * const stt = new SpeechmaticsSTT({
28
- * apiKey: process.env.SPEECHMATICS_API_KEY,
36
+ * key: process.env.SPEECHMATICS_API_KEY,
29
37
  * language: 'en',
30
38
  * });
31
39
  * ```
@@ -17,7 +17,7 @@ function isDeepgramManagedModel(model) {
17
17
  * @example
18
18
  * ```typescript
19
19
  * const stt = new SpeechmaticsSTT({
20
- * apiKey: process.env.SPEECHMATICS_API_KEY,
20
+ * key: process.env.SPEECHMATICS_API_KEY,
21
21
  * language: 'en',
22
22
  * });
23
23
  * ```
@@ -28,10 +28,14 @@ export class SpeechmaticsSTT extends BaseSTT {
28
28
  this.options = options;
29
29
  }
30
30
  toConfig() {
31
- const { apiKey, language, model, uri, additionalParams } = this.options;
31
+ const { key, apiKey, language, model, uri, additionalParams } = this.options;
32
+ const wireKey = key !== null && key !== void 0 ? key : apiKey;
33
+ _requireString(wireKey, "key", "SpeechmaticsSTT");
34
+ const params = Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { key: wireKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri }));
35
+ delete params.api_key;
32
36
  return {
33
37
  vendor: "speechmatics",
34
- params: Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, language }), (model !== undefined && { model })), (uri !== undefined && { uri })),
38
+ params,
35
39
  };
36
40
  }
37
41
  }