@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.
package/index.d.ts CHANGED
@@ -2304,11 +2304,34 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2304
2304
  }
2305
2305
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2306
2306
  interface Queue<Body = unknown> {
2307
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2307
+ metrics(): Promise<QueueMetrics>;
2308
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2308
2309
  sendBatch(
2309
2310
  messages: Iterable<MessageSendRequest<Body>>,
2310
2311
  options?: QueueSendBatchOptions,
2311
- ): Promise<void>;
2312
+ ): Promise<QueueSendBatchResponse>;
2313
+ }
2314
+ interface QueueSendMetrics {
2315
+ backlogCount: number;
2316
+ backlogBytes: number;
2317
+ oldestMessageTimestamp?: Date;
2318
+ }
2319
+ interface QueueSendMetadata {
2320
+ metrics: QueueSendMetrics;
2321
+ }
2322
+ interface QueueSendResponse {
2323
+ metadata: QueueSendMetadata;
2324
+ }
2325
+ interface QueueSendBatchMetrics {
2326
+ backlogCount: number;
2327
+ backlogBytes: number;
2328
+ oldestMessageTimestamp?: Date;
2329
+ }
2330
+ interface QueueSendBatchMetadata {
2331
+ metrics: QueueSendBatchMetrics;
2332
+ }
2333
+ interface QueueSendBatchResponse {
2334
+ metadata: QueueSendBatchMetadata;
2312
2335
  }
2313
2336
  interface QueueSendOptions {
2314
2337
  contentType?: QueueContentType;
@@ -2322,6 +2345,19 @@ interface MessageSendRequest<Body = unknown> {
2322
2345
  contentType?: QueueContentType;
2323
2346
  delaySeconds?: number;
2324
2347
  }
2348
+ interface QueueMetrics {
2349
+ backlogCount: number;
2350
+ backlogBytes: number;
2351
+ oldestMessageTimestamp?: Date;
2352
+ }
2353
+ interface MessageBatchMetrics {
2354
+ backlogCount: number;
2355
+ backlogBytes: number;
2356
+ oldestMessageTimestamp?: Date;
2357
+ }
2358
+ interface MessageBatchMetadata {
2359
+ metrics: MessageBatchMetrics;
2360
+ }
2325
2361
  interface QueueRetryOptions {
2326
2362
  delaySeconds?: number;
2327
2363
  }
@@ -2336,12 +2372,14 @@ interface Message<Body = unknown> {
2336
2372
  interface QueueEvent<Body = unknown> extends ExtendableEvent {
2337
2373
  readonly messages: readonly Message<Body>[];
2338
2374
  readonly queue: string;
2375
+ readonly metadata: MessageBatchMetadata;
2339
2376
  retryAll(options?: QueueRetryOptions): void;
2340
2377
  ackAll(): void;
2341
2378
  }
2342
2379
  interface MessageBatch<Body = unknown> {
2343
2380
  readonly messages: readonly Message<Body>[];
2344
2381
  readonly queue: string;
2382
+ readonly metadata: MessageBatchMetadata;
2345
2383
  retryAll(options?: QueueRetryOptions): void;
2346
2384
  ackAll(): void;
2347
2385
  }
@@ -3878,73 +3916,145 @@ declare abstract class Performance {
3878
3916
  // ============ AI Search Error Interfaces ============
3879
3917
  interface AiSearchInternalError extends Error {}
3880
3918
  interface AiSearchNotFoundError extends Error {}
3881
- // ============ AI Search Request Types ============
3882
- type AiSearchSearchRequest = {
3883
- messages: Array<{
3884
- role: "system" | "developer" | "user" | "assistant" | "tool";
3885
- content: string | null;
3886
- }>;
3887
- ai_search_options?: {
3888
- retrieval?: {
3889
- retrieval_type?: "vector" | "keyword" | "hybrid";
3890
- /** Match threshold (0-1, default 0.4) */
3891
- match_threshold?: number;
3892
- /** Maximum number of results (1-50, default 10) */
3893
- max_num_results?: number;
3894
- filters?: VectorizeVectorMetadataFilter;
3895
- /** Context expansion (0-3, default 0) */
3896
- context_expansion?: number;
3897
- [key: string]: unknown;
3898
- };
3899
- query_rewrite?: {
3900
- enabled?: boolean;
3901
- model?: string;
3902
- rewrite_prompt?: string;
3903
- [key: string]: unknown;
3904
- };
3905
- reranking?: {
3906
- enabled?: boolean;
3907
- model?: "@cf/baai/bge-reranker-base" | string;
3908
- /** Match threshold (0-1, default 0.4) */
3909
- match_threshold?: number;
3910
- [key: string]: unknown;
3911
- };
3919
+ // ============ AI Search Common Types ============
3920
+ /** A single message in a conversation-style search or chat request. */
3921
+ type AiSearchMessage = {
3922
+ role: "system" | "developer" | "user" | "assistant" | "tool";
3923
+ content: string | null;
3924
+ };
3925
+ /**
3926
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
3927
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
3928
+ */
3929
+ type AiSearchOptions = {
3930
+ retrieval?: {
3931
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
3932
+ retrieval_type?: "vector" | "keyword" | "hybrid";
3933
+ /** Fusion method for combining vector + keyword results. */
3934
+ fusion_method?: "max" | "rrf";
3935
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
3936
+ keyword_match_mode?: "and" | "or";
3937
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
3938
+ match_threshold?: number;
3939
+ /** Maximum number of results to return (1-50). Default 10. */
3940
+ max_num_results?: number;
3941
+ /** Vectorize metadata filters applied to the search. */
3942
+ filters?: VectorizeVectorMetadataFilter;
3943
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
3944
+ context_expansion?: number;
3945
+ /** If true, return only item metadata without chunk text. */
3946
+ metadata_only?: boolean;
3947
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
3948
+ return_on_failure?: boolean;
3949
+ /** Boost results by metadata field values. Max 3 entries. */
3950
+ boost_by?: Array<{
3951
+ field: string;
3952
+ direction?: "asc" | "desc" | "exists" | "not_exists";
3953
+ }>;
3954
+ [key: string]: unknown;
3955
+ };
3956
+ query_rewrite?: {
3957
+ enabled?: boolean;
3958
+ model?: string;
3959
+ rewrite_prompt?: string;
3960
+ [key: string]: unknown;
3961
+ };
3962
+ reranking?: {
3963
+ enabled?: boolean;
3964
+ model?: string;
3965
+ /** Match threshold (0-1, default 0.4) */
3966
+ match_threshold?: number;
3912
3967
  [key: string]: unknown;
3913
3968
  };
3969
+ cache?: {
3970
+ enabled?: boolean;
3971
+ cache_threshold?:
3972
+ | "super_strict_match"
3973
+ | "close_enough"
3974
+ | "flexible_friend"
3975
+ | "anything_goes";
3976
+ };
3977
+ [key: string]: unknown;
3914
3978
  };
3979
+ // ============ AI Search Request Types ============
3980
+ /**
3981
+ * Request body for single-instance search.
3982
+ * Exactly one of `query` or `messages` must be provided.
3983
+ */
3984
+ type AiSearchSearchRequest =
3985
+ | {
3986
+ /** Simple query string. */
3987
+ query: string;
3988
+ messages?: never;
3989
+ ai_search_options?: AiSearchOptions;
3990
+ }
3991
+ | {
3992
+ query?: never;
3993
+ /** Conversation-style input. At least one user message with non-empty content is required. */
3994
+ messages: AiSearchMessage[];
3995
+ ai_search_options?: AiSearchOptions;
3996
+ };
3915
3997
  type AiSearchChatCompletionsRequest = {
3916
- messages: Array<{
3917
- role: "system" | "developer" | "user" | "assistant" | "tool";
3918
- content: string | null;
3919
- [key: string]: unknown;
3920
- }>;
3998
+ messages: AiSearchMessage[];
3921
3999
  model?: string;
3922
4000
  stream?: boolean;
3923
- ai_search_options?: {
3924
- retrieval?: {
3925
- retrieval_type?: "vector" | "keyword" | "hybrid";
3926
- match_threshold?: number;
3927
- max_num_results?: number;
3928
- filters?: VectorizeVectorMetadataFilter;
3929
- context_expansion?: number;
3930
- [key: string]: unknown;
3931
- };
3932
- query_rewrite?: {
3933
- enabled?: boolean;
3934
- model?: string;
3935
- rewrite_prompt?: string;
3936
- [key: string]: unknown;
3937
- };
3938
- reranking?: {
3939
- enabled?: boolean;
3940
- model?: "@cf/baai/bge-reranker-base" | string;
3941
- match_threshold?: number;
3942
- [key: string]: unknown;
3943
- };
3944
- [key: string]: unknown;
3945
- };
4001
+ ai_search_options?: AiSearchOptions;
3946
4002
  [key: string]: unknown;
3947
4003
  };
4004
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4005
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4006
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4007
+ /** Instance IDs to search across (1-10). */
4008
+ instance_ids: string[];
4009
+ };
4010
+ /**
4011
+ * Request for searching across multiple instances within a namespace.
4012
+ * `ai_search_options` is required and must include `instance_ids`.
4013
+ * Exactly one of `query` or `messages` must be provided.
4014
+ */
4015
+ type AiSearchMultiSearchRequest =
4016
+ | {
4017
+ /** Simple query string. */
4018
+ query: string;
4019
+ messages?: never;
4020
+ ai_search_options: AiSearchMultiSearchOptions;
4021
+ }
4022
+ | {
4023
+ query?: never;
4024
+ /** Conversation-style input. */
4025
+ messages: AiSearchMessage[];
4026
+ ai_search_options: AiSearchMultiSearchOptions;
4027
+ };
4028
+ /** A search result chunk tagged with the instance it originated from. */
4029
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4030
+ instance_id: string;
4031
+ };
4032
+ /** Describes a per-instance error during a multi-instance operation. */
4033
+ type AiSearchMultiSearchError = {
4034
+ instance_id: string;
4035
+ message: string;
4036
+ };
4037
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4038
+ type AiSearchMultiSearchResponse = {
4039
+ search_query: string;
4040
+ chunks: AiSearchMultiSearchChunk[];
4041
+ errors?: AiSearchMultiSearchError[];
4042
+ };
4043
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4044
+ type AiSearchMultiChatCompletionsRequest = Omit<
4045
+ AiSearchChatCompletionsRequest,
4046
+ "ai_search_options"
4047
+ > & {
4048
+ ai_search_options: AiSearchMultiSearchOptions;
4049
+ };
4050
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4051
+ type AiSearchMultiChatCompletionsResponse = Omit<
4052
+ AiSearchChatCompletionsResponse,
4053
+ "chunks"
4054
+ > & {
4055
+ chunks: AiSearchMultiSearchChunk[];
4056
+ errors?: AiSearchMultiSearchError[];
4057
+ };
3948
4058
  // ============ AI Search Response Types ============
3949
4059
  type AiSearchSearchResponse = {
3950
4060
  search_query: string;
@@ -3964,6 +4074,14 @@ type AiSearchSearchResponse = {
3964
4074
  keyword_score?: number;
3965
4075
  /** Vector similarity score (0-1) */
3966
4076
  vector_score?: number;
4077
+ /** Keyword rank position */
4078
+ keyword_rank?: number;
4079
+ /** Vector rank position */
4080
+ vector_rank?: number;
4081
+ /** Reranking model score */
4082
+ reranking_score?: number;
4083
+ /** Fusion method used to combine results */
4084
+ fusion_method?: "rrf" | "max";
3967
4085
  [key: string]: unknown;
3968
4086
  };
3969
4087
  }>;
@@ -3992,19 +4110,88 @@ type AiSearchStatsResponse = {
3992
4110
  skipped?: number;
3993
4111
  outdated?: number;
3994
4112
  last_activity?: string;
4113
+ /** Storage engine statistics. */
4114
+ engine?: {
4115
+ vectorize?: {
4116
+ vectorsCount: number;
4117
+ dimensions: number;
4118
+ };
4119
+ r2?: {
4120
+ payloadSizeBytes: number;
4121
+ metadataSizeBytes: number;
4122
+ objectCount: number;
4123
+ };
4124
+ };
3995
4125
  };
3996
4126
  // ============ AI Search Instance Info Types ============
3997
4127
  type AiSearchInstanceInfo = {
3998
4128
  id: string;
3999
4129
  type?: "r2" | "web-crawler" | string;
4000
4130
  source?: string;
4131
+ source_params?: unknown;
4001
4132
  paused?: boolean;
4002
4133
  status?: string;
4003
4134
  namespace?: string;
4004
4135
  created_at?: string;
4005
4136
  modified_at?: string;
4137
+ token_id?: string;
4138
+ ai_gateway_id?: string;
4139
+ rewrite_query?: boolean;
4140
+ reranking?: boolean;
4141
+ embedding_model?: string;
4142
+ ai_search_model?: string;
4143
+ rewrite_model?: string;
4144
+ reranking_model?: string;
4145
+ /** @deprecated Use index_method instead. */
4146
+ hybrid_search_enabled?: boolean;
4147
+ /** Controls which storage backends are active. */
4148
+ index_method?: {
4149
+ vector?: boolean;
4150
+ keyword?: boolean;
4151
+ };
4152
+ /** Fusion method for combining vector and keyword results. */
4153
+ fusion_method?: "max" | "rrf";
4154
+ indexing_options?: {
4155
+ keyword_tokenizer?: "porter" | "trigram";
4156
+ } | null;
4157
+ retrieval_options?: {
4158
+ keyword_match_mode?: "and" | "or";
4159
+ boost_by?: Array<{
4160
+ field: string;
4161
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4162
+ }>;
4163
+ } | null;
4164
+ chunk?: boolean;
4165
+ chunk_size?: number;
4166
+ chunk_overlap?: number;
4167
+ score_threshold?: number;
4168
+ max_num_results?: number;
4169
+ cache?: boolean;
4170
+ cache_threshold?:
4171
+ | "super_strict_match"
4172
+ | "close_enough"
4173
+ | "flexible_friend"
4174
+ | "anything_goes";
4175
+ custom_metadata?: Array<{
4176
+ field_name: string;
4177
+ data_type: "text" | "number" | "boolean" | "datetime";
4178
+ }>;
4179
+ /** Sync interval in seconds. */
4180
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4181
+ metadata?: Record<string, unknown>;
4006
4182
  [key: string]: unknown;
4007
4183
  };
4184
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4185
+ type AiSearchListInstancesParams = {
4186
+ page?: number;
4187
+ per_page?: number;
4188
+ /** Search instances by ID. */
4189
+ search?: string;
4190
+ /** Field to sort by. */
4191
+ order_by?: "created_at";
4192
+ /** Sort direction. */
4193
+ order_by_direction?: "asc" | "desc";
4194
+ };
4008
4195
  type AiSearchListResponse = {
4009
4196
  result: AiSearchInstanceInfo[];
4010
4197
  result_info?: {
@@ -4032,19 +4219,64 @@ type AiSearchConfig = {
4032
4219
  reranking?: boolean;
4033
4220
  embedding_model?: string;
4034
4221
  ai_search_model?: string;
4222
+ rewrite_model?: string;
4223
+ reranking_model?: string;
4224
+ /** @deprecated Use index_method instead. */
4225
+ hybrid_search_enabled?: boolean;
4226
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4227
+ index_method?: {
4228
+ vector?: boolean;
4229
+ keyword?: boolean;
4230
+ };
4231
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4232
+ fusion_method?: "max" | "rrf";
4233
+ indexing_options?: {
4234
+ keyword_tokenizer?: "porter" | "trigram";
4235
+ } | null;
4236
+ retrieval_options?: {
4237
+ keyword_match_mode?: "and" | "or";
4238
+ boost_by?: Array<{
4239
+ field: string;
4240
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4241
+ }>;
4242
+ } | null;
4243
+ chunk?: boolean;
4244
+ chunk_size?: number;
4245
+ chunk_overlap?: number;
4246
+ /** Minimum similarity score (0-1) for a result to be included. */
4247
+ score_threshold?: number;
4248
+ max_num_results?: number;
4249
+ cache?: boolean;
4250
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4251
+ cache_threshold?:
4252
+ | "super_strict_match"
4253
+ | "close_enough"
4254
+ | "flexible_friend"
4255
+ | "anything_goes";
4256
+ custom_metadata?: Array<{
4257
+ field_name: string;
4258
+ data_type: "text" | "number" | "boolean" | "datetime";
4259
+ }>;
4260
+ namespace?: string;
4261
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4262
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4263
+ metadata?: Record<string, unknown>;
4035
4264
  [key: string]: unknown;
4036
4265
  };
4037
4266
  // ============ AI Search Item Types ============
4038
4267
  type AiSearchItemInfo = {
4039
4268
  id: string;
4040
4269
  key: string;
4041
- status:
4042
- | "completed"
4043
- | "error"
4044
- | "skipped"
4045
- | "queued"
4046
- | "processing"
4047
- | "outdated";
4270
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4271
+ next_action?: "INDEX" | "DELETE" | null;
4272
+ error?: string;
4273
+ checksum?: string;
4274
+ namespace?: string;
4275
+ chunks_count?: number | null;
4276
+ file_size?: number | null;
4277
+ source_id?: string | null;
4278
+ last_seen_at?: string;
4279
+ created_at?: string;
4048
4280
  metadata?: Record<string, unknown>;
4049
4281
  [key: string]: unknown;
4050
4282
  };
@@ -4060,6 +4292,22 @@ type AiSearchUploadItemOptions = {
4060
4292
  type AiSearchListItemsParams = {
4061
4293
  page?: number;
4062
4294
  per_page?: number;
4295
+ /** Search items by key name. */
4296
+ search?: string;
4297
+ /** Sort order for results. */
4298
+ sort_by?: "status" | "modified_at";
4299
+ /** Filter items by processing status. */
4300
+ status?:
4301
+ | "queued"
4302
+ | "running"
4303
+ | "completed"
4304
+ | "error"
4305
+ | "skipped"
4306
+ | "outdated";
4307
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4308
+ source?: string;
4309
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4310
+ metadata_filter?: string;
4063
4311
  };
4064
4312
  type AiSearchListItemsResponse = {
4065
4313
  result: AiSearchItemInfo[];
@@ -4070,6 +4318,61 @@ type AiSearchListItemsResponse = {
4070
4318
  total_count: number;
4071
4319
  };
4072
4320
  };
4321
+ // ============ AI Search Item Logs Types ============
4322
+ type AiSearchItemLogsParams = {
4323
+ /** Maximum number of log entries to return (1-100, default 50). */
4324
+ limit?: number;
4325
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4326
+ cursor?: string;
4327
+ };
4328
+ type AiSearchItemLog = {
4329
+ timestamp: string;
4330
+ action: string;
4331
+ message: string;
4332
+ fileKey?: string;
4333
+ chunkCount?: number;
4334
+ processingTimeMs?: number;
4335
+ errorType?: string;
4336
+ };
4337
+ /** Paginated response for item processing logs (cursor-based). */
4338
+ type AiSearchItemLogsResponse = {
4339
+ result: AiSearchItemLog[];
4340
+ result_info: {
4341
+ count: number;
4342
+ per_page: number;
4343
+ cursor: string | null;
4344
+ truncated: boolean;
4345
+ };
4346
+ };
4347
+ // ============ AI Search Item Chunks Types ============
4348
+ type AiSearchItemChunksParams = {
4349
+ /** Maximum number of chunks to return (1-100, default 20). */
4350
+ limit?: number;
4351
+ /** Offset into the chunks list (default 0). */
4352
+ offset?: number;
4353
+ };
4354
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4355
+ type AiSearchItemChunk = {
4356
+ id: string;
4357
+ text: string;
4358
+ start_byte: number;
4359
+ end_byte: number;
4360
+ item?: {
4361
+ timestamp?: number;
4362
+ key: string;
4363
+ metadata?: Record<string, unknown>;
4364
+ };
4365
+ };
4366
+ /** Paginated response for item chunks (offset-based). */
4367
+ type AiSearchItemChunksResponse = {
4368
+ result: AiSearchItemChunk[];
4369
+ result_info: {
4370
+ count: number;
4371
+ total: number;
4372
+ limit: number;
4373
+ offset: number;
4374
+ };
4375
+ };
4073
4376
  // ============ AI Search Job Types ============
4074
4377
  type AiSearchJobInfo = {
4075
4378
  id: string;
@@ -4118,7 +4421,7 @@ type AiSearchJobLogsResponse = {
4118
4421
  // ============ AI Search Sub-Service Classes ============
4119
4422
  /**
4120
4423
  * Single item service for an AI Search instance.
4121
- * Provides info, delete, and download operations on a specific item.
4424
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4122
4425
  */
4123
4426
  declare abstract class AiSearchItem {
4124
4427
  /** Get metadata about this item. */
@@ -4128,6 +4431,25 @@ declare abstract class AiSearchItem {
4128
4431
  * @returns Object with body stream, content type, filename, and size.
4129
4432
  */
4130
4433
  download(): Promise<AiSearchItemContentResult>;
4434
+ /**
4435
+ * Trigger re-indexing of this item.
4436
+ * @returns The updated item info.
4437
+ */
4438
+ sync(): Promise<AiSearchItemInfo>;
4439
+ /**
4440
+ * Retrieve processing logs for this item (cursor-based pagination).
4441
+ * @param params Optional pagination parameters (limit, cursor).
4442
+ * @returns Paginated log entries for this item.
4443
+ */
4444
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4445
+ /**
4446
+ * List indexed chunks for this item (offset-based pagination).
4447
+ * @param params Optional pagination parameters (limit, offset).
4448
+ * @returns Paginated chunk entries for this item.
4449
+ */
4450
+ chunks(
4451
+ params?: AiSearchItemChunksParams,
4452
+ ): Promise<AiSearchItemChunksResponse>;
4131
4453
  }
4132
4454
  /**
4133
4455
  * Items collection service for an AI Search instance.
@@ -4137,49 +4459,64 @@ declare abstract class AiSearchItems {
4137
4459
  /** List items in this instance. */
4138
4460
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4139
4461
  /**
4140
- * Upload a file as an item.
4462
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4463
+ * filename already exists, it is overwritten and re-indexed.
4141
4464
  * @param name Filename for the uploaded item.
4142
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4465
+ * @param content File content as a ReadableStream, Blob, or string.
4143
4466
  * @param options Optional metadata to attach to the item.
4144
4467
  * @returns The created item info.
4145
4468
  */
4146
4469
  upload(
4147
4470
  name: string,
4148
- content: ReadableStream | ArrayBuffer | string,
4471
+ content: ReadableStream | Blob | string,
4149
4472
  options?: AiSearchUploadItemOptions,
4150
4473
  ): Promise<AiSearchItemInfo>;
4151
4474
  /**
4152
4475
  * Upload a file and poll until processing completes.
4476
+ * Behaves as an upsert: if an item with the same filename already exists,
4477
+ * it is overwritten and re-indexed.
4153
4478
  * @param name Filename for the uploaded item.
4154
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4155
- * @param options Optional metadata to attach to the item.
4479
+ * @param content File content as a ReadableStream, Blob, or string.
4480
+ * @param options Optional metadata and polling configuration.
4156
4481
  * @returns The item info after processing completes (or timeout).
4157
4482
  */
4158
4483
  uploadAndPoll(
4159
4484
  name: string,
4160
- content: ReadableStream | ArrayBuffer | string,
4161
- options?: AiSearchUploadItemOptions,
4485
+ content: ReadableStream | Blob | string,
4486
+ options?: AiSearchUploadItemOptions & {
4487
+ /** Polling interval in milliseconds (default 1000). */
4488
+ pollIntervalMs?: number;
4489
+ /** Maximum time to wait in milliseconds (default 30000). */
4490
+ timeoutMs?: number;
4491
+ },
4162
4492
  ): Promise<AiSearchItemInfo>;
4163
4493
  /**
4164
4494
  * Get an item by ID.
4165
4495
  * @param itemId The item identifier.
4166
- * @returns Item service for info, delete, and download operations.
4496
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4167
4497
  */
4168
4498
  get(itemId: string): AiSearchItem;
4169
- /** Delete this item from the instance.
4499
+ /**
4500
+ * Delete an item from the instance.
4170
4501
  * @param itemId The item identifier.
4171
4502
  */
4172
4503
  delete(itemId: string): Promise<void>;
4173
4504
  }
4174
4505
  /**
4175
4506
  * Single job service for an AI Search instance.
4176
- * Provides info and logs for a specific job.
4507
+ * Provides info, logs, and cancel operations for a specific job.
4177
4508
  */
4178
4509
  declare abstract class AiSearchJob {
4179
4510
  /** Get metadata about this job. */
4180
4511
  info(): Promise<AiSearchJobInfo>;
4181
4512
  /** Get logs for this job. */
4182
4513
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4514
+ /**
4515
+ * Cancel a running job.
4516
+ * @returns The updated job info.
4517
+ * @throws AiSearchNotFoundError if the job does not exist.
4518
+ */
4519
+ cancel(): Promise<AiSearchJobInfo>;
4183
4520
  }
4184
4521
  /**
4185
4522
  * Jobs collection service for an AI Search instance.
@@ -4197,7 +4534,7 @@ declare abstract class AiSearchJobs {
4197
4534
  /**
4198
4535
  * Get a job by ID.
4199
4536
  * @param jobId The job identifier.
4200
- * @returns Job service for info and logs operations.
4537
+ * @returns Job service for info, logs, and cancel operations.
4201
4538
  */
4202
4539
  get(jobId: string): AiSearchJob;
4203
4540
  }
@@ -4216,7 +4553,7 @@ declare abstract class AiSearchJobs {
4216
4553
  * // Via namespace binding
4217
4554
  * const instance = env.AI_SEARCH.get("blog");
4218
4555
  * const results = await instance.search({
4219
- * messages: [{ role: "user", content: "How does caching work?" }],
4556
+ * query: "How does caching work?",
4220
4557
  * });
4221
4558
  *
4222
4559
  * // Via single instance binding
@@ -4228,7 +4565,7 @@ declare abstract class AiSearchJobs {
4228
4565
  declare abstract class AiSearchInstance {
4229
4566
  /**
4230
4567
  * Search the AI Search instance for relevant chunks.
4231
- * @param params Search request with messages and optional AI search options.
4568
+ * @param params Search request with query or messages and optional AI search options.
4232
4569
  * @returns Search response with matching chunks and search query.
4233
4570
  */
4234
4571
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4260,7 +4597,7 @@ declare abstract class AiSearchInstance {
4260
4597
  info(): Promise<AiSearchInstanceInfo>;
4261
4598
  /**
4262
4599
  * Get instance statistics (item count, indexing status, etc.).
4263
- * @returns Statistics with counts per status and last activity time.
4600
+ * @returns Statistics with counts per status, last activity time, and engine details.
4264
4601
  */
4265
4602
  stats(): Promise<AiSearchStatsResponse>;
4266
4603
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4272,27 +4609,30 @@ declare abstract class AiSearchInstance {
4272
4609
  * Namespace-level AI Search service.
4273
4610
  *
4274
4611
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4275
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4612
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4613
+ * and multi-instance search/chat operations.
4276
4614
  *
4277
4615
  * @example
4278
4616
  * ```ts
4279
4617
  * // Access an instance within the namespace
4280
4618
  * const blog = env.AI_SEARCH.get("blog");
4281
- * const results = await blog.search({
4282
- * messages: [{ role: "user", content: "How does caching work?" }],
4283
- * });
4619
+ * const results = await blog.search({ query: "How does caching work?" });
4284
4620
  *
4285
4621
  * // List all instances in the namespace
4286
4622
  * const instances = await env.AI_SEARCH.list();
4287
4623
  *
4288
4624
  * // Create a new instance with built-in storage
4289
- * const tenant = await env.AI_SEARCH.create({
4290
- * id: "tenant-123",
4291
- * });
4625
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4292
4626
  *
4293
4627
  * // Upload items into the instance
4294
4628
  * await tenant.items.upload("doc.pdf", fileContent);
4295
4629
  *
4630
+ * // Search across multiple instances
4631
+ * const multi = await env.AI_SEARCH.search({
4632
+ * query: "caching",
4633
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4634
+ * });
4635
+ *
4296
4636
  * // Delete an instance
4297
4637
  * await env.AI_SEARCH.delete("tenant-123");
4298
4638
  * ```
@@ -4305,10 +4645,11 @@ declare abstract class AiSearchNamespace {
4305
4645
  */
4306
4646
  get(name: string): AiSearchInstance;
4307
4647
  /**
4308
- * List all instances in the bound namespace.
4309
- * @returns Array of instance metadata.
4648
+ * List instances in the bound namespace.
4649
+ * @param params Optional pagination, search, and ordering parameters.
4650
+ * @returns Array of instance metadata with pagination info.
4310
4651
  */
4311
- list(): Promise<AiSearchListResponse>;
4652
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4312
4653
  /**
4313
4654
  * Create a new instance within the bound namespace.
4314
4655
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4333,6 +4674,35 @@ declare abstract class AiSearchNamespace {
4333
4674
  * @param name Instance name to delete.
4334
4675
  */
4335
4676
  delete(name: string): Promise<void>;
4677
+ /**
4678
+ * Search across multiple instances within the bound namespace.
4679
+ * Fans out to the specified instance_ids and merges results.
4680
+ * @param params Search request with required `ai_search_options.instance_ids`.
4681
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4682
+ */
4683
+ search(
4684
+ params: AiSearchMultiSearchRequest,
4685
+ ): Promise<AiSearchMultiSearchResponse>;
4686
+ /**
4687
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4688
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4689
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4690
+ * @returns ReadableStream of server-sent events.
4691
+ */
4692
+ chatCompletions(
4693
+ params: AiSearchMultiChatCompletionsRequest & {
4694
+ stream: true;
4695
+ },
4696
+ ): Promise<ReadableStream>;
4697
+ /**
4698
+ * Generate chat completions across multiple instances within the bound namespace.
4699
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4700
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4701
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4702
+ */
4703
+ chatCompletions(
4704
+ params: AiSearchMultiChatCompletionsRequest,
4705
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4336
4706
  }
4337
4707
  type AiImageClassificationInput = {
4338
4708
  image: number[];
@@ -11984,8 +12354,8 @@ declare module "cloudflare:email" {
11984
12354
  * Evaluation context for targeting rules.
11985
12355
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
11986
12356
  */
11987
- type EvaluationContext = Record<string, string | number | boolean>;
11988
- interface EvaluationDetails<T> {
12357
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12358
+ interface FlagshipEvaluationDetails<T> {
11989
12359
  flagKey: string;
11990
12360
  value: T;
11991
12361
  variant?: string | undefined;
@@ -11993,7 +12363,7 @@ interface EvaluationDetails<T> {
11993
12363
  errorCode?: string | undefined;
11994
12364
  errorMessage?: string | undefined;
11995
12365
  }
11996
- interface FlagEvaluationError extends Error {}
12366
+ interface FlagshipEvaluationError extends Error {}
11997
12367
  /**
11998
12368
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
11999
12369
  *
@@ -12013,7 +12383,7 @@ interface FlagEvaluationError extends Error {}
12013
12383
  * console.log(details.variant, details.reason);
12014
12384
  * ```
12015
12385
  */
12016
- declare abstract class Flags {
12386
+ declare abstract class Flagship {
12017
12387
  /**
12018
12388
  * Get a flag value without type checking.
12019
12389
  * @param flagKey The key of the flag to evaluate.
@@ -12023,7 +12393,7 @@ declare abstract class Flags {
12023
12393
  get(
12024
12394
  flagKey: string,
12025
12395
  defaultValue?: unknown,
12026
- context?: EvaluationContext,
12396
+ context?: FlagshipEvaluationContext,
12027
12397
  ): Promise<unknown>;
12028
12398
  /**
12029
12399
  * Get a boolean flag value.
@@ -12034,7 +12404,7 @@ declare abstract class Flags {
12034
12404
  getBooleanValue(
12035
12405
  flagKey: string,
12036
12406
  defaultValue: boolean,
12037
- context?: EvaluationContext,
12407
+ context?: FlagshipEvaluationContext,
12038
12408
  ): Promise<boolean>;
12039
12409
  /**
12040
12410
  * Get a string flag value.
@@ -12045,7 +12415,7 @@ declare abstract class Flags {
12045
12415
  getStringValue(
12046
12416
  flagKey: string,
12047
12417
  defaultValue: string,
12048
- context?: EvaluationContext,
12418
+ context?: FlagshipEvaluationContext,
12049
12419
  ): Promise<string>;
12050
12420
  /**
12051
12421
  * Get a number flag value.
@@ -12056,7 +12426,7 @@ declare abstract class Flags {
12056
12426
  getNumberValue(
12057
12427
  flagKey: string,
12058
12428
  defaultValue: number,
12059
- context?: EvaluationContext,
12429
+ context?: FlagshipEvaluationContext,
12060
12430
  ): Promise<number>;
12061
12431
  /**
12062
12432
  * Get an object flag value.
@@ -12067,7 +12437,7 @@ declare abstract class Flags {
12067
12437
  getObjectValue<T extends object>(
12068
12438
  flagKey: string,
12069
12439
  defaultValue: T,
12070
- context?: EvaluationContext,
12440
+ context?: FlagshipEvaluationContext,
12071
12441
  ): Promise<T>;
12072
12442
  /**
12073
12443
  * Get a boolean flag value with full evaluation details.
@@ -12078,8 +12448,8 @@ declare abstract class Flags {
12078
12448
  getBooleanDetails(
12079
12449
  flagKey: string,
12080
12450
  defaultValue: boolean,
12081
- context?: EvaluationContext,
12082
- ): Promise<EvaluationDetails<boolean>>;
12451
+ context?: FlagshipEvaluationContext,
12452
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12083
12453
  /**
12084
12454
  * Get a string flag value with full evaluation details.
12085
12455
  * @param flagKey The key of the flag to evaluate.
@@ -12089,8 +12459,8 @@ declare abstract class Flags {
12089
12459
  getStringDetails(
12090
12460
  flagKey: string,
12091
12461
  defaultValue: string,
12092
- context?: EvaluationContext,
12093
- ): Promise<EvaluationDetails<string>>;
12462
+ context?: FlagshipEvaluationContext,
12463
+ ): Promise<FlagshipEvaluationDetails<string>>;
12094
12464
  /**
12095
12465
  * Get a number flag value with full evaluation details.
12096
12466
  * @param flagKey The key of the flag to evaluate.
@@ -12100,8 +12470,8 @@ declare abstract class Flags {
12100
12470
  getNumberDetails(
12101
12471
  flagKey: string,
12102
12472
  defaultValue: number,
12103
- context?: EvaluationContext,
12104
- ): Promise<EvaluationDetails<number>>;
12473
+ context?: FlagshipEvaluationContext,
12474
+ ): Promise<FlagshipEvaluationDetails<number>>;
12105
12475
  /**
12106
12476
  * Get an object flag value with full evaluation details.
12107
12477
  * @param flagKey The key of the flag to evaluate.
@@ -12111,8 +12481,8 @@ declare abstract class Flags {
12111
12481
  getObjectDetails<T extends object>(
12112
12482
  flagKey: string,
12113
12483
  defaultValue: T,
12114
- context?: EvaluationContext,
12115
- ): Promise<EvaluationDetails<T>>;
12484
+ context?: FlagshipEvaluationContext,
12485
+ ): Promise<FlagshipEvaluationDetails<T>>;
12116
12486
  }
12117
12487
  /**
12118
12488
  * Hello World binding to serve as an explanatory example. DO NOT USE