fix(cli): align Functions with SDK on v3 CLI

Closed
SH
2mo ago
+283-30

Summary

  • align browse functions with the canonical Functions SDK/CLI contract
  • accept --api-url as 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 / flowObserved outputConfidence / sufficiency
pnpm --filter browse lintFormatting, ESLint, and TypeScript checks passedProves the v3 backport is statically valid
Functions contract suite16/16 tests passedCovers publish, invoke, scaffold, local runtime, project precedence/inference, archive limits, API alias, and error contracts
pnpm --filter browse test under the CI-standard umask25 files and 369/369 tests passedProves the full Browse suite remains green on the v3 lineage
Fresh browse functions init using the locally built CLIProject scaffolded and installed successfullyProves the packaged command path and current SDK dependency work together
Real browse functions publish index.ts with BROWSERBASE_PROJECT_ID unsetFunction was published/updated successfully through the production Functions APIDirectly proves the reported publish failure is fixed by API-key project inference
Real deployed invocation against https://example.comCOMPLETED in 2 seconds with result title Example DomainProves 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.