Protocol Overview
Event Types
session_init
Sent when a session starts:stdout
Captured console output:log
Structured log messages:tool_call
Request for tool execution:tool_result_applied
Confirmation that tool result was applied:heartbeat
Keep-alive message:final
Session completed:error
Execution error:NDJSON Format
Events are sent as newline-delimited JSON:- Streaming-friendly - Parse events as they arrive
- Memory efficient - No buffering entire response
- Simple parsing - Split by newline, parse each line
Tool Call Flow
When the runtime needs to call a tool:Submitting Tool Results
End-to-End Encryption
Optional encryption using ECDH key exchange + AES-256-GCM:Key Exchange
Encrypted Events
Configuration
Reconnection
The protocol supports reconnection with event replay:Sequence Tracking
Events include sequence numbers for ordering:Event Filtering
Filter events to reduce bandwidth:Protocol Constants
| Constant | Value | Description |
|---|---|---|
PROTOCOL_VERSION | "1.0" | Protocol version |
HEARTBEAT_INTERVAL | 5000ms | Time between heartbeats |
DEFAULT_TIMEOUT | 30000ms | Default session timeout |
Related
- EnclaveJS Overview - Streaming runtime architecture
- @enclave-vm/types - Type definitions
- @enclave-vm/stream - Stream utilities