@cloudflare/workers-types 4.20260227.0 → 4.20260228.0
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 +297 -9
- package/2021-11-03/index.ts +297 -9
- package/2022-01-31/index.d.ts +297 -9
- package/2022-01-31/index.ts +297 -9
- package/2022-03-21/index.d.ts +297 -9
- package/2022-03-21/index.ts +297 -9
- package/2022-08-04/index.d.ts +297 -9
- package/2022-08-04/index.ts +297 -9
- package/2022-10-31/index.d.ts +297 -9
- package/2022-10-31/index.ts +297 -9
- package/2022-11-30/index.d.ts +297 -9
- package/2022-11-30/index.ts +297 -9
- package/2023-03-01/index.d.ts +297 -9
- package/2023-03-01/index.ts +297 -9
- package/2023-07-01/index.d.ts +297 -9
- package/2023-07-01/index.ts +297 -9
- package/experimental/index.d.ts +299 -9
- package/experimental/index.ts +299 -9
- package/index.d.ts +297 -9
- package/index.ts +297 -9
- package/latest/index.d.ts +297 -9
- package/latest/index.ts +297 -9
- package/oldest/index.d.ts +297 -9
- package/oldest/index.ts +297 -9
- package/package.json +1 -1
package/2022-03-21/index.ts
CHANGED
|
@@ -3826,6 +3826,184 @@ export declare abstract class Performance {
|
|
|
3826
3826
|
/* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
|
|
3827
3827
|
now(): number;
|
|
3828
3828
|
}
|
|
3829
|
+
// AI Search V2 API Error Interfaces
|
|
3830
|
+
export interface AiSearchInternalError extends Error {}
|
|
3831
|
+
export interface AiSearchNotFoundError extends Error {}
|
|
3832
|
+
export interface AiSearchNameNotSetError extends Error {}
|
|
3833
|
+
// Filter types (shared with AutoRAG for compatibility)
|
|
3834
|
+
export type ComparisonFilter = {
|
|
3835
|
+
key: string;
|
|
3836
|
+
type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
|
|
3837
|
+
value: string | number | boolean;
|
|
3838
|
+
};
|
|
3839
|
+
export type CompoundFilter = {
|
|
3840
|
+
type: "and" | "or";
|
|
3841
|
+
filters: ComparisonFilter[];
|
|
3842
|
+
};
|
|
3843
|
+
// AI Search V2 Request Types
|
|
3844
|
+
export type AiSearchSearchRequest = {
|
|
3845
|
+
messages: Array<{
|
|
3846
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3847
|
+
content: string | null;
|
|
3848
|
+
}>;
|
|
3849
|
+
ai_search_options?: {
|
|
3850
|
+
retrieval?: {
|
|
3851
|
+
retrieval_type?: "vector" | "keyword" | "hybrid";
|
|
3852
|
+
/** Match threshold (0-1, default 0.4) */
|
|
3853
|
+
match_threshold?: number;
|
|
3854
|
+
/** Maximum number of results (1-50, default 10) */
|
|
3855
|
+
max_num_results?: number;
|
|
3856
|
+
filters?: CompoundFilter | ComparisonFilter;
|
|
3857
|
+
/** Context expansion (0-3, default 0) */
|
|
3858
|
+
context_expansion?: number;
|
|
3859
|
+
[key: string]: unknown;
|
|
3860
|
+
};
|
|
3861
|
+
query_rewrite?: {
|
|
3862
|
+
enabled?: boolean;
|
|
3863
|
+
model?: string;
|
|
3864
|
+
rewrite_prompt?: string;
|
|
3865
|
+
[key: string]: unknown;
|
|
3866
|
+
};
|
|
3867
|
+
reranking?: {
|
|
3868
|
+
/** Enable reranking (default false) */
|
|
3869
|
+
enabled?: boolean;
|
|
3870
|
+
model?: "@cf/baai/bge-reranker-base" | "";
|
|
3871
|
+
/** Match threshold (0-1, default 0.4) */
|
|
3872
|
+
match_threshold?: number;
|
|
3873
|
+
[key: string]: unknown;
|
|
3874
|
+
};
|
|
3875
|
+
[key: string]: unknown;
|
|
3876
|
+
};
|
|
3877
|
+
};
|
|
3878
|
+
export type AiSearchChatCompletionsRequest = {
|
|
3879
|
+
messages: Array<{
|
|
3880
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
3881
|
+
content: string | null;
|
|
3882
|
+
}>;
|
|
3883
|
+
model?: string;
|
|
3884
|
+
stream?: boolean;
|
|
3885
|
+
ai_search_options?: {
|
|
3886
|
+
retrieval?: {
|
|
3887
|
+
retrieval_type?: "vector" | "keyword" | "hybrid";
|
|
3888
|
+
match_threshold?: number;
|
|
3889
|
+
max_num_results?: number;
|
|
3890
|
+
filters?: CompoundFilter | ComparisonFilter;
|
|
3891
|
+
context_expansion?: number;
|
|
3892
|
+
[key: string]: unknown;
|
|
3893
|
+
};
|
|
3894
|
+
query_rewrite?: {
|
|
3895
|
+
enabled?: boolean;
|
|
3896
|
+
model?: string;
|
|
3897
|
+
rewrite_prompt?: string;
|
|
3898
|
+
[key: string]: unknown;
|
|
3899
|
+
};
|
|
3900
|
+
reranking?: {
|
|
3901
|
+
enabled?: boolean;
|
|
3902
|
+
model?: "@cf/baai/bge-reranker-base" | "";
|
|
3903
|
+
match_threshold?: number;
|
|
3904
|
+
[key: string]: unknown;
|
|
3905
|
+
};
|
|
3906
|
+
[key: string]: unknown;
|
|
3907
|
+
};
|
|
3908
|
+
[key: string]: unknown;
|
|
3909
|
+
};
|
|
3910
|
+
// AI Search V2 Response Types
|
|
3911
|
+
export type AiSearchSearchResponse = {
|
|
3912
|
+
search_query: string;
|
|
3913
|
+
chunks: Array<{
|
|
3914
|
+
id: string;
|
|
3915
|
+
type: string;
|
|
3916
|
+
/** Match score (0-1) */
|
|
3917
|
+
score: number;
|
|
3918
|
+
text: string;
|
|
3919
|
+
item: {
|
|
3920
|
+
timestamp?: number;
|
|
3921
|
+
key: string;
|
|
3922
|
+
metadata?: Record<string, unknown>;
|
|
3923
|
+
};
|
|
3924
|
+
scoring_details?: {
|
|
3925
|
+
/** Keyword match score (0-1) */
|
|
3926
|
+
keyword_score?: number;
|
|
3927
|
+
/** Vector similarity score (0-1) */
|
|
3928
|
+
vector_score?: number;
|
|
3929
|
+
};
|
|
3930
|
+
}>;
|
|
3931
|
+
};
|
|
3932
|
+
export type AiSearchListResponse = Array<{
|
|
3933
|
+
id: string;
|
|
3934
|
+
internal_id?: string;
|
|
3935
|
+
account_id?: string;
|
|
3936
|
+
account_tag?: string;
|
|
3937
|
+
/** Whether the instance is enabled (default true) */
|
|
3938
|
+
enable?: boolean;
|
|
3939
|
+
type?: "r2" | "web-crawler";
|
|
3940
|
+
source?: string;
|
|
3941
|
+
[key: string]: unknown;
|
|
3942
|
+
}>;
|
|
3943
|
+
export type AiSearchConfig = {
|
|
3944
|
+
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
3945
|
+
id: string;
|
|
3946
|
+
type: "r2" | "web-crawler";
|
|
3947
|
+
source: string;
|
|
3948
|
+
source_params?: object;
|
|
3949
|
+
/** Token ID (UUID format) */
|
|
3950
|
+
token_id?: string;
|
|
3951
|
+
ai_gateway_id?: string;
|
|
3952
|
+
/** Enable query rewriting (default false) */
|
|
3953
|
+
rewrite_query?: boolean;
|
|
3954
|
+
/** Enable reranking (default false) */
|
|
3955
|
+
reranking?: boolean;
|
|
3956
|
+
embedding_model?: string;
|
|
3957
|
+
ai_search_model?: string;
|
|
3958
|
+
};
|
|
3959
|
+
export type AiSearchInstance = {
|
|
3960
|
+
id: string;
|
|
3961
|
+
enable?: boolean;
|
|
3962
|
+
type?: "r2" | "web-crawler";
|
|
3963
|
+
source?: string;
|
|
3964
|
+
[key: string]: unknown;
|
|
3965
|
+
};
|
|
3966
|
+
// AI Search Instance Service - Instance-level operations
|
|
3967
|
+
export declare abstract class AiSearchInstanceService {
|
|
3968
|
+
/**
|
|
3969
|
+
* Search the AI Search instance for relevant chunks.
|
|
3970
|
+
* @param params Search request with messages and AI search options
|
|
3971
|
+
* @returns Search response with matching chunks
|
|
3972
|
+
*/
|
|
3973
|
+
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
3974
|
+
/**
|
|
3975
|
+
* Generate chat completions with AI Search context.
|
|
3976
|
+
* @param params Chat completions request with optional streaming
|
|
3977
|
+
* @returns Response object (if streaming) or chat completion result
|
|
3978
|
+
*/
|
|
3979
|
+
chatCompletions(
|
|
3980
|
+
params: AiSearchChatCompletionsRequest,
|
|
3981
|
+
): Promise<Response | object>;
|
|
3982
|
+
/**
|
|
3983
|
+
* Delete this AI Search instance.
|
|
3984
|
+
*/
|
|
3985
|
+
delete(): Promise<void>;
|
|
3986
|
+
}
|
|
3987
|
+
// AI Search Account Service - Account-level operations
|
|
3988
|
+
export declare abstract class AiSearchAccountService {
|
|
3989
|
+
/**
|
|
3990
|
+
* List all AI Search instances in the account.
|
|
3991
|
+
* @returns Array of AI Search instances
|
|
3992
|
+
*/
|
|
3993
|
+
list(): Promise<AiSearchListResponse>;
|
|
3994
|
+
/**
|
|
3995
|
+
* Get an AI Search instance by ID.
|
|
3996
|
+
* @param name Instance ID
|
|
3997
|
+
* @returns Instance service for performing operations
|
|
3998
|
+
*/
|
|
3999
|
+
get(name: string): AiSearchInstanceService;
|
|
4000
|
+
/**
|
|
4001
|
+
* Create a new AI Search instance.
|
|
4002
|
+
* @param config Instance configuration
|
|
4003
|
+
* @returns Instance service for performing operations
|
|
4004
|
+
*/
|
|
4005
|
+
create(config: AiSearchConfig): Promise<AiSearchInstanceService>;
|
|
4006
|
+
}
|
|
3829
4007
|
export type AiImageClassificationInput = {
|
|
3830
4008
|
image: number[];
|
|
3831
4009
|
};
|
|
@@ -9326,6 +9504,48 @@ export declare abstract class Ai<
|
|
|
9326
9504
|
> {
|
|
9327
9505
|
aiGatewayLogId: string | null;
|
|
9328
9506
|
gateway(gatewayId: string): AiGateway;
|
|
9507
|
+
/**
|
|
9508
|
+
* Access the AI Search API for managing AI-powered search instances.
|
|
9509
|
+
*
|
|
9510
|
+
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
9511
|
+
* - Account-level operations: `list()`, `create()`
|
|
9512
|
+
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
9513
|
+
*
|
|
9514
|
+
* @example
|
|
9515
|
+
* ```typescript
|
|
9516
|
+
* // List all AI Search instances
|
|
9517
|
+
* const instances = await env.AI.aiSearch.list();
|
|
9518
|
+
*
|
|
9519
|
+
* // Search an instance
|
|
9520
|
+
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
9521
|
+
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9522
|
+
* ai_search_options: {
|
|
9523
|
+
* retrieval: { max_num_results: 10 }
|
|
9524
|
+
* }
|
|
9525
|
+
* });
|
|
9526
|
+
*
|
|
9527
|
+
* // Generate chat completions with AI Search context
|
|
9528
|
+
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
9529
|
+
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
9530
|
+
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
9531
|
+
* });
|
|
9532
|
+
* ```
|
|
9533
|
+
*/
|
|
9534
|
+
aiSearch: AiSearchAccountService;
|
|
9535
|
+
/**
|
|
9536
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9537
|
+
* Use `env.AI.aiSearch` instead for better API design and new features.
|
|
9538
|
+
*
|
|
9539
|
+
* Migration guide:
|
|
9540
|
+
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9541
|
+
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
9542
|
+
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9543
|
+
*
|
|
9544
|
+
* Note: The old API continues to work for backwards compatibility, but new projects should use AI Search.
|
|
9545
|
+
*
|
|
9546
|
+
* @see AiSearchAccountService
|
|
9547
|
+
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
9548
|
+
*/
|
|
9329
9549
|
autorag(autoragId: string): AutoRAG;
|
|
9330
9550
|
run<
|
|
9331
9551
|
Name extends keyof AiModelList,
|
|
@@ -9482,19 +9702,30 @@ export declare abstract class AiGateway {
|
|
|
9482
9702
|
): Promise<Response>;
|
|
9483
9703
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
9484
9704
|
}
|
|
9705
|
+
/**
|
|
9706
|
+
* @deprecated AutoRAG has been replaced by AI Search. Use AiSearchInternalError instead.
|
|
9707
|
+
* @see AiSearchInternalError
|
|
9708
|
+
*/
|
|
9485
9709
|
export interface AutoRAGInternalError extends Error {}
|
|
9710
|
+
/**
|
|
9711
|
+
* @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNotFoundError instead.
|
|
9712
|
+
* @see AiSearchNotFoundError
|
|
9713
|
+
*/
|
|
9486
9714
|
export interface AutoRAGNotFoundError extends Error {}
|
|
9715
|
+
/**
|
|
9716
|
+
* @deprecated This error type is no longer used in the AI Search API.
|
|
9717
|
+
*/
|
|
9487
9718
|
export interface AutoRAGUnauthorizedError extends Error {}
|
|
9719
|
+
/**
|
|
9720
|
+
* @deprecated AutoRAG has been replaced by AI Search. Use AiSearchNameNotSetError instead.
|
|
9721
|
+
* @see AiSearchNameNotSetError
|
|
9722
|
+
*/
|
|
9488
9723
|
export interface AutoRAGNameNotSetError extends Error {}
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
export type CompoundFilter = {
|
|
9495
|
-
type: "and" | "or";
|
|
9496
|
-
filters: ComparisonFilter[];
|
|
9497
|
-
};
|
|
9724
|
+
/**
|
|
9725
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9726
|
+
* Use AiSearchSearchRequest with the new API instead.
|
|
9727
|
+
* @see AiSearchSearchRequest
|
|
9728
|
+
*/
|
|
9498
9729
|
export type AutoRagSearchRequest = {
|
|
9499
9730
|
query: string;
|
|
9500
9731
|
filters?: CompoundFilter | ComparisonFilter;
|
|
@@ -9509,16 +9740,31 @@ export type AutoRagSearchRequest = {
|
|
|
9509
9740
|
};
|
|
9510
9741
|
rewrite_query?: boolean;
|
|
9511
9742
|
};
|
|
9743
|
+
/**
|
|
9744
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9745
|
+
* Use AiSearchChatCompletionsRequest with the new API instead.
|
|
9746
|
+
* @see AiSearchChatCompletionsRequest
|
|
9747
|
+
*/
|
|
9512
9748
|
export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
9513
9749
|
stream?: boolean;
|
|
9514
9750
|
system_prompt?: string;
|
|
9515
9751
|
};
|
|
9752
|
+
/**
|
|
9753
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9754
|
+
* Use AiSearchChatCompletionsRequest with stream: true instead.
|
|
9755
|
+
* @see AiSearchChatCompletionsRequest
|
|
9756
|
+
*/
|
|
9516
9757
|
export type AutoRagAiSearchRequestStreaming = Omit<
|
|
9517
9758
|
AutoRagAiSearchRequest,
|
|
9518
9759
|
"stream"
|
|
9519
9760
|
> & {
|
|
9520
9761
|
stream: true;
|
|
9521
9762
|
};
|
|
9763
|
+
/**
|
|
9764
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9765
|
+
* Use AiSearchSearchResponse with the new API instead.
|
|
9766
|
+
* @see AiSearchSearchResponse
|
|
9767
|
+
*/
|
|
9522
9768
|
export type AutoRagSearchResponse = {
|
|
9523
9769
|
object: "vector_store.search_results.page";
|
|
9524
9770
|
search_query: string;
|
|
@@ -9535,6 +9781,11 @@ export type AutoRagSearchResponse = {
|
|
|
9535
9781
|
has_more: boolean;
|
|
9536
9782
|
next_page: string | null;
|
|
9537
9783
|
};
|
|
9784
|
+
/**
|
|
9785
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9786
|
+
* Use AiSearchListResponse with the new API instead.
|
|
9787
|
+
* @see AiSearchListResponse
|
|
9788
|
+
*/
|
|
9538
9789
|
export type AutoRagListResponse = {
|
|
9539
9790
|
id: string;
|
|
9540
9791
|
enable: boolean;
|
|
@@ -9544,14 +9795,51 @@ export type AutoRagListResponse = {
|
|
|
9544
9795
|
paused: boolean;
|
|
9545
9796
|
status: string;
|
|
9546
9797
|
}[];
|
|
9798
|
+
/**
|
|
9799
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9800
|
+
* The new API returns different response formats for chat completions.
|
|
9801
|
+
*/
|
|
9547
9802
|
export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
9548
9803
|
response: string;
|
|
9549
9804
|
};
|
|
9805
|
+
/**
|
|
9806
|
+
* @deprecated AutoRAG has been replaced by AI Search.
|
|
9807
|
+
* Use the new AI Search API instead: `env.AI.aiSearch`
|
|
9808
|
+
*
|
|
9809
|
+
* Migration guide:
|
|
9810
|
+
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
9811
|
+
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
9812
|
+
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
9813
|
+
*
|
|
9814
|
+
* @see AiSearchAccountService
|
|
9815
|
+
* @see AiSearchInstanceService
|
|
9816
|
+
*/
|
|
9550
9817
|
export declare abstract class AutoRAG {
|
|
9818
|
+
/**
|
|
9819
|
+
* @deprecated Use `env.AI.aiSearch.list()` instead.
|
|
9820
|
+
* @see AiSearchAccountService.list
|
|
9821
|
+
*/
|
|
9551
9822
|
list(): Promise<AutoRagListResponse>;
|
|
9823
|
+
/**
|
|
9824
|
+
* @deprecated Use `env.AI.aiSearch.get(id).search(...)` instead.
|
|
9825
|
+
* Note: The new API uses a messages array instead of a query string.
|
|
9826
|
+
* @see AiSearchInstanceService.search
|
|
9827
|
+
*/
|
|
9552
9828
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
9829
|
+
/**
|
|
9830
|
+
* @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
|
|
9831
|
+
* @see AiSearchInstanceService.chatCompletions
|
|
9832
|
+
*/
|
|
9553
9833
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
9834
|
+
/**
|
|
9835
|
+
* @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
|
|
9836
|
+
* @see AiSearchInstanceService.chatCompletions
|
|
9837
|
+
*/
|
|
9554
9838
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
9839
|
+
/**
|
|
9840
|
+
* @deprecated Use `env.AI.aiSearch.get(id).chatCompletions(...)` instead.
|
|
9841
|
+
* @see AiSearchInstanceService.chatCompletions
|
|
9842
|
+
*/
|
|
9555
9843
|
aiSearch(
|
|
9556
9844
|
params: AutoRagAiSearchRequest,
|
|
9557
9845
|
): Promise<AutoRagAiSearchResponse | Response>;
|