fix(cli): run mounted product surfaces in a child process when standalone
Fixes #1795. Replaces #1796, whose bundling approach a review correctly rejected.
All three groups now work in the compiled standalone binary:
file: mounted, and `file integration available` reached the product (Go binary)
flows: mounted, and `flows check` reached the product (flows SDK)
sessions: mounted, and `sessions stats` reached the product (native addon)
PROBE: all groups mounted
Verified against a real compiled binary, isolated HOME, no node_modules reachable, running real commands — not --help.
Why not bundle
#1796 bundled the SDKs with esbuild. It cannot work, for structural reasons:
@relayfile/sdk/relay-clilocates and spawns a Go binary; exec needs a real pathai-histdlopens a native addon through a variable specifier — invisible to any bundler, in a package this repo does not own- all three surfaces read files relative to
import.meta.url, which relocates once bundled
Observed in a compiled binary: ENOENT … open '/$bunfs/root/command-spec.json'.
Why not resolve in-process either
The next attempt provisioned a real package tree and imported from it. That got two of three groups working — but only by accident of their dependency graphs. Inside a compiled Bun binary, a module loaded by absolute path cannot resolve bare specifiers from the tree beside it:
- neither a bare dynamic import nor
import.meta.resolvefinds a scoped package with anexportssubpath, though both work under Node - an unscoped package without
exportsresolves fine, which is what makes this easy to miss - resolving the entry point by hand fixes exactly one level; the level below fails identically:
Cannot find package 'yaml' imported from …/@relayflows/sdk/dist/cli-watch.js
NODE_PATH does not change it (tested).
What this does
Runs the surface under the node that installed it. A provisioned tree exists only if npm ran, and npm implies node, so the interpreter is always present. Module resolution stops being the CLI's problem. Cost: one process per invocation.
The runner has two modes, because help must keep saying agent-relay rather than the product's own name:
describe— returns the declared command tree as JSON; the host renders help itselfrun— streams the surface's output back
Chunks stay bytes, so export --format tar survives the boundary, and stdin is inherited so interactive prompts still work. This is the shape relayfile's own surface already uses for its Go binary.
The probe is the deliverable
scripts/standalone-mount-probe.sh runs the compiled binary in /tmp with an isolated HOME, so no ancestor node_modules can satisfy an import by accident, and exercises a real command per group. Validated both directions before being relied on:
working npm install → all groups mounted exit 0
broken binary → mount is broken exit 1
Building those controls surfaced two defects in the probe itself: declare -a GROUPS=(...) never took effect (bash keeps a special GROUPS array of the caller's group IDs, so the loop iterated 1000 and 998), and the "implementation missing" test matched any cannot find module, flagging a structured REFUSED that named the probe's own throwaway flow file.
Also here
- Dependency floors raised —
^0.10.63and^0.18.0admitted versions with norelay-clisubpath at all. Now^0.10.64/^2.0.19/^0.18.1, each checked against the registry. workflows/fix-standalone-mount.flow.ts— the flow that drove this. It proved the bug against a compiled binary before changing anything, and its final gate refused after the implementation looked complete (typecheck green, tests green). That refusal is why the in-process limit was found rather than shipped.
48 tests pass; tsc --noEmit clean.
Known limitation
First use of a group installs its SDK (seconds, cached by version). The npm distribution is untouched: when the specifier resolves normally, none of this runs.
🤖 Generated with Claude Code
[!NOTE]
Medium Risk
Changes standalone CLI startup and first-use behavior (network/npm provisioning, child processes, cached installs under the user data dir) and bumps several product SDK pins, though npm installs are unchanged when imports already resolve.
Overview
Fixes #1795: the compiled standalone agent-relay binary can mount file, flows, and sessions instead of failing with misleading “not installed” errors.
On first use in the standalone build, pinned SDKs are npm install’d under ~/.agentworkforce/relay/surfaces (with @relayhistory/cloud-client for sessions). Surfaces are loaded via a generated run-surface.mjs child Node process (describe for help trees, run for commands), because the Bun-compiled host cannot resolve bare imports from the provisioned tree. importProductSurface keeps the normal npm path as a direct import(); provisioning runs only when standalone and the specifier is truly missing.
Dependency floors move to @relayfile/sdk ^0.10.64, @relayflows/sdk ^2.0.19, and ai-hist ^0.18.1 (monorepo 12.2.5). Load failures now distinguish incomplete installs, missing transitive deps, and provisioning errors (including Windows/UNC paths).
Regression coverage adds standalone smoke checks for all three groups, scripts/standalone-mount-probe.sh (compiled binary, isolated HOME, real commands—not just --help**), and RelayFlow case **1795-standalone-mount`**.
Reviewed by Cursor Bugbot for commit 1e3d570b222d9714e8fcfb842473e6b6650fca32. Bugbot is set up for automated code reviews on this repo. Configure here.
- Change type:
bugfix - RelayFlow case:
1795-standalone-mount