Intelligence

Artifacts

Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.

Repository
README.md
CONSTITUTION_COMPLIANCE_AUDIT_V1.mdREADME.md
repositories/aaf-holdings/hq01/lib/sessions/README.md
3.5 KB

HQ01 Session Manager

A management interface for Claude CLI sessions running on HQ01.

This is not an AI orchestrator, and not autonomous execution. It starts, observes, and stops Claude CLI processes on the server. The CEO can start a session from a phone, lock it, walk away, and the process keeps running on HQ01; later they return to read the logs and status.

Design

  • Files are the source of truth. No database. Each session is a directory under /srv/aaf/runtime/claude/sessions/<id>/.
  • Additive. Nothing in HQ01 V1 is changed; this is a new department surface bolted onto the existing operating system.
  • HQ01 never blocks. Starting a session spawns a detached process and returns immediately. The process outlives the HTTP request and the Next.js worker that handled it.
  • No websockets. The dashboard and detail pages refresh on a short interval; the log viewer polls a tail endpoint.

Runtime layout

/srv/aaf/runtime/claude/sessions/<id>/
  session.json    live, mutable state (status, pid, timestamps, last_activity)
  metadata.json   immutable creation record (intent + provenance)
  stdout.log      captured standard output (shown in the log viewer)
  stderr.log      captured standard error

session.json is reconciled against reality on every read: if it claims a PID that is no longer alive, the status is downgraded to exited and persisted.

Modules

PathResponsibility
lib/process/spawn.tsDetached process spawn with stdout/stderr capture.
lib/process/signal.tsPID liveness (isAlive) and graceful terminate.
lib/sessions/config.tsRuntime root and defaults (env-overridable).
lib/sessions/types.tsSession, SessionMetadata, StartSessionInput.
lib/sessions/store.tsAtomic JSON read/write, listing, log tailing.
lib/sessions/manager.tsstart / stop / list / get / logs orchestration.
lib/sessions/presets.tsQuick-start presets (e.g. Agent Z).

HTTP API

Method & pathAction
GET /api/sessionsList all sessions.
POST /api/sessionsStart a session; returns immediately.
GET /api/sessions/:idSession record + metadata.
POST /api/sessions/:id/stopGracefully stop the process.
GET /api/sessions/:id/logsTail of stdout/stderr (?bytes=N).

Start payload

{
  "name": "Agent Z",
  "executive": "agent-z",
  "working_directory": "/srv/aaf/repositories/aaf-holdings",
  "branch": "mission/MS-0001",   // optional
  "mission_id": "MS-0001",        // optional
  "assignment_id": null,          // optional
  "prompt": "…",                  // optional → claude --print <prompt>
  "command": "claude",            // optional override
  "args": ["…"]                   // optional full override
}

By default a session runs claude --print --verbose <prompt>: print mode streams output to the logs and never needs a TTY. Provide command/args to run the manager against any other executable.

Configuration

Env varDefaultPurpose
HQ01_SESSIONS_ROOT/srv/aaf/runtime/claude/sessionsRuntime root.
HQ01_CLAUDE_BINclaudeExecutable launched for new sessions.

UI

  • /sessions — dashboard of session cards (status, runtime, repo, branch) with Start (incl. presets) and Stop.
  • /sessions/:id — detail: live logs, assigned mission, command, PID, runtime, working directory, branch, status.

root · /srv/aaf