Skip to content

RAG-1300: Add Web Search binding types#6768

Merged
danlapid merged 1 commit into
cloudflare:mainfrom
G4brym:gmassadas/web-search-binding-types
May 21, 2026
Merged

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

Conversation

@G4brym
Copy link
Copy Markdown
Member

@G4brym G4brym commented May 18, 2026

Adds TypeScript types for the new web_search Workers binding.

  • WebSearch.search({ query, limit? }){ items, metadata }
  • WebSearchResult: url, title, description?, lastModifiedDate?, imageUrl?, faviconUrl?
  • WebSearchResponseMetadata: query, requestId, latencyMs
  • limit defaults to 10, capped at 20

Discovery-only — no page bodies. Callers fetch() URLs themselves; Pay-per-Crawl and publisher controls apply at the fetch site.

Wrangler binding is a single object (one shared web corpus, no namespace/instance):

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

Snapshot also contains a 2-line ChatCompletionsBase fix on Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT.inputs — matches what bazel generates from current ai.d.ts; needed for check-snapshot to pass. Pre-existing drift from fff20c4f0. Happy to split out if preferred.

@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-commenter commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.62%. Comparing base (fff20c4) to head (279db6b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6768   +/-   ##
=======================================
  Coverage   66.62%   66.62%           
=======================================
  Files         402      402           
  Lines      115914   115914           
  Branches    19425    19425           
=======================================
  Hits        77231    77231           
  Misses      27094    27094           
  Partials    11589    11589           

☔ 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
@G4brym G4brym force-pushed the gmassadas/web-search-binding-types branch 2 times, most recently from fd21008 to 64e0c6a Compare May 21, 2026 09:25
@G4brym G4brym marked this pull request as ready for review May 21, 2026 09:27
@G4brym G4brym force-pushed the gmassadas/web-search-binding-types branch from 64e0c6a to ed7419c Compare May 21, 2026 09:32
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?, lastModifiedDate?,
  imageUrl?, faviconUrl?)
- WebSearchResponseMetadata (query, requestId, latencyMs)
- WebSearchSearchResponse ({ items, 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.

`lastModifiedDate` is exposed as a naive ISO-8601 datetime string
(e.g. `"2025-11-30T04:39:48"`) when the upstream catalog knows it.

Snapshots are the upstream baseline with only the appended
`defines/web-search.d.ts` block; they were not full-regenerated to
avoid sweeping in unrelated drift.
@G4brym G4brym force-pushed the gmassadas/web-search-binding-types branch from ed7419c to 279db6b Compare May 21, 2026 09:40
Copy link
Copy Markdown
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

types look fine - should unblock miniflare stuff?

@G4brym
Copy link
Copy Markdown
Member Author

G4brym commented May 21, 2026

types look fine - should unblock miniflare stuff?

this will be a remote only binding, so this pr can wait for the repo to be unlocked. meanwhile on workers sdk repo we can continue without typegen

@danlapid danlapid merged commit 69229c2 into cloudflare:main May 21, 2026
21 of 23 checks passed
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.

5 participants