WebSocket Protocol
Aurora uses WebSocket connections for real-time, bidirectional communication with the AI agent. This enables streaming responses, live tool execution updates, and interactive confirmations.Connection
Endpoint
wss:// for production with TLS)
Authentication
Authentication is handled via the initialization message after connecting. Connection Example:Message Protocol
All messages follow a consistent JSON structure:Client → Server Messages
Initialization
Sent immediately after connection to authenticate the user.string
default:"init"
Message type identifier
string
required
Authenticated user identifier
Chat Query
Send a message to the AI agent.string
required
User’s message text
string
required
User identifier
string
required
Chat session UUID (for context continuity)
string
LLM model to use (e.g., “gpt-4”, “claude-3-opus”)
string
default:"agent"
Chat mode:
agent (read-write) or ask (read-only)string
Active cloud project ID
array
default:"[]"
File attachments (images, PDFs, etc.)
object
UI preferences to save with session
object
Direct tool invocation (bypasses AI decision-making)
Control Messages
Control ongoing operations.string
default:"control"
Message type identifier
string
required
Control action:
cancelstring
required
Session to control
string
required
User identifier
- Stops ongoing AI workflow
- Cancels pending infrastructure confirmations
- Consolidates partial messages
- Saves context for session resumption
- Sends END status to client
Confirmation Response
Respond to infrastructure confirmation requests.string
default:"confirmation_response"
Message type identifier
string
required
ID of the confirmation request
boolean
required
Whether the action is approved
string
required
User identifier
string
required
Session identifier
Server → Client Messages
Status Messages
Indicate connection and workflow status.string
default:"status"
Message type
boolean
Whether workflow is complete (only for END)
Message Chunks
Streamed response text from the AI agent.string
default:"message"
Message type
object
string
Associated session ID
- Text is sent incrementally as LLM generates it
- Chunks are split at sentence boundaries for smooth display
- Multiple chunks combine to form complete messages
- Large chunks (>100 chars) are automatically split
Tool Call Events
Notify client of tool invocations.string
default:"tool_call"
Message type
object
Tool Result Events
Report tool execution results.string
default:"tool_result"
Message type
object
Confirmation Requests
Request user approval for infrastructure changes.string
default:"confirmation_request"
Message type
object
Usage Info
API cost tracking information.string
default:"usage_info"
Message type
Error Messages
string
default:"error"
Message type
object
Rate Limiting
WebSocket connections are rate-limited:- Rate: 5 messages per 60 seconds per client
- Enforcement: Token bucket algorithm
- Response: Error message when limit exceeded
Connection Lifecycle
- Connect - Establish WebSocket connection
- Initialize - Send init message with user_id
- Ready - Receive START status
- Chat - Exchange messages and receive responses
- Tools - Receive tool call events during execution
- Complete - Receive END status when done
- Disconnect - Close connection gracefully
Best Practices
Connection Management
- Implement automatic reconnection with exponential backoff
- Handle connection drops gracefully
- Send init message immediately after connecting
- Monitor connection state and show status to user
Message Handling
- Buffer message chunks for display
- Update UI progressively as chunks arrive
- Show tool execution status in real-time
- Handle out-of-order messages by session_id
Error Recovery
- Retry failed messages with exponential backoff
- Show connection errors to user
- Allow manual retry of failed operations
- Preserve unsent messages across reconnections
Performance
- Keep WebSocket connection alive between messages
- Reuse connections for multiple sessions
- Close connections after extended inactivity
- Monitor memory usage from buffered chunks