agora-agents 2.6.1 → 2.8.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.
- package/README.md +3 -3
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/agentkit/Agent.d.ts +1 -1
- package/dist/cjs/agentkit/Agent.js +28 -4
- package/dist/cjs/agentkit/AgentSession.d.ts +24 -0
- package/dist/cjs/agentkit/AgentSession.js +95 -23
- package/dist/cjs/agentkit/debug.d.ts +31 -0
- package/dist/cjs/agentkit/debug.js +143 -0
- package/dist/cjs/agentkit/index.d.ts +8 -3
- package/dist/cjs/agentkit/index.js +19 -3
- package/dist/cjs/agentkit/preview/client.d.ts +59 -0
- package/dist/cjs/agentkit/preview/client.js +94 -0
- package/dist/cjs/agentkit/preview/index.d.ts +12 -0
- package/dist/cjs/agentkit/preview/index.js +22 -0
- package/dist/cjs/agentkit/preview/vendors.d.ts +74 -0
- package/dist/cjs/agentkit/preview/vendors.js +88 -0
- package/dist/cjs/agentkit/token.js +32 -3
- package/dist/cjs/agentkit/types.d.ts +27 -6
- package/dist/cjs/agentkit/vendors/base.d.ts +6 -2
- package/dist/cjs/agentkit/vendors/base.js +4 -0
- package/dist/cjs/agentkit/vendors/cn.js +7 -5
- package/dist/cjs/agentkit/vendors/llm.js +8 -1
- package/dist/cjs/agentkit/vendors/stt.d.ts +45 -2
- package/dist/cjs/agentkit/vendors/stt.js +53 -5
- package/dist/cjs/agentkit/vendors/tts.js +1 -1
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.d.ts +12 -20
- package/dist/cjs/api/resources/agents/client/requests/StartAgentsRequest.js +1 -1
- package/dist/cjs/api/types/Asr.d.ts +4 -1
- package/dist/cjs/api/types/GeminiAsr.d.ts +10 -0
- package/dist/cjs/api/types/GeminiAsr.js +3 -0
- package/dist/cjs/api/types/GeminiAsrParams.d.ts +33 -0
- package/dist/cjs/api/types/GeminiAsrParams.js +12 -0
- package/dist/cjs/api/types/index.d.ts +2 -0
- package/dist/cjs/api/types/index.js +2 -0
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.js +15 -3
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/agentkit/Agent.d.mts +1 -1
- package/dist/esm/agentkit/Agent.mjs +28 -4
- package/dist/esm/agentkit/AgentSession.d.mts +24 -0
- package/dist/esm/agentkit/AgentSession.mjs +95 -23
- package/dist/esm/agentkit/debug.d.mts +31 -0
- package/dist/esm/agentkit/debug.mjs +138 -0
- package/dist/esm/agentkit/index.d.mts +8 -3
- package/dist/esm/agentkit/index.mjs +4 -1
- package/dist/esm/agentkit/preview/client.d.mts +59 -0
- package/dist/esm/agentkit/preview/client.mjs +88 -0
- package/dist/esm/agentkit/preview/index.d.mts +12 -0
- package/dist/esm/agentkit/preview/index.mjs +9 -0
- package/dist/esm/agentkit/preview/vendors.d.mts +74 -0
- package/dist/esm/agentkit/preview/vendors.mjs +83 -0
- package/dist/esm/agentkit/token.mjs +32 -3
- package/dist/esm/agentkit/types.d.mts +27 -6
- package/dist/esm/agentkit/vendors/base.d.mts +6 -2
- package/dist/esm/agentkit/vendors/base.mjs +4 -0
- package/dist/esm/agentkit/vendors/cn.mjs +7 -5
- package/dist/esm/agentkit/vendors/llm.mjs +8 -1
- package/dist/esm/agentkit/vendors/stt.d.mts +45 -2
- package/dist/esm/agentkit/vendors/stt.mjs +51 -4
- package/dist/esm/agentkit/vendors/tts.mjs +1 -1
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.d.mts +12 -20
- package/dist/esm/api/resources/agents/client/requests/StartAgentsRequest.mjs +1 -1
- package/dist/esm/api/types/Asr.d.mts +4 -1
- package/dist/esm/api/types/GeminiAsr.d.mts +10 -0
- package/dist/esm/api/types/GeminiAsr.mjs +2 -0
- package/dist/esm/api/types/GeminiAsrParams.d.mts +33 -0
- package/dist/esm/api/types/GeminiAsrParams.mjs +9 -0
- package/dist/esm/api/types/index.d.mts +2 -0
- package/dist/esm/api/types/index.mjs +2 -0
- package/dist/esm/index.d.mts +2 -2
- package/dist/esm/index.mjs +4 -4
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +4 -2
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.d.ts +0 -1
- package/dist/cjs/agentkit/__tests__/area-aware-vendors.test.js +0 -87
- package/dist/cjs/agentkit/__tests__/readme-examples.test.d.ts +0 -1
- package/dist/cjs/agentkit/__tests__/readme-examples.test.js +0 -126
- package/dist/cjs/agentkit/__tests__/type-safety.test.d.ts +0 -14
- package/dist/cjs/agentkit/__tests__/type-safety.test.js +0 -321
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.d.mts +0 -1
- package/dist/esm/agentkit/__tests__/area-aware-vendors.test.mjs +0 -85
- package/dist/esm/agentkit/__tests__/readme-examples.test.d.mts +0 -1
- package/dist/esm/agentkit/__tests__/readme-examples.test.mjs +0 -124
- package/dist/esm/agentkit/__tests__/type-safety.test.d.mts +0 -14
- package/dist/esm/agentkit/__tests__/type-safety.test.mjs +0 -319
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
* parts that need manual updates when adding new sugar.
|
|
21
21
|
*/
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.XAiTTS = exports.TypecastTTS = exports.SarvamTTS = exports.RimeTTS = exports.OpenAITTS = exports.MurfTTS = exports.MistralTTS = exports.MiniMaxTTS = exports.MicrosoftTTS = exports.HumeAITTS = exports.GradiumTTS = exports.GoogleTTS = exports.GenericTTS = exports.FishAudioTTS = exports.ElevenLabsTTS = exports.DeepgramTTS = exports.CartesiaTTS = exports.AmazonTTS = exports.XAiSTT = exports.SpeechmaticsSTT = exports.SarvamSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.GoogleSTT = exports.DeepgramSTT = void 0;
|
|
23
|
+
exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.createPreviewRoute = exports.normalizePresetInput = exports.AgentPresets = exports.redactSecrets = exports.redactHeadersForDebug = exports.REDACTED = exports.TurnDetectionTypeValues = exports.ThinkOnThinkingActionInterrupt = exports.ThinkOnThinkingActionIgnore = exports.ThinkOnSpeakingActionInterrupt = exports.ThinkOnSpeakingActionIgnore = exports.ThinkOnListeningActionInterrupt = exports.ThinkOnListeningActionInject = exports.ThinkOnListeningActionIgnore = exports.SpeakPriorityValues = exports.SpeakPriorityInterrupt = exports.SpeakPriorityIgnore = exports.SpeakPriorityAppend = exports.SilenceActionValues = exports.SalModeValues = exports.MllmTurnDetectionModeValues = exports.MllmTurnDetectionModeServerVad = exports.MllmTurnDetectionModeSemanticVad = exports.MllmTurnDetectionModeAgoraVad = exports.InterruptionModeValues = exports.InterruptionModeStartOfSpeech = exports.InterruptionModeKeywords = exports.InterruptionDisabledStrategyIgnore = exports.InterruptionDisabledStrategyAppend = exports.InterruptionDisabledStrategy = exports.Geofence = exports.FillerWordsSelectionRule = exports.DataChannel = exports.CredentialMode = exports.AudioScenario = exports.validateTtsSampleRate = exports.validateAvatarConfig = exports.toBaseAvatarConfig = exports.isSpatiusAvatar = exports.isSensetimeAvatar = exports.isLiveAvatarAvatar = exports.isHeyGenAvatar = exports.isGenericAvatar = exports.isAvatarTokenManaged = exports.isAnamAvatar = exports.isAkoolAvatar = exports.AgentSession = exports.Agent = void 0;
|
|
24
|
+
exports.OpenAI = exports.Groq = exports.Gemini = exports.Dify = exports.CustomLLM = exports.AzureOpenAI = exports.Anthropic = exports.AmazonBedrock = exports.XfyunSTT = exports.XfyunDialectSTT = exports.XfyunBigModelSTT = exports.TencentTTS = exports.TencentSTT = exports.TencentLLM = exports.StepFunTTS = exports.SpatiusAvatar = exports.SensetimeAvatar = exports.MiniMaxCNTTS = exports.MicrosoftCNTTS = exports.MicrosoftCNSTT = exports.FengmingSTT = exports.DeepSeekLLM = exports.CosyVoiceTTS = exports.BytedanceTTS = exports.BytedanceLLM = exports.BytedanceDuplexTTS = exports.AliyunLLM = exports.BaseTTS = exports.BaseSTT = exports.BaseMLLM = exports.BaseLLM = exports.BaseCNTTS = exports.BaseCNSTT = exports.BaseCNMLLM = exports.BaseCNLLM = exports.BaseCNAvatar = exports.BaseAvatar = exports.LiveAvatarAvatar = exports.HeyGenAvatar = exports.GenericAvatar = exports.AnamAvatar = exports.AkoolAvatar = exports.MAX_EXPIRY_SECONDS = exports.generateRtcToken = exports.generateConvoAIToken = exports.ExpiresIn = exports.OpenAIGPTLive = exports.requiredPreviewFeatures = exports.previewRequestHeaders = exports.PreviewFeatures = void 0;
|
|
25
|
+
exports.XAiTTS = exports.TypecastTTS = exports.SarvamTTS = exports.RimeTTS = exports.OpenAITTS = exports.MurfTTS = exports.MistralTTS = exports.MiniMaxTTS = exports.MicrosoftTTS = exports.HumeAITTS = exports.GradiumTTS = exports.GoogleTTS = exports.GenericTTS = exports.FishAudioTTS = exports.ElevenLabsTTS = exports.DeepgramTTS = exports.CartesiaTTS = exports.AmazonTTS = exports.XAiSTT = exports.SpeechmaticsSTT = exports.SarvamSTT = exports.OpenAISTT = exports.MicrosoftSTT = exports.GoogleSTT = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = exports.GeminiSTT = exports.DeepgramSTT = exports.AssemblyAISTT = exports.AresSTT = exports.AmazonSTT = exports.XaiGrok = exports.VertexAI = exports.QwenOmni = exports.OpenAIRealtime = exports.GeminiLive = exports.AzureOpenAIRealtime = exports.VertexAILLM = void 0;
|
|
26
26
|
// Core classes
|
|
27
27
|
var Agent_js_1 = require("./Agent.js");
|
|
28
28
|
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return Agent_js_1.Agent; } });
|
|
@@ -71,9 +71,22 @@ Object.defineProperty(exports, "ThinkOnSpeakingActionInterrupt", { enumerable: t
|
|
|
71
71
|
Object.defineProperty(exports, "ThinkOnThinkingActionIgnore", { enumerable: true, get: function () { return constants_js_1.ThinkOnThinkingActionIgnore; } });
|
|
72
72
|
Object.defineProperty(exports, "ThinkOnThinkingActionInterrupt", { enumerable: true, get: function () { return constants_js_1.ThinkOnThinkingActionInterrupt; } });
|
|
73
73
|
Object.defineProperty(exports, "TurnDetectionTypeValues", { enumerable: true, get: function () { return constants_js_1.TurnDetectionTypeValues; } });
|
|
74
|
+
var debug_js_1 = require("./debug.js");
|
|
75
|
+
Object.defineProperty(exports, "REDACTED", { enumerable: true, get: function () { return debug_js_1.REDACTED; } });
|
|
76
|
+
Object.defineProperty(exports, "redactHeadersForDebug", { enumerable: true, get: function () { return debug_js_1.redactHeadersForDebug; } });
|
|
77
|
+
Object.defineProperty(exports, "redactSecrets", { enumerable: true, get: function () { return debug_js_1.redactSecrets; } });
|
|
74
78
|
var presets_js_1 = require("./presets.js");
|
|
75
79
|
Object.defineProperty(exports, "AgentPresets", { enumerable: true, get: function () { return presets_js_1.AgentPresets; } });
|
|
76
80
|
Object.defineProperty(exports, "normalizePresetInput", { enumerable: true, get: function () { return presets_js_1.normalizePresetInput; } });
|
|
81
|
+
var client_js_1 = require("./preview/client.js");
|
|
82
|
+
Object.defineProperty(exports, "createPreviewRoute", { enumerable: true, get: function () { return client_js_1.createPreviewRoute; } });
|
|
83
|
+
Object.defineProperty(exports, "PREVIEW_API_BASE_URL", { enumerable: true, get: function () { return client_js_1.PREVIEW_API_BASE_URL; } });
|
|
84
|
+
Object.defineProperty(exports, "PREVIEW_FEATURE_HEADER", { enumerable: true, get: function () { return client_js_1.PREVIEW_FEATURE_HEADER; } });
|
|
85
|
+
Object.defineProperty(exports, "PreviewFeatures", { enumerable: true, get: function () { return client_js_1.PreviewFeatures; } });
|
|
86
|
+
Object.defineProperty(exports, "previewRequestHeaders", { enumerable: true, get: function () { return client_js_1.previewRequestHeaders; } });
|
|
87
|
+
Object.defineProperty(exports, "requiredPreviewFeatures", { enumerable: true, get: function () { return client_js_1.requiredPreviewFeatures; } });
|
|
88
|
+
var vendors_js_1 = require("./preview/vendors.js");
|
|
89
|
+
Object.defineProperty(exports, "OpenAIGPTLive", { enumerable: true, get: function () { return vendors_js_1.OpenAIGPTLive; } });
|
|
77
90
|
// Token generation
|
|
78
91
|
var token_js_1 = require("./token.js");
|
|
79
92
|
Object.defineProperty(exports, "ExpiresIn", { enumerable: true, get: function () { return token_js_1.ExpiresIn; } });
|
|
@@ -144,6 +157,9 @@ Object.defineProperty(exports, "AmazonSTT", { enumerable: true, get: function ()
|
|
|
144
157
|
Object.defineProperty(exports, "AresSTT", { enumerable: true, get: function () { return stt_js_1.AresSTT; } });
|
|
145
158
|
Object.defineProperty(exports, "AssemblyAISTT", { enumerable: true, get: function () { return stt_js_1.AssemblyAISTT; } });
|
|
146
159
|
Object.defineProperty(exports, "DeepgramSTT", { enumerable: true, get: function () { return stt_js_1.DeepgramSTT; } });
|
|
160
|
+
Object.defineProperty(exports, "GeminiSTT", { enumerable: true, get: function () { return stt_js_1.GeminiSTT; } });
|
|
161
|
+
Object.defineProperty(exports, "GeminiSTTModels", { enumerable: true, get: function () { return stt_js_1.GeminiSTTModels; } });
|
|
162
|
+
Object.defineProperty(exports, "GeminiTranscriptionMode", { enumerable: true, get: function () { return stt_js_1.GeminiTranscriptionMode; } });
|
|
147
163
|
Object.defineProperty(exports, "GoogleSTT", { enumerable: true, get: function () { return stt_js_1.GoogleSTT; } });
|
|
148
164
|
Object.defineProperty(exports, "MicrosoftSTT", { enumerable: true, get: function () { return stt_js_1.MicrosoftSTT; } });
|
|
149
165
|
Object.defineProperty(exports, "OpenAISTT", { enumerable: true, get: function () { return stt_js_1.OpenAISTT; } });
|
|
@@ -0,0 +1,59 @@
|
|
|
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 a provider ships on
|
|
11
|
+
* the production gateway, remove its preview registration and move its class
|
|
12
|
+
* into the corresponding production vendor module.
|
|
13
|
+
*/
|
|
14
|
+
import type { AgoraClient } from "../../AgoraPoolClient.js";
|
|
15
|
+
import type * as Agora from "../../api/index.js";
|
|
16
|
+
import { AgentManagementClient } from "../../api/resources/agentManagement/client/Client.js";
|
|
17
|
+
import { AgentsClient } from "../../api/resources/agents/client/Client.js";
|
|
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
|
+
/** @deprecated Gemini ASR now uses the production endpoint. */
|
|
35
|
+
readonly GeminiLive: "gemini-live";
|
|
36
|
+
readonly LiveModels: "live-models";
|
|
37
|
+
};
|
|
38
|
+
/** A preview provider family gate value. */
|
|
39
|
+
export type PreviewFeature = (typeof PreviewFeatures)[keyof typeof PreviewFeatures];
|
|
40
|
+
/** Session-scoped clients bound to one resolved route. */
|
|
41
|
+
export interface PreviewRoute {
|
|
42
|
+
readonly agents: AgentsClient;
|
|
43
|
+
readonly agentManagement: AgentManagementClient;
|
|
44
|
+
readonly baseUrl: string;
|
|
45
|
+
readonly features: readonly PreviewFeature[];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Pins the gate after any caller headers. This is also used for per-call auth
|
|
49
|
+
* headers so a custom `agora-feature` value can never blank the session gate.
|
|
50
|
+
*/
|
|
51
|
+
export declare function previewRequestHeaders(features: readonly PreviewFeature[], headers?: Record<string, string>): Record<string, string>;
|
|
52
|
+
/** Build generated resource clients for one preview session. */
|
|
53
|
+
export declare function createPreviewRoute(client: AgoraClient, features: readonly PreviewFeature[]): PreviewRoute;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the preview features a start request needs, derived from the request
|
|
56
|
+
* body rather than from the vendor classes — so hand-written configs are
|
|
57
|
+
* covered too.
|
|
58
|
+
*/
|
|
59
|
+
export declare function requiredPreviewFeatures(properties: Agora.StartAgentsRequest.Properties): PreviewFeature[];
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Preview endpoint routing.
|
|
4
|
+
*
|
|
5
|
+
* Preview providers are not served by the production Conversational AI gateway.
|
|
6
|
+
* They live behind a single partner host and are gated by an `agora-feature`
|
|
7
|
+
* header. AgentSession detects preview providers from its resolved request body
|
|
8
|
+
* and binds that session to the preview host while ordinary AgoraClient calls
|
|
9
|
+
* remain on the regional production endpoint.
|
|
10
|
+
*
|
|
11
|
+
* Everything under `agentkit/preview/` is temporary. When a provider ships on
|
|
12
|
+
* the production gateway, remove its preview registration and move its class
|
|
13
|
+
* into the corresponding production vendor module.
|
|
14
|
+
*/
|
|
15
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
17
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
18
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
19
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
20
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
21
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = void 0;
|
|
26
|
+
exports.previewRequestHeaders = previewRequestHeaders;
|
|
27
|
+
exports.createPreviewRoute = createPreviewRoute;
|
|
28
|
+
exports.requiredPreviewFeatures = requiredPreviewFeatures;
|
|
29
|
+
const Client_js_1 = require("../../api/resources/agentManagement/client/Client.js");
|
|
30
|
+
const Client_js_2 = require("../../api/resources/agents/client/Client.js");
|
|
31
|
+
const vendors_js_1 = require("./vendors.js");
|
|
32
|
+
/** Base URL that serves the preview providers. */
|
|
33
|
+
exports.PREVIEW_API_BASE_URL = "https://partner.ai.agora.io/preview/api/conversational-ai-agent";
|
|
34
|
+
/**
|
|
35
|
+
* Request header that opts a request into a preview provider family.
|
|
36
|
+
*
|
|
37
|
+
* This is the header the preview gateway routes on. A request that reaches the
|
|
38
|
+
* gateway without it is not rejected — it is routed to the production
|
|
39
|
+
* environment, where the preview providers do not exist.
|
|
40
|
+
*/
|
|
41
|
+
exports.PREVIEW_FEATURE_HEADER = "agora-feature";
|
|
42
|
+
/**
|
|
43
|
+
* Preview provider families. Each value is one entry in the
|
|
44
|
+
* {@link PREVIEW_FEATURE_HEADER} header and gates a set of vendors on the
|
|
45
|
+
* preview endpoint.
|
|
46
|
+
*/
|
|
47
|
+
exports.PreviewFeatures = {
|
|
48
|
+
/** @deprecated Gemini ASR now uses the production endpoint. */
|
|
49
|
+
GeminiLive: "gemini-live",
|
|
50
|
+
LiveModels: "live-models",
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Pins the gate after any caller headers. This is also used for per-call auth
|
|
54
|
+
* headers so a custom `agora-feature` value can never blank the session gate.
|
|
55
|
+
*/
|
|
56
|
+
function previewRequestHeaders(features, headers) {
|
|
57
|
+
return Object.assign(Object.assign({}, headers), { [exports.PREVIEW_FEATURE_HEADER]: features.join(",") });
|
|
58
|
+
}
|
|
59
|
+
/** Build generated resource clients for one preview session. */
|
|
60
|
+
function createPreviewRoute(client, features) {
|
|
61
|
+
var _a;
|
|
62
|
+
const clientOptions = client._options;
|
|
63
|
+
const fetchFn = (_a = clientOptions.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch;
|
|
64
|
+
const options = Object.assign(Object.assign({}, clientOptions), { baseUrl: exports.PREVIEW_API_BASE_URL, headers: previewRequestHeaders(features, clientOptions.headers), fetch: (input, init) => __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
const headers = new Headers(init === null || init === void 0 ? void 0 : init.headers);
|
|
66
|
+
headers.set(exports.PREVIEW_FEATURE_HEADER, features.join(","));
|
|
67
|
+
return fetchFn(input, Object.assign(Object.assign({}, init), { headers }));
|
|
68
|
+
}) });
|
|
69
|
+
return {
|
|
70
|
+
agents: new Client_js_2.AgentsClient(options),
|
|
71
|
+
agentManagement: new Client_js_1.AgentManagementClient(options),
|
|
72
|
+
baseUrl: exports.PREVIEW_API_BASE_URL,
|
|
73
|
+
features: [...features],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** ASR vendor served only by the preview endpoint. */
|
|
77
|
+
const PREVIEW_ASR_VENDORS = new Set();
|
|
78
|
+
/**
|
|
79
|
+
* Returns the preview features a start request needs, derived from the request
|
|
80
|
+
* body rather than from the vendor classes — so hand-written configs are
|
|
81
|
+
* covered too.
|
|
82
|
+
*/
|
|
83
|
+
function requiredPreviewFeatures(properties) {
|
|
84
|
+
var _a;
|
|
85
|
+
const features = new Set();
|
|
86
|
+
const asrVendor = (_a = properties.asr) === null || _a === void 0 ? void 0 : _a.vendor;
|
|
87
|
+
if (asrVendor !== undefined && PREVIEW_ASR_VENDORS.has(asrVendor)) {
|
|
88
|
+
features.add(exports.PreviewFeatures.GeminiLive);
|
|
89
|
+
}
|
|
90
|
+
if ((0, vendors_js_1.isOpenAIGPTLiveConfig)(properties.mllm)) {
|
|
91
|
+
features.add(exports.PreviewFeatures.LiveModels);
|
|
92
|
+
}
|
|
93
|
+
return [...features];
|
|
94
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Preview provider surface.
|
|
3
|
+
*
|
|
4
|
+
* Preview routing stays here while provider implementations can graduate to
|
|
5
|
+
* the production vendor modules independently.
|
|
6
|
+
*/
|
|
7
|
+
export type { GeminiSTTModel, GeminiSTTOptions } from "../vendors/stt.js";
|
|
8
|
+
export { GeminiSTT, GeminiSTTModels, GeminiTranscriptionMode } from "../vendors/stt.js";
|
|
9
|
+
export type { PreviewFeature, PreviewRoute } from "./client.js";
|
|
10
|
+
export { createPreviewRoute, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, previewRequestHeaders, requiredPreviewFeatures, } from "./client.js";
|
|
11
|
+
export type { OpenAIGPTLiveOptions } from "./vendors.js";
|
|
12
|
+
export { OpenAIGPTLive } from "./vendors.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Preview provider surface.
|
|
4
|
+
*
|
|
5
|
+
* Preview routing stays here while provider implementations can graduate to
|
|
6
|
+
* the production vendor modules independently.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.OpenAIGPTLive = exports.requiredPreviewFeatures = exports.previewRequestHeaders = exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.createPreviewRoute = exports.GeminiTranscriptionMode = exports.GeminiSTTModels = exports.GeminiSTT = void 0;
|
|
10
|
+
var stt_js_1 = require("../vendors/stt.js");
|
|
11
|
+
Object.defineProperty(exports, "GeminiSTT", { enumerable: true, get: function () { return stt_js_1.GeminiSTT; } });
|
|
12
|
+
Object.defineProperty(exports, "GeminiSTTModels", { enumerable: true, get: function () { return stt_js_1.GeminiSTTModels; } });
|
|
13
|
+
Object.defineProperty(exports, "GeminiTranscriptionMode", { enumerable: true, get: function () { return stt_js_1.GeminiTranscriptionMode; } });
|
|
14
|
+
var client_js_1 = require("./client.js");
|
|
15
|
+
Object.defineProperty(exports, "createPreviewRoute", { enumerable: true, get: function () { return client_js_1.createPreviewRoute; } });
|
|
16
|
+
Object.defineProperty(exports, "PREVIEW_API_BASE_URL", { enumerable: true, get: function () { return client_js_1.PREVIEW_API_BASE_URL; } });
|
|
17
|
+
Object.defineProperty(exports, "PREVIEW_FEATURE_HEADER", { enumerable: true, get: function () { return client_js_1.PREVIEW_FEATURE_HEADER; } });
|
|
18
|
+
Object.defineProperty(exports, "PreviewFeatures", { enumerable: true, get: function () { return client_js_1.PreviewFeatures; } });
|
|
19
|
+
Object.defineProperty(exports, "previewRequestHeaders", { enumerable: true, get: function () { return client_js_1.previewRequestHeaders; } });
|
|
20
|
+
Object.defineProperty(exports, "requiredPreviewFeatures", { enumerable: true, get: function () { return client_js_1.requiredPreviewFeatures; } });
|
|
21
|
+
var vendors_js_1 = require("./vendors.js");
|
|
22
|
+
Object.defineProperty(exports, "OpenAIGPTLive", { enumerable: true, get: function () { return vendors_js_1.OpenAIGPTLive; } });
|
|
@@ -0,0 +1,74 @@
|
|
|
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 work
|
|
6
|
+
* with the corresponding Agent builder method. AgentSession routes them to the
|
|
7
|
+
* preview endpoint automatically.
|
|
8
|
+
*/
|
|
9
|
+
import type { McpServersItem, MllmConfig, MllmTurnDetectionConfig } from "../types.js";
|
|
10
|
+
import { BaseMLLM } from "../vendors/base.js";
|
|
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 {
|
|
15
|
+
apiKey: string;
|
|
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-diamond-alpha. */
|
|
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
|
+
/** OpenAI-Alpha selector. Defaults to the required GPT Live v3 contract. */
|
|
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>;
|
|
69
|
+
}
|
|
70
|
+
export declare class OpenAIGPTLive extends BaseMLLM {
|
|
71
|
+
private readonly options;
|
|
72
|
+
constructor(options: OpenAIGPTLiveOptions);
|
|
73
|
+
toConfig(): MllmConfig;
|
|
74
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Preview provider vendor classes.
|
|
4
|
+
*
|
|
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 work
|
|
7
|
+
* with the corresponding Agent builder method. AgentSession routes them to the
|
|
8
|
+
* preview endpoint automatically.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.OpenAIGPTLive = exports.OPENAI_GPT_LIVE_VENDOR = void 0;
|
|
12
|
+
exports.isOpenAIGPTLiveConfig = isOpenAIGPTLiveConfig;
|
|
13
|
+
const base_js_1 = require("../vendors/base.js");
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// OpenAI GPT Live (MLLM)
|
|
16
|
+
// =============================================================================
|
|
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 {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
super();
|
|
27
|
+
this.options = options;
|
|
28
|
+
if (!options.apiKey)
|
|
29
|
+
throw new Error("OpenAIGPTLive requires apiKey");
|
|
30
|
+
}
|
|
31
|
+
toConfig() {
|
|
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-diamond-alpha", alpha_selector: "quicksilver=v3" }, 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) }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.OpenAIGPTLive = OpenAIGPTLive;
|
|
@@ -20,6 +20,35 @@ exports.generateConvoAIToken = generateConvoAIToken;
|
|
|
20
20
|
const agora_token_1 = __importDefault(require("agora-token"));
|
|
21
21
|
const DEFAULT_EXPIRY_SECONDS = 86400;
|
|
22
22
|
exports.MAX_EXPIRY_SECONDS = 86400;
|
|
23
|
+
/**
|
|
24
|
+
* Length `agora-token` requires of both the app ID and the app certificate.
|
|
25
|
+
* Either one being a different length yields an empty token.
|
|
26
|
+
*/
|
|
27
|
+
const AGORA_CREDENTIAL_LENGTH = 32;
|
|
28
|
+
/**
|
|
29
|
+
* Rejects the empty string `agora-token` returns for a malformed credential.
|
|
30
|
+
*
|
|
31
|
+
* The builders validate nothing and never throw — they hand back `""` whenever
|
|
32
|
+
* `appId` or `appCertificate` is not exactly {@link AGORA_CREDENTIAL_LENGTH}
|
|
33
|
+
* characters. That empty token is then sent as `token: ""`, and the failure
|
|
34
|
+
* surfaces as an opaque gateway auth error naming neither field. A value pasted
|
|
35
|
+
* with a trailing newline or a stray space is enough to trigger it, so fail
|
|
36
|
+
* here, where the cause is still visible.
|
|
37
|
+
*
|
|
38
|
+
* Credential values are never included in the message — only their lengths.
|
|
39
|
+
*/
|
|
40
|
+
function _requireBuiltToken(token, appId, appCertificate) {
|
|
41
|
+
if (token) {
|
|
42
|
+
return token;
|
|
43
|
+
}
|
|
44
|
+
const wrong = [["appId", appId], ["appCertificate", appCertificate]].filter(([, value]) => value.length !== AGORA_CREDENTIAL_LENGTH);
|
|
45
|
+
const detail = wrong.length > 0
|
|
46
|
+
? wrong.map(([name, value]) => `${name} is ${value.length} characters`).join(" and ")
|
|
47
|
+
: "both are the right length, so the values themselves were rejected";
|
|
48
|
+
throw new Error(`Failed to build an Agora token: appId and appCertificate must each be exactly ` +
|
|
49
|
+
`${AGORA_CREDENTIAL_LENGTH} characters (${detail}). ` +
|
|
50
|
+
"Check the values for stray whitespace or a truncated paste.");
|
|
51
|
+
}
|
|
23
52
|
/**
|
|
24
53
|
* Convenience helpers for specifying token expiry durations.
|
|
25
54
|
*
|
|
@@ -91,7 +120,7 @@ function _validateExpiresIn(secs) {
|
|
|
91
120
|
function generateRtcToken(opts) {
|
|
92
121
|
var _a, _b;
|
|
93
122
|
const expiry = (_a = opts.expirySeconds) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRY_SECONDS;
|
|
94
|
-
return agora_token_1.default.RtcTokenBuilder.buildTokenWithUid(opts.appId, opts.appCertificate, opts.channel, opts.uid, (_b = opts.role) !== null && _b !== void 0 ? _b : agora_token_1.default.RtcRole.PUBLISHER, expiry, expiry);
|
|
123
|
+
return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithUid(opts.appId, opts.appCertificate, opts.channel, opts.uid, (_b = opts.role) !== null && _b !== void 0 ? _b : agora_token_1.default.RtcRole.PUBLISHER, expiry, expiry), opts.appId, opts.appCertificate);
|
|
95
124
|
}
|
|
96
125
|
/**
|
|
97
126
|
* Builds a short-lived RTC token for a string UID (user account).
|
|
@@ -105,7 +134,7 @@ function generateRtcToken(opts) {
|
|
|
105
134
|
function generateRtcTokenWithAccount(opts) {
|
|
106
135
|
var _a, _b;
|
|
107
136
|
const expiry = (_a = opts.expirySeconds) !== null && _a !== void 0 ? _a : DEFAULT_EXPIRY_SECONDS;
|
|
108
|
-
return agora_token_1.default.RtcTokenBuilder.buildTokenWithUserAccount(opts.appId, opts.appCertificate, opts.channel, opts.account, (_b = opts.role) !== null && _b !== void 0 ? _b : agora_token_1.default.RtcRole.PUBLISHER, expiry, expiry);
|
|
137
|
+
return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithUserAccount(opts.appId, opts.appCertificate, opts.channel, opts.account, (_b = opts.role) !== null && _b !== void 0 ? _b : agora_token_1.default.RtcRole.PUBLISHER, expiry, expiry), opts.appId, opts.appCertificate);
|
|
109
138
|
}
|
|
110
139
|
/**
|
|
111
140
|
* Builds a combined RTC + RTM token for ConvoAI REST API authentication.
|
|
@@ -123,7 +152,7 @@ function generateConvoAIToken(opts) {
|
|
|
123
152
|
const configuredPrivilegeExpire = (_b = opts.privilegeExpire) !== null && _b !== void 0 ? _b : 0;
|
|
124
153
|
const privilegeExpire = configuredPrivilegeExpire === 0 ? tokenExpire : configuredPrivilegeExpire;
|
|
125
154
|
const account = _uidToAccount(opts.uid);
|
|
126
|
-
return agora_token_1.default.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agora_token_1.default.RtcRole.PUBLISHER, tokenExpire, privilegeExpire);
|
|
155
|
+
return _requireBuiltToken(agora_token_1.default.RtcTokenBuilder.buildTokenWithRtm(opts.appId, opts.appCertificate, opts.channelName, account, agora_token_1.default.RtcRole.PUBLISHER, tokenExpire, privilegeExpire), opts.appId, opts.appCertificate);
|
|
127
156
|
}
|
|
128
157
|
function _uidToAccount(uid) {
|
|
129
158
|
if (!Number.isInteger(uid)) {
|
|
@@ -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";
|
|
@@ -72,6 +74,10 @@ export type SttConfig = {
|
|
|
72
74
|
vendor: "xai";
|
|
73
75
|
language?: TurnDetectionLanguage;
|
|
74
76
|
params: XAiAsrParams;
|
|
77
|
+
} | {
|
|
78
|
+
vendor: "gemini";
|
|
79
|
+
language?: TurnDetectionLanguage;
|
|
80
|
+
params: GeminiAsrParams;
|
|
75
81
|
} | Asr;
|
|
76
82
|
/** ASR configuration — alias for {@link SttConfig} (wire field: `asr`). */
|
|
77
83
|
export type AsrConfig = SttConfig;
|
|
@@ -79,10 +85,17 @@ export type AsrConfig = SttConfig;
|
|
|
79
85
|
export type AsrVendorName = string;
|
|
80
86
|
/** TTS (Text-to-Speech) configuration - discriminated union */
|
|
81
87
|
export type TtsConfig = Tts;
|
|
82
|
-
/**
|
|
83
|
-
export type
|
|
84
|
-
|
|
85
|
-
export type
|
|
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>;
|
|
86
99
|
/** Avatar configuration */
|
|
87
100
|
export type AvatarConfig = StartAgentsRequest.Properties.Avatar;
|
|
88
101
|
/** Avatar vendor (akool, liveavatar, anam, generic, deprecated heygen) */
|
|
@@ -202,6 +215,10 @@ export type FillerWordsTriggerFixedTimeConfig = StartAgentsRequest.Properties.Fi
|
|
|
202
215
|
export type FillerWordsContent = StartAgentsRequest.Properties.FillerWords.Content;
|
|
203
216
|
/** Static filler word content config (`content.static_config`) */
|
|
204
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;
|
|
205
222
|
/** Filler word selection rule: `"shuffle"` | `"round_robin"` */
|
|
206
223
|
export type FillerWordsContentSelectionRule = StartAgentsRequest.Properties.FillerWords.Content.StaticConfig.SelectionRule;
|
|
207
224
|
/** Custom business labels attached to the agent (returned in notification callbacks) */
|
|
@@ -210,7 +227,7 @@ export type Labels = Record<string, string>;
|
|
|
210
227
|
export type LlmGreetingConfigs = Llm.GreetingConfigs;
|
|
211
228
|
/** Greeting broadcast ASR policy: `"merge_reply"` | `"context"` */
|
|
212
229
|
export type LlmGreetingConfigsMode = Llm.GreetingConfigs.UninterruptibleAsrPolicy;
|
|
213
|
-
/** MCP server config item (`llm.mcp_servers[]`) */
|
|
230
|
+
/** MCP server config item (`llm.mcp_servers[]` or `mllm.mcp_servers[]`) */
|
|
214
231
|
export type McpServersItem = Record<string, unknown>;
|
|
215
232
|
/** Full agent configuration (alias for StartAgentsRequest.Properties) */
|
|
216
233
|
export type AgentConfig = StartAgentsRequest.Properties;
|
|
@@ -382,6 +399,8 @@ interface BaseLlmConfig {
|
|
|
382
399
|
template_variables?: Record<string, string>;
|
|
383
400
|
/** MCP server configurations enabling the agent to call tools from external services */
|
|
384
401
|
mcp_servers?: McpServersItem[];
|
|
402
|
+
/** Inline synchronous REST tools exposed to the LLM for function calling */
|
|
403
|
+
tools?: LlmTool[];
|
|
385
404
|
}
|
|
386
405
|
/**
|
|
387
406
|
* LLM (Large Language Model) configuration with vendor-specific typed parameters.
|
|
@@ -542,6 +561,8 @@ export interface SarvamAsrParams {
|
|
|
542
561
|
*/
|
|
543
562
|
export type XAiAsr = XAiAsrType;
|
|
544
563
|
export type XAiAsrParams = XAiAsrParamsType;
|
|
564
|
+
/** Google Gemini STT parameters generated from the API schema. */
|
|
565
|
+
export type GeminiAsrParams = GeminiAsrParamsType;
|
|
545
566
|
export type MicrosoftTts = MicrosoftTtsType;
|
|
546
567
|
export type MicrosoftTtsParams = MicrosoftTtsParamsType;
|
|
547
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) {
|