@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.
@@ -549,6 +549,7 @@ declare abstract class Navigator {
549
549
  sendBeacon(url: string, body?: BodyInit): boolean;
550
550
  readonly userAgent: string;
551
551
  readonly hardwareConcurrency: number;
552
+ readonly platform: string;
552
553
  }
553
554
  interface AlarmInvocationInfo {
554
555
  readonly isRetry: boolean;
@@ -2324,11 +2325,34 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2324
2325
  }
2325
2326
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2326
2327
  interface Queue<Body = unknown> {
2327
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2328
+ metrics(): Promise<QueueMetrics>;
2329
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2328
2330
  sendBatch(
2329
2331
  messages: Iterable<MessageSendRequest<Body>>,
2330
2332
  options?: QueueSendBatchOptions,
2331
- ): Promise<void>;
2333
+ ): Promise<QueueSendBatchResponse>;
2334
+ }
2335
+ interface QueueSendMetrics {
2336
+ backlogCount: number;
2337
+ backlogBytes: number;
2338
+ oldestMessageTimestamp?: Date;
2339
+ }
2340
+ interface QueueSendMetadata {
2341
+ metrics: QueueSendMetrics;
2342
+ }
2343
+ interface QueueSendResponse {
2344
+ metadata: QueueSendMetadata;
2345
+ }
2346
+ interface QueueSendBatchMetrics {
2347
+ backlogCount: number;
2348
+ backlogBytes: number;
2349
+ oldestMessageTimestamp?: Date;
2350
+ }
2351
+ interface QueueSendBatchMetadata {
2352
+ metrics: QueueSendBatchMetrics;
2353
+ }
2354
+ interface QueueSendBatchResponse {
2355
+ metadata: QueueSendBatchMetadata;
2332
2356
  }
2333
2357
  interface QueueSendOptions {
2334
2358
  contentType?: QueueContentType;
@@ -2342,6 +2366,19 @@ interface MessageSendRequest<Body = unknown> {
2342
2366
  contentType?: QueueContentType;
2343
2367
  delaySeconds?: number;
2344
2368
  }
2369
+ interface QueueMetrics {
2370
+ backlogCount: number;
2371
+ backlogBytes: number;
2372
+ oldestMessageTimestamp?: Date;
2373
+ }
2374
+ interface MessageBatchMetrics {
2375
+ backlogCount: number;
2376
+ backlogBytes: number;
2377
+ oldestMessageTimestamp?: Date;
2378
+ }
2379
+ interface MessageBatchMetadata {
2380
+ metrics: MessageBatchMetrics;
2381
+ }
2345
2382
  interface QueueRetryOptions {
2346
2383
  delaySeconds?: number;
2347
2384
  }
@@ -2356,12 +2393,14 @@ interface Message<Body = unknown> {
2356
2393
  interface QueueEvent<Body = unknown> extends ExtendableEvent {
2357
2394
  readonly messages: readonly Message<Body>[];
2358
2395
  readonly queue: string;
2396
+ readonly metadata: MessageBatchMetadata;
2359
2397
  retryAll(options?: QueueRetryOptions): void;
2360
2398
  ackAll(): void;
2361
2399
  }
2362
2400
  interface MessageBatch<Body = unknown> {
2363
2401
  readonly messages: readonly Message<Body>[];
2364
2402
  readonly queue: string;
2403
+ readonly metadata: MessageBatchMetadata;
2365
2404
  retryAll(options?: QueueRetryOptions): void;
2366
2405
  ackAll(): void;
2367
2406
  }
@@ -3979,73 +4018,145 @@ declare abstract class Performance {
3979
4018
  // ============ AI Search Error Interfaces ============
3980
4019
  interface AiSearchInternalError extends Error {}
3981
4020
  interface AiSearchNotFoundError extends Error {}
3982
- // ============ AI Search Request Types ============
3983
- type AiSearchSearchRequest = {
3984
- messages: Array<{
3985
- role: "system" | "developer" | "user" | "assistant" | "tool";
3986
- content: string | null;
3987
- }>;
3988
- ai_search_options?: {
3989
- retrieval?: {
3990
- retrieval_type?: "vector" | "keyword" | "hybrid";
3991
- /** Match threshold (0-1, default 0.4) */
3992
- match_threshold?: number;
3993
- /** Maximum number of results (1-50, default 10) */
3994
- max_num_results?: number;
3995
- filters?: VectorizeVectorMetadataFilter;
3996
- /** Context expansion (0-3, default 0) */
3997
- context_expansion?: number;
3998
- [key: string]: unknown;
3999
- };
4000
- query_rewrite?: {
4001
- enabled?: boolean;
4002
- model?: string;
4003
- rewrite_prompt?: string;
4004
- [key: string]: unknown;
4005
- };
4006
- reranking?: {
4007
- enabled?: boolean;
4008
- model?: "@cf/baai/bge-reranker-base" | string;
4009
- /** Match threshold (0-1, default 0.4) */
4010
- match_threshold?: number;
4011
- [key: string]: unknown;
4012
- };
4021
+ // ============ AI Search Common Types ============
4022
+ /** A single message in a conversation-style search or chat request. */
4023
+ type AiSearchMessage = {
4024
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4025
+ content: string | null;
4026
+ };
4027
+ /**
4028
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4029
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4030
+ */
4031
+ type AiSearchOptions = {
4032
+ retrieval?: {
4033
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4034
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4035
+ /** Fusion method for combining vector + keyword results. */
4036
+ fusion_method?: "max" | "rrf";
4037
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4038
+ keyword_match_mode?: "and" | "or";
4039
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4040
+ match_threshold?: number;
4041
+ /** Maximum number of results to return (1-50). Default 10. */
4042
+ max_num_results?: number;
4043
+ /** Vectorize metadata filters applied to the search. */
4044
+ filters?: VectorizeVectorMetadataFilter;
4045
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4046
+ context_expansion?: number;
4047
+ /** If true, return only item metadata without chunk text. */
4048
+ metadata_only?: boolean;
4049
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4050
+ return_on_failure?: boolean;
4051
+ /** Boost results by metadata field values. Max 3 entries. */
4052
+ boost_by?: Array<{
4053
+ field: string;
4054
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4055
+ }>;
4056
+ [key: string]: unknown;
4057
+ };
4058
+ query_rewrite?: {
4059
+ enabled?: boolean;
4060
+ model?: string;
4061
+ rewrite_prompt?: string;
4062
+ [key: string]: unknown;
4063
+ };
4064
+ reranking?: {
4065
+ enabled?: boolean;
4066
+ model?: string;
4067
+ /** Match threshold (0-1, default 0.4) */
4068
+ match_threshold?: number;
4013
4069
  [key: string]: unknown;
4014
4070
  };
4071
+ cache?: {
4072
+ enabled?: boolean;
4073
+ cache_threshold?:
4074
+ | "super_strict_match"
4075
+ | "close_enough"
4076
+ | "flexible_friend"
4077
+ | "anything_goes";
4078
+ };
4079
+ [key: string]: unknown;
4015
4080
  };
4081
+ // ============ AI Search Request Types ============
4082
+ /**
4083
+ * Request body for single-instance search.
4084
+ * Exactly one of `query` or `messages` must be provided.
4085
+ */
4086
+ type AiSearchSearchRequest =
4087
+ | {
4088
+ /** Simple query string. */
4089
+ query: string;
4090
+ messages?: never;
4091
+ ai_search_options?: AiSearchOptions;
4092
+ }
4093
+ | {
4094
+ query?: never;
4095
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4096
+ messages: AiSearchMessage[];
4097
+ ai_search_options?: AiSearchOptions;
4098
+ };
4016
4099
  type AiSearchChatCompletionsRequest = {
4017
- messages: Array<{
4018
- role: "system" | "developer" | "user" | "assistant" | "tool";
4019
- content: string | null;
4020
- [key: string]: unknown;
4021
- }>;
4100
+ messages: AiSearchMessage[];
4022
4101
  model?: string;
4023
4102
  stream?: boolean;
4024
- ai_search_options?: {
4025
- retrieval?: {
4026
- retrieval_type?: "vector" | "keyword" | "hybrid";
4027
- match_threshold?: number;
4028
- max_num_results?: number;
4029
- filters?: VectorizeVectorMetadataFilter;
4030
- context_expansion?: number;
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?: "@cf/baai/bge-reranker-base" | string;
4042
- match_threshold?: number;
4043
- [key: string]: unknown;
4044
- };
4045
- [key: string]: unknown;
4046
- };
4103
+ ai_search_options?: AiSearchOptions;
4047
4104
  [key: string]: unknown;
4048
4105
  };
4106
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4107
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4108
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4109
+ /** Instance IDs to search across (1-10). */
4110
+ instance_ids: string[];
4111
+ };
4112
+ /**
4113
+ * Request for searching across multiple instances within a namespace.
4114
+ * `ai_search_options` is required and must include `instance_ids`.
4115
+ * Exactly one of `query` or `messages` must be provided.
4116
+ */
4117
+ type AiSearchMultiSearchRequest =
4118
+ | {
4119
+ /** Simple query string. */
4120
+ query: string;
4121
+ messages?: never;
4122
+ ai_search_options: AiSearchMultiSearchOptions;
4123
+ }
4124
+ | {
4125
+ query?: never;
4126
+ /** Conversation-style input. */
4127
+ messages: AiSearchMessage[];
4128
+ ai_search_options: AiSearchMultiSearchOptions;
4129
+ };
4130
+ /** A search result chunk tagged with the instance it originated from. */
4131
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4132
+ instance_id: string;
4133
+ };
4134
+ /** Describes a per-instance error during a multi-instance operation. */
4135
+ type AiSearchMultiSearchError = {
4136
+ instance_id: string;
4137
+ message: string;
4138
+ };
4139
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4140
+ type AiSearchMultiSearchResponse = {
4141
+ search_query: string;
4142
+ chunks: AiSearchMultiSearchChunk[];
4143
+ errors?: AiSearchMultiSearchError[];
4144
+ };
4145
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4146
+ type AiSearchMultiChatCompletionsRequest = Omit<
4147
+ AiSearchChatCompletionsRequest,
4148
+ "ai_search_options"
4149
+ > & {
4150
+ ai_search_options: AiSearchMultiSearchOptions;
4151
+ };
4152
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4153
+ type AiSearchMultiChatCompletionsResponse = Omit<
4154
+ AiSearchChatCompletionsResponse,
4155
+ "chunks"
4156
+ > & {
4157
+ chunks: AiSearchMultiSearchChunk[];
4158
+ errors?: AiSearchMultiSearchError[];
4159
+ };
4049
4160
  // ============ AI Search Response Types ============
4050
4161
  type AiSearchSearchResponse = {
4051
4162
  search_query: string;
@@ -4065,6 +4176,14 @@ type AiSearchSearchResponse = {
4065
4176
  keyword_score?: number;
4066
4177
  /** Vector similarity score (0-1) */
4067
4178
  vector_score?: number;
4179
+ /** Keyword rank position */
4180
+ keyword_rank?: number;
4181
+ /** Vector rank position */
4182
+ vector_rank?: number;
4183
+ /** Reranking model score */
4184
+ reranking_score?: number;
4185
+ /** Fusion method used to combine results */
4186
+ fusion_method?: "rrf" | "max";
4068
4187
  [key: string]: unknown;
4069
4188
  };
4070
4189
  }>;
@@ -4093,19 +4212,88 @@ type AiSearchStatsResponse = {
4093
4212
  skipped?: number;
4094
4213
  outdated?: number;
4095
4214
  last_activity?: string;
4215
+ /** Storage engine statistics. */
4216
+ engine?: {
4217
+ vectorize?: {
4218
+ vectorsCount: number;
4219
+ dimensions: number;
4220
+ };
4221
+ r2?: {
4222
+ payloadSizeBytes: number;
4223
+ metadataSizeBytes: number;
4224
+ objectCount: number;
4225
+ };
4226
+ };
4096
4227
  };
4097
4228
  // ============ AI Search Instance Info Types ============
4098
4229
  type AiSearchInstanceInfo = {
4099
4230
  id: string;
4100
4231
  type?: "r2" | "web-crawler" | string;
4101
4232
  source?: string;
4233
+ source_params?: unknown;
4102
4234
  paused?: boolean;
4103
4235
  status?: string;
4104
4236
  namespace?: string;
4105
4237
  created_at?: string;
4106
4238
  modified_at?: string;
4239
+ token_id?: string;
4240
+ ai_gateway_id?: string;
4241
+ rewrite_query?: boolean;
4242
+ reranking?: boolean;
4243
+ embedding_model?: string;
4244
+ ai_search_model?: string;
4245
+ rewrite_model?: string;
4246
+ reranking_model?: string;
4247
+ /** @deprecated Use index_method instead. */
4248
+ hybrid_search_enabled?: boolean;
4249
+ /** Controls which storage backends are active. */
4250
+ index_method?: {
4251
+ vector?: boolean;
4252
+ keyword?: boolean;
4253
+ };
4254
+ /** Fusion method for combining vector and keyword results. */
4255
+ fusion_method?: "max" | "rrf";
4256
+ indexing_options?: {
4257
+ keyword_tokenizer?: "porter" | "trigram";
4258
+ } | null;
4259
+ retrieval_options?: {
4260
+ keyword_match_mode?: "and" | "or";
4261
+ boost_by?: Array<{
4262
+ field: string;
4263
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4264
+ }>;
4265
+ } | null;
4266
+ chunk?: boolean;
4267
+ chunk_size?: number;
4268
+ chunk_overlap?: number;
4269
+ score_threshold?: number;
4270
+ max_num_results?: number;
4271
+ cache?: boolean;
4272
+ cache_threshold?:
4273
+ | "super_strict_match"
4274
+ | "close_enough"
4275
+ | "flexible_friend"
4276
+ | "anything_goes";
4277
+ custom_metadata?: Array<{
4278
+ field_name: string;
4279
+ data_type: "text" | "number" | "boolean" | "datetime";
4280
+ }>;
4281
+ /** Sync interval in seconds. */
4282
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4283
+ metadata?: Record<string, unknown>;
4107
4284
  [key: string]: unknown;
4108
4285
  };
4286
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4287
+ type AiSearchListInstancesParams = {
4288
+ page?: number;
4289
+ per_page?: number;
4290
+ /** Search instances by ID. */
4291
+ search?: string;
4292
+ /** Field to sort by. */
4293
+ order_by?: "created_at";
4294
+ /** Sort direction. */
4295
+ order_by_direction?: "asc" | "desc";
4296
+ };
4109
4297
  type AiSearchListResponse = {
4110
4298
  result: AiSearchInstanceInfo[];
4111
4299
  result_info?: {
@@ -4133,19 +4321,64 @@ type AiSearchConfig = {
4133
4321
  reranking?: boolean;
4134
4322
  embedding_model?: string;
4135
4323
  ai_search_model?: string;
4324
+ rewrite_model?: string;
4325
+ reranking_model?: string;
4326
+ /** @deprecated Use index_method instead. */
4327
+ hybrid_search_enabled?: boolean;
4328
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4329
+ index_method?: {
4330
+ vector?: boolean;
4331
+ keyword?: boolean;
4332
+ };
4333
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4334
+ fusion_method?: "max" | "rrf";
4335
+ indexing_options?: {
4336
+ keyword_tokenizer?: "porter" | "trigram";
4337
+ } | null;
4338
+ retrieval_options?: {
4339
+ keyword_match_mode?: "and" | "or";
4340
+ boost_by?: Array<{
4341
+ field: string;
4342
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4343
+ }>;
4344
+ } | null;
4345
+ chunk?: boolean;
4346
+ chunk_size?: number;
4347
+ chunk_overlap?: number;
4348
+ /** Minimum similarity score (0-1) for a result to be included. */
4349
+ score_threshold?: number;
4350
+ max_num_results?: number;
4351
+ cache?: boolean;
4352
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4353
+ cache_threshold?:
4354
+ | "super_strict_match"
4355
+ | "close_enough"
4356
+ | "flexible_friend"
4357
+ | "anything_goes";
4358
+ custom_metadata?: Array<{
4359
+ field_name: string;
4360
+ data_type: "text" | "number" | "boolean" | "datetime";
4361
+ }>;
4362
+ namespace?: string;
4363
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4364
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4365
+ metadata?: Record<string, unknown>;
4136
4366
  [key: string]: unknown;
4137
4367
  };
4138
4368
  // ============ AI Search Item Types ============
4139
4369
  type AiSearchItemInfo = {
4140
4370
  id: string;
4141
4371
  key: string;
4142
- status:
4143
- | "completed"
4144
- | "error"
4145
- | "skipped"
4146
- | "queued"
4147
- | "processing"
4148
- | "outdated";
4372
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4373
+ next_action?: "INDEX" | "DELETE" | null;
4374
+ error?: string;
4375
+ checksum?: string;
4376
+ namespace?: string;
4377
+ chunks_count?: number | null;
4378
+ file_size?: number | null;
4379
+ source_id?: string | null;
4380
+ last_seen_at?: string;
4381
+ created_at?: string;
4149
4382
  metadata?: Record<string, unknown>;
4150
4383
  [key: string]: unknown;
4151
4384
  };
@@ -4161,6 +4394,22 @@ type AiSearchUploadItemOptions = {
4161
4394
  type AiSearchListItemsParams = {
4162
4395
  page?: number;
4163
4396
  per_page?: number;
4397
+ /** Search items by key name. */
4398
+ search?: string;
4399
+ /** Sort order for results. */
4400
+ sort_by?: "status" | "modified_at";
4401
+ /** Filter items by processing status. */
4402
+ status?:
4403
+ | "queued"
4404
+ | "running"
4405
+ | "completed"
4406
+ | "error"
4407
+ | "skipped"
4408
+ | "outdated";
4409
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4410
+ source?: string;
4411
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4412
+ metadata_filter?: string;
4164
4413
  };
4165
4414
  type AiSearchListItemsResponse = {
4166
4415
  result: AiSearchItemInfo[];
@@ -4171,6 +4420,61 @@ type AiSearchListItemsResponse = {
4171
4420
  total_count: number;
4172
4421
  };
4173
4422
  };
4423
+ // ============ AI Search Item Logs Types ============
4424
+ type AiSearchItemLogsParams = {
4425
+ /** Maximum number of log entries to return (1-100, default 50). */
4426
+ limit?: number;
4427
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4428
+ cursor?: string;
4429
+ };
4430
+ type AiSearchItemLog = {
4431
+ timestamp: string;
4432
+ action: string;
4433
+ message: string;
4434
+ fileKey?: string;
4435
+ chunkCount?: number;
4436
+ processingTimeMs?: number;
4437
+ errorType?: string;
4438
+ };
4439
+ /** Paginated response for item processing logs (cursor-based). */
4440
+ type AiSearchItemLogsResponse = {
4441
+ result: AiSearchItemLog[];
4442
+ result_info: {
4443
+ count: number;
4444
+ per_page: number;
4445
+ cursor: string | null;
4446
+ truncated: boolean;
4447
+ };
4448
+ };
4449
+ // ============ AI Search Item Chunks Types ============
4450
+ type AiSearchItemChunksParams = {
4451
+ /** Maximum number of chunks to return (1-100, default 20). */
4452
+ limit?: number;
4453
+ /** Offset into the chunks list (default 0). */
4454
+ offset?: number;
4455
+ };
4456
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4457
+ type AiSearchItemChunk = {
4458
+ id: string;
4459
+ text: string;
4460
+ start_byte: number;
4461
+ end_byte: number;
4462
+ item?: {
4463
+ timestamp?: number;
4464
+ key: string;
4465
+ metadata?: Record<string, unknown>;
4466
+ };
4467
+ };
4468
+ /** Paginated response for item chunks (offset-based). */
4469
+ type AiSearchItemChunksResponse = {
4470
+ result: AiSearchItemChunk[];
4471
+ result_info: {
4472
+ count: number;
4473
+ total: number;
4474
+ limit: number;
4475
+ offset: number;
4476
+ };
4477
+ };
4174
4478
  // ============ AI Search Job Types ============
4175
4479
  type AiSearchJobInfo = {
4176
4480
  id: string;
@@ -4219,7 +4523,7 @@ type AiSearchJobLogsResponse = {
4219
4523
  // ============ AI Search Sub-Service Classes ============
4220
4524
  /**
4221
4525
  * Single item service for an AI Search instance.
4222
- * Provides info, delete, and download operations on a specific item.
4526
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4223
4527
  */
4224
4528
  declare abstract class AiSearchItem {
4225
4529
  /** Get metadata about this item. */
@@ -4229,6 +4533,25 @@ declare abstract class AiSearchItem {
4229
4533
  * @returns Object with body stream, content type, filename, and size.
4230
4534
  */
4231
4535
  download(): Promise<AiSearchItemContentResult>;
4536
+ /**
4537
+ * Trigger re-indexing of this item.
4538
+ * @returns The updated item info.
4539
+ */
4540
+ sync(): Promise<AiSearchItemInfo>;
4541
+ /**
4542
+ * Retrieve processing logs for this item (cursor-based pagination).
4543
+ * @param params Optional pagination parameters (limit, cursor).
4544
+ * @returns Paginated log entries for this item.
4545
+ */
4546
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4547
+ /**
4548
+ * List indexed chunks for this item (offset-based pagination).
4549
+ * @param params Optional pagination parameters (limit, offset).
4550
+ * @returns Paginated chunk entries for this item.
4551
+ */
4552
+ chunks(
4553
+ params?: AiSearchItemChunksParams,
4554
+ ): Promise<AiSearchItemChunksResponse>;
4232
4555
  }
4233
4556
  /**
4234
4557
  * Items collection service for an AI Search instance.
@@ -4238,49 +4561,64 @@ declare abstract class AiSearchItems {
4238
4561
  /** List items in this instance. */
4239
4562
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4240
4563
  /**
4241
- * Upload a file as an item.
4564
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4565
+ * filename already exists, it is overwritten and re-indexed.
4242
4566
  * @param name Filename for the uploaded item.
4243
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4567
+ * @param content File content as a ReadableStream, Blob, or string.
4244
4568
  * @param options Optional metadata to attach to the item.
4245
4569
  * @returns The created item info.
4246
4570
  */
4247
4571
  upload(
4248
4572
  name: string,
4249
- content: ReadableStream | ArrayBuffer | string,
4573
+ content: ReadableStream | Blob | string,
4250
4574
  options?: AiSearchUploadItemOptions,
4251
4575
  ): Promise<AiSearchItemInfo>;
4252
4576
  /**
4253
4577
  * Upload a file and poll until processing completes.
4578
+ * Behaves as an upsert: if an item with the same filename already exists,
4579
+ * it is overwritten and re-indexed.
4254
4580
  * @param name Filename for the uploaded item.
4255
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4256
- * @param options Optional metadata to attach to the item.
4581
+ * @param content File content as a ReadableStream, Blob, or string.
4582
+ * @param options Optional metadata and polling configuration.
4257
4583
  * @returns The item info after processing completes (or timeout).
4258
4584
  */
4259
4585
  uploadAndPoll(
4260
4586
  name: string,
4261
- content: ReadableStream | ArrayBuffer | string,
4262
- options?: AiSearchUploadItemOptions,
4587
+ content: ReadableStream | Blob | string,
4588
+ options?: AiSearchUploadItemOptions & {
4589
+ /** Polling interval in milliseconds (default 1000). */
4590
+ pollIntervalMs?: number;
4591
+ /** Maximum time to wait in milliseconds (default 30000). */
4592
+ timeoutMs?: number;
4593
+ },
4263
4594
  ): Promise<AiSearchItemInfo>;
4264
4595
  /**
4265
4596
  * Get an item by ID.
4266
4597
  * @param itemId The item identifier.
4267
- * @returns Item service for info, delete, and download operations.
4598
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4268
4599
  */
4269
4600
  get(itemId: string): AiSearchItem;
4270
- /** Delete this item from the instance.
4601
+ /**
4602
+ * Delete an item from the instance.
4271
4603
  * @param itemId The item identifier.
4272
4604
  */
4273
4605
  delete(itemId: string): Promise<void>;
4274
4606
  }
4275
4607
  /**
4276
4608
  * Single job service for an AI Search instance.
4277
- * Provides info and logs for a specific job.
4609
+ * Provides info, logs, and cancel operations for a specific job.
4278
4610
  */
4279
4611
  declare abstract class AiSearchJob {
4280
4612
  /** Get metadata about this job. */
4281
4613
  info(): Promise<AiSearchJobInfo>;
4282
4614
  /** Get logs for this job. */
4283
4615
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4616
+ /**
4617
+ * Cancel a running job.
4618
+ * @returns The updated job info.
4619
+ * @throws AiSearchNotFoundError if the job does not exist.
4620
+ */
4621
+ cancel(): Promise<AiSearchJobInfo>;
4284
4622
  }
4285
4623
  /**
4286
4624
  * Jobs collection service for an AI Search instance.
@@ -4298,7 +4636,7 @@ declare abstract class AiSearchJobs {
4298
4636
  /**
4299
4637
  * Get a job by ID.
4300
4638
  * @param jobId The job identifier.
4301
- * @returns Job service for info and logs operations.
4639
+ * @returns Job service for info, logs, and cancel operations.
4302
4640
  */
4303
4641
  get(jobId: string): AiSearchJob;
4304
4642
  }
@@ -4317,7 +4655,7 @@ declare abstract class AiSearchJobs {
4317
4655
  * // Via namespace binding
4318
4656
  * const instance = env.AI_SEARCH.get("blog");
4319
4657
  * const results = await instance.search({
4320
- * messages: [{ role: "user", content: "How does caching work?" }],
4658
+ * query: "How does caching work?",
4321
4659
  * });
4322
4660
  *
4323
4661
  * // Via single instance binding
@@ -4329,7 +4667,7 @@ declare abstract class AiSearchJobs {
4329
4667
  declare abstract class AiSearchInstance {
4330
4668
  /**
4331
4669
  * Search the AI Search instance for relevant chunks.
4332
- * @param params Search request with messages and optional AI search options.
4670
+ * @param params Search request with query or messages and optional AI search options.
4333
4671
  * @returns Search response with matching chunks and search query.
4334
4672
  */
4335
4673
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4361,7 +4699,7 @@ declare abstract class AiSearchInstance {
4361
4699
  info(): Promise<AiSearchInstanceInfo>;
4362
4700
  /**
4363
4701
  * Get instance statistics (item count, indexing status, etc.).
4364
- * @returns Statistics with counts per status and last activity time.
4702
+ * @returns Statistics with counts per status, last activity time, and engine details.
4365
4703
  */
4366
4704
  stats(): Promise<AiSearchStatsResponse>;
4367
4705
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4373,27 +4711,30 @@ declare abstract class AiSearchInstance {
4373
4711
  * Namespace-level AI Search service.
4374
4712
  *
4375
4713
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4376
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4714
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4715
+ * and multi-instance search/chat operations.
4377
4716
  *
4378
4717
  * @example
4379
4718
  * ```ts
4380
4719
  * // Access an instance within the namespace
4381
4720
  * const blog = env.AI_SEARCH.get("blog");
4382
- * const results = await blog.search({
4383
- * messages: [{ role: "user", content: "How does caching work?" }],
4384
- * });
4721
+ * const results = await blog.search({ query: "How does caching work?" });
4385
4722
  *
4386
4723
  * // List all instances in the namespace
4387
4724
  * const instances = await env.AI_SEARCH.list();
4388
4725
  *
4389
4726
  * // Create a new instance with built-in storage
4390
- * const tenant = await env.AI_SEARCH.create({
4391
- * id: "tenant-123",
4392
- * });
4727
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4393
4728
  *
4394
4729
  * // Upload items into the instance
4395
4730
  * await tenant.items.upload("doc.pdf", fileContent);
4396
4731
  *
4732
+ * // Search across multiple instances
4733
+ * const multi = await env.AI_SEARCH.search({
4734
+ * query: "caching",
4735
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4736
+ * });
4737
+ *
4397
4738
  * // Delete an instance
4398
4739
  * await env.AI_SEARCH.delete("tenant-123");
4399
4740
  * ```
@@ -4406,10 +4747,11 @@ declare abstract class AiSearchNamespace {
4406
4747
  */
4407
4748
  get(name: string): AiSearchInstance;
4408
4749
  /**
4409
- * List all instances in the bound namespace.
4410
- * @returns Array of instance metadata.
4750
+ * List instances in the bound namespace.
4751
+ * @param params Optional pagination, search, and ordering parameters.
4752
+ * @returns Array of instance metadata with pagination info.
4411
4753
  */
4412
- list(): Promise<AiSearchListResponse>;
4754
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4413
4755
  /**
4414
4756
  * Create a new instance within the bound namespace.
4415
4757
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4434,6 +4776,35 @@ declare abstract class AiSearchNamespace {
4434
4776
  * @param name Instance name to delete.
4435
4777
  */
4436
4778
  delete(name: string): Promise<void>;
4779
+ /**
4780
+ * Search across multiple instances within the bound namespace.
4781
+ * Fans out to the specified instance_ids and merges results.
4782
+ * @param params Search request with required `ai_search_options.instance_ids`.
4783
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4784
+ */
4785
+ search(
4786
+ params: AiSearchMultiSearchRequest,
4787
+ ): Promise<AiSearchMultiSearchResponse>;
4788
+ /**
4789
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4790
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4791
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4792
+ * @returns ReadableStream of server-sent events.
4793
+ */
4794
+ chatCompletions(
4795
+ params: AiSearchMultiChatCompletionsRequest & {
4796
+ stream: true;
4797
+ },
4798
+ ): Promise<ReadableStream>;
4799
+ /**
4800
+ * Generate chat completions across multiple instances within the bound namespace.
4801
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4802
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4803
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4804
+ */
4805
+ chatCompletions(
4806
+ params: AiSearchMultiChatCompletionsRequest,
4807
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4437
4808
  }
4438
4809
  type AiImageClassificationInput = {
4439
4810
  image: number[];
@@ -12085,8 +12456,8 @@ declare module "cloudflare:email" {
12085
12456
  * Evaluation context for targeting rules.
12086
12457
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12087
12458
  */
12088
- type EvaluationContext = Record<string, string | number | boolean>;
12089
- interface EvaluationDetails<T> {
12459
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12460
+ interface FlagshipEvaluationDetails<T> {
12090
12461
  flagKey: string;
12091
12462
  value: T;
12092
12463
  variant?: string | undefined;
@@ -12094,7 +12465,7 @@ interface EvaluationDetails<T> {
12094
12465
  errorCode?: string | undefined;
12095
12466
  errorMessage?: string | undefined;
12096
12467
  }
12097
- interface FlagEvaluationError extends Error {}
12468
+ interface FlagshipEvaluationError extends Error {}
12098
12469
  /**
12099
12470
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12100
12471
  *
@@ -12114,7 +12485,7 @@ interface FlagEvaluationError extends Error {}
12114
12485
  * console.log(details.variant, details.reason);
12115
12486
  * ```
12116
12487
  */
12117
- declare abstract class Flags {
12488
+ declare abstract class Flagship {
12118
12489
  /**
12119
12490
  * Get a flag value without type checking.
12120
12491
  * @param flagKey The key of the flag to evaluate.
@@ -12124,7 +12495,7 @@ declare abstract class Flags {
12124
12495
  get(
12125
12496
  flagKey: string,
12126
12497
  defaultValue?: unknown,
12127
- context?: EvaluationContext,
12498
+ context?: FlagshipEvaluationContext,
12128
12499
  ): Promise<unknown>;
12129
12500
  /**
12130
12501
  * Get a boolean flag value.
@@ -12135,7 +12506,7 @@ declare abstract class Flags {
12135
12506
  getBooleanValue(
12136
12507
  flagKey: string,
12137
12508
  defaultValue: boolean,
12138
- context?: EvaluationContext,
12509
+ context?: FlagshipEvaluationContext,
12139
12510
  ): Promise<boolean>;
12140
12511
  /**
12141
12512
  * Get a string flag value.
@@ -12146,7 +12517,7 @@ declare abstract class Flags {
12146
12517
  getStringValue(
12147
12518
  flagKey: string,
12148
12519
  defaultValue: string,
12149
- context?: EvaluationContext,
12520
+ context?: FlagshipEvaluationContext,
12150
12521
  ): Promise<string>;
12151
12522
  /**
12152
12523
  * Get a number flag value.
@@ -12157,7 +12528,7 @@ declare abstract class Flags {
12157
12528
  getNumberValue(
12158
12529
  flagKey: string,
12159
12530
  defaultValue: number,
12160
- context?: EvaluationContext,
12531
+ context?: FlagshipEvaluationContext,
12161
12532
  ): Promise<number>;
12162
12533
  /**
12163
12534
  * Get an object flag value.
@@ -12168,7 +12539,7 @@ declare abstract class Flags {
12168
12539
  getObjectValue<T extends object>(
12169
12540
  flagKey: string,
12170
12541
  defaultValue: T,
12171
- context?: EvaluationContext,
12542
+ context?: FlagshipEvaluationContext,
12172
12543
  ): Promise<T>;
12173
12544
  /**
12174
12545
  * Get a boolean flag value with full evaluation details.
@@ -12179,8 +12550,8 @@ declare abstract class Flags {
12179
12550
  getBooleanDetails(
12180
12551
  flagKey: string,
12181
12552
  defaultValue: boolean,
12182
- context?: EvaluationContext,
12183
- ): Promise<EvaluationDetails<boolean>>;
12553
+ context?: FlagshipEvaluationContext,
12554
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12184
12555
  /**
12185
12556
  * Get a string flag value with full evaluation details.
12186
12557
  * @param flagKey The key of the flag to evaluate.
@@ -12190,8 +12561,8 @@ declare abstract class Flags {
12190
12561
  getStringDetails(
12191
12562
  flagKey: string,
12192
12563
  defaultValue: string,
12193
- context?: EvaluationContext,
12194
- ): Promise<EvaluationDetails<string>>;
12564
+ context?: FlagshipEvaluationContext,
12565
+ ): Promise<FlagshipEvaluationDetails<string>>;
12195
12566
  /**
12196
12567
  * Get a number flag value with full evaluation details.
12197
12568
  * @param flagKey The key of the flag to evaluate.
@@ -12201,8 +12572,8 @@ declare abstract class Flags {
12201
12572
  getNumberDetails(
12202
12573
  flagKey: string,
12203
12574
  defaultValue: number,
12204
- context?: EvaluationContext,
12205
- ): Promise<EvaluationDetails<number>>;
12575
+ context?: FlagshipEvaluationContext,
12576
+ ): Promise<FlagshipEvaluationDetails<number>>;
12206
12577
  /**
12207
12578
  * Get an object flag value with full evaluation details.
12208
12579
  * @param flagKey The key of the flag to evaluate.
@@ -12212,8 +12583,8 @@ declare abstract class Flags {
12212
12583
  getObjectDetails<T extends object>(
12213
12584
  flagKey: string,
12214
12585
  defaultValue: T,
12215
- context?: EvaluationContext,
12216
- ): Promise<EvaluationDetails<T>>;
12586
+ context?: FlagshipEvaluationContext,
12587
+ ): Promise<FlagshipEvaluationDetails<T>>;
12217
12588
  }
12218
12589
  /**
12219
12590
  * Hello World binding to serve as an explanatory example. DO NOT USE