agentbridge
agentbridge is the CLI coding-agent adapter library. It bridges individual
coding tools (Claude Code, GitHub Copilot, OpenAI Codex, or any CLI that speaks
the agentbridge JSON protocol) into the shadi_mas coordination runtime so they
can exchange context, delegate tasks, and coordinate autonomously toward a shared
programming goal.
How it fits into SHADI
CLI tools agentbridge adapters shadi_mas engine
────────────── ───────────────────── ─────────────────────────────
Claude Code ──► ClaudeCodeAdapter ──►
Copilot CLI ──► CopilotAdapter ──►
Codex CLI ──► CodexAdapter ──► MasRuntime<DevelopmentEngine>
Cursor Agent ──► CursorAgentAdapter ──►
any CLI ──► GenericStdioAdapter ──►
│ │
│ ContextPacket │ A2A / SLIM / DIR
│ (handoff / relay) │ (transport / discovery)
Core types
CliAdapter (trait)
The central abstraction. Implement this to add any coding tool.
ContextPacket
A portable, serializable snapshot of a coding session: conversation history, code files, git diff, and generated artifacts. Used for context handoff between tools and for persistence across sessions.
Serializes to/from JSON:
let pkt = new;
let bytes = pkt.to_bytes?;
let restored = from_bytes?;
CliToolAdapter<A> (wrapper)
Bridges any CliAdapter into shadi_mas::ToolAdapter so it can participate
directly in MasRuntime<DevelopmentEngine> coordination rounds.
let inner = new;
let tool_adapter = new;
// tool_adapter now implements shadi_mas::ToolAdapter
Subprocess protocol (GenericStdioAdapter)
GenericStdioAdapter spawns a subprocess and communicates via newline-delimited
JSON on stdin/stdout. Any process that speaks this protocol becomes a agentbridge
participant with no code changes:
Requests (agentbridge → subprocess stdin):
Responses (subprocess stdout → agentbridge):
Spawn an adapter:
let adapter = spawn?;
Implementing a custom adapter
use ;
use AgentId;
Crate features
This crate ships with zero optional features. All heavy infrastructure
(shadi_mas coordination, A2A, SLIM) is brought in at the agentbridge_cli
binary level so the library stays lightweight.