Skip to content

feat(setup): wire daemon autostart on boot/login per platform#187

Merged
vreshch merged 1 commit into
masterfrom
feat/setup-autostart
May 7, 2026
Merged

feat(setup): wire daemon autostart on boot/login per platform#187
vreshch merged 1 commit into
masterfrom
feat/setup-autostart

Conversation

@vreshch

@vreshch vreshch commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

agentage setup now wires the daemon to start automatically on machine restart. One platform module each, dependency-injected so they unit-test cleanly without spawning real systemctl/launchctl/schtasks.

Platform Mechanism Trigger Privileges
Linux ~/.config/systemd/user/agentage.service + loginctl enable-linger boot (linger) none
macOS ~/Library/LaunchAgents/io.agentage.daemon.plist + launchctl bootstrap user login none
Windows schtasks /Create /SC ONLOGON /TN AgentageDaemon user logon none

Daemon stores state in ~/.agentage/, so it must run as the user. That rules out LaunchDaemon (root) and Windows Services (LocalSystem) — only Linux + linger gives true pre-login boot without privilege escalation.

Behavior

  • Fresh setup: installs by default. --no-autostart opts out.
  • --disconnect: removes the unit/plist/task. --no-autostart keeps it.
  • --reauth / --no-login: leaves existing wiring alone.
  • Install/uninstall failures are warnings, never fatal — setup completes either way.
  • Summary line surfaces the trigger: Autostart: systemd-user (starts at boot) / (starts at login).
  • JSON output adds an autostart: { mechanism, unitPath, startsAtBoot } field.

Test plan

  • Unit tests for each platform module (rendering + exec wiring + idempotency) — 24 tests
  • Unit tests for setup wiring (default-on, --no-autostart, standalone skip, disconnect cleanup) — 7 new tests
  • npm run verify — 738 tests pass, build green
  • Smoke-tested live on Linux: installAutostart() deploys the unit, systemctl --user is-enabled agentage.service returns enabled, loginctl show-user vreshch -p Linger is yes → daemon will start at boot. uninstallAutostart() removes the unit + disables cleanly.
  • macOS / Windows: rendered output verified via tests; live-install requires those OSes — please validate post-merge or in a follow-up.

Notes

  • Rejected auto-launch npm package — last release 3y ago, doesn't do systemd-linger (only ~/.config/autostart/.desktop = login-time on Linux).
  • Each module is a thin renderer + deps.exec(...) wrapper, so cross-platform tests run on any host.
  • No new dependencies.

Linux: ~/.config/systemd/user/agentage.service + loginctl enable-linger
  → starts at boot, no sudo, restart-on-failure.
macOS: ~/Library/LaunchAgents/io.agentage.daemon.plist + launchctl
  bootstrap → starts at user login (LaunchDaemon would need root and
  break ~/.agentage paths).
Windows: schtasks /Create /SC ONLOGON /TN AgentageDaemon → starts at
  user logon, no admin (a Windows Service would need admin and run as
  LocalSystem).

Default-on during fresh setup; --no-autostart opts out. setup
--disconnect is symmetric: removes the unit/plist/task unless
--no-autostart is also passed.

Each platform module is dependency-injected (homeDir, nodeBin,
entryPath, exec) so unit tests cover rendering + exec wiring on every
platform without spawning real systemctl/launchctl/schtasks.
@github-actions

github-actions Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

🎉 PR Validation ✅ PASSED

Commit: 7891aaa53d566b2b9f1cb8185ae69ebff54912cd
Branch: feat/setup-autostart

Checks:

  • ✅ Release guard (no version/changelog changes)
  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests + coverage passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-05-06T21:48:50.929Z

@vreshch vreshch marked this pull request as ready for review May 7, 2026 21:55
@vreshch vreshch merged commit bf386dd into master May 7, 2026
1 check passed
@vreshch vreshch deleted the feat/setup-autostart branch May 7, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant