Skip to content

Commit c85222c

Browse files
shrey150claude
andauthored
Make BROWSERBASE_PROJECT_ID optional in CLI (browserbase#1803)
## Summary - Stacked on browserbase#1800 - Only `BROWSERBASE_API_KEY` is required for remote mode in the CLI - `BROWSERBASE_PROJECT_ID` is still passed through if set, but no longer checked ## Changes - `packages/cli/src/index.ts` — `hasBrowserbaseCredentials()` only checks for API key - `packages/cli/tests/mode.test.ts` — Updated test to match new error message - `packages/cli/README.md` — Updated docs to reflect optional project ID ## Test plan - [x] Existing mode test updated - [x] Manual: `browse env remote` with only `BROWSERBASE_API_KEY` set 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Make `BROWSERBASE_PROJECT_ID` optional in the CLI for remote mode, so only `BROWSERBASE_API_KEY` is required. The project ID is still forwarded when provided. - **Bug Fixes** - Updated remote mode check and error message to only require `BROWSERBASE_API_KEY`. - Autodetection now defaults to `remote` when the API key is set; otherwise `local`. - Updated tests and `@browserbasehq/browse-cli` README to match. <sup>Written for commit 99eb186. Summary will update on new commits. <a href="https://cubic.dev/pr/browserbase/stagehand/pull/1803">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. --> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f8c7738 commit c85222c

3 files changed

Lines changed: 5 additions & 8 deletions

File tree

packages/cli/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Behavior details:
183183
- `browse env <target>` persists an override and restarts the daemon
184184
- `browse stop` clears the override so next start falls back to env-var-based auto detection
185185
- Auto detection defaults to:
186-
- `remote` when `BROWSERBASE_API_KEY` and `BROWSERBASE_PROJECT_ID` are set
186+
- `remote` when `BROWSERBASE_API_KEY` is set
187187
- `local` otherwise
188188
189189
## Global Options
@@ -202,7 +202,7 @@ Behavior details:
202202
|----------|-------------|
203203
| `BROWSE_SESSION` | Default session name (alternative to `--session`) |
204204
| `BROWSERBASE_API_KEY` | Browserbase API key (required for `browse env remote`) |
205-
| `BROWSERBASE_PROJECT_ID` | Browserbase project ID (required for `browse env remote`) |
205+
| `BROWSERBASE_PROJECT_ID` | Browserbase project ID (optional, passed through if set) |
206206
207207
## Element References
208208

packages/cli/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,13 @@ function getModeOverridePath(session: string): string {
145145
type BrowseMode = "browserbase" | "local";
146146

147147
function hasBrowserbaseCredentials(): boolean {
148-
return Boolean(
149-
process.env.BROWSERBASE_API_KEY && process.env.BROWSERBASE_PROJECT_ID,
150-
);
148+
return Boolean(process.env.BROWSERBASE_API_KEY);
151149
}
152150

153151
function assertModeSupported(mode: BrowseMode): void {
154152
if (mode === "browserbase" && !hasBrowserbaseCredentials()) {
155153
throw new Error(
156-
"Remote mode requires BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID. Set both env vars or run `browse env local`.",
154+
"Remote mode requires BROWSERBASE_API_KEY. Set the env var or run `browse env local`.",
157155
);
158156
}
159157
}

packages/cli/tests/mode.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,11 @@ describe("Browse CLI env command", () => {
8888
env: {
8989
...process.env,
9090
BROWSERBASE_API_KEY: "",
91-
BROWSERBASE_PROJECT_ID: "",
9291
},
9392
});
9493
expect(result.exitCode).not.toBe(0);
9594
expect(result.stderr).toContain(
96-
"Remote mode requires BROWSERBASE_API_KEY and BROWSERBASE_PROJECT_ID",
95+
"Remote mode requires BROWSERBASE_API_KEY",
9796
);
9897
});
9998
});

0 commit comments

Comments
 (0)