@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/2021-11-03/index.d.ts +480 -110
- package/2021-11-03/index.ts +483 -109
- package/2022-01-31/index.d.ts +480 -110
- package/2022-01-31/index.ts +483 -109
- package/2022-03-21/index.d.ts +481 -110
- package/2022-03-21/index.ts +484 -109
- package/2022-08-04/index.d.ts +481 -110
- package/2022-08-04/index.ts +484 -109
- package/2022-10-31/index.d.ts +481 -110
- package/2022-10-31/index.ts +484 -109
- package/2022-11-30/index.d.ts +481 -110
- package/2022-11-30/index.ts +484 -109
- package/2023-03-01/index.d.ts +481 -110
- package/2023-03-01/index.ts +484 -109
- package/2023-07-01/index.d.ts +481 -110
- package/2023-07-01/index.ts +484 -109
- package/experimental/index.d.ts +442 -109
- package/experimental/index.ts +445 -108
- package/index.d.ts +480 -110
- package/index.ts +483 -109
- package/latest/index.d.ts +481 -110
- package/latest/index.ts +484 -109
- package/oldest/index.d.ts +480 -110
- package/oldest/index.ts +483 -109
- package/package.json +1 -1
package/experimental/index.d.ts
CHANGED
|
@@ -574,6 +574,7 @@ declare abstract class Navigator {
|
|
|
574
574
|
sendBeacon(url: string, body?: BodyInit): boolean;
|
|
575
575
|
readonly userAgent: string;
|
|
576
576
|
readonly hardwareConcurrency: number;
|
|
577
|
+
readonly platform: string;
|
|
577
578
|
readonly language: string;
|
|
578
579
|
readonly languages: string[];
|
|
579
580
|
readonly storage: StorageManager;
|
|
@@ -2417,12 +2418,12 @@ interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
2417
2418
|
}
|
|
2418
2419
|
type QueueContentType = "text" | "bytes" | "json" | "v8";
|
|
2419
2420
|
interface Queue<Body = unknown> {
|
|
2421
|
+
metrics(): Promise<QueueMetrics>;
|
|
2420
2422
|
send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
|
|
2421
2423
|
sendBatch(
|
|
2422
2424
|
messages: Iterable<MessageSendRequest<Body>>,
|
|
2423
2425
|
options?: QueueSendBatchOptions,
|
|
2424
2426
|
): Promise<QueueSendBatchResponse>;
|
|
2425
|
-
metrics(): Promise<QueueMetrics>;
|
|
2426
2427
|
}
|
|
2427
2428
|
interface QueueSendMetrics {
|
|
2428
2429
|
backlogCount: number;
|
|
@@ -4710,73 +4711,145 @@ interface EventCounts {
|
|
|
4710
4711
|
// ============ AI Search Error Interfaces ============
|
|
4711
4712
|
interface AiSearchInternalError extends Error {}
|
|
4712
4713
|
interface AiSearchNotFoundError extends Error {}
|
|
4713
|
-
// ============ AI Search
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4714
|
+
// ============ AI Search Common Types ============
|
|
4715
|
+
/** A single message in a conversation-style search or chat request. */
|
|
4716
|
+
type AiSearchMessage = {
|
|
4717
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4718
|
+
content: string | null;
|
|
4719
|
+
};
|
|
4720
|
+
/**
|
|
4721
|
+
* Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
|
|
4722
|
+
* Contains retrieval, query rewrite, reranking, and cache sub-options.
|
|
4723
|
+
*/
|
|
4724
|
+
type AiSearchOptions = {
|
|
4725
|
+
retrieval?: {
|
|
4726
|
+
/** Which retrieval backend to use. Defaults to the instance's configured index_method. */
|
|
4727
|
+
retrieval_type?: "vector" | "keyword" | "hybrid";
|
|
4728
|
+
/** Fusion method for combining vector + keyword results. */
|
|
4729
|
+
fusion_method?: "max" | "rrf";
|
|
4730
|
+
/** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
|
|
4731
|
+
keyword_match_mode?: "and" | "or";
|
|
4732
|
+
/** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
|
|
4733
|
+
match_threshold?: number;
|
|
4734
|
+
/** Maximum number of results to return (1-50). Default 10. */
|
|
4735
|
+
max_num_results?: number;
|
|
4736
|
+
/** Vectorize metadata filters applied to the search. */
|
|
4737
|
+
filters?: VectorizeVectorMetadataFilter;
|
|
4738
|
+
/** Number of surrounding chunks to include for context (0-3). Default 0. */
|
|
4739
|
+
context_expansion?: number;
|
|
4740
|
+
/** If true, return only item metadata without chunk text. */
|
|
4741
|
+
metadata_only?: boolean;
|
|
4742
|
+
/** If true (default), return empty results on retrieval failure instead of throwing. */
|
|
4743
|
+
return_on_failure?: boolean;
|
|
4744
|
+
/** Boost results by metadata field values. Max 3 entries. */
|
|
4745
|
+
boost_by?: Array<{
|
|
4746
|
+
field: string;
|
|
4747
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
4748
|
+
}>;
|
|
4749
|
+
[key: string]: unknown;
|
|
4750
|
+
};
|
|
4751
|
+
query_rewrite?: {
|
|
4752
|
+
enabled?: boolean;
|
|
4753
|
+
model?: string;
|
|
4754
|
+
rewrite_prompt?: string;
|
|
4755
|
+
[key: string]: unknown;
|
|
4756
|
+
};
|
|
4757
|
+
reranking?: {
|
|
4758
|
+
enabled?: boolean;
|
|
4759
|
+
model?: string;
|
|
4760
|
+
/** Match threshold (0-1, default 0.4) */
|
|
4761
|
+
match_threshold?: number;
|
|
4744
4762
|
[key: string]: unknown;
|
|
4745
4763
|
};
|
|
4764
|
+
cache?: {
|
|
4765
|
+
enabled?: boolean;
|
|
4766
|
+
cache_threshold?:
|
|
4767
|
+
| "super_strict_match"
|
|
4768
|
+
| "close_enough"
|
|
4769
|
+
| "flexible_friend"
|
|
4770
|
+
| "anything_goes";
|
|
4771
|
+
};
|
|
4772
|
+
[key: string]: unknown;
|
|
4746
4773
|
};
|
|
4774
|
+
// ============ AI Search Request Types ============
|
|
4775
|
+
/**
|
|
4776
|
+
* Request body for single-instance search.
|
|
4777
|
+
* Exactly one of `query` or `messages` must be provided.
|
|
4778
|
+
*/
|
|
4779
|
+
type AiSearchSearchRequest =
|
|
4780
|
+
| {
|
|
4781
|
+
/** Simple query string. */
|
|
4782
|
+
query: string;
|
|
4783
|
+
messages?: never;
|
|
4784
|
+
ai_search_options?: AiSearchOptions;
|
|
4785
|
+
}
|
|
4786
|
+
| {
|
|
4787
|
+
query?: never;
|
|
4788
|
+
/** Conversation-style input. At least one user message with non-empty content is required. */
|
|
4789
|
+
messages: AiSearchMessage[];
|
|
4790
|
+
ai_search_options?: AiSearchOptions;
|
|
4791
|
+
};
|
|
4747
4792
|
type AiSearchChatCompletionsRequest = {
|
|
4748
|
-
messages:
|
|
4749
|
-
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4750
|
-
content: string | null;
|
|
4751
|
-
[key: string]: unknown;
|
|
4752
|
-
}>;
|
|
4793
|
+
messages: AiSearchMessage[];
|
|
4753
4794
|
model?: string;
|
|
4754
4795
|
stream?: boolean;
|
|
4755
|
-
ai_search_options?:
|
|
4756
|
-
retrieval?: {
|
|
4757
|
-
retrieval_type?: "vector" | "keyword" | "hybrid";
|
|
4758
|
-
match_threshold?: number;
|
|
4759
|
-
max_num_results?: number;
|
|
4760
|
-
filters?: VectorizeVectorMetadataFilter;
|
|
4761
|
-
context_expansion?: number;
|
|
4762
|
-
[key: string]: unknown;
|
|
4763
|
-
};
|
|
4764
|
-
query_rewrite?: {
|
|
4765
|
-
enabled?: boolean;
|
|
4766
|
-
model?: string;
|
|
4767
|
-
rewrite_prompt?: string;
|
|
4768
|
-
[key: string]: unknown;
|
|
4769
|
-
};
|
|
4770
|
-
reranking?: {
|
|
4771
|
-
enabled?: boolean;
|
|
4772
|
-
model?: "@cf/baai/bge-reranker-base" | string;
|
|
4773
|
-
match_threshold?: number;
|
|
4774
|
-
[key: string]: unknown;
|
|
4775
|
-
};
|
|
4776
|
-
[key: string]: unknown;
|
|
4777
|
-
};
|
|
4796
|
+
ai_search_options?: AiSearchOptions;
|
|
4778
4797
|
[key: string]: unknown;
|
|
4779
4798
|
};
|
|
4799
|
+
// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
|
|
4800
|
+
/** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
|
|
4801
|
+
type AiSearchMultiSearchOptions = AiSearchOptions & {
|
|
4802
|
+
/** Instance IDs to search across (1-10). */
|
|
4803
|
+
instance_ids: string[];
|
|
4804
|
+
};
|
|
4805
|
+
/**
|
|
4806
|
+
* Request for searching across multiple instances within a namespace.
|
|
4807
|
+
* `ai_search_options` is required and must include `instance_ids`.
|
|
4808
|
+
* Exactly one of `query` or `messages` must be provided.
|
|
4809
|
+
*/
|
|
4810
|
+
type AiSearchMultiSearchRequest =
|
|
4811
|
+
| {
|
|
4812
|
+
/** Simple query string. */
|
|
4813
|
+
query: string;
|
|
4814
|
+
messages?: never;
|
|
4815
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4816
|
+
}
|
|
4817
|
+
| {
|
|
4818
|
+
query?: never;
|
|
4819
|
+
/** Conversation-style input. */
|
|
4820
|
+
messages: AiSearchMessage[];
|
|
4821
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4822
|
+
};
|
|
4823
|
+
/** A search result chunk tagged with the instance it originated from. */
|
|
4824
|
+
type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
|
|
4825
|
+
instance_id: string;
|
|
4826
|
+
};
|
|
4827
|
+
/** Describes a per-instance error during a multi-instance operation. */
|
|
4828
|
+
type AiSearchMultiSearchError = {
|
|
4829
|
+
instance_id: string;
|
|
4830
|
+
message: string;
|
|
4831
|
+
};
|
|
4832
|
+
/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
|
|
4833
|
+
type AiSearchMultiSearchResponse = {
|
|
4834
|
+
search_query: string;
|
|
4835
|
+
chunks: AiSearchMultiSearchChunk[];
|
|
4836
|
+
errors?: AiSearchMultiSearchError[];
|
|
4837
|
+
};
|
|
4838
|
+
/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
|
|
4839
|
+
type AiSearchMultiChatCompletionsRequest = Omit<
|
|
4840
|
+
AiSearchChatCompletionsRequest,
|
|
4841
|
+
"ai_search_options"
|
|
4842
|
+
> & {
|
|
4843
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4844
|
+
};
|
|
4845
|
+
/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
|
|
4846
|
+
type AiSearchMultiChatCompletionsResponse = Omit<
|
|
4847
|
+
AiSearchChatCompletionsResponse,
|
|
4848
|
+
"chunks"
|
|
4849
|
+
> & {
|
|
4850
|
+
chunks: AiSearchMultiSearchChunk[];
|
|
4851
|
+
errors?: AiSearchMultiSearchError[];
|
|
4852
|
+
};
|
|
4780
4853
|
// ============ AI Search Response Types ============
|
|
4781
4854
|
type AiSearchSearchResponse = {
|
|
4782
4855
|
search_query: string;
|
|
@@ -4796,6 +4869,14 @@ type AiSearchSearchResponse = {
|
|
|
4796
4869
|
keyword_score?: number;
|
|
4797
4870
|
/** Vector similarity score (0-1) */
|
|
4798
4871
|
vector_score?: number;
|
|
4872
|
+
/** Keyword rank position */
|
|
4873
|
+
keyword_rank?: number;
|
|
4874
|
+
/** Vector rank position */
|
|
4875
|
+
vector_rank?: number;
|
|
4876
|
+
/** Reranking model score */
|
|
4877
|
+
reranking_score?: number;
|
|
4878
|
+
/** Fusion method used to combine results */
|
|
4879
|
+
fusion_method?: "rrf" | "max";
|
|
4799
4880
|
[key: string]: unknown;
|
|
4800
4881
|
};
|
|
4801
4882
|
}>;
|
|
@@ -4824,19 +4905,88 @@ type AiSearchStatsResponse = {
|
|
|
4824
4905
|
skipped?: number;
|
|
4825
4906
|
outdated?: number;
|
|
4826
4907
|
last_activity?: string;
|
|
4908
|
+
/** Storage engine statistics. */
|
|
4909
|
+
engine?: {
|
|
4910
|
+
vectorize?: {
|
|
4911
|
+
vectorsCount: number;
|
|
4912
|
+
dimensions: number;
|
|
4913
|
+
};
|
|
4914
|
+
r2?: {
|
|
4915
|
+
payloadSizeBytes: number;
|
|
4916
|
+
metadataSizeBytes: number;
|
|
4917
|
+
objectCount: number;
|
|
4918
|
+
};
|
|
4919
|
+
};
|
|
4827
4920
|
};
|
|
4828
4921
|
// ============ AI Search Instance Info Types ============
|
|
4829
4922
|
type AiSearchInstanceInfo = {
|
|
4830
4923
|
id: string;
|
|
4831
4924
|
type?: "r2" | "web-crawler" | string;
|
|
4832
4925
|
source?: string;
|
|
4926
|
+
source_params?: unknown;
|
|
4833
4927
|
paused?: boolean;
|
|
4834
4928
|
status?: string;
|
|
4835
4929
|
namespace?: string;
|
|
4836
4930
|
created_at?: string;
|
|
4837
4931
|
modified_at?: string;
|
|
4932
|
+
token_id?: string;
|
|
4933
|
+
ai_gateway_id?: string;
|
|
4934
|
+
rewrite_query?: boolean;
|
|
4935
|
+
reranking?: boolean;
|
|
4936
|
+
embedding_model?: string;
|
|
4937
|
+
ai_search_model?: string;
|
|
4938
|
+
rewrite_model?: string;
|
|
4939
|
+
reranking_model?: string;
|
|
4940
|
+
/** @deprecated Use index_method instead. */
|
|
4941
|
+
hybrid_search_enabled?: boolean;
|
|
4942
|
+
/** Controls which storage backends are active. */
|
|
4943
|
+
index_method?: {
|
|
4944
|
+
vector?: boolean;
|
|
4945
|
+
keyword?: boolean;
|
|
4946
|
+
};
|
|
4947
|
+
/** Fusion method for combining vector and keyword results. */
|
|
4948
|
+
fusion_method?: "max" | "rrf";
|
|
4949
|
+
indexing_options?: {
|
|
4950
|
+
keyword_tokenizer?: "porter" | "trigram";
|
|
4951
|
+
} | null;
|
|
4952
|
+
retrieval_options?: {
|
|
4953
|
+
keyword_match_mode?: "and" | "or";
|
|
4954
|
+
boost_by?: Array<{
|
|
4955
|
+
field: string;
|
|
4956
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
4957
|
+
}>;
|
|
4958
|
+
} | null;
|
|
4959
|
+
chunk?: boolean;
|
|
4960
|
+
chunk_size?: number;
|
|
4961
|
+
chunk_overlap?: number;
|
|
4962
|
+
score_threshold?: number;
|
|
4963
|
+
max_num_results?: number;
|
|
4964
|
+
cache?: boolean;
|
|
4965
|
+
cache_threshold?:
|
|
4966
|
+
| "super_strict_match"
|
|
4967
|
+
| "close_enough"
|
|
4968
|
+
| "flexible_friend"
|
|
4969
|
+
| "anything_goes";
|
|
4970
|
+
custom_metadata?: Array<{
|
|
4971
|
+
field_name: string;
|
|
4972
|
+
data_type: "text" | "number" | "boolean" | "datetime";
|
|
4973
|
+
}>;
|
|
4974
|
+
/** Sync interval in seconds. */
|
|
4975
|
+
sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
|
|
4976
|
+
metadata?: Record<string, unknown>;
|
|
4838
4977
|
[key: string]: unknown;
|
|
4839
4978
|
};
|
|
4979
|
+
/** Pagination, search, and ordering parameters for listing instances within a namespace. */
|
|
4980
|
+
type AiSearchListInstancesParams = {
|
|
4981
|
+
page?: number;
|
|
4982
|
+
per_page?: number;
|
|
4983
|
+
/** Search instances by ID. */
|
|
4984
|
+
search?: string;
|
|
4985
|
+
/** Field to sort by. */
|
|
4986
|
+
order_by?: "created_at";
|
|
4987
|
+
/** Sort direction. */
|
|
4988
|
+
order_by_direction?: "asc" | "desc";
|
|
4989
|
+
};
|
|
4840
4990
|
type AiSearchListResponse = {
|
|
4841
4991
|
result: AiSearchInstanceInfo[];
|
|
4842
4992
|
result_info?: {
|
|
@@ -4864,19 +5014,64 @@ type AiSearchConfig = {
|
|
|
4864
5014
|
reranking?: boolean;
|
|
4865
5015
|
embedding_model?: string;
|
|
4866
5016
|
ai_search_model?: string;
|
|
5017
|
+
rewrite_model?: string;
|
|
5018
|
+
reranking_model?: string;
|
|
5019
|
+
/** @deprecated Use index_method instead. */
|
|
5020
|
+
hybrid_search_enabled?: boolean;
|
|
5021
|
+
/** Controls which storage backends are used during indexing. Defaults to vector-only. */
|
|
5022
|
+
index_method?: {
|
|
5023
|
+
vector?: boolean;
|
|
5024
|
+
keyword?: boolean;
|
|
5025
|
+
};
|
|
5026
|
+
/** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
|
|
5027
|
+
fusion_method?: "max" | "rrf";
|
|
5028
|
+
indexing_options?: {
|
|
5029
|
+
keyword_tokenizer?: "porter" | "trigram";
|
|
5030
|
+
} | null;
|
|
5031
|
+
retrieval_options?: {
|
|
5032
|
+
keyword_match_mode?: "and" | "or";
|
|
5033
|
+
boost_by?: Array<{
|
|
5034
|
+
field: string;
|
|
5035
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
5036
|
+
}>;
|
|
5037
|
+
} | null;
|
|
5038
|
+
chunk?: boolean;
|
|
5039
|
+
chunk_size?: number;
|
|
5040
|
+
chunk_overlap?: number;
|
|
5041
|
+
/** Minimum similarity score (0-1) for a result to be included. */
|
|
5042
|
+
score_threshold?: number;
|
|
5043
|
+
max_num_results?: number;
|
|
5044
|
+
cache?: boolean;
|
|
5045
|
+
/** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
|
|
5046
|
+
cache_threshold?:
|
|
5047
|
+
| "super_strict_match"
|
|
5048
|
+
| "close_enough"
|
|
5049
|
+
| "flexible_friend"
|
|
5050
|
+
| "anything_goes";
|
|
5051
|
+
custom_metadata?: Array<{
|
|
5052
|
+
field_name: string;
|
|
5053
|
+
data_type: "text" | "number" | "boolean" | "datetime";
|
|
5054
|
+
}>;
|
|
5055
|
+
namespace?: string;
|
|
5056
|
+
/** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
|
|
5057
|
+
sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
|
|
5058
|
+
metadata?: Record<string, unknown>;
|
|
4867
5059
|
[key: string]: unknown;
|
|
4868
5060
|
};
|
|
4869
5061
|
// ============ AI Search Item Types ============
|
|
4870
5062
|
type AiSearchItemInfo = {
|
|
4871
5063
|
id: string;
|
|
4872
5064
|
key: string;
|
|
4873
|
-
status:
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
5065
|
+
status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
|
|
5066
|
+
next_action?: "INDEX" | "DELETE" | null;
|
|
5067
|
+
error?: string;
|
|
5068
|
+
checksum?: string;
|
|
5069
|
+
namespace?: string;
|
|
5070
|
+
chunks_count?: number | null;
|
|
5071
|
+
file_size?: number | null;
|
|
5072
|
+
source_id?: string | null;
|
|
5073
|
+
last_seen_at?: string;
|
|
5074
|
+
created_at?: string;
|
|
4880
5075
|
metadata?: Record<string, unknown>;
|
|
4881
5076
|
[key: string]: unknown;
|
|
4882
5077
|
};
|
|
@@ -4892,6 +5087,22 @@ type AiSearchUploadItemOptions = {
|
|
|
4892
5087
|
type AiSearchListItemsParams = {
|
|
4893
5088
|
page?: number;
|
|
4894
5089
|
per_page?: number;
|
|
5090
|
+
/** Search items by key name. */
|
|
5091
|
+
search?: string;
|
|
5092
|
+
/** Sort order for results. */
|
|
5093
|
+
sort_by?: "status" | "modified_at";
|
|
5094
|
+
/** Filter items by processing status. */
|
|
5095
|
+
status?:
|
|
5096
|
+
| "queued"
|
|
5097
|
+
| "running"
|
|
5098
|
+
| "completed"
|
|
5099
|
+
| "error"
|
|
5100
|
+
| "skipped"
|
|
5101
|
+
| "outdated";
|
|
5102
|
+
/** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
|
|
5103
|
+
source?: string;
|
|
5104
|
+
/** JSON-encoded Vectorize filter for metadata filtering. */
|
|
5105
|
+
metadata_filter?: string;
|
|
4895
5106
|
};
|
|
4896
5107
|
type AiSearchListItemsResponse = {
|
|
4897
5108
|
result: AiSearchItemInfo[];
|
|
@@ -4902,6 +5113,61 @@ type AiSearchListItemsResponse = {
|
|
|
4902
5113
|
total_count: number;
|
|
4903
5114
|
};
|
|
4904
5115
|
};
|
|
5116
|
+
// ============ AI Search Item Logs Types ============
|
|
5117
|
+
type AiSearchItemLogsParams = {
|
|
5118
|
+
/** Maximum number of log entries to return (1-100, default 50). */
|
|
5119
|
+
limit?: number;
|
|
5120
|
+
/** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
|
|
5121
|
+
cursor?: string;
|
|
5122
|
+
};
|
|
5123
|
+
type AiSearchItemLog = {
|
|
5124
|
+
timestamp: string;
|
|
5125
|
+
action: string;
|
|
5126
|
+
message: string;
|
|
5127
|
+
fileKey?: string;
|
|
5128
|
+
chunkCount?: number;
|
|
5129
|
+
processingTimeMs?: number;
|
|
5130
|
+
errorType?: string;
|
|
5131
|
+
};
|
|
5132
|
+
/** Paginated response for item processing logs (cursor-based). */
|
|
5133
|
+
type AiSearchItemLogsResponse = {
|
|
5134
|
+
result: AiSearchItemLog[];
|
|
5135
|
+
result_info: {
|
|
5136
|
+
count: number;
|
|
5137
|
+
per_page: number;
|
|
5138
|
+
cursor: string | null;
|
|
5139
|
+
truncated: boolean;
|
|
5140
|
+
};
|
|
5141
|
+
};
|
|
5142
|
+
// ============ AI Search Item Chunks Types ============
|
|
5143
|
+
type AiSearchItemChunksParams = {
|
|
5144
|
+
/** Maximum number of chunks to return (1-100, default 20). */
|
|
5145
|
+
limit?: number;
|
|
5146
|
+
/** Offset into the chunks list (default 0). */
|
|
5147
|
+
offset?: number;
|
|
5148
|
+
};
|
|
5149
|
+
/** A single indexed chunk belonging to an item, including its text content and byte range. */
|
|
5150
|
+
type AiSearchItemChunk = {
|
|
5151
|
+
id: string;
|
|
5152
|
+
text: string;
|
|
5153
|
+
start_byte: number;
|
|
5154
|
+
end_byte: number;
|
|
5155
|
+
item?: {
|
|
5156
|
+
timestamp?: number;
|
|
5157
|
+
key: string;
|
|
5158
|
+
metadata?: Record<string, unknown>;
|
|
5159
|
+
};
|
|
5160
|
+
};
|
|
5161
|
+
/** Paginated response for item chunks (offset-based). */
|
|
5162
|
+
type AiSearchItemChunksResponse = {
|
|
5163
|
+
result: AiSearchItemChunk[];
|
|
5164
|
+
result_info: {
|
|
5165
|
+
count: number;
|
|
5166
|
+
total: number;
|
|
5167
|
+
limit: number;
|
|
5168
|
+
offset: number;
|
|
5169
|
+
};
|
|
5170
|
+
};
|
|
4905
5171
|
// ============ AI Search Job Types ============
|
|
4906
5172
|
type AiSearchJobInfo = {
|
|
4907
5173
|
id: string;
|
|
@@ -4950,7 +5216,7 @@ type AiSearchJobLogsResponse = {
|
|
|
4950
5216
|
// ============ AI Search Sub-Service Classes ============
|
|
4951
5217
|
/**
|
|
4952
5218
|
* Single item service for an AI Search instance.
|
|
4953
|
-
* Provides info,
|
|
5219
|
+
* Provides info, download, sync, logs, and chunks operations on a specific item.
|
|
4954
5220
|
*/
|
|
4955
5221
|
declare abstract class AiSearchItem {
|
|
4956
5222
|
/** Get metadata about this item. */
|
|
@@ -4960,6 +5226,25 @@ declare abstract class AiSearchItem {
|
|
|
4960
5226
|
* @returns Object with body stream, content type, filename, and size.
|
|
4961
5227
|
*/
|
|
4962
5228
|
download(): Promise<AiSearchItemContentResult>;
|
|
5229
|
+
/**
|
|
5230
|
+
* Trigger re-indexing of this item.
|
|
5231
|
+
* @returns The updated item info.
|
|
5232
|
+
*/
|
|
5233
|
+
sync(): Promise<AiSearchItemInfo>;
|
|
5234
|
+
/**
|
|
5235
|
+
* Retrieve processing logs for this item (cursor-based pagination).
|
|
5236
|
+
* @param params Optional pagination parameters (limit, cursor).
|
|
5237
|
+
* @returns Paginated log entries for this item.
|
|
5238
|
+
*/
|
|
5239
|
+
logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
|
|
5240
|
+
/**
|
|
5241
|
+
* List indexed chunks for this item (offset-based pagination).
|
|
5242
|
+
* @param params Optional pagination parameters (limit, offset).
|
|
5243
|
+
* @returns Paginated chunk entries for this item.
|
|
5244
|
+
*/
|
|
5245
|
+
chunks(
|
|
5246
|
+
params?: AiSearchItemChunksParams,
|
|
5247
|
+
): Promise<AiSearchItemChunksResponse>;
|
|
4963
5248
|
}
|
|
4964
5249
|
/**
|
|
4965
5250
|
* Items collection service for an AI Search instance.
|
|
@@ -4969,49 +5254,64 @@ declare abstract class AiSearchItems {
|
|
|
4969
5254
|
/** List items in this instance. */
|
|
4970
5255
|
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4971
5256
|
/**
|
|
4972
|
-
* Upload a file as an item.
|
|
5257
|
+
* Upload a file as an item. Behaves as an upsert: if an item with the same
|
|
5258
|
+
* filename already exists, it is overwritten and re-indexed.
|
|
4973
5259
|
* @param name Filename for the uploaded item.
|
|
4974
|
-
* @param content File content as a ReadableStream,
|
|
5260
|
+
* @param content File content as a ReadableStream, Blob, or string.
|
|
4975
5261
|
* @param options Optional metadata to attach to the item.
|
|
4976
5262
|
* @returns The created item info.
|
|
4977
5263
|
*/
|
|
4978
5264
|
upload(
|
|
4979
5265
|
name: string,
|
|
4980
|
-
content: ReadableStream |
|
|
5266
|
+
content: ReadableStream | Blob | string,
|
|
4981
5267
|
options?: AiSearchUploadItemOptions,
|
|
4982
5268
|
): Promise<AiSearchItemInfo>;
|
|
4983
5269
|
/**
|
|
4984
5270
|
* Upload a file and poll until processing completes.
|
|
5271
|
+
* Behaves as an upsert: if an item with the same filename already exists,
|
|
5272
|
+
* it is overwritten and re-indexed.
|
|
4985
5273
|
* @param name Filename for the uploaded item.
|
|
4986
|
-
* @param content File content as a ReadableStream,
|
|
4987
|
-
* @param options Optional metadata
|
|
5274
|
+
* @param content File content as a ReadableStream, Blob, or string.
|
|
5275
|
+
* @param options Optional metadata and polling configuration.
|
|
4988
5276
|
* @returns The item info after processing completes (or timeout).
|
|
4989
5277
|
*/
|
|
4990
5278
|
uploadAndPoll(
|
|
4991
5279
|
name: string,
|
|
4992
|
-
content: ReadableStream |
|
|
4993
|
-
options?: AiSearchUploadItemOptions
|
|
5280
|
+
content: ReadableStream | Blob | string,
|
|
5281
|
+
options?: AiSearchUploadItemOptions & {
|
|
5282
|
+
/** Polling interval in milliseconds (default 1000). */
|
|
5283
|
+
pollIntervalMs?: number;
|
|
5284
|
+
/** Maximum time to wait in milliseconds (default 30000). */
|
|
5285
|
+
timeoutMs?: number;
|
|
5286
|
+
},
|
|
4994
5287
|
): Promise<AiSearchItemInfo>;
|
|
4995
5288
|
/**
|
|
4996
5289
|
* Get an item by ID.
|
|
4997
5290
|
* @param itemId The item identifier.
|
|
4998
|
-
* @returns Item service for info,
|
|
5291
|
+
* @returns Item service for info, download, sync, logs, and chunks operations.
|
|
4999
5292
|
*/
|
|
5000
5293
|
get(itemId: string): AiSearchItem;
|
|
5001
|
-
/**
|
|
5294
|
+
/**
|
|
5295
|
+
* Delete an item from the instance.
|
|
5002
5296
|
* @param itemId The item identifier.
|
|
5003
5297
|
*/
|
|
5004
5298
|
delete(itemId: string): Promise<void>;
|
|
5005
5299
|
}
|
|
5006
5300
|
/**
|
|
5007
5301
|
* Single job service for an AI Search instance.
|
|
5008
|
-
* Provides info and
|
|
5302
|
+
* Provides info, logs, and cancel operations for a specific job.
|
|
5009
5303
|
*/
|
|
5010
5304
|
declare abstract class AiSearchJob {
|
|
5011
5305
|
/** Get metadata about this job. */
|
|
5012
5306
|
info(): Promise<AiSearchJobInfo>;
|
|
5013
5307
|
/** Get logs for this job. */
|
|
5014
5308
|
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
5309
|
+
/**
|
|
5310
|
+
* Cancel a running job.
|
|
5311
|
+
* @returns The updated job info.
|
|
5312
|
+
* @throws AiSearchNotFoundError if the job does not exist.
|
|
5313
|
+
*/
|
|
5314
|
+
cancel(): Promise<AiSearchJobInfo>;
|
|
5015
5315
|
}
|
|
5016
5316
|
/**
|
|
5017
5317
|
* Jobs collection service for an AI Search instance.
|
|
@@ -5029,7 +5329,7 @@ declare abstract class AiSearchJobs {
|
|
|
5029
5329
|
/**
|
|
5030
5330
|
* Get a job by ID.
|
|
5031
5331
|
* @param jobId The job identifier.
|
|
5032
|
-
* @returns Job service for info and
|
|
5332
|
+
* @returns Job service for info, logs, and cancel operations.
|
|
5033
5333
|
*/
|
|
5034
5334
|
get(jobId: string): AiSearchJob;
|
|
5035
5335
|
}
|
|
@@ -5048,7 +5348,7 @@ declare abstract class AiSearchJobs {
|
|
|
5048
5348
|
* // Via namespace binding
|
|
5049
5349
|
* const instance = env.AI_SEARCH.get("blog");
|
|
5050
5350
|
* const results = await instance.search({
|
|
5051
|
-
*
|
|
5351
|
+
* query: "How does caching work?",
|
|
5052
5352
|
* });
|
|
5053
5353
|
*
|
|
5054
5354
|
* // Via single instance binding
|
|
@@ -5060,7 +5360,7 @@ declare abstract class AiSearchJobs {
|
|
|
5060
5360
|
declare abstract class AiSearchInstance {
|
|
5061
5361
|
/**
|
|
5062
5362
|
* Search the AI Search instance for relevant chunks.
|
|
5063
|
-
* @param params Search request with messages and optional AI search options.
|
|
5363
|
+
* @param params Search request with query or messages and optional AI search options.
|
|
5064
5364
|
* @returns Search response with matching chunks and search query.
|
|
5065
5365
|
*/
|
|
5066
5366
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
@@ -5092,7 +5392,7 @@ declare abstract class AiSearchInstance {
|
|
|
5092
5392
|
info(): Promise<AiSearchInstanceInfo>;
|
|
5093
5393
|
/**
|
|
5094
5394
|
* Get instance statistics (item count, indexing status, etc.).
|
|
5095
|
-
* @returns Statistics with counts per status
|
|
5395
|
+
* @returns Statistics with counts per status, last activity time, and engine details.
|
|
5096
5396
|
*/
|
|
5097
5397
|
stats(): Promise<AiSearchStatsResponse>;
|
|
5098
5398
|
/** Items collection — list, upload, and manage items in this instance. */
|
|
@@ -5104,27 +5404,30 @@ declare abstract class AiSearchInstance {
|
|
|
5104
5404
|
* Namespace-level AI Search service.
|
|
5105
5405
|
*
|
|
5106
5406
|
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
5107
|
-
* Scoped to a single namespace. Provides dynamic instance access, creation,
|
|
5407
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
|
|
5408
|
+
* and multi-instance search/chat operations.
|
|
5108
5409
|
*
|
|
5109
5410
|
* @example
|
|
5110
5411
|
* ```ts
|
|
5111
5412
|
* // Access an instance within the namespace
|
|
5112
5413
|
* const blog = env.AI_SEARCH.get("blog");
|
|
5113
|
-
* const results = await blog.search({
|
|
5114
|
-
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
5115
|
-
* });
|
|
5414
|
+
* const results = await blog.search({ query: "How does caching work?" });
|
|
5116
5415
|
*
|
|
5117
5416
|
* // List all instances in the namespace
|
|
5118
5417
|
* const instances = await env.AI_SEARCH.list();
|
|
5119
5418
|
*
|
|
5120
5419
|
* // Create a new instance with built-in storage
|
|
5121
|
-
* const tenant = await env.AI_SEARCH.create({
|
|
5122
|
-
* id: "tenant-123",
|
|
5123
|
-
* });
|
|
5420
|
+
* const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
|
|
5124
5421
|
*
|
|
5125
5422
|
* // Upload items into the instance
|
|
5126
5423
|
* await tenant.items.upload("doc.pdf", fileContent);
|
|
5127
5424
|
*
|
|
5425
|
+
* // Search across multiple instances
|
|
5426
|
+
* const multi = await env.AI_SEARCH.search({
|
|
5427
|
+
* query: "caching",
|
|
5428
|
+
* ai_search_options: { instance_ids: ["blog", "docs"] },
|
|
5429
|
+
* });
|
|
5430
|
+
*
|
|
5128
5431
|
* // Delete an instance
|
|
5129
5432
|
* await env.AI_SEARCH.delete("tenant-123");
|
|
5130
5433
|
* ```
|
|
@@ -5137,10 +5440,11 @@ declare abstract class AiSearchNamespace {
|
|
|
5137
5440
|
*/
|
|
5138
5441
|
get(name: string): AiSearchInstance;
|
|
5139
5442
|
/**
|
|
5140
|
-
* List
|
|
5141
|
-
* @
|
|
5443
|
+
* List instances in the bound namespace.
|
|
5444
|
+
* @param params Optional pagination, search, and ordering parameters.
|
|
5445
|
+
* @returns Array of instance metadata with pagination info.
|
|
5142
5446
|
*/
|
|
5143
|
-
list(): Promise<AiSearchListResponse>;
|
|
5447
|
+
list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
|
|
5144
5448
|
/**
|
|
5145
5449
|
* Create a new instance within the bound namespace.
|
|
5146
5450
|
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
@@ -5165,6 +5469,35 @@ declare abstract class AiSearchNamespace {
|
|
|
5165
5469
|
* @param name Instance name to delete.
|
|
5166
5470
|
*/
|
|
5167
5471
|
delete(name: string): Promise<void>;
|
|
5472
|
+
/**
|
|
5473
|
+
* Search across multiple instances within the bound namespace.
|
|
5474
|
+
* Fans out to the specified instance_ids and merges results.
|
|
5475
|
+
* @param params Search request with required `ai_search_options.instance_ids`.
|
|
5476
|
+
* @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
|
|
5477
|
+
*/
|
|
5478
|
+
search(
|
|
5479
|
+
params: AiSearchMultiSearchRequest,
|
|
5480
|
+
): Promise<AiSearchMultiSearchResponse>;
|
|
5481
|
+
/**
|
|
5482
|
+
* Generate chat completions across multiple instances within the bound namespace (streaming).
|
|
5483
|
+
* Fans out to the specified instance_ids, merges context, and generates a response.
|
|
5484
|
+
* @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
|
|
5485
|
+
* @returns ReadableStream of server-sent events.
|
|
5486
|
+
*/
|
|
5487
|
+
chatCompletions(
|
|
5488
|
+
params: AiSearchMultiChatCompletionsRequest & {
|
|
5489
|
+
stream: true;
|
|
5490
|
+
},
|
|
5491
|
+
): Promise<ReadableStream>;
|
|
5492
|
+
/**
|
|
5493
|
+
* Generate chat completions across multiple instances within the bound namespace.
|
|
5494
|
+
* Fans out to the specified instance_ids, merges context, and generates a response.
|
|
5495
|
+
* @param params Chat completions request with required `ai_search_options.instance_ids`.
|
|
5496
|
+
* @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
|
|
5497
|
+
*/
|
|
5498
|
+
chatCompletions(
|
|
5499
|
+
params: AiSearchMultiChatCompletionsRequest,
|
|
5500
|
+
): Promise<AiSearchMultiChatCompletionsResponse>;
|
|
5168
5501
|
}
|
|
5169
5502
|
type AiImageClassificationInput = {
|
|
5170
5503
|
image: number[];
|
|
@@ -12816,8 +13149,8 @@ declare module "cloudflare:email" {
|
|
|
12816
13149
|
* Evaluation context for targeting rules.
|
|
12817
13150
|
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12818
13151
|
*/
|
|
12819
|
-
type
|
|
12820
|
-
interface
|
|
13152
|
+
type FlagshipEvaluationContext = Record<string, string | number | boolean>;
|
|
13153
|
+
interface FlagshipEvaluationDetails<T> {
|
|
12821
13154
|
flagKey: string;
|
|
12822
13155
|
value: T;
|
|
12823
13156
|
variant?: string | undefined;
|
|
@@ -12825,7 +13158,7 @@ interface EvaluationDetails<T> {
|
|
|
12825
13158
|
errorCode?: string | undefined;
|
|
12826
13159
|
errorMessage?: string | undefined;
|
|
12827
13160
|
}
|
|
12828
|
-
interface
|
|
13161
|
+
interface FlagshipEvaluationError extends Error {}
|
|
12829
13162
|
/**
|
|
12830
13163
|
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12831
13164
|
*
|
|
@@ -12845,7 +13178,7 @@ interface FlagEvaluationError extends Error {}
|
|
|
12845
13178
|
* console.log(details.variant, details.reason);
|
|
12846
13179
|
* ```
|
|
12847
13180
|
*/
|
|
12848
|
-
declare abstract class
|
|
13181
|
+
declare abstract class Flagship {
|
|
12849
13182
|
/**
|
|
12850
13183
|
* Get a flag value without type checking.
|
|
12851
13184
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12855,7 +13188,7 @@ declare abstract class Flags {
|
|
|
12855
13188
|
get(
|
|
12856
13189
|
flagKey: string,
|
|
12857
13190
|
defaultValue?: unknown,
|
|
12858
|
-
context?:
|
|
13191
|
+
context?: FlagshipEvaluationContext,
|
|
12859
13192
|
): Promise<unknown>;
|
|
12860
13193
|
/**
|
|
12861
13194
|
* Get a boolean flag value.
|
|
@@ -12866,7 +13199,7 @@ declare abstract class Flags {
|
|
|
12866
13199
|
getBooleanValue(
|
|
12867
13200
|
flagKey: string,
|
|
12868
13201
|
defaultValue: boolean,
|
|
12869
|
-
context?:
|
|
13202
|
+
context?: FlagshipEvaluationContext,
|
|
12870
13203
|
): Promise<boolean>;
|
|
12871
13204
|
/**
|
|
12872
13205
|
* Get a string flag value.
|
|
@@ -12877,7 +13210,7 @@ declare abstract class Flags {
|
|
|
12877
13210
|
getStringValue(
|
|
12878
13211
|
flagKey: string,
|
|
12879
13212
|
defaultValue: string,
|
|
12880
|
-
context?:
|
|
13213
|
+
context?: FlagshipEvaluationContext,
|
|
12881
13214
|
): Promise<string>;
|
|
12882
13215
|
/**
|
|
12883
13216
|
* Get a number flag value.
|
|
@@ -12888,7 +13221,7 @@ declare abstract class Flags {
|
|
|
12888
13221
|
getNumberValue(
|
|
12889
13222
|
flagKey: string,
|
|
12890
13223
|
defaultValue: number,
|
|
12891
|
-
context?:
|
|
13224
|
+
context?: FlagshipEvaluationContext,
|
|
12892
13225
|
): Promise<number>;
|
|
12893
13226
|
/**
|
|
12894
13227
|
* Get an object flag value.
|
|
@@ -12899,7 +13232,7 @@ declare abstract class Flags {
|
|
|
12899
13232
|
getObjectValue<T extends object>(
|
|
12900
13233
|
flagKey: string,
|
|
12901
13234
|
defaultValue: T,
|
|
12902
|
-
context?:
|
|
13235
|
+
context?: FlagshipEvaluationContext,
|
|
12903
13236
|
): Promise<T>;
|
|
12904
13237
|
/**
|
|
12905
13238
|
* Get a boolean flag value with full evaluation details.
|
|
@@ -12910,8 +13243,8 @@ declare abstract class Flags {
|
|
|
12910
13243
|
getBooleanDetails(
|
|
12911
13244
|
flagKey: string,
|
|
12912
13245
|
defaultValue: boolean,
|
|
12913
|
-
context?:
|
|
12914
|
-
): Promise<
|
|
13246
|
+
context?: FlagshipEvaluationContext,
|
|
13247
|
+
): Promise<FlagshipEvaluationDetails<boolean>>;
|
|
12915
13248
|
/**
|
|
12916
13249
|
* Get a string flag value with full evaluation details.
|
|
12917
13250
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12921,8 +13254,8 @@ declare abstract class Flags {
|
|
|
12921
13254
|
getStringDetails(
|
|
12922
13255
|
flagKey: string,
|
|
12923
13256
|
defaultValue: string,
|
|
12924
|
-
context?:
|
|
12925
|
-
): Promise<
|
|
13257
|
+
context?: FlagshipEvaluationContext,
|
|
13258
|
+
): Promise<FlagshipEvaluationDetails<string>>;
|
|
12926
13259
|
/**
|
|
12927
13260
|
* Get a number flag value with full evaluation details.
|
|
12928
13261
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12932,8 +13265,8 @@ declare abstract class Flags {
|
|
|
12932
13265
|
getNumberDetails(
|
|
12933
13266
|
flagKey: string,
|
|
12934
13267
|
defaultValue: number,
|
|
12935
|
-
context?:
|
|
12936
|
-
): Promise<
|
|
13268
|
+
context?: FlagshipEvaluationContext,
|
|
13269
|
+
): Promise<FlagshipEvaluationDetails<number>>;
|
|
12937
13270
|
/**
|
|
12938
13271
|
* Get an object flag value with full evaluation details.
|
|
12939
13272
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12943,8 +13276,8 @@ declare abstract class Flags {
|
|
|
12943
13276
|
getObjectDetails<T extends object>(
|
|
12944
13277
|
flagKey: string,
|
|
12945
13278
|
defaultValue: T,
|
|
12946
|
-
context?:
|
|
12947
|
-
): Promise<
|
|
13279
|
+
context?: FlagshipEvaluationContext,
|
|
13280
|
+
): Promise<FlagshipEvaluationDetails<T>>;
|
|
12948
13281
|
}
|
|
12949
13282
|
/**
|
|
12950
13283
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|