67e12b39fe
- Added RpcClient class with subprocess-based RPC communication, thread-safe request/response handling, and 30+ public methods for agent operations. - Defined 65+ public API symbols including protocol types, dataclasses, parser functions, and custom exception types for RPC communication. - Implemented event listener system with on_event, on_ui_request, and on_extension_error callbacks for asynchronous RPC event handling. - Added comprehensive test suite with integration tests for RpcClient and unit tests for protocol parsing functions. - Configured Python package with setuptools, PEP 561 type hints support, and documentation for usage and API reference.
omp-rpc
Typed Python bindings for the omp --mode rpc protocol used by the coding agent.
This package wraps the newline-delimited JSON RPC transport exposed by the CLI and provides:
- typed command methods for the stable RPC surface
- typed protocol models for state, bash results, compaction, and session stats
- a process-backed client that manages request correlation over stdio
- helpers for collecting prompt runs and handling extension UI requests
Basic Usage
from omp_rpc import RpcClient
with RpcClient(provider="anthropic", model="claude-sonnet-4-5") as client:
state = client.get_state()
print(state.model.id if state.model else "no model")
turn = client.prompt_and_wait("Reply with just the word hello")
print(turn.require_assistant_text())
By default the client runs:
omp --mode rpc
You can also point it at a custom command, which is useful inside this repo while developing against the Bun entrypoint:
from omp_rpc import RpcClient
with RpcClient(
command=[
"bun",
"packages/coding-agent/src/cli.ts",
"--mode",
"rpc",
"--provider",
"anthropic",
"--model",
"claude-sonnet-4-5",
],
) as client:
print(client.get_state().session_id)
Extension UI Requests
Extensions in RPC mode can ask the host for input. Those requests are available as
typed ExtensionUiRequest instances:
request = client.next_ui_request(timeout=5.0)
if request.method == "confirm":
client.send_ui_confirmation(request.id, True)
elif request.method in {"input", "editor"}:
client.send_ui_value(request.id, "approved")
Protocol Reference
The canonical wire protocol still lives in the repo at
docs/rpc.md.