feat: start the daemon after a successful setup#257
Merged
Conversation
Contributor
|
🎉 PR Validation ✅ PASSED Commit: Checks:
Ready to merge! ✨ 🔗 View workflow run |
vreshch
marked this pull request as ready for review
July 8, 2026 22:51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
After
agentage setupcompletes a sign-in, the daemon is now started so account sync begins immediately and the nextagentage statusshows daemon/mcp/sync as healthy. Previously setup signed in but left the daemon stopped (it only autostarted lazily on the first memory verb).The success path (
src/commands/auth/setup.ts, after credentials are saved) calls the sameensureDaemon()the memory verbs use, via a newstartDaemonhelper and a mockableensureDaemondep onSetupDeps.ensureDaemonis idempotent: it reuses a live daemon (no restart) and starts a stopped one (detached), returning a client or null. Version-mismatch handling is unchanged (it already lives insideensureDaemon).Output lines match the existing no-emoji tone:
Daemon running.Could not start the daemon - run: agentage daemon startDaemon disabled - account sync will run in-process on demand.Disable-switch behavior
--no-daemon/AGENTAGE_NO_DAEMON=1(daemonDisabled()): short-circuits, does NOT start the daemon, prints the one-line disabled note.--disconnect(sign-out): returns before the sign-in flow, never reachesstartDaemon.--no-browserstill reaches it (it is a normal sign-in).Test coverage
New unit tests beside
setup.ts:ensureDaemonexactly once--disconnectdoes NOT callensureDaemonAGENTAGE_NO_DAEMON=1short-circuits (noensureDaemoncall) while auth is still persistednpm run verifygreen (type-check + e2e type-check + lint + prettier + 442 tests + build).Smoke (isolated
AGENTAGE_CONFIG_DIR):node dist/cli.js setup --disconnect-> "Nothing to disconnect." (no daemon touched);node dist/cli.js --no-daemon status-> clean. A real OAuth sign-in cannot be driven headless, so the daemon-start line is unit-verified (mockedensureDaemon) and needs a real login to confirm end-to-end.Observation (not implemented) - status auth line shows UTC absolute expiry
The status auth line renders
token valid until <ISO-Z>in UTC. For a user in CEST near midnight this reads as "yesterday" even when the token is valid ~1h into the future (UTC-vs-local confusion).Findings:
accessTokenExpiresAtfrom the OAuth introspection endpoint (/api/auth/mcp/get-session), surfaced viaintrospectToken->report.auth.tokenExpiresAt->authLineinstatus.ts. It is the ACCESS-token expiry, not the session lifetime.expires_inseconds (seetoAuthState); the CLI refreshes proactively when past expiry. Practically this is a short window (roughly minutes-to-an-hour class), which makes an absolute timestamp both noisy and easy to misread.status.tsalready downgrades a past/unrefreshable expiry to(session active).Proposed display (owner to pick, not implemented here):
signed in (token expires in 47m)- clearest, no timezone ambiguity, honest about the short TTL.signed in (token valid until 01:12 local)- fixes the UTC confusion but still exposes a short-lived, noisy absolute time.signed in (session active)- introspection already proves the session is live server-side; the access-token expiry is an implementation detail the user rarely needs.Recommendation: option 3 (or option 1 if a countdown is desired). The access token is refreshed automatically, so its exact expiry is low-value to surface; showing it invites the "why does it say yesterday" confusion for little benefit.