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