agentd daemon: Replace Process.createProcess with systemd delegation

t-743·WorkTask·
·
·
·Omni/Agentd
Parent:t-739·Created2 weeks ago·Updated1 week ago·pipeline runs →

Description

Edit

Refactor Daemon.hs to stop managing Pi processes directly and delegate to systemd instead. This is the core daemon refactor.

1. Remove RunningAgent and in-memory process tracking:

  • Delete data RunningAgent (has raStdinHandle, raWorktreePath, raWorktreeRepoRoot)
  • Delete dsRunning :: TVar (Map Text RunningAgent) from DaemonState
  • Delete monitorPiAgent function
  • Delete readPiOutput function
  • Delete readPiStderr function
  • Delete sendToPiProcess (replace with FIFO write)

2. Remove git worktree code:

  • Delete prepareWorkspace function (creates git worktrees)
  • Delete cleanupWorktree function
  • Delete the DELETE /agents/:id/worktree API endpoint
  • Remove raWorktreePath and raWorktreeRepoRoot from all code paths

3. Update POST /agents (spawn):

  • Instead of Process.createProcess, call the same logic as agentd agent create + agentd agent start
  • SpawnRequest includes: name (optional, auto-generate if missing), provider, model, cwd (required), thinking level
  • No automatic worktree creation

4. Update POST /agents/:id/send:

  • Write to FIFO at ~/.local/state/pi-agents/<name>.fifo instead of raStdinHandle
  • Record message in DB

5. Update GET /agents/:id:

  • Read from systemd state + DB, not in-memory TVar
  • Call systemctl --user is-active pi-agent@<name> and merge with DB record

The daemon becomes stateless w.r.t. processes. All process state lives in systemd. All persistent state lives in SQLite.

Files to modify:

  • Omni/Agentd/Daemon.hs (major refactor, ~1888 lines currently)

Timeline (7)

💬[human]2 weeks ago

Daemon server now routes spawn/list/status/send/stop/delete through persistent systemd-backed agent controls. Removed legacy worktree/merge HTTP handlers and DELETE /agents/:id/worktree route. Legacy in-process spawn/process-management code remains in file but is no longer on active API path.

💬[human]2 weeks ago

Filed follow-up t-750 for deeper dead-code removal and dropping -Wno-unused-top-binds. Keeping current transition-safe code in this patchset to avoid destabilizing active rollout.

💬[human]1 week ago

Ava verified: implementation present in live tree (file/feature confirmed via inspection). Moving to Verified.

🔄[human]Review → Verified1 week ago