@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
  }
@@ -3974,73 +4013,145 @@ declare abstract class Performance {
3974
4013
  // ============ AI Search Error Interfaces ============
3975
4014
  interface AiSearchInternalError extends Error {}
3976
4015
  interface AiSearchNotFoundError extends Error {}
3977
- // ============ AI Search Request Types ============
3978
- type AiSearchSearchRequest = {
3979
- messages: Array<{
3980
- role: "system" | "developer" | "user" | "assistant" | "tool";
3981
- content: string | null;
3982
- }>;
3983
- ai_search_options?: {
3984
- retrieval?: {
3985
- retrieval_type?: "vector" | "keyword" | "hybrid";
3986
- /** Match threshold (0-1, default 0.4) */
3987
- match_threshold?: number;
3988
- /** Maximum number of results (1-50, default 10) */
3989
- max_num_results?: number;
3990
- filters?: VectorizeVectorMetadataFilter;
3991
- /** Context expansion (0-3, default 0) */
3992
- context_expansion?: number;
3993
- [key: string]: unknown;
3994
- };
3995
- query_rewrite?: {
3996
- enabled?: boolean;
3997
- model?: string;
3998
- rewrite_prompt?: string;
3999
- [key: string]: unknown;
4000
- };
4001
- reranking?: {
4002
- enabled?: boolean;
4003
- model?: "@cf/baai/bge-reranker-base" | string;
4004
- /** Match threshold (0-1, default 0.4) */
4005
- match_threshold?: number;
4006
- [key: string]: unknown;
4007
- };
4016
+ // ============ AI Search Common Types ============
4017
+ /** A single message in a conversation-style search or chat request. */
4018
+ type AiSearchMessage = {
4019
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4020
+ content: string | null;
4021
+ };
4022
+ /**
4023
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4024
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4025
+ */
4026
+ type AiSearchOptions = {
4027
+ retrieval?: {
4028
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4029
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4030
+ /** Fusion method for combining vector + keyword results. */
4031
+ fusion_method?: "max" | "rrf";
4032
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4033
+ keyword_match_mode?: "and" | "or";
4034
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4035
+ match_threshold?: number;
4036
+ /** Maximum number of results to return (1-50). Default 10. */
4037
+ max_num_results?: number;
4038
+ /** Vectorize metadata filters applied to the search. */
4039
+ filters?: VectorizeVectorMetadataFilter;
4040
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4041
+ context_expansion?: number;
4042
+ /** If true, return only item metadata without chunk text. */
4043
+ metadata_only?: boolean;
4044
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4045
+ return_on_failure?: boolean;
4046
+ /** Boost results by metadata field values. Max 3 entries. */
4047
+ boost_by?: Array<{
4048
+ field: string;
4049
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4050
+ }>;
4051
+ [key: string]: unknown;
4052
+ };
4053
+ query_rewrite?: {
4054
+ enabled?: boolean;
4055
+ model?: string;
4056
+ rewrite_prompt?: string;
4057
+ [key: string]: unknown;
4058
+ };
4059
+ reranking?: {
4060
+ enabled?: boolean;
4061
+ model?: string;
4062
+ /** Match threshold (0-1, default 0.4) */
4063
+ match_threshold?: number;
4008
4064
  [key: string]: unknown;
4009
4065
  };
4066
+ cache?: {
4067
+ enabled?: boolean;
4068
+ cache_threshold?:
4069
+ | "super_strict_match"
4070
+ | "close_enough"
4071
+ | "flexible_friend"
4072
+ | "anything_goes";
4073
+ };
4074
+ [key: string]: unknown;
4010
4075
  };
4076
+ // ============ AI Search Request Types ============
4077
+ /**
4078
+ * Request body for single-instance search.
4079
+ * Exactly one of `query` or `messages` must be provided.
4080
+ */
4081
+ type AiSearchSearchRequest =
4082
+ | {
4083
+ /** Simple query string. */
4084
+ query: string;
4085
+ messages?: never;
4086
+ ai_search_options?: AiSearchOptions;
4087
+ }
4088
+ | {
4089
+ query?: never;
4090
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4091
+ messages: AiSearchMessage[];
4092
+ ai_search_options?: AiSearchOptions;
4093
+ };
4011
4094
  type AiSearchChatCompletionsRequest = {
4012
- messages: Array<{
4013
- role: "system" | "developer" | "user" | "assistant" | "tool";
4014
- content: string | null;
4015
- [key: string]: unknown;
4016
- }>;
4095
+ messages: AiSearchMessage[];
4017
4096
  model?: string;
4018
4097
  stream?: boolean;
4019
- ai_search_options?: {
4020
- retrieval?: {
4021
- retrieval_type?: "vector" | "keyword" | "hybrid";
4022
- match_threshold?: number;
4023
- max_num_results?: number;
4024
- filters?: VectorizeVectorMetadataFilter;
4025
- context_expansion?: number;
4026
- [key: string]: unknown;
4027
- };
4028
- query_rewrite?: {
4029
- enabled?: boolean;
4030
- model?: string;
4031
- rewrite_prompt?: string;
4032
- [key: string]: unknown;
4033
- };
4034
- reranking?: {
4035
- enabled?: boolean;
4036
- model?: "@cf/baai/bge-reranker-base" | string;
4037
- match_threshold?: number;
4038
- [key: string]: unknown;
4039
- };
4040
- [key: string]: unknown;
4041
- };
4098
+ ai_search_options?: AiSearchOptions;
4042
4099
  [key: string]: unknown;
4043
4100
  };
4101
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4102
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4103
+ type AiSearchMultiSearchOptions = AiSearchOptions & {
4104
+ /** Instance IDs to search across (1-10). */
4105
+ instance_ids: string[];
4106
+ };
4107
+ /**
4108
+ * Request for searching across multiple instances within a namespace.
4109
+ * `ai_search_options` is required and must include `instance_ids`.
4110
+ * Exactly one of `query` or `messages` must be provided.
4111
+ */
4112
+ type AiSearchMultiSearchRequest =
4113
+ | {
4114
+ /** Simple query string. */
4115
+ query: string;
4116
+ messages?: never;
4117
+ ai_search_options: AiSearchMultiSearchOptions;
4118
+ }
4119
+ | {
4120
+ query?: never;
4121
+ /** Conversation-style input. */
4122
+ messages: AiSearchMessage[];
4123
+ ai_search_options: AiSearchMultiSearchOptions;
4124
+ };
4125
+ /** A search result chunk tagged with the instance it originated from. */
4126
+ type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4127
+ instance_id: string;
4128
+ };
4129
+ /** Describes a per-instance error during a multi-instance operation. */
4130
+ type AiSearchMultiSearchError = {
4131
+ instance_id: string;
4132
+ message: string;
4133
+ };
4134
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4135
+ type AiSearchMultiSearchResponse = {
4136
+ search_query: string;
4137
+ chunks: AiSearchMultiSearchChunk[];
4138
+ errors?: AiSearchMultiSearchError[];
4139
+ };
4140
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4141
+ type AiSearchMultiChatCompletionsRequest = Omit<
4142
+ AiSearchChatCompletionsRequest,
4143
+ "ai_search_options"
4144
+ > & {
4145
+ ai_search_options: AiSearchMultiSearchOptions;
4146
+ };
4147
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4148
+ type AiSearchMultiChatCompletionsResponse = Omit<
4149
+ AiSearchChatCompletionsResponse,
4150
+ "chunks"
4151
+ > & {
4152
+ chunks: AiSearchMultiSearchChunk[];
4153
+ errors?: AiSearchMultiSearchError[];
4154
+ };
4044
4155
  // ============ AI Search Response Types ============
4045
4156
  type AiSearchSearchResponse = {
4046
4157
  search_query: string;
@@ -4060,6 +4171,14 @@ type AiSearchSearchResponse = {
4060
4171
  keyword_score?: number;
4061
4172
  /** Vector similarity score (0-1) */
4062
4173
  vector_score?: number;
4174
+ /** Keyword rank position */
4175
+ keyword_rank?: number;
4176
+ /** Vector rank position */
4177
+ vector_rank?: number;
4178
+ /** Reranking model score */
4179
+ reranking_score?: number;
4180
+ /** Fusion method used to combine results */
4181
+ fusion_method?: "rrf" | "max";
4063
4182
  [key: string]: unknown;
4064
4183
  };
4065
4184
  }>;
@@ -4088,19 +4207,88 @@ type AiSearchStatsResponse = {
4088
4207
  skipped?: number;
4089
4208
  outdated?: number;
4090
4209
  last_activity?: string;
4210
+ /** Storage engine statistics. */
4211
+ engine?: {
4212
+ vectorize?: {
4213
+ vectorsCount: number;
4214
+ dimensions: number;
4215
+ };
4216
+ r2?: {
4217
+ payloadSizeBytes: number;
4218
+ metadataSizeBytes: number;
4219
+ objectCount: number;
4220
+ };
4221
+ };
4091
4222
  };
4092
4223
  // ============ AI Search Instance Info Types ============
4093
4224
  type AiSearchInstanceInfo = {
4094
4225
  id: string;
4095
4226
  type?: "r2" | "web-crawler" | string;
4096
4227
  source?: string;
4228
+ source_params?: unknown;
4097
4229
  paused?: boolean;
4098
4230
  status?: string;
4099
4231
  namespace?: string;
4100
4232
  created_at?: string;
4101
4233
  modified_at?: string;
4234
+ token_id?: string;
4235
+ ai_gateway_id?: string;
4236
+ rewrite_query?: boolean;
4237
+ reranking?: boolean;
4238
+ embedding_model?: string;
4239
+ ai_search_model?: string;
4240
+ rewrite_model?: string;
4241
+ reranking_model?: string;
4242
+ /** @deprecated Use index_method instead. */
4243
+ hybrid_search_enabled?: boolean;
4244
+ /** Controls which storage backends are active. */
4245
+ index_method?: {
4246
+ vector?: boolean;
4247
+ keyword?: boolean;
4248
+ };
4249
+ /** Fusion method for combining vector and keyword results. */
4250
+ fusion_method?: "max" | "rrf";
4251
+ indexing_options?: {
4252
+ keyword_tokenizer?: "porter" | "trigram";
4253
+ } | null;
4254
+ retrieval_options?: {
4255
+ keyword_match_mode?: "and" | "or";
4256
+ boost_by?: Array<{
4257
+ field: string;
4258
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4259
+ }>;
4260
+ } | null;
4261
+ chunk?: boolean;
4262
+ chunk_size?: number;
4263
+ chunk_overlap?: number;
4264
+ score_threshold?: number;
4265
+ max_num_results?: number;
4266
+ cache?: boolean;
4267
+ cache_threshold?:
4268
+ | "super_strict_match"
4269
+ | "close_enough"
4270
+ | "flexible_friend"
4271
+ | "anything_goes";
4272
+ custom_metadata?: Array<{
4273
+ field_name: string;
4274
+ data_type: "text" | "number" | "boolean" | "datetime";
4275
+ }>;
4276
+ /** Sync interval in seconds. */
4277
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4278
+ metadata?: Record<string, unknown>;
4102
4279
  [key: string]: unknown;
4103
4280
  };
4281
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4282
+ type AiSearchListInstancesParams = {
4283
+ page?: number;
4284
+ per_page?: number;
4285
+ /** Search instances by ID. */
4286
+ search?: string;
4287
+ /** Field to sort by. */
4288
+ order_by?: "created_at";
4289
+ /** Sort direction. */
4290
+ order_by_direction?: "asc" | "desc";
4291
+ };
4104
4292
  type AiSearchListResponse = {
4105
4293
  result: AiSearchInstanceInfo[];
4106
4294
  result_info?: {
@@ -4128,19 +4316,64 @@ type AiSearchConfig = {
4128
4316
  reranking?: boolean;
4129
4317
  embedding_model?: string;
4130
4318
  ai_search_model?: string;
4319
+ rewrite_model?: string;
4320
+ reranking_model?: string;
4321
+ /** @deprecated Use index_method instead. */
4322
+ hybrid_search_enabled?: boolean;
4323
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4324
+ index_method?: {
4325
+ vector?: boolean;
4326
+ keyword?: boolean;
4327
+ };
4328
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4329
+ fusion_method?: "max" | "rrf";
4330
+ indexing_options?: {
4331
+ keyword_tokenizer?: "porter" | "trigram";
4332
+ } | null;
4333
+ retrieval_options?: {
4334
+ keyword_match_mode?: "and" | "or";
4335
+ boost_by?: Array<{
4336
+ field: string;
4337
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4338
+ }>;
4339
+ } | null;
4340
+ chunk?: boolean;
4341
+ chunk_size?: number;
4342
+ chunk_overlap?: number;
4343
+ /** Minimum similarity score (0-1) for a result to be included. */
4344
+ score_threshold?: number;
4345
+ max_num_results?: number;
4346
+ cache?: boolean;
4347
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4348
+ cache_threshold?:
4349
+ | "super_strict_match"
4350
+ | "close_enough"
4351
+ | "flexible_friend"
4352
+ | "anything_goes";
4353
+ custom_metadata?: Array<{
4354
+ field_name: string;
4355
+ data_type: "text" | "number" | "boolean" | "datetime";
4356
+ }>;
4357
+ namespace?: string;
4358
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4359
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4360
+ metadata?: Record<string, unknown>;
4131
4361
  [key: string]: unknown;
4132
4362
  };
4133
4363
  // ============ AI Search Item Types ============
4134
4364
  type AiSearchItemInfo = {
4135
4365
  id: string;
4136
4366
  key: string;
4137
- status:
4138
- | "completed"
4139
- | "error"
4140
- | "skipped"
4141
- | "queued"
4142
- | "processing"
4143
- | "outdated";
4367
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4368
+ next_action?: "INDEX" | "DELETE" | null;
4369
+ error?: string;
4370
+ checksum?: string;
4371
+ namespace?: string;
4372
+ chunks_count?: number | null;
4373
+ file_size?: number | null;
4374
+ source_id?: string | null;
4375
+ last_seen_at?: string;
4376
+ created_at?: string;
4144
4377
  metadata?: Record<string, unknown>;
4145
4378
  [key: string]: unknown;
4146
4379
  };
@@ -4156,6 +4389,22 @@ type AiSearchUploadItemOptions = {
4156
4389
  type AiSearchListItemsParams = {
4157
4390
  page?: number;
4158
4391
  per_page?: number;
4392
+ /** Search items by key name. */
4393
+ search?: string;
4394
+ /** Sort order for results. */
4395
+ sort_by?: "status" | "modified_at";
4396
+ /** Filter items by processing status. */
4397
+ status?:
4398
+ | "queued"
4399
+ | "running"
4400
+ | "completed"
4401
+ | "error"
4402
+ | "skipped"
4403
+ | "outdated";
4404
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4405
+ source?: string;
4406
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4407
+ metadata_filter?: string;
4159
4408
  };
4160
4409
  type AiSearchListItemsResponse = {
4161
4410
  result: AiSearchItemInfo[];
@@ -4166,6 +4415,61 @@ type AiSearchListItemsResponse = {
4166
4415
  total_count: number;
4167
4416
  };
4168
4417
  };
4418
+ // ============ AI Search Item Logs Types ============
4419
+ type AiSearchItemLogsParams = {
4420
+ /** Maximum number of log entries to return (1-100, default 50). */
4421
+ limit?: number;
4422
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4423
+ cursor?: string;
4424
+ };
4425
+ type AiSearchItemLog = {
4426
+ timestamp: string;
4427
+ action: string;
4428
+ message: string;
4429
+ fileKey?: string;
4430
+ chunkCount?: number;
4431
+ processingTimeMs?: number;
4432
+ errorType?: string;
4433
+ };
4434
+ /** Paginated response for item processing logs (cursor-based). */
4435
+ type AiSearchItemLogsResponse = {
4436
+ result: AiSearchItemLog[];
4437
+ result_info: {
4438
+ count: number;
4439
+ per_page: number;
4440
+ cursor: string | null;
4441
+ truncated: boolean;
4442
+ };
4443
+ };
4444
+ // ============ AI Search Item Chunks Types ============
4445
+ type AiSearchItemChunksParams = {
4446
+ /** Maximum number of chunks to return (1-100, default 20). */
4447
+ limit?: number;
4448
+ /** Offset into the chunks list (default 0). */
4449
+ offset?: number;
4450
+ };
4451
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4452
+ type AiSearchItemChunk = {
4453
+ id: string;
4454
+ text: string;
4455
+ start_byte: number;
4456
+ end_byte: number;
4457
+ item?: {
4458
+ timestamp?: number;
4459
+ key: string;
4460
+ metadata?: Record<string, unknown>;
4461
+ };
4462
+ };
4463
+ /** Paginated response for item chunks (offset-based). */
4464
+ type AiSearchItemChunksResponse = {
4465
+ result: AiSearchItemChunk[];
4466
+ result_info: {
4467
+ count: number;
4468
+ total: number;
4469
+ limit: number;
4470
+ offset: number;
4471
+ };
4472
+ };
4169
4473
  // ============ AI Search Job Types ============
4170
4474
  type AiSearchJobInfo = {
4171
4475
  id: string;
@@ -4214,7 +4518,7 @@ type AiSearchJobLogsResponse = {
4214
4518
  // ============ AI Search Sub-Service Classes ============
4215
4519
  /**
4216
4520
  * Single item service for an AI Search instance.
4217
- * Provides info, delete, and download operations on a specific item.
4521
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4218
4522
  */
4219
4523
  declare abstract class AiSearchItem {
4220
4524
  /** Get metadata about this item. */
@@ -4224,6 +4528,25 @@ declare abstract class AiSearchItem {
4224
4528
  * @returns Object with body stream, content type, filename, and size.
4225
4529
  */
4226
4530
  download(): Promise<AiSearchItemContentResult>;
4531
+ /**
4532
+ * Trigger re-indexing of this item.
4533
+ * @returns The updated item info.
4534
+ */
4535
+ sync(): Promise<AiSearchItemInfo>;
4536
+ /**
4537
+ * Retrieve processing logs for this item (cursor-based pagination).
4538
+ * @param params Optional pagination parameters (limit, cursor).
4539
+ * @returns Paginated log entries for this item.
4540
+ */
4541
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4542
+ /**
4543
+ * List indexed chunks for this item (offset-based pagination).
4544
+ * @param params Optional pagination parameters (limit, offset).
4545
+ * @returns Paginated chunk entries for this item.
4546
+ */
4547
+ chunks(
4548
+ params?: AiSearchItemChunksParams,
4549
+ ): Promise<AiSearchItemChunksResponse>;
4227
4550
  }
4228
4551
  /**
4229
4552
  * Items collection service for an AI Search instance.
@@ -4233,49 +4556,64 @@ declare abstract class AiSearchItems {
4233
4556
  /** List items in this instance. */
4234
4557
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4235
4558
  /**
4236
- * Upload a file as an item.
4559
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4560
+ * filename already exists, it is overwritten and re-indexed.
4237
4561
  * @param name Filename for the uploaded item.
4238
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4562
+ * @param content File content as a ReadableStream, Blob, or string.
4239
4563
  * @param options Optional metadata to attach to the item.
4240
4564
  * @returns The created item info.
4241
4565
  */
4242
4566
  upload(
4243
4567
  name: string,
4244
- content: ReadableStream | ArrayBuffer | string,
4568
+ content: ReadableStream | Blob | string,
4245
4569
  options?: AiSearchUploadItemOptions,
4246
4570
  ): Promise<AiSearchItemInfo>;
4247
4571
  /**
4248
4572
  * Upload a file and poll until processing completes.
4573
+ * Behaves as an upsert: if an item with the same filename already exists,
4574
+ * it is overwritten and re-indexed.
4249
4575
  * @param name Filename for the uploaded item.
4250
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4251
- * @param options Optional metadata to attach to the item.
4576
+ * @param content File content as a ReadableStream, Blob, or string.
4577
+ * @param options Optional metadata and polling configuration.
4252
4578
  * @returns The item info after processing completes (or timeout).
4253
4579
  */
4254
4580
  uploadAndPoll(
4255
4581
  name: string,
4256
- content: ReadableStream | ArrayBuffer | string,
4257
- options?: AiSearchUploadItemOptions,
4582
+ content: ReadableStream | Blob | string,
4583
+ options?: AiSearchUploadItemOptions & {
4584
+ /** Polling interval in milliseconds (default 1000). */
4585
+ pollIntervalMs?: number;
4586
+ /** Maximum time to wait in milliseconds (default 30000). */
4587
+ timeoutMs?: number;
4588
+ },
4258
4589
  ): Promise<AiSearchItemInfo>;
4259
4590
  /**
4260
4591
  * Get an item by ID.
4261
4592
  * @param itemId The item identifier.
4262
- * @returns Item service for info, delete, and download operations.
4593
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4263
4594
  */
4264
4595
  get(itemId: string): AiSearchItem;
4265
- /** Delete this item from the instance.
4596
+ /**
4597
+ * Delete an item from the instance.
4266
4598
  * @param itemId The item identifier.
4267
4599
  */
4268
4600
  delete(itemId: string): Promise<void>;
4269
4601
  }
4270
4602
  /**
4271
4603
  * Single job service for an AI Search instance.
4272
- * Provides info and logs for a specific job.
4604
+ * Provides info, logs, and cancel operations for a specific job.
4273
4605
  */
4274
4606
  declare abstract class AiSearchJob {
4275
4607
  /** Get metadata about this job. */
4276
4608
  info(): Promise<AiSearchJobInfo>;
4277
4609
  /** Get logs for this job. */
4278
4610
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4611
+ /**
4612
+ * Cancel a running job.
4613
+ * @returns The updated job info.
4614
+ * @throws AiSearchNotFoundError if the job does not exist.
4615
+ */
4616
+ cancel(): Promise<AiSearchJobInfo>;
4279
4617
  }
4280
4618
  /**
4281
4619
  * Jobs collection service for an AI Search instance.
@@ -4293,7 +4631,7 @@ declare abstract class AiSearchJobs {
4293
4631
  /**
4294
4632
  * Get a job by ID.
4295
4633
  * @param jobId The job identifier.
4296
- * @returns Job service for info and logs operations.
4634
+ * @returns Job service for info, logs, and cancel operations.
4297
4635
  */
4298
4636
  get(jobId: string): AiSearchJob;
4299
4637
  }
@@ -4312,7 +4650,7 @@ declare abstract class AiSearchJobs {
4312
4650
  * // Via namespace binding
4313
4651
  * const instance = env.AI_SEARCH.get("blog");
4314
4652
  * const results = await instance.search({
4315
- * messages: [{ role: "user", content: "How does caching work?" }],
4653
+ * query: "How does caching work?",
4316
4654
  * });
4317
4655
  *
4318
4656
  * // Via single instance binding
@@ -4324,7 +4662,7 @@ declare abstract class AiSearchJobs {
4324
4662
  declare abstract class AiSearchInstance {
4325
4663
  /**
4326
4664
  * Search the AI Search instance for relevant chunks.
4327
- * @param params Search request with messages and optional AI search options.
4665
+ * @param params Search request with query or messages and optional AI search options.
4328
4666
  * @returns Search response with matching chunks and search query.
4329
4667
  */
4330
4668
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4356,7 +4694,7 @@ declare abstract class AiSearchInstance {
4356
4694
  info(): Promise<AiSearchInstanceInfo>;
4357
4695
  /**
4358
4696
  * Get instance statistics (item count, indexing status, etc.).
4359
- * @returns Statistics with counts per status and last activity time.
4697
+ * @returns Statistics with counts per status, last activity time, and engine details.
4360
4698
  */
4361
4699
  stats(): Promise<AiSearchStatsResponse>;
4362
4700
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4368,27 +4706,30 @@ declare abstract class AiSearchInstance {
4368
4706
  * Namespace-level AI Search service.
4369
4707
  *
4370
4708
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4371
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4709
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4710
+ * and multi-instance search/chat operations.
4372
4711
  *
4373
4712
  * @example
4374
4713
  * ```ts
4375
4714
  * // Access an instance within the namespace
4376
4715
  * const blog = env.AI_SEARCH.get("blog");
4377
- * const results = await blog.search({
4378
- * messages: [{ role: "user", content: "How does caching work?" }],
4379
- * });
4716
+ * const results = await blog.search({ query: "How does caching work?" });
4380
4717
  *
4381
4718
  * // List all instances in the namespace
4382
4719
  * const instances = await env.AI_SEARCH.list();
4383
4720
  *
4384
4721
  * // Create a new instance with built-in storage
4385
- * const tenant = await env.AI_SEARCH.create({
4386
- * id: "tenant-123",
4387
- * });
4722
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4388
4723
  *
4389
4724
  * // Upload items into the instance
4390
4725
  * await tenant.items.upload("doc.pdf", fileContent);
4391
4726
  *
4727
+ * // Search across multiple instances
4728
+ * const multi = await env.AI_SEARCH.search({
4729
+ * query: "caching",
4730
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4731
+ * });
4732
+ *
4392
4733
  * // Delete an instance
4393
4734
  * await env.AI_SEARCH.delete("tenant-123");
4394
4735
  * ```
@@ -4401,10 +4742,11 @@ declare abstract class AiSearchNamespace {
4401
4742
  */
4402
4743
  get(name: string): AiSearchInstance;
4403
4744
  /**
4404
- * List all instances in the bound namespace.
4405
- * @returns Array of instance metadata.
4745
+ * List instances in the bound namespace.
4746
+ * @param params Optional pagination, search, and ordering parameters.
4747
+ * @returns Array of instance metadata with pagination info.
4406
4748
  */
4407
- list(): Promise<AiSearchListResponse>;
4749
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4408
4750
  /**
4409
4751
  * Create a new instance within the bound namespace.
4410
4752
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4429,6 +4771,35 @@ declare abstract class AiSearchNamespace {
4429
4771
  * @param name Instance name to delete.
4430
4772
  */
4431
4773
  delete(name: string): Promise<void>;
4774
+ /**
4775
+ * Search across multiple instances within the bound namespace.
4776
+ * Fans out to the specified instance_ids and merges results.
4777
+ * @param params Search request with required `ai_search_options.instance_ids`.
4778
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4779
+ */
4780
+ search(
4781
+ params: AiSearchMultiSearchRequest,
4782
+ ): Promise<AiSearchMultiSearchResponse>;
4783
+ /**
4784
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4785
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4786
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4787
+ * @returns ReadableStream of server-sent events.
4788
+ */
4789
+ chatCompletions(
4790
+ params: AiSearchMultiChatCompletionsRequest & {
4791
+ stream: true;
4792
+ },
4793
+ ): Promise<ReadableStream>;
4794
+ /**
4795
+ * Generate chat completions across multiple instances within the bound namespace.
4796
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4797
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4798
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4799
+ */
4800
+ chatCompletions(
4801
+ params: AiSearchMultiChatCompletionsRequest,
4802
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4432
4803
  }
4433
4804
  type AiImageClassificationInput = {
4434
4805
  image: number[];
@@ -12080,8 +12451,8 @@ declare module "cloudflare:email" {
12080
12451
  * Evaluation context for targeting rules.
12081
12452
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12082
12453
  */
12083
- type EvaluationContext = Record<string, string | number | boolean>;
12084
- interface EvaluationDetails<T> {
12454
+ type FlagshipEvaluationContext = Record<string, string | number | boolean>;
12455
+ interface FlagshipEvaluationDetails<T> {
12085
12456
  flagKey: string;
12086
12457
  value: T;
12087
12458
  variant?: string | undefined;
@@ -12089,7 +12460,7 @@ interface EvaluationDetails<T> {
12089
12460
  errorCode?: string | undefined;
12090
12461
  errorMessage?: string | undefined;
12091
12462
  }
12092
- interface FlagEvaluationError extends Error {}
12463
+ interface FlagshipEvaluationError extends Error {}
12093
12464
  /**
12094
12465
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12095
12466
  *
@@ -12109,7 +12480,7 @@ interface FlagEvaluationError extends Error {}
12109
12480
  * console.log(details.variant, details.reason);
12110
12481
  * ```
12111
12482
  */
12112
- declare abstract class Flags {
12483
+ declare abstract class Flagship {
12113
12484
  /**
12114
12485
  * Get a flag value without type checking.
12115
12486
  * @param flagKey The key of the flag to evaluate.
@@ -12119,7 +12490,7 @@ declare abstract class Flags {
12119
12490
  get(
12120
12491
  flagKey: string,
12121
12492
  defaultValue?: unknown,
12122
- context?: EvaluationContext,
12493
+ context?: FlagshipEvaluationContext,
12123
12494
  ): Promise<unknown>;
12124
12495
  /**
12125
12496
  * Get a boolean flag value.
@@ -12130,7 +12501,7 @@ declare abstract class Flags {
12130
12501
  getBooleanValue(
12131
12502
  flagKey: string,
12132
12503
  defaultValue: boolean,
12133
- context?: EvaluationContext,
12504
+ context?: FlagshipEvaluationContext,
12134
12505
  ): Promise<boolean>;
12135
12506
  /**
12136
12507
  * Get a string flag value.
@@ -12141,7 +12512,7 @@ declare abstract class Flags {
12141
12512
  getStringValue(
12142
12513
  flagKey: string,
12143
12514
  defaultValue: string,
12144
- context?: EvaluationContext,
12515
+ context?: FlagshipEvaluationContext,
12145
12516
  ): Promise<string>;
12146
12517
  /**
12147
12518
  * Get a number flag value.
@@ -12152,7 +12523,7 @@ declare abstract class Flags {
12152
12523
  getNumberValue(
12153
12524
  flagKey: string,
12154
12525
  defaultValue: number,
12155
- context?: EvaluationContext,
12526
+ context?: FlagshipEvaluationContext,
12156
12527
  ): Promise<number>;
12157
12528
  /**
12158
12529
  * Get an object flag value.
@@ -12163,7 +12534,7 @@ declare abstract class Flags {
12163
12534
  getObjectValue<T extends object>(
12164
12535
  flagKey: string,
12165
12536
  defaultValue: T,
12166
- context?: EvaluationContext,
12537
+ context?: FlagshipEvaluationContext,
12167
12538
  ): Promise<T>;
12168
12539
  /**
12169
12540
  * Get a boolean flag value with full evaluation details.
@@ -12174,8 +12545,8 @@ declare abstract class Flags {
12174
12545
  getBooleanDetails(
12175
12546
  flagKey: string,
12176
12547
  defaultValue: boolean,
12177
- context?: EvaluationContext,
12178
- ): Promise<EvaluationDetails<boolean>>;
12548
+ context?: FlagshipEvaluationContext,
12549
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12179
12550
  /**
12180
12551
  * Get a string flag value with full evaluation details.
12181
12552
  * @param flagKey The key of the flag to evaluate.
@@ -12185,8 +12556,8 @@ declare abstract class Flags {
12185
12556
  getStringDetails(
12186
12557
  flagKey: string,
12187
12558
  defaultValue: string,
12188
- context?: EvaluationContext,
12189
- ): Promise<EvaluationDetails<string>>;
12559
+ context?: FlagshipEvaluationContext,
12560
+ ): Promise<FlagshipEvaluationDetails<string>>;
12190
12561
  /**
12191
12562
  * Get a number flag value with full evaluation details.
12192
12563
  * @param flagKey The key of the flag to evaluate.
@@ -12196,8 +12567,8 @@ declare abstract class Flags {
12196
12567
  getNumberDetails(
12197
12568
  flagKey: string,
12198
12569
  defaultValue: number,
12199
- context?: EvaluationContext,
12200
- ): Promise<EvaluationDetails<number>>;
12570
+ context?: FlagshipEvaluationContext,
12571
+ ): Promise<FlagshipEvaluationDetails<number>>;
12201
12572
  /**
12202
12573
  * Get an object flag value with full evaluation details.
12203
12574
  * @param flagKey The key of the flag to evaluate.
@@ -12207,8 +12578,8 @@ declare abstract class Flags {
12207
12578
  getObjectDetails<T extends object>(
12208
12579
  flagKey: string,
12209
12580
  defaultValue: T,
12210
- context?: EvaluationContext,
12211
- ): Promise<EvaluationDetails<T>>;
12581
+ context?: FlagshipEvaluationContext,
12582
+ ): Promise<FlagshipEvaluationDetails<T>>;
12212
12583
  }
12213
12584
  /**
12214
12585
  * Hello World binding to serve as an explanatory example. DO NOT USE