@cloudflare/workers-types 4.20260415.1 → 4.20260416.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/latest/index.d.ts CHANGED
@@ -552,6 +552,7 @@ declare abstract class Navigator {
552
552
  sendBeacon(url: string, body?: BodyInit): boolean;
553
553
  readonly userAgent: string;
554
554
  readonly hardwareConcurrency: number;
555
+ readonly platform: string;
555
556
  readonly language: string;
556
557
  readonly languages: string[];
557
558
  }
@@ -2342,11 +2343,34 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2342
2343
  }
2343
2344
  type QueueContentType = "text" | "bytes" | "json" | "v8";
2344
2345
  interface Queue<Body = unknown> {
2345
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2346
+ metrics(): Promise<QueueMetrics>;
2347
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2346
2348
  sendBatch(
2347
2349
  messages: Iterable<MessageSendRequest<Body>>,
2348
2350
  options?: QueueSendBatchOptions,
2349
- ): Promise<void>;
2351
+ ): Promise<QueueSendBatchResponse>;
2352
+ }
2353
+ interface QueueSendMetrics {
2354
+ backlogCount: number;
2355
+ backlogBytes: number;
2356
+ oldestMessageTimestamp?: Date;
2357
+ }
2358
+ interface QueueSendMetadata {
2359
+ metrics: QueueSendMetrics;
2360
+ }
2361
+ interface QueueSendResponse {
2362
+ metadata: QueueSendMetadata;
2363
+ }
2364
+ interface QueueSendBatchMetrics {
2365
+ backlogCount: number;
2366
+ backlogBytes: number;
2367
+ oldestMessageTimestamp?: Date;
2368
+ }
2369
+ interface QueueSendBatchMetadata {
2370
+ metrics: QueueSendBatchMetrics;
2371
+ }
2372
+ interface QueueSendBatchResponse {
2373
+ metadata: QueueSendBatchMetadata;
2350
2374
  }
2351
2375
  interface QueueSendOptions {
2352
2376
  contentType?: QueueContentType;
@@ -2360,6 +2384,19 @@ interface MessageSendRequest<Body = unknown> {
2360
2384
  contentType?: QueueContentType;
2361
2385
  delaySeconds?: number;
2362
2386
  }
2387
+ interface QueueMetrics {
2388
+ backlogCount: number;
2389
+ backlogBytes: number;
2390
+ oldestMessageTimestamp?: Date;
2391
+ }
2392
+ interface MessageBatchMetrics {
2393
+ backlogCount: number;
2394
+ backlogBytes: number;
2395
+ oldestMessageTimestamp?: Date;
2396
+ }
2397
+ interface MessageBatchMetadata {
2398
+ metrics: MessageBatchMetrics;
2399
+ }
2363
2400
  interface QueueRetryOptions {
2364
2401
  delaySeconds?: number;
2365
2402
  }
@@ -2374,12 +2411,14 @@ interface Message<Body = unknown> {
2374
2411
  interface QueueEvent<Body = unknown> extends ExtendableEvent {
2375
2412
  readonly messages: readonly Message<Body>[];
2376
2413
  readonly queue: string;
2414
+ readonly metadata: MessageBatchMetadata;
2377
2415
  retryAll(options?: QueueRetryOptions): void;
2378
2416
  ackAll(): void;
2379
2417
  }
2380
2418
  interface MessageBatch<Body = unknown> {
2381
2419
  readonly messages: readonly Message<Body>[];
2382
2420
  readonly queue: string;
2421
+ readonly metadata: MessageBatchMetadata;
2383
2422
  retryAll(options?: QueueRetryOptions): void;
2384
2423
  ackAll(): void;
2385
2424
  }
@@ -4018,73 +4057,145 @@ declare abstract class Performance {
4018
4057
  // ============ AI Search Error Interfaces ============
4019
4058
  interface AiSearchInternalError extends Error {}
4020
4059
  interface AiSearchNotFoundError extends Error {}
4021
- // ============ AI Search Request Types ============
4022
- type AiSearchSearchRequest = {
4023
- messages: Array<{
4024
- role: "system" | "developer" | "user" | "assistant" | "tool";
4025
- content: string | null;
4026
- }>;
4027
- ai_search_options?: {
4028
- retrieval?: {
4029
- retrieval_type?: "vector" | "keyword" | "hybrid";
4030
- /** Match threshold (0-1, default 0.4) */
4031
- match_threshold?: number;
4032
- /** Maximum number of results (1-50, default 10) */
4033
- max_num_results?: number;
4034
- filters?: VectorizeVectorMetadataFilter;
4035
- /** Context expansion (0-3, default 0) */
4036
- context_expansion?: number;
4037
- [key: string]: unknown;
4038
- };
4039
- query_rewrite?: {
4040
- enabled?: boolean;
4041
- model?: string;
4042
- rewrite_prompt?: string;
4043
- [key: string]: unknown;
4044
- };
4045
- reranking?: {
4046
- enabled?: boolean;
4047
- model?: "@cf/baai/bge-reranker-base" | string;
4048
- /** Match threshold (0-1, default 0.4) */
4049
- match_threshold?: number;
4050
- [key: string]: unknown;
4051
- };
4060
+ // ============ AI Search Common Types ============
4061
+ /** A single message in a conversation-style search or chat request. */
4062
+ type AiSearchMessage = {
4063
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4064
+ content: string | null;
4065
+ };
4066
+ /**
4067
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4068
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4069
+ */
4070
+ type AiSearchOptions = {
4071
+ retrieval?: {
4072
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4073
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4074
+ /** Fusion method for combining vector + keyword results. */
4075
+ fusion_method?: "max" | "rrf";
4076
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4077
+ keyword_match_mode?: "and" | "or";
4078
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4079
+ match_threshold?: number;
4080
+ /** Maximum number of results to return (1-50). Default 10. */
4081
+ max_num_results?: number;
4082
+ /** Vectorize metadata filters applied to the search. */
4083
+ filters?: VectorizeVectorMetadataFilter;
4084
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4085
+ context_expansion?: number;
4086
+ /** If true, return only item metadata without chunk text. */
4087
+ metadata_only?: boolean;
4088
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4089
+ return_on_failure?: boolean;
4090
+ /** Boost results by metadata field values. Max 3 entries. */
4091
+ boost_by?: Array<{
4092
+ field: string;
4093
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4094
+ }>;
4095
+ [key: string]: unknown;
4096
+ };
4097
+ query_rewrite?: {
4098
+ enabled?: boolean;
4099
+ model?: string;
4100
+ rewrite_prompt?: string;
4101
+ [key: string]: unknown;
4102
+ };
4103
+ reranking?: {
4104
+ enabled?: boolean;
4105
+ model?: string;
4106
+ /** Match threshold (0-1, default 0.4) */
4107
+ match_threshold?: number;
4052
4108
  [key: string]: unknown;
4053
4109
  };
4110
+ cache?: {
4111
+ enabled?: boolean;
4112
+ cache_threshold?:
4113
+ | "super_strict_match"
4114
+ | "close_enough"
4115
+ | "flexible_friend"
4116
+ | "anything_goes";
4117
+ };
4118
+ [key: string]: unknown;
4054
4119
  };
4120
+ // ============ AI Search Request Types ============
4121
+ /**
4122
+ * Request body for single-instance search.
4123
+ * Exactly one of `query` or `messages` must be provided.
4124
+ */
4125
+ type AiSearchSearchRequest =
4126
+ | {
4127
+ /** Simple query string. */
4128
+ query: string;
4129
+ messages?: never;
4130
+ ai_search_options?: AiSearchOptions;
4131
+ }
4132
+ | {
4133
+ query?: never;
4134
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4135
+ messages: AiSearchMessage[];
4136
+ ai_search_options?: AiSearchOptions;
4137
+ };
4055
4138
  type AiSearchChatCompletionsRequest = {
4056
- messages: Array<{
4057
- role: "system" | "developer" | "user" | "assistant" | "tool";
4058
- content: string | null;
4059
- [key: string]: unknown;
4060
- }>;
4139
+ messages: AiSearchMessage[];
4061
4140
  model?: string;
4062
4141
  stream?: boolean;
4063
- ai_search_options?: {
4064
- retrieval?: {
4065
- retrieval_type?: "vector" | "keyword" | "hybrid";
4066
- match_threshold?: number;
4067
- max_num_results?: number;
4068
- filters?: VectorizeVectorMetadataFilter;
4069
- context_expansion?: number;
4070
- [key: string]: unknown;
4071
- };
4072
- query_rewrite?: {
4073
- enabled?: boolean;
4074
- model?: string;
4075
- rewrite_prompt?: string;
4076
- [key: string]: unknown;
4077
- };
4078
- reranking?: {
4079
- enabled?: boolean;
4080
- model?: "@cf/baai/bge-reranker-base" | string;
4081
- match_threshold?: number;
4082
- [key: string]: unknown;
4083
- };
4084
- [key: string]: unknown;
4085
- };
4142
+ ai_search_options?: AiSearchOptions;
4086
4143
  [key: string]: unknown;
4087
4144
  };
4145
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4146
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4147
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4148
+ /** Instance IDs to search across (1-10). */
4149
+ instance_ids: string[];
4150
+ };
4151
+ /**
4152
+ * Request for searching across multiple instances within a namespace.
4153
+ * `ai_search_options` is required and must include `instance_ids`.
4154
+ * Exactly one of `query` or `messages` must be provided.
4155
+ */
4156
+ type AiSearchMultiSearchRequest =
4157
+ | {
4158
+ /** Simple query string. */
4159
+ query: string;
4160
+ messages?: never;
4161
+ ai_search_options: AiSearchMultiSearchOptions;
4162
+ }
4163
+ | {
4164
+ query?: never;
4165
+ /** Conversation-style input. */
4166
+ messages: AiSearchMessage[];
4167
+ ai_search_options: AiSearchMultiSearchOptions;
4168
+ };
4169
+ /** A search result chunk tagged with the instance it originated from. */
4170
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4171
+ instance_id: string;
4172
+ };
4173
+ /** Describes a per-instance error during a multi-instance operation. */
4174
+ type AiSearchMultiSearchError = {
4175
+ instance_id: string;
4176
+ message: string;
4177
+ };
4178
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4179
+ type AiSearchMultiSearchResponse = {
4180
+ search_query: string;
4181
+ chunks: AiSearchMultiSearchChunk[];
4182
+ errors?: AiSearchMultiSearchError[];
4183
+ };
4184
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4185
+ type AiSearchMultiChatCompletionsRequest = Omit<
4186
+ AiSearchChatCompletionsRequest,
4187
+ "ai_search_options"
4188
+ > & {
4189
+ ai_search_options: AiSearchMultiSearchOptions;
4190
+ };
4191
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4192
+ type AiSearchMultiChatCompletionsResponse = Omit<
4193
+ AiSearchChatCompletionsResponse,
4194
+ "chunks"
4195
+ > & {
4196
+ chunks: AiSearchMultiSearchChunk[];
4197
+ errors?: AiSearchMultiSearchError[];
4198
+ };
4088
4199
  // ============ AI Search Response Types ============
4089
4200
  type AiSearchSearchResponse = {
4090
4201
  search_query: string;
@@ -4104,6 +4215,14 @@ type AiSearchSearchResponse = {
4104
4215
  keyword_score?: number;
4105
4216
  /** Vector similarity score (0-1) */
4106
4217
  vector_score?: number;
4218
+ /** Keyword rank position */
4219
+ keyword_rank?: number;
4220
+ /** Vector rank position */
4221
+ vector_rank?: number;
4222
+ /** Reranking model score */
4223
+ reranking_score?: number;
4224
+ /** Fusion method used to combine results */
4225
+ fusion_method?: "rrf" | "max";
4107
4226
  [key: string]: unknown;
4108
4227
  };
4109
4228
  }>;
@@ -4132,19 +4251,88 @@ type AiSearchStatsResponse = {
4132
4251
  skipped?: number;
4133
4252
  outdated?: number;
4134
4253
  last_activity?: string;
4254
+ /** Storage engine statistics. */
4255
+ engine?: {
4256
+ vectorize?: {
4257
+ vectorsCount: number;
4258
+ dimensions: number;
4259
+ };
4260
+ r2?: {
4261
+ payloadSizeBytes: number;
4262
+ metadataSizeBytes: number;
4263
+ objectCount: number;
4264
+ };
4265
+ };
4135
4266
  };
4136
4267
  // ============ AI Search Instance Info Types ============
4137
4268
  type AiSearchInstanceInfo = {
4138
4269
  id: string;
4139
4270
  type?: "r2" | "web-crawler" | string;
4140
4271
  source?: string;
4272
+ source_params?: unknown;
4141
4273
  paused?: boolean;
4142
4274
  status?: string;
4143
4275
  namespace?: string;
4144
4276
  created_at?: string;
4145
4277
  modified_at?: string;
4278
+ token_id?: string;
4279
+ ai_gateway_id?: string;
4280
+ rewrite_query?: boolean;
4281
+ reranking?: boolean;
4282
+ embedding_model?: string;
4283
+ ai_search_model?: string;
4284
+ rewrite_model?: string;
4285
+ reranking_model?: string;
4286
+ /** @deprecated Use index_method instead. */
4287
+ hybrid_search_enabled?: boolean;
4288
+ /** Controls which storage backends are active. */
4289
+ index_method?: {
4290
+ vector?: boolean;
4291
+ keyword?: boolean;
4292
+ };
4293
+ /** Fusion method for combining vector and keyword results. */
4294
+ fusion_method?: "max" | "rrf";
4295
+ indexing_options?: {
4296
+ keyword_tokenizer?: "porter" | "trigram";
4297
+ } | null;
4298
+ retrieval_options?: {
4299
+ keyword_match_mode?: "and" | "or";
4300
+ boost_by?: Array<{
4301
+ field: string;
4302
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4303
+ }>;
4304
+ } | null;
4305
+ chunk?: boolean;
4306
+ chunk_size?: number;
4307
+ chunk_overlap?: number;
4308
+ score_threshold?: number;
4309
+ max_num_results?: number;
4310
+ cache?: boolean;
4311
+ cache_threshold?:
4312
+ | "super_strict_match"
4313
+ | "close_enough"
4314
+ | "flexible_friend"
4315
+ | "anything_goes";
4316
+ custom_metadata?: Array<{
4317
+ field_name: string;
4318
+ data_type: "text" | "number" | "boolean" | "datetime";
4319
+ }>;
4320
+ /** Sync interval in seconds. */
4321
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4322
+ metadata?: Record<string, unknown>;
4146
4323
  [key: string]: unknown;
4147
4324
  };
4325
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4326
+ type AiSearchListInstancesParams = {
4327
+ page?: number;
4328
+ per_page?: number;
4329
+ /** Search instances by ID. */
4330
+ search?: string;
4331
+ /** Field to sort by. */
4332
+ order_by?: "created_at";
4333
+ /** Sort direction. */
4334
+ order_by_direction?: "asc" | "desc";
4335
+ };
4148
4336
  type AiSearchListResponse = {
4149
4337
  result: AiSearchInstanceInfo[];
4150
4338
  result_info?: {
@@ -4172,19 +4360,64 @@ type AiSearchConfig = {
4172
4360
  reranking?: boolean;
4173
4361
  embedding_model?: string;
4174
4362
  ai_search_model?: string;
4363
+ rewrite_model?: string;
4364
+ reranking_model?: string;
4365
+ /** @deprecated Use index_method instead. */
4366
+ hybrid_search_enabled?: boolean;
4367
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4368
+ index_method?: {
4369
+ vector?: boolean;
4370
+ keyword?: boolean;
4371
+ };
4372
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4373
+ fusion_method?: "max" | "rrf";
4374
+ indexing_options?: {
4375
+ keyword_tokenizer?: "porter" | "trigram";
4376
+ } | null;
4377
+ retrieval_options?: {
4378
+ keyword_match_mode?: "and" | "or";
4379
+ boost_by?: Array<{
4380
+ field: string;
4381
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4382
+ }>;
4383
+ } | null;
4384
+ chunk?: boolean;
4385
+ chunk_size?: number;
4386
+ chunk_overlap?: number;
4387
+ /** Minimum similarity score (0-1) for a result to be included. */
4388
+ score_threshold?: number;
4389
+ max_num_results?: number;
4390
+ cache?: boolean;
4391
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4392
+ cache_threshold?:
4393
+ | "super_strict_match"
4394
+ | "close_enough"
4395
+ | "flexible_friend"
4396
+ | "anything_goes";
4397
+ custom_metadata?: Array<{
4398
+ field_name: string;
4399
+ data_type: "text" | "number" | "boolean" | "datetime";
4400
+ }>;
4401
+ namespace?: string;
4402
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4403
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4404
+ metadata?: Record<string, unknown>;
4175
4405
  [key: string]: unknown;
4176
4406
  };
4177
4407
  // ============ AI Search Item Types ============
4178
4408
  type AiSearchItemInfo = {
4179
4409
  id: string;
4180
4410
  key: string;
4181
- status:
4182
- | "completed"
4183
- | "error"
4184
- | "skipped"
4185
- | "queued"
4186
- | "processing"
4187
- | "outdated";
4411
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4412
+ next_action?: "INDEX" | "DELETE" | null;
4413
+ error?: string;
4414
+ checksum?: string;
4415
+ namespace?: string;
4416
+ chunks_count?: number | null;
4417
+ file_size?: number | null;
4418
+ source_id?: string | null;
4419
+ last_seen_at?: string;
4420
+ created_at?: string;
4188
4421
  metadata?: Record<string, unknown>;
4189
4422
  [key: string]: unknown;
4190
4423
  };
@@ -4200,6 +4433,22 @@ type AiSearchUploadItemOptions = {
4200
4433
  type AiSearchListItemsParams = {
4201
4434
  page?: number;
4202
4435
  per_page?: number;
4436
+ /** Search items by key name. */
4437
+ search?: string;
4438
+ /** Sort order for results. */
4439
+ sort_by?: "status" | "modified_at";
4440
+ /** Filter items by processing status. */
4441
+ status?:
4442
+ | "queued"
4443
+ | "running"
4444
+ | "completed"
4445
+ | "error"
4446
+ | "skipped"
4447
+ | "outdated";
4448
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4449
+ source?: string;
4450
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4451
+ metadata_filter?: string;
4203
4452
  };
4204
4453
  type AiSearchListItemsResponse = {
4205
4454
  result: AiSearchItemInfo[];
@@ -4210,6 +4459,61 @@ type AiSearchListItemsResponse = {
4210
4459
  total_count: number;
4211
4460
  };
4212
4461
  };
4462
+ // ============ AI Search Item Logs Types ============
4463
+ type AiSearchItemLogsParams = {
4464
+ /** Maximum number of log entries to return (1-100, default 50). */
4465
+ limit?: number;
4466
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4467
+ cursor?: string;
4468
+ };
4469
+ type AiSearchItemLog = {
4470
+ timestamp: string;
4471
+ action: string;
4472
+ message: string;
4473
+ fileKey?: string;
4474
+ chunkCount?: number;
4475
+ processingTimeMs?: number;
4476
+ errorType?: string;
4477
+ };
4478
+ /** Paginated response for item processing logs (cursor-based). */
4479
+ type AiSearchItemLogsResponse = {
4480
+ result: AiSearchItemLog[];
4481
+ result_info: {
4482
+ count: number;
4483
+ per_page: number;
4484
+ cursor: string | null;
4485
+ truncated: boolean;
4486
+ };
4487
+ };
4488
+ // ============ AI Search Item Chunks Types ============
4489
+ type AiSearchItemChunksParams = {
4490
+ /** Maximum number of chunks to return (1-100, default 20). */
4491
+ limit?: number;
4492
+ /** Offset into the chunks list (default 0). */
4493
+ offset?: number;
4494
+ };
4495
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4496
+ type AiSearchItemChunk = {
4497
+ id: string;
4498
+ text: string;
4499
+ start_byte: number;
4500
+ end_byte: number;
4501
+ item?: {
4502
+ timestamp?: number;
4503
+ key: string;
4504
+ metadata?: Record<string, unknown>;
4505
+ };
4506
+ };
4507
+ /** Paginated response for item chunks (offset-based). */
4508
+ type AiSearchItemChunksResponse = {
4509
+ result: AiSearchItemChunk[];
4510
+ result_info: {
4511
+ count: number;
4512
+ total: number;
4513
+ limit: number;
4514
+ offset: number;
4515
+ };
4516
+ };
4213
4517
  // ============ AI Search Job Types ============
4214
4518
  type AiSearchJobInfo = {
4215
4519
  id: string;
@@ -4258,7 +4562,7 @@ type AiSearchJobLogsResponse = {
4258
4562
  // ============ AI Search Sub-Service Classes ============
4259
4563
  /**
4260
4564
  * Single item service for an AI Search instance.
4261
- * Provides info, delete, and download operations on a specific item.
4565
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4262
4566
  */
4263
4567
  declare abstract class AiSearchItem {
4264
4568
  /** Get metadata about this item. */
@@ -4268,6 +4572,25 @@ declare abstract class AiSearchItem {
4268
4572
  * @returns Object with body stream, content type, filename, and size.
4269
4573
  */
4270
4574
  download(): Promise<AiSearchItemContentResult>;
4575
+ /**
4576
+ * Trigger re-indexing of this item.
4577
+ * @returns The updated item info.
4578
+ */
4579
+ sync(): Promise<AiSearchItemInfo>;
4580
+ /**
4581
+ * Retrieve processing logs for this item (cursor-based pagination).
4582
+ * @param params Optional pagination parameters (limit, cursor).
4583
+ * @returns Paginated log entries for this item.
4584
+ */
4585
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4586
+ /**
4587
+ * List indexed chunks for this item (offset-based pagination).
4588
+ * @param params Optional pagination parameters (limit, offset).
4589
+ * @returns Paginated chunk entries for this item.
4590
+ */
4591
+ chunks(
4592
+ params?: AiSearchItemChunksParams,
4593
+ ): Promise<AiSearchItemChunksResponse>;
4271
4594
  }
4272
4595
  /**
4273
4596
  * Items collection service for an AI Search instance.
@@ -4277,49 +4600,64 @@ declare abstract class AiSearchItems {
4277
4600
  /** List items in this instance. */
4278
4601
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4279
4602
  /**
4280
- * Upload a file as an item.
4603
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4604
+ * filename already exists, it is overwritten and re-indexed.
4281
4605
  * @param name Filename for the uploaded item.
4282
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4606
+ * @param content File content as a ReadableStream, Blob, or string.
4283
4607
  * @param options Optional metadata to attach to the item.
4284
4608
  * @returns The created item info.
4285
4609
  */
4286
4610
  upload(
4287
4611
  name: string,
4288
- content: ReadableStream | ArrayBuffer | string,
4612
+ content: ReadableStream | Blob | string,
4289
4613
  options?: AiSearchUploadItemOptions,
4290
4614
  ): Promise<AiSearchItemInfo>;
4291
4615
  /**
4292
4616
  * Upload a file and poll until processing completes.
4617
+ * Behaves as an upsert: if an item with the same filename already exists,
4618
+ * it is overwritten and re-indexed.
4293
4619
  * @param name Filename for the uploaded item.
4294
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4295
- * @param options Optional metadata to attach to the item.
4620
+ * @param content File content as a ReadableStream, Blob, or string.
4621
+ * @param options Optional metadata and polling configuration.
4296
4622
  * @returns The item info after processing completes (or timeout).
4297
4623
  */
4298
4624
  uploadAndPoll(
4299
4625
  name: string,
4300
- content: ReadableStream | ArrayBuffer | string,
4301
- options?: AiSearchUploadItemOptions,
4626
+ content: ReadableStream | Blob | string,
4627
+ options?: AiSearchUploadItemOptions & {
4628
+ /** Polling interval in milliseconds (default 1000). */
4629
+ pollIntervalMs?: number;
4630
+ /** Maximum time to wait in milliseconds (default 30000). */
4631
+ timeoutMs?: number;
4632
+ },
4302
4633
  ): Promise<AiSearchItemInfo>;
4303
4634
  /**
4304
4635
  * Get an item by ID.
4305
4636
  * @param itemId The item identifier.
4306
- * @returns Item service for info, delete, and download operations.
4637
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4307
4638
  */
4308
4639
  get(itemId: string): AiSearchItem;
4309
- /** Delete this item from the instance.
4640
+ /**
4641
+ * Delete an item from the instance.
4310
4642
  * @param itemId The item identifier.
4311
4643
  */
4312
4644
  delete(itemId: string): Promise<void>;
4313
4645
  }
4314
4646
  /**
4315
4647
  * Single job service for an AI Search instance.
4316
- * Provides info and logs for a specific job.
4648
+ * Provides info, logs, and cancel operations for a specific job.
4317
4649
  */
4318
4650
  declare abstract class AiSearchJob {
4319
4651
  /** Get metadata about this job. */
4320
4652
  info(): Promise<AiSearchJobInfo>;
4321
4653
  /** Get logs for this job. */
4322
4654
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4655
+ /**
4656
+ * Cancel a running job.
4657
+ * @returns The updated job info.
4658
+ * @throws AiSearchNotFoundError if the job does not exist.
4659
+ */
4660
+ cancel(): Promise<AiSearchJobInfo>;
4323
4661
  }
4324
4662
  /**
4325
4663
  * Jobs collection service for an AI Search instance.
@@ -4337,7 +4675,7 @@ declare abstract class AiSearchJobs {
4337
4675
  /**
4338
4676
  * Get a job by ID.
4339
4677
  * @param jobId The job identifier.
4340
- * @returns Job service for info and logs operations.
4678
+ * @returns Job service for info, logs, and cancel operations.
4341
4679
  */
4342
4680
  get(jobId: string): AiSearchJob;
4343
4681
  }
@@ -4356,7 +4694,7 @@ declare abstract class AiSearchJobs {
4356
4694
  * // Via namespace binding
4357
4695
  * const instance = env.AI_SEARCH.get("blog");
4358
4696
  * const results = await instance.search({
4359
- * messages: [{ role: "user", content: "How does caching work?" }],
4697
+ * query: "How does caching work?",
4360
4698
  * });
4361
4699
  *
4362
4700
  * // Via single instance binding
@@ -4368,7 +4706,7 @@ declare abstract class AiSearchJobs {
4368
4706
  declare abstract class AiSearchInstance {
4369
4707
  /**
4370
4708
  * Search the AI Search instance for relevant chunks.
4371
- * @param params Search request with messages and optional AI search options.
4709
+ * @param params Search request with query or messages and optional AI search options.
4372
4710
  * @returns Search response with matching chunks and search query.
4373
4711
  */
4374
4712
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4400,7 +4738,7 @@ declare abstract class AiSearchInstance {
4400
4738
  info(): Promise<AiSearchInstanceInfo>;
4401
4739
  /**
4402
4740
  * Get instance statistics (item count, indexing status, etc.).
4403
- * @returns Statistics with counts per status and last activity time.
4741
+ * @returns Statistics with counts per status, last activity time, and engine details.
4404
4742
  */
4405
4743
  stats(): Promise<AiSearchStatsResponse>;
4406
4744
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4412,27 +4750,30 @@ declare abstract class AiSearchInstance {
4412
4750
  * Namespace-level AI Search service.
4413
4751
  *
4414
4752
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4415
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4753
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4754
+ * and multi-instance search/chat operations.
4416
4755
  *
4417
4756
  * @example
4418
4757
  * ```ts
4419
4758
  * // Access an instance within the namespace
4420
4759
  * const blog = env.AI_SEARCH.get("blog");
4421
- * const results = await blog.search({
4422
- * messages: [{ role: "user", content: "How does caching work?" }],
4423
- * });
4760
+ * const results = await blog.search({ query: "How does caching work?" });
4424
4761
  *
4425
4762
  * // List all instances in the namespace
4426
4763
  * const instances = await env.AI_SEARCH.list();
4427
4764
  *
4428
4765
  * // Create a new instance with built-in storage
4429
- * const tenant = await env.AI_SEARCH.create({
4430
- * id: "tenant-123",
4431
- * });
4766
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4432
4767
  *
4433
4768
  * // Upload items into the instance
4434
4769
  * await tenant.items.upload("doc.pdf", fileContent);
4435
4770
  *
4771
+ * // Search across multiple instances
4772
+ * const multi = await env.AI_SEARCH.search({
4773
+ * query: "caching",
4774
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4775
+ * });
4776
+ *
4436
4777
  * // Delete an instance
4437
4778
  * await env.AI_SEARCH.delete("tenant-123");
4438
4779
  * ```
@@ -4445,10 +4786,11 @@ declare abstract class AiSearchNamespace {
4445
4786
  */
4446
4787
  get(name: string): AiSearchInstance;
4447
4788
  /**
4448
- * List all instances in the bound namespace.
4449
- * @returns Array of instance metadata.
4789
+ * List instances in the bound namespace.
4790
+ * @param params Optional pagination, search, and ordering parameters.
4791
+ * @returns Array of instance metadata with pagination info.
4450
4792
  */
4451
- list(): Promise<AiSearchListResponse>;
4793
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4452
4794
  /**
4453
4795
  * Create a new instance within the bound namespace.
4454
4796
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4473,6 +4815,35 @@ declare abstract class AiSearchNamespace {
4473
4815
  * @param name Instance name to delete.
4474
4816
  */
4475
4817
  delete(name: string): Promise<void>;
4818
+ /**
4819
+ * Search across multiple instances within the bound namespace.
4820
+ * Fans out to the specified instance_ids and merges results.
4821
+ * @param params Search request with required `ai_search_options.instance_ids`.
4822
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4823
+ */
4824
+ search(
4825
+ params: AiSearchMultiSearchRequest,
4826
+ ): Promise<AiSearchMultiSearchResponse>;
4827
+ /**
4828
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4829
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4830
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4831
+ * @returns ReadableStream of server-sent events.
4832
+ */
4833
+ chatCompletions(
4834
+ params: AiSearchMultiChatCompletionsRequest & {
4835
+ stream: true;
4836
+ },
4837
+ ): Promise<ReadableStream>;
4838
+ /**
4839
+ * Generate chat completions across multiple instances within the bound namespace.
4840
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4841
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4842
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4843
+ */
4844
+ chatCompletions(
4845
+ params: AiSearchMultiChatCompletionsRequest,
4846
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4476
4847
  }
4477
4848
  type AiImageClassificationInput = {
4478
4849
  image: number[];
@@ -12124,8 +12495,8 @@ declare module "cloudflare:email" {
12124
12495
  * Evaluation context for targeting rules.
12125
12496
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12126
12497
  */
12127
- type EvaluationContext = Record<string, string | number | boolean>;
12128
- interface EvaluationDetails<T> {
12498
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12499
+ interface FlagshipEvaluationDetails<T> {
12129
12500
  flagKey: string;
12130
12501
  value: T;
12131
12502
  variant?: string | undefined;
@@ -12133,7 +12504,7 @@ interface EvaluationDetails<T> {
12133
12504
  errorCode?: string | undefined;
12134
12505
  errorMessage?: string | undefined;
12135
12506
  }
12136
- interface FlagEvaluationError extends Error {}
12507
+ interface FlagshipEvaluationError extends Error {}
12137
12508
  /**
12138
12509
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12139
12510
  *
@@ -12153,7 +12524,7 @@ interface FlagEvaluationError extends Error {}
12153
12524
  * console.log(details.variant, details.reason);
12154
12525
  * ```
12155
12526
  */
12156
- declare abstract class Flags {
12527
+ declare abstract class Flagship {
12157
12528
  /**
12158
12529
  * Get a flag value without type checking.
12159
12530
  * @param flagKey The key of the flag to evaluate.
@@ -12163,7 +12534,7 @@ declare abstract class Flags {
12163
12534
  get(
12164
12535
  flagKey: string,
12165
12536
  defaultValue?: unknown,
12166
- context?: EvaluationContext,
12537
+ context?: FlagshipEvaluationContext,
12167
12538
  ): Promise<unknown>;
12168
12539
  /**
12169
12540
  * Get a boolean flag value.
@@ -12174,7 +12545,7 @@ declare abstract class Flags {
12174
12545
  getBooleanValue(
12175
12546
  flagKey: string,
12176
12547
  defaultValue: boolean,
12177
- context?: EvaluationContext,
12548
+ context?: FlagshipEvaluationContext,
12178
12549
  ): Promise<boolean>;
12179
12550
  /**
12180
12551
  * Get a string flag value.
@@ -12185,7 +12556,7 @@ declare abstract class Flags {
12185
12556
  getStringValue(
12186
12557
  flagKey: string,
12187
12558
  defaultValue: string,
12188
- context?: EvaluationContext,
12559
+ context?: FlagshipEvaluationContext,
12189
12560
  ): Promise<string>;
12190
12561
  /**
12191
12562
  * Get a number flag value.
@@ -12196,7 +12567,7 @@ declare abstract class Flags {
12196
12567
  getNumberValue(
12197
12568
  flagKey: string,
12198
12569
  defaultValue: number,
12199
- context?: EvaluationContext,
12570
+ context?: FlagshipEvaluationContext,
12200
12571
  ): Promise<number>;
12201
12572
  /**
12202
12573
  * Get an object flag value.
@@ -12207,7 +12578,7 @@ declare abstract class Flags {
12207
12578
  getObjectValue<T extends object>(
12208
12579
  flagKey: string,
12209
12580
  defaultValue: T,
12210
- context?: EvaluationContext,
12581
+ context?: FlagshipEvaluationContext,
12211
12582
  ): Promise<T>;
12212
12583
  /**
12213
12584
  * Get a boolean flag value with full evaluation details.
@@ -12218,8 +12589,8 @@ declare abstract class Flags {
12218
12589
  getBooleanDetails(
12219
12590
  flagKey: string,
12220
12591
  defaultValue: boolean,
12221
- context?: EvaluationContext,
12222
- ): Promise<EvaluationDetails<boolean>>;
12592
+ context?: FlagshipEvaluationContext,
12593
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12223
12594
  /**
12224
12595
  * Get a string flag value with full evaluation details.
12225
12596
  * @param flagKey The key of the flag to evaluate.
@@ -12229,8 +12600,8 @@ declare abstract class Flags {
12229
12600
  getStringDetails(
12230
12601
  flagKey: string,
12231
12602
  defaultValue: string,
12232
- context?: EvaluationContext,
12233
- ): Promise<EvaluationDetails<string>>;
12603
+ context?: FlagshipEvaluationContext,
12604
+ ): Promise<FlagshipEvaluationDetails<string>>;
12234
12605
  /**
12235
12606
  * Get a number flag value with full evaluation details.
12236
12607
  * @param flagKey The key of the flag to evaluate.
@@ -12240,8 +12611,8 @@ declare abstract class Flags {
12240
12611
  getNumberDetails(
12241
12612
  flagKey: string,
12242
12613
  defaultValue: number,
12243
- context?: EvaluationContext,
12244
- ): Promise<EvaluationDetails<number>>;
12614
+ context?: FlagshipEvaluationContext,
12615
+ ): Promise<FlagshipEvaluationDetails<number>>;
12245
12616
  /**
12246
12617
  * Get an object flag value with full evaluation details.
12247
12618
  * @param flagKey The key of the flag to evaluate.
@@ -12251,8 +12622,8 @@ declare abstract class Flags {
12251
12622
  getObjectDetails<T extends object>(
12252
12623
  flagKey: string,
12253
12624
  defaultValue: T,
12254
- context?: EvaluationContext,
12255
- ): Promise<EvaluationDetails<T>>;
12625
+ context?: FlagshipEvaluationContext,
12626
+ ): Promise<FlagshipEvaluationDetails<T>>;
12256
12627
  }
12257
12628
  /**
12258
12629
  * Hello World binding to serve as an explanatory example. DO NOT USE