Skip to content
File

Blob: types/generated-snapshot/experimental/index.d.ts

typescript16002 lines
1/*! *****************************************************************************
2Copyright (c) Cloudflare. All rights reserved.
3Copyright (c) Microsoft Corporation. All rights reserved.
4
5Licensed under the Apache License, Version 2.0 (the "License"); you may not use
6this file except in compliance with the License. You may obtain a copy of the
7License at http://www.apache.org/licenses/LICENSE-2.0
8THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
9KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
10WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
11MERCHANTABLITY OR NON-INFRINGEMENT.
12See the Apache Version 2.0 License for specific language governing permissions
13and limitations under the License.
14***************************************************************************** */
15/* eslint-disable */
16// noinspection JSUnusedGlobalSymbols
17declare var onmessage: never;
18/**
19 * 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.
20 *
21 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException)
22 */
23declare class DOMException extends Error {
24 constructor(message?: string, name?: string);
25 /**
26 * The **`message`** read-only property of the a message or description associated with the given error name.
27 *
28 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/message)
29 */
30 readonly message: string;
31 /**
32 * The **`name`** read-only property of the one of the strings associated with an error name.
33 *
34 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/name)
35 */
36 readonly name: string;
37 /**
38 * The **`code`** read-only property of the DOMException interface returns one of the legacy error code constants, or `0` if none match.
39 * @deprecated
40 *
41 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DOMException/code)
42 */
43 readonly code: number;
44 static readonly INDEX_SIZE_ERR: number;
45 static readonly DOMSTRING_SIZE_ERR: number;
46 static readonly HIERARCHY_REQUEST_ERR: number;
47 static readonly WRONG_DOCUMENT_ERR: number;
48 static readonly INVALID_CHARACTER_ERR: number;
49 static readonly NO_DATA_ALLOWED_ERR: number;
50 static readonly NO_MODIFICATION_ALLOWED_ERR: number;
51 static readonly NOT_FOUND_ERR: number;
52 static readonly NOT_SUPPORTED_ERR: number;
53 static readonly INUSE_ATTRIBUTE_ERR: number;
54 static readonly INVALID_STATE_ERR: number;
55 static readonly SYNTAX_ERR: number;
56 static readonly INVALID_MODIFICATION_ERR: number;
57 static readonly NAMESPACE_ERR: number;
58 static readonly INVALID_ACCESS_ERR: number;
59 static readonly VALIDATION_ERR: number;
60 static readonly TYPE_MISMATCH_ERR: number;
61 static readonly SECURITY_ERR: number;
62 static readonly NETWORK_ERR: number;
63 static readonly ABORT_ERR: number;
64 static readonly URL_MISMATCH_ERR: number;
65 static readonly QUOTA_EXCEEDED_ERR: number;
66 static readonly TIMEOUT_ERR: number;
67 static readonly INVALID_NODE_TYPE_ERR: number;
68 static readonly DATA_CLONE_ERR: number;
69 get stack(): any;
70 set stack(value: any);
71}
72type WorkerGlobalScopeEventMap = {
73 fetch: FetchEvent;
74 scheduled: ScheduledEvent;
75 queue: QueueEvent;
76 unhandledrejection: PromiseRejectionEvent;
77 rejectionhandled: PromiseRejectionEvent;
78};
79declare abstract class WorkerGlobalScope extends EventTarget<WorkerGlobalScopeEventMap> {
80 EventTarget: typeof EventTarget;
81}
82/* The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox). *
83 * The **`console`** object provides access to the debugging console (e.g., the Web console in Firefox).
84 *
85 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)
86 */
87interface Console {
88 "assert"(condition?: boolean, ...data: any[]): void;
89 /**
90 * The **`console.clear()`** static method clears the console if possible.
91 *
92 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/clear_static)
93 */
94 clear(): void;
95 /**
96 * The **`console.count()`** static method logs the number of times that this particular call to `count()` has been called.
97 *
98 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/count_static)
99 */
100 count(label?: string): void;
101 /**
102 * The **`console.countReset()`** static method resets counter used with console/count_static.
103 *
104 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/countReset_static)
105 */
106 countReset(label?: string): void;
107 /**
108 * The **`console.debug()`** static method outputs a message to the console at the 'debug' log level.
109 *
110 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/debug_static)
111 */
112 debug(...data: any[]): void;
113 /**
114 * The **`console.dir()`** static method displays a list of the properties of the specified JavaScript object.
115 *
116 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dir_static)
117 */
118 dir(item?: any, options?: any): void;
119 /**
120 * The **`console.dirxml()`** static method displays an interactive tree of the descendant elements of the specified XML/HTML element.
121 *
122 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/dirxml_static)
123 */
124 dirxml(...data: any[]): void;
125 /**
126 * The **`console.error()`** static method outputs a message to the console at the 'error' log level.
127 *
128 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/error_static)
129 */
130 error(...data: any[]): void;
131 /**
132 * 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.
133 *
134 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/group_static)
135 */
136 group(...data: any[]): void;
137 /**
138 * The **`console.groupCollapsed()`** static method creates a new inline group in the console.
139 *
140 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupCollapsed_static)
141 */
142 groupCollapsed(...data: any[]): void;
143 /**
144 * The **`console.groupEnd()`** static method exits the current inline group in the console.
145 *
146 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/groupEnd_static)
147 */
148 groupEnd(): void;
149 /**
150 * The **`console.info()`** static method outputs a message to the console at the 'info' log level.
151 *
152 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/info_static)
153 */
154 info(...data: any[]): void;
155 /**
156 * The **`console.log()`** static method outputs a message to the console.
157 *
158 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/log_static)
159 */
160 log(...data: any[]): void;
161 /**
162 * The **`console.table()`** static method displays tabular data as a table.
163 *
164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/table_static)
165 */
166 table(tabularData?: any, properties?: string[]): void;
167 /**
168 * The **`console.time()`** static method starts a timer you can use to track how long an operation takes.
169 *
170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/time_static)
171 */
172 time(label?: string): void;
173 /**
174 * The **`console.timeEnd()`** static method stops a timer that was previously started by calling console/time_static.
175 *
176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeEnd_static)
177 */
178 timeEnd(label?: string): void;
179 /**
180 * The **`console.timeLog()`** static method logs the current value of a timer that was previously started by calling console/time_static.
181 *
182 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/timeLog_static)
183 */
184 timeLog(label?: string, ...data: any[]): void;
185 timeStamp(label?: string): void;
186 /**
187 * The **`console.trace()`** static method outputs a stack trace to the console.
188 *
189 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/trace_static)
190 */
191 trace(...data: any[]): void;
192 /**
193 * The **`console.warn()`** static method outputs a warning message to the console at the 'warning' log level.
194 *
195 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/console/warn_static)
196 */
197 warn(...data: any[]): void;
198}
199declare const console: Console;
200type BufferSource = ArrayBufferView | ArrayBuffer;
201type TypedArray =
202 | Int8Array
203 | Uint8Array
204 | Uint8ClampedArray
205 | Int16Array
206 | Uint16Array
207 | Int32Array
208 | Uint32Array
209 | Float32Array
210 | Float64Array
211 | BigInt64Array
212 | BigUint64Array;
213declare namespace WebAssembly {
214 class CompileError extends Error {
215 constructor(message?: string);
216 }
217 class RuntimeError extends Error {
218 constructor(message?: string);
219 }
220 type ValueType =
221 | "anyfunc"
222 | "externref"
223 | "f32"
224 | "f64"
225 | "i32"
226 | "i64"
227 | "v128";
228 interface GlobalDescriptor {
229 value: ValueType;
230 mutable?: boolean;
231 }
232 class Global {
233 constructor(descriptor: GlobalDescriptor, value?: any);
234 value: any;
235 valueOf(): any;
236 }
237 type ImportValue = ExportValue | number;
238 type ModuleImports = Record<string, ImportValue>;
239 type Imports = Record<string, ModuleImports>;
240 type ExportValue = Function | Global | Memory | Table;
241 type Exports = Record<string, ExportValue>;
242 class Instance {
243 constructor(module: Module, imports?: Imports);
244 readonly exports: Exports;
245 }
246 interface MemoryDescriptor {
247 initial: number;
248 maximum?: number;
249 shared?: boolean;
250 }
251 class Memory {
252 constructor(descriptor: MemoryDescriptor);
253 readonly buffer: ArrayBuffer;
254 grow(delta: number): number;
255 }
256 type ImportExportKind = "function" | "global" | "memory" | "table";
257 interface ModuleExportDescriptor {
258 kind: ImportExportKind;
259 name: string;
260 }
261 interface ModuleImportDescriptor {
262 kind: ImportExportKind;
263 module: string;
264 name: string;
265 }
266 abstract class Module {
267 static customSections(module: Module, sectionName: string): ArrayBuffer[];
268 static exports(module: Module): ModuleExportDescriptor[];
269 static imports(module: Module): ModuleImportDescriptor[];
270 }
271 type TableKind = "anyfunc" | "externref";
272 interface TableDescriptor {
273 element: TableKind;
274 initial: number;
275 maximum?: number;
276 }
277 class Table {
278 constructor(descriptor: TableDescriptor, value?: any);
279 readonly length: number;
280 get(index: number): any;
281 grow(delta: number, value?: any): number;
282 set(index: number, value?: any): void;
283 }
284 function instantiate(module: Module, imports?: Imports): Promise<Instance>;
285 function validate(bytes: BufferSource): boolean;
286}
287/**
288 * The **`ServiceWorkerGlobalScope`** interface of the Service Worker API represents the global execution context of a service worker.
289 * Available only in secure contexts.
290 *
291 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ServiceWorkerGlobalScope)
292 */
293interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
294 DOMException: typeof DOMException;
295 WorkerGlobalScope: typeof WorkerGlobalScope;
296 EventTarget: typeof EventTarget;
297 btoa(data: string): string;
298 atob(data: string): string;
299 setTimeout(callback: (...args: any[]) => void, msDelay?: number): number;
300 setTimeout<Args extends any[]>(
301 callback: (...args: Args) => void,
302 msDelay?: number,
303 ...args: Args
304 ): number;
305 clearTimeout(timeoutId: number | null): void;
306 setInterval(callback: (...args: any[]) => void, msDelay?: number): number;
307 setInterval<Args extends any[]>(
308 callback: (...args: Args) => void,
309 msDelay?: number,
310 ...args: Args
311 ): number;
312 clearInterval(timeoutId: number | null): void;
313 queueMicrotask(task: Function): void;
314 structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
315 reportError(error: any): void;
316 fetch(
317 input: RequestInfo | URL,
318 init?: RequestInit<RequestInitCfProperties>,
319 ): Promise<Response>;
320 self: ServiceWorkerGlobalScope;
321 crypto: Crypto;
322 caches: CacheStorage;
323 scheduler: Scheduler;
324 performance: Performance;
325 Cloudflare: Cloudflare;
326 readonly origin: string;
327 Event: typeof Event;
328 ExtendableEvent: typeof ExtendableEvent;
329 CustomEvent: typeof CustomEvent;
330 PromiseRejectionEvent: typeof PromiseRejectionEvent;
331 FetchEvent: typeof FetchEvent;
332 TailEvent: typeof TailEvent;
333 TraceEvent: typeof TailEvent;
334 ScheduledEvent: typeof ScheduledEvent;
335 MessageEvent: typeof MessageEvent;
336 CloseEvent: typeof CloseEvent;
337 ReadableStreamDefaultReader: typeof ReadableStreamDefaultReader;
338 ReadableStreamBYOBReader: typeof ReadableStreamBYOBReader;
339 ReadableStream: typeof ReadableStream;
340 WritableStream: typeof WritableStream;
341 WritableStreamDefaultWriter: typeof WritableStreamDefaultWriter;
342 TransformStream: typeof TransformStream;
343 ByteLengthQueuingStrategy: typeof ByteLengthQueuingStrategy;
344 CountQueuingStrategy: typeof CountQueuingStrategy;
345 ErrorEvent: typeof ErrorEvent;
346 MessageChannel: typeof MessageChannel;
347 MessagePort: typeof MessagePort;
348 FileSystemHandle: typeof FileSystemHandle;
349 FileSystemFileHandle: typeof FileSystemFileHandle;
350 FileSystemDirectoryHandle: typeof FileSystemDirectoryHandle;
351 FileSystemWritableFileStream: typeof FileSystemWritableFileStream;
352 StorageManager: typeof StorageManager;
353 EventSource: typeof EventSource;
354 ReadableStreamBYOBRequest: typeof ReadableStreamBYOBRequest;
355 ReadableStreamDefaultController: typeof ReadableStreamDefaultController;
356 ReadableByteStreamController: typeof ReadableByteStreamController;
357 WritableStreamDefaultController: typeof WritableStreamDefaultController;
358 TransformStreamDefaultController: typeof TransformStreamDefaultController;
359 CompressionStream: typeof CompressionStream;
360 DecompressionStream: typeof DecompressionStream;
361 TextEncoderStream: typeof TextEncoderStream;
362 TextDecoderStream: typeof TextDecoderStream;
363 Headers: typeof Headers;
364 Body: typeof Body;
365 Request: typeof Request;
366 Response: typeof Response;
367 WebSocket: typeof WebSocket;
368 WebSocketPair: typeof WebSocketPair;
369 WebSocketRequestResponsePair: typeof WebSocketRequestResponsePair;
370 AbortController: typeof AbortController;
371 AbortSignal: typeof AbortSignal;
372 TextDecoder: typeof TextDecoder;
373 TextEncoder: typeof TextEncoder;
374 navigator: Navigator;
375 Navigator: typeof Navigator;
376 URL: typeof URL;
377 URLSearchParams: typeof URLSearchParams;
378 URLPattern: typeof URLPattern;
379 Blob: typeof Blob;
380 File: typeof File;
381 FormData: typeof FormData;
382 Crypto: typeof Crypto;
383 SubtleCrypto: typeof SubtleCrypto;
384 CryptoKey: typeof CryptoKey;
385 CacheStorage: typeof CacheStorage;
386 Cache: typeof Cache;
387 FixedLengthStream: typeof FixedLengthStream;
388 IdentityTransformStream: typeof IdentityTransformStream;
389 HTMLRewriter: typeof HTMLRewriter;
390 Performance: typeof Performance;
391 PerformanceEntry: typeof PerformanceEntry;
392 PerformanceMark: typeof PerformanceMark;
393 PerformanceMeasure: typeof PerformanceMeasure;
394 PerformanceResourceTiming: typeof PerformanceResourceTiming;
395 PerformanceObserver: typeof PerformanceObserver;
396 PerformanceObserverEntryList: typeof PerformanceObserverEntryList;
397}
398declare function addEventListener<Type extends keyof WorkerGlobalScopeEventMap>(
399 type: Type,
400 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
401 options?: EventTargetAddEventListenerOptions | boolean,
402): void;
403declare function removeEventListener<
404 Type extends keyof WorkerGlobalScopeEventMap,
405>(
406 type: Type,
407 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
408 options?: EventTargetEventListenerOptions | boolean,
409): void;
410/**
411 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
412 *
413 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
414 */
415declare function dispatchEvent(
416 event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
417): boolean;
418/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
419declare function btoa(data: string): string;
420/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
421declare function atob(data: string): string;
422/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
423declare function setTimeout(
424 callback: (...args: any[]) => void,
425 msDelay?: number,
426): number;
427/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
428declare function setTimeout<Args extends any[]>(
429 callback: (...args: Args) => void,
430 msDelay?: number,
431 ...args: Args
432): number;
433/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
434declare function clearTimeout(timeoutId: number | null): void;
435/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
436declare function setInterval(
437 callback: (...args: any[]) => void,
438 msDelay?: number,
439): number;
440/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
441declare function setInterval<Args extends any[]>(
442 callback: (...args: Args) => void,
443 msDelay?: number,
444 ...args: Args
445): number;
446/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
447declare function clearInterval(timeoutId: number | null): void;
448/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
449declare function queueMicrotask(task: Function): void;
450/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
451declare function structuredClone<T>(
452 value: T,
453 options?: StructuredSerializeOptions,
454): T;
455/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
456declare function reportError(error: any): void;
457/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
458declare function fetch(
459 input: RequestInfo | URL,
460 init?: RequestInit<RequestInitCfProperties>,
461): Promise<Response>;
462declare const self: ServiceWorkerGlobalScope;
463/**
464 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
465 * The Workers runtime implements the full surface of this API, but with some differences in
466 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
467 * compared to those implemented in most browsers.
468 *
469 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
470 */
471declare const crypto: Crypto;
472/**
473 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
474 *
475 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
476 */
477declare const caches: CacheStorage;
478declare const scheduler: Scheduler;
479/**
480 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
481 * as well as timing of subrequests and other operations.
482 *
483 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
484 */
485declare const performance: Performance;
486declare const Cloudflare: Cloudflare;
487declare const origin: string;
488declare const navigator: Navigator;
489interface TestController {}
490interface ExecutionContext<Props = unknown> {
491 waitUntil(promise: Promise<any>): void;
492 passThroughOnException(): void;
493 readonly exports: Cloudflare.Exports;
494 readonly props: Props;
495 cache?: CacheContext;
496 readonly version?: {
497 readonly metadata?: {
498 readonly id: string;
499 };
500 readonly cohort?: string;
501 readonly key?: string;
502 readonly override?: string;
503 };
504 tracing?: Tracing;
505 abort(reason?: any): void;
506}
507type ExportedHandlerFetchHandler<
508 Env = unknown,
509 CfHostMetadata = unknown,
510 Props = unknown,
511> = (
512 request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
513 env: Env,
514 ctx: ExecutionContext<Props>,
515) => Response | Promise<Response>;
516type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
517 socket: Socket,
518 env: Env,
519 ctx: ExecutionContext<Props>,
520) => void | Promise<void>;
521type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
522 events: TraceItem[],
523 env: Env,
524 ctx: ExecutionContext<Props>,
525) => void | Promise<void>;
526type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (
527 traces: TraceItem[],
528 env: Env,
529 ctx: ExecutionContext<Props>,
530) => void | Promise<void>;
531type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (
532 event: TailStream.TailEvent<TailStream.Onset>,
533 env: Env,
534 ctx: ExecutionContext<Props>,
535) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
536type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (
537 controller: ScheduledController,
538 env: Env,
539 ctx: ExecutionContext<Props>,
540) => void | Promise<void>;
541type ExportedHandlerQueueHandler<
542 Env = unknown,
543 Message = unknown,
544 Props = unknown,
545> = (
546 batch: MessageBatch<Message>,
547 env: Env,
548 ctx: ExecutionContext<Props>,
549) => void | Promise<void>;
550type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (
551 controller: TestController,
552 env: Env,
553 ctx: ExecutionContext<Props>,
554) => void | Promise<void>;
555interface ExportedHandler<
556 Env = unknown,
557 QueueHandlerMessage = unknown,
558 CfHostMetadata = unknown,
559 Props = unknown,
560> {
561 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
562 connect?: ExportedHandlerConnectHandler<Env, Props>;
563 tail?: ExportedHandlerTailHandler<Env, Props>;
564 trace?: ExportedHandlerTraceHandler<Env, Props>;
565 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
566 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
567 test?: ExportedHandlerTestHandler<Env, Props>;
568 email?: EmailExportedHandler<Env, Props>;
569 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
570}
571interface StructuredSerializeOptions {
572 transfer?: any[];
573}
574declare abstract class Navigator {
575 sendBeacon(url: string, body?: BodyInit): boolean;
576 readonly userAgent: string;
577 readonly hardwareConcurrency: number;
578 readonly platform: string;
579 readonly language: string;
580 readonly languages: string[];
581 readonly storage: StorageManager;
582}
583interface AlarmInvocationInfo {
584 readonly isRetry: boolean;
585 readonly retryCount: number;
586 readonly scheduledTime: number;
587}
588interface Cloudflare {
589 readonly compatibilityFlags: Record<string, boolean>;
590}
591interface CachePurgeError {
592 code: number;
593 message: string;
594}
595interface CachePurgeResult {
596 success: boolean;
597 errors: CachePurgeError[];
598}
599interface CachePurgeOptions {
600 tags?: string[];
601 pathPrefixes?: string[];
602 purgeEverything?: boolean;
603}
604interface CacheContext {
605 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
606}
607declare abstract class ColoLocalActorNamespace {
608 get(actorId: string): Fetcher;
609}
610interface DurableObject {
611 fetch(request: Request): Response | Promise<Response>;
612 connect?(socket: Socket): void | Promise<void>;
613 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
614 webSocketMessage?(
615 ws: WebSocket,
616 message: string | ArrayBuffer,
617 ): void | Promise<void>;
618 webSocketClose?(
619 ws: WebSocket,
620 code: number,
621 reason: string,
622 wasClean: boolean,
623 ): void | Promise<void>;
624 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
625}
626type DurableObjectStub<
627 T extends Rpc.DurableObjectBranded | undefined = undefined,
628> = Fetcher<
629 T,
630 "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
631> & {
632 readonly id: DurableObjectId;
633 readonly name?: string;
634};
635interface DurableObjectId {
636 toString(): string;
637 equals(other: DurableObjectId): boolean;
638 readonly name?: string;
639 readonly jurisdiction?: string;
640}
641declare abstract class DurableObjectNamespace<
642 T extends Rpc.DurableObjectBranded | undefined = undefined,
643> {
644 newUniqueId(
645 options?: DurableObjectNamespaceNewUniqueIdOptions,
646 ): DurableObjectId;
647 idFromName(name: string): DurableObjectId;
648 idFromString(id: string): DurableObjectId;
649 get(
650 id: DurableObjectId,
651 options?: DurableObjectNamespaceGetDurableObjectOptions,
652 ): DurableObjectStub<T>;
653 getByName(
654 name: string,
655 options?: DurableObjectNamespaceGetDurableObjectOptions,
656 ): DurableObjectStub<T>;
657 getExisting(
658 id: DurableObjectId,
659 options?: DurableObjectNamespaceGetDurableObjectOptions,
660 ): DurableObjectStub<T>;
661 jurisdiction(
662 jurisdiction: DurableObjectJurisdiction,
663 ): DurableObjectNamespace<T>;
664}
665type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
666interface DurableObjectNamespaceNewUniqueIdOptions {
667 jurisdiction?: DurableObjectJurisdiction;
668}
669type DurableObjectLocationHint =
670 | "wnam"
671 | "enam"
672 | "sam"
673 | "weur"
674 | "eeur"
675 | "apac"
676 | "oc"
677 | "afr"
678 | "me";
679type DurableObjectRoutingMode = "primary-only";
680interface DurableObjectNamespaceGetDurableObjectOptions {
681 locationHint?: DurableObjectLocationHint;
682 routingMode?: DurableObjectRoutingMode;
683 version?: {
684 cohort?: string;
685 };
686}
687interface DurableObjectClass<
688 _T extends Rpc.DurableObjectBranded | undefined = undefined,
689> {}
690interface DurableObjectNamespaceGetDurableObjectOptionsVersionOptions {
691 cohort?: string;
692}
693interface DurableObjectState<Props = unknown> {
694 waitUntil(promise: Promise<any>): void;
695 readonly exports: Cloudflare.Exports;
696 readonly props: Props;
697 readonly id: DurableObjectId;
698 readonly storage: DurableObjectStorage;
699 container?: Container;
700 facets: DurableObjectFacets;
701 version?: DurableObjectStateVersion;
702 readonly primaryStub?: DurableObjectStub;
703 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
704 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
705 getWebSockets(tag?: string): WebSocket[];
706 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
707 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
708 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
709 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
710 getHibernatableWebSocketEventTimeout(): number | null;
711 getTags(ws: WebSocket): string[];
712 abort(reason?: string): void;
713 configureReadReplication(
714 options: DurableObjectReadReplicationOptions,
715 ): Promise<void>;
716}
717interface DurableObjectTransaction {
718 get<T = unknown>(
719 key: string,
720 options?: DurableObjectGetOptions,
721 ): Promise<T | undefined>;
722 get<T = unknown>(
723 keys: string[],
724 options?: DurableObjectGetOptions,
725 ): Promise<Map<string, T>>;
726 list<T = unknown>(
727 options?: DurableObjectListOptions,
728 ): Promise<Map<string, T>>;
729 put<T>(
730 key: string,
731 value: T,
732 options?: DurableObjectPutOptions,
733 ): Promise<void>;
734 put<T>(
735 entries: Record<string, T>,
736 options?: DurableObjectPutOptions,
737 ): Promise<void>;
738 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
739 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
740 rollback(): void;
741 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
742 setAlarm(
743 scheduledTime: number | Date,
744 options?: DurableObjectSetAlarmOptions,
745 ): Promise<void>;
746 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
747}
748interface DurableObjectStorage {
749 get<T = unknown>(
750 key: string,
751 options?: DurableObjectGetOptions,
752 ): Promise<T | undefined>;
753 get<T = unknown>(
754 keys: string[],
755 options?: DurableObjectGetOptions,
756 ): Promise<Map<string, T>>;
757 list<T = unknown>(
758 options?: DurableObjectListOptions,
759 ): Promise<Map<string, T>>;
760 put<T>(
761 key: string,
762 value: T,
763 options?: DurableObjectPutOptions,
764 ): Promise<void>;
765 put<T>(
766 entries: Record<string, T>,
767 options?: DurableObjectPutOptions,
768 ): Promise<void>;
769 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
770 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
771 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
772 transaction<T>(
773 closure: (txn: DurableObjectTransaction) => Promise<T>,
774 ): Promise<T>;
775 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
776 setAlarm(
777 scheduledTime: number | Date,
778 options?: DurableObjectSetAlarmOptions,
779 ): Promise<void>;
780 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
781 sync(): Promise<void>;
782 sql: SqlStorage;
783 kv: SyncKvStorage;
784 transactionSync<T>(closure: () => T): T;
785 getCurrentBookmark(): Promise<string>;
786 getBookmarkForTime(timestamp: number | Date): Promise<string>;
787 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
788 waitForBookmark(bookmark: string): Promise<void>;
789 /** @deprecated Use `ctx.primaryStub` instead. */
790 readonly primary?: DurableObjectStub;
791 /** @deprecated Use `ctx.configureReadReplication()` instead. */
792 ensureReplicas(): void;
793 /** @deprecated Use `ctx.configureReadReplication()` instead. */
794 disableReplicas(): void;
795}
796interface DurableObjectReadReplicationOptions {
797 mode: "auto" | "disabled";
798}
799interface DurableObjectListOptions {
800 start?: string;
801 startAfter?: string;
802 end?: string;
803 prefix?: string;
804 reverse?: boolean;
805 limit?: number;
806 allowConcurrency?: boolean;
807 noCache?: boolean;
808}
809interface DurableObjectGetOptions {
810 allowConcurrency?: boolean;
811 noCache?: boolean;
812}
813interface DurableObjectGetAlarmOptions {
814 allowConcurrency?: boolean;
815}
816interface DurableObjectPutOptions {
817 allowConcurrency?: boolean;
818 allowUnconfirmed?: boolean;
819 noCache?: boolean;
820}
821interface DurableObjectSetAlarmOptions {
822 allowConcurrency?: boolean;
823 allowUnconfirmed?: boolean;
824}
825declare class WebSocketRequestResponsePair {
826 constructor(request: string, response: string);
827 get request(): string;
828 get response(): string;
829}
830interface DurableObjectFacets {
831 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
832 name: string,
833 getStartupOptions: () =>
834 | FacetStartupOptions<T>
835 | Promise<FacetStartupOptions<T>>,
836 ): Fetcher<T>;
837 abort(name: string, reason: any): void;
838 delete(name: string): void;
839}
840interface FacetStartupOptions<
841 T extends Rpc.DurableObjectBranded | undefined = undefined,
842> {
843 id?: DurableObjectId | string;
844 class: DurableObjectClass<T>;
845}
846interface DurableObjectStateVersion {
847 cohort?: string;
848}
849interface AnalyticsEngineDataset {
850 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
851}
852interface AnalyticsEngineDataPoint {
853 indexes?: ((ArrayBuffer | string) | null)[];
854 doubles?: number[];
855 blobs?: ((ArrayBuffer | string) | null)[];
856}
857/**
858 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
859 *
860 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
861 */
862declare class Event {
863 constructor(type: string, init?: EventInit);
864 /**
865 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
866 *
867 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
868 */
869 get type(): string;
870 /**
871 * The **`eventPhase`** read-only property of the being evaluated.
872 *
873 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
874 */
875 get eventPhase(): number;
876 /**
877 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
878 *
879 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
880 */
881 get composed(): boolean;
882 /**
883 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
884 *
885 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
886 */
887 get bubbles(): boolean;
888 /**
889 * 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.
890 *
891 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
892 */
893 get cancelable(): boolean;
894 /**
895 * 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.
896 *
897 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
898 */
899 get defaultPrevented(): boolean;
900 /**
901 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
902 * @deprecated
903 *
904 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
905 */
906 get returnValue(): boolean;
907 /**
908 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
909 *
910 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
911 */
912 get currentTarget(): EventTarget | null;
913 /**
914 * The read-only **`target`** property of the dispatched.
915 *
916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
917 */
918 get target(): EventTarget | undefined;
919 /**
920 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
921 * @deprecated
922 *
923 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
924 */
925 get srcElement(): EventTarget | undefined;
926 /**
927 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
928 *
929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
930 */
931 get timeStamp(): number;
932 /**
933 * 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.
934 *
935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
936 */
937 readonly isTrusted: boolean;
938 /**
939 * The **`cancelBubble`** property of the Event interface is deprecated.
940 * @deprecated
941 *
942 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
943 */
944 get cancelBubble(): boolean;
945 /**
946 * The **`cancelBubble`** property of the Event interface is deprecated.
947 * @deprecated
948 *
949 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
950 */
951 set cancelBubble(value: boolean);
952 /**
953 * 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.
954 *
955 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
956 */
957 stopImmediatePropagation(): void;
958 /**
959 * 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.
960 *
961 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
962 */
963 preventDefault(): void;
964 /**
965 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
966 *
967 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
968 */
969 stopPropagation(): void;
970 /**
971 * 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.
972 *
973 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
974 */
975 composedPath(): EventTarget[];
976 static readonly NONE: number;
977 static readonly CAPTURING_PHASE: number;
978 static readonly AT_TARGET: number;
979 static readonly BUBBLING_PHASE: number;
980}
981interface EventInit {
982 bubbles?: boolean;
983 cancelable?: boolean;
984 composed?: boolean;
985}
986type EventListener<EventType extends Event = Event> = (
987 event: EventType,
988) => void;
989interface EventListenerObject<EventType extends Event = Event> {
990 handleEvent(event: EventType): void;
991}
992type EventListenerOrEventListenerObject<EventType extends Event = Event> =
993 | EventListener<EventType>
994 | EventListenerObject<EventType>;
995/**
996 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
997 *
998 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
999 */
1000declare class EventTarget<
1001 EventMap extends Record<string, Event> = Record<string, Event>,
1002> {
1003 constructor();
1004 /**
1005 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
1006 *
1007 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
1008 */
1009 addEventListener<Type extends keyof EventMap>(
1010 type: Type,
1011 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
1012 options?: EventTargetAddEventListenerOptions | boolean,
1013 ): void;
1014 /**
1015 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
1016 *
1017 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
1018 */
1019 removeEventListener<Type extends keyof EventMap>(
1020 type: Type,
1021 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
1022 options?: EventTargetEventListenerOptions | boolean,
1023 ): void;
1024 /**
1025 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
1026 *
1027 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
1028 */
1029 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
1030}
1031interface EventTargetEventListenerOptions {
1032 capture?: boolean;
1033}
1034interface EventTargetAddEventListenerOptions {
1035 capture?: boolean;
1036 passive?: boolean;
1037 once?: boolean;
1038 signal?: AbortSignal;
1039}
1040interface EventTargetHandlerObject {
1041 handleEvent: (event: Event) => any | undefined;
1042}
1043/**
1044 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
1045 *
1046 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
1047 */
1048declare class AbortController {
1049 constructor();
1050 /**
1051 * 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.
1052 *
1053 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
1054 */
1055 get signal(): AbortSignal;
1056 /**
1057 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
1058 *
1059 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
1060 */
1061 abort(reason?: any): void;
1062}
1063/**
1064 * 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.
1065 *
1066 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
1067 */
1068declare abstract class AbortSignal extends EventTarget {
1069 /**
1070 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
1071 *
1072 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
1073 */
1074 static abort(reason?: any): AbortSignal;
1075 /**
1076 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
1077 *
1078 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
1079 */
1080 static timeout(delay: number): AbortSignal;
1081 /**
1082 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
1083 *
1084 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
1085 */
1086 static any(signals: AbortSignal[]): AbortSignal;
1087 /**
1088 * 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`).
1089 *
1090 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
1091 */
1092 get aborted(): boolean;
1093 /**
1094 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
1095 *
1096 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
1097 */
1098 get reason(): any;
1099 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1100 get onabort(): any | null;
1101 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1102 set onabort(value: any | null);
1103 /**
1104 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
1105 *
1106 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
1107 */
1108 throwIfAborted(): void;
1109}
1110interface Scheduler {
1111 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
1112}
1113interface SchedulerWaitOptions {
1114 signal?: AbortSignal;
1115}
1116/**
1117 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
1118 *
1119 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
1120 */
1121declare abstract class ExtendableEvent extends Event {
1122 /**
1123 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
1124 *
1125 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
1126 */
1127 waitUntil(promise: Promise<any>): void;
1128}
1129/**
1130 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
1131 *
1132 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
1133 */
1134declare class CustomEvent<T = any> extends Event {
1135 constructor(type: string, init?: CustomEventCustomEventInit);
1136 /**
1137 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
1138 *
1139 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
1140 */
1141 get detail(): T;
1142}
1143interface CustomEventCustomEventInit {
1144 bubbles?: boolean;
1145 cancelable?: boolean;
1146 composed?: boolean;
1147 detail?: any;
1148}
1149/**
1150 * 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.
1151 *
1152 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
1153 */
1154declare class Blob {
1155 constructor(
1156 bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
1157 options?: BlobOptions,
1158 );
1159 /**
1160 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
1161 *
1162 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
1163 */
1164 get size(): number;
1165 /**
1166 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
1167 *
1168 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
1169 */
1170 get type(): string;
1171 /**
1172 * 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.
1173 *
1174 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
1175 */
1176 slice(start?: number, end?: number, type?: string): Blob;
1177 /**
1178 * 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.
1179 *
1180 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
1181 */
1182 arrayBuffer(): Promise<ArrayBuffer>;
1183 /**
1184 * 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.
1185 *
1186 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
1187 */
1188 bytes(): Promise<Uint8Array>;
1189 /**
1190 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
1191 *
1192 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
1193 */
1194 text(): Promise<string>;
1195 /**
1196 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
1197 *
1198 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
1199 */
1200 stream(): ReadableStream;
1201}
1202interface BlobOptions {
1203 type?: string;
1204}
1205/**
1206 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
1207 *
1208 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
1209 */
1210declare class File extends Blob {
1211 constructor(
1212 bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
1213 name: string,
1214 options?: FileOptions,
1215 );
1216 /**
1217 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
1218 *
1219 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
1220 */
1221 get name(): string;
1222 /**
1223 * 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).
1224 *
1225 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
1226 */
1227 get lastModified(): number;
1228}
1229interface FileOptions {
1230 type?: string;
1231 lastModified?: number;
1232}
1233/**
1234 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1235 *
1236 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1237 */
1238declare abstract class CacheStorage {
1239 /**
1240 * The **`open()`** method of the the Cache object matching the `cacheName`.
1241 *
1242 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
1243 */
1244 open(cacheName: string): Promise<Cache>;
1245 readonly default: Cache;
1246}
1247/**
1248 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1249 *
1250 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1251 */
1252declare abstract class Cache {
1253 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1254 delete(
1255 request: RequestInfo | URL,
1256 options?: CacheQueryOptions,
1257 ): Promise<boolean>;
1258 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1259 match(
1260 request: RequestInfo | URL,
1261 options?: CacheQueryOptions,
1262 ): Promise<Response | undefined>;
1263 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1264 put(request: RequestInfo | URL, response: Response): Promise<void>;
1265}
1266interface CacheQueryOptions {
1267 ignoreMethod?: boolean;
1268}
1269/**
1270 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1271 * The Workers runtime implements the full surface of this API, but with some differences in
1272 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1273 * compared to those implemented in most browsers.
1274 *
1275 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1276 */
1277declare abstract class Crypto {
1278 /**
1279 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1280 * Available only in secure contexts.
1281 *
1282 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1283 */
1284 get subtle(): SubtleCrypto;
1285 /**
1286 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1287 *
1288 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1289 */
1290 getRandomValues<
1291 T extends
1292 | Int8Array
1293 | Uint8Array
1294 | Int16Array
1295 | Uint16Array
1296 | Int32Array
1297 | Uint32Array
1298 | BigInt64Array
1299 | BigUint64Array,
1300 >(buffer: T): T;
1301 /**
1302 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1303 * Available only in secure contexts.
1304 *
1305 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1306 */
1307 randomUUID(): string;
1308 DigestStream: typeof DigestStream;
1309}
1310/**
1311 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1312 * Available only in secure contexts.
1313 *
1314 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1315 */
1316declare abstract class SubtleCrypto {
1317 /**
1318 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1319 *
1320 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1321 */
1322 encrypt(
1323 algorithm: string | SubtleCryptoEncryptAlgorithm,
1324 key: CryptoKey,
1325 plainText: ArrayBuffer | ArrayBufferView,
1326 ): Promise<ArrayBuffer>;
1327 /**
1328 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1329 *
1330 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1331 */
1332 decrypt(
1333 algorithm: string | SubtleCryptoEncryptAlgorithm,
1334 key: CryptoKey,
1335 cipherText: ArrayBuffer | ArrayBufferView,
1336 ): Promise<ArrayBuffer>;
1337 /**
1338 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1339 *
1340 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1341 */
1342 sign(
1343 algorithm: string | SubtleCryptoSignAlgorithm,
1344 key: CryptoKey,
1345 data: ArrayBuffer | ArrayBufferView,
1346 ): Promise<ArrayBuffer>;
1347 /**
1348 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1349 *
1350 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1351 */
1352 verify(
1353 algorithm: string | SubtleCryptoSignAlgorithm,
1354 key: CryptoKey,
1355 signature: ArrayBuffer | ArrayBufferView,
1356 data: ArrayBuffer | ArrayBufferView,
1357 ): Promise<boolean>;
1358 /**
1359 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1360 *
1361 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1362 */
1363 digest(
1364 algorithm: string | SubtleCryptoHashAlgorithm,
1365 data: ArrayBuffer | ArrayBufferView,
1366 ): Promise<ArrayBuffer>;
1367 /**
1368 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1369 *
1370 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1371 */
1372 generateKey(
1373 algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
1374 extractable: boolean,
1375 keyUsages: string[],
1376 ): Promise<CryptoKey | CryptoKeyPair>;
1377 /**
1378 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1379 *
1380 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1381 */
1382 deriveKey(
1383 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1384 baseKey: CryptoKey,
1385 derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1386 extractable: boolean,
1387 keyUsages: string[],
1388 ): Promise<CryptoKey>;
1389 /**
1390 * The **`deriveBits()`** method of the key.
1391 *
1392 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1393 */
1394 deriveBits(
1395 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1396 baseKey: CryptoKey,
1397 length?: number | null,
1398 ): Promise<ArrayBuffer>;
1399 /**
1400 * 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.
1401 *
1402 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1403 */
1404 importKey(
1405 format: string,
1406 keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
1407 algorithm: string | SubtleCryptoImportKeyAlgorithm,
1408 extractable: boolean,
1409 keyUsages: string[],
1410 ): Promise<CryptoKey>;
1411 /**
1412 * 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.
1413 *
1414 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1415 */
1416 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1417 /**
1418 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1419 *
1420 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1421 */
1422 wrapKey(
1423 format: string,
1424 key: CryptoKey,
1425 wrappingKey: CryptoKey,
1426 wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1427 ): Promise<ArrayBuffer>;
1428 /**
1429 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1430 *
1431 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1432 */
1433 unwrapKey(
1434 format: string,
1435 wrappedKey: ArrayBuffer | ArrayBufferView,
1436 unwrappingKey: CryptoKey,
1437 unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1438 unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1439 extractable: boolean,
1440 keyUsages: string[],
1441 ): Promise<CryptoKey>;
1442 timingSafeEqual(
1443 a: ArrayBuffer | ArrayBufferView,
1444 b: ArrayBuffer | ArrayBufferView,
1445 ): boolean;
1446}
1447/**
1448 * 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.
1449 * Available only in secure contexts.
1450 *
1451 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1452 */
1453declare abstract class CryptoKey {
1454 /**
1455 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1456 *
1457 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1458 */
1459 readonly type: string;
1460 /**
1461 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1462 *
1463 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1464 */
1465 readonly extractable: boolean;
1466 /**
1467 * 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.
1468 *
1469 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1470 */
1471 readonly algorithm:
1472 | CryptoKeyKeyAlgorithm
1473 | CryptoKeyAesKeyAlgorithm
1474 | CryptoKeyHmacKeyAlgorithm
1475 | CryptoKeyRsaKeyAlgorithm
1476 | CryptoKeyEllipticKeyAlgorithm
1477 | CryptoKeyArbitraryKeyAlgorithm;
1478 /**
1479 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1480 *
1481 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1482 */
1483 readonly usages: string[];
1484}
1485interface CryptoKeyPair {
1486 publicKey: CryptoKey;
1487 privateKey: CryptoKey;
1488}
1489interface JsonWebKey {
1490 kty: string;
1491 use?: string;
1492 key_ops?: string[];
1493 alg?: string;
1494 ext?: boolean;
1495 crv?: string;
1496 x?: string;
1497 y?: string;
1498 d?: string;
1499 n?: string;
1500 e?: string;
1501 p?: string;
1502 q?: string;
1503 dp?: string;
1504 dq?: string;
1505 qi?: string;
1506 oth?: RsaOtherPrimesInfo[];
1507 k?: string;
1508}
1509interface RsaOtherPrimesInfo {
1510 r?: string;
1511 d?: string;
1512 t?: string;
1513}
1514interface SubtleCryptoDeriveKeyAlgorithm {
1515 name: string;
1516 salt?: ArrayBuffer | ArrayBufferView;
1517 iterations?: number;
1518 hash?: string | SubtleCryptoHashAlgorithm;
1519 $public?: CryptoKey;
1520 info?: ArrayBuffer | ArrayBufferView;
1521}
1522interface SubtleCryptoEncryptAlgorithm {
1523 name: string;
1524 iv?: ArrayBuffer | ArrayBufferView;
1525 additionalData?: ArrayBuffer | ArrayBufferView;
1526 tagLength?: number;
1527 counter?: ArrayBuffer | ArrayBufferView;
1528 length?: number;
1529 label?: ArrayBuffer | ArrayBufferView;
1530}
1531interface SubtleCryptoGenerateKeyAlgorithm {
1532 name: string;
1533 hash?: string | SubtleCryptoHashAlgorithm;
1534 modulusLength?: number;
1535 publicExponent?: ArrayBuffer | ArrayBufferView;
1536 length?: number;
1537 namedCurve?: string;
1538}
1539interface SubtleCryptoHashAlgorithm {
1540 name: string;
1541}
1542interface SubtleCryptoImportKeyAlgorithm {
1543 name: string;
1544 hash?: string | SubtleCryptoHashAlgorithm;
1545 length?: number;
1546 namedCurve?: string;
1547 compressed?: boolean;
1548}
1549interface SubtleCryptoSignAlgorithm {
1550 name: string;
1551 hash?: string | SubtleCryptoHashAlgorithm;
1552 dataLength?: number;
1553 saltLength?: number;
1554}
1555interface CryptoKeyKeyAlgorithm {
1556 name: string;
1557}
1558interface CryptoKeyAesKeyAlgorithm {
1559 name: string;
1560 length: number;
1561}
1562interface CryptoKeyHmacKeyAlgorithm {
1563 name: string;
1564 hash: CryptoKeyKeyAlgorithm;
1565 length: number;
1566}
1567interface CryptoKeyRsaKeyAlgorithm {
1568 name: string;
1569 modulusLength: number;
1570 publicExponent: ArrayBuffer | ArrayBufferView;
1571 hash?: CryptoKeyKeyAlgorithm;
1572}
1573interface CryptoKeyEllipticKeyAlgorithm {
1574 name: string;
1575 namedCurve: string;
1576}
1577interface CryptoKeyArbitraryKeyAlgorithm {
1578 name: string;
1579 hash?: CryptoKeyKeyAlgorithm;
1580 namedCurve?: string;
1581 length?: number;
1582}
1583declare class DigestStream extends WritableStream<
1584 ArrayBuffer | ArrayBufferView
1585> {
1586 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1587 readonly digest: Promise<ArrayBuffer>;
1588 get bytesWritten(): number | bigint;
1589}
1590/**
1591 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1592 *
1593 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1594 */
1595declare class TextDecoder {
1596 constructor(label?: string, options?: TextDecoderConstructorOptions);
1597 /**
1598 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1599 *
1600 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1601 */
1602 decode(
1603 input?: ArrayBuffer | ArrayBufferView,
1604 options?: TextDecoderDecodeOptions,
1605 ): string;
1606 get encoding(): string;
1607 get fatal(): boolean;
1608 get ignoreBOM(): boolean;
1609}
1610/**
1611 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1612 *
1613 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1614 */
1615declare class TextEncoder {
1616 constructor();
1617 /**
1618 * 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.
1619 *
1620 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1621 */
1622 encode(input?: string): Uint8Array;
1623 /**
1624 * 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.
1625 *
1626 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1627 */
1628 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1629 get encoding(): string;
1630}
1631interface TextDecoderConstructorOptions {
1632 fatal: boolean;
1633 ignoreBOM: boolean;
1634}
1635interface TextDecoderDecodeOptions {
1636 stream: boolean;
1637}
1638interface TextEncoderEncodeIntoResult {
1639 read: number;
1640 written: number;
1641}
1642/**
1643 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1644 *
1645 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1646 */
1647declare class ErrorEvent extends Event {
1648 constructor(type: string, init?: ErrorEventErrorEventInit);
1649 /**
1650 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1651 *
1652 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1653 */
1654 get filename(): string;
1655 /**
1656 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1657 *
1658 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1659 */
1660 get message(): string;
1661 /**
1662 * 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.
1663 *
1664 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1665 */
1666 get lineno(): number;
1667 /**
1668 * 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.
1669 *
1670 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1671 */
1672 get colno(): number;
1673 /**
1674 * 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.
1675 *
1676 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1677 */
1678 get error(): any;
1679}
1680interface ErrorEventErrorEventInit {
1681 message?: string;
1682 filename?: string;
1683 lineno?: number;
1684 colno?: number;
1685 error?: any;
1686}
1687/**
1688 * The **`MessageEvent`** interface represents a message received by a target object.
1689 *
1690 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1691 */
1692declare class MessageEvent extends Event {
1693 constructor(type: string, initializer: MessageEventInit);
1694 /**
1695 * 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.
1696 *
1697 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1698 */
1699 readonly data: any;
1700 /**
1701 * The **`origin`** read-only property of the origin of the message emitter.
1702 *
1703 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1704 */
1705 readonly origin: string | null;
1706 /**
1707 * The **`lastEventId`** read-only property of the unique ID for the event.
1708 *
1709 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1710 */
1711 readonly lastEventId: string;
1712 /**
1713 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1714 *
1715 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1716 */
1717 readonly source: MessagePort | null;
1718 /**
1719 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1720 *
1721 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1722 */
1723 readonly ports: MessagePort[];
1724}
1725interface MessageEventInit {
1726 data: ArrayBuffer | string;
1727}
1728/**
1729 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1730 *
1731 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1732 */
1733declare abstract class PromiseRejectionEvent extends Event {
1734 /**
1735 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1736 *
1737 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1738 */
1739 readonly promise: Promise<any>;
1740 /**
1741 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1742 *
1743 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1744 */
1745 readonly reason: any;
1746}
1747/**
1748 * 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.
1749 *
1750 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1751 */
1752declare class FormData {
1753 constructor();
1754 /**
1755 * 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.
1756 *
1757 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1758 */
1759 append(name: string, value: string | Blob): void;
1760 /**
1761 * 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.
1762 *
1763 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1764 */
1765 append(name: string, value: string): void;
1766 /**
1767 * 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.
1768 *
1769 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1770 */
1771 append(name: string, value: Blob, filename?: string): void;
1772 /**
1773 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1774 *
1775 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1776 */
1777 delete(name: string): void;
1778 /**
1779 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1780 *
1781 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1782 */
1783 get(name: string): (File | string) | null;
1784 /**
1785 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1786 *
1787 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1788 */
1789 getAll(name: string): (File | string)[];
1790 /**
1791 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1792 *
1793 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1794 */
1795 has(name: string): boolean;
1796 /**
1797 * 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.
1798 *
1799 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1800 */
1801 set(name: string, value: string | Blob): void;
1802 /**
1803 * 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.
1804 *
1805 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1806 */
1807 set(name: string, value: string): void;
1808 /**
1809 * 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.
1810 *
1811 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1812 */
1813 set(name: string, value: Blob, filename?: string): void;
1814 /* Returns an array of key, value pairs for every entry in the list. */
1815 entries(): IterableIterator<[key: string, value: File | string]>;
1816 /* Returns a list of keys in the list. */
1817 keys(): IterableIterator<string>;
1818 /* Returns a list of values in the list. */
1819 values(): IterableIterator<File | string>;
1820 forEach<This = unknown>(
1821 callback: (
1822 this: This,
1823 value: File | string,
1824 key: string,
1825 parent: FormData,
1826 ) => void,
1827 thisArg?: This,
1828 ): void;
1829 [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
1830}
1831interface ContentOptions {
1832 html?: boolean;
1833}
1834declare class HTMLRewriter {
1835 constructor();
1836 on(
1837 selector: string,
1838 handlers: HTMLRewriterElementContentHandlers,
1839 ): HTMLRewriter;
1840 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1841 transform(response: Response): Response;
1842}
1843interface HTMLRewriterElementContentHandlers {
1844 element?(element: Element): void | Promise<void>;
1845 comments?(comment: Comment): void | Promise<void>;
1846 text?(element: Text): void | Promise<void>;
1847}
1848interface HTMLRewriterDocumentContentHandlers {
1849 doctype?(doctype: Doctype): void | Promise<void>;
1850 comments?(comment: Comment): void | Promise<void>;
1851 text?(text: Text): void | Promise<void>;
1852 end?(end: DocumentEnd): void | Promise<void>;
1853}
1854interface Doctype {
1855 readonly name: string | null;
1856 readonly publicId: string | null;
1857 readonly systemId: string | null;
1858}
1859interface Element {
1860 tagName: string;
1861 readonly attributes: IterableIterator<string[]>;
1862 readonly removed: boolean;
1863 readonly namespaceURI: string;
1864 getAttribute(name: string): string | null;
1865 hasAttribute(name: string): boolean;
1866 setAttribute(name: string, value: string): Element;
1867 removeAttribute(name: string): Element;
1868 before(
1869 content: string | ReadableStream | Response,
1870 options?: ContentOptions,
1871 ): Element;
1872 after(
1873 content: string | ReadableStream | Response,
1874 options?: ContentOptions,
1875 ): Element;
1876 prepend(
1877 content: string | ReadableStream | Response,
1878 options?: ContentOptions,
1879 ): Element;
1880 append(
1881 content: string | ReadableStream | Response,
1882 options?: ContentOptions,
1883 ): Element;
1884 replace(
1885 content: string | ReadableStream | Response,
1886 options?: ContentOptions,
1887 ): Element;
1888 remove(): Element;
1889 removeAndKeepContent(): Element;
1890 setInnerContent(
1891 content: string | ReadableStream | Response,
1892 options?: ContentOptions,
1893 ): Element;
1894 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1895}
1896interface EndTag {
1897 name: string;
1898 before(
1899 content: string | ReadableStream | Response,
1900 options?: ContentOptions,
1901 ): EndTag;
1902 after(
1903 content: string | ReadableStream | Response,
1904 options?: ContentOptions,
1905 ): EndTag;
1906 remove(): EndTag;
1907}
1908interface Comment {
1909 text: string;
1910 readonly removed: boolean;
1911 before(content: string, options?: ContentOptions): Comment;
1912 after(content: string, options?: ContentOptions): Comment;
1913 replace(content: string, options?: ContentOptions): Comment;
1914 remove(): Comment;
1915}
1916interface Text {
1917 readonly text: string;
1918 readonly lastInTextNode: boolean;
1919 readonly removed: boolean;
1920 before(
1921 content: string | ReadableStream | Response,
1922 options?: ContentOptions,
1923 ): Text;
1924 after(
1925 content: string | ReadableStream | Response,
1926 options?: ContentOptions,
1927 ): Text;
1928 replace(
1929 content: string | ReadableStream | Response,
1930 options?: ContentOptions,
1931 ): Text;
1932 remove(): Text;
1933}
1934interface DocumentEnd {
1935 append(content: string, options?: ContentOptions): DocumentEnd;
1936}
1937/**
1938 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1939 *
1940 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1941 */
1942declare abstract class FetchEvent extends ExtendableEvent {
1943 /**
1944 * The **`request`** read-only property of the the event handler.
1945 *
1946 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1947 */
1948 readonly request: Request;
1949 /**
1950 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1951 *
1952 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1953 */
1954 respondWith(promise: Response | Promise<Response>): void;
1955 passThroughOnException(): void;
1956}
1957type HeadersInit =
1958 | Headers
1959 | Iterable<Iterable<string>>
1960 | Record<string, string>;
1961/**
1962 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1963 *
1964 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1965 */
1966declare class Headers {
1967 constructor(init?: HeadersInit);
1968 /**
1969 * 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.
1970 *
1971 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1972 */
1973 get(name: string): string | null;
1974 getAll(name: string): string[];
1975 /**
1976 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1977 *
1978 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1979 */
1980 getSetCookie(): string[];
1981 /**
1982 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1983 *
1984 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1985 */
1986 has(name: string): boolean;
1987 /**
1988 * 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.
1989 *
1990 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1991 */
1992 set(name: string, value: string): void;
1993 /**
1994 * 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.
1995 *
1996 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1997 */
1998 append(name: string, value: string): void;
1999 /**
2000 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
2001 *
2002 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
2003 */
2004 delete(name: string): void;
2005 forEach<This = unknown>(
2006 callback: (this: This, value: string, key: string, parent: Headers) => void,
2007 thisArg?: This,
2008 ): void;
2009 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
2010 entries(): IterableIterator<[key: string, value: string]>;
2011 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
2012 keys(): IterableIterator<string>;
2013 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
2014 values(): IterableIterator<string>;
2015 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2016}
2017type BodyInit =
2018 | ReadableStream<Uint8Array>
2019 | string
2020 | ArrayBuffer
2021 | ArrayBufferView
2022 | Blob
2023 | URLSearchParams
2024 | FormData
2025 | Iterable<ArrayBuffer | ArrayBufferView>
2026 | AsyncIterable<ArrayBuffer | ArrayBufferView>;
2027declare abstract class Body {
2028 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
2029 get body(): ReadableStream | null;
2030 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
2031 get bodyUsed(): boolean;
2032 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
2033 arrayBuffer(): Promise<ArrayBuffer>;
2034 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
2035 bytes(): Promise<Uint8Array>;
2036 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
2037 text(): Promise<string>;
2038 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
2039 json<T>(): Promise<T>;
2040 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
2041 formData(): Promise<FormData>;
2042 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
2043 blob(): Promise<Blob>;
2044}
2045/**
2046 * The **`Response`** interface of the Fetch API represents the response to a request.
2047 *
2048 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2049 */
2050declare var Response: {
2051 prototype: Response;
2052 new (body?: BodyInit | null, init?: ResponseInit): Response;
2053 error(): Response;
2054 redirect(url: string, status?: number): Response;
2055 json(any: any, maybeInit?: ResponseInit | Response): Response;
2056};
2057/**
2058 * The **`Response`** interface of the Fetch API represents the response to a request.
2059 *
2060 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2061 */
2062interface Response extends Body {
2063 /**
2064 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
2065 *
2066 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
2067 */
2068 clone(): Response;
2069 /**
2070 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
2071 *
2072 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
2073 */
2074 status: number;
2075 /**
2076 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
2077 *
2078 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
2079 */
2080 statusText: string;
2081 /**
2082 * The **`headers`** read-only property of the with the response.
2083 *
2084 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
2085 */
2086 headers: Headers;
2087 /**
2088 * 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.
2089 *
2090 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
2091 */
2092 ok: boolean;
2093 /**
2094 * 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.
2095 *
2096 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
2097 */
2098 redirected: boolean;
2099 /**
2100 * The **`url`** read-only property of the Response interface contains the URL of the response.
2101 *
2102 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
2103 */
2104 url: string;
2105 webSocket: WebSocket | null;
2106 cf: any | undefined;
2107 /**
2108 * The **`type`** read-only property of the Response interface contains the type of the response.
2109 *
2110 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
2111 */
2112 type: "default" | "error";
2113}
2114interface ResponseInit {
2115 status?: number;
2116 statusText?: string;
2117 headers?: HeadersInit;
2118 cf?: any;
2119 webSocket?: WebSocket | null;
2120 encodeBody?: "automatic" | "manual";
2121}
2122type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
2123 | Request<CfHostMetadata, Cf>
2124 | string;
2125/**
2126 * The **`Request`** interface of the Fetch API represents a resource request.
2127 *
2128 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2129 */
2130declare var Request: {
2131 prototype: Request;
2132 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
2133 input: RequestInfo<CfProperties> | URL,
2134 init?: RequestInit<Cf>,
2135 ): Request<CfHostMetadata, Cf>;
2136};
2137/**
2138 * The **`Request`** interface of the Fetch API represents a resource request.
2139 *
2140 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2141 */
2142interface Request<
2143 CfHostMetadata = unknown,
2144 Cf = CfProperties<CfHostMetadata>,
2145> extends Body {
2146 /**
2147 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
2148 *
2149 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
2150 */
2151 clone(): Request<CfHostMetadata, Cf>;
2152 /**
2153 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
2154 *
2155 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
2156 */
2157 method: string;
2158 /**
2159 * The **`url`** read-only property of the Request interface contains the URL of the request.
2160 *
2161 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
2162 */
2163 url: string;
2164 /**
2165 * The **`headers`** read-only property of the with the request.
2166 *
2167 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
2168 */
2169 headers: Headers;
2170 /**
2171 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
2172 *
2173 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
2174 */
2175 redirect: string;
2176 fetcher: Fetcher | null;
2177 /**
2178 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
2179 *
2180 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
2181 */
2182 signal: AbortSignal;
2183 cf?: Cf;
2184 /**
2185 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
2186 *
2187 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
2188 */
2189 integrity: string;
2190 /**
2191 * 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.
2192 *
2193 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
2194 */
2195 keepalive: boolean;
2196 /**
2197 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
2198 *
2199 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
2200 */
2201 cache?: "no-store" | "no-cache" | "reload";
2202}
2203interface RequestInit<Cf = CfProperties> {
2204 /* A string to set request's method. */
2205 method?: string;
2206 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
2207 headers?: HeadersInit;
2208 /* A BodyInit object or null to set request's body. */
2209 body?: BodyInit | null;
2210 /* 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. */
2211 redirect?: string;
2212 fetcher?: Fetcher | null;
2213 cf?: Cf;
2214 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
2215 cache?: "no-store" | "no-cache" | "reload";
2216 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
2217 integrity?: string;
2218 /* An AbortSignal to set request's signal. */
2219 signal?: AbortSignal | null;
2220 encodeResponseBody?: "automatic" | "manual";
2221}
2222type Service<
2223 T extends
2224 | (new (...args: any[]) => Rpc.WorkerEntrypointBranded)
2225 | Rpc.WorkerEntrypointBranded
2226 | ExportedHandler<any, any, any>
2227 | undefined = undefined,
2228> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
2229 ? Fetcher<InstanceType<T>>
2230 : T extends Rpc.WorkerEntrypointBranded
2231 ? Fetcher<T>
2232 : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded>
2233 ? never
2234 : Fetcher<undefined>;
2235type Fetcher<
2236 T extends Rpc.EntrypointBranded | undefined = undefined,
2237 Reserved extends string = never,
2238> = (T extends Rpc.EntrypointBranded
2239 ? Rpc.Provider<T, Reserved | "fetch" | "connect" | "queue" | "scheduled">
2240 : unknown) & {
2241 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
2242 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
2243 queue(
2244 queueName: string,
2245 messages: ServiceBindingQueueMessage[],
2246 metadata?: MessageBatchMetadata,
2247 ): Promise<FetcherQueueResult>;
2248 scheduled(options?: FetcherScheduledOptions): Promise<FetcherScheduledResult>;
2249};
2250interface FetcherScheduledOptions {
2251 scheduledTime?: Date;
2252 cron?: string;
2253}
2254interface FetcherScheduledResult {
2255 outcome: string;
2256 noRetry: boolean;
2257}
2258interface FetcherQueueResult {
2259 outcome: string;
2260 ackAll: boolean;
2261 retryBatch: QueueRetryBatch;
2262 explicitAcks: string[];
2263 retryMessages: QueueRetryMessage[];
2264}
2265type ServiceBindingQueueMessage<Body = unknown> = {
2266 id: string;
2267 timestamp: Date;
2268 attempts: number;
2269} & (
2270 | {
2271 body: Body;
2272 }
2273 | {
2274 serializedBody: ArrayBuffer | ArrayBufferView;
2275 }
2276);
2277interface KVNamespaceListKey<Metadata, Key extends string = string> {
2278 name: Key;
2279 expiration?: number;
2280 metadata?: Metadata;
2281}
2282type KVNamespaceListResult<Metadata, Key extends string = string> =
2283 | {
2284 list_complete: false;
2285 keys: KVNamespaceListKey<Metadata, Key>[];
2286 cursor: string;
2287 cacheStatus: string | null;
2288 }
2289 | {
2290 list_complete: true;
2291 keys: KVNamespaceListKey<Metadata, Key>[];
2292 cacheStatus: string | null;
2293 };
2294interface KVNamespace<Key extends string = string> {
2295 get(
2296 key: Key,
2297 options?: Partial<KVNamespaceGetOptions<undefined>>,
2298 ): Promise<string | null>;
2299 get(key: Key, type: "text"): Promise<string | null>;
2300 get<ExpectedValue = unknown>(
2301 key: Key,
2302 type: "json",
2303 ): Promise<ExpectedValue | null>;
2304 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
2305 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
2306 get(
2307 key: Key,
2308 options?: KVNamespaceGetOptions<"text">,
2309 ): Promise<string | null>;
2310 get<ExpectedValue = unknown>(
2311 key: Key,
2312 options?: KVNamespaceGetOptions<"json">,
2313 ): Promise<ExpectedValue | null>;
2314 get(
2315 key: Key,
2316 options?: KVNamespaceGetOptions<"arrayBuffer">,
2317 ): Promise<ArrayBuffer | null>;
2318 get(
2319 key: Key,
2320 options?: KVNamespaceGetOptions<"stream">,
2321 ): Promise<ReadableStream | null>;
2322 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
2323 get<ExpectedValue = unknown>(
2324 key: Array<Key>,
2325 type: "json",
2326 ): Promise<Map<string, ExpectedValue | null>>;
2327 get(
2328 key: Array<Key>,
2329 options?: Partial<KVNamespaceGetOptions<undefined>>,
2330 ): Promise<Map<string, string | null>>;
2331 get(
2332 key: Array<Key>,
2333 options?: KVNamespaceGetOptions<"text">,
2334 ): Promise<Map<string, string | null>>;
2335 get<ExpectedValue = unknown>(
2336 key: Array<Key>,
2337 options?: KVNamespaceGetOptions<"json">,
2338 ): Promise<Map<string, ExpectedValue | null>>;
2339 list<Metadata = unknown>(
2340 options?: KVNamespaceListOptions,
2341 ): Promise<KVNamespaceListResult<Metadata, Key>>;
2342 put(
2343 key: Key,
2344 value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
2345 options?: KVNamespacePutOptions,
2346 ): Promise<void>;
2347 getWithMetadata<Metadata = unknown>(
2348 key: Key,
2349 options?: Partial<KVNamespaceGetOptions<undefined>>,
2350 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2351 getWithMetadata<Metadata = unknown>(
2352 key: Key,
2353 type: "text",
2354 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2355 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2356 key: Key,
2357 type: "json",
2358 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2359 getWithMetadata<Metadata = unknown>(
2360 key: Key,
2361 type: "arrayBuffer",
2362 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2363 getWithMetadata<Metadata = unknown>(
2364 key: Key,
2365 type: "stream",
2366 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2367 getWithMetadata<Metadata = unknown>(
2368 key: Key,
2369 options: KVNamespaceGetOptions<"text">,
2370 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2371 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2372 key: Key,
2373 options: KVNamespaceGetOptions<"json">,
2374 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2375 getWithMetadata<Metadata = unknown>(
2376 key: Key,
2377 options: KVNamespaceGetOptions<"arrayBuffer">,
2378 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2379 getWithMetadata<Metadata = unknown>(
2380 key: Key,
2381 options: KVNamespaceGetOptions<"stream">,
2382 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2383 getWithMetadata<Metadata = unknown>(
2384 key: Array<Key>,
2385 type: "text",
2386 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2387 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2388 key: Array<Key>,
2389 type: "json",
2390 ): Promise<
2391 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2392 >;
2393 getWithMetadata<Metadata = unknown>(
2394 key: Array<Key>,
2395 options?: Partial<KVNamespaceGetOptions<undefined>>,
2396 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2397 getWithMetadata<Metadata = unknown>(
2398 key: Array<Key>,
2399 options?: KVNamespaceGetOptions<"text">,
2400 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2401 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2402 key: Array<Key>,
2403 options?: KVNamespaceGetOptions<"json">,
2404 ): Promise<
2405 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2406 >;
2407 delete(key: Key): Promise<void>;
2408 deleteBulk(keys: Key | Key[]): Promise<void>;
2409}
2410interface KVNamespaceListOptions {
2411 limit?: number;
2412 prefix?: string | null;
2413 cursor?: string | null;
2414}
2415interface KVNamespaceGetOptions<Type> {
2416 type: Type;
2417 cacheTtl?: number;
2418}
2419interface KVNamespacePutOptions {
2420 expiration?: number;
2421 expirationTtl?: number;
2422 metadata?: any | null;
2423}
2424interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2425 value: Value | null;
2426 metadata: Metadata | null;
2427 cacheStatus: string | null;
2428}
2429type QueueContentType = "text" | "bytes" | "json" | "v8";
2430interface Queue<Body = unknown> {
2431 metrics(): Promise<QueueMetrics>;
2432 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2433 sendBatch(
2434 messages: Iterable<MessageSendRequest<Body>>,
2435 options?: QueueSendBatchOptions,
2436 ): Promise<QueueSendBatchResponse>;
2437}
2438interface QueueSendMetrics {
2439 backlogCount: number;
2440 backlogBytes: number;
2441 oldestMessageTimestamp?: Date;
2442}
2443interface QueueSendMetadata {
2444 metrics: QueueSendMetrics;
2445}
2446interface QueueSendResponse {
2447 metadata: QueueSendMetadata;
2448}
2449interface QueueSendBatchMetrics {
2450 backlogCount: number;
2451 backlogBytes: number;
2452 oldestMessageTimestamp?: Date;
2453}
2454interface QueueSendBatchMetadata {
2455 metrics: QueueSendBatchMetrics;
2456}
2457interface QueueSendBatchResponse {
2458 metadata: QueueSendBatchMetadata;
2459}
2460interface QueueSendOptions {
2461 contentType?: QueueContentType;
2462 delaySeconds?: number;
2463}
2464interface QueueSendBatchOptions {
2465 delaySeconds?: number;
2466}
2467interface MessageSendRequest<Body = unknown> {
2468 body: Body;
2469 contentType?: QueueContentType;
2470 delaySeconds?: number;
2471}
2472interface QueueMetrics {
2473 backlogCount: number;
2474 backlogBytes: number;
2475 oldestMessageTimestamp?: Date;
2476}
2477interface MessageBatchMetrics {
2478 backlogCount: number;
2479 backlogBytes: number;
2480 oldestMessageTimestamp?: Date;
2481}
2482interface MessageBatchMetadata {
2483 metrics: MessageBatchMetrics;
2484}
2485interface QueueRetryBatch {
2486 retry: boolean;
2487 delaySeconds?: number;
2488}
2489interface QueueRetryMessage {
2490 msgId: string;
2491 delaySeconds?: number;
2492}
2493interface QueueRetryOptions {
2494 delaySeconds?: number;
2495}
2496interface Message<Body = unknown> {
2497 readonly id: string;
2498 readonly timestamp: Date;
2499 readonly body: Body;
2500 readonly attempts: number;
2501 retry(options?: QueueRetryOptions): void;
2502 ack(): void;
2503}
2504interface QueueEvent<Body = unknown> extends ExtendableEvent {
2505 readonly messages: readonly Message<Body>[];
2506 readonly queue: string;
2507 readonly metadata: MessageBatchMetadata;
2508 retryAll(options?: QueueRetryOptions): void;
2509 ackAll(): void;
2510}
2511interface MessageBatch<Body = unknown> {
2512 readonly messages: readonly Message<Body>[];
2513 readonly queue: string;
2514 readonly metadata: MessageBatchMetadata;
2515 retryAll(options?: QueueRetryOptions): void;
2516 ackAll(): void;
2517}
2518interface R2Error extends Error {
2519 readonly name: string;
2520 readonly code: number;
2521 readonly message: string;
2522 readonly action: string;
2523 readonly stack: any;
2524}
2525interface R2ListOptions {
2526 limit?: number;
2527 prefix?: string;
2528 cursor?: string;
2529 delimiter?: string;
2530 startAfter?: string;
2531 include?: ("httpMetadata" | "customMetadata")[];
2532}
2533interface R2Bucket {
2534 head(key: string): Promise<R2Object | null>;
2535 get(
2536 key: string,
2537 options: R2GetOptions & {
2538 onlyIf: R2Conditional | Headers;
2539 },
2540 ): Promise<R2ObjectBody | R2Object | null>;
2541 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
2542 put(
2543 key: string,
2544 value:
2545 | ReadableStream
2546 | ArrayBuffer
2547 | ArrayBufferView
2548 | string
2549 | null
2550 | Blob,
2551 options?: R2PutOptions & {
2552 onlyIf: R2Conditional | Headers;
2553 },
2554 ): Promise<R2Object | null>;
2555 put(
2556 key: string,
2557 value:
2558 | ReadableStream
2559 | ArrayBuffer
2560 | ArrayBufferView
2561 | string
2562 | null
2563 | Blob,
2564 options?: R2PutOptions,
2565 ): Promise<R2Object>;
2566 createMultipartUpload(
2567 key: string,
2568 options?: R2MultipartOptions,
2569 ): Promise<R2MultipartUpload>;
2570 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
2571 delete(keys: string | string[]): Promise<void>;
2572 list(options?: R2ListOptions): Promise<R2Objects>;
2573}
2574interface R2MultipartUpload {
2575 readonly key: string;
2576 readonly uploadId: string;
2577 uploadPart(
2578 partNumber: number,
2579 value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
2580 options?: R2UploadPartOptions,
2581 ): Promise<R2UploadedPart>;
2582 abort(): Promise<void>;
2583 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
2584}
2585interface R2UploadedPart {
2586 partNumber: number;
2587 etag: string;
2588}
2589declare abstract class R2Object {
2590 readonly key: string;
2591 readonly version: string;
2592 readonly size: number;
2593 readonly etag: string;
2594 readonly httpEtag: string;
2595 readonly checksums: R2Checksums;
2596 readonly uploaded: Date;
2597 readonly httpMetadata?: R2HTTPMetadata;
2598 readonly customMetadata?: Record<string, string>;
2599 readonly range?: R2Range;
2600 readonly storageClass: string;
2601 readonly ssecKeyMd5?: string;
2602 writeHttpMetadata(headers: Headers): void;
2603}
2604interface R2ObjectBody extends R2Object {
2605 get body(): ReadableStream;
2606 get bodyUsed(): boolean;
2607 arrayBuffer(): Promise<ArrayBuffer>;
2608 bytes(): Promise<Uint8Array>;
2609 text(): Promise<string>;
2610 json<T>(): Promise<T>;
2611 blob(): Promise<Blob>;
2612}
2613type R2Range =
2614 | {
2615 offset: number;
2616 length?: number;
2617 }
2618 | {
2619 offset?: number;
2620 length: number;
2621 }
2622 | {
2623 suffix: number;
2624 };
2625interface R2Conditional {
2626 etagMatches?: string;
2627 etagDoesNotMatch?: string;
2628 uploadedBefore?: Date;
2629 uploadedAfter?: Date;
2630 secondsGranularity?: boolean;
2631}
2632interface R2GetOptions {
2633 onlyIf?: R2Conditional | Headers;
2634 range?: R2Range | Headers;
2635 ssecKey?: ArrayBuffer | string;
2636}
2637interface R2PutOptions {
2638 onlyIf?: R2Conditional | Headers;
2639 httpMetadata?: R2HTTPMetadata | Headers;
2640 customMetadata?: Record<string, string>;
2641 md5?: (ArrayBuffer | ArrayBufferView) | string;
2642 sha1?: (ArrayBuffer | ArrayBufferView) | string;
2643 sha256?: (ArrayBuffer | ArrayBufferView) | string;
2644 sha384?: (ArrayBuffer | ArrayBufferView) | string;
2645 sha512?: (ArrayBuffer | ArrayBufferView) | string;
2646 storageClass?: string;
2647 ssecKey?: ArrayBuffer | string;
2648}
2649interface R2MultipartOptions {
2650 httpMetadata?: R2HTTPMetadata | Headers;
2651 customMetadata?: Record<string, string>;
2652 storageClass?: string;
2653 ssecKey?: ArrayBuffer | string;
2654}
2655interface R2Checksums {
2656 readonly md5?: ArrayBuffer;
2657 readonly sha1?: ArrayBuffer;
2658 readonly sha256?: ArrayBuffer;
2659 readonly sha384?: ArrayBuffer;
2660 readonly sha512?: ArrayBuffer;
2661 toJSON(): R2StringChecksums;
2662}
2663interface R2StringChecksums {
2664 md5?: string;
2665 sha1?: string;
2666 sha256?: string;
2667 sha384?: string;
2668 sha512?: string;
2669}
2670interface R2HTTPMetadata {
2671 contentType?: string;
2672 contentLanguage?: string;
2673 contentDisposition?: string;
2674 contentEncoding?: string;
2675 cacheControl?: string;
2676 cacheExpiry?: Date;
2677}
2678type R2Objects = {
2679 objects: R2Object[];
2680 delimitedPrefixes: string[];
2681} & (
2682 | {
2683 truncated: true;
2684 cursor: string;
2685 }
2686 | {
2687 truncated: false;
2688 }
2689);
2690interface R2UploadPartOptions {
2691 ssecKey?: ArrayBuffer | string;
2692}
2693declare abstract class JsRpcPromise {
2694 then(handler: Function, errorHandler?: Function): any;
2695 catch(errorHandler: Function): any;
2696 finally(onFinally: Function): any;
2697}
2698declare abstract class JsRpcProperty {
2699 then(handler: Function, errorHandler?: Function): any;
2700 catch(errorHandler: Function): any;
2701 finally(onFinally: Function): any;
2702}
2703declare abstract class ScheduledEvent extends ExtendableEvent {
2704 readonly scheduledTime: number;
2705 readonly cron: string;
2706 noRetry(): void;
2707}
2708interface ScheduledController {
2709 readonly scheduledTime: number;
2710 readonly cron: string;
2711 noRetry(): void;
2712}
2713interface QueuingStrategy<T = any> {
2714 highWaterMark?: number | bigint;
2715 size?: (chunk: T) => number | bigint;
2716}
2717interface UnderlyingSink<W = any> {
2718 type?: string;
2719 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2720 write?: (
2721 chunk: W,
2722 controller: WritableStreamDefaultController,
2723 ) => void | Promise<void>;
2724 abort?: (reason: any) => void | Promise<void>;
2725 close?: () => void | Promise<void>;
2726}
2727interface UnderlyingByteSource {
2728 type: "bytes";
2729 autoAllocateChunkSize?: number;
2730 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2731 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2732 cancel?: (reason: any) => void | Promise<void>;
2733}
2734interface UnderlyingSource<R = any> {
2735 type?: "" | undefined;
2736 start?: (
2737 controller: ReadableStreamDefaultController<R>,
2738 ) => void | Promise<void>;
2739 pull?: (
2740 controller: ReadableStreamDefaultController<R>,
2741 ) => void | Promise<void>;
2742 cancel?: (reason: any) => void | Promise<void>;
2743 expectedLength?: number | bigint;
2744}
2745interface Transformer<I = any, O = any> {
2746 readableType?: string;
2747 writableType?: string;
2748 start?: (
2749 controller: TransformStreamDefaultController<O>,
2750 ) => void | Promise<void>;
2751 transform?: (
2752 chunk: I,
2753 controller: TransformStreamDefaultController<O>,
2754 ) => void | Promise<void>;
2755 flush?: (
2756 controller: TransformStreamDefaultController<O>,
2757 ) => void | Promise<void>;
2758 cancel?: (reason: any) => void | Promise<void>;
2759 expectedLength?: number;
2760}
2761interface StreamPipeOptions {
2762 preventAbort?: boolean;
2763 preventCancel?: boolean;
2764 /**
2765 * 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.
2766 *
2767 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2768 *
2769 * Errors and closures of the source and destination streams propagate as follows:
2770 *
2771 * 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.
2772 *
2773 * 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.
2774 *
2775 * 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.
2776 *
2777 * 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.
2778 *
2779 * 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.
2780 */
2781 preventClose?: boolean;
2782 signal?: AbortSignal;
2783}
2784type ReadableStreamReadResult<R = any> =
2785 | {
2786 done: false;
2787 value: R;
2788 }
2789 | {
2790 done: true;
2791 value?: undefined;
2792 };
2793/**
2794 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2795 *
2796 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2797 */
2798interface ReadableStream<R = any> {
2799 /**
2800 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2801 *
2802 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2803 */
2804 get locked(): boolean;
2805 /**
2806 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2807 *
2808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2809 */
2810 cancel(reason?: any): Promise<void>;
2811 /**
2812 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2813 *
2814 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2815 */
2816 getReader(): ReadableStreamDefaultReader<R>;
2817 /**
2818 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2819 *
2820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2821 */
2822 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2823 /**
2824 * 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.
2825 *
2826 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2827 */
2828 pipeThrough<T>(
2829 transform: ReadableWritablePair<T, R>,
2830 options?: StreamPipeOptions,
2831 ): ReadableStream<T>;
2832 /**
2833 * 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.
2834 *
2835 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2836 */
2837 pipeTo(
2838 destination: WritableStream<R>,
2839 options?: StreamPipeOptions,
2840 ): Promise<void>;
2841 /**
2842 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2843 *
2844 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2845 */
2846 tee(): [ReadableStream<R>, ReadableStream<R>];
2847 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2848 [Symbol.asyncIterator](
2849 options?: ReadableStreamValuesOptions,
2850 ): AsyncIterableIterator<R>;
2851}
2852/**
2853 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2854 *
2855 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2856 */
2857declare const ReadableStream: {
2858 prototype: ReadableStream;
2859 new (
2860 underlyingSource: UnderlyingByteSource,
2861 strategy?: QueuingStrategy<Uint8Array>,
2862 ): ReadableStream<Uint8Array>;
2863 new <R = any>(
2864 underlyingSource?: UnderlyingSource<R>,
2865 strategy?: QueuingStrategy<R>,
2866 ): ReadableStream<R>;
2867};
2868/**
2869 * 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).
2870 *
2871 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2872 */
2873declare class ReadableStreamDefaultReader<R = any> {
2874 constructor(stream: ReadableStream);
2875 get closed(): Promise<void>;
2876 cancel(reason?: any): Promise<void>;
2877 /**
2878 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2879 *
2880 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2881 */
2882 read(): Promise<ReadableStreamReadResult<R>>;
2883 /**
2884 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2885 *
2886 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2887 */
2888 releaseLock(): void;
2889}
2890/**
2891 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2892 *
2893 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2894 */
2895declare class ReadableStreamBYOBReader {
2896 constructor(stream: ReadableStream);
2897 get closed(): Promise<void>;
2898 cancel(reason?: any): Promise<void>;
2899 /**
2900 * 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.
2901 *
2902 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2903 */
2904 read<T extends ArrayBufferView>(
2905 view: T,
2906 ): Promise<ReadableStreamReadResult<T>>;
2907 /**
2908 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2909 *
2910 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2911 */
2912 releaseLock(): void;
2913 readAtLeast<T extends ArrayBufferView>(
2914 minElements: number,
2915 view: T,
2916 ): Promise<ReadableStreamReadResult<T>>;
2917}
2918interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2919 min?: number;
2920}
2921interface ReadableStreamGetReaderOptions {
2922 /**
2923 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2924 *
2925 * 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.
2926 */
2927 mode: "byob";
2928}
2929/**
2930 * 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).
2931 *
2932 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2933 */
2934declare abstract class ReadableStreamBYOBRequest {
2935 /**
2936 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2937 *
2938 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2939 */
2940 get view(): Uint8Array | null;
2941 /**
2942 * 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.
2943 *
2944 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2945 */
2946 respond(bytesWritten: number): void;
2947 /**
2948 * 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.
2949 *
2950 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2951 */
2952 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2953 get atLeast(): number | null;
2954}
2955/**
2956 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2957 *
2958 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2959 */
2960declare abstract class ReadableStreamDefaultController<R = any> {
2961 /**
2962 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2963 *
2964 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2965 */
2966 get desiredSize(): number | null;
2967 /**
2968 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2969 *
2970 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2971 */
2972 close(): void;
2973 /**
2974 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2975 *
2976 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2977 */
2978 enqueue(chunk?: R): void;
2979 /**
2980 * The **`error()`** method of the with the associated stream to error.
2981 *
2982 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2983 */
2984 error(reason: any): void;
2985}
2986/**
2987 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2988 *
2989 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2990 */
2991declare abstract class ReadableByteStreamController {
2992 /**
2993 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2994 *
2995 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2996 */
2997 get byobRequest(): ReadableStreamBYOBRequest | null;
2998 /**
2999 * 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'.
3000 *
3001 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
3002 */
3003 get desiredSize(): number | null;
3004 /**
3005 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
3006 *
3007 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
3008 */
3009 close(): void;
3010 /**
3011 * 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).
3012 *
3013 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
3014 */
3015 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
3016 /**
3017 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
3018 *
3019 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
3020 */
3021 error(reason: any): void;
3022}
3023/**
3024 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
3025 *
3026 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
3027 */
3028declare abstract class WritableStreamDefaultController {
3029 /**
3030 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
3031 *
3032 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
3033 */
3034 get signal(): AbortSignal;
3035 /**
3036 * The **`error()`** method of the with the associated stream to error.
3037 *
3038 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
3039 */
3040 error(reason?: any): void;
3041}
3042/**
3043 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
3044 *
3045 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
3046 */
3047declare abstract class TransformStreamDefaultController<O = any> {
3048 /**
3049 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
3050 *
3051 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
3052 */
3053 get desiredSize(): number | null;
3054 /**
3055 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
3056 *
3057 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
3058 */
3059 enqueue(chunk?: O): void;
3060 /**
3061 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
3062 *
3063 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
3064 */
3065 error(reason: any): void;
3066 /**
3067 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
3068 *
3069 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
3070 */
3071 terminate(): void;
3072}
3073interface ReadableWritablePair<R = any, W = any> {
3074 readable: ReadableStream<R>;
3075 /**
3076 * 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.
3077 *
3078 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
3079 */
3080 writable: WritableStream<W>;
3081}
3082/**
3083 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
3084 *
3085 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
3086 */
3087declare class WritableStream<W = any> {
3088 constructor(
3089 underlyingSink?: UnderlyingSink,
3090 queuingStrategy?: QueuingStrategy,
3091 );
3092 /**
3093 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
3094 *
3095 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
3096 */
3097 get locked(): boolean;
3098 /**
3099 * 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.
3100 *
3101 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
3102 */
3103 abort(reason?: any): Promise<void>;
3104 /**
3105 * The **`close()`** method of the WritableStream interface closes the associated stream.
3106 *
3107 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
3108 */
3109 close(): Promise<void>;
3110 /**
3111 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
3112 *
3113 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
3114 */
3115 getWriter(): WritableStreamDefaultWriter<W>;
3116}
3117/**
3118 * 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.
3119 *
3120 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
3121 */
3122declare class WritableStreamDefaultWriter<W = any> {
3123 constructor(stream: WritableStream);
3124 /**
3125 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
3126 *
3127 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
3128 */
3129 get closed(): Promise<void>;
3130 /**
3131 * 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.
3132 *
3133 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
3134 */
3135 get ready(): Promise<void>;
3136 /**
3137 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
3138 *
3139 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
3140 */
3141 get desiredSize(): number | null;
3142 /**
3143 * 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.
3144 *
3145 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
3146 */
3147 abort(reason?: any): Promise<void>;
3148 /**
3149 * The **`close()`** method of the stream.
3150 *
3151 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
3152 */
3153 close(): Promise<void>;
3154 /**
3155 * The **`write()`** method of the operation.
3156 *
3157 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
3158 */
3159 write(chunk?: W): Promise<void>;
3160 /**
3161 * The **`releaseLock()`** method of the corresponding stream.
3162 *
3163 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
3164 */
3165 releaseLock(): void;
3166}
3167/**
3168 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
3169 *
3170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
3171 */
3172declare class TransformStream<I = any, O = any> {
3173 constructor(
3174 transformer?: Transformer<I, O>,
3175 writableStrategy?: QueuingStrategy<I>,
3176 readableStrategy?: QueuingStrategy<O>,
3177 );
3178 /**
3179 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
3180 *
3181 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
3182 */
3183 get readable(): ReadableStream<O>;
3184 /**
3185 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
3186 *
3187 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
3188 */
3189 get writable(): WritableStream<I>;
3190}
3191declare class FixedLengthStream extends IdentityTransformStream {
3192 constructor(
3193 expectedLength: number | bigint,
3194 queuingStrategy?: IdentityTransformStreamQueuingStrategy,
3195 );
3196}
3197declare class IdentityTransformStream extends TransformStream<
3198 ArrayBuffer | ArrayBufferView,
3199 Uint8Array
3200> {
3201 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
3202}
3203interface IdentityTransformStreamQueuingStrategy {
3204 highWaterMark?: number | bigint;
3205}
3206interface ReadableStreamValuesOptions {
3207 preventCancel?: boolean;
3208}
3209/**
3210 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
3211 *
3212 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
3213 */
3214declare class CompressionStream extends TransformStream<
3215 ArrayBuffer | ArrayBufferView,
3216 Uint8Array
3217> {
3218 constructor(format: "gzip" | "deflate" | "deflate-raw");
3219}
3220/**
3221 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
3222 *
3223 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
3224 */
3225declare class DecompressionStream extends TransformStream<
3226 ArrayBuffer | ArrayBufferView,
3227 Uint8Array
3228> {
3229 constructor(format: "gzip" | "deflate" | "deflate-raw");
3230}
3231/**
3232 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
3233 *
3234 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
3235 */
3236declare class TextEncoderStream extends TransformStream<string, Uint8Array> {
3237 constructor();
3238 get encoding(): string;
3239}
3240/**
3241 * 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.
3242 *
3243 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
3244 */
3245declare class TextDecoderStream extends TransformStream<
3246 ArrayBuffer | ArrayBufferView,
3247 string
3248> {
3249 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
3250 get encoding(): string;
3251 get fatal(): boolean;
3252 get ignoreBOM(): boolean;
3253}
3254interface TextDecoderStreamTextDecoderStreamInit {
3255 fatal?: boolean;
3256 ignoreBOM?: boolean;
3257}
3258/**
3259 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
3260 *
3261 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
3262 */
3263declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
3264 constructor(init: QueuingStrategyInit);
3265 /**
3266 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
3267 *
3268 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
3269 */
3270 get highWaterMark(): number;
3271 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
3272 get size(): (chunk?: any) => number;
3273}
3274/**
3275 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
3276 *
3277 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
3278 */
3279declare class CountQueuingStrategy implements QueuingStrategy {
3280 constructor(init: QueuingStrategyInit);
3281 /**
3282 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
3283 *
3284 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
3285 */
3286 get highWaterMark(): number;
3287 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
3288 get size(): (chunk?: any) => number;
3289}
3290interface QueuingStrategyInit {
3291 /**
3292 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
3293 *
3294 * 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.
3295 */
3296 highWaterMark: number;
3297}
3298interface TracePreviewInfo {
3299 id: string;
3300 slug: string;
3301 name: string;
3302}
3303interface ScriptVersion {
3304 id?: string;
3305 tag?: string;
3306 message?: string;
3307}
3308declare abstract class TailEvent extends ExtendableEvent {
3309 readonly events: TraceItem[];
3310 readonly traces: TraceItem[];
3311}
3312interface TraceItem {
3313 readonly event:
3314 | (
3315 | TraceItemFetchEventInfo
3316 | TraceItemJsRpcEventInfo
3317 | TraceItemConnectEventInfo
3318 | TraceItemScheduledEventInfo
3319 | TraceItemAlarmEventInfo
3320 | TraceItemQueueEventInfo
3321 | TraceItemEmailEventInfo
3322 | TraceItemTailEventInfo
3323 | TraceItemCustomEventInfo
3324 | TraceItemHibernatableWebSocketEventInfo
3325 )
3326 | null;
3327 readonly eventTimestamp: number | null;
3328 readonly logs: TraceLog[];
3329 readonly exceptions: TraceException[];
3330 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
3331 readonly scriptName: string | null;
3332 readonly entrypoint?: string;
3333 readonly scriptVersion?: ScriptVersion;
3334 readonly dispatchNamespace?: string;
3335 readonly scriptTags?: string[];
3336 readonly tailAttributes?: Record<string, boolean | number | string>;
3337 readonly preview?: TracePreviewInfo;
3338 readonly durableObjectId?: string;
3339 readonly outcome: string;
3340 readonly executionModel: string;
3341 readonly truncated: boolean;
3342 readonly cpuTime: number;
3343 readonly wallTime: number;
3344}
3345interface TraceItemAlarmEventInfo {
3346 readonly scheduledTime: Date;
3347}
3348interface TraceItemConnectEventInfo {}
3349interface TraceItemCustomEventInfo {}
3350interface TraceItemScheduledEventInfo {
3351 readonly scheduledTime: number;
3352 readonly cron: string;
3353}
3354interface TraceItemQueueEventInfo {
3355 readonly queue: string;
3356 readonly batchSize: number;
3357}
3358interface TraceItemEmailEventInfo {
3359 readonly mailFrom: string;
3360 readonly rcptTo: string;
3361 readonly rawSize: number;
3362}
3363interface TraceItemTailEventInfo {
3364 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
3365}
3366interface TraceItemTailEventInfoTailItem {
3367 readonly scriptName: string | null;
3368}
3369interface TraceItemFetchEventInfo {
3370 readonly response?: TraceItemFetchEventInfoResponse;
3371 readonly request: TraceItemFetchEventInfoRequest;
3372}
3373interface TraceItemFetchEventInfoRequest {
3374 readonly cf?: any;
3375 readonly headers: Record<string, string>;
3376 readonly method: string;
3377 readonly url: string;
3378 getUnredacted(): TraceItemFetchEventInfoRequest;
3379}
3380interface TraceItemFetchEventInfoResponse {
3381 readonly status: number;
3382}
3383interface TraceItemJsRpcEventInfo {
3384 readonly rpcMethod: string;
3385}
3386interface TraceItemHibernatableWebSocketEventInfo {
3387 readonly getWebSocketEvent:
3388 | TraceItemHibernatableWebSocketEventInfoMessage
3389 | TraceItemHibernatableWebSocketEventInfoClose
3390 | TraceItemHibernatableWebSocketEventInfoError;
3391}
3392interface TraceItemHibernatableWebSocketEventInfoMessage {
3393 readonly webSocketEventType: string;
3394}
3395interface TraceItemHibernatableWebSocketEventInfoClose {
3396 readonly webSocketEventType: string;
3397 readonly code: number;
3398 readonly wasClean: boolean;
3399}
3400interface TraceItemHibernatableWebSocketEventInfoError {
3401 readonly webSocketEventType: string;
3402}
3403interface TraceLog {
3404 readonly timestamp: number;
3405 readonly level: string;
3406 readonly message: any;
3407}
3408interface TraceException {
3409 readonly timestamp: number;
3410 readonly message: string;
3411 readonly name: string;
3412 readonly stack?: string;
3413}
3414interface TraceDiagnosticChannelEvent {
3415 readonly timestamp: number;
3416 readonly channel: string;
3417 readonly message: any;
3418}
3419interface TraceMetrics {
3420 readonly cpuTime: number;
3421 readonly wallTime: number;
3422}
3423interface UnsafeTraceMetrics {
3424 fromTrace(item: TraceItem): TraceMetrics;
3425}
3426/**
3427 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
3428 *
3429 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
3430 */
3431declare class URL {
3432 constructor(url: string | URL, base?: string | URL);
3433 /**
3434 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
3435 *
3436 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
3437 */
3438 get origin(): string;
3439 /**
3440 * The **`href`** property of the URL interface is a string containing the whole URL.
3441 *
3442 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3443 */
3444 get href(): string;
3445 /**
3446 * The **`href`** property of the URL interface is a string containing the whole URL.
3447 *
3448 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3449 */
3450 set href(value: string);
3451 /**
3452 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3453 *
3454 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3455 */
3456 get protocol(): string;
3457 /**
3458 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3459 *
3460 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3461 */
3462 set protocol(value: string);
3463 /**
3464 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3465 *
3466 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3467 */
3468 get username(): string;
3469 /**
3470 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3471 *
3472 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3473 */
3474 set username(value: string);
3475 /**
3476 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3477 *
3478 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3479 */
3480 get password(): string;
3481 /**
3482 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3483 *
3484 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3485 */
3486 set password(value: string);
3487 /**
3488 * 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.
3489 *
3490 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3491 */
3492 get host(): string;
3493 /**
3494 * 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.
3495 *
3496 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3497 */
3498 set host(value: string);
3499 /**
3500 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3501 *
3502 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3503 */
3504 get hostname(): string;
3505 /**
3506 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3507 *
3508 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3509 */
3510 set hostname(value: string);
3511 /**
3512 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3513 *
3514 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3515 */
3516 get port(): string;
3517 /**
3518 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3519 *
3520 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3521 */
3522 set port(value: string);
3523 /**
3524 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3525 *
3526 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3527 */
3528 get pathname(): string;
3529 /**
3530 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3531 *
3532 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3533 */
3534 set pathname(value: string);
3535 /**
3536 * 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.
3537 *
3538 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3539 */
3540 get search(): string;
3541 /**
3542 * 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.
3543 *
3544 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3545 */
3546 set search(value: string);
3547 /**
3548 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3549 *
3550 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3551 */
3552 get hash(): string;
3553 /**
3554 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3555 *
3556 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3557 */
3558 set hash(value: string);
3559 /**
3560 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
3561 *
3562 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
3563 */
3564 get searchParams(): URLSearchParams;
3565 /**
3566 * 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.
3567 *
3568 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
3569 */
3570 toJSON(): string;
3571 /*function toString() { [native code] }*/
3572 toString(): string;
3573 /**
3574 * 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.
3575 *
3576 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
3577 */
3578 static canParse(url: string, base?: string): boolean;
3579 /**
3580 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
3581 *
3582 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
3583 */
3584 static parse(url: string, base?: string): URL | null;
3585 /**
3586 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
3587 *
3588 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
3589 */
3590 static createObjectURL(object: File | Blob): string;
3591 /**
3592 * 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.
3593 *
3594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
3595 */
3596 static revokeObjectURL(object_url: string): void;
3597}
3598/**
3599 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
3600 *
3601 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
3602 */
3603declare class URLSearchParams {
3604 constructor(
3605 init?: Iterable<Iterable<string>> | Record<string, string> | string,
3606 );
3607 /**
3608 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
3609 *
3610 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
3611 */
3612 get size(): number;
3613 /**
3614 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
3615 *
3616 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
3617 */
3618 append(name: string, value: string): void;
3619 /**
3620 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
3621 *
3622 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
3623 */
3624 delete(name: string, value?: string): void;
3625 /**
3626 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
3627 *
3628 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
3629 */
3630 get(name: string): string | null;
3631 /**
3632 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
3633 *
3634 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
3635 */
3636 getAll(name: string): string[];
3637 /**
3638 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
3639 *
3640 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
3641 */
3642 has(name: string, value?: string): boolean;
3643 /**
3644 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
3645 *
3646 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
3647 */
3648 set(name: string, value: string): void;
3649 /**
3650 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
3651 *
3652 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
3653 */
3654 sort(): void;
3655 /* Returns an array of key, value pairs for every entry in the search params. */
3656 entries(): IterableIterator<[key: string, value: string]>;
3657 /* Returns a list of keys in the search params. */
3658 keys(): IterableIterator<string>;
3659 /* Returns a list of values in the search params. */
3660 values(): IterableIterator<string>;
3661 forEach<This = unknown>(
3662 callback: (
3663 this: This,
3664 value: string,
3665 key: string,
3666 parent: URLSearchParams,
3667 ) => void,
3668 thisArg?: This,
3669 ): void;
3670 /*function toString() { [native code] }*/
3671 toString(): string;
3672 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
3673}
3674declare class URLPattern {
3675 constructor(
3676 input?: string | URLPatternInit,
3677 baseURL?: string | URLPatternOptions,
3678 patternOptions?: URLPatternOptions,
3679 );
3680 get protocol(): string;
3681 get username(): string;
3682 get password(): string;
3683 get hostname(): string;
3684 get port(): string;
3685 get pathname(): string;
3686 get search(): string;
3687 get hash(): string;
3688 get hasRegExpGroups(): boolean;
3689 test(input?: string | URLPatternInit, baseURL?: string): boolean;
3690 exec(
3691 input?: string | URLPatternInit,
3692 baseURL?: string,
3693 ): URLPatternResult | null;
3694}
3695interface URLPatternInit {
3696 protocol?: string;
3697 username?: string;
3698 password?: string;
3699 hostname?: string;
3700 port?: string;
3701 pathname?: string;
3702 search?: string;
3703 hash?: string;
3704 baseURL?: string;
3705}
3706interface URLPatternComponentResult {
3707 input: string;
3708 groups: Record<string, string>;
3709}
3710interface URLPatternResult {
3711 inputs: (string | URLPatternInit)[];
3712 protocol: URLPatternComponentResult;
3713 username: URLPatternComponentResult;
3714 password: URLPatternComponentResult;
3715 hostname: URLPatternComponentResult;
3716 port: URLPatternComponentResult;
3717 pathname: URLPatternComponentResult;
3718 search: URLPatternComponentResult;
3719 hash: URLPatternComponentResult;
3720}
3721interface URLPatternOptions {
3722 ignoreCase?: boolean;
3723}
3724/**
3725 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3726 *
3727 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3728 */
3729declare class CloseEvent extends Event {
3730 constructor(type: string, initializer?: CloseEventInit);
3731 /**
3732 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3733 *
3734 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3735 */
3736 readonly code: number;
3737 /**
3738 * 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.
3739 *
3740 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3741 */
3742 readonly reason: string;
3743 /**
3744 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3745 *
3746 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3747 */
3748 readonly wasClean: boolean;
3749}
3750interface CloseEventInit {
3751 code?: number;
3752 reason?: string;
3753 wasClean?: boolean;
3754}
3755type WebSocketEventMap = {
3756 close: CloseEvent;
3757 message: MessageEvent;
3758 open: Event;
3759 error: ErrorEvent;
3760};
3761/**
3762 * 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.
3763 *
3764 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3765 */
3766declare var WebSocket: {
3767 prototype: WebSocket;
3768 new (url: string, protocols?: string[] | string): WebSocket;
3769 readonly READY_STATE_CONNECTING: number;
3770 readonly CONNECTING: number;
3771 readonly READY_STATE_OPEN: number;
3772 readonly OPEN: number;
3773 readonly READY_STATE_CLOSING: number;
3774 readonly CLOSING: number;
3775 readonly READY_STATE_CLOSED: number;
3776 readonly CLOSED: number;
3777};
3778/**
3779 * 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.
3780 *
3781 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3782 */
3783interface WebSocket extends EventTarget<WebSocketEventMap> {
3784 accept(options?: WebSocketAcceptOptions): void;
3785 /**
3786 * 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.
3787 *
3788 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3789 */
3790 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3791 /**
3792 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3793 *
3794 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3795 */
3796 close(code?: number, reason?: string): void;
3797 serializeAttachment(attachment: any): void;
3798 deserializeAttachment(): any | null;
3799 /**
3800 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3801 *
3802 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3803 */
3804 readyState: number;
3805 /**
3806 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3807 *
3808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3809 */
3810 url: string | null;
3811 /**
3812 * 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.
3813 *
3814 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3815 */
3816 protocol: string | null;
3817 /**
3818 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3819 *
3820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3821 */
3822 extensions: string | null;
3823 /**
3824 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3825 *
3826 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3827 */
3828 binaryType: "blob" | "arraybuffer";
3829}
3830interface WebSocketAcceptOptions {
3831 /**
3832 * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3833 * automatically send a reciprocal Close frame, leaving the connection in a half-open
3834 * state. This is useful for proxying scenarios where you need to coordinate closing
3835 * both sides independently. Defaults to `false` when the
3836 * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3837 */
3838 allowHalfOpen?: boolean;
3839}
3840declare const WebSocketPair: {
3841 new (): {
3842 0: WebSocket;
3843 1: WebSocket;
3844 };
3845};
3846interface SqlStorage {
3847 exec<T extends Record<string, SqlStorageValue>>(
3848 query: string,
3849 ...bindings: any[]
3850 ): SqlStorageCursor<T>;
3851 prepare(query: string): SqlStorageStatement;
3852 ingest(query: string): SqlStorageIngestResult;
3853 setMaxPageCountForTest(count: number): void;
3854 get databaseSize(): number;
3855 Cursor: typeof SqlStorageCursor;
3856 Statement: typeof SqlStorageStatement;
3857}
3858declare abstract class SqlStorageStatement {}
3859type SqlStorageValue = ArrayBuffer | string | number | null;
3860declare abstract class SqlStorageCursor<
3861 T extends Record<string, SqlStorageValue>,
3862> {
3863 next():
3864 | {
3865 done?: false;
3866 value: T;
3867 }
3868 | {
3869 done: true;
3870 value?: never;
3871 };
3872 toArray(): T[];
3873 one(): T;
3874 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3875 columnNames: string[];
3876 get rowsRead(): number;
3877 get rowsWritten(): number;
3878 get reusedCachedQueryForTest(): boolean;
3879 [Symbol.iterator](): IterableIterator<T>;
3880}
3881interface SqlStorageIngestResult {
3882 remainder: string;
3883 rowsRead: number;
3884 rowsWritten: number;
3885 statementCount: number;
3886}
3887interface Socket {
3888 get readable(): ReadableStream;
3889 get writable(): WritableStream;
3890 get closed(): Promise<void>;
3891 get opened(): Promise<SocketInfo>;
3892 get upgraded(): boolean;
3893 get secureTransport(): "on" | "off" | "starttls";
3894 close(): Promise<void>;
3895 startTls(options?: TlsOptions): Socket;
3896}
3897interface SocketOptions {
3898 secureTransport?: string;
3899 allowHalfOpen: boolean;
3900 highWaterMark?: number | bigint;
3901}
3902interface SocketAddress {
3903 hostname: string;
3904 port: number;
3905}
3906interface TlsOptions {
3907 expectedServerHostname?: string;
3908}
3909interface SocketInfo {
3910 remoteAddress?: string;
3911 localAddress?: string;
3912}
3913/**
3914 * The **`EventSource`** interface is web content's interface to server-sent events.
3915 *
3916 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3917 */
3918declare class EventSource extends EventTarget {
3919 constructor(url: string, init?: EventSourceEventSourceInit);
3920 /**
3921 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3922 *
3923 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3924 */
3925 close(): void;
3926 /**
3927 * The **`url`** read-only property of the URL of the source.
3928 *
3929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3930 */
3931 get url(): string;
3932 /**
3933 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3934 *
3935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3936 */
3937 get withCredentials(): boolean;
3938 /**
3939 * The **`readyState`** read-only property of the connection.
3940 *
3941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3942 */
3943 get readyState(): number;
3944 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3945 get onopen(): any | null;
3946 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3947 set onopen(value: any | null);
3948 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3949 get onmessage(): any | null;
3950 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3951 set onmessage(value: any | null);
3952 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3953 get onerror(): any | null;
3954 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3955 set onerror(value: any | null);
3956 static readonly CONNECTING: number;
3957 static readonly OPEN: number;
3958 static readonly CLOSED: number;
3959 static from(stream: ReadableStream): EventSource;
3960}
3961interface EventSourceEventSourceInit {
3962 withCredentials?: boolean;
3963 fetcher?: Fetcher;
3964}
3965interface ExecOutput {
3966 readonly stdout: ArrayBuffer;
3967 readonly stderr: ArrayBuffer;
3968 readonly exitCode: number;
3969}
3970interface ContainerExecOptions {
3971 cwd?: string;
3972 env?: Record<string, string>;
3973 user?: string;
3974 stdin?: ReadableStream | "pipe";
3975 stdout?: "pipe" | "ignore";
3976 stderr?: "pipe" | "ignore" | "combined";
3977}
3978interface ExecProcess {
3979 readonly stdin: WritableStream | null;
3980 readonly stdout: ReadableStream | null;
3981 readonly stderr: ReadableStream | null;
3982 readonly pid: number;
3983 readonly exitCode: Promise<number>;
3984 output(): Promise<ExecOutput>;
3985 kill(signal?: number): void;
3986}
3987interface Container {
3988 get running(): boolean;
3989 start(options?: ContainerStartupOptions): void;
3990 monitor(): Promise<void>;
3991 destroy(error?: any): Promise<void>;
3992 signal(signo: number): void;
3993 getTcpPort(port: number): Fetcher;
3994 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
3995 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
3996 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
3997 snapshotDirectory(
3998 options: ContainerDirectorySnapshotOptions,
3999 ): Promise<ContainerDirectorySnapshot>;
4000 snapshotContainer(
4001 options: ContainerSnapshotOptions,
4002 ): Promise<ContainerSnapshot>;
4003 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
4004 exec(cmd: string[], options?: ContainerExecOptions): Promise<ExecProcess>;
4005 interceptOutboundTcp(addr: string, binding: Fetcher): Promise<void>;
4006 inspect(): Promise<ContainerInfo | null>;
4007}
4008interface ContainerDirectorySnapshot {
4009 id: string;
4010 size: number;
4011 dir: string;
4012 name?: string;
4013}
4014interface ContainerDirectorySnapshotOptions {
4015 dir: string;
4016 name?: string;
4017}
4018interface ContainerDirectorySnapshotRestoreParams {
4019 snapshot: ContainerDirectorySnapshot;
4020 mountPoint?: string;
4021}
4022interface ContainerSnapshot {
4023 id: string;
4024 size: number;
4025 name?: string;
4026}
4027interface ContainerSnapshotOptions {
4028 name?: string;
4029}
4030interface ContainerStartupOptions {
4031 entrypoint?: string[];
4032 enableInternet: boolean;
4033 env?: Record<string, string>;
4034 hardTimeout?: number | bigint;
4035 labels?: Record<string, string>;
4036 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
4037 containerSnapshot?: ContainerSnapshot;
4038}
4039interface ContainerInfo {
4040 labels: Record<string, string>;
4041}
4042/**
4043 * The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
4044 * Available only in secure contexts.
4045 *
4046 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle)
4047 */
4048declare abstract class FileSystemHandle {
4049 /**
4050 * The **`kind`** read-only property of the `'file'` if the associated entry is a file or `'directory'`.
4051 *
4052 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind)
4053 */
4054 get kind(): string;
4055 /**
4056 * The **`name`** read-only property of the handle.
4057 *
4058 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/name)
4059 */
4060 get name(): string;
4061 /**
4062 * The **`isSameEntry()`** method of the ```js-nolint isSameEntry(fileSystemHandle) ``` - FileSystemHandle - : The `FileSystemHandle` to match against the handle on which the method is invoked.
4063 *
4064 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/isSameEntry)
4065 */
4066 isSameEntry(other: FileSystemHandle): Promise<boolean>;
4067 getUniqueId(): Promise<string>;
4068 remove(options?: FileSystemHandleRemoveOptions): Promise<void>;
4069}
4070/**
4071 * The **`FileSystemFileHandle`** interface of the File System API represents a handle to a file system entry.
4072 * Available only in secure contexts.
4073 *
4074 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle)
4075 */
4076declare abstract class FileSystemFileHandle extends FileSystemHandle {
4077 /**
4078 * The **`getFile()`** method of the If the file on disk changes or is removed after this method is called, the returned ```js-nolint getFile() ``` None.
4079 *
4080 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile)
4081 */
4082 getFile(): Promise<File>;
4083 /**
4084 * The **`createWritable()`** method of the FileSystemFileHandle interface creates a FileSystemWritableFileStream that can be used to write to a file.
4085 *
4086 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable)
4087 */
4088 createWritable(
4089 options?: FileSystemFileHandleFileSystemCreateWritableOptions,
4090 ): Promise<FileSystemWritableFileStream>;
4091}
4092/**
4093 * The **`FileSystemDirectoryHandle`** interface of the File System API provides a handle to a file system directory.
4094 * Available only in secure contexts.
4095 *
4096 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle)
4097 */
4098declare abstract class FileSystemDirectoryHandle extends FileSystemHandle {
4099 /**
4100 * The **`getFileHandle()`** method of the directory the method is called.
4101 *
4102 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getFileHandle)
4103 */
4104 getFileHandle(
4105 name: string,
4106 options?: FileSystemDirectoryHandleFileSystemGetFileOptions,
4107 ): Promise<FileSystemFileHandle>;
4108 /**
4109 * The **`getDirectoryHandle()`** method of the within the directory handle on which the method is called.
4110 *
4111 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle)
4112 */
4113 getDirectoryHandle(
4114 name: string,
4115 options?: FileSystemDirectoryHandleFileSystemGetDirectoryOptions,
4116 ): Promise<FileSystemDirectoryHandle>;
4117 /**
4118 * The **`removeEntry()`** method of the directory handle contains a file or directory called the name specified.
4119 *
4120 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/removeEntry)
4121 */
4122 removeEntry(
4123 name: string,
4124 options?: FileSystemDirectoryHandleFileSystemRemoveOptions,
4125 ): Promise<void>;
4126 /**
4127 * The **`resolve()`** method of the directory names from the parent handle to the specified child entry, with the name of the child entry as the last array item.
4128 *
4129 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/resolve)
4130 */
4131 resolve(possibleDescendant: FileSystemHandle): Promise<string[]>;
4132 entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
4133 keys(): AsyncIterableIterator<string>;
4134 values(): AsyncIterableIterator<FileSystemHandle>;
4135 forEach(
4136 callback: (
4137 param0: string,
4138 param1: FileSystemHandle,
4139 param2: FileSystemDirectoryHandle,
4140 ) => void,
4141 thisArg?: any,
4142 ): void;
4143 [Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
4144}
4145/**
4146 * The **`FileSystemWritableFileStream`** interface of the File System API is a WritableStream object with additional convenience methods, which operates on a single file on disk.
4147 * Available only in secure contexts.
4148 *
4149 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream)
4150 */
4151declare abstract class FileSystemWritableFileStream extends WritableStream {
4152 /**
4153 * The **`write()`** method of the FileSystemWritableFileStream interface writes content into the file the method is called on, at the current file cursor offset.
4154 *
4155 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/write)
4156 */
4157 write(
4158 data:
4159 | Blob
4160 | (ArrayBuffer | ArrayBufferView)
4161 | string
4162 | FileSystemFileWriteParams,
4163 ): Promise<void>;
4164 /**
4165 * The **`seek()`** method of the FileSystemWritableFileStream interface updates the current file cursor offset to the position (in bytes) specified when calling the method.
4166 *
4167 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/seek)
4168 */
4169 seek(position: number): Promise<void>;
4170 /**
4171 * The **`truncate()`** method of the FileSystemWritableFileStream interface resizes the file associated with the stream to the specified size in bytes.
4172 *
4173 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/truncate)
4174 */
4175 truncate(size: number): Promise<void>;
4176}
4177/**
4178 * The **`StorageManager`** interface of the Storage API provides an interface for managing persistence permissions and estimating available storage.
4179 * Available only in secure contexts.
4180 *
4181 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/StorageManager)
4182 */
4183declare abstract class StorageManager {
4184 /**
4185 * The **`getDirectory()`** method of the StorageManager interface is used to obtain a reference to a FileSystemDirectoryHandle object allowing access to a directory and its contents, stored in the origin private file system (OPFS).
4186 *
4187 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/StorageManager/getDirectory)
4188 */
4189 getDirectory(): Promise<FileSystemDirectoryHandle>;
4190}
4191interface FileSystemFileHandleFileSystemCreateWritableOptions {
4192 keepExistingData?: boolean;
4193}
4194interface FileSystemDirectoryHandleFileSystemGetFileOptions {
4195 create: boolean;
4196}
4197interface FileSystemDirectoryHandleFileSystemGetDirectoryOptions {
4198 create: boolean;
4199}
4200interface FileSystemDirectoryHandleFileSystemRemoveOptions {
4201 recursive: boolean;
4202}
4203interface FileSystemFileWriteParams {
4204 type: string;
4205 size?: number;
4206 position?: number;
4207 data?: (Blob | (ArrayBuffer | ArrayBufferView) | string) | null;
4208}
4209interface FileSystemHandleRemoveOptions {
4210 recursive?: boolean;
4211}
4212/**
4213 * 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.
4214 *
4215 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
4216 */
4217declare abstract class MessagePort extends EventTarget {
4218 /**
4219 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
4220 *
4221 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
4222 */
4223 postMessage(
4224 data?: any,
4225 options?: any[] | MessagePortPostMessageOptions,
4226 ): void;
4227 /**
4228 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
4229 *
4230 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
4231 */
4232 close(): void;
4233 /**
4234 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
4235 *
4236 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
4237 */
4238 start(): void;
4239 get onmessage(): any | null;
4240 set onmessage(value: any | null);
4241}
4242/**
4243 * 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.
4244 *
4245 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
4246 */
4247declare class MessageChannel {
4248 constructor();
4249 /**
4250 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
4251 *
4252 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
4253 */
4254 readonly port1: MessagePort;
4255 /**
4256 * 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.
4257 *
4258 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
4259 */
4260 readonly port2: MessagePort;
4261}
4262interface MessagePortPostMessageOptions {
4263 transfer?: any[];
4264}
4265type LoopbackForExport<
4266 T extends
4267 | (new (...args: any[]) => Rpc.EntrypointBranded)
4268 | ExportedHandler<any, any, any>
4269 | undefined = undefined,
4270> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
4271 ? LoopbackServiceStub<InstanceType<T>>
4272 : T extends new (...args: any[]) => Rpc.DurableObjectBranded
4273 ? LoopbackDurableObjectClass<InstanceType<T>>
4274 : T extends ExportedHandler<any, any, any>
4275 ? LoopbackServiceStub<undefined>
4276 : undefined;
4277type LoopbackServiceStub<
4278 T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
4279> = Fetcher<T> &
4280 (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
4281 ? (opts: {
4282 props?: Props;
4283 version?: {
4284 cohort?: string | null;
4285 };
4286 }) => Fetcher<T>
4287 : (opts: {
4288 props?: any;
4289 version?: {
4290 cohort?: string | null;
4291 };
4292 }) => Fetcher<T>);
4293type LoopbackDurableObjectClass<
4294 T extends Rpc.DurableObjectBranded | undefined = undefined,
4295> = DurableObjectClass<T> &
4296 (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
4297 ? (opts: { props?: Props }) => DurableObjectClass<T>
4298 : (opts: { props?: any }) => DurableObjectClass<T>);
4299interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
4300interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
4301interface SyncKvStorage {
4302 get<T = unknown>(key: string): T | undefined;
4303 list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
4304 put<T>(key: string, value: T): void;
4305 delete(key: string): boolean;
4306}
4307interface SyncKvListOptions {
4308 start?: string;
4309 startAfter?: string;
4310 end?: string;
4311 prefix?: string;
4312 reverse?: boolean;
4313 limit?: number;
4314}
4315interface WorkerStub {
4316 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
4317 name?: string,
4318 options?: WorkerStubEntrypointOptions,
4319 ): Fetcher<T>;
4320 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
4321 name?: string,
4322 options?: WorkerStubEntrypointOptions,
4323 ): DurableObjectClass<T>;
4324}
4325interface WorkerStubEntrypointOptions {
4326 props?: any;
4327 limits?: workerdResourceLimits;
4328}
4329interface WorkerLoader {
4330 get(
4331 name: string | null,
4332 getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
4333 ): WorkerStub;
4334 load(code: WorkerLoaderWorkerCode): WorkerStub;
4335}
4336interface WorkerLoaderModule {
4337 js?: string;
4338 cjs?: string;
4339 text?: string;
4340 data?: ArrayBuffer;
4341 json?: any;
4342 py?: string;
4343 wasm?: ArrayBuffer;
4344}
4345interface WorkerLoaderWorkerCode {
4346 compatibilityDate: string;
4347 compatibilityFlags?: string[];
4348 allowExperimental?: boolean;
4349 limits?: workerdResourceLimits;
4350 mainModule: string;
4351 modules: Record<string, WorkerLoaderModule | string>;
4352 env?: any;
4353 globalOutbound?: Fetcher | null;
4354 tails?: Fetcher[];
4355 streamingTails?: Fetcher[];
4356}
4357interface workerdResourceLimits {
4358 cpuMs?: number;
4359 subRequests?: number;
4360}
4361/**
4362 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
4363 * as well as timing of subrequests and other operations.
4364 *
4365 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
4366 */
4367declare abstract class Performance extends EventTarget {
4368 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
4369 get timeOrigin(): number;
4370 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
4371 now(): number;
4372 get eventCounts(): EventCounts;
4373 /**
4374 * The **`clearMarks()`** method removes all or specific PerformanceMark objects from the browser's performance timeline.
4375 *
4376 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks)
4377 */
4378 clearMarks(name?: string): void;
4379 /**
4380 * The **`clearMeasures()`** method removes all or specific PerformanceMeasure objects from the browser's performance timeline.
4381 *
4382 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures)
4383 */
4384 clearMeasures(name?: string): void;
4385 /**
4386 * The **`clearResourceTimings()`** method removes all performance entries with an PerformanceEntry.entryType of `'resource'` from the browser's performance timeline and sets the size of the performance resource data buffer to zero.
4387 *
4388 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings)
4389 */
4390 clearResourceTimings(): void;
4391 /**
4392 * The **`getEntries()`** method returns an array of all PerformanceEntry objects currently present in the performance timeline.
4393 *
4394 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries)
4395 */
4396 getEntries(): PerformanceEntry[];
4397 /**
4398 * The **`getEntriesByName()`** method returns an array of PerformanceEntry objects currently present in the performance timeline with the given _name_ and _type_.
4399 *
4400 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName)
4401 */
4402 getEntriesByName(name: string, type?: string): PerformanceEntry[];
4403 /**
4404 * The **`getEntriesByType()`** method returns an array of PerformanceEntry objects currently present in the performance timeline for a given _type_.
4405 *
4406 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType)
4407 */
4408 getEntriesByType(type: string): PerformanceEntry[];
4409 /**
4410 * The **`mark()`** method creates a named PerformanceMark object representing a high resolution timestamp marker in the browser's performance timeline.
4411 *
4412 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark)
4413 */
4414 mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
4415 /**
4416 * The **`measure()`** method creates a named PerformanceMeasure object representing a time measurement between two marks in the browser's performance timeline.
4417 *
4418 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure)
4419 */
4420 measure(
4421 measureName: string,
4422 measureOptionsOrStartMark?: PerformanceMeasureOptions | string,
4423 maybeEndMark?: string,
4424 ): PerformanceMeasure;
4425 /**
4426 * The **`setResourceTimingBufferSize()`** method sets the desired size of the browser's resource timing buffer which stores the `'resource'` performance entries.
4427 *
4428 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize)
4429 */
4430 setResourceTimingBufferSize(size: number): void;
4431 /**
4432 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
4433 *
4434 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
4435 */
4436 toJSON(): object;
4437 get nodeTiming(): PerformanceNodeTiming;
4438 eventLoopUtilization(): PerformanceEventLoopUtilization;
4439 markResourceTiming(): void;
4440 timerify(fn: () => void): () => void;
4441}
4442interface PerformanceEventLoopUtilization {
4443 idle: number;
4444 active: number;
4445 utilization: number;
4446}
4447interface PerformanceNodeTiming extends PerformanceEntry {
4448 readonly nodeStart: number;
4449 readonly v8Start: number;
4450 readonly bootstrapComplete: number;
4451 readonly environment: number;
4452 readonly loopStart: number;
4453 readonly loopExit: number;
4454 readonly idleTime: number;
4455 readonly uvMetricsInfo: UvMetricsInfo;
4456 toJSON(): object;
4457}
4458interface UvMetricsInfo {
4459 loopCount: number;
4460 events: number;
4461 eventsWaiting: number;
4462}
4463/**
4464 * **`PerformanceMark`** is an interface for PerformanceEntry objects with an PerformanceEntry.entryType of `'mark'`.
4465 *
4466 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
4467 */
4468declare class PerformanceMark extends PerformanceEntry {
4469 constructor(name: string, maybeOptions?: PerformanceMarkOptions);
4470 /**
4471 * The read-only **`detail`** property returns arbitrary metadata that was included in the mark upon construction (either when using Performance.mark or the PerformanceMark.PerformanceMark constructor).
4472 *
4473 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail)
4474 */
4475 get detail(): any;
4476 toJSON(): object;
4477}
4478/**
4479 * **`PerformanceMeasure`** is an _abstract_ interface for PerformanceEntry objects with an PerformanceEntry.entryType of `'measure'`.
4480 *
4481 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
4482 */
4483declare abstract class PerformanceMeasure extends PerformanceEntry {
4484 /**
4485 * The read-only **`detail`** property returns arbitrary metadata that was included in the mark upon construction (when using Performance.measure.
4486 *
4487 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail)
4488 */
4489 get detail(): any;
4490 toJSON(): object;
4491}
4492interface PerformanceMarkOptions {
4493 detail?: any;
4494 startTime?: number;
4495}
4496interface PerformanceMeasureOptions {
4497 detail?: any;
4498 start?: number;
4499 duration?: number;
4500 end?: number;
4501}
4502/**
4503 * The **`PerformanceObserverEntryList`** interface is a list of PerformanceEntry that were explicitly observed via the PerformanceObserver.observe method.
4504 *
4505 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList)
4506 */
4507declare abstract class PerformanceObserverEntryList {
4508 /**
4509 * The **`getEntries()`** method of the PerformanceObserverEntryList interface returns a list of explicitly observed PerformanceEntry objects.
4510 *
4511 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntries)
4512 */
4513 getEntries(): PerformanceEntry[];
4514 /**
4515 * The **`getEntriesByType()`** method of the PerformanceObserverEntryList returns a list of explicitly _observed_ PerformanceEntry objects for a given PerformanceEntry.entryType.
4516 *
4517 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntriesByType)
4518 */
4519 getEntriesByType(type: string): PerformanceEntry[];
4520 /**
4521 * The **`getEntriesByName()`** method of the PerformanceObserverEntryList interface returns a list of explicitly observed PerformanceEntry objects for a given PerformanceEntry.name and PerformanceEntry.entryType.
4522 *
4523 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntriesByName)
4524 */
4525 getEntriesByName(name: string, type?: string): PerformanceEntry[];
4526}
4527/**
4528 * The **`PerformanceEntry`** object encapsulates a single performance metric that is part of the browser's performance timeline.
4529 *
4530 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
4531 */
4532declare abstract class PerformanceEntry {
4533 /**
4534 * The read-only **`name`** property of the PerformanceEntry interface is a string representing the name for a performance entry.
4535 *
4536 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name)
4537 */
4538 get name(): string;
4539 /**
4540 * The read-only **`entryType`** property returns a string representing the type of performance metric that this entry represents.
4541 *
4542 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType)
4543 */
4544 get entryType(): string;
4545 /**
4546 * The read-only **`startTime`** property returns the first DOMHighResTimeStamp recorded for this PerformanceEntry.
4547 *
4548 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime)
4549 */
4550 get startTime(): number;
4551 /**
4552 * The read-only **`duration`** property returns a DOMHighResTimeStamp that is the duration of the PerformanceEntry.
4553 *
4554 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration)
4555 */
4556 get duration(): number;
4557 /**
4558 * The **`toJSON()`** method is a Serialization; it returns a JSON representation of the PerformanceEntry object.
4559 *
4560 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON)
4561 */
4562 toJSON(): object;
4563}
4564/**
4565 * The **`PerformanceResourceTiming`** interface enables retrieval and analysis of detailed network timing data regarding the loading of an application's resources.
4566 *
4567 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming)
4568 */
4569declare abstract class PerformanceResourceTiming extends PerformanceEntry {
4570 /**
4571 * The **`connectEnd`** read-only property returns the DOMHighResTimeStamp immediately after the browser finishes establishing the connection to the server to retrieve the resource.
4572 *
4573 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/connectEnd)
4574 */
4575 get connectEnd(): number;
4576 /**
4577 * The **`connectStart`** read-only property returns the DOMHighResTimeStamp immediately before the user agent starts establishing the connection to the server to retrieve the resource.
4578 *
4579 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/connectStart)
4580 */
4581 get connectStart(): number;
4582 /**
4583 * The **`decodedBodySize`** read-only property returns the size (in octets) received from the fetch (HTTP or cache) of the message body after removing any applied content encoding (like gzip or Brotli).
4584 *
4585 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/decodedBodySize)
4586 */
4587 get decodedBodySize(): number;
4588 /**
4589 * The **`domainLookupEnd`** read-only property returns the DOMHighResTimeStamp immediately after the browser finishes the domain-name lookup for the resource.
4590 *
4591 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/domainLookupEnd)
4592 */
4593 get domainLookupEnd(): number;
4594 /**
4595 * The **`domainLookupStart`** read-only property returns the DOMHighResTimeStamp immediately before the browser starts the domain name lookup for the resource.
4596 *
4597 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/domainLookupStart)
4598 */
4599 get domainLookupStart(): number;
4600 /**
4601 * The **`encodedBodySize`** read-only property represents the size (in octets) received from the fetch (HTTP or cache) of the payload body before removing any applied content encodings (like gzip or Brotli).
4602 *
4603 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/encodedBodySize)
4604 */
4605 get encodedBodySize(): number;
4606 /**
4607 * The **`fetchStart`** read-only property represents a DOMHighResTimeStamp immediately before the browser starts to fetch the resource.
4608 *
4609 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/fetchStart)
4610 */
4611 get fetchStart(): number;
4612 /**
4613 * The **`initiatorType`** read-only property is a string representing web platform feature that initiated the resource load.
4614 *
4615 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/initiatorType)
4616 */
4617 get initiatorType(): string;
4618 /**
4619 * The **`nextHopProtocol`** read-only property is a string representing the network protocol used to fetch the resource, as identified by the ALPN Protocol ID (RFC7301).
4620 *
4621 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/nextHopProtocol)
4622 */
4623 get nextHopProtocol(): string;
4624 /**
4625 * The **`redirectEnd`** read-only property returns a DOMHighResTimeStamp immediately after receiving the last byte of the response of the last redirect.
4626 *
4627 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/redirectEnd)
4628 */
4629 get redirectEnd(): number;
4630 /**
4631 * The **`redirectStart`** read-only property returns a DOMHighResTimeStamp representing the start time of the fetch which that initiates the redirect.
4632 *
4633 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/redirectStart)
4634 */
4635 get redirectStart(): number;
4636 /**
4637 * The **`requestStart`** read-only property returns a DOMHighResTimeStamp of the time immediately before the browser starts requesting the resource from the server, cache, or local resource.
4638 *
4639 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/requestStart)
4640 */
4641 get requestStart(): number;
4642 /**
4643 * The **`responseEnd`** read-only property returns a DOMHighResTimeStamp immediately after the browser receives the last byte of the resource or immediately before the transport connection is closed, whichever comes first.
4644 *
4645 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseEnd)
4646 */
4647 get responseEnd(): number;
4648 /**
4649 * The **`responseStart`** read-only property returns a DOMHighResTimeStamp immediately after the browser receives the first byte of the response from the server, cache, or local resource.
4650 *
4651 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseStart)
4652 */
4653 get responseStart(): number;
4654 /**
4655 * The **`responseStatus`** read-only property represents the HTTP response status code returned when fetching the resource.
4656 *
4657 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseStatus)
4658 */
4659 get responseStatus(): number;
4660 /**
4661 * The **`secureConnectionStart`** read-only property returns a DOMHighResTimeStamp immediately before the browser starts the handshake process to secure the current connection.
4662 *
4663 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/secureConnectionStart)
4664 */
4665 get secureConnectionStart(): number | undefined;
4666 /**
4667 * The **`transferSize`** read-only property represents the size (in octets) of the fetched resource.
4668 *
4669 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/transferSize)
4670 */
4671 get transferSize(): number;
4672 /**
4673 * The **`workerStart`** read-only property of the PerformanceResourceTiming interface returns a The `workerStart` property can have the following values: - A DOMHighResTimeStamp.
4674 *
4675 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/workerStart)
4676 */
4677 get workerStart(): number;
4678}
4679/**
4680 * The **`PerformanceObserver`** interface is used to observe performance measurement events and be notified of new PerformanceEntry as they are recorded in the browser's _performance timeline_.
4681 *
4682 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver)
4683 */
4684declare class PerformanceObserver {
4685 constructor(callback: any);
4686 /**
4687 * The **`disconnect()`** method of the PerformanceObserver interface is used to stop the performance observer from receiving any PerformanceEntry events.
4688 *
4689 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/disconnect)
4690 */
4691 disconnect(): void;
4692 /**
4693 * The **`observe()`** method of the **PerformanceObserver** interface is used to specify the set of performance entry types to observe.
4694 *
4695 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/observe)
4696 */
4697 observe(options?: PerformanceObserverObserveOptions): void;
4698 /**
4699 * The **`takeRecords()`** method of the PerformanceObserver interface returns the current list of PerformanceEntry objects stored in the performance observer, emptying it out.
4700 *
4701 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/takeRecords)
4702 */
4703 takeRecords(): PerformanceEntry[];
4704 readonly supportedEntryTypes: string[];
4705}
4706interface PerformanceObserverObserveOptions {
4707 buffered?: boolean;
4708 durationThreshold?: number;
4709 entryTypes?: string[];
4710 type?: string;
4711}
4712interface EventCounts {
4713 get size(): number;
4714 get(eventType: string): number | undefined;
4715 has(eventType: string): boolean;
4716 entries(): IterableIterator<string[]>;
4717 keys(): IterableIterator<string>;
4718 values(): IterableIterator<number>;
4719 forEach(
4720 param1: (param0: number, param1: string, param2: EventCounts) => void,
4721 param2?: any,
4722 ): void;
4723 [Symbol.iterator](): IterableIterator<string[]>;
4724}
4725interface Tracing {
4726 enterSpan<T, A extends unknown[]>(
4727 name: string,
4728 callback: (span: Span, ...args: A) => T,
4729 ...args: A
4730 ): T;
4731 Span: typeof Span;
4732}
4733declare abstract class Span {
4734 get isTraced(): boolean;
4735 setAttribute(key: string, value?: boolean | number | string): void;
4736}
4737// ============ AI Search Error Interfaces ============
4738interface AiSearchInternalError extends Error {}
4739interface AiSearchNotFoundError extends Error {}
4740// ============ AI Search Common Types ============
4741/** A single message in a conversation-style search or chat request. */
4742type AiSearchMessage = {
4743 role: "system" | "developer" | "user" | "assistant" | "tool";
4744 content: string | null;
4745};
4746/**
4747 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4748 * Contains retrieval, query rewrite, reranking, and cache sub-options.
4749 */
4750type AiSearchOptions = {
4751 retrieval?: {
4752 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4753 retrieval_type?: "vector" | "keyword" | "hybrid";
4754 /** Fusion method for combining vector + keyword results. */
4755 fusion_method?: "max" | "rrf";
4756 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4757 keyword_match_mode?: "and" | "or";
4758 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4759 match_threshold?: number;
4760 /** Maximum number of results to return (1-50). Default 10. */
4761 max_num_results?: number;
4762 /** Vectorize metadata filters applied to the search. */
4763 filters?: VectorizeVectorMetadataFilter;
4764 /** Number of surrounding chunks to include for context (0-3). Default 0. */
4765 context_expansion?: number;
4766 /** If true, return only item metadata without chunk text. */
4767 metadata_only?: boolean;
4768 /** If true (default), return empty results on retrieval failure instead of throwing. */
4769 return_on_failure?: boolean;
4770 /** Boost results by metadata field values. Max 3 entries. */
4771 boost_by?: Array<{
4772 field: string;
4773 direction?: "asc" | "desc" | "exists" | "not_exists";
4774 }>;
4775 [key: string]: unknown;
4776 };
4777 query_rewrite?: {
4778 enabled?: boolean;
4779 model?: string;
4780 rewrite_prompt?: string;
4781 [key: string]: unknown;
4782 };
4783 reranking?: {
4784 enabled?: boolean;
4785 model?: string;
4786 /** Match threshold (0-1, default 0.4) */
4787 match_threshold?: number;
4788 [key: string]: unknown;
4789 };
4790 cache?: {
4791 enabled?: boolean;
4792 cache_threshold?:
4793 | "super_strict_match"
4794 | "close_enough"
4795 | "flexible_friend"
4796 | "anything_goes";
4797 };
4798 [key: string]: unknown;
4799};
4800// ============ AI Search Request Types ============
4801/**
4802 * Request body for single-instance search.
4803 * Exactly one of `query` or `messages` must be provided.
4804 */
4805type AiSearchSearchRequest =
4806 | {
4807 /** Simple query string. */
4808 query: string;
4809 messages?: never;
4810 ai_search_options?: AiSearchOptions;
4811 }
4812 | {
4813 query?: never;
4814 /** Conversation-style input. At least one user message with non-empty content is required. */
4815 messages: AiSearchMessage[];
4816 ai_search_options?: AiSearchOptions;
4817 };
4818type AiSearchChatCompletionsRequest = {
4819 messages: AiSearchMessage[];
4820 model?: string;
4821 stream?: boolean;
4822 ai_search_options?: AiSearchOptions;
4823 [key: string]: unknown;
4824};
4825// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4826/** `ai_search_options` shape for multi-instance requests โ€” requires `instance_ids`. */
4827type AiSearchMultiSearchOptions = AiSearchOptions & {
4828 /** Instance IDs to search across (1-10). */
4829 instance_ids: string[];
4830};
4831/**
4832 * Request for searching across multiple instances within a namespace.
4833 * `ai_search_options` is required and must include `instance_ids`.
4834 * Exactly one of `query` or `messages` must be provided.
4835 */
4836type AiSearchMultiSearchRequest =
4837 | {
4838 /** Simple query string. */
4839 query: string;
4840 messages?: never;
4841 ai_search_options: AiSearchMultiSearchOptions;
4842 }
4843 | {
4844 query?: never;
4845 /** Conversation-style input. */
4846 messages: AiSearchMessage[];
4847 ai_search_options: AiSearchMultiSearchOptions;
4848 };
4849/** A search result chunk tagged with the instance it originated from. */
4850type AiSearchMultiSearchChunk = AiSearchSearchResponse["chunks"][number] & {
4851 instance_id: string;
4852};
4853/** Describes a per-instance error during a multi-instance operation. */
4854type AiSearchMultiSearchError = {
4855 instance_id: string;
4856 message: string;
4857};
4858/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4859type AiSearchMultiSearchResponse = {
4860 search_query: string;
4861 chunks: AiSearchMultiSearchChunk[];
4862 errors?: AiSearchMultiSearchError[];
4863};
4864/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4865type AiSearchMultiChatCompletionsRequest = Omit<
4866 AiSearchChatCompletionsRequest,
4867 "ai_search_options"
4868> & {
4869 ai_search_options: AiSearchMultiSearchOptions;
4870};
4871/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4872type AiSearchMultiChatCompletionsResponse = Omit<
4873 AiSearchChatCompletionsResponse,
4874 "chunks"
4875> & {
4876 chunks: AiSearchMultiSearchChunk[];
4877 errors?: AiSearchMultiSearchError[];
4878};
4879// ============ AI Search Response Types ============
4880type AiSearchSearchResponse = {
4881 search_query: string;
4882 chunks: Array<{
4883 id: string;
4884 type: string;
4885 /** Match score (0-1) */
4886 score: number;
4887 text: string;
4888 item: {
4889 timestamp?: number;
4890 key: string;
4891 metadata?: Record<string, unknown>;
4892 };
4893 scoring_details?: {
4894 /** Keyword match score (0-1) */
4895 keyword_score?: number;
4896 /** Vector similarity score (0-1) */
4897 vector_score?: number;
4898 /** Keyword rank position */
4899 keyword_rank?: number;
4900 /** Vector rank position */
4901 vector_rank?: number;
4902 /** Reranking model score */
4903 reranking_score?: number;
4904 /** Fusion method used to combine results */
4905 fusion_method?: "rrf" | "max";
4906 [key: string]: unknown;
4907 };
4908 }>;
4909};
4910type AiSearchChatCompletionsResponse = {
4911 id?: string;
4912 object?: string;
4913 model?: string;
4914 choices: Array<{
4915 index?: number;
4916 message: {
4917 role: "system" | "developer" | "user" | "assistant" | "tool";
4918 content: string | null;
4919 [key: string]: unknown;
4920 };
4921 [key: string]: unknown;
4922 }>;
4923 chunks: AiSearchSearchResponse["chunks"];
4924 [key: string]: unknown;
4925};
4926type AiSearchStatsResponse = {
4927 queued?: number;
4928 running?: number;
4929 completed?: number;
4930 error?: number;
4931 skipped?: number;
4932 outdated?: number;
4933 last_activity?: string;
4934 /** Storage engine statistics. */
4935 engine?: {
4936 vectorize?: {
4937 vectorsCount: number;
4938 dimensions: number;
4939 };
4940 r2?: {
4941 payloadSizeBytes: number;
4942 metadataSizeBytes: number;
4943 objectCount: number;
4944 };
4945 };
4946};
4947// ============ AI Search Instance Info Types ============
4948type AiSearchInstanceInfo = {
4949 id: string;
4950 type?: "r2" | "web-crawler" | string;
4951 source?: string;
4952 source_params?: unknown;
4953 paused?: boolean;
4954 status?: string;
4955 namespace?: string;
4956 created_at?: string;
4957 modified_at?: string;
4958 token_id?: string;
4959 ai_gateway_id?: string;
4960 rewrite_query?: boolean;
4961 reranking?: boolean;
4962 embedding_model?: string;
4963 ai_search_model?: string;
4964 rewrite_model?: string;
4965 reranking_model?: string;
4966 /** @deprecated Use index_method instead. */
4967 hybrid_search_enabled?: boolean;
4968 /** Controls which storage backends are active. */
4969 index_method?: {
4970 vector?: boolean;
4971 keyword?: boolean;
4972 };
4973 /** Fusion method for combining vector and keyword results. */
4974 fusion_method?: "max" | "rrf";
4975 indexing_options?: {
4976 keyword_tokenizer?: "porter" | "trigram";
4977 } | null;
4978 retrieval_options?: {
4979 keyword_match_mode?: "and" | "or";
4980 boost_by?: Array<{
4981 field: string;
4982 direction?: "asc" | "desc" | "exists" | "not_exists";
4983 }>;
4984 } | null;
4985 chunk?: boolean;
4986 chunk_size?: number;
4987 chunk_overlap?: number;
4988 score_threshold?: number;
4989 max_num_results?: number;
4990 cache?: boolean;
4991 cache_threshold?:
4992 | "super_strict_match"
4993 | "close_enough"
4994 | "flexible_friend"
4995 | "anything_goes";
4996 custom_metadata?: Array<{
4997 field_name: string;
4998 data_type: "text" | "number" | "boolean" | "datetime";
4999 }>;
5000 /** Sync interval in seconds. */
5001 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5002 metadata?: Record<string, unknown>;
5003 [key: string]: unknown;
5004};
5005/** Pagination, search, and ordering parameters for listing instances within a namespace. */
5006type AiSearchListInstancesParams = {
5007 page?: number;
5008 per_page?: number;
5009 /** Search instances by ID. */
5010 search?: string;
5011 /** Field to sort by. */
5012 order_by?: "created_at";
5013 /** Sort direction. */
5014 order_by_direction?: "asc" | "desc";
5015};
5016type AiSearchListResponse = {
5017 result: AiSearchInstanceInfo[];
5018 result_info?: {
5019 count: number;
5020 page: number;
5021 per_page: number;
5022 total_count: number;
5023 };
5024};
5025// ============ AI Search Config Types ============
5026type AiSearchConfig = {
5027 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
5028 id: string;
5029 /** Instance type. Omit to create with built-in storage. */
5030 type?: "r2" | "web-crawler" | string;
5031 /** Source URL (required for web-crawler type). */
5032 source?: string;
5033 source_params?: unknown;
5034 /** Token ID (UUID format) */
5035 token_id?: string;
5036 ai_gateway_id?: string;
5037 /** Enable query rewriting (default false) */
5038 rewrite_query?: boolean;
5039 /** Enable reranking (default false) */
5040 reranking?: boolean;
5041 embedding_model?: string;
5042 ai_search_model?: string;
5043 rewrite_model?: string;
5044 reranking_model?: string;
5045 /** @deprecated Use index_method instead. */
5046 hybrid_search_enabled?: boolean;
5047 /** Controls which storage backends are used during indexing. Defaults to vector-only. */
5048 index_method?: {
5049 vector?: boolean;
5050 keyword?: boolean;
5051 };
5052 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
5053 fusion_method?: "max" | "rrf";
5054 indexing_options?: {
5055 keyword_tokenizer?: "porter" | "trigram";
5056 } | null;
5057 retrieval_options?: {
5058 keyword_match_mode?: "and" | "or";
5059 boost_by?: Array<{
5060 field: string;
5061 direction?: "asc" | "desc" | "exists" | "not_exists";
5062 }>;
5063 } | null;
5064 chunk?: boolean;
5065 chunk_size?: number;
5066 chunk_overlap?: number;
5067 /** Minimum similarity score (0-1) for a result to be included. */
5068 score_threshold?: number;
5069 max_num_results?: number;
5070 cache?: boolean;
5071 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
5072 cache_threshold?:
5073 | "super_strict_match"
5074 | "close_enough"
5075 | "flexible_friend"
5076 | "anything_goes";
5077 custom_metadata?: Array<{
5078 field_name: string;
5079 data_type: "text" | "number" | "boolean" | "datetime";
5080 }>;
5081 namespace?: string;
5082 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
5083 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5084 metadata?: Record<string, unknown>;
5085 [key: string]: unknown;
5086};
5087// ============ AI Search Item Types ============
5088type AiSearchItemInfo = {
5089 id: string;
5090 key: string;
5091 status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
5092 next_action?: "INDEX" | "DELETE" | null;
5093 error?: string;
5094 checksum?: string;
5095 namespace?: string;
5096 chunks_count?: number | null;
5097 file_size?: number | null;
5098 source_id?: string | null;
5099 last_seen_at?: string;
5100 created_at?: string;
5101 metadata?: Record<string, unknown>;
5102 [key: string]: unknown;
5103};
5104type AiSearchItemContentResult = {
5105 body: ReadableStream;
5106 contentType: string;
5107 filename: string;
5108 size: number;
5109};
5110type AiSearchUploadItemOptions = {
5111 metadata?: Record<string, unknown>;
5112};
5113type AiSearchListItemsParams = {
5114 page?: number;
5115 per_page?: number;
5116 /** Search items by key name. */
5117 search?: string;
5118 /** Sort order for results. */
5119 sort_by?: "status" | "modified_at";
5120 /** Filter items by processing status. */
5121 status?:
5122 | "queued"
5123 | "running"
5124 | "completed"
5125 | "error"
5126 | "skipped"
5127 | "outdated";
5128 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
5129 source?: string;
5130 /** JSON-encoded Vectorize filter for metadata filtering. */
5131 metadata_filter?: string;
5132};
5133type AiSearchListItemsResponse = {
5134 result: AiSearchItemInfo[];
5135 result_info?: {
5136 count: number;
5137 page: number;
5138 per_page: number;
5139 total_count: number;
5140 };
5141};
5142// ============ AI Search Item Logs Types ============
5143type AiSearchItemLogsParams = {
5144 /** Maximum number of log entries to return (1-100, default 50). */
5145 limit?: number;
5146 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
5147 cursor?: string;
5148};
5149type AiSearchItemLog = {
5150 timestamp: string;
5151 action: string;
5152 message: string;
5153 fileKey?: string;
5154 chunkCount?: number;
5155 processingTimeMs?: number;
5156 errorType?: string;
5157};
5158/** Paginated response for item processing logs (cursor-based). */
5159type AiSearchItemLogsResponse = {
5160 result: AiSearchItemLog[];
5161 result_info: {
5162 count: number;
5163 per_page: number;
5164 cursor: string | null;
5165 truncated: boolean;
5166 };
5167};
5168// ============ AI Search Item Chunks Types ============
5169type AiSearchItemChunksParams = {
5170 /** Maximum number of chunks to return (1-100, default 20). */
5171 limit?: number;
5172 /** Offset into the chunks list (default 0). */
5173 offset?: number;
5174};
5175/** A single indexed chunk belonging to an item, including its text content and byte range. */
5176type AiSearchItemChunk = {
5177 id: string;
5178 text: string;
5179 start_byte: number;
5180 end_byte: number;
5181 item?: {
5182 timestamp?: number;
5183 key: string;
5184 metadata?: Record<string, unknown>;
5185 };
5186};
5187/** Paginated response for item chunks (offset-based). */
5188type AiSearchItemChunksResponse = {
5189 result: AiSearchItemChunk[];
5190 result_info: {
5191 count: number;
5192 total: number;
5193 limit: number;
5194 offset: number;
5195 };
5196};
5197// ============ AI Search Job Types ============
5198type AiSearchJobInfo = {
5199 id: string;
5200 source: "user" | "schedule";
5201 description?: string;
5202 last_seen_at?: string;
5203 started_at?: string;
5204 ended_at?: string;
5205 end_reason?: string;
5206};
5207type AiSearchJobLog = {
5208 id: number;
5209 message: string;
5210 message_type: number;
5211 created_at: number;
5212};
5213type AiSearchCreateJobParams = {
5214 description?: string;
5215};
5216type AiSearchListJobsParams = {
5217 page?: number;
5218 per_page?: number;
5219};
5220type AiSearchListJobsResponse = {
5221 result: AiSearchJobInfo[];
5222 result_info?: {
5223 count: number;
5224 page: number;
5225 per_page: number;
5226 total_count: number;
5227 };
5228};
5229type AiSearchJobLogsParams = {
5230 page?: number;
5231 per_page?: number;
5232};
5233type AiSearchJobLogsResponse = {
5234 result: AiSearchJobLog[];
5235 result_info?: {
5236 count: number;
5237 page: number;
5238 per_page: number;
5239 total_count: number;
5240 };
5241};
5242// ============ AI Search Sub-Service Classes ============
5243/**
5244 * Single item service for an AI Search instance.
5245 * Provides info, download, sync, logs, and chunks operations on a specific item.
5246 */
5247declare abstract class AiSearchItem {
5248 /** Get metadata about this item. */
5249 info(): Promise<AiSearchItemInfo>;
5250 /**
5251 * Download the item's content.
5252 * @returns Object with body stream, content type, filename, and size.
5253 */
5254 download(): Promise<AiSearchItemContentResult>;
5255 /**
5256 * Trigger re-indexing of this item.
5257 * @returns The updated item info.
5258 */
5259 sync(): Promise<AiSearchItemInfo>;
5260 /**
5261 * Retrieve processing logs for this item (cursor-based pagination).
5262 * @param params Optional pagination parameters (limit, cursor).
5263 * @returns Paginated log entries for this item.
5264 */
5265 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
5266 /**
5267 * List indexed chunks for this item (offset-based pagination).
5268 * @param params Optional pagination parameters (limit, offset).
5269 * @returns Paginated chunk entries for this item.
5270 */
5271 chunks(
5272 params?: AiSearchItemChunksParams,
5273 ): Promise<AiSearchItemChunksResponse>;
5274}
5275/**
5276 * Items collection service for an AI Search instance.
5277 * Provides list, upload, and access to individual items.
5278 */
5279declare abstract class AiSearchItems {
5280 /** List items in this instance. */
5281 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
5282 /**
5283 * Upload a file as an item. Behaves as an upsert: if an item with the same
5284 * filename already exists, it is overwritten and re-indexed.
5285 * @param name Filename for the uploaded item.
5286 * @param content File content as a ReadableStream, Blob, or string.
5287 * @param options Optional metadata to attach to the item.
5288 * @returns The created item info.
5289 */
5290 upload(
5291 name: string,
5292 content: ReadableStream | Blob | string,
5293 options?: AiSearchUploadItemOptions,
5294 ): Promise<AiSearchItemInfo>;
5295 /**
5296 * Upload a file and poll until processing completes.
5297 * Behaves as an upsert: if an item with the same filename already exists,
5298 * it is overwritten and re-indexed.
5299 * @param name Filename for the uploaded item.
5300 * @param content File content as a ReadableStream, Blob, or string.
5301 * @param options Optional metadata and polling configuration.
5302 * @returns The item info after processing completes (or timeout).
5303 */
5304 uploadAndPoll(
5305 name: string,
5306 content: ReadableStream | Blob | string,
5307 options?: AiSearchUploadItemOptions & {
5308 /** Polling interval in milliseconds (default 1000). */
5309 pollIntervalMs?: number;
5310 /** Maximum time to wait in milliseconds (default 30000). */
5311 timeoutMs?: number;
5312 },
5313 ): Promise<AiSearchItemInfo>;
5314 /**
5315 * Get an item by ID.
5316 * @param itemId The item identifier.
5317 * @returns Item service for info, download, sync, logs, and chunks operations.
5318 */
5319 get(itemId: string): AiSearchItem;
5320 /**
5321 * Delete an item from the instance.
5322 * @param itemId The item identifier.
5323 */
5324 delete(itemId: string): Promise<void>;
5325}
5326/**
5327 * Single job service for an AI Search instance.
5328 * Provides info, logs, and cancel operations for a specific job.
5329 */
5330declare abstract class AiSearchJob {
5331 /** Get metadata about this job. */
5332 info(): Promise<AiSearchJobInfo>;
5333 /** Get logs for this job. */
5334 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
5335 /**
5336 * Cancel a running job.
5337 * @returns The updated job info.
5338 * @throws AiSearchNotFoundError if the job does not exist.
5339 */
5340 cancel(): Promise<AiSearchJobInfo>;
5341}
5342/**
5343 * Jobs collection service for an AI Search instance.
5344 * Provides list, create, and access to individual jobs.
5345 */
5346declare abstract class AiSearchJobs {
5347 /** List jobs for this instance. */
5348 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
5349 /**
5350 * Create a new indexing job.
5351 * @param params Optional job parameters.
5352 * @returns The created job info.
5353 */
5354 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
5355 /**
5356 * Get a job by ID.
5357 * @param jobId The job identifier.
5358 * @returns Job service for info, logs, and cancel operations.
5359 */
5360 get(jobId: string): AiSearchJob;
5361}
5362// ============ AI Search Binding Classes ============
5363/**
5364 * Instance-level AI Search service.
5365 *
5366 * Used as:
5367 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)
5368 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
5369 *
5370 * Provides search, chat, update, stats, items, and jobs operations.
5371 *
5372 * @example
5373 * ```ts
5374 * // Via namespace binding
5375 * const instance = env.AI_SEARCH.get("blog");
5376 * const results = await instance.search({
5377 * query: "How does caching work?",
5378 * });
5379 *
5380 * // Via single instance binding
5381 * const results = await env.BLOG_SEARCH.search({
5382 * messages: [{ role: "user", content: "How does caching work?" }],
5383 * });
5384 * ```
5385 */
5386declare abstract class AiSearchInstance {
5387 /**
5388 * Search the AI Search instance for relevant chunks.
5389 * @param params Search request with query or messages and optional AI search options.
5390 * @returns Search response with matching chunks and search query.
5391 */
5392 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
5393 /**
5394 * Generate chat completions with AI Search context (streaming).
5395 * @param params Chat completions request with stream: true.
5396 * @returns ReadableStream of server-sent events.
5397 */
5398 chatCompletions(
5399 params: AiSearchChatCompletionsRequest & {
5400 stream: true;
5401 },
5402 ): Promise<ReadableStream>;
5403 /**
5404 * Generate chat completions with AI Search context.
5405 * @param params Chat completions request.
5406 * @returns Chat completion response with choices and RAG chunks.
5407 */
5408 chatCompletions(
5409 params: AiSearchChatCompletionsRequest,
5410 ): Promise<AiSearchChatCompletionsResponse>;
5411 /**
5412 * Update the instance configuration.
5413 * @param config Partial configuration to update.
5414 * @returns Updated instance info.
5415 */
5416 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
5417 /** Get metadata about this instance. */
5418 info(): Promise<AiSearchInstanceInfo>;
5419 /**
5420 * Get instance statistics (item count, indexing status, etc.).
5421 * @returns Statistics with counts per status, last activity time, and engine details.
5422 */
5423 stats(): Promise<AiSearchStatsResponse>;
5424 /** Items collection โ€” list, upload, and manage items in this instance. */
5425 get items(): AiSearchItems;
5426 /** Jobs collection โ€” list, create, and inspect indexing jobs. */
5427 get jobs(): AiSearchJobs;
5428}
5429/**
5430 * Namespace-level AI Search service.
5431 *
5432 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
5433 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
5434 * and multi-instance search/chat operations.
5435 *
5436 * @example
5437 * ```ts
5438 * // Access an instance within the namespace
5439 * const blog = env.AI_SEARCH.get("blog");
5440 * const results = await blog.search({ query: "How does caching work?" });
5441 *
5442 * // List all instances in the namespace
5443 * const instances = await env.AI_SEARCH.list();
5444 *
5445 * // Create a new instance with built-in storage
5446 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
5447 *
5448 * // Upload items into the instance
5449 * await tenant.items.upload("doc.pdf", fileContent);
5450 *
5451 * // Search across multiple instances
5452 * const multi = await env.AI_SEARCH.search({
5453 * query: "caching",
5454 * ai_search_options: { instance_ids: ["blog", "docs"] },
5455 * });
5456 *
5457 * // Delete an instance
5458 * await env.AI_SEARCH.delete("tenant-123");
5459 * ```
5460 */
5461declare abstract class AiSearchNamespace {
5462 /**
5463 * Get an instance by name within the bound namespace.
5464 * @param name Instance name.
5465 * @returns Instance service for search, chat, update, stats, items, and jobs.
5466 */
5467 get(name: string): AiSearchInstance;
5468 /**
5469 * List instances in the bound namespace.
5470 * @param params Optional pagination, search, and ordering parameters.
5471 * @returns Array of instance metadata with pagination info.
5472 */
5473 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
5474 /**
5475 * Create a new instance within the bound namespace.
5476 * @param config Instance configuration. Only `id` is required โ€” omit `type` and `source` to create with built-in storage.
5477 * @returns Instance service for the newly created instance.
5478 *
5479 * @example
5480 * ```ts
5481 * // Create with built-in storage (upload items manually)
5482 * const instance = await env.AI_SEARCH.create({ id: "my-search" });
5483 *
5484 * // Create with web crawler source
5485 * const instance = await env.AI_SEARCH.create({
5486 * id: "docs-search",
5487 * type: "web-crawler",
5488 * source: "https://developers.cloudflare.com",
5489 * });
5490 * ```
5491 */
5492 create(config: AiSearchConfig): Promise<AiSearchInstance>;
5493 /**
5494 * Delete an instance from the bound namespace.
5495 * @param name Instance name to delete.
5496 */
5497 delete(name: string): Promise<void>;
5498 /**
5499 * Search across multiple instances within the bound namespace.
5500 * Fans out to the specified instance_ids and merges results.
5501 * @param params Search request with required `ai_search_options.instance_ids`.
5502 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
5503 */
5504 search(
5505 params: AiSearchMultiSearchRequest,
5506 ): Promise<AiSearchMultiSearchResponse>;
5507 /**
5508 * Generate chat completions across multiple instances within the bound namespace (streaming).
5509 * Fans out to the specified instance_ids, merges context, and generates a response.
5510 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
5511 * @returns ReadableStream of server-sent events.
5512 */
5513 chatCompletions(
5514 params: AiSearchMultiChatCompletionsRequest & {
5515 stream: true;
5516 },
5517 ): Promise<ReadableStream>;
5518 /**
5519 * Generate chat completions across multiple instances within the bound namespace.
5520 * Fans out to the specified instance_ids, merges context, and generates a response.
5521 * @param params Chat completions request with required `ai_search_options.instance_ids`.
5522 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
5523 */
5524 chatCompletions(
5525 params: AiSearchMultiChatCompletionsRequest,
5526 ): Promise<AiSearchMultiChatCompletionsResponse>;
5527}
5528type AiImageClassificationInput = {
5529 image: number[];
5530};
5531type AiImageClassificationOutput = {
5532 score?: number;
5533 label?: string;
5534}[];
5535declare abstract class BaseAiImageClassification {
5536 inputs: AiImageClassificationInput;
5537 postProcessedOutputs: AiImageClassificationOutput;
5538}
5539type AiImageToTextInput = {
5540 image: number[];
5541 prompt?: string;
5542 max_tokens?: number;
5543 temperature?: number;
5544 top_p?: number;
5545 top_k?: number;
5546 seed?: number;
5547 repetition_penalty?: number;
5548 frequency_penalty?: number;
5549 presence_penalty?: number;
5550 raw?: boolean;
5551 messages?: RoleScopedChatInput[];
5552};
5553type AiImageToTextOutput = {
5554 description: string;
5555};
5556declare abstract class BaseAiImageToText {
5557 inputs: AiImageToTextInput;
5558 postProcessedOutputs: AiImageToTextOutput;
5559}
5560type AiImageTextToTextInput = {
5561 image: string;
5562 prompt?: string;
5563 max_tokens?: number;
5564 temperature?: number;
5565 ignore_eos?: boolean;
5566 top_p?: number;
5567 top_k?: number;
5568 seed?: number;
5569 repetition_penalty?: number;
5570 frequency_penalty?: number;
5571 presence_penalty?: number;
5572 raw?: boolean;
5573 messages?: RoleScopedChatInput[];
5574};
5575type AiImageTextToTextOutput = {
5576 description: string;
5577};
5578declare abstract class BaseAiImageTextToText {
5579 inputs: AiImageTextToTextInput;
5580 postProcessedOutputs: AiImageTextToTextOutput;
5581}
5582type AiMultimodalEmbeddingsInput = {
5583 image: string;
5584 text: string[];
5585};
5586type AiIMultimodalEmbeddingsOutput = {
5587 data: number[][];
5588 shape: number[];
5589};
5590declare abstract class BaseAiMultimodalEmbeddings {
5591 inputs: AiImageTextToTextInput;
5592 postProcessedOutputs: AiImageTextToTextOutput;
5593}
5594type AiObjectDetectionInput = {
5595 image: number[];
5596};
5597type AiObjectDetectionOutput = {
5598 score?: number;
5599 label?: string;
5600}[];
5601declare abstract class BaseAiObjectDetection {
5602 inputs: AiObjectDetectionInput;
5603 postProcessedOutputs: AiObjectDetectionOutput;
5604}
5605type AiSentenceSimilarityInput = {
5606 source: string;
5607 sentences: string[];
5608};
5609type AiSentenceSimilarityOutput = number[];
5610declare abstract class BaseAiSentenceSimilarity {
5611 inputs: AiSentenceSimilarityInput;
5612 postProcessedOutputs: AiSentenceSimilarityOutput;
5613}
5614type AiAutomaticSpeechRecognitionInput = {
5615 audio: number[];
5616};
5617type AiAutomaticSpeechRecognitionOutput = {
5618 text?: string;
5619 words?: {
5620 word: string;
5621 start: number;
5622 end: number;
5623 }[];
5624 vtt?: string;
5625};
5626declare abstract class BaseAiAutomaticSpeechRecognition {
5627 inputs: AiAutomaticSpeechRecognitionInput;
5628 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
5629}
5630type AiSummarizationInput = {
5631 input_text: string;
5632 max_length?: number;
5633};
5634type AiSummarizationOutput = {
5635 summary: string;
5636};
5637declare abstract class BaseAiSummarization {
5638 inputs: AiSummarizationInput;
5639 postProcessedOutputs: AiSummarizationOutput;
5640}
5641type AiTextClassificationInput = {
5642 text: string;
5643};
5644type AiTextClassificationOutput = {
5645 score?: number;
5646 label?: string;
5647}[];
5648declare abstract class BaseAiTextClassification {
5649 inputs: AiTextClassificationInput;
5650 postProcessedOutputs: AiTextClassificationOutput;
5651}
5652type AiTextEmbeddingsInput = {
5653 text: string | string[];
5654};
5655type AiTextEmbeddingsOutput = {
5656 shape: number[];
5657 data: number[][];
5658};
5659declare abstract class BaseAiTextEmbeddings {
5660 inputs: AiTextEmbeddingsInput;
5661 postProcessedOutputs: AiTextEmbeddingsOutput;
5662}
5663type RoleScopedChatInput = {
5664 role:
5665 | "user"
5666 | "assistant"
5667 | "system"
5668 | "tool"
5669 | (string & NonNullable<unknown>);
5670 content: string;
5671 name?: string;
5672};
5673type AiTextGenerationToolLegacyInput = {
5674 name: string;
5675 description: string;
5676 parameters?: {
5677 type: "object" | (string & NonNullable<unknown>);
5678 properties: {
5679 [key: string]: {
5680 type: string;
5681 description?: string;
5682 };
5683 };
5684 required: string[];
5685 };
5686};
5687type AiTextGenerationToolInput = {
5688 type: "function" | (string & NonNullable<unknown>);
5689 function: {
5690 name: string;
5691 description: string;
5692 parameters?: {
5693 type: "object" | (string & NonNullable<unknown>);
5694 properties: {
5695 [key: string]: {
5696 type: string;
5697 description?: string;
5698 };
5699 };
5700 required: string[];
5701 };
5702 };
5703};
5704type AiTextGenerationFunctionsInput = {
5705 name: string;
5706 code: string;
5707};
5708type AiTextGenerationResponseFormat = {
5709 type: string;
5710 json_schema?: any;
5711};
5712type AiTextGenerationInput = {
5713 prompt?: string;
5714 raw?: boolean;
5715 stream?: boolean;
5716 max_tokens?: number;
5717 temperature?: number;
5718 top_p?: number;
5719 top_k?: number;
5720 seed?: number;
5721 repetition_penalty?: number;
5722 frequency_penalty?: number;
5723 presence_penalty?: number;
5724 messages?: RoleScopedChatInput[];
5725 response_format?: AiTextGenerationResponseFormat;
5726 tools?:
5727 | AiTextGenerationToolInput[]
5728 | AiTextGenerationToolLegacyInput[]
5729 | (object & NonNullable<unknown>);
5730 functions?: AiTextGenerationFunctionsInput[];
5731};
5732type AiTextGenerationToolLegacyOutput = {
5733 name: string;
5734 arguments: unknown;
5735};
5736type AiTextGenerationToolOutput = {
5737 id: string;
5738 type: "function";
5739 function: {
5740 name: string;
5741 arguments: string;
5742 };
5743};
5744type UsageTags = {
5745 prompt_tokens: number;
5746 completion_tokens: number;
5747 total_tokens: number;
5748};
5749type AiTextGenerationOutput = {
5750 response?: string;
5751 tool_calls?: AiTextGenerationToolLegacyOutput[] &
5752 AiTextGenerationToolOutput[];
5753 usage?: UsageTags;
5754};
5755declare abstract class BaseAiTextGeneration {
5756 inputs: AiTextGenerationInput;
5757 postProcessedOutputs: AiTextGenerationOutput;
5758}
5759type AiTextToSpeechInput = {
5760 prompt: string;
5761 lang?: string;
5762};
5763type AiTextToSpeechOutput =
5764 | Uint8Array
5765 | {
5766 audio: string;
5767 };
5768declare abstract class BaseAiTextToSpeech {
5769 inputs: AiTextToSpeechInput;
5770 postProcessedOutputs: AiTextToSpeechOutput;
5771}
5772type AiTextToImageInput = {
5773 prompt: string;
5774 negative_prompt?: string;
5775 height?: number;
5776 width?: number;
5777 image?: number[];
5778 image_b64?: string;
5779 mask?: number[];
5780 num_steps?: number;
5781 strength?: number;
5782 guidance?: number;
5783 seed?: number;
5784};
5785type AiTextToImageOutput = ReadableStream<Uint8Array>;
5786declare abstract class BaseAiTextToImage {
5787 inputs: AiTextToImageInput;
5788 postProcessedOutputs: AiTextToImageOutput;
5789}
5790type AiTranslationInput = {
5791 text: string;
5792 target_lang: string;
5793 source_lang?: string;
5794};
5795type AiTranslationOutput = {
5796 translated_text?: string;
5797};
5798declare abstract class BaseAiTranslation {
5799 inputs: AiTranslationInput;
5800 postProcessedOutputs: AiTranslationOutput;
5801}
5802/**
5803 * Workers AI support for OpenAI's Chat Completions API
5804 */
5805type ChatCompletionContentPartText = {
5806 type: "text";
5807 text: string;
5808};
5809type ChatCompletionContentPartImage = {
5810 type: "image_url";
5811 image_url: {
5812 url: string;
5813 detail?: "auto" | "low" | "high";
5814 };
5815};
5816type ChatCompletionContentPartInputAudio = {
5817 type: "input_audio";
5818 input_audio: {
5819 /** Base64 encoded audio data. */
5820 data: string;
5821 format: "wav" | "mp3";
5822 };
5823};
5824type ChatCompletionContentPartFile = {
5825 type: "file";
5826 file: {
5827 /** Base64 encoded file data. */
5828 file_data?: string;
5829 /** The ID of an uploaded file. */
5830 file_id?: string;
5831 filename?: string;
5832 };
5833};
5834type ChatCompletionContentPartRefusal = {
5835 type: "refusal";
5836 refusal: string;
5837};
5838type ChatCompletionContentPart =
5839 | ChatCompletionContentPartText
5840 | ChatCompletionContentPartImage
5841 | ChatCompletionContentPartInputAudio
5842 | ChatCompletionContentPartFile;
5843type FunctionDefinition = {
5844 name: string;
5845 description?: string;
5846 parameters?: Record<string, unknown>;
5847 strict?: boolean | null;
5848};
5849type ChatCompletionFunctionTool = {
5850 type: "function";
5851 function: FunctionDefinition;
5852};
5853type ChatCompletionCustomToolGrammarFormat = {
5854 type: "grammar";
5855 grammar: {
5856 definition: string;
5857 syntax: "lark" | "regex";
5858 };
5859};
5860type ChatCompletionCustomToolTextFormat = {
5861 type: "text";
5862};
5863type ChatCompletionCustomToolFormat =
5864 | ChatCompletionCustomToolTextFormat
5865 | ChatCompletionCustomToolGrammarFormat;
5866type ChatCompletionCustomTool = {
5867 type: "custom";
5868 custom: {
5869 name: string;
5870 description?: string;
5871 format?: ChatCompletionCustomToolFormat;
5872 };
5873};
5874type ChatCompletionTool = ChatCompletionFunctionTool | ChatCompletionCustomTool;
5875type ChatCompletionMessageFunctionToolCall = {
5876 id: string;
5877 type: "function";
5878 function: {
5879 name: string;
5880 /** JSON-encoded arguments string. */
5881 arguments: string;
5882 };
5883};
5884type ChatCompletionMessageCustomToolCall = {
5885 id: string;
5886 type: "custom";
5887 custom: {
5888 name: string;
5889 input: string;
5890 };
5891};
5892type ChatCompletionMessageToolCall =
5893 | ChatCompletionMessageFunctionToolCall
5894 | ChatCompletionMessageCustomToolCall;
5895type ChatCompletionToolChoiceFunction = {
5896 type: "function";
5897 function: {
5898 name: string;
5899 };
5900};
5901type ChatCompletionToolChoiceCustom = {
5902 type: "custom";
5903 custom: {
5904 name: string;
5905 };
5906};
5907type ChatCompletionToolChoiceAllowedTools = {
5908 type: "allowed_tools";
5909 allowed_tools: {
5910 mode: "auto" | "required";
5911 tools: Array<Record<string, unknown>>;
5912 };
5913};
5914type ChatCompletionToolChoiceOption =
5915 | "none"
5916 | "auto"
5917 | "required"
5918 | ChatCompletionToolChoiceFunction
5919 | ChatCompletionToolChoiceCustom
5920 | ChatCompletionToolChoiceAllowedTools;
5921type DeveloperMessage = {
5922 role: "developer";
5923 content:
5924 | string
5925 | Array<{
5926 type: "text";
5927 text: string;
5928 }>;
5929 name?: string;
5930};
5931type SystemMessage = {
5932 role: "system";
5933 content:
5934 | string
5935 | Array<{
5936 type: "text";
5937 text: string;
5938 }>;
5939 name?: string;
5940};
5941/**
5942 * Permissive merged content part used inside UserMessage arrays.
5943 *
5944 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
5945 * inside nested array items does not correctly match different branches for
5946 * different array elements, so the schema uses a single merged object.
5947 */
5948type UserMessageContentPart = {
5949 type: "text" | "image_url" | "input_audio" | "file";
5950 text?: string;
5951 image_url?: {
5952 url?: string;
5953 detail?: "auto" | "low" | "high";
5954 };
5955 input_audio?: {
5956 data?: string;
5957 format?: "wav" | "mp3";
5958 };
5959 file?: {
5960 file_data?: string;
5961 file_id?: string;
5962 filename?: string;
5963 };
5964};
5965type UserMessage = {
5966 role: "user";
5967 content: string | Array<UserMessageContentPart>;
5968 name?: string;
5969};
5970type AssistantMessageContentPart = {
5971 type: "text" | "refusal";
5972 text?: string;
5973 refusal?: string;
5974};
5975type AssistantMessage = {
5976 role: "assistant";
5977 content?: string | null | Array<AssistantMessageContentPart>;
5978 refusal?: string | null;
5979 name?: string;
5980 audio?: {
5981 id: string;
5982 };
5983 tool_calls?: Array<ChatCompletionMessageToolCall>;
5984 function_call?: {
5985 name: string;
5986 arguments: string;
5987 };
5988};
5989type ToolMessage = {
5990 role: "tool";
5991 content:
5992 | string
5993 | Array<{
5994 type: "text";
5995 text: string;
5996 }>;
5997 tool_call_id: string;
5998};
5999type FunctionMessage = {
6000 role: "function";
6001 content: string;
6002 name: string;
6003};
6004type ChatCompletionMessageParam =
6005 | DeveloperMessage
6006 | SystemMessage
6007 | UserMessage
6008 | AssistantMessage
6009 | ToolMessage
6010 | FunctionMessage;
6011type ChatCompletionsResponseFormatText = {
6012 type: "text";
6013};
6014type ChatCompletionsResponseFormatJSONObject = {
6015 type: "json_object";
6016};
6017type ResponseFormatJSONSchema = {
6018 type: "json_schema";
6019 json_schema: {
6020 name: string;
6021 description?: string;
6022 schema?: Record<string, unknown>;
6023 strict?: boolean | null;
6024 };
6025};
6026type ResponseFormat =
6027 | ChatCompletionsResponseFormatText
6028 | ChatCompletionsResponseFormatJSONObject
6029 | ResponseFormatJSONSchema;
6030type ChatCompletionsStreamOptions = {
6031 include_usage?: boolean;
6032 include_obfuscation?: boolean;
6033};
6034type PredictionContent = {
6035 type: "content";
6036 content:
6037 | string
6038 | Array<{
6039 type: "text";
6040 text: string;
6041 }>;
6042};
6043type AudioParams = {
6044 voice:
6045 | string
6046 | {
6047 id: string;
6048 };
6049 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
6050};
6051type WebSearchUserLocation = {
6052 type: "approximate";
6053 approximate: {
6054 city?: string;
6055 country?: string;
6056 region?: string;
6057 timezone?: string;
6058 };
6059};
6060type WebSearchOptions = {
6061 search_context_size?: "low" | "medium" | "high";
6062 user_location?: WebSearchUserLocation;
6063};
6064type ChatTemplateKwargs = {
6065 /** Whether to enable reasoning, enabled by default. */
6066 enable_thinking?: boolean;
6067 /** If false, preserves reasoning context between turns. */
6068 clear_thinking?: boolean;
6069};
6070/** Shared optional properties used by both Prompt and Messages input branches. */
6071type ChatCompletionsCommonOptions = {
6072 model?: string;
6073 audio?: AudioParams;
6074 frequency_penalty?: number | null;
6075 logit_bias?: Record<string, unknown> | null;
6076 logprobs?: boolean | null;
6077 top_logprobs?: number | null;
6078 max_tokens?: number | null;
6079 max_completion_tokens?: number | null;
6080 metadata?: Record<string, unknown> | null;
6081 modalities?: Array<"text" | "audio"> | null;
6082 n?: number | null;
6083 parallel_tool_calls?: boolean;
6084 prediction?: PredictionContent;
6085 presence_penalty?: number | null;
6086 reasoning_effort?: "low" | "medium" | "high" | null;
6087 chat_template_kwargs?: ChatTemplateKwargs;
6088 response_format?: ResponseFormat;
6089 seed?: number | null;
6090 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6091 stop?: string | Array<string> | null;
6092 store?: boolean | null;
6093 stream?: boolean | null;
6094 stream_options?: ChatCompletionsStreamOptions;
6095 temperature?: number | null;
6096 tool_choice?: ChatCompletionToolChoiceOption;
6097 tools?: Array<ChatCompletionTool>;
6098 top_p?: number | null;
6099 user?: string;
6100 web_search_options?: WebSearchOptions;
6101 function_call?:
6102 | "none"
6103 | "auto"
6104 | {
6105 name: string;
6106 };
6107 functions?: Array<FunctionDefinition>;
6108};
6109type PromptTokensDetails = {
6110 cached_tokens?: number;
6111 audio_tokens?: number;
6112};
6113type CompletionTokensDetails = {
6114 reasoning_tokens?: number;
6115 audio_tokens?: number;
6116 accepted_prediction_tokens?: number;
6117 rejected_prediction_tokens?: number;
6118};
6119type CompletionUsage = {
6120 prompt_tokens: number;
6121 completion_tokens: number;
6122 total_tokens: number;
6123 prompt_tokens_details?: PromptTokensDetails;
6124 completion_tokens_details?: CompletionTokensDetails;
6125};
6126type ChatCompletionTopLogprob = {
6127 token: string;
6128 logprob: number;
6129 bytes: Array<number> | null;
6130};
6131type ChatCompletionTokenLogprob = {
6132 token: string;
6133 logprob: number;
6134 bytes: Array<number> | null;
6135 top_logprobs: Array<ChatCompletionTopLogprob>;
6136};
6137type ChatCompletionAudio = {
6138 id: string;
6139 /** Base64 encoded audio bytes. */
6140 data: string;
6141 expires_at: number;
6142 transcript: string;
6143};
6144type ChatCompletionUrlCitation = {
6145 type: "url_citation";
6146 url_citation: {
6147 url: string;
6148 title: string;
6149 start_index: number;
6150 end_index: number;
6151 };
6152};
6153type ChatCompletionResponseMessage = {
6154 role: "assistant";
6155 content: string | null;
6156 refusal: string | null;
6157 annotations?: Array<ChatCompletionUrlCitation>;
6158 audio?: ChatCompletionAudio;
6159 tool_calls?: Array<ChatCompletionMessageToolCall>;
6160 function_call?: {
6161 name: string;
6162 arguments: string;
6163 } | null;
6164};
6165type ChatCompletionLogprobs = {
6166 content: Array<ChatCompletionTokenLogprob> | null;
6167 refusal?: Array<ChatCompletionTokenLogprob> | null;
6168};
6169type ChatCompletionChoice = {
6170 index: number;
6171 message: ChatCompletionResponseMessage;
6172 finish_reason:
6173 | "stop"
6174 | "length"
6175 | "tool_calls"
6176 | "content_filter"
6177 | "function_call";
6178 logprobs: ChatCompletionLogprobs | null;
6179};
6180type ChatCompletionsPromptInput = {
6181 prompt: string;
6182} & ChatCompletionsCommonOptions;
6183type ChatCompletionsMessagesInput = {
6184 messages: Array<ChatCompletionMessageParam>;
6185} & ChatCompletionsCommonOptions;
6186type ChatCompletionsOutput = {
6187 id: string;
6188 object: string;
6189 created: number;
6190 model: string;
6191 choices: Array<ChatCompletionChoice>;
6192 usage?: CompletionUsage;
6193 system_fingerprint?: string | null;
6194 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6195};
6196/**
6197 * Workers AI support for OpenAI's Responses API
6198 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
6199 *
6200 * It's a stripped down version from its source.
6201 * It currently supports basic function calling, json mode and accepts images as input.
6202 *
6203 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
6204 * We plan to add those incrementally as model + platform capabilities evolve.
6205 */
6206type ResponsesInput = {
6207 background?: boolean | null;
6208 conversation?: string | ResponseConversationParam | null;
6209 include?: Array<ResponseIncludable> | null;
6210 input?: string | ResponseInput;
6211 instructions?: string | null;
6212 max_output_tokens?: number | null;
6213 parallel_tool_calls?: boolean | null;
6214 previous_response_id?: string | null;
6215 prompt_cache_key?: string;
6216 reasoning?: Reasoning | null;
6217 safety_identifier?: string;
6218 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6219 stream?: boolean | null;
6220 stream_options?: StreamOptions | null;
6221 temperature?: number | null;
6222 text?: ResponseTextConfig;
6223 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
6224 tools?: Array<Tool>;
6225 top_p?: number | null;
6226 truncation?: "auto" | "disabled" | null;
6227};
6228type ResponsesOutput = {
6229 id?: string;
6230 created_at?: number;
6231 output_text?: string;
6232 error?: ResponseError | null;
6233 incomplete_details?: ResponseIncompleteDetails | null;
6234 instructions?: string | Array<ResponseInputItem> | null;
6235 object?: "response";
6236 output?: Array<ResponseOutputItem>;
6237 parallel_tool_calls?: boolean;
6238 temperature?: number | null;
6239 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
6240 tools?: Array<Tool>;
6241 top_p?: number | null;
6242 max_output_tokens?: number | null;
6243 previous_response_id?: string | null;
6244 prompt?: ResponsePrompt | null;
6245 reasoning?: Reasoning | null;
6246 safety_identifier?: string;
6247 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6248 status?: ResponseStatus;
6249 text?: ResponseTextConfig;
6250 truncation?: "auto" | "disabled" | null;
6251 usage?: ResponseUsage;
6252};
6253type EasyInputMessage = {
6254 content: string | ResponseInputMessageContentList;
6255 role: "user" | "assistant" | "system" | "developer";
6256 type?: "message";
6257};
6258type ResponsesFunctionTool = {
6259 name: string;
6260 parameters: {
6261 [key: string]: unknown;
6262 } | null;
6263 strict: boolean | null;
6264 type: "function";
6265 description?: string | null;
6266};
6267type ResponseIncompleteDetails = {
6268 reason?: "max_output_tokens" | "content_filter";
6269};
6270type ResponsePrompt = {
6271 id: string;
6272 variables?: {
6273 [key: string]: string | ResponseInputText | ResponseInputImage;
6274 } | null;
6275 version?: string | null;
6276};
6277type Reasoning = {
6278 effort?: ReasoningEffort | null;
6279 generate_summary?: "auto" | "concise" | "detailed" | null;
6280 summary?: "auto" | "concise" | "detailed" | null;
6281};
6282type ResponseContent =
6283 | ResponseInputText
6284 | ResponseInputImage
6285 | ResponseOutputText
6286 | ResponseOutputRefusal
6287 | ResponseContentReasoningText;
6288type ResponseContentReasoningText = {
6289 text: string;
6290 type: "reasoning_text";
6291};
6292type ResponseConversationParam = {
6293 id: string;
6294};
6295type ResponseCreatedEvent = {
6296 response: Response;
6297 sequence_number: number;
6298 type: "response.created";
6299};
6300type ResponseCustomToolCallOutput = {
6301 call_id: string;
6302 output: string | Array<ResponseInputText | ResponseInputImage>;
6303 type: "custom_tool_call_output";
6304 id?: string;
6305};
6306type ResponseError = {
6307 code:
6308 | "server_error"
6309 | "rate_limit_exceeded"
6310 | "invalid_prompt"
6311 | "vector_store_timeout"
6312 | "invalid_image"
6313 | "invalid_image_format"
6314 | "invalid_base64_image"
6315 | "invalid_image_url"
6316 | "image_too_large"
6317 | "image_too_small"
6318 | "image_parse_error"
6319 | "image_content_policy_violation"
6320 | "invalid_image_mode"
6321 | "image_file_too_large"
6322 | "unsupported_image_media_type"
6323 | "empty_image_file"
6324 | "failed_to_download_image"
6325 | "image_file_not_found";
6326 message: string;
6327};
6328type ResponseErrorEvent = {
6329 code: string | null;
6330 message: string;
6331 param: string | null;
6332 sequence_number: number;
6333 type: "error";
6334};
6335type ResponseFailedEvent = {
6336 response: Response;
6337 sequence_number: number;
6338 type: "response.failed";
6339};
6340type ResponseFormatText = {
6341 type: "text";
6342};
6343type ResponseFormatJSONObject = {
6344 type: "json_object";
6345};
6346type ResponseFormatTextConfig =
6347 | ResponseFormatText
6348 | ResponseFormatTextJSONSchemaConfig
6349 | ResponseFormatJSONObject;
6350type ResponseFormatTextJSONSchemaConfig = {
6351 name: string;
6352 schema: {
6353 [key: string]: unknown;
6354 };
6355 type: "json_schema";
6356 description?: string;
6357 strict?: boolean | null;
6358};
6359type ResponseFunctionCallArgumentsDeltaEvent = {
6360 delta: string;
6361 item_id: string;
6362 output_index: number;
6363 sequence_number: number;
6364 type: "response.function_call_arguments.delta";
6365};
6366type ResponseFunctionCallArgumentsDoneEvent = {
6367 arguments: string;
6368 item_id: string;
6369 name: string;
6370 output_index: number;
6371 sequence_number: number;
6372 type: "response.function_call_arguments.done";
6373};
6374type ResponseFunctionCallOutputItem =
6375 | ResponseInputTextContent
6376 | ResponseInputImageContent;
6377type ResponseFunctionCallOutputItemList = Array<ResponseFunctionCallOutputItem>;
6378type ResponseFunctionToolCall = {
6379 arguments: string;
6380 call_id: string;
6381 name: string;
6382 type: "function_call";
6383 id?: string;
6384 status?: "in_progress" | "completed" | "incomplete";
6385};
6386interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
6387 id: string;
6388}
6389type ResponseFunctionToolCallOutputItem = {
6390 id: string;
6391 call_id: string;
6392 output: string | Array<ResponseInputText | ResponseInputImage>;
6393 type: "function_call_output";
6394 status?: "in_progress" | "completed" | "incomplete";
6395};
6396type ResponseIncludable =
6397 | "message.input_image.image_url"
6398 | "message.output_text.logprobs";
6399type ResponseIncompleteEvent = {
6400 response: Response;
6401 sequence_number: number;
6402 type: "response.incomplete";
6403};
6404type ResponseInput = Array<ResponseInputItem>;
6405type ResponseInputContent = ResponseInputText | ResponseInputImage;
6406type ResponseInputImage = {
6407 detail: "low" | "high" | "auto";
6408 type: "input_image";
6409 /**
6410 * Base64 encoded image
6411 */
6412 image_url?: string | null;
6413};
6414type ResponseInputImageContent = {
6415 type: "input_image";
6416 detail?: "low" | "high" | "auto" | null;
6417 /**
6418 * Base64 encoded image
6419 */
6420 image_url?: string | null;
6421};
6422type ResponseInputItem =
6423 | EasyInputMessage
6424 | ResponseInputItemMessage
6425 | ResponseOutputMessage
6426 | ResponseFunctionToolCall
6427 | ResponseInputItemFunctionCallOutput
6428 | ResponseReasoningItem;
6429type ResponseInputItemFunctionCallOutput = {
6430 call_id: string;
6431 output: string | ResponseFunctionCallOutputItemList;
6432 type: "function_call_output";
6433 id?: string | null;
6434 status?: "in_progress" | "completed" | "incomplete" | null;
6435};
6436type ResponseInputItemMessage = {
6437 content: ResponseInputMessageContentList;
6438 role: "user" | "system" | "developer";
6439 status?: "in_progress" | "completed" | "incomplete";
6440 type?: "message";
6441};
6442type ResponseInputMessageContentList = Array<ResponseInputContent>;
6443type ResponseInputMessageItem = {
6444 id: string;
6445 content: ResponseInputMessageContentList;
6446 role: "user" | "system" | "developer";
6447 status?: "in_progress" | "completed" | "incomplete";
6448 type?: "message";
6449};
6450type ResponseInputText = {
6451 text: string;
6452 type: "input_text";
6453};
6454type ResponseInputTextContent = {
6455 text: string;
6456 type: "input_text";
6457};
6458type ResponseItem =
6459 | ResponseInputMessageItem
6460 | ResponseOutputMessage
6461 | ResponseFunctionToolCallItem
6462 | ResponseFunctionToolCallOutputItem;
6463type ResponseOutputItem =
6464 | ResponseOutputMessage
6465 | ResponseFunctionToolCall
6466 | ResponseReasoningItem;
6467type ResponseOutputItemAddedEvent = {
6468 item: ResponseOutputItem;
6469 output_index: number;
6470 sequence_number: number;
6471 type: "response.output_item.added";
6472};
6473type ResponseOutputItemDoneEvent = {
6474 item: ResponseOutputItem;
6475 output_index: number;
6476 sequence_number: number;
6477 type: "response.output_item.done";
6478};
6479type ResponseOutputMessage = {
6480 id: string;
6481 content: Array<ResponseOutputText | ResponseOutputRefusal>;
6482 role: "assistant";
6483 status: "in_progress" | "completed" | "incomplete";
6484 type: "message";
6485};
6486type ResponseOutputRefusal = {
6487 refusal: string;
6488 type: "refusal";
6489};
6490type ResponseOutputText = {
6491 text: string;
6492 type: "output_text";
6493 logprobs?: Array<Logprob>;
6494};
6495type ResponseReasoningItem = {
6496 id: string;
6497 summary: Array<ResponseReasoningSummaryItem>;
6498 type: "reasoning";
6499 content?: Array<ResponseReasoningContentItem>;
6500 encrypted_content?: string | null;
6501 status?: "in_progress" | "completed" | "incomplete";
6502};
6503type ResponseReasoningSummaryItem = {
6504 text: string;
6505 type: "summary_text";
6506};
6507type ResponseReasoningContentItem = {
6508 text: string;
6509 type: "reasoning_text";
6510};
6511type ResponseReasoningTextDeltaEvent = {
6512 content_index: number;
6513 delta: string;
6514 item_id: string;
6515 output_index: number;
6516 sequence_number: number;
6517 type: "response.reasoning_text.delta";
6518};
6519type ResponseReasoningTextDoneEvent = {
6520 content_index: number;
6521 item_id: string;
6522 output_index: number;
6523 sequence_number: number;
6524 text: string;
6525 type: "response.reasoning_text.done";
6526};
6527type ResponseRefusalDeltaEvent = {
6528 content_index: number;
6529 delta: string;
6530 item_id: string;
6531 output_index: number;
6532 sequence_number: number;
6533 type: "response.refusal.delta";
6534};
6535type ResponseRefusalDoneEvent = {
6536 content_index: number;
6537 item_id: string;
6538 output_index: number;
6539 refusal: string;
6540 sequence_number: number;
6541 type: "response.refusal.done";
6542};
6543type ResponseStatus =
6544 | "completed"
6545 | "failed"
6546 | "in_progress"
6547 | "cancelled"
6548 | "queued"
6549 | "incomplete";
6550type ResponseStreamEvent =
6551 | ResponseCompletedEvent
6552 | ResponseCreatedEvent
6553 | ResponseErrorEvent
6554 | ResponseFunctionCallArgumentsDeltaEvent
6555 | ResponseFunctionCallArgumentsDoneEvent
6556 | ResponseFailedEvent
6557 | ResponseIncompleteEvent
6558 | ResponseOutputItemAddedEvent
6559 | ResponseOutputItemDoneEvent
6560 | ResponseReasoningTextDeltaEvent
6561 | ResponseReasoningTextDoneEvent
6562 | ResponseRefusalDeltaEvent
6563 | ResponseRefusalDoneEvent
6564 | ResponseTextDeltaEvent
6565 | ResponseTextDoneEvent;
6566type ResponseCompletedEvent = {
6567 response: Response;
6568 sequence_number: number;
6569 type: "response.completed";
6570};
6571type ResponseTextConfig = {
6572 format?: ResponseFormatTextConfig;
6573 verbosity?: "low" | "medium" | "high" | null;
6574};
6575type ResponseTextDeltaEvent = {
6576 content_index: number;
6577 delta: string;
6578 item_id: string;
6579 logprobs: Array<Logprob>;
6580 output_index: number;
6581 sequence_number: number;
6582 type: "response.output_text.delta";
6583};
6584type ResponseTextDoneEvent = {
6585 content_index: number;
6586 item_id: string;
6587 logprobs: Array<Logprob>;
6588 output_index: number;
6589 sequence_number: number;
6590 text: string;
6591 type: "response.output_text.done";
6592};
6593type Logprob = {
6594 token: string;
6595 logprob: number;
6596 top_logprobs?: Array<TopLogprob>;
6597};
6598type TopLogprob = {
6599 token?: string;
6600 logprob?: number;
6601};
6602type ResponseUsage = {
6603 input_tokens: number;
6604 output_tokens: number;
6605 total_tokens: number;
6606};
6607type Tool = ResponsesFunctionTool;
6608type ToolChoiceFunction = {
6609 name: string;
6610 type: "function";
6611};
6612type ToolChoiceOptions = "none";
6613type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
6614type StreamOptions = {
6615 include_obfuscation?: boolean;
6616};
6617/** Marks keys from T that aren't in U as optional never */
6618type Without<T, U> = {
6619 [P in Exclude<keyof T, keyof U>]?: never;
6620};
6621/** Either T or U, but not both (mutually exclusive) */
6622type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
6623type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
6624 | {
6625 text: string | string[];
6626 /**
6627 * 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.
6628 */
6629 pooling?: "mean" | "cls";
6630 }
6631 | {
6632 /**
6633 * Batch of the embeddings requests to run using async-queue
6634 */
6635 requests: {
6636 text: string | string[];
6637 /**
6638 * 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.
6639 */
6640 pooling?: "mean" | "cls";
6641 }[];
6642 };
6643type Ai_Cf_Baai_Bge_Base_En_V1_5_Output =
6644 | {
6645 shape?: number[];
6646 /**
6647 * Embeddings of the requested text values
6648 */
6649 data?: number[][];
6650 /**
6651 * The pooling method used in the embedding process.
6652 */
6653 pooling?: "mean" | "cls";
6654 }
6655 | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
6656interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
6657 /**
6658 * The async request id that can be used to obtain the results.
6659 */
6660 request_id?: string;
6661}
6662declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
6663 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
6664 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
6665}
6666type Ai_Cf_Openai_Whisper_Input =
6667 | string
6668 | {
6669 /**
6670 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6671 */
6672 audio: number[];
6673 };
6674interface Ai_Cf_Openai_Whisper_Output {
6675 /**
6676 * The transcription
6677 */
6678 text: string;
6679 word_count?: number;
6680 words?: {
6681 word?: string;
6682 /**
6683 * The second this word begins in the recording
6684 */
6685 start?: number;
6686 /**
6687 * The ending second when the word completes
6688 */
6689 end?: number;
6690 }[];
6691 vtt?: string;
6692}
6693declare abstract class Base_Ai_Cf_Openai_Whisper {
6694 inputs: Ai_Cf_Openai_Whisper_Input;
6695 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
6696}
6697type Ai_Cf_Meta_M2M100_1_2B_Input =
6698 | {
6699 /**
6700 * The text to be translated
6701 */
6702 text: string;
6703 /**
6704 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6705 */
6706 source_lang?: string;
6707 /**
6708 * The language code to translate the text into (e.g., 'es' for Spanish)
6709 */
6710 target_lang: string;
6711 }
6712 | {
6713 /**
6714 * Batch of the embeddings requests to run using async-queue
6715 */
6716 requests: {
6717 /**
6718 * The text to be translated
6719 */
6720 text: string;
6721 /**
6722 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6723 */
6724 source_lang?: string;
6725 /**
6726 * The language code to translate the text into (e.g., 'es' for Spanish)
6727 */
6728 target_lang: string;
6729 }[];
6730 };
6731type Ai_Cf_Meta_M2M100_1_2B_Output =
6732 | {
6733 /**
6734 * The translated text in the target language
6735 */
6736 translated_text?: string;
6737 }
6738 | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
6739interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
6740 /**
6741 * The async request id that can be used to obtain the results.
6742 */
6743 request_id?: string;
6744}
6745declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
6746 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
6747 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
6748}
6749type Ai_Cf_Baai_Bge_Small_En_V1_5_Input =
6750 | {
6751 text: string | string[];
6752 /**
6753 * 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.
6754 */
6755 pooling?: "mean" | "cls";
6756 }
6757 | {
6758 /**
6759 * Batch of the embeddings requests to run using async-queue
6760 */
6761 requests: {
6762 text: string | string[];
6763 /**
6764 * 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.
6765 */
6766 pooling?: "mean" | "cls";
6767 }[];
6768 };
6769type Ai_Cf_Baai_Bge_Small_En_V1_5_Output =
6770 | {
6771 shape?: number[];
6772 /**
6773 * Embeddings of the requested text values
6774 */
6775 data?: number[][];
6776 /**
6777 * The pooling method used in the embedding process.
6778 */
6779 pooling?: "mean" | "cls";
6780 }
6781 | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
6782interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
6783 /**
6784 * The async request id that can be used to obtain the results.
6785 */
6786 request_id?: string;
6787}
6788declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
6789 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
6790 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
6791}
6792type Ai_Cf_Baai_Bge_Large_En_V1_5_Input =
6793 | {
6794 text: string | string[];
6795 /**
6796 * 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.
6797 */
6798 pooling?: "mean" | "cls";
6799 }
6800 | {
6801 /**
6802 * Batch of the embeddings requests to run using async-queue
6803 */
6804 requests: {
6805 text: string | string[];
6806 /**
6807 * 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.
6808 */
6809 pooling?: "mean" | "cls";
6810 }[];
6811 };
6812type Ai_Cf_Baai_Bge_Large_En_V1_5_Output =
6813 | {
6814 shape?: number[];
6815 /**
6816 * Embeddings of the requested text values
6817 */
6818 data?: number[][];
6819 /**
6820 * The pooling method used in the embedding process.
6821 */
6822 pooling?: "mean" | "cls";
6823 }
6824 | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
6825interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
6826 /**
6827 * The async request id that can be used to obtain the results.
6828 */
6829 request_id?: string;
6830}
6831declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
6832 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
6833 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
6834}
6835type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input =
6836 | string
6837 | {
6838 /**
6839 * The input text prompt for the model to generate a response.
6840 */
6841 prompt?: string;
6842 /**
6843 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6844 */
6845 raw?: boolean;
6846 /**
6847 * 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.
6848 */
6849 top_p?: number;
6850 /**
6851 * 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.
6852 */
6853 top_k?: number;
6854 /**
6855 * Random seed for reproducibility of the generation.
6856 */
6857 seed?: number;
6858 /**
6859 * Penalty for repeated tokens; higher values discourage repetition.
6860 */
6861 repetition_penalty?: number;
6862 /**
6863 * Decreases the likelihood of the model repeating the same lines verbatim.
6864 */
6865 frequency_penalty?: number;
6866 /**
6867 * Increases the likelihood of the model introducing new topics.
6868 */
6869 presence_penalty?: number;
6870 image: number[] | (string & NonNullable<unknown>);
6871 /**
6872 * The maximum number of tokens to generate in the response.
6873 */
6874 max_tokens?: number;
6875 };
6876interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
6877 description?: string;
6878}
6879declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
6880 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
6881 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
6882}
6883type Ai_Cf_Openai_Whisper_Tiny_En_Input =
6884 | string
6885 | {
6886 /**
6887 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6888 */
6889 audio: number[];
6890 };
6891interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
6892 /**
6893 * The transcription
6894 */
6895 text: string;
6896 word_count?: number;
6897 words?: {
6898 word?: string;
6899 /**
6900 * The second this word begins in the recording
6901 */
6902 start?: number;
6903 /**
6904 * The ending second when the word completes
6905 */
6906 end?: number;
6907 }[];
6908 vtt?: string;
6909}
6910declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
6911 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
6912 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
6913}
6914interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
6915 audio:
6916 | string
6917 | {
6918 body?: object;
6919 contentType?: string;
6920 };
6921 /**
6922 * Supported tasks are 'translate' or 'transcribe'.
6923 */
6924 task?: string;
6925 /**
6926 * The language of the audio being transcribed or translated.
6927 */
6928 language?: string;
6929 /**
6930 * Preprocess the audio with a voice activity detection model.
6931 */
6932 vad_filter?: boolean;
6933 /**
6934 * A text prompt to help provide context to the model on the contents of the audio.
6935 */
6936 initial_prompt?: string;
6937 /**
6938 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
6939 */
6940 prefix?: string;
6941 /**
6942 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
6943 */
6944 beam_size?: number;
6945 /**
6946 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
6947 */
6948 condition_on_previous_text?: boolean;
6949 /**
6950 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
6951 */
6952 no_speech_threshold?: number;
6953 /**
6954 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
6955 */
6956 compression_ratio_threshold?: number;
6957 /**
6958 * Threshold for filtering out segments with low average log probability, indicating low confidence.
6959 */
6960 log_prob_threshold?: number;
6961 /**
6962 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
6963 */
6964 hallucination_silence_threshold?: number;
6965}
6966interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
6967 transcription_info?: {
6968 /**
6969 * The language of the audio being transcribed or translated.
6970 */
6971 language?: string;
6972 /**
6973 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
6974 */
6975 language_probability?: number;
6976 /**
6977 * The total duration of the original audio file, in seconds.
6978 */
6979 duration?: number;
6980 /**
6981 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
6982 */
6983 duration_after_vad?: number;
6984 };
6985 /**
6986 * The complete transcription of the audio.
6987 */
6988 text: string;
6989 /**
6990 * The total number of words in the transcription.
6991 */
6992 word_count?: number;
6993 segments?: {
6994 /**
6995 * The starting time of the segment within the audio, in seconds.
6996 */
6997 start?: number;
6998 /**
6999 * The ending time of the segment within the audio, in seconds.
7000 */
7001 end?: number;
7002 /**
7003 * The transcription of the segment.
7004 */
7005 text?: string;
7006 /**
7007 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
7008 */
7009 temperature?: number;
7010 /**
7011 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
7012 */
7013 avg_logprob?: number;
7014 /**
7015 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
7016 */
7017 compression_ratio?: number;
7018 /**
7019 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
7020 */
7021 no_speech_prob?: number;
7022 words?: {
7023 /**
7024 * The individual word transcribed from the audio.
7025 */
7026 word?: string;
7027 /**
7028 * The starting time of the word within the audio, in seconds.
7029 */
7030 start?: number;
7031 /**
7032 * The ending time of the word within the audio, in seconds.
7033 */
7034 end?: number;
7035 }[];
7036 }[];
7037 /**
7038 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
7039 */
7040 vtt?: string;
7041}
7042declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
7043 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
7044 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
7045}
7046type Ai_Cf_Baai_Bge_M3_Input =
7047 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts
7048 | Ai_Cf_Baai_Bge_M3_Input_Embedding
7049 | {
7050 /**
7051 * Batch of the embeddings requests to run using async-queue
7052 */
7053 requests: (
7054 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1
7055 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1
7056 )[];
7057 };
7058interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
7059 /**
7060 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
7061 */
7062 query?: string;
7063 /**
7064 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7065 */
7066 contexts: {
7067 /**
7068 * One of the provided context content
7069 */
7070 text?: string;
7071 }[];
7072 /**
7073 * When provided with too long context should the model error out or truncate the context to fit?
7074 */
7075 truncate_inputs?: boolean;
7076}
7077interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
7078 text: string | string[];
7079 /**
7080 * When provided with too long context should the model error out or truncate the context to fit?
7081 */
7082 truncate_inputs?: boolean;
7083}
7084interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
7085 /**
7086 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
7087 */
7088 query?: string;
7089 /**
7090 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7091 */
7092 contexts: {
7093 /**
7094 * One of the provided context content
7095 */
7096 text?: string;
7097 }[];
7098 /**
7099 * When provided with too long context should the model error out or truncate the context to fit?
7100 */
7101 truncate_inputs?: boolean;
7102}
7103interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
7104 text: string | string[];
7105 /**
7106 * When provided with too long context should the model error out or truncate the context to fit?
7107 */
7108 truncate_inputs?: boolean;
7109}
7110type Ai_Cf_Baai_Bge_M3_Output =
7111 | Ai_Cf_Baai_Bge_M3_Output_Query
7112 | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
7113 | Ai_Cf_Baai_Bge_M3_Output_Embedding
7114 | Ai_Cf_Baai_Bge_M3_AsyncResponse;
7115interface Ai_Cf_Baai_Bge_M3_Output_Query {
7116 response?: {
7117 /**
7118 * Index of the context in the request
7119 */
7120 id?: number;
7121 /**
7122 * Score of the context under the index.
7123 */
7124 score?: number;
7125 }[];
7126}
7127interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
7128 response?: number[][];
7129 shape?: number[];
7130 /**
7131 * The pooling method used in the embedding process.
7132 */
7133 pooling?: "mean" | "cls";
7134}
7135interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
7136 shape?: number[];
7137 /**
7138 * Embeddings of the requested text values
7139 */
7140 data?: number[][];
7141 /**
7142 * The pooling method used in the embedding process.
7143 */
7144 pooling?: "mean" | "cls";
7145}
7146interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
7147 /**
7148 * The async request id that can be used to obtain the results.
7149 */
7150 request_id?: string;
7151}
7152declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
7153 inputs: Ai_Cf_Baai_Bge_M3_Input;
7154 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
7155}
7156interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
7157 /**
7158 * A text description of the image you want to generate.
7159 */
7160 prompt: string;
7161 /**
7162 * The number of diffusion steps; higher values can improve quality but take longer.
7163 */
7164 steps?: number;
7165}
7166interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
7167 /**
7168 * The generated image in Base64 format.
7169 */
7170 image?: string;
7171}
7172declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
7173 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
7174 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
7175}
7176type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input =
7177 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt
7178 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
7179interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
7180 /**
7181 * The input text prompt for the model to generate a response.
7182 */
7183 prompt: string;
7184 image?: number[] | (string & NonNullable<unknown>);
7185 /**
7186 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7187 */
7188 raw?: boolean;
7189 /**
7190 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7191 */
7192 stream?: boolean;
7193 /**
7194 * The maximum number of tokens to generate in the response.
7195 */
7196 max_tokens?: number;
7197 /**
7198 * Controls the randomness of the output; higher values produce more random results.
7199 */
7200 temperature?: number;
7201 /**
7202 * 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.
7203 */
7204 top_p?: number;
7205 /**
7206 * 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.
7207 */
7208 top_k?: number;
7209 /**
7210 * Random seed for reproducibility of the generation.
7211 */
7212 seed?: number;
7213 /**
7214 * Penalty for repeated tokens; higher values discourage repetition.
7215 */
7216 repetition_penalty?: number;
7217 /**
7218 * Decreases the likelihood of the model repeating the same lines verbatim.
7219 */
7220 frequency_penalty?: number;
7221 /**
7222 * Increases the likelihood of the model introducing new topics.
7223 */
7224 presence_penalty?: number;
7225 /**
7226 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7227 */
7228 lora?: string;
7229}
7230interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
7231 /**
7232 * An array of message objects representing the conversation history.
7233 */
7234 messages: {
7235 /**
7236 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7237 */
7238 role?: string;
7239 /**
7240 * The tool call id. If you don't know what to put here you can fall back to 000000001
7241 */
7242 tool_call_id?: string;
7243 content?:
7244 | string
7245 | {
7246 /**
7247 * Type of the content provided
7248 */
7249 type?: string;
7250 text?: string;
7251 image_url?: {
7252 /**
7253 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7254 */
7255 url?: string;
7256 };
7257 }[]
7258 | {
7259 /**
7260 * Type of the content provided
7261 */
7262 type?: string;
7263 text?: string;
7264 image_url?: {
7265 /**
7266 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7267 */
7268 url?: string;
7269 };
7270 };
7271 }[];
7272 image?: number[] | (string & NonNullable<unknown>);
7273 functions?: {
7274 name: string;
7275 code: string;
7276 }[];
7277 /**
7278 * A list of tools available for the assistant to use.
7279 */
7280 tools?: (
7281 | {
7282 /**
7283 * The name of the tool. More descriptive the better.
7284 */
7285 name: string;
7286 /**
7287 * A brief description of what the tool does.
7288 */
7289 description: string;
7290 /**
7291 * Schema defining the parameters accepted by the tool.
7292 */
7293 parameters: {
7294 /**
7295 * The type of the parameters object (usually 'object').
7296 */
7297 type: string;
7298 /**
7299 * List of required parameter names.
7300 */
7301 required?: string[];
7302 /**
7303 * Definitions of each parameter.
7304 */
7305 properties: {
7306 [k: string]: {
7307 /**
7308 * The data type of the parameter.
7309 */
7310 type: string;
7311 /**
7312 * A description of the expected parameter.
7313 */
7314 description: string;
7315 };
7316 };
7317 };
7318 }
7319 | {
7320 /**
7321 * Specifies the type of tool (e.g., 'function').
7322 */
7323 type: string;
7324 /**
7325 * Details of the function tool.
7326 */
7327 function: {
7328 /**
7329 * The name of the function.
7330 */
7331 name: string;
7332 /**
7333 * A brief description of what the function does.
7334 */
7335 description: string;
7336 /**
7337 * Schema defining the parameters accepted by the function.
7338 */
7339 parameters: {
7340 /**
7341 * The type of the parameters object (usually 'object').
7342 */
7343 type: string;
7344 /**
7345 * List of required parameter names.
7346 */
7347 required?: string[];
7348 /**
7349 * Definitions of each parameter.
7350 */
7351 properties: {
7352 [k: string]: {
7353 /**
7354 * The data type of the parameter.
7355 */
7356 type: string;
7357 /**
7358 * A description of the expected parameter.
7359 */
7360 description: string;
7361 };
7362 };
7363 };
7364 };
7365 }
7366 )[];
7367 /**
7368 * If true, the response will be streamed back incrementally.
7369 */
7370 stream?: boolean;
7371 /**
7372 * The maximum number of tokens to generate in the response.
7373 */
7374 max_tokens?: number;
7375 /**
7376 * Controls the randomness of the output; higher values produce more random results.
7377 */
7378 temperature?: number;
7379 /**
7380 * 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.
7381 */
7382 top_p?: number;
7383 /**
7384 * 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.
7385 */
7386 top_k?: number;
7387 /**
7388 * Random seed for reproducibility of the generation.
7389 */
7390 seed?: number;
7391 /**
7392 * Penalty for repeated tokens; higher values discourage repetition.
7393 */
7394 repetition_penalty?: number;
7395 /**
7396 * Decreases the likelihood of the model repeating the same lines verbatim.
7397 */
7398 frequency_penalty?: number;
7399 /**
7400 * Increases the likelihood of the model introducing new topics.
7401 */
7402 presence_penalty?: number;
7403}
7404type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
7405 /**
7406 * The generated text response from the model
7407 */
7408 response?: string;
7409 /**
7410 * An array of tool calls requests made during the response generation
7411 */
7412 tool_calls?: {
7413 /**
7414 * The arguments passed to be passed to the tool call request
7415 */
7416 arguments?: object;
7417 /**
7418 * The name of the tool to be called
7419 */
7420 name?: string;
7421 }[];
7422};
7423declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
7424 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
7425 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
7426}
7427type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input =
7428 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt
7429 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages
7430 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
7431interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
7432 /**
7433 * The input text prompt for the model to generate a response.
7434 */
7435 prompt: string;
7436 /**
7437 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7438 */
7439 lora?: string;
7440 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
7441 /**
7442 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7443 */
7444 raw?: boolean;
7445 /**
7446 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7447 */
7448 stream?: boolean;
7449 /**
7450 * The maximum number of tokens to generate in the response.
7451 */
7452 max_tokens?: number;
7453 /**
7454 * Controls the randomness of the output; higher values produce more random results.
7455 */
7456 temperature?: number;
7457 /**
7458 * 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.
7459 */
7460 top_p?: number;
7461 /**
7462 * 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.
7463 */
7464 top_k?: number;
7465 /**
7466 * Random seed for reproducibility of the generation.
7467 */
7468 seed?: number;
7469 /**
7470 * Penalty for repeated tokens; higher values discourage repetition.
7471 */
7472 repetition_penalty?: number;
7473 /**
7474 * Decreases the likelihood of the model repeating the same lines verbatim.
7475 */
7476 frequency_penalty?: number;
7477 /**
7478 * Increases the likelihood of the model introducing new topics.
7479 */
7480 presence_penalty?: number;
7481}
7482interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
7483 type?: "json_object" | "json_schema";
7484 json_schema?: unknown;
7485}
7486interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
7487 /**
7488 * An array of message objects representing the conversation history.
7489 */
7490 messages: {
7491 /**
7492 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7493 */
7494 role: string;
7495 content:
7496 | string
7497 | {
7498 /**
7499 * Type of the content (text)
7500 */
7501 type?: string;
7502 /**
7503 * Text content
7504 */
7505 text?: string;
7506 }[];
7507 }[];
7508 functions?: {
7509 name: string;
7510 code: string;
7511 }[];
7512 /**
7513 * A list of tools available for the assistant to use.
7514 */
7515 tools?: (
7516 | {
7517 /**
7518 * The name of the tool. More descriptive the better.
7519 */
7520 name: string;
7521 /**
7522 * A brief description of what the tool does.
7523 */
7524 description: string;
7525 /**
7526 * Schema defining the parameters accepted by the tool.
7527 */
7528 parameters: {
7529 /**
7530 * The type of the parameters object (usually 'object').
7531 */
7532 type: string;
7533 /**
7534 * List of required parameter names.
7535 */
7536 required?: string[];
7537 /**
7538 * Definitions of each parameter.
7539 */
7540 properties: {
7541 [k: string]: {
7542 /**
7543 * The data type of the parameter.
7544 */
7545 type: string;
7546 /**
7547 * A description of the expected parameter.
7548 */
7549 description: string;
7550 };
7551 };
7552 };
7553 }
7554 | {
7555 /**
7556 * Specifies the type of tool (e.g., 'function').
7557 */
7558 type: string;
7559 /**
7560 * Details of the function tool.
7561 */
7562 function: {
7563 /**
7564 * The name of the function.
7565 */
7566 name: string;
7567 /**
7568 * A brief description of what the function does.
7569 */
7570 description: string;
7571 /**
7572 * Schema defining the parameters accepted by the function.
7573 */
7574 parameters: {
7575 /**
7576 * The type of the parameters object (usually 'object').
7577 */
7578 type: string;
7579 /**
7580 * List of required parameter names.
7581 */
7582 required?: string[];
7583 /**
7584 * Definitions of each parameter.
7585 */
7586 properties: {
7587 [k: string]: {
7588 /**
7589 * The data type of the parameter.
7590 */
7591 type: string;
7592 /**
7593 * A description of the expected parameter.
7594 */
7595 description: string;
7596 };
7597 };
7598 };
7599 };
7600 }
7601 )[];
7602 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
7603 /**
7604 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7605 */
7606 raw?: boolean;
7607 /**
7608 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7609 */
7610 stream?: boolean;
7611 /**
7612 * The maximum number of tokens to generate in the response.
7613 */
7614 max_tokens?: number;
7615 /**
7616 * Controls the randomness of the output; higher values produce more random results.
7617 */
7618 temperature?: number;
7619 /**
7620 * 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.
7621 */
7622 top_p?: number;
7623 /**
7624 * 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.
7625 */
7626 top_k?: number;
7627 /**
7628 * Random seed for reproducibility of the generation.
7629 */
7630 seed?: number;
7631 /**
7632 * Penalty for repeated tokens; higher values discourage repetition.
7633 */
7634 repetition_penalty?: number;
7635 /**
7636 * Decreases the likelihood of the model repeating the same lines verbatim.
7637 */
7638 frequency_penalty?: number;
7639 /**
7640 * Increases the likelihood of the model introducing new topics.
7641 */
7642 presence_penalty?: number;
7643}
7644interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
7645 type?: "json_object" | "json_schema";
7646 json_schema?: unknown;
7647}
7648interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
7649 requests?: {
7650 /**
7651 * 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.
7652 */
7653 external_reference?: string;
7654 /**
7655 * Prompt for the text generation model
7656 */
7657 prompt?: string;
7658 /**
7659 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7660 */
7661 stream?: boolean;
7662 /**
7663 * The maximum number of tokens to generate in the response.
7664 */
7665 max_tokens?: number;
7666 /**
7667 * Controls the randomness of the output; higher values produce more random results.
7668 */
7669 temperature?: number;
7670 /**
7671 * 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.
7672 */
7673 top_p?: number;
7674 /**
7675 * Random seed for reproducibility of the generation.
7676 */
7677 seed?: number;
7678 /**
7679 * Penalty for repeated tokens; higher values discourage repetition.
7680 */
7681 repetition_penalty?: number;
7682 /**
7683 * Decreases the likelihood of the model repeating the same lines verbatim.
7684 */
7685 frequency_penalty?: number;
7686 /**
7687 * Increases the likelihood of the model introducing new topics.
7688 */
7689 presence_penalty?: number;
7690 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
7691 }[];
7692}
7693interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
7694 type?: "json_object" | "json_schema";
7695 json_schema?: unknown;
7696}
7697type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output =
7698 | {
7699 /**
7700 * The generated text response from the model
7701 */
7702 response: string;
7703 /**
7704 * Usage statistics for the inference request
7705 */
7706 usage?: {
7707 /**
7708 * Total number of tokens in input
7709 */
7710 prompt_tokens?: number;
7711 /**
7712 * Total number of tokens in output
7713 */
7714 completion_tokens?: number;
7715 /**
7716 * Total number of input and output tokens
7717 */
7718 total_tokens?: number;
7719 };
7720 /**
7721 * An array of tool calls requests made during the response generation
7722 */
7723 tool_calls?: {
7724 /**
7725 * The arguments passed to be passed to the tool call request
7726 */
7727 arguments?: object;
7728 /**
7729 * The name of the tool to be called
7730 */
7731 name?: string;
7732 }[];
7733 }
7734 | string
7735 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
7736interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
7737 /**
7738 * The async request id that can be used to obtain the results.
7739 */
7740 request_id?: string;
7741}
7742declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
7743 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
7744 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
7745}
7746interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
7747 /**
7748 * An array of message objects representing the conversation history.
7749 */
7750 messages: {
7751 /**
7752 * The role of the message sender must alternate between 'user' and 'assistant'.
7753 */
7754 role: "user" | "assistant";
7755 /**
7756 * The content of the message as a string.
7757 */
7758 content: string;
7759 }[];
7760 /**
7761 * The maximum number of tokens to generate in the response.
7762 */
7763 max_tokens?: number;
7764 /**
7765 * Controls the randomness of the output; higher values produce more random results.
7766 */
7767 temperature?: number;
7768 /**
7769 * Dictate the output format of the generated response.
7770 */
7771 response_format?: {
7772 /**
7773 * Set to json_object to process and output generated text as JSON.
7774 */
7775 type?: string;
7776 };
7777}
7778interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
7779 response?:
7780 | string
7781 | {
7782 /**
7783 * Whether the conversation is safe or not.
7784 */
7785 safe?: boolean;
7786 /**
7787 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
7788 */
7789 categories?: string[];
7790 };
7791 /**
7792 * Usage statistics for the inference request
7793 */
7794 usage?: {
7795 /**
7796 * Total number of tokens in input
7797 */
7798 prompt_tokens?: number;
7799 /**
7800 * Total number of tokens in output
7801 */
7802 completion_tokens?: number;
7803 /**
7804 * Total number of input and output tokens
7805 */
7806 total_tokens?: number;
7807 };
7808}
7809declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
7810 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
7811 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
7812}
7813interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
7814 /**
7815 * A query you wish to perform against the provided contexts.
7816 */
7817 /**
7818 * Number of returned results starting with the best score.
7819 */
7820 top_k?: number;
7821 /**
7822 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7823 */
7824 contexts: {
7825 /**
7826 * One of the provided context content
7827 */
7828 text?: string;
7829 }[];
7830}
7831interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
7832 response?: {
7833 /**
7834 * Index of the context in the request
7835 */
7836 id?: number;
7837 /**
7838 * Score of the context under the index.
7839 */
7840 score?: number;
7841 }[];
7842}
7843declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
7844 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
7845 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
7846}
7847type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input =
7848 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt
7849 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
7850interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
7851 /**
7852 * The input text prompt for the model to generate a response.
7853 */
7854 prompt: string;
7855 /**
7856 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7857 */
7858 lora?: string;
7859 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
7860 /**
7861 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7862 */
7863 raw?: boolean;
7864 /**
7865 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7866 */
7867 stream?: boolean;
7868 /**
7869 * The maximum number of tokens to generate in the response.
7870 */
7871 max_tokens?: number;
7872 /**
7873 * Controls the randomness of the output; higher values produce more random results.
7874 */
7875 temperature?: number;
7876 /**
7877 * 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.
7878 */
7879 top_p?: number;
7880 /**
7881 * 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.
7882 */
7883 top_k?: number;
7884 /**
7885 * Random seed for reproducibility of the generation.
7886 */
7887 seed?: number;
7888 /**
7889 * Penalty for repeated tokens; higher values discourage repetition.
7890 */
7891 repetition_penalty?: number;
7892 /**
7893 * Decreases the likelihood of the model repeating the same lines verbatim.
7894 */
7895 frequency_penalty?: number;
7896 /**
7897 * Increases the likelihood of the model introducing new topics.
7898 */
7899 presence_penalty?: number;
7900}
7901interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
7902 type?: "json_object" | "json_schema";
7903 json_schema?: unknown;
7904}
7905interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
7906 /**
7907 * An array of message objects representing the conversation history.
7908 */
7909 messages: {
7910 /**
7911 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7912 */
7913 role: string;
7914 /**
7915 * The content of the message as a string.
7916 */
7917 content: string;
7918 }[];
7919 functions?: {
7920 name: string;
7921 code: string;
7922 }[];
7923 /**
7924 * A list of tools available for the assistant to use.
7925 */
7926 tools?: (
7927 | {
7928 /**
7929 * The name of the tool. More descriptive the better.
7930 */
7931 name: string;
7932 /**
7933 * A brief description of what the tool does.
7934 */
7935 description: string;
7936 /**
7937 * Schema defining the parameters accepted by the tool.
7938 */
7939 parameters: {
7940 /**
7941 * The type of the parameters object (usually 'object').
7942 */
7943 type: string;
7944 /**
7945 * List of required parameter names.
7946 */
7947 required?: string[];
7948 /**
7949 * Definitions of each parameter.
7950 */
7951 properties: {
7952 [k: string]: {
7953 /**
7954 * The data type of the parameter.
7955 */
7956 type: string;
7957 /**
7958 * A description of the expected parameter.
7959 */
7960 description: string;
7961 };
7962 };
7963 };
7964 }
7965 | {
7966 /**
7967 * Specifies the type of tool (e.g., 'function').
7968 */
7969 type: string;
7970 /**
7971 * Details of the function tool.
7972 */
7973 function: {
7974 /**
7975 * The name of the function.
7976 */
7977 name: string;
7978 /**
7979 * A brief description of what the function does.
7980 */
7981 description: string;
7982 /**
7983 * Schema defining the parameters accepted by the function.
7984 */
7985 parameters: {
7986 /**
7987 * The type of the parameters object (usually 'object').
7988 */
7989 type: string;
7990 /**
7991 * List of required parameter names.
7992 */
7993 required?: string[];
7994 /**
7995 * Definitions of each parameter.
7996 */
7997 properties: {
7998 [k: string]: {
7999 /**
8000 * The data type of the parameter.
8001 */
8002 type: string;
8003 /**
8004 * A description of the expected parameter.
8005 */
8006 description: string;
8007 };
8008 };
8009 };
8010 };
8011 }
8012 )[];
8013 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
8014 /**
8015 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8016 */
8017 raw?: boolean;
8018 /**
8019 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8020 */
8021 stream?: boolean;
8022 /**
8023 * The maximum number of tokens to generate in the response.
8024 */
8025 max_tokens?: number;
8026 /**
8027 * Controls the randomness of the output; higher values produce more random results.
8028 */
8029 temperature?: number;
8030 /**
8031 * 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.
8032 */
8033 top_p?: number;
8034 /**
8035 * 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.
8036 */
8037 top_k?: number;
8038 /**
8039 * Random seed for reproducibility of the generation.
8040 */
8041 seed?: number;
8042 /**
8043 * Penalty for repeated tokens; higher values discourage repetition.
8044 */
8045 repetition_penalty?: number;
8046 /**
8047 * Decreases the likelihood of the model repeating the same lines verbatim.
8048 */
8049 frequency_penalty?: number;
8050 /**
8051 * Increases the likelihood of the model introducing new topics.
8052 */
8053 presence_penalty?: number;
8054}
8055interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
8056 type?: "json_object" | "json_schema";
8057 json_schema?: unknown;
8058}
8059type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
8060 /**
8061 * The generated text response from the model
8062 */
8063 response: string;
8064 /**
8065 * Usage statistics for the inference request
8066 */
8067 usage?: {
8068 /**
8069 * Total number of tokens in input
8070 */
8071 prompt_tokens?: number;
8072 /**
8073 * Total number of tokens in output
8074 */
8075 completion_tokens?: number;
8076 /**
8077 * Total number of input and output tokens
8078 */
8079 total_tokens?: number;
8080 };
8081 /**
8082 * An array of tool calls requests made during the response generation
8083 */
8084 tool_calls?: {
8085 /**
8086 * The arguments passed to be passed to the tool call request
8087 */
8088 arguments?: object;
8089 /**
8090 * The name of the tool to be called
8091 */
8092 name?: string;
8093 }[];
8094};
8095declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
8096 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
8097 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
8098}
8099type Ai_Cf_Qwen_Qwq_32B_Input =
8100 | Ai_Cf_Qwen_Qwq_32B_Prompt
8101 | Ai_Cf_Qwen_Qwq_32B_Messages;
8102interface Ai_Cf_Qwen_Qwq_32B_Prompt {
8103 /**
8104 * The input text prompt for the model to generate a response.
8105 */
8106 prompt: string;
8107 /**
8108 * JSON schema that should be fulfilled for the response.
8109 */
8110 guided_json?: object;
8111 /**
8112 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8113 */
8114 raw?: boolean;
8115 /**
8116 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8117 */
8118 stream?: boolean;
8119 /**
8120 * The maximum number of tokens to generate in the response.
8121 */
8122 max_tokens?: number;
8123 /**
8124 * Controls the randomness of the output; higher values produce more random results.
8125 */
8126 temperature?: number;
8127 /**
8128 * 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.
8129 */
8130 top_p?: number;
8131 /**
8132 * 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.
8133 */
8134 top_k?: number;
8135 /**
8136 * Random seed for reproducibility of the generation.
8137 */
8138 seed?: number;
8139 /**
8140 * Penalty for repeated tokens; higher values discourage repetition.
8141 */
8142 repetition_penalty?: number;
8143 /**
8144 * Decreases the likelihood of the model repeating the same lines verbatim.
8145 */
8146 frequency_penalty?: number;
8147 /**
8148 * Increases the likelihood of the model introducing new topics.
8149 */
8150 presence_penalty?: number;
8151}
8152interface Ai_Cf_Qwen_Qwq_32B_Messages {
8153 /**
8154 * An array of message objects representing the conversation history.
8155 */
8156 messages: {
8157 /**
8158 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8159 */
8160 role?: string;
8161 /**
8162 * The tool call id. If you don't know what to put here you can fall back to 000000001
8163 */
8164 tool_call_id?: string;
8165 content?:
8166 | string
8167 | {
8168 /**
8169 * Type of the content provided
8170 */
8171 type?: string;
8172 text?: string;
8173 image_url?: {
8174 /**
8175 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8176 */
8177 url?: string;
8178 };
8179 }[]
8180 | {
8181 /**
8182 * Type of the content provided
8183 */
8184 type?: string;
8185 text?: string;
8186 image_url?: {
8187 /**
8188 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8189 */
8190 url?: string;
8191 };
8192 };
8193 }[];
8194 functions?: {
8195 name: string;
8196 code: string;
8197 }[];
8198 /**
8199 * A list of tools available for the assistant to use.
8200 */
8201 tools?: (
8202 | {
8203 /**
8204 * The name of the tool. More descriptive the better.
8205 */
8206 name: string;
8207 /**
8208 * A brief description of what the tool does.
8209 */
8210 description: string;
8211 /**
8212 * Schema defining the parameters accepted by the tool.
8213 */
8214 parameters: {
8215 /**
8216 * The type of the parameters object (usually 'object').
8217 */
8218 type: string;
8219 /**
8220 * List of required parameter names.
8221 */
8222 required?: string[];
8223 /**
8224 * Definitions of each parameter.
8225 */
8226 properties: {
8227 [k: string]: {
8228 /**
8229 * The data type of the parameter.
8230 */
8231 type: string;
8232 /**
8233 * A description of the expected parameter.
8234 */
8235 description: string;
8236 };
8237 };
8238 };
8239 }
8240 | {
8241 /**
8242 * Specifies the type of tool (e.g., 'function').
8243 */
8244 type: string;
8245 /**
8246 * Details of the function tool.
8247 */
8248 function: {
8249 /**
8250 * The name of the function.
8251 */
8252 name: string;
8253 /**
8254 * A brief description of what the function does.
8255 */
8256 description: string;
8257 /**
8258 * Schema defining the parameters accepted by the function.
8259 */
8260 parameters: {
8261 /**
8262 * The type of the parameters object (usually 'object').
8263 */
8264 type: string;
8265 /**
8266 * List of required parameter names.
8267 */
8268 required?: string[];
8269 /**
8270 * Definitions of each parameter.
8271 */
8272 properties: {
8273 [k: string]: {
8274 /**
8275 * The data type of the parameter.
8276 */
8277 type: string;
8278 /**
8279 * A description of the expected parameter.
8280 */
8281 description: string;
8282 };
8283 };
8284 };
8285 };
8286 }
8287 )[];
8288 /**
8289 * JSON schema that should be fufilled for the response.
8290 */
8291 guided_json?: object;
8292 /**
8293 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8294 */
8295 raw?: boolean;
8296 /**
8297 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8298 */
8299 stream?: boolean;
8300 /**
8301 * The maximum number of tokens to generate in the response.
8302 */
8303 max_tokens?: number;
8304 /**
8305 * Controls the randomness of the output; higher values produce more random results.
8306 */
8307 temperature?: number;
8308 /**
8309 * 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.
8310 */
8311 top_p?: number;
8312 /**
8313 * 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.
8314 */
8315 top_k?: number;
8316 /**
8317 * Random seed for reproducibility of the generation.
8318 */
8319 seed?: number;
8320 /**
8321 * Penalty for repeated tokens; higher values discourage repetition.
8322 */
8323 repetition_penalty?: number;
8324 /**
8325 * Decreases the likelihood of the model repeating the same lines verbatim.
8326 */
8327 frequency_penalty?: number;
8328 /**
8329 * Increases the likelihood of the model introducing new topics.
8330 */
8331 presence_penalty?: number;
8332}
8333type Ai_Cf_Qwen_Qwq_32B_Output = {
8334 /**
8335 * The generated text response from the model
8336 */
8337 response: string;
8338 /**
8339 * Usage statistics for the inference request
8340 */
8341 usage?: {
8342 /**
8343 * Total number of tokens in input
8344 */
8345 prompt_tokens?: number;
8346 /**
8347 * Total number of tokens in output
8348 */
8349 completion_tokens?: number;
8350 /**
8351 * Total number of input and output tokens
8352 */
8353 total_tokens?: number;
8354 };
8355 /**
8356 * An array of tool calls requests made during the response generation
8357 */
8358 tool_calls?: {
8359 /**
8360 * The arguments passed to be passed to the tool call request
8361 */
8362 arguments?: object;
8363 /**
8364 * The name of the tool to be called
8365 */
8366 name?: string;
8367 }[];
8368};
8369declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
8370 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
8371 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
8372}
8373type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input =
8374 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt
8375 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
8376interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
8377 /**
8378 * The input text prompt for the model to generate a response.
8379 */
8380 prompt: string;
8381 /**
8382 * JSON schema that should be fulfilled for the response.
8383 */
8384 guided_json?: object;
8385 /**
8386 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8387 */
8388 raw?: boolean;
8389 /**
8390 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8391 */
8392 stream?: boolean;
8393 /**
8394 * The maximum number of tokens to generate in the response.
8395 */
8396 max_tokens?: number;
8397 /**
8398 * Controls the randomness of the output; higher values produce more random results.
8399 */
8400 temperature?: number;
8401 /**
8402 * 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.
8403 */
8404 top_p?: number;
8405 /**
8406 * 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.
8407 */
8408 top_k?: number;
8409 /**
8410 * Random seed for reproducibility of the generation.
8411 */
8412 seed?: number;
8413 /**
8414 * Penalty for repeated tokens; higher values discourage repetition.
8415 */
8416 repetition_penalty?: number;
8417 /**
8418 * Decreases the likelihood of the model repeating the same lines verbatim.
8419 */
8420 frequency_penalty?: number;
8421 /**
8422 * Increases the likelihood of the model introducing new topics.
8423 */
8424 presence_penalty?: number;
8425}
8426interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
8427 /**
8428 * An array of message objects representing the conversation history.
8429 */
8430 messages: {
8431 /**
8432 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8433 */
8434 role?: string;
8435 /**
8436 * 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
8437 */
8438 tool_call_id?: string;
8439 content?:
8440 | string
8441 | {
8442 /**
8443 * Type of the content provided
8444 */
8445 type?: string;
8446 text?: string;
8447 image_url?: {
8448 /**
8449 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8450 */
8451 url?: string;
8452 };
8453 }[]
8454 | {
8455 /**
8456 * Type of the content provided
8457 */
8458 type?: string;
8459 text?: string;
8460 image_url?: {
8461 /**
8462 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8463 */
8464 url?: string;
8465 };
8466 };
8467 }[];
8468 functions?: {
8469 name: string;
8470 code: string;
8471 }[];
8472 /**
8473 * A list of tools available for the assistant to use.
8474 */
8475 tools?: (
8476 | {
8477 /**
8478 * The name of the tool. More descriptive the better.
8479 */
8480 name: string;
8481 /**
8482 * A brief description of what the tool does.
8483 */
8484 description: string;
8485 /**
8486 * Schema defining the parameters accepted by the tool.
8487 */
8488 parameters: {
8489 /**
8490 * The type of the parameters object (usually 'object').
8491 */
8492 type: string;
8493 /**
8494 * List of required parameter names.
8495 */
8496 required?: string[];
8497 /**
8498 * Definitions of each parameter.
8499 */
8500 properties: {
8501 [k: string]: {
8502 /**
8503 * The data type of the parameter.
8504 */
8505 type: string;
8506 /**
8507 * A description of the expected parameter.
8508 */
8509 description: string;
8510 };
8511 };
8512 };
8513 }
8514 | {
8515 /**
8516 * Specifies the type of tool (e.g., 'function').
8517 */
8518 type: string;
8519 /**
8520 * Details of the function tool.
8521 */
8522 function: {
8523 /**
8524 * The name of the function.
8525 */
8526 name: string;
8527 /**
8528 * A brief description of what the function does.
8529 */
8530 description: string;
8531 /**
8532 * Schema defining the parameters accepted by the function.
8533 */
8534 parameters: {
8535 /**
8536 * The type of the parameters object (usually 'object').
8537 */
8538 type: string;
8539 /**
8540 * List of required parameter names.
8541 */
8542 required?: string[];
8543 /**
8544 * Definitions of each parameter.
8545 */
8546 properties: {
8547 [k: string]: {
8548 /**
8549 * The data type of the parameter.
8550 */
8551 type: string;
8552 /**
8553 * A description of the expected parameter.
8554 */
8555 description: string;
8556 };
8557 };
8558 };
8559 };
8560 }
8561 )[];
8562 /**
8563 * JSON schema that should be fufilled for the response.
8564 */
8565 guided_json?: object;
8566 /**
8567 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8568 */
8569 raw?: boolean;
8570 /**
8571 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8572 */
8573 stream?: boolean;
8574 /**
8575 * The maximum number of tokens to generate in the response.
8576 */
8577 max_tokens?: number;
8578 /**
8579 * Controls the randomness of the output; higher values produce more random results.
8580 */
8581 temperature?: number;
8582 /**
8583 * 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.
8584 */
8585 top_p?: number;
8586 /**
8587 * 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.
8588 */
8589 top_k?: number;
8590 /**
8591 * Random seed for reproducibility of the generation.
8592 */
8593 seed?: number;
8594 /**
8595 * Penalty for repeated tokens; higher values discourage repetition.
8596 */
8597 repetition_penalty?: number;
8598 /**
8599 * Decreases the likelihood of the model repeating the same lines verbatim.
8600 */
8601 frequency_penalty?: number;
8602 /**
8603 * Increases the likelihood of the model introducing new topics.
8604 */
8605 presence_penalty?: number;
8606}
8607type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
8608 /**
8609 * The generated text response from the model
8610 */
8611 response: string;
8612 /**
8613 * Usage statistics for the inference request
8614 */
8615 usage?: {
8616 /**
8617 * Total number of tokens in input
8618 */
8619 prompt_tokens?: number;
8620 /**
8621 * Total number of tokens in output
8622 */
8623 completion_tokens?: number;
8624 /**
8625 * Total number of input and output tokens
8626 */
8627 total_tokens?: number;
8628 };
8629 /**
8630 * An array of tool calls requests made during the response generation
8631 */
8632 tool_calls?: {
8633 /**
8634 * The arguments passed to be passed to the tool call request
8635 */
8636 arguments?: object;
8637 /**
8638 * The name of the tool to be called
8639 */
8640 name?: string;
8641 }[];
8642};
8643declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
8644 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
8645 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
8646}
8647type Ai_Cf_Google_Gemma_3_12B_It_Input =
8648 | Ai_Cf_Google_Gemma_3_12B_It_Prompt
8649 | Ai_Cf_Google_Gemma_3_12B_It_Messages;
8650interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
8651 /**
8652 * The input text prompt for the model to generate a response.
8653 */
8654 prompt: string;
8655 /**
8656 * JSON schema that should be fufilled for the response.
8657 */
8658 guided_json?: object;
8659 /**
8660 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8661 */
8662 raw?: boolean;
8663 /**
8664 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8665 */
8666 stream?: boolean;
8667 /**
8668 * The maximum number of tokens to generate in the response.
8669 */
8670 max_tokens?: number;
8671 /**
8672 * Controls the randomness of the output; higher values produce more random results.
8673 */
8674 temperature?: number;
8675 /**
8676 * 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.
8677 */
8678 top_p?: number;
8679 /**
8680 * 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.
8681 */
8682 top_k?: number;
8683 /**
8684 * Random seed for reproducibility of the generation.
8685 */
8686 seed?: number;
8687 /**
8688 * Penalty for repeated tokens; higher values discourage repetition.
8689 */
8690 repetition_penalty?: number;
8691 /**
8692 * Decreases the likelihood of the model repeating the same lines verbatim.
8693 */
8694 frequency_penalty?: number;
8695 /**
8696 * Increases the likelihood of the model introducing new topics.
8697 */
8698 presence_penalty?: number;
8699}
8700interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
8701 /**
8702 * An array of message objects representing the conversation history.
8703 */
8704 messages: {
8705 /**
8706 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8707 */
8708 role?: string;
8709 content?:
8710 | string
8711 | {
8712 /**
8713 * Type of the content provided
8714 */
8715 type?: string;
8716 text?: string;
8717 image_url?: {
8718 /**
8719 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8720 */
8721 url?: string;
8722 };
8723 }[];
8724 }[];
8725 functions?: {
8726 name: string;
8727 code: string;
8728 }[];
8729 /**
8730 * A list of tools available for the assistant to use.
8731 */
8732 tools?: (
8733 | {
8734 /**
8735 * The name of the tool. More descriptive the better.
8736 */
8737 name: string;
8738 /**
8739 * A brief description of what the tool does.
8740 */
8741 description: string;
8742 /**
8743 * Schema defining the parameters accepted by the tool.
8744 */
8745 parameters: {
8746 /**
8747 * The type of the parameters object (usually 'object').
8748 */
8749 type: string;
8750 /**
8751 * List of required parameter names.
8752 */
8753 required?: string[];
8754 /**
8755 * Definitions of each parameter.
8756 */
8757 properties: {
8758 [k: string]: {
8759 /**
8760 * The data type of the parameter.
8761 */
8762 type: string;
8763 /**
8764 * A description of the expected parameter.
8765 */
8766 description: string;
8767 };
8768 };
8769 };
8770 }
8771 | {
8772 /**
8773 * Specifies the type of tool (e.g., 'function').
8774 */
8775 type: string;
8776 /**
8777 * Details of the function tool.
8778 */
8779 function: {
8780 /**
8781 * The name of the function.
8782 */
8783 name: string;
8784 /**
8785 * A brief description of what the function does.
8786 */
8787 description: string;
8788 /**
8789 * Schema defining the parameters accepted by the function.
8790 */
8791 parameters: {
8792 /**
8793 * The type of the parameters object (usually 'object').
8794 */
8795 type: string;
8796 /**
8797 * List of required parameter names.
8798 */
8799 required?: string[];
8800 /**
8801 * Definitions of each parameter.
8802 */
8803 properties: {
8804 [k: string]: {
8805 /**
8806 * The data type of the parameter.
8807 */
8808 type: string;
8809 /**
8810 * A description of the expected parameter.
8811 */
8812 description: string;
8813 };
8814 };
8815 };
8816 };
8817 }
8818 )[];
8819 /**
8820 * JSON schema that should be fufilled for the response.
8821 */
8822 guided_json?: object;
8823 /**
8824 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8825 */
8826 raw?: boolean;
8827 /**
8828 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8829 */
8830 stream?: boolean;
8831 /**
8832 * The maximum number of tokens to generate in the response.
8833 */
8834 max_tokens?: number;
8835 /**
8836 * Controls the randomness of the output; higher values produce more random results.
8837 */
8838 temperature?: number;
8839 /**
8840 * 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.
8841 */
8842 top_p?: number;
8843 /**
8844 * 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.
8845 */
8846 top_k?: number;
8847 /**
8848 * Random seed for reproducibility of the generation.
8849 */
8850 seed?: number;
8851 /**
8852 * Penalty for repeated tokens; higher values discourage repetition.
8853 */
8854 repetition_penalty?: number;
8855 /**
8856 * Decreases the likelihood of the model repeating the same lines verbatim.
8857 */
8858 frequency_penalty?: number;
8859 /**
8860 * Increases the likelihood of the model introducing new topics.
8861 */
8862 presence_penalty?: number;
8863}
8864type Ai_Cf_Google_Gemma_3_12B_It_Output = {
8865 /**
8866 * The generated text response from the model
8867 */
8868 response: string;
8869 /**
8870 * Usage statistics for the inference request
8871 */
8872 usage?: {
8873 /**
8874 * Total number of tokens in input
8875 */
8876 prompt_tokens?: number;
8877 /**
8878 * Total number of tokens in output
8879 */
8880 completion_tokens?: number;
8881 /**
8882 * Total number of input and output tokens
8883 */
8884 total_tokens?: number;
8885 };
8886 /**
8887 * An array of tool calls requests made during the response generation
8888 */
8889 tool_calls?: {
8890 /**
8891 * The arguments passed to be passed to the tool call request
8892 */
8893 arguments?: object;
8894 /**
8895 * The name of the tool to be called
8896 */
8897 name?: string;
8898 }[];
8899};
8900declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
8901 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
8902 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
8903}
8904type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input =
8905 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt
8906 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages
8907 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
8908interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
8909 /**
8910 * The input text prompt for the model to generate a response.
8911 */
8912 prompt: string;
8913 /**
8914 * JSON schema that should be fulfilled for the response.
8915 */
8916 guided_json?: object;
8917 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8918 /**
8919 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8920 */
8921 raw?: boolean;
8922 /**
8923 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8924 */
8925 stream?: boolean;
8926 /**
8927 * The maximum number of tokens to generate in the response.
8928 */
8929 max_tokens?: number;
8930 /**
8931 * Controls the randomness of the output; higher values produce more random results.
8932 */
8933 temperature?: number;
8934 /**
8935 * 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.
8936 */
8937 top_p?: number;
8938 /**
8939 * 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.
8940 */
8941 top_k?: number;
8942 /**
8943 * Random seed for reproducibility of the generation.
8944 */
8945 seed?: number;
8946 /**
8947 * Penalty for repeated tokens; higher values discourage repetition.
8948 */
8949 repetition_penalty?: number;
8950 /**
8951 * Decreases the likelihood of the model repeating the same lines verbatim.
8952 */
8953 frequency_penalty?: number;
8954 /**
8955 * Increases the likelihood of the model introducing new topics.
8956 */
8957 presence_penalty?: number;
8958}
8959interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
8960 type?: "json_object" | "json_schema";
8961 json_schema?: unknown;
8962}
8963interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
8964 /**
8965 * An array of message objects representing the conversation history.
8966 */
8967 messages: {
8968 /**
8969 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8970 */
8971 role?: string;
8972 /**
8973 * The tool call id. If you don't know what to put here you can fall back to 000000001
8974 */
8975 tool_call_id?: string;
8976 content?:
8977 | string
8978 | {
8979 /**
8980 * Type of the content provided
8981 */
8982 type?: string;
8983 text?: string;
8984 image_url?: {
8985 /**
8986 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8987 */
8988 url?: string;
8989 };
8990 }[]
8991 | {
8992 /**
8993 * Type of the content provided
8994 */
8995 type?: string;
8996 text?: string;
8997 image_url?: {
8998 /**
8999 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9000 */
9001 url?: string;
9002 };
9003 };
9004 }[];
9005 functions?: {
9006 name: string;
9007 code: string;
9008 }[];
9009 /**
9010 * A list of tools available for the assistant to use.
9011 */
9012 tools?: (
9013 | {
9014 /**
9015 * The name of the tool. More descriptive the better.
9016 */
9017 name: string;
9018 /**
9019 * A brief description of what the tool does.
9020 */
9021 description: string;
9022 /**
9023 * Schema defining the parameters accepted by the tool.
9024 */
9025 parameters: {
9026 /**
9027 * The type of the parameters object (usually 'object').
9028 */
9029 type: string;
9030 /**
9031 * List of required parameter names.
9032 */
9033 required?: string[];
9034 /**
9035 * Definitions of each parameter.
9036 */
9037 properties: {
9038 [k: string]: {
9039 /**
9040 * The data type of the parameter.
9041 */
9042 type: string;
9043 /**
9044 * A description of the expected parameter.
9045 */
9046 description: string;
9047 };
9048 };
9049 };
9050 }
9051 | {
9052 /**
9053 * Specifies the type of tool (e.g., 'function').
9054 */
9055 type: string;
9056 /**
9057 * Details of the function tool.
9058 */
9059 function: {
9060 /**
9061 * The name of the function.
9062 */
9063 name: string;
9064 /**
9065 * A brief description of what the function does.
9066 */
9067 description: string;
9068 /**
9069 * Schema defining the parameters accepted by the function.
9070 */
9071 parameters: {
9072 /**
9073 * The type of the parameters object (usually 'object').
9074 */
9075 type: string;
9076 /**
9077 * List of required parameter names.
9078 */
9079 required?: string[];
9080 /**
9081 * Definitions of each parameter.
9082 */
9083 properties: {
9084 [k: string]: {
9085 /**
9086 * The data type of the parameter.
9087 */
9088 type: string;
9089 /**
9090 * A description of the expected parameter.
9091 */
9092 description: string;
9093 };
9094 };
9095 };
9096 };
9097 }
9098 )[];
9099 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9100 /**
9101 * JSON schema that should be fufilled for the response.
9102 */
9103 guided_json?: object;
9104 /**
9105 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9106 */
9107 raw?: boolean;
9108 /**
9109 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9110 */
9111 stream?: boolean;
9112 /**
9113 * The maximum number of tokens to generate in the response.
9114 */
9115 max_tokens?: number;
9116 /**
9117 * Controls the randomness of the output; higher values produce more random results.
9118 */
9119 temperature?: number;
9120 /**
9121 * 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.
9122 */
9123 top_p?: number;
9124 /**
9125 * 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.
9126 */
9127 top_k?: number;
9128 /**
9129 * Random seed for reproducibility of the generation.
9130 */
9131 seed?: number;
9132 /**
9133 * Penalty for repeated tokens; higher values discourage repetition.
9134 */
9135 repetition_penalty?: number;
9136 /**
9137 * Decreases the likelihood of the model repeating the same lines verbatim.
9138 */
9139 frequency_penalty?: number;
9140 /**
9141 * Increases the likelihood of the model introducing new topics.
9142 */
9143 presence_penalty?: number;
9144}
9145interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
9146 requests: (
9147 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner
9148 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner
9149 )[];
9150}
9151interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
9152 /**
9153 * The input text prompt for the model to generate a response.
9154 */
9155 prompt: string;
9156 /**
9157 * JSON schema that should be fulfilled for the response.
9158 */
9159 guided_json?: object;
9160 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9161 /**
9162 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9163 */
9164 raw?: boolean;
9165 /**
9166 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9167 */
9168 stream?: boolean;
9169 /**
9170 * The maximum number of tokens to generate in the response.
9171 */
9172 max_tokens?: number;
9173 /**
9174 * Controls the randomness of the output; higher values produce more random results.
9175 */
9176 temperature?: number;
9177 /**
9178 * 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.
9179 */
9180 top_p?: number;
9181 /**
9182 * 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.
9183 */
9184 top_k?: number;
9185 /**
9186 * Random seed for reproducibility of the generation.
9187 */
9188 seed?: number;
9189 /**
9190 * Penalty for repeated tokens; higher values discourage repetition.
9191 */
9192 repetition_penalty?: number;
9193 /**
9194 * Decreases the likelihood of the model repeating the same lines verbatim.
9195 */
9196 frequency_penalty?: number;
9197 /**
9198 * Increases the likelihood of the model introducing new topics.
9199 */
9200 presence_penalty?: number;
9201}
9202interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
9203 /**
9204 * An array of message objects representing the conversation history.
9205 */
9206 messages: {
9207 /**
9208 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9209 */
9210 role?: string;
9211 /**
9212 * The tool call id. If you don't know what to put here you can fall back to 000000001
9213 */
9214 tool_call_id?: string;
9215 content?:
9216 | string
9217 | {
9218 /**
9219 * Type of the content provided
9220 */
9221 type?: string;
9222 text?: string;
9223 image_url?: {
9224 /**
9225 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9226 */
9227 url?: string;
9228 };
9229 }[]
9230 | {
9231 /**
9232 * Type of the content provided
9233 */
9234 type?: string;
9235 text?: string;
9236 image_url?: {
9237 /**
9238 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9239 */
9240 url?: string;
9241 };
9242 };
9243 }[];
9244 functions?: {
9245 name: string;
9246 code: string;
9247 }[];
9248 /**
9249 * A list of tools available for the assistant to use.
9250 */
9251 tools?: (
9252 | {
9253 /**
9254 * The name of the tool. More descriptive the better.
9255 */
9256 name: string;
9257 /**
9258 * A brief description of what the tool does.
9259 */
9260 description: string;
9261 /**
9262 * Schema defining the parameters accepted by the tool.
9263 */
9264 parameters: {
9265 /**
9266 * The type of the parameters object (usually 'object').
9267 */
9268 type: string;
9269 /**
9270 * List of required parameter names.
9271 */
9272 required?: string[];
9273 /**
9274 * Definitions of each parameter.
9275 */
9276 properties: {
9277 [k: string]: {
9278 /**
9279 * The data type of the parameter.
9280 */
9281 type: string;
9282 /**
9283 * A description of the expected parameter.
9284 */
9285 description: string;
9286 };
9287 };
9288 };
9289 }
9290 | {
9291 /**
9292 * Specifies the type of tool (e.g., 'function').
9293 */
9294 type: string;
9295 /**
9296 * Details of the function tool.
9297 */
9298 function: {
9299 /**
9300 * The name of the function.
9301 */
9302 name: string;
9303 /**
9304 * A brief description of what the function does.
9305 */
9306 description: string;
9307 /**
9308 * Schema defining the parameters accepted by the function.
9309 */
9310 parameters: {
9311 /**
9312 * The type of the parameters object (usually 'object').
9313 */
9314 type: string;
9315 /**
9316 * List of required parameter names.
9317 */
9318 required?: string[];
9319 /**
9320 * Definitions of each parameter.
9321 */
9322 properties: {
9323 [k: string]: {
9324 /**
9325 * The data type of the parameter.
9326 */
9327 type: string;
9328 /**
9329 * A description of the expected parameter.
9330 */
9331 description: string;
9332 };
9333 };
9334 };
9335 };
9336 }
9337 )[];
9338 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9339 /**
9340 * JSON schema that should be fufilled for the response.
9341 */
9342 guided_json?: object;
9343 /**
9344 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9345 */
9346 raw?: boolean;
9347 /**
9348 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9349 */
9350 stream?: boolean;
9351 /**
9352 * The maximum number of tokens to generate in the response.
9353 */
9354 max_tokens?: number;
9355 /**
9356 * Controls the randomness of the output; higher values produce more random results.
9357 */
9358 temperature?: number;
9359 /**
9360 * 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.
9361 */
9362 top_p?: number;
9363 /**
9364 * 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.
9365 */
9366 top_k?: number;
9367 /**
9368 * Random seed for reproducibility of the generation.
9369 */
9370 seed?: number;
9371 /**
9372 * Penalty for repeated tokens; higher values discourage repetition.
9373 */
9374 repetition_penalty?: number;
9375 /**
9376 * Decreases the likelihood of the model repeating the same lines verbatim.
9377 */
9378 frequency_penalty?: number;
9379 /**
9380 * Increases the likelihood of the model introducing new topics.
9381 */
9382 presence_penalty?: number;
9383}
9384type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
9385 /**
9386 * The generated text response from the model
9387 */
9388 response: string;
9389 /**
9390 * Usage statistics for the inference request
9391 */
9392 usage?: {
9393 /**
9394 * Total number of tokens in input
9395 */
9396 prompt_tokens?: number;
9397 /**
9398 * Total number of tokens in output
9399 */
9400 completion_tokens?: number;
9401 /**
9402 * Total number of input and output tokens
9403 */
9404 total_tokens?: number;
9405 };
9406 /**
9407 * An array of tool calls requests made during the response generation
9408 */
9409 tool_calls?: {
9410 /**
9411 * The tool call id.
9412 */
9413 id?: string;
9414 /**
9415 * Specifies the type of tool (e.g., 'function').
9416 */
9417 type?: string;
9418 /**
9419 * Details of the function tool.
9420 */
9421 function?: {
9422 /**
9423 * The name of the tool to be called
9424 */
9425 name?: string;
9426 /**
9427 * The arguments passed to be passed to the tool call request
9428 */
9429 arguments?: object;
9430 };
9431 }[];
9432};
9433declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
9434 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
9435 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
9436}
9437type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input =
9438 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt
9439 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages
9440 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
9441interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
9442 /**
9443 * The input text prompt for the model to generate a response.
9444 */
9445 prompt: string;
9446 /**
9447 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9448 */
9449 lora?: string;
9450 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
9451 /**
9452 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9453 */
9454 raw?: boolean;
9455 /**
9456 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9457 */
9458 stream?: boolean;
9459 /**
9460 * The maximum number of tokens to generate in the response.
9461 */
9462 max_tokens?: number;
9463 /**
9464 * Controls the randomness of the output; higher values produce more random results.
9465 */
9466 temperature?: number;
9467 /**
9468 * 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.
9469 */
9470 top_p?: number;
9471 /**
9472 * 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.
9473 */
9474 top_k?: number;
9475 /**
9476 * Random seed for reproducibility of the generation.
9477 */
9478 seed?: number;
9479 /**
9480 * Penalty for repeated tokens; higher values discourage repetition.
9481 */
9482 repetition_penalty?: number;
9483 /**
9484 * Decreases the likelihood of the model repeating the same lines verbatim.
9485 */
9486 frequency_penalty?: number;
9487 /**
9488 * Increases the likelihood of the model introducing new topics.
9489 */
9490 presence_penalty?: number;
9491}
9492interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
9493 type?: "json_object" | "json_schema";
9494 json_schema?: unknown;
9495}
9496interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
9497 /**
9498 * An array of message objects representing the conversation history.
9499 */
9500 messages: {
9501 /**
9502 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9503 */
9504 role: string;
9505 content:
9506 | string
9507 | {
9508 /**
9509 * Type of the content (text)
9510 */
9511 type?: string;
9512 /**
9513 * Text content
9514 */
9515 text?: string;
9516 }[];
9517 }[];
9518 functions?: {
9519 name: string;
9520 code: string;
9521 }[];
9522 /**
9523 * A list of tools available for the assistant to use.
9524 */
9525 tools?: (
9526 | {
9527 /**
9528 * The name of the tool. More descriptive the better.
9529 */
9530 name: string;
9531 /**
9532 * A brief description of what the tool does.
9533 */
9534 description: string;
9535 /**
9536 * Schema defining the parameters accepted by the tool.
9537 */
9538 parameters: {
9539 /**
9540 * The type of the parameters object (usually 'object').
9541 */
9542 type: string;
9543 /**
9544 * List of required parameter names.
9545 */
9546 required?: string[];
9547 /**
9548 * Definitions of each parameter.
9549 */
9550 properties: {
9551 [k: string]: {
9552 /**
9553 * The data type of the parameter.
9554 */
9555 type: string;
9556 /**
9557 * A description of the expected parameter.
9558 */
9559 description: string;
9560 };
9561 };
9562 };
9563 }
9564 | {
9565 /**
9566 * Specifies the type of tool (e.g., 'function').
9567 */
9568 type: string;
9569 /**
9570 * Details of the function tool.
9571 */
9572 function: {
9573 /**
9574 * The name of the function.
9575 */
9576 name: string;
9577 /**
9578 * A brief description of what the function does.
9579 */
9580 description: string;
9581 /**
9582 * Schema defining the parameters accepted by the function.
9583 */
9584 parameters: {
9585 /**
9586 * The type of the parameters object (usually 'object').
9587 */
9588 type: string;
9589 /**
9590 * List of required parameter names.
9591 */
9592 required?: string[];
9593 /**
9594 * Definitions of each parameter.
9595 */
9596 properties: {
9597 [k: string]: {
9598 /**
9599 * The data type of the parameter.
9600 */
9601 type: string;
9602 /**
9603 * A description of the expected parameter.
9604 */
9605 description: string;
9606 };
9607 };
9608 };
9609 };
9610 }
9611 )[];
9612 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
9613 /**
9614 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9615 */
9616 raw?: boolean;
9617 /**
9618 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9619 */
9620 stream?: boolean;
9621 /**
9622 * The maximum number of tokens to generate in the response.
9623 */
9624 max_tokens?: number;
9625 /**
9626 * Controls the randomness of the output; higher values produce more random results.
9627 */
9628 temperature?: number;
9629 /**
9630 * 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.
9631 */
9632 top_p?: number;
9633 /**
9634 * 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.
9635 */
9636 top_k?: number;
9637 /**
9638 * Random seed for reproducibility of the generation.
9639 */
9640 seed?: number;
9641 /**
9642 * Penalty for repeated tokens; higher values discourage repetition.
9643 */
9644 repetition_penalty?: number;
9645 /**
9646 * Decreases the likelihood of the model repeating the same lines verbatim.
9647 */
9648 frequency_penalty?: number;
9649 /**
9650 * Increases the likelihood of the model introducing new topics.
9651 */
9652 presence_penalty?: number;
9653}
9654interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
9655 type?: "json_object" | "json_schema";
9656 json_schema?: unknown;
9657}
9658interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
9659 requests: (
9660 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1
9661 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1
9662 )[];
9663}
9664interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
9665 /**
9666 * The input text prompt for the model to generate a response.
9667 */
9668 prompt: string;
9669 /**
9670 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9671 */
9672 lora?: string;
9673 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
9674 /**
9675 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9676 */
9677 raw?: boolean;
9678 /**
9679 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9680 */
9681 stream?: boolean;
9682 /**
9683 * The maximum number of tokens to generate in the response.
9684 */
9685 max_tokens?: number;
9686 /**
9687 * Controls the randomness of the output; higher values produce more random results.
9688 */
9689 temperature?: number;
9690 /**
9691 * 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.
9692 */
9693 top_p?: number;
9694 /**
9695 * 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.
9696 */
9697 top_k?: number;
9698 /**
9699 * Random seed for reproducibility of the generation.
9700 */
9701 seed?: number;
9702 /**
9703 * Penalty for repeated tokens; higher values discourage repetition.
9704 */
9705 repetition_penalty?: number;
9706 /**
9707 * Decreases the likelihood of the model repeating the same lines verbatim.
9708 */
9709 frequency_penalty?: number;
9710 /**
9711 * Increases the likelihood of the model introducing new topics.
9712 */
9713 presence_penalty?: number;
9714}
9715interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
9716 type?: "json_object" | "json_schema";
9717 json_schema?: unknown;
9718}
9719interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
9720 /**
9721 * An array of message objects representing the conversation history.
9722 */
9723 messages: {
9724 /**
9725 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9726 */
9727 role: string;
9728 content:
9729 | string
9730 | {
9731 /**
9732 * Type of the content (text)
9733 */
9734 type?: string;
9735 /**
9736 * Text content
9737 */
9738 text?: string;
9739 }[];
9740 }[];
9741 functions?: {
9742 name: string;
9743 code: string;
9744 }[];
9745 /**
9746 * A list of tools available for the assistant to use.
9747 */
9748 tools?: (
9749 | {
9750 /**
9751 * The name of the tool. More descriptive the better.
9752 */
9753 name: string;
9754 /**
9755 * A brief description of what the tool does.
9756 */
9757 description: string;
9758 /**
9759 * Schema defining the parameters accepted by the tool.
9760 */
9761 parameters: {
9762 /**
9763 * The type of the parameters object (usually 'object').
9764 */
9765 type: string;
9766 /**
9767 * List of required parameter names.
9768 */
9769 required?: string[];
9770 /**
9771 * Definitions of each parameter.
9772 */
9773 properties: {
9774 [k: string]: {
9775 /**
9776 * The data type of the parameter.
9777 */
9778 type: string;
9779 /**
9780 * A description of the expected parameter.
9781 */
9782 description: string;
9783 };
9784 };
9785 };
9786 }
9787 | {
9788 /**
9789 * Specifies the type of tool (e.g., 'function').
9790 */
9791 type: string;
9792 /**
9793 * Details of the function tool.
9794 */
9795 function: {
9796 /**
9797 * The name of the function.
9798 */
9799 name: string;
9800 /**
9801 * A brief description of what the function does.
9802 */
9803 description: string;
9804 /**
9805 * Schema defining the parameters accepted by the function.
9806 */
9807 parameters: {
9808 /**
9809 * The type of the parameters object (usually 'object').
9810 */
9811 type: string;
9812 /**
9813 * List of required parameter names.
9814 */
9815 required?: string[];
9816 /**
9817 * Definitions of each parameter.
9818 */
9819 properties: {
9820 [k: string]: {
9821 /**
9822 * The data type of the parameter.
9823 */
9824 type: string;
9825 /**
9826 * A description of the expected parameter.
9827 */
9828 description: string;
9829 };
9830 };
9831 };
9832 };
9833 }
9834 )[];
9835 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
9836 /**
9837 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9838 */
9839 raw?: boolean;
9840 /**
9841 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9842 */
9843 stream?: boolean;
9844 /**
9845 * The maximum number of tokens to generate in the response.
9846 */
9847 max_tokens?: number;
9848 /**
9849 * Controls the randomness of the output; higher values produce more random results.
9850 */
9851 temperature?: number;
9852 /**
9853 * 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.
9854 */
9855 top_p?: number;
9856 /**
9857 * 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.
9858 */
9859 top_k?: number;
9860 /**
9861 * Random seed for reproducibility of the generation.
9862 */
9863 seed?: number;
9864 /**
9865 * Penalty for repeated tokens; higher values discourage repetition.
9866 */
9867 repetition_penalty?: number;
9868 /**
9869 * Decreases the likelihood of the model repeating the same lines verbatim.
9870 */
9871 frequency_penalty?: number;
9872 /**
9873 * Increases the likelihood of the model introducing new topics.
9874 */
9875 presence_penalty?: number;
9876}
9877interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
9878 type?: "json_object" | "json_schema";
9879 json_schema?: unknown;
9880}
9881type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output =
9882 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response
9883 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response
9884 | string
9885 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
9886interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
9887 /**
9888 * Unique identifier for the completion
9889 */
9890 id?: string;
9891 /**
9892 * Object type identifier
9893 */
9894 object?: "chat.completion";
9895 /**
9896 * Unix timestamp of when the completion was created
9897 */
9898 created?: number;
9899 /**
9900 * Model used for the completion
9901 */
9902 model?: string;
9903 /**
9904 * List of completion choices
9905 */
9906 choices?: {
9907 /**
9908 * Index of the choice in the list
9909 */
9910 index?: number;
9911 /**
9912 * The message generated by the model
9913 */
9914 message?: {
9915 /**
9916 * Role of the message author
9917 */
9918 role: string;
9919 /**
9920 * The content of the message
9921 */
9922 content: string;
9923 /**
9924 * Internal reasoning content (if available)
9925 */
9926 reasoning_content?: string;
9927 /**
9928 * Tool calls made by the assistant
9929 */
9930 tool_calls?: {
9931 /**
9932 * Unique identifier for the tool call
9933 */
9934 id: string;
9935 /**
9936 * Type of tool call
9937 */
9938 type: "function";
9939 function: {
9940 /**
9941 * Name of the function to call
9942 */
9943 name: string;
9944 /**
9945 * JSON string of arguments for the function
9946 */
9947 arguments: string;
9948 };
9949 }[];
9950 };
9951 /**
9952 * Reason why the model stopped generating
9953 */
9954 finish_reason?: string;
9955 /**
9956 * Stop reason (may be null)
9957 */
9958 stop_reason?: string | null;
9959 /**
9960 * Log probabilities (if requested)
9961 */
9962 logprobs?: {} | null;
9963 }[];
9964 /**
9965 * Usage statistics for the inference request
9966 */
9967 usage?: {
9968 /**
9969 * Total number of tokens in input
9970 */
9971 prompt_tokens?: number;
9972 /**
9973 * Total number of tokens in output
9974 */
9975 completion_tokens?: number;
9976 /**
9977 * Total number of input and output tokens
9978 */
9979 total_tokens?: number;
9980 };
9981 /**
9982 * Log probabilities for the prompt (if requested)
9983 */
9984 prompt_logprobs?: {} | null;
9985}
9986interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
9987 /**
9988 * Unique identifier for the completion
9989 */
9990 id?: string;
9991 /**
9992 * Object type identifier
9993 */
9994 object?: "text_completion";
9995 /**
9996 * Unix timestamp of when the completion was created
9997 */
9998 created?: number;
9999 /**
10000 * Model used for the completion
10001 */
10002 model?: string;
10003 /**
10004 * List of completion choices
10005 */
10006 choices?: {
10007 /**
10008 * Index of the choice in the list
10009 */
10010 index: number;
10011 /**
10012 * The generated text completion
10013 */
10014 text: string;
10015 /**
10016 * Reason why the model stopped generating
10017 */
10018 finish_reason: string;
10019 /**
10020 * Stop reason (may be null)
10021 */
10022 stop_reason?: string | null;
10023 /**
10024 * Log probabilities (if requested)
10025 */
10026 logprobs?: {} | null;
10027 /**
10028 * Log probabilities for the prompt (if requested)
10029 */
10030 prompt_logprobs?: {} | null;
10031 }[];
10032 /**
10033 * Usage statistics for the inference request
10034 */
10035 usage?: {
10036 /**
10037 * Total number of tokens in input
10038 */
10039 prompt_tokens?: number;
10040 /**
10041 * Total number of tokens in output
10042 */
10043 completion_tokens?: number;
10044 /**
10045 * Total number of input and output tokens
10046 */
10047 total_tokens?: number;
10048 };
10049}
10050interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
10051 /**
10052 * The async request id that can be used to obtain the results.
10053 */
10054 request_id?: string;
10055}
10056declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
10057 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
10058 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
10059}
10060interface Ai_Cf_Deepgram_Nova_3_Input {
10061 audio: {
10062 body: object;
10063 contentType: string;
10064 };
10065 /**
10066 * 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.
10067 */
10068 custom_topic_mode?: "extended" | "strict";
10069 /**
10070 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
10071 */
10072 custom_topic?: string;
10073 /**
10074 * 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
10075 */
10076 custom_intent_mode?: "extended" | "strict";
10077 /**
10078 * Custom intents you want the model to detect within your input audio if present
10079 */
10080 custom_intent?: string;
10081 /**
10082 * Identifies and extracts key entities from content in submitted audio
10083 */
10084 detect_entities?: boolean;
10085 /**
10086 * Identifies the dominant language spoken in submitted audio
10087 */
10088 detect_language?: boolean;
10089 /**
10090 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
10091 */
10092 diarize?: boolean;
10093 /**
10094 * Identify and extract key entities from content in submitted audio
10095 */
10096 dictation?: boolean;
10097 /**
10098 * Specify the expected encoding of your submitted audio
10099 */
10100 encoding?:
10101 | "linear16"
10102 | "flac"
10103 | "mulaw"
10104 | "amr-nb"
10105 | "amr-wb"
10106 | "opus"
10107 | "speex"
10108 | "g729";
10109 /**
10110 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
10111 */
10112 extra?: string;
10113 /**
10114 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
10115 */
10116 filler_words?: boolean;
10117 /**
10118 * Key term prompting can boost or suppress specialized terminology and brands.
10119 */
10120 keyterm?: string;
10121 /**
10122 * Keywords can boost or suppress specialized terminology and brands.
10123 */
10124 keywords?: string;
10125 /**
10126 * 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.
10127 */
10128 language?: string;
10129 /**
10130 * Spoken measurements will be converted to their corresponding abbreviations.
10131 */
10132 measurements?: boolean;
10133 /**
10134 * 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.
10135 */
10136 mip_opt_out?: boolean;
10137 /**
10138 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
10139 */
10140 mode?: "general" | "medical" | "finance";
10141 /**
10142 * Transcribe each audio channel independently.
10143 */
10144 multichannel?: boolean;
10145 /**
10146 * Numerals converts numbers from written format to numerical format.
10147 */
10148 numerals?: boolean;
10149 /**
10150 * Splits audio into paragraphs to improve transcript readability.
10151 */
10152 paragraphs?: boolean;
10153 /**
10154 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
10155 */
10156 profanity_filter?: boolean;
10157 /**
10158 * Add punctuation and capitalization to the transcript.
10159 */
10160 punctuate?: boolean;
10161 /**
10162 * Redaction removes sensitive information from your transcripts.
10163 */
10164 redact?: string;
10165 /**
10166 * Search for terms or phrases in submitted audio and replaces them.
10167 */
10168 replace?: string;
10169 /**
10170 * Search for terms or phrases in submitted audio.
10171 */
10172 search?: string;
10173 /**
10174 * Recognizes the sentiment throughout a transcript or text.
10175 */
10176 sentiment?: boolean;
10177 /**
10178 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
10179 */
10180 smart_format?: boolean;
10181 /**
10182 * Detect topics throughout a transcript or text.
10183 */
10184 topics?: boolean;
10185 /**
10186 * Segments speech into meaningful semantic units.
10187 */
10188 utterances?: boolean;
10189 /**
10190 * Seconds to wait before detecting a pause between words in submitted audio.
10191 */
10192 utt_split?: number;
10193 /**
10194 * The number of channels in the submitted audio
10195 */
10196 channels?: number;
10197 /**
10198 * 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.
10199 */
10200 interim_results?: boolean;
10201 /**
10202 * 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
10203 */
10204 endpointing?: string;
10205 /**
10206 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
10207 */
10208 vad_events?: boolean;
10209 /**
10210 * 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.
10211 */
10212 utterance_end_ms?: boolean;
10213}
10214interface Ai_Cf_Deepgram_Nova_3_Output {
10215 results?: {
10216 channels?: {
10217 alternatives?: {
10218 confidence?: number;
10219 transcript?: string;
10220 words?: {
10221 confidence?: number;
10222 end?: number;
10223 start?: number;
10224 word?: string;
10225 }[];
10226 }[];
10227 }[];
10228 summary?: {
10229 result?: string;
10230 short?: string;
10231 };
10232 sentiments?: {
10233 segments?: {
10234 text?: string;
10235 start_word?: number;
10236 end_word?: number;
10237 sentiment?: string;
10238 sentiment_score?: number;
10239 }[];
10240 average?: {
10241 sentiment?: string;
10242 sentiment_score?: number;
10243 };
10244 };
10245 };
10246}
10247declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
10248 inputs: Ai_Cf_Deepgram_Nova_3_Input;
10249 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
10250}
10251interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
10252 queries?: string | string[];
10253 /**
10254 * Optional instruction for the task
10255 */
10256 instruction?: string;
10257 documents?: string | string[];
10258 text?: string | string[];
10259}
10260interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
10261 data?: number[][];
10262 shape?: number[];
10263}
10264declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
10265 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
10266 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
10267}
10268type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input =
10269 | {
10270 /**
10271 * readable stream with audio data and content-type specified for that data
10272 */
10273 audio: {
10274 body: object;
10275 contentType: string;
10276 };
10277 /**
10278 * type of data PCM data that's sent to the inference server as raw array
10279 */
10280 dtype?: "uint8" | "float32" | "float64";
10281 }
10282 | {
10283 /**
10284 * base64 encoded audio data
10285 */
10286 audio: string;
10287 /**
10288 * type of data PCM data that's sent to the inference server as raw array
10289 */
10290 dtype?: "uint8" | "float32" | "float64";
10291 };
10292interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
10293 /**
10294 * if true, end-of-turn was detected
10295 */
10296 is_complete?: boolean;
10297 /**
10298 * probability of the end-of-turn detection
10299 */
10300 probability?: number;
10301}
10302declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
10303 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
10304 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
10305}
10306declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
10307 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
10308 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
10309}
10310declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
10311 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
10312 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
10313}
10314interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
10315 /**
10316 * A text description of the image you want to generate.
10317 */
10318 prompt: string;
10319 /**
10320 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
10321 */
10322 guidance?: number;
10323 /**
10324 * Random seed for reproducibility of the image generation
10325 */
10326 seed?: number;
10327 /**
10328 * The height of the generated image in pixels
10329 */
10330 height?: number;
10331 /**
10332 * The width of the generated image in pixels
10333 */
10334 width?: number;
10335 /**
10336 * The number of diffusion steps; higher values can improve quality but take longer
10337 */
10338 num_steps?: number;
10339 /**
10340 * Specify what to exclude from the generated images
10341 */
10342 negative_prompt?: string;
10343}
10344/**
10345 * The generated image in JPEG format
10346 */
10347type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
10348declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
10349 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
10350 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
10351}
10352interface Ai_Cf_Leonardo_Lucid_Origin_Input {
10353 /**
10354 * A text description of the image you want to generate.
10355 */
10356 prompt: string;
10357 /**
10358 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
10359 */
10360 guidance?: number;
10361 /**
10362 * Random seed for reproducibility of the image generation
10363 */
10364 seed?: number;
10365 /**
10366 * The height of the generated image in pixels
10367 */
10368 height?: number;
10369 /**
10370 * The width of the generated image in pixels
10371 */
10372 width?: number;
10373 /**
10374 * The number of diffusion steps; higher values can improve quality but take longer
10375 */
10376 num_steps?: number;
10377 /**
10378 * The number of diffusion steps; higher values can improve quality but take longer
10379 */
10380 steps?: number;
10381}
10382interface Ai_Cf_Leonardo_Lucid_Origin_Output {
10383 /**
10384 * The generated image in Base64 format.
10385 */
10386 image?: string;
10387}
10388declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
10389 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
10390 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
10391}
10392interface Ai_Cf_Deepgram_Aura_1_Input {
10393 /**
10394 * Speaker used to produce the audio.
10395 */
10396 speaker?:
10397 | "angus"
10398 | "asteria"
10399 | "arcas"
10400 | "orion"
10401 | "orpheus"
10402 | "athena"
10403 | "luna"
10404 | "zeus"
10405 | "perseus"
10406 | "helios"
10407 | "hera"
10408 | "stella";
10409 /**
10410 * Encoding of the output audio.
10411 */
10412 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10413 /**
10414 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10415 */
10416 container?: "none" | "wav" | "ogg";
10417 /**
10418 * The text content to be converted to speech
10419 */
10420 text: string;
10421 /**
10422 * 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
10423 */
10424 sample_rate?: number;
10425 /**
10426 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10427 */
10428 bit_rate?: number;
10429}
10430/**
10431 * The generated audio in MP3 format
10432 */
10433type Ai_Cf_Deepgram_Aura_1_Output = string;
10434declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
10435 inputs: Ai_Cf_Deepgram_Aura_1_Input;
10436 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
10437}
10438interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
10439 /**
10440 * Input text to translate. Can be a single string or a list of strings.
10441 */
10442 text: string | string[];
10443 /**
10444 * Target langauge to translate to
10445 */
10446 target_language:
10447 | "asm_Beng"
10448 | "awa_Deva"
10449 | "ben_Beng"
10450 | "bho_Deva"
10451 | "brx_Deva"
10452 | "doi_Deva"
10453 | "eng_Latn"
10454 | "gom_Deva"
10455 | "gon_Deva"
10456 | "guj_Gujr"
10457 | "hin_Deva"
10458 | "hne_Deva"
10459 | "kan_Knda"
10460 | "kas_Arab"
10461 | "kas_Deva"
10462 | "kha_Latn"
10463 | "lus_Latn"
10464 | "mag_Deva"
10465 | "mai_Deva"
10466 | "mal_Mlym"
10467 | "mar_Deva"
10468 | "mni_Beng"
10469 | "mni_Mtei"
10470 | "npi_Deva"
10471 | "ory_Orya"
10472 | "pan_Guru"
10473 | "san_Deva"
10474 | "sat_Olck"
10475 | "snd_Arab"
10476 | "snd_Deva"
10477 | "tam_Taml"
10478 | "tel_Telu"
10479 | "urd_Arab"
10480 | "unr_Deva";
10481}
10482interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
10483 /**
10484 * Translated texts
10485 */
10486 translations: string[];
10487}
10488declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
10489 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
10490 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
10491}
10492type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input =
10493 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt
10494 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages
10495 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
10496interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
10497 /**
10498 * The input text prompt for the model to generate a response.
10499 */
10500 prompt: string;
10501 /**
10502 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10503 */
10504 lora?: string;
10505 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
10506 /**
10507 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10508 */
10509 raw?: boolean;
10510 /**
10511 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10512 */
10513 stream?: boolean;
10514 /**
10515 * The maximum number of tokens to generate in the response.
10516 */
10517 max_tokens?: number;
10518 /**
10519 * Controls the randomness of the output; higher values produce more random results.
10520 */
10521 temperature?: number;
10522 /**
10523 * 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.
10524 */
10525 top_p?: number;
10526 /**
10527 * 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.
10528 */
10529 top_k?: number;
10530 /**
10531 * Random seed for reproducibility of the generation.
10532 */
10533 seed?: number;
10534 /**
10535 * Penalty for repeated tokens; higher values discourage repetition.
10536 */
10537 repetition_penalty?: number;
10538 /**
10539 * Decreases the likelihood of the model repeating the same lines verbatim.
10540 */
10541 frequency_penalty?: number;
10542 /**
10543 * Increases the likelihood of the model introducing new topics.
10544 */
10545 presence_penalty?: number;
10546}
10547interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
10548 type?: "json_object" | "json_schema";
10549 json_schema?: unknown;
10550}
10551interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
10552 /**
10553 * An array of message objects representing the conversation history.
10554 */
10555 messages: {
10556 /**
10557 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10558 */
10559 role: string;
10560 content:
10561 | string
10562 | {
10563 /**
10564 * Type of the content (text)
10565 */
10566 type?: string;
10567 /**
10568 * Text content
10569 */
10570 text?: string;
10571 }[];
10572 }[];
10573 functions?: {
10574 name: string;
10575 code: string;
10576 }[];
10577 /**
10578 * A list of tools available for the assistant to use.
10579 */
10580 tools?: (
10581 | {
10582 /**
10583 * The name of the tool. More descriptive the better.
10584 */
10585 name: string;
10586 /**
10587 * A brief description of what the tool does.
10588 */
10589 description: string;
10590 /**
10591 * Schema defining the parameters accepted by the tool.
10592 */
10593 parameters: {
10594 /**
10595 * The type of the parameters object (usually 'object').
10596 */
10597 type: string;
10598 /**
10599 * List of required parameter names.
10600 */
10601 required?: string[];
10602 /**
10603 * Definitions of each parameter.
10604 */
10605 properties: {
10606 [k: string]: {
10607 /**
10608 * The data type of the parameter.
10609 */
10610 type: string;
10611 /**
10612 * A description of the expected parameter.
10613 */
10614 description: string;
10615 };
10616 };
10617 };
10618 }
10619 | {
10620 /**
10621 * Specifies the type of tool (e.g., 'function').
10622 */
10623 type: string;
10624 /**
10625 * Details of the function tool.
10626 */
10627 function: {
10628 /**
10629 * The name of the function.
10630 */
10631 name: string;
10632 /**
10633 * A brief description of what the function does.
10634 */
10635 description: string;
10636 /**
10637 * Schema defining the parameters accepted by the function.
10638 */
10639 parameters: {
10640 /**
10641 * The type of the parameters object (usually 'object').
10642 */
10643 type: string;
10644 /**
10645 * List of required parameter names.
10646 */
10647 required?: string[];
10648 /**
10649 * Definitions of each parameter.
10650 */
10651 properties: {
10652 [k: string]: {
10653 /**
10654 * The data type of the parameter.
10655 */
10656 type: string;
10657 /**
10658 * A description of the expected parameter.
10659 */
10660 description: string;
10661 };
10662 };
10663 };
10664 };
10665 }
10666 )[];
10667 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
10668 /**
10669 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10670 */
10671 raw?: boolean;
10672 /**
10673 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10674 */
10675 stream?: boolean;
10676 /**
10677 * The maximum number of tokens to generate in the response.
10678 */
10679 max_tokens?: number;
10680 /**
10681 * Controls the randomness of the output; higher values produce more random results.
10682 */
10683 temperature?: number;
10684 /**
10685 * 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.
10686 */
10687 top_p?: number;
10688 /**
10689 * 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.
10690 */
10691 top_k?: number;
10692 /**
10693 * Random seed for reproducibility of the generation.
10694 */
10695 seed?: number;
10696 /**
10697 * Penalty for repeated tokens; higher values discourage repetition.
10698 */
10699 repetition_penalty?: number;
10700 /**
10701 * Decreases the likelihood of the model repeating the same lines verbatim.
10702 */
10703 frequency_penalty?: number;
10704 /**
10705 * Increases the likelihood of the model introducing new topics.
10706 */
10707 presence_penalty?: number;
10708}
10709interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
10710 type?: "json_object" | "json_schema";
10711 json_schema?: unknown;
10712}
10713interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
10714 requests: (
10715 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1
10716 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1
10717 )[];
10718}
10719interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
10720 /**
10721 * The input text prompt for the model to generate a response.
10722 */
10723 prompt: string;
10724 /**
10725 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10726 */
10727 lora?: string;
10728 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
10729 /**
10730 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10731 */
10732 raw?: boolean;
10733 /**
10734 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10735 */
10736 stream?: boolean;
10737 /**
10738 * The maximum number of tokens to generate in the response.
10739 */
10740 max_tokens?: number;
10741 /**
10742 * Controls the randomness of the output; higher values produce more random results.
10743 */
10744 temperature?: number;
10745 /**
10746 * 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.
10747 */
10748 top_p?: number;
10749 /**
10750 * 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.
10751 */
10752 top_k?: number;
10753 /**
10754 * Random seed for reproducibility of the generation.
10755 */
10756 seed?: number;
10757 /**
10758 * Penalty for repeated tokens; higher values discourage repetition.
10759 */
10760 repetition_penalty?: number;
10761 /**
10762 * Decreases the likelihood of the model repeating the same lines verbatim.
10763 */
10764 frequency_penalty?: number;
10765 /**
10766 * Increases the likelihood of the model introducing new topics.
10767 */
10768 presence_penalty?: number;
10769}
10770interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
10771 type?: "json_object" | "json_schema";
10772 json_schema?: unknown;
10773}
10774interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
10775 /**
10776 * An array of message objects representing the conversation history.
10777 */
10778 messages: {
10779 /**
10780 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10781 */
10782 role: string;
10783 content:
10784 | string
10785 | {
10786 /**
10787 * Type of the content (text)
10788 */
10789 type?: string;
10790 /**
10791 * Text content
10792 */
10793 text?: string;
10794 }[];
10795 }[];
10796 functions?: {
10797 name: string;
10798 code: string;
10799 }[];
10800 /**
10801 * A list of tools available for the assistant to use.
10802 */
10803 tools?: (
10804 | {
10805 /**
10806 * The name of the tool. More descriptive the better.
10807 */
10808 name: string;
10809 /**
10810 * A brief description of what the tool does.
10811 */
10812 description: string;
10813 /**
10814 * Schema defining the parameters accepted by the tool.
10815 */
10816 parameters: {
10817 /**
10818 * The type of the parameters object (usually 'object').
10819 */
10820 type: string;
10821 /**
10822 * List of required parameter names.
10823 */
10824 required?: string[];
10825 /**
10826 * Definitions of each parameter.
10827 */
10828 properties: {
10829 [k: string]: {
10830 /**
10831 * The data type of the parameter.
10832 */
10833 type: string;
10834 /**
10835 * A description of the expected parameter.
10836 */
10837 description: string;
10838 };
10839 };
10840 };
10841 }
10842 | {
10843 /**
10844 * Specifies the type of tool (e.g., 'function').
10845 */
10846 type: string;
10847 /**
10848 * Details of the function tool.
10849 */
10850 function: {
10851 /**
10852 * The name of the function.
10853 */
10854 name: string;
10855 /**
10856 * A brief description of what the function does.
10857 */
10858 description: string;
10859 /**
10860 * Schema defining the parameters accepted by the function.
10861 */
10862 parameters: {
10863 /**
10864 * The type of the parameters object (usually 'object').
10865 */
10866 type: string;
10867 /**
10868 * List of required parameter names.
10869 */
10870 required?: string[];
10871 /**
10872 * Definitions of each parameter.
10873 */
10874 properties: {
10875 [k: string]: {
10876 /**
10877 * The data type of the parameter.
10878 */
10879 type: string;
10880 /**
10881 * A description of the expected parameter.
10882 */
10883 description: string;
10884 };
10885 };
10886 };
10887 };
10888 }
10889 )[];
10890 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
10891 /**
10892 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10893 */
10894 raw?: boolean;
10895 /**
10896 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10897 */
10898 stream?: boolean;
10899 /**
10900 * The maximum number of tokens to generate in the response.
10901 */
10902 max_tokens?: number;
10903 /**
10904 * Controls the randomness of the output; higher values produce more random results.
10905 */
10906 temperature?: number;
10907 /**
10908 * 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.
10909 */
10910 top_p?: number;
10911 /**
10912 * 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.
10913 */
10914 top_k?: number;
10915 /**
10916 * Random seed for reproducibility of the generation.
10917 */
10918 seed?: number;
10919 /**
10920 * Penalty for repeated tokens; higher values discourage repetition.
10921 */
10922 repetition_penalty?: number;
10923 /**
10924 * Decreases the likelihood of the model repeating the same lines verbatim.
10925 */
10926 frequency_penalty?: number;
10927 /**
10928 * Increases the likelihood of the model introducing new topics.
10929 */
10930 presence_penalty?: number;
10931}
10932interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
10933 type?: "json_object" | "json_schema";
10934 json_schema?: unknown;
10935}
10936type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output =
10937 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response
10938 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response
10939 | string
10940 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
10941interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
10942 /**
10943 * Unique identifier for the completion
10944 */
10945 id?: string;
10946 /**
10947 * Object type identifier
10948 */
10949 object?: "chat.completion";
10950 /**
10951 * Unix timestamp of when the completion was created
10952 */
10953 created?: number;
10954 /**
10955 * Model used for the completion
10956 */
10957 model?: string;
10958 /**
10959 * List of completion choices
10960 */
10961 choices?: {
10962 /**
10963 * Index of the choice in the list
10964 */
10965 index?: number;
10966 /**
10967 * The message generated by the model
10968 */
10969 message?: {
10970 /**
10971 * Role of the message author
10972 */
10973 role: string;
10974 /**
10975 * The content of the message
10976 */
10977 content: string;
10978 /**
10979 * Internal reasoning content (if available)
10980 */
10981 reasoning_content?: string;
10982 /**
10983 * Tool calls made by the assistant
10984 */
10985 tool_calls?: {
10986 /**
10987 * Unique identifier for the tool call
10988 */
10989 id: string;
10990 /**
10991 * Type of tool call
10992 */
10993 type: "function";
10994 function: {
10995 /**
10996 * Name of the function to call
10997 */
10998 name: string;
10999 /**
11000 * JSON string of arguments for the function
11001 */
11002 arguments: string;
11003 };
11004 }[];
11005 };
11006 /**
11007 * Reason why the model stopped generating
11008 */
11009 finish_reason?: string;
11010 /**
11011 * Stop reason (may be null)
11012 */
11013 stop_reason?: string | null;
11014 /**
11015 * Log probabilities (if requested)
11016 */
11017 logprobs?: {} | null;
11018 }[];
11019 /**
11020 * Usage statistics for the inference request
11021 */
11022 usage?: {
11023 /**
11024 * Total number of tokens in input
11025 */
11026 prompt_tokens?: number;
11027 /**
11028 * Total number of tokens in output
11029 */
11030 completion_tokens?: number;
11031 /**
11032 * Total number of input and output tokens
11033 */
11034 total_tokens?: number;
11035 };
11036 /**
11037 * Log probabilities for the prompt (if requested)
11038 */
11039 prompt_logprobs?: {} | null;
11040}
11041interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
11042 /**
11043 * Unique identifier for the completion
11044 */
11045 id?: string;
11046 /**
11047 * Object type identifier
11048 */
11049 object?: "text_completion";
11050 /**
11051 * Unix timestamp of when the completion was created
11052 */
11053 created?: number;
11054 /**
11055 * Model used for the completion
11056 */
11057 model?: string;
11058 /**
11059 * List of completion choices
11060 */
11061 choices?: {
11062 /**
11063 * Index of the choice in the list
11064 */
11065 index: number;
11066 /**
11067 * The generated text completion
11068 */
11069 text: string;
11070 /**
11071 * Reason why the model stopped generating
11072 */
11073 finish_reason: string;
11074 /**
11075 * Stop reason (may be null)
11076 */
11077 stop_reason?: string | null;
11078 /**
11079 * Log probabilities (if requested)
11080 */
11081 logprobs?: {} | null;
11082 /**
11083 * Log probabilities for the prompt (if requested)
11084 */
11085 prompt_logprobs?: {} | null;
11086 }[];
11087 /**
11088 * Usage statistics for the inference request
11089 */
11090 usage?: {
11091 /**
11092 * Total number of tokens in input
11093 */
11094 prompt_tokens?: number;
11095 /**
11096 * Total number of tokens in output
11097 */
11098 completion_tokens?: number;
11099 /**
11100 * Total number of input and output tokens
11101 */
11102 total_tokens?: number;
11103 };
11104}
11105interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
11106 /**
11107 * The async request id that can be used to obtain the results.
11108 */
11109 request_id?: string;
11110}
11111declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
11112 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
11113 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
11114}
11115interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
11116 /**
11117 * Input text to embed. Can be a single string or a list of strings.
11118 */
11119 text: string | string[];
11120}
11121interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
11122 /**
11123 * Embedding vectors, where each vector is a list of floats.
11124 */
11125 data: number[][];
11126 /**
11127 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
11128 *
11129 * @minItems 2
11130 * @maxItems 2
11131 */
11132 shape: [number, number];
11133}
11134declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
11135 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
11136 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
11137}
11138interface Ai_Cf_Deepgram_Flux_Input {
11139 /**
11140 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
11141 */
11142 encoding: "linear16";
11143 /**
11144 * Sample rate of the audio stream in Hz.
11145 */
11146 sample_rate: string;
11147 /**
11148 * 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.
11149 */
11150 eager_eot_threshold?: string;
11151 /**
11152 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
11153 */
11154 eot_threshold?: string;
11155 /**
11156 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
11157 */
11158 eot_timeout_ms?: string;
11159 /**
11160 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
11161 */
11162 keyterm?: string;
11163 /**
11164 * 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
11165 */
11166 mip_opt_out?: "true" | "false";
11167 /**
11168 * Label your requests for the purpose of identification during usage reporting
11169 */
11170 tag?: string;
11171}
11172/**
11173 * Output will be returned as websocket messages.
11174 */
11175interface Ai_Cf_Deepgram_Flux_Output {
11176 /**
11177 * The unique identifier of the request (uuid)
11178 */
11179 request_id?: string;
11180 /**
11181 * Starts at 0 and increments for each message the server sends to the client.
11182 */
11183 sequence_id?: number;
11184 /**
11185 * The type of event being reported.
11186 */
11187 event?:
11188 | "Update"
11189 | "StartOfTurn"
11190 | "EagerEndOfTurn"
11191 | "TurnResumed"
11192 | "EndOfTurn";
11193 /**
11194 * The index of the current turn
11195 */
11196 turn_index?: number;
11197 /**
11198 * Start time in seconds of the audio range that was transcribed
11199 */
11200 audio_window_start?: number;
11201 /**
11202 * End time in seconds of the audio range that was transcribed
11203 */
11204 audio_window_end?: number;
11205 /**
11206 * Text that was said over the course of the current turn
11207 */
11208 transcript?: string;
11209 /**
11210 * The words in the transcript
11211 */
11212 words?: {
11213 /**
11214 * The individual punctuated, properly-cased word from the transcript
11215 */
11216 word: string;
11217 /**
11218 * Confidence that this word was transcribed correctly
11219 */
11220 confidence: number;
11221 }[];
11222 /**
11223 * Confidence that no more speech is coming in this turn
11224 */
11225 end_of_turn_confidence?: number;
11226}
11227declare abstract class Base_Ai_Cf_Deepgram_Flux {
11228 inputs: Ai_Cf_Deepgram_Flux_Input;
11229 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
11230}
11231interface Ai_Cf_Deepgram_Aura_2_En_Input {
11232 /**
11233 * Speaker used to produce the audio.
11234 */
11235 speaker?:
11236 | "amalthea"
11237 | "andromeda"
11238 | "apollo"
11239 | "arcas"
11240 | "aries"
11241 | "asteria"
11242 | "athena"
11243 | "atlas"
11244 | "aurora"
11245 | "callista"
11246 | "cora"
11247 | "cordelia"
11248 | "delia"
11249 | "draco"
11250 | "electra"
11251 | "harmonia"
11252 | "helena"
11253 | "hera"
11254 | "hermes"
11255 | "hyperion"
11256 | "iris"
11257 | "janus"
11258 | "juno"
11259 | "jupiter"
11260 | "luna"
11261 | "mars"
11262 | "minerva"
11263 | "neptune"
11264 | "odysseus"
11265 | "ophelia"
11266 | "orion"
11267 | "orpheus"
11268 | "pandora"
11269 | "phoebe"
11270 | "pluto"
11271 | "saturn"
11272 | "thalia"
11273 | "theia"
11274 | "vesta"
11275 | "zeus";
11276 /**
11277 * Encoding of the output audio.
11278 */
11279 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
11280 /**
11281 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
11282 */
11283 container?: "none" | "wav" | "ogg";
11284 /**
11285 * The text content to be converted to speech
11286 */
11287 text: string;
11288 /**
11289 * 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
11290 */
11291 sample_rate?: number;
11292 /**
11293 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
11294 */
11295 bit_rate?: number;
11296}
11297/**
11298 * The generated audio in MP3 format
11299 */
11300type Ai_Cf_Deepgram_Aura_2_En_Output = string;
11301declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
11302 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
11303 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
11304}
11305interface Ai_Cf_Deepgram_Aura_2_Es_Input {
11306 /**
11307 * Speaker used to produce the audio.
11308 */
11309 speaker?:
11310 | "sirio"
11311 | "nestor"
11312 | "carina"
11313 | "celeste"
11314 | "alvaro"
11315 | "diana"
11316 | "aquila"
11317 | "selena"
11318 | "estrella"
11319 | "javier";
11320 /**
11321 * Encoding of the output audio.
11322 */
11323 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
11324 /**
11325 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
11326 */
11327 container?: "none" | "wav" | "ogg";
11328 /**
11329 * The text content to be converted to speech
11330 */
11331 text: string;
11332 /**
11333 * 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
11334 */
11335 sample_rate?: number;
11336 /**
11337 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
11338 */
11339 bit_rate?: number;
11340}
11341/**
11342 * The generated audio in MP3 format
11343 */
11344type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
11345declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
11346 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
11347 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
11348}
11349interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
11350 multipart: {
11351 body?: object;
11352 contentType?: string;
11353 };
11354}
11355interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
11356 /**
11357 * Generated image as Base64 string.
11358 */
11359 image?: string;
11360}
11361declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
11362 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
11363 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
11364}
11365interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
11366 multipart: {
11367 body?: object;
11368 contentType?: string;
11369 };
11370}
11371interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
11372 /**
11373 * Generated image as Base64 string.
11374 */
11375 image?: string;
11376}
11377declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
11378 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
11379 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
11380}
11381interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
11382 multipart: {
11383 body?: object;
11384 contentType?: string;
11385 };
11386}
11387interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
11388 /**
11389 * Generated image as Base64 string.
11390 */
11391 image?: string;
11392}
11393declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
11394 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
11395 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
11396}
11397declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
11398 inputs: ChatCompletionsInput;
11399 postProcessedOutputs: ChatCompletionsOutput;
11400}
11401declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
11402 inputs: ChatCompletionsInput;
11403 postProcessedOutputs: ChatCompletionsOutput;
11404}
11405declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
11406 inputs: ChatCompletionsInput;
11407 postProcessedOutputs: ChatCompletionsOutput;
11408}
11409declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
11410 inputs: ChatCompletionsInput;
11411 postProcessedOutputs: ChatCompletionsOutput;
11412}
11413interface AiModels {
11414 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
11415 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
11416 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
11417 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
11418 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
11419 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
11420 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
11421 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
11422 "@cf/microsoft/resnet-50": BaseAiImageClassification;
11423 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
11424 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
11425 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
11426 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
11427 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
11428 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
11429 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
11430 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
11431 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
11432 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
11433 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
11434 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
11435 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
11436 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
11437 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
11438 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
11439 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
11440 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
11441 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
11442 "@cf/microsoft/phi-2": BaseAiTextGeneration;
11443 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
11444 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
11445 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
11446 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
11447 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
11448 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
11449 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
11450 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
11451 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
11452 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
11453 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
11454 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
11455 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
11456 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
11457 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
11458 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
11459 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
11460 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
11461 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
11462 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
11463 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
11464 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
11465 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
11466 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
11467 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
11468 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
11469 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
11470 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
11471 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
11472 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
11473 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
11474 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
11475 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
11476 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
11477 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
11478 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
11479 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
11480 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
11481 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
11482 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
11483 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
11484 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
11485 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
11486 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
11487 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
11488 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
11489 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
11490 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
11491 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
11492 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
11493 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
11494 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
11495 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
11496 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
11497 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
11498 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
11499 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
11500 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
11501 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
11502 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
11503}
11504type AiOptions = {
11505 /**
11506 * Send requests as an asynchronous batch job, only works for supported models
11507 * https://developers.cloudflare.com/workers-ai/features/batch-api
11508 */
11509 queueRequest?: boolean;
11510 /**
11511 * Establish websocket connections, only works for supported models
11512 */
11513 websocket?: boolean;
11514 /**
11515 * Tag your requests to group and view them in Cloudflare dashboard.
11516 *
11517 * Rules:
11518 * Tags must only contain letters, numbers, and the symbols: : - . / @
11519 * Each tag can have maximum 50 characters.
11520 * Maximum 5 tags are allowed each request.
11521 * Duplicate tags will removed.
11522 */
11523 tags?: string[];
11524 gateway?: GatewayOptions;
11525 returnRawResponse?: boolean;
11526 prefix?: string;
11527 extraHeaders?: object;
11528 signal?: AbortSignal;
11529};
11530type AiModelsSearchParams = {
11531 author?: string;
11532 hide_experimental?: boolean;
11533 page?: number;
11534 per_page?: number;
11535 search?: string;
11536 source?: number;
11537 task?: string;
11538};
11539type AiModelsSearchObject = {
11540 id: string;
11541 source: number;
11542 name: string;
11543 description: string;
11544 task: {
11545 id: string;
11546 name: string;
11547 description: string;
11548 };
11549 tags: string[];
11550 properties: {
11551 property_id: string;
11552 value: string;
11553 }[];
11554};
11555type ChatCompletionsBase = XOR<
11556 ChatCompletionsPromptInput,
11557 ChatCompletionsMessagesInput
11558>;
11559type ChatCompletionsInput = XOR<
11560 ChatCompletionsBase,
11561 {
11562 requests: ChatCompletionsBase[];
11563 }
11564>;
11565interface InferenceUpstreamError extends Error {}
11566interface AiInternalError extends Error {}
11567type AiModelListType = Record<string, any>;
11568type AiAsyncBatchResponse = {
11569 request_id: string;
11570};
11571declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
11572 aiGatewayLogId: string | null;
11573 gateway(gatewayId: string): AiGateway;
11574 /**
11575 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
11576 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11577 */
11578 aiSearch(): AiSearchNamespace;
11579 /**
11580 * @deprecated AutoRAG has been replaced by AI Search.
11581 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
11582 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11583 *
11584 * @param autoragId Instance ID
11585 */
11586 autorag(autoragId: string): AutoRAG;
11587 // Batch request
11588 run<Name extends keyof AiModelList>(
11589 model: Name,
11590 inputs: {
11591 requests: AiModelList[Name]["inputs"][];
11592 },
11593 options: AiOptions & {
11594 queueRequest: true;
11595 },
11596 ): Promise<AiAsyncBatchResponse>;
11597 // Raw response
11598 run<Name extends keyof AiModelList>(
11599 model: Name,
11600 inputs: AiModelList[Name]["inputs"],
11601 options: AiOptions & {
11602 returnRawResponse: true;
11603 },
11604 ): Promise<Response>;
11605 // WebSocket
11606 run<Name extends keyof AiModelList>(
11607 model: Name,
11608 inputs: AiModelList[Name]["inputs"],
11609 options: AiOptions & {
11610 websocket: true;
11611 },
11612 ): Promise<Response>;
11613 // Streaming
11614 run<Name extends keyof AiModelList>(
11615 model: Name,
11616 inputs: AiModelList[Name]["inputs"] & {
11617 stream: true;
11618 },
11619 options?: AiOptions,
11620 ): Promise<ReadableStream>;
11621 // Normal (default) - known model
11622 run<Name extends keyof AiModelList>(
11623 model: Name,
11624 inputs: AiModelList[Name]["inputs"],
11625 options?: AiOptions,
11626 ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
11627 // Unknown model (gateway fallback)
11628 run(
11629 model: string & {},
11630 inputs: Record<string, unknown>,
11631 options?: AiOptions,
11632 ): Promise<Record<string, unknown>>;
11633 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
11634 toMarkdown(): ToMarkdownService;
11635 toMarkdown(
11636 files: MarkdownDocument[],
11637 options?: ConversionRequestOptions,
11638 ): Promise<ConversionResponse[]>;
11639 toMarkdown(
11640 files: MarkdownDocument,
11641 options?: ConversionRequestOptions,
11642 ): Promise<ConversionResponse>;
11643}
11644type GatewayRetries = {
11645 maxAttempts?: 1 | 2 | 3 | 4 | 5;
11646 retryDelayMs?: number;
11647 backoff?: "constant" | "linear" | "exponential";
11648};
11649type GatewayOptions = {
11650 id: string;
11651 cacheKey?: string;
11652 cacheTtl?: number;
11653 skipCache?: boolean;
11654 metadata?: Record<string, number | string | boolean | null | bigint>;
11655 collectLog?: boolean;
11656 eventId?: string;
11657 requestTimeoutMs?: number;
11658 retries?: GatewayRetries;
11659};
11660type UniversalGatewayOptions = Exclude<GatewayOptions, "id"> & {
11661 /**
11662 ** @deprecated
11663 */
11664 id?: string;
11665};
11666type AiGatewayPatchLog = {
11667 score?: number | null;
11668 feedback?: -1 | 1 | null;
11669 metadata?: Record<string, number | string | boolean | null | bigint> | null;
11670};
11671type AiGatewayLog = {
11672 id: string;
11673 provider: string;
11674 model: string;
11675 model_type?: string;
11676 path: string;
11677 duration: number;
11678 request_type?: string;
11679 request_content_type?: string;
11680 status_code: number;
11681 response_content_type?: string;
11682 success: boolean;
11683 cached: boolean;
11684 tokens_in?: number;
11685 tokens_out?: number;
11686 metadata?: Record<string, number | string | boolean | null | bigint>;
11687 step?: number;
11688 cost?: number;
11689 custom_cost?: boolean;
11690 request_size: number;
11691 request_head?: string;
11692 request_head_complete: boolean;
11693 response_size: number;
11694 response_head?: string;
11695 response_head_complete: boolean;
11696 created_at: Date;
11697};
11698type AIGatewayProviders =
11699 | "workers-ai"
11700 | "anthropic"
11701 | "aws-bedrock"
11702 | "azure-openai"
11703 | "google-vertex-ai"
11704 | "huggingface"
11705 | "openai"
11706 | "perplexity-ai"
11707 | "replicate"
11708 | "groq"
11709 | "cohere"
11710 | "google-ai-studio"
11711 | "mistral"
11712 | "grok"
11713 | "openrouter"
11714 | "deepseek"
11715 | "cerebras"
11716 | "cartesia"
11717 | "elevenlabs"
11718 | "adobe-firefly";
11719type AIGatewayHeaders = {
11720 "cf-aig-metadata":
11721 | Record<string, number | string | boolean | null | bigint>
11722 | string;
11723 "cf-aig-custom-cost":
11724 | {
11725 per_token_in?: number;
11726 per_token_out?: number;
11727 }
11728 | {
11729 total_cost?: number;
11730 }
11731 | string;
11732 "cf-aig-cache-ttl": number | string;
11733 "cf-aig-skip-cache": boolean | string;
11734 "cf-aig-cache-key": string;
11735 "cf-aig-event-id": string;
11736 "cf-aig-request-timeout": number | string;
11737 "cf-aig-max-attempts": number | string;
11738 "cf-aig-retry-delay": number | string;
11739 "cf-aig-backoff": string;
11740 "cf-aig-collect-log": boolean | string;
11741 Authorization: string;
11742 "Content-Type": string;
11743 [key: string]: string | number | boolean | object;
11744};
11745type AIGatewayUniversalRequest = {
11746 provider: AIGatewayProviders | string; // eslint-disable-line
11747 endpoint: string;
11748 headers: Partial<AIGatewayHeaders>;
11749 query: unknown;
11750};
11751interface AiGatewayInternalError extends Error {}
11752interface AiGatewayLogNotFound extends Error {}
11753declare abstract class AiGateway {
11754 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
11755 getLog(logId: string): Promise<AiGatewayLog>;
11756 run(
11757 data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
11758 options?: {
11759 gateway?: UniversalGatewayOptions;
11760 extraHeaders?: object;
11761 signal?: AbortSignal;
11762 },
11763 ): Promise<Response>;
11764 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
11765}
11766// Copyright (c) 2022-2025 Cloudflare, Inc.
11767// Licensed under the Apache 2.0 license found in the LICENSE file or at:
11768// https://opensource.org/licenses/Apache-2.0
11769/**
11770 * Artifacts โ€” Git-compatible file storage on Cloudflare Workers.
11771 *
11772 * Provides programmatic access to create, manage, and fork repositories,
11773 * and to issue and revoke scoped access tokens.
11774 */
11775/** Information about a repository. */
11776interface ArtifactsRepoInfo {
11777 /** Unique repository ID. */
11778 id: string;
11779 /** Repository name. */
11780 name: string;
11781 /** Repository description, or null if not set. */
11782 description: string | null;
11783 /** Default branch name (e.g. "main"). */
11784 defaultBranch: string;
11785 /** ISO 8601 creation timestamp. */
11786 createdAt: string;
11787 /** ISO 8601 last-updated timestamp. */
11788 updatedAt: string;
11789 /** ISO 8601 timestamp of the last push, or null if never pushed. */
11790 lastPushAt: string | null;
11791 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */
11792 source: string | null;
11793 /** Whether the repository is read-only. */
11794 readOnly: boolean;
11795 /** HTTPS git remote URL. */
11796 remote: string;
11797}
11798/** Result of creating a repository โ€” includes the initial access token. */
11799interface ArtifactsCreateRepoResult {
11800 /** Unique repository ID. */
11801 id: string;
11802 /** Repository name. */
11803 name: string;
11804 /** Repository description, or null if not set. */
11805 description: string | null;
11806 /** Default branch name. */
11807 defaultBranch: string;
11808 /** HTTPS git remote URL. */
11809 remote: string;
11810 /** Plaintext access token (only returned at creation time). */
11811 token: string;
11812 /** ISO 8601 token expiry timestamp. */
11813 tokenExpiresAt: string;
11814}
11815/** Paginated list of repositories. */
11816interface ArtifactsRepoListResult {
11817 /** Repositories in this page (without the `remote` field). */
11818 repos: Omit<ArtifactsRepoInfo, "remote">[];
11819 /** Total number of repositories in the namespace. */
11820 total: number;
11821 /** Cursor for the next page, if there are more results. */
11822 cursor?: string;
11823}
11824/** Result of creating an access token. */
11825interface ArtifactsCreateTokenResult {
11826 /** Unique token ID. */
11827 id: string;
11828 /** Plaintext token (only returned at creation time). */
11829 plaintext: string;
11830 /** Token scope: "read" or "write". */
11831 scope: "read" | "write";
11832 /** ISO 8601 token expiry timestamp. */
11833 expiresAt: string;
11834}
11835/** Token metadata (no plaintext). */
11836interface ArtifactsTokenInfo {
11837 /** Unique token ID. */
11838 id: string;
11839 /** Token scope: "read" or "write". */
11840 scope: "read" | "write";
11841 /** Token state: "active", "expired", or "revoked". */
11842 state: "active" | "expired" | "revoked";
11843 /** ISO 8601 creation timestamp. */
11844 createdAt: string;
11845 /** ISO 8601 expiry timestamp. */
11846 expiresAt: string;
11847}
11848/** Paginated list of tokens for a repository. */
11849interface ArtifactsTokenListResult {
11850 /** Tokens in this page. */
11851 tokens: ArtifactsTokenInfo[];
11852 /** Total number of tokens for the repository. */
11853 total: number;
11854}
11855/**
11856 * Handle for a single repository. Returned by Artifacts.get().
11857 *
11858 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11859 */
11860interface ArtifactsRepo extends ArtifactsRepoInfo {
11861 /**
11862 * Create an access token for this repo.
11863 * @param scope Token scope: "write" (default) or "read".
11864 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11865 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11866 */
11867 createToken(
11868 scope?: "write" | "read",
11869 ttl?: number,
11870 ): Promise<ArtifactsCreateTokenResult>;
11871 /** List tokens for this repo (metadata only, no plaintext). */
11872 listTokens(): Promise<ArtifactsTokenListResult>;
11873 /**
11874 * Revoke a token by plaintext or ID.
11875 * @param tokenOrId Plaintext token or token ID.
11876 * @returns true if revoked, false if not found.
11877 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11878 */
11879 revokeToken(tokenOrId: string): Promise<boolean>;
11880 // โ”€โ”€ Fork โ”€โ”€
11881 /**
11882 * Fork this repo to a new repo.
11883 * @param name Target repository name.
11884 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11885 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11886 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11887 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11888 */
11889 fork(
11890 name: string,
11891 opts?: {
11892 description?: string;
11893 readOnly?: boolean;
11894 defaultBranchOnly?: boolean;
11895 },
11896 ): Promise<ArtifactsCreateRepoResult>;
11897}
11898// โ”€โ”€ Error types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11899/**
11900 * Error codes returned by Artifacts binding operations.
11901 *
11902 * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11903 */
11904type ArtifactsErrorCode =
11905 | "ALREADY_EXISTS"
11906 | "NOT_FOUND"
11907 | "IMPORT_IN_PROGRESS"
11908 | "FORK_IN_PROGRESS"
11909 | "INVALID_INPUT"
11910 | "INVALID_REPO_NAME"
11911 | "INVALID_TTL"
11912 | "INVALID_URL"
11913 | "REMOTE_AUTH_REQUIRED"
11914 | "UPSTREAM_UNAVAILABLE"
11915 | "MEMORY_LIMIT"
11916 | "INTERNAL_ERROR";
11917/**
11918 * Error thrown by Artifacts binding operations.
11919 *
11920 * Uses a string `.code` discriminator following the Cloudflare platform
11921 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11922 * the REST API `errors[].code` values.
11923 */
11924interface ArtifactsError extends Error {
11925 readonly name: "ArtifactsError";
11926 /** String error code for programmatic matching. */
11927 readonly code: ArtifactsErrorCode;
11928 /** Numeric error code matching the REST API. */
11929 readonly numericCode: number;
11930}
11931// โ”€โ”€ Binding โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11932/**
11933 * Artifacts binding โ€” namespace-level operations.
11934 *
11935 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11936 */
11937interface Artifacts {
11938 /**
11939 * Create a new repository with an initial access token.
11940 * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11941 * @param opts Optional: readOnly flag, description, default branch name.
11942 * @returns Repo metadata with initial token.
11943 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11944 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11945 */
11946 create(
11947 name: string,
11948 opts?: {
11949 readOnly?: boolean;
11950 description?: string;
11951 setDefaultBranch?: string;
11952 },
11953 ): Promise<ArtifactsCreateRepoResult>;
11954 /**
11955 * Get a handle to an existing repository.
11956 * @param name Repository name.
11957 * @returns Repo handle.
11958 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11959 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11960 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11961 */
11962 get(name: string): Promise<ArtifactsRepo>;
11963 /**
11964 * Import a repository from an external git remote.
11965 * @param params Source URL and optional branch/depth, plus target name and options.
11966 * @returns Repo metadata with initial token.
11967 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11968 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11969 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11970 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11971 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11972 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11973 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11974 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11975 */
11976 import(params: {
11977 source: {
11978 url: string;
11979 branch?: string;
11980 depth?: number;
11981 };
11982 target: {
11983 name: string;
11984 opts?: {
11985 description?: string;
11986 readOnly?: boolean;
11987 };
11988 };
11989 }): Promise<ArtifactsCreateRepoResult>;
11990 /**
11991 * List repositories with cursor-based pagination.
11992 * @param opts Optional: limit (1โ€“200, default 50), cursor for next page.
11993 */
11994 list(opts?: {
11995 limit?: number;
11996 cursor?: string;
11997 }): Promise<ArtifactsRepoListResult>;
11998 /**
11999 * Delete a repository and all associated tokens.
12000 * @param name Repository name.
12001 * @returns true if deleted, false if not found.
12002 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
12003 */
12004 delete(name: string): Promise<boolean>;
12005}
12006/**
12007 * @deprecated Use the standalone AI Search Workers binding instead.
12008 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12009 */
12010interface AutoRAGInternalError extends Error {}
12011/**
12012 * @deprecated Use the standalone AI Search Workers binding instead.
12013 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12014 */
12015interface AutoRAGNotFoundError extends Error {}
12016/**
12017 * @deprecated Use the standalone AI Search Workers binding instead.
12018 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12019 */
12020interface AutoRAGUnauthorizedError extends Error {}
12021/**
12022 * @deprecated Use the standalone AI Search Workers binding instead.
12023 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12024 */
12025interface AutoRAGNameNotSetError extends Error {}
12026type ComparisonFilter = {
12027 key: string;
12028 type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
12029 value: string | number | boolean;
12030};
12031type CompoundFilter = {
12032 type: "and" | "or";
12033 filters: ComparisonFilter[];
12034};
12035/**
12036 * @deprecated Use the standalone AI Search Workers binding instead.
12037 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12038 */
12039type AutoRagSearchRequest = {
12040 query: string;
12041 filters?: CompoundFilter | ComparisonFilter;
12042 max_num_results?: number;
12043 ranking_options?: {
12044 ranker?: string;
12045 score_threshold?: number;
12046 };
12047 reranking?: {
12048 enabled?: boolean;
12049 model?: string;
12050 };
12051 rewrite_query?: boolean;
12052};
12053/**
12054 * @deprecated Use the standalone AI Search Workers binding instead.
12055 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12056 */
12057type AutoRagAiSearchRequest = AutoRagSearchRequest & {
12058 stream?: boolean;
12059 system_prompt?: string;
12060};
12061/**
12062 * @deprecated Use the standalone AI Search Workers binding instead.
12063 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12064 */
12065type AutoRagAiSearchRequestStreaming = Omit<
12066 AutoRagAiSearchRequest,
12067 "stream"
12068> & {
12069 stream: true;
12070};
12071/**
12072 * @deprecated Use the standalone AI Search Workers binding instead.
12073 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12074 */
12075type AutoRagSearchResponse = {
12076 object: "vector_store.search_results.page";
12077 search_query: string;
12078 data: {
12079 file_id: string;
12080 filename: string;
12081 score: number;
12082 attributes: Record<string, string | number | boolean | null>;
12083 content: {
12084 type: "text";
12085 text: string;
12086 }[];
12087 }[];
12088 has_more: boolean;
12089 next_page: string | null;
12090};
12091/**
12092 * @deprecated Use the standalone AI Search Workers binding instead.
12093 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12094 */
12095type AutoRagListResponse = {
12096 id: string;
12097 enable: boolean;
12098 type: string;
12099 source: string;
12100 vectorize_name: string;
12101 paused: boolean;
12102 status: string;
12103}[];
12104/**
12105 * @deprecated Use the standalone AI Search Workers binding instead.
12106 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12107 */
12108type AutoRagAiSearchResponse = AutoRagSearchResponse & {
12109 response: string;
12110};
12111/**
12112 * @deprecated Use the standalone AI Search Workers binding instead.
12113 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12114 */
12115declare abstract class AutoRAG {
12116 /**
12117 * @deprecated Use the standalone AI Search Workers binding instead.
12118 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12119 */
12120 list(): Promise<AutoRagListResponse>;
12121 /**
12122 * @deprecated Use the standalone AI Search Workers binding instead.
12123 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12124 */
12125 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
12126 /**
12127 * @deprecated Use the standalone AI Search Workers binding instead.
12128 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12129 */
12130 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
12131 /**
12132 * @deprecated Use the standalone AI Search Workers binding instead.
12133 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12134 */
12135 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
12136 /**
12137 * @deprecated Use the standalone AI Search Workers binding instead.
12138 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12139 */
12140 aiSearch(
12141 params: AutoRagAiSearchRequest,
12142 ): Promise<AutoRagAiSearchResponse | Response>;
12143}
12144interface BasicImageTransformations {
12145 /**
12146 * Maximum width in image pixels. The value must be an integer.
12147 */
12148 width?: number;
12149 /**
12150 * Maximum height in image pixels. The value must be an integer.
12151 */
12152 height?: number;
12153 /**
12154 * Resizing mode as a string. It affects interpretation of width and height
12155 * options:
12156 * - scale-down: Similar to contain, but the image is never enlarged. If
12157 * the image is larger than given width or height, it will be resized.
12158 * Otherwise its original size will be kept.
12159 * - contain: Resizes to maximum size that fits within the given width and
12160 * height. If only a single dimension is given (e.g. only width), the
12161 * image will be shrunk or enlarged to exactly match that dimension.
12162 * Aspect ratio is always preserved.
12163 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
12164 * and height. If the image has an aspect ratio different from the ratio
12165 * of width and height, it will be cropped to fit.
12166 * - crop: The image will be shrunk and cropped to fit within the area
12167 * specified by width and height. The image will not be enlarged. For images
12168 * smaller than the given dimensions it's the same as scale-down. For
12169 * images larger than the given dimensions, it's the same as cover.
12170 * See also trim.
12171 * - pad: Resizes to the maximum size that fits within the given width and
12172 * height, and then fills the remaining area with a background color
12173 * (white by default). Use of this mode is not recommended, as the same
12174 * effect can be more efficiently achieved with the contain mode and the
12175 * CSS object-fit: contain property.
12176 * - squeeze: Stretches and deforms to the width and height given, even if it
12177 * breaks aspect ratio
12178 */
12179 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
12180 /**
12181 * Image segmentation using artificial intelligence models. Sets pixels not
12182 * within selected segment area to transparent e.g "foreground" sets every
12183 * background pixel as transparent.
12184 */
12185 segment?: "foreground";
12186 /**
12187 * When cropping with fit: "cover", this defines the side or point that should
12188 * be left uncropped. The value is either a string
12189 * "left", "right", "top", "bottom", "auto", or "center" (the default),
12190 * or an object {x, y} containing focal point coordinates in the original
12191 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
12192 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
12193 * crop bottom or left and right sides as necessary, but wonโ€™t crop anything
12194 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
12195 * preserve as much as possible around a point at 20% of the height of the
12196 * source image.
12197 */
12198 gravity?:
12199 | "face"
12200 | "left"
12201 | "right"
12202 | "top"
12203 | "bottom"
12204 | "center"
12205 | "auto"
12206 | "entropy"
12207 | BasicImageTransformationsGravityCoordinates;
12208 /**
12209 * Background color to add underneath the image. Applies only to images with
12210 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โ€ฆ),
12211 * hsl(โ€ฆ), etc.)
12212 */
12213 background?: string;
12214 /**
12215 * Number of degrees (90, 180, 270) to rotate the image by. width and height
12216 * options refer to axes after rotation.
12217 */
12218 rotate?: 0 | 90 | 180 | 270 | 360;
12219}
12220interface BasicImageTransformationsGravityCoordinates {
12221 x?: number;
12222 y?: number;
12223 mode?: "remainder" | "box-center";
12224}
12225/**
12226 * In addition to the properties you can set in the RequestInit dict
12227 * that you pass as an argument to the Request constructor, you can
12228 * set certain properties of a `cf` object to control how Cloudflare
12229 * features are applied to that new Request.
12230 *
12231 * Note: Currently, these properties cannot be tested in the
12232 * playground.
12233 */
12234interface RequestInitCfProperties extends Record<string, unknown> {
12235 cacheEverything?: boolean;
12236 /**
12237 * A request's cache key is what determines if two requests are
12238 * "the same" for caching purposes. If a request has the same cache key
12239 * as some previous request, then we can serve the same cached response for
12240 * both. (e.g. 'some-key')
12241 *
12242 * Only available for Enterprise customers.
12243 */
12244 cacheKey?: string;
12245 /**
12246 * This allows you to append additional Cache-Tag response headers
12247 * to the origin response without modifications to the origin server.
12248 * This will allow for greater control over the Purge by Cache Tag feature
12249 * utilizing changes only in the Workers process.
12250 *
12251 * Only available for Enterprise customers.
12252 */
12253 cacheTags?: string[];
12254 /**
12255 * Force response to be cached for a given number of seconds. (e.g. 300)
12256 */
12257 cacheTtl?: number;
12258 /**
12259 * Force response to be cached for a given number of seconds based on the Origin status code.
12260 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
12261 */
12262 cacheTtlByStatus?: Record<string, number>;
12263 /**
12264 * Explicit Cache-Control header value to set on the response stored in cache.
12265 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
12266 *
12267 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
12268 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
12269 *
12270 * Can be used together with `cacheTtlByStatus`.
12271 */
12272 cacheControl?: string;
12273 /**
12274 * Whether the response should be eligible for Cache Reserve storage.
12275 */
12276 cacheReserveEligible?: boolean;
12277 /**
12278 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
12279 */
12280 respectStrongEtag?: boolean;
12281 /**
12282 * Whether to strip ETag headers from the origin response before caching.
12283 */
12284 stripEtags?: boolean;
12285 /**
12286 * Whether to strip Last-Modified headers from the origin response before caching.
12287 */
12288 stripLastModified?: boolean;
12289 /**
12290 * Whether to enable Cache Deception Armor, which protects against web cache
12291 * deception attacks by verifying the Content-Type matches the URL extension.
12292 */
12293 cacheDeceptionArmor?: boolean;
12294 /**
12295 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
12296 */
12297 cacheReserveMinimumFileSize?: number;
12298 scrapeShield?: boolean;
12299 apps?: boolean;
12300 image?: RequestInitCfPropertiesImage;
12301 minify?: RequestInitCfPropertiesImageMinify;
12302 mirage?: boolean;
12303 polish?: "lossy" | "lossless" | "off";
12304 r2?: RequestInitCfPropertiesR2;
12305 /**
12306 * Redirects the request to an alternate origin server. You can use this,
12307 * for example, to implement load balancing across several origins.
12308 * (e.g.us-east.example.com)
12309 *
12310 * Note - For security reasons, the hostname set in resolveOverride must
12311 * be proxied on the same Cloudflare zone of the incoming request.
12312 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
12313 * resolve to a host under a different domain or a DNS only domain first
12314 * declare a CNAME record within your own zoneโ€™s DNS mapping to the
12315 * external hostname, set proxy on Cloudflare, then set resolveOverride
12316 * to point to that CNAME record.
12317 */
12318 resolveOverride?: string;
12319}
12320interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
12321 /**
12322 * Absolute URL of the image file to use for the drawing. It can be any of
12323 * the supported file formats. For drawing of watermarks or non-rectangular
12324 * overlays we recommend using PNG or WebP images.
12325 */
12326 url: string;
12327 /**
12328 * Floating-point number between 0 (transparent) and 1 (opaque).
12329 * For example, opacity: 0.5 makes overlay semitransparent.
12330 */
12331 opacity?: number;
12332 /**
12333 * - If set to true, the overlay image will be tiled to cover the entire
12334 * area. This is useful for stock-photo-like watermarks.
12335 * - If set to "x", the overlay image will be tiled horizontally only
12336 * (form a line).
12337 * - If set to "y", the overlay image will be tiled vertically only
12338 * (form a line).
12339 */
12340 repeat?: true | "x" | "y";
12341 /**
12342 * Position of the overlay image relative to a given edge. Each property is
12343 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
12344 * positions left side of the overlay 10 pixels from the left edge of the
12345 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
12346 * of the background image.
12347 *
12348 * Setting both left & right, or both top & bottom is an error.
12349 *
12350 * If no position is specified, the image will be centered.
12351 */
12352 top?: number;
12353 left?: number;
12354 bottom?: number;
12355 right?: number;
12356}
12357interface RequestInitCfPropertiesImage extends BasicImageTransformations {
12358 /**
12359 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
12360 * easier to specify higher-DPI sizes in <img srcset>.
12361 */
12362 dpr?: number;
12363 /**
12364 * Allows you to trim your image. Takes dpr into account and is performed before
12365 * resizing or rotation.
12366 *
12367 * It can be used as:
12368 * - left, top, right, bottom - it will specify the number of pixels to cut
12369 * off each side
12370 * - width, height - the width/height you'd like to end up with - can be used
12371 * in combination with the properties above
12372 * - border - this will automatically trim the surroundings of an image based on
12373 * it's color. It consists of three properties:
12374 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
12375 * - tolerance: difference from color to treat as color
12376 * - keep: the number of pixels of border to keep
12377 */
12378 trim?:
12379 | "border"
12380 | {
12381 top?: number;
12382 bottom?: number;
12383 left?: number;
12384 right?: number;
12385 width?: number;
12386 height?: number;
12387 border?:
12388 | boolean
12389 | {
12390 color?: string;
12391 tolerance?: number;
12392 keep?: number;
12393 };
12394 };
12395 /**
12396 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
12397 * make images look worse, but load faster. The default is 85. It applies only
12398 * to JPEG and WebP images. It doesnโ€™t have any effect on PNG.
12399 */
12400 quality?: number | "low" | "medium-low" | "medium-high" | "high";
12401 /**
12402 * Output format to generate. It can be:
12403 * - avif: generate images in AVIF format.
12404 * - webp: generate images in Google WebP format. Set quality to 100 to get
12405 * the WebP-lossless format.
12406 * - json: instead of generating an image, outputs information about the
12407 * image, in JSON format. The JSON object will contain image size
12408 * (before and after resizing), source imageโ€™s MIME type, file size, etc.
12409 * - jpeg: generate images in JPEG format.
12410 * - png: generate images in PNG format.
12411 */
12412 format?:
12413 | "avif"
12414 | "webp"
12415 | "json"
12416 | "jpeg"
12417 | "png"
12418 | "baseline-jpeg"
12419 | "png-force"
12420 | "svg";
12421 /**
12422 * Whether to preserve animation frames from input files. Default is true.
12423 * Setting it to false reduces animations to still images. This setting is
12424 * recommended when enlarging images or processing arbitrary user content,
12425 * because large GIF animations can weigh tens or even hundreds of megabytes.
12426 * It is also useful to set anim:false when using format:"json" to get the
12427 * response quicker without the number of frames.
12428 */
12429 anim?: boolean;
12430 /**
12431 * What EXIF data should be preserved in the output image. Note that EXIF
12432 * rotation and embedded color profiles are always applied ("baked in" into
12433 * the image), and aren't affected by this option. Note that if the Polish
12434 * feature is enabled, all metadata may have been removed already and this
12435 * option may have no effect.
12436 * - keep: Preserve most of EXIF metadata, including GPS location if there's
12437 * any.
12438 * - copyright: Only keep the copyright tag, and discard everything else.
12439 * This is the default behavior for JPEG files.
12440 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
12441 * output formats always discard metadata.
12442 */
12443 metadata?: "keep" | "copyright" | "none";
12444 /**
12445 * Strength of sharpening filter to apply to the image. Floating-point
12446 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
12447 * recommended value for downscaled images.
12448 */
12449 sharpen?: number;
12450 /**
12451 * Radius of a blur filter (approximate gaussian). Maximum supported radius
12452 * is 250.
12453 */
12454 blur?: number;
12455 /**
12456 * Overlays are drawn in the order they appear in the array (last array
12457 * entry is the topmost layer).
12458 */
12459 draw?: RequestInitCfPropertiesImageDraw[];
12460 /**
12461 * Fetching image from authenticated origin. Setting this property will
12462 * pass authentication headers (Authorization, Cookie, etc.) through to
12463 * the origin.
12464 */
12465 "origin-auth"?: "share-publicly";
12466 /**
12467 * Adds a border around the image. The border is added after resizing. Border
12468 * width takes dpr into account, and can be specified either using a single
12469 * width property, or individually for each side.
12470 */
12471 border?:
12472 | {
12473 color: string;
12474 width: number;
12475 }
12476 | {
12477 color: string;
12478 top: number;
12479 right: number;
12480 bottom: number;
12481 left: number;
12482 };
12483 /**
12484 * Increase brightness by a factor. A value of 1.0 equals no change, a value
12485 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
12486 * 0 is ignored.
12487 */
12488 brightness?: number;
12489 /**
12490 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
12491 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
12492 * ignored.
12493 */
12494 contrast?: number;
12495 /**
12496 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
12497 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
12498 */
12499 gamma?: number;
12500 /**
12501 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
12502 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
12503 * ignored.
12504 */
12505 saturation?: number;
12506 /**
12507 * Flips the images horizontally, vertically, or both. Flipping is applied before
12508 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
12509 * horizontally, then rotated by 90 degrees.
12510 */
12511 flip?: "h" | "v" | "hv";
12512 /**
12513 * Slightly reduces latency on a cache miss by selecting a
12514 * quickest-to-compress file format, at a cost of increased file size and
12515 * lower image quality. It will usually override the format option and choose
12516 * JPEG over WebP or AVIF. We do not recommend using this option, except in
12517 * unusual circumstances like resizing uncacheable dynamically-generated
12518 * images.
12519 */
12520 compression?: "fast";
12521}
12522interface RequestInitCfPropertiesImageMinify {
12523 javascript?: boolean;
12524 css?: boolean;
12525 html?: boolean;
12526}
12527interface RequestInitCfPropertiesR2 {
12528 /**
12529 * Colo id of bucket that an object is stored in
12530 */
12531 bucketColoId?: number;
12532}
12533/**
12534 * Request metadata provided by Cloudflare's edge.
12535 */
12536type IncomingRequestCfProperties<HostMetadata = unknown> =
12537 IncomingRequestCfPropertiesBase &
12538 IncomingRequestCfPropertiesBotManagementEnterprise &
12539 IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
12540 IncomingRequestCfPropertiesGeographicInformation &
12541 IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
12542interface IncomingRequestCfPropertiesBase extends Record<string, unknown> {
12543 /**
12544 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
12545 *
12546 * @example 395747
12547 */
12548 asn?: number;
12549 /**
12550 * The organization which owns the ASN of the incoming request.
12551 *
12552 * @example "Google Cloud"
12553 */
12554 asOrganization?: string;
12555 /**
12556 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
12557 *
12558 * @example "gzip, deflate, br"
12559 */
12560 clientAcceptEncoding?: string;
12561 /**
12562 * The number of milliseconds it took for the request to reach your worker.
12563 *
12564 * @example 22
12565 */
12566 clientTcpRtt?: number;
12567 /**
12568 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
12569 * airport code of the data center that the request hit.
12570 *
12571 * @example "DFW"
12572 */
12573 colo: string;
12574 /**
12575 * Represents the upstream's response to a
12576 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
12577 * from cloudflare.
12578 *
12579 * For workers with no upstream, this will always be `1`.
12580 *
12581 * @example 3
12582 */
12583 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
12584 /**
12585 * The HTTP Protocol the request used.
12586 *
12587 * @example "HTTP/2"
12588 */
12589 httpProtocol: string;
12590 /**
12591 * The browser-requested prioritization information in the request object.
12592 *
12593 * If no information was set, defaults to the empty string `""`
12594 *
12595 * @example "weight=192;exclusive=0;group=3;group-weight=127"
12596 * @default ""
12597 */
12598 requestPriority: string;
12599 /**
12600 * The TLS version of the connection to Cloudflare.
12601 * In requests served over plaintext (without TLS), this property is the empty string `""`.
12602 *
12603 * @example "TLSv1.3"
12604 */
12605 tlsVersion: string;
12606 /**
12607 * The cipher for the connection to Cloudflare.
12608 * In requests served over plaintext (without TLS), this property is the empty string `""`.
12609 *
12610 * @example "AEAD-AES128-GCM-SHA256"
12611 */
12612 tlsCipher: string;
12613 /**
12614 * 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.
12615 *
12616 * If the incoming request was served over plaintext (without TLS) this field is undefined.
12617 */
12618 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
12619}
12620interface IncomingRequestCfPropertiesBotManagementBase {
12621 /**
12622 * Cloudflareโ€™s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
12623 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
12624 *
12625 * @example 54
12626 */
12627 score: number;
12628 /**
12629 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
12630 * 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).
12631 */
12632 verifiedBot: boolean;
12633 /**
12634 * A boolean value that is true if the request originates from a
12635 * Cloudflare-verified proxy service.
12636 */
12637 corporateProxy: boolean;
12638 /**
12639 * 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.
12640 */
12641 staticResource: boolean;
12642 /**
12643 * 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).
12644 */
12645 detectionIds: number[];
12646}
12647interface IncomingRequestCfPropertiesBotManagement {
12648 /**
12649 * Results of Cloudflare's Bot Management analysis
12650 */
12651 botManagement: IncomingRequestCfPropertiesBotManagementBase;
12652 /**
12653 * Duplicate of `botManagement.score`.
12654 *
12655 * @deprecated
12656 */
12657 clientTrustScore: number;
12658}
12659interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
12660 /**
12661 * Results of Cloudflare's Bot Management analysis
12662 */
12663 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
12664 /**
12665 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
12666 * across different destination IPs, Ports, and X509 certificates.
12667 */
12668 ja3Hash: string;
12669 };
12670}
12671interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> {
12672 /**
12673 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
12674 *
12675 * This field is only present if you have Cloudflare for SaaS enabled on your account
12676 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
12677 */
12678 hostMetadata?: HostMetadata;
12679}
12680interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
12681 /**
12682 * Information about the client certificate presented to Cloudflare.
12683 *
12684 * This is populated when the incoming request is served over TLS using
12685 * either Cloudflare Access or API Shield (mTLS)
12686 * and the presented SSL certificate has a valid
12687 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
12688 * (i.e., not `null` or `""`).
12689 *
12690 * Otherwise, a set of placeholder values are used.
12691 *
12692 * The property `certPresented` will be set to `"1"` when
12693 * the object is populated (i.e. the above conditions were met).
12694 */
12695 tlsClientAuth:
12696 | IncomingRequestCfPropertiesTLSClientAuth
12697 | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
12698}
12699/**
12700 * Metadata about the request's TLS handshake
12701 */
12702interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
12703 /**
12704 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12705 *
12706 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12707 */
12708 clientHandshake: string;
12709 /**
12710 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12711 *
12712 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12713 */
12714 serverHandshake: string;
12715 /**
12716 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12717 *
12718 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12719 */
12720 clientFinished: string;
12721 /**
12722 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12723 *
12724 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12725 */
12726 serverFinished: string;
12727}
12728/**
12729 * Geographic data about the request's origin.
12730 */
12731interface IncomingRequestCfPropertiesGeographicInformation {
12732 /**
12733 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
12734 *
12735 * 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.
12736 *
12737 * If Cloudflare is unable to determine where the request originated this property is omitted.
12738 *
12739 * The country code `"T1"` is used for requests originating on TOR.
12740 *
12741 * @example "GB"
12742 */
12743 country?: Iso3166Alpha2Code | "T1";
12744 /**
12745 * If present, this property indicates that the request originated in the EU
12746 *
12747 * @example "1"
12748 */
12749 isEUCountry?: "1";
12750 /**
12751 * A two-letter code indicating the continent the request originated from.
12752 *
12753 * @example "AN"
12754 */
12755 continent?: ContinentCode;
12756 /**
12757 * The city the request originated from
12758 *
12759 * @example "Austin"
12760 */
12761 city?: string;
12762 /**
12763 * Postal code of the incoming request
12764 *
12765 * @example "78701"
12766 */
12767 postalCode?: string;
12768 /**
12769 * Latitude of the incoming request
12770 *
12771 * @example "30.27130"
12772 */
12773 latitude?: string;
12774 /**
12775 * Longitude of the incoming request
12776 *
12777 * @example "-97.74260"
12778 */
12779 longitude?: string;
12780 /**
12781 * Timezone of the incoming request
12782 *
12783 * @example "America/Chicago"
12784 */
12785 timezone?: string;
12786 /**
12787 * If known, the ISO 3166-2 name for the first level region associated with
12788 * the IP address of the incoming request
12789 *
12790 * @example "Texas"
12791 */
12792 region?: string;
12793 /**
12794 * If known, the ISO 3166-2 code for the first-level region associated with
12795 * the IP address of the incoming request
12796 *
12797 * @example "TX"
12798 */
12799 regionCode?: string;
12800 /**
12801 * Metro code (DMA) of the incoming request
12802 *
12803 * @example "635"
12804 */
12805 metroCode?: string;
12806}
12807/** Data about the incoming request's TLS certificate */
12808interface IncomingRequestCfPropertiesTLSClientAuth {
12809 /** Always `"1"`, indicating that the certificate was presented */
12810 certPresented: "1";
12811 /**
12812 * Result of certificate verification.
12813 *
12814 * @example "FAILED:self signed certificate"
12815 */
12816 certVerified: Exclude<CertVerificationStatus, "NONE">;
12817 /** The presented certificate's revokation status.
12818 *
12819 * - A value of `"1"` indicates the certificate has been revoked
12820 * - A value of `"0"` indicates the certificate has not been revoked
12821 */
12822 certRevoked: "1" | "0";
12823 /**
12824 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12825 *
12826 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12827 */
12828 certIssuerDN: string;
12829 /**
12830 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12831 *
12832 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12833 */
12834 certSubjectDN: string;
12835 /**
12836 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12837 *
12838 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12839 */
12840 certIssuerDNRFC2253: string;
12841 /**
12842 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12843 *
12844 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12845 */
12846 certSubjectDNRFC2253: string;
12847 /** The certificate issuer's distinguished name (legacy policies) */
12848 certIssuerDNLegacy: string;
12849 /** The certificate subject's distinguished name (legacy policies) */
12850 certSubjectDNLegacy: string;
12851 /**
12852 * The certificate's serial number
12853 *
12854 * @example "00936EACBE07F201DF"
12855 */
12856 certSerial: string;
12857 /**
12858 * The certificate issuer's serial number
12859 *
12860 * @example "2489002934BDFEA34"
12861 */
12862 certIssuerSerial: string;
12863 /**
12864 * The certificate's Subject Key Identifier
12865 *
12866 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12867 */
12868 certSKI: string;
12869 /**
12870 * The certificate issuer's Subject Key Identifier
12871 *
12872 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12873 */
12874 certIssuerSKI: string;
12875 /**
12876 * The certificate's SHA-1 fingerprint
12877 *
12878 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
12879 */
12880 certFingerprintSHA1: string;
12881 /**
12882 * The certificate's SHA-256 fingerprint
12883 *
12884 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
12885 */
12886 certFingerprintSHA256: string;
12887 /**
12888 * The effective starting date of the certificate
12889 *
12890 * @example "Dec 22 19:39:00 2018 GMT"
12891 */
12892 certNotBefore: string;
12893 /**
12894 * The effective expiration date of the certificate
12895 *
12896 * @example "Dec 22 19:39:00 2018 GMT"
12897 */
12898 certNotAfter: string;
12899}
12900/** Placeholder values for TLS Client Authorization */
12901interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
12902 certPresented: "0";
12903 certVerified: "NONE";
12904 certRevoked: "0";
12905 certIssuerDN: "";
12906 certSubjectDN: "";
12907 certIssuerDNRFC2253: "";
12908 certSubjectDNRFC2253: "";
12909 certIssuerDNLegacy: "";
12910 certSubjectDNLegacy: "";
12911 certSerial: "";
12912 certIssuerSerial: "";
12913 certSKI: "";
12914 certIssuerSKI: "";
12915 certFingerprintSHA1: "";
12916 certFingerprintSHA256: "";
12917 certNotBefore: "";
12918 certNotAfter: "";
12919}
12920/** Possible outcomes of TLS verification */
12921declare type CertVerificationStatus =
12922 /** Authentication succeeded */
12923 | "SUCCESS"
12924 /** No certificate was presented */
12925 | "NONE"
12926 /** Failed because the certificate was self-signed */
12927 | "FAILED:self signed certificate"
12928 /** Failed because the certificate failed a trust chain check */
12929 | "FAILED:unable to verify the first certificate"
12930 /** Failed because the certificate not yet valid */
12931 | "FAILED:certificate is not yet valid"
12932 /** Failed because the certificate is expired */
12933 | "FAILED:certificate has expired"
12934 /** Failed for another unspecified reason */
12935 | "FAILED";
12936/**
12937 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
12938 */
12939declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
12940 | 0 /** Unknown */
12941 | 1 /** no keepalives (not found) */
12942 | 2 /** no connection re-use, opening keepalive connection failed */
12943 | 3 /** no connection re-use, keepalive accepted and saved */
12944 | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
12945 | 5; /** connection re-use, accepted by the origin server */
12946/** ISO 3166-1 Alpha-2 codes */
12947declare type Iso3166Alpha2Code =
12948 | "AD"
12949 | "AE"
12950 | "AF"
12951 | "AG"
12952 | "AI"
12953 | "AL"
12954 | "AM"
12955 | "AO"
12956 | "AQ"
12957 | "AR"
12958 | "AS"
12959 | "AT"
12960 | "AU"
12961 | "AW"
12962 | "AX"
12963 | "AZ"
12964 | "BA"
12965 | "BB"
12966 | "BD"
12967 | "BE"
12968 | "BF"
12969 | "BG"
12970 | "BH"
12971 | "BI"
12972 | "BJ"
12973 | "BL"
12974 | "BM"
12975 | "BN"
12976 | "BO"
12977 | "BQ"
12978 | "BR"
12979 | "BS"
12980 | "BT"
12981 | "BV"
12982 | "BW"
12983 | "BY"
12984 | "BZ"
12985 | "CA"
12986 | "CC"
12987 | "CD"
12988 | "CF"
12989 | "CG"
12990 | "CH"
12991 | "CI"
12992 | "CK"
12993 | "CL"
12994 | "CM"
12995 | "CN"
12996 | "CO"
12997 | "CR"
12998 | "CU"
12999 | "CV"
13000 | "CW"
13001 | "CX"
13002 | "CY"
13003 | "CZ"
13004 | "DE"
13005 | "DJ"
13006 | "DK"
13007 | "DM"
13008 | "DO"
13009 | "DZ"
13010 | "EC"
13011 | "EE"
13012 | "EG"
13013 | "EH"
13014 | "ER"
13015 | "ES"
13016 | "ET"
13017 | "FI"
13018 | "FJ"
13019 | "FK"
13020 | "FM"
13021 | "FO"
13022 | "FR"
13023 | "GA"
13024 | "GB"
13025 | "GD"
13026 | "GE"
13027 | "GF"
13028 | "GG"
13029 | "GH"
13030 | "GI"
13031 | "GL"
13032 | "GM"
13033 | "GN"
13034 | "GP"
13035 | "GQ"
13036 | "GR"
13037 | "GS"
13038 | "GT"
13039 | "GU"
13040 | "GW"
13041 | "GY"
13042 | "HK"
13043 | "HM"
13044 | "HN"
13045 | "HR"
13046 | "HT"
13047 | "HU"
13048 | "ID"
13049 | "IE"
13050 | "IL"
13051 | "IM"
13052 | "IN"
13053 | "IO"
13054 | "IQ"
13055 | "IR"
13056 | "IS"
13057 | "IT"
13058 | "JE"
13059 | "JM"
13060 | "JO"
13061 | "JP"
13062 | "KE"
13063 | "KG"
13064 | "KH"
13065 | "KI"
13066 | "KM"
13067 | "KN"
13068 | "KP"
13069 | "KR"
13070 | "KW"
13071 | "KY"
13072 | "KZ"
13073 | "LA"
13074 | "LB"
13075 | "LC"
13076 | "LI"
13077 | "LK"
13078 | "LR"
13079 | "LS"
13080 | "LT"
13081 | "LU"
13082 | "LV"
13083 | "LY"
13084 | "MA"
13085 | "MC"
13086 | "MD"
13087 | "ME"
13088 | "MF"
13089 | "MG"
13090 | "MH"
13091 | "MK"
13092 | "ML"
13093 | "MM"
13094 | "MN"
13095 | "MO"
13096 | "MP"
13097 | "MQ"
13098 | "MR"
13099 | "MS"
13100 | "MT"
13101 | "MU"
13102 | "MV"
13103 | "MW"
13104 | "MX"
13105 | "MY"
13106 | "MZ"
13107 | "NA"
13108 | "NC"
13109 | "NE"
13110 | "NF"
13111 | "NG"
13112 | "NI"
13113 | "NL"
13114 | "NO"
13115 | "NP"
13116 | "NR"
13117 | "NU"
13118 | "NZ"
13119 | "OM"
13120 | "PA"
13121 | "PE"
13122 | "PF"
13123 | "PG"
13124 | "PH"
13125 | "PK"
13126 | "PL"
13127 | "PM"
13128 | "PN"
13129 | "PR"
13130 | "PS"
13131 | "PT"
13132 | "PW"
13133 | "PY"
13134 | "QA"
13135 | "RE"
13136 | "RO"
13137 | "RS"
13138 | "RU"
13139 | "RW"
13140 | "SA"
13141 | "SB"
13142 | "SC"
13143 | "SD"
13144 | "SE"
13145 | "SG"
13146 | "SH"
13147 | "SI"
13148 | "SJ"
13149 | "SK"
13150 | "SL"
13151 | "SM"
13152 | "SN"
13153 | "SO"
13154 | "SR"
13155 | "SS"
13156 | "ST"
13157 | "SV"
13158 | "SX"
13159 | "SY"
13160 | "SZ"
13161 | "TC"
13162 | "TD"
13163 | "TF"
13164 | "TG"
13165 | "TH"
13166 | "TJ"
13167 | "TK"
13168 | "TL"
13169 | "TM"
13170 | "TN"
13171 | "TO"
13172 | "TR"
13173 | "TT"
13174 | "TV"
13175 | "TW"
13176 | "TZ"
13177 | "UA"
13178 | "UG"
13179 | "UM"
13180 | "US"
13181 | "UY"
13182 | "UZ"
13183 | "VA"
13184 | "VC"
13185 | "VE"
13186 | "VG"
13187 | "VI"
13188 | "VN"
13189 | "VU"
13190 | "WF"
13191 | "WS"
13192 | "YE"
13193 | "YT"
13194 | "ZA"
13195 | "ZM"
13196 | "ZW";
13197/** The 2-letter continent codes Cloudflare uses */
13198declare type ContinentCode = "AF" | "AN" | "AS" | "EU" | "NA" | "OC" | "SA";
13199type CfProperties<HostMetadata = unknown> =
13200 | IncomingRequestCfProperties<HostMetadata>
13201 | RequestInitCfProperties;
13202interface D1Meta {
13203 duration: number;
13204 size_after: number;
13205 rows_read: number;
13206 rows_written: number;
13207 last_row_id: number;
13208 changed_db: boolean;
13209 changes: number;
13210 /**
13211 * The region of the database instance that executed the query.
13212 */
13213 served_by_region?: string;
13214 /**
13215 * The three letters airport code of the colo that executed the query.
13216 */
13217 served_by_colo?: string;
13218 /**
13219 * True if-and-only-if the database instance that executed the query was the primary.
13220 */
13221 served_by_primary?: boolean;
13222 timings?: {
13223 /**
13224 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
13225 */
13226 sql_duration_ms: number;
13227 };
13228 /**
13229 * Number of total attempts to execute the query, due to automatic retries.
13230 * Note: All other fields in the response like `timings` only apply to the last attempt.
13231 */
13232 total_attempts?: number;
13233}
13234interface D1Response {
13235 success: true;
13236 meta: D1Meta & Record<string, unknown>;
13237 error?: never;
13238}
13239type D1Result<T = unknown> = D1Response & {
13240 results: T[];
13241};
13242interface D1ExecResult {
13243 count: number;
13244 duration: number;
13245}
13246type D1SessionConstraint =
13247 // Indicates that the first query should go to the primary, and the rest queries
13248 // using the same D1DatabaseSession will go to any replica that is consistent with
13249 // the bookmark maintained by the session (returned by the first query).
13250 | "first-primary"
13251 // Indicates that the first query can go anywhere (primary or replica), and the rest queries
13252 // using the same D1DatabaseSession will go to any replica that is consistent with
13253 // the bookmark maintained by the session (returned by the first query).
13254 | "first-unconstrained";
13255type D1SessionBookmark = string;
13256declare abstract class D1Database {
13257 prepare(query: string): D1PreparedStatement;
13258 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13259 exec(query: string): Promise<D1ExecResult>;
13260 /**
13261 * Creates a new D1 Session anchored at the given constraint or the bookmark.
13262 * All queries executed using the created session will have sequential consistency,
13263 * meaning that all writes done through the session will be visible in subsequent reads.
13264 *
13265 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
13266 */
13267 withSession(
13268 constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint,
13269 ): D1DatabaseSession;
13270 /**
13271 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
13272 */
13273 dump(): Promise<ArrayBuffer>;
13274}
13275declare abstract class D1DatabaseSession {
13276 prepare(query: string): D1PreparedStatement;
13277 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13278 /**
13279 * @returns The latest session bookmark across all executed queries on the session.
13280 * If no query has been executed yet, `null` is returned.
13281 */
13282 getBookmark(): D1SessionBookmark | null;
13283}
13284declare abstract class D1PreparedStatement {
13285 bind(...values: unknown[]): D1PreparedStatement;
13286 first<T = unknown>(colName: string): Promise<T | null>;
13287 first<T = Record<string, unknown>>(): Promise<T | null>;
13288 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
13289 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
13290 raw<T = unknown[]>(options: {
13291 columnNames: true;
13292 }): Promise<[string[], ...T[]]>;
13293 raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
13294}
13295// `Disposable` was added to TypeScript's standard lib types in version 5.2.
13296// To support older TypeScript versions, define an empty `Disposable` interface.
13297// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
13298// but this will ensure type checking on older versions still passes.
13299// TypeScript's interface merging will ensure our empty interface is effectively
13300// ignored when `Disposable` is included in the standard lib.
13301interface Disposable {}
13302/**
13303 * The returned data after sending an email
13304 */
13305interface EmailSendResult {
13306 /**
13307 * The Email Message ID
13308 */
13309 messageId: string;
13310}
13311/**
13312 * An email message that can be sent from a Worker.
13313 */
13314interface EmailMessage {
13315 /**
13316 * Envelope From attribute of the email message.
13317 */
13318 readonly from: string;
13319 /**
13320 * Envelope To attribute of the email message.
13321 */
13322 readonly to: string;
13323}
13324/**
13325 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
13326 */
13327interface ForwardableEmailMessage extends EmailMessage {
13328 /**
13329 * Stream of the email message content.
13330 */
13331 readonly raw: ReadableStream<Uint8Array>;
13332 /**
13333 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
13334 */
13335 readonly headers: Headers;
13336 /**
13337 * Size of the email message content.
13338 */
13339 readonly rawSize: number;
13340 /**
13341 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
13342 * @param reason The reject reason.
13343 * @returns void
13344 */
13345 setReject(reason: string): void;
13346 /**
13347 * Forward this email message to a verified destination address of the account.
13348 * @param rcptTo Verified destination address.
13349 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
13350 * @returns A promise that resolves when the email message is forwarded.
13351 */
13352 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
13353 /**
13354 * Reply to the sender of this email message with a new EmailMessage object.
13355 * @param message The reply message.
13356 * @returns A promise that resolves when the email message is replied.
13357 */
13358 reply(message: EmailMessage): Promise<EmailSendResult>;
13359}
13360/** A file attachment for an email message */
13361type EmailAttachment =
13362 | {
13363 disposition: "inline";
13364 contentId: string;
13365 filename: string;
13366 type: string;
13367 content: string | ArrayBuffer | ArrayBufferView;
13368 }
13369 | {
13370 disposition: "attachment";
13371 contentId?: undefined;
13372 filename: string;
13373 type: string;
13374 content: string | ArrayBuffer | ArrayBufferView;
13375 };
13376/** An Email Address */
13377interface EmailAddress {
13378 name: string;
13379 email: string;
13380}
13381/**
13382 * A binding that allows a Worker to send email messages.
13383 */
13384interface SendEmail {
13385 send(message: EmailMessage): Promise<EmailSendResult>;
13386 send(builder: {
13387 from: string | EmailAddress;
13388 to: string | string[];
13389 subject: string;
13390 replyTo?: string | EmailAddress;
13391 cc?: string | string[];
13392 bcc?: string | string[];
13393 headers?: Record<string, string>;
13394 text?: string;
13395 html?: string;
13396 attachments?: EmailAttachment[];
13397 }): Promise<EmailSendResult>;
13398}
13399declare abstract class EmailEvent extends ExtendableEvent {
13400 readonly message: ForwardableEmailMessage;
13401}
13402declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
13403 message: ForwardableEmailMessage,
13404 env: Env,
13405 ctx: ExecutionContext<Props>,
13406) => void | Promise<void>;
13407declare module "cloudflare:email" {
13408 let _EmailMessage: {
13409 prototype: EmailMessage;
13410 new (from: string, to: string, raw: ReadableStream | string): EmailMessage;
13411 };
13412 export { _EmailMessage as EmailMessage };
13413}
13414/**
13415 * Evaluation context for targeting rules.
13416 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
13417 */
13418type FlagshipEvaluationContext = Record<string, string | number | boolean>;
13419interface FlagshipEvaluationDetails<T> {
13420 flagKey: string;
13421 value: T;
13422 variant?: string | undefined;
13423 reason?: string | undefined;
13424 errorCode?: string | undefined;
13425 errorMessage?: string | undefined;
13426}
13427interface FlagshipEvaluationError extends Error {}
13428/**
13429 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
13430 *
13431 * @example
13432 * ```typescript
13433 * // Get a boolean flag value with a default
13434 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
13435 *
13436 * // Get a flag value with evaluation context for targeting
13437 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
13438 * userId: 'user-123',
13439 * country: 'US',
13440 * });
13441 *
13442 * // Get full evaluation details including variant and reason
13443 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
13444 * console.log(details.variant, details.reason);
13445 * ```
13446 */
13447declare abstract class Flagship {
13448 /**
13449 * Get a flag value without type checking.
13450 * @param flagKey The key of the flag to evaluate.
13451 * @param defaultValue Optional default value returned when evaluation fails.
13452 * @param context Optional evaluation context for targeting rules.
13453 */
13454 get(
13455 flagKey: string,
13456 defaultValue?: unknown,
13457 context?: FlagshipEvaluationContext,
13458 ): Promise<unknown>;
13459 /**
13460 * Get a boolean flag value.
13461 * @param flagKey The key of the flag to evaluate.
13462 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13463 * @param context Optional evaluation context for targeting rules.
13464 */
13465 getBooleanValue(
13466 flagKey: string,
13467 defaultValue: boolean,
13468 context?: FlagshipEvaluationContext,
13469 ): Promise<boolean>;
13470 /**
13471 * Get a string flag value.
13472 * @param flagKey The key of the flag to evaluate.
13473 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13474 * @param context Optional evaluation context for targeting rules.
13475 */
13476 getStringValue(
13477 flagKey: string,
13478 defaultValue: string,
13479 context?: FlagshipEvaluationContext,
13480 ): Promise<string>;
13481 /**
13482 * Get a number flag value.
13483 * @param flagKey The key of the flag to evaluate.
13484 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13485 * @param context Optional evaluation context for targeting rules.
13486 */
13487 getNumberValue(
13488 flagKey: string,
13489 defaultValue: number,
13490 context?: FlagshipEvaluationContext,
13491 ): Promise<number>;
13492 /**
13493 * Get an object flag value.
13494 * @param flagKey The key of the flag to evaluate.
13495 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13496 * @param context Optional evaluation context for targeting rules.
13497 */
13498 getObjectValue<T extends object>(
13499 flagKey: string,
13500 defaultValue: T,
13501 context?: FlagshipEvaluationContext,
13502 ): Promise<T>;
13503 /**
13504 * Get a boolean flag value with full evaluation details.
13505 * @param flagKey The key of the flag to evaluate.
13506 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13507 * @param context Optional evaluation context for targeting rules.
13508 */
13509 getBooleanDetails(
13510 flagKey: string,
13511 defaultValue: boolean,
13512 context?: FlagshipEvaluationContext,
13513 ): Promise<FlagshipEvaluationDetails<boolean>>;
13514 /**
13515 * Get a string flag value with full evaluation details.
13516 * @param flagKey The key of the flag to evaluate.
13517 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13518 * @param context Optional evaluation context for targeting rules.
13519 */
13520 getStringDetails(
13521 flagKey: string,
13522 defaultValue: string,
13523 context?: FlagshipEvaluationContext,
13524 ): Promise<FlagshipEvaluationDetails<string>>;
13525 /**
13526 * Get a number flag value with full evaluation details.
13527 * @param flagKey The key of the flag to evaluate.
13528 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13529 * @param context Optional evaluation context for targeting rules.
13530 */
13531 getNumberDetails(
13532 flagKey: string,
13533 defaultValue: number,
13534 context?: FlagshipEvaluationContext,
13535 ): Promise<FlagshipEvaluationDetails<number>>;
13536 /**
13537 * Get an object flag value with full evaluation details.
13538 * @param flagKey The key of the flag to evaluate.
13539 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13540 * @param context Optional evaluation context for targeting rules.
13541 */
13542 getObjectDetails<T extends object>(
13543 flagKey: string,
13544 defaultValue: T,
13545 context?: FlagshipEvaluationContext,
13546 ): Promise<FlagshipEvaluationDetails<T>>;
13547}
13548/**
13549 * Hello World binding to serve as an explanatory example. DO NOT USE
13550 */
13551interface HelloWorldBinding {
13552 /**
13553 * Retrieve the current stored value
13554 */
13555 get(): Promise<{
13556 value: string;
13557 ms?: number;
13558 }>;
13559 /**
13560 * Set a new stored value
13561 */
13562 set(value: string): Promise<void>;
13563}
13564interface Hyperdrive {
13565 /**
13566 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
13567 *
13568 * Calling this method returns an identical socket to if you call
13569 * `connect("host:port")` using the `host` and `port` fields from this object.
13570 * Pick whichever approach works better with your preferred DB client library.
13571 *
13572 * Note that this socket is not yet authenticated -- it's expected that your
13573 * code (or preferably, the client library of your choice) will authenticate
13574 * using the information in this class's readonly fields.
13575 */
13576 connect(): Socket;
13577 /**
13578 * A valid DB connection string that can be passed straight into the typical
13579 * client library/driver/ORM. This will typically be the easiest way to use
13580 * Hyperdrive.
13581 */
13582 readonly connectionString: string;
13583 /*
13584 * A randomly generated hostname that is only valid within the context of the
13585 * currently running Worker which, when passed into `connect()` function from
13586 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
13587 * for your database.
13588 */
13589 readonly host: string;
13590 /*
13591 * The port that must be paired the the host field when connecting.
13592 */
13593 readonly port: number;
13594 /*
13595 * The username to use when authenticating to your database via Hyperdrive.
13596 * Unlike the host and password, this will be the same every time
13597 */
13598 readonly user: string;
13599 /*
13600 * The randomly generated password to use when authenticating to your
13601 * database via Hyperdrive. Like the host field, this password is only valid
13602 * within the context of the currently running Worker instance from which
13603 * it's read.
13604 */
13605 readonly password: string;
13606 /*
13607 * The name of the database to connect to.
13608 */
13609 readonly database: string;
13610}
13611// Copyright (c) 2024 Cloudflare, Inc.
13612// Licensed under the Apache 2.0 license found in the LICENSE file or at:
13613// https://opensource.org/licenses/Apache-2.0
13614type ImageInfoResponse =
13615 | {
13616 format: "image/svg+xml";
13617 }
13618 | {
13619 format: string;
13620 fileSize: number;
13621 width: number;
13622 height: number;
13623 };
13624type ImageTransform = {
13625 width?: number;
13626 height?: number;
13627 background?: string;
13628 blur?: number;
13629 border?:
13630 | {
13631 color?: string;
13632 width?: number;
13633 }
13634 | {
13635 top?: number;
13636 bottom?: number;
13637 left?: number;
13638 right?: number;
13639 };
13640 brightness?: number;
13641 contrast?: number;
13642 fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
13643 flip?: "h" | "v" | "hv";
13644 gamma?: number;
13645 segment?: "foreground";
13646 gravity?:
13647 | "face"
13648 | "left"
13649 | "right"
13650 | "top"
13651 | "bottom"
13652 | "center"
13653 | "auto"
13654 | "entropy"
13655 | {
13656 x?: number;
13657 y?: number;
13658 mode: "remainder" | "box-center";
13659 };
13660 rotate?: 0 | 90 | 180 | 270;
13661 saturation?: number;
13662 sharpen?: number;
13663 trim?:
13664 | "border"
13665 | {
13666 top?: number;
13667 bottom?: number;
13668 left?: number;
13669 right?: number;
13670 width?: number;
13671 height?: number;
13672 border?:
13673 | boolean
13674 | {
13675 color?: string;
13676 tolerance?: number;
13677 keep?: number;
13678 };
13679 };
13680};
13681type ImageDrawOptions = {
13682 opacity?: number;
13683 repeat?: boolean | string;
13684 top?: number;
13685 left?: number;
13686 bottom?: number;
13687 right?: number;
13688};
13689type ImageInputOptions = {
13690 encoding?: "base64";
13691};
13692type ImageOutputOptions = {
13693 format:
13694 | "image/jpeg"
13695 | "image/png"
13696 | "image/gif"
13697 | "image/webp"
13698 | "image/avif"
13699 | "rgb"
13700 | "rgba";
13701 quality?: number;
13702 background?: string;
13703 anim?: boolean;
13704};
13705interface ImageMetadata {
13706 id: string;
13707 filename?: string;
13708 uploaded?: string;
13709 requireSignedURLs: boolean;
13710 meta?: Record<string, unknown>;
13711 variants: string[];
13712 draft?: boolean;
13713 creator?: string;
13714}
13715interface ImageUploadOptions {
13716 id?: string;
13717 filename?: string;
13718 requireSignedURLs?: boolean;
13719 metadata?: Record<string, unknown>;
13720 creator?: string;
13721 encoding?: "base64";
13722}
13723interface ImageUpdateOptions {
13724 requireSignedURLs?: boolean;
13725 metadata?: Record<string, unknown>;
13726 creator?: string;
13727}
13728interface ImageListOptions {
13729 limit?: number;
13730 cursor?: string;
13731 sortOrder?: "asc" | "desc";
13732 creator?: string;
13733}
13734interface ImageList {
13735 images: ImageMetadata[];
13736 cursor?: string;
13737 listComplete: boolean;
13738}
13739interface ImageHandle {
13740 /**
13741 * Get metadata for a hosted image
13742 * @returns Image metadata, or null if not found
13743 */
13744 details(): Promise<ImageMetadata | null>;
13745 /**
13746 * Get the raw image data for a hosted image
13747 * @returns ReadableStream of image bytes, or null if not found
13748 */
13749 bytes(): Promise<ReadableStream<Uint8Array> | null>;
13750 /**
13751 * Update hosted image metadata
13752 * @param options Properties to update
13753 * @returns Updated image metadata
13754 * @throws {@link ImagesError} if update fails
13755 */
13756 update(options: ImageUpdateOptions): Promise<ImageMetadata>;
13757 /**
13758 * Delete a hosted image
13759 * @returns True if deleted, false if not found
13760 */
13761 delete(): Promise<boolean>;
13762}
13763interface HostedImagesBinding {
13764 /**
13765 * Get a handle for a hosted image
13766 * @param imageId The ID of the image (UUID or custom ID)
13767 * @returns A handle for per-image operations
13768 */
13769 image(imageId: string): ImageHandle;
13770 /**
13771 * Upload a new hosted image
13772 * @param image The image file to upload
13773 * @param options Upload configuration
13774 * @returns Metadata for the uploaded image
13775 * @throws {@link ImagesError} if upload fails
13776 */
13777 upload(
13778 image: ReadableStream<Uint8Array> | ArrayBuffer,
13779 options?: ImageUploadOptions,
13780 ): Promise<ImageMetadata>;
13781 /**
13782 * List hosted images with pagination
13783 * @param options List configuration
13784 * @returns List of images with pagination info
13785 * @throws {@link ImagesError} if list fails
13786 */
13787 list(options?: ImageListOptions): Promise<ImageList>;
13788}
13789interface ImagesBinding {
13790 /**
13791 * Get image metadata (type, width and height)
13792 * @throws {@link ImagesError} with code 9412 if input is not an image
13793 * @param stream The image bytes
13794 */
13795 info(
13796 stream: ReadableStream<Uint8Array>,
13797 options?: ImageInputOptions,
13798 ): Promise<ImageInfoResponse>;
13799 /**
13800 * Begin applying a series of transformations to an image
13801 * @param stream The image bytes
13802 * @returns A transform handle
13803 */
13804 input(
13805 stream: ReadableStream<Uint8Array>,
13806 options?: ImageInputOptions,
13807 ): ImageTransformer;
13808 /**
13809 * Access hosted images CRUD operations
13810 */
13811 readonly hosted: HostedImagesBinding;
13812}
13813interface ImageTransformer {
13814 /**
13815 * Apply transform next, returning a transform handle.
13816 * You can then apply more transformations, draw, or retrieve the output.
13817 * @param transform
13818 */
13819 transform(transform: ImageTransform): ImageTransformer;
13820 /**
13821 * Draw an image on this transformer, returning a transform handle.
13822 * You can then apply more transformations, draw, or retrieve the output.
13823 * @param image The image (or transformer that will give the image) to draw
13824 * @param options The options configuring how to draw the image
13825 */
13826 draw(
13827 image: ReadableStream<Uint8Array> | ImageTransformer,
13828 options?: ImageDrawOptions,
13829 ): ImageTransformer;
13830 /**
13831 * Retrieve the image that results from applying the transforms to the
13832 * provided input
13833 * @param options Options that apply to the output e.g. output format
13834 */
13835 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
13836}
13837type ImageTransformationOutputOptions = {
13838 encoding?: "base64";
13839};
13840interface ImageTransformationResult {
13841 /**
13842 * The image as a response, ready to store in cache or return to users
13843 */
13844 response(): Response;
13845 /**
13846 * The content type of the returned image
13847 */
13848 contentType(): string;
13849 /**
13850 * The bytes of the response
13851 */
13852 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
13853}
13854interface ImagesError extends Error {
13855 readonly code: number;
13856 readonly message: string;
13857 readonly stack?: string;
13858}
13859/**
13860 * Media binding for transforming media streams.
13861 * Provides the entry point for media transformation operations.
13862 */
13863interface MediaBinding {
13864 /**
13865 * Creates a media transformer from an input stream.
13866 * @param media - The input media bytes
13867 * @returns A MediaTransformer instance for applying transformations
13868 */
13869 input(media: ReadableStream<Uint8Array>): MediaTransformer;
13870}
13871/**
13872 * Media transformer for applying transformation operations to media content.
13873 * Handles sizing, fitting, and other input transformation parameters.
13874 */
13875interface MediaTransformer {
13876 /**
13877 * Applies transformation options to the media content.
13878 * @param transform - Configuration for how the media should be transformed
13879 * @returns A generator for producing the transformed media output
13880 */
13881 transform(
13882 transform?: MediaTransformationInputOptions,
13883 ): MediaTransformationGenerator;
13884 /**
13885 * Generates the final media output with specified options.
13886 * @param output - Configuration for the output format and parameters
13887 * @returns The final transformation result containing the transformed media
13888 */
13889 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13890}
13891/**
13892 * Generator for producing media transformation results.
13893 * Configures the output format and parameters for the transformed media.
13894 */
13895interface MediaTransformationGenerator {
13896 /**
13897 * Generates the final media output with specified options.
13898 * @param output - Configuration for the output format and parameters
13899 * @returns The final transformation result containing the transformed media
13900 */
13901 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13902}
13903/**
13904 * Result of a media transformation operation.
13905 * Provides multiple ways to access the transformed media content.
13906 */
13907interface MediaTransformationResult {
13908 /**
13909 * Returns the transformed media as a readable stream of bytes.
13910 * @returns A promise containing a readable stream with the transformed media
13911 */
13912 media(): Promise<ReadableStream<Uint8Array>>;
13913 /**
13914 * Returns the transformed media as an HTTP response object.
13915 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
13916 */
13917 response(): Promise<Response>;
13918 /**
13919 * Returns the MIME type of the transformed media.
13920 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
13921 */
13922 contentType(): Promise<string>;
13923}
13924/**
13925 * Configuration options for transforming media input.
13926 * Controls how the media should be resized and fitted.
13927 */
13928type MediaTransformationInputOptions = {
13929 /** How the media should be resized to fit the specified dimensions */
13930 fit?: "contain" | "cover" | "scale-down";
13931 /** Target width in pixels */
13932 width?: number;
13933 /** Target height in pixels */
13934 height?: number;
13935};
13936/**
13937 * Configuration options for Media Transformations output.
13938 * Controls the format, timing, and type of the generated output.
13939 */
13940type MediaTransformationOutputOptions = {
13941 /**
13942 * Output mode determining the type of media to generate
13943 */
13944 mode?: "video" | "spritesheet" | "frame" | "audio";
13945 /** Whether to include audio in the output */
13946 audio?: boolean;
13947 /**
13948 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
13949 */
13950 time?: string;
13951 /**
13952 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
13953 */
13954 duration?: string;
13955 /**
13956 * Number of frames in the spritesheet.
13957 */
13958 imageCount?: number;
13959 /**
13960 * Output format for the generated media.
13961 */
13962 format?: "jpg" | "png" | "m4a";
13963};
13964/**
13965 * Error object for media transformation operations.
13966 * Extends the standard Error interface with additional media-specific information.
13967 */
13968interface MediaError extends Error {
13969 readonly code: number;
13970 readonly message: string;
13971 readonly stack?: string;
13972}
13973declare module "cloudflare:node" {
13974 interface NodeStyleServer {
13975 listen(...args: unknown[]): this;
13976 address(): {
13977 port?: number | null | undefined;
13978 };
13979 }
13980 export function httpServerHandler(port: number): ExportedHandler;
13981 export function httpServerHandler(options: { port: number }): ExportedHandler;
13982 export function httpServerHandler(server: NodeStyleServer): ExportedHandler;
13983}
13984type Params<P extends string = any> = Record<P, string | string[]>;
13985type EventContext<Env, P extends string, Data> = {
13986 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13987 functionPath: string;
13988 waitUntil: (promise: Promise<any>) => void;
13989 passThroughOnException: () => void;
13990 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
13991 env: Env & {
13992 ASSETS: {
13993 fetch: typeof fetch;
13994 };
13995 };
13996 params: Params<P>;
13997 data: Data;
13998};
13999type PagesFunction<
14000 Env = unknown,
14001 Params extends string = any,
14002 Data extends Record<string, unknown> = Record<string, unknown>,
14003> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
14004type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
14005 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
14006 functionPath: string;
14007 waitUntil: (promise: Promise<any>) => void;
14008 passThroughOnException: () => void;
14009 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
14010 env: Env & {
14011 ASSETS: {
14012 fetch: typeof fetch;
14013 };
14014 };
14015 params: Params<P>;
14016 data: Data;
14017 pluginArgs: PluginArgs;
14018};
14019type PagesPluginFunction<
14020 Env = unknown,
14021 Params extends string = any,
14022 Data extends Record<string, unknown> = Record<string, unknown>,
14023 PluginArgs = unknown,
14024> = (
14025 context: EventPluginContext<Env, Params, Data, PluginArgs>,
14026) => Response | Promise<Response>;
14027declare module "assets:*" {
14028 export const onRequest: PagesFunction;
14029}
14030// Copyright (c) 2022-2023 Cloudflare, Inc.
14031// Licensed under the Apache 2.0 license found in the LICENSE file or at:
14032// https://opensource.org/licenses/Apache-2.0
14033declare module "cloudflare:pipelines" {
14034 export abstract class PipelineTransformationEntrypoint<
14035 Env = unknown,
14036 I extends PipelineRecord = PipelineRecord,
14037 O extends PipelineRecord = PipelineRecord,
14038 > {
14039 protected env: Env;
14040 protected ctx: ExecutionContext;
14041 constructor(ctx: ExecutionContext, env: Env);
14042 /**
14043 * run receives an array of PipelineRecord which can be
14044 * transformed and returned to the pipeline
14045 * @param records Incoming records from the pipeline to be transformed
14046 * @param metadata Information about the specific pipeline calling the transformation entrypoint
14047 * @returns A promise containing the transformed PipelineRecord array
14048 */
14049 public run(records: I[], metadata: PipelineBatchMetadata): Promise<O[]>;
14050 }
14051 export type PipelineRecord = Record<string, unknown>;
14052 export type PipelineBatchMetadata = {
14053 pipelineId: string;
14054 pipelineName: string;
14055 };
14056 export interface Pipeline<T extends PipelineRecord = PipelineRecord> {
14057 /**
14058 * The Pipeline interface represents the type of a binding to a Pipeline
14059 *
14060 * @param records The records to send to the pipeline
14061 */
14062 send(records: T[]): Promise<void>;
14063 }
14064}
14065// PubSubMessage represents an incoming PubSub message.
14066// The message includes metadata about the broker, the client, and the payload
14067// itself.
14068// https://developers.cloudflare.com/pub-sub/
14069interface PubSubMessage {
14070 // Message ID
14071 readonly mid: number;
14072 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
14073 readonly broker: string;
14074 // The MQTT topic the message was sent on.
14075 readonly topic: string;
14076 // The client ID of the client that published this message.
14077 readonly clientId: string;
14078 // The unique identifier (JWT ID) used by the client to authenticate, if token
14079 // auth was used.
14080 readonly jti?: string;
14081 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
14082 // received the message from the client.
14083 readonly receivedAt: number;
14084 // An (optional) string with the MIME type of the payload, if set by the
14085 // client.
14086 readonly contentType: string;
14087 // Set to 1 when the payload is a UTF-8 string
14088 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
14089 readonly payloadFormatIndicator: number;
14090 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
14091 // You can use payloadFormatIndicator to inspect this before decoding.
14092 payload: string | Uint8Array;
14093}
14094// JsonWebKey extended by kid parameter
14095interface JsonWebKeyWithKid extends JsonWebKey {
14096 // Key Identifier of the JWK
14097 readonly kid: string;
14098}
14099interface RateLimitOptions {
14100 key: string;
14101}
14102interface RateLimitOutcome {
14103 success: boolean;
14104}
14105interface RateLimit {
14106 /**
14107 * Rate limit a request based on the provided options.
14108 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
14109 * @returns A promise that resolves with the outcome of the rate limit.
14110 */
14111 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
14112}
14113// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
14114// to referenced by `Fetcher`. This is included in the "importable" version of the types which
14115// strips all `module` blocks.
14116declare namespace Rpc {
14117 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
14118 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
14119 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
14120 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
14121 export const __RPC_STUB_BRAND: "__RPC_STUB_BRAND";
14122 export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
14123 export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
14124 export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
14125 export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
14126 export interface RpcTargetBranded {
14127 [__RPC_TARGET_BRAND]: never;
14128 }
14129 export interface WorkerEntrypointBranded {
14130 [__WORKER_ENTRYPOINT_BRAND]: never;
14131 }
14132 export interface DurableObjectBranded {
14133 [__DURABLE_OBJECT_BRAND]: never;
14134 }
14135 export interface WorkflowEntrypointBranded {
14136 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
14137 }
14138 export type EntrypointBranded =
14139 | WorkerEntrypointBranded
14140 | DurableObjectBranded
14141 | WorkflowEntrypointBranded;
14142 // Types that can be used through `Stub`s
14143 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
14144 // Types that can be passed over RPC
14145 // The reason for using a generic type here is to build a serializable subset of structured
14146 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
14147 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
14148 type Serializable<T> =
14149 // Structured cloneables
14150 | BaseType
14151 // Structured cloneable composites
14152 | Map<
14153 T extends Map<infer U, unknown> ? Serializable<U> : never,
14154 T extends Map<unknown, infer U> ? Serializable<U> : never
14155 >
14156 | Set<T extends Set<infer U> ? Serializable<U> : never>
14157 | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
14158 | {
14159 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
14160 }
14161 // Special types
14162 | Stub<Stubable>
14163 // Serialized as stubs, see `Stubify`
14164 | Stubable;
14165 // Base type for all RPC stubs, including common memory management methods.
14166 // `T` is used as a marker type for unwrapping `Stub`s later.
14167 interface StubBase<T extends Stubable> extends Disposable {
14168 [__RPC_STUB_BRAND]: T;
14169 dup(): this;
14170 }
14171 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
14172 // This represents all the types that can be sent as-is over an RPC boundary
14173 type BaseType =
14174 | void
14175 | undefined
14176 | null
14177 | boolean
14178 | number
14179 | bigint
14180 | string
14181 | TypedArray
14182 | ArrayBuffer
14183 | DataView
14184 | Date
14185 | Error
14186 | RegExp
14187 | ReadableStream<Uint8Array>
14188 | WritableStream<Uint8Array>
14189 | Request
14190 | Response
14191 | Headers;
14192 // Recursively rewrite all `Stubable` types with `Stub`s
14193 type Stubify<T> = T extends Stubable
14194 ? Stub<T>
14195 : T extends Map<infer K, infer V>
14196 ? Map<Stubify<K>, Stubify<V>>
14197 : T extends Set<infer V>
14198 ? Set<Stubify<V>>
14199 : T extends Array<infer V>
14200 ? Array<Stubify<V>>
14201 : T extends ReadonlyArray<infer V>
14202 ? ReadonlyArray<Stubify<V>>
14203 : T extends BaseType
14204 ? T
14205 : T extends {
14206 [key: string | number]: any;
14207 }
14208 ? {
14209 [K in keyof T]: Stubify<T[K]>;
14210 }
14211 : T;
14212 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
14213 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
14214 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
14215 type Unstubify<T> =
14216 T extends StubBase<infer V>
14217 ? V
14218 : T extends Map<infer K, infer V>
14219 ? Map<Unstubify<K>, Unstubify<V>>
14220 : T extends Set<infer V>
14221 ? Set<Unstubify<V>>
14222 : T extends Array<infer V>
14223 ? Array<Unstubify<V>>
14224 : T extends ReadonlyArray<infer V>
14225 ? ReadonlyArray<Unstubify<V>>
14226 : T extends BaseType
14227 ? T
14228 : T extends {
14229 [key: string | number]: unknown;
14230 }
14231 ? {
14232 [K in keyof T]: Unstubify<T[K]>;
14233 }
14234 : T;
14235 type UnstubifyAll<A extends any[]> = {
14236 [I in keyof A]: Unstubify<A[I]>;
14237 };
14238 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
14239 // Note `unknown & T` is equivalent to `T`.
14240 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
14241 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
14242 // Type for method return or property on an RPC interface.
14243 // - Stubable types are replaced by stubs.
14244 // - Serializable types are passed by value, with stubable types replaced by stubs
14245 // and a top-level `Disposer`.
14246 // Everything else can't be passed over PRC.
14247 // Technically, we use custom thenables here, but they quack like `Promise`s.
14248 // Intersecting with `(Maybe)Provider` allows pipelining.
14249 type Result<R> = R extends Stubable
14250 ? Promise<Stub<R>> & Provider<R>
14251 : R extends Serializable<R>
14252 ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
14253 : never;
14254 // Type for method or property on an RPC interface.
14255 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
14256 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
14257 // For properties, rewrite types to be `Result`s.
14258 // In each case, unwrap `Promise`s.
14259 type MethodOrProperty<V> = V extends (...args: infer P) => infer R
14260 ? (...args: UnstubifyAll<P>) => Result<Awaited<R>>
14261 : Result<Awaited<V>>;
14262 // Type for the callable part of an `Provider` if `T` is callable.
14263 // This is intersected with methods/properties.
14264 type MaybeCallableProvider<T> = T extends (...args: any[]) => any
14265 ? MethodOrProperty<T>
14266 : unknown;
14267 // Base type for all other types providing RPC-like interfaces.
14268 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
14269 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
14270 export type Provider<
14271 T extends object,
14272 Reserved extends string = never,
14273 > = MaybeCallableProvider<T> &
14274 Pick<
14275 {
14276 [K in keyof T]: MethodOrProperty<T[K]>;
14277 },
14278 Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>
14279 >;
14280}
14281declare namespace Cloudflare {
14282 // Type of `env`.
14283 //
14284 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
14285 // will merge all declarations.
14286 //
14287 // You can use `wrangler types` to generate the `Env` type automatically.
14288 interface Env {}
14289 // Project-specific parameters used to inform types.
14290 //
14291 // This interface is, again, intended to be declared in project-specific files, and then that
14292 // declaration will be merged with this one.
14293 //
14294 // A project should have a declaration like this:
14295 //
14296 // interface GlobalProps {
14297 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
14298 // // of `ctx.exports`.
14299 // mainModule: typeof import("my-main-module");
14300 //
14301 // // Declares which of the main module's exports are configured with durable storage, and
14302 // // thus should behave as Durable Object namsepace bindings.
14303 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
14304 // }
14305 //
14306 // You can use `wrangler types` to generate `GlobalProps` automatically.
14307 interface GlobalProps {}
14308 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
14309 // present.
14310 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
14311 ? GlobalProps[K]
14312 : Default;
14313 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
14314 // `mainModule` property.
14315 type MainModule = GlobalProp<"mainModule", {}>;
14316 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
14317 type Exports = {
14318 [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
14319 // If the export is listed in `durableNamespaces`, then it is also a
14320 // DurableObjectNamespace.
14321 (K extends GlobalProp<"durableNamespaces", never>
14322 ? MainModule[K] extends new (...args: any[]) => infer DoInstance
14323 ? DoInstance extends Rpc.DurableObjectBranded
14324 ? DurableObjectNamespace<DoInstance>
14325 : DurableObjectNamespace<undefined>
14326 : DurableObjectNamespace<undefined>
14327 : {});
14328 };
14329}
14330declare namespace CloudflareWorkersModule {
14331 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
14332 export const RpcStub: {
14333 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
14334 };
14335 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
14336 [Rpc.__RPC_TARGET_BRAND]: never;
14337 }
14338 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
14339 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
14340 implements Rpc.WorkerEntrypointBranded
14341 {
14342 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
14343 protected ctx: ExecutionContext<Props>;
14344 protected env: Env;
14345 constructor(ctx: ExecutionContext, env: Env);
14346 email?(message: ForwardableEmailMessage): void | Promise<void>;
14347 fetch?(request: Request): Response | Promise<Response>;
14348 connect?(socket: Socket): void | Promise<void>;
14349 queue?(batch: MessageBatch): void | Promise<void>;
14350 scheduled?(controller: ScheduledController): void | Promise<void>;
14351 tail?(events: TraceItem[]): void | Promise<void>;
14352 tailStream?(
14353 event: TailStream.TailEvent<TailStream.Onset>,
14354 ):
14355 | TailStream.TailEventHandlerType
14356 | Promise<TailStream.TailEventHandlerType>;
14357 test?(controller: TestController): void | Promise<void>;
14358 trace?(traces: TraceItem[]): void | Promise<void>;
14359 }
14360 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
14361 implements Rpc.DurableObjectBranded
14362 {
14363 [Rpc.__DURABLE_OBJECT_BRAND]: never;
14364 protected ctx: DurableObjectState<Props>;
14365 protected env: Env;
14366 constructor(ctx: DurableObjectState, env: Env);
14367 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
14368 fetch?(request: Request): Response | Promise<Response>;
14369 connect?(socket: Socket): void | Promise<void>;
14370 webSocketMessage?(
14371 ws: WebSocket,
14372 message: string | ArrayBuffer,
14373 ): void | Promise<void>;
14374 webSocketClose?(
14375 ws: WebSocket,
14376 code: number,
14377 reason: string,
14378 wasClean: boolean,
14379 ): void | Promise<void>;
14380 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
14381 }
14382 export type WorkflowDurationLabel =
14383 | "second"
14384 | "minute"
14385 | "hour"
14386 | "day"
14387 | "week"
14388 | "month"
14389 | "year";
14390 export type WorkflowSleepDuration =
14391 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
14392 | number;
14393 export type WorkflowDelayDuration = WorkflowSleepDuration;
14394 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
14395 export type WorkflowRetentionDuration = WorkflowSleepDuration;
14396 export type WorkflowBackoff = "constant" | "linear" | "exponential";
14397 export type WorkflowStepConfig = {
14398 retries?: {
14399 limit: number;
14400 delay: WorkflowDelayDuration | number;
14401 backoff?: WorkflowBackoff;
14402 };
14403 timeout?: WorkflowTimeoutDuration | number;
14404 };
14405 export type WorkflowEvent<T> = {
14406 payload: Readonly<T>;
14407 timestamp: Date;
14408 instanceId: string;
14409 };
14410 export type WorkflowStepEvent<T> = {
14411 payload: Readonly<T>;
14412 timestamp: Date;
14413 type: string;
14414 };
14415 export type WorkflowStepContext = {
14416 step: {
14417 name: string;
14418 count: number;
14419 };
14420 attempt: number;
14421 config: WorkflowStepConfig;
14422 };
14423 export abstract class WorkflowStep {
14424 do<T extends Rpc.Serializable<T>>(
14425 name: string,
14426 callback: (ctx: WorkflowStepContext) => Promise<T>,
14427 ): Promise<T>;
14428 do<T extends Rpc.Serializable<T>>(
14429 name: string,
14430 config: WorkflowStepConfig,
14431 callback: (ctx: WorkflowStepContext) => Promise<T>,
14432 ): Promise<T>;
14433 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
14434 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
14435 waitForEvent<T extends Rpc.Serializable<T>>(
14436 name: string,
14437 options: {
14438 type: string;
14439 timeout?: WorkflowTimeoutDuration | number;
14440 },
14441 ): Promise<WorkflowStepEvent<T>>;
14442 }
14443 export type WorkflowInstanceStatus =
14444 | "queued"
14445 | "running"
14446 | "paused"
14447 | "errored"
14448 | "terminated"
14449 | "complete"
14450 | "waiting"
14451 | "waitingForPause"
14452 | "unknown";
14453 export abstract class WorkflowEntrypoint<
14454 Env = unknown,
14455 T extends Rpc.Serializable<T> | unknown = unknown,
14456 >
14457 implements Rpc.WorkflowEntrypointBranded
14458 {
14459 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
14460 protected ctx: ExecutionContext;
14461 protected env: Env;
14462 constructor(ctx: ExecutionContext, env: Env);
14463 run(
14464 event: Readonly<WorkflowEvent<T>>,
14465 step: WorkflowStep,
14466 ): Promise<unknown>;
14467 }
14468 export function waitUntil(promise: Promise<unknown>): void;
14469 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
14470 export function withExports(newExports: unknown, fn: () => unknown): unknown;
14471 export function withEnvAndExports(
14472 newEnv: unknown,
14473 newExports: unknown,
14474 fn: () => unknown,
14475 ): unknown;
14476 export const env: Cloudflare.Env;
14477 export const exports: Cloudflare.Exports;
14478 export const cache: CacheContext;
14479 export const tracing: Tracing;
14480}
14481declare module "cloudflare:workers" {
14482 export = CloudflareWorkersModule;
14483}
14484interface SecretsStoreSecret {
14485 /**
14486 * Get a secret from the Secrets Store, returning a string of the secret value
14487 * if it exists, or throws an error if it does not exist
14488 */
14489 get(): Promise<string>;
14490}
14491declare module "cloudflare:sockets" {
14492 function _connect(
14493 address: string | SocketAddress,
14494 options?: SocketOptions,
14495 ): Socket;
14496 export { _connect as connect };
14497}
14498/**
14499 * Binding entrypoint for Cloudflare Stream.
14500 *
14501 * Usage:
14502 * - Binding-level operations:
14503 * `await env.STREAM.videos.upload`
14504 * `await env.STREAM.videos.createDirectUpload`
14505 * `await env.STREAM.videos.*`
14506 * `await env.STREAM.watermarks.*`
14507 * - Per-video operations:
14508 * `await env.STREAM.video(id).downloads.*`
14509 * `await env.STREAM.video(id).captions.*`
14510 *
14511 * Example usage:
14512 * ```ts
14513 * await env.STREAM.video(id).downloads.generate();
14514 *
14515 * const video = env.STREAM.video(id)
14516 * const captions = video.captions.list();
14517 * const videoDetails = video.details()
14518 * ```
14519 */
14520interface StreamBinding {
14521 /**
14522 * Returns a handle scoped to a single video for per-video operations.
14523 * @param id The unique identifier for the video.
14524 * @returns A handle for per-video operations.
14525 */
14526 video(id: string): StreamVideoHandle;
14527 /**
14528 * Uploads a new video from a provided URL.
14529 * @param url The URL to upload from.
14530 * @param params Optional upload parameters.
14531 * @returns The uploaded video details.
14532 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
14533 * @throws {QuotaReachedError} if the account storage capacity is exceeded
14534 * @throws {MaxFileSizeError} if the file size is too large
14535 * @throws {RateLimitedError} if the server received too many requests
14536 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
14537 * @throws {InternalError} if an unexpected error occurs
14538 */
14539 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
14540 /**
14541 * Creates a direct upload that allows video uploads without an API key.
14542 * @param params Parameters for the direct upload
14543 * @returns The direct upload details.
14544 * @throws {BadRequestError} if the parameters are invalid
14545 * @throws {RateLimitedError} if the server received too many requests
14546 * @throws {InternalError} if an unexpected error occurs
14547 */
14548 createDirectUpload(
14549 params: StreamDirectUploadCreateParams,
14550 ): Promise<StreamDirectUpload>;
14551 videos: StreamVideos;
14552 watermarks: StreamWatermarks;
14553}
14554/**
14555 * Handle for operations scoped to a single Stream video.
14556 */
14557interface StreamVideoHandle {
14558 /**
14559 * The unique identifier for the video.
14560 */
14561 id: string;
14562 /**
14563 * Get a full videos details
14564 * @returns The full video details.
14565 * @throws {NotFoundError} if the video is not found
14566 * @throws {InternalError} if an unexpected error occurs
14567 */
14568 details(): Promise<StreamVideo>;
14569 /**
14570 * Update details for a single video.
14571 * @param params The fields to update for the video.
14572 * @returns The updated video details.
14573 * @throws {NotFoundError} if the video is not found
14574 * @throws {BadRequestError} if the parameters are invalid
14575 * @throws {InternalError} if an unexpected error occurs
14576 */
14577 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
14578 /**
14579 * Deletes a video and its copies from Cloudflare Stream.
14580 * @returns A promise that resolves when deletion completes.
14581 * @throws {NotFoundError} if the video is not found
14582 * @throws {InternalError} if an unexpected error occurs
14583 */
14584 delete(): Promise<void>;
14585 /**
14586 * Creates a signed URL token for a video.
14587 * @returns The signed token that was created.
14588 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
14589 */
14590 generateToken(): Promise<string>;
14591 downloads: StreamScopedDownloads;
14592 captions: StreamScopedCaptions;
14593}
14594interface StreamVideo {
14595 /**
14596 * The unique identifier for the video.
14597 */
14598 id: string;
14599 /**
14600 * A user-defined identifier for the media creator.
14601 */
14602 creator: string | null;
14603 /**
14604 * The thumbnail URL for the video.
14605 */
14606 thumbnail: string;
14607 /**
14608 * The thumbnail timestamp percentage.
14609 */
14610 thumbnailTimestampPct: number;
14611 /**
14612 * Indicates whether the video is ready to stream.
14613 */
14614 readyToStream: boolean;
14615 /**
14616 * The date and time the video became ready to stream.
14617 */
14618 readyToStreamAt: string | null;
14619 /**
14620 * Processing status information.
14621 */
14622 status: StreamVideoStatus;
14623 /**
14624 * A user modifiable key-value store.
14625 */
14626 meta: Record<string, string>;
14627 /**
14628 * The date and time the video was created.
14629 */
14630 created: string;
14631 /**
14632 * The date and time the video was last modified.
14633 */
14634 modified: string;
14635 /**
14636 * The date and time at which the video will be deleted.
14637 */
14638 scheduledDeletion: string | null;
14639 /**
14640 * The size of the video in bytes.
14641 */
14642 size: number;
14643 /**
14644 * The preview URL for the video.
14645 */
14646 preview?: string;
14647 /**
14648 * Origins allowed to display the video.
14649 */
14650 allowedOrigins: Array<string>;
14651 /**
14652 * Indicates whether signed URLs are required.
14653 */
14654 requireSignedURLs: boolean | null;
14655 /**
14656 * The date and time the video was uploaded.
14657 */
14658 uploaded: string | null;
14659 /**
14660 * The date and time when the upload URL expires.
14661 */
14662 uploadExpiry: string | null;
14663 /**
14664 * The maximum size in bytes for direct uploads.
14665 */
14666 maxSizeBytes: number | null;
14667 /**
14668 * The maximum duration in seconds for direct uploads.
14669 */
14670 maxDurationSeconds: number | null;
14671 /**
14672 * The video duration in seconds. -1 indicates unknown.
14673 */
14674 duration: number;
14675 /**
14676 * Input metadata for the original upload.
14677 */
14678 input: StreamVideoInput;
14679 /**
14680 * Playback URLs for the video.
14681 */
14682 hlsPlaybackUrl: string;
14683 dashPlaybackUrl: string;
14684 /**
14685 * The watermark applied to the video, if any.
14686 */
14687 watermark: StreamWatermark | null;
14688 /**
14689 * The live input id associated with the video, if any.
14690 */
14691 liveInputId?: string | null;
14692 /**
14693 * The source video id if this is a clip.
14694 */
14695 clippedFromId: string | null;
14696 /**
14697 * Public details associated with the video.
14698 */
14699 publicDetails: StreamPublicDetails | null;
14700}
14701type StreamVideoStatus = {
14702 /**
14703 * The current processing state.
14704 */
14705 state: string;
14706 /**
14707 * The current processing step.
14708 */
14709 step?: string;
14710 /**
14711 * The percent complete as a string.
14712 */
14713 pctComplete?: string;
14714 /**
14715 * An error reason code, if applicable.
14716 */
14717 errorReasonCode: string;
14718 /**
14719 * An error reason text, if applicable.
14720 */
14721 errorReasonText: string;
14722};
14723type StreamVideoInput = {
14724 /**
14725 * The input width in pixels.
14726 */
14727 width: number;
14728 /**
14729 * The input height in pixels.
14730 */
14731 height: number;
14732};
14733type StreamPublicDetails = {
14734 /**
14735 * The public title for the video.
14736 */
14737 title: string | null;
14738 /**
14739 * The public share link.
14740 */
14741 share_link: string | null;
14742 /**
14743 * The public channel link.
14744 */
14745 channel_link: string | null;
14746 /**
14747 * The public logo URL.
14748 */
14749 logo: string | null;
14750};
14751type StreamDirectUpload = {
14752 /**
14753 * The URL an unauthenticated upload can use for a single multipart request.
14754 */
14755 uploadURL: string;
14756 /**
14757 * A Cloudflare-generated unique identifier for a media item.
14758 */
14759 id: string;
14760 /**
14761 * The watermark profile applied to the upload.
14762 */
14763 watermark: StreamWatermark | null;
14764 /**
14765 * The scheduled deletion time, if any.
14766 */
14767 scheduledDeletion: string | null;
14768};
14769type StreamDirectUploadCreateParams = {
14770 /**
14771 * The maximum duration in seconds for a video upload.
14772 */
14773 maxDurationSeconds: number;
14774 /**
14775 * The date and time after upload when videos will not be accepted.
14776 */
14777 expiry?: string;
14778 /**
14779 * A user-defined identifier for the media creator.
14780 */
14781 creator?: string;
14782 /**
14783 * A user modifiable key-value store used to reference other systems of record for
14784 * managing videos.
14785 */
14786 meta?: Record<string, string>;
14787 /**
14788 * Lists the origins allowed to display the video.
14789 */
14790 allowedOrigins?: Array<string>;
14791 /**
14792 * Indicates whether the video can be accessed using the id. When set to `true`,
14793 * a signed token must be generated with a signing key to view the video.
14794 */
14795 requireSignedURLs?: boolean;
14796 /**
14797 * The thumbnail timestamp percentage.
14798 */
14799 thumbnailTimestampPct?: number;
14800 /**
14801 * The date and time at which the video will be deleted. Include `null` to remove
14802 * a scheduled deletion.
14803 */
14804 scheduledDeletion?: string | null;
14805 /**
14806 * The watermark profile to apply.
14807 */
14808 watermark?: StreamDirectUploadWatermark;
14809};
14810type StreamDirectUploadWatermark = {
14811 /**
14812 * The unique identifier for the watermark profile.
14813 */
14814 id: string;
14815};
14816type StreamUrlUploadParams = {
14817 /**
14818 * Lists the origins allowed to display the video. Enter allowed origin
14819 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14820 * video to be viewed on any origin.
14821 */
14822 allowedOrigins?: Array<string>;
14823 /**
14824 * A user-defined identifier for the media creator.
14825 */
14826 creator?: string;
14827 /**
14828 * A user modifiable key-value store used to reference other systems of
14829 * record for managing videos.
14830 */
14831 meta?: Record<string, string>;
14832 /**
14833 * Indicates whether the video can be a accessed using the id. When
14834 * set to `true`, a signed token must be generated with a signing key to view the
14835 * video.
14836 */
14837 requireSignedURLs?: boolean;
14838 /**
14839 * Indicates the date and time at which the video will be deleted. Omit
14840 * the field to indicate no change, or include with a `null` value to remove an
14841 * existing scheduled deletion. If specified, must be at least 30 days from upload
14842 * time.
14843 */
14844 scheduledDeletion?: string | null;
14845 /**
14846 * The timestamp for a thumbnail image calculated as a percentage value
14847 * of the video's duration. To convert from a second-wise timestamp to a
14848 * percentage, divide the desired timestamp by the total duration of the video. If
14849 * this value is not set, the default thumbnail image is taken from 0s of the
14850 * video.
14851 */
14852 thumbnailTimestampPct?: number;
14853 /**
14854 * The identifier for the watermark profile
14855 */
14856 watermarkId?: string;
14857};
14858interface StreamScopedCaptions {
14859 /**
14860 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
14861 * One caption or subtitle file per language is allowed.
14862 * @param language The BCP 47 language tag for the caption or subtitle.
14863 * @param input The caption or subtitle stream to upload.
14864 * @returns The created caption entry.
14865 * @throws {NotFoundError} if the video is not found
14866 * @throws {BadRequestError} if the language or file is invalid
14867 * @throws {InternalError} if an unexpected error occurs
14868 */
14869 upload(language: string, input: ReadableStream): Promise<StreamCaption>;
14870 /**
14871 * Generate captions or subtitles for the provided language via AI.
14872 * @param language The BCP 47 language tag to generate.
14873 * @returns The generated caption entry.
14874 * @throws {NotFoundError} if the video is not found
14875 * @throws {BadRequestError} if the language is invalid
14876 * @throws {StreamError} if a generated caption already exists
14877 * @throws {StreamError} if the video duration is too long
14878 * @throws {StreamError} if the video is missing audio
14879 * @throws {StreamError} if the requested language is not supported
14880 * @throws {InternalError} if an unexpected error occurs
14881 */
14882 generate(language: string): Promise<StreamCaption>;
14883 /**
14884 * Lists the captions or subtitles.
14885 * Use the language parameter to filter by a specific language.
14886 * @param language The optional BCP 47 language tag to filter by.
14887 * @returns The list of captions or subtitles.
14888 * @throws {NotFoundError} if the video or caption is not found
14889 * @throws {InternalError} if an unexpected error occurs
14890 */
14891 list(language?: string): Promise<StreamCaption[]>;
14892 /**
14893 * Removes the captions or subtitles from a video.
14894 * @param language The BCP 47 language tag to remove.
14895 * @returns A promise that resolves when deletion completes.
14896 * @throws {NotFoundError} if the video or caption is not found
14897 * @throws {InternalError} if an unexpected error occurs
14898 */
14899 delete(language: string): Promise<void>;
14900}
14901interface StreamScopedDownloads {
14902 /**
14903 * Generates a download for a video when a video is ready to view. Available
14904 * types are `default` and `audio`. Defaults to `default` when omitted.
14905 * @param downloadType The download type to create.
14906 * @returns The current downloads for the video.
14907 * @throws {NotFoundError} if the video is not found
14908 * @throws {BadRequestError} if the download type is invalid
14909 * @throws {StreamError} if the video duration is too long to generate a download
14910 * @throws {StreamError} if the video is not ready to stream
14911 * @throws {InternalError} if an unexpected error occurs
14912 */
14913 generate(
14914 downloadType?: StreamDownloadType,
14915 ): Promise<StreamDownloadGetResponse>;
14916 /**
14917 * Lists the downloads created for a video.
14918 * @returns The current downloads for the video.
14919 * @throws {NotFoundError} if the video or downloads are not found
14920 * @throws {InternalError} if an unexpected error occurs
14921 */
14922 get(): Promise<StreamDownloadGetResponse>;
14923 /**
14924 * Delete the downloads for a video. Available types are `default` and `audio`.
14925 * Defaults to `default` when omitted.
14926 * @param downloadType The download type to delete.
14927 * @returns A promise that resolves when deletion completes.
14928 * @throws {NotFoundError} if the video or downloads are not found
14929 * @throws {InternalError} if an unexpected error occurs
14930 */
14931 delete(downloadType?: StreamDownloadType): Promise<void>;
14932}
14933interface StreamVideos {
14934 /**
14935 * Lists all videos in a users account.
14936 * @returns The list of videos.
14937 * @throws {BadRequestError} if the parameters are invalid
14938 * @throws {InternalError} if an unexpected error occurs
14939 */
14940 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
14941}
14942interface StreamWatermarks {
14943 /**
14944 * Generate a new watermark profile
14945 * @param input The image stream to upload
14946 * @param params The watermark creation parameters.
14947 * @returns The created watermark profile.
14948 * @throws {BadRequestError} if the parameters are invalid
14949 * @throws {InvalidURLError} if the URL is invalid
14950 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14951 * @throws {InternalError} if an unexpected error occurs
14952 */
14953 generate(
14954 input: ReadableStream,
14955 params: StreamWatermarkCreateParams,
14956 ): Promise<StreamWatermark>;
14957 /**
14958 * Generate a new watermark profile
14959 * @param url The image url to upload
14960 * @param params The watermark creation parameters.
14961 * @returns The created watermark profile.
14962 * @throws {BadRequestError} if the parameters are invalid
14963 * @throws {InvalidURLError} if the URL is invalid
14964 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14965 * @throws {InternalError} if an unexpected error occurs
14966 */
14967 generate(
14968 url: string,
14969 params: StreamWatermarkCreateParams,
14970 ): Promise<StreamWatermark>;
14971 /**
14972 * Lists all watermark profiles for an account.
14973 * @returns The list of watermark profiles.
14974 * @throws {InternalError} if an unexpected error occurs
14975 */
14976 list(): Promise<StreamWatermark[]>;
14977 /**
14978 * Retrieves details for a single watermark profile.
14979 * @param watermarkId The watermark profile identifier.
14980 * @returns The watermark profile details.
14981 * @throws {NotFoundError} if the watermark is not found
14982 * @throws {InternalError} if an unexpected error occurs
14983 */
14984 get(watermarkId: string): Promise<StreamWatermark>;
14985 /**
14986 * Deletes a watermark profile.
14987 * @param watermarkId The watermark profile identifier.
14988 * @returns A promise that resolves when deletion completes.
14989 * @throws {NotFoundError} if the watermark is not found
14990 * @throws {InternalError} if an unexpected error occurs
14991 */
14992 delete(watermarkId: string): Promise<void>;
14993}
14994type StreamUpdateVideoParams = {
14995 /**
14996 * Lists the origins allowed to display the video. Enter allowed origin
14997 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14998 * video to be viewed on any origin.
14999 */
15000 allowedOrigins?: Array<string>;
15001 /**
15002 * A user-defined identifier for the media creator.
15003 */
15004 creator?: string;
15005 /**
15006 * The maximum duration in seconds for a video upload. Can be set for a
15007 * video that is not yet uploaded to limit its duration. Uploads that exceed the
15008 * specified duration will fail during processing. A value of `-1` means the value
15009 * is unknown.
15010 */
15011 maxDurationSeconds?: number;
15012 /**
15013 * A user modifiable key-value store used to reference other systems of
15014 * record for managing videos.
15015 */
15016 meta?: Record<string, string>;
15017 /**
15018 * Indicates whether the video can be a accessed using the id. When
15019 * set to `true`, a signed token must be generated with a signing key to view the
15020 * video.
15021 */
15022 requireSignedURLs?: boolean;
15023 /**
15024 * Indicates the date and time at which the video will be deleted. Omit
15025 * the field to indicate no change, or include with a `null` value to remove an
15026 * existing scheduled deletion. If specified, must be at least 30 days from upload
15027 * time.
15028 */
15029 scheduledDeletion?: string | null;
15030 /**
15031 * The timestamp for a thumbnail image calculated as a percentage value
15032 * of the video's duration. To convert from a second-wise timestamp to a
15033 * percentage, divide the desired timestamp by the total duration of the video. If
15034 * this value is not set, the default thumbnail image is taken from 0s of the
15035 * video.
15036 */
15037 thumbnailTimestampPct?: number;
15038};
15039type StreamCaption = {
15040 /**
15041 * Whether the caption was generated via AI.
15042 */
15043 generated?: boolean;
15044 /**
15045 * The language label displayed in the native language to users.
15046 */
15047 label: string;
15048 /**
15049 * The language tag in BCP 47 format.
15050 */
15051 language: string;
15052 /**
15053 * The status of a generated caption.
15054 */
15055 status?: "ready" | "inprogress" | "error";
15056};
15057type StreamDownloadStatus = "ready" | "inprogress" | "error";
15058type StreamDownloadType = "default" | "audio";
15059type StreamDownload = {
15060 /**
15061 * Indicates the progress as a percentage between 0 and 100.
15062 */
15063 percentComplete: number;
15064 /**
15065 * The status of a generated download.
15066 */
15067 status: StreamDownloadStatus;
15068 /**
15069 * The URL to access the generated download.
15070 */
15071 url?: string;
15072};
15073/**
15074 * An object with download type keys. Each key is optional and only present if that
15075 * download type has been created.
15076 */
15077type StreamDownloadGetResponse = {
15078 /**
15079 * The audio-only download. Only present if this download type has been created.
15080 */
15081 audio?: StreamDownload;
15082 /**
15083 * The default video download. Only present if this download type has been created.
15084 */
15085 default?: StreamDownload;
15086};
15087type StreamWatermarkPosition =
15088 | "upperRight"
15089 | "upperLeft"
15090 | "lowerLeft"
15091 | "lowerRight"
15092 | "center";
15093type StreamWatermark = {
15094 /**
15095 * The unique identifier for a watermark profile.
15096 */
15097 id: string;
15098 /**
15099 * The size of the image in bytes.
15100 */
15101 size: number;
15102 /**
15103 * The height of the image in pixels.
15104 */
15105 height: number;
15106 /**
15107 * The width of the image in pixels.
15108 */
15109 width: number;
15110 /**
15111 * The date and a time a watermark profile was created.
15112 */
15113 created: string;
15114 /**
15115 * The source URL for a downloaded image. If the watermark profile was created via
15116 * direct upload, this field is null.
15117 */
15118 downloadedFrom: string | null;
15119 /**
15120 * A short description of the watermark profile.
15121 */
15122 name: string;
15123 /**
15124 * The translucency of the image. A value of `0.0` makes the image completely
15125 * transparent, and `1.0` makes the image completely opaque. Note that if the image
15126 * is already semi-transparent, setting this to `1.0` will not make the image
15127 * completely opaque.
15128 */
15129 opacity: number;
15130 /**
15131 * The whitespace between the adjacent edges (determined by position) of the video
15132 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
15133 * video width or length, as determined by the algorithm.
15134 */
15135 padding: number;
15136 /**
15137 * The size of the image relative to the overall size of the video. This parameter
15138 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
15139 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
15140 */
15141 scale: number;
15142 /**
15143 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
15144 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
15145 * `padding` parameter.
15146 */
15147 position: StreamWatermarkPosition;
15148};
15149type StreamWatermarkCreateParams = {
15150 /**
15151 * A short description of the watermark profile.
15152 */
15153 name?: string;
15154 /**
15155 * The translucency of the image. A value of `0.0` makes the image completely
15156 * transparent, and `1.0` makes the image completely opaque. Note that if the
15157 * image is already semi-transparent, setting this to `1.0` will not make the
15158 * image completely opaque.
15159 */
15160 opacity?: number;
15161 /**
15162 * The whitespace between the adjacent edges (determined by position) of the
15163 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
15164 * padded video width or length, as determined by the algorithm.
15165 */
15166 padding?: number;
15167 /**
15168 * The size of the image relative to the overall size of the video. This
15169 * parameter will adapt to horizontal and vertical videos automatically. `0.0`
15170 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
15171 * entire video.
15172 */
15173 scale?: number;
15174 /**
15175 * The location of the image.
15176 */
15177 position?: StreamWatermarkPosition;
15178};
15179type StreamVideosListParams = {
15180 /**
15181 * The maximum number of videos to return.
15182 */
15183 limit?: number;
15184 /**
15185 * Return videos created before this timestamp.
15186 * (RFC3339/RFC3339Nano)
15187 */
15188 before?: string;
15189 /**
15190 * Comparison operator for the `before` field.
15191 * @default 'lt'
15192 */
15193 beforeComp?: StreamPaginationComparison;
15194 /**
15195 * Return videos created after this timestamp.
15196 * (RFC3339/RFC3339Nano)
15197 */
15198 after?: string;
15199 /**
15200 * Comparison operator for the `after` field.
15201 * @default 'gte'
15202 */
15203 afterComp?: StreamPaginationComparison;
15204};
15205type StreamPaginationComparison = "eq" | "gt" | "gte" | "lt" | "lte";
15206/**
15207 * Error object for Stream binding operations.
15208 */
15209interface StreamError extends Error {
15210 readonly code: number;
15211 readonly statusCode: number;
15212 readonly message: string;
15213 readonly stack?: string;
15214}
15215interface InternalError extends StreamError {
15216 name: "InternalError";
15217}
15218interface BadRequestError extends StreamError {
15219 name: "BadRequestError";
15220}
15221interface NotFoundError extends StreamError {
15222 name: "NotFoundError";
15223}
15224interface ForbiddenError extends StreamError {
15225 name: "ForbiddenError";
15226}
15227interface RateLimitedError extends StreamError {
15228 name: "RateLimitedError";
15229}
15230interface QuotaReachedError extends StreamError {
15231 name: "QuotaReachedError";
15232}
15233interface MaxFileSizeError extends StreamError {
15234 name: "MaxFileSizeError";
15235}
15236interface InvalidURLError extends StreamError {
15237 name: "InvalidURLError";
15238}
15239interface AlreadyUploadedError extends StreamError {
15240 name: "AlreadyUploadedError";
15241}
15242interface TooManyWatermarksError extends StreamError {
15243 name: "TooManyWatermarksError";
15244}
15245type MarkdownDocument = {
15246 name: string;
15247 blob: Blob;
15248};
15249type ConversionResponse =
15250 | {
15251 id: string;
15252 name: string;
15253 mimeType: string;
15254 format: "markdown";
15255 tokens: number;
15256 data: string;
15257 }
15258 | {
15259 id: string;
15260 name: string;
15261 mimeType: string;
15262 format: "error";
15263 error: string;
15264 };
15265type ImageConversionOptions = {
15266 descriptionLanguage?: "en" | "es" | "fr" | "it" | "pt" | "de";
15267};
15268type EmbeddedImageConversionOptions = ImageConversionOptions & {
15269 convert?: boolean;
15270 maxConvertedImages?: number;
15271};
15272type ConversionOptions = {
15273 html?: {
15274 images?: EmbeddedImageConversionOptions & {
15275 convertOGImage?: boolean;
15276 };
15277 hostname?: string;
15278 cssSelector?: string;
15279 };
15280 docx?: {
15281 images?: EmbeddedImageConversionOptions;
15282 };
15283 image?: ImageConversionOptions;
15284 pdf?: {
15285 images?: EmbeddedImageConversionOptions;
15286 metadata?: boolean;
15287 };
15288};
15289type ConversionRequestOptions = {
15290 gateway?: GatewayOptions;
15291 extraHeaders?: object;
15292 conversionOptions?: ConversionOptions;
15293};
15294type SupportedFileFormat = {
15295 mimeType: string;
15296 extension: string;
15297};
15298declare abstract class ToMarkdownService {
15299 transform(
15300 files: MarkdownDocument[],
15301 options?: ConversionRequestOptions,
15302 ): Promise<ConversionResponse[]>;
15303 transform(
15304 files: MarkdownDocument,
15305 options?: ConversionRequestOptions,
15306 ): Promise<ConversionResponse>;
15307 supported(): Promise<SupportedFileFormat[]>;
15308}
15309declare namespace TailStream {
15310 interface Header {
15311 readonly name: string;
15312 readonly value: string;
15313 }
15314 interface FetchEventInfo {
15315 readonly type: "fetch";
15316 readonly method: string;
15317 readonly url: string;
15318 readonly cfJson?: object;
15319 readonly headers: Header[];
15320 }
15321 interface JsRpcEventInfo {
15322 readonly type: "jsrpc";
15323 }
15324 interface ScheduledEventInfo {
15325 readonly type: "scheduled";
15326 readonly scheduledTime: Date;
15327 readonly cron: string;
15328 }
15329 interface AlarmEventInfo {
15330 readonly type: "alarm";
15331 readonly scheduledTime: Date;
15332 }
15333 interface QueueEventInfo {
15334 readonly type: "queue";
15335 readonly queueName: string;
15336 readonly batchSize: number;
15337 }
15338 interface EmailEventInfo {
15339 readonly type: "email";
15340 readonly mailFrom: string;
15341 readonly rcptTo: string;
15342 readonly rawSize: number;
15343 }
15344 interface TraceEventInfo {
15345 readonly type: "trace";
15346 readonly traces: (string | null)[];
15347 }
15348 interface HibernatableWebSocketEventInfoMessage {
15349 readonly type: "message";
15350 }
15351 interface HibernatableWebSocketEventInfoError {
15352 readonly type: "error";
15353 }
15354 interface HibernatableWebSocketEventInfoClose {
15355 readonly type: "close";
15356 readonly code: number;
15357 readonly wasClean: boolean;
15358 }
15359 interface HibernatableWebSocketEventInfo {
15360 readonly type: "hibernatableWebSocket";
15361 readonly info:
15362 | HibernatableWebSocketEventInfoClose
15363 | HibernatableWebSocketEventInfoError
15364 | HibernatableWebSocketEventInfoMessage;
15365 }
15366 interface CustomEventInfo {
15367 readonly type: "custom";
15368 }
15369 interface FetchResponseInfo {
15370 readonly type: "fetch";
15371 readonly statusCode: number;
15372 }
15373 interface ConnectEventInfo {
15374 readonly type: "connect";
15375 }
15376 type EventOutcome =
15377 | "ok"
15378 | "canceled"
15379 | "exception"
15380 | "unknown"
15381 | "killSwitch"
15382 | "daemonDown"
15383 | "exceededCpu"
15384 | "exceededMemory"
15385 | "loadShed"
15386 | "responseStreamDisconnected"
15387 | "scriptNotFound"
15388 | "internalError";
15389 interface ScriptVersion {
15390 readonly id: string;
15391 readonly tag?: string;
15392 readonly message?: string;
15393 }
15394 interface TracePreviewInfo {
15395 readonly id: string;
15396 readonly slug: string;
15397 readonly name: string;
15398 }
15399 interface Onset {
15400 readonly type: "onset";
15401 readonly attributes: Attribute[];
15402 // id for the span being opened by this Onset event.
15403 readonly spanId: string;
15404 readonly dispatchNamespace?: string;
15405 readonly entrypoint?: string;
15406 readonly executionModel: string;
15407 readonly scriptName?: string;
15408 readonly scriptTags?: string[];
15409 readonly scriptVersion?: ScriptVersion;
15410 readonly preview?: TracePreviewInfo;
15411 readonly info:
15412 | FetchEventInfo
15413 | ConnectEventInfo
15414 | JsRpcEventInfo
15415 | ScheduledEventInfo
15416 | AlarmEventInfo
15417 | QueueEventInfo
15418 | EmailEventInfo
15419 | TraceEventInfo
15420 | HibernatableWebSocketEventInfo
15421 | CustomEventInfo;
15422 }
15423 interface Outcome {
15424 readonly type: "outcome";
15425 readonly outcome: EventOutcome;
15426 readonly cpuTime: number;
15427 readonly wallTime: number;
15428 }
15429 interface SpanOpen {
15430 readonly type: "spanOpen";
15431 readonly name: string;
15432 // id for the span being opened by this SpanOpen event.
15433 readonly spanId: string;
15434 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
15435 }
15436 interface SpanClose {
15437 readonly type: "spanClose";
15438 readonly outcome: EventOutcome;
15439 }
15440 interface DiagnosticChannelEvent {
15441 readonly type: "diagnosticChannel";
15442 readonly channel: string;
15443 readonly message: any;
15444 }
15445 interface Exception {
15446 readonly type: "exception";
15447 readonly name: string;
15448 readonly message: string;
15449 readonly stack?: string;
15450 }
15451 interface Log {
15452 readonly type: "log";
15453 readonly level: "debug" | "error" | "info" | "log" | "warn";
15454 readonly message: object;
15455 }
15456 interface DroppedEventsDiagnostic {
15457 readonly diagnosticsType: "droppedEvents";
15458 readonly count: number;
15459 }
15460 interface StreamDiagnostic {
15461 readonly type: "streamDiagnostic";
15462 // To add new diagnostic types, define a new interface and add it to this union type.
15463 readonly diagnostic: DroppedEventsDiagnostic;
15464 }
15465 // This marks the worker handler return information.
15466 // This is separate from Outcome because the worker invocation can live for a long time after
15467 // returning. For example - Websockets that return an http upgrade response but then continue
15468 // streaming information or SSE http connections.
15469 interface Return {
15470 readonly type: "return";
15471 readonly info?: FetchResponseInfo;
15472 }
15473 interface Attribute {
15474 readonly name: string;
15475 readonly value:
15476 | string
15477 | string[]
15478 | boolean
15479 | boolean[]
15480 | number
15481 | number[]
15482 | bigint
15483 | bigint[];
15484 }
15485 interface Attributes {
15486 readonly type: "attributes";
15487 readonly info: Attribute[];
15488 }
15489 type EventType =
15490 | Onset
15491 | Outcome
15492 | SpanOpen
15493 | SpanClose
15494 | DiagnosticChannelEvent
15495 | Exception
15496 | Log
15497 | StreamDiagnostic
15498 | Return
15499 | Attributes;
15500 // Context in which this trace event lives.
15501 interface SpanContext {
15502 // Single id for the entire top-level invocation
15503 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
15504 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
15505 // should use a new traceId.
15506 readonly traceId: string;
15507 // spanId in which this event is handled
15508 // for Onset and SpanOpen events this would be the parent span id
15509 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
15510 // For Hibernate and Mark this would be the span under which they were emitted.
15511 // spanId is not set ONLY if:
15512 // 1. This is an Onset event
15513 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
15514 readonly spanId?: string;
15515 // W3C trace flags from an upstream traceparent. Absent when no upstream
15516 // sampling decision was made.
15517 readonly traceFlags?: number;
15518 }
15519 interface TailEvent<Event extends EventType> {
15520 // invocation id of the currently invoked worker stage.
15521 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
15522 readonly invocationId: string;
15523 // Inherited spanContext for this event.
15524 readonly spanContext: SpanContext;
15525 readonly timestamp: Date;
15526 readonly sequence: number;
15527 readonly event: Event;
15528 }
15529 type TailEventHandler<Event extends EventType = EventType> = (
15530 event: TailEvent<Event>,
15531 ) => void | Promise<void>;
15532 type TailEventHandlerObject = {
15533 outcome?: TailEventHandler<Outcome>;
15534 spanOpen?: TailEventHandler<SpanOpen>;
15535 spanClose?: TailEventHandler<SpanClose>;
15536 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
15537 exception?: TailEventHandler<Exception>;
15538 log?: TailEventHandler<Log>;
15539 return?: TailEventHandler<Return>;
15540 attributes?: TailEventHandler<Attributes>;
15541 };
15542 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
15543}
15544// Copyright (c) 2022-2023 Cloudflare, Inc.
15545// Licensed under the Apache 2.0 license found in the LICENSE file or at:
15546// https://opensource.org/licenses/Apache-2.0
15547/**
15548 * Data types supported for holding vector metadata.
15549 */
15550type VectorizeVectorMetadataValue = string | number | boolean | string[];
15551/**
15552 * Additional information to associate with a vector.
15553 */
15554type VectorizeVectorMetadata =
15555 | VectorizeVectorMetadataValue
15556 | Record<string, VectorizeVectorMetadataValue>;
15557type VectorFloatArray = Float32Array | Float64Array;
15558interface VectorizeError {
15559 code?: number;
15560 error: string;
15561}
15562/**
15563 * Comparison logic/operation to use for metadata filtering.
15564 *
15565 * This list is expected to grow as support for more operations are released.
15566 */
15567type VectorizeVectorMetadataFilterOp =
15568 | "$eq"
15569 | "$ne"
15570 | "$lt"
15571 | "$lte"
15572 | "$gt"
15573 | "$gte";
15574type VectorizeVectorMetadataFilterCollectionOp = "$in" | "$nin";
15575/**
15576 * Filter criteria for vector metadata used to limit the retrieved query result set.
15577 */
15578type VectorizeVectorMetadataFilter = {
15579 [field: string]:
15580 | Exclude<VectorizeVectorMetadataValue, string[]>
15581 | null
15582 | {
15583 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<
15584 VectorizeVectorMetadataValue,
15585 string[]
15586 > | null;
15587 }
15588 | {
15589 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<
15590 VectorizeVectorMetadataValue,
15591 string[]
15592 >[];
15593 };
15594};
15595/**
15596 * Supported distance metrics for an index.
15597 * Distance metrics determine how other "similar" vectors are determined.
15598 */
15599type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
15600/**
15601 * Metadata return levels for a Vectorize query.
15602 *
15603 * Default to "none".
15604 *
15605 * @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.
15606 * @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).
15607 * @property none No indexed metadata will be returned.
15608 */
15609type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
15610interface VectorizeQueryOptions {
15611 topK?: number;
15612 namespace?: string;
15613 returnValues?: boolean;
15614 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
15615 filter?: VectorizeVectorMetadataFilter;
15616}
15617/**
15618 * Information about the configuration of an index.
15619 */
15620type VectorizeIndexConfig =
15621 | {
15622 dimensions: number;
15623 metric: VectorizeDistanceMetric;
15624 }
15625 | {
15626 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
15627 };
15628/**
15629 * Metadata about an existing index.
15630 *
15631 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15632 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
15633 */
15634interface VectorizeIndexDetails {
15635 /** The unique ID of the index */
15636 readonly id: string;
15637 /** The name of the index. */
15638 name: string;
15639 /** (optional) A human readable description for the index. */
15640 description?: string;
15641 /** The index configuration, including the dimension size and distance metric. */
15642 config: VectorizeIndexConfig;
15643 /** The number of records containing vectors within the index. */
15644 vectorsCount: number;
15645}
15646/**
15647 * Metadata about an existing index.
15648 */
15649interface VectorizeIndexInfo {
15650 /** The number of records containing vectors within the index. */
15651 vectorCount: number;
15652 /** Number of dimensions the index has been configured for. */
15653 dimensions: number;
15654 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
15655 processedUpToDatetime: number;
15656 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
15657 processedUpToMutation: number;
15658}
15659/**
15660 * Represents a single vector value set along with its associated metadata.
15661 */
15662interface VectorizeVector {
15663 /** 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. */
15664 id: string;
15665 /** The vector values */
15666 values: VectorFloatArray | number[];
15667 /** The namespace this vector belongs to. */
15668 namespace?: string;
15669 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
15670 metadata?: Record<string, VectorizeVectorMetadata>;
15671}
15672/**
15673 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
15674 */
15675type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
15676 Omit<VectorizeVector, "values"> & {
15677 /** The score or rank for similarity, when returned as a result */
15678 score: number;
15679 };
15680/**
15681 * A set of matching {@link VectorizeMatch} for a particular query.
15682 */
15683interface VectorizeMatches {
15684 matches: VectorizeMatch[];
15685 count: number;
15686}
15687/**
15688 * Results of an operation that performed a mutation on a set of vectors.
15689 * Here, `ids` is a list of vectors that were successfully processed.
15690 *
15691 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15692 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
15693 */
15694interface VectorizeVectorMutation {
15695 /* List of ids of vectors that were successfully processed. */
15696 ids: string[];
15697 /* Total count of the number of processed vectors. */
15698 count: number;
15699}
15700/**
15701 * Result type indicating a mutation on the Vectorize Index.
15702 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
15703 */
15704interface VectorizeAsyncMutation {
15705 /** The unique identifier for the async mutation operation containing the changeset. */
15706 mutationId: string;
15707}
15708/**
15709 * A Vectorize Vector Search Index for querying vectors/embeddings.
15710 *
15711 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15712 * See {@link Vectorize} for its new implementation.
15713 */
15714declare abstract class VectorizeIndex {
15715 /**
15716 * Get information about the currently bound index.
15717 * @returns A promise that resolves with information about the current index.
15718 */
15719 public describe(): Promise<VectorizeIndexDetails>;
15720 /**
15721 * Use the provided vector to perform a similarity search across the index.
15722 * @param vector Input vector that will be used to drive the similarity search.
15723 * @param options Configuration options to massage the returned data.
15724 * @returns A promise that resolves with matched and scored vectors.
15725 */
15726 public query(
15727 vector: VectorFloatArray | number[],
15728 options?: VectorizeQueryOptions,
15729 ): Promise<VectorizeMatches>;
15730 /**
15731 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15732 * @param vectors List of vectors that will be inserted.
15733 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15734 */
15735 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15736 /**
15737 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15738 * @param vectors List of vectors that will be upserted.
15739 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15740 */
15741 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15742 /**
15743 * Delete a list of vectors with a matching id.
15744 * @param ids List of vector ids that should be deleted.
15745 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
15746 */
15747 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
15748 /**
15749 * Get a list of vectors with a matching id.
15750 * @param ids List of vector ids that should be returned.
15751 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15752 */
15753 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15754}
15755/**
15756 * A Vectorize Vector Search Index for querying vectors/embeddings.
15757 *
15758 * Mutations in this version are async, returning a mutation id.
15759 */
15760declare abstract class Vectorize {
15761 /**
15762 * Get information about the currently bound index.
15763 * @returns A promise that resolves with information about the current index.
15764 */
15765 public describe(): Promise<VectorizeIndexInfo>;
15766 /**
15767 * Use the provided vector to perform a similarity search across the index.
15768 * @param vector Input vector that will be used to drive the similarity search.
15769 * @param options Configuration options to massage the returned data.
15770 * @returns A promise that resolves with matched and scored vectors.
15771 */
15772 public query(
15773 vector: VectorFloatArray | number[],
15774 options?: VectorizeQueryOptions,
15775 ): Promise<VectorizeMatches>;
15776 /**
15777 * Use the provided vector-id to perform a similarity search across the index.
15778 * @param vectorId Id for a vector in the index against which the index should be queried.
15779 * @param options Configuration options to massage the returned data.
15780 * @returns A promise that resolves with matched and scored vectors.
15781 */
15782 public queryById(
15783 vectorId: string,
15784 options?: VectorizeQueryOptions,
15785 ): Promise<VectorizeMatches>;
15786 /**
15787 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15788 * @param vectors List of vectors that will be inserted.
15789 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
15790 */
15791 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15792 /**
15793 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15794 * @param vectors List of vectors that will be upserted.
15795 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
15796 */
15797 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15798 /**
15799 * Delete a list of vectors with a matching id.
15800 * @param ids List of vector ids that should be deleted.
15801 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
15802 */
15803 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
15804 /**
15805 * Get a list of vectors with a matching id.
15806 * @param ids List of vector ids that should be returned.
15807 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15808 */
15809 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15810}
15811/**
15812 * The interface for "version_metadata" binding
15813 * providing metadata about the Worker Version using this binding.
15814 */
15815type WorkerVersionMetadata = {
15816 /** The ID of the Worker Version using this binding */
15817 id: string;
15818 /** The tag of the Worker Version using this binding */
15819 tag: string;
15820 /** The timestamp of when the Worker Version was uploaded */
15821 timestamp: string;
15822};
15823interface DynamicDispatchLimits {
15824 /**
15825 * Limit CPU time in milliseconds.
15826 */
15827 cpuMs?: number;
15828 /**
15829 * Limit number of subrequests.
15830 */
15831 subRequests?: number;
15832}
15833interface DynamicDispatchOptions {
15834 /**
15835 * Limit resources of invoked Worker script.
15836 */
15837 limits?: DynamicDispatchLimits;
15838 /**
15839 * Arguments for outbound Worker script, if configured.
15840 */
15841 outbound?: {
15842 [key: string]: any;
15843 };
15844}
15845interface DispatchNamespace {
15846 /**
15847 * @param name Name of the Worker script.
15848 * @param args Arguments to Worker script.
15849 * @param options Options for Dynamic Dispatch invocation.
15850 * @returns A Fetcher object that allows you to send requests to the Worker script.
15851 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
15852 */
15853 get(
15854 name: string,
15855 args?: {
15856 [key: string]: any;
15857 },
15858 options?: DynamicDispatchOptions,
15859 ): Fetcher;
15860}
15861declare module "cloudflare:workflows" {
15862 /**
15863 * NonRetryableError allows for a user to throw a fatal error
15864 * that makes a Workflow instance fail immediately without triggering a retry
15865 */
15866 export class NonRetryableError extends Error {
15867 public constructor(message: string, name?: string);
15868 }
15869}
15870declare abstract class Workflow<PARAMS = unknown> {
15871 /**
15872 * Get a handle to an existing instance of the Workflow.
15873 * @param id Id for the instance of this Workflow
15874 * @returns A promise that resolves with a handle for the Instance
15875 */
15876 public get(id: string): Promise<WorkflowInstance>;
15877 /**
15878 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
15879 * @param options Options when creating an instance including id and params
15880 * @returns A promise that resolves with a handle for the Instance
15881 */
15882 public create(
15883 options?: WorkflowInstanceCreateOptions<PARAMS>,
15884 ): Promise<WorkflowInstance>;
15885 /**
15886 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
15887 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
15888 * @param batch List of Options when creating an instance including name and params
15889 * @returns A promise that resolves with a list of handles for the created instances.
15890 */
15891 public createBatch(
15892 batch: WorkflowInstanceCreateOptions<PARAMS>[],
15893 ): Promise<WorkflowInstance[]>;
15894}
15895type WorkflowDurationLabel =
15896 | "second"
15897 | "minute"
15898 | "hour"
15899 | "day"
15900 | "week"
15901 | "month"
15902 | "year";
15903type WorkflowSleepDuration =
15904 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
15905 | number;
15906type WorkflowRetentionDuration = WorkflowSleepDuration;
15907interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
15908 /**
15909 * An id for your Workflow instance. Must be unique within the Workflow.
15910 */
15911 id?: string;
15912 /**
15913 * The event payload the Workflow instance is triggered with
15914 */
15915 params?: PARAMS;
15916 /**
15917 * The retention policy for Workflow instance.
15918 * Defaults to the maximum retention period available for the owner's account.
15919 */
15920 retention?: {
15921 successRetention?: WorkflowRetentionDuration;
15922 errorRetention?: WorkflowRetentionDuration;
15923 };
15924}
15925type InstanceStatus = {
15926 status:
15927 | "queued" // means that instance is waiting to be started (see concurrency limits)
15928 | "running"
15929 | "paused"
15930 | "errored"
15931 | "terminated" // user terminated the instance while it was running
15932 | "complete"
15933 | "waiting" // instance is hibernating and waiting for sleep or event to finish
15934 | "waitingForPause" // instance is finishing the current work to pause
15935 | "unknown";
15936 error?: {
15937 name: string;
15938 message: string;
15939 };
15940 output?: unknown;
15941};
15942interface WorkflowError {
15943 code?: number;
15944 message: string;
15945}
15946interface WorkflowInstanceRestartOptions {
15947 /**
15948 * Restart from a specific step. If omitted, the instance restarts from the beginning.
15949 * The step must exist in the instance's execution history.
15950 */
15951 from?: {
15952 /**
15953 * The step name as defined in your workflow code.
15954 */
15955 name: string;
15956 /**
15957 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15958 * @default 1
15959 */
15960 count?: number;
15961 /**
15962 * Step type filter. Use when different step types share the same name.
15963 */
15964 type?: "do" | "sleep" | "waitForEvent";
15965 };
15966}
15967declare abstract class WorkflowInstance {
15968 public id: string;
15969 /**
15970 * Pause the instance.
15971 */
15972 public pause(): Promise<void>;
15973 /**
15974 * Resume the instance. If it is already running, an error will be thrown.
15975 */
15976 public resume(): Promise<void>;
15977 /**
15978 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
15979 */
15980 public terminate(): Promise<void>;
15981 /**
15982 * Restart the instance. Optionally restart from a specific step, preserving
15983 * cached results for all steps before it.
15984 * @param options Options for the restart, including an optional step to restart from.
15985 */
15986 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15987 /**
15988 * Returns the current status of the instance.
15989 */
15990 public status(): Promise<InstanceStatus>;
15991 /**
15992 * Send an event to this instance.
15993 */
15994 public sendEvent({
15995 type,
15996 payload,
15997 }: {
15998 type: string;
15999 payload: unknown;
16000 }): Promise<void>;
16001}