fix(cli): align Functions with SDK on v3 CLI - #2704
Open
shrey150 wants to merge 4 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: bad9aa9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
This was referenced Aug 13, 2026
shrey150
marked this pull request as ready for review
August 13, 2026 15:57
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Architecture diagram
sequenceDiagram
participant User as CLI User
participant CLI as browse CLI (functions commands)
participant Shared as functions/shared.ts
participant API as Browserbase Functions API
participant SDK as SDK Runtime (local dev)
participant FS as Filesystem
Note over User,FS: Functions CLI - Publish Flow
User->>CLI: browse functions publish index.ts --project-id optional
CLI->>Shared: resolveFunctionsProjectConfig({apiKey, baseUrl, projectId})
Shared->>Shared: Check --project-id, fallback to BROWSERBASE_PROJECT_ID env
Shared-->>CLI: config with optional projectId
CLI->>FS: Create archive from process.cwd()
FS-->>CLI: archivePath
CLI->>FS: Check archive size
alt Archive > 50MB
CLI->>User: Error: archive exceeds 50MB limit
end
CLI->>API: POST /v1/functions (multipart: archive + metadata)
Note right of CLI: metadata includes entrypoint + projectId (if set)
API-->>CLI: 200 OK / deployment response
Note over User,SDK: Functions CLI - Init & Scaffold Flow
User->>CLI: browse functions init my-function
CLI->>FS: Check package manager exists
CLI->>FS: Write package.json
Note right of FS: version 1.0.0, packageManager field
CLI->>FS: Scaffold entrypoint, .env (API key only, no project ID)
CLI->>FS: Install deps
Note right of FS: @browserbasehq/sdk-functions, playwright-core, zod
Note over User,SDK: Functions CLI - Local Dev Flow
User->>CLI: browse functions dev index.ts --project-id opt
CLI->>Shared: resolveFunctionsProjectConfig()
Shared-->>CLI: config (may include projectId)
CLI->>SDK: Start local runtime API on host:port
Note over SDK: InvocationBridge + BrowserSessionManager
User->>SDK: HTTP request to function URL
SDK->>SDK: Build invocation context
Note right of SDK: {invocation: {id, region:"local"}, session}
SDK->>API: POST /v1/sessions (projectId + session config)
API-->>SDK: session id + connectUrl
SDK->>SDK: Trigger invocation with Lambda runtime headers
Note right of SDK: Lambda-Runtime-Invoked-Function-Arn uses us-east-1 region
alt Successful invocation
SDK-->>User: 202 + result
else Runtime error
SDK->>SDK: Format error as {message, stackTrace, type}
SDK-->>User: 500 + error object
end
SDK->>API: POST /v1/sessions/:id (projectId + REQUEST_RELEASE)
API-->>SDK: 200 OK
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
browse functionswith the canonical Functions SDK/CLI contract--api-urlas an alias for--base-urlRoot 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, whosepackages/clitree is identical to the publishedbrowse@0.9.6tag. It supersedes #2700 so the hotfix does not accidentally include the broaderv4-spike-climigration.Impact
browse functions init,dev,publish, andinvokenow follow the working SDK behavior. In particular, publishing works with onlyBROWSERBASE_API_KEY; callers may still provide--project-idorBROWSERBASE_PROJECT_IDexplicitly.E2E Test Matrix
pnpm --filter browse lintpnpm --filter browse testunder the CI-standard umaskbrowse functions initusing the locally built CLIbrowse functions publish index.tswithBROWSERBASE_PROJECT_IDunsethttps://example.comCOMPLETEDin 2 seconds with result titleExample DomainRelease
#2705 is the stacked release PR. It bumps Browse to
0.9.7and adds av3-cli-only trusted-publishing job that packs, smoke-tests, and publishes only the Browse tarball.