API Reference minga_claude_bridge v#0.1.0

Copy Markdown View Source

Modules

Minga extension that serves the Claude models of the user's Claude subscription through the claude CLI.

Finds the claude executable and reads its version.

Raw protocol logs for debugging, written only when CLAUDE_BRIDGE_DEBUG=1.

Computes the environment of a Claude Code child process.

Decides whether a Minga request continues the live Claude Code session or must start a fresh one.

Builds the claude command-line arguments for one session.

Joins Port line fragments into complete lines.

Routes the JSON-RPC messages of the in-process MCP server named "minga".

A validated MCP tools/call request that Minga must run.

Prepares tool input schemas for Claude Code's MCP client.

Signals an operating-system process by pid and stops it within a bounded time.

The MingaAgent.InferenceRoute that serves Claude models through the user's Claude Code login.

The processes and settings MingaClaudeBridge.Route uses.

Pure conversions between Minga's route values (MingaAgent.InferenceRoute.*) and the bridge's session values.

Converts Claude Code's plan-usage data to Minga's MingaAgent.InferenceRoute.PlanWindow values.

Starts Claude Code without a prompt to read its initialize answer: the account, the models, and the version. No model request is made.

One Claude Code process serving one Minga conversation.

The events a MingaClaudeBridge.Session sends for one request, as {ref, event} messages.

One input to a MingaClaudeBridge.Session: a new prompt, or the results of the tool calls the previous request ended with.

Accumulates the assistant messages Claude Code streams for one request.

Holds the route's last known readiness and plan limits, and reports changes to Minga.

The bridge's process tree, started as the extension's child.

Pairs held MCP tools/call control requests with the tool results Minga sends later.

The byte channel between a MingaClaudeBridge.Session and one Claude Code process.

The MingaClaudeBridge.Transport that runs the real claude executable through an Erlang Port.

The bridge's version.

Codec for Claude Code's stream-json protocol.

An assistant frame: a complete or partial assistant message.

Content blocks of Anthropic messages, as a tagged sum type.

A control_cancel_request frame: the sender withdraws the control_request with the same request_id. The receiver should stop work on that request and must not answer it.

A control_request frame. Claude Code sends these to the bridge (for example mcp_message and can_use_tool), and the bridge sends them to Claude Code (initialize and interrupt). Both directions share this shape, so outbound frames decode back to this struct.

A control_response frame: the answer to a control_request, in either direction.

A rate_limit_event frame: plan usage for Claude subscription accounts.

The result frame that ends each Claude Code turn.

Anthropic stop_reason values.

A stream_event frame: one Anthropic streaming event, emitted when Claude Code runs with --include-partial-messages.

The system frame with subtype init, which Claude Code emits when a session starts.

Any frame whose type the codec does not model, such as keep_alive, system frames other than init, or types added by a newer CLI.

Token counts from an Anthropic usage object.

A user frame: a user message, either one Claude Code echoes or replays, or one the bridge sends.

Private directories the bridge owns: the empty working directory of each claude process, and the debug log directory.