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