@cloudflare/workers-types 4.20260527.1 → 4.20260529.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 +740 -0
- package/2021-11-03/index.ts +740 -0
- package/2022-01-31/index.d.ts +740 -0
- package/2022-01-31/index.ts +740 -0
- package/2022-03-21/index.d.ts +740 -0
- package/2022-03-21/index.ts +740 -0
- package/2022-08-04/index.d.ts +740 -0
- package/2022-08-04/index.ts +740 -0
- package/2022-10-31/index.d.ts +740 -0
- package/2022-10-31/index.ts +740 -0
- package/2022-11-30/index.d.ts +740 -0
- package/2022-11-30/index.ts +740 -0
- package/2023-03-01/index.d.ts +740 -0
- package/2023-03-01/index.ts +740 -0
- package/2023-07-01/index.d.ts +740 -0
- package/2023-07-01/index.ts +740 -0
- package/experimental/index.d.ts +740 -0
- package/experimental/index.ts +740 -0
- package/index.d.ts +740 -0
- package/index.ts +740 -0
- package/latest/index.d.ts +740 -0
- package/latest/index.ts +740 -0
- package/oldest/index.d.ts +740 -0
- package/oldest/index.ts +740 -0
- package/package.json +1 -1
package/2021-11-03/index.ts
CHANGED
|
@@ -3931,6 +3931,239 @@ export declare abstract class Span {
|
|
|
3931
3931
|
get isTraced(): boolean;
|
|
3932
3932
|
setAttribute(key: string, value?: boolean | number | string): void;
|
|
3933
3933
|
}
|
|
3934
|
+
// ============================================================================
|
|
3935
|
+
// Agent Memory
|
|
3936
|
+
//
|
|
3937
|
+
// Public type surface for user Workers binding to an Agent Memory namespace.
|
|
3938
|
+
// ============================================================================
|
|
3939
|
+
/** Memory type — every memory is classified into exactly one. */
|
|
3940
|
+
export type AgentMemoryMemoryType = "fact" | "event" | "instruction" | "task";
|
|
3941
|
+
/** Search intensity for recall. */
|
|
3942
|
+
export type AgentMemoryThinkingLevel = "low" | "medium" | "high";
|
|
3943
|
+
/** Response verbosity for recall. */
|
|
3944
|
+
export type AgentMemoryResponseLength = "short" | "medium" | "long";
|
|
3945
|
+
/** A conversation message passed to ingest(). */
|
|
3946
|
+
export interface AgentMemoryMessage {
|
|
3947
|
+
role: "system" | "user" | "assistant";
|
|
3948
|
+
content: string;
|
|
3949
|
+
/** Optional message timestamp. */
|
|
3950
|
+
timestamp?: Date;
|
|
3951
|
+
}
|
|
3952
|
+
/** Raw memory content passed to remember(). */
|
|
3953
|
+
export interface AgentMemoryIncomingMemory {
|
|
3954
|
+
/** Raw memory content. The service classifies and summarizes automatically. */
|
|
3955
|
+
content: string;
|
|
3956
|
+
/** Optional session identifier to associate with this memory. */
|
|
3957
|
+
sessionId?: string | null | undefined;
|
|
3958
|
+
}
|
|
3959
|
+
/** A stored memory returned from remember(), get(), and delete(). */
|
|
3960
|
+
export interface AgentMemoryMemory {
|
|
3961
|
+
/** Memory ID. */
|
|
3962
|
+
id: string;
|
|
3963
|
+
/** Memory type. */
|
|
3964
|
+
type: AgentMemoryMemoryType;
|
|
3965
|
+
/** Text summary. */
|
|
3966
|
+
summary: string;
|
|
3967
|
+
/** Memory text. */
|
|
3968
|
+
content: string;
|
|
3969
|
+
/** Session that created this memory. */
|
|
3970
|
+
sessionId: string | null;
|
|
3971
|
+
/** Memory creation time. */
|
|
3972
|
+
createdAt: Date;
|
|
3973
|
+
/** Memory last-update time. */
|
|
3974
|
+
updatedAt: Date;
|
|
3975
|
+
}
|
|
3976
|
+
/** Single entry in a list() response. Same shape as Memory minus full content. */
|
|
3977
|
+
export type AgentMemoryMemoryListEntry = Omit<AgentMemoryMemory, "content">;
|
|
3978
|
+
/** A scored memory candidate in a recall result. */
|
|
3979
|
+
export interface AgentMemoryScoredCandidate {
|
|
3980
|
+
/** Candidate ID. */
|
|
3981
|
+
id: string;
|
|
3982
|
+
/** Text summary. */
|
|
3983
|
+
summary: string;
|
|
3984
|
+
/** Session that created this candidate, when known. */
|
|
3985
|
+
sessionId: string | null;
|
|
3986
|
+
/** Relevance score (higher is better). Comparable only within a single query. */
|
|
3987
|
+
score: number;
|
|
3988
|
+
}
|
|
3989
|
+
/** Options for the ingest() method. */
|
|
3990
|
+
export interface AgentMemoryIngestOptions {
|
|
3991
|
+
/** Session identifier to associate with memories created during ingestion. */
|
|
3992
|
+
sessionId?: string | null | undefined;
|
|
3993
|
+
}
|
|
3994
|
+
/** Options for the getSummary() method. */
|
|
3995
|
+
export interface AgentMemoryGetSummaryOptions {
|
|
3996
|
+
/** Session identifier to retrieve session summary for. */
|
|
3997
|
+
sessionId?: string | null | undefined;
|
|
3998
|
+
}
|
|
3999
|
+
/** Response from the getSummary() method. */
|
|
4000
|
+
export interface AgentMemoryGetSummaryResponse {
|
|
4001
|
+
/** Markdown summary. */
|
|
4002
|
+
summary: string;
|
|
4003
|
+
}
|
|
4004
|
+
/**
|
|
4005
|
+
* Options for the recall() method.
|
|
4006
|
+
*
|
|
4007
|
+
* `referenceDate` accepts a Date object, an ISO-8601 date string
|
|
4008
|
+
* (YYYY-MM-DD), or a full ISO-8601 datetime string. When provided, this
|
|
4009
|
+
* date is used as "today" for resolving relative time references
|
|
4010
|
+
* ("how many days ago", "last week") instead of the server's wall-clock time.
|
|
4011
|
+
*/
|
|
4012
|
+
export interface AgentMemoryRecallOptions {
|
|
4013
|
+
/** Recall intensity: "low" (default), "medium", or "high". */
|
|
4014
|
+
thinkingLevel?: AgentMemoryThinkingLevel;
|
|
4015
|
+
/** Response verbosity: "short", "medium" (default), or "long". */
|
|
4016
|
+
responseLength?: AgentMemoryResponseLength;
|
|
4017
|
+
/** Temporal anchor for date arithmetic. */
|
|
4018
|
+
referenceDate?: Date | string;
|
|
4019
|
+
}
|
|
4020
|
+
/** Response from the recall() method. */
|
|
4021
|
+
export interface AgentMemoryRecallResult {
|
|
4022
|
+
/** Number of memories retrieved. */
|
|
4023
|
+
count: number;
|
|
4024
|
+
/** LLM-generated answer synthesizing the matching memories. */
|
|
4025
|
+
answer: string;
|
|
4026
|
+
/** Matching memories ranked by relevance. */
|
|
4027
|
+
candidates: AgentMemoryScoredCandidate[];
|
|
4028
|
+
}
|
|
4029
|
+
/**
|
|
4030
|
+
* Options for the list() method.
|
|
4031
|
+
*
|
|
4032
|
+
* `cursor` is the opaque continuation token returned by the previous page;
|
|
4033
|
+
* pass it back unchanged to fetch the next page. `sessionId` and `type`
|
|
4034
|
+
* are exact-match filters; combining them is allowed.
|
|
4035
|
+
*/
|
|
4036
|
+
export interface AgentMemoryListMemoriesOptions {
|
|
4037
|
+
/** Maximum number of memories to return. Default 20, max 500. */
|
|
4038
|
+
limit?: number;
|
|
4039
|
+
/** Opaque cursor from a previous page. */
|
|
4040
|
+
cursor?: string;
|
|
4041
|
+
/** Exact-match session filter. */
|
|
4042
|
+
sessionId?: string;
|
|
4043
|
+
/** Exact-match memory-type filter. */
|
|
4044
|
+
type?: AgentMemoryMemoryType;
|
|
4045
|
+
}
|
|
4046
|
+
/** Response from the list() method. */
|
|
4047
|
+
export interface AgentMemoryListMemoriesResult {
|
|
4048
|
+
memories: AgentMemoryMemoryListEntry[];
|
|
4049
|
+
/** Continuation cursor; absent when this page exhausted the result set. */
|
|
4050
|
+
cursor?: string;
|
|
4051
|
+
}
|
|
4052
|
+
/**
|
|
4053
|
+
* A single Agent Memory profile, scoped to a profile name.
|
|
4054
|
+
*
|
|
4055
|
+
* Returned by {@link AgentMemoryNamespace.getProfile}.
|
|
4056
|
+
*/
|
|
4057
|
+
export declare abstract class AgentMemoryProfile {
|
|
4058
|
+
/**
|
|
4059
|
+
* Retrieve a memory by ID.
|
|
4060
|
+
*
|
|
4061
|
+
* @param memoryId - ULID of the memory to retrieve.
|
|
4062
|
+
* @throws if the memory does not exist.
|
|
4063
|
+
*/
|
|
4064
|
+
get(memoryId: string): Promise<AgentMemoryMemory>;
|
|
4065
|
+
/**
|
|
4066
|
+
* Delete a memory by ID.
|
|
4067
|
+
*
|
|
4068
|
+
* Removes the memory and any source messages linked by the memory's
|
|
4069
|
+
* source message IDs.
|
|
4070
|
+
*
|
|
4071
|
+
* @param memoryId - ULID of the memory to delete.
|
|
4072
|
+
* @throws if the memory does not exist.
|
|
4073
|
+
*/
|
|
4074
|
+
delete(memoryId: string): Promise<AgentMemoryMemory>;
|
|
4075
|
+
/**
|
|
4076
|
+
* Store a memory in this profile. The content is automatically classified,
|
|
4077
|
+
* summarized, and indexed.
|
|
4078
|
+
*
|
|
4079
|
+
* @param memory - Raw memory content to persist.
|
|
4080
|
+
*/
|
|
4081
|
+
remember(memory: AgentMemoryIncomingMemory): Promise<AgentMemoryMemory>;
|
|
4082
|
+
/**
|
|
4083
|
+
* Extract memories from a conversation.
|
|
4084
|
+
*
|
|
4085
|
+
* @param messages - Conversation messages to extract memories from.
|
|
4086
|
+
* @param options - Optional ingest options.
|
|
4087
|
+
*/
|
|
4088
|
+
ingest(
|
|
4089
|
+
messages: Iterable<AgentMemoryMessage>,
|
|
4090
|
+
options?: AgentMemoryIngestOptions,
|
|
4091
|
+
): Promise<void>;
|
|
4092
|
+
/**
|
|
4093
|
+
* Get a profile summary.
|
|
4094
|
+
*
|
|
4095
|
+
* @param options - Optional getSummary options.
|
|
4096
|
+
*/
|
|
4097
|
+
getSummary(
|
|
4098
|
+
options?: AgentMemoryGetSummaryOptions,
|
|
4099
|
+
): Promise<AgentMemoryGetSummaryResponse>;
|
|
4100
|
+
/**
|
|
4101
|
+
* Recall memories in this profile.
|
|
4102
|
+
*
|
|
4103
|
+
* @param query - Recall query matched against memory content and keywords.
|
|
4104
|
+
* @param options - Optional recall parameters.
|
|
4105
|
+
* @returns Matching memories with relevance scores and a synthesized answer.
|
|
4106
|
+
*/
|
|
4107
|
+
recall(
|
|
4108
|
+
query: string,
|
|
4109
|
+
options?: AgentMemoryRecallOptions,
|
|
4110
|
+
): Promise<AgentMemoryRecallResult>;
|
|
4111
|
+
/**
|
|
4112
|
+
* List active memories in this profile.
|
|
4113
|
+
*
|
|
4114
|
+
* Returns a paginated, filterable view of stored memories. Superseded
|
|
4115
|
+
* versions are excluded. Use the returned `cursor` (when present) to
|
|
4116
|
+
* fetch the next page.
|
|
4117
|
+
*
|
|
4118
|
+
* @param options - Optional pagination and filter options.
|
|
4119
|
+
*/
|
|
4120
|
+
list(
|
|
4121
|
+
options?: AgentMemoryListMemoriesOptions,
|
|
4122
|
+
): Promise<AgentMemoryListMemoriesResult>;
|
|
4123
|
+
/**
|
|
4124
|
+
* Soft-delete every memory and message in this profile that is tagged
|
|
4125
|
+
* with `sessionId`.
|
|
4126
|
+
*
|
|
4127
|
+
* Idempotent: deleting a sessionId that has no rows is a no-op.
|
|
4128
|
+
*
|
|
4129
|
+
* @param sessionId - Session to delete.
|
|
4130
|
+
*/
|
|
4131
|
+
deleteSession(sessionId: string): Promise<void>;
|
|
4132
|
+
}
|
|
4133
|
+
/**
|
|
4134
|
+
* Namespace-level Agent Memory binding.
|
|
4135
|
+
*
|
|
4136
|
+
* Used as the type of an `env.MEMORY`-style binding backed by the Agent
|
|
4137
|
+
* Memory product.
|
|
4138
|
+
*
|
|
4139
|
+
* @example
|
|
4140
|
+
* ```ts
|
|
4141
|
+
* export default {
|
|
4142
|
+
* async fetch(_request: Request, env: Env): Promise<Response> {
|
|
4143
|
+
* const profile = await env.MEMORY.getProfile("wrangler-e2e");
|
|
4144
|
+
* const summary = await profile.getSummary();
|
|
4145
|
+
* return Response.json(summary);
|
|
4146
|
+
* },
|
|
4147
|
+
* };
|
|
4148
|
+
* ```
|
|
4149
|
+
*/
|
|
4150
|
+
export declare abstract class AgentMemoryNamespace {
|
|
4151
|
+
/**
|
|
4152
|
+
* Get a memory profile by name. Profiles are isolated by namespace and
|
|
4153
|
+
* addressed by a compound key (namespaceId:profileName).
|
|
4154
|
+
*
|
|
4155
|
+
* @param profileName - Profile name (validated against naming rules).
|
|
4156
|
+
* @returns RPC target for interacting with the profile.
|
|
4157
|
+
*/
|
|
4158
|
+
getProfile(profileName: string): Promise<AgentMemoryProfile>;
|
|
4159
|
+
/**
|
|
4160
|
+
* Soft-delete a profile and schedule deferred purge. Marks all
|
|
4161
|
+
* memories and messages as deleted.
|
|
4162
|
+
*
|
|
4163
|
+
* @param profileName - Name of the profile to delete.
|
|
4164
|
+
*/
|
|
4165
|
+
deleteProfile(profileName: string): Promise<void>;
|
|
4166
|
+
}
|
|
3934
4167
|
// ============ AI Search Error Interfaces ============
|
|
3935
4168
|
export interface AiSearchInternalError extends Error {}
|
|
3936
4169
|
export interface AiSearchNotFoundError extends Error {}
|
|
@@ -11346,6 +11579,513 @@ export declare abstract class AutoRAG {
|
|
|
11346
11579
|
params: AutoRagAiSearchRequest,
|
|
11347
11580
|
): Promise<AutoRagAiSearchResponse | Response>;
|
|
11348
11581
|
}
|
|
11582
|
+
export type BrowserRunLifecycleEvent =
|
|
11583
|
+
| "load"
|
|
11584
|
+
| "domcontentloaded"
|
|
11585
|
+
| "networkidle0"
|
|
11586
|
+
| "networkidle2";
|
|
11587
|
+
export type BrowserRunResourceType =
|
|
11588
|
+
| "document"
|
|
11589
|
+
| "stylesheet"
|
|
11590
|
+
| "image"
|
|
11591
|
+
| "media"
|
|
11592
|
+
| "font"
|
|
11593
|
+
| "script"
|
|
11594
|
+
| "texttrack"
|
|
11595
|
+
| "xhr"
|
|
11596
|
+
| "fetch"
|
|
11597
|
+
| "prefetch"
|
|
11598
|
+
| "eventsource"
|
|
11599
|
+
| "websocket"
|
|
11600
|
+
| "manifest"
|
|
11601
|
+
| "signedexchange"
|
|
11602
|
+
| "ping"
|
|
11603
|
+
| "cspviolationreport"
|
|
11604
|
+
| "preflight"
|
|
11605
|
+
| "other";
|
|
11606
|
+
/** Options fields shared by all quick actions. */
|
|
11607
|
+
export interface BrowserRunBaseOptions {
|
|
11608
|
+
/** Adds `<script>` tags into the page with the desired URL or content.
|
|
11609
|
+
* @see https://pptr.dev/api/puppeteer.frameaddscripttagoptions
|
|
11610
|
+
*/
|
|
11611
|
+
addScriptTag?: Array<{
|
|
11612
|
+
content?: string;
|
|
11613
|
+
url?: string;
|
|
11614
|
+
type?: string;
|
|
11615
|
+
id?: string;
|
|
11616
|
+
}>;
|
|
11617
|
+
/** Adds `<link rel="stylesheet">` or `<style>` tags into the page.
|
|
11618
|
+
* @see https://pptr.dev/api/puppeteer.frameaddstyletagoptions
|
|
11619
|
+
*/
|
|
11620
|
+
addStyleTag?: Array<{
|
|
11621
|
+
content?: string;
|
|
11622
|
+
url?: string;
|
|
11623
|
+
}>;
|
|
11624
|
+
/** Provide credentials for HTTP authentication. @see https://pptr.dev/api/puppeteer.credentials */
|
|
11625
|
+
authenticate?: {
|
|
11626
|
+
username: string;
|
|
11627
|
+
password: string;
|
|
11628
|
+
};
|
|
11629
|
+
/** Set cookies before navigating. @see https://pptr.dev/api/puppeteer.cookieparam */
|
|
11630
|
+
cookies?: Array<{
|
|
11631
|
+
name: string;
|
|
11632
|
+
value: string;
|
|
11633
|
+
url?: string;
|
|
11634
|
+
domain?: string;
|
|
11635
|
+
path?: string;
|
|
11636
|
+
secure?: boolean;
|
|
11637
|
+
httpOnly?: boolean;
|
|
11638
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
11639
|
+
expires?: number;
|
|
11640
|
+
priority?: "Low" | "Medium" | "High";
|
|
11641
|
+
sameParty?: boolean;
|
|
11642
|
+
sourceScheme?: "Unset" | "NonSecure" | "Secure";
|
|
11643
|
+
sourcePort?: number;
|
|
11644
|
+
partitionKey?: string;
|
|
11645
|
+
}>;
|
|
11646
|
+
/** Emulate a specific CSS media type (e.g. `"screen"`, `"print"`). */
|
|
11647
|
+
emulateMediaType?: string;
|
|
11648
|
+
/** Navigation options. @see https://pptr.dev/api/puppeteer.gotooptions */
|
|
11649
|
+
gotoOptions?: {
|
|
11650
|
+
/** Navigation timeout in milliseconds (max 60 000). @default 30000 */
|
|
11651
|
+
timeout?: number;
|
|
11652
|
+
/** When to consider navigation complete. @default "domcontentloaded" */
|
|
11653
|
+
waitUntil?: BrowserRunLifecycleEvent | BrowserRunLifecycleEvent[];
|
|
11654
|
+
referer?: string;
|
|
11655
|
+
referrerPolicy?: string;
|
|
11656
|
+
};
|
|
11657
|
+
/** Block requests matching these regex patterns. Mutually exclusive with `allowRequestPattern`. */
|
|
11658
|
+
rejectRequestPattern?: string[];
|
|
11659
|
+
/** Only allow requests matching these regex patterns. Mutually exclusive with `rejectRequestPattern`. */
|
|
11660
|
+
allowRequestPattern?: string[];
|
|
11661
|
+
/** Block requests of these resource types. Mutually exclusive with `allowResourceTypes`. */
|
|
11662
|
+
rejectResourceTypes?: BrowserRunResourceType[];
|
|
11663
|
+
/** Only allow requests of these resource types. Mutually exclusive with `rejectResourceTypes`. */
|
|
11664
|
+
allowResourceTypes?: BrowserRunResourceType[];
|
|
11665
|
+
/** Additional HTTP headers sent with every request. */
|
|
11666
|
+
setExtraHTTPHeaders?: Record<string, string>;
|
|
11667
|
+
/** Whether JavaScript is enabled on the page. */
|
|
11668
|
+
setJavaScriptEnabled?: boolean;
|
|
11669
|
+
/** Override the default user agent string.
|
|
11670
|
+
* @default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
|
|
11671
|
+
* */
|
|
11672
|
+
userAgent?: string;
|
|
11673
|
+
/** Set the browser viewport size.
|
|
11674
|
+
* @see https://pptr.dev/api/puppeteer.viewport
|
|
11675
|
+
* @default {width:1920,height:1080}
|
|
11676
|
+
* */
|
|
11677
|
+
viewport?: {
|
|
11678
|
+
width: number;
|
|
11679
|
+
height: number;
|
|
11680
|
+
deviceScaleFactor?: number;
|
|
11681
|
+
isMobile?: boolean;
|
|
11682
|
+
isLandscape?: boolean;
|
|
11683
|
+
hasTouch?: boolean;
|
|
11684
|
+
};
|
|
11685
|
+
/** Wait for a CSS selector to appear in the page before proceeding.
|
|
11686
|
+
* @see https://pptr.dev/api/puppeteer.waitforselectoroptions
|
|
11687
|
+
*/
|
|
11688
|
+
waitForSelector?: {
|
|
11689
|
+
selector: string;
|
|
11690
|
+
hidden?: true;
|
|
11691
|
+
visible?: true;
|
|
11692
|
+
/** Timeout in milliseconds. Max 120000 */
|
|
11693
|
+
timeout?: number;
|
|
11694
|
+
};
|
|
11695
|
+
/** Wait for a fixed delay in milliseconds before proceeding. Max 120000 */
|
|
11696
|
+
waitForTimeout?: number;
|
|
11697
|
+
/** When true, continue on best-effort when awaited events fail or timeout. */
|
|
11698
|
+
bestAttempt?: boolean;
|
|
11699
|
+
/** Maximum duration in milliseconds for the browser action after page load. Max 120000 */
|
|
11700
|
+
actionTimeout?: number;
|
|
11701
|
+
/** Cache time to live in seconds (0-86400). Set to 0 to disable.
|
|
11702
|
+
* @default 5
|
|
11703
|
+
*/
|
|
11704
|
+
cacheTTL?: number;
|
|
11705
|
+
}
|
|
11706
|
+
/** Common options shared by all quick actions. Exactly one of `url` or `html` must be provided.*/
|
|
11707
|
+
export type BrowserRunCommonOptions =
|
|
11708
|
+
| (BrowserRunBaseOptions & {
|
|
11709
|
+
/** URL to navigate to, e.g. `"https://example.com"`. */
|
|
11710
|
+
url: string;
|
|
11711
|
+
})
|
|
11712
|
+
| (BrowserRunBaseOptions & {
|
|
11713
|
+
/** Set the HTML content of the page directly. */
|
|
11714
|
+
html: string;
|
|
11715
|
+
});
|
|
11716
|
+
export type BrowserRunPuppeteerScreenshotOptions = {
|
|
11717
|
+
/** @default "png" */
|
|
11718
|
+
type?: "png" | "jpeg" | "webp";
|
|
11719
|
+
/** @default "binary" */
|
|
11720
|
+
encoding?: "binary" | "base64";
|
|
11721
|
+
quality?: number;
|
|
11722
|
+
fullPage?: boolean;
|
|
11723
|
+
clip?: {
|
|
11724
|
+
x: number;
|
|
11725
|
+
y: number;
|
|
11726
|
+
width: number;
|
|
11727
|
+
height: number;
|
|
11728
|
+
scale?: number;
|
|
11729
|
+
};
|
|
11730
|
+
omitBackground?: boolean;
|
|
11731
|
+
optimizeForSpeed?: boolean;
|
|
11732
|
+
captureBeyondViewport?: boolean;
|
|
11733
|
+
fromSurface?: boolean;
|
|
11734
|
+
};
|
|
11735
|
+
export type BrowserRunScreenshotOptions = BrowserRunCommonOptions & {
|
|
11736
|
+
/** CSS selector of the element to screenshot. */
|
|
11737
|
+
selector?: string;
|
|
11738
|
+
/** When true, scroll the entire page before taking the screenshot. */
|
|
11739
|
+
scrollPage?: boolean;
|
|
11740
|
+
/** @see https://pptr.dev/api/puppeteer.screenshotoptions */
|
|
11741
|
+
screenshotOptions?: BrowserRunPuppeteerScreenshotOptions;
|
|
11742
|
+
};
|
|
11743
|
+
export type BrowserRunPDFOptions = BrowserRunCommonOptions & {
|
|
11744
|
+
/** @see https://pptr.dev/api/puppeteer.pdfoptions */
|
|
11745
|
+
pdfOptions?: {
|
|
11746
|
+
/** @default 1 */
|
|
11747
|
+
scale?: number;
|
|
11748
|
+
/** @default false */
|
|
11749
|
+
displayHeaderFooter?: boolean;
|
|
11750
|
+
headerTemplate?: string;
|
|
11751
|
+
footerTemplate?: string;
|
|
11752
|
+
/** @default false */
|
|
11753
|
+
printBackground?: boolean;
|
|
11754
|
+
/** @default false */
|
|
11755
|
+
landscape?: boolean;
|
|
11756
|
+
pageRanges?: string;
|
|
11757
|
+
/** @default "letter" */
|
|
11758
|
+
format?:
|
|
11759
|
+
| "letter"
|
|
11760
|
+
| "legal"
|
|
11761
|
+
| "tabloid"
|
|
11762
|
+
| "ledger"
|
|
11763
|
+
| "a0"
|
|
11764
|
+
| "a1"
|
|
11765
|
+
| "a2"
|
|
11766
|
+
| "a3"
|
|
11767
|
+
| "a4"
|
|
11768
|
+
| "a5"
|
|
11769
|
+
| "a6";
|
|
11770
|
+
width?: string | number;
|
|
11771
|
+
height?: string | number;
|
|
11772
|
+
/** @default false */
|
|
11773
|
+
preferCSSPageSize?: boolean;
|
|
11774
|
+
margin?: {
|
|
11775
|
+
top?: string | number;
|
|
11776
|
+
right?: string | number;
|
|
11777
|
+
bottom?: string | number;
|
|
11778
|
+
left?: string | number;
|
|
11779
|
+
};
|
|
11780
|
+
/** @default false */
|
|
11781
|
+
omitBackground?: boolean;
|
|
11782
|
+
/** @default true */
|
|
11783
|
+
tagged?: boolean;
|
|
11784
|
+
/** @default false */
|
|
11785
|
+
outline?: boolean;
|
|
11786
|
+
/** @default 30000 */
|
|
11787
|
+
timeout?: number;
|
|
11788
|
+
};
|
|
11789
|
+
};
|
|
11790
|
+
export type BrowserRunScrapeOptions = BrowserRunCommonOptions & {
|
|
11791
|
+
/** CSS selectors to scrape. At least one element is required. */
|
|
11792
|
+
elements: Array<{
|
|
11793
|
+
selector: string;
|
|
11794
|
+
}>;
|
|
11795
|
+
};
|
|
11796
|
+
export type BrowserRunLinksOptions = BrowserRunCommonOptions & {
|
|
11797
|
+
/** When true, only return links that are visible on the page. @default false */
|
|
11798
|
+
visibleLinksOnly?: boolean;
|
|
11799
|
+
/** When true, exclude links pointing to external domains. @default false */
|
|
11800
|
+
excludeExternalLinks?: boolean;
|
|
11801
|
+
};
|
|
11802
|
+
export type BrowserRunSnapshotOptions = BrowserRunCommonOptions & {
|
|
11803
|
+
/** @see https://pptr.dev/api/puppeteer.screenshotoptions */
|
|
11804
|
+
screenshotOptions?: Omit<BrowserRunPuppeteerScreenshotOptions, "encoding">;
|
|
11805
|
+
};
|
|
11806
|
+
export interface BrowserRunJsonBaseOptions {
|
|
11807
|
+
/** Custom AI models to try in order. Max 3. Falls back to next on error. */
|
|
11808
|
+
custom_ai?: Array<{
|
|
11809
|
+
/** Model ID in `<provider>/<model_name>` format, e.g. `"workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast"`. */
|
|
11810
|
+
model: string;
|
|
11811
|
+
/** Bearer token. Not needed for workers-ai models. */
|
|
11812
|
+
authorization?: string;
|
|
11813
|
+
}>;
|
|
11814
|
+
}
|
|
11815
|
+
/**
|
|
11816
|
+
* Options for the `json` quick action.
|
|
11817
|
+
* At least one of `prompt` or `response_format` must be provided.
|
|
11818
|
+
*/
|
|
11819
|
+
export type BrowserRunJsonOptions = BrowserRunCommonOptions &
|
|
11820
|
+
BrowserRunJsonBaseOptions &
|
|
11821
|
+
(
|
|
11822
|
+
| {
|
|
11823
|
+
/** Natural-language prompt describing what data to extract. */
|
|
11824
|
+
prompt: string;
|
|
11825
|
+
/** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */
|
|
11826
|
+
response_format?: AiTextGenerationResponseFormat;
|
|
11827
|
+
}
|
|
11828
|
+
| {
|
|
11829
|
+
/** Natural-language prompt describing what data to extract. */
|
|
11830
|
+
prompt?: string;
|
|
11831
|
+
/** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */
|
|
11832
|
+
response_format: AiTextGenerationResponseFormat;
|
|
11833
|
+
}
|
|
11834
|
+
);
|
|
11835
|
+
export type BrowserRunContentOptions = BrowserRunCommonOptions;
|
|
11836
|
+
export type BrowserRunMarkdownOptions = BrowserRunCommonOptions;
|
|
11837
|
+
export type BrowserRunResponseMeta = {
|
|
11838
|
+
/** HTTP status code of the rendered page */
|
|
11839
|
+
status: number;
|
|
11840
|
+
/** Page title */
|
|
11841
|
+
title: string;
|
|
11842
|
+
};
|
|
11843
|
+
/** Success response for `content` action. */
|
|
11844
|
+
export type BrowserRunContentSuccessResponse = {
|
|
11845
|
+
success: true;
|
|
11846
|
+
/** Extracted HTML content */
|
|
11847
|
+
result: string;
|
|
11848
|
+
meta: BrowserRunResponseMeta;
|
|
11849
|
+
};
|
|
11850
|
+
/** Success response for `links` action. */
|
|
11851
|
+
export type BrowserRunLinksSuccessResponse = {
|
|
11852
|
+
success: true;
|
|
11853
|
+
/** Extracted links */
|
|
11854
|
+
result: string[];
|
|
11855
|
+
};
|
|
11856
|
+
/** Success response for `scrape` action. */
|
|
11857
|
+
export type BrowserRunScrapeSuccessResponse = {
|
|
11858
|
+
success: true;
|
|
11859
|
+
result: Array<{
|
|
11860
|
+
/** The CSS selector used to find elements. */
|
|
11861
|
+
selector: string;
|
|
11862
|
+
/** Array of elements matching the selector. */
|
|
11863
|
+
results: Array<{
|
|
11864
|
+
/** Outer HTML of the element. */
|
|
11865
|
+
html: string;
|
|
11866
|
+
/** Text content of the element. */
|
|
11867
|
+
text: string;
|
|
11868
|
+
/** Width of the element in pixels. */
|
|
11869
|
+
width: number;
|
|
11870
|
+
/** Height of the element in pixels. */
|
|
11871
|
+
height: number;
|
|
11872
|
+
/** Top position of the element relative to the viewport in pixels. */
|
|
11873
|
+
top: number;
|
|
11874
|
+
/** Left position of the element relative to the viewport in pixels. */
|
|
11875
|
+
left: number;
|
|
11876
|
+
/** Array of HTML attributes on the element. */
|
|
11877
|
+
attributes: Array<{
|
|
11878
|
+
/** Attribute name. */
|
|
11879
|
+
name: string;
|
|
11880
|
+
/** Attribute value. */
|
|
11881
|
+
value: string;
|
|
11882
|
+
}>;
|
|
11883
|
+
}>;
|
|
11884
|
+
}>;
|
|
11885
|
+
};
|
|
11886
|
+
/** Success response for `snapshot` action. */
|
|
11887
|
+
export type BrowserRunSnapshotSuccessResponse = {
|
|
11888
|
+
success: true;
|
|
11889
|
+
result: {
|
|
11890
|
+
/** HTML content of the page. */
|
|
11891
|
+
content: string;
|
|
11892
|
+
/** Base64-encoded screenshot image. */
|
|
11893
|
+
screenshot: string;
|
|
11894
|
+
};
|
|
11895
|
+
meta: BrowserRunResponseMeta;
|
|
11896
|
+
};
|
|
11897
|
+
/** Success response for `json` action. */
|
|
11898
|
+
export type BrowserRunJsonSuccessResponse = {
|
|
11899
|
+
success: true;
|
|
11900
|
+
/** JSON data extracted from the page using an AI model */
|
|
11901
|
+
result: Record<string, unknown>;
|
|
11902
|
+
};
|
|
11903
|
+
/** Success response for `markdown` action. */
|
|
11904
|
+
export type BrowserRunMarkdownSuccessResponse = {
|
|
11905
|
+
success: true;
|
|
11906
|
+
/** Extracted markdown content */
|
|
11907
|
+
result: string;
|
|
11908
|
+
};
|
|
11909
|
+
/** Error response for BrowserRun actions. */
|
|
11910
|
+
export type BrowserRunErrorResponse = {
|
|
11911
|
+
success: false;
|
|
11912
|
+
errors: {
|
|
11913
|
+
message: string;
|
|
11914
|
+
code?: number;
|
|
11915
|
+
detail?: string;
|
|
11916
|
+
path?: string;
|
|
11917
|
+
}[];
|
|
11918
|
+
};
|
|
11919
|
+
/** Error response for BrowserRun `json` action. */
|
|
11920
|
+
export type BrowserRunJsonErrorResponse = BrowserRunErrorResponse & {
|
|
11921
|
+
/** Raw AI response text for debugging */
|
|
11922
|
+
rawAiResponse?: string;
|
|
11923
|
+
};
|
|
11924
|
+
/**
|
|
11925
|
+
* Browser Run API binding for automating headless browsers.
|
|
11926
|
+
* @see https://developers.cloudflare.com/browser-run/
|
|
11927
|
+
*/
|
|
11928
|
+
export declare abstract class BrowserRun {
|
|
11929
|
+
/**
|
|
11930
|
+
* Send a raw HTTP request to the Browser Run API.
|
|
11931
|
+
* Used by libraries like `@cloudflare/puppeteer` to acquire and connect to a browser instance.
|
|
11932
|
+
* @see https://developers.cloudflare.com/browser-run/
|
|
11933
|
+
*/
|
|
11934
|
+
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
|
11935
|
+
/**
|
|
11936
|
+
* Take a screenshot of a web page.
|
|
11937
|
+
* @param action - Must be `'screenshot'`.
|
|
11938
|
+
* @param options - Screenshot options including viewport, selectors, and image format.
|
|
11939
|
+
* @returns A `Response` containing one of:
|
|
11940
|
+
*
|
|
11941
|
+
* **Success (HTTP 200):**
|
|
11942
|
+
* - Binary image data with `Content-Type: image/png`, `image/jpeg`, or `image/webp` (when `encoding: 'binary'`, the default)
|
|
11943
|
+
* - Data URI string with `Content-Type: text/plain` (when `encoding: 'base64'`)
|
|
11944
|
+
*
|
|
11945
|
+
* **Error:**
|
|
11946
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
11947
|
+
*
|
|
11948
|
+
* **Headers:**
|
|
11949
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
11950
|
+
*/
|
|
11951
|
+
quickAction(
|
|
11952
|
+
action: "screenshot",
|
|
11953
|
+
options: BrowserRunScreenshotOptions,
|
|
11954
|
+
): Promise<Response>;
|
|
11955
|
+
/**
|
|
11956
|
+
* Generate a PDF of a web page.
|
|
11957
|
+
* @param action - Must be `'pdf'`.
|
|
11958
|
+
* @param options - PDF generation options including page size, margins, and headers/footers.
|
|
11959
|
+
* @returns A `Response` containing one of:
|
|
11960
|
+
*
|
|
11961
|
+
* **Success (HTTP 200):**
|
|
11962
|
+
* - Binary PDF data with `Content-Type: application/pdf`
|
|
11963
|
+
*
|
|
11964
|
+
* **Error:**
|
|
11965
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
11966
|
+
*
|
|
11967
|
+
* **Headers:**
|
|
11968
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
11969
|
+
*/
|
|
11970
|
+
quickAction(action: "pdf", options: BrowserRunPDFOptions): Promise<Response>;
|
|
11971
|
+
/**
|
|
11972
|
+
* Get the HTML content of a web page.
|
|
11973
|
+
* @param action - Must be `'content'`.
|
|
11974
|
+
* @param options - Navigation and page interaction options.
|
|
11975
|
+
* @returns A `Response` containing one of:
|
|
11976
|
+
*
|
|
11977
|
+
* **Success (HTTP 200):**
|
|
11978
|
+
* - `BrowserRunContentSuccessResponse` JSON with `Content-Type: application/json`
|
|
11979
|
+
*
|
|
11980
|
+
* **Error:**
|
|
11981
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
11982
|
+
*
|
|
11983
|
+
* **Headers:**
|
|
11984
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
11985
|
+
*/
|
|
11986
|
+
quickAction(
|
|
11987
|
+
action: "content",
|
|
11988
|
+
options: BrowserRunContentOptions,
|
|
11989
|
+
): Promise<Response>;
|
|
11990
|
+
/**
|
|
11991
|
+
* Scrape elements from a web page by CSS selector.
|
|
11992
|
+
* @param action - Must be `'scrape'`.
|
|
11993
|
+
* @param options - Scrape options with CSS selectors for elements to extract.
|
|
11994
|
+
* @returns A `Response` containing one of:
|
|
11995
|
+
*
|
|
11996
|
+
* **Success (HTTP 200):**
|
|
11997
|
+
* - `BrowserRunScrapeSuccessResponse` JSON with `Content-Type: application/json`
|
|
11998
|
+
*
|
|
11999
|
+
* **Error:**
|
|
12000
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
12001
|
+
*
|
|
12002
|
+
* **Headers:**
|
|
12003
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
12004
|
+
*/
|
|
12005
|
+
quickAction(
|
|
12006
|
+
action: "scrape",
|
|
12007
|
+
options: BrowserRunScrapeOptions,
|
|
12008
|
+
): Promise<Response>;
|
|
12009
|
+
/**
|
|
12010
|
+
* Extract all links from a web page.
|
|
12011
|
+
* @param action - Must be `'links'`.
|
|
12012
|
+
* @param options - Options to filter visible or internal links only.
|
|
12013
|
+
* @returns A `Response` containing one of:
|
|
12014
|
+
*
|
|
12015
|
+
* **Success (HTTP 200):**
|
|
12016
|
+
* - `BrowserRunLinksSuccessResponse` JSON with `Content-Type: application/json`
|
|
12017
|
+
*
|
|
12018
|
+
* **Error:**
|
|
12019
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
12020
|
+
*
|
|
12021
|
+
* **Headers:**
|
|
12022
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
12023
|
+
*/
|
|
12024
|
+
quickAction(
|
|
12025
|
+
action: "links",
|
|
12026
|
+
options: BrowserRunLinksOptions,
|
|
12027
|
+
): Promise<Response>;
|
|
12028
|
+
/**
|
|
12029
|
+
* Get both the HTML content and a base64-encoded screenshot of a web page.
|
|
12030
|
+
* @param action - Must be `'snapshot'`.
|
|
12031
|
+
* @param options - Snapshot options including screenshot settings (encoding is always base64).
|
|
12032
|
+
* @returns A `Response` containing one of:
|
|
12033
|
+
*
|
|
12034
|
+
* **Success (HTTP 200):**
|
|
12035
|
+
* - `BrowserRunSnapshotSuccessResponse` JSON with `Content-Type: application/json`
|
|
12036
|
+
*
|
|
12037
|
+
* **Error:**
|
|
12038
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
12039
|
+
*
|
|
12040
|
+
* **Headers:**
|
|
12041
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
12042
|
+
*/
|
|
12043
|
+
quickAction(
|
|
12044
|
+
action: "snapshot",
|
|
12045
|
+
options: BrowserRunSnapshotOptions,
|
|
12046
|
+
): Promise<Response>;
|
|
12047
|
+
/**
|
|
12048
|
+
* Extract structured JSON data from a web page using AI.
|
|
12049
|
+
* @param action - Must be `'json'`.
|
|
12050
|
+
* @param options - JSON extraction options with prompt or response_format schema.
|
|
12051
|
+
* @returns A `Response` containing one of:
|
|
12052
|
+
*
|
|
12053
|
+
* **Success (HTTP 200):**
|
|
12054
|
+
* - `BrowserRunJsonSuccessResponse` JSON with `Content-Type: application/json`
|
|
12055
|
+
*
|
|
12056
|
+
* **Error:**
|
|
12057
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
12058
|
+
* - HTTP 422 with code `2012` for HTML-to-markdown conversion failures
|
|
12059
|
+
* - HTTP 422/500 for AI extraction failures (may include `rawAiResponse` field)
|
|
12060
|
+
*
|
|
12061
|
+
* **Headers:**
|
|
12062
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
12063
|
+
*/
|
|
12064
|
+
quickAction(
|
|
12065
|
+
action: "json",
|
|
12066
|
+
options: BrowserRunJsonOptions,
|
|
12067
|
+
): Promise<Response>;
|
|
12068
|
+
/**
|
|
12069
|
+
* Convert a web page to Markdown.
|
|
12070
|
+
* @param action - Must be `'markdown'`.
|
|
12071
|
+
* @param options - Navigation and page interaction options.
|
|
12072
|
+
* @returns A `Response` containing one of:
|
|
12073
|
+
*
|
|
12074
|
+
* **Success (HTTP 200):**
|
|
12075
|
+
* - `BrowserRunMarkdownSuccessResponse` JSON with `Content-Type: application/json`
|
|
12076
|
+
*
|
|
12077
|
+
* **Error:**
|
|
12078
|
+
* - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)
|
|
12079
|
+
* - HTTP 422 with code `2012` for HTML-to-markdown conversion failures
|
|
12080
|
+
*
|
|
12081
|
+
* **Headers:**
|
|
12082
|
+
* - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)
|
|
12083
|
+
*/
|
|
12084
|
+
quickAction(
|
|
12085
|
+
action: "markdown",
|
|
12086
|
+
options: BrowserRunMarkdownOptions,
|
|
12087
|
+
): Promise<Response>;
|
|
12088
|
+
}
|
|
11349
12089
|
export interface BasicImageTransformations {
|
|
11350
12090
|
/**
|
|
11351
12091
|
* Maximum width in image pixels. The value must be an integer.
|