fix(cli): align Functions with SDK
BLUF
Repair the immediate browse functions drift so fresh Browse-generated projects develop, publish, and invoke successfully. Project selection is inferred from the API key by default; --project-id / BROWSERBASE_PROJECT_ID remains an optional override.
Root cause
The Functions API did not introduce a breaking contract change. Browse had a parallel implementation that stopped tracking the canonical SDK/CLI as it evolved. The most visible failures came from stale scaffold metadata/dependencies and runtime/archive behavior—not from a newly required project ID.
Changes
- align scaffold package metadata, required dependencies, and npm/pnpm output with the SDK
- infer the Functions project from the API key while preserving an explicit override
- align local invocation context, structured runtime errors, Lambda ARN formatting, API URL flags, and the 50 MB archive guard
- cover publish, invoke, async status, local dev, scaffolding, and error contracts
This is the tactical fix. The stacked follow-up, https://github.com/browserbase/stagehand/pull/2701, removes the parallel implementation entirely by consuming the shared SDK core. The canonical core extraction is https://github.com/browserbase/sdk-functions-node/pull/40.
E2E test matrix
| Command / flow | Observed output | Confidence / sufficiency |
|---|---|---|
| Browse lint/build | Formatting, ESLint, typecheck, manifest generation, and build passed | Proves the package compiles; does not exercise Functions remotely |
| Browse full test suite | 25 files and all tests passed | Covers Browse command, JSON, telemetry, and error contracts; most service boundaries are mocked |
| Workspace check | 10/10 format/lint/typecheck tasks passed with 0 errors | Proves the tactical changes do not break the containing workspace |
| Fresh npm and pnpm scaffolds | Both installed with complete metadata and dependencies | Proves generated projects are installable under both package managers |
| Local Functions dev with real credentials | Managed session connected, invoked starter code, and released cleanly | Exercises the real session/runtime path on public starter behavior |
| Fresh scaffold publish | Cloud build completed and created a function version | Exercises archive upload and build polling against the real Functions service |
| Synchronous invoke | Invocation completed with expected starter results | Exercises the real blocking invocation path |
| Async invoke followed by independent status lookup | Submission and status polling completed with the expected result | Exercises the real non-blocking and resume/status path |
Publish and local dev without --project-id | Both completed after project inference from the API key | Proves the corrected default project-selection path for the tested account |
Live validation used public starter behavior. Secrets, account identifiers, resource IDs, and connection URLs are intentionally omitted.