ExAgent.Chat.Reader (ExAgent v3.0.0)

View Source

Read and reconcile a chat view from a concrete, already authorized Server PID.

Stability — Stable.

Attach with ExAgent.Server.attach(pid, self(), delivery: :demand) before the first page. Apply the returned rows and state before acknowledging each notice with ExAgent.Server.ack_events/4. A retry of the acknowledgement uses the same notice and cursor. The host owns monitoring and authorization.

Summary

Functions

Correlate a lost admission acknowledgement with a receipt or a matching root terminal. Use the request ID originally submitted with the key. A receipt for a different request ID returns {:error, :idempotency_conflict}.

Refresh approvals and deferral summaries from the authorized Server.

Observe cancellation for a specific turn. Recovery after a remount or a gap also checks the retained buffer and the matching continuation. An uncertain outcome stays pending until the Server exposes the confirmed result.

Read the latest, earlier or replacement transcript window and its controls.

Read and reduce a notice without acknowledging it. Returns the row update and the batch for receipt correlation. :replay means the retention window expired or the batch was too large, and a fresh history page was applied.

Functions

admission(server, chat, key, request_id, events \\ [])

@spec admission(pid(), ExAgent.Chat.t(), ExAgent.Server.admission_key(), String.t(), [
  ExAgent.Event.t()
]) ::
  {:ok, :admitted | ExAgent.Chat.cancellation()} | {:error, term()}

Correlate a lost admission acknowledgement with a receipt or a matching root terminal. Use the request ID originally submitted with the key. A receipt for a different request ID returns {:error, :idempotency_conflict}.

approvals(server, chat)

@spec approvals(pid(), ExAgent.Chat.t()) ::
  {:ok, ExAgent.Chat.t()} | {:error, :unavailable}

Refresh approvals and deferral summaries from the authorized Server.

cancellation(server, chat, run_id, key, events \\ :replay)

@spec cancellation(
  pid(),
  ExAgent.Chat.t(),
  String.t(),
  ExAgent.Server.admission_key() | nil,
  [ExAgent.Event.t()] | :replay
) :: ExAgent.Chat.cancellation() | nil

Observe cancellation for a specific turn. Recovery after a remount or a gap also checks the retained buffer and the matching continuation. An uncertain outcome stays pending until the Server exposes the confirmed result.

history(server, chat, mode \\ :latest)

@spec history(pid(), ExAgent.Chat.t(), :latest | :older | :reload) ::
  {:ok, ExAgent.Chat.t(), ExAgent.Chat.row_update()} | {:error, :unavailable}

Read the latest, earlier or replacement transcript window and its controls.

notice(server, chat, notice)

@spec notice(pid(), ExAgent.Chat.t(), reference()) ::
  {:ok, ExAgent.Chat.t(), ExAgent.Chat.row_update() | nil,
   [ExAgent.Event.t()] | :replay}
  | {:error, :unavailable | :stale_notice}

Read and reduce a notice without acknowledging it. Returns the row update and the batch for receipt correlation. :replay means the retention window expired or the batch was too large, and a fresh history page was applied.