Documentation
¶
Overview ¶
Package ipc carries NDJSON messages between the parent ape process (`ape chat` / `ape pipeline`) and the bridge subprocess (`ape mcp-bridge`) over a single TCP connection.
The wire shape is documented in docs/reference/bridge-ipc.md. The IPC abstraction is small enough that a future plan can swap TCP+NDJSON for stdlib WebSocket or NATS-embedded without touching the SSE broker or the MCP runtime — keep the Message struct authoritative.
Ported from https://github.com/diegosz/claude_mcp_bridge_poc, commit 4e542d0 (MIT), extended for PLAN-5 / C3 with new frame types (call, hook, step-bind, stop) and a JSON Payload escape hatch for opaque hook envelopes.
Index ¶
Constants ¶
const ( TypeReady = "ready" // bridge → parent (handshake) TypeMessage = "message" // parent → bridge (wake await_message) TypeReply = "reply" // bridge → parent (skill called reply()) TypeCall = "call" // bridge → parent (mirror of every MCP tool call) TypeHook = "hook" // `ape notify` → parent (hook envelope forwarded) TypeStepBind = "step-bind" // parent → bridge (session_id → step mapping) TypeStop = "stop" // parent → bridge (SIGTERM about to fire; clean shutdown) TypeBufferOvf = "buffer-overflow" )
Frame types. Documented in PLAN-5 / C3 — IPC wire table.
const ( HookPreToolUse = "PreToolUse" HookPostToolUse = "PostToolUse" HookUserPromptSubmit = "UserPromptSubmit" HookSubagentStart = "SubagentStart" HookSubagentStop = "SubagentStop" HookStop = "Stop" )
Hook event names emitted by Claude Code's hooks block. The bridge settings register `ape notify --event <name>` for each of these; the parent then routes them via the IPC `hook` frame.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Message ¶
type Message struct {
Type string `json:"type"`
Content string `json:"content,omitempty"`
Tool string `json:"tool,omitempty"`
Params json.RawMessage `json:"params,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Event string `json:"event,omitempty"`
SessionID string `json:"session_id,omitempty"`
AgentID string `json:"agent_id,omitempty"`
Step string `json:"step,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
ID string `json:"id,omitempty"` // pairs deferred await_message entries with their flush
}
Message is the canonical IPC frame. Fields are populated per the `Type` discriminator; consumers should switch on Type and treat unrelated fields as best-effort. Payload is reserved for opaque blobs (hook envelopes) where the parent does not need to interpret the inner shape.