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