- 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
After f3a08fd a new customer's daemon supports all three agents, but it
still dies on shell exit — the install incantation says "start the
daemon: ~/.local/share/cockpit/cockpit-daemon.sh" which is a foreground
process. The `--install` flag was supposed to register a systemd user
service via install-daemon.sh, but that file wasn't in the bundle and
the agent CLI only looked in process.cwd()/scripts/.
Three-file change:
• route.ts FILES + next.config.ts outputFileTracingIncludes add
install-daemon.sh (now 12 files in the bundle).
• cockpit-agent.js --install handler now prefers ${DAEMON_DIR}/
install-daemon.sh, falling back to process.cwd()/scripts/install-
daemon.sh for developers running from inside the repo.
install-daemon.sh's existing structure works in the flat ~/.local/share/
cockpit/ layout without modification: WorkingDirectory + ExecStart use
$SCRIPT_DIR (= the daemon dir, all 12 files siblings), and the token
arrives via env from the CLI's spawn — bypassing the PROJECT_DIR/
.env.local fallback that would have been wrong for non-clone users.
After this, `curl … | node - init --token ck_… --install` enrolls the
daemon as a systemd user service in one shot — survives shell exit,
reboot, and restarts on failure.
The documented install path is curl … | node - init, but node consumes
process.stdin to receive the script body, leaving stdin at EOF by the
time the script runs. If the user omits --token, the prompt() call
printed "Paste your ck_* agent token:" and silently terminated — the
readline closed immediately on EOF, the answer was empty, the next
check exited the process with no useful error to the user. Verified
the silent failure locally before fixing.
Two changes:
1. prompt() now opens /dev/tty directly when process.stdin isn't a
TTY, so the user can still type a token even when the script body
came in through a pipe. Standard installer pattern (rustup, brew,
nvm). Falls back to process.stdin where /dev/tty doesn't exist
(Windows) — in that case --token is the only path forward.
2. Before prompting, check that we have *some* TTY (stdin or stdout).
If neither is a TTY (CI, sandboxes, daemons), exit 2 with the
clean message "Non-interactive environment: pass --token ck_… as
an argument." instead of hanging on an unread prompt.
Verified:
• cat agent.js | node - init (no token, no TTY) → exits 2, clear msg
• cat agent.js | node - init --token ck_invalid → 401 as before
• Tsc/eslint clean.
After 02c2551 (init now installs daemon scripts to ~/.local/share/cockpit/)
and fcc56f1 (route verified live), three customer-facing lines in the
agent CLI were still wrong:
• `init` command description didn't mention daemon install — said only
"Save daemon token and verify connectivity"
• "After init, start the daemon: source ${ENV_FILE} && cockpit-daemon.sh"
assumes cockpit-daemon.sh is on PATH (it isn't); correct path is
${DAEMON_DIR}/cockpit-daemon.sh
• Both the help Examples and the soft-fail retry hint referenced
`npx @cockpit/agent init` — a command that does not work because the
package isn't on npm; new customers can only get here via curl|node
Rewrites the help to:
- Describe what init actually does
- Document the install/upgrade incantation (curl|node -)
- Show the correct daemon start path
- Keep --install in the option list but note it's repo-clone-only for
now (the only path that still works there; ship a proper
~/.local/share/cockpit/install-daemon.sh in a follow-up)
Soft-fail retry hint now prints the same curl|node command with the
token already filled in, so the user can paste and retry without
having to remember the form.
Closes the second half of the connect-step gap. Last week's 422873a
made `curl|node - init --token X` reachable for new customers (the
agent CLI was served via /api/agent/install). 15727a7 added an
honesty disclaimer that the daemon scripts still required a Cockpit
repo clone. This commit removes the disclaimer by shipping the
scripts the same way.
• New /api/agent/daemon route spawns `tar -czf - -C scripts/ …`
with the 4 daemon files (~1500 lines bash: cockpit-daemon.sh,
_brand.sh, agent-hook-lib.sh, agent-hook-bridge.sh) and returns
the gzipped tarball (~20 KB).
• next.config.ts outputFileTracingIncludes pins those 4 source
files to the route so Vercel ships them in the bundle (the route
reads them via spawn at runtime — they'd otherwise be tree-shaken).
• src/proxy.ts matcher exception adds api/agent/daemon so the
download works pre-auth.
• packages/agent/bin/cockpit-agent.js gets a new downloadDaemon()
step inside `init`: after writeEnvFile, fetch the tarball, pipe
into `tar -xz -C ~/.local/share/cockpit`, chmod +x the two
executables. Soft-fail with a warning if it errors — the token
write still lands and the user can retry by re-running init.
• ConnectMachineStep step 3 drops the "requires repo clone, public
installer coming soon" caveat in favor of the actual path
(~/.local/share/cockpit/cockpit-daemon.sh).
After this, a brand-new customer's path is:
1. Sign up + onboarding (username + project + connect)
2. Generate token → copy one curl command → paste into terminal
3. ONE command installs both the env file AND the daemon scripts
4. Run ~/.local/share/cockpit/cockpit-daemon.sh and they're live
No repo clone. No npm publish dependency. Customer-#2-ready.
Last commit (422873a) made step 2 of the connect flow work for new
customers, but step 3 — "Start the daemon: ./scripts/cockpit-daemon.sh"
— was still a lie: the agent CLI only writes a token env file, it does
not install the 783-line daemon script. New customers would copy that
path, get "No such file or directory", and assume they did something
wrong.
Update both surfaces (the onboarding UI's step 3 + the CLI's post-init
"Next steps" output) to acknowledge that the daemon currently requires
a Cockpit repo clone and flag a one-line public installer as coming
soon. The "Skip for now" button on the step already lets non-developer
customers complete onboarding and explore the cloud — the copy now
makes that the explicit, honest path.
Does not change behavior. The real fix (serve scripts/cockpit-daemon.sh
+ _brand.sh + agent-hook-lib.sh via /api/agent/daemon, with a bash
installer that drops them into ~/.local/share/cockpit) is queued — out
of scope for one commit (1500+ lines of bash, multi-file tracing).
Add @cockpit/agent init, server-side PIN enforcement for private APIs,
Postgres-backed cron jobs, daemon auto-continue sync, and cloud/local docs
so SaaS users get a clear path from browser signup to local dispatch.
Co-authored-by: Cursor <cursoragent@cursor.com>