API reference
Full list of exports, types, and type literals.
Exports
Classes & functions
| Kind | Name |
|---|---|
| Class | BuddyClient — new BuddyClient(options) |
| Function | joinRoom(options) — standalone direct-join; returns Promise<Session> |
| Class | BuddyError — base error; all SDK errors extend it |
| Class | AuthenticationError extends BuddyError |
| Class | APIError extends BuddyError |
| Class | NetworkError extends BuddyError |
| Class | TimeoutError extends BuddyError |
| Class | InvalidRequestError extends BuddyError |
| Class | SessionError extends BuddyError |
Types
import type {
// Client
ClientOptions,
StartSessionOptions,
JoinRoomOptions,
ExecutionMode,
CreateLeadOptions,
LeadResult,
API,
// Session
Session,
SessionState,
SessionEvent,
SessionEventMap,
WildcardHandler,
Unsubscribe,
// Status + transcripts
ConnectionStatus,
TranscriptEntry,
UserTranscript,
AssistantTranscript,
ToolCallTranscript,
// Server-emitted lifecycle
ConversationEndReason,
PipelineErrorDetails,
// Helper-event shapes
AssistantSpeakingEvent,
UserSpeakingEvent
} from '@juspay/breeze-buddy-client-sdk'; Type literals
ConnectionStatus
type ConnectionStatus =
| 'idle'
| 'connecting'
| 'connected'
| 'disconnecting'
| 'disconnected'
| 'error'; ExecutionMode
type ExecutionMode = 'production' | 'test' | 'stream'; Maps to wire values DAILY, DAILY_TEST, DAILY_STREAM respectively.
ConversationEndReason
type ConversationEndReason = 'idle_timeout' | 'client_disconnected'; PipelineErrorDetails
type PipelineErrorDetails = {
processor: string;
error: string;
}; AssistantSpeakingEvent
type AssistantSpeakingEvent =
| { type: 'start' }
| { type: 'chunk'; text: string }
| { type: 'end' }; UserSpeakingEvent
type UserSpeakingEvent =
| { type: 'start' }
| { type: 'end' }; Type shapes
ClientOptions
type ClientOptions = {
baseUrl?: string; // defaults to 'https://clairvoyance.breezelabs.app'
auth: { token: string };
resellerId: string;
merchantId: string;
}; StartSessionOptions
type StartSessionOptions = {
templateId: string;
payload?: Record<string, unknown>;
requestId?: string;
executionMode?: ExecutionMode;
on?: Partial<SessionEventMap>;
}; JoinRoomOptions
type JoinRoomOptions = {
roomUrl: string;
token: string;
on?: Partial<SessionEventMap>;
}; Session
type Session = {
getState: () => SessionState;
close: () => Promise<void>;
mute: () => void;
unmute: () => void;
setMicEnabled: (enabled: boolean) => void;
assistantSpeak: (text: string) => Promise<void>;
sendMessage: (msgType: string, data?: unknown) => void;
on: <E extends SessionEvent>(event: E, handler: SessionEventMap[E]) => void;
off: <E extends SessionEvent>(event: E, handler: SessionEventMap[E]) => void;
onUserTranscript: (handler: (entry: UserTranscript) => void) => Unsubscribe;
onAssistantTranscript: (handler: (entry: AssistantTranscript) => void) => Unsubscribe;
onToolCall: (handler: (entry: ToolCallTranscript) => void) => Unsubscribe;
onAssistantSpeaking: (handler: (event: AssistantSpeakingEvent) => void) => Unsubscribe;
onUserSpeaking: (handler: (event: UserSpeakingEvent) => void) => Unsubscribe;
[Symbol.asyncDispose]?: () => Promise<void>;
}; SessionState
type SessionState = {
status: ConnectionStatus;
isMicEnabled: boolean;
transcripts: TranscriptEntry[];
assistantAudioTrack: MediaStreamTrack | null;
userAudioTrack: MediaStreamTrack | null;
error: string | null;
}; TranscriptEntry
type UserTranscript = {
id: string;
role: 'user';
text: string;
isComplete: boolean;
};
type AssistantTranscript = {
id: string;
role: 'assistant';
text: string;
isComplete: boolean;
};
type ToolCallTranscript = {
id: string;
role: 'tool_call';
functionName: string;
isComplete: boolean;
};
type TranscriptEntry = UserTranscript | AssistantTranscript | ToolCallTranscript; SessionEventMap
type SessionEventMap = {
// Connection lifecycle
'connected': () => void;
'disconnected': () => void;
'error': (message: string) => void;
'state-change': (status: ConnectionStatus) => void;
'assistant-ready': () => void;
// Conversation lifecycle (server-emitted)
'conversation-start': () => void;
'conversation-end': (reason: ConversationEndReason) => void;
'pipeline-error': (details: PipelineErrorDetails) => void;
// Media
'track-started': (track: MediaStreamTrack, local: boolean) => void;
'track-stopped': (track: MediaStreamTrack, local: boolean) => void;
'mic-change': (enabled: boolean) => void;
// Speech activity (VAD)
'user-speech-start': () => void;
'user-speech-end': () => void;
'assistant-speech-start': () => void;
'assistant-speech-end': () => void;
// TTS lifecycle
'tts-start': () => void;
'tts-chunk': (text: string) => void;
'tts-end': () => void;
// Transcripts + telemetry
'transcript': (entry: TranscriptEntry) => void;
'metrics': (data: unknown) => void;
// Wildcard
'*': WildcardHandler;
};
type SessionEvent = keyof SessionEventMap;
type WildcardHandler = (event: Exclude<SessionEvent, '*'>, ...args: unknown[]) => void;
type Unsubscribe = () => void; CreateLeadOptions & LeadResult (low-level API)
type CreateLeadOptions = {
templateId: string;
payload?: Record<string, unknown>;
requestId?: string;
executionMode?: ExecutionMode;
};
type LeadResult = {
leadId: string;
};
// Accessible via client.api.createLead(options)
type API = {
createLead: (options: CreateLeadOptions) => Promise<LeadResult>;
}; Stability
Pre-1.0 (0.1.0). Breaking changes may land in minor versions until 1.0.0. Pin an exact version if stability matters. Deprecations will be documented in CHANGELOG.md.
Was this helpful?