@cloudflare/workers-types 4.20260329.1 → 4.20260331.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 +379 -124
- package/2021-11-03/index.ts +379 -124
- package/2022-01-31/index.d.ts +379 -124
- package/2022-01-31/index.ts +379 -124
- package/2022-03-21/index.d.ts +379 -124
- package/2022-03-21/index.ts +379 -124
- package/2022-08-04/index.d.ts +379 -124
- package/2022-08-04/index.ts +379 -124
- package/2022-10-31/index.d.ts +379 -124
- package/2022-10-31/index.ts +379 -124
- package/2022-11-30/index.d.ts +379 -124
- package/2022-11-30/index.ts +379 -124
- package/2023-03-01/index.d.ts +379 -124
- package/2023-03-01/index.ts +379 -124
- package/2023-07-01/index.d.ts +379 -124
- package/2023-07-01/index.ts +379 -124
- package/experimental/index.d.ts +393 -126
- package/experimental/index.ts +393 -126
- package/index.d.ts +379 -124
- package/index.ts +379 -124
- package/latest/index.d.ts +379 -124
- package/latest/index.ts +379 -124
- package/oldest/index.d.ts +379 -124
- package/oldest/index.ts +379 -124
- package/package.json +1 -1
package/experimental/index.d.ts
CHANGED
|
@@ -3266,6 +3266,11 @@ interface QueuingStrategyInit {
|
|
|
3266
3266
|
*/
|
|
3267
3267
|
highWaterMark: number;
|
|
3268
3268
|
}
|
|
3269
|
+
interface TracePreviewInfo {
|
|
3270
|
+
id: string;
|
|
3271
|
+
slug: string;
|
|
3272
|
+
name: string;
|
|
3273
|
+
}
|
|
3269
3274
|
interface ScriptVersion {
|
|
3270
3275
|
id?: string;
|
|
3271
3276
|
tag?: string;
|
|
@@ -3300,6 +3305,7 @@ interface TraceItem {
|
|
|
3300
3305
|
readonly dispatchNamespace?: string;
|
|
3301
3306
|
readonly scriptTags?: string[];
|
|
3302
3307
|
readonly tailAttributes?: Record<string, boolean | number | string>;
|
|
3308
|
+
readonly preview?: TracePreviewInfo;
|
|
3303
3309
|
readonly durableObjectId?: string;
|
|
3304
3310
|
readonly outcome: string;
|
|
3305
3311
|
readonly executionModel: string;
|
|
@@ -3941,6 +3947,9 @@ interface Container {
|
|
|
3941
3947
|
snapshotDirectory(
|
|
3942
3948
|
options: ContainerDirectorySnapshotOptions,
|
|
3943
3949
|
): Promise<ContainerDirectorySnapshot>;
|
|
3950
|
+
snapshotContainer(
|
|
3951
|
+
options: ContainerSnapshotOptions,
|
|
3952
|
+
): Promise<ContainerSnapshot>;
|
|
3944
3953
|
}
|
|
3945
3954
|
interface ContainerDirectorySnapshot {
|
|
3946
3955
|
id: string;
|
|
@@ -3952,17 +3961,26 @@ interface ContainerDirectorySnapshotOptions {
|
|
|
3952
3961
|
dir: string;
|
|
3953
3962
|
name?: string;
|
|
3954
3963
|
}
|
|
3955
|
-
interface
|
|
3964
|
+
interface ContainerDirectorySnapshotRestoreParams {
|
|
3956
3965
|
snapshot: ContainerDirectorySnapshot;
|
|
3957
3966
|
mountPoint?: string;
|
|
3958
3967
|
}
|
|
3968
|
+
interface ContainerSnapshot {
|
|
3969
|
+
id: string;
|
|
3970
|
+
size: number;
|
|
3971
|
+
name?: string;
|
|
3972
|
+
}
|
|
3973
|
+
interface ContainerSnapshotOptions {
|
|
3974
|
+
name?: string;
|
|
3975
|
+
}
|
|
3959
3976
|
interface ContainerStartupOptions {
|
|
3960
3977
|
entrypoint?: string[];
|
|
3961
3978
|
enableInternet: boolean;
|
|
3962
3979
|
env?: Record<string, string>;
|
|
3963
3980
|
hardTimeout?: number | bigint;
|
|
3964
3981
|
labels?: Record<string, string>;
|
|
3965
|
-
|
|
3982
|
+
directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
|
|
3983
|
+
containerSnapshot?: ContainerSnapshot;
|
|
3966
3984
|
}
|
|
3967
3985
|
/**
|
|
3968
3986
|
* The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
|
|
@@ -4641,11 +4659,10 @@ interface EventCounts {
|
|
|
4641
4659
|
): void;
|
|
4642
4660
|
[Symbol.iterator](): IterableIterator<string[]>;
|
|
4643
4661
|
}
|
|
4644
|
-
// AI Search
|
|
4662
|
+
// ============ AI Search Error Interfaces ============
|
|
4645
4663
|
interface AiSearchInternalError extends Error {}
|
|
4646
4664
|
interface AiSearchNotFoundError extends Error {}
|
|
4647
|
-
|
|
4648
|
-
// AI Search V2 Request Types
|
|
4665
|
+
// ============ AI Search Request Types ============
|
|
4649
4666
|
type AiSearchSearchRequest = {
|
|
4650
4667
|
messages: Array<{
|
|
4651
4668
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
@@ -4670,9 +4687,8 @@ type AiSearchSearchRequest = {
|
|
|
4670
4687
|
[key: string]: unknown;
|
|
4671
4688
|
};
|
|
4672
4689
|
reranking?: {
|
|
4673
|
-
/** Enable reranking (default false) */
|
|
4674
4690
|
enabled?: boolean;
|
|
4675
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
4691
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
4676
4692
|
/** Match threshold (0-1, default 0.4) */
|
|
4677
4693
|
match_threshold?: number;
|
|
4678
4694
|
[key: string]: unknown;
|
|
@@ -4684,6 +4700,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
4684
4700
|
messages: Array<{
|
|
4685
4701
|
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4686
4702
|
content: string | null;
|
|
4703
|
+
[key: string]: unknown;
|
|
4687
4704
|
}>;
|
|
4688
4705
|
model?: string;
|
|
4689
4706
|
stream?: boolean;
|
|
@@ -4704,7 +4721,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
4704
4721
|
};
|
|
4705
4722
|
reranking?: {
|
|
4706
4723
|
enabled?: boolean;
|
|
4707
|
-
model?: "@cf/baai/bge-reranker-base" |
|
|
4724
|
+
model?: "@cf/baai/bge-reranker-base" | string;
|
|
4708
4725
|
match_threshold?: number;
|
|
4709
4726
|
[key: string]: unknown;
|
|
4710
4727
|
};
|
|
@@ -4712,7 +4729,7 @@ type AiSearchChatCompletionsRequest = {
|
|
|
4712
4729
|
};
|
|
4713
4730
|
[key: string]: unknown;
|
|
4714
4731
|
};
|
|
4715
|
-
// AI Search
|
|
4732
|
+
// ============ AI Search Response Types ============
|
|
4716
4733
|
type AiSearchSearchResponse = {
|
|
4717
4734
|
search_query: string;
|
|
4718
4735
|
chunks: Array<{
|
|
@@ -4731,26 +4748,65 @@ type AiSearchSearchResponse = {
|
|
|
4731
4748
|
keyword_score?: number;
|
|
4732
4749
|
/** Vector similarity score (0-1) */
|
|
4733
4750
|
vector_score?: number;
|
|
4751
|
+
[key: string]: unknown;
|
|
4734
4752
|
};
|
|
4735
4753
|
}>;
|
|
4736
4754
|
};
|
|
4737
|
-
type
|
|
4755
|
+
type AiSearchChatCompletionsResponse = {
|
|
4756
|
+
id?: string;
|
|
4757
|
+
object?: string;
|
|
4758
|
+
model?: string;
|
|
4759
|
+
choices: Array<{
|
|
4760
|
+
index?: number;
|
|
4761
|
+
message: {
|
|
4762
|
+
role: "system" | "developer" | "user" | "assistant" | "tool";
|
|
4763
|
+
content: string | null;
|
|
4764
|
+
[key: string]: unknown;
|
|
4765
|
+
};
|
|
4766
|
+
[key: string]: unknown;
|
|
4767
|
+
}>;
|
|
4768
|
+
chunks: AiSearchSearchResponse["chunks"];
|
|
4769
|
+
[key: string]: unknown;
|
|
4770
|
+
};
|
|
4771
|
+
type AiSearchStatsResponse = {
|
|
4772
|
+
queued?: number;
|
|
4773
|
+
running?: number;
|
|
4774
|
+
completed?: number;
|
|
4775
|
+
error?: number;
|
|
4776
|
+
skipped?: number;
|
|
4777
|
+
outdated?: number;
|
|
4778
|
+
last_activity?: string;
|
|
4779
|
+
};
|
|
4780
|
+
// ============ AI Search Instance Info Types ============
|
|
4781
|
+
type AiSearchInstanceInfo = {
|
|
4738
4782
|
id: string;
|
|
4739
|
-
|
|
4740
|
-
account_id?: string;
|
|
4741
|
-
account_tag?: string;
|
|
4742
|
-
/** Whether the instance is enabled (default true) */
|
|
4743
|
-
enable?: boolean;
|
|
4744
|
-
type?: "r2" | "web-crawler";
|
|
4783
|
+
type?: "r2" | "web-crawler" | string;
|
|
4745
4784
|
source?: string;
|
|
4785
|
+
paused?: boolean;
|
|
4786
|
+
status?: string;
|
|
4787
|
+
namespace?: string;
|
|
4788
|
+
created_at?: string;
|
|
4789
|
+
modified_at?: string;
|
|
4746
4790
|
[key: string]: unknown;
|
|
4747
|
-
}
|
|
4791
|
+
};
|
|
4792
|
+
type AiSearchListResponse = {
|
|
4793
|
+
result: AiSearchInstanceInfo[];
|
|
4794
|
+
result_info?: {
|
|
4795
|
+
count: number;
|
|
4796
|
+
page: number;
|
|
4797
|
+
per_page: number;
|
|
4798
|
+
total_count: number;
|
|
4799
|
+
};
|
|
4800
|
+
};
|
|
4801
|
+
// ============ AI Search Config Types ============
|
|
4748
4802
|
type AiSearchConfig = {
|
|
4749
4803
|
/** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
|
|
4750
4804
|
id: string;
|
|
4751
|
-
type
|
|
4752
|
-
|
|
4753
|
-
|
|
4805
|
+
/** Instance type. Omit to create with built-in storage. */
|
|
4806
|
+
type?: "r2" | "web-crawler" | string;
|
|
4807
|
+
/** Source URL (required for web-crawler type). */
|
|
4808
|
+
source?: string;
|
|
4809
|
+
source_params?: unknown;
|
|
4754
4810
|
/** Token ID (UUID format) */
|
|
4755
4811
|
token_id?: string;
|
|
4756
4812
|
ai_gateway_id?: string;
|
|
@@ -4760,54 +4816,307 @@ type AiSearchConfig = {
|
|
|
4760
4816
|
reranking?: boolean;
|
|
4761
4817
|
embedding_model?: string;
|
|
4762
4818
|
ai_search_model?: string;
|
|
4819
|
+
[key: string]: unknown;
|
|
4763
4820
|
};
|
|
4764
|
-
|
|
4821
|
+
// ============ AI Search Item Types ============
|
|
4822
|
+
type AiSearchItemInfo = {
|
|
4765
4823
|
id: string;
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4824
|
+
key: string;
|
|
4825
|
+
status:
|
|
4826
|
+
| "completed"
|
|
4827
|
+
| "error"
|
|
4828
|
+
| "skipped"
|
|
4829
|
+
| "queued"
|
|
4830
|
+
| "processing"
|
|
4831
|
+
| "outdated";
|
|
4832
|
+
metadata?: Record<string, unknown>;
|
|
4769
4833
|
[key: string]: unknown;
|
|
4770
4834
|
};
|
|
4771
|
-
|
|
4772
|
-
|
|
4835
|
+
type AiSearchItemContentResult = {
|
|
4836
|
+
body: ReadableStream;
|
|
4837
|
+
contentType: string;
|
|
4838
|
+
filename: string;
|
|
4839
|
+
size: number;
|
|
4840
|
+
};
|
|
4841
|
+
type AiSearchUploadItemOptions = {
|
|
4842
|
+
metadata?: Record<string, unknown>;
|
|
4843
|
+
};
|
|
4844
|
+
type AiSearchListItemsParams = {
|
|
4845
|
+
page?: number;
|
|
4846
|
+
per_page?: number;
|
|
4847
|
+
};
|
|
4848
|
+
type AiSearchListItemsResponse = {
|
|
4849
|
+
result: AiSearchItemInfo[];
|
|
4850
|
+
result_info?: {
|
|
4851
|
+
count: number;
|
|
4852
|
+
page: number;
|
|
4853
|
+
per_page: number;
|
|
4854
|
+
total_count: number;
|
|
4855
|
+
};
|
|
4856
|
+
};
|
|
4857
|
+
// ============ AI Search Job Types ============
|
|
4858
|
+
type AiSearchJobInfo = {
|
|
4859
|
+
id: string;
|
|
4860
|
+
source: "user" | "schedule";
|
|
4861
|
+
description?: string;
|
|
4862
|
+
last_seen_at?: string;
|
|
4863
|
+
started_at?: string;
|
|
4864
|
+
ended_at?: string;
|
|
4865
|
+
end_reason?: string;
|
|
4866
|
+
};
|
|
4867
|
+
type AiSearchJobLog = {
|
|
4868
|
+
id: number;
|
|
4869
|
+
message: string;
|
|
4870
|
+
message_type: number;
|
|
4871
|
+
created_at: number;
|
|
4872
|
+
};
|
|
4873
|
+
type AiSearchCreateJobParams = {
|
|
4874
|
+
description?: string;
|
|
4875
|
+
};
|
|
4876
|
+
type AiSearchListJobsParams = {
|
|
4877
|
+
page?: number;
|
|
4878
|
+
per_page?: number;
|
|
4879
|
+
};
|
|
4880
|
+
type AiSearchListJobsResponse = {
|
|
4881
|
+
result: AiSearchJobInfo[];
|
|
4882
|
+
result_info?: {
|
|
4883
|
+
count: number;
|
|
4884
|
+
page: number;
|
|
4885
|
+
per_page: number;
|
|
4886
|
+
total_count: number;
|
|
4887
|
+
};
|
|
4888
|
+
};
|
|
4889
|
+
type AiSearchJobLogsParams = {
|
|
4890
|
+
page?: number;
|
|
4891
|
+
per_page?: number;
|
|
4892
|
+
};
|
|
4893
|
+
type AiSearchJobLogsResponse = {
|
|
4894
|
+
result: AiSearchJobLog[];
|
|
4895
|
+
result_info?: {
|
|
4896
|
+
count: number;
|
|
4897
|
+
page: number;
|
|
4898
|
+
per_page: number;
|
|
4899
|
+
total_count: number;
|
|
4900
|
+
};
|
|
4901
|
+
};
|
|
4902
|
+
// ============ AI Search Sub-Service Classes ============
|
|
4903
|
+
/**
|
|
4904
|
+
* Single item service for an AI Search instance.
|
|
4905
|
+
* Provides info, delete, and download operations on a specific item.
|
|
4906
|
+
*/
|
|
4907
|
+
declare abstract class AiSearchItem {
|
|
4908
|
+
/** Get metadata about this item. */
|
|
4909
|
+
info(): Promise<AiSearchItemInfo>;
|
|
4910
|
+
/**
|
|
4911
|
+
* Download the item's content.
|
|
4912
|
+
* @returns Object with body stream, content type, filename, and size.
|
|
4913
|
+
*/
|
|
4914
|
+
download(): Promise<AiSearchItemContentResult>;
|
|
4915
|
+
}
|
|
4916
|
+
/**
|
|
4917
|
+
* Items collection service for an AI Search instance.
|
|
4918
|
+
* Provides list, upload, and access to individual items.
|
|
4919
|
+
*/
|
|
4920
|
+
declare abstract class AiSearchItems {
|
|
4921
|
+
/** List items in this instance. */
|
|
4922
|
+
list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
|
|
4923
|
+
/**
|
|
4924
|
+
* Upload a file as an item.
|
|
4925
|
+
* @param name Filename for the uploaded item.
|
|
4926
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4927
|
+
* @param options Optional metadata to attach to the item.
|
|
4928
|
+
* @returns The created item info.
|
|
4929
|
+
*/
|
|
4930
|
+
upload(
|
|
4931
|
+
name: string,
|
|
4932
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4933
|
+
options?: AiSearchUploadItemOptions,
|
|
4934
|
+
): Promise<AiSearchItemInfo>;
|
|
4935
|
+
/**
|
|
4936
|
+
* Upload a file and poll until processing completes.
|
|
4937
|
+
* @param name Filename for the uploaded item.
|
|
4938
|
+
* @param content File content as a ReadableStream, ArrayBuffer, or string.
|
|
4939
|
+
* @param options Optional metadata to attach to the item.
|
|
4940
|
+
* @returns The item info after processing completes (or timeout).
|
|
4941
|
+
*/
|
|
4942
|
+
uploadAndPoll(
|
|
4943
|
+
name: string,
|
|
4944
|
+
content: ReadableStream | ArrayBuffer | string,
|
|
4945
|
+
options?: AiSearchUploadItemOptions,
|
|
4946
|
+
): Promise<AiSearchItemInfo>;
|
|
4947
|
+
/**
|
|
4948
|
+
* Get an item by ID.
|
|
4949
|
+
* @param itemId The item identifier.
|
|
4950
|
+
* @returns Item service for info, delete, and download operations.
|
|
4951
|
+
*/
|
|
4952
|
+
get(itemId: string): AiSearchItem;
|
|
4953
|
+
/** Delete this item from the instance.
|
|
4954
|
+
* @param itemId The item identifier.
|
|
4955
|
+
*/
|
|
4956
|
+
delete(itemId: string): Promise<void>;
|
|
4957
|
+
}
|
|
4958
|
+
/**
|
|
4959
|
+
* Single job service for an AI Search instance.
|
|
4960
|
+
* Provides info and logs for a specific job.
|
|
4961
|
+
*/
|
|
4962
|
+
declare abstract class AiSearchJob {
|
|
4963
|
+
/** Get metadata about this job. */
|
|
4964
|
+
info(): Promise<AiSearchJobInfo>;
|
|
4965
|
+
/** Get logs for this job. */
|
|
4966
|
+
logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
|
|
4967
|
+
}
|
|
4968
|
+
/**
|
|
4969
|
+
* Jobs collection service for an AI Search instance.
|
|
4970
|
+
* Provides list, create, and access to individual jobs.
|
|
4971
|
+
*/
|
|
4972
|
+
declare abstract class AiSearchJobs {
|
|
4973
|
+
/** List jobs for this instance. */
|
|
4974
|
+
list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
|
|
4975
|
+
/**
|
|
4976
|
+
* Create a new indexing job.
|
|
4977
|
+
* @param params Optional job parameters.
|
|
4978
|
+
* @returns The created job info.
|
|
4979
|
+
*/
|
|
4980
|
+
create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
|
|
4981
|
+
/**
|
|
4982
|
+
* Get a job by ID.
|
|
4983
|
+
* @param jobId The job identifier.
|
|
4984
|
+
* @returns Job service for info and logs operations.
|
|
4985
|
+
*/
|
|
4986
|
+
get(jobId: string): AiSearchJob;
|
|
4987
|
+
}
|
|
4988
|
+
// ============ AI Search Binding Classes ============
|
|
4989
|
+
/**
|
|
4990
|
+
* Instance-level AI Search service.
|
|
4991
|
+
*
|
|
4992
|
+
* Used as:
|
|
4993
|
+
* - The return type of `AiSearchNamespace.get(name)` (namespace binding)
|
|
4994
|
+
* - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
|
|
4995
|
+
*
|
|
4996
|
+
* Provides search, chat, update, stats, items, and jobs operations.
|
|
4997
|
+
*
|
|
4998
|
+
* @example
|
|
4999
|
+
* ```ts
|
|
5000
|
+
* // Via namespace binding
|
|
5001
|
+
* const instance = env.AI_SEARCH.get("blog");
|
|
5002
|
+
* const results = await instance.search({
|
|
5003
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
5004
|
+
* });
|
|
5005
|
+
*
|
|
5006
|
+
* // Via single instance binding
|
|
5007
|
+
* const results = await env.BLOG_SEARCH.search({
|
|
5008
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
5009
|
+
* });
|
|
5010
|
+
* ```
|
|
5011
|
+
*/
|
|
5012
|
+
declare abstract class AiSearchInstance {
|
|
4773
5013
|
/**
|
|
4774
5014
|
* Search the AI Search instance for relevant chunks.
|
|
4775
|
-
* @param params Search request with messages and AI search options
|
|
4776
|
-
* @returns Search response with matching chunks
|
|
5015
|
+
* @param params Search request with messages and optional AI search options.
|
|
5016
|
+
* @returns Search response with matching chunks and search query.
|
|
4777
5017
|
*/
|
|
4778
5018
|
search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
|
|
5019
|
+
/**
|
|
5020
|
+
* Generate chat completions with AI Search context (streaming).
|
|
5021
|
+
* @param params Chat completions request with stream: true.
|
|
5022
|
+
* @returns ReadableStream of server-sent events.
|
|
5023
|
+
*/
|
|
5024
|
+
chatCompletions(
|
|
5025
|
+
params: AiSearchChatCompletionsRequest & {
|
|
5026
|
+
stream: true;
|
|
5027
|
+
},
|
|
5028
|
+
): Promise<ReadableStream>;
|
|
4779
5029
|
/**
|
|
4780
5030
|
* Generate chat completions with AI Search context.
|
|
4781
|
-
* @param params Chat completions request
|
|
4782
|
-
* @returns
|
|
5031
|
+
* @param params Chat completions request.
|
|
5032
|
+
* @returns Chat completion response with choices and RAG chunks.
|
|
4783
5033
|
*/
|
|
4784
5034
|
chatCompletions(
|
|
4785
5035
|
params: AiSearchChatCompletionsRequest,
|
|
4786
|
-
): Promise<
|
|
5036
|
+
): Promise<AiSearchChatCompletionsResponse>;
|
|
4787
5037
|
/**
|
|
4788
|
-
*
|
|
5038
|
+
* Update the instance configuration.
|
|
5039
|
+
* @param config Partial configuration to update.
|
|
5040
|
+
* @returns Updated instance info.
|
|
4789
5041
|
*/
|
|
4790
|
-
|
|
5042
|
+
update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
|
|
5043
|
+
/** Get metadata about this instance. */
|
|
5044
|
+
info(): Promise<AiSearchInstanceInfo>;
|
|
5045
|
+
/**
|
|
5046
|
+
* Get instance statistics (item count, indexing status, etc.).
|
|
5047
|
+
* @returns Statistics with counts per status and last activity time.
|
|
5048
|
+
*/
|
|
5049
|
+
stats(): Promise<AiSearchStatsResponse>;
|
|
5050
|
+
/** Items collection — list, upload, and manage items in this instance. */
|
|
5051
|
+
get items(): AiSearchItems;
|
|
5052
|
+
/** Jobs collection — list, create, and inspect indexing jobs. */
|
|
5053
|
+
get jobs(): AiSearchJobs;
|
|
4791
5054
|
}
|
|
4792
|
-
|
|
4793
|
-
|
|
5055
|
+
/**
|
|
5056
|
+
* Namespace-level AI Search service.
|
|
5057
|
+
*
|
|
5058
|
+
* Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
|
|
5059
|
+
* Scoped to a single namespace. Provides dynamic instance access, creation, and deletion.
|
|
5060
|
+
*
|
|
5061
|
+
* @example
|
|
5062
|
+
* ```ts
|
|
5063
|
+
* // Access an instance within the namespace
|
|
5064
|
+
* const blog = env.AI_SEARCH.get("blog");
|
|
5065
|
+
* const results = await blog.search({
|
|
5066
|
+
* messages: [{ role: "user", content: "How does caching work?" }],
|
|
5067
|
+
* });
|
|
5068
|
+
*
|
|
5069
|
+
* // List all instances in the namespace
|
|
5070
|
+
* const instances = await env.AI_SEARCH.list();
|
|
5071
|
+
*
|
|
5072
|
+
* // Create a new instance with built-in storage
|
|
5073
|
+
* const tenant = await env.AI_SEARCH.create({
|
|
5074
|
+
* id: "tenant-123",
|
|
5075
|
+
* });
|
|
5076
|
+
*
|
|
5077
|
+
* // Upload items into the instance
|
|
5078
|
+
* await tenant.items.upload("doc.pdf", fileContent);
|
|
5079
|
+
*
|
|
5080
|
+
* // Delete an instance
|
|
5081
|
+
* await env.AI_SEARCH.delete("tenant-123");
|
|
5082
|
+
* ```
|
|
5083
|
+
*/
|
|
5084
|
+
declare abstract class AiSearchNamespace {
|
|
5085
|
+
/**
|
|
5086
|
+
* Get an instance by name within the bound namespace.
|
|
5087
|
+
* @param name Instance name.
|
|
5088
|
+
* @returns Instance service for search, chat, update, stats, items, and jobs.
|
|
5089
|
+
*/
|
|
5090
|
+
get(name: string): AiSearchInstance;
|
|
4794
5091
|
/**
|
|
4795
|
-
* List all
|
|
4796
|
-
* @returns Array of
|
|
5092
|
+
* List all instances in the bound namespace.
|
|
5093
|
+
* @returns Array of instance metadata.
|
|
4797
5094
|
*/
|
|
4798
5095
|
list(): Promise<AiSearchListResponse>;
|
|
4799
5096
|
/**
|
|
4800
|
-
*
|
|
4801
|
-
* @param
|
|
4802
|
-
* @returns Instance service for
|
|
5097
|
+
* Create a new instance within the bound namespace.
|
|
5098
|
+
* @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.
|
|
5099
|
+
* @returns Instance service for the newly created instance.
|
|
5100
|
+
*
|
|
5101
|
+
* @example
|
|
5102
|
+
* ```ts
|
|
5103
|
+
* // Create with built-in storage (upload items manually)
|
|
5104
|
+
* const instance = await env.AI_SEARCH.create({ id: "my-search" });
|
|
5105
|
+
*
|
|
5106
|
+
* // Create with web crawler source
|
|
5107
|
+
* const instance = await env.AI_SEARCH.create({
|
|
5108
|
+
* id: "docs-search",
|
|
5109
|
+
* type: "web-crawler",
|
|
5110
|
+
* source: "https://developers.cloudflare.com",
|
|
5111
|
+
* });
|
|
5112
|
+
* ```
|
|
4803
5113
|
*/
|
|
4804
|
-
|
|
5114
|
+
create(config: AiSearchConfig): Promise<AiSearchInstance>;
|
|
4805
5115
|
/**
|
|
4806
|
-
*
|
|
4807
|
-
* @param
|
|
4808
|
-
* @returns Instance service for performing operations
|
|
5116
|
+
* Delete an instance from the bound namespace.
|
|
5117
|
+
* @param name Instance name to delete.
|
|
4809
5118
|
*/
|
|
4810
|
-
|
|
5119
|
+
delete(name: string): Promise<void>;
|
|
4811
5120
|
}
|
|
4812
5121
|
type AiImageClassificationInput = {
|
|
4813
5122
|
image: number[];
|
|
@@ -10805,6 +11114,7 @@ type AiOptions = {
|
|
|
10805
11114
|
returnRawResponse?: boolean;
|
|
10806
11115
|
prefix?: string;
|
|
10807
11116
|
extraHeaders?: object;
|
|
11117
|
+
signal?: AbortSignal;
|
|
10808
11118
|
};
|
|
10809
11119
|
type AiModelsSearchParams = {
|
|
10810
11120
|
author?: string;
|
|
@@ -10848,46 +11158,16 @@ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
|
|
|
10848
11158
|
aiGatewayLogId: string | null;
|
|
10849
11159
|
gateway(gatewayId: string): AiGateway;
|
|
10850
11160
|
/**
|
|
10851
|
-
*
|
|
10852
|
-
*
|
|
10853
|
-
* This is the new API that replaces AutoRAG with better namespace separation:
|
|
10854
|
-
* - Account-level operations: `list()`, `create()`
|
|
10855
|
-
* - Instance-level operations: `get(id).search()`, `get(id).chatCompletions()`, `get(id).delete()`
|
|
10856
|
-
*
|
|
10857
|
-
* @example
|
|
10858
|
-
* ```typescript
|
|
10859
|
-
* // List all AI Search instances
|
|
10860
|
-
* const instances = await env.AI.aiSearch.list();
|
|
10861
|
-
*
|
|
10862
|
-
* // Search an instance
|
|
10863
|
-
* const results = await env.AI.aiSearch.get('my-search').search({
|
|
10864
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10865
|
-
* ai_search_options: {
|
|
10866
|
-
* retrieval: { max_num_results: 10 }
|
|
10867
|
-
* }
|
|
10868
|
-
* });
|
|
10869
|
-
*
|
|
10870
|
-
* // Generate chat completions with AI Search context
|
|
10871
|
-
* const response = await env.AI.aiSearch.get('my-search').chatCompletions({
|
|
10872
|
-
* messages: [{ role: 'user', content: 'What is the policy?' }],
|
|
10873
|
-
* model: '@cf/meta/llama-3.3-70b-instruct-fp8-fast'
|
|
10874
|
-
* });
|
|
10875
|
-
* ```
|
|
11161
|
+
* @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
11162
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10876
11163
|
*/
|
|
10877
|
-
aiSearch():
|
|
11164
|
+
aiSearch(): AiSearchNamespace;
|
|
10878
11165
|
/**
|
|
10879
11166
|
* @deprecated AutoRAG has been replaced by AI Search.
|
|
10880
|
-
* Use `
|
|
11167
|
+
* Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
|
|
11168
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
10881
11169
|
*
|
|
10882
|
-
*
|
|
10883
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
10884
|
-
* - `env.AI.autorag('id').search({ query: '...' })` → `env.AI.aiSearch.get('id').search({ messages: [{ role: 'user', content: '...' }] })`
|
|
10885
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
10886
|
-
*
|
|
10887
|
-
* Note: The old API continues to work for backwards compatibility, but new projects should use AI Search.
|
|
10888
|
-
*
|
|
10889
|
-
* @see AiSearchAccountService
|
|
10890
|
-
* @param autoragId Optional instance ID (omit for account-level operations)
|
|
11170
|
+
* @param autoragId Instance ID
|
|
10891
11171
|
*/
|
|
10892
11172
|
autorag(autoragId: string): AutoRAG;
|
|
10893
11173
|
run<
|
|
@@ -11046,22 +11326,23 @@ declare abstract class AiGateway {
|
|
|
11046
11326
|
getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
|
|
11047
11327
|
}
|
|
11048
11328
|
/**
|
|
11049
|
-
* @deprecated
|
|
11050
|
-
*
|
|
11329
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11330
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11051
11331
|
*/
|
|
11052
11332
|
interface AutoRAGInternalError extends Error {}
|
|
11053
11333
|
/**
|
|
11054
|
-
* @deprecated
|
|
11055
|
-
*
|
|
11334
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11335
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11056
11336
|
*/
|
|
11057
11337
|
interface AutoRAGNotFoundError extends Error {}
|
|
11058
11338
|
/**
|
|
11059
|
-
* @deprecated
|
|
11339
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11340
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11060
11341
|
*/
|
|
11061
11342
|
interface AutoRAGUnauthorizedError extends Error {}
|
|
11062
11343
|
/**
|
|
11063
|
-
* @deprecated
|
|
11064
|
-
*
|
|
11344
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11345
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11065
11346
|
*/
|
|
11066
11347
|
interface AutoRAGNameNotSetError extends Error {}
|
|
11067
11348
|
type ComparisonFilter = {
|
|
@@ -11074,9 +11355,8 @@ type CompoundFilter = {
|
|
|
11074
11355
|
filters: ComparisonFilter[];
|
|
11075
11356
|
};
|
|
11076
11357
|
/**
|
|
11077
|
-
* @deprecated
|
|
11078
|
-
*
|
|
11079
|
-
* @see AiSearchSearchRequest
|
|
11358
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11359
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11080
11360
|
*/
|
|
11081
11361
|
type AutoRagSearchRequest = {
|
|
11082
11362
|
query: string;
|
|
@@ -11093,18 +11373,16 @@ type AutoRagSearchRequest = {
|
|
|
11093
11373
|
rewrite_query?: boolean;
|
|
11094
11374
|
};
|
|
11095
11375
|
/**
|
|
11096
|
-
* @deprecated
|
|
11097
|
-
*
|
|
11098
|
-
* @see AiSearchChatCompletionsRequest
|
|
11376
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11377
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11099
11378
|
*/
|
|
11100
11379
|
type AutoRagAiSearchRequest = AutoRagSearchRequest & {
|
|
11101
11380
|
stream?: boolean;
|
|
11102
11381
|
system_prompt?: string;
|
|
11103
11382
|
};
|
|
11104
11383
|
/**
|
|
11105
|
-
* @deprecated
|
|
11106
|
-
*
|
|
11107
|
-
* @see AiSearchChatCompletionsRequest
|
|
11384
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11385
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11108
11386
|
*/
|
|
11109
11387
|
type AutoRagAiSearchRequestStreaming = Omit<
|
|
11110
11388
|
AutoRagAiSearchRequest,
|
|
@@ -11113,9 +11391,8 @@ type AutoRagAiSearchRequestStreaming = Omit<
|
|
|
11113
11391
|
stream: true;
|
|
11114
11392
|
};
|
|
11115
11393
|
/**
|
|
11116
|
-
* @deprecated
|
|
11117
|
-
*
|
|
11118
|
-
* @see AiSearchSearchResponse
|
|
11394
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11395
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11119
11396
|
*/
|
|
11120
11397
|
type AutoRagSearchResponse = {
|
|
11121
11398
|
object: "vector_store.search_results.page";
|
|
@@ -11134,9 +11411,8 @@ type AutoRagSearchResponse = {
|
|
|
11134
11411
|
next_page: string | null;
|
|
11135
11412
|
};
|
|
11136
11413
|
/**
|
|
11137
|
-
* @deprecated
|
|
11138
|
-
*
|
|
11139
|
-
* @see AiSearchListResponse
|
|
11414
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11415
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11140
11416
|
*/
|
|
11141
11417
|
type AutoRagListResponse = {
|
|
11142
11418
|
id: string;
|
|
@@ -11148,49 +11424,40 @@ type AutoRagListResponse = {
|
|
|
11148
11424
|
status: string;
|
|
11149
11425
|
}[];
|
|
11150
11426
|
/**
|
|
11151
|
-
* @deprecated
|
|
11152
|
-
*
|
|
11427
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11428
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11153
11429
|
*/
|
|
11154
11430
|
type AutoRagAiSearchResponse = AutoRagSearchResponse & {
|
|
11155
11431
|
response: string;
|
|
11156
11432
|
};
|
|
11157
11433
|
/**
|
|
11158
|
-
* @deprecated
|
|
11159
|
-
*
|
|
11160
|
-
*
|
|
11161
|
-
* Migration guide:
|
|
11162
|
-
* - `env.AI.autorag().list()` → `env.AI.aiSearch.list()`
|
|
11163
|
-
* - `env.AI.autorag('id').search(...)` → `env.AI.aiSearch.get('id').search(...)`
|
|
11164
|
-
* - `env.AI.autorag('id').aiSearch(...)` → `env.AI.aiSearch.get('id').chatCompletions(...)`
|
|
11165
|
-
*
|
|
11166
|
-
* @see AiSearchAccountService
|
|
11167
|
-
* @see AiSearchInstanceService
|
|
11434
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11435
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11168
11436
|
*/
|
|
11169
11437
|
declare abstract class AutoRAG {
|
|
11170
11438
|
/**
|
|
11171
|
-
* @deprecated Use
|
|
11172
|
-
*
|
|
11439
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11440
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11173
11441
|
*/
|
|
11174
11442
|
list(): Promise<AutoRagListResponse>;
|
|
11175
11443
|
/**
|
|
11176
|
-
* @deprecated Use
|
|
11177
|
-
*
|
|
11178
|
-
* @see AiSearchInstanceService.search
|
|
11444
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11445
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11179
11446
|
*/
|
|
11180
11447
|
search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
|
|
11181
11448
|
/**
|
|
11182
|
-
* @deprecated Use
|
|
11183
|
-
*
|
|
11449
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11450
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11184
11451
|
*/
|
|
11185
11452
|
aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
|
|
11186
11453
|
/**
|
|
11187
|
-
* @deprecated Use
|
|
11188
|
-
*
|
|
11454
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11455
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11189
11456
|
*/
|
|
11190
11457
|
aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
|
|
11191
11458
|
/**
|
|
11192
|
-
* @deprecated Use
|
|
11193
|
-
*
|
|
11459
|
+
* @deprecated Use the standalone AI Search Workers binding instead.
|
|
11460
|
+
* See https://developers.cloudflare.com/ai-search/usage/workers-binding/
|
|
11194
11461
|
*/
|
|
11195
11462
|
aiSearch(
|
|
11196
11463
|
params: AutoRagAiSearchRequest,
|