worker-configuration.d.ts (541200B)
1 /* eslint-disable */ 2 // Generated by Wrangler by running `wrangler types` (hash: 3d3fdd145760295159fc1eac24135779) 3 // Runtime types generated with workerd@1.20260611.1 2026-06-13 nodejs_compat 4 interface __BaseEnv_Env { 5 } 6 declare namespace Cloudflare { 7 interface GlobalProps { 8 mainModule: typeof import("./src/index"); 9 } 10 interface Env extends __BaseEnv_Env {} 11 } 12 interface Env extends __BaseEnv_Env {} 13 14 // Begin runtime types 15 /*! ***************************************************************************** 16 Copyright (c) Cloudflare. All rights reserved. 17 Copyright (c) Microsoft Corporation. All rights reserved. 18 19 Licensed under the Apache License, Version 2.0 (the "License"); you may not use 20 this file except in compliance with the License. You may obtain a copy of the 21 License at http://www.apache.org/licenses/LICENSE-2.0 22 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 23 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 24 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 25 MERCHANTABLITY OR NON-INFRINGEMENT. 26 See the Apache Version 2.0 License for specific language governing permissions 27 and limitations under the License. 28 ***************************************************************************** */ 29 /* eslint-disable */ 30 // noinspection JSUnusedGlobalSymbols 31 declare var onmessage: never; 32 /** 33 * 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. 34 * 35 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException) 36 */ 37 declare class DOMException extends Error { 38 constructor(message?: string, name?: string); 39 /** 40 * The **`message`** read-only property of the a message or description associated with the given error name. 41 * 42 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message) 43 */ 44 readonly message: string; 45 /** 46 * The **`name`** read-only property of the one of the strings associated with an error name. 47 * 48 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name) 49 */ 50 readonly name: string; 51 /** 52 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match. 53 * @deprecated 54 * 55 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code) 56 */ 57 readonly code: number; 58 static readonly INDEX_SIZE_ERR: number; 59 static readonly DOMSTRING_SIZE_ERR: number; 60 static readonly HIERARCHY_REQUEST_ERR: number; 61 static readonly WRONG_DOCUMENT_ERR: number; 62 static readonly INVALID_CHARACTER_ERR: number; 63 static readonly NO_DATA_ALLOWED_ERR: number; 64 static readonly NO_MODIFICATION_ALLOWED_ERR: number; 65 static readonly NOT_FOUND_ERR: number; 66 static readonly NOT_SUPPORTED_ERR: number; 67 static readonly INUSE_ATTRIBUTE_ERR: number; 68 static readonly INVALID_STATE_ERR: number; 69 static readonly SYNTAX_ERR: number; 70 static readonly INVALID_MODIFICATION_ERR: number; 71 static readonly NAMESPACE_ERR: number; 72 static readonly INVALID_ACCESS_ERR: number; 73 static readonly VALIDATION_ERR: number; 74 static readonly TYPE_MISMATCH_ERR: number; 75 static readonly SECURITY_ERR: number; 76 static readonly NETWORK_ERR: number; 77 static readonly ABORT_ERR: number; 78 static readonly URL_MISMATCH_ERR: number; 79 static readonly QUOTA_EXCEEDED_ERR: number; 80 static readonly TIMEOUT_ERR: number; 81 static readonly INVALID_NODE_TYPE_ERR: number; 82 static readonly DATA_CLONE_ERR: number; 83 get stack(): any; 84 set stack(value: any); 85 } 86 type WorkerGlobalScopeEventMap = { 87 fetch: FetchEvent; 88 scheduled: ScheduledEvent; 89 queue: QueueEvent; 90 unhandledrejection: PromiseRejectionEvent; 91 rejectionhandled: PromiseRejectionEvent; 92 }; 93 declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> { 94 EventTarget: typeof EventTarget; 95 } 96 /* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). * 97 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). 98 * 99 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console) 100 */ 101 interface Console { 102 "assert"(condition?: boolean, ...data: any[]): void; 103 /** 104 * The **`console.clear()`** static method clears the console if possible. 105 * 106 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static) 107 */ 108 clear(): void; 109 /** 110 * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called. 111 * 112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static) 113 */ 114 count(label?: string): void; 115 /** 116 * The **`console.countReset()`** static method resets counter used with console/count_static. 117 * 118 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static) 119 */ 120 countReset(label?: string): void; 121 /** 122 * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level. 123 * 124 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static) 125 */ 126 debug(...data: any[]): void; 127 /** 128 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object. 129 * 130 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static) 131 */ 132 dir(item?: any, options?: any): void; 133 /** 134 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element. 135 * 136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static) 137 */ 138 dirxml(...data: any[]): void; 139 /** 140 * The **`console.error()`** static method outputs a message to the console at the 'error' log level. 141 * 142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static) 143 */ 144 error(...data: any[]): void; 145 /** 146 * 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_static is called. 147 * 148 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static) 149 */ 150 group(...data: any[]): void; 151 /** 152 * The **`console.groupCollapsed()`** static method creates a new inline group in the console. 153 * 154 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static) 155 */ 156 groupCollapsed(...data: any[]): void; 157 /** 158 * The **`console.groupEnd()`** static method exits the current inline group in the console. 159 * 160 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static) 161 */ 162 groupEnd(): void; 163 /** 164 * The **`console.info()`** static method outputs a message to the console at the 'info' log level. 165 * 166 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static) 167 */ 168 info(...data: any[]): void; 169 /** 170 * The **`console.log()`** static method outputs a message to the console. 171 * 172 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static) 173 */ 174 log(...data: any[]): void; 175 /** 176 * The **`console.table()`** static method displays tabular data as a table. 177 * 178 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static) 179 */ 180 table(tabularData?: any, properties?: string[]): void; 181 /** 182 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes. 183 * 184 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static) 185 */ 186 time(label?: string): void; 187 /** 188 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static. 189 * 190 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static) 191 */ 192 timeEnd(label?: string): void; 193 /** 194 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static. 195 * 196 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static) 197 */ 198 timeLog(label?: string, ...data: any[]): void; 199 timeStamp(label?: string): void; 200 /** 201 * The **`console.trace()`** static method outputs a stack trace to the console. 202 * 203 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static) 204 */ 205 trace(...data: any[]): void; 206 /** 207 * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level. 208 * 209 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static) 210 */ 211 warn(...data: any[]): void; 212 } 213 declare const console: Console; 214 type BufferSource = ArrayBufferView | ArrayBuffer; 215 type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; 216 declare namespace WebAssembly { 217 class CompileError extends Error { 218 constructor(message?: string); 219 } 220 class RuntimeError extends Error { 221 constructor(message?: string); 222 } 223 type ValueType = "anyfunc" | "externref" | "f32" | "f64" | "i32" | "i64" | "v128"; 224 interface GlobalDescriptor { 225 value: ValueType; 226 mutable?: boolean; 227 } 228 class Global { 229 constructor(descriptor: GlobalDescriptor, value?: any); 230 value: any; 231 valueOf(): any; 232 } 233 type ImportValue = ExportValue | number; 234 type ModuleImports = Record<string, ImportValue>; 235 type Imports = Record<string, ModuleImports>; 236 type ExportValue = Function | Global | Memory | Table; 237 type Exports = Record<string, ExportValue>; 238 class Instance { 239 constructor(module: Module, imports?: Imports); 240 readonly exports: Exports; 241 } 242 interface MemoryDescriptor { 243 initial: number; 244 maximum?: number; 245 shared?: boolean; 246 } 247 class Memory { 248 constructor(descriptor: MemoryDescriptor); 249 readonly buffer: ArrayBuffer; 250 grow(delta: number): number; 251 } 252 type ImportExportKind = "function" | "global" | "memory" | "table"; 253 interface ModuleExportDescriptor { 254 kind: ImportExportKind; 255 name: string; 256 } 257 interface ModuleImportDescriptor { 258 kind: ImportExportKind; 259 module: string; 260 name: string; 261 } 262 abstract class Module { 263 static customSections(module: Module, sectionName: string): ArrayBuffer[]; 264 static exports(module: Module): ModuleExportDescriptor[]; 265 static imports(module: Module): ModuleImportDescriptor[]; 266 } 267 type TableKind = "anyfunc" | "externref"; 268 interface TableDescriptor { 269 element: TableKind; 270 initial: number; 271 maximum?: number; 272 } 273 class Table { 274 constructor(descriptor: TableDescriptor, value?: any); 275 readonly length: number; 276 get(index: number): any; 277 grow(delta: number, value?: any): number; 278 set(index: number, value?: any): void; 279 } 280 function instantiate(module: Module, imports?: Imports): Promise<Instance>; 281 function validate(bytes: BufferSource): boolean; 282 } 283 /** 284 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker. 285 * Available only in secure contexts. 286 * 287 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope) 288 */ 289 interface ServiceWorkerGlobalScope extends WorkerGlobalScope { 290 DOMException: typeof DOMException; 291 WorkerGlobalScope: typeof WorkerGlobalScope; 292 btoa(data: string): string; 293 atob(data: string): string; 294 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; 295 setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 296 clearTimeout(timeoutId: number | null): void; 297 setInterval(callback: (...args: any[]) => void, msDelay?: number): number; 298 setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 299 clearInterval(timeoutId: number | null): void; 300 queueMicrotask(task: Function): void; 301 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T; 302 reportError(error: any): void; 303 fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>; 304 self: ServiceWorkerGlobalScope; 305 crypto: Crypto; 306 caches: CacheStorage; 307 scheduler: Scheduler; 308 performance: Performance; 309 Cloudflare: Cloudflare; 310 readonly origin: string; 311 Event: typeof Event; 312 ExtendableEvent: typeof ExtendableEvent; 313 CustomEvent: typeof CustomEvent; 314 PromiseRejectionEvent: typeof PromiseRejectionEvent; 315 FetchEvent: typeof FetchEvent; 316 TailEvent: typeof TailEvent; 317 TraceEvent: typeof TailEvent; 318 ScheduledEvent: typeof ScheduledEvent; 319 MessageEvent: typeof MessageEvent; 320 CloseEvent: typeof CloseEvent; 321 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader; 322 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader; 323 ReadableStream: typeof ReadableStream; 324 WritableStream: typeof WritableStream; 325 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter; 326 TransformStream: typeof TransformStream; 327 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy; 328 CountQueuingStrategy: typeof CountQueuingStrategy; 329 ErrorEvent: typeof ErrorEvent; 330 MessageChannel: typeof MessageChannel; 331 MessagePort: typeof MessagePort; 332 EventSource: typeof EventSource; 333 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest; 334 ReadableStreamDefaultController: typeof ReadableStreamDefaultController; 335 ReadableByteStreamController: typeof ReadableByteStreamController; 336 WritableStreamDefaultController: typeof WritableStreamDefaultController; 337 TransformStreamDefaultController: typeof TransformStreamDefaultController; 338 CompressionStream: typeof CompressionStream; 339 DecompressionStream: typeof DecompressionStream; 340 TextEncoderStream: typeof TextEncoderStream; 341 TextDecoderStream: typeof TextDecoderStream; 342 Headers: typeof Headers; 343 Body: typeof Body; 344 Request: typeof Request; 345 Response: typeof Response; 346 WebSocket: typeof WebSocket; 347 WebSocketPair: typeof WebSocketPair; 348 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair; 349 AbortController: typeof AbortController; 350 AbortSignal: typeof AbortSignal; 351 TextDecoder: typeof TextDecoder; 352 TextEncoder: typeof TextEncoder; 353 navigator: Navigator; 354 Navigator: typeof Navigator; 355 URL: typeof URL; 356 URLSearchParams: typeof URLSearchParams; 357 URLPattern: typeof URLPattern; 358 Blob: typeof Blob; 359 File: typeof File; 360 FormData: typeof FormData; 361 Crypto: typeof Crypto; 362 SubtleCrypto: typeof SubtleCrypto; 363 CryptoKey: typeof CryptoKey; 364 CacheStorage: typeof CacheStorage; 365 Cache: typeof Cache; 366 FixedLengthStream: typeof FixedLengthStream; 367 IdentityTransformStream: typeof IdentityTransformStream; 368 HTMLRewriter: typeof HTMLRewriter; 369 } 370 declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void; 371 declare function removeEventListener<Type extends keyof WorkerGlobalScopeEventMap>(type: Type, handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void; 372 /** 373 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. 374 * 375 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) 376 */ 377 declare function dispatchEvent(event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap]): boolean; 378 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */ 379 declare function btoa(data: string): string; 380 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */ 381 declare function atob(data: string): string; 382 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ 383 declare function setTimeout(callback: (...args: any[]) => void, msDelay?: number): number; 384 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */ 385 declare function setTimeout<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 386 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */ 387 declare function clearTimeout(timeoutId: number | null): void; 388 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ 389 declare function setInterval(callback: (...args: any[]) => void, msDelay?: number): number; 390 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */ 391 declare function setInterval<Args extends any[]>(callback: (...args: Args) => void, msDelay?: number, ...args: Args): number; 392 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */ 393 declare function clearInterval(timeoutId: number | null): void; 394 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */ 395 declare function queueMicrotask(task: Function): void; 396 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */ 397 declare function structuredClone<T>(value: T, options?: StructuredSerializeOptions): T; 398 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */ 399 declare function reportError(error: any): void; 400 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */ 401 declare function fetch(input: RequestInfo | URL, init?: RequestInit<RequestInitCfProperties>): Promise<Response>; 402 declare const self: ServiceWorkerGlobalScope; 403 /** 404 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks. 405 * The Workers runtime implements the full surface of this API, but with some differences in 406 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) 407 * compared to those implemented in most browsers. 408 * 409 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) 410 */ 411 declare const crypto: Crypto; 412 /** 413 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 414 * 415 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 416 */ 417 declare const caches: CacheStorage; 418 declare const scheduler: Scheduler; 419 /** 420 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance, 421 * as well as timing of subrequests and other operations. 422 * 423 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) 424 */ 425 declare const performance: Performance; 426 declare const Cloudflare: Cloudflare; 427 declare const origin: string; 428 declare const navigator: Navigator; 429 interface TestController { 430 } 431 interface ExecutionContext<Props = unknown> { 432 waitUntil(promise: Promise<any>): void; 433 passThroughOnException(): void; 434 readonly exports: Cloudflare.Exports; 435 readonly props: Props; 436 cache?: CacheContext; 437 tracing?: Tracing; 438 } 439 type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>; 440 type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 441 type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (events: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 442 type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (traces: TraceItem[], env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 443 type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (event: TailStream.TailEvent<TailStream.Onset>, env: Env, ctx: ExecutionContext<Props>) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>; 444 type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (controller: ScheduledController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 445 type ExportedHandlerQueueHandler<Env = unknown, Message = unknown, Props = unknown> = (batch: MessageBatch<Message>, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 446 type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (controller: TestController, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 447 interface ExportedHandler<Env = unknown, QueueHandlerMessage = unknown, CfHostMetadata = unknown, Props = unknown> { 448 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>; 449 connect?: ExportedHandlerConnectHandler<Env, Props>; 450 tail?: ExportedHandlerTailHandler<Env, Props>; 451 trace?: ExportedHandlerTraceHandler<Env, Props>; 452 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>; 453 scheduled?: ExportedHandlerScheduledHandler<Env, Props>; 454 test?: ExportedHandlerTestHandler<Env, Props>; 455 email?: EmailExportedHandler<Env, Props>; 456 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>; 457 } 458 interface StructuredSerializeOptions { 459 transfer?: any[]; 460 } 461 declare abstract class Navigator { 462 sendBeacon(url: string, body?: BodyInit): boolean; 463 readonly userAgent: string; 464 readonly hardwareConcurrency: number; 465 readonly platform: string; 466 readonly language: string; 467 readonly languages: string[]; 468 } 469 interface AlarmInvocationInfo { 470 readonly isRetry: boolean; 471 readonly retryCount: number; 472 readonly scheduledTime: number; 473 } 474 interface Cloudflare { 475 readonly compatibilityFlags: Record<string, boolean>; 476 } 477 interface CachePurgeError { 478 code: number; 479 message: string; 480 } 481 interface CachePurgeResult { 482 success: boolean; 483 errors: CachePurgeError[]; 484 } 485 interface CachePurgeOptions { 486 tags?: string[]; 487 pathPrefixes?: string[]; 488 purgeEverything?: boolean; 489 } 490 interface CacheContext { 491 purge(options: CachePurgeOptions): Promise<CachePurgeResult>; 492 } 493 declare abstract class ColoLocalActorNamespace { 494 get(actorId: string): Fetcher; 495 } 496 interface DurableObject { 497 fetch(request: Request): Response | Promise<Response>; 498 connect?(socket: Socket): void | Promise<void>; 499 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 500 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 501 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 502 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; 503 } 504 type DurableObjectStub<T extends Rpc.DurableObjectBranded | undefined = undefined> = Fetcher<T, "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"> & { 505 readonly id: DurableObjectId; 506 readonly name?: string; 507 }; 508 interface DurableObjectId { 509 toString(): string; 510 equals(other: DurableObjectId): boolean; 511 readonly name?: string; 512 readonly jurisdiction?: string; 513 } 514 declare abstract class DurableObjectNamespace<T extends Rpc.DurableObjectBranded | undefined = undefined> { 515 newUniqueId(options?: DurableObjectNamespaceNewUniqueIdOptions): DurableObjectId; 516 idFromName(name: string): DurableObjectId; 517 idFromString(id: string): DurableObjectId; 518 get(id: DurableObjectId, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>; 519 getByName(name: string, options?: DurableObjectNamespaceGetDurableObjectOptions): DurableObjectStub<T>; 520 jurisdiction(jurisdiction: DurableObjectJurisdiction): DurableObjectNamespace<T>; 521 } 522 type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high"; 523 interface DurableObjectNamespaceNewUniqueIdOptions { 524 jurisdiction?: DurableObjectJurisdiction; 525 } 526 type DurableObjectLocationHint = "wnam" | "enam" | "sam" | "weur" | "eeur" | "apac" | "oc" | "afr" | "me"; 527 type DurableObjectRoutingMode = "primary-only"; 528 interface DurableObjectNamespaceGetDurableObjectOptions { 529 locationHint?: DurableObjectLocationHint; 530 routingMode?: DurableObjectRoutingMode; 531 } 532 interface DurableObjectClass<_T extends Rpc.DurableObjectBranded | undefined = undefined> { 533 } 534 interface DurableObjectState<Props = unknown> { 535 waitUntil(promise: Promise<any>): void; 536 readonly exports: Cloudflare.Exports; 537 readonly props: Props; 538 readonly id: DurableObjectId; 539 readonly storage: DurableObjectStorage; 540 container?: Container; 541 facets: DurableObjectFacets; 542 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>; 543 acceptWebSocket(ws: WebSocket, tags?: string[]): void; 544 getWebSockets(tag?: string): WebSocket[]; 545 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void; 546 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null; 547 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null; 548 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void; 549 getHibernatableWebSocketEventTimeout(): number | null; 550 getTags(ws: WebSocket): string[]; 551 abort(reason?: string): void; 552 } 553 interface DurableObjectTransaction { 554 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>; 555 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>; 556 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>; 557 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>; 558 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>; 559 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>; 560 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>; 561 rollback(): void; 562 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; 563 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>; 564 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; 565 } 566 interface DurableObjectStorage { 567 get<T = unknown>(key: string, options?: DurableObjectGetOptions): Promise<T | undefined>; 568 get<T = unknown>(keys: string[], options?: DurableObjectGetOptions): Promise<Map<string, T>>; 569 list<T = unknown>(options?: DurableObjectListOptions): Promise<Map<string, T>>; 570 put<T>(key: string, value: T, options?: DurableObjectPutOptions): Promise<void>; 571 put<T>(entries: Record<string, T>, options?: DurableObjectPutOptions): Promise<void>; 572 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>; 573 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>; 574 deleteAll(options?: DurableObjectPutOptions): Promise<void>; 575 transaction<T>(closure: (txn: DurableObjectTransaction) => Promise<T>): Promise<T>; 576 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>; 577 setAlarm(scheduledTime: number | Date, options?: DurableObjectSetAlarmOptions): Promise<void>; 578 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>; 579 sync(): Promise<void>; 580 sql: SqlStorage; 581 kv: SyncKvStorage; 582 transactionSync<T>(closure: () => T): T; 583 getCurrentBookmark(): Promise<string>; 584 getBookmarkForTime(timestamp: number | Date): Promise<string>; 585 onNextSessionRestoreBookmark(bookmark: string): Promise<string>; 586 } 587 interface DurableObjectListOptions { 588 start?: string; 589 startAfter?: string; 590 end?: string; 591 prefix?: string; 592 reverse?: boolean; 593 limit?: number; 594 allowConcurrency?: boolean; 595 noCache?: boolean; 596 } 597 interface DurableObjectGetOptions { 598 allowConcurrency?: boolean; 599 noCache?: boolean; 600 } 601 interface DurableObjectGetAlarmOptions { 602 allowConcurrency?: boolean; 603 } 604 interface DurableObjectPutOptions { 605 allowConcurrency?: boolean; 606 allowUnconfirmed?: boolean; 607 noCache?: boolean; 608 } 609 interface DurableObjectSetAlarmOptions { 610 allowConcurrency?: boolean; 611 allowUnconfirmed?: boolean; 612 } 613 declare class WebSocketRequestResponsePair { 614 constructor(request: string, response: string); 615 get request(): string; 616 get response(): string; 617 } 618 interface DurableObjectFacets { 619 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(name: string, getStartupOptions: () => FacetStartupOptions<T> | Promise<FacetStartupOptions<T>>): Fetcher<T>; 620 abort(name: string, reason: any): void; 621 delete(name: string): void; 622 } 623 interface FacetStartupOptions<T extends Rpc.DurableObjectBranded | undefined = undefined> { 624 id?: DurableObjectId | string; 625 class: DurableObjectClass<T>; 626 } 627 interface AnalyticsEngineDataset { 628 writeDataPoint(event?: AnalyticsEngineDataPoint): void; 629 } 630 interface AnalyticsEngineDataPoint { 631 indexes?: ((ArrayBuffer | string) | null)[]; 632 doubles?: number[]; 633 blobs?: ((ArrayBuffer | string) | null)[]; 634 } 635 /** 636 * The **`Event`** interface represents an event which takes place on an `EventTarget`. 637 * 638 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event) 639 */ 640 declare class Event { 641 constructor(type: string, init?: EventInit); 642 /** 643 * The **`type`** read-only property of the Event interface returns a string containing the event's type. 644 * 645 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type) 646 */ 647 get type(): string; 648 /** 649 * The **`eventPhase`** read-only property of the being evaluated. 650 * 651 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase) 652 */ 653 get eventPhase(): number; 654 /** 655 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM. 656 * 657 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed) 658 */ 659 get composed(): boolean; 660 /** 661 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not. 662 * 663 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles) 664 */ 665 get bubbles(): boolean; 666 /** 667 * 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. 668 * 669 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable) 670 */ 671 get cancelable(): boolean; 672 /** 673 * 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. 674 * 675 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented) 676 */ 677 get defaultPrevented(): boolean; 678 /** 679 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not. 680 * @deprecated 681 * 682 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue) 683 */ 684 get returnValue(): boolean; 685 /** 686 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached. 687 * 688 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget) 689 */ 690 get currentTarget(): EventTarget | undefined; 691 /** 692 * The read-only **`target`** property of the dispatched. 693 * 694 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target) 695 */ 696 get target(): EventTarget | undefined; 697 /** 698 * The deprecated **`Event.srcElement`** is an alias for the Event.target property. 699 * @deprecated 700 * 701 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement) 702 */ 703 get srcElement(): EventTarget | undefined; 704 /** 705 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created. 706 * 707 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp) 708 */ 709 get timeStamp(): number; 710 /** 711 * The **`isTrusted`** read-only property of the 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 The only exception is the `click` event, which initializes the `isTrusted` property to `false` in user agents. 712 * 713 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted) 714 */ 715 get isTrusted(): boolean; 716 /** 717 * The **`cancelBubble`** property of the Event interface is deprecated. 718 * @deprecated 719 * 720 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) 721 */ 722 get cancelBubble(): boolean; 723 /** 724 * The **`cancelBubble`** property of the Event interface is deprecated. 725 * @deprecated 726 * 727 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble) 728 */ 729 set cancelBubble(value: boolean); 730 /** 731 * The **`stopImmediatePropagation()`** method of the If several listeners are attached to the same element for the same event type, they are called in the order in which they were added. 732 * 733 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation) 734 */ 735 stopImmediatePropagation(): void; 736 /** 737 * The **`preventDefault()`** method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be. 738 * 739 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault) 740 */ 741 preventDefault(): void; 742 /** 743 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases. 744 * 745 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation) 746 */ 747 stopPropagation(): void; 748 /** 749 * 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. 750 * 751 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath) 752 */ 753 composedPath(): EventTarget[]; 754 static readonly NONE: number; 755 static readonly CAPTURING_PHASE: number; 756 static readonly AT_TARGET: number; 757 static readonly BUBBLING_PHASE: number; 758 } 759 interface EventInit { 760 bubbles?: boolean; 761 cancelable?: boolean; 762 composed?: boolean; 763 } 764 type EventListener<EventType extends Event = Event> = (event: EventType) => void; 765 interface EventListenerObject<EventType extends Event = Event> { 766 handleEvent(event: EventType): void; 767 } 768 type EventListenerOrEventListenerObject<EventType extends Event = Event> = EventListener<EventType> | EventListenerObject<EventType>; 769 /** 770 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them. 771 * 772 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget) 773 */ 774 declare class EventTarget<EventMap extends Record<string, Event> = Record<string, Event>> { 775 constructor(); 776 /** 777 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. 778 * 779 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener) 780 */ 781 addEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetAddEventListenerOptions | boolean): void; 782 /** 783 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. 784 * 785 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener) 786 */ 787 removeEventListener<Type extends keyof EventMap>(type: Type, handler: EventListenerOrEventListenerObject<EventMap[Type]>, options?: EventTargetEventListenerOptions | boolean): void; 788 /** 789 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. 790 * 791 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent) 792 */ 793 dispatchEvent(event: EventMap[keyof EventMap]): boolean; 794 } 795 interface EventTargetEventListenerOptions { 796 capture?: boolean; 797 } 798 interface EventTargetAddEventListenerOptions { 799 capture?: boolean; 800 passive?: boolean; 801 once?: boolean; 802 signal?: AbortSignal; 803 } 804 interface EventTargetHandlerObject { 805 handleEvent: (event: Event) => any | undefined; 806 } 807 /** 808 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired. 809 * 810 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController) 811 */ 812 declare class AbortController { 813 constructor(); 814 /** 815 * 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. 816 * 817 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal) 818 */ 819 get signal(): AbortSignal; 820 /** 821 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed. 822 * 823 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort) 824 */ 825 abort(reason?: any): void; 826 } 827 /** 828 * 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. 829 * 830 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal) 831 */ 832 declare abstract class AbortSignal extends EventTarget { 833 /** 834 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event). 835 * 836 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static) 837 */ 838 static abort(reason?: any): AbortSignal; 839 /** 840 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time. 841 * 842 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static) 843 */ 844 static timeout(delay: number): AbortSignal; 845 /** 846 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal. 847 * 848 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static) 849 */ 850 static any(signals: AbortSignal[]): AbortSignal; 851 /** 852 * 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`). 853 * 854 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted) 855 */ 856 get aborted(): boolean; 857 /** 858 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason. 859 * 860 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason) 861 */ 862 get reason(): any; 863 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ 864 get onabort(): any | null; 865 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */ 866 set onabort(value: any | null); 867 /** 868 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing. 869 * 870 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted) 871 */ 872 throwIfAborted(): void; 873 } 874 interface Scheduler { 875 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>; 876 } 877 interface SchedulerWaitOptions { 878 signal?: AbortSignal; 879 } 880 /** 881 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle. 882 * 883 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent) 884 */ 885 declare abstract class ExtendableEvent extends Event { 886 /** 887 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing. 888 * 889 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil) 890 */ 891 waitUntil(promise: Promise<any>): void; 892 } 893 /** 894 * The **`CustomEvent`** interface represents events initialized by an application for any purpose. 895 * 896 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent) 897 */ 898 declare class CustomEvent<T = any> extends Event { 899 constructor(type: string, init?: CustomEventCustomEventInit); 900 /** 901 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event. 902 * 903 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail) 904 */ 905 get detail(): T; 906 } 907 interface CustomEventCustomEventInit { 908 bubbles?: boolean; 909 cancelable?: boolean; 910 composed?: boolean; 911 detail?: any; 912 } 913 /** 914 * 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. 915 * 916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob) 917 */ 918 declare class Blob { 919 constructor(bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[], options?: BlobOptions); 920 /** 921 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes. 922 * 923 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size) 924 */ 925 get size(): number; 926 /** 927 * The **`type`** read-only property of the Blob interface returns the MIME type of the file. 928 * 929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type) 930 */ 931 get type(): string; 932 /** 933 * 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. 934 * 935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice) 936 */ 937 slice(start?: number, end?: number, type?: string): Blob; 938 /** 939 * 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. 940 * 941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer) 942 */ 943 arrayBuffer(): Promise<ArrayBuffer>; 944 /** 945 * 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. 946 * 947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes) 948 */ 949 bytes(): Promise<Uint8Array>; 950 /** 951 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8. 952 * 953 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text) 954 */ 955 text(): Promise<string>; 956 /** 957 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`. 958 * 959 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream) 960 */ 961 stream(): ReadableStream; 962 } 963 interface BlobOptions { 964 type?: string; 965 } 966 /** 967 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content. 968 * 969 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File) 970 */ 971 declare class File extends Blob { 972 constructor(bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined, name: string, options?: FileOptions); 973 /** 974 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object. 975 * 976 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name) 977 */ 978 get name(): string; 979 /** 980 * 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). 981 * 982 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified) 983 */ 984 get lastModified(): number; 985 } 986 interface FileOptions { 987 type?: string; 988 lastModified?: number; 989 } 990 /** 991 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 992 * 993 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 994 */ 995 declare abstract class CacheStorage { 996 /** 997 * The **`open()`** method of the the Cache object matching the `cacheName`. 998 * 999 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open) 1000 */ 1001 open(cacheName: string): Promise<Cache>; 1002 readonly default: Cache; 1003 } 1004 /** 1005 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache. 1006 * 1007 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/) 1008 */ 1009 declare abstract class Cache { 1010 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */ 1011 delete(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<boolean>; 1012 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */ 1013 match(request: RequestInfo | URL, options?: CacheQueryOptions): Promise<Response | undefined>; 1014 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */ 1015 put(request: RequestInfo | URL, response: Response): Promise<void>; 1016 } 1017 interface CacheQueryOptions { 1018 ignoreMethod?: boolean; 1019 } 1020 /** 1021 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks. 1022 * The Workers runtime implements the full surface of this API, but with some differences in 1023 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms) 1024 * compared to those implemented in most browsers. 1025 * 1026 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/) 1027 */ 1028 declare abstract class Crypto { 1029 /** 1030 * The **`Crypto.subtle`** read-only property returns a cryptographic operations. 1031 * Available only in secure contexts. 1032 * 1033 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle) 1034 */ 1035 get subtle(): SubtleCrypto; 1036 /** 1037 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values. 1038 * 1039 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) 1040 */ 1041 getRandomValues<T extends Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array | BigInt64Array | BigUint64Array>(buffer: T): T; 1042 /** 1043 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator. 1044 * Available only in secure contexts. 1045 * 1046 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) 1047 */ 1048 randomUUID(): string; 1049 DigestStream: typeof DigestStream; 1050 } 1051 /** 1052 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions. 1053 * Available only in secure contexts. 1054 * 1055 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) 1056 */ 1057 declare abstract class SubtleCrypto { 1058 /** 1059 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data. 1060 * 1061 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) 1062 */ 1063 encrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, plainText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 1064 /** 1065 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data. 1066 * 1067 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) 1068 */ 1069 decrypt(algorithm: string | SubtleCryptoEncryptAlgorithm, key: CryptoKey, cipherText: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 1070 /** 1071 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature. 1072 * 1073 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) 1074 */ 1075 sign(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 1076 /** 1077 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature. 1078 * 1079 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) 1080 */ 1081 verify(algorithm: string | SubtleCryptoSignAlgorithm, key: CryptoKey, signature: ArrayBuffer | ArrayBufferView, data: ArrayBuffer | ArrayBufferView): Promise<boolean>; 1082 /** 1083 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function. 1084 * 1085 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) 1086 */ 1087 digest(algorithm: string | SubtleCryptoHashAlgorithm, data: ArrayBuffer | ArrayBufferView): Promise<ArrayBuffer>; 1088 /** 1089 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms). 1090 * 1091 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) 1092 */ 1093 generateKey(algorithm: string | SubtleCryptoGenerateKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey | CryptoKeyPair>; 1094 /** 1095 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key. 1096 * 1097 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) 1098 */ 1099 deriveKey(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 1100 /** 1101 * The **`deriveBits()`** method of the key. 1102 * 1103 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) 1104 */ 1105 deriveBits(algorithm: string | SubtleCryptoDeriveKeyAlgorithm, baseKey: CryptoKey, length?: number | null): Promise<ArrayBuffer>; 1106 /** 1107 * 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. 1108 * 1109 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) 1110 */ 1111 importKey(format: string, keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey, algorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 1112 /** 1113 * 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. 1114 * 1115 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) 1116 */ 1117 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>; 1118 /** 1119 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key. 1120 * 1121 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) 1122 */ 1123 wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm): Promise<ArrayBuffer>; 1124 /** 1125 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key. 1126 * 1127 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) 1128 */ 1129 unwrapKey(format: string, wrappedKey: ArrayBuffer | ArrayBufferView, unwrappingKey: CryptoKey, unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm, unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm, extractable: boolean, keyUsages: string[]): Promise<CryptoKey>; 1130 timingSafeEqual(a: ArrayBuffer | ArrayBufferView, b: ArrayBuffer | ArrayBufferView): boolean; 1131 } 1132 /** 1133 * The **`CryptoKey`** interface of the Web Crypto API represents a cryptographic key obtained from one of the SubtleCrypto methods SubtleCrypto.generateKey, SubtleCrypto.deriveKey, SubtleCrypto.importKey, or SubtleCrypto.unwrapKey. 1134 * Available only in secure contexts. 1135 * 1136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey) 1137 */ 1138 declare abstract class CryptoKey { 1139 /** 1140 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object. 1141 * 1142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) 1143 */ 1144 readonly type: string; 1145 /** 1146 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`. 1147 * 1148 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) 1149 */ 1150 readonly extractable: boolean; 1151 /** 1152 * 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. 1153 * 1154 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) 1155 */ 1156 readonly algorithm: CryptoKeyKeyAlgorithm | CryptoKeyAesKeyAlgorithm | CryptoKeyHmacKeyAlgorithm | CryptoKeyRsaKeyAlgorithm | CryptoKeyEllipticKeyAlgorithm | CryptoKeyArbitraryKeyAlgorithm; 1157 /** 1158 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key. 1159 * 1160 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) 1161 */ 1162 readonly usages: string[]; 1163 } 1164 interface CryptoKeyPair { 1165 publicKey: CryptoKey; 1166 privateKey: CryptoKey; 1167 } 1168 interface JsonWebKey { 1169 kty: string; 1170 use?: string; 1171 key_ops?: string[]; 1172 alg?: string; 1173 ext?: boolean; 1174 crv?: string; 1175 x?: string; 1176 y?: string; 1177 d?: string; 1178 n?: string; 1179 e?: string; 1180 p?: string; 1181 q?: string; 1182 dp?: string; 1183 dq?: string; 1184 qi?: string; 1185 oth?: RsaOtherPrimesInfo[]; 1186 k?: string; 1187 } 1188 interface RsaOtherPrimesInfo { 1189 r?: string; 1190 d?: string; 1191 t?: string; 1192 } 1193 interface SubtleCryptoDeriveKeyAlgorithm { 1194 name: string; 1195 salt?: (ArrayBuffer | ArrayBufferView); 1196 iterations?: number; 1197 hash?: (string | SubtleCryptoHashAlgorithm); 1198 $public?: CryptoKey; 1199 info?: (ArrayBuffer | ArrayBufferView); 1200 } 1201 interface SubtleCryptoEncryptAlgorithm { 1202 name: string; 1203 iv?: (ArrayBuffer | ArrayBufferView); 1204 additionalData?: (ArrayBuffer | ArrayBufferView); 1205 tagLength?: number; 1206 counter?: (ArrayBuffer | ArrayBufferView); 1207 length?: number; 1208 label?: (ArrayBuffer | ArrayBufferView); 1209 } 1210 interface SubtleCryptoGenerateKeyAlgorithm { 1211 name: string; 1212 hash?: (string | SubtleCryptoHashAlgorithm); 1213 modulusLength?: number; 1214 publicExponent?: (ArrayBuffer | ArrayBufferView); 1215 length?: number; 1216 namedCurve?: string; 1217 } 1218 interface SubtleCryptoHashAlgorithm { 1219 name: string; 1220 } 1221 interface SubtleCryptoImportKeyAlgorithm { 1222 name: string; 1223 hash?: (string | SubtleCryptoHashAlgorithm); 1224 length?: number; 1225 namedCurve?: string; 1226 compressed?: boolean; 1227 } 1228 interface SubtleCryptoSignAlgorithm { 1229 name: string; 1230 hash?: (string | SubtleCryptoHashAlgorithm); 1231 dataLength?: number; 1232 saltLength?: number; 1233 } 1234 interface CryptoKeyKeyAlgorithm { 1235 name: string; 1236 } 1237 interface CryptoKeyAesKeyAlgorithm { 1238 name: string; 1239 length: number; 1240 } 1241 interface CryptoKeyHmacKeyAlgorithm { 1242 name: string; 1243 hash: CryptoKeyKeyAlgorithm; 1244 length: number; 1245 } 1246 interface CryptoKeyRsaKeyAlgorithm { 1247 name: string; 1248 modulusLength: number; 1249 publicExponent: ArrayBuffer | ArrayBufferView; 1250 hash?: CryptoKeyKeyAlgorithm; 1251 } 1252 interface CryptoKeyEllipticKeyAlgorithm { 1253 name: string; 1254 namedCurve: string; 1255 } 1256 interface CryptoKeyArbitraryKeyAlgorithm { 1257 name: string; 1258 hash?: CryptoKeyKeyAlgorithm; 1259 namedCurve?: string; 1260 length?: number; 1261 } 1262 declare class DigestStream extends WritableStream<ArrayBuffer | ArrayBufferView> { 1263 constructor(algorithm: string | SubtleCryptoHashAlgorithm); 1264 readonly digest: Promise<ArrayBuffer>; 1265 get bytesWritten(): number | bigint; 1266 } 1267 /** 1268 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc. 1269 * 1270 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder) 1271 */ 1272 declare class TextDecoder { 1273 constructor(label?: string, options?: TextDecoderConstructorOptions); 1274 /** 1275 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter. 1276 * 1277 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode) 1278 */ 1279 decode(input?: (ArrayBuffer | ArrayBufferView), options?: TextDecoderDecodeOptions): string; 1280 get encoding(): string; 1281 get fatal(): boolean; 1282 get ignoreBOM(): boolean; 1283 } 1284 /** 1285 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes. 1286 * 1287 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder) 1288 */ 1289 declare class TextEncoder { 1290 constructor(); 1291 /** 1292 * The **`TextEncoder.encode()`** method takes a string as input, and returns a Global_Objects/Uint8Array containing the text given in parameters encoded with the specific method for that TextEncoder object. 1293 * 1294 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode) 1295 */ 1296 encode(input?: string): Uint8Array; 1297 /** 1298 * The **`TextEncoder.encodeInto()`** method takes a string to encode and a destination Uint8Array to put resulting UTF-8 encoded text into, and returns a dictionary object indicating the progress of the encoding. 1299 * 1300 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto) 1301 */ 1302 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult; 1303 get encoding(): string; 1304 } 1305 interface TextDecoderConstructorOptions { 1306 fatal: boolean; 1307 ignoreBOM: boolean; 1308 } 1309 interface TextDecoderDecodeOptions { 1310 stream: boolean; 1311 } 1312 interface TextEncoderEncodeIntoResult { 1313 read: number; 1314 written: number; 1315 } 1316 /** 1317 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files. 1318 * 1319 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent) 1320 */ 1321 declare class ErrorEvent extends Event { 1322 constructor(type: string, init?: ErrorEventErrorEventInit); 1323 /** 1324 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred. 1325 * 1326 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename) 1327 */ 1328 get filename(): string; 1329 /** 1330 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem. 1331 * 1332 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message) 1333 */ 1334 get message(): string; 1335 /** 1336 * 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. 1337 * 1338 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno) 1339 */ 1340 get lineno(): number; 1341 /** 1342 * 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. 1343 * 1344 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno) 1345 */ 1346 get colno(): number; 1347 /** 1348 * 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. 1349 * 1350 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error) 1351 */ 1352 get error(): any; 1353 } 1354 interface ErrorEventErrorEventInit { 1355 message?: string; 1356 filename?: string; 1357 lineno?: number; 1358 colno?: number; 1359 error?: any; 1360 } 1361 /** 1362 * The **`MessageEvent`** interface represents a message received by a target object. 1363 * 1364 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent) 1365 */ 1366 declare class MessageEvent extends Event { 1367 constructor(type: string, initializer: MessageEventInit); 1368 /** 1369 * The **`data`** read-only property of the The data sent by the message emitter; this can be any data type, depending on what originated this event. 1370 * 1371 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data) 1372 */ 1373 readonly data: any; 1374 /** 1375 * The **`origin`** read-only property of the origin of the message emitter. 1376 * 1377 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin) 1378 */ 1379 readonly origin: string | null; 1380 /** 1381 * The **`lastEventId`** read-only property of the unique ID for the event. 1382 * 1383 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId) 1384 */ 1385 readonly lastEventId: string; 1386 /** 1387 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter. 1388 * 1389 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source) 1390 */ 1391 readonly source: MessagePort | null; 1392 /** 1393 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order. 1394 * 1395 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports) 1396 */ 1397 readonly ports: MessagePort[]; 1398 } 1399 interface MessageEventInit { 1400 data: ArrayBuffer | string; 1401 } 1402 /** 1403 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected. 1404 * 1405 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent) 1406 */ 1407 declare abstract class PromiseRejectionEvent extends Event { 1408 /** 1409 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected. 1410 * 1411 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise) 1412 */ 1413 readonly promise: Promise<any>; 1414 /** 1415 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject(). 1416 * 1417 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason) 1418 */ 1419 readonly reason: any; 1420 } 1421 /** 1422 * 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 Window/fetch, XMLHttpRequest.send() or navigator.sendBeacon() methods. 1423 * 1424 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData) 1425 */ 1426 declare class FormData { 1427 constructor(); 1428 /** 1429 * 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. 1430 * 1431 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) 1432 */ 1433 append(name: string, value: string | Blob): void; 1434 /** 1435 * 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. 1436 * 1437 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) 1438 */ 1439 append(name: string, value: string): void; 1440 /** 1441 * 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. 1442 * 1443 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append) 1444 */ 1445 append(name: string, value: Blob, filename?: string): void; 1446 /** 1447 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object. 1448 * 1449 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete) 1450 */ 1451 delete(name: string): void; 1452 /** 1453 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object. 1454 * 1455 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get) 1456 */ 1457 get(name: string): (File | string) | null; 1458 /** 1459 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object. 1460 * 1461 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll) 1462 */ 1463 getAll(name: string): (File | string)[]; 1464 /** 1465 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key. 1466 * 1467 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has) 1468 */ 1469 has(name: string): boolean; 1470 /** 1471 * 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. 1472 * 1473 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) 1474 */ 1475 set(name: string, value: string | Blob): void; 1476 /** 1477 * 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. 1478 * 1479 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) 1480 */ 1481 set(name: string, value: string): void; 1482 /** 1483 * 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. 1484 * 1485 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set) 1486 */ 1487 set(name: string, value: Blob, filename?: string): void; 1488 /* Returns an array of key, value pairs for every entry in the list. */ 1489 entries(): IterableIterator<[ 1490 key: string, 1491 value: File | string 1492 ]>; 1493 /* Returns a list of keys in the list. */ 1494 keys(): IterableIterator<string>; 1495 /* Returns a list of values in the list. */ 1496 values(): IterableIterator<(File | string)>; 1497 forEach<This = unknown>(callback: (this: This, value: File | string, key: string, parent: FormData) => void, thisArg?: This): void; 1498 [Symbol.iterator](): IterableIterator<[ 1499 key: string, 1500 value: File | string 1501 ]>; 1502 } 1503 interface ContentOptions { 1504 html?: boolean; 1505 } 1506 declare class HTMLRewriter { 1507 constructor(); 1508 on(selector: string, handlers: HTMLRewriterElementContentHandlers): HTMLRewriter; 1509 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter; 1510 transform(response: Response): Response; 1511 } 1512 interface HTMLRewriterElementContentHandlers { 1513 element?(element: Element): void | Promise<void>; 1514 comments?(comment: Comment): void | Promise<void>; 1515 text?(element: Text): void | Promise<void>; 1516 } 1517 interface HTMLRewriterDocumentContentHandlers { 1518 doctype?(doctype: Doctype): void | Promise<void>; 1519 comments?(comment: Comment): void | Promise<void>; 1520 text?(text: Text): void | Promise<void>; 1521 end?(end: DocumentEnd): void | Promise<void>; 1522 } 1523 interface Doctype { 1524 readonly name: string | null; 1525 readonly publicId: string | null; 1526 readonly systemId: string | null; 1527 } 1528 interface Element { 1529 tagName: string; 1530 readonly attributes: IterableIterator<string[]>; 1531 readonly removed: boolean; 1532 readonly namespaceURI: string; 1533 getAttribute(name: string): string | null; 1534 hasAttribute(name: string): boolean; 1535 setAttribute(name: string, value: string): Element; 1536 removeAttribute(name: string): Element; 1537 before(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1538 after(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1539 prepend(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1540 append(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1541 replace(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1542 remove(): Element; 1543 removeAndKeepContent(): Element; 1544 setInnerContent(content: string | ReadableStream | Response, options?: ContentOptions): Element; 1545 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void; 1546 } 1547 interface EndTag { 1548 name: string; 1549 before(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; 1550 after(content: string | ReadableStream | Response, options?: ContentOptions): EndTag; 1551 remove(): EndTag; 1552 } 1553 interface Comment { 1554 text: string; 1555 readonly removed: boolean; 1556 before(content: string, options?: ContentOptions): Comment; 1557 after(content: string, options?: ContentOptions): Comment; 1558 replace(content: string, options?: ContentOptions): Comment; 1559 remove(): Comment; 1560 } 1561 interface Text { 1562 readonly text: string; 1563 readonly lastInTextNode: boolean; 1564 readonly removed: boolean; 1565 before(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1566 after(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1567 replace(content: string | ReadableStream | Response, options?: ContentOptions): Text; 1568 remove(): Text; 1569 } 1570 interface DocumentEnd { 1571 append(content: string, options?: ContentOptions): DocumentEnd; 1572 } 1573 /** 1574 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope. 1575 * 1576 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent) 1577 */ 1578 declare abstract class FetchEvent extends ExtendableEvent { 1579 /** 1580 * The **`request`** read-only property of the the event handler. 1581 * 1582 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request) 1583 */ 1584 readonly request: Request; 1585 /** 1586 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself. 1587 * 1588 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith) 1589 */ 1590 respondWith(promise: Response | Promise<Response>): void; 1591 passThroughOnException(): void; 1592 } 1593 type HeadersInit = Headers | Iterable<Iterable<string>> | Record<string, string>; 1594 /** 1595 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers. 1596 * 1597 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers) 1598 */ 1599 declare class Headers { 1600 constructor(init?: HeadersInit); 1601 /** 1602 * 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. 1603 * 1604 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get) 1605 */ 1606 get(name: string): string | null; 1607 getAll(name: string): string[]; 1608 /** 1609 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response. 1610 * 1611 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie) 1612 */ 1613 getSetCookie(): string[]; 1614 /** 1615 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header. 1616 * 1617 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has) 1618 */ 1619 has(name: string): boolean; 1620 /** 1621 * 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. 1622 * 1623 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set) 1624 */ 1625 set(name: string, value: string): void; 1626 /** 1627 * 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. 1628 * 1629 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append) 1630 */ 1631 append(name: string, value: string): void; 1632 /** 1633 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object. 1634 * 1635 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete) 1636 */ 1637 delete(name: string): void; 1638 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: Headers) => void, thisArg?: This): void; 1639 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */ 1640 entries(): IterableIterator<[ 1641 key: string, 1642 value: string 1643 ]>; 1644 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */ 1645 keys(): IterableIterator<string>; 1646 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */ 1647 values(): IterableIterator<string>; 1648 [Symbol.iterator](): IterableIterator<[ 1649 key: string, 1650 value: string 1651 ]>; 1652 } 1653 type BodyInit = ReadableStream<Uint8Array> | string | ArrayBuffer | ArrayBufferView | Blob | URLSearchParams | FormData | Iterable<ArrayBuffer | ArrayBufferView> | AsyncIterable<ArrayBuffer | ArrayBufferView>; 1654 declare abstract class Body { 1655 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */ 1656 get body(): ReadableStream | null; 1657 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */ 1658 get bodyUsed(): boolean; 1659 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */ 1660 arrayBuffer(): Promise<ArrayBuffer>; 1661 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */ 1662 bytes(): Promise<Uint8Array>; 1663 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */ 1664 text(): Promise<string>; 1665 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */ 1666 json<T>(): Promise<T>; 1667 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */ 1668 formData(): Promise<FormData>; 1669 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */ 1670 blob(): Promise<Blob>; 1671 } 1672 /** 1673 * The **`Response`** interface of the Fetch API represents the response to a request. 1674 * 1675 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) 1676 */ 1677 declare var Response: { 1678 prototype: Response; 1679 new (body?: BodyInit | null, init?: ResponseInit): Response; 1680 error(): Response; 1681 redirect(url: string, status?: number): Response; 1682 json(any: any, maybeInit?: (ResponseInit | Response)): Response; 1683 }; 1684 /** 1685 * The **`Response`** interface of the Fetch API represents the response to a request. 1686 * 1687 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response) 1688 */ 1689 interface Response extends Body { 1690 /** 1691 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable. 1692 * 1693 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) 1694 */ 1695 clone(): Response; 1696 /** 1697 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response. 1698 * 1699 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) 1700 */ 1701 status: number; 1702 /** 1703 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status. 1704 * 1705 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) 1706 */ 1707 statusText: string; 1708 /** 1709 * The **`headers`** read-only property of the with the response. 1710 * 1711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) 1712 */ 1713 headers: Headers; 1714 /** 1715 * 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. 1716 * 1717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) 1718 */ 1719 ok: boolean; 1720 /** 1721 * 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. 1722 * 1723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) 1724 */ 1725 redirected: boolean; 1726 /** 1727 * The **`url`** read-only property of the Response interface contains the URL of the response. 1728 * 1729 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) 1730 */ 1731 url: string; 1732 webSocket: WebSocket | null; 1733 cf: any | undefined; 1734 /** 1735 * The **`type`** read-only property of the Response interface contains the type of the response. 1736 * 1737 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type) 1738 */ 1739 type: "default" | "error"; 1740 } 1741 interface ResponseInit { 1742 status?: number; 1743 statusText?: string; 1744 headers?: HeadersInit; 1745 cf?: any; 1746 webSocket?: (WebSocket | null); 1747 encodeBody?: "automatic" | "manual"; 1748 } 1749 type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> = Request<CfHostMetadata, Cf> | string; 1750 /** 1751 * The **`Request`** interface of the Fetch API represents a resource request. 1752 * 1753 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request) 1754 */ 1755 declare var Request: { 1756 prototype: Request; 1757 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(input: RequestInfo<CfProperties> | URL, init?: RequestInit<Cf>): Request<CfHostMetadata, Cf>; 1758 }; 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 */ 1764 interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> extends Body { 1765 /** 1766 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object. 1767 * 1768 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) 1769 */ 1770 clone(): Request<CfHostMetadata, Cf>; 1771 /** 1772 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request. 1773 * 1774 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method) 1775 */ 1776 method: string; 1777 /** 1778 * The **`url`** read-only property of the Request interface contains the URL of the request. 1779 * 1780 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url) 1781 */ 1782 url: string; 1783 /** 1784 * The **`headers`** read-only property of the with the request. 1785 * 1786 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers) 1787 */ 1788 headers: Headers; 1789 /** 1790 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled. 1791 * 1792 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect) 1793 */ 1794 redirect: string; 1795 fetcher: Fetcher | null; 1796 /** 1797 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request. 1798 * 1799 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal) 1800 */ 1801 signal: AbortSignal; 1802 cf?: Cf; 1803 /** 1804 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request. 1805 * 1806 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity) 1807 */ 1808 integrity: string; 1809 /** 1810 * 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. 1811 * 1812 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive) 1813 */ 1814 keepalive: boolean; 1815 /** 1816 * The **`cache`** read-only property of the Request interface contains the cache mode of the request. 1817 * 1818 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache) 1819 */ 1820 cache?: "no-store" | "no-cache"; 1821 } 1822 interface RequestInit<Cf = CfProperties> { 1823 /* A string to set request's method. */ 1824 method?: string; 1825 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */ 1826 headers?: HeadersInit; 1827 /* A BodyInit object or null to set request's body. */ 1828 body?: BodyInit | null; 1829 /* 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. */ 1830 redirect?: string; 1831 fetcher?: (Fetcher | null); 1832 cf?: Cf; 1833 /* A string indicating how the request will interact with the browser's cache to set request's cache. */ 1834 cache?: "no-store" | "no-cache"; 1835 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */ 1836 integrity?: string; 1837 /* An AbortSignal to set request's signal. */ 1838 signal?: (AbortSignal | null); 1839 encodeResponseBody?: "automatic" | "manual"; 1840 } 1841 type 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>; 1842 type Fetcher<T extends Rpc.EntrypointBranded | undefined = undefined, Reserved extends string = never> = (T extends Rpc.EntrypointBranded ? Rpc.Provider<T, Reserved | "fetch" | "connect"> : unknown) & { 1843 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; 1844 connect(address: SocketAddress | string, options?: SocketOptions): Socket; 1845 }; 1846 interface KVNamespaceListKey<Metadata, Key extends string = string> { 1847 name: Key; 1848 expiration?: number; 1849 metadata?: Metadata; 1850 } 1851 type KVNamespaceListResult<Metadata, Key extends string = string> = { 1852 list_complete: false; 1853 keys: KVNamespaceListKey<Metadata, Key>[]; 1854 cursor: string; 1855 cacheStatus: string | null; 1856 } | { 1857 list_complete: true; 1858 keys: KVNamespaceListKey<Metadata, Key>[]; 1859 cacheStatus: string | null; 1860 }; 1861 interface KVNamespace<Key extends string = string> { 1862 get(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<string | null>; 1863 get(key: Key, type: "text"): Promise<string | null>; 1864 get<ExpectedValue = unknown>(key: Key, type: "json"): Promise<ExpectedValue | null>; 1865 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>; 1866 get(key: Key, type: "stream"): Promise<ReadableStream | null>; 1867 get(key: Key, options?: KVNamespaceGetOptions<"text">): Promise<string | null>; 1868 get<ExpectedValue = unknown>(key: Key, options?: KVNamespaceGetOptions<"json">): Promise<ExpectedValue | null>; 1869 get(key: Key, options?: KVNamespaceGetOptions<"arrayBuffer">): Promise<ArrayBuffer | null>; 1870 get(key: Key, options?: KVNamespaceGetOptions<"stream">): Promise<ReadableStream | null>; 1871 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>; 1872 get<ExpectedValue = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, ExpectedValue | null>>; 1873 get(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, string | null>>; 1874 get(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, string | null>>; 1875 get<ExpectedValue = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, ExpectedValue | null>>; 1876 list<Metadata = unknown>(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult<Metadata, Key>>; 1877 put(key: Key, value: string | ArrayBuffer | ArrayBufferView | ReadableStream, options?: KVNamespacePutOptions): Promise<void>; 1878 getWithMetadata<Metadata = unknown>(key: Key, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1879 getWithMetadata<Metadata = unknown>(key: Key, type: "text"): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1880 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, type: "json"): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>; 1881 getWithMetadata<Metadata = unknown>(key: Key, type: "arrayBuffer"): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>; 1882 getWithMetadata<Metadata = unknown>(key: Key, type: "stream"): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>; 1883 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"text">): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>; 1884 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"json">): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>; 1885 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"arrayBuffer">): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>; 1886 getWithMetadata<Metadata = unknown>(key: Key, options: KVNamespaceGetOptions<"stream">): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>; 1887 getWithMetadata<Metadata = unknown>(key: Array<Key>, type: "text"): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1888 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, type: "json"): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>; 1889 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: Partial<KVNamespaceGetOptions<undefined>>): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1890 getWithMetadata<Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"text">): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>; 1891 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(key: Array<Key>, options?: KVNamespaceGetOptions<"json">): Promise<Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>>; 1892 delete(key: Key): Promise<void>; 1893 } 1894 interface KVNamespaceListOptions { 1895 limit?: number; 1896 prefix?: (string | null); 1897 cursor?: (string | null); 1898 } 1899 interface KVNamespaceGetOptions<Type> { 1900 type: Type; 1901 cacheTtl?: number; 1902 } 1903 interface KVNamespacePutOptions { 1904 expiration?: number; 1905 expirationTtl?: number; 1906 metadata?: (any | null); 1907 } 1908 interface KVNamespaceGetWithMetadataResult<Value, Metadata> { 1909 value: Value | null; 1910 metadata: Metadata | null; 1911 cacheStatus: string | null; 1912 } 1913 type QueueContentType = "text" | "bytes" | "json" | "v8"; 1914 interface Queue<Body = unknown> { 1915 metrics(): Promise<QueueMetrics>; 1916 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>; 1917 sendBatch(messages: Iterable<MessageSendRequest<Body>>, options?: QueueSendBatchOptions): Promise<QueueSendBatchResponse>; 1918 } 1919 interface QueueSendMetrics { 1920 backlogCount: number; 1921 backlogBytes: number; 1922 oldestMessageTimestamp?: Date; 1923 } 1924 interface QueueSendMetadata { 1925 metrics: QueueSendMetrics; 1926 } 1927 interface QueueSendResponse { 1928 metadata: QueueSendMetadata; 1929 } 1930 interface QueueSendBatchMetrics { 1931 backlogCount: number; 1932 backlogBytes: number; 1933 oldestMessageTimestamp?: Date; 1934 } 1935 interface QueueSendBatchMetadata { 1936 metrics: QueueSendBatchMetrics; 1937 } 1938 interface QueueSendBatchResponse { 1939 metadata: QueueSendBatchMetadata; 1940 } 1941 interface QueueSendOptions { 1942 contentType?: QueueContentType; 1943 delaySeconds?: number; 1944 } 1945 interface QueueSendBatchOptions { 1946 delaySeconds?: number; 1947 } 1948 interface MessageSendRequest<Body = unknown> { 1949 body: Body; 1950 contentType?: QueueContentType; 1951 delaySeconds?: number; 1952 } 1953 interface QueueMetrics { 1954 backlogCount: number; 1955 backlogBytes: number; 1956 oldestMessageTimestamp?: Date; 1957 } 1958 interface MessageBatchMetrics { 1959 backlogCount: number; 1960 backlogBytes: number; 1961 oldestMessageTimestamp?: Date; 1962 } 1963 interface MessageBatchMetadata { 1964 metrics: MessageBatchMetrics; 1965 } 1966 interface QueueRetryOptions { 1967 delaySeconds?: number; 1968 } 1969 interface Message<Body = unknown> { 1970 readonly id: string; 1971 readonly timestamp: Date; 1972 readonly body: Body; 1973 readonly attempts: number; 1974 retry(options?: QueueRetryOptions): void; 1975 ack(): void; 1976 } 1977 interface QueueEvent<Body = unknown> extends ExtendableEvent { 1978 readonly messages: readonly Message<Body>[]; 1979 readonly queue: string; 1980 readonly metadata: MessageBatchMetadata; 1981 retryAll(options?: QueueRetryOptions): void; 1982 ackAll(): void; 1983 } 1984 interface MessageBatch<Body = unknown> { 1985 readonly messages: readonly Message<Body>[]; 1986 readonly queue: string; 1987 readonly metadata: MessageBatchMetadata; 1988 retryAll(options?: QueueRetryOptions): void; 1989 ackAll(): void; 1990 } 1991 interface R2Error extends Error { 1992 readonly name: string; 1993 readonly code: number; 1994 readonly message: string; 1995 readonly action: string; 1996 readonly stack: any; 1997 } 1998 interface R2ListOptions { 1999 limit?: number; 2000 prefix?: string; 2001 cursor?: string; 2002 delimiter?: string; 2003 startAfter?: string; 2004 include?: ("httpMetadata" | "customMetadata")[]; 2005 } 2006 interface R2Bucket { 2007 head(key: string): Promise<R2Object | null>; 2008 get(key: string, options: R2GetOptions & { 2009 onlyIf: R2Conditional | Headers; 2010 }): Promise<R2ObjectBody | R2Object | null>; 2011 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>; 2012 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions & { 2013 onlyIf: R2Conditional | Headers; 2014 }): Promise<R2Object | null>; 2015 put(key: string, value: ReadableStream | ArrayBuffer | ArrayBufferView | string | null | Blob, options?: R2PutOptions): Promise<R2Object>; 2016 createMultipartUpload(key: string, options?: R2MultipartOptions): Promise<R2MultipartUpload>; 2017 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload; 2018 delete(keys: string | string[]): Promise<void>; 2019 list(options?: R2ListOptions): Promise<R2Objects>; 2020 } 2021 interface R2MultipartUpload { 2022 readonly key: string; 2023 readonly uploadId: string; 2024 uploadPart(partNumber: number, value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob, options?: R2UploadPartOptions): Promise<R2UploadedPart>; 2025 abort(): Promise<void>; 2026 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>; 2027 } 2028 interface R2UploadedPart { 2029 partNumber: number; 2030 etag: string; 2031 } 2032 declare abstract class R2Object { 2033 readonly key: string; 2034 readonly version: string; 2035 readonly size: number; 2036 readonly etag: string; 2037 readonly httpEtag: string; 2038 readonly checksums: R2Checksums; 2039 readonly uploaded: Date; 2040 readonly httpMetadata?: R2HTTPMetadata; 2041 readonly customMetadata?: Record<string, string>; 2042 readonly range?: R2Range; 2043 readonly storageClass: string; 2044 readonly ssecKeyMd5?: string; 2045 writeHttpMetadata(headers: Headers): void; 2046 } 2047 interface R2ObjectBody extends R2Object { 2048 get body(): ReadableStream; 2049 get bodyUsed(): boolean; 2050 arrayBuffer(): Promise<ArrayBuffer>; 2051 bytes(): Promise<Uint8Array>; 2052 text(): Promise<string>; 2053 json<T>(): Promise<T>; 2054 blob(): Promise<Blob>; 2055 } 2056 type R2Range = { 2057 offset: number; 2058 length?: number; 2059 } | { 2060 offset?: number; 2061 length: number; 2062 } | { 2063 suffix: number; 2064 }; 2065 interface R2Conditional { 2066 etagMatches?: string; 2067 etagDoesNotMatch?: string; 2068 uploadedBefore?: Date; 2069 uploadedAfter?: Date; 2070 secondsGranularity?: boolean; 2071 } 2072 interface R2GetOptions { 2073 onlyIf?: (R2Conditional | Headers); 2074 range?: (R2Range | Headers); 2075 ssecKey?: (ArrayBuffer | string); 2076 } 2077 interface R2PutOptions { 2078 onlyIf?: (R2Conditional | Headers); 2079 httpMetadata?: (R2HTTPMetadata | Headers); 2080 customMetadata?: Record<string, string>; 2081 md5?: ((ArrayBuffer | ArrayBufferView) | string); 2082 sha1?: ((ArrayBuffer | ArrayBufferView) | string); 2083 sha256?: ((ArrayBuffer | ArrayBufferView) | string); 2084 sha384?: ((ArrayBuffer | ArrayBufferView) | string); 2085 sha512?: ((ArrayBuffer | ArrayBufferView) | string); 2086 storageClass?: string; 2087 ssecKey?: (ArrayBuffer | string); 2088 } 2089 interface R2MultipartOptions { 2090 httpMetadata?: (R2HTTPMetadata | Headers); 2091 customMetadata?: Record<string, string>; 2092 storageClass?: string; 2093 ssecKey?: (ArrayBuffer | string); 2094 } 2095 interface R2Checksums { 2096 readonly md5?: ArrayBuffer; 2097 readonly sha1?: ArrayBuffer; 2098 readonly sha256?: ArrayBuffer; 2099 readonly sha384?: ArrayBuffer; 2100 readonly sha512?: ArrayBuffer; 2101 toJSON(): R2StringChecksums; 2102 } 2103 interface R2StringChecksums { 2104 md5?: string; 2105 sha1?: string; 2106 sha256?: string; 2107 sha384?: string; 2108 sha512?: string; 2109 } 2110 interface R2HTTPMetadata { 2111 contentType?: string; 2112 contentLanguage?: string; 2113 contentDisposition?: string; 2114 contentEncoding?: string; 2115 cacheControl?: string; 2116 cacheExpiry?: Date; 2117 } 2118 type R2Objects = { 2119 objects: R2Object[]; 2120 delimitedPrefixes: string[]; 2121 } & ({ 2122 truncated: true; 2123 cursor: string; 2124 } | { 2125 truncated: false; 2126 }); 2127 interface R2UploadPartOptions { 2128 ssecKey?: (ArrayBuffer | string); 2129 } 2130 declare abstract class ScheduledEvent extends ExtendableEvent { 2131 readonly scheduledTime: number; 2132 readonly cron: string; 2133 noRetry(): void; 2134 } 2135 interface ScheduledController { 2136 readonly scheduledTime: number; 2137 readonly cron: string; 2138 noRetry(): void; 2139 } 2140 interface QueuingStrategy<T = any> { 2141 highWaterMark?: (number | bigint); 2142 size?: (chunk: T) => number | bigint; 2143 } 2144 interface UnderlyingSink<W = any> { 2145 type?: string; 2146 start?: (controller: WritableStreamDefaultController) => void | Promise<void>; 2147 write?: (chunk: W, controller: WritableStreamDefaultController) => void | Promise<void>; 2148 abort?: (reason: any) => void | Promise<void>; 2149 close?: () => void | Promise<void>; 2150 } 2151 interface UnderlyingByteSource { 2152 type: "bytes"; 2153 autoAllocateChunkSize?: number; 2154 start?: (controller: ReadableByteStreamController) => void | Promise<void>; 2155 pull?: (controller: ReadableByteStreamController) => void | Promise<void>; 2156 cancel?: (reason: any) => void | Promise<void>; 2157 } 2158 interface UnderlyingSource<R = any> { 2159 type?: "" | undefined; 2160 start?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>; 2161 pull?: (controller: ReadableStreamDefaultController<R>) => void | Promise<void>; 2162 cancel?: (reason: any) => void | Promise<void>; 2163 expectedLength?: (number | bigint); 2164 } 2165 interface Transformer<I = any, O = any> { 2166 readableType?: string; 2167 writableType?: string; 2168 start?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>; 2169 transform?: (chunk: I, controller: TransformStreamDefaultController<O>) => void | Promise<void>; 2170 flush?: (controller: TransformStreamDefaultController<O>) => void | Promise<void>; 2171 cancel?: (reason: any) => void | Promise<void>; 2172 expectedLength?: number; 2173 } 2174 interface StreamPipeOptions { 2175 preventAbort?: boolean; 2176 preventCancel?: boolean; 2177 /** 2178 * 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. 2179 * 2180 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. 2181 * 2182 * Errors and closures of the source and destination streams propagate as follows: 2183 * 2184 * 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. 2185 * 2186 * 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. 2187 * 2188 * 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. 2189 * 2190 * 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. 2191 * 2192 * 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. 2193 */ 2194 preventClose?: boolean; 2195 signal?: AbortSignal; 2196 } 2197 type ReadableStreamReadResult<R = any> = { 2198 done: false; 2199 value: R; 2200 } | { 2201 done: true; 2202 value?: undefined; 2203 }; 2204 /** 2205 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data. 2206 * 2207 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) 2208 */ 2209 interface ReadableStream<R = any> { 2210 /** 2211 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader. 2212 * 2213 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked) 2214 */ 2215 get locked(): boolean; 2216 /** 2217 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled. 2218 * 2219 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel) 2220 */ 2221 cancel(reason?: any): Promise<void>; 2222 /** 2223 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. 2224 * 2225 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) 2226 */ 2227 getReader(): ReadableStreamDefaultReader<R>; 2228 /** 2229 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it. 2230 * 2231 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader) 2232 */ 2233 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader; 2234 /** 2235 * 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. 2236 * 2237 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough) 2238 */ 2239 pipeThrough<T>(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>; 2240 /** 2241 * 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. 2242 * 2243 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo) 2244 */ 2245 pipeTo(destination: WritableStream<R>, options?: StreamPipeOptions): Promise<void>; 2246 /** 2247 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances. 2248 * 2249 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee) 2250 */ 2251 tee(): [ 2252 ReadableStream<R>, 2253 ReadableStream<R> 2254 ]; 2255 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>; 2256 [Symbol.asyncIterator](options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>; 2257 } 2258 /** 2259 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data. 2260 * 2261 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream) 2262 */ 2263 declare const ReadableStream: { 2264 prototype: ReadableStream; 2265 new (underlyingSource: UnderlyingByteSource, strategy?: QueuingStrategy<Uint8Array>): ReadableStream<Uint8Array>; 2266 new <R = any>(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>): ReadableStream<R>; 2267 }; 2268 /** 2269 * 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). 2270 * 2271 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader) 2272 */ 2273 declare class ReadableStreamDefaultReader<R = any> { 2274 constructor(stream: ReadableStream); 2275 get closed(): Promise<void>; 2276 cancel(reason?: any): Promise<void>; 2277 /** 2278 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue. 2279 * 2280 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read) 2281 */ 2282 read(): Promise<ReadableStreamReadResult<R>>; 2283 /** 2284 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream. 2285 * 2286 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock) 2287 */ 2288 releaseLock(): void; 2289 } 2290 /** 2291 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source. 2292 * 2293 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader) 2294 */ 2295 declare class ReadableStreamBYOBReader { 2296 constructor(stream: ReadableStream); 2297 get closed(): Promise<void>; 2298 cancel(reason?: any): Promise<void>; 2299 /** 2300 * 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. 2301 * 2302 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read) 2303 */ 2304 read<T extends ArrayBufferView>(view: T): Promise<ReadableStreamReadResult<T>>; 2305 /** 2306 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream. 2307 * 2308 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock) 2309 */ 2310 releaseLock(): void; 2311 readAtLeast<T extends ArrayBufferView>(minElements: number, view: T): Promise<ReadableStreamReadResult<T>>; 2312 } 2313 interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions { 2314 min?: number; 2315 } 2316 interface ReadableStreamGetReaderOptions { 2317 /** 2318 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader. 2319 * 2320 * 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. 2321 */ 2322 mode: "byob"; 2323 } 2324 /** 2325 * 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). 2326 * 2327 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest) 2328 */ 2329 declare abstract class ReadableStreamBYOBRequest { 2330 /** 2331 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view. 2332 * 2333 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view) 2334 */ 2335 get view(): Uint8Array | null; 2336 /** 2337 * 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. 2338 * 2339 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond) 2340 */ 2341 respond(bytesWritten: number): void; 2342 /** 2343 * 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. 2344 * 2345 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView) 2346 */ 2347 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void; 2348 get atLeast(): number | null; 2349 } 2350 /** 2351 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue. 2352 * 2353 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController) 2354 */ 2355 declare abstract class ReadableStreamDefaultController<R = any> { 2356 /** 2357 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue. 2358 * 2359 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize) 2360 */ 2361 get desiredSize(): number | null; 2362 /** 2363 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream. 2364 * 2365 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close) 2366 */ 2367 close(): void; 2368 /** 2369 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue. 2370 * 2371 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue) 2372 */ 2373 enqueue(chunk?: R): void; 2374 /** 2375 * The **`error()`** method of the with the associated stream to error. 2376 * 2377 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error) 2378 */ 2379 error(reason: any): void; 2380 } 2381 /** 2382 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream. 2383 * 2384 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController) 2385 */ 2386 declare abstract class ReadableByteStreamController { 2387 /** 2388 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests. 2389 * 2390 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest) 2391 */ 2392 get byobRequest(): ReadableStreamBYOBRequest | null; 2393 /** 2394 * 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'. 2395 * 2396 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize) 2397 */ 2398 get desiredSize(): number | null; 2399 /** 2400 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream. 2401 * 2402 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close) 2403 */ 2404 close(): void; 2405 /** 2406 * The **`enqueue()`** method of the ReadableByteStreamController interface enqueues a given chunk on the associated readable byte stream (the chunk is copied into the stream's internal queues). 2407 * 2408 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue) 2409 */ 2410 enqueue(chunk: ArrayBuffer | ArrayBufferView): void; 2411 /** 2412 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason. 2413 * 2414 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error) 2415 */ 2416 error(reason: any): void; 2417 } 2418 /** 2419 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state. 2420 * 2421 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController) 2422 */ 2423 declare abstract class WritableStreamDefaultController { 2424 /** 2425 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller. 2426 * 2427 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal) 2428 */ 2429 get signal(): AbortSignal; 2430 /** 2431 * The **`error()`** method of the with the associated stream to error. 2432 * 2433 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error) 2434 */ 2435 error(reason?: any): void; 2436 } 2437 /** 2438 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream. 2439 * 2440 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController) 2441 */ 2442 declare abstract class TransformStreamDefaultController<O = any> { 2443 /** 2444 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream. 2445 * 2446 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize) 2447 */ 2448 get desiredSize(): number | null; 2449 /** 2450 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream. 2451 * 2452 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue) 2453 */ 2454 enqueue(chunk?: O): void; 2455 /** 2456 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream. 2457 * 2458 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error) 2459 */ 2460 error(reason: any): void; 2461 /** 2462 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream. 2463 * 2464 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate) 2465 */ 2466 terminate(): void; 2467 } 2468 interface ReadableWritablePair<R = any, W = any> { 2469 readable: ReadableStream<R>; 2470 /** 2471 * 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. 2472 * 2473 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. 2474 */ 2475 writable: WritableStream<W>; 2476 } 2477 /** 2478 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink. 2479 * 2480 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream) 2481 */ 2482 declare class WritableStream<W = any> { 2483 constructor(underlyingSink?: UnderlyingSink, queuingStrategy?: QueuingStrategy); 2484 /** 2485 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer. 2486 * 2487 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked) 2488 */ 2489 get locked(): boolean; 2490 /** 2491 * 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. 2492 * 2493 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort) 2494 */ 2495 abort(reason?: any): Promise<void>; 2496 /** 2497 * The **`close()`** method of the WritableStream interface closes the associated stream. 2498 * 2499 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close) 2500 */ 2501 close(): Promise<void>; 2502 /** 2503 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance. 2504 * 2505 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter) 2506 */ 2507 getWriter(): WritableStreamDefaultWriter<W>; 2508 } 2509 /** 2510 * 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. 2511 * 2512 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter) 2513 */ 2514 declare class WritableStreamDefaultWriter<W = any> { 2515 constructor(stream: WritableStream); 2516 /** 2517 * The **`closed`** read-only property of the the stream errors or the writer's lock is released. 2518 * 2519 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed) 2520 */ 2521 get closed(): Promise<void>; 2522 /** 2523 * The **`ready`** read-only property of the 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. 2524 * 2525 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready) 2526 */ 2527 get ready(): Promise<void>; 2528 /** 2529 * The **`desiredSize`** read-only property of the to fill the stream's internal queue. 2530 * 2531 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize) 2532 */ 2533 get desiredSize(): number | null; 2534 /** 2535 * The **`abort()`** method of the 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. 2536 * 2537 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort) 2538 */ 2539 abort(reason?: any): Promise<void>; 2540 /** 2541 * The **`close()`** method of the stream. 2542 * 2543 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close) 2544 */ 2545 close(): Promise<void>; 2546 /** 2547 * The **`write()`** method of the operation. 2548 * 2549 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write) 2550 */ 2551 write(chunk?: W): Promise<void>; 2552 /** 2553 * The **`releaseLock()`** method of the corresponding stream. 2554 * 2555 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock) 2556 */ 2557 releaseLock(): void; 2558 } 2559 /** 2560 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept. 2561 * 2562 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream) 2563 */ 2564 declare class TransformStream<I = any, O = any> { 2565 constructor(transformer?: Transformer<I, O>, writableStrategy?: QueuingStrategy<I>, readableStrategy?: QueuingStrategy<O>); 2566 /** 2567 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`. 2568 * 2569 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable) 2570 */ 2571 get readable(): ReadableStream<O>; 2572 /** 2573 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`. 2574 * 2575 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable) 2576 */ 2577 get writable(): WritableStream<I>; 2578 } 2579 declare class FixedLengthStream extends IdentityTransformStream { 2580 constructor(expectedLength: number | bigint, queuingStrategy?: IdentityTransformStreamQueuingStrategy); 2581 } 2582 declare class IdentityTransformStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 2583 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy); 2584 } 2585 interface IdentityTransformStreamQueuingStrategy { 2586 highWaterMark?: (number | bigint); 2587 } 2588 interface ReadableStreamValuesOptions { 2589 preventCancel?: boolean; 2590 } 2591 /** 2592 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data. 2593 * 2594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream) 2595 */ 2596 declare class CompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 2597 constructor(format: "gzip" | "deflate" | "deflate-raw"); 2598 } 2599 /** 2600 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data. 2601 * 2602 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream) 2603 */ 2604 declare class DecompressionStream extends TransformStream<ArrayBuffer | ArrayBufferView, Uint8Array> { 2605 constructor(format: "gzip" | "deflate" | "deflate-raw"); 2606 } 2607 /** 2608 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding. 2609 * 2610 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream) 2611 */ 2612 declare class TextEncoderStream extends TransformStream<string, Uint8Array> { 2613 constructor(); 2614 get encoding(): string; 2615 } 2616 /** 2617 * 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. 2618 * 2619 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream) 2620 */ 2621 declare class TextDecoderStream extends TransformStream<ArrayBuffer | ArrayBufferView, string> { 2622 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit); 2623 get encoding(): string; 2624 get fatal(): boolean; 2625 get ignoreBOM(): boolean; 2626 } 2627 interface TextDecoderStreamTextDecoderStreamInit { 2628 fatal?: boolean; 2629 ignoreBOM?: boolean; 2630 } 2631 /** 2632 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams. 2633 * 2634 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy) 2635 */ 2636 declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> { 2637 constructor(init: QueuingStrategyInit); 2638 /** 2639 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied. 2640 * 2641 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark) 2642 */ 2643 get highWaterMark(): number; 2644 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */ 2645 get size(): (chunk?: any) => number; 2646 } 2647 /** 2648 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams. 2649 * 2650 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy) 2651 */ 2652 declare class CountQueuingStrategy implements QueuingStrategy { 2653 constructor(init: QueuingStrategyInit); 2654 /** 2655 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied. 2656 * 2657 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark) 2658 */ 2659 get highWaterMark(): number; 2660 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */ 2661 get size(): (chunk?: any) => number; 2662 } 2663 interface QueuingStrategyInit { 2664 /** 2665 * Creates a new ByteLengthQueuingStrategy with the provided high water mark. 2666 * 2667 * 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. 2668 */ 2669 highWaterMark: number; 2670 } 2671 interface TracePreviewInfo { 2672 id: string; 2673 slug: string; 2674 name: string; 2675 } 2676 interface ScriptVersion { 2677 id?: string; 2678 tag?: string; 2679 message?: string; 2680 } 2681 declare abstract class TailEvent extends ExtendableEvent { 2682 readonly events: TraceItem[]; 2683 readonly traces: TraceItem[]; 2684 } 2685 interface TraceItem { 2686 readonly event: (TraceItemFetchEventInfo | TraceItemJsRpcEventInfo | TraceItemConnectEventInfo | TraceItemScheduledEventInfo | TraceItemAlarmEventInfo | TraceItemQueueEventInfo | TraceItemEmailEventInfo | TraceItemTailEventInfo | TraceItemCustomEventInfo | TraceItemHibernatableWebSocketEventInfo) | null; 2687 readonly eventTimestamp: number | null; 2688 readonly logs: TraceLog[]; 2689 readonly exceptions: TraceException[]; 2690 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[]; 2691 readonly scriptName: string | null; 2692 readonly entrypoint?: string; 2693 readonly scriptVersion?: ScriptVersion; 2694 readonly dispatchNamespace?: string; 2695 readonly scriptTags?: string[]; 2696 readonly tailAttributes?: Record<string, boolean | number | string>; 2697 readonly preview?: TracePreviewInfo; 2698 readonly durableObjectId?: string; 2699 readonly outcome: string; 2700 readonly executionModel: string; 2701 readonly truncated: boolean; 2702 readonly cpuTime: number; 2703 readonly wallTime: number; 2704 } 2705 interface TraceItemAlarmEventInfo { 2706 readonly scheduledTime: Date; 2707 } 2708 interface TraceItemConnectEventInfo { 2709 } 2710 interface TraceItemCustomEventInfo { 2711 } 2712 interface TraceItemScheduledEventInfo { 2713 readonly scheduledTime: number; 2714 readonly cron: string; 2715 } 2716 interface TraceItemQueueEventInfo { 2717 readonly queue: string; 2718 readonly batchSize: number; 2719 } 2720 interface TraceItemEmailEventInfo { 2721 readonly mailFrom: string; 2722 readonly rcptTo: string; 2723 readonly rawSize: number; 2724 } 2725 interface TraceItemTailEventInfo { 2726 readonly consumedEvents: TraceItemTailEventInfoTailItem[]; 2727 } 2728 interface TraceItemTailEventInfoTailItem { 2729 readonly scriptName: string | null; 2730 } 2731 interface TraceItemFetchEventInfo { 2732 readonly response?: TraceItemFetchEventInfoResponse; 2733 readonly request: TraceItemFetchEventInfoRequest; 2734 } 2735 interface TraceItemFetchEventInfoRequest { 2736 readonly cf?: any; 2737 readonly headers: Record<string, string>; 2738 readonly method: string; 2739 readonly url: string; 2740 getUnredacted(): TraceItemFetchEventInfoRequest; 2741 } 2742 interface TraceItemFetchEventInfoResponse { 2743 readonly status: number; 2744 } 2745 interface TraceItemJsRpcEventInfo { 2746 readonly rpcMethod: string; 2747 } 2748 interface TraceItemHibernatableWebSocketEventInfo { 2749 readonly getWebSocketEvent: TraceItemHibernatableWebSocketEventInfoMessage | TraceItemHibernatableWebSocketEventInfoClose | TraceItemHibernatableWebSocketEventInfoError; 2750 } 2751 interface TraceItemHibernatableWebSocketEventInfoMessage { 2752 readonly webSocketEventType: string; 2753 } 2754 interface TraceItemHibernatableWebSocketEventInfoClose { 2755 readonly webSocketEventType: string; 2756 readonly code: number; 2757 readonly wasClean: boolean; 2758 } 2759 interface TraceItemHibernatableWebSocketEventInfoError { 2760 readonly webSocketEventType: string; 2761 } 2762 interface TraceLog { 2763 readonly timestamp: number; 2764 readonly level: string; 2765 readonly message: any; 2766 } 2767 interface TraceException { 2768 readonly timestamp: number; 2769 readonly message: string; 2770 readonly name: string; 2771 readonly stack?: string; 2772 } 2773 interface TraceDiagnosticChannelEvent { 2774 readonly timestamp: number; 2775 readonly channel: string; 2776 readonly message: any; 2777 } 2778 interface TraceMetrics { 2779 readonly cpuTime: number; 2780 readonly wallTime: number; 2781 } 2782 interface UnsafeTraceMetrics { 2783 fromTrace(item: TraceItem): TraceMetrics; 2784 } 2785 /** 2786 * The **`URL`** interface is used to parse, construct, normalize, and encode URL. 2787 * 2788 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL) 2789 */ 2790 declare class URL { 2791 constructor(url: string | URL, base?: string | URL); 2792 /** 2793 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL. 2794 * 2795 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin) 2796 */ 2797 get origin(): string; 2798 /** 2799 * The **`href`** property of the URL interface is a string containing the whole URL. 2800 * 2801 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) 2802 */ 2803 get href(): string; 2804 /** 2805 * The **`href`** property of the URL interface is a string containing the whole URL. 2806 * 2807 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href) 2808 */ 2809 set href(value: string); 2810 /** 2811 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`. 2812 * 2813 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) 2814 */ 2815 get protocol(): string; 2816 /** 2817 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`. 2818 * 2819 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol) 2820 */ 2821 set protocol(value: string); 2822 /** 2823 * The **`username`** property of the URL interface is a string containing the username component of the URL. 2824 * 2825 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) 2826 */ 2827 get username(): string; 2828 /** 2829 * The **`username`** property of the URL interface is a string containing the username component of the URL. 2830 * 2831 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username) 2832 */ 2833 set username(value: string); 2834 /** 2835 * The **`password`** property of the URL interface is a string containing the password component of the URL. 2836 * 2837 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) 2838 */ 2839 get password(): string; 2840 /** 2841 * The **`password`** property of the URL interface is a string containing the password component of the URL. 2842 * 2843 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password) 2844 */ 2845 set password(value: string); 2846 /** 2847 * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL. 2848 * 2849 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) 2850 */ 2851 get host(): string; 2852 /** 2853 * The **`host`** property of the URL interface is a string containing the host, which is the URL.hostname, and then, if the port of the URL is nonempty, a `':'`, followed by the URL.port of the URL. 2854 * 2855 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host) 2856 */ 2857 set host(value: string); 2858 /** 2859 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. 2860 * 2861 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) 2862 */ 2863 get hostname(): string; 2864 /** 2865 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL. 2866 * 2867 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname) 2868 */ 2869 set hostname(value: string); 2870 /** 2871 * The **`port`** property of the URL interface is a string containing the port number of the URL. 2872 * 2873 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) 2874 */ 2875 get port(): string; 2876 /** 2877 * The **`port`** property of the URL interface is a string containing the port number of the URL. 2878 * 2879 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port) 2880 */ 2881 set port(value: string); 2882 /** 2883 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. 2884 * 2885 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) 2886 */ 2887 get pathname(): string; 2888 /** 2889 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure. 2890 * 2891 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname) 2892 */ 2893 set pathname(value: string); 2894 /** 2895 * 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. 2896 * 2897 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) 2898 */ 2899 get search(): string; 2900 /** 2901 * 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. 2902 * 2903 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search) 2904 */ 2905 set search(value: string); 2906 /** 2907 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL. 2908 * 2909 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) 2910 */ 2911 get hash(): string; 2912 /** 2913 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL. 2914 * 2915 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash) 2916 */ 2917 set hash(value: string); 2918 /** 2919 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL. 2920 * 2921 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams) 2922 */ 2923 get searchParams(): URLSearchParams; 2924 /** 2925 * 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 ```js-nolint toJSON() ``` None. 2926 * 2927 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON) 2928 */ 2929 toJSON(): string; 2930 /*function toString() { [native code] }*/ 2931 toString(): string; 2932 /** 2933 * 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. 2934 * 2935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) 2936 */ 2937 static canParse(url: string, base?: string): boolean; 2938 /** 2939 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters. 2940 * 2941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static) 2942 */ 2943 static parse(url: string, base?: string): URL | null; 2944 /** 2945 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter. 2946 * 2947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) 2948 */ 2949 static createObjectURL(object: File | Blob): string; 2950 /** 2951 * The **`revokeObjectURL()`** static method of the URL interface releases an existing object URL which was previously created by calling Call this method when you've finished using an object URL to let the browser know not to keep the reference to the file any longer. 2952 * 2953 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) 2954 */ 2955 static revokeObjectURL(object_url: string): void; 2956 } 2957 /** 2958 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL. 2959 * 2960 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) 2961 */ 2962 declare class URLSearchParams { 2963 constructor(init?: (Iterable<Iterable<string>> | Record<string, string> | string)); 2964 /** 2965 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries. 2966 * 2967 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size) 2968 */ 2969 get size(): number; 2970 /** 2971 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter. 2972 * 2973 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append) 2974 */ 2975 append(name: string, value: string): void; 2976 /** 2977 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters. 2978 * 2979 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete) 2980 */ 2981 delete(name: string, value?: string): void; 2982 /** 2983 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter. 2984 * 2985 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get) 2986 */ 2987 get(name: string): string | null; 2988 /** 2989 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array. 2990 * 2991 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll) 2992 */ 2993 getAll(name: string): string[]; 2994 /** 2995 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters. 2996 * 2997 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has) 2998 */ 2999 has(name: string, value?: string): boolean; 3000 /** 3001 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value. 3002 * 3003 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set) 3004 */ 3005 set(name: string, value: string): void; 3006 /** 3007 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`. 3008 * 3009 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort) 3010 */ 3011 sort(): void; 3012 /* Returns an array of key, value pairs for every entry in the search params. */ 3013 entries(): IterableIterator<[ 3014 key: string, 3015 value: string 3016 ]>; 3017 /* Returns a list of keys in the search params. */ 3018 keys(): IterableIterator<string>; 3019 /* Returns a list of values in the search params. */ 3020 values(): IterableIterator<string>; 3021 forEach<This = unknown>(callback: (this: This, value: string, key: string, parent: URLSearchParams) => void, thisArg?: This): void; 3022 /*function toString() { [native code] }*/ 3023 toString(): string; 3024 [Symbol.iterator](): IterableIterator<[ 3025 key: string, 3026 value: string 3027 ]>; 3028 } 3029 declare class URLPattern { 3030 constructor(input?: (string | URLPatternInit), baseURL?: (string | URLPatternOptions), patternOptions?: URLPatternOptions); 3031 get protocol(): string; 3032 get username(): string; 3033 get password(): string; 3034 get hostname(): string; 3035 get port(): string; 3036 get pathname(): string; 3037 get search(): string; 3038 get hash(): string; 3039 get hasRegExpGroups(): boolean; 3040 test(input?: (string | URLPatternInit), baseURL?: string): boolean; 3041 exec(input?: (string | URLPatternInit), baseURL?: string): URLPatternResult | null; 3042 } 3043 interface URLPatternInit { 3044 protocol?: string; 3045 username?: string; 3046 password?: string; 3047 hostname?: string; 3048 port?: string; 3049 pathname?: string; 3050 search?: string; 3051 hash?: string; 3052 baseURL?: string; 3053 } 3054 interface URLPatternComponentResult { 3055 input: string; 3056 groups: Record<string, string>; 3057 } 3058 interface URLPatternResult { 3059 inputs: (string | URLPatternInit)[]; 3060 protocol: URLPatternComponentResult; 3061 username: URLPatternComponentResult; 3062 password: URLPatternComponentResult; 3063 hostname: URLPatternComponentResult; 3064 port: URLPatternComponentResult; 3065 pathname: URLPatternComponentResult; 3066 search: URLPatternComponentResult; 3067 hash: URLPatternComponentResult; 3068 } 3069 interface URLPatternOptions { 3070 ignoreCase?: boolean; 3071 } 3072 /** 3073 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed. 3074 * 3075 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent) 3076 */ 3077 declare class CloseEvent extends Event { 3078 constructor(type: string, initializer?: CloseEventInit); 3079 /** 3080 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed. 3081 * 3082 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code) 3083 */ 3084 readonly code: number; 3085 /** 3086 * 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. 3087 * 3088 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason) 3089 */ 3090 readonly reason: string; 3091 /** 3092 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly. 3093 * 3094 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean) 3095 */ 3096 readonly wasClean: boolean; 3097 } 3098 interface CloseEventInit { 3099 code?: number; 3100 reason?: string; 3101 wasClean?: boolean; 3102 } 3103 type WebSocketEventMap = { 3104 close: CloseEvent; 3105 message: MessageEvent; 3106 open: Event; 3107 error: ErrorEvent; 3108 }; 3109 /** 3110 * 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. 3111 * 3112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) 3113 */ 3114 declare var WebSocket: { 3115 prototype: WebSocket; 3116 new (url: string, protocols?: (string[] | string)): WebSocket; 3117 readonly READY_STATE_CONNECTING: number; 3118 readonly CONNECTING: number; 3119 readonly READY_STATE_OPEN: number; 3120 readonly OPEN: number; 3121 readonly READY_STATE_CLOSING: number; 3122 readonly CLOSING: number; 3123 readonly READY_STATE_CLOSED: number; 3124 readonly CLOSED: number; 3125 }; 3126 /** 3127 * 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. 3128 * 3129 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket) 3130 */ 3131 interface WebSocket extends EventTarget<WebSocketEventMap> { 3132 accept(options?: WebSocketAcceptOptions): void; 3133 /** 3134 * 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. 3135 * 3136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send) 3137 */ 3138 send(message: (ArrayBuffer | ArrayBufferView) | string): void; 3139 /** 3140 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing. 3141 * 3142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close) 3143 */ 3144 close(code?: number, reason?: string): void; 3145 serializeAttachment(attachment: any): void; 3146 deserializeAttachment(): any | null; 3147 /** 3148 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection. 3149 * 3150 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState) 3151 */ 3152 readyState: number; 3153 /** 3154 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor. 3155 * 3156 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url) 3157 */ 3158 url: string | null; 3159 /** 3160 * 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. 3161 * 3162 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol) 3163 */ 3164 protocol: string | null; 3165 /** 3166 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server. 3167 * 3168 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions) 3169 */ 3170 extensions: string | null; 3171 /** 3172 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection. 3173 * 3174 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType) 3175 */ 3176 binaryType: "blob" | "arraybuffer"; 3177 } 3178 interface WebSocketAcceptOptions { 3179 /** 3180 * When set to `true`, receiving a server-initiated WebSocket Close frame will not 3181 * automatically send a reciprocal Close frame, leaving the connection in a half-open 3182 * state. This is useful for proxying scenarios where you need to coordinate closing 3183 * both sides independently. Defaults to `false` when the 3184 * `no_web_socket_half_open_by_default` compatibility flag is enabled. 3185 */ 3186 allowHalfOpen?: boolean; 3187 } 3188 declare const WebSocketPair: { 3189 new (): { 3190 0: WebSocket; 3191 1: WebSocket; 3192 }; 3193 }; 3194 interface SqlStorage { 3195 exec<T extends Record<string, SqlStorageValue>>(query: string, ...bindings: any[]): SqlStorageCursor<T>; 3196 get databaseSize(): number; 3197 Cursor: typeof SqlStorageCursor; 3198 Statement: typeof SqlStorageStatement; 3199 } 3200 declare abstract class SqlStorageStatement { 3201 } 3202 type SqlStorageValue = ArrayBuffer | string | number | null; 3203 declare abstract class SqlStorageCursor<T extends Record<string, SqlStorageValue>> { 3204 next(): { 3205 done?: false; 3206 value: T; 3207 } | { 3208 done: true; 3209 value?: never; 3210 }; 3211 toArray(): T[]; 3212 one(): T; 3213 raw<U extends SqlStorageValue[]>(): IterableIterator<U>; 3214 columnNames: string[]; 3215 get rowsRead(): number; 3216 get rowsWritten(): number; 3217 [Symbol.iterator](): IterableIterator<T>; 3218 } 3219 interface Socket { 3220 get readable(): ReadableStream; 3221 get writable(): WritableStream; 3222 get closed(): Promise<void>; 3223 get opened(): Promise<SocketInfo>; 3224 get upgraded(): boolean; 3225 get secureTransport(): "on" | "off" | "starttls"; 3226 close(): Promise<void>; 3227 startTls(options?: TlsOptions): Socket; 3228 } 3229 interface SocketOptions { 3230 secureTransport?: string; 3231 allowHalfOpen: boolean; 3232 highWaterMark?: (number | bigint); 3233 } 3234 interface SocketAddress { 3235 hostname: string; 3236 port: number; 3237 } 3238 interface TlsOptions { 3239 expectedServerHostname?: string; 3240 } 3241 interface SocketInfo { 3242 remoteAddress?: string; 3243 localAddress?: string; 3244 } 3245 /** 3246 * The **`EventSource`** interface is web content's interface to server-sent events. 3247 * 3248 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) 3249 */ 3250 declare class EventSource extends EventTarget { 3251 constructor(url: string, init?: EventSourceEventSourceInit); 3252 /** 3253 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None. 3254 * 3255 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close) 3256 */ 3257 close(): void; 3258 /** 3259 * The **`url`** read-only property of the URL of the source. 3260 * 3261 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url) 3262 */ 3263 get url(): string; 3264 /** 3265 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set. 3266 * 3267 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials) 3268 */ 3269 get withCredentials(): boolean; 3270 /** 3271 * The **`readyState`** read-only property of the connection. 3272 * 3273 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState) 3274 */ 3275 get readyState(): number; 3276 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ 3277 get onopen(): any | null; 3278 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */ 3279 set onopen(value: any | null); 3280 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ 3281 get onmessage(): any | null; 3282 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */ 3283 set onmessage(value: any | null); 3284 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ 3285 get onerror(): any | null; 3286 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */ 3287 set onerror(value: any | null); 3288 static readonly CONNECTING: number; 3289 static readonly OPEN: number; 3290 static readonly CLOSED: number; 3291 static from(stream: ReadableStream): EventSource; 3292 } 3293 interface EventSourceEventSourceInit { 3294 withCredentials?: boolean; 3295 fetcher?: Fetcher; 3296 } 3297 interface Container { 3298 get running(): boolean; 3299 start(options?: ContainerStartupOptions): void; 3300 monitor(): Promise<void>; 3301 destroy(error?: any): Promise<void>; 3302 signal(signo: number): void; 3303 getTcpPort(port: number): Fetcher; 3304 setInactivityTimeout(durationMs: number | bigint): Promise<void>; 3305 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>; 3306 interceptAllOutboundHttp(binding: Fetcher): Promise<void>; 3307 snapshotDirectory(options: ContainerDirectorySnapshotOptions): Promise<ContainerDirectorySnapshot>; 3308 snapshotContainer(options: ContainerSnapshotOptions): Promise<ContainerSnapshot>; 3309 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>; 3310 } 3311 interface ContainerDirectorySnapshot { 3312 id: string; 3313 size: number; 3314 dir: string; 3315 name?: string; 3316 } 3317 interface ContainerDirectorySnapshotOptions { 3318 dir: string; 3319 name?: string; 3320 } 3321 interface ContainerDirectorySnapshotRestoreParams { 3322 snapshot: ContainerDirectorySnapshot; 3323 mountPoint?: string; 3324 } 3325 interface ContainerSnapshot { 3326 id: string; 3327 size: number; 3328 name?: string; 3329 } 3330 interface ContainerSnapshotOptions { 3331 name?: string; 3332 } 3333 interface ContainerStartupOptions { 3334 entrypoint?: string[]; 3335 enableInternet: boolean; 3336 env?: Record<string, string>; 3337 labels?: Record<string, string>; 3338 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[]; 3339 containerSnapshot?: ContainerSnapshot; 3340 } 3341 /** 3342 * 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. 3343 * 3344 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort) 3345 */ 3346 declare abstract class MessagePort extends EventTarget { 3347 /** 3348 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts. 3349 * 3350 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage) 3351 */ 3352 postMessage(data?: any, options?: (any[] | MessagePortPostMessageOptions)): void; 3353 /** 3354 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active. 3355 * 3356 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close) 3357 */ 3358 close(): void; 3359 /** 3360 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port. 3361 * 3362 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start) 3363 */ 3364 start(): void; 3365 get onmessage(): any | null; 3366 set onmessage(value: any | null); 3367 } 3368 /** 3369 * 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. 3370 * 3371 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel) 3372 */ 3373 declare class MessageChannel { 3374 constructor(); 3375 /** 3376 * The **`port1`** read-only property of the the port attached to the context that originated the channel. 3377 * 3378 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1) 3379 */ 3380 readonly port1: MessagePort; 3381 /** 3382 * The **`port2`** read-only property of the the port attached to the context at the other end of the channel, which the message is initially sent to. 3383 * 3384 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2) 3385 */ 3386 readonly port2: MessagePort; 3387 } 3388 interface MessagePortPostMessageOptions { 3389 transfer?: any[]; 3390 } 3391 type 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; 3392 type LoopbackServiceStub<T extends Rpc.WorkerEntrypointBranded | undefined = undefined> = Fetcher<T> & (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props> ? (opts: { 3393 props?: Props; 3394 }) => Fetcher<T> : (opts: { 3395 props?: any; 3396 }) => Fetcher<T>); 3397 type LoopbackDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined = undefined> = DurableObjectClass<T> & (T extends CloudflareWorkersModule.DurableObject<any, infer Props> ? (opts: { 3398 props?: Props; 3399 }) => DurableObjectClass<T> : (opts: { 3400 props?: any; 3401 }) => DurableObjectClass<T>); 3402 interface LoopbackDurableObjectNamespace extends DurableObjectNamespace { 3403 } 3404 interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace { 3405 } 3406 interface SyncKvStorage { 3407 get<T = unknown>(key: string): T | undefined; 3408 list<T = unknown>(options?: SyncKvListOptions): Iterable<[ 3409 string, 3410 T 3411 ]>; 3412 put<T>(key: string, value: T): void; 3413 delete(key: string): boolean; 3414 } 3415 interface SyncKvListOptions { 3416 start?: string; 3417 startAfter?: string; 3418 end?: string; 3419 prefix?: string; 3420 reverse?: boolean; 3421 limit?: number; 3422 } 3423 interface WorkerStub { 3424 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): Fetcher<T>; 3425 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(name?: string, options?: WorkerStubEntrypointOptions): DurableObjectClass<T>; 3426 } 3427 interface WorkerStubEntrypointOptions { 3428 props?: any; 3429 limits?: workerdResourceLimits; 3430 } 3431 interface WorkerLoader { 3432 get(name: string | null, getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>): WorkerStub; 3433 load(code: WorkerLoaderWorkerCode): WorkerStub; 3434 } 3435 interface WorkerLoaderModule { 3436 js?: string; 3437 cjs?: string; 3438 text?: string; 3439 data?: ArrayBuffer; 3440 json?: any; 3441 py?: string; 3442 wasm?: ArrayBuffer; 3443 } 3444 interface WorkerLoaderWorkerCode { 3445 compatibilityDate: string; 3446 compatibilityFlags?: string[]; 3447 allowExperimental?: boolean; 3448 limits?: workerdResourceLimits; 3449 mainModule: string; 3450 modules: Record<string, WorkerLoaderModule | string>; 3451 env?: any; 3452 globalOutbound?: (Fetcher | null); 3453 tails?: Fetcher[]; 3454 streamingTails?: Fetcher[]; 3455 } 3456 interface workerdResourceLimits { 3457 cpuMs?: number; 3458 subRequests?: number; 3459 } 3460 /** 3461 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance, 3462 * as well as timing of subrequests and other operations. 3463 * 3464 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/) 3465 */ 3466 declare abstract class Performance { 3467 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */ 3468 get timeOrigin(): number; 3469 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */ 3470 now(): number; 3471 /** 3472 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object. 3473 * 3474 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON) 3475 */ 3476 toJSON(): object; 3477 } 3478 interface Tracing { 3479 enterSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T; 3480 Span: typeof Span; 3481 } 3482 declare abstract class Span { 3483 get isTraced(): boolean; 3484 setAttribute(key: string, value?: (boolean | number | string)): void; 3485 } 3486 // ============================================================================ 3487 // Agent Memory 3488 // 3489 // Public type surface for user Workers binding to an Agent Memory namespace. 3490 // ============================================================================ 3491 /** Memory type — every memory is classified into exactly one. */ 3492 type AgentMemoryMemoryType = "fact" | "event" | "instruction" | "task"; 3493 /** Search intensity for recall. */ 3494 type AgentMemoryThinkingLevel = "low" | "medium" | "high"; 3495 /** Response verbosity for recall. */ 3496 type AgentMemoryResponseLength = "short" | "medium" | "long"; 3497 /** A conversation message passed to ingest(). */ 3498 interface AgentMemoryMessage { 3499 role: "system" | "user" | "assistant"; 3500 content: string; 3501 /** Optional message timestamp. */ 3502 timestamp?: Date; 3503 } 3504 /** Raw memory content passed to remember(). */ 3505 interface AgentMemoryIncomingMemory { 3506 /** Raw memory content. The service classifies and summarizes automatically. */ 3507 content: string; 3508 /** Optional session identifier to associate with this memory. */ 3509 sessionId?: string | null | undefined; 3510 } 3511 /** A stored memory returned from remember(), get(), and delete(). */ 3512 interface AgentMemoryMemory { 3513 /** Memory ID. */ 3514 id: string; 3515 /** Memory type. */ 3516 type: AgentMemoryMemoryType; 3517 /** Text summary. */ 3518 summary: string; 3519 /** Memory text. */ 3520 content: string; 3521 /** Session that created this memory. */ 3522 sessionId: string | null; 3523 /** Memory creation time. */ 3524 createdAt: Date; 3525 /** Memory last-update time. */ 3526 updatedAt: Date; 3527 } 3528 /** Single entry in a list() response. Same shape as Memory minus full content. */ 3529 type AgentMemoryMemoryListEntry = Omit<AgentMemoryMemory, "content">; 3530 /** A scored memory candidate in a recall result. */ 3531 interface AgentMemoryScoredCandidate { 3532 /** Candidate ID. */ 3533 id: string; 3534 /** Text summary. */ 3535 summary: string; 3536 /** Session that created this candidate, when known. */ 3537 sessionId: string | null; 3538 /** Relevance score (higher is better). Comparable only within a single query. */ 3539 score: number; 3540 } 3541 /** Options for the ingest() method. */ 3542 interface AgentMemoryIngestOptions { 3543 /** Session identifier to associate with memories created during ingestion. */ 3544 sessionId?: string | null | undefined; 3545 } 3546 /** Options for the getSummary() method. */ 3547 interface AgentMemoryGetSummaryOptions { 3548 /** Session identifier to retrieve session summary for. */ 3549 sessionId?: string | null | undefined; 3550 } 3551 /** Response from the getSummary() method. */ 3552 interface AgentMemoryGetSummaryResponse { 3553 /** Markdown summary. */ 3554 summary: string; 3555 } 3556 /** 3557 * Options for the recall() method. 3558 * 3559 * `referenceDate` accepts a Date object, an ISO-8601 date string 3560 * (YYYY-MM-DD), or a full ISO-8601 datetime string. When provided, this 3561 * date is used as "today" for resolving relative time references 3562 * ("how many days ago", "last week") instead of the server's wall-clock time. 3563 */ 3564 interface AgentMemoryRecallOptions { 3565 /** Recall intensity: "low" (default), "medium", or "high". */ 3566 thinkingLevel?: AgentMemoryThinkingLevel; 3567 /** Response verbosity: "short", "medium" (default), or "long". */ 3568 responseLength?: AgentMemoryResponseLength; 3569 /** Temporal anchor for date arithmetic. */ 3570 referenceDate?: Date | string; 3571 } 3572 /** Response from the recall() method. */ 3573 interface AgentMemoryRecallResult { 3574 /** Number of memories retrieved. */ 3575 count: number; 3576 /** LLM-generated answer synthesizing the matching memories. */ 3577 answer: string; 3578 /** Matching memories ranked by relevance. */ 3579 candidates: AgentMemoryScoredCandidate[]; 3580 } 3581 /** 3582 * Options for the list() method. 3583 * 3584 * `cursor` is the opaque continuation token returned by the previous page; 3585 * pass it back unchanged to fetch the next page. `sessionId` and `type` 3586 * are exact-match filters; combining them is allowed. 3587 */ 3588 interface AgentMemoryListMemoriesOptions { 3589 /** Maximum number of memories to return. Default 20, max 500. */ 3590 limit?: number; 3591 /** Opaque cursor from a previous page. */ 3592 cursor?: string; 3593 /** Exact-match session filter. */ 3594 sessionId?: string; 3595 /** Exact-match memory-type filter. */ 3596 type?: AgentMemoryMemoryType; 3597 } 3598 /** Response from the list() method. */ 3599 interface AgentMemoryListMemoriesResult { 3600 memories: AgentMemoryMemoryListEntry[]; 3601 /** Continuation cursor; absent when this page exhausted the result set. */ 3602 cursor?: string; 3603 } 3604 /** 3605 * A single Agent Memory profile, scoped to a profile name. 3606 * 3607 * Returned by {@link AgentMemoryNamespace.getProfile}. 3608 */ 3609 declare abstract class AgentMemoryProfile { 3610 /** 3611 * Retrieve a memory by ID. 3612 * 3613 * @param memoryId - ULID of the memory to retrieve. 3614 * @throws if the memory does not exist. 3615 */ 3616 get(memoryId: string): Promise<AgentMemoryMemory>; 3617 /** 3618 * Delete a memory by ID. 3619 * 3620 * Removes the memory and any source messages linked by the memory's 3621 * source message IDs. 3622 * 3623 * @param memoryId - ULID of the memory to delete. 3624 * @throws if the memory does not exist. 3625 */ 3626 delete(memoryId: string): Promise<AgentMemoryMemory>; 3627 /** 3628 * Store a memory in this profile. The content is automatically classified, 3629 * summarized, and indexed. 3630 * 3631 * @param memory - Raw memory content to persist. 3632 */ 3633 remember(memory: AgentMemoryIncomingMemory): Promise<AgentMemoryMemory>; 3634 /** 3635 * Extract memories from a conversation. 3636 * 3637 * @param messages - Conversation messages to extract memories from. 3638 * @param options - Optional ingest options. 3639 */ 3640 ingest(messages: Iterable<AgentMemoryMessage>, options?: AgentMemoryIngestOptions): Promise<void>; 3641 /** 3642 * Get a profile summary. 3643 * 3644 * @param options - Optional getSummary options. 3645 */ 3646 getSummary(options?: AgentMemoryGetSummaryOptions): Promise<AgentMemoryGetSummaryResponse>; 3647 /** 3648 * Recall memories in this profile. 3649 * 3650 * @param query - Recall query matched against memory content and keywords. 3651 * @param options - Optional recall parameters. 3652 * @returns Matching memories with relevance scores and a synthesized answer. 3653 */ 3654 recall(query: string, options?: AgentMemoryRecallOptions): Promise<AgentMemoryRecallResult>; 3655 /** 3656 * List active memories in this profile. 3657 * 3658 * Returns a paginated, filterable view of stored memories. Superseded 3659 * versions are excluded. Use the returned `cursor` (when present) to 3660 * fetch the next page. 3661 * 3662 * @param options - Optional pagination and filter options. 3663 */ 3664 list(options?: AgentMemoryListMemoriesOptions): Promise<AgentMemoryListMemoriesResult>; 3665 /** 3666 * Soft-delete every memory and message in this profile that is tagged 3667 * with `sessionId`. 3668 * 3669 * Idempotent: deleting a sessionId that has no rows is a no-op. 3670 * 3671 * @param sessionId - Session to delete. 3672 */ 3673 deleteSession(sessionId: string): Promise<void>; 3674 } 3675 /** 3676 * Namespace-level Agent Memory binding. 3677 * 3678 * Used as the type of an `env.MEMORY`-style binding backed by the Agent 3679 * Memory product. 3680 * 3681 * @example 3682 * ```ts 3683 * export default { 3684 * async fetch(_request: Request, env: Env): Promise<Response> { 3685 * const profile = await env.MEMORY.getProfile("wrangler-e2e"); 3686 * const summary = await profile.getSummary(); 3687 * return Response.json(summary); 3688 * }, 3689 * }; 3690 * ``` 3691 */ 3692 declare abstract class AgentMemoryNamespace { 3693 /** 3694 * Get a memory profile by name. Profiles are isolated by namespace and 3695 * addressed by a compound key (namespaceId:profileName). 3696 * 3697 * @param profileName - Profile name (validated against naming rules). 3698 * @returns RPC target for interacting with the profile. 3699 */ 3700 getProfile(profileName: string): Promise<AgentMemoryProfile>; 3701 /** 3702 * Soft-delete a profile and schedule deferred purge. Marks all 3703 * memories and messages as deleted. 3704 * 3705 * @param profileName - Name of the profile to delete. 3706 */ 3707 deleteProfile(profileName: string): Promise<void>; 3708 } 3709 // ============ AI Search Error Interfaces ============ 3710 interface AiSearchInternalError extends Error { 3711 } 3712 interface AiSearchNotFoundError extends Error { 3713 } 3714 // ============ AI Search Common Types ============ 3715 /** A single message in a conversation-style search or chat request. */ 3716 type AiSearchMessage = { 3717 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; 3718 content: string | null; 3719 }; 3720 /** 3721 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests. 3722 * Contains retrieval, query rewrite, reranking, and cache sub-options. 3723 */ 3724 type AiSearchOptions = { 3725 retrieval?: { 3726 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */ 3727 retrieval_type?: 'vector' | 'keyword' | 'hybrid'; 3728 /** Fusion method for combining vector + keyword results. */ 3729 fusion_method?: 'max' | 'rrf'; 3730 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */ 3731 keyword_match_mode?: 'and' | 'or'; 3732 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */ 3733 match_threshold?: number; 3734 /** Maximum number of results to return (1-50). Default 10. */ 3735 max_num_results?: number; 3736 /** Vectorize metadata filters applied to the search. */ 3737 filters?: VectorizeVectorMetadataFilter; 3738 /** Number of surrounding chunks to include for context (0-3). Default 0. */ 3739 context_expansion?: number; 3740 /** If true, return only item metadata without chunk text. */ 3741 metadata_only?: boolean; 3742 /** If true (default), return empty results on retrieval failure instead of throwing. */ 3743 return_on_failure?: boolean; 3744 /** Boost results by metadata field values. Max 3 entries. */ 3745 boost_by?: Array<{ 3746 field: string; 3747 direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; 3748 }>; 3749 [key: string]: unknown; 3750 }; 3751 query_rewrite?: { 3752 enabled?: boolean; 3753 model?: string; 3754 rewrite_prompt?: string; 3755 [key: string]: unknown; 3756 }; 3757 reranking?: { 3758 enabled?: boolean; 3759 model?: string; 3760 /** Match threshold (0-1, default 0.4) */ 3761 match_threshold?: number; 3762 [key: string]: unknown; 3763 }; 3764 cache?: { 3765 enabled?: boolean; 3766 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; 3767 }; 3768 [key: string]: unknown; 3769 }; 3770 // ============ AI Search Request Types ============ 3771 /** 3772 * Request body for single-instance search. 3773 * Exactly one of `query` or `messages` must be provided. 3774 */ 3775 type AiSearchSearchRequest = { 3776 /** Simple query string. */ 3777 query: string; 3778 messages?: never; 3779 ai_search_options?: AiSearchOptions; 3780 } | { 3781 query?: never; 3782 /** Conversation-style input. At least one user message with non-empty content is required. */ 3783 messages: AiSearchMessage[]; 3784 ai_search_options?: AiSearchOptions; 3785 }; 3786 type AiSearchChatCompletionsRequest = { 3787 messages: AiSearchMessage[]; 3788 model?: string; 3789 stream?: boolean; 3790 ai_search_options?: AiSearchOptions; 3791 [key: string]: unknown; 3792 }; 3793 // ============ AI Search Multi-Instance Types (Namespace-Scoped) ============ 3794 /** `ai_search_options` shape for multi-instance requests — requires `instance_ids`. */ 3795 type AiSearchMultiSearchOptions = AiSearchOptions & { 3796 /** Instance IDs to search across (1-10). */ 3797 instance_ids: string[]; 3798 }; 3799 /** 3800 * Request for searching across multiple instances within a namespace. 3801 * `ai_search_options` is required and must include `instance_ids`. 3802 * Exactly one of `query` or `messages` must be provided. 3803 */ 3804 type AiSearchMultiSearchRequest = { 3805 /** Simple query string. */ 3806 query: string; 3807 messages?: never; 3808 ai_search_options: AiSearchMultiSearchOptions; 3809 } | { 3810 query?: never; 3811 /** Conversation-style input. */ 3812 messages: AiSearchMessage[]; 3813 ai_search_options: AiSearchMultiSearchOptions; 3814 }; 3815 /** A search result chunk tagged with the instance it originated from. */ 3816 type AiSearchMultiSearchChunk = AiSearchSearchResponse['chunks'][number] & { 3817 instance_id: string; 3818 }; 3819 /** Describes a per-instance error during a multi-instance operation. */ 3820 type AiSearchMultiSearchError = { 3821 instance_id: string; 3822 message: string; 3823 }; 3824 /** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */ 3825 type AiSearchMultiSearchResponse = { 3826 search_query: string; 3827 chunks: AiSearchMultiSearchChunk[]; 3828 errors?: AiSearchMultiSearchError[]; 3829 }; 3830 /** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */ 3831 type AiSearchMultiChatCompletionsRequest = Omit<AiSearchChatCompletionsRequest, 'ai_search_options'> & { 3832 ai_search_options: AiSearchMultiSearchOptions; 3833 }; 3834 /** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */ 3835 type AiSearchMultiChatCompletionsResponse = Omit<AiSearchChatCompletionsResponse, 'chunks'> & { 3836 chunks: AiSearchMultiSearchChunk[]; 3837 errors?: AiSearchMultiSearchError[]; 3838 }; 3839 // ============ AI Search Response Types ============ 3840 type AiSearchSearchResponse = { 3841 search_query: string; 3842 chunks: Array<{ 3843 id: string; 3844 type: string; 3845 /** Match score (0-1) */ 3846 score: number; 3847 text: string; 3848 item: { 3849 timestamp?: number; 3850 key: string; 3851 metadata?: Record<string, unknown>; 3852 }; 3853 scoring_details?: { 3854 /** Keyword match score (0-1) */ 3855 keyword_score?: number; 3856 /** Vector similarity score (0-1) */ 3857 vector_score?: number; 3858 /** Keyword rank position */ 3859 keyword_rank?: number; 3860 /** Vector rank position */ 3861 vector_rank?: number; 3862 /** Reranking model score */ 3863 reranking_score?: number; 3864 /** Fusion method used to combine results */ 3865 fusion_method?: 'rrf' | 'max'; 3866 [key: string]: unknown; 3867 }; 3868 }>; 3869 }; 3870 type AiSearchChatCompletionsResponse = { 3871 id?: string; 3872 object?: string; 3873 model?: string; 3874 choices: Array<{ 3875 index?: number; 3876 message: { 3877 role: 'system' | 'developer' | 'user' | 'assistant' | 'tool'; 3878 content: string | null; 3879 [key: string]: unknown; 3880 }; 3881 [key: string]: unknown; 3882 }>; 3883 chunks: AiSearchSearchResponse['chunks']; 3884 [key: string]: unknown; 3885 }; 3886 type AiSearchStatsResponse = { 3887 queued?: number; 3888 running?: number; 3889 completed?: number; 3890 error?: number; 3891 skipped?: number; 3892 outdated?: number; 3893 last_activity?: string; 3894 /** Storage engine statistics. */ 3895 engine?: { 3896 vectorize?: { 3897 vectorsCount: number; 3898 dimensions: number; 3899 }; 3900 r2?: { 3901 payloadSizeBytes: number; 3902 metadataSizeBytes: number; 3903 objectCount: number; 3904 }; 3905 }; 3906 }; 3907 // ============ AI Search Instance Info Types ============ 3908 type AiSearchInstanceInfo = { 3909 id: string; 3910 type?: 'r2' | 'web-crawler' | string; 3911 source?: string; 3912 source_params?: unknown; 3913 paused?: boolean; 3914 status?: string; 3915 namespace?: string; 3916 created_at?: string; 3917 modified_at?: string; 3918 token_id?: string; 3919 ai_gateway_id?: string; 3920 rewrite_query?: boolean; 3921 reranking?: boolean; 3922 embedding_model?: string; 3923 ai_search_model?: string; 3924 rewrite_model?: string; 3925 reranking_model?: string; 3926 /** @deprecated Use index_method instead. */ 3927 hybrid_search_enabled?: boolean; 3928 /** Controls which storage backends are active. */ 3929 index_method?: { 3930 vector?: boolean; 3931 keyword?: boolean; 3932 }; 3933 /** Fusion method for combining vector and keyword results. */ 3934 fusion_method?: 'max' | 'rrf'; 3935 indexing_options?: { 3936 keyword_tokenizer?: 'porter' | 'trigram'; 3937 } | null; 3938 retrieval_options?: { 3939 keyword_match_mode?: 'and' | 'or'; 3940 boost_by?: Array<{ 3941 field: string; 3942 direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; 3943 }>; 3944 } | null; 3945 chunk?: boolean; 3946 chunk_size?: number; 3947 chunk_overlap?: number; 3948 score_threshold?: number; 3949 max_num_results?: number; 3950 cache?: boolean; 3951 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; 3952 custom_metadata?: Array<{ 3953 field_name: string; 3954 data_type: 'text' | 'number' | 'boolean' | 'datetime'; 3955 }>; 3956 /** Sync interval in seconds. */ 3957 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400; 3958 metadata?: Record<string, unknown>; 3959 [key: string]: unknown; 3960 }; 3961 /** Pagination, search, and ordering parameters for listing instances within a namespace. */ 3962 type AiSearchListInstancesParams = { 3963 page?: number; 3964 per_page?: number; 3965 /** Search instances by ID. */ 3966 search?: string; 3967 /** Field to sort by. */ 3968 order_by?: 'created_at'; 3969 /** Sort direction. */ 3970 order_by_direction?: 'asc' | 'desc'; 3971 }; 3972 type AiSearchListResponse = { 3973 result: AiSearchInstanceInfo[]; 3974 result_info?: { 3975 count: number; 3976 page: number; 3977 per_page: number; 3978 total_count: number; 3979 }; 3980 }; 3981 // ============ AI Search Config Types ============ 3982 type AiSearchConfig = { 3983 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */ 3984 id: string; 3985 /** Instance type. Omit to create with built-in storage. */ 3986 type?: 'r2' | 'web-crawler' | string; 3987 /** Source URL (required for web-crawler type). */ 3988 source?: string; 3989 source_params?: unknown; 3990 /** Token ID (UUID format) */ 3991 token_id?: string; 3992 ai_gateway_id?: string; 3993 /** Enable query rewriting (default false) */ 3994 rewrite_query?: boolean; 3995 /** Enable reranking (default false) */ 3996 reranking?: boolean; 3997 embedding_model?: string; 3998 ai_search_model?: string; 3999 rewrite_model?: string; 4000 reranking_model?: string; 4001 /** @deprecated Use index_method instead. */ 4002 hybrid_search_enabled?: boolean; 4003 /** Controls which storage backends are used during indexing. Defaults to vector-only. */ 4004 index_method?: { 4005 vector?: boolean; 4006 keyword?: boolean; 4007 }; 4008 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */ 4009 fusion_method?: 'max' | 'rrf'; 4010 indexing_options?: { 4011 keyword_tokenizer?: 'porter' | 'trigram'; 4012 } | null; 4013 retrieval_options?: { 4014 keyword_match_mode?: 'and' | 'or'; 4015 boost_by?: Array<{ 4016 field: string; 4017 direction?: 'asc' | 'desc' | 'exists' | 'not_exists'; 4018 }>; 4019 } | null; 4020 chunk?: boolean; 4021 chunk_size?: number; 4022 chunk_overlap?: number; 4023 /** Minimum similarity score (0-1) for a result to be included. */ 4024 score_threshold?: number; 4025 max_num_results?: number; 4026 cache?: boolean; 4027 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */ 4028 cache_threshold?: 'super_strict_match' | 'close_enough' | 'flexible_friend' | 'anything_goes'; 4029 custom_metadata?: Array<{ 4030 field_name: string; 4031 data_type: 'text' | 'number' | 'boolean' | 'datetime'; 4032 }>; 4033 namespace?: string; 4034 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */ 4035 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400; 4036 metadata?: Record<string, unknown>; 4037 [key: string]: unknown; 4038 }; 4039 // ============ AI Search Item Types ============ 4040 type AiSearchItemInfo = { 4041 id: string; 4042 key: string; 4043 status: 'completed' | 'error' | 'skipped' | 'queued' | 'running' | 'outdated'; 4044 next_action?: 'INDEX' | 'DELETE' | null; 4045 error?: string; 4046 checksum?: string; 4047 namespace?: string; 4048 chunks_count?: number | null; 4049 file_size?: number | null; 4050 source_id?: string | null; 4051 last_seen_at?: string; 4052 created_at?: string; 4053 metadata?: Record<string, unknown>; 4054 [key: string]: unknown; 4055 }; 4056 type AiSearchItemContentResult = { 4057 body: ReadableStream; 4058 contentType: string; 4059 filename: string; 4060 size: number; 4061 }; 4062 type AiSearchUploadItemOptions = { 4063 metadata?: Record<string, unknown>; 4064 }; 4065 type AiSearchListItemsParams = { 4066 page?: number; 4067 per_page?: number; 4068 /** Search items by key name. */ 4069 search?: string; 4070 /** Sort order for results. */ 4071 sort_by?: 'status' | 'modified_at'; 4072 /** Filter items by processing status. */ 4073 status?: 'queued' | 'running' | 'completed' | 'error' | 'skipped' | 'outdated'; 4074 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */ 4075 source?: string; 4076 /** JSON-encoded Vectorize filter for metadata filtering. */ 4077 metadata_filter?: string; 4078 }; 4079 type AiSearchListItemsResponse = { 4080 result: AiSearchItemInfo[]; 4081 result_info?: { 4082 count: number; 4083 page: number; 4084 per_page: number; 4085 total_count: number; 4086 }; 4087 }; 4088 // ============ AI Search Item Logs Types ============ 4089 type AiSearchItemLogsParams = { 4090 /** Maximum number of log entries to return (1-100, default 50). */ 4091 limit?: number; 4092 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */ 4093 cursor?: string; 4094 }; 4095 type AiSearchItemLog = { 4096 timestamp: string; 4097 action: string; 4098 message: string; 4099 fileKey?: string; 4100 chunkCount?: number; 4101 processingTimeMs?: number; 4102 errorType?: string; 4103 }; 4104 /** Paginated response for item processing logs (cursor-based). */ 4105 type AiSearchItemLogsResponse = { 4106 result: AiSearchItemLog[]; 4107 result_info: { 4108 count: number; 4109 per_page: number; 4110 cursor: string | null; 4111 truncated: boolean; 4112 }; 4113 }; 4114 // ============ AI Search Item Chunks Types ============ 4115 type AiSearchItemChunksParams = { 4116 /** Maximum number of chunks to return (1-100, default 20). */ 4117 limit?: number; 4118 /** Offset into the chunks list (default 0). */ 4119 offset?: number; 4120 }; 4121 /** A single indexed chunk belonging to an item, including its text content and byte range. */ 4122 type AiSearchItemChunk = { 4123 id: string; 4124 text: string; 4125 start_byte: number; 4126 end_byte: number; 4127 item?: { 4128 timestamp?: number; 4129 key: string; 4130 metadata?: Record<string, unknown>; 4131 }; 4132 }; 4133 /** Paginated response for item chunks (offset-based). */ 4134 type AiSearchItemChunksResponse = { 4135 result: AiSearchItemChunk[]; 4136 result_info: { 4137 count: number; 4138 total: number; 4139 limit: number; 4140 offset: number; 4141 }; 4142 }; 4143 // ============ AI Search Job Types ============ 4144 type AiSearchJobInfo = { 4145 id: string; 4146 source: 'user' | 'schedule'; 4147 description?: string; 4148 last_seen_at?: string; 4149 started_at?: string; 4150 ended_at?: string; 4151 end_reason?: string; 4152 }; 4153 type AiSearchJobLog = { 4154 id: number; 4155 message: string; 4156 message_type: number; 4157 created_at: number; 4158 }; 4159 type AiSearchCreateJobParams = { 4160 description?: string; 4161 }; 4162 type AiSearchListJobsParams = { 4163 page?: number; 4164 per_page?: number; 4165 }; 4166 type AiSearchListJobsResponse = { 4167 result: AiSearchJobInfo[]; 4168 result_info?: { 4169 count: number; 4170 page: number; 4171 per_page: number; 4172 total_count: number; 4173 }; 4174 }; 4175 type AiSearchJobLogsParams = { 4176 page?: number; 4177 per_page?: number; 4178 }; 4179 type AiSearchJobLogsResponse = { 4180 result: AiSearchJobLog[]; 4181 result_info?: { 4182 count: number; 4183 page: number; 4184 per_page: number; 4185 total_count: number; 4186 }; 4187 }; 4188 // ============ AI Search Sub-Service Classes ============ 4189 /** 4190 * Single item service for an AI Search instance. 4191 * Provides info, download, sync, logs, and chunks operations on a specific item. 4192 */ 4193 declare abstract class AiSearchItem { 4194 /** Get metadata about this item. */ 4195 info(): Promise<AiSearchItemInfo>; 4196 /** 4197 * Download the item's content. 4198 * @returns Object with body stream, content type, filename, and size. 4199 */ 4200 download(): Promise<AiSearchItemContentResult>; 4201 /** 4202 * Trigger re-indexing of this item. 4203 * @returns The updated item info. 4204 */ 4205 sync(): Promise<AiSearchItemInfo>; 4206 /** 4207 * Retrieve processing logs for this item (cursor-based pagination). 4208 * @param params Optional pagination parameters (limit, cursor). 4209 * @returns Paginated log entries for this item. 4210 */ 4211 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>; 4212 /** 4213 * List indexed chunks for this item (offset-based pagination). 4214 * @param params Optional pagination parameters (limit, offset). 4215 * @returns Paginated chunk entries for this item. 4216 */ 4217 chunks(params?: AiSearchItemChunksParams): Promise<AiSearchItemChunksResponse>; 4218 } 4219 /** 4220 * Items collection service for an AI Search instance. 4221 * Provides list, upload, and access to individual items. 4222 */ 4223 declare abstract class AiSearchItems { 4224 /** List items in this instance. */ 4225 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>; 4226 /** 4227 * Upload a file as an item. Behaves as an upsert: if an item with the same 4228 * filename already exists, it is overwritten and re-indexed. 4229 * @param name Filename for the uploaded item. 4230 * @param content File content as a ReadableStream, Blob, or string. 4231 * @param options Optional metadata to attach to the item. 4232 * @returns The created item info. 4233 */ 4234 upload(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions): Promise<AiSearchItemInfo>; 4235 /** 4236 * Upload a file and poll until processing completes. 4237 * Behaves as an upsert: if an item with the same filename already exists, 4238 * it is overwritten and re-indexed. 4239 * @param name Filename for the uploaded item. 4240 * @param content File content as a ReadableStream, Blob, or string. 4241 * @param options Optional metadata and polling configuration. 4242 * @returns The item info after processing completes (or timeout). 4243 */ 4244 uploadAndPoll(name: string, content: ReadableStream | Blob | string, options?: AiSearchUploadItemOptions & { 4245 /** Polling interval in milliseconds (default 1000). */ 4246 pollIntervalMs?: number; 4247 /** Maximum time to wait in milliseconds (default 30000). */ 4248 timeoutMs?: number; 4249 }): Promise<AiSearchItemInfo>; 4250 /** 4251 * Get an item by ID. 4252 * @param itemId The item identifier. 4253 * @returns Item service for info, download, sync, logs, and chunks operations. 4254 */ 4255 get(itemId: string): AiSearchItem; 4256 /** 4257 * Delete an item from the instance. 4258 * @param itemId The item identifier. 4259 */ 4260 delete(itemId: string): Promise<void>; 4261 } 4262 /** 4263 * Single job service for an AI Search instance. 4264 * Provides info, logs, and cancel operations for a specific job. 4265 */ 4266 declare abstract class AiSearchJob { 4267 /** Get metadata about this job. */ 4268 info(): Promise<AiSearchJobInfo>; 4269 /** Get logs for this job. */ 4270 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>; 4271 /** 4272 * Cancel a running job. 4273 * @returns The updated job info. 4274 * @throws AiSearchNotFoundError if the job does not exist. 4275 */ 4276 cancel(): Promise<AiSearchJobInfo>; 4277 } 4278 /** 4279 * Jobs collection service for an AI Search instance. 4280 * Provides list, create, and access to individual jobs. 4281 */ 4282 declare abstract class AiSearchJobs { 4283 /** List jobs for this instance. */ 4284 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>; 4285 /** 4286 * Create a new indexing job. 4287 * @param params Optional job parameters. 4288 * @returns The created job info. 4289 */ 4290 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>; 4291 /** 4292 * Get a job by ID. 4293 * @param jobId The job identifier. 4294 * @returns Job service for info, logs, and cancel operations. 4295 */ 4296 get(jobId: string): AiSearchJob; 4297 } 4298 // ============ AI Search Binding Classes ============ 4299 /** 4300 * Instance-level AI Search service. 4301 * 4302 * Used as: 4303 * - The return type of `AiSearchNamespace.get(name)` (namespace binding) 4304 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`) 4305 * 4306 * Provides search, chat, update, stats, items, and jobs operations. 4307 * 4308 * @example 4309 * ```ts 4310 * // Via namespace binding 4311 * const instance = env.AI_SEARCH.get("blog"); 4312 * const results = await instance.search({ 4313 * query: "How does caching work?", 4314 * }); 4315 * 4316 * // Via single instance binding 4317 * const results = await env.BLOG_SEARCH.search({ 4318 * messages: [{ role: "user", content: "How does caching work?" }], 4319 * }); 4320 * ``` 4321 */ 4322 declare abstract class AiSearchInstance { 4323 /** 4324 * Search the AI Search instance for relevant chunks. 4325 * @param params Search request with query or messages and optional AI search options. 4326 * @returns Search response with matching chunks and search query. 4327 */ 4328 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>; 4329 /** 4330 * Generate chat completions with AI Search context (streaming). 4331 * @param params Chat completions request with stream: true. 4332 * @returns ReadableStream of server-sent events. 4333 */ 4334 chatCompletions(params: AiSearchChatCompletionsRequest & { 4335 stream: true; 4336 }): Promise<ReadableStream>; 4337 /** 4338 * Generate chat completions with AI Search context. 4339 * @param params Chat completions request. 4340 * @returns Chat completion response with choices and RAG chunks. 4341 */ 4342 chatCompletions(params: AiSearchChatCompletionsRequest): Promise<AiSearchChatCompletionsResponse>; 4343 /** 4344 * Update the instance configuration. 4345 * @param config Partial configuration to update. 4346 * @returns Updated instance info. 4347 */ 4348 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>; 4349 /** Get metadata about this instance. */ 4350 info(): Promise<AiSearchInstanceInfo>; 4351 /** 4352 * Get instance statistics (item count, indexing status, etc.). 4353 * @returns Statistics with counts per status, last activity time, and engine details. 4354 */ 4355 stats(): Promise<AiSearchStatsResponse>; 4356 /** Items collection — list, upload, and manage items in this instance. */ 4357 get items(): AiSearchItems; 4358 /** Jobs collection — list, create, and inspect indexing jobs. */ 4359 get jobs(): AiSearchJobs; 4360 } 4361 /** 4362 * Namespace-level AI Search service. 4363 * 4364 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`). 4365 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion, 4366 * and multi-instance search/chat operations. 4367 * 4368 * @example 4369 * ```ts 4370 * // Access an instance within the namespace 4371 * const blog = env.AI_SEARCH.get("blog"); 4372 * const results = await blog.search({ query: "How does caching work?" }); 4373 * 4374 * // List all instances in the namespace 4375 * const instances = await env.AI_SEARCH.list(); 4376 * 4377 * // Create a new instance with built-in storage 4378 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" }); 4379 * 4380 * // Upload items into the instance 4381 * await tenant.items.upload("doc.pdf", fileContent); 4382 * 4383 * // Search across multiple instances 4384 * const multi = await env.AI_SEARCH.search({ 4385 * query: "caching", 4386 * ai_search_options: { instance_ids: ["blog", "docs"] }, 4387 * }); 4388 * 4389 * // Delete an instance 4390 * await env.AI_SEARCH.delete("tenant-123"); 4391 * ``` 4392 */ 4393 declare abstract class AiSearchNamespace { 4394 /** 4395 * Get an instance by name within the bound namespace. 4396 * @param name Instance name. 4397 * @returns Instance service for search, chat, update, stats, items, and jobs. 4398 */ 4399 get(name: string): AiSearchInstance; 4400 /** 4401 * List instances in the bound namespace. 4402 * @param params Optional pagination, search, and ordering parameters. 4403 * @returns Array of instance metadata with pagination info. 4404 */ 4405 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>; 4406 /** 4407 * Create a new instance within the bound namespace. 4408 * @param config Instance configuration. Only `id` is required — omit `type` and `source` to create with built-in storage. 4409 * @returns Instance service for the newly created instance. 4410 * 4411 * @example 4412 * ```ts 4413 * // Create with built-in storage (upload items manually) 4414 * const instance = await env.AI_SEARCH.create({ id: "my-search" }); 4415 * 4416 * // Create with web crawler source 4417 * const instance = await env.AI_SEARCH.create({ 4418 * id: "docs-search", 4419 * type: "web-crawler", 4420 * source: "https://developers.cloudflare.com", 4421 * }); 4422 * ``` 4423 */ 4424 create(config: AiSearchConfig): Promise<AiSearchInstance>; 4425 /** 4426 * Delete an instance from the bound namespace. 4427 * @param name Instance name to delete. 4428 */ 4429 delete(name: string): Promise<void>; 4430 /** 4431 * Search across multiple instances within the bound namespace. 4432 * Fans out to the specified instance_ids and merges results. 4433 * @param params Search request with required `ai_search_options.instance_ids`. 4434 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors. 4435 */ 4436 search(params: AiSearchMultiSearchRequest): Promise<AiSearchMultiSearchResponse>; 4437 /** 4438 * Generate chat completions across multiple instances within the bound namespace (streaming). 4439 * Fans out to the specified instance_ids, merges context, and generates a response. 4440 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`. 4441 * @returns ReadableStream of server-sent events. 4442 */ 4443 chatCompletions(params: AiSearchMultiChatCompletionsRequest & { 4444 stream: true; 4445 }): Promise<ReadableStream>; 4446 /** 4447 * Generate chat completions across multiple instances within the bound namespace. 4448 * Fans out to the specified instance_ids, merges context, and generates a response. 4449 * @param params Chat completions request with required `ai_search_options.instance_ids`. 4450 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors. 4451 */ 4452 chatCompletions(params: AiSearchMultiChatCompletionsRequest): Promise<AiSearchMultiChatCompletionsResponse>; 4453 } 4454 type AiImageClassificationInput = { 4455 image: number[]; 4456 }; 4457 type AiImageClassificationOutput = { 4458 score?: number; 4459 label?: string; 4460 }[]; 4461 declare abstract class BaseAiImageClassification { 4462 inputs: AiImageClassificationInput; 4463 postProcessedOutputs: AiImageClassificationOutput; 4464 } 4465 type AiImageToTextInput = { 4466 image: number[]; 4467 prompt?: string; 4468 max_tokens?: number; 4469 temperature?: number; 4470 top_p?: number; 4471 top_k?: number; 4472 seed?: number; 4473 repetition_penalty?: number; 4474 frequency_penalty?: number; 4475 presence_penalty?: number; 4476 raw?: boolean; 4477 messages?: RoleScopedChatInput[]; 4478 }; 4479 type AiImageToTextOutput = { 4480 description: string; 4481 }; 4482 declare abstract class BaseAiImageToText { 4483 inputs: AiImageToTextInput; 4484 postProcessedOutputs: AiImageToTextOutput; 4485 } 4486 type AiImageTextToTextInput = { 4487 image: string; 4488 prompt?: string; 4489 max_tokens?: number; 4490 temperature?: number; 4491 ignore_eos?: boolean; 4492 top_p?: number; 4493 top_k?: number; 4494 seed?: number; 4495 repetition_penalty?: number; 4496 frequency_penalty?: number; 4497 presence_penalty?: number; 4498 raw?: boolean; 4499 messages?: RoleScopedChatInput[]; 4500 }; 4501 type AiImageTextToTextOutput = { 4502 description: string; 4503 }; 4504 declare abstract class BaseAiImageTextToText { 4505 inputs: AiImageTextToTextInput; 4506 postProcessedOutputs: AiImageTextToTextOutput; 4507 } 4508 type AiMultimodalEmbeddingsInput = { 4509 image: string; 4510 text: string[]; 4511 }; 4512 type AiIMultimodalEmbeddingsOutput = { 4513 data: number[][]; 4514 shape: number[]; 4515 }; 4516 declare abstract class BaseAiMultimodalEmbeddings { 4517 inputs: AiImageTextToTextInput; 4518 postProcessedOutputs: AiImageTextToTextOutput; 4519 } 4520 type AiObjectDetectionInput = { 4521 image: number[]; 4522 }; 4523 type AiObjectDetectionOutput = { 4524 score?: number; 4525 label?: string; 4526 }[]; 4527 declare abstract class BaseAiObjectDetection { 4528 inputs: AiObjectDetectionInput; 4529 postProcessedOutputs: AiObjectDetectionOutput; 4530 } 4531 type AiSentenceSimilarityInput = { 4532 source: string; 4533 sentences: string[]; 4534 }; 4535 type AiSentenceSimilarityOutput = number[]; 4536 declare abstract class BaseAiSentenceSimilarity { 4537 inputs: AiSentenceSimilarityInput; 4538 postProcessedOutputs: AiSentenceSimilarityOutput; 4539 } 4540 type AiAutomaticSpeechRecognitionInput = { 4541 audio: number[]; 4542 }; 4543 type AiAutomaticSpeechRecognitionOutput = { 4544 text?: string; 4545 words?: { 4546 word: string; 4547 start: number; 4548 end: number; 4549 }[]; 4550 vtt?: string; 4551 }; 4552 declare abstract class BaseAiAutomaticSpeechRecognition { 4553 inputs: AiAutomaticSpeechRecognitionInput; 4554 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput; 4555 } 4556 type AiSummarizationInput = { 4557 input_text: string; 4558 max_length?: number; 4559 }; 4560 type AiSummarizationOutput = { 4561 summary: string; 4562 }; 4563 declare abstract class BaseAiSummarization { 4564 inputs: AiSummarizationInput; 4565 postProcessedOutputs: AiSummarizationOutput; 4566 } 4567 type AiTextClassificationInput = { 4568 text: string; 4569 }; 4570 type AiTextClassificationOutput = { 4571 score?: number; 4572 label?: string; 4573 }[]; 4574 declare abstract class BaseAiTextClassification { 4575 inputs: AiTextClassificationInput; 4576 postProcessedOutputs: AiTextClassificationOutput; 4577 } 4578 type AiTextEmbeddingsInput = { 4579 text: string | string[]; 4580 }; 4581 type AiTextEmbeddingsOutput = { 4582 shape: number[]; 4583 data: number[][]; 4584 }; 4585 declare abstract class BaseAiTextEmbeddings { 4586 inputs: AiTextEmbeddingsInput; 4587 postProcessedOutputs: AiTextEmbeddingsOutput; 4588 } 4589 type RoleScopedChatInput = { 4590 role: "user" | "assistant" | "system" | "tool" | (string & NonNullable<unknown>); 4591 content: string; 4592 name?: string; 4593 }; 4594 type AiTextGenerationToolLegacyInput = { 4595 name: string; 4596 description: string; 4597 parameters?: { 4598 type: "object" | (string & NonNullable<unknown>); 4599 properties: { 4600 [key: string]: { 4601 type: string; 4602 description?: string; 4603 }; 4604 }; 4605 required: string[]; 4606 }; 4607 }; 4608 type AiTextGenerationToolInput = { 4609 type: "function" | (string & NonNullable<unknown>); 4610 function: { 4611 name: string; 4612 description: string; 4613 parameters?: { 4614 type: "object" | (string & NonNullable<unknown>); 4615 properties: { 4616 [key: string]: { 4617 type: string; 4618 description?: string; 4619 }; 4620 }; 4621 required: string[]; 4622 }; 4623 }; 4624 }; 4625 type AiTextGenerationFunctionsInput = { 4626 name: string; 4627 code: string; 4628 }; 4629 type AiTextGenerationResponseFormat = { 4630 type: string; 4631 json_schema?: any; 4632 }; 4633 type AiTextGenerationInput = { 4634 prompt?: string; 4635 raw?: boolean; 4636 stream?: boolean; 4637 max_tokens?: number; 4638 temperature?: number; 4639 top_p?: number; 4640 top_k?: number; 4641 seed?: number; 4642 repetition_penalty?: number; 4643 frequency_penalty?: number; 4644 presence_penalty?: number; 4645 messages?: RoleScopedChatInput[]; 4646 response_format?: AiTextGenerationResponseFormat; 4647 tools?: AiTextGenerationToolInput[] | AiTextGenerationToolLegacyInput[] | (object & NonNullable<unknown>); 4648 functions?: AiTextGenerationFunctionsInput[]; 4649 }; 4650 type AiTextGenerationToolLegacyOutput = { 4651 name: string; 4652 arguments: unknown; 4653 }; 4654 type AiTextGenerationToolOutput = { 4655 id: string; 4656 type: "function"; 4657 function: { 4658 name: string; 4659 arguments: string; 4660 }; 4661 }; 4662 type UsageTags = { 4663 prompt_tokens: number; 4664 completion_tokens: number; 4665 total_tokens: number; 4666 }; 4667 type AiTextGenerationOutput = { 4668 response?: string; 4669 tool_calls?: AiTextGenerationToolLegacyOutput[] & AiTextGenerationToolOutput[]; 4670 usage?: UsageTags; 4671 }; 4672 declare abstract class BaseAiTextGeneration { 4673 inputs: AiTextGenerationInput; 4674 postProcessedOutputs: AiTextGenerationOutput; 4675 } 4676 type AiTextToSpeechInput = { 4677 prompt: string; 4678 lang?: string; 4679 }; 4680 type AiTextToSpeechOutput = Uint8Array | { 4681 audio: string; 4682 }; 4683 declare abstract class BaseAiTextToSpeech { 4684 inputs: AiTextToSpeechInput; 4685 postProcessedOutputs: AiTextToSpeechOutput; 4686 } 4687 type AiTextToImageInput = { 4688 prompt: string; 4689 negative_prompt?: string; 4690 height?: number; 4691 width?: number; 4692 image?: number[]; 4693 image_b64?: string; 4694 mask?: number[]; 4695 num_steps?: number; 4696 strength?: number; 4697 guidance?: number; 4698 seed?: number; 4699 }; 4700 type AiTextToImageOutput = ReadableStream<Uint8Array>; 4701 declare abstract class BaseAiTextToImage { 4702 inputs: AiTextToImageInput; 4703 postProcessedOutputs: AiTextToImageOutput; 4704 } 4705 type AiTranslationInput = { 4706 text: string; 4707 target_lang: string; 4708 source_lang?: string; 4709 }; 4710 type AiTranslationOutput = { 4711 translated_text?: string; 4712 }; 4713 declare abstract class BaseAiTranslation { 4714 inputs: AiTranslationInput; 4715 postProcessedOutputs: AiTranslationOutput; 4716 } 4717 /** 4718 * Workers AI support for OpenAI's Chat Completions API 4719 */ 4720 type ChatCompletionContentPartText = { 4721 type: "text"; 4722 text: string; 4723 }; 4724 type ChatCompletionContentPartImage = { 4725 type: "image_url"; 4726 image_url: { 4727 url: string; 4728 detail?: "auto" | "low" | "high"; 4729 }; 4730 }; 4731 type ChatCompletionContentPartInputAudio = { 4732 type: "input_audio"; 4733 input_audio: { 4734 /** Base64 encoded audio data. */ 4735 data: string; 4736 format: "wav" | "mp3"; 4737 }; 4738 }; 4739 type ChatCompletionContentPartFile = { 4740 type: "file"; 4741 file: { 4742 /** Base64 encoded file data. */ 4743 file_data?: string; 4744 /** The ID of an uploaded file. */ 4745 file_id?: string; 4746 filename?: string; 4747 }; 4748 }; 4749 type ChatCompletionContentPartRefusal = { 4750 type: "refusal"; 4751 refusal: string; 4752 }; 4753 type ChatCompletionContentPart = ChatCompletionContentPartText | ChatCompletionContentPartImage | ChatCompletionContentPartInputAudio | ChatCompletionContentPartFile; 4754 type FunctionDefinition = { 4755 name: string; 4756 description?: string; 4757 parameters?: Record<string, unknown>; 4758 strict?: boolean | null; 4759 }; 4760 type ChatCompletionFunctionTool = { 4761 type: "function"; 4762 function: FunctionDefinition; 4763 }; 4764 type ChatCompletionCustomToolGrammarFormat = { 4765 type: "grammar"; 4766 grammar: { 4767 definition: string; 4768 syntax: "lark" | "regex"; 4769 }; 4770 }; 4771 type ChatCompletionCustomToolTextFormat = { 4772 type: "text"; 4773 }; 4774 type ChatCompletionCustomToolFormat = ChatCompletionCustomToolTextFormat | ChatCompletionCustomToolGrammarFormat; 4775 type ChatCompletionCustomTool = { 4776 type: "custom"; 4777 custom: { 4778 name: string; 4779 description?: string; 4780 format?: ChatCompletionCustomToolFormat; 4781 }; 4782 }; 4783 type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool; 4784 type ChatCompletionMessageFunctionToolCall = { 4785 id: string; 4786 type: "function"; 4787 function: { 4788 name: string; 4789 /** JSON-encoded arguments string. */ 4790 arguments: string; 4791 }; 4792 }; 4793 type ChatCompletionMessageCustomToolCall = { 4794 id: string; 4795 type: "custom"; 4796 custom: { 4797 name: string; 4798 input: string; 4799 }; 4800 }; 4801 type ChatCompletionMessageToolCall = ChatCompletionMessageFunctionToolCall | ChatCompletionMessageCustomToolCall; 4802 type ChatCompletionToolChoiceFunction = { 4803 type: "function"; 4804 function: { 4805 name: string; 4806 }; 4807 }; 4808 type ChatCompletionToolChoiceCustom = { 4809 type: "custom"; 4810 custom: { 4811 name: string; 4812 }; 4813 }; 4814 type ChatCompletionToolChoiceAllowedTools = { 4815 type: "allowed_tools"; 4816 allowed_tools: { 4817 mode: "auto" | "required"; 4818 tools: Array<Record<string, unknown>>; 4819 }; 4820 }; 4821 type ChatCompletionToolChoiceOption = "none" | "auto" | "required" | ChatCompletionToolChoiceFunction | ChatCompletionToolChoiceCustom | ChatCompletionToolChoiceAllowedTools; 4822 type DeveloperMessage = { 4823 role: "developer"; 4824 content: string | Array<{ 4825 type: "text"; 4826 text: string; 4827 }>; 4828 name?: string; 4829 }; 4830 type SystemMessage = { 4831 role: "system"; 4832 content: string | Array<{ 4833 type: "text"; 4834 text: string; 4835 }>; 4836 name?: string; 4837 }; 4838 /** 4839 * Permissive merged content part used inside UserMessage arrays. 4840 * 4841 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination 4842 * inside nested array items does not correctly match different branches for 4843 * different array elements, so the schema uses a single merged object. 4844 */ 4845 type UserMessageContentPart = { 4846 type: "text" | "image_url" | "input_audio" | "file"; 4847 text?: string; 4848 image_url?: { 4849 url?: string; 4850 detail?: "auto" | "low" | "high"; 4851 }; 4852 input_audio?: { 4853 data?: string; 4854 format?: "wav" | "mp3"; 4855 }; 4856 file?: { 4857 file_data?: string; 4858 file_id?: string; 4859 filename?: string; 4860 }; 4861 }; 4862 type UserMessage = { 4863 role: "user"; 4864 content: string | Array<UserMessageContentPart>; 4865 name?: string; 4866 }; 4867 type AssistantMessageContentPart = { 4868 type: "text" | "refusal"; 4869 text?: string; 4870 refusal?: string; 4871 }; 4872 type AssistantMessage = { 4873 role: "assistant"; 4874 content?: string | null | Array<AssistantMessageContentPart>; 4875 refusal?: string | null; 4876 name?: string; 4877 audio?: { 4878 id: string; 4879 }; 4880 tool_calls?: Array<ChatCompletionMessageToolCall>; 4881 function_call?: { 4882 name: string; 4883 arguments: string; 4884 }; 4885 }; 4886 type ToolMessage = { 4887 role: "tool"; 4888 content: string | Array<{ 4889 type: "text"; 4890 text: string; 4891 }>; 4892 tool_call_id: string; 4893 }; 4894 type FunctionMessage = { 4895 role: "function"; 4896 content: string; 4897 name: string; 4898 }; 4899 type ChatCompletionMessageParam = DeveloperMessage | SystemMessage | UserMessage | AssistantMessage | ToolMessage | FunctionMessage; 4900 type ChatCompletionsResponseFormatText = { 4901 type: "text"; 4902 }; 4903 type ChatCompletionsResponseFormatJSONObject = { 4904 type: "json_object"; 4905 }; 4906 type ResponseFormatJSONSchema = { 4907 type: "json_schema"; 4908 json_schema: { 4909 name: string; 4910 description?: string; 4911 schema?: Record<string, unknown>; 4912 strict?: boolean | null; 4913 }; 4914 }; 4915 type ResponseFormat = ChatCompletionsResponseFormatText | ChatCompletionsResponseFormatJSONObject | ResponseFormatJSONSchema; 4916 type ChatCompletionsStreamOptions = { 4917 include_usage?: boolean; 4918 include_obfuscation?: boolean; 4919 }; 4920 type PredictionContent = { 4921 type: "content"; 4922 content: string | Array<{ 4923 type: "text"; 4924 text: string; 4925 }>; 4926 }; 4927 type AudioParams = { 4928 voice: string | { 4929 id: string; 4930 }; 4931 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16"; 4932 }; 4933 type WebSearchUserLocation = { 4934 type: "approximate"; 4935 approximate: { 4936 city?: string; 4937 country?: string; 4938 region?: string; 4939 timezone?: string; 4940 }; 4941 }; 4942 type WebSearchOptions = { 4943 search_context_size?: "low" | "medium" | "high"; 4944 user_location?: WebSearchUserLocation; 4945 }; 4946 type ChatTemplateKwargs = { 4947 /** Whether to enable reasoning, enabled by default. */ 4948 enable_thinking?: boolean; 4949 /** If false, preserves reasoning context between turns. */ 4950 clear_thinking?: boolean; 4951 }; 4952 /** Shared optional properties used by both Prompt and Messages input branches. */ 4953 type ChatCompletionsCommonOptions = { 4954 model?: string; 4955 audio?: AudioParams; 4956 frequency_penalty?: number | null; 4957 logit_bias?: Record<string, unknown> | null; 4958 logprobs?: boolean | null; 4959 top_logprobs?: number | null; 4960 max_tokens?: number | null; 4961 max_completion_tokens?: number | null; 4962 metadata?: Record<string, unknown> | null; 4963 modalities?: Array<"text" | "audio"> | null; 4964 n?: number | null; 4965 parallel_tool_calls?: boolean; 4966 prediction?: PredictionContent; 4967 presence_penalty?: number | null; 4968 reasoning_effort?: "low" | "medium" | "high" | null; 4969 chat_template_kwargs?: ChatTemplateKwargs; 4970 response_format?: ResponseFormat; 4971 seed?: number | null; 4972 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 4973 stop?: string | Array<string> | null; 4974 store?: boolean | null; 4975 stream?: boolean | null; 4976 stream_options?: ChatCompletionsStreamOptions; 4977 temperature?: number | null; 4978 tool_choice?: ChatCompletionToolChoiceOption; 4979 tools?: Array<ChatCompletionTool>; 4980 top_p?: number | null; 4981 user?: string; 4982 web_search_options?: WebSearchOptions; 4983 function_call?: "none" | "auto" | { 4984 name: string; 4985 }; 4986 functions?: Array<FunctionDefinition>; 4987 }; 4988 type PromptTokensDetails = { 4989 cached_tokens?: number; 4990 audio_tokens?: number; 4991 }; 4992 type CompletionTokensDetails = { 4993 reasoning_tokens?: number; 4994 audio_tokens?: number; 4995 accepted_prediction_tokens?: number; 4996 rejected_prediction_tokens?: number; 4997 }; 4998 type CompletionUsage = { 4999 prompt_tokens: number; 5000 completion_tokens: number; 5001 total_tokens: number; 5002 prompt_tokens_details?: PromptTokensDetails; 5003 completion_tokens_details?: CompletionTokensDetails; 5004 }; 5005 type ChatCompletionTopLogprob = { 5006 token: string; 5007 logprob: number; 5008 bytes: Array<number> | null; 5009 }; 5010 type ChatCompletionTokenLogprob = { 5011 token: string; 5012 logprob: number; 5013 bytes: Array<number> | null; 5014 top_logprobs: Array<ChatCompletionTopLogprob>; 5015 }; 5016 type ChatCompletionAudio = { 5017 id: string; 5018 /** Base64 encoded audio bytes. */ 5019 data: string; 5020 expires_at: number; 5021 transcript: string; 5022 }; 5023 type ChatCompletionUrlCitation = { 5024 type: "url_citation"; 5025 url_citation: { 5026 url: string; 5027 title: string; 5028 start_index: number; 5029 end_index: number; 5030 }; 5031 }; 5032 type ChatCompletionResponseMessage = { 5033 role: "assistant"; 5034 content: string | null; 5035 refusal: string | null; 5036 annotations?: Array<ChatCompletionUrlCitation>; 5037 audio?: ChatCompletionAudio; 5038 tool_calls?: Array<ChatCompletionMessageToolCall>; 5039 function_call?: { 5040 name: string; 5041 arguments: string; 5042 } | null; 5043 }; 5044 type ChatCompletionLogprobs = { 5045 content: Array<ChatCompletionTokenLogprob> | null; 5046 refusal?: Array<ChatCompletionTokenLogprob> | null; 5047 }; 5048 type ChatCompletionChoice = { 5049 index: number; 5050 message: ChatCompletionResponseMessage; 5051 finish_reason: "stop" | "length" | "tool_calls" | "content_filter" | "function_call"; 5052 logprobs: ChatCompletionLogprobs | null; 5053 }; 5054 type ChatCompletionsMessagesInput = { 5055 messages: Array<ChatCompletionMessageParam>; 5056 } & ChatCompletionsCommonOptions; 5057 type ChatCompletionsOutput = { 5058 id: string; 5059 object: string; 5060 created: number; 5061 model: string; 5062 choices: Array<ChatCompletionChoice>; 5063 usage?: CompletionUsage; 5064 system_fingerprint?: string | null; 5065 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 5066 }; 5067 /** 5068 * Workers AI support for OpenAI's Responses API 5069 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts 5070 * 5071 * It's a stripped down version from its source. 5072 * It currently supports basic function calling, json mode and accepts images as input. 5073 * 5074 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools. 5075 * We plan to add those incrementally as model + platform capabilities evolve. 5076 */ 5077 type ResponsesInput = { 5078 background?: boolean | null; 5079 conversation?: string | ResponseConversationParam | null; 5080 include?: Array<ResponseIncludable> | null; 5081 input?: string | ResponseInput; 5082 instructions?: string | null; 5083 max_output_tokens?: number | null; 5084 parallel_tool_calls?: boolean | null; 5085 previous_response_id?: string | null; 5086 prompt_cache_key?: string; 5087 reasoning?: Reasoning | null; 5088 safety_identifier?: string; 5089 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 5090 stream?: boolean | null; 5091 stream_options?: StreamOptions | null; 5092 temperature?: number | null; 5093 text?: ResponseTextConfig; 5094 tool_choice?: ToolChoiceOptions | ToolChoiceFunction; 5095 tools?: Array<Tool>; 5096 top_p?: number | null; 5097 truncation?: "auto" | "disabled" | null; 5098 }; 5099 type ResponsesOutput = { 5100 id?: string; 5101 created_at?: number; 5102 output_text?: string; 5103 error?: ResponseError | null; 5104 incomplete_details?: ResponseIncompleteDetails | null; 5105 instructions?: string | Array<ResponseInputItem> | null; 5106 object?: "response"; 5107 output?: Array<ResponseOutputItem>; 5108 parallel_tool_calls?: boolean; 5109 temperature?: number | null; 5110 tool_choice?: ToolChoiceOptions | ToolChoiceFunction; 5111 tools?: Array<Tool>; 5112 top_p?: number | null; 5113 max_output_tokens?: number | null; 5114 previous_response_id?: string | null; 5115 prompt?: ResponsePrompt | null; 5116 reasoning?: Reasoning | null; 5117 safety_identifier?: string; 5118 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null; 5119 status?: ResponseStatus; 5120 text?: ResponseTextConfig; 5121 truncation?: "auto" | "disabled" | null; 5122 usage?: ResponseUsage; 5123 }; 5124 type EasyInputMessage = { 5125 content: string | ResponseInputMessageContentList; 5126 role: "user" | "assistant" | "system" | "developer"; 5127 type?: "message"; 5128 }; 5129 type ResponsesFunctionTool = { 5130 name: string; 5131 parameters: { 5132 [key: string]: unknown; 5133 } | null; 5134 strict: boolean | null; 5135 type: "function"; 5136 description?: string | null; 5137 }; 5138 type ResponseIncompleteDetails = { 5139 reason?: "max_output_tokens" | "content_filter"; 5140 }; 5141 type ResponsePrompt = { 5142 id: string; 5143 variables?: { 5144 [key: string]: string | ResponseInputText | ResponseInputImage; 5145 } | null; 5146 version?: string | null; 5147 }; 5148 type Reasoning = { 5149 effort?: ReasoningEffort | null; 5150 generate_summary?: "auto" | "concise" | "detailed" | null; 5151 summary?: "auto" | "concise" | "detailed" | null; 5152 }; 5153 type ResponseContent = ResponseInputText | ResponseInputImage | ResponseOutputText | ResponseOutputRefusal | ResponseContentReasoningText; 5154 type ResponseContentReasoningText = { 5155 text: string; 5156 type: "reasoning_text"; 5157 }; 5158 type ResponseConversationParam = { 5159 id: string; 5160 }; 5161 type ResponseCreatedEvent = { 5162 response: Response; 5163 sequence_number: number; 5164 type: "response.created"; 5165 }; 5166 type ResponseCustomToolCallOutput = { 5167 call_id: string; 5168 output: string | Array<ResponseInputText | ResponseInputImage>; 5169 type: "custom_tool_call_output"; 5170 id?: string; 5171 }; 5172 type ResponseError = { 5173 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"; 5174 message: string; 5175 }; 5176 type ResponseErrorEvent = { 5177 code: string | null; 5178 message: string; 5179 param: string | null; 5180 sequence_number: number; 5181 type: "error"; 5182 }; 5183 type ResponseFailedEvent = { 5184 response: Response; 5185 sequence_number: number; 5186 type: "response.failed"; 5187 }; 5188 type ResponseFormatText = { 5189 type: "text"; 5190 }; 5191 type ResponseFormatJSONObject = { 5192 type: "json_object"; 5193 }; 5194 type ResponseFormatTextConfig = ResponseFormatText | ResponseFormatTextJSONSchemaConfig | ResponseFormatJSONObject; 5195 type ResponseFormatTextJSONSchemaConfig = { 5196 name: string; 5197 schema: { 5198 [key: string]: unknown; 5199 }; 5200 type: "json_schema"; 5201 description?: string; 5202 strict?: boolean | null; 5203 }; 5204 type ResponseFunctionCallArgumentsDeltaEvent = { 5205 delta: string; 5206 item_id: string; 5207 output_index: number; 5208 sequence_number: number; 5209 type: "response.function_call_arguments.delta"; 5210 }; 5211 type ResponseFunctionCallArgumentsDoneEvent = { 5212 arguments: string; 5213 item_id: string; 5214 name: string; 5215 output_index: number; 5216 sequence_number: number; 5217 type: "response.function_call_arguments.done"; 5218 }; 5219 type ResponseFunctionCallOutputItem = ResponseInputTextContent | ResponseInputImageContent; 5220 type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>; 5221 type ResponseFunctionToolCall = { 5222 arguments: string; 5223 call_id: string; 5224 name: string; 5225 type: "function_call"; 5226 id?: string; 5227 status?: "in_progress" | "completed" | "incomplete"; 5228 }; 5229 interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall { 5230 id: string; 5231 } 5232 type ResponseFunctionToolCallOutputItem = { 5233 id: string; 5234 call_id: string; 5235 output: string | Array<ResponseInputText | ResponseInputImage>; 5236 type: "function_call_output"; 5237 status?: "in_progress" | "completed" | "incomplete"; 5238 }; 5239 type ResponseIncludable = "message.input_image.image_url" | "message.output_text.logprobs"; 5240 type ResponseIncompleteEvent = { 5241 response: Response; 5242 sequence_number: number; 5243 type: "response.incomplete"; 5244 }; 5245 type ResponseInput = Array<ResponseInputItem>; 5246 type ResponseInputContent = ResponseInputText | ResponseInputImage; 5247 type ResponseInputImage = { 5248 detail: "low" | "high" | "auto"; 5249 type: "input_image"; 5250 /** 5251 * Base64 encoded image 5252 */ 5253 image_url?: string | null; 5254 }; 5255 type ResponseInputImageContent = { 5256 type: "input_image"; 5257 detail?: "low" | "high" | "auto" | null; 5258 /** 5259 * Base64 encoded image 5260 */ 5261 image_url?: string | null; 5262 }; 5263 type ResponseInputItem = EasyInputMessage | ResponseInputItemMessage | ResponseOutputMessage | ResponseFunctionToolCall | ResponseInputItemFunctionCallOutput | ResponseReasoningItem; 5264 type ResponseInputItemFunctionCallOutput = { 5265 call_id: string; 5266 output: string | ResponseFunctionCallOutputItemList; 5267 type: "function_call_output"; 5268 id?: string | null; 5269 status?: "in_progress" | "completed" | "incomplete" | null; 5270 }; 5271 type ResponseInputItemMessage = { 5272 content: ResponseInputMessageContentList; 5273 role: "user" | "system" | "developer"; 5274 status?: "in_progress" | "completed" | "incomplete"; 5275 type?: "message"; 5276 }; 5277 type ResponseInputMessageContentList = Array<ResponseInputContent>; 5278 type ResponseInputMessageItem = { 5279 id: string; 5280 content: ResponseInputMessageContentList; 5281 role: "user" | "system" | "developer"; 5282 status?: "in_progress" | "completed" | "incomplete"; 5283 type?: "message"; 5284 }; 5285 type ResponseInputText = { 5286 text: string; 5287 type: "input_text"; 5288 }; 5289 type ResponseInputTextContent = { 5290 text: string; 5291 type: "input_text"; 5292 }; 5293 type ResponseItem = ResponseInputMessageItem | ResponseOutputMessage | ResponseFunctionToolCallItem | ResponseFunctionToolCallOutputItem; 5294 type ResponseOutputItem = ResponseOutputMessage | ResponseFunctionToolCall | ResponseReasoningItem; 5295 type ResponseOutputItemAddedEvent = { 5296 item: ResponseOutputItem; 5297 output_index: number; 5298 sequence_number: number; 5299 type: "response.output_item.added"; 5300 }; 5301 type ResponseOutputItemDoneEvent = { 5302 item: ResponseOutputItem; 5303 output_index: number; 5304 sequence_number: number; 5305 type: "response.output_item.done"; 5306 }; 5307 type ResponseOutputMessage = { 5308 id: string; 5309 content: Array<ResponseOutputText | ResponseOutputRefusal>; 5310 role: "assistant"; 5311 status: "in_progress" | "completed" | "incomplete"; 5312 type: "message"; 5313 }; 5314 type ResponseOutputRefusal = { 5315 refusal: string; 5316 type: "refusal"; 5317 }; 5318 type ResponseOutputText = { 5319 text: string; 5320 type: "output_text"; 5321 logprobs?: Array<Logprob>; 5322 }; 5323 type ResponseReasoningItem = { 5324 id: string; 5325 summary: Array<ResponseReasoningSummaryItem>; 5326 type: "reasoning"; 5327 content?: Array<ResponseReasoningContentItem>; 5328 encrypted_content?: string | null; 5329 status?: "in_progress" | "completed" | "incomplete"; 5330 }; 5331 type ResponseReasoningSummaryItem = { 5332 text: string; 5333 type: "summary_text"; 5334 }; 5335 type ResponseReasoningContentItem = { 5336 text: string; 5337 type: "reasoning_text"; 5338 }; 5339 type ResponseReasoningTextDeltaEvent = { 5340 content_index: number; 5341 delta: string; 5342 item_id: string; 5343 output_index: number; 5344 sequence_number: number; 5345 type: "response.reasoning_text.delta"; 5346 }; 5347 type ResponseReasoningTextDoneEvent = { 5348 content_index: number; 5349 item_id: string; 5350 output_index: number; 5351 sequence_number: number; 5352 text: string; 5353 type: "response.reasoning_text.done"; 5354 }; 5355 type ResponseRefusalDeltaEvent = { 5356 content_index: number; 5357 delta: string; 5358 item_id: string; 5359 output_index: number; 5360 sequence_number: number; 5361 type: "response.refusal.delta"; 5362 }; 5363 type ResponseRefusalDoneEvent = { 5364 content_index: number; 5365 item_id: string; 5366 output_index: number; 5367 refusal: string; 5368 sequence_number: number; 5369 type: "response.refusal.done"; 5370 }; 5371 type ResponseStatus = "completed" | "failed" | "in_progress" | "cancelled" | "queued" | "incomplete"; 5372 type ResponseStreamEvent = ResponseCompletedEvent | ResponseCreatedEvent | ResponseErrorEvent | ResponseFunctionCallArgumentsDeltaEvent | ResponseFunctionCallArgumentsDoneEvent | ResponseFailedEvent | ResponseIncompleteEvent | ResponseOutputItemAddedEvent | ResponseOutputItemDoneEvent | ResponseReasoningTextDeltaEvent | ResponseReasoningTextDoneEvent | ResponseRefusalDeltaEvent | ResponseRefusalDoneEvent | ResponseTextDeltaEvent | ResponseTextDoneEvent; 5373 type ResponseCompletedEvent = { 5374 response: Response; 5375 sequence_number: number; 5376 type: "response.completed"; 5377 }; 5378 type ResponseTextConfig = { 5379 format?: ResponseFormatTextConfig; 5380 verbosity?: "low" | "medium" | "high" | null; 5381 }; 5382 type ResponseTextDeltaEvent = { 5383 content_index: number; 5384 delta: string; 5385 item_id: string; 5386 logprobs: Array<Logprob>; 5387 output_index: number; 5388 sequence_number: number; 5389 type: "response.output_text.delta"; 5390 }; 5391 type ResponseTextDoneEvent = { 5392 content_index: number; 5393 item_id: string; 5394 logprobs: Array<Logprob>; 5395 output_index: number; 5396 sequence_number: number; 5397 text: string; 5398 type: "response.output_text.done"; 5399 }; 5400 type Logprob = { 5401 token: string; 5402 logprob: number; 5403 top_logprobs?: Array<TopLogprob>; 5404 }; 5405 type TopLogprob = { 5406 token?: string; 5407 logprob?: number; 5408 }; 5409 type ResponseUsage = { 5410 input_tokens: number; 5411 output_tokens: number; 5412 total_tokens: number; 5413 }; 5414 type Tool = ResponsesFunctionTool; 5415 type ToolChoiceFunction = { 5416 name: string; 5417 type: "function"; 5418 }; 5419 type ToolChoiceOptions = "none"; 5420 type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null; 5421 type StreamOptions = { 5422 include_obfuscation?: boolean; 5423 }; 5424 /** Marks keys from T that aren't in U as optional never */ 5425 type Without<T, U> = { 5426 [P in Exclude<keyof T, keyof U>]?: never; 5427 }; 5428 /** Either T or U, but not both (mutually exclusive) */ 5429 type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>); 5430 type Ai_Cf_Baai_Bge_Base_En_V1_5_Input = { 5431 text: string | string[]; 5432 /** 5433 * 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. 5434 */ 5435 pooling?: "mean" | "cls"; 5436 } | { 5437 /** 5438 * Batch of the embeddings requests to run using async-queue 5439 */ 5440 requests: { 5441 text: string | string[]; 5442 /** 5443 * 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. 5444 */ 5445 pooling?: "mean" | "cls"; 5446 }[]; 5447 }; 5448 type Ai_Cf_Baai_Bge_Base_En_V1_5_Output = { 5449 shape?: number[]; 5450 /** 5451 * Embeddings of the requested text values 5452 */ 5453 data?: number[][]; 5454 /** 5455 * The pooling method used in the embedding process. 5456 */ 5457 pooling?: "mean" | "cls"; 5458 } | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse; 5459 interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse { 5460 /** 5461 * The async request id that can be used to obtain the results. 5462 */ 5463 request_id?: string; 5464 } 5465 declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 { 5466 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input; 5467 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output; 5468 } 5469 type Ai_Cf_Openai_Whisper_Input = string | { 5470 /** 5471 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values 5472 */ 5473 audio: number[]; 5474 }; 5475 interface Ai_Cf_Openai_Whisper_Output { 5476 /** 5477 * The transcription 5478 */ 5479 text: string; 5480 word_count?: number; 5481 words?: { 5482 word?: string; 5483 /** 5484 * The second this word begins in the recording 5485 */ 5486 start?: number; 5487 /** 5488 * The ending second when the word completes 5489 */ 5490 end?: number; 5491 }[]; 5492 vtt?: string; 5493 } 5494 declare abstract class Base_Ai_Cf_Openai_Whisper { 5495 inputs: Ai_Cf_Openai_Whisper_Input; 5496 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output; 5497 } 5498 type Ai_Cf_Meta_M2M100_1_2B_Input = { 5499 /** 5500 * The text to be translated 5501 */ 5502 text: string; 5503 /** 5504 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified 5505 */ 5506 source_lang?: string; 5507 /** 5508 * The language code to translate the text into (e.g., 'es' for Spanish) 5509 */ 5510 target_lang: string; 5511 } | { 5512 /** 5513 * Batch of the embeddings requests to run using async-queue 5514 */ 5515 requests: { 5516 /** 5517 * The text to be translated 5518 */ 5519 text: string; 5520 /** 5521 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified 5522 */ 5523 source_lang?: string; 5524 /** 5525 * The language code to translate the text into (e.g., 'es' for Spanish) 5526 */ 5527 target_lang: string; 5528 }[]; 5529 }; 5530 type Ai_Cf_Meta_M2M100_1_2B_Output = { 5531 /** 5532 * The translated text in the target language 5533 */ 5534 translated_text?: string; 5535 } | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse; 5536 interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse { 5537 /** 5538 * The async request id that can be used to obtain the results. 5539 */ 5540 request_id?: string; 5541 } 5542 declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B { 5543 inputs: Ai_Cf_Meta_M2M100_1_2B_Input; 5544 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output; 5545 } 5546 type Ai_Cf_Baai_Bge_Small_En_V1_5_Input = { 5547 text: string | string[]; 5548 /** 5549 * 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. 5550 */ 5551 pooling?: "mean" | "cls"; 5552 } | { 5553 /** 5554 * Batch of the embeddings requests to run using async-queue 5555 */ 5556 requests: { 5557 text: string | string[]; 5558 /** 5559 * 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. 5560 */ 5561 pooling?: "mean" | "cls"; 5562 }[]; 5563 }; 5564 type Ai_Cf_Baai_Bge_Small_En_V1_5_Output = { 5565 shape?: number[]; 5566 /** 5567 * Embeddings of the requested text values 5568 */ 5569 data?: number[][]; 5570 /** 5571 * The pooling method used in the embedding process. 5572 */ 5573 pooling?: "mean" | "cls"; 5574 } | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse; 5575 interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse { 5576 /** 5577 * The async request id that can be used to obtain the results. 5578 */ 5579 request_id?: string; 5580 } 5581 declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 { 5582 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input; 5583 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output; 5584 } 5585 type Ai_Cf_Baai_Bge_Large_En_V1_5_Input = { 5586 text: string | string[]; 5587 /** 5588 * 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. 5589 */ 5590 pooling?: "mean" | "cls"; 5591 } | { 5592 /** 5593 * Batch of the embeddings requests to run using async-queue 5594 */ 5595 requests: { 5596 text: string | string[]; 5597 /** 5598 * 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. 5599 */ 5600 pooling?: "mean" | "cls"; 5601 }[]; 5602 }; 5603 type Ai_Cf_Baai_Bge_Large_En_V1_5_Output = { 5604 shape?: number[]; 5605 /** 5606 * Embeddings of the requested text values 5607 */ 5608 data?: number[][]; 5609 /** 5610 * The pooling method used in the embedding process. 5611 */ 5612 pooling?: "mean" | "cls"; 5613 } | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse; 5614 interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse { 5615 /** 5616 * The async request id that can be used to obtain the results. 5617 */ 5618 request_id?: string; 5619 } 5620 declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 { 5621 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input; 5622 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output; 5623 } 5624 type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input = string | { 5625 /** 5626 * The input text prompt for the model to generate a response. 5627 */ 5628 prompt?: string; 5629 /** 5630 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 5631 */ 5632 raw?: boolean; 5633 /** 5634 * 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. 5635 */ 5636 top_p?: number; 5637 /** 5638 * 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. 5639 */ 5640 top_k?: number; 5641 /** 5642 * Random seed for reproducibility of the generation. 5643 */ 5644 seed?: number; 5645 /** 5646 * Penalty for repeated tokens; higher values discourage repetition. 5647 */ 5648 repetition_penalty?: number; 5649 /** 5650 * Decreases the likelihood of the model repeating the same lines verbatim. 5651 */ 5652 frequency_penalty?: number; 5653 /** 5654 * Increases the likelihood of the model introducing new topics. 5655 */ 5656 presence_penalty?: number; 5657 image: number[] | (string & NonNullable<unknown>); 5658 /** 5659 * The maximum number of tokens to generate in the response. 5660 */ 5661 max_tokens?: number; 5662 }; 5663 interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output { 5664 description?: string; 5665 } 5666 declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M { 5667 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input; 5668 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output; 5669 } 5670 type Ai_Cf_Openai_Whisper_Tiny_En_Input = string | { 5671 /** 5672 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values 5673 */ 5674 audio: number[]; 5675 }; 5676 interface Ai_Cf_Openai_Whisper_Tiny_En_Output { 5677 /** 5678 * The transcription 5679 */ 5680 text: string; 5681 word_count?: number; 5682 words?: { 5683 word?: string; 5684 /** 5685 * The second this word begins in the recording 5686 */ 5687 start?: number; 5688 /** 5689 * The ending second when the word completes 5690 */ 5691 end?: number; 5692 }[]; 5693 vtt?: string; 5694 } 5695 declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En { 5696 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input; 5697 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output; 5698 } 5699 interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input { 5700 audio: string | { 5701 body?: object; 5702 contentType?: string; 5703 }; 5704 /** 5705 * Supported tasks are 'translate' or 'transcribe'. 5706 */ 5707 task?: string; 5708 /** 5709 * The language of the audio being transcribed or translated. 5710 */ 5711 language?: string; 5712 /** 5713 * Preprocess the audio with a voice activity detection model. 5714 */ 5715 vad_filter?: boolean; 5716 /** 5717 * A text prompt to help provide context to the model on the contents of the audio. 5718 */ 5719 initial_prompt?: string; 5720 /** 5721 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result. 5722 */ 5723 prefix?: string; 5724 /** 5725 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed. 5726 */ 5727 beam_size?: number; 5728 /** 5729 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops. 5730 */ 5731 condition_on_previous_text?: boolean; 5732 /** 5733 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped. 5734 */ 5735 no_speech_threshold?: number; 5736 /** 5737 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text. 5738 */ 5739 compression_ratio_threshold?: number; 5740 /** 5741 * Threshold for filtering out segments with low average log probability, indicating low confidence. 5742 */ 5743 log_prob_threshold?: number; 5744 /** 5745 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations. 5746 */ 5747 hallucination_silence_threshold?: number; 5748 } 5749 interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output { 5750 transcription_info?: { 5751 /** 5752 * The language of the audio being transcribed or translated. 5753 */ 5754 language?: string; 5755 /** 5756 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1. 5757 */ 5758 language_probability?: number; 5759 /** 5760 * The total duration of the original audio file, in seconds. 5761 */ 5762 duration?: number; 5763 /** 5764 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds. 5765 */ 5766 duration_after_vad?: number; 5767 }; 5768 /** 5769 * The complete transcription of the audio. 5770 */ 5771 text: string; 5772 /** 5773 * The total number of words in the transcription. 5774 */ 5775 word_count?: number; 5776 segments?: { 5777 /** 5778 * The starting time of the segment within the audio, in seconds. 5779 */ 5780 start?: number; 5781 /** 5782 * The ending time of the segment within the audio, in seconds. 5783 */ 5784 end?: number; 5785 /** 5786 * The transcription of the segment. 5787 */ 5788 text?: string; 5789 /** 5790 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs. 5791 */ 5792 temperature?: number; 5793 /** 5794 * The average log probability of the predictions for the words in this segment, indicating overall confidence. 5795 */ 5796 avg_logprob?: number; 5797 /** 5798 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process. 5799 */ 5800 compression_ratio?: number; 5801 /** 5802 * The probability that the segment contains no speech, represented as a decimal between 0 and 1. 5803 */ 5804 no_speech_prob?: number; 5805 words?: { 5806 /** 5807 * The individual word transcribed from the audio. 5808 */ 5809 word?: string; 5810 /** 5811 * The starting time of the word within the audio, in seconds. 5812 */ 5813 start?: number; 5814 /** 5815 * The ending time of the word within the audio, in seconds. 5816 */ 5817 end?: number; 5818 }[]; 5819 }[]; 5820 /** 5821 * The transcription in WebVTT format, which includes timing and text information for use in subtitles. 5822 */ 5823 vtt?: string; 5824 } 5825 declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo { 5826 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input; 5827 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output; 5828 } 5829 type Ai_Cf_Baai_Bge_M3_Input = Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts | Ai_Cf_Baai_Bge_M3_Input_Embedding | { 5830 /** 5831 * Batch of the embeddings requests to run using async-queue 5832 */ 5833 requests: (Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1)[]; 5834 }; 5835 interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts { 5836 /** 5837 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts 5838 */ 5839 query?: string; 5840 /** 5841 * List of provided contexts. Note that the index in this array is important, as the response will refer to it. 5842 */ 5843 contexts: { 5844 /** 5845 * One of the provided context content 5846 */ 5847 text?: string; 5848 }[]; 5849 /** 5850 * When provided with too long context should the model error out or truncate the context to fit? 5851 */ 5852 truncate_inputs?: boolean; 5853 } 5854 interface Ai_Cf_Baai_Bge_M3_Input_Embedding { 5855 text: string | string[]; 5856 /** 5857 * When provided with too long context should the model error out or truncate the context to fit? 5858 */ 5859 truncate_inputs?: boolean; 5860 } 5861 interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 { 5862 /** 5863 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts 5864 */ 5865 query?: string; 5866 /** 5867 * List of provided contexts. Note that the index in this array is important, as the response will refer to it. 5868 */ 5869 contexts: { 5870 /** 5871 * One of the provided context content 5872 */ 5873 text?: string; 5874 }[]; 5875 /** 5876 * When provided with too long context should the model error out or truncate the context to fit? 5877 */ 5878 truncate_inputs?: boolean; 5879 } 5880 interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 { 5881 text: string | string[]; 5882 /** 5883 * When provided with too long context should the model error out or truncate the context to fit? 5884 */ 5885 truncate_inputs?: boolean; 5886 } 5887 type 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; 5888 interface Ai_Cf_Baai_Bge_M3_Output_Query { 5889 response?: { 5890 /** 5891 * Index of the context in the request 5892 */ 5893 id?: number; 5894 /** 5895 * Score of the context under the index. 5896 */ 5897 score?: number; 5898 }[]; 5899 } 5900 interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts { 5901 response?: number[][]; 5902 shape?: number[]; 5903 /** 5904 * The pooling method used in the embedding process. 5905 */ 5906 pooling?: "mean" | "cls"; 5907 } 5908 interface Ai_Cf_Baai_Bge_M3_Output_Embedding { 5909 shape?: number[]; 5910 /** 5911 * Embeddings of the requested text values 5912 */ 5913 data?: number[][]; 5914 /** 5915 * The pooling method used in the embedding process. 5916 */ 5917 pooling?: "mean" | "cls"; 5918 } 5919 interface Ai_Cf_Baai_Bge_M3_AsyncResponse { 5920 /** 5921 * The async request id that can be used to obtain the results. 5922 */ 5923 request_id?: string; 5924 } 5925 declare abstract class Base_Ai_Cf_Baai_Bge_M3 { 5926 inputs: Ai_Cf_Baai_Bge_M3_Input; 5927 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output; 5928 } 5929 interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input { 5930 /** 5931 * A text description of the image you want to generate. 5932 */ 5933 prompt: string; 5934 /** 5935 * The number of diffusion steps; higher values can improve quality but take longer. 5936 */ 5937 steps?: number; 5938 } 5939 interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output { 5940 /** 5941 * The generated image in Base64 format. 5942 */ 5943 image?: string; 5944 } 5945 declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell { 5946 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input; 5947 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output; 5948 } 5949 type 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; 5950 interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt { 5951 /** 5952 * The input text prompt for the model to generate a response. 5953 */ 5954 prompt: string; 5955 image?: number[] | (string & NonNullable<unknown>); 5956 /** 5957 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 5958 */ 5959 raw?: boolean; 5960 /** 5961 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 5962 */ 5963 stream?: boolean; 5964 /** 5965 * The maximum number of tokens to generate in the response. 5966 */ 5967 max_tokens?: number; 5968 /** 5969 * Controls the randomness of the output; higher values produce more random results. 5970 */ 5971 temperature?: number; 5972 /** 5973 * 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. 5974 */ 5975 top_p?: number; 5976 /** 5977 * 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. 5978 */ 5979 top_k?: number; 5980 /** 5981 * Random seed for reproducibility of the generation. 5982 */ 5983 seed?: number; 5984 /** 5985 * Penalty for repeated tokens; higher values discourage repetition. 5986 */ 5987 repetition_penalty?: number; 5988 /** 5989 * Decreases the likelihood of the model repeating the same lines verbatim. 5990 */ 5991 frequency_penalty?: number; 5992 /** 5993 * Increases the likelihood of the model introducing new topics. 5994 */ 5995 presence_penalty?: number; 5996 /** 5997 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 5998 */ 5999 lora?: string; 6000 } 6001 interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages { 6002 /** 6003 * An array of message objects representing the conversation history. 6004 */ 6005 messages: { 6006 /** 6007 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6008 */ 6009 role?: string; 6010 /** 6011 * The tool call id. If you don't know what to put here you can fall back to 000000001 6012 */ 6013 tool_call_id?: string; 6014 content?: string | { 6015 /** 6016 * Type of the content provided 6017 */ 6018 type?: string; 6019 text?: string; 6020 image_url?: { 6021 /** 6022 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 6023 */ 6024 url?: string; 6025 }; 6026 }[] | { 6027 /** 6028 * Type of the content provided 6029 */ 6030 type?: string; 6031 text?: string; 6032 image_url?: { 6033 /** 6034 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 6035 */ 6036 url?: string; 6037 }; 6038 }; 6039 }[]; 6040 image?: number[] | (string & NonNullable<unknown>); 6041 functions?: { 6042 name: string; 6043 code: string; 6044 }[]; 6045 /** 6046 * A list of tools available for the assistant to use. 6047 */ 6048 tools?: ({ 6049 /** 6050 * The name of the tool. More descriptive the better. 6051 */ 6052 name: string; 6053 /** 6054 * A brief description of what the tool does. 6055 */ 6056 description: string; 6057 /** 6058 * Schema defining the parameters accepted by the tool. 6059 */ 6060 parameters: { 6061 /** 6062 * The type of the parameters object (usually 'object'). 6063 */ 6064 type: string; 6065 /** 6066 * List of required parameter names. 6067 */ 6068 required?: string[]; 6069 /** 6070 * Definitions of each parameter. 6071 */ 6072 properties: { 6073 [k: string]: { 6074 /** 6075 * The data type of the parameter. 6076 */ 6077 type: string; 6078 /** 6079 * A description of the expected parameter. 6080 */ 6081 description: string; 6082 }; 6083 }; 6084 }; 6085 } | { 6086 /** 6087 * Specifies the type of tool (e.g., 'function'). 6088 */ 6089 type: string; 6090 /** 6091 * Details of the function tool. 6092 */ 6093 function: { 6094 /** 6095 * The name of the function. 6096 */ 6097 name: string; 6098 /** 6099 * A brief description of what the function does. 6100 */ 6101 description: string; 6102 /** 6103 * Schema defining the parameters accepted by the function. 6104 */ 6105 parameters: { 6106 /** 6107 * The type of the parameters object (usually 'object'). 6108 */ 6109 type: string; 6110 /** 6111 * List of required parameter names. 6112 */ 6113 required?: string[]; 6114 /** 6115 * Definitions of each parameter. 6116 */ 6117 properties: { 6118 [k: string]: { 6119 /** 6120 * The data type of the parameter. 6121 */ 6122 type: string; 6123 /** 6124 * A description of the expected parameter. 6125 */ 6126 description: string; 6127 }; 6128 }; 6129 }; 6130 }; 6131 })[]; 6132 /** 6133 * If true, the response will be streamed back incrementally. 6134 */ 6135 stream?: boolean; 6136 /** 6137 * The maximum number of tokens to generate in the response. 6138 */ 6139 max_tokens?: number; 6140 /** 6141 * Controls the randomness of the output; higher values produce more random results. 6142 */ 6143 temperature?: number; 6144 /** 6145 * 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. 6146 */ 6147 top_p?: number; 6148 /** 6149 * 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. 6150 */ 6151 top_k?: number; 6152 /** 6153 * Random seed for reproducibility of the generation. 6154 */ 6155 seed?: number; 6156 /** 6157 * Penalty for repeated tokens; higher values discourage repetition. 6158 */ 6159 repetition_penalty?: number; 6160 /** 6161 * Decreases the likelihood of the model repeating the same lines verbatim. 6162 */ 6163 frequency_penalty?: number; 6164 /** 6165 * Increases the likelihood of the model introducing new topics. 6166 */ 6167 presence_penalty?: number; 6168 } 6169 type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = { 6170 /** 6171 * The generated text response from the model 6172 */ 6173 response?: string; 6174 /** 6175 * An array of tool calls requests made during the response generation 6176 */ 6177 tool_calls?: { 6178 /** 6179 * The arguments passed to be passed to the tool call request 6180 */ 6181 arguments?: object; 6182 /** 6183 * The name of the tool to be called 6184 */ 6185 name?: string; 6186 }[]; 6187 }; 6188 declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct { 6189 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input; 6190 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output; 6191 } 6192 type 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; 6193 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt { 6194 /** 6195 * The input text prompt for the model to generate a response. 6196 */ 6197 prompt: string; 6198 /** 6199 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 6200 */ 6201 lora?: string; 6202 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode; 6203 /** 6204 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 6205 */ 6206 raw?: boolean; 6207 /** 6208 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6209 */ 6210 stream?: boolean; 6211 /** 6212 * The maximum number of tokens to generate in the response. 6213 */ 6214 max_tokens?: number; 6215 /** 6216 * Controls the randomness of the output; higher values produce more random results. 6217 */ 6218 temperature?: number; 6219 /** 6220 * 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. 6221 */ 6222 top_p?: number; 6223 /** 6224 * 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. 6225 */ 6226 top_k?: number; 6227 /** 6228 * Random seed for reproducibility of the generation. 6229 */ 6230 seed?: number; 6231 /** 6232 * Penalty for repeated tokens; higher values discourage repetition. 6233 */ 6234 repetition_penalty?: number; 6235 /** 6236 * Decreases the likelihood of the model repeating the same lines verbatim. 6237 */ 6238 frequency_penalty?: number; 6239 /** 6240 * Increases the likelihood of the model introducing new topics. 6241 */ 6242 presence_penalty?: number; 6243 } 6244 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode { 6245 type?: "json_object" | "json_schema"; 6246 json_schema?: unknown; 6247 } 6248 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages { 6249 /** 6250 * An array of message objects representing the conversation history. 6251 */ 6252 messages: { 6253 /** 6254 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6255 */ 6256 role: string; 6257 content: string | { 6258 /** 6259 * Type of the content (text) 6260 */ 6261 type?: string; 6262 /** 6263 * Text content 6264 */ 6265 text?: string; 6266 }[]; 6267 }[]; 6268 functions?: { 6269 name: string; 6270 code: string; 6271 }[]; 6272 /** 6273 * A list of tools available for the assistant to use. 6274 */ 6275 tools?: ({ 6276 /** 6277 * The name of the tool. More descriptive the better. 6278 */ 6279 name: string; 6280 /** 6281 * A brief description of what the tool does. 6282 */ 6283 description: string; 6284 /** 6285 * Schema defining the parameters accepted by the tool. 6286 */ 6287 parameters: { 6288 /** 6289 * The type of the parameters object (usually 'object'). 6290 */ 6291 type: string; 6292 /** 6293 * List of required parameter names. 6294 */ 6295 required?: string[]; 6296 /** 6297 * Definitions of each parameter. 6298 */ 6299 properties: { 6300 [k: string]: { 6301 /** 6302 * The data type of the parameter. 6303 */ 6304 type: string; 6305 /** 6306 * A description of the expected parameter. 6307 */ 6308 description: string; 6309 }; 6310 }; 6311 }; 6312 } | { 6313 /** 6314 * Specifies the type of tool (e.g., 'function'). 6315 */ 6316 type: string; 6317 /** 6318 * Details of the function tool. 6319 */ 6320 function: { 6321 /** 6322 * The name of the function. 6323 */ 6324 name: string; 6325 /** 6326 * A brief description of what the function does. 6327 */ 6328 description: string; 6329 /** 6330 * Schema defining the parameters accepted by the function. 6331 */ 6332 parameters: { 6333 /** 6334 * The type of the parameters object (usually 'object'). 6335 */ 6336 type: string; 6337 /** 6338 * List of required parameter names. 6339 */ 6340 required?: string[]; 6341 /** 6342 * Definitions of each parameter. 6343 */ 6344 properties: { 6345 [k: string]: { 6346 /** 6347 * The data type of the parameter. 6348 */ 6349 type: string; 6350 /** 6351 * A description of the expected parameter. 6352 */ 6353 description: string; 6354 }; 6355 }; 6356 }; 6357 }; 6358 })[]; 6359 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1; 6360 /** 6361 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 6362 */ 6363 raw?: boolean; 6364 /** 6365 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6366 */ 6367 stream?: boolean; 6368 /** 6369 * The maximum number of tokens to generate in the response. 6370 */ 6371 max_tokens?: number; 6372 /** 6373 * Controls the randomness of the output; higher values produce more random results. 6374 */ 6375 temperature?: number; 6376 /** 6377 * 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. 6378 */ 6379 top_p?: number; 6380 /** 6381 * 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. 6382 */ 6383 top_k?: number; 6384 /** 6385 * Random seed for reproducibility of the generation. 6386 */ 6387 seed?: number; 6388 /** 6389 * Penalty for repeated tokens; higher values discourage repetition. 6390 */ 6391 repetition_penalty?: number; 6392 /** 6393 * Decreases the likelihood of the model repeating the same lines verbatim. 6394 */ 6395 frequency_penalty?: number; 6396 /** 6397 * Increases the likelihood of the model introducing new topics. 6398 */ 6399 presence_penalty?: number; 6400 } 6401 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 { 6402 type?: "json_object" | "json_schema"; 6403 json_schema?: unknown; 6404 } 6405 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch { 6406 requests?: { 6407 /** 6408 * 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. 6409 */ 6410 external_reference?: string; 6411 /** 6412 * Prompt for the text generation model 6413 */ 6414 prompt?: string; 6415 /** 6416 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6417 */ 6418 stream?: boolean; 6419 /** 6420 * The maximum number of tokens to generate in the response. 6421 */ 6422 max_tokens?: number; 6423 /** 6424 * Controls the randomness of the output; higher values produce more random results. 6425 */ 6426 temperature?: number; 6427 /** 6428 * 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. 6429 */ 6430 top_p?: number; 6431 /** 6432 * Random seed for reproducibility of the generation. 6433 */ 6434 seed?: number; 6435 /** 6436 * Penalty for repeated tokens; higher values discourage repetition. 6437 */ 6438 repetition_penalty?: number; 6439 /** 6440 * Decreases the likelihood of the model repeating the same lines verbatim. 6441 */ 6442 frequency_penalty?: number; 6443 /** 6444 * Increases the likelihood of the model introducing new topics. 6445 */ 6446 presence_penalty?: number; 6447 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2; 6448 }[]; 6449 } 6450 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 { 6451 type?: "json_object" | "json_schema"; 6452 json_schema?: unknown; 6453 } 6454 type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output = { 6455 /** 6456 * The generated text response from the model 6457 */ 6458 response: string; 6459 /** 6460 * Usage statistics for the inference request 6461 */ 6462 usage?: { 6463 /** 6464 * Total number of tokens in input 6465 */ 6466 prompt_tokens?: number; 6467 /** 6468 * Total number of tokens in output 6469 */ 6470 completion_tokens?: number; 6471 /** 6472 * Total number of input and output tokens 6473 */ 6474 total_tokens?: number; 6475 }; 6476 /** 6477 * An array of tool calls requests made during the response generation 6478 */ 6479 tool_calls?: { 6480 /** 6481 * The arguments passed to be passed to the tool call request 6482 */ 6483 arguments?: object; 6484 /** 6485 * The name of the tool to be called 6486 */ 6487 name?: string; 6488 }[]; 6489 } | string | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse; 6490 interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse { 6491 /** 6492 * The async request id that can be used to obtain the results. 6493 */ 6494 request_id?: string; 6495 } 6496 declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast { 6497 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input; 6498 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output; 6499 } 6500 interface Ai_Cf_Meta_Llama_Guard_3_8B_Input { 6501 /** 6502 * An array of message objects representing the conversation history. 6503 */ 6504 messages: { 6505 /** 6506 * The role of the message sender must alternate between 'user' and 'assistant'. 6507 */ 6508 role: "user" | "assistant"; 6509 /** 6510 * The content of the message as a string. 6511 */ 6512 content: string; 6513 }[]; 6514 /** 6515 * The maximum number of tokens to generate in the response. 6516 */ 6517 max_tokens?: number; 6518 /** 6519 * Controls the randomness of the output; higher values produce more random results. 6520 */ 6521 temperature?: number; 6522 /** 6523 * Dictate the output format of the generated response. 6524 */ 6525 response_format?: { 6526 /** 6527 * Set to json_object to process and output generated text as JSON. 6528 */ 6529 type?: string; 6530 }; 6531 } 6532 interface Ai_Cf_Meta_Llama_Guard_3_8B_Output { 6533 response?: string | { 6534 /** 6535 * Whether the conversation is safe or not. 6536 */ 6537 safe?: boolean; 6538 /** 6539 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe. 6540 */ 6541 categories?: string[]; 6542 }; 6543 /** 6544 * Usage statistics for the inference request 6545 */ 6546 usage?: { 6547 /** 6548 * Total number of tokens in input 6549 */ 6550 prompt_tokens?: number; 6551 /** 6552 * Total number of tokens in output 6553 */ 6554 completion_tokens?: number; 6555 /** 6556 * Total number of input and output tokens 6557 */ 6558 total_tokens?: number; 6559 }; 6560 } 6561 declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B { 6562 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input; 6563 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output; 6564 } 6565 interface Ai_Cf_Baai_Bge_Reranker_Base_Input { 6566 /** 6567 * A query you wish to perform against the provided contexts. 6568 */ 6569 /** 6570 * Number of returned results starting with the best score. 6571 */ 6572 top_k?: number; 6573 /** 6574 * List of provided contexts. Note that the index in this array is important, as the response will refer to it. 6575 */ 6576 contexts: { 6577 /** 6578 * One of the provided context content 6579 */ 6580 text?: string; 6581 }[]; 6582 } 6583 interface Ai_Cf_Baai_Bge_Reranker_Base_Output { 6584 response?: { 6585 /** 6586 * Index of the context in the request 6587 */ 6588 id?: number; 6589 /** 6590 * Score of the context under the index. 6591 */ 6592 score?: number; 6593 }[]; 6594 } 6595 declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base { 6596 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input; 6597 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output; 6598 } 6599 type 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; 6600 interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt { 6601 /** 6602 * The input text prompt for the model to generate a response. 6603 */ 6604 prompt: string; 6605 /** 6606 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 6607 */ 6608 lora?: string; 6609 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode; 6610 /** 6611 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 6612 */ 6613 raw?: boolean; 6614 /** 6615 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6616 */ 6617 stream?: boolean; 6618 /** 6619 * The maximum number of tokens to generate in the response. 6620 */ 6621 max_tokens?: number; 6622 /** 6623 * Controls the randomness of the output; higher values produce more random results. 6624 */ 6625 temperature?: number; 6626 /** 6627 * 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. 6628 */ 6629 top_p?: number; 6630 /** 6631 * 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. 6632 */ 6633 top_k?: number; 6634 /** 6635 * Random seed for reproducibility of the generation. 6636 */ 6637 seed?: number; 6638 /** 6639 * Penalty for repeated tokens; higher values discourage repetition. 6640 */ 6641 repetition_penalty?: number; 6642 /** 6643 * Decreases the likelihood of the model repeating the same lines verbatim. 6644 */ 6645 frequency_penalty?: number; 6646 /** 6647 * Increases the likelihood of the model introducing new topics. 6648 */ 6649 presence_penalty?: number; 6650 } 6651 interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode { 6652 type?: "json_object" | "json_schema"; 6653 json_schema?: unknown; 6654 } 6655 interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages { 6656 /** 6657 * An array of message objects representing the conversation history. 6658 */ 6659 messages: { 6660 /** 6661 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6662 */ 6663 role: string; 6664 /** 6665 * The content of the message as a string. 6666 */ 6667 content: string; 6668 }[]; 6669 functions?: { 6670 name: string; 6671 code: string; 6672 }[]; 6673 /** 6674 * A list of tools available for the assistant to use. 6675 */ 6676 tools?: ({ 6677 /** 6678 * The name of the tool. More descriptive the better. 6679 */ 6680 name: string; 6681 /** 6682 * A brief description of what the tool does. 6683 */ 6684 description: string; 6685 /** 6686 * Schema defining the parameters accepted by the tool. 6687 */ 6688 parameters: { 6689 /** 6690 * The type of the parameters object (usually 'object'). 6691 */ 6692 type: string; 6693 /** 6694 * List of required parameter names. 6695 */ 6696 required?: string[]; 6697 /** 6698 * Definitions of each parameter. 6699 */ 6700 properties: { 6701 [k: string]: { 6702 /** 6703 * The data type of the parameter. 6704 */ 6705 type: string; 6706 /** 6707 * A description of the expected parameter. 6708 */ 6709 description: string; 6710 }; 6711 }; 6712 }; 6713 } | { 6714 /** 6715 * Specifies the type of tool (e.g., 'function'). 6716 */ 6717 type: string; 6718 /** 6719 * Details of the function tool. 6720 */ 6721 function: { 6722 /** 6723 * The name of the function. 6724 */ 6725 name: string; 6726 /** 6727 * A brief description of what the function does. 6728 */ 6729 description: string; 6730 /** 6731 * Schema defining the parameters accepted by the function. 6732 */ 6733 parameters: { 6734 /** 6735 * The type of the parameters object (usually 'object'). 6736 */ 6737 type: string; 6738 /** 6739 * List of required parameter names. 6740 */ 6741 required?: string[]; 6742 /** 6743 * Definitions of each parameter. 6744 */ 6745 properties: { 6746 [k: string]: { 6747 /** 6748 * The data type of the parameter. 6749 */ 6750 type: string; 6751 /** 6752 * A description of the expected parameter. 6753 */ 6754 description: string; 6755 }; 6756 }; 6757 }; 6758 }; 6759 })[]; 6760 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1; 6761 /** 6762 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 6763 */ 6764 raw?: boolean; 6765 /** 6766 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6767 */ 6768 stream?: boolean; 6769 /** 6770 * The maximum number of tokens to generate in the response. 6771 */ 6772 max_tokens?: number; 6773 /** 6774 * Controls the randomness of the output; higher values produce more random results. 6775 */ 6776 temperature?: number; 6777 /** 6778 * 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. 6779 */ 6780 top_p?: number; 6781 /** 6782 * 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. 6783 */ 6784 top_k?: number; 6785 /** 6786 * Random seed for reproducibility of the generation. 6787 */ 6788 seed?: number; 6789 /** 6790 * Penalty for repeated tokens; higher values discourage repetition. 6791 */ 6792 repetition_penalty?: number; 6793 /** 6794 * Decreases the likelihood of the model repeating the same lines verbatim. 6795 */ 6796 frequency_penalty?: number; 6797 /** 6798 * Increases the likelihood of the model introducing new topics. 6799 */ 6800 presence_penalty?: number; 6801 } 6802 interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 { 6803 type?: "json_object" | "json_schema"; 6804 json_schema?: unknown; 6805 } 6806 type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = { 6807 /** 6808 * The generated text response from the model 6809 */ 6810 response: string; 6811 /** 6812 * Usage statistics for the inference request 6813 */ 6814 usage?: { 6815 /** 6816 * Total number of tokens in input 6817 */ 6818 prompt_tokens?: number; 6819 /** 6820 * Total number of tokens in output 6821 */ 6822 completion_tokens?: number; 6823 /** 6824 * Total number of input and output tokens 6825 */ 6826 total_tokens?: number; 6827 }; 6828 /** 6829 * An array of tool calls requests made during the response generation 6830 */ 6831 tool_calls?: { 6832 /** 6833 * The arguments passed to be passed to the tool call request 6834 */ 6835 arguments?: object; 6836 /** 6837 * The name of the tool to be called 6838 */ 6839 name?: string; 6840 }[]; 6841 }; 6842 declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct { 6843 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input; 6844 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output; 6845 } 6846 type Ai_Cf_Qwen_Qwq_32B_Input = Ai_Cf_Qwen_Qwq_32B_Prompt | Ai_Cf_Qwen_Qwq_32B_Messages; 6847 interface Ai_Cf_Qwen_Qwq_32B_Prompt { 6848 /** 6849 * The input text prompt for the model to generate a response. 6850 */ 6851 prompt: string; 6852 /** 6853 * JSON schema that should be fulfilled for the response. 6854 */ 6855 guided_json?: object; 6856 /** 6857 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 6858 */ 6859 raw?: boolean; 6860 /** 6861 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 6862 */ 6863 stream?: boolean; 6864 /** 6865 * The maximum number of tokens to generate in the response. 6866 */ 6867 max_tokens?: number; 6868 /** 6869 * Controls the randomness of the output; higher values produce more random results. 6870 */ 6871 temperature?: number; 6872 /** 6873 * 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. 6874 */ 6875 top_p?: number; 6876 /** 6877 * 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. 6878 */ 6879 top_k?: number; 6880 /** 6881 * Random seed for reproducibility of the generation. 6882 */ 6883 seed?: number; 6884 /** 6885 * Penalty for repeated tokens; higher values discourage repetition. 6886 */ 6887 repetition_penalty?: number; 6888 /** 6889 * Decreases the likelihood of the model repeating the same lines verbatim. 6890 */ 6891 frequency_penalty?: number; 6892 /** 6893 * Increases the likelihood of the model introducing new topics. 6894 */ 6895 presence_penalty?: number; 6896 } 6897 interface Ai_Cf_Qwen_Qwq_32B_Messages { 6898 /** 6899 * An array of message objects representing the conversation history. 6900 */ 6901 messages: { 6902 /** 6903 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 6904 */ 6905 role?: string; 6906 /** 6907 * The tool call id. If you don't know what to put here you can fall back to 000000001 6908 */ 6909 tool_call_id?: string; 6910 content?: string | { 6911 /** 6912 * Type of the content provided 6913 */ 6914 type?: string; 6915 text?: string; 6916 image_url?: { 6917 /** 6918 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 6919 */ 6920 url?: string; 6921 }; 6922 }[] | { 6923 /** 6924 * Type of the content provided 6925 */ 6926 type?: string; 6927 text?: string; 6928 image_url?: { 6929 /** 6930 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 6931 */ 6932 url?: string; 6933 }; 6934 }; 6935 }[]; 6936 functions?: { 6937 name: string; 6938 code: string; 6939 }[]; 6940 /** 6941 * A list of tools available for the assistant to use. 6942 */ 6943 tools?: ({ 6944 /** 6945 * The name of the tool. More descriptive the better. 6946 */ 6947 name: string; 6948 /** 6949 * A brief description of what the tool does. 6950 */ 6951 description: string; 6952 /** 6953 * Schema defining the parameters accepted by the tool. 6954 */ 6955 parameters: { 6956 /** 6957 * The type of the parameters object (usually 'object'). 6958 */ 6959 type: string; 6960 /** 6961 * List of required parameter names. 6962 */ 6963 required?: string[]; 6964 /** 6965 * Definitions of each parameter. 6966 */ 6967 properties: { 6968 [k: string]: { 6969 /** 6970 * The data type of the parameter. 6971 */ 6972 type: string; 6973 /** 6974 * A description of the expected parameter. 6975 */ 6976 description: string; 6977 }; 6978 }; 6979 }; 6980 } | { 6981 /** 6982 * Specifies the type of tool (e.g., 'function'). 6983 */ 6984 type: string; 6985 /** 6986 * Details of the function tool. 6987 */ 6988 function: { 6989 /** 6990 * The name of the function. 6991 */ 6992 name: string; 6993 /** 6994 * A brief description of what the function does. 6995 */ 6996 description: string; 6997 /** 6998 * Schema defining the parameters accepted by the function. 6999 */ 7000 parameters: { 7001 /** 7002 * The type of the parameters object (usually 'object'). 7003 */ 7004 type: string; 7005 /** 7006 * List of required parameter names. 7007 */ 7008 required?: string[]; 7009 /** 7010 * Definitions of each parameter. 7011 */ 7012 properties: { 7013 [k: string]: { 7014 /** 7015 * The data type of the parameter. 7016 */ 7017 type: string; 7018 /** 7019 * A description of the expected parameter. 7020 */ 7021 description: string; 7022 }; 7023 }; 7024 }; 7025 }; 7026 })[]; 7027 /** 7028 * JSON schema that should be fufilled for the response. 7029 */ 7030 guided_json?: object; 7031 /** 7032 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7033 */ 7034 raw?: boolean; 7035 /** 7036 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7037 */ 7038 stream?: boolean; 7039 /** 7040 * The maximum number of tokens to generate in the response. 7041 */ 7042 max_tokens?: number; 7043 /** 7044 * Controls the randomness of the output; higher values produce more random results. 7045 */ 7046 temperature?: number; 7047 /** 7048 * 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. 7049 */ 7050 top_p?: number; 7051 /** 7052 * 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. 7053 */ 7054 top_k?: number; 7055 /** 7056 * Random seed for reproducibility of the generation. 7057 */ 7058 seed?: number; 7059 /** 7060 * Penalty for repeated tokens; higher values discourage repetition. 7061 */ 7062 repetition_penalty?: number; 7063 /** 7064 * Decreases the likelihood of the model repeating the same lines verbatim. 7065 */ 7066 frequency_penalty?: number; 7067 /** 7068 * Increases the likelihood of the model introducing new topics. 7069 */ 7070 presence_penalty?: number; 7071 } 7072 type Ai_Cf_Qwen_Qwq_32B_Output = { 7073 /** 7074 * The generated text response from the model 7075 */ 7076 response: string; 7077 /** 7078 * Usage statistics for the inference request 7079 */ 7080 usage?: { 7081 /** 7082 * Total number of tokens in input 7083 */ 7084 prompt_tokens?: number; 7085 /** 7086 * Total number of tokens in output 7087 */ 7088 completion_tokens?: number; 7089 /** 7090 * Total number of input and output tokens 7091 */ 7092 total_tokens?: number; 7093 }; 7094 /** 7095 * An array of tool calls requests made during the response generation 7096 */ 7097 tool_calls?: { 7098 /** 7099 * The arguments passed to be passed to the tool call request 7100 */ 7101 arguments?: object; 7102 /** 7103 * The name of the tool to be called 7104 */ 7105 name?: string; 7106 }[]; 7107 }; 7108 declare abstract class Base_Ai_Cf_Qwen_Qwq_32B { 7109 inputs: Ai_Cf_Qwen_Qwq_32B_Input; 7110 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output; 7111 } 7112 type 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; 7113 interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt { 7114 /** 7115 * The input text prompt for the model to generate a response. 7116 */ 7117 prompt: string; 7118 /** 7119 * JSON schema that should be fulfilled for the response. 7120 */ 7121 guided_json?: object; 7122 /** 7123 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7124 */ 7125 raw?: boolean; 7126 /** 7127 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7128 */ 7129 stream?: boolean; 7130 /** 7131 * The maximum number of tokens to generate in the response. 7132 */ 7133 max_tokens?: number; 7134 /** 7135 * Controls the randomness of the output; higher values produce more random results. 7136 */ 7137 temperature?: number; 7138 /** 7139 * 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. 7140 */ 7141 top_p?: number; 7142 /** 7143 * 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. 7144 */ 7145 top_k?: number; 7146 /** 7147 * Random seed for reproducibility of the generation. 7148 */ 7149 seed?: number; 7150 /** 7151 * Penalty for repeated tokens; higher values discourage repetition. 7152 */ 7153 repetition_penalty?: number; 7154 /** 7155 * Decreases the likelihood of the model repeating the same lines verbatim. 7156 */ 7157 frequency_penalty?: number; 7158 /** 7159 * Increases the likelihood of the model introducing new topics. 7160 */ 7161 presence_penalty?: number; 7162 } 7163 interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages { 7164 /** 7165 * An array of message objects representing the conversation history. 7166 */ 7167 messages: { 7168 /** 7169 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7170 */ 7171 role?: string; 7172 /** 7173 * 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 000000001 7174 */ 7175 tool_call_id?: string; 7176 content?: string | { 7177 /** 7178 * Type of the content provided 7179 */ 7180 type?: string; 7181 text?: string; 7182 image_url?: { 7183 /** 7184 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7185 */ 7186 url?: string; 7187 }; 7188 }[] | { 7189 /** 7190 * Type of the content provided 7191 */ 7192 type?: string; 7193 text?: string; 7194 image_url?: { 7195 /** 7196 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7197 */ 7198 url?: string; 7199 }; 7200 }; 7201 }[]; 7202 functions?: { 7203 name: string; 7204 code: string; 7205 }[]; 7206 /** 7207 * A list of tools available for the assistant to use. 7208 */ 7209 tools?: ({ 7210 /** 7211 * The name of the tool. More descriptive the better. 7212 */ 7213 name: string; 7214 /** 7215 * A brief description of what the tool does. 7216 */ 7217 description: string; 7218 /** 7219 * Schema defining the parameters accepted by the tool. 7220 */ 7221 parameters: { 7222 /** 7223 * The type of the parameters object (usually 'object'). 7224 */ 7225 type: string; 7226 /** 7227 * List of required parameter names. 7228 */ 7229 required?: string[]; 7230 /** 7231 * Definitions of each parameter. 7232 */ 7233 properties: { 7234 [k: string]: { 7235 /** 7236 * The data type of the parameter. 7237 */ 7238 type: string; 7239 /** 7240 * A description of the expected parameter. 7241 */ 7242 description: string; 7243 }; 7244 }; 7245 }; 7246 } | { 7247 /** 7248 * Specifies the type of tool (e.g., 'function'). 7249 */ 7250 type: string; 7251 /** 7252 * Details of the function tool. 7253 */ 7254 function: { 7255 /** 7256 * The name of the function. 7257 */ 7258 name: string; 7259 /** 7260 * A brief description of what the function does. 7261 */ 7262 description: string; 7263 /** 7264 * Schema defining the parameters accepted by the function. 7265 */ 7266 parameters: { 7267 /** 7268 * The type of the parameters object (usually 'object'). 7269 */ 7270 type: string; 7271 /** 7272 * List of required parameter names. 7273 */ 7274 required?: string[]; 7275 /** 7276 * Definitions of each parameter. 7277 */ 7278 properties: { 7279 [k: string]: { 7280 /** 7281 * The data type of the parameter. 7282 */ 7283 type: string; 7284 /** 7285 * A description of the expected parameter. 7286 */ 7287 description: string; 7288 }; 7289 }; 7290 }; 7291 }; 7292 })[]; 7293 /** 7294 * JSON schema that should be fufilled for the response. 7295 */ 7296 guided_json?: object; 7297 /** 7298 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7299 */ 7300 raw?: boolean; 7301 /** 7302 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7303 */ 7304 stream?: boolean; 7305 /** 7306 * The maximum number of tokens to generate in the response. 7307 */ 7308 max_tokens?: number; 7309 /** 7310 * Controls the randomness of the output; higher values produce more random results. 7311 */ 7312 temperature?: number; 7313 /** 7314 * 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. 7315 */ 7316 top_p?: number; 7317 /** 7318 * 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. 7319 */ 7320 top_k?: number; 7321 /** 7322 * Random seed for reproducibility of the generation. 7323 */ 7324 seed?: number; 7325 /** 7326 * Penalty for repeated tokens; higher values discourage repetition. 7327 */ 7328 repetition_penalty?: number; 7329 /** 7330 * Decreases the likelihood of the model repeating the same lines verbatim. 7331 */ 7332 frequency_penalty?: number; 7333 /** 7334 * Increases the likelihood of the model introducing new topics. 7335 */ 7336 presence_penalty?: number; 7337 } 7338 type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = { 7339 /** 7340 * The generated text response from the model 7341 */ 7342 response: string; 7343 /** 7344 * Usage statistics for the inference request 7345 */ 7346 usage?: { 7347 /** 7348 * Total number of tokens in input 7349 */ 7350 prompt_tokens?: number; 7351 /** 7352 * Total number of tokens in output 7353 */ 7354 completion_tokens?: number; 7355 /** 7356 * Total number of input and output tokens 7357 */ 7358 total_tokens?: number; 7359 }; 7360 /** 7361 * An array of tool calls requests made during the response generation 7362 */ 7363 tool_calls?: { 7364 /** 7365 * The arguments passed to be passed to the tool call request 7366 */ 7367 arguments?: object; 7368 /** 7369 * The name of the tool to be called 7370 */ 7371 name?: string; 7372 }[]; 7373 }; 7374 declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct { 7375 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input; 7376 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output; 7377 } 7378 type Ai_Cf_Google_Gemma_3_12B_It_Input = Ai_Cf_Google_Gemma_3_12B_It_Prompt | Ai_Cf_Google_Gemma_3_12B_It_Messages; 7379 interface Ai_Cf_Google_Gemma_3_12B_It_Prompt { 7380 /** 7381 * The input text prompt for the model to generate a response. 7382 */ 7383 prompt: string; 7384 /** 7385 * JSON schema that should be fufilled for the response. 7386 */ 7387 guided_json?: object; 7388 /** 7389 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7390 */ 7391 raw?: boolean; 7392 /** 7393 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7394 */ 7395 stream?: boolean; 7396 /** 7397 * The maximum number of tokens to generate in the response. 7398 */ 7399 max_tokens?: number; 7400 /** 7401 * Controls the randomness of the output; higher values produce more random results. 7402 */ 7403 temperature?: number; 7404 /** 7405 * 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. 7406 */ 7407 top_p?: number; 7408 /** 7409 * 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. 7410 */ 7411 top_k?: number; 7412 /** 7413 * Random seed for reproducibility of the generation. 7414 */ 7415 seed?: number; 7416 /** 7417 * Penalty for repeated tokens; higher values discourage repetition. 7418 */ 7419 repetition_penalty?: number; 7420 /** 7421 * Decreases the likelihood of the model repeating the same lines verbatim. 7422 */ 7423 frequency_penalty?: number; 7424 /** 7425 * Increases the likelihood of the model introducing new topics. 7426 */ 7427 presence_penalty?: number; 7428 } 7429 interface Ai_Cf_Google_Gemma_3_12B_It_Messages { 7430 /** 7431 * An array of message objects representing the conversation history. 7432 */ 7433 messages: { 7434 /** 7435 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7436 */ 7437 role?: string; 7438 content?: string | { 7439 /** 7440 * Type of the content provided 7441 */ 7442 type?: string; 7443 text?: string; 7444 image_url?: { 7445 /** 7446 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7447 */ 7448 url?: string; 7449 }; 7450 }[]; 7451 }[]; 7452 functions?: { 7453 name: string; 7454 code: string; 7455 }[]; 7456 /** 7457 * A list of tools available for the assistant to use. 7458 */ 7459 tools?: ({ 7460 /** 7461 * The name of the tool. More descriptive the better. 7462 */ 7463 name: string; 7464 /** 7465 * A brief description of what the tool does. 7466 */ 7467 description: string; 7468 /** 7469 * Schema defining the parameters accepted by the tool. 7470 */ 7471 parameters: { 7472 /** 7473 * The type of the parameters object (usually 'object'). 7474 */ 7475 type: string; 7476 /** 7477 * List of required parameter names. 7478 */ 7479 required?: string[]; 7480 /** 7481 * Definitions of each parameter. 7482 */ 7483 properties: { 7484 [k: string]: { 7485 /** 7486 * The data type of the parameter. 7487 */ 7488 type: string; 7489 /** 7490 * A description of the expected parameter. 7491 */ 7492 description: string; 7493 }; 7494 }; 7495 }; 7496 } | { 7497 /** 7498 * Specifies the type of tool (e.g., 'function'). 7499 */ 7500 type: string; 7501 /** 7502 * Details of the function tool. 7503 */ 7504 function: { 7505 /** 7506 * The name of the function. 7507 */ 7508 name: string; 7509 /** 7510 * A brief description of what the function does. 7511 */ 7512 description: string; 7513 /** 7514 * Schema defining the parameters accepted by the function. 7515 */ 7516 parameters: { 7517 /** 7518 * The type of the parameters object (usually 'object'). 7519 */ 7520 type: string; 7521 /** 7522 * List of required parameter names. 7523 */ 7524 required?: string[]; 7525 /** 7526 * Definitions of each parameter. 7527 */ 7528 properties: { 7529 [k: string]: { 7530 /** 7531 * The data type of the parameter. 7532 */ 7533 type: string; 7534 /** 7535 * A description of the expected parameter. 7536 */ 7537 description: string; 7538 }; 7539 }; 7540 }; 7541 }; 7542 })[]; 7543 /** 7544 * JSON schema that should be fufilled for the response. 7545 */ 7546 guided_json?: object; 7547 /** 7548 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7549 */ 7550 raw?: boolean; 7551 /** 7552 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7553 */ 7554 stream?: boolean; 7555 /** 7556 * The maximum number of tokens to generate in the response. 7557 */ 7558 max_tokens?: number; 7559 /** 7560 * Controls the randomness of the output; higher values produce more random results. 7561 */ 7562 temperature?: number; 7563 /** 7564 * 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. 7565 */ 7566 top_p?: number; 7567 /** 7568 * 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. 7569 */ 7570 top_k?: number; 7571 /** 7572 * Random seed for reproducibility of the generation. 7573 */ 7574 seed?: number; 7575 /** 7576 * Penalty for repeated tokens; higher values discourage repetition. 7577 */ 7578 repetition_penalty?: number; 7579 /** 7580 * Decreases the likelihood of the model repeating the same lines verbatim. 7581 */ 7582 frequency_penalty?: number; 7583 /** 7584 * Increases the likelihood of the model introducing new topics. 7585 */ 7586 presence_penalty?: number; 7587 } 7588 type Ai_Cf_Google_Gemma_3_12B_It_Output = { 7589 /** 7590 * The generated text response from the model 7591 */ 7592 response: string; 7593 /** 7594 * Usage statistics for the inference request 7595 */ 7596 usage?: { 7597 /** 7598 * Total number of tokens in input 7599 */ 7600 prompt_tokens?: number; 7601 /** 7602 * Total number of tokens in output 7603 */ 7604 completion_tokens?: number; 7605 /** 7606 * Total number of input and output tokens 7607 */ 7608 total_tokens?: number; 7609 }; 7610 /** 7611 * An array of tool calls requests made during the response generation 7612 */ 7613 tool_calls?: { 7614 /** 7615 * The arguments passed to be passed to the tool call request 7616 */ 7617 arguments?: object; 7618 /** 7619 * The name of the tool to be called 7620 */ 7621 name?: string; 7622 }[]; 7623 }; 7624 declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It { 7625 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input; 7626 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output; 7627 } 7628 type 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; 7629 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt { 7630 /** 7631 * The input text prompt for the model to generate a response. 7632 */ 7633 prompt: string; 7634 /** 7635 * JSON schema that should be fulfilled for the response. 7636 */ 7637 guided_json?: object; 7638 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 7639 /** 7640 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7641 */ 7642 raw?: boolean; 7643 /** 7644 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7645 */ 7646 stream?: boolean; 7647 /** 7648 * The maximum number of tokens to generate in the response. 7649 */ 7650 max_tokens?: number; 7651 /** 7652 * Controls the randomness of the output; higher values produce more random results. 7653 */ 7654 temperature?: number; 7655 /** 7656 * 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. 7657 */ 7658 top_p?: number; 7659 /** 7660 * 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. 7661 */ 7662 top_k?: number; 7663 /** 7664 * Random seed for reproducibility of the generation. 7665 */ 7666 seed?: number; 7667 /** 7668 * Penalty for repeated tokens; higher values discourage repetition. 7669 */ 7670 repetition_penalty?: number; 7671 /** 7672 * Decreases the likelihood of the model repeating the same lines verbatim. 7673 */ 7674 frequency_penalty?: number; 7675 /** 7676 * Increases the likelihood of the model introducing new topics. 7677 */ 7678 presence_penalty?: number; 7679 } 7680 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode { 7681 type?: "json_object" | "json_schema"; 7682 json_schema?: unknown; 7683 } 7684 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages { 7685 /** 7686 * An array of message objects representing the conversation history. 7687 */ 7688 messages: { 7689 /** 7690 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7691 */ 7692 role?: string; 7693 /** 7694 * The tool call id. If you don't know what to put here you can fall back to 000000001 7695 */ 7696 tool_call_id?: string; 7697 content?: string | { 7698 /** 7699 * Type of the content provided 7700 */ 7701 type?: string; 7702 text?: string; 7703 image_url?: { 7704 /** 7705 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7706 */ 7707 url?: string; 7708 }; 7709 }[] | { 7710 /** 7711 * Type of the content provided 7712 */ 7713 type?: string; 7714 text?: string; 7715 image_url?: { 7716 /** 7717 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7718 */ 7719 url?: string; 7720 }; 7721 }; 7722 }[]; 7723 functions?: { 7724 name: string; 7725 code: string; 7726 }[]; 7727 /** 7728 * A list of tools available for the assistant to use. 7729 */ 7730 tools?: ({ 7731 /** 7732 * The name of the tool. More descriptive the better. 7733 */ 7734 name: string; 7735 /** 7736 * A brief description of what the tool does. 7737 */ 7738 description: string; 7739 /** 7740 * Schema defining the parameters accepted by the tool. 7741 */ 7742 parameters: { 7743 /** 7744 * The type of the parameters object (usually 'object'). 7745 */ 7746 type: string; 7747 /** 7748 * List of required parameter names. 7749 */ 7750 required?: string[]; 7751 /** 7752 * Definitions of each parameter. 7753 */ 7754 properties: { 7755 [k: string]: { 7756 /** 7757 * The data type of the parameter. 7758 */ 7759 type: string; 7760 /** 7761 * A description of the expected parameter. 7762 */ 7763 description: string; 7764 }; 7765 }; 7766 }; 7767 } | { 7768 /** 7769 * Specifies the type of tool (e.g., 'function'). 7770 */ 7771 type: string; 7772 /** 7773 * Details of the function tool. 7774 */ 7775 function: { 7776 /** 7777 * The name of the function. 7778 */ 7779 name: string; 7780 /** 7781 * A brief description of what the function does. 7782 */ 7783 description: string; 7784 /** 7785 * Schema defining the parameters accepted by the function. 7786 */ 7787 parameters: { 7788 /** 7789 * The type of the parameters object (usually 'object'). 7790 */ 7791 type: string; 7792 /** 7793 * List of required parameter names. 7794 */ 7795 required?: string[]; 7796 /** 7797 * Definitions of each parameter. 7798 */ 7799 properties: { 7800 [k: string]: { 7801 /** 7802 * The data type of the parameter. 7803 */ 7804 type: string; 7805 /** 7806 * A description of the expected parameter. 7807 */ 7808 description: string; 7809 }; 7810 }; 7811 }; 7812 }; 7813 })[]; 7814 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 7815 /** 7816 * JSON schema that should be fufilled for the response. 7817 */ 7818 guided_json?: object; 7819 /** 7820 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7821 */ 7822 raw?: boolean; 7823 /** 7824 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7825 */ 7826 stream?: boolean; 7827 /** 7828 * The maximum number of tokens to generate in the response. 7829 */ 7830 max_tokens?: number; 7831 /** 7832 * Controls the randomness of the output; higher values produce more random results. 7833 */ 7834 temperature?: number; 7835 /** 7836 * 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. 7837 */ 7838 top_p?: number; 7839 /** 7840 * 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. 7841 */ 7842 top_k?: number; 7843 /** 7844 * Random seed for reproducibility of the generation. 7845 */ 7846 seed?: number; 7847 /** 7848 * Penalty for repeated tokens; higher values discourage repetition. 7849 */ 7850 repetition_penalty?: number; 7851 /** 7852 * Decreases the likelihood of the model repeating the same lines verbatim. 7853 */ 7854 frequency_penalty?: number; 7855 /** 7856 * Increases the likelihood of the model introducing new topics. 7857 */ 7858 presence_penalty?: number; 7859 } 7860 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch { 7861 requests: (Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner)[]; 7862 } 7863 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner { 7864 /** 7865 * The input text prompt for the model to generate a response. 7866 */ 7867 prompt: string; 7868 /** 7869 * JSON schema that should be fulfilled for the response. 7870 */ 7871 guided_json?: object; 7872 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 7873 /** 7874 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 7875 */ 7876 raw?: boolean; 7877 /** 7878 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 7879 */ 7880 stream?: boolean; 7881 /** 7882 * The maximum number of tokens to generate in the response. 7883 */ 7884 max_tokens?: number; 7885 /** 7886 * Controls the randomness of the output; higher values produce more random results. 7887 */ 7888 temperature?: number; 7889 /** 7890 * 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. 7891 */ 7892 top_p?: number; 7893 /** 7894 * 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. 7895 */ 7896 top_k?: number; 7897 /** 7898 * Random seed for reproducibility of the generation. 7899 */ 7900 seed?: number; 7901 /** 7902 * Penalty for repeated tokens; higher values discourage repetition. 7903 */ 7904 repetition_penalty?: number; 7905 /** 7906 * Decreases the likelihood of the model repeating the same lines verbatim. 7907 */ 7908 frequency_penalty?: number; 7909 /** 7910 * Increases the likelihood of the model introducing new topics. 7911 */ 7912 presence_penalty?: number; 7913 } 7914 interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner { 7915 /** 7916 * An array of message objects representing the conversation history. 7917 */ 7918 messages: { 7919 /** 7920 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 7921 */ 7922 role?: string; 7923 /** 7924 * The tool call id. If you don't know what to put here you can fall back to 000000001 7925 */ 7926 tool_call_id?: string; 7927 content?: string | { 7928 /** 7929 * Type of the content provided 7930 */ 7931 type?: string; 7932 text?: string; 7933 image_url?: { 7934 /** 7935 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7936 */ 7937 url?: string; 7938 }; 7939 }[] | { 7940 /** 7941 * Type of the content provided 7942 */ 7943 type?: string; 7944 text?: string; 7945 image_url?: { 7946 /** 7947 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted 7948 */ 7949 url?: string; 7950 }; 7951 }; 7952 }[]; 7953 functions?: { 7954 name: string; 7955 code: string; 7956 }[]; 7957 /** 7958 * A list of tools available for the assistant to use. 7959 */ 7960 tools?: ({ 7961 /** 7962 * The name of the tool. More descriptive the better. 7963 */ 7964 name: string; 7965 /** 7966 * A brief description of what the tool does. 7967 */ 7968 description: string; 7969 /** 7970 * Schema defining the parameters accepted by the tool. 7971 */ 7972 parameters: { 7973 /** 7974 * The type of the parameters object (usually 'object'). 7975 */ 7976 type: string; 7977 /** 7978 * List of required parameter names. 7979 */ 7980 required?: string[]; 7981 /** 7982 * Definitions of each parameter. 7983 */ 7984 properties: { 7985 [k: string]: { 7986 /** 7987 * The data type of the parameter. 7988 */ 7989 type: string; 7990 /** 7991 * A description of the expected parameter. 7992 */ 7993 description: string; 7994 }; 7995 }; 7996 }; 7997 } | { 7998 /** 7999 * Specifies the type of tool (e.g., 'function'). 8000 */ 8001 type: string; 8002 /** 8003 * Details of the function tool. 8004 */ 8005 function: { 8006 /** 8007 * The name of the function. 8008 */ 8009 name: string; 8010 /** 8011 * A brief description of what the function does. 8012 */ 8013 description: string; 8014 /** 8015 * Schema defining the parameters accepted by the function. 8016 */ 8017 parameters: { 8018 /** 8019 * The type of the parameters object (usually 'object'). 8020 */ 8021 type: string; 8022 /** 8023 * List of required parameter names. 8024 */ 8025 required?: string[]; 8026 /** 8027 * Definitions of each parameter. 8028 */ 8029 properties: { 8030 [k: string]: { 8031 /** 8032 * The data type of the parameter. 8033 */ 8034 type: string; 8035 /** 8036 * A description of the expected parameter. 8037 */ 8038 description: string; 8039 }; 8040 }; 8041 }; 8042 }; 8043 })[]; 8044 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode; 8045 /** 8046 * JSON schema that should be fufilled for the response. 8047 */ 8048 guided_json?: object; 8049 /** 8050 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 8051 */ 8052 raw?: boolean; 8053 /** 8054 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 8055 */ 8056 stream?: boolean; 8057 /** 8058 * The maximum number of tokens to generate in the response. 8059 */ 8060 max_tokens?: number; 8061 /** 8062 * Controls the randomness of the output; higher values produce more random results. 8063 */ 8064 temperature?: number; 8065 /** 8066 * 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. 8067 */ 8068 top_p?: number; 8069 /** 8070 * 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. 8071 */ 8072 top_k?: number; 8073 /** 8074 * Random seed for reproducibility of the generation. 8075 */ 8076 seed?: number; 8077 /** 8078 * Penalty for repeated tokens; higher values discourage repetition. 8079 */ 8080 repetition_penalty?: number; 8081 /** 8082 * Decreases the likelihood of the model repeating the same lines verbatim. 8083 */ 8084 frequency_penalty?: number; 8085 /** 8086 * Increases the likelihood of the model introducing new topics. 8087 */ 8088 presence_penalty?: number; 8089 } 8090 type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = { 8091 /** 8092 * The generated text response from the model 8093 */ 8094 response: string; 8095 /** 8096 * Usage statistics for the inference request 8097 */ 8098 usage?: { 8099 /** 8100 * Total number of tokens in input 8101 */ 8102 prompt_tokens?: number; 8103 /** 8104 * Total number of tokens in output 8105 */ 8106 completion_tokens?: number; 8107 /** 8108 * Total number of input and output tokens 8109 */ 8110 total_tokens?: number; 8111 }; 8112 /** 8113 * An array of tool calls requests made during the response generation 8114 */ 8115 tool_calls?: { 8116 /** 8117 * The tool call id. 8118 */ 8119 id?: string; 8120 /** 8121 * Specifies the type of tool (e.g., 'function'). 8122 */ 8123 type?: string; 8124 /** 8125 * Details of the function tool. 8126 */ 8127 function?: { 8128 /** 8129 * The name of the tool to be called 8130 */ 8131 name?: string; 8132 /** 8133 * The arguments passed to be passed to the tool call request 8134 */ 8135 arguments?: object; 8136 }; 8137 }[]; 8138 }; 8139 declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct { 8140 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input; 8141 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output; 8142 } 8143 type 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; 8144 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt { 8145 /** 8146 * The input text prompt for the model to generate a response. 8147 */ 8148 prompt: string; 8149 /** 8150 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 8151 */ 8152 lora?: string; 8153 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode; 8154 /** 8155 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 8156 */ 8157 raw?: boolean; 8158 /** 8159 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 8160 */ 8161 stream?: boolean; 8162 /** 8163 * The maximum number of tokens to generate in the response. 8164 */ 8165 max_tokens?: number; 8166 /** 8167 * Controls the randomness of the output; higher values produce more random results. 8168 */ 8169 temperature?: number; 8170 /** 8171 * 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. 8172 */ 8173 top_p?: number; 8174 /** 8175 * 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. 8176 */ 8177 top_k?: number; 8178 /** 8179 * Random seed for reproducibility of the generation. 8180 */ 8181 seed?: number; 8182 /** 8183 * Penalty for repeated tokens; higher values discourage repetition. 8184 */ 8185 repetition_penalty?: number; 8186 /** 8187 * Decreases the likelihood of the model repeating the same lines verbatim. 8188 */ 8189 frequency_penalty?: number; 8190 /** 8191 * Increases the likelihood of the model introducing new topics. 8192 */ 8193 presence_penalty?: number; 8194 } 8195 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode { 8196 type?: "json_object" | "json_schema"; 8197 json_schema?: unknown; 8198 } 8199 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages { 8200 /** 8201 * An array of message objects representing the conversation history. 8202 */ 8203 messages: { 8204 /** 8205 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 8206 */ 8207 role: string; 8208 content: string | { 8209 /** 8210 * Type of the content (text) 8211 */ 8212 type?: string; 8213 /** 8214 * Text content 8215 */ 8216 text?: string; 8217 }[]; 8218 }[]; 8219 functions?: { 8220 name: string; 8221 code: string; 8222 }[]; 8223 /** 8224 * A list of tools available for the assistant to use. 8225 */ 8226 tools?: ({ 8227 /** 8228 * The name of the tool. More descriptive the better. 8229 */ 8230 name: string; 8231 /** 8232 * A brief description of what the tool does. 8233 */ 8234 description: string; 8235 /** 8236 * Schema defining the parameters accepted by the tool. 8237 */ 8238 parameters: { 8239 /** 8240 * The type of the parameters object (usually 'object'). 8241 */ 8242 type: string; 8243 /** 8244 * List of required parameter names. 8245 */ 8246 required?: string[]; 8247 /** 8248 * Definitions of each parameter. 8249 */ 8250 properties: { 8251 [k: string]: { 8252 /** 8253 * The data type of the parameter. 8254 */ 8255 type: string; 8256 /** 8257 * A description of the expected parameter. 8258 */ 8259 description: string; 8260 }; 8261 }; 8262 }; 8263 } | { 8264 /** 8265 * Specifies the type of tool (e.g., 'function'). 8266 */ 8267 type: string; 8268 /** 8269 * Details of the function tool. 8270 */ 8271 function: { 8272 /** 8273 * The name of the function. 8274 */ 8275 name: string; 8276 /** 8277 * A brief description of what the function does. 8278 */ 8279 description: string; 8280 /** 8281 * Schema defining the parameters accepted by the function. 8282 */ 8283 parameters: { 8284 /** 8285 * The type of the parameters object (usually 'object'). 8286 */ 8287 type: string; 8288 /** 8289 * List of required parameter names. 8290 */ 8291 required?: string[]; 8292 /** 8293 * Definitions of each parameter. 8294 */ 8295 properties: { 8296 [k: string]: { 8297 /** 8298 * The data type of the parameter. 8299 */ 8300 type: string; 8301 /** 8302 * A description of the expected parameter. 8303 */ 8304 description: string; 8305 }; 8306 }; 8307 }; 8308 }; 8309 })[]; 8310 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1; 8311 /** 8312 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 8313 */ 8314 raw?: boolean; 8315 /** 8316 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 8317 */ 8318 stream?: boolean; 8319 /** 8320 * The maximum number of tokens to generate in the response. 8321 */ 8322 max_tokens?: number; 8323 /** 8324 * Controls the randomness of the output; higher values produce more random results. 8325 */ 8326 temperature?: number; 8327 /** 8328 * 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. 8329 */ 8330 top_p?: number; 8331 /** 8332 * 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. 8333 */ 8334 top_k?: number; 8335 /** 8336 * Random seed for reproducibility of the generation. 8337 */ 8338 seed?: number; 8339 /** 8340 * Penalty for repeated tokens; higher values discourage repetition. 8341 */ 8342 repetition_penalty?: number; 8343 /** 8344 * Decreases the likelihood of the model repeating the same lines verbatim. 8345 */ 8346 frequency_penalty?: number; 8347 /** 8348 * Increases the likelihood of the model introducing new topics. 8349 */ 8350 presence_penalty?: number; 8351 } 8352 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 { 8353 type?: "json_object" | "json_schema"; 8354 json_schema?: unknown; 8355 } 8356 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch { 8357 requests: (Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1)[]; 8358 } 8359 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 { 8360 /** 8361 * The input text prompt for the model to generate a response. 8362 */ 8363 prompt: string; 8364 /** 8365 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 8366 */ 8367 lora?: string; 8368 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2; 8369 /** 8370 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 8371 */ 8372 raw?: boolean; 8373 /** 8374 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 8375 */ 8376 stream?: boolean; 8377 /** 8378 * The maximum number of tokens to generate in the response. 8379 */ 8380 max_tokens?: number; 8381 /** 8382 * Controls the randomness of the output; higher values produce more random results. 8383 */ 8384 temperature?: number; 8385 /** 8386 * 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. 8387 */ 8388 top_p?: number; 8389 /** 8390 * 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. 8391 */ 8392 top_k?: number; 8393 /** 8394 * Random seed for reproducibility of the generation. 8395 */ 8396 seed?: number; 8397 /** 8398 * Penalty for repeated tokens; higher values discourage repetition. 8399 */ 8400 repetition_penalty?: number; 8401 /** 8402 * Decreases the likelihood of the model repeating the same lines verbatim. 8403 */ 8404 frequency_penalty?: number; 8405 /** 8406 * Increases the likelihood of the model introducing new topics. 8407 */ 8408 presence_penalty?: number; 8409 } 8410 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 { 8411 type?: "json_object" | "json_schema"; 8412 json_schema?: unknown; 8413 } 8414 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 { 8415 /** 8416 * An array of message objects representing the conversation history. 8417 */ 8418 messages: { 8419 /** 8420 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 8421 */ 8422 role: string; 8423 content: string | { 8424 /** 8425 * Type of the content (text) 8426 */ 8427 type?: string; 8428 /** 8429 * Text content 8430 */ 8431 text?: string; 8432 }[]; 8433 }[]; 8434 functions?: { 8435 name: string; 8436 code: string; 8437 }[]; 8438 /** 8439 * A list of tools available for the assistant to use. 8440 */ 8441 tools?: ({ 8442 /** 8443 * The name of the tool. More descriptive the better. 8444 */ 8445 name: string; 8446 /** 8447 * A brief description of what the tool does. 8448 */ 8449 description: string; 8450 /** 8451 * Schema defining the parameters accepted by the tool. 8452 */ 8453 parameters: { 8454 /** 8455 * The type of the parameters object (usually 'object'). 8456 */ 8457 type: string; 8458 /** 8459 * List of required parameter names. 8460 */ 8461 required?: string[]; 8462 /** 8463 * Definitions of each parameter. 8464 */ 8465 properties: { 8466 [k: string]: { 8467 /** 8468 * The data type of the parameter. 8469 */ 8470 type: string; 8471 /** 8472 * A description of the expected parameter. 8473 */ 8474 description: string; 8475 }; 8476 }; 8477 }; 8478 } | { 8479 /** 8480 * Specifies the type of tool (e.g., 'function'). 8481 */ 8482 type: string; 8483 /** 8484 * Details of the function tool. 8485 */ 8486 function: { 8487 /** 8488 * The name of the function. 8489 */ 8490 name: string; 8491 /** 8492 * A brief description of what the function does. 8493 */ 8494 description: string; 8495 /** 8496 * Schema defining the parameters accepted by the function. 8497 */ 8498 parameters: { 8499 /** 8500 * The type of the parameters object (usually 'object'). 8501 */ 8502 type: string; 8503 /** 8504 * List of required parameter names. 8505 */ 8506 required?: string[]; 8507 /** 8508 * Definitions of each parameter. 8509 */ 8510 properties: { 8511 [k: string]: { 8512 /** 8513 * The data type of the parameter. 8514 */ 8515 type: string; 8516 /** 8517 * A description of the expected parameter. 8518 */ 8519 description: string; 8520 }; 8521 }; 8522 }; 8523 }; 8524 })[]; 8525 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3; 8526 /** 8527 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 8528 */ 8529 raw?: boolean; 8530 /** 8531 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 8532 */ 8533 stream?: boolean; 8534 /** 8535 * The maximum number of tokens to generate in the response. 8536 */ 8537 max_tokens?: number; 8538 /** 8539 * Controls the randomness of the output; higher values produce more random results. 8540 */ 8541 temperature?: number; 8542 /** 8543 * 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. 8544 */ 8545 top_p?: number; 8546 /** 8547 * 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. 8548 */ 8549 top_k?: number; 8550 /** 8551 * Random seed for reproducibility of the generation. 8552 */ 8553 seed?: number; 8554 /** 8555 * Penalty for repeated tokens; higher values discourage repetition. 8556 */ 8557 repetition_penalty?: number; 8558 /** 8559 * Decreases the likelihood of the model repeating the same lines verbatim. 8560 */ 8561 frequency_penalty?: number; 8562 /** 8563 * Increases the likelihood of the model introducing new topics. 8564 */ 8565 presence_penalty?: number; 8566 } 8567 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 { 8568 type?: "json_object" | "json_schema"; 8569 json_schema?: unknown; 8570 } 8571 type 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; 8572 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response { 8573 /** 8574 * Unique identifier for the completion 8575 */ 8576 id?: string; 8577 /** 8578 * Object type identifier 8579 */ 8580 object?: "chat.completion"; 8581 /** 8582 * Unix timestamp of when the completion was created 8583 */ 8584 created?: number; 8585 /** 8586 * Model used for the completion 8587 */ 8588 model?: string; 8589 /** 8590 * List of completion choices 8591 */ 8592 choices?: { 8593 /** 8594 * Index of the choice in the list 8595 */ 8596 index?: number; 8597 /** 8598 * The message generated by the model 8599 */ 8600 message?: { 8601 /** 8602 * Role of the message author 8603 */ 8604 role: string; 8605 /** 8606 * The content of the message 8607 */ 8608 content: string; 8609 /** 8610 * Internal reasoning content (if available) 8611 */ 8612 reasoning_content?: string; 8613 /** 8614 * Tool calls made by the assistant 8615 */ 8616 tool_calls?: { 8617 /** 8618 * Unique identifier for the tool call 8619 */ 8620 id: string; 8621 /** 8622 * Type of tool call 8623 */ 8624 type: "function"; 8625 function: { 8626 /** 8627 * Name of the function to call 8628 */ 8629 name: string; 8630 /** 8631 * JSON string of arguments for the function 8632 */ 8633 arguments: string; 8634 }; 8635 }[]; 8636 }; 8637 /** 8638 * Reason why the model stopped generating 8639 */ 8640 finish_reason?: string; 8641 /** 8642 * Stop reason (may be null) 8643 */ 8644 stop_reason?: string | null; 8645 /** 8646 * Log probabilities (if requested) 8647 */ 8648 logprobs?: {} | null; 8649 }[]; 8650 /** 8651 * Usage statistics for the inference request 8652 */ 8653 usage?: { 8654 /** 8655 * Total number of tokens in input 8656 */ 8657 prompt_tokens?: number; 8658 /** 8659 * Total number of tokens in output 8660 */ 8661 completion_tokens?: number; 8662 /** 8663 * Total number of input and output tokens 8664 */ 8665 total_tokens?: number; 8666 }; 8667 /** 8668 * Log probabilities for the prompt (if requested) 8669 */ 8670 prompt_logprobs?: {} | null; 8671 } 8672 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response { 8673 /** 8674 * Unique identifier for the completion 8675 */ 8676 id?: string; 8677 /** 8678 * Object type identifier 8679 */ 8680 object?: "text_completion"; 8681 /** 8682 * Unix timestamp of when the completion was created 8683 */ 8684 created?: number; 8685 /** 8686 * Model used for the completion 8687 */ 8688 model?: string; 8689 /** 8690 * List of completion choices 8691 */ 8692 choices?: { 8693 /** 8694 * Index of the choice in the list 8695 */ 8696 index: number; 8697 /** 8698 * The generated text completion 8699 */ 8700 text: string; 8701 /** 8702 * Reason why the model stopped generating 8703 */ 8704 finish_reason: string; 8705 /** 8706 * Stop reason (may be null) 8707 */ 8708 stop_reason?: string | null; 8709 /** 8710 * Log probabilities (if requested) 8711 */ 8712 logprobs?: {} | null; 8713 /** 8714 * Log probabilities for the prompt (if requested) 8715 */ 8716 prompt_logprobs?: {} | null; 8717 }[]; 8718 /** 8719 * Usage statistics for the inference request 8720 */ 8721 usage?: { 8722 /** 8723 * Total number of tokens in input 8724 */ 8725 prompt_tokens?: number; 8726 /** 8727 * Total number of tokens in output 8728 */ 8729 completion_tokens?: number; 8730 /** 8731 * Total number of input and output tokens 8732 */ 8733 total_tokens?: number; 8734 }; 8735 } 8736 interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse { 8737 /** 8738 * The async request id that can be used to obtain the results. 8739 */ 8740 request_id?: string; 8741 } 8742 declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 { 8743 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input; 8744 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output; 8745 } 8746 interface Ai_Cf_Deepgram_Nova_3_Input { 8747 audio: { 8748 body: object; 8749 contentType: string; 8750 }; 8751 /** 8752 * 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. 8753 */ 8754 custom_topic_mode?: "extended" | "strict"; 8755 /** 8756 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100 8757 */ 8758 custom_topic?: string; 8759 /** 8760 * 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 param 8761 */ 8762 custom_intent_mode?: "extended" | "strict"; 8763 /** 8764 * Custom intents you want the model to detect within your input audio if present 8765 */ 8766 custom_intent?: string; 8767 /** 8768 * Identifies and extracts key entities from content in submitted audio 8769 */ 8770 detect_entities?: boolean; 8771 /** 8772 * Identifies the dominant language spoken in submitted audio 8773 */ 8774 detect_language?: boolean; 8775 /** 8776 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0 8777 */ 8778 diarize?: boolean; 8779 /** 8780 * Identify and extract key entities from content in submitted audio 8781 */ 8782 dictation?: boolean; 8783 /** 8784 * Specify the expected encoding of your submitted audio 8785 */ 8786 encoding?: "linear16" | "flac" | "mulaw" | "amr-nb" | "amr-wb" | "opus" | "speex" | "g729"; 8787 /** 8788 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing 8789 */ 8790 extra?: string; 8791 /** 8792 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um' 8793 */ 8794 filler_words?: boolean; 8795 /** 8796 * Key term prompting can boost or suppress specialized terminology and brands. 8797 */ 8798 keyterm?: string; 8799 /** 8800 * Keywords can boost or suppress specialized terminology and brands. 8801 */ 8802 keywords?: string; 8803 /** 8804 * 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. 8805 */ 8806 language?: string; 8807 /** 8808 * Spoken measurements will be converted to their corresponding abbreviations. 8809 */ 8810 measurements?: boolean; 8811 /** 8812 * 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. 8813 */ 8814 mip_opt_out?: boolean; 8815 /** 8816 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio 8817 */ 8818 mode?: "general" | "medical" | "finance"; 8819 /** 8820 * Transcribe each audio channel independently. 8821 */ 8822 multichannel?: boolean; 8823 /** 8824 * Numerals converts numbers from written format to numerical format. 8825 */ 8826 numerals?: boolean; 8827 /** 8828 * Splits audio into paragraphs to improve transcript readability. 8829 */ 8830 paragraphs?: boolean; 8831 /** 8832 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely. 8833 */ 8834 profanity_filter?: boolean; 8835 /** 8836 * Add punctuation and capitalization to the transcript. 8837 */ 8838 punctuate?: boolean; 8839 /** 8840 * Redaction removes sensitive information from your transcripts. 8841 */ 8842 redact?: string; 8843 /** 8844 * Search for terms or phrases in submitted audio and replaces them. 8845 */ 8846 replace?: string; 8847 /** 8848 * Search for terms or phrases in submitted audio. 8849 */ 8850 search?: string; 8851 /** 8852 * Recognizes the sentiment throughout a transcript or text. 8853 */ 8854 sentiment?: boolean; 8855 /** 8856 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability. 8857 */ 8858 smart_format?: boolean; 8859 /** 8860 * Detect topics throughout a transcript or text. 8861 */ 8862 topics?: boolean; 8863 /** 8864 * Segments speech into meaningful semantic units. 8865 */ 8866 utterances?: boolean; 8867 /** 8868 * Seconds to wait before detecting a pause between words in submitted audio. 8869 */ 8870 utt_split?: number; 8871 /** 8872 * The number of channels in the submitted audio 8873 */ 8874 channels?: number; 8875 /** 8876 * 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. 8877 */ 8878 interim_results?: boolean; 8879 /** 8880 * 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 endpointing 8881 */ 8882 endpointing?: string; 8883 /** 8884 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets. 8885 */ 8886 vad_events?: boolean; 8887 /** 8888 * 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. 8889 */ 8890 utterance_end_ms?: boolean; 8891 } 8892 interface Ai_Cf_Deepgram_Nova_3_Output { 8893 results?: { 8894 channels?: { 8895 alternatives?: { 8896 confidence?: number; 8897 transcript?: string; 8898 words?: { 8899 confidence?: number; 8900 end?: number; 8901 start?: number; 8902 word?: string; 8903 }[]; 8904 }[]; 8905 }[]; 8906 summary?: { 8907 result?: string; 8908 short?: string; 8909 }; 8910 sentiments?: { 8911 segments?: { 8912 text?: string; 8913 start_word?: number; 8914 end_word?: number; 8915 sentiment?: string; 8916 sentiment_score?: number; 8917 }[]; 8918 average?: { 8919 sentiment?: string; 8920 sentiment_score?: number; 8921 }; 8922 }; 8923 }; 8924 } 8925 declare abstract class Base_Ai_Cf_Deepgram_Nova_3 { 8926 inputs: Ai_Cf_Deepgram_Nova_3_Input; 8927 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output; 8928 } 8929 interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input { 8930 queries?: string | string[]; 8931 /** 8932 * Optional instruction for the task 8933 */ 8934 instruction?: string; 8935 documents?: string | string[]; 8936 text?: string | string[]; 8937 } 8938 interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output { 8939 data?: number[][]; 8940 shape?: number[]; 8941 } 8942 declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B { 8943 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input; 8944 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output; 8945 } 8946 type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input = { 8947 /** 8948 * readable stream with audio data and content-type specified for that data 8949 */ 8950 audio: { 8951 body: object; 8952 contentType: string; 8953 }; 8954 /** 8955 * type of data PCM data that's sent to the inference server as raw array 8956 */ 8957 dtype?: "uint8" | "float32" | "float64"; 8958 } | { 8959 /** 8960 * base64 encoded audio data 8961 */ 8962 audio: string; 8963 /** 8964 * type of data PCM data that's sent to the inference server as raw array 8965 */ 8966 dtype?: "uint8" | "float32" | "float64"; 8967 }; 8968 interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output { 8969 /** 8970 * if true, end-of-turn was detected 8971 */ 8972 is_complete?: boolean; 8973 /** 8974 * probability of the end-of-turn detection 8975 */ 8976 probability?: number; 8977 } 8978 declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 { 8979 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input; 8980 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output; 8981 } 8982 declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B { 8983 inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>; 8984 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>; 8985 } 8986 declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B { 8987 inputs: XOR<ResponsesInput, ChatCompletionsMessagesInput>; 8988 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>; 8989 } 8990 interface Ai_Cf_Leonardo_Phoenix_1_0_Input { 8991 /** 8992 * A text description of the image you want to generate. 8993 */ 8994 prompt: string; 8995 /** 8996 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt 8997 */ 8998 guidance?: number; 8999 /** 9000 * Random seed for reproducibility of the image generation 9001 */ 9002 seed?: number; 9003 /** 9004 * The height of the generated image in pixels 9005 */ 9006 height?: number; 9007 /** 9008 * The width of the generated image in pixels 9009 */ 9010 width?: number; 9011 /** 9012 * The number of diffusion steps; higher values can improve quality but take longer 9013 */ 9014 num_steps?: number; 9015 /** 9016 * Specify what to exclude from the generated images 9017 */ 9018 negative_prompt?: string; 9019 } 9020 /** 9021 * The generated image in JPEG format 9022 */ 9023 type Ai_Cf_Leonardo_Phoenix_1_0_Output = string; 9024 declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 { 9025 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input; 9026 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output; 9027 } 9028 interface Ai_Cf_Leonardo_Lucid_Origin_Input { 9029 /** 9030 * A text description of the image you want to generate. 9031 */ 9032 prompt: string; 9033 /** 9034 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt 9035 */ 9036 guidance?: number; 9037 /** 9038 * Random seed for reproducibility of the image generation 9039 */ 9040 seed?: number; 9041 /** 9042 * The height of the generated image in pixels 9043 */ 9044 height?: number; 9045 /** 9046 * The width of the generated image in pixels 9047 */ 9048 width?: number; 9049 /** 9050 * The number of diffusion steps; higher values can improve quality but take longer 9051 */ 9052 num_steps?: number; 9053 /** 9054 * The number of diffusion steps; higher values can improve quality but take longer 9055 */ 9056 steps?: number; 9057 } 9058 interface Ai_Cf_Leonardo_Lucid_Origin_Output { 9059 /** 9060 * The generated image in Base64 format. 9061 */ 9062 image?: string; 9063 } 9064 declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin { 9065 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input; 9066 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output; 9067 } 9068 interface Ai_Cf_Deepgram_Aura_1_Input { 9069 /** 9070 * Speaker used to produce the audio. 9071 */ 9072 speaker?: "angus" | "asteria" | "arcas" | "orion" | "orpheus" | "athena" | "luna" | "zeus" | "perseus" | "helios" | "hera" | "stella"; 9073 /** 9074 * Encoding of the output audio. 9075 */ 9076 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; 9077 /** 9078 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. 9079 */ 9080 container?: "none" | "wav" | "ogg"; 9081 /** 9082 * The text content to be converted to speech 9083 */ 9084 text: string; 9085 /** 9086 * 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 configurable 9087 */ 9088 sample_rate?: number; 9089 /** 9090 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. 9091 */ 9092 bit_rate?: number; 9093 } 9094 /** 9095 * The generated audio in MP3 format 9096 */ 9097 type Ai_Cf_Deepgram_Aura_1_Output = string; 9098 declare abstract class Base_Ai_Cf_Deepgram_Aura_1 { 9099 inputs: Ai_Cf_Deepgram_Aura_1_Input; 9100 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output; 9101 } 9102 interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input { 9103 /** 9104 * Input text to translate. Can be a single string or a list of strings. 9105 */ 9106 text: string | string[]; 9107 /** 9108 * Target langauge to translate to 9109 */ 9110 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"; 9111 } 9112 interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output { 9113 /** 9114 * Translated texts 9115 */ 9116 translations: string[]; 9117 } 9118 declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B { 9119 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input; 9120 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output; 9121 } 9122 type 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; 9123 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt { 9124 /** 9125 * The input text prompt for the model to generate a response. 9126 */ 9127 prompt: string; 9128 /** 9129 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 9130 */ 9131 lora?: string; 9132 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode; 9133 /** 9134 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 9135 */ 9136 raw?: boolean; 9137 /** 9138 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 9139 */ 9140 stream?: boolean; 9141 /** 9142 * The maximum number of tokens to generate in the response. 9143 */ 9144 max_tokens?: number; 9145 /** 9146 * Controls the randomness of the output; higher values produce more random results. 9147 */ 9148 temperature?: number; 9149 /** 9150 * 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. 9151 */ 9152 top_p?: number; 9153 /** 9154 * 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. 9155 */ 9156 top_k?: number; 9157 /** 9158 * Random seed for reproducibility of the generation. 9159 */ 9160 seed?: number; 9161 /** 9162 * Penalty for repeated tokens; higher values discourage repetition. 9163 */ 9164 repetition_penalty?: number; 9165 /** 9166 * Decreases the likelihood of the model repeating the same lines verbatim. 9167 */ 9168 frequency_penalty?: number; 9169 /** 9170 * Increases the likelihood of the model introducing new topics. 9171 */ 9172 presence_penalty?: number; 9173 } 9174 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode { 9175 type?: "json_object" | "json_schema"; 9176 json_schema?: unknown; 9177 } 9178 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages { 9179 /** 9180 * An array of message objects representing the conversation history. 9181 */ 9182 messages: { 9183 /** 9184 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 9185 */ 9186 role: string; 9187 content: string | { 9188 /** 9189 * Type of the content (text) 9190 */ 9191 type?: string; 9192 /** 9193 * Text content 9194 */ 9195 text?: string; 9196 }[]; 9197 }[]; 9198 functions?: { 9199 name: string; 9200 code: string; 9201 }[]; 9202 /** 9203 * A list of tools available for the assistant to use. 9204 */ 9205 tools?: ({ 9206 /** 9207 * The name of the tool. More descriptive the better. 9208 */ 9209 name: string; 9210 /** 9211 * A brief description of what the tool does. 9212 */ 9213 description: string; 9214 /** 9215 * Schema defining the parameters accepted by the tool. 9216 */ 9217 parameters: { 9218 /** 9219 * The type of the parameters object (usually 'object'). 9220 */ 9221 type: string; 9222 /** 9223 * List of required parameter names. 9224 */ 9225 required?: string[]; 9226 /** 9227 * Definitions of each parameter. 9228 */ 9229 properties: { 9230 [k: string]: { 9231 /** 9232 * The data type of the parameter. 9233 */ 9234 type: string; 9235 /** 9236 * A description of the expected parameter. 9237 */ 9238 description: string; 9239 }; 9240 }; 9241 }; 9242 } | { 9243 /** 9244 * Specifies the type of tool (e.g., 'function'). 9245 */ 9246 type: string; 9247 /** 9248 * Details of the function tool. 9249 */ 9250 function: { 9251 /** 9252 * The name of the function. 9253 */ 9254 name: string; 9255 /** 9256 * A brief description of what the function does. 9257 */ 9258 description: string; 9259 /** 9260 * Schema defining the parameters accepted by the function. 9261 */ 9262 parameters: { 9263 /** 9264 * The type of the parameters object (usually 'object'). 9265 */ 9266 type: string; 9267 /** 9268 * List of required parameter names. 9269 */ 9270 required?: string[]; 9271 /** 9272 * Definitions of each parameter. 9273 */ 9274 properties: { 9275 [k: string]: { 9276 /** 9277 * The data type of the parameter. 9278 */ 9279 type: string; 9280 /** 9281 * A description of the expected parameter. 9282 */ 9283 description: string; 9284 }; 9285 }; 9286 }; 9287 }; 9288 })[]; 9289 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1; 9290 /** 9291 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 9292 */ 9293 raw?: boolean; 9294 /** 9295 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 9296 */ 9297 stream?: boolean; 9298 /** 9299 * The maximum number of tokens to generate in the response. 9300 */ 9301 max_tokens?: number; 9302 /** 9303 * Controls the randomness of the output; higher values produce more random results. 9304 */ 9305 temperature?: number; 9306 /** 9307 * 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. 9308 */ 9309 top_p?: number; 9310 /** 9311 * 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. 9312 */ 9313 top_k?: number; 9314 /** 9315 * Random seed for reproducibility of the generation. 9316 */ 9317 seed?: number; 9318 /** 9319 * Penalty for repeated tokens; higher values discourage repetition. 9320 */ 9321 repetition_penalty?: number; 9322 /** 9323 * Decreases the likelihood of the model repeating the same lines verbatim. 9324 */ 9325 frequency_penalty?: number; 9326 /** 9327 * Increases the likelihood of the model introducing new topics. 9328 */ 9329 presence_penalty?: number; 9330 } 9331 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 { 9332 type?: "json_object" | "json_schema"; 9333 json_schema?: unknown; 9334 } 9335 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch { 9336 requests: (Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1)[]; 9337 } 9338 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 { 9339 /** 9340 * The input text prompt for the model to generate a response. 9341 */ 9342 prompt: string; 9343 /** 9344 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model. 9345 */ 9346 lora?: string; 9347 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2; 9348 /** 9349 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 9350 */ 9351 raw?: boolean; 9352 /** 9353 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 9354 */ 9355 stream?: boolean; 9356 /** 9357 * The maximum number of tokens to generate in the response. 9358 */ 9359 max_tokens?: number; 9360 /** 9361 * Controls the randomness of the output; higher values produce more random results. 9362 */ 9363 temperature?: number; 9364 /** 9365 * 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. 9366 */ 9367 top_p?: number; 9368 /** 9369 * 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. 9370 */ 9371 top_k?: number; 9372 /** 9373 * Random seed for reproducibility of the generation. 9374 */ 9375 seed?: number; 9376 /** 9377 * Penalty for repeated tokens; higher values discourage repetition. 9378 */ 9379 repetition_penalty?: number; 9380 /** 9381 * Decreases the likelihood of the model repeating the same lines verbatim. 9382 */ 9383 frequency_penalty?: number; 9384 /** 9385 * Increases the likelihood of the model introducing new topics. 9386 */ 9387 presence_penalty?: number; 9388 } 9389 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 { 9390 type?: "json_object" | "json_schema"; 9391 json_schema?: unknown; 9392 } 9393 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 { 9394 /** 9395 * An array of message objects representing the conversation history. 9396 */ 9397 messages: { 9398 /** 9399 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool'). 9400 */ 9401 role: string; 9402 content: string | { 9403 /** 9404 * Type of the content (text) 9405 */ 9406 type?: string; 9407 /** 9408 * Text content 9409 */ 9410 text?: string; 9411 }[]; 9412 }[]; 9413 functions?: { 9414 name: string; 9415 code: string; 9416 }[]; 9417 /** 9418 * A list of tools available for the assistant to use. 9419 */ 9420 tools?: ({ 9421 /** 9422 * The name of the tool. More descriptive the better. 9423 */ 9424 name: string; 9425 /** 9426 * A brief description of what the tool does. 9427 */ 9428 description: string; 9429 /** 9430 * Schema defining the parameters accepted by the tool. 9431 */ 9432 parameters: { 9433 /** 9434 * The type of the parameters object (usually 'object'). 9435 */ 9436 type: string; 9437 /** 9438 * List of required parameter names. 9439 */ 9440 required?: string[]; 9441 /** 9442 * Definitions of each parameter. 9443 */ 9444 properties: { 9445 [k: string]: { 9446 /** 9447 * The data type of the parameter. 9448 */ 9449 type: string; 9450 /** 9451 * A description of the expected parameter. 9452 */ 9453 description: string; 9454 }; 9455 }; 9456 }; 9457 } | { 9458 /** 9459 * Specifies the type of tool (e.g., 'function'). 9460 */ 9461 type: string; 9462 /** 9463 * Details of the function tool. 9464 */ 9465 function: { 9466 /** 9467 * The name of the function. 9468 */ 9469 name: string; 9470 /** 9471 * A brief description of what the function does. 9472 */ 9473 description: string; 9474 /** 9475 * Schema defining the parameters accepted by the function. 9476 */ 9477 parameters: { 9478 /** 9479 * The type of the parameters object (usually 'object'). 9480 */ 9481 type: string; 9482 /** 9483 * List of required parameter names. 9484 */ 9485 required?: string[]; 9486 /** 9487 * Definitions of each parameter. 9488 */ 9489 properties: { 9490 [k: string]: { 9491 /** 9492 * The data type of the parameter. 9493 */ 9494 type: string; 9495 /** 9496 * A description of the expected parameter. 9497 */ 9498 description: string; 9499 }; 9500 }; 9501 }; 9502 }; 9503 })[]; 9504 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3; 9505 /** 9506 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting. 9507 */ 9508 raw?: boolean; 9509 /** 9510 * If true, the response will be streamed back incrementally using SSE, Server Sent Events. 9511 */ 9512 stream?: boolean; 9513 /** 9514 * The maximum number of tokens to generate in the response. 9515 */ 9516 max_tokens?: number; 9517 /** 9518 * Controls the randomness of the output; higher values produce more random results. 9519 */ 9520 temperature?: number; 9521 /** 9522 * 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. 9523 */ 9524 top_p?: number; 9525 /** 9526 * 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. 9527 */ 9528 top_k?: number; 9529 /** 9530 * Random seed for reproducibility of the generation. 9531 */ 9532 seed?: number; 9533 /** 9534 * Penalty for repeated tokens; higher values discourage repetition. 9535 */ 9536 repetition_penalty?: number; 9537 /** 9538 * Decreases the likelihood of the model repeating the same lines verbatim. 9539 */ 9540 frequency_penalty?: number; 9541 /** 9542 * Increases the likelihood of the model introducing new topics. 9543 */ 9544 presence_penalty?: number; 9545 } 9546 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 { 9547 type?: "json_object" | "json_schema"; 9548 json_schema?: unknown; 9549 } 9550 type 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; 9551 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response { 9552 /** 9553 * Unique identifier for the completion 9554 */ 9555 id?: string; 9556 /** 9557 * Object type identifier 9558 */ 9559 object?: "chat.completion"; 9560 /** 9561 * Unix timestamp of when the completion was created 9562 */ 9563 created?: number; 9564 /** 9565 * Model used for the completion 9566 */ 9567 model?: string; 9568 /** 9569 * List of completion choices 9570 */ 9571 choices?: { 9572 /** 9573 * Index of the choice in the list 9574 */ 9575 index?: number; 9576 /** 9577 * The message generated by the model 9578 */ 9579 message?: { 9580 /** 9581 * Role of the message author 9582 */ 9583 role: string; 9584 /** 9585 * The content of the message 9586 */ 9587 content: string; 9588 /** 9589 * Internal reasoning content (if available) 9590 */ 9591 reasoning_content?: string; 9592 /** 9593 * Tool calls made by the assistant 9594 */ 9595 tool_calls?: { 9596 /** 9597 * Unique identifier for the tool call 9598 */ 9599 id: string; 9600 /** 9601 * Type of tool call 9602 */ 9603 type: "function"; 9604 function: { 9605 /** 9606 * Name of the function to call 9607 */ 9608 name: string; 9609 /** 9610 * JSON string of arguments for the function 9611 */ 9612 arguments: string; 9613 }; 9614 }[]; 9615 }; 9616 /** 9617 * Reason why the model stopped generating 9618 */ 9619 finish_reason?: string; 9620 /** 9621 * Stop reason (may be null) 9622 */ 9623 stop_reason?: string | null; 9624 /** 9625 * Log probabilities (if requested) 9626 */ 9627 logprobs?: {} | null; 9628 }[]; 9629 /** 9630 * Usage statistics for the inference request 9631 */ 9632 usage?: { 9633 /** 9634 * Total number of tokens in input 9635 */ 9636 prompt_tokens?: number; 9637 /** 9638 * Total number of tokens in output 9639 */ 9640 completion_tokens?: number; 9641 /** 9642 * Total number of input and output tokens 9643 */ 9644 total_tokens?: number; 9645 }; 9646 /** 9647 * Log probabilities for the prompt (if requested) 9648 */ 9649 prompt_logprobs?: {} | null; 9650 } 9651 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response { 9652 /** 9653 * Unique identifier for the completion 9654 */ 9655 id?: string; 9656 /** 9657 * Object type identifier 9658 */ 9659 object?: "text_completion"; 9660 /** 9661 * Unix timestamp of when the completion was created 9662 */ 9663 created?: number; 9664 /** 9665 * Model used for the completion 9666 */ 9667 model?: string; 9668 /** 9669 * List of completion choices 9670 */ 9671 choices?: { 9672 /** 9673 * Index of the choice in the list 9674 */ 9675 index: number; 9676 /** 9677 * The generated text completion 9678 */ 9679 text: string; 9680 /** 9681 * Reason why the model stopped generating 9682 */ 9683 finish_reason: string; 9684 /** 9685 * Stop reason (may be null) 9686 */ 9687 stop_reason?: string | null; 9688 /** 9689 * Log probabilities (if requested) 9690 */ 9691 logprobs?: {} | null; 9692 /** 9693 * Log probabilities for the prompt (if requested) 9694 */ 9695 prompt_logprobs?: {} | null; 9696 }[]; 9697 /** 9698 * Usage statistics for the inference request 9699 */ 9700 usage?: { 9701 /** 9702 * Total number of tokens in input 9703 */ 9704 prompt_tokens?: number; 9705 /** 9706 * Total number of tokens in output 9707 */ 9708 completion_tokens?: number; 9709 /** 9710 * Total number of input and output tokens 9711 */ 9712 total_tokens?: number; 9713 }; 9714 } 9715 interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse { 9716 /** 9717 * The async request id that can be used to obtain the results. 9718 */ 9719 request_id?: string; 9720 } 9721 declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It { 9722 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input; 9723 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output; 9724 } 9725 interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input { 9726 /** 9727 * Input text to embed. Can be a single string or a list of strings. 9728 */ 9729 text: string | string[]; 9730 } 9731 interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output { 9732 /** 9733 * Embedding vectors, where each vector is a list of floats. 9734 */ 9735 data: number[][]; 9736 /** 9737 * Shape of the embedding data as [number_of_embeddings, embedding_dimension]. 9738 * 9739 * @minItems 2 9740 * @maxItems 2 9741 */ 9742 shape: [ 9743 number, 9744 number 9745 ]; 9746 } 9747 declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B { 9748 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input; 9749 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output; 9750 } 9751 interface Ai_Cf_Deepgram_Flux_Input { 9752 /** 9753 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM. 9754 */ 9755 encoding: "linear16"; 9756 /** 9757 * Sample rate of the audio stream in Hz. 9758 */ 9759 sample_rate: string; 9760 /** 9761 * 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. 9762 */ 9763 eager_eot_threshold?: string; 9764 /** 9765 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9. 9766 */ 9767 eot_threshold?: string; 9768 /** 9769 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence. 9770 */ 9771 eot_timeout_ms?: string; 9772 /** 9773 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms. 9774 */ 9775 keyterm?: string; 9776 /** 9777 * 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-mip 9778 */ 9779 mip_opt_out?: "true" | "false"; 9780 /** 9781 * Label your requests for the purpose of identification during usage reporting 9782 */ 9783 tag?: string; 9784 } 9785 /** 9786 * Output will be returned as websocket messages. 9787 */ 9788 interface Ai_Cf_Deepgram_Flux_Output { 9789 /** 9790 * The unique identifier of the request (uuid) 9791 */ 9792 request_id?: string; 9793 /** 9794 * Starts at 0 and increments for each message the server sends to the client. 9795 */ 9796 sequence_id?: number; 9797 /** 9798 * The type of event being reported. 9799 */ 9800 event?: "Update" | "StartOfTurn" | "EagerEndOfTurn" | "TurnResumed" | "EndOfTurn"; 9801 /** 9802 * The index of the current turn 9803 */ 9804 turn_index?: number; 9805 /** 9806 * Start time in seconds of the audio range that was transcribed 9807 */ 9808 audio_window_start?: number; 9809 /** 9810 * End time in seconds of the audio range that was transcribed 9811 */ 9812 audio_window_end?: number; 9813 /** 9814 * Text that was said over the course of the current turn 9815 */ 9816 transcript?: string; 9817 /** 9818 * The words in the transcript 9819 */ 9820 words?: { 9821 /** 9822 * The individual punctuated, properly-cased word from the transcript 9823 */ 9824 word: string; 9825 /** 9826 * Confidence that this word was transcribed correctly 9827 */ 9828 confidence: number; 9829 }[]; 9830 /** 9831 * Confidence that no more speech is coming in this turn 9832 */ 9833 end_of_turn_confidence?: number; 9834 } 9835 declare abstract class Base_Ai_Cf_Deepgram_Flux { 9836 inputs: Ai_Cf_Deepgram_Flux_Input; 9837 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output; 9838 } 9839 interface Ai_Cf_Deepgram_Aura_2_En_Input { 9840 /** 9841 * Speaker used to produce the audio. 9842 */ 9843 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"; 9844 /** 9845 * Encoding of the output audio. 9846 */ 9847 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; 9848 /** 9849 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. 9850 */ 9851 container?: "none" | "wav" | "ogg"; 9852 /** 9853 * The text content to be converted to speech 9854 */ 9855 text: string; 9856 /** 9857 * 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 configurable 9858 */ 9859 sample_rate?: number; 9860 /** 9861 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. 9862 */ 9863 bit_rate?: number; 9864 } 9865 /** 9866 * The generated audio in MP3 format 9867 */ 9868 type Ai_Cf_Deepgram_Aura_2_En_Output = string; 9869 declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En { 9870 inputs: Ai_Cf_Deepgram_Aura_2_En_Input; 9871 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output; 9872 } 9873 interface Ai_Cf_Deepgram_Aura_2_Es_Input { 9874 /** 9875 * Speaker used to produce the audio. 9876 */ 9877 speaker?: "sirio" | "nestor" | "carina" | "celeste" | "alvaro" | "diana" | "aquila" | "selena" | "estrella" | "javier"; 9878 /** 9879 * Encoding of the output audio. 9880 */ 9881 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac"; 9882 /** 9883 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type.. 9884 */ 9885 container?: "none" | "wav" | "ogg"; 9886 /** 9887 * The text content to be converted to speech 9888 */ 9889 text: string; 9890 /** 9891 * 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 configurable 9892 */ 9893 sample_rate?: number; 9894 /** 9895 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type. 9896 */ 9897 bit_rate?: number; 9898 } 9899 /** 9900 * The generated audio in MP3 format 9901 */ 9902 type Ai_Cf_Deepgram_Aura_2_Es_Output = string; 9903 declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es { 9904 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input; 9905 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output; 9906 } 9907 interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input { 9908 multipart: { 9909 body?: object; 9910 contentType?: string; 9911 }; 9912 } 9913 interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output { 9914 /** 9915 * Generated image as Base64 string. 9916 */ 9917 image?: string; 9918 } 9919 declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev { 9920 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input; 9921 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output; 9922 } 9923 interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input { 9924 multipart: { 9925 body?: object; 9926 contentType?: string; 9927 }; 9928 } 9929 interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output { 9930 /** 9931 * Generated image as Base64 string. 9932 */ 9933 image?: string; 9934 } 9935 declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B { 9936 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input; 9937 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output; 9938 } 9939 interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input { 9940 multipart: { 9941 body?: object; 9942 contentType?: string; 9943 }; 9944 } 9945 interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output { 9946 /** 9947 * Generated image as Base64 string. 9948 */ 9949 image?: string; 9950 } 9951 declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B { 9952 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input; 9953 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output; 9954 } 9955 declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash { 9956 inputs: ChatCompletionsInput; 9957 postProcessedOutputs: ChatCompletionsOutput; 9958 } 9959 declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 { 9960 inputs: ChatCompletionsInput; 9961 postProcessedOutputs: ChatCompletionsOutput; 9962 } 9963 declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_6 { 9964 inputs: ChatCompletionsInput; 9965 postProcessedOutputs: ChatCompletionsOutput; 9966 } 9967 declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B { 9968 inputs: ChatCompletionsInput; 9969 postProcessedOutputs: ChatCompletionsOutput; 9970 } 9971 declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT { 9972 inputs: ChatCompletionsInput; 9973 postProcessedOutputs: ChatCompletionsOutput; 9974 } 9975 interface AiModels { 9976 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification; 9977 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage; 9978 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage; 9979 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage; 9980 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage; 9981 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage; 9982 "@cf/myshell-ai/melotts": BaseAiTextToSpeech; 9983 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings; 9984 "@cf/microsoft/resnet-50": BaseAiImageClassification; 9985 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration; 9986 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration; 9987 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration; 9988 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration; 9989 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration; 9990 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration; 9991 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration; 9992 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration; 9993 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration; 9994 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration; 9995 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration; 9996 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration; 9997 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration; 9998 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration; 9999 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration; 10000 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration; 10001 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration; 10002 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration; 10003 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration; 10004 "@cf/microsoft/phi-2": BaseAiTextGeneration; 10005 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration; 10006 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration; 10007 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration; 10008 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration; 10009 "@hf/google/gemma-7b-it": BaseAiTextGeneration; 10010 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration; 10011 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration; 10012 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration; 10013 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration; 10014 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration; 10015 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration; 10016 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration; 10017 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration; 10018 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration; 10019 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration; 10020 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration; 10021 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration; 10022 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration; 10023 "@cf/facebook/bart-large-cnn": BaseAiSummarization; 10024 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText; 10025 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5; 10026 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper; 10027 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B; 10028 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5; 10029 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5; 10030 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M; 10031 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En; 10032 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo; 10033 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3; 10034 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell; 10035 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct; 10036 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast; 10037 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B; 10038 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base; 10039 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct; 10040 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B; 10041 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct; 10042 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It; 10043 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct; 10044 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8; 10045 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3; 10046 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B; 10047 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2; 10048 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B; 10049 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B; 10050 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0; 10051 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin; 10052 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1; 10053 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B; 10054 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It; 10055 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B; 10056 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux; 10057 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En; 10058 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es; 10059 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev; 10060 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B; 10061 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B; 10062 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash; 10063 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5; 10064 "@cf/moonshotai/kimi-k2.6": Base_Ai_Cf_Moonshotai_Kimi_K2_6; 10065 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B; 10066 "@cf/google/gemma-4-26b-a4b-it": Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT; 10067 } 10068 type AiOptions = { 10069 /** 10070 * Send requests as an asynchronous batch job, only works for supported models 10071 * https://developers.cloudflare.com/workers-ai/features/batch-api 10072 */ 10073 queueRequest?: boolean; 10074 /** 10075 * Establish websocket connections, only works for supported models 10076 */ 10077 websocket?: boolean; 10078 /** 10079 * Tag your requests to group and view them in Cloudflare dashboard. 10080 * 10081 * Rules: 10082 * Tags must only contain letters, numbers, and the symbols: : - . / @ 10083 * Each tag can have maximum 50 characters. 10084 * Maximum 5 tags are allowed each request. 10085 * Duplicate tags will removed. 10086 */ 10087 tags?: string[]; 10088 gateway?: GatewayOptions; 10089 returnRawResponse?: boolean; 10090 prefix?: string; 10091 extraHeaders?: object; 10092 signal?: AbortSignal; 10093 }; 10094 type AiModelsSearchParams = { 10095 author?: string; 10096 hide_experimental?: boolean; 10097 page?: number; 10098 per_page?: number; 10099 search?: string; 10100 source?: number; 10101 task?: string; 10102 }; 10103 type AiModelsSearchObject = { 10104 id: string; 10105 source: number; 10106 name: string; 10107 description: string; 10108 task: { 10109 id: string; 10110 name: string; 10111 description: string; 10112 }; 10113 tags: string[]; 10114 properties: { 10115 property_id: string; 10116 value: string; 10117 }[]; 10118 }; 10119 type ChatCompletionsBase = ChatCompletionsMessagesInput; 10120 type ChatCompletionsInput = ChatCompletionsMessagesInput; 10121 interface InferenceUpstreamError extends Error { 10122 } 10123 interface AiInternalError extends Error { 10124 } 10125 type AiModelListType = Record<string, any>; 10126 type AiAsyncBatchResponse = { 10127 request_id: string; 10128 }; 10129 declare abstract class Ai<AiModelList extends AiModelListType = AiModels> { 10130 aiGatewayLogId: string | null; 10131 gateway(gatewayId: string): AiGateway; 10132 /** 10133 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. 10134 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10135 */ 10136 aiSearch(): AiSearchNamespace; 10137 /** 10138 * @deprecated AutoRAG has been replaced by AI Search. 10139 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead. 10140 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10141 * 10142 * @param autoragId Instance ID 10143 */ 10144 autorag(autoragId: string): AutoRAG; 10145 // Batch request 10146 run<Name extends keyof AiModelList>(model: Name, inputs: { 10147 requests: AiModelList[Name]['inputs'][]; 10148 }, options: AiOptions & { 10149 queueRequest: true; 10150 }): Promise<AiAsyncBatchResponse>; 10151 // Raw response 10152 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & { 10153 returnRawResponse: true; 10154 }): Promise<Response>; 10155 // WebSocket 10156 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options: AiOptions & { 10157 websocket: true; 10158 }): Promise<Response>; 10159 // Streaming 10160 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'] & { 10161 stream: true; 10162 }, options?: AiOptions): Promise<ReadableStream>; 10163 // Normal (default) - known model 10164 run<Name extends keyof AiModelList>(model: Name, inputs: AiModelList[Name]['inputs'], options?: AiOptions): Promise<AiModelList[Name]['postProcessedOutputs']>; 10165 // Unknown model (fallback). 10166 // 10167 // The `Exclude<..., keyof AiModelList>` constraint forces TypeScript to 10168 // route any model name that is a literal key of `AiModelList` to one of 10169 // the known-model overloads above (so input/output mismatches surface as 10170 // type errors rather than silently falling back to `Record<string, unknown>`). 10171 // Names that aren't in `AiModelList` — e.g. third-party gateway models 10172 // like `"google/nano-banana"` — still hit this overload. 10173 run<Model extends string>(model: Model extends keyof AiModelList ? never : Model, inputs: Record<string, unknown>, options?: AiOptions): Promise<Record<string, unknown>>; 10174 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>; 10175 toMarkdown(): ToMarkdownService; 10176 toMarkdown(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>; 10177 toMarkdown(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>; 10178 } 10179 type GatewayRetries = { 10180 maxAttempts?: 1 | 2 | 3 | 4 | 5; 10181 retryDelayMs?: number; 10182 backoff?: 'constant' | 'linear' | 'exponential'; 10183 }; 10184 type GatewayOptions = { 10185 id: string; 10186 cacheKey?: string; 10187 cacheTtl?: number; 10188 skipCache?: boolean; 10189 metadata?: Record<string, number | string | boolean | null | bigint>; 10190 collectLog?: boolean; 10191 eventId?: string; 10192 requestTimeoutMs?: number; 10193 retries?: GatewayRetries; 10194 }; 10195 type UniversalGatewayOptions = Exclude<GatewayOptions, 'id'> & { 10196 /** 10197 ** @deprecated 10198 */ 10199 id?: string; 10200 }; 10201 type AiGatewayPatchLog = { 10202 score?: number | null; 10203 feedback?: -1 | 1 | null; 10204 metadata?: Record<string, number | string | boolean | null | bigint> | null; 10205 }; 10206 type AiGatewayLog = { 10207 id: string; 10208 provider: string; 10209 model: string; 10210 model_type?: string; 10211 path: string; 10212 duration: number; 10213 request_type?: string; 10214 request_content_type?: string; 10215 status_code: number; 10216 response_content_type?: string; 10217 success: boolean; 10218 cached: boolean; 10219 tokens_in?: number; 10220 tokens_out?: number; 10221 metadata?: Record<string, number | string | boolean | null | bigint>; 10222 step?: number; 10223 cost?: number; 10224 custom_cost?: boolean; 10225 request_size: number; 10226 request_head?: string; 10227 request_head_complete: boolean; 10228 response_size: number; 10229 response_head?: string; 10230 response_head_complete: boolean; 10231 created_at: Date; 10232 }; 10233 type 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'; 10234 type AIGatewayHeaders = { 10235 'cf-aig-metadata': Record<string, number | string | boolean | null | bigint> | string; 10236 'cf-aig-custom-cost': { 10237 per_token_in?: number; 10238 per_token_out?: number; 10239 } | { 10240 total_cost?: number; 10241 } | string; 10242 'cf-aig-cache-ttl': number | string; 10243 'cf-aig-skip-cache': boolean | string; 10244 'cf-aig-cache-key': string; 10245 'cf-aig-event-id': string; 10246 'cf-aig-request-timeout': number | string; 10247 'cf-aig-max-attempts': number | string; 10248 'cf-aig-retry-delay': number | string; 10249 'cf-aig-backoff': string; 10250 'cf-aig-collect-log': boolean | string; 10251 Authorization: string; 10252 'Content-Type': string; 10253 [key: string]: string | number | boolean | object; 10254 }; 10255 type AIGatewayUniversalRequest = { 10256 provider: AIGatewayProviders | string; // eslint-disable-line 10257 endpoint: string; 10258 headers: Partial<AIGatewayHeaders>; 10259 query: unknown; 10260 }; 10261 interface AiGatewayInternalError extends Error { 10262 } 10263 interface AiGatewayLogNotFound extends Error { 10264 } 10265 declare abstract class AiGateway { 10266 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>; 10267 getLog(logId: string): Promise<AiGatewayLog>; 10268 run(data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[], options?: { 10269 gateway?: UniversalGatewayOptions; 10270 extraHeaders?: object; 10271 signal?: AbortSignal; 10272 }): Promise<Response>; 10273 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line 10274 } 10275 // Copyright (c) 2022-2025 Cloudflare, Inc. 10276 // Licensed under the Apache 2.0 license found in the LICENSE file or at: 10277 // https://opensource.org/licenses/Apache-2.0 10278 /** 10279 * Artifacts — Git-compatible file storage on Cloudflare Workers. 10280 * 10281 * Provides programmatic access to create, manage, and fork repositories, 10282 * and to issue and revoke scoped access tokens. 10283 */ 10284 /** Information about a repository. */ 10285 interface ArtifactsRepoInfo { 10286 /** Unique repository ID. */ 10287 id: string; 10288 /** Repository name. */ 10289 name: string; 10290 /** Repository description, or null if not set. */ 10291 description: string | null; 10292 /** Default branch name (e.g. "main"). */ 10293 defaultBranch: string; 10294 /** ISO 8601 creation timestamp. */ 10295 createdAt: string; 10296 /** ISO 8601 last-updated timestamp. */ 10297 updatedAt: string; 10298 /** ISO 8601 timestamp of the last push, or null if never pushed. */ 10299 lastPushAt: string | null; 10300 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */ 10301 source: string | null; 10302 /** Whether the repository is read-only. */ 10303 readOnly: boolean; 10304 /** HTTPS git remote URL. */ 10305 remote: string; 10306 } 10307 /** Result of creating a repository — includes the initial access token. */ 10308 interface ArtifactsCreateRepoResult { 10309 /** Unique repository ID. */ 10310 id: string; 10311 /** Repository name. */ 10312 name: string; 10313 /** Repository description, or null if not set. */ 10314 description: string | null; 10315 /** Default branch name. */ 10316 defaultBranch: string; 10317 /** HTTPS git remote URL. */ 10318 remote: string; 10319 /** Plaintext access token (only returned at creation time). */ 10320 token: string; 10321 /** ISO 8601 token expiry timestamp. */ 10322 tokenExpiresAt: string; 10323 } 10324 /** Paginated list of repositories. */ 10325 interface ArtifactsRepoListResult { 10326 /** Repositories in this page (without the `remote` field). */ 10327 repos: Omit<ArtifactsRepoInfo, 'remote'>[]; 10328 /** Total number of repositories in the namespace. */ 10329 total: number; 10330 /** Cursor for the next page, if there are more results. */ 10331 cursor?: string; 10332 } 10333 /** Result of creating an access token. */ 10334 interface ArtifactsCreateTokenResult { 10335 /** Unique token ID. */ 10336 id: string; 10337 /** Plaintext token (only returned at creation time). */ 10338 plaintext: string; 10339 /** Token scope: "read" or "write". */ 10340 scope: 'read' | 'write'; 10341 /** ISO 8601 token expiry timestamp. */ 10342 expiresAt: string; 10343 } 10344 /** Token metadata (no plaintext). */ 10345 interface ArtifactsTokenInfo { 10346 /** Unique token ID. */ 10347 id: string; 10348 /** Token scope: "read" or "write". */ 10349 scope: 'read' | 'write'; 10350 /** Token state: "active", "expired", or "revoked". */ 10351 state: 'active' | 'expired' | 'revoked'; 10352 /** ISO 8601 creation timestamp. */ 10353 createdAt: string; 10354 /** ISO 8601 expiry timestamp. */ 10355 expiresAt: string; 10356 } 10357 /** Paginated list of tokens for a repository. */ 10358 interface ArtifactsTokenListResult { 10359 /** Tokens in this page. */ 10360 tokens: ArtifactsTokenInfo[]; 10361 /** Total number of tokens for the repository. */ 10362 total: number; 10363 } 10364 /** 10365 * Handle for a single repository. Returned by Artifacts.get(). 10366 * 10367 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs. 10368 */ 10369 interface ArtifactsRepo extends ArtifactsRepoInfo { 10370 /** 10371 * Create an access token for this repo. 10372 * @param scope Token scope: "write" (default) or "read". 10373 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000). 10374 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range. 10375 */ 10376 createToken(scope?: 'write' | 'read', ttl?: number): Promise<ArtifactsCreateTokenResult>; 10377 /** List tokens for this repo (metadata only, no plaintext). */ 10378 listTokens(): Promise<ArtifactsTokenListResult>; 10379 /** 10380 * Revoke a token by plaintext or ID. 10381 * @param tokenOrId Plaintext token or token ID. 10382 * @returns true if revoked, false if not found. 10383 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty. 10384 */ 10385 revokeToken(tokenOrId: string): Promise<boolean>; 10386 // ── Fork ── 10387 /** 10388 * Fork this repo to a new repo. 10389 * @param name Target repository name. 10390 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true). 10391 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. 10392 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists. 10393 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running. 10394 */ 10395 fork(name: string, opts?: { 10396 description?: string; 10397 readOnly?: boolean; 10398 defaultBranchOnly?: boolean; 10399 }): Promise<ArtifactsCreateRepoResult>; 10400 } 10401 // ── Error types ────────────────────────────────────────────────────────────── 10402 /** 10403 * Error codes returned by Artifacts binding operations. 10404 * 10405 * Each code maps to a numeric code available on `ArtifactsError.numericCode`. 10406 */ 10407 type 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'; 10408 /** 10409 * Error thrown by Artifacts binding operations. 10410 * 10411 * Uses a string `.code` discriminator following the Cloudflare platform 10412 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches 10413 * the REST API `errors[].code` values. 10414 */ 10415 interface ArtifactsError extends Error { 10416 readonly name: 'ArtifactsError'; 10417 /** String error code for programmatic matching. */ 10418 readonly code: ArtifactsErrorCode; 10419 /** Numeric error code matching the REST API. */ 10420 readonly numericCode: number; 10421 } 10422 // ── Binding ────────────────────────────────────────────────────────────────── 10423 /** 10424 * Artifacts binding — namespace-level operations. 10425 * 10426 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs. 10427 */ 10428 interface Artifacts { 10429 /** 10430 * Create a new repository with an initial access token. 10431 * @param name Repository name (alphanumeric, dots, hyphens, underscores). 10432 * @param opts Optional: readOnly flag, description, default branch name. 10433 * @returns Repo metadata with initial token. 10434 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. 10435 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists. 10436 */ 10437 create(name: string, opts?: { 10438 readOnly?: boolean; 10439 description?: string; 10440 setDefaultBranch?: string; 10441 }): Promise<ArtifactsCreateRepoResult>; 10442 /** 10443 * Get a handle to an existing repository. 10444 * @param name Repository name. 10445 * @returns Repo handle. 10446 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist. 10447 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing. 10448 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking. 10449 */ 10450 get(name: string): Promise<ArtifactsRepo>; 10451 /** 10452 * Import a repository from an external git remote. 10453 * @param params Source URL and optional branch/depth, plus target name and options. 10454 * @returns Repo metadata with initial token. 10455 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid. 10456 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS. 10457 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository. 10458 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication. 10459 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist. 10460 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached. 10461 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits. 10462 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists. 10463 */ 10464 import(params: { 10465 source: { 10466 url: string; 10467 branch?: string; 10468 depth?: number; 10469 }; 10470 target: { 10471 name: string; 10472 opts?: { 10473 description?: string; 10474 readOnly?: boolean; 10475 }; 10476 }; 10477 }): Promise<ArtifactsCreateRepoResult>; 10478 /** 10479 * List repositories with cursor-based pagination. 10480 * @param opts Optional: limit (1–200, default 50), cursor for next page. 10481 */ 10482 list(opts?: { 10483 limit?: number; 10484 cursor?: string; 10485 }): Promise<ArtifactsRepoListResult>; 10486 /** 10487 * Delete a repository and all associated tokens. 10488 * @param name Repository name. 10489 * @returns true if deleted, false if not found. 10490 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid. 10491 */ 10492 delete(name: string): Promise<boolean>; 10493 } 10494 /** 10495 * @deprecated Use the standalone AI Search Workers binding instead. 10496 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10497 */ 10498 interface AutoRAGInternalError extends Error { 10499 } 10500 /** 10501 * @deprecated Use the standalone AI Search Workers binding instead. 10502 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10503 */ 10504 interface AutoRAGNotFoundError extends Error { 10505 } 10506 /** 10507 * @deprecated Use the standalone AI Search Workers binding instead. 10508 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10509 */ 10510 interface AutoRAGUnauthorizedError extends Error { 10511 } 10512 /** 10513 * @deprecated Use the standalone AI Search Workers binding instead. 10514 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10515 */ 10516 interface AutoRAGNameNotSetError extends Error { 10517 } 10518 type ComparisonFilter = { 10519 key: string; 10520 type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; 10521 value: string | number | boolean; 10522 }; 10523 type CompoundFilter = { 10524 type: 'and' | 'or'; 10525 filters: ComparisonFilter[]; 10526 }; 10527 /** 10528 * @deprecated Use the standalone AI Search Workers binding instead. 10529 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10530 */ 10531 type AutoRagSearchRequest = { 10532 query: string; 10533 filters?: CompoundFilter | ComparisonFilter; 10534 max_num_results?: number; 10535 ranking_options?: { 10536 ranker?: string; 10537 score_threshold?: number; 10538 }; 10539 reranking?: { 10540 enabled?: boolean; 10541 model?: string; 10542 }; 10543 rewrite_query?: boolean; 10544 }; 10545 /** 10546 * @deprecated Use the standalone AI Search Workers binding instead. 10547 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10548 */ 10549 type AutoRagAiSearchRequest = AutoRagSearchRequest & { 10550 stream?: boolean; 10551 system_prompt?: string; 10552 }; 10553 /** 10554 * @deprecated Use the standalone AI Search Workers binding instead. 10555 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10556 */ 10557 type AutoRagAiSearchRequestStreaming = Omit<AutoRagAiSearchRequest, 'stream'> & { 10558 stream: true; 10559 }; 10560 /** 10561 * @deprecated Use the standalone AI Search Workers binding instead. 10562 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10563 */ 10564 type AutoRagSearchResponse = { 10565 object: 'vector_store.search_results.page'; 10566 search_query: string; 10567 data: { 10568 file_id: string; 10569 filename: string; 10570 score: number; 10571 attributes: Record<string, string | number | boolean | null>; 10572 content: { 10573 type: 'text'; 10574 text: string; 10575 }[]; 10576 }[]; 10577 has_more: boolean; 10578 next_page: string | null; 10579 }; 10580 /** 10581 * @deprecated Use the standalone AI Search Workers binding instead. 10582 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10583 */ 10584 type AutoRagListResponse = { 10585 id: string; 10586 enable: boolean; 10587 type: string; 10588 source: string; 10589 vectorize_name: string; 10590 paused: boolean; 10591 status: string; 10592 }[]; 10593 /** 10594 * @deprecated Use the standalone AI Search Workers binding instead. 10595 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10596 */ 10597 type AutoRagAiSearchResponse = AutoRagSearchResponse & { 10598 response: string; 10599 }; 10600 /** 10601 * @deprecated Use the standalone AI Search Workers binding instead. 10602 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10603 */ 10604 declare abstract class AutoRAG { 10605 /** 10606 * @deprecated Use the standalone AI Search Workers binding instead. 10607 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10608 */ 10609 list(): Promise<AutoRagListResponse>; 10610 /** 10611 * @deprecated Use the standalone AI Search Workers binding instead. 10612 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10613 */ 10614 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>; 10615 /** 10616 * @deprecated Use the standalone AI Search Workers binding instead. 10617 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10618 */ 10619 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>; 10620 /** 10621 * @deprecated Use the standalone AI Search Workers binding instead. 10622 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10623 */ 10624 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>; 10625 /** 10626 * @deprecated Use the standalone AI Search Workers binding instead. 10627 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/ 10628 */ 10629 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse | Response>; 10630 } 10631 type BrowserRunLifecycleEvent = 'load' | 'domcontentloaded' | 'networkidle0' | 'networkidle2'; 10632 type BrowserRunResourceType = 'document' | 'stylesheet' | 'image' | 'media' | 'font' | 'script' | 'texttrack' | 'xhr' | 'fetch' | 'prefetch' | 'eventsource' | 'websocket' | 'manifest' | 'signedexchange' | 'ping' | 'cspviolationreport' | 'preflight' | 'other'; 10633 /** Options fields shared by all quick actions. */ 10634 interface BrowserRunBaseOptions { 10635 /** Adds `<script>` tags into the page with the desired URL or content. 10636 * @see https://pptr.dev/api/puppeteer.frameaddscripttagoptions 10637 */ 10638 addScriptTag?: Array<{ 10639 content?: string; 10640 url?: string; 10641 type?: string; 10642 id?: string; 10643 }>; 10644 /** Adds `<link rel="stylesheet">` or `<style>` tags into the page. 10645 * @see https://pptr.dev/api/puppeteer.frameaddstyletagoptions 10646 */ 10647 addStyleTag?: Array<{ 10648 content?: string; 10649 url?: string; 10650 }>; 10651 /** Provide credentials for HTTP authentication. @see https://pptr.dev/api/puppeteer.credentials */ 10652 authenticate?: { 10653 username: string; 10654 password: string; 10655 }; 10656 /** Set cookies before navigating. @see https://pptr.dev/api/puppeteer.cookieparam */ 10657 cookies?: Array<{ 10658 name: string; 10659 value: string; 10660 url?: string; 10661 domain?: string; 10662 path?: string; 10663 secure?: boolean; 10664 httpOnly?: boolean; 10665 sameSite?: 'Strict' | 'Lax' | 'None'; 10666 expires?: number; 10667 priority?: 'Low' | 'Medium' | 'High'; 10668 sameParty?: boolean; 10669 sourceScheme?: 'Unset' | 'NonSecure' | 'Secure'; 10670 sourcePort?: number; 10671 partitionKey?: string; 10672 }>; 10673 /** Emulate a specific CSS media type (e.g. `"screen"`, `"print"`). */ 10674 emulateMediaType?: string; 10675 /** Navigation options. @see https://pptr.dev/api/puppeteer.gotooptions */ 10676 gotoOptions?: { 10677 /** Navigation timeout in milliseconds (max 60 000). @default 30000 */ 10678 timeout?: number; 10679 /** When to consider navigation complete. @default "domcontentloaded" */ 10680 waitUntil?: BrowserRunLifecycleEvent | BrowserRunLifecycleEvent[]; 10681 referer?: string; 10682 referrerPolicy?: string; 10683 }; 10684 /** Block requests matching these regex patterns. Mutually exclusive with `allowRequestPattern`. */ 10685 rejectRequestPattern?: string[]; 10686 /** Only allow requests matching these regex patterns. Mutually exclusive with `rejectRequestPattern`. */ 10687 allowRequestPattern?: string[]; 10688 /** Block requests of these resource types. Mutually exclusive with `allowResourceTypes`. */ 10689 rejectResourceTypes?: BrowserRunResourceType[]; 10690 /** Only allow requests of these resource types. Mutually exclusive with `rejectResourceTypes`. */ 10691 allowResourceTypes?: BrowserRunResourceType[]; 10692 /** Additional HTTP headers sent with every request. */ 10693 setExtraHTTPHeaders?: Record<string, string>; 10694 /** Whether JavaScript is enabled on the page. */ 10695 setJavaScriptEnabled?: boolean; 10696 /** Override the default user agent string. 10697 * @default "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" 10698 * */ 10699 userAgent?: string; 10700 /** Set the browser viewport size. 10701 * @see https://pptr.dev/api/puppeteer.viewport 10702 * @default {width:1920,height:1080} 10703 * */ 10704 viewport?: { 10705 width: number; 10706 height: number; 10707 deviceScaleFactor?: number; 10708 isMobile?: boolean; 10709 isLandscape?: boolean; 10710 hasTouch?: boolean; 10711 }; 10712 /** Wait for a CSS selector to appear in the page before proceeding. 10713 * @see https://pptr.dev/api/puppeteer.waitforselectoroptions 10714 */ 10715 waitForSelector?: { 10716 selector: string; 10717 hidden?: true; 10718 visible?: true; 10719 /** Timeout in milliseconds. Max 120000 */ 10720 timeout?: number; 10721 }; 10722 /** Wait for a fixed delay in milliseconds before proceeding. Max 120000 */ 10723 waitForTimeout?: number; 10724 /** When true, continue on best-effort when awaited events fail or timeout. */ 10725 bestAttempt?: boolean; 10726 /** Maximum duration in milliseconds for the browser action after page load. Max 120000 */ 10727 actionTimeout?: number; 10728 /** Cache time to live in seconds (0-86400). Set to 0 to disable. 10729 * @default 5 10730 */ 10731 cacheTTL?: number; 10732 } 10733 /** Common options shared by all quick actions. Exactly one of `url` or `html` must be provided.*/ 10734 type BrowserRunCommonOptions = (BrowserRunBaseOptions & { 10735 /** URL to navigate to, e.g. `"https://example.com"`. */ 10736 url: string; 10737 }) | (BrowserRunBaseOptions & { 10738 /** Set the HTML content of the page directly. */ 10739 html: string; 10740 }); 10741 type BrowserRunPuppeteerScreenshotOptions = { 10742 /** @default "png" */ 10743 type?: 'png' | 'jpeg' | 'webp'; 10744 /** @default "binary" */ 10745 encoding?: 'binary' | 'base64'; 10746 quality?: number; 10747 fullPage?: boolean; 10748 clip?: { 10749 x: number; 10750 y: number; 10751 width: number; 10752 height: number; 10753 scale?: number; 10754 }; 10755 omitBackground?: boolean; 10756 optimizeForSpeed?: boolean; 10757 captureBeyondViewport?: boolean; 10758 fromSurface?: boolean; 10759 }; 10760 type BrowserRunScreenshotOptions = BrowserRunCommonOptions & { 10761 /** CSS selector of the element to screenshot. */ 10762 selector?: string; 10763 /** When true, scroll the entire page before taking the screenshot. */ 10764 scrollPage?: boolean; 10765 /** @see https://pptr.dev/api/puppeteer.screenshotoptions */ 10766 screenshotOptions?: BrowserRunPuppeteerScreenshotOptions; 10767 }; 10768 type BrowserRunPDFOptions = BrowserRunCommonOptions & { 10769 /** @see https://pptr.dev/api/puppeteer.pdfoptions */ 10770 pdfOptions?: { 10771 /** @default 1 */ 10772 scale?: number; 10773 /** @default false */ 10774 displayHeaderFooter?: boolean; 10775 headerTemplate?: string; 10776 footerTemplate?: string; 10777 /** @default false */ 10778 printBackground?: boolean; 10779 /** @default false */ 10780 landscape?: boolean; 10781 pageRanges?: string; 10782 /** @default "letter" */ 10783 format?: 'letter' | 'legal' | 'tabloid' | 'ledger' | 'a0' | 'a1' | 'a2' | 'a3' | 'a4' | 'a5' | 'a6'; 10784 width?: string | number; 10785 height?: string | number; 10786 /** @default false */ 10787 preferCSSPageSize?: boolean; 10788 margin?: { 10789 top?: string | number; 10790 right?: string | number; 10791 bottom?: string | number; 10792 left?: string | number; 10793 }; 10794 /** @default false */ 10795 omitBackground?: boolean; 10796 /** @default true */ 10797 tagged?: boolean; 10798 /** @default false */ 10799 outline?: boolean; 10800 /** @default 30000 */ 10801 timeout?: number; 10802 }; 10803 }; 10804 type BrowserRunScrapeOptions = BrowserRunCommonOptions & { 10805 /** CSS selectors to scrape. At least one element is required. */ 10806 elements: Array<{ 10807 selector: string; 10808 }>; 10809 }; 10810 type BrowserRunLinksOptions = BrowserRunCommonOptions & { 10811 /** When true, only return links that are visible on the page. @default false */ 10812 visibleLinksOnly?: boolean; 10813 /** When true, exclude links pointing to external domains. @default false */ 10814 excludeExternalLinks?: boolean; 10815 }; 10816 type BrowserRunSnapshotOptions = BrowserRunCommonOptions & { 10817 /** @see https://pptr.dev/api/puppeteer.screenshotoptions */ 10818 screenshotOptions?: Omit<BrowserRunPuppeteerScreenshotOptions, 'encoding'>; 10819 }; 10820 interface BrowserRunJsonBaseOptions { 10821 /** Custom AI models to try in order. Max 3. Falls back to next on error. */ 10822 custom_ai?: Array<{ 10823 /** Model ID in `<provider>/<model_name>` format, e.g. `"workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast"`. */ 10824 model: string; 10825 /** Bearer token. Not needed for workers-ai models. */ 10826 authorization?: string; 10827 }>; 10828 } 10829 /** 10830 * Options for the `json` quick action. 10831 * At least one of `prompt` or `response_format` must be provided. 10832 */ 10833 type BrowserRunJsonOptions = BrowserRunCommonOptions & BrowserRunJsonBaseOptions & ({ 10834 /** Natural-language prompt describing what data to extract. */ 10835 prompt: string; 10836 /** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */ 10837 response_format?: AiTextGenerationResponseFormat; 10838 } | { 10839 /** Natural-language prompt describing what data to extract. */ 10840 prompt?: string; 10841 /** Structured output schema for the AI model. @see https://developers.cloudflare.com/workers-ai/json-mode/ */ 10842 response_format: AiTextGenerationResponseFormat; 10843 }); 10844 type BrowserRunContentOptions = BrowserRunCommonOptions; 10845 type BrowserRunMarkdownOptions = BrowserRunCommonOptions; 10846 type BrowserRunResponseMeta = { 10847 /** HTTP status code of the rendered page */ 10848 status: number; 10849 /** Page title */ 10850 title: string; 10851 }; 10852 /** Success response for `content` action. */ 10853 type BrowserRunContentSuccessResponse = { 10854 success: true; 10855 /** Extracted HTML content */ 10856 result: string; 10857 meta: BrowserRunResponseMeta; 10858 }; 10859 /** Success response for `links` action. */ 10860 type BrowserRunLinksSuccessResponse = { 10861 success: true; 10862 /** Extracted links */ 10863 result: string[]; 10864 }; 10865 /** Success response for `scrape` action. */ 10866 type BrowserRunScrapeSuccessResponse = { 10867 success: true; 10868 result: Array<{ 10869 /** The CSS selector used to find elements. */ 10870 selector: string; 10871 /** Array of elements matching the selector. */ 10872 results: Array<{ 10873 /** Outer HTML of the element. */ 10874 html: string; 10875 /** Text content of the element. */ 10876 text: string; 10877 /** Width of the element in pixels. */ 10878 width: number; 10879 /** Height of the element in pixels. */ 10880 height: number; 10881 /** Top position of the element relative to the viewport in pixels. */ 10882 top: number; 10883 /** Left position of the element relative to the viewport in pixels. */ 10884 left: number; 10885 /** Array of HTML attributes on the element. */ 10886 attributes: Array<{ 10887 /** Attribute name. */ 10888 name: string; 10889 /** Attribute value. */ 10890 value: string; 10891 }>; 10892 }>; 10893 }>; 10894 }; 10895 /** Success response for `snapshot` action. */ 10896 type BrowserRunSnapshotSuccessResponse = { 10897 success: true; 10898 result: { 10899 /** HTML content of the page. */ 10900 content: string; 10901 /** Base64-encoded screenshot image. */ 10902 screenshot: string; 10903 }; 10904 meta: BrowserRunResponseMeta; 10905 }; 10906 /** Success response for `json` action. */ 10907 type BrowserRunJsonSuccessResponse = { 10908 success: true; 10909 /** JSON data extracted from the page using an AI model */ 10910 result: Record<string, unknown>; 10911 }; 10912 /** Success response for `markdown` action. */ 10913 type BrowserRunMarkdownSuccessResponse = { 10914 success: true; 10915 /** Extracted markdown content */ 10916 result: string; 10917 }; 10918 /** Error response for BrowserRun actions. */ 10919 type BrowserRunErrorResponse = { 10920 success: false; 10921 errors: { 10922 message: string; 10923 code?: number; 10924 detail?: string; 10925 path?: string; 10926 }[]; 10927 }; 10928 /** Error response for BrowserRun `json` action. */ 10929 type BrowserRunJsonErrorResponse = BrowserRunErrorResponse & { 10930 /** Raw AI response text for debugging */ 10931 rawAiResponse?: string; 10932 }; 10933 /** 10934 * Browser Run API binding for automating headless browsers. 10935 * @see https://developers.cloudflare.com/browser-run/ 10936 */ 10937 declare abstract class BrowserRun { 10938 /** 10939 * Send a raw HTTP request to the Browser Run API. 10940 * Used by libraries like `@cloudflare/puppeteer` to acquire and connect to a browser instance. 10941 * @see https://developers.cloudflare.com/browser-run/ 10942 */ 10943 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>; 10944 /** 10945 * Take a screenshot of a web page. 10946 * @param action - Must be `'screenshot'`. 10947 * @param options - Screenshot options including viewport, selectors, and image format. 10948 * @returns A `Response` containing one of: 10949 * 10950 * **Success (HTTP 200):** 10951 * - Binary image data with `Content-Type: image/png`, `image/jpeg`, or `image/webp` (when `encoding: 'binary'`, the default) 10952 * - Data URI string with `Content-Type: text/plain` (when `encoding: 'base64'`) 10953 * 10954 * **Error:** 10955 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 10956 * 10957 * **Headers:** 10958 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 10959 */ 10960 quickAction(action: 'screenshot', options: BrowserRunScreenshotOptions): Promise<Response>; 10961 /** 10962 * Generate a PDF of a web page. 10963 * @param action - Must be `'pdf'`. 10964 * @param options - PDF generation options including page size, margins, and headers/footers. 10965 * @returns A `Response` containing one of: 10966 * 10967 * **Success (HTTP 200):** 10968 * - Binary PDF data with `Content-Type: application/pdf` 10969 * 10970 * **Error:** 10971 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 10972 * 10973 * **Headers:** 10974 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 10975 */ 10976 quickAction(action: 'pdf', options: BrowserRunPDFOptions): Promise<Response>; 10977 /** 10978 * Get the HTML content of a web page. 10979 * @param action - Must be `'content'`. 10980 * @param options - Navigation and page interaction options. 10981 * @returns A `Response` containing one of: 10982 * 10983 * **Success (HTTP 200):** 10984 * - `BrowserRunContentSuccessResponse` JSON with `Content-Type: application/json` 10985 * 10986 * **Error:** 10987 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 10988 * 10989 * **Headers:** 10990 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 10991 */ 10992 quickAction(action: 'content', options: BrowserRunContentOptions): Promise<Response>; 10993 /** 10994 * Scrape elements from a web page by CSS selector. 10995 * @param action - Must be `'scrape'`. 10996 * @param options - Scrape options with CSS selectors for elements to extract. 10997 * @returns A `Response` containing one of: 10998 * 10999 * **Success (HTTP 200):** 11000 * - `BrowserRunScrapeSuccessResponse` JSON with `Content-Type: application/json` 11001 * 11002 * **Error:** 11003 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 11004 * 11005 * **Headers:** 11006 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 11007 */ 11008 quickAction(action: 'scrape', options: BrowserRunScrapeOptions): Promise<Response>; 11009 /** 11010 * Extract all links from a web page. 11011 * @param action - Must be `'links'`. 11012 * @param options - Options to filter visible or internal links only. 11013 * @returns A `Response` containing one of: 11014 * 11015 * **Success (HTTP 200):** 11016 * - `BrowserRunLinksSuccessResponse` JSON with `Content-Type: application/json` 11017 * 11018 * **Error:** 11019 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 11020 * 11021 * **Headers:** 11022 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 11023 */ 11024 quickAction(action: 'links', options: BrowserRunLinksOptions): Promise<Response>; 11025 /** 11026 * Get both the HTML content and a base64-encoded screenshot of a web page. 11027 * @param action - Must be `'snapshot'`. 11028 * @param options - Snapshot options including screenshot settings (encoding is always base64). 11029 * @returns A `Response` containing one of: 11030 * 11031 * **Success (HTTP 200):** 11032 * - `BrowserRunSnapshotSuccessResponse` JSON with `Content-Type: application/json` 11033 * 11034 * **Error:** 11035 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 11036 * 11037 * **Headers:** 11038 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 11039 */ 11040 quickAction(action: 'snapshot', options: BrowserRunSnapshotOptions): Promise<Response>; 11041 /** 11042 * Extract structured JSON data from a web page using AI. 11043 * @param action - Must be `'json'`. 11044 * @param options - JSON extraction options with prompt or response_format schema. 11045 * @returns A `Response` containing one of: 11046 * 11047 * **Success (HTTP 200):** 11048 * - `BrowserRunJsonSuccessResponse` JSON with `Content-Type: application/json` 11049 * 11050 * **Error:** 11051 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 11052 * - HTTP 422 with code `2012` for HTML-to-markdown conversion failures 11053 * - HTTP 422/500 for AI extraction failures (may include `rawAiResponse` field) 11054 * 11055 * **Headers:** 11056 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 11057 */ 11058 quickAction(action: 'json', options: BrowserRunJsonOptions): Promise<Response>; 11059 /** 11060 * Convert a web page to Markdown. 11061 * @param action - Must be `'markdown'`. 11062 * @param options - Navigation and page interaction options. 11063 * @returns A `Response` containing one of: 11064 * 11065 * **Success (HTTP 200):** 11066 * - `BrowserRunMarkdownSuccessResponse` JSON with `Content-Type: application/json` 11067 * 11068 * **Error:** 11069 * - `BrowserRunErrorResponse` JSON with appropriate HTTP status code (400, 422, 429, 500, 503) 11070 * - HTTP 422 with code `2012` for HTML-to-markdown conversion failures 11071 * 11072 * **Headers:** 11073 * - `X-Browser-Ms-Used`: Browser time consumed in milliseconds (set when status < 500) 11074 */ 11075 quickAction(action: 'markdown', options: BrowserRunMarkdownOptions): Promise<Response>; 11076 } 11077 interface BasicImageTransformations { 11078 /** 11079 * Maximum width in image pixels. The value must be an integer. 11080 */ 11081 width?: number; 11082 /** 11083 * Maximum height in image pixels. The value must be an integer. 11084 */ 11085 height?: number; 11086 /** 11087 * Resizing mode as a string. It affects interpretation of width and height 11088 * options: 11089 * - scale-down: Similar to contain, but the image is never enlarged. If 11090 * the image is larger than given width or height, it will be resized. 11091 * Otherwise its original size will be kept. 11092 * - contain: Resizes to maximum size that fits within the given width and 11093 * height. If only a single dimension is given (e.g. only width), the 11094 * image will be shrunk or enlarged to exactly match that dimension. 11095 * Aspect ratio is always preserved. 11096 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width 11097 * and height. If the image has an aspect ratio different from the ratio 11098 * of width and height, it will be cropped to fit. 11099 * - crop: The image will be shrunk and cropped to fit within the area 11100 * specified by width and height. The image will not be enlarged. For images 11101 * smaller than the given dimensions it's the same as scale-down. For 11102 * images larger than the given dimensions, it's the same as cover. 11103 * See also trim. 11104 * - pad: Resizes to the maximum size that fits within the given width and 11105 * height, and then fills the remaining area with a background color 11106 * (white by default). Use of this mode is not recommended, as the same 11107 * effect can be more efficiently achieved with the contain mode and the 11108 * CSS object-fit: contain property. 11109 * - squeeze: Stretches and deforms to the width and height given, even if it 11110 * breaks aspect ratio 11111 */ 11112 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze"; 11113 /** 11114 * Image segmentation using artificial intelligence models. Sets pixels not 11115 * within selected segment area to transparent e.g "foreground" sets every 11116 * background pixel as transparent. 11117 */ 11118 segment?: "foreground"; 11119 /** 11120 * When cropping with fit: "cover", this defines the side or point that should 11121 * be left uncropped. The value is either a string 11122 * "left", "right", "top", "bottom", "auto", or "center" (the default), 11123 * or an object {x, y} containing focal point coordinates in the original 11124 * image expressed as fractions ranging from 0.0 (top or left) to 1.0 11125 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will 11126 * crop bottom or left and right sides as necessary, but won’t crop anything 11127 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to 11128 * preserve as much as possible around a point at 20% of the height of the 11129 * source image. 11130 */ 11131 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | BasicImageTransformationsGravityCoordinates; 11132 /** 11133 * Background color to add underneath the image. Applies only to images with 11134 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(…), 11135 * hsl(…), etc.) 11136 */ 11137 background?: string; 11138 /** 11139 * Number of degrees (90, 180, 270) to rotate the image by. width and height 11140 * options refer to axes after rotation. 11141 */ 11142 rotate?: 0 | 90 | 180 | 270 | 360; 11143 } 11144 interface BasicImageTransformationsGravityCoordinates { 11145 x?: number; 11146 y?: number; 11147 mode?: 'remainder' | 'box-center'; 11148 } 11149 /** 11150 * In addition to the properties you can set in the RequestInit dict 11151 * that you pass as an argument to the Request constructor, you can 11152 * set certain properties of a `cf` object to control how Cloudflare 11153 * features are applied to that new Request. 11154 * 11155 * Note: Currently, these properties cannot be tested in the 11156 * playground. 11157 */ 11158 interface RequestInitCfProperties extends Record<string, unknown> { 11159 cacheEverything?: boolean; 11160 /** 11161 * A request's cache key is what determines if two requests are 11162 * "the same" for caching purposes. If a request has the same cache key 11163 * as some previous request, then we can serve the same cached response for 11164 * both. (e.g. 'some-key') 11165 * 11166 * Only available for Enterprise customers. 11167 */ 11168 cacheKey?: string; 11169 /** 11170 * This allows you to append additional Cache-Tag response headers 11171 * to the origin response without modifications to the origin server. 11172 * This will allow for greater control over the Purge by Cache Tag feature 11173 * utilizing changes only in the Workers process. 11174 * 11175 * Only available for Enterprise customers. 11176 */ 11177 cacheTags?: string[]; 11178 /** 11179 * Force response to be cached for a given number of seconds. (e.g. 300) 11180 */ 11181 cacheTtl?: number; 11182 /** 11183 * Force response to be cached for a given number of seconds based on the Origin status code. 11184 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 }) 11185 */ 11186 cacheTtlByStatus?: Record<string, number>; 11187 /** 11188 * Explicit Cache-Control header value to set on the response stored in cache. 11189 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400'). 11190 * 11191 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`), 11192 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError. 11193 * 11194 * Can be used together with `cacheTtlByStatus`. 11195 */ 11196 cacheControl?: string; 11197 /** 11198 * Whether the response should be eligible for Cache Reserve storage. 11199 */ 11200 cacheReserveEligible?: boolean; 11201 /** 11202 * Whether to respect strong ETags (as opposed to weak ETags) from the origin. 11203 */ 11204 respectStrongEtag?: boolean; 11205 /** 11206 * Whether to strip ETag headers from the origin response before caching. 11207 */ 11208 stripEtags?: boolean; 11209 /** 11210 * Whether to strip Last-Modified headers from the origin response before caching. 11211 */ 11212 stripLastModified?: boolean; 11213 /** 11214 * Whether to enable Cache Deception Armor, which protects against web cache 11215 * deception attacks by verifying the Content-Type matches the URL extension. 11216 */ 11217 cacheDeceptionArmor?: boolean; 11218 /** 11219 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage. 11220 */ 11221 cacheReserveMinimumFileSize?: number; 11222 scrapeShield?: boolean; 11223 apps?: boolean; 11224 image?: RequestInitCfPropertiesImage; 11225 minify?: RequestInitCfPropertiesImageMinify; 11226 mirage?: boolean; 11227 polish?: "lossy" | "lossless" | "off"; 11228 r2?: RequestInitCfPropertiesR2; 11229 /** 11230 * Redirects the request to an alternate origin server. You can use this, 11231 * for example, to implement load balancing across several origins. 11232 * (e.g.us-east.example.com) 11233 * 11234 * Note - For security reasons, the hostname set in resolveOverride must 11235 * be proxied on the same Cloudflare zone of the incoming request. 11236 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to 11237 * resolve to a host under a different domain or a DNS only domain first 11238 * declare a CNAME record within your own zone’s DNS mapping to the 11239 * external hostname, set proxy on Cloudflare, then set resolveOverride 11240 * to point to that CNAME record. 11241 */ 11242 resolveOverride?: string; 11243 } 11244 interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations { 11245 /** 11246 * Absolute URL of the image file to use for the drawing. It can be any of 11247 * the supported file formats. For drawing of watermarks or non-rectangular 11248 * overlays we recommend using PNG or WebP images. 11249 */ 11250 url: string; 11251 /** 11252 * Floating-point number between 0 (transparent) and 1 (opaque). 11253 * For example, opacity: 0.5 makes overlay semitransparent. 11254 */ 11255 opacity?: number; 11256 /** 11257 * - If set to true, the overlay image will be tiled to cover the entire 11258 * area. This is useful for stock-photo-like watermarks. 11259 * - If set to "x", the overlay image will be tiled horizontally only 11260 * (form a line). 11261 * - If set to "y", the overlay image will be tiled vertically only 11262 * (form a line). 11263 */ 11264 repeat?: true | "x" | "y"; 11265 /** 11266 * How to combine the foreground and backdrop pixels to create the result 11267 */ 11268 composite?: 11269 /** Foreground drawn on top of backdrop (default) */ 11270 'over' 11271 /** Foreground shown only where backdrop is opaque */ 11272 | 'in' 11273 /** Foreground drawn on top, but clipped to the backdrop's shape */ 11274 | 'atop' 11275 /** Foreground shown only where backdrop is transparent */ 11276 | 'out' 11277 /** Foreground and backdrop visible only where the other is not */ 11278 | 'xor' 11279 /** Foreground and backdrop channels added (brightening) */ 11280 | 'lighter'; 11281 /** 11282 * Position of the overlay image relative to a given edge. Each property is 11283 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10 11284 * positions left side of the overlay 10 pixels from the left edge of the 11285 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom 11286 * of the background image. 11287 * 11288 * Setting both left & right, or both top & bottom is an error. 11289 * 11290 * If no position is specified, the image will be centered. 11291 */ 11292 top?: number; 11293 left?: number; 11294 bottom?: number; 11295 right?: number; 11296 } 11297 interface RequestInitCfPropertiesImage extends BasicImageTransformations { 11298 /** 11299 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it 11300 * easier to specify higher-DPI sizes in <img srcset>. 11301 */ 11302 dpr?: number; 11303 /** 11304 * Allows you to trim your image. Takes dpr into account and is performed before 11305 * resizing or rotation. 11306 * 11307 * It can be used as: 11308 * - left, top, right, bottom - it will specify the number of pixels to cut 11309 * off each side 11310 * - width, height - the width/height you'd like to end up with - can be used 11311 * in combination with the properties above 11312 * - border - this will automatically trim the surroundings of an image based on 11313 * it's color. It consists of three properties: 11314 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit) 11315 * - tolerance: difference from color to treat as color 11316 * - keep: the number of pixels of border to keep 11317 */ 11318 trim?: "border" | { 11319 top?: number; 11320 bottom?: number; 11321 left?: number; 11322 right?: number; 11323 width?: number; 11324 height?: number; 11325 border?: boolean | { 11326 color?: string; 11327 tolerance?: number; 11328 keep?: number; 11329 }; 11330 }; 11331 /** 11332 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values 11333 * make images look worse, but load faster. The default is 85. It applies only 11334 * to JPEG and WebP images. It doesn’t have any effect on PNG. 11335 */ 11336 quality?: number | "low" | "medium-low" | "medium-high" | "high"; 11337 /** 11338 * Output format to generate. It can be: 11339 * - avif: generate images in AVIF format. 11340 * - webp: generate images in Google WebP format. Set quality to 100 to get 11341 * the WebP-lossless format. 11342 * - json: instead of generating an image, outputs information about the 11343 * image, in JSON format. The JSON object will contain image size 11344 * (before and after resizing), source image’s MIME type, file size, etc. 11345 * - jpeg: generate images in JPEG format. 11346 * - png: generate images in PNG format. 11347 */ 11348 format?: "avif" | "webp" | "json" | "jpeg" | "png" | "baseline-jpeg" | "png-force" | "svg"; 11349 /** 11350 * Whether to preserve animation frames from input files. Default is true. 11351 * Setting it to false reduces animations to still images. This setting is 11352 * recommended when enlarging images or processing arbitrary user content, 11353 * because large GIF animations can weigh tens or even hundreds of megabytes. 11354 * It is also useful to set anim:false when using format:"json" to get the 11355 * response quicker without the number of frames. 11356 */ 11357 anim?: boolean; 11358 /** 11359 * What EXIF data should be preserved in the output image. Note that EXIF 11360 * rotation and embedded color profiles are always applied ("baked in" into 11361 * the image), and aren't affected by this option. Note that if the Polish 11362 * feature is enabled, all metadata may have been removed already and this 11363 * option may have no effect. 11364 * - keep: Preserve most of EXIF metadata, including GPS location if there's 11365 * any. 11366 * - copyright: Only keep the copyright tag, and discard everything else. 11367 * This is the default behavior for JPEG files. 11368 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG 11369 * output formats always discard metadata. 11370 */ 11371 metadata?: "keep" | "copyright" | "none"; 11372 /** 11373 * Strength of sharpening filter to apply to the image. Floating-point 11374 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a 11375 * recommended value for downscaled images. 11376 */ 11377 sharpen?: number; 11378 /** 11379 * Radius of a blur filter (approximate gaussian). Maximum supported radius 11380 * is 250. 11381 */ 11382 blur?: number; 11383 /** 11384 * Overlays are drawn in the order they appear in the array (last array 11385 * entry is the topmost layer). 11386 */ 11387 draw?: RequestInitCfPropertiesImageDraw[]; 11388 /** 11389 * Fetching image from authenticated origin. Setting this property will 11390 * pass authentication headers (Authorization, Cookie, etc.) through to 11391 * the origin. 11392 */ 11393 "origin-auth"?: "share-publicly"; 11394 /** 11395 * Adds a border around the image. The border is added after resizing. Border 11396 * width takes dpr into account, and can be specified either using a single 11397 * width property, or individually for each side. 11398 */ 11399 border?: { 11400 color: string; 11401 width: number; 11402 } | { 11403 color: string; 11404 top: number; 11405 right: number; 11406 bottom: number; 11407 left: number; 11408 }; 11409 /** 11410 * Increase brightness by a factor. A value of 1.0 equals no change, a value 11411 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright. 11412 * 0 is ignored. 11413 */ 11414 brightness?: number; 11415 /** 11416 * Increase contrast by a factor. A value of 1.0 equals no change, a value of 11417 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is 11418 * ignored. 11419 */ 11420 contrast?: number; 11421 /** 11422 * Increase exposure by a factor. A value of 1.0 equals no change, a value of 11423 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored. 11424 */ 11425 gamma?: number; 11426 /** 11427 * Increase contrast by a factor. A value of 1.0 equals no change, a value of 11428 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is 11429 * ignored. 11430 */ 11431 saturation?: number; 11432 /** 11433 * Flips the images horizontally, vertically, or both. Flipping is applied before 11434 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped 11435 * horizontally, then rotated by 90 degrees. 11436 */ 11437 flip?: 'h' | 'v' | 'hv'; 11438 /** 11439 * Slightly reduces latency on a cache miss by selecting a 11440 * quickest-to-compress file format, at a cost of increased file size and 11441 * lower image quality. It will usually override the format option and choose 11442 * JPEG over WebP or AVIF. We do not recommend using this option, except in 11443 * unusual circumstances like resizing uncacheable dynamically-generated 11444 * images. 11445 */ 11446 compression?: "fast"; 11447 } 11448 interface RequestInitCfPropertiesImageMinify { 11449 javascript?: boolean; 11450 css?: boolean; 11451 html?: boolean; 11452 } 11453 interface RequestInitCfPropertiesR2 { 11454 /** 11455 * Colo id of bucket that an object is stored in 11456 */ 11457 bucketColoId?: number; 11458 } 11459 /** 11460 * Request metadata provided by Cloudflare's edge. 11461 */ 11462 type IncomingRequestCfProperties<HostMetadata = unknown> = IncomingRequestCfPropertiesBase & IncomingRequestCfPropertiesBotManagementEnterprise & IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> & IncomingRequestCfPropertiesGeographicInformation & IncomingRequestCfPropertiesCloudflareAccessOrApiShield; 11463 interface IncomingRequestCfPropertiesBase extends Record<string, unknown> { 11464 /** 11465 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request. 11466 * 11467 * @example 395747 11468 */ 11469 asn?: number; 11470 /** 11471 * The organization which owns the ASN of the incoming request. 11472 * 11473 * @example "Google Cloud" 11474 */ 11475 asOrganization?: string; 11476 /** 11477 * The original value of the `Accept-Encoding` header if Cloudflare modified it. 11478 * 11479 * @example "gzip, deflate, br" 11480 */ 11481 clientAcceptEncoding?: string; 11482 /** 11483 * The number of milliseconds it took for the request to reach your worker. 11484 * 11485 * @example 22 11486 */ 11487 clientTcpRtt?: number; 11488 /** 11489 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code) 11490 * airport code of the data center that the request hit. 11491 * 11492 * @example "DFW" 11493 */ 11494 colo: string; 11495 /** 11496 * Represents the upstream's response to a 11497 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html) 11498 * from cloudflare. 11499 * 11500 * For workers with no upstream, this will always be `1`. 11501 * 11502 * @example 3 11503 */ 11504 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus; 11505 /** 11506 * The HTTP Protocol the request used. 11507 * 11508 * @example "HTTP/2" 11509 */ 11510 httpProtocol: string; 11511 /** 11512 * The browser-requested prioritization information in the request object. 11513 * 11514 * If no information was set, defaults to the empty string `""` 11515 * 11516 * @example "weight=192;exclusive=0;group=3;group-weight=127" 11517 * @default "" 11518 */ 11519 requestPriority: string; 11520 /** 11521 * The TLS version of the connection to Cloudflare. 11522 * In requests served over plaintext (without TLS), this property is the empty string `""`. 11523 * 11524 * @example "TLSv1.3" 11525 */ 11526 tlsVersion: string; 11527 /** 11528 * The cipher for the connection to Cloudflare. 11529 * In requests served over plaintext (without TLS), this property is the empty string `""`. 11530 * 11531 * @example "AEAD-AES128-GCM-SHA256" 11532 */ 11533 tlsCipher: string; 11534 /** 11535 * 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. 11536 * 11537 * If the incoming request was served over plaintext (without TLS) this field is undefined. 11538 */ 11539 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata; 11540 } 11541 interface IncomingRequestCfPropertiesBotManagementBase { 11542 /** 11543 * Cloudflare’s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot, 11544 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human). 11545 * 11546 * @example 54 11547 */ 11548 score: number; 11549 /** 11550 * A boolean value that is true if the request comes from a good bot, like Google or Bing. 11551 * 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). 11552 */ 11553 verifiedBot: boolean; 11554 /** 11555 * A boolean value that is true if the request originates from a 11556 * Cloudflare-verified proxy service. 11557 */ 11558 corporateProxy: boolean; 11559 /** 11560 * 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. 11561 */ 11562 staticResource: boolean; 11563 /** 11564 * 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). 11565 */ 11566 detectionIds: number[]; 11567 } 11568 interface IncomingRequestCfPropertiesBotManagement { 11569 /** 11570 * Results of Cloudflare's Bot Management analysis 11571 */ 11572 botManagement: IncomingRequestCfPropertiesBotManagementBase; 11573 /** 11574 * Duplicate of `botManagement.score`. 11575 * 11576 * @deprecated 11577 */ 11578 clientTrustScore: number; 11579 } 11580 interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement { 11581 /** 11582 * Results of Cloudflare's Bot Management analysis 11583 */ 11584 botManagement: IncomingRequestCfPropertiesBotManagementBase & { 11585 /** 11586 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients 11587 * across different destination IPs, Ports, and X509 certificates. 11588 */ 11589 ja3Hash: string; 11590 }; 11591 } 11592 interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> { 11593 /** 11594 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/). 11595 * 11596 * This field is only present if you have Cloudflare for SaaS enabled on your account 11597 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)). 11598 */ 11599 hostMetadata?: HostMetadata; 11600 } 11601 interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield { 11602 /** 11603 * Information about the client certificate presented to Cloudflare. 11604 * 11605 * This is populated when the incoming request is served over TLS using 11606 * either Cloudflare Access or API Shield (mTLS) 11607 * and the presented SSL certificate has a valid 11608 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number) 11609 * (i.e., not `null` or `""`). 11610 * 11611 * Otherwise, a set of placeholder values are used. 11612 * 11613 * The property `certPresented` will be set to `"1"` when 11614 * the object is populated (i.e. the above conditions were met). 11615 */ 11616 tlsClientAuth: IncomingRequestCfPropertiesTLSClientAuth | IncomingRequestCfPropertiesTLSClientAuthPlaceholder; 11617 } 11618 /** 11619 * Metadata about the request's TLS handshake 11620 */ 11621 interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata { 11622 /** 11623 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal 11624 * 11625 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" 11626 */ 11627 clientHandshake: string; 11628 /** 11629 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal 11630 * 11631 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d" 11632 */ 11633 serverHandshake: string; 11634 /** 11635 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal 11636 * 11637 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" 11638 */ 11639 clientFinished: string; 11640 /** 11641 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal 11642 * 11643 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b" 11644 */ 11645 serverFinished: string; 11646 } 11647 /** 11648 * Geographic data about the request's origin. 11649 */ 11650 interface IncomingRequestCfPropertiesGeographicInformation { 11651 /** 11652 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from. 11653 * 11654 * 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. 11655 * 11656 * If Cloudflare is unable to determine where the request originated this property is omitted. 11657 * 11658 * The country code `"T1"` is used for requests originating on TOR. 11659 * 11660 * @example "GB" 11661 */ 11662 country?: Iso3166Alpha2Code | "T1"; 11663 /** 11664 * If present, this property indicates that the request originated in the EU 11665 * 11666 * @example "1" 11667 */ 11668 isEUCountry?: "1"; 11669 /** 11670 * A two-letter code indicating the continent the request originated from. 11671 * 11672 * @example "AN" 11673 */ 11674 continent?: ContinentCode; 11675 /** 11676 * The city the request originated from 11677 * 11678 * @example "Austin" 11679 */ 11680 city?: string; 11681 /** 11682 * Postal code of the incoming request 11683 * 11684 * @example "78701" 11685 */ 11686 postalCode?: string; 11687 /** 11688 * Latitude of the incoming request 11689 * 11690 * @example "30.27130" 11691 */ 11692 latitude?: string; 11693 /** 11694 * Longitude of the incoming request 11695 * 11696 * @example "-97.74260" 11697 */ 11698 longitude?: string; 11699 /** 11700 * Timezone of the incoming request 11701 * 11702 * @example "America/Chicago" 11703 */ 11704 timezone?: string; 11705 /** 11706 * If known, the ISO 3166-2 name for the first level region associated with 11707 * the IP address of the incoming request 11708 * 11709 * @example "Texas" 11710 */ 11711 region?: string; 11712 /** 11713 * If known, the ISO 3166-2 code for the first-level region associated with 11714 * the IP address of the incoming request 11715 * 11716 * @example "TX" 11717 */ 11718 regionCode?: string; 11719 /** 11720 * Metro code (DMA) of the incoming request 11721 * 11722 * @example "635" 11723 */ 11724 metroCode?: string; 11725 } 11726 /** Data about the incoming request's TLS certificate */ 11727 interface IncomingRequestCfPropertiesTLSClientAuth { 11728 /** Always `"1"`, indicating that the certificate was presented */ 11729 certPresented: "1"; 11730 /** 11731 * Result of certificate verification. 11732 * 11733 * @example "FAILED:self signed certificate" 11734 */ 11735 certVerified: Exclude<CertVerificationStatus, "NONE">; 11736 /** The presented certificate's revokation status. 11737 * 11738 * - A value of `"1"` indicates the certificate has been revoked 11739 * - A value of `"0"` indicates the certificate has not been revoked 11740 */ 11741 certRevoked: "1" | "0"; 11742 /** 11743 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) 11744 * 11745 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 11746 */ 11747 certIssuerDN: string; 11748 /** 11749 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) 11750 * 11751 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 11752 */ 11753 certSubjectDN: string; 11754 /** 11755 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) 11756 * 11757 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 11758 */ 11759 certIssuerDNRFC2253: string; 11760 /** 11761 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted) 11762 * 11763 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare" 11764 */ 11765 certSubjectDNRFC2253: string; 11766 /** The certificate issuer's distinguished name (legacy policies) */ 11767 certIssuerDNLegacy: string; 11768 /** The certificate subject's distinguished name (legacy policies) */ 11769 certSubjectDNLegacy: string; 11770 /** 11771 * The certificate's serial number 11772 * 11773 * @example "00936EACBE07F201DF" 11774 */ 11775 certSerial: string; 11776 /** 11777 * The certificate issuer's serial number 11778 * 11779 * @example "2489002934BDFEA34" 11780 */ 11781 certIssuerSerial: string; 11782 /** 11783 * The certificate's Subject Key Identifier 11784 * 11785 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" 11786 */ 11787 certSKI: string; 11788 /** 11789 * The certificate issuer's Subject Key Identifier 11790 * 11791 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4" 11792 */ 11793 certIssuerSKI: string; 11794 /** 11795 * The certificate's SHA-1 fingerprint 11796 * 11797 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e" 11798 */ 11799 certFingerprintSHA1: string; 11800 /** 11801 * The certificate's SHA-256 fingerprint 11802 * 11803 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea" 11804 */ 11805 certFingerprintSHA256: string; 11806 /** 11807 * The effective starting date of the certificate 11808 * 11809 * @example "Dec 22 19:39:00 2018 GMT" 11810 */ 11811 certNotBefore: string; 11812 /** 11813 * The effective expiration date of the certificate 11814 * 11815 * @example "Dec 22 19:39:00 2018 GMT" 11816 */ 11817 certNotAfter: string; 11818 /** 11819 * The client leaf certificate in [RFC 9440](https://www.rfc-editor.org/rfc/rfc9440) 11820 * format (`:base64-DER:`). Empty if no client certificate was presented or if 11821 * the leaf certificate exceeded 10 KB (see {@link certRFC9440TooLarge}). 11822 * 11823 * Suitable for forwarding to an origin via the `Client-Cert` HTTP header. 11824 */ 11825 certRFC9440: string; 11826 /** 11827 * `true` if the leaf certificate exceeded 10 KB and was omitted from 11828 * {@link certRFC9440}. 11829 */ 11830 certRFC9440TooLarge: boolean; 11831 /** 11832 * The intermediate certificate chain in [RFC 9440](https://www.rfc-editor.org/rfc/rfc9440) 11833 * format as a comma-separated list. Empty if no intermediates were sent or 11834 * if the chain exceeded 16 KB (see {@link certChainRFC9440TooLarge}). 11835 * 11836 * Suitable for forwarding to an origin via the `Client-Cert-Chain` HTTP header. 11837 */ 11838 certChainRFC9440: string; 11839 /** 11840 * `true` if the intermediate chain exceeded 16 KB and was omitted from 11841 * {@link certChainRFC9440}. 11842 */ 11843 certChainRFC9440TooLarge: boolean; 11844 } 11845 /** Placeholder values for TLS Client Authorization */ 11846 interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder { 11847 certPresented: "0"; 11848 certVerified: "NONE"; 11849 certRevoked: "0"; 11850 certIssuerDN: ""; 11851 certSubjectDN: ""; 11852 certIssuerDNRFC2253: ""; 11853 certSubjectDNRFC2253: ""; 11854 certIssuerDNLegacy: ""; 11855 certSubjectDNLegacy: ""; 11856 certSerial: ""; 11857 certIssuerSerial: ""; 11858 certSKI: ""; 11859 certIssuerSKI: ""; 11860 certFingerprintSHA1: ""; 11861 certFingerprintSHA256: ""; 11862 certNotBefore: ""; 11863 certNotAfter: ""; 11864 certRFC9440: ""; 11865 certRFC9440TooLarge: false; 11866 certChainRFC9440: ""; 11867 certChainRFC9440TooLarge: false; 11868 } 11869 /** Possible outcomes of TLS verification */ 11870 declare type CertVerificationStatus = 11871 /** Authentication succeeded */ 11872 "SUCCESS" 11873 /** No certificate was presented */ 11874 | "NONE" 11875 /** Failed because the certificate was self-signed */ 11876 | "FAILED:self signed certificate" 11877 /** Failed because the certificate failed a trust chain check */ 11878 | "FAILED:unable to verify the first certificate" 11879 /** Failed because the certificate not yet valid */ 11880 | "FAILED:certificate is not yet valid" 11881 /** Failed because the certificate is expired */ 11882 | "FAILED:certificate has expired" 11883 /** Failed for another unspecified reason */ 11884 | "FAILED"; 11885 /** 11886 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare. 11887 */ 11888 declare 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 */ 11889 /** ISO 3166-1 Alpha-2 codes */ 11890 declare 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"; 11891 /** The 2-letter continent codes Cloudflare uses */ 11892 declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA"; 11893 type CfProperties<HostMetadata = unknown> = IncomingRequestCfProperties<HostMetadata> | RequestInitCfProperties; 11894 interface D1Meta { 11895 duration: number; 11896 size_after: number; 11897 rows_read: number; 11898 rows_written: number; 11899 last_row_id: number; 11900 changed_db: boolean; 11901 changes: number; 11902 /** 11903 * The region of the database instance that executed the query. 11904 */ 11905 served_by_region?: string; 11906 /** 11907 * The three letters airport code of the colo that executed the query. 11908 */ 11909 served_by_colo?: string; 11910 /** 11911 * True if-and-only-if the database instance that executed the query was the primary. 11912 */ 11913 served_by_primary?: boolean; 11914 timings?: { 11915 /** 11916 * The duration of the SQL query execution by the database instance. It doesn't include any network time. 11917 */ 11918 sql_duration_ms: number; 11919 }; 11920 /** 11921 * Number of total attempts to execute the query, due to automatic retries. 11922 * Note: All other fields in the response like `timings` only apply to the last attempt. 11923 */ 11924 total_attempts?: number; 11925 } 11926 interface D1Response { 11927 success: true; 11928 meta: D1Meta & Record<string, unknown>; 11929 error?: never; 11930 } 11931 type D1Result<T = unknown> = D1Response & { 11932 results: T[]; 11933 }; 11934 interface D1ExecResult { 11935 count: number; 11936 duration: number; 11937 } 11938 type D1SessionConstraint = 11939 // Indicates that the first query should go to the primary, and the rest queries 11940 // using the same D1DatabaseSession will go to any replica that is consistent with 11941 // the bookmark maintained by the session (returned by the first query). 11942 'first-primary' 11943 // Indicates that the first query can go anywhere (primary or replica), and the rest queries 11944 // using the same D1DatabaseSession will go to any replica that is consistent with 11945 // the bookmark maintained by the session (returned by the first query). 11946 | 'first-unconstrained'; 11947 type D1SessionBookmark = string; 11948 declare abstract class D1Database { 11949 prepare(query: string): D1PreparedStatement; 11950 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>; 11951 exec(query: string): Promise<D1ExecResult>; 11952 /** 11953 * Creates a new D1 Session anchored at the given constraint or the bookmark. 11954 * All queries executed using the created session will have sequential consistency, 11955 * meaning that all writes done through the session will be visible in subsequent reads. 11956 * 11957 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session. 11958 */ 11959 withSession(constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint): D1DatabaseSession; 11960 /** 11961 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases. 11962 */ 11963 dump(): Promise<ArrayBuffer>; 11964 } 11965 declare abstract class D1DatabaseSession { 11966 prepare(query: string): D1PreparedStatement; 11967 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>; 11968 /** 11969 * @returns The latest session bookmark across all executed queries on the session. 11970 * If no query has been executed yet, `null` is returned. 11971 */ 11972 getBookmark(): D1SessionBookmark | null; 11973 } 11974 declare abstract class D1PreparedStatement { 11975 bind(...values: unknown[]): D1PreparedStatement; 11976 first<T = unknown>(colName: string): Promise<T | null>; 11977 first<T = Record<string, unknown>>(): Promise<T | null>; 11978 run<T = Record<string, unknown>>(): Promise<D1Result<T>>; 11979 all<T = Record<string, unknown>>(): Promise<D1Result<T>>; 11980 raw<T = unknown[]>(options: { 11981 columnNames: true; 11982 }): Promise<[ 11983 string[], 11984 ...T[] 11985 ]>; 11986 raw<T = unknown[]>(options?: { 11987 columnNames?: false; 11988 }): Promise<T[]>; 11989 } 11990 // `Disposable` was added to TypeScript's standard lib types in version 5.2. 11991 // To support older TypeScript versions, define an empty `Disposable` interface. 11992 // Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2, 11993 // but this will ensure type checking on older versions still passes. 11994 // TypeScript's interface merging will ensure our empty interface is effectively 11995 // ignored when `Disposable` is included in the standard lib. 11996 interface Disposable { 11997 } 11998 /** 11999 * The returned data after sending an email 12000 */ 12001 interface EmailSendResult { 12002 /** 12003 * The Email Message ID 12004 */ 12005 messageId: string; 12006 } 12007 /** 12008 * An email message that can be sent from a Worker. 12009 */ 12010 interface EmailMessage { 12011 /** 12012 * Envelope From attribute of the email message. 12013 */ 12014 readonly from: string; 12015 /** 12016 * Envelope To attribute of the email message. 12017 */ 12018 readonly to: string; 12019 } 12020 /** 12021 * An email message that is sent to a consumer Worker and can be rejected/forwarded. 12022 */ 12023 interface ForwardableEmailMessage extends EmailMessage { 12024 /** 12025 * Stream of the email message content. 12026 */ 12027 readonly raw: ReadableStream<Uint8Array>; 12028 /** 12029 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). 12030 */ 12031 readonly headers: Headers; 12032 /** 12033 * Size of the email message content. 12034 */ 12035 readonly rawSize: number; 12036 /** 12037 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason. 12038 * @param reason The reject reason. 12039 * @returns void 12040 */ 12041 setReject(reason: string): void; 12042 /** 12043 * Forward this email message to a verified destination address of the account. 12044 * @param rcptTo Verified destination address. 12045 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers). 12046 * @returns A promise that resolves when the email message is forwarded. 12047 */ 12048 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>; 12049 /** 12050 * Reply to the sender of this email message with a new EmailMessage object. 12051 * @param message The reply message. 12052 * @returns A promise that resolves when the email message is replied. 12053 */ 12054 reply(message: EmailMessage): Promise<EmailSendResult>; 12055 } 12056 /** A file attachment for an email message */ 12057 type EmailAttachment = { 12058 disposition: 'inline'; 12059 contentId: string; 12060 filename: string; 12061 type: string; 12062 content: string | ArrayBuffer | ArrayBufferView; 12063 } | { 12064 disposition: 'attachment'; 12065 contentId?: undefined; 12066 filename: string; 12067 type: string; 12068 content: string | ArrayBuffer | ArrayBufferView; 12069 }; 12070 /** An Email Address */ 12071 interface EmailAddress { 12072 name: string; 12073 email: string; 12074 } 12075 /** 12076 * A binding that allows a Worker to send email messages. 12077 */ 12078 interface SendEmail { 12079 send(message: EmailMessage): Promise<EmailSendResult>; 12080 send(builder: { 12081 from: string | EmailAddress; 12082 to: string | EmailAddress | (string | EmailAddress)[]; 12083 subject: string; 12084 replyTo?: string | EmailAddress; 12085 cc?: string | EmailAddress | (string | EmailAddress)[]; 12086 bcc?: string | EmailAddress | (string | EmailAddress)[]; 12087 headers?: Record<string, string>; 12088 text?: string; 12089 html?: string; 12090 attachments?: EmailAttachment[]; 12091 }): Promise<EmailSendResult>; 12092 } 12093 declare abstract class EmailEvent extends ExtendableEvent { 12094 readonly message: ForwardableEmailMessage; 12095 } 12096 declare type EmailExportedHandler<Env = unknown, Props = unknown> = (message: ForwardableEmailMessage, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>; 12097 declare module "cloudflare:email" { 12098 let _EmailMessage: { 12099 prototype: EmailMessage; 12100 new (from: string, to: string, raw: ReadableStream | string): EmailMessage; 12101 }; 12102 export { _EmailMessage as EmailMessage }; 12103 } 12104 /** 12105 * Evaluation context for targeting rules. 12106 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values. 12107 */ 12108 type FlagshipEvaluationContext = Record<string, string | number | boolean>; 12109 interface FlagshipEvaluationDetails<T> { 12110 flagKey: string; 12111 value: T; 12112 variant?: string | undefined; 12113 reason?: string | undefined; 12114 errorCode?: string | undefined; 12115 errorMessage?: string | undefined; 12116 } 12117 interface FlagshipEvaluationError extends Error { 12118 } 12119 /** 12120 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script. 12121 * 12122 * @example 12123 * ```typescript 12124 * // Get a boolean flag value with a default 12125 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false); 12126 * 12127 * // Get a flag value with evaluation context for targeting 12128 * const variant = await env.FLAGS.getStringValue('experiment', 'control', { 12129 * userId: 'user-123', 12130 * country: 'US', 12131 * }); 12132 * 12133 * // Get full evaluation details including variant and reason 12134 * const details = await env.FLAGS.getBooleanDetails('my-feature', false); 12135 * console.log(details.variant, details.reason); 12136 * ``` 12137 */ 12138 declare abstract class Flagship { 12139 /** 12140 * Get a flag value without type checking. 12141 * @param flagKey The key of the flag to evaluate. 12142 * @param defaultValue Optional default value returned when evaluation fails. 12143 * @param context Optional evaluation context for targeting rules. 12144 */ 12145 get(flagKey: string, defaultValue?: unknown, context?: FlagshipEvaluationContext): Promise<unknown>; 12146 /** 12147 * Get a boolean flag value. 12148 * @param flagKey The key of the flag to evaluate. 12149 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12150 * @param context Optional evaluation context for targeting rules. 12151 */ 12152 getBooleanValue(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<boolean>; 12153 /** 12154 * Get a string flag value. 12155 * @param flagKey The key of the flag to evaluate. 12156 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12157 * @param context Optional evaluation context for targeting rules. 12158 */ 12159 getStringValue(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<string>; 12160 /** 12161 * Get a number flag value. 12162 * @param flagKey The key of the flag to evaluate. 12163 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12164 * @param context Optional evaluation context for targeting rules. 12165 */ 12166 getNumberValue(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<number>; 12167 /** 12168 * Get an object flag value. 12169 * @param flagKey The key of the flag to evaluate. 12170 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12171 * @param context Optional evaluation context for targeting rules. 12172 */ 12173 getObjectValue<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<T>; 12174 /** 12175 * Get a boolean flag value with full evaluation details. 12176 * @param flagKey The key of the flag to evaluate. 12177 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12178 * @param context Optional evaluation context for targeting rules. 12179 */ 12180 getBooleanDetails(flagKey: string, defaultValue: boolean, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<boolean>>; 12181 /** 12182 * Get a string flag value with full evaluation details. 12183 * @param flagKey The key of the flag to evaluate. 12184 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12185 * @param context Optional evaluation context for targeting rules. 12186 */ 12187 getStringDetails(flagKey: string, defaultValue: string, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<string>>; 12188 /** 12189 * Get a number flag value with full evaluation details. 12190 * @param flagKey The key of the flag to evaluate. 12191 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12192 * @param context Optional evaluation context for targeting rules. 12193 */ 12194 getNumberDetails(flagKey: string, defaultValue: number, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<number>>; 12195 /** 12196 * Get an object flag value with full evaluation details. 12197 * @param flagKey The key of the flag to evaluate. 12198 * @param defaultValue Default value returned when evaluation fails or the flag type does not match. 12199 * @param context Optional evaluation context for targeting rules. 12200 */ 12201 getObjectDetails<T extends object>(flagKey: string, defaultValue: T, context?: FlagshipEvaluationContext): Promise<FlagshipEvaluationDetails<T>>; 12202 } 12203 /** 12204 * Hello World binding to serve as an explanatory example. DO NOT USE 12205 */ 12206 interface HelloWorldBinding { 12207 /** 12208 * Retrieve the current stored value 12209 */ 12210 get(): Promise<{ 12211 value: string; 12212 ms?: number; 12213 }>; 12214 /** 12215 * Set a new stored value 12216 */ 12217 set(value: string): Promise<void>; 12218 } 12219 interface Hyperdrive { 12220 /** 12221 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket. 12222 * 12223 * Calling this method returns an identical socket to if you call 12224 * `connect("host:port")` using the `host` and `port` fields from this object. 12225 * Pick whichever approach works better with your preferred DB client library. 12226 * 12227 * Note that this socket is not yet authenticated -- it's expected that your 12228 * code (or preferably, the client library of your choice) will authenticate 12229 * using the information in this class's readonly fields. 12230 */ 12231 connect(): Socket; 12232 /** 12233 * A valid DB connection string that can be passed straight into the typical 12234 * client library/driver/ORM. This will typically be the easiest way to use 12235 * Hyperdrive. 12236 */ 12237 readonly connectionString: string; 12238 /* 12239 * A randomly generated hostname that is only valid within the context of the 12240 * currently running Worker which, when passed into `connect()` function from 12241 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance 12242 * for your database. 12243 */ 12244 readonly host: string; 12245 /* 12246 * The port that must be paired the the host field when connecting. 12247 */ 12248 readonly port: number; 12249 /* 12250 * The username to use when authenticating to your database via Hyperdrive. 12251 * Unlike the host and password, this will be the same every time 12252 */ 12253 readonly user: string; 12254 /* 12255 * The randomly generated password to use when authenticating to your 12256 * database via Hyperdrive. Like the host field, this password is only valid 12257 * within the context of the currently running Worker instance from which 12258 * it's read. 12259 */ 12260 readonly password: string; 12261 /* 12262 * The name of the database to connect to. 12263 */ 12264 readonly database: string; 12265 } 12266 // Copyright (c) 2024 Cloudflare, Inc. 12267 // Licensed under the Apache 2.0 license found in the LICENSE file or at: 12268 // https://opensource.org/licenses/Apache-2.0 12269 type ImageInfoResponse = { 12270 format: 'image/svg+xml'; 12271 } | { 12272 format: string; 12273 fileSize: number; 12274 width: number; 12275 height: number; 12276 }; 12277 type ImageTransform = { 12278 width?: number; 12279 height?: number; 12280 background?: string; 12281 blur?: number; 12282 border?: { 12283 color?: string; 12284 width?: number; 12285 } | { 12286 top?: number; 12287 bottom?: number; 12288 left?: number; 12289 right?: number; 12290 }; 12291 brightness?: number; 12292 contrast?: number; 12293 fit?: 'scale-down' | 'contain' | 'pad' | 'squeeze' | 'cover' | 'crop'; 12294 flip?: 'h' | 'v' | 'hv'; 12295 gamma?: number; 12296 segment?: 'foreground'; 12297 gravity?: 'face' | 'left' | 'right' | 'top' | 'bottom' | 'center' | 'auto' | 'entropy' | { 12298 x?: number; 12299 y?: number; 12300 mode: 'remainder' | 'box-center'; 12301 }; 12302 rotate?: 0 | 90 | 180 | 270; 12303 saturation?: number; 12304 sharpen?: number; 12305 trim?: 'border' | { 12306 top?: number; 12307 bottom?: number; 12308 left?: number; 12309 right?: number; 12310 width?: number; 12311 height?: number; 12312 border?: boolean | { 12313 color?: string; 12314 tolerance?: number; 12315 keep?: number; 12316 }; 12317 }; 12318 }; 12319 type ImageDrawOptions = { 12320 opacity?: number; 12321 repeat?: boolean | string; 12322 composite?: ImageCompositeMode; 12323 top?: number; 12324 left?: number; 12325 bottom?: number; 12326 right?: number; 12327 }; 12328 type ImageCompositeMode = 12329 /** Foreground drawn on top of backdrop (default) */ 12330 'over' 12331 /** Foreground shown only where backdrop is opaque */ 12332 | 'in' 12333 /** Foreground drawn on top, but clipped to the backdrop's shape */ 12334 | 'atop' 12335 /** Foreground shown only where backdrop is transparent */ 12336 | 'out' 12337 /** Foreground and backdrop visible only where the other is not */ 12338 | 'xor' 12339 /** Foreground and backdrop channels added (brightening) */ 12340 | 'lighter'; 12341 type ImageInputOptions = { 12342 encoding?: 'base64'; 12343 }; 12344 type ImageOutputOptions = { 12345 format: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp' | 'image/avif' | 'rgb' | 'rgba'; 12346 quality?: number; 12347 background?: string; 12348 anim?: boolean; 12349 }; 12350 interface ImageMetadata { 12351 id: string; 12352 filename?: string; 12353 uploaded?: string; 12354 requireSignedURLs: boolean; 12355 meta?: Record<string, unknown>; 12356 variants: string[]; 12357 draft?: boolean; 12358 creator?: string; 12359 } 12360 interface ImageUploadOptions { 12361 id?: string; 12362 filename?: string; 12363 requireSignedURLs?: boolean; 12364 metadata?: Record<string, unknown>; 12365 creator?: string; 12366 encoding?: 'base64'; 12367 } 12368 interface ImageUpdateOptions { 12369 requireSignedURLs?: boolean; 12370 metadata?: Record<string, unknown>; 12371 creator?: string; 12372 } 12373 interface ImageListOptions { 12374 limit?: number; 12375 cursor?: string; 12376 sortOrder?: 'asc' | 'desc'; 12377 creator?: string; 12378 } 12379 interface ImageList { 12380 images: ImageMetadata[]; 12381 cursor?: string; 12382 listComplete: boolean; 12383 } 12384 interface ImageHandle { 12385 /** 12386 * Get metadata for a hosted image 12387 * @returns Image metadata, or null if not found 12388 */ 12389 details(): Promise<ImageMetadata | null>; 12390 /** 12391 * Get the raw image data for a hosted image 12392 * @returns ReadableStream of image bytes, or null if not found 12393 */ 12394 bytes(): Promise<ReadableStream<Uint8Array> | null>; 12395 /** 12396 * Update hosted image metadata 12397 * @param options Properties to update 12398 * @returns Updated image metadata 12399 * @throws {@link ImagesError} if update fails 12400 */ 12401 update(options: ImageUpdateOptions): Promise<ImageMetadata>; 12402 /** 12403 * Delete a hosted image 12404 * @returns True if deleted, false if not found 12405 */ 12406 delete(): Promise<boolean>; 12407 } 12408 interface HostedImagesBinding { 12409 /** 12410 * Get a handle for a hosted image 12411 * @param imageId The ID of the image (UUID or custom ID) 12412 * @returns A handle for per-image operations 12413 */ 12414 image(imageId: string): ImageHandle; 12415 /** 12416 * Upload a new hosted image 12417 * @param image The image file to upload 12418 * @param options Upload configuration 12419 * @returns Metadata for the uploaded image 12420 * @throws {@link ImagesError} if upload fails 12421 */ 12422 upload(image: ReadableStream<Uint8Array> | ArrayBuffer, options?: ImageUploadOptions): Promise<ImageMetadata>; 12423 /** 12424 * List hosted images with pagination 12425 * @param options List configuration 12426 * @returns List of images with pagination info 12427 * @throws {@link ImagesError} if list fails 12428 */ 12429 list(options?: ImageListOptions): Promise<ImageList>; 12430 } 12431 interface ImagesBinding { 12432 /** 12433 * Get image metadata (type, width and height) 12434 * @throws {@link ImagesError} with code 9412 if input is not an image 12435 * @param stream The image bytes 12436 */ 12437 info(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): Promise<ImageInfoResponse>; 12438 /** 12439 * Begin applying a series of transformations to an image 12440 * @param stream The image bytes 12441 * @returns A transform handle 12442 */ 12443 input(stream: ReadableStream<Uint8Array>, options?: ImageInputOptions): ImageTransformer; 12444 /** 12445 * Access hosted images CRUD operations 12446 */ 12447 readonly hosted: HostedImagesBinding; 12448 } 12449 interface ImageTransformer { 12450 /** 12451 * Apply transform next, returning a transform handle. 12452 * You can then apply more transformations, draw, or retrieve the output. 12453 * @param transform 12454 */ 12455 transform(transform: ImageTransform): ImageTransformer; 12456 /** 12457 * Draw an image on this transformer, returning a transform handle. 12458 * You can then apply more transformations, draw, or retrieve the output. 12459 * @param image The image (or transformer that will give the image) to draw 12460 * @param options The options configuring how to draw the image 12461 */ 12462 draw(image: ReadableStream<Uint8Array> | ImageTransformer, options?: ImageDrawOptions): ImageTransformer; 12463 /** 12464 * Retrieve the image that results from applying the transforms to the 12465 * provided input 12466 * @param options Options that apply to the output e.g. output format 12467 */ 12468 output(options: ImageOutputOptions): Promise<ImageTransformationResult>; 12469 } 12470 type ImageTransformationOutputOptions = { 12471 encoding?: 'base64'; 12472 }; 12473 interface ImageTransformationResult { 12474 /** 12475 * The image as a response, ready to store in cache or return to users 12476 */ 12477 response(): Response; 12478 /** 12479 * The content type of the returned image 12480 */ 12481 contentType(): string; 12482 /** 12483 * The bytes of the response 12484 */ 12485 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>; 12486 } 12487 interface ImagesError extends Error { 12488 readonly code: number; 12489 readonly message: string; 12490 readonly stack?: string; 12491 } 12492 /** 12493 * Media binding for transforming media streams. 12494 * Provides the entry point for media transformation operations. 12495 */ 12496 interface MediaBinding { 12497 /** 12498 * Creates a media transformer from an input stream. 12499 * @param media - The input media bytes 12500 * @returns A MediaTransformer instance for applying transformations 12501 */ 12502 input(media: ReadableStream<Uint8Array>): MediaTransformer; 12503 } 12504 /** 12505 * Media transformer for applying transformation operations to media content. 12506 * Handles sizing, fitting, and other input transformation parameters. 12507 */ 12508 interface MediaTransformer { 12509 /** 12510 * Applies transformation options to the media content. 12511 * @param transform - Configuration for how the media should be transformed 12512 * @returns A generator for producing the transformed media output 12513 */ 12514 transform(transform?: MediaTransformationInputOptions): MediaTransformationGenerator; 12515 /** 12516 * Generates the final media output with specified options. 12517 * @param output - Configuration for the output format and parameters 12518 * @returns The final transformation result containing the transformed media 12519 */ 12520 output(output?: MediaTransformationOutputOptions): MediaTransformationResult; 12521 } 12522 /** 12523 * Generator for producing media transformation results. 12524 * Configures the output format and parameters for the transformed media. 12525 */ 12526 interface MediaTransformationGenerator { 12527 /** 12528 * Generates the final media output with specified options. 12529 * @param output - Configuration for the output format and parameters 12530 * @returns The final transformation result containing the transformed media 12531 */ 12532 output(output?: MediaTransformationOutputOptions): MediaTransformationResult; 12533 } 12534 /** 12535 * Result of a media transformation operation. 12536 * Provides multiple ways to access the transformed media content. 12537 */ 12538 interface MediaTransformationResult { 12539 /** 12540 * Returns the transformed media as a readable stream of bytes. 12541 * @returns A promise containing a readable stream with the transformed media 12542 */ 12543 media(): Promise<ReadableStream<Uint8Array>>; 12544 /** 12545 * Returns the transformed media as an HTTP response object. 12546 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users 12547 */ 12548 response(): Promise<Response>; 12549 /** 12550 * Returns the MIME type of the transformed media. 12551 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4') 12552 */ 12553 contentType(): Promise<string>; 12554 } 12555 /** 12556 * Configuration options for transforming media input. 12557 * Controls how the media should be resized and fitted. 12558 */ 12559 type MediaTransformationInputOptions = { 12560 /** How the media should be resized to fit the specified dimensions */ 12561 fit?: 'contain' | 'cover' | 'scale-down'; 12562 /** Target width in pixels */ 12563 width?: number; 12564 /** Target height in pixels */ 12565 height?: number; 12566 }; 12567 /** 12568 * Configuration options for Media Transformations output. 12569 * Controls the format, timing, and type of the generated output. 12570 */ 12571 type MediaTransformationOutputOptions = { 12572 /** 12573 * Output mode determining the type of media to generate 12574 */ 12575 mode?: 'video' | 'spritesheet' | 'frame' | 'audio'; 12576 /** Whether to include audio in the output */ 12577 audio?: boolean; 12578 /** 12579 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s'). 12580 */ 12581 time?: string; 12582 /** 12583 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s'). 12584 */ 12585 duration?: string; 12586 /** 12587 * Number of frames in the spritesheet. 12588 */ 12589 imageCount?: number; 12590 /** 12591 * Output format for the generated media. 12592 */ 12593 format?: 'jpg' | 'png' | 'm4a'; 12594 }; 12595 /** 12596 * Error object for media transformation operations. 12597 * Extends the standard Error interface with additional media-specific information. 12598 */ 12599 interface MediaError extends Error { 12600 readonly code: number; 12601 readonly message: string; 12602 readonly stack?: string; 12603 } 12604 declare module 'cloudflare:node' { 12605 interface NodeStyleServer { 12606 listen(...args: unknown[]): this; 12607 address(): { 12608 port?: number | null | undefined; 12609 }; 12610 } 12611 export function httpServerHandler(port: number): ExportedHandler; 12612 export function httpServerHandler(options: { 12613 port: number; 12614 }): ExportedHandler; 12615 export function httpServerHandler(server: NodeStyleServer): ExportedHandler; 12616 } 12617 type Params<P extends string = any> = Record<P, string | string[]>; 12618 type EventContext<Env, P extends string, Data> = { 12619 request: Request<unknown, IncomingRequestCfProperties<unknown>>; 12620 functionPath: string; 12621 waitUntil: (promise: Promise<any>) => void; 12622 passThroughOnException: () => void; 12623 next: (input?: Request | string, init?: RequestInit) => Promise<Response>; 12624 env: Env & { 12625 ASSETS: { 12626 fetch: typeof fetch; 12627 }; 12628 }; 12629 params: Params<P>; 12630 data: Data; 12631 }; 12632 type PagesFunction<Env = unknown, Params extends string = any, Data extends Record<string, unknown> = Record<string, unknown>> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>; 12633 type EventPluginContext<Env, P extends string, Data, PluginArgs> = { 12634 request: Request<unknown, IncomingRequestCfProperties<unknown>>; 12635 functionPath: string; 12636 waitUntil: (promise: Promise<any>) => void; 12637 passThroughOnException: () => void; 12638 next: (input?: Request | string, init?: RequestInit) => Promise<Response>; 12639 env: Env & { 12640 ASSETS: { 12641 fetch: typeof fetch; 12642 }; 12643 }; 12644 params: Params<P>; 12645 data: Data; 12646 pluginArgs: PluginArgs; 12647 }; 12648 type 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>; 12649 declare module "assets:*" { 12650 export const onRequest: PagesFunction; 12651 } 12652 // Copyright (c) 2022-2023 Cloudflare, Inc. 12653 // Licensed under the Apache 2.0 license found in the LICENSE file or at: 12654 // https://opensource.org/licenses/Apache-2.0 12655 declare module "cloudflare:pipelines" { 12656 export abstract class PipelineTransformationEntrypoint<Env = unknown, I extends PipelineRecord = PipelineRecord, O extends PipelineRecord = PipelineRecord> { 12657 protected env: Env; 12658 protected ctx: ExecutionContext; 12659 constructor(ctx: ExecutionContext, env: Env); 12660 /** 12661 * run receives an array of PipelineRecord which can be 12662 * transformed and returned to the pipeline 12663 * @param records Incoming records from the pipeline to be transformed 12664 * @param metadata Information about the specific pipeline calling the transformation entrypoint 12665 * @returns A promise containing the transformed PipelineRecord array 12666 */ 12667 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>; 12668 } 12669 export type PipelineRecord = Record<string, unknown>; 12670 export type PipelineBatchMetadata = { 12671 pipelineId: string; 12672 pipelineName: string; 12673 }; 12674 export interface Pipeline<T extends PipelineRecord = PipelineRecord> { 12675 /** 12676 * The Pipeline interface represents the type of a binding to a Pipeline 12677 * 12678 * @param records The records to send to the pipeline 12679 */ 12680 send(records: T[]): Promise<void>; 12681 } 12682 } 12683 // PubSubMessage represents an incoming PubSub message. 12684 // The message includes metadata about the broker, the client, and the payload 12685 // itself. 12686 // https://developers.cloudflare.com/pub-sub/ 12687 interface PubSubMessage { 12688 // Message ID 12689 readonly mid: number; 12690 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT 12691 readonly broker: string; 12692 // The MQTT topic the message was sent on. 12693 readonly topic: string; 12694 // The client ID of the client that published this message. 12695 readonly clientId: string; 12696 // The unique identifier (JWT ID) used by the client to authenticate, if token 12697 // auth was used. 12698 readonly jti?: string; 12699 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker 12700 // received the message from the client. 12701 readonly receivedAt: number; 12702 // An (optional) string with the MIME type of the payload, if set by the 12703 // client. 12704 readonly contentType: string; 12705 // Set to 1 when the payload is a UTF-8 string 12706 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063 12707 readonly payloadFormatIndicator: number; 12708 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays. 12709 // You can use payloadFormatIndicator to inspect this before decoding. 12710 payload: string | Uint8Array; 12711 } 12712 // JsonWebKey extended by kid parameter 12713 interface JsonWebKeyWithKid extends JsonWebKey { 12714 // Key Identifier of the JWK 12715 readonly kid: string; 12716 } 12717 interface RateLimitOptions { 12718 key: string; 12719 } 12720 interface RateLimitOutcome { 12721 success: boolean; 12722 } 12723 interface RateLimit { 12724 /** 12725 * Rate limit a request based on the provided options. 12726 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/ 12727 * @returns A promise that resolves with the outcome of the rate limit. 12728 */ 12729 limit(options: RateLimitOptions): Promise<RateLimitOutcome>; 12730 } 12731 // Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need 12732 // to referenced by `Fetcher`. This is included in the "importable" version of the types which 12733 // strips all `module` blocks. 12734 declare namespace Rpc { 12735 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s. 12736 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`. 12737 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to 12738 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape) 12739 export const __RPC_STUB_BRAND: '__RPC_STUB_BRAND'; 12740 export const __RPC_TARGET_BRAND: '__RPC_TARGET_BRAND'; 12741 export const __WORKER_ENTRYPOINT_BRAND: '__WORKER_ENTRYPOINT_BRAND'; 12742 export const __DURABLE_OBJECT_BRAND: '__DURABLE_OBJECT_BRAND'; 12743 export const __WORKFLOW_ENTRYPOINT_BRAND: '__WORKFLOW_ENTRYPOINT_BRAND'; 12744 export interface RpcTargetBranded { 12745 [__RPC_TARGET_BRAND]: never; 12746 } 12747 export interface WorkerEntrypointBranded { 12748 [__WORKER_ENTRYPOINT_BRAND]: never; 12749 } 12750 export interface DurableObjectBranded { 12751 [__DURABLE_OBJECT_BRAND]: never; 12752 } 12753 export interface WorkflowEntrypointBranded { 12754 [__WORKFLOW_ENTRYPOINT_BRAND]: never; 12755 } 12756 export type EntrypointBranded = WorkerEntrypointBranded | DurableObjectBranded | WorkflowEntrypointBranded; 12757 // Types that can be used through `Stub`s 12758 export type Stubable = RpcTargetBranded | ((...args: any[]) => any); 12759 // Types that can be passed over RPC 12760 // The reason for using a generic type here is to build a serializable subset of structured 12761 // cloneable composite types. This allows types defined with the "interface" keyword to pass the 12762 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass. 12763 type Serializable<T> = 12764 // Structured cloneables 12765 BaseType 12766 // Structured cloneable composites 12767 | 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> | { 12768 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never; 12769 } 12770 // Special types 12771 | Stub<Stubable> 12772 // Serialized as stubs, see `Stubify` 12773 | Stubable; 12774 // Base type for all RPC stubs, including common memory management methods. 12775 // `T` is used as a marker type for unwrapping `Stub`s later. 12776 interface StubBase<T extends Stubable> extends Disposable { 12777 [__RPC_STUB_BRAND]: T; 12778 dup(): this; 12779 } 12780 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>; 12781 // This represents all the types that can be sent as-is over an RPC boundary 12782 type BaseType = void | undefined | null | boolean | number | bigint | string | TypedArray | ArrayBuffer | DataView | Date | Error | RegExp | ReadableStream<Uint8Array> | WritableStream<Uint8Array> | Request | Response | Headers; 12783 // Recursively rewrite all `Stubable` types with `Stub`s 12784 // prettier-ignore 12785 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 { 12786 [key: string | number]: any; 12787 } ? { 12788 [K in keyof T]: Stubify<T[K]>; 12789 } : T; 12790 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s. 12791 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies: 12792 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`. 12793 // prettier-ignore 12794 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 { 12795 [key: string | number]: unknown; 12796 } ? { 12797 [K in keyof T]: Unstubify<T[K]>; 12798 } : T; 12799 type UnstubifyAll<A extends any[]> = { 12800 [I in keyof A]: Unstubify<A[I]>; 12801 }; 12802 // Utility type for adding `Provider`/`Disposable`s to `object` types only. 12803 // Note `unknown & T` is equivalent to `T`. 12804 type MaybeProvider<T> = T extends object ? Provider<T> : unknown; 12805 type MaybeDisposable<T> = T extends object ? Disposable : unknown; 12806 // Type for method return or property on an RPC interface. 12807 // - Stubable types are replaced by stubs. 12808 // - Serializable types are passed by value, with stubable types replaced by stubs 12809 // and a top-level `Disposer`. 12810 // Everything else can't be passed over PRC. 12811 // Technically, we use custom thenables here, but they quack like `Promise`s. 12812 // Intersecting with `(Maybe)Provider` allows pipelining. 12813 // prettier-ignore 12814 type Result<R> = R extends Stubable ? Promise<Stub<R>> & Provider<R> : R extends Serializable<R> ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R> : never; 12815 // Type for method or property on an RPC interface. 12816 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s. 12817 // Unwrapping `Stub`s allows calling with `Stubable` arguments. 12818 // For properties, rewrite types to be `Result`s. 12819 // In each case, unwrap `Promise`s. 12820 type MethodOrProperty<V> = V extends (...args: infer P) => infer R ? (...args: UnstubifyAll<P>) => Result<Awaited<R>> : Result<Awaited<V>>; 12821 // Type for the callable part of an `Provider` if `T` is callable. 12822 // This is intersected with methods/properties. 12823 type MaybeCallableProvider<T> = T extends (...args: any[]) => any ? MethodOrProperty<T> : unknown; 12824 // Base type for all other types providing RPC-like interfaces. 12825 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types. 12826 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC. 12827 export type Provider<T extends object, Reserved extends string = never> = MaybeCallableProvider<T> & Pick<{ 12828 [K in keyof T]: MethodOrProperty<T[K]>; 12829 }, Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>>; 12830 } 12831 declare namespace Cloudflare { 12832 // Type of `env`. 12833 // 12834 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript 12835 // will merge all declarations. 12836 // 12837 // You can use `wrangler types` to generate the `Env` type automatically. 12838 interface Env { 12839 } 12840 // Project-specific parameters used to inform types. 12841 // 12842 // This interface is, again, intended to be declared in project-specific files, and then that 12843 // declaration will be merged with this one. 12844 // 12845 // A project should have a declaration like this: 12846 // 12847 // interface GlobalProps { 12848 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type 12849 // // of `ctx.exports`. 12850 // mainModule: typeof import("my-main-module"); 12851 // 12852 // // Declares which of the main module's exports are configured with durable storage, and 12853 // // thus should behave as Durable Object namsepace bindings. 12854 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject"; 12855 // } 12856 // 12857 // You can use `wrangler types` to generate `GlobalProps` automatically. 12858 interface GlobalProps { 12859 } 12860 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not 12861 // present. 12862 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps ? GlobalProps[K] : Default; 12863 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the 12864 // `mainModule` property. 12865 type MainModule = GlobalProp<"mainModule", {}>; 12866 // The type of ctx.exports, which contains loopback bindings for all top-level exports. 12867 type Exports = { 12868 [K in keyof MainModule]: LoopbackForExport<MainModule[K]> 12869 // If the export is listed in `durableNamespaces`, then it is also a 12870 // DurableObjectNamespace. 12871 & (K extends GlobalProp<"durableNamespaces", never> ? MainModule[K] extends new (...args: any[]) => infer DoInstance ? DoInstance extends Rpc.DurableObjectBranded ? DurableObjectNamespace<DoInstance> : DurableObjectNamespace<undefined> : DurableObjectNamespace<undefined> : {}); 12872 }; 12873 } 12874 declare namespace CloudflareWorkersModule { 12875 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>; 12876 export const RpcStub: { 12877 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>; 12878 }; 12879 export abstract class RpcTarget implements Rpc.RpcTargetBranded { 12880 [Rpc.__RPC_TARGET_BRAND]: never; 12881 } 12882 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC 12883 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}> implements Rpc.WorkerEntrypointBranded { 12884 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never; 12885 protected ctx: ExecutionContext<Props>; 12886 protected env: Env; 12887 constructor(ctx: ExecutionContext, env: Env); 12888 email?(message: ForwardableEmailMessage): void | Promise<void>; 12889 fetch?(request: Request): Response | Promise<Response>; 12890 connect?(socket: Socket): void | Promise<void>; 12891 queue?(batch: MessageBatch): void | Promise<void>; 12892 scheduled?(controller: ScheduledController): void | Promise<void>; 12893 tail?(events: TraceItem[]): void | Promise<void>; 12894 tailStream?(event: TailStream.TailEvent<TailStream.Onset>): TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>; 12895 test?(controller: TestController): void | Promise<void>; 12896 trace?(traces: TraceItem[]): void | Promise<void>; 12897 } 12898 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}> implements Rpc.DurableObjectBranded { 12899 [Rpc.__DURABLE_OBJECT_BRAND]: never; 12900 protected ctx: DurableObjectState<Props>; 12901 protected env: Env; 12902 constructor(ctx: DurableObjectState, env: Env); 12903 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>; 12904 fetch?(request: Request): Response | Promise<Response>; 12905 connect?(socket: Socket): void | Promise<void>; 12906 webSocketMessage?(ws: WebSocket, message: string | ArrayBuffer): void | Promise<void>; 12907 webSocketClose?(ws: WebSocket, code: number, reason: string, wasClean: boolean): void | Promise<void>; 12908 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>; 12909 } 12910 export type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; 12911 export type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; 12912 export type WorkflowDelayDuration = WorkflowSleepDuration; 12913 export type WorkflowTimeoutDuration = WorkflowSleepDuration; 12914 export type WorkflowRetentionDuration = WorkflowSleepDuration; 12915 export type WorkflowBackoff = 'constant' | 'linear' | 'exponential'; 12916 export type WorkflowStepSensitivity = 'output'; 12917 export type WorkflowStepConfig = { 12918 retries?: { 12919 limit: number; 12920 delay: WorkflowDelayDuration | number; 12921 backoff?: WorkflowBackoff; 12922 }; 12923 timeout?: WorkflowTimeoutDuration | number; 12924 sensitive?: WorkflowStepSensitivity; 12925 }; 12926 export type WorkflowCronSchedule = { 12927 /** Cron expression that triggered this event. */ 12928 cron: string; 12929 /** Timestamp of the scheduled trigger, in milliseconds since the Unix epoch. */ 12930 scheduledTime: number; 12931 }; 12932 export type WorkflowEvent<T> = { 12933 payload: Readonly<T>; 12934 timestamp: Date; 12935 instanceId: string; 12936 workflowName: string; 12937 schedule?: WorkflowCronSchedule; 12938 }; 12939 export type WorkflowStepEvent<T> = { 12940 payload: Readonly<T>; 12941 timestamp: Date; 12942 type: string; 12943 sensitive?: WorkflowStepSensitivity; 12944 }; 12945 export type WorkflowStepContext = { 12946 step: { 12947 name: string; 12948 count: number; 12949 }; 12950 attempt: number; 12951 config: WorkflowStepConfig; 12952 }; 12953 export type WorkflowRollbackContext<T = unknown> = { 12954 error: Error; 12955 output: T | undefined; 12956 stepName: string; 12957 }; 12958 export type WorkflowRollbackHandler<T = unknown> = (ctx: WorkflowRollbackContext<T>) => Promise<void>; 12959 export type WorkflowStepRollbackOptions<T = unknown> = { 12960 rollback?: WorkflowRollbackHandler<T>; 12961 rollbackConfig?: WorkflowStepConfig; 12962 }; 12963 export abstract class WorkflowStep { 12964 do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>; 12965 do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>; 12966 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>; 12967 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>; 12968 waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: { 12969 type: string; 12970 timeout?: WorkflowTimeoutDuration | number; 12971 }): Promise<WorkflowStepEvent<T>>; 12972 } 12973 export type WorkflowInstanceStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting' | 'waitingForPause' | 'unknown'; 12974 export abstract class WorkflowEntrypoint<Env = unknown, T extends Rpc.Serializable<T> | unknown = unknown> implements Rpc.WorkflowEntrypointBranded { 12975 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never; 12976 protected ctx: ExecutionContext; 12977 protected env: Env; 12978 constructor(ctx: ExecutionContext, env: Env); 12979 run(event: Readonly<WorkflowEvent<T>>, step: WorkflowStep): Promise<unknown>; 12980 } 12981 export function waitUntil(promise: Promise<unknown>): void; 12982 export function withEnv(newEnv: unknown, fn: () => unknown): unknown; 12983 export function withExports(newExports: unknown, fn: () => unknown): unknown; 12984 export function withEnvAndExports(newEnv: unknown, newExports: unknown, fn: () => unknown): unknown; 12985 export const env: Cloudflare.Env; 12986 export const exports: Cloudflare.Exports; 12987 export const cache: CacheContext; 12988 export const tracing: Tracing; 12989 } 12990 declare module 'cloudflare:workers' { 12991 export = CloudflareWorkersModule; 12992 } 12993 interface SecretsStoreSecret { 12994 /** 12995 * Get a secret from the Secrets Store, returning a string of the secret value 12996 * if it exists, or throws an error if it does not exist 12997 */ 12998 get(): Promise<string>; 12999 } 13000 declare module "cloudflare:sockets" { 13001 function _connect(address: string | SocketAddress, options?: SocketOptions): Socket; 13002 export { _connect as connect }; 13003 } 13004 /** 13005 * Binding entrypoint for Cloudflare Stream. 13006 * 13007 * Usage: 13008 * - Binding-level operations: 13009 * `await env.STREAM.videos.upload` 13010 * `await env.STREAM.videos.createDirectUpload` 13011 * `await env.STREAM.videos.*` 13012 * `await env.STREAM.watermarks.*` 13013 * - Per-video operations: 13014 * `await env.STREAM.video(id).downloads.*` 13015 * `await env.STREAM.video(id).captions.*` 13016 * 13017 * Example usage: 13018 * ```ts 13019 * await env.STREAM.video(id).downloads.generate(); 13020 * 13021 * const video = env.STREAM.video(id) 13022 * const captions = video.captions.list(); 13023 * const videoDetails = video.details() 13024 * ``` 13025 */ 13026 interface StreamBinding { 13027 /** 13028 * Returns a handle scoped to a single video for per-video operations. 13029 * @param id The unique identifier for the video. 13030 * @returns A handle for per-video operations. 13031 */ 13032 video(id: string): StreamVideoHandle; 13033 /** 13034 * Uploads a new video from a provided URL. 13035 * @param url The URL to upload from. 13036 * @param params Optional upload parameters. 13037 * @returns The uploaded video details. 13038 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid 13039 * @throws {QuotaReachedError} if the account storage capacity is exceeded 13040 * @throws {MaxFileSizeError} if the file size is too large 13041 * @throws {RateLimitedError} if the server received too many requests 13042 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL 13043 * @throws {InternalError} if an unexpected error occurs 13044 */ 13045 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>; 13046 /** 13047 * Creates a direct upload that allows video uploads without an API key. 13048 * @param params Parameters for the direct upload 13049 * @returns The direct upload details. 13050 * @throws {BadRequestError} if the parameters are invalid 13051 * @throws {RateLimitedError} if the server received too many requests 13052 * @throws {InternalError} if an unexpected error occurs 13053 */ 13054 createDirectUpload(params: StreamDirectUploadCreateParams): Promise<StreamDirectUpload>; 13055 videos: StreamVideos; 13056 watermarks: StreamWatermarks; 13057 } 13058 /** 13059 * Handle for operations scoped to a single Stream video. 13060 */ 13061 interface StreamVideoHandle { 13062 /** 13063 * The unique identifier for the video. 13064 */ 13065 id: string; 13066 /** 13067 * Get a full videos details 13068 * @returns The full video details. 13069 * @throws {NotFoundError} if the video is not found 13070 * @throws {InternalError} if an unexpected error occurs 13071 */ 13072 details(): Promise<StreamVideo>; 13073 /** 13074 * Update details for a single video. 13075 * @param params The fields to update for the video. 13076 * @returns The updated video details. 13077 * @throws {NotFoundError} if the video is not found 13078 * @throws {BadRequestError} if the parameters are invalid 13079 * @throws {InternalError} if an unexpected error occurs 13080 */ 13081 update(params: StreamUpdateVideoParams): Promise<StreamVideo>; 13082 /** 13083 * Deletes a video and its copies from Cloudflare Stream. 13084 * @returns A promise that resolves when deletion completes. 13085 * @throws {NotFoundError} if the video is not found 13086 * @throws {InternalError} if an unexpected error occurs 13087 */ 13088 delete(): Promise<void>; 13089 /** 13090 * Creates a signed URL token for a video. 13091 * @returns The signed token that was created. 13092 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed 13093 */ 13094 generateToken(): Promise<string>; 13095 downloads: StreamScopedDownloads; 13096 captions: StreamScopedCaptions; 13097 } 13098 interface StreamVideo { 13099 /** 13100 * The unique identifier for the video. 13101 */ 13102 id: string; 13103 /** 13104 * A user-defined identifier for the media creator. 13105 */ 13106 creator: string | null; 13107 /** 13108 * The thumbnail URL for the video. 13109 */ 13110 thumbnail: string; 13111 /** 13112 * The thumbnail timestamp percentage. 13113 */ 13114 thumbnailTimestampPct: number; 13115 /** 13116 * Indicates whether the video is ready to stream. 13117 */ 13118 readyToStream: boolean; 13119 /** 13120 * The date and time the video became ready to stream. 13121 */ 13122 readyToStreamAt: string | null; 13123 /** 13124 * Processing status information. 13125 */ 13126 status: StreamVideoStatus; 13127 /** 13128 * A user modifiable key-value store. 13129 */ 13130 meta: Record<string, string>; 13131 /** 13132 * The date and time the video was created. 13133 */ 13134 created: string; 13135 /** 13136 * The date and time the video was last modified. 13137 */ 13138 modified: string; 13139 /** 13140 * The date and time at which the video will be deleted. 13141 */ 13142 scheduledDeletion: string | null; 13143 /** 13144 * The size of the video in bytes. 13145 */ 13146 size: number; 13147 /** 13148 * The preview URL for the video. 13149 */ 13150 preview?: string; 13151 /** 13152 * Origins allowed to display the video. 13153 */ 13154 allowedOrigins: Array<string>; 13155 /** 13156 * Indicates whether signed URLs are required. 13157 */ 13158 requireSignedURLs: boolean | null; 13159 /** 13160 * The date and time the video was uploaded. 13161 */ 13162 uploaded: string | null; 13163 /** 13164 * The date and time when the upload URL expires. 13165 */ 13166 uploadExpiry: string | null; 13167 /** 13168 * The maximum size in bytes for direct uploads. 13169 */ 13170 maxSizeBytes: number | null; 13171 /** 13172 * The maximum duration in seconds for direct uploads. 13173 */ 13174 maxDurationSeconds: number | null; 13175 /** 13176 * The video duration in seconds. -1 indicates unknown. 13177 */ 13178 duration: number; 13179 /** 13180 * Input metadata for the original upload. 13181 */ 13182 input: StreamVideoInput; 13183 /** 13184 * Playback URLs for the video. 13185 */ 13186 hlsPlaybackUrl: string; 13187 dashPlaybackUrl: string; 13188 /** 13189 * The watermark applied to the video, if any. 13190 */ 13191 watermark: StreamWatermark | null; 13192 /** 13193 * The live input id associated with the video, if any. 13194 */ 13195 liveInputId?: string | null; 13196 /** 13197 * The source video id if this is a clip. 13198 */ 13199 clippedFromId: string | null; 13200 /** 13201 * Public details associated with the video. 13202 */ 13203 publicDetails: StreamPublicDetails | null; 13204 } 13205 type StreamVideoStatus = { 13206 /** 13207 * The current processing state. 13208 */ 13209 state: string; 13210 /** 13211 * The current processing step. 13212 */ 13213 step?: string; 13214 /** 13215 * The percent complete as a string. 13216 */ 13217 pctComplete?: string; 13218 /** 13219 * An error reason code, if applicable. 13220 */ 13221 errorReasonCode: string; 13222 /** 13223 * An error reason text, if applicable. 13224 */ 13225 errorReasonText: string; 13226 }; 13227 type StreamVideoInput = { 13228 /** 13229 * The input width in pixels. 13230 */ 13231 width: number; 13232 /** 13233 * The input height in pixels. 13234 */ 13235 height: number; 13236 }; 13237 type StreamPublicDetails = { 13238 /** 13239 * The public title for the video. 13240 */ 13241 title: string | null; 13242 /** 13243 * The public share link. 13244 */ 13245 share_link: string | null; 13246 /** 13247 * The public channel link. 13248 */ 13249 channel_link: string | null; 13250 /** 13251 * The public logo URL. 13252 */ 13253 logo: string | null; 13254 }; 13255 type StreamDirectUpload = { 13256 /** 13257 * The URL an unauthenticated upload can use for a single multipart request. 13258 */ 13259 uploadURL: string; 13260 /** 13261 * A Cloudflare-generated unique identifier for a media item. 13262 */ 13263 id: string; 13264 /** 13265 * The watermark profile applied to the upload. 13266 */ 13267 watermark: StreamWatermark | null; 13268 /** 13269 * The scheduled deletion time, if any. 13270 */ 13271 scheduledDeletion: string | null; 13272 }; 13273 type StreamDirectUploadCreateParams = { 13274 /** 13275 * The maximum duration in seconds for a video upload. 13276 */ 13277 maxDurationSeconds: number; 13278 /** 13279 * The date and time after upload when videos will not be accepted. 13280 */ 13281 expiry?: string; 13282 /** 13283 * A user-defined identifier for the media creator. 13284 */ 13285 creator?: string; 13286 /** 13287 * A user modifiable key-value store used to reference other systems of record for 13288 * managing videos. 13289 */ 13290 meta?: Record<string, string>; 13291 /** 13292 * Lists the origins allowed to display the video. 13293 */ 13294 allowedOrigins?: Array<string>; 13295 /** 13296 * Indicates whether the video can be accessed using the id. When set to `true`, 13297 * a signed token must be generated with a signing key to view the video. 13298 */ 13299 requireSignedURLs?: boolean; 13300 /** 13301 * The thumbnail timestamp percentage. 13302 */ 13303 thumbnailTimestampPct?: number; 13304 /** 13305 * The date and time at which the video will be deleted. Include `null` to remove 13306 * a scheduled deletion. 13307 */ 13308 scheduledDeletion?: string | null; 13309 /** 13310 * The watermark profile to apply. 13311 */ 13312 watermark?: StreamDirectUploadWatermark; 13313 }; 13314 type StreamDirectUploadWatermark = { 13315 /** 13316 * The unique identifier for the watermark profile. 13317 */ 13318 id: string; 13319 }; 13320 type StreamUrlUploadParams = { 13321 /** 13322 * Lists the origins allowed to display the video. Enter allowed origin 13323 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the 13324 * video to be viewed on any origin. 13325 */ 13326 allowedOrigins?: Array<string>; 13327 /** 13328 * A user-defined identifier for the media creator. 13329 */ 13330 creator?: string; 13331 /** 13332 * A user modifiable key-value store used to reference other systems of 13333 * record for managing videos. 13334 */ 13335 meta?: Record<string, string>; 13336 /** 13337 * Indicates whether the video can be a accessed using the id. When 13338 * set to `true`, a signed token must be generated with a signing key to view the 13339 * video. 13340 */ 13341 requireSignedURLs?: boolean; 13342 /** 13343 * Indicates the date and time at which the video will be deleted. Omit 13344 * the field to indicate no change, or include with a `null` value to remove an 13345 * existing scheduled deletion. If specified, must be at least 30 days from upload 13346 * time. 13347 */ 13348 scheduledDeletion?: string | null; 13349 /** 13350 * The timestamp for a thumbnail image calculated as a percentage value 13351 * of the video's duration. To convert from a second-wise timestamp to a 13352 * percentage, divide the desired timestamp by the total duration of the video. If 13353 * this value is not set, the default thumbnail image is taken from 0s of the 13354 * video. 13355 */ 13356 thumbnailTimestampPct?: number; 13357 /** 13358 * The identifier for the watermark profile 13359 */ 13360 watermarkId?: string; 13361 }; 13362 interface StreamScopedCaptions { 13363 /** 13364 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language. 13365 * One caption or subtitle file per language is allowed. 13366 * @param language The BCP 47 language tag for the caption or subtitle. 13367 * @param input The caption or subtitle stream to upload. 13368 * @returns The created caption entry. 13369 * @throws {NotFoundError} if the video is not found 13370 * @throws {BadRequestError} if the language or file is invalid 13371 * @throws {InternalError} if an unexpected error occurs 13372 */ 13373 upload(language: string, input: ReadableStream): Promise<StreamCaption>; 13374 /** 13375 * Generate captions or subtitles for the provided language via AI. 13376 * @param language The BCP 47 language tag to generate. 13377 * @returns The generated caption entry. 13378 * @throws {NotFoundError} if the video is not found 13379 * @throws {BadRequestError} if the language is invalid 13380 * @throws {StreamError} if a generated caption already exists 13381 * @throws {StreamError} if the video duration is too long 13382 * @throws {StreamError} if the video is missing audio 13383 * @throws {StreamError} if the requested language is not supported 13384 * @throws {InternalError} if an unexpected error occurs 13385 */ 13386 generate(language: string): Promise<StreamCaption>; 13387 /** 13388 * Lists the captions or subtitles. 13389 * Use the language parameter to filter by a specific language. 13390 * @param language The optional BCP 47 language tag to filter by. 13391 * @returns The list of captions or subtitles. 13392 * @throws {NotFoundError} if the video or caption is not found 13393 * @throws {InternalError} if an unexpected error occurs 13394 */ 13395 list(language?: string): Promise<StreamCaption[]>; 13396 /** 13397 * Removes the captions or subtitles from a video. 13398 * @param language The BCP 47 language tag to remove. 13399 * @returns A promise that resolves when deletion completes. 13400 * @throws {NotFoundError} if the video or caption is not found 13401 * @throws {InternalError} if an unexpected error occurs 13402 */ 13403 delete(language: string): Promise<void>; 13404 } 13405 interface StreamScopedDownloads { 13406 /** 13407 * Generates a download for a video when a video is ready to view. Available 13408 * types are `default` and `audio`. Defaults to `default` when omitted. 13409 * @param downloadType The download type to create. 13410 * @returns The current downloads for the video. 13411 * @throws {NotFoundError} if the video is not found 13412 * @throws {BadRequestError} if the download type is invalid 13413 * @throws {StreamError} if the video duration is too long to generate a download 13414 * @throws {StreamError} if the video is not ready to stream 13415 * @throws {InternalError} if an unexpected error occurs 13416 */ 13417 generate(downloadType?: StreamDownloadType): Promise<StreamDownloadGetResponse>; 13418 /** 13419 * Lists the downloads created for a video. 13420 * @returns The current downloads for the video. 13421 * @throws {NotFoundError} if the video or downloads are not found 13422 * @throws {InternalError} if an unexpected error occurs 13423 */ 13424 get(): Promise<StreamDownloadGetResponse>; 13425 /** 13426 * Delete the downloads for a video. Available types are `default` and `audio`. 13427 * Defaults to `default` when omitted. 13428 * @param downloadType The download type to delete. 13429 * @returns A promise that resolves when deletion completes. 13430 * @throws {NotFoundError} if the video or downloads are not found 13431 * @throws {InternalError} if an unexpected error occurs 13432 */ 13433 delete(downloadType?: StreamDownloadType): Promise<void>; 13434 } 13435 interface StreamVideos { 13436 /** 13437 * Lists all videos in a users account. 13438 * @returns The list of videos. 13439 * @throws {BadRequestError} if the parameters are invalid 13440 * @throws {InternalError} if an unexpected error occurs 13441 */ 13442 list(params?: StreamVideosListParams): Promise<StreamVideo[]>; 13443 } 13444 interface StreamWatermarks { 13445 /** 13446 * Generate a new watermark profile 13447 * @param input The image stream to upload 13448 * @param params The watermark creation parameters. 13449 * @returns The created watermark profile. 13450 * @throws {BadRequestError} if the parameters are invalid 13451 * @throws {InvalidURLError} if the URL is invalid 13452 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached 13453 * @throws {InternalError} if an unexpected error occurs 13454 */ 13455 generate(input: ReadableStream, params: StreamWatermarkCreateParams): Promise<StreamWatermark>; 13456 /** 13457 * Generate a new watermark profile 13458 * @param url The image url to upload 13459 * @param params The watermark creation parameters. 13460 * @returns The created watermark profile. 13461 * @throws {BadRequestError} if the parameters are invalid 13462 * @throws {InvalidURLError} if the URL is invalid 13463 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached 13464 * @throws {InternalError} if an unexpected error occurs 13465 */ 13466 generate(url: string, params: StreamWatermarkCreateParams): Promise<StreamWatermark>; 13467 /** 13468 * Lists all watermark profiles for an account. 13469 * @returns The list of watermark profiles. 13470 * @throws {InternalError} if an unexpected error occurs 13471 */ 13472 list(): Promise<StreamWatermark[]>; 13473 /** 13474 * Retrieves details for a single watermark profile. 13475 * @param watermarkId The watermark profile identifier. 13476 * @returns The watermark profile details. 13477 * @throws {NotFoundError} if the watermark is not found 13478 * @throws {InternalError} if an unexpected error occurs 13479 */ 13480 get(watermarkId: string): Promise<StreamWatermark>; 13481 /** 13482 * Deletes a watermark profile. 13483 * @param watermarkId The watermark profile identifier. 13484 * @returns A promise that resolves when deletion completes. 13485 * @throws {NotFoundError} if the watermark is not found 13486 * @throws {InternalError} if an unexpected error occurs 13487 */ 13488 delete(watermarkId: string): Promise<void>; 13489 } 13490 type StreamUpdateVideoParams = { 13491 /** 13492 * Lists the origins allowed to display the video. Enter allowed origin 13493 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the 13494 * video to be viewed on any origin. 13495 */ 13496 allowedOrigins?: Array<string>; 13497 /** 13498 * A user-defined identifier for the media creator. 13499 */ 13500 creator?: string; 13501 /** 13502 * The maximum duration in seconds for a video upload. Can be set for a 13503 * video that is not yet uploaded to limit its duration. Uploads that exceed the 13504 * specified duration will fail during processing. A value of `-1` means the value 13505 * is unknown. 13506 */ 13507 maxDurationSeconds?: number; 13508 /** 13509 * A user modifiable key-value store used to reference other systems of 13510 * record for managing videos. 13511 */ 13512 meta?: Record<string, string>; 13513 /** 13514 * Indicates whether the video can be a accessed using the id. When 13515 * set to `true`, a signed token must be generated with a signing key to view the 13516 * video. 13517 */ 13518 requireSignedURLs?: boolean; 13519 /** 13520 * Indicates the date and time at which the video will be deleted. Omit 13521 * the field to indicate no change, or include with a `null` value to remove an 13522 * existing scheduled deletion. If specified, must be at least 30 days from upload 13523 * time. 13524 */ 13525 scheduledDeletion?: string | null; 13526 /** 13527 * The timestamp for a thumbnail image calculated as a percentage value 13528 * of the video's duration. To convert from a second-wise timestamp to a 13529 * percentage, divide the desired timestamp by the total duration of the video. If 13530 * this value is not set, the default thumbnail image is taken from 0s of the 13531 * video. 13532 */ 13533 thumbnailTimestampPct?: number; 13534 }; 13535 type StreamCaption = { 13536 /** 13537 * Whether the caption was generated via AI. 13538 */ 13539 generated?: boolean; 13540 /** 13541 * The language label displayed in the native language to users. 13542 */ 13543 label: string; 13544 /** 13545 * The language tag in BCP 47 format. 13546 */ 13547 language: string; 13548 /** 13549 * The status of a generated caption. 13550 */ 13551 status?: 'ready' | 'inprogress' | 'error'; 13552 }; 13553 type StreamDownloadStatus = 'ready' | 'inprogress' | 'error'; 13554 type StreamDownloadType = 'default' | 'audio'; 13555 type StreamDownload = { 13556 /** 13557 * Indicates the progress as a percentage between 0 and 100. 13558 */ 13559 percentComplete: number; 13560 /** 13561 * The status of a generated download. 13562 */ 13563 status: StreamDownloadStatus; 13564 /** 13565 * The URL to access the generated download. 13566 */ 13567 url?: string; 13568 }; 13569 /** 13570 * An object with download type keys. Each key is optional and only present if that 13571 * download type has been created. 13572 */ 13573 type StreamDownloadGetResponse = { 13574 /** 13575 * The audio-only download. Only present if this download type has been created. 13576 */ 13577 audio?: StreamDownload; 13578 /** 13579 * The default video download. Only present if this download type has been created. 13580 */ 13581 default?: StreamDownload; 13582 }; 13583 type StreamWatermarkPosition = 'upperRight' | 'upperLeft' | 'lowerLeft' | 'lowerRight' | 'center'; 13584 type StreamWatermark = { 13585 /** 13586 * The unique identifier for a watermark profile. 13587 */ 13588 id: string; 13589 /** 13590 * The size of the image in bytes. 13591 */ 13592 size: number; 13593 /** 13594 * The height of the image in pixels. 13595 */ 13596 height: number; 13597 /** 13598 * The width of the image in pixels. 13599 */ 13600 width: number; 13601 /** 13602 * The date and a time a watermark profile was created. 13603 */ 13604 created: string; 13605 /** 13606 * The source URL for a downloaded image. If the watermark profile was created via 13607 * direct upload, this field is null. 13608 */ 13609 downloadedFrom: string | null; 13610 /** 13611 * A short description of the watermark profile. 13612 */ 13613 name: string; 13614 /** 13615 * The translucency of the image. A value of `0.0` makes the image completely 13616 * transparent, and `1.0` makes the image completely opaque. Note that if the image 13617 * is already semi-transparent, setting this to `1.0` will not make the image 13618 * completely opaque. 13619 */ 13620 opacity: number; 13621 /** 13622 * The whitespace between the adjacent edges (determined by position) of the video 13623 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded 13624 * video width or length, as determined by the algorithm. 13625 */ 13626 padding: number; 13627 /** 13628 * The size of the image relative to the overall size of the video. This parameter 13629 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no 13630 * scaling (use the size of the image as-is), and `1.0 `fills the entire video. 13631 */ 13632 scale: number; 13633 /** 13634 * The location of the image. Valid positions are: `upperRight`, `upperLeft`, 13635 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the 13636 * `padding` parameter. 13637 */ 13638 position: StreamWatermarkPosition; 13639 }; 13640 type StreamWatermarkCreateParams = { 13641 /** 13642 * A short description of the watermark profile. 13643 */ 13644 name?: string; 13645 /** 13646 * The translucency of the image. A value of `0.0` makes the image completely 13647 * transparent, and `1.0` makes the image completely opaque. Note that if the 13648 * image is already semi-transparent, setting this to `1.0` will not make the 13649 * image completely opaque. 13650 */ 13651 opacity?: number; 13652 /** 13653 * The whitespace between the adjacent edges (determined by position) of the 13654 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully 13655 * padded video width or length, as determined by the algorithm. 13656 */ 13657 padding?: number; 13658 /** 13659 * The size of the image relative to the overall size of the video. This 13660 * parameter will adapt to horizontal and vertical videos automatically. `0.0` 13661 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the 13662 * entire video. 13663 */ 13664 scale?: number; 13665 /** 13666 * The location of the image. 13667 */ 13668 position?: StreamWatermarkPosition; 13669 }; 13670 type StreamVideosListParams = { 13671 /** 13672 * The maximum number of videos to return. 13673 */ 13674 limit?: number; 13675 /** 13676 * Return videos created before this timestamp. 13677 * (RFC3339/RFC3339Nano) 13678 */ 13679 before?: string; 13680 /** 13681 * Comparison operator for the `before` field. 13682 * @default 'lt' 13683 */ 13684 beforeComp?: StreamPaginationComparison; 13685 /** 13686 * Return videos created after this timestamp. 13687 * (RFC3339/RFC3339Nano) 13688 */ 13689 after?: string; 13690 /** 13691 * Comparison operator for the `after` field. 13692 * @default 'gte' 13693 */ 13694 afterComp?: StreamPaginationComparison; 13695 }; 13696 type StreamPaginationComparison = 'eq' | 'gt' | 'gte' | 'lt' | 'lte'; 13697 /** 13698 * Error object for Stream binding operations. 13699 */ 13700 interface StreamError extends Error { 13701 readonly code: number; 13702 readonly statusCode: number; 13703 readonly message: string; 13704 readonly stack?: string; 13705 } 13706 interface InternalError extends StreamError { 13707 name: 'InternalError'; 13708 } 13709 interface BadRequestError extends StreamError { 13710 name: 'BadRequestError'; 13711 } 13712 interface NotFoundError extends StreamError { 13713 name: 'NotFoundError'; 13714 } 13715 interface ForbiddenError extends StreamError { 13716 name: 'ForbiddenError'; 13717 } 13718 interface RateLimitedError extends StreamError { 13719 name: 'RateLimitedError'; 13720 } 13721 interface QuotaReachedError extends StreamError { 13722 name: 'QuotaReachedError'; 13723 } 13724 interface MaxFileSizeError extends StreamError { 13725 name: 'MaxFileSizeError'; 13726 } 13727 interface InvalidURLError extends StreamError { 13728 name: 'InvalidURLError'; 13729 } 13730 interface AlreadyUploadedError extends StreamError { 13731 name: 'AlreadyUploadedError'; 13732 } 13733 interface TooManyWatermarksError extends StreamError { 13734 name: 'TooManyWatermarksError'; 13735 } 13736 type MarkdownDocument = { 13737 name: string; 13738 blob: Blob; 13739 }; 13740 type ConversionResponse = { 13741 id: string; 13742 name: string; 13743 mimeType: string; 13744 format: 'markdown'; 13745 tokens: number; 13746 data: string; 13747 } | { 13748 id: string; 13749 name: string; 13750 mimeType: string; 13751 format: 'error'; 13752 error: string; 13753 }; 13754 type ImageConversionOptions = { 13755 descriptionLanguage?: 'en' | 'es' | 'fr' | 'it' | 'pt' | 'de'; 13756 }; 13757 type EmbeddedImageConversionOptions = ImageConversionOptions & { 13758 convert?: boolean; 13759 maxConvertedImages?: number; 13760 }; 13761 type ConversionOptions = { 13762 html?: { 13763 images?: EmbeddedImageConversionOptions & { 13764 convertOGImage?: boolean; 13765 }; 13766 hostname?: string; 13767 cssSelector?: string; 13768 }; 13769 docx?: { 13770 images?: EmbeddedImageConversionOptions; 13771 }; 13772 image?: ImageConversionOptions; 13773 pdf?: { 13774 images?: EmbeddedImageConversionOptions; 13775 metadata?: boolean; 13776 }; 13777 }; 13778 type ConversionRequestOptions = { 13779 gateway?: GatewayOptions; 13780 extraHeaders?: object; 13781 conversionOptions?: ConversionOptions; 13782 }; 13783 type SupportedFileFormat = { 13784 mimeType: string; 13785 extension: string; 13786 }; 13787 declare abstract class ToMarkdownService { 13788 transform(files: MarkdownDocument[], options?: ConversionRequestOptions): Promise<ConversionResponse[]>; 13789 transform(files: MarkdownDocument, options?: ConversionRequestOptions): Promise<ConversionResponse>; 13790 supported(): Promise<SupportedFileFormat[]>; 13791 } 13792 declare namespace TailStream { 13793 interface Header { 13794 readonly name: string; 13795 readonly value: string; 13796 } 13797 interface FetchEventInfo { 13798 readonly type: "fetch"; 13799 readonly method: string; 13800 readonly url: string; 13801 readonly cfJson?: object; 13802 readonly headers: Header[]; 13803 } 13804 interface JsRpcEventInfo { 13805 readonly type: "jsrpc"; 13806 } 13807 interface ScheduledEventInfo { 13808 readonly type: "scheduled"; 13809 readonly scheduledTime: Date; 13810 readonly cron: string; 13811 } 13812 interface AlarmEventInfo { 13813 readonly type: "alarm"; 13814 readonly scheduledTime: Date; 13815 } 13816 interface QueueEventInfo { 13817 readonly type: "queue"; 13818 readonly queueName: string; 13819 readonly batchSize: number; 13820 } 13821 interface EmailEventInfo { 13822 readonly type: "email"; 13823 readonly mailFrom: string; 13824 readonly rcptTo: string; 13825 readonly rawSize: number; 13826 } 13827 interface TraceEventInfo { 13828 readonly type: "trace"; 13829 readonly traces: (string | null)[]; 13830 } 13831 interface HibernatableWebSocketEventInfoMessage { 13832 readonly type: "message"; 13833 } 13834 interface HibernatableWebSocketEventInfoError { 13835 readonly type: "error"; 13836 } 13837 interface HibernatableWebSocketEventInfoClose { 13838 readonly type: "close"; 13839 readonly code: number; 13840 readonly wasClean: boolean; 13841 } 13842 interface HibernatableWebSocketEventInfo { 13843 readonly type: "hibernatableWebSocket"; 13844 readonly info: HibernatableWebSocketEventInfoClose | HibernatableWebSocketEventInfoError | HibernatableWebSocketEventInfoMessage; 13845 } 13846 interface CustomEventInfo { 13847 readonly type: "custom"; 13848 } 13849 interface FetchResponseInfo { 13850 readonly type: "fetch"; 13851 readonly statusCode: number; 13852 } 13853 interface ConnectEventInfo { 13854 readonly type: "connect"; 13855 } 13856 type EventOutcome = "ok" | "canceled" | "exception" | "unknown" | "killSwitch" | "daemonDown" | "exceededCpu" | "exceededMemory" | "loadShed" | "responseStreamDisconnected" | "scriptNotFound" | "internalError"; 13857 interface ScriptVersion { 13858 readonly id: string; 13859 readonly tag?: string; 13860 readonly message?: string; 13861 } 13862 interface TracePreviewInfo { 13863 readonly id: string; 13864 readonly slug: string; 13865 readonly name: string; 13866 } 13867 interface Onset { 13868 readonly type: "onset"; 13869 readonly attributes: Attribute[]; 13870 // id for the span being opened by this Onset event. 13871 readonly spanId: string; 13872 readonly dispatchNamespace?: string; 13873 readonly entrypoint?: string; 13874 readonly executionModel: string; 13875 readonly scriptName?: string; 13876 readonly scriptTags?: string[]; 13877 readonly scriptVersion?: ScriptVersion; 13878 readonly preview?: TracePreviewInfo; 13879 readonly info: FetchEventInfo | ConnectEventInfo | JsRpcEventInfo | ScheduledEventInfo | AlarmEventInfo | QueueEventInfo | EmailEventInfo | TraceEventInfo | HibernatableWebSocketEventInfo | CustomEventInfo; 13880 } 13881 interface Outcome { 13882 readonly type: "outcome"; 13883 readonly outcome: EventOutcome; 13884 readonly cpuTime: number; 13885 readonly wallTime: number; 13886 } 13887 interface SpanOpen { 13888 readonly type: "spanOpen"; 13889 readonly name: string; 13890 // id for the span being opened by this SpanOpen event. 13891 readonly spanId: string; 13892 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes; 13893 } 13894 interface SpanClose { 13895 readonly type: "spanClose"; 13896 readonly outcome: EventOutcome; 13897 } 13898 interface DiagnosticChannelEvent { 13899 readonly type: "diagnosticChannel"; 13900 readonly channel: string; 13901 readonly message: any; 13902 } 13903 interface Exception { 13904 readonly type: "exception"; 13905 readonly name: string; 13906 readonly message: string; 13907 readonly stack?: string; 13908 } 13909 interface Log { 13910 readonly type: "log"; 13911 readonly level: "debug" | "error" | "info" | "log" | "warn"; 13912 readonly message: object; 13913 } 13914 interface DroppedEventsDiagnostic { 13915 readonly diagnosticsType: "droppedEvents"; 13916 readonly count: number; 13917 } 13918 interface StreamDiagnostic { 13919 readonly type: 'streamDiagnostic'; 13920 // To add new diagnostic types, define a new interface and add it to this union type. 13921 readonly diagnostic: DroppedEventsDiagnostic; 13922 } 13923 // This marks the worker handler return information. 13924 // This is separate from Outcome because the worker invocation can live for a long time after 13925 // returning. For example - Websockets that return an http upgrade response but then continue 13926 // streaming information or SSE http connections. 13927 interface Return { 13928 readonly type: "return"; 13929 readonly info?: FetchResponseInfo; 13930 } 13931 interface Attribute { 13932 readonly name: string; 13933 readonly value: string | string[] | boolean | boolean[] | number | number[] | bigint | bigint[]; 13934 } 13935 interface Attributes { 13936 readonly type: "attributes"; 13937 readonly info: Attribute[]; 13938 } 13939 type EventType = Onset | Outcome | SpanOpen | SpanClose | DiagnosticChannelEvent | Exception | Log | StreamDiagnostic | Return | Attributes; 13940 // Context in which this trace event lives. 13941 interface SpanContext { 13942 // Single id for the entire top-level invocation 13943 // This should be a new traceId for the first worker stage invoked in the eyeball request and then 13944 // same-account service-bindings should reuse the same traceId but cross-account service-bindings 13945 // should use a new traceId. 13946 readonly traceId: string; 13947 // spanId in which this event is handled 13948 // for Onset and SpanOpen events this would be the parent span id 13949 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events 13950 // For Hibernate and Mark this would be the span under which they were emitted. 13951 // spanId is not set ONLY if: 13952 // 1. This is an Onset event 13953 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation) 13954 readonly spanId?: string; 13955 // W3C trace flags from an upstream traceparent. Absent when no upstream 13956 // sampling decision was made. 13957 readonly traceFlags?: number; 13958 } 13959 interface TailEvent<Event extends EventType> { 13960 // invocation id of the currently invoked worker stage. 13961 // invocation id will always be unique to every Onset event and will be the same until the Outcome event. 13962 readonly invocationId: string; 13963 // Inherited spanContext for this event. 13964 readonly spanContext: SpanContext; 13965 readonly timestamp: Date; 13966 readonly sequence: number; 13967 readonly event: Event; 13968 } 13969 type TailEventHandler<Event extends EventType = EventType> = (event: TailEvent<Event>) => void | Promise<void>; 13970 type TailEventHandlerObject = { 13971 outcome?: TailEventHandler<Outcome>; 13972 spanOpen?: TailEventHandler<SpanOpen>; 13973 spanClose?: TailEventHandler<SpanClose>; 13974 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>; 13975 exception?: TailEventHandler<Exception>; 13976 log?: TailEventHandler<Log>; 13977 return?: TailEventHandler<Return>; 13978 attributes?: TailEventHandler<Attributes>; 13979 }; 13980 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject; 13981 } 13982 // Copyright (c) 2022-2023 Cloudflare, Inc. 13983 // Licensed under the Apache 2.0 license found in the LICENSE file or at: 13984 // https://opensource.org/licenses/Apache-2.0 13985 /** 13986 * Data types supported for holding vector metadata. 13987 */ 13988 type VectorizeVectorMetadataValue = string | number | boolean | string[]; 13989 /** 13990 * Additional information to associate with a vector. 13991 */ 13992 type VectorizeVectorMetadata = VectorizeVectorMetadataValue | Record<string, VectorizeVectorMetadataValue>; 13993 type VectorFloatArray = Float32Array | Float64Array; 13994 interface VectorizeError { 13995 code?: number; 13996 error: string; 13997 } 13998 /** 13999 * Comparison logic/operation to use for metadata filtering. 14000 * 14001 * This list is expected to grow as support for more operations are released. 14002 */ 14003 type VectorizeVectorMetadataFilterOp = '$eq' | '$ne' | '$lt' | '$lte' | '$gt' | '$gte'; 14004 type VectorizeVectorMetadataFilterCollectionOp = '$in' | '$nin'; 14005 /** 14006 * Filter criteria for vector metadata used to limit the retrieved query result set. 14007 */ 14008 type VectorizeVectorMetadataFilter = { 14009 [field: string]: Exclude<VectorizeVectorMetadataValue, string[]> | null | { 14010 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<VectorizeVectorMetadataValue, string[]> | null; 14011 } | { 14012 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<VectorizeVectorMetadataValue, string[]>[]; 14013 }; 14014 }; 14015 /** 14016 * Supported distance metrics for an index. 14017 * Distance metrics determine how other "similar" vectors are determined. 14018 */ 14019 type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product"; 14020 /** 14021 * Metadata return levels for a Vectorize query. 14022 * 14023 * Default to "none". 14024 * 14025 * @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. 14026 * @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). 14027 * @property none No indexed metadata will be returned. 14028 */ 14029 type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none"; 14030 interface VectorizeQueryOptions { 14031 topK?: number; 14032 namespace?: string; 14033 returnValues?: boolean; 14034 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel; 14035 filter?: VectorizeVectorMetadataFilter; 14036 } 14037 /** 14038 * Information about the configuration of an index. 14039 */ 14040 type VectorizeIndexConfig = { 14041 dimensions: number; 14042 metric: VectorizeDistanceMetric; 14043 } | { 14044 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity 14045 }; 14046 /** 14047 * Metadata about an existing index. 14048 * 14049 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 14050 * See {@link VectorizeIndexInfo} for its post-beta equivalent. 14051 */ 14052 interface VectorizeIndexDetails { 14053 /** The unique ID of the index */ 14054 readonly id: string; 14055 /** The name of the index. */ 14056 name: string; 14057 /** (optional) A human readable description for the index. */ 14058 description?: string; 14059 /** The index configuration, including the dimension size and distance metric. */ 14060 config: VectorizeIndexConfig; 14061 /** The number of records containing vectors within the index. */ 14062 vectorsCount: number; 14063 } 14064 /** 14065 * Metadata about an existing index. 14066 */ 14067 interface VectorizeIndexInfo { 14068 /** The number of records containing vectors within the index. */ 14069 vectorCount: number; 14070 /** Number of dimensions the index has been configured for. */ 14071 dimensions: number; 14072 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */ 14073 processedUpToDatetime: number; 14074 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */ 14075 processedUpToMutation: number; 14076 } 14077 /** 14078 * Represents a single vector value set along with its associated metadata. 14079 */ 14080 interface VectorizeVector { 14081 /** 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. */ 14082 id: string; 14083 /** The vector values */ 14084 values: VectorFloatArray | number[]; 14085 /** The namespace this vector belongs to. */ 14086 namespace?: string; 14087 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */ 14088 metadata?: Record<string, VectorizeVectorMetadata>; 14089 } 14090 /** 14091 * Represents a matched vector for a query along with its score and (if specified) the matching vector information. 14092 */ 14093 type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> & Omit<VectorizeVector, "values"> & { 14094 /** The score or rank for similarity, when returned as a result */ 14095 score: number; 14096 }; 14097 /** 14098 * A set of matching {@link VectorizeMatch} for a particular query. 14099 */ 14100 interface VectorizeMatches { 14101 matches: VectorizeMatch[]; 14102 count: number; 14103 } 14104 /** 14105 * Results of an operation that performed a mutation on a set of vectors. 14106 * Here, `ids` is a list of vectors that were successfully processed. 14107 * 14108 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 14109 * See {@link VectorizeAsyncMutation} for its post-beta equivalent. 14110 */ 14111 interface VectorizeVectorMutation { 14112 /* List of ids of vectors that were successfully processed. */ 14113 ids: string[]; 14114 /* Total count of the number of processed vectors. */ 14115 count: number; 14116 } 14117 /** 14118 * Result type indicating a mutation on the Vectorize Index. 14119 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation. 14120 */ 14121 interface VectorizeAsyncMutation { 14122 /** The unique identifier for the async mutation operation containing the changeset. */ 14123 mutationId: string; 14124 } 14125 /** 14126 * A Vectorize Vector Search Index for querying vectors/embeddings. 14127 * 14128 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released. 14129 * See {@link Vectorize} for its new implementation. 14130 */ 14131 declare abstract class VectorizeIndex { 14132 /** 14133 * Get information about the currently bound index. 14134 * @returns A promise that resolves with information about the current index. 14135 */ 14136 public describe(): Promise<VectorizeIndexDetails>; 14137 /** 14138 * Use the provided vector to perform a similarity search across the index. 14139 * @param vector Input vector that will be used to drive the similarity search. 14140 * @param options Configuration options to massage the returned data. 14141 * @returns A promise that resolves with matched and scored vectors. 14142 */ 14143 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 14144 /** 14145 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. 14146 * @param vectors List of vectors that will be inserted. 14147 * @returns A promise that resolves with the ids & count of records that were successfully processed. 14148 */ 14149 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>; 14150 /** 14151 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. 14152 * @param vectors List of vectors that will be upserted. 14153 * @returns A promise that resolves with the ids & count of records that were successfully processed. 14154 */ 14155 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>; 14156 /** 14157 * Delete a list of vectors with a matching id. 14158 * @param ids List of vector ids that should be deleted. 14159 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted). 14160 */ 14161 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>; 14162 /** 14163 * Get a list of vectors with a matching id. 14164 * @param ids List of vector ids that should be returned. 14165 * @returns A promise that resolves with the raw unscored vectors matching the id set. 14166 */ 14167 public getByIds(ids: string[]): Promise<VectorizeVector[]>; 14168 } 14169 /** 14170 * A Vectorize Vector Search Index for querying vectors/embeddings. 14171 * 14172 * Mutations in this version are async, returning a mutation id. 14173 */ 14174 declare abstract class Vectorize { 14175 /** 14176 * Get information about the currently bound index. 14177 * @returns A promise that resolves with information about the current index. 14178 */ 14179 public describe(): Promise<VectorizeIndexInfo>; 14180 /** 14181 * Use the provided vector to perform a similarity search across the index. 14182 * @param vector Input vector that will be used to drive the similarity search. 14183 * @param options Configuration options to massage the returned data. 14184 * @returns A promise that resolves with matched and scored vectors. 14185 */ 14186 public query(vector: VectorFloatArray | number[], options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 14187 /** 14188 * Use the provided vector-id to perform a similarity search across the index. 14189 * @param vectorId Id for a vector in the index against which the index should be queried. 14190 * @param options Configuration options to massage the returned data. 14191 * @returns A promise that resolves with matched and scored vectors. 14192 */ 14193 public queryById(vectorId: string, options?: VectorizeQueryOptions): Promise<VectorizeMatches>; 14194 /** 14195 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown. 14196 * @param vectors List of vectors that will be inserted. 14197 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset. 14198 */ 14199 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>; 14200 /** 14201 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values. 14202 * @param vectors List of vectors that will be upserted. 14203 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset. 14204 */ 14205 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>; 14206 /** 14207 * Delete a list of vectors with a matching id. 14208 * @param ids List of vector ids that should be deleted. 14209 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset. 14210 */ 14211 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>; 14212 /** 14213 * Get a list of vectors with a matching id. 14214 * @param ids List of vector ids that should be returned. 14215 * @returns A promise that resolves with the raw unscored vectors matching the id set. 14216 */ 14217 public getByIds(ids: string[]): Promise<VectorizeVector[]>; 14218 } 14219 /** 14220 * The interface for "version_metadata" binding 14221 * providing metadata about the Worker Version using this binding. 14222 */ 14223 type WorkerVersionMetadata = { 14224 /** The ID of the Worker Version using this binding */ 14225 id: string; 14226 /** The tag of the Worker Version using this binding */ 14227 tag: string; 14228 /** The timestamp of when the Worker Version was uploaded */ 14229 timestamp: string; 14230 }; 14231 // ============ Web Search Request Types ============ 14232 /** 14233 * Options for a Web Search query. 14234 */ 14235 type WebSearchSearchOptions = { 14236 /** The search query. */ 14237 query: string; 14238 /** 14239 * Maximum number of results to return. Defaults to 10, capped at 20. 14240 * The actual count may be lower if fewer matches exist. 14241 */ 14242 limit?: number; 14243 }; 14244 // ============ Web Search Response Types ============ 14245 /** 14246 * A single Web Search result. 14247 * 14248 * Web Search is discovery-only -- results carry catalog metadata about a page 14249 * but never the page body. To read a result's content the caller invokes the 14250 * global `fetch()` API against the result's `url`, at which point the 14251 * destination's own access controls apply (including Cloudflare Pay-per-Crawl). 14252 */ 14253 type WebSearchResult = { 14254 /** Canonical URL. */ 14255 url: string; 14256 /** Page title. */ 14257 title: string; 14258 /** Page-level description. May be absent. */ 14259 description?: string; 14260 /** 14261 * Last-modified date for the page, when known. Naive (no timezone) 14262 * ISO-8601 datetime, e.g. `"2025-11-30T04:39:48"`. 14263 */ 14264 lastModifiedDate?: string; 14265 /** 14266 * Page meta image URL (typically the `og:image`). May be absent. 14267 */ 14268 imageUrl?: string; 14269 /** Optional favicon URL for UI hints. */ 14270 faviconUrl?: string; 14271 }; 14272 /** 14273 * Per-response metadata for a Web Search query. Carries operational 14274 * fields useful for support and debugging. 14275 */ 14276 type WebSearchResponseMetadata = { 14277 /** The query that was executed. */ 14278 query: string; 14279 /** Opaque request identifier used for support and debugging. */ 14280 requestId: string; 14281 /** End-to-end latency for this search request, in milliseconds. */ 14282 latencyMs: number; 14283 }; 14284 /** 14285 * Response from a Web Search query. 14286 */ 14287 type WebSearchSearchResponse = { 14288 items: WebSearchResult[]; 14289 metadata: WebSearchResponseMetadata; 14290 }; 14291 // ============ Web Search Binding Class ============ 14292 /** 14293 * Cloudflare Web Search binding. 14294 * 14295 * Discovery-only primitive for agents and Workers. Returns URLs and catalog 14296 * metadata for a query; never returns page content or excerpts. To read a 14297 * result's body, fetch the URL with the global `fetch()` API. 14298 * 14299 * Declared in wrangler with a single object (there is exactly one corpus, the 14300 * public web, so there is no name, namespace, or instance to specify): 14301 * 14302 * ```jsonc 14303 * { "web_search": { "binding": "WEBSEARCH" } } 14304 * ``` 14305 * 14306 * @example 14307 * ```ts 14308 * const { items, metadata } = await env.WEBSEARCH.search({ 14309 * query: "Cloudflare Workers", 14310 * }); 14311 * 14312 * const top = items[0]; 14313 * console.log(top.url, top.title, metadata.latencyMs); 14314 * 14315 * // Read content yourself; pay-per-crawl and other publisher 14316 * // controls apply at the fetch site, not at search time. 14317 * const page = await fetch(top.url); 14318 * ``` 14319 */ 14320 declare abstract class WebSearch { 14321 /** 14322 * Run a Web Search query. 14323 * @param options Search options. Only `query` is required. 14324 * @returns The matching results plus per-response metadata. 14325 */ 14326 search(options: WebSearchSearchOptions): Promise<WebSearchSearchResponse>; 14327 } 14328 interface DynamicDispatchLimits { 14329 /** 14330 * Limit CPU time in milliseconds. 14331 */ 14332 cpuMs?: number; 14333 /** 14334 * Limit number of subrequests. 14335 */ 14336 subRequests?: number; 14337 } 14338 interface DynamicDispatchOptions { 14339 /** 14340 * Limit resources of invoked Worker script. 14341 */ 14342 limits?: DynamicDispatchLimits; 14343 /** 14344 * Arguments for outbound Worker script, if configured. 14345 */ 14346 outbound?: { 14347 [key: string]: any; 14348 }; 14349 } 14350 interface DispatchNamespace { 14351 /** 14352 * @param name Name of the Worker script. 14353 * @param args Arguments to Worker script. 14354 * @param options Options for Dynamic Dispatch invocation. 14355 * @returns A Fetcher object that allows you to send requests to the Worker script. 14356 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown. 14357 */ 14358 get(name: string, args?: { 14359 [key: string]: any; 14360 }, options?: DynamicDispatchOptions): Fetcher; 14361 } 14362 declare module 'cloudflare:workflows' { 14363 /** 14364 * NonRetryableError allows for a user to throw a fatal error 14365 * that makes a Workflow instance fail immediately without triggering a retry 14366 */ 14367 export class NonRetryableError extends Error { 14368 public constructor(message: string, name?: string); 14369 } 14370 } 14371 declare abstract class Workflow<PARAMS = unknown> { 14372 /** 14373 * Get a handle to an existing instance of the Workflow. 14374 * @param id Id for the instance of this Workflow 14375 * @returns A promise that resolves with a handle for the Instance 14376 */ 14377 public get(id: string): Promise<WorkflowInstance>; 14378 /** 14379 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown. 14380 * @param options Options when creating an instance including id and params 14381 * @returns A promise that resolves with a handle for the Instance 14382 */ 14383 public create(options?: WorkflowInstanceCreateOptions<PARAMS>): Promise<WorkflowInstance>; 14384 /** 14385 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown. 14386 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached. 14387 * @param batch List of Options when creating an instance including name and params 14388 * @returns A promise that resolves with a list of handles for the created instances. 14389 */ 14390 public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>; 14391 } 14392 type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year'; 14393 type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number; 14394 type WorkflowRetentionDuration = WorkflowSleepDuration; 14395 interface WorkflowInstanceCreateOptions<PARAMS = unknown> { 14396 /** 14397 * An id for your Workflow instance. Must be unique within the Workflow. 14398 */ 14399 id?: string; 14400 /** 14401 * The event payload the Workflow instance is triggered with 14402 */ 14403 params?: PARAMS; 14404 /** 14405 * The retention policy for Workflow instance. 14406 * Defaults to the maximum retention period available for the owner's account. 14407 */ 14408 retention?: { 14409 successRetention?: WorkflowRetentionDuration; 14410 errorRetention?: WorkflowRetentionDuration; 14411 }; 14412 } 14413 type InstanceStatus = { 14414 status: 'queued' // means that instance is waiting to be started (see concurrency limits) 14415 | 'running' | 'paused' | 'errored' | 'terminated' // user terminated the instance while it was running 14416 | 'complete' | 'waiting' // instance is hibernating and waiting for sleep or event to finish 14417 | 'waitingForPause' // instance is finishing the current work to pause 14418 | 'unknown'; 14419 error?: { 14420 name: string; 14421 message: string; 14422 }; 14423 output?: unknown; 14424 }; 14425 interface WorkflowError { 14426 code?: number; 14427 message: string; 14428 } 14429 interface WorkflowInstanceRestartOptions { 14430 /** 14431 * Restart from a specific step. If omitted, the instance restarts from the beginning. 14432 * The step must exist in the instance's execution history. 14433 */ 14434 from?: { 14435 /** 14436 * The step name as defined in your workflow code. 14437 */ 14438 name: string; 14439 /** 14440 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop). 14441 * @default 1 14442 */ 14443 count?: number; 14444 /** 14445 * Step type filter. Use when different step types share the same name. 14446 */ 14447 type?: 'do' | 'sleep' | 'waitForEvent'; 14448 }; 14449 } 14450 declare abstract class WorkflowInstance { 14451 public id: string; 14452 /** 14453 * Pause the instance. 14454 */ 14455 public pause(): Promise<void>; 14456 /** 14457 * Resume the instance. If it is already running, an error will be thrown. 14458 */ 14459 public resume(): Promise<void>; 14460 /** 14461 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown. 14462 */ 14463 public terminate(): Promise<void>; 14464 /** 14465 * Restart the instance. Optionally restart from a specific step, preserving 14466 * cached results for all steps before it. 14467 * @param options Options for the restart, including an optional step to restart from. 14468 */ 14469 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>; 14470 /** 14471 * Returns the current status of the instance. 14472 */ 14473 public status(): Promise<InstanceStatus>; 14474 /** 14475 * Send an event to this instance. 14476 */ 14477 public sendEvent({ type, payload, }: { 14478 type: string; 14479 payload: unknown; 14480 }): Promise<void>; 14481 }