agentd: Implement agent start/stop/restart via systemd

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

Description

Edit

Add start/stop/restart commands to the agentd agent CLI group.

Commands: 1. agentd agent start <name>

  • Verify config exists in DB/env file
  • Run systemctl --user start pi-agent@<name>
  • Update DB status to 'running'
  • Print status confirmation

2. agentd agent stop <name>

  • Run systemctl --user stop pi-agent@<name>
  • Update DB status to 'stopped'

3. agentd agent restart <name>

  • Run systemctl --user restart pi-agent@<name>
  • Update DB status to 'running'

Important: must set XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS env vars when calling systemctl, same as the current pi-agent script does:

XDG_RUNTIME_DIR=/run/user/$(id -u)
DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus

Use System.Process to shell out to systemctl. Check exit codes and report errors clearly.

Files to modify:

  • Omni/Agentd.hs (CLI dispatch)
  • Omni/Agentd/Daemon.hs (systemd interaction functions)

Timeline (3)

💬[human]1 week ago

Ava verified: 'agentd agent' subcommand group is live in production agentd CLI. agent create/list/status/start/stop/restart/send/logs/rm/purge all present and functional. Moving to Verified.

🔄[human]Review → Verified1 week ago