Skip to content

fix(lib): default to the bundled binary so createBeeClient() works on Windows - #30

Open
1aifanatic wants to merge 1 commit into
bee-computer:mainfrom
1aifanatic:fix/lib-default-bundled-binary
Open

1aifanatic wants to merge 1 commit into
bee-computer:mainfrom
1aifanatic:fix/lib-default-bundled-binary

Conversation

@1aifanatic

Copy link
Copy Markdown

Problem

createBeeClient() (and createBeeCliRunner()) default to command: "bee". With the library installed from npm:

  • Windows: bee on PATH is npm's bee.cmd shim, and child_process.spawn can't run .cmd files without a shell. So createBeeClient() with no options fails even though the package already ships dist/platforms/windows-x64/bee.exe.
  • Any OS without a global install: bee isn't on PATH at all, so the README example (const bee = createBeeClient();) fails until the caller passes command by hand.

Reproduced on Windows 11 with @beeai/cli 0.9.0 and Node 25:

const r = await createBeeClient().run(["status"]);
// published 0.9.0  -> Error: spawn bee ENOENT
// this branch      -> exit 0, "Not logged in."

Change

When no command is passed, the runner now resolves the binary the same way bin/bee.js does:

  1. BEE_CLI_BINARY, if set;
  2. the platform binary shipped next to the library (dist/lib → dist/platforms/<os>-<arch>/bee[.exe]);
  3. otherwise bee on PATH, as before.

An explicit command still wins, so existing callers and the integration tests (which pass command) are unaffected. The README's library section describes the new default.

Checks

  • bun install, bun run typecheck and bun run build pass.
  • bun run build:lib, then the snippet above against the built dist/lib/index.js. With the binary in place: exit 0. Without it: falls back to spawn bee exactly as today.

Found while building a Bee-powered app on Windows for the Amazon Developer Hackathon.

… Windows

createBeeClient() defaulted to command "bee". On Windows that only resolves
to npm's bee.cmd shim, which child_process.spawn cannot run without a shell,
so createBeeClient() with no options fails with "spawn bee ENOENT" even
though the package ships bee.exe. Without a global install it fails on every
platform.

When no command is given, the runner now uses the same lookup as bin/bee.js:
BEE_CLI_BINARY, then the platform binary shipped next to the library
(dist/lib -> dist/platforms/<os>-<arch>/bee[.exe]), and only then "bee" on
PATH. An explicit command still wins.

Claude-Session: https://claude.ai/code/session_01Lf8fMvJ11NuujSbk1HaBq5
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