agora-agents 2.7.0 → 2.8.1

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 (90) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/agentkit/Agent.d.ts +1 -1
  4. package/dist/cjs/agentkit/Agent.js +27 -12
  5. package/dist/cjs/agentkit/AgentSession.d.ts +0 -3
  6. package/dist/cjs/agentkit/AgentSession.js +3 -3
  7. package/dist/cjs/agentkit/debug.d.ts +2 -4
  8. package/dist/cjs/agentkit/debug.js +15 -6
  9. package/dist/cjs/agentkit/index.d.ts +7 -5
  10. package/dist/cjs/agentkit/index.js +15 -12
  11. package/dist/cjs/agentkit/preview/client.d.ts +6 -5
  12. package/dist/cjs/agentkit/preview/client.js +10 -5
  13. package/dist/cjs/agentkit/preview/index.d.ts +6 -5
  14. package/dist/cjs/agentkit/preview/index.js +8 -6
  15. package/dist/cjs/agentkit/preview/vendors.d.ts +65 -63
  16. package/dist/cjs/agentkit/preview/vendors.js +71 -36
  17. package/dist/cjs/agentkit/types.d.ts +23 -41
  18. package/dist/cjs/agentkit/vendors/base.d.ts +6 -2
  19. package/dist/cjs/agentkit/vendors/base.js +4 -0
  20. package/dist/cjs/agentkit/vendors/cn.js +7 -5
  21. package/dist/cjs/agentkit/vendors/llm.js +8 -1
  22. package/dist/cjs/agentkit/vendors/stt.d.ts +45 -2
  23. package/dist/cjs/agentkit/vendors/stt.js +53 -5
  24. package/dist/cjs/agentkit/vendors/tts.js +1 -1
  25. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +12 -20
  26. package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +1 -1
  27. package/dist/cjs/api/types/Asr.d.ts +4 -1
  28. package/dist/cjs/api/types/GeminiAsr.d.ts +10 -0
  29. package/dist/cjs/api/types/GeminiAsr.js +3 -0
  30. package/dist/cjs/api/types/GeminiAsrParams.d.ts +33 -0
  31. package/dist/cjs/api/types/GeminiAsrParams.js +12 -0
  32. package/dist/cjs/api/types/index.d.ts +2 -0
  33. package/dist/cjs/api/types/index.js +2 -0
  34. package/dist/cjs/index.d.ts +2 -2
  35. package/dist/cjs/index.js +5 -3
  36. package/dist/cjs/version.d.ts +1 -1
  37. package/dist/cjs/version.js +1 -1
  38. package/dist/esm/BaseClient.mjs +2 -2
  39. package/dist/esm/agentkit/Agent.d.mts +1 -1
  40. package/dist/esm/agentkit/Agent.mjs +27 -12
  41. package/dist/esm/agentkit/AgentSession.d.mts +0 -3
  42. package/dist/esm/agentkit/AgentSession.mjs +3 -3
  43. package/dist/esm/agentkit/debug.d.mts +2 -4
  44. package/dist/esm/agentkit/debug.mjs +15 -6
  45. package/dist/esm/agentkit/index.d.mts +7 -5
  46. package/dist/esm/agentkit/index.mjs +3 -2
  47. package/dist/esm/agentkit/preview/client.d.mts +6 -5
  48. package/dist/esm/agentkit/preview/client.mjs +10 -5
  49. package/dist/esm/agentkit/preview/index.d.mts +6 -5
  50. package/dist/esm/agentkit/preview/index.mjs +4 -4
  51. package/dist/esm/agentkit/preview/vendors.d.mts +65 -63
  52. package/dist/esm/agentkit/preview/vendors.mjs +69 -35
  53. package/dist/esm/agentkit/types.d.mts +23 -41
  54. package/dist/esm/agentkit/vendors/base.d.mts +6 -2
  55. package/dist/esm/agentkit/vendors/base.mjs +4 -0
  56. package/dist/esm/agentkit/vendors/cn.mjs +7 -5
  57. package/dist/esm/agentkit/vendors/llm.mjs +8 -1
  58. package/dist/esm/agentkit/vendors/stt.d.mts +45 -2
  59. package/dist/esm/agentkit/vendors/stt.mjs +51 -4
  60. package/dist/esm/agentkit/vendors/tts.mjs +1 -1
  61. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +12 -20
  62. package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +1 -1
  63. package/dist/esm/api/types/Asr.d.mts +4 -1
  64. package/dist/esm/api/types/GeminiAsr.d.mts +10 -0
  65. package/dist/esm/api/types/GeminiAsr.mjs +2 -0
  66. package/dist/esm/api/types/GeminiAsrParams.d.mts +33 -0
  67. package/dist/esm/api/types/GeminiAsrParams.mjs +9 -0
  68. package/dist/esm/api/types/index.d.mts +2 -0
  69. package/dist/esm/api/types/index.mjs +2 -0
  70. package/dist/esm/index.d.mts +2 -2
  71. package/dist/esm/index.mjs +2 -2
  72. package/dist/esm/version.d.mts +1 -1
  73. package/dist/esm/version.mjs +1 -1
  74. package/package.json +4 -2
  75. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +0 -1
  76. package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +0 -87
  77. package/dist/cjs/agentkit/__tests__/preview-types.test.d.ts +0 -7
  78. package/dist/cjs/agentkit/__tests__/preview-types.test.js +0 -57
  79. package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +0 -1
  80. package/dist/cjs/agentkit/__tests__/readme-examples.test.js +0 -126
  81. package/dist/cjs/agentkit/__tests__/type-safety.test.d.ts +0 -14
  82. package/dist/cjs/agentkit/__tests__/type-safety.test.js +0 -321
  83. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +0 -1
  84. package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +0 -85
  85. package/dist/esm/agentkit/__tests__/preview-types.test.d.mts +0 -7
  86. package/dist/esm/agentkit/__tests__/preview-types.test.mjs +0 -55
  87. package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +0 -1
  88. package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +0 -124
  89. package/dist/esm/agentkit/__tests__/type-safety.test.d.mts +0 -14
  90. package/dist/esm/agentkit/__tests__/type-safety.test.mjs +0 -319
@@ -3,51 +3,86 @@
3
3
  * Preview provider vendor classes.
4
4
  *
5
5
  * These follow the same shape as the GA vendor classes in `vendors/` —
6
- * camelCase constructor options in, snake_case wire config out — so they drop
7
- * into `agent.withStt()` unchanged. They only work against the preview
8
- * endpoint; AgentSession routes it automatically.
6
+ * camelCase constructor options in, snake_case wire config out — so they work
7
+ * with the corresponding Agent builder method. AgentSession routes them to the
8
+ * preview endpoint automatically.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.GeminiSTT = exports.GeminiSTTModels = void 0;
11
+ exports.OpenAIGPTLive = exports.OPENAI_GPT_LIVE_VENDOR = void 0;
12
+ exports.isOpenAIGPTLiveConfig = isOpenAIGPTLiveConfig;
12
13
  const base_js_1 = require("../vendors/base.js");
13
14
  // =============================================================================
14
- // Gemini 3.5 Transcribe (ASR)
15
+ // OpenAI GPT Live (MLLM)
15
16
  // =============================================================================
16
- /** Gemini preview transcription models. */
17
- exports.GeminiSTTModels = {
18
- Transcribe35Live: "gemini-3.5-transcribe-live",
19
- };
20
- /**
21
- * Gemini 3.5 Transcribe ASR vendor (preview).
22
- *
23
- * @example
24
- * ```typescript
25
- * const agent = new Agent({ client }).withStt(new GeminiSTT({
26
- * apiKey: process.env.GOOGLE_API_KEY!,
27
- * languageCodes: ['en-US'],
28
- * }));
29
- * ```
30
- */
31
- class GeminiSTT extends base_js_1.BaseSTT {
17
+ exports.OPENAI_GPT_LIVE_VENDOR = "openai_gpt_live";
18
+ function isOpenAIGPTLiveConfig(config) {
19
+ return (config === null || config === void 0 ? void 0 : config.vendor) === exports.OPENAI_GPT_LIVE_VENDOR;
20
+ }
21
+ function normalizeMcpServers(servers) {
22
+ return servers.map((server) => (Object.assign({ transport: "streamable_http" }, server)));
23
+ }
24
+ class OpenAIGPTLive extends base_js_1.BaseMLLM {
32
25
  constructor(options) {
33
26
  super();
34
- if (!options.apiKey) {
35
- throw new Error("GeminiSTT requires apiKey");
36
- }
37
27
  this.options = options;
28
+ if (!options.apiKey)
29
+ throw new Error("OpenAIGPTLive requires apiKey");
38
30
  }
39
31
  toConfig() {
40
- const { apiKey, model = exports.GeminiSTTModels.Transcribe35Live, languageCodes, customVocabulary, sampleRate = 16000, wordTimestamp, additionalParams, } = this.options;
41
- 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 }));
42
- if ("custom_vocabulary" in params && params.word_timestamp === true) {
43
- throw new Error("customVocabulary cannot be used with wordTimestamp=true");
44
- }
45
- // No top-level `language`: `Agent` sets it from `turnDetection.language`,
46
- // the same as every other STT vendor.
47
- return {
48
- vendor: "gemini",
49
- params,
50
- };
32
+ var _a, _b;
33
+ const o = this.options;
34
+ const params = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ model: "gpt-live-1" }, o.params), (o.instructions !== undefined && { prompt: o.instructions })), (o.model !== undefined && { model: o.model })), (o.voice !== undefined && { voice: o.voice })), (o.prompt !== undefined && { prompt: o.prompt })), (o.baseUrl !== undefined && { base_url: o.baseUrl })), (o.path !== undefined && { path: o.path })), (o.alphaSelector !== undefined && { alpha_selector: o.alphaSelector })), (o.headers !== undefined && { headers: o.headers })), (o.outputIdleEndMs !== undefined && { output_idle_end_ms: o.outputIdleEndMs })), (o.inputIdleEndMs !== undefined && { input_idle_end_ms: o.inputIdleEndMs })), (o.outputSilencePeak !== undefined && { output_silence_peak: o.outputSilencePeak })), (o.outputSampleRate !== undefined && { output_sample_rate: o.outputSampleRate })), (o.outputBufferMs !== undefined && { output_buffer_ms: o.outputBufferMs })), (o.inputBatchMs !== undefined && { input_batch_ms: o.inputBatchMs })), (o.toolEnabled !== undefined && { tool_enabled: o.toolEnabled })), (o.delegation !== undefined && { delegation: o.delegation })), (o.responsesModel !== undefined && { responses_model: o.responsesModel })), (o.interruptOnUserTurn !== undefined && { interrupt_on_user_turn: o.interruptOnUserTurn })), (o.sessionParams !== undefined && { session_params: o.sessionParams }));
35
+ if (o.inputAudioTranscription !== undefined || "input_audio_transcription" in params) {
36
+ throw new Error("GPT Live v3 does not support input_audio_transcription");
37
+ }
38
+ if (o.turnDetection !== undefined || "turn_detection" in params) {
39
+ console.warn("GPT Live v3 ignores turn_detection; endpointing is internal");
40
+ delete params.turn_detection;
41
+ }
42
+ if (params.delegation !== undefined && params.delegation !== "client" && params.delegation !== "responses") {
43
+ throw new Error("GPT Live delegation must be client or responses");
44
+ }
45
+ if (params.headers !== undefined) {
46
+ let headers;
47
+ try {
48
+ headers = JSON.parse(String(params.headers));
49
+ }
50
+ catch (_c) {
51
+ throw new Error("GPT Live headers must be a JSON object string");
52
+ }
53
+ if (headers === null || typeof headers !== "object" || Array.isArray(headers)) {
54
+ throw new Error("GPT Live headers must be a JSON object string");
55
+ }
56
+ }
57
+ const session = params.session_params === undefined ? {} : params.session_params;
58
+ if (session === null || typeof session !== "object" || Array.isArray(session)) {
59
+ throw new Error("GPT Live session_params must be an object");
60
+ }
61
+ for (const key of ["model", "delegation", "audio", "instructions", "input"]) {
62
+ if (key in session)
63
+ throw new Error(`GPT Live session_params cannot override ${key}`);
64
+ }
65
+ let url = o.url ||
66
+ `${String((_a = params.base_url) !== null && _a !== void 0 ? _a : "wss://api.openai.com").replace(/\/+$/, "")}/${String((_b = params.path) !== null && _b !== void 0 ? _b : "/v1/live/sessions").replace(/^\/+/, "")}`;
67
+ if (!/^wss?:\/\/[^/]/i.test(url)) {
68
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
69
+ }
70
+ let parsed;
71
+ try {
72
+ parsed = new URL(url);
73
+ }
74
+ catch (_d) {
75
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
76
+ }
77
+ if ((parsed.protocol !== "ws:" && parsed.protocol !== "wss:") || !parsed.hostname) {
78
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
79
+ }
80
+ if (parsed.hostname === "api.openai.com" && parsed.pathname === "/v1/live") {
81
+ parsed.pathname = "/v1/live/sessions";
82
+ url = parsed.toString();
83
+ }
84
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: exports.OPENAI_GPT_LIVE_VENDOR, api_key: o.apiKey, url,
85
+ params }, (o.greeting !== undefined && { greeting_message: o.greeting })), (o.failureMessage !== undefined && { failure_message: o.failureMessage })), (o.inputModalities !== undefined && { input_modalities: o.inputModalities })), (o.outputModalities !== undefined && { output_modalities: o.outputModalities })), (o.messages !== undefined && { messages: o.messages })), (o.mcpServers !== undefined && { mcp_servers: normalizeMcpServers(o.mcpServers) }));
51
86
  }
52
87
  }
53
- exports.GeminiSTT = GeminiSTT;
88
+ exports.OpenAIGPTLive = OpenAIGPTLive;
@@ -2,7 +2,7 @@
2
2
  * Clean type aliases for the Agora Conversational AI SDK.
3
3
  * These provide shorter, more intuitive names for the verbose Fern-generated types.
4
4
  */
5
- import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, TypecastTtsParams as TypecastTtsParamsType, TypecastTts as TypecastTtsType, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.js";
5
+ import type { AgentThinkAgentManagementResponse, AmazonTtsParams as AmazonTtsParamsType, AmazonTts as AmazonTtsType, Asr, AsrLanguage, CartesiaTtsParams as CartesiaTtsParamsType, CartesiaTts as CartesiaTtsType, ElevenLabsTtsParams as ElevenLabsTtsParamsType, ElevenLabsTts as ElevenLabsTtsType, FishAudioTtsParams as FishAudioTtsParamsType, FishAudioTts as FishAudioTtsType, GeminiAsrParams as GeminiAsrParamsType, GenericHttpTtsParams as GenericTtsParamsType, GenericHttpTts as GenericTtsType, GetAgentsResponse, GetHistoryAgentsResponse, GetTurnsAgentsResponse, GoogleTtsParams as GoogleTtsParamsType, GoogleTts as GoogleTtsType, GradiumTtsParams as GradiumTtsParamsType, GradiumTts as GradiumTtsType, HumeAiTtsParams as HumeAiTtsParamsType, HumeAiTts as HumeAiTtsType, ListAgentsResponse, Llm, LlmToolExecution as LlmToolExecutionType, LlmToolFunction as LlmToolFunctionType, LlmToolServer as LlmToolServerType, LlmTool as LlmToolType, MicrosoftTtsParams as MicrosoftTtsParamsType, MicrosoftTts as MicrosoftTtsType, MinimaxTtsParams as MinimaxTtsParamsType, MinimaxTts as MinimaxTtsType, MistralTtsParams as MistralTtsParamsType, MistralTts as MistralTtsType, Mllm, MllmTurnDetection, MllmTurnDetection as MllmTurnDetectionNS, MurfTtsParams as MurfTtsParamsType, MurfTts as MurfTtsType, OpenAiTtsParams as OpenAiTtsParamsType, OpenAiTts as OpenAiTtsType, RimeTtsParams as RimeTtsParamsType, RimeTts as RimeTtsType, SarvamTtsParams as SarvamTtsParamsType, SarvamTts as SarvamTtsType, SpatiusAvatarParams as SpatiusAvatarParamsType, SpeakAgentsRequest, StartAgentsRequest, Tts, TypecastTtsParams as TypecastTtsParamsType, TypecastTts as TypecastTtsType, UpdateAgentsRequest, XAiAsrParams as XAiAsrParamsType, XAiAsr as XAiAsrType, XAiTtsParams as XAiTtsParamsType, XAiTts as XAiTtsType } from "../api/index.js";
6
6
  import type { AgentThinkAgentManagementRequest } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.js";
7
7
  import type { PresetInput } from "./presets.js";
8
8
  /** LLM request style (openai, gemini, anthropic, dify) */
@@ -15,6 +15,7 @@ export type LlmStyle = Llm.Style;
15
15
  export type SttConfig = {
16
16
  vendor: "fengming";
17
17
  language?: TurnDetectionLanguage;
18
+ keywords?: string[];
18
19
  params?: Record<string, unknown>;
19
20
  } | {
20
21
  vendor: "tencent";
@@ -63,6 +64,7 @@ export type SttConfig = {
63
64
  } | {
64
65
  vendor: "ares";
65
66
  language?: TurnDetectionLanguage;
67
+ keywords?: string[];
66
68
  params?: AresParams;
67
69
  } | {
68
70
  vendor: "sarvam";
@@ -83,10 +85,17 @@ export type AsrConfig = SttConfig;
83
85
  export type AsrVendorName = string;
84
86
  /** TTS (Text-to-Speech) configuration - discriminated union */
85
87
  export type TtsConfig = Tts;
86
- /** MLLM (Multimodal LLM) configuration */
87
- export type MllmConfig = Mllm;
88
- /** MLLM wire vendor name (openai, azure, gemini, vertexai, xai, qwen_omni) */
89
- export type MllmVendor = Mllm.Vendor;
88
+ /** Inline synchronous REST tool exposed to a standard text LLM. */
89
+ export type LlmTool = LlmToolType;
90
+ export type LlmToolExecution = LlmToolExecutionType;
91
+ export type LlmToolFunction = LlmToolFunctionType;
92
+ export type LlmToolServer = LlmToolServerType;
93
+ /** MLLM configuration, including preview vendors not present in the generated schema yet. */
94
+ export type MllmConfig = Omit<Mllm, "vendor"> & {
95
+ vendor?: Mllm.Vendor | "openai_gpt_live";
96
+ };
97
+ /** MLLM wire vendor name, including preview vendors. */
98
+ export type MllmVendor = Exclude<MllmConfig["vendor"], undefined>;
90
99
  /** Avatar configuration */
91
100
  export type AvatarConfig = StartAgentsRequest.Properties.Avatar;
92
101
  /** Avatar vendor (akool, liveavatar, anam, generic, deprecated heygen) */
@@ -206,6 +215,10 @@ export type FillerWordsTriggerFixedTimeConfig = StartAgentsRequest.Properties.Fi
206
215
  export type FillerWordsContent = StartAgentsRequest.Properties.FillerWords.Content;
207
216
  /** Static filler word content config (`content.static_config`) */
208
217
  export type FillerWordsContentStaticConfig = StartAgentsRequest.Properties.FillerWords.Content.StaticConfig;
218
+ /** Generated filler word content configuration. */
219
+ export type FillerWordsContentGeneratedConfig = StartAgentsRequest.Properties.FillerWords.Content.GeneratedConfig;
220
+ /** OpenAI-compatible provider settings for generated filler words. */
221
+ export type FillerWordsGeneratedLlmProvider = StartAgentsRequest.Properties.FillerWords.Content.GeneratedConfig.LlmProvider;
209
222
  /** Filler word selection rule: `"shuffle"` | `"round_robin"` */
210
223
  export type FillerWordsContentSelectionRule = StartAgentsRequest.Properties.FillerWords.Content.StaticConfig.SelectionRule;
211
224
  /** Custom business labels attached to the agent (returned in notification callbacks) */
@@ -214,7 +227,7 @@ export type Labels = Record<string, string>;
214
227
  export type LlmGreetingConfigs = Llm.GreetingConfigs;
215
228
  /** Greeting broadcast ASR policy: `"merge_reply"` | `"context"` */
216
229
  export type LlmGreetingConfigsMode = Llm.GreetingConfigs.UninterruptibleAsrPolicy;
217
- /** MCP server config item (`llm.mcp_servers[]`) */
230
+ /** MCP server config item (`llm.mcp_servers[]` or `mllm.mcp_servers[]`) */
218
231
  export type McpServersItem = Record<string, unknown>;
219
232
  /** Full agent configuration (alias for StartAgentsRequest.Properties) */
220
233
  export type AgentConfig = StartAgentsRequest.Properties;
@@ -386,6 +399,8 @@ interface BaseLlmConfig {
386
399
  template_variables?: Record<string, string>;
387
400
  /** MCP server configurations enabling the agent to call tools from external services */
388
401
  mcp_servers?: McpServersItem[];
402
+ /** Inline synchronous REST tools exposed to the LLM for function calling */
403
+ tools?: LlmTool[];
389
404
  }
390
405
  /**
391
406
  * LLM (Large Language Model) configuration with vendor-specific typed parameters.
@@ -546,41 +561,8 @@ export interface SarvamAsrParams {
546
561
  */
547
562
  export type XAiAsr = XAiAsrType;
548
563
  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
- }
564
+ /** Google Gemini STT parameters generated from the API schema. */
565
+ export type GeminiAsrParams = GeminiAsrParamsType;
584
566
  export type MicrosoftTts = MicrosoftTtsType;
585
567
  export type MicrosoftTtsParams = MicrosoftTtsParamsType;
586
568
  export type ElevenLabsTts = ElevenLabsTtsType;
@@ -5,7 +5,7 @@
5
5
  * that converts TypeScript-friendly constructor params (camelCase) into the
6
6
  * Agora API format (snake_case).
7
7
  */
8
- import type { AvatarConfig, LlmConfig, LlmGreetingConfigs, McpServersItem, MllmConfig, SttConfig, TtsConfig } from "../types.js";
8
+ import type { AvatarConfig, LlmConfig, LlmGreetingConfigs, LlmTool, McpServersItem, MllmConfig, SttConfig, TtsConfig } from "../types.js";
9
9
  /**
10
10
  * Common options shared by all LLM vendor classes.
11
11
  * These map directly to top-level fields on `LlmConfig` that are not
@@ -42,8 +42,10 @@ export interface BaseLlmOptions {
42
42
  * Omit for standard OpenAI / Anthropic / Gemini endpoints.
43
43
  */
44
44
  vendor?: string;
45
- /** MCP server configurations enabling the agent to call tools from external services */
45
+ /** MCP server configurations enabling the agent to call tools from external services. Requires `withTools(true)`. */
46
46
  mcpServers?: McpServersItem[];
47
+ /** Inline synchronous REST tools exposed to the LLM for function calling. Requires `withTools(true)`. */
48
+ tools?: LlmTool[];
47
49
  }
48
50
  type VendorScope = "global" | "cn";
49
51
  /**
@@ -93,6 +95,7 @@ declare abstract class ScopedBaseLLM<TScope extends VendorScope> {
93
95
  private readonly _templateVariables?;
94
96
  private readonly _vendor?;
95
97
  private readonly _mcpServers?;
98
+ private readonly _tools?;
96
99
  constructor(areaScope: TScope, options?: BaseLlmOptions);
97
100
  protected get outputModalities(): string[] | undefined;
98
101
  protected get greetingConfigs(): LlmGreetingConfigs | undefined;
@@ -101,6 +104,7 @@ declare abstract class ScopedBaseLLM<TScope extends VendorScope> {
101
104
  protected get vendor(): string | undefined;
102
105
  /** MCP servers with transport defaulted to streamable_http (API requires it; only option). */
103
106
  protected get mcpServers(): McpServersItem[] | undefined;
107
+ protected get tools(): LlmTool[] | undefined;
104
108
  /**
105
109
  * Converts the vendor configuration to the Agora API format.
106
110
  */
@@ -20,6 +20,7 @@ class ScopedBaseLLM {
20
20
  this._templateVariables = options === null || options === void 0 ? void 0 : options.templateVariables;
21
21
  this._vendor = options === null || options === void 0 ? void 0 : options.vendor;
22
22
  this._mcpServers = options === null || options === void 0 ? void 0 : options.mcpServers;
23
+ this._tools = options === null || options === void 0 ? void 0 : options.tools;
23
24
  }
24
25
  get outputModalities() {
25
26
  return this._outputModalities;
@@ -43,6 +44,9 @@ class ScopedBaseLLM {
43
44
  return this._mcpServers;
44
45
  return this._mcpServers.map((s) => (s.transport ? s : Object.assign(Object.assign({}, s), { transport: "streamable_http" })));
45
46
  }
47
+ get tools() {
48
+ return this._tools;
49
+ }
46
50
  }
47
51
  class BaseLLM extends ScopedBaseLLM {
48
52
  constructor(options) {
@@ -9,15 +9,17 @@ function requireString(value, field, vendor) {
9
9
  }
10
10
  class FengmingSTT extends base_js_1.BaseCNSTT {
11
11
  constructor(options = {}) {
12
+ var _a;
12
13
  super();
14
+ if (Object.keys((_a = options.additionalParams) !== null && _a !== void 0 ? _a : {}).includes("keywords")) {
15
+ throw new Error("FengmingSTT additionalParams must not contain keywords; use the top-level keywords option");
16
+ }
13
17
  this.options = options;
14
18
  }
15
19
  toConfig() {
16
20
  const { keywords, additionalParams } = this.options;
17
- const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
18
- return Object.assign({ vendor: "fengming" }, (hasParams && {
19
- params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
20
- }));
21
+ const hasParams = additionalParams !== undefined && Object.keys(additionalParams).length > 0;
22
+ return Object.assign(Object.assign({ vendor: "fengming" }, (keywords !== undefined && { keywords })), (hasParams && { params: Object.assign({}, additionalParams) }));
21
23
  }
22
24
  }
23
25
  exports.FengmingSTT = FengmingSTT;
@@ -228,7 +230,7 @@ class StepFunTTS extends base_js_1.BaseCNTTS {
228
230
  exports.StepFunTTS = StepFunTTS;
229
231
  function cnLlmConfig(options, vendor) {
230
232
  var _a;
231
- return Object.assign(Object.assign({ url: options.url }, (options.apiKey && { api_key: options.apiKey })), { params: Object.assign({ model: options.model }, options.params), headers: options.headers, max_history: options.maxHistory, system_messages: options.systemMessages, greeting_message: options.greetingMessage, greeting_audio_url: options.greetingAudioUrl, failure_message: options.failureMessage, input_modalities: (_a = options.inputModalities) !== null && _a !== void 0 ? _a : ["text"], output_modalities: options.outputModalities, style: "openai", vendor, greeting_configs: options.greetingConfigs, template_variables: options.templateVariables, mcp_servers: options.mcpServers });
233
+ return Object.assign(Object.assign({ url: options.url }, (options.apiKey && { api_key: options.apiKey })), { params: Object.assign({ model: options.model }, options.params), headers: options.headers, max_history: options.maxHistory, system_messages: options.systemMessages, greeting_message: options.greetingMessage, greeting_audio_url: options.greetingAudioUrl, failure_message: options.failureMessage, input_modalities: (_a = options.inputModalities) !== null && _a !== void 0 ? _a : ["text"], output_modalities: options.outputModalities, style: "openai", vendor, greeting_configs: options.greetingConfigs, template_variables: options.templateVariables, mcp_servers: options.mcpServers, tools: options.tools });
232
234
  }
233
235
  class AliyunLLM extends base_js_1.BaseCNLLM {
234
236
  constructor(options) {
@@ -60,7 +60,7 @@ class OpenAI extends base_js_1.BaseLLM {
60
60
  const { apiKey, model, url, maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
61
61
  return Object.assign(Object.assign({ url: url !== null && url !== void 0 ? url : "https://api.openai.com/v1/chat/completions" }, (apiKey && { api_key: apiKey })), {
62
62
  // model is the default; params entries extend it; named fields win.
63
- params: Object.assign(Object.assign(Object.assign(Object.assign({ model }, params), (temperature !== undefined && { temperature })), (topP !== undefined && { top_p: topP })), (maxTokens !== undefined && { max_tokens: maxTokens })), headers, max_history: maxHistory, system_messages: systemMessages, greeting_message: greetingMessage, greeting_audio_url: this.greetingAudioUrl, failure_message: failureMessage, input_modalities: inputModalities !== null && inputModalities !== void 0 ? inputModalities : ["text"], output_modalities: this.outputModalities, style: "openai", vendor: this.vendor, greeting_configs: this.greetingConfigs, template_variables: this.templateVariables, mcp_servers: this.mcpServers });
63
+ params: Object.assign(Object.assign(Object.assign(Object.assign({ model }, params), (temperature !== undefined && { temperature })), (topP !== undefined && { top_p: topP })), (maxTokens !== undefined && { max_tokens: maxTokens })), headers, max_history: maxHistory, system_messages: systemMessages, greeting_message: greetingMessage, greeting_audio_url: this.greetingAudioUrl, failure_message: failureMessage, input_modalities: inputModalities !== null && inputModalities !== void 0 ? inputModalities : ["text"], output_modalities: this.outputModalities, style: "openai", vendor: this.vendor, greeting_configs: this.greetingConfigs, template_variables: this.templateVariables, mcp_servers: this.mcpServers, tools: this.tools });
64
64
  }
65
65
  }
66
66
  exports.OpenAI = OpenAI;
@@ -112,6 +112,7 @@ class AzureOpenAI extends base_js_1.BaseLLM {
112
112
  greeting_configs: this.greetingConfigs,
113
113
  template_variables: this.templateVariables,
114
114
  mcp_servers: this.mcpServers,
115
+ tools: this.tools,
115
116
  };
116
117
  }
117
118
  }
@@ -160,6 +161,7 @@ class Anthropic extends base_js_1.BaseLLM {
160
161
  greeting_configs: this.greetingConfigs,
161
162
  template_variables: this.templateVariables,
162
163
  mcp_servers: this.mcpServers,
164
+ tools: this.tools,
163
165
  };
164
166
  }
165
167
  }
@@ -205,6 +207,7 @@ class Gemini extends base_js_1.BaseLLM {
205
207
  greeting_configs: this.greetingConfigs,
206
208
  template_variables: this.templateVariables,
207
209
  mcp_servers: this.mcpServers,
210
+ tools: this.tools,
208
211
  };
209
212
  }
210
213
  }
@@ -228,6 +231,7 @@ function openAIStyleConfig(options, vendor) {
228
231
  greeting_configs: options.greetingConfigs,
229
232
  template_variables: options.templateVariables,
230
233
  mcp_servers: options.mcpServers,
234
+ tools: options.tools,
231
235
  };
232
236
  }
233
237
  class Groq extends base_js_1.BaseLLM {
@@ -286,6 +290,7 @@ class VertexAILLM extends base_js_1.BaseLLM {
286
290
  greeting_configs: this.greetingConfigs,
287
291
  template_variables: this.templateVariables,
288
292
  mcp_servers: this.mcpServers,
293
+ tools: this.tools,
289
294
  };
290
295
  }
291
296
  }
@@ -322,6 +327,7 @@ class AmazonBedrock extends base_js_1.BaseLLM {
322
327
  greeting_configs: this.greetingConfigs,
323
328
  template_variables: this.templateVariables,
324
329
  mcp_servers: this.mcpServers,
330
+ tools: this.tools,
325
331
  };
326
332
  }
327
333
  }
@@ -354,6 +360,7 @@ class Dify extends base_js_1.BaseLLM {
354
360
  greeting_configs: this.greetingConfigs,
355
361
  template_variables: this.templateVariables,
356
362
  mcp_servers: this.mcpServers,
363
+ tools: this.tools,
357
364
  };
358
365
  }
359
366
  }
@@ -2,8 +2,51 @@
2
2
  * Type-safe STT (Speech-to-Text) vendor classes.
3
3
  */
4
4
  import { type DeepgramPresetModel } from "../presets.js";
5
- import type { SttConfig } from "../types.js";
6
- import { BaseSTT } from "./base.js";
5
+ import type { SttConfig, TurnDetectionLanguage } from "../types.js";
6
+ import { BaseSTT, type SampleRate } from "./base.js";
7
+ /** Gemini transcription models. */
8
+ export declare const GeminiSTTModels: {
9
+ readonly Transcribe35Live: "gemini-3.5-transcribe-live";
10
+ };
11
+ /** A Gemini transcription model. Known models autocomplete while newer model names remain accepted. */
12
+ export type GeminiSTTModel = (typeof GeminiSTTModels)[keyof typeof GeminiSTTModels] | (string & {});
13
+ /** Transcription output mode for Gemini ASR. */
14
+ export declare const GeminiTranscriptionMode: {
15
+ readonly Smart: "SMART";
16
+ readonly Verbatim: "VERBATIM";
17
+ };
18
+ export type GeminiTranscriptionMode = (typeof GeminiTranscriptionMode)[keyof typeof GeminiTranscriptionMode];
19
+ /** Constructor options for Google Gemini STT. */
20
+ export interface GeminiSTTOptions {
21
+ /** Google Gemini API key. */
22
+ apiKey: string;
23
+ /** Gemini transcription model. Defaults to `gemini-3.5-transcribe-live`. */
24
+ model?: GeminiSTTModel;
25
+ /** Language code for speech recognition (for example, `en-US`). */
26
+ language?: string;
27
+ /** Candidate transcription languages, serialized as `params.language_hints`. */
28
+ languageHints?: readonly TurnDetectionLanguage[];
29
+ /** @deprecated Use `languageHints` instead. */
30
+ languageCodes?: readonly TurnDetectionLanguage[];
31
+ /** Words and phrases used to bias recognition. */
32
+ customVocabulary?: readonly string[];
33
+ /** Audio sample rate in Hz. Defaults to 16000. */
34
+ sampleRate?: SampleRate;
35
+ /** Whether to include word-level timestamps. Cannot be true when custom vocabulary or SMART mode is used. */
36
+ wordTimestamp?: boolean;
37
+ /** Transcript cleanup mode. Defaults to VERBATIM when omitted. */
38
+ mode?: GeminiTranscriptionMode;
39
+ /** Whether to include speaker labels. Cannot be true when mode is SMART. */
40
+ diarization?: boolean;
41
+ /** Additional vendor-specific parameters. Explicit options take precedence. */
42
+ additionalParams?: Record<string, unknown>;
43
+ }
44
+ /** Google Gemini STT vendor. */
45
+ export declare class GeminiSTT extends BaseSTT {
46
+ private readonly options;
47
+ constructor(options: GeminiSTTOptions);
48
+ toConfig(): SttConfig;
49
+ }
7
50
  /**
8
51
  * Constructor options for Speechmatics STT.
9
52
  */
@@ -3,7 +3,7 @@
3
3
  * Type-safe STT (Speech-to-Text) vendor classes.
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.XAiSTT = exports.SarvamSTT = exports.AresSTT = exports.AssemblyAISTT = exports.AmazonSTT = exports.GoogleSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.DeepgramSTT = exports.SpeechmaticsSTT = void 0;
6
+ exports.XAiSTT = exports.SarvamSTT = exports.AresSTT = exports.AssemblyAISTT = exports.AmazonSTT = exports.GoogleSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.DeepgramSTT = exports.SpeechmaticsSTT = exports.GeminiSTT = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = void 0;
7
7
  const presets_js_1 = require("../presets.js");
8
8
  const base_js_1 = require("./base.js");
9
9
  function _requireString(value, field, vendor) {
@@ -14,6 +14,52 @@ function _requireString(value, field, vendor) {
14
14
  function isDeepgramManagedModel(model) {
15
15
  return model !== undefined && presets_js_1.DeepgramPresetModels.includes(model.trim().toLowerCase());
16
16
  }
17
+ /** Gemini transcription models. */
18
+ exports.GeminiSTTModels = {
19
+ Transcribe35Live: "gemini-3.5-transcribe-live",
20
+ };
21
+ /** Transcription output mode for Gemini ASR. */
22
+ exports.GeminiTranscriptionMode = {
23
+ Smart: "SMART",
24
+ Verbatim: "VERBATIM",
25
+ };
26
+ /** Google Gemini STT vendor. */
27
+ class GeminiSTT extends base_js_1.BaseSTT {
28
+ constructor(options) {
29
+ var _a, _b, _c;
30
+ super();
31
+ _requireString(options.apiKey, "apiKey", "GeminiSTT");
32
+ const wordTimestamp = options.wordTimestamp === true;
33
+ if (((_b = (_a = options.customVocabulary) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0 && wordTimestamp) {
34
+ throw new Error("customVocabulary cannot be used with wordTimestamp=true");
35
+ }
36
+ const mode = (_c = options.mode) !== null && _c !== void 0 ? _c : exports.GeminiTranscriptionMode.Verbatim;
37
+ if (mode !== exports.GeminiTranscriptionMode.Smart && mode !== exports.GeminiTranscriptionMode.Verbatim) {
38
+ throw new Error("GeminiSTT Mode must be SMART or VERBATIM");
39
+ }
40
+ if (mode === exports.GeminiTranscriptionMode.Smart) {
41
+ if (wordTimestamp) {
42
+ throw new Error("GeminiSTT Mode=SMART cannot be used with WordTimestamp=true");
43
+ }
44
+ if (options.diarization === true) {
45
+ throw new Error("GeminiSTT Mode=SMART cannot be used with Diarization=true");
46
+ }
47
+ }
48
+ this.options = options;
49
+ }
50
+ toConfig() {
51
+ const { apiKey, model, language, languageHints, languageCodes, customVocabulary, sampleRate, wordTimestamp, mode, diarization, additionalParams, } = this.options;
52
+ const resolvedLanguageHints = languageHints !== null && languageHints !== void 0 ? languageHints : languageCodes;
53
+ const params = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, additionalParams), { api_key: apiKey, model: model === undefined ? exports.GeminiSTTModels.Transcribe35Live : model, sample_rate: sampleRate === undefined ? 16000 : sampleRate }), (language !== undefined && { language })), (resolvedLanguageHints !== undefined && {
54
+ language_hints: [...resolvedLanguageHints],
55
+ })), (customVocabulary !== undefined && { custom_vocabulary: [...customVocabulary] })), (wordTimestamp !== undefined && { word_timestamp: wordTimestamp })), (mode !== undefined && { mode })), (diarization !== undefined && { diarization }));
56
+ return {
57
+ vendor: "gemini",
58
+ params,
59
+ };
60
+ }
61
+ }
62
+ exports.GeminiSTT = GeminiSTT;
17
63
  /**
18
64
  * Speechmatics STT vendor.
19
65
  *
@@ -219,15 +265,17 @@ exports.AssemblyAISTT = AssemblyAISTT;
219
265
  */
220
266
  class AresSTT extends base_js_1.BaseSTT {
221
267
  constructor(options = {}) {
268
+ var _a;
222
269
  super();
270
+ if (Object.keys((_a = options.additionalParams) !== null && _a !== void 0 ? _a : {}).includes("keywords")) {
271
+ throw new Error("AresSTT additionalParams must not contain keywords; use the top-level keywords option");
272
+ }
223
273
  this.options = options;
224
274
  }
225
275
  toConfig() {
226
276
  const { keywords, additionalParams } = this.options;
227
- const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
228
- return Object.assign({ vendor: "ares" }, (hasParams && {
229
- params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
230
- }));
277
+ const hasParams = additionalParams !== undefined && Object.keys(additionalParams).length > 0;
278
+ return Object.assign(Object.assign({ vendor: "ares" }, (keywords !== undefined && { keywords })), (hasParams && { params: Object.assign({}, additionalParams) }));
231
279
  }
232
280
  }
233
281
  exports.AresSTT = AresSTT;
@@ -12,7 +12,7 @@ function requireString(value, field, vendor) {
12
12
  throw new Error(`${vendor} requires ${field}`);
13
13
  }
14
14
  }
15
- function requireRecord(value, field, vendor) {
15
+ function _requireRecord(value, field, vendor) {
16
16
  if (value == null || typeof value !== "object" || Array.isArray(value)) {
17
17
  throw new Error(`${vendor} requires ${field}`);
18
18
  }