fix(cli): use shared Functions core for V4 Browse
Browse maintains a separate implementation of Functions scaffolding, archives, HTTP requests, polling, and local runtime behavior. This moves init, dev, publish, and invoke onto @browserbasehq/sdk-functions/core, retaining Browse JSON output, credential resolution, telemetry, and signal handling. It also adds explicit --project-id support on publish/dev and the SDK-compatible --api-url alias.
This follows the August 2026 Browse/Functions SDK parity work. The problem was implementation drift, not a demonstrated breaking Functions HTTP API change. Tactical V3 #2704 and its release PR #2705 were closed unmerged; this PR is the shared-core successor for V4.
Published Browse 0.11.0 already passes the single-project scaffold/publish/invoke and cloud-secrets happy paths tested below. This PR is not a prerequisite for those basic commands. It remains useful for explicit project selection, canonical scaffold/archive/runtime behavior, and preventing separate implementations from drifting again. Successful happy-path tests do not prove full SDK parity.
Blocked on the Functions SDK release. The required /core export is in browserbase/sdk-functions-node#40, still an open draft. This draft intentionally pins commit 097ad455f4af8ca2f4932da7641373d77963d2d1; npm still serves 1.0.1, which has no /core export. Before merging/releasing Browse, merge and publish the SDK change, replace the catalog Git pin with the released version, regenerate the lockfile, remove the temporary Git-dependency build allowance, and repeat validation.
E2E Test Matrix
Retested on 2026-09-24 against production with a single-project credential, synthetic functions/secrets, and public example.com. PR head: de797d612626a8bc8b002b6e926b20e52d9868e2.
| Command / flow | Observed output | Confidence / sufficiency |
|---|---|---|
| Released Browse 0.11.0: fresh npm and pnpm scaffold → publish → invoke | Both builds/invocations COMPLETED; returned title Example Domain | Establishes working baseline with portable registry URLs; does not cover multi-project credentials |
| Released Browse 0.11.0: local dev and browser invocation | HTTP 200; Example Domain; clean exit | Basic local runtime works; local context.secrets is absent |
| Released Browse 0.11.0: cloud secret lifecycle | Create/get/list/update/attach/invoke/detach/delete passed; hashes/lengths matched; no test secrets remain | Cloud attachments work independently of this PR |
| This PR: rebuild Browse | TypeScript compile and command manifest generation passed | Rebuilt the exact branch under test |
| This PR: fresh pnpm scaffold → cloud publish → deployed invocation | Build/invocation COMPLETED; title Example Domain; browser session completed | Confirms the shared-core path remains operational |
functions publish index.ts --dry-run --project-id <project-id> | Released CLI exits 2 for nonexistent flag; this PR accepts and forwards the ID | Confirms an outstanding, concrete parity improvement; no live multi-project credential test |
The initial current-baseline cloud attempts failed with WORKLOAD_ERROR; build logs identified ENOTFOUND for private devbox registry URLs. Normalizing the npm lockfile tarball URLs and using the public registry for the generated pnpm-project archive lockfile made both released-CLI builds succeed. Versions/integrity checksums were preserved. The earlier broad fresh-scaffold-failure rationale should therefore not be treated as proof that released Browse cannot deploy ordinary functions.
Prior validation on 2026-09-23 additionally passed frozen install; Browse/V4 SDK/extension builds; the full CLI suite (397 tests across 28 files); CLI TypeScript/formatting/ESLint; and import of /core without CLI execution. Those full suites were not rerun for this documentation-only evidence update. Fresh registry-package validation remains required after the SDK release.