Skip to content

RAG-1300: Add Web Search binding types#6768

Draft
G4brym wants to merge 1 commit into
cloudflare:mainfrom
G4brym:gmassadas/web-search-binding-types
Draft

RAG-1300: Add Web Search binding types#6768
G4brym wants to merge 1 commit into
cloudflare:mainfrom
G4brym:gmassadas/web-search-binding-types

Conversation

@G4brym
Copy link
Copy Markdown
Member

@G4brym G4brym commented May 18, 2026

Summary

Adds TypeScript type definitions for the new web_search Workers binding:

  • WebSearch — abstract class with single search() method
  • WebSearchSearchOptionsquery + optional limit
  • WebSearchResulturl, title, description?, type, authors?, thumbnailUrl?, faviconUrl?
  • WebSearchSearchResponseresults + per-response metadata (query, requestId, latencyMs)

The container types are named WebSearchSearchOptions / WebSearchSearchResponse to avoid a name collision with the pre-existing WebSearchOptions type in ai.d.ts (used by the OpenAI-compatible web_search_options field on Workers AI chat completions).

Design

Discovery-only by design — no snippets, content, or scoringDetails fields. Aligns with Cloudflare Pay-per-Crawl: callers fetch URLs themselves via the global fetch() API if they need bodies, at which point publisher access controls apply.

The wrangler binding is declared as a single object (not an array) — there is exactly one shared web corpus, so there is no name, namespace, or instance to specify:

{ "web_search": { "binding": "WEBSEARCH" } }

Verification

  • bazel build //types:types — green
  • Regenerated latest + experimental snapshots included

Companion changes

  • edgeworker-config-serviceweb_search binding kind, reader, authorizer, and SubPipeline targeting WebSearchEntrypoint
  • workers-sdk — wrangler config schema, validation, miniflare plugin, type generation emitting WebSearch
  • websearch-monorepowebsearch-worker app (WebSearchEntrypoint phase-1 echo)

Adds TypeScript type definitions for the new `web_search` binding kind:

- WebSearch (abstract class with single `search()` method)
- WebSearchSearchOptions (query + optional limit)
- WebSearchResult (url, title, description?, type, authors?,
  thumbnailUrl?, faviconUrl?)
- WebSearchSearchResponse (results + per-response metadata)

The container types are named `WebSearchSearchOptions` /
`WebSearchSearchResponse` to avoid a name collision with the
pre-existing `WebSearchOptions` type in ai.d.ts (used by the
OpenAI-compatible `web_search_options` field on Workers AI chat
completions).

Discovery-only by design: no `snippets`, `content`, or
`scoringDetails` fields. Pay-per-Crawl alignment -- callers fetch
URLs themselves via the global `fetch()` API if they need bodies.

Includes regenerated generated-snapshot files for latest +
experimental.
@G4brym G4brym requested review from a team as code owners May 18, 2026 16:04
@G4brym G4brym requested a review from james-elicx May 18, 2026 16:04
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.62%. Comparing base (e899a92) to head (bc9c1b2).
⚠️ Report is 261 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6768      +/-   ##
==========================================
- Coverage   70.92%   66.62%   -4.30%     
==========================================
  Files         438      402      -36     
  Lines      123626   115914    -7712     
  Branches    19450    19425      -25     
==========================================
- Hits        87685    77231   -10454     
- Misses      24403    27094    +2691     
- Partials    11538    11589      +51     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@G4brym G4brym changed the title Add Web Search binding types RAG-1300: Add Web Search binding types May 18, 2026
@G4brym G4brym marked this pull request as draft May 18, 2026 17:09
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.

2 participants