Skip to content

Find and launch provider CLIs on native Windows - #4661

Merged
SawyerHood merged 3 commits into
mainfrom
bb/windows-provider-launch-thr_jensq3v9th
Oct 2, 2026
Merged

SawyerHood merged 3 commits into
mainfrom
bb/windows-provider-launch-thr_jensq3v9th

Conversation

@SawyerHood

@SawyerHood SawyerHood commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

On native Windows the installed provider CLIs were detected wrongly or could not be started:

  • resolveExecutablePath took the first line of where codex. npm installs an extensionless sh shim beside codex.cmd, and where lists the shim first, so bb reported an executable path Windows cannot run.
  • The Codex and Pi bridges launched their CLI with node:child_process spawn("codex" | "pi"). Node's spawn only finds .exe and .com by name, so an npm install (codex.cmd) failed and provider models codex returned missing_executable.
  • Claude Code's native installer puts claude.exe in %USERPROFILE%\.local\bin, which is not on PATH. bb looked only on PATH (and in $HOME, which is unset on Windows), so it reported Claude Code as not installed and offered the curl … | bash installer.

Part of #1206.

What changed

  • provider-maintenance-kit.ts: resolveExecutablePath picks the first where result whose extension is in PATHEXT (new pure selectResolvedExecutable) and reports the CLI as missing when none has one; macOS and Linux still take the first which result. downloadedInstallerCommand takes an optional { powershellUrl } and returns powershell.exe … "irm <url> | iex" on Windows when one is given.
  • @get-bb/plugin-sdk/provider-bridge exports experimental_spawnPortableProcess (the daemon's existing cross-spawn launcher). The Codex app-server connection and the Pi RPC child use it in place of spawn. Entries added to docs/api_to_audit.md and to the Agent providers surface of the Plugin Guide (plugins/plugin-api-docs/src/surfaces.ts); the plugin SDK version goes to 0.6.13.
  • The same subpath exports experimental_killPortableProcess. For an npm-installed CLI the launcher's child is the cmd.exe that runs the .cmd shim, and killing only that wrapper leaves the provider running. On Windows the new function stops the child's whole process tree; elsewhere it sends the signal as before. The Codex connection and the Pi RPC child use it at every place they killed the child.
  • Claude Code: the maintenance probes fall back to %USERPROFILE%\.local\bin\claude.exe on Windows when claude is not on PATH, the session resolver looks for claude.exe on PATH and at that location, and the install action uses https://claude.ai/install.ps1 on Windows.

Behavior on macOS and Linux is unchanged. The Cursor installer action is still the bash script on Windows; that needs Cursor's Windows install command and is not part of this PR.

How you verified

  • Windows 11 Enterprise VM (build 26300) with npm install -g @openai/codex (0.160.0) and Claude Code installed by its PowerShell installer (2.1.287, not on PATH), on a branch with this change on top of Start bb and run the bb CLI on native Windows #4657 (needed to build on Windows):

    • bb machine provider-cli status: Codex executablePath is …\npm\codex.cmd (was …\npm\codex), Claude Code is installed: true at C:\Users\bb\.local\bin\claude.exe version 2.1.287 (was installed: false).
    • bb provider models codex and bb provider models claude-code list models (both returned missing_executable before).
  • Linux: turbo run lint typecheck test for @bb/provider-bridge-protocol, @get-bb/plugin-sdk, @bb/domain, and the Claude Code, Codex, and Pi provider plugins passes (22 of 22 tasks). check-plugin-sdk-version.mjs reports the surface change with a version bump, and check-npm-version-guard.mjs passes (0.6.13 is not on npm).

  • New kit tests cover the PATHEXT selection, the missing result when no candidate is runnable, and the Windows installer command. packages/process-utils/test/portable-process.test.ts has a Windows-only test that launches a .cmd shim, kills it through the new function, and checks the shim's child process is gone; it passes on the VM (5 passed, 1 POSIX-only skipped) and a POSIX test pins the plain signal.

  • Real sessions, same VM, on an installed build that also contains the other open Windows changes, after signing both CLIs in: a Codex thread and a Claude Code thread each provisioned a worktree, ran the repository's setup hook, and completed a turn. Each agent ran bb status and reported its own thread id, created a file in the worktree, and reported Windows PowerShell as its shell with the worktree as the working directory.

Not verified: stopping a hung Codex or Pi session on Windows through the app (the tree kill is covered by the test above, not by a hung provider); the Pi CLI on Windows, which is not installed there; the Claude Code PowerShell install action run from bb's Settings (I ran the same installer by hand).

🤖 Generated with Claude Code

AGENT GENERATED

On Windows bb resolved npm's extensionless `codex` shim, could not spawn the
Codex or Pi CLI through its `.cmd` launcher, and did not find Claude Code's
native install, which is not on PATH.

- Prefer the `where` result whose extension is in PATHEXT.
- Export `experimental_spawnPortableProcess` from the provider-bridge SDK and
  launch the Codex and Pi CLIs with it.
- Find Claude Code at `%USERPROFILE%\.local\bin\claude.exe` and offer its
  PowerShell installer on Windows.
- Bump the plugin SDK to 0.6.13 for the new export.

Co-Authored-By: Claude Code <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-02T01:45:12.434577Z 88fddcb 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

Copy link
Copy Markdown

💡 Codex Review

const child: ChildProcess = experimental_spawnPortableProcess({

P1 Badge Kill the provider process tree for .cmd launches

On native Windows with an npm-installed CLI, this helper returns the cmd.exe wrapper created for the .cmd shim, but killChild() still escalates only through child.kill(); the same is true of PiRpcChild.kill(). As the new audit entry itself notes in docs/api_to_audit.md:1140-1143, killing that wrapper does not terminate the provider process, so a hung Codex or Pi process can continue running tools after bb reports the session stopped. These call sites need a managed process-tree stop rather than the raw ChildProcess handle.


export { spawnPortableProcess as experimental_spawnPortableProcess } from "@bb/process-utils";

P1 Badge Document the new provider-bridge SDK surface

This public SDK export is recorded in docs/api_to_audit.md, but plugins/plugin-api-docs/src/surfaces.ts contains no experimental_spawnPortableProcess entry. That leaves the new bridge-authoring API absent from the Plugin Guide and its API-symbol inventory; add the symbol and its behavior to the appropriate documented surface.

AGENTS.md reference: AGENTS.md:L29-L29

ℹ️ 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".

@SawyerHood
SawyerHood marked this pull request as draft October 1, 2026 23:37
@SawyerHood
SawyerHood marked this pull request as ready for review October 2, 2026 01:41

@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: 88fddcba3f

ℹ️ 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".

Comment on lines +42 to +44
) ??
candidates[0] ??
null

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Return null when no PATHEXT candidate is runnable

When PATHEXT is defined but excludes every result from where.exe—for example, .EXE with only npm's extensionless codex shim and codex.cmd present—this fallback returns the extensionless shell shim that Windows cannot execute. Callers then treat the provider as installed because the resolved path is non-null, recreating the false-positive detection this change is intended to prevent; return null when no candidate has an allowed extension.

Useful? React with 👍 / 👎.

…ction

- Add experimental_killPortableProcess: on Windows it terminates the child's
  whole process tree, since an npm .cmd shim makes the child a cmd.exe wrapper.
  The Codex and Pi bridges stop their CLIs with it.
- Report no executable when PATHEXT admits none of the where results, instead
  of returning a shim Windows cannot run.
- List both portable-process exports in the Plugin Guide and the
  plugin-authoring index.

Co-Authored-By: Claude Code <[email protected]>
@SawyerHood
SawyerHood merged commit 52d9b21 into main Oct 2, 2026
21 checks passed
@SawyerHood
SawyerHood deleted the bb/windows-provider-launch-thr_jensq3v9th branch October 2, 2026 03:22
SawyerHood added a commit that referenced this pull request Oct 12, 2026
## Human comments

## What was wrong

Two Windows npm-shim issues remain after #4661. `probePiVersion()` uses
`execFile("pi", ["--version"])`, which cannot launch the npm `pi.cmd`
shim and can report `ENOENT` despite Pi being installed. The RPC
launcher can execute that shim through `cmd.exe`, but the intermediate
shell does not forward BB's extra stdio descriptors 3 and 4; the
extension then fails with `Unsupported fd type: UNKNOWN`. These were
reproduced with BB 0.45.0 and Pi 0.85.1, and the version-probe issue
also reproduces with Pi 1.1.0. The unchanged probe is visible in the
[branch
base](https://github.com/get-bb/bb/blob/81f98d635d98e5c6f97e56362cfb9f4fbe8cb6fe/plugins/provider-pi/src/bridge/provider-maintenance.ts#L132-L145).

## What changed

- Keep `resolvePiLaunch()` as the original configuration resolver.
Installation identity, executable metadata, cache keys, and npm/Bun
maintenance continue to describe Pi, not its Node interpreter.
- Add a separate provider-local process-launch resolver, used only by
the version probe and RPC spawn. On Windows, unwrap recognized npm Node
`pi.cmd` shims into Node plus the validated package CLI. Resolve against
the child's environment/cwd, prefer sibling `node.exe`, otherwise
resolve Node from the child's PATH, and preserve configured prefix
arguments.
- Support both global npm prefixes and local `node_modules/.bin`
layouts. Validate manifest/bin contents and physical CLI containment;
only accept standard npm shim templates targeting that manifest CLI.
Custom wrappers remain unchanged, including custom files named `pi.cmd`
beside a valid Pi package.
- When the shim has no sibling `node.exe`, look up `node` with `.JS`
removed from `PATHEXT`, as the npm shim does, so a `node.js` file in the
thread's working directory is not chosen as the Node executable.
- Keep ordinary `node:child_process` `execFile` for probing, including
its existing 15 s timeout, stdout-only parsing, output bound, and
failure diagnostics. RPC launches retain both the ordinary stream and
the extra bidirectional extension channel.
- Retain real-process probe/error tests, npm-layout/manifest/bin/wrapper
tests, native Windows extra-FD regressions, installation-identity
assertions, and default npm-shim model/list tests using the real
injected extension.

Following review feedback, this PR no longer introduces an SDK export or
version bump. The earlier SDK/docs changes and unrelated
attachment-preview fix have been removed. The resulting diff is confined
to `provider-pi` and its `which-command` lockfile entry. No host
protocol, CLI, user-facing configuration, or installed-plugin changes.

## How you verified

Linux:

```sh
pnpm exec turbo run lint typecheck test prepare:bundled --filter=bb-plugin-provider-pi --concurrency=2
node .github/workflows/check-plugin-sdk-version.mjs
node .github/workflows/check-version-lockstep.mjs
git diff --check
```

The final Turbo run passed **11/11 tasks**: **233 tests passed, 7
skipped**, plus lint, typecheck and bundled preparation. Windows-only
tests are skipped on Linux. Both accepted npm templates and LF/CRLF
handling are covered; custom-wrapper tests retain a valid npm target
while injecting additional commands, so they test actual wrapper
rejection rather than merely a mismatched target.

Native Windows, Node **24.18.0**: bundled the final upstream
implementation into a temporary standalone module without installing
dependencies or modifying the running BB service. Global and local
canonical npm fixtures verify version probing/install-gate success,
original `pi.cmd` installation identity, configured arguments,
custom-wrapper preservation, ordinary RPC, and descriptor 4 → CLI →
descriptor 3 round trips.

```text
global: original Pi identity + plain execFile probe/install gate + explicit shim/prefix + RPC/fd4/fd3 PASS
local: original Pi identity + plain execFile probe/install gate + explicit shim/prefix + RPC/fd4/fd3 PASS
Installed Pi version: 1.1.0 installation identity: pi.cmd
Installed Pi live catalog: 31 real BB extension extra pipes and refresh PASS (automatic user extensions disabled)
ALL SIMPLIFIED WINDOWS CHECKS PASSED
```

The live smoke uses the machine's existing Pi **1.1.0**, `--no-session
--no-extensions`, and an explicit temporary BB extension. An initial run
with automatically loaded user extensions timed out; disabling those
extensions isolated this launch fix and passed. No model prompt or full
thread turn was sent, no native session was persisted, and installed
providers/configuration were not changed. Windows regressions were
exercised through equivalent standalone bundles, not a full native
Windows Vitest run. CI and review still validate integration before
merge.

Fixes #5332

> AGENT GENERATED

---------

Co-authored-by: Sawyer Hood <[email protected]>
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