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
@@ -7,9 +7,9 @@
7
7
  * and binds that session to the preview host while ordinary AgoraClient calls
8
8
  * remain on the regional production endpoint.
9
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`.
10
+ * Everything under `agentkit/preview/` is temporary. When a provider ships on
11
+ * the production gateway, remove its preview registration and move its class
12
+ * into the corresponding production vendor module.
13
13
  */
14
14
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
15
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -22,6 +22,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
22
22
  };
23
23
  import { AgentManagementClient } from "../../api/resources/agentManagement/client/Client.mjs";
24
24
  import { AgentsClient } from "../../api/resources/agents/client/Client.mjs";
25
+ import { isOpenAIGPTLiveConfig } from "./vendors.mjs";
25
26
  /** Base URL that serves the preview providers. */
26
27
  export const PREVIEW_API_BASE_URL = "https://partner.ai.agora.io/preview/api/conversational-ai-agent";
27
28
  /**
@@ -38,8 +39,9 @@ export const PREVIEW_FEATURE_HEADER = "agora-feature";
38
39
  * preview endpoint.
39
40
  */
40
41
  export const PreviewFeatures = {
41
- /** Gemini 3.5 Transcribe ASR. */
42
+ /** @deprecated Gemini ASR now uses the production endpoint. */
42
43
  GeminiLive: "gemini-live",
44
+ LiveModels: "live-models",
43
45
  };
44
46
  /**
45
47
  * Pins the gate after any caller headers. This is also used for per-call auth
@@ -66,7 +68,7 @@ export function createPreviewRoute(client, features) {
66
68
  };
67
69
  }
68
70
  /** ASR vendor served only by the preview endpoint. */
69
- const PREVIEW_ASR_VENDORS = new Set(["gemini"]);
71
+ const PREVIEW_ASR_VENDORS = new Set();
70
72
  /**
71
73
  * Returns the preview features a start request needs, derived from the request
72
74
  * body rather than from the vendor classes — so hand-written configs are
@@ -79,5 +81,8 @@ export function requiredPreviewFeatures(properties) {
79
81
  if (asrVendor !== undefined && PREVIEW_ASR_VENDORS.has(asrVendor)) {
80
82
  features.add(PreviewFeatures.GeminiLive);
81
83
  }
84
+ if (isOpenAIGPTLiveConfig(properties.mllm)) {
85
+ features.add(PreviewFeatures.LiveModels);
86
+ }
82
87
  return [...features];
83
88
  }
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Preview provider surface.
3
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`.
4
+ * Preview routing stays here while provider implementations can graduate to
5
+ * the production vendor modules independently.
7
6
  */
7
+ export type { GeminiSTTModel, GeminiSTTOptions } from "../vendors/stt.mjs";
8
+ export { GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode } from "../vendors/stt.mjs";
8
9
  export type { PreviewFeature, PreviewRoute } from "./client.mjs";
9
10
  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";
11
+ export type { OpenAIGPTLiveOptions } from "./vendors.mjs";
12
+ export { OpenAIGPTLive } from "./vendors.mjs";
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Preview provider surface.
3
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`.
4
+ * Preview routing stays here while provider implementations can graduate to
5
+ * the production vendor modules independently.
7
6
  */
7
+ export { GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode } from "../vendors/stt.mjs";
8
8
  export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./client.mjs";
9
- export { GeminiSTT, GeminiSTTModels } from "./vendors.mjs";
9
+ export { OpenAIGPTLive } from "./vendors.mjs";
@@ -2,71 +2,73 @@
2
2
  * Preview provider vendor classes.
3
3
  *
4
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.
5
+ * camelCase constructor options in, snake_case wire config out — so they work
6
+ * with the corresponding Agent builder method. AgentSession routes them to the
7
+ * preview endpoint automatically.
8
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. */
9
+ import type { McpServersItem, MllmConfig, MllmTurnDetectionConfig } from "../types.mjs";
10
+ import { BaseMLLM } from "../vendors/base.mjs";
11
+ export declare const OPENAI_GPT_LIVE_VENDOR: "openai_gpt_live";
12
+ export declare function isOpenAIGPTLiveConfig(config: unknown): boolean;
13
+ /** GPT Live v3 alpha options. Not for production traffic. */
14
+ export interface OpenAIGPTLiveOptions {
25
15
  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>;
16
+ /** Full WebSocket URL, used verbatim except OpenAI's legacy /v1/live route. */
17
+ url?: string;
18
+ /** @deprecated Use prompt. Serialized as prompt; an explicit prompt wins. */
19
+ instructions?: string;
20
+ greeting?: string;
21
+ failureMessage?: string;
22
+ inputModalities?: string[];
23
+ outputModalities?: string[];
24
+ messages?: Record<string, unknown>[];
25
+ /** MCP servers exposed to GPT Live. Requires Agent.withTools(). */
26
+ mcpServers?: McpServersItem[];
27
+ /** Additional provider fields; explicit options take precedence. */
28
+ params?: Record<string, unknown>;
29
+ /** @deprecated Unsupported in v3; setting this raises an error. */
30
+ inputAudioTranscription?: Record<string, unknown>;
31
+ /** @deprecated Ignored with a warning; v3 performs endpointing internally. */
32
+ turnDetection?: MllmTurnDetectionConfig;
33
+ /** Defaults to gpt-live-1. */
34
+ model?: string;
35
+ /** Output voice; provider default marin. Custom voice objects require PR #1522; use params after rollout. */
36
+ voice?: string;
37
+ /** Session instructions. */
38
+ prompt?: string;
39
+ /** Host when url is omitted; default wss://api.openai.com. */
40
+ baseUrl?: string;
41
+ /** WebSocket path; default /v1/live/sessions. */
42
+ path?: string;
43
+ /** Optional OpenAI-Alpha selector for preview contracts. Omitted by default. */
44
+ alphaSelector?: string;
45
+ /** Extra provider request headers as a JSON string; protocol headers win. */
46
+ headers?: string;
47
+ /** Assistant silence boundary in ms; provider default 600. Zero disables inference. */
48
+ outputIdleEndMs?: number;
49
+ /** Caller silence boundary in ms; provider default 1500. */
50
+ inputIdleEndMs?: number;
51
+ /** Speech amplitude threshold on the 16-bit scale; provider default 50. */
52
+ outputSilencePeak?: number;
53
+ /** Graph PCM sample rate; provider default 24000. */
54
+ outputSampleRate?: number;
55
+ /** Initial audio cushion; provider default 0. Negative disables pacing. */
56
+ outputBufferMs?: number;
57
+ /** Mic append batching in ms. Join default 0; extension class default 100. */
58
+ inputBatchMs?: number;
59
+ /** Advertise graph tools; provider default false. Does not control delegate built-ins. */
60
+ toolEnabled?: boolean;
61
+ /** Tool delegation mode; provider default responses. Fixed for the session. */
62
+ delegation?: "client" | "responses";
63
+ /** Tool delegate model; provider default gpt-5.6-sol. */
64
+ responsesModel?: string;
65
+ /** Interrupt playback on caller speech; provider default false. */
66
+ interruptOnUserTurn?: boolean;
67
+ /** Unmodelled v3 session fields. Cannot override model, delegation, audio, instructions or input. */
68
+ sessionParams?: Record<string, unknown>;
56
69
  }
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 {
70
+ export declare class OpenAIGPTLive extends BaseMLLM {
69
71
  private readonly options;
70
- constructor(options: GeminiSTTOptions);
71
- toConfig(): SttConfig;
72
+ constructor(options: OpenAIGPTLiveOptions);
73
+ toConfig(): MllmConfig;
72
74
  }
@@ -2,48 +2,82 @@
2
2
  * Preview provider vendor classes.
3
3
  *
4
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.
5
+ * camelCase constructor options in, snake_case wire config out — so they work
6
+ * with the corresponding Agent builder method. AgentSession routes them to the
7
+ * preview endpoint automatically.
8
8
  */
9
- import { BaseSTT } from "../vendors/base.mjs";
9
+ import { BaseMLLM } from "../vendors/base.mjs";
10
10
  // =============================================================================
11
- // Gemini 3.5 Transcribe (ASR)
11
+ // OpenAI GPT Live (MLLM)
12
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 {
13
+ export const OPENAI_GPT_LIVE_VENDOR = "openai_gpt_live";
14
+ export function isOpenAIGPTLiveConfig(config) {
15
+ return (config === null || config === void 0 ? void 0 : config.vendor) === OPENAI_GPT_LIVE_VENDOR;
16
+ }
17
+ function normalizeMcpServers(servers) {
18
+ return servers.map((server) => (Object.assign({ transport: "streamable_http" }, server)));
19
+ }
20
+ export class OpenAIGPTLive extends BaseMLLM {
29
21
  constructor(options) {
30
22
  super();
31
- if (!options.apiKey) {
32
- throw new Error("GeminiSTT requires apiKey");
33
- }
34
23
  this.options = options;
24
+ if (!options.apiKey)
25
+ throw new Error("OpenAIGPTLive requires apiKey");
35
26
  }
36
27
  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
- };
28
+ var _a, _b;
29
+ const o = this.options;
30
+ 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 }));
31
+ if (o.inputAudioTranscription !== undefined || "input_audio_transcription" in params) {
32
+ throw new Error("GPT Live v3 does not support input_audio_transcription");
33
+ }
34
+ if (o.turnDetection !== undefined || "turn_detection" in params) {
35
+ console.warn("GPT Live v3 ignores turn_detection; endpointing is internal");
36
+ delete params.turn_detection;
37
+ }
38
+ if (params.delegation !== undefined && params.delegation !== "client" && params.delegation !== "responses") {
39
+ throw new Error("GPT Live delegation must be client or responses");
40
+ }
41
+ if (params.headers !== undefined) {
42
+ let headers;
43
+ try {
44
+ headers = JSON.parse(String(params.headers));
45
+ }
46
+ catch (_c) {
47
+ throw new Error("GPT Live headers must be a JSON object string");
48
+ }
49
+ if (headers === null || typeof headers !== "object" || Array.isArray(headers)) {
50
+ throw new Error("GPT Live headers must be a JSON object string");
51
+ }
52
+ }
53
+ const session = params.session_params === undefined ? {} : params.session_params;
54
+ if (session === null || typeof session !== "object" || Array.isArray(session)) {
55
+ throw new Error("GPT Live session_params must be an object");
56
+ }
57
+ for (const key of ["model", "delegation", "audio", "instructions", "input"]) {
58
+ if (key in session)
59
+ throw new Error(`GPT Live session_params cannot override ${key}`);
60
+ }
61
+ let url = o.url ||
62
+ `${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(/^\/+/, "")}`;
63
+ if (!/^wss?:\/\/[^/]/i.test(url)) {
64
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
65
+ }
66
+ let parsed;
67
+ try {
68
+ parsed = new URL(url);
69
+ }
70
+ catch (_d) {
71
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
72
+ }
73
+ if ((parsed.protocol !== "ws:" && parsed.protocol !== "wss:") || !parsed.hostname) {
74
+ throw new Error("GPT Live url must be a full ws:// or wss:// endpoint");
75
+ }
76
+ if (parsed.hostname === "api.openai.com" && parsed.pathname === "/v1/live") {
77
+ parsed.pathname = "/v1/live/sessions";
78
+ url = parsed.toString();
79
+ }
80
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ vendor: OPENAI_GPT_LIVE_VENDOR, api_key: o.apiKey, url,
81
+ 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) }));
48
82
  }
49
83
  }
@@ -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.mjs";
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.mjs";
6
6
  import type { AgentThinkAgentManagementRequest } from "../api/resources/agentManagement/client/requests/AgentThinkAgentManagementRequest.mjs";
7
7
  import type { PresetInput } from "./presets.mjs";
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.mjs";
8
+ import type { AvatarConfig, LlmConfig, LlmGreetingConfigs, LlmTool, McpServersItem, MllmConfig, SttConfig, TtsConfig } from "../types.mjs";
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
  */
@@ -17,6 +17,7 @@ class ScopedBaseLLM {
17
17
  this._templateVariables = options === null || options === void 0 ? void 0 : options.templateVariables;
18
18
  this._vendor = options === null || options === void 0 ? void 0 : options.vendor;
19
19
  this._mcpServers = options === null || options === void 0 ? void 0 : options.mcpServers;
20
+ this._tools = options === null || options === void 0 ? void 0 : options.tools;
20
21
  }
21
22
  get outputModalities() {
22
23
  return this._outputModalities;
@@ -40,6 +41,9 @@ class ScopedBaseLLM {
40
41
  return this._mcpServers;
41
42
  return this._mcpServers.map((s) => (s.transport ? s : Object.assign(Object.assign({}, s), { transport: "streamable_http" })));
42
43
  }
44
+ get tools() {
45
+ return this._tools;
46
+ }
43
47
  }
44
48
  export class BaseLLM extends ScopedBaseLLM {
45
49
  constructor(options) {
@@ -6,15 +6,17 @@ function requireString(value, field, vendor) {
6
6
  }
7
7
  export class FengmingSTT extends BaseCNSTT {
8
8
  constructor(options = {}) {
9
+ var _a;
9
10
  super();
11
+ if (Object.keys((_a = options.additionalParams) !== null && _a !== void 0 ? _a : {}).includes("keywords")) {
12
+ throw new Error("FengmingSTT additionalParams must not contain keywords; use the top-level keywords option");
13
+ }
10
14
  this.options = options;
11
15
  }
12
16
  toConfig() {
13
17
  const { keywords, additionalParams } = this.options;
14
- const hasParams = keywords !== undefined || (additionalParams !== undefined && Object.keys(additionalParams).length > 0);
15
- return Object.assign({ vendor: "fengming" }, (hasParams && {
16
- params: Object.assign(Object.assign({}, additionalParams), (keywords !== undefined && { keywords })),
17
- }));
18
+ const hasParams = additionalParams !== undefined && Object.keys(additionalParams).length > 0;
19
+ return Object.assign(Object.assign({ vendor: "fengming" }, (keywords !== undefined && { keywords })), (hasParams && { params: Object.assign({}, additionalParams) }));
18
20
  }
19
21
  }
20
22
  export class MicrosoftCNSTT extends BaseCNSTT {
@@ -212,7 +214,7 @@ export class StepFunTTS extends BaseCNTTS {
212
214
  }
213
215
  function cnLlmConfig(options, vendor) {
214
216
  var _a;
215
- 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 });
217
+ 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 });
216
218
  }
217
219
  export class AliyunLLM extends BaseCNLLM {
218
220
  constructor(options) {
@@ -57,7 +57,7 @@ export class OpenAI extends BaseLLM {
57
57
  const { apiKey, model, url, maxHistory, temperature, topP, maxTokens, systemMessages, greetingMessage, failureMessage, inputModalities, params, headers, } = this.options;
58
58
  return Object.assign(Object.assign({ url: url !== null && url !== void 0 ? url : "https://api.openai.com/v1/chat/completions" }, (apiKey && { api_key: apiKey })), {
59
59
  // model is the default; params entries extend it; named fields win.
60
- 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 });
60
+ 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 });
61
61
  }
62
62
  }
63
63
  /**
@@ -108,6 +108,7 @@ export class AzureOpenAI extends BaseLLM {
108
108
  greeting_configs: this.greetingConfigs,
109
109
  template_variables: this.templateVariables,
110
110
  mcp_servers: this.mcpServers,
111
+ tools: this.tools,
111
112
  };
112
113
  }
113
114
  }
@@ -155,6 +156,7 @@ export class Anthropic extends BaseLLM {
155
156
  greeting_configs: this.greetingConfigs,
156
157
  template_variables: this.templateVariables,
157
158
  mcp_servers: this.mcpServers,
159
+ tools: this.tools,
158
160
  };
159
161
  }
160
162
  }
@@ -199,6 +201,7 @@ export class Gemini extends BaseLLM {
199
201
  greeting_configs: this.greetingConfigs,
200
202
  template_variables: this.templateVariables,
201
203
  mcp_servers: this.mcpServers,
204
+ tools: this.tools,
202
205
  };
203
206
  }
204
207
  }
@@ -221,6 +224,7 @@ function openAIStyleConfig(options, vendor) {
221
224
  greeting_configs: options.greetingConfigs,
222
225
  template_variables: options.templateVariables,
223
226
  mcp_servers: options.mcpServers,
227
+ tools: options.tools,
224
228
  };
225
229
  }
226
230
  export class Groq extends BaseLLM {
@@ -277,6 +281,7 @@ export class VertexAILLM extends BaseLLM {
277
281
  greeting_configs: this.greetingConfigs,
278
282
  template_variables: this.templateVariables,
279
283
  mcp_servers: this.mcpServers,
284
+ tools: this.tools,
280
285
  };
281
286
  }
282
287
  }
@@ -312,6 +317,7 @@ export class AmazonBedrock extends BaseLLM {
312
317
  greeting_configs: this.greetingConfigs,
313
318
  template_variables: this.templateVariables,
314
319
  mcp_servers: this.mcpServers,
320
+ tools: this.tools,
315
321
  };
316
322
  }
317
323
  }
@@ -343,6 +349,7 @@ export class Dify extends BaseLLM {
343
349
  greeting_configs: this.greetingConfigs,
344
350
  template_variables: this.templateVariables,
345
351
  mcp_servers: this.mcpServers,
352
+ tools: this.tools,
346
353
  };
347
354
  }
348
355
  }