@cloudflare/workers-types 4.20260415.1 → 4.20260416.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2417,12 +2417,12 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2417
2417
  }
2418
2418
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2419
2419
  interface Queue<Body = unknown> {
2420
+ metrics(): Promise<QueueMetrics>;
2420
2421
  send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2421
2422
  sendBatch(
2422
2423
  messages: Iterable<MessageSendRequest<Body>>,
2423
2424
  options?: QueueSendBatchOptions,
2424
2425
  ): Promise<QueueSendBatchResponse>;
2425
- metrics(): Promise<QueueMetrics>;
2426
2426
  }
2427
2427
  interface QueueSendMetrics {
2428
2428
  backlogCount: number;
@@ -4710,73 +4710,145 @@ interface EventCounts {
4710
4710
  // ============ AI Search Error Interfaces ============
4711
4711
  interface AiSearchInternalError extends Error {}
4712
4712
  interface AiSearchNotFoundError extends Error {}
4713
- // ============ AI Search Request Types ============
4714
- type AiSearchSearchRequest = {
4715
- messages: Array<{
4716
- role: "system" | "developer" | "user" | "assistant" | "tool";
4717
- content: string | null;
4718
- }>;
4719
- ai_search_options?: {
4720
- retrieval?: {
4721
- retrieval_type?: "vector" | "keyword" | "hybrid";
4722
- /** Match threshold (0-1, default 0.4) */
4723
- match_threshold?: number;
4724
- /** Maximum number of results (1-50, default 10) */
4725
- max_num_results?: number;
4726
- filters?: VectorizeVectorMetadataFilter;
4727
- /** Context expansion (0-3, default 0) */
4728
- context_expansion?: number;
4729
- [key: string]: unknown;
4730
- };
4731
- query_rewrite?: {
4732
- enabled?: boolean;
4733
- model?: string;
4734
- rewrite_prompt?: string;
4735
- [key: string]: unknown;
4736
- };
4737
- reranking?: {
4738
- enabled?: boolean;
4739
- model?: "@cf/baai/bge-reranker-base" | string;
4740
- /** Match threshold (0-1, default 0.4) */
4741
- match_threshold?: number;
4742
- [key: string]: unknown;
4743
- };
4713
+ // ============ AI Search Common Types ============
4714
+ /** A single message in a conversation-style search or chat request. */
4715
+ type AiSearchMessage = {
4716
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4717
+ content: string | null;
4718
+ };
4719
+ /**
4720
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4721
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4722
+ */
4723
+ type AiSearchOptions = {
4724
+ retrieval?: {
4725
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4726
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4727
+ /** Fusion method for combining vector + keyword results. */
4728
+ fusion_method?: "max" | "rrf";
4729
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4730
+ keyword_match_mode?: "and" | "or";
4731
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4732
+ match_threshold?: number;
4733
+ /** Maximum number of results to return (1-50). Default 10. */
4734
+ max_num_results?: number;
4735
+ /** Vectorize metadata filters applied to the search. */
4736
+ filters?: VectorizeVectorMetadataFilter;
4737
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4738
+ context_expansion?: number;
4739
+ /** If true, return only item metadata without chunk text. */
4740
+ metadata_only?: boolean;
4741
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4742
+ return_on_failure?: boolean;
4743
+ /** Boost results by metadata field values. Max 3 entries. */
4744
+ boost_by?: Array<{
4745
+ field: string;
4746
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4747
+ }>;
4748
+ [key: string]: unknown;
4749
+ };
4750
+ query_rewrite?: {
4751
+ enabled?: boolean;
4752
+ model?: string;
4753
+ rewrite_prompt?: string;
4754
+ [key: string]: unknown;
4755
+ };
4756
+ reranking?: {
4757
+ enabled?: boolean;
4758
+ model?: string;
4759
+ /** Match threshold (0-1, default 0.4) */
4760
+ match_threshold?: number;
4744
4761
  [key: string]: unknown;
4745
4762
  };
4763
+ cache?: {
4764
+ enabled?: boolean;
4765
+ cache_threshold?:
4766
+ | "super_strict_match"
4767
+ | "close_enough"
4768
+ | "flexible_friend"
4769
+ | "anything_goes";
4770
+ };
4771
+ [key: string]: unknown;
4746
4772
  };
4773
+ // ============ AI Search Request Types ============
4774
+ /**
4775
+ * Request body for single-instance search.
4776
+ * Exactly one of `query` or `messages` must be provided.
4777
+ */
4778
+ type AiSearchSearchRequest =
4779
+ | {
4780
+ /** Simple query string. */
4781
+ query: string;
4782
+ messages?: never;
4783
+ ai_search_options?: AiSearchOptions;
4784
+ }
4785
+ | {
4786
+ query?: never;
4787
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4788
+ messages: AiSearchMessage[];
4789
+ ai_search_options?: AiSearchOptions;
4790
+ };
4747
4791
  type AiSearchChatCompletionsRequest = {
4748
- messages: Array<{
4749
- role: "system" | "developer" | "user" | "assistant" | "tool";
4750
- content: string | null;
4751
- [key: string]: unknown;
4752
- }>;
4792
+ messages: AiSearchMessage[];
4753
4793
  model?: string;
4754
4794
  stream?: boolean;
4755
- ai_search_options?: {
4756
- retrieval?: {
4757
- retrieval_type?: "vector" | "keyword" | "hybrid";
4758
- match_threshold?: number;
4759
- max_num_results?: number;
4760
- filters?: VectorizeVectorMetadataFilter;
4761
- context_expansion?: number;
4762
- [key: string]: unknown;
4763
- };
4764
- query_rewrite?: {
4765
- enabled?: boolean;
4766
- model?: string;
4767
- rewrite_prompt?: string;
4768
- [key: string]: unknown;
4769
- };
4770
- reranking?: {
4771
- enabled?: boolean;
4772
- model?: "@cf/baai/bge-reranker-base" | string;
4773
- match_threshold?: number;
4774
- [key: string]: unknown;
4775
- };
4776
- [key: string]: unknown;
4777
- };
4795
+ ai_search_options?: AiSearchOptions;
4778
4796
  [key: string]: unknown;
4779
4797
  };
4798
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4799
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4800
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4801
+ /** Instance IDs to search across (1-10). */
4802
+ instance_ids: string[];
4803
+ };
4804
+ /**
4805
+ * Request for searching across multiple instances within a namespace.
4806
+ * `ai_search_options` is required and must include `instance_ids`.
4807
+ * Exactly one of `query` or `messages` must be provided.
4808
+ */
4809
+ type AiSearchMultiSearchRequest =
4810
+ | {
4811
+ /** Simple query string. */
4812
+ query: string;
4813
+ messages?: never;
4814
+ ai_search_options: AiSearchMultiSearchOptions;
4815
+ }
4816
+ | {
4817
+ query?: never;
4818
+ /** Conversation-style input. */
4819
+ messages: AiSearchMessage[];
4820
+ ai_search_options: AiSearchMultiSearchOptions;
4821
+ };
4822
+ /** A search result chunk tagged with the instance it originated from. */
4823
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4824
+ instance_id: string;
4825
+ };
4826
+ /** Describes a per-instance error during a multi-instance operation. */
4827
+ type AiSearchMultiSearchError = {
4828
+ instance_id: string;
4829
+ message: string;
4830
+ };
4831
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4832
+ type AiSearchMultiSearchResponse = {
4833
+ search_query: string;
4834
+ chunks: AiSearchMultiSearchChunk[];
4835
+ errors?: AiSearchMultiSearchError[];
4836
+ };
4837
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4838
+ type AiSearchMultiChatCompletionsRequest = Omit<
4839
+ AiSearchChatCompletionsRequest,
4840
+ "ai_search_options"
4841
+ > & {
4842
+ ai_search_options: AiSearchMultiSearchOptions;
4843
+ };
4844
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4845
+ type AiSearchMultiChatCompletionsResponse = Omit<
4846
+ AiSearchChatCompletionsResponse,
4847
+ "chunks"
4848
+ > & {
4849
+ chunks: AiSearchMultiSearchChunk[];
4850
+ errors?: AiSearchMultiSearchError[];
4851
+ };
4780
4852
  // ============ AI Search Response Types ============
4781
4853
  type AiSearchSearchResponse = {
4782
4854
  search_query: string;
@@ -4796,6 +4868,14 @@ type AiSearchSearchResponse = {
4796
4868
  keyword_score?: number;
4797
4869
  /** Vector similarity score (0-1) */
4798
4870
  vector_score?: number;
4871
+ /** Keyword rank position */
4872
+ keyword_rank?: number;
4873
+ /** Vector rank position */
4874
+ vector_rank?: number;
4875
+ /** Reranking model score */
4876
+ reranking_score?: number;
4877
+ /** Fusion method used to combine results */
4878
+ fusion_method?: "rrf" | "max";
4799
4879
  [key: string]: unknown;
4800
4880
  };
4801
4881
  }>;
@@ -4824,19 +4904,88 @@ type AiSearchStatsResponse = {
4824
4904
  skipped?: number;
4825
4905
  outdated?: number;
4826
4906
  last_activity?: string;
4907
+ /** Storage engine statistics. */
4908
+ engine?: {
4909
+ vectorize?: {
4910
+ vectorsCount: number;
4911
+ dimensions: number;
4912
+ };
4913
+ r2?: {
4914
+ payloadSizeBytes: number;
4915
+ metadataSizeBytes: number;
4916
+ objectCount: number;
4917
+ };
4918
+ };
4827
4919
  };
4828
4920
  // ============ AI Search Instance Info Types ============
4829
4921
  type AiSearchInstanceInfo = {
4830
4922
  id: string;
4831
4923
  type?: "r2" | "web-crawler" | string;
4832
4924
  source?: string;
4925
+ source_params?: unknown;
4833
4926
  paused?: boolean;
4834
4927
  status?: string;
4835
4928
  namespace?: string;
4836
4929
  created_at?: string;
4837
4930
  modified_at?: string;
4931
+ token_id?: string;
4932
+ ai_gateway_id?: string;
4933
+ rewrite_query?: boolean;
4934
+ reranking?: boolean;
4935
+ embedding_model?: string;
4936
+ ai_search_model?: string;
4937
+ rewrite_model?: string;
4938
+ reranking_model?: string;
4939
+ /** @deprecated Use index_method instead. */
4940
+ hybrid_search_enabled?: boolean;
4941
+ /** Controls which storage backends are active. */
4942
+ index_method?: {
4943
+ vector?: boolean;
4944
+ keyword?: boolean;
4945
+ };
4946
+ /** Fusion method for combining vector and keyword results. */
4947
+ fusion_method?: "max" | "rrf";
4948
+ indexing_options?: {
4949
+ keyword_tokenizer?: "porter" | "trigram";
4950
+ } | null;
4951
+ retrieval_options?: {
4952
+ keyword_match_mode?: "and" | "or";
4953
+ boost_by?: Array<{
4954
+ field: string;
4955
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4956
+ }>;
4957
+ } | null;
4958
+ chunk?: boolean;
4959
+ chunk_size?: number;
4960
+ chunk_overlap?: number;
4961
+ score_threshold?: number;
4962
+ max_num_results?: number;
4963
+ cache?: boolean;
4964
+ cache_threshold?:
4965
+ | "super_strict_match"
4966
+ | "close_enough"
4967
+ | "flexible_friend"
4968
+ | "anything_goes";
4969
+ custom_metadata?: Array<{
4970
+ field_name: string;
4971
+ data_type: "text" | "number" | "boolean" | "datetime";
4972
+ }>;
4973
+ /** Sync interval in seconds. */
4974
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4975
+ metadata?: Record<string, unknown>;
4838
4976
  [key: string]: unknown;
4839
4977
  };
4978
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4979
+ type AiSearchListInstancesParams = {
4980
+ page?: number;
4981
+ per_page?: number;
4982
+ /** Search instances by ID. */
4983
+ search?: string;
4984
+ /** Field to sort by. */
4985
+ order_by?: "created_at";
4986
+ /** Sort direction. */
4987
+ order_by_direction?: "asc" | "desc";
4988
+ };
4840
4989
  type AiSearchListResponse = {
4841
4990
  result: AiSearchInstanceInfo[];
4842
4991
  result_info?: {
@@ -4864,19 +5013,64 @@ type AiSearchConfig = {
4864
5013
  reranking?: boolean;
4865
5014
  embedding_model?: string;
4866
5015
  ai_search_model?: string;
5016
+ rewrite_model?: string;
5017
+ reranking_model?: string;
5018
+ /** @deprecated Use index_method instead. */
5019
+ hybrid_search_enabled?: boolean;
5020
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
5021
+ index_method?: {
5022
+ vector?: boolean;
5023
+ keyword?: boolean;
5024
+ };
5025
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
5026
+ fusion_method?: "max" | "rrf";
5027
+ indexing_options?: {
5028
+ keyword_tokenizer?: "porter" | "trigram";
5029
+ } | null;
5030
+ retrieval_options?: {
5031
+ keyword_match_mode?: "and" | "or";
5032
+ boost_by?: Array<{
5033
+ field: string;
5034
+ direction?: "asc" | "desc" | "exists" | "not_exists";
5035
+ }>;
5036
+ } | null;
5037
+ chunk?: boolean;
5038
+ chunk_size?: number;
5039
+ chunk_overlap?: number;
5040
+ /** Minimum similarity score (0-1) for a result to be included. */
5041
+ score_threshold?: number;
5042
+ max_num_results?: number;
5043
+ cache?: boolean;
5044
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
5045
+ cache_threshold?:
5046
+ | "super_strict_match"
5047
+ | "close_enough"
5048
+ | "flexible_friend"
5049
+ | "anything_goes";
5050
+ custom_metadata?: Array<{
5051
+ field_name: string;
5052
+ data_type: "text" | "number" | "boolean" | "datetime";
5053
+ }>;
5054
+ namespace?: string;
5055
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
5056
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5057
+ metadata?: Record<string, unknown>;
4867
5058
  [key: string]: unknown;
4868
5059
  };
4869
5060
  // ============ AI Search Item Types ============
4870
5061
  type AiSearchItemInfo = {
4871
5062
  id: string;
4872
5063
  key: string;
4873
- status:
4874
- | "completed"
4875
- | "error"
4876
- | "skipped"
4877
- | "queued"
4878
- | "processing"
4879
- | "outdated";
5064
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
5065
+ next_action?: "INDEX" | "DELETE" | null;
5066
+ error?: string;
5067
+ checksum?: string;
5068
+ namespace?: string;
5069
+ chunks_count?: number | null;
5070
+ file_size?: number | null;
5071
+ source_id?: string | null;
5072
+ last_seen_at?: string;
5073
+ created_at?: string;
4880
5074
  metadata?: Record<string, unknown>;
4881
5075
  [key: string]: unknown;
4882
5076
  };
@@ -4892,6 +5086,22 @@ type AiSearchUploadItemOptions = {
4892
5086
  type AiSearchListItemsParams = {
4893
5087
  page?: number;
4894
5088
  per_page?: number;
5089
+ /** Search items by key name. */
5090
+ search?: string;
5091
+ /** Sort order for results. */
5092
+ sort_by?: "status" | "modified_at";
5093
+ /** Filter items by processing status. */
5094
+ status?:
5095
+ | "queued"
5096
+ | "running"
5097
+ | "completed"
5098
+ | "error"
5099
+ | "skipped"
5100
+ | "outdated";
5101
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
5102
+ source?: string;
5103
+ /** JSON-encoded Vectorize filter for metadata filtering. */
5104
+ metadata_filter?: string;
4895
5105
  };
4896
5106
  type AiSearchListItemsResponse = {
4897
5107
  result: AiSearchItemInfo[];
@@ -4902,6 +5112,61 @@ type AiSearchListItemsResponse = {
4902
5112
  total_count: number;
4903
5113
  };
4904
5114
  };
5115
+ // ============ AI Search Item Logs Types ============
5116
+ type AiSearchItemLogsParams = {
5117
+ /** Maximum number of log entries to return (1-100, default 50). */
5118
+ limit?: number;
5119
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
5120
+ cursor?: string;
5121
+ };
5122
+ type AiSearchItemLog = {
5123
+ timestamp: string;
5124
+ action: string;
5125
+ message: string;
5126
+ fileKey?: string;
5127
+ chunkCount?: number;
5128
+ processingTimeMs?: number;
5129
+ errorType?: string;
5130
+ };
5131
+ /** Paginated response for item processing logs (cursor-based). */
5132
+ type AiSearchItemLogsResponse = {
5133
+ result: AiSearchItemLog[];
5134
+ result_info: {
5135
+ count: number;
5136
+ per_page: number;
5137
+ cursor: string | null;
5138
+ truncated: boolean;
5139
+ };
5140
+ };
5141
+ // ============ AI Search Item Chunks Types ============
5142
+ type AiSearchItemChunksParams = {
5143
+ /** Maximum number of chunks to return (1-100, default 20). */
5144
+ limit?: number;
5145
+ /** Offset into the chunks list (default 0). */
5146
+ offset?: number;
5147
+ };
5148
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
5149
+ type AiSearchItemChunk = {
5150
+ id: string;
5151
+ text: string;
5152
+ start_byte: number;
5153
+ end_byte: number;
5154
+ item?: {
5155
+ timestamp?: number;
5156
+ key: string;
5157
+ metadata?: Record<string, unknown>;
5158
+ };
5159
+ };
5160
+ /** Paginated response for item chunks (offset-based). */
5161
+ type AiSearchItemChunksResponse = {
5162
+ result: AiSearchItemChunk[];
5163
+ result_info: {
5164
+ count: number;
5165
+ total: number;
5166
+ limit: number;
5167
+ offset: number;
5168
+ };
5169
+ };
4905
5170
  // ============ AI Search Job Types ============
4906
5171
  type AiSearchJobInfo = {
4907
5172
  id: string;
@@ -4950,7 +5215,7 @@ type AiSearchJobLogsResponse = {
4950
5215
  // ============ AI Search Sub-Service Classes ============
4951
5216
  /**
4952
5217
  * Single item service for an AI Search instance.
4953
- * Provides info, delete, and download operations on a specific item.
5218
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4954
5219
  */
4955
5220
  declare abstract class AiSearchItem {
4956
5221
  /** Get metadata about this item. */
@@ -4960,6 +5225,25 @@ declare abstract class AiSearchItem {
4960
5225
  * @returns Object with body stream, content type, filename, and size.
4961
5226
  */
4962
5227
  download(): Promise<AiSearchItemContentResult>;
5228
+ /**
5229
+ * Trigger re-indexing of this item.
5230
+ * @returns The updated item info.
5231
+ */
5232
+ sync(): Promise<AiSearchItemInfo>;
5233
+ /**
5234
+ * Retrieve processing logs for this item (cursor-based pagination).
5235
+ * @param params Optional pagination parameters (limit, cursor).
5236
+ * @returns Paginated log entries for this item.
5237
+ */
5238
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
5239
+ /**
5240
+ * List indexed chunks for this item (offset-based pagination).
5241
+ * @param params Optional pagination parameters (limit, offset).
5242
+ * @returns Paginated chunk entries for this item.
5243
+ */
5244
+ chunks(
5245
+ params?: AiSearchItemChunksParams,
5246
+ ): Promise<AiSearchItemChunksResponse>;
4963
5247
  }
4964
5248
  /**
4965
5249
  * Items collection service for an AI Search instance.
@@ -4969,49 +5253,64 @@ declare abstract class AiSearchItems {
4969
5253
  /** List items in this instance. */
4970
5254
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4971
5255
  /**
4972
- * Upload a file as an item.
5256
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
5257
+ * filename already exists, it is overwritten and re-indexed.
4973
5258
  * @param name Filename for the uploaded item.
4974
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
5259
+ * @param content File content as a ReadableStream, Blob, or string.
4975
5260
  * @param options Optional metadata to attach to the item.
4976
5261
  * @returns The created item info.
4977
5262
  */
4978
5263
  upload(
4979
5264
  name: string,
4980
- content: ReadableStream | ArrayBuffer | string,
5265
+ content: ReadableStream | Blob | string,
4981
5266
  options?: AiSearchUploadItemOptions,
4982
5267
  ): Promise<AiSearchItemInfo>;
4983
5268
  /**
4984
5269
  * Upload a file and poll until processing completes.
5270
+ * Behaves as an upsert: if an item with the same filename already exists,
5271
+ * it is overwritten and re-indexed.
4985
5272
  * @param name Filename for the uploaded item.
4986
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4987
- * @param options Optional metadata to attach to the item.
5273
+ * @param content File content as a ReadableStream, Blob, or string.
5274
+ * @param options Optional metadata and polling configuration.
4988
5275
  * @returns The item info after processing completes (or timeout).
4989
5276
  */
4990
5277
  uploadAndPoll(
4991
5278
  name: string,
4992
- content: ReadableStream | ArrayBuffer | string,
4993
- options?: AiSearchUploadItemOptions,
5279
+ content: ReadableStream | Blob | string,
5280
+ options?: AiSearchUploadItemOptions & {
5281
+ /** Polling interval in milliseconds (default 1000). */
5282
+ pollIntervalMs?: number;
5283
+ /** Maximum time to wait in milliseconds (default 30000). */
5284
+ timeoutMs?: number;
5285
+ },
4994
5286
  ): Promise<AiSearchItemInfo>;
4995
5287
  /**
4996
5288
  * Get an item by ID.
4997
5289
  * @param itemId The item identifier.
4998
- * @returns Item service for info, delete, and download operations.
5290
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4999
5291
  */
5000
5292
  get(itemId: string): AiSearchItem;
5001
- /** Delete this item from the instance.
5293
+ /**
5294
+ * Delete an item from the instance.
5002
5295
  * @param itemId The item identifier.
5003
5296
  */
5004
5297
  delete(itemId: string): Promise<void>;
5005
5298
  }
5006
5299
  /**
5007
5300
  * Single job service for an AI Search instance.
5008
- * Provides info and logs for a specific job.
5301
+ * Provides info, logs, and cancel operations for a specific job.
5009
5302
  */
5010
5303
  declare abstract class AiSearchJob {
5011
5304
  /** Get metadata about this job. */
5012
5305
  info(): Promise<AiSearchJobInfo>;
5013
5306
  /** Get logs for this job. */
5014
5307
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
5308
+ /**
5309
+ * Cancel a running job.
5310
+ * @returns The updated job info.
5311
+ * @throws AiSearchNotFoundError if the job does not exist.
5312
+ */
5313
+ cancel(): Promise<AiSearchJobInfo>;
5015
5314
  }
5016
5315
  /**
5017
5316
  * Jobs collection service for an AI Search instance.
@@ -5029,7 +5328,7 @@ declare abstract class AiSearchJobs {
5029
5328
  /**
5030
5329
  * Get a job by ID.
5031
5330
  * @param jobId The job identifier.
5032
- * @returns Job service for info and logs operations.
5331
+ * @returns Job service for info, logs, and cancel operations.
5033
5332
  */
5034
5333
  get(jobId: string): AiSearchJob;
5035
5334
  }
@@ -5048,7 +5347,7 @@ declare abstract class AiSearchJobs {
5048
5347
  * // Via namespace binding
5049
5348
  * const instance = env.AI_SEARCH.get("blog");
5050
5349
  * const results = await instance.search({
5051
- * messages: [{ role: "user", content: "How does caching work?" }],
5350
+ * query: "How does caching work?",
5052
5351
  * });
5053
5352
  *
5054
5353
  * // Via single instance binding
@@ -5060,7 +5359,7 @@ declare abstract class AiSearchJobs {
5060
5359
  declare abstract class AiSearchInstance {
5061
5360
  /**
5062
5361
  * Search the AI Search instance for relevant chunks.
5063
- * @param params Search request with messages and optional AI search options.
5362
+ * @param params Search request with query or messages and optional AI search options.
5064
5363
  * @returns Search response with matching chunks and search query.
5065
5364
  */
5066
5365
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -5092,7 +5391,7 @@ declare abstract class AiSearchInstance {
5092
5391
  info(): Promise<AiSearchInstanceInfo>;
5093
5392
  /**
5094
5393
  * Get instance statistics (item count, indexing status, etc.).
5095
- * @returns Statistics with counts per status and last activity time.
5394
+ * @returns Statistics with counts per status, last activity time, and engine details.
5096
5395
  */
5097
5396
  stats(): Promise<AiSearchStatsResponse>;
5098
5397
  /** Items collection — list, upload, and manage items in this instance. */
@@ -5104,27 +5403,30 @@ declare abstract class AiSearchInstance {
5104
5403
  * Namespace-level AI Search service.
5105
5404
  *
5106
5405
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
5107
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
5406
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
5407
+ * and multi-instance search/chat operations.
5108
5408
  *
5109
5409
  * @example
5110
5410
  * ```ts
5111
5411
  * // Access an instance within the namespace
5112
5412
  * const blog = env.AI_SEARCH.get("blog");
5113
- * const results = await blog.search({
5114
- * messages: [{ role: "user", content: "How does caching work?" }],
5115
- * });
5413
+ * const results = await blog.search({ query: "How does caching work?" });
5116
5414
  *
5117
5415
  * // List all instances in the namespace
5118
5416
  * const instances = await env.AI_SEARCH.list();
5119
5417
  *
5120
5418
  * // Create a new instance with built-in storage
5121
- * const tenant = await env.AI_SEARCH.create({
5122
- * id: "tenant-123",
5123
- * });
5419
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
5124
5420
  *
5125
5421
  * // Upload items into the instance
5126
5422
  * await tenant.items.upload("doc.pdf", fileContent);
5127
5423
  *
5424
+ * // Search across multiple instances
5425
+ * const multi = await env.AI_SEARCH.search({
5426
+ * query: "caching",
5427
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
5428
+ * });
5429
+ *
5128
5430
  * // Delete an instance
5129
5431
  * await env.AI_SEARCH.delete("tenant-123");
5130
5432
  * ```
@@ -5137,10 +5439,11 @@ declare abstract class AiSearchNamespace {
5137
5439
  */
5138
5440
  get(name: string): AiSearchInstance;
5139
5441
  /**
5140
- * List all instances in the bound namespace.
5141
- * @returns Array of instance metadata.
5442
+ * List instances in the bound namespace.
5443
+ * @param params Optional pagination, search, and ordering parameters.
5444
+ * @returns Array of instance metadata with pagination info.
5142
5445
  */
5143
- list(): Promise<AiSearchListResponse>;
5446
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
5144
5447
  /**
5145
5448
  * Create a new instance within the bound namespace.
5146
5449
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -5165,6 +5468,35 @@ declare abstract class AiSearchNamespace {
5165
5468
  * @param name Instance name to delete.
5166
5469
  */
5167
5470
  delete(name: string): Promise<void>;
5471
+ /**
5472
+ * Search across multiple instances within the bound namespace.
5473
+ * Fans out to the specified instance_ids and merges results.
5474
+ * @param params Search request with required `ai_search_options.instance_ids`.
5475
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
5476
+ */
5477
+ search(
5478
+ params: AiSearchMultiSearchRequest,
5479
+ ): Promise<AiSearchMultiSearchResponse>;
5480
+ /**
5481
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
5482
+ * Fans out to the specified instance_ids, merges context, and generates a response.
5483
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
5484
+ * @returns ReadableStream of server-sent events.
5485
+ */
5486
+ chatCompletions(
5487
+ params: AiSearchMultiChatCompletionsRequest & {
5488
+ stream: true;
5489
+ },
5490
+ ): Promise<ReadableStream>;
5491
+ /**
5492
+ * Generate chat completions across multiple instances within the bound namespace.
5493
+ * Fans out to the specified instance_ids, merges context, and generates a response.
5494
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
5495
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
5496
+ */
5497
+ chatCompletions(
5498
+ params: AiSearchMultiChatCompletionsRequest,
5499
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
5168
5500
  }
5169
5501
  type AiImageClassificationInput = {
5170
5502
  image: number[];
@@ -12816,8 +13148,8 @@ declare module "cloudflare:email" {
12816
13148
  * Evaluation context for targeting rules.
12817
13149
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12818
13150
  */
12819
- type EvaluationContext = Record<string, string | number | boolean>;
12820
- interface EvaluationDetails<T> {
13151
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
13152
+ interface FlagshipEvaluationDetails<T> {
12821
13153
  flagKey: string;
12822
13154
  value: T;
12823
13155
  variant?: string | undefined;
@@ -12825,7 +13157,7 @@ interface EvaluationDetails<T> {
12825
13157
  errorCode?: string | undefined;
12826
13158
  errorMessage?: string | undefined;
12827
13159
  }
12828
- interface FlagEvaluationError extends Error {}
13160
+ interface FlagshipEvaluationError extends Error {}
12829
13161
  /**
12830
13162
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12831
13163
  *
@@ -12845,7 +13177,7 @@ interface FlagEvaluationError extends Error {}
12845
13177
  * console.log(details.variant, details.reason);
12846
13178
  * ```
12847
13179
  */
12848
- declare abstract class Flags {
13180
+ declare abstract class Flagship {
12849
13181
  /**
12850
13182
  * Get a flag value without type checking.
12851
13183
  * @param flagKey The key of the flag to evaluate.
@@ -12855,7 +13187,7 @@ declare abstract class Flags {
12855
13187
  get(
12856
13188
  flagKey: string,
12857
13189
  defaultValue?: unknown,
12858
- context?: EvaluationContext,
13190
+ context?: FlagshipEvaluationContext,
12859
13191
  ): Promise<unknown>;
12860
13192
  /**
12861
13193
  * Get a boolean flag value.
@@ -12866,7 +13198,7 @@ declare abstract class Flags {
12866
13198
  getBooleanValue(
12867
13199
  flagKey: string,
12868
13200
  defaultValue: boolean,
12869
- context?: EvaluationContext,
13201
+ context?: FlagshipEvaluationContext,
12870
13202
  ): Promise<boolean>;
12871
13203
  /**
12872
13204
  * Get a string flag value.
@@ -12877,7 +13209,7 @@ declare abstract class Flags {
12877
13209
  getStringValue(
12878
13210
  flagKey: string,
12879
13211
  defaultValue: string,
12880
- context?: EvaluationContext,
13212
+ context?: FlagshipEvaluationContext,
12881
13213
  ): Promise<string>;
12882
13214
  /**
12883
13215
  * Get a number flag value.
@@ -12888,7 +13220,7 @@ declare abstract class Flags {
12888
13220
  getNumberValue(
12889
13221
  flagKey: string,
12890
13222
  defaultValue: number,
12891
- context?: EvaluationContext,
13223
+ context?: FlagshipEvaluationContext,
12892
13224
  ): Promise<number>;
12893
13225
  /**
12894
13226
  * Get an object flag value.
@@ -12899,7 +13231,7 @@ declare abstract class Flags {
12899
13231
  getObjectValue<T extends object>(
12900
13232
  flagKey: string,
12901
13233
  defaultValue: T,
12902
- context?: EvaluationContext,
13234
+ context?: FlagshipEvaluationContext,
12903
13235
  ): Promise<T>;
12904
13236
  /**
12905
13237
  * Get a boolean flag value with full evaluation details.
@@ -12910,8 +13242,8 @@ declare abstract class Flags {
12910
13242
  getBooleanDetails(
12911
13243
  flagKey: string,
12912
13244
  defaultValue: boolean,
12913
- context?: EvaluationContext,
12914
- ): Promise<EvaluationDetails<boolean>>;
13245
+ context?: FlagshipEvaluationContext,
13246
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12915
13247
  /**
12916
13248
  * Get a string flag value with full evaluation details.
12917
13249
  * @param flagKey The key of the flag to evaluate.
@@ -12921,8 +13253,8 @@ declare abstract class Flags {
12921
13253
  getStringDetails(
12922
13254
  flagKey: string,
12923
13255
  defaultValue: string,
12924
- context?: EvaluationContext,
12925
- ): Promise<EvaluationDetails<string>>;
13256
+ context?: FlagshipEvaluationContext,
13257
+ ): Promise<FlagshipEvaluationDetails<string>>;
12926
13258
  /**
12927
13259
  * Get a number flag value with full evaluation details.
12928
13260
  * @param flagKey The key of the flag to evaluate.
@@ -12932,8 +13264,8 @@ declare abstract class Flags {
12932
13264
  getNumberDetails(
12933
13265
  flagKey: string,
12934
13266
  defaultValue: number,
12935
- context?: EvaluationContext,
12936
- ): Promise<EvaluationDetails<number>>;
13267
+ context?: FlagshipEvaluationContext,
13268
+ ): Promise<FlagshipEvaluationDetails<number>>;
12937
13269
  /**
12938
13270
  * Get an object flag value with full evaluation details.
12939
13271
  * @param flagKey The key of the flag to evaluate.
@@ -12943,8 +13275,8 @@ declare abstract class Flags {
12943
13275
  getObjectDetails<T extends object>(
12944
13276
  flagKey: string,
12945
13277
  defaultValue: T,
12946
- context?: EvaluationContext,
12947
- ): Promise<EvaluationDetails<T>>;
13278
+ context?: FlagshipEvaluationContext,
13279
+ ): Promise<FlagshipEvaluationDetails<T>>;
12948
13280
  }
12949
13281
  /**
12950
13282
  * Hello World binding to serve as an explanatory example. DO NOT USE