Skip to content

Root Channel

The root channel is the top-level channel every AHP server exposes. It carries global state — the agents the server provides, the terminals it manages, and host-level configuration — plus the catalogue events for sessions.

URI

ahp-root://

Exactly one root channel exists per server. Clients SHOULD subscribe to it during the handshake via initialSubscriptions to receive the agent list, terminal list, and host config in the same round-trip.

State

Subscribers receive a RootState snapshot:

typescript
RootState {
  agents: AgentInfo[]
  activeSessions?: number
  terminals?: TerminalInfo[]
  config?: RootConfigState
}
  • agents — agent backends the server can speak to, including any protectedResources they require for authentication. See Authentication.
  • activeSessions — count of non-disposed sessions. Lightweight badge counter.
  • terminals — lightweight per-terminal metadata for rendering a terminal manager UI without subscribing to every terminal. See Terminal Channel for the full state.
  • config — host-level configuration schema and current values.

The session list is not part of root state. Clients fetch it imperatively via listSessions and patch it from root/* notifications described below.

Methods and events on this channel

This section lists wire methods that are interpreted in the context of ahp-root://. If params.channel is some other URI, they are handled by the target channel instead.

Commands (params.channel = "ahp-root://")

MethodKindWhy it belongs on root
initializerequestConnection-level handshake command; scoped to the root channel.
pingrequestConnection liveness check; scoped to the root channel.
reconnectrequestConnection resume/replay negotiation; scoped to the root channel.
listSessionsrequestSession catalogue lives on root (root/session* events keep the cache fresh).
resourceReadrequestFilesystem/content access is connection-level, not session-local.
resourceWriterequestFilesystem/content access is connection-level, not session-local.
resourceListrequestFilesystem/content access is connection-level, not session-local.
resourceCopyrequestFilesystem/content access is connection-level, not session-local.
resourceDeleterequestFilesystem/content access is connection-level, not session-local.
resourceMoverequestFilesystem/content access is connection-level, not session-local.
resourceRequestrequestPermission grant/revocation flow is connection-level.
authenticaterequestBearer-token push for protected resources is connection-level.
resolveSessionConfigrequestPre-creation config resolution happens before any session channel exists.
sessionConfigCompletionsrequestCompletes dynamic fields in pre-creation session config.

Notifications (params.channel = "ahp-root://")

MethodKindMeaning
actionserver → client notificationRoot-scoped action envelope (root/* action payloads).
root/sessionAddedserver → client notificationSession catalogue entry created.
root/sessionRemovedserver → client notificationSession catalogue entry removed.
root/sessionSummaryChangedserver → client notificationSession catalogue entry mutated.
unsubscribeclient → server notificationStop receiving root-channel messages.
dispatchActionclient → server notificationDispatch a root-scoped client action (currently root/configChanged).

auth/required may also be emitted on ahp-root:// when the auth requirement is root-scoped; see Authentication.

Actions

Root state is mutated by action envelopes broadcast on this channel. Refer to the Root Channel Reference for the full list; the root-scoped actions are:

ActionDirectionReducer effect
root/agentsChangedServerReplaces agents
root/activeSessionsChangedServerReplaces activeSessions
root/terminalsChangedServerReplaces terminals
root/configChangedServer / ClientMerges (or replaces) config.values

All root-scoped action envelopes have channel: "ahp-root://".

Protocol Notifications

In addition to action envelopes, the server pushes per-session catalogue events to subscribers of ahp-root://. These notifications keep cached session lists in sync without subscribing to every session URI individually.

root/sessionAdded

Emitted when a new session is created.

json
{
  "jsonrpc": "2.0",
  "method": "root/sessionAdded",
  "params": {
    "channel": "ahp-root://",
    "summary": {
      "resource": "ahp-session:/<uuid>",
      "title": "New Session",
      "status": 1,
      "createdAt": 1710000000000,
      "modifiedAt": 1710000000000
    }
  }
}

root/sessionRemoved

Emitted when a session is disposed.

json
{
  "jsonrpc": "2.0",
  "method": "root/sessionRemoved",
  "params": {
    "channel": "ahp-root://",
    "session": "ahp-session:/<uuid>"
  }
}

root/sessionSummaryChanged

Emitted when any mutable field on an existing SessionSummary changes (title, status, modifiedAt, model, agent, working directory, read/done state, diff statistics, …). Only the changed fields are carried; identity fields (resource, provider, createdAt) never change and MUST be omitted.

json
{
  "jsonrpc": "2.0",
  "method": "root/sessionSummaryChanged",
  "params": {
    "channel": "ahp-root://",
    "session": "ahp-session:/<uuid>",
    "changes": {
      "title": "Refactor auth middleware",
      "status": 8,
      "modifiedAt": 1710000123456
    }
  }
}

Servers MAY coalesce or debounce this notification for noisy fields — for example, rapid modifiedAt bumps during a streaming turn, or frequent diffs updates during an edit burst. Clients that have no cached entry for session MAY ignore the notification.

Like all protocol notifications, the root/* events are ephemeral and are not replayed on reconnect. After reconnecting, clients SHOULD re-fetch the catalogue via listSessions.

Authentication Events

The server MAY emit auth/required on the root channel when an agent's protected resource needs (re-)authentication. See Authentication for the full flow.

Released under the MIT License.