@cloudflare/workers-types 4.20260415.1 → 4.20260416.2

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.
@@ -576,6 +576,7 @@ export declare abstract class Navigator {
576
576
  sendBeacon(url: string, body?: BodyInit): boolean;
577
577
  readonly userAgent: string;
578
578
  readonly hardwareConcurrency: number;
579
+ readonly platform: string;
579
580
  readonly language: string;
580
581
  readonly languages: string[];
581
582
  readonly storage: StorageManager;
@@ -2420,12 +2421,12 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2420
2421
  }
2421
2422
  export type QueueContentType = "text" | "bytes" | "json" | "v8";
2422
2423
  export interface Queue<Body = unknown> {
2424
+ metrics(): Promise<QueueMetrics>;
2423
2425
  send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2424
2426
  sendBatch(
2425
2427
  messages: Iterable<MessageSendRequest<Body>>,
2426
2428
  options?: QueueSendBatchOptions,
2427
2429
  ): Promise<QueueSendBatchResponse>;
2428
- metrics(): Promise<QueueMetrics>;
2429
2430
  }
2430
2431
  export interface QueueSendMetrics {
2431
2432
  backlogCount: number;
@@ -4716,72 +4717,145 @@ export interface EventCounts {
4716
4717
  // ============ AI Search Error Interfaces ============
4717
4718
  export interface AiSearchInternalError extends Error {}
4718
4719
  export interface AiSearchNotFoundError extends Error {}
4719
- // ============ AI Search Request Types ============
4720
- export type AiSearchSearchRequest = {
4721
- messages: Array<{
4722
- role: "system" | "developer" | "user" | "assistant" | "tool";
4723
- content: string | null;
4724
- }>;
4725
- ai_search_options?: {
4726
- retrieval?: {
4727
- retrieval_type?: "vector" | "keyword" | "hybrid";
4728
- /** Match threshold (0-1, default 0.4) */
4729
- match_threshold?: number;
4730
- /** Maximum number of results (1-50, default 10) */
4731
- max_num_results?: number;
4732
- filters?: VectorizeVectorMetadataFilter;
4733
- /** Context expansion (0-3, default 0) */
4734
- context_expansion?: number;
4735
- [key: string]: unknown;
4736
- };
4737
- query_rewrite?: {
4738
- enabled?: boolean;
4739
- model?: string;
4740
- rewrite_prompt?: string;
4741
- [key: string]: unknown;
4742
- };
4743
- reranking?: {
4744
- enabled?: boolean;
4745
- model?: "@cf/baai/bge-reranker-base" | string;
4746
- /** Match threshold (0-1, default 0.4) */
4747
- match_threshold?: number;
4748
- [key: string]: unknown;
4749
- };
4720
+ // ============ AI Search Common Types ============
4721
+ /** A single message in a conversation-style search or chat request. */
4722
+ export type AiSearchMessage = {
4723
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4724
+ content: string | null;
4725
+ };
4726
+ /**
4727
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4728
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4729
+ */
4730
+ export type AiSearchOptions = {
4731
+ retrieval?: {
4732
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4733
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4734
+ /** Fusion method for combining vector + keyword results. */
4735
+ fusion_method?: "max" | "rrf";
4736
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4737
+ keyword_match_mode?: "and" | "or";
4738
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4739
+ match_threshold?: number;
4740
+ /** Maximum number of results to return (1-50). Default 10. */
4741
+ max_num_results?: number;
4742
+ /** Vectorize metadata filters applied to the search. */
4743
+ filters?: VectorizeVectorMetadataFilter;
4744
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4745
+ context_expansion?: number;
4746
+ /** If true, return only item metadata without chunk text. */
4747
+ metadata_only?: boolean;
4748
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4749
+ return_on_failure?: boolean;
4750
+ /** Boost results by metadata field values. Max 3 entries. */
4751
+ boost_by?: Array<{
4752
+ field: string;
4753
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4754
+ }>;
4755
+ [key: string]: unknown;
4756
+ };
4757
+ query_rewrite?: {
4758
+ enabled?: boolean;
4759
+ model?: string;
4760
+ rewrite_prompt?: string;
4761
+ [key: string]: unknown;
4762
+ };
4763
+ reranking?: {
4764
+ enabled?: boolean;
4765
+ model?: string;
4766
+ /** Match threshold (0-1, default 0.4) */
4767
+ match_threshold?: number;
4750
4768
  [key: string]: unknown;
4751
4769
  };
4770
+ cache?: {
4771
+ enabled?: boolean;
4772
+ cache_threshold?:
4773
+ | "super_strict_match"
4774
+ | "close_enough"
4775
+ | "flexible_friend"
4776
+ | "anything_goes";
4777
+ };
4778
+ [key: string]: unknown;
4752
4779
  };
4780
+ // ============ AI Search Request Types ============
4781
+ /**
4782
+ * Request body for single-instance search.
4783
+ * Exactly one of `query` or `messages` must be provided.
4784
+ */
4785
+ export type AiSearchSearchRequest =
4786
+ | {
4787
+ /** Simple query string. */
4788
+ query: string;
4789
+ messages?: never;
4790
+ ai_search_options?: AiSearchOptions;
4791
+ }
4792
+ | {
4793
+ query?: never;
4794
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4795
+ messages: AiSearchMessage[];
4796
+ ai_search_options?: AiSearchOptions;
4797
+ };
4753
4798
  export type AiSearchChatCompletionsRequest = {
4754
- messages: Array<{
4755
- role: "system" | "developer" | "user" | "assistant" | "tool";
4756
- content: string | null;
4757
- [key: string]: unknown;
4758
- }>;
4799
+ messages: AiSearchMessage[];
4759
4800
  model?: string;
4760
4801
  stream?: boolean;
4761
- ai_search_options?: {
4762
- retrieval?: {
4763
- retrieval_type?: "vector" | "keyword" | "hybrid";
4764
- match_threshold?: number;
4765
- max_num_results?: number;
4766
- filters?: VectorizeVectorMetadataFilter;
4767
- context_expansion?: number;
4768
- [key: string]: unknown;
4769
- };
4770
- query_rewrite?: {
4771
- enabled?: boolean;
4772
- model?: string;
4773
- rewrite_prompt?: string;
4774
- [key: string]: unknown;
4775
- };
4776
- reranking?: {
4777
- enabled?: boolean;
4778
- model?: "@cf/baai/bge-reranker-base" | string;
4779
- match_threshold?: number;
4780
- [key: string]: unknown;
4802
+ ai_search_options?: AiSearchOptions;
4803
+ [key: string]: unknown;
4804
+ };
4805
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4806
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4807
+ export type AiSearchMultiSearchOptions = AiSearchOptions & {
4808
+ /** Instance IDs to search across (1-10). */
4809
+ instance_ids: string[];
4810
+ };
4811
+ /**
4812
+ * Request for searching across multiple instances within a namespace.
4813
+ * `ai_search_options` is required and must include `instance_ids`.
4814
+ * Exactly one of `query` or `messages` must be provided.
4815
+ */
4816
+ export type AiSearchMultiSearchRequest =
4817
+ | {
4818
+ /** Simple query string. */
4819
+ query: string;
4820
+ messages?: never;
4821
+ ai_search_options: AiSearchMultiSearchOptions;
4822
+ }
4823
+ | {
4824
+ query?: never;
4825
+ /** Conversation-style input. */
4826
+ messages: AiSearchMessage[];
4827
+ ai_search_options: AiSearchMultiSearchOptions;
4781
4828
  };
4782
- [key: string]: unknown;
4829
+ /** A search result chunk tagged with the instance it originated from. */
4830
+ export type AiSearchMultiSearchChunk =
4831
+ AiSearchSearchResponse["chunks"][number] & {
4832
+ instance_id: string;
4783
4833
  };
4784
- [key: string]: unknown;
4834
+ /** Describes a per-instance error during a multi-instance operation. */
4835
+ export type AiSearchMultiSearchError = {
4836
+ instance_id: string;
4837
+ message: string;
4838
+ };
4839
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4840
+ export type AiSearchMultiSearchResponse = {
4841
+ search_query: string;
4842
+ chunks: AiSearchMultiSearchChunk[];
4843
+ errors?: AiSearchMultiSearchError[];
4844
+ };
4845
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4846
+ export type AiSearchMultiChatCompletionsRequest = Omit<
4847
+ AiSearchChatCompletionsRequest,
4848
+ "ai_search_options"
4849
+ > & {
4850
+ ai_search_options: AiSearchMultiSearchOptions;
4851
+ };
4852
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4853
+ export type AiSearchMultiChatCompletionsResponse = Omit<
4854
+ AiSearchChatCompletionsResponse,
4855
+ "chunks"
4856
+ > & {
4857
+ chunks: AiSearchMultiSearchChunk[];
4858
+ errors?: AiSearchMultiSearchError[];
4785
4859
  };
4786
4860
  // ============ AI Search Response Types ============
4787
4861
  export type AiSearchSearchResponse = {
@@ -4802,6 +4876,14 @@ export type AiSearchSearchResponse = {
4802
4876
  keyword_score?: number;
4803
4877
  /** Vector similarity score (0-1) */
4804
4878
  vector_score?: number;
4879
+ /** Keyword rank position */
4880
+ keyword_rank?: number;
4881
+ /** Vector rank position */
4882
+ vector_rank?: number;
4883
+ /** Reranking model score */
4884
+ reranking_score?: number;
4885
+ /** Fusion method used to combine results */
4886
+ fusion_method?: "rrf" | "max";
4805
4887
  [key: string]: unknown;
4806
4888
  };
4807
4889
  }>;
@@ -4830,19 +4912,88 @@ export type AiSearchStatsResponse = {
4830
4912
  skipped?: number;
4831
4913
  outdated?: number;
4832
4914
  last_activity?: string;
4915
+ /** Storage engine statistics. */
4916
+ engine?: {
4917
+ vectorize?: {
4918
+ vectorsCount: number;
4919
+ dimensions: number;
4920
+ };
4921
+ r2?: {
4922
+ payloadSizeBytes: number;
4923
+ metadataSizeBytes: number;
4924
+ objectCount: number;
4925
+ };
4926
+ };
4833
4927
  };
4834
4928
  // ============ AI Search Instance Info Types ============
4835
4929
  export type AiSearchInstanceInfo = {
4836
4930
  id: string;
4837
4931
  type?: "r2" | "web-crawler" | string;
4838
4932
  source?: string;
4933
+ source_params?: unknown;
4839
4934
  paused?: boolean;
4840
4935
  status?: string;
4841
4936
  namespace?: string;
4842
4937
  created_at?: string;
4843
4938
  modified_at?: string;
4939
+ token_id?: string;
4940
+ ai_gateway_id?: string;
4941
+ rewrite_query?: boolean;
4942
+ reranking?: boolean;
4943
+ embedding_model?: string;
4944
+ ai_search_model?: string;
4945
+ rewrite_model?: string;
4946
+ reranking_model?: string;
4947
+ /** @deprecated Use index_method instead. */
4948
+ hybrid_search_enabled?: boolean;
4949
+ /** Controls which storage backends are active. */
4950
+ index_method?: {
4951
+ vector?: boolean;
4952
+ keyword?: boolean;
4953
+ };
4954
+ /** Fusion method for combining vector and keyword results. */
4955
+ fusion_method?: "max" | "rrf";
4956
+ indexing_options?: {
4957
+ keyword_tokenizer?: "porter" | "trigram";
4958
+ } | null;
4959
+ retrieval_options?: {
4960
+ keyword_match_mode?: "and" | "or";
4961
+ boost_by?: Array<{
4962
+ field: string;
4963
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4964
+ }>;
4965
+ } | null;
4966
+ chunk?: boolean;
4967
+ chunk_size?: number;
4968
+ chunk_overlap?: number;
4969
+ score_threshold?: number;
4970
+ max_num_results?: number;
4971
+ cache?: boolean;
4972
+ cache_threshold?:
4973
+ | "super_strict_match"
4974
+ | "close_enough"
4975
+ | "flexible_friend"
4976
+ | "anything_goes";
4977
+ custom_metadata?: Array<{
4978
+ field_name: string;
4979
+ data_type: "text" | "number" | "boolean" | "datetime";
4980
+ }>;
4981
+ /** Sync interval in seconds. */
4982
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4983
+ metadata?: Record<string, unknown>;
4844
4984
  [key: string]: unknown;
4845
4985
  };
4986
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4987
+ export type AiSearchListInstancesParams = {
4988
+ page?: number;
4989
+ per_page?: number;
4990
+ /** Search instances by ID. */
4991
+ search?: string;
4992
+ /** Field to sort by. */
4993
+ order_by?: "created_at";
4994
+ /** Sort direction. */
4995
+ order_by_direction?: "asc" | "desc";
4996
+ };
4846
4997
  export type AiSearchListResponse = {
4847
4998
  result: AiSearchInstanceInfo[];
4848
4999
  result_info?: {
@@ -4870,19 +5021,64 @@ export type AiSearchConfig = {
4870
5021
  reranking?: boolean;
4871
5022
  embedding_model?: string;
4872
5023
  ai_search_model?: string;
5024
+ rewrite_model?: string;
5025
+ reranking_model?: string;
5026
+ /** @deprecated Use index_method instead. */
5027
+ hybrid_search_enabled?: boolean;
5028
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
5029
+ index_method?: {
5030
+ vector?: boolean;
5031
+ keyword?: boolean;
5032
+ };
5033
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
5034
+ fusion_method?: "max" | "rrf";
5035
+ indexing_options?: {
5036
+ keyword_tokenizer?: "porter" | "trigram";
5037
+ } | null;
5038
+ retrieval_options?: {
5039
+ keyword_match_mode?: "and" | "or";
5040
+ boost_by?: Array<{
5041
+ field: string;
5042
+ direction?: "asc" | "desc" | "exists" | "not_exists";
5043
+ }>;
5044
+ } | null;
5045
+ chunk?: boolean;
5046
+ chunk_size?: number;
5047
+ chunk_overlap?: number;
5048
+ /** Minimum similarity score (0-1) for a result to be included. */
5049
+ score_threshold?: number;
5050
+ max_num_results?: number;
5051
+ cache?: boolean;
5052
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
5053
+ cache_threshold?:
5054
+ | "super_strict_match"
5055
+ | "close_enough"
5056
+ | "flexible_friend"
5057
+ | "anything_goes";
5058
+ custom_metadata?: Array<{
5059
+ field_name: string;
5060
+ data_type: "text" | "number" | "boolean" | "datetime";
5061
+ }>;
5062
+ namespace?: string;
5063
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
5064
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5065
+ metadata?: Record<string, unknown>;
4873
5066
  [key: string]: unknown;
4874
5067
  };
4875
5068
  // ============ AI Search Item Types ============
4876
5069
  export type AiSearchItemInfo = {
4877
5070
  id: string;
4878
5071
  key: string;
4879
- status:
4880
- | "completed"
4881
- | "error"
4882
- | "skipped"
4883
- | "queued"
4884
- | "processing"
4885
- | "outdated";
5072
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
5073
+ next_action?: "INDEX" | "DELETE" | null;
5074
+ error?: string;
5075
+ checksum?: string;
5076
+ namespace?: string;
5077
+ chunks_count?: number | null;
5078
+ file_size?: number | null;
5079
+ source_id?: string | null;
5080
+ last_seen_at?: string;
5081
+ created_at?: string;
4886
5082
  metadata?: Record<string, unknown>;
4887
5083
  [key: string]: unknown;
4888
5084
  };
@@ -4898,6 +5094,22 @@ export type AiSearchUploadItemOptions = {
4898
5094
  export type AiSearchListItemsParams = {
4899
5095
  page?: number;
4900
5096
  per_page?: number;
5097
+ /** Search items by key name. */
5098
+ search?: string;
5099
+ /** Sort order for results. */
5100
+ sort_by?: "status" | "modified_at";
5101
+ /** Filter items by processing status. */
5102
+ status?:
5103
+ | "queued"
5104
+ | "running"
5105
+ | "completed"
5106
+ | "error"
5107
+ | "skipped"
5108
+ | "outdated";
5109
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
5110
+ source?: string;
5111
+ /** JSON-encoded Vectorize filter for metadata filtering. */
5112
+ metadata_filter?: string;
4901
5113
  };
4902
5114
  export type AiSearchListItemsResponse = {
4903
5115
  result: AiSearchItemInfo[];
@@ -4908,6 +5120,61 @@ export type AiSearchListItemsResponse = {
4908
5120
  total_count: number;
4909
5121
  };
4910
5122
  };
5123
+ // ============ AI Search Item Logs Types ============
5124
+ export type AiSearchItemLogsParams = {
5125
+ /** Maximum number of log entries to return (1-100, default 50). */
5126
+ limit?: number;
5127
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
5128
+ cursor?: string;
5129
+ };
5130
+ export type AiSearchItemLog = {
5131
+ timestamp: string;
5132
+ action: string;
5133
+ message: string;
5134
+ fileKey?: string;
5135
+ chunkCount?: number;
5136
+ processingTimeMs?: number;
5137
+ errorType?: string;
5138
+ };
5139
+ /** Paginated response for item processing logs (cursor-based). */
5140
+ export type AiSearchItemLogsResponse = {
5141
+ result: AiSearchItemLog[];
5142
+ result_info: {
5143
+ count: number;
5144
+ per_page: number;
5145
+ cursor: string | null;
5146
+ truncated: boolean;
5147
+ };
5148
+ };
5149
+ // ============ AI Search Item Chunks Types ============
5150
+ export type AiSearchItemChunksParams = {
5151
+ /** Maximum number of chunks to return (1-100, default 20). */
5152
+ limit?: number;
5153
+ /** Offset into the chunks list (default 0). */
5154
+ offset?: number;
5155
+ };
5156
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
5157
+ export type AiSearchItemChunk = {
5158
+ id: string;
5159
+ text: string;
5160
+ start_byte: number;
5161
+ end_byte: number;
5162
+ item?: {
5163
+ timestamp?: number;
5164
+ key: string;
5165
+ metadata?: Record<string, unknown>;
5166
+ };
5167
+ };
5168
+ /** Paginated response for item chunks (offset-based). */
5169
+ export type AiSearchItemChunksResponse = {
5170
+ result: AiSearchItemChunk[];
5171
+ result_info: {
5172
+ count: number;
5173
+ total: number;
5174
+ limit: number;
5175
+ offset: number;
5176
+ };
5177
+ };
4911
5178
  // ============ AI Search Job Types ============
4912
5179
  export type AiSearchJobInfo = {
4913
5180
  id: string;
@@ -4956,7 +5223,7 @@ export type AiSearchJobLogsResponse = {
4956
5223
  // ============ AI Search Sub-Service Classes ============
4957
5224
  /**
4958
5225
  * Single item service for an AI Search instance.
4959
- * Provides info, delete, and download operations on a specific item.
5226
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4960
5227
  */
4961
5228
  export declare abstract class AiSearchItem {
4962
5229
  /** Get metadata about this item. */
@@ -4966,6 +5233,25 @@ export declare abstract class AiSearchItem {
4966
5233
  * @returns Object with body stream, content type, filename, and size.
4967
5234
  */
4968
5235
  download(): Promise<AiSearchItemContentResult>;
5236
+ /**
5237
+ * Trigger re-indexing of this item.
5238
+ * @returns The updated item info.
5239
+ */
5240
+ sync(): Promise<AiSearchItemInfo>;
5241
+ /**
5242
+ * Retrieve processing logs for this item (cursor-based pagination).
5243
+ * @param params Optional pagination parameters (limit, cursor).
5244
+ * @returns Paginated log entries for this item.
5245
+ */
5246
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
5247
+ /**
5248
+ * List indexed chunks for this item (offset-based pagination).
5249
+ * @param params Optional pagination parameters (limit, offset).
5250
+ * @returns Paginated chunk entries for this item.
5251
+ */
5252
+ chunks(
5253
+ params?: AiSearchItemChunksParams,
5254
+ ): Promise<AiSearchItemChunksResponse>;
4969
5255
  }
4970
5256
  /**
4971
5257
  * Items collection service for an AI Search instance.
@@ -4975,49 +5261,64 @@ export declare abstract class AiSearchItems {
4975
5261
  /** List items in this instance. */
4976
5262
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4977
5263
  /**
4978
- * Upload a file as an item.
5264
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
5265
+ * filename already exists, it is overwritten and re-indexed.
4979
5266
  * @param name Filename for the uploaded item.
4980
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
5267
+ * @param content File content as a ReadableStream, Blob, or string.
4981
5268
  * @param options Optional metadata to attach to the item.
4982
5269
  * @returns The created item info.
4983
5270
  */
4984
5271
  upload(
4985
5272
  name: string,
4986
- content: ReadableStream | ArrayBuffer | string,
5273
+ content: ReadableStream | Blob | string,
4987
5274
  options?: AiSearchUploadItemOptions,
4988
5275
  ): Promise<AiSearchItemInfo>;
4989
5276
  /**
4990
5277
  * Upload a file and poll until processing completes.
5278
+ * Behaves as an upsert: if an item with the same filename already exists,
5279
+ * it is overwritten and re-indexed.
4991
5280
  * @param name Filename for the uploaded item.
4992
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4993
- * @param options Optional metadata to attach to the item.
5281
+ * @param content File content as a ReadableStream, Blob, or string.
5282
+ * @param options Optional metadata and polling configuration.
4994
5283
  * @returns The item info after processing completes (or timeout).
4995
5284
  */
4996
5285
  uploadAndPoll(
4997
5286
  name: string,
4998
- content: ReadableStream | ArrayBuffer | string,
4999
- options?: AiSearchUploadItemOptions,
5287
+ content: ReadableStream | Blob | string,
5288
+ options?: AiSearchUploadItemOptions & {
5289
+ /** Polling interval in milliseconds (default 1000). */
5290
+ pollIntervalMs?: number;
5291
+ /** Maximum time to wait in milliseconds (default 30000). */
5292
+ timeoutMs?: number;
5293
+ },
5000
5294
  ): Promise<AiSearchItemInfo>;
5001
5295
  /**
5002
5296
  * Get an item by ID.
5003
5297
  * @param itemId The item identifier.
5004
- * @returns Item service for info, delete, and download operations.
5298
+ * @returns Item service for info, download, sync, logs, and chunks operations.
5005
5299
  */
5006
5300
  get(itemId: string): AiSearchItem;
5007
- /** Delete this item from the instance.
5301
+ /**
5302
+ * Delete an item from the instance.
5008
5303
  * @param itemId The item identifier.
5009
5304
  */
5010
5305
  delete(itemId: string): Promise<void>;
5011
5306
  }
5012
5307
  /**
5013
5308
  * Single job service for an AI Search instance.
5014
- * Provides info and logs for a specific job.
5309
+ * Provides info, logs, and cancel operations for a specific job.
5015
5310
  */
5016
5311
  export declare abstract class AiSearchJob {
5017
5312
  /** Get metadata about this job. */
5018
5313
  info(): Promise<AiSearchJobInfo>;
5019
5314
  /** Get logs for this job. */
5020
5315
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
5316
+ /**
5317
+ * Cancel a running job.
5318
+ * @returns The updated job info.
5319
+ * @throws AiSearchNotFoundError if the job does not exist.
5320
+ */
5321
+ cancel(): Promise<AiSearchJobInfo>;
5021
5322
  }
5022
5323
  /**
5023
5324
  * Jobs collection service for an AI Search instance.
@@ -5035,7 +5336,7 @@ export declare abstract class AiSearchJobs {
5035
5336
  /**
5036
5337
  * Get a job by ID.
5037
5338
  * @param jobId The job identifier.
5038
- * @returns Job service for info and logs operations.
5339
+ * @returns Job service for info, logs, and cancel operations.
5039
5340
  */
5040
5341
  get(jobId: string): AiSearchJob;
5041
5342
  }
@@ -5054,7 +5355,7 @@ export declare abstract class AiSearchJobs {
5054
5355
  * // Via namespace binding
5055
5356
  * const instance = env.AI_SEARCH.get("blog");
5056
5357
  * const results = await instance.search({
5057
- * messages: [{ role: "user", content: "How does caching work?" }],
5358
+ * query: "How does caching work?",
5058
5359
  * });
5059
5360
  *
5060
5361
  * // Via single instance binding
@@ -5066,7 +5367,7 @@ export declare abstract class AiSearchJobs {
5066
5367
  export declare abstract class AiSearchInstance {
5067
5368
  /**
5068
5369
  * Search the AI Search instance for relevant chunks.
5069
- * @param params Search request with messages and optional AI search options.
5370
+ * @param params Search request with query or messages and optional AI search options.
5070
5371
  * @returns Search response with matching chunks and search query.
5071
5372
  */
5072
5373
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -5098,7 +5399,7 @@ export declare abstract class AiSearchInstance {
5098
5399
  info(): Promise<AiSearchInstanceInfo>;
5099
5400
  /**
5100
5401
  * Get instance statistics (item count, indexing status, etc.).
5101
- * @returns Statistics with counts per status and last activity time.
5402
+ * @returns Statistics with counts per status, last activity time, and engine details.
5102
5403
  */
5103
5404
  stats(): Promise<AiSearchStatsResponse>;
5104
5405
  /** Items collection — list, upload, and manage items in this instance. */
@@ -5110,27 +5411,30 @@ export declare abstract class AiSearchInstance {
5110
5411
  * Namespace-level AI Search service.
5111
5412
  *
5112
5413
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
5113
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
5414
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
5415
+ * and multi-instance search/chat operations.
5114
5416
  *
5115
5417
  * @example
5116
5418
  * ```ts
5117
5419
  * // Access an instance within the namespace
5118
5420
  * const blog = env.AI_SEARCH.get("blog");
5119
- * const results = await blog.search({
5120
- * messages: [{ role: "user", content: "How does caching work?" }],
5121
- * });
5421
+ * const results = await blog.search({ query: "How does caching work?" });
5122
5422
  *
5123
5423
  * // List all instances in the namespace
5124
5424
  * const instances = await env.AI_SEARCH.list();
5125
5425
  *
5126
5426
  * // Create a new instance with built-in storage
5127
- * const tenant = await env.AI_SEARCH.create({
5128
- * id: "tenant-123",
5129
- * });
5427
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
5130
5428
  *
5131
5429
  * // Upload items into the instance
5132
5430
  * await tenant.items.upload("doc.pdf", fileContent);
5133
5431
  *
5432
+ * // Search across multiple instances
5433
+ * const multi = await env.AI_SEARCH.search({
5434
+ * query: "caching",
5435
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
5436
+ * });
5437
+ *
5134
5438
  * // Delete an instance
5135
5439
  * await env.AI_SEARCH.delete("tenant-123");
5136
5440
  * ```
@@ -5143,10 +5447,11 @@ export declare abstract class AiSearchNamespace {
5143
5447
  */
5144
5448
  get(name: string): AiSearchInstance;
5145
5449
  /**
5146
- * List all instances in the bound namespace.
5147
- * @returns Array of instance metadata.
5450
+ * List instances in the bound namespace.
5451
+ * @param params Optional pagination, search, and ordering parameters.
5452
+ * @returns Array of instance metadata with pagination info.
5148
5453
  */
5149
- list(): Promise<AiSearchListResponse>;
5454
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
5150
5455
  /**
5151
5456
  * Create a new instance within the bound namespace.
5152
5457
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -5171,6 +5476,35 @@ export declare abstract class AiSearchNamespace {
5171
5476
  * @param name Instance name to delete.
5172
5477
  */
5173
5478
  delete(name: string): Promise<void>;
5479
+ /**
5480
+ * Search across multiple instances within the bound namespace.
5481
+ * Fans out to the specified instance_ids and merges results.
5482
+ * @param params Search request with required `ai_search_options.instance_ids`.
5483
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
5484
+ */
5485
+ search(
5486
+ params: AiSearchMultiSearchRequest,
5487
+ ): Promise<AiSearchMultiSearchResponse>;
5488
+ /**
5489
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
5490
+ * Fans out to the specified instance_ids, merges context, and generates a response.
5491
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
5492
+ * @returns ReadableStream of server-sent events.
5493
+ */
5494
+ chatCompletions(
5495
+ params: AiSearchMultiChatCompletionsRequest & {
5496
+ stream: true;
5497
+ },
5498
+ ): Promise<ReadableStream>;
5499
+ /**
5500
+ * Generate chat completions across multiple instances within the bound namespace.
5501
+ * Fans out to the specified instance_ids, merges context, and generates a response.
5502
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
5503
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
5504
+ */
5505
+ chatCompletions(
5506
+ params: AiSearchMultiChatCompletionsRequest,
5507
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
5174
5508
  }
5175
5509
  export type AiImageClassificationInput = {
5176
5510
  image: number[];
@@ -12832,8 +13166,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12832
13166
  * Evaluation context for targeting rules.
12833
13167
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12834
13168
  */
12835
- export type EvaluationContext = Record<string, string | number | boolean>;
12836
- export interface EvaluationDetails<T> {
13169
+ export type FlagshipEvaluationContext = Record<
13170
+ string,
13171
+ string | number | boolean
13172
+ >;
13173
+ export interface FlagshipEvaluationDetails<T> {
12837
13174
  flagKey: string;
12838
13175
  value: T;
12839
13176
  variant?: string | undefined;
@@ -12841,7 +13178,7 @@ export interface EvaluationDetails<T> {
12841
13178
  errorCode?: string | undefined;
12842
13179
  errorMessage?: string | undefined;
12843
13180
  }
12844
- export interface FlagEvaluationError extends Error {}
13181
+ export interface FlagshipEvaluationError extends Error {}
12845
13182
  /**
12846
13183
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12847
13184
  *
@@ -12861,7 +13198,7 @@ export interface FlagEvaluationError extends Error {}
12861
13198
  * console.log(details.variant, details.reason);
12862
13199
  * ```
12863
13200
  */
12864
- export declare abstract class Flags {
13201
+ export declare abstract class Flagship {
12865
13202
  /**
12866
13203
  * Get a flag value without type checking.
12867
13204
  * @param flagKey The key of the flag to evaluate.
@@ -12871,7 +13208,7 @@ export declare abstract class Flags {
12871
13208
  get(
12872
13209
  flagKey: string,
12873
13210
  defaultValue?: unknown,
12874
- context?: EvaluationContext,
13211
+ context?: FlagshipEvaluationContext,
12875
13212
  ): Promise<unknown>;
12876
13213
  /**
12877
13214
  * Get a boolean flag value.
@@ -12882,7 +13219,7 @@ export declare abstract class Flags {
12882
13219
  getBooleanValue(
12883
13220
  flagKey: string,
12884
13221
  defaultValue: boolean,
12885
- context?: EvaluationContext,
13222
+ context?: FlagshipEvaluationContext,
12886
13223
  ): Promise<boolean>;
12887
13224
  /**
12888
13225
  * Get a string flag value.
@@ -12893,7 +13230,7 @@ export declare abstract class Flags {
12893
13230
  getStringValue(
12894
13231
  flagKey: string,
12895
13232
  defaultValue: string,
12896
- context?: EvaluationContext,
13233
+ context?: FlagshipEvaluationContext,
12897
13234
  ): Promise<string>;
12898
13235
  /**
12899
13236
  * Get a number flag value.
@@ -12904,7 +13241,7 @@ export declare abstract class Flags {
12904
13241
  getNumberValue(
12905
13242
  flagKey: string,
12906
13243
  defaultValue: number,
12907
- context?: EvaluationContext,
13244
+ context?: FlagshipEvaluationContext,
12908
13245
  ): Promise<number>;
12909
13246
  /**
12910
13247
  * Get an object flag value.
@@ -12915,7 +13252,7 @@ export declare abstract class Flags {
12915
13252
  getObjectValue<T extends object>(
12916
13253
  flagKey: string,
12917
13254
  defaultValue: T,
12918
- context?: EvaluationContext,
13255
+ context?: FlagshipEvaluationContext,
12919
13256
  ): Promise<T>;
12920
13257
  /**
12921
13258
  * Get a boolean flag value with full evaluation details.
@@ -12926,8 +13263,8 @@ export declare abstract class Flags {
12926
13263
  getBooleanDetails(
12927
13264
  flagKey: string,
12928
13265
  defaultValue: boolean,
12929
- context?: EvaluationContext,
12930
- ): Promise<EvaluationDetails<boolean>>;
13266
+ context?: FlagshipEvaluationContext,
13267
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12931
13268
  /**
12932
13269
  * Get a string flag value with full evaluation details.
12933
13270
  * @param flagKey The key of the flag to evaluate.
@@ -12937,8 +13274,8 @@ export declare abstract class Flags {
12937
13274
  getStringDetails(
12938
13275
  flagKey: string,
12939
13276
  defaultValue: string,
12940
- context?: EvaluationContext,
12941
- ): Promise<EvaluationDetails<string>>;
13277
+ context?: FlagshipEvaluationContext,
13278
+ ): Promise<FlagshipEvaluationDetails<string>>;
12942
13279
  /**
12943
13280
  * Get a number flag value with full evaluation details.
12944
13281
  * @param flagKey The key of the flag to evaluate.
@@ -12948,8 +13285,8 @@ export declare abstract class Flags {
12948
13285
  getNumberDetails(
12949
13286
  flagKey: string,
12950
13287
  defaultValue: number,
12951
- context?: EvaluationContext,
12952
- ): Promise<EvaluationDetails<number>>;
13288
+ context?: FlagshipEvaluationContext,
13289
+ ): Promise<FlagshipEvaluationDetails<number>>;
12953
13290
  /**
12954
13291
  * Get an object flag value with full evaluation details.
12955
13292
  * @param flagKey The key of the flag to evaluate.
@@ -12959,8 +13296,8 @@ export declare abstract class Flags {
12959
13296
  getObjectDetails<T extends object>(
12960
13297
  flagKey: string,
12961
13298
  defaultValue: T,
12962
- context?: EvaluationContext,
12963
- ): Promise<EvaluationDetails<T>>;
13299
+ context?: FlagshipEvaluationContext,
13300
+ ): Promise<FlagshipEvaluationDetails<T>>;
12964
13301
  }
12965
13302
  /**
12966
13303
  * Hello World binding to serve as an explanatory example. DO NOT USE