feat(cli): persist sessions and filter Fleet nodes

Merged
KH
4mo ago
+1593-78

Summary

  • Persist one project-scoped workspace session across CLI, MCP startup, broker startup, and Fleet node restarts until an explicit create, join, or switch.
  • Preserve an enrolled Fleet node association without storing node tokens in the project session, so supervised restarts retain the same node identity.
  • Make Fleet node listings live-node-first by default, hide stale direct/non-node history with a count on stderr, and add --all for the complete roster.
  • Add CLI parity for targeted or automatic Fleet spawn/release, direct and steer DMs, and inbox checks.
  • Harden environment credential precedence and prevent ambient agent tokens from leaking into persisted-session fallback.

Remote Fleet proof

  • Verified Tailscale direct connectivity to sf-mini and finn-mini.
  • Installed Agent Relay 11.0.2 and configured launchd supervision on both machines with repository-scoped working directories.
  • Spawned and registered workers through Agent Relay only after restart:
    • sf-mini: invocation inv_205925107711696896
    • finn-mini: invocation inv_205925145182515200
  • Released both proof workers and verified both nodes returned to zero active agents.

Test Plan

  • Tests added/updated
  • Manual testing completed
  • CLI suite: 734 passed, 11 skipped
  • Cloud suite: 168 passed
  • Relayfile target: 10 passed, 4 skipped
  • Full typecheck, CLI build, Cloud build, Prettier, diff check, and ESLint completed; ESLint reports only three pre-existing complexity warnings.
  • Independent fresh-context Claude and Codex reviewers both returned PASS through Agent Relay.

Operational notes

  • sf-mini is Cloud-enrolled. finn-mini uses the supported persisted workspace-key mode because Cloud enrollment requires owner/admin permission; normal Fleet spawning does not require SSH.
  • During initial sf-mini diagnosis, restarting an old node whose working directory was HOME triggered orphan cleanup and stopped an unrelated Factory broker. Factory was recovered, and the Fleet launch agent is now scoped to the Relay repository to remove that unsafe condition.
  • The existing local .trajectories/index.json deletion was not included in this PR.

Screenshots

Not applicable.