export * from "./errors"; export { AvatarError } from "../core/AvatarError"; /** * Log level for SDK logging */ export type LogLevel = "verbose" | "debug" | "info" | "warn" | "error"; /** * Environment type */ export type Environment = "cn" | "overseas"; /** * AvatarSDK configuration interface * * SDK supports three authentication methods: * 1. Permanent AK/SK: Set appKey and secretKey only. No refresh needed. * 2. Temporary AK/SK + STS: Set appKey, secretKey, and stsToken. * All three need to be refreshed together via updateTempAKSK(). * 3. WSS Token: Set wssToken only. Refresh via updateWssToken(). * * Authentication priority: AK/SK > WSS Token * * @note Structural config properties (environment, logEnabled, etc.) are immutable after initialization. * Only authentication credentials can be updated via dedicated methods. */ export interface AvatarSDKConfig { /** * App Key (Optional, required for AK/SK authentication) * Use with secretKey for permanent or temporary AK/SK authentication. */ appKey?: string; /** * Secret Key (Optional, required for AK/SK authentication) * Use with appKey for permanent or temporary AK/SK authentication. */ secretKey?: string; /** * STS Token (Optional) * Required for temporary AK/SK + STS authentication. * Must be used together with appKey and secretKey. * Refresh all three via updateTempAKSK(). */ stsToken?: string | null; /** * WSS Token (Optional) * Use for WSS Token authentication (without AK/SK). * Refresh via updateWssToken(). */ wssToken?: string | null; /** Enable logging (Optional), default is true */ logEnabled?: boolean; /** Log level (Optional), default is "info" */ logLevel?: LogLevel; /** Environment type (Optional), default is "cn" */ environment?: Environment; /** Extra parameters dictionary (Optional) */ extraDict?: Record; } /** * AvatarSession configuration interface * * Supports two avatar modes: * - **FlowAct-R1**: Provide `avatarImageUrl` (photo URL of the avatar). * - **FlowAct-R2**: Provide `roleId` (server-created avatar role ID). * * At least one of `avatarImageUrl` or `roleId` must be provided. */ export interface AvatarSessionConfig { /** * Avatar image URL (Required for FlowAct-R1). Photo URL of the avatar. * Omit when using FlowAct-R2 with `roleId`. */ avatarImageUrl?: string; /** * Avatar Role ID (Required for FlowAct-R2). The role ID returned by the * avatar creation API. Omit when using FlowAct-R1 with `avatarImageUrl`. */ roleId?: string; /** Speaker (Required). The speaker ID for TTS */ speaker: string; /** User prompt (Optional). Custom prompt for the avatar */ userPrompt?: string; /** * Speech rate (Optional). Controls the speed of output speech, * value range [-50, 100], default is 0 */ speechRate?: number; /** * Loudness rate (Optional). Controls the volume of output speech, * value range [-50, 100], default is 0 */ loudnessRate?: number; /** Enable web search (Optional), default is false */ enableWebsearch?: boolean; /** * Action list (Optional). List of looping actions for the avatar. * Each element is a string identifier of the action. */ actionList?: string[]; /** Extra parameters dictionary (Optional) */ extraParams?: Record; } /** * Avatar session state */ export type AvatarSessionState = "idle" | "starting" | "started" | "ending" | "ended"; /** * Image or video stream scaling mode */ export type RenderMode = /** * Fit the view first, default value. * Video scales proportionally until it fills the view. When video and view dimensions don't match, * the extra part of the video will be cropped. */ "hidden" /** * Show all video content first. * Video scales proportionally to ensure all content is visible. When video and view dimensions don't match, * the unfilled area of the view will be filled with background color. */ | "fit" /** * Video adapts to canvas. * Video scales non-proportionally to fill the view. During this process, the aspect ratio of the video may change. */ | "fill"; /** * Audio frame data structure */ export interface AudioFrame { /** Sample rate of the audio */ sampleRate: number; /** Number of audio channels */ channel: number; /** Number of samples in the frame */ samples: number; /** PCM audio buffer */ buffer: Uint8Array; } /** * AvatarSession event types and their argument signatures */ export interface AvatarSessionEvents { /** Session did start successfully */ start: []; /** Called when an Avatar session has ended, either by request or due to an error */ end: [error?: Error]; /** Audio capture started successfully */ audioCaptureStart: []; /** Audio capture stopped */ audioCaptureStop: []; /** Audio capture error (either start failed or runtime error) */ audioCaptureFail: [error: Error]; /** Audio frame callback from local microphone recording */ audioFrame: [frame: AudioFrame]; }