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