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