fix(cli): align Functions with SDK

Draft
SH
3mo ago
+188-29

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 / flowObserved outputConfidence / sufficiency
Browse lint/buildFormatting, ESLint, typecheck, manifest generation, and build passedProves the package compiles; does not exercise Functions remotely
Browse full test suite25 files and all tests passedCovers Browse command, JSON, telemetry, and error contracts; most service boundaries are mocked
Workspace check10/10 format/lint/typecheck tasks passed with 0 errorsProves the tactical changes do not break the containing workspace
Fresh npm and pnpm scaffoldsBoth installed with complete metadata and dependenciesProves generated projects are installable under both package managers
Local Functions dev with real credentialsManaged session connected, invoked starter code, and released cleanlyExercises the real session/runtime path on public starter behavior
Fresh scaffold publishCloud build completed and created a function versionExercises archive upload and build polling against the real Functions service
Synchronous invokeInvocation completed with expected starter resultsExercises the real blocking invocation path
Async invoke followed by independent status lookupSubmission and status polling completed with the expected resultExercises the real non-blocking and resume/status path
Publish and local dev without --project-idBoth completed after project inference from the API keyProves 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.