SuperPi.ACP.Session (super_pi v0.1.0)

Copy Markdown View Source

One ACP session: its id, its conversation, the renderer state and the running prompt.

The sessionId is an opaque string (acp_...), not the conversation id. Editors such as Zed store it and send it back on session/load, possibly after a restart, so the mapping lives in SuperPi.Gateway.Sessions (a table), per principal.

Summary

Functions

Cancels the turn. The order is load-bearing: pending prompts first, then the machine.

Creates a session and its conversation. harness is the harness module.

Forks the conversation at its latest visible entry into a new session (_superpi/session/fork). session/load resumes, so a fork is a separate custom method.

Finds an existing session. Returns {:ok, session} or :error.

The modes a client may pick: up to the remote ceiling and the harness ceiling.

The harness named in _meta.harness of a request, or the default.

The history of the session as session/update payloads, for session/load.

Sets the mode. The mode must be one of modes/1.

Types

t()

@type t() :: %SuperPi.ACP.Session{
  conversation_id: term(),
  cwd: term(),
  id: term(),
  last_end: term(),
  prompt: term(),
  renderer: term()
}

Functions

cancel(session)

@spec cancel(t()) :: :ok

Cancels the turn. The order is load-bearing: pending prompts first, then the machine.

create(principal, cwd, harness, opts \\ [])

@spec create(String.t(), String.t(), module(), keyword()) :: t()

Creates a session and its conversation. harness is the harness module.

fork(principal, session)

@spec fork(String.t(), t()) :: {:ok, t()} | {:error, term()}

Forks the conversation at its latest visible entry into a new session (_superpi/session/fork). session/load resumes, so a fork is a separate custom method.

load(principal, session_id, cwd)

@spec load(String.t(), String.t(), String.t()) :: {:ok, t()} | :error

Finds an existing session. Returns {:ok, session} or :error.

modes(conversation_id)

@spec modes(integer()) :: %{required(String.t()) => term()}

The modes a client may pick: up to the remote ceiling and the harness ceiling.

pick_harness(meta)

@spec pick_harness(map() | nil) :: {:ok, module()} | {:error, String.t()}

The harness named in _meta.harness of a request, or the default.

replay(session)

@spec replay(t()) :: [map()]

The history of the session as session/update payloads, for session/load.

set_mode(conversation_id, mode_id)

@spec set_mode(integer(), String.t()) :: :ok | {:error, String.t()}

Sets the mode. The mode must be one of modes/1.