Repository navigation
feat(cli): add search filtering options and migrate search to SDK - #3481
Conversation
Add new search params from core#15309: - --include-domains / --exclude-domains: filter by domain (hostname, path, wildcard) - --start-published-date / --end-published-date: filter by publication date - --category: content category filter (Exa only) - --user-location: localize ranking by country code - --moderation: filter unsafe content (Exa only) - --objective: natural-language task intent - --max-age-hours: refetch stale cached pages - --excerpts: return relevant passages Also: - Expand mode support: Exa now supports deep-lite and deep modes - Include provider/mode in response output - Add validation for Parallel provider constraints (domain limits, country codes) - Update browse skill docs with new params and examples - Add comprehensive tests for new flags and validation Co-authored-by: Shrey Pandya <[email protected]>
🦋 Changeset detectedLatest commit: b3738c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Co-authored-by: Shrey Pandya <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Architecture diagram
sequenceDiagram
participant User as User / Agent
participant CLI as browse CLI (cloud search)
participant Validator as Search Flag Validator
participant API as Browserbase Search API
participant Output as Output Formatter
Note over User,Output: Browse Cloud Search Flow
User->>CLI: Run browse cloud search with flags
CLI->>CLI: Parse flags (provider, mode, filters)
CLI->>Validator: Validate search flags
Validator->>Validator: Check domain format (no scheme/port/query)
Validator->>Validator: Check Parallel domain limits (max 200)
Validator->>Validator: Check include/exclude mutual exclusion (Parallel)
Validator->>Validator: Check user-location format + Parallel country support
Validator->>Validator: Check objective length (max 4096 chars)
alt Validation fails
Validator-->>CLI: Error (exit code 2)
CLI-->>User: Show error, abort
else Validation passes
Validator-->>CLI: Valid flags
end
CLI->>CLI: Build request body
Note over CLI: Conditionally includes:<br/>query, numResults, provider, mode,<br/>includeDomains, excludeDomains,<br/>startPublishedDate, endPublishedDate,<br/>category, userLocation, moderation,<br/>objective, maxAgeHours, excerpts
CLI->>API: POST /v1/search (JSON body + auth headers)
API-->>CLI: SearchResponse (requestId, query, provider, mode, results)
alt Response includes excerpts
CLI->>Output: Format results with excerpts
else Standard response
CLI->>Output: Format results (JSON or table)
end
alt JSON output format
Output-->>User: Full JSON (includes provider, mode, excerpts)
else Table output format
Output-->>User: Table with optional excerpts column
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
- Reject Exa-only modes (deep, deep-lite) with Parallel provider before API call - Fix port detection in path-prefix domains (e.g. example.com:8080/docs) - Add tests for new validation cases Co-authored-by: Shrey Pandya <[email protected]>
Bug fixes in search.ts: 1. Only run Parallel-specific checks when --provider parallel is explicit 2. Infer exa provider for deep/deep-lite modes 3. Reject empty domain lists (commas-only or whitespace) 4. Lowercase and dedupe domains 5. Detect ports in domain/path strings like bbc.com:443/news 6. Reject empty/whitespace-only --objective 7. Validate date formats strictly (YYYY-MM-DD or RFC 3339) 8. Reject start date after end date 9. Count query code points (not UTF-16 units) 10. Collapse whitespace in sanitizeOutput (control chars + spaces) 11. Warn on domain overlap (include intersects exclude) 12. Accept lowercase t/z in ISO date-times 13. Require --provider when --mode is not deep/deep-lite Also updates SKILL.md to document auto-routing behavior and updates tests to match new validation logic. Co-authored-by: Shrey Pandya <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
…nd docs - Lowercase only hostname, preserve path case (example.com/Docs stays) - Only reject --moderation with explicit --provider parallel (not --no-moderation) - Update SKILL.md: 'Exa-only (auto-routes)' instead of 'Requires --provider exa' Co-authored-by: Shrey Pandya <[email protected]>
Co-authored-by: Shrey Pandya <[email protected]>
- Bump @browserbasehq/sdk from ^2.14.0 to ^2.28.0 - Replace raw HTTP calls with SDK client methods: - search.ts: use client.search.web() - extensions/delete.ts: use client.extensions.delete() - contexts/update.ts: use client.contexts.update() - contexts/delete.ts: use client.contexts.delete() - Keep requestBrowserbase/requestBrowserbaseJson for secrets API - Update changeset to mention SDK migration Co-authored-by: Shrey Pandya <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Call setRunTelemetryCompletion on successful SDK calls to preserve requestHadHttpResponse tracking that was present in raw HTTP calls. Co-authored-by: Shrey Pandya <[email protected]>
The new SDK version adds search filtering params (includeDomains, excludeDomains, startPublishedDate, endPublishedDate, category, userLocation, moderation, objective, maxAgeHours, excerpts) and response fields (mode, provider, per-result excerpts). Co-authored-by: Shrey Pandya <[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]>
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]>
Co-authored-by: Shrey Pandya <[email protected]>
<!-- 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 (#3497) <!-- CURSOR_AGENT_PR_BODY_BEGIN --> ## 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 to `withBrowserbaseApi` to preserve `requestHadHttpResponse` tracking ## Stack 1. #3495 — SDK bump ← **base** 2. **This PR** — Migrate contexts and extensions commands 3. #3481 — Add search filtering options and migrate search to SDK <!-- 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 Migrates the CLI's `contexts` and `extensions` commands from raw HTTP calls to the Browserbase SDK client methods. - `contexts delete` and `contexts update` now use `client.contexts.delete` and `client.contexts.update`. - `extensions delete` now uses `client.extensions.delete`. - `withBrowserbaseApi` now sets `requestHadHttpResponse: true` and `httpStatus: 200` on success so telemetry tracking from the old raw HTTP calls is preserved. <sup>Written for commit 6582ab6. Summary will update on new commits.</sup> <a href="https://cubic.dev/pr/browserbase/stagehand/pull/3497?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/3497?returnTo=https%3A%2F%2Fgithub.com%2Fbrowserbase%2Fstagehand%2Fpull%2F3497&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]>
Release Browse independently of the Stagehand SDKs. Merging this PR publishes the CLI from the merged commit. ## 0.12.0 ### Minor Changes - [#3482](#3482) [`8901460`](8901460) Thanks [@suyashguptasg](https://github.com/suyashguptasg)! - Add `--size regular|large|xlarge` to `browse cloud sessions create` to select the browser size. - [#3499](#3499) [`a5a19ea`](a5a19ea) Thanks [@shrey150](https://github.com/shrey150)! - Remove deprecated `browse cloud contexts update`; context uploads are no longer supported. ### Patch Changes - [#3450](#3450) [`c118e9c`](c118e9c) Thanks [@shrey150](https://github.com/shrey150)! - Add `browse discord` command to open the Stagehand Discord in your system browser - [#3473](#3473) [`0f9a64c`](0f9a64c) Thanks [@github-actions](https://github.com/apps/github-actions)! - fix the CLI printing replacement characters when a daemon reply splits a multi-byte character across socket chunks - [#3451](#3451) [`902e91b`](902e91b) Thanks [@shrey150](https://github.com/shrey150)! - Add Discord and GitHub links to root help footer and support hints on unexpected errors - [#3481](#3481) [`ebf15c8`](ebf15c8) Thanks [@shrey150](https://github.com/shrey150)! - Add search filtering options and migrate cloud commands to the Browserbase SDK. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
Adds support for new Browserbase Search API parameters and migrates the search command to use the SDK.
SDK Migration
Migrates
browse cloud searchfrom raw HTTP toclient.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
--provideris omitted, the API auto-routes to a provider that supports your params. Validation checks that apply to Parallel are only enforced when--provider parallelis explicit. For deep/deep-lite modes, the CLI automatically infers--provider exa.Validation Improvements
Stack
Files Changed
packages/cli/src/commands/cloud/search.ts— SDK migration + new flagspackages/cli/skills/browse/SKILL.md— updated docs with new paramspackages/cli/tests/cli-cloud-contract.test.ts— comprehensive tests.changeset/search-api-params.md— changesetSummary by cubic
Adds the new Browserbase Search API parameters to
browse cloud searchwith 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 supportsdeep-liteanddeepmodes, responses includeproviderandmodefields, and--excerptsreturns relevant passages in JSON and table output.New Features
--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.--provider.@browserbasehq/sdkto ^2.28.0;search,contexts delete/update, andextensions deletenow use SDK client methods.requestHadHttpResponsetelemetry like the raw HTTP calls they replaced.Validation
--end-published-date.--moderationis rejected only with an explicit--provider parallel;--no-moderationremains allowed.Written for commit b3738c2. Summary will update on new commits.