@cloudflare/workers-types 4.20260415.1 → 4.20260416.1

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