Commit Graph
64 Commits
Author SHA1 Message Date
Mao NakamotoandClaude Fable 5 5fc3333f9a fix(control): fleet truth pass — honest hero, live janitors, actionable streaks
Dogfood session drove FleetCrown against production and found the fleet
had been silently dead for 2 days behind a green light:

- nudge-idle raw-queried beacon_settings WHERE mode != 'off', so users
  with NO row (missing row = default 'on') were invisible to the
  scheduler — autopilot dispatched nothing while the hero said
  'Autopilot on'. New SSOT getFleetAutopilotUserIds() decides
  enrollment for schedulers; missing rows count as on.
- The stale-run reaper only ran on /api/control page loads: 16 runs sat
  'waiting' for 51h until a human looked, then got stamped with
  fabricated 51h durations. New hourly reap-stale-runs cron reaps all
  users; finishedAt = startedAt + STALE_RUN_MINUTES (truthful).
- Hero headline was mode-derived ('Building' + pulsing green with 0
  working and 16/16 failed runs). deriveFleetPulse() (pure, tested)
  now derives Building / Waiting to dispatch / Stalled(+Review
  failures link) / Paused from live counts + latest outcomes.
- OutcomeStreak ✗ glyphs were unlabeled dead-ends; the streak now
  deep-links to /activity?window=week&project=<key>.
- box-runner logged 'connected · last poll 0s ago' every 2s to journald
  (~40k lines/day); now logs on state change + 15-min heartbeat.

Presenter tests 25/25 (6 new fleet-pulse cases).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 22:00:50 +02:00
Mao Nakamoto bd5da41132 fix(loops): surface readiness and auth labels 2026-07-01 04:20:42 +02:00
Mao Nakamoto cf45aa9be5 fix(loops): route idle nudges through dispatch spine 2026-07-01 02:52:21 +02:00
Mao Nakamoto 66e3ac55dc feat(multitenancy): gate shared cloud execution 2026-06-30 19:07:54 +02:00
Mao Nakamoto 033b780326 feat(control): complete terminal and orchestration trust pass 2026-06-30 14:53:06 +02:00
Mao NakamotoandCursor f755b4f134 fix(loki,control): show builder-online copy for cloud queue dispatches
Cloud inject always queues even when box-runner is connected; distinguish
runnerConnected in Loki footer, Control toasts, and dispatch-status SSOT.
Add prod dogfood script and dispatch-status tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 00:08:43 +02:00
Mao NakamotoandCursor a491e9e487 feat(loki,control): unified builder UX and move-forward dispatch
Browser-first onboarding and executor-copy SSOT; Loki imperatives and move-forward
route to the same builder queue as Control with cloud-first Terminal links; fleet-kick
queues when offline; deploy script syncs box-runner.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 22:58:32 +02:00
Mao NakamotoandCursor 480294fa15 feat(control,loki): subset loops and screenshot dispatch
Add Build/Pause selected on Control, multi-project command fan-out in Loki,
and route scoped screenshots to dispatch with vision preflight instead of chat.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 19:45:42 +02:00
Mao NakamotoandCursor 9f0d170484 feat(control): fleet-kick on Start building and fix nudge-idle cron
Start building now batch-dispatches next_best on eligible idle projects
(capped at three concurrent) and Loki accepts develop-all phrasing; restore
the daily idle nudge for users with autopilot on after the mode collapse.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-29 18:58:10 +02:00
Mao NakamotoandCursor f62565e9b8 feat(control): ship Phase 1 fleet play/pause hero UX
Prominent ui-control-hero autopilot card with Building/Paused status, large
Start/Pause CTA, per-project toggles, rail override chips, and refresh sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-28 11:09:33 +02:00
Mao NakamotoandCursor 50b52301e1 feat(rag): Memory index health and Hetzner install SSOT
Surface fleet-knowledge chunk counts on /memory, document box RAG ops via
install-fleet-rag.sh, and add rag-retrieval test script. Reindex on production
already active (24 chunks across 21 project profiles).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 18:39:47 +02:00
Mao NakamotoandCursor 239e6d8ec4 fix(projects): cloud inject carries full project context to agents
Phone/Loki/beacon dispatches queued bare promptKey strings on the cloud host;
assembleInjectPrompt now matches orchestration/run. Persist architecture/
conventions/DoD from AI briefs, expand injected fields, add build-contract UI,
and reindex profile embeddings on save when RAG is enabled.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 18:19:55 +02:00
Mao NakamotoandCursor 6dd74f2c2b feat(terminal,loki): mobile full-screen terminal and develop handoff
Expand/collapse on phones gives xterm usable height; Loki dispatches route
"let's develop" through next_best and link to watch the agent. Profile drawer
follows action-first hierarchy with filtered activity noise.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 16:22:30 +02:00
Mao NakamotoandCursor 215a4fe3ea fix(projects): merge duplicate entities and simplify fleet overview
Resolve case-insensitive duplicate project rows in Postgres, prevent
recurrence in entity creation, and redesign the Projects page hierarchy
(search-first, compact list, attention cards, activity redaction).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-27 12:13:43 +02:00
GandClaude Opus 4.8 4fcccef200 feat(autopilot): definition-of-done stop-gate — don't stop on the agent's own say-so (#43)
The /goal pattern. closeRunFromSession closes a run the moment the agent writes
status: ready — the agent grading its own homework (Ralph Wiggum). When a project
declares a definition_of_done (now a first-class profile field, injected into
every dispatch), the close is gated by a DIFFERENT-lineage model:

- dod-gate.ts: verifyDefinitionOfDone(dod, handoff) — gpt-oss-120b (not the
  worker's lineage) reads the handoff against the stated bar, returns {met, gap}.
  Fail-OPEN (a judge error lets the run close rather than wedge the loop).
- applyDoDGate (pure, unit-tested): a SUCCESS close with an unmet bar is
  downgraded to "partial" with the gap written into `next`, so autopilot's
  existing continue-loop keeps working instead of stopping. Only gates success;
  error/partial are untouched.
- Wired at the control close seam, fire-and-forget + an in-flight guard so the
  judge fires at most once per run and never blocks the control response.

This makes "done" an objective, cross-model-verified condition per project —
the lever the loop-engineering literature calls the real one. scripts/test/
dod-gate.ts (7 cases) added to the pre-push suite. tsc=0, eslint=0.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 11:57:30 +02:00
GandClaude Opus 4.8 c0372977bd fix(ux): audit quick-wins + always-surface capacity banner (#31)
* fix(ux): quick-win batch from the action audit

Four honest/routing fixes surfaced by the full UX audit:
- proxy.ts: /privacy /terms /license /docs/quickstart were auth-gated (missing
  from the public matcher) — logged-out footer clicks bounced to sign-in. Now public.
- projects/[id] GET: the response omitted gitUrl, so the project detail DRAWER
  showed no repo link for GitHub-imported projects (the grid card worked). Added.
- DesktopDownload: macOS + Windows were marked status:'ready' but ship no asset
  (Linux-only) → the auto-detected Download CTA 404'd. Flipped to 'comingSoon'
  and added the ComingSoonPanel branch (watch-releases + use-web CTA) the config
  comment always promised but was never implemented.
- changelog.ts: added the real v0.8.9 entry (was stale at 0.8.8 vs the live
  release) so the footer version pill + /releases are current.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* fix(control): always surface the capacity banner when autopilot can't act

Chasing the auto-reroute banner gate (after the SSE/GET session fix made the
data correct) revealed a UX gap: shouldShowManualCapacityBanner returned false
under autopilot for 'tab-closed' — so a project that hit a rate-limit wall but
isn't running showed NO indicator and NO call to action. A capacity wall must
never be silently invisible.

Now surfaces the manual banner under autopilot whenever autopilot CANNOT act on
its own (all-tried / no-fallback / tab-closed). For a not-running project,
clicking Switch still persists the agent preference for the next launch. When
autopilot CAN act, the auto banner shows instead. Test asserts the tab-closed case.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 22:45:42 +02:00
GandClaude Opus 4.8 cd7eec4708 fix(control): one session resolver shared by GET route and SSE stream (#30)
Closes the SSE/GET divergence found while dogfooding auto-reroute. On the local
runtime the GET /api/control fell back to the persisted project_states row
(parseSession ?? dbState), but the SSE stream's local path (readFastState) was
file-only with no DB fallback. So a project whose session .md was absent but
whose project_states row persisted showed its session via GET yet null via the
live (SSE-driven) page — which hid the auto-reroute capacity banner.

src/lib/project-session.ts is the SSOT:
- dbRowToSession(r): the one project_states -> SessionState projection (was
  duplicated inline in the GET route and the stream's dbToFastState).
- resolveProjectSession(fileSession, dbRow) = fileSession ?? dbRowToSession(dbRow).

Used by all three sites: the GET fallback, the stream's dbToFastState (cloud),
and the stream's local scanProjects (which now fetches project_states and fills
null sessions — the fallback it was missing). The two paths can no longer drift.

Contract test (test:project-session, wired into pre-push): file-present wins,
file-absent-DB-present surfaces the row, neither -> null, GET/SSE identical.

Implements milestone 1 of the 'Single derived-state read-model' roadmap goal.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 21:42:40 +02:00
GandClaude Opus 4.8 2e407f34a6 feat(control): headless auto-reroute agents off capacity walls under autopilot (#27)
* feat(control): auto-reroute agents on capacity walls under autopilot

Closes the loop from 'we can resolve a fallback' to 'we reroute live.' When
a project hits a rate-limit/quota wall (detectCapacityIssueFromProject) and
autopilot is on, FleetCrown now switches to the next installed fallback agent
itself via the existing switch-agent path — no human click. With autopilot
off, the manual CapacityIssueBanner is unchanged.

- src/lib/auto-reroute.ts: pure, tested decision (decideAutoReroute +
  shouldShowManualCapacityBanner). Loop-safe: AGENT_FALLBACK_ORDER cycles, so
  a per-episode tried-set stops an all-exhausted fleet from churning and
  surfaces a manual banner instead.
- ProjectCard: act once per distinct session state (mtime + outgoing agent)
  so a switch landing (which lags the poll) can't re-fire or flash a false
  'exhausted'; autopilot-gated; reuses performAgentSwitch.
- CapacityIssueBanner: 'auto' (switching…) and 'exhausted' variants.
- scripts/test/auto-reroute.ts (npm run test:auto-reroute): 12 cases incl.
  loop safety + skip-gate priority.

First increment (client/control surface). Follow-up: same decision server-side
in the beacon path for headless reroute when no browser is open.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* feat(beacon): headless auto-reroute on capacity walls (no browser needed)

Increment 2: the /control auto-reroute only fires while the page is open.
The beacon path runs server-side when an agent's session ends, so it reroutes
unattended — the real fleet-operation win. The beacon already detected the
capacity issue + computed the fallback (resolveNextAvailableAgent) and only
stored it; now it acts.

- src/lib/auto-reroute.ts: decideHeadlessReroute + MAX_AUTO_REROUTES_PER_WINDOW.
  Loop safety without a client ref = DB guard: cap auto-switches per project
  per 15-min window (one full fallback cycle, then stop) + skip while a switch
  is still unclaimed.
- db/queries/pending-commands.ts: recentSwitchAgentStats(userId, tab) →
  {windowCount, pending}, windowed so a dead unclaimed command can't block.
- api/beacon/route.ts: on capacityIssue, resolve effective autopilot
  (per-project override ?? global) + dir/tab, then enqueue switch_agent.
  Best-effort — never blocks or fails beacon creation.
- 7 new headless test cases (19 total).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 07:08:22 +02:00
G 0c07610a47 fix(brand): add the scripts/_brand.sh SSOT lever that brand.ts already promised (#26)
brand.ts documents scripts/_brand.sh as the shell-side mirror of APP_NAME /
APP_SLUG / APP_DOMAIN — the rebrand lever for shell consumers — but the file
never existed. Shell scripts had no SSOT to read from, so a future rename had
no lever on the shell side despite the docs claiming one (Ground Truth #2).

- Create scripts/_brand.sh: the four canonical values + derived URLs, sourcing
  guard, and a note on why APP_SLUG (infra id: DB, systemd unit, paths) stays
  stable on a display rebrand.
- Wire its one genuine consumer — scripts/hetzner/verify.sh now sources it for
  the FleetCrown health check + bridge domain (other products keep their own
  identifiers). Not a mass rewrite; slug-tied infra is intentionally untouched.
- Add scripts/test/brand-sync.ts (test:brand-sync) enforcing that the shell
  mirror never drifts from brand.ts, wired into the pre-push hook. Turns "keep
  in sync" from a comment into a guarantee.

tsc clean, eslint clean, 6/6 brand-sync assertions, drift case verified to fail.
2026-06-23 05:17:49 +02:00
GandClaude Opus 4.8 0780f4d99c fix(activity): strip harness scaffolding from prompt display titles (#10)
Dispatches can capture the fully-assembled prompt — context tiers plus harness
envelopes — so activity feeds rendered noise like "<task-notification><task-id>…"
as the title of every run. promptDisplayBody now runs a pure sanitizer that drops
<task-notification>/<system-reminder>/<command-*> blocks and stray harness tags,
falling through to the next source (resolved prompt → intent label) when a value
is all scaffolding. It only rewrites when a harness tag is actually present, so
clean prompts — and their whitespace — pass through verbatim. Fixes the titles on
both the /control Activity panel and the project-profile feed (PR #7).

Pure function, covered by 3 new prompt-history test cases (now 7/7).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 11:30:34 +02:00
GandClaude Opus 4.8 ec3cab4f9d refactor(orchestration): build run summary from the SSOT field array (#5)
* feat(control): capture per-run commit SHA — truthful "did it ship?" state

Run outcomes recorded status/done/tests/health but never the commit a run
produced, so a self-reported "done" with no git trace looked identical to one
that actually landed code. Add `commit` to the orchestration summary contract
(SSOT), parse it from both the on-disk handoff and the finish API, and ask the
agent to emit `git rev-parse --short HEAD` in its handoff. The Previous-run
panel now shows the SHA, and flags a finished+done run that recorded no commit
with a "no commit" warning chip — surfacing the untruthful-state failure mode
the control loop must catch instead of trust.

Summary is JSONB, so no schema migration. block-reason/no-op-count remain
dropped by the two hand-written summary literals (separate follow-up).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* refactor(orchestration): build run summary from the SSOT field array

parseOrchestrationSummary and the /finish route each hand-wrote the summary
object, so block-reason and no-op-count — both in ORCHESTRATION_TASK_SUMMARY_FIELDS
— were silently dropped when a summary was persisted via the finish API (they
survived only on the session.md path, which builds generically). A self-throttled
agent reporting block-reason: awaiting_user would have that loop-control signal
thrown away on the cloud dispatch path.

Add buildOrchestrationSummary(fields) — Object.fromEntries over the SSOT array —
and use it in both places. Adding a field to the contract array now persists it
everywhere; no literal can drop one again. New test covers the previously-lost
fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 10:36:34 +02:00
GandClaude Opus 4.8 05c57b3208 feat(control): capture per-run commit SHA — truthful "did it ship?" state (#4)
Run outcomes recorded status/done/tests/health but never the commit a run
produced, so a self-reported "done" with no git trace looked identical to one
that actually landed code. Add `commit` to the orchestration summary contract
(SSOT), parse it from both the on-disk handoff and the finish API, and ask the
agent to emit `git rev-parse --short HEAD` in its handoff. The Previous-run
panel now shows the SHA, and flags a finished+done run that recorded no commit
with a "no commit" warning chip — surfacing the untruthful-state failure mode
the control loop must catch instead of trust.

Summary is JSONB, so no schema migration. block-reason/no-op-count remain
dropped by the two hand-written summary literals (separate follow-up).

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-19 10:14:02 +02:00
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 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 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 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 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 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 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 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 ea86905967 feat(control): per-project autopilot and digests 2026-06-09 18:09:09 +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 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 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 Nakamoto 797fa998e7 fix(control): repair local project sync and desktop command draining 2026-06-08 09:09:21 +02:00
Mao Nakamoto b73bb9a8d4 feat(desktop+web): v0.7.2 — peek tab contents from /control
The hardest UX gap in /control was: you saw your tab NAMES + state chips
('Working', 'Awaiting input') but never the actual screen content. To know
what the agent was saying you had to alt-tab into Zellij and find the
right tab. Web-shell users saw even less.

v0.7.2 closes that. Per-tab eye-icon button on /control workspaces table
opens a drawer that captures the live screen of that Zellij tab and renders
it as a static terminal frame (monospace, dark background, scrollable).
Auto-refresh toggle re-peeks every 3s for watching long-running agents
without permanently leaving the user on the peeked tab.

Mechanism (sub-200ms round-trip):
  1. ZellijLiveRows eye-button → setPeekTab(name)
  2. PeekTabDrawer mounts → window.fleetRunner.peekTab(name)
  3. preload → IPC peek-tab → main process
  4. src/lib/zellij.peekTab: save focus, go-to-tab-name, dump-screen to
     /tmp file, restore focus, read+strip ANSI, unlink temp
  5. Returns content → drawer renders in <pre>

Same focus-dance pattern as injectIntoTab (already in zellij.ts) — users
have accepted that disruption budget for remote dispatch, this reuses it.

Outside Fleet Runner the button is hidden (one-tick mount probe of
window.fleetRunner.peekTab). No degraded "button that always errors"
experience for browser users.

Also in this drop:
  - desktop bump 0.7.1 → 0.7.2 (auto-update will pull this on next launch)
  - control-presenter test: "cockpit" string was a leftover from the rename,
    failed CI on the v0.7.1 push; now compares to 'FleetCrown' as intended
  - ZellijLivePanel daemon-offline CTA now points to /releases/latest
    instead of the hardcoded fleet-runner-v0.7.0 tag (was pointing users
    at the broken bundled-renderer build)

Next: v0.7.3 cloud-fallback (browser-only users get peek via the command
queue → daemon → result table → SSE), v0.8 inline terminal column.
2026-06-06 14:54:46 +02:00
Mao NakamotoandClaude Opus 4.7 209299c08f feat(onboarding): auto-onboard first-time users with a derivable username
Drops the "isReturning" gate in decideHealPatch so the heal fires on
first sign-in too. When a user signs in with OAuth (GitHub / Google /
Twitter) and we can derive a unique username from their display name
or email local-part, we set it + onboardedAt right there in the JWT
callback. They land authenticated with onboardingComplete=true and
middleware sends them straight to /control instead of via /onboarding.

User-visible effect: GitHub OAuth → /control in ONE page load instead
of two. The /control empty state's GitHubRepoSuggestions / LocalDev-
Suggestions / FleetRunnerAutoMint then take over from there.

Fallback (still works): users whose suggested username collides with
an existing one, or whose display name + email can't yield ≥2 chars
of [a-z0-9-], get null patch → middleware sends them to /onboarding
to pick manually. The page is no longer a forced gate — just a
fallback for the edge cases.

Side benefit: also skips the wasted "onboardedAt-only" write that
the old logic would do for returning users without a valid username,
since onboardedAt without a valid username is a no-op
(isOnboardingComplete still gates on both).

The /settings → Profile editor lets users change the auto-picked
username later, so we're not stealing their choice — just defaulting it.

Tests: 7/7 pass (npm run test:onboarding-heal). Updated existing
brand-new-user assertion to reflect the new policy and added a
collision-fallback test case.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-05 12:33:02 +02:00
Georgy Butaev e30c842869 feat(desktop) + fix(design,lint): project selection + auto-sync + Sync to Web (ck_* token); canonical injectIntoTab + real appendEvent bridge.dispatch/worker.started in Fleet Runner runtime (replaces fake in-memory); hardened zellij.ts (session resolution + -- write-chars); ui-public-download-* + --public-accent (zero design violations); full cockpit->fleetcrown rebrand in desktop/scripts/docs/thoughts/marketing/home; update desktop README + docs/desktop-app.md with capabilities + gaps (in-memory vs real log)
- desktop build clean, tsc clean, lint 0, home/ 89/89
- advances desktop-2/3: dispatches now produce durable events in ~/.fleetcrown/events.jsonl with proper runId/sentinel so stop-hooks and web control plane treat them as first-class
- still no embedded watcher (idle via co-running home/watcher.ts for now)

Refs: desktop-app.md phases, Cockpit.roadmap T1/T2, prior landing 2d98638
2026-06-02 14:54:51 +02:00
Georgy Butaev b08ac4da14 feat(desktop): project selection + auto-sync on connect + Sync to Web (agent token to /runtime-state); switch to canonical injectIntoTab; ui-public-download-* classes (zero design violations); forward custom prompts as queueHead; clean lint; broad docs/marketing/scripts updates for FleetCrown desktop runtime 2026-06-02 12:17:12 +02:00
g-butandClaude Opus 4.7 ddbfa8878d feat(autopilot): five-level trust ladder + restore Beacon popup wire
User clarified the actual product vision: autopilot is a TRUST LADDER,
not a config screen. Five levels, each adding one more thing Cockpit
decides on your behalf. The middle level (Beacon — popup + countdown
auto-pick) was orphaned by commit 848da6c "stop hook calls strategist
(no more popup race)" — that swap traded the popup race for a
loose-cannon strategist that fired AI-composed prompts without consent.
Bringing the popup back, without the old race (KDE D-Bus + Chrome
+ /tmp polling), since the SSE-driven Chromium window already
replaced the old multi-layer setup.

The five-level ladder, marketing-clear:

  L1  Manual       — only what you type    (Free tier)
  L2  Queue        — drains your queue     (Free tier)
  L3  Beacon       — popup + countdown     (Pro $20/mo) ← new default
  L4  Continuous   — auto-fires next-best  (Pro $20/mo)
  L5  Mission      — Groq composes from
                     mission/goals/roadmap (Mission $50/mo)

Concrete changes this commit:

- src/config/beacon.ts: AUTO_INJECT_MODE_VALUES gains "beacon" (the
  popup level). All five values have user-facing labels Manual / Queue
  / Beacon / Continuous / Mission with description lines that name the
  level number and the sales-grade one-line pitch.

- src/lib/constants/control.ts: DEFAULT_AUTO_INJECT_MODE flips from
  "strategist" (L5) to "beacon" (L3). New users start at the right
  trust level — Cockpit shows them every dispatch through a popup
  with countdown auto-pick, so they earn confidence in the system
  before opting into Continuous or Mission.

- scripts/agent-hook-bridge.sh:
  • autopilot_dispatch_and_inject() gains a new branch for
    mode="beacon": calls ./beacon.py stop $tab $session_file, captures
    the user's choice (or countdown auto-pick) on stdout, then
    dispatches via emit_or_inject_prompt with the chosen prompt key.
    Custom prompts come back as "__custom__<body>".
  • Bash defaults for _BEACON_AUTO_MODE change from "strategist" →
    "beacon" in both the API-fetch path and the Python-config
    fallback path, so a fresh install with no settings row lands at
    L3, not L5.

- src/components/control/AutomationPolicyControl.tsx: MODE_STYLE record
  gains the "beacon" case (cyan-dot, pulsing). Tooltips for all five
  cases rewritten with the level number + the one-line pitch so
  hovering the pill teaches the trust ladder.

- src/components/control/ControlFleetStatus.tsx: AUTOMATION_HINT
  record gains the "beacon" case. Hints under the fleet chips now
  describe the level in plain English (was: jargon like "strategist
  composes context-aware prompts" → now: "Mission — Cockpit composes
  context-aware prompts from project mission, goals, and history").

Note: the existing "strategist" code value is preserved as the L5
storage key. Mission as a customer-grade feature still needs the
work tracked in roadmap "## Proposed": project context loader,
quality gate, audit trail, sleep budget, trust score. Today's commit
is just the ladder + the missing beacon wire.

beacon.py itself was already installed at
~/.local/share/cockpit-beacon/beacon.py (orphaned since 848da6c);
this commit puts it back in the call path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 15:05:38 +02:00
g-butandClaude Opus 4.7 8866ca5e51 fix(control): replace "Saved agent context" jargon with "Idle"
Browser dogfood 2026-05-31: user typed into the /control textarea
"Fix the 'Saved agent context Xw ago' wording — it sounds like a
security leak. Use 'Idle · last active Xw ago' instead." Caught
that the label was opaque jargon — it describes the INTERNAL
data state ("we have a saved handoff blob") rather than the
OBSERVABLE state for the human reader ("the agent is idle").

control-presenter.ts:563 — handoff-present-but-no-live-observation
case now reads "Idle" instead of "Saved agent context". The row's
timestamp column already shows recency (Xw ago) so the prefix
doesn't need to duplicate it.

Test updated to match the new wording. 19/19 stays green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 13:53:03 +02:00
g-butandClaude Opus 4.7 60732f9ac4 fix(control): kill three info-leaks in the /control project rows
User audit 2026-05-31 surfaced three loud noise sources in the
project rows that were diluting every other signal on the page:

1. Saved-handoff dumps leaking into row activity text. Lines like
   "Saved handoff: Wait for user to (a) resolve the OAuth blocker
   by signing in with a fresh GitHub account..." were the agent's
   own internal notes being pasted verbatim into the user-facing
   table. getTabActivityText() now returns short lifecycle states
   only — "Ready — pick the next task", "Agent open · idle",
   "Closed", "Tab open · no agent process". Handoff content
   belongs in a per-project expand/tooltip, not the always-visible
   row.

2. "Last sync 6h ago" prefix repeated on every one of 21 project
   rows when the daemon was offline globally. staleEvidenceLabel()
   dropped the prefix in the common case — the global offline
   banner already owns the "system is stale" signal; rows should
   just describe last-known state. Preserve the prefix ONLY when
   there's no other evidence to show (rare).

3. "Tab #1 Unlinked" dangling scratch tabs surfacing in the
   workspace table. buildLiveTabRows now filters tabs that map to
   no registered project — they're visible noise that the user's
   actual zellij window already shows. The control surface is for
   fleet ops, not a generic tab list. Test updated to assert the
   filter behavior (Mystery tab dropped, registered tabs kept).

All three were silent UX papercuts that the SSOT and gate work
couldn't surface — the user had to point at the screenshot.
control-presenter tests stayed 19/19 after the test rewrite.

Items 2, 3, 4 of the 7-item Elon-team-pass plan. Items 5 (hierarchy)
+ 6 (header/rail vocab reconciliation) coming next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 13:25:34 +02:00
g-butandClaude Opus 4.7 b89fdfc9d2 fix(dispatch): gate autopilot on status:working + pending blockers
Live-incident regression. Earlier today the autopilot injected a
2000-char next_best template into the user's keystrokes mid-typing
while they were composing a message to the agent, producing garbled
text like "wtf ust happened? what is this injecSetup (run, read
outputs):...". The session handoff said status:working — which is
documented in three places as the suppression signal — but the
daemon fired anyway because nothing in the dispatch pipeline
actually read the status field.

Root cause: agent-hook-bridge.sh:autopilot_dispatch_and_inject()
extracted done/next/tests/todos/health from the session file but
not status. The dispatch route's HandoffSchema didn't include
status either. The user trusted a guarantee the code never made.

Three coordinated fixes:

1. agent-hook-bridge.sh now reads `status:` from the session file
   AND counts files in ~/.claude/sessions/<P>.blockers/pending/.
   Either condition (status:working OR blockerCount>0) causes the
   daemon to skip the dispatch HTTP call entirely — saves a network
   round-trip and surfaces the gate in daemon logs.

2. The dispatch route's HandoffSchema gains a `status` field and
   the body gains `blockerCount`. Defence-in-depth: even if a
   custom integration or cloud-only caller bypasses the daemon's
   client-side gate, the route refuses to act on a working status
   or pending blockers. Two new DispatchResult.source values
   (status_gate, blocker_gate) make these refusals greppable in
   logs.

3. The gate logic moves out of the route handler into a pure
   helper at src/lib/orchestration/dispatch-gates.ts so the
   invariants can be unit-tested without spinning up a real Next
   request. 11 inline tests cover: status:working wins over every
   mode; blockers beat happy-path; legacy empty status preserves
   existing permissive behavior; etc. Wired into
   `npm run test:dispatch-gates`.

Closes the highest-impact symptom of the strategist's broken trust
model. The user can now leave autopilot on and trust that their
status:working handoff actually stops it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-31 06:45:24 +02:00
g-butandCursor 92757c655b fix(push): return 503 on bad VAPID keys instead of silent 500
Malformed Vercel VAPID keys caused setVapidDetails to throw; wrap configure
and notify in try/catch. Use STALE_CLAIM_SECONDS in reclaim SQL.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:27:41 +02:00
g-butandCursor 60f0cff749 feat(push): web push subscriptions and stop-hook notifications
Adds VAPID-backed subscribe/notify API, service worker, top-bar pill,
and Stop hook push_notify_stop for ambient agent-done signals on mobile.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-30 21:05:35 +02:00