agora-agents 3.0.0-alpha.3 → 3.0.0-alpha.4
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/AgoraPoolClient.js +25 -8
- package/dist/cjs/agentkit/AgentSession.js +2 -8
- package/dist/cjs/agentkit/index.d.ts +2 -2
- package/dist/cjs/agentkit/index.js +4 -3
- package/dist/cjs/agentkit/session-backend.d.ts +3 -1
- package/dist/cjs/agentkit/session-backend.js +32 -33
- package/dist/cjs/agentkit/token.d.ts +38 -3
- package/dist/cjs/agentkit/token.js +28 -1
- package/dist/cjs/agentkit/v3.d.ts +7 -3
- package/dist/cjs/agentkit/v3.js +22 -14
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +9 -3
- package/dist/cjs/v3/campaigns.js +5 -2
- package/dist/cjs/v3/errors.d.ts +103 -0
- package/dist/cjs/v3/errors.js +179 -0
- package/dist/cjs/v3/index.d.ts +2 -0
- package/dist/cjs/v3/index.js +9 -1
- package/dist/cjs/v3/resources.js +17 -8
- package/dist/cjs/v3/session-lifecycle.d.ts +2 -1
- package/dist/cjs/v3/session-lifecycle.js +22 -18
- package/dist/cjs/v3/transport.d.ts +1 -13
- package/dist/cjs/v3/transport.js +86 -41
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/AgoraPoolClient.mjs +26 -9
- package/dist/esm/agentkit/AgentSession.mjs +2 -8
- package/dist/esm/agentkit/index.d.mts +2 -2
- package/dist/esm/agentkit/index.mjs +1 -1
- package/dist/esm/agentkit/session-backend.d.mts +3 -1
- package/dist/esm/agentkit/session-backend.mjs +33 -34
- package/dist/esm/agentkit/token.d.mts +38 -3
- package/dist/esm/agentkit/token.mjs +27 -1
- package/dist/esm/agentkit/v3.d.mts +7 -3
- package/dist/esm/agentkit/v3.mjs +21 -13
- package/dist/esm/index.d.mts +4 -4
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/v3/campaigns.mjs +5 -2
- package/dist/esm/v3/errors.d.mts +103 -0
- package/dist/esm/v3/errors.mjs +167 -0
- package/dist/esm/v3/index.d.mts +2 -0
- package/dist/esm/v3/index.mjs +1 -0
- package/dist/esm/v3/resources.mjs +17 -8
- package/dist/esm/v3/session-lifecycle.d.mts +2 -1
- package/dist/esm/v3/session-lifecycle.mjs +22 -18
- package/dist/esm/v3/transport.d.mts +1 -13
- package/dist/esm/v3/transport.mjs +83 -38
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type { AgoraAuthMode } from "./AgoraPoolClient.js";
|
|
2
2
|
export { AgoraClient } from "./AgoraPoolClient.js";
|
|
3
3
|
export type { AgoraArea, AreaScope, GlobalArea } from "./agentkit/area.js";
|
|
4
|
-
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AgentOptions, AgentPreset, AgentSessionEvent, AgentSessionEventHandler, AgentSessionOptions, AgentsClient, AkoolAvatarConfig, AkoolAvatarOptions, AkoolSampleRate, AliyunLLMOptions, AmazonBedrockOptions, AmazonSTTOptions, AmazonTTSOptions, AmazonTts, AmazonTtsParams, AnamAvatarConfig, AnamAvatarOptions, AnthropicOptions, AresSTTOptions, AsrConfig, AsrPreset, AsrVendorName, AssemblyAISTTOptions, AvatarConfig, AvatarVendor, AvatarWireVendor, AzureOpenAIOptions, AzureOpenAIRealtimeOptions, AzureOpenAIRealtimeParams, BaseMllmOptions, BytedanceDuplexTTSOptions, BytedanceLLMOptions, BytedanceTTSOptions, CartesiaSampleRate, CartesiaTTSOptions, CartesiaTts, CartesiaTtsParams, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, CustomLLMOptions, DeepgramSTTOptions, DeepgramTTSOptions, DeepSeekLLMOptions, DifyOptions, Eagerness, ElevenLabsSampleRate, ElevenLabsTTSOptions, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FengmingSTTOptions, FillerWordsConfig, FillerWordsContent, FillerWordsContentGeneratedConfig, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsGeneratedLlmProvider, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTTSOptions, FishAudioTts, FishAudioTtsParams, GeminiAsrParams, GeminiLiveModel, GeminiLiveOptions, GeminiLiveVoice, GeminiOptions, GeminiPreviewVoice, GeminiSTTModel, GeminiSTTOptions, GeminiThinkingLevel, GenerateConvoAITokenOptions, GenerateTokenOptions, GenericAvatarConfig, GenericAvatarOptions, GenericTTSOptions, GenericTts, GenericTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, GoogleSTTOptions, GoogleTTSOptions, GoogleTts, GoogleTtsParams, GradiumTTSOptions, GradiumTts, GradiumTtsParams, GroqOptions, HeyGenAvatarConfig, HeyGenAvatarOptions, HeyGenSampleRate, HumeAITTSOptions, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LemonSliceOptions, LiveAvatarAvatarConfig, LiveAvatarAvatarOptions, LiveAvatarSampleRate, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmPreset, LlmStyle, LlmTool, LlmToolExecution, LlmToolFunction, LlmToolServer, LlmVendor, McpServer, McpServersItem, MicrosoftCNSampleRate, MicrosoftCNSTTOptions, MicrosoftCNTTSOptions, MicrosoftSampleRate, MicrosoftSTTOptions, MicrosoftTTSOptions, MicrosoftTts, MicrosoftTtsParams, MiniMaxCNTTSOptions, MiniMaxTTSOptions, MinimaxTts, MinimaxTtsParams, MistralTTSOptions, MistralTts, MistralTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTTSOptions, MurfTts, MurfTtsParams, OpenAIGPTLiveOptions, OpenAIOptions, OpenAIRealtimeOptions, OpenAISTTOptions, OpenAITTSOptions, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, PresetCategory, PresetInput, PreviewFeature, PreviewRoute, ProtofaceOptions, QwenOmniOptions, RimeTTSOptions, RimeTts, RimeTtsParams, RTZRSTTOptions, RtcConfig, RtzrAsr, RtzrAsrParams, SalConfig, SalMode, SampleRate, SarvamSTTOptions, SarvamTTSOptions, SarvamTts, SarvamTtsParams, SayOptions, SensetimeAvatarConfig, SensetimeAvatarOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SmallestAISTTOptions, SmallestAITTSOptions, SmallestAiAsr, SmallestAiAsrParams, SmallestAiTts, SmallestAiTtsParams, SpatiusAvatarConfig, SpatiusAvatarOptions, SpatiusAvatarParams, SpeakConfig, SpeakPriority, SpeechmaticsSTTOptions, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, StepFunTTSOptions, StrictAvatarConfig, SttConfig, SttVendor, TavusOptions, TencentLLMOptions, TencentSTTOptions, TencentTTSOptions, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TtsPreset, TtsVendor, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, TypecastTTSOptions, TypecastTts, TypecastTtsParams, VertexAILLMOptions, VertexAIOptions, XAiAsr, XAiAsrParams, XAiSTTOptions, XAiTTSOptions, XAiTts, XAiTtsParams, XaiGrokOptions, XfyunBigModelSTTOptions, XfyunDialectSTTOptions, XfyunSTTOptions, } from "./agentkit/index.js";
|
|
5
|
-
export { Agent, AgentPresets, AgentSession, AkoolAvatar, AliyunLLM, AmazonBedrock, AmazonSTT, AmazonTTS, AnamAvatar, Anthropic, AresSTT, AssemblyAISTT, AudioScenario, AzureOpenAI, AzureOpenAIRealtime, BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNMLLM, BaseCNSTT, BaseCNTTS, BaseLLM, BaseMLLM, BaseSTT, BaseTTS, BytedanceDuplexTTS, BytedanceLLM, BytedanceTTS, CartesiaTTS, CosyVoiceTTS, CredentialMode, CustomLLM, createPreviewRoute, DataChannel, DeepgramSTT, DeepgramTTS, DeepSeekLLM, Dify, ElevenLabsTTS, ExpiresIn, FengmingSTT, FillerWordsSelectionRule, FishAudioTTS, GEMINI_MLLM_DEFAULT_MODEL, GEMINI_MLLM_URL, GEMINI_PREVIEW_MLLM_URL, Gemini, GeminiLive, GeminiLiveModels, GeminiSTT, GeminiSTTModels, GeminiThinkingLevels, GeminiTranscriptionMode, GenericAvatar, GenericTTS, Geofence, GoogleSTT, GoogleTTS, GradiumTTS, Groq, generateConvoAIToken, generateRtcToken, HeyGenAvatar, HumeAITTS, InterruptionDisabledStrategy, InterruptionDisabledStrategyAppend, InterruptionDisabledStrategyIgnore, InterruptionModeKeywords, InterruptionModeStartOfSpeech, InterruptionModeValues, isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, LemonSlice, LiveAvatarAvatar, MAX_EXPIRY_SECONDS, MicrosoftCNSTT, MicrosoftCNTTS, MicrosoftSTT, MicrosoftTTS, MiniMaxCNTTS, MiniMaxTTS, MistralTTS, MllmTurnDetectionModeAgoraVad, MllmTurnDetectionModeSemanticVad, MllmTurnDetectionModeServerVad, MllmTurnDetectionModeValues, MurfTTS, normalizePresetInput, OpenAI, OpenAIGPTLive, OpenAIRealtime, OpenAISTT, OpenAITTS, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, Protoface, previewRequestHeaders, QwenOmni, REDACTED, RimeTTS, RTZRSTT, redactHeadersForDebug, redactSecrets, SalModeValues, SarvamSTT, SarvamTTS, SarvamTTSLanguage, SensetimeAvatar, SilenceActionValues, SmallestAISTT, SmallestAITTS, SpatiusAvatar, SpeakPriorityAppend, SpeakPriorityIgnore, SpeakPriorityInterrupt, SpeakPriorityValues, SpeechmaticsSTT, StepFunTTS, Tavus, TencentLLM, TencentSTT, TencentTTS, ThinkOnListeningActionIgnore, ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnSpeakingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnThinkingActionInterrupt, TurnDetectionTypeValues, TypecastTTS, toBaseAvatarConfig, VertexAI, VertexAILLM, validateAvatarConfig, validateTtsSampleRate, XAiSTT, XAiTTS, XaiGrok, XfyunBigModelSTT, XfyunDialectSTT, XfyunSTT, } from "./agentkit/index.js";
|
|
4
|
+
export type { AdvancedFeatures, AgentConfig, AgentConfigUpdate, AgentOptions, AgentPreset, AgentSessionEvent, AgentSessionEventHandler, AgentSessionOptions, AgentsClient, AkoolAvatarConfig, AkoolAvatarOptions, AkoolSampleRate, AliyunLLMOptions, AmazonBedrockOptions, AmazonSTTOptions, AmazonTTSOptions, AmazonTts, AmazonTtsParams, AnamAvatarConfig, AnamAvatarOptions, AnthropicOptions, AresSTTOptions, AsrConfig, AsrPreset, AsrVendorName, AssemblyAISTTOptions, AvatarConfig, AvatarVendor, AvatarWireVendor, AzureOpenAIOptions, AzureOpenAIRealtimeOptions, AzureOpenAIRealtimeParams, BaseMllmOptions, BytedanceDuplexTTSOptions, BytedanceLLMOptions, BytedanceTTSOptions, CartesiaSampleRate, CartesiaTTSOptions, CartesiaTts, CartesiaTtsParams, CNAvatarVendor, CNLlmVendor, CNMllmVendor, CNSttVendor, CNTtsVendor, ConversationHistory, ConversationRole, ConversationSessionTurn, ConversationTurn, ConversationTurns, CustomLLMOptions, DeepgramSTTOptions, DeepgramTTSOptions, DeepSeekLLMOptions, DifyOptions, Eagerness, ElevenLabsSampleRate, ElevenLabsTTSOptions, ElevenLabsTts, ElevenLabsTtsParams, EndOfSpeechConfig, EndOfSpeechMode, EndOfSpeechSemanticConfig, EndOfSpeechVadConfig, FarewellConfig, FengmingSTTOptions, FillerWordsConfig, FillerWordsContent, FillerWordsContentGeneratedConfig, FillerWordsContentSelectionRule, FillerWordsContentStaticConfig, FillerWordsGeneratedLlmProvider, FillerWordsTrigger, FillerWordsTriggerFixedTimeConfig, FishAudioTTSOptions, FishAudioTts, FishAudioTtsParams, GeminiAsrParams, GeminiLiveModel, GeminiLiveOptions, GeminiLiveVoice, GeminiOptions, GeminiPreviewVoice, GeminiSTTModel, GeminiSTTOptions, GeminiThinkingLevel, GenerateClientTokenOptions, GenerateConvoAITokenOptions, GenerateTokenOptions, GenericAvatarConfig, GenericAvatarOptions, GenericTTSOptions, GenericTts, GenericTtsParams, GeofenceArea, GeofenceConfig, GeofenceExcludeArea, GetTurnsOptions, GlobalAvatarVendor, GlobalLlmVendor, GlobalMllmVendor, GlobalSttVendor, GlobalTtsVendor, GoogleSTTOptions, GoogleTTSOptions, GoogleTts, GoogleTtsParams, GradiumTTSOptions, GradiumTts, GradiumTtsParams, GroqOptions, HeyGenAvatarConfig, HeyGenAvatarOptions, HeyGenSampleRate, HumeAITTSOptions, HumeAiTts, HumeAiTtsParams, InterruptionConfig, InterruptionMode, InterruptMode, Labels, LemonSliceOptions, LiveAvatarAvatarConfig, LiveAvatarAvatarOptions, LiveAvatarSampleRate, LlmConfig, LlmGreetingConfigs, LlmGreetingConfigsMode, LlmPreset, LlmStyle, LlmTool, LlmToolExecution, LlmToolFunction, LlmToolServer, LlmVendor, McpServer, McpServersItem, MicrosoftCNSampleRate, MicrosoftCNSTTOptions, MicrosoftCNTTSOptions, MicrosoftSampleRate, MicrosoftSTTOptions, MicrosoftTTSOptions, MicrosoftTts, MicrosoftTtsParams, MiniMaxCNTTSOptions, MiniMaxTTSOptions, MinimaxTts, MinimaxTtsParams, MistralTTSOptions, MistralTts, MistralTtsParams, MllmConfig, MllmTurnDetectionConfig, MllmTurnDetectionMode, MllmVendor, MurfTTSOptions, MurfTts, MurfTtsParams, OpenAIGPTLiveOptions, OpenAIOptions, OpenAIRealtimeOptions, OpenAISTTOptions, OpenAITTSOptions, OpenAiTts, OpenAiTtsParams, ParametersAudioScenario, ParametersDataChannel, PresetCategory, PresetInput, PreviewFeature, PreviewRoute, ProtofaceOptions, QwenOmniOptions, RimeTTSOptions, RimeTts, RimeTtsParams, RTZRSTTOptions, RtcConfig, RtzrAsr, RtzrAsrParams, SalConfig, SalMode, SampleRate, SarvamSTTOptions, SarvamTTSOptions, SarvamTts, SarvamTtsParams, SayOptions, SensetimeAvatarConfig, SensetimeAvatarOptions, SessionInfo, SessionListResponse, SessionOptions, SessionParams, SessionParamsInput, SessionStatus, SessionSummary, SilenceAction, SilenceConfig, SmallestAISTTOptions, SmallestAITTSOptions, SmallestAiAsr, SmallestAiAsrParams, SmallestAiTts, SmallestAiTtsParams, SpatiusAvatarConfig, SpatiusAvatarOptions, SpatiusAvatarParams, SpeakConfig, SpeakPriority, SpeechmaticsSTTOptions, StartOfSpeechConfig, StartOfSpeechDisabledConfig, StartOfSpeechDisabledConfigStrategy, StartOfSpeechKeywordsConfig, StartOfSpeechMode, StartOfSpeechVadConfig, StepFunTTSOptions, StrictAvatarConfig, SttConfig, SttVendor, TavusOptions, TencentLLMOptions, TencentSTTOptions, TencentTTSOptions, ThinkOnListeningAction, ThinkOnSpeakingAction, ThinkOnThinkingAction, ThinkOptions, ThinkResponse, TtsConfig, TtsPreset, TtsVendor, TurnDetectionConfig, TurnDetectionLanguage, TurnDetectionNestedConfig, TurnDetectionType, TypecastTTSOptions, TypecastTts, TypecastTtsParams, VertexAILLMOptions, VertexAIOptions, XAiAsr, XAiAsrParams, XAiSTTOptions, XAiTTSOptions, XAiTts, XAiTtsParams, XaiGrokOptions, XfyunBigModelSTTOptions, XfyunDialectSTTOptions, XfyunSTTOptions, } from "./agentkit/index.js";
|
|
5
|
+
export { Agent, AgentPresets, AgentSession, AkoolAvatar, AliyunLLM, AmazonBedrock, AmazonSTT, AmazonTTS, AnamAvatar, Anthropic, AresSTT, AssemblyAISTT, AudioScenario, AzureOpenAI, AzureOpenAIRealtime, BaseAvatar, BaseCNAvatar, BaseCNLLM, BaseCNMLLM, BaseCNSTT, BaseCNTTS, BaseLLM, BaseMLLM, BaseSTT, BaseTTS, BytedanceDuplexTTS, BytedanceLLM, BytedanceTTS, CartesiaTTS, CosyVoiceTTS, CredentialMode, CustomLLM, createPreviewRoute, DataChannel, DeepgramSTT, DeepgramTTS, DeepSeekLLM, Dify, ElevenLabsTTS, ExpiresIn, FengmingSTT, FillerWordsSelectionRule, FishAudioTTS, GEMINI_MLLM_DEFAULT_MODEL, GEMINI_MLLM_URL, GEMINI_PREVIEW_MLLM_URL, Gemini, GeminiLive, GeminiLiveModels, GeminiSTT, GeminiSTTModels, GeminiThinkingLevels, GeminiTranscriptionMode, GenericAvatar, GenericTTS, Geofence, GoogleSTT, GoogleTTS, GradiumTTS, Groq, generateClientToken, generateConvoAIToken, generateRtcToken, HeyGenAvatar, HumeAITTS, InterruptionDisabledStrategy, InterruptionDisabledStrategyAppend, InterruptionDisabledStrategyIgnore, InterruptionModeKeywords, InterruptionModeStartOfSpeech, InterruptionModeValues, isAkoolAvatar, isAnamAvatar, isAvatarTokenManaged, isGenericAvatar, isHeyGenAvatar, isLiveAvatarAvatar, isSensetimeAvatar, isSpatiusAvatar, LemonSlice, LiveAvatarAvatar, MAX_EXPIRY_SECONDS, MicrosoftCNSTT, MicrosoftCNTTS, MicrosoftSTT, MicrosoftTTS, MiniMaxCNTTS, MiniMaxTTS, MistralTTS, MllmTurnDetectionModeAgoraVad, MllmTurnDetectionModeSemanticVad, MllmTurnDetectionModeServerVad, MllmTurnDetectionModeValues, MurfTTS, normalizePresetInput, OpenAI, OpenAIGPTLive, OpenAIRealtime, OpenAISTT, OpenAITTS, PREVIEW_API_BASE_URL, PREVIEW_FEATURE_HEADER, PreviewFeatures, Protoface, previewRequestHeaders, QwenOmni, REDACTED, RimeTTS, RTZRSTT, redactHeadersForDebug, redactSecrets, SalModeValues, SarvamSTT, SarvamTTS, SarvamTTSLanguage, SensetimeAvatar, SilenceActionValues, SmallestAISTT, SmallestAITTS, SpatiusAvatar, SpeakPriorityAppend, SpeakPriorityIgnore, SpeakPriorityInterrupt, SpeakPriorityValues, SpeechmaticsSTT, StepFunTTS, Tavus, TencentLLM, TencentSTT, TencentTTS, ThinkOnListeningActionIgnore, ThinkOnListeningActionInject, ThinkOnListeningActionInterrupt, ThinkOnSpeakingActionIgnore, ThinkOnSpeakingActionInterrupt, ThinkOnThinkingActionIgnore, ThinkOnThinkingActionInterrupt, TurnDetectionTypeValues, TypecastTTS, toBaseAvatarConfig, VertexAI, VertexAILLM, validateAvatarConfig, validateTtsSampleRate, XAiSTT, XAiTTS, XaiGrok, XfyunBigModelSTT, XfyunDialectSTT, XfyunSTT, } from "./agentkit/index.js";
|
|
6
6
|
export { UnsupportedSessionOperationError } from "./agentkit/session-backend.js";
|
|
7
7
|
export type { AssignNumberOptions, DeployOptions, SaveOptions, SecretRef, VariableDefinition } from "./agentkit/v3.js";
|
|
8
8
|
export { DeployedAgent, NumberNotFoundError, SavedAgent, SecretRefNotSupportedError, secretRef, UnsupportedFieldError, } from "./agentkit/v3.js";
|
|
@@ -14,5 +14,5 @@ export { Area } from "./core/domain/index.js";
|
|
|
14
14
|
export { AgoraEnvironment } from "./environments.js";
|
|
15
15
|
export { AgoraError, AgoraTimeoutError } from "./errors/index.js";
|
|
16
16
|
export * from "./exports.js";
|
|
17
|
-
export type { V3, V3Options } from "./v3/index.js";
|
|
18
|
-
export { PreconditionFailedError, V3Client, V3Error } from "./v3/index.js";
|
|
17
|
+
export type { AnyV3Error, V3, V3ApiErrorOptions, V3ErrorCategory, V3ErrorOptions, V3Options, } from "./v3/index.js";
|
|
18
|
+
export { AgoraV3Error, PreconditionFailedError, V3Client, V3ConfigurationError, V3ConnectionError, V3Error, V3TimeoutError, V3ValidationError, } from "./v3/index.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -37,9 +37,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.GeminiLiveModels = exports.GeminiLive = exports.Gemini = exports.GEMINI_PREVIEW_MLLM_URL = exports.GEMINI_MLLM_URL = exports.GEMINI_MLLM_DEFAULT_MODEL = exports.FishAudioTTS = exports.FillerWordsSelectionRule = exports.FengmingSTT = exports.ExpiresIn = exports.ElevenLabsTTS = exports.Dify = exports.DeepSeekLLM = exports.DeepgramTTS = exports.DeepgramSTT = exports.DataChannel = exports.createPreviewRoute = exports.CustomLLM = exports.CredentialMode = exports.CosyVoiceTTS = exports.CartesiaTTS = exports.BytedanceTTS = exports.BytedanceLLM = exports.BytedanceDuplexTTS = exports.BaseTTS = exports.BaseSTT = exports.BaseMLLM = exports.BaseLLM = exports.BaseCNTTS = exports.BaseCNSTT = exports.BaseCNMLLM = exports.BaseCNLLM = exports.BaseCNAvatar = exports.BaseAvatar = exports.AzureOpenAIRealtime = exports.AzureOpenAI = exports.AudioScenario = exports.AssemblyAISTT = exports.AresSTT = exports.Anthropic = exports.AnamAvatar = exports.AmazonTTS = exports.AmazonSTT = exports.AmazonBedrock = exports.AliyunLLM = exports.AkoolAvatar = exports.AgentSession = exports.AgentPresets = exports.Agent = exports.AgoraClient = void 0;
|
|
40
|
-
exports.
|
|
41
|
-
exports.
|
|
42
|
-
exports.V3Error = exports.V3Client = exports.PreconditionFailedError = exports.AgoraTimeoutError = exports.AgoraError = exports.AgoraEnvironment = exports.Area = exports.Agora = exports.GeminiTTSModels = exports.GeminiTTS = exports.UnsupportedFieldError = exports.secretRef = exports.SecretRefNotSupportedError = exports.SavedAgent = exports.NumberNotFoundError = exports.DeployedAgent = exports.UnsupportedSessionOperationError = void 0;
|
|
40
|
+
exports.OpenAISTT = exports.OpenAIRealtime = exports.OpenAIGPTLive = exports.OpenAI = exports.normalizePresetInput = exports.MurfTTS = exports.MllmTurnDetectionModeValues = exports.MllmTurnDetectionModeServerVad = exports.MllmTurnDetectionModeSemanticVad = exports.MllmTurnDetectionModeAgoraVad = exports.MistralTTS = exports.MiniMaxTTS = exports.MiniMaxCNTTS = exports.MicrosoftTTS = exports.MicrosoftSTT = exports.MicrosoftCNTTS = exports.MicrosoftCNSTT = exports.MAX_EXPIRY_SECONDS = exports.LiveAvatarAvatar = exports.LemonSlice = exports.isSpatiusAvatar = exports.isSensetimeAvatar = exports.isLiveAvatarAvatar = exports.isHeyGenAvatar = exports.isGenericAvatar = exports.isAvatarTokenManaged = exports.isAnamAvatar = exports.isAkoolAvatar = exports.InterruptionModeValues = exports.InterruptionModeStartOfSpeech = exports.InterruptionModeKeywords = exports.InterruptionDisabledStrategyIgnore = exports.InterruptionDisabledStrategyAppend = exports.InterruptionDisabledStrategy = exports.HumeAITTS = exports.HeyGenAvatar = exports.generateRtcToken = exports.generateConvoAIToken = exports.generateClientToken = exports.Groq = exports.GradiumTTS = exports.GoogleTTS = exports.GoogleSTT = exports.Geofence = exports.GenericTTS = exports.GenericAvatar = exports.GeminiTranscriptionMode = exports.GeminiThinkingLevels = exports.GeminiSTTModels = exports.GeminiSTT = void 0;
|
|
41
|
+
exports.XfyunDialectSTT = exports.XfyunBigModelSTT = exports.XaiGrok = exports.XAiTTS = exports.XAiSTT = exports.validateTtsSampleRate = exports.validateAvatarConfig = exports.VertexAILLM = exports.VertexAI = exports.toBaseAvatarConfig = exports.TypecastTTS = exports.TurnDetectionTypeValues = exports.ThinkOnThinkingActionInterrupt = exports.ThinkOnThinkingActionIgnore = exports.ThinkOnSpeakingActionInterrupt = exports.ThinkOnSpeakingActionIgnore = exports.ThinkOnListeningActionInterrupt = exports.ThinkOnListeningActionInject = exports.ThinkOnListeningActionIgnore = exports.TencentTTS = exports.TencentSTT = exports.TencentLLM = exports.Tavus = exports.StepFunTTS = exports.SpeechmaticsSTT = exports.SpeakPriorityValues = exports.SpeakPriorityInterrupt = exports.SpeakPriorityIgnore = exports.SpeakPriorityAppend = exports.SpatiusAvatar = exports.SmallestAITTS = exports.SmallestAISTT = exports.SilenceActionValues = exports.SensetimeAvatar = exports.SarvamTTSLanguage = exports.SarvamTTS = exports.SarvamSTT = exports.SalModeValues = exports.redactSecrets = exports.redactHeadersForDebug = exports.RTZRSTT = exports.RimeTTS = exports.REDACTED = exports.QwenOmni = exports.previewRequestHeaders = exports.Protoface = exports.PreviewFeatures = exports.PREVIEW_FEATURE_HEADER = exports.PREVIEW_API_BASE_URL = exports.OpenAITTS = void 0;
|
|
42
|
+
exports.V3ValidationError = exports.V3TimeoutError = exports.V3Error = exports.V3ConnectionError = exports.V3ConfigurationError = exports.V3Client = exports.PreconditionFailedError = exports.AgoraV3Error = exports.AgoraTimeoutError = exports.AgoraError = exports.AgoraEnvironment = exports.Area = exports.Agora = exports.GeminiTTSModels = exports.GeminiTTS = exports.UnsupportedFieldError = exports.secretRef = exports.SecretRefNotSupportedError = exports.SavedAgent = exports.NumberNotFoundError = exports.DeployedAgent = exports.UnsupportedSessionOperationError = exports.XfyunSTT = void 0;
|
|
43
43
|
var AgoraPoolClient_js_1 = require("./AgoraPoolClient.js");
|
|
44
44
|
Object.defineProperty(exports, "AgoraClient", { enumerable: true, get: function () { return AgoraPoolClient_js_1.AgoraClient; } });
|
|
45
45
|
// Agentkit layer exports - clean, ergonomic API
|
|
@@ -106,6 +106,7 @@ Object.defineProperty(exports, "GoogleSTT", { enumerable: true, get: function ()
|
|
|
106
106
|
Object.defineProperty(exports, "GoogleTTS", { enumerable: true, get: function () { return index_js_1.GoogleTTS; } });
|
|
107
107
|
Object.defineProperty(exports, "GradiumTTS", { enumerable: true, get: function () { return index_js_1.GradiumTTS; } });
|
|
108
108
|
Object.defineProperty(exports, "Groq", { enumerable: true, get: function () { return index_js_1.Groq; } });
|
|
109
|
+
Object.defineProperty(exports, "generateClientToken", { enumerable: true, get: function () { return index_js_1.generateClientToken; } });
|
|
109
110
|
Object.defineProperty(exports, "generateConvoAIToken", { enumerable: true, get: function () { return index_js_1.generateConvoAIToken; } });
|
|
110
111
|
Object.defineProperty(exports, "generateRtcToken", { enumerable: true, get: function () { return index_js_1.generateRtcToken; } });
|
|
111
112
|
// Avatar vendors
|
|
@@ -221,6 +222,11 @@ Object.defineProperty(exports, "AgoraError", { enumerable: true, get: function (
|
|
|
221
222
|
Object.defineProperty(exports, "AgoraTimeoutError", { enumerable: true, get: function () { return index_js_3.AgoraTimeoutError; } });
|
|
222
223
|
__exportStar(require("./exports.js"), exports);
|
|
223
224
|
var index_js_4 = require("./v3/index.js");
|
|
225
|
+
Object.defineProperty(exports, "AgoraV3Error", { enumerable: true, get: function () { return index_js_4.AgoraV3Error; } });
|
|
224
226
|
Object.defineProperty(exports, "PreconditionFailedError", { enumerable: true, get: function () { return index_js_4.PreconditionFailedError; } });
|
|
225
227
|
Object.defineProperty(exports, "V3Client", { enumerable: true, get: function () { return index_js_4.V3Client; } });
|
|
228
|
+
Object.defineProperty(exports, "V3ConfigurationError", { enumerable: true, get: function () { return index_js_4.V3ConfigurationError; } });
|
|
229
|
+
Object.defineProperty(exports, "V3ConnectionError", { enumerable: true, get: function () { return index_js_4.V3ConnectionError; } });
|
|
226
230
|
Object.defineProperty(exports, "V3Error", { enumerable: true, get: function () { return index_js_4.V3Error; } });
|
|
231
|
+
Object.defineProperty(exports, "V3TimeoutError", { enumerable: true, get: function () { return index_js_4.V3TimeoutError; } });
|
|
232
|
+
Object.defineProperty(exports, "V3ValidationError", { enumerable: true, get: function () { return index_js_4.V3ValidationError; } });
|
package/dist/cjs/v3/campaigns.js
CHANGED
|
@@ -26,6 +26,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
26
26
|
};
|
|
27
27
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
28
|
exports.CampaignsResource = void 0;
|
|
29
|
+
const errors_js_1 = require("./errors.js");
|
|
29
30
|
const transport_js_1 = require("./transport.js");
|
|
30
31
|
class CampaignsResource {
|
|
31
32
|
constructor(transport) {
|
|
@@ -45,12 +46,14 @@ class CampaignsResource {
|
|
|
45
46
|
const seen = new Set();
|
|
46
47
|
let cursor = request === null || request === void 0 ? void 0 : request.cursor;
|
|
47
48
|
while (true) {
|
|
48
|
-
const page = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options));
|
|
49
|
+
const { data: page, rawResponse } = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options).withRawResponse());
|
|
49
50
|
yield __await(yield* __asyncDelegator(__asyncValues(page.data.list)));
|
|
50
51
|
if (!page.has_more)
|
|
51
52
|
return yield __await(void 0);
|
|
52
53
|
if (!page.next_cursor || seen.has(page.next_cursor))
|
|
53
|
-
throw new
|
|
54
|
+
throw new errors_js_1.V3Error(rawResponse.status, page, rawResponse, {
|
|
55
|
+
message: "Invalid repeated or missing pagination cursor",
|
|
56
|
+
});
|
|
54
57
|
cursor = page.next_cursor;
|
|
55
58
|
seen.add(cursor);
|
|
56
59
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured error taxonomy for the v3 preview API.
|
|
3
|
+
*
|
|
4
|
+
* Every error raised by a `client.v3.*` operation, and by the AgentKit paths that
|
|
5
|
+
* call it, is an {@link AgoraV3Error} in exactly one {@link V3ErrorCategory}:
|
|
6
|
+
*
|
|
7
|
+
* - `validation` {@link V3ValidationError}: input rejected locally before any request.
|
|
8
|
+
* - `configuration` {@link V3ConfigurationError}: the client itself is misconfigured.
|
|
9
|
+
* - `connection` {@link V3ConnectionError}: the request could not complete;
|
|
10
|
+
* {@link V3TimeoutError} is its timeout subtype.
|
|
11
|
+
* - `api` {@link V3Error}: a non-2xx response, or a 2xx response that violates
|
|
12
|
+
* the API contract; {@link PreconditionFailedError} is its 412 subtype.
|
|
13
|
+
*
|
|
14
|
+
* The category names and meanings are shared with the Go and Python SDKs.
|
|
15
|
+
*/
|
|
16
|
+
import type { RawResponse } from "../core/fetcher/RawResponse.js";
|
|
17
|
+
import type { ErrorReason } from "./types.js";
|
|
18
|
+
/** The failure kind shared by every v3 error. Subtypes keep their parent's category. */
|
|
19
|
+
export type V3ErrorCategory = "validation" | "configuration" | "connection" | "api";
|
|
20
|
+
/** Constructor options for v3 errors. Mirrors ES2022 `ErrorOptions`. */
|
|
21
|
+
export interface V3ErrorOptions {
|
|
22
|
+
/** The underlying error, exposed as the standard `error.cause`. */
|
|
23
|
+
cause?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Root of every v3 error. Catch this to handle any failure from a v3 operation. */
|
|
26
|
+
export declare abstract class AgoraV3Error extends Error {
|
|
27
|
+
/** Which of the four shared categories this error belongs to. */
|
|
28
|
+
abstract readonly category: V3ErrorCategory;
|
|
29
|
+
/** The underlying error, when this error wraps one. */
|
|
30
|
+
readonly cause?: unknown;
|
|
31
|
+
constructor(message: string, options?: V3ErrorOptions);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The caller's input was rejected locally, before any HTTP request was sent:
|
|
35
|
+
* invalid identifiers, bodies, secret names, idempotency keys, unsupported
|
|
36
|
+
* fields or options, or conflicting options.
|
|
37
|
+
*/
|
|
38
|
+
export declare class V3ValidationError extends AgoraV3Error {
|
|
39
|
+
get category(): "validation";
|
|
40
|
+
constructor(message: string, options?: V3ErrorOptions);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The client itself is misconfigured, such as an invalid `v3.baseUrl` origin or
|
|
44
|
+
* missing or conflicting credentials. A deployment problem, not a bad request.
|
|
45
|
+
*/
|
|
46
|
+
export declare class V3ConfigurationError extends AgoraV3Error {
|
|
47
|
+
get category(): "configuration";
|
|
48
|
+
constructor(message: string, options?: V3ErrorOptions);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The request could not complete: DNS failure, refused or reset connection, TLS
|
|
52
|
+
* failure, an aborted request or body. The underlying error, when the runtime
|
|
53
|
+
* reported one, is available as `cause`.
|
|
54
|
+
*/
|
|
55
|
+
export declare class V3ConnectionError extends AgoraV3Error {
|
|
56
|
+
get category(): "connection";
|
|
57
|
+
constructor(message: string, options?: V3ErrorOptions);
|
|
58
|
+
}
|
|
59
|
+
/** The request exceeded its timeout (`timeoutInSeconds`). A {@link V3ConnectionError}. */
|
|
60
|
+
export declare class V3TimeoutError extends V3ConnectionError {
|
|
61
|
+
constructor(message: string, options?: V3ErrorOptions);
|
|
62
|
+
}
|
|
63
|
+
/** Options for {@link V3Error}. */
|
|
64
|
+
export interface V3ApiErrorOptions extends V3ErrorOptions {
|
|
65
|
+
/** Overrides the default `v3 request failed (<status>)` message. */
|
|
66
|
+
message?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A non-2xx response, or a 2xx response that violates the API contract (a body that
|
|
70
|
+
* is not valid JSON, or missing required data such as an ETag); `statusCode` is then
|
|
71
|
+
* the 2xx status. `body` is the parsed JSON body when available, otherwise the text.
|
|
72
|
+
*/
|
|
73
|
+
export declare class V3Error extends AgoraV3Error {
|
|
74
|
+
readonly statusCode: number;
|
|
75
|
+
readonly body: unknown;
|
|
76
|
+
readonly rawResponse: RawResponse;
|
|
77
|
+
get category(): "api";
|
|
78
|
+
constructor(statusCode: number, body: unknown, rawResponse: RawResponse, options?: V3ApiErrorOptions);
|
|
79
|
+
/** Response headers. */
|
|
80
|
+
get headers(): Headers;
|
|
81
|
+
/** The `Agora-Request-Id` response header; quote it when contacting support. */
|
|
82
|
+
get requestId(): string | null;
|
|
83
|
+
/** Human-readable `detail` from the error body, when present. */
|
|
84
|
+
get detail(): string | undefined;
|
|
85
|
+
/** Machine-readable `reason` from the error body (for example `"AgentNotFound"`), when present. */
|
|
86
|
+
get reason(): ErrorReason | (string & {}) | undefined;
|
|
87
|
+
}
|
|
88
|
+
/** The `If-Match` / `If-None-Match` precondition failed (HTTP 412). A {@link V3Error}. */
|
|
89
|
+
export declare class PreconditionFailedError extends V3Error {
|
|
90
|
+
private readonly reload;
|
|
91
|
+
constructor(body: unknown, raw: RawResponse, reload: () => Promise<unknown>, options?: V3ApiErrorOptions);
|
|
92
|
+
/** Re-read the resource to obtain its current representation and ETag. */
|
|
93
|
+
latest(): Promise<unknown>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Union of the four category classes, discriminated by `category`:
|
|
97
|
+
* `if (error.category === "api") error.statusCode` narrows without `instanceof`.
|
|
98
|
+
*/
|
|
99
|
+
export type AnyV3Error = V3ValidationError | V3ConfigurationError | V3ConnectionError | V3Error;
|
|
100
|
+
/** @internal Register an error class defined outside this module for cross-build `instanceof`. */
|
|
101
|
+
export declare function registerV3ErrorClass(target: abstract new (...args: never[]) => AgoraV3Error, name: string): void;
|
|
102
|
+
/** @internal Run a local validator and rethrow its plain errors as {@link V3ValidationError}. */
|
|
103
|
+
export declare function asValidation<T>(run: () => T): T;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PreconditionFailedError = exports.V3Error = exports.V3TimeoutError = exports.V3ConnectionError = exports.V3ConfigurationError = exports.V3ValidationError = exports.AgoraV3Error = void 0;
|
|
4
|
+
exports.registerV3ErrorClass = registerV3ErrorClass;
|
|
5
|
+
exports.asValidation = asValidation;
|
|
6
|
+
// Instances carry the tags of every taxonomy class in their chain under a
|
|
7
|
+
// registry symbol, so `instanceof` also holds when an application ends up with
|
|
8
|
+
// both the CommonJS and ESM builds (or two installed copies) of this package.
|
|
9
|
+
const BRANDS = Symbol.for("agora-agents.v3.error-brands");
|
|
10
|
+
const TAGS = new WeakMap();
|
|
11
|
+
function tag(target, name) {
|
|
12
|
+
TAGS.set(target, `agora-agents.${name}`);
|
|
13
|
+
}
|
|
14
|
+
/** Root of every v3 error. Catch this to handle any failure from a v3 operation. */
|
|
15
|
+
class AgoraV3Error extends Error {
|
|
16
|
+
constructor(message, options) {
|
|
17
|
+
super(message);
|
|
18
|
+
// Native classes already get the right prototype; keep it explicit for
|
|
19
|
+
// consumers that down-level this package to ES5.
|
|
20
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
21
|
+
this.name = "AgoraV3Error";
|
|
22
|
+
if (options !== undefined && "cause" in options) {
|
|
23
|
+
Object.defineProperty(this, "cause", {
|
|
24
|
+
value: options.cause,
|
|
25
|
+
writable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const brands = [];
|
|
31
|
+
for (let ctor = new.target; typeof ctor === "function"; ctor = Object.getPrototypeOf(ctor)) {
|
|
32
|
+
const name = TAGS.get(ctor);
|
|
33
|
+
if (name !== undefined)
|
|
34
|
+
brands.push(name);
|
|
35
|
+
}
|
|
36
|
+
Object.defineProperty(this, BRANDS, { value: brands, enumerable: false });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.AgoraV3Error = AgoraV3Error;
|
|
40
|
+
// Inherited by every subclass; `this` is the class on the right of `instanceof`.
|
|
41
|
+
Object.defineProperty(AgoraV3Error, Symbol.hasInstance, {
|
|
42
|
+
value: function hasInstance(value) {
|
|
43
|
+
if (Function.prototype[Symbol.hasInstance].call(this, value))
|
|
44
|
+
return true;
|
|
45
|
+
const name = TAGS.get(this);
|
|
46
|
+
if (name === undefined || value === null || typeof value !== "object")
|
|
47
|
+
return false;
|
|
48
|
+
const brands = value[BRANDS];
|
|
49
|
+
return Array.isArray(brands) && brands.includes(name);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* The caller's input was rejected locally, before any HTTP request was sent:
|
|
54
|
+
* invalid identifiers, bodies, secret names, idempotency keys, unsupported
|
|
55
|
+
* fields or options, or conflicting options.
|
|
56
|
+
*/
|
|
57
|
+
class V3ValidationError extends AgoraV3Error {
|
|
58
|
+
get category() {
|
|
59
|
+
return "validation";
|
|
60
|
+
}
|
|
61
|
+
constructor(message, options) {
|
|
62
|
+
super(message, options);
|
|
63
|
+
this.name = "V3ValidationError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.V3ValidationError = V3ValidationError;
|
|
67
|
+
/**
|
|
68
|
+
* The client itself is misconfigured, such as an invalid `v3.baseUrl` origin or
|
|
69
|
+
* missing or conflicting credentials. A deployment problem, not a bad request.
|
|
70
|
+
*/
|
|
71
|
+
class V3ConfigurationError extends AgoraV3Error {
|
|
72
|
+
get category() {
|
|
73
|
+
return "configuration";
|
|
74
|
+
}
|
|
75
|
+
constructor(message, options) {
|
|
76
|
+
super(message, options);
|
|
77
|
+
this.name = "V3ConfigurationError";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.V3ConfigurationError = V3ConfigurationError;
|
|
81
|
+
/**
|
|
82
|
+
* The request could not complete: DNS failure, refused or reset connection, TLS
|
|
83
|
+
* failure, an aborted request or body. The underlying error, when the runtime
|
|
84
|
+
* reported one, is available as `cause`.
|
|
85
|
+
*/
|
|
86
|
+
class V3ConnectionError extends AgoraV3Error {
|
|
87
|
+
get category() {
|
|
88
|
+
return "connection";
|
|
89
|
+
}
|
|
90
|
+
constructor(message, options) {
|
|
91
|
+
super(message, options);
|
|
92
|
+
this.name = "V3ConnectionError";
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.V3ConnectionError = V3ConnectionError;
|
|
96
|
+
/** The request exceeded its timeout (`timeoutInSeconds`). A {@link V3ConnectionError}. */
|
|
97
|
+
class V3TimeoutError extends V3ConnectionError {
|
|
98
|
+
constructor(message, options) {
|
|
99
|
+
super(message, options);
|
|
100
|
+
this.name = "V3TimeoutError";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.V3TimeoutError = V3TimeoutError;
|
|
104
|
+
function stringField(body, key) {
|
|
105
|
+
if (body === null || typeof body !== "object" || Array.isArray(body))
|
|
106
|
+
return undefined;
|
|
107
|
+
const value = body[key];
|
|
108
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* A non-2xx response, or a 2xx response that violates the API contract (a body that
|
|
112
|
+
* is not valid JSON, or missing required data such as an ETag); `statusCode` is then
|
|
113
|
+
* the 2xx status. `body` is the parsed JSON body when available, otherwise the text.
|
|
114
|
+
*/
|
|
115
|
+
class V3Error extends AgoraV3Error {
|
|
116
|
+
get category() {
|
|
117
|
+
return "api";
|
|
118
|
+
}
|
|
119
|
+
constructor(statusCode, body, rawResponse, options) {
|
|
120
|
+
var _a;
|
|
121
|
+
super((_a = options === null || options === void 0 ? void 0 : options.message) !== null && _a !== void 0 ? _a : `v3 request failed (${statusCode})`, options);
|
|
122
|
+
this.statusCode = statusCode;
|
|
123
|
+
this.body = body;
|
|
124
|
+
this.rawResponse = rawResponse;
|
|
125
|
+
this.name = "V3Error";
|
|
126
|
+
}
|
|
127
|
+
/** Response headers. */
|
|
128
|
+
get headers() {
|
|
129
|
+
return this.rawResponse.headers;
|
|
130
|
+
}
|
|
131
|
+
/** The `Agora-Request-Id` response header; quote it when contacting support. */
|
|
132
|
+
get requestId() {
|
|
133
|
+
return this.rawResponse.headers.get("Agora-Request-Id");
|
|
134
|
+
}
|
|
135
|
+
/** Human-readable `detail` from the error body, when present. */
|
|
136
|
+
get detail() {
|
|
137
|
+
return stringField(this.body, "detail");
|
|
138
|
+
}
|
|
139
|
+
/** Machine-readable `reason` from the error body (for example `"AgentNotFound"`), when present. */
|
|
140
|
+
get reason() {
|
|
141
|
+
return stringField(this.body, "reason");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.V3Error = V3Error;
|
|
145
|
+
/** The `If-Match` / `If-None-Match` precondition failed (HTTP 412). A {@link V3Error}. */
|
|
146
|
+
class PreconditionFailedError extends V3Error {
|
|
147
|
+
constructor(body, raw, reload, options) {
|
|
148
|
+
super(412, body, raw, options);
|
|
149
|
+
this.reload = reload;
|
|
150
|
+
this.name = "PreconditionFailedError";
|
|
151
|
+
}
|
|
152
|
+
/** Re-read the resource to obtain its current representation and ETag. */
|
|
153
|
+
latest() {
|
|
154
|
+
return this.reload();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.PreconditionFailedError = PreconditionFailedError;
|
|
158
|
+
tag(AgoraV3Error, "AgoraV3Error");
|
|
159
|
+
tag(V3ValidationError, "V3ValidationError");
|
|
160
|
+
tag(V3ConfigurationError, "V3ConfigurationError");
|
|
161
|
+
tag(V3ConnectionError, "V3ConnectionError");
|
|
162
|
+
tag(V3TimeoutError, "V3TimeoutError");
|
|
163
|
+
tag(V3Error, "V3Error");
|
|
164
|
+
tag(PreconditionFailedError, "PreconditionFailedError");
|
|
165
|
+
/** @internal Register an error class defined outside this module for cross-build `instanceof`. */
|
|
166
|
+
function registerV3ErrorClass(target, name) {
|
|
167
|
+
tag(target, name);
|
|
168
|
+
}
|
|
169
|
+
/** @internal Run a local validator and rethrow its plain errors as {@link V3ValidationError}. */
|
|
170
|
+
function asValidation(run) {
|
|
171
|
+
try {
|
|
172
|
+
return run();
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (error instanceof AgoraV3Error || !(error instanceof Error))
|
|
176
|
+
throw error;
|
|
177
|
+
throw new V3ValidationError(error.message, { cause: error });
|
|
178
|
+
}
|
|
179
|
+
}
|
package/dist/cjs/v3/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { CampaignsResource } from "./campaigns.js";
|
|
|
2
2
|
export { CampaignsResource } from "./campaigns.js";
|
|
3
3
|
import { AgentsResource, NumbersResource, SecretsResource, SessionsResource } from "./resources.js";
|
|
4
4
|
import type { V3Transport } from "./transport.js";
|
|
5
|
+
export type { AnyV3Error, V3ApiErrorOptions, V3ErrorCategory, V3ErrorOptions } from "./errors.js";
|
|
6
|
+
export { AgoraV3Error, PreconditionFailedError, V3ConfigurationError, V3ConnectionError, V3Error, V3TimeoutError, V3ValidationError, } from "./errors.js";
|
|
5
7
|
export * from "./resources.js";
|
|
6
8
|
export * from "./transport.js";
|
|
7
9
|
export * as V3 from "./types.js";
|
package/dist/cjs/v3/index.js
CHANGED
|
@@ -36,11 +36,19 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.V3Client = exports.V3 = exports.CampaignsResource = void 0;
|
|
39
|
+
exports.V3Client = exports.V3 = exports.V3ValidationError = exports.V3TimeoutError = exports.V3Error = exports.V3ConnectionError = exports.V3ConfigurationError = exports.PreconditionFailedError = exports.AgoraV3Error = exports.CampaignsResource = void 0;
|
|
40
40
|
const campaigns_js_1 = require("./campaigns.js");
|
|
41
41
|
var campaigns_js_2 = require("./campaigns.js");
|
|
42
42
|
Object.defineProperty(exports, "CampaignsResource", { enumerable: true, get: function () { return campaigns_js_2.CampaignsResource; } });
|
|
43
43
|
const resources_js_1 = require("./resources.js");
|
|
44
|
+
var errors_js_1 = require("./errors.js");
|
|
45
|
+
Object.defineProperty(exports, "AgoraV3Error", { enumerable: true, get: function () { return errors_js_1.AgoraV3Error; } });
|
|
46
|
+
Object.defineProperty(exports, "PreconditionFailedError", { enumerable: true, get: function () { return errors_js_1.PreconditionFailedError; } });
|
|
47
|
+
Object.defineProperty(exports, "V3ConfigurationError", { enumerable: true, get: function () { return errors_js_1.V3ConfigurationError; } });
|
|
48
|
+
Object.defineProperty(exports, "V3ConnectionError", { enumerable: true, get: function () { return errors_js_1.V3ConnectionError; } });
|
|
49
|
+
Object.defineProperty(exports, "V3Error", { enumerable: true, get: function () { return errors_js_1.V3Error; } });
|
|
50
|
+
Object.defineProperty(exports, "V3TimeoutError", { enumerable: true, get: function () { return errors_js_1.V3TimeoutError; } });
|
|
51
|
+
Object.defineProperty(exports, "V3ValidationError", { enumerable: true, get: function () { return errors_js_1.V3ValidationError; } });
|
|
44
52
|
__exportStar(require("./resources.js"), exports);
|
|
45
53
|
__exportStar(require("./transport.js"), exports);
|
|
46
54
|
exports.V3 = __importStar(require("./types.js"));
|
package/dist/cjs/v3/resources.js
CHANGED
|
@@ -14,6 +14,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
14
14
|
};
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.SessionsResource = exports.NumbersResource = exports.SecretsResource = exports.AgentsResource = void 0;
|
|
17
|
+
const errors_js_1 = require("./errors.js");
|
|
17
18
|
const session_lifecycle_js_1 = require("./session-lifecycle.js");
|
|
18
19
|
const transport_js_1 = require("./transport.js");
|
|
19
20
|
class AgentsResource {
|
|
@@ -34,13 +35,15 @@ class AgentsResource {
|
|
|
34
35
|
let cursor = request === null || request === void 0 ? void 0 : request.cursor;
|
|
35
36
|
const seen = new Set();
|
|
36
37
|
do {
|
|
37
|
-
const page = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options));
|
|
38
|
+
const { data: page, rawResponse } = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options).withRawResponse());
|
|
38
39
|
for (const item of page.data.list)
|
|
39
40
|
yield yield __await(item);
|
|
40
41
|
if (!page.has_more)
|
|
41
42
|
return yield __await(void 0);
|
|
42
43
|
if (!page.next_cursor || seen.has(page.next_cursor))
|
|
43
|
-
throw new
|
|
44
|
+
throw new errors_js_1.V3Error(rawResponse.status, page, rawResponse, {
|
|
45
|
+
message: "Invalid repeated or missing pagination cursor",
|
|
46
|
+
});
|
|
44
47
|
cursor = page.next_cursor;
|
|
45
48
|
seen.add(cursor);
|
|
46
49
|
} while (cursor !== undefined && cursor !== null);
|
|
@@ -75,13 +78,15 @@ class SecretsResource {
|
|
|
75
78
|
let cursor = request === null || request === void 0 ? void 0 : request.cursor;
|
|
76
79
|
const seen = new Set();
|
|
77
80
|
do {
|
|
78
|
-
const page = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options));
|
|
81
|
+
const { data: page, rawResponse } = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options).withRawResponse());
|
|
79
82
|
for (const item of page.data.list)
|
|
80
83
|
yield yield __await(item);
|
|
81
84
|
if (!page.has_more)
|
|
82
85
|
return yield __await(void 0);
|
|
83
86
|
if (!page.next_cursor || seen.has(page.next_cursor))
|
|
84
|
-
throw new
|
|
87
|
+
throw new errors_js_1.V3Error(rawResponse.status, page, rawResponse, {
|
|
88
|
+
message: "Invalid repeated or missing pagination cursor",
|
|
89
|
+
});
|
|
85
90
|
cursor = page.next_cursor;
|
|
86
91
|
seen.add(cursor);
|
|
87
92
|
} while (cursor !== undefined && cursor !== null);
|
|
@@ -125,13 +130,15 @@ class NumbersResource {
|
|
|
125
130
|
let cursor = request === null || request === void 0 ? void 0 : request.cursor;
|
|
126
131
|
const seen = new Set();
|
|
127
132
|
do {
|
|
128
|
-
const page = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options));
|
|
133
|
+
const { data: page, rawResponse } = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options).withRawResponse());
|
|
129
134
|
for (const item of page.data.list)
|
|
130
135
|
yield yield __await(item);
|
|
131
136
|
if (!page.has_more)
|
|
132
137
|
return yield __await(void 0);
|
|
133
138
|
if (!page.next_cursor || seen.has(page.next_cursor))
|
|
134
|
-
throw new
|
|
139
|
+
throw new errors_js_1.V3Error(rawResponse.status, page, rawResponse, {
|
|
140
|
+
message: "Invalid repeated or missing pagination cursor",
|
|
141
|
+
});
|
|
135
142
|
cursor = page.next_cursor;
|
|
136
143
|
seen.add(cursor);
|
|
137
144
|
} while (cursor !== undefined && cursor !== null);
|
|
@@ -167,13 +174,15 @@ class SessionsResource extends session_lifecycle_js_1.SessionLifecycleResource {
|
|
|
167
174
|
let cursor = request === null || request === void 0 ? void 0 : request.cursor;
|
|
168
175
|
const seen = new Set();
|
|
169
176
|
do {
|
|
170
|
-
const page = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options));
|
|
177
|
+
const { data: page, rawResponse } = yield __await(this.list(Object.assign(Object.assign({}, request), { cursor }), options).withRawResponse());
|
|
171
178
|
for (const item of page.data.list)
|
|
172
179
|
yield yield __await(item);
|
|
173
180
|
if (!page.has_more)
|
|
174
181
|
return yield __await(void 0);
|
|
175
182
|
if (!page.next_cursor || seen.has(page.next_cursor))
|
|
176
|
-
throw new
|
|
183
|
+
throw new errors_js_1.V3Error(rawResponse.status, page, rawResponse, {
|
|
184
|
+
message: "Invalid repeated or missing pagination cursor",
|
|
185
|
+
});
|
|
177
186
|
cursor = page.next_cursor;
|
|
178
187
|
seen.add(cursor);
|
|
179
188
|
} while (cursor !== undefined && cursor !== null);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { BaseRequestOptions } from "../BaseClient.js";
|
|
5
5
|
import type { HttpResponsePromise } from "../core/fetcher/HttpResponsePromise.js";
|
|
6
|
+
import type { RawResponse } from "../core/fetcher/RawResponse.js";
|
|
6
7
|
import type * as Schema from "./session-schema.js";
|
|
7
8
|
import { type V3Transport } from "./transport.js";
|
|
8
9
|
export type SessionGeofence = {
|
|
@@ -28,7 +29,7 @@ export interface SessionStartResponse {
|
|
|
28
29
|
status: "STARTING" | "RUNNING";
|
|
29
30
|
create_ts: number;
|
|
30
31
|
}
|
|
31
|
-
export declare function normalizeSessionStart(value: unknown): SessionStartResponse;
|
|
32
|
+
export declare function normalizeSessionStart(value: unknown, rawResponse: RawResponse): SessionStartResponse;
|
|
32
33
|
export declare function validateSessionStart(request: SessionStartRequest | EphemeralSessionStartRequest): void;
|
|
33
34
|
export declare class SessionLifecycleResource {
|
|
34
35
|
protected transport: V3Transport;
|