@cloudflare/workers-types 4.20260414.1 → 4.20260416.1

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.
@@ -2327,11 +2327,34 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2327
2327
  }
2328
2328
  export type QueueContentType = "text" | "bytes" | "json" | "v8";
2329
2329
  export interface Queue<Body = unknown> {
2330
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2330
+ metrics(): Promise<QueueMetrics>;
2331
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2331
2332
  sendBatch(
2332
2333
  messages: Iterable<MessageSendRequest<Body>>,
2333
2334
  options?: QueueSendBatchOptions,
2334
- ): Promise<void>;
2335
+ ): Promise<QueueSendBatchResponse>;
2336
+ }
2337
+ export interface QueueSendMetrics {
2338
+ backlogCount: number;
2339
+ backlogBytes: number;
2340
+ oldestMessageTimestamp?: Date;
2341
+ }
2342
+ export interface QueueSendMetadata {
2343
+ metrics: QueueSendMetrics;
2344
+ }
2345
+ export interface QueueSendResponse {
2346
+ metadata: QueueSendMetadata;
2347
+ }
2348
+ export interface QueueSendBatchMetrics {
2349
+ backlogCount: number;
2350
+ backlogBytes: number;
2351
+ oldestMessageTimestamp?: Date;
2352
+ }
2353
+ export interface QueueSendBatchMetadata {
2354
+ metrics: QueueSendBatchMetrics;
2355
+ }
2356
+ export interface QueueSendBatchResponse {
2357
+ metadata: QueueSendBatchMetadata;
2335
2358
  }
2336
2359
  export interface QueueSendOptions {
2337
2360
  contentType?: QueueContentType;
@@ -2345,6 +2368,19 @@ export interface MessageSendRequest<Body = unknown> {
2345
2368
  contentType?: QueueContentType;
2346
2369
  delaySeconds?: number;
2347
2370
  }
2371
+ export interface QueueMetrics {
2372
+ backlogCount: number;
2373
+ backlogBytes: number;
2374
+ oldestMessageTimestamp?: Date;
2375
+ }
2376
+ export interface MessageBatchMetrics {
2377
+ backlogCount: number;
2378
+ backlogBytes: number;
2379
+ oldestMessageTimestamp?: Date;
2380
+ }
2381
+ export interface MessageBatchMetadata {
2382
+ metrics: MessageBatchMetrics;
2383
+ }
2348
2384
  export interface QueueRetryOptions {
2349
2385
  delaySeconds?: number;
2350
2386
  }
@@ -2359,12 +2395,14 @@ export interface Message<Body = unknown> {
2359
2395
  export interface QueueEvent<Body = unknown> extends ExtendableEvent {
2360
2396
  readonly messages: readonly Message<Body>[];
2361
2397
  readonly queue: string;
2398
+ readonly metadata: MessageBatchMetadata;
2362
2399
  retryAll(options?: QueueRetryOptions): void;
2363
2400
  ackAll(): void;
2364
2401
  }
2365
2402
  export interface MessageBatch<Body = unknown> {
2366
2403
  readonly messages: readonly Message<Body>[];
2367
2404
  readonly queue: string;
2405
+ readonly metadata: MessageBatchMetadata;
2368
2406
  retryAll(options?: QueueRetryOptions): void;
2369
2407
  ackAll(): void;
2370
2408
  }
@@ -3985,72 +4023,145 @@ export declare abstract class Performance {
3985
4023
  // ============ AI Search Error Interfaces ============
3986
4024
  export interface AiSearchInternalError extends Error {}
3987
4025
  export interface AiSearchNotFoundError extends Error {}
3988
- // ============ AI Search Request Types ============
3989
- export type AiSearchSearchRequest = {
3990
- messages: Array<{
3991
- role: "system" | "developer" | "user" | "assistant" | "tool";
3992
- content: string | null;
3993
- }>;
3994
- ai_search_options?: {
3995
- retrieval?: {
3996
- retrieval_type?: "vector" | "keyword" | "hybrid";
3997
- /** Match threshold (0-1, default 0.4) */
3998
- match_threshold?: number;
3999
- /** Maximum number of results (1-50, default 10) */
4000
- max_num_results?: number;
4001
- filters?: VectorizeVectorMetadataFilter;
4002
- /** Context expansion (0-3, default 0) */
4003
- context_expansion?: number;
4004
- [key: string]: unknown;
4005
- };
4006
- query_rewrite?: {
4007
- enabled?: boolean;
4008
- model?: string;
4009
- rewrite_prompt?: string;
4010
- [key: string]: unknown;
4011
- };
4012
- reranking?: {
4013
- enabled?: boolean;
4014
- model?: "@cf/baai/bge-reranker-base" | string;
4015
- /** Match threshold (0-1, default 0.4) */
4016
- match_threshold?: number;
4017
- [key: string]: unknown;
4018
- };
4026
+ // ============ AI Search Common Types ============
4027
+ /** A single message in a conversation-style search or chat request. */
4028
+ export type AiSearchMessage = {
4029
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4030
+ content: string | null;
4031
+ };
4032
+ /**
4033
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4034
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4035
+ */
4036
+ export type AiSearchOptions = {
4037
+ retrieval?: {
4038
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4039
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4040
+ /** Fusion method for combining vector + keyword results. */
4041
+ fusion_method?: "max" | "rrf";
4042
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4043
+ keyword_match_mode?: "and" | "or";
4044
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4045
+ match_threshold?: number;
4046
+ /** Maximum number of results to return (1-50). Default 10. */
4047
+ max_num_results?: number;
4048
+ /** Vectorize metadata filters applied to the search. */
4049
+ filters?: VectorizeVectorMetadataFilter;
4050
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4051
+ context_expansion?: number;
4052
+ /** If true, return only item metadata without chunk text. */
4053
+ metadata_only?: boolean;
4054
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4055
+ return_on_failure?: boolean;
4056
+ /** Boost results by metadata field values. Max 3 entries. */
4057
+ boost_by?: Array<{
4058
+ field: string;
4059
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4060
+ }>;
4061
+ [key: string]: unknown;
4062
+ };
4063
+ query_rewrite?: {
4064
+ enabled?: boolean;
4065
+ model?: string;
4066
+ rewrite_prompt?: string;
4067
+ [key: string]: unknown;
4068
+ };
4069
+ reranking?: {
4070
+ enabled?: boolean;
4071
+ model?: string;
4072
+ /** Match threshold (0-1, default 0.4) */
4073
+ match_threshold?: number;
4019
4074
  [key: string]: unknown;
4020
4075
  };
4076
+ cache?: {
4077
+ enabled?: boolean;
4078
+ cache_threshold?:
4079
+ | "super_strict_match"
4080
+ | "close_enough"
4081
+ | "flexible_friend"
4082
+ | "anything_goes";
4083
+ };
4084
+ [key: string]: unknown;
4021
4085
  };
4086
+ // ============ AI Search Request Types ============
4087
+ /**
4088
+ * Request body for single-instance search.
4089
+ * Exactly one of `query` or `messages` must be provided.
4090
+ */
4091
+ export type AiSearchSearchRequest =
4092
+ | {
4093
+ /** Simple query string. */
4094
+ query: string;
4095
+ messages?: never;
4096
+ ai_search_options?: AiSearchOptions;
4097
+ }
4098
+ | {
4099
+ query?: never;
4100
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4101
+ messages: AiSearchMessage[];
4102
+ ai_search_options?: AiSearchOptions;
4103
+ };
4022
4104
  export type AiSearchChatCompletionsRequest = {
4023
- messages: Array<{
4024
- role: "system" | "developer" | "user" | "assistant" | "tool";
4025
- content: string | null;
4026
- [key: string]: unknown;
4027
- }>;
4105
+ messages: AiSearchMessage[];
4028
4106
  model?: string;
4029
4107
  stream?: boolean;
4030
- ai_search_options?: {
4031
- retrieval?: {
4032
- retrieval_type?: "vector" | "keyword" | "hybrid";
4033
- match_threshold?: number;
4034
- max_num_results?: number;
4035
- filters?: VectorizeVectorMetadataFilter;
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?: number;
4049
- [key: string]: unknown;
4108
+ ai_search_options?: AiSearchOptions;
4109
+ [key: string]: unknown;
4110
+ };
4111
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4112
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4113
+ export type AiSearchMultiSearchOptions = AiSearchOptions & {
4114
+ /** Instance IDs to search across (1-10). */
4115
+ instance_ids: string[];
4116
+ };
4117
+ /**
4118
+ * Request for searching across multiple instances within a namespace.
4119
+ * `ai_search_options` is required and must include `instance_ids`.
4120
+ * Exactly one of `query` or `messages` must be provided.
4121
+ */
4122
+ export type AiSearchMultiSearchRequest =
4123
+ | {
4124
+ /** Simple query string. */
4125
+ query: string;
4126
+ messages?: never;
4127
+ ai_search_options: AiSearchMultiSearchOptions;
4128
+ }
4129
+ | {
4130
+ query?: never;
4131
+ /** Conversation-style input. */
4132
+ messages: AiSearchMessage[];
4133
+ ai_search_options: AiSearchMultiSearchOptions;
4050
4134
  };
4051
- [key: string]: unknown;
4135
+ /** A search result chunk tagged with the instance it originated from. */
4136
+ export type AiSearchMultiSearchChunk =
4137
+ AiSearchSearchResponse["chunks"][number] & {
4138
+ instance_id: string;
4052
4139
  };
4053
- [key: string]: unknown;
4140
+ /** Describes a per-instance error during a multi-instance operation. */
4141
+ export type AiSearchMultiSearchError = {
4142
+ instance_id: string;
4143
+ message: string;
4144
+ };
4145
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4146
+ export type AiSearchMultiSearchResponse = {
4147
+ search_query: string;
4148
+ chunks: AiSearchMultiSearchChunk[];
4149
+ errors?: AiSearchMultiSearchError[];
4150
+ };
4151
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4152
+ export type AiSearchMultiChatCompletionsRequest = Omit<
4153
+ AiSearchChatCompletionsRequest,
4154
+ "ai_search_options"
4155
+ > & {
4156
+ ai_search_options: AiSearchMultiSearchOptions;
4157
+ };
4158
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4159
+ export type AiSearchMultiChatCompletionsResponse = Omit<
4160
+ AiSearchChatCompletionsResponse,
4161
+ "chunks"
4162
+ > & {
4163
+ chunks: AiSearchMultiSearchChunk[];
4164
+ errors?: AiSearchMultiSearchError[];
4054
4165
  };
4055
4166
  // ============ AI Search Response Types ============
4056
4167
  export type AiSearchSearchResponse = {
@@ -4071,6 +4182,14 @@ export type AiSearchSearchResponse = {
4071
4182
  keyword_score?: number;
4072
4183
  /** Vector similarity score (0-1) */
4073
4184
  vector_score?: number;
4185
+ /** Keyword rank position */
4186
+ keyword_rank?: number;
4187
+ /** Vector rank position */
4188
+ vector_rank?: number;
4189
+ /** Reranking model score */
4190
+ reranking_score?: number;
4191
+ /** Fusion method used to combine results */
4192
+ fusion_method?: "rrf" | "max";
4074
4193
  [key: string]: unknown;
4075
4194
  };
4076
4195
  }>;
@@ -4099,19 +4218,88 @@ export type AiSearchStatsResponse = {
4099
4218
  skipped?: number;
4100
4219
  outdated?: number;
4101
4220
  last_activity?: string;
4221
+ /** Storage engine statistics. */
4222
+ engine?: {
4223
+ vectorize?: {
4224
+ vectorsCount: number;
4225
+ dimensions: number;
4226
+ };
4227
+ r2?: {
4228
+ payloadSizeBytes: number;
4229
+ metadataSizeBytes: number;
4230
+ objectCount: number;
4231
+ };
4232
+ };
4102
4233
  };
4103
4234
  // ============ AI Search Instance Info Types ============
4104
4235
  export type AiSearchInstanceInfo = {
4105
4236
  id: string;
4106
4237
  type?: "r2" | "web-crawler" | string;
4107
4238
  source?: string;
4239
+ source_params?: unknown;
4108
4240
  paused?: boolean;
4109
4241
  status?: string;
4110
4242
  namespace?: string;
4111
4243
  created_at?: string;
4112
4244
  modified_at?: string;
4245
+ token_id?: string;
4246
+ ai_gateway_id?: string;
4247
+ rewrite_query?: boolean;
4248
+ reranking?: boolean;
4249
+ embedding_model?: string;
4250
+ ai_search_model?: string;
4251
+ rewrite_model?: string;
4252
+ reranking_model?: string;
4253
+ /** @deprecated Use index_method instead. */
4254
+ hybrid_search_enabled?: boolean;
4255
+ /** Controls which storage backends are active. */
4256
+ index_method?: {
4257
+ vector?: boolean;
4258
+ keyword?: boolean;
4259
+ };
4260
+ /** Fusion method for combining vector and keyword results. */
4261
+ fusion_method?: "max" | "rrf";
4262
+ indexing_options?: {
4263
+ keyword_tokenizer?: "porter" | "trigram";
4264
+ } | null;
4265
+ retrieval_options?: {
4266
+ keyword_match_mode?: "and" | "or";
4267
+ boost_by?: Array<{
4268
+ field: string;
4269
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4270
+ }>;
4271
+ } | null;
4272
+ chunk?: boolean;
4273
+ chunk_size?: number;
4274
+ chunk_overlap?: number;
4275
+ score_threshold?: number;
4276
+ max_num_results?: number;
4277
+ cache?: boolean;
4278
+ cache_threshold?:
4279
+ | "super_strict_match"
4280
+ | "close_enough"
4281
+ | "flexible_friend"
4282
+ | "anything_goes";
4283
+ custom_metadata?: Array<{
4284
+ field_name: string;
4285
+ data_type: "text" | "number" | "boolean" | "datetime";
4286
+ }>;
4287
+ /** Sync interval in seconds. */
4288
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4289
+ metadata?: Record<string, unknown>;
4113
4290
  [key: string]: unknown;
4114
4291
  };
4292
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4293
+ export type AiSearchListInstancesParams = {
4294
+ page?: number;
4295
+ per_page?: number;
4296
+ /** Search instances by ID. */
4297
+ search?: string;
4298
+ /** Field to sort by. */
4299
+ order_by?: "created_at";
4300
+ /** Sort direction. */
4301
+ order_by_direction?: "asc" | "desc";
4302
+ };
4115
4303
  export type AiSearchListResponse = {
4116
4304
  result: AiSearchInstanceInfo[];
4117
4305
  result_info?: {
@@ -4139,19 +4327,64 @@ export type AiSearchConfig = {
4139
4327
  reranking?: boolean;
4140
4328
  embedding_model?: string;
4141
4329
  ai_search_model?: string;
4330
+ rewrite_model?: string;
4331
+ reranking_model?: string;
4332
+ /** @deprecated Use index_method instead. */
4333
+ hybrid_search_enabled?: boolean;
4334
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4335
+ index_method?: {
4336
+ vector?: boolean;
4337
+ keyword?: boolean;
4338
+ };
4339
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4340
+ fusion_method?: "max" | "rrf";
4341
+ indexing_options?: {
4342
+ keyword_tokenizer?: "porter" | "trigram";
4343
+ } | null;
4344
+ retrieval_options?: {
4345
+ keyword_match_mode?: "and" | "or";
4346
+ boost_by?: Array<{
4347
+ field: string;
4348
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4349
+ }>;
4350
+ } | null;
4351
+ chunk?: boolean;
4352
+ chunk_size?: number;
4353
+ chunk_overlap?: number;
4354
+ /** Minimum similarity score (0-1) for a result to be included. */
4355
+ score_threshold?: number;
4356
+ max_num_results?: number;
4357
+ cache?: boolean;
4358
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4359
+ cache_threshold?:
4360
+ | "super_strict_match"
4361
+ | "close_enough"
4362
+ | "flexible_friend"
4363
+ | "anything_goes";
4364
+ custom_metadata?: Array<{
4365
+ field_name: string;
4366
+ data_type: "text" | "number" | "boolean" | "datetime";
4367
+ }>;
4368
+ namespace?: string;
4369
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4370
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4371
+ metadata?: Record<string, unknown>;
4142
4372
  [key: string]: unknown;
4143
4373
  };
4144
4374
  // ============ AI Search Item Types ============
4145
4375
  export type AiSearchItemInfo = {
4146
4376
  id: string;
4147
4377
  key: string;
4148
- status:
4149
- | "completed"
4150
- | "error"
4151
- | "skipped"
4152
- | "queued"
4153
- | "processing"
4154
- | "outdated";
4378
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4379
+ next_action?: "INDEX" | "DELETE" | null;
4380
+ error?: string;
4381
+ checksum?: string;
4382
+ namespace?: string;
4383
+ chunks_count?: number | null;
4384
+ file_size?: number | null;
4385
+ source_id?: string | null;
4386
+ last_seen_at?: string;
4387
+ created_at?: string;
4155
4388
  metadata?: Record<string, unknown>;
4156
4389
  [key: string]: unknown;
4157
4390
  };
@@ -4167,6 +4400,22 @@ export type AiSearchUploadItemOptions = {
4167
4400
  export type AiSearchListItemsParams = {
4168
4401
  page?: number;
4169
4402
  per_page?: number;
4403
+ /** Search items by key name. */
4404
+ search?: string;
4405
+ /** Sort order for results. */
4406
+ sort_by?: "status" | "modified_at";
4407
+ /** Filter items by processing status. */
4408
+ status?:
4409
+ | "queued"
4410
+ | "running"
4411
+ | "completed"
4412
+ | "error"
4413
+ | "skipped"
4414
+ | "outdated";
4415
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4416
+ source?: string;
4417
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4418
+ metadata_filter?: string;
4170
4419
  };
4171
4420
  export type AiSearchListItemsResponse = {
4172
4421
  result: AiSearchItemInfo[];
@@ -4177,6 +4426,61 @@ export type AiSearchListItemsResponse = {
4177
4426
  total_count: number;
4178
4427
  };
4179
4428
  };
4429
+ // ============ AI Search Item Logs Types ============
4430
+ export type AiSearchItemLogsParams = {
4431
+ /** Maximum number of log entries to return (1-100, default 50). */
4432
+ limit?: number;
4433
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4434
+ cursor?: string;
4435
+ };
4436
+ export type AiSearchItemLog = {
4437
+ timestamp: string;
4438
+ action: string;
4439
+ message: string;
4440
+ fileKey?: string;
4441
+ chunkCount?: number;
4442
+ processingTimeMs?: number;
4443
+ errorType?: string;
4444
+ };
4445
+ /** Paginated response for item processing logs (cursor-based). */
4446
+ export type AiSearchItemLogsResponse = {
4447
+ result: AiSearchItemLog[];
4448
+ result_info: {
4449
+ count: number;
4450
+ per_page: number;
4451
+ cursor: string | null;
4452
+ truncated: boolean;
4453
+ };
4454
+ };
4455
+ // ============ AI Search Item Chunks Types ============
4456
+ export type AiSearchItemChunksParams = {
4457
+ /** Maximum number of chunks to return (1-100, default 20). */
4458
+ limit?: number;
4459
+ /** Offset into the chunks list (default 0). */
4460
+ offset?: number;
4461
+ };
4462
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4463
+ export type AiSearchItemChunk = {
4464
+ id: string;
4465
+ text: string;
4466
+ start_byte: number;
4467
+ end_byte: number;
4468
+ item?: {
4469
+ timestamp?: number;
4470
+ key: string;
4471
+ metadata?: Record<string, unknown>;
4472
+ };
4473
+ };
4474
+ /** Paginated response for item chunks (offset-based). */
4475
+ export type AiSearchItemChunksResponse = {
4476
+ result: AiSearchItemChunk[];
4477
+ result_info: {
4478
+ count: number;
4479
+ total: number;
4480
+ limit: number;
4481
+ offset: number;
4482
+ };
4483
+ };
4180
4484
  // ============ AI Search Job Types ============
4181
4485
  export type AiSearchJobInfo = {
4182
4486
  id: string;
@@ -4225,7 +4529,7 @@ export type AiSearchJobLogsResponse = {
4225
4529
  // ============ AI Search Sub-Service Classes ============
4226
4530
  /**
4227
4531
  * Single item service for an AI Search instance.
4228
- * Provides info, delete, and download operations on a specific item.
4532
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4229
4533
  */
4230
4534
  export declare abstract class AiSearchItem {
4231
4535
  /** Get metadata about this item. */
@@ -4235,6 +4539,25 @@ export declare abstract class AiSearchItem {
4235
4539
  * @returns Object with body stream, content type, filename, and size.
4236
4540
  */
4237
4541
  download(): Promise<AiSearchItemContentResult>;
4542
+ /**
4543
+ * Trigger re-indexing of this item.
4544
+ * @returns The updated item info.
4545
+ */
4546
+ sync(): Promise<AiSearchItemInfo>;
4547
+ /**
4548
+ * Retrieve processing logs for this item (cursor-based pagination).
4549
+ * @param params Optional pagination parameters (limit, cursor).
4550
+ * @returns Paginated log entries for this item.
4551
+ */
4552
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4553
+ /**
4554
+ * List indexed chunks for this item (offset-based pagination).
4555
+ * @param params Optional pagination parameters (limit, offset).
4556
+ * @returns Paginated chunk entries for this item.
4557
+ */
4558
+ chunks(
4559
+ params?: AiSearchItemChunksParams,
4560
+ ): Promise<AiSearchItemChunksResponse>;
4238
4561
  }
4239
4562
  /**
4240
4563
  * Items collection service for an AI Search instance.
@@ -4244,49 +4567,64 @@ export declare abstract class AiSearchItems {
4244
4567
  /** List items in this instance. */
4245
4568
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4246
4569
  /**
4247
- * Upload a file as an item.
4570
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4571
+ * filename already exists, it is overwritten and re-indexed.
4248
4572
  * @param name Filename for the uploaded item.
4249
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4573
+ * @param content File content as a ReadableStream, Blob, or string.
4250
4574
  * @param options Optional metadata to attach to the item.
4251
4575
  * @returns The created item info.
4252
4576
  */
4253
4577
  upload(
4254
4578
  name: string,
4255
- content: ReadableStream | ArrayBuffer | string,
4579
+ content: ReadableStream | Blob | string,
4256
4580
  options?: AiSearchUploadItemOptions,
4257
4581
  ): Promise<AiSearchItemInfo>;
4258
4582
  /**
4259
4583
  * Upload a file and poll until processing completes.
4584
+ * Behaves as an upsert: if an item with the same filename already exists,
4585
+ * it is overwritten and re-indexed.
4260
4586
  * @param name Filename for the uploaded item.
4261
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4262
- * @param options Optional metadata to attach to the item.
4587
+ * @param content File content as a ReadableStream, Blob, or string.
4588
+ * @param options Optional metadata and polling configuration.
4263
4589
  * @returns The item info after processing completes (or timeout).
4264
4590
  */
4265
4591
  uploadAndPoll(
4266
4592
  name: string,
4267
- content: ReadableStream | ArrayBuffer | string,
4268
- options?: AiSearchUploadItemOptions,
4593
+ content: ReadableStream | Blob | string,
4594
+ options?: AiSearchUploadItemOptions & {
4595
+ /** Polling interval in milliseconds (default 1000). */
4596
+ pollIntervalMs?: number;
4597
+ /** Maximum time to wait in milliseconds (default 30000). */
4598
+ timeoutMs?: number;
4599
+ },
4269
4600
  ): Promise<AiSearchItemInfo>;
4270
4601
  /**
4271
4602
  * Get an item by ID.
4272
4603
  * @param itemId The item identifier.
4273
- * @returns Item service for info, delete, and download operations.
4604
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4274
4605
  */
4275
4606
  get(itemId: string): AiSearchItem;
4276
- /** Delete this item from the instance.
4607
+ /**
4608
+ * Delete an item from the instance.
4277
4609
  * @param itemId The item identifier.
4278
4610
  */
4279
4611
  delete(itemId: string): Promise<void>;
4280
4612
  }
4281
4613
  /**
4282
4614
  * Single job service for an AI Search instance.
4283
- * Provides info and logs for a specific job.
4615
+ * Provides info, logs, and cancel operations for a specific job.
4284
4616
  */
4285
4617
  export declare abstract class AiSearchJob {
4286
4618
  /** Get metadata about this job. */
4287
4619
  info(): Promise<AiSearchJobInfo>;
4288
4620
  /** Get logs for this job. */
4289
4621
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4622
+ /**
4623
+ * Cancel a running job.
4624
+ * @returns The updated job info.
4625
+ * @throws AiSearchNotFoundError if the job does not exist.
4626
+ */
4627
+ cancel(): Promise<AiSearchJobInfo>;
4290
4628
  }
4291
4629
  /**
4292
4630
  * Jobs collection service for an AI Search instance.
@@ -4304,7 +4642,7 @@ export declare abstract class AiSearchJobs {
4304
4642
  /**
4305
4643
  * Get a job by ID.
4306
4644
  * @param jobId The job identifier.
4307
- * @returns Job service for info and logs operations.
4645
+ * @returns Job service for info, logs, and cancel operations.
4308
4646
  */
4309
4647
  get(jobId: string): AiSearchJob;
4310
4648
  }
@@ -4323,7 +4661,7 @@ export declare abstract class AiSearchJobs {
4323
4661
  * // Via namespace binding
4324
4662
  * const instance = env.AI_SEARCH.get("blog");
4325
4663
  * const results = await instance.search({
4326
- * messages: [{ role: "user", content: "How does caching work?" }],
4664
+ * query: "How does caching work?",
4327
4665
  * });
4328
4666
  *
4329
4667
  * // Via single instance binding
@@ -4335,7 +4673,7 @@ export declare abstract class AiSearchJobs {
4335
4673
  export declare abstract class AiSearchInstance {
4336
4674
  /**
4337
4675
  * Search the AI Search instance for relevant chunks.
4338
- * @param params Search request with messages and optional AI search options.
4676
+ * @param params Search request with query or messages and optional AI search options.
4339
4677
  * @returns Search response with matching chunks and search query.
4340
4678
  */
4341
4679
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4367,7 +4705,7 @@ export declare abstract class AiSearchInstance {
4367
4705
  info(): Promise<AiSearchInstanceInfo>;
4368
4706
  /**
4369
4707
  * Get instance statistics (item count, indexing status, etc.).
4370
- * @returns Statistics with counts per status and last activity time.
4708
+ * @returns Statistics with counts per status, last activity time, and engine details.
4371
4709
  */
4372
4710
  stats(): Promise<AiSearchStatsResponse>;
4373
4711
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4379,27 +4717,30 @@ export declare abstract class AiSearchInstance {
4379
4717
  * Namespace-level AI Search service.
4380
4718
  *
4381
4719
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4382
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4720
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4721
+ * and multi-instance search/chat operations.
4383
4722
  *
4384
4723
  * @example
4385
4724
  * ```ts
4386
4725
  * // Access an instance within the namespace
4387
4726
  * const blog = env.AI_SEARCH.get("blog");
4388
- * const results = await blog.search({
4389
- * messages: [{ role: "user", content: "How does caching work?" }],
4390
- * });
4727
+ * const results = await blog.search({ query: "How does caching work?" });
4391
4728
  *
4392
4729
  * // List all instances in the namespace
4393
4730
  * const instances = await env.AI_SEARCH.list();
4394
4731
  *
4395
4732
  * // Create a new instance with built-in storage
4396
- * const tenant = await env.AI_SEARCH.create({
4397
- * id: "tenant-123",
4398
- * });
4733
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4399
4734
  *
4400
4735
  * // Upload items into the instance
4401
4736
  * await tenant.items.upload("doc.pdf", fileContent);
4402
4737
  *
4738
+ * // Search across multiple instances
4739
+ * const multi = await env.AI_SEARCH.search({
4740
+ * query: "caching",
4741
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4742
+ * });
4743
+ *
4403
4744
  * // Delete an instance
4404
4745
  * await env.AI_SEARCH.delete("tenant-123");
4405
4746
  * ```
@@ -4412,10 +4753,11 @@ export declare abstract class AiSearchNamespace {
4412
4753
  */
4413
4754
  get(name: string): AiSearchInstance;
4414
4755
  /**
4415
- * List all instances in the bound namespace.
4416
- * @returns Array of instance metadata.
4756
+ * List instances in the bound namespace.
4757
+ * @param params Optional pagination, search, and ordering parameters.
4758
+ * @returns Array of instance metadata with pagination info.
4417
4759
  */
4418
- list(): Promise<AiSearchListResponse>;
4760
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4419
4761
  /**
4420
4762
  * Create a new instance within the bound namespace.
4421
4763
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4440,6 +4782,35 @@ export declare abstract class AiSearchNamespace {
4440
4782
  * @param name Instance name to delete.
4441
4783
  */
4442
4784
  delete(name: string): Promise<void>;
4785
+ /**
4786
+ * Search across multiple instances within the bound namespace.
4787
+ * Fans out to the specified instance_ids and merges results.
4788
+ * @param params Search request with required `ai_search_options.instance_ids`.
4789
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4790
+ */
4791
+ search(
4792
+ params: AiSearchMultiSearchRequest,
4793
+ ): Promise<AiSearchMultiSearchResponse>;
4794
+ /**
4795
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4796
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4797
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4798
+ * @returns ReadableStream of server-sent events.
4799
+ */
4800
+ chatCompletions(
4801
+ params: AiSearchMultiChatCompletionsRequest & {
4802
+ stream: true;
4803
+ },
4804
+ ): Promise<ReadableStream>;
4805
+ /**
4806
+ * Generate chat completions across multiple instances within the bound namespace.
4807
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4808
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4809
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4810
+ */
4811
+ chatCompletions(
4812
+ params: AiSearchMultiChatCompletionsRequest,
4813
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4443
4814
  }
4444
4815
  export type AiImageClassificationInput = {
4445
4816
  image: number[];
@@ -12101,8 +12472,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12101
12472
  * Evaluation context for targeting rules.
12102
12473
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12103
12474
  */
12104
- export type EvaluationContext = Record<string, string | number | boolean>;
12105
- export interface EvaluationDetails<T> {
12475
+ export type FlagshipEvaluationContext = Record<
12476
+ string,
12477
+ string | number | boolean
12478
+ >;
12479
+ export interface FlagshipEvaluationDetails<T> {
12106
12480
  flagKey: string;
12107
12481
  value: T;
12108
12482
  variant?: string | undefined;
@@ -12110,7 +12484,7 @@ export interface EvaluationDetails<T> {
12110
12484
  errorCode?: string | undefined;
12111
12485
  errorMessage?: string | undefined;
12112
12486
  }
12113
- export interface FlagEvaluationError extends Error {}
12487
+ export interface FlagshipEvaluationError extends Error {}
12114
12488
  /**
12115
12489
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12116
12490
  *
@@ -12130,7 +12504,7 @@ export interface FlagEvaluationError extends Error {}
12130
12504
  * console.log(details.variant, details.reason);
12131
12505
  * ```
12132
12506
  */
12133
- export declare abstract class Flags {
12507
+ export declare abstract class Flagship {
12134
12508
  /**
12135
12509
  * Get a flag value without type checking.
12136
12510
  * @param flagKey The key of the flag to evaluate.
@@ -12140,7 +12514,7 @@ export declare abstract class Flags {
12140
12514
  get(
12141
12515
  flagKey: string,
12142
12516
  defaultValue?: unknown,
12143
- context?: EvaluationContext,
12517
+ context?: FlagshipEvaluationContext,
12144
12518
  ): Promise<unknown>;
12145
12519
  /**
12146
12520
  * Get a boolean flag value.
@@ -12151,7 +12525,7 @@ export declare abstract class Flags {
12151
12525
  getBooleanValue(
12152
12526
  flagKey: string,
12153
12527
  defaultValue: boolean,
12154
- context?: EvaluationContext,
12528
+ context?: FlagshipEvaluationContext,
12155
12529
  ): Promise<boolean>;
12156
12530
  /**
12157
12531
  * Get a string flag value.
@@ -12162,7 +12536,7 @@ export declare abstract class Flags {
12162
12536
  getStringValue(
12163
12537
  flagKey: string,
12164
12538
  defaultValue: string,
12165
- context?: EvaluationContext,
12539
+ context?: FlagshipEvaluationContext,
12166
12540
  ): Promise<string>;
12167
12541
  /**
12168
12542
  * Get a number flag value.
@@ -12173,7 +12547,7 @@ export declare abstract class Flags {
12173
12547
  getNumberValue(
12174
12548
  flagKey: string,
12175
12549
  defaultValue: number,
12176
- context?: EvaluationContext,
12550
+ context?: FlagshipEvaluationContext,
12177
12551
  ): Promise<number>;
12178
12552
  /**
12179
12553
  * Get an object flag value.
@@ -12184,7 +12558,7 @@ export declare abstract class Flags {
12184
12558
  getObjectValue<T extends object>(
12185
12559
  flagKey: string,
12186
12560
  defaultValue: T,
12187
- context?: EvaluationContext,
12561
+ context?: FlagshipEvaluationContext,
12188
12562
  ): Promise<T>;
12189
12563
  /**
12190
12564
  * Get a boolean flag value with full evaluation details.
@@ -12195,8 +12569,8 @@ export declare abstract class Flags {
12195
12569
  getBooleanDetails(
12196
12570
  flagKey: string,
12197
12571
  defaultValue: boolean,
12198
- context?: EvaluationContext,
12199
- ): Promise<EvaluationDetails<boolean>>;
12572
+ context?: FlagshipEvaluationContext,
12573
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12200
12574
  /**
12201
12575
  * Get a string flag value with full evaluation details.
12202
12576
  * @param flagKey The key of the flag to evaluate.
@@ -12206,8 +12580,8 @@ export declare abstract class Flags {
12206
12580
  getStringDetails(
12207
12581
  flagKey: string,
12208
12582
  defaultValue: string,
12209
- context?: EvaluationContext,
12210
- ): Promise<EvaluationDetails<string>>;
12583
+ context?: FlagshipEvaluationContext,
12584
+ ): Promise<FlagshipEvaluationDetails<string>>;
12211
12585
  /**
12212
12586
  * Get a number flag value with full evaluation details.
12213
12587
  * @param flagKey The key of the flag to evaluate.
@@ -12217,8 +12591,8 @@ export declare abstract class Flags {
12217
12591
  getNumberDetails(
12218
12592
  flagKey: string,
12219
12593
  defaultValue: number,
12220
- context?: EvaluationContext,
12221
- ): Promise<EvaluationDetails<number>>;
12594
+ context?: FlagshipEvaluationContext,
12595
+ ): Promise<FlagshipEvaluationDetails<number>>;
12222
12596
  /**
12223
12597
  * Get an object flag value with full evaluation details.
12224
12598
  * @param flagKey The key of the flag to evaluate.
@@ -12228,8 +12602,8 @@ export declare abstract class Flags {
12228
12602
  getObjectDetails<T extends object>(
12229
12603
  flagKey: string,
12230
12604
  defaultValue: T,
12231
- context?: EvaluationContext,
12232
- ): Promise<EvaluationDetails<T>>;
12605
+ context?: FlagshipEvaluationContext,
12606
+ ): Promise<FlagshipEvaluationDetails<T>>;
12233
12607
  }
12234
12608
  /**
12235
12609
  * Hello World binding to serve as an explanatory example. DO NOT USE