# `ExMCP.ACP.AdapterBridge`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/acp/adapter_bridge.ex#L1)

GenServer bridge between ACP clients and non-native CLI agents.

Owns the Port subprocess and delegates translation to a pluggable
`ExMCP.ACP.Adapter` implementation. Uses an outbox + waiters queue
for synchronized message delivery.

## Modes

- **Persistent** (default) — opens a Port on init, keeps it alive
- **One-shot** — adapter manages subprocess per prompt (Codex pattern)
- **Adapter-managed** — adapter owns one or more persistent subprocess Ports

Pending output is bounded by both `:max_outbox_messages` (1,024 by default)
and `:max_outbox_bytes` (4 MiB by default). `:max_one_shot_tasks` defaults to 8.

## Usage

    {:ok, bridge} = AdapterBridge.start_link(
      adapter: ExMCP.ACP.Adapters.ClaudeSDK,
      adapter_opts: [model: "sonnet"]
    )

    :ok = AdapterBridge.send_message(bridge, json_rpc_string)
    {:ok, response} = AdapterBridge.receive_message(bridge)

# `t`

```elixir
@type t() :: GenServer.server()
```

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(t()) :: :ok
```

Close the bridge and terminate the subprocess.

# `receive_message`

```elixir
@spec receive_message(t(), timeout()) :: {:ok, String.t()} | {:error, term()}
```

Receive the next ACP message from the agent. Blocks until available.

# `send_message`

```elixir
@spec send_message(t(), String.t()) :: :ok | {:error, term()}
```

Send a JSON-encoded ACP message to the agent.

# `start_link`

```elixir
@spec start_link(keyword()) :: GenServer.on_start()
```

Start the bridge linked to the caller.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
