ExAthena.Chat.Session (ExAthena v0.13.0)

Copy Markdown View Source

In-memory state for one interactive mix athena.chat session.

Plain struct + transformation functions — deliberately not a GenServer. The REPL is single-process and synchronous; each turn produces a new %Session{} from the previous one.

Summary

Types

t()

@type t() :: %ExAthena.Chat.Session{
  cost_usd: float(),
  cwd: String.t() | nil,
  iteration: non_neg_integer(),
  messages: [ExAthena.Messages.Message.t()],
  mode: atom(),
  model: String.t(),
  permission_mode: atom(),
  provider: atom(),
  tools: :all | [module()],
  usage: %{input_tokens: non_neg_integer(), output_tokens: non_neg_integer()}
}

Functions

append_user(session, text)

@spec append_user(t(), String.t()) :: t()

apply_result(session, result)

@spec apply_result(t(), ExAthena.Result.t()) :: t()

clear_messages(session)

@spec clear_messages(t()) :: t()

new(opts \\ [])

@spec new(keyword()) :: t()

set_cwd(session, cwd)

@spec set_cwd(t(), String.t() | nil) :: t()

set_mode(session, mode)

@spec set_mode(t(), atom()) :: t()

set_model(session, model)

@spec set_model(t(), String.t()) :: t()

tool_results(session)

@spec tool_results(t()) :: [ExAthena.Messages.ToolResult.t()]

Extract every ToolResult from the session's message history, ordered most-recent first.

Used by /expand in the REPL so the user can reference recent tool outputs by position (/expand 1 for the latest, /expand 2 for the one before, etc.).