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