feat(cli): relay init downloads the standalone Relaycast engine
Summary
relay init from an npm install fell back to npm install @relaycast/engine and ran it with Node. On Node 26 (no better-sqlite3 prebuild) or with npm ignore-scripts=true, the local server never started.
Now, before starting the local server, relay init makes sure the pinned standalone relaycast-engine (11.1.0) is in the canonical bin slot (getCanonicalRelaycastEnginePath() from @agent-relay/harness-driver/install-paths: AGENT_RELAY_INSTALL_DIR/bin → AGENT_RELAY_HOME/bin → ~/.agentworkforce/relay/bin, the slot install.sh and the broker use):
- Picks the release asset
relaycast-engine-<ver>-<os>-<arch>: darwin/linux x64+arm64,linux-musl-*on musl (ldd script →/lib/ld-musl-*→process.reportglibc check),windows-x64.exe. - Fetches the
.sha256first, so a missing asset fails fast, then the binary. Timeouts are bounded at 60s and 300s. It verifies withnode:crypto, writes a 0755 temp file in the same dir, and atomically renames it torelaycast-engine[.exe]. - Prints one progress line. Skips the download when the installed binary's
--versionis the pinned version or newer (same rule as install.sh). - On any failure (offline, 404, bad digest, checksum mismatch) it installs nothing. It then falls back to an existing binary if there is one, or else to the npm package, and logs the reason.
- New injectable deps
downloadEngine,engineVersionandenginePlatformonInitCommandDependencies. The default test setup is offline.
Tests
npx vitest run packages/cli/src/cli/commands/init.test.ts: 46 pass. The new tests cover success (installed with 0755 beforestartEngine, no temp left behind), checksum mismatch (not installed, npm fallback), 404 (npm fallback), already-installed pinned version (no download), an older binary kept when the download fails, and asset-name mapping for darwin, linux, musl and windows, plus unsupported platforms.tsc --noEmit -p packages/cliis clean.
End-to-end (Node 26.8.1, npm ignore-scripts=true, isolated AGENT_RELAY_HOME/AGENT_RELAY_INSTALL_DIR, port 8799)
relay init --yes --tools none --port 8799 downloaded relaycast-engine-11.1.0-linux-x64, verified and installed it, and started it as the server process. No engine/ npm prefix was created. Then:
- registered
aliceandbob - sent a DM from alice to bob
relay message inbox check --as bobshowed 1 unread from alicerelay init --stopbrought/healthdown- a restart did not download again
🤖 Generated with Claude Code
![View with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v3-3x.png)
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Need help on this PR? Tag @codesmith-bot with what you need.
Agent Relay sessions