feat(connect): honor BU_CDP_WS env var in session.connect()#45
Merged
Alezander9 merged 1 commit intomainfrom May 9, 2026
Merged
feat(connect): honor BU_CDP_WS env var in session.connect()#45Alezander9 merged 1 commit intomainfrom
Alezander9 merged 1 commit intomainfrom
Conversation
Eval harnesses and CI need to hand the agent a preconfigured browser
without putting the WS URL in the prompt. Restores the convention from
the pre-port Python harness: when `BU_CDP_WS` (or alias `BU_CDP_URL`)
is set, no-args `session.connect()` connects there directly, ahead of
OS scan. Explicit { wsUrl } / { profileDir } calls ignore the env var.
If the env var is set but unreachable, surface the error rather than
silently falling through to OS scan — matches Python harness PR #300
which closed the same hole.
- src/cdp/session.ts: env-var precedence in connect(), ~5 lines.
- skills/BROWSER.md: one-paragraph note under Connecting.
- test/connect-env.test.ts: 4 tests covering precedence, fallback, override.
Verified: bun typecheck clean, bun test 12 pass + 5 chrome-gated skip
(was 8 + 5 baseline; +4 from the new tests).
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.
Why
Eval harnesses and CI need to hand the agent a preconfigured browser without burying the WS URL in the prompt. The pre-port Python harness honored
BU_CDP_WSfor exactly this; v0.1.0 lost it during the TS port. Re-adopting the same convention.What
When
session.connect()is called with no args, checkBU_CDP_WS(and aliasBU_CDP_URL) before the OS scan:Explicit
{ wsUrl }/{ profileDir }calls ignore the env var. If the env var is set but the endpoint is unreachable, the error surfaces rather than silently falling through to OS scan — matches Python harness PR #300, which closed exactly that hole (was billing for a cloud browser while silently using a local Chrome).Scope
packages/bcode-browser/src/cdp/session.ts— ~5 line addition inconnect(), doc-comment expanded to spell out the precedence.packages/bcode-browser/skills/BROWSER.md— one-paragraph note under "Connecting".packages/bcode-browser/test/connect-env.test.ts— 4 tests covering: BU_CDP_WS path, BU_CDP_URL alias, explicit-opts-override-env, fail-fast on stale env URL. Uses a tinyBun.serveWS upgrade endpoint; no Chrome needed.+117 lines, mostly the new test file.
Verified
bun typecheckclean frompackages/bcode-browser/and from repo root (filtered turbo run).bun testfrompackages/bcode-browser/: 12 pass + 5 chrome-gated skip (was 8 + 5; +4 from this PR).Eval team usage
The agent's natural snippet
await session.connect()lands on the eval browser. No prompt boilerplate, no skill changes per-eval, no risk of the model picking a different browser.