Repository navigation
refactor(cli): migrate contexts and extensions commands to Browserbase SDK - #3497
Merged
Merged
Conversation
|
This was referenced Nov 19, 2026
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Architecture diagram
sequenceDiagram
participant CLI as CLI Command
participant Resolver as Context Resolver
participant API as Browserbase API Lib
participant Client as SDK Client
participant Remote as Browserbase Remote API
participant Telemetry as Run Telemetry
Note over CLI,Remote: Contexts Delete Flow
CLI->>Resolver: resolveContextRefOrFail(args.id)
Resolver-->>CLI: context id
CLI->>API: createBrowserbaseClient(toApiOptions(flags))
API-->>CLI: client
CLI->>API: withBrowserbaseApi("contexts", () => client.contexts.delete(id))
API->>Client: client.contexts.delete(id)
Client->>Remote: DELETE /v1/contexts/{id}
Remote-->>Client: 200 OK
Client-->>API: success
API->>Telemetry: setRunTelemetryCompletion({requestHadHttpResponse: true})
API-->>CLI: success
CLI->>CLI: removeContextAliasesById(id)
Note over CLI,Remote: Contexts Update Flow
CLI->>Resolver: resolveContextRefOrFail(args.id)
Resolver-->>CLI: context id
CLI->>API: createBrowserbaseClient(toApiOptions(flags))
API-->>CLI: client
CLI->>API: withBrowserbaseApi("contexts", () => client.contexts.update(id))
API->>Client: client.contexts.update(id)
Client->>Remote: PUT /v1/contexts/{id}
Remote-->>Client: updated context
Client-->>API: result
API->>Telemetry: setRunTelemetryCompletion({requestHadHttpResponse: true})
API-->>CLI: result
CLI->>CLI: outputJson(result)
Note over CLI,Remote: Extensions Delete Flow
CLI->>API: createBrowserbaseClient(toApiOptions(flags))
API-->>CLI: client
CLI->>API: withBrowserbaseApi("extensions", () => client.extensions.delete(args.id))
API->>Client: client.extensions.delete(args.id)
Client->>Remote: DELETE /v1/extensions/{id}
Remote-->>Client: 200 OK
Client-->>API: success
API->>Telemetry: setRunTelemetryCompletion({requestHadHttpResponse: true})
API-->>CLI: success
CLI->>CLI: outputJson({ok: true, id: args.id})
alt Error Response
Client-->>API: throws
API->>API: rethrowBrowserbaseApiError(error, command)
API-->>CLI: rethrows error
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
shrey150
added a commit
that referenced
this pull request
Nov 19, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Bumps `@browserbasehq/sdk` from ^2.14.0 to ^2.28.0. The new SDK version adds: - Search filtering params: `includeDomains`, `excludeDomains`, `startPublishedDate`, `endPublishedDate`, `category`, `userLocation`, `moderation`, `objective`, `maxAgeHours`, `excerpts` - Search response fields: `mode`, `provider`, per-result `excerpts` ## Stack 1. **This PR** — SDK bump 2. #3497 — Migrate contexts and extensions commands 3. #3481 — Add search filtering options and migrate search to SDK ## Changes - `packages/cli/package.json` — SDK version bump - `pnpm-lock.yaml` — lockfile update <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-8715c72a-522c-5520-b1c4-7fea371c861c?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> <a href="https://cursor.com/background-agent?bcId=bc-8715c72a-522c-5520-b1c4-7fea371c861c&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> </div> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Bumps `@browserbasehq/sdk` from ^2.14.0 to ^2.28.0 in the CLI package. The new version adds search filtering params (`includeDomains`, `excludeDomains`, `startPublishedDate`, `endPublishedDate`, `category`, `userLocation`, `moderation`, `objective`, `maxAgeHours`, `excerpts`) and search response fields (`mode`, `provider`, per-result `excerpts`). No behavior changes in the CLI itself; this is a dependency and lockfile update to prepare for upcoming migration work. <sup>Written for commit db169aa. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3495?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/3495?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3495&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. --> Co-authored-by: Cursor Agent <[email protected]>
…e SDK Replace raw HTTP calls with SDK client methods: - contexts/delete.ts: use client.contexts.delete() - contexts/update.ts: use client.contexts.update() - extensions/delete.ts: use client.extensions.delete() Also add success telemetry to withBrowserbaseApi to preserve requestHadHttpResponse tracking that raw HTTP calls had. Co-authored-by: Shrey Pandya <[email protected]>
Set httpStatus: 200 for successful SDK calls to maintain telemetry parity with raw HTTP calls that recorded response.status. Co-authored-by: Shrey Pandya <[email protected]>
shrey150
force-pushed
the
cursor/contexts-extensions-sdk-861c
branch
from
November 19, 2026 18:05
179f4bb to
6582ab6
Compare
ziruihao
approved these changes
Nov 19, 2026
shrey150
added a commit
that referenced
this pull request
Nov 19, 2026
) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Adds support for new Browserbase Search API parameters and migrates the search command to use the SDK. ## SDK Migration Migrates `browse cloud search` from raw HTTP to `client.search.web()`. ## New Search Flags - `--include-domains` / `--exclude-domains` — domain filtering with path prefixes and wildcards - `--start-published-date` / `--end-published-date` — date range filtering (YYYY-MM-DD or RFC 3339) - `--category` — content category filter (news, tweet, company, research_paper, pdf, github, movie, song, personal_site, linkedin_profile) - `--user-location` — two-letter country code for location relevance - `--moderation` — safety filter (safe/off) - `--objective` — natural language objective (up to 4096 code points) - `--max-age-hours` — recency filter - `--excerpts` — return relevant passages (shown in both JSON and table output) ## Provider Auto-Routing When `--provider` is omitted, the API auto-routes to a provider that supports your params. Validation checks that apply to Parallel are only enforced when `--provider parallel` is explicit. For deep/deep-lite modes, the CLI automatically infers `--provider exa`. ## Validation Improvements - Domain lists: validates non-empty, trims whitespace, lowercases hostname (preserves path case), deduplicates, rejects schemes/ports/query strings - Dates: strict YYYY-MM-DD or RFC 3339 format, validates actual date values, rejects start > end - Query/objective: code point counting (not UTF-16), rejects empty/whitespace - Mode/provider: validates valid combinations per provider - Control character stripping in table output for security ## Stack 1. #3495 — SDK bump 2. #3497 — Migrate contexts and extensions commands ← **base** 3. **This PR** — Add search filtering options and migrate search to SDK ## Files Changed - `packages/cli/src/commands/cloud/search.ts` — SDK migration + new flags - `packages/cli/skills/browse/SKILL.md` — updated docs with new params - `packages/cli/tests/cli-cloud-contract.test.ts` — comprehensive tests - `.changeset/search-api-params.md` — changeset <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-8715c72a-522c-5520-b1c4-7fea371c861c?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> <a href="https://cursor.com/background-agent?bcId=bc-8715c72a-522c-5520-b1c4-7fea371c861c&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> </div> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds the new Browserbase Search API parameters to `browse cloud search` with client-side validation before requests are sent, and migrates search, context, and extension cloud commands from raw HTTP calls to the Browserbase SDK. Exa now supports `deep-lite` and `deep` modes, responses include `provider` and `mode` fields, and `--excerpts` returns relevant passages in JSON and table output. **New Features** - New flags: `--include-domains`/`--exclude-domains` (hostname, path prefix, or wildcard; hostname lowercased, path case preserved), `--start-published-date`/`--end-published-date` (strict ISO 8601), `--category`, `--user-location`, `--moderation`, `--objective` (max 4096 code points), `--max-age-hours`, and `--excerpts`. - Deep/deep-lite modes infer the exa provider; other modes require an explicit `--provider`. - Bumps `@browserbasehq/sdk` to ^2.28.0; `search`, `contexts delete/update`, and `extensions delete` now use SDK client methods. - Successful SDK calls now record `requestHadHttpResponse` telemetry like the raw HTTP calls they replaced. **Validation** - Rejects invalid domain formats (scheme, port, query, fragment), empty domain lists, unsupported parallel country codes, parallel include/exclude conflicts, >200 domains, and parallel with exa-only flags like `--end-published-date`. - `--moderation` is rejected only with an explicit `--provider parallel`; `--no-moderation` remains allowed. <sup>Written for commit b3738c2. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3481?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/3481?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3481&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. --> --------- Co-authored-by: Cursor Agent <[email protected]>
shrey150
added a commit
that referenced
this pull request
Nov 19, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## Summary Removes the deprecated `browse cloud contexts update` command. Context uploads are no longer supported by the API. ## Changes - Deleted `packages/cli/src/commands/cloud/contexts/update.ts` - Removed references from `README.md`, `SKILL.md`, and test files - Added test to verify the removed command is rejected - Added changeset for minor version bump ## Context This follows the SDK migration in #3497 (now merged), after which the command returned a 400 error instead of the deprecation message. <!-- CURSOR_AGENT_PR_BODY_END --> <div><a href="https://cursor.com/agents/bc-8715c72a-522c-5520-b1c4-7fea371c861c?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> <a href="https://cursor.com/background-agent?bcId=bc-8715c72a-522c-5520-b1c4-7fea371c861c&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> </div> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Removes the deprecated `browse cloud contexts update` command. Context uploads are no longer supported by the API, and since the SDK migration the command returns a 400 error instead of the deprecation message. - Deletes the command and its references from `README.md`, `SKILL.md`, and the API contract tests. - Adds a test verifying the command is rejected as unknown, plus a changeset for a `browse` minor version bump. <sup>Written for commit 5f453af. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3499?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/3499?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3499&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. --> Co-authored-by: Cursor Agent <[email protected]>
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
Migrates contexts and extensions commands from raw HTTP calls to the Browserbase SDK client methods.
Changes
contexts/delete.ts→client.contexts.delete(id)contexts/update.ts→client.contexts.update(id)extensions/delete.ts→client.extensions.delete(id)api.ts→ Add success telemetry towithBrowserbaseApito preserverequestHadHttpResponsetrackingStack
Summary by cubic
Migrates the CLI's
contextsandextensionscommands from raw HTTP calls to the Browserbase SDK client methods.contexts deleteandcontexts updatenow useclient.contexts.deleteandclient.contexts.update.extensions deletenow usesclient.extensions.delete.withBrowserbaseApinow setsrequestHadHttpResponse: trueandhttpStatus: 200on success so telemetry tracking from the old raw HTTP calls is preserved.Written for commit 6582ab6. Summary will update on new commits.