# `ExMCP.ACP.Adapters.ZCode.Sessions`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.4.0/lib/ex_mcp/acp/adapters/zcode/sessions.ex#L1)

Pure session helpers for the ZCode ACP adapter.

ZCode sessions are keyed by the `sessionId` string returned by
`session/create` or `session/resume`. Each session tracks the active turn
(for cancellation), accumulated text/usage, and the current mode and model.

# `adapter_state`

```elixir
@type adapter_state() :: %{
  :sessions =&gt; %{required(String.t()) =&gt; session()},
  :model =&gt; any(),
  :mode_id =&gt; any(),
  optional(any()) =&gt; any()
}
```

# `session`

```elixir
@type session() :: map()
```

# `store_state`

```elixir
@type store_state() :: %{
  :sessions =&gt; %{required(String.t()) =&gt; session()},
  optional(any()) =&gt; any()
}
```

# `current_id`

```elixir
@spec current_id(store_state()) :: String.t() | nil
```

Returns the current (only) session ID, or nil.

# `empty`

```elixir
@spec empty(String.t() | nil, adapter_state()) :: session()
```

# `fetch`

```elixir
@spec fetch(store_state(), String.t()) :: {:ok, session()} | {:error, String.t()}
```

Fetches a session from state by ID.

# `fetch_id`

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

Fetches a session ID from ACP params.

# `from_snapshot`

```elixir
@spec from_snapshot(String.t(), map(), adapter_state()) :: session()
```

Builds a session from a ZCode snapshot (as returned by session/create,
session/resume, or embedded in event notifications).

# `id_from_params`

```elixir
@spec id_from_params(map(), store_state()) :: String.t() | nil
```

Resolves a session ID from notification params.

# `put`

```elixir
@spec put(store_state(), String.t() | nil, session()) :: store_state()
```

# `reset_prompt_accumulators`

```elixir
@spec reset_prompt_accumulators(session(), term()) :: session()
```

Resets per-prompt accumulators on a session.

# `to_acp_session_info`

```elixir
@spec to_acp_session_info(map()) :: map()
```

Converts a ZCode session list entry to an ACP SessionInfo map.

# `update`

```elixir
@spec update(adapter_state(), String.t() | nil, (session() -&gt; session())) ::
  adapter_state()
```

---

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