RAG-1300: Add Web Search binding types#6768
Draft
G4brym wants to merge 1 commit into
Draft
Conversation
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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
Adds TypeScript type definitions for the new
web_searchWorkers binding:WebSearch— abstract class with singlesearch()methodWebSearchSearchOptions—query+ optionallimitWebSearchResult—url,title,description?,type,authors?,thumbnailUrl?,faviconUrl?WebSearchSearchResponse—results+ per-responsemetadata(query,requestId,latencyMs)The container types are named
WebSearchSearchOptions/WebSearchSearchResponseto avoid a name collision with the pre-existingWebSearchOptionstype inai.d.ts(used by the OpenAI-compatibleweb_search_optionsfield on Workers AI chat completions).Design
Discovery-only by design — no
snippets,content, orscoringDetailsfields. Aligns with Cloudflare Pay-per-Crawl: callers fetch URLs themselves via the globalfetch()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— greenlatest+experimentalsnapshots includedCompanion changes
web_searchbinding kind, reader, authorizer, and SubPipeline targetingWebSearchEntrypointWebSearchwebsearch-workerapp (WebSearchEntrypointphase-1 echo)