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