Make projectId optional for Browserbase sessions

Merged
SH
8mo ago
+92-44

Summary

  • Browserbase no longer requires a projectId — only an API key
  • Stops Stagehand from throwing when BROWSERBASE_PROJECT_ID is not set, while still passing it through when provided
  • Updates all call sites: requireBrowserbaseCreds(), createBrowserbaseSession(), StagehandAPIClient, and shutdown supervisor

Changes

  • v3.ts — requireBrowserbaseCreds() only throws on missing apiKey, makes projectId optional in return type; removed redundant guard that still checked projectId
  • launch/browserbase.ts — projectId parameter made optional, conditionally included in create payload
  • api.ts — projectId optional in StagehandAPIClient, x-bb-project-id header only sent when set
  • shutdown/supervisor.ts — cleanup no longer requires projectId
  • types/private/shutdown.ts — projectId made optional in ShutdownSupervisorConfig

Test plan

  • Init with BROWSERBASE_API_KEY only (no BROWSERBASE_PROJECT_ID) — succeeds, connects to Browserbase, page loads
  • Verified redundant guard at v3.ts:889 was blocking init — fixed
  • Init with both env vars set — should still work as before
  • Verify session cleanup works without projectId

🤖 Generated with Claude Code

Co-authored-by: Chris Read rcreadii@gmail.com