JSON-RPC Protocol

Clawdius uses JSON-RPC for communication between editor extensions and the core engine.

Overview

The clawdius-code binary acts as a JSON-RPC server, communicating with editor extensions over stdio. The protocol follows the JSON-RPC 2.0 specification.

Transport

JSON-RPC messages are exchanged over standard input/output:

Editor Extension (TypeScript)
    │ stdin/stdout
    ▼
clawdius-code Binary
    │ Rust API calls
    ▼
clawdius-core Library

Request Format

{
  "jsonrpc": "2.0",
  "method": "semantic_search",
  "params": {
    "query": "error handling",
    "limit": 10
  },
  "id": 1
}

Response Format

Success

{
  "jsonrpc": "2.0",
  "result": {
    "matches": [...]
  },
  "id": 1
}

Error

{
  "jsonrpc": "2.0",
  "error": {
    "code": -32600,
    "message": "Invalid params"
  },
  "id": 1
}

Standard Methods

MethodDescriptionParams
semantic_searchSearch codebase by queryquery, limit
get_contextGet context for a filepath, line, column
chatSend a chat messagemessage, session_id, mode
get_sessionGet session detailssession_id
list_sessionsList all sessions-
create_checkpointCreate a checkpointdescription
get_completionGet code completionfile, line, column, language
git_statusGet git status-
git_diffGet git diffstaged

JSON-RPC Server (Gateway)

The clawdius-gateway crate provides an HTTP-based JSON-RPC server using jsonrpsee:

clawdius server --host 0.0.0.0 --port 8080

This exposes the same methods over HTTP/WebSocket for remote access.

Library

The jsonrpsee crate provides both server and client implementations:

[workspace.dependencies]
jsonrpsee = { version = "0.24", features = ["server", "client", "ws-client"] }

Error Codes

CodeMeaning
-32700Parse error
-32600Invalid request
-32601Method not found
-32602Invalid params
-32603Internal error

VSCode Extension Commands

The VSCode extension communicates via JSON-RPC:

CommandDescription
Clawdius: Ask a questionOpen chat input
Clawdius: Chat with selectionChat about selected code
Clawdius: Add file to contextAdd file to conversation
Clawdius: Create checkpointSave current state
Clawdius: Open chat viewOpen sidebar chat