Skip to content

Update AI Search binding types to match implementation#6541

Merged
npaun merged 1 commit intocloudflare:mainfrom
G4brym:gmassadas/update-ai-search-binding-types
Apr 15, 2026
Merged

Update AI Search binding types to match implementation#6541
npaun merged 1 commit intocloudflare:mainfrom
G4brym:gmassadas/update-ai-search-binding-types

Conversation

@G4brym
Copy link
Copy Markdown
Member

@G4brym G4brym commented Apr 9, 2026

Summary

Syncs types/defines/ai-search.d.ts (and generated snapshots) with the actual AI Search binding entrypoint implementation. The workerd type definitions had fallen behind, missing several methods, type variants, and fields that the binding already supports.

New methods

  • AiSearchNamespace: search(), chatCompletions() for multi-instance fan-out; list() now accepts pagination/search/ordering params
  • AiSearchItem: sync() (trigger re-indexing), logs() (processing logs), chunks() (indexed chunks)
  • AiSearchJob: cancel() (cancel running job)

New types

  • AiSearchMessage, AiSearchOptions (shared across requests)
  • AiSearchMultiSearchRequest/Response, AiSearchMultiChatCompletionsRequest/Response (namespace fan-out)
  • AiSearchListInstancesParams (instance list pagination/search/ordering)
  • AiSearchItemLogsParams/Log/Response, AiSearchItemChunksParams/Chunk/Response (item sub-resources)

Type expansions

  • AiSearchSearchRequest: now a discriminated union supporting both { query: string } and { messages: [...] }
  • AiSearchOptions.retrieval: added fusion_method, keyword_match_mode, metadata_only, return_on_failure, boost_by
  • AiSearchOptions: added cache sub-object
  • AiSearchStatsResponse: added engine field (vectorize/r2 storage stats)
  • AiSearchInstanceInfo: expanded from 8 to 25+ typed fields
  • AiSearchConfig: expanded from 11 to 22+ typed fields
  • AiSearchListItemsParams: added search, sort_by, status, source, metadata_filter
  • scoring_details: added keyword_rank, vector_rank, reranking_score, fusion_method
  • upload()/uploadAndPoll(): content type now includes Blob; poll options added (pollIntervalMs, timeoutMs)

Fixes

  • AiSearchItemInfo.status: 'processing''running' (matches actual API response)
  • AiSearchItemInfo: added missing fields (next_action, error, checksum, chunks_count, file_size, etc.)

@G4brym G4brym force-pushed the gmassadas/update-ai-search-binding-types branch 3 times, most recently from 289a8a4 to eb14f4d Compare April 9, 2026 14:45
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 9, 2026

Merging this PR will not alter performance

✅ 72 untouched benchmarks
⏩ 129 skipped benchmarks1


Comparing G4brym:gmassadas/update-ai-search-binding-types (f62f8dd) with main (e899a92)

Open in CodSpeed

Footnotes

  1. 129 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@G4brym G4brym force-pushed the gmassadas/update-ai-search-binding-types branch 3 times, most recently from 30a017f to f7eacf0 Compare April 9, 2026 15:31
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.92%. Comparing base (e899a92) to head (f62f8dd).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6541   +/-   ##
=======================================
  Coverage   70.92%   70.92%           
=======================================
  Files         438      438           
  Lines      123626   123626           
  Branches    19450    19450           
=======================================
  Hits        87685    87685           
  Misses      24403    24403           
  Partials    11538    11538           

☔ 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 force-pushed the gmassadas/update-ai-search-binding-types branch from f7eacf0 to 631b577 Compare April 13, 2026 16:34
@G4brym G4brym marked this pull request as ready for review April 13, 2026 18:53
@G4brym G4brym requested review from a team as code owners April 13, 2026 18:53
@G4brym G4brym requested a review from edmundhung April 13, 2026 18:53
@G4brym G4brym force-pushed the gmassadas/update-ai-search-binding-types branch 2 times, most recently from 1193fc7 to 06bb66f Compare April 14, 2026 14:34
Sync ai-search.d.ts with the binding-entrypoint implementation:

- Add query variant to AiSearchSearchRequest (discriminated union)
- Add AiSearchNamespace.search()/chatCompletions() for multi-instance fan-out
- Add AiSearchNamespace.list() params (pagination, search, ordering)
- Add AiSearchItem.sync(), logs(), chunks() methods
- Add AiSearchJob.cancel() method
- Add AiSearchOptions with full retrieval, cache, reranking, query_rewrite fields
- Expand AiSearchConfig and AiSearchInstanceInfo with all typed fields
- Expand AiSearchListItemsParams with search, sort, status, source, metadata filters
- Expand scoring_details with keyword_rank, vector_rank, reranking_score, fusion_method
- Add engine stats (vectorize/r2) to AiSearchStatsResponse
- Fix AiSearchItemInfo.status: 'processing' -> 'running'
- Add Blob to upload() content type, poll options to uploadAndPoll()
- Add missing types: Multi-search/chat, item logs/chunks, list instance params
- Update generated snapshots (latest + experimental)
@G4brym G4brym force-pushed the gmassadas/update-ai-search-binding-types branch from 06bb66f to f62f8dd Compare April 14, 2026 16:16
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.

Assuming that these types accurately match the runtime code in the product - LGTM

@petebacondarwin petebacondarwin removed the request for review from edmundhung April 15, 2026 08:49
@npaun npaun merged commit 792a571 into cloudflare:main Apr 15, 2026
26 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.

6 participants