Skip to content

Enroll a Windows machine with another bb server - #4735

Merged
SawyerHood merged 1 commit into
mainfrom
bb/windows-remote-machines-thr_jensq3v9th
Oct 2, 2026
Merged

SawyerHood merged 1 commit into
mainfrom
bb/windows-remote-machines-thr_jensq3v9th

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Adding a machine produced only curl … /install.sh | sh, and install-machine.sh stops on anything but macOS and Linux, so a Windows computer could not join another bb server. Two things would also have broken an enrolled Windows daemon: the host package the server builds for machines left out bb.cmd, so bb did not resolve in that machine's terminals and agent shells, and the daemon's protocol self-update ran npm by bare name, which Windows cannot start. Part of #1206.

What changed

  • Installer. New apps/server/src/assets/install-machine-windows.mjs, a Node script with no dependencies. It reads the same enrollment bundle as the shell installer, installs the server's host package into %USERPROFILE%\.bb-machines\<server-host>\npm (SHA-256 checked, conditional request on later runs, npm registry fallback on 404), verifies the native modules load, runs bb machine enroll, joins, and starts the supervised daemon. It registers the daemon in the user's Run registry key so it starts at sign-in, and --start, --stop, and --uninstall --host-id <id> manage it from the copy it leaves in the machine directory.
  • Starting the daemon. The daemon is created through WMI (Win32_Process.Create, hidden window) and not as a child of the installer. A child process would die with the installing SSH session, and would hold the installer's output pipe open so a captured install never returns.
  • Server. GET /install.ps1 returns a PowerShell script that writes the installer to a temp file and runs it with the bundle in an environment variable. An unusable enrollment returns a script that throws the reason with status 200, because irm | iex discards the body of an error response. manualEnrollmentPowerShellCommand builds irm -Headers @{…} '<server>/install.ps1' | iex.
  • Contract. The enrollment-command and reconnect responses gain windowsCommand. The plugin SDK surface check reports no change.
  • UI and CLI. The command box in Add machine and Reconnect has a "macOS or Linux" / "Windows" toggle; bb machine create --provider manual prints both commands.
  • Host package and self-update. The host package the server builds for machines lists win32 in its os field whatever bb-app itself lists, so npm accepts it on Windows; bb.cmd ships in it, and the protocol self-update runs npm through the portable launcher on Windows. The installer removes the retired package directories npm leaves behind when it replaces a running package.
  • Docs: bb guide machines, docs/multiple-devices.md.

The daemon runs in the signed-in user's session from the Run key, not as a Windows service, so it stops when the user signs out. Enrollment through bb connect also needs the gate to forward /install.ps1 (#4734).

How you verified

  • Windows 11 Enterprise VM (build 26300), against a bb server running on the same VM with direct machine access, on a branch combining this with the other open Windows changes:
    • bb machine create --provider manual, then the returned PowerShell command run with its output captured: the installer downloaded and installed the host package, enrolled, started the daemon, and exited 0; bb machine list showed the second machine connected, and it stayed connected after the installing SSH session ended.
    • A terminal created on the enrolled machine ran bb status and exited 0.
    • --stop left no daemon processes and the machine disconnected; --start reconnected it in 2 seconds; --uninstall removed the machine directory and the Run entry.
    • Self-update: with the server rebuilt one protocol version ahead and restarted, the enrolled daemon logged "Installed the server-matched bb host package; restarting the daemon", exited 75, was restarted by its supervisor, and reported the new protocol version within 15 seconds.
  • Linux: new tests for the PowerShell command, the wrapper script (literal here-string, quoted bundle, refusal of a script that would end the here-string), the installer's argument, bundle, startup-command, and service-name logic, the /install.ps1 responses, the host package contents, and the dialog toggle. On this branch before the last rebase, turbo run lint typecheck test --filter='...[origin/main]': 184 of 186 tasks passed. The failing tasks were the app and server test tasks, with tests that time out when the development machine is loaded (PromptBoxInternal.test.tsx, PluginSettings.test.tsx, machine-environment.test.ts, plugin-native-server-loading.test.ts) and pass when run alone. Both plugin SDK version checks pass. After the rebase onto current main, lint and typecheck pass for the same filter.

Not verified: a non-administrator Windows account (the VM user is an administrator); starting at sign-in from the Run key (the entry was checked, sign-in was not exercised); enrollment through bb connect; PowerShell 7 (the VM has Windows PowerShell 5.1).

🤖 Generated with Claude Code

AGENT GENERATED

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-02T16:55:59.622241Z c2cec11 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2cec11362

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


async function installPackage({ dataDir, npmPrefix, source }) {
const launch = npmLaunch([
"install",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Allow the generated host package to install on win32

On a normal Windows installation, this npm install rejects the downloaded artifact with EBADPLATFORM before enrollment can run. Both artifact builders preserve packages/bb-app/package.json's os: ["darwin", "linux"] in the generated host package (packages/bb-app/scripts/build-host.mjs and apps/server/src/services/install/bb-app-artifact.ts); npm's bundled package-json documentation confirms that os specifies the permitted operating systems and uses process.platform. Generate the host-only package with win32 permitted rather than inheriting the desktop package restriction.

Useful? React with 👍 / 👎.

Adding a machine produced only a curl-and-sh command, so a Windows
computer could not join another server. The server now also returns a
PowerShell command that fetches /install.ps1, which writes and runs a
Node installer: it installs the server's host package under the machine
directory, enrolls, starts the daemon without a window through WMI so it
outlives the installing session, and registers it in the user's Run key.
The same installer stops, starts, and removes the machine. The Add
machine and Reconnect dialogs offer the Windows command, and the CLI
prints both.

The host package now ships bb.cmd, and the daemon's protocol self-update
runs npm through the portable launcher, so an enrolled Windows daemon
follows its server's version.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood force-pushed the bb/windows-remote-machines-thr_jensq3v9th branch from c2cec11 to 86d4f5b Compare October 2, 2026 17:29
SawyerHood added a commit that referenced this pull request Oct 2, 2026
## Human comments

## What was wrong

The connect gate forwards a fixed list of installer paths to a server
without a session, so a machine being added can fetch them:
`/install.sh`, `/install/version`, and `/install/bb-app.tgz`. The
Windows machine installer added in #4735 is served at `/install.ps1`,
which the gate does not forward without a session. Part of #1206.

## What changed

- `apps/connect/src/worker.ts`: `/install.ps1` joins the public
installer path list. Like the others it is GET only, is refused for a
machine target, and has the cloud-dev header stripped.

This deploys with the gate. It has no effect until a server serves the
path.

## How you verified

- Linux: the existing gate test that forwards each installer path
without session or machine auth now also covers `/install.ps1`. On this
branch before the last rebase, `turbo run lint typecheck test
--filter='...[origin/main]'`: 14 of 14 tasks passed. After the rebase
onto current main, lint and typecheck pass for the same filter.

Not verified: not deployed or exercised on staging. The Windows
enrollment was tested against a server reached directly, not through the
gate.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Code <[email protected]>
@SawyerHood
SawyerHood merged commit 450954c into main Oct 2, 2026
27 checks passed
@SawyerHood
SawyerHood deleted the bb/windows-remote-machines-thr_jensq3v9th branch October 2, 2026 18:09
SawyerHood added a commit that referenced this pull request Oct 2, 2026
## Human comments

## What was wrong

`npm` refused `bb-app` on Windows with EBADPLATFORM because the
package's `os` list named only macOS and Linux, and the README and
platform docs said native Windows was not supported. The tarball smoke
that guards the npm path could not run on Windows: it spawned `npm`,
`npx`, and the installed bin links by bare name, and stopped only the
direct child. Part of #1206. Stacked on #4735, whose behavior the
platform doc describes.

## What changed

- `packages/bb-app/package.json`: `os` includes `win32`.
- `packages/bb-app/scripts/smoke-tarball.mjs` and `managed-process.mjs`:
on Windows the smoke runs npm and npx through Node, runs each installed
command through the `.cmd` shim npm creates, stops process trees with
`taskkill` (bounded to 2 seconds, then the direct kill), and retries
removing its temp directory. macOS and Linux behavior is unchanged.
- `.github/workflows/ci.yml`: the Windows app smoke job also runs
`smoke:tarball`.
- Docs: the README, `packages/bb-app/README.md`,
`docs/platform-support.md`, and `docs/windows-ci.md` describe native
Windows as an alpha host beside WSL2 (Git for Windows required,
drive-letter paths, PowerShell terminals, the Windows machine command,
no server move to Windows).

## How you verified

- Windows 11 Enterprise VM (build 26300): `node
scripts/smoke-tarball.mjs` passed in about a minute: `npm pack`, `npx
--package <tarball> bb-app --help`, `npm install` of the tarball, the
help and config commands through the `.cmd` shims, the provider bridge
and plugin host worker bundles, the full stack, and a joined daemon.
Before the `os` change npm refused the tarball.
- Linux: `smoke:tarball` passes; the bb-app package tests pass with the
updated `os` assertion. On this branch before the last rebase, `turbo
run lint typecheck test --filter='...[origin/main]'`: 184 of 186 tasks
passed. The failing tasks were the app and server test tasks, with tests
that time out when the development machine is loaded
(`PromptBoxInternal.test.tsx`, `machine-environment.test.ts`,
`plugin-native-server-loading.test.ts`) and pass when run alone. After
the rebase onto current main, lint and typecheck pass for the same
filter.

Not verified: `npx bb-app@latest` from the public registry (nothing is
published with this change yet); the new CI step has not run.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

> AGENT GENERATED

Co-authored-by: Claude Code <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant