Skip to content

Fix Pi Windows npm shim probing and RPC pipes - #5271

Merged
SawyerHood merged 6 commits into
get-bb:mainfrom
yteruel31:fix/pi-windows-version-probe
Oct 12, 2026
Merged

SawyerHood merged 6 commits into
get-bb:mainfrom
yteruel31:fix/pi-windows-version-probe

Conversation

@yteruel31

@yteruel31 yteruel31 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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.

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:

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.

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

@yteruel31
yteruel31 force-pushed the fix/pi-windows-version-probe branch from d014fb2 to 606364b Compare October 9, 2026 18:56
@yteruel31
yteruel31 marked this pull request as ready for review October 9, 2026 19:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 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-09T19:06:26.178239Z 606364b 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: 606364b2d0

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

/**
* Runs a CLI with buffered stdout/stderr, resolving Windows npm `.cmd` shims.
* Bounds output with `maxBuffer` and stops descendants on timeout or abort.
* Throws errors carrying `code`, `signal`, `killed`, `stdout` and `stderr`.

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 Preserve the promised error shape for pre-aborted signals

When a bridge passes an AbortSignal that is already aborted, execPortableFile exits at packages/process-utils/src/exec-portable-file.ts:25 by throwing signal.reason directly; that value may be a string or DOMException, so it lacks the five fields this new public declaration and audit entry promise on failure. Callers following the exported contract can therefore fail while handling this cancellation path; normalize the early-abort branch into the same structured AbortError used after launch (or explicitly narrow the guarantee).

AGENTS.md reference: AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've removed the SDK export from this PR, so it no longer introduces the AbortSignal error contract you flagged. The provider now uses its own Pi process-launch resolver with plain execFile. This removes the newly exposed contract rather than changing the existing internal early-abort behavior. Updated in 7f3043b.

@yteruel31 yteruel31 changed the title Fix Pi version probing for Windows npm shims Fix Pi Windows npm shim probing and RPC pipes Oct 9, 2026
@MayankBansal12

Copy link
Copy Markdown
Contributor

hey @yteruel31, i hit the same bug (#5332) with pi in windows.

i raised a small fix PR in MayankBansal12#7

Same idea, but it leaves resolvePiLaunch alone so install detection stays correct, and it skips the new SDK export, since plain execFile works once Pi runs via node. Feel free to borrow anything from it.

@yteruel31

Copy link
Copy Markdown
Contributor Author

@MayankBansal12 Thanks, you're right about preserving Pi's installation identity. I've separated configuration resolution from the actual process launch and kept the fix provider-local, using plain execFile without a new SDK export. Global/local npm support and the extra-pipe regression tests are retained. Native Windows smoke checks pass, with automatic user extensions disabled for the live Pi smoke. Updated in 7f3043b.

yteruel31 and others added 2 commits October 10, 2026 19:44
The npm shim removes .JS from PATHEXT before it looks up `node`, so a
`node.js` file in the working directory is never mistaken for the Node
executable. The unwrapped launch searched the thread's working directory
with the full PATHEXT, so a workspace with a root-level `node.js` had
that file chosen as the command and Pi could not start.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@SawyerHood
SawyerHood merged commit 0c6882c into get-bb:main Oct 12, 2026
46 checks passed
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.

[BUG] Pi provider on Windows: "Could not determine the pi version: pi --version exited with ENOENT"

3 participants