@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.
@@ -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
  }
@@ -3959,72 +3997,145 @@ export declare abstract class Performance {
3959
3997
  // ============ AI Search Error Interfaces ============
3960
3998
  export interface AiSearchInternalError extends Error {}
3961
3999
  export interface AiSearchNotFoundError extends Error {}
3962
- // ============ AI Search Request Types ============
3963
- export type AiSearchSearchRequest = {
3964
- messages: Array<{
3965
- role: "system" | "developer" | "user" | "assistant" | "tool";
3966
- content: string | null;
3967
- }>;
3968
- ai_search_options?: {
3969
- retrieval?: {
3970
- retrieval_type?: "vector" | "keyword" | "hybrid";
3971
- /** Match threshold (0-1, default 0.4) */
3972
- match_threshold?: number;
3973
- /** Maximum number of results (1-50, default 10) */
3974
- max_num_results?: number;
3975
- filters?: VectorizeVectorMetadataFilter;
3976
- /** Context expansion (0-3, default 0) */
3977
- context_expansion?: number;
3978
- [key: string]: unknown;
3979
- };
3980
- query_rewrite?: {
3981
- enabled?: boolean;
3982
- model?: string;
3983
- rewrite_prompt?: string;
3984
- [key: string]: unknown;
3985
- };
3986
- reranking?: {
3987
- enabled?: boolean;
3988
- model?: "@cf/baai/bge-reranker-base" | string;
3989
- /** Match threshold (0-1, default 0.4) */
3990
- match_threshold?: number;
3991
- [key: string]: unknown;
3992
- };
4000
+ // ============ AI Search Common Types ============
4001
+ /** A single message in a conversation-style search or chat request. */
4002
+ export type AiSearchMessage = {
4003
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4004
+ content: string | null;
4005
+ };
4006
+ /**
4007
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4008
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4009
+ */
4010
+ export type AiSearchOptions = {
4011
+ retrieval?: {
4012
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4013
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4014
+ /** Fusion method for combining vector + keyword results. */
4015
+ fusion_method?: "max" | "rrf";
4016
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4017
+ keyword_match_mode?: "and" | "or";
4018
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4019
+ match_threshold?: number;
4020
+ /** Maximum number of results to return (1-50). Default 10. */
4021
+ max_num_results?: number;
4022
+ /** Vectorize metadata filters applied to the search. */
4023
+ filters?: VectorizeVectorMetadataFilter;
4024
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4025
+ context_expansion?: number;
4026
+ /** If true, return only item metadata without chunk text. */
4027
+ metadata_only?: boolean;
4028
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4029
+ return_on_failure?: boolean;
4030
+ /** Boost results by metadata field values. Max 3 entries. */
4031
+ boost_by?: Array<{
4032
+ field: string;
4033
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4034
+ }>;
4035
+ [key: string]: unknown;
4036
+ };
4037
+ query_rewrite?: {
4038
+ enabled?: boolean;
4039
+ model?: string;
4040
+ rewrite_prompt?: string;
4041
+ [key: string]: unknown;
4042
+ };
4043
+ reranking?: {
4044
+ enabled?: boolean;
4045
+ model?: string;
4046
+ /** Match threshold (0-1, default 0.4) */
4047
+ match_threshold?: number;
3993
4048
  [key: string]: unknown;
3994
4049
  };
4050
+ cache?: {
4051
+ enabled?: boolean;
4052
+ cache_threshold?:
4053
+ | "super_strict_match"
4054
+ | "close_enough"
4055
+ | "flexible_friend"
4056
+ | "anything_goes";
4057
+ };
4058
+ [key: string]: unknown;
3995
4059
  };
4060
+ // ============ AI Search Request Types ============
4061
+ /**
4062
+ * Request body for single-instance search.
4063
+ * Exactly one of `query` or `messages` must be provided.
4064
+ */
4065
+ export type AiSearchSearchRequest =
4066
+ | {
4067
+ /** Simple query string. */
4068
+ query: string;
4069
+ messages?: never;
4070
+ ai_search_options?: AiSearchOptions;
4071
+ }
4072
+ | {
4073
+ query?: never;
4074
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4075
+ messages: AiSearchMessage[];
4076
+ ai_search_options?: AiSearchOptions;
4077
+ };
3996
4078
  export type AiSearchChatCompletionsRequest = {
3997
- messages: Array<{
3998
- role: "system" | "developer" | "user" | "assistant" | "tool";
3999
- content: string | null;
4000
- [key: string]: unknown;
4001
- }>;
4079
+ messages: AiSearchMessage[];
4002
4080
  model?: string;
4003
4081
  stream?: boolean;
4004
- ai_search_options?: {
4005
- retrieval?: {
4006
- retrieval_type?: "vector" | "keyword" | "hybrid";
4007
- match_threshold?: number;
4008
- max_num_results?: number;
4009
- filters?: VectorizeVectorMetadataFilter;
4010
- context_expansion?: number;
4011
- [key: string]: unknown;
4012
- };
4013
- query_rewrite?: {
4014
- enabled?: boolean;
4015
- model?: string;
4016
- rewrite_prompt?: string;
4017
- [key: string]: unknown;
4018
- };
4019
- reranking?: {
4020
- enabled?: boolean;
4021
- model?: "@cf/baai/bge-reranker-base" | string;
4022
- match_threshold?: number;
4023
- [key: string]: unknown;
4082
+ ai_search_options?: AiSearchOptions;
4083
+ [key: string]: unknown;
4084
+ };
4085
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4086
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4087
+ export type AiSearchMultiSearchOptions = AiSearchOptions & {
4088
+ /** Instance IDs to search across (1-10). */
4089
+ instance_ids: string[];
4090
+ };
4091
+ /**
4092
+ * Request for searching across multiple instances within a namespace.
4093
+ * `ai_search_options` is required and must include `instance_ids`.
4094
+ * Exactly one of `query` or `messages` must be provided.
4095
+ */
4096
+ export type AiSearchMultiSearchRequest =
4097
+ | {
4098
+ /** Simple query string. */
4099
+ query: string;
4100
+ messages?: never;
4101
+ ai_search_options: AiSearchMultiSearchOptions;
4102
+ }
4103
+ | {
4104
+ query?: never;
4105
+ /** Conversation-style input. */
4106
+ messages: AiSearchMessage[];
4107
+ ai_search_options: AiSearchMultiSearchOptions;
4024
4108
  };
4025
- [key: string]: unknown;
4109
+ /** A search result chunk tagged with the instance it originated from. */
4110
+ export type AiSearchMultiSearchChunk =
4111
+ AiSearchSearchResponse["chunks"][number] & {
4112
+ instance_id: string;
4026
4113
  };
4027
- [key: string]: unknown;
4114
+ /** Describes a per-instance error during a multi-instance operation. */
4115
+ export type AiSearchMultiSearchError = {
4116
+ instance_id: string;
4117
+ message: string;
4118
+ };
4119
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4120
+ export type AiSearchMultiSearchResponse = {
4121
+ search_query: string;
4122
+ chunks: AiSearchMultiSearchChunk[];
4123
+ errors?: AiSearchMultiSearchError[];
4124
+ };
4125
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4126
+ export type AiSearchMultiChatCompletionsRequest = Omit<
4127
+ AiSearchChatCompletionsRequest,
4128
+ "ai_search_options"
4129
+ > & {
4130
+ ai_search_options: AiSearchMultiSearchOptions;
4131
+ };
4132
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4133
+ export type AiSearchMultiChatCompletionsResponse = Omit<
4134
+ AiSearchChatCompletionsResponse,
4135
+ "chunks"
4136
+ > & {
4137
+ chunks: AiSearchMultiSearchChunk[];
4138
+ errors?: AiSearchMultiSearchError[];
4028
4139
  };
4029
4140
  // ============ AI Search Response Types ============
4030
4141
  export type AiSearchSearchResponse = {
@@ -4045,6 +4156,14 @@ export type AiSearchSearchResponse = {
4045
4156
  keyword_score?: number;
4046
4157
  /** Vector similarity score (0-1) */
4047
4158
  vector_score?: number;
4159
+ /** Keyword rank position */
4160
+ keyword_rank?: number;
4161
+ /** Vector rank position */
4162
+ vector_rank?: number;
4163
+ /** Reranking model score */
4164
+ reranking_score?: number;
4165
+ /** Fusion method used to combine results */
4166
+ fusion_method?: "rrf" | "max";
4048
4167
  [key: string]: unknown;
4049
4168
  };
4050
4169
  }>;
@@ -4073,19 +4192,88 @@ export type AiSearchStatsResponse = {
4073
4192
  skipped?: number;
4074
4193
  outdated?: number;
4075
4194
  last_activity?: string;
4195
+ /** Storage engine statistics. */
4196
+ engine?: {
4197
+ vectorize?: {
4198
+ vectorsCount: number;
4199
+ dimensions: number;
4200
+ };
4201
+ r2?: {
4202
+ payloadSizeBytes: number;
4203
+ metadataSizeBytes: number;
4204
+ objectCount: number;
4205
+ };
4206
+ };
4076
4207
  };
4077
4208
  // ============ AI Search Instance Info Types ============
4078
4209
  export type AiSearchInstanceInfo = {
4079
4210
  id: string;
4080
4211
  type?: "r2" | "web-crawler" | string;
4081
4212
  source?: string;
4213
+ source_params?: unknown;
4082
4214
  paused?: boolean;
4083
4215
  status?: string;
4084
4216
  namespace?: string;
4085
4217
  created_at?: string;
4086
4218
  modified_at?: string;
4219
+ token_id?: string;
4220
+ ai_gateway_id?: string;
4221
+ rewrite_query?: boolean;
4222
+ reranking?: boolean;
4223
+ embedding_model?: string;
4224
+ ai_search_model?: string;
4225
+ rewrite_model?: string;
4226
+ reranking_model?: string;
4227
+ /** @deprecated Use index_method instead. */
4228
+ hybrid_search_enabled?: boolean;
4229
+ /** Controls which storage backends are active. */
4230
+ index_method?: {
4231
+ vector?: boolean;
4232
+ keyword?: boolean;
4233
+ };
4234
+ /** Fusion method for combining vector and keyword results. */
4235
+ fusion_method?: "max" | "rrf";
4236
+ indexing_options?: {
4237
+ keyword_tokenizer?: "porter" | "trigram";
4238
+ } | null;
4239
+ retrieval_options?: {
4240
+ keyword_match_mode?: "and" | "or";
4241
+ boost_by?: Array<{
4242
+ field: string;
4243
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4244
+ }>;
4245
+ } | null;
4246
+ chunk?: boolean;
4247
+ chunk_size?: number;
4248
+ chunk_overlap?: number;
4249
+ score_threshold?: number;
4250
+ max_num_results?: number;
4251
+ cache?: boolean;
4252
+ cache_threshold?:
4253
+ | "super_strict_match"
4254
+ | "close_enough"
4255
+ | "flexible_friend"
4256
+ | "anything_goes";
4257
+ custom_metadata?: Array<{
4258
+ field_name: string;
4259
+ data_type: "text" | "number" | "boolean" | "datetime";
4260
+ }>;
4261
+ /** Sync interval in seconds. */
4262
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4263
+ metadata?: Record<string, unknown>;
4087
4264
  [key: string]: unknown;
4088
4265
  };
4266
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4267
+ export type AiSearchListInstancesParams = {
4268
+ page?: number;
4269
+ per_page?: number;
4270
+ /** Search instances by ID. */
4271
+ search?: string;
4272
+ /** Field to sort by. */
4273
+ order_by?: "created_at";
4274
+ /** Sort direction. */
4275
+ order_by_direction?: "asc" | "desc";
4276
+ };
4089
4277
  export type AiSearchListResponse = {
4090
4278
  result: AiSearchInstanceInfo[];
4091
4279
  result_info?: {
@@ -4113,19 +4301,64 @@ export type AiSearchConfig = {
4113
4301
  reranking?: boolean;
4114
4302
  embedding_model?: string;
4115
4303
  ai_search_model?: string;
4304
+ rewrite_model?: string;
4305
+ reranking_model?: string;
4306
+ /** @deprecated Use index_method instead. */
4307
+ hybrid_search_enabled?: boolean;
4308
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4309
+ index_method?: {
4310
+ vector?: boolean;
4311
+ keyword?: boolean;
4312
+ };
4313
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4314
+ fusion_method?: "max" | "rrf";
4315
+ indexing_options?: {
4316
+ keyword_tokenizer?: "porter" | "trigram";
4317
+ } | null;
4318
+ retrieval_options?: {
4319
+ keyword_match_mode?: "and" | "or";
4320
+ boost_by?: Array<{
4321
+ field: string;
4322
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4323
+ }>;
4324
+ } | null;
4325
+ chunk?: boolean;
4326
+ chunk_size?: number;
4327
+ chunk_overlap?: number;
4328
+ /** Minimum similarity score (0-1) for a result to be included. */
4329
+ score_threshold?: number;
4330
+ max_num_results?: number;
4331
+ cache?: boolean;
4332
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4333
+ cache_threshold?:
4334
+ | "super_strict_match"
4335
+ | "close_enough"
4336
+ | "flexible_friend"
4337
+ | "anything_goes";
4338
+ custom_metadata?: Array<{
4339
+ field_name: string;
4340
+ data_type: "text" | "number" | "boolean" | "datetime";
4341
+ }>;
4342
+ namespace?: string;
4343
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4344
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4345
+ metadata?: Record<string, unknown>;
4116
4346
  [key: string]: unknown;
4117
4347
  };
4118
4348
  // ============ AI Search Item Types ============
4119
4349
  export type AiSearchItemInfo = {
4120
4350
  id: string;
4121
4351
  key: string;
4122
- status:
4123
- | "completed"
4124
- | "error"
4125
- | "skipped"
4126
- | "queued"
4127
- | "processing"
4128
- | "outdated";
4352
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4353
+ next_action?: "INDEX" | "DELETE" | null;
4354
+ error?: string;
4355
+ checksum?: string;
4356
+ namespace?: string;
4357
+ chunks_count?: number | null;
4358
+ file_size?: number | null;
4359
+ source_id?: string | null;
4360
+ last_seen_at?: string;
4361
+ created_at?: string;
4129
4362
  metadata?: Record<string, unknown>;
4130
4363
  [key: string]: unknown;
4131
4364
  };
@@ -4141,6 +4374,22 @@ export type AiSearchUploadItemOptions = {
4141
4374
  export type AiSearchListItemsParams = {
4142
4375
  page?: number;
4143
4376
  per_page?: number;
4377
+ /** Search items by key name. */
4378
+ search?: string;
4379
+ /** Sort order for results. */
4380
+ sort_by?: "status" | "modified_at";
4381
+ /** Filter items by processing status. */
4382
+ status?:
4383
+ | "queued"
4384
+ | "running"
4385
+ | "completed"
4386
+ | "error"
4387
+ | "skipped"
4388
+ | "outdated";
4389
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4390
+ source?: string;
4391
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4392
+ metadata_filter?: string;
4144
4393
  };
4145
4394
  export type AiSearchListItemsResponse = {
4146
4395
  result: AiSearchItemInfo[];
@@ -4151,6 +4400,61 @@ export type AiSearchListItemsResponse = {
4151
4400
  total_count: number;
4152
4401
  };
4153
4402
  };
4403
+ // ============ AI Search Item Logs Types ============
4404
+ export type AiSearchItemLogsParams = {
4405
+ /** Maximum number of log entries to return (1-100, default 50). */
4406
+ limit?: number;
4407
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4408
+ cursor?: string;
4409
+ };
4410
+ export type AiSearchItemLog = {
4411
+ timestamp: string;
4412
+ action: string;
4413
+ message: string;
4414
+ fileKey?: string;
4415
+ chunkCount?: number;
4416
+ processingTimeMs?: number;
4417
+ errorType?: string;
4418
+ };
4419
+ /** Paginated response for item processing logs (cursor-based). */
4420
+ export type AiSearchItemLogsResponse = {
4421
+ result: AiSearchItemLog[];
4422
+ result_info: {
4423
+ count: number;
4424
+ per_page: number;
4425
+ cursor: string | null;
4426
+ truncated: boolean;
4427
+ };
4428
+ };
4429
+ // ============ AI Search Item Chunks Types ============
4430
+ export type AiSearchItemChunksParams = {
4431
+ /** Maximum number of chunks to return (1-100, default 20). */
4432
+ limit?: number;
4433
+ /** Offset into the chunks list (default 0). */
4434
+ offset?: number;
4435
+ };
4436
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4437
+ export type AiSearchItemChunk = {
4438
+ id: string;
4439
+ text: string;
4440
+ start_byte: number;
4441
+ end_byte: number;
4442
+ item?: {
4443
+ timestamp?: number;
4444
+ key: string;
4445
+ metadata?: Record<string, unknown>;
4446
+ };
4447
+ };
4448
+ /** Paginated response for item chunks (offset-based). */
4449
+ export type AiSearchItemChunksResponse = {
4450
+ result: AiSearchItemChunk[];
4451
+ result_info: {
4452
+ count: number;
4453
+ total: number;
4454
+ limit: number;
4455
+ offset: number;
4456
+ };
4457
+ };
4154
4458
  // ============ AI Search Job Types ============
4155
4459
  export type AiSearchJobInfo = {
4156
4460
  id: string;
@@ -4199,7 +4503,7 @@ export type AiSearchJobLogsResponse = {
4199
4503
  // ============ AI Search Sub-Service Classes ============
4200
4504
  /**
4201
4505
  * Single item service for an AI Search instance.
4202
- * Provides info, delete, and download operations on a specific item.
4506
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4203
4507
  */
4204
4508
  export declare abstract class AiSearchItem {
4205
4509
  /** Get metadata about this item. */
@@ -4209,6 +4513,25 @@ export declare abstract class AiSearchItem {
4209
4513
  * @returns Object with body stream, content type, filename, and size.
4210
4514
  */
4211
4515
  download(): Promise<AiSearchItemContentResult>;
4516
+ /**
4517
+ * Trigger re-indexing of this item.
4518
+ * @returns The updated item info.
4519
+ */
4520
+ sync(): Promise<AiSearchItemInfo>;
4521
+ /**
4522
+ * Retrieve processing logs for this item (cursor-based pagination).
4523
+ * @param params Optional pagination parameters (limit, cursor).
4524
+ * @returns Paginated log entries for this item.
4525
+ */
4526
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4527
+ /**
4528
+ * List indexed chunks for this item (offset-based pagination).
4529
+ * @param params Optional pagination parameters (limit, offset).
4530
+ * @returns Paginated chunk entries for this item.
4531
+ */
4532
+ chunks(
4533
+ params?: AiSearchItemChunksParams,
4534
+ ): Promise<AiSearchItemChunksResponse>;
4212
4535
  }
4213
4536
  /**
4214
4537
  * Items collection service for an AI Search instance.
@@ -4218,49 +4541,64 @@ export declare abstract class AiSearchItems {
4218
4541
  /** List items in this instance. */
4219
4542
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4220
4543
  /**
4221
- * Upload a file as an item.
4544
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4545
+ * filename already exists, it is overwritten and re-indexed.
4222
4546
  * @param name Filename for the uploaded item.
4223
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4547
+ * @param content File content as a ReadableStream, Blob, or string.
4224
4548
  * @param options Optional metadata to attach to the item.
4225
4549
  * @returns The created item info.
4226
4550
  */
4227
4551
  upload(
4228
4552
  name: string,
4229
- content: ReadableStream | ArrayBuffer | string,
4553
+ content: ReadableStream | Blob | string,
4230
4554
  options?: AiSearchUploadItemOptions,
4231
4555
  ): Promise<AiSearchItemInfo>;
4232
4556
  /**
4233
4557
  * Upload a file and poll until processing completes.
4558
+ * Behaves as an upsert: if an item with the same filename already exists,
4559
+ * it is overwritten and re-indexed.
4234
4560
  * @param name Filename for the uploaded item.
4235
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4236
- * @param options Optional metadata to attach to the item.
4561
+ * @param content File content as a ReadableStream, Blob, or string.
4562
+ * @param options Optional metadata and polling configuration.
4237
4563
  * @returns The item info after processing completes (or timeout).
4238
4564
  */
4239
4565
  uploadAndPoll(
4240
4566
  name: string,
4241
- content: ReadableStream | ArrayBuffer | string,
4242
- options?: AiSearchUploadItemOptions,
4567
+ content: ReadableStream | Blob | string,
4568
+ options?: AiSearchUploadItemOptions & {
4569
+ /** Polling interval in milliseconds (default 1000). */
4570
+ pollIntervalMs?: number;
4571
+ /** Maximum time to wait in milliseconds (default 30000). */
4572
+ timeoutMs?: number;
4573
+ },
4243
4574
  ): Promise<AiSearchItemInfo>;
4244
4575
  /**
4245
4576
  * Get an item by ID.
4246
4577
  * @param itemId The item identifier.
4247
- * @returns Item service for info, delete, and download operations.
4578
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4248
4579
  */
4249
4580
  get(itemId: string): AiSearchItem;
4250
- /** Delete this item from the instance.
4581
+ /**
4582
+ * Delete an item from the instance.
4251
4583
  * @param itemId The item identifier.
4252
4584
  */
4253
4585
  delete(itemId: string): Promise<void>;
4254
4586
  }
4255
4587
  /**
4256
4588
  * Single job service for an AI Search instance.
4257
- * Provides info and logs for a specific job.
4589
+ * Provides info, logs, and cancel operations for a specific job.
4258
4590
  */
4259
4591
  export declare abstract class AiSearchJob {
4260
4592
  /** Get metadata about this job. */
4261
4593
  info(): Promise<AiSearchJobInfo>;
4262
4594
  /** Get logs for this job. */
4263
4595
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4596
+ /**
4597
+ * Cancel a running job.
4598
+ * @returns The updated job info.
4599
+ * @throws AiSearchNotFoundError if the job does not exist.
4600
+ */
4601
+ cancel(): Promise<AiSearchJobInfo>;
4264
4602
  }
4265
4603
  /**
4266
4604
  * Jobs collection service for an AI Search instance.
@@ -4278,7 +4616,7 @@ export declare abstract class AiSearchJobs {
4278
4616
  /**
4279
4617
  * Get a job by ID.
4280
4618
  * @param jobId The job identifier.
4281
- * @returns Job service for info and logs operations.
4619
+ * @returns Job service for info, logs, and cancel operations.
4282
4620
  */
4283
4621
  get(jobId: string): AiSearchJob;
4284
4622
  }
@@ -4297,7 +4635,7 @@ export declare abstract class AiSearchJobs {
4297
4635
  * // Via namespace binding
4298
4636
  * const instance = env.AI_SEARCH.get("blog");
4299
4637
  * const results = await instance.search({
4300
- * messages: [{ role: "user", content: "How does caching work?" }],
4638
+ * query: "How does caching work?",
4301
4639
  * });
4302
4640
  *
4303
4641
  * // Via single instance binding
@@ -4309,7 +4647,7 @@ export declare abstract class AiSearchJobs {
4309
4647
  export declare abstract class AiSearchInstance {
4310
4648
  /**
4311
4649
  * Search the AI Search instance for relevant chunks.
4312
- * @param params Search request with messages and optional AI search options.
4650
+ * @param params Search request with query or messages and optional AI search options.
4313
4651
  * @returns Search response with matching chunks and search query.
4314
4652
  */
4315
4653
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4341,7 +4679,7 @@ export declare abstract class AiSearchInstance {
4341
4679
  info(): Promise<AiSearchInstanceInfo>;
4342
4680
  /**
4343
4681
  * Get instance statistics (item count, indexing status, etc.).
4344
- * @returns Statistics with counts per status and last activity time.
4682
+ * @returns Statistics with counts per status, last activity time, and engine details.
4345
4683
  */
4346
4684
  stats(): Promise<AiSearchStatsResponse>;
4347
4685
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4353,27 +4691,30 @@ export declare abstract class AiSearchInstance {
4353
4691
  * Namespace-level AI Search service.
4354
4692
  *
4355
4693
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4356
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4694
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4695
+ * and multi-instance search/chat operations.
4357
4696
  *
4358
4697
  * @example
4359
4698
  * ```ts
4360
4699
  * // Access an instance within the namespace
4361
4700
  * const blog = env.AI_SEARCH.get("blog");
4362
- * const results = await blog.search({
4363
- * messages: [{ role: "user", content: "How does caching work?" }],
4364
- * });
4701
+ * const results = await blog.search({ query: "How does caching work?" });
4365
4702
  *
4366
4703
  * // List all instances in the namespace
4367
4704
  * const instances = await env.AI_SEARCH.list();
4368
4705
  *
4369
4706
  * // Create a new instance with built-in storage
4370
- * const tenant = await env.AI_SEARCH.create({
4371
- * id: "tenant-123",
4372
- * });
4707
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4373
4708
  *
4374
4709
  * // Upload items into the instance
4375
4710
  * await tenant.items.upload("doc.pdf", fileContent);
4376
4711
  *
4712
+ * // Search across multiple instances
4713
+ * const multi = await env.AI_SEARCH.search({
4714
+ * query: "caching",
4715
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4716
+ * });
4717
+ *
4377
4718
  * // Delete an instance
4378
4719
  * await env.AI_SEARCH.delete("tenant-123");
4379
4720
  * ```
@@ -4386,10 +4727,11 @@ export declare abstract class AiSearchNamespace {
4386
4727
  */
4387
4728
  get(name: string): AiSearchInstance;
4388
4729
  /**
4389
- * List all instances in the bound namespace.
4390
- * @returns Array of instance metadata.
4730
+ * List instances in the bound namespace.
4731
+ * @param params Optional pagination, search, and ordering parameters.
4732
+ * @returns Array of instance metadata with pagination info.
4391
4733
  */
4392
- list(): Promise<AiSearchListResponse>;
4734
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4393
4735
  /**
4394
4736
  * Create a new instance within the bound namespace.
4395
4737
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4414,6 +4756,35 @@ export declare abstract class AiSearchNamespace {
4414
4756
  * @param name Instance name to delete.
4415
4757
  */
4416
4758
  delete(name: string): Promise<void>;
4759
+ /**
4760
+ * Search across multiple instances within the bound namespace.
4761
+ * Fans out to the specified instance_ids and merges results.
4762
+ * @param params Search request with required `ai_search_options.instance_ids`.
4763
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4764
+ */
4765
+ search(
4766
+ params: AiSearchMultiSearchRequest,
4767
+ ): Promise<AiSearchMultiSearchResponse>;
4768
+ /**
4769
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4770
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4771
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4772
+ * @returns ReadableStream of server-sent events.
4773
+ */
4774
+ chatCompletions(
4775
+ params: AiSearchMultiChatCompletionsRequest & {
4776
+ stream: true;
4777
+ },
4778
+ ): Promise<ReadableStream>;
4779
+ /**
4780
+ * Generate chat completions across multiple instances within the bound namespace.
4781
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4782
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4783
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4784
+ */
4785
+ chatCompletions(
4786
+ params: AiSearchMultiChatCompletionsRequest,
4787
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4417
4788
  }
4418
4789
  export type AiImageClassificationInput = {
4419
4790
  image: number[];
@@ -12075,8 +12446,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12075
12446
  * Evaluation context for targeting rules.
12076
12447
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12077
12448
  */
12078
- export type EvaluationContext = Record<string, string | number | boolean>;
12079
- export interface EvaluationDetails<T> {
12449
+ export type FlagshipEvaluationContext = Record<
12450
+ string,
12451
+ string | number | boolean
12452
+ >;
12453
+ export interface FlagshipEvaluationDetails<T> {
12080
12454
  flagKey: string;
12081
12455
  value: T;
12082
12456
  variant?: string | undefined;
@@ -12084,7 +12458,7 @@ export interface EvaluationDetails<T> {
12084
12458
  errorCode?: string | undefined;
12085
12459
  errorMessage?: string | undefined;
12086
12460
  }
12087
- export interface FlagEvaluationError extends Error {}
12461
+ export interface FlagshipEvaluationError extends Error {}
12088
12462
  /**
12089
12463
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12090
12464
  *
@@ -12104,7 +12478,7 @@ export interface FlagEvaluationError extends Error {}
12104
12478
  * console.log(details.variant, details.reason);
12105
12479
  * ```
12106
12480
  */
12107
- export declare abstract class Flags {
12481
+ export declare abstract class Flagship {
12108
12482
  /**
12109
12483
  * Get a flag value without type checking.
12110
12484
  * @param flagKey The key of the flag to evaluate.
@@ -12114,7 +12488,7 @@ export declare abstract class Flags {
12114
12488
  get(
12115
12489
  flagKey: string,
12116
12490
  defaultValue?: unknown,
12117
- context?: EvaluationContext,
12491
+ context?: FlagshipEvaluationContext,
12118
12492
  ): Promise<unknown>;
12119
12493
  /**
12120
12494
  * Get a boolean flag value.
@@ -12125,7 +12499,7 @@ export declare abstract class Flags {
12125
12499
  getBooleanValue(
12126
12500
  flagKey: string,
12127
12501
  defaultValue: boolean,
12128
- context?: EvaluationContext,
12502
+ context?: FlagshipEvaluationContext,
12129
12503
  ): Promise<boolean>;
12130
12504
  /**
12131
12505
  * Get a string flag value.
@@ -12136,7 +12510,7 @@ export declare abstract class Flags {
12136
12510
  getStringValue(
12137
12511
  flagKey: string,
12138
12512
  defaultValue: string,
12139
- context?: EvaluationContext,
12513
+ context?: FlagshipEvaluationContext,
12140
12514
  ): Promise<string>;
12141
12515
  /**
12142
12516
  * Get a number flag value.
@@ -12147,7 +12521,7 @@ export declare abstract class Flags {
12147
12521
  getNumberValue(
12148
12522
  flagKey: string,
12149
12523
  defaultValue: number,
12150
- context?: EvaluationContext,
12524
+ context?: FlagshipEvaluationContext,
12151
12525
  ): Promise<number>;
12152
12526
  /**
12153
12527
  * Get an object flag value.
@@ -12158,7 +12532,7 @@ export declare abstract class Flags {
12158
12532
  getObjectValue<T extends object>(
12159
12533
  flagKey: string,
12160
12534
  defaultValue: T,
12161
- context?: EvaluationContext,
12535
+ context?: FlagshipEvaluationContext,
12162
12536
  ): Promise<T>;
12163
12537
  /**
12164
12538
  * Get a boolean flag value with full evaluation details.
@@ -12169,8 +12543,8 @@ export declare abstract class Flags {
12169
12543
  getBooleanDetails(
12170
12544
  flagKey: string,
12171
12545
  defaultValue: boolean,
12172
- context?: EvaluationContext,
12173
- ): Promise<EvaluationDetails<boolean>>;
12546
+ context?: FlagshipEvaluationContext,
12547
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12174
12548
  /**
12175
12549
  * Get a string flag value with full evaluation details.
12176
12550
  * @param flagKey The key of the flag to evaluate.
@@ -12180,8 +12554,8 @@ export declare abstract class Flags {
12180
12554
  getStringDetails(
12181
12555
  flagKey: string,
12182
12556
  defaultValue: string,
12183
- context?: EvaluationContext,
12184
- ): Promise<EvaluationDetails<string>>;
12557
+ context?: FlagshipEvaluationContext,
12558
+ ): Promise<FlagshipEvaluationDetails<string>>;
12185
12559
  /**
12186
12560
  * Get a number flag value with full evaluation details.
12187
12561
  * @param flagKey The key of the flag to evaluate.
@@ -12191,8 +12565,8 @@ export declare abstract class Flags {
12191
12565
  getNumberDetails(
12192
12566
  flagKey: string,
12193
12567
  defaultValue: number,
12194
- context?: EvaluationContext,
12195
- ): Promise<EvaluationDetails<number>>;
12568
+ context?: FlagshipEvaluationContext,
12569
+ ): Promise<FlagshipEvaluationDetails<number>>;
12196
12570
  /**
12197
12571
  * Get an object flag value with full evaluation details.
12198
12572
  * @param flagKey The key of the flag to evaluate.
@@ -12202,8 +12576,8 @@ export declare abstract class Flags {
12202
12576
  getObjectDetails<T extends object>(
12203
12577
  flagKey: string,
12204
12578
  defaultValue: T,
12205
- context?: EvaluationContext,
12206
- ): Promise<EvaluationDetails<T>>;
12579
+ context?: FlagshipEvaluationContext,
12580
+ ): Promise<FlagshipEvaluationDetails<T>>;
12207
12581
  }
12208
12582
  /**
12209
12583
  * Hello World binding to serve as an explanatory example. DO NOT USE