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