import type { AgoraArea } from "./agentkit/area.js"; import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; import { AgoraClient as BaseAgoraClient } from "./Client.js"; import { Pool } from "./core/domain/index.js"; /** * Auth mode for the client: * - `basic`: Customer ID + Secret for REST API (HTTP Basic Auth) * - `token`: Pre-built `agora token=` auth header * - `app-credentials`: appId + appCertificate only; AgentSession generates * a fresh ConvoAI token per API call */ export type AgoraAuthMode = "basic" | "token" | "app-credentials"; export declare namespace AgoraClient { type Options = BaseOptions & AuthOptions; interface BaseOptions extends Omit { /** The area to use for regional URL selection */ area: TArea; /** Agora App ID — used as the `appid` path parameter and for RTC token generation */ appId: string; /** Agora App Certificate — used to sign RTC tokens. Keep this secret. */ appCertificate: string; } /** Use Customer ID + Secret for REST API authentication (HTTP Basic Auth) */ interface BasicAuthOptions { customerId: string; customerSecret: string; authToken?: never; } /** Use a pre-built Agora token for REST API authentication. Pass the raw token; the SDK sets `Authorization: agora token=` automatically. */ interface TokenAuthOptions { authToken: string; customerId?: never; customerSecret?: never; } /** * Use only appId + appCertificate. AgentSession generates a fresh * ConvoAI token per API call — no Customer Secret required. */ interface AppCredentialsOptions { customerId?: never; customerSecret?: never; authToken?: never; } type AuthOptions = BasicAuthOptions | TokenAuthOptions | AppCredentialsOptions; interface RequestOptions extends BaseRequestOptions { } } /** * AgoraClient extends the base client with domain pool support for * regional URL cycling and automatic domain selection. * * Three authentication modes are supported: * * **App credentials (recommended)** — no Customer Secret needed; AgentSession * generates a short-lived ConvoAI token per API call: * ```typescript * const client = new AgoraClient({ * area: Area.US, * appId: "your-app-id", * appCertificate: "your-app-certificate", * }); * ``` * * **Token auth** — pass a raw Agora token; the SDK sets the `agora token=` header automatically: * ```typescript * const client = new AgoraClient({ * area: Area.US, * appId: "your-app-id", * appCertificate: "your-app-certificate", * authToken: "", * }); * ``` * * **Basic auth** — Customer ID + Secret from Agora Console: * ```typescript * const client = new AgoraClient({ * area: Area.US, * appId: "your-app-id", * appCertificate: "your-app-certificate", * customerId: "your-customer-id", * customerSecret: "your-customer-secret", * }); * ``` */ export declare class AgoraClient extends BaseAgoraClient { protected readonly _pool: Pool; /** Agora App ID */ readonly appId: string; /** Agora App Certificate (used for RTC token signing) */ readonly appCertificate: string; /** The active authentication mode */ readonly authMode: AgoraAuthMode; /** The configured routing area */ readonly area: TArea; constructor(options: AgoraClient.Options); /** * Get the underlying domain pool for advanced usage. * You can use this to manually cycle regions or select the best domain. */ get pool(): Pool; /** * Cycle to the next region prefix in the pool. * Call this when a request fails to try a different region. */ nextRegion(): void; /** * Select the best domain using DNS resolution. * This is automatically called periodically, but you can call it manually. */ selectBestDomain(signal?: AbortSignal): Promise; /** * Get the current URL being used for requests. */ getCurrentURL(): string; /** * Stop an agent by its ID. * * Use this when handling a stop request from your client app (e.g., an end-call * button) without holding an `AgentSession` reference. Create a client with the * same credentials used to start the agent and call this method. * * If the agent has already stopped (e.g., timed out or crashed), this method * returns successfully rather than throwing. * * @param agentId - The agent instance ID returned by `AgentSession.start()` * * @example * // End-call handler — no session reference needed * const client = new AgoraClient({ area: Area.US, appId: '...', appCertificate: '...' }); * await client.stopAgent(agentId); */ stopAgent(agentId: string): Promise; }