import { EventEmitter } from 'eventemitter3'; import { T as Transcript } from './TranscriptManager-Bh-JJm_m.js'; import { TrilletRoomDetails } from './server.js'; /** * Browser Fingerprinting Utility * Generates a deterministic fingerprint based on stable browser/hardware characteristics. * Used for demo link usage limit tracking. * * Strategy: * 1. localStorage persistence — generate once, reuse across tabs/sessions forever * 2. Stable hardware-only seed — if storage is cleared, the same hardware signals * produce the same hash, so the fingerprint stays consistent * 3. Server-side IP fallback — handled by the backend when no fingerprint is sent */ declare class BrowserFingerprint { private static cachedFingerprint; /** * Generate (or retrieve) a deterministic browser fingerprint. * Cached in memory → localStorage → derived from stable hardware signals. */ static generate(): Promise; /** * Collect only hardware / environment signals that do NOT change between * tabs, sessions, or browser restarts on the same device. * * Deliberately excluded (volatile / anti-fingerprint randomised): * - canvas.toDataURL() — randomised per origin in many browsers * - font detection — noisy across rendering states * - screen.availWidth/Height — changes with taskbar / dock resize * - navigator.doNotTrack — user can toggle * - timezoneOffset — changes with DST * - navigator.userAgent — changes on browser update */ private static getStableSignals; /** * WebGL vendor + renderer string (GPU identifier, very stable) */ private static getWebGLFingerprint; /** * SHA-256 hash of the signals object → hex string */ private static hashComponents; private static getStored; private static persist; /** * Clear both in-memory and persisted fingerprint (useful for testing) */ static clearCache(): void; } interface TrilletAgentConfig { apiKey?: string; workspaceId?: string; agentId: string; variables?: Record; callbackUrl?: string; /** * `voice` and `text` are single-modality sessions. `multimodal` is one conversation * the visitor can type in or talk in, switching any time with {@link setVoiceEnabled}. */ mode?: 'voice' | 'text' | 'multimodal'; /** Multimodal only: start with the microphone on (the visitor chose to call). */ startWithVoice?: boolean; /** Override the API host (whitelabel API domain, or a local backend in development). */ apiBaseUrl?: string; demoHash?: string; /** * Pre-call gate. Awaited once at the top of every call-start path — before any * network request or LiveKit connection — so a rejection aborts the call cleanly * with nothing minted and nothing connected. * * Plug your own verification in here: a reCAPTCHA challenge you verify on your * server, a login check, a quota lookup. Throw (or reject) to block the call; the * error propagates to the caller and is emitted on the `error` event. * * @example * const agent = new TrilletAgent({ * agentId, * onBeforeCall: async () => { * const ok = await myServer.verifyHuman(); * if (!ok) throw new Error('Verification failed'); * }, * }); */ onBeforeCall?: () => Promise; } declare class TrilletAgent extends EventEmitter { private sdk; private config; private sdkToken; private transcriptManager; constructor(config: TrilletAgentConfig); private setupEventForwarding; /** * Set up default RPC handlers for common agent interactions * This should be called after connection is established */ private setupDefaultRpcHandlers; /** * **Server-side only — requires an API key, do not call from the browser.** * * Puts a full-privilege `X-API-KEY` on the request, so this must run where the * key is safe. For the secure pattern, mint the room on your backend with * `createCall` (from `@trillet-ai/web-sdk/server`) and call {@link joinRoom} in * the browser instead. Kept for backward compatibility. */ startCall(): Promise; startPublicCall(): Promise; /** * Connect to a pre-minted Trillet room. The secure browser entry point: takes * the room details returned by `createCall` (server-side) and joins LiveKit * directly — makes NO Trillet API call, so no API key, workspaceId or agentId * ever reaches the browser. * * @param roomDetails - the backend response, e.g. `{ connection: { url, token }, ... }` */ joinRoom(roomDetails: TrilletRoomDetails): Promise; /** * Run the caller's pre-call gate, if any. * * Invoked by each public call-start path exactly once. `startCall` and * `startPublicCall` therefore delegate to {@link connectToRoom} rather than to the * public {@link joinRoom} — routing them through `joinRoom` would fire a customer's * hook a second time per call, re-running their challenge or verification request. */ private runBeforeCall; /** Join LiveKit. Assumes the pre-call gate has already run. */ private connectToRoom; endCall(): void; toggleMicrophone(enabled: boolean): void; private muted; /** True while the visitor's microphone is muted on a live voice call. */ get isMuted(): boolean; /** * Mute or unmute the visitor's microphone and wait for LiveKit to apply it. * Emits `muteChanged` (boolean). A no-op when no call is connected. */ setMuted(muted: boolean): Promise; private updateMuted; get isAssistantSpeaking(): boolean; /** The settled record: finals only. */ getTranscripts(): Transcript[]; /** Finals plus speech still in progress, the same list `transcriptUpdate` carries. */ getLiveTranscripts(): Transcript[]; getCurrentTranscript(): { [key: string]: string; }; /** * Register an RPC method handler for receiving calls from the agent * @param method - The RPC method name to handle * @param handler - The function to handle the RPC call */ registerRpcMethod(method: string, handler: (data: any) => Promise | any): void; /** * Send an RPC call to the agent * @param method - The RPC method name * @param payload - The data to send * @param responseTimeout - Timeout in milliseconds (default: 30000) */ sendRpcMessage(method: string, payload: any, responseTimeout?: number): Promise; private voiceEnabled; private recentTyped; /** Multimodal: whether the microphone/voice side is currently on. */ get isVoiceEnabled(): boolean; /** * Multimodal only: switch the SAME conversation between typing and talking. Turns * the mic on/off and tells the agent, which turns its speech on/off and keeps the * whole conversation in context. Emits `modalityChanged` with 'voice' | 'text'. */ setVoiceEnabled(enabled: boolean): Promise; /** * Emit `greetingSkipped` once the agent says it will not greet (participant attribute * `trillet.greeting=none`, TRI-2230), so a message held for the greeting can go now. */ private watchGreeting; /** * Resolve once the agent's session is ready to receive (its `lk.agent.state` has * moved past "initializing"), or reject after `timeoutMs`. Joining the room is not * enough: a text message sent before the session listens is silently dropped. */ private waitForAgent; sendTextMessage(text: string): Promise; /** * Get the browser fingerprint for this session * Useful for demo pages to send fingerprint when checking limits */ getBrowserFingerprint(): Promise; } export { BrowserFingerprint, TrilletAgent, type TrilletAgentConfig, TrilletRoomDetails };