fix(cli): align Functions with SDK on v3 CLI
Summary
- align
browse functionswith the canonical Functions SDK/CLI contract - accept
--api-urlas an alias for--base-url - forward optional project IDs for publish and local session lifecycle calls while allowing the API to infer the project from the API key
- match the SDK's local invocation context, runtime error shape, scaffold metadata, dependencies, and archive-size guard
Root cause
Browse maintained a parallel Functions client implementation. The canonical SDK/CLI evolved while Browse did not, so Browse's request/scaffold/runtime behavior drifted even though the Functions HTTP API itself did not make a breaking change.
This PR is deliberately based on v3-cli, whose packages/cli tree is identical to the published browse@0.9.6 tag. It supersedes #2700 so the hotfix does not accidentally include the broader v4-spike-cli migration.
Impact
browse functions init, dev, publish, and invoke now follow the working SDK behavior. In particular, publishing works with only BROWSERBASE_API_KEY; callers may still provide --project-id or BROWSERBASE_PROJECT_ID explicitly.
E2E Test Matrix
| Command / flow | Observed output | Confidence / sufficiency |
|---|---|---|
pnpm --filter browse lint | Formatting, ESLint, and TypeScript checks passed | Proves the v3 backport is statically valid |
| Functions contract suite | 16/16 tests passed | Covers publish, invoke, scaffold, local runtime, project precedence/inference, archive limits, API alias, and error contracts |
pnpm --filter browse test under the CI-standard umask | 25 files and 369/369 tests passed | Proves the full Browse suite remains green on the v3 lineage |
Fresh browse functions init using the locally built CLI | Project scaffolded and installed successfully | Proves the packaged command path and current SDK dependency work together |
Real browse functions publish index.ts with BROWSERBASE_PROJECT_ID unset | Function was published/updated successfully through the production Functions API | Directly proves the reported publish failure is fixed by API-key project inference |
Real deployed invocation against https://example.com | COMPLETED in 2 seconds with result title Example Domain | Proves the published artifact executes end to end with a real Browserbase session |
Release
#2705 is the stacked release PR. It bumps Browse to 0.9.7 and adds a v3-cli-only trusted-publishing job that packs, smoke-tests, and publishes only the Browse tarball.