Skip to content

feat: hub client, login command, hub sync + heartbeat#50

Merged
vreshch merged 2 commits intomasterfrom
feature/phase-4-hub-client
Mar 21, 2026
Merged

feat: hub client, login command, hub sync + heartbeat#50
vreshch merged 2 commits intomasterfrom
feature/phase-4-hub-client

Conversation

@vreshch
Copy link
Contributor

@vreshch vreshch commented Mar 21, 2026

Summary

Daemon-side hub integration — login, registration, heartbeat, and reconnection.

  • Auth module: read/write/delete ~/.agentage/auth.json storing Supabase session (access_token + refresh_token), user info, hub URL + machineId
  • OAuth callback server: temporary Express on random port. Opens browser to Supabase OAuth, exchanges code for session via @supabase/supabase-js. 120s timeout. Falls back to printing URL for headless environments.
  • Hub REST client: register (upsert by machine ID), heartbeat (agent sync + pending commands), deregister, getMachines, getAgents. Uses Supabase JWT for auth headers.
  • Hub sync: orchestrates register → heartbeat loop (30s interval) → exponential backoff reconnection (1s → 30s max). Processes pending commands from heartbeat response.
  • Login command: agentage login --hub <url> fetches supabaseUrl + supabaseAnonKey from hub's /api/health, opens browser for OAuth. --token escape hatch for headless/CI.
  • Status command: shows hub connection state, URL, user email (was hardcoded to "not connected")
  • Daemon entry: initializes hub sync on startup if auth.json exists, graceful disconnect on shutdown
  • Health endpoint: now includes hubConnected, hubUrl, userEmail
  • 129 tests passing (7 new: auth read/write/delete, reconnection)

New dependency

@supabase/supabase-js — OAuth code exchange, token refresh, auth state management

Test plan

  • npm run verify passes (type-check + lint + format + 129 tests + build)
  • Review OAuth callback flow (auth-callback.ts)
  • Review hub sync lifecycle (register → heartbeat → reconnection)
  • Review auth.json format and persistence

vreshch added 2 commits March 21, 2026 10:40
- Auth module: read/write/delete ~/.agentage/auth.json with Supabase session
- OAuth callback server: temporary Express on random port, exchanges code
  via @supabase/supabase-js, 120s timeout
- Hub client: REST client for hub API (register, heartbeat, deregister,
  getMachines, getAgents) with Supabase JWT auth headers
- Hub sync: register → heartbeat loop (30s) → reconnection with
  exponential backoff (1s → 30s max). Processes pending commands.
- Reconnection module: generic exponential backoff with reset on success
- Login command: --hub flag (default agentage.io), fetches supabaseUrl +
  anonKey from hub health endpoint, opens browser for OAuth, --token
  escape hatch for headless/CI
- Status command: shows hub connection state, URL, user email
- Daemon entry: initializes hub sync on startup if auth.json exists,
  graceful hub disconnect on shutdown
- Health endpoint: includes hubConnected, hubUrl, userEmail
- 129 tests passing (7 new: auth read/write/delete, reconnection)
@github-actions
Copy link

🎉 PR Validation ✅ PASSED

Commit: 97fd926a3f601cc0189e378e22cf54e7221c99f5
Branch: feature/phase-4-hub-client

Checks:

  • ✅ Dependencies installed
  • ✅ Type check passed
  • ✅ Linting passed
  • ✅ Format check passed
  • ✅ Tests passed
  • ✅ Build successful

Ready to merge!


🔗 View workflow run
⏰ Generated at: 2026-03-21T12:21:11.911Z

@vreshch vreshch merged commit a06a7de into master Mar 21, 2026
1 check passed
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