Skip to main content
Complete reference for the SynapseSDK class and the public exports of @eka-care/medassist-core.

SynapseSDK methods

startSession

startSession(existingSession?: { session_id: string; session_token: string }): Promise<SessionResponse>
Creates a new session — or validates and refreshes an existing one — and sets up the connection. Returns a SessionResponse.

sendMessage

sendMessage(options: SendMessageOptions): Promise<void>
Sends a message, files, audio, or a tool result. Options:
FieldTypePurpose
messagestringText content.
messageIdstringOptional message identifier.
filesFile[]File attachments.
audioAudioMetaDataA recorded audio clip.
toolCalledbooleanMarks an elicitation-component response.
tool_declinedbooleanThe user declined a suggested tool.
tool_idstringThe tool this message relates to.
tool_resultRecord<string, unknown>Result from a tool / elicitation.
initial_promptsTInitalPrompt[]Initial conversation prompts.
hiddenbooleanSend without showing the message to the user.

callTool

callTool(tool_id: string, message_id: string, params?: Record<string, unknown>): Promise<void>
Executes a tool with parameters. The result returns as a TOOL_CALL event.

sendFeedback

sendFeedback(messageId: string, feedback: USER_FEEDBACK, reason?: string): Promise<void>
Sends like/dislike feedback on a message.

on / off

on(event: SYNAPSE_REALTIME_EVENTS, listener: (...args: unknown[]) => void): void
off(event: SYNAPSE_REALTIME_EVENTS, listener: (...args: unknown[]) => void): void
Register and remove event listeners. See Events. off needs the same function reference passed to on.

startRecording / endRecording

startRecording(options: {
  onChunks: (chunks: AudioMetaData) => void;
  onError?: (error: Error) => void;
}): Promise<void>

endRecording(): void
Start and stop audio recording. See Voice & audio.

getSessionConfig

getSessionConfig(): SessionResponse
Returns the current session config. Throws if no session is initialized.

getAgentConfig

getAgentConfig(): Promise<AgentConfigResponse>
Fetches the agent’s configuration — theme, connectivity, initial message, watermark.

isConnected

isConnected(): boolean
Whether the SDK is currently connected.

voice

get voice(): VoiceAgent
Returns a VoiceAgent for voice-mode conversations.

endSession

endSession(): void
Closes the connection and cleans up resources.

Types

SessionResponse

interface SessionResponse {
  session_id: string;
  session_token?: string;
  session_validity_s?: string;
  user_id?: string;
  msg?: string;
  initial_message?: TInitialMessage;
}

TContext

type TContext = {
  profile?: {
    mobile?: string;
    name?: string;
    age?: number;
    gender?: string;
    marital_status?: string;
  };
  intent?: string;
  user_location?: { lat: number; long: number };
  referer?: string;
  [key: string]: unknown;
};

Environment

type Environment = "development" | "production" | "staging";

SynapseSDKCallbacks

interface SynapseSDKCallbacks {
  onSessionRefreshed?: (session: SessionResponse) => void;
  onError?: (error: TSynapseError) => void;
}

TSynapseError

interface TSynapseError {
  message: string;
  error?: { code?: string; msg?: string } & Record<string, unknown>;
  code?: string;
  status?: number;
  context?: Record<string, unknown>;
}

ToolCallData

type ToolCallData = {
  tool_id: string | null;
  tool_type?: SYNAPSE_TOOL_TYPES;
  tool_name: string;
  details?: ToolDetails; // component, status, input, _meta
  meta?: Record<string, unknown>;
};

Enums

SYNAPSE_REALTIME_EVENTS

CONNECTED, DISCONNECTED, PROGRESS_MESSAGE, MESSAGE_CHUNK, TIPS_MESSAGE, END_OF_STREAM, ERROR, TOOL_CALL, AUDIO_TRANSCRIPT, TOOL_START, TOOL_END. See Events.

SYNAPSE_COMPONENTS

MOBILE (mobile_number), OTP (otp), EMAIL (email_address), PILL (pills), MULTI (multi), DOCTOR_CARD (doctor_card), CARD (card), MEDIA_CARD (media_card).

SYNAPSE_EICITATION_STATUS

PROGRESS (progress), SUCCESS (success), FAILURE (failure).

USER_FEEDBACK

LIKE, DISLIKE, NONE.

SYNAPSE_REALTIME_ERROR_CODES

ConstantValue
SESSION_INACTIVEsession_not_found
SESSION_EXPIREDsession_expired
INVALID_EVENTinvalid_event
INVALID_CONTENT_TYPEinvalid_content
PARSING_ERRORparsing
FILE_UPLOAD_INPROGRESSfile_upload_inprogress
TIMEOUTtimeout
SERVER_ERRORserver_error
SESSION_TOKEN_MISMATCHsession_token_mismatch
PROMPT_FETCH_ERRORprompt_fetch_error
INVALID_FILE_REQUESTinvalid_file_request

DisconnectionReason

CLIENT_CLOSED, SERVER_CLOSED, CONNECTION_ERROR, AUTHENTICATION_ERROR, MAX_RECONNECT_ATTEMPTS, TIMEOUT, NETWORK_ERROR.
Always import enum values from @eka-care/medassist-core rather than hardcoding their string values — the strings are an implementation detail and the enums are the stable contract.