feat(cli): relay init downloads the standalone Relaycast engine

Merged
KH
16d ago
+474-20

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.report glibc check), windows-x64.exe.
  • Fetches the .sha256 first, so a missing asset fails fast, then the binary. Timeouts are bounded at 60s and 300s. It verifies with node:crypto, writes a 0755 temp file in the same dir, and atomically renames it to relaycast-engine[.exe].
  • Prints one progress line. Skips the download when the installed binary's --version is 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, engineVersion and enginePlatform on InitCommandDependencies. 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 before startEngine, 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/cli is 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 alice and bob
  • sent a DM from alice to bob
  • relay message inbox check --as bob showed 1 unread from alice
  • relay init --stop brought /health down
  • a restart did not download again

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.


Agent Relay sessions

  • claude session ad853590 · opened via gh pr create · last active 2026-10-27
  • claude session 5a4f854b · contributor · ran gh pr commands · last active 2026-10-27