1/* eslint-disable */2// Generated by Wrangler by running `wrangler types` (hash: 4244ca629f6011b823f8b11dd959b509)3// Runtime types generated with workerd@1.20260820.1 2026-08-20 4interface __BaseEnv_Env {5 ASSETS: Fetcher;6}7declare namespace Cloudflare {8 interface GlobalProps {9 mainModule: typeof import("./src/index");10 }11 interface Env extends __BaseEnv_Env {}12}13interface Env extends __BaseEnv_Env {}1415// Begin runtime types16/*! *****************************************************************************17Copyright (c) Cloudflare. All rights reserved.18Copyright (c) Microsoft Corporation. All rights reserved.1920Licensed under the Apache License, Version 2.0 (the "License"); you may not use21this file except in compliance with the License. You may obtain a copy of the22License at http://www.apache.org/licenses/LICENSE-2.023THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY24KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED25WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,26MERCHANTABLITY OR NON-INFRINGEMENT.27See the Apache Version 2.0 License for specific language governing permissions28and limitations under the License.29***************************************************************************** */30/* eslint-disable */31// noinspection JSUnusedGlobalSymbols32declare var onmessage: never;33/**34 * The **`DOMException`** interface represents an abnormal event (called an exception) that occurs as a result of calling a method or accessing a property of a web API. This is how error conditions are described in web APIs.35 *36 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)37 */38declare class DOMException extends Error {39 constructor(message?: string, name?: string);40 /**41 * The **`message`** read-only property of the DOMException interface returns a string representing a message or description associated with the given error name.42 *43 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)44 */45 readonly message: string;46 /**47 * The **`name`** read-only property of the DOMException interface returns a string that contains one of the strings associated with an error name.48 *49 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)50 */51 readonly name: string;52 /**53 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or 0 if none match.54 * @deprecated55 *56 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)57 */58 readonly code: number;59 static readonly INDEX_SIZE_ERR: number;60 static readonly DOMSTRING_SIZE_ERR: number;61 static readonly HIERARCHY_REQUEST_ERR: number;62 static readonly WRONG_DOCUMENT_ERR: number;63 static readonly INVALID_CHARACTER_ERR: number;64 static readonly NO_DATA_ALLOWED_ERR: number;65 static readonly NO_MODIFICATION_ALLOWED_ERR: number;66 static readonly NOT_FOUND_ERR: number;67 static readonly NOT_SUPPORTED_ERR: number;68 static readonly INUSE_ATTRIBUTE_ERR: number;69 static readonly INVALID_STATE_ERR: number;70 static readonly SYNTAX_ERR: number;71 static readonly INVALID_MODIFICATION_ERR: number;72 static readonly NAMESPACE_ERR: number;73 static readonly INVALID_ACCESS_ERR: number;74 static readonly VALIDATION_ERR: number;75 static readonly TYPE_MISMATCH_ERR: number;76 static readonly SECURITY_ERR: number;77 static readonly NETWORK_ERR: number;78 static readonly ABORT_ERR: number;79 static readonly URL_MISMATCH_ERR: number;80 static readonly QUOTA_EXCEEDED_ERR: number;81 static readonly TIMEOUT_ERR: number;82 static readonly INVALID_NODE_TYPE_ERR: number;83 static readonly DATA_CLONE_ERR: number;84 get stack(): any;85 set stack(value: any);86}87type WorkerGlobalScopeEventMap = {88 fetch: FetchEvent;89 scheduled: ScheduledEvent;90 queue: QueueEvent;91 unhandledrejection: PromiseRejectionEvent;92 rejectionhandled: PromiseRejectionEvent;93};94declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {95 EventTarget: typeof EventTarget;96}97/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *98 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).99 *100 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)101 */102interface Console {103 "assert"(condition?: boolean, ...data: any[]): void;104 /**105 * The **`console.clear()`** static method clears the console if possible.106 *107 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)108 */109 clear(): void;110 /**111 * The **`console.count()`** static method logs the number of times that this particular call to count() has been called.112 *113 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)114 */115 count(label?: string): void;116 /**117 * The **`console.countReset()`** static method resets counter used with console.count().118 *119 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)120 */121 countReset(label?: string): void;122 /**123 * The **`console.debug()`** static method outputs a message to the console at the "debug" log level. The message is only displayed to the user if the console is configured to display debug output. In most cases, the log level is configured within the console UI. This log level might correspond to the Debug or Verbose log level.124 *125 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)126 */127 debug(...data: any[]): void;128 /**129 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object. In browser consoles, the output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects.130 *131 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)132 */133 dir(item?: any, options?: any): void;134 /**135 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element. If it is not possible to display as an element the JavaScript Object view is shown instead. The output is presented as a hierarchical listing of expandable nodes that let you see the contents of child nodes.136 *137 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)138 */139 dirxml(...data: any[]): void;140 /**141 * The **`console.error()`** static method outputs a message to the console at the "error" log level. The message is only displayed to the user if the console is configured to display error output. In most cases, the log level is configured within the console UI. The message may be formatted as an error, with red colors and call stack information.142 *143 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)144 */145 error(...data: any[]): void;146 /**147 * The **`console.group()`** static method creates a new inline group in the Web console log, causing any subsequent console messages to be indented by an additional level, until console.groupEnd() is called.148 *149 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)150 */151 group(...data: any[]): void;152 /**153 * The **`console.groupCollapsed()`** static method creates a new inline group in the console. Unlike console.group(), however, the new group is created collapsed. The user will need to use the disclosure button next to it to expand it, revealing the entries created in the group.154 *155 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)156 */157 groupCollapsed(...data: any[]): void;158 /**159 * The **`console.groupEnd()`** static method exits the current inline group in the console. See Using groups in the console in the console documentation for details and examples.160 *161 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)162 */163 groupEnd(): void;164 /**165 * The **`console.info()`** static method outputs a message to the console at the "info" log level. The message is only displayed to the user if the console is configured to display info output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as a small "i" icon next to it.166 *167 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)168 */169 info(...data: any[]): void;170 /**171 * The **`console.log()`** static method outputs a message to the console.172 *173 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)174 */175 log(...data: any[]): void;176 /**177 * The **`console.table()`** static method displays tabular data as a table.178 *179 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)180 */181 table(tabularData?: any, properties?: string[]): void;182 /**183 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes. You give each timer a unique name, and may have up to 10,000 timers running on a given page. When you call console.timeEnd() with the same name, the browser will output the time, in milliseconds, that elapsed since the timer was started.184 *185 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)186 */187 time(label?: string): void;188 /**189 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console.time().190 *191 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)192 */193 timeEnd(label?: string): void;194 /**195 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console.time().196 *197 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)198 */199 timeLog(label?: string, ...data: any[]): void;200 /* The **`console.timeStamp()`** static method adds a single marker to the browser's Performance tool (Firefox bug 1387528, Chrome). This lets you correlate a point in your code with the other events recorded in the timeline, such as layout and paint events. */201 timeStamp(label?: string): void;202 /**203 * The **`console.trace()`** static method outputs a stack trace to the console.204 *205 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)206 */207 trace(...data: any[]): void;208 /**209 * The **`console.warn()`** static method outputs a warning message to the console at the "warning" log level. The message is only displayed to the user if the console is configured to display warning output. In most cases, the log level is configured within the console UI. The message may receive special formatting, such as yellow colors and a warning icon.210 *211 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)212 */213 warn(...data: any[]): void;214}215declare const console: Console;216type BufferSource = ArrayBufferView | ArrayBuffer;217type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;218declare namespace WebAssembly {219 class CompileError extends Error {220 constructor(message?: string);221 }222 class RuntimeError extends Error {223 constructor(message?: string);224 }225 type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128";226 interface GlobalDescriptor {227 value: ValueType;228 mutable?: boolean;229 }230 class Global {231 constructor(descriptor: GlobalDescriptor, value?: any);232 value: any;233 valueOf(): any;234 }235 type ImportValue = ExportValue | number;236 type ModuleImports = Record<string, ImportValue>;237 type Imports = Record<string, ModuleImports>;238 type ExportValue = Function | Global | Memory | Table;239 type Exports = Record<string, ExportValue>;240 class Instance {241 constructor(module: Module, imports?: Imports);242 readonly exports: Exports;243 }244 interface MemoryDescriptor {245 initial: number;246 maximum?: number;247 shared?: boolean;248 }249 class Memory {250 constructor(descriptor: MemoryDescriptor);251 readonly buffer: ArrayBuffer;252 grow(delta: number): number;253 }254 type ImportExportKind = "function" | "global" | "memory" | "table";255 interface ModuleExportDescriptor {256 kind: ImportExportKind;257 name: string;258 }259 interface ModuleImportDescriptor {260 kind: ImportExportKind;261 module: string;262 name: string;263 }264 abstract class Module {265 static customSections(module: Module, sectionName: string): ArrayBuffer[];266 static exports(module: Module): ModuleExportDescriptor[];267 static imports(module: Module): ModuleImportDescriptor[];268 }269 type TableKind = "anyfunc" | "externref";270 interface TableDescriptor {271 element: TableKind;272 initial: number;273 maximum?: number;274 }275 class Table {276 constructor(descriptor: TableDescriptor, value?: any);277 readonly length: number;278 get(index: number): any;279 grow(delta: number, value?: any): number;280 set(index: number, value?: any): void;281 }282 function instantiate(module: Module, imports?: Imports): Promise<Instance>;283 function validate(bytes: BufferSource): boolean;284}285/**286 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.287 * Available only in secure contexts.288 *289 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)290 */291interface ServiceWorkerGlobalScope extends WorkerGlobalScope {292 DOMException: typeof DOMException;293 WorkerGlobalScope: typeof WorkerGlobalScope;294 btoa(data: string): string;295 atob(data: string): string;296 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;297 setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;298 clearTimeout(timeoutId: number | null): void;299 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;300 setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;301 clearInterval(timeoutId: number | null): void;302 queueMicrotask(task: Function): void;303 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;304 reportError(error: any): void;305 fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;306 self: ServiceWorkerGlobalScope;307 crypto: Crypto;308 caches: CacheStorage;309 scheduler: Scheduler;310 performance: Performance;311 Cloudflare: Cloudflare;312 readonly origin: string;313 Event: typeof Event;314 ExtendableEvent: typeof ExtendableEvent;315 CustomEvent: typeof CustomEvent;316 PromiseRejectionEvent: typeof PromiseRejectionEvent;317 FetchEvent: typeof FetchEvent;318 TailEvent: typeof TailEvent;319 TraceEvent: typeof TailEvent;320 ScheduledEvent: typeof ScheduledEvent;321 MessageEvent: typeof MessageEvent;322 CloseEvent: typeof CloseEvent;323 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;324 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;325 ReadableStream: typeof ReadableStream;326 WritableStream: typeof WritableStream;327 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;328 TransformStream: typeof TransformStream;329 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;330 CountQueuingStrategy: typeof CountQueuingStrategy;331 ErrorEvent: typeof ErrorEvent;332 MessageChannel: typeof MessageChannel;333 MessagePort: typeof MessagePort;334 EventSource: typeof EventSource;335 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;336 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;337 ReadableByteStreamController: typeof ReadableByteStreamController;338 WritableStreamDefaultController: typeof WritableStreamDefaultController;339 TransformStreamDefaultController: typeof TransformStreamDefaultController;340 CompressionStream: typeof CompressionStream;341 DecompressionStream: typeof DecompressionStream;342 TextEncoderStream: typeof TextEncoderStream;343 TextDecoderStream: typeof TextDecoderStream;344 Headers: typeof Headers;345 Body: typeof Body;346 Request: typeof Request;347 Response: typeof Response;348 WebSocket: typeof WebSocket;349 WebSocketPair: typeof WebSocketPair;350 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;351 AbortController: typeof AbortController;352 AbortSignal: typeof AbortSignal;353 TextDecoder: typeof TextDecoder;354 TextEncoder: typeof TextEncoder;355 navigator: Navigator;356 Navigator: typeof Navigator;357 URL: typeof URL;358 URLSearchParams: typeof URLSearchParams;359 URLPattern: typeof URLPattern;360 Blob: typeof Blob;361 File: typeof File;362 FormData: typeof FormData;363 Crypto: typeof Crypto;364 SubtleCrypto: typeof SubtleCrypto;365 CryptoKey: typeof CryptoKey;366 CacheStorage: typeof CacheStorage;367 Cache: typeof Cache;368 FixedLengthStream: typeof FixedLengthStream;369 IdentityTransformStream: typeof IdentityTransformStream;370 HTMLRewriter: typeof HTMLRewriter;371}372declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;373declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;374/**375 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().376 *377 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)378 */379declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean;380/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */381declare function btoa(data: string): string;382/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */383declare function atob(data: string): string;384/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */385declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;386/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */387declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;388/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */389declare function clearTimeout(timeoutId: number | null): void;390/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */391declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number;392/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */393declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number;394/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */395declare function clearInterval(timeoutId: number | null): void;396/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */397declare function queueMicrotask(task: Function): void;398/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */399declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;400/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */401declare function reportError(error: any): void;402/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */403declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>;404declare const self: ServiceWorkerGlobalScope;405/**406* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.407* The Workers runtime implements the full surface of this API, but with some differences in408* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)409* compared to those implemented in most browsers.410*411* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)412*/413declare const crypto: Crypto;414/**415* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.416*417* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)418*/419declare const caches: CacheStorage;420/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/scheduler) */421declare const scheduler: Scheduler;422/**423* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,424* as well as timing of subrequests and other operations.425*426* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)427*/428declare const performance: Performance;429declare const Cloudflare: Cloudflare;430declare const origin: string;431declare const navigator: Navigator;432interface TestController {433}434interface ExecutionContext<Props = unknown> {435 waitUntil(promise: Promise<any>): void;436 passThroughOnException(): void;437 readonly exports: Cloudflare.Exports;438 readonly props: Props;439 cache?: CacheContext;440 readonly access?: CloudflareAccessContext;441 tracing: Tracing;442 abort(reason?: any): void;443}444type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>;445type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;446type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;447type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;448type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext<Props>) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;449type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;450type ExportedHandlerQueueHandler<Env = unknown, Message = unknown, Props = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;451type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;452interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown, Props = unknown> {453 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;454 connect?: ExportedHandlerConnectHandler<Env, Props>;455 tail?: ExportedHandlerTailHandler<Env, Props>;456 trace?: ExportedHandlerTraceHandler<Env, Props>;457 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;458 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;459 test?: ExportedHandlerTestHandler<Env, Props>;460 email?: EmailExportedHandler<Env, Props>;461 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;462}463interface StructuredSerializeOptions {464 transfer?: any[];465}466declare abstract class Navigator {467 sendBeacon(url: string, body?: BodyInit): boolean;468 readonly userAgent: string;469 readonly hardwareConcurrency: number;470 readonly platform: string;471 readonly language: string;472 readonly languages: string[];473}474interface AlarmInvocationInfo {475 readonly isRetry: boolean;476 readonly retryCount: number;477 readonly scheduledTime: number;478}479interface Cloudflare {480 readonly compatibilityFlags: Record<string, boolean>;481}482interface CachePurgeError {483 code: number;484 message: string;485}486interface CachePurgeResult {487 success: boolean;488 errors: CachePurgeError[];489}490interface CachePurgeOptions {491 tags?: string[];492 pathPrefixes?: string[];493 purgeEverything?: boolean;494}495interface CacheContext {496 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;497}498interface CloudflareAccessContext {499 readonly aud: string;500 getIdentity(): Promise<CloudflareAccessIdentity | undefined>;501}502declare abstract class ColoLocalActorNamespace {503 get(actorId: string): Fetcher;504}505interface DurableObject {506 fetch(request: Request): Response | Promise<Response>;507 connect?(socket: Socket): void | Promise<void>;508 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;509 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;510 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;511 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;512}513type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & {514 readonly id: DurableObjectId;515 readonly name?: string;516};517interface DurableObjectId {518 toString(): string;519 equals(other: DurableObjectId): boolean;520 readonly name?: string;521 readonly jurisdiction?: string;522}523declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> {524 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId;525 idFromName(name: string): DurableObjectId;526 idFromString(id: string): DurableObjectId;527 get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;528 getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>;529 jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>;530}531type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high" | "us";532interface DurableObjectNamespaceNewUniqueIdOptions {533 jurisdiction?: DurableObjectJurisdiction;534}535type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "apac-ne" | "apac-se" | "oc" | "afr" | "me";536type DurableObjectRoutingMode = "primary-only";537interface DurableObjectNamespaceGetDurableObjectOptions {538 locationHint?: DurableObjectLocationHint;539 routingMode?: DurableObjectRoutingMode;540}541interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> {542}543interface DurableObjectState<Props = unknown> {544 waitUntil(promise: Promise<any>): void;545 readonly exports: Cloudflare.Exports;546 readonly props: Props;547 readonly id: DurableObjectId;548 readonly storage: DurableObjectStorage;549 container?: Container;550 facets: DurableObjectFacets;551 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;552 acceptWebSocket(ws: WebSocket, tags?: string[]): void;553 getWebSockets(tag?: string): WebSocket[];554 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;555 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;556 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;557 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;558 getHibernatableWebSocketEventTimeout(): number | null;559 getTags(ws: WebSocket): string[];560 abort(reason?: string): void;561}562interface DurableObjectTransaction {563 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;564 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;565 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;566 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;567 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;568 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;569 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;570 rollback(): void;571 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;572 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;573 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;574}575interface DurableObjectStorage {576 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>;577 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>;578 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>;579 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>;580 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>;581 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;582 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;583 deleteAll(options?: DurableObjectPutOptions): Promise<void>;584 transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>;585 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;586 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>;587 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;588 sync(): Promise<void>;589 sql: SqlStorage;590 kv: SyncKvStorage;591 transactionSync<T>(closure: () => T): T;592 getCurrentBookmark(): Promise<string>;593 getBookmarkForTime(timestamp: number | Date): Promise<string>;594 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;595}596interface DurableObjectListOptions {597 start?: string;598 startAfter?: string;599 end?: string;600 prefix?: string;601 reverse?: boolean;602 limit?: number;603 allowConcurrency?: boolean;604 noCache?: boolean;605}606interface DurableObjectGetOptions {607 allowConcurrency?: boolean;608 noCache?: boolean;609}610interface DurableObjectGetAlarmOptions {611 allowConcurrency?: boolean;612}613interface DurableObjectPutOptions {614 allowConcurrency?: boolean;615 allowUnconfirmed?: boolean;616 noCache?: boolean;617}618interface DurableObjectSetAlarmOptions {619 allowConcurrency?: boolean;620 allowUnconfirmed?: boolean;621}622declare class WebSocketRequestResponsePair {623 constructor(request: string, response: string);624 get request(): string;625 get response(): string;626}627interface DurableObjectFacets {628 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(name: string, getStartupOptions: () => FacetStartupOptions<T> | Promise<FacetStartupOptions<T>>): Fetcher<T>;629 abort(name: string, reason: any): void;630 delete(name: string): void;631 clone(src: string, dst: string): void;632}633interface FacetStartupOptions<T extends Rpc.DurableObjectBranded | undefined = undefined> {634 id?: DurableObjectId | string;635 class: DurableObjectClass<T>;636}637interface AnalyticsEngineDataset {638 writeDataPoint(event?: AnalyticsEngineDataPoint): void;639}640interface AnalyticsEngineDataPoint {641 indexes?: ((ArrayBuffer | string) | null)[];642 doubles?: number[];643 blobs?: ((ArrayBuffer | string) | null)[];644}645/**646 * The **`Event`** interface represents an event which takes place on an EventTarget.647 *648 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)649 */650declare class Event {651 constructor(type: string, init?: EventInit);652 /**653 * The **`type`** read-only property of the Event interface returns a string containing the event's type. It is set when the event is constructed and is the name commonly used to refer to the specific event, such as click, load, or error.654 *655 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)656 */657 get type(): string;658 /**659 * The **`eventPhase`** read-only property of the Event interface indicates which phase of the event flow is currently being evaluated.660 *661 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)662 */663 get eventPhase(): number;664 /**665 * The read-only **`composed`** property of the Event interface returns a boolean value which indicates whether or not the event will propagate across the shadow DOM boundary into the standard DOM.666 *667 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)668 */669 get composed(): boolean;670 /**671 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.672 *673 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)674 */675 get bubbles(): boolean;676 /**677 * The **`cancelable`** read-only property of the Event interface indicates whether the event can be canceled, and therefore prevented as if the event never happened.678 *679 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)680 */681 get cancelable(): boolean;682 /**683 * The **`defaultPrevented`** read-only property of the Event interface returns a boolean value indicating whether or not the call to Event.preventDefault() canceled the event.684 *685 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)686 */687 get defaultPrevented(): boolean;688 /**689 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.690 * @deprecated691 *692 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)693 */694 get returnValue(): boolean;695 /**696 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.697 *698 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)699 */700 get currentTarget(): EventTarget | undefined;701 /**702 * The read-only **`target`** property of the Event interface is a reference to the object onto which the event was dispatched. It is different from Event.currentTarget when the event handler is called during the bubbling or capturing phase of the event.703 *704 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)705 */706 get target(): EventTarget | undefined;707 /**708 * The deprecated **`Event.srcElement`** is an alias for the Event.target property. Use Event.target instead.709 * @deprecated710 *711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)712 */713 get srcElement(): EventTarget | undefined;714 /**715 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.716 *717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)718 */719 get timeStamp(): number;720 /**721 * The **`isTrusted`** read-only property of the Event interface is a boolean value that is true when the event was generated by the user agent (including via user actions and programmatic methods such as HTMLElement.focus()), and false when the event was dispatched via EventTarget.dispatchEvent(). The only exception is the click event, which initializes the isTrusted property to false in user agents.722 *723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)724 */725 get isTrusted(): boolean;726 /**727 * The **`cancelBubble`** property of the Event interface is deprecated. Use Event.stopPropagation() instead. Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details.728 * @deprecated729 *730 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)731 */732 get cancelBubble(): boolean;733 /**734 * The **`cancelBubble`** property of the Event interface is deprecated. Use Event.stopPropagation() instead. Setting its value to true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See Browser compatibility for details.735 * @deprecated736 *737 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)738 */739 set cancelBubble(value: boolean);740 /**741 * The **`stopImmediatePropagation()`** method of the Event interface prevents other listeners of the same event from being called.742 *743 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)744 */745 stopImmediatePropagation(): void;746 /**747 * The **`preventDefault()`** method of the Event interface tells the user agent that the event is being explicitly handled, so its default action, such as page scrolling, link navigation, or pasting text, should not be taken.748 *749 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)750 */751 preventDefault(): void;752 /**753 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. It does not, however, prevent any default behaviors from occurring; for instance, clicks on links are still processed. If you want to stop those behaviors, see the preventDefault() method. It also does not prevent propagation to other event-handlers of the current element. If you want to stop those, see stopImmediatePropagation().754 *755 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)756 */757 stopPropagation(): void;758 /**759 * The **`composedPath()`** method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked. This does not include nodes in shadow trees if the shadow root was created with its ShadowRoot.mode closed.760 *761 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)762 */763 composedPath(): EventTarget[];764 static readonly NONE: number;765 static readonly CAPTURING_PHASE: number;766 static readonly AT_TARGET: number;767 static readonly BUBBLING_PHASE: number;768}769interface EventInit {770 bubbles?: boolean;771 cancelable?: boolean;772 composed?: boolean;773}774type EventListener<EventType extends Event = Event> = (event: EventType) => void;775interface EventListenerObject<EventType extends Event = Event> {776 handleEvent(event: EventType): void;777}778type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>;779/**780 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them. In other words, any target of events implements the three methods associated with this interface.781 *782 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)783 */784declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> {785 constructor();786 /**787 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.788 *789 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)790 */791 addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void;792 /**793 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.794 *795 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)796 */797 removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void;798 /**799 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().800 *801 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)802 */803 dispatchEvent(event: EventMap[keyof EventMap]): boolean;804}805interface EventTargetEventListenerOptions {806 capture?: boolean;807}808interface EventTargetAddEventListenerOptions {809 capture?: boolean;810 passive?: boolean;811 once?: boolean;812 signal?: AbortSignal;813}814interface EventTargetHandlerObject {815 handleEvent: (event: Event) => any | undefined;816}817/**818 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.819 *820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)821 */822declare class AbortController {823 constructor();824 /**825 * The **`signal`** read-only property of the AbortController interface returns an AbortSignal object instance, which can be used to communicate with/abort an asynchronous operation as desired.826 *827 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)828 */829 get signal(): AbortSignal;830 /**831 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed. This is able to abort fetch requests, the consumption of any response bodies, or streams.832 *833 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)834 */835 abort(reason?: any): void;836}837/**838 * The **`AbortSignal`** interface represents a signal object that allows you to communicate with an asynchronous operation (such as a fetch request) and abort it if required via an AbortController object.839 *840 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)841 */842declare abstract class AbortSignal extends EventTarget {843 /**844 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an abort event).845 *846 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)847 */848 static abort(reason?: any): AbortSignal;849 /**850 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.851 *852 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)853 */854 static timeout(delay: number): AbortSignal;855 /**856 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal. The returned abort signal is aborted when any of the input iterable abort signals are aborted. The abort reason will be set to the reason of the first signal that is aborted. If any of the given abort signals are already aborted then so will be the returned AbortSignal.857 *858 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)859 */860 static any(signals: AbortSignal[]): AbortSignal;861 /**862 * The **`aborted`** read-only property returns a value that indicates whether the asynchronous operations the signal is communicating with are aborted (true) or not (false).863 *864 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)865 */866 get aborted(): boolean;867 /**868 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.869 *870 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)871 */872 get reason(): any;873 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */874 get onabort(): any | null;875 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */876 set onabort(value: any | null);877 /**878 * The **`throwIfAborted()`** method throws the signal's abort reason if the signal has been aborted; otherwise it does nothing.879 *880 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)881 */882 throwIfAborted(): void;883}884/**885 * The **`Scheduler`** interface of the Prioritized Task Scheduling API provides methods for scheduling prioritized tasks.886 *887 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Scheduler)888 */889interface Scheduler {890 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;891}892interface SchedulerWaitOptions {893 signal?: AbortSignal;894}895/**896 * The **`ExtendableEvent`** interface extends the lifetime of the install and activate events dispatched on the global scope as part of the service worker lifecycle. This ensures that any functional events (like FetchEvent) are not dispatched until it upgrades database schemas and deletes the outdated cache entries.897 *898 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)899 */900declare abstract class ExtendableEvent extends Event {901 /**902 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing. It can also be used to detect whether that work was successful. In service workers, waitUntil() tells the browser that work is ongoing until the promise settles, and it shouldn't terminate the service worker if it wants that work to complete.903 *904 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)905 */906 waitUntil(promise: Promise<any>): void;907}908/**909 * The **`CustomEvent`** interface can be used to attach custom data to an event generated by an application.910 *911 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)912 */913declare class CustomEvent<T = any> extends Event {914 constructor(type: string, init?: CustomEventCustomEventInit);915 /**916 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.917 *918 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)919 */920 get detail(): T;921}922interface CustomEventCustomEventInit {923 bubbles?: boolean;924 cancelable?: boolean;925 composed?: boolean;926 detail?: any;927}928/**929 * The **`Blob`** interface represents a blob, which is a file-like object of immutable, raw data; they can be read as text or binary data, or converted into a ReadableStream so its methods can be used for processing the data.930 *931 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)932 */933declare class Blob {934 constructor(bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions);935 /**936 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.937 *938 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)939 */940 get size(): number;941 /**942 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.943 *944 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)945 */946 get type(): string;947 /**948 * The **`slice()`** method of the Blob interface creates and returns a new Blob object which contains data from a subset of the blob on which it's called.949 *950 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)951 */952 slice(start?: number, end?: number, type?: string): Blob;953 /**954 * The **`arrayBuffer()`** method of the Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer.955 *956 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)957 */958 arrayBuffer(): Promise<ArrayBuffer>;959 /**960 * The **`bytes()`** method of the Blob interface returns a Promise that resolves with a Uint8Array containing the contents of the blob as an array of bytes.961 *962 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)963 */964 bytes(): Promise<Uint8Array>;965 /**966 * The **`text()`** method of the Blob interface returns a Promise that resolves with a string containing the contents of the blob, interpreted as UTF-8.967 *968 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)969 */970 text(): Promise<string>;971 /**972 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the Blob.973 *974 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)975 */976 stream(): ReadableStream;977}978interface BlobOptions {979 type?: string;980}981/**982 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.983 *984 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)985 */986declare class File extends Blob {987 constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions);988 /**989 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object. For security reasons, the path is excluded from this property.990 *991 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)992 */993 get name(): string;994 /**995 * The **`lastModified`** read-only property of the File interface provides the last modified date of the file as the number of milliseconds since the Unix epoch (January 1, 1970 at midnight). Files without a known last modified date return the current date.996 *997 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)998 */999 get lastModified(): number;1000}1001interface FileOptions {1002 type?: string;1003 lastModified?: number;1004}1005/**1006* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.1007*1008* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)1009*/1010declare abstract class CacheStorage {1011 /**1012 * The **`open()`** method of the CacheStorage interface returns a Promise that resolves to the Cache object matching the cacheName.1013 *1014 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)1015 */1016 open(cacheName: string): Promise<Cache>;1017 readonly default: Cache;1018}1019/**1020* The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.1021*1022* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)1023*/1024declare abstract class Cache {1025 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */1026 delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>;1027 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */1028 match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>;1029 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */1030 put(request: RequestInfo | URL, response: Response): Promise<void>;1031}1032interface CacheQueryOptions {1033 ignoreMethod?: boolean;1034}1035/**1036* The Web Crypto API provides a set of low-level functions for common cryptographic tasks.1037* The Workers runtime implements the full surface of this API, but with some differences in1038* the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)1039* compared to those implemented in most browsers.1040*1041* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)1042*/1043declare abstract class Crypto {1044 /**1045 * The **`Crypto.subtle`** read-only property returns a SubtleCrypto which can then be used to perform low-level cryptographic operations.1046 * Available only in secure contexts.1047 *1048 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)1049 */1050 get subtle(): SubtleCrypto;1051 /**1052 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values. The array given as the parameter is filled with random numbers (random in its cryptographic meaning).1053 *1054 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)1055 */1056 getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T;1057 /**1058 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.1059 * Available only in secure contexts.1060 *1061 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)1062 */1063 randomUUID(): string;1064 DigestStream: typeof DigestStream;1065}1066/**1067 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.1068 * Available only in secure contexts.1069 *1070 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)1071 */1072declare abstract class SubtleCrypto {1073 /**1074 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.1075 *1076 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)1077 */1078 encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;1079 /**1080 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data. It takes as arguments a key to decrypt with, some optional extra parameters, and the data to decrypt (also known as "ciphertext"). It returns a Promise which will be fulfilled with the decrypted data (also known as "plaintext").1081 *1082 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)1083 */1084 decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;1085 /**1086 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.1087 *1088 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)1089 */1090 sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;1091 /**1092 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.1093 *1094 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)1095 */1096 verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>;1097 /**1098 * The **`digest()`** method of the SubtleCrypto interface generates a digest of the given data, using the specified hash function. A digest is a short fixed-length value derived from some variable-length input. Cryptographic digests should exhibit collision-resistance, meaning that it's hard to come up with two different inputs that have the same digest value.1099 *1100 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)1101 */1102 digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>;1103 /**1104 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).1105 *1106 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)1107 */1108 generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>;1109 /**1110 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.1111 *1112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)1113 */1114 deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;1115 /**1116 * The **`deriveBits()`** method of the SubtleCrypto interface can be used to derive an array of bits from a base key.1117 *1118 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)1119 */1120 deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>;1121 /**1122 * The **`importKey()`** method of the SubtleCrypto interface imports a key: that is, it takes as input a key in an external, portable format and gives you a CryptoKey object that you can use in the Web Crypto API.1123 *1124 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)1125 */1126 importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;1127 /**1128 * The **`exportKey()`** method of the SubtleCrypto interface exports a key: that is, it takes as input a CryptoKey object and gives you the key in an external, portable format.1129 *1130 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)1131 */1132 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;1133 /**1134 * The **`wrapKey()`** method of the SubtleCrypto interface "wraps" a key. This means that it exports the key in an external, portable format, then encrypts the exported key. Wrapping a key helps protect it in untrusted environments, such as inside an otherwise unprotected data store or in transmission over an unprotected network.1135 *1136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)1137 */1138 wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>;1139 /**1140 * The **`unwrapKey()`** method of the SubtleCrypto interface "unwraps" a key. This means that it takes as its input a key that has been exported and then encrypted (also called "wrapped"). It decrypts the key and then imports it, returning a CryptoKey object that can be used in the Web Crypto API.1141 *1142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)1143 */1144 unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>;1145 timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean;1146}1147/**1148 * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods generateKey(), deriveKey(), importKey(), or unwrapKey().1149 * Available only in secure contexts.1150 *1151 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)1152 */1153declare abstract class CryptoKey {1154 /**1155 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object. It can have the following values:1156 *1157 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)1158 */1159 readonly type: string;1160 /**1161 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using SubtleCrypto.exportKey() or SubtleCrypto.wrapKey().1162 *1163 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)1164 */1165 readonly extractable: boolean;1166 /**1167 * The read-only **`algorithm`** property of the CryptoKey interface returns an object describing the algorithm for which this key can be used, and any associated extra parameters.1168 *1169 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)1170 */1171 readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm;1172 /**1173 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.1174 *1175 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)1176 */1177 readonly usages: string[];1178}1179interface CryptoKeyPair {1180 publicKey: CryptoKey;1181 privateKey: CryptoKey;1182}1183interface JsonWebKey {1184 kty: string;1185 use?: string;1186 key_ops?: string[];1187 alg?: string;1188 ext?: boolean;1189 crv?: string;1190 x?: string;1191 y?: string;1192 d?: string;1193 n?: string;1194 e?: string;1195 p?: string;1196 q?: string;1197 dp?: string;1198 dq?: string;1199 qi?: string;1200 oth?: RsaOtherPrimesInfo[];1201 k?: string;1202}1203interface RsaOtherPrimesInfo {1204 r?: string;1205 d?: string;1206 t?: string;1207}1208interface SubtleCryptoDeriveKeyAlgorithm {1209 name: string;1210 salt?: (ArrayBuffer | ArrayBufferView);1211 iterations?: number;1212 hash?: (string | SubtleCryptoHashAlgorithm);1213 $public?: CryptoKey;1214 info?: (ArrayBuffer | ArrayBufferView);1215}1216interface SubtleCryptoEncryptAlgorithm {1217 name: string;1218 iv?: (ArrayBuffer | ArrayBufferView);1219 additionalData?: (ArrayBuffer | ArrayBufferView);1220 tagLength?: number;1221 counter?: (ArrayBuffer | ArrayBufferView);1222 length?: number;1223 label?: (ArrayBuffer | ArrayBufferView);1224}1225interface SubtleCryptoGenerateKeyAlgorithm {1226 name: string;1227 hash?: (string | SubtleCryptoHashAlgorithm);1228 modulusLength?: number;1229 publicExponent?: (ArrayBuffer | ArrayBufferView);1230 length?: number;1231 namedCurve?: string;1232}1233interface SubtleCryptoHashAlgorithm {1234 name: string;1235}1236interface SubtleCryptoImportKeyAlgorithm {1237 name: string;1238 hash?: (string | SubtleCryptoHashAlgorithm);1239 length?: number;1240 namedCurve?: string;1241 compressed?: boolean;1242}1243interface SubtleCryptoSignAlgorithm {1244 name: string;1245 hash?: (string | SubtleCryptoHashAlgorithm);1246 dataLength?: number;1247 saltLength?: number;1248}1249interface CryptoKeyKeyAlgorithm {1250 name: string;1251}1252interface CryptoKeyAesKeyAlgorithm {1253 name: string;1254 length: number;1255}1256interface CryptoKeyHmacKeyAlgorithm {1257 name: string;1258 hash: CryptoKeyKeyAlgorithm;1259 length: number;1260}1261interface CryptoKeyRsaKeyAlgorithm {1262 name: string;1263 modulusLength: number;1264 publicExponent: ArrayBuffer | ArrayBufferView;1265 hash?: CryptoKeyKeyAlgorithm;1266}1267interface CryptoKeyEllipticKeyAlgorithm {1268 name: string;1269 namedCurve: string;1270}1271interface CryptoKeyArbitraryKeyAlgorithm {1272 name: string;1273 hash?: CryptoKeyKeyAlgorithm;1274 namedCurve?: string;1275 length?: number;1276}1277declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> {1278 constructor(algorithm: string | SubtleCryptoHashAlgorithm);1279 readonly digest: Promise<ArrayBuffer>;1280 get bytesWritten(): number | bigint;1281}1282/**1283 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as UTF-8, ISO-8859-2, or GBK. A decoder takes an array of bytes as input and returns a JavaScript string.1284 *1285 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)1286 */1287declare class TextDecoder {1288 constructor(label?: string, options?: TextDecoderConstructorOptions);1289 /**1290 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.1291 *1292 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)1293 */1294 decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string;1295 get encoding(): string;1296 get fatal(): boolean;1297 get ignoreBOM(): boolean;1298}1299/**1300 * The **`TextEncoder`** interface enables you to encode a JavaScript string using UTF-8.1301 *1302 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)1303 */1304declare class TextEncoder {1305 constructor();1306 /**1307 * The **`TextEncoder.encode()`** method takes a string as input, and returns a Uint8Array containing the string encoded using UTF-8.1308 *1309 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)1310 */1311 encode(input?: string): Uint8Array;1312 /**1313 * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns an object indicating the progress of the encoding. This is potentially more performant than the encode() method — especially when the target buffer is a view into a Wasm heap.1314 *1315 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)1316 */1317 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;1318 get encoding(): string;1319}1320interface TextDecoderConstructorOptions {1321 fatal: boolean;1322 ignoreBOM: boolean;1323}1324interface TextDecoderDecodeOptions {1325 stream: boolean;1326}1327interface TextEncoderEncodeIntoResult {1328 read: number;1329 written: number;1330}1331/**1332 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.1333 *1334 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)1335 */1336declare class ErrorEvent extends Event {1337 constructor(type: string, init?: ErrorEventErrorEventInit);1338 /**1339 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.1340 *1341 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)1342 */1343 get filename(): string;1344 /**1345 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.1346 *1347 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)1348 */1349 get message(): string;1350 /**1351 * The **`lineno`** read-only property of the ErrorEvent interface returns an integer containing the line number of the script file on which the error occurred.1352 *1353 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)1354 */1355 get lineno(): number;1356 /**1357 * The **`colno`** read-only property of the ErrorEvent interface returns an integer containing the column number of the script file on which the error occurred.1358 *1359 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)1360 */1361 get colno(): number;1362 /**1363 * The **`error`** read-only property of the ErrorEvent interface returns a JavaScript value, such as an Error or DOMException, representing the error associated with this event.1364 *1365 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)1366 */1367 get error(): any;1368}1369interface ErrorEventErrorEventInit {1370 message?: string;1371 filename?: string;1372 lineno?: number;1373 colno?: number;1374 error?: any;1375}1376/**1377 * The **`MessageEvent`** interface represents a message received by a target object.1378 *1379 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)1380 */1381declare class MessageEvent extends Event {1382 constructor(type: string, initializer: MessageEventInit);1383 /**1384 * The **`data`** read-only property of the MessageEvent interface represents the data sent by the message emitter.1385 *1386 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)1387 */1388 readonly data: any;1389 /**1390 * The **`origin`** read-only property of the MessageEvent interface is a string representing the origin of the message emitter.1391 *1392 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)1393 */1394 readonly origin: string | null;1395 /**1396 * The **`lastEventId`** read-only property of the MessageEvent interface is a string representing a unique ID for the event.1397 *1398 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)1399 */1400 readonly lastEventId: string;1401 /**1402 * The **`source`** read-only property of the MessageEvent interface is a MessageEventSource (which can be a WindowProxy, MessagePort, or ServiceWorker object) representing the message emitter.1403 *1404 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)1405 */1406 readonly source: MessagePort | null;1407 /**1408 * The **`ports`** read-only property of the MessageEvent interface is an array of MessagePort objects containing all MessagePort objects sent with the message, in order.1409 *1410 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)1411 */1412 readonly ports: MessagePort[];1413}1414interface MessageEventInit {1415 data: ArrayBuffer | string;1416}1417/**1418 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected. These events are particularly useful for telemetry and debugging purposes.1419 *1420 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)1421 */1422declare abstract class PromiseRejectionEvent extends Event {1423 /**1424 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript Promise which was rejected. You can examine the event's PromiseRejectionEvent.reason property to learn why the promise was rejected.1425 *1426 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)1427 */1428 readonly promise: Promise<any>;1429 /**1430 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). This in theory provides information about why the promise was rejected.1431 *1432 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)1433 */1434 readonly reason: any;1435}1436/**1437 * The **`FormData`** interface provides a way to construct a set of key/value pairs representing form fields and their values, which can be sent using the fetch(), XMLHttpRequest.send() or navigator.sendBeacon() methods. It uses the same format a form would use if the encoding type were set to "multipart/form-data".1438 *1439 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)1440 */1441declare class FormData {1442 constructor();1443 /**1444 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.1445 *1446 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)1447 */1448 append(name: string, value: string | Blob): void;1449 /**1450 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.1451 *1452 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)1453 */1454 append(name: string, value: string): void;1455 /**1456 * The **`append()`** method of the FormData interface appends a new value onto an existing key inside a FormData object, or adds the key if it does not already exist.1457 *1458 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)1459 */1460 append(name: string, value: Blob, filename?: string): void;1461 /**1462 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a FormData object.1463 *1464 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)1465 */1466 delete(name: string): void;1467 /**1468 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a FormData object. If you expect multiple values and want all of them, use the getAll() method instead.1469 *1470 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)1471 */1472 get(name: string): (File | string) | null;1473 /**1474 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a FormData object.1475 *1476 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)1477 */1478 getAll(name: string): (File | string)[];1479 /**1480 * The **`has()`** method of the FormData interface returns whether a FormData object contains a certain key.1481 *1482 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)1483 */1484 has(name: string): boolean;1485 /**1486 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.1487 *1488 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)1489 */1490 set(name: string, value: string | Blob): void;1491 /**1492 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.1493 *1494 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)1495 */1496 set(name: string, value: string): void;1497 /**1498 * The **`set()`** method of the FormData interface sets a new value for an existing key inside a FormData object, or adds the key/value if it does not already exist.1499 *1500 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)1501 */1502 set(name: string, value: Blob, filename?: string): void;1503 entries(): IterableIterator<[1504 key: string,1505 value: File | string1506 ]>;1507 keys(): IterableIterator<string>;1508 values(): IterableIterator<(File | string)>;1509 forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void;1510 [Symbol.iterator](): IterableIterator<[1511 key: string,1512 value: File | string1513 ]>;1514}1515interface ContentOptions {1516 html?: boolean;1517}1518declare class HTMLRewriter {1519 constructor();1520 on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter;1521 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;1522 transform(response: Response): Response;1523}1524interface HTMLRewriterElementContentHandlers {1525 element?(element: Element): void | Promise<void>;1526 comments?(comment: Comment): void | Promise<void>;1527 text?(element: Text): void | Promise<void>;1528}1529interface HTMLRewriterDocumentContentHandlers {1530 doctype?(doctype: Doctype): void | Promise<void>;1531 comments?(comment: Comment): void | Promise<void>;1532 text?(text: Text): void | Promise<void>;1533 end?(end: DocumentEnd): void | Promise<void>;1534}1535interface Doctype {1536 readonly name: string | null;1537 readonly publicId: string | null;1538 readonly systemId: string | null;1539}1540interface Element {1541 tagName: string;1542 readonly attributes: IterableIterator<string[]>;1543 readonly removed: boolean;1544 readonly namespaceURI: string;1545 getAttribute(name: string): string | null;1546 hasAttribute(name: string): boolean;1547 setAttribute(name: string, value: string): Element;1548 removeAttribute(name: string): Element;1549 before(content: string | ReadableStream | Response, options?: ContentOptions): Element;1550 after(content: string | ReadableStream | Response, options?: ContentOptions): Element;1551 prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element;1552 append(content: string | ReadableStream | Response, options?: ContentOptions): Element;1553 replace(content: string | ReadableStream | Response, options?: ContentOptions): Element;1554 remove(): Element;1555 removeAndKeepContent(): Element;1556 setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element;1557 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;1558}1559interface EndTag {1560 name: string;1561 before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;1562 after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag;1563 remove(): EndTag;1564}1565interface Comment {1566 text: string;1567 readonly removed: boolean;1568 before(content: string, options?: ContentOptions): Comment;1569 after(content: string, options?: ContentOptions): Comment;1570 replace(content: string, options?: ContentOptions): Comment;1571 remove(): Comment;1572}1573interface Text {1574 readonly text: string;1575 readonly lastInTextNode: boolean;1576 readonly removed: boolean;1577 before(content: string | ReadableStream | Response, options?: ContentOptions): Text;1578 after(content: string | ReadableStream | Response, options?: ContentOptions): Text;1579 replace(content: string | ReadableStream | Response, options?: ContentOptions): Text;1580 remove(): Text;1581}1582interface DocumentEnd {1583 append(content: string, options?: ContentOptions): DocumentEnd;1584}1585/**1586 * This is the event type for fetch events dispatched on the service worker global scope. It contains information about the fetch, including the request and how the receiver will treat the response. It provides the event.respondWith() method, which allows us to provide a response to this fetch.1587 *1588 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)1589 */1590declare abstract class FetchEvent extends ExtendableEvent {1591 /**1592 * The **`request`** read-only property of the FetchEvent interface returns the Request that triggered the event handler.1593 *1594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)1595 */1596 readonly request: Request;1597 /**1598 * The **`respondWith()`** method of FetchEvent prevents the browser's default fetch handling, and allows you to provide a promise for a Response yourself.1599 *1600 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)1601 */1602 respondWith(promise: Response | Promise<Response>): void;1603 passThroughOnException(): void;1604}1605type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>;1606/**1607 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers. These actions include retrieving, setting, adding to, and removing headers from the list of the request's headers.1608 *1609 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)1610 */1611declare class Headers {1612 constructor(init?: HeadersInit);1613 /**1614 * The **`get()`** method of the Headers interface returns a byte string of all the values of a header within a Headers object with a given name. If the requested header doesn't exist in the Headers object, it returns null.1615 *1616 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)1617 */1618 get(name: string): string | null;1619 getAll(name: string): string[];1620 /**1621 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response. This allows Headers objects to handle having multiple Set-Cookie headers, which wasn't possible prior to its implementation.1622 *1623 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)1624 */1625 getSetCookie(): string[];1626 /**1627 * The **`has()`** method of the Headers interface returns a boolean stating whether a Headers object contains a certain header.1628 *1629 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)1630 */1631 has(name: string): boolean;1632 /**1633 * The **`set()`** method of the Headers interface sets a new value for an existing header inside a Headers object, or adds the header if it does not already exist.1634 *1635 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)1636 */1637 set(name: string, value: string): void;1638 /**1639 * The **`append()`** method of the Headers interface appends a new value onto an existing header inside a Headers object, or adds the header if it does not already exist.1640 *1641 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)1642 */1643 append(name: string, value: string): void;1644 /**1645 * The **`delete()`** method of the Headers interface deletes a header from the current Headers object.1646 *1647 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)1648 */1649 delete(name: string): void;1650 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void;1651 entries(): IterableIterator<[1652 key: string,1653 value: string1654 ]>;1655 keys(): IterableIterator<string>;1656 values(): IterableIterator<string>;1657 [Symbol.iterator](): IterableIterator<[1658 key: string,1659 value: string1660 ]>;1661}1662type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData | Iterable<ArrayBuffer | ArrayBufferView> | AsyncIterable<ArrayBuffer | ArrayBufferView>;1663declare abstract class Body {1664 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */1665 get body(): ReadableStream | null;1666 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */1667 get bodyUsed(): boolean;1668 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */1669 arrayBuffer(): Promise<ArrayBuffer>;1670 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */1671 bytes(): Promise<Uint8Array>;1672 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */1673 text(): Promise<string>;1674 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */1675 json<T>(): Promise<T>;1676 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */1677 formData(): Promise<FormData>;1678 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */1679 blob(): Promise<Blob>;1680}1681/**1682 * The **`Response`** interface of the Fetch API represents the response to a request.1683 *1684 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)1685 */1686declare var Response: {1687 prototype: Response;1688 new (body?: BodyInit | null, init?: ResponseInit): Response;1689 error(): Response;1690 redirect(url: string, status?: number): Response;1691 json(any: any, maybeInit?: (ResponseInit | Response)): Response;1692};1693/**1694 * The **`Response`** interface of the Fetch API represents the response to a request.1695 *1696 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)1697 */1698interface Response extends Body {1699 /**1700 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.1701 *1702 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)1703 */1704 clone(): Response;1705 /**1706 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.1707 *1708 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)1709 */1710 status: number;1711 /**1712 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.1713 *1714 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)1715 */1716 statusText: string;1717 /**1718 * The **`headers`** read-only property of the Response interface contains the Headers object associated with the response.1719 *1720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)1721 */1722 headers: Headers;1723 /**1724 * The **`ok`** read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not.1725 *1726 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)1727 */1728 ok: boolean;1729 /**1730 * The **`redirected`** read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected.1731 *1732 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)1733 */1734 redirected: boolean;1735 /**1736 * The **`url`** read-only property of the Response interface contains the URL of the response. The value of the url property will be the final URL obtained after any redirects.1737 *1738 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)1739 */1740 url: string;1741 webSocket: WebSocket | null;1742 cf: any | undefined;1743 /**1744 * The **`type`** read-only property of the Response interface contains the type of the response. The type determines whether scripts are able to access the response body and headers.1745 *1746 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)1747 */1748 type: "default" | "error";1749}1750interface ResponseInit {1751 status?: number;1752 statusText?: string;1753 headers?: HeadersInit;1754 cf?: any;1755 webSocket?: (WebSocket | null);1756 encodeBody?: "automatic" | "manual";1757}1758type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string;1759/**1760 * The **`Request`** interface of the Fetch API represents a resource request.1761 *1762 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)1763 */1764declare var Request: {1765 prototype: Request;1766 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>;1767};1768/**1769 * The **`Request`** interface of the Fetch API represents a resource request.1770 *1771 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)1772 */1773interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body {1774 /**1775 * The **`clone()`** method of the Request interface creates a copy of the current Request object.1776 *1777 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)1778 */1779 clone(): Request<CfHostMetadata, Cf>;1780 /**1781 * The **`method`** read-only property of the Request interface contains the request's method (GET, POST, etc.)1782 *1783 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)1784 */1785 method: string;1786 /**1787 * The **`url`** read-only property of the Request interface contains the URL of the request.1788 *1789 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)1790 */1791 url: string;1792 /**1793 * The **`headers`** read-only property of the Request interface contains the Headers object associated with the request.1794 *1795 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)1796 */1797 headers: Headers;1798 /**1799 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.1800 *1801 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)1802 */1803 redirect: string;1804 fetcher: Fetcher | null;1805 /**1806 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.1807 *1808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)1809 */1810 signal: AbortSignal;1811 cf?: Cf;1812 /**1813 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.1814 *1815 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)1816 */1817 integrity: string;1818 /**1819 * The **`keepalive`** read-only property of the Request interface contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.1820 *1821 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)1822 */1823 keepalive: boolean;1824 /**1825 * The **`cache`** read-only property of the Request interface contains the cache mode of the request. It controls how the request will interact with the browser's HTTP cache.1826 *1827 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)1828 */1829 cache?: "no-store" | "no-cache";1830}1831interface RequestInit<Cf = CfProperties> {1832 /* A string to set request's method. */1833 method?: string;1834 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */1835 headers?: HeadersInit;1836 /* A BodyInit object or null to set request's body. */1837 body?: BodyInit | null;1838 /* A string indicating whether request follows redirects, results in an error upon encountering a redirect, or returns the redirect (in an opaque fashion). Sets request's redirect. */1839 redirect?: string;1840 fetcher?: (Fetcher | null);1841 cf?: Cf;1842 /* A string indicating how the request will interact with the browser's cache to set request's cache. */1843 cache?: "no-store" | "no-cache";1844 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */1845 integrity?: string;1846 /* An AbortSignal to set request's signal. */1847 signal?: (AbortSignal | null);1848 encodeResponseBody?: "automatic" | "manual";1849}1850type Service<T extends (new (...args: any[]) => Rpc.WorkerEntrypointBranded) | Rpc.WorkerEntrypointBranded | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? Fetcher<InstanceType<T>> : T extends Rpc.WorkerEntrypointBranded ? Fetcher<T> : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded> ? never : Fetcher<undefined>;1851type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & {1852 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;1853 connect(address: SocketAddress | string, options?: SocketOptions): Socket;1854};1855interface KVNamespaceListKey<Metadata, Key extends string = string> {1856 name: Key;1857 expiration?: number;1858 metadata?: Metadata;1859}1860type KVNamespaceListResult<Metadata, Key extends string = string> = {1861 list_complete: false;1862 keys: KVNamespaceListKey<Metadata, Key>[];1863 cursor: string;1864 cacheStatus: string | null;1865} | {1866 list_complete: true;1867 keys: KVNamespaceListKey<Metadata, Key>[];1868 cacheStatus: string | null;1869};1870interface KVNamespace<Key extends string = string> {1871 get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>;1872 get(key: Key, type: "text"): Promise<string | null>;1873 get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>;1874 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;1875 get(key: Key, type: "stream"): Promise<ReadableStream | null>;1876 get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>;1877 get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>;1878 get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>;1879 get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>;1880 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;1881 get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>;1882 get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>;1883 get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>;1884 get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>;1885 list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>;1886 put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;1887 getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;1888 getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;1889 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;1890 getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;1891 getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;1892 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;1893 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;1894 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;1895 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;1896 getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;1897 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;1898 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;1899 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;1900 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>;1901 delete(key: Key): Promise<void>;1902}1903interface KVNamespaceListOptions {1904 limit?: number;1905 prefix?: (string | null);1906 cursor?: (string | null);1907}1908interface KVNamespaceGetOptions<Type> {1909 type: Type;1910 cacheTtl?: number;1911}1912interface KVNamespacePutOptions {1913 expiration?: number;1914 expirationTtl?: number;1915 metadata?: (any | null);1916}1917interface KVNamespaceGetWithMetadataResult<Value, Metadata> {1918 value: Value | null;1919 metadata: Metadata | null;1920 cacheStatus: string | null;1921}1922type QueueContentType = "text" | "bytes" | "json" | "v8";1923interface Queue<Body = unknown> {1924 metrics(): Promise<QueueMetrics>;1925 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;1926 sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<QueueSendBatchResponse>;1927}1928interface QueueSendMetrics {1929 backlogCount: number;1930 backlogBytes: number;1931 oldestMessageTimestamp?: Date;1932}1933interface QueueSendMetadata {1934 metrics: QueueSendMetrics;1935}1936interface QueueSendResponse {1937 metadata: QueueSendMetadata;1938}1939interface QueueSendBatchMetrics {1940 backlogCount: number;1941 backlogBytes: number;1942 oldestMessageTimestamp?: Date;1943}1944interface QueueSendBatchMetadata {1945 metrics: QueueSendBatchMetrics;1946}1947interface QueueSendBatchResponse {1948 metadata: QueueSendBatchMetadata;1949}1950interface QueueSendOptions {1951 contentType?: QueueContentType;1952 delaySeconds?: number;1953}1954interface QueueSendBatchOptions {1955 delaySeconds?: number;1956}1957interface MessageSendRequest<Body = unknown> {1958 body: Body;1959 contentType?: QueueContentType;1960 delaySeconds?: number;1961}1962interface QueueMetrics {1963 backlogCount: number;1964 backlogBytes: number;1965 oldestMessageTimestamp?: Date;1966}1967interface MessageBatchMetrics {1968 backlogCount: number;1969 backlogBytes: number;1970 oldestMessageTimestamp?: Date;1971}1972interface MessageBatchMetadata {1973 metrics: MessageBatchMetrics;1974}1975interface QueueRetryOptions {1976 delaySeconds?: number;1977}1978interface Message<Body = unknown> {1979 readonly id: string;1980 readonly timestamp: Date;1981 readonly body: Body;1982 readonly attempts: number;1983 retry(options?: QueueRetryOptions): void;1984 ack(): void;1985}1986interface QueueEvent<Body = unknown> extends ExtendableEvent {1987 readonly messages: readonly Message<Body>[];1988 readonly queue: string;1989 readonly metadata: MessageBatchMetadata;1990 retryAll(options?: QueueRetryOptions): void;1991 ackAll(): void;1992}1993interface MessageBatch<Body = unknown> {1994 readonly messages: readonly Message<Body>[];1995 readonly queue: string;1996 readonly metadata: MessageBatchMetadata;1997 retryAll(options?: QueueRetryOptions): void;1998 ackAll(): void;1999}2000interface R2Error extends Error {2001 readonly name: string;2002 readonly code: number;2003 readonly message: string;2004 readonly action: string;2005 readonly stack: any;2006}2007interface R2ListOptions {2008 limit?: number;2009 prefix?: string;2010 cursor?: string;2011 delimiter?: string;2012 startAfter?: string;2013 include?: ("httpMetadata" | "customMetadata")[];2014}2015interface R2Bucket {2016 head(key: string): Promise<R2Object | null>;2017 get(key: string, options: R2GetOptions & {2018 onlyIf: R2Conditional | Headers;2019 }): Promise<R2ObjectBody | R2Object | null>;2020 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;2021 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & {2022 onlyIf: R2Conditional | Headers;2023 }): Promise<R2Object | null>;2024 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>;2025 createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>;2026 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;2027 delete(keys: string | string[]): Promise<void>;2028 list(options?: R2ListOptions): Promise<R2Objects>;2029}2030interface R2MultipartUpload {2031 readonly key: string;2032 readonly uploadId: string;2033 uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>;2034 abort(): Promise<void>;2035 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;2036}2037interface R2UploadedPart {2038 partNumber: number;2039 etag: string;2040}2041declare abstract class R2Object {2042 readonly key: string;2043 readonly version: string;2044 readonly size: number;2045 readonly etag: string;2046 readonly httpEtag: string;2047 readonly checksums: R2Checksums;2048 readonly uploaded: Date;2049 readonly httpMetadata?: R2HTTPMetadata;2050 readonly customMetadata?: Record<string, string>;2051 readonly range?: R2Range;2052 readonly storageClass: string;2053 readonly ssecKeyMd5?: string;2054 writeHttpMetadata(headers: Headers): void;2055}2056interface R2ObjectBody extends R2Object {2057 get body(): ReadableStream;2058 get bodyUsed(): boolean;2059 arrayBuffer(): Promise<ArrayBuffer>;2060 bytes(): Promise<Uint8Array>;2061 text(): Promise<string>;2062 json<T>(): Promise<T>;2063 blob(): Promise<Blob>;2064}2065type R2Range = {2066 offset: number;2067 length?: number;2068} | {2069 offset?: number;2070 length: number;2071} | {2072 suffix: number;2073};2074interface R2Conditional {2075 etagMatches?: string;2076 etagDoesNotMatch?: string;2077 uploadedBefore?: Date;2078 uploadedAfter?: Date;2079 secondsGranularity?: boolean;2080}2081interface R2GetOptions {2082 onlyIf?: (R2Conditional | Headers);2083 range?: (R2Range | Headers);2084 ssecKey?: (ArrayBuffer | string);2085}2086interface R2PutOptions {2087 onlyIf?: (R2Conditional | Headers);2088 httpMetadata?: (R2HTTPMetadata | Headers);2089 customMetadata?: Record<string, string>;2090 md5?: ((ArrayBuffer | ArrayBufferView) | string);2091 sha1?: ((ArrayBuffer | ArrayBufferView) | string);2092 sha256?: ((ArrayBuffer | ArrayBufferView) | string);2093 sha384?: ((ArrayBuffer | ArrayBufferView) | string);2094 sha512?: ((ArrayBuffer | ArrayBufferView) | string);2095 storageClass?: string;2096 ssecKey?: (ArrayBuffer | string);2097}2098interface R2MultipartOptions {2099 httpMetadata?: (R2HTTPMetadata | Headers);2100 customMetadata?: Record<string, string>;2101 storageClass?: string;2102 ssecKey?: (ArrayBuffer | string);2103}2104interface R2Checksums {2105 readonly md5?: ArrayBuffer;2106 readonly sha1?: ArrayBuffer;2107 readonly sha256?: ArrayBuffer;2108 readonly sha384?: ArrayBuffer;2109 readonly sha512?: ArrayBuffer;2110 toJSON(): R2StringChecksums;2111}2112interface R2StringChecksums {2113 md5?: string;2114 sha1?: string;2115 sha256?: string;2116 sha384?: string;2117 sha512?: string;2118}2119interface R2HTTPMetadata {2120 contentType?: string;2121 contentLanguage?: string;2122 contentDisposition?: string;2123 contentEncoding?: string;2124 cacheControl?: string;2125 cacheExpiry?: Date;2126}2127type R2Objects = {2128 objects: R2Object[];2129 delimitedPrefixes: string[];2130} & ({2131 truncated: true;2132 cursor: string;2133} | {2134 truncated: false;2135});2136interface R2UploadPartOptions {2137 ssecKey?: (ArrayBuffer | string);2138}2139declare abstract class ScheduledEvent extends ExtendableEvent {2140 readonly scheduledTime: number;2141 readonly cron: string;2142 noRetry(): void;2143}2144interface ScheduledController {2145 readonly scheduledTime: number;2146 readonly cron: string;2147 noRetry(): void;2148}2149interface QueuingStrategy<T = any> {2150 highWaterMark?: (number | bigint);2151 size?: (chunk: T) => number | bigint;2152}2153interface UnderlyingSink<W = any> {2154 type?: string;2155 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;2156 write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>;2157 abort?: (reason: any) => void | Promise<void>;2158 close?: () => void | Promise<void>;2159}2160interface UnderlyingByteSource {2161 type: "bytes";2162 autoAllocateChunkSize?: number;2163 start?: (controller: ReadableByteStreamController) => void | Promise<void>;2164 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;2165 cancel?: (reason: any) => void | Promise<void>;2166}2167interface UnderlyingSource<R = any> {2168 type?: "" | undefined;2169 start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;2170 pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>;2171 cancel?: (reason: any) => void | Promise<void>;2172 expectedLength?: (number | bigint);2173}2174interface Transformer<I = any, O = any> {2175 readableType?: string;2176 writableType?: string;2177 start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;2178 transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>;2179 flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>;2180 cancel?: (reason: any) => void | Promise<void>;2181 expectedLength?: number;2182}2183interface StreamPipeOptions {2184 preventAbort?: boolean;2185 preventCancel?: boolean;2186 /**2187 * Pipes this readable stream to a given writable stream destination. The way in which the piping process behaves under various error conditions can be customized with a number of passed options. It returns a promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.2188 *2189 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.2190 *2191 * Errors and closures of the source and destination streams propagate as follows:2192 *2193 * An error in this source readable stream will abort destination, unless preventAbort is truthy. The returned promise will be rejected with the source's error, or with any error that occurs during aborting the destination.2194 *2195 * An error in destination will cancel this source readable stream, unless preventCancel is truthy. The returned promise will be rejected with the destination's error, or with any error that occurs during canceling the source.2196 *2197 * When this source readable stream closes, destination will be closed, unless preventClose is truthy. The returned promise will be fulfilled once this process completes, unless an error is encountered while closing the destination, in which case it will be rejected with that error.2198 *2199 * If destination starts out closed or closing, this source readable stream will be canceled, unless preventCancel is true. The returned promise will be rejected with an error indicating piping to a closed stream failed, or with any error that occurs during canceling the source.2200 *2201 * The signal option can be set to an AbortSignal to allow aborting an ongoing pipe operation via the corresponding AbortController. In this case, this source readable stream will be canceled, and destination aborted, unless the respective options preventCancel or preventAbort are set.2202 */2203 preventClose?: boolean;2204 signal?: AbortSignal;2205}2206type ReadableStreamReadResult<R = any> = {2207 done: false;2208 value: R;2209} | {2210 done: true;2211 value?: undefined;2212};2213/**2214 * The **`ReadableStream`** interface of the Streams API represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.2215 *2216 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)2217 */2218interface ReadableStream<R = any> {2219 /**2220 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.2221 *2222 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)2223 */2224 get locked(): boolean;2225 /**2226 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.2227 *2228 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)2229 */2230 cancel(reason?: any): Promise<void>;2231 /**2232 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released.2233 *2234 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)2235 */2236 getReader(): ReadableStreamDefaultReader<R>;2237 /**2238 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. While the stream is locked, no other reader can be acquired until this one is released.2239 *2240 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)2241 */2242 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;2243 /**2244 * The **`pipeThrough()`** method of the ReadableStream interface provides a chainable way of piping the current stream through a transform stream or any other writable/readable pair.2245 *2246 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)2247 */2248 pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>;2249 /**2250 * The **`pipeTo()`** method of the ReadableStream interface pipes the current ReadableStream to a given WritableStream and returns a Promise that fulfills when the piping process completes successfully, or rejects if any errors were encountered.2251 *2252 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)2253 */2254 pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>;2255 /**2256 * The **`tee()`** method of the ReadableStream interface tees the current readable stream, returning a two-element array containing the two resulting branches as new ReadableStream instances.2257 *2258 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)2259 */2260 tee(): [2261 ReadableStream<R>,2262 ReadableStream<R>2263 ];2264 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;2265 [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;2266}2267/**2268 * The **`ReadableStream`** interface of the Streams API represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.2269 *2270 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)2271 */2272declare const ReadableStream: {2273 prototype: ReadableStream;2274 new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>;2275 new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>;2276};2277/**2278 * The **`ReadableStreamDefaultReader`** interface of the Streams API represents a default reader that can be used to read stream data supplied from a network (such as a fetch request).2279 *2280 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)2281 */2282declare class ReadableStreamDefaultReader<R = any> {2283 constructor(stream: ReadableStream);2284 get closed(): Promise<void>;2285 cancel(reason?: any): Promise<void>;2286 /**2287 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.2288 *2289 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)2290 */2291 read(): Promise<ReadableStreamReadResult<R>>;2292 /**2293 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.2294 *2295 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)2296 */2297 releaseLock(): void;2298}2299/**2300 * The **`ReadableStreamBYOBReader`** interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source. It is used for efficient copying from underlying sources where the data is delivered as an "anonymous" sequence of bytes, such as files.2301 *2302 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)2303 */2304declare class ReadableStreamBYOBReader {2305 constructor(stream: ReadableStream);2306 get closed(): Promise<void>;2307 cancel(reason?: any): Promise<void>;2308 /**2309 * The **`read()`** method of the ReadableStreamBYOBReader interface is used to read data into a view on a user-supplied buffer from an associated readable byte stream. A request for data will be satisfied from the stream's internal queues if there is any data present. If the stream queues are empty, the request may be supplied as a zero-copy transfer from the underlying byte source.2310 *2311 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)2312 */2313 read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>;2314 /**2315 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream. After the lock is released, the reader is no longer active.2316 *2317 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)2318 */2319 releaseLock(): void;2320 readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>;2321}2322interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {2323 min?: number;2324}2325interface ReadableStreamGetReaderOptions {2326 /**2327 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.2328 *2329 * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. The returned BYOB reader provides the ability to directly read individual chunks from the stream via its read() method, into developer-supplied buffers, allowing more precise control over allocation.2330 */2331 mode: "byob";2332}2333/**2334 * The **`ReadableStreamBYOBRequest`** interface of the Streams API represents a "pull request" for data from an underlying source that will made as a zero-copy transfer to a consumer (bypassing the stream's internal queues).2335 *2336 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)2337 */2338declare abstract class ReadableStreamBYOBRequest {2339 /**2340 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.2341 *2342 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)2343 */2344 get view(): Uint8Array | null;2345 /**2346 * The **`respond()`** method of the ReadableStreamBYOBRequest interface is used to signal to the associated readable byte stream that the specified number of bytes were written into the ReadableStreamBYOBRequest.view.2347 *2348 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)2349 */2350 respond(bytesWritten: number): void;2351 /**2352 * The **`respondWithNewView()`** method of the ReadableStreamBYOBRequest interface specifies a new view that the consumer of the associated readable byte stream should write to instead of ReadableStreamBYOBRequest.view.2353 *2354 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)2355 */2356 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;2357 get atLeast(): number | null;2358}2359/**2360 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue. Default controllers are for streams that are not byte streams.2361 *2362 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)2363 */2364declare abstract class ReadableStreamDefaultController<R = any> {2365 /**2366 * The **`desiredSize`** read-only property of the ReadableStreamDefaultController interface returns the desired size required to fill the stream's internal queue.2367 *2368 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)2369 */2370 get desiredSize(): number | null;2371 /**2372 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.2373 *2374 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)2375 */2376 close(): void;2377 /**2378 * The **`enqueue()`** method of the ReadableStreamDefaultController interface enqueues a given chunk in the associated stream.2379 *2380 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)2381 */2382 enqueue(chunk?: R): void;2383 /**2384 * The **`error()`** method of the ReadableStreamDefaultController interface causes any future interactions with the associated stream to error.2385 *2386 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)2387 */2388 error(reason: any): void;2389}2390/**2391 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream. It allows control of the state and internal queue of a ReadableStream with an underlying byte source, and enables efficient zero-copy transfer of data from the underlying source to a consumer when the stream's internal queue is empty.2392 *2393 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)2394 */2395declare abstract class ReadableByteStreamController {2396 /**2397 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or null if there are no pending requests.2398 *2399 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)2400 */2401 get byobRequest(): ReadableStreamBYOBRequest | null;2402 /**2403 * The **`desiredSize`** read-only property of the ReadableByteStreamController interface returns the number of bytes required to fill the stream's internal queue to its "desired size".2404 *2405 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)2406 */2407 get desiredSize(): number | null;2408 /**2409 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.2410 *2411 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)2412 */2413 close(): void;2414 /**2415 * The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is transferred into the stream's internal queues).2416 *2417 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)2418 */2419 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;2420 /**2421 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.2422 *2423 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)2424 */2425 error(reason: any): void;2426}2427/**2428 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state. When constructing a WritableStream, the underlying sink is given a corresponding WritableStreamDefaultController instance to manipulate.2429 *2430 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)2431 */2432declare abstract class WritableStreamDefaultController {2433 /**2434 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.2435 *2436 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)2437 */2438 get signal(): AbortSignal;2439 /**2440 * The **`error()`** method of the WritableStreamDefaultController interface causes any future interactions with the associated stream to error.2441 *2442 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)2443 */2444 error(reason?: any): void;2445}2446/**2447 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.2448 *2449 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)2450 */2451declare abstract class TransformStreamDefaultController<O = any> {2452 /**2453 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.2454 *2455 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)2456 */2457 get desiredSize(): number | null;2458 /**2459 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.2460 *2461 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)2462 */2463 enqueue(chunk?: O): void;2464 /**2465 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream. Any further interactions with it will fail with the given error message, and any chunks in the queue will be discarded.2466 *2467 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)2468 */2469 error(reason: any): void;2470 /**2471 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.2472 *2473 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)2474 */2475 terminate(): void;2476}2477interface ReadableWritablePair<R = any, W = any> {2478 readable: ReadableStream<R>;2479 /**2480 * Provides a convenient, chainable way of piping this readable stream through a transform stream (or any other { writable, readable } pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.2481 *2482 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.2483 */2484 writable: WritableStream<W>;2485}2486/**2487 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. This object comes with built-in backpressure and queuing.2488 *2489 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)2490 */2491declare class WritableStream<W = any> {2492 constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy);2493 /**2494 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the WritableStream is locked to a writer.2495 *2496 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)2497 */2498 get locked(): boolean;2499 /**2500 * The **`abort()`** method of the WritableStream interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.2501 *2502 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)2503 */2504 abort(reason?: any): Promise<void>;2505 /**2506 * The **`close()`** method of the WritableStream interface closes the associated stream. All chunks written before this method is called are sent before the returned promise is fulfilled.2507 *2508 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)2509 */2510 close(): Promise<void>;2511 /**2512 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance. While the stream is locked, no other writer can be acquired until this one is released.2513 *2514 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)2515 */2516 getWriter(): WritableStreamDefaultWriter<W>;2517}2518/**2519 * The **`WritableStreamDefaultWriter`** interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the WritableStream ensuring that no other streams can write to the underlying sink.2520 *2521 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)2522 */2523declare class WritableStreamDefaultWriter<W = any> {2524 constructor(stream: WritableStream);2525 /**2526 * The **`closed`** read-only property of the WritableStreamDefaultWriter interface returns a Promise that fulfills if the stream becomes closed, or rejects if the stream errors or the writer's lock is released.2527 *2528 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)2529 */2530 get closed(): Promise<void>;2531 /**2532 * The **`ready`** read-only property of the WritableStreamDefaultWriter interface returns a Promise that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.2533 *2534 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)2535 */2536 get ready(): Promise<void>;2537 /**2538 * The **`desiredSize`** read-only property of the WritableStreamDefaultWriter interface returns the desired size required to fill the stream's internal queue.2539 *2540 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)2541 */2542 get desiredSize(): number | null;2543 /**2544 * The **`abort()`** method of the WritableStreamDefaultWriter interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.2545 *2546 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)2547 */2548 abort(reason?: any): Promise<void>;2549 /**2550 * The **`close()`** method of the WritableStreamDefaultWriter interface closes the associated writable stream.2551 *2552 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)2553 */2554 close(): Promise<void>;2555 /**2556 * The **`write()`** method of the WritableStreamDefaultWriter interface writes a passed chunk of data to a WritableStream and its underlying sink, then returns a Promise that resolves to indicate the success or failure of the write operation.2557 *2558 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)2559 */2560 write(chunk?: W): Promise<void>;2561 /**2562 * The **`releaseLock()`** method of the WritableStreamDefaultWriter interface releases the writer's lock on the corresponding stream. After the lock is released, the writer is no longer active. If the associated stream is errored when the lock is released, the writer will appear errored in the same way from now on; otherwise, the writer will appear closed.2563 *2564 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)2565 */2566 releaseLock(): void;2567}2568/**2569 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain transform stream concept.2570 *2571 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)2572 */2573declare class TransformStream<I = any, O = any> {2574 constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>);2575 /**2576 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this TransformStream. This stream emits the transformed output data.2577 *2578 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)2579 */2580 get readable(): ReadableStream<O>;2581 /**2582 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this TransformStream. This stream accepts input data that will be transformed and emitted to the readable stream.2583 *2584 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)2585 */2586 get writable(): WritableStream<I>;2587}2588declare class FixedLengthStream extends IdentityTransformStream {2589 constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy);2590}2591declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {2592 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);2593}2594interface IdentityTransformStreamQueuingStrategy {2595 highWaterMark?: (number | bigint);2596}2597interface ReadableStreamValuesOptions {2598 preventCancel?: boolean;2599}2600/**2601 * The **`CompressionStream`** interface of the Compression Streams API compresses a stream of data. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.2602 *2603 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)2604 */2605declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {2606 constructor(format: "gzip" | "deflate" | "deflate-raw");2607}2608/**2609 * The **`DecompressionStream`** interface of the Compression Streams API decompresses a stream of data. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.2610 *2611 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)2612 */2613declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> {2614 constructor(format: "gzip" | "deflate" | "deflate-raw");2615}2616/**2617 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding. It is the streaming equivalent of TextEncoder. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.2618 *2619 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)2620 */2621declare class TextEncoderStream extends TransformStream<string, Uint8Array> {2622 constructor();2623 get encoding(): string;2624}2625/**2626 * The **`TextDecoderStream`** interface of the Encoding API converts a stream of text in a binary encoding, such as UTF-8 etc., to a stream of strings. It is the streaming equivalent of TextDecoder. It implements the same shape as a TransformStream, allowing it to be used in ReadableStream.pipeThrough() and similar methods.2627 *2628 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)2629 */2630declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> {2631 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);2632 get encoding(): string;2633 get fatal(): boolean;2634 get ignoreBOM(): boolean;2635}2636interface TextDecoderStreamTextDecoderStreamInit {2637 fatal?: boolean;2638 ignoreBOM?: boolean;2639}2640/**2641 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.2642 *2643 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)2644 */2645declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {2646 constructor(init: QueuingStrategyInit);2647 /**2648 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.2649 *2650 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)2651 */2652 get highWaterMark(): number;2653 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */2654 get size(): (chunk?: any) => number;2655}2656/**2657 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.2658 *2659 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)2660 */2661declare class CountQueuingStrategy implements QueuingStrategy {2662 constructor(init: QueuingStrategyInit);2663 /**2664 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.2665 *2666 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)2667 */2668 get highWaterMark(): number;2669 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */2670 get size(): (chunk?: any) => number;2671}2672interface QueuingStrategyInit {2673 /**2674 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.2675 *2676 * Note that the provided high water mark will not be validated ahead of time. Instead, if it is negative, NaN, or not a number, the resulting ByteLengthQueuingStrategy will cause the corresponding stream constructor to throw.2677 */2678 highWaterMark: number;2679}2680interface TracePreviewInfo {2681 id: string;2682 slug: string;2683 name: string;2684}2685interface ScriptVersion {2686 id?: string;2687 tag?: string;2688 message?: string;2689}2690declare abstract class TailEvent extends ExtendableEvent {2691 readonly events: TraceItem[];2692 readonly traces: TraceItem[];2693}2694interface TraceItem {2695 readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemConnectEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null;2696 readonly eventTimestamp: number | null;2697 readonly logs: TraceLog[];2698 readonly exceptions: TraceException[];2699 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];2700 readonly scriptName: string | null;2701 readonly entrypoint?: string;2702 readonly scriptVersion?: ScriptVersion;2703 readonly dispatchNamespace?: string;2704 readonly scriptTags?: string[];2705 readonly tailAttributes?: Record<string, boolean | number | string>;2706 readonly preview?: TracePreviewInfo;2707 readonly durableObjectId?: string;2708 readonly outcome: string;2709 readonly executionModel: string;2710 readonly truncated: boolean;2711 readonly cpuTime: number;2712 readonly wallTime: number;2713}2714interface TraceItemAlarmEventInfo {2715 readonly scheduledTime: Date;2716}2717interface TraceItemConnectEventInfo {2718}2719interface TraceItemCustomEventInfo {2720}2721interface TraceItemScheduledEventInfo {2722 readonly scheduledTime: number;2723 readonly cron: string;2724}2725interface TraceItemQueueEventInfo {2726 readonly queue: string;2727 readonly batchSize: number;2728}2729interface TraceItemEmailEventInfo {2730 readonly mailFrom: string;2731 readonly rcptTo: string;2732 readonly rawSize: number;2733}2734interface TraceItemTailEventInfo {2735 readonly consumedEvents: TraceItemTailEventInfoTailItem[];2736}2737interface TraceItemTailEventInfoTailItem {2738 readonly scriptName: string | null;2739}2740interface TraceItemFetchEventInfo {2741 readonly response?: TraceItemFetchEventInfoResponse;2742 readonly request: TraceItemFetchEventInfoRequest;2743}2744interface TraceItemFetchEventInfoRequest {2745 readonly cf?: any;2746 readonly headers: Record<string, string>;2747 readonly method: string;2748 readonly url: string;2749 getUnredacted(): TraceItemFetchEventInfoRequest;2750}2751interface TraceItemFetchEventInfoResponse {2752 readonly status: number;2753}2754interface TraceItemJsRpcEventInfo {2755 readonly rpcMethod: string;2756}2757interface TraceItemHibernatableWebSocketEventInfo {2758 readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError;2759}2760interface TraceItemHibernatableWebSocketEventInfoMessage {2761 readonly webSocketEventType: string;2762}2763interface TraceItemHibernatableWebSocketEventInfoClose {2764 readonly webSocketEventType: string;2765 readonly code: number;2766 readonly wasClean: boolean;2767}2768interface TraceItemHibernatableWebSocketEventInfoError {2769 readonly webSocketEventType: string;2770}2771interface TraceLog {2772 readonly timestamp: number;2773 readonly level: string;2774 readonly message: any;2775 readonly errorInfo?: (TraceLogErrorInfo | null)[];2776}2777interface TraceLogErrorInfo {2778 name: string;2779 message: string;2780 stack?: string;2781}2782interface TraceException {2783 readonly timestamp: number;2784 readonly message: string;2785 readonly name: string;2786 readonly stack?: string;2787}2788interface TraceDiagnosticChannelEvent {2789 readonly timestamp: number;2790 readonly channel: string;2791 readonly message: any;2792}2793interface TraceMetrics {2794 readonly cpuTime: number;2795 readonly wallTime: number;2796}2797interface UnsafeTraceMetrics {2798 fromTrace(item: TraceItem): TraceMetrics;2799}2800/**2801 * The **`URL`** interface is used to parse, construct, normalize, and encode URLs. It works by providing properties which allow you to easily read and modify the components of a URL.2802 *2803 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)2804 */2805declare class URL {2806 constructor(url: string | URL, base?: string | URL);2807 /**2808 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.2809 *2810 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)2811 */2812 get origin(): string;2813 /**2814 * The **`href`** property of the URL interface is a string containing the whole URL.2815 *2816 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)2817 */2818 get href(): string;2819 /**2820 * The **`href`** property of the URL interface is a string containing the whole URL.2821 *2822 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)2823 */2824 set href(value: string);2825 /**2826 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final ":".2827 *2828 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)2829 */2830 get protocol(): string;2831 /**2832 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final ":".2833 *2834 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)2835 */2836 set protocol(value: string);2837 /**2838 * The **`username`** property of the URL interface is a string containing the username component of the URL. If the URL does not have a username, this property contains an empty string, "".2839 *2840 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)2841 */2842 get username(): string;2843 /**2844 * The **`username`** property of the URL interface is a string containing the username component of the URL. If the URL does not have a username, this property contains an empty string, "".2845 *2846 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)2847 */2848 set username(value: string);2849 /**2850 * The **`password`** property of the URL interface is a string containing the password component of the URL. If the URL does not have a password, this property contains an empty string, "".2851 *2852 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)2853 */2854 get password(): string;2855 /**2856 * The **`password`** property of the URL interface is a string containing the password component of the URL. If the URL does not have a password, this property contains an empty string, "".2857 *2858 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)2859 */2860 set password(value: string);2861 /**2862 * The **`host`** property of the URL interface is a string containing the host, which is the hostname, and then, if the port of the URL is nonempty, a ":", followed by the port of the URL. If the URL does not have a hostname, this property contains an empty string, "".2863 *2864 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)2865 */2866 get host(): string;2867 /**2868 * The **`host`** property of the URL interface is a string containing the host, which is the hostname, and then, if the port of the URL is nonempty, a ":", followed by the port of the URL. If the URL does not have a hostname, this property contains an empty string, "".2869 *2870 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)2871 */2872 set host(value: string);2873 /**2874 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. If the URL does not have a hostname, this property contains an empty string, "". IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to IDN.2875 *2876 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)2877 */2878 get hostname(): string;2879 /**2880 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. If the URL does not have a hostname, this property contains an empty string, "". IPv4 and IPv6 addresses are normalized, such as stripping leading zeros, and domain names are converted to IDN.2881 *2882 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)2883 */2884 set hostname(value: string);2885 /**2886 * The **`port`** property of the URL interface is a string containing the port number of the URL. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, "".2887 *2888 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)2889 */2890 get port(): string;2891 /**2892 * The **`port`** property of the URL interface is a string containing the port number of the URL. If the port is the default for the protocol (80 for ws: and http:, 443 for wss: and https:, and 21 for ftp:), this property contains an empty string, "".2893 *2894 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)2895 */2896 set port(value: string);2897 /**2898 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. It is a string constructed from a list of path segments, each of which is prefixed by a / character.2899 *2900 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)2901 */2902 get pathname(): string;2903 /**2904 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. It is a string constructed from a list of path segments, each of which is prefixed by a / character.2905 *2906 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)2907 */2908 set pathname(value: string);2909 /**2910 * The **`search`** property of the URL interface is a search string, also called a query string, that is a string containing a "?" followed by the parameters of the URL. If the URL does not have a search query, this property contains an empty string, "".2911 *2912 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)2913 */2914 get search(): string;2915 /**2916 * The **`search`** property of the URL interface is a search string, also called a query string, that is a string containing a "?" followed by the parameters of the URL. If the URL does not have a search query, this property contains an empty string, "".2917 *2918 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)2919 */2920 set search(value: string);2921 /**2922 * The **`hash`** property of the URL interface is a string containing a "#" followed by the fragment identifier of the URL. If the URL does not have a fragment identifier, this property contains an empty string, "".2923 *2924 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)2925 */2926 get hash(): string;2927 /**2928 * The **`hash`** property of the URL interface is a string containing a "#" followed by the fragment identifier of the URL. If the URL does not have a fragment identifier, this property contains an empty string, "".2929 *2930 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)2931 */2932 set hash(value: string);2933 /**2934 * The **`searchParams`** read-only property of the URL interface returns a URLSearchParams object allowing access to the GET decoded query arguments contained in the URL.2935 *2936 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)2937 */2938 get searchParams(): URLSearchParams;2939 /**2940 * The **`toJSON()`** method of the URL interface returns a string containing a serialized version of the URL, although in practice it seems to have the same effect as URL.toString().2941 *2942 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)2943 */2944 toJSON(): string;2945 /*function toString() { [native code] }*/2946 toString(): string;2947 /**2948 * The **`URL.canParse()`** static method of the URL interface returns a boolean indicating whether or not an absolute URL, or a relative URL combined with a base URL, are parsable and valid.2949 *2950 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)2951 */2952 static canParse(url: string, base?: string): boolean;2953 /**2954 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.2955 *2956 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)2957 */2958 static parse(url: string, base?: string): URL | null;2959 /**2960 * The **`createObjectURL()`** static method of the URL interface creates a string containing a blob URL pointing to the object given in the parameter.2961 *2962 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)2963 */2964 static createObjectURL(object: File | Blob): string;2965 /**2966 * The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling URL.createObjectURL().2967 *2968 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)2969 */2970 static revokeObjectURL(object_url: string): void;2971}2972/**2973 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.2974 *2975 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)2976 */2977declare class URLSearchParams {2978 constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string));2979 /**2980 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.2981 *2982 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)2983 */2984 get size(): number;2985 /**2986 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.2987 *2988 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)2989 */2990 append(name: string, value: string): void;2991 /**2992 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.2993 *2994 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)2995 */2996 delete(name: string, value?: string): void;2997 /**2998 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.2999 *3000 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)3001 */3002 get(name: string): string | null;3003 /**3004 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.3005 *3006 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)3007 */3008 getAll(name: string): string[];3009 /**3010 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.3011 *3012 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)3013 */3014 has(name: string, value?: string): boolean;3015 /**3016 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value. If there were several matching values, this method deletes the others. If the search parameter doesn't exist, this method creates it.3017 *3018 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)3019 */3020 set(name: string, value: string): void;3021 /**3022 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns undefined. Key/value pairs are sorted by the values of the UTF-16 code units of the keys. This method uses a stable sorting algorithm (i.e., the relative order between key/value pairs with equal keys will be preserved).3023 *3024 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)3025 */3026 sort(): void;3027 entries(): IterableIterator<[3028 key: string,3029 value: string3030 ]>;3031 keys(): IterableIterator<string>;3032 values(): IterableIterator<string>;3033 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void;3034 /*function toString() { [native code] }*/3035 toString(): string;3036 [Symbol.iterator](): IterableIterator<[3037 key: string,3038 value: string3039 ]>;3040}3041/**3042 * The **`URLPattern`** interface of the URL Pattern API matches URLs or parts of URLs against a pattern. The pattern can contain capturing groups that extract parts of the matched URL.3043 *3044 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern)3045 */3046declare class URLPattern {3047 constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions);3048 /**3049 * The **`protocol`** read-only property of the URLPattern interface is a string containing the pattern used to match the protocol part of a URL.3050 *3051 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/protocol)3052 */3053 get protocol(): string;3054 /**3055 * The **`username`** read-only property of the URLPattern interface is a string containing the pattern used to match the username part of a URL.3056 *3057 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/username)3058 */3059 get username(): string;3060 /**3061 * The **`password`** read-only property of the URLPattern interface is a string containing the pattern used to match the password part of a URL.3062 *3063 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/password)3064 */3065 get password(): string;3066 /**3067 * The **`hostname`** read-only property of the URLPattern interface is a string containing the pattern used to match the hostname part of a URL.3068 *3069 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/hostname)3070 */3071 get hostname(): string;3072 /**3073 * The **`port`** read-only property of the URLPattern interface is a string containing the pattern used to match the port part of a URL.3074 *3075 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/port)3076 */3077 get port(): string;3078 /**3079 * The **`pathname`** read-only property of the URLPattern interface is a string containing the pattern used to match the pathname part of a URL.3080 *3081 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/pathname)3082 */3083 get pathname(): string;3084 /**3085 * The **`search`** read-only property of the URLPattern interface is a string containing the pattern used to match the search part of a URL.3086 *3087 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/search)3088 */3089 get search(): string;3090 /**3091 * The **`hash`** read-only property of the URLPattern interface is a string containing the pattern used to match the fragment part of a URL.3092 *3093 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/hash)3094 */3095 get hash(): string;3096 /**3097 * The **`hasRegExpGroups`** read-only property of the URLPattern interface is a boolean indicating whether or not any of the URLPattern components contain regular expression capturing groups.3098 *3099 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/hasRegExpGroups)3100 */3101 get hasRegExpGroups(): boolean;3102 /**3103 * The **`test()`** method of the URLPattern interface takes a URL string or object of URL parts, and returns a boolean indicating if the given input matches the current pattern.3104 *3105 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/test)3106 */3107 test(input?: (string | URLPatternInit), baseURL?: string): boolean;3108 /**3109 * The **`exec()`** method of the URLPattern interface takes a URL or object of URL parts, and returns either an object containing the results of matching the URL to the pattern, or null if the URL does not match the pattern.3110 *3111 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLPattern/exec)3112 */3113 exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null;3114}3115interface URLPatternInit {3116 protocol?: string;3117 username?: string;3118 password?: string;3119 hostname?: string;3120 port?: string;3121 pathname?: string;3122 search?: string;3123 hash?: string;3124 baseURL?: string;3125}3126interface URLPatternComponentResult {3127 input: string;3128 groups: Record<string, string>;3129}3130interface URLPatternResult {3131 inputs: (string | URLPatternInit)[];3132 protocol: URLPatternComponentResult;3133 username: URLPatternComponentResult;3134 password: URLPatternComponentResult;3135 hostname: URLPatternComponentResult;3136 port: URLPatternComponentResult;3137 pathname: URLPatternComponentResult;3138 search: URLPatternComponentResult;3139 hash: URLPatternComponentResult;3140}3141interface URLPatternOptions {3142 ignoreCase?: boolean;3143}3144/**3145 * A **`CloseEvent`** is sent to clients using WebSockets when the connection is closed. This is delivered to the listener indicated by the WebSocket object's onclose attribute.3146 *3147 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)3148 */3149declare class CloseEvent extends Event {3150 constructor(type: string, initializer?: CloseEventInit);3151 /**3152 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.3153 *3154 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)3155 */3156 readonly code: number;3157 /**3158 * The **`reason`** read-only property of the CloseEvent interface returns the WebSocket connection close reason the server gave for closing the connection; that is, a concise human-readable prose explanation for the closure.3159 *3160 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)3161 */3162 readonly reason: string;3163 /**3164 * The **`wasClean`** read-only property of the CloseEvent interface returns true if the connection closed cleanly.3165 *3166 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)3167 */3168 readonly wasClean: boolean;3169}3170interface CloseEventInit {3171 code?: number;3172 reason?: string;3173 wasClean?: boolean;3174}3175type WebSocketEventMap = {3176 close: CloseEvent;3177 message: MessageEvent;3178 open: Event;3179 error: ErrorEvent;3180};3181/**3182 * The **`WebSocket`** object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.3183 *3184 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)3185 */3186declare var WebSocket: {3187 prototype: WebSocket;3188 new (url: string, protocols?: (string[] | string)): WebSocket;3189 readonly READY_STATE_CONNECTING: number;3190 readonly CONNECTING: number;3191 readonly READY_STATE_OPEN: number;3192 readonly OPEN: number;3193 readonly READY_STATE_CLOSING: number;3194 readonly CLOSING: number;3195 readonly READY_STATE_CLOSED: number;3196 readonly CLOSED: number;3197};3198/**3199 * The **`WebSocket`** object provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.3200 *3201 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)3202 */3203interface WebSocket extends EventTarget<WebSocketEventMap> {3204 accept(options?: WebSocketAcceptOptions): void;3205 /**3206 * The **`WebSocket.send()`** method enqueues the specified data to be transmitted to the server over the WebSocket connection, increasing the value of bufferedAmount by the number of bytes needed to contain the data. If the data can't be sent (for example, because it needs to be buffered but the buffer is full), the socket is closed automatically. The browser will throw an exception if you call send() when the connection is in the CONNECTING state. If you call send() when the connection is in the CLOSING or CLOSED states, the browser will silently discard the data.3207 *3208 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)3209 */3210 send(message: (ArrayBuffer | ArrayBufferView) | string): void;3211 /**3212 * The **`WebSocket.close()`** method closes the WebSocket connection or connection attempt, if any. If the connection is already CLOSED, this method does nothing.3213 *3214 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)3215 */3216 close(code?: number, reason?: string): void;3217 serializeAttachment(attachment: any): void;3218 deserializeAttachment(): any | null;3219 /**3220 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.3221 *3222 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)3223 */3224 readyState: number;3225 /**3226 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.3227 *3228 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)3229 */3230 url: string | null;3231 /**3232 * The **`WebSocket.protocol`** read-only property returns the name of the sub-protocol the server selected; this will be one of the strings specified in the protocols parameter when creating the WebSocket object, or the empty string if no connection is established.3233 *3234 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)3235 */3236 protocol: string | null;3237 /**3238 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server. This is currently only the empty string or a list of extensions as negotiated by the connection.3239 *3240 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)3241 */3242 extensions: string | null;3243 /**3244 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.3245 *3246 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)3247 */3248 binaryType: "blob" | "arraybuffer";3249}3250interface WebSocketAcceptOptions {3251 /**3252 * When set to `true`, receiving a server-initiated WebSocket Close frame will not3253 * automatically send a reciprocal Close frame, leaving the connection in a half-open3254 * state. This is useful for proxying scenarios where you need to coordinate closing3255 * both sides independently. Defaults to `false` when the3256 * `no_web_socket_half_open_by_default` compatibility flag is enabled.3257 */3258 allowHalfOpen?: boolean;3259}3260declare const WebSocketPair: {3261 new (): {3262 0: WebSocket;3263 1: WebSocket;3264 };3265};3266interface SqlStorage {3267 exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>;3268 get databaseSize(): number;3269 Cursor: typeof SqlStorageCursor;3270 Statement: typeof SqlStorageStatement;3271}3272declare abstract class SqlStorageStatement {3273}3274type SqlStorageValue = ArrayBuffer | string | number | null;3275declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> {3276 next(): {3277 done?: false;3278 value: T;3279 } | {3280 done: true;3281 value?: never;3282 };3283 toArray(): T[];3284 one(): T;3285 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;3286 columnNames: string[];3287 get rowsRead(): number;3288 get rowsWritten(): number;3289 [Symbol.iterator](): IterableIterator<T>;3290}3291interface Socket {3292 get readable(): ReadableStream;3293 get writable(): WritableStream;3294 get closed(): Promise<void>;3295 get opened(): Promise<SocketInfo>;3296 get upgraded(): boolean;3297 get secureTransport(): "on" | "off" | "starttls";3298 close(): Promise<void>;3299 startTls(options?: TlsOptions): Socket;3300}3301interface SocketOptions {3302 secureTransport?: string;3303 allowHalfOpen: boolean;3304 highWaterMark?: (number | bigint);3305}3306interface SocketAddress {3307 hostname: string;3308 port: number;3309}3310interface TlsOptions {3311 expectedServerHostname?: string;3312}3313interface SocketInfo {3314 remoteAddress?: string;3315 localAddress?: string;3316}3317/**3318 * The **`EventSource`** interface is web content's interface to server-sent events.3319 *3320 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)3321 */3322declare class EventSource extends EventTarget {3323 constructor(url: string, init?: EventSourceEventSourceInit);3324 /**3325 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the EventSource.readyState attribute to 2 (closed).3326 *3327 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)3328 */3329 close(): void;3330 /**3331 * The **`url`** read-only property of the EventSource interface returns a string representing the URL of the source.3332 *3333 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)3334 */3335 get url(): string;3336 /**3337 * The **`withCredentials`** read-only property of the EventSource interface returns a boolean value indicating whether the EventSource object was instantiated with CORS credentials set.3338 *3339 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)3340 */3341 get withCredentials(): boolean;3342 /**3343 * The **`readyState`** read-only property of the EventSource interface returns a number representing the state of the connection.3344 *3345 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)3346 */3347 get readyState(): number;3348 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */3349 get onopen(): any | null;3350 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */3351 set onopen(value: any | null);3352 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */3353 get onmessage(): any | null;3354 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */3355 set onmessage(value: any | null);3356 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */3357 get onerror(): any | null;3358 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */3359 set onerror(value: any | null);3360 static readonly CONNECTING: number;3361 static readonly OPEN: number;3362 static readonly CLOSED: number;3363 static from(stream: ReadableStream): EventSource;3364}3365interface EventSourceEventSourceInit {3366 withCredentials?: boolean;3367 fetcher?: Fetcher;3368}3369interface ExecOutput {3370 readonly stdout: ArrayBuffer;3371 readonly stderr: ArrayBuffer;3372 readonly exitCode: number;3373}3374interface ContainerExecOptions {3375 cwd?: string;3376 env?: Record<string, string>;3377 user?: string;3378 signal?: AbortSignal;3379 pty?: boolean | ContainerExecPtyOptions;3380 stdin?: ReadableStream | "pipe";3381 stdout?: "pipe" | "ignore";3382 stderr?: "pipe" | "ignore" | "combined";3383}3384interface ContainerExecPtyOptions {3385 cols?: number;3386 rows?: number;3387}3388interface ExecProcess {3389 readonly stdin: WritableStream | null;3390 readonly stdout: ReadableStream | null;3391 readonly stderr: ReadableStream | null;3392 readonly pid: number;3393 readonly isPty: boolean;3394 readonly exitCode: Promise<number>;3395 output(): Promise<ExecOutput>;3396 kill(signal?: number): void;3397 resize(cols: number, rows: number): void;3398}3399interface Container {3400 get running(): boolean;3401 start(options?: ContainerStartupOptions): void;3402 monitor(): Promise<void>;3403 destroy(error?: any): Promise<void>;3404 signal(signo: number): void;3405 getTcpPort(port: number): Fetcher;3406 setInactivityTimeout(durationMs: number | bigint): Promise<void>;3407 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;3408 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;3409 snapshotDirectory(options: ContainerDirectorySnapshotOptions): Promise<ContainerDirectorySnapshot>;3410 snapshotContainer(options: ContainerSnapshotOptions): Promise<ContainerSnapshot>;3411 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;3412 exec(cmd: string[], options?: ContainerExecOptions): Promise<ExecProcess>;3413}3414interface ContainerDirectorySnapshot {3415 id: string;3416 size: number;3417 dir: string;3418 name?: string;3419}3420interface ContainerDirectorySnapshotOptions {3421 dir: string;3422 name?: string;3423}3424interface ContainerDirectorySnapshotRestoreParams {3425 snapshot: ContainerDirectorySnapshot;3426 mountPoint?: string;3427}3428interface ContainerSnapshot {3429 id: string;3430 size: number;3431 name?: string;3432}3433interface ContainerSnapshotRestoreParams {3434 id: string;3435}3436interface ContainerSnapshotOptions {3437 name?: string;3438}3439type ContainerStartupOptions = {3440 entrypoint?: string[];3441 enableInternet: boolean;3442 env?: Record<string, string>;3443 instance?: "lite" | "standard-1" | "standard-2" | "standard-3" | "standard-4" | ContainerStartResources;3444 labels?: Record<string, string>;3445 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];3446} & ({3447 image: string;3448 containerSnapshot?: never;3449} | {3450 image?: never;3451 containerSnapshot?: ContainerSnapshotRestoreParams;3452});3453interface ContainerStartResources {3454 vcpu: number;3455 memoryMib: number;3456 diskMb: number;3457}3458/**3459 * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.3460 *3461 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)3462 */3463declare abstract class MessagePort extends EventTarget {3464 /**3465 * The **`postMessage()`** method of the MessagePort interface sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.3466 *3467 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)3468 */3469 postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void;3470 /**3471 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. This stops the flow of messages to that port.3472 *3473 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)3474 */3475 close(): void;3476 /**3477 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. This method is only needed when using EventTarget.addEventListener; it is implied when using onmessage.3478 *3479 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)3480 */3481 start(): void;3482 get onmessage(): any | null;3483 set onmessage(value: any | null);3484}3485/**3486 * The **`MessageChannel`** interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.3487 *3488 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)3489 */3490declare class MessageChannel {3491 constructor();3492 /**3493 * The **`port1`** read-only property of the MessageChannel interface returns the first port of the message channel — the port attached to the context that originated the channel.3494 *3495 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)3496 */3497 readonly port1: MessagePort;3498 /**3499 * The **`port2`** read-only property of the MessageChannel interface returns the second port of the message channel — the port attached to the context at the other end of the channel, which the message is initially sent to.3500 *3501 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)3502 */3503 readonly port2: MessagePort;3504}3505interface MessagePortPostMessageOptions {3506 transfer?: any[];3507}3508type LoopbackForExport<T extends (new (...args: any[]) => Rpc.EntrypointBranded) | ExportedHandler<any, any, any> | undefined = undefined> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded ? LoopbackServiceStub<InstanceType<T>> : T extends new (...args: any[]) => Rpc.DurableObjectBranded ? LoopbackDurableObjectClass<InstanceType<T>> : T extends ExportedHandler<any, any, any> ? LoopbackServiceStub<undefined> : undefined;3509type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: {3510 props?: Props;3511}) => Fetcher<T> : (opts: {3512 props?: any;3513}) => Fetcher<T>);3514type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: {3515 props?: Props;3516}) => DurableObjectClass<T> : (opts: {3517 props?: any;3518}) => DurableObjectClass<T>);3519interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {3520}3521interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {3522}3523interface SyncKvStorage {3524 get<T = unknown>(key: string): T | undefined;3525 list<T = unknown>(options?: SyncKvListOptions): Iterable<[3526 string,3527 T3528 ]>;3529 put<T>(key: string, value: T): void;3530 delete(key: string): boolean;3531}3532interface SyncKvListOptions {3533 start?: string;3534 startAfter?: string;3535 end?: string;3536 prefix?: string;3537 reverse?: boolean;3538 limit?: number;3539}3540interface WorkerStub {3541 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>;3542 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): DurableObjectClass<T>;3543}3544interface WorkerStubEntrypointOptions {3545 props?: any;3546 limits?: workerdResourceLimits;3547}3548interface WorkerLoader {3549 get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub;3550 load(code: WorkerLoaderWorkerCode): WorkerStub;3551}3552interface WorkerLoaderModule {3553 js?: string;3554 cjs?: string;3555 text?: string;3556 data?: ArrayBuffer;3557 json?: any;3558 py?: string;3559 wasm?: ArrayBuffer;3560}3561interface WorkerLoaderWorkerCode {3562 compatibilityDate: string;3563 compatibilityFlags?: string[];3564 allowExperimental?: boolean;3565 limits?: workerdResourceLimits;3566 mainModule: string;3567 modules: Record<string, WorkerLoaderModule | string>;3568 env?: any;3569 globalOutbound?: (Fetcher | null);3570 tails?: Fetcher[];3571 streamingTails?: Fetcher[];3572}3573interface workerdResourceLimits {3574 cpuMs?: number;3575 subRequests?: number;3576}3577/**3578* The Workers runtime supports a subset of the Performance API, used to measure timing and performance,3579* as well as timing of subrequests and other operations.3580*3581* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)3582*/3583declare abstract class Performance {3584 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */3585 get timeOrigin(): number;3586 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */3587 now(): number;3588 /**3589 * The **`toJSON()`** method of the Performance interface is a serializer; it returns a JSON representation of the Performance object.3590 *3591 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)3592 */3593 toJSON(): object;3594}3595interface Tracing {3596 enterSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;3597 startActiveSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;3598 startSpan(name: string): Span;3599 Span: typeof Span;3600}3601declare abstract class Span {3602 get isTraced(): boolean;3603 setAttribute(key: string, value: boolean | number | string): this;3604 setAttributes(attributes: Record<string, boolean | number | string | undefined>): this;3605 end(): void;3606}3607/**3608 * Represents the identity of a user authenticated via Cloudflare Access.3609 * This matches the result of calling /cdn-cgi/access/get-identity.3610 *3611 * The exact structure of the returned object depends on the identity provider3612 * configuration for the Access application. The fields below represent commonly3613 * available properties, but additional provider-specific fields may be present.3614 */3615interface CloudflareAccessIdentity extends Record<string, unknown> {3616 /** The user's email address, if available from the identity provider. */3617 email?: string;3618 /** The user's display name. */3619 name?: string;3620 /** The user's unique identifier. */3621 user_uuid?: string;3622 /** The Cloudflare account ID. */3623 account_id?: string;3624 /** Login timestamp (Unix epoch seconds). */3625 iat?: number;3626 /** The user's IP address at authentication time. */3627 ip?: string;3628 /** Authentication methods used (e.g., "pwd"). */3629 amr?: string[];3630 /** Identity provider information. */3631 idp?: {3632 id: string;3633 type: string;3634 };3635 /** Geographic information about where the user authenticated. */3636 geo?: {3637 country: string;3638 };3639 /** Group memberships from the identity provider. */3640 groups?: Array<{3641 id: string;3642 name: string;3643 email?: string;3644 }>;3645 /** Device posture check results, keyed by check ID. */3646 devicePosture?: Record<string, unknown>;3647 /** True if the user connected via Cloudflare WARP. */3648 is_warp?: boolean;3649 /** True if the user is authenticated via Cloudflare Gateway. */3650 is_gateway?: boolean;3651}3652// ============================================================================3653// Agent Memory3654//3655// Public type surface for user Workers binding to an Agent Memory namespace.3656// ============================================================================3657/** Memory type — every memory is classified into exactly one. */3658type AgentMemoryMemoryType = "fact" | "event" | "instruction" | "task";3659/** Search intensity for recall. */3660type AgentMemoryThinkingLevel = "low" | "medium" | "high";3661/** Response verbosity for recall. */3662type AgentMemoryResponseLength = "short" | "medium" | "long";3663/** A conversation message passed to ingest(). */3664interface AgentMemoryMessage {3665 role: "system" | "user" | "assistant";3666 content: string;3667 /** Optional message timestamp. */3668 timestamp?: Date;3669}3670/** Raw memory content passed to remember(). */3671interface AgentMemoryIncomingMemory {3672 /** Raw memory content. The service classifies and summarizes automatically. */3673 content: string;3674 /** Optional session identifier to associate with this memory. */3675 sessionId?: string | null | undefined;3676}3677/** A stored memory returned from remember(), get(), and delete(). */3678interface AgentMemoryMemory {3679 /** Memory ID. */3680 id: string;3681 /** Memory type. */3682 type: AgentMemoryMemoryType;3683 /** Text summary. */3684 summary: string;3685 /** Memory text. */3686 content: string;3687 /** Session that created this memory. */3688 sessionId: string | null;3689 /** Memory creation time. */3690 createdAt: Date;3691 /** Memory last-update time. */3692 updatedAt: Date;3693}3694/** Single entry in a list() response. Same shape as Memory minus full content. */3695type AgentMemoryMemoryListEntry = Omit<AgentMemoryMemory, "content">;3696/** A scored memory candidate in a recall result. */3697interface AgentMemoryScoredCandidate {3698 /** Candidate ID. */3699 id: string;3700 /** Text summary. */3701 summary: string;3702 /** Session that created this candidate, when known. */3703 sessionId: string | null;3704 /** Relevance score (higher is better). Comparable only within a single query. */3705 score: number;3706}3707/** Options for the ingest() method. */3708interface AgentMemoryIngestOptions {3709 /** Session identifier to associate with memories created during ingestion. */3710 sessionId?: string | null | undefined;3711}3712/** Options for the getSummary() method. */3713interface AgentMemoryGetSummaryOptions {3714 /** Session identifier to retrieve session summary for. */3715 sessionId?: string | null | undefined;3716}3717/** Response from the getSummary() method. */3718interface AgentMemoryGetSummaryResponse {3719 /** Markdown summary. */3720 summary: string;3721}3722/**3723 * Options for the recall() method.3724 *3725 * `referenceDate` accepts a Date object, an ISO-8601 date string3726 * (YYYY-MM-DD), or a full ISO-8601 datetime string. When provided, this3727 * date is used as "today" for resolving relative time references3728 * ("how many days ago", "last week") instead of the server's wall-clock time.3729 */3730interface AgentMemoryRecallOptions {3731 /** Recall intensity: "low" (default), "medium", or "high". */3732 thinkingLevel?: AgentMemoryThinkingLevel;3733 /** Response verbosity: "short", "medium" (default), or "long". */3734 responseLength?: AgentMemoryResponseLength;3735 /** Temporal anchor for date arithmetic. */3736 referenceDate?: Date | string;3737}3738/** Response from the recall() method. */3739interface AgentMemoryRecallResult {3740 /** Number of memories retrieved. */3741 count: number;3742 /** LLM-generated answer synthesizing the matching memories. */3743 answer: string;3744 /** Matching memories ranked by relevance. */3745 candidates: AgentMemoryScoredCandidate[];3746}3747/**3748 * Options for the list() method.3749 *3750 * `cursor` is the opaque continuation token returned by the previous page;3751 * pass it back unchanged to fetch the next page. `sessionId` and `type`3752 * are exact-match filters; combining them is allowed.3753 */3754interface AgentMemoryListMemoriesOptions {3755 /** Maximum number of memories to return. Default 20, max 500. */3756 limit?: number;3757 /** Opaque cursor from a previous page. */3758 cursor?: string;3759 /** Exact-match session filter. */3760 sessionId?: string;3761 /** Exact-match memory-type filter. */3762 type?: AgentMemoryMemoryType;3763}3764/** Response from the list() method. */3765interface AgentMemoryListMemoriesResult {3766 memories: AgentMemoryMemoryListEntry[];3767 /** Continuation cursor; absent when this page exhausted the result set. */3768 cursor?: string;3769}3770/**3771 * A single Agent Memory profile, scoped to a profile name.3772 *3773 * Returned by {@link AgentMemoryNamespace.getProfile}.3774 */3775declare abstract class AgentMemoryProfile {3776 /**3777 * Retrieve a memory by ID.3778 *3779 * @param memoryId - ULID of the memory to retrieve.3780 * @throws if the memory does not exist.3781 */3782 get(memoryId: string): Promise<AgentMemoryMemory>;3783 /**3784 * Delete a memory by ID.3785 *3786 * Removes the memory and any source messages linked by the memory's3787 * source message IDs.3788 *3789 * @param memoryId - ULID of the memory to delete.3790 * @throws if the memory does not exist.3791 */3792 delete(memoryId: string): Promise<AgentMemoryMemory>;3793 /**3794 * Store a memory in this profile. The content is automatically classified,3795 * summarized, and indexed.3796 *3797 * @param memory - Raw memory content to persist.3798 */3799 remember(memory: AgentMemoryIncomingMemory): Promise<AgentMemoryMemory>;3800 /**3801 * Extract memories from a conversation.3802 *3803 * @param messages - Conversation messages to extract memories from.3804 * @param options - Optional ingest options.3805 */3806 ingest(messages: Iterable<AgentMemoryMessage>, options?: AgentMemoryIngestOptions): Promise<void>;3807 /**3808 * Get a profile summary.3809 *3810 * @param options - Optional getSummary options.3811 */3812 getSummary(options?: AgentMemoryGetSummaryOptions): Promise<AgentMemoryGetSummaryResponse>;3813 /**3814 * Recall memories in this profile.3815 *3816 * @param query - Recall query matched against memory content and keywords.3817 * @param options - Optional recall parameters.3818 * @returns Matching memories with relevance scores and a synthesized answer.3819 */3820 recall(query: string, options?: AgentMemoryRecallOptions): Promise<AgentMemoryRecallResult>;3821 /**3822 * List active memories in this profile.3823 *3824 * Returns a paginated, filterable view of stored memories. Superseded3825 * versions are excluded. Use the returned `cursor` (when present) to3826 * fetch the next page.3827 *3828 * @param options - Optional pagination and filter options.3829 */3830 list(options?: AgentMemoryListMemoriesOptions): Promise<AgentMemoryListMemoriesResult>;3831 /**3832 * Soft-delete every memory and message in this profile that is tagged3833 * with `sessionId`.3834 *3835 * Idempotent: deleting a sessionId that has no rows is a no-op.3836 *3837 * @param sessionId - Session to delete.3838 */3839 deleteSession(sessionId: string): Promise<void>;3840}3841/**3842 * Namespace-level Agent Memory binding.3843 *3844 * Used as the type of an `env.MEMORY`-style binding backed by the Agent3845 * Memory product.3846 *3847 * @example3848 * ```ts3849 * export default {3850 * async fetch(_request: Request, env: Env): Promise<Response> {3851 * const profile = await env.MEMORY.getProfile("wrangler-e2e");3852 * const summary = await profile.getSummary();3853 * return Response.json(summary);3854 * },3855 * };3856 * ```3857 */3858declare abstract class AgentMemoryNamespace {3859 /**3860 * Get a memory profile by name. Profiles are isolated by namespace and3861 * addressed by a compound key (namespaceId:profileName).3862 *3863 * @param profileName - Profile name (validated against naming rules).3864 * @returns RPC target for interacting with the profile.3865 */3866 getProfile(profileName: string): Promise<AgentMemoryProfile>;3867 /**3868 * Soft-delete a profile and schedule deferred purge. Marks all3869 * memories and messages as deleted.3870 *3871 * @param profileName - Name of the profile to delete.3872 */3873 deleteProfile(profileName: string): Promise<void>;3874}3875// ============ AI Search Error Interfaces ============3876interface AiSearchInternalError extends Error {3877}3878interface AiSearchNotFoundError extends Error {3879}3880// ============ AI Search Common Types ============3881/** A single message in a conversation-style search or chat request. */3882type AiSearchMessage = {3883 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';3884 content: string | null;3885};3886/**3887 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.3888 * Contains retrieval, query rewrite, reranking, and cache sub-options.3889 */3890type AiSearchOptions = {3891 retrieval?: {3892 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */3893 retrieval_type?: 'vector' | 'keyword' | 'hybrid';3894 /** Fusion method for combining vector + keyword results. */3895 fusion_method?: 'max' | 'rrf';3896 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */3897 keyword_match_mode?: 'and' | 'or';3898 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */3899 match_threshold?: number;3900 /** Maximum number of results to return (1-50). Default 10. */3901 max_num_results?: number;3902 /** Vectorize metadata filters applied to the search. */3903 filters?: VectorizeVectorMetadataFilter;3904 /** Number of surrounding chunks to include for context (0-3). Default 0. */3905 context_expansion?: number;3906 /** If true, return only item metadata without chunk text. */3907 metadata_only?: boolean;3908 /** If true (default), return empty results on retrieval failure instead of throwing. */3909 return_on_failure?: boolean;3910 /** Boost results by metadata field values. Max 3 entries. */3911 boost_by?: Array<{3912 field: string;3913 direction?: 'asc' | 'desc' | 'exists' | 'not_exists';3914 }>;3915 [key: string]: unknown;3916 };3917 query_rewrite?: {3918 enabled?: boolean;3919 model?: string;3920 rewrite_prompt?: string;3921 [key: string]: unknown;3922 };3923 reranking?: {3924 enabled?: boolean;3925 model?: string;3926 /** Match threshold (0-1, default 0.4) */3927 match_threshold?: number;3928 [key: string]: unknown;3929 };3930 cache?: {3931 enabled?: boolean;3932 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes';3933 };3934 [key: string]: unknown;3935};3936// ============ AI Search Request Types ============3937/**3938 * Request body for single-instance search.3939 * Exactly one of `query` or `messages` must be provided.3940 */3941type AiSearchSearchRequest = {3942 /** Simple query string. */3943 query: string;3944 messages?: never;3945 ai_search_options?: AiSearchOptions;3946} | {3947 query?: never;3948 /** Conversation-style input. At least one user message with non-empty content is required. */3949 messages: AiSearchMessage[];3950 ai_search_options?: AiSearchOptions;3951};3952type AiSearchChatCompletionsRequest = {3953 messages: AiSearchMessage[];3954 model?: string;3955 stream?: boolean;3956 ai_search_options?: AiSearchOptions;3957 [key: string]: unknown;3958};3959// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============3960/** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */3961type AiSearchMultiSearchOptions = AiSearchOptions & {3962 /** Instance IDs to search across (1-10). */3963 instance_ids: string[];3964};3965/**3966 * Request for searching across multiple instances within a namespace.3967 * `ai_search_options` is required and must include `instance_ids`.3968 * Exactly one of `query` or `messages` must be provided.3969 */3970type AiSearchMultiSearchRequest = {3971 /** Simple query string. */3972 query: string;3973 messages?: never;3974 ai_search_options: AiSearchMultiSearchOptions;3975} | {3976 query?: never;3977 /** Conversation-style input. */3978 messages: AiSearchMessage[];3979 ai_search_options: AiSearchMultiSearchOptions;3980};3981/** A search result chunk tagged with the instance it originated from. */3982type AiSearchMultiSearchChunk = AiSearchSearchResponse['chunks'][number] & {3983 instance_id: string;3984};3985/** Describes a per-instance error during a multi-instance operation. */3986type AiSearchMultiSearchError = {3987 instance_id: string;3988 message: string;3989};3990/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */3991type AiSearchMultiSearchResponse = {3992 search_query: string;3993 chunks: AiSearchMultiSearchChunk[];3994 errors?: AiSearchMultiSearchError[];3995};3996/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */3997type AiSearchMultiChatCompletionsRequest = Omit<AiSearchChatCompletionsRequest, 'ai_search_options'> & {3998 ai_search_options: AiSearchMultiSearchOptions;3999};4000/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */4001type AiSearchMultiChatCompletionsResponse = Omit<AiSearchChatCompletionsResponse, 'chunks'> & {4002 chunks: AiSearchMultiSearchChunk[];4003 errors?: AiSearchMultiSearchError[];4004};4005// ============ AI Search Response Types ============4006type AiSearchSearchResponse = {4007 search_query: string;4008 chunks: Array<{4009 id: string;4010 type: string;4011 /** Match score (0-1) */4012 score: number;4013 text: string;4014 item: {4015 timestamp?: number;4016 key: string;4017 metadata?: Record<string, unknown>;4018 };4019 scoring_details?: {4020 /** Keyword match score (0-1) */4021 keyword_score?: number;4022 /** Vector similarity score (0-1) */4023 vector_score?: number;4024 /** Keyword rank position */4025 keyword_rank?: number;4026 /** Vector rank position */4027 vector_rank?: number;4028 /** Reranking model score */4029 reranking_score?: number;4030 /** Fusion method used to combine results */4031 fusion_method?: 'rrf' | 'max';4032 [key: string]: unknown;4033 };4034 }>;4035};4036type AiSearchChatCompletionsResponse = {4037 id?: string;4038 object?: string;4039 model?: string;4040 choices: Array<{4041 index?: number;4042 message: {4043 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool';4044 content: string | null;4045 [key: string]: unknown;4046 };4047 [key: string]: unknown;4048 }>;4049 chunks: AiSearchSearchResponse['chunks'];4050 [key: string]: unknown;4051};4052type AiSearchStatsResponse = {4053 queued?: number;4054 running?: number;4055 completed?: number;4056 error?: number;4057 skipped?: number;4058 outdated?: number;4059 last_activity?: string;4060 /** Storage engine statistics. */4061 engine?: {4062 vectorize?: {4063 vectorsCount: number;4064 dimensions: number;4065 };4066 r2?: {4067 payloadSizeBytes: number;4068 metadataSizeBytes: number;4069 objectCount: number;4070 };4071 };4072};4073// ============ AI Search Instance Info Types ============4074type AiSearchInstanceInfo = {4075 id: string;4076 type?: 'r2' | 'web-crawler' | string;4077 source?: string;4078 source_params?: unknown;4079 paused?: boolean;4080 status?: string;4081 namespace?: string;4082 created_at?: string;4083 modified_at?: string;4084 token_id?: string;4085 ai_gateway_id?: string;4086 rewrite_query?: boolean;4087 reranking?: boolean;4088 embedding_model?: string;4089 ai_search_model?: string;4090 rewrite_model?: string;4091 reranking_model?: string;4092 /** @deprecated Use index_method instead. */4093 hybrid_search_enabled?: boolean;4094 /** Controls which storage backends are active. */4095 index_method?: {4096 vector?: boolean;4097 keyword?: boolean;4098 };4099 /** Fusion method for combining vector and keyword results. */4100 fusion_method?: 'max' | 'rrf';4101 indexing_options?: {4102 keyword_tokenizer?: 'porter' | 'trigram';4103 } | null;4104 retrieval_options?: {4105 keyword_match_mode?: 'and' | 'or';4106 boost_by?: Array<{4107 field: string;4108 direction?: 'asc' | 'desc' | 'exists' | 'not_exists';4109 }>;4110 } | null;4111 chunk?: boolean;4112 chunk_size?: number;4113 chunk_overlap?: number;4114 score_threshold?: number;4115 max_num_results?: number;4116 cache?: boolean;4117 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes';4118 custom_metadata?: Array<{4119 field_name: string;4120 data_type: 'text' | 'number' | 'boolean' | 'datetime';4121 }>;4122 /** Sync interval in seconds. */4123 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;4124 metadata?: Record<string, unknown>;4125 [key: string]: unknown;4126};4127/** Pagination, search, and ordering parameters for listing instances within a namespace. */4128type AiSearchListInstancesParams = {4129 page?: number;4130 per_page?: number;4131 /** Search instances by ID. */4132 search?: string;4133 /** Field to sort by. */4134 order_by?: 'created_at';4135 /** Sort direction. */4136 order_by_direction?: 'asc' | 'desc';4137};4138type AiSearchListResponse = {4139 result: AiSearchInstanceInfo[];4140 result_info?: {4141 count: number;4142 page: number;4143 per_page: number;4144 total_count: number;4145 };4146};4147// ============ AI Search Config Types ============4148type AiSearchConfig = {4149 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */4150 id: string;4151 /** Instance type. Omit to create with built-in storage. */4152 type?: 'r2' | 'web-crawler' | string;4153 /** Source URL (required for web-crawler type). */4154 source?: string;4155 source_params?: unknown;4156 /** Token ID (UUID format) */4157 token_id?: string;4158 ai_gateway_id?: string;4159 /** Enable query rewriting (default false) */4160 rewrite_query?: boolean;4161 /** Enable reranking (default false) */4162 reranking?: boolean;4163 embedding_model?: string;4164 ai_search_model?: string;4165 rewrite_model?: string;4166 reranking_model?: string;4167 /** @deprecated Use index_method instead. */4168 hybrid_search_enabled?: boolean;4169 /** Controls which storage backends are used during indexing. Defaults to vector-only. */4170 index_method?: {4171 vector?: boolean;4172 keyword?: boolean;4173 };4174 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */4175 fusion_method?: 'max' | 'rrf';4176 indexing_options?: {4177 keyword_tokenizer?: 'porter' | 'trigram';4178 } | null;4179 retrieval_options?: {4180 keyword_match_mode?: 'and' | 'or';4181 boost_by?: Array<{4182 field: string;4183 direction?: 'asc' | 'desc' | 'exists' | 'not_exists';4184 }>;4185 } | null;4186 chunk?: boolean;4187 chunk_size?: number;4188 chunk_overlap?: number;4189 /** Minimum similarity score (0-1) for a result to be included. */4190 score_threshold?: number;4191 max_num_results?: number;4192 cache?: boolean;4193 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */4194 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes';4195 custom_metadata?: Array<{4196 field_name: string;4197 data_type: 'text' | 'number' | 'boolean' | 'datetime';4198 }>;4199 namespace?: string;4200 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */4201 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;4202 metadata?: Record<string, unknown>;4203 [key: string]: unknown;4204};4205// ============ AI Search Item Types ============4206type AiSearchItemInfo = {4207 id: string;4208 key: string;4209 status: 'completed' | 'error' | 'skipped' | 'queued' | 'running' | 'outdated';4210 next_action?: 'INDEX' | 'DELETE' | null;4211 error?: string;4212 checksum?: string;4213 namespace?: string;4214 chunks_count?: number | null;4215 file_size?: number | null;4216 source_id?: string | null;4217 last_seen_at?: string;4218 created_at?: string;4219 metadata?: Record<string, unknown>;4220 [key: string]: unknown;4221};4222type AiSearchItemContentResult = {4223 body: ReadableStream;4224 contentType: string;4225 filename: string;4226 size: number;4227};4228type AiSearchUploadItemOptions = {4229 metadata?: Record<string, unknown>;4230};4231type AiSearchListItemsParams = {4232 page?: number;4233 per_page?: number;4234 /** Search items by key name. */4235 search?: string;4236 /** Sort order for results. */4237 sort_by?: 'status' | 'modified_at';4238 /** Filter items by processing status. */4239 status?: 'queued' | 'running' | 'completed' | 'error' | 'skipped' | 'outdated';4240 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */4241 source?: string;4242 /** JSON-encoded Vectorize filter for metadata filtering. */4243 metadata_filter?: string;4244 /** Filter items by their unique ID. Returns at most one item. */4245 item_id?: string;4246 /**4247 * Filter items by their exact key (object key / filename). Keys are unique4248 * per source, so combine with `source` to disambiguate across data sources.4249 */4250 key?: string;4251};4252type AiSearchListItemsResponse = {4253 result: AiSearchItemInfo[];4254 result_info?: {4255 count: number;4256 page: number;4257 per_page: number;4258 total_count: number;4259 };4260};4261// ============ AI Search Item Logs Types ============4262type AiSearchItemLogsParams = {4263 /** Maximum number of log entries to return (1-100, default 50). */4264 limit?: number;4265 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */4266 cursor?: string;4267};4268type AiSearchItemLog = {4269 timestamp: string;4270 action: string;4271 message: string;4272 fileKey?: string;4273 chunkCount?: number;4274 processingTimeMs?: number;4275 errorType?: string;4276};4277/** Paginated response for item processing logs (cursor-based). */4278type AiSearchItemLogsResponse = {4279 result: AiSearchItemLog[];4280 result_info: {4281 count: number;4282 per_page: number;4283 cursor: string | null;4284 truncated: boolean;4285 };4286};4287// ============ AI Search Item Chunks Types ============4288type AiSearchItemChunksParams = {4289 /** Maximum number of chunks to return (1-100, default 20). */4290 limit?: number;4291 /** Offset into the chunks list (default 0). */4292 offset?: number;4293};4294/** A single indexed chunk belonging to an item, including its text content and byte range. */4295type AiSearchItemChunk = {4296 id: string;4297 text: string;4298 start_byte: number;4299 end_byte: number;4300 item?: {4301 timestamp?: number;4302 key: string;4303 metadata?: Record<string, unknown>;4304 };4305};4306/** Paginated response for item chunks (offset-based). */4307type AiSearchItemChunksResponse = {4308 result: AiSearchItemChunk[];4309 result_info: {4310 count: number;4311 total: number;4312 limit: number;4313 offset: number;4314 };4315};4316// ============ AI Search Job Types ============4317type AiSearchJobInfo = {4318 id: string;4319 source: 'user' | 'schedule';4320 description?: string;4321 last_seen_at?: string;4322 started_at?: string;4323 ended_at?: string;4324 end_reason?: string;4325};4326type AiSearchJobLog = {4327 id: number;4328 message: string;4329 message_type: number;4330 created_at: number;4331};4332type AiSearchCreateJobParams = {4333 description?: string;4334};4335type AiSearchListJobsParams = {4336 page?: number;4337 per_page?: number;4338};4339type AiSearchListJobsResponse = {4340 result: AiSearchJobInfo[];4341 result_info?: {4342 count: number;4343 page: number;4344 per_page: number;4345 total_count: number;4346 };4347};4348type AiSearchJobLogsParams = {4349 page?: number;4350 per_page?: number;4351};4352type AiSearchJobLogsResponse = {4353 result: AiSearchJobLog[];4354 result_info?: {4355 count: number;4356 page: number;4357 per_page: number;4358 total_count: number;4359 };4360};4361// ============ AI Search Sub-Service Classes ============4362/**4363 * Single item service for an AI Search instance.4364 * Provides info, download, sync, logs, and chunks operations on a specific item.4365 */4366declare abstract class AiSearchItem {4367 /** Get metadata about this item. */4368 info(): Promise<AiSearchItemInfo>;4369 /**4370 * Download the item's content.4371 * @returns Object with body stream, content type, filename, and size.4372 */4373 download(): Promise<AiSearchItemContentResult>;4374 /**4375 * Trigger re-indexing of this item.4376 * @returns The updated item info.4377 */4378 sync(): Promise<AiSearchItemInfo>;4379 /**4380 * Retrieve processing logs for this item (cursor-based pagination).4381 * @param params Optional pagination parameters (limit, cursor).4382 * @returns Paginated log entries for this item.4383 */4384 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;4385 /**4386 * List indexed chunks for this item (offset-based pagination).4387 * @param params Optional pagination parameters (limit, offset).4388 * @returns Paginated chunk entries for this item.4389 */4390 chunks(params?: AiSearchItemChunksParams): Promise<AiSearchItemChunksResponse>;4391}4392/**4393 * Items collection service for an AI Search instance.4394 * Provides list, upload, and access to individual items.4395 */4396declare abstract class AiSearchItems {4397 /** List items in this instance. */4398 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;4399 /**4400 * Upload a file as an item. Behaves as an upsert: if an item with the same4401 * filename already exists, it is overwritten and re-indexed.4402 * @param name Filename for the uploaded item.4403 * @param content File content as a ReadableStream, Blob, or string.4404 * @param options Optional metadata to attach to the item.4405 * @returns The created item info.4406 */4407 upload(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>;4408 /**4409 * Upload a file and poll until processing completes.4410 * Behaves as an upsert: if an item with the same filename already exists,4411 * it is overwritten and re-indexed.4412 * @param name Filename for the uploaded item.4413 * @param content File content as a ReadableStream, Blob, or string.4414 * @param options Optional metadata and polling configuration.4415 * @returns The item info after processing completes (or timeout).4416 */4417 uploadAndPoll(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions & {4418 /** Polling interval in milliseconds (default 1000). */4419 pollIntervalMs?: number;4420 /** Maximum time to wait in milliseconds (default 30000). */4421 timeoutMs?: number;4422 }): Promise<AiSearchItemInfo>;4423 /**4424 * Get an item by ID.4425 * @param itemId The item identifier.4426 * @returns Item service for info, download, sync, logs, and chunks operations.4427 */4428 get(itemId: string): AiSearchItem;4429 /**4430 * Delete an item from the instance.4431 * @param itemId The item identifier.4432 */4433 delete(itemId: string): Promise<void>;4434}4435/**4436 * Single job service for an AI Search instance.4437 * Provides info, logs, and cancel operations for a specific job.4438 */4439declare abstract class AiSearchJob {4440 /** Get metadata about this job. */4441 info(): Promise<AiSearchJobInfo>;4442 /** Get logs for this job. */4443 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;4444 /**4445 * Cancel a running job.4446 * @returns The updated job info.4447 * @throws AiSearchNotFoundError if the job does not exist.4448 */4449 cancel(): Promise<AiSearchJobInfo>;4450}4451/**4452 * Jobs collection service for an AI Search instance.4453 * Provides list, create, and access to individual jobs.4454 */4455declare abstract class AiSearchJobs {4456 /** List jobs for this instance. */4457 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;4458 /**4459 * Create a new indexing job.4460 * @param params Optional job parameters.4461 * @returns The created job info.4462 */4463 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;4464 /**4465 * Get a job by ID.4466 * @param jobId The job identifier.4467 * @returns Job service for info, logs, and cancel operations.4468 */4469 get(jobId: string): AiSearchJob;4470}4471// ============ AI Search Binding Classes ============4472/**4473 * Instance-level AI Search service.4474 *4475 * Used as:4476 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)4477 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)4478 *4479 * Provides search, chat, update, stats, items, and jobs operations.4480 *4481 * @example4482 * ```ts4483 * // Via namespace binding4484 * const instance = env.AI_SEARCH.get("blog");4485 * const results = await instance.search({4486 * query: "How does caching work?",4487 * });4488 *4489 * // Via single instance binding4490 * const results = await env.BLOG_SEARCH.search({4491 * messages: [{ role: "user", content: "How does caching work?" }],4492 * });4493 * ```4494 */4495declare abstract class AiSearchInstance {4496 /**4497 * Search the AI Search instance for relevant chunks.4498 * @param params Search request with query or messages and optional AI search options.4499 * @returns Search response with matching chunks and search query.4500 */4501 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;4502 /**4503 * Generate chat completions with AI Search context (streaming).4504 * @param params Chat completions request with stream: true.4505 * @returns ReadableStream of server-sent events.4506 */4507 chatCompletions(params: AiSearchChatCompletionsRequest & {4508 stream: true;4509 }): Promise<ReadableStream>;4510 /**4511 * Generate chat completions with AI Search context.4512 * @param params Chat completions request.4513 * @returns Chat completion response with choices and RAG chunks.4514 */4515 chatCompletions(params: AiSearchChatCompletionsRequest): Promise<AiSearchChatCompletionsResponse>;4516 /**4517 * Update the instance configuration.4518 * @param config Partial configuration to update.4519 * @returns Updated instance info.4520 */4521 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;4522 /** Get metadata about this instance. */4523 info(): Promise<AiSearchInstanceInfo>;4524 /**4525 * Get instance statistics (item count, indexing status, etc.).4526 * @returns Statistics with counts per status, last activity time, and engine details.4527 */4528 stats(): Promise<AiSearchStatsResponse>;4529 /** Items collection — list, upload, and manage items in this instance. */4530 get items(): AiSearchItems;4531 /** Jobs collection — list, create, and inspect indexing jobs. */4532 get jobs(): AiSearchJobs;4533}4534/**4535 * Namespace-level AI Search service.4536 *4537 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).4538 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,4539 * and multi-instance search/chat operations.4540 *4541 * @example4542 * ```ts4543 * // Access an instance within the namespace4544 * const blog = env.AI_SEARCH.get("blog");4545 * const results = await blog.search({ query: "How does caching work?" });4546 *4547 * // List all instances in the namespace4548 * const instances = await env.AI_SEARCH.list();4549 *4550 * // Create a new instance with built-in storage4551 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });4552 *4553 * // Upload items into the instance4554 * await tenant.items.upload("doc.pdf", fileContent);4555 *4556 * // Search across multiple instances4557 * const multi = await env.AI_SEARCH.search({4558 * query: "caching",4559 * ai_search_options: { instance_ids: ["blog", "docs"] },4560 * });4561 *4562 * // Delete an instance4563 * await env.AI_SEARCH.delete("tenant-123");4564 * ```4565 */4566declare abstract class AiSearchNamespace {4567 /**4568 * Get an instance by name within the bound namespace.4569 * @param name Instance name.4570 * @returns Instance service for search, chat, update, stats, items, and jobs.4571 */4572 get(name: string): AiSearchInstance;4573 /**4574 * List instances in the bound namespace.4575 * @param params Optional pagination, search, and ordering parameters.4576 * @returns Array of instance metadata with pagination info.4577 */4578 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;4579 /**4580 * Create a new instance within the bound namespace.4581 * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage.4582 * @returns Instance service for the newly created instance.4583 *4584 * @example4585 * ```ts4586 * // Create with built-in storage (upload items manually)4587 * const instance = await env.AI_SEARCH.create({ id: "my-search" });4588 *4589 * // Create with web crawler source4590 * const instance = await env.AI_SEARCH.create({4591 * id: "docs-search",4592 * type: "web-crawler",4593 * source: "https://developers.cloudflare.com",4594 * });4595 * ```4596 */4597 create(config: AiSearchConfig): Promise<AiSearchInstance>;4598 /**4599 * Delete an instance from the bound namespace.4600 * @param name Instance name to delete.4601 */4602 delete(name: string): Promise<void>;4603 /**4604 * Search across multiple instances within the bound namespace.4605 * Fans out to the specified instance_ids and merges results.4606 * @param params Search request with required `ai_search_options.instance_ids`.4607 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.4608 */4609 search(params: AiSearchMultiSearchRequest): Promise<AiSearchMultiSearchResponse>;4610 /**4611 * Generate chat completions across multiple instances within the bound namespace (streaming).4612 * Fans out to the specified instance_ids, merges context, and generates a response.4613 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.4614 * @returns ReadableStream of server-sent events.4615 */4616 chatCompletions(params: AiSearchMultiChatCompletionsRequest & {4617 stream: true;4618 }): Promise<ReadableStream>;4619 /**4620 * Generate chat completions across multiple instances within the bound namespace.4621 * Fans out to the specified instance_ids, merges context, and generates a response.4622 * @param params Chat completions request with required `ai_search_options.instance_ids`.4623 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.4624 */4625 chatCompletions(params: AiSearchMultiChatCompletionsRequest): Promise<AiSearchMultiChatCompletionsResponse>;4626}4627type AiImageClassificationInput = {4628 image: number[];4629};4630type AiImageClassificationOutput = {4631 score?: number;4632 label?: string;4633}[];4634declare abstract class BaseAiImageClassification {4635 inputs: AiImageClassificationInput;4636 postProcessedOutputs: AiImageClassificationOutput;4637}4638type AiImageToTextInput = {4639 image: number[];4640 prompt?: string;4641 max_tokens?: number;4642 temperature?: number;4643 top_p?: number;4644 top_k?: number;4645 seed?: number;4646 repetition_penalty?: number;4647 frequency_penalty?: number;4648 presence_penalty?: number;4649 raw?: boolean;4650 messages?: RoleScopedChatInput[];4651};4652type AiImageToTextOutput = {4653 description: string;4654};4655declare abstract class BaseAiImageToText {4656 inputs: AiImageToTextInput;4657 postProcessedOutputs: AiImageToTextOutput;4658}4659type AiImageTextToTextInput = {4660 image: string;4661 prompt?: string;4662 max_tokens?: number;4663 temperature?: number;4664 ignore_eos?: boolean;4665 top_p?: number;4666 top_k?: number;4667 seed?: number;4668 repetition_penalty?: number;4669 frequency_penalty?: number;4670 presence_penalty?: number;4671 raw?: boolean;4672 messages?: RoleScopedChatInput[];4673};4674type AiImageTextToTextOutput = {4675 description: string;4676};4677declare abstract class BaseAiImageTextToText {4678 inputs: AiImageTextToTextInput;4679 postProcessedOutputs: AiImageTextToTextOutput;4680}4681type AiMultimodalEmbeddingsInput = {4682 image: string;4683 text: string[];4684};4685type AiIMultimodalEmbeddingsOutput = {4686 data: number[][];4687 shape: number[];4688};4689declare abstract class BaseAiMultimodalEmbeddings {4690 inputs: AiImageTextToTextInput;4691 postProcessedOutputs: AiImageTextToTextOutput;4692}4693type AiObjectDetectionInput = {4694 image: number[];4695};4696type AiObjectDetectionOutput = {4697 score?: number;4698 label?: string;4699}[];4700declare abstract class BaseAiObjectDetection {4701 inputs: AiObjectDetectionInput;4702 postProcessedOutputs: AiObjectDetectionOutput;4703}4704type AiSentenceSimilarityInput = {4705 source: string;4706 sentences: string[];4707};4708type AiSentenceSimilarityOutput = number[];4709declare abstract class BaseAiSentenceSimilarity {4710 inputs: AiSentenceSimilarityInput;4711 postProcessedOutputs: AiSentenceSimilarityOutput;4712}4713type AiAutomaticSpeechRecognitionInput = {4714 audio: number[];4715};4716type AiAutomaticSpeechRecognitionOutput = {4717 text?: string;4718 words?: {4719 word: string;4720 start: number;4721 end: number;4722 }[];4723 vtt?: string;4724};4725declare abstract class BaseAiAutomaticSpeechRecognition {4726 inputs: AiAutomaticSpeechRecognitionInput;4727 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;4728}4729type AiSummarizationInput = {4730 input_text: string;4731 max_length?: number;4732};4733type AiSummarizationOutput = {4734 summary: string;4735};4736declare abstract class BaseAiSummarization {4737 inputs: AiSummarizationInput;4738 postProcessedOutputs: AiSummarizationOutput;4739}4740type AiTextClassificationInput = {4741 text: string;4742};4743type AiTextClassificationOutput = {4744 score?: number;4745 label?: string;4746}[];4747declare abstract class BaseAiTextClassification {4748 inputs: AiTextClassificationInput;4749 postProcessedOutputs: AiTextClassificationOutput;4750}4751type AiTextEmbeddingsInput = {4752 text: string | string[];4753};4754type AiTextEmbeddingsOutput = {4755 shape: number[];4756 data: number[][];4757};4758declare abstract class BaseAiTextEmbeddings {4759 inputs: AiTextEmbeddingsInput;4760 postProcessedOutputs: AiTextEmbeddingsOutput;4761}4762type RoleScopedChatInput = {4763 role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>);4764 content: string;4765 name?: string;4766};4767type AiTextGenerationToolLegacyInput = {4768 name: string;4769 description: string;4770 parameters?: {4771 type: "object" | (string & NonNullable<unknown>);4772 properties: {4773 [key: string]: {4774 type: string;4775 description?: string;4776 };4777 };4778 required: string[];4779 };4780};4781type AiTextGenerationToolInput = {4782 type: "function" | (string & NonNullable<unknown>);4783 function: {4784 name: string;4785 description: string;4786 parameters?: {4787 type: "object" | (string & NonNullable<unknown>);4788 properties: {4789 [key: string]: {4790 type: string;4791 description?: string;4792 };4793 };4794 required: string[];4795 };4796 };4797};4798type AiTextGenerationFunctionsInput = {4799 name: string;4800 code: string;4801};4802type AiTextGenerationResponseFormat = {4803 type: string;4804 json_schema?: any;4805};4806type AiTextGenerationInput = {4807 prompt?: string;4808 raw?: boolean;4809 stream?: boolean;4810 max_tokens?: number;4811 temperature?: number;4812 top_p?: number;4813 top_k?: number;4814 seed?: number;4815 repetition_penalty?: number;4816 frequency_penalty?: number;4817 presence_penalty?: number;4818 messages?: RoleScopedChatInput[];4819 response_format?: AiTextGenerationResponseFormat;4820 tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>);4821 functions?: AiTextGenerationFunctionsInput[];4822};4823type AiTextGenerationToolLegacyOutput = {4824 name: string;4825 arguments: unknown;4826};4827type AiTextGenerationToolOutput = {4828 id: string;4829 type: "function";4830 function: {4831 name: string;4832 arguments: string;4833 };4834};4835type UsageTags = {4836 prompt_tokens: number;4837 completion_tokens: number;4838 total_tokens: number;4839};4840type AiTextGenerationOutput = {4841 response?: string;4842 tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[];4843 usage?: UsageTags;4844};4845declare abstract class BaseAiTextGeneration {4846 inputs: AiTextGenerationInput;4847 postProcessedOutputs: AiTextGenerationOutput;4848}4849type AiTextToSpeechInput = {4850 prompt: string;4851 lang?: string;4852};4853type AiTextToSpeechOutput = Uint8Array | {4854 audio: string;4855};4856declare abstract class BaseAiTextToSpeech {4857 inputs: AiTextToSpeechInput;4858 postProcessedOutputs: AiTextToSpeechOutput;4859}4860type AiTextToImageInput = {4861 prompt: string;4862 negative_prompt?: string;4863 height?: number;4864 width?: number;4865 image?: number[];4866 image_b64?: string;4867 mask?: number[];4868 num_steps?: number;4869 strength?: number;4870 guidance?: number;4871 seed?: number;4872};4873type AiTextToImageOutput = ReadableStream<Uint8Array>;4874declare abstract class BaseAiTextToImage {4875 inputs: AiTextToImageInput;4876 postProcessedOutputs: AiTextToImageOutput;4877}4878type AiTranslationInput = {4879 text: string;4880 target_lang: string;4881 source_lang?: string;4882};4883type AiTranslationOutput = {4884 translated_text?: string;4885};4886declare abstract class BaseAiTranslation {4887 inputs: AiTranslationInput;4888 postProcessedOutputs: AiTranslationOutput;4889}4890/**4891 * Workers AI support for OpenAI's Chat Completions API4892 */4893type ChatCompletionContentPartText = {4894 type: "text";4895 text: string;4896};4897type ChatCompletionContentPartImage = {4898 type: "image_url";4899 image_url: {4900 url: string;4901 detail?: "auto" | "low" | "high";4902 };4903};4904type ChatCompletionContentPartInputAudio = {4905 type: "input_audio";4906 input_audio: {4907 /** Base64 encoded audio data. */4908 data: string;4909 format: "wav" | "mp3";4910 };4911};4912type ChatCompletionContentPartFile = {4913 type: "file";4914 file: {4915 /** Base64 encoded file data. */4916 file_data?: string;4917 /** The ID of an uploaded file. */4918 file_id?: string;4919 filename?: string;4920 };4921};4922type ChatCompletionContentPartRefusal = {4923 type: "refusal";4924 refusal: string;4925};4926type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile;4927type FunctionDefinition = {4928 name: string;4929 description?: string;4930 parameters?: Record<string, unknown>;4931 strict?: boolean | null;4932};4933type ChatCompletionFunctionTool = {4934 type: "function";4935 function: FunctionDefinition;4936};4937type ChatCompletionCustomToolGrammarFormat = {4938 type: "grammar";4939 grammar: {4940 definition: string;4941 syntax: "lark" | "regex";4942 };4943};4944type ChatCompletionCustomToolTextFormat = {4945 type: "text";4946};4947type ChatCompletionCustomToolFormat = ChatCompletionCustomToolTextFormat | ChatCompletionCustomToolGrammarFormat;4948type ChatCompletionCustomTool = {4949 type: "custom";4950 custom: {4951 name: string;4952 description?: string;4953 format?: ChatCompletionCustomToolFormat;4954 };4955};4956type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;4957type ChatCompletionMessageFunctionToolCall = {4958 id: string;4959 type: "function";4960 function: {4961 name: string;4962 /** JSON-encoded arguments string. */4963 arguments: string;4964 };4965};4966type ChatCompletionMessageCustomToolCall = {4967 id: string;4968 type: "custom";4969 custom: {4970 name: string;4971 input: string;4972 };4973};4974type ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall;4975type ChatCompletionToolChoiceFunction = {4976 type: "function";4977 function: {4978 name: string;4979 };4980};4981type ChatCompletionToolChoiceCustom = {4982 type: "custom";4983 custom: {4984 name: string;4985 };4986};4987type ChatCompletionToolChoiceAllowedTools = {4988 type: "allowed_tools";4989 allowed_tools: {4990 mode: "auto" | "required";4991 tools: Array<Record<string, unknown>>;4992 };4993};4994type ChatCompletionToolChoiceOption = "none" | "auto" | "required" | ChatCompletionToolChoiceFunction | ChatCompletionToolChoiceCustom | ChatCompletionToolChoiceAllowedTools;4995type DeveloperMessage = {4996 role: "developer";4997 content: string | Array<{4998 type: "text";4999 text: string;5000 }>;5001 name?: string;5002};5003type SystemMessage = {5004 role: "system";5005 content: string | Array<{5006 type: "text";5007 text: string;5008 }>;5009 name?: string;5010};5011/**5012 * Permissive merged content part used inside UserMessage arrays.5013 *5014 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination5015 * inside nested array items does not correctly match different branches for5016 * different array elements, so the schema uses a single merged object.5017 */5018type UserMessageContentPart = {5019 type: "text" | "image_url" | "input_audio" | "file";5020 text?: string;5021 image_url?: {5022 url?: string;5023 detail?: "auto" | "low" | "high";5024 };5025 input_audio?: {5026 data?: string;5027 format?: "wav" | "mp3";5028 };5029 file?: {5030 file_data?: string;5031 file_id?: string;5032 filename?: string;5033 };5034};5035type UserMessage = {5036 role: "user";5037 content: string | Array<UserMessageContentPart>;5038 name?: string;5039};5040type AssistantMessageContentPart = {5041 type: "text" | "refusal";5042 text?: string;5043 refusal?: string;5044};5045type AssistantMessage = {5046 role: "assistant";5047 content?: string | null | Array<AssistantMessageContentPart>;5048 refusal?: string | null;5049 name?: string;5050 audio?: {5051 id: string;5052 };5053 tool_calls?: Array<ChatCompletionMessageToolCall>;5054 function_call?: {5055 name: string;5056 arguments: string;5057 };5058};5059type ToolMessage = {5060 role: "tool";5061 content: string | Array<{5062 type: "text";5063 text: string;5064 }>;5065 tool_call_id: string;5066};5067type FunctionMessage = {5068 role: "function";5069 content: string;5070 name: string;5071};5072type ChatCompletionMessageParam = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage;5073type ChatCompletionsResponseFormatText = {5074 type: "text";5075};5076type ChatCompletionsResponseFormatJSONObject = {5077 type: "json_object";5078};5079type ResponseFormatJSONSchema = {5080 type: "json_schema";5081 json_schema: {5082 name: string;5083 description?: string;5084 schema?: Record<string, unknown>;5085 strict?: boolean | null;5086 };5087};5088type ResponseFormat = ChatCompletionsResponseFormatText | ChatCompletionsResponseFormatJSONObject | ResponseFormatJSONSchema;5089type ChatCompletionsStreamOptions = {5090 include_usage?: boolean;5091 include_obfuscation?: boolean;5092};5093type PredictionContent = {5094 type: "content";5095 content: string | Array<{5096 type: "text";5097 text: string;5098 }>;5099};5100type AudioParams = {5101 voice: string | {5102 id: string;5103 };5104 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";5105};5106type WebSearchUserLocation = {5107 type: "approximate";5108 approximate: {5109 city?: string;5110 country?: string;5111 region?: string;5112 timezone?: string;5113 };5114};5115type WebSearchOptions = {5116 search_context_size?: "low" | "medium" | "high";5117 user_location?: WebSearchUserLocation;5118};5119type ChatTemplateKwargs = {5120 /** Whether to enable reasoning, enabled by default. */5121 enable_thinking?: boolean;5122 /** If false, preserves reasoning context between turns. */5123 clear_thinking?: boolean;5124};5125/** Shared optional properties used by both Prompt and Messages input branches. */5126type ChatCompletionsCommonOptions = {5127 model?: string;5128 audio?: AudioParams;5129 frequency_penalty?: number | null;5130 logit_bias?: Record<string, unknown> | null;5131 logprobs?: boolean | null;5132 top_logprobs?: number | null;5133 max_tokens?: number | null;5134 max_completion_tokens?: number | null;5135 metadata?: Record<string, unknown> | null;5136 modalities?: Array<"text" | "audio"> | null;5137 n?: number | null;5138 parallel_tool_calls?: boolean;5139 prediction?: PredictionContent;5140 presence_penalty?: number | null;5141 reasoning_effort?: "low" | "medium" | "high" | null;5142 chat_template_kwargs?: ChatTemplateKwargs;5143 response_format?: ResponseFormat;5144 seed?: number | null;5145 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;5146 stop?: string | Array<string> | null;5147 store?: boolean | null;5148 stream?: boolean | null;5149 stream_options?: ChatCompletionsStreamOptions;5150 temperature?: number | null;5151 tool_choice?: ChatCompletionToolChoiceOption;5152 tools?: Array<ChatCompletionTool>;5153 top_p?: number | null;5154 user?: string;5155 web_search_options?: WebSearchOptions;5156 function_call?: "none" | "auto" | {5157 name: string;5158 };5159 functions?: Array<FunctionDefinition>;5160};5161type PromptTokensDetails = {5162 cached_tokens?: number;5163 audio_tokens?: number;5164};5165type CompletionTokensDetails = {5166 reasoning_tokens?: number;5167 audio_tokens?: number;5168 accepted_prediction_tokens?: number;5169 rejected_prediction_tokens?: number;5170};5171type CompletionUsage = {5172 prompt_tokens: number;5173 completion_tokens: number;5174 total_tokens: number;5175 prompt_tokens_details?: PromptTokensDetails;5176 completion_tokens_details?: CompletionTokensDetails;5177};5178type ChatCompletionTopLogprob = {5179 token: string;5180 logprob: number;5181 bytes: Array<number> | null;5182};5183type ChatCompletionTokenLogprob = {5184 token: string;5185 logprob: number;5186 bytes: Array<number> | null;5187 top_logprobs: Array<ChatCompletionTopLogprob>;5188};5189type ChatCompletionAudio = {5190 id: string;5191 /** Base64 encoded audio bytes. */5192 data: string;5193 expires_at: number;5194 transcript: string;5195};5196type ChatCompletionUrlCitation = {5197 type: "url_citation";5198 url_citation: {5199 url: string;5200 title: string;5201 start_index: number;5202 end_index: number;5203 };5204};5205type ChatCompletionResponseMessage = {5206 role: "assistant";5207 content: string | null;5208 refusal: string | null;5209 annotations?: Array<ChatCompletionUrlCitation>;5210 audio?: ChatCompletionAudio;5211 tool_calls?: Array<ChatCompletionMessageToolCall>;5212 function_call?: {5213 name: string;5214 arguments: string;5215 } | null;5216};5217type ChatCompletionLogprobs = {5218 content: Array<ChatCompletionTokenLogprob> | null;5219 refusal?: Array<ChatCompletionTokenLogprob> | null;5220};5221type ChatCompletionChoice = {5222 index: number;5223 message: ChatCompletionResponseMessage;5224 finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call";5225 logprobs: ChatCompletionLogprobs | null;5226};5227type ChatCompletionsMessagesInput = {5228 messages: Array<ChatCompletionMessageParam>;5229} & ChatCompletionsCommonOptions;5230type ChatCompletionsOutput = {5231 id: string;5232 object: string;5233 created: number;5234 model: string;5235 choices: Array<ChatCompletionChoice>;5236 usage?: CompletionUsage;5237 system_fingerprint?: string | null;5238 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;5239};5240/**5241 * Workers AI support for OpenAI's Responses API5242 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts5243 *5244 * It's a stripped down version from its source.5245 * It currently supports basic function calling, json mode and accepts images as input.5246 *5247 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.5248 * We plan to add those incrementally as model + platform capabilities evolve.5249 */5250type ResponsesInput = {5251 background?: boolean | null;5252 conversation?: string | ResponseConversationParam | null;5253 include?: Array<ResponseIncludable> | null;5254 input?: string | ResponseInput;5255 instructions?: string | null;5256 max_output_tokens?: number | null;5257 parallel_tool_calls?: boolean | null;5258 previous_response_id?: string | null;5259 prompt_cache_key?: string;5260 reasoning?: Reasoning | null;5261 safety_identifier?: string;5262 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;5263 stream?: boolean | null;5264 stream_options?: StreamOptions | null;5265 temperature?: number | null;5266 text?: ResponseTextConfig;5267 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;5268 tools?: Array<Tool>;5269 top_p?: number | null;5270 truncation?: "auto" | "disabled" | null;5271};5272type ResponsesOutput = {5273 id?: string;5274 created_at?: number;5275 output_text?: string;5276 error?: ResponseError | null;5277 incomplete_details?: ResponseIncompleteDetails | null;5278 instructions?: string | Array<ResponseInputItem> | null;5279 object?: "response";5280 output?: Array<ResponseOutputItem>;5281 parallel_tool_calls?: boolean;5282 temperature?: number | null;5283 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;5284 tools?: Array<Tool>;5285 top_p?: number | null;5286 max_output_tokens?: number | null;5287 previous_response_id?: string | null;5288 prompt?: ResponsePrompt | null;5289 reasoning?: Reasoning | null;5290 safety_identifier?: string;5291 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;5292 status?: ResponseStatus;5293 text?: ResponseTextConfig;5294 truncation?: "auto" | "disabled" | null;5295 usage?: ResponseUsage;5296};5297type EasyInputMessage = {5298 content: string | ResponseInputMessageContentList;5299 role: "user" | "assistant" | "system" | "developer";5300 type?: "message";5301};5302type ResponsesFunctionTool = {5303 name: string;5304 parameters: {5305 [key: string]: unknown;5306 } | null;5307 strict: boolean | null;5308 type: "function";5309 description?: string | null;5310};5311type ResponseIncompleteDetails = {5312 reason?: "max_output_tokens" | "content_filter";5313};5314type ResponsePrompt = {5315 id: string;5316 variables?: {5317 [key: string]: string | ResponseInputText | ResponseInputImage;5318 } | null;5319 version?: string | null;5320};5321type Reasoning = {5322 effort?: ReasoningEffort | null;5323 generate_summary?: "auto" | "concise" | "detailed" | null;5324 summary?: "auto" | "concise" | "detailed" | null;5325};5326type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText;5327type ResponseContentReasoningText = {5328 text: string;5329 type: "reasoning_text";5330};5331type ResponseConversationParam = {5332 id: string;5333};5334type ResponseCreatedEvent = {5335 response: Response;5336 sequence_number: number;5337 type: "response.created";5338};5339type ResponseCustomToolCallOutput = {5340 call_id: string;5341 output: string | Array<ResponseInputText | ResponseInputImage>;5342 type: "custom_tool_call_output";5343 id?: string;5344};5345type ResponseError = {5346 code: "server_error" | "rate_limit_exceeded" | "invalid_prompt" | "vector_store_timeout" | "invalid_image" | "invalid_image_format" | "invalid_base64_image" | "invalid_image_url" | "image_too_large" | "image_too_small" | "image_parse_error" | "image_content_policy_violation" | "invalid_image_mode" | "image_file_too_large" | "unsupported_image_media_type" | "empty_image_file" | "failed_to_download_image" | "image_file_not_found";5347 message: string;5348};5349type ResponseErrorEvent = {5350 code: string | null;5351 message: string;5352 param: string | null;5353 sequence_number: number;5354 type: "error";5355};5356type ResponseFailedEvent = {5357 response: Response;5358 sequence_number: number;5359 type: "response.failed";5360};5361type ResponseFormatText = {5362 type: "text";5363};5364type ResponseFormatJSONObject = {5365 type: "json_object";5366};5367type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject;5368type ResponseFormatTextJSONSchemaConfig = {5369 name: string;5370 schema: {5371 [key: string]: unknown;5372 };5373 type: "json_schema";5374 description?: string;5375 strict?: boolean | null;5376};5377type ResponseFunctionCallArgumentsDeltaEvent = {5378 delta: string;5379 item_id: string;5380 output_index: number;5381 sequence_number: number;5382 type: "response.function_call_arguments.delta";5383};5384type ResponseFunctionCallArgumentsDoneEvent = {5385 arguments: string;5386 item_id: string;5387 name: string;5388 output_index: number;5389 sequence_number: number;5390 type: "response.function_call_arguments.done";5391};5392type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent;5393type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;5394type ResponseFunctionToolCall = {5395 arguments: string;5396 call_id: string;5397 name: string;5398 type: "function_call";5399 id?: string;5400 status?: "in_progress" | "completed" | "incomplete";5401};5402interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {5403 id: string;5404}5405type ResponseFunctionToolCallOutputItem = {5406 id: string;5407 call_id: string;5408 output: string | Array<ResponseInputText | ResponseInputImage>;5409 type: "function_call_output";5410 status?: "in_progress" | "completed" | "incomplete";5411};5412type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs";5413type ResponseIncompleteEvent = {5414 response: Response;5415 sequence_number: number;5416 type: "response.incomplete";5417};5418type ResponseInput = Array<ResponseInputItem>;5419type ResponseInputContent = ResponseInputText | ResponseInputImage;5420type ResponseInputImage = {5421 detail: "low" | "high" | "auto";5422 type: "input_image";5423 /**5424 * Base64 encoded image5425 */5426 image_url?: string | null;5427};5428type ResponseInputImageContent = {5429 type: "input_image";5430 detail?: "low" | "high" | "auto" | null;5431 /**5432 * Base64 encoded image5433 */5434 image_url?: string | null;5435};5436type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem;5437type ResponseInputItemFunctionCallOutput = {5438 call_id: string;5439 output: string | ResponseFunctionCallOutputItemList;5440 type: "function_call_output";5441 id?: string | null;5442 status?: "in_progress" | "completed" | "incomplete" | null;5443};5444type ResponseInputItemMessage = {5445 content: ResponseInputMessageContentList;5446 role: "user" | "system" | "developer";5447 status?: "in_progress" | "completed" | "incomplete";5448 type?: "message";5449};5450type ResponseInputMessageContentList = Array<ResponseInputContent>;5451type ResponseInputMessageItem = {5452 id: string;5453 content: ResponseInputMessageContentList;5454 role: "user" | "system" | "developer";5455 status?: "in_progress" | "completed" | "incomplete";5456 type?: "message";5457};5458type ResponseInputText = {5459 text: string;5460 type: "input_text";5461};5462type ResponseInputTextContent = {5463 text: string;5464 type: "input_text";5465};5466type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem;5467type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem;5468type ResponseOutputItemAddedEvent = {5469 item: ResponseOutputItem;5470 output_index: number;5471 sequence_number: number;5472 type: "response.output_item.added";5473};5474type ResponseOutputItemDoneEvent = {5475 item: ResponseOutputItem;5476 output_index: number;5477 sequence_number: number;5478 type: "response.output_item.done";5479};5480type ResponseOutputMessage = {5481 id: string;5482 content: Array<ResponseOutputText | ResponseOutputRefusal>;5483 role: "assistant";5484 status: "in_progress" | "completed" | "incomplete";5485 type: "message";5486};5487type ResponseOutputRefusal = {5488 refusal: string;5489 type: "refusal";5490};5491type ResponseOutputText = {5492 text: string;5493 type: "output_text";5494 logprobs?: Array<Logprob>;5495};5496type ResponseReasoningItem = {5497 id: string;5498 summary: Array<ResponseReasoningSummaryItem>;5499 type: "reasoning";5500 content?: Array<ResponseReasoningContentItem>;5501 encrypted_content?: string | null;5502 status?: "in_progress" | "completed" | "incomplete";5503};5504type ResponseReasoningSummaryItem = {5505 text: string;5506 type: "summary_text";5507};5508type ResponseReasoningContentItem = {5509 text: string;5510 type: "reasoning_text";5511};5512type ResponseReasoningTextDeltaEvent = {5513 content_index: number;5514 delta: string;5515 item_id: string;5516 output_index: number;5517 sequence_number: number;5518 type: "response.reasoning_text.delta";5519};5520type ResponseReasoningTextDoneEvent = {5521 content_index: number;5522 item_id: string;5523 output_index: number;5524 sequence_number: number;5525 text: string;5526 type: "response.reasoning_text.done";5527};5528type ResponseRefusalDeltaEvent = {5529 content_index: number;5530 delta: string;5531 item_id: string;5532 output_index: number;5533 sequence_number: number;5534 type: "response.refusal.delta";5535};5536type ResponseRefusalDoneEvent = {5537 content_index: number;5538 item_id: string;5539 output_index: number;5540 refusal: string;5541 sequence_number: number;5542 type: "response.refusal.done";5543};5544type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete";5545type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent;5546type ResponseCompletedEvent = {5547 response: Response;5548 sequence_number: number;5549 type: "response.completed";5550};5551type ResponseTextConfig = {5552 format?: ResponseFormatTextConfig;5553 verbosity?: "low" | "medium" | "high" | null;5554};5555type ResponseTextDeltaEvent = {5556 content_index: number;5557 delta: string;5558 item_id: string;5559 logprobs: Array<Logprob>;5560 output_index: number;5561 sequence_number: number;5562 type: "response.output_text.delta";5563};5564type ResponseTextDoneEvent = {5565 content_index: number;5566 item_id: string;5567 logprobs: Array<Logprob>;5568 output_index: number;5569 sequence_number: number;5570 text: string;5571 type: "response.output_text.done";5572};5573type Logprob = {5574 token: string;5575 logprob: number;5576 top_logprobs?: Array<TopLogprob>;5577};5578type TopLogprob = {5579 token?: string;5580 logprob?: number;5581};5582type ResponseUsage = {5583 input_tokens: number;5584 output_tokens: number;5585 total_tokens: number;5586};5587type Tool = ResponsesFunctionTool;5588type ToolChoiceFunction = {5589 name: string;5590 type: "function";5591};5592type ToolChoiceOptions = "none";5593type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;5594type StreamOptions = {5595 include_obfuscation?: boolean;5596};5597/** Marks keys from T that aren't in U as optional never */5598type Without<T, U> = {5599 [P in Exclude<keyof T, keyof U>]?: never;5600};5601/** Either T or U, but not both (mutually exclusive) */5602type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);5603type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = {5604 text: string | string[];5605 /**5606 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5607 */5608 pooling?: "mean" | "cls";5609} | {5610 /**5611 * Batch of the embeddings requests to run using async-queue5612 */5613 requests: {5614 text: string | string[];5615 /**5616 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5617 */5618 pooling?: "mean" | "cls";5619 }[];5620};5621type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = {5622 shape?: number[];5623 /**5624 * Embeddings of the requested text values5625 */5626 data?: number[][];5627 /**5628 * The pooling method used in the embedding process.5629 */5630 pooling?: "mean" | "cls";5631} | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;5632interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {5633 /**5634 * The async request id that can be used to obtain the results.5635 */5636 request_id?: string;5637}5638declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {5639 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;5640 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;5641}5642type Ai_Cf_Openai_Whisper_Input = string | {5643 /**5644 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values5645 */5646 audio: number[];5647};5648interface Ai_Cf_Openai_Whisper_Output {5649 /**5650 * The transcription5651 */5652 text: string;5653 word_count?: number;5654 words?: {5655 word?: string;5656 /**5657 * The second this word begins in the recording5658 */5659 start?: number;5660 /**5661 * The ending second when the word completes5662 */5663 end?: number;5664 }[];5665 vtt?: string;5666}5667declare abstract class Base_Ai_Cf_Openai_Whisper {5668 inputs: Ai_Cf_Openai_Whisper_Input;5669 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;5670}5671type Ai_Cf_Meta_M2M100_1_2B_Input = {5672 /**5673 * The text to be translated5674 */5675 text: string;5676 /**5677 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified5678 */5679 source_lang?: string;5680 /**5681 * The language code to translate the text into (e.g., 'es' for Spanish)5682 */5683 target_lang: string;5684} | {5685 /**5686 * Batch of the embeddings requests to run using async-queue5687 */5688 requests: {5689 /**5690 * The text to be translated5691 */5692 text: string;5693 /**5694 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified5695 */5696 source_lang?: string;5697 /**5698 * The language code to translate the text into (e.g., 'es' for Spanish)5699 */5700 target_lang: string;5701 }[];5702};5703type Ai_Cf_Meta_M2M100_1_2B_Output = {5704 /**5705 * The translated text in the target language5706 */5707 translated_text?: string;5708} | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;5709interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {5710 /**5711 * The async request id that can be used to obtain the results.5712 */5713 request_id?: string;5714}5715declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {5716 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;5717 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;5718}5719type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = {5720 text: string | string[];5721 /**5722 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5723 */5724 pooling?: "mean" | "cls";5725} | {5726 /**5727 * Batch of the embeddings requests to run using async-queue5728 */5729 requests: {5730 text: string | string[];5731 /**5732 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5733 */5734 pooling?: "mean" | "cls";5735 }[];5736};5737type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = {5738 shape?: number[];5739 /**5740 * Embeddings of the requested text values5741 */5742 data?: number[][];5743 /**5744 * The pooling method used in the embedding process.5745 */5746 pooling?: "mean" | "cls";5747} | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;5748interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {5749 /**5750 * The async request id that can be used to obtain the results.5751 */5752 request_id?: string;5753}5754declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {5755 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;5756 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;5757}5758type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = {5759 text: string | string[];5760 /**5761 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5762 */5763 pooling?: "mean" | "cls";5764} | {5765 /**5766 * Batch of the embeddings requests to run using async-queue5767 */5768 requests: {5769 text: string | string[];5770 /**5771 * The pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.5772 */5773 pooling?: "mean" | "cls";5774 }[];5775};5776type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = {5777 shape?: number[];5778 /**5779 * Embeddings of the requested text values5780 */5781 data?: number[][];5782 /**5783 * The pooling method used in the embedding process.5784 */5785 pooling?: "mean" | "cls";5786} | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;5787interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {5788 /**5789 * The async request id that can be used to obtain the results.5790 */5791 request_id?: string;5792}5793declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {5794 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;5795 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;5796}5797type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | {5798 /**5799 * The input text prompt for the model to generate a response.5800 */5801 prompt?: string;5802 /**5803 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.5804 */5805 raw?: boolean;5806 /**5807 * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.5808 */5809 top_p?: number;5810 /**5811 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.5812 */5813 top_k?: number;5814 /**5815 * Random seed for reproducibility of the generation.5816 */5817 seed?: number;5818 /**5819 * Penalty for repeated tokens; higher values discourage repetition.5820 */5821 repetition_penalty?: number;5822 /**5823 * Decreases the likelihood of the model repeating the same lines verbatim.5824 */5825 frequency_penalty?: number;5826 /**5827 * Increases the likelihood of the model introducing new topics.5828 */5829 presence_penalty?: number;5830 image: number[] | (string & NonNullable<unknown>);5831 /**5832 * The maximum number of tokens to generate in the response.5833 */5834 max_tokens?: number;5835};5836interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {5837 description?: string;5838}5839declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {5840 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;5841 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;5842}5843type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | {5844 /**5845 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values5846 */5847 audio: number[];5848};5849interface Ai_Cf_Openai_Whisper_Tiny_En_Output {5850 /**5851 * The transcription5852 */5853 text: string;5854 word_count?: number;5855 words?: {5856 word?: string;5857 /**5858 * The second this word begins in the recording5859 */5860 start?: number;5861 /**5862 * The ending second when the word completes5863 */5864 end?: number;5865 }[];5866 vtt?: string;5867}5868declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {5869 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;5870 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;5871}5872interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {5873 audio: string | {5874 body?: object;5875 contentType?: string;5876 };5877 /**5878 * Supported tasks are 'translate' or 'transcribe'.5879 */5880 task?: string;5881 /**5882 * The language of the audio being transcribed or translated.5883 */5884 language?: string;5885 /**5886 * Preprocess the audio with a voice activity detection model.5887 */5888 vad_filter?: boolean;5889 /**5890 * A text prompt to help provide context to the model on the contents of the audio.5891 */5892 initial_prompt?: string;5893 /**5894 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.5895 */5896 prefix?: string;5897 /**5898 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.5899 */5900 beam_size?: number;5901 /**5902 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.5903 */5904 condition_on_previous_text?: boolean;5905 /**5906 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.5907 */5908 no_speech_threshold?: number;5909 /**5910 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.5911 */5912 compression_ratio_threshold?: number;5913 /**5914 * Threshold for filtering out segments with low average log probability, indicating low confidence.5915 */5916 log_prob_threshold?: number;5917 /**5918 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.5919 */5920 hallucination_silence_threshold?: number;5921}5922interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {5923 transcription_info?: {5924 /**5925 * The language of the audio being transcribed or translated.5926 */5927 language?: string;5928 /**5929 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.5930 */5931 language_probability?: number;5932 /**5933 * The total duration of the original audio file, in seconds.5934 */5935 duration?: number;5936 /**5937 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.5938 */5939 duration_after_vad?: number;5940 };5941 /**5942 * The complete transcription of the audio.5943 */5944 text: string;5945 /**5946 * The total number of words in the transcription.5947 */5948 word_count?: number;5949 segments?: {5950 /**5951 * The starting time of the segment within the audio, in seconds.5952 */5953 start?: number;5954 /**5955 * The ending time of the segment within the audio, in seconds.5956 */5957 end?: number;5958 /**5959 * The transcription of the segment.5960 */5961 text?: string;5962 /**5963 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.5964 */5965 temperature?: number;5966 /**5967 * The average log probability of the predictions for the words in this segment, indicating overall confidence.5968 */5969 avg_logprob?: number;5970 /**5971 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.5972 */5973 compression_ratio?: number;5974 /**5975 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.5976 */5977 no_speech_prob?: number;5978 words?: {5979 /**5980 * The individual word transcribed from the audio.5981 */5982 word?: string;5983 /**5984 * The starting time of the word within the audio, in seconds.5985 */5986 start?: number;5987 /**5988 * The ending time of the word within the audio, in seconds.5989 */5990 end?: number;5991 }[];5992 }[];5993 /**5994 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.5995 */5996 vtt?: string;5997}5998declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {5999 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;6000 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;6001}6002type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | {6003 /**6004 * Batch of the embeddings requests to run using async-queue6005 */6006 requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[];6007};6008interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {6009 /**6010 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts6011 */6012 query?: string;6013 /**6014 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.6015 */6016 contexts: {6017 /**6018 * One of the provided context content6019 */6020 text?: string;6021 }[];6022 /**6023 * When provided with too long context should the model error out or truncate the context to fit?6024 */6025 truncate_inputs?: boolean;6026}6027interface Ai_Cf_Baai_Bge_M3_Input_Embedding {6028 text: string | string[];6029 /**6030 * When provided with too long context should the model error out or truncate the context to fit?6031 */6032 truncate_inputs?: boolean;6033}6034interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {6035 /**6036 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts6037 */6038 query?: string;6039 /**6040 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.6041 */6042 contexts: {6043 /**6044 * One of the provided context content6045 */6046 text?: string;6047 }[];6048 /**6049 * When provided with too long context should the model error out or truncate the context to fit?6050 */6051 truncate_inputs?: boolean;6052}6053interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {6054 text: string | string[];6055 /**6056 * When provided with too long context should the model error out or truncate the context to fit?6057 */6058 truncate_inputs?: boolean;6059}6060type Ai_Cf_Baai_Bge_M3_Output = Ai_Cf_Baai_Bge_M3_Output_Query | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts | Ai_Cf_Baai_Bge_M3_Output_Embedding | Ai_Cf_Baai_Bge_M3_AsyncResponse;6061interface Ai_Cf_Baai_Bge_M3_Output_Query {6062 response?: {6063 /**6064 * Index of the context in the request6065 */6066 id?: number;6067 /**6068 * Score of the context under the index.6069 */6070 score?: number;6071 }[];6072}6073interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {6074 response?: number[][];6075 shape?: number[];6076 /**6077 * The pooling method used in the embedding process.6078 */6079 pooling?: "mean" | "cls";6080}6081interface Ai_Cf_Baai_Bge_M3_Output_Embedding {6082 shape?: number[];6083 /**6084 * Embeddings of the requested text values6085 */6086 data?: number[][];6087 /**6088 * The pooling method used in the embedding process.6089 */6090 pooling?: "mean" | "cls";6091}6092interface Ai_Cf_Baai_Bge_M3_AsyncResponse {6093 /**6094 * The async request id that can be used to obtain the results.6095 */6096 request_id?: string;6097}6098declare abstract class Base_Ai_Cf_Baai_Bge_M3 {6099 inputs: Ai_Cf_Baai_Bge_M3_Input;6100 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;6101}6102interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {6103 /**6104 * A text description of the image you want to generate.6105 */6106 prompt: string;6107 /**6108 * The number of diffusion steps; higher values can improve quality but take longer.6109 */6110 steps?: number;6111}6112interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {6113 /**6114 * The generated image in Base64 format.6115 */6116 image?: string;6117}6118declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {6119 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;6120 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;6121}6122type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;6123interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {6124 /**6125 * The input text prompt for the model to generate a response.6126 */6127 prompt: string;6128 image?: number[] | (string & NonNullable<unknown>);6129 /**6130 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.6131 */6132 raw?: boolean;6133 /**6134 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6135 */6136 stream?: boolean;6137 /**6138 * The maximum number of tokens to generate in the response.6139 */6140 max_tokens?: number;6141 /**6142 * Controls the randomness of the output; higher values produce more random results.6143 */6144 temperature?: number;6145 /**6146 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6147 */6148 top_p?: number;6149 /**6150 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6151 */6152 top_k?: number;6153 /**6154 * Random seed for reproducibility of the generation.6155 */6156 seed?: number;6157 /**6158 * Penalty for repeated tokens; higher values discourage repetition.6159 */6160 repetition_penalty?: number;6161 /**6162 * Decreases the likelihood of the model repeating the same lines verbatim.6163 */6164 frequency_penalty?: number;6165 /**6166 * Increases the likelihood of the model introducing new topics.6167 */6168 presence_penalty?: number;6169 /**6170 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.6171 */6172 lora?: string;6173}6174interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {6175 /**6176 * An array of message objects representing the conversation history.6177 */6178 messages: {6179 /**6180 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').6181 */6182 role?: string;6183 /**6184 * The tool call id. If you don't know what to put here you can fall back to 0000000016185 */6186 tool_call_id?: string;6187 content?: string | {6188 /**6189 * Type of the content provided6190 */6191 type?: string;6192 text?: string;6193 image_url?: {6194 /**6195 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted6196 */6197 url?: string;6198 };6199 }[] | {6200 /**6201 * Type of the content provided6202 */6203 type?: string;6204 text?: string;6205 image_url?: {6206 /**6207 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted6208 */6209 url?: string;6210 };6211 };6212 }[];6213 image?: number[] | (string & NonNullable<unknown>);6214 functions?: {6215 name: string;6216 code: string;6217 }[];6218 /**6219 * A list of tools available for the assistant to use.6220 */6221 tools?: ({6222 /**6223 * The name of the tool. More descriptive the better.6224 */6225 name: string;6226 /**6227 * A brief description of what the tool does.6228 */6229 description: string;6230 /**6231 * Schema defining the parameters accepted by the tool.6232 */6233 parameters: {6234 /**6235 * The type of the parameters object (usually 'object').6236 */6237 type: string;6238 /**6239 * List of required parameter names.6240 */6241 required?: string[];6242 /**6243 * Definitions of each parameter.6244 */6245 properties: {6246 [k: string]: {6247 /**6248 * The data type of the parameter.6249 */6250 type: string;6251 /**6252 * A description of the expected parameter.6253 */6254 description: string;6255 };6256 };6257 };6258 } | {6259 /**6260 * Specifies the type of tool (e.g., 'function').6261 */6262 type: string;6263 /**6264 * Details of the function tool.6265 */6266 function: {6267 /**6268 * The name of the function.6269 */6270 name: string;6271 /**6272 * A brief description of what the function does.6273 */6274 description: string;6275 /**6276 * Schema defining the parameters accepted by the function.6277 */6278 parameters: {6279 /**6280 * The type of the parameters object (usually 'object').6281 */6282 type: string;6283 /**6284 * List of required parameter names.6285 */6286 required?: string[];6287 /**6288 * Definitions of each parameter.6289 */6290 properties: {6291 [k: string]: {6292 /**6293 * The data type of the parameter.6294 */6295 type: string;6296 /**6297 * A description of the expected parameter.6298 */6299 description: string;6300 };6301 };6302 };6303 };6304 })[];6305 /**6306 * If true, the response will be streamed back incrementally.6307 */6308 stream?: boolean;6309 /**6310 * The maximum number of tokens to generate in the response.6311 */6312 max_tokens?: number;6313 /**6314 * Controls the randomness of the output; higher values produce more random results.6315 */6316 temperature?: number;6317 /**6318 * Controls the creativity of the AI's responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6319 */6320 top_p?: number;6321 /**6322 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6323 */6324 top_k?: number;6325 /**6326 * Random seed for reproducibility of the generation.6327 */6328 seed?: number;6329 /**6330 * Penalty for repeated tokens; higher values discourage repetition.6331 */6332 repetition_penalty?: number;6333 /**6334 * Decreases the likelihood of the model repeating the same lines verbatim.6335 */6336 frequency_penalty?: number;6337 /**6338 * Increases the likelihood of the model introducing new topics.6339 */6340 presence_penalty?: number;6341}6342type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {6343 /**6344 * The generated text response from the model6345 */6346 response?: string;6347 /**6348 * An array of tool calls requests made during the response generation6349 */6350 tool_calls?: {6351 /**6352 * The arguments passed to be passed to the tool call request6353 */6354 arguments?: object;6355 /**6356 * The name of the tool to be called6357 */6358 name?: string;6359 }[];6360};6361declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {6362 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;6363 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;6364}6365type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input = Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;6366interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {6367 /**6368 * The input text prompt for the model to generate a response.6369 */6370 prompt: string;6371 /**6372 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.6373 */6374 lora?: string;6375 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;6376 /**6377 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.6378 */6379 raw?: boolean;6380 /**6381 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6382 */6383 stream?: boolean;6384 /**6385 * The maximum number of tokens to generate in the response.6386 */6387 max_tokens?: number;6388 /**6389 * Controls the randomness of the output; higher values produce more random results.6390 */6391 temperature?: number;6392 /**6393 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6394 */6395 top_p?: number;6396 /**6397 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6398 */6399 top_k?: number;6400 /**6401 * Random seed for reproducibility of the generation.6402 */6403 seed?: number;6404 /**6405 * Penalty for repeated tokens; higher values discourage repetition.6406 */6407 repetition_penalty?: number;6408 /**6409 * Decreases the likelihood of the model repeating the same lines verbatim.6410 */6411 frequency_penalty?: number;6412 /**6413 * Increases the likelihood of the model introducing new topics.6414 */6415 presence_penalty?: number;6416}6417interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {6418 type?: "json_object" | "json_schema";6419 json_schema?: unknown;6420}6421interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {6422 /**6423 * An array of message objects representing the conversation history.6424 */6425 messages: {6426 /**6427 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').6428 */6429 role: string;6430 content: string | {6431 /**6432 * Type of the content (text)6433 */6434 type?: string;6435 /**6436 * Text content6437 */6438 text?: string;6439 }[];6440 }[];6441 functions?: {6442 name: string;6443 code: string;6444 }[];6445 /**6446 * A list of tools available for the assistant to use.6447 */6448 tools?: ({6449 /**6450 * The name of the tool. More descriptive the better.6451 */6452 name: string;6453 /**6454 * A brief description of what the tool does.6455 */6456 description: string;6457 /**6458 * Schema defining the parameters accepted by the tool.6459 */6460 parameters: {6461 /**6462 * The type of the parameters object (usually 'object').6463 */6464 type: string;6465 /**6466 * List of required parameter names.6467 */6468 required?: string[];6469 /**6470 * Definitions of each parameter.6471 */6472 properties: {6473 [k: string]: {6474 /**6475 * The data type of the parameter.6476 */6477 type: string;6478 /**6479 * A description of the expected parameter.6480 */6481 description: string;6482 };6483 };6484 };6485 } | {6486 /**6487 * Specifies the type of tool (e.g., 'function').6488 */6489 type: string;6490 /**6491 * Details of the function tool.6492 */6493 function: {6494 /**6495 * The name of the function.6496 */6497 name: string;6498 /**6499 * A brief description of what the function does.6500 */6501 description: string;6502 /**6503 * Schema defining the parameters accepted by the function.6504 */6505 parameters: {6506 /**6507 * The type of the parameters object (usually 'object').6508 */6509 type: string;6510 /**6511 * List of required parameter names.6512 */6513 required?: string[];6514 /**6515 * Definitions of each parameter.6516 */6517 properties: {6518 [k: string]: {6519 /**6520 * The data type of the parameter.6521 */6522 type: string;6523 /**6524 * A description of the expected parameter.6525 */6526 description: string;6527 };6528 };6529 };6530 };6531 })[];6532 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;6533 /**6534 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.6535 */6536 raw?: boolean;6537 /**6538 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6539 */6540 stream?: boolean;6541 /**6542 * The maximum number of tokens to generate in the response.6543 */6544 max_tokens?: number;6545 /**6546 * Controls the randomness of the output; higher values produce more random results.6547 */6548 temperature?: number;6549 /**6550 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6551 */6552 top_p?: number;6553 /**6554 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6555 */6556 top_k?: number;6557 /**6558 * Random seed for reproducibility of the generation.6559 */6560 seed?: number;6561 /**6562 * Penalty for repeated tokens; higher values discourage repetition.6563 */6564 repetition_penalty?: number;6565 /**6566 * Decreases the likelihood of the model repeating the same lines verbatim.6567 */6568 frequency_penalty?: number;6569 /**6570 * Increases the likelihood of the model introducing new topics.6571 */6572 presence_penalty?: number;6573}6574interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {6575 type?: "json_object" | "json_schema";6576 json_schema?: unknown;6577}6578interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {6579 requests?: {6580 /**6581 * User-supplied reference. This field will be present in the response as well it can be used to reference the request and response. It's NOT validated to be unique.6582 */6583 external_reference?: string;6584 /**6585 * Prompt for the text generation model6586 */6587 prompt?: string;6588 /**6589 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6590 */6591 stream?: boolean;6592 /**6593 * The maximum number of tokens to generate in the response.6594 */6595 max_tokens?: number;6596 /**6597 * Controls the randomness of the output; higher values produce more random results.6598 */6599 temperature?: number;6600 /**6601 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6602 */6603 top_p?: number;6604 /**6605 * Random seed for reproducibility of the generation.6606 */6607 seed?: number;6608 /**6609 * Penalty for repeated tokens; higher values discourage repetition.6610 */6611 repetition_penalty?: number;6612 /**6613 * Decreases the likelihood of the model repeating the same lines verbatim.6614 */6615 frequency_penalty?: number;6616 /**6617 * Increases the likelihood of the model introducing new topics.6618 */6619 presence_penalty?: number;6620 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;6621 }[];6622}6623interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {6624 type?: "json_object" | "json_schema";6625 json_schema?: unknown;6626}6627type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = {6628 /**6629 * The generated text response from the model6630 */6631 response: string;6632 /**6633 * Usage statistics for the inference request6634 */6635 usage?: {6636 /**6637 * Total number of tokens in input6638 */6639 prompt_tokens?: number;6640 /**6641 * Total number of tokens in output6642 */6643 completion_tokens?: number;6644 /**6645 * Total number of input and output tokens6646 */6647 total_tokens?: number;6648 };6649 /**6650 * An array of tool calls requests made during the response generation6651 */6652 tool_calls?: {6653 /**6654 * The arguments passed to be passed to the tool call request6655 */6656 arguments?: object;6657 /**6658 * The name of the tool to be called6659 */6660 name?: string;6661 }[];6662} | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;6663interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {6664 /**6665 * The async request id that can be used to obtain the results.6666 */6667 request_id?: string;6668}6669declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {6670 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;6671 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;6672}6673interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {6674 /**6675 * An array of message objects representing the conversation history.6676 */6677 messages: {6678 /**6679 * The role of the message sender must alternate between 'user' and 'assistant'.6680 */6681 role: "user" | "assistant";6682 /**6683 * The content of the message as a string.6684 */6685 content: string;6686 }[];6687 /**6688 * The maximum number of tokens to generate in the response.6689 */6690 max_tokens?: number;6691 /**6692 * Controls the randomness of the output; higher values produce more random results.6693 */6694 temperature?: number;6695 /**6696 * Dictate the output format of the generated response.6697 */6698 response_format?: {6699 /**6700 * Set to json_object to process and output generated text as JSON.6701 */6702 type?: string;6703 };6704}6705interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {6706 response?: string | {6707 /**6708 * Whether the conversation is safe or not.6709 */6710 safe?: boolean;6711 /**6712 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.6713 */6714 categories?: string[];6715 };6716 /**6717 * Usage statistics for the inference request6718 */6719 usage?: {6720 /**6721 * Total number of tokens in input6722 */6723 prompt_tokens?: number;6724 /**6725 * Total number of tokens in output6726 */6727 completion_tokens?: number;6728 /**6729 * Total number of input and output tokens6730 */6731 total_tokens?: number;6732 };6733}6734declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {6735 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;6736 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;6737}6738interface Ai_Cf_Baai_Bge_Reranker_Base_Input {6739 /**6740 * A query you wish to perform against the provided contexts.6741 */6742 /**6743 * Number of returned results starting with the best score.6744 */6745 top_k?: number;6746 /**6747 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.6748 */6749 contexts: {6750 /**6751 * One of the provided context content6752 */6753 text?: string;6754 }[];6755}6756interface Ai_Cf_Baai_Bge_Reranker_Base_Output {6757 response?: {6758 /**6759 * Index of the context in the request6760 */6761 id?: number;6762 /**6763 * Score of the context under the index.6764 */6765 score?: number;6766 }[];6767}6768declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {6769 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;6770 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;6771}6772type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input = Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;6773interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {6774 /**6775 * The input text prompt for the model to generate a response.6776 */6777 prompt: string;6778 /**6779 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.6780 */6781 lora?: string;6782 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;6783 /**6784 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.6785 */6786 raw?: boolean;6787 /**6788 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6789 */6790 stream?: boolean;6791 /**6792 * The maximum number of tokens to generate in the response.6793 */6794 max_tokens?: number;6795 /**6796 * Controls the randomness of the output; higher values produce more random results.6797 */6798 temperature?: number;6799 /**6800 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6801 */6802 top_p?: number;6803 /**6804 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6805 */6806 top_k?: number;6807 /**6808 * Random seed for reproducibility of the generation.6809 */6810 seed?: number;6811 /**6812 * Penalty for repeated tokens; higher values discourage repetition.6813 */6814 repetition_penalty?: number;6815 /**6816 * Decreases the likelihood of the model repeating the same lines verbatim.6817 */6818 frequency_penalty?: number;6819 /**6820 * Increases the likelihood of the model introducing new topics.6821 */6822 presence_penalty?: number;6823}6824interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {6825 type?: "json_object" | "json_schema";6826 json_schema?: unknown;6827}6828interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {6829 /**6830 * An array of message objects representing the conversation history.6831 */6832 messages: {6833 /**6834 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').6835 */6836 role: string;6837 /**6838 * The content of the message as a string.6839 */6840 content: string;6841 }[];6842 functions?: {6843 name: string;6844 code: string;6845 }[];6846 /**6847 * A list of tools available for the assistant to use.6848 */6849 tools?: ({6850 /**6851 * The name of the tool. More descriptive the better.6852 */6853 name: string;6854 /**6855 * A brief description of what the tool does.6856 */6857 description: string;6858 /**6859 * Schema defining the parameters accepted by the tool.6860 */6861 parameters: {6862 /**6863 * The type of the parameters object (usually 'object').6864 */6865 type: string;6866 /**6867 * List of required parameter names.6868 */6869 required?: string[];6870 /**6871 * Definitions of each parameter.6872 */6873 properties: {6874 [k: string]: {6875 /**6876 * The data type of the parameter.6877 */6878 type: string;6879 /**6880 * A description of the expected parameter.6881 */6882 description: string;6883 };6884 };6885 };6886 } | {6887 /**6888 * Specifies the type of tool (e.g., 'function').6889 */6890 type: string;6891 /**6892 * Details of the function tool.6893 */6894 function: {6895 /**6896 * The name of the function.6897 */6898 name: string;6899 /**6900 * A brief description of what the function does.6901 */6902 description: string;6903 /**6904 * Schema defining the parameters accepted by the function.6905 */6906 parameters: {6907 /**6908 * The type of the parameters object (usually 'object').6909 */6910 type: string;6911 /**6912 * List of required parameter names.6913 */6914 required?: string[];6915 /**6916 * Definitions of each parameter.6917 */6918 properties: {6919 [k: string]: {6920 /**6921 * The data type of the parameter.6922 */6923 type: string;6924 /**6925 * A description of the expected parameter.6926 */6927 description: string;6928 };6929 };6930 };6931 };6932 })[];6933 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;6934 /**6935 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.6936 */6937 raw?: boolean;6938 /**6939 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.6940 */6941 stream?: boolean;6942 /**6943 * The maximum number of tokens to generate in the response.6944 */6945 max_tokens?: number;6946 /**6947 * Controls the randomness of the output; higher values produce more random results.6948 */6949 temperature?: number;6950 /**6951 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.6952 */6953 top_p?: number;6954 /**6955 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.6956 */6957 top_k?: number;6958 /**6959 * Random seed for reproducibility of the generation.6960 */6961 seed?: number;6962 /**6963 * Penalty for repeated tokens; higher values discourage repetition.6964 */6965 repetition_penalty?: number;6966 /**6967 * Decreases the likelihood of the model repeating the same lines verbatim.6968 */6969 frequency_penalty?: number;6970 /**6971 * Increases the likelihood of the model introducing new topics.6972 */6973 presence_penalty?: number;6974}6975interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {6976 type?: "json_object" | "json_schema";6977 json_schema?: unknown;6978}6979type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {6980 /**6981 * The generated text response from the model6982 */6983 response: string;6984 /**6985 * Usage statistics for the inference request6986 */6987 usage?: {6988 /**6989 * Total number of tokens in input6990 */6991 prompt_tokens?: number;6992 /**6993 * Total number of tokens in output6994 */6995 completion_tokens?: number;6996 /**6997 * Total number of input and output tokens6998 */6999 total_tokens?: number;7000 };7001 /**7002 * An array of tool calls requests made during the response generation7003 */7004 tool_calls?: {7005 /**7006 * The arguments passed to be passed to the tool call request7007 */7008 arguments?: object;7009 /**7010 * The name of the tool to be called7011 */7012 name?: string;7013 }[];7014};7015declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {7016 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;7017 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;7018}7019type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages;7020interface Ai_Cf_Qwen_Qwq_32B_Prompt {7021 /**7022 * The input text prompt for the model to generate a response.7023 */7024 prompt: string;7025 /**7026 * JSON schema that should be fulfilled for the response.7027 */7028 guided_json?: object;7029 /**7030 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7031 */7032 raw?: boolean;7033 /**7034 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7035 */7036 stream?: boolean;7037 /**7038 * The maximum number of tokens to generate in the response.7039 */7040 max_tokens?: number;7041 /**7042 * Controls the randomness of the output; higher values produce more random results.7043 */7044 temperature?: number;7045 /**7046 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7047 */7048 top_p?: number;7049 /**7050 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7051 */7052 top_k?: number;7053 /**7054 * Random seed for reproducibility of the generation.7055 */7056 seed?: number;7057 /**7058 * Penalty for repeated tokens; higher values discourage repetition.7059 */7060 repetition_penalty?: number;7061 /**7062 * Decreases the likelihood of the model repeating the same lines verbatim.7063 */7064 frequency_penalty?: number;7065 /**7066 * Increases the likelihood of the model introducing new topics.7067 */7068 presence_penalty?: number;7069}7070interface Ai_Cf_Qwen_Qwq_32B_Messages {7071 /**7072 * An array of message objects representing the conversation history.7073 */7074 messages: {7075 /**7076 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').7077 */7078 role?: string;7079 /**7080 * The tool call id. If you don't know what to put here you can fall back to 0000000017081 */7082 tool_call_id?: string;7083 content?: string | {7084 /**7085 * Type of the content provided7086 */7087 type?: string;7088 text?: string;7089 image_url?: {7090 /**7091 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7092 */7093 url?: string;7094 };7095 }[] | {7096 /**7097 * Type of the content provided7098 */7099 type?: string;7100 text?: string;7101 image_url?: {7102 /**7103 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7104 */7105 url?: string;7106 };7107 };7108 }[];7109 functions?: {7110 name: string;7111 code: string;7112 }[];7113 /**7114 * A list of tools available for the assistant to use.7115 */7116 tools?: ({7117 /**7118 * The name of the tool. More descriptive the better.7119 */7120 name: string;7121 /**7122 * A brief description of what the tool does.7123 */7124 description: string;7125 /**7126 * Schema defining the parameters accepted by the tool.7127 */7128 parameters: {7129 /**7130 * The type of the parameters object (usually 'object').7131 */7132 type: string;7133 /**7134 * List of required parameter names.7135 */7136 required?: string[];7137 /**7138 * Definitions of each parameter.7139 */7140 properties: {7141 [k: string]: {7142 /**7143 * The data type of the parameter.7144 */7145 type: string;7146 /**7147 * A description of the expected parameter.7148 */7149 description: string;7150 };7151 };7152 };7153 } | {7154 /**7155 * Specifies the type of tool (e.g., 'function').7156 */7157 type: string;7158 /**7159 * Details of the function tool.7160 */7161 function: {7162 /**7163 * The name of the function.7164 */7165 name: string;7166 /**7167 * A brief description of what the function does.7168 */7169 description: string;7170 /**7171 * Schema defining the parameters accepted by the function.7172 */7173 parameters: {7174 /**7175 * The type of the parameters object (usually 'object').7176 */7177 type: string;7178 /**7179 * List of required parameter names.7180 */7181 required?: string[];7182 /**7183 * Definitions of each parameter.7184 */7185 properties: {7186 [k: string]: {7187 /**7188 * The data type of the parameter.7189 */7190 type: string;7191 /**7192 * A description of the expected parameter.7193 */7194 description: string;7195 };7196 };7197 };7198 };7199 })[];7200 /**7201 * JSON schema that should be fufilled for the response.7202 */7203 guided_json?: object;7204 /**7205 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7206 */7207 raw?: boolean;7208 /**7209 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7210 */7211 stream?: boolean;7212 /**7213 * The maximum number of tokens to generate in the response.7214 */7215 max_tokens?: number;7216 /**7217 * Controls the randomness of the output; higher values produce more random results.7218 */7219 temperature?: number;7220 /**7221 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7222 */7223 top_p?: number;7224 /**7225 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7226 */7227 top_k?: number;7228 /**7229 * Random seed for reproducibility of the generation.7230 */7231 seed?: number;7232 /**7233 * Penalty for repeated tokens; higher values discourage repetition.7234 */7235 repetition_penalty?: number;7236 /**7237 * Decreases the likelihood of the model repeating the same lines verbatim.7238 */7239 frequency_penalty?: number;7240 /**7241 * Increases the likelihood of the model introducing new topics.7242 */7243 presence_penalty?: number;7244}7245type Ai_Cf_Qwen_Qwq_32B_Output = {7246 /**7247 * The generated text response from the model7248 */7249 response: string;7250 /**7251 * Usage statistics for the inference request7252 */7253 usage?: {7254 /**7255 * Total number of tokens in input7256 */7257 prompt_tokens?: number;7258 /**7259 * Total number of tokens in output7260 */7261 completion_tokens?: number;7262 /**7263 * Total number of input and output tokens7264 */7265 total_tokens?: number;7266 };7267 /**7268 * An array of tool calls requests made during the response generation7269 */7270 tool_calls?: {7271 /**7272 * The arguments passed to be passed to the tool call request7273 */7274 arguments?: object;7275 /**7276 * The name of the tool to be called7277 */7278 name?: string;7279 }[];7280};7281declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {7282 inputs: Ai_Cf_Qwen_Qwq_32B_Input;7283 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;7284}7285type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input = Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;7286interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {7287 /**7288 * The input text prompt for the model to generate a response.7289 */7290 prompt: string;7291 /**7292 * JSON schema that should be fulfilled for the response.7293 */7294 guided_json?: object;7295 /**7296 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7297 */7298 raw?: boolean;7299 /**7300 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7301 */7302 stream?: boolean;7303 /**7304 * The maximum number of tokens to generate in the response.7305 */7306 max_tokens?: number;7307 /**7308 * Controls the randomness of the output; higher values produce more random results.7309 */7310 temperature?: number;7311 /**7312 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7313 */7314 top_p?: number;7315 /**7316 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7317 */7318 top_k?: number;7319 /**7320 * Random seed for reproducibility of the generation.7321 */7322 seed?: number;7323 /**7324 * Penalty for repeated tokens; higher values discourage repetition.7325 */7326 repetition_penalty?: number;7327 /**7328 * Decreases the likelihood of the model repeating the same lines verbatim.7329 */7330 frequency_penalty?: number;7331 /**7332 * Increases the likelihood of the model introducing new topics.7333 */7334 presence_penalty?: number;7335}7336interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {7337 /**7338 * An array of message objects representing the conversation history.7339 */7340 messages: {7341 /**7342 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').7343 */7344 role?: string;7345 /**7346 * The tool call id. Must be supplied for tool calls for Mistral-3. If you don't know what to put here you can fall back to 0000000017347 */7348 tool_call_id?: string;7349 content?: string | {7350 /**7351 * Type of the content provided7352 */7353 type?: string;7354 text?: string;7355 image_url?: {7356 /**7357 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7358 */7359 url?: string;7360 };7361 }[] | {7362 /**7363 * Type of the content provided7364 */7365 type?: string;7366 text?: string;7367 image_url?: {7368 /**7369 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7370 */7371 url?: string;7372 };7373 };7374 }[];7375 functions?: {7376 name: string;7377 code: string;7378 }[];7379 /**7380 * A list of tools available for the assistant to use.7381 */7382 tools?: ({7383 /**7384 * The name of the tool. More descriptive the better.7385 */7386 name: string;7387 /**7388 * A brief description of what the tool does.7389 */7390 description: string;7391 /**7392 * Schema defining the parameters accepted by the tool.7393 */7394 parameters: {7395 /**7396 * The type of the parameters object (usually 'object').7397 */7398 type: string;7399 /**7400 * List of required parameter names.7401 */7402 required?: string[];7403 /**7404 * Definitions of each parameter.7405 */7406 properties: {7407 [k: string]: {7408 /**7409 * The data type of the parameter.7410 */7411 type: string;7412 /**7413 * A description of the expected parameter.7414 */7415 description: string;7416 };7417 };7418 };7419 } | {7420 /**7421 * Specifies the type of tool (e.g., 'function').7422 */7423 type: string;7424 /**7425 * Details of the function tool.7426 */7427 function: {7428 /**7429 * The name of the function.7430 */7431 name: string;7432 /**7433 * A brief description of what the function does.7434 */7435 description: string;7436 /**7437 * Schema defining the parameters accepted by the function.7438 */7439 parameters: {7440 /**7441 * The type of the parameters object (usually 'object').7442 */7443 type: string;7444 /**7445 * List of required parameter names.7446 */7447 required?: string[];7448 /**7449 * Definitions of each parameter.7450 */7451 properties: {7452 [k: string]: {7453 /**7454 * The data type of the parameter.7455 */7456 type: string;7457 /**7458 * A description of the expected parameter.7459 */7460 description: string;7461 };7462 };7463 };7464 };7465 })[];7466 /**7467 * JSON schema that should be fufilled for the response.7468 */7469 guided_json?: object;7470 /**7471 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7472 */7473 raw?: boolean;7474 /**7475 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7476 */7477 stream?: boolean;7478 /**7479 * The maximum number of tokens to generate in the response.7480 */7481 max_tokens?: number;7482 /**7483 * Controls the randomness of the output; higher values produce more random results.7484 */7485 temperature?: number;7486 /**7487 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7488 */7489 top_p?: number;7490 /**7491 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7492 */7493 top_k?: number;7494 /**7495 * Random seed for reproducibility of the generation.7496 */7497 seed?: number;7498 /**7499 * Penalty for repeated tokens; higher values discourage repetition.7500 */7501 repetition_penalty?: number;7502 /**7503 * Decreases the likelihood of the model repeating the same lines verbatim.7504 */7505 frequency_penalty?: number;7506 /**7507 * Increases the likelihood of the model introducing new topics.7508 */7509 presence_penalty?: number;7510}7511type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {7512 /**7513 * The generated text response from the model7514 */7515 response: string;7516 /**7517 * Usage statistics for the inference request7518 */7519 usage?: {7520 /**7521 * Total number of tokens in input7522 */7523 prompt_tokens?: number;7524 /**7525 * Total number of tokens in output7526 */7527 completion_tokens?: number;7528 /**7529 * Total number of input and output tokens7530 */7531 total_tokens?: number;7532 };7533 /**7534 * An array of tool calls requests made during the response generation7535 */7536 tool_calls?: {7537 /**7538 * The arguments passed to be passed to the tool call request7539 */7540 arguments?: object;7541 /**7542 * The name of the tool to be called7543 */7544 name?: string;7545 }[];7546};7547declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {7548 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;7549 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;7550}7551type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages;7552interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {7553 /**7554 * The input text prompt for the model to generate a response.7555 */7556 prompt: string;7557 /**7558 * JSON schema that should be fufilled for the response.7559 */7560 guided_json?: object;7561 /**7562 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7563 */7564 raw?: boolean;7565 /**7566 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7567 */7568 stream?: boolean;7569 /**7570 * The maximum number of tokens to generate in the response.7571 */7572 max_tokens?: number;7573 /**7574 * Controls the randomness of the output; higher values produce more random results.7575 */7576 temperature?: number;7577 /**7578 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7579 */7580 top_p?: number;7581 /**7582 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7583 */7584 top_k?: number;7585 /**7586 * Random seed for reproducibility of the generation.7587 */7588 seed?: number;7589 /**7590 * Penalty for repeated tokens; higher values discourage repetition.7591 */7592 repetition_penalty?: number;7593 /**7594 * Decreases the likelihood of the model repeating the same lines verbatim.7595 */7596 frequency_penalty?: number;7597 /**7598 * Increases the likelihood of the model introducing new topics.7599 */7600 presence_penalty?: number;7601}7602interface Ai_Cf_Google_Gemma_3_12B_It_Messages {7603 /**7604 * An array of message objects representing the conversation history.7605 */7606 messages: {7607 /**7608 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').7609 */7610 role?: string;7611 content?: string | {7612 /**7613 * Type of the content provided7614 */7615 type?: string;7616 text?: string;7617 image_url?: {7618 /**7619 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7620 */7621 url?: string;7622 };7623 }[];7624 }[];7625 functions?: {7626 name: string;7627 code: string;7628 }[];7629 /**7630 * A list of tools available for the assistant to use.7631 */7632 tools?: ({7633 /**7634 * The name of the tool. More descriptive the better.7635 */7636 name: string;7637 /**7638 * A brief description of what the tool does.7639 */7640 description: string;7641 /**7642 * Schema defining the parameters accepted by the tool.7643 */7644 parameters: {7645 /**7646 * The type of the parameters object (usually 'object').7647 */7648 type: string;7649 /**7650 * List of required parameter names.7651 */7652 required?: string[];7653 /**7654 * Definitions of each parameter.7655 */7656 properties: {7657 [k: string]: {7658 /**7659 * The data type of the parameter.7660 */7661 type: string;7662 /**7663 * A description of the expected parameter.7664 */7665 description: string;7666 };7667 };7668 };7669 } | {7670 /**7671 * Specifies the type of tool (e.g., 'function').7672 */7673 type: string;7674 /**7675 * Details of the function tool.7676 */7677 function: {7678 /**7679 * The name of the function.7680 */7681 name: string;7682 /**7683 * A brief description of what the function does.7684 */7685 description: string;7686 /**7687 * Schema defining the parameters accepted by the function.7688 */7689 parameters: {7690 /**7691 * The type of the parameters object (usually 'object').7692 */7693 type: string;7694 /**7695 * List of required parameter names.7696 */7697 required?: string[];7698 /**7699 * Definitions of each parameter.7700 */7701 properties: {7702 [k: string]: {7703 /**7704 * The data type of the parameter.7705 */7706 type: string;7707 /**7708 * A description of the expected parameter.7709 */7710 description: string;7711 };7712 };7713 };7714 };7715 })[];7716 /**7717 * JSON schema that should be fufilled for the response.7718 */7719 guided_json?: object;7720 /**7721 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7722 */7723 raw?: boolean;7724 /**7725 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7726 */7727 stream?: boolean;7728 /**7729 * The maximum number of tokens to generate in the response.7730 */7731 max_tokens?: number;7732 /**7733 * Controls the randomness of the output; higher values produce more random results.7734 */7735 temperature?: number;7736 /**7737 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7738 */7739 top_p?: number;7740 /**7741 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7742 */7743 top_k?: number;7744 /**7745 * Random seed for reproducibility of the generation.7746 */7747 seed?: number;7748 /**7749 * Penalty for repeated tokens; higher values discourage repetition.7750 */7751 repetition_penalty?: number;7752 /**7753 * Decreases the likelihood of the model repeating the same lines verbatim.7754 */7755 frequency_penalty?: number;7756 /**7757 * Increases the likelihood of the model introducing new topics.7758 */7759 presence_penalty?: number;7760}7761type Ai_Cf_Google_Gemma_3_12B_It_Output = {7762 /**7763 * The generated text response from the model7764 */7765 response: string;7766 /**7767 * Usage statistics for the inference request7768 */7769 usage?: {7770 /**7771 * Total number of tokens in input7772 */7773 prompt_tokens?: number;7774 /**7775 * Total number of tokens in output7776 */7777 completion_tokens?: number;7778 /**7779 * Total number of input and output tokens7780 */7781 total_tokens?: number;7782 };7783 /**7784 * An array of tool calls requests made during the response generation7785 */7786 tool_calls?: {7787 /**7788 * The arguments passed to be passed to the tool call request7789 */7790 arguments?: object;7791 /**7792 * The name of the tool to be called7793 */7794 name?: string;7795 }[];7796};7797declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {7798 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;7799 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;7800}7801type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input = Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;7802interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {7803 /**7804 * The input text prompt for the model to generate a response.7805 */7806 prompt: string;7807 /**7808 * JSON schema that should be fulfilled for the response.7809 */7810 guided_json?: object;7811 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;7812 /**7813 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7814 */7815 raw?: boolean;7816 /**7817 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7818 */7819 stream?: boolean;7820 /**7821 * The maximum number of tokens to generate in the response.7822 */7823 max_tokens?: number;7824 /**7825 * Controls the randomness of the output; higher values produce more random results.7826 */7827 temperature?: number;7828 /**7829 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.7830 */7831 top_p?: number;7832 /**7833 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.7834 */7835 top_k?: number;7836 /**7837 * Random seed for reproducibility of the generation.7838 */7839 seed?: number;7840 /**7841 * Penalty for repeated tokens; higher values discourage repetition.7842 */7843 repetition_penalty?: number;7844 /**7845 * Decreases the likelihood of the model repeating the same lines verbatim.7846 */7847 frequency_penalty?: number;7848 /**7849 * Increases the likelihood of the model introducing new topics.7850 */7851 presence_penalty?: number;7852}7853interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {7854 type?: "json_object" | "json_schema";7855 json_schema?: unknown;7856}7857interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {7858 /**7859 * An array of message objects representing the conversation history.7860 */7861 messages: {7862 /**7863 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').7864 */7865 role?: string;7866 /**7867 * The tool call id. If you don't know what to put here you can fall back to 0000000017868 */7869 tool_call_id?: string;7870 content?: string | {7871 /**7872 * Type of the content provided7873 */7874 type?: string;7875 text?: string;7876 image_url?: {7877 /**7878 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7879 */7880 url?: string;7881 };7882 }[] | {7883 /**7884 * Type of the content provided7885 */7886 type?: string;7887 text?: string;7888 image_url?: {7889 /**7890 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted7891 */7892 url?: string;7893 };7894 };7895 }[];7896 functions?: {7897 name: string;7898 code: string;7899 }[];7900 /**7901 * A list of tools available for the assistant to use.7902 */7903 tools?: ({7904 /**7905 * The name of the tool. More descriptive the better.7906 */7907 name: string;7908 /**7909 * A brief description of what the tool does.7910 */7911 description: string;7912 /**7913 * Schema defining the parameters accepted by the tool.7914 */7915 parameters: {7916 /**7917 * The type of the parameters object (usually 'object').7918 */7919 type: string;7920 /**7921 * List of required parameter names.7922 */7923 required?: string[];7924 /**7925 * Definitions of each parameter.7926 */7927 properties: {7928 [k: string]: {7929 /**7930 * The data type of the parameter.7931 */7932 type: string;7933 /**7934 * A description of the expected parameter.7935 */7936 description: string;7937 };7938 };7939 };7940 } | {7941 /**7942 * Specifies the type of tool (e.g., 'function').7943 */7944 type: string;7945 /**7946 * Details of the function tool.7947 */7948 function: {7949 /**7950 * The name of the function.7951 */7952 name: string;7953 /**7954 * A brief description of what the function does.7955 */7956 description: string;7957 /**7958 * Schema defining the parameters accepted by the function.7959 */7960 parameters: {7961 /**7962 * The type of the parameters object (usually 'object').7963 */7964 type: string;7965 /**7966 * List of required parameter names.7967 */7968 required?: string[];7969 /**7970 * Definitions of each parameter.7971 */7972 properties: {7973 [k: string]: {7974 /**7975 * The data type of the parameter.7976 */7977 type: string;7978 /**7979 * A description of the expected parameter.7980 */7981 description: string;7982 };7983 };7984 };7985 };7986 })[];7987 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;7988 /**7989 * JSON schema that should be fufilled for the response.7990 */7991 guided_json?: object;7992 /**7993 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.7994 */7995 raw?: boolean;7996 /**7997 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.7998 */7999 stream?: boolean;8000 /**8001 * The maximum number of tokens to generate in the response.8002 */8003 max_tokens?: number;8004 /**8005 * Controls the randomness of the output; higher values produce more random results.8006 */8007 temperature?: number;8008 /**8009 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8010 */8011 top_p?: number;8012 /**8013 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8014 */8015 top_k?: number;8016 /**8017 * Random seed for reproducibility of the generation.8018 */8019 seed?: number;8020 /**8021 * Penalty for repeated tokens; higher values discourage repetition.8022 */8023 repetition_penalty?: number;8024 /**8025 * Decreases the likelihood of the model repeating the same lines verbatim.8026 */8027 frequency_penalty?: number;8028 /**8029 * Increases the likelihood of the model introducing new topics.8030 */8031 presence_penalty?: number;8032}8033interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {8034 requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[];8035}8036interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {8037 /**8038 * The input text prompt for the model to generate a response.8039 */8040 prompt: string;8041 /**8042 * JSON schema that should be fulfilled for the response.8043 */8044 guided_json?: object;8045 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;8046 /**8047 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8048 */8049 raw?: boolean;8050 /**8051 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8052 */8053 stream?: boolean;8054 /**8055 * The maximum number of tokens to generate in the response.8056 */8057 max_tokens?: number;8058 /**8059 * Controls the randomness of the output; higher values produce more random results.8060 */8061 temperature?: number;8062 /**8063 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8064 */8065 top_p?: number;8066 /**8067 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8068 */8069 top_k?: number;8070 /**8071 * Random seed for reproducibility of the generation.8072 */8073 seed?: number;8074 /**8075 * Penalty for repeated tokens; higher values discourage repetition.8076 */8077 repetition_penalty?: number;8078 /**8079 * Decreases the likelihood of the model repeating the same lines verbatim.8080 */8081 frequency_penalty?: number;8082 /**8083 * Increases the likelihood of the model introducing new topics.8084 */8085 presence_penalty?: number;8086}8087interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {8088 /**8089 * An array of message objects representing the conversation history.8090 */8091 messages: {8092 /**8093 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').8094 */8095 role?: string;8096 /**8097 * The tool call id. If you don't know what to put here you can fall back to 0000000018098 */8099 tool_call_id?: string;8100 content?: string | {8101 /**8102 * Type of the content provided8103 */8104 type?: string;8105 text?: string;8106 image_url?: {8107 /**8108 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted8109 */8110 url?: string;8111 };8112 }[] | {8113 /**8114 * Type of the content provided8115 */8116 type?: string;8117 text?: string;8118 image_url?: {8119 /**8120 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted8121 */8122 url?: string;8123 };8124 };8125 }[];8126 functions?: {8127 name: string;8128 code: string;8129 }[];8130 /**8131 * A list of tools available for the assistant to use.8132 */8133 tools?: ({8134 /**8135 * The name of the tool. More descriptive the better.8136 */8137 name: string;8138 /**8139 * A brief description of what the tool does.8140 */8141 description: string;8142 /**8143 * Schema defining the parameters accepted by the tool.8144 */8145 parameters: {8146 /**8147 * The type of the parameters object (usually 'object').8148 */8149 type: string;8150 /**8151 * List of required parameter names.8152 */8153 required?: string[];8154 /**8155 * Definitions of each parameter.8156 */8157 properties: {8158 [k: string]: {8159 /**8160 * The data type of the parameter.8161 */8162 type: string;8163 /**8164 * A description of the expected parameter.8165 */8166 description: string;8167 };8168 };8169 };8170 } | {8171 /**8172 * Specifies the type of tool (e.g., 'function').8173 */8174 type: string;8175 /**8176 * Details of the function tool.8177 */8178 function: {8179 /**8180 * The name of the function.8181 */8182 name: string;8183 /**8184 * A brief description of what the function does.8185 */8186 description: string;8187 /**8188 * Schema defining the parameters accepted by the function.8189 */8190 parameters: {8191 /**8192 * The type of the parameters object (usually 'object').8193 */8194 type: string;8195 /**8196 * List of required parameter names.8197 */8198 required?: string[];8199 /**8200 * Definitions of each parameter.8201 */8202 properties: {8203 [k: string]: {8204 /**8205 * The data type of the parameter.8206 */8207 type: string;8208 /**8209 * A description of the expected parameter.8210 */8211 description: string;8212 };8213 };8214 };8215 };8216 })[];8217 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;8218 /**8219 * JSON schema that should be fufilled for the response.8220 */8221 guided_json?: object;8222 /**8223 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8224 */8225 raw?: boolean;8226 /**8227 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8228 */8229 stream?: boolean;8230 /**8231 * The maximum number of tokens to generate in the response.8232 */8233 max_tokens?: number;8234 /**8235 * Controls the randomness of the output; higher values produce more random results.8236 */8237 temperature?: number;8238 /**8239 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8240 */8241 top_p?: number;8242 /**8243 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8244 */8245 top_k?: number;8246 /**8247 * Random seed for reproducibility of the generation.8248 */8249 seed?: number;8250 /**8251 * Penalty for repeated tokens; higher values discourage repetition.8252 */8253 repetition_penalty?: number;8254 /**8255 * Decreases the likelihood of the model repeating the same lines verbatim.8256 */8257 frequency_penalty?: number;8258 /**8259 * Increases the likelihood of the model introducing new topics.8260 */8261 presence_penalty?: number;8262}8263type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {8264 /**8265 * The generated text response from the model8266 */8267 response: string;8268 /**8269 * Usage statistics for the inference request8270 */8271 usage?: {8272 /**8273 * Total number of tokens in input8274 */8275 prompt_tokens?: number;8276 /**8277 * Total number of tokens in output8278 */8279 completion_tokens?: number;8280 /**8281 * Total number of input and output tokens8282 */8283 total_tokens?: number;8284 };8285 /**8286 * An array of tool calls requests made during the response generation8287 */8288 tool_calls?: {8289 /**8290 * The tool call id.8291 */8292 id?: string;8293 /**8294 * Specifies the type of tool (e.g., 'function').8295 */8296 type?: string;8297 /**8298 * Details of the function tool.8299 */8300 function?: {8301 /**8302 * The name of the tool to be called8303 */8304 name?: string;8305 /**8306 * The arguments passed to be passed to the tool call request8307 */8308 arguments?: object;8309 };8310 }[];8311};8312declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {8313 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;8314 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;8315}8316type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;8317interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {8318 /**8319 * The input text prompt for the model to generate a response.8320 */8321 prompt: string;8322 /**8323 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.8324 */8325 lora?: string;8326 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;8327 /**8328 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8329 */8330 raw?: boolean;8331 /**8332 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8333 */8334 stream?: boolean;8335 /**8336 * The maximum number of tokens to generate in the response.8337 */8338 max_tokens?: number;8339 /**8340 * Controls the randomness of the output; higher values produce more random results.8341 */8342 temperature?: number;8343 /**8344 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8345 */8346 top_p?: number;8347 /**8348 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8349 */8350 top_k?: number;8351 /**8352 * Random seed for reproducibility of the generation.8353 */8354 seed?: number;8355 /**8356 * Penalty for repeated tokens; higher values discourage repetition.8357 */8358 repetition_penalty?: number;8359 /**8360 * Decreases the likelihood of the model repeating the same lines verbatim.8361 */8362 frequency_penalty?: number;8363 /**8364 * Increases the likelihood of the model introducing new topics.8365 */8366 presence_penalty?: number;8367}8368interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {8369 type?: "json_object" | "json_schema";8370 json_schema?: unknown;8371}8372interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {8373 /**8374 * An array of message objects representing the conversation history.8375 */8376 messages: {8377 /**8378 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').8379 */8380 role: string;8381 content: string | {8382 /**8383 * Type of the content (text)8384 */8385 type?: string;8386 /**8387 * Text content8388 */8389 text?: string;8390 }[];8391 }[];8392 functions?: {8393 name: string;8394 code: string;8395 }[];8396 /**8397 * A list of tools available for the assistant to use.8398 */8399 tools?: ({8400 /**8401 * The name of the tool. More descriptive the better.8402 */8403 name: string;8404 /**8405 * A brief description of what the tool does.8406 */8407 description: string;8408 /**8409 * Schema defining the parameters accepted by the tool.8410 */8411 parameters: {8412 /**8413 * The type of the parameters object (usually 'object').8414 */8415 type: string;8416 /**8417 * List of required parameter names.8418 */8419 required?: string[];8420 /**8421 * Definitions of each parameter.8422 */8423 properties: {8424 [k: string]: {8425 /**8426 * The data type of the parameter.8427 */8428 type: string;8429 /**8430 * A description of the expected parameter.8431 */8432 description: string;8433 };8434 };8435 };8436 } | {8437 /**8438 * Specifies the type of tool (e.g., 'function').8439 */8440 type: string;8441 /**8442 * Details of the function tool.8443 */8444 function: {8445 /**8446 * The name of the function.8447 */8448 name: string;8449 /**8450 * A brief description of what the function does.8451 */8452 description: string;8453 /**8454 * Schema defining the parameters accepted by the function.8455 */8456 parameters: {8457 /**8458 * The type of the parameters object (usually 'object').8459 */8460 type: string;8461 /**8462 * List of required parameter names.8463 */8464 required?: string[];8465 /**8466 * Definitions of each parameter.8467 */8468 properties: {8469 [k: string]: {8470 /**8471 * The data type of the parameter.8472 */8473 type: string;8474 /**8475 * A description of the expected parameter.8476 */8477 description: string;8478 };8479 };8480 };8481 };8482 })[];8483 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;8484 /**8485 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8486 */8487 raw?: boolean;8488 /**8489 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8490 */8491 stream?: boolean;8492 /**8493 * The maximum number of tokens to generate in the response.8494 */8495 max_tokens?: number;8496 /**8497 * Controls the randomness of the output; higher values produce more random results.8498 */8499 temperature?: number;8500 /**8501 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8502 */8503 top_p?: number;8504 /**8505 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8506 */8507 top_k?: number;8508 /**8509 * Random seed for reproducibility of the generation.8510 */8511 seed?: number;8512 /**8513 * Penalty for repeated tokens; higher values discourage repetition.8514 */8515 repetition_penalty?: number;8516 /**8517 * Decreases the likelihood of the model repeating the same lines verbatim.8518 */8519 frequency_penalty?: number;8520 /**8521 * Increases the likelihood of the model introducing new topics.8522 */8523 presence_penalty?: number;8524}8525interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {8526 type?: "json_object" | "json_schema";8527 json_schema?: unknown;8528}8529interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {8530 requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[];8531}8532interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {8533 /**8534 * The input text prompt for the model to generate a response.8535 */8536 prompt: string;8537 /**8538 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.8539 */8540 lora?: string;8541 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;8542 /**8543 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8544 */8545 raw?: boolean;8546 /**8547 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8548 */8549 stream?: boolean;8550 /**8551 * The maximum number of tokens to generate in the response.8552 */8553 max_tokens?: number;8554 /**8555 * Controls the randomness of the output; higher values produce more random results.8556 */8557 temperature?: number;8558 /**8559 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8560 */8561 top_p?: number;8562 /**8563 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8564 */8565 top_k?: number;8566 /**8567 * Random seed for reproducibility of the generation.8568 */8569 seed?: number;8570 /**8571 * Penalty for repeated tokens; higher values discourage repetition.8572 */8573 repetition_penalty?: number;8574 /**8575 * Decreases the likelihood of the model repeating the same lines verbatim.8576 */8577 frequency_penalty?: number;8578 /**8579 * Increases the likelihood of the model introducing new topics.8580 */8581 presence_penalty?: number;8582}8583interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {8584 type?: "json_object" | "json_schema";8585 json_schema?: unknown;8586}8587interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {8588 /**8589 * An array of message objects representing the conversation history.8590 */8591 messages: {8592 /**8593 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').8594 */8595 role: string;8596 content: string | {8597 /**8598 * Type of the content (text)8599 */8600 type?: string;8601 /**8602 * Text content8603 */8604 text?: string;8605 }[];8606 }[];8607 functions?: {8608 name: string;8609 code: string;8610 }[];8611 /**8612 * A list of tools available for the assistant to use.8613 */8614 tools?: ({8615 /**8616 * The name of the tool. More descriptive the better.8617 */8618 name: string;8619 /**8620 * A brief description of what the tool does.8621 */8622 description: string;8623 /**8624 * Schema defining the parameters accepted by the tool.8625 */8626 parameters: {8627 /**8628 * The type of the parameters object (usually 'object').8629 */8630 type: string;8631 /**8632 * List of required parameter names.8633 */8634 required?: string[];8635 /**8636 * Definitions of each parameter.8637 */8638 properties: {8639 [k: string]: {8640 /**8641 * The data type of the parameter.8642 */8643 type: string;8644 /**8645 * A description of the expected parameter.8646 */8647 description: string;8648 };8649 };8650 };8651 } | {8652 /**8653 * Specifies the type of tool (e.g., 'function').8654 */8655 type: string;8656 /**8657 * Details of the function tool.8658 */8659 function: {8660 /**8661 * The name of the function.8662 */8663 name: string;8664 /**8665 * A brief description of what the function does.8666 */8667 description: string;8668 /**8669 * Schema defining the parameters accepted by the function.8670 */8671 parameters: {8672 /**8673 * The type of the parameters object (usually 'object').8674 */8675 type: string;8676 /**8677 * List of required parameter names.8678 */8679 required?: string[];8680 /**8681 * Definitions of each parameter.8682 */8683 properties: {8684 [k: string]: {8685 /**8686 * The data type of the parameter.8687 */8688 type: string;8689 /**8690 * A description of the expected parameter.8691 */8692 description: string;8693 };8694 };8695 };8696 };8697 })[];8698 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;8699 /**8700 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.8701 */8702 raw?: boolean;8703 /**8704 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.8705 */8706 stream?: boolean;8707 /**8708 * The maximum number of tokens to generate in the response.8709 */8710 max_tokens?: number;8711 /**8712 * Controls the randomness of the output; higher values produce more random results.8713 */8714 temperature?: number;8715 /**8716 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.8717 */8718 top_p?: number;8719 /**8720 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.8721 */8722 top_k?: number;8723 /**8724 * Random seed for reproducibility of the generation.8725 */8726 seed?: number;8727 /**8728 * Penalty for repeated tokens; higher values discourage repetition.8729 */8730 repetition_penalty?: number;8731 /**8732 * Decreases the likelihood of the model repeating the same lines verbatim.8733 */8734 frequency_penalty?: number;8735 /**8736 * Increases the likelihood of the model introducing new topics.8737 */8738 presence_penalty?: number;8739}8740interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {8741 type?: "json_object" | "json_schema";8742 json_schema?: unknown;8743}8744type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output = Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response | string | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;8745interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {8746 /**8747 * Unique identifier for the completion8748 */8749 id?: string;8750 /**8751 * Object type identifier8752 */8753 object?: "chat.completion";8754 /**8755 * Unix timestamp of when the completion was created8756 */8757 created?: number;8758 /**8759 * Model used for the completion8760 */8761 model?: string;8762 /**8763 * List of completion choices8764 */8765 choices?: {8766 /**8767 * Index of the choice in the list8768 */8769 index?: number;8770 /**8771 * The message generated by the model8772 */8773 message?: {8774 /**8775 * Role of the message author8776 */8777 role: string;8778 /**8779 * The content of the message8780 */8781 content: string;8782 /**8783 * Internal reasoning content (if available)8784 */8785 reasoning_content?: string;8786 /**8787 * Tool calls made by the assistant8788 */8789 tool_calls?: {8790 /**8791 * Unique identifier for the tool call8792 */8793 id: string;8794 /**8795 * Type of tool call8796 */8797 type: "function";8798 function: {8799 /**8800 * Name of the function to call8801 */8802 name: string;8803 /**8804 * JSON string of arguments for the function8805 */8806 arguments: string;8807 };8808 }[];8809 };8810 /**8811 * Reason why the model stopped generating8812 */8813 finish_reason?: string;8814 /**8815 * Stop reason (may be null)8816 */8817 stop_reason?: string | null;8818 /**8819 * Log probabilities (if requested)8820 */8821 logprobs?: {} | null;8822 }[];8823 /**8824 * Usage statistics for the inference request8825 */8826 usage?: {8827 /**8828 * Total number of tokens in input8829 */8830 prompt_tokens?: number;8831 /**8832 * Total number of tokens in output8833 */8834 completion_tokens?: number;8835 /**8836 * Total number of input and output tokens8837 */8838 total_tokens?: number;8839 };8840 /**8841 * Log probabilities for the prompt (if requested)8842 */8843 prompt_logprobs?: {} | null;8844}8845interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {8846 /**8847 * Unique identifier for the completion8848 */8849 id?: string;8850 /**8851 * Object type identifier8852 */8853 object?: "text_completion";8854 /**8855 * Unix timestamp of when the completion was created8856 */8857 created?: number;8858 /**8859 * Model used for the completion8860 */8861 model?: string;8862 /**8863 * List of completion choices8864 */8865 choices?: {8866 /**8867 * Index of the choice in the list8868 */8869 index: number;8870 /**8871 * The generated text completion8872 */8873 text: string;8874 /**8875 * Reason why the model stopped generating8876 */8877 finish_reason: string;8878 /**8879 * Stop reason (may be null)8880 */8881 stop_reason?: string | null;8882 /**8883 * Log probabilities (if requested)8884 */8885 logprobs?: {} | null;8886 /**8887 * Log probabilities for the prompt (if requested)8888 */8889 prompt_logprobs?: {} | null;8890 }[];8891 /**8892 * Usage statistics for the inference request8893 */8894 usage?: {8895 /**8896 * Total number of tokens in input8897 */8898 prompt_tokens?: number;8899 /**8900 * Total number of tokens in output8901 */8902 completion_tokens?: number;8903 /**8904 * Total number of input and output tokens8905 */8906 total_tokens?: number;8907 };8908}8909interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {8910 /**8911 * The async request id that can be used to obtain the results.8912 */8913 request_id?: string;8914}8915declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {8916 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;8917 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;8918}8919interface Ai_Cf_Deepgram_Nova_3_Input {8920 audio: {8921 body: object;8922 contentType: string;8923 };8924 /**8925 * Sets how the model will interpret strings submitted to the custom_topic param. When strict, the model will only return topics submitted using the custom_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom_topic param.8926 */8927 custom_topic_mode?: "extended" | "strict";8928 /**8929 * Custom topics you want the model to detect within your input audio or text if present Submit up to 1008930 */8931 custom_topic?: string;8932 /**8933 * Sets how the model will interpret intents submitted to the custom_intent param. When strict, the model will only return intents submitted using the custom_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom_intents param8934 */8935 custom_intent_mode?: "extended" | "strict";8936 /**8937 * Custom intents you want the model to detect within your input audio if present8938 */8939 custom_intent?: string;8940 /**8941 * Identifies and extracts key entities from content in submitted audio8942 */8943 detect_entities?: boolean;8944 /**8945 * Identifies the dominant language spoken in submitted audio8946 */8947 detect_language?: boolean;8948 /**8949 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 08950 */8951 diarize?: boolean;8952 /**8953 * Identify and extract key entities from content in submitted audio8954 */8955 dictation?: boolean;8956 /**8957 * Specify the expected encoding of your submitted audio8958 */8959 encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729";8960 /**8961 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing8962 */8963 extra?: string;8964 /**8965 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'8966 */8967 filler_words?: boolean;8968 /**8969 * Key term prompting can boost or suppress specialized terminology and brands.8970 */8971 keyterm?: string;8972 /**8973 * Keywords can boost or suppress specialized terminology and brands.8974 */8975 keywords?: string;8976 /**8977 * The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.8978 */8979 language?: string;8980 /**8981 * Spoken measurements will be converted to their corresponding abbreviations.8982 */8983 measurements?: boolean;8984 /**8985 * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.8986 */8987 mip_opt_out?: boolean;8988 /**8989 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio8990 */8991 mode?: "general" | "medical" | "finance";8992 /**8993 * Transcribe each audio channel independently.8994 */8995 multichannel?: boolean;8996 /**8997 * Numerals converts numbers from written format to numerical format.8998 */8999 numerals?: boolean;9000 /**9001 * Splits audio into paragraphs to improve transcript readability.9002 */9003 paragraphs?: boolean;9004 /**9005 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.9006 */9007 profanity_filter?: boolean;9008 /**9009 * Add punctuation and capitalization to the transcript.9010 */9011 punctuate?: boolean;9012 /**9013 * Redaction removes sensitive information from your transcripts.9014 */9015 redact?: string;9016 /**9017 * Search for terms or phrases in submitted audio and replaces them.9018 */9019 replace?: string;9020 /**9021 * Search for terms or phrases in submitted audio.9022 */9023 search?: string;9024 /**9025 * Recognizes the sentiment throughout a transcript or text.9026 */9027 sentiment?: boolean;9028 /**9029 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.9030 */9031 smart_format?: boolean;9032 /**9033 * Detect topics throughout a transcript or text.9034 */9035 topics?: boolean;9036 /**9037 * Segments speech into meaningful semantic units.9038 */9039 utterances?: boolean;9040 /**9041 * Seconds to wait before detecting a pause between words in submitted audio.9042 */9043 utt_split?: number;9044 /**9045 * The number of channels in the submitted audio9046 */9047 channels?: number;9048 /**9049 * Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.9050 */9051 interim_results?: boolean;9052 /**9053 * Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing9054 */9055 endpointing?: string;9056 /**9057 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.9058 */9059 vad_events?: boolean;9060 /**9061 * Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results. Note: Supported only for webosockets.9062 */9063 utterance_end_ms?: boolean;9064}9065interface Ai_Cf_Deepgram_Nova_3_Output {9066 results?: {9067 channels?: {9068 alternatives?: {9069 confidence?: number;9070 transcript?: string;9071 words?: {9072 confidence?: number;9073 end?: number;9074 start?: number;9075 word?: string;9076 }[];9077 }[];9078 }[];9079 summary?: {9080 result?: string;9081 short?: string;9082 };9083 sentiments?: {9084 segments?: {9085 text?: string;9086 start_word?: number;9087 end_word?: number;9088 sentiment?: string;9089 sentiment_score?: number;9090 }[];9091 average?: {9092 sentiment?: string;9093 sentiment_score?: number;9094 };9095 };9096 };9097}9098declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {9099 inputs: Ai_Cf_Deepgram_Nova_3_Input;9100 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;9101}9102interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {9103 queries?: string | string[];9104 /**9105 * Optional instruction for the task9106 */9107 instruction?: string;9108 documents?: string | string[];9109 text?: string | string[];9110}9111interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {9112 data?: number[][];9113 shape?: number[];9114}9115declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {9116 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;9117 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;9118}9119type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = {9120 /**9121 * readable stream with audio data and content-type specified for that data9122 */9123 audio: {9124 body: object;9125 contentType: string;9126 };9127 /**9128 * type of data PCM data that's sent to the inference server as raw array9129 */9130 dtype?: "uint8" | "float32" | "float64";9131} | {9132 /**9133 * base64 encoded audio data9134 */9135 audio: string;9136 /**9137 * type of data PCM data that's sent to the inference server as raw array9138 */9139 dtype?: "uint8" | "float32" | "float64";9140};9141interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {9142 /**9143 * if true, end-of-turn was detected9144 */9145 is_complete?: boolean;9146 /**9147 * probability of the end-of-turn detection9148 */9149 probability?: number;9150}9151declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {9152 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;9153 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;9154}9155declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {9156 inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;9157 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;9158}9159declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {9160 inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>;9161 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;9162}9163interface Ai_Cf_Leonardo_Phoenix_1_0_Input {9164 /**9165 * A text description of the image you want to generate.9166 */9167 prompt: string;9168 /**9169 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt9170 */9171 guidance?: number;9172 /**9173 * Random seed for reproducibility of the image generation9174 */9175 seed?: number;9176 /**9177 * The height of the generated image in pixels9178 */9179 height?: number;9180 /**9181 * The width of the generated image in pixels9182 */9183 width?: number;9184 /**9185 * The number of diffusion steps; higher values can improve quality but take longer9186 */9187 num_steps?: number;9188 /**9189 * Specify what to exclude from the generated images9190 */9191 negative_prompt?: string;9192}9193/**9194 * The generated image in JPEG format9195 */9196type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;9197declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {9198 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;9199 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;9200}9201interface Ai_Cf_Leonardo_Lucid_Origin_Input {9202 /**9203 * A text description of the image you want to generate.9204 */9205 prompt: string;9206 /**9207 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt9208 */9209 guidance?: number;9210 /**9211 * Random seed for reproducibility of the image generation9212 */9213 seed?: number;9214 /**9215 * The height of the generated image in pixels9216 */9217 height?: number;9218 /**9219 * The width of the generated image in pixels9220 */9221 width?: number;9222 /**9223 * The number of diffusion steps; higher values can improve quality but take longer9224 */9225 num_steps?: number;9226 /**9227 * The number of diffusion steps; higher values can improve quality but take longer9228 */9229 steps?: number;9230}9231interface Ai_Cf_Leonardo_Lucid_Origin_Output {9232 /**9233 * The generated image in Base64 format.9234 */9235 image?: string;9236}9237declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {9238 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;9239 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;9240}9241interface Ai_Cf_Deepgram_Aura_1_Input {9242 /**9243 * Speaker used to produce the audio.9244 */9245 speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella";9246 /**9247 * Encoding of the output audio.9248 */9249 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";9250 /**9251 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..9252 */9253 container?: "none" | "wav" | "ogg";9254 /**9255 * The text content to be converted to speech9256 */9257 text: string;9258 /**9259 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable9260 */9261 sample_rate?: number;9262 /**9263 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.9264 */9265 bit_rate?: number;9266}9267/**9268 * The generated audio in MP3 format9269 */9270type Ai_Cf_Deepgram_Aura_1_Output = string;9271declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {9272 inputs: Ai_Cf_Deepgram_Aura_1_Input;9273 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;9274}9275interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {9276 /**9277 * Input text to translate. Can be a single string or a list of strings.9278 */9279 text: string | string[];9280 /**9281 * Target langauge to translate to9282 */9283 target_language: "asm_Beng" | "awa_Deva" | "ben_Beng" | "bho_Deva" | "brx_Deva" | "doi_Deva" | "eng_Latn" | "gom_Deva" | "gon_Deva" | "guj_Gujr" | "hin_Deva" | "hne_Deva" | "kan_Knda" | "kas_Arab" | "kas_Deva" | "kha_Latn" | "lus_Latn" | "mag_Deva" | "mai_Deva" | "mal_Mlym" | "mar_Deva" | "mni_Beng" | "mni_Mtei" | "npi_Deva" | "ory_Orya" | "pan_Guru" | "san_Deva" | "sat_Olck" | "snd_Arab" | "snd_Deva" | "tam_Taml" | "tel_Telu" | "urd_Arab" | "unr_Deva";9284}9285interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {9286 /**9287 * Translated texts9288 */9289 translations: string[];9290}9291declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {9292 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;9293 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;9294}9295type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;9296interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {9297 /**9298 * The input text prompt for the model to generate a response.9299 */9300 prompt: string;9301 /**9302 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.9303 */9304 lora?: string;9305 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;9306 /**9307 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.9308 */9309 raw?: boolean;9310 /**9311 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.9312 */9313 stream?: boolean;9314 /**9315 * The maximum number of tokens to generate in the response.9316 */9317 max_tokens?: number;9318 /**9319 * Controls the randomness of the output; higher values produce more random results.9320 */9321 temperature?: number;9322 /**9323 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.9324 */9325 top_p?: number;9326 /**9327 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.9328 */9329 top_k?: number;9330 /**9331 * Random seed for reproducibility of the generation.9332 */9333 seed?: number;9334 /**9335 * Penalty for repeated tokens; higher values discourage repetition.9336 */9337 repetition_penalty?: number;9338 /**9339 * Decreases the likelihood of the model repeating the same lines verbatim.9340 */9341 frequency_penalty?: number;9342 /**9343 * Increases the likelihood of the model introducing new topics.9344 */9345 presence_penalty?: number;9346}9347interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {9348 type?: "json_object" | "json_schema";9349 json_schema?: unknown;9350}9351interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {9352 /**9353 * An array of message objects representing the conversation history.9354 */9355 messages: {9356 /**9357 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').9358 */9359 role: string;9360 content: string | {9361 /**9362 * Type of the content (text)9363 */9364 type?: string;9365 /**9366 * Text content9367 */9368 text?: string;9369 }[];9370 }[];9371 functions?: {9372 name: string;9373 code: string;9374 }[];9375 /**9376 * A list of tools available for the assistant to use.9377 */9378 tools?: ({9379 /**9380 * The name of the tool. More descriptive the better.9381 */9382 name: string;9383 /**9384 * A brief description of what the tool does.9385 */9386 description: string;9387 /**9388 * Schema defining the parameters accepted by the tool.9389 */9390 parameters: {9391 /**9392 * The type of the parameters object (usually 'object').9393 */9394 type: string;9395 /**9396 * List of required parameter names.9397 */9398 required?: string[];9399 /**9400 * Definitions of each parameter.9401 */9402 properties: {9403 [k: string]: {9404 /**9405 * The data type of the parameter.9406 */9407 type: string;9408 /**9409 * A description of the expected parameter.9410 */9411 description: string;9412 };9413 };9414 };9415 } | {9416 /**9417 * Specifies the type of tool (e.g., 'function').9418 */9419 type: string;9420 /**9421 * Details of the function tool.9422 */9423 function: {9424 /**9425 * The name of the function.9426 */9427 name: string;9428 /**9429 * A brief description of what the function does.9430 */9431 description: string;9432 /**9433 * Schema defining the parameters accepted by the function.9434 */9435 parameters: {9436 /**9437 * The type of the parameters object (usually 'object').9438 */9439 type: string;9440 /**9441 * List of required parameter names.9442 */9443 required?: string[];9444 /**9445 * Definitions of each parameter.9446 */9447 properties: {9448 [k: string]: {9449 /**9450 * The data type of the parameter.9451 */9452 type: string;9453 /**9454 * A description of the expected parameter.9455 */9456 description: string;9457 };9458 };9459 };9460 };9461 })[];9462 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;9463 /**9464 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.9465 */9466 raw?: boolean;9467 /**9468 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.9469 */9470 stream?: boolean;9471 /**9472 * The maximum number of tokens to generate in the response.9473 */9474 max_tokens?: number;9475 /**9476 * Controls the randomness of the output; higher values produce more random results.9477 */9478 temperature?: number;9479 /**9480 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.9481 */9482 top_p?: number;9483 /**9484 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.9485 */9486 top_k?: number;9487 /**9488 * Random seed for reproducibility of the generation.9489 */9490 seed?: number;9491 /**9492 * Penalty for repeated tokens; higher values discourage repetition.9493 */9494 repetition_penalty?: number;9495 /**9496 * Decreases the likelihood of the model repeating the same lines verbatim.9497 */9498 frequency_penalty?: number;9499 /**9500 * Increases the likelihood of the model introducing new topics.9501 */9502 presence_penalty?: number;9503}9504interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {9505 type?: "json_object" | "json_schema";9506 json_schema?: unknown;9507}9508interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {9509 requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[];9510}9511interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {9512 /**9513 * The input text prompt for the model to generate a response.9514 */9515 prompt: string;9516 /**9517 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.9518 */9519 lora?: string;9520 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;9521 /**9522 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.9523 */9524 raw?: boolean;9525 /**9526 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.9527 */9528 stream?: boolean;9529 /**9530 * The maximum number of tokens to generate in the response.9531 */9532 max_tokens?: number;9533 /**9534 * Controls the randomness of the output; higher values produce more random results.9535 */9536 temperature?: number;9537 /**9538 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.9539 */9540 top_p?: number;9541 /**9542 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.9543 */9544 top_k?: number;9545 /**9546 * Random seed for reproducibility of the generation.9547 */9548 seed?: number;9549 /**9550 * Penalty for repeated tokens; higher values discourage repetition.9551 */9552 repetition_penalty?: number;9553 /**9554 * Decreases the likelihood of the model repeating the same lines verbatim.9555 */9556 frequency_penalty?: number;9557 /**9558 * Increases the likelihood of the model introducing new topics.9559 */9560 presence_penalty?: number;9561}9562interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {9563 type?: "json_object" | "json_schema";9564 json_schema?: unknown;9565}9566interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {9567 /**9568 * An array of message objects representing the conversation history.9569 */9570 messages: {9571 /**9572 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').9573 */9574 role: string;9575 content: string | {9576 /**9577 * Type of the content (text)9578 */9579 type?: string;9580 /**9581 * Text content9582 */9583 text?: string;9584 }[];9585 }[];9586 functions?: {9587 name: string;9588 code: string;9589 }[];9590 /**9591 * A list of tools available for the assistant to use.9592 */9593 tools?: ({9594 /**9595 * The name of the tool. More descriptive the better.9596 */9597 name: string;9598 /**9599 * A brief description of what the tool does.9600 */9601 description: string;9602 /**9603 * Schema defining the parameters accepted by the tool.9604 */9605 parameters: {9606 /**9607 * The type of the parameters object (usually 'object').9608 */9609 type: string;9610 /**9611 * List of required parameter names.9612 */9613 required?: string[];9614 /**9615 * Definitions of each parameter.9616 */9617 properties: {9618 [k: string]: {9619 /**9620 * The data type of the parameter.9621 */9622 type: string;9623 /**9624 * A description of the expected parameter.9625 */9626 description: string;9627 };9628 };9629 };9630 } | {9631 /**9632 * Specifies the type of tool (e.g., 'function').9633 */9634 type: string;9635 /**9636 * Details of the function tool.9637 */9638 function: {9639 /**9640 * The name of the function.9641 */9642 name: string;9643 /**9644 * A brief description of what the function does.9645 */9646 description: string;9647 /**9648 * Schema defining the parameters accepted by the function.9649 */9650 parameters: {9651 /**9652 * The type of the parameters object (usually 'object').9653 */9654 type: string;9655 /**9656 * List of required parameter names.9657 */9658 required?: string[];9659 /**9660 * Definitions of each parameter.9661 */9662 properties: {9663 [k: string]: {9664 /**9665 * The data type of the parameter.9666 */9667 type: string;9668 /**9669 * A description of the expected parameter.9670 */9671 description: string;9672 };9673 };9674 };9675 };9676 })[];9677 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;9678 /**9679 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.9680 */9681 raw?: boolean;9682 /**9683 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.9684 */9685 stream?: boolean;9686 /**9687 * The maximum number of tokens to generate in the response.9688 */9689 max_tokens?: number;9690 /**9691 * Controls the randomness of the output; higher values produce more random results.9692 */9693 temperature?: number;9694 /**9695 * Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.9696 */9697 top_p?: number;9698 /**9699 * Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.9700 */9701 top_k?: number;9702 /**9703 * Random seed for reproducibility of the generation.9704 */9705 seed?: number;9706 /**9707 * Penalty for repeated tokens; higher values discourage repetition.9708 */9709 repetition_penalty?: number;9710 /**9711 * Decreases the likelihood of the model repeating the same lines verbatim.9712 */9713 frequency_penalty?: number;9714 /**9715 * Increases the likelihood of the model introducing new topics.9716 */9717 presence_penalty?: number;9718}9719interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {9720 type?: "json_object" | "json_schema";9721 json_schema?: unknown;9722}9723type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output = Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response | string | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;9724interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {9725 /**9726 * Unique identifier for the completion9727 */9728 id?: string;9729 /**9730 * Object type identifier9731 */9732 object?: "chat.completion";9733 /**9734 * Unix timestamp of when the completion was created9735 */9736 created?: number;9737 /**9738 * Model used for the completion9739 */9740 model?: string;9741 /**9742 * List of completion choices9743 */9744 choices?: {9745 /**9746 * Index of the choice in the list9747 */9748 index?: number;9749 /**9750 * The message generated by the model9751 */9752 message?: {9753 /**9754 * Role of the message author9755 */9756 role: string;9757 /**9758 * The content of the message9759 */9760 content: string;9761 /**9762 * Internal reasoning content (if available)9763 */9764 reasoning_content?: string;9765 /**9766 * Tool calls made by the assistant9767 */9768 tool_calls?: {9769 /**9770 * Unique identifier for the tool call9771 */9772 id: string;9773 /**9774 * Type of tool call9775 */9776 type: "function";9777 function: {9778 /**9779 * Name of the function to call9780 */9781 name: string;9782 /**9783 * JSON string of arguments for the function9784 */9785 arguments: string;9786 };9787 }[];9788 };9789 /**9790 * Reason why the model stopped generating9791 */9792 finish_reason?: string;9793 /**9794 * Stop reason (may be null)9795 */9796 stop_reason?: string | null;9797 /**9798 * Log probabilities (if requested)9799 */9800 logprobs?: {} | null;9801 }[];9802 /**9803 * Usage statistics for the inference request9804 */9805 usage?: {9806 /**9807 * Total number of tokens in input9808 */9809 prompt_tokens?: number;9810 /**9811 * Total number of tokens in output9812 */9813 completion_tokens?: number;9814 /**9815 * Total number of input and output tokens9816 */9817 total_tokens?: number;9818 };9819 /**9820 * Log probabilities for the prompt (if requested)9821 */9822 prompt_logprobs?: {} | null;9823}9824interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {9825 /**9826 * Unique identifier for the completion9827 */9828 id?: string;9829 /**9830 * Object type identifier9831 */9832 object?: "text_completion";9833 /**9834 * Unix timestamp of when the completion was created9835 */9836 created?: number;9837 /**9838 * Model used for the completion9839 */9840 model?: string;9841 /**9842 * List of completion choices9843 */9844 choices?: {9845 /**9846 * Index of the choice in the list9847 */9848 index: number;9849 /**9850 * The generated text completion9851 */9852 text: string;9853 /**9854 * Reason why the model stopped generating9855 */9856 finish_reason: string;9857 /**9858 * Stop reason (may be null)9859 */9860 stop_reason?: string | null;9861 /**9862 * Log probabilities (if requested)9863 */9864 logprobs?: {} | null;9865 /**9866 * Log probabilities for the prompt (if requested)9867 */9868 prompt_logprobs?: {} | null;9869 }[];9870 /**9871 * Usage statistics for the inference request9872 */9873 usage?: {9874 /**9875 * Total number of tokens in input9876 */9877 prompt_tokens?: number;9878 /**9879 * Total number of tokens in output9880 */9881 completion_tokens?: number;9882 /**9883 * Total number of input and output tokens9884 */9885 total_tokens?: number;9886 };9887}9888interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {9889 /**9890 * The async request id that can be used to obtain the results.9891 */9892 request_id?: string;9893}9894declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {9895 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;9896 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;9897}9898interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {9899 /**9900 * Input text to embed. Can be a single string or a list of strings.9901 */9902 text: string | string[];9903}9904interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {9905 /**9906 * Embedding vectors, where each vector is a list of floats.9907 */9908 data: number[][];9909 /**9910 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].9911 *9912 * @minItems 29913 * @maxItems 29914 */9915 shape: [9916 number,9917 number9918 ];9919}9920declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {9921 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;9922 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;9923}9924interface Ai_Cf_Deepgram_Flux_Input {9925 /**9926 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.9927 */9928 encoding: "linear16";9929 /**9930 * Sample rate of the audio stream in Hz.9931 */9932 sample_rate: string;9933 /**9934 * End-of-turn confidence required to fire an eager end-of-turn event. When set, enables EagerEndOfTurn and TurnResumed events. Valid Values 0.3 - 0.9.9935 */9936 eager_eot_threshold?: string;9937 /**9938 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.9939 */9940 eot_threshold?: string;9941 /**9942 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.9943 */9944 eot_timeout_ms?: string;9945 /**9946 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.9947 */9948 keyterm?: string;9949 /**9950 * Opts out requests from the Deepgram Model Improvement Program. Refer to Deepgram Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip9951 */9952 mip_opt_out?: "true" | "false";9953 /**9954 * Label your requests for the purpose of identification during usage reporting9955 */9956 tag?: string;9957}9958/**9959 * Output will be returned as websocket messages.9960 */9961interface Ai_Cf_Deepgram_Flux_Output {9962 /**9963 * The unique identifier of the request (uuid)9964 */9965 request_id?: string;9966 /**9967 * Starts at 0 and increments for each message the server sends to the client.9968 */9969 sequence_id?: number;9970 /**9971 * The type of event being reported.9972 */9973 event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn";9974 /**9975 * The index of the current turn9976 */9977 turn_index?: number;9978 /**9979 * Start time in seconds of the audio range that was transcribed9980 */9981 audio_window_start?: number;9982 /**9983 * End time in seconds of the audio range that was transcribed9984 */9985 audio_window_end?: number;9986 /**9987 * Text that was said over the course of the current turn9988 */9989 transcript?: string;9990 /**9991 * The words in the transcript9992 */9993 words?: {9994 /**9995 * The individual punctuated, properly-cased word from the transcript9996 */9997 word: string;9998 /**9999 * Confidence that this word was transcribed correctly10000 */10001 confidence: number;10002 }[];10003 /**10004 * Confidence that no more speech is coming in this turn10005 */10006 end_of_turn_confidence?: number;10007}10008declare abstract class Base_Ai_Cf_Deepgram_Flux {10009 inputs: Ai_Cf_Deepgram_Flux_Input;10010 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;10011}10012interface Ai_Cf_Deepgram_Aura_2_En_Input {10013 /**10014 * Speaker used to produce the audio.10015 */10016 speaker?: "amalthea" | "andromeda" | "apollo" | "arcas" | "aries" | "asteria" | "athena" | "atlas" | "aurora" | "callista" | "cora" | "cordelia" | "delia" | "draco" | "electra" | "harmonia" | "helena" | "hera" | "hermes" | "hyperion" | "iris" | "janus" | "juno" | "jupiter" | "luna" | "mars" | "minerva" | "neptune" | "odysseus" | "ophelia" | "orion" | "orpheus" | "pandora" | "phoebe" | "pluto" | "saturn" | "thalia" | "theia" | "vesta" | "zeus";10017 /**10018 * Encoding of the output audio.10019 */10020 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";10021 /**10022 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..10023 */10024 container?: "none" | "wav" | "ogg";10025 /**10026 * The text content to be converted to speech10027 */10028 text: string;10029 /**10030 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable10031 */10032 sample_rate?: number;10033 /**10034 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.10035 */10036 bit_rate?: number;10037}10038/**10039 * The generated audio in MP3 format10040 */10041type Ai_Cf_Deepgram_Aura_2_En_Output = string;10042declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {10043 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;10044 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;10045}10046interface Ai_Cf_Deepgram_Aura_2_Es_Input {10047 /**10048 * Speaker used to produce the audio.10049 */10050 speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier";10051 /**10052 * Encoding of the output audio.10053 */10054 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";10055 /**10056 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..10057 */10058 container?: "none" | "wav" | "ogg";10059 /**10060 * The text content to be converted to speech10061 */10062 text: string;10063 /**10064 * Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable10065 */10066 sample_rate?: number;10067 /**10068 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.10069 */10070 bit_rate?: number;10071}10072/**10073 * The generated audio in MP3 format10074 */10075type Ai_Cf_Deepgram_Aura_2_Es_Output = string;10076declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {10077 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;10078 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;10079}10080interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {10081 multipart: {10082 body?: object;10083 contentType?: string;10084 };10085}10086interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {10087 /**10088 * Generated image as Base64 string.10089 */10090 image?: string;10091}10092declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {10093 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;10094 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;10095}10096interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {10097 multipart: {10098 body?: object;10099 contentType?: string;10100 };10101}10102interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {10103 /**10104 * Generated image as Base64 string.10105 */10106 image?: string;10107}10108declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {10109 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;10110 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;10111}10112interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {10113 multipart: {10114 body?: object;10115 contentType?: string;10116 };10117}10118interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {10119 /**10120 * Generated image as Base64 string.10121 */10122 image?: string;10123}10124declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {10125 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;10126 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;10127}10128declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {10129 inputs: ChatCompletionsInput;10130 postProcessedOutputs: ChatCompletionsOutput;10131}10132declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {10133 inputs: ChatCompletionsInput;10134 postProcessedOutputs: ChatCompletionsOutput;10135}10136declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 {10137 inputs: ChatCompletionsInput;10138 postProcessedOutputs: ChatCompletionsOutput;10139}10140declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {10141 inputs: ChatCompletionsInput;10142 postProcessedOutputs: ChatCompletionsOutput;10143}10144declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {10145 inputs: ChatCompletionsInput;10146 postProcessedOutputs: ChatCompletionsOutput;10147}10148interface AiModels {10149 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;10150 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;10151 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;10152 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;10153 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;10154 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;10155 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;10156 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;10157 "@cf/microsoft/resnet-50": BaseAiImageClassification;10158 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;10159 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;10160 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;10161 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;10162 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;10163 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;10164 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;10165 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;10166 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;10167 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;10168 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;10169 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;10170 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;10171 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;10172 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;10173 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;10174 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;10175 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;10176 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;10177 "@cf/microsoft/phi-2": BaseAiTextGeneration;10178 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;10179 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;10180 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;10181 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;10182 "@hf/google/gemma-7b-it": BaseAiTextGeneration;10183 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;10184 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;10185 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;10186 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;10187 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;10188 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;10189 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;10190 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;10191 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;10192 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;10193 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;10194 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;10195 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;10196 "@cf/facebook/bart-large-cnn": BaseAiSummarization;10197 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;10198 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;10199 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;10200 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;10201 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;10202 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;10203 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;10204 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;10205 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;10206 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;10207 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;10208 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;10209 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;10210 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;10211 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;10212 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;10213 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;10214 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;10215 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;10216 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;10217 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;10218 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;10219 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;10220 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;10221 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;10222 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;10223 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;10224 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;10225 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;10226 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;10227 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;10228 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;10229 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;10230 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;10231 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;10232 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;10233 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;10234 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;10235 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;10236 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;10237 "@cf/moonshotai/kimi-k2.6": Base_Ai_Cf_Moonshotai_Kimi_K2_6;10238 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;10239 "@cf/google/gemma-4-26b-a4b-it": Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT;10240}10241type AiOptions = {10242 /**10243 * Send requests as an asynchronous batch job, only works for supported models10244 * https://developers.cloudflare.com/workers-ai/features/batch-api10245 */10246 queueRequest?: boolean;10247 /**10248 * Establish websocket connections, only works for supported models10249 */10250 websocket?: boolean;10251 /**10252 * Tag your requests to group and view them in Cloudflare dashboard.10253 *10254 * Rules:10255 * Tags must only contain letters, numbers, and the symbols: : - . / @10256 * Each tag can have maximum 50 characters.10257 * Maximum 5 tags are allowed each request.10258 * Duplicate tags will removed.10259 */10260 tags?: string[];10261 gateway?: GatewayOptions;10262 returnRawResponse?: boolean;10263 prefix?: string;10264 extraHeaders?: object;10265 signal?: AbortSignal;10266};10267type AiModelsSearchParams = {10268 author?: string;10269 hide_experimental?: boolean;10270 page?: number;10271 per_page?: number;10272 search?: string;10273 source?: number;10274 task?: string;10275};10276type AiModelsSearchObject = {10277 id: string;10278 source: number;10279 name: string;10280 description: string;10281 task: {10282 id: string;10283 name: string;10284 description: string;10285 };10286 tags: string[];10287 properties: {10288 property_id: string;10289 value: string;10290 }[];10291};10292type ChatCompletionsBase = ChatCompletionsMessagesInput;10293type ChatCompletionsInput = ChatCompletionsMessagesInput;10294interface InferenceUpstreamError extends Error {10295}10296interface AiInternalError extends Error {10297}10298type AiModelListType = Record<string, any>;10299type AiAsyncBatchResponse = {10300 request_id: string;10301};10302declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {10303 aiGatewayLogId: string | null;10304 gateway(gatewayId: string): AiGateway;10305 /**10306 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.10307 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10308 */10309 aiSearch(): AiSearchNamespace;10310 /**10311 * @deprecated AutoRAG has been replaced by AI Search.10312 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.10313 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10314 *10315 * @param autoragId Instance ID10316 */10317 autorag(autoragId: string): AutoRAG;10318 // Batch request10319 run<Name extends keyof AiModelList>(model: Name, inputs: {10320 requests: AiModelList[Name]['inputs'][];10321 }, options: AiOptions & {10322 queueRequest: true;10323 }): Promise<AiAsyncBatchResponse>;10324 // Raw response10325 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & {10326 returnRawResponse: true;10327 }): Promise<Response>;10328 // WebSocket10329 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & {10330 websocket: true;10331 }): Promise<Response>;10332 // Streaming10333 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'] & {10334 stream: true;10335 }, options?: AiOptions): Promise<ReadableStream>;10336 // Normal (default) - known model10337 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options?: AiOptions): Promise<AiModelList[Name]['postProcessedOutputs']>;10338 // Unknown model (fallback).10339 //10340 // The `Exclude<..., keyof AiModelList>` constraint forces TypeScript to10341 // route any model name that is a literal key of `AiModelList` to one of10342 // the known-model overloads above (so input/output mismatches surface as10343 // type errors rather than silently falling back to `Record<string, unknown>`).10344 // Names that aren't in `AiModelList` — e.g. third-party gateway models10345 // like `"google/nano-banana"` — still hit this overload.10346 run<Model extends string>(model: Model extends keyof AiModelList ? never : Model, inputs: Record<string, unknown>, options?: AiOptions): Promise<Record<string, unknown>>;10347 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;10348 toMarkdown(): ToMarkdownService;10349 toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;10350 toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;10351}10352type GatewayRetries = {10353 maxAttempts?: 1 | 2 | 3 | 4 | 5;10354 retryDelayMs?: number;10355 backoff?: 'constant' | 'linear' | 'exponential';10356};10357type GatewayOptions = {10358 id: string;10359 cacheKey?: string;10360 cacheTtl?: number;10361 skipCache?: boolean;10362 metadata?: Record<string, number | string | boolean | null | bigint>;10363 collectLog?: boolean;10364 eventId?: string;10365 requestTimeoutMs?: number;10366 retries?: GatewayRetries;10367};10368type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & {10369 /**10370 ** @deprecated10371 */10372 id?: string;10373};10374type AiGatewayPatchLog = {10375 score?: number | null;10376 feedback?: -1 | 1 | null;10377 metadata?: Record<string, number | string | boolean | null | bigint> | null;10378};10379type AiGatewayLog = {10380 id: string;10381 provider: string;10382 model: string;10383 model_type?: string;10384 path: string;10385 duration: number;10386 request_type?: string;10387 request_content_type?: string;10388 status_code: number;10389 response_content_type?: string;10390 success: boolean;10391 cached: boolean;10392 tokens_in?: number;10393 tokens_out?: number;10394 metadata?: Record<string, number | string | boolean | null | bigint>;10395 step?: number;10396 cost?: number;10397 custom_cost?: boolean;10398 request_size: number;10399 request_head?: string;10400 request_head_complete: boolean;10401 response_size: number;10402 response_head?: string;10403 response_head_complete: boolean;10404 created_at: Date;10405};10406type AIGatewayProviders = 'workers-ai' | 'anthropic' | 'aws-bedrock' | 'azure-openai' | 'google-vertex-ai' | 'huggingface' | 'openai' | 'perplexity-ai' | 'replicate' | 'groq' | 'cohere' | 'google-ai-studio' | 'mistral' | 'grok' | 'openrouter' | 'deepseek' | 'cerebras' | 'cartesia' | 'elevenlabs' | 'adobe-firefly';10407type AIGatewayHeaders = {10408 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string;10409 'cf-aig-custom-cost': {10410 per_token_in?: number;10411 per_token_out?: number;10412 } | {10413 total_cost?: number;10414 } | string;10415 'cf-aig-cache-ttl': number | string;10416 'cf-aig-skip-cache': boolean | string;10417 'cf-aig-cache-key': string;10418 'cf-aig-event-id': string;10419 'cf-aig-request-timeout': number | string;10420 'cf-aig-max-attempts': number | string;10421 'cf-aig-retry-delay': number | string;10422 'cf-aig-backoff': string;10423 'cf-aig-collect-log': boolean | string;10424 Authorization: string;10425 'Content-Type': string;10426 [key: string]: string | number | boolean | object;10427};10428type AIGatewayUniversalRequest = {10429 provider: AIGatewayProviders | string; // eslint-disable-line10430 endpoint: string;10431 headers: Partial<AIGatewayHeaders>;10432 query: unknown;10433};10434interface AiGatewayInternalError extends Error {10435}10436interface AiGatewayLogNotFound extends Error {10437}10438declare abstract class AiGateway {10439 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;10440 getLog(logId: string): Promise<AiGatewayLog>;10441 run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: {10442 gateway?: UniversalGatewayOptions;10443 extraHeaders?: object;10444 signal?: AbortSignal;10445 }): Promise<Response>;10446 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line10447}10448// Copyright (c) 2022-2025 Cloudflare, Inc.10449// Licensed under the Apache 2.0 license found in the LICENSE file or at:10450// https://opensource.org/licenses/Apache-2.010451/**10452 * Artifacts — Git-compatible file storage on Cloudflare Workers.10453 *10454 * Provides programmatic access to create, manage, and fork repositories,10455 * and to issue and revoke scoped access tokens.10456 */10457/** Information about a repository. */10458interface ArtifactsRepoInfo {10459 /** Unique repository ID. */10460 id: string;10461 /** Repository name. */10462 name: string;10463 /** Repository description, or null if not set. */10464 description: string | null;10465 /** Default branch name (e.g. "main"). */10466 defaultBranch: string;10467 /** ISO 8601 creation timestamp. */10468 createdAt: string;10469 /** ISO 8601 last-updated timestamp. */10470 updatedAt: string;10471 /** ISO 8601 timestamp of the last push, or null if never pushed. */10472 lastPushAt: string | null;10473 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */10474 source: string | null;10475 /** Whether the repository is read-only. */10476 readOnly: boolean;10477 /** HTTPS git remote URL. */10478 remote: string;10479}10480/** Result of creating a repository — includes the initial access token. */10481interface ArtifactsCreateRepoResult {10482 /** Unique repository ID. */10483 id: string;10484 /** Repository name. */10485 name: string;10486 /** Repository description, or null if not set. */10487 description: string | null;10488 /** Default branch name. */10489 defaultBranch: string;10490 /** HTTPS git remote URL. */10491 remote: string;10492 /** Plaintext access token (only returned at creation time). */10493 token: string;10494 /** ISO 8601 token expiry timestamp. */10495 tokenExpiresAt: string;10496}10497/** Paginated list of repositories. */10498interface ArtifactsRepoListResult {10499 /** Repositories in this page (without the `remote` field). */10500 repos: Omit<ArtifactsRepoInfo, 'remote'>[];10501 /** Total number of repositories in the namespace. */10502 total: number;10503 /** Cursor for the next page, if there are more results. */10504 cursor?: string;10505}10506/** Result of creating an access token. */10507interface ArtifactsCreateTokenResult {10508 /** Unique token ID. */10509 id: string;10510 /** Plaintext token (only returned at creation time). */10511 plaintext: string;10512 /** Token scope: "read" or "write". */10513 scope: 'read' | 'write';10514 /** ISO 8601 token expiry timestamp. */10515 expiresAt: string;10516}10517/** Token metadata (no plaintext). */10518interface ArtifactsTokenInfo {10519 /** Unique token ID. */10520 id: string;10521 /** Token scope: "read" or "write". */10522 scope: 'read' | 'write';10523 /** Token state: "active", "expired", or "revoked". */10524 state: 'active' | 'expired' | 'revoked';10525 /** ISO 8601 creation timestamp. */10526 createdAt: string;10527 /** ISO 8601 expiry timestamp. */10528 expiresAt: string;10529}10530/** Paginated list of tokens for a repository. */10531interface ArtifactsTokenListResult {10532 /** Tokens in this page. */10533 tokens: ArtifactsTokenInfo[];10534 /** Total number of tokens for the repository. */10535 total: number;10536}10537/**10538 * Handle for a single repository. Returned by Artifacts.get().10539 *10540 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.10541 */10542interface ArtifactsRepo extends ArtifactsRepoInfo {10543 /**10544 * Create an access token for this repo.10545 * @param scope Token scope: "write" (default) or "read".10546 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).10547 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.10548 */10549 createToken(scope?: 'write' | 'read', ttl?: number): Promise<ArtifactsCreateTokenResult>;10550 /** List tokens for this repo (metadata only, no plaintext). */10551 listTokens(): Promise<ArtifactsTokenListResult>;10552 /**10553 * Revoke a token by plaintext or ID.10554 * @param tokenOrId Plaintext token or token ID.10555 * @returns true if revoked, false if not found.10556 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.10557 */10558 revokeToken(tokenOrId: string): Promise<boolean>;10559 // ── Fork ──10560 /**10561 * Fork this repo to a new repo.10562 * @param name Target repository name.10563 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).10564 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.10565 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.10566 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.10567 */10568 fork(name: string, opts?: {10569 description?: string;10570 readOnly?: boolean;10571 defaultBranchOnly?: boolean;10572 }): Promise<ArtifactsCreateRepoResult>;10573}10574// ── Error types ──────────────────────────────────────────────────────────────10575/**10576 * Error codes returned by Artifacts binding operations.10577 *10578 * Each code maps to a numeric code available on `ArtifactsError.numericCode`.10579 */10580type ArtifactsErrorCode = 'ALREADY_EXISTS' | 'NOT_FOUND' | 'IMPORT_IN_PROGRESS' | 'FORK_IN_PROGRESS' | 'INVALID_INPUT' | 'INVALID_REPO_NAME' | 'INVALID_TTL' | 'INVALID_URL' | 'REMOTE_AUTH_REQUIRED' | 'UPSTREAM_UNAVAILABLE' | 'MEMORY_LIMIT' | 'INTERNAL_ERROR';10581/**10582 * Error thrown by Artifacts binding operations.10583 *10584 * Uses a string `.code` discriminator following the Cloudflare platform10585 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches10586 * the REST API `errors[].code` values.10587 */10588interface ArtifactsError extends Error {10589 readonly name: 'ArtifactsError';10590 /** String error code for programmatic matching. */10591 readonly code: ArtifactsErrorCode;10592 /** Numeric error code matching the REST API. */10593 readonly numericCode: number;10594}10595// ── Binding ──────────────────────────────────────────────────────────────────10596/**10597 * Artifacts binding — namespace-level operations.10598 *10599 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.10600 */10601interface Artifacts {10602 /**10603 * Create a new repository with an initial access token.10604 * @param name Repository name (alphanumeric, dots, hyphens, underscores).10605 * @param opts Optional: readOnly flag, description, default branch name.10606 * @returns Repo metadata with initial token.10607 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.10608 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.10609 */10610 create(name: string, opts?: {10611 readOnly?: boolean;10612 description?: string;10613 setDefaultBranch?: string;10614 }): Promise<ArtifactsCreateRepoResult>;10615 /**10616 * Get a handle to an existing repository.10617 * @param name Repository name.10618 * @returns Repo handle.10619 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.10620 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.10621 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.10622 */10623 get(name: string): Promise<ArtifactsRepo>;10624 /**10625 * Import a repository from an external git remote.10626 * @param params Source URL and optional branch/depth, plus target name and options.10627 * @returns Repo metadata with initial token.10628 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.10629 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.10630 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.10631 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.10632 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.10633 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.10634 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.10635 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.10636 */10637 import(params: {10638 source: {10639 url: string;10640 branch?: string;10641 depth?: number;10642 };10643 target: {10644 name: string;10645 opts?: {10646 description?: string;10647 readOnly?: boolean;10648 };10649 };10650 }): Promise<ArtifactsCreateRepoResult>;10651 /**10652 * List repositories with cursor-based pagination.10653 * @param opts Optional: limit (1–200, default 50), cursor for next page.10654 */10655 list(opts?: {10656 limit?: number;10657 cursor?: string;10658 }): Promise<ArtifactsRepoListResult>;10659 /**10660 * Delete a repository and all associated tokens.10661 * @param name Repository name.10662 * @returns true if deleted, false if not found.10663 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.10664 */10665 delete(name: string): Promise<boolean>;10666}10667/**10668 * @deprecated Use the standalone AI Search Workers binding instead.10669 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10670 */10671interface AutoRAGInternalError extends Error {10672}10673/**10674 * @deprecated Use the standalone AI Search Workers binding instead.10675 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10676 */10677interface AutoRAGNotFoundError extends Error {10678}10679/**10680 * @deprecated Use the standalone AI Search Workers binding instead.10681 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10682 */10683interface AutoRAGUnauthorizedError extends Error {10684}10685/**10686 * @deprecated Use the standalone AI Search Workers binding instead.10687 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10688 */10689interface AutoRAGNameNotSetError extends Error {10690}10691type ComparisonFilter = {10692 key: string;10693 type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';10694 value: string | number | boolean;10695};10696type CompoundFilter = {10697 type: 'and' | 'or';10698 filters: ComparisonFilter[];10699};10700/**10701 * @deprecated Use the standalone AI Search Workers binding instead.10702 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10703 */10704type AutoRagSearchRequest = {10705 query: string;10706 filters?: CompoundFilter | ComparisonFilter;10707 max_num_results?: number;10708 ranking_options?: {10709 ranker?: string;10710 score_threshold?: number;10711 };10712 reranking?: {10713 enabled?: boolean;10714 model?: string;10715 };10716 rewrite_query?: boolean;10717};10718/**10719 * @deprecated Use the standalone AI Search Workers binding instead.10720 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10721 */10722type AutoRagAiSearchRequest = AutoRagSearchRequest & {10723 stream?: boolean;10724 system_prompt?: string;10725};10726/**10727 * @deprecated Use the standalone AI Search Workers binding instead.10728 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10729 */10730type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & {10731 stream: true;10732};10733/**10734 * @deprecated Use the standalone AI Search Workers binding instead.10735 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10736 */10737type AutoRagSearchResponse = {10738 object: 'vector_store.search_results.page';10739 search_query: string;10740 data: {10741 file_id: string;10742 filename: string;10743 score: number;10744 attributes: Record<string, string | number | boolean | null>;10745 content: {10746 type: 'text';10747 text: string;10748 }[];10749 }[];10750 has_more: boolean;10751 next_page: string | null;10752};10753/**10754 * @deprecated Use the standalone AI Search Workers binding instead.10755 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10756 */10757type AutoRagListResponse = {10758 id: string;10759 enable: boolean;10760 type: string;10761 source: string;10762 vectorize_name: string;10763 paused: boolean;10764 status: string;10765}[];10766/**10767 * @deprecated Use the standalone AI Search Workers binding instead.10768 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10769 */10770type AutoRagAiSearchResponse = AutoRagSearchResponse & {10771 response: string;10772};10773/**10774 * @deprecated Use the standalone AI Search Workers binding instead.10775 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10776 */10777declare abstract class AutoRAG {10778 /**10779 * @deprecated Use the standalone AI Search Workers binding instead.10780 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10781 */10782 list(): Promise<AutoRagListResponse>;10783 /**10784 * @deprecated Use the standalone AI Search Workers binding instead.10785 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10786 */10787 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;10788 /**10789 * @deprecated Use the standalone AI Search Workers binding instead.10790 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10791 */10792 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;10793 /**10794 * @deprecated Use the standalone AI Search Workers binding instead.10795 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10796 */10797 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;10798 /**10799 * @deprecated Use the standalone AI Search Workers binding instead.10800 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/10801 */10802 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>;10803}10804type BrowserRunLifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2';10805type BrowserRunResourceType = 'document' | 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'texttrack' | 'xhr' | 'fetch' | 'prefetch' | 'eventsource' | 'websocket' | 'manifest' | 'signedexchange' | 'ping' | 'cspviolationreport' | 'preflight' | 'other';10806/** Options fields shared by all quick actions. */10807interface BrowserRunBaseOptions {10808 /** Adds `<script>` tags into the page with the desired URL or content.10809 * @see https://pptr.dev/api/puppeteer.frameaddscripttagoptions10810 */10811 addScriptTag?: Array<{10812 content?: string;10813 url?: string;10814 type?: string;10815 id?: string;10816 }>;10817 /** Adds `<link rel="stylesheet">` or `<style>` tags into the page.10818 * @see https://pptr.dev/api/puppeteer.frameaddstyletagoptions10819 */10820 addStyleTag?: Array<{10821 content?: string;10822 url?: string;10823 }>;10824 /** Provide credentials for HTTP authentication. @see https://pptr.dev/api/puppeteer.credentials */10825 authenticate?: {10826 username: string;10827 password: string;10828 };10829 /** Set cookies before navigating. @see https://pptr.dev/api/puppeteer.cookieparam */10830 cookies?: Array<{10831 name: string;10832 value: string;10833 url?: string;10834 domain?: string;10835 path?: string;10836 secure?: boolean;10837 httpOnly?: boolean;10838 sameSite?: 'Strict' | 'Lax' | 'None';10839 expires?: number;10840 priority?: 'Low' | 'Medium' | 'High';10841 sameParty?: boolean;10842 sourceScheme?: 'Unset' | 'NonSecure' | 'Secure';10843 sourcePort?: number;10844 partitionKey?: string;10845 }>;10846 /** Emulate a specific CSS media type (e.g. `"screen"`, `"print"`). */10847 emulateMediaType?: string;10848 /** Navigation options. @see https://pptr.dev/api/puppeteer.gotooptions */10849 gotoOptions?: {10850 /** Navigation timeout in milliseconds (max 60 000). @default 30000 */10851 timeout?: number;10852 /** When to consider navigation complete. @default "domcontentloaded" */10853 waitUntil?: BrowserRunLifecycleEvent | BrowserRunLifecycleEvent[];10854 referer?: string;10855 referrerPolicy?: string;10856 };10857 /** Block requests matching these regex patterns. Mutually exclusive with `allowRequestPattern`. */10858 rejectRequestPattern?: string[];10859 /** Only allow requests matching these regex patterns. Mutually exclusive with `rejectRequestPattern`. */10860 allowRequestPattern?: string[];10861 /** Block requests of these resource types. Mutually exclusive with `allowResourceTypes`. */10862 rejectResourceTypes?: BrowserRunResourceType[];10863 /** Only allow requests of these resource types. Mutually exclusive with `rejectResourceTypes`. */10864 allowResourceTypes?: BrowserRunResourceType[];10865 /** Additional HTTP headers sent with every request. */10866 setExtraHTTPHeaders?: Record<string, string>;10867 /** Whether JavaScript is enabled on the page. */10868 setJavaScriptEnabled?: boolean;10869 /** Override the default user agent string.10870 * @default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"10871 * */10872 userAgent?: string;10873 /** Set the browser viewport size.10874 * @see https://pptr.dev/api/puppeteer.viewport10875 * @default {width:1920,height:1080}10876 * */10877 viewport?: {10878 width: number;10879 height: number;10880 deviceScaleFactor?: number;10881 isMobile?: boolean;10882 isLandscape?: boolean;10883 hasTouch?: boolean;10884 };10885 /** Wait for a CSS selector to appear in the page before proceeding.10886 * @see https://pptr.dev/api/puppeteer.waitforselectoroptions10887 */10888 waitForSelector?: {10889 selector: string;10890 hidden?: true;10891 visible?: true;10892 /** Timeout in milliseconds. Max 120000 */10893 timeout?: number;10894 };10895 /** Wait for a fixed delay in milliseconds before proceeding. Max 120000 */10896 waitForTimeout?: number;10897 /** When true, continue on best-effort when awaited events fail or timeout. */10898 bestAttempt?: boolean;10899 /** Maximum duration in milliseconds for the browser action after page load. Max 120000 */10900 actionTimeout?: number;10901 /** Cache time to live in seconds (0-86400). Set to 0 to disable.10902 * @default 510903 */10904 cacheTTL?: number;10905}10906/** Common options shared by all quick actions. Exactly one of `url` or `html` must be provided.*/10907type BrowserRunCommonOptions = (BrowserRunBaseOptions & {10908 /** URL to navigate to, e.g. `"https://example.com"`. */10909 url: string;10910}) | (BrowserRunBaseOptions & {10911 /** Set the HTML content of the page directly. */10912 html: string;10913});10914type BrowserRunPuppeteerScreenshotOptions = {10915 /** @default "png" */10916 type?: 'png' | 'jpeg' | 'webp';10917 /** @default "binary" */10918 encoding?: 'binary' | 'base64';10919 quality?: number;10920 fullPage?: boolean;10921 clip?: {10922 x: number;10923 y: number;10924 width: number;10925 height: number;10926 scale?: number;10927 };10928 omitBackground?: boolean;10929 optimizeForSpeed?: boolean;10930 captureBeyondViewport?: boolean;10931 fromSurface?: boolean;10932};10933type BrowserRunScreenshotOptions = BrowserRunCommonOptions & {10934 /** CSS selector of the element to screenshot. */10935 selector?: string;10936 /** When true, scroll the entire page before taking the screenshot. */10937 scrollPage?: boolean;10938 /** @see https://pptr.dev/api/puppeteer.screenshotoptions */10939 screenshotOptions?: BrowserRunPuppeteerScreenshotOptions;10940};10941type BrowserRunPDFOptions = BrowserRunCommonOptions & {10942 /** @see https://pptr.dev/api/puppeteer.pdfoptions */10943 pdfOptions?: {10944 /** @default 1 */10945 scale?: number;10946 /** @default false */10947 displayHeaderFooter?: boolean;10948 headerTemplate?: string;10949 footerTemplate?: string;10950 /** @default false */10951 printBackground?: boolean;10952 /** @default false */10953 landscape?: boolean;10954 pageRanges?: string;10955 /** @default "letter" */10956 format?: 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6';10957 width?: string | number;10958 height?: string | number;10959 /** @default false */10960 preferCSSPageSize?: boolean;10961 margin?: {10962 top?: string | number;10963 right?: string | number;10964 bottom?: string | number;10965 left?: string | number;10966 };10967 /** @default false */10968 omitBackground?: boolean;10969 /** @default true */10970 tagged?: boolean;10971 /** @default false */10972 outline?: boolean;10973 /** @default 30000 */10974 timeout?: number;10975 };10976};10977type BrowserRunScrapeOptions = BrowserRunCommonOptions & {10978 /** CSS selectors to scrape. At least one element is required. */10979 elements: Array<{10980 selector: string;10981 }>;10982};10983type BrowserRunLinksOptions = BrowserRunCommonOptions & {10984 /** When true, only return links that are visible on the page. @default false */10985 visibleLinksOnly?: boolean;10986 /** When true, exclude links pointing to external domains. @default false */10987 excludeExternalLinks?: boolean;10988};10989type BrowserRunSnapshotFormat = 'content' | 'screenshot' | 'markdown' | 'accessibilityTree';10990type BrowserRunSnapshotOptions = BrowserRunCommonOptions & {10991 /** Which representations of the page to return. At least two distinct formats10992 * are required; request a single format from its dedicated action instead.10993 * @default ["content","screenshot"]10994 */10995 formats?: BrowserRunSnapshotFormat[];10996 /** @see https://pptr.dev/api/puppeteer.screenshotoptions */10997 screenshotOptions?: Omit<BrowserRunPuppeteerScreenshotOptions, 'encoding'>;10998};10999/** Options for the `accessibilityTree` quick action. */11000type BrowserRunAccessibilityTreeOptions = BrowserRunCommonOptions & {11001 /** When true, prune nodes that carry no semantic meaning, such as generic11002 * containers. Defaults to true, or to false when `root` is set so that the11003 * requested subtree is returned as-is.11004 */11005 interestingOnly?: boolean;11006 /** CSS selector limiting the tree to the matching element's subtree.11007 * A selector that matches nothing yields `accessibilityTree: null` with11008 * HTTP 200; a malformed selector is an error.11009 */11010 root?: string;11011};11012interface BrowserRunJsonBaseOptions {11013 /** Custom AI models to try in order. Max 3. Falls back to next on error. */11014 custom_ai?: Array<{11015 /** Model ID in `<provider>/<model_name>` format, e.g. `"workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast"`. */11016 model: string;11017 /** Bearer token. Not needed for workers-ai models. */11018 authorization?: string;11019 }>;11020}11021/**11022 * Options for the `json` quick action.11023 * At least one of `prompt` or `response_format` must be provided.11024 */11025type BrowserRunJsonOptions = BrowserRunCommonOptions & BrowserRunJsonBaseOptions & ({11026 /** Natural-language prompt describing what data to extract. */11027 prompt: string;11028 /** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */11029 response_format?: AiTextGenerationResponseFormat;11030} | {11031 /** Natural-language prompt describing what data to extract. */11032 prompt?: string;11033 /** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */11034 response_format: AiTextGenerationResponseFormat;11035});11036type BrowserRunContentOptions = BrowserRunCommonOptions;11037type BrowserRunMarkdownOptions = BrowserRunCommonOptions;11038type BrowserRunResponseMeta = {11039 /** HTTP status code of the rendered page */11040 status: number;11041 /** Page title */11042 title: string;11043};11044/**11045 * A node in the page's accessibility tree, as exposed to assistive technology.11046 * `role` is the only field always present; the rest are populated when the11047 * underlying element defines them.11048 * @see https://pptr.dev/api/puppeteer.serializedaxnode11049 */11050interface BrowserRunSerializedAXNode {11051 /** The ARIA role, e.g. `"button"`, `"heading"`, `"RootWebArea"`. */11052 role: string;11053 /** The `aria-autocomplete` value. */11054 autocomplete?: string;11055 /** Checked state of a checkbox, radio, or menu item. */11056 checked?: boolean | 'mixed';11057 /** Accessible description, typically from `aria-describedby` or `title`. */11058 description?: string;11059 disabled?: boolean;11060 expanded?: boolean;11061 /** Whether the element currently holds keyboard focus. */11062 focused?: boolean;11063 /** The kind of popup the element triggers, e.g. `"menu"`, `"dialog"`. */11064 haspopup?: string;11065 /** The `aria-invalid` value. */11066 invalid?: string;11067 /** Keyboard shortcuts bound to the element, from `aria-keyshortcuts`. */11068 keyshortcuts?: string;11069 /** Hierarchical level, e.g. the heading level of an `<h2>`. */11070 level?: number;11071 /** Whether the element is a modal dialog. */11072 modal?: boolean;11073 /** Whether a text input accepts multiple lines. */11074 multiline?: boolean;11075 /** Whether more than one option can be selected. */11076 multiselectable?: boolean;11077 /** Accessible name, e.g. a button's label or an image's alt text. */11078 name?: string;11079 orientation?: string;11080 /** Pressed state of a toggle button. */11081 pressed?: boolean | 'mixed';11082 readonly?: boolean;11083 required?: boolean;11084 /** Author-supplied role description, from `aria-roledescription`. */11085 roledescription?: string;11086 selected?: boolean;11087 /** Current value of an input or range element. */11088 value?: string | number;11089 valuemax?: number;11090 valuemin?: number;11091 /** Human-readable form of `value`, from `aria-valuetext`. */11092 valuetext?: string;11093 /** Child nodes. Absent for leaf nodes. */11094 children?: BrowserRunSerializedAXNode[];11095}11096/** Success response for `content` action. */11097type BrowserRunContentSuccessResponse = {11098 success: true;11099 /** Extracted HTML content */11100 result: string;11101 meta: BrowserRunResponseMeta;11102};11103/** Success response for `links` action. */11104type BrowserRunLinksSuccessResponse = {11105 success: true;11106 /** Extracted links */11107 result: string[];11108};11109/** Success response for `scrape` action. */11110type BrowserRunScrapeSuccessResponse = {11111 success: true;11112 result: Array<{11113 /** The CSS selector used to find elements. */11114 selector: string;11115 /** Array of elements matching the selector. */11116 results: Array<{11117 /** Outer HTML of the element. */11118 html: string;11119 /** Text content of the element. */11120 text: string;11121 /** Width of the element in pixels. */11122 width: number;11123 /** Height of the element in pixels. */11124 height: number;11125 /** Top position of the element relative to the viewport in pixels. */11126 top: number;11127 /** Left position of the element relative to the viewport in pixels. */11128 left: number;11129 /** Array of HTML attributes on the element. */11130 attributes: Array<{11131 /** Attribute name. */11132 name: string;11133 /** Attribute value. */11134 value: string;11135 }>;11136 }>;11137 }>;11138};11139/** Success response for `snapshot` action. Each field is present only when the11140 * corresponding entry was requested in `formats`.11141 */11142type BrowserRunSnapshotSuccessResponse = {11143 success: true;11144 result: {11145 /** HTML content of the page. */11146 content?: string;11147 /** Base64-encoded screenshot image. */11148 screenshot?: string;11149 /** Markdown content. Prefixed with YAML frontmatter (e.g. `title`) when the11150 * page provides that metadata.11151 */11152 markdown?: string;11153 /** Root of the page's accessibility tree. */11154 accessibilityTree?: BrowserRunSerializedAXNode;11155 };11156 meta: BrowserRunResponseMeta;11157};11158/** Success response for `accessibilityTree` action. */11159type BrowserRunAccessibilityTreeSuccessResponse = {11160 success: true;11161 result: {11162 /** Root of the accessibility tree, or `null` when `root` matched no element. */11163 accessibilityTree: BrowserRunSerializedAXNode | null;11164 };11165 meta: BrowserRunResponseMeta;11166};11167/** Success response for `json` action. */11168type BrowserRunJsonSuccessResponse = {11169 success: true;11170 /** JSON data extracted from the page using an AI model */11171 result: Record<string, unknown>;11172};11173/** Success response for `markdown` action. */11174type BrowserRunMarkdownSuccessResponse = {11175 success: true;11176 /** Extracted markdown content */11177 result: string;11178};11179/** Error response for BrowserRun actions. */11180type BrowserRunErrorResponse = {11181 success: false;11182 errors: {11183 message: string;11184 code?: number;11185 detail?: string;11186 path?: string;11187 }[];11188};11189/** Error response for BrowserRun `json` action. */11190type BrowserRunJsonErrorResponse = BrowserRunErrorResponse & {11191 /** Raw AI response text for debugging */11192 rawAiResponse?: string;11193};11194/**11195 * Browser Run API binding for automating headless browsers.11196 * @see https://developers.cloudflare.com/browser-run/11197 */11198declare abstract class BrowserRun {11199 /**11200 * Send a raw HTTP request to the Browser Run API.11201 * Used by libraries like `@cloudflare/puppeteer` to acquire and connect to a browser instance.11202 * @see https://developers.cloudflare.com/browser-run/11203 */11204 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;11205 /**11206 * Take a screenshot of a web page.11207 * @param action - Must be `'screenshot'`.11208 * @param options - Screenshot options including viewport, selectors, and image format.11209 * @returns A `Response` containing one of:11210 *11211 * **Success (HTTP 200):**11212 * - Binary image data with `Content-Type: image/png`, `image/jpeg`, or `image/webp` (when `encoding: 'binary'`, the default)11213 * - Data URI string with `Content-Type: text/plain` (when `encoding: 'base64'`)11214 *11215 * **Error:**11216 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11217 *11218 * **Headers:**11219 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11220 */11221 quickAction(action: 'screenshot', options: BrowserRunScreenshotOptions): Promise<Response>;11222 /**11223 * Generate a PDF of a web page.11224 * @param action - Must be `'pdf'`.11225 * @param options - PDF generation options including page size, margins, and headers/footers.11226 * @returns A `Response` containing one of:11227 *11228 * **Success (HTTP 200):**11229 * - Binary PDF data with `Content-Type: application/pdf`11230 *11231 * **Error:**11232 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11233 *11234 * **Headers:**11235 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11236 */11237 quickAction(action: 'pdf', options: BrowserRunPDFOptions): Promise<Response>;11238 /**11239 * Get the HTML content of a web page.11240 * @param action - Must be `'content'`.11241 * @param options - Navigation and page interaction options.11242 * @returns A `Response` containing one of:11243 *11244 * **Success (HTTP 200):**11245 * - `BrowserRunContentSuccessResponse` JSON with `Content-Type: application/json`11246 *11247 * **Error:**11248 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11249 *11250 * **Headers:**11251 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11252 */11253 quickAction(action: 'content', options: BrowserRunContentOptions): Promise<Response>;11254 /**11255 * Scrape elements from a web page by CSS selector.11256 * @param action - Must be `'scrape'`.11257 * @param options - Scrape options with CSS selectors for elements to extract.11258 * @returns A `Response` containing one of:11259 *11260 * **Success (HTTP 200):**11261 * - `BrowserRunScrapeSuccessResponse` JSON with `Content-Type: application/json`11262 *11263 * **Error:**11264 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11265 *11266 * **Headers:**11267 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11268 */11269 quickAction(action: 'scrape', options: BrowserRunScrapeOptions): Promise<Response>;11270 /**11271 * Extract all links from a web page.11272 * @param action - Must be `'links'`.11273 * @param options - Options to filter visible or internal links only.11274 * @returns A `Response` containing one of:11275 *11276 * **Success (HTTP 200):**11277 * - `BrowserRunLinksSuccessResponse` JSON with `Content-Type: application/json`11278 *11279 * **Error:**11280 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11281 *11282 * **Headers:**11283 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11284 */11285 quickAction(action: 'links', options: BrowserRunLinksOptions): Promise<Response>;11286 /**11287 * Get several representations of a web page in one request.11288 * @param action - Must be `'snapshot'`.11289 * @param options - Snapshot options including the `formats` to return and11290 * screenshot settings (encoding is always base64).11291 * @returns A `Response` containing one of:11292 *11293 * **Success (HTTP 200):**11294 * - `BrowserRunSnapshotSuccessResponse` JSON with `Content-Type: application/json`11295 *11296 * **Error:**11297 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11298 *11299 * **Headers:**11300 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11301 */11302 quickAction(action: 'snapshot', options: BrowserRunSnapshotOptions): Promise<Response>;11303 /**11304 * Extract structured JSON data from a web page using AI.11305 * @param action - Must be `'json'`.11306 * @param options - JSON extraction options with prompt or response_format schema.11307 * @returns A `Response` containing one of:11308 *11309 * **Success (HTTP 200):**11310 * - `BrowserRunJsonSuccessResponse` JSON with `Content-Type: application/json`11311 *11312 * **Error:**11313 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11314 * - HTTP 422 with code `2012` for HTML-to-markdown conversion failures11315 * - HTTP 422/500 for AI extraction failures (may include `rawAiResponse` field)11316 *11317 * **Headers:**11318 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11319 */11320 quickAction(action: 'json', options: BrowserRunJsonOptions): Promise<Response>;11321 /**11322 * Convert a web page to Markdown.11323 * @param action - Must be `'markdown'`.11324 * @param options - Navigation and page interaction options.11325 * @returns A `Response` containing one of:11326 *11327 * **Success (HTTP 200):**11328 * - `BrowserRunMarkdownSuccessResponse` JSON with `Content-Type: application/json`11329 *11330 * **Error:**11331 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11332 * - HTTP 422 with code `2012` for HTML-to-markdown conversion failures11333 *11334 * **Headers:**11335 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11336 */11337 quickAction(action: 'markdown', options: BrowserRunMarkdownOptions): Promise<Response>;11338 /**11339 * Get the accessibility tree of a web page.11340 * @param action - Must be `'accessibilityTree'`.11341 * @param options - Options to scope the tree to a subtree and to control11342 * whether semantically uninteresting nodes are pruned.11343 * @returns A `Response` containing one of:11344 *11345 * **Success (HTTP 200):**11346 * - `BrowserRunAccessibilityTreeSuccessResponse` JSON with `Content-Type: application/json`11347 * - `result.accessibilityTree` is `null` when `root` matched no element11348 *11349 * **Error:**11350 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503)11351 * - HTTP 422 for a malformed `root` selector11352 * - HTTP 500 with code `2017` or `2018` when the tree could not be built11353 *11354 * **Headers:**11355 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500)11356 */11357 quickAction(action: 'accessibilityTree', options: BrowserRunAccessibilityTreeOptions): Promise<Response>;11358}11359/**11360 * In addition to the properties you can set in the RequestInit dict11361 * that you pass as an argument to the Request constructor, you can11362 * set certain properties of a `cf` object to control how Cloudflare11363 * features are applied to that new Request.11364 *11365 * Note: Currently, these properties cannot be tested in the11366 * playground.11367 */11368interface RequestInitCfProperties extends Record<string, unknown> {11369 cacheEverything?: boolean;11370 /**11371 * A request's cache key is what determines if two requests are11372 * "the same" for caching purposes. If a request has the same cache key11373 * as some previous request, then we can serve the same cached response for11374 * both. (e.g. 'some-key')11375 *11376 * Only available for Enterprise customers.11377 */11378 cacheKey?: string;11379 /**11380 * This allows you to append additional Cache-Tag response headers11381 * to the origin response without modifications to the origin server.11382 * This will allow for greater control over the Purge by Cache Tag feature11383 * utilizing changes only in the Workers process.11384 *11385 * Only available for Enterprise customers.11386 */11387 cacheTags?: string[];11388 /**11389 * Force response to be cached for a given number of seconds. (e.g. 300)11390 */11391 cacheTtl?: number;11392 /**11393 * Force response to be cached for a given number of seconds based on the Origin status code.11394 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })11395 */11396 cacheTtlByStatus?: Record<string, number>;11397 /** Controls how responses with a `Vary` header are cached for this request. */11398 vary?: RequestInitCfPropertiesVary;11399 /**11400 * Explicit Cache-Control header value to set on the response stored in cache.11401 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').11402 *11403 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),11404 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.11405 *11406 * Can be used together with `cacheTtlByStatus`.11407 */11408 cacheControl?: string;11409 /**11410 * Whether the response should be eligible for Cache Reserve storage.11411 */11412 cacheReserveEligible?: boolean;11413 /**11414 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.11415 */11416 respectStrongEtag?: boolean;11417 /**11418 * Whether to strip ETag headers from the origin response before caching.11419 */11420 stripEtags?: boolean;11421 /**11422 * Whether to strip Last-Modified headers from the origin response before caching.11423 */11424 stripLastModified?: boolean;11425 /**11426 * Whether to enable Cache Deception Armor, which protects against web cache11427 * deception attacks by verifying the Content-Type matches the URL extension.11428 */11429 cacheDeceptionArmor?: boolean;11430 /**11431 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.11432 */11433 cacheReserveMinimumFileSize?: number;11434 scrapeShield?: boolean;11435 apps?: boolean;11436 /**11437 * Controls whether an outbound gRPC-web subrequest from this Worker is11438 * converted to gRPC at the Cloudflare edge.11439 *11440 * - `"passthrough"`: forward the subrequest unchanged as gRPC-web (default).11441 * - `"convert"`: convert the gRPC-web subrequest to gRPC at the edge.11442 *11443 * Provides per-request control over the same edge conversion behavior11444 * gated by the `auto_grpc_convert` compatibility flag.11445 */11446 grpcWeb?: "passthrough" | "convert";11447 image?: RequestInitCfPropertiesImage;11448 minify?: RequestInitCfPropertiesImageMinify;11449 mirage?: boolean;11450 polish?: "lossy" | "lossless" | "off";11451 r2?: RequestInitCfPropertiesR2;11452 /**11453 * Redirects the request to an alternate origin server. You can use this,11454 * for example, to implement load balancing across several origins.11455 * (e.g.us-east.example.com)11456 *11457 * Note - For security reasons, the hostname set in resolveOverride must11458 * be proxied on the same Cloudflare zone of the incoming request.11459 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to11460 * resolve to a host under a different domain or a DNS only domain first11461 * declare a CNAME record within your own zone’s DNS mapping to the11462 * external hostname, set proxy on Cloudflare, then set resolveOverride11463 * to point to that CNAME record.11464 */11465 resolveOverride?: string;11466}11467/**11468 * Controls how Workers Standard Vary handles a request header listed by an11469 * origin `Vary` response header:11470 *11471 * - `"normalize"`: normalize the request header value before it is used in the11472 * cache variance key.11473 * - `"passthrough"`: use the raw request header value in the cache variance11474 * key.11475 * - `"bypass"`: bypass cache when the header appears in the origin `Vary`11476 * response header.11477 */11478type RequestInitCfPropertiesVaryAction = "normalize" | "passthrough" | "bypass";11479/** Configuration for Workers Standard Vary support. */11480interface RequestInitCfPropertiesVary {11481 /** The fallback action for varied request headers not listed in `headers`. */11482 default: RequestInitCfPropertiesVaryHeader;11483 /**11484 * Lowercase request header names and their Vary configuration.11485 *11486 * The `accept` header can include `media_types`, the `accept-language`11487 * header can include `languages`, and other headers support only `action`.11488 */11489 headers?: RequestInitCfPropertiesVaryHeaders;11490}11491/** Common Vary behavior for a single request header. */11492interface RequestInitCfPropertiesVaryHeader {11493 /** How this request header contributes to cache variance. */11494 action: RequestInitCfPropertiesVaryAction;11495}11496/** Vary behavior for the `accept` request header. */11497interface RequestInitCfPropertiesVaryAcceptHeader extends RequestInitCfPropertiesVaryHeader {11498 /**11499 * Media types to keep when normalizing the `Accept` request header.11500 *11501 * Named `media_types` to match the serialized `cf.vary` configuration.11502 */11503 media_types?: string[];11504}11505/** Vary behavior for the `accept-language` request header. */11506interface RequestInitCfPropertiesVaryAcceptLanguageHeader extends RequestInitCfPropertiesVaryHeader {11507 /**11508 * Language tags to keep when normalizing the `Accept-Language` request11509 * header.11510 */11511 languages?: string[];11512}11513/**11514 * Lowercase request header names and their Vary behavior.11515 *11516 * The index signature allows arbitrary custom request headers beyond the11517 * well-known `accept` and `accept-language` specializations.11518 */11519interface RequestInitCfPropertiesVaryHeaders {11520 accept?: RequestInitCfPropertiesVaryAcceptHeader;11521 "accept-language"?: RequestInitCfPropertiesVaryAcceptLanguageHeader;11522 [header: string]: RequestInitCfPropertiesVaryHeader | RequestInitCfPropertiesVaryAcceptHeader | RequestInitCfPropertiesVaryAcceptLanguageHeader | undefined;11523}11524interface BasicImageTransformations {11525 /**11526 * Maximum width in image pixels. The value must be an integer.11527 */11528 width?: number;11529 /**11530 * Maximum height in image pixels. The value must be an integer.11531 */11532 height?: number;11533 /**11534 * When cropping with fit: "cover", this defines the side or point that should11535 * be left uncropped. The value is either a string11536 * "left", "right", "top", "bottom", "auto", or "center" (the default),11537 * or an object {x, y} containing focal point coordinates in the original11538 * image expressed as fractions ranging from 0.0 (top or left) to 1.011539 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will11540 * crop bottom or left and right sides as necessary, but won’t crop anything11541 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to11542 * preserve as much as possible around a point at 20% of the height of the11543 * source image.11544 */11545 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates;11546 /**11547 * Specifies how closely the image is cropped toward detected faces when combined11548 * with the gravity=face option. Accepts a valid range between 0.0 (includes as much11549 * of the background as possible) and 1.0 (crops the image as closely to the face as11550 * possible). The default is 0.11551 */11552 zoom?: number;11553 /**11554 * Resizing mode as a string. It affects interpretation of width and height11555 * options:11556 * - scale-down: Similar to contain, but the image is never enlarged. If11557 * the image is larger than given width or height, it will be resized.11558 * Otherwise its original size will be kept.11559 * - scale-up: Similar to contain, but the image is never shrunk. If the11560 * image is smaller than the given width or height, it will be resized.11561 * Otherwise its original size will be kept.11562 * - contain: Resizes to maximum size that fits within the given width and11563 * height. If only a single dimension is given (e.g. only width), the11564 * image will be shrunk or enlarged to exactly match that dimension.11565 * Aspect ratio is always preserved.11566 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width11567 * and height. If the image has an aspect ratio different from the ratio11568 * of width and height, it will be cropped to fit.11569 * - crop: The image will be shrunk and cropped to fit within the area11570 * specified by width and height. The image will not be enlarged. For images11571 * smaller than the given dimensions it's the same as scale-down. For11572 * images larger than the given dimensions, it's the same as cover.11573 * See also trim.11574 * - pad: Resizes to the maximum size that fits within the given width and11575 * height, and then fills the remaining area with a background color11576 * (white by default). Use of this mode is not recommended, as the same11577 * effect can be more efficiently achieved with the contain mode and the11578 * CSS object-fit: contain property.11579 * - squeeze: Stretches and deforms to the width and height given, even if it11580 * breaks aspect ratio11581 */11582 fit?: "scale-down" | "scale-up" | "contain" | "cover" | "crop" | "pad" | "squeeze";11583 /**11584 * Allows you to trim your image. Takes dpr into account and is performed before11585 * resizing or rotation.11586 *11587 * It can be used as:11588 * - left, top, right, bottom - it will specify the number of pixels to cut11589 * off each side11590 * - width, height - the width/height you'd like to end up with - can be used11591 * in combination with the properties above11592 * - border - this will automatically trim the surroundings of an image based on11593 * it's color. It consists of three properties:11594 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)11595 * - tolerance: difference from color to treat as color11596 * - keep: the number of pixels of border to keep11597 */11598 trim?: "border" | {11599 top?: number;11600 bottom?: number;11601 left?: number;11602 right?: number;11603 width?: number;11604 height?: number;11605 border?: boolean | {11606 color?: string;11607 tolerance?: number;11608 keep?: number;11609 };11610 };11611 /**11612 * Background color to add underneath the image. Applies only to images with11613 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…),11614 * hsl(…), etc.)11615 */11616 background?: string;11617 /**11618 * Flips the images horizontally, vertically, or both. Flipping is applied before11619 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped11620 * horizontally, then rotated by 90 degrees.11621 */11622 flip?: 'h' | 'v' | 'hv';11623 /**11624 * Number of degrees (90, 180, 270) to rotate the image by. width and height11625 * options refer to axes after rotation.11626 */11627 rotate?: 0 | 90 | 180 | 270 | 360;11628 /**11629 * Strength of sharpening filter to apply to the image. Floating-point11630 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a11631 * recommended value for downscaled images.11632 */11633 sharpen?: number;11634 /**11635 * Radius of a blur filter (approximate gaussian). Maximum supported radius11636 * is 250.11637 */11638 blur?: number;11639 /**11640 * Increase contrast by a factor. A value of 1.0 equals no change, a value of11641 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is11642 * ignored.11643 */11644 contrast?: number;11645 /**11646 * Increase brightness by a factor. A value of 1.0 equals no change, a value11647 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.11648 * 0 is ignored.11649 */11650 brightness?: number;11651 /**11652 * Increase exposure by a factor. A value of 1.0 equals no change, a value of11653 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.11654 */11655 gamma?: number;11656 /**11657 * Increase contrast by a factor. A value of 1.0 equals no change, a value of11658 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is11659 * ignored.11660 */11661 saturation?: number;11662 /**11663 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it11664 * easier to specify higher-DPI sizes in <img srcset>.11665 */11666 dpr?: number;11667 /**11668 * Adds a border around the image. The border is added after resizing. Border11669 * width takes dpr into account, and can be specified either using a single11670 * width property, or individually for each side.11671 */11672 border?: {11673 color: string;11674 width: number;11675 } | {11676 color: string;11677 top: number;11678 right: number;11679 bottom: number;11680 left: number;11681 };11682 /**11683 * Image segmentation using artificial intelligence models. Sets pixels not11684 * within selected segment area to transparent e.g "foreground" sets every11685 * background pixel as transparent.11686 */11687 segment?: "foreground";11688 /**11689 * Controls the algorithm used when an image needs to be enlarged. This11690 * parameter works with any fit mode that upscales, such as `contain`,11691 * `cover`, and `scale-up`. It has no effect when `fit=scale-down` or when11692 * the target dimensions are smaller than the source.11693 * - interpolate: Uses bicubic interpolation, which may reduce image quality.11694 * This is the default behavior when `upscale` is not specified.11695 * - generate: Uses AI upscaling to produce sharper, more detailed results11696 * when enlarging images.11697 */11698 upscale?: "interpolate" | "generate";11699}11700interface BasicImageTransformationsGravityCoordinates {11701 x?: number;11702 y?: number;11703 mode?: 'remainder' | 'box-center';11704}11705interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {11706 /**11707 * Absolute URL of the image file to use for the drawing. It can be any of11708 * the supported file formats. For drawing of watermarks or non-rectangular11709 * overlays we recommend using PNG or WebP images.11710 */11711 url: string;11712 /**11713 * Floating-point number between 0 (transparent) and 1 (opaque).11714 * For example, opacity: 0.5 makes overlay semitransparent.11715 */11716 opacity?: number;11717 /**11718 * - If set to true, the overlay image will be tiled to cover the entire11719 * area. This is useful for stock-photo-like watermarks.11720 * - If set to "x", the overlay image will be tiled horizontally only11721 * (form a line).11722 * - If set to "y", the overlay image will be tiled vertically only11723 * (form a line).11724 */11725 repeat?: true | "x" | "y";11726 /**11727 * How to combine the foreground and backdrop pixels to create the result11728 */11729 composite?: 11730 /** Foreground drawn on top of backdrop (default) */11731 'over'11732 /** Foreground shown only where backdrop is opaque */11733 | 'in'11734 /** Foreground drawn on top, but clipped to the backdrop's shape */11735 | 'atop'11736 /** Foreground shown only where backdrop is transparent */11737 | 'out'11738 /** Foreground and backdrop visible only where the other is not */11739 | 'xor'11740 /** Foreground and backdrop channels added (brightening) */11741 | 'lighter';11742 /**11743 * Position of the overlay image relative to a given edge. Each property is11744 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 1011745 * positions left side of the overlay 10 pixels from the left edge of the11746 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom11747 * of the background image.11748 *11749 * Setting both left & right, or both top & bottom is an error.11750 *11751 * If no position is specified, the image will be centered.11752 */11753 top?: number;11754 left?: number;11755 bottom?: number;11756 right?: number;11757}11758interface RequestInitCfPropertiesImage extends BasicImageTransformations {11759 /**11760 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values11761 * make images look worse, but load faster. The default is 85. It applies only11762 * to JPEG and WebP images. It doesn’t have any effect on PNG.11763 */11764 quality?: number | "low" | "medium-low" | "medium-high" | "high";11765 /**11766 * Output format to generate. It can be:11767 * - avif: generate images in AVIF format.11768 * - webp: generate images in Google WebP format. Set quality to 100 to get11769 * the WebP-lossless format.11770 * - json: instead of generating an image, outputs information about the11771 * image, in JSON format. The JSON object will contain image size11772 * (before and after resizing), source image’s MIME type, file size, etc.11773 * - jpeg: generate images in JPEG format.11774 * - png: generate images in PNG format.11775 */11776 format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg";11777 /**11778 * Whether to preserve animation frames from input files. Default is true.11779 * Setting it to false reduces animations to still images. This setting is11780 * recommended when enlarging images or processing arbitrary user content,11781 * because large GIF animations can weigh tens or even hundreds of megabytes.11782 * It is also useful to set anim:false when using format:"json" to get the11783 * response quicker without the number of frames.11784 */11785 anim?: boolean;11786 /**11787 * What EXIF data should be preserved in the output image. Note that EXIF11788 * rotation and embedded color profiles are always applied ("baked in" into11789 * the image), and aren't affected by this option. Note that if the Polish11790 * feature is enabled, all metadata may have been removed already and this11791 * option may have no effect.11792 * - keep: Preserve most of EXIF metadata, including GPS location if there's11793 * any.11794 * - copyright: Only keep the copyright tag, and discard everything else.11795 * This is the default behavior for JPEG files.11796 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG11797 * output formats always discard metadata.11798 */11799 metadata?: "keep" | "copyright" | "none";11800 /**11801 * Overlays are drawn in the order they appear in the array (last array11802 * entry is the topmost layer).11803 */11804 draw?: RequestInitCfPropertiesImageDraw[];11805 /**11806 * Fetching image from authenticated origin. Setting this property will11807 * pass authentication headers (Authorization, Cookie, etc.) through to11808 * the origin.11809 */11810 "origin-auth"?: "share-publicly";11811 /**11812 * Slightly reduces latency on a cache miss by selecting a11813 * quickest-to-compress file format, at a cost of increased file size and11814 * lower image quality. It will usually override the format option and choose11815 * JPEG over WebP or AVIF. We do not recommend using this option, except in11816 * unusual circumstances like resizing uncacheable dynamically-generated11817 * images.11818 */11819 compression?: "fast";11820}11821interface RequestInitCfPropertiesImageMinify {11822 javascript?: boolean;11823 css?: boolean;11824 html?: boolean;11825}11826interface RequestInitCfPropertiesR2 {11827 /**11828 * Colo id of bucket that an object is stored in11829 */11830 bucketColoId?: number;11831}11832/**11833 * Request metadata provided by Cloudflare's edge.11834 */11835type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield;11836interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {11837 /**11838 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.11839 *11840 * @example 39574711841 */11842 asn?: number;11843 /**11844 * The organization which owns the ASN of the incoming request.11845 *11846 * @example "Google Cloud"11847 */11848 asOrganization?: string;11849 /**11850 * The original value of the `Accept-Encoding` header if Cloudflare modified it.11851 *11852 * @example "gzip, deflate, br"11853 */11854 clientAcceptEncoding?: string;11855 /**11856 * The number of milliseconds it took for the request to reach your worker.11857 *11858 * @example 2211859 */11860 clientTcpRtt?: number;11861 /**11862 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)11863 * airport code of the data center that the request hit.11864 *11865 * @example "DFW"11866 */11867 colo: string;11868 /**11869 * Represents the upstream's response to a11870 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)11871 * from cloudflare.11872 *11873 * For workers with no upstream, this will always be `1`.11874 *11875 * @example 311876 */11877 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;11878 /**11879 * The HTTP Protocol the request used.11880 *11881 * @example "HTTP/2"11882 */11883 httpProtocol: string;11884 /**11885 * The browser-requested prioritization information in the request object.11886 *11887 * If no information was set, defaults to the empty string `""`11888 *11889 * @example "weight=192;exclusive=0;group=3;group-weight=127"11890 * @default ""11891 */11892 requestPriority: string;11893 /**11894 * The TLS version of the connection to Cloudflare.11895 * In requests served over plaintext (without TLS), this property is the empty string `""`.11896 *11897 * @example "TLSv1.3"11898 */11899 tlsVersion: string;11900 /**11901 * The cipher for the connection to Cloudflare.11902 * In requests served over plaintext (without TLS), this property is the empty string `""`.11903 *11904 * @example "AEAD-AES128-GCM-SHA256"11905 */11906 tlsCipher: string;11907 /**11908 * Metadata containing the [`HELLO`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2) and [`FINISHED`](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9) messages from this request's TLS handshake.11909 *11910 * If the incoming request was served over plaintext (without TLS) this field is undefined.11911 */11912 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;11913}11914interface IncomingRequestCfPropertiesBotManagementBase {11915 /**11916 * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,11917 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).11918 *11919 * @example 5411920 */11921 score: number;11922 /**11923 * A boolean value that is true if the request comes from a good bot, like Google or Bing.11924 * Most customers choose to allow this traffic. For more details, see [Traffic from known bots](https://developers.cloudflare.com/firewall/known-issues-and-faq/#how-does-firewall-rules-handle-traffic-from-known-bots).11925 */11926 verifiedBot: boolean;11927 /**11928 * A boolean value that is true if the request originates from a11929 * Cloudflare-verified proxy service.11930 */11931 corporateProxy: boolean;11932 /**11933 * A boolean value that's true if the request matches [file extensions](https://developers.cloudflare.com/bots/reference/static-resources/) for many types of static resources.11934 */11935 staticResource: boolean;11936 /**11937 * List of IDs that correlate to the Bot Management heuristic detections made on a request (you can have multiple heuristic detections on the same request).11938 */11939 detectionIds: number[];11940}11941interface IncomingRequestCfPropertiesBotManagement {11942 /**11943 * Results of Cloudflare's Bot Management analysis11944 */11945 botManagement: IncomingRequestCfPropertiesBotManagementBase;11946 /**11947 * Duplicate of `botManagement.score`.11948 *11949 * @deprecated11950 */11951 clientTrustScore: number;11952}11953interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {11954 /**11955 * Results of Cloudflare's Bot Management analysis11956 */11957 botManagement: IncomingRequestCfPropertiesBotManagementBase & {11958 /**11959 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients11960 * across different destination IPs, Ports, and X509 certificates.11961 */11962 ja3Hash: string;11963 };11964}11965interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {11966 /**11967 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).11968 *11969 * This field is only present if you have Cloudflare for SaaS enabled on your account11970 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).11971 */11972 hostMetadata?: HostMetadata;11973}11974interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {11975 /**11976 * Information about the client certificate presented to Cloudflare.11977 *11978 * This is populated when the incoming request is served over TLS using11979 * either Cloudflare Access or API Shield (mTLS)11980 * and the presented SSL certificate has a valid11981 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)11982 * (i.e., not `null` or `""`).11983 *11984 * Otherwise, a set of placeholder values are used.11985 *11986 * The property `certPresented` will be set to `"1"` when11987 * the object is populated (i.e. the above conditions were met).11988 */11989 tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;11990}11991/**11992 * Metadata about the request's TLS handshake11993 */11994interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {11995 /**11996 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal11997 *11998 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"11999 */12000 clientHandshake: string;12001 /**12002 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal12003 *12004 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"12005 */12006 serverHandshake: string;12007 /**12008 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal12009 *12010 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"12011 */12012 clientFinished: string;12013 /**12014 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal12015 *12016 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"12017 */12018 serverFinished: string;12019}12020/**12021 * Geographic data about the request's origin.12022 */12023interface IncomingRequestCfPropertiesGeographicInformation {12024 /**12025 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.12026 *12027 * If your worker is [configured to accept TOR connections](https://support.cloudflare.com/hc/en-us/articles/203306930-Understanding-Cloudflare-Tor-support-and-Onion-Routing), this may also be `"T1"`, indicating a request that originated over TOR.12028 *12029 * If Cloudflare is unable to determine where the request originated this property is omitted.12030 *12031 * The country code `"T1"` is used for requests originating on TOR.12032 *12033 * @example "GB"12034 */12035 country?: Iso3166Alpha2Code | "T1";12036 /**12037 * If present, this property indicates that the request originated in the EU12038 *12039 * @example "1"12040 */12041 isEUCountry?: "1";12042 /**12043 * A two-letter code indicating the continent the request originated from.12044 *12045 * @example "AN"12046 */12047 continent?: ContinentCode;12048 /**12049 * The city the request originated from12050 *12051 * @example "Austin"12052 */12053 city?: string;12054 /**12055 * Postal code of the incoming request12056 *12057 * @example "78701"12058 */12059 postalCode?: string;12060 /**12061 * Latitude of the incoming request12062 *12063 * @example "30.27130"12064 */12065 latitude?: string;12066 /**12067 * Longitude of the incoming request12068 *12069 * @example "-97.74260"12070 */12071 longitude?: string;12072 /**12073 * Timezone of the incoming request12074 *12075 * @example "America/Chicago"12076 */12077 timezone?: string;12078 /**12079 * If known, the ISO 3166-2 name for the first level region associated with12080 * the IP address of the incoming request12081 *12082 * @example "Texas"12083 */12084 region?: string;12085 /**12086 * If known, the ISO 3166-2 code for the first-level region associated with12087 * the IP address of the incoming request12088 *12089 * @example "TX"12090 */12091 regionCode?: string;12092 /**12093 * Metro code (DMA) of the incoming request12094 *12095 * @example "635"12096 */12097 metroCode?: string;12098}12099/** Data about the incoming request's TLS certificate */12100interface IncomingRequestCfPropertiesTLSClientAuth {12101 /** Always `"1"`, indicating that the certificate was presented */12102 certPresented: "1";12103 /**12104 * Result of certificate verification.12105 *12106 * @example "FAILED:self signed certificate"12107 */12108 certVerified: Exclude<CertVerificationStatus, "NONE">;12109 /** The presented certificate's revokation status.12110 *12111 * - A value of `"1"` indicates the certificate has been revoked12112 * - A value of `"0"` indicates the certificate has not been revoked12113 */12114 certRevoked: "1" | "0";12115 /**12116 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)12117 *12118 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"12119 */12120 certIssuerDN: string;12121 /**12122 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)12123 *12124 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"12125 */12126 certSubjectDN: string;12127 /**12128 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)12129 *12130 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"12131 */12132 certIssuerDNRFC2253: string;12133 /**12134 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)12135 *12136 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"12137 */12138 certSubjectDNRFC2253: string;12139 /** The certificate issuer's distinguished name (legacy policies) */12140 certIssuerDNLegacy: string;12141 /** The certificate subject's distinguished name (legacy policies) */12142 certSubjectDNLegacy: string;12143 /**12144 * The certificate's serial number12145 *12146 * @example "00936EACBE07F201DF"12147 */12148 certSerial: string;12149 /**12150 * The certificate issuer's serial number12151 *12152 * @example "2489002934BDFEA34"12153 */12154 certIssuerSerial: string;12155 /**12156 * The certificate's Subject Key Identifier12157 *12158 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"12159 */12160 certSKI: string;12161 /**12162 * The certificate issuer's Subject Key Identifier12163 *12164 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"12165 */12166 certIssuerSKI: string;12167 /**12168 * The certificate's SHA-1 fingerprint12169 *12170 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"12171 */12172 certFingerprintSHA1: string;12173 /**12174 * The certificate's SHA-256 fingerprint12175 *12176 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"12177 */12178 certFingerprintSHA256: string;12179 /**12180 * The effective starting date of the certificate12181 *12182 * @example "Dec 22 19:39:00 2018 GMT"12183 */12184 certNotBefore: string;12185 /**12186 * The effective expiration date of the certificate12187 *12188 * @example "Dec 22 19:39:00 2018 GMT"12189 */12190 certNotAfter: string;12191 /**12192 * The client leaf certificate in [RFC 9440](https://www.rfc-editor.org/rfc/rfc9440)12193 * format (`:base64-DER:`). Empty if no client certificate was presented or if12194 * the leaf certificate exceeded 10 KB (see {@link certRFC9440TooLarge}).12195 *12196 * Suitable for forwarding to an origin via the `Client-Cert` HTTP header.12197 */12198 certRFC9440: string;12199 /**12200 * `true` if the leaf certificate exceeded 10 KB and was omitted from12201 * {@link certRFC9440}.12202 */12203 certRFC9440TooLarge: boolean;12204 /**12205 * The intermediate certificate chain in [RFC 9440](https://www.rfc-editor.org/rfc/rfc9440)12206 * format as a comma-separated list. Empty if no intermediates were sent or12207 * if the chain exceeded 16 KB (see {@link certChainRFC9440TooLarge}).12208 *12209 * Suitable for forwarding to an origin via the `Client-Cert-Chain` HTTP header.12210 */12211 certChainRFC9440: string;12212 /**12213 * `true` if the intermediate chain exceeded 16 KB and was omitted from12214 * {@link certChainRFC9440}.12215 */12216 certChainRFC9440TooLarge: boolean;12217}12218/** Placeholder values for TLS Client Authorization */12219interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {12220 certPresented: "0";12221 certVerified: "NONE";12222 certRevoked: "0";12223 certIssuerDN: "";12224 certSubjectDN: "";12225 certIssuerDNRFC2253: "";12226 certSubjectDNRFC2253: "";12227 certIssuerDNLegacy: "";12228 certSubjectDNLegacy: "";12229 certSerial: "";12230 certIssuerSerial: "";12231 certSKI: "";12232 certIssuerSKI: "";12233 certFingerprintSHA1: "";12234 certFingerprintSHA256: "";12235 certNotBefore: "";12236 certNotAfter: "";12237 certRFC9440: "";12238 certRFC9440TooLarge: false;12239 certChainRFC9440: "";12240 certChainRFC9440TooLarge: false;12241}12242/** Possible outcomes of TLS verification */12243declare type CertVerificationStatus = 12244/** Authentication succeeded */12245"SUCCESS"12246/** No certificate was presented */12247 | "NONE"12248/** Failed because the certificate was self-signed */12249 | "FAILED:self signed certificate"12250/** Failed because the certificate failed a trust chain check */12251 | "FAILED:unable to verify the first certificate"12252/** Failed because the certificate not yet valid */12253 | "FAILED:certificate is not yet valid"12254/** Failed because the certificate is expired */12255 | "FAILED:certificate has expired"12256/** Failed for another unspecified reason */12257 | "FAILED";12258/**12259 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.12260 */12261declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus = 0 /** Unknown */ | 1 /** no keepalives (not found) */ | 2 /** no connection re-use, opening keepalive connection failed */ | 3 /** no connection re-use, keepalive accepted and saved */ | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */ | 5; /** connection re-use, accepted by the origin server */12262/** ISO 3166-1 Alpha-2 codes */12263declare type Iso3166Alpha2Code = "AD" | "AE" | "AF" | "AG" | "AI" | "AL" | "AM" | "AO" | "AQ" | "AR" | "AS" | "AT" | "AU" | "AW" | "AX" | "AZ" | "BA" | "BB" | "BD" | "BE" | "BF" | "BG" | "BH" | "BI" | "BJ" | "BL" | "BM" | "BN" | "BO" | "BQ" | "BR" | "BS" | "BT" | "BV" | "BW" | "BY" | "BZ" | "CA" | "CC" | "CD" | "CF" | "CG" | "CH" | "CI" | "CK" | "CL" | "CM" | "CN" | "CO" | "CR" | "CU" | "CV" | "CW" | "CX" | "CY" | "CZ" | "DE" | "DJ" | "DK" | "DM" | "DO" | "DZ" | "EC" | "EE" | "EG" | "EH" | "ER" | "ES" | "ET" | "FI" | "FJ" | "FK" | "FM" | "FO" | "FR" | "GA" | "GB" | "GD" | "GE" | "GF" | "GG" | "GH" | "GI" | "GL" | "GM" | "GN" | "GP" | "GQ" | "GR" | "GS" | "GT" | "GU" | "GW" | "GY" | "HK" | "HM" | "HN" | "HR" | "HT" | "HU" | "ID" | "IE" | "IL" | "IM" | "IN" | "IO" | "IQ" | "IR" | "IS" | "IT" | "JE" | "JM" | "JO" | "JP" | "KE" | "KG" | "KH" | "KI" | "KM" | "KN" | "KP" | "KR" | "KW" | "KY" | "KZ" | "LA" | "LB" | "LC" | "LI" | "LK" | "LR" | "LS" | "LT" | "LU" | "LV" | "LY" | "MA" | "MC" | "MD" | "ME" | "MF" | "MG" | "MH" | "MK" | "ML" | "MM" | "MN" | "MO" | "MP" | "MQ" | "MR" | "MS" | "MT" | "MU" | "MV" | "MW" | "MX" | "MY" | "MZ" | "NA" | "NC" | "NE" | "NF" | "NG" | "NI" | "NL" | "NO" | "NP" | "NR" | "NU" | "NZ" | "OM" | "PA" | "PE" | "PF" | "PG" | "PH" | "PK" | "PL" | "PM" | "PN" | "PR" | "PS" | "PT" | "PW" | "PY" | "QA" | "RE" | "RO" | "RS" | "RU" | "RW" | "SA" | "SB" | "SC" | "SD" | "SE" | "SG" | "SH" | "SI" | "SJ" | "SK" | "SL" | "SM" | "SN" | "SO" | "SR" | "SS" | "ST" | "SV" | "SX" | "SY" | "SZ" | "TC" | "TD" | "TF" | "TG" | "TH" | "TJ" | "TK" | "TL" | "TM" | "TN" | "TO" | "TR" | "TT" | "TV" | "TW" | "TZ" | "UA" | "UG" | "UM" | "US" | "UY" | "UZ" | "VA" | "VC" | "VE" | "VG" | "VI" | "VN" | "VU" | "WF" | "WS" | "YE" | "YT" | "ZA" | "ZM" | "ZW";12264/** The 2-letter continent codes Cloudflare uses */12265declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";12266type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties;12267interface D1Meta {12268 duration: number;12269 size_after: number;12270 rows_read: number;12271 rows_written: number;12272 last_row_id: number;12273 changed_db: boolean;12274 changes: number;12275 /**12276 * The region of the database instance that executed the query.12277 */12278 served_by_region?: string;12279 /**12280 * The three letters airport code of the colo that executed the query.12281 */12282 served_by_colo?: string;12283 /**12284 * True if-and-only-if the database instance that executed the query was the primary.12285 */12286 served_by_primary?: boolean;12287 timings?: {12288 /**12289 * The duration of the SQL query execution by the database instance. It doesn't include any network time.12290 */12291 sql_duration_ms: number;12292 };12293 /**12294 * Number of total attempts to execute the query, due to automatic retries.12295 * Note: All other fields in the response like `timings` only apply to the last attempt.12296 */12297 total_attempts?: number;12298}12299interface D1Response {12300 success: true;12301 meta: D1Meta & Record<string, unknown>;12302 error?: never;12303}12304type D1Result<T = unknown> = D1Response & {12305 results: T[];12306};12307interface D1ExecResult {12308 count: number;12309 duration: number;12310}12311type D1SessionConstraint = 12312// Indicates that the first query should go to the primary, and the rest queries12313// using the same D1DatabaseSession will go to any replica that is consistent with12314// the bookmark maintained by the session (returned by the first query).12315'first-primary'12316// Indicates that the first query can go anywhere (primary or replica), and the rest queries12317// using the same D1DatabaseSession will go to any replica that is consistent with12318// the bookmark maintained by the session (returned by the first query).12319 | 'first-unconstrained';12320type D1SessionBookmark = string;12321declare abstract class D1Database {12322 prepare(query: string): D1PreparedStatement;12323 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;12324 exec(query: string): Promise<D1ExecResult>;12325 /**12326 * Creates a new D1 Session anchored at the given constraint or the bookmark.12327 * All queries executed using the created session will have sequential consistency,12328 * meaning that all writes done through the session will be visible in subsequent reads.12329 *12330 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.12331 */12332 withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession;12333 /**12334 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.12335 */12336 dump(): Promise<ArrayBuffer>;12337}12338declare abstract class D1DatabaseSession {12339 prepare(query: string): D1PreparedStatement;12340 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;12341 /**12342 * @returns The latest session bookmark across all executed queries on the session.12343 * If no query has been executed yet, `null` is returned.12344 */12345 getBookmark(): D1SessionBookmark | null;12346}12347declare abstract class D1PreparedStatement {12348 bind(...values: unknown[]): D1PreparedStatement;12349 first<T = unknown>(colName: string): Promise<T | null>;12350 first<T = Record<string, unknown>>(): Promise<T | null>;12351 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;12352 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;12353 raw<T = unknown[]>(options: {12354 columnNames: true;12355 }): Promise<[12356 string[],12357 ...T[]12358 ]>;12359 raw<T = unknown[]>(options?: {12360 columnNames?: false;12361 }): Promise<T[]>;12362}12363// `Disposable` was added to TypeScript's standard lib types in version 5.2.12364// To support older TypeScript versions, define an empty `Disposable` interface.12365// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,12366// but this will ensure type checking on older versions still passes.12367// TypeScript's interface merging will ensure our empty interface is effectively12368// ignored when `Disposable` is included in the standard lib.12369interface Disposable {12370}12371/**12372 * The returned data after sending an email12373 */12374interface EmailSendResult {12375 /**12376 * The Email Message ID12377 */12378 messageId: string;12379}12380/**12381 * An email message that can be sent from a Worker.12382 */12383interface EmailMessage {12384 /**12385 * Envelope From attribute of the email message.12386 */12387 readonly from: string;12388 /**12389 * Envelope To attribute of the email message.12390 */12391 readonly to: string;12392}12393/**12394 * An email message that is sent to a consumer Worker and can be rejected/forwarded.12395 */12396interface ForwardableEmailMessage extends EmailMessage {12397 /**12398 * Stream of the email message content.12399 */12400 readonly raw: ReadableStream<Uint8Array>;12401 /**12402 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).12403 */12404 readonly headers: Headers;12405 /**12406 * Size of the email message content.12407 */12408 readonly rawSize: number;12409 /**12410 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.12411 * @param reason The reject reason.12412 * @returns void12413 */12414 setReject(reason: string): void;12415 /**12416 * Forward this email message to a verified destination address of the account.12417 * @param rcptTo Verified destination address.12418 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).12419 * @returns A promise that resolves when the email message is forwarded.12420 */12421 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;12422 /**12423 * Reply to the sender of this email message with a new EmailMessage object.12424 * @param message The reply message.12425 * @returns A promise that resolves when the email message is replied.12426 */12427 reply(message: EmailMessage): Promise<EmailSendResult>;12428 /**12429 * Reply to the sender of this email message with a message built from the given12430 * fields. Threading headers (In-Reply-To/References) are set automatically.12431 * @param builder The reply message contents.12432 * @returns A promise that resolves when the email message is replied.12433 */12434 reply(builder: EmailReplyMessageBuilder): Promise<EmailSendResult>;12435}12436/** A file attachment for an email message */12437type EmailAttachment = {12438 disposition: 'inline';12439 contentId: string;12440 filename: string;12441 type: string;12442 content: string | ArrayBuffer | ArrayBufferView;12443} | {12444 disposition: 'attachment';12445 contentId?: undefined;12446 filename: string;12447 type: string;12448 content: string | ArrayBuffer | ArrayBufferView;12449};12450/** An Email Address */12451interface EmailAddress {12452 name: string;12453 email: string;12454}12455/**12456 * Recipient fields for `SendEmail.send()`. At least one of `to`, `cc`, or12457 * `bcc` must be provided.12458 */12459type EmailDestinations = {12460 to?: string | EmailAddress | (string | EmailAddress)[];12461 cc?: string | EmailAddress | (string | EmailAddress)[];12462 bcc?: string | EmailAddress | (string | EmailAddress)[];12463} & ({12464 to: string | EmailAddress | (string | EmailAddress)[];12465} | {12466 cc: string | EmailAddress | (string | EmailAddress)[];12467} | {12468 bcc: string | EmailAddress | (string | EmailAddress)[];12469});12470/**12471 * Fields shared by all composed emails (no recipients). Used directly by12472 * `ForwardableEmailMessage.reply()`, which always replies to the original12473 * sender, and extended by `EmailMessageBuilder` for `SendEmail.send()`.12474 */12475interface EmailReplyMessageBuilder {12476 from: string | EmailAddress;12477 subject: string;12478 replyTo?: string | EmailAddress;12479 headers?: Record<string, string>;12480 text?: string;12481 html?: string;12482 attachments?: EmailAttachment[];12483}12484/**12485 * Fields for composing an email without constructing raw MIME, for12486 * `SendEmail.send()`. Requires at least one of `to`, `cc`, or `bcc`.12487 */12488type EmailMessageBuilder = EmailReplyMessageBuilder & EmailDestinations;12489/**12490 * A binding that allows a Worker to send email messages.12491 */12492interface SendEmail {12493 send(message: EmailMessage): Promise<EmailSendResult>;12494 send(builder: EmailMessageBuilder): Promise<EmailSendResult>;12495}12496declare abstract class EmailEvent extends ExtendableEvent {12497 readonly message: ForwardableEmailMessage;12498}12499declare type EmailExportedHandler<Env = unknown, Props = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;12500declare module "cloudflare:email" {12501 let _EmailMessage: {12502 prototype: EmailMessage;12503 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;12504 };12505 export { _EmailMessage as EmailMessage };12506}12507/**12508 * Evaluation context for targeting rules.12509 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.12510 */12511type FlagshipEvaluationContext = Record<string, string | number | boolean>;12512interface FlagshipEvaluationDetails<T> {12513 flagKey: string;12514 value: T;12515 variant?: string | undefined;12516 reason?: string | undefined;12517 errorCode?: string | undefined;12518 errorMessage?: string | undefined;12519}12520interface FlagshipEvaluationError extends Error {12521}12522/**12523 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.12524 *12525 * @example12526 * ```typescript12527 * // Get a boolean flag value with a default12528 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);12529 *12530 * // Get a flag value with evaluation context for targeting12531 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {12532 * userId: 'user-123',12533 * country: 'US',12534 * });12535 *12536 * // Get full evaluation details including variant and reason12537 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);12538 * console.log(details.variant, details.reason);12539 * ```12540 */12541declare abstract class Flagship {12542 /**12543 * Get a flag value without type checking.12544 * @param flagKey The key of the flag to evaluate.12545 * @param defaultValue Optional default value returned when evaluation fails.12546 * @param context Optional evaluation context for targeting rules.12547 */12548 get(flagKey: string, defaultValue?: unknown, context?: FlagshipEvaluationContext): Promise<unknown>;12549 /**12550 * Get a boolean flag value.12551 * @param flagKey The key of the flag to evaluate.12552 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12553 * @param context Optional evaluation context for targeting rules.12554 */12555 getBooleanValue(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<boolean>;12556 /**12557 * Get a string flag value.12558 * @param flagKey The key of the flag to evaluate.12559 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12560 * @param context Optional evaluation context for targeting rules.12561 */12562 getStringValue(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<string>;12563 /**12564 * Get a number flag value.12565 * @param flagKey The key of the flag to evaluate.12566 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12567 * @param context Optional evaluation context for targeting rules.12568 */12569 getNumberValue(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<number>;12570 /**12571 * Get an object flag value.12572 * @param flagKey The key of the flag to evaluate.12573 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12574 * @param context Optional evaluation context for targeting rules.12575 */12576 getObjectValue<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<T>;12577 /**12578 * Get a boolean flag value with full evaluation details.12579 * @param flagKey The key of the flag to evaluate.12580 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12581 * @param context Optional evaluation context for targeting rules.12582 */12583 getBooleanDetails(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<boolean>>;12584 /**12585 * Get a string flag value with full evaluation details.12586 * @param flagKey The key of the flag to evaluate.12587 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12588 * @param context Optional evaluation context for targeting rules.12589 */12590 getStringDetails(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<string>>;12591 /**12592 * Get a number flag value with full evaluation details.12593 * @param flagKey The key of the flag to evaluate.12594 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12595 * @param context Optional evaluation context for targeting rules.12596 */12597 getNumberDetails(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<number>>;12598 /**12599 * Get an object flag value with full evaluation details.12600 * @param flagKey The key of the flag to evaluate.12601 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.12602 * @param context Optional evaluation context for targeting rules.12603 */12604 getObjectDetails<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<T>>;12605}12606/**12607 * Hello World binding to serve as an explanatory example. DO NOT USE12608 */12609interface HelloWorldBinding {12610 /**12611 * Retrieve the current stored value12612 */12613 get(): Promise<{12614 value: string;12615 ms?: number;12616 }>;12617 /**12618 * Set a new stored value12619 */12620 set(value: string): Promise<void>;12621}12622interface Hyperdrive {12623 /**12624 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.12625 *12626 * Calling this method returns an identical socket to if you call12627 * `connect("host:port")` using the `host` and `port` fields from this object.12628 * Pick whichever approach works better with your preferred DB client library.12629 *12630 * Note that this socket is not yet authenticated -- it's expected that your12631 * code (or preferably, the client library of your choice) will authenticate12632 * using the information in this class's readonly fields.12633 */12634 connect(): Socket;12635 /**12636 * A valid DB connection string that can be passed straight into the typical12637 * client library/driver/ORM. This will typically be the easiest way to use12638 * Hyperdrive.12639 */12640 readonly connectionString: string;12641 /*12642 * A randomly generated hostname that is only valid within the context of the12643 * currently running Worker which, when passed into `connect()` function from12644 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance12645 * for your database.12646 */12647 readonly host: string;12648 /*12649 * A synthetic IPv4 address (in the reserved 240.0.0.0/4 range) that, like the12650 * host field, is only valid within the context of the currently running12651 * Worker and, when passed into the `connect()` function from the12652 * "cloudflare:sockets" module, will connect to the Hyperdrive instance for12653 * your database. This is provided for database drivers that require the host12654 * to be an IP literal rather than a hostname.12655 */12656 readonly ip: string;12657 /*12658 * The port that must be paired the the host field when connecting.12659 */12660 readonly port: number;12661 /*12662 * The username to use when authenticating to your database via Hyperdrive.12663 * Unlike the host and password, this will be the same every time12664 */12665 readonly user: string;12666 /*12667 * The randomly generated password to use when authenticating to your12668 * database via Hyperdrive. Like the host field, this password is only valid12669 * within the context of the currently running Worker instance from which12670 * it's read.12671 */12672 readonly password: string;12673 /*12674 * The name of the database to connect to.12675 */12676 readonly database: string;12677}12678// Copyright (c) 2024 Cloudflare, Inc.12679// Licensed under the Apache 2.0 license found in the LICENSE file or at:12680// https://opensource.org/licenses/Apache-2.012681type ImageInfoResponse = {12682 format: 'image/svg+xml';12683} | {12684 format: string;12685 fileSize: number;12686 width: number;12687 height: number;12688};12689/**12690 * Parameters for rasterizing text into an image.12691 */12692type TextRasterize = {12693 /** The text content to render */12694 content: string;12695 /** rasterization options for the text **/12696 options: TextOptions;12697};12698type TextOptions = {12699 /** Font configuration */12700 font: {12701 /** URL to a font file in TrueType (.ttf), OpenType (.otf), WOFF (.woff), or WOFF2 (.woff2) format */12702 url: string;12703 };12704 /** Font size in points (pt) */12705 size?: number;12706 /** Text color in CSS format: hex (#RRGGBB or #RRGGBBAA), rgb(r,g,b), rgba(r,g,b,a), or named colors */12707 color?: string;12708};12709type ImageSource = ReadableStream<Uint8Array> | TextRasterize;12710type ImageTransform = {12711 width?: number;12712 height?: number;12713 background?: string;12714 blur?: number;12715 border?: {12716 color?: string;12717 width?: number;12718 } | {12719 top?: number;12720 bottom?: number;12721 left?: number;12722 right?: number;12723 };12724 brightness?: number;12725 contrast?: number;12726 fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop';12727 flip?: 'h' | 'v' | 'hv';12728 gamma?: number;12729 segment?: 'foreground';12730 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | {12731 x?: number;12732 y?: number;12733 mode: 'remainder' | 'box-center';12734 };12735 rotate?: 0 | 90 | 180 | 270;12736 saturation?: number;12737 sharpen?: number;12738 trim?: 'border' | {12739 top?: number;12740 bottom?: number;12741 left?: number;12742 right?: number;12743 width?: number;12744 height?: number;12745 border?: boolean | {12746 color?: string;12747 tolerance?: number;12748 keep?: number;12749 };12750 };12751};12752type ImageDrawOptions = {12753 opacity?: number;12754 repeat?: boolean | string;12755 composite?: ImageCompositeMode;12756 top?: number;12757 left?: number;12758 bottom?: number;12759 right?: number;12760};12761type ImageCompositeMode = 12762/** Foreground drawn on top of backdrop (default) */12763'over'12764/** Foreground shown only where backdrop is opaque */12765 | 'in'12766/** Foreground drawn on top, but clipped to the backdrop's shape */12767 | 'atop'12768/** Foreground shown only where backdrop is transparent */12769 | 'out'12770/** Foreground and backdrop visible only where the other is not */12771 | 'xor'12772/** Foreground and backdrop channels added (brightening) */12773 | 'lighter';12774type ImageInputOptions = {12775 encoding?: 'base64';12776};12777type ImageOutputOptions = {12778 format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba';12779 quality?: number;12780 background?: string;12781 anim?: boolean;12782};12783interface ImageMetadata {12784 id: string;12785 filename?: string;12786 uploaded?: string;12787 requireSignedURLs: boolean;12788 meta?: Record<string, unknown>;12789 variants: string[];12790 draft?: boolean;12791 creator?: string;12792}12793interface ImageUploadOptions {12794 id?: string;12795 filename?: string;12796 requireSignedURLs?: boolean;12797 metadata?: Record<string, unknown>;12798 creator?: string;12799 /**12800 * If 'base64', the input data will be decoded from base64 before processing12801 */12802 encoding?: 'base64';12803}12804interface ImageUpdateOptions {12805 requireSignedURLs?: boolean;12806 metadata?: Record<string, unknown>;12807 creator?: string;12808}12809type ImageMetadataFilterOperators = {12810 eq?: string | number | boolean;12811 in?: string[] | number[];12812 gt?: number;12813 gte?: number;12814 lt?: number;12815 lte?: number;12816};12817type ImageMetadataFilterValue = string | number | boolean | ImageMetadataFilterOperators;12818interface ImageListFilter {12819 metadata?: Record<string, ImageMetadataFilterValue>;12820}12821interface ImageListOptions {12822 limit?: number;12823 cursor?: string;12824 sortOrder?: 'asc' | 'desc';12825 creator?: string;12826 filter?: ImageListFilter;12827}12828interface ImageSignedUrlOptions {12829 variant: string;12830 expiresIn?: number;12831 keyName?: string;12832}12833interface ImageDirectUploadOptions {12834 id?: string;12835 requireSignedURLs?: boolean;12836 metadata?: Record<string, unknown>;12837 creator?: string;12838 expiresIn?: number;12839}12840interface ImageDirectUploadResult {12841 id: string;12842 uploadURL: string;12843}12844interface ImageList {12845 images: ImageMetadata[];12846 cursor?: string;12847 listComplete: boolean;12848}12849interface ImageHandle {12850 /**12851 * Get metadata for a hosted image12852 * @returns Image metadata, or null if not found12853 */12854 details(): Promise<ImageMetadata | null>;12855 /**12856 * Get the raw image data for a hosted image12857 * @returns ReadableStream of image bytes, or null if not found12858 */12859 bytes(): Promise<ReadableStream<Uint8Array> | null>;12860 /**12861 * Generate a signed delivery URL for this hosted image.12862 * @param options Signing configuration12863 * @returns A signed image delivery URL12864 * @throws {@link ImagesError} if signing fails12865 */12866 signedUrl(options: ImageSignedUrlOptions): Promise<string>;12867 /**12868 * Update hosted image metadata12869 * @param options Properties to update12870 * @returns Updated image metadata12871 * @throws {@link ImagesError} if update fails12872 */12873 update(options: ImageUpdateOptions): Promise<ImageMetadata>;12874 /**12875 * Delete a hosted image12876 * @returns True if deleted, false if not found12877 */12878 delete(): Promise<boolean>;12879}12880interface HostedImagesBinding {12881 /**12882 * Get a handle for a hosted image12883 * @param imageId The ID of the image (UUID or custom ID)12884 * @returns A handle for per-image operations12885 */12886 image(imageId: string): ImageHandle;12887 /**12888 * Upload a new hosted image12889 * @param image The image file to upload12890 * @param options Upload configuration12891 * @returns Metadata for the uploaded image12892 * @throws {@link ImagesError} if upload fails12893 */12894 upload(image: ReadableStream<Uint8Array> | ArrayBuffer, options?: ImageUploadOptions): Promise<ImageMetadata>;12895 /**12896 * List hosted images with pagination12897 * @param options List configuration12898 * @returns List of images with pagination info12899 * @throws {@link ImagesError} if list fails12900 */12901 list(options?: ImageListOptions): Promise<ImageList>;12902 /**12903 * Create a Direct Creator Upload link, letting an end user upload an12904 * image straight to Cloudflare without exposing an API token12905 * @param options Upload link configuration12906 * @returns The new image ID and the upload URL to hand to the end user12907 * @throws {@link ImagesError} if creation fails12908 */12909 createDirectUpload(options?: ImageDirectUploadOptions): Promise<ImageDirectUploadResult>;12910}12911interface ImagesBinding {12912 /**12913 * Get image metadata (type, width and height)12914 * @throws {@link ImagesError} with code 9412 if input is not an image12915 * @param stream The image bytes12916 */12917 info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>;12918 /**12919 * Begin applying a series of transformations to an image12920 * @param stream The image bytes12921 * @returns A transform handle12922 */12923 input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer;12924 /**12925 * Begin applying a series of transformations to text12926 * @param content string to be rendered12927 * @param options font, optional color and size to use in rendering text12928 * @returns A transform handle12929 */12930 text(content: string, options: TextOptions): ImageTransformer;12931 /**12932 * Access hosted images CRUD operations12933 */12934 readonly hosted: HostedImagesBinding;12935}12936interface ImageTransformer {12937 /**12938 * Apply transform next, returning a transform handle.12939 * You can then apply more transformations, draw, or retrieve the output.12940 * @param transform12941 */12942 transform(transform: ImageTransform): ImageTransformer;12943 /**12944 * Draw an image on this transformer, returning a transform handle.12945 * You can then apply more transformations, draw, or retrieve the output.12946 * @param image The image (or transformer that will give the image) to draw12947 * @param options The options configuring how to draw the image12948 */12949 draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer;12950 /**12951 * Retrieve the image that results from applying the transforms to the12952 * provided input12953 * @param options Options that apply to the output e.g. output format12954 */12955 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;12956}12957type ImageTransformationOutputOptions = {12958 encoding?: 'base64';12959};12960type ImageTransformationResponseOptions = {12961 headers?: HeadersInit;12962};12963interface ImageTransformationResult {12964 /**12965 * The image as a response, ready to store in cache or return to users12966 * @param options Options that apply to the returned response, e.g. additional headers12967 */12968 response(options?: ImageTransformationResponseOptions): Response;12969 /**12970 * The content type of the returned image12971 */12972 contentType(): string;12973 /**12974 * The bytes of the response12975 */12976 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;12977}12978interface ImagesError extends Error {12979 readonly code: number;12980 readonly message: string;12981 readonly stack?: string;12982}12983/**12984 * Media binding for transforming media streams.12985 * Provides the entry point for media transformation operations.12986 */12987interface MediaBinding {12988 /**12989 * Creates a media transformer from an input stream.12990 * @param media - The input media bytes12991 * @returns A MediaTransformer instance for applying transformations12992 */12993 input(media: ReadableStream<Uint8Array>): MediaTransformer;12994}12995/**12996 * Media transformer for applying transformation operations to media content.12997 * Handles sizing, fitting, and other input transformation parameters.12998 */12999interface MediaTransformer {13000 /**13001 * Applies transformation options to the media content.13002 * @param transform - Configuration for how the media should be transformed13003 * @returns A generator for producing the transformed media output13004 */13005 transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator;13006 /**13007 * Generates the final media output with specified options.13008 * @param output - Configuration for the output format and parameters13009 * @returns The final transformation result containing the transformed media13010 */13011 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;13012}13013/**13014 * Generator for producing media transformation results.13015 * Configures the output format and parameters for the transformed media.13016 */13017interface MediaTransformationGenerator {13018 /**13019 * Generates the final media output with specified options.13020 * @param output - Configuration for the output format and parameters13021 * @returns The final transformation result containing the transformed media13022 */13023 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;13024}13025/**13026 * Result of a media transformation operation.13027 * Provides multiple ways to access the transformed media content.13028 */13029interface MediaTransformationResult {13030 /**13031 * Returns the transformed media as a readable stream of bytes.13032 * @returns A promise containing a readable stream with the transformed media13033 */13034 media(): Promise<ReadableStream<Uint8Array>>;13035 /**13036 * Returns the transformed media as an HTTP response object.13037 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users13038 */13039 response(): Promise<Response>;13040 /**13041 * Returns the MIME type of the transformed media.13042 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')13043 */13044 contentType(): Promise<string>;13045}13046/**13047 * Configuration options for transforming media input.13048 * Controls how the media should be resized and fitted.13049 */13050type MediaTransformationInputOptions = {13051 /** How the media should be resized to fit the specified dimensions */13052 fit?: 'contain' | 'cover' | 'scale-down';13053 /** Target width in pixels */13054 width?: number;13055 /** Target height in pixels */13056 height?: number;13057};13058/**13059 * Configuration options for Media Transformations output.13060 * Controls the format, timing, and type of the generated output.13061 */13062type MediaTransformationOutputOptions = {13063 /**13064 * Output mode determining the type of media to generate13065 */13066 mode?: 'video' | 'spritesheet' | 'frame' | 'audio';13067 /** Whether to include audio in the output */13068 audio?: boolean;13069 /**13070 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').13071 */13072 time?: string;13073 /**13074 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').13075 */13076 duration?: string;13077 /**13078 * Number of frames in the spritesheet.13079 */13080 imageCount?: number;13081 /**13082 * Output format for the generated media.13083 */13084 format?: 'jpg' | 'png' | 'm4a';13085};13086/**13087 * Error object for media transformation operations.13088 * Extends the standard Error interface with additional media-specific information.13089 */13090interface MediaError extends Error {13091 readonly code: number;13092 readonly message: string;13093 readonly stack?: string;13094}13095declare module 'cloudflare:node' {13096 interface NodeStyleServer {13097 listen(...args: unknown[]): this;13098 address(): {13099 port?: number | null | undefined;13100 };13101 }13102 export function httpServerHandler(port: number): ExportedHandler;13103 export function httpServerHandler(options: {13104 port: number;13105 }): ExportedHandler;13106 export function httpServerHandler(server: NodeStyleServer): ExportedHandler;13107}13108type Params<P extends string = any> = Record<P, string | string[]>;13109type EventContext<Env, P extends string, Data> = {13110 request: Request<unknown, IncomingRequestCfProperties<unknown>>;13111 functionPath: string;13112 waitUntil: (promise: Promise<any>) => void;13113 passThroughOnException: () => void;13114 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;13115 env: Env & {13116 ASSETS: {13117 fetch: typeof fetch;13118 };13119 };13120 params: Params<P>;13121 data: Data;13122};13123type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;13124type EventPluginContext<Env, P extends string, Data, PluginArgs> = {13125 request: Request<unknown, IncomingRequestCfProperties<unknown>>;13126 functionPath: string;13127 waitUntil: (promise: Promise<any>) => void;13128 passThroughOnException: () => void;13129 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;13130 env: Env & {13131 ASSETS: {13132 fetch: typeof fetch;13133 };13134 };13135 params: Params<P>;13136 data: Data;13137 pluginArgs: PluginArgs;13138};13139type PagesPluginFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>, PluginArgs = unknown> = (context: EventPluginContext<Env, Params, Data, PluginArgs>) => Response | Promise<Response>;13140declare module "assets:*" {13141 export const onRequest: PagesFunction;13142}13143// Copyright (c) 2022-2023 Cloudflare, Inc.13144// Licensed under the Apache 2.0 license found in the LICENSE file or at:13145// https://opensource.org/licenses/Apache-2.013146declare module "cloudflare:pipelines" {13147 export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> {13148 protected env: Env;13149 protected ctx: ExecutionContext;13150 constructor(ctx: ExecutionContext, env: Env);13151 /**13152 * run receives an array of PipelineRecord which can be13153 * transformed and returned to the pipeline13154 * @param records Incoming records from the pipeline to be transformed13155 * @param metadata Information about the specific pipeline calling the transformation entrypoint13156 * @returns A promise containing the transformed PipelineRecord array13157 */13158 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;13159 }13160 export type PipelineRecord = Record<string, unknown>;13161 export type PipelineBatchMetadata = {13162 pipelineId: string;13163 pipelineName: string;13164 };13165 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {13166 /**13167 * The Pipeline interface represents the type of a binding to a Pipeline13168 *13169 * @param records The records to send to the pipeline13170 */13171 send(records: T[]): Promise<void>;13172 }13173}13174// PubSubMessage represents an incoming PubSub message.13175// The message includes metadata about the broker, the client, and the payload13176// itself.13177// https://developers.cloudflare.com/pub-sub/13178interface PubSubMessage {13179 // Message ID13180 readonly mid: number;13181 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT13182 readonly broker: string;13183 // The MQTT topic the message was sent on.13184 readonly topic: string;13185 // The client ID of the client that published this message.13186 readonly clientId: string;13187 // The unique identifier (JWT ID) used by the client to authenticate, if token13188 // auth was used.13189 readonly jti?: string;13190 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker13191 // received the message from the client.13192 readonly receivedAt: number;13193 // An (optional) string with the MIME type of the payload, if set by the13194 // client.13195 readonly contentType: string;13196 // Set to 1 when the payload is a UTF-8 string13197 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc390106313198 readonly payloadFormatIndicator: number;13199 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.13200 // You can use payloadFormatIndicator to inspect this before decoding.13201 payload: string | Uint8Array;13202}13203// JsonWebKey extended by kid parameter13204interface JsonWebKeyWithKid extends JsonWebKey {13205 // Key Identifier of the JWK13206 readonly kid: string;13207}13208interface RateLimitOptions {13209 key: string;13210}13211interface RateLimitOutcome {13212 success: boolean;13213}13214interface RateLimit {13215 /**13216 * Rate limit a request based on the provided options.13217 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/13218 * @returns A promise that resolves with the outcome of the rate limit.13219 */13220 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;13221}13222// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need13223// to referenced by `Fetcher`. This is included in the "importable" version of the types which13224// strips all `module` blocks.13225declare namespace Rpc {13226 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.13227 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.13228 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to13229 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)13230 export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND';13231 export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND';13232 export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND';13233 export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND';13234 export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND';13235 export interface RpcTargetBranded {13236 [__RPC_TARGET_BRAND]: never;13237 }13238 export interface WorkerEntrypointBranded {13239 [__WORKER_ENTRYPOINT_BRAND]: never;13240 }13241 export interface DurableObjectBranded {13242 [__DURABLE_OBJECT_BRAND]: never;13243 }13244 export interface WorkflowEntrypointBranded {13245 [__WORKFLOW_ENTRYPOINT_BRAND]: never;13246 }13247 export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded;13248 // Types that can be used through `Stub`s13249 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);13250 // Types that can be passed over RPC13251 // The reason for using a generic type here is to build a serializable subset of structured13252 // cloneable composite types. This allows types defined with the "interface" keyword to pass the13253 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.13254 type Serializable<T> = 13255 // Structured cloneables13256 BaseType13257 // Structured cloneable composites13258 | Map<T extends Map<infer U, unknown> ? Serializable<U> : never, T extends Map<unknown, infer U> ? Serializable<U> : never> | Set<T extends Set<infer U> ? Serializable<U> : never> | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never> | {13259 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;13260 }13261 // Special types13262 | Stub<Stubable>13263 // Serialized as stubs, see `Stubify`13264 | Stubable;13265 // Base type for all RPC stubs, including common memory management methods.13266 // `T` is used as a marker type for unwrapping `Stub`s later.13267 interface StubBase<T extends Stubable> extends Disposable {13268 [__RPC_STUB_BRAND]: T;13269 dup(): this;13270 }13271 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;13272 // This represents all the types that can be sent as-is over an RPC boundary13273 type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers;13274 // Recursively rewrite all `Stubable` types with `Stub`s13275 // prettier-ignore13276 type Stubify<T> = T extends Stubable ? Stub<T> : T extends Map<infer K, infer V> ? Map<Stubify<K>, Stubify<V>> : T extends Set<infer V> ? Set<Stubify<V>> : T extends Array<infer V> ? Array<Stubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Stubify<V>> : T extends BaseType ? T : T extends {13277 [key: string | number]: any;13278 } ? {13279 [K in keyof T]: Stubify<T[K]>;13280 } : T;13281 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.13282 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:13283 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.13284 // prettier-ignore13285 type Unstubify<T> = T extends StubBase<infer V> ? V : T extends Map<infer K, infer V> ? Map<Unstubify<K>, Unstubify<V>> : T extends Set<infer V> ? Set<Unstubify<V>> : T extends Array<infer V> ? Array<Unstubify<V>> : T extends ReadonlyArray<infer V> ? ReadonlyArray<Unstubify<V>> : T extends BaseType ? T : T extends {13286 [key: string | number]: unknown;13287 } ? {13288 [K in keyof T]: Unstubify<T[K]>;13289 } : T;13290 type UnstubifyAll<A extends any[]> = {13291 [I in keyof A]: Unstubify<A[I]>;13292 };13293 // Utility type for adding `Provider`/`Disposable`s to `object` types only.13294 // Note `unknown & T` is equivalent to `T`.13295 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;13296 type MaybeDisposable<T> = T extends object ? Disposable : unknown;13297 // Type for method return or property on an RPC interface.13298 // - Stubable types are replaced by stubs.13299 // - Serializable types are passed by value, with stubable types replaced by stubs13300 // and a top-level `Disposer`.13301 // Everything else can't be passed over PRC.13302 // Technically, we use custom thenables here, but they quack like `Promise`s.13303 // Intersecting with `(Maybe)Provider` allows pipelining.13304 // prettier-ignore13305 type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never;13306 // Type for method or property on an RPC interface.13307 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.13308 // Unwrapping `Stub`s allows calling with `Stubable` arguments.13309 // For properties, rewrite types to be `Result`s.13310 // In each case, unwrap `Promise`s.13311 type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>;13312 // Type for the callable part of an `Provider` if `T` is callable.13313 // This is intersected with methods/properties.13314 type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown;13315 // Base type for all other types providing RPC-like interfaces.13316 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.13317 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.13318 export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & Pick<{13319 [K in keyof T]: MethodOrProperty<T[K]>;13320 }, Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>>;13321}13322declare namespace Cloudflare {13323 // Type of `env`.13324 //13325 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript13326 // will merge all declarations.13327 //13328 // You can use `wrangler types` to generate the `Env` type automatically.13329 interface Env {13330 }13331 // Project-specific parameters used to inform types.13332 //13333 // This interface is, again, intended to be declared in project-specific files, and then that13334 // declaration will be merged with this one.13335 //13336 // A project should have a declaration like this:13337 //13338 // interface GlobalProps {13339 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type13340 // // of `ctx.exports`.13341 // mainModule: typeof import("my-main-module");13342 //13343 // // Declares which of the main module's exports are configured with durable storage, and13344 // // thus should behave as Durable Object namsepace bindings.13345 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";13346 // }13347 //13348 // You can use `wrangler types` to generate `GlobalProps` automatically.13349 interface GlobalProps {13350 }13351 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not13352 // present.13353 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default;13354 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the13355 // `mainModule` property.13356 type MainModule = GlobalProp<"mainModule", {}>;13357 // The type of ctx.exports, which contains loopback bindings for all top-level exports.13358 type Exports = {13359 [K in keyof MainModule]: LoopbackForExport<MainModule[K]>13360 // If the export is listed in `durableNamespaces`, then it is also a13361 // DurableObjectNamespace.13362 & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {});13363 };13364}13365declare namespace CloudflareWorkersModule {13366 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;13367 export const RpcStub: {13368 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;13369 };13370 export abstract class RpcTarget implements Rpc.RpcTargetBranded {13371 [Rpc.__RPC_TARGET_BRAND]: never;13372 }13373 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC13374 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded {13375 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;13376 protected ctx: ExecutionContext<Props>;13377 protected env: Env;13378 constructor(ctx: ExecutionContext, env: Env);13379 email?(message: ForwardableEmailMessage): void | Promise<void>;13380 fetch?(request: Request): Response | Promise<Response>;13381 connect?(socket: Socket): void | Promise<void>;13382 queue?(batch: MessageBatch): void | Promise<void>;13383 scheduled?(controller: ScheduledController): void | Promise<void>;13384 tail?(events: TraceItem[]): void | Promise<void>;13385 tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;13386 test?(controller: TestController): void | Promise<void>;13387 trace?(traces: TraceItem[]): void | Promise<void>;13388 }13389 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded {13390 [Rpc.__DURABLE_OBJECT_BRAND]: never;13391 protected ctx: DurableObjectState<Props>;13392 protected env: Env;13393 constructor(ctx: DurableObjectState, env: Env);13394 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;13395 fetch?(request: Request): Response | Promise<Response>;13396 connect?(socket: Socket): void | Promise<void>;13397 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>;13398 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>;13399 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;13400 }13401 export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';13402 export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;13403 export type WorkflowDelayDuration = WorkflowSleepDuration;13404 export type WorkflowDynamicDelayContext = {13405 ctx: WorkflowStepContext<WorkflowDelayFunction>;13406 error: Error;13407 };13408 export type WorkflowDelayFunction = (input: WorkflowDynamicDelayContext) => WorkflowDelayDuration | Promise<WorkflowDelayDuration>;13409 export type WorkflowTimeoutDuration = WorkflowSleepDuration;13410 export type WorkflowRetentionDuration = WorkflowSleepDuration;13411 export type WorkflowBackoff = 'constant' | 'linear' | 'exponential';13412 export type WorkflowStepSensitivity = 'output';13413 export type WorkflowStepConfig = {13414 retries?: {13415 limit: number;13416 delay: WorkflowDelayDuration | number | WorkflowDelayFunction;13417 backoff?: WorkflowBackoff;13418 };13419 timeout?: WorkflowTimeoutDuration | number;13420 sensitive?: WorkflowStepSensitivity;13421 };13422 // Internal discriminators used only for `WorkflowStep.do` overload13423 // resolution. They mirror `WorkflowStepConfig` but pin `retries.delay` to a13424 // single kind so the callback context can be narrowed based on the shape of13425 // the config argument (rather than on an inferred type parameter, which is13426 // lost when the caller supplies an explicit return-type argument). Not13427 // exported: they must not widen the public type surface.13428 type WorkflowStepConfigWithStaticDelay = Omit<WorkflowStepConfig, 'retries'> & {13429 retries?: {13430 limit: number;13431 delay: WorkflowDelayDuration | number;13432 backoff?: WorkflowBackoff;13433 };13434 };13435 type WorkflowStepConfigWithDelayFunction = Omit<WorkflowStepConfig, 'retries'> & {13436 retries: {13437 limit: number;13438 delay: WorkflowDelayFunction;13439 backoff?: WorkflowBackoff;13440 };13441 };13442 export type WorkflowStepRollbackConfig = Pick<WorkflowStepConfig, 'retries' | 'timeout'>;13443 export type WorkflowCronSchedule = {13444 /** Cron expression that triggered this event. */13445 cron: string;13446 /** Timestamp of the scheduled trigger, in milliseconds since the Unix epoch. */13447 scheduledTime: number;13448 };13449 export type WorkflowEvent<T> = {13450 payload: Readonly<T>;13451 timestamp: Date;13452 instanceId: string;13453 workflowName: string;13454 schedule?: WorkflowCronSchedule;13455 };13456 export type WorkflowStepEvent<T> = {13457 payload: Readonly<T>;13458 timestamp: Date;13459 type: string;13460 sensitive?: WorkflowStepSensitivity;13461 };13462 export type WorkflowStepContext<Delay = WorkflowDelayDuration | number> = {13463 step: {13464 name: string;13465 count: number;13466 };13467 attempt: number;13468 config: {13469 retries?: {13470 limit: number;13471 backoff?: WorkflowBackoff;13472 } & (Delay extends WorkflowDelayFunction ? {} : {13473 delay: WorkflowDelayDuration | number;13474 });13475 timeout?: WorkflowTimeoutDuration | number;13476 sensitive?: WorkflowStepSensitivity;13477 };13478 };13479 // The rollback handler receives the step context, so it mirrors the same13480 // delay discriminant as the step callback: when the step was configured with13481 // a dynamic delay function the resolved `config.retries.delay` is omitted,13482 // otherwise it is present. `Delay` is threaded from the `WorkflowStep.do`13483 // overload that matched the step config.13484 export type WorkflowRollbackContext<T = unknown, Delay = WorkflowDelayDuration | number> = {13485 ctx: WorkflowStepContext<Delay>;13486 error: Error;13487 output: T | undefined;13488 /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */13489 stepName: string;13490 };13491 export type WorkflowRollbackHandler<T = unknown, Delay = WorkflowDelayDuration | number> = (ctx: WorkflowRollbackContext<T, Delay>) => Promise<void>;13492 export type WorkflowStepRollbackOptions<T = unknown, Delay = WorkflowDelayDuration | number> = {13493 rollback: WorkflowRollbackHandler<T, Delay>;13494 rollbackConfig?: WorkflowStepRollbackConfig;13495 };13496 export abstract class WorkflowStep {13497 do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;13498 // The config overloads discriminate on the shape of `config.retries.delay`13499 // so the callback context reflects whether the resolved delay is present13500 // (static delay) or omitted (dynamic delay function). Each has a single13501 // type parameter, so an explicit return-type argument (`do<T>(...)`) still13502 // resolves here. ORDERING IS LOAD-BEARING: the broad `WorkflowStepConfig`13503 // fallback MUST remain last, otherwise it shadows the discriminating13504 // overloads and narrowing is silently lost.13505 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithDelayFunction, callback: (ctx: WorkflowStepContext<WorkflowDelayFunction>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayFunction>): Promise<T>;13506 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithStaticDelay, callback: (ctx: WorkflowStepContext<WorkflowDelayDuration | number>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayDuration | number>): Promise<T>;13507 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;13508 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;13509 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;13510 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {13511 type: string;13512 timeout?: WorkflowTimeoutDuration | number;13513 }): Promise<WorkflowStepEvent<T>>;13514 }13515 export type WorkflowInstanceStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting' | 'waitingForPause' | 'unknown';13516 export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded {13517 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;13518 protected ctx: ExecutionContext;13519 protected env: Env;13520 constructor(ctx: ExecutionContext, env: Env);13521 run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>;13522 }13523 export function waitUntil(promise: Promise<unknown>): void;13524 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;13525 export function withExports(newExports: unknown, fn: () => unknown): unknown;13526 export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown;13527 export const env: Cloudflare.Env;13528 export const exports: Cloudflare.Exports;13529 export const cache: CacheContext;13530 export const tracing: Tracing;13531}13532declare module 'cloudflare:workers' {13533 export = CloudflareWorkersModule;13534}13535interface SecretsStoreSecret {13536 /**13537 * Get a secret from the Secrets Store, returning a string of the secret value13538 * if it exists, or throws an error if it does not exist13539 */13540 get(): Promise<string>;13541}13542declare module "cloudflare:sockets" {13543 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket;13544 export { _connect as connect };13545}13546/**13547 * Binding entrypoint for Cloudflare Stream.13548 *13549 * Usage:13550 * - Binding-level operations:13551 * `await env.STREAM.videos.upload`13552 * `await env.STREAM.videos.createDirectUpload`13553 * `await env.STREAM.videos.*`13554 * `await env.STREAM.watermarks.*`13555 * - Per-video operations:13556 * `await env.STREAM.video(id).downloads.*`13557 * `await env.STREAM.video(id).captions.*`13558 *13559 * Example usage:13560 * ```ts13561 * await env.STREAM.video(id).downloads.generate();13562 *13563 * const video = env.STREAM.video(id)13564 * const captions = video.captions.list();13565 * const videoDetails = video.details()13566 * ```13567 */13568interface StreamBinding {13569 /**13570 * Returns a handle scoped to a single video for per-video operations.13571 * @param id The unique identifier for the video.13572 * @returns A handle for per-video operations.13573 */13574 video(id: string): StreamVideoHandle;13575 /**13576 * Uploads a new video from a provided URL.13577 * @param url The URL to upload from.13578 * @param params Optional upload parameters.13579 * @returns The uploaded video details.13580 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid13581 * @throws {QuotaReachedError} if the account storage capacity is exceeded13582 * @throws {MaxFileSizeError} if the file size is too large13583 * @throws {RateLimitedError} if the server received too many requests13584 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL13585 * @throws {InternalError} if an unexpected error occurs13586 */13587 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;13588 /**13589 * Creates a direct upload that allows video uploads without an API key.13590 * @param params Parameters for the direct upload13591 * @returns The direct upload details.13592 * @throws {BadRequestError} if the parameters are invalid13593 * @throws {RateLimitedError} if the server received too many requests13594 * @throws {InternalError} if an unexpected error occurs13595 */13596 createDirectUpload(params: StreamDirectUploadCreateParams): Promise<StreamDirectUpload>;13597 videos: StreamVideos;13598 watermarks: StreamWatermarks;13599}13600/**13601 * Handle for operations scoped to a single Stream video.13602 */13603interface StreamVideoHandle {13604 /**13605 * The unique identifier for the video.13606 */13607 id: string;13608 /**13609 * Get a full videos details13610 * @returns The full video details.13611 * @throws {NotFoundError} if the video is not found13612 * @throws {InternalError} if an unexpected error occurs13613 */13614 details(): Promise<StreamVideo>;13615 /**13616 * Update details for a single video.13617 * @param params The fields to update for the video.13618 * @returns The updated video details.13619 * @throws {NotFoundError} if the video is not found13620 * @throws {BadRequestError} if the parameters are invalid13621 * @throws {InternalError} if an unexpected error occurs13622 */13623 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;13624 /**13625 * Deletes a video and its copies from Cloudflare Stream.13626 * @returns A promise that resolves when deletion completes.13627 * @throws {NotFoundError} if the video is not found13628 * @throws {InternalError} if an unexpected error occurs13629 */13630 delete(): Promise<void>;13631 /**13632 * Creates a signed URL token for a video.13633 * @returns The signed token that was created.13634 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed13635 */13636 generateToken(): Promise<string>;13637 downloads: StreamScopedDownloads;13638 captions: StreamScopedCaptions;13639}13640interface StreamVideo {13641 /**13642 * The unique identifier for the video.13643 */13644 id: string;13645 /**13646 * A user-defined identifier for the media creator.13647 */13648 creator: string | null;13649 /**13650 * The thumbnail URL for the video.13651 */13652 thumbnail: string;13653 /**13654 * The thumbnail timestamp percentage.13655 */13656 thumbnailTimestampPct: number;13657 /**13658 * Indicates whether the video is ready to stream.13659 */13660 readyToStream: boolean;13661 /**13662 * The date and time the video became ready to stream.13663 */13664 readyToStreamAt: string | null;13665 /**13666 * Processing status information.13667 */13668 status: StreamVideoStatus;13669 /**13670 * A user modifiable key-value store.13671 */13672 meta: Record<string, string>;13673 /**13674 * The date and time the video was created.13675 */13676 created: string;13677 /**13678 * The date and time the video was last modified.13679 */13680 modified: string;13681 /**13682 * The date and time at which the video will be deleted.13683 */13684 scheduledDeletion: string | null;13685 /**13686 * The size of the video in bytes.13687 */13688 size: number;13689 /**13690 * The preview URL for the video.13691 */13692 preview?: string;13693 /**13694 * Origins allowed to display the video.13695 */13696 allowedOrigins: Array<string>;13697 /**13698 * Indicates whether signed URLs are required.13699 */13700 requireSignedURLs: boolean | null;13701 /**13702 * The date and time the video was uploaded.13703 */13704 uploaded: string | null;13705 /**13706 * The date and time when the upload URL expires.13707 */13708 uploadExpiry: string | null;13709 /**13710 * The maximum size in bytes for direct uploads.13711 */13712 maxSizeBytes: number | null;13713 /**13714 * The maximum duration in seconds for direct uploads.13715 */13716 maxDurationSeconds: number | null;13717 /**13718 * The video duration in seconds. -1 indicates unknown.13719 */13720 duration: number;13721 /**13722 * Input metadata for the original upload.13723 */13724 input: StreamVideoInput;13725 /**13726 * Playback URLs for the video.13727 */13728 hlsPlaybackUrl: string;13729 dashPlaybackUrl: string;13730 /**13731 * The watermark applied to the video, if any.13732 */13733 watermark: StreamWatermark | null;13734 /**13735 * The live input id associated with the video, if any.13736 */13737 liveInputId?: string | null;13738 /**13739 * The source video id if this is a clip.13740 */13741 clippedFromId: string | null;13742 /**13743 * Public details associated with the video.13744 */13745 publicDetails: StreamPublicDetails | null;13746}13747type StreamVideoStatus = {13748 /**13749 * The current processing state.13750 */13751 state: string;13752 /**13753 * The current processing step.13754 */13755 step?: string;13756 /**13757 * The percent complete as a string.13758 */13759 pctComplete?: string;13760 /**13761 * An error reason code, if applicable.13762 */13763 errorReasonCode: string;13764 /**13765 * An error reason text, if applicable.13766 */13767 errorReasonText: string;13768};13769type StreamVideoInput = {13770 /**13771 * The input width in pixels.13772 */13773 width: number;13774 /**13775 * The input height in pixels.13776 */13777 height: number;13778};13779type StreamPublicDetails = {13780 /**13781 * The public title for the video.13782 */13783 title: string | null;13784 /**13785 * The public share link.13786 */13787 share_link: string | null;13788 /**13789 * The public channel link.13790 */13791 channel_link: string | null;13792 /**13793 * The public logo URL.13794 */13795 logo: string | null;13796};13797type StreamDirectUpload = {13798 /**13799 * The URL an unauthenticated upload can use for a single multipart request.13800 */13801 uploadURL: string;13802 /**13803 * A Cloudflare-generated unique identifier for a media item.13804 */13805 id: string;13806 /**13807 * The watermark profile applied to the upload.13808 */13809 watermark: StreamWatermark | null;13810 /**13811 * The scheduled deletion time, if any.13812 */13813 scheduledDeletion: string | null;13814};13815type StreamDirectUploadCreateParams = {13816 /**13817 * The maximum duration in seconds for a video upload.13818 */13819 maxDurationSeconds: number;13820 /**13821 * The date and time after upload when videos will not be accepted.13822 */13823 expiry?: string;13824 /**13825 * A user-defined identifier for the media creator.13826 */13827 creator?: string;13828 /**13829 * A user modifiable key-value store used to reference other systems of record for13830 * managing videos.13831 */13832 meta?: Record<string, string>;13833 /**13834 * Lists the origins allowed to display the video.13835 */13836 allowedOrigins?: Array<string>;13837 /**13838 * Indicates whether the video can be accessed using the id. When set to `true`,13839 * a signed token must be generated with a signing key to view the video.13840 */13841 requireSignedURLs?: boolean;13842 /**13843 * The thumbnail timestamp percentage.13844 */13845 thumbnailTimestampPct?: number;13846 /**13847 * The date and time at which the video will be deleted. Include `null` to remove13848 * a scheduled deletion.13849 */13850 scheduledDeletion?: string | null;13851 /**13852 * The watermark profile to apply.13853 */13854 watermark?: StreamDirectUploadWatermark;13855};13856type StreamDirectUploadWatermark = {13857 /**13858 * The unique identifier for the watermark profile.13859 */13860 id: string;13861};13862type StreamUrlUploadParams = {13863 /**13864 * Lists the origins allowed to display the video. Enter allowed origin13865 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the13866 * video to be viewed on any origin.13867 */13868 allowedOrigins?: Array<string>;13869 /**13870 * A user-defined identifier for the media creator.13871 */13872 creator?: string;13873 /**13874 * A user modifiable key-value store used to reference other systems of13875 * record for managing videos.13876 */13877 meta?: Record<string, string>;13878 /**13879 * Indicates whether the video can be a accessed using the id. When13880 * set to `true`, a signed token must be generated with a signing key to view the13881 * video.13882 */13883 requireSignedURLs?: boolean;13884 /**13885 * Indicates the date and time at which the video will be deleted. Omit13886 * the field to indicate no change, or include with a `null` value to remove an13887 * existing scheduled deletion. If specified, must be at least 30 days from upload13888 * time.13889 */13890 scheduledDeletion?: string | null;13891 /**13892 * The timestamp for a thumbnail image calculated as a percentage value13893 * of the video's duration. To convert from a second-wise timestamp to a13894 * percentage, divide the desired timestamp by the total duration of the video. If13895 * this value is not set, the default thumbnail image is taken from 0s of the13896 * video.13897 */13898 thumbnailTimestampPct?: number;13899 /**13900 * The identifier for the watermark profile13901 */13902 watermarkId?: string;13903};13904interface StreamScopedCaptions {13905 /**13906 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.13907 * One caption or subtitle file per language is allowed.13908 * @param language The BCP 47 language tag for the caption or subtitle.13909 * @param input The caption or subtitle stream to upload.13910 * @returns The created caption entry.13911 * @throws {NotFoundError} if the video is not found13912 * @throws {BadRequestError} if the language or file is invalid13913 * @throws {InternalError} if an unexpected error occurs13914 */13915 upload(language: string, input: ReadableStream): Promise<StreamCaption>;13916 /**13917 * Generate captions or subtitles for the provided language via AI.13918 * @param language The BCP 47 language tag to generate.13919 * @returns The generated caption entry.13920 * @throws {NotFoundError} if the video is not found13921 * @throws {BadRequestError} if the language is invalid13922 * @throws {StreamError} if a generated caption already exists13923 * @throws {StreamError} if the video duration is too long13924 * @throws {StreamError} if the video is missing audio13925 * @throws {StreamError} if the requested language is not supported13926 * @throws {InternalError} if an unexpected error occurs13927 */13928 generate(language: string): Promise<StreamCaption>;13929 /**13930 * Lists the captions or subtitles.13931 * Use the language parameter to filter by a specific language.13932 * @param language The optional BCP 47 language tag to filter by.13933 * @returns The list of captions or subtitles.13934 * @throws {NotFoundError} if the video or caption is not found13935 * @throws {InternalError} if an unexpected error occurs13936 */13937 list(language?: string): Promise<StreamCaption[]>;13938 /**13939 * Removes the captions or subtitles from a video.13940 * @param language The BCP 47 language tag to remove.13941 * @returns A promise that resolves when deletion completes.13942 * @throws {NotFoundError} if the video or caption is not found13943 * @throws {InternalError} if an unexpected error occurs13944 */13945 delete(language: string): Promise<void>;13946}13947interface StreamScopedDownloads {13948 /**13949 * Generates a download for a video when a video is ready to view. Available13950 * types are `default` and `audio`. Defaults to `default` when omitted.13951 * @param downloadType The download type to create.13952 * @returns The current downloads for the video.13953 * @throws {NotFoundError} if the video is not found13954 * @throws {BadRequestError} if the download type is invalid13955 * @throws {StreamError} if the video duration is too long to generate a download13956 * @throws {StreamError} if the video is not ready to stream13957 * @throws {InternalError} if an unexpected error occurs13958 */13959 generate(downloadType?: StreamDownloadType): Promise<StreamDownloadGetResponse>;13960 /**13961 * Lists the downloads created for a video.13962 * @returns The current downloads for the video.13963 * @throws {NotFoundError} if the video or downloads are not found13964 * @throws {InternalError} if an unexpected error occurs13965 */13966 get(): Promise<StreamDownloadGetResponse>;13967 /**13968 * Delete the downloads for a video. Available types are `default` and `audio`.13969 * Defaults to `default` when omitted.13970 * @param downloadType The download type to delete.13971 * @returns A promise that resolves when deletion completes.13972 * @throws {NotFoundError} if the video or downloads are not found13973 * @throws {InternalError} if an unexpected error occurs13974 */13975 delete(downloadType?: StreamDownloadType): Promise<void>;13976}13977interface StreamVideos {13978 /**13979 * Lists all videos in a users account.13980 * @returns The list of videos.13981 * @throws {BadRequestError} if the parameters are invalid13982 * @throws {InternalError} if an unexpected error occurs13983 */13984 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;13985}13986interface StreamWatermarks {13987 /**13988 * Generate a new watermark profile13989 * @param input The image stream to upload13990 * @param params The watermark creation parameters.13991 * @returns The created watermark profile.13992 * @throws {BadRequestError} if the parameters are invalid13993 * @throws {InvalidURLError} if the URL is invalid13994 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached13995 * @throws {InternalError} if an unexpected error occurs13996 */13997 generate(input: ReadableStream, params: StreamWatermarkCreateParams): Promise<StreamWatermark>;13998 /**13999 * Generate a new watermark profile14000 * @param url The image url to upload14001 * @param params The watermark creation parameters.14002 * @returns The created watermark profile.14003 * @throws {BadRequestError} if the parameters are invalid14004 * @throws {InvalidURLError} if the URL is invalid14005 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached14006 * @throws {InternalError} if an unexpected error occurs14007 */14008 generate(url: string, params: StreamWatermarkCreateParams): Promise<StreamWatermark>;14009 /**14010 * Lists all watermark profiles for an account.14011 * @returns The list of watermark profiles.14012 * @throws {InternalError} if an unexpected error occurs14013 */14014 list(): Promise<StreamWatermark[]>;14015 /**14016 * Retrieves details for a single watermark profile.14017 * @param watermarkId The watermark profile identifier.14018 * @returns The watermark profile details.14019 * @throws {NotFoundError} if the watermark is not found14020 * @throws {InternalError} if an unexpected error occurs14021 */14022 get(watermarkId: string): Promise<StreamWatermark>;14023 /**14024 * Deletes a watermark profile.14025 * @param watermarkId The watermark profile identifier.14026 * @returns A promise that resolves when deletion completes.14027 * @throws {NotFoundError} if the watermark is not found14028 * @throws {InternalError} if an unexpected error occurs14029 */14030 delete(watermarkId: string): Promise<void>;14031}14032type StreamUpdateVideoParams = {14033 /**14034 * Lists the origins allowed to display the video. Enter allowed origin14035 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the14036 * video to be viewed on any origin.14037 */14038 allowedOrigins?: Array<string>;14039 /**14040 * A user-defined identifier for the media creator.14041 */14042 creator?: string;14043 /**14044 * The maximum duration in seconds for a video upload. Can be set for a14045 * video that is not yet uploaded to limit its duration. Uploads that exceed the14046 * specified duration will fail during processing. A value of `-1` means the value14047 * is unknown.14048 */14049 maxDurationSeconds?: number;14050 /**14051 * A user modifiable key-value store used to reference other systems of14052 * record for managing videos.14053 */14054 meta?: Record<string, string>;14055 /**14056 * Indicates whether the video can be a accessed using the id. When14057 * set to `true`, a signed token must be generated with a signing key to view the14058 * video.14059 */14060 requireSignedURLs?: boolean;14061 /**14062 * Indicates the date and time at which the video will be deleted. Omit14063 * the field to indicate no change, or include with a `null` value to remove an14064 * existing scheduled deletion. If specified, must be at least 30 days from upload14065 * time.14066 */14067 scheduledDeletion?: string | null;14068 /**14069 * The timestamp for a thumbnail image calculated as a percentage value14070 * of the video's duration. To convert from a second-wise timestamp to a14071 * percentage, divide the desired timestamp by the total duration of the video. If14072 * this value is not set, the default thumbnail image is taken from 0s of the14073 * video.14074 */14075 thumbnailTimestampPct?: number;14076};14077type StreamCaption = {14078 /**14079 * Whether the caption was generated via AI.14080 */14081 generated?: boolean;14082 /**14083 * The language label displayed in the native language to users.14084 */14085 label: string;14086 /**14087 * The language tag in BCP 47 format.14088 */14089 language: string;14090 /**14091 * The status of a generated caption.14092 */14093 status?: 'ready' | 'inprogress' | 'error';14094};14095type StreamDownloadStatus = 'ready' | 'inprogress' | 'error';14096type StreamDownloadType = 'default' | 'audio';14097type StreamDownload = {14098 /**14099 * Indicates the progress as a percentage between 0 and 100.14100 */14101 percentComplete: number;14102 /**14103 * The status of a generated download.14104 */14105 status: StreamDownloadStatus;14106 /**14107 * The URL to access the generated download.14108 */14109 url?: string;14110};14111/**14112 * An object with download type keys. Each key is optional and only present if that14113 * download type has been created.14114 */14115type StreamDownloadGetResponse = {14116 /**14117 * The audio-only download. Only present if this download type has been created.14118 */14119 audio?: StreamDownload;14120 /**14121 * The default video download. Only present if this download type has been created.14122 */14123 default?: StreamDownload;14124};14125type StreamWatermarkPosition = 'upperRight' | 'upperLeft' | 'lowerLeft' | 'lowerRight' | 'center';14126type StreamWatermark = {14127 /**14128 * The unique identifier for a watermark profile.14129 */14130 id: string;14131 /**14132 * The size of the image in bytes.14133 */14134 size: number;14135 /**14136 * The height of the image in pixels.14137 */14138 height: number;14139 /**14140 * The width of the image in pixels.14141 */14142 width: number;14143 /**14144 * The date and a time a watermark profile was created.14145 */14146 created: string;14147 /**14148 * The source URL for a downloaded image. If the watermark profile was created via14149 * direct upload, this field is null.14150 */14151 downloadedFrom: string | null;14152 /**14153 * A short description of the watermark profile.14154 */14155 name: string;14156 /**14157 * The translucency of the image. A value of `0.0` makes the image completely14158 * transparent, and `1.0` makes the image completely opaque. Note that if the image14159 * is already semi-transparent, setting this to `1.0` will not make the image14160 * completely opaque.14161 */14162 opacity: number;14163 /**14164 * The whitespace between the adjacent edges (determined by position) of the video14165 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded14166 * video width or length, as determined by the algorithm.14167 */14168 padding: number;14169 /**14170 * The size of the image relative to the overall size of the video. This parameter14171 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no14172 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.14173 */14174 scale: number;14175 /**14176 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,14177 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the14178 * `padding` parameter.14179 */14180 position: StreamWatermarkPosition;14181};14182type StreamWatermarkCreateParams = {14183 /**14184 * A short description of the watermark profile.14185 */14186 name?: string;14187 /**14188 * The translucency of the image. A value of `0.0` makes the image completely14189 * transparent, and `1.0` makes the image completely opaque. Note that if the14190 * image is already semi-transparent, setting this to `1.0` will not make the14191 * image completely opaque.14192 */14193 opacity?: number;14194 /**14195 * The whitespace between the adjacent edges (determined by position) of the14196 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully14197 * padded video width or length, as determined by the algorithm.14198 */14199 padding?: number;14200 /**14201 * The size of the image relative to the overall size of the video. This14202 * parameter will adapt to horizontal and vertical videos automatically. `0.0`14203 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the14204 * entire video.14205 */14206 scale?: number;14207 /**14208 * The location of the image.14209 */14210 position?: StreamWatermarkPosition;14211};14212type StreamVideosListParams = {14213 /**14214 * The maximum number of videos to return.14215 */14216 limit?: number;14217 /**14218 * Return videos created before this timestamp.14219 * (RFC3339/RFC3339Nano)14220 */14221 before?: string;14222 /**14223 * Comparison operator for the `before` field.14224 * @default 'lt'14225 */14226 beforeComp?: StreamPaginationComparison;14227 /**14228 * Return videos created after this timestamp.14229 * (RFC3339/RFC3339Nano)14230 */14231 after?: string;14232 /**14233 * Comparison operator for the `after` field.14234 * @default 'gte'14235 */14236 afterComp?: StreamPaginationComparison;14237};14238type StreamPaginationComparison = 'eq' | 'gt' | 'gte' | 'lt' | 'lte';14239/**14240 * Error object for Stream binding operations.14241 */14242interface StreamError extends Error {14243 readonly code: number;14244 readonly statusCode: number;14245 readonly message: string;14246 readonly stack?: string;14247}14248interface InternalError extends StreamError {14249 name: 'InternalError';14250}14251interface BadRequestError extends StreamError {14252 name: 'BadRequestError';14253}14254interface NotFoundError extends StreamError {14255 name: 'NotFoundError';14256}14257interface ForbiddenError extends StreamError {14258 name: 'ForbiddenError';14259}14260interface RateLimitedError extends StreamError {14261 name: 'RateLimitedError';14262}14263interface QuotaReachedError extends StreamError {14264 name: 'QuotaReachedError';14265}14266interface MaxFileSizeError extends StreamError {14267 name: 'MaxFileSizeError';14268}14269interface InvalidURLError extends StreamError {14270 name: 'InvalidURLError';14271}14272interface AlreadyUploadedError extends StreamError {14273 name: 'AlreadyUploadedError';14274}14275interface TooManyWatermarksError extends StreamError {14276 name: 'TooManyWatermarksError';14277}14278type MarkdownDocument = {14279 name: string;14280 blob: Blob;14281};14282type OutputFormat = 'markdown' | 'text';14283type ConversionResponse = {14284 id: string;14285 name: string;14286 mimeType: string;14287 format: OutputFormat;14288 tokens: number;14289 data: string;14290} | {14291 id: string;14292 name: string;14293 mimeType: string;14294 format: 'error';14295 error: string;14296};14297type ImageConversionOptions = {14298 descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de';14299};14300type EmbeddedImageConversionOptions = ImageConversionOptions & {14301 convert?: boolean;14302 maxConvertedImages?: number;14303};14304type ConversionOutputOptions = {14305 format?: OutputFormat;14306};14307type ConversionOptions = {14308 output?: ConversionOutputOptions;14309 html?: {14310 images?: EmbeddedImageConversionOptions & {14311 convertOGImage?: boolean;14312 };14313 hostname?: string;14314 cssSelector?: string;14315 };14316 docx?: {14317 images?: EmbeddedImageConversionOptions;14318 };14319 image?: ImageConversionOptions;14320 pdf?: {14321 images?: EmbeddedImageConversionOptions;14322 metadata?: boolean;14323 };14324};14325type ConversionRequestOptions = {14326 gateway?: GatewayOptions;14327 extraHeaders?: object;14328 conversionOptions?: ConversionOptions;14329};14330type SupportedFileFormat = {14331 mimeType: string;14332 extension: string;14333};14334declare abstract class ToMarkdownService {14335 transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>;14336 transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>;14337 supported(): Promise<SupportedFileFormat[]>;14338}14339declare namespace TailStream {14340 interface Header {14341 readonly name: string;14342 readonly value: string;14343 }14344 interface FetchEventInfo {14345 readonly type: "fetch";14346 readonly method: string;14347 readonly url: string;14348 readonly cfJson?: object;14349 readonly headers: Header[];14350 }14351 interface JsRpcEventInfo {14352 readonly type: "jsrpc";14353 }14354 interface ScheduledEventInfo {14355 readonly type: "scheduled";14356 readonly scheduledTime: Date;14357 readonly cron: string;14358 }14359 interface AlarmEventInfo {14360 readonly type: "alarm";14361 readonly scheduledTime: Date;14362 }14363 interface QueueEventInfo {14364 readonly type: "queue";14365 readonly queueName: string;14366 readonly batchSize: number;14367 }14368 interface EmailEventInfo {14369 readonly type: "email";14370 readonly mailFrom: string;14371 readonly rcptTo: string;14372 readonly rawSize: number;14373 }14374 interface TraceEventInfo {14375 readonly type: "trace";14376 readonly traces: (string | null)[];14377 }14378 interface HibernatableWebSocketEventInfoMessage {14379 readonly type: "message";14380 }14381 interface HibernatableWebSocketEventInfoError {14382 readonly type: "error";14383 }14384 interface HibernatableWebSocketEventInfoClose {14385 readonly type: "close";14386 readonly code: number;14387 readonly wasClean: boolean;14388 }14389 interface HibernatableWebSocketEventInfo {14390 readonly type: "hibernatableWebSocket";14391 readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage;14392 }14393 interface CustomEventInfo {14394 readonly type: "custom";14395 }14396 interface FetchResponseInfo {14397 readonly type: "fetch";14398 readonly statusCode: number;14399 }14400 interface ConnectEventInfo {14401 readonly type: "connect";14402 }14403 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound" | "internalError" | "exceededWallTime";14404 interface ScriptVersion {14405 readonly id: string;14406 readonly tag?: string;14407 readonly message?: string;14408 }14409 interface TracePreviewInfo {14410 readonly id: string;14411 readonly slug: string;14412 readonly name: string;14413 }14414 interface Onset {14415 readonly type: "onset";14416 readonly attributes: Attribute[];14417 // id for the span being opened by this Onset event.14418 readonly spanId: string;14419 readonly dispatchNamespace?: string;14420 readonly entrypoint?: string;14421 readonly executionModel: string;14422 readonly durableObjectId?: string;14423 readonly scriptName?: string;14424 readonly scriptTags?: string[];14425 readonly scriptVersion?: ScriptVersion;14426 readonly preview?: TracePreviewInfo;14427 readonly info: FetchEventInfo | ConnectEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo;14428 }14429 interface Outcome {14430 readonly type: "outcome";14431 readonly outcome: EventOutcome;14432 readonly cpuTime: number;14433 readonly wallTime: number;14434 }14435 interface SpanOpen {14436 readonly type: "spanOpen";14437 readonly name: string;14438 // id for the span being opened by this SpanOpen event.14439 readonly spanId: string;14440 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;14441 }14442 interface SpanClose {14443 readonly type: "spanClose";14444 readonly outcome: EventOutcome;14445 }14446 interface DiagnosticChannelEvent {14447 readonly type: "diagnosticChannel";14448 readonly channel: string;14449 readonly message: any;14450 }14451 interface Exception {14452 readonly type: "exception";14453 readonly name: string;14454 readonly message: string;14455 readonly stack?: string;14456 }14457 interface TailStreamErrorInfo {14458 readonly name: string;14459 readonly message: string;14460 readonly stack?: string;14461 }14462 type Log = {14463 readonly type: "log";14464 readonly level: "debug" | "error" | "info" | "log" | "warn";14465 readonly errorInfo?: readonly (TailStreamErrorInfo | null)[];14466 } & ({14467 readonly message: object;14468 readonly truncated?: false;14469 } | {14470 readonly message: string;14471 readonly truncated: true;14472 });14473 interface DroppedEventsDiagnostic {14474 readonly diagnosticsType: "droppedEvents";14475 readonly count: number;14476 }14477 interface StreamDiagnostic {14478 readonly type: 'streamDiagnostic';14479 // To add new diagnostic types, define a new interface and add it to this union type.14480 readonly diagnostic: DroppedEventsDiagnostic;14481 }14482 // This marks the worker handler return information.14483 // This is separate from Outcome because the worker invocation can live for a long time after14484 // returning. For example - Websockets that return an http upgrade response but then continue14485 // streaming information or SSE http connections.14486 interface Return {14487 readonly type: "return";14488 readonly info?: FetchResponseInfo;14489 }14490 interface Attribute {14491 readonly name: string;14492 readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[];14493 }14494 interface Attributes {14495 readonly type: "attributes";14496 readonly info: Attribute[];14497 }14498 type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | StreamDiagnostic | Return | Attributes;14499 // Context in which this trace event lives.14500 interface SpanContext {14501 // Single id for the entire top-level invocation14502 // This should be a new traceId for the first worker stage invoked in the eyeball request and then14503 // same-account service-bindings should reuse the same traceId but cross-account service-bindings14504 // should use a new traceId.14505 readonly traceId: string;14506 // spanId in which this event is handled14507 // for Onset and SpanOpen events this would be the parent span id14508 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events14509 // For Hibernate and Mark this would be the span under which they were emitted.14510 // spanId is not set ONLY if:14511 // 1. This is an Onset event14512 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)14513 readonly spanId?: string;14514 // W3C trace flags from an upstream traceparent. Absent when no upstream14515 // sampling decision was made.14516 readonly traceFlags?: number;14517 }14518 interface TailEvent<Event extends EventType> {14519 // invocation id of the currently invoked worker stage.14520 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.14521 readonly invocationId: string;14522 // Inherited spanContext for this event.14523 readonly spanContext: SpanContext;14524 readonly timestamp: Date;14525 readonly sequence: number;14526 readonly event: Event;14527 }14528 type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>;14529 type TailEventHandlerObject = {14530 outcome?: TailEventHandler<Outcome>;14531 spanOpen?: TailEventHandler<SpanOpen>;14532 spanClose?: TailEventHandler<SpanClose>;14533 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;14534 exception?: TailEventHandler<Exception>;14535 log?: TailEventHandler<Log>;14536 return?: TailEventHandler<Return>;14537 attributes?: TailEventHandler<Attributes>;14538 };14539 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;14540}14541// Copyright (c) 2022-2023 Cloudflare, Inc.14542// Licensed under the Apache 2.0 license found in the LICENSE file or at:14543// https://opensource.org/licenses/Apache-2.014544/**14545 * Data types supported for holding vector metadata.14546 */14547type VectorizeVectorMetadataValue = string | number | boolean | string[];14548/**14549 * Additional information to associate with a vector.14550 */14551type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>;14552type VectorFloatArray = Float32Array | Float64Array;14553interface VectorizeError {14554 code?: number;14555 error: string;14556}14557/**14558 * Comparison logic/operation to use for metadata filtering.14559 *14560 * This list is expected to grow as support for more operations are released.14561 */14562type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte';14563type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin';14564/**14565 * Filter criteria for vector metadata used to limit the retrieved query result set.14566 */14567type VectorizeVectorMetadataFilter = {14568 [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | {14569 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null;14570 } | {14571 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[];14572 };14573};14574/**14575 * Supported distance metrics for an index.14576 * Distance metrics determine how other "similar" vectors are determined.14577 */14578type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";14579/**14580 * Metadata return levels for a Vectorize query.14581 *14582 * Default to "none".14583 *14584 * @property all Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data.14585 * @property indexed Return all metadata fields configured for indexing in the vector return set. This level of retrieval is "free" in that no additional overhead is incurred returning this data. However, note that indexed metadata is subject to truncation (especially for larger strings).14586 * @property none No indexed metadata will be returned.14587 */14588type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";14589interface VectorizeQueryOptions {14590 topK?: number;14591 namespace?: string;14592 returnValues?: boolean;14593 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;14594 filter?: VectorizeVectorMetadataFilter;14595}14596/**14597 * Information about the configuration of an index.14598 */14599type VectorizeIndexConfig = {14600 dimensions: number;14601 metric: VectorizeDistanceMetric;14602} | {14603 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity14604};14605/**14606 * Metadata about an existing index.14607 *14608 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.14609 * See {@link VectorizeIndexInfo} for its post-beta equivalent.14610 */14611interface VectorizeIndexDetails {14612 /** The unique ID of the index */14613 readonly id: string;14614 /** The name of the index. */14615 name: string;14616 /** (optional) A human readable description for the index. */14617 description?: string;14618 /** The index configuration, including the dimension size and distance metric. */14619 config: VectorizeIndexConfig;14620 /** The number of records containing vectors within the index. */14621 vectorsCount: number;14622}14623/**14624 * Metadata about an existing index.14625 */14626interface VectorizeIndexInfo {14627 /** The number of records containing vectors within the index. */14628 vectorCount: number;14629 /** Number of dimensions the index has been configured for. */14630 dimensions: number;14631 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */14632 processedUpToDatetime: number;14633 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */14634 processedUpToMutation: number;14635}14636/**14637 * Represents a single vector value set along with its associated metadata.14638 */14639interface VectorizeVector {14640 /** The ID for the vector. This can be user-defined, and must be unique. It should uniquely identify the object, and is best set based on the ID of what the vector represents. */14641 id: string;14642 /** The vector values */14643 values: VectorFloatArray | number[];14644 /** The namespace this vector belongs to. */14645 namespace?: string;14646 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */14647 metadata?: Record<string, VectorizeVectorMetadata>;14648}14649/**14650 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.14651 */14652type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & {14653 /** The score or rank for similarity, when returned as a result */14654 score: number;14655};14656/**14657 * A set of matching {@link VectorizeMatch} for a particular query.14658 */14659interface VectorizeMatches {14660 matches: VectorizeMatch[];14661 count: number;14662}14663/**14664 * Results of an operation that performed a mutation on a set of vectors.14665 * Here, `ids` is a list of vectors that were successfully processed.14666 *14667 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.14668 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.14669 */14670interface VectorizeVectorMutation {14671 /* List of ids of vectors that were successfully processed. */14672 ids: string[];14673 /* Total count of the number of processed vectors. */14674 count: number;14675}14676/**14677 * Result type indicating a mutation on the Vectorize Index.14678 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.14679 */14680interface VectorizeAsyncMutation {14681 /** The unique identifier for the async mutation operation containing the changeset. */14682 mutationId: string;14683}14684/**14685 * A Vectorize Vector Search Index for querying vectors/embeddings.14686 *14687 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.14688 * See {@link Vectorize} for its new implementation.14689 */14690declare abstract class VectorizeIndex {14691 /**14692 * Get information about the currently bound index.14693 * @returns A promise that resolves with information about the current index.14694 */14695 public describe(): Promise<VectorizeIndexDetails>;14696 /**14697 * Use the provided vector to perform a similarity search across the index.14698 * @param vector Input vector that will be used to drive the similarity search.14699 * @param options Configuration options to massage the returned data.14700 * @returns A promise that resolves with matched and scored vectors.14701 */14702 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;14703 /**14704 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.14705 * @param vectors List of vectors that will be inserted.14706 * @returns A promise that resolves with the ids & count of records that were successfully processed.14707 */14708 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;14709 /**14710 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.14711 * @param vectors List of vectors that will be upserted.14712 * @returns A promise that resolves with the ids & count of records that were successfully processed.14713 */14714 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;14715 /**14716 * Delete a list of vectors with a matching id.14717 * @param ids List of vector ids that should be deleted.14718 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).14719 */14720 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;14721 /**14722 * Get a list of vectors with a matching id.14723 * @param ids List of vector ids that should be returned.14724 * @returns A promise that resolves with the raw unscored vectors matching the id set.14725 */14726 public getByIds(ids: string[]): Promise<VectorizeVector[]>;14727}14728/**14729 * A Vectorize Vector Search Index for querying vectors/embeddings.14730 *14731 * Mutations in this version are async, returning a mutation id.14732 */14733declare abstract class Vectorize {14734 /**14735 * Get information about the currently bound index.14736 * @returns A promise that resolves with information about the current index.14737 */14738 public describe(): Promise<VectorizeIndexInfo>;14739 /**14740 * Use the provided vector to perform a similarity search across the index.14741 * @param vector Input vector that will be used to drive the similarity search.14742 * @param options Configuration options to massage the returned data.14743 * @returns A promise that resolves with matched and scored vectors.14744 */14745 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>;14746 /**14747 * Use the provided vector-id to perform a similarity search across the index.14748 * @param vectorId Id for a vector in the index against which the index should be queried.14749 * @param options Configuration options to massage the returned data.14750 * @returns A promise that resolves with matched and scored vectors.14751 */14752 public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>;14753 /**14754 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.14755 * @param vectors List of vectors that will be inserted.14756 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.14757 */14758 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;14759 /**14760 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.14761 * @param vectors List of vectors that will be upserted.14762 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.14763 */14764 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;14765 /**14766 * Delete a list of vectors with a matching id.14767 * @param ids List of vector ids that should be deleted.14768 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.14769 */14770 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;14771 /**14772 * Get a list of vectors with a matching id.14773 * @param ids List of vector ids that should be returned.14774 * @returns A promise that resolves with the raw unscored vectors matching the id set.14775 */14776 public getByIds(ids: string[]): Promise<VectorizeVector[]>;14777}14778/**14779 * The interface for "version_metadata" binding14780 * providing metadata about the Worker Version using this binding.14781 */14782type WorkerVersionMetadata = {14783 /** The ID of the Worker Version using this binding */14784 id: string;14785 /** The tag of the Worker Version using this binding */14786 tag: string;14787 /** The timestamp of when the Worker Version was uploaded */14788 timestamp: string;14789};14790// ============ Web Search Request Types ============14791/**14792 * Options for a Web Search query.14793 */14794type WebSearchSearchOptions = {14795 /** The search query. */14796 query: string;14797 /**14798 * Maximum number of results to return. Defaults to 10, capped at 20.14799 * The actual count may be lower if fewer matches exist.14800 */14801 limit?: number;14802};14803// ============ Web Search Response Types ============14804/**14805 * A single Web Search result.14806 *14807 * Web Search is discovery-only -- results carry catalog metadata about a page14808 * but never the page body. To read a result's content the caller invokes the14809 * global `fetch()` API against the result's `url`, at which point the14810 * destination's own access controls apply (including Cloudflare Pay-per-Crawl).14811 */14812type WebSearchResult = {14813 /** Canonical URL. */14814 url: string;14815 /** Page title. */14816 title: string;14817 /** Page-level description. May be absent. */14818 description?: string;14819 /**14820 * Last-modified date for the page, when known. Naive (no timezone)14821 * ISO-8601 datetime, e.g. `"2025-11-30T04:39:48"`.14822 */14823 lastModifiedDate?: string;14824 /**14825 * Page meta image URL (typically the `og:image`). May be absent.14826 */14827 imageUrl?: string;14828 /** Optional favicon URL for UI hints. */14829 faviconUrl?: string;14830};14831/**14832 * Per-response metadata for a Web Search query. Carries operational14833 * fields useful for support and debugging.14834 */14835type WebSearchResponseMetadata = {14836 /** The query that was executed. */14837 query: string;14838 /** Opaque request identifier used for support and debugging. */14839 requestId: string;14840 /** End-to-end latency for this search request, in milliseconds. */14841 latencyMs: number;14842};14843/**14844 * Response from a Web Search query.14845 */14846type WebSearchSearchResponse = {14847 items: WebSearchResult[];14848 metadata: WebSearchResponseMetadata;14849};14850// ============ Web Search Binding Class ============14851/**14852 * Cloudflare Web Search binding.14853 *14854 * Discovery-only primitive for agents and Workers. Returns URLs and catalog14855 * metadata for a query; never returns page content or excerpts. To read a14856 * result's body, fetch the URL with the global `fetch()` API.14857 *14858 * Declared in wrangler with a single object (there is exactly one corpus, the14859 * public web, so there is no name, namespace, or instance to specify):14860 *14861 * ```jsonc14862 * { "web_search": { "binding": "WEBSEARCH" } }14863 * ```14864 *14865 * @example14866 * ```ts14867 * const { items, metadata } = await env.WEBSEARCH.search({14868 * query: "Cloudflare Workers",14869 * });14870 *14871 * const top = items[0];14872 * console.log(top.url, top.title, metadata.latencyMs);14873 *14874 * // Read content yourself; pay-per-crawl and other publisher14875 * // controls apply at the fetch site, not at search time.14876 * const page = await fetch(top.url);14877 * ```14878 */14879declare abstract class WebSearch {14880 /**14881 * Run a Web Search query.14882 * @param options Search options. Only `query` is required.14883 * @returns The matching results plus per-response metadata.14884 */14885 search(options: WebSearchSearchOptions): Promise<WebSearchSearchResponse>;14886}14887interface DynamicDispatchLimits {14888 /**14889 * Limit CPU time in milliseconds.14890 */14891 cpuMs?: number;14892 /**14893 * Limit number of subrequests.14894 */14895 subRequests?: number;14896}14897interface DynamicDispatchOptions {14898 /**14899 * Limit resources of invoked Worker script.14900 */14901 limits?: DynamicDispatchLimits;14902 /**14903 * Arguments for outbound Worker script, if configured.14904 */14905 outbound?: {14906 [key: string]: any;14907 };14908}14909interface DispatchNamespace {14910 /**14911 * @param name Name of the Worker script.14912 * @param args Arguments to Worker script.14913 * @param options Options for Dynamic Dispatch invocation.14914 * @returns A Fetcher object that allows you to send requests to the Worker script.14915 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.14916 */14917 get(name: string, args?: {14918 [key: string]: any;14919 }, options?: DynamicDispatchOptions): Fetcher;14920}14921declare module 'cloudflare:workflows' {14922 /**14923 * NonRetryableError allows for a user to throw a fatal error14924 * that makes a Workflow instance fail immediately without triggering a retry14925 */14926 export class NonRetryableError extends Error {14927 public constructor(message: string, name?: string);14928 }14929}14930declare abstract class Workflow<PARAMS = unknown> {14931 /**14932 * Get a handle to an existing instance of the Workflow.14933 * @param id Id for the instance of this Workflow14934 * @returns A promise that resolves with a handle for the Instance14935 */14936 public get(id: string): Promise<WorkflowInstance>;14937 /**14938 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.14939 * @param options Options when creating an instance including id and params14940 * @returns A promise that resolves with a handle for the Instance14941 */14942 public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>;14943 /**14944 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.14945 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.14946 * @param batch List of Options when creating an instance including name and params14947 * @returns A promise that resolves with a list of handles for the created instances.14948 */14949 public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;14950 /**14951 * Delete a batch of Workflow instances and their stored state.14952 * `deleteBatch` is limited to 100 instances at a time. Duplicate IDs are deleted once.14953 * The result contains one entry for each input position; IDs that do not exist are returned as per-instance errors.14954 * @param instanceIds IDs of the Workflow instances to delete14955 * @returns A promise that resolves with the successfully deleted instances and any per-instance errors.14956 */14957 public deleteBatch(instanceIds: string[]): Promise<WorkflowBatchDeleteResult>;14958}14959type WorkflowBatchDeleteResult = {14960 deleted: {14961 id: string;14962 }[];14963 errors: {14964 id: string;14965 code: number;14966 message: string;14967 }[];14968};14969type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';14970type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;14971type WorkflowRetentionDuration = WorkflowSleepDuration;14972/** Geographic regions supported when creating a Workflow instance.14973 * Location hints are best-effort placement preferences. */14974type WorkflowInstanceLocationHint = 'wnam' | 'enam' | 'sam' | 'weur' | 'eeur' | 'apac' | 'apac-ne' | 'apac-se' | 'oc' | 'afr' | 'me';14975interface WorkflowInstanceCreateOptions<PARAMS = unknown> {14976 /**14977 * An id for your Workflow instance. Must be unique within the Workflow.14978 */14979 id?: string;14980 /**14981 * The event payload the Workflow instance is triggered with14982 */14983 params?: PARAMS;14984 /**14985 * The retention policy for Workflow instance.14986 * Defaults to the maximum retention period available for the owner's account.14987 */14988 retention?: {14989 successRetention?: WorkflowRetentionDuration;14990 errorRetention?: WorkflowRetentionDuration;14991 };14992 /** A best-effort geographic placement preference for the Workflow instance.14993 * See `WorkflowInstanceLocationHint` for supported regions. */14994 locationHint?: WorkflowInstanceLocationHint;14995}14996type InstanceStatus = {14997 status: 'queued' // means that instance is waiting to be started (see concurrency limits)14998 | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running14999 | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish15000 | 'waitingForPause' // instance is finishing the current work to pause15001 | 'unknown';15002 error?: {15003 name: string;15004 message: string;15005 };15006 output?: unknown;15007};15008interface WorkflowError {15009 code?: number;15010 message: string;15011}15012interface WorkflowInstanceTerminateOptions {15013 /**15014 * If true, run registered rollback handlers before terminating the instance.15015 * Only steps that registered rollback handlers are rolled back.15016 */15017 rollback?: boolean;15018}15019interface WorkflowInstanceRestartOptions {15020 /**15021 * Restart from a specific step. If omitted, the instance restarts from the beginning.15022 * The step must exist in the instance's execution history.15023 */15024 from?: {15025 /**15026 * The step name as defined in your workflow code.15027 */15028 name: string;15029 /**15030 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).15031 * @default 115032 */15033 count?: number;15034 /**15035 * Step type filter. Use when different step types share the same name.15036 */15037 type?: 'do' | 'sleep' | 'waitForEvent';15038 };15039}15040declare abstract class WorkflowInstance {15041 public id: string;15042 /**15043 * Pause the instance.15044 */15045 public pause(): Promise<void>;15046 /**15047 * Resume the instance. If it is already running, an error will be thrown.15048 */15049 public resume(): Promise<void>;15050 /**15051 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.15052 * @param options Options for termination, including whether registered rollback handlers should run.15053 */15054 public terminate(options?: WorkflowInstanceTerminateOptions): Promise<void>;15055 /**15056 * Restart the instance. Optionally restart from a specific step, preserving15057 * cached results for all steps before it.15058 * @param options Options for the restart, including an optional step to restart from.15059 */15060 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;15061 /**15062 * Delete the instance and its stored state.15063 */15064 public delete(): Promise<void>;15065 /**15066 * Returns the current status of the instance.15067 */15068 public status(): Promise<InstanceStatus>;15069 /**15070 * Send an event to this instance.15071 */15072 public sendEvent({ type, payload, }: {15073 type: string;15074 payload: unknown;15075 }): Promise<void>;15076}