@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/index.ts CHANGED
@@ -2307,11 +2307,34 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2307
2307
  }
2308
2308
  export type QueueContentType = "text" | "bytes" | "json" | "v8";
2309
2309
  export interface Queue<Body = unknown> {
2310
- send(message: Body, options?: QueueSendOptions): Promise<void>;
2310
+ metrics(): Promise<QueueMetrics>;
2311
+ send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2311
2312
  sendBatch(
2312
2313
  messages: Iterable<MessageSendRequest<Body>>,
2313
2314
  options?: QueueSendBatchOptions,
2314
- ): Promise<void>;
2315
+ ): Promise<QueueSendBatchResponse>;
2316
+ }
2317
+ export interface QueueSendMetrics {
2318
+ backlogCount: number;
2319
+ backlogBytes: number;
2320
+ oldestMessageTimestamp?: Date;
2321
+ }
2322
+ export interface QueueSendMetadata {
2323
+ metrics: QueueSendMetrics;
2324
+ }
2325
+ export interface QueueSendResponse {
2326
+ metadata: QueueSendMetadata;
2327
+ }
2328
+ export interface QueueSendBatchMetrics {
2329
+ backlogCount: number;
2330
+ backlogBytes: number;
2331
+ oldestMessageTimestamp?: Date;
2332
+ }
2333
+ export interface QueueSendBatchMetadata {
2334
+ metrics: QueueSendBatchMetrics;
2335
+ }
2336
+ export interface QueueSendBatchResponse {
2337
+ metadata: QueueSendBatchMetadata;
2315
2338
  }
2316
2339
  export interface QueueSendOptions {
2317
2340
  contentType?: QueueContentType;
@@ -2325,6 +2348,19 @@ export interface MessageSendRequest<Body = unknown> {
2325
2348
  contentType?: QueueContentType;
2326
2349
  delaySeconds?: number;
2327
2350
  }
2351
+ export interface QueueMetrics {
2352
+ backlogCount: number;
2353
+ backlogBytes: number;
2354
+ oldestMessageTimestamp?: Date;
2355
+ }
2356
+ export interface MessageBatchMetrics {
2357
+ backlogCount: number;
2358
+ backlogBytes: number;
2359
+ oldestMessageTimestamp?: Date;
2360
+ }
2361
+ export interface MessageBatchMetadata {
2362
+ metrics: MessageBatchMetrics;
2363
+ }
2328
2364
  export interface QueueRetryOptions {
2329
2365
  delaySeconds?: number;
2330
2366
  }
@@ -2339,12 +2375,14 @@ export interface Message<Body = unknown> {
2339
2375
  export interface QueueEvent<Body = unknown> extends ExtendableEvent {
2340
2376
  readonly messages: readonly Message<Body>[];
2341
2377
  readonly queue: string;
2378
+ readonly metadata: MessageBatchMetadata;
2342
2379
  retryAll(options?: QueueRetryOptions): void;
2343
2380
  ackAll(): void;
2344
2381
  }
2345
2382
  export interface MessageBatch<Body = unknown> {
2346
2383
  readonly messages: readonly Message<Body>[];
2347
2384
  readonly queue: string;
2385
+ readonly metadata: MessageBatchMetadata;
2348
2386
  retryAll(options?: QueueRetryOptions): void;
2349
2387
  ackAll(): void;
2350
2388
  }
@@ -3884,72 +3922,145 @@ export declare abstract class Performance {
3884
3922
  // ============ AI Search Error Interfaces ============
3885
3923
  export interface AiSearchInternalError extends Error {}
3886
3924
  export interface AiSearchNotFoundError extends Error {}
3887
- // ============ AI Search Request Types ============
3888
- export type AiSearchSearchRequest = {
3889
- messages: Array<{
3890
- role: "system" | "developer" | "user" | "assistant" | "tool";
3891
- content: string | null;
3892
- }>;
3893
- ai_search_options?: {
3894
- retrieval?: {
3895
- retrieval_type?: "vector" | "keyword" | "hybrid";
3896
- /** Match threshold (0-1, default 0.4) */
3897
- match_threshold?: number;
3898
- /** Maximum number of results (1-50, default 10) */
3899
- max_num_results?: number;
3900
- filters?: VectorizeVectorMetadataFilter;
3901
- /** Context expansion (0-3, default 0) */
3902
- context_expansion?: number;
3903
- [key: string]: unknown;
3904
- };
3905
- query_rewrite?: {
3906
- enabled?: boolean;
3907
- model?: string;
3908
- rewrite_prompt?: string;
3909
- [key: string]: unknown;
3910
- };
3911
- reranking?: {
3912
- enabled?: boolean;
3913
- model?: "@cf/baai/bge-reranker-base" | string;
3914
- /** Match threshold (0-1, default 0.4) */
3915
- match_threshold?: number;
3916
- [key: string]: unknown;
3917
- };
3925
+ // ============ AI Search Common Types ============
3926
+ /** A single message in a conversation-style search or chat request. */
3927
+ export type AiSearchMessage = {
3928
+ role: "system" | "developer" | "user" | "assistant" | "tool";
3929
+ content: string | null;
3930
+ };
3931
+ /**
3932
+ * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
3933
+ * Contains retrieval, query rewrite, reranking, and cache sub-options.
3934
+ */
3935
+ export type AiSearchOptions = {
3936
+ retrieval?: {
3937
+ /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
3938
+ retrieval_type?: "vector" | "keyword" | "hybrid";
3939
+ /** Fusion method for combining vector + keyword results. */
3940
+ fusion_method?: "max" | "rrf";
3941
+ /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
3942
+ keyword_match_mode?: "and" | "or";
3943
+ /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
3944
+ match_threshold?: number;
3945
+ /** Maximum number of results to return (1-50). Default 10. */
3946
+ max_num_results?: number;
3947
+ /** Vectorize metadata filters applied to the search. */
3948
+ filters?: VectorizeVectorMetadataFilter;
3949
+ /** Number of surrounding chunks to include for context (0-3). Default 0. */
3950
+ context_expansion?: number;
3951
+ /** If true, return only item metadata without chunk text. */
3952
+ metadata_only?: boolean;
3953
+ /** If true (default), return empty results on retrieval failure instead of throwing. */
3954
+ return_on_failure?: boolean;
3955
+ /** Boost results by metadata field values. Max 3 entries. */
3956
+ boost_by?: Array<{
3957
+ field: string;
3958
+ direction?: "asc" | "desc" | "exists" | "not_exists";
3959
+ }>;
3960
+ [key: string]: unknown;
3961
+ };
3962
+ query_rewrite?: {
3963
+ enabled?: boolean;
3964
+ model?: string;
3965
+ rewrite_prompt?: string;
3966
+ [key: string]: unknown;
3967
+ };
3968
+ reranking?: {
3969
+ enabled?: boolean;
3970
+ model?: string;
3971
+ /** Match threshold (0-1, default 0.4) */
3972
+ match_threshold?: number;
3918
3973
  [key: string]: unknown;
3919
3974
  };
3975
+ cache?: {
3976
+ enabled?: boolean;
3977
+ cache_threshold?:
3978
+ | "super_strict_match"
3979
+ | "close_enough"
3980
+ | "flexible_friend"
3981
+ | "anything_goes";
3982
+ };
3983
+ [key: string]: unknown;
3920
3984
  };
3985
+ // ============ AI Search Request Types ============
3986
+ /**
3987
+ * Request body for single-instance search.
3988
+ * Exactly one of `query` or `messages` must be provided.
3989
+ */
3990
+ export type AiSearchSearchRequest =
3991
+ | {
3992
+ /** Simple query string. */
3993
+ query: string;
3994
+ messages?: never;
3995
+ ai_search_options?: AiSearchOptions;
3996
+ }
3997
+ | {
3998
+ query?: never;
3999
+ /** Conversation-style input. At least one user message with non-empty content is required. */
4000
+ messages: AiSearchMessage[];
4001
+ ai_search_options?: AiSearchOptions;
4002
+ };
3921
4003
  export type AiSearchChatCompletionsRequest = {
3922
- messages: Array<{
3923
- role: "system" | "developer" | "user" | "assistant" | "tool";
3924
- content: string | null;
3925
- [key: string]: unknown;
3926
- }>;
4004
+ messages: AiSearchMessage[];
3927
4005
  model?: string;
3928
4006
  stream?: boolean;
3929
- ai_search_options?: {
3930
- retrieval?: {
3931
- retrieval_type?: "vector" | "keyword" | "hybrid";
3932
- match_threshold?: number;
3933
- max_num_results?: number;
3934
- filters?: VectorizeVectorMetadataFilter;
3935
- context_expansion?: number;
3936
- [key: string]: unknown;
3937
- };
3938
- query_rewrite?: {
3939
- enabled?: boolean;
3940
- model?: string;
3941
- rewrite_prompt?: string;
3942
- [key: string]: unknown;
3943
- };
3944
- reranking?: {
3945
- enabled?: boolean;
3946
- model?: "@cf/baai/bge-reranker-base" | string;
3947
- match_threshold?: number;
3948
- [key: string]: unknown;
4007
+ ai_search_options?: AiSearchOptions;
4008
+ [key: string]: unknown;
4009
+ };
4010
+ // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4011
+ /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
4012
+ export type AiSearchMultiSearchOptions = AiSearchOptions & {
4013
+ /** Instance IDs to search across (1-10). */
4014
+ instance_ids: string[];
4015
+ };
4016
+ /**
4017
+ * Request for searching across multiple instances within a namespace.
4018
+ * `ai_search_options` is required and must include `instance_ids`.
4019
+ * Exactly one of `query` or `messages` must be provided.
4020
+ */
4021
+ export type AiSearchMultiSearchRequest =
4022
+ | {
4023
+ /** Simple query string. */
4024
+ query: string;
4025
+ messages?: never;
4026
+ ai_search_options: AiSearchMultiSearchOptions;
4027
+ }
4028
+ | {
4029
+ query?: never;
4030
+ /** Conversation-style input. */
4031
+ messages: AiSearchMessage[];
4032
+ ai_search_options: AiSearchMultiSearchOptions;
3949
4033
  };
3950
- [key: string]: unknown;
4034
+ /** A search result chunk tagged with the instance it originated from. */
4035
+ export type AiSearchMultiSearchChunk =
4036
+ AiSearchSearchResponse["chunks"][number] & {
4037
+ instance_id: string;
3951
4038
  };
3952
- [key: string]: unknown;
4039
+ /** Describes a per-instance error during a multi-instance operation. */
4040
+ export type AiSearchMultiSearchError = {
4041
+ instance_id: string;
4042
+ message: string;
4043
+ };
4044
+ /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4045
+ export type AiSearchMultiSearchResponse = {
4046
+ search_query: string;
4047
+ chunks: AiSearchMultiSearchChunk[];
4048
+ errors?: AiSearchMultiSearchError[];
4049
+ };
4050
+ /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4051
+ export type AiSearchMultiChatCompletionsRequest = Omit<
4052
+ AiSearchChatCompletionsRequest,
4053
+ "ai_search_options"
4054
+ > & {
4055
+ ai_search_options: AiSearchMultiSearchOptions;
4056
+ };
4057
+ /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4058
+ export type AiSearchMultiChatCompletionsResponse = Omit<
4059
+ AiSearchChatCompletionsResponse,
4060
+ "chunks"
4061
+ > & {
4062
+ chunks: AiSearchMultiSearchChunk[];
4063
+ errors?: AiSearchMultiSearchError[];
3953
4064
  };
3954
4065
  // ============ AI Search Response Types ============
3955
4066
  export type AiSearchSearchResponse = {
@@ -3970,6 +4081,14 @@ export type AiSearchSearchResponse = {
3970
4081
  keyword_score?: number;
3971
4082
  /** Vector similarity score (0-1) */
3972
4083
  vector_score?: number;
4084
+ /** Keyword rank position */
4085
+ keyword_rank?: number;
4086
+ /** Vector rank position */
4087
+ vector_rank?: number;
4088
+ /** Reranking model score */
4089
+ reranking_score?: number;
4090
+ /** Fusion method used to combine results */
4091
+ fusion_method?: "rrf" | "max";
3973
4092
  [key: string]: unknown;
3974
4093
  };
3975
4094
  }>;
@@ -3998,19 +4117,88 @@ export type AiSearchStatsResponse = {
3998
4117
  skipped?: number;
3999
4118
  outdated?: number;
4000
4119
  last_activity?: string;
4120
+ /** Storage engine statistics. */
4121
+ engine?: {
4122
+ vectorize?: {
4123
+ vectorsCount: number;
4124
+ dimensions: number;
4125
+ };
4126
+ r2?: {
4127
+ payloadSizeBytes: number;
4128
+ metadataSizeBytes: number;
4129
+ objectCount: number;
4130
+ };
4131
+ };
4001
4132
  };
4002
4133
  // ============ AI Search Instance Info Types ============
4003
4134
  export type AiSearchInstanceInfo = {
4004
4135
  id: string;
4005
4136
  type?: "r2" | "web-crawler" | string;
4006
4137
  source?: string;
4138
+ source_params?: unknown;
4007
4139
  paused?: boolean;
4008
4140
  status?: string;
4009
4141
  namespace?: string;
4010
4142
  created_at?: string;
4011
4143
  modified_at?: string;
4144
+ token_id?: string;
4145
+ ai_gateway_id?: string;
4146
+ rewrite_query?: boolean;
4147
+ reranking?: boolean;
4148
+ embedding_model?: string;
4149
+ ai_search_model?: string;
4150
+ rewrite_model?: string;
4151
+ reranking_model?: string;
4152
+ /** @deprecated Use index_method instead. */
4153
+ hybrid_search_enabled?: boolean;
4154
+ /** Controls which storage backends are active. */
4155
+ index_method?: {
4156
+ vector?: boolean;
4157
+ keyword?: boolean;
4158
+ };
4159
+ /** Fusion method for combining vector and keyword results. */
4160
+ fusion_method?: "max" | "rrf";
4161
+ indexing_options?: {
4162
+ keyword_tokenizer?: "porter" | "trigram";
4163
+ } | null;
4164
+ retrieval_options?: {
4165
+ keyword_match_mode?: "and" | "or";
4166
+ boost_by?: Array<{
4167
+ field: string;
4168
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4169
+ }>;
4170
+ } | null;
4171
+ chunk?: boolean;
4172
+ chunk_size?: number;
4173
+ chunk_overlap?: number;
4174
+ score_threshold?: number;
4175
+ max_num_results?: number;
4176
+ cache?: boolean;
4177
+ cache_threshold?:
4178
+ | "super_strict_match"
4179
+ | "close_enough"
4180
+ | "flexible_friend"
4181
+ | "anything_goes";
4182
+ custom_metadata?: Array<{
4183
+ field_name: string;
4184
+ data_type: "text" | "number" | "boolean" | "datetime";
4185
+ }>;
4186
+ /** Sync interval in seconds. */
4187
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4188
+ metadata?: Record<string, unknown>;
4012
4189
  [key: string]: unknown;
4013
4190
  };
4191
+ /** Pagination, search, and ordering parameters for listing instances within a namespace. */
4192
+ export type AiSearchListInstancesParams = {
4193
+ page?: number;
4194
+ per_page?: number;
4195
+ /** Search instances by ID. */
4196
+ search?: string;
4197
+ /** Field to sort by. */
4198
+ order_by?: "created_at";
4199
+ /** Sort direction. */
4200
+ order_by_direction?: "asc" | "desc";
4201
+ };
4014
4202
  export type AiSearchListResponse = {
4015
4203
  result: AiSearchInstanceInfo[];
4016
4204
  result_info?: {
@@ -4038,19 +4226,64 @@ export type AiSearchConfig = {
4038
4226
  reranking?: boolean;
4039
4227
  embedding_model?: string;
4040
4228
  ai_search_model?: string;
4229
+ rewrite_model?: string;
4230
+ reranking_model?: string;
4231
+ /** @deprecated Use index_method instead. */
4232
+ hybrid_search_enabled?: boolean;
4233
+ /** Controls which storage backends are used during indexing. Defaults to vector-only. */
4234
+ index_method?: {
4235
+ vector?: boolean;
4236
+ keyword?: boolean;
4237
+ };
4238
+ /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
4239
+ fusion_method?: "max" | "rrf";
4240
+ indexing_options?: {
4241
+ keyword_tokenizer?: "porter" | "trigram";
4242
+ } | null;
4243
+ retrieval_options?: {
4244
+ keyword_match_mode?: "and" | "or";
4245
+ boost_by?: Array<{
4246
+ field: string;
4247
+ direction?: "asc" | "desc" | "exists" | "not_exists";
4248
+ }>;
4249
+ } | null;
4250
+ chunk?: boolean;
4251
+ chunk_size?: number;
4252
+ chunk_overlap?: number;
4253
+ /** Minimum similarity score (0-1) for a result to be included. */
4254
+ score_threshold?: number;
4255
+ max_num_results?: number;
4256
+ cache?: boolean;
4257
+ /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
4258
+ cache_threshold?:
4259
+ | "super_strict_match"
4260
+ | "close_enough"
4261
+ | "flexible_friend"
4262
+ | "anything_goes";
4263
+ custom_metadata?: Array<{
4264
+ field_name: string;
4265
+ data_type: "text" | "number" | "boolean" | "datetime";
4266
+ }>;
4267
+ namespace?: string;
4268
+ /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
4269
+ sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
4270
+ metadata?: Record<string, unknown>;
4041
4271
  [key: string]: unknown;
4042
4272
  };
4043
4273
  // ============ AI Search Item Types ============
4044
4274
  export type AiSearchItemInfo = {
4045
4275
  id: string;
4046
4276
  key: string;
4047
- status:
4048
- | "completed"
4049
- | "error"
4050
- | "skipped"
4051
- | "queued"
4052
- | "processing"
4053
- | "outdated";
4277
+ status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
4278
+ next_action?: "INDEX" | "DELETE" | null;
4279
+ error?: string;
4280
+ checksum?: string;
4281
+ namespace?: string;
4282
+ chunks_count?: number | null;
4283
+ file_size?: number | null;
4284
+ source_id?: string | null;
4285
+ last_seen_at?: string;
4286
+ created_at?: string;
4054
4287
  metadata?: Record<string, unknown>;
4055
4288
  [key: string]: unknown;
4056
4289
  };
@@ -4066,6 +4299,22 @@ export type AiSearchUploadItemOptions = {
4066
4299
  export type AiSearchListItemsParams = {
4067
4300
  page?: number;
4068
4301
  per_page?: number;
4302
+ /** Search items by key name. */
4303
+ search?: string;
4304
+ /** Sort order for results. */
4305
+ sort_by?: "status" | "modified_at";
4306
+ /** Filter items by processing status. */
4307
+ status?:
4308
+ | "queued"
4309
+ | "running"
4310
+ | "completed"
4311
+ | "error"
4312
+ | "skipped"
4313
+ | "outdated";
4314
+ /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
4315
+ source?: string;
4316
+ /** JSON-encoded Vectorize filter for metadata filtering. */
4317
+ metadata_filter?: string;
4069
4318
  };
4070
4319
  export type AiSearchListItemsResponse = {
4071
4320
  result: AiSearchItemInfo[];
@@ -4076,6 +4325,61 @@ export type AiSearchListItemsResponse = {
4076
4325
  total_count: number;
4077
4326
  };
4078
4327
  };
4328
+ // ============ AI Search Item Logs Types ============
4329
+ export type AiSearchItemLogsParams = {
4330
+ /** Maximum number of log entries to return (1-100, default 50). */
4331
+ limit?: number;
4332
+ /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
4333
+ cursor?: string;
4334
+ };
4335
+ export type AiSearchItemLog = {
4336
+ timestamp: string;
4337
+ action: string;
4338
+ message: string;
4339
+ fileKey?: string;
4340
+ chunkCount?: number;
4341
+ processingTimeMs?: number;
4342
+ errorType?: string;
4343
+ };
4344
+ /** Paginated response for item processing logs (cursor-based). */
4345
+ export type AiSearchItemLogsResponse = {
4346
+ result: AiSearchItemLog[];
4347
+ result_info: {
4348
+ count: number;
4349
+ per_page: number;
4350
+ cursor: string | null;
4351
+ truncated: boolean;
4352
+ };
4353
+ };
4354
+ // ============ AI Search Item Chunks Types ============
4355
+ export type AiSearchItemChunksParams = {
4356
+ /** Maximum number of chunks to return (1-100, default 20). */
4357
+ limit?: number;
4358
+ /** Offset into the chunks list (default 0). */
4359
+ offset?: number;
4360
+ };
4361
+ /** A single indexed chunk belonging to an item, including its text content and byte range. */
4362
+ export type AiSearchItemChunk = {
4363
+ id: string;
4364
+ text: string;
4365
+ start_byte: number;
4366
+ end_byte: number;
4367
+ item?: {
4368
+ timestamp?: number;
4369
+ key: string;
4370
+ metadata?: Record<string, unknown>;
4371
+ };
4372
+ };
4373
+ /** Paginated response for item chunks (offset-based). */
4374
+ export type AiSearchItemChunksResponse = {
4375
+ result: AiSearchItemChunk[];
4376
+ result_info: {
4377
+ count: number;
4378
+ total: number;
4379
+ limit: number;
4380
+ offset: number;
4381
+ };
4382
+ };
4079
4383
  // ============ AI Search Job Types ============
4080
4384
  export type AiSearchJobInfo = {
4081
4385
  id: string;
@@ -4124,7 +4428,7 @@ export type AiSearchJobLogsResponse = {
4124
4428
  // ============ AI Search Sub-Service Classes ============
4125
4429
  /**
4126
4430
  * Single item service for an AI Search instance.
4127
- * Provides info, delete, and download operations on a specific item.
4431
+ * Provides info, download, sync, logs, and chunks operations on a specific item.
4128
4432
  */
4129
4433
  export declare abstract class AiSearchItem {
4130
4434
  /** Get metadata about this item. */
@@ -4134,6 +4438,25 @@ export declare abstract class AiSearchItem {
4134
4438
  * @returns Object with body stream, content type, filename, and size.
4135
4439
  */
4136
4440
  download(): Promise<AiSearchItemContentResult>;
4441
+ /**
4442
+ * Trigger re-indexing of this item.
4443
+ * @returns The updated item info.
4444
+ */
4445
+ sync(): Promise<AiSearchItemInfo>;
4446
+ /**
4447
+ * Retrieve processing logs for this item (cursor-based pagination).
4448
+ * @param params Optional pagination parameters (limit, cursor).
4449
+ * @returns Paginated log entries for this item.
4450
+ */
4451
+ logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
4452
+ /**
4453
+ * List indexed chunks for this item (offset-based pagination).
4454
+ * @param params Optional pagination parameters (limit, offset).
4455
+ * @returns Paginated chunk entries for this item.
4456
+ */
4457
+ chunks(
4458
+ params?: AiSearchItemChunksParams,
4459
+ ): Promise<AiSearchItemChunksResponse>;
4137
4460
  }
4138
4461
  /**
4139
4462
  * Items collection service for an AI Search instance.
@@ -4143,49 +4466,64 @@ export declare abstract class AiSearchItems {
4143
4466
  /** List items in this instance. */
4144
4467
  list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
4145
4468
  /**
4146
- * Upload a file as an item.
4469
+ * Upload a file as an item. Behaves as an upsert: if an item with the same
4470
+ * filename already exists, it is overwritten and re-indexed.
4147
4471
  * @param name Filename for the uploaded item.
4148
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4472
+ * @param content File content as a ReadableStream, Blob, or string.
4149
4473
  * @param options Optional metadata to attach to the item.
4150
4474
  * @returns The created item info.
4151
4475
  */
4152
4476
  upload(
4153
4477
  name: string,
4154
- content: ReadableStream | ArrayBuffer | string,
4478
+ content: ReadableStream | Blob | string,
4155
4479
  options?: AiSearchUploadItemOptions,
4156
4480
  ): Promise<AiSearchItemInfo>;
4157
4481
  /**
4158
4482
  * Upload a file and poll until processing completes.
4483
+ * Behaves as an upsert: if an item with the same filename already exists,
4484
+ * it is overwritten and re-indexed.
4159
4485
  * @param name Filename for the uploaded item.
4160
- * @param content File content as a ReadableStream, ArrayBuffer, or string.
4161
- * @param options Optional metadata to attach to the item.
4486
+ * @param content File content as a ReadableStream, Blob, or string.
4487
+ * @param options Optional metadata and polling configuration.
4162
4488
  * @returns The item info after processing completes (or timeout).
4163
4489
  */
4164
4490
  uploadAndPoll(
4165
4491
  name: string,
4166
- content: ReadableStream | ArrayBuffer | string,
4167
- options?: AiSearchUploadItemOptions,
4492
+ content: ReadableStream | Blob | string,
4493
+ options?: AiSearchUploadItemOptions & {
4494
+ /** Polling interval in milliseconds (default 1000). */
4495
+ pollIntervalMs?: number;
4496
+ /** Maximum time to wait in milliseconds (default 30000). */
4497
+ timeoutMs?: number;
4498
+ },
4168
4499
  ): Promise<AiSearchItemInfo>;
4169
4500
  /**
4170
4501
  * Get an item by ID.
4171
4502
  * @param itemId The item identifier.
4172
- * @returns Item service for info, delete, and download operations.
4503
+ * @returns Item service for info, download, sync, logs, and chunks operations.
4173
4504
  */
4174
4505
  get(itemId: string): AiSearchItem;
4175
- /** Delete this item from the instance.
4506
+ /**
4507
+ * Delete an item from the instance.
4176
4508
  * @param itemId The item identifier.
4177
4509
  */
4178
4510
  delete(itemId: string): Promise<void>;
4179
4511
  }
4180
4512
  /**
4181
4513
  * Single job service for an AI Search instance.
4182
- * Provides info and logs for a specific job.
4514
+ * Provides info, logs, and cancel operations for a specific job.
4183
4515
  */
4184
4516
  export declare abstract class AiSearchJob {
4185
4517
  /** Get metadata about this job. */
4186
4518
  info(): Promise<AiSearchJobInfo>;
4187
4519
  /** Get logs for this job. */
4188
4520
  logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
4521
+ /**
4522
+ * Cancel a running job.
4523
+ * @returns The updated job info.
4524
+ * @throws AiSearchNotFoundError if the job does not exist.
4525
+ */
4526
+ cancel(): Promise<AiSearchJobInfo>;
4189
4527
  }
4190
4528
  /**
4191
4529
  * Jobs collection service for an AI Search instance.
@@ -4203,7 +4541,7 @@ export declare abstract class AiSearchJobs {
4203
4541
  /**
4204
4542
  * Get a job by ID.
4205
4543
  * @param jobId The job identifier.
4206
- * @returns Job service for info and logs operations.
4544
+ * @returns Job service for info, logs, and cancel operations.
4207
4545
  */
4208
4546
  get(jobId: string): AiSearchJob;
4209
4547
  }
@@ -4222,7 +4560,7 @@ export declare abstract class AiSearchJobs {
4222
4560
  * // Via namespace binding
4223
4561
  * const instance = env.AI_SEARCH.get("blog");
4224
4562
  * const results = await instance.search({
4225
- * messages: [{ role: "user", content: "How does caching work?" }],
4563
+ * query: "How does caching work?",
4226
4564
  * });
4227
4565
  *
4228
4566
  * // Via single instance binding
@@ -4234,7 +4572,7 @@ export declare abstract class AiSearchJobs {
4234
4572
  export declare abstract class AiSearchInstance {
4235
4573
  /**
4236
4574
  * Search the AI Search instance for relevant chunks.
4237
- * @param params Search request with messages and optional AI search options.
4575
+ * @param params Search request with query or messages and optional AI search options.
4238
4576
  * @returns Search response with matching chunks and search query.
4239
4577
  */
4240
4578
  search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
@@ -4266,7 +4604,7 @@ export declare abstract class AiSearchInstance {
4266
4604
  info(): Promise<AiSearchInstanceInfo>;
4267
4605
  /**
4268
4606
  * Get instance statistics (item count, indexing status, etc.).
4269
- * @returns Statistics with counts per status and last activity time.
4607
+ * @returns Statistics with counts per status, last activity time, and engine details.
4270
4608
  */
4271
4609
  stats(): Promise<AiSearchStatsResponse>;
4272
4610
  /** Items collection — list, upload, and manage items in this instance. */
@@ -4278,27 +4616,30 @@ export declare abstract class AiSearchInstance {
4278
4616
  * Namespace-level AI Search service.
4279
4617
  *
4280
4618
  * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
4281
- * Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
4619
+ * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
4620
+ * and multi-instance search/chat operations.
4282
4621
  *
4283
4622
  * @example
4284
4623
  * ```ts
4285
4624
  * // Access an instance within the namespace
4286
4625
  * const blog = env.AI_SEARCH.get("blog");
4287
- * const results = await blog.search({
4288
- * messages: [{ role: "user", content: "How does caching work?" }],
4289
- * });
4626
+ * const results = await blog.search({ query: "How does caching work?" });
4290
4627
  *
4291
4628
  * // List all instances in the namespace
4292
4629
  * const instances = await env.AI_SEARCH.list();
4293
4630
  *
4294
4631
  * // Create a new instance with built-in storage
4295
- * const tenant = await env.AI_SEARCH.create({
4296
- * id: "tenant-123",
4297
- * });
4632
+ * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
4298
4633
  *
4299
4634
  * // Upload items into the instance
4300
4635
  * await tenant.items.upload("doc.pdf", fileContent);
4301
4636
  *
4637
+ * // Search across multiple instances
4638
+ * const multi = await env.AI_SEARCH.search({
4639
+ * query: "caching",
4640
+ * ai_search_options: { instance_ids: ["blog", "docs"] },
4641
+ * });
4642
+ *
4302
4643
  * // Delete an instance
4303
4644
  * await env.AI_SEARCH.delete("tenant-123");
4304
4645
  * ```
@@ -4311,10 +4652,11 @@ export declare abstract class AiSearchNamespace {
4311
4652
  */
4312
4653
  get(name: string): AiSearchInstance;
4313
4654
  /**
4314
- * List all instances in the bound namespace.
4315
- * @returns Array of instance metadata.
4655
+ * List instances in the bound namespace.
4656
+ * @param params Optional pagination, search, and ordering parameters.
4657
+ * @returns Array of instance metadata with pagination info.
4316
4658
  */
4317
- list(): Promise<AiSearchListResponse>;
4659
+ list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
4318
4660
  /**
4319
4661
  * Create a new instance within the bound namespace.
4320
4662
  * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
@@ -4339,6 +4681,35 @@ export declare abstract class AiSearchNamespace {
4339
4681
  * @param name Instance name to delete.
4340
4682
  */
4341
4683
  delete(name: string): Promise<void>;
4684
+ /**
4685
+ * Search across multiple instances within the bound namespace.
4686
+ * Fans out to the specified instance_ids and merges results.
4687
+ * @param params Search request with required `ai_search_options.instance_ids`.
4688
+ * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
4689
+ */
4690
+ search(
4691
+ params: AiSearchMultiSearchRequest,
4692
+ ): Promise<AiSearchMultiSearchResponse>;
4693
+ /**
4694
+ * Generate chat completions across multiple instances within the bound namespace (streaming).
4695
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4696
+ * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
4697
+ * @returns ReadableStream of server-sent events.
4698
+ */
4699
+ chatCompletions(
4700
+ params: AiSearchMultiChatCompletionsRequest & {
4701
+ stream: true;
4702
+ },
4703
+ ): Promise<ReadableStream>;
4704
+ /**
4705
+ * Generate chat completions across multiple instances within the bound namespace.
4706
+ * Fans out to the specified instance_ids, merges context, and generates a response.
4707
+ * @param params Chat completions request with required `ai_search_options.instance_ids`.
4708
+ * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
4709
+ */
4710
+ chatCompletions(
4711
+ params: AiSearchMultiChatCompletionsRequest,
4712
+ ): Promise<AiSearchMultiChatCompletionsResponse>;
4342
4713
  }
4343
4714
  export type AiImageClassificationInput = {
4344
4715
  image: number[];
@@ -12000,8 +12371,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12000
12371
  * Evaluation context for targeting rules.
12001
12372
  * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12002
12373
  */
12003
- export type EvaluationContext = Record<string, string | number | boolean>;
12004
- export interface EvaluationDetails<T> {
12374
+ export type FlagshipEvaluationContext = Record<
12375
+ string,
12376
+ string | number | boolean
12377
+ >;
12378
+ export interface FlagshipEvaluationDetails<T> {
12005
12379
  flagKey: string;
12006
12380
  value: T;
12007
12381
  variant?: string | undefined;
@@ -12009,7 +12383,7 @@ export interface EvaluationDetails<T> {
12009
12383
  errorCode?: string | undefined;
12010
12384
  errorMessage?: string | undefined;
12011
12385
  }
12012
- export interface FlagEvaluationError extends Error {}
12386
+ export interface FlagshipEvaluationError extends Error {}
12013
12387
  /**
12014
12388
  * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12015
12389
  *
@@ -12029,7 +12403,7 @@ export interface FlagEvaluationError extends Error {}
12029
12403
  * console.log(details.variant, details.reason);
12030
12404
  * ```
12031
12405
  */
12032
- export declare abstract class Flags {
12406
+ export declare abstract class Flagship {
12033
12407
  /**
12034
12408
  * Get a flag value without type checking.
12035
12409
  * @param flagKey The key of the flag to evaluate.
@@ -12039,7 +12413,7 @@ export declare abstract class Flags {
12039
12413
  get(
12040
12414
  flagKey: string,
12041
12415
  defaultValue?: unknown,
12042
- context?: EvaluationContext,
12416
+ context?: FlagshipEvaluationContext,
12043
12417
  ): Promise<unknown>;
12044
12418
  /**
12045
12419
  * Get a boolean flag value.
@@ -12050,7 +12424,7 @@ export declare abstract class Flags {
12050
12424
  getBooleanValue(
12051
12425
  flagKey: string,
12052
12426
  defaultValue: boolean,
12053
- context?: EvaluationContext,
12427
+ context?: FlagshipEvaluationContext,
12054
12428
  ): Promise<boolean>;
12055
12429
  /**
12056
12430
  * Get a string flag value.
@@ -12061,7 +12435,7 @@ export declare abstract class Flags {
12061
12435
  getStringValue(
12062
12436
  flagKey: string,
12063
12437
  defaultValue: string,
12064
- context?: EvaluationContext,
12438
+ context?: FlagshipEvaluationContext,
12065
12439
  ): Promise<string>;
12066
12440
  /**
12067
12441
  * Get a number flag value.
@@ -12072,7 +12446,7 @@ export declare abstract class Flags {
12072
12446
  getNumberValue(
12073
12447
  flagKey: string,
12074
12448
  defaultValue: number,
12075
- context?: EvaluationContext,
12449
+ context?: FlagshipEvaluationContext,
12076
12450
  ): Promise<number>;
12077
12451
  /**
12078
12452
  * Get an object flag value.
@@ -12083,7 +12457,7 @@ export declare abstract class Flags {
12083
12457
  getObjectValue<T extends object>(
12084
12458
  flagKey: string,
12085
12459
  defaultValue: T,
12086
- context?: EvaluationContext,
12460
+ context?: FlagshipEvaluationContext,
12087
12461
  ): Promise<T>;
12088
12462
  /**
12089
12463
  * Get a boolean flag value with full evaluation details.
@@ -12094,8 +12468,8 @@ export declare abstract class Flags {
12094
12468
  getBooleanDetails(
12095
12469
  flagKey: string,
12096
12470
  defaultValue: boolean,
12097
- context?: EvaluationContext,
12098
- ): Promise<EvaluationDetails<boolean>>;
12471
+ context?: FlagshipEvaluationContext,
12472
+ ): Promise<FlagshipEvaluationDetails<boolean>>;
12099
12473
  /**
12100
12474
  * Get a string flag value with full evaluation details.
12101
12475
  * @param flagKey The key of the flag to evaluate.
@@ -12105,8 +12479,8 @@ export declare abstract class Flags {
12105
12479
  getStringDetails(
12106
12480
  flagKey: string,
12107
12481
  defaultValue: string,
12108
- context?: EvaluationContext,
12109
- ): Promise<EvaluationDetails<string>>;
12482
+ context?: FlagshipEvaluationContext,
12483
+ ): Promise<FlagshipEvaluationDetails<string>>;
12110
12484
  /**
12111
12485
  * Get a number flag value with full evaluation details.
12112
12486
  * @param flagKey The key of the flag to evaluate.
@@ -12116,8 +12490,8 @@ export declare abstract class Flags {
12116
12490
  getNumberDetails(
12117
12491
  flagKey: string,
12118
12492
  defaultValue: number,
12119
- context?: EvaluationContext,
12120
- ): Promise<EvaluationDetails<number>>;
12493
+ context?: FlagshipEvaluationContext,
12494
+ ): Promise<FlagshipEvaluationDetails<number>>;
12121
12495
  /**
12122
12496
  * Get an object flag value with full evaluation details.
12123
12497
  * @param flagKey The key of the flag to evaluate.
@@ -12127,8 +12501,8 @@ export declare abstract class Flags {
12127
12501
  getObjectDetails<T extends object>(
12128
12502
  flagKey: string,
12129
12503
  defaultValue: T,
12130
- context?: EvaluationContext,
12131
- ): Promise<EvaluationDetails<T>>;
12504
+ context?: FlagshipEvaluationContext,
12505
+ ): Promise<FlagshipEvaluationDetails<T>>;
12132
12506
  }
12133
12507
  /**
12134
12508
  * Hello World binding to serve as an explanatory example. DO NOT USE