@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.
package/latest/index.ts CHANGED
@@ -554,6 +554,7 @@ export declare abstract class Navigator {
554
554
  sendBeacon(url: string, body?: BodyInit): boolean;
555
555
  readonly userAgent: string;
556
556
  readonly hardwareConcurrency: number;
557
+ readonly platform: string;
557
558
  readonly language: string;
558
559
  readonly languages: string[];
559
560
  }
@@ -2345,11 +2346,34 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2345
2346
  }
2346
2347
  export type QueueContentType = "text" | "bytes" | "json" | "v8";
2347
2348
  export interface Queue<Body = unknown> {
2348
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2349
+ metrics(): Promise<QueueMetrics>;
2350
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2349
2351
  sendBatch(
2350
2352
  messages: Iterable<MessageSendRequest<Body>>,
2351
2353
  options?: QueueSendBatchOptions,
2352
- ): Promise<void>;
2354
+ ): Promise<QueueSendBatchResponse>;
2355
+ }
2356
+ export interface QueueSendMetrics {
2357
+ backlogCount: number;
2358
+ backlogBytes: number;
2359
+ oldestMessageTimestamp?: Date;
2360
+ }
2361
+ export interface QueueSendMetadata {
2362
+ metrics: QueueSendMetrics;
2363
+ }
2364
+ export interface QueueSendResponse {
2365
+ metadata: QueueSendMetadata;
2366
+ }
2367
+ export interface QueueSendBatchMetrics {
2368
+ backlogCount: number;
2369
+ backlogBytes: number;
2370
+ oldestMessageTimestamp?: Date;
2371
+ }
2372
+ export interface QueueSendBatchMetadata {
2373
+ metrics: QueueSendBatchMetrics;
2374
+ }
2375
+ export interface QueueSendBatchResponse {
2376
+ metadata: QueueSendBatchMetadata;
2353
2377
  }
2354
2378
  export interface QueueSendOptions {
2355
2379
  contentType?: QueueContentType;
@@ -2363,6 +2387,19 @@ export interface MessageSendRequest<Body = unknown> {
2363
2387
  contentType?: QueueContentType;
2364
2388
  delaySeconds?: number;
2365
2389
  }
2390
+ export interface QueueMetrics {
2391
+ backlogCount: number;
2392
+ backlogBytes: number;
2393
+ oldestMessageTimestamp?: Date;
2394
+ }
2395
+ export interface MessageBatchMetrics {
2396
+ backlogCount: number;
2397
+ backlogBytes: number;
2398
+ oldestMessageTimestamp?: Date;
2399
+ }
2400
+ export interface MessageBatchMetadata {
2401
+ metrics: MessageBatchMetrics;
2402
+ }
2366
2403
  export interface QueueRetryOptions {
2367
2404
  delaySeconds?: number;
2368
2405
  }
@@ -2377,12 +2414,14 @@ export interface Message<Body = unknown> {
2377
2414
  export interface QueueEvent<Body = unknown> extends ExtendableEvent {
2378
2415
  readonly messages: readonly Message<Body>[];
2379
2416
  readonly queue: string;
2417
+ readonly metadata: MessageBatchMetadata;
2380
2418
  retryAll(options?: QueueRetryOptions): void;
2381
2419
  ackAll(): void;
2382
2420
  }
2383
2421
  export interface MessageBatch<Body = unknown> {
2384
2422
  readonly messages: readonly Message<Body>[];
2385
2423
  readonly queue: string;
2424
+ readonly metadata: MessageBatchMetadata;
2386
2425
  retryAll(options?: QueueRetryOptions): void;
2387
2426
  ackAll(): void;
2388
2427
  }
@@ -4024,72 +4063,145 @@ export declare abstract class Performance {
4024
4063
  // ============ AI Search Error Interfaces ============
4025
4064
  export interface AiSearchInternalError extends Error {}
4026
4065
  export interface AiSearchNotFoundError extends Error {}
4027
- // ============ AI Search Request Types ============
4028
- export type AiSearchSearchRequest = {
4029
- messages: Array<{
4030
- role: "system" | "developer" | "user" | "assistant" | "tool";
4031
- content: string | null;
4032
- }>;
4033
- ai_search_options?: {
4034
- retrieval?: {
4035
- retrieval_type?: "vector" | "keyword" | "hybrid";
4036
- /** Match threshold (0-1, default 0.4) */
4037
- match_threshold?: number;
4038
- /** Maximum number of results (1-50, default 10) */
4039
- max_num_results?: number;
4040
- filters?: VectorizeVectorMetadataFilter;
4041
- /** Context expansion (0-3, default 0) */
4042
- context_expansion?: number;
4043
- [key: string]: unknown;
4044
- };
4045
- query_rewrite?: {
4046
- enabled?: boolean;
4047
- model?: string;
4048
- rewrite_prompt?: string;
4049
- [key: string]: unknown;
4050
- };
4051
- reranking?: {
4052
- enabled?: boolean;
4053
- model?: "@cf/baai/bge-reranker-base" | string;
4054
- /** Match threshold (0-1, default 0.4) */
4055
- match_threshold?: number;
4056
- [key: string]: unknown;
4057
- };
4066
+ // ============ AI Search Common Types ============
4067
+ /** A single message in a conversation-style search or chat request. */
4068
+ export type AiSearchMessage = {
4069
+ role: "system" | "developer" | "user" | "assistant" | "tool";
4070
+ content: string | null;
4071
+ };
4072
+ /**
4073
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4074
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
4075
+ */
4076
+ export type AiSearchOptions = {
4077
+ retrieval?: {
4078
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4079
+ retrieval_type?: "vector" | "keyword" | "hybrid";
4080
+ /** Fusion method for combining vector + keyword results. */
4081
+ fusion_method?: "max" | "rrf";
4082
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4083
+ keyword_match_mode?: "and" | "or";
4084
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4085
+ match_threshold?: number;
4086
+ /** Maximum number of results to return (1-50). Default 10. */
4087
+ max_num_results?: number;
4088
+ /** Vectorize metadata filters applied to the search. */
4089
+ filters?: VectorizeVectorMetadataFilter;
4090
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
4091
+ context_expansion?: number;
4092
+ /** If true, return only item metadata without chunk text. */
4093
+ metadata_only?: boolean;
4094
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
4095
+ return_on_failure?: boolean;
4096
+ /** Boost results by metadata field values. Max 3 entries. */
4097
+ boost_by?: Array<{
4098
+ field: string;
4099
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4100
+ }>;
4101
+ [key: string]: unknown;
4102
+ };
4103
+ query_rewrite?: {
4104
+ enabled?: boolean;
4105
+ model?: string;
4106
+ rewrite_prompt?: string;
4107
+ [key: string]: unknown;
4108
+ };
4109
+ reranking?: {
4110
+ enabled?: boolean;
4111
+ model?: string;
4112
+ /** Match threshold (0-1, default 0.4) */
4113
+ match_threshold?: number;
4058
4114
  [key: string]: unknown;
4059
4115
  };
4116
+ cache?: {
4117
+ enabled?: boolean;
4118
+ cache_threshold?:
4119
+ | "super_strict_match"
4120
+ | "close_enough"
4121
+ | "flexible_friend"
4122
+ | "anything_goes";
4123
+ };
4124
+ [key: string]: unknown;
4060
4125
  };
4126
+ // ============ AI Search Request Types ============
4127
+ /**
4128
+ * Request body for single-instance search.
4129
+ * Exactly one of `query` or `messages` must be provided.
4130
+ */
4131
+ export type AiSearchSearchRequest =
4132
+ | {
4133
+ /** Simple query string. */
4134
+ query: string;
4135
+ messages?: never;
4136
+ ai_search_options?: AiSearchOptions;
4137
+ }
4138
+ | {
4139
+ query?: never;
4140
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4141
+ messages: AiSearchMessage[];
4142
+ ai_search_options?: AiSearchOptions;
4143
+ };
4061
4144
  export type AiSearchChatCompletionsRequest = {
4062
- messages: Array<{
4063
- role: "system" | "developer" | "user" | "assistant" | "tool";
4064
- content: string | null;
4065
- [key: string]: unknown;
4066
- }>;
4145
+ messages: AiSearchMessage[];
4067
4146
  model?: string;
4068
4147
  stream?: boolean;
4069
- ai_search_options?: {
4070
- retrieval?: {
4071
- retrieval_type?: "vector" | "keyword" | "hybrid";
4072
- match_threshold?: number;
4073
- max_num_results?: number;
4074
- filters?: VectorizeVectorMetadataFilter;
4075
- context_expansion?: number;
4076
- [key: string]: unknown;
4077
- };
4078
- query_rewrite?: {
4079
- enabled?: boolean;
4080
- model?: string;
4081
- rewrite_prompt?: string;
4082
- [key: string]: unknown;
4083
- };
4084
- reranking?: {
4085
- enabled?: boolean;
4086
- model?: "@cf/baai/bge-reranker-base" | string;
4087
- match_threshold?: number;
4088
- [key: string]: unknown;
4148
+ ai_search_options?: AiSearchOptions;
4149
+ [key: string]: unknown;
4150
+ };
4151
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4152
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4153
+ export type AiSearchMultiSearchOptions = AiSearchOptions & {
4154
+ /** Instance IDs to search across (1-10). */
4155
+ instance_ids: string[];
4156
+ };
4157
+ /**
4158
+ * Request for searching across multiple instances within a namespace.
4159
+ * `ai_search_options` is required and must include `instance_ids`.
4160
+ * Exactly one of `query` or `messages` must be provided.
4161
+ */
4162
+ export type AiSearchMultiSearchRequest =
4163
+ | {
4164
+ /** Simple query string. */
4165
+ query: string;
4166
+ messages?: never;
4167
+ ai_search_options: AiSearchMultiSearchOptions;
4168
+ }
4169
+ | {
4170
+ query?: never;
4171
+ /** Conversation-style input. */
4172
+ messages: AiSearchMessage[];
4173
+ ai_search_options: AiSearchMultiSearchOptions;
4089
4174
  };
4090
- [key: string]: unknown;
4175
+ /** A search result chunk tagged with the instance it originated from. */
4176
+ export type AiSearchMultiSearchChunk =
4177
+ AiSearchSearchResponse["chunks"][number] & {
4178
+ instance_id: string;
4091
4179
  };
4092
- [key: string]: unknown;
4180
+ /** Describes a per-instance error during a multi-instance operation. */
4181
+ export type AiSearchMultiSearchError = {
4182
+ instance_id: string;
4183
+ message: string;
4184
+ };
4185
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4186
+ export type AiSearchMultiSearchResponse = {
4187
+ search_query: string;
4188
+ chunks: AiSearchMultiSearchChunk[];
4189
+ errors?: AiSearchMultiSearchError[];
4190
+ };
4191
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4192
+ export type AiSearchMultiChatCompletionsRequest = Omit<
4193
+ AiSearchChatCompletionsRequest,
4194
+ "ai_search_options"
4195
+ > & {
4196
+ ai_search_options: AiSearchMultiSearchOptions;
4197
+ };
4198
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4199
+ export type AiSearchMultiChatCompletionsResponse = Omit<
4200
+ AiSearchChatCompletionsResponse,
4201
+ "chunks"
4202
+ > & {
4203
+ chunks: AiSearchMultiSearchChunk[];
4204
+ errors?: AiSearchMultiSearchError[];
4093
4205
  };
4094
4206
  // ============ AI Search Response Types ============
4095
4207
  export type AiSearchSearchResponse = {
@@ -4110,6 +4222,14 @@ export type AiSearchSearchResponse = {
4110
4222
  keyword_score?: number;
4111
4223
  /** Vector similarity score (0-1) */
4112
4224
  vector_score?: number;
4225
+ /** Keyword rank position */
4226
+ keyword_rank?: number;
4227
+ /** Vector rank position */
4228
+ vector_rank?: number;
4229
+ /** Reranking model score */
4230
+ reranking_score?: number;
4231
+ /** Fusion method used to combine results */
4232
+ fusion_method?: "rrf" | "max";
4113
4233
  [key: string]: unknown;
4114
4234
  };
4115
4235
  }>;
@@ -4138,19 +4258,88 @@ export type AiSearchStatsResponse = {
4138
4258
  skipped?: number;
4139
4259
  outdated?: number;
4140
4260
  last_activity?: string;
4261
+ /** Storage engine statistics. */
4262
+ engine?: {
4263
+ vectorize?: {
4264
+ vectorsCount: number;
4265
+ dimensions: number;
4266
+ };
4267
+ r2?: {
4268
+ payloadSizeBytes: number;
4269
+ metadataSizeBytes: number;
4270
+ objectCount: number;
4271
+ };
4272
+ };
4141
4273
  };
4142
4274
  // ============ AI Search Instance Info Types ============
4143
4275
  export type AiSearchInstanceInfo = {
4144
4276
  id: string;
4145
4277
  type?: "r2" | "web-crawler" | string;
4146
4278
  source?: string;
4279
+ source_params?: unknown;
4147
4280
  paused?: boolean;
4148
4281
  status?: string;
4149
4282
  namespace?: string;
4150
4283
  created_at?: string;
4151
4284
  modified_at?: string;
4285
+ token_id?: string;
4286
+ ai_gateway_id?: string;
4287
+ rewrite_query?: boolean;
4288
+ reranking?: boolean;
4289
+ embedding_model?: string;
4290
+ ai_search_model?: string;
4291
+ rewrite_model?: string;
4292
+ reranking_model?: string;
4293
+ /** @deprecated Use index_method instead. */
4294
+ hybrid_search_enabled?: boolean;
4295
+ /** Controls which storage backends are active. */
4296
+ index_method?: {
4297
+ vector?: boolean;
4298
+ keyword?: boolean;
4299
+ };
4300
+ /** Fusion method for combining vector and keyword results. */
4301
+ fusion_method?: "max" | "rrf";
4302
+ indexing_options?: {
4303
+ keyword_tokenizer?: "porter" | "trigram";
4304
+ } | null;
4305
+ retrieval_options?: {
4306
+ keyword_match_mode?: "and" | "or";
4307
+ boost_by?: Array<{
4308
+ field: string;
4309
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4310
+ }>;
4311
+ } | null;
4312
+ chunk?: boolean;
4313
+ chunk_size?: number;
4314
+ chunk_overlap?: number;
4315
+ score_threshold?: number;
4316
+ max_num_results?: number;
4317
+ cache?: boolean;
4318
+ cache_threshold?:
4319
+ | "super_strict_match"
4320
+ | "close_enough"
4321
+ | "flexible_friend"
4322
+ | "anything_goes";
4323
+ custom_metadata?: Array<{
4324
+ field_name: string;
4325
+ data_type: "text" | "number" | "boolean" | "datetime";
4326
+ }>;
4327
+ /** Sync interval in seconds. */
4328
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4329
+ metadata?: Record<string, unknown>;
4152
4330
  [key: string]: unknown;
4153
4331
  };
4332
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4333
+ export type AiSearchListInstancesParams = {
4334
+ page?: number;
4335
+ per_page?: number;
4336
+ /** Search instances by ID. */
4337
+ search?: string;
4338
+ /** Field to sort by. */
4339
+ order_by?: "created_at";
4340
+ /** Sort direction. */
4341
+ order_by_direction?: "asc" | "desc";
4342
+ };
4154
4343
  export type AiSearchListResponse = {
4155
4344
  result: AiSearchInstanceInfo[];
4156
4345
  result_info?: {
@@ -4178,19 +4367,64 @@ export type AiSearchConfig = {
4178
4367
  reranking?: boolean;
4179
4368
  embedding_model?: string;
4180
4369
  ai_search_model?: string;
4370
+ rewrite_model?: string;
4371
+ reranking_model?: string;
4372
+ /** @deprecated Use index_method instead. */
4373
+ hybrid_search_enabled?: boolean;
4374
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4375
+ index_method?: {
4376
+ vector?: boolean;
4377
+ keyword?: boolean;
4378
+ };
4379
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4380
+ fusion_method?: "max" | "rrf";
4381
+ indexing_options?: {
4382
+ keyword_tokenizer?: "porter" | "trigram";
4383
+ } | null;
4384
+ retrieval_options?: {
4385
+ keyword_match_mode?: "and" | "or";
4386
+ boost_by?: Array<{
4387
+ field: string;
4388
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4389
+ }>;
4390
+ } | null;
4391
+ chunk?: boolean;
4392
+ chunk_size?: number;
4393
+ chunk_overlap?: number;
4394
+ /** Minimum similarity score (0-1) for a result to be included. */
4395
+ score_threshold?: number;
4396
+ max_num_results?: number;
4397
+ cache?: boolean;
4398
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4399
+ cache_threshold?:
4400
+ | "super_strict_match"
4401
+ | "close_enough"
4402
+ | "flexible_friend"
4403
+ | "anything_goes";
4404
+ custom_metadata?: Array<{
4405
+ field_name: string;
4406
+ data_type: "text" | "number" | "boolean" | "datetime";
4407
+ }>;
4408
+ namespace?: string;
4409
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4410
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4411
+ metadata?: Record<string, unknown>;
4181
4412
  [key: string]: unknown;
4182
4413
  };
4183
4414
  // ============ AI Search Item Types ============
4184
4415
  export type AiSearchItemInfo = {
4185
4416
  id: string;
4186
4417
  key: string;
4187
- status:
4188
- | "completed"
4189
- | "error"
4190
- | "skipped"
4191
- | "queued"
4192
- | "processing"
4193
- | "outdated";
4418
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4419
+ next_action?: "INDEX" | "DELETE" | null;
4420
+ error?: string;
4421
+ checksum?: string;
4422
+ namespace?: string;
4423
+ chunks_count?: number | null;
4424
+ file_size?: number | null;
4425
+ source_id?: string | null;
4426
+ last_seen_at?: string;
4427
+ created_at?: string;
4194
4428
  metadata?: Record<string, unknown>;
4195
4429
  [key: string]: unknown;
4196
4430
  };
@@ -4206,6 +4440,22 @@ export type AiSearchUploadItemOptions = {
4206
4440
  export type AiSearchListItemsParams = {
4207
4441
  page?: number;
4208
4442
  per_page?: number;
4443
+ /** Search items by key name. */
4444
+ search?: string;
4445
+ /** Sort order for results. */
4446
+ sort_by?: "status" | "modified_at";
4447
+ /** Filter items by processing status. */
4448
+ status?:
4449
+ | "queued"
4450
+ | "running"
4451
+ | "completed"
4452
+ | "error"
4453
+ | "skipped"
4454
+ | "outdated";
4455
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4456
+ source?: string;
4457
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4458
+ metadata_filter?: string;
4209
4459
  };
4210
4460
  export type AiSearchListItemsResponse = {
4211
4461
  result: AiSearchItemInfo[];
@@ -4216,6 +4466,61 @@ export type AiSearchListItemsResponse = {
4216
4466
  total_count: number;
4217
4467
  };
4218
4468
  };
4469
+ // ============ AI Search Item Logs Types ============
4470
+ export type AiSearchItemLogsParams = {
4471
+ /** Maximum number of log entries to return (1-100, default 50). */
4472
+ limit?: number;
4473
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4474
+ cursor?: string;
4475
+ };
4476
+ export type AiSearchItemLog = {
4477
+ timestamp: string;
4478
+ action: string;
4479
+ message: string;
4480
+ fileKey?: string;
4481
+ chunkCount?: number;
4482
+ processingTimeMs?: number;
4483
+ errorType?: string;
4484
+ };
4485
+ /** Paginated response for item processing logs (cursor-based). */
4486
+ export type AiSearchItemLogsResponse = {
4487
+ result: AiSearchItemLog[];
4488
+ result_info: {
4489
+ count: number;
4490
+ per_page: number;
4491
+ cursor: string | null;
4492
+ truncated: boolean;
4493
+ };
4494
+ };
4495
+ // ============ AI Search Item Chunks Types ============
4496
+ export type AiSearchItemChunksParams = {
4497
+ /** Maximum number of chunks to return (1-100, default 20). */
4498
+ limit?: number;
4499
+ /** Offset into the chunks list (default 0). */
4500
+ offset?: number;
4501
+ };
4502
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4503
+ export type AiSearchItemChunk = {
4504
+ id: string;
4505
+ text: string;
4506
+ start_byte: number;
4507
+ end_byte: number;
4508
+ item?: {
4509
+ timestamp?: number;
4510
+ key: string;
4511
+ metadata?: Record<string, unknown>;
4512
+ };
4513
+ };
4514
+ /** Paginated response for item chunks (offset-based). */
4515
+ export type AiSearchItemChunksResponse = {
4516
+ result: AiSearchItemChunk[];
4517
+ result_info: {
4518
+ count: number;
4519
+ total: number;
4520
+ limit: number;
4521
+ offset: number;
4522
+ };
4523
+ };
4219
4524
  // ============ AI Search Job Types ============
4220
4525
  export type AiSearchJobInfo = {
4221
4526
  id: string;
@@ -4264,7 +4569,7 @@ export type AiSearchJobLogsResponse = {
4264
4569
  // ============ AI Search Sub-Service Classes ============
4265
4570
  /**
4266
4571
  * Single item service for an AI Search instance.
4267
- * Provides info, delete, and download operations on a specific item.
4572
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4268
4573
  */
4269
4574
  export declare abstract class AiSearchItem {
4270
4575
  /** Get metadata about this item. */
@@ -4274,6 +4579,25 @@ export declare abstract class AiSearchItem {
4274
4579
  * @returns Object with body stream, content type, filename, and size.
4275
4580
  */
4276
4581
  download(): Promise<AiSearchItemContentResult>;
4582
+ /**
4583
+ * Trigger re-indexing of this item.
4584
+ * @returns The updated item info.
4585
+ */
4586
+ sync(): Promise<AiSearchItemInfo>;
4587
+ /**
4588
+ * Retrieve processing logs for this item (cursor-based pagination).
4589
+ * @param params Optional pagination parameters (limit, cursor).
4590
+ * @returns Paginated log entries for this item.
4591
+ */
4592
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4593
+ /**
4594
+ * List indexed chunks for this item (offset-based pagination).
4595
+ * @param params Optional pagination parameters (limit, offset).
4596
+ * @returns Paginated chunk entries for this item.
4597
+ */
4598
+ chunks(
4599
+ params?: AiSearchItemChunksParams,
4600
+ ): Promise<AiSearchItemChunksResponse>;
4277
4601
  }
4278
4602
  /**
4279
4603
  * Items collection service for an AI Search instance.
@@ -4283,49 +4607,64 @@ export declare abstract class AiSearchItems {
4283
4607
  /** List items in this instance. */
4284
4608
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4285
4609
  /**
4286
- * Upload a file as an item.
4610
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4611
+ * filename already exists, it is overwritten and re-indexed.
4287
4612
  * @param name Filename for the uploaded item.
4288
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4613
+ * @param content File content as a ReadableStream, Blob, or string.
4289
4614
  * @param options Optional metadata to attach to the item.
4290
4615
  * @returns The created item info.
4291
4616
  */
4292
4617
  upload(
4293
4618
  name: string,
4294
- content: ReadableStream | ArrayBuffer | string,
4619
+ content: ReadableStream | Blob | string,
4295
4620
  options?: AiSearchUploadItemOptions,
4296
4621
  ): Promise<AiSearchItemInfo>;
4297
4622
  /**
4298
4623
  * Upload a file and poll until processing completes.
4624
+ * Behaves as an upsert: if an item with the same filename already exists,
4625
+ * it is overwritten and re-indexed.
4299
4626
  * @param name Filename for the uploaded item.
4300
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4301
- * @param options Optional metadata to attach to the item.
4627
+ * @param content File content as a ReadableStream, Blob, or string.
4628
+ * @param options Optional metadata and polling configuration.
4302
4629
  * @returns The item info after processing completes (or timeout).
4303
4630
  */
4304
4631
  uploadAndPoll(
4305
4632
  name: string,
4306
- content: ReadableStream | ArrayBuffer | string,
4307
- options?: AiSearchUploadItemOptions,
4633
+ content: ReadableStream | Blob | string,
4634
+ options?: AiSearchUploadItemOptions & {
4635
+ /** Polling interval in milliseconds (default 1000). */
4636
+ pollIntervalMs?: number;
4637
+ /** Maximum time to wait in milliseconds (default 30000). */
4638
+ timeoutMs?: number;
4639
+ },
4308
4640
  ): Promise<AiSearchItemInfo>;
4309
4641
  /**
4310
4642
  * Get an item by ID.
4311
4643
  * @param itemId The item identifier.
4312
- * @returns Item service for info, delete, and download operations.
4644
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4313
4645
  */
4314
4646
  get(itemId: string): AiSearchItem;
4315
- /** Delete this item from the instance.
4647
+ /**
4648
+ * Delete an item from the instance.
4316
4649
  * @param itemId The item identifier.
4317
4650
  */
4318
4651
  delete(itemId: string): Promise<void>;
4319
4652
  }
4320
4653
  /**
4321
4654
  * Single job service for an AI Search instance.
4322
- * Provides info and logs for a specific job.
4655
+ * Provides info, logs, and cancel operations for a specific job.
4323
4656
  */
4324
4657
  export declare abstract class AiSearchJob {
4325
4658
  /** Get metadata about this job. */
4326
4659
  info(): Promise<AiSearchJobInfo>;
4327
4660
  /** Get logs for this job. */
4328
4661
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4662
+ /**
4663
+ * Cancel a running job.
4664
+ * @returns The updated job info.
4665
+ * @throws AiSearchNotFoundError if the job does not exist.
4666
+ */
4667
+ cancel(): Promise<AiSearchJobInfo>;
4329
4668
  }
4330
4669
  /**
4331
4670
  * Jobs collection service for an AI Search instance.
@@ -4343,7 +4682,7 @@ export declare abstract class AiSearchJobs {
4343
4682
  /**
4344
4683
  * Get a job by ID.
4345
4684
  * @param jobId The job identifier.
4346
- * @returns Job service for info and logs operations.
4685
+ * @returns Job service for info, logs, and cancel operations.
4347
4686
  */
4348
4687
  get(jobId: string): AiSearchJob;
4349
4688
  }
@@ -4362,7 +4701,7 @@ export declare abstract class AiSearchJobs {
4362
4701
  * // Via namespace binding
4363
4702
  * const instance = env.AI_SEARCH.get("blog");
4364
4703
  * const results = await instance.search({
4365
- * messages: [{ role: "user", content: "How does caching work?" }],
4704
+ * query: "How does caching work?",
4366
4705
  * });
4367
4706
  *
4368
4707
  * // Via single instance binding
@@ -4374,7 +4713,7 @@ export declare abstract class AiSearchJobs {
4374
4713
  export declare abstract class AiSearchInstance {
4375
4714
  /**
4376
4715
  * Search the AI Search instance for relevant chunks.
4377
- * @param params Search request with messages and optional AI search options.
4716
+ * @param params Search request with query or messages and optional AI search options.
4378
4717
  * @returns Search response with matching chunks and search query.
4379
4718
  */
4380
4719
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4406,7 +4745,7 @@ export declare abstract class AiSearchInstance {
4406
4745
  info(): Promise<AiSearchInstanceInfo>;
4407
4746
  /**
4408
4747
  * Get instance statistics (item count, indexing status, etc.).
4409
- * @returns Statistics with counts per status and last activity time.
4748
+ * @returns Statistics with counts per status, last activity time, and engine details.
4410
4749
  */
4411
4750
  stats(): Promise<AiSearchStatsResponse>;
4412
4751
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4418,27 +4757,30 @@ export declare abstract class AiSearchInstance {
4418
4757
  * Namespace-level AI Search service.
4419
4758
  *
4420
4759
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4421
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4760
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4761
+ * and multi-instance search/chat operations.
4422
4762
  *
4423
4763
  * @example
4424
4764
  * ```ts
4425
4765
  * // Access an instance within the namespace
4426
4766
  * const blog = env.AI_SEARCH.get("blog");
4427
- * const results = await blog.search({
4428
- * messages: [{ role: "user", content: "How does caching work?" }],
4429
- * });
4767
+ * const results = await blog.search({ query: "How does caching work?" });
4430
4768
  *
4431
4769
  * // List all instances in the namespace
4432
4770
  * const instances = await env.AI_SEARCH.list();
4433
4771
  *
4434
4772
  * // Create a new instance with built-in storage
4435
- * const tenant = await env.AI_SEARCH.create({
4436
- * id: "tenant-123",
4437
- * });
4773
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4438
4774
  *
4439
4775
  * // Upload items into the instance
4440
4776
  * await tenant.items.upload("doc.pdf", fileContent);
4441
4777
  *
4778
+ * // Search across multiple instances
4779
+ * const multi = await env.AI_SEARCH.search({
4780
+ * query: "caching",
4781
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4782
+ * });
4783
+ *
4442
4784
  * // Delete an instance
4443
4785
  * await env.AI_SEARCH.delete("tenant-123");
4444
4786
  * ```
@@ -4451,10 +4793,11 @@ export declare abstract class AiSearchNamespace {
4451
4793
  */
4452
4794
  get(name: string): AiSearchInstance;
4453
4795
  /**
4454
- * List all instances in the bound namespace.
4455
- * @returns Array of instance metadata.
4796
+ * List instances in the bound namespace.
4797
+ * @param params Optional pagination, search, and ordering parameters.
4798
+ * @returns Array of instance metadata with pagination info.
4456
4799
  */
4457
- list(): Promise<AiSearchListResponse>;
4800
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4458
4801
  /**
4459
4802
  * Create a new instance within the bound namespace.
4460
4803
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4479,6 +4822,35 @@ export declare abstract class AiSearchNamespace {
4479
4822
  * @param name Instance name to delete.
4480
4823
  */
4481
4824
  delete(name: string): Promise<void>;
4825
+ /**
4826
+ * Search across multiple instances within the bound namespace.
4827
+ * Fans out to the specified instance_ids and merges results.
4828
+ * @param params Search request with required `ai_search_options.instance_ids`.
4829
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4830
+ */
4831
+ search(
4832
+ params: AiSearchMultiSearchRequest,
4833
+ ): Promise<AiSearchMultiSearchResponse>;
4834
+ /**
4835
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4836
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4837
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4838
+ * @returns ReadableStream of server-sent events.
4839
+ */
4840
+ chatCompletions(
4841
+ params: AiSearchMultiChatCompletionsRequest & {
4842
+ stream: true;
4843
+ },
4844
+ ): Promise<ReadableStream>;
4845
+ /**
4846
+ * Generate chat completions across multiple instances within the bound namespace.
4847
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4848
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4849
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4850
+ */
4851
+ chatCompletions(
4852
+ params: AiSearchMultiChatCompletionsRequest,
4853
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4482
4854
  }
4483
4855
  export type AiImageClassificationInput = {
4484
4856
  image: number[];
@@ -12140,8 +12512,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12140
12512
  * Evaluation context for targeting rules.
12141
12513
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12142
12514
  */
12143
- export type EvaluationContext = Record<string, string | number | boolean>;
12144
- export interface EvaluationDetails<T> {
12515
+ export type FlagshipEvaluationContext = Record<
12516
+ string,
12517
+ string | number | boolean
12518
+ >;
12519
+ export interface FlagshipEvaluationDetails<T> {
12145
12520
  flagKey: string;
12146
12521
  value: T;
12147
12522
  variant?: string | undefined;
@@ -12149,7 +12524,7 @@ export interface EvaluationDetails<T> {
12149
12524
  errorCode?: string | undefined;
12150
12525
  errorMessage?: string | undefined;
12151
12526
  }
12152
- export interface FlagEvaluationError extends Error {}
12527
+ export interface FlagshipEvaluationError extends Error {}
12153
12528
  /**
12154
12529
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12155
12530
  *
@@ -12169,7 +12544,7 @@ export interface FlagEvaluationError extends Error {}
12169
12544
  * console.log(details.variant, details.reason);
12170
12545
  * ```
12171
12546
  */
12172
- export declare abstract class Flags {
12547
+ export declare abstract class Flagship {
12173
12548
  /**
12174
12549
  * Get a flag value without type checking.
12175
12550
  * @param flagKey The key of the flag to evaluate.
@@ -12179,7 +12554,7 @@ export declare abstract class Flags {
12179
12554
  get(
12180
12555
  flagKey: string,
12181
12556
  defaultValue?: unknown,
12182
- context?: EvaluationContext,
12557
+ context?: FlagshipEvaluationContext,
12183
12558
  ): Promise<unknown>;
12184
12559
  /**
12185
12560
  * Get a boolean flag value.
@@ -12190,7 +12565,7 @@ export declare abstract class Flags {
12190
12565
  getBooleanValue(
12191
12566
  flagKey: string,
12192
12567
  defaultValue: boolean,
12193
- context?: EvaluationContext,
12568
+ context?: FlagshipEvaluationContext,
12194
12569
  ): Promise<boolean>;
12195
12570
  /**
12196
12571
  * Get a string flag value.
@@ -12201,7 +12576,7 @@ export declare abstract class Flags {
12201
12576
  getStringValue(
12202
12577
  flagKey: string,
12203
12578
  defaultValue: string,
12204
- context?: EvaluationContext,
12579
+ context?: FlagshipEvaluationContext,
12205
12580
  ): Promise<string>;
12206
12581
  /**
12207
12582
  * Get a number flag value.
@@ -12212,7 +12587,7 @@ export declare abstract class Flags {
12212
12587
  getNumberValue(
12213
12588
  flagKey: string,
12214
12589
  defaultValue: number,
12215
- context?: EvaluationContext,
12590
+ context?: FlagshipEvaluationContext,
12216
12591
  ): Promise<number>;
12217
12592
  /**
12218
12593
  * Get an object flag value.
@@ -12223,7 +12598,7 @@ export declare abstract class Flags {
12223
12598
  getObjectValue<T extends object>(
12224
12599
  flagKey: string,
12225
12600
  defaultValue: T,
12226
- context?: EvaluationContext,
12601
+ context?: FlagshipEvaluationContext,
12227
12602
  ): Promise<T>;
12228
12603
  /**
12229
12604
  * Get a boolean flag value with full evaluation details.
@@ -12234,8 +12609,8 @@ export declare abstract class Flags {
12234
12609
  getBooleanDetails(
12235
12610
  flagKey: string,
12236
12611
  defaultValue: boolean,
12237
- context?: EvaluationContext,
12238
- ): Promise<EvaluationDetails<boolean>>;
12612
+ context?: FlagshipEvaluationContext,
12613
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12239
12614
  /**
12240
12615
  * Get a string flag value with full evaluation details.
12241
12616
  * @param flagKey The key of the flag to evaluate.
@@ -12245,8 +12620,8 @@ export declare abstract class Flags {
12245
12620
  getStringDetails(
12246
12621
  flagKey: string,
12247
12622
  defaultValue: string,
12248
- context?: EvaluationContext,
12249
- ): Promise<EvaluationDetails<string>>;
12623
+ context?: FlagshipEvaluationContext,
12624
+ ): Promise<FlagshipEvaluationDetails<string>>;
12250
12625
  /**
12251
12626
  * Get a number flag value with full evaluation details.
12252
12627
  * @param flagKey The key of the flag to evaluate.
@@ -12256,8 +12631,8 @@ export declare abstract class Flags {
12256
12631
  getNumberDetails(
12257
12632
  flagKey: string,
12258
12633
  defaultValue: number,
12259
- context?: EvaluationContext,
12260
- ): Promise<EvaluationDetails<number>>;
12634
+ context?: FlagshipEvaluationContext,
12635
+ ): Promise<FlagshipEvaluationDetails<number>>;
12261
12636
  /**
12262
12637
  * Get an object flag value with full evaluation details.
12263
12638
  * @param flagKey The key of the flag to evaluate.
@@ -12267,8 +12642,8 @@ export declare abstract class Flags {
12267
12642
  getObjectDetails<T extends object>(
12268
12643
  flagKey: string,
12269
12644
  defaultValue: T,
12270
- context?: EvaluationContext,
12271
- ): Promise<EvaluationDetails<T>>;
12645
+ context?: FlagshipEvaluationContext,
12646
+ ): Promise<FlagshipEvaluationDetails<T>>;
12272
12647
  }
12273
12648
  /**
12274
12649
  * Hello World binding to serve as an explanatory example. DO NOT USE