Repository navigation
Let the machine installer adopt an enrolled data directory - #4173
Merged
Merged
Conversation
`install-machine.sh --adopt --data-dir <dir>` installs the persistent, self-updating host daemon service for a data directory that is already enrolled, such as the one a server move leaves on the old server's computer. It reads the machine ID from auth.json and the server address and credential headers from config.json instead of a bootstrap bundle, skips enrollment, and otherwise runs the normal install: server-matched package in <dir>/npm, launchd/systemd service with --auto-update, and a wait for the daemon to connect. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood
marked this pull request as ready for review
September 23, 2026 17:37
SawyerHood
added a commit
that referenced
this pull request
Sep 23, 2026
## Human comments ## What was wrong After a server moves off `bb-app` or the desktop app, there was no supported way to turn the old computer into a persistent, self-updating machine while keeping its identity and threads. The only way to get an auto-updating daemon was to enroll a new machine, and threads can't move or fork onto a different machine. Stacked on #4173, which adds `install-machine.sh --adopt`. ## What changed - **New command** `bb server install-machine-service [--data-dir <dir>] [--yes] [--json]` (`apps/cli/src/commands/server-machine-service.ts`): - requires the `server-moved.json` lock, `auth.json`, a server address in `config.json`, and Node.js 22.19+ on the PATH - asks for confirmation unless `--yes` - stops the bb recorded in `bb-app-runtime.json`, using the same verified stop as `bb-app stop` - runs `install-machine.sh --adopt --data-dir <dir>` - `--json` prints `dataDir`, `serverUrl`, `toHostName` and `serviceFile` - the Node check runs before anything stops, so an old Node leaves bb running - **Installer location:** the bb-app launcher passes the installer path (`server/dist/assets/install-machine.sh`) to the CLI as `BB_MACHINE_INSTALLER`, the same way it already passes `BB_APP_VERSION`. The CLI ships its own installer rather than downloading the server's, so people already stuck on an older server can still adopt. - **`@bb/config/machine-service`:** `findMachineServiceFile` finds the launchd plist or systemd unit whose `BB_DATA_DIR` matches a data directory, comparing canonical paths and undoing the installer's escaping. - **`bb server unlock`** refuses while such a service exists, because unlocking would start a second daemon on the same data. The error gives the command that removes the service. - **Docs:** the machines guide template, the bb-cli skill and its command index and thread-creation reference, `docs/api_to_audit.md`, `docs/server-move-plan.md`, and `docs/cli-guide-and-skill.md`. No server/daemon wire change. ## How you verified - `apps/cli/src/__tests__/command-output/server-machine-service.test.ts`, run with a fake installer against a real live process: - stops the recorded bb (it exits with SIGTERM) and passes `--adopt --data-dir` - refuses a directory that no server moved away from - leaves bb running when `node` on PATH is 20.18.1 - reports an installer failure - `unlock` refuses while the service exists - `packages/config/test/machine-service.test.ts`: launchd and systemd matching, symlinked data directories, escaping, and no match. - `packages/bb-app/test/index.test.ts`: the CLI receives `BB_MACHINE_INSTALLER`. - `pnpm exec turbo run test --filter=@bb/cli --filter=@bb/templates`: 841 + 47 passed. - `pnpm exec turbo run test --filter=@bb/config --filter=bb-app`: passed. - Typecheck passes for `@bb/cli`, `@bb/config` and `bb-app`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
When a bb server moves off the desktop app (or
npx bb-app), the old computer stays a machine only through that app's own bb-app process. That daemon runs only while the app is open, and because it ships inside the app it never updates itself. Every release changesHOST_DAEMON_PROTOCOL_VERSION(203 → 207 → 215 → 216 across 0.43.0–0.43.4), so the first server update after the move rejects the old computer's daemon, and threads on that machine stop working. Machines installed from the command line don't have this problem:install-machine.shgives them a launchd/systemd service with--auto-update. But the installer only works from an enrollment bundle, which creates a new machine, so it can't take over the old computer's existing machine and its threads.This PR is the first layer of a stack; it has no prerequisite.
What changed
apps/server/src/assets/install-machine.shaccepts--adopt --data-dir <dir>. It reads the machine ID from<dir>/auth.json, and the server address plus credential headers (serverHeaders, or a legacymachineCredential) from<dir>/config.json. It skipsbb machine enroll, then runs the normal install:<dir>/npm--auto-updatenodethrough an environment variable rather than argv, the same way the bootstrap bundle does.--adoptrefuses to combine with--bootstrap-envor with lifecycle actions, and it requires--data-dir.No server/daemon wire change.
How you verified
apps/server/test/app/install-machine-script.test.ts:machineCredentialis used as the headerauth.jsonfails before npm runscurlnow records its--configheaders.pnpm exec turbo run test --filter=@bb/server -- test/app/install-machine-script.test.ts src/services/machines/bootstrap.test.ts: 48 passed.@bb/serversuite on the top of the stack: 3085 passed.🤖 Generated with Claude Code