Skip to content

Web / WebSocket

Human provides a WebSocket-based channel for web UIs and browser extensions. Supports local mode (direct WebSocket to the gateway) and relay mode (connect through a relay server).

  • Build with -DHU_ENABLE_WEB=ON or -DHU_ENABLE_ALL_CHANNELS=ON
  • Gateway running for WebSocket connections
  • Web UI or browser extension that implements the WebChannel v1 protocol

For development or local use, bind to loopback:

{
"channels": {
"web": {
"accounts": {
"default": {
"transport": "local",
"listen": "127.0.0.1",
"port": 32123,
"path": "/ws",
"auth_token": "replace-with-long-random-token",
"allowed_origins": [
"http://localhost:5173",
"chrome-extension://your-extension-id"
]
}
}
}
}
}

For remote access, use the relay transport:

{
"channels": {
"web": {
"accounts": {
"default": {
"transport": "relay",
"relay_url": "wss://relay.human.io/ws/agent",
"relay_agent_id": "default",
"relay_token": "replace-with-relay-token",
"relay_token_ttl_secs": 2592000,
"relay_pairing_code_ttl_secs": 300,
"relay_ui_token_ttl_secs": 86400,
"relay_e2e_required": false
}
}
}
}
}
FieldTypeDescription
transportstring"local" or "relay"
listenstringBind address (127.0.0.1 local, 0.0.0.0 for remote)
portnumberWebSocket port
pathstringWebSocket path (e.g. /ws)
auth_tokenstringOptional; required when binding non-loopback
allowed_originsarrayCORS origins for WebSocket upgrade
relay_urlstringRelay server WebSocket URL (relay mode)
relay_agent_idstringAgent identifier on the relay
relay_tokenstringToken for relay authentication
relay_token_ttl_secsnumberTTL for relay token
relay_pairing_code_ttl_secsnumberPairing code expiry
relay_ui_token_ttl_secsnumberUI JWT TTL
relay_e2e_requiredboolRequire E2E encryption for relay payloads
  1. Client sends pairing_request with one-time pairing_code
  2. Server responds with pairing_result including access_token (JWT)
  3. Client includes access_token in every user_message (top-level or payload.access_token)
  • assistant_chunk: Streaming text chunks
  • assistant_final: Final assistant message
  • Event envelope format: {"v":1,"type":"assistant_chunk"|"assistant_final","session_id":"...","agent_id":"default","payload":{"content":"..."}}
  • Local: WebSocket server runs in the gateway; UI connects directly to ws://127.0.0.1:port/path
  • Relay: Agent connects outbound to relay; UI connects to relay separately; relay routes messages

When relay_e2e_required is true, the UI and agent exchange X25519 keys during pairing and send encrypted payloads in payload.e2e.

  • Gateway required: Web channel needs the gateway for WebSocket serving
  • Token validation: Optional auth_token validates WebSocket upgrade when binding non-loopback
  • Protocol: See spec/webchannel_v1.json for the full WebChannel v1 specification
  • UI/extension separate: The web UI or Chrome extension lives in a separate repository and connects via the WebSocket endpoint