# `ClaudeAgentSDK.Transport`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L1)

Behaviour describing the transport layer used to communicate with the Claude CLI.

A transport is responsible for starting and supervising the underlying connection,
forwarding JSON control/data frames to the CLI, broadcasting replies to subscribers,
and shutting down cleanly when the client stops.

Implementations should be OTP-friendly processes (typically a `GenServer`)
that encapsulate any state required to maintain the connection.

# `message`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L17)

```elixir
@type message() :: binary()
```

Binary payload encoded as newline-terminated JSON.

# `opts`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L20)

```elixir
@type opts() :: keyword()
```

Transport-specific options propagated from `Client.start_link/1`.

# `t`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L14)

```elixir
@type t() :: pid()
```

Opaque transport reference returned from `start_link/1`.

# `close`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L40)

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

Closes the transport and releases any external resources.

# `end_input`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L60)
*optional* 

```elixir
@callback end_input(t()) :: :ok | {:error, term()}
```

Signals end of input stream to the CLI process.

This closes stdin to indicate no more input will be sent. Required for
non-streaming queries where the CLI waits for stdin to close before
processing.

## Implementation Notes

- For Port-based transports: Close the stdin pipe
- For erlexec-based transports: Send `:eof` signal
- This callback is optional - transports may not support it

# `send`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L30)

```elixir
@callback send(t(), message()) :: :ok | {:error, term()}
```

Sends a JSON payload to the CLI.

# `start_link`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L25)

```elixir
@callback start_link(opts()) :: {:ok, t()} | {:error, term()}
```

Starts the transport process and establishes the CLI connection.

# `status`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L45)

```elixir
@callback status(t()) :: :connected | :disconnected | :error
```

Returns the current connection status for observability/health checks.

# `subscribe`
[🔗](https://github.com/nshkrdotcom/claude_agent_sdk/blob/v0.9.2/lib/claude_agent_sdk/transport.ex#L35)

```elixir
@callback subscribe(t(), pid()) :: :ok
```

Subscribes the given process to receive inbound messages.

---

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