@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.
@@ -544,6 +544,7 @@ declare abstract class Navigator {
544
544
  sendBeacon(url: string, body?: BodyInit): boolean;
545
545
  readonly userAgent: string;
546
546
  readonly hardwareConcurrency: number;
547
+ readonly platform: string;
547
548
  }
548
549
  interface AlarmInvocationInfo {
549
550
  readonly isRetry: boolean;
@@ -2319,11 +2320,34 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2319
2320
  }
2320
2321
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2321
2322
  interface Queue<Body = unknown> {
2322
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2323
+ metrics(): Promise<QueueMetrics>;
2324
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2323
2325
  sendBatch(
2324
2326
  messages: Iterable<MessageSendRequest<Body>>,
2325
2327
  options?: QueueSendBatchOptions,
2326
- ): Promise<void>;
2328
+ ): Promise<QueueSendBatchResponse>;
2329
+ }
2330
+ interface QueueSendMetrics {
2331
+ backlogCount: number;
2332
+ backlogBytes: number;
2333
+ oldestMessageTimestamp?: Date;
2334
+ }
2335
+ interface QueueSendMetadata {
2336
+ metrics: QueueSendMetrics;
2337
+ }
2338
+ interface QueueSendResponse {
2339
+ metadata: QueueSendMetadata;
2340
+ }
2341
+ interface QueueSendBatchMetrics {
2342
+ backlogCount: number;
2343
+ backlogBytes: number;
2344
+ oldestMessageTimestamp?: Date;
2345
+ }
2346
+ interface QueueSendBatchMetadata {
2347
+ metrics: QueueSendBatchMetrics;
2348
+ }
2349
+ interface QueueSendBatchResponse {
2350
+ metadata: QueueSendBatchMetadata;
2327
2351
  }
2328
2352
  interface QueueSendOptions {
2329
2353
  contentType?: QueueContentType;
@@ -2337,6 +2361,19 @@ interface MessageSendRequest<Body = unknown> {
2337
2361
  contentType?: QueueContentType;
2338
2362
  delaySeconds?: number;
2339
2363
  }
2364
+ interface QueueMetrics {
2365
+ backlogCount: number;
2366
+ backlogBytes: number;
2367
+ oldestMessageTimestamp?: Date;
2368
+ }
2369
+ interface MessageBatchMetrics {
2370
+ backlogCount: number;
2371
+ backlogBytes: number;
2372
+ oldestMessageTimestamp?: Date;
2373
+ }
2374
+ interface MessageBatchMetadata {
2375
+ metrics: MessageBatchMetrics;
2376
+ }
2340
2377
  interface QueueRetryOptions {
2341
2378
  delaySeconds?: number;
2342
2379
  }
@@ -2351,12 +2388,14 @@ interface Message<Body = unknown> {
2351
2388
  interface QueueEvent<Body = unknown> extends ExtendableEvent {
2352
2389
  readonly messages: readonly Message<Body>[];
2353
2390
  readonly queue: string;
2391
+ readonly metadata: MessageBatchMetadata;
2354
2392
  retryAll(options?: QueueRetryOptions): void;
2355
2393
  ackAll(): void;
2356
2394
  }
2357
2395
  interface MessageBatch<Body = unknown> {
2358
2396
  readonly messages: readonly Message<Body>[];
2359
2397
  readonly queue: string;
2398
+ readonly metadata: MessageBatchMetadata;
2360
2399
  retryAll(options?: QueueRetryOptions): void;
2361
2400
  ackAll(): void;
2362
2401
  }
@@ -3954,73 +3993,145 @@ declare abstract class Performance {
3954
3993
  // ============ AI Search Error Interfaces ============
3955
3994
  interface AiSearchInternalError extends Error {}
3956
3995
  interface AiSearchNotFoundError extends Error {}
3957
- // ============ AI Search Request Types ============
3958
- type AiSearchSearchRequest = {
3959
- messages: Array<{
3960
- role: "system" | "developer" | "user" | "assistant" | "tool";
3961
- content: string | null;
3962
- }>;
3963
- ai_search_options?: {
3964
- retrieval?: {
3965
- retrieval_type?: "vector" | "keyword" | "hybrid";
3966
- /** Match threshold (0-1, default 0.4) */
3967
- match_threshold?: number;
3968
- /** Maximum number of results (1-50, default 10) */
3969
- max_num_results?: number;
3970
- filters?: VectorizeVectorMetadataFilter;
3971
- /** Context expansion (0-3, default 0) */
3972
- context_expansion?: number;
3973
- [key: string]: unknown;
3974
- };
3975
- query_rewrite?: {
3976
- enabled?: boolean;
3977
- model?: string;
3978
- rewrite_prompt?: string;
3979
- [key: string]: unknown;
3980
- };
3981
- reranking?: {
3982
- enabled?: boolean;
3983
- model?: "@cf/baai/bge-reranker-base" | string;
3984
- /** Match threshold (0-1, default 0.4) */
3985
- match_threshold?: number;
3986
- [key: string]: unknown;
3987
- };
3996
+ // ============ AI Search Common Types ============
3997
+ /** A single message in a conversation-style search or chat request. */
3998
+ type AiSearchMessage = {
3999
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4000
+ content: string | null;
4001
+ };
4002
+ /**
4003
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4004
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4005
+ */
4006
+ type AiSearchOptions = {
4007
+ retrieval?: {
4008
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4009
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4010
+ /** Fusion method for combining vector + keyword results. */
4011
+ fusion_method?: "max" | "rrf";
4012
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4013
+ keyword_match_mode?: "and" | "or";
4014
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4015
+ match_threshold?: number;
4016
+ /** Maximum number of results to return (1-50). Default 10. */
4017
+ max_num_results?: number;
4018
+ /** Vectorize metadata filters applied to the search. */
4019
+ filters?: VectorizeVectorMetadataFilter;
4020
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4021
+ context_expansion?: number;
4022
+ /** If true, return only item metadata without chunk text. */
4023
+ metadata_only?: boolean;
4024
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4025
+ return_on_failure?: boolean;
4026
+ /** Boost results by metadata field values. Max 3 entries. */
4027
+ boost_by?: Array<{
4028
+ field: string;
4029
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4030
+ }>;
4031
+ [key: string]: unknown;
4032
+ };
4033
+ query_rewrite?: {
4034
+ enabled?: boolean;
4035
+ model?: string;
4036
+ rewrite_prompt?: string;
4037
+ [key: string]: unknown;
4038
+ };
4039
+ reranking?: {
4040
+ enabled?: boolean;
4041
+ model?: string;
4042
+ /** Match threshold (0-1, default 0.4) */
4043
+ match_threshold?: number;
3988
4044
  [key: string]: unknown;
3989
4045
  };
4046
+ cache?: {
4047
+ enabled?: boolean;
4048
+ cache_threshold?:
4049
+ | "super_strict_match"
4050
+ | "close_enough"
4051
+ | "flexible_friend"
4052
+ | "anything_goes";
4053
+ };
4054
+ [key: string]: unknown;
3990
4055
  };
4056
+ // ============ AI Search Request Types ============
4057
+ /**
4058
+ * Request body for single-instance search.
4059
+ * Exactly one of `query` or `messages` must be provided.
4060
+ */
4061
+ type AiSearchSearchRequest =
4062
+ | {
4063
+ /** Simple query string. */
4064
+ query: string;
4065
+ messages?: never;
4066
+ ai_search_options?: AiSearchOptions;
4067
+ }
4068
+ | {
4069
+ query?: never;
4070
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4071
+ messages: AiSearchMessage[];
4072
+ ai_search_options?: AiSearchOptions;
4073
+ };
3991
4074
  type AiSearchChatCompletionsRequest = {
3992
- messages: Array<{
3993
- role: "system" | "developer" | "user" | "assistant" | "tool";
3994
- content: string | null;
3995
- [key: string]: unknown;
3996
- }>;
4075
+ messages: AiSearchMessage[];
3997
4076
  model?: string;
3998
4077
  stream?: boolean;
3999
- ai_search_options?: {
4000
- retrieval?: {
4001
- retrieval_type?: "vector" | "keyword" | "hybrid";
4002
- match_threshold?: number;
4003
- max_num_results?: number;
4004
- filters?: VectorizeVectorMetadataFilter;
4005
- context_expansion?: number;
4006
- [key: string]: unknown;
4007
- };
4008
- query_rewrite?: {
4009
- enabled?: boolean;
4010
- model?: string;
4011
- rewrite_prompt?: string;
4012
- [key: string]: unknown;
4013
- };
4014
- reranking?: {
4015
- enabled?: boolean;
4016
- model?: "@cf/baai/bge-reranker-base" | string;
4017
- match_threshold?: number;
4018
- [key: string]: unknown;
4019
- };
4020
- [key: string]: unknown;
4021
- };
4078
+ ai_search_options?: AiSearchOptions;
4022
4079
  [key: string]: unknown;
4023
4080
  };
4081
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4082
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4083
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4084
+ /** Instance IDs to search across (1-10). */
4085
+ instance_ids: string[];
4086
+ };
4087
+ /**
4088
+ * Request for searching across multiple instances within a namespace.
4089
+ * `ai_search_options` is required and must include `instance_ids`.
4090
+ * Exactly one of `query` or `messages` must be provided.
4091
+ */
4092
+ type AiSearchMultiSearchRequest =
4093
+ | {
4094
+ /** Simple query string. */
4095
+ query: string;
4096
+ messages?: never;
4097
+ ai_search_options: AiSearchMultiSearchOptions;
4098
+ }
4099
+ | {
4100
+ query?: never;
4101
+ /** Conversation-style input. */
4102
+ messages: AiSearchMessage[];
4103
+ ai_search_options: AiSearchMultiSearchOptions;
4104
+ };
4105
+ /** A search result chunk tagged with the instance it originated from. */
4106
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4107
+ instance_id: string;
4108
+ };
4109
+ /** Describes a per-instance error during a multi-instance operation. */
4110
+ type AiSearchMultiSearchError = {
4111
+ instance_id: string;
4112
+ message: string;
4113
+ };
4114
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4115
+ type AiSearchMultiSearchResponse = {
4116
+ search_query: string;
4117
+ chunks: AiSearchMultiSearchChunk[];
4118
+ errors?: AiSearchMultiSearchError[];
4119
+ };
4120
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4121
+ type AiSearchMultiChatCompletionsRequest = Omit<
4122
+ AiSearchChatCompletionsRequest,
4123
+ "ai_search_options"
4124
+ > & {
4125
+ ai_search_options: AiSearchMultiSearchOptions;
4126
+ };
4127
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4128
+ type AiSearchMultiChatCompletionsResponse = Omit<
4129
+ AiSearchChatCompletionsResponse,
4130
+ "chunks"
4131
+ > & {
4132
+ chunks: AiSearchMultiSearchChunk[];
4133
+ errors?: AiSearchMultiSearchError[];
4134
+ };
4024
4135
  // ============ AI Search Response Types ============
4025
4136
  type AiSearchSearchResponse = {
4026
4137
  search_query: string;
@@ -4040,6 +4151,14 @@ type AiSearchSearchResponse = {
4040
4151
  keyword_score?: number;
4041
4152
  /** Vector similarity score (0-1) */
4042
4153
  vector_score?: number;
4154
+ /** Keyword rank position */
4155
+ keyword_rank?: number;
4156
+ /** Vector rank position */
4157
+ vector_rank?: number;
4158
+ /** Reranking model score */
4159
+ reranking_score?: number;
4160
+ /** Fusion method used to combine results */
4161
+ fusion_method?: "rrf" | "max";
4043
4162
  [key: string]: unknown;
4044
4163
  };
4045
4164
  }>;
@@ -4068,19 +4187,88 @@ type AiSearchStatsResponse = {
4068
4187
  skipped?: number;
4069
4188
  outdated?: number;
4070
4189
  last_activity?: string;
4190
+ /** Storage engine statistics. */
4191
+ engine?: {
4192
+ vectorize?: {
4193
+ vectorsCount: number;
4194
+ dimensions: number;
4195
+ };
4196
+ r2?: {
4197
+ payloadSizeBytes: number;
4198
+ metadataSizeBytes: number;
4199
+ objectCount: number;
4200
+ };
4201
+ };
4071
4202
  };
4072
4203
  // ============ AI Search Instance Info Types ============
4073
4204
  type AiSearchInstanceInfo = {
4074
4205
  id: string;
4075
4206
  type?: "r2" | "web-crawler" | string;
4076
4207
  source?: string;
4208
+ source_params?: unknown;
4077
4209
  paused?: boolean;
4078
4210
  status?: string;
4079
4211
  namespace?: string;
4080
4212
  created_at?: string;
4081
4213
  modified_at?: string;
4214
+ token_id?: string;
4215
+ ai_gateway_id?: string;
4216
+ rewrite_query?: boolean;
4217
+ reranking?: boolean;
4218
+ embedding_model?: string;
4219
+ ai_search_model?: string;
4220
+ rewrite_model?: string;
4221
+ reranking_model?: string;
4222
+ /** @deprecated Use index_method instead. */
4223
+ hybrid_search_enabled?: boolean;
4224
+ /** Controls which storage backends are active. */
4225
+ index_method?: {
4226
+ vector?: boolean;
4227
+ keyword?: boolean;
4228
+ };
4229
+ /** Fusion method for combining vector and keyword results. */
4230
+ fusion_method?: "max" | "rrf";
4231
+ indexing_options?: {
4232
+ keyword_tokenizer?: "porter" | "trigram";
4233
+ } | null;
4234
+ retrieval_options?: {
4235
+ keyword_match_mode?: "and" | "or";
4236
+ boost_by?: Array<{
4237
+ field: string;
4238
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4239
+ }>;
4240
+ } | null;
4241
+ chunk?: boolean;
4242
+ chunk_size?: number;
4243
+ chunk_overlap?: number;
4244
+ score_threshold?: number;
4245
+ max_num_results?: number;
4246
+ cache?: boolean;
4247
+ cache_threshold?:
4248
+ | "super_strict_match"
4249
+ | "close_enough"
4250
+ | "flexible_friend"
4251
+ | "anything_goes";
4252
+ custom_metadata?: Array<{
4253
+ field_name: string;
4254
+ data_type: "text" | "number" | "boolean" | "datetime";
4255
+ }>;
4256
+ /** Sync interval in seconds. */
4257
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4258
+ metadata?: Record<string, unknown>;
4082
4259
  [key: string]: unknown;
4083
4260
  };
4261
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4262
+ type AiSearchListInstancesParams = {
4263
+ page?: number;
4264
+ per_page?: number;
4265
+ /** Search instances by ID. */
4266
+ search?: string;
4267
+ /** Field to sort by. */
4268
+ order_by?: "created_at";
4269
+ /** Sort direction. */
4270
+ order_by_direction?: "asc" | "desc";
4271
+ };
4084
4272
  type AiSearchListResponse = {
4085
4273
  result: AiSearchInstanceInfo[];
4086
4274
  result_info?: {
@@ -4108,19 +4296,64 @@ type AiSearchConfig = {
4108
4296
  reranking?: boolean;
4109
4297
  embedding_model?: string;
4110
4298
  ai_search_model?: string;
4299
+ rewrite_model?: string;
4300
+ reranking_model?: string;
4301
+ /** @deprecated Use index_method instead. */
4302
+ hybrid_search_enabled?: boolean;
4303
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4304
+ index_method?: {
4305
+ vector?: boolean;
4306
+ keyword?: boolean;
4307
+ };
4308
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4309
+ fusion_method?: "max" | "rrf";
4310
+ indexing_options?: {
4311
+ keyword_tokenizer?: "porter" | "trigram";
4312
+ } | null;
4313
+ retrieval_options?: {
4314
+ keyword_match_mode?: "and" | "or";
4315
+ boost_by?: Array<{
4316
+ field: string;
4317
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4318
+ }>;
4319
+ } | null;
4320
+ chunk?: boolean;
4321
+ chunk_size?: number;
4322
+ chunk_overlap?: number;
4323
+ /** Minimum similarity score (0-1) for a result to be included. */
4324
+ score_threshold?: number;
4325
+ max_num_results?: number;
4326
+ cache?: boolean;
4327
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4328
+ cache_threshold?:
4329
+ | "super_strict_match"
4330
+ | "close_enough"
4331
+ | "flexible_friend"
4332
+ | "anything_goes";
4333
+ custom_metadata?: Array<{
4334
+ field_name: string;
4335
+ data_type: "text" | "number" | "boolean" | "datetime";
4336
+ }>;
4337
+ namespace?: string;
4338
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4339
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4340
+ metadata?: Record<string, unknown>;
4111
4341
  [key: string]: unknown;
4112
4342
  };
4113
4343
  // ============ AI Search Item Types ============
4114
4344
  type AiSearchItemInfo = {
4115
4345
  id: string;
4116
4346
  key: string;
4117
- status:
4118
- | "completed"
4119
- | "error"
4120
- | "skipped"
4121
- | "queued"
4122
- | "processing"
4123
- | "outdated";
4347
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4348
+ next_action?: "INDEX" | "DELETE" | null;
4349
+ error?: string;
4350
+ checksum?: string;
4351
+ namespace?: string;
4352
+ chunks_count?: number | null;
4353
+ file_size?: number | null;
4354
+ source_id?: string | null;
4355
+ last_seen_at?: string;
4356
+ created_at?: string;
4124
4357
  metadata?: Record<string, unknown>;
4125
4358
  [key: string]: unknown;
4126
4359
  };
@@ -4136,6 +4369,22 @@ type AiSearchUploadItemOptions = {
4136
4369
  type AiSearchListItemsParams = {
4137
4370
  page?: number;
4138
4371
  per_page?: number;
4372
+ /** Search items by key name. */
4373
+ search?: string;
4374
+ /** Sort order for results. */
4375
+ sort_by?: "status" | "modified_at";
4376
+ /** Filter items by processing status. */
4377
+ status?:
4378
+ | "queued"
4379
+ | "running"
4380
+ | "completed"
4381
+ | "error"
4382
+ | "skipped"
4383
+ | "outdated";
4384
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4385
+ source?: string;
4386
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4387
+ metadata_filter?: string;
4139
4388
  };
4140
4389
  type AiSearchListItemsResponse = {
4141
4390
  result: AiSearchItemInfo[];
@@ -4146,6 +4395,61 @@ type AiSearchListItemsResponse = {
4146
4395
  total_count: number;
4147
4396
  };
4148
4397
  };
4398
+ // ============ AI Search Item Logs Types ============
4399
+ type AiSearchItemLogsParams = {
4400
+ /** Maximum number of log entries to return (1-100, default 50). */
4401
+ limit?: number;
4402
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4403
+ cursor?: string;
4404
+ };
4405
+ type AiSearchItemLog = {
4406
+ timestamp: string;
4407
+ action: string;
4408
+ message: string;
4409
+ fileKey?: string;
4410
+ chunkCount?: number;
4411
+ processingTimeMs?: number;
4412
+ errorType?: string;
4413
+ };
4414
+ /** Paginated response for item processing logs (cursor-based). */
4415
+ type AiSearchItemLogsResponse = {
4416
+ result: AiSearchItemLog[];
4417
+ result_info: {
4418
+ count: number;
4419
+ per_page: number;
4420
+ cursor: string | null;
4421
+ truncated: boolean;
4422
+ };
4423
+ };
4424
+ // ============ AI Search Item Chunks Types ============
4425
+ type AiSearchItemChunksParams = {
4426
+ /** Maximum number of chunks to return (1-100, default 20). */
4427
+ limit?: number;
4428
+ /** Offset into the chunks list (default 0). */
4429
+ offset?: number;
4430
+ };
4431
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4432
+ type AiSearchItemChunk = {
4433
+ id: string;
4434
+ text: string;
4435
+ start_byte: number;
4436
+ end_byte: number;
4437
+ item?: {
4438
+ timestamp?: number;
4439
+ key: string;
4440
+ metadata?: Record<string, unknown>;
4441
+ };
4442
+ };
4443
+ /** Paginated response for item chunks (offset-based). */
4444
+ type AiSearchItemChunksResponse = {
4445
+ result: AiSearchItemChunk[];
4446
+ result_info: {
4447
+ count: number;
4448
+ total: number;
4449
+ limit: number;
4450
+ offset: number;
4451
+ };
4452
+ };
4149
4453
  // ============ AI Search Job Types ============
4150
4454
  type AiSearchJobInfo = {
4151
4455
  id: string;
@@ -4194,7 +4498,7 @@ type AiSearchJobLogsResponse = {
4194
4498
  // ============ AI Search Sub-Service Classes ============
4195
4499
  /**
4196
4500
  * Single item service for an AI Search instance.
4197
- * Provides info, delete, and download operations on a specific item.
4501
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4198
4502
  */
4199
4503
  declare abstract class AiSearchItem {
4200
4504
  /** Get metadata about this item. */
@@ -4204,6 +4508,25 @@ declare abstract class AiSearchItem {
4204
4508
  * @returns Object with body stream, content type, filename, and size.
4205
4509
  */
4206
4510
  download(): Promise<AiSearchItemContentResult>;
4511
+ /**
4512
+ * Trigger re-indexing of this item.
4513
+ * @returns The updated item info.
4514
+ */
4515
+ sync(): Promise<AiSearchItemInfo>;
4516
+ /**
4517
+ * Retrieve processing logs for this item (cursor-based pagination).
4518
+ * @param params Optional pagination parameters (limit, cursor).
4519
+ * @returns Paginated log entries for this item.
4520
+ */
4521
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4522
+ /**
4523
+ * List indexed chunks for this item (offset-based pagination).
4524
+ * @param params Optional pagination parameters (limit, offset).
4525
+ * @returns Paginated chunk entries for this item.
4526
+ */
4527
+ chunks(
4528
+ params?: AiSearchItemChunksParams,
4529
+ ): Promise<AiSearchItemChunksResponse>;
4207
4530
  }
4208
4531
  /**
4209
4532
  * Items collection service for an AI Search instance.
@@ -4213,49 +4536,64 @@ declare abstract class AiSearchItems {
4213
4536
  /** List items in this instance. */
4214
4537
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4215
4538
  /**
4216
- * Upload a file as an item.
4539
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4540
+ * filename already exists, it is overwritten and re-indexed.
4217
4541
  * @param name Filename for the uploaded item.
4218
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4542
+ * @param content File content as a ReadableStream, Blob, or string.
4219
4543
  * @param options Optional metadata to attach to the item.
4220
4544
  * @returns The created item info.
4221
4545
  */
4222
4546
  upload(
4223
4547
  name: string,
4224
- content: ReadableStream | ArrayBuffer | string,
4548
+ content: ReadableStream | Blob | string,
4225
4549
  options?: AiSearchUploadItemOptions,
4226
4550
  ): Promise<AiSearchItemInfo>;
4227
4551
  /**
4228
4552
  * Upload a file and poll until processing completes.
4553
+ * Behaves as an upsert: if an item with the same filename already exists,
4554
+ * it is overwritten and re-indexed.
4229
4555
  * @param name Filename for the uploaded item.
4230
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4231
- * @param options Optional metadata to attach to the item.
4556
+ * @param content File content as a ReadableStream, Blob, or string.
4557
+ * @param options Optional metadata and polling configuration.
4232
4558
  * @returns The item info after processing completes (or timeout).
4233
4559
  */
4234
4560
  uploadAndPoll(
4235
4561
  name: string,
4236
- content: ReadableStream | ArrayBuffer | string,
4237
- options?: AiSearchUploadItemOptions,
4562
+ content: ReadableStream | Blob | string,
4563
+ options?: AiSearchUploadItemOptions & {
4564
+ /** Polling interval in milliseconds (default 1000). */
4565
+ pollIntervalMs?: number;
4566
+ /** Maximum time to wait in milliseconds (default 30000). */
4567
+ timeoutMs?: number;
4568
+ },
4238
4569
  ): Promise<AiSearchItemInfo>;
4239
4570
  /**
4240
4571
  * Get an item by ID.
4241
4572
  * @param itemId The item identifier.
4242
- * @returns Item service for info, delete, and download operations.
4573
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4243
4574
  */
4244
4575
  get(itemId: string): AiSearchItem;
4245
- /** Delete this item from the instance.
4576
+ /**
4577
+ * Delete an item from the instance.
4246
4578
  * @param itemId The item identifier.
4247
4579
  */
4248
4580
  delete(itemId: string): Promise<void>;
4249
4581
  }
4250
4582
  /**
4251
4583
  * Single job service for an AI Search instance.
4252
- * Provides info and logs for a specific job.
4584
+ * Provides info, logs, and cancel operations for a specific job.
4253
4585
  */
4254
4586
  declare abstract class AiSearchJob {
4255
4587
  /** Get metadata about this job. */
4256
4588
  info(): Promise<AiSearchJobInfo>;
4257
4589
  /** Get logs for this job. */
4258
4590
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4591
+ /**
4592
+ * Cancel a running job.
4593
+ * @returns The updated job info.
4594
+ * @throws AiSearchNotFoundError if the job does not exist.
4595
+ */
4596
+ cancel(): Promise<AiSearchJobInfo>;
4259
4597
  }
4260
4598
  /**
4261
4599
  * Jobs collection service for an AI Search instance.
@@ -4273,7 +4611,7 @@ declare abstract class AiSearchJobs {
4273
4611
  /**
4274
4612
  * Get a job by ID.
4275
4613
  * @param jobId The job identifier.
4276
- * @returns Job service for info and logs operations.
4614
+ * @returns Job service for info, logs, and cancel operations.
4277
4615
  */
4278
4616
  get(jobId: string): AiSearchJob;
4279
4617
  }
@@ -4292,7 +4630,7 @@ declare abstract class AiSearchJobs {
4292
4630
  * // Via namespace binding
4293
4631
  * const instance = env.AI_SEARCH.get("blog");
4294
4632
  * const results = await instance.search({
4295
- * messages: [{ role: "user", content: "How does caching work?" }],
4633
+ * query: "How does caching work?",
4296
4634
  * });
4297
4635
  *
4298
4636
  * // Via single instance binding
@@ -4304,7 +4642,7 @@ declare abstract class AiSearchJobs {
4304
4642
  declare abstract class AiSearchInstance {
4305
4643
  /**
4306
4644
  * Search the AI Search instance for relevant chunks.
4307
- * @param params Search request with messages and optional AI search options.
4645
+ * @param params Search request with query or messages and optional AI search options.
4308
4646
  * @returns Search response with matching chunks and search query.
4309
4647
  */
4310
4648
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4336,7 +4674,7 @@ declare abstract class AiSearchInstance {
4336
4674
  info(): Promise<AiSearchInstanceInfo>;
4337
4675
  /**
4338
4676
  * Get instance statistics (item count, indexing status, etc.).
4339
- * @returns Statistics with counts per status and last activity time.
4677
+ * @returns Statistics with counts per status, last activity time, and engine details.
4340
4678
  */
4341
4679
  stats(): Promise<AiSearchStatsResponse>;
4342
4680
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4348,27 +4686,30 @@ declare abstract class AiSearchInstance {
4348
4686
  * Namespace-level AI Search service.
4349
4687
  *
4350
4688
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4351
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4689
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4690
+ * and multi-instance search/chat operations.
4352
4691
  *
4353
4692
  * @example
4354
4693
  * ```ts
4355
4694
  * // Access an instance within the namespace
4356
4695
  * const blog = env.AI_SEARCH.get("blog");
4357
- * const results = await blog.search({
4358
- * messages: [{ role: "user", content: "How does caching work?" }],
4359
- * });
4696
+ * const results = await blog.search({ query: "How does caching work?" });
4360
4697
  *
4361
4698
  * // List all instances in the namespace
4362
4699
  * const instances = await env.AI_SEARCH.list();
4363
4700
  *
4364
4701
  * // Create a new instance with built-in storage
4365
- * const tenant = await env.AI_SEARCH.create({
4366
- * id: "tenant-123",
4367
- * });
4702
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4368
4703
  *
4369
4704
  * // Upload items into the instance
4370
4705
  * await tenant.items.upload("doc.pdf", fileContent);
4371
4706
  *
4707
+ * // Search across multiple instances
4708
+ * const multi = await env.AI_SEARCH.search({
4709
+ * query: "caching",
4710
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4711
+ * });
4712
+ *
4372
4713
  * // Delete an instance
4373
4714
  * await env.AI_SEARCH.delete("tenant-123");
4374
4715
  * ```
@@ -4381,10 +4722,11 @@ declare abstract class AiSearchNamespace {
4381
4722
  */
4382
4723
  get(name: string): AiSearchInstance;
4383
4724
  /**
4384
- * List all instances in the bound namespace.
4385
- * @returns Array of instance metadata.
4725
+ * List instances in the bound namespace.
4726
+ * @param params Optional pagination, search, and ordering parameters.
4727
+ * @returns Array of instance metadata with pagination info.
4386
4728
  */
4387
- list(): Promise<AiSearchListResponse>;
4729
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4388
4730
  /**
4389
4731
  * Create a new instance within the bound namespace.
4390
4732
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4409,6 +4751,35 @@ declare abstract class AiSearchNamespace {
4409
4751
  * @param name Instance name to delete.
4410
4752
  */
4411
4753
  delete(name: string): Promise<void>;
4754
+ /**
4755
+ * Search across multiple instances within the bound namespace.
4756
+ * Fans out to the specified instance_ids and merges results.
4757
+ * @param params Search request with required `ai_search_options.instance_ids`.
4758
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4759
+ */
4760
+ search(
4761
+ params: AiSearchMultiSearchRequest,
4762
+ ): Promise<AiSearchMultiSearchResponse>;
4763
+ /**
4764
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4765
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4766
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4767
+ * @returns ReadableStream of server-sent events.
4768
+ */
4769
+ chatCompletions(
4770
+ params: AiSearchMultiChatCompletionsRequest & {
4771
+ stream: true;
4772
+ },
4773
+ ): Promise<ReadableStream>;
4774
+ /**
4775
+ * Generate chat completions across multiple instances within the bound namespace.
4776
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4777
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4778
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4779
+ */
4780
+ chatCompletions(
4781
+ params: AiSearchMultiChatCompletionsRequest,
4782
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4412
4783
  }
4413
4784
  type AiImageClassificationInput = {
4414
4785
  image: number[];
@@ -12060,8 +12431,8 @@ declare module "cloudflare:email" {
12060
12431
  * Evaluation context for targeting rules.
12061
12432
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12062
12433
  */
12063
- type EvaluationContext = Record<string, string | number | boolean>;
12064
- interface EvaluationDetails<T> {
12434
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12435
+ interface FlagshipEvaluationDetails<T> {
12065
12436
  flagKey: string;
12066
12437
  value: T;
12067
12438
  variant?: string | undefined;
@@ -12069,7 +12440,7 @@ interface EvaluationDetails<T> {
12069
12440
  errorCode?: string | undefined;
12070
12441
  errorMessage?: string | undefined;
12071
12442
  }
12072
- interface FlagEvaluationError extends Error {}
12443
+ interface FlagshipEvaluationError extends Error {}
12073
12444
  /**
12074
12445
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12075
12446
  *
@@ -12089,7 +12460,7 @@ interface FlagEvaluationError extends Error {}
12089
12460
  * console.log(details.variant, details.reason);
12090
12461
  * ```
12091
12462
  */
12092
- declare abstract class Flags {
12463
+ declare abstract class Flagship {
12093
12464
  /**
12094
12465
  * Get a flag value without type checking.
12095
12466
  * @param flagKey The key of the flag to evaluate.
@@ -12099,7 +12470,7 @@ declare abstract class Flags {
12099
12470
  get(
12100
12471
  flagKey: string,
12101
12472
  defaultValue?: unknown,
12102
- context?: EvaluationContext,
12473
+ context?: FlagshipEvaluationContext,
12103
12474
  ): Promise<unknown>;
12104
12475
  /**
12105
12476
  * Get a boolean flag value.
@@ -12110,7 +12481,7 @@ declare abstract class Flags {
12110
12481
  getBooleanValue(
12111
12482
  flagKey: string,
12112
12483
  defaultValue: boolean,
12113
- context?: EvaluationContext,
12484
+ context?: FlagshipEvaluationContext,
12114
12485
  ): Promise<boolean>;
12115
12486
  /**
12116
12487
  * Get a string flag value.
@@ -12121,7 +12492,7 @@ declare abstract class Flags {
12121
12492
  getStringValue(
12122
12493
  flagKey: string,
12123
12494
  defaultValue: string,
12124
- context?: EvaluationContext,
12495
+ context?: FlagshipEvaluationContext,
12125
12496
  ): Promise<string>;
12126
12497
  /**
12127
12498
  * Get a number flag value.
@@ -12132,7 +12503,7 @@ declare abstract class Flags {
12132
12503
  getNumberValue(
12133
12504
  flagKey: string,
12134
12505
  defaultValue: number,
12135
- context?: EvaluationContext,
12506
+ context?: FlagshipEvaluationContext,
12136
12507
  ): Promise<number>;
12137
12508
  /**
12138
12509
  * Get an object flag value.
@@ -12143,7 +12514,7 @@ declare abstract class Flags {
12143
12514
  getObjectValue<T extends object>(
12144
12515
  flagKey: string,
12145
12516
  defaultValue: T,
12146
- context?: EvaluationContext,
12517
+ context?: FlagshipEvaluationContext,
12147
12518
  ): Promise<T>;
12148
12519
  /**
12149
12520
  * Get a boolean flag value with full evaluation details.
@@ -12154,8 +12525,8 @@ declare abstract class Flags {
12154
12525
  getBooleanDetails(
12155
12526
  flagKey: string,
12156
12527
  defaultValue: boolean,
12157
- context?: EvaluationContext,
12158
- ): Promise<EvaluationDetails<boolean>>;
12528
+ context?: FlagshipEvaluationContext,
12529
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12159
12530
  /**
12160
12531
  * Get a string flag value with full evaluation details.
12161
12532
  * @param flagKey The key of the flag to evaluate.
@@ -12165,8 +12536,8 @@ declare abstract class Flags {
12165
12536
  getStringDetails(
12166
12537
  flagKey: string,
12167
12538
  defaultValue: string,
12168
- context?: EvaluationContext,
12169
- ): Promise<EvaluationDetails<string>>;
12539
+ context?: FlagshipEvaluationContext,
12540
+ ): Promise<FlagshipEvaluationDetails<string>>;
12170
12541
  /**
12171
12542
  * Get a number flag value with full evaluation details.
12172
12543
  * @param flagKey The key of the flag to evaluate.
@@ -12176,8 +12547,8 @@ declare abstract class Flags {
12176
12547
  getNumberDetails(
12177
12548
  flagKey: string,
12178
12549
  defaultValue: number,
12179
- context?: EvaluationContext,
12180
- ): Promise<EvaluationDetails<number>>;
12550
+ context?: FlagshipEvaluationContext,
12551
+ ): Promise<FlagshipEvaluationDetails<number>>;
12181
12552
  /**
12182
12553
  * Get an object flag value with full evaluation details.
12183
12554
  * @param flagKey The key of the flag to evaluate.
@@ -12187,8 +12558,8 @@ declare abstract class Flags {
12187
12558
  getObjectDetails<T extends object>(
12188
12559
  flagKey: string,
12189
12560
  defaultValue: T,
12190
- context?: EvaluationContext,
12191
- ): Promise<EvaluationDetails<T>>;
12561
+ context?: FlagshipEvaluationContext,
12562
+ ): Promise<FlagshipEvaluationDetails<T>>;
12192
12563
  }
12193
12564
  /**
12194
12565
  * Hello World binding to serve as an explanatory example. DO NOT USE