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.
Summary
Functions
Returns the current (only) session ID, or nil.
Fetches a session from state by ID.
Fetches a session ID from ACP params.
Builds a session from a ZCode snapshot (as returned by session/create, session/resume, or embedded in event notifications).
Resolves a session ID from notification params.
Resets per-prompt accumulators on a session.
Converts a ZCode session list entry to an ACP SessionInfo map.
Types
Functions
@spec current_id(store_state()) :: String.t() | nil
Returns the current (only) session ID, or nil.
@spec empty(String.t() | nil, adapter_state()) :: session()
@spec fetch(store_state(), String.t()) :: {:ok, session()} | {:error, String.t()}
Fetches a session from state by ID.
Fetches a session ID from ACP params.
@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).
@spec id_from_params(map(), store_state()) :: String.t() | nil
Resolves a session ID from notification params.
@spec put(store_state(), String.t() | nil, session()) :: store_state()
Resets per-prompt accumulators on a session.
Converts a ZCode session list entry to an ACP SessionInfo map.
@spec update(adapter_state(), String.t() | nil, (session() -> session())) :: adapter_state()