Protocol / crates/hippo-proto

Wire Protocol (v1)

All shared message types, relay envelopes, and error codes are defined in crates/hippo-proto/src/messages.rs and mirrored by the Dart client in mobile/lib/protocol/hippo_messages.dart.

CLI Discovery & Runner Flags

hippo-daemon executes AI CLI tools via subprocess streaming JSON rather than scraping terminal ANSI text. Each adapter maps ApprovalMode (read_only, ask_before_write, auto_safe) to native CLI flags:

CLI execution flags per adapter
Adapter Plan / Read-Only Auto-Safe / Approved Continuity
Antigravity (agy) --output-format stream-json --mode plan --dangerously-skip-permissions --sandbox (AutoSafe) Warm pool via --input-format stream-json --conversation <id>
Claude Code (claude) --output-format stream-json --verbose --include-partial-messages --permission-mode plan --permission-mode acceptEdits or bypassPermissions --resume <conversation_id>
OpenAI Codex (codex) exec --json --sandbox read-only exec --json --sandbox workspace-write Stateless per execution
OpenCode (opencode) run --format json --agent plan run --format json --agent build --auto --session <conversation_id>

Relay Envelopes (RelayEnvelope)

When communicating through hippo-relay, peers authenticate using a signed challenge nonce (hippo-relay-host-v1 or hippo-relay-client-v1) and then exchange Route envelopes:

{
  "type": "route",
  "host_id": "<uuid>",
  "client_id": "<uuid>",
  "kind": "handshake_init | handshake_ack | encrypted_frame",
  "payload_json": "{\"seq\":1,\"ciphertext_b64\":\"...\"}"
}

The relay also handles challenge, register_host, register_client, and peer_offline control frames without ever inspecting encrypted inner payloads.

Client to Host RPCs (ClientMessage)

Every variant is tagged with "type" in snake_case inside the decrypted AEAD frame:

ClientMessage variants
Type Fields Purpose
ping None Heartbeat check; triggers Pong.
list_workspaces None Returns allowlisted repositories.
list_adapters None Returns installed CLI adapters and selectable model options.
get_tree workspace_id, path Lists entries inside a directory (excluding .git, target, node_modules).
read_file workspace_id, path Reads UTF-8 file up to 512 KB, returning SHA-256 and dirty_in_ide.
write_file workspace_id, path, content, base_sha256, force_dirty Writes file with optimistic SHA-256 concurrency checks.
get_diff workspace_id Returns unstaged git diff (up to 1 MB).
run_prompt request_id, workspace_id, adapter, model, conversation_id, prompt, mode, include_ide_context Starts an agent task and streams sequenced JobEventEnvelope updates.
list_conversations / load_conversation workspace_id or conversation_id Lists or loads saved conversation turns from SQLite.
rename_conversation / delete_conversation conversation_id, optional title Manages conversation history stored on host.
resume_job / cancel_job job_id, optional last_seen_seq Replays missed events from SQLite or tears down the process tree.
approval_decision approval_id, approved, reason Approves or rejects a pending mutation request.
reset_session workspace_id, adapter Clears pooled persistent runner processes for an adapter/workspace pair.
get_quotas / set_quota_budget provider, max_requests, window_hours Reads current quota buckets or updates custom request budgets.

Host to Client Messages (HostMessage)

  • Pong { server_time }
  • WorkspacesList { workspaces } & AdaptersList { adapters }
  • TreeListing { workspace_id, path, entries }
  • FileContent { workspace_id, path, content, sha256, dirty_in_ide, truncated }
  • FileWriteResult { workspace_id, path, new_sha256 }
  • DiffResult { workspace_id, diff }
  • JobAccepted { request_id, job_id, conversation_id }
  • ConversationsList, ConversationLoaded, & SessionReset
  • JobEventEnvelope { job_id, seq, timestamp, event }
  • QuotasSnapshot { quotas } & IdeContextSnapshot { workspace_id, context }
  • Error { request_id, code, message } where code is one of unauthorized, not_found, path_forbidden, dirty_buffer_conflict, hash_mismatch, adapter_unavailable, invalid_request, or internal.

Job Events & Quota Confidence

Inside JobEventEnvelope, event carries one of six typed payloads tagged by "kind":

JobEvent variants
Kind Payload Description
output_chunk text, is_stderr Coalesced streaming output chunk from stdout or stderr.
tool_use tool_name, summary Structured tool invocation emitted by the CLI runner.
approval_required approval_id, title, command_or_diff Pauses execution until mobile returns ApprovalDecision.
status_changed status One of running, waiting_approval, completed, cancelled, or failed.
completed exit_code, input_tokens, output_tokens Final completion status and token usage counters when reported.
error message Runtime error or rate-limit message from the CLI process.

Each QuotaStatus entry also includes a QuotaConfidence enum value: exact, observed, configured, or local_usage.