@cloudflare/workers-types 4.20260414.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/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 +480 -110
- package/2022-03-21/index.ts +483 -109
- package/2022-08-04/index.d.ts +480 -110
- package/2022-08-04/index.ts +483 -109
- package/2022-10-31/index.d.ts +480 -110
- package/2022-10-31/index.ts +483 -109
- package/2022-11-30/index.d.ts +480 -110
- package/2022-11-30/index.ts +483 -109
- package/2023-03-01/index.d.ts +480 -110
- package/2023-03-01/index.ts +483 -109
- package/2023-07-01/index.d.ts +480 -110
- package/2023-07-01/index.ts +483 -109
- package/experimental/index.d.ts +441 -109
- package/experimental/index.ts +444 -108
- package/index.d.ts +480 -110
- package/index.ts +483 -109
- package/latest/index.d.ts +480 -110
- package/latest/index.ts +483 -109
- package/oldest/index.d.ts +480 -110
- package/oldest/index.ts +483 -109
- package/package.json +1 -1
package/experimental/index.ts
CHANGED
|
@@ -2420,12 +2420,12 @@ export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
|
|
|
2420
2420
|
}
|
|
2421
2421
|
export type QueueContentType = "text" | "bytes" | "json" | "v8";
|
|
2422
2422
|
export interface Queue<Body = unknown> {
|
|
2423
|
+
metrics(): Promise<QueueMetrics>;
|
|
2423
2424
|
send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
|
|
2424
2425
|
sendBatch(
|
|
2425
2426
|
messages: Iterable<MessageSendRequest<Body>>,
|
|
2426
2427
|
options?: QueueSendBatchOptions,
|
|
2427
2428
|
): Promise<QueueSendBatchResponse>;
|
|
2428
|
-
metrics(): Promise<QueueMetrics>;
|
|
2429
2429
|
}
|
|
2430
2430
|
export interface QueueSendMetrics {
|
|
2431
2431
|
backlogCount: number;
|
|
@@ -4716,72 +4716,145 @@ export interface EventCounts {
|
|
|
4716
4716
|
// ============ AI Search Error Interfaces ============
|
|
4717
4717
|
export interface AiSearchInternalError extends Error {}
|
|
4718
4718
|
export interface AiSearchNotFoundError extends Error {}
|
|
4719
|
-
// ============ AI Search
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4719
|
+
// ============ AI Search Common Types ============
|
|
4720
|
+
/** A single message in a conversation-style search or chat request. */
|
|
4721
|
+
export type AiSearchMessage = {
|
|
4722
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4723
|
+
content: string | null;
|
|
4724
|
+
};
|
|
4725
|
+
/**
|
|
4726
|
+
* Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
|
|
4727
|
+
* Contains retrieval, query rewrite, reranking, and cache sub-options.
|
|
4728
|
+
*/
|
|
4729
|
+
export type AiSearchOptions = {
|
|
4730
|
+
retrieval?: {
|
|
4731
|
+
/** Which retrieval backend to use. Defaults to the instance's configured index_method. */
|
|
4732
|
+
retrieval_type?: "vector" | "keyword" | "hybrid";
|
|
4733
|
+
/** Fusion method for combining vector + keyword results. */
|
|
4734
|
+
fusion_method?: "max" | "rrf";
|
|
4735
|
+
/** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
|
|
4736
|
+
keyword_match_mode?: "and" | "or";
|
|
4737
|
+
/** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
|
|
4738
|
+
match_threshold?: number;
|
|
4739
|
+
/** Maximum number of results to return (1-50). Default 10. */
|
|
4740
|
+
max_num_results?: number;
|
|
4741
|
+
/** Vectorize metadata filters applied to the search. */
|
|
4742
|
+
filters?: VectorizeVectorMetadataFilter;
|
|
4743
|
+
/** Number of surrounding chunks to include for context (0-3). Default 0. */
|
|
4744
|
+
context_expansion?: number;
|
|
4745
|
+
/** If true, return only item metadata without chunk text. */
|
|
4746
|
+
metadata_only?: boolean;
|
|
4747
|
+
/** If true (default), return empty results on retrieval failure instead of throwing. */
|
|
4748
|
+
return_on_failure?: boolean;
|
|
4749
|
+
/** Boost results by metadata field values. Max 3 entries. */
|
|
4750
|
+
boost_by?: Array<{
|
|
4751
|
+
field: string;
|
|
4752
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
4753
|
+
}>;
|
|
4754
|
+
[key: string]: unknown;
|
|
4755
|
+
};
|
|
4756
|
+
query_rewrite?: {
|
|
4757
|
+
enabled?: boolean;
|
|
4758
|
+
model?: string;
|
|
4759
|
+
rewrite_prompt?: string;
|
|
4760
|
+
[key: string]: unknown;
|
|
4761
|
+
};
|
|
4762
|
+
reranking?: {
|
|
4763
|
+
enabled?: boolean;
|
|
4764
|
+
model?: string;
|
|
4765
|
+
/** Match threshold (0-1, default 0.4) */
|
|
4766
|
+
match_threshold?: number;
|
|
4750
4767
|
[key: string]: unknown;
|
|
4751
4768
|
};
|
|
4769
|
+
cache?: {
|
|
4770
|
+
enabled?: boolean;
|
|
4771
|
+
cache_threshold?:
|
|
4772
|
+
| "super_strict_match"
|
|
4773
|
+
| "close_enough"
|
|
4774
|
+
| "flexible_friend"
|
|
4775
|
+
| "anything_goes";
|
|
4776
|
+
};
|
|
4777
|
+
[key: string]: unknown;
|
|
4752
4778
|
};
|
|
4779
|
+
// ============ AI Search Request Types ============
|
|
4780
|
+
/**
|
|
4781
|
+
* Request body for single-instance search.
|
|
4782
|
+
* Exactly one of `query` or `messages` must be provided.
|
|
4783
|
+
*/
|
|
4784
|
+
export type AiSearchSearchRequest =
|
|
4785
|
+
| {
|
|
4786
|
+
/** Simple query string. */
|
|
4787
|
+
query: string;
|
|
4788
|
+
messages?: never;
|
|
4789
|
+
ai_search_options?: AiSearchOptions;
|
|
4790
|
+
}
|
|
4791
|
+
| {
|
|
4792
|
+
query?: never;
|
|
4793
|
+
/** Conversation-style input. At least one user message with non-empty content is required. */
|
|
4794
|
+
messages: AiSearchMessage[];
|
|
4795
|
+
ai_search_options?: AiSearchOptions;
|
|
4796
|
+
};
|
|
4753
4797
|
export type AiSearchChatCompletionsRequest = {
|
|
4754
|
-
messages:
|
|
4755
|
-
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4756
|
-
content: string | null;
|
|
4757
|
-
[key: string]: unknown;
|
|
4758
|
-
}>;
|
|
4798
|
+
messages: AiSearchMessage[];
|
|
4759
4799
|
model?: string;
|
|
4760
4800
|
stream?: boolean;
|
|
4761
|
-
ai_search_options?:
|
|
4762
|
-
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4801
|
+
ai_search_options?: AiSearchOptions;
|
|
4802
|
+
[key: string]: unknown;
|
|
4803
|
+
};
|
|
4804
|
+
// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
|
|
4805
|
+
/** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */
|
|
4806
|
+
export type AiSearchMultiSearchOptions = AiSearchOptions & {
|
|
4807
|
+
/** Instance IDs to search across (1-10). */
|
|
4808
|
+
instance_ids: string[];
|
|
4809
|
+
};
|
|
4810
|
+
/**
|
|
4811
|
+
* Request for searching across multiple instances within a namespace.
|
|
4812
|
+
* `ai_search_options` is required and must include `instance_ids`.
|
|
4813
|
+
* Exactly one of `query` or `messages` must be provided.
|
|
4814
|
+
*/
|
|
4815
|
+
export type AiSearchMultiSearchRequest =
|
|
4816
|
+
| {
|
|
4817
|
+
/** Simple query string. */
|
|
4818
|
+
query: string;
|
|
4819
|
+
messages?: never;
|
|
4820
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4821
|
+
}
|
|
4822
|
+
| {
|
|
4823
|
+
query?: never;
|
|
4824
|
+
/** Conversation-style input. */
|
|
4825
|
+
messages: AiSearchMessage[];
|
|
4826
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4781
4827
|
};
|
|
4782
|
-
|
|
4828
|
+
/** A search result chunk tagged with the instance it originated from. */
|
|
4829
|
+
export type AiSearchMultiSearchChunk =
|
|
4830
|
+
AiSearchSearchResponse["chunks"][number] & {
|
|
4831
|
+
instance_id: string;
|
|
4783
4832
|
};
|
|
4784
|
-
|
|
4833
|
+
/** Describes a per-instance error during a multi-instance operation. */
|
|
4834
|
+
export type AiSearchMultiSearchError = {
|
|
4835
|
+
instance_id: string;
|
|
4836
|
+
message: string;
|
|
4837
|
+
};
|
|
4838
|
+
/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
|
|
4839
|
+
export type AiSearchMultiSearchResponse = {
|
|
4840
|
+
search_query: string;
|
|
4841
|
+
chunks: AiSearchMultiSearchChunk[];
|
|
4842
|
+
errors?: AiSearchMultiSearchError[];
|
|
4843
|
+
};
|
|
4844
|
+
/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
|
|
4845
|
+
export type AiSearchMultiChatCompletionsRequest = Omit<
|
|
4846
|
+
AiSearchChatCompletionsRequest,
|
|
4847
|
+
"ai_search_options"
|
|
4848
|
+
> & {
|
|
4849
|
+
ai_search_options: AiSearchMultiSearchOptions;
|
|
4850
|
+
};
|
|
4851
|
+
/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
|
|
4852
|
+
export type AiSearchMultiChatCompletionsResponse = Omit<
|
|
4853
|
+
AiSearchChatCompletionsResponse,
|
|
4854
|
+
"chunks"
|
|
4855
|
+
> & {
|
|
4856
|
+
chunks: AiSearchMultiSearchChunk[];
|
|
4857
|
+
errors?: AiSearchMultiSearchError[];
|
|
4785
4858
|
};
|
|
4786
4859
|
// ============ AI Search Response Types ============
|
|
4787
4860
|
export type AiSearchSearchResponse = {
|
|
@@ -4802,6 +4875,14 @@ export type AiSearchSearchResponse = {
|
|
|
4802
4875
|
keyword_score?: number;
|
|
4803
4876
|
/** Vector similarity score (0-1) */
|
|
4804
4877
|
vector_score?: number;
|
|
4878
|
+
/** Keyword rank position */
|
|
4879
|
+
keyword_rank?: number;
|
|
4880
|
+
/** Vector rank position */
|
|
4881
|
+
vector_rank?: number;
|
|
4882
|
+
/** Reranking model score */
|
|
4883
|
+
reranking_score?: number;
|
|
4884
|
+
/** Fusion method used to combine results */
|
|
4885
|
+
fusion_method?: "rrf" | "max";
|
|
4805
4886
|
[key: string]: unknown;
|
|
4806
4887
|
};
|
|
4807
4888
|
}>;
|
|
@@ -4830,19 +4911,88 @@ export type AiSearchStatsResponse = {
|
|
|
4830
4911
|
skipped?: number;
|
|
4831
4912
|
outdated?: number;
|
|
4832
4913
|
last_activity?: string;
|
|
4914
|
+
/** Storage engine statistics. */
|
|
4915
|
+
engine?: {
|
|
4916
|
+
vectorize?: {
|
|
4917
|
+
vectorsCount: number;
|
|
4918
|
+
dimensions: number;
|
|
4919
|
+
};
|
|
4920
|
+
r2?: {
|
|
4921
|
+
payloadSizeBytes: number;
|
|
4922
|
+
metadataSizeBytes: number;
|
|
4923
|
+
objectCount: number;
|
|
4924
|
+
};
|
|
4925
|
+
};
|
|
4833
4926
|
};
|
|
4834
4927
|
// ============ AI Search Instance Info Types ============
|
|
4835
4928
|
export type AiSearchInstanceInfo = {
|
|
4836
4929
|
id: string;
|
|
4837
4930
|
type?: "r2" | "web-crawler" | string;
|
|
4838
4931
|
source?: string;
|
|
4932
|
+
source_params?: unknown;
|
|
4839
4933
|
paused?: boolean;
|
|
4840
4934
|
status?: string;
|
|
4841
4935
|
namespace?: string;
|
|
4842
4936
|
created_at?: string;
|
|
4843
4937
|
modified_at?: string;
|
|
4938
|
+
token_id?: string;
|
|
4939
|
+
ai_gateway_id?: string;
|
|
4940
|
+
rewrite_query?: boolean;
|
|
4941
|
+
reranking?: boolean;
|
|
4942
|
+
embedding_model?: string;
|
|
4943
|
+
ai_search_model?: string;
|
|
4944
|
+
rewrite_model?: string;
|
|
4945
|
+
reranking_model?: string;
|
|
4946
|
+
/** @deprecated Use index_method instead. */
|
|
4947
|
+
hybrid_search_enabled?: boolean;
|
|
4948
|
+
/** Controls which storage backends are active. */
|
|
4949
|
+
index_method?: {
|
|
4950
|
+
vector?: boolean;
|
|
4951
|
+
keyword?: boolean;
|
|
4952
|
+
};
|
|
4953
|
+
/** Fusion method for combining vector and keyword results. */
|
|
4954
|
+
fusion_method?: "max" | "rrf";
|
|
4955
|
+
indexing_options?: {
|
|
4956
|
+
keyword_tokenizer?: "porter" | "trigram";
|
|
4957
|
+
} | null;
|
|
4958
|
+
retrieval_options?: {
|
|
4959
|
+
keyword_match_mode?: "and" | "or";
|
|
4960
|
+
boost_by?: Array<{
|
|
4961
|
+
field: string;
|
|
4962
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
4963
|
+
}>;
|
|
4964
|
+
} | null;
|
|
4965
|
+
chunk?: boolean;
|
|
4966
|
+
chunk_size?: number;
|
|
4967
|
+
chunk_overlap?: number;
|
|
4968
|
+
score_threshold?: number;
|
|
4969
|
+
max_num_results?: number;
|
|
4970
|
+
cache?: boolean;
|
|
4971
|
+
cache_threshold?:
|
|
4972
|
+
| "super_strict_match"
|
|
4973
|
+
| "close_enough"
|
|
4974
|
+
| "flexible_friend"
|
|
4975
|
+
| "anything_goes";
|
|
4976
|
+
custom_metadata?: Array<{
|
|
4977
|
+
field_name: string;
|
|
4978
|
+
data_type: "text" | "number" | "boolean" | "datetime";
|
|
4979
|
+
}>;
|
|
4980
|
+
/** Sync interval in seconds. */
|
|
4981
|
+
sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
|
|
4982
|
+
metadata?: Record<string, unknown>;
|
|
4844
4983
|
[key: string]: unknown;
|
|
4845
4984
|
};
|
|
4985
|
+
/** Pagination, search, and ordering parameters for listing instances within a namespace. */
|
|
4986
|
+
export type AiSearchListInstancesParams = {
|
|
4987
|
+
page?: number;
|
|
4988
|
+
per_page?: number;
|
|
4989
|
+
/** Search instances by ID. */
|
|
4990
|
+
search?: string;
|
|
4991
|
+
/** Field to sort by. */
|
|
4992
|
+
order_by?: "created_at";
|
|
4993
|
+
/** Sort direction. */
|
|
4994
|
+
order_by_direction?: "asc" | "desc";
|
|
4995
|
+
};
|
|
4846
4996
|
export type AiSearchListResponse = {
|
|
4847
4997
|
result: AiSearchInstanceInfo[];
|
|
4848
4998
|
result_info?: {
|
|
@@ -4870,19 +5020,64 @@ export type AiSearchConfig = {
|
|
|
4870
5020
|
reranking?: boolean;
|
|
4871
5021
|
embedding_model?: string;
|
|
4872
5022
|
ai_search_model?: string;
|
|
5023
|
+
rewrite_model?: string;
|
|
5024
|
+
reranking_model?: string;
|
|
5025
|
+
/** @deprecated Use index_method instead. */
|
|
5026
|
+
hybrid_search_enabled?: boolean;
|
|
5027
|
+
/** Controls which storage backends are used during indexing. Defaults to vector-only. */
|
|
5028
|
+
index_method?: {
|
|
5029
|
+
vector?: boolean;
|
|
5030
|
+
keyword?: boolean;
|
|
5031
|
+
};
|
|
5032
|
+
/** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
|
|
5033
|
+
fusion_method?: "max" | "rrf";
|
|
5034
|
+
indexing_options?: {
|
|
5035
|
+
keyword_tokenizer?: "porter" | "trigram";
|
|
5036
|
+
} | null;
|
|
5037
|
+
retrieval_options?: {
|
|
5038
|
+
keyword_match_mode?: "and" | "or";
|
|
5039
|
+
boost_by?: Array<{
|
|
5040
|
+
field: string;
|
|
5041
|
+
direction?: "asc" | "desc" | "exists" | "not_exists";
|
|
5042
|
+
}>;
|
|
5043
|
+
} | null;
|
|
5044
|
+
chunk?: boolean;
|
|
5045
|
+
chunk_size?: number;
|
|
5046
|
+
chunk_overlap?: number;
|
|
5047
|
+
/** Minimum similarity score (0-1) for a result to be included. */
|
|
5048
|
+
score_threshold?: number;
|
|
5049
|
+
max_num_results?: number;
|
|
5050
|
+
cache?: boolean;
|
|
5051
|
+
/** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
|
|
5052
|
+
cache_threshold?:
|
|
5053
|
+
| "super_strict_match"
|
|
5054
|
+
| "close_enough"
|
|
5055
|
+
| "flexible_friend"
|
|
5056
|
+
| "anything_goes";
|
|
5057
|
+
custom_metadata?: Array<{
|
|
5058
|
+
field_name: string;
|
|
5059
|
+
data_type: "text" | "number" | "boolean" | "datetime";
|
|
5060
|
+
}>;
|
|
5061
|
+
namespace?: string;
|
|
5062
|
+
/** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
|
|
5063
|
+
sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
|
|
5064
|
+
metadata?: Record<string, unknown>;
|
|
4873
5065
|
[key: string]: unknown;
|
|
4874
5066
|
};
|
|
4875
5067
|
// ============ AI Search Item Types ============
|
|
4876
5068
|
export type AiSearchItemInfo = {
|
|
4877
5069
|
id: string;
|
|
4878
5070
|
key: string;
|
|
4879
|
-
status:
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
5071
|
+
status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
|
|
5072
|
+
next_action?: "INDEX" | "DELETE" | null;
|
|
5073
|
+
error?: string;
|
|
5074
|
+
checksum?: string;
|
|
5075
|
+
namespace?: string;
|
|
5076
|
+
chunks_count?: number | null;
|
|
5077
|
+
file_size?: number | null;
|
|
5078
|
+
source_id?: string | null;
|
|
5079
|
+
last_seen_at?: string;
|
|
5080
|
+
created_at?: string;
|
|
4886
5081
|
metadata?: Record<string, unknown>;
|
|
4887
5082
|
[key: string]: unknown;
|
|
4888
5083
|
};
|
|
@@ -4898,6 +5093,22 @@ export type AiSearchUploadItemOptions = {
|
|
|
4898
5093
|
export type AiSearchListItemsParams = {
|
|
4899
5094
|
page?: number;
|
|
4900
5095
|
per_page?: number;
|
|
5096
|
+
/** Search items by key name. */
|
|
5097
|
+
search?: string;
|
|
5098
|
+
/** Sort order for results. */
|
|
5099
|
+
sort_by?: "status" | "modified_at";
|
|
5100
|
+
/** Filter items by processing status. */
|
|
5101
|
+
status?:
|
|
5102
|
+
| "queued"
|
|
5103
|
+
| "running"
|
|
5104
|
+
| "completed"
|
|
5105
|
+
| "error"
|
|
5106
|
+
| "skipped"
|
|
5107
|
+
| "outdated";
|
|
5108
|
+
/** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
|
|
5109
|
+
source?: string;
|
|
5110
|
+
/** JSON-encoded Vectorize filter for metadata filtering. */
|
|
5111
|
+
metadata_filter?: string;
|
|
4901
5112
|
};
|
|
4902
5113
|
export type AiSearchListItemsResponse = {
|
|
4903
5114
|
result: AiSearchItemInfo[];
|
|
@@ -4908,6 +5119,61 @@ export type AiSearchListItemsResponse = {
|
|
|
4908
5119
|
total_count: number;
|
|
4909
5120
|
};
|
|
4910
5121
|
};
|
|
5122
|
+
// ============ AI Search Item Logs Types ============
|
|
5123
|
+
export type AiSearchItemLogsParams = {
|
|
5124
|
+
/** Maximum number of log entries to return (1-100, default 50). */
|
|
5125
|
+
limit?: number;
|
|
5126
|
+
/** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
|
|
5127
|
+
cursor?: string;
|
|
5128
|
+
};
|
|
5129
|
+
export type AiSearchItemLog = {
|
|
5130
|
+
timestamp: string;
|
|
5131
|
+
action: string;
|
|
5132
|
+
message: string;
|
|
5133
|
+
fileKey?: string;
|
|
5134
|
+
chunkCount?: number;
|
|
5135
|
+
processingTimeMs?: number;
|
|
5136
|
+
errorType?: string;
|
|
5137
|
+
};
|
|
5138
|
+
/** Paginated response for item processing logs (cursor-based). */
|
|
5139
|
+
export type AiSearchItemLogsResponse = {
|
|
5140
|
+
result: AiSearchItemLog[];
|
|
5141
|
+
result_info: {
|
|
5142
|
+
count: number;
|
|
5143
|
+
per_page: number;
|
|
5144
|
+
cursor: string | null;
|
|
5145
|
+
truncated: boolean;
|
|
5146
|
+
};
|
|
5147
|
+
};
|
|
5148
|
+
// ============ AI Search Item Chunks Types ============
|
|
5149
|
+
export type AiSearchItemChunksParams = {
|
|
5150
|
+
/** Maximum number of chunks to return (1-100, default 20). */
|
|
5151
|
+
limit?: number;
|
|
5152
|
+
/** Offset into the chunks list (default 0). */
|
|
5153
|
+
offset?: number;
|
|
5154
|
+
};
|
|
5155
|
+
/** A single indexed chunk belonging to an item, including its text content and byte range. */
|
|
5156
|
+
export type AiSearchItemChunk = {
|
|
5157
|
+
id: string;
|
|
5158
|
+
text: string;
|
|
5159
|
+
start_byte: number;
|
|
5160
|
+
end_byte: number;
|
|
5161
|
+
item?: {
|
|
5162
|
+
timestamp?: number;
|
|
5163
|
+
key: string;
|
|
5164
|
+
metadata?: Record<string, unknown>;
|
|
5165
|
+
};
|
|
5166
|
+
};
|
|
5167
|
+
/** Paginated response for item chunks (offset-based). */
|
|
5168
|
+
export type AiSearchItemChunksResponse = {
|
|
5169
|
+
result: AiSearchItemChunk[];
|
|
5170
|
+
result_info: {
|
|
5171
|
+
count: number;
|
|
5172
|
+
total: number;
|
|
5173
|
+
limit: number;
|
|
5174
|
+
offset: number;
|
|
5175
|
+
};
|
|
5176
|
+
};
|
|
4911
5177
|
// ============ AI Search Job Types ============
|
|
4912
5178
|
export type AiSearchJobInfo = {
|
|
4913
5179
|
id: string;
|
|
@@ -4956,7 +5222,7 @@ export type AiSearchJobLogsResponse = {
|
|
|
4956
5222
|
// ============ AI Search Sub-Service Classes ============
|
|
4957
5223
|
/**
|
|
4958
5224
|
* Single item service for an AI Search instance.
|
|
4959
|
-
* Provides info,
|
|
5225
|
+
* Provides info, download, sync, logs, and chunks operations on a specific item.
|
|
4960
5226
|
*/
|
|
4961
5227
|
export declare abstract class AiSearchItem {
|
|
4962
5228
|
/** Get metadata about this item. */
|
|
@@ -4966,6 +5232,25 @@ export declare abstract class AiSearchItem {
|
|
|
4966
5232
|
* @returns Object with body stream, content type, filename, and size.
|
|
4967
5233
|
*/
|
|
4968
5234
|
download(): Promise<AiSearchItemContentResult>;
|
|
5235
|
+
/**
|
|
5236
|
+
* Trigger re-indexing of this item.
|
|
5237
|
+
* @returns The updated item info.
|
|
5238
|
+
*/
|
|
5239
|
+
sync(): Promise<AiSearchItemInfo>;
|
|
5240
|
+
/**
|
|
5241
|
+
* Retrieve processing logs for this item (cursor-based pagination).
|
|
5242
|
+
* @param params Optional pagination parameters (limit, cursor).
|
|
5243
|
+
* @returns Paginated log entries for this item.
|
|
5244
|
+
*/
|
|
5245
|
+
logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
|
|
5246
|
+
/**
|
|
5247
|
+
* List indexed chunks for this item (offset-based pagination).
|
|
5248
|
+
* @param params Optional pagination parameters (limit, offset).
|
|
5249
|
+
* @returns Paginated chunk entries for this item.
|
|
5250
|
+
*/
|
|
5251
|
+
chunks(
|
|
5252
|
+
params?: AiSearchItemChunksParams,
|
|
5253
|
+
): Promise<AiSearchItemChunksResponse>;
|
|
4969
5254
|
}
|
|
4970
5255
|
/**
|
|
4971
5256
|
* Items collection service for an AI Search instance.
|
|
@@ -4975,49 +5260,64 @@ export declare abstract class AiSearchItems {
|
|
|
4975
5260
|
/** List items in this instance. */
|
|
4976
5261
|
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4977
5262
|
/**
|
|
4978
|
-
* Upload a file as an item.
|
|
5263
|
+
* Upload a file as an item. Behaves as an upsert: if an item with the same
|
|
5264
|
+
* filename already exists, it is overwritten and re-indexed.
|
|
4979
5265
|
* @param name Filename for the uploaded item.
|
|
4980
|
-
* @param content File content as a ReadableStream,
|
|
5266
|
+
* @param content File content as a ReadableStream, Blob, or string.
|
|
4981
5267
|
* @param options Optional metadata to attach to the item.
|
|
4982
5268
|
* @returns The created item info.
|
|
4983
5269
|
*/
|
|
4984
5270
|
upload(
|
|
4985
5271
|
name: string,
|
|
4986
|
-
content: ReadableStream |
|
|
5272
|
+
content: ReadableStream | Blob | string,
|
|
4987
5273
|
options?: AiSearchUploadItemOptions,
|
|
4988
5274
|
): Promise<AiSearchItemInfo>;
|
|
4989
5275
|
/**
|
|
4990
5276
|
* Upload a file and poll until processing completes.
|
|
5277
|
+
* Behaves as an upsert: if an item with the same filename already exists,
|
|
5278
|
+
* it is overwritten and re-indexed.
|
|
4991
5279
|
* @param name Filename for the uploaded item.
|
|
4992
|
-
* @param content File content as a ReadableStream,
|
|
4993
|
-
* @param options Optional metadata
|
|
5280
|
+
* @param content File content as a ReadableStream, Blob, or string.
|
|
5281
|
+
* @param options Optional metadata and polling configuration.
|
|
4994
5282
|
* @returns The item info after processing completes (or timeout).
|
|
4995
5283
|
*/
|
|
4996
5284
|
uploadAndPoll(
|
|
4997
5285
|
name: string,
|
|
4998
|
-
content: ReadableStream |
|
|
4999
|
-
options?: AiSearchUploadItemOptions
|
|
5286
|
+
content: ReadableStream | Blob | string,
|
|
5287
|
+
options?: AiSearchUploadItemOptions & {
|
|
5288
|
+
/** Polling interval in milliseconds (default 1000). */
|
|
5289
|
+
pollIntervalMs?: number;
|
|
5290
|
+
/** Maximum time to wait in milliseconds (default 30000). */
|
|
5291
|
+
timeoutMs?: number;
|
|
5292
|
+
},
|
|
5000
5293
|
): Promise<AiSearchItemInfo>;
|
|
5001
5294
|
/**
|
|
5002
5295
|
* Get an item by ID.
|
|
5003
5296
|
* @param itemId The item identifier.
|
|
5004
|
-
* @returns Item service for info,
|
|
5297
|
+
* @returns Item service for info, download, sync, logs, and chunks operations.
|
|
5005
5298
|
*/
|
|
5006
5299
|
get(itemId: string): AiSearchItem;
|
|
5007
|
-
/**
|
|
5300
|
+
/**
|
|
5301
|
+
* Delete an item from the instance.
|
|
5008
5302
|
* @param itemId The item identifier.
|
|
5009
5303
|
*/
|
|
5010
5304
|
delete(itemId: string): Promise<void>;
|
|
5011
5305
|
}
|
|
5012
5306
|
/**
|
|
5013
5307
|
* Single job service for an AI Search instance.
|
|
5014
|
-
* Provides info and
|
|
5308
|
+
* Provides info, logs, and cancel operations for a specific job.
|
|
5015
5309
|
*/
|
|
5016
5310
|
export declare abstract class AiSearchJob {
|
|
5017
5311
|
/** Get metadata about this job. */
|
|
5018
5312
|
info(): Promise<AiSearchJobInfo>;
|
|
5019
5313
|
/** Get logs for this job. */
|
|
5020
5314
|
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
5315
|
+
/**
|
|
5316
|
+
* Cancel a running job.
|
|
5317
|
+
* @returns The updated job info.
|
|
5318
|
+
* @throws AiSearchNotFoundError if the job does not exist.
|
|
5319
|
+
*/
|
|
5320
|
+
cancel(): Promise<AiSearchJobInfo>;
|
|
5021
5321
|
}
|
|
5022
5322
|
/**
|
|
5023
5323
|
* Jobs collection service for an AI Search instance.
|
|
@@ -5035,7 +5335,7 @@ export declare abstract class AiSearchJobs {
|
|
|
5035
5335
|
/**
|
|
5036
5336
|
* Get a job by ID.
|
|
5037
5337
|
* @param jobId The job identifier.
|
|
5038
|
-
* @returns Job service for info and
|
|
5338
|
+
* @returns Job service for info, logs, and cancel operations.
|
|
5039
5339
|
*/
|
|
5040
5340
|
get(jobId: string): AiSearchJob;
|
|
5041
5341
|
}
|
|
@@ -5054,7 +5354,7 @@ export declare abstract class AiSearchJobs {
|
|
|
5054
5354
|
* // Via namespace binding
|
|
5055
5355
|
* const instance = env.AI_SEARCH.get("blog");
|
|
5056
5356
|
* const results = await instance.search({
|
|
5057
|
-
*
|
|
5357
|
+
* query: "How does caching work?",
|
|
5058
5358
|
* });
|
|
5059
5359
|
*
|
|
5060
5360
|
* // Via single instance binding
|
|
@@ -5066,7 +5366,7 @@ export declare abstract class AiSearchJobs {
|
|
|
5066
5366
|
export declare abstract class AiSearchInstance {
|
|
5067
5367
|
/**
|
|
5068
5368
|
* Search the AI Search instance for relevant chunks.
|
|
5069
|
-
* @param params Search request with messages and optional AI search options.
|
|
5369
|
+
* @param params Search request with query or messages and optional AI search options.
|
|
5070
5370
|
* @returns Search response with matching chunks and search query.
|
|
5071
5371
|
*/
|
|
5072
5372
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
@@ -5098,7 +5398,7 @@ export declare abstract class AiSearchInstance {
|
|
|
5098
5398
|
info(): Promise<AiSearchInstanceInfo>;
|
|
5099
5399
|
/**
|
|
5100
5400
|
* Get instance statistics (item count, indexing status, etc.).
|
|
5101
|
-
* @returns Statistics with counts per status
|
|
5401
|
+
* @returns Statistics with counts per status, last activity time, and engine details.
|
|
5102
5402
|
*/
|
|
5103
5403
|
stats(): Promise<AiSearchStatsResponse>;
|
|
5104
5404
|
/** Items collection — list, upload, and manage items in this instance. */
|
|
@@ -5110,27 +5410,30 @@ export declare abstract class AiSearchInstance {
|
|
|
5110
5410
|
* Namespace-level AI Search service.
|
|
5111
5411
|
*
|
|
5112
5412
|
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
5113
|
-
* Scoped to a single namespace. Provides dynamic instance access, creation,
|
|
5413
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
|
|
5414
|
+
* and multi-instance search/chat operations.
|
|
5114
5415
|
*
|
|
5115
5416
|
* @example
|
|
5116
5417
|
* ```ts
|
|
5117
5418
|
* // Access an instance within the namespace
|
|
5118
5419
|
* const blog = env.AI_SEARCH.get("blog");
|
|
5119
|
-
* const results = await blog.search({
|
|
5120
|
-
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
5121
|
-
* });
|
|
5420
|
+
* const results = await blog.search({ query: "How does caching work?" });
|
|
5122
5421
|
*
|
|
5123
5422
|
* // List all instances in the namespace
|
|
5124
5423
|
* const instances = await env.AI_SEARCH.list();
|
|
5125
5424
|
*
|
|
5126
5425
|
* // Create a new instance with built-in storage
|
|
5127
|
-
* const tenant = await env.AI_SEARCH.create({
|
|
5128
|
-
* id: "tenant-123",
|
|
5129
|
-
* });
|
|
5426
|
+
* const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
|
|
5130
5427
|
*
|
|
5131
5428
|
* // Upload items into the instance
|
|
5132
5429
|
* await tenant.items.upload("doc.pdf", fileContent);
|
|
5133
5430
|
*
|
|
5431
|
+
* // Search across multiple instances
|
|
5432
|
+
* const multi = await env.AI_SEARCH.search({
|
|
5433
|
+
* query: "caching",
|
|
5434
|
+
* ai_search_options: { instance_ids: ["blog", "docs"] },
|
|
5435
|
+
* });
|
|
5436
|
+
*
|
|
5134
5437
|
* // Delete an instance
|
|
5135
5438
|
* await env.AI_SEARCH.delete("tenant-123");
|
|
5136
5439
|
* ```
|
|
@@ -5143,10 +5446,11 @@ export declare abstract class AiSearchNamespace {
|
|
|
5143
5446
|
*/
|
|
5144
5447
|
get(name: string): AiSearchInstance;
|
|
5145
5448
|
/**
|
|
5146
|
-
* List
|
|
5147
|
-
* @
|
|
5449
|
+
* List instances in the bound namespace.
|
|
5450
|
+
* @param params Optional pagination, search, and ordering parameters.
|
|
5451
|
+
* @returns Array of instance metadata with pagination info.
|
|
5148
5452
|
*/
|
|
5149
|
-
list(): Promise<AiSearchListResponse>;
|
|
5453
|
+
list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
|
|
5150
5454
|
/**
|
|
5151
5455
|
* Create a new instance within the bound namespace.
|
|
5152
5456
|
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
@@ -5171,6 +5475,35 @@ export declare abstract class AiSearchNamespace {
|
|
|
5171
5475
|
* @param name Instance name to delete.
|
|
5172
5476
|
*/
|
|
5173
5477
|
delete(name: string): Promise<void>;
|
|
5478
|
+
/**
|
|
5479
|
+
* Search across multiple instances within the bound namespace.
|
|
5480
|
+
* Fans out to the specified instance_ids and merges results.
|
|
5481
|
+
* @param params Search request with required `ai_search_options.instance_ids`.
|
|
5482
|
+
* @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
|
|
5483
|
+
*/
|
|
5484
|
+
search(
|
|
5485
|
+
params: AiSearchMultiSearchRequest,
|
|
5486
|
+
): Promise<AiSearchMultiSearchResponse>;
|
|
5487
|
+
/**
|
|
5488
|
+
* Generate chat completions across multiple instances within the bound namespace (streaming).
|
|
5489
|
+
* Fans out to the specified instance_ids, merges context, and generates a response.
|
|
5490
|
+
* @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
|
|
5491
|
+
* @returns ReadableStream of server-sent events.
|
|
5492
|
+
*/
|
|
5493
|
+
chatCompletions(
|
|
5494
|
+
params: AiSearchMultiChatCompletionsRequest & {
|
|
5495
|
+
stream: true;
|
|
5496
|
+
},
|
|
5497
|
+
): Promise<ReadableStream>;
|
|
5498
|
+
/**
|
|
5499
|
+
* Generate chat completions across multiple instances within the bound namespace.
|
|
5500
|
+
* Fans out to the specified instance_ids, merges context, and generates a response.
|
|
5501
|
+
* @param params Chat completions request with required `ai_search_options.instance_ids`.
|
|
5502
|
+
* @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
|
|
5503
|
+
*/
|
|
5504
|
+
chatCompletions(
|
|
5505
|
+
params: AiSearchMultiChatCompletionsRequest,
|
|
5506
|
+
): Promise<AiSearchMultiChatCompletionsResponse>;
|
|
5174
5507
|
}
|
|
5175
5508
|
export type AiImageClassificationInput = {
|
|
5176
5509
|
image: number[];
|
|
@@ -12832,8 +13165,11 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
|
|
|
12832
13165
|
* Evaluation context for targeting rules.
|
|
12833
13166
|
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12834
13167
|
*/
|
|
12835
|
-
export type
|
|
12836
|
-
|
|
13168
|
+
export type FlagshipEvaluationContext = Record<
|
|
13169
|
+
string,
|
|
13170
|
+
string | number | boolean
|
|
13171
|
+
>;
|
|
13172
|
+
export interface FlagshipEvaluationDetails<T> {
|
|
12837
13173
|
flagKey: string;
|
|
12838
13174
|
value: T;
|
|
12839
13175
|
variant?: string | undefined;
|
|
@@ -12841,7 +13177,7 @@ export interface EvaluationDetails<T> {
|
|
|
12841
13177
|
errorCode?: string | undefined;
|
|
12842
13178
|
errorMessage?: string | undefined;
|
|
12843
13179
|
}
|
|
12844
|
-
export interface
|
|
13180
|
+
export interface FlagshipEvaluationError extends Error {}
|
|
12845
13181
|
/**
|
|
12846
13182
|
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12847
13183
|
*
|
|
@@ -12861,7 +13197,7 @@ export interface FlagEvaluationError extends Error {}
|
|
|
12861
13197
|
* console.log(details.variant, details.reason);
|
|
12862
13198
|
* ```
|
|
12863
13199
|
*/
|
|
12864
|
-
export declare abstract class
|
|
13200
|
+
export declare abstract class Flagship {
|
|
12865
13201
|
/**
|
|
12866
13202
|
* Get a flag value without type checking.
|
|
12867
13203
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12871,7 +13207,7 @@ export declare abstract class Flags {
|
|
|
12871
13207
|
get(
|
|
12872
13208
|
flagKey: string,
|
|
12873
13209
|
defaultValue?: unknown,
|
|
12874
|
-
context?:
|
|
13210
|
+
context?: FlagshipEvaluationContext,
|
|
12875
13211
|
): Promise<unknown>;
|
|
12876
13212
|
/**
|
|
12877
13213
|
* Get a boolean flag value.
|
|
@@ -12882,7 +13218,7 @@ export declare abstract class Flags {
|
|
|
12882
13218
|
getBooleanValue(
|
|
12883
13219
|
flagKey: string,
|
|
12884
13220
|
defaultValue: boolean,
|
|
12885
|
-
context?:
|
|
13221
|
+
context?: FlagshipEvaluationContext,
|
|
12886
13222
|
): Promise<boolean>;
|
|
12887
13223
|
/**
|
|
12888
13224
|
* Get a string flag value.
|
|
@@ -12893,7 +13229,7 @@ export declare abstract class Flags {
|
|
|
12893
13229
|
getStringValue(
|
|
12894
13230
|
flagKey: string,
|
|
12895
13231
|
defaultValue: string,
|
|
12896
|
-
context?:
|
|
13232
|
+
context?: FlagshipEvaluationContext,
|
|
12897
13233
|
): Promise<string>;
|
|
12898
13234
|
/**
|
|
12899
13235
|
* Get a number flag value.
|
|
@@ -12904,7 +13240,7 @@ export declare abstract class Flags {
|
|
|
12904
13240
|
getNumberValue(
|
|
12905
13241
|
flagKey: string,
|
|
12906
13242
|
defaultValue: number,
|
|
12907
|
-
context?:
|
|
13243
|
+
context?: FlagshipEvaluationContext,
|
|
12908
13244
|
): Promise<number>;
|
|
12909
13245
|
/**
|
|
12910
13246
|
* Get an object flag value.
|
|
@@ -12915,7 +13251,7 @@ export declare abstract class Flags {
|
|
|
12915
13251
|
getObjectValue<T extends object>(
|
|
12916
13252
|
flagKey: string,
|
|
12917
13253
|
defaultValue: T,
|
|
12918
|
-
context?:
|
|
13254
|
+
context?: FlagshipEvaluationContext,
|
|
12919
13255
|
): Promise<T>;
|
|
12920
13256
|
/**
|
|
12921
13257
|
* Get a boolean flag value with full evaluation details.
|
|
@@ -12926,8 +13262,8 @@ export declare abstract class Flags {
|
|
|
12926
13262
|
getBooleanDetails(
|
|
12927
13263
|
flagKey: string,
|
|
12928
13264
|
defaultValue: boolean,
|
|
12929
|
-
context?:
|
|
12930
|
-
): Promise<
|
|
13265
|
+
context?: FlagshipEvaluationContext,
|
|
13266
|
+
): Promise<FlagshipEvaluationDetails<boolean>>;
|
|
12931
13267
|
/**
|
|
12932
13268
|
* Get a string flag value with full evaluation details.
|
|
12933
13269
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12937,8 +13273,8 @@ export declare abstract class Flags {
|
|
|
12937
13273
|
getStringDetails(
|
|
12938
13274
|
flagKey: string,
|
|
12939
13275
|
defaultValue: string,
|
|
12940
|
-
context?:
|
|
12941
|
-
): Promise<
|
|
13276
|
+
context?: FlagshipEvaluationContext,
|
|
13277
|
+
): Promise<FlagshipEvaluationDetails<string>>;
|
|
12942
13278
|
/**
|
|
12943
13279
|
* Get a number flag value with full evaluation details.
|
|
12944
13280
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12948,8 +13284,8 @@ export declare abstract class Flags {
|
|
|
12948
13284
|
getNumberDetails(
|
|
12949
13285
|
flagKey: string,
|
|
12950
13286
|
defaultValue: number,
|
|
12951
|
-
context?:
|
|
12952
|
-
): Promise<
|
|
13287
|
+
context?: FlagshipEvaluationContext,
|
|
13288
|
+
): Promise<FlagshipEvaluationDetails<number>>;
|
|
12953
13289
|
/**
|
|
12954
13290
|
* Get an object flag value with full evaluation details.
|
|
12955
13291
|
* @param flagKey The key of the flag to evaluate.
|
|
@@ -12959,8 +13295,8 @@ export declare abstract class Flags {
|
|
|
12959
13295
|
getObjectDetails<T extends object>(
|
|
12960
13296
|
flagKey: string,
|
|
12961
13297
|
defaultValue: T,
|
|
12962
|
-
context?:
|
|
12963
|
-
): Promise<
|
|
13298
|
+
context?: FlagshipEvaluationContext,
|
|
13299
|
+
): Promise<FlagshipEvaluationDetails<T>>;
|
|
12964
13300
|
}
|
|
12965
13301
|
/**
|
|
12966
13302
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|