Plugin Protocol
oxide-code hosts long-lived out-of-process plugins over stdio using newline-delimited JSON-RPC 2.0 (NDJSON). Each message is a single UTF-8 JSON object terminated by \n. The host inherits plugin stderr for diagnostics and terminates the child process on exit.
Configuration
Section titled “Configuration”Plugins are configured in config.toml via [[plugins]] entries:
[[plugins]]name = "example"command = ["/path/to/my-plugin", "--stdio"]timeout_ms = 30000env = { EXAMPLE_MODE = "strict" }config = { mode = "strict", retries = 3 }| Field | Type | Default | Description |
|---|---|---|---|
name |
string |
Required | Human-readable plugin name |
command |
string[] |
Required | Executable and arguments to spawn |
timeout_ms |
integer |
30000 |
Per-request timeout in milliseconds |
env |
map<string, string> |
None | Extra environment variables for the child process |
config |
any |
{} |
Opaque plugin configuration forwarded in initialize |
Host-to-Plugin Requests
Section titled “Host-to-Plugin Requests”initialize
Section titled “initialize”Sent immediately after spawning the plugin. The config field carries the plugin’s [[plugins]].config value verbatim (or {} when omitted). The plugin responds with its PluginManifest.
Request:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocol_version":1,"config":{"mode":"strict"}}}Response:
{ "jsonrpc": "2.0", "id": 1, "result": { "name": "example", "version": "0.1.0", "tools": [ { "name": "example_tool", "description": "Run an example action", "input_schema": {"type": "object"}, "deferred": false } ], "commands": [ { "name": "example", "description": "Run example command", "default_keybinding": "ctrl+e" } ], "hooks": [ { "event": "PreToolUse", "matcher": "bash", "on_error": "allow" } ], "prompt_sections": [ { "name": "example_guidelines", "content": "Follow example plugin conventions." } ], "attachment_converters": ["application/pdf", "video/*"], "compaction": true }}Each entry in tools accepts an optional deferred boolean (defaults to false). When deferred is true, the host omits the tool’s full schema from model requests until the model loads it via load_tool_schemas.
tool/call
Section titled “tool/call”Invokes a tool declared in the plugin manifest.
Request:
{"jsonrpc":"2.0","id":2,"method":"tool/call","params":{"name":"example_tool","arguments":{"key":"value"}}}Response:
{"jsonrpc":"2.0","id":2,"result":{"content":"output text","is_error":false}}command/list
Section titled “command/list”Optional request that queries the plugin’s current slash commands (for dynamic refresh). If a plugin returns -32601 (method not found), the host falls back to the static commands array from initialize.
Request:
{"jsonrpc":"2.0","id":3,"method":"command/list","params":{}}Response:
{ "jsonrpc": "2.0", "id": 3, "result": { "commands": [ { "name": "example:review", "description": "Review a pull request", "arguments": [ { "name": "pr", "description": "PR number", "required": true } ] } ] }}command/invoke
Section titled “command/invoke”Invokes a plugin slash command with a raw argument string and runtime context (including state_db_path, session_id, cwd, model, and provider). The host also injects OX_STATE_DB into the plugin process environment (unless already configured in env) and forwards state_db_path in initialize so plugins such as a custom /stats provider can read $XDG_STATE_HOME/ox/state.db directly.
Request:
{"jsonrpc":"2.0","id":4,"method":"command/invoke","params":{"name":"stats","args":"week","context":{"state_db_path":"/home/user/.local/state/ox/state.db","session_id":"session-1","cwd":"/workspace","model":"claude-sonnet-5-5","provider":"anthropic"}}}Response:
{"jsonrpc":"2.0","id":4,"result":{"content":"## Weekly Usage\n...","description":"Weekly usage summary","mode":"markdown"}}mode is optional and controls how the host handles content:
"markdown"(default): Renders a Markdown transcript entry."system": Appends a plain system notice."prompt": Submitscontentas a user prompt to the agent.
hook/invoke
Section titled “hook/invoke”Invokes a lifecycle hook subscribed in PluginManifest.hooks. Parameters match the HookInput JSON payload delivered to command hooks.
Request:
{"jsonrpc":"2.0","id":6,"method":"hook/invoke","params":{"event":"PreToolUse","cwd":"/workspace","tool_name":"bash","tool_input":{"command":"ls"}}}Response:
{"jsonrpc":"2.0","id":6,"result":{"block":false,"systemMessage":"checked","hookSpecificOutput":{"updatedInput":{"command":"ls -la"}}}}prompt/sections
Section titled “prompt/sections”Optional request that queries dynamic system prompt sections for the current working directory. If a plugin returns -32601 (method not found), the host falls back to the static prompt_sections array from initialize.
Request:
{"jsonrpc":"2.0","id":7,"method":"prompt/sections","params":{"cwd":"/workspace"}}Response:
{"jsonrpc":"2.0","id":7,"result":{"sections":[{"name":"example_guidelines","content":"Dynamic guidance."}]}}attachment/convert
Section titled “attachment/convert”Converts a multimodal attachment into one or more wire-neutral ContentBlock items (such as extracted text or rendered images) for models that do not accept the original media type or size natively. Plugins advertise supported MIME types or wildcard patterns (for example "application/pdf", "video/*") in PluginManifest.attachment_converters.
Request:
{ "jsonrpc": "2.0", "id": 8, "method": "attachment/convert", "params": { "media_type": "application/pdf", "filename": "report.pdf", "data_base64": "<base64>", "target_modalities": ["text", "image"] }}Large local files may supply "path" instead of "data_base64".
Response:
{ "jsonrpc": "2.0", "id": 8, "result": { "blocks": [ { "type": "text", "text": "Extracted document summary..." } ] }}compaction/compact
Section titled “compaction/compact”Summarizes older conversation messages during automatic or manual (/compact) compaction. Plugins opt in by setting "compaction": true in PluginManifest. When no plugin handles compaction or a plugin returns an error, the host falls back to its built-in LLM summarizer.
Request:
{ "jsonrpc": "2.0", "id": 9, "method": "compaction/compact", "params": { "messages": [ { "role": "user", "content": [{ "type": "text", "text": "Fix the failing parser test." }] } ], "previous_summary": "Optional prior summary for incremental compaction", "focus": "Preserve file paths and error messages", "hook_guidance": "Optional guidance from PreCompact hooks", "trigger": "manual", "model": "claude-sonnet-5-5" }}Response:
{ "jsonrpc": "2.0", "id": 9, "result": { "summary": "## Goal\nFix the failing parser test..." }}shutdown
Section titled “shutdown”Requests graceful plugin termination.
Request:
{"jsonrpc":"2.0","id":10,"method":"shutdown","params":{}}Response:
{"jsonrpc":"2.0","id":10,"result":{}}Plugin-to-Host Callbacks
Section titled “Plugin-to-Host Callbacks”While handling an in-flight host request, a plugin may send JSON-RPC requests or notifications back to the host on stdout.
The host handles each incoming request, writes the JSON-RPC response (result or error) to plugin stdin, and continues awaiting the original response. Unhandled methods return -32601 (method not found), and malformed parameters for known methods return -32602 (invalid params). Notifications (messages with method and no id) receive no reply.
Standardized host/* callback methods:
| Method | Params | Result |
|---|---|---|
host/log |
{ level, message, target? } |
{} (or sent as a notification) |
host/ask_permission |
{ tool_name, arguments, reason? } |
{ decision, reason? } |
host/invoke_tool |
{ name, arguments } |
{ content, is_error? } |
host/complete |
{ prompt, system?, max_tokens? } |
{ content } |
host/emit_hint |
{ id, text, priority? } |
{ accepted, reason? } |
Plugin hints are normalized to a single line, capped at priority 20, and subject to the host’s TUI rate limits. host/emit_hint returns accepted: true when queued for TUI evaluation, or accepted: false with a reason for invalid hints and non-TUI hosts.