Skip to content

refactor(cli): consume shared Functions core - #2701

Draft
shrey150 wants to merge 4 commits into
agent/browse-v4-7-context-namesfrom
agent/use-functions-core
Draft

refactor(cli): consume shared Functions core#2701
shrey150 wants to merge 4 commits into
agent/browse-v4-7-context-namesfrom
agent/use-functions-core

Conversation

@shrey150

@shrey150 shrey150 commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Make Browse a thin Oclif adapter over the canonical @browserbasehq/sdk-functions/core library.

  • Remove roughly 1,300 lines of duplicate archive, HTTP, polling, scaffold, and local-runtime logic.
  • Preserve Browse's flags, structured JSON output, telemetry classification, exit codes, stderr logging, and signal ownership.
  • Carry the SDK-compatible --api-url/-u alias and optional --project-id behavior that fix(cli): align Functions with SDK on v3 CLI #2704 hotfixed only on the V3 release branch.
  • Keep bb functions and Browse on one implementation so their behavior cannot drift independently again.

Stack

  1. chore(cli): import Browse V3 baseline #2833 — exact Browse V3 baseline import
  2. refactor(cli): migrate Browse runtime to Stagehand V4 #2834 — Stagehand V4 runtime cutover and CLI-owned cursor
  3. fix(cli): restore V3 network capture through a CDP sidecar #2849 — CLI-private CDP sidecar; restores V3 network capture
  4. refactor(cli): remove coordinate XPath return flag #2835 — remove --return-xpath; complete supported V3 parity
  5. test(evals): exercise the workspace V4 CLI #2838 — eval, packaging, and release wiring
  6. fix(cli): persist context names in Browserbase #2839 — managed Context names (fast-follow)
  7. refactor(cli): consume shared Functions core #2701 — shared Functions core consumer (fast-follow)

Dependency and release gate

This PR depends on sdk-functions-node #40, which exposes the shared core. The catalog is temporarily pinned to the exact tested SDK commit c74bea65c3dd645470e0fc80e65cfff283310665; the Git dependency requires its prepare build and a temporary pnpm allowBuilds entry.

Keep this PR draft and do not merge or publish Browse from the commit pin. After @browserbasehq/sdk-functions@1.1.0 is published:

  1. Replace the catalog pin with ^1.1.0.
  2. Remove the temporary allowBuilds entry and TODO.
  3. Regenerate the lockfile from a clean install.
  4. Rerun frozen install, the full matrix below, package/consumer checks, and fresh npm and pnpm scaffold live-cloud smokes.

Review boundary

The SDK core owns scaffolding, archive rules, Functions HTTP requests, project inference/override, build and invocation polling, local runtime behavior, and typed failures. This PR owns only Oclif flags, Browse output/telemetry/error adaptation, signals, and dependency wiring.

The public SDK core surface consumed or made available to hosts is:

  • Projects/archives: createFunctionProject, createFunctionArchive, listFunctionArchiveEntries, validateFunctionArchiveSize, and MAX_FUNCTION_ARCHIVE_SIZE_BYTES.
  • Cloud operations: publishFunction, getBuildStatus, invokeFunction, and getInvocationStatus.
  • Local runtime: startDevServer and its typed handle/options/log events.
  • Transport/config: shared project resolution, API request/polling helpers, result types, and FunctionsCoreError with stable error codes.

The existing package root and bb binary remain intact. An explicit contract test verifies that importing @browserbasehq/sdk-functions/core does not execute the package's Commander CLI.

E2E test matrix

Command / flow Observed output Confidence / sufficiency
SDK pnpm lint and build Passed on rebased SDK head c74bea65c Proves source, ESM/CJS bundles, and declarations compile on current SDK main
SDK unit suite 63/63 passed Covers core and Commander adapter contracts
SDK packed-tarball integration suite 58/58 passed, including ESM, CommonJS, declarations, CLI, scaffold, manifest, and a TypeScript consumer Proves the package subpath and retained CLI compose after packing
SDK live E2E 4/4 public starter templates scaffolded, installed, published, built, and invoked Exercises the real Functions service across every starter template
Stagehand frozen install with exact SDK pin Passed under pnpm 11.10 with the exact SHA-bound codeload build allowance Proves a clean V4 consumer can install and build the temporary Git dependency
Browse build/lint and focused Functions contracts on current restacked head d3b3b7e20 Build and lint passed; 15/15 contracts passed Covers flag, JSON, telemetry, error, and headless-import behavior
Browse full suite 25/25 files and 384/384 tests passed Covers the complete stacked CLI, not only Functions adapters
Workspace build/check Build 6/6; check 17/17 Proves the fast-follow composes with the full V4 stack
GitHub CI on the stacked head 44 successful, 8 intentionally skipped, 0 failed Repeats clean install, build, checks, language smokes, eval regression, TypeScript unit/browser, and 31 discovered integration shards
Local dev with real credentials and no BROWSERBASE_PROJECT_ID Runtime connected; HTTP invocation opened a managed session and returned Example Domain Exercises project inference, real session creation, local protocol, and signal cleanup
Browse cloud publish and synchronous invoke Build completed with one Function; invocation completed with shared-core-ok Exercises archive, API transport, polling, and blocking invocation
Browse async invoke plus independent status lookup Initial state was PENDING; status lookup reached COMPLETED with the same result Exercises non-blocking submission and resumable status checks
Cross-host invocation The exact SDK #40 bb CLI invoked the Function published by Browse and observed the same result Proves both host CLIs share compatible core contracts

Live validation used synthetic functions and public targets. Secrets, account identifiers, resource IDs, and connection URLs are intentionally omitted.

The unreleased-package live smoke used the exact packed SDK #40 tarball in the SDK's canonical dual-lock fixture. A fresh registry install of the eventual 1.1.0 package in both npm and pnpm scaffolds is still mandatory after publication; that is the remaining release-level uncertainty and the reason this PR stays draft.

@changeset-bot

changeset-bot Bot commented Aug 13, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d3b3b7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
browse Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shrey150
shrey150 force-pushed the agent/use-functions-core branch from 090cef8 to a7a72ab Compare August 28, 2026 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant