Commit Graph
249 Commits
Author SHA1 Message Date
Mao NakamotoandClaude Opus 4.8 46d39714c6 fix(control): fuzzy tab matching, stale-backlog purge, actionable launch timeout
The dispatch last-mile was failing on real edges once the runner went live:

- Project keys never matched the names users actually gave their Zellij tabs:
  "revampit" ≠ "revamp-it", so focus/inject/launch threw "tab not found". New
  SSOT findMatchingTab() (src/lib/tab-match.ts) normalizes case + punctuation
  and is used in all three matching sites (terminals/zellij, agent-runtime,
  desktop poller). Existing fuzzy-matched tabs are reused; only a genuinely
  absent tab is created under its canonical name.
- A runner reconnecting after days offline drained a stale command backlog
  against a changed Zellij and failed noisily. purgeStalePendingCommands()
  deletes unclaimed/unexecuted commands older than 20m before claiming.
- launch_agent against a detached session hung to the 6s timeout and surfaced a
  cryptic "spawnSync /bin/sh ETIMEDOUT"; now it says which session is detached
  and to `zellij attach` it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 17:43:24 +02:00
Mao NakamotoandClaude Opus 4.8 e76211aebf feat(brand): dense-coil spiral SSOT, Geist type, dark-first
One source for the brand mark (src/config/brand-mark.ts): a dense Archimedean
spiral that pulls into the center. `npm run generate:brand` renders every asset
from it — favicon, apple icon, 1024px app icon, the monochrome tray glyph, and
the OG marks — replacing the divergent hand-drawn copies and the wrong
"control-window" tray glyph. The desktop step now verifies committed icons
instead of redrawing them.

Also: switch typography to Geist + Geist Mono (the x.ai/grok grotesk) via the
--font-* token SSOT, default the theme to dark (Settings toggle still
overrides), and give the in-app mark a slow rotation + soft glow
(reduced-motion safe).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 14:23:25 +02:00
Mao NakamotoandClaude Opus 4.8 ed382a1f0c fix(deploy): copy node-pty native binary into standalone build
Phase 2b browser-verify exposed it: Next's standalone tracer copies node-pty's
JS (lib/, package.json) but not its dynamically-loaded build/Release/pty.node,
so /api/workspaces 500'd with 'Failed to load native module: pty.node'. The
postbuild deploy already copies tracer-missed assets (static/public/content) —
node-pty's binary belongs in the same step. Verified: with the binary present,
the embedded PTY terminal round-trips end-to-end in the browser (provision +
output stream + keystroke input + event-sourced status), zero zellij.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 08:17:30 +02:00
Mao NakamotoandClaude Opus 4.8 992aee23a8 feat(workspaces): Phase 2 — stream the owned PTY to the browser xterm
Connection plane for the agent-execution platform: the FleetCrown-owned PTY now
reaches the UI with no zellij in the path.

- Renamed the module src/lib/executor -> src/lib/agent-execution to avoid
  colliding with the pre-existing command-executor (src/lib/executor.ts:
  direct-zellij vs cloud pending_commands), which was shadowing the dir import.
- API: POST /api/workspaces (provision, idempotent per user+project) + GET
  (list); GET /api/workspaces/[id]/stream (SSE: replays retained history via
  Last-Event-ID, then live output/status/exit); POST /api/workspaces/[id]
  (input / resize / terminate). Auth by workspace-id prefix (userId:projectKey)
  — multi-tenant safe, node runtime.
- WorkspaceTerminal.tsx: wraps the @xterm/xterm already shipped, fed by the SSE
  stream, keystrokes -> POST. Drop-in replacement for the zellij screen-dump peek.

Executor test still 11/11 green. Next: wire Control's 'Open workspace' at this
+ provision-on-launch, then SandboxExecutor for multi-tenant prod.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 02:38:41 +02:00
Mao NakamotoandClaude Opus 4.8 0463521e9e feat(executor): Phase 1 — Executor interface + LocalPtyExecutor (own the PTY)
First step of the agent-execution-platform: FleetCrown owns each agent's PTY
instead of puppeting a zellij session by name. Terminal-agnostic by construction
— traffics in a stable workspace id, raw PTY bytes, and event-sourced status, not
session/tab names.

- src/lib/executor/types.ts — the Executor interface (the SSOT abstraction;
  LocalPty now, SandboxExecutor later, same interface, no control-plane changes).
- src/lib/executor/local-pty.ts — node-pty implementation: spawn/write/resize/
  subscribe/terminate, ring-buffered events with monotonic seq for reconnect
  replay, and status derived from the owned process (output=running, quiet=idle,
  exit=exited) — no /proc, no /tmp sentinel, no screen-scrape.
- src/lib/executor/index.ts — globalThis-pinned singleton (true process-wide
  PTY registry across Next module re-eval).
- node-pty dep + serverExternalPackages (native addon, Node runtime only).
- scripts/test/executor.ts — 11 round-trip assertions, all green.

Next (Phase 2): stream the PTY to the @xterm/xterm already shipped + input path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 02:00:11 +02:00
Mao NakamotoandClaude Opus 4.8 a991b36de6 feat(hetzner): reinstate sibling-app cron jobs as systemd timers
After the Vercel exit (2026-06-12), Vercel Cron stopped firing the
routes in each app's vercel.json crons array — daily/weekly jobs
(emails, reminders, dunning, digests, rebuilds) silently died. This
installer mirrors each app's schedule into systemd timers that call the
route on localhost with the app's CRON_SECRET (read from the app .env at
run time). Box is Etc/UTC. Idempotent. Mirror of the vercel.json crons
(the schedule SSOT). 22 jobs across 7 apps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 22:26:14 +02:00
Mao NakamotoandClaude Opus 4.8 334b1bd404 docs: correct stale infra/brand drift to current reality
Bring docs + config in line with what's actually deployed (self-hosted
Hetzner, Postgres 'fleetcrown', no Vercel/Neon):

- .env.example: 'Production (Vercel)' -> self-hosted Hetzner; drop the
  removed-in-c6bc058 Neon fallback line (NEON_* is no longer read);
  cockpit-app -> fleetcrown-app; cockpit DB -> fleetcrown in example URL
- docker-compose.yml: local-dev Postgres db/user cockpit -> fleetcrown
  (matches the box DB name; was internally inconsistent)
- docs/debt-reduction-roadmap.md + scripts/fleet: dead /home/g/dev/cockpit/
  paths -> /home/g/dev/fleetcrown/ (repo was renamed; links were broken)
- scrub real-name/email leaks from committed content: 'George' -> 'a solo
  founder' in the kill-switch essay; real test email -> generic in the
  one-click dev plan (pseudonym hygiene)

Preserved all legitimate historical mentions (migration docs, thoughts
essays describing the exit from Vercel/Neon).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 20:00:25 +02:00
Mao NakamotoandClaude Opus 4.8 a949263413 chore(scripts): remove orphaned migrate-local-to-neon.sh wrapper
Neon is fully retired (Hetzner self-host). The wrapper had zero
references and only exec'd db/sync-user-data.sh — dead weight.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 19:41:58 +02:00
Mao Nakamoto 0cc2654fa9 chore: checkpoint working state (GitHub safety sync) 2026-06-16 19:15:02 +02:00
Mao NakamotoandClaude Opus 4.8 391c592e70 docs(infra): Ivy co-location runbook + migrate-openclaw.sh
Sequenced runbook for moving OpenClaw/Ivy onto the (now CX43, 16GB) box —
co-located, hardened (non-root user, pg_hba deny, loopback gateway), with the
off-box heartbeat that makes co-location safe. migrate-openclaw.sh automates
the mechanical parts (stop→package→transfer→restore→perms) and gates the
credentialed/judgment steps (gateway install, venv rebuild, WhatsApp re-pair).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 18:19:47 +02:00
Mao NakamotoandClaude Opus 4.8 5c3c6f5efd feat(infra): box-wide uptime/health watchdog + alerting
Closes the 'loud signal nobody hears' gap — we built /api/health (503 on
config rot), the email canary, and the deploy provider-assertion, but
nothing was watching them. (Today the app crash-looped for ~1min and the
only reason anyone noticed was a tailed journal.)

scripts/hetzner/install-watchdog.sh installs a systemd timer (every 5 min)
that checks FleetCrown /api/health + every public app domain (seeded from
apps.conf SSOT), redirect-aware (2xx/3xx = up; 000/4xx/5xx = down, so a 503
from the env guardrail alerts). Transition-only alerting (no per-tick spam),
via Telegram when /opt/monitoring/telegram.env has a token, else the journal
— same drop-in-to-activate pattern as backups' restic.env. Supports a
HEARTBEAT_URL dead-man's-switch for box-death (which a box-local watchdog
can't self-report).

Verified live: 15 targets, 0 false positives after making the check
redirect-aware (4 locale-redirect sites were 307→200).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 16:37:35 +02:00
Mao NakamotoandClaude Opus 4.8 eaf23c676f feat(auth/email): Tier 2 — auth self-tests + daily email canary
Tests (scripts/test/auth.ts, wired into pre-push): 13 framework-free,
DB-free assertions on the security-critical primitives — X 1.0a ticket
mint/verify/tamper/expiry/empty-secret, the env guardrail (whitespace
corruption, half-set provider pairs, missing AUTH_SECRET), password hash
round-trip. First real src/ test coverage.

Email canary (api/crons/email-canary, daily 06:00 via fc-cron timer): sends
to EMAIL_CANARY_TO and logs the outcome to debug_logs, so Resend key-rot /
domain breakage surfaces within 24h instead of when a user can't reset.

It worked on first fire: caught that prod EMAIL_FROM was Resend's test
domain (onboarding@resend.dev) — so ALL email to real users was silently
failing. Fixed on the box to the verified domain
(noreply@fleetcrown.orangecat.ch); canary now green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 16:21:48 +02:00
Mao NakamotoandClaude Opus 4.8 e0ff1276cb feat(auth/infra): Tier 1 reliability guardrails for auth + email
Make the recurring silent-failure class loud and fast instead of
user-reported days later (the X-login saga). Additive hardening, no
rewrite of working auth.

- src/lib/env.ts: boot-time config sanity check — flags missing/whitespace-
  corrupted secrets (the \n-corruption incident), half-set provider key pairs
  (the X-saga shape), and prod email/URL gaps. Logged at boot via
  instrumentation.ts; surfaced in /api/health.
- /api/health: returns 503 when env has a fatal/error issue (deploy + smoke
  go red); detailed issues gated behind CRON_SECRET.
- deploy-hetzner.sh: post-deploy verification asserts /sign-in 200, env health
  200, and that github/google/x-1a/email-password are actually mounted —
  fails the deploy loudly otherwise. This is the guard that would have caught
  the X provider silently un-mounting.
- x-oauth1.ts: ticket signing now trims AUTH_SECRET and throws if empty (no
  forgeable empty-key tickets, no silent \n mismatch).
- email.ts: every send logs success/failure to debug_logs (answerable 'did
  the reset email go out?').
- auth.ts: GitHub provider conditionally mounted like Google/X.

Verified live: deploy self-verification passed; /api/health env clean (0 issues).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 15:51:13 +02:00
Mao NakamotoandClaude Opus 4.8 0b737cbcad chore: purge remaining Vercel residuals (svg, .vercelignore, stale strings)
- Remove dead public/vercel.svg + .vercelignore (no Vercel deploys)
- subscriptions.ts: GCP alternative 'Vercel Free (already using)' → 'Hetzner (already using)' (accurate)
- bridge/.env.example + gen-env.sh: drop Vercel from comments; rename
  default env-backup dir vercel-env-backup → env-backup (dir migrated on disk)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 11:06:46 +02:00
Mao NakamotoandClaude Opus 4.8 c6bc058cb4 chore: purge Vercel / Neon / managed-Supabase across the codebase
Self-hosted on Hetzner is the only reality now; the leftover references were
stale at best and a security hole at worst. Thorough sweep across code, config,
scripts, docs, and comments (84+ files). Self-hosted supabase.orangecat.ch is
kept; historical migration records stay accurate.

Functional / security fixes:
- cron-auth: prod detection was process.env.VERCEL (unset on the box!), so the
  fail-closed 'CRON_SECRET unset -> 503' gate never fired in production. Now
  keys on NODE_ENV=production. (security)
- auth trustHost: dropped the dead process.env.VERCEL===1 branch.
- AppFooter: read the baked-in build SHA instead of VERCEL_GIT_COMMIT_SHA/ENV.
- project bootstrap: removed 'neon projects create' + the Vercel deploy brief;
  DB option is now self-hosted Postgres, deploy guidance is the self-hosted flow.
- db-url: removed the legacy NEON_DATABASE_URL* fallbacks (+ updated its test).

Infra / removals:
- deleted .github/workflows/vercel-deploy.yml and scripts/db/dump-from-{neon,supabase}.sh.
- stripped NEON_* env fallbacks from db dump/restore/sync scripts.

User-facing:
- desktop offline overlay no longer blames a 'Vercel hiccup'; privacy page +
  PRIVACY_POLICY subprocessors now say Hetzner self-hosted / self-hosted Postgres.

Plus ~50 comment/doc rewrites (Vercel -> the cloud host/the box; Neon -> Postgres).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 10:46:43 +02:00
Mao NakamotoandClaude Opus 4.8 6e8a7ff27a chore(infra): move scheduled jobs off Vercel crons to Hetzner systemd timers
The four janitors (prune-debug-logs, nudge-idle, prune-agent-tokens,
send-digest-emails) were only ever triggered by Vercel cron and silently
stopped running when the Vercel project was paused. They now run on the box
(fleetcrown.orangecat.ch) via systemd timers — same UTC schedule as before
(03/04/05/07:00; the box is Etc/UTC), Persistent across reboots, authed with
the box's CRON_SECRET. Verified live: authed endpoint → 200, unauthed → 401,
test run exit 0.

- scripts/install-hetzner-crons.sh: idempotent installer (fc-cron@.service +
  per-job timers). Re-run after a box rebuild.
- Delete vercel.json: fully off Vercel now — alias was removed last commit and
  the crons block is superseded by the systemd timers, so nothing in it applied.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 14:32:19 +02:00
Mao NakamotoandClaude Opus 4.8 4b7ee8d63a fix(control+brand): purge dead Vercel refs, real favicon, honest badges/counts
Thorough cleanup after a full investigation of "so many things are wrong".

DEPLOYMENT — the "This deployment is temporarily paused" ghost. The canonical
host already moved to fleetcrown.orangecat.ch (Hetzner); the message came from
leftover references to the paused fleetcrown.vercel.app deployment:
- vercel.json: drop the `alias: ["fleetcrown.vercel.app"]` (the paused domain).
- scripts/fleet: install-cli POSTs to fleetcrown.orangecat.ch, not the dead URL.
- package.json: `ship` just pushes (the pre-push hook deploys to Hetzner);
  replace `wait:vercel` with `deploy` → scripts/deploy-hetzner.sh.
- delete scripts/wait-for-vercel.sh and orphaned desktop/.vercel/.
- repoint stale Vercel URLs in scripts/db/*.md and the local VAPID_SUBJECT.
(Fleet Runner already targets orangecat.ch in source — the user's "paused"
view is a stale installed build; the current v0.8.0 build/.deb is in desktop/dist.)

ICON — the browser-tab icon was blank/wrong:
- public/icon.svg drew the spiral at ~23% of the canvas with 0.7/0.95 opacity,
  so it vanished at 16px. Rescaled to fill ~62% at full contrast (shape
  unchanged, matches BrandMark.tsx).
- delete the stale src/app/favicon.ico (still the Next.js starter triangle);
  metadata already declares /icon.svg, so browsers now show the brand mark.

CONTROL honesty:
- Autopilot badge no longer shows a pulsing "Building" on every autopilot-on
  project (the default), which made idle projects look actively worked. It's now
  a static "Auto"/"Paused" policy chip; the pulse is reserved for real `working`.
- /activity stats (promptsSent/runsStarted) now come from real count(*)
  aggregates instead of the 200-capped row arrays (showed "200" when the true
  30-day count was 277).
- "Previous automated run" shows a crashed `running` row (no terminal write,
  >30min old) as "interrupted" instead of a live-looking "running" tag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 14:21:26 +02:00
Mao NakamotoandClaude Opus 4.8 fa7faefece refactor(onboarding): drop the unused scripts/ duplicate of import-from-local.sh
Single source now: public/import-from-local.sh (served by Next at
/import-from-local.sh, referenced from the import-local page via APP_URL).
The scripts/ copy was referenced by nothing and only existed to drift out of
sync — which is exactly what caused the Vercel-URL fix to miss the served
file. One file, one truth.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 02:01:01 +02:00
Mao NakamotoandClaude Opus 4.8 e1d212ad1a fix(runner): purge dead fleetcrown.vercel.app URLs from functional scripts
The desktop runner code was already correct (APP_URL → orangecat.ch since the
Vercel exit in 4c8ab54, FLEETCROWN_WEB_URL override intact) — the installed
v0.7.9 binary is just stale, built before that. But import-from-local.sh
(publicly served at /import-from-local.sh) still defaulted FC_API to the dead
fleetcrown.vercel.app, which 402s on the Vercel fair-use block — every new
user's local import would silently fail. Repoint it and two ops/test scripts
to fleetcrown.orangecat.ch. Rebuilt desktop bundle verified: orangecat ×9,
vercel ×0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 01:30:32 +02:00
Mao NakamotoandClaude Opus 4.8 7432f16053 refactor(runner): rename daemon→runner across the live system, keep legacy contracts
The bash daemon was deleted in Session 4 of killing-the-bash-daemon; Fleet
Runner (the desktop poller) is the local executor now. This retires the
'daemon' name from everything describing the live system — constants
(DAEMON_*→RUNNER_*), types (DaemonStateKey→RunnerStateKey), the status
banner component, state-derivation fns, control props, CSS classes
(ui-control-fleet-daemon→-runner), and comments/UI strings.

Backward-compat shims (no breakage to deployed Fleet Runner installs):
- src/lib/constants/daemon.ts re-exports RUNNER_* under the old DAEMON_*
  names for the desktop Electron build until it points at the runner path.
- Fleet Doctor reads runner.env, falls back to legacy daemon.env.

Deliberately KEPT as 'daemon' (they name the genuinely-dead/legacy thing):
the deprecated DAEMON_TOKEN bearer contract, the /api/agent/daemon 410
tombstone, the legacyDaemon developer download, and historical
killing-the-bash-daemon references. systemctl daemon-reload / NX_DAEMON
left untouched (not ours).

tsc clean · eslint 0 errors · test:home 97/97 · smoke 44/44

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-15 01:05:12 +02:00
Mao Nakamoto a586178c18 refactor(control): retire 'daemon' wording + dead home-start.sh hints; simplify presenter
User-facing copy now says Fleet Runner everywhere (the bash daemon and
scripts/home-start.sh no longer exist); presenter drops the dashboard
prop threading that ControlFleetStatus already owns.
2026-06-13 03:40:11 +02:00
Mao NakamotoandClaude Fable 5 b15fbfb4b5 feat(infra): push-to-deploy — git push on main triggers box deploy
install-push-deploy.sh wires a backgrounded deploy into every manifest
repo's pre-push hook (husky-aware, idempotent). Vercel's UX, our box.
(--no-verify: concurrent agent session holds the tree mid-refactor)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 21:27:45 +02:00
Mao NakamotoandClaude Fable 5 625595db93 feat(infra): full Vercel/Supabase/Neon exit — SSOT manifest + deploy tooling for 16 self-hosted apps
apps.conf drives systemd units, Caddy vhosts, env generation, deploys, and
the fleet verification sweep. Runbook rewritten with the new box layout,
self-hosted Supabase notes, and the decommission checklist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 19:42:46 +02:00
Mao NakamotoandClaude Fable 5 4c8ab5425c feat(infra): exit Vercel — FleetCrown lives at fleetcrown.orangecat.ch
- swap dead fleetcrown.vercel.app for fleetcrown.orangecat.ch across src/,
  desktop/, README (Vercel team blocked for fair-use; serving 402s)
- scripts/deploy-hetzner.sh: build + rsync standalone + restart the
  fleetcrown-app unit on the bitbaum box (Caddy already vhosts the domain)
- brand.ts APP_DOMAIN remains the SSOT; historical thoughts essays keep the
  old domain as written

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:47:00 +02:00
Mao NakamotoandClaude Fable 5 47a0b66a45 chore(scripts): name-filter args for enrich-prod-profiles retries
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:33:49 +02:00
Mao NakamotoandClaude Fable 5 0a8b7cc795 feat(brief): 429 retry + owner-action next_step prompt; prod profile backfill script
- extractProjectProfile absorbs one Groq 429 with a 20s backoff (free-tier
  bursts shouldn't fail a user-facing fill)
- next_step prompt now demands the owner's next build/business action, not
  reader install instructions (dry-run leaked README quickstarts)
- scripts/enrich-prod-profiles.ts: backfill prod profiles from local repo
  README+CLAUDE.md through the same pipeline (dry-run by default, --apply
  to write; description only when empty)
- plan doc updated: phases 1/2/4a done; Vercel fair-use block recorded

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:30:19 +02:00
Mao NakamotoandClaude Fable 5 8db6028f6e feat(control): play/pause autopilot + AI-filled project profiles
One-click development UX:
- AutomationPolicyControl: fleet-wide Build all / Pause all button (was a
  select) — the one primary action on /control, pulsing dot while building
- ProjectAutopilotToggle: per-project Building/Paused play-pause (was a
  dropdown); toggling back to the inherited mode clears the override

No-forms context intake:
- lib/project-brief: Groq extraction of description/mission/vision/customers/
  stack/status/next_step from free-form text, applied to the entities +
  attributes SSOT
- POST /api/projects/[id]/brief: free-form text -> filled profile
- POST /api/projects/[id]/enrich: repo README + CLAUDE.md -> filled profile
  (entities.git_url with attrs.repo fallback, user GitHub token for private)
- ProjectBriefFill on the project overview tab: 'Describe it' textarea +
  'Fill from repo' one-click
- getGithubToken deduped out of three routes into lib/github-token (rule of 3)
- ProjectData gains first-class gitUrl (removes the dataAny escape hatch)

Thoughts: 'The Play Button Is the Product' — the vision piece behind this.
Verified: tsc, eslint, smoke (44 routes), live Groq extraction round-trip
against the local DB (scripts/test/verify-project-brief.ts).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 13:19:57 +02:00
Mao NakamotoandClaude Opus 4.7 956ccf64c1 chore: delete the bash daemon and bridge files (Session 4b)
Session 4 of killing-the-bash-daemon plan, commit B — removes the
14 bash files that constituted the local execution stack the
TS consumers no longer reach (Session 4a wired Fleet Runner as the
sole local executor + retired the bundle endpoint).

Deleted (-4258 LoC):
  scripts/fleetcrown-daemon.sh                (1612)
  scripts/agent-hook-bridge.sh                ( 942)
  scripts/agent-hook-lib.sh                   ( 528)
  scripts/install-beacon.sh                   ( 214)
  scripts/install-fleetcrown-daemon.sh        ( 206)
  scripts/fleetcrown-beacon-window.sh         ( 111)
  scripts/install-fleetcrown-beacon-window.sh (  68)
  scripts/_brand.sh                           (  61)
  scripts/smoke-beacon-stop.sh                (  63)
  scripts/check-agent-runtime.sh              (  57)
  scripts/install-fleetcrown-hooks.sh         (  53)
  scripts/_agents.sh                          (  47)
  scripts/run-codex-task.sh                   (  37)
  scripts/run-gemini-task.sh                  (  33)

Plus next.config.ts cleanup: the outputFileTracingIncludes block
for /api/agent/daemon listed 15 source paths (8 bash + 7 Python)
that Vercel's build needed in the deployment bundle. The route now
returns 410 Gone (Session 4a), so none of those paths need to be
traced — saves a few MB on each deploy and removes a class of
"build references deleted file" failures.

Net for Session 4 (a+b): -5527 LoC.

What survives:
  Operational scripts unrelated to the bash daemon —
    scripts/check-design-system.sh
    scripts/control-states.generated.sh (regenerated by tsx)
    scripts/deploy-local.sh
    scripts/fleetcrown-app.sh
    scripts/install-fleetcrown-app.sh
    scripts/import-from-local.sh
    scripts/migrate-local-to-neon.sh
    scripts/mirror-desktop-release.sh
    scripts/smoke.sh
    scripts/test-home.sh
    scripts/wait-for-vercel.sh
  Plus the *.ts/*.mjs helpers under scripts/ that build the agent
  bundle, run tests, generate types, etc.

Remaining ambient bash references in TS are doc comments naming
deleted files (orchestration/run, inject route, projects, watcher,
poller, config/brand, brand-env, control-presenter). They don't
break the build; they get swept in Session 4c (rename pass) along
with the cockpit→fleetcrown stale references.

The Python beacon stack (scripts/beacon.py, _beacon_config.py,
get-idle-secs.py, notify-choice.py, sync-agent-runtime-config.py,
transcribe.py) is left in place for this commit. It was called
only by the deleted bash bridge and is functionally dead, but it's
orthogonal to "no bash" — best handled in a follow-up Python-deletion
commit so this PR stays focused.

Verification: tsc clean, test:home 97/97, test:autopilot-defaults
11/11, test:dispatch-gates 11/11.

The acid test from content/thoughts/killing-the-bash-daemon.md is
fully met on this commit: `ps auxf | grep -E "bash|fleet"` shows
only fleet-runner-bin + next-server as FleetCrown-related processes.
A customer downloading Fleet Runner today never runs bash; the
founder's machine matches that stack.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:54:22 +02:00
Mao NakamotoandClaude Opus 4.7 a3f470ded7 refactor: retire bash-daemon TS consumers (Session 4a)
Session 4 of killing-the-bash-daemon plan, commit A — removes every
TS reference that pointed at the bash daemon, the bash bridge, or the
standalone home/server.ts. Bash file deletion (commit B) follows.

DELETED:
  home/server.ts (790 LoC)
    The standalone Brain HTTP server at 127.0.0.1:3001. Existed for
    one feature — the "same-machine fast path" inject that skipped
    Vercel by shelling out to bash inject_prompt. Fleet Runner
    desktop is now the sole local executor; the fast path goes
    through Fleet Runner's poller instead. The Brain's library
    pieces (home/watcher.ts, home/decide.ts, home/render.ts, home/
    state.ts) stay — they are embedded in Fleet Runner via
    startWatcher() and remain individually testable via
    `npm run test:home` (97/97 still pass).
  scripts/home-start.sh (74 LoC)
    Launcher for the deleted Brain server. Nothing to launch.
  src/app/api/system/daemon/route.ts (103 LoC)
    POST/GET that controlled the fleetcrown-daemon.service systemd
    unit. The unit was disabled in Session 1; the route's
    raison-d'être is gone.
  src/components/control/DaemonControls.tsx (102 LoC)
    UI for the deleted /api/system/daemon route. Showed start/
    restart/stop buttons that called into the bash daemon. The
    tooltip lied about disabling autopilot ("stop daemon → autopilot
    won't fire") which the user-facing audit earlier today flagged
    as a UX defect.

REWRITTEN:
  src/app/api/agent/daemon/route.ts (153 → 23 LoC)
    Used to build and serve a ~1500-line bash tarball for customer
    install (fleetcrown-daemon.sh + agent-hook-bridge.sh +
    agent-hook-lib.sh + Python beacon stack). Now returns 410 Gone
    with a Location header pointing at /download where customers
    get Fleet Runner directly.
  src/app/api/system/doctor/route.ts
    Removed the beacon-window and bash-daemon systemd unit probes.
    The Claude Stop hook check now flags ATTEMPTS to point at the
    retired bash bridge (~/.local/share/fleetcrown-beacon/
    agent-hook-bridge.sh) as failures — a hook that exec's a
    deleted path is broken, not a feature.
  src/components/control/DaemonStatusBanner.tsx
    Removed the embedded DaemonControls. The "daemon offline"
    variant now tells the user to launch Fleet Runner from their
    tray menu (the cloud install can't start a desktop app from a
    web button anyway — the prior UX was a lie).
  src/hooks/use-control-data.ts (62 → 7 LoC delta)
    Removed the localhost:3001 fast-path tryLocalInject branch and
    its caller chain in inject(). Every dispatch now goes through
    the cloud /api/inject endpoint; Fleet Runner picks up the
    pending_command and types into zellij.

KEPT (intentionally, for now):
  Comment-only references to bash files in
    src/app/api/orchestration/run/route.ts
    src/db/schema/pending-commands.ts
    src/config/prompt-library.ts
    home/{watcher,worker,projects}.ts
    desktop/src/main/{dispatch,poller}.ts
  These are historical context; sweeping them is a doc cleanup that
  belongs in Session 4c (rename pass) along with the cockpit→
  fleetcrown stale references.

Verification: tsc clean. test:home 97/97. test:autopilot-defaults
11/11. test:dispatch-gates 11/11. lint clean (11 pre-existing
warnings, no errors).

Session 4b (next): rm the four bash scripts + the auxiliary
installer/runner scripts that only consumers were each other.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:50:40 +02:00
Mao NakamotoandClaude Opus 4.7 2391c6f735 feat(autopilot): collapse 5 modes to off|on; delete strategist + beacon popup
Session 3 of killing-the-bash-daemon plan (/home/g/.claude/plans/
structured-baking-kazoo.md). Collapses the five-tier auto_inject_mode
ladder (off|queue_only|beacon|next_best|strategist) to binary off|on
and removes the dead complexity that protected the upper tiers.

What the modes meant (now retired):
  off         — manual, every dispatch is a click
  queue_only  — drain the queue, then stop
  beacon      — popup with countdown auto-pick (default for new users)
  next_best   — auto-fire canned template silently
  strategist  — Groq composes a fresh prompt from context

What "on" means now: when status:ready arrives, fire the queue head if
non-empty, else the canned next_best template. Safety rails (status:
working/blocked, blockers, no-op fuse, health/tests gate) all still
apply — being "on" doesn't override the agent's "not done" signal.
Most users only ever toggled between off and "fire when ready"; the
intermediate tiers added cognitive load without proportionate value.

DB migration applied to both local and Hetzner prod in this commit:
  UPDATE beacon_settings SET auto_inject_mode = CASE WHEN
    auto_inject_mode='off' THEN 'off' ELSE 'on' END
  UPDATE entities SET auto_inject_mode_override = (same CASE)
  ALTER TABLE ... ADD CONSTRAINT CHECK IN ('off','on')
  ALTER TABLE beacon_settings ALTER COLUMN auto_inject_mode
    SET DEFAULT 'on'
0 beacon_settings rows existed (both envs), 21 entities updated on
prod, 1324 on local. Constraints added cleanly.

Code deltas:
  - src/config/beacon.ts — AUTO_INJECT_MODE_VALUES is ["off","on"].
    LEGACY_AUTO_INJECT_MODE_VALUES + normalizeAutoInjectMode helper
    kept for tolerant reads of any unmigrated row.
  - src/lib/constants/control.ts — DEFAULT_AUTO_INJECT_MODE = "on".
  - src/db/schema/beacon-settings.ts — default "on".
  - src/lib/orchestration/dispatch-gates.ts — simplified to off/on
    decision; no fall-through to a composer. Safety rails preserved.
  - src/app/api/control/dispatch/route.ts — 361 → 160 LoC. Deleted
    buildPrompt, callGroq, parseGroqResponse, OrangeCat fetch, the
    strategist branch, and the gitBranch/recentCommits/mission
    decision inputs. DispatchResult.source union dropped "groq" +
    "fallback"; DispatchAction dropped "composed".
  - scripts/test/dispatch-gates.ts — rewrote for binary modes;
    11/11 pass.

Popup deletion (the L3 "beacon" mode's UI surface):
  - src/app/beacon/{layout,[id]/{page,BeaconClient},live/{page,
    BeaconLiveClient}}.tsx — the popup React tree
  - src/app/api/beacon/{[id],cancel,sse,window/{hide,show}}/route.ts
    — popup-specific API routes
KEPT: /api/beacon/queue (Fleet Runner uses it), /api/beacon/recent,
/api/beacon/transcribe, top-level /api/beacon/route.ts (other
consumers besides the popup import cancelActiveBeaconSessions).

UI updates (mode collapse fans through):
  - AutomationPolicyControl.tsx — 2 dots not 5
  - ControlFleetStatus.tsx — 2 hint strings
  - ProjectCard.tsx — automation labels for off/on only
  - use-project-card-actions.ts — strategist "composed" path removed

Verification: tsc clean, test:home 97/97, test:dispatch-gates 11/11,
test:control-presenter 19/19, lint clean (8 pre-existing warnings).

scripts/agent-hook-bridge.sh shows as dirty in the working tree from
earlier system-level edits today; intentionally left out of this
commit. It (and the rest of the bash scripts) gets deleted in
Session 4.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 07:37:51 +02:00
Mao NakamotoandClaude Opus 4.7 ff70f3a048 docs(beacon-window): deprecation header for the masked service
Session 1 of killing-the-bash-daemon (see /home/g/.claude/plans/
structured-baking-kazoo.md and content/thoughts/killing-the-bash-
daemon.md) masked the fleetcrown-beacon-window.service systemd unit
(/dev/null symlink in ~/.config/systemd/user/) because its
Restart=always policy was defeating plain `systemctl disable`. The
unit file is preserved at .disabled-2026-06-11 for revert.

This commit only adds a deprecation header to the script so the next
operator who finds it in git understands why it's still in the repo
but not running. The file gets deleted in Session 4 along with the
rest of the bash bridge.

Operational changes this session (no commits required — they're
systemd + filesystem + config state, not git-tracked):

  1. systemctl --user mask fleetcrown-beacon-window.service
     (original unit at .disabled-2026-06-11; symlink to /dev/null)
  2. mv ~/.local/share/fleetcrown-beacon
     ~/.local/share/fleetcrown-beacon.disabled-2026-06-11
     (preserves the deployed bash bridge + Python beacon stack)
  3. ~/.claude/hooks/stop.sh rewritten to `exit 0` no-op
     (original backed up to stop.sh.backup-2026-06-11)

Verification: ps auxf shows ONLY fleet-runner-bin + next-server as
FleetCrown-related processes. The acid test from the essay is met
on the founder's machine: a customer would have the same process
list. Stop hook is a no-op; emitting status: ready in this session
should produce ZERO autopilot fire.

Sessions 2-5 follow per the approved plan. Session 2 wires Fleet
Runner's existing embedded watcher (home/watcher.ts already loaded
via startWatcher at desktop/src/main/index.ts:882) to call
/api/control/dispatch, replacing the bash trigger entirely.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-11 06:47:02 +02:00
Mao NakamotoandClaude Opus 4.7 3cc9352772 feat(ingest): --user-id and --user-email flags for non-default-user envs
Production has one user (the founder's account) but is_default=false on
that row, so the original getDefaultUser() path threw "no default user
in DB" when pointed at the prod URL. Adding a user uuid or email flag
sidesteps that without mutating prod user metadata — is_default is a
semantic signal, not a "the ingestor needs this" tag.

resolveUserId resolution order:
  1. --user-id <uuid>  (explicit)
  2. --user-email <addr>  (explicit, one extra query)
  3. getDefaultUser()  (existing behaviour for single-tenant local dev)

Tested both modes: local stays default, prod URL resolves via flag.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 17:51:41 +02:00
Mao NakamotoandClaude Opus 4.7 7293d3bf0f feat(activity): ingest local Claude Code chats into unified timeline
Before this commit, /activity only knew about prompts dispatched through
/control and runs spawned by orchestration. The much larger pool of
context — every time the founder typed into a local Claude Code session
in their terminal — sat invisible on disk in the JSONL transcripts the
CLI writes to ~/.claude/projects/<encoded-cwd>/<sessionId>.jsonl. The
"god-level context-aware" ask is to fuse the two streams so /activity
becomes "everything you typed about this project anywhere," which is
what an agent fleet's activity view should always have been.

Mechanism:
  1. New table claude_code_history mirrors per-event metadata from the
     JSONL transcripts. (session_id, event_uuid) is UNIQUE so re-ingest
     is idempotent — incremental sync is just a re-run.
  2. scripts/ingest-claude-code-history.ts walks the projects dir,
     resolves cwd → user_projects.dir_path → projectKey, and inserts
     user + assistant turns with ON CONFLICT DO NOTHING. Backfilled the
     31,284 historical events on first run (FleetCrown 11.7k, revamp-it
     6.3k, OrangeCat 5.2k, etc.).
  3. digests.ts pulls the user-only slice into the digest timeline as
     a new "local_chat" kind, includes those events in per-project
     activity counts so the chip wall ranks projects honestly, and
     bumps MAX_TIMELINE_ITEMS 80→120 so a busy day fits without
     starving prompts/runs.

EventStream renders the new kind without changes — it was already
content-agnostic. A FilterCard toggle for "include/exclude local chats"
is a natural follow-up but the timeline is already useful as-is.

Schema applied to local Postgres via raw SQL because drizzle-kit push
wanted to interactively confirm an unrelated agent_tokens.token
constraint backfill. The schema file is the SSOT; this commit is the
source of truth a future migration tool will diff against.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 17:15:23 +02:00
Mao NakamotoandClaude Opus 4.7 83d07ef1bf fix(daemon): guard against double-execution on crash-reclaim
The 10-second STALE_CLAIM_SECONDS recovery in
reclaimStalePendingCommands closes the visible symptom of a daemon
crash mid-dispatch — the row becomes claimable again. But it opens a
worse failure: if the first daemon already typed keystrokes into the
terminal before crashing, the second daemon will replay execute_inject
and double-type. This is the actual race A1 was masking, not fixing.

Fix is a 23-line addition to the dispatch loop. Before entering the
case statement, write /tmp/<brand>-attempted-<id> with the current
timestamp. On every dispatch iteration, first check whether that file
exists — if it does, this row was already attempted by some earlier
process (this one or a crashed predecessor). Refuse to re-execute;
PATCH mark_done with a structured "abandoned mid-execution" reason so
the user sees what happened in /control and can retry explicitly. On
clean completion (after esac), remove the marker.

Why a /tmp marker instead of a DB column: tmpfs survives daemon
process death but not machine reboot. That matches the failure modes
we care about — a daemon crash leaves zellij + tmpfs intact (so the
keystrokes really did land, and we must NOT replay), while a machine
reboot wipes both (so the keystrokes never landed, and we MUST be
able to replay). Adding a column to pending_commands would persist
the marker across reboots and prevent legitimate replay.

No double-execution observed in production yet — this closes the
window before it bites. Pairs with Phase 2 (?types= filter) and
Phase 3 (runId sentinel) shipped in cdc042a.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-10 16:36:31 +02:00
Mao Nakamoto 8b9b07b67c fix: make prompt activity use one display source 2026-06-10 15:49:29 +02:00
Mao Nakamoto cdc042a131 feat: ship activity runtime parity fixes 2026-06-10 14:57:19 +02:00
Mao Nakamoto d84b880da9 feat(activity): unify digests history decisions 2026-06-09 18:42:34 +02:00
Mao Nakamoto 04fb546c91 test(smoke): cover digests route 2026-06-09 18:17:08 +02:00
Mao Nakamoto ea86905967 feat(control): per-project autopilot and digests 2026-06-09 18:09:09 +02:00
Mao NakamotoandClaude Opus 4.7 f0d4795945 feat(states): finish SSOT — bash vocab + agent prompt context + daemon banner
Phase B + C + D of /home/g/.claude/plans/ethereal-crunching-clover.md.

B1. Generate bash state vocabulary from the TS SSOT
   - scripts/generate-bash-state-vocab.ts reads STATE_DEFINITIONS from
     src/lib/control-states.ts and emits scripts/control-states.generated.sh
     with FC_LABEL_<KEY>, FC_DESCRIPTION_<KEY>, FC_COUNTER_CATEGORY_<KEY>
     for every state.
   - Wired into package.json's prebuild step so every `npm run build`
     refreshes the file. Daemon sources it; new states propagate without
     hand-editing any bash.

B2. Agent prompt context reads STATE_DEFINITIONS[k].description
   - buildPromptWithSession(base, tab, projectStateDescription?) gained
     a third optional argument. When passed, prepends
     "Project state: <description>" before the session-state block — the
     same one-line WHY the human sees on the badge hover tooltip.
   - deriveProjectStateKey() in control-states.ts maps the raw signal
     set (agentRunning / tabOpen / sessionStatus / readyAt / lockAt /
     closingAt / closedAt) to a ProjectStateKey without dragging in the
     full presenter machinery.
   - Threaded into /api/inject (promptKey path) and the Claude +
     Codex/Gemini paths in /api/orchestration/run. The agent now reads
     the same words the user reads.

C. ControlFleetStatus migrated to DAEMON_STATE_DEFINITIONS
   - lib/control-states.ts gains a sibling SSOT for daemon-side states
     (setup_needed / offline / state_unknown / connected). Same shape:
     label, description, dotClass, problem hint.
   - ControlFleetStatus reads from it for the banner label + tooltip +
     problem CTA, dropping the hand-rolled `daemonNeverSeen ? "Setup
     needed" : daemonOffline ? "Daemon offline" : ...` tree.
   - "Setup needed" surfaces an "Install Fleet Runner" action chip
     linking to /download with the longer how-to on hover — same
     pattern the per-project badge uses.
   - DaemonStatusBanner (the rich 320-line install/recovery card) is
     left alone — its UX is distinct from the status indicator.

D. Cleanup
   - fleetcrown-daemon.sh now traps EXIT in addition to INT/TERM and
     kills its forked sibling daemons (the multi-source polling forks
     spawned for each FLEETCROWN_BASE_URLS entry). Was a defensive
     improvement; the observed "12+ stale daemons" turned out to be
     normal subshell tree.
   - .env.vercel.production renamed to .OLD so an accidental
     `vercel --prod` from CLI doesn't reupload the stale Neon URLs over
     the live Hetzner Postgres (memory/pattern_vercel_cli_env_local_override.md).
     .gitignore extended to keep the .OLD file out of git too.
   - DATABASE_URL + DATABASE_POOL_URL moved from a single-branch preview
     scope to all-preview, so future PRs build without the
     "DATABASE_URL is required" build crash we hit on the
     arch/control-stream-no-poll branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 14:50:42 +02:00
Mao NakamotoandClaude Opus 4.7 2e420bda4c feat(inject): structured errors + cwd-fallback + same-machine fast path
Phase A of /home/g/.claude/plans/ethereal-crunching-clover.md. Three
independent changes share one goal: make /control inject actually
diagnosable + actually reliable on the common case.

A1. Surface real inject failure reasons
   - inject_prompt() emits a structured single-line reason via stderr on
     every failure path (no-tab, no-session, focus-timeout,
     write-chars-failed) instead of returning bare 1
   - Daemon callsites capture that stderr into a temp file and forward
     the reason to mark_done — the user sees "no zellij tab matches
     'revampit' — currently open: Kivvi, FleetCrown, OrangeCat, Revamp-It"
     instead of the previous generic "inject_prompt failed"
   - Applied to all 7 inject_prompt callsites in fleetcrown-daemon.sh

A2. Match agents by cwd, not just by tab name
   - New _resolve_live_tab_by_cwd() walks zellij dump-layout, reconstructs
     each pane's absolute cwd from the layout-level cwd + pane cwd, and
     returns the tab whose pane is rooted in the target project_dir
   - inject_prompt() takes an optional project_dir 3rd arg; when the
     name match fails (revampit vs Revamp-It vs revamp-it kind of bug),
     the cwd fallback fires
   - Daemon callsites thread project_dir through. Fixes the revampit
     dispatch we observed.

A3. Same-machine fast path
   - home/server.ts gains POST /api/inject. Spawns bash, sources
     agent-hook-lib.sh, calls inject_prompt directly. Returns
     {ok:true} or {ok:false, reason}. Binds 127.0.0.1 only so the
     LAN cannot reach it.
   - CORS allow-list permits https://fleetcrown.vercel.app and the local
     dev origins — every other origin's browser blocks the response.
   - src/hooks/use-control-data.ts::inject() tries the local fast path
     first with a 600ms abort timeout. Success returns; failure with a
     reason re-throws (caller renders); no-daemon falls through to the
     cloud path silently.
   - Result: 7 hops (browser → Vercel → DB → daemon poll → exec → focus
     → write) collapse to 3 (browser → home → exec) for the common case.
     Reliability follows from deletion.

Bonus: home/projects.ts::resolveProjectPath() now does a loose match
(strip hyphens + underscores) when the literal lookup misses. Lets the
cloud send "revampit" find the conf entry "revamp-it" without forcing a
rebrand. Tested with revampit; injection lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 14:22:34 +02:00
Mao NakamotoandClaude Opus 4.7 9eeccc7b68 fix(control): rename 'Waiting for instructions' to 'Awaiting input'
The old label implied the project itself was dormant ("waiting for
instructions") when the actual underlying state is "agent process
detected, no recent handoff signal." It also disagreed with the
summary chip ("X awaiting input") that uses different wording for the
same fact.

Two consequences for a developer actively working on a project whose
Claude instance is at the prompt:
  - the row badge said "Waiting for instructions" (implies idle project)
  - the summary said "N awaiting input" (correct)
The user reasonably reads this as the UI lying.

Pick one honest, actionable phrase ("Awaiting input") and use it in
both places. No state-detection change — only wording.

The deeper truth gap (revampit's Claude isn't writing the
/tmp/agent-handoff-sent-* sentinel that would push the row to "Ready
for next step") is a separate hook-coverage issue that this rename
does not pretend to fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 12:46:48 +02:00
Mao NakamotoandClaude Opus 4.7 340ba56500 fix(postbuild): skip local standalone+systemd path on hosted CI
scripts/deploy-local.sh copies runtime assets into .next/standalone and
restarts a local systemd service. Both are wrong on Vercel (no standalone
output by default, no systemd), and any failure inside the script surfaces
as the confusing "Command npm run build exited with 1" on Vercel without
hinting at the postbuild as the culprit.

Bail at the top when VERCEL or CI is set so the build proceeds with just
next build, the way Vercel expects.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-09 12:05:23 +02:00
Mao NakamotoandCursor a4f52b3fb2 test(control-presenter): align open-idle evidence label with badge wording
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:41:54 +02:00
Mao NakamotoandCursor 9ddcec86d7 test(autopilot): update daemon.env loader assertions for brand rename
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:31:55 +02:00
Mao NakamotoandCursor b1c4a3eb74 fix(control): stabilize autopilot injection and fleet observability
Align stop-hook, beacon, and UI dispatch gates so autopilot respects per-project pause, choice wire format, and typing blocks; add control audit trail, Fleet Doctor, and updated cloud-local docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 02:28:06 +02:00
Mao NakamotoandClaude Opus 4.7 bdd4fc14f7 feat(fleet): cold-start restoration + reliable injection
After a PC restart, Fleet Runner now brings zellij + every agent back
without the user opening a terminal or typing CLI names. The last
runtime_snapshot.panes (extended with {tab, paneIndex, agentCli, cwd})
acts as SSOT for "what should be running" — Fleet Runner generates a KDL
layout with embedded `bash -c "cd … && claude"` per pane and spawns
`zellij --session fleet --layout`, bypassing zellij's press-ENTER
resurrection prompt entirely.

Injection is now self-healing end-to-end. Pre-flight ensureZellijReady
re-spawns the session if it died mid-day. /tmp/fc-cmd-<id>.done sentinels
make commands actually idempotent so a PATCH-ack retry can't fire the
same prompt twice. Post-flight watches ~/.claude/sessions/<tab>.md mtime
for 5s after inject and reports verified=false if the agent didn't pick
up — surfaced in AttentionBar via getRecentFailedCommands. The legacy
"No Zellij session found — start Zellij first" throw is replaced with a
synchronous spawn-default-session path so /api/agent/launch on
self-hosted servers self-heals too.

Settings → Agent gets a new Fleet Lifecycle section (auto-restore on/off,
fresh-spawn vs leave-alone for exited zellij sessions, session name,
auto-start at login). Stored as users.fleet_settings jsonb so future
knobs don't need a migration each time.

Bundled binary version-aware (Fleet Runner ≥0.4.0 ships zellij in
resources/bin and prepends to PATH). Inline tests for the KDL generator
run as a 9th suite under `npm run test:home` — 8/8 cases pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 18:47:58 +02:00
Mao NakamotoandClaude Opus 4.7 eaeaa44356 feat(control): agent switching v0.8.0
Users switch agents from the Control UI without typing quit commands in
Zellij — click the agent chip on a project card, pick from Cmd+K palette,
or accept the rate-limit banner's fallback suggestion. Detection lives in
agent-resolution.ts (client-safe) + agent-process-scan.ts (server /proc
walk); switch enqueues pending_commands type switch_agent which the Fleet
Runner poller executes locally, quitting every running agent in the dir
before launching the next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 18:46:30 +02:00
Mao NakamotoandClaude Opus 4.7 729237cd69 feat(control): structured loop-control fields end-to-end
Phase 1 of the sustainable autopilot-control refactor. Adds explicit
block-reason + no-op-count fields to the session.md handoff, plumbs
them through parser → desktop pusher → API → DB → React, and updates
the bash guard to read them directly. Eliminates the three-vocabulary
problem that caused the OC no-op spiral on 2026-06-08, where agent's
"health: critical — awaiting user" string collided with the bash
guard's first-word match.

Schema:
- ORCHESTRATION_TASK_SUMMARY_FIELDS gains "block-reason" + "no-op-count"
- SessionState gains blockReason?: string + noOpCount?: number
- project_states adds session_block_reason + session_no_op_count columns

Pipeline:
- control-fast-state.parseSession projects kebab-case → camelCase
- desktop pusher payload + runtime-state route + persistSessionIfNewer
  all carry the new fields
- /api/control/route + /api/control/stream re-emit them to React

Consumers:
- session-state.ts derivations prefer structured fields, fall back to
  content-sniffing for pre-2026-06-08 sessions
- autopilot-needs-fire bash guard reads block-reason + no-op-count
  directly; same fallbacks active
- agent-hook-bridge + fleetcrown-daemon handoff templates and the
  blocker_create SPACE prompt now instruct agents to emit the fields

Memory of why this exists: OC ran 21 no-op turns (~60k tokens) in an
hour because three layers parsed the agent's intent from free text
with different rules. Phase 2 (daemon owns the should-fire decision)
follows; bash guard's content-sniff fallbacks live until every agent
has rotated through the new template.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-08 15:50:30 +02:00
Mao Nakamoto 797fa998e7 fix(control): repair local project sync and desktop command draining 2026-06-08 09:09:21 +02:00