Skip to content

feat(cli): add --stagehand flag to browse cloud extensions upload - #3289

Merged
shrey150 merged 2 commits into
mainfrom
cursor/cli-extension-upload-stagehand-81e3
Oct 27, 2026
Merged

shrey150 merged 2 commits into
mainfrom
cursor/cli-extension-upload-stagehand-81e3

Conversation

@shrey150

@shrey150 shrey150 commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Upload the bundled Stagehand extension directly without requiring a file path. Uses getExtensionArchive() from @browserbasehq/stagehand and passes the bytes via toFile() to the Browserbase API.

why

what changed

test plan


Summary by cubic

Adds a --stagehand flag to browse cloud extensions upload so the bundled Stagehand extension can be uploaded without a file path; the archive bytes come from getExtensionArchive() and are sent to the Browserbase API without writing a temp file.

  • The file argument is now optional; you must provide either a file path or --stagehand.
  • Passing both --stagehand and a file path errors out.

Written for commit 3e27ee2. Summary will update on new commits.

View guided diff Turn on auto-fix

why

Sean added a public getExtensionArchive() helper to the Stagehand SDK (packages/sdk-ts/src/extensionAssets.ts, #3267) so users can get the bundled extension ZIP without reaching into node_modules/@browserbasehq/stagehand/dist/assets/stagehand-extension.zip—a path that may change across releases. He asked for the CLI and docs to use it.

The existing browse cloud extensions upload <file> command only accepts a filesystem path, so users had to pass that brittle internal path directly. This adds a --stagehand flag that handles the export and upload in one step.

what changed

  • Add --stagehand boolean flag to browse cloud extensions upload
  • With --stagehand: call getExtensionArchive() from @browserbasehq/stagehand to get the Uint8Array, wrap it with the Browserbase SDK's toFile(bytes, "stagehand-extension.zip", { type: "application/zip" }), and pass that to client.extensions.create(). No temp file is written.
  • Make the file positional arg optional (was required)
  • Validation: --stagehand and file are mutually exclusive; providing both exits 1 with "Cannot specify both --stagehand and a file path.". Providing neither exits 1 with "Provide a file path or use --stagehand to upload the Stagehand extension."
  • Existing <file> path behavior unchanged—still uses resolveUploadableFile() to stream from disk
  • Output unchanged: prints the JSON response from extensions.create (includes id)
  • Update command description and examples in help
  • Add Browse patch changeset
  • Add 3 tests in packages/cli/tests/cli-cloud-contract.test.ts:
    • extensions upload --stagehand uploads the bundled Stagehand extension: verifies multipart POST to /v1/extensions with filename="stagehand-extension.zip"
    • extensions upload rejects both --stagehand and a file path: verifies exit 1 and error message
    • extensions upload requires --stagehand or a file path: verifies exit 1 and error message when neither provided

Before:

browse cloud extensions upload node_modules/@browserbasehq/stagehand/dist/assets/stagehand-extension.zip

After:

browse cloud extensions upload --stagehand

test plan

  • 505 CLI tests pass (38 test files), including the 3 new tests
  • pnpm format:check passes
  • pnpm eslint passes
  • pnpm turbo run build --filter=browse succeeds (TypeScript compiles, oclif manifest generates)

PR 1 of 2. #3275 is stacked on this and updates the user-facing instructions (functions init, deployment docs, CLI skill) to use --stagehand.


Summary by cubic

Adds a --stagehand flag to browse cloud extensions upload so the bundled Stagehand extension can be uploaded without a file path.

  • The file argument is now optional; you must provide either a file path or --stagehand.
  • Passing both --stagehand and a file path errors out.

Written for commit 81444f9. Summary will update on new commits.

View guided diff Turn on auto-fix

Open in Web Open in Cursor 

@changeset-bot

changeset-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1eaf09d

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

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Architecture diagram
sequenceDiagram
    participant User as CLI User
    participant CLI as Browse CLI ExtensionsUpload
    participant SDK as @browserbasehq/stagehand
    participant BB as Browserbase API
    participant FS as Local File System

    Note over User,BB: Cloud Extension Upload Flow

    User->>CLI: browse cloud extensions upload [file] [--stagehand]
    CLI->>CLI: Parse args & flags

    alt --stagehand flag set
        CLI->>SDK: getExtensionArchive() - get bundled Stagehand extension
        SDK-->>CLI: Byte archive data
        CLI->>CLI: toFile(archive, "stagehand-extension.zip", {type: "application/zip"})
    else file path provided
        CLI->>FS: Read extension ZIP file
        FS-->>CLI: Uploadable file
    end

    CLI->>BB: POST /v1/extensions (multipart/form-data)
    alt Success
        BB-->>CLI: 200 Response with extension ID
        CLI-->>User: Output JSON result
    else Error (401, 400, etc.)
        BB-->>CLI: Error response
        CLI-->>User: Error message
    end

    Note over CLI: Validation branches
    alt both --stagehand and file path
        CLI-->>User: Error: Cannot specify both
    else neither --stagehand nor file path
        CLI-->>User: Error: Provide a file path or use --stagehand
    end
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/tests/cli-cloud-contract.test.ts
cursoragent and others added 2 commits October 26, 2026 19:29
Upload the bundled Stagehand extension directly without requiring a
file path. Uses getExtensionArchive() from @browserbasehq/stagehand
and passes the bytes via toFile() to the Browserbase API.

Co-authored-by: Shrey Pandya <shrey150@yahoo.com>
Co-authored-by: Shrey Pandya <shrey150@yahoo.com>
@shrey150
shrey150 force-pushed the cursor/cli-extension-upload-stagehand-81e3 branch from 3e27ee2 to 1eaf09d Compare October 27, 2026 02:29
@shrey150
shrey150 merged commit aa67fee into main Oct 27, 2026
14 of 15 checks passed
@shrey150
shrey150 deleted the cursor/cli-extension-upload-stagehand-81e3 branch October 27, 2026 02:30
shrey150 added a commit that referenced this pull request Oct 27, 2026
…3275)

# why

`browse functions init` still instructed users to upload the Stagehand
extension from a hardcoded path inside `node_modules`. The public
`getExtensionArchive()` helper lets them export the bundled ZIP without
depending on the SDK's package layout.

# what changed

- Export `stagehand-extension.zip` with `getExtensionArchive()` before
uploading it in the initializer's next steps and generated starter
comments.
- Update the deployment guide's starter example to match its existing
export instructions.
- Add a Browse patch changeset.

# test plan

- CLI build, changed-file formatting and lint, changeset validation, and
Mintlify docs validation passed.
- All 81 Functions and cloud API contract tests passed.
- Initialized a fresh project with npm and published Stagehand 4.3.0,
ran the exact generated export command, and verified the resulting ZIP
contains a valid Manifest V3 extension. Confirmed the command matches
the starter comments and deployment guide.

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Updates `browse functions init` and the deployment guide so extension
upload instructions use `browse cloud extensions upload --stagehand`
instead of exporting the bundled ZIP or referencing a hardcoded
`node_modules` path.

- Drops the `node -e` export command from the deployment guide's upload
step.
- Adds `--stagehand` to the CLI skill examples and includes a patch
changeset for `browse`.

<sup>Written for commit cc89ff3.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/browserbase/stagehand/pull/3275?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/browserbase/stagehand/3275?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3275&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
# why

PR 2 of 2, stacked on #3289. The parent adds `browse cloud extensions
upload --stagehand`. This updates the user-facing instructions to use
it.

# what changed

- Update `functions init` template comment and `nextSteps` output
- Simplify deployment guide's extension upload step
- Add `--stagehand` example to CLI skill

# test plan

- 505 CLI tests pass
- Build, lint, and formatting pass
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-036e53ad-deeb-5484-9f72-e4ced49d81e3?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-036e53ad-deeb-5484-9f72-e4ced49d81e3&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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.

3 participants