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