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