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