Skip to content
File

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

typescript15954 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
17export declare 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 */
23export declare 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}
72export type WorkerGlobalScopeEventMap = {
73 fetch: FetchEvent;
74 scheduled: ScheduledEvent;
75 queue: QueueEvent;
76 unhandledrejection: PromiseRejectionEvent;
77 rejectionhandled: PromiseRejectionEvent;
78};
79export declare 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 */
87export interface 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}
199export declare const console: Console;
200export type BufferSource = ArrayBufferView | ArrayBuffer;
201export type TypedArray =
202 | Int8Array
203 | Uint8Array
204 | Uint8ClampedArray
205 | Int16Array
206 | Uint16Array
207 | Int32Array
208 | Uint32Array
209 | Float32Array
210 | Float64Array
211 | BigInt64Array
212 | BigUint64Array;
213export declare 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 */
293export interface 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}
398export declare function addEventListener<
399 Type extends keyof WorkerGlobalScopeEventMap,
400>(
401 type: Type,
402 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
403 options?: EventTargetAddEventListenerOptions | boolean,
404): void;
405export declare function removeEventListener<
406 Type extends keyof WorkerGlobalScopeEventMap,
407>(
408 type: Type,
409 handler: EventListenerOrEventListenerObject<WorkerGlobalScopeEventMap[Type]>,
410 options?: EventTargetEventListenerOptions | boolean,
411): void;
412/**
413 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
414 *
415 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
416 */
417export declare function dispatchEvent(
418 event: WorkerGlobalScopeEventMap[keyof WorkerGlobalScopeEventMap],
419): boolean;
420/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/btoa) */
421export declare function btoa(data: string): string;
422/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/atob) */
423export declare function atob(data: string): string;
424/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
425export declare function setTimeout(
426 callback: (...args: any[]) => void,
427 msDelay?: number,
428): number;
429/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setTimeout) */
430export declare function setTimeout<Args extends any[]>(
431 callback: (...args: Args) => void,
432 msDelay?: number,
433 ...args: Args
434): number;
435/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearTimeout) */
436export declare function clearTimeout(timeoutId: number | null): void;
437/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
438export declare function setInterval(
439 callback: (...args: any[]) => void,
440 msDelay?: number,
441): number;
442/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/setInterval) */
443export declare function setInterval<Args extends any[]>(
444 callback: (...args: Args) => void,
445 msDelay?: number,
446 ...args: Args
447): number;
448/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/clearInterval) */
449export declare function clearInterval(timeoutId: number | null): void;
450/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/queueMicrotask) */
451export declare function queueMicrotask(task: Function): void;
452/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/structuredClone) */
453export declare function structuredClone<T>(
454 value: T,
455 options?: StructuredSerializeOptions,
456): T;
457/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/reportError) */
458export declare function reportError(error: any): void;
459/* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) */
460export declare function fetch(
461 input: RequestInfo | URL,
462 init?: RequestInit<RequestInitCfProperties>,
463): Promise<Response>;
464export declare const self: ServiceWorkerGlobalScope;
465/**
466 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
467 * The Workers runtime implements the full surface of this API, but with some differences in
468 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
469 * compared to those implemented in most browsers.
470 *
471 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
472 */
473export declare const crypto: Crypto;
474/**
475 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
476 *
477 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
478 */
479export declare const caches: CacheStorage;
480export declare const scheduler: Scheduler;
481/**
482 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
483 * as well as timing of subrequests and other operations.
484 *
485 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
486 */
487export declare const performance: Performance;
488export declare const Cloudflare: Cloudflare;
489export declare const origin: string;
490export declare const navigator: Navigator;
491export interface TestController {}
492export interface ExecutionContext<Props = unknown> {
493 waitUntil(promise: Promise<any>): void;
494 passThroughOnException(): void;
495 readonly exports: Cloudflare.Exports;
496 readonly props: Props;
497 cache?: CacheContext;
498 readonly version?: {
499 readonly metadata?: {
500 readonly id: string;
501 };
502 readonly cohort?: string;
503 readonly key?: string;
504 readonly override?: string;
505 };
506 tracing?: Tracing;
507 abort(reason?: any): void;
508}
509export type ExportedHandlerFetchHandler<
510 Env = unknown,
511 CfHostMetadata = unknown,
512 Props = unknown,
513> = (
514 request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
515 env: Env,
516 ctx: ExecutionContext<Props>,
517) => Response | Promise<Response>;
518export type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (
519 socket: Socket,
520 env: Env,
521 ctx: ExecutionContext<Props>,
522) => void | Promise<void>;
523export type ExportedHandlerTailHandler<Env = unknown, Props = unknown> = (
524 events: TraceItem[],
525 env: Env,
526 ctx: ExecutionContext<Props>,
527) => void | Promise<void>;
528export type ExportedHandlerTraceHandler<Env = unknown, Props = unknown> = (
529 traces: TraceItem[],
530 env: Env,
531 ctx: ExecutionContext<Props>,
532) => void | Promise<void>;
533export type ExportedHandlerTailStreamHandler<Env = unknown, Props = unknown> = (
534 event: TailStream.TailEvent<TailStream.Onset>,
535 env: Env,
536 ctx: ExecutionContext<Props>,
537) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
538export type ExportedHandlerScheduledHandler<Env = unknown, Props = unknown> = (
539 controller: ScheduledController,
540 env: Env,
541 ctx: ExecutionContext<Props>,
542) => void | Promise<void>;
543export type ExportedHandlerQueueHandler<
544 Env = unknown,
545 Message = unknown,
546 Props = unknown,
547> = (
548 batch: MessageBatch<Message>,
549 env: Env,
550 ctx: ExecutionContext<Props>,
551) => void | Promise<void>;
552export type ExportedHandlerTestHandler<Env = unknown, Props = unknown> = (
553 controller: TestController,
554 env: Env,
555 ctx: ExecutionContext<Props>,
556) => void | Promise<void>;
557export interface ExportedHandler<
558 Env = unknown,
559 QueueHandlerMessage = unknown,
560 CfHostMetadata = unknown,
561 Props = unknown,
562> {
563 fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata, Props>;
564 connect?: ExportedHandlerConnectHandler<Env, Props>;
565 tail?: ExportedHandlerTailHandler<Env, Props>;
566 trace?: ExportedHandlerTraceHandler<Env, Props>;
567 tailStream?: ExportedHandlerTailStreamHandler<Env, Props>;
568 scheduled?: ExportedHandlerScheduledHandler<Env, Props>;
569 test?: ExportedHandlerTestHandler<Env, Props>;
570 email?: EmailExportedHandler<Env, Props>;
571 queue?: ExportedHandlerQueueHandler<Env, QueueHandlerMessage, Props>;
572}
573export interface StructuredSerializeOptions {
574 transfer?: any[];
575}
576export declare abstract class Navigator {
577 sendBeacon(url: string, body?: BodyInit): boolean;
578 readonly userAgent: string;
579 readonly hardwareConcurrency: number;
580 readonly platform: string;
581 readonly language: string;
582 readonly languages: string[];
583 readonly storage: StorageManager;
584}
585export interface AlarmInvocationInfo {
586 readonly isRetry: boolean;
587 readonly retryCount: number;
588 readonly scheduledTime: number;
589}
590export interface Cloudflare {
591 readonly compatibilityFlags: Record<string, boolean>;
592}
593export interface CachePurgeError {
594 code: number;
595 message: string;
596}
597export interface CachePurgeResult {
598 success: boolean;
599 errors: CachePurgeError[];
600}
601export interface CachePurgeOptions {
602 tags?: string[];
603 pathPrefixes?: string[];
604 purgeEverything?: boolean;
605}
606export interface CacheContext {
607 purge(options: CachePurgeOptions): Promise<CachePurgeResult>;
608}
609export declare abstract class ColoLocalActorNamespace {
610 get(actorId: string): Fetcher;
611}
612export interface DurableObject {
613 fetch(request: Request): Response | Promise<Response>;
614 connect?(socket: Socket): void | Promise<void>;
615 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
616 webSocketMessage?(
617 ws: WebSocket,
618 message: string | ArrayBuffer,
619 ): void | Promise<void>;
620 webSocketClose?(
621 ws: WebSocket,
622 code: number,
623 reason: string,
624 wasClean: boolean,
625 ): void | Promise<void>;
626 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
627}
628export type DurableObjectStub<
629 T extends Rpc.DurableObjectBranded | undefined = undefined,
630> = Fetcher<
631 T,
632 "alarm" | "connect" | "webSocketMessage" | "webSocketClose" | "webSocketError"
633> & {
634 readonly id: DurableObjectId;
635 readonly name?: string;
636};
637export interface DurableObjectId {
638 toString(): string;
639 equals(other: DurableObjectId): boolean;
640 readonly name?: string;
641 readonly jurisdiction?: string;
642}
643export declare abstract class DurableObjectNamespace<
644 T extends Rpc.DurableObjectBranded | undefined = undefined,
645> {
646 newUniqueId(
647 options?: DurableObjectNamespaceNewUniqueIdOptions,
648 ): DurableObjectId;
649 idFromName(name: string): DurableObjectId;
650 idFromString(id: string): DurableObjectId;
651 get(
652 id: DurableObjectId,
653 options?: DurableObjectNamespaceGetDurableObjectOptions,
654 ): DurableObjectStub<T>;
655 getByName(
656 name: string,
657 options?: DurableObjectNamespaceGetDurableObjectOptions,
658 ): DurableObjectStub<T>;
659 getExisting(
660 id: DurableObjectId,
661 options?: DurableObjectNamespaceGetDurableObjectOptions,
662 ): DurableObjectStub<T>;
663 jurisdiction(
664 jurisdiction: DurableObjectJurisdiction,
665 ): DurableObjectNamespace<T>;
666}
667export type DurableObjectJurisdiction = "eu" | "fedramp" | "fedramp-high";
668export interface DurableObjectNamespaceNewUniqueIdOptions {
669 jurisdiction?: DurableObjectJurisdiction;
670}
671export type DurableObjectLocationHint =
672 | "wnam"
673 | "enam"
674 | "sam"
675 | "weur"
676 | "eeur"
677 | "apac"
678 | "oc"
679 | "afr"
680 | "me";
681export type DurableObjectRoutingMode = "primary-only";
682export interface DurableObjectNamespaceGetDurableObjectOptions {
683 locationHint?: DurableObjectLocationHint;
684 routingMode?: DurableObjectRoutingMode;
685 version?: {
686 cohort?: string;
687 };
688}
689export interface DurableObjectClass<
690 _T extends Rpc.DurableObjectBranded | undefined = undefined,
691> {}
692export interface DurableObjectNamespaceGetDurableObjectOptionsVersionOptions {
693 cohort?: string;
694}
695export interface DurableObjectState<Props = unknown> {
696 waitUntil(promise: Promise<any>): void;
697 readonly exports: Cloudflare.Exports;
698 readonly props: Props;
699 readonly id: DurableObjectId;
700 readonly storage: DurableObjectStorage;
701 container?: Container;
702 facets: DurableObjectFacets;
703 version?: DurableObjectStateVersion;
704 readonly primaryStub?: DurableObjectStub;
705 blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
706 acceptWebSocket(ws: WebSocket, tags?: string[]): void;
707 getWebSockets(tag?: string): WebSocket[];
708 setWebSocketAutoResponse(maybeReqResp?: WebSocketRequestResponsePair): void;
709 getWebSocketAutoResponse(): WebSocketRequestResponsePair | null;
710 getWebSocketAutoResponseTimestamp(ws: WebSocket): Date | null;
711 setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
712 getHibernatableWebSocketEventTimeout(): number | null;
713 getTags(ws: WebSocket): string[];
714 abort(reason?: string): void;
715 configureReadReplication(
716 options: DurableObjectReadReplicationOptions,
717 ): Promise<void>;
718}
719export interface DurableObjectTransaction {
720 get<T = unknown>(
721 key: string,
722 options?: DurableObjectGetOptions,
723 ): Promise<T | undefined>;
724 get<T = unknown>(
725 keys: string[],
726 options?: DurableObjectGetOptions,
727 ): Promise<Map<string, T>>;
728 list<T = unknown>(
729 options?: DurableObjectListOptions,
730 ): Promise<Map<string, T>>;
731 put<T>(
732 key: string,
733 value: T,
734 options?: DurableObjectPutOptions,
735 ): Promise<void>;
736 put<T>(
737 entries: Record<string, T>,
738 options?: DurableObjectPutOptions,
739 ): Promise<void>;
740 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
741 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
742 rollback(): void;
743 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
744 setAlarm(
745 scheduledTime: number | Date,
746 options?: DurableObjectSetAlarmOptions,
747 ): Promise<void>;
748 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
749}
750export interface DurableObjectStorage {
751 get<T = unknown>(
752 key: string,
753 options?: DurableObjectGetOptions,
754 ): Promise<T | undefined>;
755 get<T = unknown>(
756 keys: string[],
757 options?: DurableObjectGetOptions,
758 ): Promise<Map<string, T>>;
759 list<T = unknown>(
760 options?: DurableObjectListOptions,
761 ): Promise<Map<string, T>>;
762 put<T>(
763 key: string,
764 value: T,
765 options?: DurableObjectPutOptions,
766 ): Promise<void>;
767 put<T>(
768 entries: Record<string, T>,
769 options?: DurableObjectPutOptions,
770 ): Promise<void>;
771 delete(key: string, options?: DurableObjectPutOptions): Promise<boolean>;
772 delete(keys: string[], options?: DurableObjectPutOptions): Promise<number>;
773 deleteAll(options?: DurableObjectPutOptions): Promise<void>;
774 transaction<T>(
775 closure: (txn: DurableObjectTransaction) => Promise<T>,
776 ): Promise<T>;
777 getAlarm(options?: DurableObjectGetAlarmOptions): Promise<number | null>;
778 setAlarm(
779 scheduledTime: number | Date,
780 options?: DurableObjectSetAlarmOptions,
781 ): Promise<void>;
782 deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
783 sync(): Promise<void>;
784 sql: SqlStorage;
785 kv: SyncKvStorage;
786 transactionSync<T>(closure: () => T): T;
787 getCurrentBookmark(): Promise<string>;
788 getBookmarkForTime(timestamp: number | Date): Promise<string>;
789 onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
790 waitForBookmark(bookmark: string): Promise<void>;
791 /** @deprecated Use `ctx.primaryStub` instead. */
792 readonly primary?: DurableObjectStub;
793 /** @deprecated Use `ctx.configureReadReplication()` instead. */
794 ensureReplicas(): void;
795 /** @deprecated Use `ctx.configureReadReplication()` instead. */
796 disableReplicas(): void;
797}
798export interface DurableObjectReadReplicationOptions {
799 mode: "auto" | "disabled";
800}
801export interface DurableObjectListOptions {
802 start?: string;
803 startAfter?: string;
804 end?: string;
805 prefix?: string;
806 reverse?: boolean;
807 limit?: number;
808 allowConcurrency?: boolean;
809 noCache?: boolean;
810}
811export interface DurableObjectGetOptions {
812 allowConcurrency?: boolean;
813 noCache?: boolean;
814}
815export interface DurableObjectGetAlarmOptions {
816 allowConcurrency?: boolean;
817}
818export interface DurableObjectPutOptions {
819 allowConcurrency?: boolean;
820 allowUnconfirmed?: boolean;
821 noCache?: boolean;
822}
823export interface DurableObjectSetAlarmOptions {
824 allowConcurrency?: boolean;
825 allowUnconfirmed?: boolean;
826}
827export declare class WebSocketRequestResponsePair {
828 constructor(request: string, response: string);
829 get request(): string;
830 get response(): string;
831}
832export interface DurableObjectFacets {
833 get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
834 name: string,
835 getStartupOptions: () =>
836 | FacetStartupOptions<T>
837 | Promise<FacetStartupOptions<T>>,
838 ): Fetcher<T>;
839 abort(name: string, reason: any): void;
840 delete(name: string): void;
841}
842export interface FacetStartupOptions<
843 T extends Rpc.DurableObjectBranded | undefined = undefined,
844> {
845 id?: DurableObjectId | string;
846 class: DurableObjectClass<T>;
847}
848export interface DurableObjectStateVersion {
849 cohort?: string;
850}
851export interface AnalyticsEngineDataset {
852 writeDataPoint(event?: AnalyticsEngineDataPoint): void;
853}
854export interface AnalyticsEngineDataPoint {
855 indexes?: ((ArrayBuffer | string) | null)[];
856 doubles?: number[];
857 blobs?: ((ArrayBuffer | string) | null)[];
858}
859/**
860 * The **`Event`** interface represents an event which takes place on an `EventTarget`.
861 *
862 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event)
863 */
864export declare class Event {
865 constructor(type: string, init?: EventInit);
866 /**
867 * The **`type`** read-only property of the Event interface returns a string containing the event's type.
868 *
869 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/type)
870 */
871 get type(): string;
872 /**
873 * The **`eventPhase`** read-only property of the being evaluated.
874 *
875 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/eventPhase)
876 */
877 get eventPhase(): number;
878 /**
879 * The read-only **`composed`** property of the or not the event will propagate across the shadow DOM boundary into the standard DOM.
880 *
881 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composed)
882 */
883 get composed(): boolean;
884 /**
885 * The **`bubbles`** read-only property of the Event interface indicates whether the event bubbles up through the DOM tree or not.
886 *
887 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/bubbles)
888 */
889 get bubbles(): boolean;
890 /**
891 * 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.
892 *
893 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelable)
894 */
895 get cancelable(): boolean;
896 /**
897 * 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.
898 *
899 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/defaultPrevented)
900 */
901 get defaultPrevented(): boolean;
902 /**
903 * The Event property **`returnValue`** indicates whether the default action for this event has been prevented or not.
904 * @deprecated
905 *
906 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/returnValue)
907 */
908 get returnValue(): boolean;
909 /**
910 * The **`currentTarget`** read-only property of the Event interface identifies the element to which the event handler has been attached.
911 *
912 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/currentTarget)
913 */
914 get currentTarget(): EventTarget | null;
915 /**
916 * The read-only **`target`** property of the dispatched.
917 *
918 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/target)
919 */
920 get target(): EventTarget | undefined;
921 /**
922 * The deprecated **`Event.srcElement`** is an alias for the Event.target property.
923 * @deprecated
924 *
925 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/srcElement)
926 */
927 get srcElement(): EventTarget | undefined;
928 /**
929 * The **`timeStamp`** read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
930 *
931 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/timeStamp)
932 */
933 get timeStamp(): number;
934 /**
935 * 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.
936 *
937 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/isTrusted)
938 */
939 readonly isTrusted: boolean;
940 /**
941 * The **`cancelBubble`** property of the Event interface is deprecated.
942 * @deprecated
943 *
944 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
945 */
946 get cancelBubble(): boolean;
947 /**
948 * The **`cancelBubble`** property of the Event interface is deprecated.
949 * @deprecated
950 *
951 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/cancelBubble)
952 */
953 set cancelBubble(value: boolean);
954 /**
955 * 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.
956 *
957 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopImmediatePropagation)
958 */
959 stopImmediatePropagation(): void;
960 /**
961 * 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.
962 *
963 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/preventDefault)
964 */
965 preventDefault(): void;
966 /**
967 * The **`stopPropagation()`** method of the Event interface prevents further propagation of the current event in the capturing and bubbling phases.
968 *
969 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/stopPropagation)
970 */
971 stopPropagation(): void;
972 /**
973 * 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.
974 *
975 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Event/composedPath)
976 */
977 composedPath(): EventTarget[];
978 static readonly NONE: number;
979 static readonly CAPTURING_PHASE: number;
980 static readonly AT_TARGET: number;
981 static readonly BUBBLING_PHASE: number;
982}
983export interface EventInit {
984 bubbles?: boolean;
985 cancelable?: boolean;
986 composed?: boolean;
987}
988export type EventListener<EventType extends Event = Event> = (
989 event: EventType,
990) => void;
991export interface EventListenerObject<EventType extends Event = Event> {
992 handleEvent(event: EventType): void;
993}
994export type EventListenerOrEventListenerObject<
995 EventType extends Event = Event,
996> = EventListener<EventType> | EventListenerObject<EventType>;
997/**
998 * The **`EventTarget`** interface is implemented by objects that can receive events and may have listeners for them.
999 *
1000 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget)
1001 */
1002export declare class EventTarget<
1003 EventMap extends Record<string, Event> = Record<string, Event>,
1004> {
1005 constructor();
1006 /**
1007 * The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
1008 *
1009 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
1010 */
1011 addEventListener<Type extends keyof EventMap>(
1012 type: Type,
1013 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
1014 options?: EventTargetAddEventListenerOptions | boolean,
1015 ): void;
1016 /**
1017 * The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.
1018 *
1019 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
1020 */
1021 removeEventListener<Type extends keyof EventMap>(
1022 type: Type,
1023 handler: EventListenerOrEventListenerObject<EventMap[Type]>,
1024 options?: EventTargetEventListenerOptions | boolean,
1025 ): void;
1026 /**
1027 * The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.
1028 *
1029 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
1030 */
1031 dispatchEvent(event: EventMap[keyof EventMap]): boolean;
1032}
1033export interface EventTargetEventListenerOptions {
1034 capture?: boolean;
1035}
1036export interface EventTargetAddEventListenerOptions {
1037 capture?: boolean;
1038 passive?: boolean;
1039 once?: boolean;
1040 signal?: AbortSignal;
1041}
1042export interface EventTargetHandlerObject {
1043 handleEvent: (event: Event) => any | undefined;
1044}
1045/**
1046 * The **`AbortController`** interface represents a controller object that allows you to abort one or more Web requests as and when desired.
1047 *
1048 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController)
1049 */
1050export declare class AbortController {
1051 constructor();
1052 /**
1053 * 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.
1054 *
1055 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/signal)
1056 */
1057 get signal(): AbortSignal;
1058 /**
1059 * The **`abort()`** method of the AbortController interface aborts an asynchronous operation before it has completed.
1060 *
1061 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortController/abort)
1062 */
1063 abort(reason?: any): void;
1064}
1065/**
1066 * 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.
1067 *
1068 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal)
1069 */
1070export declare abstract class AbortSignal extends EventTarget {
1071 /**
1072 * The **`AbortSignal.abort()`** static method returns an AbortSignal that is already set as aborted (and which does not trigger an AbortSignal/abort_event event).
1073 *
1074 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_static)
1075 */
1076 static abort(reason?: any): AbortSignal;
1077 /**
1078 * The **`AbortSignal.timeout()`** static method returns an AbortSignal that will automatically abort after a specified time.
1079 *
1080 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/timeout_static)
1081 */
1082 static timeout(delay: number): AbortSignal;
1083 /**
1084 * The **`AbortSignal.any()`** static method takes an iterable of abort signals and returns an AbortSignal.
1085 *
1086 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/any_static)
1087 */
1088 static any(signals: AbortSignal[]): AbortSignal;
1089 /**
1090 * 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`).
1091 *
1092 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted)
1093 */
1094 get aborted(): boolean;
1095 /**
1096 * The **`reason`** read-only property returns a JavaScript value that indicates the abort reason.
1097 *
1098 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/reason)
1099 */
1100 get reason(): any;
1101 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1102 get onabort(): any | null;
1103 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event) */
1104 set onabort(value: any | null);
1105 /**
1106 * The **`throwIfAborted()`** method throws the signal's abort AbortSignal.reason if the signal has been aborted; otherwise it does nothing.
1107 *
1108 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AbortSignal/throwIfAborted)
1109 */
1110 throwIfAborted(): void;
1111}
1112export interface Scheduler {
1113 wait(delay: number, maybeOptions?: SchedulerWaitOptions): Promise<void>;
1114}
1115export interface SchedulerWaitOptions {
1116 signal?: AbortSignal;
1117}
1118/**
1119 * The **`ExtendableEvent`** interface extends the lifetime of the `install` and `activate` events dispatched on the global scope as part of the service worker lifecycle.
1120 *
1121 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent)
1122 */
1123export declare abstract class ExtendableEvent extends Event {
1124 /**
1125 * The **`ExtendableEvent.waitUntil()`** method tells the event dispatcher that work is ongoing.
1126 *
1127 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ExtendableEvent/waitUntil)
1128 */
1129 waitUntil(promise: Promise<any>): void;
1130}
1131/**
1132 * The **`CustomEvent`** interface represents events initialized by an application for any purpose.
1133 *
1134 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent)
1135 */
1136export declare class CustomEvent<T = any> extends Event {
1137 constructor(type: string, init?: CustomEventCustomEventInit);
1138 /**
1139 * The read-only **`detail`** property of the CustomEvent interface returns any data passed when initializing the event.
1140 *
1141 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CustomEvent/detail)
1142 */
1143 get detail(): T;
1144}
1145export interface CustomEventCustomEventInit {
1146 bubbles?: boolean;
1147 cancelable?: boolean;
1148 composed?: boolean;
1149 detail?: any;
1150}
1151/**
1152 * 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.
1153 *
1154 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob)
1155 */
1156export declare class Blob {
1157 constructor(
1158 bits?: ((ArrayBuffer | ArrayBufferView) | string | Blob)[],
1159 options?: BlobOptions,
1160 );
1161 /**
1162 * The **`size`** read-only property of the Blob interface returns the size of the Blob or File in bytes.
1163 *
1164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/size)
1165 */
1166 get size(): number;
1167 /**
1168 * The **`type`** read-only property of the Blob interface returns the MIME type of the file.
1169 *
1170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/type)
1171 */
1172 get type(): string;
1173 /**
1174 * 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.
1175 *
1176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/slice)
1177 */
1178 slice(start?: number, end?: number, type?: string): Blob;
1179 /**
1180 * 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.
1181 *
1182 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/arrayBuffer)
1183 */
1184 arrayBuffer(): Promise<ArrayBuffer>;
1185 /**
1186 * 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.
1187 *
1188 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/bytes)
1189 */
1190 bytes(): Promise<Uint8Array>;
1191 /**
1192 * The **`text()`** method of the string containing the contents of the blob, interpreted as UTF-8.
1193 *
1194 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/text)
1195 */
1196 text(): Promise<string>;
1197 /**
1198 * The **`stream()`** method of the Blob interface returns a ReadableStream which upon reading returns the data contained within the `Blob`.
1199 *
1200 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Blob/stream)
1201 */
1202 stream(): ReadableStream;
1203}
1204export interface BlobOptions {
1205 type?: string;
1206}
1207/**
1208 * The **`File`** interface provides information about files and allows JavaScript in a web page to access their content.
1209 *
1210 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File)
1211 */
1212export declare class File extends Blob {
1213 constructor(
1214 bits: ((ArrayBuffer | ArrayBufferView) | string | Blob)[] | undefined,
1215 name: string,
1216 options?: FileOptions,
1217 );
1218 /**
1219 * The **`name`** read-only property of the File interface returns the name of the file represented by a File object.
1220 *
1221 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/name)
1222 */
1223 get name(): string;
1224 /**
1225 * 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).
1226 *
1227 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/File/lastModified)
1228 */
1229 get lastModified(): number;
1230}
1231export interface FileOptions {
1232 type?: string;
1233 lastModified?: number;
1234}
1235/**
1236 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1237 *
1238 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1239 */
1240export declare abstract class CacheStorage {
1241 /**
1242 * The **`open()`** method of the the Cache object matching the `cacheName`.
1243 *
1244 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CacheStorage/open)
1245 */
1246 open(cacheName: string): Promise<Cache>;
1247 readonly default: Cache;
1248}
1249/**
1250 * The Cache API allows fine grained control of reading and writing from the Cloudflare global network cache.
1251 *
1252 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/)
1253 */
1254export declare abstract class Cache {
1255 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1256 delete(
1257 request: RequestInfo | URL,
1258 options?: CacheQueryOptions,
1259 ): Promise<boolean>;
1260 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1261 match(
1262 request: RequestInfo | URL,
1263 options?: CacheQueryOptions,
1264 ): Promise<Response | undefined>;
1265 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1266 put(request: RequestInfo | URL, response: Response): Promise<void>;
1267}
1268export interface CacheQueryOptions {
1269 ignoreMethod?: boolean;
1270}
1271/**
1272 * The Web Crypto API provides a set of low-level functions for common cryptographic tasks.
1273 * The Workers runtime implements the full surface of this API, but with some differences in
1274 * the [supported algorithms](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/#supported-algorithms)
1275 * compared to those implemented in most browsers.
1276 *
1277 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/web-crypto/)
1278 */
1279export declare abstract class Crypto {
1280 /**
1281 * The **`Crypto.subtle`** read-only property returns a cryptographic operations.
1282 * Available only in secure contexts.
1283 *
1284 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle)
1285 */
1286 get subtle(): SubtleCrypto;
1287 /**
1288 * The **`Crypto.getRandomValues()`** method lets you get cryptographically strong random values.
1289 *
1290 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues)
1291 */
1292 getRandomValues<
1293 T extends
1294 | Int8Array
1295 | Uint8Array
1296 | Int16Array
1297 | Uint16Array
1298 | Int32Array
1299 | Uint32Array
1300 | BigInt64Array
1301 | BigUint64Array,
1302 >(buffer: T): T;
1303 /**
1304 * The **`randomUUID()`** method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator.
1305 * Available only in secure contexts.
1306 *
1307 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID)
1308 */
1309 randomUUID(): string;
1310 DigestStream: typeof DigestStream;
1311}
1312/**
1313 * The **`SubtleCrypto`** interface of the Web Crypto API provides a number of low-level cryptographic functions.
1314 * Available only in secure contexts.
1315 *
1316 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto)
1317 */
1318export declare abstract class SubtleCrypto {
1319 /**
1320 * The **`encrypt()`** method of the SubtleCrypto interface encrypts data.
1321 *
1322 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt)
1323 */
1324 encrypt(
1325 algorithm: string | SubtleCryptoEncryptAlgorithm,
1326 key: CryptoKey,
1327 plainText: ArrayBuffer | ArrayBufferView,
1328 ): Promise<ArrayBuffer>;
1329 /**
1330 * The **`decrypt()`** method of the SubtleCrypto interface decrypts some encrypted data.
1331 *
1332 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt)
1333 */
1334 decrypt(
1335 algorithm: string | SubtleCryptoEncryptAlgorithm,
1336 key: CryptoKey,
1337 cipherText: ArrayBuffer | ArrayBufferView,
1338 ): Promise<ArrayBuffer>;
1339 /**
1340 * The **`sign()`** method of the SubtleCrypto interface generates a digital signature.
1341 *
1342 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign)
1343 */
1344 sign(
1345 algorithm: string | SubtleCryptoSignAlgorithm,
1346 key: CryptoKey,
1347 data: ArrayBuffer | ArrayBufferView,
1348 ): Promise<ArrayBuffer>;
1349 /**
1350 * The **`verify()`** method of the SubtleCrypto interface verifies a digital signature.
1351 *
1352 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify)
1353 */
1354 verify(
1355 algorithm: string | SubtleCryptoSignAlgorithm,
1356 key: CryptoKey,
1357 signature: ArrayBuffer | ArrayBufferView,
1358 data: ArrayBuffer | ArrayBufferView,
1359 ): Promise<boolean>;
1360 /**
1361 * The **`digest()`** method of the SubtleCrypto interface generates a _digest_ of the given data, using the specified hash function.
1362 *
1363 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest)
1364 */
1365 digest(
1366 algorithm: string | SubtleCryptoHashAlgorithm,
1367 data: ArrayBuffer | ArrayBufferView,
1368 ): Promise<ArrayBuffer>;
1369 /**
1370 * The **`generateKey()`** method of the SubtleCrypto interface is used to generate a new key (for symmetric algorithms) or key pair (for public-key algorithms).
1371 *
1372 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey)
1373 */
1374 generateKey(
1375 algorithm: string | SubtleCryptoGenerateKeyAlgorithm,
1376 extractable: boolean,
1377 keyUsages: string[],
1378 ): Promise<CryptoKey | CryptoKeyPair>;
1379 /**
1380 * The **`deriveKey()`** method of the SubtleCrypto interface can be used to derive a secret key from a master key.
1381 *
1382 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey)
1383 */
1384 deriveKey(
1385 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1386 baseKey: CryptoKey,
1387 derivedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1388 extractable: boolean,
1389 keyUsages: string[],
1390 ): Promise<CryptoKey>;
1391 /**
1392 * The **`deriveBits()`** method of the key.
1393 *
1394 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits)
1395 */
1396 deriveBits(
1397 algorithm: string | SubtleCryptoDeriveKeyAlgorithm,
1398 baseKey: CryptoKey,
1399 length?: number | null,
1400 ): Promise<ArrayBuffer>;
1401 /**
1402 * 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.
1403 *
1404 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey)
1405 */
1406 importKey(
1407 format: string,
1408 keyData: (ArrayBuffer | ArrayBufferView) | JsonWebKey,
1409 algorithm: string | SubtleCryptoImportKeyAlgorithm,
1410 extractable: boolean,
1411 keyUsages: string[],
1412 ): Promise<CryptoKey>;
1413 /**
1414 * 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.
1415 *
1416 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey)
1417 */
1418 exportKey(format: string, key: CryptoKey): Promise<ArrayBuffer | JsonWebKey>;
1419 /**
1420 * The **`wrapKey()`** method of the SubtleCrypto interface 'wraps' a key.
1421 *
1422 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey)
1423 */
1424 wrapKey(
1425 format: string,
1426 key: CryptoKey,
1427 wrappingKey: CryptoKey,
1428 wrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1429 ): Promise<ArrayBuffer>;
1430 /**
1431 * The **`unwrapKey()`** method of the SubtleCrypto interface 'unwraps' a key.
1432 *
1433 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey)
1434 */
1435 unwrapKey(
1436 format: string,
1437 wrappedKey: ArrayBuffer | ArrayBufferView,
1438 unwrappingKey: CryptoKey,
1439 unwrapAlgorithm: string | SubtleCryptoEncryptAlgorithm,
1440 unwrappedKeyAlgorithm: string | SubtleCryptoImportKeyAlgorithm,
1441 extractable: boolean,
1442 keyUsages: string[],
1443 ): Promise<CryptoKey>;
1444 timingSafeEqual(
1445 a: ArrayBuffer | ArrayBufferView,
1446 b: ArrayBuffer | ArrayBufferView,
1447 ): boolean;
1448}
1449/**
1450 * 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.
1451 * Available only in secure contexts.
1452 *
1453 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey)
1454 */
1455export declare abstract class CryptoKey {
1456 /**
1457 * The read-only **`type`** property of the CryptoKey interface indicates which kind of key is represented by the object.
1458 *
1459 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type)
1460 */
1461 readonly type: string;
1462 /**
1463 * The read-only **`extractable`** property of the CryptoKey interface indicates whether or not the key may be extracted using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey()`.
1464 *
1465 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable)
1466 */
1467 readonly extractable: boolean;
1468 /**
1469 * 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.
1470 *
1471 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm)
1472 */
1473 readonly algorithm:
1474 | CryptoKeyKeyAlgorithm
1475 | CryptoKeyAesKeyAlgorithm
1476 | CryptoKeyHmacKeyAlgorithm
1477 | CryptoKeyRsaKeyAlgorithm
1478 | CryptoKeyEllipticKeyAlgorithm
1479 | CryptoKeyArbitraryKeyAlgorithm;
1480 /**
1481 * The read-only **`usages`** property of the CryptoKey interface indicates what can be done with the key.
1482 *
1483 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages)
1484 */
1485 readonly usages: string[];
1486}
1487export interface CryptoKeyPair {
1488 publicKey: CryptoKey;
1489 privateKey: CryptoKey;
1490}
1491export interface JsonWebKey {
1492 kty: string;
1493 use?: string;
1494 key_ops?: string[];
1495 alg?: string;
1496 ext?: boolean;
1497 crv?: string;
1498 x?: string;
1499 y?: string;
1500 d?: string;
1501 n?: string;
1502 e?: string;
1503 p?: string;
1504 q?: string;
1505 dp?: string;
1506 dq?: string;
1507 qi?: string;
1508 oth?: RsaOtherPrimesInfo[];
1509 k?: string;
1510}
1511export interface RsaOtherPrimesInfo {
1512 r?: string;
1513 d?: string;
1514 t?: string;
1515}
1516export interface SubtleCryptoDeriveKeyAlgorithm {
1517 name: string;
1518 salt?: ArrayBuffer | ArrayBufferView;
1519 iterations?: number;
1520 hash?: string | SubtleCryptoHashAlgorithm;
1521 $public?: CryptoKey;
1522 info?: ArrayBuffer | ArrayBufferView;
1523}
1524export interface SubtleCryptoEncryptAlgorithm {
1525 name: string;
1526 iv?: ArrayBuffer | ArrayBufferView;
1527 additionalData?: ArrayBuffer | ArrayBufferView;
1528 tagLength?: number;
1529 counter?: ArrayBuffer | ArrayBufferView;
1530 length?: number;
1531 label?: ArrayBuffer | ArrayBufferView;
1532}
1533export interface SubtleCryptoGenerateKeyAlgorithm {
1534 name: string;
1535 hash?: string | SubtleCryptoHashAlgorithm;
1536 modulusLength?: number;
1537 publicExponent?: ArrayBuffer | ArrayBufferView;
1538 length?: number;
1539 namedCurve?: string;
1540}
1541export interface SubtleCryptoHashAlgorithm {
1542 name: string;
1543}
1544export interface SubtleCryptoImportKeyAlgorithm {
1545 name: string;
1546 hash?: string | SubtleCryptoHashAlgorithm;
1547 length?: number;
1548 namedCurve?: string;
1549 compressed?: boolean;
1550}
1551export interface SubtleCryptoSignAlgorithm {
1552 name: string;
1553 hash?: string | SubtleCryptoHashAlgorithm;
1554 dataLength?: number;
1555 saltLength?: number;
1556}
1557export interface CryptoKeyKeyAlgorithm {
1558 name: string;
1559}
1560export interface CryptoKeyAesKeyAlgorithm {
1561 name: string;
1562 length: number;
1563}
1564export interface CryptoKeyHmacKeyAlgorithm {
1565 name: string;
1566 hash: CryptoKeyKeyAlgorithm;
1567 length: number;
1568}
1569export interface CryptoKeyRsaKeyAlgorithm {
1570 name: string;
1571 modulusLength: number;
1572 publicExponent: ArrayBuffer | ArrayBufferView;
1573 hash?: CryptoKeyKeyAlgorithm;
1574}
1575export interface CryptoKeyEllipticKeyAlgorithm {
1576 name: string;
1577 namedCurve: string;
1578}
1579export interface CryptoKeyArbitraryKeyAlgorithm {
1580 name: string;
1581 hash?: CryptoKeyKeyAlgorithm;
1582 namedCurve?: string;
1583 length?: number;
1584}
1585export declare class DigestStream extends WritableStream<
1586 ArrayBuffer | ArrayBufferView
1587> {
1588 constructor(algorithm: string | SubtleCryptoHashAlgorithm);
1589 readonly digest: Promise<ArrayBuffer>;
1590 get bytesWritten(): number | bigint;
1591}
1592/**
1593 * The **`TextDecoder`** interface represents a decoder for a specific text encoding, such as `UTF-8`, `ISO-8859-2`, `KOI8-R`, `GBK`, etc.
1594 *
1595 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder)
1596 */
1597export declare class TextDecoder {
1598 constructor(label?: string, options?: TextDecoderConstructorOptions);
1599 /**
1600 * The **`TextDecoder.decode()`** method returns a string containing text decoded from the buffer passed as a parameter.
1601 *
1602 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoder/decode)
1603 */
1604 decode(
1605 input?: ArrayBuffer | ArrayBufferView,
1606 options?: TextDecoderDecodeOptions,
1607 ): string;
1608 get encoding(): string;
1609 get fatal(): boolean;
1610 get ignoreBOM(): boolean;
1611}
1612/**
1613 * The **`TextEncoder`** interface takes a stream of code points as input and emits a stream of UTF-8 bytes.
1614 *
1615 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder)
1616 */
1617export declare class TextEncoder {
1618 constructor();
1619 /**
1620 * 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.
1621 *
1622 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encode)
1623 */
1624 encode(input?: string): Uint8Array;
1625 /**
1626 * 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.
1627 *
1628 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoder/encodeInto)
1629 */
1630 encodeInto(input: string, buffer: Uint8Array): TextEncoderEncodeIntoResult;
1631 get encoding(): string;
1632}
1633export interface TextDecoderConstructorOptions {
1634 fatal: boolean;
1635 ignoreBOM: boolean;
1636}
1637export interface TextDecoderDecodeOptions {
1638 stream: boolean;
1639}
1640export interface TextEncoderEncodeIntoResult {
1641 read: number;
1642 written: number;
1643}
1644/**
1645 * The **`ErrorEvent`** interface represents events providing information related to errors in scripts or in files.
1646 *
1647 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent)
1648 */
1649export declare class ErrorEvent extends Event {
1650 constructor(type: string, init?: ErrorEventErrorEventInit);
1651 /**
1652 * The **`filename`** read-only property of the ErrorEvent interface returns a string containing the name of the script file in which the error occurred.
1653 *
1654 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/filename)
1655 */
1656 get filename(): string;
1657 /**
1658 * The **`message`** read-only property of the ErrorEvent interface returns a string containing a human-readable error message describing the problem.
1659 *
1660 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/message)
1661 */
1662 get message(): string;
1663 /**
1664 * 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.
1665 *
1666 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/lineno)
1667 */
1668 get lineno(): number;
1669 /**
1670 * 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.
1671 *
1672 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/colno)
1673 */
1674 get colno(): number;
1675 /**
1676 * 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.
1677 *
1678 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ErrorEvent/error)
1679 */
1680 get error(): any;
1681}
1682export interface ErrorEventErrorEventInit {
1683 message?: string;
1684 filename?: string;
1685 lineno?: number;
1686 colno?: number;
1687 error?: any;
1688}
1689/**
1690 * The **`MessageEvent`** interface represents a message received by a target object.
1691 *
1692 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent)
1693 */
1694export declare class MessageEvent extends Event {
1695 constructor(type: string, initializer: MessageEventInit);
1696 /**
1697 * 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.
1698 *
1699 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/data)
1700 */
1701 readonly data: any;
1702 /**
1703 * The **`origin`** read-only property of the origin of the message emitter.
1704 *
1705 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/origin)
1706 */
1707 readonly origin: string | null;
1708 /**
1709 * The **`lastEventId`** read-only property of the unique ID for the event.
1710 *
1711 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/lastEventId)
1712 */
1713 readonly lastEventId: string;
1714 /**
1715 * The **`source`** read-only property of the a WindowProxy, MessagePort, or a `MessageEventSource` (which can be a WindowProxy, message emitter.
1716 *
1717 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/source)
1718 */
1719 readonly source: MessagePort | null;
1720 /**
1721 * The **`ports`** read-only property of the containing all MessagePort objects sent with the message, in order.
1722 *
1723 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageEvent/ports)
1724 */
1725 readonly ports: MessagePort[];
1726}
1727export interface MessageEventInit {
1728 data: ArrayBuffer | string;
1729}
1730/**
1731 * The **`PromiseRejectionEvent`** interface represents events which are sent to the global script context when JavaScript Promises are rejected.
1732 *
1733 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent)
1734 */
1735export declare abstract class PromiseRejectionEvent extends Event {
1736 /**
1737 * The PromiseRejectionEvent interface's **`promise`** read-only property indicates the JavaScript rejected.
1738 *
1739 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/promise)
1740 */
1741 readonly promise: Promise<any>;
1742 /**
1743 * The PromiseRejectionEvent **`reason`** read-only property is any JavaScript value or Object which provides the reason passed into Promise.reject().
1744 *
1745 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PromiseRejectionEvent/reason)
1746 */
1747 readonly reason: any;
1748}
1749/**
1750 * 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.
1751 *
1752 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData)
1753 */
1754export declare class FormData {
1755 constructor();
1756 /**
1757 * 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.
1758 *
1759 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1760 */
1761 append(name: string, value: string | Blob): void;
1762 /**
1763 * 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.
1764 *
1765 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1766 */
1767 append(name: string, value: string): void;
1768 /**
1769 * 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.
1770 *
1771 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/append)
1772 */
1773 append(name: string, value: Blob, filename?: string): void;
1774 /**
1775 * The **`delete()`** method of the FormData interface deletes a key and its value(s) from a `FormData` object.
1776 *
1777 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/delete)
1778 */
1779 delete(name: string): void;
1780 /**
1781 * The **`get()`** method of the FormData interface returns the first value associated with a given key from within a `FormData` object.
1782 *
1783 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/get)
1784 */
1785 get(name: string): (File | string) | null;
1786 /**
1787 * The **`getAll()`** method of the FormData interface returns all the values associated with a given key from within a `FormData` object.
1788 *
1789 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/getAll)
1790 */
1791 getAll(name: string): (File | string)[];
1792 /**
1793 * The **`has()`** method of the FormData interface returns whether a `FormData` object contains a certain key.
1794 *
1795 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/has)
1796 */
1797 has(name: string): boolean;
1798 /**
1799 * 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.
1800 *
1801 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1802 */
1803 set(name: string, value: string | Blob): void;
1804 /**
1805 * 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.
1806 *
1807 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1808 */
1809 set(name: string, value: string): void;
1810 /**
1811 * 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.
1812 *
1813 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FormData/set)
1814 */
1815 set(name: string, value: Blob, filename?: string): void;
1816 /* Returns an array of key, value pairs for every entry in the list. */
1817 entries(): IterableIterator<[key: string, value: File | string]>;
1818 /* Returns a list of keys in the list. */
1819 keys(): IterableIterator<string>;
1820 /* Returns a list of values in the list. */
1821 values(): IterableIterator<File | string>;
1822 forEach<This = unknown>(
1823 callback: (
1824 this: This,
1825 value: File | string,
1826 key: string,
1827 parent: FormData,
1828 ) => void,
1829 thisArg?: This,
1830 ): void;
1831 [Symbol.iterator](): IterableIterator<[key: string, value: File | string]>;
1832}
1833export interface ContentOptions {
1834 html?: boolean;
1835}
1836export declare class HTMLRewriter {
1837 constructor();
1838 on(
1839 selector: string,
1840 handlers: HTMLRewriterElementContentHandlers,
1841 ): HTMLRewriter;
1842 onDocument(handlers: HTMLRewriterDocumentContentHandlers): HTMLRewriter;
1843 transform(response: Response): Response;
1844}
1845export interface HTMLRewriterElementContentHandlers {
1846 element?(element: Element): void | Promise<void>;
1847 comments?(comment: Comment): void | Promise<void>;
1848 text?(element: Text): void | Promise<void>;
1849}
1850export interface HTMLRewriterDocumentContentHandlers {
1851 doctype?(doctype: Doctype): void | Promise<void>;
1852 comments?(comment: Comment): void | Promise<void>;
1853 text?(text: Text): void | Promise<void>;
1854 end?(end: DocumentEnd): void | Promise<void>;
1855}
1856export interface Doctype {
1857 readonly name: string | null;
1858 readonly publicId: string | null;
1859 readonly systemId: string | null;
1860}
1861export interface Element {
1862 tagName: string;
1863 readonly attributes: IterableIterator<string[]>;
1864 readonly removed: boolean;
1865 readonly namespaceURI: string;
1866 getAttribute(name: string): string | null;
1867 hasAttribute(name: string): boolean;
1868 setAttribute(name: string, value: string): Element;
1869 removeAttribute(name: string): Element;
1870 before(
1871 content: string | ReadableStream | Response,
1872 options?: ContentOptions,
1873 ): Element;
1874 after(
1875 content: string | ReadableStream | Response,
1876 options?: ContentOptions,
1877 ): Element;
1878 prepend(
1879 content: string | ReadableStream | Response,
1880 options?: ContentOptions,
1881 ): Element;
1882 append(
1883 content: string | ReadableStream | Response,
1884 options?: ContentOptions,
1885 ): Element;
1886 replace(
1887 content: string | ReadableStream | Response,
1888 options?: ContentOptions,
1889 ): Element;
1890 remove(): Element;
1891 removeAndKeepContent(): Element;
1892 setInnerContent(
1893 content: string | ReadableStream | Response,
1894 options?: ContentOptions,
1895 ): Element;
1896 onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1897}
1898export interface EndTag {
1899 name: string;
1900 before(
1901 content: string | ReadableStream | Response,
1902 options?: ContentOptions,
1903 ): EndTag;
1904 after(
1905 content: string | ReadableStream | Response,
1906 options?: ContentOptions,
1907 ): EndTag;
1908 remove(): EndTag;
1909}
1910export interface Comment {
1911 text: string;
1912 readonly removed: boolean;
1913 before(content: string, options?: ContentOptions): Comment;
1914 after(content: string, options?: ContentOptions): Comment;
1915 replace(content: string, options?: ContentOptions): Comment;
1916 remove(): Comment;
1917}
1918export interface Text {
1919 readonly text: string;
1920 readonly lastInTextNode: boolean;
1921 readonly removed: boolean;
1922 before(
1923 content: string | ReadableStream | Response,
1924 options?: ContentOptions,
1925 ): Text;
1926 after(
1927 content: string | ReadableStream | Response,
1928 options?: ContentOptions,
1929 ): Text;
1930 replace(
1931 content: string | ReadableStream | Response,
1932 options?: ContentOptions,
1933 ): Text;
1934 remove(): Text;
1935}
1936export interface DocumentEnd {
1937 append(content: string, options?: ContentOptions): DocumentEnd;
1938}
1939/**
1940 * This is the event type for `fetch` events dispatched on the ServiceWorkerGlobalScope.
1941 *
1942 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent)
1943 */
1944export declare abstract class FetchEvent extends ExtendableEvent {
1945 /**
1946 * The **`request`** read-only property of the the event handler.
1947 *
1948 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/request)
1949 */
1950 readonly request: Request;
1951 /**
1952 * The **`respondWith()`** method of allows you to provide a promise for a Response yourself.
1953 *
1954 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FetchEvent/respondWith)
1955 */
1956 respondWith(promise: Response | Promise<Response>): void;
1957 passThroughOnException(): void;
1958}
1959export type HeadersInit =
1960 | Headers
1961 | Iterable<Iterable<string>>
1962 | Record<string, string>;
1963/**
1964 * The **`Headers`** interface of the Fetch API allows you to perform various actions on HTTP request and response headers.
1965 *
1966 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers)
1967 */
1968export declare class Headers {
1969 constructor(init?: HeadersInit);
1970 /**
1971 * 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.
1972 *
1973 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/get)
1974 */
1975 get(name: string): string | null;
1976 getAll(name: string): string[];
1977 /**
1978 * The **`getSetCookie()`** method of the Headers interface returns an array containing the values of all Set-Cookie headers associated with a response.
1979 *
1980 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/getSetCookie)
1981 */
1982 getSetCookie(): string[];
1983 /**
1984 * The **`has()`** method of the Headers interface returns a boolean stating whether a `Headers` object contains a certain header.
1985 *
1986 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/has)
1987 */
1988 has(name: string): boolean;
1989 /**
1990 * 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.
1991 *
1992 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/set)
1993 */
1994 set(name: string, value: string): void;
1995 /**
1996 * 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.
1997 *
1998 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/append)
1999 */
2000 append(name: string, value: string): void;
2001 /**
2002 * The **`delete()`** method of the Headers interface deletes a header from the current `Headers` object.
2003 *
2004 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Headers/delete)
2005 */
2006 delete(name: string): void;
2007 forEach<This = unknown>(
2008 callback: (this: This, value: string, key: string, parent: Headers) => void,
2009 thisArg?: This,
2010 ): void;
2011 /* Returns an iterator allowing to go through all key/value pairs contained in this object. */
2012 entries(): IterableIterator<[key: string, value: string]>;
2013 /* Returns an iterator allowing to go through all keys of the key/value pairs contained in this object. */
2014 keys(): IterableIterator<string>;
2015 /* Returns an iterator allowing to go through all values of the key/value pairs contained in this object. */
2016 values(): IterableIterator<string>;
2017 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
2018}
2019export type BodyInit =
2020 | ReadableStream<Uint8Array>
2021 | string
2022 | ArrayBuffer
2023 | ArrayBufferView
2024 | Blob
2025 | URLSearchParams
2026 | FormData
2027 | Iterable<ArrayBuffer | ArrayBufferView>
2028 | AsyncIterable<ArrayBuffer | ArrayBufferView>;
2029export declare abstract class Body {
2030 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) */
2031 get body(): ReadableStream | null;
2032 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
2033 get bodyUsed(): boolean;
2034 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
2035 arrayBuffer(): Promise<ArrayBuffer>;
2036 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) */
2037 bytes(): Promise<Uint8Array>;
2038 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) */
2039 text(): Promise<string>;
2040 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) */
2041 json<T>(): Promise<T>;
2042 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) */
2043 formData(): Promise<FormData>;
2044 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
2045 blob(): Promise<Blob>;
2046}
2047/**
2048 * The **`Response`** interface of the Fetch API represents the response to a request.
2049 *
2050 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2051 */
2052export declare var Response: {
2053 prototype: Response;
2054 new (body?: BodyInit | null, init?: ResponseInit): Response;
2055 error(): Response;
2056 redirect(url: string, status?: number): Response;
2057 json(any: any, maybeInit?: ResponseInit | Response): Response;
2058};
2059/**
2060 * The **`Response`** interface of the Fetch API represents the response to a request.
2061 *
2062 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
2063 */
2064export interface Response extends Body {
2065 /**
2066 * The **`clone()`** method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable.
2067 *
2068 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone)
2069 */
2070 clone(): Response;
2071 /**
2072 * The **`status`** read-only property of the Response interface contains the HTTP status codes of the response.
2073 *
2074 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)
2075 */
2076 status: number;
2077 /**
2078 * The **`statusText`** read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status.
2079 *
2080 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)
2081 */
2082 statusText: string;
2083 /**
2084 * The **`headers`** read-only property of the with the response.
2085 *
2086 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers)
2087 */
2088 headers: Headers;
2089 /**
2090 * 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.
2091 *
2092 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok)
2093 */
2094 ok: boolean;
2095 /**
2096 * 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.
2097 *
2098 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected)
2099 */
2100 redirected: boolean;
2101 /**
2102 * The **`url`** read-only property of the Response interface contains the URL of the response.
2103 *
2104 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url)
2105 */
2106 url: string;
2107 webSocket: WebSocket | null;
2108 cf: any | undefined;
2109 /**
2110 * The **`type`** read-only property of the Response interface contains the type of the response.
2111 *
2112 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/type)
2113 */
2114 type: "default" | "error";
2115}
2116export interface ResponseInit {
2117 status?: number;
2118 statusText?: string;
2119 headers?: HeadersInit;
2120 cf?: any;
2121 webSocket?: WebSocket | null;
2122 encodeBody?: "automatic" | "manual";
2123}
2124export type RequestInfo<
2125 CfHostMetadata = unknown,
2126 Cf = CfProperties<CfHostMetadata>,
2127> = Request<CfHostMetadata, Cf> | string;
2128/**
2129 * The **`Request`** interface of the Fetch API represents a resource request.
2130 *
2131 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2132 */
2133export declare var Request: {
2134 prototype: Request;
2135 new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
2136 input: RequestInfo<CfProperties> | URL,
2137 init?: RequestInit<Cf>,
2138 ): Request<CfHostMetadata, Cf>;
2139};
2140/**
2141 * The **`Request`** interface of the Fetch API represents a resource request.
2142 *
2143 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
2144 */
2145export interface Request<
2146 CfHostMetadata = unknown,
2147 Cf = CfProperties<CfHostMetadata>,
2148> extends Body {
2149 /**
2150 * The **`clone()`** method of the Request interface creates a copy of the current `Request` object.
2151 *
2152 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone)
2153 */
2154 clone(): Request<CfHostMetadata, Cf>;
2155 /**
2156 * The **`method`** read-only property of the `POST`, etc.) A String indicating the method of the request.
2157 *
2158 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
2159 */
2160 method: string;
2161 /**
2162 * The **`url`** read-only property of the Request interface contains the URL of the request.
2163 *
2164 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
2165 */
2166 url: string;
2167 /**
2168 * The **`headers`** read-only property of the with the request.
2169 *
2170 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
2171 */
2172 headers: Headers;
2173 /**
2174 * The **`redirect`** read-only property of the Request interface contains the mode for how redirects are handled.
2175 *
2176 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
2177 */
2178 redirect: string;
2179 fetcher: Fetcher | null;
2180 /**
2181 * The read-only **`signal`** property of the Request interface returns the AbortSignal associated with the request.
2182 *
2183 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
2184 */
2185 signal: AbortSignal;
2186 cf?: Cf;
2187 /**
2188 * The **`integrity`** read-only property of the Request interface contains the subresource integrity value of the request.
2189 *
2190 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
2191 */
2192 integrity: string;
2193 /**
2194 * 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.
2195 *
2196 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
2197 */
2198 keepalive: boolean;
2199 /**
2200 * The **`cache`** read-only property of the Request interface contains the cache mode of the request.
2201 *
2202 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
2203 */
2204 cache?: "no-store" | "no-cache" | "reload";
2205}
2206export interface RequestInit<Cf = CfProperties> {
2207 /* A string to set request's method. */
2208 method?: string;
2209 /* A Headers object, an object literal, or an array of two-item arrays to set request's headers. */
2210 headers?: HeadersInit;
2211 /* A BodyInit object or null to set request's body. */
2212 body?: BodyInit | null;
2213 /* 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. */
2214 redirect?: string;
2215 fetcher?: Fetcher | null;
2216 cf?: Cf;
2217 /* A string indicating how the request will interact with the browser's cache to set request's cache. */
2218 cache?: "no-store" | "no-cache" | "reload";
2219 /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
2220 integrity?: string;
2221 /* An AbortSignal to set request's signal. */
2222 signal?: AbortSignal | null;
2223 encodeResponseBody?: "automatic" | "manual";
2224}
2225export type Service<
2226 T extends
2227 | (new (...args: any[]) => Rpc.WorkerEntrypointBranded)
2228 | Rpc.WorkerEntrypointBranded
2229 | ExportedHandler<any, any, any>
2230 | undefined = undefined,
2231> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
2232 ? Fetcher<InstanceType<T>>
2233 : T extends Rpc.WorkerEntrypointBranded
2234 ? Fetcher<T>
2235 : T extends Exclude<Rpc.EntrypointBranded, Rpc.WorkerEntrypointBranded>
2236 ? never
2237 : Fetcher<undefined>;
2238export type Fetcher<
2239 T extends Rpc.EntrypointBranded | undefined = undefined,
2240 Reserved extends string = never,
2241> = (T extends Rpc.EntrypointBranded
2242 ? Rpc.Provider<T, Reserved | "fetch" | "connect" | "queue" | "scheduled">
2243 : unknown) & {
2244 fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
2245 connect(address: SocketAddress | string, options?: SocketOptions): Socket;
2246 queue(
2247 queueName: string,
2248 messages: ServiceBindingQueueMessage[],
2249 metadata?: MessageBatchMetadata,
2250 ): Promise<FetcherQueueResult>;
2251 scheduled(options?: FetcherScheduledOptions): Promise<FetcherScheduledResult>;
2252};
2253export interface FetcherScheduledOptions {
2254 scheduledTime?: Date;
2255 cron?: string;
2256}
2257export interface FetcherScheduledResult {
2258 outcome: string;
2259 noRetry: boolean;
2260}
2261export interface FetcherQueueResult {
2262 outcome: string;
2263 ackAll: boolean;
2264 retryBatch: QueueRetryBatch;
2265 explicitAcks: string[];
2266 retryMessages: QueueRetryMessage[];
2267}
2268export type ServiceBindingQueueMessage<Body = unknown> = {
2269 id: string;
2270 timestamp: Date;
2271 attempts: number;
2272} & (
2273 | {
2274 body: Body;
2275 }
2276 | {
2277 serializedBody: ArrayBuffer | ArrayBufferView;
2278 }
2279);
2280export interface KVNamespaceListKey<Metadata, Key extends string = string> {
2281 name: Key;
2282 expiration?: number;
2283 metadata?: Metadata;
2284}
2285export type KVNamespaceListResult<Metadata, Key extends string = string> =
2286 | {
2287 list_complete: false;
2288 keys: KVNamespaceListKey<Metadata, Key>[];
2289 cursor: string;
2290 cacheStatus: string | null;
2291 }
2292 | {
2293 list_complete: true;
2294 keys: KVNamespaceListKey<Metadata, Key>[];
2295 cacheStatus: string | null;
2296 };
2297export interface KVNamespace<Key extends string = string> {
2298 get(
2299 key: Key,
2300 options?: Partial<KVNamespaceGetOptions<undefined>>,
2301 ): Promise<string | null>;
2302 get(key: Key, type: "text"): Promise<string | null>;
2303 get<ExpectedValue = unknown>(
2304 key: Key,
2305 type: "json",
2306 ): Promise<ExpectedValue | null>;
2307 get(key: Key, type: "arrayBuffer"): Promise<ArrayBuffer | null>;
2308 get(key: Key, type: "stream"): Promise<ReadableStream | null>;
2309 get(
2310 key: Key,
2311 options?: KVNamespaceGetOptions<"text">,
2312 ): Promise<string | null>;
2313 get<ExpectedValue = unknown>(
2314 key: Key,
2315 options?: KVNamespaceGetOptions<"json">,
2316 ): Promise<ExpectedValue | null>;
2317 get(
2318 key: Key,
2319 options?: KVNamespaceGetOptions<"arrayBuffer">,
2320 ): Promise<ArrayBuffer | null>;
2321 get(
2322 key: Key,
2323 options?: KVNamespaceGetOptions<"stream">,
2324 ): Promise<ReadableStream | null>;
2325 get(key: Array<Key>, type: "text"): Promise<Map<string, string | null>>;
2326 get<ExpectedValue = unknown>(
2327 key: Array<Key>,
2328 type: "json",
2329 ): Promise<Map<string, ExpectedValue | null>>;
2330 get(
2331 key: Array<Key>,
2332 options?: Partial<KVNamespaceGetOptions<undefined>>,
2333 ): Promise<Map<string, string | null>>;
2334 get(
2335 key: Array<Key>,
2336 options?: KVNamespaceGetOptions<"text">,
2337 ): Promise<Map<string, string | null>>;
2338 get<ExpectedValue = unknown>(
2339 key: Array<Key>,
2340 options?: KVNamespaceGetOptions<"json">,
2341 ): Promise<Map<string, ExpectedValue | null>>;
2342 list<Metadata = unknown>(
2343 options?: KVNamespaceListOptions,
2344 ): Promise<KVNamespaceListResult<Metadata, Key>>;
2345 put(
2346 key: Key,
2347 value: string | ArrayBuffer | ArrayBufferView | ReadableStream,
2348 options?: KVNamespacePutOptions,
2349 ): Promise<void>;
2350 getWithMetadata<Metadata = unknown>(
2351 key: Key,
2352 options?: Partial<KVNamespaceGetOptions<undefined>>,
2353 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2354 getWithMetadata<Metadata = unknown>(
2355 key: Key,
2356 type: "text",
2357 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2358 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2359 key: Key,
2360 type: "json",
2361 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2362 getWithMetadata<Metadata = unknown>(
2363 key: Key,
2364 type: "arrayBuffer",
2365 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2366 getWithMetadata<Metadata = unknown>(
2367 key: Key,
2368 type: "stream",
2369 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2370 getWithMetadata<Metadata = unknown>(
2371 key: Key,
2372 options: KVNamespaceGetOptions<"text">,
2373 ): Promise<KVNamespaceGetWithMetadataResult<string, Metadata>>;
2374 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2375 key: Key,
2376 options: KVNamespaceGetOptions<"json">,
2377 ): Promise<KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>;
2378 getWithMetadata<Metadata = unknown>(
2379 key: Key,
2380 options: KVNamespaceGetOptions<"arrayBuffer">,
2381 ): Promise<KVNamespaceGetWithMetadataResult<ArrayBuffer, Metadata>>;
2382 getWithMetadata<Metadata = unknown>(
2383 key: Key,
2384 options: KVNamespaceGetOptions<"stream">,
2385 ): Promise<KVNamespaceGetWithMetadataResult<ReadableStream, Metadata>>;
2386 getWithMetadata<Metadata = unknown>(
2387 key: Array<Key>,
2388 type: "text",
2389 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2390 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2391 key: Array<Key>,
2392 type: "json",
2393 ): Promise<
2394 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2395 >;
2396 getWithMetadata<Metadata = unknown>(
2397 key: Array<Key>,
2398 options?: Partial<KVNamespaceGetOptions<undefined>>,
2399 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2400 getWithMetadata<Metadata = unknown>(
2401 key: Array<Key>,
2402 options?: KVNamespaceGetOptions<"text">,
2403 ): Promise<Map<string, KVNamespaceGetWithMetadataResult<string, Metadata>>>;
2404 getWithMetadata<ExpectedValue = unknown, Metadata = unknown>(
2405 key: Array<Key>,
2406 options?: KVNamespaceGetOptions<"json">,
2407 ): Promise<
2408 Map<string, KVNamespaceGetWithMetadataResult<ExpectedValue, Metadata>>
2409 >;
2410 delete(key: Key): Promise<void>;
2411 deleteBulk(keys: Key | Key[]): Promise<void>;
2412}
2413export interface KVNamespaceListOptions {
2414 limit?: number;
2415 prefix?: string | null;
2416 cursor?: string | null;
2417}
2418export interface KVNamespaceGetOptions<Type> {
2419 type: Type;
2420 cacheTtl?: number;
2421}
2422export interface KVNamespacePutOptions {
2423 expiration?: number;
2424 expirationTtl?: number;
2425 metadata?: any | null;
2426}
2427export interface KVNamespaceGetWithMetadataResult<Value, Metadata> {
2428 value: Value | null;
2429 metadata: Metadata | null;
2430 cacheStatus: string | null;
2431}
2432export type QueueContentType = "text" | "bytes" | "json" | "v8";
2433export interface Queue<Body = unknown> {
2434 metrics(): Promise<QueueMetrics>;
2435 send(message: Body, options?: QueueSendOptions): Promise<QueueSendResponse>;
2436 sendBatch(
2437 messages: Iterable<MessageSendRequest<Body>>,
2438 options?: QueueSendBatchOptions,
2439 ): Promise<QueueSendBatchResponse>;
2440}
2441export interface QueueSendMetrics {
2442 backlogCount: number;
2443 backlogBytes: number;
2444 oldestMessageTimestamp?: Date;
2445}
2446export interface QueueSendMetadata {
2447 metrics: QueueSendMetrics;
2448}
2449export interface QueueSendResponse {
2450 metadata: QueueSendMetadata;
2451}
2452export interface QueueSendBatchMetrics {
2453 backlogCount: number;
2454 backlogBytes: number;
2455 oldestMessageTimestamp?: Date;
2456}
2457export interface QueueSendBatchMetadata {
2458 metrics: QueueSendBatchMetrics;
2459}
2460export interface QueueSendBatchResponse {
2461 metadata: QueueSendBatchMetadata;
2462}
2463export interface QueueSendOptions {
2464 contentType?: QueueContentType;
2465 delaySeconds?: number;
2466}
2467export interface QueueSendBatchOptions {
2468 delaySeconds?: number;
2469}
2470export interface MessageSendRequest<Body = unknown> {
2471 body: Body;
2472 contentType?: QueueContentType;
2473 delaySeconds?: number;
2474}
2475export interface QueueMetrics {
2476 backlogCount: number;
2477 backlogBytes: number;
2478 oldestMessageTimestamp?: Date;
2479}
2480export interface MessageBatchMetrics {
2481 backlogCount: number;
2482 backlogBytes: number;
2483 oldestMessageTimestamp?: Date;
2484}
2485export interface MessageBatchMetadata {
2486 metrics: MessageBatchMetrics;
2487}
2488export interface QueueRetryBatch {
2489 retry: boolean;
2490 delaySeconds?: number;
2491}
2492export interface QueueRetryMessage {
2493 msgId: string;
2494 delaySeconds?: number;
2495}
2496export interface QueueRetryOptions {
2497 delaySeconds?: number;
2498}
2499export interface Message<Body = unknown> {
2500 readonly id: string;
2501 readonly timestamp: Date;
2502 readonly body: Body;
2503 readonly attempts: number;
2504 retry(options?: QueueRetryOptions): void;
2505 ack(): void;
2506}
2507export interface QueueEvent<Body = unknown> extends ExtendableEvent {
2508 readonly messages: readonly Message<Body>[];
2509 readonly queue: string;
2510 readonly metadata: MessageBatchMetadata;
2511 retryAll(options?: QueueRetryOptions): void;
2512 ackAll(): void;
2513}
2514export interface MessageBatch<Body = unknown> {
2515 readonly messages: readonly Message<Body>[];
2516 readonly queue: string;
2517 readonly metadata: MessageBatchMetadata;
2518 retryAll(options?: QueueRetryOptions): void;
2519 ackAll(): void;
2520}
2521export interface R2Error extends Error {
2522 readonly name: string;
2523 readonly code: number;
2524 readonly message: string;
2525 readonly action: string;
2526 readonly stack: any;
2527}
2528export interface R2ListOptions {
2529 limit?: number;
2530 prefix?: string;
2531 cursor?: string;
2532 delimiter?: string;
2533 startAfter?: string;
2534 include?: ("httpMetadata" | "customMetadata")[];
2535}
2536export interface R2Bucket {
2537 head(key: string): Promise<R2Object | null>;
2538 get(
2539 key: string,
2540 options: R2GetOptions & {
2541 onlyIf: R2Conditional | Headers;
2542 },
2543 ): Promise<R2ObjectBody | R2Object | null>;
2544 get(key: string, options?: R2GetOptions): Promise<R2ObjectBody | null>;
2545 put(
2546 key: string,
2547 value:
2548 | ReadableStream
2549 | ArrayBuffer
2550 | ArrayBufferView
2551 | string
2552 | null
2553 | Blob,
2554 options?: R2PutOptions & {
2555 onlyIf: R2Conditional | Headers;
2556 },
2557 ): Promise<R2Object | null>;
2558 put(
2559 key: string,
2560 value:
2561 | ReadableStream
2562 | ArrayBuffer
2563 | ArrayBufferView
2564 | string
2565 | null
2566 | Blob,
2567 options?: R2PutOptions,
2568 ): Promise<R2Object>;
2569 createMultipartUpload(
2570 key: string,
2571 options?: R2MultipartOptions,
2572 ): Promise<R2MultipartUpload>;
2573 resumeMultipartUpload(key: string, uploadId: string): R2MultipartUpload;
2574 delete(keys: string | string[]): Promise<void>;
2575 list(options?: R2ListOptions): Promise<R2Objects>;
2576}
2577export interface R2MultipartUpload {
2578 readonly key: string;
2579 readonly uploadId: string;
2580 uploadPart(
2581 partNumber: number,
2582 value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
2583 options?: R2UploadPartOptions,
2584 ): Promise<R2UploadedPart>;
2585 abort(): Promise<void>;
2586 complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
2587}
2588export interface R2UploadedPart {
2589 partNumber: number;
2590 etag: string;
2591}
2592export declare abstract class R2Object {
2593 readonly key: string;
2594 readonly version: string;
2595 readonly size: number;
2596 readonly etag: string;
2597 readonly httpEtag: string;
2598 readonly checksums: R2Checksums;
2599 readonly uploaded: Date;
2600 readonly httpMetadata?: R2HTTPMetadata;
2601 readonly customMetadata?: Record<string, string>;
2602 readonly range?: R2Range;
2603 readonly storageClass: string;
2604 readonly ssecKeyMd5?: string;
2605 writeHttpMetadata(headers: Headers): void;
2606}
2607export interface R2ObjectBody extends R2Object {
2608 get body(): ReadableStream;
2609 get bodyUsed(): boolean;
2610 arrayBuffer(): Promise<ArrayBuffer>;
2611 bytes(): Promise<Uint8Array>;
2612 text(): Promise<string>;
2613 json<T>(): Promise<T>;
2614 blob(): Promise<Blob>;
2615}
2616export type R2Range =
2617 | {
2618 offset: number;
2619 length?: number;
2620 }
2621 | {
2622 offset?: number;
2623 length: number;
2624 }
2625 | {
2626 suffix: number;
2627 };
2628export interface R2Conditional {
2629 etagMatches?: string;
2630 etagDoesNotMatch?: string;
2631 uploadedBefore?: Date;
2632 uploadedAfter?: Date;
2633 secondsGranularity?: boolean;
2634}
2635export interface R2GetOptions {
2636 onlyIf?: R2Conditional | Headers;
2637 range?: R2Range | Headers;
2638 ssecKey?: ArrayBuffer | string;
2639}
2640export interface R2PutOptions {
2641 onlyIf?: R2Conditional | Headers;
2642 httpMetadata?: R2HTTPMetadata | Headers;
2643 customMetadata?: Record<string, string>;
2644 md5?: (ArrayBuffer | ArrayBufferView) | string;
2645 sha1?: (ArrayBuffer | ArrayBufferView) | string;
2646 sha256?: (ArrayBuffer | ArrayBufferView) | string;
2647 sha384?: (ArrayBuffer | ArrayBufferView) | string;
2648 sha512?: (ArrayBuffer | ArrayBufferView) | string;
2649 storageClass?: string;
2650 ssecKey?: ArrayBuffer | string;
2651}
2652export interface R2MultipartOptions {
2653 httpMetadata?: R2HTTPMetadata | Headers;
2654 customMetadata?: Record<string, string>;
2655 storageClass?: string;
2656 ssecKey?: ArrayBuffer | string;
2657}
2658export interface R2Checksums {
2659 readonly md5?: ArrayBuffer;
2660 readonly sha1?: ArrayBuffer;
2661 readonly sha256?: ArrayBuffer;
2662 readonly sha384?: ArrayBuffer;
2663 readonly sha512?: ArrayBuffer;
2664 toJSON(): R2StringChecksums;
2665}
2666export interface R2StringChecksums {
2667 md5?: string;
2668 sha1?: string;
2669 sha256?: string;
2670 sha384?: string;
2671 sha512?: string;
2672}
2673export interface R2HTTPMetadata {
2674 contentType?: string;
2675 contentLanguage?: string;
2676 contentDisposition?: string;
2677 contentEncoding?: string;
2678 cacheControl?: string;
2679 cacheExpiry?: Date;
2680}
2681export type R2Objects = {
2682 objects: R2Object[];
2683 delimitedPrefixes: string[];
2684} & (
2685 | {
2686 truncated: true;
2687 cursor: string;
2688 }
2689 | {
2690 truncated: false;
2691 }
2692);
2693export interface R2UploadPartOptions {
2694 ssecKey?: ArrayBuffer | string;
2695}
2696export declare abstract class JsRpcPromise {
2697 then(handler: Function, errorHandler?: Function): any;
2698 catch(errorHandler: Function): any;
2699 finally(onFinally: Function): any;
2700}
2701export declare abstract class JsRpcProperty {
2702 then(handler: Function, errorHandler?: Function): any;
2703 catch(errorHandler: Function): any;
2704 finally(onFinally: Function): any;
2705}
2706export declare abstract class ScheduledEvent extends ExtendableEvent {
2707 readonly scheduledTime: number;
2708 readonly cron: string;
2709 noRetry(): void;
2710}
2711export interface ScheduledController {
2712 readonly scheduledTime: number;
2713 readonly cron: string;
2714 noRetry(): void;
2715}
2716export interface QueuingStrategy<T = any> {
2717 highWaterMark?: number | bigint;
2718 size?: (chunk: T) => number | bigint;
2719}
2720export interface UnderlyingSink<W = any> {
2721 type?: string;
2722 start?: (controller: WritableStreamDefaultController) => void | Promise<void>;
2723 write?: (
2724 chunk: W,
2725 controller: WritableStreamDefaultController,
2726 ) => void | Promise<void>;
2727 abort?: (reason: any) => void | Promise<void>;
2728 close?: () => void | Promise<void>;
2729}
2730export interface UnderlyingByteSource {
2731 type: "bytes";
2732 autoAllocateChunkSize?: number;
2733 start?: (controller: ReadableByteStreamController) => void | Promise<void>;
2734 pull?: (controller: ReadableByteStreamController) => void | Promise<void>;
2735 cancel?: (reason: any) => void | Promise<void>;
2736}
2737export interface UnderlyingSource<R = any> {
2738 type?: "" | undefined;
2739 start?: (
2740 controller: ReadableStreamDefaultController<R>,
2741 ) => void | Promise<void>;
2742 pull?: (
2743 controller: ReadableStreamDefaultController<R>,
2744 ) => void | Promise<void>;
2745 cancel?: (reason: any) => void | Promise<void>;
2746 expectedLength?: number | bigint;
2747}
2748export interface Transformer<I = any, O = any> {
2749 readableType?: string;
2750 writableType?: string;
2751 start?: (
2752 controller: TransformStreamDefaultController<O>,
2753 ) => void | Promise<void>;
2754 transform?: (
2755 chunk: I,
2756 controller: TransformStreamDefaultController<O>,
2757 ) => void | Promise<void>;
2758 flush?: (
2759 controller: TransformStreamDefaultController<O>,
2760 ) => void | Promise<void>;
2761 cancel?: (reason: any) => void | Promise<void>;
2762 expectedLength?: number;
2763}
2764export interface StreamPipeOptions {
2765 preventAbort?: boolean;
2766 preventCancel?: boolean;
2767 /**
2768 * 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.
2769 *
2770 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
2771 *
2772 * Errors and closures of the source and destination streams propagate as follows:
2773 *
2774 * 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.
2775 *
2776 * 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.
2777 *
2778 * 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.
2779 *
2780 * 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.
2781 *
2782 * 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.
2783 */
2784 preventClose?: boolean;
2785 signal?: AbortSignal;
2786}
2787export type ReadableStreamReadResult<R = any> =
2788 | {
2789 done: false;
2790 value: R;
2791 }
2792 | {
2793 done: true;
2794 value?: undefined;
2795 };
2796/**
2797 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2798 *
2799 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2800 */
2801export interface ReadableStream<R = any> {
2802 /**
2803 * The **`locked`** read-only property of the ReadableStream interface returns whether or not the readable stream is locked to a reader.
2804 *
2805 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/locked)
2806 */
2807 get locked(): boolean;
2808 /**
2809 * The **`cancel()`** method of the ReadableStream interface returns a Promise that resolves when the stream is canceled.
2810 *
2811 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/cancel)
2812 */
2813 cancel(reason?: any): Promise<void>;
2814 /**
2815 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2816 *
2817 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2818 */
2819 getReader(): ReadableStreamDefaultReader<R>;
2820 /**
2821 * The **`getReader()`** method of the ReadableStream interface creates a reader and locks the stream to it.
2822 *
2823 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/getReader)
2824 */
2825 getReader(options: ReadableStreamGetReaderOptions): ReadableStreamBYOBReader;
2826 /**
2827 * 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.
2828 *
2829 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeThrough)
2830 */
2831 pipeThrough<T>(
2832 transform: ReadableWritablePair<T, R>,
2833 options?: StreamPipeOptions,
2834 ): ReadableStream<T>;
2835 /**
2836 * 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.
2837 *
2838 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/pipeTo)
2839 */
2840 pipeTo(
2841 destination: WritableStream<R>,
2842 options?: StreamPipeOptions,
2843 ): Promise<void>;
2844 /**
2845 * The **`tee()`** method of the two-element array containing the two resulting branches as new ReadableStream instances.
2846 *
2847 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream/tee)
2848 */
2849 tee(): [ReadableStream<R>, ReadableStream<R>];
2850 values(options?: ReadableStreamValuesOptions): AsyncIterableIterator<R>;
2851 [Symbol.asyncIterator](
2852 options?: ReadableStreamValuesOptions,
2853 ): AsyncIterableIterator<R>;
2854}
2855/**
2856 * The `ReadableStream` interface of the Streams API represents a readable stream of byte data.
2857 *
2858 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStream)
2859 */
2860export declare const ReadableStream: {
2861 prototype: ReadableStream;
2862 new (
2863 underlyingSource: UnderlyingByteSource,
2864 strategy?: QueuingStrategy<Uint8Array>,
2865 ): ReadableStream<Uint8Array>;
2866 new <R = any>(
2867 underlyingSource?: UnderlyingSource<R>,
2868 strategy?: QueuingStrategy<R>,
2869 ): ReadableStream<R>;
2870};
2871/**
2872 * 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).
2873 *
2874 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader)
2875 */
2876export declare class ReadableStreamDefaultReader<R = any> {
2877 constructor(stream: ReadableStream);
2878 get closed(): Promise<void>;
2879 cancel(reason?: any): Promise<void>;
2880 /**
2881 * The **`read()`** method of the ReadableStreamDefaultReader interface returns a Promise providing access to the next chunk in the stream's internal queue.
2882 *
2883 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/read)
2884 */
2885 read(): Promise<ReadableStreamReadResult<R>>;
2886 /**
2887 * The **`releaseLock()`** method of the ReadableStreamDefaultReader interface releases the reader's lock on the stream.
2888 *
2889 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultReader/releaseLock)
2890 */
2891 releaseLock(): void;
2892}
2893/**
2894 * The `ReadableStreamBYOBReader` interface of the Streams API defines a reader for a ReadableStream that supports zero-copy reading from an underlying byte source.
2895 *
2896 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader)
2897 */
2898export declare class ReadableStreamBYOBReader {
2899 constructor(stream: ReadableStream);
2900 get closed(): Promise<void>;
2901 cancel(reason?: any): Promise<void>;
2902 /**
2903 * 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.
2904 *
2905 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/read)
2906 */
2907 read<T extends ArrayBufferView>(
2908 view: T,
2909 ): Promise<ReadableStreamReadResult<T>>;
2910 /**
2911 * The **`releaseLock()`** method of the ReadableStreamBYOBReader interface releases the reader's lock on the stream.
2912 *
2913 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBReader/releaseLock)
2914 */
2915 releaseLock(): void;
2916 readAtLeast<T extends ArrayBufferView>(
2917 minElements: number,
2918 view: T,
2919 ): Promise<ReadableStreamReadResult<T>>;
2920}
2921export interface ReadableStreamBYOBReaderReadableStreamBYOBReaderReadOptions {
2922 min?: number;
2923}
2924export interface ReadableStreamGetReaderOptions {
2925 /**
2926 * Creates a ReadableStreamBYOBReader and locks the stream to the new reader.
2927 *
2928 * 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.
2929 */
2930 mode: "byob";
2931}
2932/**
2933 * 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).
2934 *
2935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest)
2936 */
2937export declare abstract class ReadableStreamBYOBRequest {
2938 /**
2939 * The **`view`** getter property of the ReadableStreamBYOBRequest interface returns the current view.
2940 *
2941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/view)
2942 */
2943 get view(): Uint8Array | null;
2944 /**
2945 * 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.
2946 *
2947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respond)
2948 */
2949 respond(bytesWritten: number): void;
2950 /**
2951 * 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.
2952 *
2953 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamBYOBRequest/respondWithNewView)
2954 */
2955 respondWithNewView(view: ArrayBuffer | ArrayBufferView): void;
2956 get atLeast(): number | null;
2957}
2958/**
2959 * The **`ReadableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a ReadableStream's state and internal queue.
2960 *
2961 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController)
2962 */
2963export declare abstract class ReadableStreamDefaultController<R = any> {
2964 /**
2965 * The **`desiredSize`** read-only property of the required to fill the stream's internal queue.
2966 *
2967 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/desiredSize)
2968 */
2969 get desiredSize(): number | null;
2970 /**
2971 * The **`close()`** method of the ReadableStreamDefaultController interface closes the associated stream.
2972 *
2973 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/close)
2974 */
2975 close(): void;
2976 /**
2977 * The **`enqueue()`** method of the ```js-nolint enqueue(chunk) ``` - `chunk` - : The chunk to enqueue.
2978 *
2979 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/enqueue)
2980 */
2981 enqueue(chunk?: R): void;
2982 /**
2983 * The **`error()`** method of the with the associated stream to error.
2984 *
2985 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableStreamDefaultController/error)
2986 */
2987 error(reason: any): void;
2988}
2989/**
2990 * The **`ReadableByteStreamController`** interface of the Streams API represents a controller for a readable byte stream.
2991 *
2992 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController)
2993 */
2994export declare abstract class ReadableByteStreamController {
2995 /**
2996 * The **`byobRequest`** read-only property of the ReadableByteStreamController interface returns the current BYOB request, or `null` if there are no pending requests.
2997 *
2998 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/byobRequest)
2999 */
3000 get byobRequest(): ReadableStreamBYOBRequest | null;
3001 /**
3002 * 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'.
3003 *
3004 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/desiredSize)
3005 */
3006 get desiredSize(): number | null;
3007 /**
3008 * The **`close()`** method of the ReadableByteStreamController interface closes the associated stream.
3009 *
3010 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/close)
3011 */
3012 close(): void;
3013 /**
3014 * 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).
3015 *
3016 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/enqueue)
3017 */
3018 enqueue(chunk: ArrayBuffer | ArrayBufferView): void;
3019 /**
3020 * The **`error()`** method of the ReadableByteStreamController interface causes any future interactions with the associated stream to error with the specified reason.
3021 *
3022 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ReadableByteStreamController/error)
3023 */
3024 error(reason: any): void;
3025}
3026/**
3027 * The **`WritableStreamDefaultController`** interface of the Streams API represents a controller allowing control of a WritableStream's state.
3028 *
3029 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController)
3030 */
3031export declare abstract class WritableStreamDefaultController {
3032 /**
3033 * The read-only **`signal`** property of the WritableStreamDefaultController interface returns the AbortSignal associated with the controller.
3034 *
3035 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/signal)
3036 */
3037 get signal(): AbortSignal;
3038 /**
3039 * The **`error()`** method of the with the associated stream to error.
3040 *
3041 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultController/error)
3042 */
3043 error(reason?: any): void;
3044}
3045/**
3046 * The **`TransformStreamDefaultController`** interface of the Streams API provides methods to manipulate the associated ReadableStream and WritableStream.
3047 *
3048 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController)
3049 */
3050export declare abstract class TransformStreamDefaultController<O = any> {
3051 /**
3052 * The **`desiredSize`** read-only property of the TransformStreamDefaultController interface returns the desired size to fill the queue of the associated ReadableStream.
3053 *
3054 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/desiredSize)
3055 */
3056 get desiredSize(): number | null;
3057 /**
3058 * The **`enqueue()`** method of the TransformStreamDefaultController interface enqueues the given chunk in the readable side of the stream.
3059 *
3060 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/enqueue)
3061 */
3062 enqueue(chunk?: O): void;
3063 /**
3064 * The **`error()`** method of the TransformStreamDefaultController interface errors both sides of the stream.
3065 *
3066 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/error)
3067 */
3068 error(reason: any): void;
3069 /**
3070 * The **`terminate()`** method of the TransformStreamDefaultController interface closes the readable side and errors the writable side of the stream.
3071 *
3072 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStreamDefaultController/terminate)
3073 */
3074 terminate(): void;
3075}
3076export interface ReadableWritablePair<R = any, W = any> {
3077 readable: ReadableStream<R>;
3078 /**
3079 * 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.
3080 *
3081 * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader.
3082 */
3083 writable: WritableStream<W>;
3084}
3085/**
3086 * The **`WritableStream`** interface of the Streams API provides a standard abstraction for writing streaming data to a destination, known as a sink.
3087 *
3088 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream)
3089 */
3090export declare class WritableStream<W = any> {
3091 constructor(
3092 underlyingSink?: UnderlyingSink,
3093 queuingStrategy?: QueuingStrategy,
3094 );
3095 /**
3096 * The **`locked`** read-only property of the WritableStream interface returns a boolean indicating whether the `WritableStream` is locked to a writer.
3097 *
3098 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/locked)
3099 */
3100 get locked(): boolean;
3101 /**
3102 * 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.
3103 *
3104 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/abort)
3105 */
3106 abort(reason?: any): Promise<void>;
3107 /**
3108 * The **`close()`** method of the WritableStream interface closes the associated stream.
3109 *
3110 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/close)
3111 */
3112 close(): Promise<void>;
3113 /**
3114 * The **`getWriter()`** method of the WritableStream interface returns a new instance of WritableStreamDefaultWriter and locks the stream to that instance.
3115 *
3116 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStream/getWriter)
3117 */
3118 getWriter(): WritableStreamDefaultWriter<W>;
3119}
3120/**
3121 * 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.
3122 *
3123 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter)
3124 */
3125export declare class WritableStreamDefaultWriter<W = any> {
3126 constructor(stream: WritableStream);
3127 /**
3128 * The **`closed`** read-only property of the the stream errors or the writer's lock is released.
3129 *
3130 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/closed)
3131 */
3132 get closed(): Promise<void>;
3133 /**
3134 * 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.
3135 *
3136 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/ready)
3137 */
3138 get ready(): Promise<void>;
3139 /**
3140 * The **`desiredSize`** read-only property of the to fill the stream's internal queue.
3141 *
3142 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/desiredSize)
3143 */
3144 get desiredSize(): number | null;
3145 /**
3146 * 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.
3147 *
3148 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/abort)
3149 */
3150 abort(reason?: any): Promise<void>;
3151 /**
3152 * The **`close()`** method of the stream.
3153 *
3154 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/close)
3155 */
3156 close(): Promise<void>;
3157 /**
3158 * The **`write()`** method of the operation.
3159 *
3160 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/write)
3161 */
3162 write(chunk?: W): Promise<void>;
3163 /**
3164 * The **`releaseLock()`** method of the corresponding stream.
3165 *
3166 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WritableStreamDefaultWriter/releaseLock)
3167 */
3168 releaseLock(): void;
3169}
3170/**
3171 * The **`TransformStream`** interface of the Streams API represents a concrete implementation of the pipe chain _transform stream_ concept.
3172 *
3173 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream)
3174 */
3175export declare class TransformStream<I = any, O = any> {
3176 constructor(
3177 transformer?: Transformer<I, O>,
3178 writableStrategy?: QueuingStrategy<I>,
3179 readableStrategy?: QueuingStrategy<O>,
3180 );
3181 /**
3182 * The **`readable`** read-only property of the TransformStream interface returns the ReadableStream instance controlled by this `TransformStream`.
3183 *
3184 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/readable)
3185 */
3186 get readable(): ReadableStream<O>;
3187 /**
3188 * The **`writable`** read-only property of the TransformStream interface returns the WritableStream instance controlled by this `TransformStream`.
3189 *
3190 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TransformStream/writable)
3191 */
3192 get writable(): WritableStream<I>;
3193}
3194export declare class FixedLengthStream extends IdentityTransformStream {
3195 constructor(
3196 expectedLength: number | bigint,
3197 queuingStrategy?: IdentityTransformStreamQueuingStrategy,
3198 );
3199}
3200export declare class IdentityTransformStream extends TransformStream<
3201 ArrayBuffer | ArrayBufferView,
3202 Uint8Array
3203> {
3204 constructor(queuingStrategy?: IdentityTransformStreamQueuingStrategy);
3205}
3206export interface IdentityTransformStreamQueuingStrategy {
3207 highWaterMark?: number | bigint;
3208}
3209export interface ReadableStreamValuesOptions {
3210 preventCancel?: boolean;
3211}
3212/**
3213 * The **`CompressionStream`** interface of the Compression Streams API is an API for compressing a stream of data.
3214 *
3215 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CompressionStream)
3216 */
3217export declare class CompressionStream extends TransformStream<
3218 ArrayBuffer | ArrayBufferView,
3219 Uint8Array
3220> {
3221 constructor(format: "gzip" | "deflate" | "deflate-raw");
3222}
3223/**
3224 * The **`DecompressionStream`** interface of the Compression Streams API is an API for decompressing a stream of data.
3225 *
3226 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/DecompressionStream)
3227 */
3228export declare class DecompressionStream extends TransformStream<
3229 ArrayBuffer | ArrayBufferView,
3230 Uint8Array
3231> {
3232 constructor(format: "gzip" | "deflate" | "deflate-raw");
3233}
3234/**
3235 * The **`TextEncoderStream`** interface of the Encoding API converts a stream of strings into bytes in the UTF-8 encoding.
3236 *
3237 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextEncoderStream)
3238 */
3239export declare class TextEncoderStream extends TransformStream<
3240 string,
3241 Uint8Array
3242> {
3243 constructor();
3244 get encoding(): string;
3245}
3246/**
3247 * 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.
3248 *
3249 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/TextDecoderStream)
3250 */
3251export declare class TextDecoderStream extends TransformStream<
3252 ArrayBuffer | ArrayBufferView,
3253 string
3254> {
3255 constructor(label?: string, options?: TextDecoderStreamTextDecoderStreamInit);
3256 get encoding(): string;
3257 get fatal(): boolean;
3258 get ignoreBOM(): boolean;
3259}
3260export interface TextDecoderStreamTextDecoderStreamInit {
3261 fatal?: boolean;
3262 ignoreBOM?: boolean;
3263}
3264/**
3265 * The **`ByteLengthQueuingStrategy`** interface of the Streams API provides a built-in byte length queuing strategy that can be used when constructing streams.
3266 *
3267 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy)
3268 */
3269export declare class ByteLengthQueuingStrategy implements QueuingStrategy<ArrayBufferView> {
3270 constructor(init: QueuingStrategyInit);
3271 /**
3272 * The read-only **`ByteLengthQueuingStrategy.highWaterMark`** property returns the total number of bytes that can be contained in the internal queue before backpressure is applied.
3273 *
3274 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/highWaterMark)
3275 */
3276 get highWaterMark(): number;
3277 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/ByteLengthQueuingStrategy/size) */
3278 get size(): (chunk?: any) => number;
3279}
3280/**
3281 * The **`CountQueuingStrategy`** interface of the Streams API provides a built-in chunk counting queuing strategy that can be used when constructing streams.
3282 *
3283 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy)
3284 */
3285export declare class CountQueuingStrategy implements QueuingStrategy {
3286 constructor(init: QueuingStrategyInit);
3287 /**
3288 * The read-only **`CountQueuingStrategy.highWaterMark`** property returns the total number of chunks that can be contained in the internal queue before backpressure is applied.
3289 *
3290 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/highWaterMark)
3291 */
3292 get highWaterMark(): number;
3293 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/CountQueuingStrategy/size) */
3294 get size(): (chunk?: any) => number;
3295}
3296export interface QueuingStrategyInit {
3297 /**
3298 * Creates a new ByteLengthQueuingStrategy with the provided high water mark.
3299 *
3300 * 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.
3301 */
3302 highWaterMark: number;
3303}
3304export interface TracePreviewInfo {
3305 id: string;
3306 slug: string;
3307 name: string;
3308}
3309export interface ScriptVersion {
3310 id?: string;
3311 tag?: string;
3312 message?: string;
3313}
3314export declare abstract class TailEvent extends ExtendableEvent {
3315 readonly events: TraceItem[];
3316 readonly traces: TraceItem[];
3317}
3318export interface TraceItem {
3319 readonly event:
3320 | (
3321 | TraceItemFetchEventInfo
3322 | TraceItemJsRpcEventInfo
3323 | TraceItemConnectEventInfo
3324 | TraceItemScheduledEventInfo
3325 | TraceItemAlarmEventInfo
3326 | TraceItemQueueEventInfo
3327 | TraceItemEmailEventInfo
3328 | TraceItemTailEventInfo
3329 | TraceItemCustomEventInfo
3330 | TraceItemHibernatableWebSocketEventInfo
3331 )
3332 | null;
3333 readonly eventTimestamp: number | null;
3334 readonly logs: TraceLog[];
3335 readonly exceptions: TraceException[];
3336 readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
3337 readonly scriptName: string | null;
3338 readonly entrypoint?: string;
3339 readonly scriptVersion?: ScriptVersion;
3340 readonly dispatchNamespace?: string;
3341 readonly scriptTags?: string[];
3342 readonly tailAttributes?: Record<string, boolean | number | string>;
3343 readonly preview?: TracePreviewInfo;
3344 readonly durableObjectId?: string;
3345 readonly outcome: string;
3346 readonly executionModel: string;
3347 readonly truncated: boolean;
3348 readonly cpuTime: number;
3349 readonly wallTime: number;
3350}
3351export interface TraceItemAlarmEventInfo {
3352 readonly scheduledTime: Date;
3353}
3354export interface TraceItemConnectEventInfo {}
3355export interface TraceItemCustomEventInfo {}
3356export interface TraceItemScheduledEventInfo {
3357 readonly scheduledTime: number;
3358 readonly cron: string;
3359}
3360export interface TraceItemQueueEventInfo {
3361 readonly queue: string;
3362 readonly batchSize: number;
3363}
3364export interface TraceItemEmailEventInfo {
3365 readonly mailFrom: string;
3366 readonly rcptTo: string;
3367 readonly rawSize: number;
3368}
3369export interface TraceItemTailEventInfo {
3370 readonly consumedEvents: TraceItemTailEventInfoTailItem[];
3371}
3372export interface TraceItemTailEventInfoTailItem {
3373 readonly scriptName: string | null;
3374}
3375export interface TraceItemFetchEventInfo {
3376 readonly response?: TraceItemFetchEventInfoResponse;
3377 readonly request: TraceItemFetchEventInfoRequest;
3378}
3379export interface TraceItemFetchEventInfoRequest {
3380 readonly cf?: any;
3381 readonly headers: Record<string, string>;
3382 readonly method: string;
3383 readonly url: string;
3384 getUnredacted(): TraceItemFetchEventInfoRequest;
3385}
3386export interface TraceItemFetchEventInfoResponse {
3387 readonly status: number;
3388}
3389export interface TraceItemJsRpcEventInfo {
3390 readonly rpcMethod: string;
3391}
3392export interface TraceItemHibernatableWebSocketEventInfo {
3393 readonly getWebSocketEvent:
3394 | TraceItemHibernatableWebSocketEventInfoMessage
3395 | TraceItemHibernatableWebSocketEventInfoClose
3396 | TraceItemHibernatableWebSocketEventInfoError;
3397}
3398export interface TraceItemHibernatableWebSocketEventInfoMessage {
3399 readonly webSocketEventType: string;
3400}
3401export interface TraceItemHibernatableWebSocketEventInfoClose {
3402 readonly webSocketEventType: string;
3403 readonly code: number;
3404 readonly wasClean: boolean;
3405}
3406export interface TraceItemHibernatableWebSocketEventInfoError {
3407 readonly webSocketEventType: string;
3408}
3409export interface TraceLog {
3410 readonly timestamp: number;
3411 readonly level: string;
3412 readonly message: any;
3413}
3414export interface TraceException {
3415 readonly timestamp: number;
3416 readonly message: string;
3417 readonly name: string;
3418 readonly stack?: string;
3419}
3420export interface TraceDiagnosticChannelEvent {
3421 readonly timestamp: number;
3422 readonly channel: string;
3423 readonly message: any;
3424}
3425export interface TraceMetrics {
3426 readonly cpuTime: number;
3427 readonly wallTime: number;
3428}
3429export interface UnsafeTraceMetrics {
3430 fromTrace(item: TraceItem): TraceMetrics;
3431}
3432/**
3433 * The **`URL`** interface is used to parse, construct, normalize, and encode URL.
3434 *
3435 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL)
3436 */
3437export declare class URL {
3438 constructor(url: string | URL, base?: string | URL);
3439 /**
3440 * The **`origin`** read-only property of the URL interface returns a string containing the Unicode serialization of the origin of the represented URL.
3441 *
3442 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/origin)
3443 */
3444 get origin(): 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 get href(): string;
3451 /**
3452 * The **`href`** property of the URL interface is a string containing the whole URL.
3453 *
3454 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/href)
3455 */
3456 set href(value: 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 get protocol(): string;
3463 /**
3464 * The **`protocol`** property of the URL interface is a string containing the protocol or scheme of the URL, including the final `':'`.
3465 *
3466 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/protocol)
3467 */
3468 set protocol(value: 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 get username(): string;
3475 /**
3476 * The **`username`** property of the URL interface is a string containing the username component of the URL.
3477 *
3478 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/username)
3479 */
3480 set username(value: 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 get password(): string;
3487 /**
3488 * The **`password`** property of the URL interface is a string containing the password component of the URL.
3489 *
3490 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/password)
3491 */
3492 set password(value: 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 get host(): string;
3499 /**
3500 * 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.
3501 *
3502 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/host)
3503 */
3504 set host(value: 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 get hostname(): string;
3511 /**
3512 * The **`hostname`** property of the URL interface is a string containing either the domain name or IP address of the URL.
3513 *
3514 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hostname)
3515 */
3516 set hostname(value: 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 get port(): string;
3523 /**
3524 * The **`port`** property of the URL interface is a string containing the port number of the URL.
3525 *
3526 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/port)
3527 */
3528 set port(value: 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 get pathname(): string;
3535 /**
3536 * The **`pathname`** property of the URL interface represents a location in a hierarchical structure.
3537 *
3538 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/pathname)
3539 */
3540 set pathname(value: 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 get search(): string;
3547 /**
3548 * 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.
3549 *
3550 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/search)
3551 */
3552 set search(value: 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 get hash(): string;
3559 /**
3560 * The **`hash`** property of the URL interface is a string containing a `'#'` followed by the fragment identifier of the URL.
3561 *
3562 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/hash)
3563 */
3564 set hash(value: string);
3565 /**
3566 * The **`searchParams`** read-only property of the access to the [MISSING: httpmethod('GET')] decoded query arguments contained in the URL.
3567 *
3568 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/searchParams)
3569 */
3570 get searchParams(): URLSearchParams;
3571 /**
3572 * 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.
3573 *
3574 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/toJSON)
3575 */
3576 toJSON(): string;
3577 /*function toString() { [native code] }*/
3578 toString(): string;
3579 /**
3580 * 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.
3581 *
3582 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static)
3583 */
3584 static canParse(url: string, base?: string): boolean;
3585 /**
3586 * The **`URL.parse()`** static method of the URL interface returns a newly created URL object representing the URL defined by the parameters.
3587 *
3588 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/parse_static)
3589 */
3590 static parse(url: string, base?: string): URL | null;
3591 /**
3592 * The **`createObjectURL()`** static method of the URL interface creates a string containing a URL representing the object given in the parameter.
3593 *
3594 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static)
3595 */
3596 static createObjectURL(object: File | Blob): string;
3597 /**
3598 * 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.
3599 *
3600 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static)
3601 */
3602 static revokeObjectURL(object_url: string): void;
3603}
3604/**
3605 * The **`URLSearchParams`** interface defines utility methods to work with the query string of a URL.
3606 *
3607 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams)
3608 */
3609export declare class URLSearchParams {
3610 constructor(
3611 init?: Iterable<Iterable<string>> | Record<string, string> | string,
3612 );
3613 /**
3614 * The **`size`** read-only property of the URLSearchParams interface indicates the total number of search parameter entries.
3615 *
3616 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/size)
3617 */
3618 get size(): number;
3619 /**
3620 * The **`append()`** method of the URLSearchParams interface appends a specified key/value pair as a new search parameter.
3621 *
3622 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/append)
3623 */
3624 append(name: string, value: string): void;
3625 /**
3626 * The **`delete()`** method of the URLSearchParams interface deletes specified parameters and their associated value(s) from the list of all search parameters.
3627 *
3628 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/delete)
3629 */
3630 delete(name: string, value?: string): void;
3631 /**
3632 * The **`get()`** method of the URLSearchParams interface returns the first value associated to the given search parameter.
3633 *
3634 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/get)
3635 */
3636 get(name: string): string | null;
3637 /**
3638 * The **`getAll()`** method of the URLSearchParams interface returns all the values associated with a given search parameter as an array.
3639 *
3640 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/getAll)
3641 */
3642 getAll(name: string): string[];
3643 /**
3644 * The **`has()`** method of the URLSearchParams interface returns a boolean value that indicates whether the specified parameter is in the search parameters.
3645 *
3646 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/has)
3647 */
3648 has(name: string, value?: string): boolean;
3649 /**
3650 * The **`set()`** method of the URLSearchParams interface sets the value associated with a given search parameter to the given value.
3651 *
3652 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/set)
3653 */
3654 set(name: string, value: string): void;
3655 /**
3656 * The **`URLSearchParams.sort()`** method sorts all key/value pairs contained in this object in place and returns `undefined`.
3657 *
3658 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams/sort)
3659 */
3660 sort(): void;
3661 /* Returns an array of key, value pairs for every entry in the search params. */
3662 entries(): IterableIterator<[key: string, value: string]>;
3663 /* Returns a list of keys in the search params. */
3664 keys(): IterableIterator<string>;
3665 /* Returns a list of values in the search params. */
3666 values(): IterableIterator<string>;
3667 forEach<This = unknown>(
3668 callback: (
3669 this: This,
3670 value: string,
3671 key: string,
3672 parent: URLSearchParams,
3673 ) => void,
3674 thisArg?: This,
3675 ): void;
3676 /*function toString() { [native code] }*/
3677 toString(): string;
3678 [Symbol.iterator](): IterableIterator<[key: string, value: string]>;
3679}
3680export declare class URLPattern {
3681 constructor(
3682 input?: string | URLPatternInit,
3683 baseURL?: string | URLPatternOptions,
3684 patternOptions?: URLPatternOptions,
3685 );
3686 get protocol(): string;
3687 get username(): string;
3688 get password(): string;
3689 get hostname(): string;
3690 get port(): string;
3691 get pathname(): string;
3692 get search(): string;
3693 get hash(): string;
3694 get hasRegExpGroups(): boolean;
3695 test(input?: string | URLPatternInit, baseURL?: string): boolean;
3696 exec(
3697 input?: string | URLPatternInit,
3698 baseURL?: string,
3699 ): URLPatternResult | null;
3700}
3701export interface URLPatternInit {
3702 protocol?: string;
3703 username?: string;
3704 password?: string;
3705 hostname?: string;
3706 port?: string;
3707 pathname?: string;
3708 search?: string;
3709 hash?: string;
3710 baseURL?: string;
3711}
3712export interface URLPatternComponentResult {
3713 input: string;
3714 groups: Record<string, string>;
3715}
3716export interface URLPatternResult {
3717 inputs: (string | URLPatternInit)[];
3718 protocol: URLPatternComponentResult;
3719 username: URLPatternComponentResult;
3720 password: URLPatternComponentResult;
3721 hostname: URLPatternComponentResult;
3722 port: URLPatternComponentResult;
3723 pathname: URLPatternComponentResult;
3724 search: URLPatternComponentResult;
3725 hash: URLPatternComponentResult;
3726}
3727export interface URLPatternOptions {
3728 ignoreCase?: boolean;
3729}
3730/**
3731 * A `CloseEvent` is sent to clients using WebSockets when the connection is closed.
3732 *
3733 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent)
3734 */
3735export declare class CloseEvent extends Event {
3736 constructor(type: string, initializer?: CloseEventInit);
3737 /**
3738 * The **`code`** read-only property of the CloseEvent interface returns a WebSocket connection close code indicating the reason the connection was closed.
3739 *
3740 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/code)
3741 */
3742 readonly code: number;
3743 /**
3744 * 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.
3745 *
3746 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/reason)
3747 */
3748 readonly reason: string;
3749 /**
3750 * The **`wasClean`** read-only property of the CloseEvent interface returns `true` if the connection closed cleanly.
3751 *
3752 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CloseEvent/wasClean)
3753 */
3754 readonly wasClean: boolean;
3755}
3756export interface CloseEventInit {
3757 code?: number;
3758 reason?: string;
3759 wasClean?: boolean;
3760}
3761export type WebSocketEventMap = {
3762 close: CloseEvent;
3763 message: MessageEvent;
3764 open: Event;
3765 error: ErrorEvent;
3766};
3767/**
3768 * 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.
3769 *
3770 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3771 */
3772export declare var WebSocket: {
3773 prototype: WebSocket;
3774 new (url: string, protocols?: string[] | string): WebSocket;
3775 readonly READY_STATE_CONNECTING: number;
3776 readonly CONNECTING: number;
3777 readonly READY_STATE_OPEN: number;
3778 readonly OPEN: number;
3779 readonly READY_STATE_CLOSING: number;
3780 readonly CLOSING: number;
3781 readonly READY_STATE_CLOSED: number;
3782 readonly CLOSED: number;
3783};
3784/**
3785 * 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.
3786 *
3787 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
3788 */
3789export interface WebSocket extends EventTarget<WebSocketEventMap> {
3790 accept(options?: WebSocketAcceptOptions): void;
3791 /**
3792 * 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.
3793 *
3794 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/send)
3795 */
3796 send(message: (ArrayBuffer | ArrayBufferView) | string): void;
3797 /**
3798 * The **`WebSocket.close()`** method closes the already `CLOSED`, this method does nothing.
3799 *
3800 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/close)
3801 */
3802 close(code?: number, reason?: string): void;
3803 serializeAttachment(attachment: any): void;
3804 deserializeAttachment(): any | null;
3805 /**
3806 * The **`WebSocket.readyState`** read-only property returns the current state of the WebSocket connection.
3807 *
3808 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
3809 */
3810 readyState: number;
3811 /**
3812 * The **`WebSocket.url`** read-only property returns the absolute URL of the WebSocket as resolved by the constructor.
3813 *
3814 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
3815 */
3816 url: string | null;
3817 /**
3818 * 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.
3819 *
3820 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
3821 */
3822 protocol: string | null;
3823 /**
3824 * The **`WebSocket.extensions`** read-only property returns the extensions selected by the server.
3825 *
3826 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
3827 */
3828 extensions: string | null;
3829 /**
3830 * The **`WebSocket.binaryType`** property controls the type of binary data being received over the WebSocket connection.
3831 *
3832 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/binaryType)
3833 */
3834 binaryType: "blob" | "arraybuffer";
3835}
3836export interface WebSocketAcceptOptions {
3837 /**
3838 * When set to `true`, receiving a server-initiated WebSocket Close frame will not
3839 * automatically send a reciprocal Close frame, leaving the connection in a half-open
3840 * state. This is useful for proxying scenarios where you need to coordinate closing
3841 * both sides independently. Defaults to `false` when the
3842 * `no_web_socket_half_open_by_default` compatibility flag is enabled.
3843 */
3844 allowHalfOpen?: boolean;
3845}
3846export declare const WebSocketPair: {
3847 new (): {
3848 0: WebSocket;
3849 1: WebSocket;
3850 };
3851};
3852export interface SqlStorage {
3853 exec<T extends Record<string, SqlStorageValue>>(
3854 query: string,
3855 ...bindings: any[]
3856 ): SqlStorageCursor<T>;
3857 prepare(query: string): SqlStorageStatement;
3858 ingest(query: string): SqlStorageIngestResult;
3859 setMaxPageCountForTest(count: number): void;
3860 get databaseSize(): number;
3861 Cursor: typeof SqlStorageCursor;
3862 Statement: typeof SqlStorageStatement;
3863}
3864export declare abstract class SqlStorageStatement {}
3865export type SqlStorageValue = ArrayBuffer | string | number | null;
3866export declare abstract class SqlStorageCursor<
3867 T extends Record<string, SqlStorageValue>,
3868> {
3869 next():
3870 | {
3871 done?: false;
3872 value: T;
3873 }
3874 | {
3875 done: true;
3876 value?: never;
3877 };
3878 toArray(): T[];
3879 one(): T;
3880 raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
3881 columnNames: string[];
3882 get rowsRead(): number;
3883 get rowsWritten(): number;
3884 get reusedCachedQueryForTest(): boolean;
3885 [Symbol.iterator](): IterableIterator<T>;
3886}
3887export interface SqlStorageIngestResult {
3888 remainder: string;
3889 rowsRead: number;
3890 rowsWritten: number;
3891 statementCount: number;
3892}
3893export interface Socket {
3894 get readable(): ReadableStream;
3895 get writable(): WritableStream;
3896 get closed(): Promise<void>;
3897 get opened(): Promise<SocketInfo>;
3898 get upgraded(): boolean;
3899 get secureTransport(): "on" | "off" | "starttls";
3900 close(): Promise<void>;
3901 startTls(options?: TlsOptions): Socket;
3902}
3903export interface SocketOptions {
3904 secureTransport?: string;
3905 allowHalfOpen: boolean;
3906 highWaterMark?: number | bigint;
3907}
3908export interface SocketAddress {
3909 hostname: string;
3910 port: number;
3911}
3912export interface TlsOptions {
3913 expectedServerHostname?: string;
3914}
3915export interface SocketInfo {
3916 remoteAddress?: string;
3917 localAddress?: string;
3918}
3919/**
3920 * The **`EventSource`** interface is web content's interface to server-sent events.
3921 *
3922 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource)
3923 */
3924export declare class EventSource extends EventTarget {
3925 constructor(url: string, init?: EventSourceEventSourceInit);
3926 /**
3927 * The **`close()`** method of the EventSource interface closes the connection, if one is made, and sets the ```js-nolint close() ``` None.
3928 *
3929 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
3930 */
3931 close(): void;
3932 /**
3933 * The **`url`** read-only property of the URL of the source.
3934 *
3935 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
3936 */
3937 get url(): string;
3938 /**
3939 * The **`withCredentials`** read-only property of the the `EventSource` object was instantiated with CORS credentials set.
3940 *
3941 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
3942 */
3943 get withCredentials(): boolean;
3944 /**
3945 * The **`readyState`** read-only property of the connection.
3946 *
3947 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
3948 */
3949 get readyState(): number;
3950 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3951 get onopen(): any | null;
3952 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
3953 set onopen(value: any | null);
3954 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3955 get onmessage(): any | null;
3956 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
3957 set onmessage(value: any | null);
3958 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3959 get onerror(): any | null;
3960 /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
3961 set onerror(value: any | null);
3962 static readonly CONNECTING: number;
3963 static readonly OPEN: number;
3964 static readonly CLOSED: number;
3965 static from(stream: ReadableStream): EventSource;
3966}
3967export interface EventSourceEventSourceInit {
3968 withCredentials?: boolean;
3969 fetcher?: Fetcher;
3970}
3971export interface ExecOutput {
3972 readonly stdout: ArrayBuffer;
3973 readonly stderr: ArrayBuffer;
3974 readonly exitCode: number;
3975}
3976export interface ContainerExecOptions {
3977 cwd?: string;
3978 env?: Record<string, string>;
3979 user?: string;
3980 stdin?: ReadableStream | "pipe";
3981 stdout?: "pipe" | "ignore";
3982 stderr?: "pipe" | "ignore" | "combined";
3983}
3984export interface ExecProcess {
3985 readonly stdin: WritableStream | null;
3986 readonly stdout: ReadableStream | null;
3987 readonly stderr: ReadableStream | null;
3988 readonly pid: number;
3989 readonly exitCode: Promise<number>;
3990 output(): Promise<ExecOutput>;
3991 kill(signal?: number): void;
3992}
3993export interface Container {
3994 get running(): boolean;
3995 start(options?: ContainerStartupOptions): void;
3996 monitor(): Promise<void>;
3997 destroy(error?: any): Promise<void>;
3998 signal(signo: number): void;
3999 getTcpPort(port: number): Fetcher;
4000 setInactivityTimeout(durationMs: number | bigint): Promise<void>;
4001 interceptOutboundHttp(addr: string, binding: Fetcher): Promise<void>;
4002 interceptAllOutboundHttp(binding: Fetcher): Promise<void>;
4003 snapshotDirectory(
4004 options: ContainerDirectorySnapshotOptions,
4005 ): Promise<ContainerDirectorySnapshot>;
4006 snapshotContainer(
4007 options: ContainerSnapshotOptions,
4008 ): Promise<ContainerSnapshot>;
4009 interceptOutboundHttps(addr: string, binding: Fetcher): Promise<void>;
4010 exec(cmd: string[], options?: ContainerExecOptions): Promise<ExecProcess>;
4011 interceptOutboundTcp(addr: string, binding: Fetcher): Promise<void>;
4012 inspect(): Promise<ContainerInfo | null>;
4013}
4014export interface ContainerDirectorySnapshot {
4015 id: string;
4016 size: number;
4017 dir: string;
4018 name?: string;
4019}
4020export interface ContainerDirectorySnapshotOptions {
4021 dir: string;
4022 name?: string;
4023}
4024export interface ContainerDirectorySnapshotRestoreParams {
4025 snapshot: ContainerDirectorySnapshot;
4026 mountPoint?: string;
4027}
4028export interface ContainerSnapshot {
4029 id: string;
4030 size: number;
4031 name?: string;
4032}
4033export interface ContainerSnapshotOptions {
4034 name?: string;
4035}
4036export interface ContainerStartupOptions {
4037 entrypoint?: string[];
4038 enableInternet: boolean;
4039 env?: Record<string, string>;
4040 hardTimeout?: number | bigint;
4041 labels?: Record<string, string>;
4042 directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
4043 containerSnapshot?: ContainerSnapshot;
4044}
4045export interface ContainerInfo {
4046 labels: Record<string, string>;
4047}
4048/**
4049 * The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
4050 * Available only in secure contexts.
4051 *
4052 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle)
4053 */
4054export declare abstract class FileSystemHandle {
4055 /**
4056 * The **`kind`** read-only property of the `'file'` if the associated entry is a file or `'directory'`.
4057 *
4058 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/kind)
4059 */
4060 get kind(): string;
4061 /**
4062 * The **`name`** read-only property of the handle.
4063 *
4064 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/name)
4065 */
4066 get name(): string;
4067 /**
4068 * The **`isSameEntry()`** method of the ```js-nolint isSameEntry(fileSystemHandle) ``` - FileSystemHandle - : The `FileSystemHandle` to match against the handle on which the method is invoked.
4069 *
4070 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemHandle/isSameEntry)
4071 */
4072 isSameEntry(other: FileSystemHandle): Promise<boolean>;
4073 getUniqueId(): Promise<string>;
4074 remove(options?: FileSystemHandleRemoveOptions): Promise<void>;
4075}
4076/**
4077 * The **`FileSystemFileHandle`** interface of the File System API represents a handle to a file system entry.
4078 * Available only in secure contexts.
4079 *
4080 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle)
4081 */
4082export declare abstract class FileSystemFileHandle extends FileSystemHandle {
4083 /**
4084 * 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.
4085 *
4086 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/getFile)
4087 */
4088 getFile(): Promise<File>;
4089 /**
4090 * The **`createWritable()`** method of the FileSystemFileHandle interface creates a FileSystemWritableFileStream that can be used to write to a file.
4091 *
4092 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemFileHandle/createWritable)
4093 */
4094 createWritable(
4095 options?: FileSystemFileHandleFileSystemCreateWritableOptions,
4096 ): Promise<FileSystemWritableFileStream>;
4097}
4098/**
4099 * The **`FileSystemDirectoryHandle`** interface of the File System API provides a handle to a file system directory.
4100 * Available only in secure contexts.
4101 *
4102 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle)
4103 */
4104export declare abstract class FileSystemDirectoryHandle extends FileSystemHandle {
4105 /**
4106 * The **`getFileHandle()`** method of the directory the method is called.
4107 *
4108 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getFileHandle)
4109 */
4110 getFileHandle(
4111 name: string,
4112 options?: FileSystemDirectoryHandleFileSystemGetFileOptions,
4113 ): Promise<FileSystemFileHandle>;
4114 /**
4115 * The **`getDirectoryHandle()`** method of the within the directory handle on which the method is called.
4116 *
4117 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/getDirectoryHandle)
4118 */
4119 getDirectoryHandle(
4120 name: string,
4121 options?: FileSystemDirectoryHandleFileSystemGetDirectoryOptions,
4122 ): Promise<FileSystemDirectoryHandle>;
4123 /**
4124 * The **`removeEntry()`** method of the directory handle contains a file or directory called the name specified.
4125 *
4126 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/removeEntry)
4127 */
4128 removeEntry(
4129 name: string,
4130 options?: FileSystemDirectoryHandleFileSystemRemoveOptions,
4131 ): Promise<void>;
4132 /**
4133 * 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.
4134 *
4135 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemDirectoryHandle/resolve)
4136 */
4137 resolve(possibleDescendant: FileSystemHandle): Promise<string[]>;
4138 entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
4139 keys(): AsyncIterableIterator<string>;
4140 values(): AsyncIterableIterator<FileSystemHandle>;
4141 forEach(
4142 callback: (
4143 param0: string,
4144 param1: FileSystemHandle,
4145 param2: FileSystemDirectoryHandle,
4146 ) => void,
4147 thisArg?: any,
4148 ): void;
4149 [Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
4150}
4151/**
4152 * The **`FileSystemWritableFileStream`** interface of the File System API is a WritableStream object with additional convenience methods, which operates on a single file on disk.
4153 * Available only in secure contexts.
4154 *
4155 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream)
4156 */
4157export declare abstract class FileSystemWritableFileStream extends WritableStream {
4158 /**
4159 * The **`write()`** method of the FileSystemWritableFileStream interface writes content into the file the method is called on, at the current file cursor offset.
4160 *
4161 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/write)
4162 */
4163 write(
4164 data:
4165 | Blob
4166 | (ArrayBuffer | ArrayBufferView)
4167 | string
4168 | FileSystemFileWriteParams,
4169 ): Promise<void>;
4170 /**
4171 * The **`seek()`** method of the FileSystemWritableFileStream interface updates the current file cursor offset to the position (in bytes) specified when calling the method.
4172 *
4173 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/seek)
4174 */
4175 seek(position: number): Promise<void>;
4176 /**
4177 * The **`truncate()`** method of the FileSystemWritableFileStream interface resizes the file associated with the stream to the specified size in bytes.
4178 *
4179 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/FileSystemWritableFileStream/truncate)
4180 */
4181 truncate(size: number): Promise<void>;
4182}
4183/**
4184 * The **`StorageManager`** interface of the Storage API provides an interface for managing persistence permissions and estimating available storage.
4185 * Available only in secure contexts.
4186 *
4187 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/StorageManager)
4188 */
4189export declare abstract class StorageManager {
4190 /**
4191 * 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).
4192 *
4193 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/StorageManager/getDirectory)
4194 */
4195 getDirectory(): Promise<FileSystemDirectoryHandle>;
4196}
4197export interface FileSystemFileHandleFileSystemCreateWritableOptions {
4198 keepExistingData?: boolean;
4199}
4200export interface FileSystemDirectoryHandleFileSystemGetFileOptions {
4201 create: boolean;
4202}
4203export interface FileSystemDirectoryHandleFileSystemGetDirectoryOptions {
4204 create: boolean;
4205}
4206export interface FileSystemDirectoryHandleFileSystemRemoveOptions {
4207 recursive: boolean;
4208}
4209export interface FileSystemFileWriteParams {
4210 type: string;
4211 size?: number;
4212 position?: number;
4213 data?: (Blob | (ArrayBuffer | ArrayBufferView) | string) | null;
4214}
4215export interface FileSystemHandleRemoveOptions {
4216 recursive?: boolean;
4217}
4218/**
4219 * 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.
4220 *
4221 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort)
4222 */
4223export declare abstract class MessagePort extends EventTarget {
4224 /**
4225 * The **`postMessage()`** method of the transfers ownership of objects to other browsing contexts.
4226 *
4227 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/postMessage)
4228 */
4229 postMessage(
4230 data?: any,
4231 options?: any[] | MessagePortPostMessageOptions,
4232 ): void;
4233 /**
4234 * The **`close()`** method of the MessagePort interface disconnects the port, so it is no longer active.
4235 *
4236 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/close)
4237 */
4238 close(): void;
4239 /**
4240 * The **`start()`** method of the MessagePort interface starts the sending of messages queued on the port.
4241 *
4242 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessagePort/start)
4243 */
4244 start(): void;
4245 get onmessage(): any | null;
4246 set onmessage(value: any | null);
4247}
4248/**
4249 * 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.
4250 *
4251 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel)
4252 */
4253export declare class MessageChannel {
4254 constructor();
4255 /**
4256 * The **`port1`** read-only property of the the port attached to the context that originated the channel.
4257 *
4258 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port1)
4259 */
4260 readonly port1: MessagePort;
4261 /**
4262 * 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.
4263 *
4264 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MessageChannel/port2)
4265 */
4266 readonly port2: MessagePort;
4267}
4268export interface MessagePortPostMessageOptions {
4269 transfer?: any[];
4270}
4271export type LoopbackForExport<
4272 T extends
4273 | (new (...args: any[]) => Rpc.EntrypointBranded)
4274 | ExportedHandler<any, any, any>
4275 | undefined = undefined,
4276> = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
4277 ? LoopbackServiceStub<InstanceType<T>>
4278 : T extends new (...args: any[]) => Rpc.DurableObjectBranded
4279 ? LoopbackDurableObjectClass<InstanceType<T>>
4280 : T extends ExportedHandler<any, any, any>
4281 ? LoopbackServiceStub<undefined>
4282 : undefined;
4283export type LoopbackServiceStub<
4284 T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
4285> = Fetcher<T> &
4286 (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
4287 ? (opts: {
4288 props?: Props;
4289 version?: {
4290 cohort?: string | null;
4291 };
4292 }) => Fetcher<T>
4293 : (opts: {
4294 props?: any;
4295 version?: {
4296 cohort?: string | null;
4297 };
4298 }) => Fetcher<T>);
4299export type LoopbackDurableObjectClass<
4300 T extends Rpc.DurableObjectBranded | undefined = undefined,
4301> = DurableObjectClass<T> &
4302 (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
4303 ? (opts: { props?: Props }) => DurableObjectClass<T>
4304 : (opts: { props?: any }) => DurableObjectClass<T>);
4305export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
4306export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
4307export interface SyncKvStorage {
4308 get<T = unknown>(key: string): T | undefined;
4309 list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
4310 put<T>(key: string, value: T): void;
4311 delete(key: string): boolean;
4312}
4313export interface SyncKvListOptions {
4314 start?: string;
4315 startAfter?: string;
4316 end?: string;
4317 prefix?: string;
4318 reverse?: boolean;
4319 limit?: number;
4320}
4321export interface WorkerStub {
4322 getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
4323 name?: string,
4324 options?: WorkerStubEntrypointOptions,
4325 ): Fetcher<T>;
4326 getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
4327 name?: string,
4328 options?: WorkerStubEntrypointOptions,
4329 ): DurableObjectClass<T>;
4330}
4331export interface WorkerStubEntrypointOptions {
4332 props?: any;
4333 limits?: workerdResourceLimits;
4334}
4335export interface WorkerLoader {
4336 get(
4337 name: string | null,
4338 getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
4339 ): WorkerStub;
4340 load(code: WorkerLoaderWorkerCode): WorkerStub;
4341}
4342export interface WorkerLoaderModule {
4343 js?: string;
4344 cjs?: string;
4345 text?: string;
4346 data?: ArrayBuffer;
4347 json?: any;
4348 py?: string;
4349 wasm?: ArrayBuffer;
4350}
4351export interface WorkerLoaderWorkerCode {
4352 compatibilityDate: string;
4353 compatibilityFlags?: string[];
4354 allowExperimental?: boolean;
4355 limits?: workerdResourceLimits;
4356 mainModule: string;
4357 modules: Record<string, WorkerLoaderModule | string>;
4358 env?: any;
4359 globalOutbound?: Fetcher | null;
4360 tails?: Fetcher[];
4361 streamingTails?: Fetcher[];
4362}
4363export interface workerdResourceLimits {
4364 cpuMs?: number;
4365 subRequests?: number;
4366}
4367/**
4368 * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
4369 * as well as timing of subrequests and other operations.
4370 *
4371 * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
4372 */
4373export declare abstract class Performance extends EventTarget {
4374 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
4375 get timeOrigin(): number;
4376 /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
4377 now(): number;
4378 get eventCounts(): EventCounts;
4379 /**
4380 * The **`clearMarks()`** method removes all or specific PerformanceMark objects from the browser's performance timeline.
4381 *
4382 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks)
4383 */
4384 clearMarks(name?: string): void;
4385 /**
4386 * The **`clearMeasures()`** method removes all or specific PerformanceMeasure objects from the browser's performance timeline.
4387 *
4388 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures)
4389 */
4390 clearMeasures(name?: string): void;
4391 /**
4392 * 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.
4393 *
4394 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings)
4395 */
4396 clearResourceTimings(): void;
4397 /**
4398 * The **`getEntries()`** method returns an array of all PerformanceEntry objects currently present in the performance timeline.
4399 *
4400 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries)
4401 */
4402 getEntries(): PerformanceEntry[];
4403 /**
4404 * The **`getEntriesByName()`** method returns an array of PerformanceEntry objects currently present in the performance timeline with the given _name_ and _type_.
4405 *
4406 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName)
4407 */
4408 getEntriesByName(name: string, type?: string): PerformanceEntry[];
4409 /**
4410 * The **`getEntriesByType()`** method returns an array of PerformanceEntry objects currently present in the performance timeline for a given _type_.
4411 *
4412 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType)
4413 */
4414 getEntriesByType(type: string): PerformanceEntry[];
4415 /**
4416 * The **`mark()`** method creates a named PerformanceMark object representing a high resolution timestamp marker in the browser's performance timeline.
4417 *
4418 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark)
4419 */
4420 mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
4421 /**
4422 * The **`measure()`** method creates a named PerformanceMeasure object representing a time measurement between two marks in the browser's performance timeline.
4423 *
4424 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure)
4425 */
4426 measure(
4427 measureName: string,
4428 measureOptionsOrStartMark?: PerformanceMeasureOptions | string,
4429 maybeEndMark?: string,
4430 ): PerformanceMeasure;
4431 /**
4432 * The **`setResourceTimingBufferSize()`** method sets the desired size of the browser's resource timing buffer which stores the `'resource'` performance entries.
4433 *
4434 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize)
4435 */
4436 setResourceTimingBufferSize(size: number): void;
4437 /**
4438 * The **`toJSON()`** method of the Performance interface is a Serialization; it returns a JSON representation of the Performance object.
4439 *
4440 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/toJSON)
4441 */
4442 toJSON(): object;
4443 get nodeTiming(): PerformanceNodeTiming;
4444 eventLoopUtilization(): PerformanceEventLoopUtilization;
4445 markResourceTiming(): void;
4446 timerify(fn: () => void): () => void;
4447}
4448export interface PerformanceEventLoopUtilization {
4449 idle: number;
4450 active: number;
4451 utilization: number;
4452}
4453export interface PerformanceNodeTiming extends PerformanceEntry {
4454 readonly nodeStart: number;
4455 readonly v8Start: number;
4456 readonly bootstrapComplete: number;
4457 readonly environment: number;
4458 readonly loopStart: number;
4459 readonly loopExit: number;
4460 readonly idleTime: number;
4461 readonly uvMetricsInfo: UvMetricsInfo;
4462 toJSON(): object;
4463}
4464export interface UvMetricsInfo {
4465 loopCount: number;
4466 events: number;
4467 eventsWaiting: number;
4468}
4469/**
4470 * **`PerformanceMark`** is an interface for PerformanceEntry objects with an PerformanceEntry.entryType of `'mark'`.
4471 *
4472 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
4473 */
4474export declare class PerformanceMark extends PerformanceEntry {
4475 constructor(name: string, maybeOptions?: PerformanceMarkOptions);
4476 /**
4477 * 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).
4478 *
4479 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail)
4480 */
4481 get detail(): any;
4482 toJSON(): object;
4483}
4484/**
4485 * **`PerformanceMeasure`** is an _abstract_ interface for PerformanceEntry objects with an PerformanceEntry.entryType of `'measure'`.
4486 *
4487 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
4488 */
4489export declare abstract class PerformanceMeasure extends PerformanceEntry {
4490 /**
4491 * The read-only **`detail`** property returns arbitrary metadata that was included in the mark upon construction (when using Performance.measure.
4492 *
4493 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail)
4494 */
4495 get detail(): any;
4496 toJSON(): object;
4497}
4498export interface PerformanceMarkOptions {
4499 detail?: any;
4500 startTime?: number;
4501}
4502export interface PerformanceMeasureOptions {
4503 detail?: any;
4504 start?: number;
4505 duration?: number;
4506 end?: number;
4507}
4508/**
4509 * The **`PerformanceObserverEntryList`** interface is a list of PerformanceEntry that were explicitly observed via the PerformanceObserver.observe method.
4510 *
4511 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList)
4512 */
4513export declare abstract class PerformanceObserverEntryList {
4514 /**
4515 * The **`getEntries()`** method of the PerformanceObserverEntryList interface returns a list of explicitly observed PerformanceEntry objects.
4516 *
4517 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntries)
4518 */
4519 getEntries(): PerformanceEntry[];
4520 /**
4521 * The **`getEntriesByType()`** method of the PerformanceObserverEntryList returns a list of explicitly _observed_ PerformanceEntry objects for a given PerformanceEntry.entryType.
4522 *
4523 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntriesByType)
4524 */
4525 getEntriesByType(type: string): PerformanceEntry[];
4526 /**
4527 * The **`getEntriesByName()`** method of the PerformanceObserverEntryList interface returns a list of explicitly observed PerformanceEntry objects for a given PerformanceEntry.name and PerformanceEntry.entryType.
4528 *
4529 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserverEntryList/getEntriesByName)
4530 */
4531 getEntriesByName(name: string, type?: string): PerformanceEntry[];
4532}
4533/**
4534 * The **`PerformanceEntry`** object encapsulates a single performance metric that is part of the browser's performance timeline.
4535 *
4536 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
4537 */
4538export declare abstract class PerformanceEntry {
4539 /**
4540 * The read-only **`name`** property of the PerformanceEntry interface is a string representing the name for a performance entry.
4541 *
4542 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name)
4543 */
4544 get name(): string;
4545 /**
4546 * The read-only **`entryType`** property returns a string representing the type of performance metric that this entry represents.
4547 *
4548 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType)
4549 */
4550 get entryType(): string;
4551 /**
4552 * The read-only **`startTime`** property returns the first DOMHighResTimeStamp recorded for this PerformanceEntry.
4553 *
4554 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime)
4555 */
4556 get startTime(): number;
4557 /**
4558 * The read-only **`duration`** property returns a DOMHighResTimeStamp that is the duration of the PerformanceEntry.
4559 *
4560 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration)
4561 */
4562 get duration(): number;
4563 /**
4564 * The **`toJSON()`** method is a Serialization; it returns a JSON representation of the PerformanceEntry object.
4565 *
4566 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON)
4567 */
4568 toJSON(): object;
4569}
4570/**
4571 * The **`PerformanceResourceTiming`** interface enables retrieval and analysis of detailed network timing data regarding the loading of an application's resources.
4572 *
4573 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming)
4574 */
4575export declare abstract class PerformanceResourceTiming extends PerformanceEntry {
4576 /**
4577 * The **`connectEnd`** read-only property returns the DOMHighResTimeStamp immediately after the browser finishes establishing the connection to the server to retrieve the resource.
4578 *
4579 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/connectEnd)
4580 */
4581 get connectEnd(): number;
4582 /**
4583 * The **`connectStart`** read-only property returns the DOMHighResTimeStamp immediately before the user agent starts establishing the connection to the server to retrieve the resource.
4584 *
4585 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/connectStart)
4586 */
4587 get connectStart(): number;
4588 /**
4589 * 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).
4590 *
4591 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/decodedBodySize)
4592 */
4593 get decodedBodySize(): number;
4594 /**
4595 * The **`domainLookupEnd`** read-only property returns the DOMHighResTimeStamp immediately after the browser finishes the domain-name lookup for the resource.
4596 *
4597 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/domainLookupEnd)
4598 */
4599 get domainLookupEnd(): number;
4600 /**
4601 * The **`domainLookupStart`** read-only property returns the DOMHighResTimeStamp immediately before the browser starts the domain name lookup for the resource.
4602 *
4603 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/domainLookupStart)
4604 */
4605 get domainLookupStart(): number;
4606 /**
4607 * 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).
4608 *
4609 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/encodedBodySize)
4610 */
4611 get encodedBodySize(): number;
4612 /**
4613 * The **`fetchStart`** read-only property represents a DOMHighResTimeStamp immediately before the browser starts to fetch the resource.
4614 *
4615 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/fetchStart)
4616 */
4617 get fetchStart(): number;
4618 /**
4619 * The **`initiatorType`** read-only property is a string representing web platform feature that initiated the resource load.
4620 *
4621 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/initiatorType)
4622 */
4623 get initiatorType(): string;
4624 /**
4625 * 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).
4626 *
4627 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/nextHopProtocol)
4628 */
4629 get nextHopProtocol(): string;
4630 /**
4631 * The **`redirectEnd`** read-only property returns a DOMHighResTimeStamp immediately after receiving the last byte of the response of the last redirect.
4632 *
4633 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/redirectEnd)
4634 */
4635 get redirectEnd(): number;
4636 /**
4637 * The **`redirectStart`** read-only property returns a DOMHighResTimeStamp representing the start time of the fetch which that initiates the redirect.
4638 *
4639 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/redirectStart)
4640 */
4641 get redirectStart(): number;
4642 /**
4643 * 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.
4644 *
4645 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/requestStart)
4646 */
4647 get requestStart(): number;
4648 /**
4649 * 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.
4650 *
4651 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseEnd)
4652 */
4653 get responseEnd(): number;
4654 /**
4655 * 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.
4656 *
4657 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseStart)
4658 */
4659 get responseStart(): number;
4660 /**
4661 * The **`responseStatus`** read-only property represents the HTTP response status code returned when fetching the resource.
4662 *
4663 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/responseStatus)
4664 */
4665 get responseStatus(): number;
4666 /**
4667 * The **`secureConnectionStart`** read-only property returns a DOMHighResTimeStamp immediately before the browser starts the handshake process to secure the current connection.
4668 *
4669 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/secureConnectionStart)
4670 */
4671 get secureConnectionStart(): number | undefined;
4672 /**
4673 * The **`transferSize`** read-only property represents the size (in octets) of the fetched resource.
4674 *
4675 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/transferSize)
4676 */
4677 get transferSize(): number;
4678 /**
4679 * The **`workerStart`** read-only property of the PerformanceResourceTiming interface returns a The `workerStart` property can have the following values: - A DOMHighResTimeStamp.
4680 *
4681 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceResourceTiming/workerStart)
4682 */
4683 get workerStart(): number;
4684}
4685/**
4686 * 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_.
4687 *
4688 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver)
4689 */
4690export declare class PerformanceObserver {
4691 constructor(callback: any);
4692 /**
4693 * The **`disconnect()`** method of the PerformanceObserver interface is used to stop the performance observer from receiving any PerformanceEntry events.
4694 *
4695 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/disconnect)
4696 */
4697 disconnect(): void;
4698 /**
4699 * The **`observe()`** method of the **PerformanceObserver** interface is used to specify the set of performance entry types to observe.
4700 *
4701 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/observe)
4702 */
4703 observe(options?: PerformanceObserverObserveOptions): void;
4704 /**
4705 * The **`takeRecords()`** method of the PerformanceObserver interface returns the current list of PerformanceEntry objects stored in the performance observer, emptying it out.
4706 *
4707 * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceObserver/takeRecords)
4708 */
4709 takeRecords(): PerformanceEntry[];
4710 readonly supportedEntryTypes: string[];
4711}
4712export interface PerformanceObserverObserveOptions {
4713 buffered?: boolean;
4714 durationThreshold?: number;
4715 entryTypes?: string[];
4716 type?: string;
4717}
4718export interface EventCounts {
4719 get size(): number;
4720 get(eventType: string): number | undefined;
4721 has(eventType: string): boolean;
4722 entries(): IterableIterator<string[]>;
4723 keys(): IterableIterator<string>;
4724 values(): IterableIterator<number>;
4725 forEach(
4726 param1: (param0: number, param1: string, param2: EventCounts) => void,
4727 param2?: any,
4728 ): void;
4729 [Symbol.iterator](): IterableIterator<string[]>;
4730}
4731export interface Tracing {
4732 enterSpan<T, A extends unknown[]>(
4733 name: string,
4734 callback: (span: Span, ...args: A) => T,
4735 ...args: A
4736 ): T;
4737 Span: typeof Span;
4738}
4739export declare abstract class Span {
4740 get isTraced(): boolean;
4741 setAttribute(key: string, value?: boolean | number | string): void;
4742}
4743// ============ AI Search Error Interfaces ============
4744export interface AiSearchInternalError extends Error {}
4745export interface AiSearchNotFoundError extends Error {}
4746// ============ AI Search Common Types ============
4747/** A single message in a conversation-style search or chat request. */
4748export type AiSearchMessage = {
4749 role: "system" | "developer" | "user" | "assistant" | "tool";
4750 content: string | null;
4751};
4752/**
4753 * Common shape for `ai_search_options` used by both single-instance and multi-instance requests.
4754 * Contains retrieval, query rewrite, reranking, and cache sub-options.
4755 */
4756export type AiSearchOptions = {
4757 retrieval?: {
4758 /** Which retrieval backend to use. Defaults to the instance's configured index_method. */
4759 retrieval_type?: "vector" | "keyword" | "hybrid";
4760 /** Fusion method for combining vector + keyword results. */
4761 fusion_method?: "max" | "rrf";
4762 /** How keyword terms are combined: "and" = all terms must match, "or" = any term matches. */
4763 keyword_match_mode?: "and" | "or";
4764 /** Minimum similarity score (0-1) for a result to be included. Default 0.4. */
4765 match_threshold?: number;
4766 /** Maximum number of results to return (1-50). Default 10. */
4767 max_num_results?: number;
4768 /** Vectorize metadata filters applied to the search. */
4769 filters?: VectorizeVectorMetadataFilter;
4770 /** Number of surrounding chunks to include for context (0-3). Default 0. */
4771 context_expansion?: number;
4772 /** If true, return only item metadata without chunk text. */
4773 metadata_only?: boolean;
4774 /** If true (default), return empty results on retrieval failure instead of throwing. */
4775 return_on_failure?: boolean;
4776 /** Boost results by metadata field values. Max 3 entries. */
4777 boost_by?: Array<{
4778 field: string;
4779 direction?: "asc" | "desc" | "exists" | "not_exists";
4780 }>;
4781 [key: string]: unknown;
4782 };
4783 query_rewrite?: {
4784 enabled?: boolean;
4785 model?: string;
4786 rewrite_prompt?: string;
4787 [key: string]: unknown;
4788 };
4789 reranking?: {
4790 enabled?: boolean;
4791 model?: string;
4792 /** Match threshold (0-1, default 0.4) */
4793 match_threshold?: number;
4794 [key: string]: unknown;
4795 };
4796 cache?: {
4797 enabled?: boolean;
4798 cache_threshold?:
4799 | "super_strict_match"
4800 | "close_enough"
4801 | "flexible_friend"
4802 | "anything_goes";
4803 };
4804 [key: string]: unknown;
4805};
4806// ============ AI Search Request Types ============
4807/**
4808 * Request body for single-instance search.
4809 * Exactly one of `query` or `messages` must be provided.
4810 */
4811export type AiSearchSearchRequest =
4812 | {
4813 /** Simple query string. */
4814 query: string;
4815 messages?: never;
4816 ai_search_options?: AiSearchOptions;
4817 }
4818 | {
4819 query?: never;
4820 /** Conversation-style input. At least one user message with non-empty content is required. */
4821 messages: AiSearchMessage[];
4822 ai_search_options?: AiSearchOptions;
4823 };
4824export type AiSearchChatCompletionsRequest = {
4825 messages: AiSearchMessage[];
4826 model?: string;
4827 stream?: boolean;
4828 ai_search_options?: AiSearchOptions;
4829 [key: string]: unknown;
4830};
4831// ============ AI Search Multi-Instance Types (Namespace-Scoped) ============
4832/** `ai_search_options` shape for multi-instance requests โ€” requires `instance_ids`. */
4833export type AiSearchMultiSearchOptions = AiSearchOptions & {
4834 /** Instance IDs to search across (1-10). */
4835 instance_ids: string[];
4836};
4837/**
4838 * Request for searching across multiple instances within a namespace.
4839 * `ai_search_options` is required and must include `instance_ids`.
4840 * Exactly one of `query` or `messages` must be provided.
4841 */
4842export type AiSearchMultiSearchRequest =
4843 | {
4844 /** Simple query string. */
4845 query: string;
4846 messages?: never;
4847 ai_search_options: AiSearchMultiSearchOptions;
4848 }
4849 | {
4850 query?: never;
4851 /** Conversation-style input. */
4852 messages: AiSearchMessage[];
4853 ai_search_options: AiSearchMultiSearchOptions;
4854 };
4855/** A search result chunk tagged with the instance it originated from. */
4856export type AiSearchMultiSearchChunk =
4857 AiSearchSearchResponse["chunks"][number] & {
4858 instance_id: string;
4859 };
4860/** Describes a per-instance error during a multi-instance operation. */
4861export type AiSearchMultiSearchError = {
4862 instance_id: string;
4863 message: string;
4864};
4865/** Response from a multi-instance search, with chunks tagged by instance and optional partial-failure errors. */
4866export type AiSearchMultiSearchResponse = {
4867 search_query: string;
4868 chunks: AiSearchMultiSearchChunk[];
4869 errors?: AiSearchMultiSearchError[];
4870};
4871/** Request for chat completions across multiple instances within a namespace. `ai_search_options` is required and must include `instance_ids`. */
4872export type AiSearchMultiChatCompletionsRequest = Omit<
4873 AiSearchChatCompletionsRequest,
4874 "ai_search_options"
4875> & {
4876 ai_search_options: AiSearchMultiSearchOptions;
4877};
4878/** Response from multi-instance chat completions, with chunks tagged by instance and optional partial-failure errors. */
4879export type AiSearchMultiChatCompletionsResponse = Omit<
4880 AiSearchChatCompletionsResponse,
4881 "chunks"
4882> & {
4883 chunks: AiSearchMultiSearchChunk[];
4884 errors?: AiSearchMultiSearchError[];
4885};
4886// ============ AI Search Response Types ============
4887export type AiSearchSearchResponse = {
4888 search_query: string;
4889 chunks: Array<{
4890 id: string;
4891 type: string;
4892 /** Match score (0-1) */
4893 score: number;
4894 text: string;
4895 item: {
4896 timestamp?: number;
4897 key: string;
4898 metadata?: Record<string, unknown>;
4899 };
4900 scoring_details?: {
4901 /** Keyword match score (0-1) */
4902 keyword_score?: number;
4903 /** Vector similarity score (0-1) */
4904 vector_score?: number;
4905 /** Keyword rank position */
4906 keyword_rank?: number;
4907 /** Vector rank position */
4908 vector_rank?: number;
4909 /** Reranking model score */
4910 reranking_score?: number;
4911 /** Fusion method used to combine results */
4912 fusion_method?: "rrf" | "max";
4913 [key: string]: unknown;
4914 };
4915 }>;
4916};
4917export type AiSearchChatCompletionsResponse = {
4918 id?: string;
4919 object?: string;
4920 model?: string;
4921 choices: Array<{
4922 index?: number;
4923 message: {
4924 role: "system" | "developer" | "user" | "assistant" | "tool";
4925 content: string | null;
4926 [key: string]: unknown;
4927 };
4928 [key: string]: unknown;
4929 }>;
4930 chunks: AiSearchSearchResponse["chunks"];
4931 [key: string]: unknown;
4932};
4933export type AiSearchStatsResponse = {
4934 queued?: number;
4935 running?: number;
4936 completed?: number;
4937 error?: number;
4938 skipped?: number;
4939 outdated?: number;
4940 last_activity?: string;
4941 /** Storage engine statistics. */
4942 engine?: {
4943 vectorize?: {
4944 vectorsCount: number;
4945 dimensions: number;
4946 };
4947 r2?: {
4948 payloadSizeBytes: number;
4949 metadataSizeBytes: number;
4950 objectCount: number;
4951 };
4952 };
4953};
4954// ============ AI Search Instance Info Types ============
4955export type AiSearchInstanceInfo = {
4956 id: string;
4957 type?: "r2" | "web-crawler" | string;
4958 source?: string;
4959 source_params?: unknown;
4960 paused?: boolean;
4961 status?: string;
4962 namespace?: string;
4963 created_at?: string;
4964 modified_at?: string;
4965 token_id?: string;
4966 ai_gateway_id?: string;
4967 rewrite_query?: boolean;
4968 reranking?: boolean;
4969 embedding_model?: string;
4970 ai_search_model?: string;
4971 rewrite_model?: string;
4972 reranking_model?: string;
4973 /** @deprecated Use index_method instead. */
4974 hybrid_search_enabled?: boolean;
4975 /** Controls which storage backends are active. */
4976 index_method?: {
4977 vector?: boolean;
4978 keyword?: boolean;
4979 };
4980 /** Fusion method for combining vector and keyword results. */
4981 fusion_method?: "max" | "rrf";
4982 indexing_options?: {
4983 keyword_tokenizer?: "porter" | "trigram";
4984 } | null;
4985 retrieval_options?: {
4986 keyword_match_mode?: "and" | "or";
4987 boost_by?: Array<{
4988 field: string;
4989 direction?: "asc" | "desc" | "exists" | "not_exists";
4990 }>;
4991 } | null;
4992 chunk?: boolean;
4993 chunk_size?: number;
4994 chunk_overlap?: number;
4995 score_threshold?: number;
4996 max_num_results?: number;
4997 cache?: boolean;
4998 cache_threshold?:
4999 | "super_strict_match"
5000 | "close_enough"
5001 | "flexible_friend"
5002 | "anything_goes";
5003 custom_metadata?: Array<{
5004 field_name: string;
5005 data_type: "text" | "number" | "boolean" | "datetime";
5006 }>;
5007 /** Sync interval in seconds. */
5008 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5009 metadata?: Record<string, unknown>;
5010 [key: string]: unknown;
5011};
5012/** Pagination, search, and ordering parameters for listing instances within a namespace. */
5013export type AiSearchListInstancesParams = {
5014 page?: number;
5015 per_page?: number;
5016 /** Search instances by ID. */
5017 search?: string;
5018 /** Field to sort by. */
5019 order_by?: "created_at";
5020 /** Sort direction. */
5021 order_by_direction?: "asc" | "desc";
5022};
5023export type AiSearchListResponse = {
5024 result: AiSearchInstanceInfo[];
5025 result_info?: {
5026 count: number;
5027 page: number;
5028 per_page: number;
5029 total_count: number;
5030 };
5031};
5032// ============ AI Search Config Types ============
5033export type AiSearchConfig = {
5034 /** Instance ID (1-32 chars, pattern: ^[a-z0-9_]+(?:-[a-z0-9_]+)*$) */
5035 id: string;
5036 /** Instance type. Omit to create with built-in storage. */
5037 type?: "r2" | "web-crawler" | string;
5038 /** Source URL (required for web-crawler type). */
5039 source?: string;
5040 source_params?: unknown;
5041 /** Token ID (UUID format) */
5042 token_id?: string;
5043 ai_gateway_id?: string;
5044 /** Enable query rewriting (default false) */
5045 rewrite_query?: boolean;
5046 /** Enable reranking (default false) */
5047 reranking?: boolean;
5048 embedding_model?: string;
5049 ai_search_model?: string;
5050 rewrite_model?: string;
5051 reranking_model?: string;
5052 /** @deprecated Use index_method instead. */
5053 hybrid_search_enabled?: boolean;
5054 /** Controls which storage backends are used during indexing. Defaults to vector-only. */
5055 index_method?: {
5056 vector?: boolean;
5057 keyword?: boolean;
5058 };
5059 /** Fusion method for combining vector and keyword results. "rrf" = reciprocal rank fusion (default), "max" = maximum score. */
5060 fusion_method?: "max" | "rrf";
5061 indexing_options?: {
5062 keyword_tokenizer?: "porter" | "trigram";
5063 } | null;
5064 retrieval_options?: {
5065 keyword_match_mode?: "and" | "or";
5066 boost_by?: Array<{
5067 field: string;
5068 direction?: "asc" | "desc" | "exists" | "not_exists";
5069 }>;
5070 } | null;
5071 chunk?: boolean;
5072 chunk_size?: number;
5073 chunk_overlap?: number;
5074 /** Minimum similarity score (0-1) for a result to be included. */
5075 score_threshold?: number;
5076 max_num_results?: number;
5077 cache?: boolean;
5078 /** Similarity threshold for cache hits. Stricter = fewer cache hits but higher relevance. */
5079 cache_threshold?:
5080 | "super_strict_match"
5081 | "close_enough"
5082 | "flexible_friend"
5083 | "anything_goes";
5084 custom_metadata?: Array<{
5085 field_name: string;
5086 data_type: "text" | "number" | "boolean" | "datetime";
5087 }>;
5088 namespace?: string;
5089 /** Sync interval in seconds. 3600=1h, 7200=2h, 14400=4h, 21600=6h, 43200=12h, 86400=24h. */
5090 sync_interval?: 3600 | 7200 | 14400 | 21600 | 43200 | 86400;
5091 metadata?: Record<string, unknown>;
5092 [key: string]: unknown;
5093};
5094// ============ AI Search Item Types ============
5095export type AiSearchItemInfo = {
5096 id: string;
5097 key: string;
5098 status: "completed" | "error" | "skipped" | "queued" | "running" | "outdated";
5099 next_action?: "INDEX" | "DELETE" | null;
5100 error?: string;
5101 checksum?: string;
5102 namespace?: string;
5103 chunks_count?: number | null;
5104 file_size?: number | null;
5105 source_id?: string | null;
5106 last_seen_at?: string;
5107 created_at?: string;
5108 metadata?: Record<string, unknown>;
5109 [key: string]: unknown;
5110};
5111export type AiSearchItemContentResult = {
5112 body: ReadableStream;
5113 contentType: string;
5114 filename: string;
5115 size: number;
5116};
5117export type AiSearchUploadItemOptions = {
5118 metadata?: Record<string, unknown>;
5119};
5120export type AiSearchListItemsParams = {
5121 page?: number;
5122 per_page?: number;
5123 /** Search items by key name. */
5124 search?: string;
5125 /** Sort order for results. */
5126 sort_by?: "status" | "modified_at";
5127 /** Filter items by processing status. */
5128 status?:
5129 | "queued"
5130 | "running"
5131 | "completed"
5132 | "error"
5133 | "skipped"
5134 | "outdated";
5135 /** Filter items by source (e.g. "builtin" or "web-crawler:https://example.com"). */
5136 source?: string;
5137 /** JSON-encoded Vectorize filter for metadata filtering. */
5138 metadata_filter?: string;
5139};
5140export type AiSearchListItemsResponse = {
5141 result: AiSearchItemInfo[];
5142 result_info?: {
5143 count: number;
5144 page: number;
5145 per_page: number;
5146 total_count: number;
5147 };
5148};
5149// ============ AI Search Item Logs Types ============
5150export type AiSearchItemLogsParams = {
5151 /** Maximum number of log entries to return (1-100, default 50). */
5152 limit?: number;
5153 /** Opaque cursor for pagination. Pass the `cursor` value from a previous response. */
5154 cursor?: string;
5155};
5156export type AiSearchItemLog = {
5157 timestamp: string;
5158 action: string;
5159 message: string;
5160 fileKey?: string;
5161 chunkCount?: number;
5162 processingTimeMs?: number;
5163 errorType?: string;
5164};
5165/** Paginated response for item processing logs (cursor-based). */
5166export type AiSearchItemLogsResponse = {
5167 result: AiSearchItemLog[];
5168 result_info: {
5169 count: number;
5170 per_page: number;
5171 cursor: string | null;
5172 truncated: boolean;
5173 };
5174};
5175// ============ AI Search Item Chunks Types ============
5176export type AiSearchItemChunksParams = {
5177 /** Maximum number of chunks to return (1-100, default 20). */
5178 limit?: number;
5179 /** Offset into the chunks list (default 0). */
5180 offset?: number;
5181};
5182/** A single indexed chunk belonging to an item, including its text content and byte range. */
5183export type AiSearchItemChunk = {
5184 id: string;
5185 text: string;
5186 start_byte: number;
5187 end_byte: number;
5188 item?: {
5189 timestamp?: number;
5190 key: string;
5191 metadata?: Record<string, unknown>;
5192 };
5193};
5194/** Paginated response for item chunks (offset-based). */
5195export type AiSearchItemChunksResponse = {
5196 result: AiSearchItemChunk[];
5197 result_info: {
5198 count: number;
5199 total: number;
5200 limit: number;
5201 offset: number;
5202 };
5203};
5204// ============ AI Search Job Types ============
5205export type AiSearchJobInfo = {
5206 id: string;
5207 source: "user" | "schedule";
5208 description?: string;
5209 last_seen_at?: string;
5210 started_at?: string;
5211 ended_at?: string;
5212 end_reason?: string;
5213};
5214export type AiSearchJobLog = {
5215 id: number;
5216 message: string;
5217 message_type: number;
5218 created_at: number;
5219};
5220export type AiSearchCreateJobParams = {
5221 description?: string;
5222};
5223export type AiSearchListJobsParams = {
5224 page?: number;
5225 per_page?: number;
5226};
5227export type AiSearchListJobsResponse = {
5228 result: AiSearchJobInfo[];
5229 result_info?: {
5230 count: number;
5231 page: number;
5232 per_page: number;
5233 total_count: number;
5234 };
5235};
5236export type AiSearchJobLogsParams = {
5237 page?: number;
5238 per_page?: number;
5239};
5240export type AiSearchJobLogsResponse = {
5241 result: AiSearchJobLog[];
5242 result_info?: {
5243 count: number;
5244 page: number;
5245 per_page: number;
5246 total_count: number;
5247 };
5248};
5249// ============ AI Search Sub-Service Classes ============
5250/**
5251 * Single item service for an AI Search instance.
5252 * Provides info, download, sync, logs, and chunks operations on a specific item.
5253 */
5254export declare abstract class AiSearchItem {
5255 /** Get metadata about this item. */
5256 info(): Promise<AiSearchItemInfo>;
5257 /**
5258 * Download the item's content.
5259 * @returns Object with body stream, content type, filename, and size.
5260 */
5261 download(): Promise<AiSearchItemContentResult>;
5262 /**
5263 * Trigger re-indexing of this item.
5264 * @returns The updated item info.
5265 */
5266 sync(): Promise<AiSearchItemInfo>;
5267 /**
5268 * Retrieve processing logs for this item (cursor-based pagination).
5269 * @param params Optional pagination parameters (limit, cursor).
5270 * @returns Paginated log entries for this item.
5271 */
5272 logs(params?: AiSearchItemLogsParams): Promise<AiSearchItemLogsResponse>;
5273 /**
5274 * List indexed chunks for this item (offset-based pagination).
5275 * @param params Optional pagination parameters (limit, offset).
5276 * @returns Paginated chunk entries for this item.
5277 */
5278 chunks(
5279 params?: AiSearchItemChunksParams,
5280 ): Promise<AiSearchItemChunksResponse>;
5281}
5282/**
5283 * Items collection service for an AI Search instance.
5284 * Provides list, upload, and access to individual items.
5285 */
5286export declare abstract class AiSearchItems {
5287 /** List items in this instance. */
5288 list(params?: AiSearchListItemsParams): Promise<AiSearchListItemsResponse>;
5289 /**
5290 * Upload a file as an item. Behaves as an upsert: if an item with the same
5291 * filename already exists, it is overwritten and re-indexed.
5292 * @param name Filename for the uploaded item.
5293 * @param content File content as a ReadableStream, Blob, or string.
5294 * @param options Optional metadata to attach to the item.
5295 * @returns The created item info.
5296 */
5297 upload(
5298 name: string,
5299 content: ReadableStream | Blob | string,
5300 options?: AiSearchUploadItemOptions,
5301 ): Promise<AiSearchItemInfo>;
5302 /**
5303 * Upload a file and poll until processing completes.
5304 * Behaves as an upsert: if an item with the same filename already exists,
5305 * it is overwritten and re-indexed.
5306 * @param name Filename for the uploaded item.
5307 * @param content File content as a ReadableStream, Blob, or string.
5308 * @param options Optional metadata and polling configuration.
5309 * @returns The item info after processing completes (or timeout).
5310 */
5311 uploadAndPoll(
5312 name: string,
5313 content: ReadableStream | Blob | string,
5314 options?: AiSearchUploadItemOptions & {
5315 /** Polling interval in milliseconds (default 1000). */
5316 pollIntervalMs?: number;
5317 /** Maximum time to wait in milliseconds (default 30000). */
5318 timeoutMs?: number;
5319 },
5320 ): Promise<AiSearchItemInfo>;
5321 /**
5322 * Get an item by ID.
5323 * @param itemId The item identifier.
5324 * @returns Item service for info, download, sync, logs, and chunks operations.
5325 */
5326 get(itemId: string): AiSearchItem;
5327 /**
5328 * Delete an item from the instance.
5329 * @param itemId The item identifier.
5330 */
5331 delete(itemId: string): Promise<void>;
5332}
5333/**
5334 * Single job service for an AI Search instance.
5335 * Provides info, logs, and cancel operations for a specific job.
5336 */
5337export declare abstract class AiSearchJob {
5338 /** Get metadata about this job. */
5339 info(): Promise<AiSearchJobInfo>;
5340 /** Get logs for this job. */
5341 logs(params?: AiSearchJobLogsParams): Promise<AiSearchJobLogsResponse>;
5342 /**
5343 * Cancel a running job.
5344 * @returns The updated job info.
5345 * @throws AiSearchNotFoundError if the job does not exist.
5346 */
5347 cancel(): Promise<AiSearchJobInfo>;
5348}
5349/**
5350 * Jobs collection service for an AI Search instance.
5351 * Provides list, create, and access to individual jobs.
5352 */
5353export declare abstract class AiSearchJobs {
5354 /** List jobs for this instance. */
5355 list(params?: AiSearchListJobsParams): Promise<AiSearchListJobsResponse>;
5356 /**
5357 * Create a new indexing job.
5358 * @param params Optional job parameters.
5359 * @returns The created job info.
5360 */
5361 create(params?: AiSearchCreateJobParams): Promise<AiSearchJobInfo>;
5362 /**
5363 * Get a job by ID.
5364 * @param jobId The job identifier.
5365 * @returns Job service for info, logs, and cancel operations.
5366 */
5367 get(jobId: string): AiSearchJob;
5368}
5369// ============ AI Search Binding Classes ============
5370/**
5371 * Instance-level AI Search service.
5372 *
5373 * Used as:
5374 * - The return type of `AiSearchNamespace.get(name)` (namespace binding)
5375 * - The type of `env.BLOG_SEARCH` (single instance binding via `ai_search`)
5376 *
5377 * Provides search, chat, update, stats, items, and jobs operations.
5378 *
5379 * @example
5380 * ```ts
5381 * // Via namespace binding
5382 * const instance = env.AI_SEARCH.get("blog");
5383 * const results = await instance.search({
5384 * query: "How does caching work?",
5385 * });
5386 *
5387 * // Via single instance binding
5388 * const results = await env.BLOG_SEARCH.search({
5389 * messages: [{ role: "user", content: "How does caching work?" }],
5390 * });
5391 * ```
5392 */
5393export declare abstract class AiSearchInstance {
5394 /**
5395 * Search the AI Search instance for relevant chunks.
5396 * @param params Search request with query or messages and optional AI search options.
5397 * @returns Search response with matching chunks and search query.
5398 */
5399 search(params: AiSearchSearchRequest): Promise<AiSearchSearchResponse>;
5400 /**
5401 * Generate chat completions with AI Search context (streaming).
5402 * @param params Chat completions request with stream: true.
5403 * @returns ReadableStream of server-sent events.
5404 */
5405 chatCompletions(
5406 params: AiSearchChatCompletionsRequest & {
5407 stream: true;
5408 },
5409 ): Promise<ReadableStream>;
5410 /**
5411 * Generate chat completions with AI Search context.
5412 * @param params Chat completions request.
5413 * @returns Chat completion response with choices and RAG chunks.
5414 */
5415 chatCompletions(
5416 params: AiSearchChatCompletionsRequest,
5417 ): Promise<AiSearchChatCompletionsResponse>;
5418 /**
5419 * Update the instance configuration.
5420 * @param config Partial configuration to update.
5421 * @returns Updated instance info.
5422 */
5423 update(config: Partial<AiSearchConfig>): Promise<AiSearchInstanceInfo>;
5424 /** Get metadata about this instance. */
5425 info(): Promise<AiSearchInstanceInfo>;
5426 /**
5427 * Get instance statistics (item count, indexing status, etc.).
5428 * @returns Statistics with counts per status, last activity time, and engine details.
5429 */
5430 stats(): Promise<AiSearchStatsResponse>;
5431 /** Items collection โ€” list, upload, and manage items in this instance. */
5432 get items(): AiSearchItems;
5433 /** Jobs collection โ€” list, create, and inspect indexing jobs. */
5434 get jobs(): AiSearchJobs;
5435}
5436/**
5437 * Namespace-level AI Search service.
5438 *
5439 * Used as the type of `env.AI_SEARCH` (namespace binding via `ai_search_namespaces`).
5440 * Scoped to a single namespace. Provides dynamic instance access, creation, deletion,
5441 * and multi-instance search/chat operations.
5442 *
5443 * @example
5444 * ```ts
5445 * // Access an instance within the namespace
5446 * const blog = env.AI_SEARCH.get("blog");
5447 * const results = await blog.search({ query: "How does caching work?" });
5448 *
5449 * // List all instances in the namespace
5450 * const instances = await env.AI_SEARCH.list();
5451 *
5452 * // Create a new instance with built-in storage
5453 * const tenant = await env.AI_SEARCH.create({ id: "tenant-123" });
5454 *
5455 * // Upload items into the instance
5456 * await tenant.items.upload("doc.pdf", fileContent);
5457 *
5458 * // Search across multiple instances
5459 * const multi = await env.AI_SEARCH.search({
5460 * query: "caching",
5461 * ai_search_options: { instance_ids: ["blog", "docs"] },
5462 * });
5463 *
5464 * // Delete an instance
5465 * await env.AI_SEARCH.delete("tenant-123");
5466 * ```
5467 */
5468export declare abstract class AiSearchNamespace {
5469 /**
5470 * Get an instance by name within the bound namespace.
5471 * @param name Instance name.
5472 * @returns Instance service for search, chat, update, stats, items, and jobs.
5473 */
5474 get(name: string): AiSearchInstance;
5475 /**
5476 * List instances in the bound namespace.
5477 * @param params Optional pagination, search, and ordering parameters.
5478 * @returns Array of instance metadata with pagination info.
5479 */
5480 list(params?: AiSearchListInstancesParams): Promise<AiSearchListResponse>;
5481 /**
5482 * Create a new instance within the bound namespace.
5483 * @param config Instance configuration. Only `id` is required โ€” omit `type` and `source` to create with built-in storage.
5484 * @returns Instance service for the newly created instance.
5485 *
5486 * @example
5487 * ```ts
5488 * // Create with built-in storage (upload items manually)
5489 * const instance = await env.AI_SEARCH.create({ id: "my-search" });
5490 *
5491 * // Create with web crawler source
5492 * const instance = await env.AI_SEARCH.create({
5493 * id: "docs-search",
5494 * type: "web-crawler",
5495 * source: "https://developers.cloudflare.com",
5496 * });
5497 * ```
5498 */
5499 create(config: AiSearchConfig): Promise<AiSearchInstance>;
5500 /**
5501 * Delete an instance from the bound namespace.
5502 * @param name Instance name to delete.
5503 */
5504 delete(name: string): Promise<void>;
5505 /**
5506 * Search across multiple instances within the bound namespace.
5507 * Fans out to the specified instance_ids and merges results.
5508 * @param params Search request with required `ai_search_options.instance_ids`.
5509 * @returns Search response with chunks tagged by instance_id and optional partial-failure errors.
5510 */
5511 search(
5512 params: AiSearchMultiSearchRequest,
5513 ): Promise<AiSearchMultiSearchResponse>;
5514 /**
5515 * Generate chat completions across multiple instances within the bound namespace (streaming).
5516 * Fans out to the specified instance_ids, merges context, and generates a response.
5517 * @param params Chat completions request with stream: true and required `ai_search_options.instance_ids`.
5518 * @returns ReadableStream of server-sent events.
5519 */
5520 chatCompletions(
5521 params: AiSearchMultiChatCompletionsRequest & {
5522 stream: true;
5523 },
5524 ): Promise<ReadableStream>;
5525 /**
5526 * Generate chat completions across multiple instances within the bound namespace.
5527 * Fans out to the specified instance_ids, merges context, and generates a response.
5528 * @param params Chat completions request with required `ai_search_options.instance_ids`.
5529 * @returns Chat completion response with choices, chunks tagged by instance_id, and optional partial-failure errors.
5530 */
5531 chatCompletions(
5532 params: AiSearchMultiChatCompletionsRequest,
5533 ): Promise<AiSearchMultiChatCompletionsResponse>;
5534}
5535export type AiImageClassificationInput = {
5536 image: number[];
5537};
5538export type AiImageClassificationOutput = {
5539 score?: number;
5540 label?: string;
5541}[];
5542export declare abstract class BaseAiImageClassification {
5543 inputs: AiImageClassificationInput;
5544 postProcessedOutputs: AiImageClassificationOutput;
5545}
5546export type AiImageToTextInput = {
5547 image: number[];
5548 prompt?: string;
5549 max_tokens?: number;
5550 temperature?: number;
5551 top_p?: number;
5552 top_k?: number;
5553 seed?: number;
5554 repetition_penalty?: number;
5555 frequency_penalty?: number;
5556 presence_penalty?: number;
5557 raw?: boolean;
5558 messages?: RoleScopedChatInput[];
5559};
5560export type AiImageToTextOutput = {
5561 description: string;
5562};
5563export declare abstract class BaseAiImageToText {
5564 inputs: AiImageToTextInput;
5565 postProcessedOutputs: AiImageToTextOutput;
5566}
5567export type AiImageTextToTextInput = {
5568 image: string;
5569 prompt?: string;
5570 max_tokens?: number;
5571 temperature?: number;
5572 ignore_eos?: boolean;
5573 top_p?: number;
5574 top_k?: number;
5575 seed?: number;
5576 repetition_penalty?: number;
5577 frequency_penalty?: number;
5578 presence_penalty?: number;
5579 raw?: boolean;
5580 messages?: RoleScopedChatInput[];
5581};
5582export type AiImageTextToTextOutput = {
5583 description: string;
5584};
5585export declare abstract class BaseAiImageTextToText {
5586 inputs: AiImageTextToTextInput;
5587 postProcessedOutputs: AiImageTextToTextOutput;
5588}
5589export type AiMultimodalEmbeddingsInput = {
5590 image: string;
5591 text: string[];
5592};
5593export type AiIMultimodalEmbeddingsOutput = {
5594 data: number[][];
5595 shape: number[];
5596};
5597export declare abstract class BaseAiMultimodalEmbeddings {
5598 inputs: AiImageTextToTextInput;
5599 postProcessedOutputs: AiImageTextToTextOutput;
5600}
5601export type AiObjectDetectionInput = {
5602 image: number[];
5603};
5604export type AiObjectDetectionOutput = {
5605 score?: number;
5606 label?: string;
5607}[];
5608export declare abstract class BaseAiObjectDetection {
5609 inputs: AiObjectDetectionInput;
5610 postProcessedOutputs: AiObjectDetectionOutput;
5611}
5612export type AiSentenceSimilarityInput = {
5613 source: string;
5614 sentences: string[];
5615};
5616export type AiSentenceSimilarityOutput = number[];
5617export declare abstract class BaseAiSentenceSimilarity {
5618 inputs: AiSentenceSimilarityInput;
5619 postProcessedOutputs: AiSentenceSimilarityOutput;
5620}
5621export type AiAutomaticSpeechRecognitionInput = {
5622 audio: number[];
5623};
5624export type AiAutomaticSpeechRecognitionOutput = {
5625 text?: string;
5626 words?: {
5627 word: string;
5628 start: number;
5629 end: number;
5630 }[];
5631 vtt?: string;
5632};
5633export declare abstract class BaseAiAutomaticSpeechRecognition {
5634 inputs: AiAutomaticSpeechRecognitionInput;
5635 postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
5636}
5637export type AiSummarizationInput = {
5638 input_text: string;
5639 max_length?: number;
5640};
5641export type AiSummarizationOutput = {
5642 summary: string;
5643};
5644export declare abstract class BaseAiSummarization {
5645 inputs: AiSummarizationInput;
5646 postProcessedOutputs: AiSummarizationOutput;
5647}
5648export type AiTextClassificationInput = {
5649 text: string;
5650};
5651export type AiTextClassificationOutput = {
5652 score?: number;
5653 label?: string;
5654}[];
5655export declare abstract class BaseAiTextClassification {
5656 inputs: AiTextClassificationInput;
5657 postProcessedOutputs: AiTextClassificationOutput;
5658}
5659export type AiTextEmbeddingsInput = {
5660 text: string | string[];
5661};
5662export type AiTextEmbeddingsOutput = {
5663 shape: number[];
5664 data: number[][];
5665};
5666export declare abstract class BaseAiTextEmbeddings {
5667 inputs: AiTextEmbeddingsInput;
5668 postProcessedOutputs: AiTextEmbeddingsOutput;
5669}
5670export type RoleScopedChatInput = {
5671 role:
5672 | "user"
5673 | "assistant"
5674 | "system"
5675 | "tool"
5676 | (string & NonNullable<unknown>);
5677 content: string;
5678 name?: string;
5679};
5680export type AiTextGenerationToolLegacyInput = {
5681 name: string;
5682 description: string;
5683 parameters?: {
5684 type: "object" | (string & NonNullable<unknown>);
5685 properties: {
5686 [key: string]: {
5687 type: string;
5688 description?: string;
5689 };
5690 };
5691 required: string[];
5692 };
5693};
5694export type AiTextGenerationToolInput = {
5695 type: "function" | (string & NonNullable<unknown>);
5696 function: {
5697 name: string;
5698 description: string;
5699 parameters?: {
5700 type: "object" | (string & NonNullable<unknown>);
5701 properties: {
5702 [key: string]: {
5703 type: string;
5704 description?: string;
5705 };
5706 };
5707 required: string[];
5708 };
5709 };
5710};
5711export type AiTextGenerationFunctionsInput = {
5712 name: string;
5713 code: string;
5714};
5715export type AiTextGenerationResponseFormat = {
5716 type: string;
5717 json_schema?: any;
5718};
5719export type AiTextGenerationInput = {
5720 prompt?: string;
5721 raw?: boolean;
5722 stream?: boolean;
5723 max_tokens?: number;
5724 temperature?: number;
5725 top_p?: number;
5726 top_k?: number;
5727 seed?: number;
5728 repetition_penalty?: number;
5729 frequency_penalty?: number;
5730 presence_penalty?: number;
5731 messages?: RoleScopedChatInput[];
5732 response_format?: AiTextGenerationResponseFormat;
5733 tools?:
5734 | AiTextGenerationToolInput[]
5735 | AiTextGenerationToolLegacyInput[]
5736 | (object & NonNullable<unknown>);
5737 functions?: AiTextGenerationFunctionsInput[];
5738};
5739export type AiTextGenerationToolLegacyOutput = {
5740 name: string;
5741 arguments: unknown;
5742};
5743export type AiTextGenerationToolOutput = {
5744 id: string;
5745 type: "function";
5746 function: {
5747 name: string;
5748 arguments: string;
5749 };
5750};
5751export type UsageTags = {
5752 prompt_tokens: number;
5753 completion_tokens: number;
5754 total_tokens: number;
5755};
5756export type AiTextGenerationOutput = {
5757 response?: string;
5758 tool_calls?: AiTextGenerationToolLegacyOutput[] &
5759 AiTextGenerationToolOutput[];
5760 usage?: UsageTags;
5761};
5762export declare abstract class BaseAiTextGeneration {
5763 inputs: AiTextGenerationInput;
5764 postProcessedOutputs: AiTextGenerationOutput;
5765}
5766export type AiTextToSpeechInput = {
5767 prompt: string;
5768 lang?: string;
5769};
5770export type AiTextToSpeechOutput =
5771 | Uint8Array
5772 | {
5773 audio: string;
5774 };
5775export declare abstract class BaseAiTextToSpeech {
5776 inputs: AiTextToSpeechInput;
5777 postProcessedOutputs: AiTextToSpeechOutput;
5778}
5779export type AiTextToImageInput = {
5780 prompt: string;
5781 negative_prompt?: string;
5782 height?: number;
5783 width?: number;
5784 image?: number[];
5785 image_b64?: string;
5786 mask?: number[];
5787 num_steps?: number;
5788 strength?: number;
5789 guidance?: number;
5790 seed?: number;
5791};
5792export type AiTextToImageOutput = ReadableStream<Uint8Array>;
5793export declare abstract class BaseAiTextToImage {
5794 inputs: AiTextToImageInput;
5795 postProcessedOutputs: AiTextToImageOutput;
5796}
5797export type AiTranslationInput = {
5798 text: string;
5799 target_lang: string;
5800 source_lang?: string;
5801};
5802export type AiTranslationOutput = {
5803 translated_text?: string;
5804};
5805export declare abstract class BaseAiTranslation {
5806 inputs: AiTranslationInput;
5807 postProcessedOutputs: AiTranslationOutput;
5808}
5809/**
5810 * Workers AI support for OpenAI's Chat Completions API
5811 */
5812export type ChatCompletionContentPartText = {
5813 type: "text";
5814 text: string;
5815};
5816export type ChatCompletionContentPartImage = {
5817 type: "image_url";
5818 image_url: {
5819 url: string;
5820 detail?: "auto" | "low" | "high";
5821 };
5822};
5823export type ChatCompletionContentPartInputAudio = {
5824 type: "input_audio";
5825 input_audio: {
5826 /** Base64 encoded audio data. */
5827 data: string;
5828 format: "wav" | "mp3";
5829 };
5830};
5831export type ChatCompletionContentPartFile = {
5832 type: "file";
5833 file: {
5834 /** Base64 encoded file data. */
5835 file_data?: string;
5836 /** The ID of an uploaded file. */
5837 file_id?: string;
5838 filename?: string;
5839 };
5840};
5841export type ChatCompletionContentPartRefusal = {
5842 type: "refusal";
5843 refusal: string;
5844};
5845export type ChatCompletionContentPart =
5846 | ChatCompletionContentPartText
5847 | ChatCompletionContentPartImage
5848 | ChatCompletionContentPartInputAudio
5849 | ChatCompletionContentPartFile;
5850export type FunctionDefinition = {
5851 name: string;
5852 description?: string;
5853 parameters?: Record<string, unknown>;
5854 strict?: boolean | null;
5855};
5856export type ChatCompletionFunctionTool = {
5857 type: "function";
5858 function: FunctionDefinition;
5859};
5860export type ChatCompletionCustomToolGrammarFormat = {
5861 type: "grammar";
5862 grammar: {
5863 definition: string;
5864 syntax: "lark" | "regex";
5865 };
5866};
5867export type ChatCompletionCustomToolTextFormat = {
5868 type: "text";
5869};
5870export type ChatCompletionCustomToolFormat =
5871 | ChatCompletionCustomToolTextFormat
5872 | ChatCompletionCustomToolGrammarFormat;
5873export type ChatCompletionCustomTool = {
5874 type: "custom";
5875 custom: {
5876 name: string;
5877 description?: string;
5878 format?: ChatCompletionCustomToolFormat;
5879 };
5880};
5881export type ChatCompletionTool =
5882 | ChatCompletionFunctionTool
5883 | ChatCompletionCustomTool;
5884export type ChatCompletionMessageFunctionToolCall = {
5885 id: string;
5886 type: "function";
5887 function: {
5888 name: string;
5889 /** JSON-encoded arguments string. */
5890 arguments: string;
5891 };
5892};
5893export type ChatCompletionMessageCustomToolCall = {
5894 id: string;
5895 type: "custom";
5896 custom: {
5897 name: string;
5898 input: string;
5899 };
5900};
5901export type ChatCompletionMessageToolCall =
5902 | ChatCompletionMessageFunctionToolCall
5903 | ChatCompletionMessageCustomToolCall;
5904export type ChatCompletionToolChoiceFunction = {
5905 type: "function";
5906 function: {
5907 name: string;
5908 };
5909};
5910export type ChatCompletionToolChoiceCustom = {
5911 type: "custom";
5912 custom: {
5913 name: string;
5914 };
5915};
5916export type ChatCompletionToolChoiceAllowedTools = {
5917 type: "allowed_tools";
5918 allowed_tools: {
5919 mode: "auto" | "required";
5920 tools: Array<Record<string, unknown>>;
5921 };
5922};
5923export type ChatCompletionToolChoiceOption =
5924 | "none"
5925 | "auto"
5926 | "required"
5927 | ChatCompletionToolChoiceFunction
5928 | ChatCompletionToolChoiceCustom
5929 | ChatCompletionToolChoiceAllowedTools;
5930export type DeveloperMessage = {
5931 role: "developer";
5932 content:
5933 | string
5934 | Array<{
5935 type: "text";
5936 text: string;
5937 }>;
5938 name?: string;
5939};
5940export type SystemMessage = {
5941 role: "system";
5942 content:
5943 | string
5944 | Array<{
5945 type: "text";
5946 text: string;
5947 }>;
5948 name?: string;
5949};
5950/**
5951 * Permissive merged content part used inside UserMessage arrays.
5952 *
5953 * Cabidela has a limitation where anyOf/oneOf with enum-based discrimination
5954 * inside nested array items does not correctly match different branches for
5955 * different array elements, so the schema uses a single merged object.
5956 */
5957export type UserMessageContentPart = {
5958 type: "text" | "image_url" | "input_audio" | "file";
5959 text?: string;
5960 image_url?: {
5961 url?: string;
5962 detail?: "auto" | "low" | "high";
5963 };
5964 input_audio?: {
5965 data?: string;
5966 format?: "wav" | "mp3";
5967 };
5968 file?: {
5969 file_data?: string;
5970 file_id?: string;
5971 filename?: string;
5972 };
5973};
5974export type UserMessage = {
5975 role: "user";
5976 content: string | Array<UserMessageContentPart>;
5977 name?: string;
5978};
5979export type AssistantMessageContentPart = {
5980 type: "text" | "refusal";
5981 text?: string;
5982 refusal?: string;
5983};
5984export type AssistantMessage = {
5985 role: "assistant";
5986 content?: string | null | Array<AssistantMessageContentPart>;
5987 refusal?: string | null;
5988 name?: string;
5989 audio?: {
5990 id: string;
5991 };
5992 tool_calls?: Array<ChatCompletionMessageToolCall>;
5993 function_call?: {
5994 name: string;
5995 arguments: string;
5996 };
5997};
5998export type ToolMessage = {
5999 role: "tool";
6000 content:
6001 | string
6002 | Array<{
6003 type: "text";
6004 text: string;
6005 }>;
6006 tool_call_id: string;
6007};
6008export type FunctionMessage = {
6009 role: "function";
6010 content: string;
6011 name: string;
6012};
6013export type ChatCompletionMessageParam =
6014 | DeveloperMessage
6015 | SystemMessage
6016 | UserMessage
6017 | AssistantMessage
6018 | ToolMessage
6019 | FunctionMessage;
6020export type ChatCompletionsResponseFormatText = {
6021 type: "text";
6022};
6023export type ChatCompletionsResponseFormatJSONObject = {
6024 type: "json_object";
6025};
6026export type ResponseFormatJSONSchema = {
6027 type: "json_schema";
6028 json_schema: {
6029 name: string;
6030 description?: string;
6031 schema?: Record<string, unknown>;
6032 strict?: boolean | null;
6033 };
6034};
6035export type ResponseFormat =
6036 | ChatCompletionsResponseFormatText
6037 | ChatCompletionsResponseFormatJSONObject
6038 | ResponseFormatJSONSchema;
6039export type ChatCompletionsStreamOptions = {
6040 include_usage?: boolean;
6041 include_obfuscation?: boolean;
6042};
6043export type PredictionContent = {
6044 type: "content";
6045 content:
6046 | string
6047 | Array<{
6048 type: "text";
6049 text: string;
6050 }>;
6051};
6052export type AudioParams = {
6053 voice:
6054 | string
6055 | {
6056 id: string;
6057 };
6058 format: "wav" | "aac" | "mp3" | "flac" | "opus" | "pcm16";
6059};
6060export type WebSearchUserLocation = {
6061 type: "approximate";
6062 approximate: {
6063 city?: string;
6064 country?: string;
6065 region?: string;
6066 timezone?: string;
6067 };
6068};
6069export type WebSearchOptions = {
6070 search_context_size?: "low" | "medium" | "high";
6071 user_location?: WebSearchUserLocation;
6072};
6073export type ChatTemplateKwargs = {
6074 /** Whether to enable reasoning, enabled by default. */
6075 enable_thinking?: boolean;
6076 /** If false, preserves reasoning context between turns. */
6077 clear_thinking?: boolean;
6078};
6079/** Shared optional properties used by both Prompt and Messages input branches. */
6080export type ChatCompletionsCommonOptions = {
6081 model?: string;
6082 audio?: AudioParams;
6083 frequency_penalty?: number | null;
6084 logit_bias?: Record<string, unknown> | null;
6085 logprobs?: boolean | null;
6086 top_logprobs?: number | null;
6087 max_tokens?: number | null;
6088 max_completion_tokens?: number | null;
6089 metadata?: Record<string, unknown> | null;
6090 modalities?: Array<"text" | "audio"> | null;
6091 n?: number | null;
6092 parallel_tool_calls?: boolean;
6093 prediction?: PredictionContent;
6094 presence_penalty?: number | null;
6095 reasoning_effort?: "low" | "medium" | "high" | null;
6096 chat_template_kwargs?: ChatTemplateKwargs;
6097 response_format?: ResponseFormat;
6098 seed?: number | null;
6099 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6100 stop?: string | Array<string> | null;
6101 store?: boolean | null;
6102 stream?: boolean | null;
6103 stream_options?: ChatCompletionsStreamOptions;
6104 temperature?: number | null;
6105 tool_choice?: ChatCompletionToolChoiceOption;
6106 tools?: Array<ChatCompletionTool>;
6107 top_p?: number | null;
6108 user?: string;
6109 web_search_options?: WebSearchOptions;
6110 function_call?:
6111 | "none"
6112 | "auto"
6113 | {
6114 name: string;
6115 };
6116 functions?: Array<FunctionDefinition>;
6117};
6118export type PromptTokensDetails = {
6119 cached_tokens?: number;
6120 audio_tokens?: number;
6121};
6122export type CompletionTokensDetails = {
6123 reasoning_tokens?: number;
6124 audio_tokens?: number;
6125 accepted_prediction_tokens?: number;
6126 rejected_prediction_tokens?: number;
6127};
6128export type CompletionUsage = {
6129 prompt_tokens: number;
6130 completion_tokens: number;
6131 total_tokens: number;
6132 prompt_tokens_details?: PromptTokensDetails;
6133 completion_tokens_details?: CompletionTokensDetails;
6134};
6135export type ChatCompletionTopLogprob = {
6136 token: string;
6137 logprob: number;
6138 bytes: Array<number> | null;
6139};
6140export type ChatCompletionTokenLogprob = {
6141 token: string;
6142 logprob: number;
6143 bytes: Array<number> | null;
6144 top_logprobs: Array<ChatCompletionTopLogprob>;
6145};
6146export type ChatCompletionAudio = {
6147 id: string;
6148 /** Base64 encoded audio bytes. */
6149 data: string;
6150 expires_at: number;
6151 transcript: string;
6152};
6153export type ChatCompletionUrlCitation = {
6154 type: "url_citation";
6155 url_citation: {
6156 url: string;
6157 title: string;
6158 start_index: number;
6159 end_index: number;
6160 };
6161};
6162export type ChatCompletionResponseMessage = {
6163 role: "assistant";
6164 content: string | null;
6165 refusal: string | null;
6166 annotations?: Array<ChatCompletionUrlCitation>;
6167 audio?: ChatCompletionAudio;
6168 tool_calls?: Array<ChatCompletionMessageToolCall>;
6169 function_call?: {
6170 name: string;
6171 arguments: string;
6172 } | null;
6173};
6174export type ChatCompletionLogprobs = {
6175 content: Array<ChatCompletionTokenLogprob> | null;
6176 refusal?: Array<ChatCompletionTokenLogprob> | null;
6177};
6178export type ChatCompletionChoice = {
6179 index: number;
6180 message: ChatCompletionResponseMessage;
6181 finish_reason:
6182 | "stop"
6183 | "length"
6184 | "tool_calls"
6185 | "content_filter"
6186 | "function_call";
6187 logprobs: ChatCompletionLogprobs | null;
6188};
6189export type ChatCompletionsPromptInput = {
6190 prompt: string;
6191} & ChatCompletionsCommonOptions;
6192export type ChatCompletionsMessagesInput = {
6193 messages: Array<ChatCompletionMessageParam>;
6194} & ChatCompletionsCommonOptions;
6195export type ChatCompletionsOutput = {
6196 id: string;
6197 object: string;
6198 created: number;
6199 model: string;
6200 choices: Array<ChatCompletionChoice>;
6201 usage?: CompletionUsage;
6202 system_fingerprint?: string | null;
6203 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6204};
6205/**
6206 * Workers AI support for OpenAI's Responses API
6207 * Reference: https://github.com/openai/openai-node/blob/master/src/resources/responses/responses.ts
6208 *
6209 * It's a stripped down version from its source.
6210 * It currently supports basic function calling, json mode and accepts images as input.
6211 *
6212 * It does not include types for WebSearch, CodeInterpreter, FileInputs, MCP, CustomTools.
6213 * We plan to add those incrementally as model + platform capabilities evolve.
6214 */
6215export type ResponsesInput = {
6216 background?: boolean | null;
6217 conversation?: string | ResponseConversationParam | null;
6218 include?: Array<ResponseIncludable> | null;
6219 input?: string | ResponseInput;
6220 instructions?: string | null;
6221 max_output_tokens?: number | null;
6222 parallel_tool_calls?: boolean | null;
6223 previous_response_id?: string | null;
6224 prompt_cache_key?: string;
6225 reasoning?: Reasoning | null;
6226 safety_identifier?: string;
6227 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6228 stream?: boolean | null;
6229 stream_options?: StreamOptions | null;
6230 temperature?: number | null;
6231 text?: ResponseTextConfig;
6232 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
6233 tools?: Array<Tool>;
6234 top_p?: number | null;
6235 truncation?: "auto" | "disabled" | null;
6236};
6237export type ResponsesOutput = {
6238 id?: string;
6239 created_at?: number;
6240 output_text?: string;
6241 error?: ResponseError | null;
6242 incomplete_details?: ResponseIncompleteDetails | null;
6243 instructions?: string | Array<ResponseInputItem> | null;
6244 object?: "response";
6245 output?: Array<ResponseOutputItem>;
6246 parallel_tool_calls?: boolean;
6247 temperature?: number | null;
6248 tool_choice?: ToolChoiceOptions | ToolChoiceFunction;
6249 tools?: Array<Tool>;
6250 top_p?: number | null;
6251 max_output_tokens?: number | null;
6252 previous_response_id?: string | null;
6253 prompt?: ResponsePrompt | null;
6254 reasoning?: Reasoning | null;
6255 safety_identifier?: string;
6256 service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
6257 status?: ResponseStatus;
6258 text?: ResponseTextConfig;
6259 truncation?: "auto" | "disabled" | null;
6260 usage?: ResponseUsage;
6261};
6262export type EasyInputMessage = {
6263 content: string | ResponseInputMessageContentList;
6264 role: "user" | "assistant" | "system" | "developer";
6265 type?: "message";
6266};
6267export type ResponsesFunctionTool = {
6268 name: string;
6269 parameters: {
6270 [key: string]: unknown;
6271 } | null;
6272 strict: boolean | null;
6273 type: "function";
6274 description?: string | null;
6275};
6276export type ResponseIncompleteDetails = {
6277 reason?: "max_output_tokens" | "content_filter";
6278};
6279export type ResponsePrompt = {
6280 id: string;
6281 variables?: {
6282 [key: string]: string | ResponseInputText | ResponseInputImage;
6283 } | null;
6284 version?: string | null;
6285};
6286export type Reasoning = {
6287 effort?: ReasoningEffort | null;
6288 generate_summary?: "auto" | "concise" | "detailed" | null;
6289 summary?: "auto" | "concise" | "detailed" | null;
6290};
6291export type ResponseContent =
6292 | ResponseInputText
6293 | ResponseInputImage
6294 | ResponseOutputText
6295 | ResponseOutputRefusal
6296 | ResponseContentReasoningText;
6297export type ResponseContentReasoningText = {
6298 text: string;
6299 type: "reasoning_text";
6300};
6301export type ResponseConversationParam = {
6302 id: string;
6303};
6304export type ResponseCreatedEvent = {
6305 response: Response;
6306 sequence_number: number;
6307 type: "response.created";
6308};
6309export type ResponseCustomToolCallOutput = {
6310 call_id: string;
6311 output: string | Array<ResponseInputText | ResponseInputImage>;
6312 type: "custom_tool_call_output";
6313 id?: string;
6314};
6315export type ResponseError = {
6316 code:
6317 | "server_error"
6318 | "rate_limit_exceeded"
6319 | "invalid_prompt"
6320 | "vector_store_timeout"
6321 | "invalid_image"
6322 | "invalid_image_format"
6323 | "invalid_base64_image"
6324 | "invalid_image_url"
6325 | "image_too_large"
6326 | "image_too_small"
6327 | "image_parse_error"
6328 | "image_content_policy_violation"
6329 | "invalid_image_mode"
6330 | "image_file_too_large"
6331 | "unsupported_image_media_type"
6332 | "empty_image_file"
6333 | "failed_to_download_image"
6334 | "image_file_not_found";
6335 message: string;
6336};
6337export type ResponseErrorEvent = {
6338 code: string | null;
6339 message: string;
6340 param: string | null;
6341 sequence_number: number;
6342 type: "error";
6343};
6344export type ResponseFailedEvent = {
6345 response: Response;
6346 sequence_number: number;
6347 type: "response.failed";
6348};
6349export type ResponseFormatText = {
6350 type: "text";
6351};
6352export type ResponseFormatJSONObject = {
6353 type: "json_object";
6354};
6355export type ResponseFormatTextConfig =
6356 | ResponseFormatText
6357 | ResponseFormatTextJSONSchemaConfig
6358 | ResponseFormatJSONObject;
6359export type ResponseFormatTextJSONSchemaConfig = {
6360 name: string;
6361 schema: {
6362 [key: string]: unknown;
6363 };
6364 type: "json_schema";
6365 description?: string;
6366 strict?: boolean | null;
6367};
6368export type ResponseFunctionCallArgumentsDeltaEvent = {
6369 delta: string;
6370 item_id: string;
6371 output_index: number;
6372 sequence_number: number;
6373 type: "response.function_call_arguments.delta";
6374};
6375export type ResponseFunctionCallArgumentsDoneEvent = {
6376 arguments: string;
6377 item_id: string;
6378 name: string;
6379 output_index: number;
6380 sequence_number: number;
6381 type: "response.function_call_arguments.done";
6382};
6383export type ResponseFunctionCallOutputItem =
6384 | ResponseInputTextContent
6385 | ResponseInputImageContent;
6386export type ResponseFunctionCallOutputItemList =
6387 Array<ResponseFunctionCallOutputItem>;
6388export type ResponseFunctionToolCall = {
6389 arguments: string;
6390 call_id: string;
6391 name: string;
6392 type: "function_call";
6393 id?: string;
6394 status?: "in_progress" | "completed" | "incomplete";
6395};
6396export interface ResponseFunctionToolCallItem extends ResponseFunctionToolCall {
6397 id: string;
6398}
6399export type ResponseFunctionToolCallOutputItem = {
6400 id: string;
6401 call_id: string;
6402 output: string | Array<ResponseInputText | ResponseInputImage>;
6403 type: "function_call_output";
6404 status?: "in_progress" | "completed" | "incomplete";
6405};
6406export type ResponseIncludable =
6407 | "message.input_image.image_url"
6408 | "message.output_text.logprobs";
6409export type ResponseIncompleteEvent = {
6410 response: Response;
6411 sequence_number: number;
6412 type: "response.incomplete";
6413};
6414export type ResponseInput = Array<ResponseInputItem>;
6415export type ResponseInputContent = ResponseInputText | ResponseInputImage;
6416export type ResponseInputImage = {
6417 detail: "low" | "high" | "auto";
6418 type: "input_image";
6419 /**
6420 * Base64 encoded image
6421 */
6422 image_url?: string | null;
6423};
6424export type ResponseInputImageContent = {
6425 type: "input_image";
6426 detail?: "low" | "high" | "auto" | null;
6427 /**
6428 * Base64 encoded image
6429 */
6430 image_url?: string | null;
6431};
6432export type ResponseInputItem =
6433 | EasyInputMessage
6434 | ResponseInputItemMessage
6435 | ResponseOutputMessage
6436 | ResponseFunctionToolCall
6437 | ResponseInputItemFunctionCallOutput
6438 | ResponseReasoningItem;
6439export type ResponseInputItemFunctionCallOutput = {
6440 call_id: string;
6441 output: string | ResponseFunctionCallOutputItemList;
6442 type: "function_call_output";
6443 id?: string | null;
6444 status?: "in_progress" | "completed" | "incomplete" | null;
6445};
6446export type ResponseInputItemMessage = {
6447 content: ResponseInputMessageContentList;
6448 role: "user" | "system" | "developer";
6449 status?: "in_progress" | "completed" | "incomplete";
6450 type?: "message";
6451};
6452export type ResponseInputMessageContentList = Array<ResponseInputContent>;
6453export type ResponseInputMessageItem = {
6454 id: string;
6455 content: ResponseInputMessageContentList;
6456 role: "user" | "system" | "developer";
6457 status?: "in_progress" | "completed" | "incomplete";
6458 type?: "message";
6459};
6460export type ResponseInputText = {
6461 text: string;
6462 type: "input_text";
6463};
6464export type ResponseInputTextContent = {
6465 text: string;
6466 type: "input_text";
6467};
6468export type ResponseItem =
6469 | ResponseInputMessageItem
6470 | ResponseOutputMessage
6471 | ResponseFunctionToolCallItem
6472 | ResponseFunctionToolCallOutputItem;
6473export type ResponseOutputItem =
6474 | ResponseOutputMessage
6475 | ResponseFunctionToolCall
6476 | ResponseReasoningItem;
6477export type ResponseOutputItemAddedEvent = {
6478 item: ResponseOutputItem;
6479 output_index: number;
6480 sequence_number: number;
6481 type: "response.output_item.added";
6482};
6483export type ResponseOutputItemDoneEvent = {
6484 item: ResponseOutputItem;
6485 output_index: number;
6486 sequence_number: number;
6487 type: "response.output_item.done";
6488};
6489export type ResponseOutputMessage = {
6490 id: string;
6491 content: Array<ResponseOutputText | ResponseOutputRefusal>;
6492 role: "assistant";
6493 status: "in_progress" | "completed" | "incomplete";
6494 type: "message";
6495};
6496export type ResponseOutputRefusal = {
6497 refusal: string;
6498 type: "refusal";
6499};
6500export type ResponseOutputText = {
6501 text: string;
6502 type: "output_text";
6503 logprobs?: Array<Logprob>;
6504};
6505export type ResponseReasoningItem = {
6506 id: string;
6507 summary: Array<ResponseReasoningSummaryItem>;
6508 type: "reasoning";
6509 content?: Array<ResponseReasoningContentItem>;
6510 encrypted_content?: string | null;
6511 status?: "in_progress" | "completed" | "incomplete";
6512};
6513export type ResponseReasoningSummaryItem = {
6514 text: string;
6515 type: "summary_text";
6516};
6517export type ResponseReasoningContentItem = {
6518 text: string;
6519 type: "reasoning_text";
6520};
6521export type ResponseReasoningTextDeltaEvent = {
6522 content_index: number;
6523 delta: string;
6524 item_id: string;
6525 output_index: number;
6526 sequence_number: number;
6527 type: "response.reasoning_text.delta";
6528};
6529export type ResponseReasoningTextDoneEvent = {
6530 content_index: number;
6531 item_id: string;
6532 output_index: number;
6533 sequence_number: number;
6534 text: string;
6535 type: "response.reasoning_text.done";
6536};
6537export type ResponseRefusalDeltaEvent = {
6538 content_index: number;
6539 delta: string;
6540 item_id: string;
6541 output_index: number;
6542 sequence_number: number;
6543 type: "response.refusal.delta";
6544};
6545export type ResponseRefusalDoneEvent = {
6546 content_index: number;
6547 item_id: string;
6548 output_index: number;
6549 refusal: string;
6550 sequence_number: number;
6551 type: "response.refusal.done";
6552};
6553export type ResponseStatus =
6554 | "completed"
6555 | "failed"
6556 | "in_progress"
6557 | "cancelled"
6558 | "queued"
6559 | "incomplete";
6560export type ResponseStreamEvent =
6561 | ResponseCompletedEvent
6562 | ResponseCreatedEvent
6563 | ResponseErrorEvent
6564 | ResponseFunctionCallArgumentsDeltaEvent
6565 | ResponseFunctionCallArgumentsDoneEvent
6566 | ResponseFailedEvent
6567 | ResponseIncompleteEvent
6568 | ResponseOutputItemAddedEvent
6569 | ResponseOutputItemDoneEvent
6570 | ResponseReasoningTextDeltaEvent
6571 | ResponseReasoningTextDoneEvent
6572 | ResponseRefusalDeltaEvent
6573 | ResponseRefusalDoneEvent
6574 | ResponseTextDeltaEvent
6575 | ResponseTextDoneEvent;
6576export type ResponseCompletedEvent = {
6577 response: Response;
6578 sequence_number: number;
6579 type: "response.completed";
6580};
6581export type ResponseTextConfig = {
6582 format?: ResponseFormatTextConfig;
6583 verbosity?: "low" | "medium" | "high" | null;
6584};
6585export type ResponseTextDeltaEvent = {
6586 content_index: number;
6587 delta: string;
6588 item_id: string;
6589 logprobs: Array<Logprob>;
6590 output_index: number;
6591 sequence_number: number;
6592 type: "response.output_text.delta";
6593};
6594export type ResponseTextDoneEvent = {
6595 content_index: number;
6596 item_id: string;
6597 logprobs: Array<Logprob>;
6598 output_index: number;
6599 sequence_number: number;
6600 text: string;
6601 type: "response.output_text.done";
6602};
6603export type Logprob = {
6604 token: string;
6605 logprob: number;
6606 top_logprobs?: Array<TopLogprob>;
6607};
6608export type TopLogprob = {
6609 token?: string;
6610 logprob?: number;
6611};
6612export type ResponseUsage = {
6613 input_tokens: number;
6614 output_tokens: number;
6615 total_tokens: number;
6616};
6617export type Tool = ResponsesFunctionTool;
6618export type ToolChoiceFunction = {
6619 name: string;
6620 type: "function";
6621};
6622export type ToolChoiceOptions = "none";
6623export type ReasoningEffort = "minimal" | "low" | "medium" | "high" | null;
6624export type StreamOptions = {
6625 include_obfuscation?: boolean;
6626};
6627/** Marks keys from T that aren't in U as optional never */
6628export type Without<T, U> = {
6629 [P in Exclude<keyof T, keyof U>]?: never;
6630};
6631/** Either T or U, but not both (mutually exclusive) */
6632export type XOR<T, U> = (T & Without<U, T>) | (U & Without<T, U>);
6633export type Ai_Cf_Baai_Bge_Base_En_V1_5_Input =
6634 | {
6635 text: string | string[];
6636 /**
6637 * 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.
6638 */
6639 pooling?: "mean" | "cls";
6640 }
6641 | {
6642 /**
6643 * Batch of the embeddings requests to run using async-queue
6644 */
6645 requests: {
6646 text: string | string[];
6647 /**
6648 * 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.
6649 */
6650 pooling?: "mean" | "cls";
6651 }[];
6652 };
6653export type Ai_Cf_Baai_Bge_Base_En_V1_5_Output =
6654 | {
6655 shape?: number[];
6656 /**
6657 * Embeddings of the requested text values
6658 */
6659 data?: number[][];
6660 /**
6661 * The pooling method used in the embedding process.
6662 */
6663 pooling?: "mean" | "cls";
6664 }
6665 | Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse;
6666export interface Ai_Cf_Baai_Bge_Base_En_V1_5_AsyncResponse {
6667 /**
6668 * The async request id that can be used to obtain the results.
6669 */
6670 request_id?: string;
6671}
6672export declare abstract class Base_Ai_Cf_Baai_Bge_Base_En_V1_5 {
6673 inputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Input;
6674 postProcessedOutputs: Ai_Cf_Baai_Bge_Base_En_V1_5_Output;
6675}
6676export type Ai_Cf_Openai_Whisper_Input =
6677 | string
6678 | {
6679 /**
6680 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6681 */
6682 audio: number[];
6683 };
6684export interface Ai_Cf_Openai_Whisper_Output {
6685 /**
6686 * The transcription
6687 */
6688 text: string;
6689 word_count?: number;
6690 words?: {
6691 word?: string;
6692 /**
6693 * The second this word begins in the recording
6694 */
6695 start?: number;
6696 /**
6697 * The ending second when the word completes
6698 */
6699 end?: number;
6700 }[];
6701 vtt?: string;
6702}
6703export declare abstract class Base_Ai_Cf_Openai_Whisper {
6704 inputs: Ai_Cf_Openai_Whisper_Input;
6705 postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
6706}
6707export type Ai_Cf_Meta_M2M100_1_2B_Input =
6708 | {
6709 /**
6710 * The text to be translated
6711 */
6712 text: string;
6713 /**
6714 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6715 */
6716 source_lang?: string;
6717 /**
6718 * The language code to translate the text into (e.g., 'es' for Spanish)
6719 */
6720 target_lang: string;
6721 }
6722 | {
6723 /**
6724 * Batch of the embeddings requests to run using async-queue
6725 */
6726 requests: {
6727 /**
6728 * The text to be translated
6729 */
6730 text: string;
6731 /**
6732 * The language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified
6733 */
6734 source_lang?: string;
6735 /**
6736 * The language code to translate the text into (e.g., 'es' for Spanish)
6737 */
6738 target_lang: string;
6739 }[];
6740 };
6741export type Ai_Cf_Meta_M2M100_1_2B_Output =
6742 | {
6743 /**
6744 * The translated text in the target language
6745 */
6746 translated_text?: string;
6747 }
6748 | Ai_Cf_Meta_M2M100_1_2B_AsyncResponse;
6749export interface Ai_Cf_Meta_M2M100_1_2B_AsyncResponse {
6750 /**
6751 * The async request id that can be used to obtain the results.
6752 */
6753 request_id?: string;
6754}
6755export declare abstract class Base_Ai_Cf_Meta_M2M100_1_2B {
6756 inputs: Ai_Cf_Meta_M2M100_1_2B_Input;
6757 postProcessedOutputs: Ai_Cf_Meta_M2M100_1_2B_Output;
6758}
6759export type Ai_Cf_Baai_Bge_Small_En_V1_5_Input =
6760 | {
6761 text: string | string[];
6762 /**
6763 * 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.
6764 */
6765 pooling?: "mean" | "cls";
6766 }
6767 | {
6768 /**
6769 * Batch of the embeddings requests to run using async-queue
6770 */
6771 requests: {
6772 text: string | string[];
6773 /**
6774 * 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.
6775 */
6776 pooling?: "mean" | "cls";
6777 }[];
6778 };
6779export type Ai_Cf_Baai_Bge_Small_En_V1_5_Output =
6780 | {
6781 shape?: number[];
6782 /**
6783 * Embeddings of the requested text values
6784 */
6785 data?: number[][];
6786 /**
6787 * The pooling method used in the embedding process.
6788 */
6789 pooling?: "mean" | "cls";
6790 }
6791 | Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse;
6792export interface Ai_Cf_Baai_Bge_Small_En_V1_5_AsyncResponse {
6793 /**
6794 * The async request id that can be used to obtain the results.
6795 */
6796 request_id?: string;
6797}
6798export declare abstract class Base_Ai_Cf_Baai_Bge_Small_En_V1_5 {
6799 inputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Input;
6800 postProcessedOutputs: Ai_Cf_Baai_Bge_Small_En_V1_5_Output;
6801}
6802export type Ai_Cf_Baai_Bge_Large_En_V1_5_Input =
6803 | {
6804 text: string | string[];
6805 /**
6806 * 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.
6807 */
6808 pooling?: "mean" | "cls";
6809 }
6810 | {
6811 /**
6812 * Batch of the embeddings requests to run using async-queue
6813 */
6814 requests: {
6815 text: string | string[];
6816 /**
6817 * 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.
6818 */
6819 pooling?: "mean" | "cls";
6820 }[];
6821 };
6822export type Ai_Cf_Baai_Bge_Large_En_V1_5_Output =
6823 | {
6824 shape?: number[];
6825 /**
6826 * Embeddings of the requested text values
6827 */
6828 data?: number[][];
6829 /**
6830 * The pooling method used in the embedding process.
6831 */
6832 pooling?: "mean" | "cls";
6833 }
6834 | Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse;
6835export interface Ai_Cf_Baai_Bge_Large_En_V1_5_AsyncResponse {
6836 /**
6837 * The async request id that can be used to obtain the results.
6838 */
6839 request_id?: string;
6840}
6841export declare abstract class Base_Ai_Cf_Baai_Bge_Large_En_V1_5 {
6842 inputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Input;
6843 postProcessedOutputs: Ai_Cf_Baai_Bge_Large_En_V1_5_Output;
6844}
6845export type Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input =
6846 | string
6847 | {
6848 /**
6849 * The input text prompt for the model to generate a response.
6850 */
6851 prompt?: string;
6852 /**
6853 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
6854 */
6855 raw?: boolean;
6856 /**
6857 * 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.
6858 */
6859 top_p?: number;
6860 /**
6861 * 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.
6862 */
6863 top_k?: number;
6864 /**
6865 * Random seed for reproducibility of the generation.
6866 */
6867 seed?: number;
6868 /**
6869 * Penalty for repeated tokens; higher values discourage repetition.
6870 */
6871 repetition_penalty?: number;
6872 /**
6873 * Decreases the likelihood of the model repeating the same lines verbatim.
6874 */
6875 frequency_penalty?: number;
6876 /**
6877 * Increases the likelihood of the model introducing new topics.
6878 */
6879 presence_penalty?: number;
6880 image: number[] | (string & NonNullable<unknown>);
6881 /**
6882 * The maximum number of tokens to generate in the response.
6883 */
6884 max_tokens?: number;
6885 };
6886export interface Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output {
6887 description?: string;
6888}
6889export declare abstract class Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M {
6890 inputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Input;
6891 postProcessedOutputs: Ai_Cf_Unum_Uform_Gen2_Qwen_500M_Output;
6892}
6893export type Ai_Cf_Openai_Whisper_Tiny_En_Input =
6894 | string
6895 | {
6896 /**
6897 * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
6898 */
6899 audio: number[];
6900 };
6901export interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
6902 /**
6903 * The transcription
6904 */
6905 text: string;
6906 word_count?: number;
6907 words?: {
6908 word?: string;
6909 /**
6910 * The second this word begins in the recording
6911 */
6912 start?: number;
6913 /**
6914 * The ending second when the word completes
6915 */
6916 end?: number;
6917 }[];
6918 vtt?: string;
6919}
6920export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
6921 inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
6922 postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
6923}
6924export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
6925 audio:
6926 | string
6927 | {
6928 body?: object;
6929 contentType?: string;
6930 };
6931 /**
6932 * Supported tasks are 'translate' or 'transcribe'.
6933 */
6934 task?: string;
6935 /**
6936 * The language of the audio being transcribed or translated.
6937 */
6938 language?: string;
6939 /**
6940 * Preprocess the audio with a voice activity detection model.
6941 */
6942 vad_filter?: boolean;
6943 /**
6944 * A text prompt to help provide context to the model on the contents of the audio.
6945 */
6946 initial_prompt?: string;
6947 /**
6948 * The prefix appended to the beginning of the output of the transcription and can guide the transcription result.
6949 */
6950 prefix?: string;
6951 /**
6952 * The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.
6953 */
6954 beam_size?: number;
6955 /**
6956 * Whether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.
6957 */
6958 condition_on_previous_text?: boolean;
6959 /**
6960 * Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.
6961 */
6962 no_speech_threshold?: number;
6963 /**
6964 * Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.
6965 */
6966 compression_ratio_threshold?: number;
6967 /**
6968 * Threshold for filtering out segments with low average log probability, indicating low confidence.
6969 */
6970 log_prob_threshold?: number;
6971 /**
6972 * Optional threshold (in seconds) to skip silent periods that may cause hallucinations.
6973 */
6974 hallucination_silence_threshold?: number;
6975}
6976export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
6977 transcription_info?: {
6978 /**
6979 * The language of the audio being transcribed or translated.
6980 */
6981 language?: string;
6982 /**
6983 * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
6984 */
6985 language_probability?: number;
6986 /**
6987 * The total duration of the original audio file, in seconds.
6988 */
6989 duration?: number;
6990 /**
6991 * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
6992 */
6993 duration_after_vad?: number;
6994 };
6995 /**
6996 * The complete transcription of the audio.
6997 */
6998 text: string;
6999 /**
7000 * The total number of words in the transcription.
7001 */
7002 word_count?: number;
7003 segments?: {
7004 /**
7005 * The starting time of the segment within the audio, in seconds.
7006 */
7007 start?: number;
7008 /**
7009 * The ending time of the segment within the audio, in seconds.
7010 */
7011 end?: number;
7012 /**
7013 * The transcription of the segment.
7014 */
7015 text?: string;
7016 /**
7017 * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
7018 */
7019 temperature?: number;
7020 /**
7021 * The average log probability of the predictions for the words in this segment, indicating overall confidence.
7022 */
7023 avg_logprob?: number;
7024 /**
7025 * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
7026 */
7027 compression_ratio?: number;
7028 /**
7029 * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
7030 */
7031 no_speech_prob?: number;
7032 words?: {
7033 /**
7034 * The individual word transcribed from the audio.
7035 */
7036 word?: string;
7037 /**
7038 * The starting time of the word within the audio, in seconds.
7039 */
7040 start?: number;
7041 /**
7042 * The ending time of the word within the audio, in seconds.
7043 */
7044 end?: number;
7045 }[];
7046 }[];
7047 /**
7048 * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
7049 */
7050 vtt?: string;
7051}
7052export declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
7053 inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
7054 postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
7055}
7056export type Ai_Cf_Baai_Bge_M3_Input =
7057 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts
7058 | Ai_Cf_Baai_Bge_M3_Input_Embedding
7059 | {
7060 /**
7061 * Batch of the embeddings requests to run using async-queue
7062 */
7063 requests: (
7064 | Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1
7065 | Ai_Cf_Baai_Bge_M3_Input_Embedding_1
7066 )[];
7067 };
7068export interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts {
7069 /**
7070 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
7071 */
7072 query?: string;
7073 /**
7074 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7075 */
7076 contexts: {
7077 /**
7078 * One of the provided context content
7079 */
7080 text?: string;
7081 }[];
7082 /**
7083 * When provided with too long context should the model error out or truncate the context to fit?
7084 */
7085 truncate_inputs?: boolean;
7086}
7087export interface Ai_Cf_Baai_Bge_M3_Input_Embedding {
7088 text: string | string[];
7089 /**
7090 * When provided with too long context should the model error out or truncate the context to fit?
7091 */
7092 truncate_inputs?: boolean;
7093}
7094export interface Ai_Cf_Baai_Bge_M3_Input_QueryAnd_Contexts_1 {
7095 /**
7096 * A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts
7097 */
7098 query?: string;
7099 /**
7100 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7101 */
7102 contexts: {
7103 /**
7104 * One of the provided context content
7105 */
7106 text?: string;
7107 }[];
7108 /**
7109 * When provided with too long context should the model error out or truncate the context to fit?
7110 */
7111 truncate_inputs?: boolean;
7112}
7113export interface Ai_Cf_Baai_Bge_M3_Input_Embedding_1 {
7114 text: string | string[];
7115 /**
7116 * When provided with too long context should the model error out or truncate the context to fit?
7117 */
7118 truncate_inputs?: boolean;
7119}
7120export type Ai_Cf_Baai_Bge_M3_Output =
7121 | Ai_Cf_Baai_Bge_M3_Output_Query
7122 | Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts
7123 | Ai_Cf_Baai_Bge_M3_Output_Embedding
7124 | Ai_Cf_Baai_Bge_M3_AsyncResponse;
7125export interface Ai_Cf_Baai_Bge_M3_Output_Query {
7126 response?: {
7127 /**
7128 * Index of the context in the request
7129 */
7130 id?: number;
7131 /**
7132 * Score of the context under the index.
7133 */
7134 score?: number;
7135 }[];
7136}
7137export interface Ai_Cf_Baai_Bge_M3_Output_EmbeddingFor_Contexts {
7138 response?: number[][];
7139 shape?: number[];
7140 /**
7141 * The pooling method used in the embedding process.
7142 */
7143 pooling?: "mean" | "cls";
7144}
7145export interface Ai_Cf_Baai_Bge_M3_Output_Embedding {
7146 shape?: number[];
7147 /**
7148 * Embeddings of the requested text values
7149 */
7150 data?: number[][];
7151 /**
7152 * The pooling method used in the embedding process.
7153 */
7154 pooling?: "mean" | "cls";
7155}
7156export interface Ai_Cf_Baai_Bge_M3_AsyncResponse {
7157 /**
7158 * The async request id that can be used to obtain the results.
7159 */
7160 request_id?: string;
7161}
7162export declare abstract class Base_Ai_Cf_Baai_Bge_M3 {
7163 inputs: Ai_Cf_Baai_Bge_M3_Input;
7164 postProcessedOutputs: Ai_Cf_Baai_Bge_M3_Output;
7165}
7166export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
7167 /**
7168 * A text description of the image you want to generate.
7169 */
7170 prompt: string;
7171 /**
7172 * The number of diffusion steps; higher values can improve quality but take longer.
7173 */
7174 steps?: number;
7175}
7176export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
7177 /**
7178 * The generated image in Base64 format.
7179 */
7180 image?: string;
7181}
7182export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
7183 inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
7184 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
7185}
7186export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input =
7187 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt
7188 | Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages;
7189export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Prompt {
7190 /**
7191 * The input text prompt for the model to generate a response.
7192 */
7193 prompt: string;
7194 image?: number[] | (string & NonNullable<unknown>);
7195 /**
7196 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7197 */
7198 raw?: boolean;
7199 /**
7200 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7201 */
7202 stream?: boolean;
7203 /**
7204 * The maximum number of tokens to generate in the response.
7205 */
7206 max_tokens?: number;
7207 /**
7208 * Controls the randomness of the output; higher values produce more random results.
7209 */
7210 temperature?: number;
7211 /**
7212 * 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.
7213 */
7214 top_p?: number;
7215 /**
7216 * 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.
7217 */
7218 top_k?: number;
7219 /**
7220 * Random seed for reproducibility of the generation.
7221 */
7222 seed?: number;
7223 /**
7224 * Penalty for repeated tokens; higher values discourage repetition.
7225 */
7226 repetition_penalty?: number;
7227 /**
7228 * Decreases the likelihood of the model repeating the same lines verbatim.
7229 */
7230 frequency_penalty?: number;
7231 /**
7232 * Increases the likelihood of the model introducing new topics.
7233 */
7234 presence_penalty?: number;
7235 /**
7236 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7237 */
7238 lora?: string;
7239}
7240export interface Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Messages {
7241 /**
7242 * An array of message objects representing the conversation history.
7243 */
7244 messages: {
7245 /**
7246 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7247 */
7248 role?: string;
7249 /**
7250 * The tool call id. If you don't know what to put here you can fall back to 000000001
7251 */
7252 tool_call_id?: string;
7253 content?:
7254 | string
7255 | {
7256 /**
7257 * Type of the content provided
7258 */
7259 type?: string;
7260 text?: string;
7261 image_url?: {
7262 /**
7263 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7264 */
7265 url?: string;
7266 };
7267 }[]
7268 | {
7269 /**
7270 * Type of the content provided
7271 */
7272 type?: string;
7273 text?: string;
7274 image_url?: {
7275 /**
7276 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
7277 */
7278 url?: string;
7279 };
7280 };
7281 }[];
7282 image?: number[] | (string & NonNullable<unknown>);
7283 functions?: {
7284 name: string;
7285 code: string;
7286 }[];
7287 /**
7288 * A list of tools available for the assistant to use.
7289 */
7290 tools?: (
7291 | {
7292 /**
7293 * The name of the tool. More descriptive the better.
7294 */
7295 name: string;
7296 /**
7297 * A brief description of what the tool does.
7298 */
7299 description: string;
7300 /**
7301 * Schema defining the parameters accepted by the tool.
7302 */
7303 parameters: {
7304 /**
7305 * The type of the parameters object (usually 'object').
7306 */
7307 type: string;
7308 /**
7309 * List of required parameter names.
7310 */
7311 required?: string[];
7312 /**
7313 * Definitions of each parameter.
7314 */
7315 properties: {
7316 [k: string]: {
7317 /**
7318 * The data type of the parameter.
7319 */
7320 type: string;
7321 /**
7322 * A description of the expected parameter.
7323 */
7324 description: string;
7325 };
7326 };
7327 };
7328 }
7329 | {
7330 /**
7331 * Specifies the type of tool (e.g., 'function').
7332 */
7333 type: string;
7334 /**
7335 * Details of the function tool.
7336 */
7337 function: {
7338 /**
7339 * The name of the function.
7340 */
7341 name: string;
7342 /**
7343 * A brief description of what the function does.
7344 */
7345 description: string;
7346 /**
7347 * Schema defining the parameters accepted by the function.
7348 */
7349 parameters: {
7350 /**
7351 * The type of the parameters object (usually 'object').
7352 */
7353 type: string;
7354 /**
7355 * List of required parameter names.
7356 */
7357 required?: string[];
7358 /**
7359 * Definitions of each parameter.
7360 */
7361 properties: {
7362 [k: string]: {
7363 /**
7364 * The data type of the parameter.
7365 */
7366 type: string;
7367 /**
7368 * A description of the expected parameter.
7369 */
7370 description: string;
7371 };
7372 };
7373 };
7374 };
7375 }
7376 )[];
7377 /**
7378 * If true, the response will be streamed back incrementally.
7379 */
7380 stream?: boolean;
7381 /**
7382 * The maximum number of tokens to generate in the response.
7383 */
7384 max_tokens?: number;
7385 /**
7386 * Controls the randomness of the output; higher values produce more random results.
7387 */
7388 temperature?: number;
7389 /**
7390 * 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.
7391 */
7392 top_p?: number;
7393 /**
7394 * 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.
7395 */
7396 top_k?: number;
7397 /**
7398 * Random seed for reproducibility of the generation.
7399 */
7400 seed?: number;
7401 /**
7402 * Penalty for repeated tokens; higher values discourage repetition.
7403 */
7404 repetition_penalty?: number;
7405 /**
7406 * Decreases the likelihood of the model repeating the same lines verbatim.
7407 */
7408 frequency_penalty?: number;
7409 /**
7410 * Increases the likelihood of the model introducing new topics.
7411 */
7412 presence_penalty?: number;
7413}
7414export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output = {
7415 /**
7416 * The generated text response from the model
7417 */
7418 response?: string;
7419 /**
7420 * An array of tool calls requests made during the response generation
7421 */
7422 tool_calls?: {
7423 /**
7424 * The arguments passed to be passed to the tool call request
7425 */
7426 arguments?: object;
7427 /**
7428 * The name of the tool to be called
7429 */
7430 name?: string;
7431 }[];
7432};
7433export declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
7434 inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
7435 postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
7436}
7437export type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input =
7438 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt
7439 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages
7440 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch;
7441export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Prompt {
7442 /**
7443 * The input text prompt for the model to generate a response.
7444 */
7445 prompt: string;
7446 /**
7447 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7448 */
7449 lora?: string;
7450 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode;
7451 /**
7452 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7453 */
7454 raw?: boolean;
7455 /**
7456 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7457 */
7458 stream?: boolean;
7459 /**
7460 * The maximum number of tokens to generate in the response.
7461 */
7462 max_tokens?: number;
7463 /**
7464 * Controls the randomness of the output; higher values produce more random results.
7465 */
7466 temperature?: number;
7467 /**
7468 * 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.
7469 */
7470 top_p?: number;
7471 /**
7472 * 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.
7473 */
7474 top_k?: number;
7475 /**
7476 * Random seed for reproducibility of the generation.
7477 */
7478 seed?: number;
7479 /**
7480 * Penalty for repeated tokens; higher values discourage repetition.
7481 */
7482 repetition_penalty?: number;
7483 /**
7484 * Decreases the likelihood of the model repeating the same lines verbatim.
7485 */
7486 frequency_penalty?: number;
7487 /**
7488 * Increases the likelihood of the model introducing new topics.
7489 */
7490 presence_penalty?: number;
7491}
7492export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode {
7493 type?: "json_object" | "json_schema";
7494 json_schema?: unknown;
7495}
7496export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Messages {
7497 /**
7498 * An array of message objects representing the conversation history.
7499 */
7500 messages: {
7501 /**
7502 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7503 */
7504 role: string;
7505 content:
7506 | string
7507 | {
7508 /**
7509 * Type of the content (text)
7510 */
7511 type?: string;
7512 /**
7513 * Text content
7514 */
7515 text?: string;
7516 }[];
7517 }[];
7518 functions?: {
7519 name: string;
7520 code: string;
7521 }[];
7522 /**
7523 * A list of tools available for the assistant to use.
7524 */
7525 tools?: (
7526 | {
7527 /**
7528 * The name of the tool. More descriptive the better.
7529 */
7530 name: string;
7531 /**
7532 * A brief description of what the tool does.
7533 */
7534 description: string;
7535 /**
7536 * Schema defining the parameters accepted by the tool.
7537 */
7538 parameters: {
7539 /**
7540 * The type of the parameters object (usually 'object').
7541 */
7542 type: string;
7543 /**
7544 * List of required parameter names.
7545 */
7546 required?: string[];
7547 /**
7548 * Definitions of each parameter.
7549 */
7550 properties: {
7551 [k: string]: {
7552 /**
7553 * The data type of the parameter.
7554 */
7555 type: string;
7556 /**
7557 * A description of the expected parameter.
7558 */
7559 description: string;
7560 };
7561 };
7562 };
7563 }
7564 | {
7565 /**
7566 * Specifies the type of tool (e.g., 'function').
7567 */
7568 type: string;
7569 /**
7570 * Details of the function tool.
7571 */
7572 function: {
7573 /**
7574 * The name of the function.
7575 */
7576 name: string;
7577 /**
7578 * A brief description of what the function does.
7579 */
7580 description: string;
7581 /**
7582 * Schema defining the parameters accepted by the function.
7583 */
7584 parameters: {
7585 /**
7586 * The type of the parameters object (usually 'object').
7587 */
7588 type: string;
7589 /**
7590 * List of required parameter names.
7591 */
7592 required?: string[];
7593 /**
7594 * Definitions of each parameter.
7595 */
7596 properties: {
7597 [k: string]: {
7598 /**
7599 * The data type of the parameter.
7600 */
7601 type: string;
7602 /**
7603 * A description of the expected parameter.
7604 */
7605 description: string;
7606 };
7607 };
7608 };
7609 };
7610 }
7611 )[];
7612 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1;
7613 /**
7614 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7615 */
7616 raw?: boolean;
7617 /**
7618 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7619 */
7620 stream?: boolean;
7621 /**
7622 * The maximum number of tokens to generate in the response.
7623 */
7624 max_tokens?: number;
7625 /**
7626 * Controls the randomness of the output; higher values produce more random results.
7627 */
7628 temperature?: number;
7629 /**
7630 * 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.
7631 */
7632 top_p?: number;
7633 /**
7634 * 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.
7635 */
7636 top_k?: number;
7637 /**
7638 * Random seed for reproducibility of the generation.
7639 */
7640 seed?: number;
7641 /**
7642 * Penalty for repeated tokens; higher values discourage repetition.
7643 */
7644 repetition_penalty?: number;
7645 /**
7646 * Decreases the likelihood of the model repeating the same lines verbatim.
7647 */
7648 frequency_penalty?: number;
7649 /**
7650 * Increases the likelihood of the model introducing new topics.
7651 */
7652 presence_penalty?: number;
7653}
7654export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_1 {
7655 type?: "json_object" | "json_schema";
7656 json_schema?: unknown;
7657}
7658export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Async_Batch {
7659 requests?: {
7660 /**
7661 * 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.
7662 */
7663 external_reference?: string;
7664 /**
7665 * Prompt for the text generation model
7666 */
7667 prompt?: string;
7668 /**
7669 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7670 */
7671 stream?: boolean;
7672 /**
7673 * The maximum number of tokens to generate in the response.
7674 */
7675 max_tokens?: number;
7676 /**
7677 * Controls the randomness of the output; higher values produce more random results.
7678 */
7679 temperature?: number;
7680 /**
7681 * 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.
7682 */
7683 top_p?: number;
7684 /**
7685 * Random seed for reproducibility of the generation.
7686 */
7687 seed?: number;
7688 /**
7689 * Penalty for repeated tokens; higher values discourage repetition.
7690 */
7691 repetition_penalty?: number;
7692 /**
7693 * Decreases the likelihood of the model repeating the same lines verbatim.
7694 */
7695 frequency_penalty?: number;
7696 /**
7697 * Increases the likelihood of the model introducing new topics.
7698 */
7699 presence_penalty?: number;
7700 response_format?: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2;
7701 }[];
7702}
7703export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_JSON_Mode_2 {
7704 type?: "json_object" | "json_schema";
7705 json_schema?: unknown;
7706}
7707export type Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output =
7708 | {
7709 /**
7710 * The generated text response from the model
7711 */
7712 response: string;
7713 /**
7714 * Usage statistics for the inference request
7715 */
7716 usage?: {
7717 /**
7718 * Total number of tokens in input
7719 */
7720 prompt_tokens?: number;
7721 /**
7722 * Total number of tokens in output
7723 */
7724 completion_tokens?: number;
7725 /**
7726 * Total number of input and output tokens
7727 */
7728 total_tokens?: number;
7729 };
7730 /**
7731 * An array of tool calls requests made during the response generation
7732 */
7733 tool_calls?: {
7734 /**
7735 * The arguments passed to be passed to the tool call request
7736 */
7737 arguments?: object;
7738 /**
7739 * The name of the tool to be called
7740 */
7741 name?: string;
7742 }[];
7743 }
7744 | string
7745 | Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse;
7746export interface Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_AsyncResponse {
7747 /**
7748 * The async request id that can be used to obtain the results.
7749 */
7750 request_id?: string;
7751}
7752export declare abstract class Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast {
7753 inputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Input;
7754 postProcessedOutputs: Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast_Output;
7755}
7756export interface Ai_Cf_Meta_Llama_Guard_3_8B_Input {
7757 /**
7758 * An array of message objects representing the conversation history.
7759 */
7760 messages: {
7761 /**
7762 * The role of the message sender must alternate between 'user' and 'assistant'.
7763 */
7764 role: "user" | "assistant";
7765 /**
7766 * The content of the message as a string.
7767 */
7768 content: string;
7769 }[];
7770 /**
7771 * The maximum number of tokens to generate in the response.
7772 */
7773 max_tokens?: number;
7774 /**
7775 * Controls the randomness of the output; higher values produce more random results.
7776 */
7777 temperature?: number;
7778 /**
7779 * Dictate the output format of the generated response.
7780 */
7781 response_format?: {
7782 /**
7783 * Set to json_object to process and output generated text as JSON.
7784 */
7785 type?: string;
7786 };
7787}
7788export interface Ai_Cf_Meta_Llama_Guard_3_8B_Output {
7789 response?:
7790 | string
7791 | {
7792 /**
7793 * Whether the conversation is safe or not.
7794 */
7795 safe?: boolean;
7796 /**
7797 * A list of what hazard categories predicted for the conversation, if the conversation is deemed unsafe.
7798 */
7799 categories?: string[];
7800 };
7801 /**
7802 * Usage statistics for the inference request
7803 */
7804 usage?: {
7805 /**
7806 * Total number of tokens in input
7807 */
7808 prompt_tokens?: number;
7809 /**
7810 * Total number of tokens in output
7811 */
7812 completion_tokens?: number;
7813 /**
7814 * Total number of input and output tokens
7815 */
7816 total_tokens?: number;
7817 };
7818}
7819export declare abstract class Base_Ai_Cf_Meta_Llama_Guard_3_8B {
7820 inputs: Ai_Cf_Meta_Llama_Guard_3_8B_Input;
7821 postProcessedOutputs: Ai_Cf_Meta_Llama_Guard_3_8B_Output;
7822}
7823export interface Ai_Cf_Baai_Bge_Reranker_Base_Input {
7824 /**
7825 * A query you wish to perform against the provided contexts.
7826 */
7827 /**
7828 * Number of returned results starting with the best score.
7829 */
7830 top_k?: number;
7831 /**
7832 * List of provided contexts. Note that the index in this array is important, as the response will refer to it.
7833 */
7834 contexts: {
7835 /**
7836 * One of the provided context content
7837 */
7838 text?: string;
7839 }[];
7840}
7841export interface Ai_Cf_Baai_Bge_Reranker_Base_Output {
7842 response?: {
7843 /**
7844 * Index of the context in the request
7845 */
7846 id?: number;
7847 /**
7848 * Score of the context under the index.
7849 */
7850 score?: number;
7851 }[];
7852}
7853export declare abstract class Base_Ai_Cf_Baai_Bge_Reranker_Base {
7854 inputs: Ai_Cf_Baai_Bge_Reranker_Base_Input;
7855 postProcessedOutputs: Ai_Cf_Baai_Bge_Reranker_Base_Output;
7856}
7857export type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input =
7858 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt
7859 | Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages;
7860export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Prompt {
7861 /**
7862 * The input text prompt for the model to generate a response.
7863 */
7864 prompt: string;
7865 /**
7866 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
7867 */
7868 lora?: string;
7869 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode;
7870 /**
7871 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
7872 */
7873 raw?: boolean;
7874 /**
7875 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
7876 */
7877 stream?: boolean;
7878 /**
7879 * The maximum number of tokens to generate in the response.
7880 */
7881 max_tokens?: number;
7882 /**
7883 * Controls the randomness of the output; higher values produce more random results.
7884 */
7885 temperature?: number;
7886 /**
7887 * 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.
7888 */
7889 top_p?: number;
7890 /**
7891 * 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.
7892 */
7893 top_k?: number;
7894 /**
7895 * Random seed for reproducibility of the generation.
7896 */
7897 seed?: number;
7898 /**
7899 * Penalty for repeated tokens; higher values discourage repetition.
7900 */
7901 repetition_penalty?: number;
7902 /**
7903 * Decreases the likelihood of the model repeating the same lines verbatim.
7904 */
7905 frequency_penalty?: number;
7906 /**
7907 * Increases the likelihood of the model introducing new topics.
7908 */
7909 presence_penalty?: number;
7910}
7911export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode {
7912 type?: "json_object" | "json_schema";
7913 json_schema?: unknown;
7914}
7915export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Messages {
7916 /**
7917 * An array of message objects representing the conversation history.
7918 */
7919 messages: {
7920 /**
7921 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
7922 */
7923 role: string;
7924 /**
7925 * The content of the message as a string.
7926 */
7927 content: string;
7928 }[];
7929 functions?: {
7930 name: string;
7931 code: string;
7932 }[];
7933 /**
7934 * A list of tools available for the assistant to use.
7935 */
7936 tools?: (
7937 | {
7938 /**
7939 * The name of the tool. More descriptive the better.
7940 */
7941 name: string;
7942 /**
7943 * A brief description of what the tool does.
7944 */
7945 description: string;
7946 /**
7947 * Schema defining the parameters accepted by the tool.
7948 */
7949 parameters: {
7950 /**
7951 * The type of the parameters object (usually 'object').
7952 */
7953 type: string;
7954 /**
7955 * List of required parameter names.
7956 */
7957 required?: string[];
7958 /**
7959 * Definitions of each parameter.
7960 */
7961 properties: {
7962 [k: string]: {
7963 /**
7964 * The data type of the parameter.
7965 */
7966 type: string;
7967 /**
7968 * A description of the expected parameter.
7969 */
7970 description: string;
7971 };
7972 };
7973 };
7974 }
7975 | {
7976 /**
7977 * Specifies the type of tool (e.g., 'function').
7978 */
7979 type: string;
7980 /**
7981 * Details of the function tool.
7982 */
7983 function: {
7984 /**
7985 * The name of the function.
7986 */
7987 name: string;
7988 /**
7989 * A brief description of what the function does.
7990 */
7991 description: string;
7992 /**
7993 * Schema defining the parameters accepted by the function.
7994 */
7995 parameters: {
7996 /**
7997 * The type of the parameters object (usually 'object').
7998 */
7999 type: string;
8000 /**
8001 * List of required parameter names.
8002 */
8003 required?: string[];
8004 /**
8005 * Definitions of each parameter.
8006 */
8007 properties: {
8008 [k: string]: {
8009 /**
8010 * The data type of the parameter.
8011 */
8012 type: string;
8013 /**
8014 * A description of the expected parameter.
8015 */
8016 description: string;
8017 };
8018 };
8019 };
8020 };
8021 }
8022 )[];
8023 response_format?: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1;
8024 /**
8025 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8026 */
8027 raw?: boolean;
8028 /**
8029 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8030 */
8031 stream?: boolean;
8032 /**
8033 * The maximum number of tokens to generate in the response.
8034 */
8035 max_tokens?: number;
8036 /**
8037 * Controls the randomness of the output; higher values produce more random results.
8038 */
8039 temperature?: number;
8040 /**
8041 * 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.
8042 */
8043 top_p?: number;
8044 /**
8045 * 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.
8046 */
8047 top_k?: number;
8048 /**
8049 * Random seed for reproducibility of the generation.
8050 */
8051 seed?: number;
8052 /**
8053 * Penalty for repeated tokens; higher values discourage repetition.
8054 */
8055 repetition_penalty?: number;
8056 /**
8057 * Decreases the likelihood of the model repeating the same lines verbatim.
8058 */
8059 frequency_penalty?: number;
8060 /**
8061 * Increases the likelihood of the model introducing new topics.
8062 */
8063 presence_penalty?: number;
8064}
8065export interface Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_JSON_Mode_1 {
8066 type?: "json_object" | "json_schema";
8067 json_schema?: unknown;
8068}
8069export type Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output = {
8070 /**
8071 * The generated text response from the model
8072 */
8073 response: string;
8074 /**
8075 * Usage statistics for the inference request
8076 */
8077 usage?: {
8078 /**
8079 * Total number of tokens in input
8080 */
8081 prompt_tokens?: number;
8082 /**
8083 * Total number of tokens in output
8084 */
8085 completion_tokens?: number;
8086 /**
8087 * Total number of input and output tokens
8088 */
8089 total_tokens?: number;
8090 };
8091 /**
8092 * An array of tool calls requests made during the response generation
8093 */
8094 tool_calls?: {
8095 /**
8096 * The arguments passed to be passed to the tool call request
8097 */
8098 arguments?: object;
8099 /**
8100 * The name of the tool to be called
8101 */
8102 name?: string;
8103 }[];
8104};
8105export declare abstract class Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct {
8106 inputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Input;
8107 postProcessedOutputs: Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct_Output;
8108}
8109export type Ai_Cf_Qwen_Qwq_32B_Input =
8110 | Ai_Cf_Qwen_Qwq_32B_Prompt
8111 | Ai_Cf_Qwen_Qwq_32B_Messages;
8112export interface Ai_Cf_Qwen_Qwq_32B_Prompt {
8113 /**
8114 * The input text prompt for the model to generate a response.
8115 */
8116 prompt: string;
8117 /**
8118 * JSON schema that should be fulfilled for the response.
8119 */
8120 guided_json?: object;
8121 /**
8122 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8123 */
8124 raw?: boolean;
8125 /**
8126 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8127 */
8128 stream?: boolean;
8129 /**
8130 * The maximum number of tokens to generate in the response.
8131 */
8132 max_tokens?: number;
8133 /**
8134 * Controls the randomness of the output; higher values produce more random results.
8135 */
8136 temperature?: number;
8137 /**
8138 * 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.
8139 */
8140 top_p?: number;
8141 /**
8142 * 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.
8143 */
8144 top_k?: number;
8145 /**
8146 * Random seed for reproducibility of the generation.
8147 */
8148 seed?: number;
8149 /**
8150 * Penalty for repeated tokens; higher values discourage repetition.
8151 */
8152 repetition_penalty?: number;
8153 /**
8154 * Decreases the likelihood of the model repeating the same lines verbatim.
8155 */
8156 frequency_penalty?: number;
8157 /**
8158 * Increases the likelihood of the model introducing new topics.
8159 */
8160 presence_penalty?: number;
8161}
8162export interface Ai_Cf_Qwen_Qwq_32B_Messages {
8163 /**
8164 * An array of message objects representing the conversation history.
8165 */
8166 messages: {
8167 /**
8168 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8169 */
8170 role?: string;
8171 /**
8172 * The tool call id. If you don't know what to put here you can fall back to 000000001
8173 */
8174 tool_call_id?: string;
8175 content?:
8176 | string
8177 | {
8178 /**
8179 * Type of the content provided
8180 */
8181 type?: string;
8182 text?: string;
8183 image_url?: {
8184 /**
8185 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8186 */
8187 url?: string;
8188 };
8189 }[]
8190 | {
8191 /**
8192 * Type of the content provided
8193 */
8194 type?: string;
8195 text?: string;
8196 image_url?: {
8197 /**
8198 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8199 */
8200 url?: string;
8201 };
8202 };
8203 }[];
8204 functions?: {
8205 name: string;
8206 code: string;
8207 }[];
8208 /**
8209 * A list of tools available for the assistant to use.
8210 */
8211 tools?: (
8212 | {
8213 /**
8214 * The name of the tool. More descriptive the better.
8215 */
8216 name: string;
8217 /**
8218 * A brief description of what the tool does.
8219 */
8220 description: string;
8221 /**
8222 * Schema defining the parameters accepted by the tool.
8223 */
8224 parameters: {
8225 /**
8226 * The type of the parameters object (usually 'object').
8227 */
8228 type: string;
8229 /**
8230 * List of required parameter names.
8231 */
8232 required?: string[];
8233 /**
8234 * Definitions of each parameter.
8235 */
8236 properties: {
8237 [k: string]: {
8238 /**
8239 * The data type of the parameter.
8240 */
8241 type: string;
8242 /**
8243 * A description of the expected parameter.
8244 */
8245 description: string;
8246 };
8247 };
8248 };
8249 }
8250 | {
8251 /**
8252 * Specifies the type of tool (e.g., 'function').
8253 */
8254 type: string;
8255 /**
8256 * Details of the function tool.
8257 */
8258 function: {
8259 /**
8260 * The name of the function.
8261 */
8262 name: string;
8263 /**
8264 * A brief description of what the function does.
8265 */
8266 description: string;
8267 /**
8268 * Schema defining the parameters accepted by the function.
8269 */
8270 parameters: {
8271 /**
8272 * The type of the parameters object (usually 'object').
8273 */
8274 type: string;
8275 /**
8276 * List of required parameter names.
8277 */
8278 required?: string[];
8279 /**
8280 * Definitions of each parameter.
8281 */
8282 properties: {
8283 [k: string]: {
8284 /**
8285 * The data type of the parameter.
8286 */
8287 type: string;
8288 /**
8289 * A description of the expected parameter.
8290 */
8291 description: string;
8292 };
8293 };
8294 };
8295 };
8296 }
8297 )[];
8298 /**
8299 * JSON schema that should be fufilled for the response.
8300 */
8301 guided_json?: object;
8302 /**
8303 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8304 */
8305 raw?: boolean;
8306 /**
8307 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8308 */
8309 stream?: boolean;
8310 /**
8311 * The maximum number of tokens to generate in the response.
8312 */
8313 max_tokens?: number;
8314 /**
8315 * Controls the randomness of the output; higher values produce more random results.
8316 */
8317 temperature?: number;
8318 /**
8319 * 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.
8320 */
8321 top_p?: number;
8322 /**
8323 * 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.
8324 */
8325 top_k?: number;
8326 /**
8327 * Random seed for reproducibility of the generation.
8328 */
8329 seed?: number;
8330 /**
8331 * Penalty for repeated tokens; higher values discourage repetition.
8332 */
8333 repetition_penalty?: number;
8334 /**
8335 * Decreases the likelihood of the model repeating the same lines verbatim.
8336 */
8337 frequency_penalty?: number;
8338 /**
8339 * Increases the likelihood of the model introducing new topics.
8340 */
8341 presence_penalty?: number;
8342}
8343export type Ai_Cf_Qwen_Qwq_32B_Output = {
8344 /**
8345 * The generated text response from the model
8346 */
8347 response: string;
8348 /**
8349 * Usage statistics for the inference request
8350 */
8351 usage?: {
8352 /**
8353 * Total number of tokens in input
8354 */
8355 prompt_tokens?: number;
8356 /**
8357 * Total number of tokens in output
8358 */
8359 completion_tokens?: number;
8360 /**
8361 * Total number of input and output tokens
8362 */
8363 total_tokens?: number;
8364 };
8365 /**
8366 * An array of tool calls requests made during the response generation
8367 */
8368 tool_calls?: {
8369 /**
8370 * The arguments passed to be passed to the tool call request
8371 */
8372 arguments?: object;
8373 /**
8374 * The name of the tool to be called
8375 */
8376 name?: string;
8377 }[];
8378};
8379export declare abstract class Base_Ai_Cf_Qwen_Qwq_32B {
8380 inputs: Ai_Cf_Qwen_Qwq_32B_Input;
8381 postProcessedOutputs: Ai_Cf_Qwen_Qwq_32B_Output;
8382}
8383export type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input =
8384 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt
8385 | Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages;
8386export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Prompt {
8387 /**
8388 * The input text prompt for the model to generate a response.
8389 */
8390 prompt: string;
8391 /**
8392 * JSON schema that should be fulfilled for the response.
8393 */
8394 guided_json?: object;
8395 /**
8396 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8397 */
8398 raw?: boolean;
8399 /**
8400 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8401 */
8402 stream?: boolean;
8403 /**
8404 * The maximum number of tokens to generate in the response.
8405 */
8406 max_tokens?: number;
8407 /**
8408 * Controls the randomness of the output; higher values produce more random results.
8409 */
8410 temperature?: number;
8411 /**
8412 * 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.
8413 */
8414 top_p?: number;
8415 /**
8416 * 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.
8417 */
8418 top_k?: number;
8419 /**
8420 * Random seed for reproducibility of the generation.
8421 */
8422 seed?: number;
8423 /**
8424 * Penalty for repeated tokens; higher values discourage repetition.
8425 */
8426 repetition_penalty?: number;
8427 /**
8428 * Decreases the likelihood of the model repeating the same lines verbatim.
8429 */
8430 frequency_penalty?: number;
8431 /**
8432 * Increases the likelihood of the model introducing new topics.
8433 */
8434 presence_penalty?: number;
8435}
8436export interface Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Messages {
8437 /**
8438 * An array of message objects representing the conversation history.
8439 */
8440 messages: {
8441 /**
8442 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8443 */
8444 role?: string;
8445 /**
8446 * 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
8447 */
8448 tool_call_id?: string;
8449 content?:
8450 | string
8451 | {
8452 /**
8453 * Type of the content provided
8454 */
8455 type?: string;
8456 text?: string;
8457 image_url?: {
8458 /**
8459 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8460 */
8461 url?: string;
8462 };
8463 }[]
8464 | {
8465 /**
8466 * Type of the content provided
8467 */
8468 type?: string;
8469 text?: string;
8470 image_url?: {
8471 /**
8472 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8473 */
8474 url?: string;
8475 };
8476 };
8477 }[];
8478 functions?: {
8479 name: string;
8480 code: string;
8481 }[];
8482 /**
8483 * A list of tools available for the assistant to use.
8484 */
8485 tools?: (
8486 | {
8487 /**
8488 * The name of the tool. More descriptive the better.
8489 */
8490 name: string;
8491 /**
8492 * A brief description of what the tool does.
8493 */
8494 description: string;
8495 /**
8496 * Schema defining the parameters accepted by the tool.
8497 */
8498 parameters: {
8499 /**
8500 * The type of the parameters object (usually 'object').
8501 */
8502 type: string;
8503 /**
8504 * List of required parameter names.
8505 */
8506 required?: string[];
8507 /**
8508 * Definitions of each parameter.
8509 */
8510 properties: {
8511 [k: string]: {
8512 /**
8513 * The data type of the parameter.
8514 */
8515 type: string;
8516 /**
8517 * A description of the expected parameter.
8518 */
8519 description: string;
8520 };
8521 };
8522 };
8523 }
8524 | {
8525 /**
8526 * Specifies the type of tool (e.g., 'function').
8527 */
8528 type: string;
8529 /**
8530 * Details of the function tool.
8531 */
8532 function: {
8533 /**
8534 * The name of the function.
8535 */
8536 name: string;
8537 /**
8538 * A brief description of what the function does.
8539 */
8540 description: string;
8541 /**
8542 * Schema defining the parameters accepted by the function.
8543 */
8544 parameters: {
8545 /**
8546 * The type of the parameters object (usually 'object').
8547 */
8548 type: string;
8549 /**
8550 * List of required parameter names.
8551 */
8552 required?: string[];
8553 /**
8554 * Definitions of each parameter.
8555 */
8556 properties: {
8557 [k: string]: {
8558 /**
8559 * The data type of the parameter.
8560 */
8561 type: string;
8562 /**
8563 * A description of the expected parameter.
8564 */
8565 description: string;
8566 };
8567 };
8568 };
8569 };
8570 }
8571 )[];
8572 /**
8573 * JSON schema that should be fufilled for the response.
8574 */
8575 guided_json?: object;
8576 /**
8577 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8578 */
8579 raw?: boolean;
8580 /**
8581 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8582 */
8583 stream?: boolean;
8584 /**
8585 * The maximum number of tokens to generate in the response.
8586 */
8587 max_tokens?: number;
8588 /**
8589 * Controls the randomness of the output; higher values produce more random results.
8590 */
8591 temperature?: number;
8592 /**
8593 * 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.
8594 */
8595 top_p?: number;
8596 /**
8597 * 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.
8598 */
8599 top_k?: number;
8600 /**
8601 * Random seed for reproducibility of the generation.
8602 */
8603 seed?: number;
8604 /**
8605 * Penalty for repeated tokens; higher values discourage repetition.
8606 */
8607 repetition_penalty?: number;
8608 /**
8609 * Decreases the likelihood of the model repeating the same lines verbatim.
8610 */
8611 frequency_penalty?: number;
8612 /**
8613 * Increases the likelihood of the model introducing new topics.
8614 */
8615 presence_penalty?: number;
8616}
8617export type Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output = {
8618 /**
8619 * The generated text response from the model
8620 */
8621 response: string;
8622 /**
8623 * Usage statistics for the inference request
8624 */
8625 usage?: {
8626 /**
8627 * Total number of tokens in input
8628 */
8629 prompt_tokens?: number;
8630 /**
8631 * Total number of tokens in output
8632 */
8633 completion_tokens?: number;
8634 /**
8635 * Total number of input and output tokens
8636 */
8637 total_tokens?: number;
8638 };
8639 /**
8640 * An array of tool calls requests made during the response generation
8641 */
8642 tool_calls?: {
8643 /**
8644 * The arguments passed to be passed to the tool call request
8645 */
8646 arguments?: object;
8647 /**
8648 * The name of the tool to be called
8649 */
8650 name?: string;
8651 }[];
8652};
8653export declare abstract class Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct {
8654 inputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Input;
8655 postProcessedOutputs: Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct_Output;
8656}
8657export type Ai_Cf_Google_Gemma_3_12B_It_Input =
8658 | Ai_Cf_Google_Gemma_3_12B_It_Prompt
8659 | Ai_Cf_Google_Gemma_3_12B_It_Messages;
8660export interface Ai_Cf_Google_Gemma_3_12B_It_Prompt {
8661 /**
8662 * The input text prompt for the model to generate a response.
8663 */
8664 prompt: string;
8665 /**
8666 * JSON schema that should be fufilled for the response.
8667 */
8668 guided_json?: object;
8669 /**
8670 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8671 */
8672 raw?: boolean;
8673 /**
8674 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8675 */
8676 stream?: boolean;
8677 /**
8678 * The maximum number of tokens to generate in the response.
8679 */
8680 max_tokens?: number;
8681 /**
8682 * Controls the randomness of the output; higher values produce more random results.
8683 */
8684 temperature?: number;
8685 /**
8686 * 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.
8687 */
8688 top_p?: number;
8689 /**
8690 * 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.
8691 */
8692 top_k?: number;
8693 /**
8694 * Random seed for reproducibility of the generation.
8695 */
8696 seed?: number;
8697 /**
8698 * Penalty for repeated tokens; higher values discourage repetition.
8699 */
8700 repetition_penalty?: number;
8701 /**
8702 * Decreases the likelihood of the model repeating the same lines verbatim.
8703 */
8704 frequency_penalty?: number;
8705 /**
8706 * Increases the likelihood of the model introducing new topics.
8707 */
8708 presence_penalty?: number;
8709}
8710export interface Ai_Cf_Google_Gemma_3_12B_It_Messages {
8711 /**
8712 * An array of message objects representing the conversation history.
8713 */
8714 messages: {
8715 /**
8716 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8717 */
8718 role?: string;
8719 content?:
8720 | string
8721 | {
8722 /**
8723 * Type of the content provided
8724 */
8725 type?: string;
8726 text?: string;
8727 image_url?: {
8728 /**
8729 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8730 */
8731 url?: string;
8732 };
8733 }[];
8734 }[];
8735 functions?: {
8736 name: string;
8737 code: string;
8738 }[];
8739 /**
8740 * A list of tools available for the assistant to use.
8741 */
8742 tools?: (
8743 | {
8744 /**
8745 * The name of the tool. More descriptive the better.
8746 */
8747 name: string;
8748 /**
8749 * A brief description of what the tool does.
8750 */
8751 description: string;
8752 /**
8753 * Schema defining the parameters accepted by the tool.
8754 */
8755 parameters: {
8756 /**
8757 * The type of the parameters object (usually 'object').
8758 */
8759 type: string;
8760 /**
8761 * List of required parameter names.
8762 */
8763 required?: string[];
8764 /**
8765 * Definitions of each parameter.
8766 */
8767 properties: {
8768 [k: string]: {
8769 /**
8770 * The data type of the parameter.
8771 */
8772 type: string;
8773 /**
8774 * A description of the expected parameter.
8775 */
8776 description: string;
8777 };
8778 };
8779 };
8780 }
8781 | {
8782 /**
8783 * Specifies the type of tool (e.g., 'function').
8784 */
8785 type: string;
8786 /**
8787 * Details of the function tool.
8788 */
8789 function: {
8790 /**
8791 * The name of the function.
8792 */
8793 name: string;
8794 /**
8795 * A brief description of what the function does.
8796 */
8797 description: string;
8798 /**
8799 * Schema defining the parameters accepted by the function.
8800 */
8801 parameters: {
8802 /**
8803 * The type of the parameters object (usually 'object').
8804 */
8805 type: string;
8806 /**
8807 * List of required parameter names.
8808 */
8809 required?: string[];
8810 /**
8811 * Definitions of each parameter.
8812 */
8813 properties: {
8814 [k: string]: {
8815 /**
8816 * The data type of the parameter.
8817 */
8818 type: string;
8819 /**
8820 * A description of the expected parameter.
8821 */
8822 description: string;
8823 };
8824 };
8825 };
8826 };
8827 }
8828 )[];
8829 /**
8830 * JSON schema that should be fufilled for the response.
8831 */
8832 guided_json?: object;
8833 /**
8834 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8835 */
8836 raw?: boolean;
8837 /**
8838 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8839 */
8840 stream?: boolean;
8841 /**
8842 * The maximum number of tokens to generate in the response.
8843 */
8844 max_tokens?: number;
8845 /**
8846 * Controls the randomness of the output; higher values produce more random results.
8847 */
8848 temperature?: number;
8849 /**
8850 * 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.
8851 */
8852 top_p?: number;
8853 /**
8854 * 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.
8855 */
8856 top_k?: number;
8857 /**
8858 * Random seed for reproducibility of the generation.
8859 */
8860 seed?: number;
8861 /**
8862 * Penalty for repeated tokens; higher values discourage repetition.
8863 */
8864 repetition_penalty?: number;
8865 /**
8866 * Decreases the likelihood of the model repeating the same lines verbatim.
8867 */
8868 frequency_penalty?: number;
8869 /**
8870 * Increases the likelihood of the model introducing new topics.
8871 */
8872 presence_penalty?: number;
8873}
8874export type Ai_Cf_Google_Gemma_3_12B_It_Output = {
8875 /**
8876 * The generated text response from the model
8877 */
8878 response: string;
8879 /**
8880 * Usage statistics for the inference request
8881 */
8882 usage?: {
8883 /**
8884 * Total number of tokens in input
8885 */
8886 prompt_tokens?: number;
8887 /**
8888 * Total number of tokens in output
8889 */
8890 completion_tokens?: number;
8891 /**
8892 * Total number of input and output tokens
8893 */
8894 total_tokens?: number;
8895 };
8896 /**
8897 * An array of tool calls requests made during the response generation
8898 */
8899 tool_calls?: {
8900 /**
8901 * The arguments passed to be passed to the tool call request
8902 */
8903 arguments?: object;
8904 /**
8905 * The name of the tool to be called
8906 */
8907 name?: string;
8908 }[];
8909};
8910export declare abstract class Base_Ai_Cf_Google_Gemma_3_12B_It {
8911 inputs: Ai_Cf_Google_Gemma_3_12B_It_Input;
8912 postProcessedOutputs: Ai_Cf_Google_Gemma_3_12B_It_Output;
8913}
8914export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input =
8915 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt
8916 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages
8917 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch;
8918export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt {
8919 /**
8920 * The input text prompt for the model to generate a response.
8921 */
8922 prompt: string;
8923 /**
8924 * JSON schema that should be fulfilled for the response.
8925 */
8926 guided_json?: object;
8927 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
8928 /**
8929 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
8930 */
8931 raw?: boolean;
8932 /**
8933 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
8934 */
8935 stream?: boolean;
8936 /**
8937 * The maximum number of tokens to generate in the response.
8938 */
8939 max_tokens?: number;
8940 /**
8941 * Controls the randomness of the output; higher values produce more random results.
8942 */
8943 temperature?: number;
8944 /**
8945 * 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.
8946 */
8947 top_p?: number;
8948 /**
8949 * 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.
8950 */
8951 top_k?: number;
8952 /**
8953 * Random seed for reproducibility of the generation.
8954 */
8955 seed?: number;
8956 /**
8957 * Penalty for repeated tokens; higher values discourage repetition.
8958 */
8959 repetition_penalty?: number;
8960 /**
8961 * Decreases the likelihood of the model repeating the same lines verbatim.
8962 */
8963 frequency_penalty?: number;
8964 /**
8965 * Increases the likelihood of the model introducing new topics.
8966 */
8967 presence_penalty?: number;
8968}
8969export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode {
8970 type?: "json_object" | "json_schema";
8971 json_schema?: unknown;
8972}
8973export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages {
8974 /**
8975 * An array of message objects representing the conversation history.
8976 */
8977 messages: {
8978 /**
8979 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
8980 */
8981 role?: string;
8982 /**
8983 * The tool call id. If you don't know what to put here you can fall back to 000000001
8984 */
8985 tool_call_id?: string;
8986 content?:
8987 | string
8988 | {
8989 /**
8990 * Type of the content provided
8991 */
8992 type?: string;
8993 text?: string;
8994 image_url?: {
8995 /**
8996 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
8997 */
8998 url?: string;
8999 };
9000 }[]
9001 | {
9002 /**
9003 * Type of the content provided
9004 */
9005 type?: string;
9006 text?: string;
9007 image_url?: {
9008 /**
9009 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9010 */
9011 url?: string;
9012 };
9013 };
9014 }[];
9015 functions?: {
9016 name: string;
9017 code: string;
9018 }[];
9019 /**
9020 * A list of tools available for the assistant to use.
9021 */
9022 tools?: (
9023 | {
9024 /**
9025 * The name of the tool. More descriptive the better.
9026 */
9027 name: string;
9028 /**
9029 * A brief description of what the tool does.
9030 */
9031 description: string;
9032 /**
9033 * Schema defining the parameters accepted by the tool.
9034 */
9035 parameters: {
9036 /**
9037 * The type of the parameters object (usually 'object').
9038 */
9039 type: string;
9040 /**
9041 * List of required parameter names.
9042 */
9043 required?: string[];
9044 /**
9045 * Definitions of each parameter.
9046 */
9047 properties: {
9048 [k: string]: {
9049 /**
9050 * The data type of the parameter.
9051 */
9052 type: string;
9053 /**
9054 * A description of the expected parameter.
9055 */
9056 description: string;
9057 };
9058 };
9059 };
9060 }
9061 | {
9062 /**
9063 * Specifies the type of tool (e.g., 'function').
9064 */
9065 type: string;
9066 /**
9067 * Details of the function tool.
9068 */
9069 function: {
9070 /**
9071 * The name of the function.
9072 */
9073 name: string;
9074 /**
9075 * A brief description of what the function does.
9076 */
9077 description: string;
9078 /**
9079 * Schema defining the parameters accepted by the function.
9080 */
9081 parameters: {
9082 /**
9083 * The type of the parameters object (usually 'object').
9084 */
9085 type: string;
9086 /**
9087 * List of required parameter names.
9088 */
9089 required?: string[];
9090 /**
9091 * Definitions of each parameter.
9092 */
9093 properties: {
9094 [k: string]: {
9095 /**
9096 * The data type of the parameter.
9097 */
9098 type: string;
9099 /**
9100 * A description of the expected parameter.
9101 */
9102 description: string;
9103 };
9104 };
9105 };
9106 };
9107 }
9108 )[];
9109 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9110 /**
9111 * JSON schema that should be fufilled for the response.
9112 */
9113 guided_json?: object;
9114 /**
9115 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9116 */
9117 raw?: boolean;
9118 /**
9119 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9120 */
9121 stream?: boolean;
9122 /**
9123 * The maximum number of tokens to generate in the response.
9124 */
9125 max_tokens?: number;
9126 /**
9127 * Controls the randomness of the output; higher values produce more random results.
9128 */
9129 temperature?: number;
9130 /**
9131 * 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.
9132 */
9133 top_p?: number;
9134 /**
9135 * 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.
9136 */
9137 top_k?: number;
9138 /**
9139 * Random seed for reproducibility of the generation.
9140 */
9141 seed?: number;
9142 /**
9143 * Penalty for repeated tokens; higher values discourage repetition.
9144 */
9145 repetition_penalty?: number;
9146 /**
9147 * Decreases the likelihood of the model repeating the same lines verbatim.
9148 */
9149 frequency_penalty?: number;
9150 /**
9151 * Increases the likelihood of the model introducing new topics.
9152 */
9153 presence_penalty?: number;
9154}
9155export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Async_Batch {
9156 requests: (
9157 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner
9158 | Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner
9159 )[];
9160}
9161export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Prompt_Inner {
9162 /**
9163 * The input text prompt for the model to generate a response.
9164 */
9165 prompt: string;
9166 /**
9167 * JSON schema that should be fulfilled for the response.
9168 */
9169 guided_json?: object;
9170 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9171 /**
9172 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9173 */
9174 raw?: boolean;
9175 /**
9176 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9177 */
9178 stream?: boolean;
9179 /**
9180 * The maximum number of tokens to generate in the response.
9181 */
9182 max_tokens?: number;
9183 /**
9184 * Controls the randomness of the output; higher values produce more random results.
9185 */
9186 temperature?: number;
9187 /**
9188 * 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.
9189 */
9190 top_p?: number;
9191 /**
9192 * 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.
9193 */
9194 top_k?: number;
9195 /**
9196 * Random seed for reproducibility of the generation.
9197 */
9198 seed?: number;
9199 /**
9200 * Penalty for repeated tokens; higher values discourage repetition.
9201 */
9202 repetition_penalty?: number;
9203 /**
9204 * Decreases the likelihood of the model repeating the same lines verbatim.
9205 */
9206 frequency_penalty?: number;
9207 /**
9208 * Increases the likelihood of the model introducing new topics.
9209 */
9210 presence_penalty?: number;
9211}
9212export interface Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Messages_Inner {
9213 /**
9214 * An array of message objects representing the conversation history.
9215 */
9216 messages: {
9217 /**
9218 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9219 */
9220 role?: string;
9221 /**
9222 * The tool call id. If you don't know what to put here you can fall back to 000000001
9223 */
9224 tool_call_id?: string;
9225 content?:
9226 | string
9227 | {
9228 /**
9229 * Type of the content provided
9230 */
9231 type?: string;
9232 text?: string;
9233 image_url?: {
9234 /**
9235 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9236 */
9237 url?: string;
9238 };
9239 }[]
9240 | {
9241 /**
9242 * Type of the content provided
9243 */
9244 type?: string;
9245 text?: string;
9246 image_url?: {
9247 /**
9248 * image uri with data (e.g. data:image/jpeg;base64,/9j/...). HTTP URL will not be accepted
9249 */
9250 url?: string;
9251 };
9252 };
9253 }[];
9254 functions?: {
9255 name: string;
9256 code: string;
9257 }[];
9258 /**
9259 * A list of tools available for the assistant to use.
9260 */
9261 tools?: (
9262 | {
9263 /**
9264 * The name of the tool. More descriptive the better.
9265 */
9266 name: string;
9267 /**
9268 * A brief description of what the tool does.
9269 */
9270 description: string;
9271 /**
9272 * Schema defining the parameters accepted by the tool.
9273 */
9274 parameters: {
9275 /**
9276 * The type of the parameters object (usually 'object').
9277 */
9278 type: string;
9279 /**
9280 * List of required parameter names.
9281 */
9282 required?: string[];
9283 /**
9284 * Definitions of each parameter.
9285 */
9286 properties: {
9287 [k: string]: {
9288 /**
9289 * The data type of the parameter.
9290 */
9291 type: string;
9292 /**
9293 * A description of the expected parameter.
9294 */
9295 description: string;
9296 };
9297 };
9298 };
9299 }
9300 | {
9301 /**
9302 * Specifies the type of tool (e.g., 'function').
9303 */
9304 type: string;
9305 /**
9306 * Details of the function tool.
9307 */
9308 function: {
9309 /**
9310 * The name of the function.
9311 */
9312 name: string;
9313 /**
9314 * A brief description of what the function does.
9315 */
9316 description: string;
9317 /**
9318 * Schema defining the parameters accepted by the function.
9319 */
9320 parameters: {
9321 /**
9322 * The type of the parameters object (usually 'object').
9323 */
9324 type: string;
9325 /**
9326 * List of required parameter names.
9327 */
9328 required?: string[];
9329 /**
9330 * Definitions of each parameter.
9331 */
9332 properties: {
9333 [k: string]: {
9334 /**
9335 * The data type of the parameter.
9336 */
9337 type: string;
9338 /**
9339 * A description of the expected parameter.
9340 */
9341 description: string;
9342 };
9343 };
9344 };
9345 };
9346 }
9347 )[];
9348 response_format?: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_JSON_Mode;
9349 /**
9350 * JSON schema that should be fufilled for the response.
9351 */
9352 guided_json?: object;
9353 /**
9354 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9355 */
9356 raw?: boolean;
9357 /**
9358 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9359 */
9360 stream?: boolean;
9361 /**
9362 * The maximum number of tokens to generate in the response.
9363 */
9364 max_tokens?: number;
9365 /**
9366 * Controls the randomness of the output; higher values produce more random results.
9367 */
9368 temperature?: number;
9369 /**
9370 * 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.
9371 */
9372 top_p?: number;
9373 /**
9374 * 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.
9375 */
9376 top_k?: number;
9377 /**
9378 * Random seed for reproducibility of the generation.
9379 */
9380 seed?: number;
9381 /**
9382 * Penalty for repeated tokens; higher values discourage repetition.
9383 */
9384 repetition_penalty?: number;
9385 /**
9386 * Decreases the likelihood of the model repeating the same lines verbatim.
9387 */
9388 frequency_penalty?: number;
9389 /**
9390 * Increases the likelihood of the model introducing new topics.
9391 */
9392 presence_penalty?: number;
9393}
9394export type Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output = {
9395 /**
9396 * The generated text response from the model
9397 */
9398 response: string;
9399 /**
9400 * Usage statistics for the inference request
9401 */
9402 usage?: {
9403 /**
9404 * Total number of tokens in input
9405 */
9406 prompt_tokens?: number;
9407 /**
9408 * Total number of tokens in output
9409 */
9410 completion_tokens?: number;
9411 /**
9412 * Total number of input and output tokens
9413 */
9414 total_tokens?: number;
9415 };
9416 /**
9417 * An array of tool calls requests made during the response generation
9418 */
9419 tool_calls?: {
9420 /**
9421 * The tool call id.
9422 */
9423 id?: string;
9424 /**
9425 * Specifies the type of tool (e.g., 'function').
9426 */
9427 type?: string;
9428 /**
9429 * Details of the function tool.
9430 */
9431 function?: {
9432 /**
9433 * The name of the tool to be called
9434 */
9435 name?: string;
9436 /**
9437 * The arguments passed to be passed to the tool call request
9438 */
9439 arguments?: object;
9440 };
9441 }[];
9442};
9443export declare abstract class Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct {
9444 inputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Input;
9445 postProcessedOutputs: Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct_Output;
9446}
9447export type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input =
9448 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt
9449 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages
9450 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch;
9451export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt {
9452 /**
9453 * The input text prompt for the model to generate a response.
9454 */
9455 prompt: string;
9456 /**
9457 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9458 */
9459 lora?: string;
9460 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode;
9461 /**
9462 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9463 */
9464 raw?: boolean;
9465 /**
9466 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9467 */
9468 stream?: boolean;
9469 /**
9470 * The maximum number of tokens to generate in the response.
9471 */
9472 max_tokens?: number;
9473 /**
9474 * Controls the randomness of the output; higher values produce more random results.
9475 */
9476 temperature?: number;
9477 /**
9478 * 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.
9479 */
9480 top_p?: number;
9481 /**
9482 * 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.
9483 */
9484 top_k?: number;
9485 /**
9486 * Random seed for reproducibility of the generation.
9487 */
9488 seed?: number;
9489 /**
9490 * Penalty for repeated tokens; higher values discourage repetition.
9491 */
9492 repetition_penalty?: number;
9493 /**
9494 * Decreases the likelihood of the model repeating the same lines verbatim.
9495 */
9496 frequency_penalty?: number;
9497 /**
9498 * Increases the likelihood of the model introducing new topics.
9499 */
9500 presence_penalty?: number;
9501}
9502export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode {
9503 type?: "json_object" | "json_schema";
9504 json_schema?: unknown;
9505}
9506export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages {
9507 /**
9508 * An array of message objects representing the conversation history.
9509 */
9510 messages: {
9511 /**
9512 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9513 */
9514 role: string;
9515 content:
9516 | string
9517 | {
9518 /**
9519 * Type of the content (text)
9520 */
9521 type?: string;
9522 /**
9523 * Text content
9524 */
9525 text?: string;
9526 }[];
9527 }[];
9528 functions?: {
9529 name: string;
9530 code: string;
9531 }[];
9532 /**
9533 * A list of tools available for the assistant to use.
9534 */
9535 tools?: (
9536 | {
9537 /**
9538 * The name of the tool. More descriptive the better.
9539 */
9540 name: string;
9541 /**
9542 * A brief description of what the tool does.
9543 */
9544 description: string;
9545 /**
9546 * Schema defining the parameters accepted by the tool.
9547 */
9548 parameters: {
9549 /**
9550 * The type of the parameters object (usually 'object').
9551 */
9552 type: string;
9553 /**
9554 * List of required parameter names.
9555 */
9556 required?: string[];
9557 /**
9558 * Definitions of each parameter.
9559 */
9560 properties: {
9561 [k: string]: {
9562 /**
9563 * The data type of the parameter.
9564 */
9565 type: string;
9566 /**
9567 * A description of the expected parameter.
9568 */
9569 description: string;
9570 };
9571 };
9572 };
9573 }
9574 | {
9575 /**
9576 * Specifies the type of tool (e.g., 'function').
9577 */
9578 type: string;
9579 /**
9580 * Details of the function tool.
9581 */
9582 function: {
9583 /**
9584 * The name of the function.
9585 */
9586 name: string;
9587 /**
9588 * A brief description of what the function does.
9589 */
9590 description: string;
9591 /**
9592 * Schema defining the parameters accepted by the function.
9593 */
9594 parameters: {
9595 /**
9596 * The type of the parameters object (usually 'object').
9597 */
9598 type: string;
9599 /**
9600 * List of required parameter names.
9601 */
9602 required?: string[];
9603 /**
9604 * Definitions of each parameter.
9605 */
9606 properties: {
9607 [k: string]: {
9608 /**
9609 * The data type of the parameter.
9610 */
9611 type: string;
9612 /**
9613 * A description of the expected parameter.
9614 */
9615 description: string;
9616 };
9617 };
9618 };
9619 };
9620 }
9621 )[];
9622 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1;
9623 /**
9624 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9625 */
9626 raw?: boolean;
9627 /**
9628 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9629 */
9630 stream?: boolean;
9631 /**
9632 * The maximum number of tokens to generate in the response.
9633 */
9634 max_tokens?: number;
9635 /**
9636 * Controls the randomness of the output; higher values produce more random results.
9637 */
9638 temperature?: number;
9639 /**
9640 * 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.
9641 */
9642 top_p?: number;
9643 /**
9644 * 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.
9645 */
9646 top_k?: number;
9647 /**
9648 * Random seed for reproducibility of the generation.
9649 */
9650 seed?: number;
9651 /**
9652 * Penalty for repeated tokens; higher values discourage repetition.
9653 */
9654 repetition_penalty?: number;
9655 /**
9656 * Decreases the likelihood of the model repeating the same lines verbatim.
9657 */
9658 frequency_penalty?: number;
9659 /**
9660 * Increases the likelihood of the model introducing new topics.
9661 */
9662 presence_penalty?: number;
9663}
9664export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_1 {
9665 type?: "json_object" | "json_schema";
9666 json_schema?: unknown;
9667}
9668export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Async_Batch {
9669 requests: (
9670 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1
9671 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1
9672 )[];
9673}
9674export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Prompt_1 {
9675 /**
9676 * The input text prompt for the model to generate a response.
9677 */
9678 prompt: string;
9679 /**
9680 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
9681 */
9682 lora?: string;
9683 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2;
9684 /**
9685 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9686 */
9687 raw?: boolean;
9688 /**
9689 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9690 */
9691 stream?: boolean;
9692 /**
9693 * The maximum number of tokens to generate in the response.
9694 */
9695 max_tokens?: number;
9696 /**
9697 * Controls the randomness of the output; higher values produce more random results.
9698 */
9699 temperature?: number;
9700 /**
9701 * 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.
9702 */
9703 top_p?: number;
9704 /**
9705 * 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.
9706 */
9707 top_k?: number;
9708 /**
9709 * Random seed for reproducibility of the generation.
9710 */
9711 seed?: number;
9712 /**
9713 * Penalty for repeated tokens; higher values discourage repetition.
9714 */
9715 repetition_penalty?: number;
9716 /**
9717 * Decreases the likelihood of the model repeating the same lines verbatim.
9718 */
9719 frequency_penalty?: number;
9720 /**
9721 * Increases the likelihood of the model introducing new topics.
9722 */
9723 presence_penalty?: number;
9724}
9725export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_2 {
9726 type?: "json_object" | "json_schema";
9727 json_schema?: unknown;
9728}
9729export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Messages_1 {
9730 /**
9731 * An array of message objects representing the conversation history.
9732 */
9733 messages: {
9734 /**
9735 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
9736 */
9737 role: string;
9738 content:
9739 | string
9740 | {
9741 /**
9742 * Type of the content (text)
9743 */
9744 type?: string;
9745 /**
9746 * Text content
9747 */
9748 text?: string;
9749 }[];
9750 }[];
9751 functions?: {
9752 name: string;
9753 code: string;
9754 }[];
9755 /**
9756 * A list of tools available for the assistant to use.
9757 */
9758 tools?: (
9759 | {
9760 /**
9761 * The name of the tool. More descriptive the better.
9762 */
9763 name: string;
9764 /**
9765 * A brief description of what the tool does.
9766 */
9767 description: string;
9768 /**
9769 * Schema defining the parameters accepted by the tool.
9770 */
9771 parameters: {
9772 /**
9773 * The type of the parameters object (usually 'object').
9774 */
9775 type: string;
9776 /**
9777 * List of required parameter names.
9778 */
9779 required?: string[];
9780 /**
9781 * Definitions of each parameter.
9782 */
9783 properties: {
9784 [k: string]: {
9785 /**
9786 * The data type of the parameter.
9787 */
9788 type: string;
9789 /**
9790 * A description of the expected parameter.
9791 */
9792 description: string;
9793 };
9794 };
9795 };
9796 }
9797 | {
9798 /**
9799 * Specifies the type of tool (e.g., 'function').
9800 */
9801 type: string;
9802 /**
9803 * Details of the function tool.
9804 */
9805 function: {
9806 /**
9807 * The name of the function.
9808 */
9809 name: string;
9810 /**
9811 * A brief description of what the function does.
9812 */
9813 description: string;
9814 /**
9815 * Schema defining the parameters accepted by the function.
9816 */
9817 parameters: {
9818 /**
9819 * The type of the parameters object (usually 'object').
9820 */
9821 type: string;
9822 /**
9823 * List of required parameter names.
9824 */
9825 required?: string[];
9826 /**
9827 * Definitions of each parameter.
9828 */
9829 properties: {
9830 [k: string]: {
9831 /**
9832 * The data type of the parameter.
9833 */
9834 type: string;
9835 /**
9836 * A description of the expected parameter.
9837 */
9838 description: string;
9839 };
9840 };
9841 };
9842 };
9843 }
9844 )[];
9845 response_format?: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3;
9846 /**
9847 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
9848 */
9849 raw?: boolean;
9850 /**
9851 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
9852 */
9853 stream?: boolean;
9854 /**
9855 * The maximum number of tokens to generate in the response.
9856 */
9857 max_tokens?: number;
9858 /**
9859 * Controls the randomness of the output; higher values produce more random results.
9860 */
9861 temperature?: number;
9862 /**
9863 * 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.
9864 */
9865 top_p?: number;
9866 /**
9867 * 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.
9868 */
9869 top_k?: number;
9870 /**
9871 * Random seed for reproducibility of the generation.
9872 */
9873 seed?: number;
9874 /**
9875 * Penalty for repeated tokens; higher values discourage repetition.
9876 */
9877 repetition_penalty?: number;
9878 /**
9879 * Decreases the likelihood of the model repeating the same lines verbatim.
9880 */
9881 frequency_penalty?: number;
9882 /**
9883 * Increases the likelihood of the model introducing new topics.
9884 */
9885 presence_penalty?: number;
9886}
9887export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_JSON_Mode_3 {
9888 type?: "json_object" | "json_schema";
9889 json_schema?: unknown;
9890}
9891export type Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output =
9892 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response
9893 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response
9894 | string
9895 | Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse;
9896export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Chat_Completion_Response {
9897 /**
9898 * Unique identifier for the completion
9899 */
9900 id?: string;
9901 /**
9902 * Object type identifier
9903 */
9904 object?: "chat.completion";
9905 /**
9906 * Unix timestamp of when the completion was created
9907 */
9908 created?: number;
9909 /**
9910 * Model used for the completion
9911 */
9912 model?: string;
9913 /**
9914 * List of completion choices
9915 */
9916 choices?: {
9917 /**
9918 * Index of the choice in the list
9919 */
9920 index?: number;
9921 /**
9922 * The message generated by the model
9923 */
9924 message?: {
9925 /**
9926 * Role of the message author
9927 */
9928 role: string;
9929 /**
9930 * The content of the message
9931 */
9932 content: string;
9933 /**
9934 * Internal reasoning content (if available)
9935 */
9936 reasoning_content?: string;
9937 /**
9938 * Tool calls made by the assistant
9939 */
9940 tool_calls?: {
9941 /**
9942 * Unique identifier for the tool call
9943 */
9944 id: string;
9945 /**
9946 * Type of tool call
9947 */
9948 type: "function";
9949 function: {
9950 /**
9951 * Name of the function to call
9952 */
9953 name: string;
9954 /**
9955 * JSON string of arguments for the function
9956 */
9957 arguments: string;
9958 };
9959 }[];
9960 };
9961 /**
9962 * Reason why the model stopped generating
9963 */
9964 finish_reason?: string;
9965 /**
9966 * Stop reason (may be null)
9967 */
9968 stop_reason?: string | null;
9969 /**
9970 * Log probabilities (if requested)
9971 */
9972 logprobs?: {} | null;
9973 }[];
9974 /**
9975 * Usage statistics for the inference request
9976 */
9977 usage?: {
9978 /**
9979 * Total number of tokens in input
9980 */
9981 prompt_tokens?: number;
9982 /**
9983 * Total number of tokens in output
9984 */
9985 completion_tokens?: number;
9986 /**
9987 * Total number of input and output tokens
9988 */
9989 total_tokens?: number;
9990 };
9991 /**
9992 * Log probabilities for the prompt (if requested)
9993 */
9994 prompt_logprobs?: {} | null;
9995}
9996export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Text_Completion_Response {
9997 /**
9998 * Unique identifier for the completion
9999 */
10000 id?: string;
10001 /**
10002 * Object type identifier
10003 */
10004 object?: "text_completion";
10005 /**
10006 * Unix timestamp of when the completion was created
10007 */
10008 created?: number;
10009 /**
10010 * Model used for the completion
10011 */
10012 model?: string;
10013 /**
10014 * List of completion choices
10015 */
10016 choices?: {
10017 /**
10018 * Index of the choice in the list
10019 */
10020 index: number;
10021 /**
10022 * The generated text completion
10023 */
10024 text: string;
10025 /**
10026 * Reason why the model stopped generating
10027 */
10028 finish_reason: string;
10029 /**
10030 * Stop reason (may be null)
10031 */
10032 stop_reason?: string | null;
10033 /**
10034 * Log probabilities (if requested)
10035 */
10036 logprobs?: {} | null;
10037 /**
10038 * Log probabilities for the prompt (if requested)
10039 */
10040 prompt_logprobs?: {} | null;
10041 }[];
10042 /**
10043 * Usage statistics for the inference request
10044 */
10045 usage?: {
10046 /**
10047 * Total number of tokens in input
10048 */
10049 prompt_tokens?: number;
10050 /**
10051 * Total number of tokens in output
10052 */
10053 completion_tokens?: number;
10054 /**
10055 * Total number of input and output tokens
10056 */
10057 total_tokens?: number;
10058 };
10059}
10060export interface Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_AsyncResponse {
10061 /**
10062 * The async request id that can be used to obtain the results.
10063 */
10064 request_id?: string;
10065}
10066export declare abstract class Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8 {
10067 inputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Input;
10068 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8_Output;
10069}
10070export interface Ai_Cf_Deepgram_Nova_3_Input {
10071 audio: {
10072 body: object;
10073 contentType: string;
10074 };
10075 /**
10076 * 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.
10077 */
10078 custom_topic_mode?: "extended" | "strict";
10079 /**
10080 * Custom topics you want the model to detect within your input audio or text if present Submit up to 100
10081 */
10082 custom_topic?: string;
10083 /**
10084 * 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
10085 */
10086 custom_intent_mode?: "extended" | "strict";
10087 /**
10088 * Custom intents you want the model to detect within your input audio if present
10089 */
10090 custom_intent?: string;
10091 /**
10092 * Identifies and extracts key entities from content in submitted audio
10093 */
10094 detect_entities?: boolean;
10095 /**
10096 * Identifies the dominant language spoken in submitted audio
10097 */
10098 detect_language?: boolean;
10099 /**
10100 * Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0
10101 */
10102 diarize?: boolean;
10103 /**
10104 * Identify and extract key entities from content in submitted audio
10105 */
10106 dictation?: boolean;
10107 /**
10108 * Specify the expected encoding of your submitted audio
10109 */
10110 encoding?:
10111 | "linear16"
10112 | "flac"
10113 | "mulaw"
10114 | "amr-nb"
10115 | "amr-wb"
10116 | "opus"
10117 | "speex"
10118 | "g729";
10119 /**
10120 * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing
10121 */
10122 extra?: string;
10123 /**
10124 * Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'
10125 */
10126 filler_words?: boolean;
10127 /**
10128 * Key term prompting can boost or suppress specialized terminology and brands.
10129 */
10130 keyterm?: string;
10131 /**
10132 * Keywords can boost or suppress specialized terminology and brands.
10133 */
10134 keywords?: string;
10135 /**
10136 * 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.
10137 */
10138 language?: string;
10139 /**
10140 * Spoken measurements will be converted to their corresponding abbreviations.
10141 */
10142 measurements?: boolean;
10143 /**
10144 * 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.
10145 */
10146 mip_opt_out?: boolean;
10147 /**
10148 * Mode of operation for the model representing broad area of topic that will be talked about in the supplied audio
10149 */
10150 mode?: "general" | "medical" | "finance";
10151 /**
10152 * Transcribe each audio channel independently.
10153 */
10154 multichannel?: boolean;
10155 /**
10156 * Numerals converts numbers from written format to numerical format.
10157 */
10158 numerals?: boolean;
10159 /**
10160 * Splits audio into paragraphs to improve transcript readability.
10161 */
10162 paragraphs?: boolean;
10163 /**
10164 * Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.
10165 */
10166 profanity_filter?: boolean;
10167 /**
10168 * Add punctuation and capitalization to the transcript.
10169 */
10170 punctuate?: boolean;
10171 /**
10172 * Redaction removes sensitive information from your transcripts.
10173 */
10174 redact?: string;
10175 /**
10176 * Search for terms or phrases in submitted audio and replaces them.
10177 */
10178 replace?: string;
10179 /**
10180 * Search for terms or phrases in submitted audio.
10181 */
10182 search?: string;
10183 /**
10184 * Recognizes the sentiment throughout a transcript or text.
10185 */
10186 sentiment?: boolean;
10187 /**
10188 * Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.
10189 */
10190 smart_format?: boolean;
10191 /**
10192 * Detect topics throughout a transcript or text.
10193 */
10194 topics?: boolean;
10195 /**
10196 * Segments speech into meaningful semantic units.
10197 */
10198 utterances?: boolean;
10199 /**
10200 * Seconds to wait before detecting a pause between words in submitted audio.
10201 */
10202 utt_split?: number;
10203 /**
10204 * The number of channels in the submitted audio
10205 */
10206 channels?: number;
10207 /**
10208 * 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.
10209 */
10210 interim_results?: boolean;
10211 /**
10212 * 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
10213 */
10214 endpointing?: string;
10215 /**
10216 * Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.
10217 */
10218 vad_events?: boolean;
10219 /**
10220 * 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.
10221 */
10222 utterance_end_ms?: boolean;
10223}
10224export interface Ai_Cf_Deepgram_Nova_3_Output {
10225 results?: {
10226 channels?: {
10227 alternatives?: {
10228 confidence?: number;
10229 transcript?: string;
10230 words?: {
10231 confidence?: number;
10232 end?: number;
10233 start?: number;
10234 word?: string;
10235 }[];
10236 }[];
10237 }[];
10238 summary?: {
10239 result?: string;
10240 short?: string;
10241 };
10242 sentiments?: {
10243 segments?: {
10244 text?: string;
10245 start_word?: number;
10246 end_word?: number;
10247 sentiment?: string;
10248 sentiment_score?: number;
10249 }[];
10250 average?: {
10251 sentiment?: string;
10252 sentiment_score?: number;
10253 };
10254 };
10255 };
10256}
10257export declare abstract class Base_Ai_Cf_Deepgram_Nova_3 {
10258 inputs: Ai_Cf_Deepgram_Nova_3_Input;
10259 postProcessedOutputs: Ai_Cf_Deepgram_Nova_3_Output;
10260}
10261export interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input {
10262 queries?: string | string[];
10263 /**
10264 * Optional instruction for the task
10265 */
10266 instruction?: string;
10267 documents?: string | string[];
10268 text?: string | string[];
10269}
10270export interface Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output {
10271 data?: number[][];
10272 shape?: number[];
10273}
10274export declare abstract class Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B {
10275 inputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Input;
10276 postProcessedOutputs: Ai_Cf_Qwen_Qwen3_Embedding_0_6B_Output;
10277}
10278export type Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input =
10279 | {
10280 /**
10281 * readable stream with audio data and content-type specified for that data
10282 */
10283 audio: {
10284 body: object;
10285 contentType: string;
10286 };
10287 /**
10288 * type of data PCM data that's sent to the inference server as raw array
10289 */
10290 dtype?: "uint8" | "float32" | "float64";
10291 }
10292 | {
10293 /**
10294 * base64 encoded audio data
10295 */
10296 audio: string;
10297 /**
10298 * type of data PCM data that's sent to the inference server as raw array
10299 */
10300 dtype?: "uint8" | "float32" | "float64";
10301 };
10302export interface Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output {
10303 /**
10304 * if true, end-of-turn was detected
10305 */
10306 is_complete?: boolean;
10307 /**
10308 * probability of the end-of-turn detection
10309 */
10310 probability?: number;
10311}
10312export declare abstract class Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2 {
10313 inputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Input;
10314 postProcessedOutputs: Ai_Cf_Pipecat_Ai_Smart_Turn_V2_Output;
10315}
10316export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_120B {
10317 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
10318 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
10319}
10320export declare abstract class Base_Ai_Cf_Openai_Gpt_Oss_20B {
10321 inputs: XOR<ResponsesInput, ChatCompletionsInput>;
10322 postProcessedOutputs: XOR<ResponsesOutput, ChatCompletionsOutput>;
10323}
10324export interface Ai_Cf_Leonardo_Phoenix_1_0_Input {
10325 /**
10326 * A text description of the image you want to generate.
10327 */
10328 prompt: string;
10329 /**
10330 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
10331 */
10332 guidance?: number;
10333 /**
10334 * Random seed for reproducibility of the image generation
10335 */
10336 seed?: number;
10337 /**
10338 * The height of the generated image in pixels
10339 */
10340 height?: number;
10341 /**
10342 * The width of the generated image in pixels
10343 */
10344 width?: number;
10345 /**
10346 * The number of diffusion steps; higher values can improve quality but take longer
10347 */
10348 num_steps?: number;
10349 /**
10350 * Specify what to exclude from the generated images
10351 */
10352 negative_prompt?: string;
10353}
10354/**
10355 * The generated image in JPEG format
10356 */
10357export type Ai_Cf_Leonardo_Phoenix_1_0_Output = string;
10358export declare abstract class Base_Ai_Cf_Leonardo_Phoenix_1_0 {
10359 inputs: Ai_Cf_Leonardo_Phoenix_1_0_Input;
10360 postProcessedOutputs: Ai_Cf_Leonardo_Phoenix_1_0_Output;
10361}
10362export interface Ai_Cf_Leonardo_Lucid_Origin_Input {
10363 /**
10364 * A text description of the image you want to generate.
10365 */
10366 prompt: string;
10367 /**
10368 * Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt
10369 */
10370 guidance?: number;
10371 /**
10372 * Random seed for reproducibility of the image generation
10373 */
10374 seed?: number;
10375 /**
10376 * The height of the generated image in pixels
10377 */
10378 height?: number;
10379 /**
10380 * The width of the generated image in pixels
10381 */
10382 width?: number;
10383 /**
10384 * The number of diffusion steps; higher values can improve quality but take longer
10385 */
10386 num_steps?: number;
10387 /**
10388 * The number of diffusion steps; higher values can improve quality but take longer
10389 */
10390 steps?: number;
10391}
10392export interface Ai_Cf_Leonardo_Lucid_Origin_Output {
10393 /**
10394 * The generated image in Base64 format.
10395 */
10396 image?: string;
10397}
10398export declare abstract class Base_Ai_Cf_Leonardo_Lucid_Origin {
10399 inputs: Ai_Cf_Leonardo_Lucid_Origin_Input;
10400 postProcessedOutputs: Ai_Cf_Leonardo_Lucid_Origin_Output;
10401}
10402export interface Ai_Cf_Deepgram_Aura_1_Input {
10403 /**
10404 * Speaker used to produce the audio.
10405 */
10406 speaker?:
10407 | "angus"
10408 | "asteria"
10409 | "arcas"
10410 | "orion"
10411 | "orpheus"
10412 | "athena"
10413 | "luna"
10414 | "zeus"
10415 | "perseus"
10416 | "helios"
10417 | "hera"
10418 | "stella";
10419 /**
10420 * Encoding of the output audio.
10421 */
10422 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
10423 /**
10424 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
10425 */
10426 container?: "none" | "wav" | "ogg";
10427 /**
10428 * The text content to be converted to speech
10429 */
10430 text: string;
10431 /**
10432 * 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
10433 */
10434 sample_rate?: number;
10435 /**
10436 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
10437 */
10438 bit_rate?: number;
10439}
10440/**
10441 * The generated audio in MP3 format
10442 */
10443export type Ai_Cf_Deepgram_Aura_1_Output = string;
10444export declare abstract class Base_Ai_Cf_Deepgram_Aura_1 {
10445 inputs: Ai_Cf_Deepgram_Aura_1_Input;
10446 postProcessedOutputs: Ai_Cf_Deepgram_Aura_1_Output;
10447}
10448export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input {
10449 /**
10450 * Input text to translate. Can be a single string or a list of strings.
10451 */
10452 text: string | string[];
10453 /**
10454 * Target langauge to translate to
10455 */
10456 target_language:
10457 | "asm_Beng"
10458 | "awa_Deva"
10459 | "ben_Beng"
10460 | "bho_Deva"
10461 | "brx_Deva"
10462 | "doi_Deva"
10463 | "eng_Latn"
10464 | "gom_Deva"
10465 | "gon_Deva"
10466 | "guj_Gujr"
10467 | "hin_Deva"
10468 | "hne_Deva"
10469 | "kan_Knda"
10470 | "kas_Arab"
10471 | "kas_Deva"
10472 | "kha_Latn"
10473 | "lus_Latn"
10474 | "mag_Deva"
10475 | "mai_Deva"
10476 | "mal_Mlym"
10477 | "mar_Deva"
10478 | "mni_Beng"
10479 | "mni_Mtei"
10480 | "npi_Deva"
10481 | "ory_Orya"
10482 | "pan_Guru"
10483 | "san_Deva"
10484 | "sat_Olck"
10485 | "snd_Arab"
10486 | "snd_Deva"
10487 | "tam_Taml"
10488 | "tel_Telu"
10489 | "urd_Arab"
10490 | "unr_Deva";
10491}
10492export interface Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output {
10493 /**
10494 * Translated texts
10495 */
10496 translations: string[];
10497}
10498export declare abstract class Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B {
10499 inputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Input;
10500 postProcessedOutputs: Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B_Output;
10501}
10502export type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input =
10503 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt
10504 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages
10505 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch;
10506export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt {
10507 /**
10508 * The input text prompt for the model to generate a response.
10509 */
10510 prompt: string;
10511 /**
10512 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10513 */
10514 lora?: string;
10515 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode;
10516 /**
10517 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10518 */
10519 raw?: boolean;
10520 /**
10521 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10522 */
10523 stream?: boolean;
10524 /**
10525 * The maximum number of tokens to generate in the response.
10526 */
10527 max_tokens?: number;
10528 /**
10529 * Controls the randomness of the output; higher values produce more random results.
10530 */
10531 temperature?: number;
10532 /**
10533 * 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.
10534 */
10535 top_p?: number;
10536 /**
10537 * 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.
10538 */
10539 top_k?: number;
10540 /**
10541 * Random seed for reproducibility of the generation.
10542 */
10543 seed?: number;
10544 /**
10545 * Penalty for repeated tokens; higher values discourage repetition.
10546 */
10547 repetition_penalty?: number;
10548 /**
10549 * Decreases the likelihood of the model repeating the same lines verbatim.
10550 */
10551 frequency_penalty?: number;
10552 /**
10553 * Increases the likelihood of the model introducing new topics.
10554 */
10555 presence_penalty?: number;
10556}
10557export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode {
10558 type?: "json_object" | "json_schema";
10559 json_schema?: unknown;
10560}
10561export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages {
10562 /**
10563 * An array of message objects representing the conversation history.
10564 */
10565 messages: {
10566 /**
10567 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10568 */
10569 role: string;
10570 content:
10571 | string
10572 | {
10573 /**
10574 * Type of the content (text)
10575 */
10576 type?: string;
10577 /**
10578 * Text content
10579 */
10580 text?: string;
10581 }[];
10582 }[];
10583 functions?: {
10584 name: string;
10585 code: string;
10586 }[];
10587 /**
10588 * A list of tools available for the assistant to use.
10589 */
10590 tools?: (
10591 | {
10592 /**
10593 * The name of the tool. More descriptive the better.
10594 */
10595 name: string;
10596 /**
10597 * A brief description of what the tool does.
10598 */
10599 description: string;
10600 /**
10601 * Schema defining the parameters accepted by the tool.
10602 */
10603 parameters: {
10604 /**
10605 * The type of the parameters object (usually 'object').
10606 */
10607 type: string;
10608 /**
10609 * List of required parameter names.
10610 */
10611 required?: string[];
10612 /**
10613 * Definitions of each parameter.
10614 */
10615 properties: {
10616 [k: string]: {
10617 /**
10618 * The data type of the parameter.
10619 */
10620 type: string;
10621 /**
10622 * A description of the expected parameter.
10623 */
10624 description: string;
10625 };
10626 };
10627 };
10628 }
10629 | {
10630 /**
10631 * Specifies the type of tool (e.g., 'function').
10632 */
10633 type: string;
10634 /**
10635 * Details of the function tool.
10636 */
10637 function: {
10638 /**
10639 * The name of the function.
10640 */
10641 name: string;
10642 /**
10643 * A brief description of what the function does.
10644 */
10645 description: string;
10646 /**
10647 * Schema defining the parameters accepted by the function.
10648 */
10649 parameters: {
10650 /**
10651 * The type of the parameters object (usually 'object').
10652 */
10653 type: string;
10654 /**
10655 * List of required parameter names.
10656 */
10657 required?: string[];
10658 /**
10659 * Definitions of each parameter.
10660 */
10661 properties: {
10662 [k: string]: {
10663 /**
10664 * The data type of the parameter.
10665 */
10666 type: string;
10667 /**
10668 * A description of the expected parameter.
10669 */
10670 description: string;
10671 };
10672 };
10673 };
10674 };
10675 }
10676 )[];
10677 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1;
10678 /**
10679 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10680 */
10681 raw?: boolean;
10682 /**
10683 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10684 */
10685 stream?: boolean;
10686 /**
10687 * The maximum number of tokens to generate in the response.
10688 */
10689 max_tokens?: number;
10690 /**
10691 * Controls the randomness of the output; higher values produce more random results.
10692 */
10693 temperature?: number;
10694 /**
10695 * 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.
10696 */
10697 top_p?: number;
10698 /**
10699 * 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.
10700 */
10701 top_k?: number;
10702 /**
10703 * Random seed for reproducibility of the generation.
10704 */
10705 seed?: number;
10706 /**
10707 * Penalty for repeated tokens; higher values discourage repetition.
10708 */
10709 repetition_penalty?: number;
10710 /**
10711 * Decreases the likelihood of the model repeating the same lines verbatim.
10712 */
10713 frequency_penalty?: number;
10714 /**
10715 * Increases the likelihood of the model introducing new topics.
10716 */
10717 presence_penalty?: number;
10718}
10719export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_1 {
10720 type?: "json_object" | "json_schema";
10721 json_schema?: unknown;
10722}
10723export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Async_Batch {
10724 requests: (
10725 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1
10726 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1
10727 )[];
10728}
10729export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Prompt_1 {
10730 /**
10731 * The input text prompt for the model to generate a response.
10732 */
10733 prompt: string;
10734 /**
10735 * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
10736 */
10737 lora?: string;
10738 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2;
10739 /**
10740 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10741 */
10742 raw?: boolean;
10743 /**
10744 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10745 */
10746 stream?: boolean;
10747 /**
10748 * The maximum number of tokens to generate in the response.
10749 */
10750 max_tokens?: number;
10751 /**
10752 * Controls the randomness of the output; higher values produce more random results.
10753 */
10754 temperature?: number;
10755 /**
10756 * 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.
10757 */
10758 top_p?: number;
10759 /**
10760 * 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.
10761 */
10762 top_k?: number;
10763 /**
10764 * Random seed for reproducibility of the generation.
10765 */
10766 seed?: number;
10767 /**
10768 * Penalty for repeated tokens; higher values discourage repetition.
10769 */
10770 repetition_penalty?: number;
10771 /**
10772 * Decreases the likelihood of the model repeating the same lines verbatim.
10773 */
10774 frequency_penalty?: number;
10775 /**
10776 * Increases the likelihood of the model introducing new topics.
10777 */
10778 presence_penalty?: number;
10779}
10780export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_2 {
10781 type?: "json_object" | "json_schema";
10782 json_schema?: unknown;
10783}
10784export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Messages_1 {
10785 /**
10786 * An array of message objects representing the conversation history.
10787 */
10788 messages: {
10789 /**
10790 * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
10791 */
10792 role: string;
10793 content:
10794 | string
10795 | {
10796 /**
10797 * Type of the content (text)
10798 */
10799 type?: string;
10800 /**
10801 * Text content
10802 */
10803 text?: string;
10804 }[];
10805 }[];
10806 functions?: {
10807 name: string;
10808 code: string;
10809 }[];
10810 /**
10811 * A list of tools available for the assistant to use.
10812 */
10813 tools?: (
10814 | {
10815 /**
10816 * The name of the tool. More descriptive the better.
10817 */
10818 name: string;
10819 /**
10820 * A brief description of what the tool does.
10821 */
10822 description: string;
10823 /**
10824 * Schema defining the parameters accepted by the tool.
10825 */
10826 parameters: {
10827 /**
10828 * The type of the parameters object (usually 'object').
10829 */
10830 type: string;
10831 /**
10832 * List of required parameter names.
10833 */
10834 required?: string[];
10835 /**
10836 * Definitions of each parameter.
10837 */
10838 properties: {
10839 [k: string]: {
10840 /**
10841 * The data type of the parameter.
10842 */
10843 type: string;
10844 /**
10845 * A description of the expected parameter.
10846 */
10847 description: string;
10848 };
10849 };
10850 };
10851 }
10852 | {
10853 /**
10854 * Specifies the type of tool (e.g., 'function').
10855 */
10856 type: string;
10857 /**
10858 * Details of the function tool.
10859 */
10860 function: {
10861 /**
10862 * The name of the function.
10863 */
10864 name: string;
10865 /**
10866 * A brief description of what the function does.
10867 */
10868 description: string;
10869 /**
10870 * Schema defining the parameters accepted by the function.
10871 */
10872 parameters: {
10873 /**
10874 * The type of the parameters object (usually 'object').
10875 */
10876 type: string;
10877 /**
10878 * List of required parameter names.
10879 */
10880 required?: string[];
10881 /**
10882 * Definitions of each parameter.
10883 */
10884 properties: {
10885 [k: string]: {
10886 /**
10887 * The data type of the parameter.
10888 */
10889 type: string;
10890 /**
10891 * A description of the expected parameter.
10892 */
10893 description: string;
10894 };
10895 };
10896 };
10897 };
10898 }
10899 )[];
10900 response_format?: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3;
10901 /**
10902 * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
10903 */
10904 raw?: boolean;
10905 /**
10906 * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
10907 */
10908 stream?: boolean;
10909 /**
10910 * The maximum number of tokens to generate in the response.
10911 */
10912 max_tokens?: number;
10913 /**
10914 * Controls the randomness of the output; higher values produce more random results.
10915 */
10916 temperature?: number;
10917 /**
10918 * 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.
10919 */
10920 top_p?: number;
10921 /**
10922 * 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.
10923 */
10924 top_k?: number;
10925 /**
10926 * Random seed for reproducibility of the generation.
10927 */
10928 seed?: number;
10929 /**
10930 * Penalty for repeated tokens; higher values discourage repetition.
10931 */
10932 repetition_penalty?: number;
10933 /**
10934 * Decreases the likelihood of the model repeating the same lines verbatim.
10935 */
10936 frequency_penalty?: number;
10937 /**
10938 * Increases the likelihood of the model introducing new topics.
10939 */
10940 presence_penalty?: number;
10941}
10942export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_JSON_Mode_3 {
10943 type?: "json_object" | "json_schema";
10944 json_schema?: unknown;
10945}
10946export type Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output =
10947 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response
10948 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response
10949 | string
10950 | Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse;
10951export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Chat_Completion_Response {
10952 /**
10953 * Unique identifier for the completion
10954 */
10955 id?: string;
10956 /**
10957 * Object type identifier
10958 */
10959 object?: "chat.completion";
10960 /**
10961 * Unix timestamp of when the completion was created
10962 */
10963 created?: number;
10964 /**
10965 * Model used for the completion
10966 */
10967 model?: string;
10968 /**
10969 * List of completion choices
10970 */
10971 choices?: {
10972 /**
10973 * Index of the choice in the list
10974 */
10975 index?: number;
10976 /**
10977 * The message generated by the model
10978 */
10979 message?: {
10980 /**
10981 * Role of the message author
10982 */
10983 role: string;
10984 /**
10985 * The content of the message
10986 */
10987 content: string;
10988 /**
10989 * Internal reasoning content (if available)
10990 */
10991 reasoning_content?: string;
10992 /**
10993 * Tool calls made by the assistant
10994 */
10995 tool_calls?: {
10996 /**
10997 * Unique identifier for the tool call
10998 */
10999 id: string;
11000 /**
11001 * Type of tool call
11002 */
11003 type: "function";
11004 function: {
11005 /**
11006 * Name of the function to call
11007 */
11008 name: string;
11009 /**
11010 * JSON string of arguments for the function
11011 */
11012 arguments: string;
11013 };
11014 }[];
11015 };
11016 /**
11017 * Reason why the model stopped generating
11018 */
11019 finish_reason?: string;
11020 /**
11021 * Stop reason (may be null)
11022 */
11023 stop_reason?: string | null;
11024 /**
11025 * Log probabilities (if requested)
11026 */
11027 logprobs?: {} | null;
11028 }[];
11029 /**
11030 * Usage statistics for the inference request
11031 */
11032 usage?: {
11033 /**
11034 * Total number of tokens in input
11035 */
11036 prompt_tokens?: number;
11037 /**
11038 * Total number of tokens in output
11039 */
11040 completion_tokens?: number;
11041 /**
11042 * Total number of input and output tokens
11043 */
11044 total_tokens?: number;
11045 };
11046 /**
11047 * Log probabilities for the prompt (if requested)
11048 */
11049 prompt_logprobs?: {} | null;
11050}
11051export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Text_Completion_Response {
11052 /**
11053 * Unique identifier for the completion
11054 */
11055 id?: string;
11056 /**
11057 * Object type identifier
11058 */
11059 object?: "text_completion";
11060 /**
11061 * Unix timestamp of when the completion was created
11062 */
11063 created?: number;
11064 /**
11065 * Model used for the completion
11066 */
11067 model?: string;
11068 /**
11069 * List of completion choices
11070 */
11071 choices?: {
11072 /**
11073 * Index of the choice in the list
11074 */
11075 index: number;
11076 /**
11077 * The generated text completion
11078 */
11079 text: string;
11080 /**
11081 * Reason why the model stopped generating
11082 */
11083 finish_reason: string;
11084 /**
11085 * Stop reason (may be null)
11086 */
11087 stop_reason?: string | null;
11088 /**
11089 * Log probabilities (if requested)
11090 */
11091 logprobs?: {} | null;
11092 /**
11093 * Log probabilities for the prompt (if requested)
11094 */
11095 prompt_logprobs?: {} | null;
11096 }[];
11097 /**
11098 * Usage statistics for the inference request
11099 */
11100 usage?: {
11101 /**
11102 * Total number of tokens in input
11103 */
11104 prompt_tokens?: number;
11105 /**
11106 * Total number of tokens in output
11107 */
11108 completion_tokens?: number;
11109 /**
11110 * Total number of input and output tokens
11111 */
11112 total_tokens?: number;
11113 };
11114}
11115export interface Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_AsyncResponse {
11116 /**
11117 * The async request id that can be used to obtain the results.
11118 */
11119 request_id?: string;
11120}
11121export declare abstract class Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It {
11122 inputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Input;
11123 postProcessedOutputs: Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It_Output;
11124}
11125export interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Input {
11126 /**
11127 * Input text to embed. Can be a single string or a list of strings.
11128 */
11129 text: string | string[];
11130}
11131export interface Ai_Cf_Pfnet_Plamo_Embedding_1B_Output {
11132 /**
11133 * Embedding vectors, where each vector is a list of floats.
11134 */
11135 data: number[][];
11136 /**
11137 * Shape of the embedding data as [number_of_embeddings, embedding_dimension].
11138 *
11139 * @minItems 2
11140 * @maxItems 2
11141 */
11142 shape: [number, number];
11143}
11144export declare abstract class Base_Ai_Cf_Pfnet_Plamo_Embedding_1B {
11145 inputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Input;
11146 postProcessedOutputs: Ai_Cf_Pfnet_Plamo_Embedding_1B_Output;
11147}
11148export interface Ai_Cf_Deepgram_Flux_Input {
11149 /**
11150 * Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.
11151 */
11152 encoding: "linear16";
11153 /**
11154 * Sample rate of the audio stream in Hz.
11155 */
11156 sample_rate: string;
11157 /**
11158 * 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.
11159 */
11160 eager_eot_threshold?: string;
11161 /**
11162 * End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.
11163 */
11164 eot_threshold?: string;
11165 /**
11166 * A turn will be finished when this much time has passed after speech, regardless of EOT confidence.
11167 */
11168 eot_timeout_ms?: string;
11169 /**
11170 * Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.
11171 */
11172 keyterm?: string;
11173 /**
11174 * 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
11175 */
11176 mip_opt_out?: "true" | "false";
11177 /**
11178 * Label your requests for the purpose of identification during usage reporting
11179 */
11180 tag?: string;
11181}
11182/**
11183 * Output will be returned as websocket messages.
11184 */
11185export interface Ai_Cf_Deepgram_Flux_Output {
11186 /**
11187 * The unique identifier of the request (uuid)
11188 */
11189 request_id?: string;
11190 /**
11191 * Starts at 0 and increments for each message the server sends to the client.
11192 */
11193 sequence_id?: number;
11194 /**
11195 * The type of event being reported.
11196 */
11197 event?:
11198 | "Update"
11199 | "StartOfTurn"
11200 | "EagerEndOfTurn"
11201 | "TurnResumed"
11202 | "EndOfTurn";
11203 /**
11204 * The index of the current turn
11205 */
11206 turn_index?: number;
11207 /**
11208 * Start time in seconds of the audio range that was transcribed
11209 */
11210 audio_window_start?: number;
11211 /**
11212 * End time in seconds of the audio range that was transcribed
11213 */
11214 audio_window_end?: number;
11215 /**
11216 * Text that was said over the course of the current turn
11217 */
11218 transcript?: string;
11219 /**
11220 * The words in the transcript
11221 */
11222 words?: {
11223 /**
11224 * The individual punctuated, properly-cased word from the transcript
11225 */
11226 word: string;
11227 /**
11228 * Confidence that this word was transcribed correctly
11229 */
11230 confidence: number;
11231 }[];
11232 /**
11233 * Confidence that no more speech is coming in this turn
11234 */
11235 end_of_turn_confidence?: number;
11236}
11237export declare abstract class Base_Ai_Cf_Deepgram_Flux {
11238 inputs: Ai_Cf_Deepgram_Flux_Input;
11239 postProcessedOutputs: Ai_Cf_Deepgram_Flux_Output;
11240}
11241export interface Ai_Cf_Deepgram_Aura_2_En_Input {
11242 /**
11243 * Speaker used to produce the audio.
11244 */
11245 speaker?:
11246 | "amalthea"
11247 | "andromeda"
11248 | "apollo"
11249 | "arcas"
11250 | "aries"
11251 | "asteria"
11252 | "athena"
11253 | "atlas"
11254 | "aurora"
11255 | "callista"
11256 | "cora"
11257 | "cordelia"
11258 | "delia"
11259 | "draco"
11260 | "electra"
11261 | "harmonia"
11262 | "helena"
11263 | "hera"
11264 | "hermes"
11265 | "hyperion"
11266 | "iris"
11267 | "janus"
11268 | "juno"
11269 | "jupiter"
11270 | "luna"
11271 | "mars"
11272 | "minerva"
11273 | "neptune"
11274 | "odysseus"
11275 | "ophelia"
11276 | "orion"
11277 | "orpheus"
11278 | "pandora"
11279 | "phoebe"
11280 | "pluto"
11281 | "saturn"
11282 | "thalia"
11283 | "theia"
11284 | "vesta"
11285 | "zeus";
11286 /**
11287 * Encoding of the output audio.
11288 */
11289 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
11290 /**
11291 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
11292 */
11293 container?: "none" | "wav" | "ogg";
11294 /**
11295 * The text content to be converted to speech
11296 */
11297 text: string;
11298 /**
11299 * 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
11300 */
11301 sample_rate?: number;
11302 /**
11303 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
11304 */
11305 bit_rate?: number;
11306}
11307/**
11308 * The generated audio in MP3 format
11309 */
11310export type Ai_Cf_Deepgram_Aura_2_En_Output = string;
11311export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_En {
11312 inputs: Ai_Cf_Deepgram_Aura_2_En_Input;
11313 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_En_Output;
11314}
11315export interface Ai_Cf_Deepgram_Aura_2_Es_Input {
11316 /**
11317 * Speaker used to produce the audio.
11318 */
11319 speaker?:
11320 | "sirio"
11321 | "nestor"
11322 | "carina"
11323 | "celeste"
11324 | "alvaro"
11325 | "diana"
11326 | "aquila"
11327 | "selena"
11328 | "estrella"
11329 | "javier";
11330 /**
11331 * Encoding of the output audio.
11332 */
11333 encoding?: "linear16" | "flac" | "mulaw" | "alaw" | "mp3" | "opus" | "aac";
11334 /**
11335 * Container specifies the file format wrapper for the output audio. The available options depend on the encoding type..
11336 */
11337 container?: "none" | "wav" | "ogg";
11338 /**
11339 * The text content to be converted to speech
11340 */
11341 text: string;
11342 /**
11343 * 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
11344 */
11345 sample_rate?: number;
11346 /**
11347 * The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.
11348 */
11349 bit_rate?: number;
11350}
11351/**
11352 * The generated audio in MP3 format
11353 */
11354export type Ai_Cf_Deepgram_Aura_2_Es_Output = string;
11355export declare abstract class Base_Ai_Cf_Deepgram_Aura_2_Es {
11356 inputs: Ai_Cf_Deepgram_Aura_2_Es_Input;
11357 postProcessedOutputs: Ai_Cf_Deepgram_Aura_2_Es_Output;
11358}
11359export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input {
11360 multipart: {
11361 body?: object;
11362 contentType?: string;
11363 };
11364}
11365export interface Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output {
11366 /**
11367 * Generated image as Base64 string.
11368 */
11369 image?: string;
11370}
11371export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev {
11372 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Input;
11373 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Dev_Output;
11374}
11375export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input {
11376 multipart: {
11377 body?: object;
11378 contentType?: string;
11379 };
11380}
11381export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output {
11382 /**
11383 * Generated image as Base64 string.
11384 */
11385 image?: string;
11386}
11387export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B {
11388 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Input;
11389 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B_Output;
11390}
11391export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input {
11392 multipart: {
11393 body?: object;
11394 contentType?: string;
11395 };
11396}
11397export interface Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output {
11398 /**
11399 * Generated image as Base64 string.
11400 */
11401 image?: string;
11402}
11403export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B {
11404 inputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Input;
11405 postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B_Output;
11406}
11407export declare abstract class Base_Ai_Cf_Zai_Org_Glm_4_7_Flash {
11408 inputs: ChatCompletionsInput;
11409 postProcessedOutputs: ChatCompletionsOutput;
11410}
11411export declare abstract class Base_Ai_Cf_Moonshotai_Kimi_K2_5 {
11412 inputs: ChatCompletionsInput;
11413 postProcessedOutputs: ChatCompletionsOutput;
11414}
11415export declare abstract class Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B {
11416 inputs: ChatCompletionsInput;
11417 postProcessedOutputs: ChatCompletionsOutput;
11418}
11419export declare abstract class Base_Ai_Cf_Google_Gemma_4_26B_A4B_IT {
11420 inputs: ChatCompletionsInput;
11421 postProcessedOutputs: ChatCompletionsOutput;
11422}
11423export interface AiModels {
11424 "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
11425 "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
11426 "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
11427 "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
11428 "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
11429 "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
11430 "@cf/myshell-ai/melotts": BaseAiTextToSpeech;
11431 "@cf/google/embeddinggemma-300m": BaseAiTextEmbeddings;
11432 "@cf/microsoft/resnet-50": BaseAiImageClassification;
11433 "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
11434 "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
11435 "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
11436 "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
11437 "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
11438 "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
11439 "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
11440 "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
11441 "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
11442 "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
11443 "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
11444 "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
11445 "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
11446 "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
11447 "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
11448 "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
11449 "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
11450 "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
11451 "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
11452 "@cf/microsoft/phi-2": BaseAiTextGeneration;
11453 "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
11454 "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
11455 "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
11456 "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
11457 "@hf/google/gemma-7b-it": BaseAiTextGeneration;
11458 "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
11459 "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
11460 "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
11461 "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
11462 "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
11463 "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
11464 "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
11465 "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
11466 "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
11467 "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
11468 "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
11469 "@cf/deepseek-ai/deepseek-r1-distill-qwen-32b": BaseAiTextGeneration;
11470 "@cf/ibm-granite/granite-4.0-h-micro": BaseAiTextGeneration;
11471 "@cf/facebook/bart-large-cnn": BaseAiSummarization;
11472 "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
11473 "@cf/baai/bge-base-en-v1.5": Base_Ai_Cf_Baai_Bge_Base_En_V1_5;
11474 "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
11475 "@cf/meta/m2m100-1.2b": Base_Ai_Cf_Meta_M2M100_1_2B;
11476 "@cf/baai/bge-small-en-v1.5": Base_Ai_Cf_Baai_Bge_Small_En_V1_5;
11477 "@cf/baai/bge-large-en-v1.5": Base_Ai_Cf_Baai_Bge_Large_En_V1_5;
11478 "@cf/unum/uform-gen2-qwen-500m": Base_Ai_Cf_Unum_Uform_Gen2_Qwen_500M;
11479 "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
11480 "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
11481 "@cf/baai/bge-m3": Base_Ai_Cf_Baai_Bge_M3;
11482 "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
11483 "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
11484 "@cf/meta/llama-3.3-70b-instruct-fp8-fast": Base_Ai_Cf_Meta_Llama_3_3_70B_Instruct_Fp8_Fast;
11485 "@cf/meta/llama-guard-3-8b": Base_Ai_Cf_Meta_Llama_Guard_3_8B;
11486 "@cf/baai/bge-reranker-base": Base_Ai_Cf_Baai_Bge_Reranker_Base;
11487 "@cf/qwen/qwen2.5-coder-32b-instruct": Base_Ai_Cf_Qwen_Qwen2_5_Coder_32B_Instruct;
11488 "@cf/qwen/qwq-32b": Base_Ai_Cf_Qwen_Qwq_32B;
11489 "@cf/mistralai/mistral-small-3.1-24b-instruct": Base_Ai_Cf_Mistralai_Mistral_Small_3_1_24B_Instruct;
11490 "@cf/google/gemma-3-12b-it": Base_Ai_Cf_Google_Gemma_3_12B_It;
11491 "@cf/meta/llama-4-scout-17b-16e-instruct": Base_Ai_Cf_Meta_Llama_4_Scout_17B_16E_Instruct;
11492 "@cf/qwen/qwen3-30b-a3b-fp8": Base_Ai_Cf_Qwen_Qwen3_30B_A3B_Fp8;
11493 "@cf/deepgram/nova-3": Base_Ai_Cf_Deepgram_Nova_3;
11494 "@cf/qwen/qwen3-embedding-0.6b": Base_Ai_Cf_Qwen_Qwen3_Embedding_0_6B;
11495 "@cf/pipecat-ai/smart-turn-v2": Base_Ai_Cf_Pipecat_Ai_Smart_Turn_V2;
11496 "@cf/openai/gpt-oss-120b": Base_Ai_Cf_Openai_Gpt_Oss_120B;
11497 "@cf/openai/gpt-oss-20b": Base_Ai_Cf_Openai_Gpt_Oss_20B;
11498 "@cf/leonardo/phoenix-1.0": Base_Ai_Cf_Leonardo_Phoenix_1_0;
11499 "@cf/leonardo/lucid-origin": Base_Ai_Cf_Leonardo_Lucid_Origin;
11500 "@cf/deepgram/aura-1": Base_Ai_Cf_Deepgram_Aura_1;
11501 "@cf/ai4bharat/indictrans2-en-indic-1B": Base_Ai_Cf_Ai4Bharat_Indictrans2_En_Indic_1B;
11502 "@cf/aisingapore/gemma-sea-lion-v4-27b-it": Base_Ai_Cf_Aisingapore_Gemma_Sea_Lion_V4_27B_It;
11503 "@cf/pfnet/plamo-embedding-1b": Base_Ai_Cf_Pfnet_Plamo_Embedding_1B;
11504 "@cf/deepgram/flux": Base_Ai_Cf_Deepgram_Flux;
11505 "@cf/deepgram/aura-2-en": Base_Ai_Cf_Deepgram_Aura_2_En;
11506 "@cf/deepgram/aura-2-es": Base_Ai_Cf_Deepgram_Aura_2_Es;
11507 "@cf/black-forest-labs/flux-2-dev": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Dev;
11508 "@cf/black-forest-labs/flux-2-klein-4b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_4B;
11509 "@cf/black-forest-labs/flux-2-klein-9b": Base_Ai_Cf_Black_Forest_Labs_Flux_2_Klein_9B;
11510 "@cf/zai-org/glm-4.7-flash": Base_Ai_Cf_Zai_Org_Glm_4_7_Flash;
11511 "@cf/moonshotai/kimi-k2.5": Base_Ai_Cf_Moonshotai_Kimi_K2_5;
11512 "@cf/nvidia/nemotron-3-120b-a12b": Base_Ai_Cf_Nvidia_Nemotron_3_120B_A12B;
11513}
11514export type AiOptions = {
11515 /**
11516 * Send requests as an asynchronous batch job, only works for supported models
11517 * https://developers.cloudflare.com/workers-ai/features/batch-api
11518 */
11519 queueRequest?: boolean;
11520 /**
11521 * Establish websocket connections, only works for supported models
11522 */
11523 websocket?: boolean;
11524 /**
11525 * Tag your requests to group and view them in Cloudflare dashboard.
11526 *
11527 * Rules:
11528 * Tags must only contain letters, numbers, and the symbols: : - . / @
11529 * Each tag can have maximum 50 characters.
11530 * Maximum 5 tags are allowed each request.
11531 * Duplicate tags will removed.
11532 */
11533 tags?: string[];
11534 gateway?: GatewayOptions;
11535 returnRawResponse?: boolean;
11536 prefix?: string;
11537 extraHeaders?: object;
11538 signal?: AbortSignal;
11539};
11540export type AiModelsSearchParams = {
11541 author?: string;
11542 hide_experimental?: boolean;
11543 page?: number;
11544 per_page?: number;
11545 search?: string;
11546 source?: number;
11547 task?: string;
11548};
11549export type AiModelsSearchObject = {
11550 id: string;
11551 source: number;
11552 name: string;
11553 description: string;
11554 task: {
11555 id: string;
11556 name: string;
11557 description: string;
11558 };
11559 tags: string[];
11560 properties: {
11561 property_id: string;
11562 value: string;
11563 }[];
11564};
11565export type ChatCompletionsBase = XOR<
11566 ChatCompletionsPromptInput,
11567 ChatCompletionsMessagesInput
11568>;
11569export type ChatCompletionsInput = XOR<
11570 ChatCompletionsBase,
11571 {
11572 requests: ChatCompletionsBase[];
11573 }
11574>;
11575export interface InferenceUpstreamError extends Error {}
11576export interface AiInternalError extends Error {}
11577export type AiModelListType = Record<string, any>;
11578export type AiAsyncBatchResponse = {
11579 request_id: string;
11580};
11581export declare abstract class Ai<
11582 AiModelList extends AiModelListType = AiModels,
11583> {
11584 aiGatewayLogId: string | null;
11585 gateway(gatewayId: string): AiGateway;
11586 /**
11587 * @deprecated Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
11588 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11589 */
11590 aiSearch(): AiSearchNamespace;
11591 /**
11592 * @deprecated AutoRAG has been replaced by AI Search.
11593 * Use the standalone `ai_search_namespaces` or `ai_search` Workers bindings instead.
11594 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
11595 *
11596 * @param autoragId Instance ID
11597 */
11598 autorag(autoragId: string): AutoRAG;
11599 // Batch request
11600 run<Name extends keyof AiModelList>(
11601 model: Name,
11602 inputs: {
11603 requests: AiModelList[Name]["inputs"][];
11604 },
11605 options: AiOptions & {
11606 queueRequest: true;
11607 },
11608 ): Promise<AiAsyncBatchResponse>;
11609 // Raw response
11610 run<Name extends keyof AiModelList>(
11611 model: Name,
11612 inputs: AiModelList[Name]["inputs"],
11613 options: AiOptions & {
11614 returnRawResponse: true;
11615 },
11616 ): Promise<Response>;
11617 // WebSocket
11618 run<Name extends keyof AiModelList>(
11619 model: Name,
11620 inputs: AiModelList[Name]["inputs"],
11621 options: AiOptions & {
11622 websocket: true;
11623 },
11624 ): Promise<Response>;
11625 // Streaming
11626 run<Name extends keyof AiModelList>(
11627 model: Name,
11628 inputs: AiModelList[Name]["inputs"] & {
11629 stream: true;
11630 },
11631 options?: AiOptions,
11632 ): Promise<ReadableStream>;
11633 // Normal (default) - known model
11634 run<Name extends keyof AiModelList>(
11635 model: Name,
11636 inputs: AiModelList[Name]["inputs"],
11637 options?: AiOptions,
11638 ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
11639 // Unknown model (gateway fallback)
11640 run(
11641 model: string & {},
11642 inputs: Record<string, unknown>,
11643 options?: AiOptions,
11644 ): Promise<Record<string, unknown>>;
11645 models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
11646 toMarkdown(): ToMarkdownService;
11647 toMarkdown(
11648 files: MarkdownDocument[],
11649 options?: ConversionRequestOptions,
11650 ): Promise<ConversionResponse[]>;
11651 toMarkdown(
11652 files: MarkdownDocument,
11653 options?: ConversionRequestOptions,
11654 ): Promise<ConversionResponse>;
11655}
11656export type GatewayRetries = {
11657 maxAttempts?: 1 | 2 | 3 | 4 | 5;
11658 retryDelayMs?: number;
11659 backoff?: "constant" | "linear" | "exponential";
11660};
11661export type GatewayOptions = {
11662 id: string;
11663 cacheKey?: string;
11664 cacheTtl?: number;
11665 skipCache?: boolean;
11666 metadata?: Record<string, number | string | boolean | null | bigint>;
11667 collectLog?: boolean;
11668 eventId?: string;
11669 requestTimeoutMs?: number;
11670 retries?: GatewayRetries;
11671};
11672export type UniversalGatewayOptions = Exclude<GatewayOptions, "id"> & {
11673 /**
11674 ** @deprecated
11675 */
11676 id?: string;
11677};
11678export type AiGatewayPatchLog = {
11679 score?: number | null;
11680 feedback?: -1 | 1 | null;
11681 metadata?: Record<string, number | string | boolean | null | bigint> | null;
11682};
11683export type AiGatewayLog = {
11684 id: string;
11685 provider: string;
11686 model: string;
11687 model_type?: string;
11688 path: string;
11689 duration: number;
11690 request_type?: string;
11691 request_content_type?: string;
11692 status_code: number;
11693 response_content_type?: string;
11694 success: boolean;
11695 cached: boolean;
11696 tokens_in?: number;
11697 tokens_out?: number;
11698 metadata?: Record<string, number | string | boolean | null | bigint>;
11699 step?: number;
11700 cost?: number;
11701 custom_cost?: boolean;
11702 request_size: number;
11703 request_head?: string;
11704 request_head_complete: boolean;
11705 response_size: number;
11706 response_head?: string;
11707 response_head_complete: boolean;
11708 created_at: Date;
11709};
11710export type AIGatewayProviders =
11711 | "workers-ai"
11712 | "anthropic"
11713 | "aws-bedrock"
11714 | "azure-openai"
11715 | "google-vertex-ai"
11716 | "huggingface"
11717 | "openai"
11718 | "perplexity-ai"
11719 | "replicate"
11720 | "groq"
11721 | "cohere"
11722 | "google-ai-studio"
11723 | "mistral"
11724 | "grok"
11725 | "openrouter"
11726 | "deepseek"
11727 | "cerebras"
11728 | "cartesia"
11729 | "elevenlabs"
11730 | "adobe-firefly";
11731export type AIGatewayHeaders = {
11732 "cf-aig-metadata":
11733 | Record<string, number | string | boolean | null | bigint>
11734 | string;
11735 "cf-aig-custom-cost":
11736 | {
11737 per_token_in?: number;
11738 per_token_out?: number;
11739 }
11740 | {
11741 total_cost?: number;
11742 }
11743 | string;
11744 "cf-aig-cache-ttl": number | string;
11745 "cf-aig-skip-cache": boolean | string;
11746 "cf-aig-cache-key": string;
11747 "cf-aig-event-id": string;
11748 "cf-aig-request-timeout": number | string;
11749 "cf-aig-max-attempts": number | string;
11750 "cf-aig-retry-delay": number | string;
11751 "cf-aig-backoff": string;
11752 "cf-aig-collect-log": boolean | string;
11753 Authorization: string;
11754 "Content-Type": string;
11755 [key: string]: string | number | boolean | object;
11756};
11757export type AIGatewayUniversalRequest = {
11758 provider: AIGatewayProviders | string; // eslint-disable-line
11759 endpoint: string;
11760 headers: Partial<AIGatewayHeaders>;
11761 query: unknown;
11762};
11763export interface AiGatewayInternalError extends Error {}
11764export interface AiGatewayLogNotFound extends Error {}
11765export declare abstract class AiGateway {
11766 patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
11767 getLog(logId: string): Promise<AiGatewayLog>;
11768 run(
11769 data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
11770 options?: {
11771 gateway?: UniversalGatewayOptions;
11772 extraHeaders?: object;
11773 signal?: AbortSignal;
11774 },
11775 ): Promise<Response>;
11776 getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
11777}
11778// Copyright (c) 2022-2025 Cloudflare, Inc.
11779// Licensed under the Apache 2.0 license found in the LICENSE file or at:
11780// https://opensource.org/licenses/Apache-2.0
11781/**
11782 * Artifacts โ€” Git-compatible file storage on Cloudflare Workers.
11783 *
11784 * Provides programmatic access to create, manage, and fork repositories,
11785 * and to issue and revoke scoped access tokens.
11786 */
11787/** Information about a repository. */
11788export interface ArtifactsRepoInfo {
11789 /** Unique repository ID. */
11790 id: string;
11791 /** Repository name. */
11792 name: string;
11793 /** Repository description, or null if not set. */
11794 description: string | null;
11795 /** Default branch name (e.g. "main"). */
11796 defaultBranch: string;
11797 /** ISO 8601 creation timestamp. */
11798 createdAt: string;
11799 /** ISO 8601 last-updated timestamp. */
11800 updatedAt: string;
11801 /** ISO 8601 timestamp of the last push, or null if never pushed. */
11802 lastPushAt: string | null;
11803 /** Fork source (e.g. "github:owner/repo", "artifacts:namespace/repo"), or null if not a fork. */
11804 source: string | null;
11805 /** Whether the repository is read-only. */
11806 readOnly: boolean;
11807 /** HTTPS git remote URL. */
11808 remote: string;
11809}
11810/** Result of creating a repository โ€” includes the initial access token. */
11811export interface ArtifactsCreateRepoResult {
11812 /** Unique repository ID. */
11813 id: string;
11814 /** Repository name. */
11815 name: string;
11816 /** Repository description, or null if not set. */
11817 description: string | null;
11818 /** Default branch name. */
11819 defaultBranch: string;
11820 /** HTTPS git remote URL. */
11821 remote: string;
11822 /** Plaintext access token (only returned at creation time). */
11823 token: string;
11824 /** ISO 8601 token expiry timestamp. */
11825 tokenExpiresAt: string;
11826}
11827/** Paginated list of repositories. */
11828export interface ArtifactsRepoListResult {
11829 /** Repositories in this page (without the `remote` field). */
11830 repos: Omit<ArtifactsRepoInfo, "remote">[];
11831 /** Total number of repositories in the namespace. */
11832 total: number;
11833 /** Cursor for the next page, if there are more results. */
11834 cursor?: string;
11835}
11836/** Result of creating an access token. */
11837export interface ArtifactsCreateTokenResult {
11838 /** Unique token ID. */
11839 id: string;
11840 /** Plaintext token (only returned at creation time). */
11841 plaintext: string;
11842 /** Token scope: "read" or "write". */
11843 scope: "read" | "write";
11844 /** ISO 8601 token expiry timestamp. */
11845 expiresAt: string;
11846}
11847/** Token metadata (no plaintext). */
11848export interface ArtifactsTokenInfo {
11849 /** Unique token ID. */
11850 id: string;
11851 /** Token scope: "read" or "write". */
11852 scope: "read" | "write";
11853 /** Token state: "active", "expired", or "revoked". */
11854 state: "active" | "expired" | "revoked";
11855 /** ISO 8601 creation timestamp. */
11856 createdAt: string;
11857 /** ISO 8601 expiry timestamp. */
11858 expiresAt: string;
11859}
11860/** Paginated list of tokens for a repository. */
11861export interface ArtifactsTokenListResult {
11862 /** Tokens in this page. */
11863 tokens: ArtifactsTokenInfo[];
11864 /** Total number of tokens for the repository. */
11865 total: number;
11866}
11867/**
11868 * Handle for a single repository. Returned by Artifacts.get().
11869 *
11870 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11871 */
11872export interface ArtifactsRepo extends ArtifactsRepoInfo {
11873 /**
11874 * Create an access token for this repo.
11875 * @param scope Token scope: "write" (default) or "read".
11876 * @param ttl Time-to-live in seconds (default 86400, min 60, max 31536000).
11877 * @throws {ArtifactsError} with code `INVALID_TTL` if ttl is out of range.
11878 */
11879 createToken(
11880 scope?: "write" | "read",
11881 ttl?: number,
11882 ): Promise<ArtifactsCreateTokenResult>;
11883 /** List tokens for this repo (metadata only, no plaintext). */
11884 listTokens(): Promise<ArtifactsTokenListResult>;
11885 /**
11886 * Revoke a token by plaintext or ID.
11887 * @param tokenOrId Plaintext token or token ID.
11888 * @returns true if revoked, false if not found.
11889 * @throws {ArtifactsError} with code `INVALID_INPUT` if tokenOrId is empty.
11890 */
11891 revokeToken(tokenOrId: string): Promise<boolean>;
11892 // โ”€โ”€ Fork โ”€โ”€
11893 /**
11894 * Fork this repo to a new repo.
11895 * @param name Target repository name.
11896 * @param opts Optional: description, readOnly flag, defaultBranchOnly (default true).
11897 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11898 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11899 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if a fork is already running.
11900 */
11901 fork(
11902 name: string,
11903 opts?: {
11904 description?: string;
11905 readOnly?: boolean;
11906 defaultBranchOnly?: boolean;
11907 },
11908 ): Promise<ArtifactsCreateRepoResult>;
11909}
11910// โ”€โ”€ Error types โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11911/**
11912 * Error codes returned by Artifacts binding operations.
11913 *
11914 * Each code maps to a numeric code available on `ArtifactsError.numericCode`.
11915 */
11916export type ArtifactsErrorCode =
11917 | "ALREADY_EXISTS"
11918 | "NOT_FOUND"
11919 | "IMPORT_IN_PROGRESS"
11920 | "FORK_IN_PROGRESS"
11921 | "INVALID_INPUT"
11922 | "INVALID_REPO_NAME"
11923 | "INVALID_TTL"
11924 | "INVALID_URL"
11925 | "REMOTE_AUTH_REQUIRED"
11926 | "UPSTREAM_UNAVAILABLE"
11927 | "MEMORY_LIMIT"
11928 | "INTERNAL_ERROR";
11929/**
11930 * Error thrown by Artifacts binding operations.
11931 *
11932 * Uses a string `.code` discriminator following the Cloudflare platform
11933 * convention (StreamError, ImagesError, etc.). The `.numericCode` matches
11934 * the REST API `errors[].code` values.
11935 */
11936export interface ArtifactsError extends Error {
11937 readonly name: "ArtifactsError";
11938 /** String error code for programmatic matching. */
11939 readonly code: ArtifactsErrorCode;
11940 /** Numeric error code matching the REST API. */
11941 readonly numericCode: number;
11942}
11943// โ”€โ”€ Binding โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
11944/**
11945 * Artifacts binding โ€” namespace-level operations.
11946 *
11947 * Methods may throw `ArtifactsError` with code `INTERNAL_ERROR` if an unexpected service error occurs.
11948 */
11949export interface Artifacts {
11950 /**
11951 * Create a new repository with an initial access token.
11952 * @param name Repository name (alphanumeric, dots, hyphens, underscores).
11953 * @param opts Optional: readOnly flag, description, default branch name.
11954 * @returns Repo metadata with initial token.
11955 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
11956 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the repo already exists.
11957 */
11958 create(
11959 name: string,
11960 opts?: {
11961 readOnly?: boolean;
11962 description?: string;
11963 setDefaultBranch?: string;
11964 },
11965 ): Promise<ArtifactsCreateRepoResult>;
11966 /**
11967 * Get a handle to an existing repository.
11968 * @param name Repository name.
11969 * @returns Repo handle.
11970 * @throws {ArtifactsError} with code `NOT_FOUND` if the repo does not exist.
11971 * @throws {ArtifactsError} with code `IMPORT_IN_PROGRESS` if the repo is still importing.
11972 * @throws {ArtifactsError} with code `FORK_IN_PROGRESS` if the repo is still forking.
11973 */
11974 get(name: string): Promise<ArtifactsRepo>;
11975 /**
11976 * Import a repository from an external git remote.
11977 * @param params Source URL and optional branch/depth, plus target name and options.
11978 * @returns Repo metadata with initial token.
11979 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if the target name is invalid.
11980 * @throws {ArtifactsError} with code `INVALID_INPUT` if the source URL is not valid HTTPS.
11981 * @throws {ArtifactsError} with code `INVALID_URL` if the source URL does not point to a git repository.
11982 * @throws {ArtifactsError} with code `REMOTE_AUTH_REQUIRED` if the remote requires authentication.
11983 * @throws {ArtifactsError} with code `NOT_FOUND` if the remote repository does not exist.
11984 * @throws {ArtifactsError} with code `UPSTREAM_UNAVAILABLE` if the remote cannot be reached.
11985 * @throws {ArtifactsError} with code `MEMORY_LIMIT` if the import exceeds service memory limits.
11986 * @throws {ArtifactsError} with code `ALREADY_EXISTS` if the target repo already exists.
11987 */
11988 import(params: {
11989 source: {
11990 url: string;
11991 branch?: string;
11992 depth?: number;
11993 };
11994 target: {
11995 name: string;
11996 opts?: {
11997 description?: string;
11998 readOnly?: boolean;
11999 };
12000 };
12001 }): Promise<ArtifactsCreateRepoResult>;
12002 /**
12003 * List repositories with cursor-based pagination.
12004 * @param opts Optional: limit (1โ€“200, default 50), cursor for next page.
12005 */
12006 list(opts?: {
12007 limit?: number;
12008 cursor?: string;
12009 }): Promise<ArtifactsRepoListResult>;
12010 /**
12011 * Delete a repository and all associated tokens.
12012 * @param name Repository name.
12013 * @returns true if deleted, false if not found.
12014 * @throws {ArtifactsError} with code `INVALID_REPO_NAME` if name is invalid.
12015 */
12016 delete(name: string): Promise<boolean>;
12017}
12018/**
12019 * @deprecated Use the standalone AI Search Workers binding instead.
12020 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12021 */
12022export interface AutoRAGInternalError extends Error {}
12023/**
12024 * @deprecated Use the standalone AI Search Workers binding instead.
12025 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12026 */
12027export interface AutoRAGNotFoundError extends Error {}
12028/**
12029 * @deprecated Use the standalone AI Search Workers binding instead.
12030 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12031 */
12032export interface AutoRAGUnauthorizedError extends Error {}
12033/**
12034 * @deprecated Use the standalone AI Search Workers binding instead.
12035 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12036 */
12037export interface AutoRAGNameNotSetError extends Error {}
12038export type ComparisonFilter = {
12039 key: string;
12040 type: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
12041 value: string | number | boolean;
12042};
12043export type CompoundFilter = {
12044 type: "and" | "or";
12045 filters: ComparisonFilter[];
12046};
12047/**
12048 * @deprecated Use the standalone AI Search Workers binding instead.
12049 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12050 */
12051export type AutoRagSearchRequest = {
12052 query: string;
12053 filters?: CompoundFilter | ComparisonFilter;
12054 max_num_results?: number;
12055 ranking_options?: {
12056 ranker?: string;
12057 score_threshold?: number;
12058 };
12059 reranking?: {
12060 enabled?: boolean;
12061 model?: string;
12062 };
12063 rewrite_query?: boolean;
12064};
12065/**
12066 * @deprecated Use the standalone AI Search Workers binding instead.
12067 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12068 */
12069export type AutoRagAiSearchRequest = AutoRagSearchRequest & {
12070 stream?: boolean;
12071 system_prompt?: string;
12072};
12073/**
12074 * @deprecated Use the standalone AI Search Workers binding instead.
12075 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12076 */
12077export type AutoRagAiSearchRequestStreaming = Omit<
12078 AutoRagAiSearchRequest,
12079 "stream"
12080> & {
12081 stream: true;
12082};
12083/**
12084 * @deprecated Use the standalone AI Search Workers binding instead.
12085 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12086 */
12087export type AutoRagSearchResponse = {
12088 object: "vector_store.search_results.page";
12089 search_query: string;
12090 data: {
12091 file_id: string;
12092 filename: string;
12093 score: number;
12094 attributes: Record<string, string | number | boolean | null>;
12095 content: {
12096 type: "text";
12097 text: string;
12098 }[];
12099 }[];
12100 has_more: boolean;
12101 next_page: string | null;
12102};
12103/**
12104 * @deprecated Use the standalone AI Search Workers binding instead.
12105 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12106 */
12107export type AutoRagListResponse = {
12108 id: string;
12109 enable: boolean;
12110 type: string;
12111 source: string;
12112 vectorize_name: string;
12113 paused: boolean;
12114 status: string;
12115}[];
12116/**
12117 * @deprecated Use the standalone AI Search Workers binding instead.
12118 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12119 */
12120export type AutoRagAiSearchResponse = AutoRagSearchResponse & {
12121 response: string;
12122};
12123/**
12124 * @deprecated Use the standalone AI Search Workers binding instead.
12125 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12126 */
12127export declare abstract class AutoRAG {
12128 /**
12129 * @deprecated Use the standalone AI Search Workers binding instead.
12130 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12131 */
12132 list(): Promise<AutoRagListResponse>;
12133 /**
12134 * @deprecated Use the standalone AI Search Workers binding instead.
12135 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12136 */
12137 search(params: AutoRagSearchRequest): Promise<AutoRagSearchResponse>;
12138 /**
12139 * @deprecated Use the standalone AI Search Workers binding instead.
12140 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12141 */
12142 aiSearch(params: AutoRagAiSearchRequestStreaming): Promise<Response>;
12143 /**
12144 * @deprecated Use the standalone AI Search Workers binding instead.
12145 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12146 */
12147 aiSearch(params: AutoRagAiSearchRequest): Promise<AutoRagAiSearchResponse>;
12148 /**
12149 * @deprecated Use the standalone AI Search Workers binding instead.
12150 * See https://developers.cloudflare.com/ai-search/usage/workers-binding/
12151 */
12152 aiSearch(
12153 params: AutoRagAiSearchRequest,
12154 ): Promise<AutoRagAiSearchResponse | Response>;
12155}
12156export interface BasicImageTransformations {
12157 /**
12158 * Maximum width in image pixels. The value must be an integer.
12159 */
12160 width?: number;
12161 /**
12162 * Maximum height in image pixels. The value must be an integer.
12163 */
12164 height?: number;
12165 /**
12166 * Resizing mode as a string. It affects interpretation of width and height
12167 * options:
12168 * - scale-down: Similar to contain, but the image is never enlarged. If
12169 * the image is larger than given width or height, it will be resized.
12170 * Otherwise its original size will be kept.
12171 * - contain: Resizes to maximum size that fits within the given width and
12172 * height. If only a single dimension is given (e.g. only width), the
12173 * image will be shrunk or enlarged to exactly match that dimension.
12174 * Aspect ratio is always preserved.
12175 * - cover: Resizes (shrinks or enlarges) to fill the entire area of width
12176 * and height. If the image has an aspect ratio different from the ratio
12177 * of width and height, it will be cropped to fit.
12178 * - crop: The image will be shrunk and cropped to fit within the area
12179 * specified by width and height. The image will not be enlarged. For images
12180 * smaller than the given dimensions it's the same as scale-down. For
12181 * images larger than the given dimensions, it's the same as cover.
12182 * See also trim.
12183 * - pad: Resizes to the maximum size that fits within the given width and
12184 * height, and then fills the remaining area with a background color
12185 * (white by default). Use of this mode is not recommended, as the same
12186 * effect can be more efficiently achieved with the contain mode and the
12187 * CSS object-fit: contain property.
12188 * - squeeze: Stretches and deforms to the width and height given, even if it
12189 * breaks aspect ratio
12190 */
12191 fit?: "scale-down" | "contain" | "cover" | "crop" | "pad" | "squeeze";
12192 /**
12193 * Image segmentation using artificial intelligence models. Sets pixels not
12194 * within selected segment area to transparent e.g "foreground" sets every
12195 * background pixel as transparent.
12196 */
12197 segment?: "foreground";
12198 /**
12199 * When cropping with fit: "cover", this defines the side or point that should
12200 * be left uncropped. The value is either a string
12201 * "left", "right", "top", "bottom", "auto", or "center" (the default),
12202 * or an object {x, y} containing focal point coordinates in the original
12203 * image expressed as fractions ranging from 0.0 (top or left) to 1.0
12204 * (bottom or right), 0.5 being the center. {fit: "cover", gravity: "top"} will
12205 * crop bottom or left and right sides as necessary, but wonโ€™t crop anything
12206 * from the top. {fit: "cover", gravity: {x:0.5, y:0.2}} will crop each side to
12207 * preserve as much as possible around a point at 20% of the height of the
12208 * source image.
12209 */
12210 gravity?:
12211 | "face"
12212 | "left"
12213 | "right"
12214 | "top"
12215 | "bottom"
12216 | "center"
12217 | "auto"
12218 | "entropy"
12219 | BasicImageTransformationsGravityCoordinates;
12220 /**
12221 * Background color to add underneath the image. Applies only to images with
12222 * transparency (such as PNG). Accepts any CSS color (#RRGGBB, rgba(โ€ฆ),
12223 * hsl(โ€ฆ), etc.)
12224 */
12225 background?: string;
12226 /**
12227 * Number of degrees (90, 180, 270) to rotate the image by. width and height
12228 * options refer to axes after rotation.
12229 */
12230 rotate?: 0 | 90 | 180 | 270 | 360;
12231}
12232export interface BasicImageTransformationsGravityCoordinates {
12233 x?: number;
12234 y?: number;
12235 mode?: "remainder" | "box-center";
12236}
12237/**
12238 * In addition to the properties you can set in the RequestInit dict
12239 * that you pass as an argument to the Request constructor, you can
12240 * set certain properties of a `cf` object to control how Cloudflare
12241 * features are applied to that new Request.
12242 *
12243 * Note: Currently, these properties cannot be tested in the
12244 * playground.
12245 */
12246export interface RequestInitCfProperties extends Record<string, unknown> {
12247 cacheEverything?: boolean;
12248 /**
12249 * A request's cache key is what determines if two requests are
12250 * "the same" for caching purposes. If a request has the same cache key
12251 * as some previous request, then we can serve the same cached response for
12252 * both. (e.g. 'some-key')
12253 *
12254 * Only available for Enterprise customers.
12255 */
12256 cacheKey?: string;
12257 /**
12258 * This allows you to append additional Cache-Tag response headers
12259 * to the origin response without modifications to the origin server.
12260 * This will allow for greater control over the Purge by Cache Tag feature
12261 * utilizing changes only in the Workers process.
12262 *
12263 * Only available for Enterprise customers.
12264 */
12265 cacheTags?: string[];
12266 /**
12267 * Force response to be cached for a given number of seconds. (e.g. 300)
12268 */
12269 cacheTtl?: number;
12270 /**
12271 * Force response to be cached for a given number of seconds based on the Origin status code.
12272 * (e.g. { '200-299': 86400, '404': 1, '500-599': 0 })
12273 */
12274 cacheTtlByStatus?: Record<string, number>;
12275 /**
12276 * Explicit Cache-Control header value to set on the response stored in cache.
12277 * This gives full control over cache directives (e.g. 'public, max-age=3600, s-maxage=86400').
12278 *
12279 * Cannot be used together with `cacheTtl` or the `cache` request option (`no-store`/`no-cache`),
12280 * as these are mutually exclusive cache control mechanisms. Setting both will throw a TypeError.
12281 *
12282 * Can be used together with `cacheTtlByStatus`.
12283 */
12284 cacheControl?: string;
12285 /**
12286 * Whether the response should be eligible for Cache Reserve storage.
12287 */
12288 cacheReserveEligible?: boolean;
12289 /**
12290 * Whether to respect strong ETags (as opposed to weak ETags) from the origin.
12291 */
12292 respectStrongEtag?: boolean;
12293 /**
12294 * Whether to strip ETag headers from the origin response before caching.
12295 */
12296 stripEtags?: boolean;
12297 /**
12298 * Whether to strip Last-Modified headers from the origin response before caching.
12299 */
12300 stripLastModified?: boolean;
12301 /**
12302 * Whether to enable Cache Deception Armor, which protects against web cache
12303 * deception attacks by verifying the Content-Type matches the URL extension.
12304 */
12305 cacheDeceptionArmor?: boolean;
12306 /**
12307 * Minimum file size in bytes for a response to be eligible for Cache Reserve storage.
12308 */
12309 cacheReserveMinimumFileSize?: number;
12310 scrapeShield?: boolean;
12311 apps?: boolean;
12312 image?: RequestInitCfPropertiesImage;
12313 minify?: RequestInitCfPropertiesImageMinify;
12314 mirage?: boolean;
12315 polish?: "lossy" | "lossless" | "off";
12316 r2?: RequestInitCfPropertiesR2;
12317 /**
12318 * Redirects the request to an alternate origin server. You can use this,
12319 * for example, to implement load balancing across several origins.
12320 * (e.g.us-east.example.com)
12321 *
12322 * Note - For security reasons, the hostname set in resolveOverride must
12323 * be proxied on the same Cloudflare zone of the incoming request.
12324 * Otherwise, the setting is ignored. CNAME hosts are allowed, so to
12325 * resolve to a host under a different domain or a DNS only domain first
12326 * declare a CNAME record within your own zoneโ€™s DNS mapping to the
12327 * external hostname, set proxy on Cloudflare, then set resolveOverride
12328 * to point to that CNAME record.
12329 */
12330 resolveOverride?: string;
12331}
12332export interface RequestInitCfPropertiesImageDraw extends BasicImageTransformations {
12333 /**
12334 * Absolute URL of the image file to use for the drawing. It can be any of
12335 * the supported file formats. For drawing of watermarks or non-rectangular
12336 * overlays we recommend using PNG or WebP images.
12337 */
12338 url: string;
12339 /**
12340 * Floating-point number between 0 (transparent) and 1 (opaque).
12341 * For example, opacity: 0.5 makes overlay semitransparent.
12342 */
12343 opacity?: number;
12344 /**
12345 * - If set to true, the overlay image will be tiled to cover the entire
12346 * area. This is useful for stock-photo-like watermarks.
12347 * - If set to "x", the overlay image will be tiled horizontally only
12348 * (form a line).
12349 * - If set to "y", the overlay image will be tiled vertically only
12350 * (form a line).
12351 */
12352 repeat?: true | "x" | "y";
12353 /**
12354 * Position of the overlay image relative to a given edge. Each property is
12355 * an offset in pixels. 0 aligns exactly to the edge. For example, left: 10
12356 * positions left side of the overlay 10 pixels from the left edge of the
12357 * image it's drawn over. bottom: 0 aligns bottom of the overlay with bottom
12358 * of the background image.
12359 *
12360 * Setting both left & right, or both top & bottom is an error.
12361 *
12362 * If no position is specified, the image will be centered.
12363 */
12364 top?: number;
12365 left?: number;
12366 bottom?: number;
12367 right?: number;
12368}
12369export interface RequestInitCfPropertiesImage extends BasicImageTransformations {
12370 /**
12371 * Device Pixel Ratio. Default 1. Multiplier for width/height that makes it
12372 * easier to specify higher-DPI sizes in <img srcset>.
12373 */
12374 dpr?: number;
12375 /**
12376 * Allows you to trim your image. Takes dpr into account and is performed before
12377 * resizing or rotation.
12378 *
12379 * It can be used as:
12380 * - left, top, right, bottom - it will specify the number of pixels to cut
12381 * off each side
12382 * - width, height - the width/height you'd like to end up with - can be used
12383 * in combination with the properties above
12384 * - border - this will automatically trim the surroundings of an image based on
12385 * it's color. It consists of three properties:
12386 * - color: rgb or hex representation of the color you wish to trim (todo: verify the rgba bit)
12387 * - tolerance: difference from color to treat as color
12388 * - keep: the number of pixels of border to keep
12389 */
12390 trim?:
12391 | "border"
12392 | {
12393 top?: number;
12394 bottom?: number;
12395 left?: number;
12396 right?: number;
12397 width?: number;
12398 height?: number;
12399 border?:
12400 | boolean
12401 | {
12402 color?: string;
12403 tolerance?: number;
12404 keep?: number;
12405 };
12406 };
12407 /**
12408 * Quality setting from 1-100 (useful values are in 60-90 range). Lower values
12409 * make images look worse, but load faster. The default is 85. It applies only
12410 * to JPEG and WebP images. It doesnโ€™t have any effect on PNG.
12411 */
12412 quality?: number | "low" | "medium-low" | "medium-high" | "high";
12413 /**
12414 * Output format to generate. It can be:
12415 * - avif: generate images in AVIF format.
12416 * - webp: generate images in Google WebP format. Set quality to 100 to get
12417 * the WebP-lossless format.
12418 * - json: instead of generating an image, outputs information about the
12419 * image, in JSON format. The JSON object will contain image size
12420 * (before and after resizing), source imageโ€™s MIME type, file size, etc.
12421 * - jpeg: generate images in JPEG format.
12422 * - png: generate images in PNG format.
12423 */
12424 format?:
12425 | "avif"
12426 | "webp"
12427 | "json"
12428 | "jpeg"
12429 | "png"
12430 | "baseline-jpeg"
12431 | "png-force"
12432 | "svg";
12433 /**
12434 * Whether to preserve animation frames from input files. Default is true.
12435 * Setting it to false reduces animations to still images. This setting is
12436 * recommended when enlarging images or processing arbitrary user content,
12437 * because large GIF animations can weigh tens or even hundreds of megabytes.
12438 * It is also useful to set anim:false when using format:"json" to get the
12439 * response quicker without the number of frames.
12440 */
12441 anim?: boolean;
12442 /**
12443 * What EXIF data should be preserved in the output image. Note that EXIF
12444 * rotation and embedded color profiles are always applied ("baked in" into
12445 * the image), and aren't affected by this option. Note that if the Polish
12446 * feature is enabled, all metadata may have been removed already and this
12447 * option may have no effect.
12448 * - keep: Preserve most of EXIF metadata, including GPS location if there's
12449 * any.
12450 * - copyright: Only keep the copyright tag, and discard everything else.
12451 * This is the default behavior for JPEG files.
12452 * - none: Discard all invisible EXIF metadata. Currently WebP and PNG
12453 * output formats always discard metadata.
12454 */
12455 metadata?: "keep" | "copyright" | "none";
12456 /**
12457 * Strength of sharpening filter to apply to the image. Floating-point
12458 * number between 0 (no sharpening, default) and 10 (maximum). 1.0 is a
12459 * recommended value for downscaled images.
12460 */
12461 sharpen?: number;
12462 /**
12463 * Radius of a blur filter (approximate gaussian). Maximum supported radius
12464 * is 250.
12465 */
12466 blur?: number;
12467 /**
12468 * Overlays are drawn in the order they appear in the array (last array
12469 * entry is the topmost layer).
12470 */
12471 draw?: RequestInitCfPropertiesImageDraw[];
12472 /**
12473 * Fetching image from authenticated origin. Setting this property will
12474 * pass authentication headers (Authorization, Cookie, etc.) through to
12475 * the origin.
12476 */
12477 "origin-auth"?: "share-publicly";
12478 /**
12479 * Adds a border around the image. The border is added after resizing. Border
12480 * width takes dpr into account, and can be specified either using a single
12481 * width property, or individually for each side.
12482 */
12483 border?:
12484 | {
12485 color: string;
12486 width: number;
12487 }
12488 | {
12489 color: string;
12490 top: number;
12491 right: number;
12492 bottom: number;
12493 left: number;
12494 };
12495 /**
12496 * Increase brightness by a factor. A value of 1.0 equals no change, a value
12497 * of 0.5 equals half brightness, and a value of 2.0 equals twice as bright.
12498 * 0 is ignored.
12499 */
12500 brightness?: number;
12501 /**
12502 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
12503 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
12504 * ignored.
12505 */
12506 contrast?: number;
12507 /**
12508 * Increase exposure by a factor. A value of 1.0 equals no change, a value of
12509 * 0.5 darkens the image, and a value of 2.0 lightens the image. 0 is ignored.
12510 */
12511 gamma?: number;
12512 /**
12513 * Increase contrast by a factor. A value of 1.0 equals no change, a value of
12514 * 0.5 equals low contrast, and a value of 2.0 equals high contrast. 0 is
12515 * ignored.
12516 */
12517 saturation?: number;
12518 /**
12519 * Flips the images horizontally, vertically, or both. Flipping is applied before
12520 * rotation, so if you apply flip=h,rotate=90 then the image will be flipped
12521 * horizontally, then rotated by 90 degrees.
12522 */
12523 flip?: "h" | "v" | "hv";
12524 /**
12525 * Slightly reduces latency on a cache miss by selecting a
12526 * quickest-to-compress file format, at a cost of increased file size and
12527 * lower image quality. It will usually override the format option and choose
12528 * JPEG over WebP or AVIF. We do not recommend using this option, except in
12529 * unusual circumstances like resizing uncacheable dynamically-generated
12530 * images.
12531 */
12532 compression?: "fast";
12533}
12534export interface RequestInitCfPropertiesImageMinify {
12535 javascript?: boolean;
12536 css?: boolean;
12537 html?: boolean;
12538}
12539export interface RequestInitCfPropertiesR2 {
12540 /**
12541 * Colo id of bucket that an object is stored in
12542 */
12543 bucketColoId?: number;
12544}
12545/**
12546 * Request metadata provided by Cloudflare's edge.
12547 */
12548export type IncomingRequestCfProperties<HostMetadata = unknown> =
12549 IncomingRequestCfPropertiesBase &
12550 IncomingRequestCfPropertiesBotManagementEnterprise &
12551 IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<HostMetadata> &
12552 IncomingRequestCfPropertiesGeographicInformation &
12553 IncomingRequestCfPropertiesCloudflareAccessOrApiShield;
12554export interface IncomingRequestCfPropertiesBase extends Record<
12555 string,
12556 unknown
12557> {
12558 /**
12559 * [ASN](https://www.iana.org/assignments/as-numbers/as-numbers.xhtml) of the incoming request.
12560 *
12561 * @example 395747
12562 */
12563 asn?: number;
12564 /**
12565 * The organization which owns the ASN of the incoming request.
12566 *
12567 * @example "Google Cloud"
12568 */
12569 asOrganization?: string;
12570 /**
12571 * The original value of the `Accept-Encoding` header if Cloudflare modified it.
12572 *
12573 * @example "gzip, deflate, br"
12574 */
12575 clientAcceptEncoding?: string;
12576 /**
12577 * The number of milliseconds it took for the request to reach your worker.
12578 *
12579 * @example 22
12580 */
12581 clientTcpRtt?: number;
12582 /**
12583 * The three-letter [IATA](https://en.wikipedia.org/wiki/IATA_airport_code)
12584 * airport code of the data center that the request hit.
12585 *
12586 * @example "DFW"
12587 */
12588 colo: string;
12589 /**
12590 * Represents the upstream's response to a
12591 * [TCP `keepalive` message](https://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html)
12592 * from cloudflare.
12593 *
12594 * For workers with no upstream, this will always be `1`.
12595 *
12596 * @example 3
12597 */
12598 edgeRequestKeepAliveStatus: IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus;
12599 /**
12600 * The HTTP Protocol the request used.
12601 *
12602 * @example "HTTP/2"
12603 */
12604 httpProtocol: string;
12605 /**
12606 * The browser-requested prioritization information in the request object.
12607 *
12608 * If no information was set, defaults to the empty string `""`
12609 *
12610 * @example "weight=192;exclusive=0;group=3;group-weight=127"
12611 * @default ""
12612 */
12613 requestPriority: string;
12614 /**
12615 * The TLS version of the connection to Cloudflare.
12616 * In requests served over plaintext (without TLS), this property is the empty string `""`.
12617 *
12618 * @example "TLSv1.3"
12619 */
12620 tlsVersion: string;
12621 /**
12622 * The cipher for the connection to Cloudflare.
12623 * In requests served over plaintext (without TLS), this property is the empty string `""`.
12624 *
12625 * @example "AEAD-AES128-GCM-SHA256"
12626 */
12627 tlsCipher: string;
12628 /**
12629 * 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.
12630 *
12631 * If the incoming request was served over plaintext (without TLS) this field is undefined.
12632 */
12633 tlsExportedAuthenticator?: IncomingRequestCfPropertiesExportedAuthenticatorMetadata;
12634}
12635export interface IncomingRequestCfPropertiesBotManagementBase {
12636 /**
12637 * Cloudflareโ€™s [level of certainty](https://developers.cloudflare.com/bots/concepts/bot-score/) that a request comes from a bot,
12638 * represented as an integer percentage between `1` (almost certainly a bot) and `99` (almost certainly human).
12639 *
12640 * @example 54
12641 */
12642 score: number;
12643 /**
12644 * A boolean value that is true if the request comes from a good bot, like Google or Bing.
12645 * 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).
12646 */
12647 verifiedBot: boolean;
12648 /**
12649 * A boolean value that is true if the request originates from a
12650 * Cloudflare-verified proxy service.
12651 */
12652 corporateProxy: boolean;
12653 /**
12654 * 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.
12655 */
12656 staticResource: boolean;
12657 /**
12658 * 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).
12659 */
12660 detectionIds: number[];
12661}
12662export interface IncomingRequestCfPropertiesBotManagement {
12663 /**
12664 * Results of Cloudflare's Bot Management analysis
12665 */
12666 botManagement: IncomingRequestCfPropertiesBotManagementBase;
12667 /**
12668 * Duplicate of `botManagement.score`.
12669 *
12670 * @deprecated
12671 */
12672 clientTrustScore: number;
12673}
12674export interface IncomingRequestCfPropertiesBotManagementEnterprise extends IncomingRequestCfPropertiesBotManagement {
12675 /**
12676 * Results of Cloudflare's Bot Management analysis
12677 */
12678 botManagement: IncomingRequestCfPropertiesBotManagementBase & {
12679 /**
12680 * A [JA3 Fingerprint](https://developers.cloudflare.com/bots/concepts/ja3-fingerprint/) to help profile specific SSL/TLS clients
12681 * across different destination IPs, Ports, and X509 certificates.
12682 */
12683 ja3Hash: string;
12684 };
12685}
12686export interface IncomingRequestCfPropertiesCloudflareForSaaSEnterprise<
12687 HostMetadata,
12688> {
12689 /**
12690 * Custom metadata set per-host in [Cloudflare for SaaS](https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/).
12691 *
12692 * This field is only present if you have Cloudflare for SaaS enabled on your account
12693 * and you have followed the [required steps to enable it]((https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-for-saas/domain-support/custom-metadata/)).
12694 */
12695 hostMetadata?: HostMetadata;
12696}
12697export interface IncomingRequestCfPropertiesCloudflareAccessOrApiShield {
12698 /**
12699 * Information about the client certificate presented to Cloudflare.
12700 *
12701 * This is populated when the incoming request is served over TLS using
12702 * either Cloudflare Access or API Shield (mTLS)
12703 * and the presented SSL certificate has a valid
12704 * [Certificate Serial Number](https://ldapwiki.com/wiki/Certificate%20Serial%20Number)
12705 * (i.e., not `null` or `""`).
12706 *
12707 * Otherwise, a set of placeholder values are used.
12708 *
12709 * The property `certPresented` will be set to `"1"` when
12710 * the object is populated (i.e. the above conditions were met).
12711 */
12712 tlsClientAuth:
12713 | IncomingRequestCfPropertiesTLSClientAuth
12714 | IncomingRequestCfPropertiesTLSClientAuthPlaceholder;
12715}
12716/**
12717 * Metadata about the request's TLS handshake
12718 */
12719export interface IncomingRequestCfPropertiesExportedAuthenticatorMetadata {
12720 /**
12721 * The client's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12722 *
12723 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12724 */
12725 clientHandshake: string;
12726 /**
12727 * The server's [`HELLO` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.1.2), encoded in hexadecimal
12728 *
12729 * @example "44372ba35fa1270921d318f34c12f155dc87b682cf36a790cfaa3ba8737a1b5d"
12730 */
12731 serverHandshake: string;
12732 /**
12733 * The client's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12734 *
12735 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12736 */
12737 clientFinished: string;
12738 /**
12739 * The server's [`FINISHED` message](https://www.rfc-editor.org/rfc/rfc5246#section-7.4.9), encoded in hexadecimal
12740 *
12741 * @example "084ee802fe1348f688220e2a6040a05b2199a761f33cf753abb1b006792d3f8b"
12742 */
12743 serverFinished: string;
12744}
12745/**
12746 * Geographic data about the request's origin.
12747 */
12748export interface IncomingRequestCfPropertiesGeographicInformation {
12749 /**
12750 * The [ISO 3166-1 Alpha 2](https://www.iso.org/iso-3166-country-codes.html) country code the request originated from.
12751 *
12752 * 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.
12753 *
12754 * If Cloudflare is unable to determine where the request originated this property is omitted.
12755 *
12756 * The country code `"T1"` is used for requests originating on TOR.
12757 *
12758 * @example "GB"
12759 */
12760 country?: Iso3166Alpha2Code | "T1";
12761 /**
12762 * If present, this property indicates that the request originated in the EU
12763 *
12764 * @example "1"
12765 */
12766 isEUCountry?: "1";
12767 /**
12768 * A two-letter code indicating the continent the request originated from.
12769 *
12770 * @example "AN"
12771 */
12772 continent?: ContinentCode;
12773 /**
12774 * The city the request originated from
12775 *
12776 * @example "Austin"
12777 */
12778 city?: string;
12779 /**
12780 * Postal code of the incoming request
12781 *
12782 * @example "78701"
12783 */
12784 postalCode?: string;
12785 /**
12786 * Latitude of the incoming request
12787 *
12788 * @example "30.27130"
12789 */
12790 latitude?: string;
12791 /**
12792 * Longitude of the incoming request
12793 *
12794 * @example "-97.74260"
12795 */
12796 longitude?: string;
12797 /**
12798 * Timezone of the incoming request
12799 *
12800 * @example "America/Chicago"
12801 */
12802 timezone?: string;
12803 /**
12804 * If known, the ISO 3166-2 name for the first level region associated with
12805 * the IP address of the incoming request
12806 *
12807 * @example "Texas"
12808 */
12809 region?: string;
12810 /**
12811 * If known, the ISO 3166-2 code for the first-level region associated with
12812 * the IP address of the incoming request
12813 *
12814 * @example "TX"
12815 */
12816 regionCode?: string;
12817 /**
12818 * Metro code (DMA) of the incoming request
12819 *
12820 * @example "635"
12821 */
12822 metroCode?: string;
12823}
12824/** Data about the incoming request's TLS certificate */
12825export interface IncomingRequestCfPropertiesTLSClientAuth {
12826 /** Always `"1"`, indicating that the certificate was presented */
12827 certPresented: "1";
12828 /**
12829 * Result of certificate verification.
12830 *
12831 * @example "FAILED:self signed certificate"
12832 */
12833 certVerified: Exclude<CertVerificationStatus, "NONE">;
12834 /** The presented certificate's revokation status.
12835 *
12836 * - A value of `"1"` indicates the certificate has been revoked
12837 * - A value of `"0"` indicates the certificate has not been revoked
12838 */
12839 certRevoked: "1" | "0";
12840 /**
12841 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12842 *
12843 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12844 */
12845 certIssuerDN: string;
12846 /**
12847 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html)
12848 *
12849 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12850 */
12851 certSubjectDN: string;
12852 /**
12853 * The certificate issuer's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12854 *
12855 * @example "CN=cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12856 */
12857 certIssuerDNRFC2253: string;
12858 /**
12859 * The certificate subject's [distinguished name](https://knowledge.digicert.com/generalinformation/INFO1745.html) ([RFC 2253](https://www.rfc-editor.org/rfc/rfc2253.html) formatted)
12860 *
12861 * @example "CN=*.cloudflareaccess.com, C=US, ST=Texas, L=Austin, O=Cloudflare"
12862 */
12863 certSubjectDNRFC2253: string;
12864 /** The certificate issuer's distinguished name (legacy policies) */
12865 certIssuerDNLegacy: string;
12866 /** The certificate subject's distinguished name (legacy policies) */
12867 certSubjectDNLegacy: string;
12868 /**
12869 * The certificate's serial number
12870 *
12871 * @example "00936EACBE07F201DF"
12872 */
12873 certSerial: string;
12874 /**
12875 * The certificate issuer's serial number
12876 *
12877 * @example "2489002934BDFEA34"
12878 */
12879 certIssuerSerial: string;
12880 /**
12881 * The certificate's Subject Key Identifier
12882 *
12883 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12884 */
12885 certSKI: string;
12886 /**
12887 * The certificate issuer's Subject Key Identifier
12888 *
12889 * @example "BB:AF:7E:02:3D:FA:A6:F1:3C:84:8E:AD:EE:38:98:EC:D9:32:32:D4"
12890 */
12891 certIssuerSKI: string;
12892 /**
12893 * The certificate's SHA-1 fingerprint
12894 *
12895 * @example "6b9109f323999e52259cda7373ff0b4d26bd232e"
12896 */
12897 certFingerprintSHA1: string;
12898 /**
12899 * The certificate's SHA-256 fingerprint
12900 *
12901 * @example "acf77cf37b4156a2708e34c4eb755f9b5dbbe5ebb55adfec8f11493438d19e6ad3f157f81fa3b98278453d5652b0c1fd1d71e5695ae4d709803a4d3f39de9dea"
12902 */
12903 certFingerprintSHA256: string;
12904 /**
12905 * The effective starting date of the certificate
12906 *
12907 * @example "Dec 22 19:39:00 2018 GMT"
12908 */
12909 certNotBefore: string;
12910 /**
12911 * The effective expiration date of the certificate
12912 *
12913 * @example "Dec 22 19:39:00 2018 GMT"
12914 */
12915 certNotAfter: string;
12916}
12917/** Placeholder values for TLS Client Authorization */
12918export interface IncomingRequestCfPropertiesTLSClientAuthPlaceholder {
12919 certPresented: "0";
12920 certVerified: "NONE";
12921 certRevoked: "0";
12922 certIssuerDN: "";
12923 certSubjectDN: "";
12924 certIssuerDNRFC2253: "";
12925 certSubjectDNRFC2253: "";
12926 certIssuerDNLegacy: "";
12927 certSubjectDNLegacy: "";
12928 certSerial: "";
12929 certIssuerSerial: "";
12930 certSKI: "";
12931 certIssuerSKI: "";
12932 certFingerprintSHA1: "";
12933 certFingerprintSHA256: "";
12934 certNotBefore: "";
12935 certNotAfter: "";
12936}
12937/** Possible outcomes of TLS verification */
12938export declare type CertVerificationStatus =
12939 /** Authentication succeeded */
12940 | "SUCCESS"
12941 /** No certificate was presented */
12942 | "NONE"
12943 /** Failed because the certificate was self-signed */
12944 | "FAILED:self signed certificate"
12945 /** Failed because the certificate failed a trust chain check */
12946 | "FAILED:unable to verify the first certificate"
12947 /** Failed because the certificate not yet valid */
12948 | "FAILED:certificate is not yet valid"
12949 /** Failed because the certificate is expired */
12950 | "FAILED:certificate has expired"
12951 /** Failed for another unspecified reason */
12952 | "FAILED";
12953/**
12954 * An upstream endpoint's response to a TCP `keepalive` message from Cloudflare.
12955 */
12956export declare type IncomingRequestCfPropertiesEdgeRequestKeepAliveStatus =
12957 | 0 /** Unknown */
12958 | 1 /** no keepalives (not found) */
12959 | 2 /** no connection re-use, opening keepalive connection failed */
12960 | 3 /** no connection re-use, keepalive accepted and saved */
12961 | 4 /** connection re-use, refused by the origin server (`TCP FIN`) */
12962 | 5; /** connection re-use, accepted by the origin server */
12963/** ISO 3166-1 Alpha-2 codes */
12964export declare type Iso3166Alpha2Code =
12965 | "AD"
12966 | "AE"
12967 | "AF"
12968 | "AG"
12969 | "AI"
12970 | "AL"
12971 | "AM"
12972 | "AO"
12973 | "AQ"
12974 | "AR"
12975 | "AS"
12976 | "AT"
12977 | "AU"
12978 | "AW"
12979 | "AX"
12980 | "AZ"
12981 | "BA"
12982 | "BB"
12983 | "BD"
12984 | "BE"
12985 | "BF"
12986 | "BG"
12987 | "BH"
12988 | "BI"
12989 | "BJ"
12990 | "BL"
12991 | "BM"
12992 | "BN"
12993 | "BO"
12994 | "BQ"
12995 | "BR"
12996 | "BS"
12997 | "BT"
12998 | "BV"
12999 | "BW"
13000 | "BY"
13001 | "BZ"
13002 | "CA"
13003 | "CC"
13004 | "CD"
13005 | "CF"
13006 | "CG"
13007 | "CH"
13008 | "CI"
13009 | "CK"
13010 | "CL"
13011 | "CM"
13012 | "CN"
13013 | "CO"
13014 | "CR"
13015 | "CU"
13016 | "CV"
13017 | "CW"
13018 | "CX"
13019 | "CY"
13020 | "CZ"
13021 | "DE"
13022 | "DJ"
13023 | "DK"
13024 | "DM"
13025 | "DO"
13026 | "DZ"
13027 | "EC"
13028 | "EE"
13029 | "EG"
13030 | "EH"
13031 | "ER"
13032 | "ES"
13033 | "ET"
13034 | "FI"
13035 | "FJ"
13036 | "FK"
13037 | "FM"
13038 | "FO"
13039 | "FR"
13040 | "GA"
13041 | "GB"
13042 | "GD"
13043 | "GE"
13044 | "GF"
13045 | "GG"
13046 | "GH"
13047 | "GI"
13048 | "GL"
13049 | "GM"
13050 | "GN"
13051 | "GP"
13052 | "GQ"
13053 | "GR"
13054 | "GS"
13055 | "GT"
13056 | "GU"
13057 | "GW"
13058 | "GY"
13059 | "HK"
13060 | "HM"
13061 | "HN"
13062 | "HR"
13063 | "HT"
13064 | "HU"
13065 | "ID"
13066 | "IE"
13067 | "IL"
13068 | "IM"
13069 | "IN"
13070 | "IO"
13071 | "IQ"
13072 | "IR"
13073 | "IS"
13074 | "IT"
13075 | "JE"
13076 | "JM"
13077 | "JO"
13078 | "JP"
13079 | "KE"
13080 | "KG"
13081 | "KH"
13082 | "KI"
13083 | "KM"
13084 | "KN"
13085 | "KP"
13086 | "KR"
13087 | "KW"
13088 | "KY"
13089 | "KZ"
13090 | "LA"
13091 | "LB"
13092 | "LC"
13093 | "LI"
13094 | "LK"
13095 | "LR"
13096 | "LS"
13097 | "LT"
13098 | "LU"
13099 | "LV"
13100 | "LY"
13101 | "MA"
13102 | "MC"
13103 | "MD"
13104 | "ME"
13105 | "MF"
13106 | "MG"
13107 | "MH"
13108 | "MK"
13109 | "ML"
13110 | "MM"
13111 | "MN"
13112 | "MO"
13113 | "MP"
13114 | "MQ"
13115 | "MR"
13116 | "MS"
13117 | "MT"
13118 | "MU"
13119 | "MV"
13120 | "MW"
13121 | "MX"
13122 | "MY"
13123 | "MZ"
13124 | "NA"
13125 | "NC"
13126 | "NE"
13127 | "NF"
13128 | "NG"
13129 | "NI"
13130 | "NL"
13131 | "NO"
13132 | "NP"
13133 | "NR"
13134 | "NU"
13135 | "NZ"
13136 | "OM"
13137 | "PA"
13138 | "PE"
13139 | "PF"
13140 | "PG"
13141 | "PH"
13142 | "PK"
13143 | "PL"
13144 | "PM"
13145 | "PN"
13146 | "PR"
13147 | "PS"
13148 | "PT"
13149 | "PW"
13150 | "PY"
13151 | "QA"
13152 | "RE"
13153 | "RO"
13154 | "RS"
13155 | "RU"
13156 | "RW"
13157 | "SA"
13158 | "SB"
13159 | "SC"
13160 | "SD"
13161 | "SE"
13162 | "SG"
13163 | "SH"
13164 | "SI"
13165 | "SJ"
13166 | "SK"
13167 | "SL"
13168 | "SM"
13169 | "SN"
13170 | "SO"
13171 | "SR"
13172 | "SS"
13173 | "ST"
13174 | "SV"
13175 | "SX"
13176 | "SY"
13177 | "SZ"
13178 | "TC"
13179 | "TD"
13180 | "TF"
13181 | "TG"
13182 | "TH"
13183 | "TJ"
13184 | "TK"
13185 | "TL"
13186 | "TM"
13187 | "TN"
13188 | "TO"
13189 | "TR"
13190 | "TT"
13191 | "TV"
13192 | "TW"
13193 | "TZ"
13194 | "UA"
13195 | "UG"
13196 | "UM"
13197 | "US"
13198 | "UY"
13199 | "UZ"
13200 | "VA"
13201 | "VC"
13202 | "VE"
13203 | "VG"
13204 | "VI"
13205 | "VN"
13206 | "VU"
13207 | "WF"
13208 | "WS"
13209 | "YE"
13210 | "YT"
13211 | "ZA"
13212 | "ZM"
13213 | "ZW";
13214/** The 2-letter continent codes Cloudflare uses */
13215export declare type ContinentCode =
13216 | "AF"
13217 | "AN"
13218 | "AS"
13219 | "EU"
13220 | "NA"
13221 | "OC"
13222 | "SA";
13223export type CfProperties<HostMetadata = unknown> =
13224 | IncomingRequestCfProperties<HostMetadata>
13225 | RequestInitCfProperties;
13226export interface D1Meta {
13227 duration: number;
13228 size_after: number;
13229 rows_read: number;
13230 rows_written: number;
13231 last_row_id: number;
13232 changed_db: boolean;
13233 changes: number;
13234 /**
13235 * The region of the database instance that executed the query.
13236 */
13237 served_by_region?: string;
13238 /**
13239 * The three letters airport code of the colo that executed the query.
13240 */
13241 served_by_colo?: string;
13242 /**
13243 * True if-and-only-if the database instance that executed the query was the primary.
13244 */
13245 served_by_primary?: boolean;
13246 timings?: {
13247 /**
13248 * The duration of the SQL query execution by the database instance. It doesn't include any network time.
13249 */
13250 sql_duration_ms: number;
13251 };
13252 /**
13253 * Number of total attempts to execute the query, due to automatic retries.
13254 * Note: All other fields in the response like `timings` only apply to the last attempt.
13255 */
13256 total_attempts?: number;
13257}
13258export interface D1Response {
13259 success: true;
13260 meta: D1Meta & Record<string, unknown>;
13261 error?: never;
13262}
13263export type D1Result<T = unknown> = D1Response & {
13264 results: T[];
13265};
13266export interface D1ExecResult {
13267 count: number;
13268 duration: number;
13269}
13270export type D1SessionConstraint =
13271 // Indicates that the first query should go to the primary, and the rest queries
13272 // using the same D1DatabaseSession will go to any replica that is consistent with
13273 // the bookmark maintained by the session (returned by the first query).
13274 | "first-primary"
13275 // Indicates that the first query can go anywhere (primary or replica), and the rest queries
13276 // using the same D1DatabaseSession will go to any replica that is consistent with
13277 // the bookmark maintained by the session (returned by the first query).
13278 | "first-unconstrained";
13279export type D1SessionBookmark = string;
13280export declare abstract class D1Database {
13281 prepare(query: string): D1PreparedStatement;
13282 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13283 exec(query: string): Promise<D1ExecResult>;
13284 /**
13285 * Creates a new D1 Session anchored at the given constraint or the bookmark.
13286 * All queries executed using the created session will have sequential consistency,
13287 * meaning that all writes done through the session will be visible in subsequent reads.
13288 *
13289 * @param constraintOrBookmark Either the session constraint or the explicit bookmark to anchor the created session.
13290 */
13291 withSession(
13292 constraintOrBookmark?: D1SessionBookmark | D1SessionConstraint,
13293 ): D1DatabaseSession;
13294 /**
13295 * @deprecated dump() will be removed soon, only applies to deprecated alpha v1 databases.
13296 */
13297 dump(): Promise<ArrayBuffer>;
13298}
13299export declare abstract class D1DatabaseSession {
13300 prepare(query: string): D1PreparedStatement;
13301 batch<T = unknown>(statements: D1PreparedStatement[]): Promise<D1Result<T>[]>;
13302 /**
13303 * @returns The latest session bookmark across all executed queries on the session.
13304 * If no query has been executed yet, `null` is returned.
13305 */
13306 getBookmark(): D1SessionBookmark | null;
13307}
13308export declare abstract class D1PreparedStatement {
13309 bind(...values: unknown[]): D1PreparedStatement;
13310 first<T = unknown>(colName: string): Promise<T | null>;
13311 first<T = Record<string, unknown>>(): Promise<T | null>;
13312 run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
13313 all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
13314 raw<T = unknown[]>(options: {
13315 columnNames: true;
13316 }): Promise<[string[], ...T[]]>;
13317 raw<T = unknown[]>(options?: { columnNames?: false }): Promise<T[]>;
13318}
13319// `Disposable` was added to TypeScript's standard lib types in version 5.2.
13320// To support older TypeScript versions, define an empty `Disposable` interface.
13321// Users won't be able to use `using`/`Symbol.dispose` without upgrading to 5.2,
13322// but this will ensure type checking on older versions still passes.
13323// TypeScript's interface merging will ensure our empty interface is effectively
13324// ignored when `Disposable` is included in the standard lib.
13325export interface Disposable {}
13326/**
13327 * The returned data after sending an email
13328 */
13329export interface EmailSendResult {
13330 /**
13331 * The Email Message ID
13332 */
13333 messageId: string;
13334}
13335/**
13336 * An email message that can be sent from a Worker.
13337 */
13338export interface EmailMessage {
13339 /**
13340 * Envelope From attribute of the email message.
13341 */
13342 readonly from: string;
13343 /**
13344 * Envelope To attribute of the email message.
13345 */
13346 readonly to: string;
13347}
13348/**
13349 * An email message that is sent to a consumer Worker and can be rejected/forwarded.
13350 */
13351export interface ForwardableEmailMessage extends EmailMessage {
13352 /**
13353 * Stream of the email message content.
13354 */
13355 readonly raw: ReadableStream<Uint8Array>;
13356 /**
13357 * An [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
13358 */
13359 readonly headers: Headers;
13360 /**
13361 * Size of the email message content.
13362 */
13363 readonly rawSize: number;
13364 /**
13365 * Reject this email message by returning a permanent SMTP error back to the connecting client including the given reason.
13366 * @param reason The reject reason.
13367 * @returns void
13368 */
13369 setReject(reason: string): void;
13370 /**
13371 * Forward this email message to a verified destination address of the account.
13372 * @param rcptTo Verified destination address.
13373 * @param headers A [Headers object](https://developer.mozilla.org/en-US/docs/Web/API/Headers).
13374 * @returns A promise that resolves when the email message is forwarded.
13375 */
13376 forward(rcptTo: string, headers?: Headers): Promise<EmailSendResult>;
13377 /**
13378 * Reply to the sender of this email message with a new EmailMessage object.
13379 * @param message The reply message.
13380 * @returns A promise that resolves when the email message is replied.
13381 */
13382 reply(message: EmailMessage): Promise<EmailSendResult>;
13383}
13384/** A file attachment for an email message */
13385export type EmailAttachment =
13386 | {
13387 disposition: "inline";
13388 contentId: string;
13389 filename: string;
13390 type: string;
13391 content: string | ArrayBuffer | ArrayBufferView;
13392 }
13393 | {
13394 disposition: "attachment";
13395 contentId?: undefined;
13396 filename: string;
13397 type: string;
13398 content: string | ArrayBuffer | ArrayBufferView;
13399 };
13400/** An Email Address */
13401export interface EmailAddress {
13402 name: string;
13403 email: string;
13404}
13405/**
13406 * A binding that allows a Worker to send email messages.
13407 */
13408export interface SendEmail {
13409 send(message: EmailMessage): Promise<EmailSendResult>;
13410 send(builder: {
13411 from: string | EmailAddress;
13412 to: string | string[];
13413 subject: string;
13414 replyTo?: string | EmailAddress;
13415 cc?: string | string[];
13416 bcc?: string | string[];
13417 headers?: Record<string, string>;
13418 text?: string;
13419 html?: string;
13420 attachments?: EmailAttachment[];
13421 }): Promise<EmailSendResult>;
13422}
13423export declare abstract class EmailEvent extends ExtendableEvent {
13424 readonly message: ForwardableEmailMessage;
13425}
13426export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
13427 message: ForwardableEmailMessage,
13428 env: Env,
13429 ctx: ExecutionContext<Props>,
13430) => void | Promise<void>;
13431/**
13432 * Evaluation context for targeting rules.
13433 * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
13434 */
13435export type FlagshipEvaluationContext = Record<
13436 string,
13437 string | number | boolean
13438>;
13439export interface FlagshipEvaluationDetails<T> {
13440 flagKey: string;
13441 value: T;
13442 variant?: string | undefined;
13443 reason?: string | undefined;
13444 errorCode?: string | undefined;
13445 errorMessage?: string | undefined;
13446}
13447export interface FlagshipEvaluationError extends Error {}
13448/**
13449 * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
13450 *
13451 * @example
13452 * ```typescript
13453 * // Get a boolean flag value with a default
13454 * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
13455 *
13456 * // Get a flag value with evaluation context for targeting
13457 * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
13458 * userId: 'user-123',
13459 * country: 'US',
13460 * });
13461 *
13462 * // Get full evaluation details including variant and reason
13463 * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
13464 * console.log(details.variant, details.reason);
13465 * ```
13466 */
13467export declare abstract class Flagship {
13468 /**
13469 * Get a flag value without type checking.
13470 * @param flagKey The key of the flag to evaluate.
13471 * @param defaultValue Optional default value returned when evaluation fails.
13472 * @param context Optional evaluation context for targeting rules.
13473 */
13474 get(
13475 flagKey: string,
13476 defaultValue?: unknown,
13477 context?: FlagshipEvaluationContext,
13478 ): Promise<unknown>;
13479 /**
13480 * Get a boolean flag value.
13481 * @param flagKey The key of the flag to evaluate.
13482 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13483 * @param context Optional evaluation context for targeting rules.
13484 */
13485 getBooleanValue(
13486 flagKey: string,
13487 defaultValue: boolean,
13488 context?: FlagshipEvaluationContext,
13489 ): Promise<boolean>;
13490 /**
13491 * Get a string flag value.
13492 * @param flagKey The key of the flag to evaluate.
13493 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13494 * @param context Optional evaluation context for targeting rules.
13495 */
13496 getStringValue(
13497 flagKey: string,
13498 defaultValue: string,
13499 context?: FlagshipEvaluationContext,
13500 ): Promise<string>;
13501 /**
13502 * Get a number flag value.
13503 * @param flagKey The key of the flag to evaluate.
13504 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13505 * @param context Optional evaluation context for targeting rules.
13506 */
13507 getNumberValue(
13508 flagKey: string,
13509 defaultValue: number,
13510 context?: FlagshipEvaluationContext,
13511 ): Promise<number>;
13512 /**
13513 * Get an object flag value.
13514 * @param flagKey The key of the flag to evaluate.
13515 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13516 * @param context Optional evaluation context for targeting rules.
13517 */
13518 getObjectValue<T extends object>(
13519 flagKey: string,
13520 defaultValue: T,
13521 context?: FlagshipEvaluationContext,
13522 ): Promise<T>;
13523 /**
13524 * Get a boolean flag value with full evaluation details.
13525 * @param flagKey The key of the flag to evaluate.
13526 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13527 * @param context Optional evaluation context for targeting rules.
13528 */
13529 getBooleanDetails(
13530 flagKey: string,
13531 defaultValue: boolean,
13532 context?: FlagshipEvaluationContext,
13533 ): Promise<FlagshipEvaluationDetails<boolean>>;
13534 /**
13535 * Get a string flag value with full evaluation details.
13536 * @param flagKey The key of the flag to evaluate.
13537 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13538 * @param context Optional evaluation context for targeting rules.
13539 */
13540 getStringDetails(
13541 flagKey: string,
13542 defaultValue: string,
13543 context?: FlagshipEvaluationContext,
13544 ): Promise<FlagshipEvaluationDetails<string>>;
13545 /**
13546 * Get a number flag value with full evaluation details.
13547 * @param flagKey The key of the flag to evaluate.
13548 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13549 * @param context Optional evaluation context for targeting rules.
13550 */
13551 getNumberDetails(
13552 flagKey: string,
13553 defaultValue: number,
13554 context?: FlagshipEvaluationContext,
13555 ): Promise<FlagshipEvaluationDetails<number>>;
13556 /**
13557 * Get an object flag value with full evaluation details.
13558 * @param flagKey The key of the flag to evaluate.
13559 * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
13560 * @param context Optional evaluation context for targeting rules.
13561 */
13562 getObjectDetails<T extends object>(
13563 flagKey: string,
13564 defaultValue: T,
13565 context?: FlagshipEvaluationContext,
13566 ): Promise<FlagshipEvaluationDetails<T>>;
13567}
13568/**
13569 * Hello World binding to serve as an explanatory example. DO NOT USE
13570 */
13571export interface HelloWorldBinding {
13572 /**
13573 * Retrieve the current stored value
13574 */
13575 get(): Promise<{
13576 value: string;
13577 ms?: number;
13578 }>;
13579 /**
13580 * Set a new stored value
13581 */
13582 set(value: string): Promise<void>;
13583}
13584export interface Hyperdrive {
13585 /**
13586 * Connect directly to Hyperdrive as if it's your database, returning a TCP socket.
13587 *
13588 * Calling this method returns an identical socket to if you call
13589 * `connect("host:port")` using the `host` and `port` fields from this object.
13590 * Pick whichever approach works better with your preferred DB client library.
13591 *
13592 * Note that this socket is not yet authenticated -- it's expected that your
13593 * code (or preferably, the client library of your choice) will authenticate
13594 * using the information in this class's readonly fields.
13595 */
13596 connect(): Socket;
13597 /**
13598 * A valid DB connection string that can be passed straight into the typical
13599 * client library/driver/ORM. This will typically be the easiest way to use
13600 * Hyperdrive.
13601 */
13602 readonly connectionString: string;
13603 /*
13604 * A randomly generated hostname that is only valid within the context of the
13605 * currently running Worker which, when passed into `connect()` function from
13606 * the "cloudflare:sockets" module, will connect to the Hyperdrive instance
13607 * for your database.
13608 */
13609 readonly host: string;
13610 /*
13611 * The port that must be paired the the host field when connecting.
13612 */
13613 readonly port: number;
13614 /*
13615 * The username to use when authenticating to your database via Hyperdrive.
13616 * Unlike the host and password, this will be the same every time
13617 */
13618 readonly user: string;
13619 /*
13620 * The randomly generated password to use when authenticating to your
13621 * database via Hyperdrive. Like the host field, this password is only valid
13622 * within the context of the currently running Worker instance from which
13623 * it's read.
13624 */
13625 readonly password: string;
13626 /*
13627 * The name of the database to connect to.
13628 */
13629 readonly database: string;
13630}
13631// Copyright (c) 2024 Cloudflare, Inc.
13632// Licensed under the Apache 2.0 license found in the LICENSE file or at:
13633// https://opensource.org/licenses/Apache-2.0
13634export type ImageInfoResponse =
13635 | {
13636 format: "image/svg+xml";
13637 }
13638 | {
13639 format: string;
13640 fileSize: number;
13641 width: number;
13642 height: number;
13643 };
13644export type ImageTransform = {
13645 width?: number;
13646 height?: number;
13647 background?: string;
13648 blur?: number;
13649 border?:
13650 | {
13651 color?: string;
13652 width?: number;
13653 }
13654 | {
13655 top?: number;
13656 bottom?: number;
13657 left?: number;
13658 right?: number;
13659 };
13660 brightness?: number;
13661 contrast?: number;
13662 fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
13663 flip?: "h" | "v" | "hv";
13664 gamma?: number;
13665 segment?: "foreground";
13666 gravity?:
13667 | "face"
13668 | "left"
13669 | "right"
13670 | "top"
13671 | "bottom"
13672 | "center"
13673 | "auto"
13674 | "entropy"
13675 | {
13676 x?: number;
13677 y?: number;
13678 mode: "remainder" | "box-center";
13679 };
13680 rotate?: 0 | 90 | 180 | 270;
13681 saturation?: number;
13682 sharpen?: number;
13683 trim?:
13684 | "border"
13685 | {
13686 top?: number;
13687 bottom?: number;
13688 left?: number;
13689 right?: number;
13690 width?: number;
13691 height?: number;
13692 border?:
13693 | boolean
13694 | {
13695 color?: string;
13696 tolerance?: number;
13697 keep?: number;
13698 };
13699 };
13700};
13701export type ImageDrawOptions = {
13702 opacity?: number;
13703 repeat?: boolean | string;
13704 top?: number;
13705 left?: number;
13706 bottom?: number;
13707 right?: number;
13708};
13709export type ImageInputOptions = {
13710 encoding?: "base64";
13711};
13712export type ImageOutputOptions = {
13713 format:
13714 | "image/jpeg"
13715 | "image/png"
13716 | "image/gif"
13717 | "image/webp"
13718 | "image/avif"
13719 | "rgb"
13720 | "rgba";
13721 quality?: number;
13722 background?: string;
13723 anim?: boolean;
13724};
13725export interface ImageMetadata {
13726 id: string;
13727 filename?: string;
13728 uploaded?: string;
13729 requireSignedURLs: boolean;
13730 meta?: Record<string, unknown>;
13731 variants: string[];
13732 draft?: boolean;
13733 creator?: string;
13734}
13735export interface ImageUploadOptions {
13736 id?: string;
13737 filename?: string;
13738 requireSignedURLs?: boolean;
13739 metadata?: Record<string, unknown>;
13740 creator?: string;
13741 encoding?: "base64";
13742}
13743export interface ImageUpdateOptions {
13744 requireSignedURLs?: boolean;
13745 metadata?: Record<string, unknown>;
13746 creator?: string;
13747}
13748export interface ImageListOptions {
13749 limit?: number;
13750 cursor?: string;
13751 sortOrder?: "asc" | "desc";
13752 creator?: string;
13753}
13754export interface ImageList {
13755 images: ImageMetadata[];
13756 cursor?: string;
13757 listComplete: boolean;
13758}
13759export interface ImageHandle {
13760 /**
13761 * Get metadata for a hosted image
13762 * @returns Image metadata, or null if not found
13763 */
13764 details(): Promise<ImageMetadata | null>;
13765 /**
13766 * Get the raw image data for a hosted image
13767 * @returns ReadableStream of image bytes, or null if not found
13768 */
13769 bytes(): Promise<ReadableStream<Uint8Array> | null>;
13770 /**
13771 * Update hosted image metadata
13772 * @param options Properties to update
13773 * @returns Updated image metadata
13774 * @throws {@link ImagesError} if update fails
13775 */
13776 update(options: ImageUpdateOptions): Promise<ImageMetadata>;
13777 /**
13778 * Delete a hosted image
13779 * @returns True if deleted, false if not found
13780 */
13781 delete(): Promise<boolean>;
13782}
13783export interface HostedImagesBinding {
13784 /**
13785 * Get a handle for a hosted image
13786 * @param imageId The ID of the image (UUID or custom ID)
13787 * @returns A handle for per-image operations
13788 */
13789 image(imageId: string): ImageHandle;
13790 /**
13791 * Upload a new hosted image
13792 * @param image The image file to upload
13793 * @param options Upload configuration
13794 * @returns Metadata for the uploaded image
13795 * @throws {@link ImagesError} if upload fails
13796 */
13797 upload(
13798 image: ReadableStream<Uint8Array> | ArrayBuffer,
13799 options?: ImageUploadOptions,
13800 ): Promise<ImageMetadata>;
13801 /**
13802 * List hosted images with pagination
13803 * @param options List configuration
13804 * @returns List of images with pagination info
13805 * @throws {@link ImagesError} if list fails
13806 */
13807 list(options?: ImageListOptions): Promise<ImageList>;
13808}
13809export interface ImagesBinding {
13810 /**
13811 * Get image metadata (type, width and height)
13812 * @throws {@link ImagesError} with code 9412 if input is not an image
13813 * @param stream The image bytes
13814 */
13815 info(
13816 stream: ReadableStream<Uint8Array>,
13817 options?: ImageInputOptions,
13818 ): Promise<ImageInfoResponse>;
13819 /**
13820 * Begin applying a series of transformations to an image
13821 * @param stream The image bytes
13822 * @returns A transform handle
13823 */
13824 input(
13825 stream: ReadableStream<Uint8Array>,
13826 options?: ImageInputOptions,
13827 ): ImageTransformer;
13828 /**
13829 * Access hosted images CRUD operations
13830 */
13831 readonly hosted: HostedImagesBinding;
13832}
13833export interface ImageTransformer {
13834 /**
13835 * Apply transform next, returning a transform handle.
13836 * You can then apply more transformations, draw, or retrieve the output.
13837 * @param transform
13838 */
13839 transform(transform: ImageTransform): ImageTransformer;
13840 /**
13841 * Draw an image on this transformer, returning a transform handle.
13842 * You can then apply more transformations, draw, or retrieve the output.
13843 * @param image The image (or transformer that will give the image) to draw
13844 * @param options The options configuring how to draw the image
13845 */
13846 draw(
13847 image: ReadableStream<Uint8Array> | ImageTransformer,
13848 options?: ImageDrawOptions,
13849 ): ImageTransformer;
13850 /**
13851 * Retrieve the image that results from applying the transforms to the
13852 * provided input
13853 * @param options Options that apply to the output e.g. output format
13854 */
13855 output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
13856}
13857export type ImageTransformationOutputOptions = {
13858 encoding?: "base64";
13859};
13860export interface ImageTransformationResult {
13861 /**
13862 * The image as a response, ready to store in cache or return to users
13863 */
13864 response(): Response;
13865 /**
13866 * The content type of the returned image
13867 */
13868 contentType(): string;
13869 /**
13870 * The bytes of the response
13871 */
13872 image(options?: ImageTransformationOutputOptions): ReadableStream<Uint8Array>;
13873}
13874export interface ImagesError extends Error {
13875 readonly code: number;
13876 readonly message: string;
13877 readonly stack?: string;
13878}
13879/**
13880 * Media binding for transforming media streams.
13881 * Provides the entry point for media transformation operations.
13882 */
13883export interface MediaBinding {
13884 /**
13885 * Creates a media transformer from an input stream.
13886 * @param media - The input media bytes
13887 * @returns A MediaTransformer instance for applying transformations
13888 */
13889 input(media: ReadableStream<Uint8Array>): MediaTransformer;
13890}
13891/**
13892 * Media transformer for applying transformation operations to media content.
13893 * Handles sizing, fitting, and other input transformation parameters.
13894 */
13895export interface MediaTransformer {
13896 /**
13897 * Applies transformation options to the media content.
13898 * @param transform - Configuration for how the media should be transformed
13899 * @returns A generator for producing the transformed media output
13900 */
13901 transform(
13902 transform?: MediaTransformationInputOptions,
13903 ): MediaTransformationGenerator;
13904 /**
13905 * Generates the final media output with specified options.
13906 * @param output - Configuration for the output format and parameters
13907 * @returns The final transformation result containing the transformed media
13908 */
13909 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13910}
13911/**
13912 * Generator for producing media transformation results.
13913 * Configures the output format and parameters for the transformed media.
13914 */
13915export interface MediaTransformationGenerator {
13916 /**
13917 * Generates the final media output with specified options.
13918 * @param output - Configuration for the output format and parameters
13919 * @returns The final transformation result containing the transformed media
13920 */
13921 output(output?: MediaTransformationOutputOptions): MediaTransformationResult;
13922}
13923/**
13924 * Result of a media transformation operation.
13925 * Provides multiple ways to access the transformed media content.
13926 */
13927export interface MediaTransformationResult {
13928 /**
13929 * Returns the transformed media as a readable stream of bytes.
13930 * @returns A promise containing a readable stream with the transformed media
13931 */
13932 media(): Promise<ReadableStream<Uint8Array>>;
13933 /**
13934 * Returns the transformed media as an HTTP response object.
13935 * @returns The transformed media as a Promise<Response>, ready to store in cache or return to users
13936 */
13937 response(): Promise<Response>;
13938 /**
13939 * Returns the MIME type of the transformed media.
13940 * @returns A promise containing the content type string (e.g., 'image/jpeg', 'video/mp4')
13941 */
13942 contentType(): Promise<string>;
13943}
13944/**
13945 * Configuration options for transforming media input.
13946 * Controls how the media should be resized and fitted.
13947 */
13948export type MediaTransformationInputOptions = {
13949 /** How the media should be resized to fit the specified dimensions */
13950 fit?: "contain" | "cover" | "scale-down";
13951 /** Target width in pixels */
13952 width?: number;
13953 /** Target height in pixels */
13954 height?: number;
13955};
13956/**
13957 * Configuration options for Media Transformations output.
13958 * Controls the format, timing, and type of the generated output.
13959 */
13960export type MediaTransformationOutputOptions = {
13961 /**
13962 * Output mode determining the type of media to generate
13963 */
13964 mode?: "video" | "spritesheet" | "frame" | "audio";
13965 /** Whether to include audio in the output */
13966 audio?: boolean;
13967 /**
13968 * Starting timestamp for frame extraction or start time for clips. (e.g. '2s').
13969 */
13970 time?: string;
13971 /**
13972 * Duration for video clips, audio extraction, and spritesheet generation (e.g. '5s').
13973 */
13974 duration?: string;
13975 /**
13976 * Number of frames in the spritesheet.
13977 */
13978 imageCount?: number;
13979 /**
13980 * Output format for the generated media.
13981 */
13982 format?: "jpg" | "png" | "m4a";
13983};
13984/**
13985 * Error object for media transformation operations.
13986 * Extends the standard Error interface with additional media-specific information.
13987 */
13988export interface MediaError extends Error {
13989 readonly code: number;
13990 readonly message: string;
13991 readonly stack?: string;
13992}
13993export type Params<P extends string = any> = Record<P, string | string[]>;
13994export type EventContext<Env, P extends string, Data> = {
13995 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
13996 functionPath: string;
13997 waitUntil: (promise: Promise<any>) => void;
13998 passThroughOnException: () => void;
13999 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
14000 env: Env & {
14001 ASSETS: {
14002 fetch: typeof fetch;
14003 };
14004 };
14005 params: Params<P>;
14006 data: Data;
14007};
14008export type PagesFunction<
14009 Env = unknown,
14010 Params extends string = any,
14011 Data extends Record<string, unknown> = Record<string, unknown>,
14012> = (context: EventContext<Env, Params, Data>) => Response | Promise<Response>;
14013export type EventPluginContext<Env, P extends string, Data, PluginArgs> = {
14014 request: Request<unknown, IncomingRequestCfProperties<unknown>>;
14015 functionPath: string;
14016 waitUntil: (promise: Promise<any>) => void;
14017 passThroughOnException: () => void;
14018 next: (input?: Request | string, init?: RequestInit) => Promise<Response>;
14019 env: Env & {
14020 ASSETS: {
14021 fetch: typeof fetch;
14022 };
14023 };
14024 params: Params<P>;
14025 data: Data;
14026 pluginArgs: PluginArgs;
14027};
14028export type PagesPluginFunction<
14029 Env = unknown,
14030 Params extends string = any,
14031 Data extends Record<string, unknown> = Record<string, unknown>,
14032 PluginArgs = unknown,
14033> = (
14034 context: EventPluginContext<Env, Params, Data, PluginArgs>,
14035) => Response | Promise<Response>;
14036// PubSubMessage represents an incoming PubSub message.
14037// The message includes metadata about the broker, the client, and the payload
14038// itself.
14039// https://developers.cloudflare.com/pub-sub/
14040export interface PubSubMessage {
14041 // Message ID
14042 readonly mid: number;
14043 // MQTT broker FQDN in the form mqtts://BROKER.NAMESPACE.cloudflarepubsub.com:PORT
14044 readonly broker: string;
14045 // The MQTT topic the message was sent on.
14046 readonly topic: string;
14047 // The client ID of the client that published this message.
14048 readonly clientId: string;
14049 // The unique identifier (JWT ID) used by the client to authenticate, if token
14050 // auth was used.
14051 readonly jti?: string;
14052 // A Unix timestamp (seconds from Jan 1, 1970), set when the Pub/Sub Broker
14053 // received the message from the client.
14054 readonly receivedAt: number;
14055 // An (optional) string with the MIME type of the payload, if set by the
14056 // client.
14057 readonly contentType: string;
14058 // Set to 1 when the payload is a UTF-8 string
14059 // https://docs.oasis-open.org/mqtt/mqtt/v5.0/os/mqtt-v5.0-os.html#_Toc3901063
14060 readonly payloadFormatIndicator: number;
14061 // Pub/Sub (MQTT) payloads can be UTF-8 strings, or byte arrays.
14062 // You can use payloadFormatIndicator to inspect this before decoding.
14063 payload: string | Uint8Array;
14064}
14065// JsonWebKey extended by kid parameter
14066export interface JsonWebKeyWithKid extends JsonWebKey {
14067 // Key Identifier of the JWK
14068 readonly kid: string;
14069}
14070export interface RateLimitOptions {
14071 key: string;
14072}
14073export interface RateLimitOutcome {
14074 success: boolean;
14075}
14076export interface RateLimit {
14077 /**
14078 * Rate limit a request based on the provided options.
14079 * @see https://developers.cloudflare.com/workers/runtime-apis/bindings/rate-limit/
14080 * @returns A promise that resolves with the outcome of the rate limit.
14081 */
14082 limit(options: RateLimitOptions): Promise<RateLimitOutcome>;
14083}
14084// Namespace for RPC utility types. Unfortunately, we can't use a `module` here as these types need
14085// to referenced by `Fetcher`. This is included in the "importable" version of the types which
14086// strips all `module` blocks.
14087export declare namespace Rpc {
14088 // Branded types for identifying `WorkerEntrypoint`/`DurableObject`/`Target`s.
14089 // TypeScript uses *structural* typing meaning anything with the same shape as type `T` is a `T`.
14090 // For the classes exported by `cloudflare:workers` we want *nominal* typing (i.e. we only want to
14091 // accept `WorkerEntrypoint` from `cloudflare:workers`, not any other class with the same shape)
14092 export const __RPC_STUB_BRAND: "__RPC_STUB_BRAND";
14093 export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
14094 export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
14095 export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
14096 export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
14097 export interface RpcTargetBranded {
14098 [__RPC_TARGET_BRAND]: never;
14099 }
14100 export interface WorkerEntrypointBranded {
14101 [__WORKER_ENTRYPOINT_BRAND]: never;
14102 }
14103 export interface DurableObjectBranded {
14104 [__DURABLE_OBJECT_BRAND]: never;
14105 }
14106 export interface WorkflowEntrypointBranded {
14107 [__WORKFLOW_ENTRYPOINT_BRAND]: never;
14108 }
14109 export type EntrypointBranded =
14110 | WorkerEntrypointBranded
14111 | DurableObjectBranded
14112 | WorkflowEntrypointBranded;
14113 // Types that can be used through `Stub`s
14114 export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
14115 // Types that can be passed over RPC
14116 // The reason for using a generic type here is to build a serializable subset of structured
14117 // cloneable composite types. This allows types defined with the "interface" keyword to pass the
14118 // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
14119 type Serializable<T> =
14120 // Structured cloneables
14121 | BaseType
14122 // Structured cloneable composites
14123 | Map<
14124 T extends Map<infer U, unknown> ? Serializable<U> : never,
14125 T extends Map<unknown, infer U> ? Serializable<U> : never
14126 >
14127 | Set<T extends Set<infer U> ? Serializable<U> : never>
14128 | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
14129 | {
14130 [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
14131 }
14132 // Special types
14133 | Stub<Stubable>
14134 // Serialized as stubs, see `Stubify`
14135 | Stubable;
14136 // Base type for all RPC stubs, including common memory management methods.
14137 // `T` is used as a marker type for unwrapping `Stub`s later.
14138 interface StubBase<T extends Stubable> extends Disposable {
14139 [__RPC_STUB_BRAND]: T;
14140 dup(): this;
14141 }
14142 export type Stub<T extends Stubable> = Provider<T> & StubBase<T>;
14143 // This represents all the types that can be sent as-is over an RPC boundary
14144 type BaseType =
14145 | void
14146 | undefined
14147 | null
14148 | boolean
14149 | number
14150 | bigint
14151 | string
14152 | TypedArray
14153 | ArrayBuffer
14154 | DataView
14155 | Date
14156 | Error
14157 | RegExp
14158 | ReadableStream<Uint8Array>
14159 | WritableStream<Uint8Array>
14160 | Request
14161 | Response
14162 | Headers;
14163 // Recursively rewrite all `Stubable` types with `Stub`s
14164 type Stubify<T> = T extends Stubable
14165 ? Stub<T>
14166 : T extends Map<infer K, infer V>
14167 ? Map<Stubify<K>, Stubify<V>>
14168 : T extends Set<infer V>
14169 ? Set<Stubify<V>>
14170 : T extends Array<infer V>
14171 ? Array<Stubify<V>>
14172 : T extends ReadonlyArray<infer V>
14173 ? ReadonlyArray<Stubify<V>>
14174 : T extends BaseType
14175 ? T
14176 : T extends {
14177 [key: string | number]: any;
14178 }
14179 ? {
14180 [K in keyof T]: Stubify<T[K]>;
14181 }
14182 : T;
14183 // Recursively rewrite all `Stub<T>`s with the corresponding `T`s.
14184 // Note we use `StubBase` instead of `Stub` here to avoid circular dependencies:
14185 // `Stub` depends on `Provider`, which depends on `Unstubify`, which would depend on `Stub`.
14186 type Unstubify<T> =
14187 T extends StubBase<infer V>
14188 ? V
14189 : T extends Map<infer K, infer V>
14190 ? Map<Unstubify<K>, Unstubify<V>>
14191 : T extends Set<infer V>
14192 ? Set<Unstubify<V>>
14193 : T extends Array<infer V>
14194 ? Array<Unstubify<V>>
14195 : T extends ReadonlyArray<infer V>
14196 ? ReadonlyArray<Unstubify<V>>
14197 : T extends BaseType
14198 ? T
14199 : T extends {
14200 [key: string | number]: unknown;
14201 }
14202 ? {
14203 [K in keyof T]: Unstubify<T[K]>;
14204 }
14205 : T;
14206 type UnstubifyAll<A extends any[]> = {
14207 [I in keyof A]: Unstubify<A[I]>;
14208 };
14209 // Utility type for adding `Provider`/`Disposable`s to `object` types only.
14210 // Note `unknown & T` is equivalent to `T`.
14211 type MaybeProvider<T> = T extends object ? Provider<T> : unknown;
14212 type MaybeDisposable<T> = T extends object ? Disposable : unknown;
14213 // Type for method return or property on an RPC interface.
14214 // - Stubable types are replaced by stubs.
14215 // - Serializable types are passed by value, with stubable types replaced by stubs
14216 // and a top-level `Disposer`.
14217 // Everything else can't be passed over PRC.
14218 // Technically, we use custom thenables here, but they quack like `Promise`s.
14219 // Intersecting with `(Maybe)Provider` allows pipelining.
14220 type Result<R> = R extends Stubable
14221 ? Promise<Stub<R>> & Provider<R>
14222 : R extends Serializable<R>
14223 ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
14224 : never;
14225 // Type for method or property on an RPC interface.
14226 // For methods, unwrap `Stub`s in parameters, and rewrite returns to be `Result`s.
14227 // Unwrapping `Stub`s allows calling with `Stubable` arguments.
14228 // For properties, rewrite types to be `Result`s.
14229 // In each case, unwrap `Promise`s.
14230 type MethodOrProperty<V> = V extends (...args: infer P) => infer R
14231 ? (...args: UnstubifyAll<P>) => Result<Awaited<R>>
14232 : Result<Awaited<V>>;
14233 // Type for the callable part of an `Provider` if `T` is callable.
14234 // This is intersected with methods/properties.
14235 type MaybeCallableProvider<T> = T extends (...args: any[]) => any
14236 ? MethodOrProperty<T>
14237 : unknown;
14238 // Base type for all other types providing RPC-like interfaces.
14239 // Rewrites all methods/properties to be `MethodOrProperty`s, while preserving callable types.
14240 // `Reserved` names (e.g. stub method names like `dup()`) and symbols can't be accessed over RPC.
14241 export type Provider<
14242 T extends object,
14243 Reserved extends string = never,
14244 > = MaybeCallableProvider<T> &
14245 Pick<
14246 {
14247 [K in keyof T]: MethodOrProperty<T[K]>;
14248 },
14249 Exclude<keyof T, Reserved | symbol | keyof StubBase<never>>
14250 >;
14251}
14252export declare namespace Cloudflare {
14253 // Type of `env`.
14254 //
14255 // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
14256 // will merge all declarations.
14257 //
14258 // You can use `wrangler types` to generate the `Env` type automatically.
14259 interface Env {}
14260 // Project-specific parameters used to inform types.
14261 //
14262 // This interface is, again, intended to be declared in project-specific files, and then that
14263 // declaration will be merged with this one.
14264 //
14265 // A project should have a declaration like this:
14266 //
14267 // interface GlobalProps {
14268 // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
14269 // // of `ctx.exports`.
14270 // mainModule: typeof import("my-main-module");
14271 //
14272 // // Declares which of the main module's exports are configured with durable storage, and
14273 // // thus should behave as Durable Object namsepace bindings.
14274 // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
14275 // }
14276 //
14277 // You can use `wrangler types` to generate `GlobalProps` automatically.
14278 interface GlobalProps {}
14279 // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
14280 // present.
14281 type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
14282 ? GlobalProps[K]
14283 : Default;
14284 // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
14285 // `mainModule` property.
14286 type MainModule = GlobalProp<"mainModule", {}>;
14287 // The type of ctx.exports, which contains loopback bindings for all top-level exports.
14288 type Exports = {
14289 [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
14290 // If the export is listed in `durableNamespaces`, then it is also a
14291 // DurableObjectNamespace.
14292 (K extends GlobalProp<"durableNamespaces", never>
14293 ? MainModule[K] extends new (...args: any[]) => infer DoInstance
14294 ? DoInstance extends Rpc.DurableObjectBranded
14295 ? DurableObjectNamespace<DoInstance>
14296 : DurableObjectNamespace<undefined>
14297 : DurableObjectNamespace<undefined>
14298 : {});
14299 };
14300}
14301export declare namespace CloudflareWorkersModule {
14302 export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
14303 export const RpcStub: {
14304 new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
14305 };
14306 export abstract class RpcTarget implements Rpc.RpcTargetBranded {
14307 [Rpc.__RPC_TARGET_BRAND]: never;
14308 }
14309 // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
14310 export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
14311 implements Rpc.WorkerEntrypointBranded
14312 {
14313 [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
14314 protected ctx: ExecutionContext<Props>;
14315 protected env: Env;
14316 constructor(ctx: ExecutionContext, env: Env);
14317 email?(message: ForwardableEmailMessage): void | Promise<void>;
14318 fetch?(request: Request): Response | Promise<Response>;
14319 connect?(socket: Socket): void | Promise<void>;
14320 queue?(batch: MessageBatch): void | Promise<void>;
14321 scheduled?(controller: ScheduledController): void | Promise<void>;
14322 tail?(events: TraceItem[]): void | Promise<void>;
14323 tailStream?(
14324 event: TailStream.TailEvent<TailStream.Onset>,
14325 ):
14326 | TailStream.TailEventHandlerType
14327 | Promise<TailStream.TailEventHandlerType>;
14328 test?(controller: TestController): void | Promise<void>;
14329 trace?(traces: TraceItem[]): void | Promise<void>;
14330 }
14331 export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
14332 implements Rpc.DurableObjectBranded
14333 {
14334 [Rpc.__DURABLE_OBJECT_BRAND]: never;
14335 protected ctx: DurableObjectState<Props>;
14336 protected env: Env;
14337 constructor(ctx: DurableObjectState, env: Env);
14338 alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
14339 fetch?(request: Request): Response | Promise<Response>;
14340 connect?(socket: Socket): void | Promise<void>;
14341 webSocketMessage?(
14342 ws: WebSocket,
14343 message: string | ArrayBuffer,
14344 ): void | Promise<void>;
14345 webSocketClose?(
14346 ws: WebSocket,
14347 code: number,
14348 reason: string,
14349 wasClean: boolean,
14350 ): void | Promise<void>;
14351 webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
14352 }
14353 export type WorkflowDurationLabel =
14354 | "second"
14355 | "minute"
14356 | "hour"
14357 | "day"
14358 | "week"
14359 | "month"
14360 | "year";
14361 export type WorkflowSleepDuration =
14362 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
14363 | number;
14364 export type WorkflowDelayDuration = WorkflowSleepDuration;
14365 export type WorkflowTimeoutDuration = WorkflowSleepDuration;
14366 export type WorkflowRetentionDuration = WorkflowSleepDuration;
14367 export type WorkflowBackoff = "constant" | "linear" | "exponential";
14368 export type WorkflowStepConfig = {
14369 retries?: {
14370 limit: number;
14371 delay: WorkflowDelayDuration | number;
14372 backoff?: WorkflowBackoff;
14373 };
14374 timeout?: WorkflowTimeoutDuration | number;
14375 };
14376 export type WorkflowEvent<T> = {
14377 payload: Readonly<T>;
14378 timestamp: Date;
14379 instanceId: string;
14380 };
14381 export type WorkflowStepEvent<T> = {
14382 payload: Readonly<T>;
14383 timestamp: Date;
14384 type: string;
14385 };
14386 export type WorkflowStepContext = {
14387 step: {
14388 name: string;
14389 count: number;
14390 };
14391 attempt: number;
14392 config: WorkflowStepConfig;
14393 };
14394 export abstract class WorkflowStep {
14395 do<T extends Rpc.Serializable<T>>(
14396 name: string,
14397 callback: (ctx: WorkflowStepContext) => Promise<T>,
14398 ): Promise<T>;
14399 do<T extends Rpc.Serializable<T>>(
14400 name: string,
14401 config: WorkflowStepConfig,
14402 callback: (ctx: WorkflowStepContext) => Promise<T>,
14403 ): Promise<T>;
14404 sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
14405 sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
14406 waitForEvent<T extends Rpc.Serializable<T>>(
14407 name: string,
14408 options: {
14409 type: string;
14410 timeout?: WorkflowTimeoutDuration | number;
14411 },
14412 ): Promise<WorkflowStepEvent<T>>;
14413 }
14414 export type WorkflowInstanceStatus =
14415 | "queued"
14416 | "running"
14417 | "paused"
14418 | "errored"
14419 | "terminated"
14420 | "complete"
14421 | "waiting"
14422 | "waitingForPause"
14423 | "unknown";
14424 export abstract class WorkflowEntrypoint<
14425 Env = unknown,
14426 T extends Rpc.Serializable<T> | unknown = unknown,
14427 >
14428 implements Rpc.WorkflowEntrypointBranded
14429 {
14430 [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
14431 protected ctx: ExecutionContext;
14432 protected env: Env;
14433 constructor(ctx: ExecutionContext, env: Env);
14434 run(
14435 event: Readonly<WorkflowEvent<T>>,
14436 step: WorkflowStep,
14437 ): Promise<unknown>;
14438 }
14439 export function waitUntil(promise: Promise<unknown>): void;
14440 export function withEnv(newEnv: unknown, fn: () => unknown): unknown;
14441 export function withExports(newExports: unknown, fn: () => unknown): unknown;
14442 export function withEnvAndExports(
14443 newEnv: unknown,
14444 newExports: unknown,
14445 fn: () => unknown,
14446 ): unknown;
14447 export const env: Cloudflare.Env;
14448 export const exports: Cloudflare.Exports;
14449 export const cache: CacheContext;
14450 export const tracing: Tracing;
14451}
14452export interface SecretsStoreSecret {
14453 /**
14454 * Get a secret from the Secrets Store, returning a string of the secret value
14455 * if it exists, or throws an error if it does not exist
14456 */
14457 get(): Promise<string>;
14458}
14459/**
14460 * Binding entrypoint for Cloudflare Stream.
14461 *
14462 * Usage:
14463 * - Binding-level operations:
14464 * `await env.STREAM.videos.upload`
14465 * `await env.STREAM.videos.createDirectUpload`
14466 * `await env.STREAM.videos.*`
14467 * `await env.STREAM.watermarks.*`
14468 * - Per-video operations:
14469 * `await env.STREAM.video(id).downloads.*`
14470 * `await env.STREAM.video(id).captions.*`
14471 *
14472 * Example usage:
14473 * ```ts
14474 * await env.STREAM.video(id).downloads.generate();
14475 *
14476 * const video = env.STREAM.video(id)
14477 * const captions = video.captions.list();
14478 * const videoDetails = video.details()
14479 * ```
14480 */
14481export interface StreamBinding {
14482 /**
14483 * Returns a handle scoped to a single video for per-video operations.
14484 * @param id The unique identifier for the video.
14485 * @returns A handle for per-video operations.
14486 */
14487 video(id: string): StreamVideoHandle;
14488 /**
14489 * Uploads a new video from a provided URL.
14490 * @param url The URL to upload from.
14491 * @param params Optional upload parameters.
14492 * @returns The uploaded video details.
14493 * @throws {BadRequestError} if the upload parameter is invalid or the URL is invalid
14494 * @throws {QuotaReachedError} if the account storage capacity is exceeded
14495 * @throws {MaxFileSizeError} if the file size is too large
14496 * @throws {RateLimitedError} if the server received too many requests
14497 * @throws {AlreadyUploadedError} if a video was already uploaded to this URL
14498 * @throws {InternalError} if an unexpected error occurs
14499 */
14500 upload(url: string, params?: StreamUrlUploadParams): Promise<StreamVideo>;
14501 /**
14502 * Creates a direct upload that allows video uploads without an API key.
14503 * @param params Parameters for the direct upload
14504 * @returns The direct upload details.
14505 * @throws {BadRequestError} if the parameters are invalid
14506 * @throws {RateLimitedError} if the server received too many requests
14507 * @throws {InternalError} if an unexpected error occurs
14508 */
14509 createDirectUpload(
14510 params: StreamDirectUploadCreateParams,
14511 ): Promise<StreamDirectUpload>;
14512 videos: StreamVideos;
14513 watermarks: StreamWatermarks;
14514}
14515/**
14516 * Handle for operations scoped to a single Stream video.
14517 */
14518export interface StreamVideoHandle {
14519 /**
14520 * The unique identifier for the video.
14521 */
14522 id: string;
14523 /**
14524 * Get a full videos details
14525 * @returns The full video details.
14526 * @throws {NotFoundError} if the video is not found
14527 * @throws {InternalError} if an unexpected error occurs
14528 */
14529 details(): Promise<StreamVideo>;
14530 /**
14531 * Update details for a single video.
14532 * @param params The fields to update for the video.
14533 * @returns The updated video details.
14534 * @throws {NotFoundError} if the video is not found
14535 * @throws {BadRequestError} if the parameters are invalid
14536 * @throws {InternalError} if an unexpected error occurs
14537 */
14538 update(params: StreamUpdateVideoParams): Promise<StreamVideo>;
14539 /**
14540 * Deletes a video and its copies from Cloudflare Stream.
14541 * @returns A promise that resolves when deletion completes.
14542 * @throws {NotFoundError} if the video is not found
14543 * @throws {InternalError} if an unexpected error occurs
14544 */
14545 delete(): Promise<void>;
14546 /**
14547 * Creates a signed URL token for a video.
14548 * @returns The signed token that was created.
14549 * @throws {InternalError} if the signing key cannot be retrieved or the token cannot be signed
14550 */
14551 generateToken(): Promise<string>;
14552 downloads: StreamScopedDownloads;
14553 captions: StreamScopedCaptions;
14554}
14555export interface StreamVideo {
14556 /**
14557 * The unique identifier for the video.
14558 */
14559 id: string;
14560 /**
14561 * A user-defined identifier for the media creator.
14562 */
14563 creator: string | null;
14564 /**
14565 * The thumbnail URL for the video.
14566 */
14567 thumbnail: string;
14568 /**
14569 * The thumbnail timestamp percentage.
14570 */
14571 thumbnailTimestampPct: number;
14572 /**
14573 * Indicates whether the video is ready to stream.
14574 */
14575 readyToStream: boolean;
14576 /**
14577 * The date and time the video became ready to stream.
14578 */
14579 readyToStreamAt: string | null;
14580 /**
14581 * Processing status information.
14582 */
14583 status: StreamVideoStatus;
14584 /**
14585 * A user modifiable key-value store.
14586 */
14587 meta: Record<string, string>;
14588 /**
14589 * The date and time the video was created.
14590 */
14591 created: string;
14592 /**
14593 * The date and time the video was last modified.
14594 */
14595 modified: string;
14596 /**
14597 * The date and time at which the video will be deleted.
14598 */
14599 scheduledDeletion: string | null;
14600 /**
14601 * The size of the video in bytes.
14602 */
14603 size: number;
14604 /**
14605 * The preview URL for the video.
14606 */
14607 preview?: string;
14608 /**
14609 * Origins allowed to display the video.
14610 */
14611 allowedOrigins: Array<string>;
14612 /**
14613 * Indicates whether signed URLs are required.
14614 */
14615 requireSignedURLs: boolean | null;
14616 /**
14617 * The date and time the video was uploaded.
14618 */
14619 uploaded: string | null;
14620 /**
14621 * The date and time when the upload URL expires.
14622 */
14623 uploadExpiry: string | null;
14624 /**
14625 * The maximum size in bytes for direct uploads.
14626 */
14627 maxSizeBytes: number | null;
14628 /**
14629 * The maximum duration in seconds for direct uploads.
14630 */
14631 maxDurationSeconds: number | null;
14632 /**
14633 * The video duration in seconds. -1 indicates unknown.
14634 */
14635 duration: number;
14636 /**
14637 * Input metadata for the original upload.
14638 */
14639 input: StreamVideoInput;
14640 /**
14641 * Playback URLs for the video.
14642 */
14643 hlsPlaybackUrl: string;
14644 dashPlaybackUrl: string;
14645 /**
14646 * The watermark applied to the video, if any.
14647 */
14648 watermark: StreamWatermark | null;
14649 /**
14650 * The live input id associated with the video, if any.
14651 */
14652 liveInputId?: string | null;
14653 /**
14654 * The source video id if this is a clip.
14655 */
14656 clippedFromId: string | null;
14657 /**
14658 * Public details associated with the video.
14659 */
14660 publicDetails: StreamPublicDetails | null;
14661}
14662export type StreamVideoStatus = {
14663 /**
14664 * The current processing state.
14665 */
14666 state: string;
14667 /**
14668 * The current processing step.
14669 */
14670 step?: string;
14671 /**
14672 * The percent complete as a string.
14673 */
14674 pctComplete?: string;
14675 /**
14676 * An error reason code, if applicable.
14677 */
14678 errorReasonCode: string;
14679 /**
14680 * An error reason text, if applicable.
14681 */
14682 errorReasonText: string;
14683};
14684export type StreamVideoInput = {
14685 /**
14686 * The input width in pixels.
14687 */
14688 width: number;
14689 /**
14690 * The input height in pixels.
14691 */
14692 height: number;
14693};
14694export type StreamPublicDetails = {
14695 /**
14696 * The public title for the video.
14697 */
14698 title: string | null;
14699 /**
14700 * The public share link.
14701 */
14702 share_link: string | null;
14703 /**
14704 * The public channel link.
14705 */
14706 channel_link: string | null;
14707 /**
14708 * The public logo URL.
14709 */
14710 logo: string | null;
14711};
14712export type StreamDirectUpload = {
14713 /**
14714 * The URL an unauthenticated upload can use for a single multipart request.
14715 */
14716 uploadURL: string;
14717 /**
14718 * A Cloudflare-generated unique identifier for a media item.
14719 */
14720 id: string;
14721 /**
14722 * The watermark profile applied to the upload.
14723 */
14724 watermark: StreamWatermark | null;
14725 /**
14726 * The scheduled deletion time, if any.
14727 */
14728 scheduledDeletion: string | null;
14729};
14730export type StreamDirectUploadCreateParams = {
14731 /**
14732 * The maximum duration in seconds for a video upload.
14733 */
14734 maxDurationSeconds: number;
14735 /**
14736 * The date and time after upload when videos will not be accepted.
14737 */
14738 expiry?: string;
14739 /**
14740 * A user-defined identifier for the media creator.
14741 */
14742 creator?: string;
14743 /**
14744 * A user modifiable key-value store used to reference other systems of record for
14745 * managing videos.
14746 */
14747 meta?: Record<string, string>;
14748 /**
14749 * Lists the origins allowed to display the video.
14750 */
14751 allowedOrigins?: Array<string>;
14752 /**
14753 * Indicates whether the video can be accessed using the id. When set to `true`,
14754 * a signed token must be generated with a signing key to view the video.
14755 */
14756 requireSignedURLs?: boolean;
14757 /**
14758 * The thumbnail timestamp percentage.
14759 */
14760 thumbnailTimestampPct?: number;
14761 /**
14762 * The date and time at which the video will be deleted. Include `null` to remove
14763 * a scheduled deletion.
14764 */
14765 scheduledDeletion?: string | null;
14766 /**
14767 * The watermark profile to apply.
14768 */
14769 watermark?: StreamDirectUploadWatermark;
14770};
14771export type StreamDirectUploadWatermark = {
14772 /**
14773 * The unique identifier for the watermark profile.
14774 */
14775 id: string;
14776};
14777export type StreamUrlUploadParams = {
14778 /**
14779 * Lists the origins allowed to display the video. Enter allowed origin
14780 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14781 * video to be viewed on any origin.
14782 */
14783 allowedOrigins?: Array<string>;
14784 /**
14785 * A user-defined identifier for the media creator.
14786 */
14787 creator?: string;
14788 /**
14789 * A user modifiable key-value store used to reference other systems of
14790 * record for managing videos.
14791 */
14792 meta?: Record<string, string>;
14793 /**
14794 * Indicates whether the video can be a accessed using the id. When
14795 * set to `true`, a signed token must be generated with a signing key to view the
14796 * video.
14797 */
14798 requireSignedURLs?: boolean;
14799 /**
14800 * Indicates the date and time at which the video will be deleted. Omit
14801 * the field to indicate no change, or include with a `null` value to remove an
14802 * existing scheduled deletion. If specified, must be at least 30 days from upload
14803 * time.
14804 */
14805 scheduledDeletion?: string | null;
14806 /**
14807 * The timestamp for a thumbnail image calculated as a percentage value
14808 * of the video's duration. To convert from a second-wise timestamp to a
14809 * percentage, divide the desired timestamp by the total duration of the video. If
14810 * this value is not set, the default thumbnail image is taken from 0s of the
14811 * video.
14812 */
14813 thumbnailTimestampPct?: number;
14814 /**
14815 * The identifier for the watermark profile
14816 */
14817 watermarkId?: string;
14818};
14819export interface StreamScopedCaptions {
14820 /**
14821 * Uploads the caption or subtitle file to the endpoint for a specific BCP47 language.
14822 * One caption or subtitle file per language is allowed.
14823 * @param language The BCP 47 language tag for the caption or subtitle.
14824 * @param input The caption or subtitle stream to upload.
14825 * @returns The created caption entry.
14826 * @throws {NotFoundError} if the video is not found
14827 * @throws {BadRequestError} if the language or file is invalid
14828 * @throws {InternalError} if an unexpected error occurs
14829 */
14830 upload(language: string, input: ReadableStream): Promise<StreamCaption>;
14831 /**
14832 * Generate captions or subtitles for the provided language via AI.
14833 * @param language The BCP 47 language tag to generate.
14834 * @returns The generated caption entry.
14835 * @throws {NotFoundError} if the video is not found
14836 * @throws {BadRequestError} if the language is invalid
14837 * @throws {StreamError} if a generated caption already exists
14838 * @throws {StreamError} if the video duration is too long
14839 * @throws {StreamError} if the video is missing audio
14840 * @throws {StreamError} if the requested language is not supported
14841 * @throws {InternalError} if an unexpected error occurs
14842 */
14843 generate(language: string): Promise<StreamCaption>;
14844 /**
14845 * Lists the captions or subtitles.
14846 * Use the language parameter to filter by a specific language.
14847 * @param language The optional BCP 47 language tag to filter by.
14848 * @returns The list of captions or subtitles.
14849 * @throws {NotFoundError} if the video or caption is not found
14850 * @throws {InternalError} if an unexpected error occurs
14851 */
14852 list(language?: string): Promise<StreamCaption[]>;
14853 /**
14854 * Removes the captions or subtitles from a video.
14855 * @param language The BCP 47 language tag to remove.
14856 * @returns A promise that resolves when deletion completes.
14857 * @throws {NotFoundError} if the video or caption is not found
14858 * @throws {InternalError} if an unexpected error occurs
14859 */
14860 delete(language: string): Promise<void>;
14861}
14862export interface StreamScopedDownloads {
14863 /**
14864 * Generates a download for a video when a video is ready to view. Available
14865 * types are `default` and `audio`. Defaults to `default` when omitted.
14866 * @param downloadType The download type to create.
14867 * @returns The current downloads for the video.
14868 * @throws {NotFoundError} if the video is not found
14869 * @throws {BadRequestError} if the download type is invalid
14870 * @throws {StreamError} if the video duration is too long to generate a download
14871 * @throws {StreamError} if the video is not ready to stream
14872 * @throws {InternalError} if an unexpected error occurs
14873 */
14874 generate(
14875 downloadType?: StreamDownloadType,
14876 ): Promise<StreamDownloadGetResponse>;
14877 /**
14878 * Lists the downloads created for a video.
14879 * @returns The current downloads for the video.
14880 * @throws {NotFoundError} if the video or downloads are not found
14881 * @throws {InternalError} if an unexpected error occurs
14882 */
14883 get(): Promise<StreamDownloadGetResponse>;
14884 /**
14885 * Delete the downloads for a video. Available types are `default` and `audio`.
14886 * Defaults to `default` when omitted.
14887 * @param downloadType The download type to delete.
14888 * @returns A promise that resolves when deletion completes.
14889 * @throws {NotFoundError} if the video or downloads are not found
14890 * @throws {InternalError} if an unexpected error occurs
14891 */
14892 delete(downloadType?: StreamDownloadType): Promise<void>;
14893}
14894export interface StreamVideos {
14895 /**
14896 * Lists all videos in a users account.
14897 * @returns The list of videos.
14898 * @throws {BadRequestError} if the parameters are invalid
14899 * @throws {InternalError} if an unexpected error occurs
14900 */
14901 list(params?: StreamVideosListParams): Promise<StreamVideo[]>;
14902}
14903export interface StreamWatermarks {
14904 /**
14905 * Generate a new watermark profile
14906 * @param input The image stream to upload
14907 * @param params The watermark creation parameters.
14908 * @returns The created watermark profile.
14909 * @throws {BadRequestError} if the parameters are invalid
14910 * @throws {InvalidURLError} if the URL is invalid
14911 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14912 * @throws {InternalError} if an unexpected error occurs
14913 */
14914 generate(
14915 input: ReadableStream,
14916 params: StreamWatermarkCreateParams,
14917 ): Promise<StreamWatermark>;
14918 /**
14919 * Generate a new watermark profile
14920 * @param url The image url to upload
14921 * @param params The watermark creation parameters.
14922 * @returns The created watermark profile.
14923 * @throws {BadRequestError} if the parameters are invalid
14924 * @throws {InvalidURLError} if the URL is invalid
14925 * @throws {TooManyWatermarksError} if the number of allowed watermarks is reached
14926 * @throws {InternalError} if an unexpected error occurs
14927 */
14928 generate(
14929 url: string,
14930 params: StreamWatermarkCreateParams,
14931 ): Promise<StreamWatermark>;
14932 /**
14933 * Lists all watermark profiles for an account.
14934 * @returns The list of watermark profiles.
14935 * @throws {InternalError} if an unexpected error occurs
14936 */
14937 list(): Promise<StreamWatermark[]>;
14938 /**
14939 * Retrieves details for a single watermark profile.
14940 * @param watermarkId The watermark profile identifier.
14941 * @returns The watermark profile details.
14942 * @throws {NotFoundError} if the watermark is not found
14943 * @throws {InternalError} if an unexpected error occurs
14944 */
14945 get(watermarkId: string): Promise<StreamWatermark>;
14946 /**
14947 * Deletes a watermark profile.
14948 * @param watermarkId The watermark profile identifier.
14949 * @returns A promise that resolves when deletion completes.
14950 * @throws {NotFoundError} if the watermark is not found
14951 * @throws {InternalError} if an unexpected error occurs
14952 */
14953 delete(watermarkId: string): Promise<void>;
14954}
14955export type StreamUpdateVideoParams = {
14956 /**
14957 * Lists the origins allowed to display the video. Enter allowed origin
14958 * domains in an array and use `*` for wildcard subdomains. Empty arrays allow the
14959 * video to be viewed on any origin.
14960 */
14961 allowedOrigins?: Array<string>;
14962 /**
14963 * A user-defined identifier for the media creator.
14964 */
14965 creator?: string;
14966 /**
14967 * The maximum duration in seconds for a video upload. Can be set for a
14968 * video that is not yet uploaded to limit its duration. Uploads that exceed the
14969 * specified duration will fail during processing. A value of `-1` means the value
14970 * is unknown.
14971 */
14972 maxDurationSeconds?: number;
14973 /**
14974 * A user modifiable key-value store used to reference other systems of
14975 * record for managing videos.
14976 */
14977 meta?: Record<string, string>;
14978 /**
14979 * Indicates whether the video can be a accessed using the id. When
14980 * set to `true`, a signed token must be generated with a signing key to view the
14981 * video.
14982 */
14983 requireSignedURLs?: boolean;
14984 /**
14985 * Indicates the date and time at which the video will be deleted. Omit
14986 * the field to indicate no change, or include with a `null` value to remove an
14987 * existing scheduled deletion. If specified, must be at least 30 days from upload
14988 * time.
14989 */
14990 scheduledDeletion?: string | null;
14991 /**
14992 * The timestamp for a thumbnail image calculated as a percentage value
14993 * of the video's duration. To convert from a second-wise timestamp to a
14994 * percentage, divide the desired timestamp by the total duration of the video. If
14995 * this value is not set, the default thumbnail image is taken from 0s of the
14996 * video.
14997 */
14998 thumbnailTimestampPct?: number;
14999};
15000export type StreamCaption = {
15001 /**
15002 * Whether the caption was generated via AI.
15003 */
15004 generated?: boolean;
15005 /**
15006 * The language label displayed in the native language to users.
15007 */
15008 label: string;
15009 /**
15010 * The language tag in BCP 47 format.
15011 */
15012 language: string;
15013 /**
15014 * The status of a generated caption.
15015 */
15016 status?: "ready" | "inprogress" | "error";
15017};
15018export type StreamDownloadStatus = "ready" | "inprogress" | "error";
15019export type StreamDownloadType = "default" | "audio";
15020export type StreamDownload = {
15021 /**
15022 * Indicates the progress as a percentage between 0 and 100.
15023 */
15024 percentComplete: number;
15025 /**
15026 * The status of a generated download.
15027 */
15028 status: StreamDownloadStatus;
15029 /**
15030 * The URL to access the generated download.
15031 */
15032 url?: string;
15033};
15034/**
15035 * An object with download type keys. Each key is optional and only present if that
15036 * download type has been created.
15037 */
15038export type StreamDownloadGetResponse = {
15039 /**
15040 * The audio-only download. Only present if this download type has been created.
15041 */
15042 audio?: StreamDownload;
15043 /**
15044 * The default video download. Only present if this download type has been created.
15045 */
15046 default?: StreamDownload;
15047};
15048export type StreamWatermarkPosition =
15049 | "upperRight"
15050 | "upperLeft"
15051 | "lowerLeft"
15052 | "lowerRight"
15053 | "center";
15054export type StreamWatermark = {
15055 /**
15056 * The unique identifier for a watermark profile.
15057 */
15058 id: string;
15059 /**
15060 * The size of the image in bytes.
15061 */
15062 size: number;
15063 /**
15064 * The height of the image in pixels.
15065 */
15066 height: number;
15067 /**
15068 * The width of the image in pixels.
15069 */
15070 width: number;
15071 /**
15072 * The date and a time a watermark profile was created.
15073 */
15074 created: string;
15075 /**
15076 * The source URL for a downloaded image. If the watermark profile was created via
15077 * direct upload, this field is null.
15078 */
15079 downloadedFrom: string | null;
15080 /**
15081 * A short description of the watermark profile.
15082 */
15083 name: string;
15084 /**
15085 * The translucency of the image. A value of `0.0` makes the image completely
15086 * transparent, and `1.0` makes the image completely opaque. Note that if the image
15087 * is already semi-transparent, setting this to `1.0` will not make the image
15088 * completely opaque.
15089 */
15090 opacity: number;
15091 /**
15092 * The whitespace between the adjacent edges (determined by position) of the video
15093 * and the image. `0.0` indicates no padding, and `1.0` indicates a fully padded
15094 * video width or length, as determined by the algorithm.
15095 */
15096 padding: number;
15097 /**
15098 * The size of the image relative to the overall size of the video. This parameter
15099 * will adapt to horizontal and vertical videos automatically. `0.0` indicates no
15100 * scaling (use the size of the image as-is), and `1.0 `fills the entire video.
15101 */
15102 scale: number;
15103 /**
15104 * The location of the image. Valid positions are: `upperRight`, `upperLeft`,
15105 * `lowerLeft`, `lowerRight`, and `center`. Note that `center` ignores the
15106 * `padding` parameter.
15107 */
15108 position: StreamWatermarkPosition;
15109};
15110export type StreamWatermarkCreateParams = {
15111 /**
15112 * A short description of the watermark profile.
15113 */
15114 name?: string;
15115 /**
15116 * The translucency of the image. A value of `0.0` makes the image completely
15117 * transparent, and `1.0` makes the image completely opaque. Note that if the
15118 * image is already semi-transparent, setting this to `1.0` will not make the
15119 * image completely opaque.
15120 */
15121 opacity?: number;
15122 /**
15123 * The whitespace between the adjacent edges (determined by position) of the
15124 * video and the image. `0.0` indicates no padding, and `1.0` indicates a fully
15125 * padded video width or length, as determined by the algorithm.
15126 */
15127 padding?: number;
15128 /**
15129 * The size of the image relative to the overall size of the video. This
15130 * parameter will adapt to horizontal and vertical videos automatically. `0.0`
15131 * indicates no scaling (use the size of the image as-is), and `1.0 `fills the
15132 * entire video.
15133 */
15134 scale?: number;
15135 /**
15136 * The location of the image.
15137 */
15138 position?: StreamWatermarkPosition;
15139};
15140export type StreamVideosListParams = {
15141 /**
15142 * The maximum number of videos to return.
15143 */
15144 limit?: number;
15145 /**
15146 * Return videos created before this timestamp.
15147 * (RFC3339/RFC3339Nano)
15148 */
15149 before?: string;
15150 /**
15151 * Comparison operator for the `before` field.
15152 * @default 'lt'
15153 */
15154 beforeComp?: StreamPaginationComparison;
15155 /**
15156 * Return videos created after this timestamp.
15157 * (RFC3339/RFC3339Nano)
15158 */
15159 after?: string;
15160 /**
15161 * Comparison operator for the `after` field.
15162 * @default 'gte'
15163 */
15164 afterComp?: StreamPaginationComparison;
15165};
15166export type StreamPaginationComparison = "eq" | "gt" | "gte" | "lt" | "lte";
15167/**
15168 * Error object for Stream binding operations.
15169 */
15170export interface StreamError extends Error {
15171 readonly code: number;
15172 readonly statusCode: number;
15173 readonly message: string;
15174 readonly stack?: string;
15175}
15176export interface InternalError extends StreamError {
15177 name: "InternalError";
15178}
15179export interface BadRequestError extends StreamError {
15180 name: "BadRequestError";
15181}
15182export interface NotFoundError extends StreamError {
15183 name: "NotFoundError";
15184}
15185export interface ForbiddenError extends StreamError {
15186 name: "ForbiddenError";
15187}
15188export interface RateLimitedError extends StreamError {
15189 name: "RateLimitedError";
15190}
15191export interface QuotaReachedError extends StreamError {
15192 name: "QuotaReachedError";
15193}
15194export interface MaxFileSizeError extends StreamError {
15195 name: "MaxFileSizeError";
15196}
15197export interface InvalidURLError extends StreamError {
15198 name: "InvalidURLError";
15199}
15200export interface AlreadyUploadedError extends StreamError {
15201 name: "AlreadyUploadedError";
15202}
15203export interface TooManyWatermarksError extends StreamError {
15204 name: "TooManyWatermarksError";
15205}
15206export type MarkdownDocument = {
15207 name: string;
15208 blob: Blob;
15209};
15210export type ConversionResponse =
15211 | {
15212 id: string;
15213 name: string;
15214 mimeType: string;
15215 format: "markdown";
15216 tokens: number;
15217 data: string;
15218 }
15219 | {
15220 id: string;
15221 name: string;
15222 mimeType: string;
15223 format: "error";
15224 error: string;
15225 };
15226export type ImageConversionOptions = {
15227 descriptionLanguage?: "en" | "es" | "fr" | "it" | "pt" | "de";
15228};
15229export type EmbeddedImageConversionOptions = ImageConversionOptions & {
15230 convert?: boolean;
15231 maxConvertedImages?: number;
15232};
15233export type ConversionOptions = {
15234 html?: {
15235 images?: EmbeddedImageConversionOptions & {
15236 convertOGImage?: boolean;
15237 };
15238 hostname?: string;
15239 cssSelector?: string;
15240 };
15241 docx?: {
15242 images?: EmbeddedImageConversionOptions;
15243 };
15244 image?: ImageConversionOptions;
15245 pdf?: {
15246 images?: EmbeddedImageConversionOptions;
15247 metadata?: boolean;
15248 };
15249};
15250export type ConversionRequestOptions = {
15251 gateway?: GatewayOptions;
15252 extraHeaders?: object;
15253 conversionOptions?: ConversionOptions;
15254};
15255export type SupportedFileFormat = {
15256 mimeType: string;
15257 extension: string;
15258};
15259export declare abstract class ToMarkdownService {
15260 transform(
15261 files: MarkdownDocument[],
15262 options?: ConversionRequestOptions,
15263 ): Promise<ConversionResponse[]>;
15264 transform(
15265 files: MarkdownDocument,
15266 options?: ConversionRequestOptions,
15267 ): Promise<ConversionResponse>;
15268 supported(): Promise<SupportedFileFormat[]>;
15269}
15270export declare namespace TailStream {
15271 interface Header {
15272 readonly name: string;
15273 readonly value: string;
15274 }
15275 interface FetchEventInfo {
15276 readonly type: "fetch";
15277 readonly method: string;
15278 readonly url: string;
15279 readonly cfJson?: object;
15280 readonly headers: Header[];
15281 }
15282 interface JsRpcEventInfo {
15283 readonly type: "jsrpc";
15284 }
15285 interface ScheduledEventInfo {
15286 readonly type: "scheduled";
15287 readonly scheduledTime: Date;
15288 readonly cron: string;
15289 }
15290 interface AlarmEventInfo {
15291 readonly type: "alarm";
15292 readonly scheduledTime: Date;
15293 }
15294 interface QueueEventInfo {
15295 readonly type: "queue";
15296 readonly queueName: string;
15297 readonly batchSize: number;
15298 }
15299 interface EmailEventInfo {
15300 readonly type: "email";
15301 readonly mailFrom: string;
15302 readonly rcptTo: string;
15303 readonly rawSize: number;
15304 }
15305 interface TraceEventInfo {
15306 readonly type: "trace";
15307 readonly traces: (string | null)[];
15308 }
15309 interface HibernatableWebSocketEventInfoMessage {
15310 readonly type: "message";
15311 }
15312 interface HibernatableWebSocketEventInfoError {
15313 readonly type: "error";
15314 }
15315 interface HibernatableWebSocketEventInfoClose {
15316 readonly type: "close";
15317 readonly code: number;
15318 readonly wasClean: boolean;
15319 }
15320 interface HibernatableWebSocketEventInfo {
15321 readonly type: "hibernatableWebSocket";
15322 readonly info:
15323 | HibernatableWebSocketEventInfoClose
15324 | HibernatableWebSocketEventInfoError
15325 | HibernatableWebSocketEventInfoMessage;
15326 }
15327 interface CustomEventInfo {
15328 readonly type: "custom";
15329 }
15330 interface FetchResponseInfo {
15331 readonly type: "fetch";
15332 readonly statusCode: number;
15333 }
15334 interface ConnectEventInfo {
15335 readonly type: "connect";
15336 }
15337 type EventOutcome =
15338 | "ok"
15339 | "canceled"
15340 | "exception"
15341 | "unknown"
15342 | "killSwitch"
15343 | "daemonDown"
15344 | "exceededCpu"
15345 | "exceededMemory"
15346 | "loadShed"
15347 | "responseStreamDisconnected"
15348 | "scriptNotFound"
15349 | "internalError";
15350 interface ScriptVersion {
15351 readonly id: string;
15352 readonly tag?: string;
15353 readonly message?: string;
15354 }
15355 interface TracePreviewInfo {
15356 readonly id: string;
15357 readonly slug: string;
15358 readonly name: string;
15359 }
15360 interface Onset {
15361 readonly type: "onset";
15362 readonly attributes: Attribute[];
15363 // id for the span being opened by this Onset event.
15364 readonly spanId: string;
15365 readonly dispatchNamespace?: string;
15366 readonly entrypoint?: string;
15367 readonly executionModel: string;
15368 readonly scriptName?: string;
15369 readonly scriptTags?: string[];
15370 readonly scriptVersion?: ScriptVersion;
15371 readonly preview?: TracePreviewInfo;
15372 readonly info:
15373 | FetchEventInfo
15374 | ConnectEventInfo
15375 | JsRpcEventInfo
15376 | ScheduledEventInfo
15377 | AlarmEventInfo
15378 | QueueEventInfo
15379 | EmailEventInfo
15380 | TraceEventInfo
15381 | HibernatableWebSocketEventInfo
15382 | CustomEventInfo;
15383 }
15384 interface Outcome {
15385 readonly type: "outcome";
15386 readonly outcome: EventOutcome;
15387 readonly cpuTime: number;
15388 readonly wallTime: number;
15389 }
15390 interface SpanOpen {
15391 readonly type: "spanOpen";
15392 readonly name: string;
15393 // id for the span being opened by this SpanOpen event.
15394 readonly spanId: string;
15395 readonly info?: FetchEventInfo | JsRpcEventInfo | Attributes;
15396 }
15397 interface SpanClose {
15398 readonly type: "spanClose";
15399 readonly outcome: EventOutcome;
15400 }
15401 interface DiagnosticChannelEvent {
15402 readonly type: "diagnosticChannel";
15403 readonly channel: string;
15404 readonly message: any;
15405 }
15406 interface Exception {
15407 readonly type: "exception";
15408 readonly name: string;
15409 readonly message: string;
15410 readonly stack?: string;
15411 }
15412 interface Log {
15413 readonly type: "log";
15414 readonly level: "debug" | "error" | "info" | "log" | "warn";
15415 readonly message: object;
15416 }
15417 interface DroppedEventsDiagnostic {
15418 readonly diagnosticsType: "droppedEvents";
15419 readonly count: number;
15420 }
15421 interface StreamDiagnostic {
15422 readonly type: "streamDiagnostic";
15423 // To add new diagnostic types, define a new interface and add it to this union type.
15424 readonly diagnostic: DroppedEventsDiagnostic;
15425 }
15426 // This marks the worker handler return information.
15427 // This is separate from Outcome because the worker invocation can live for a long time after
15428 // returning. For example - Websockets that return an http upgrade response but then continue
15429 // streaming information or SSE http connections.
15430 interface Return {
15431 readonly type: "return";
15432 readonly info?: FetchResponseInfo;
15433 }
15434 interface Attribute {
15435 readonly name: string;
15436 readonly value:
15437 | string
15438 | string[]
15439 | boolean
15440 | boolean[]
15441 | number
15442 | number[]
15443 | bigint
15444 | bigint[];
15445 }
15446 interface Attributes {
15447 readonly type: "attributes";
15448 readonly info: Attribute[];
15449 }
15450 type EventType =
15451 | Onset
15452 | Outcome
15453 | SpanOpen
15454 | SpanClose
15455 | DiagnosticChannelEvent
15456 | Exception
15457 | Log
15458 | StreamDiagnostic
15459 | Return
15460 | Attributes;
15461 // Context in which this trace event lives.
15462 interface SpanContext {
15463 // Single id for the entire top-level invocation
15464 // This should be a new traceId for the first worker stage invoked in the eyeball request and then
15465 // same-account service-bindings should reuse the same traceId but cross-account service-bindings
15466 // should use a new traceId.
15467 readonly traceId: string;
15468 // spanId in which this event is handled
15469 // for Onset and SpanOpen events this would be the parent span id
15470 // for Outcome and SpanClose these this would be the span id of the opening Onset and SpanOpen events
15471 // For Hibernate and Mark this would be the span under which they were emitted.
15472 // spanId is not set ONLY if:
15473 // 1. This is an Onset event
15474 // 2. We are not inheriting any SpanContext. (e.g. this is a cross-account service binding or a new top-level invocation)
15475 readonly spanId?: string;
15476 // W3C trace flags from an upstream traceparent. Absent when no upstream
15477 // sampling decision was made.
15478 readonly traceFlags?: number;
15479 }
15480 interface TailEvent<Event extends EventType> {
15481 // invocation id of the currently invoked worker stage.
15482 // invocation id will always be unique to every Onset event and will be the same until the Outcome event.
15483 readonly invocationId: string;
15484 // Inherited spanContext for this event.
15485 readonly spanContext: SpanContext;
15486 readonly timestamp: Date;
15487 readonly sequence: number;
15488 readonly event: Event;
15489 }
15490 type TailEventHandler<Event extends EventType = EventType> = (
15491 event: TailEvent<Event>,
15492 ) => void | Promise<void>;
15493 type TailEventHandlerObject = {
15494 outcome?: TailEventHandler<Outcome>;
15495 spanOpen?: TailEventHandler<SpanOpen>;
15496 spanClose?: TailEventHandler<SpanClose>;
15497 diagnosticChannel?: TailEventHandler<DiagnosticChannelEvent>;
15498 exception?: TailEventHandler<Exception>;
15499 log?: TailEventHandler<Log>;
15500 return?: TailEventHandler<Return>;
15501 attributes?: TailEventHandler<Attributes>;
15502 };
15503 type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
15504}
15505// Copyright (c) 2022-2023 Cloudflare, Inc.
15506// Licensed under the Apache 2.0 license found in the LICENSE file or at:
15507// https://opensource.org/licenses/Apache-2.0
15508/**
15509 * Data types supported for holding vector metadata.
15510 */
15511export type VectorizeVectorMetadataValue = string | number | boolean | string[];
15512/**
15513 * Additional information to associate with a vector.
15514 */
15515export type VectorizeVectorMetadata =
15516 | VectorizeVectorMetadataValue
15517 | Record<string, VectorizeVectorMetadataValue>;
15518export type VectorFloatArray = Float32Array | Float64Array;
15519export interface VectorizeError {
15520 code?: number;
15521 error: string;
15522}
15523/**
15524 * Comparison logic/operation to use for metadata filtering.
15525 *
15526 * This list is expected to grow as support for more operations are released.
15527 */
15528export type VectorizeVectorMetadataFilterOp =
15529 | "$eq"
15530 | "$ne"
15531 | "$lt"
15532 | "$lte"
15533 | "$gt"
15534 | "$gte";
15535export type VectorizeVectorMetadataFilterCollectionOp = "$in" | "$nin";
15536/**
15537 * Filter criteria for vector metadata used to limit the retrieved query result set.
15538 */
15539export type VectorizeVectorMetadataFilter = {
15540 [field: string]:
15541 | Exclude<VectorizeVectorMetadataValue, string[]>
15542 | null
15543 | {
15544 [Op in VectorizeVectorMetadataFilterOp]?: Exclude<
15545 VectorizeVectorMetadataValue,
15546 string[]
15547 > | null;
15548 }
15549 | {
15550 [Op in VectorizeVectorMetadataFilterCollectionOp]?: Exclude<
15551 VectorizeVectorMetadataValue,
15552 string[]
15553 >[];
15554 };
15555};
15556/**
15557 * Supported distance metrics for an index.
15558 * Distance metrics determine how other "similar" vectors are determined.
15559 */
15560export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
15561/**
15562 * Metadata return levels for a Vectorize query.
15563 *
15564 * Default to "none".
15565 *
15566 * @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.
15567 * @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).
15568 * @property none No indexed metadata will be returned.
15569 */
15570export type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
15571export interface VectorizeQueryOptions {
15572 topK?: number;
15573 namespace?: string;
15574 returnValues?: boolean;
15575 returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
15576 filter?: VectorizeVectorMetadataFilter;
15577}
15578/**
15579 * Information about the configuration of an index.
15580 */
15581export type VectorizeIndexConfig =
15582 | {
15583 dimensions: number;
15584 metric: VectorizeDistanceMetric;
15585 }
15586 | {
15587 preset: string; // keep this generic, as we'll be adding more presets in the future and this is only in a read capacity
15588 };
15589/**
15590 * Metadata about an existing index.
15591 *
15592 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15593 * See {@link VectorizeIndexInfo} for its post-beta equivalent.
15594 */
15595export interface VectorizeIndexDetails {
15596 /** The unique ID of the index */
15597 readonly id: string;
15598 /** The name of the index. */
15599 name: string;
15600 /** (optional) A human readable description for the index. */
15601 description?: string;
15602 /** The index configuration, including the dimension size and distance metric. */
15603 config: VectorizeIndexConfig;
15604 /** The number of records containing vectors within the index. */
15605 vectorsCount: number;
15606}
15607/**
15608 * Metadata about an existing index.
15609 */
15610export interface VectorizeIndexInfo {
15611 /** The number of records containing vectors within the index. */
15612 vectorCount: number;
15613 /** Number of dimensions the index has been configured for. */
15614 dimensions: number;
15615 /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
15616 processedUpToDatetime: number;
15617 /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
15618 processedUpToMutation: number;
15619}
15620/**
15621 * Represents a single vector value set along with its associated metadata.
15622 */
15623export interface VectorizeVector {
15624 /** 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. */
15625 id: string;
15626 /** The vector values */
15627 values: VectorFloatArray | number[];
15628 /** The namespace this vector belongs to. */
15629 namespace?: string;
15630 /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
15631 metadata?: Record<string, VectorizeVectorMetadata>;
15632}
15633/**
15634 * Represents a matched vector for a query along with its score and (if specified) the matching vector information.
15635 */
15636export type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
15637 Omit<VectorizeVector, "values"> & {
15638 /** The score or rank for similarity, when returned as a result */
15639 score: number;
15640 };
15641/**
15642 * A set of matching {@link VectorizeMatch} for a particular query.
15643 */
15644export interface VectorizeMatches {
15645 matches: VectorizeMatch[];
15646 count: number;
15647}
15648/**
15649 * Results of an operation that performed a mutation on a set of vectors.
15650 * Here, `ids` is a list of vectors that were successfully processed.
15651 *
15652 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15653 * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
15654 */
15655export interface VectorizeVectorMutation {
15656 /* List of ids of vectors that were successfully processed. */
15657 ids: string[];
15658 /* Total count of the number of processed vectors. */
15659 count: number;
15660}
15661/**
15662 * Result type indicating a mutation on the Vectorize Index.
15663 * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
15664 */
15665export interface VectorizeAsyncMutation {
15666 /** The unique identifier for the async mutation operation containing the changeset. */
15667 mutationId: string;
15668}
15669/**
15670 * A Vectorize Vector Search Index for querying vectors/embeddings.
15671 *
15672 * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
15673 * See {@link Vectorize} for its new implementation.
15674 */
15675export declare abstract class VectorizeIndex {
15676 /**
15677 * Get information about the currently bound index.
15678 * @returns A promise that resolves with information about the current index.
15679 */
15680 public describe(): Promise<VectorizeIndexDetails>;
15681 /**
15682 * Use the provided vector to perform a similarity search across the index.
15683 * @param vector Input vector that will be used to drive the similarity search.
15684 * @param options Configuration options to massage the returned data.
15685 * @returns A promise that resolves with matched and scored vectors.
15686 */
15687 public query(
15688 vector: VectorFloatArray | number[],
15689 options?: VectorizeQueryOptions,
15690 ): Promise<VectorizeMatches>;
15691 /**
15692 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15693 * @param vectors List of vectors that will be inserted.
15694 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15695 */
15696 public insert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15697 /**
15698 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15699 * @param vectors List of vectors that will be upserted.
15700 * @returns A promise that resolves with the ids & count of records that were successfully processed.
15701 */
15702 public upsert(vectors: VectorizeVector[]): Promise<VectorizeVectorMutation>;
15703 /**
15704 * Delete a list of vectors with a matching id.
15705 * @param ids List of vector ids that should be deleted.
15706 * @returns A promise that resolves with the ids & count of records that were successfully processed (and thus deleted).
15707 */
15708 public deleteByIds(ids: string[]): Promise<VectorizeVectorMutation>;
15709 /**
15710 * Get a list of vectors with a matching id.
15711 * @param ids List of vector ids that should be returned.
15712 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15713 */
15714 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15715}
15716/**
15717 * A Vectorize Vector Search Index for querying vectors/embeddings.
15718 *
15719 * Mutations in this version are async, returning a mutation id.
15720 */
15721export declare abstract class Vectorize {
15722 /**
15723 * Get information about the currently bound index.
15724 * @returns A promise that resolves with information about the current index.
15725 */
15726 public describe(): Promise<VectorizeIndexInfo>;
15727 /**
15728 * Use the provided vector to perform a similarity search across the index.
15729 * @param vector Input vector that will be used to drive the similarity search.
15730 * @param options Configuration options to massage the returned data.
15731 * @returns A promise that resolves with matched and scored vectors.
15732 */
15733 public query(
15734 vector: VectorFloatArray | number[],
15735 options?: VectorizeQueryOptions,
15736 ): Promise<VectorizeMatches>;
15737 /**
15738 * Use the provided vector-id to perform a similarity search across the index.
15739 * @param vectorId Id for a vector in the index against which the index should be queried.
15740 * @param options Configuration options to massage the returned data.
15741 * @returns A promise that resolves with matched and scored vectors.
15742 */
15743 public queryById(
15744 vectorId: string,
15745 options?: VectorizeQueryOptions,
15746 ): Promise<VectorizeMatches>;
15747 /**
15748 * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
15749 * @param vectors List of vectors that will be inserted.
15750 * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
15751 */
15752 public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15753 /**
15754 * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
15755 * @param vectors List of vectors that will be upserted.
15756 * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
15757 */
15758 public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
15759 /**
15760 * Delete a list of vectors with a matching id.
15761 * @param ids List of vector ids that should be deleted.
15762 * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
15763 */
15764 public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
15765 /**
15766 * Get a list of vectors with a matching id.
15767 * @param ids List of vector ids that should be returned.
15768 * @returns A promise that resolves with the raw unscored vectors matching the id set.
15769 */
15770 public getByIds(ids: string[]): Promise<VectorizeVector[]>;
15771}
15772/**
15773 * The interface for "version_metadata" binding
15774 * providing metadata about the Worker Version using this binding.
15775 */
15776export type WorkerVersionMetadata = {
15777 /** The ID of the Worker Version using this binding */
15778 id: string;
15779 /** The tag of the Worker Version using this binding */
15780 tag: string;
15781 /** The timestamp of when the Worker Version was uploaded */
15782 timestamp: string;
15783};
15784export interface DynamicDispatchLimits {
15785 /**
15786 * Limit CPU time in milliseconds.
15787 */
15788 cpuMs?: number;
15789 /**
15790 * Limit number of subrequests.
15791 */
15792 subRequests?: number;
15793}
15794export interface DynamicDispatchOptions {
15795 /**
15796 * Limit resources of invoked Worker script.
15797 */
15798 limits?: DynamicDispatchLimits;
15799 /**
15800 * Arguments for outbound Worker script, if configured.
15801 */
15802 outbound?: {
15803 [key: string]: any;
15804 };
15805}
15806export interface DispatchNamespace {
15807 /**
15808 * @param name Name of the Worker script.
15809 * @param args Arguments to Worker script.
15810 * @param options Options for Dynamic Dispatch invocation.
15811 * @returns A Fetcher object that allows you to send requests to the Worker script.
15812 * @throws If the Worker script does not exist in this dispatch namespace, an error will be thrown.
15813 */
15814 get(
15815 name: string,
15816 args?: {
15817 [key: string]: any;
15818 },
15819 options?: DynamicDispatchOptions,
15820 ): Fetcher;
15821}
15822export declare abstract class Workflow<PARAMS = unknown> {
15823 /**
15824 * Get a handle to an existing instance of the Workflow.
15825 * @param id Id for the instance of this Workflow
15826 * @returns A promise that resolves with a handle for the Instance
15827 */
15828 public get(id: string): Promise<WorkflowInstance>;
15829 /**
15830 * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
15831 * @param options Options when creating an instance including id and params
15832 * @returns A promise that resolves with a handle for the Instance
15833 */
15834 public create(
15835 options?: WorkflowInstanceCreateOptions<PARAMS>,
15836 ): Promise<WorkflowInstance>;
15837 /**
15838 * Create a batch of instances and return handle for all of them. If a provided id exists, an error will be thrown.
15839 * `createBatch` is limited at 100 instances at a time or when the RPC limit for the batch (1MiB) is reached.
15840 * @param batch List of Options when creating an instance including name and params
15841 * @returns A promise that resolves with a list of handles for the created instances.
15842 */
15843 public createBatch(
15844 batch: WorkflowInstanceCreateOptions<PARAMS>[],
15845 ): Promise<WorkflowInstance[]>;
15846}
15847export type WorkflowDurationLabel =
15848 | "second"
15849 | "minute"
15850 | "hour"
15851 | "day"
15852 | "week"
15853 | "month"
15854 | "year";
15855export type WorkflowSleepDuration =
15856 | `${number} ${WorkflowDurationLabel}${"s" | ""}`
15857 | number;
15858export type WorkflowRetentionDuration = WorkflowSleepDuration;
15859export interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
15860 /**
15861 * An id for your Workflow instance. Must be unique within the Workflow.
15862 */
15863 id?: string;
15864 /**
15865 * The event payload the Workflow instance is triggered with
15866 */
15867 params?: PARAMS;
15868 /**
15869 * The retention policy for Workflow instance.
15870 * Defaults to the maximum retention period available for the owner's account.
15871 */
15872 retention?: {
15873 successRetention?: WorkflowRetentionDuration;
15874 errorRetention?: WorkflowRetentionDuration;
15875 };
15876}
15877export type InstanceStatus = {
15878 status:
15879 | "queued" // means that instance is waiting to be started (see concurrency limits)
15880 | "running"
15881 | "paused"
15882 | "errored"
15883 | "terminated" // user terminated the instance while it was running
15884 | "complete"
15885 | "waiting" // instance is hibernating and waiting for sleep or event to finish
15886 | "waitingForPause" // instance is finishing the current work to pause
15887 | "unknown";
15888 error?: {
15889 name: string;
15890 message: string;
15891 };
15892 output?: unknown;
15893};
15894export interface WorkflowError {
15895 code?: number;
15896 message: string;
15897}
15898export interface WorkflowInstanceRestartOptions {
15899 /**
15900 * Restart from a specific step. If omitted, the instance restarts from the beginning.
15901 * The step must exist in the instance's execution history.
15902 */
15903 from?: {
15904 /**
15905 * The step name as defined in your workflow code.
15906 */
15907 name: string;
15908 /**
15909 * 1-indexed occurrence of this step name. Use when the same step name appears multiple times (e.g. in a loop).
15910 * @default 1
15911 */
15912 count?: number;
15913 /**
15914 * Step type filter. Use when different step types share the same name.
15915 */
15916 type?: "do" | "sleep" | "waitForEvent";
15917 };
15918}
15919export declare abstract class WorkflowInstance {
15920 public id: string;
15921 /**
15922 * Pause the instance.
15923 */
15924 public pause(): Promise<void>;
15925 /**
15926 * Resume the instance. If it is already running, an error will be thrown.
15927 */
15928 public resume(): Promise<void>;
15929 /**
15930 * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
15931 */
15932 public terminate(): Promise<void>;
15933 /**
15934 * Restart the instance. Optionally restart from a specific step, preserving
15935 * cached results for all steps before it.
15936 * @param options Options for the restart, including an optional step to restart from.
15937 */
15938 public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
15939 /**
15940 * Returns the current status of the instance.
15941 */
15942 public status(): Promise<InstanceStatus>;
15943 /**
15944 * Send an event to this instance.
15945 */
15946 public sendEvent({
15947 type,
15948 payload,
15949 }: {
15950 type: string;
15951 payload: unknown;
15952 }): Promise<void>;
15953}