@cloudflare/workers-types 4.20260415.1 → 4.20260416.2

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