New protocol version released: This page may contain outdated information.
Creating a Client
Factory Function (Recommended)
Direct Constructor
Configuration Options
The transport protocol to use for communication.
Connection Management
connect()
Establishes a connection to the HAIP server.Promise<void>
Events:
connect- Emitted when connection is establishedhandshake- Emitted when handshake is completederror- Emitted if connection fails
disconnect()
Gracefully disconnects from the server.Promise<void>
Events:
disconnect- Emitted when disconnection is complete
isConnected()
Checks if the client is currently connected.boolean
Run Management
startRun()
Starts a new HAIP run session.Promise<string> - The generated run ID
finishRun()
Completes a run with the specified status.cancelRun()
Cancels an active run.Messaging
sendTextMessage()
Sends a text message on the specified channel.Promise<string> - The generated message ID
sendMessage()
Sends a custom HAIP message.sendBinary()
Sends binary data.Tool Integration
callTool()
Initiates a tool call.Promise<string> - The generated call ID
updateTool()
Updates the status of a tool call.completeTool()
Completes a tool call with results.cancelTool()
Cancels a tool call.Event Handling
The client extends EventEmitter and provides the following events:Connection Events
Message Events
Error Events
State Management
getConnectionState()
Gets the current connection state.HAIPConnectionState
getPerformanceMetrics()
Gets performance metrics.HAIPPerformanceMetrics
getActiveRuns()
Gets all active runs.HAIPRun[]
getRun()
Gets a specific run by ID.HAIPRun | undefined
Flow Control
sendFlowUpdate()
Sends a flow control update.Channel Control
pauseChannel()
Pauses message flow on a channel.resumeChannel()
Resumes message flow on a channel.Replay Support
requestReplay()
Requests message replay from a specific sequence number.Audio Support
sendAudioChunk()
Sends an audio chunk.Error Handling
The client provides comprehensive error handling:Next Steps
Transports
Learn about different transport options and configurations.
Examples
See practical examples of client usage.
Types
Explore the complete type definitions.
API Reference
Full API reference documentation.