@cloudflare/workers-types 0.20240712.0 → 0.20250124.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ and limitations under the License.
14
14
  ***************************************************************************** */
15
15
  /* eslint-disable */
16
16
  // noinspection JSUnusedGlobalSymbols
17
+ export declare var onmessage: never;
17
18
  /**
18
19
  * An abnormal event (called an exception) which occurs as a result of calling a method or accessing a property of a web API.
19
20
  *
@@ -227,7 +228,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
227
228
  structuredClone<T>(value: T, options?: StructuredSerializeOptions): T;
228
229
  reportError(error: any): void;
229
230
  fetch(
230
- input: RequestInfo,
231
+ input: RequestInfo | URL,
231
232
  init?: RequestInit<RequestInitCfProperties>,
232
233
  ): Promise<Response>;
233
234
  self: ServiceWorkerGlobalScope;
@@ -235,6 +236,7 @@ export interface ServiceWorkerGlobalScope extends WorkerGlobalScope {
235
236
  caches: CacheStorage;
236
237
  scheduler: Scheduler;
237
238
  performance: Performance;
239
+ Cloudflare: Cloudflare;
238
240
  readonly origin: string;
239
241
  Event: typeof Event;
240
242
  ExtendableEvent: typeof ExtendableEvent;
@@ -366,7 +368,7 @@ export declare function structuredClone<T>(
366
368
  export declare function reportError(error: any): void;
367
369
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
368
370
  export declare function fetch(
369
- input: RequestInfo,
371
+ input: RequestInfo | URL,
370
372
  init?: RequestInit<RequestInitCfProperties>,
371
373
  ): Promise<Response>;
372
374
  export declare const self: ServiceWorkerGlobalScope;
@@ -393,12 +395,14 @@ export declare const scheduler: Scheduler;
393
395
  * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
394
396
  */
395
397
  export declare const performance: Performance;
398
+ export declare const Cloudflare: Cloudflare;
396
399
  export declare const origin: string;
397
400
  export declare const navigator: Navigator;
398
401
  export interface TestController {}
399
402
  export interface ExecutionContext {
400
403
  waitUntil(promise: Promise<any>): void;
401
404
  passThroughOnException(): void;
405
+ props: any;
402
406
  }
403
407
  export type ExportedHandlerFetchHandler<
404
408
  Env = unknown,
@@ -418,6 +422,11 @@ export type ExportedHandlerTraceHandler<Env = unknown> = (
418
422
  env: Env,
419
423
  ctx: ExecutionContext,
420
424
  ) => void | Promise<void>;
425
+ export type ExportedHandlerTailStreamHandler<Env = unknown> = (
426
+ event: TailStream.TailEvent,
427
+ env: Env,
428
+ ctx: ExecutionContext,
429
+ ) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
421
430
  export type ExportedHandlerScheduledHandler<Env = unknown> = (
422
431
  controller: ScheduledController,
423
432
  env: Env,
@@ -441,6 +450,7 @@ export interface ExportedHandler<
441
450
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
442
451
  tail?: ExportedHandlerTailHandler<Env>;
443
452
  trace?: ExportedHandlerTraceHandler<Env>;
453
+ tailStream?: ExportedHandlerTailStreamHandler<Env>;
444
454
  scheduled?: ExportedHandlerScheduledHandler<Env>;
445
455
  test?: ExportedHandlerTestHandler<Env>;
446
456
  email?: EmailExportedHandler<Env>;
@@ -464,8 +474,9 @@ export declare abstract class Navigator {
464
474
  | string
465
475
  | (ArrayBuffer | ArrayBufferView)
466
476
  | Blob
477
+ | FormData
467
478
  | URLSearchParams
468
- | FormData,
479
+ | URLSearchParams,
469
480
  ): boolean;
470
481
  readonly userAgent: string;
471
482
  readonly gpu: GPU;
@@ -486,9 +497,12 @@ export interface AlarmInvocationInfo {
486
497
  readonly isRetry: boolean;
487
498
  readonly retryCount: number;
488
499
  }
500
+ export interface Cloudflare {
501
+ readonly compatibilityFlags: Record<string, boolean>;
502
+ }
489
503
  export interface DurableObject {
490
504
  fetch(request: Request): Response | Promise<Response>;
491
- alarm?(): void | Promise<void>;
505
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
492
506
  webSocketMessage?(
493
507
  ws: WebSocket,
494
508
  message: string | ArrayBuffer,
@@ -561,6 +575,7 @@ export interface DurableObjectState {
561
575
  setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
562
576
  getHibernatableWebSocketEventTimeout(): number | null;
563
577
  getTags(ws: WebSocket): string[];
578
+ abort(reason?: string): void;
564
579
  }
565
580
  export interface DurableObjectTransaction {
566
581
  get<T = unknown>(
@@ -627,7 +642,11 @@ export interface DurableObjectStorage {
627
642
  ): Promise<void>;
628
643
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
629
644
  sync(): Promise<void>;
645
+ sql: SqlStorage;
630
646
  transactionSync<T>(closure: () => T): T;
647
+ getCurrentBookmark(): Promise<string>;
648
+ getBookmarkForTime(timestamp: number | Date): Promise<string>;
649
+ onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
631
650
  }
632
651
  export interface DurableObjectListOptions {
633
652
  start?: string;
@@ -998,14 +1017,17 @@ export declare abstract class CacheStorage {
998
1017
  */
999
1018
  export declare abstract class Cache {
1000
1019
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1001
- delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
1020
+ delete(
1021
+ request: RequestInfo | URL,
1022
+ options?: CacheQueryOptions,
1023
+ ): Promise<boolean>;
1002
1024
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1003
1025
  match(
1004
- request: RequestInfo,
1026
+ request: RequestInfo | URL,
1005
1027
  options?: CacheQueryOptions,
1006
1028
  ): Promise<Response | undefined>;
1007
1029
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1008
- put(request: RequestInfo, response: Response): Promise<void>;
1030
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
1009
1031
  }
1010
1032
  export interface CacheQueryOptions {
1011
1033
  ignoreMethod?: boolean;
@@ -1428,20 +1450,44 @@ export interface Element {
1428
1450
  hasAttribute(name: string): boolean;
1429
1451
  setAttribute(name: string, value: string): Element;
1430
1452
  removeAttribute(name: string): Element;
1431
- before(content: string, options?: ContentOptions): Element;
1432
- after(content: string, options?: ContentOptions): Element;
1433
- prepend(content: string, options?: ContentOptions): Element;
1434
- append(content: string, options?: ContentOptions): Element;
1435
- replace(content: string, options?: ContentOptions): Element;
1453
+ before(
1454
+ content: string | ReadableStream | Response,
1455
+ options?: ContentOptions,
1456
+ ): Element;
1457
+ after(
1458
+ content: string | ReadableStream | Response,
1459
+ options?: ContentOptions,
1460
+ ): Element;
1461
+ prepend(
1462
+ content: string | ReadableStream | Response,
1463
+ options?: ContentOptions,
1464
+ ): Element;
1465
+ append(
1466
+ content: string | ReadableStream | Response,
1467
+ options?: ContentOptions,
1468
+ ): Element;
1469
+ replace(
1470
+ content: string | ReadableStream | Response,
1471
+ options?: ContentOptions,
1472
+ ): Element;
1436
1473
  remove(): Element;
1437
1474
  removeAndKeepContent(): Element;
1438
- setInnerContent(content: string, options?: ContentOptions): Element;
1475
+ setInnerContent(
1476
+ content: string | ReadableStream | Response,
1477
+ options?: ContentOptions,
1478
+ ): Element;
1439
1479
  onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1440
1480
  }
1441
1481
  export interface EndTag {
1442
1482
  name: string;
1443
- before(content: string, options?: ContentOptions): EndTag;
1444
- after(content: string, options?: ContentOptions): EndTag;
1483
+ before(
1484
+ content: string | ReadableStream | Response,
1485
+ options?: ContentOptions,
1486
+ ): EndTag;
1487
+ after(
1488
+ content: string | ReadableStream | Response,
1489
+ options?: ContentOptions,
1490
+ ): EndTag;
1445
1491
  remove(): EndTag;
1446
1492
  }
1447
1493
  export interface Comment {
@@ -1456,9 +1502,18 @@ export interface Text {
1456
1502
  readonly text: string;
1457
1503
  readonly lastInTextNode: boolean;
1458
1504
  readonly removed: boolean;
1459
- before(content: string, options?: ContentOptions): Text;
1460
- after(content: string, options?: ContentOptions): Text;
1461
- replace(content: string, options?: ContentOptions): Text;
1505
+ before(
1506
+ content: string | ReadableStream | Response,
1507
+ options?: ContentOptions,
1508
+ ): Text;
1509
+ after(
1510
+ content: string | ReadableStream | Response,
1511
+ options?: ContentOptions,
1512
+ ): Text;
1513
+ replace(
1514
+ content: string | ReadableStream | Response,
1515
+ options?: ContentOptions,
1516
+ ): Text;
1462
1517
  remove(): Text;
1463
1518
  }
1464
1519
  export interface DocumentEnd {
@@ -1540,28 +1595,34 @@ export declare abstract class Body {
1540
1595
  *
1541
1596
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1542
1597
  */
1543
- export declare class Response extends Body {
1544
- constructor(body?: BodyInit | null, init?: ResponseInit);
1545
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1546
- static redirect(url: string, status?: number): Response;
1547
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
1548
- static json(any: any, maybeInit?: ResponseInit | Response): Response;
1598
+ export declare var Response: {
1599
+ prototype: Response;
1600
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
1601
+ redirect(url: string, status?: number): Response;
1602
+ json(any: any, maybeInit?: ResponseInit | Response): Response;
1603
+ };
1604
+ /**
1605
+ * This Fetch API interface represents the response to a request.
1606
+ *
1607
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1608
+ */
1609
+ export interface Response extends Body {
1549
1610
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1550
1611
  clone(): Response;
1551
1612
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1552
- get status(): number;
1613
+ status: number;
1553
1614
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1554
- get statusText(): string;
1615
+ statusText: string;
1555
1616
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1556
- get headers(): Headers;
1617
+ headers: Headers;
1557
1618
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1558
- get ok(): boolean;
1619
+ ok: boolean;
1559
1620
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1560
- get redirected(): boolean;
1621
+ redirected: boolean;
1561
1622
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1562
- get url(): string;
1563
- get webSocket(): WebSocket | null;
1564
- get cf(): any | undefined;
1623
+ url: string;
1624
+ webSocket: WebSocket | null;
1625
+ cf: any | undefined;
1565
1626
  }
1566
1627
  export interface ResponseInit {
1567
1628
  status?: number;
@@ -1574,17 +1635,28 @@ export interface ResponseInit {
1574
1635
  export type RequestInfo<
1575
1636
  CfHostMetadata = unknown,
1576
1637
  Cf = CfProperties<CfHostMetadata>,
1577
- > = Request<CfHostMetadata, Cf> | string | URL;
1638
+ > = Request<CfHostMetadata, Cf> | string;
1639
+ /**
1640
+ * This Fetch API interface represents a resource request.
1641
+ *
1642
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1643
+ */
1644
+ export declare var Request: {
1645
+ prototype: Request;
1646
+ new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
1647
+ input: RequestInfo<CfProperties> | URL,
1648
+ init?: RequestInit<Cf>,
1649
+ ): Request<CfHostMetadata, Cf>;
1650
+ };
1578
1651
  /**
1579
1652
  * This Fetch API interface represents a resource request.
1580
1653
  *
1581
1654
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1582
1655
  */
1583
- export declare class Request<
1656
+ export interface Request<
1584
1657
  CfHostMetadata = unknown,
1585
1658
  Cf = CfProperties<CfHostMetadata>,
1586
1659
  > extends Body {
1587
- constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1588
1660
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1589
1661
  clone(): Request<CfHostMetadata, Cf>;
1590
1662
  /**
@@ -1592,45 +1664,45 @@ export declare class Request<
1592
1664
  *
1593
1665
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1594
1666
  */
1595
- get method(): string;
1667
+ method: string;
1596
1668
  /**
1597
1669
  * Returns the URL of request as a string.
1598
1670
  *
1599
1671
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1600
1672
  */
1601
- get url(): string;
1673
+ url: string;
1602
1674
  /**
1603
1675
  * Returns a Headers object consisting of the headers associated with request. Note that headers added in the network layer by the user agent will not be accounted for in this object, e.g., the "Host" header.
1604
1676
  *
1605
1677
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1606
1678
  */
1607
- get headers(): Headers;
1679
+ headers: Headers;
1608
1680
  /**
1609
1681
  * Returns the redirect mode associated with request, which is a string indicating how redirects for the request will be handled during fetching. A request will follow redirects by default.
1610
1682
  *
1611
1683
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1612
1684
  */
1613
- get redirect(): string;
1614
- get fetcher(): Fetcher | null;
1685
+ redirect: string;
1686
+ fetcher: Fetcher | null;
1615
1687
  /**
1616
1688
  * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1617
1689
  *
1618
1690
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1619
1691
  */
1620
- get signal(): AbortSignal;
1621
- get cf(): Cf | undefined;
1692
+ signal: AbortSignal;
1693
+ cf: Cf | undefined;
1622
1694
  /**
1623
1695
  * Returns request's subresource integrity metadata, which is a cryptographic hash of the resource being fetched. Its value consists of multiple hashes separated by whitespace. [SRI]
1624
1696
  *
1625
1697
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1626
1698
  */
1627
- get integrity(): string;
1699
+ integrity: string;
1628
1700
  /**
1629
1701
  * Returns a boolean indicating whether or not request can outlive the global in which it was created.
1630
1702
  *
1631
1703
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1632
1704
  */
1633
- get keepalive(): boolean;
1705
+ keepalive: boolean;
1634
1706
  }
1635
1707
  export interface RequestInit<Cf = CfProperties> {
1636
1708
  /* A string to set request's method. */
@@ -1657,7 +1729,7 @@ export type Fetcher<
1657
1729
  > = (T extends Rpc.EntrypointBranded
1658
1730
  ? Rpc.Provider<T, Reserved | "fetch" | "connect">
1659
1731
  : unknown) & {
1660
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1732
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1661
1733
  connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1662
1734
  };
1663
1735
  export interface FetcherPutOptions {
@@ -1879,6 +1951,7 @@ export interface R2MultipartUpload {
1879
1951
  uploadPart(
1880
1952
  partNumber: number,
1881
1953
  value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
1954
+ options?: R2UploadPartOptions,
1882
1955
  ): Promise<R2UploadedPart>;
1883
1956
  abort(): Promise<void>;
1884
1957
  complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
@@ -1899,6 +1972,7 @@ export declare abstract class R2Object {
1899
1972
  readonly customMetadata?: Record<string, string>;
1900
1973
  readonly range?: R2Range;
1901
1974
  readonly storageClass: string;
1975
+ readonly ssecKeyMd5?: string;
1902
1976
  writeHttpMetadata(headers: Headers): void;
1903
1977
  }
1904
1978
  export interface R2ObjectBody extends R2Object {
@@ -1931,6 +2005,7 @@ export interface R2Conditional {
1931
2005
  export interface R2GetOptions {
1932
2006
  onlyIf?: R2Conditional | Headers;
1933
2007
  range?: R2Range | Headers;
2008
+ ssecKey?: ArrayBuffer | string;
1934
2009
  }
1935
2010
  export interface R2PutOptions {
1936
2011
  onlyIf?: R2Conditional | Headers;
@@ -1942,11 +2017,13 @@ export interface R2PutOptions {
1942
2017
  sha384?: ArrayBuffer | string;
1943
2018
  sha512?: ArrayBuffer | string;
1944
2019
  storageClass?: string;
2020
+ ssecKey?: ArrayBuffer | string;
1945
2021
  }
1946
2022
  export interface R2MultipartOptions {
1947
2023
  httpMetadata?: R2HTTPMetadata | Headers;
1948
2024
  customMetadata?: Record<string, string>;
1949
2025
  storageClass?: string;
2026
+ ssecKey?: ArrayBuffer | string;
1950
2027
  }
1951
2028
  export interface R2Checksums {
1952
2029
  readonly md5?: ArrayBuffer;
@@ -1983,6 +2060,9 @@ export type R2Objects = {
1983
2060
  truncated: false;
1984
2061
  }
1985
2062
  );
2063
+ export interface R2UploadPartOptions {
2064
+ ssecKey?: ArrayBuffer | string;
2065
+ }
1986
2066
  export declare abstract class ScheduledEvent extends ExtendableEvent {
1987
2067
  readonly scheduledTime: number;
1988
2068
  readonly cron: string;
@@ -2396,6 +2476,8 @@ export interface TraceItem {
2396
2476
  readonly dispatchNamespace?: string;
2397
2477
  readonly scriptTags?: string[];
2398
2478
  readonly outcome: string;
2479
+ readonly executionModel: string;
2480
+ readonly truncated: boolean;
2399
2481
  }
2400
2482
  export interface TraceItemAlarmEventInfo {
2401
2483
  readonly scheduledTime: Date;
@@ -2535,6 +2617,10 @@ export declare class URL {
2535
2617
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
2536
2618
  static canParse(url: string, base?: string): boolean;
2537
2619
  static parse(url: string, base?: string): URL | null;
2620
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
2621
+ static createObjectURL(object: File | Blob): string;
2622
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
2623
+ static revokeObjectURL(object_url: string): void;
2538
2624
  }
2539
2625
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */
2540
2626
  export declare class URLSearchParams {
@@ -2708,8 +2794,24 @@ export type WebSocketEventMap = {
2708
2794
  *
2709
2795
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2710
2796
  */
2711
- export declare class WebSocket extends EventTarget<WebSocketEventMap> {
2712
- constructor(url: string, protocols?: string[] | string);
2797
+ export declare var WebSocket: {
2798
+ prototype: WebSocket;
2799
+ new (url: string, protocols?: string[] | string): WebSocket;
2800
+ readonly READY_STATE_CONNECTING: number;
2801
+ readonly CONNECTING: number;
2802
+ readonly READY_STATE_OPEN: number;
2803
+ readonly OPEN: number;
2804
+ readonly READY_STATE_CLOSING: number;
2805
+ readonly CLOSING: number;
2806
+ readonly READY_STATE_CLOSED: number;
2807
+ readonly CLOSED: number;
2808
+ };
2809
+ /**
2810
+ * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2811
+ *
2812
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2813
+ */
2814
+ export interface WebSocket extends EventTarget<WebSocketEventMap> {
2713
2815
  accept(): void;
2714
2816
  /**
2715
2817
  * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
@@ -2725,38 +2827,30 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
2725
2827
  close(code?: number, reason?: string): void;
2726
2828
  serializeAttachment(attachment: any): void;
2727
2829
  deserializeAttachment(): any | null;
2728
- static readonly READY_STATE_CONNECTING: number;
2729
- static readonly CONNECTING: number;
2730
- static readonly READY_STATE_OPEN: number;
2731
- static readonly OPEN: number;
2732
- static readonly READY_STATE_CLOSING: number;
2733
- static readonly CLOSING: number;
2734
- static readonly READY_STATE_CLOSED: number;
2735
- static readonly CLOSED: number;
2736
2830
  /**
2737
2831
  * Returns the state of the WebSocket object's connection. It can have the values described below.
2738
2832
  *
2739
2833
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2740
2834
  */
2741
- get readyState(): number;
2835
+ readyState: number;
2742
2836
  /**
2743
2837
  * Returns the URL that was used to establish the WebSocket connection.
2744
2838
  *
2745
2839
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2746
2840
  */
2747
- get url(): string | null;
2841
+ url: string | null;
2748
2842
  /**
2749
2843
  * Returns the subprotocol selected by the server, if any. It can be used in conjunction with the array form of the constructor's second argument to perform subprotocol negotiation.
2750
2844
  *
2751
2845
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2752
2846
  */
2753
- get protocol(): string | null;
2847
+ protocol: string | null;
2754
2848
  /**
2755
2849
  * Returns the extensions selected by the server, if any.
2756
2850
  *
2757
2851
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2758
2852
  */
2759
- get extensions(): string | null;
2853
+ extensions: string | null;
2760
2854
  }
2761
2855
  export declare const WebSocketPair: {
2762
2856
  new (): {
@@ -2764,6 +2858,37 @@ export declare const WebSocketPair: {
2764
2858
  1: WebSocket;
2765
2859
  };
2766
2860
  };
2861
+ export interface SqlStorage {
2862
+ exec<T extends Record<string, SqlStorageValue>>(
2863
+ query: string,
2864
+ ...bindings: any[]
2865
+ ): SqlStorageCursor<T>;
2866
+ get databaseSize(): number;
2867
+ Cursor: typeof SqlStorageCursor;
2868
+ Statement: typeof SqlStorageStatement;
2869
+ }
2870
+ export declare abstract class SqlStorageStatement {}
2871
+ export type SqlStorageValue = ArrayBuffer | string | number | null;
2872
+ export declare abstract class SqlStorageCursor<
2873
+ T extends Record<string, SqlStorageValue>,
2874
+ > {
2875
+ next():
2876
+ | {
2877
+ done?: false;
2878
+ value: T;
2879
+ }
2880
+ | {
2881
+ done: true;
2882
+ value?: never;
2883
+ };
2884
+ toArray(): T[];
2885
+ one(): T;
2886
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2887
+ columnNames: string[];
2888
+ get rowsRead(): number;
2889
+ get rowsWritten(): number;
2890
+ [Symbol.iterator](): IterableIterator<T>;
2891
+ }
2767
2892
  export interface Socket {
2768
2893
  get readable(): ReadableStream;
2769
2894
  get writable(): WritableStream;
@@ -3301,7 +3426,7 @@ export interface GPUOrigin3DDict {
3301
3426
  z?: number;
3302
3427
  }
3303
3428
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3304
- export declare class EventSource {
3429
+ export declare class EventSource extends EventTarget {
3305
3430
  constructor(url: string, init?: EventSourceEventSourceInit);
3306
3431
  /**
3307
3432
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -3400,10 +3525,10 @@ export declare abstract class BaseAiSentenceSimilarity {
3400
3525
  inputs: AiSentenceSimilarityInput;
3401
3526
  postProcessedOutputs: AiSentenceSimilarityOutput;
3402
3527
  }
3403
- export type AiSpeechRecognitionInput = {
3528
+ export type AiAutomaticSpeechRecognitionInput = {
3404
3529
  audio: number[];
3405
3530
  };
3406
- export type AiSpeechRecognitionOutput = {
3531
+ export type AiAutomaticSpeechRecognitionOutput = {
3407
3532
  text?: string;
3408
3533
  words?: {
3409
3534
  word: string;
@@ -3412,9 +3537,9 @@ export type AiSpeechRecognitionOutput = {
3412
3537
  }[];
3413
3538
  vtt?: string;
3414
3539
  };
3415
- export declare abstract class BaseAiSpeechRecognition {
3416
- inputs: AiSpeechRecognitionInput;
3417
- postProcessedOutputs: AiSpeechRecognitionOutput;
3540
+ export declare abstract class BaseAiAutomaticSpeechRecognition {
3541
+ inputs: AiAutomaticSpeechRecognitionInput;
3542
+ postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3418
3543
  }
3419
3544
  export type AiSummarizationInput = {
3420
3545
  input_text: string;
@@ -3450,16 +3575,36 @@ export declare abstract class BaseAiTextEmbeddings {
3450
3575
  postProcessedOutputs: AiTextEmbeddingsOutput;
3451
3576
  }
3452
3577
  export type RoleScopedChatInput = {
3453
- role: "user" | "assistant" | "system" | "tool";
3578
+ role:
3579
+ | "user"
3580
+ | "assistant"
3581
+ | "system"
3582
+ | "tool"
3583
+ | (string & NonNullable<unknown>);
3454
3584
  content: string;
3585
+ name?: string;
3586
+ };
3587
+ export type AiTextGenerationToolLegacyInput = {
3588
+ name: string;
3589
+ description: string;
3590
+ parameters?: {
3591
+ type: "object" | (string & NonNullable<unknown>);
3592
+ properties: {
3593
+ [key: string]: {
3594
+ type: string;
3595
+ description?: string;
3596
+ };
3597
+ };
3598
+ required: string[];
3599
+ };
3455
3600
  };
3456
3601
  export type AiTextGenerationToolInput = {
3457
- type: "function";
3602
+ type: "function" | (string & NonNullable<unknown>);
3458
3603
  function: {
3459
3604
  name: string;
3460
3605
  description: string;
3461
3606
  parameters?: {
3462
- type: "object";
3607
+ type: "object" | (string & NonNullable<unknown>);
3463
3608
  properties: {
3464
3609
  [key: string]: {
3465
3610
  type: string;
@@ -3470,6 +3615,10 @@ export type AiTextGenerationToolInput = {
3470
3615
  };
3471
3616
  };
3472
3617
  };
3618
+ export type AiTextGenerationFunctionsInput = {
3619
+ name: string;
3620
+ code: string;
3621
+ };
3473
3622
  export type AiTextGenerationInput = {
3474
3623
  prompt?: string;
3475
3624
  raw?: boolean;
@@ -3483,7 +3632,11 @@ export type AiTextGenerationInput = {
3483
3632
  frequency_penalty?: number;
3484
3633
  presence_penalty?: number;
3485
3634
  messages?: RoleScopedChatInput[];
3486
- tools?: AiTextGenerationToolInput[];
3635
+ tools?:
3636
+ | AiTextGenerationToolInput[]
3637
+ | AiTextGenerationToolLegacyInput[]
3638
+ | (object & NonNullable<unknown>);
3639
+ functions?: AiTextGenerationFunctionsInput[];
3487
3640
  };
3488
3641
  export type AiTextGenerationOutput =
3489
3642
  | {
@@ -3498,15 +3651,33 @@ export declare abstract class BaseAiTextGeneration {
3498
3651
  inputs: AiTextGenerationInput;
3499
3652
  postProcessedOutputs: AiTextGenerationOutput;
3500
3653
  }
3654
+ export type AiTextToSpeechInput = {
3655
+ prompt: string;
3656
+ lang?: string;
3657
+ };
3658
+ export type AiTextToSpeechOutput =
3659
+ | Uint8Array
3660
+ | {
3661
+ audio: string;
3662
+ };
3663
+ export declare abstract class BaseAiTextToSpeech {
3664
+ inputs: AiTextToSpeechInput;
3665
+ postProcessedOutputs: AiTextToSpeechOutput;
3666
+ }
3501
3667
  export type AiTextToImageInput = {
3502
3668
  prompt: string;
3669
+ negative_prompt?: string;
3670
+ height?: number;
3671
+ width?: number;
3503
3672
  image?: number[];
3673
+ image_b64?: string;
3504
3674
  mask?: number[];
3505
3675
  num_steps?: number;
3506
3676
  strength?: number;
3507
3677
  guidance?: number;
3678
+ seed?: number;
3508
3679
  };
3509
- export type AiTextToImageOutput = Uint8Array;
3680
+ export type AiTextToImageOutput = ReadableStream<Uint8Array>;
3510
3681
  export declare abstract class BaseAiTextToImage {
3511
3682
  inputs: AiTextToImageInput;
3512
3683
  postProcessedOutputs: AiTextToImageOutput;
@@ -3523,127 +3694,615 @@ export declare abstract class BaseAiTranslation {
3523
3694
  inputs: AiTranslationInput;
3524
3695
  postProcessedOutputs: AiTranslationOutput;
3525
3696
  }
3697
+ export type Ai_Cf_Openai_Whisper_Input =
3698
+ | string
3699
+ | {
3700
+ /**
3701
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3702
+ */
3703
+ audio: number[];
3704
+ };
3705
+ export interface Ai_Cf_Openai_Whisper_Output {
3706
+ /**
3707
+ * The transcription
3708
+ */
3709
+ text: string;
3710
+ word_count?: number;
3711
+ words?: {
3712
+ word?: string;
3713
+ /**
3714
+ * The second this word begins in the recording
3715
+ */
3716
+ start?: number;
3717
+ /**
3718
+ * The ending second when the word completes
3719
+ */
3720
+ end?: number;
3721
+ }[];
3722
+ vtt?: string;
3723
+ }
3724
+ export declare abstract class Base_Ai_Cf_Openai_Whisper {
3725
+ inputs: Ai_Cf_Openai_Whisper_Input;
3726
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
3727
+ }
3728
+ export type Ai_Cf_Openai_Whisper_Tiny_En_Input =
3729
+ | string
3730
+ | {
3731
+ /**
3732
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3733
+ */
3734
+ audio: number[];
3735
+ };
3736
+ export interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3737
+ /**
3738
+ * The transcription
3739
+ */
3740
+ text: string;
3741
+ word_count?: number;
3742
+ words?: {
3743
+ word?: string;
3744
+ /**
3745
+ * The second this word begins in the recording
3746
+ */
3747
+ start?: number;
3748
+ /**
3749
+ * The ending second when the word completes
3750
+ */
3751
+ end?: number;
3752
+ }[];
3753
+ vtt?: string;
3754
+ }
3755
+ export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3756
+ inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3757
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3758
+ }
3759
+ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3760
+ /**
3761
+ * Base64 encoded value of the audio data.
3762
+ */
3763
+ audio: string;
3764
+ /**
3765
+ * Supported tasks are 'translate' or 'transcribe'.
3766
+ */
3767
+ task?: string;
3768
+ /**
3769
+ * The language of the audio being transcribed or translated.
3770
+ */
3771
+ language?: string;
3772
+ /**
3773
+ * Preprocess the audio with a voice activity detection model.
3774
+ */
3775
+ vad_filter?: string;
3776
+ /**
3777
+ * A text prompt to help provide context to the model on the contents of the audio.
3778
+ */
3779
+ initial_prompt?: string;
3780
+ /**
3781
+ * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3782
+ */
3783
+ prefix?: string;
3784
+ }
3785
+ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3786
+ transcription_info?: {
3787
+ /**
3788
+ * The language of the audio being transcribed or translated.
3789
+ */
3790
+ language?: string;
3791
+ /**
3792
+ * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3793
+ */
3794
+ language_probability?: number;
3795
+ /**
3796
+ * The total duration of the original audio file, in seconds.
3797
+ */
3798
+ duration?: number;
3799
+ /**
3800
+ * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3801
+ */
3802
+ duration_after_vad?: number;
3803
+ };
3804
+ /**
3805
+ * The complete transcription of the audio.
3806
+ */
3807
+ text: string;
3808
+ /**
3809
+ * The total number of words in the transcription.
3810
+ */
3811
+ word_count?: number;
3812
+ segments?: {
3813
+ /**
3814
+ * The starting time of the segment within the audio, in seconds.
3815
+ */
3816
+ start?: number;
3817
+ /**
3818
+ * The ending time of the segment within the audio, in seconds.
3819
+ */
3820
+ end?: number;
3821
+ /**
3822
+ * The transcription of the segment.
3823
+ */
3824
+ text?: string;
3825
+ /**
3826
+ * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3827
+ */
3828
+ temperature?: number;
3829
+ /**
3830
+ * The average log probability of the predictions for the words in this segment, indicating overall confidence.
3831
+ */
3832
+ avg_logprob?: number;
3833
+ /**
3834
+ * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3835
+ */
3836
+ compression_ratio?: number;
3837
+ /**
3838
+ * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3839
+ */
3840
+ no_speech_prob?: number;
3841
+ words?: {
3842
+ /**
3843
+ * The individual word transcribed from the audio.
3844
+ */
3845
+ word?: string;
3846
+ /**
3847
+ * The starting time of the word within the audio, in seconds.
3848
+ */
3849
+ start?: number;
3850
+ /**
3851
+ * The ending time of the word within the audio, in seconds.
3852
+ */
3853
+ end?: number;
3854
+ }[];
3855
+ };
3856
+ /**
3857
+ * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3858
+ */
3859
+ vtt?: string;
3860
+ }
3861
+ export declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3862
+ inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3863
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3864
+ }
3865
+ export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3866
+ /**
3867
+ * A text description of the image you want to generate.
3868
+ */
3869
+ prompt: string;
3870
+ /**
3871
+ * The number of diffusion steps; higher values can improve quality but take longer.
3872
+ */
3873
+ steps?: number;
3874
+ }
3875
+ export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3876
+ /**
3877
+ * The generated image in Base64 format.
3878
+ */
3879
+ image?: string;
3880
+ }
3881
+ export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3882
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3883
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3884
+ }
3885
+ export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3886
+ export interface Prompt {
3887
+ /**
3888
+ * The input text prompt for the model to generate a response.
3889
+ */
3890
+ prompt: string;
3891
+ image?: number[] | (string & NonNullable<unknown>);
3892
+ /**
3893
+ * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3894
+ */
3895
+ raw?: boolean;
3896
+ /**
3897
+ * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3898
+ */
3899
+ stream?: boolean;
3900
+ /**
3901
+ * The maximum number of tokens to generate in the response.
3902
+ */
3903
+ max_tokens?: number;
3904
+ /**
3905
+ * Controls the randomness of the output; higher values produce more random results.
3906
+ */
3907
+ temperature?: number;
3908
+ /**
3909
+ * 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.
3910
+ */
3911
+ top_p?: number;
3912
+ /**
3913
+ * 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.
3914
+ */
3915
+ top_k?: number;
3916
+ /**
3917
+ * Random seed for reproducibility of the generation.
3918
+ */
3919
+ seed?: number;
3920
+ /**
3921
+ * Penalty for repeated tokens; higher values discourage repetition.
3922
+ */
3923
+ repetition_penalty?: number;
3924
+ /**
3925
+ * Decreases the likelihood of the model repeating the same lines verbatim.
3926
+ */
3927
+ frequency_penalty?: number;
3928
+ /**
3929
+ * Increases the likelihood of the model introducing new topics.
3930
+ */
3931
+ presence_penalty?: number;
3932
+ /**
3933
+ * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3934
+ */
3935
+ lora?: string;
3936
+ }
3937
+ export interface Messages {
3938
+ /**
3939
+ * An array of message objects representing the conversation history.
3940
+ */
3941
+ messages: {
3942
+ /**
3943
+ * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3944
+ */
3945
+ role: string;
3946
+ /**
3947
+ * The content of the message as a string.
3948
+ */
3949
+ content: string;
3950
+ }[];
3951
+ image?: number[] | string;
3952
+ functions?: {
3953
+ name: string;
3954
+ code: string;
3955
+ }[];
3956
+ /**
3957
+ * A list of tools available for the assistant to use.
3958
+ */
3959
+ tools?: (
3960
+ | {
3961
+ /**
3962
+ * The name of the tool. More descriptive the better.
3963
+ */
3964
+ name: string;
3965
+ /**
3966
+ * A brief description of what the tool does.
3967
+ */
3968
+ description: string;
3969
+ /**
3970
+ * Schema defining the parameters accepted by the tool.
3971
+ */
3972
+ parameters: {
3973
+ /**
3974
+ * The type of the parameters object (usually 'object').
3975
+ */
3976
+ type: string;
3977
+ /**
3978
+ * List of required parameter names.
3979
+ */
3980
+ required?: string[];
3981
+ /**
3982
+ * Definitions of each parameter.
3983
+ */
3984
+ properties: {
3985
+ [k: string]: {
3986
+ /**
3987
+ * The data type of the parameter.
3988
+ */
3989
+ type: string;
3990
+ /**
3991
+ * A description of the expected parameter.
3992
+ */
3993
+ description: string;
3994
+ };
3995
+ };
3996
+ };
3997
+ }
3998
+ | {
3999
+ /**
4000
+ * Specifies the type of tool (e.g., 'function').
4001
+ */
4002
+ type: string;
4003
+ /**
4004
+ * Details of the function tool.
4005
+ */
4006
+ function: {
4007
+ /**
4008
+ * The name of the function.
4009
+ */
4010
+ name: string;
4011
+ /**
4012
+ * A brief description of what the function does.
4013
+ */
4014
+ description: string;
4015
+ /**
4016
+ * Schema defining the parameters accepted by the function.
4017
+ */
4018
+ parameters: {
4019
+ /**
4020
+ * The type of the parameters object (usually 'object').
4021
+ */
4022
+ type: string;
4023
+ /**
4024
+ * List of required parameter names.
4025
+ */
4026
+ required?: string[];
4027
+ /**
4028
+ * Definitions of each parameter.
4029
+ */
4030
+ properties: {
4031
+ [k: string]: {
4032
+ /**
4033
+ * The data type of the parameter.
4034
+ */
4035
+ type: string;
4036
+ /**
4037
+ * A description of the expected parameter.
4038
+ */
4039
+ description: string;
4040
+ };
4041
+ };
4042
+ };
4043
+ };
4044
+ }
4045
+ )[];
4046
+ /**
4047
+ * If true, the response will be streamed back incrementally.
4048
+ */
4049
+ stream?: boolean;
4050
+ /**
4051
+ * The maximum number of tokens to generate in the response.
4052
+ */
4053
+ max_tokens?: number;
4054
+ /**
4055
+ * Controls the randomness of the output; higher values produce more random results.
4056
+ */
4057
+ temperature?: number;
4058
+ /**
4059
+ * 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.
4060
+ */
4061
+ top_p?: number;
4062
+ /**
4063
+ * 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.
4064
+ */
4065
+ top_k?: number;
4066
+ /**
4067
+ * Random seed for reproducibility of the generation.
4068
+ */
4069
+ seed?: number;
4070
+ /**
4071
+ * Penalty for repeated tokens; higher values discourage repetition.
4072
+ */
4073
+ repetition_penalty?: number;
4074
+ /**
4075
+ * Decreases the likelihood of the model repeating the same lines verbatim.
4076
+ */
4077
+ frequency_penalty?: number;
4078
+ /**
4079
+ * Increases the likelihood of the model introducing new topics.
4080
+ */
4081
+ presence_penalty?: number;
4082
+ }
4083
+ export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
4084
+ | {
4085
+ /**
4086
+ * The generated text response from the model
4087
+ */
4088
+ response?: string;
4089
+ /**
4090
+ * An array of tool calls requests made during the response generation
4091
+ */
4092
+ tool_calls?: {
4093
+ /**
4094
+ * The arguments passed to be passed to the tool call request
4095
+ */
4096
+ arguments?: object;
4097
+ /**
4098
+ * The name of the tool to be called
4099
+ */
4100
+ name?: string;
4101
+ }[];
4102
+ }
4103
+ | ReadableStream;
4104
+ export declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4105
+ inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4106
+ postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4107
+ }
4108
+ export interface AiModels {
4109
+ "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
4110
+ "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
4111
+ "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
4112
+ "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
4113
+ "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
4114
+ "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
4115
+ "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
4116
+ "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
4117
+ "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
4118
+ "@cf/microsoft/resnet-50": BaseAiImageClassification;
4119
+ "@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
4120
+ "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
4121
+ "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
4122
+ "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
4123
+ "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
4124
+ "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
4125
+ "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
4126
+ "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
4127
+ "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
4128
+ "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
4129
+ "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
4130
+ "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
4131
+ "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
4132
+ "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
4133
+ "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
4134
+ "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
4135
+ "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
4136
+ "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
4137
+ "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
4138
+ "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
4139
+ "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
4140
+ "@cf/microsoft/phi-2": BaseAiTextGeneration;
4141
+ "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
4142
+ "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
4143
+ "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
4144
+ "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
4145
+ "@hf/google/gemma-7b-it": BaseAiTextGeneration;
4146
+ "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
4147
+ "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
4148
+ "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
4149
+ "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
4150
+ "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
4151
+ "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
4152
+ "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
4153
+ "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
4154
+ "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
4155
+ "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
4156
+ "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
4157
+ "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
4158
+ "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
4159
+ "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
4160
+ "@cf/meta/m2m100-1.2b": BaseAiTranslation;
4161
+ "@cf/facebook/bart-large-cnn": BaseAiSummarization;
4162
+ "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
4163
+ "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
4164
+ "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
4165
+ "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
4166
+ "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
4167
+ "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
4168
+ "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
4169
+ }
4170
+ export type AiOptions = {
4171
+ gateway?: GatewayOptions;
4172
+ prefix?: string;
4173
+ extraHeaders?: object;
4174
+ };
4175
+ export type AiModelsSearchParams = {
4176
+ author?: string;
4177
+ hide_experimental?: boolean;
4178
+ page?: number;
4179
+ per_page?: number;
4180
+ search?: string;
4181
+ source?: number;
4182
+ task?: string;
4183
+ };
4184
+ export type AiModelsSearchObject = {
4185
+ id: string;
4186
+ source: number;
4187
+ name: string;
4188
+ description: string;
4189
+ task: {
4190
+ id: string;
4191
+ name: string;
4192
+ description: string;
4193
+ };
4194
+ tags: string[];
4195
+ properties: {
4196
+ property_id: string;
4197
+ value: string;
4198
+ }[];
4199
+ };
4200
+ export interface InferenceUpstreamError extends Error {}
4201
+ export interface AiInternalError extends Error {}
4202
+ export type AiModelListType = Record<string, any>;
4203
+ export declare abstract class Ai<
4204
+ AiModelList extends AiModelListType = AiModels,
4205
+ > {
4206
+ aiGatewayLogId: string | null;
4207
+ gateway(gatewayId: string): AiGateway;
4208
+ run<Name extends keyof AiModelList>(
4209
+ model: Name,
4210
+ inputs: AiModelList[Name]["inputs"],
4211
+ options?: AiOptions,
4212
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
4213
+ public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
4214
+ }
3526
4215
  export type GatewayOptions = {
3527
4216
  id: string;
4217
+ cacheKey?: string;
3528
4218
  cacheTtl?: number;
3529
4219
  skipCache?: boolean;
3530
4220
  metadata?: Record<string, number | string | boolean | null | bigint>;
4221
+ collectLog?: boolean;
3531
4222
  };
3532
- export type AiOptions = {
3533
- gateway?: GatewayOptions;
3534
- prefix?: string;
3535
- extraHeaders?: object;
4223
+ export type AiGatewayPatchLog = {
4224
+ score?: number | null;
4225
+ feedback?: -1 | 1 | null;
4226
+ metadata?: Record<string, number | string | boolean | null | bigint> | null;
3536
4227
  };
3537
- export type BaseAiTextClassificationModels =
3538
- "@cf/huggingface/distilbert-sst-2-int8";
3539
- export type BaseAiTextToImageModels =
3540
- | "@cf/stabilityai/stable-diffusion-xl-base-1.0"
3541
- | "@cf/runwayml/stable-diffusion-v1-5-inpainting"
3542
- | "@cf/runwayml/stable-diffusion-v1-5-img2img"
3543
- | "@cf/lykon/dreamshaper-8-lcm"
3544
- | "@cf/bytedance/stable-diffusion-xl-lightning";
3545
- export type BaseAiTextEmbeddingsModels =
3546
- | "@cf/baai/bge-small-en-v1.5"
3547
- | "@cf/baai/bge-base-en-v1.5"
3548
- | "@cf/baai/bge-large-en-v1.5";
3549
- export type BaseAiSpeechRecognitionModels =
3550
- | "@cf/openai/whisper"
3551
- | "@cf/openai/whisper-tiny-en"
3552
- | "@cf/openai/whisper-sherpa";
3553
- export type BaseAiImageClassificationModels = "@cf/microsoft/resnet-50";
3554
- export type BaseAiObjectDetectionModels = "@cf/facebook/detr-resnet-50";
3555
- export type BaseAiTextGenerationModels =
3556
- | "@cf/meta/llama-3-8b-instruct"
3557
- | "@cf/meta/llama-3-8b-instruct-awq"
3558
- | "@cf/meta/llama-2-7b-chat-int8"
3559
- | "@cf/mistral/mistral-7b-instruct-v0.1"
3560
- | "@cf/mistral/mistral-7b-instruct-v0.2-lora"
3561
- | "@cf/meta/llama-2-7b-chat-fp16"
3562
- | "@hf/thebloke/llama-2-13b-chat-awq"
3563
- | "@hf/thebloke/zephyr-7b-beta-awq"
3564
- | "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
3565
- | "@hf/thebloke/codellama-7b-instruct-awq"
3566
- | "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
3567
- | "@hf/thebloke/neural-chat-7b-v3-1-awq"
3568
- | "@hf/thebloke/llamaguard-7b-awq"
3569
- | "@hf/thebloke/deepseek-coder-6.7b-base-awq"
3570
- | "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
3571
- | "@hf/nousresearch/hermes-2-pro-mistral-7b"
3572
- | "@hf/mistral/mistral-7b-instruct-v0.2"
3573
- | "@hf/google/gemma-7b-it"
3574
- | "@hf/nexusflow/starling-lm-7b-beta"
3575
- | "@cf/deepseek-ai/deepseek-math-7b-instruct"
3576
- | "@cf/defog/sqlcoder-7b-2"
3577
- | "@cf/openchat/openchat-3.5-0106"
3578
- | "@cf/tiiuae/falcon-7b-instruct"
3579
- | "@cf/thebloke/discolm-german-7b-v1-awq"
3580
- | "@cf/qwen/qwen1.5-0.5b-chat"
3581
- | "@cf/qwen/qwen1.5-1.8b-chat"
3582
- | "@cf/qwen/qwen1.5-7b-chat-awq"
3583
- | "@cf/qwen/qwen1.5-14b-chat-awq"
3584
- | "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
3585
- | "@cf/microsoft/phi-2"
3586
- | "@cf/google/gemma-2b-it-lora"
3587
- | "@cf/google/gemma-7b-it-lora"
3588
- | "@cf/meta-llama/llama-2-7b-chat-hf-lora"
3589
- | "@cf/fblgit/una-cybertron-7b-v2-bf16"
3590
- | "@cf/fblgit/una-cybertron-7b-v2-awq";
3591
- export type BaseAiTranslationModels = "@cf/meta/m2m100-1.2b";
3592
- export type BaseAiSummarizationModels = "@cf/facebook/bart-large-cnn";
3593
- export type BaseAiImageToTextModels =
3594
- | "@cf/unum/uform-gen2-qwen-500m"
3595
- | "@cf/llava-hf/llava-1.5-7b-hf";
3596
- export declare abstract class Ai {
3597
- run(
3598
- model: BaseAiTextClassificationModels,
3599
- inputs: BaseAiTextClassification["inputs"],
3600
- options?: AiOptions,
3601
- ): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
3602
- run(
3603
- model: BaseAiTextToImageModels,
3604
- inputs: BaseAiTextToImage["inputs"],
3605
- options?: AiOptions,
3606
- ): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
3607
- run(
3608
- model: BaseAiTextEmbeddingsModels,
3609
- inputs: BaseAiTextEmbeddings["inputs"],
3610
- options?: AiOptions,
3611
- ): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
3612
- run(
3613
- model: BaseAiSpeechRecognitionModels,
3614
- inputs: BaseAiSpeechRecognition["inputs"],
3615
- options?: AiOptions,
3616
- ): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
3617
- run(
3618
- model: BaseAiImageClassificationModels,
3619
- inputs: BaseAiImageClassification["inputs"],
3620
- options?: AiOptions,
3621
- ): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
3622
- run(
3623
- model: BaseAiObjectDetectionModels,
3624
- inputs: BaseAiObjectDetection["inputs"],
3625
- options?: AiOptions,
3626
- ): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
3627
- run(
3628
- model: BaseAiTextGenerationModels,
3629
- inputs: BaseAiTextGeneration["inputs"],
3630
- options?: AiOptions,
3631
- ): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
3632
- run(
3633
- model: BaseAiTranslationModels,
3634
- inputs: BaseAiTranslation["inputs"],
3635
- options?: AiOptions,
3636
- ): Promise<BaseAiTranslation["postProcessedOutputs"]>;
3637
- run(
3638
- model: BaseAiSummarizationModels,
3639
- inputs: BaseAiSummarization["inputs"],
3640
- options?: AiOptions,
3641
- ): Promise<BaseAiSummarization["postProcessedOutputs"]>;
4228
+ export type AiGatewayLog = {
4229
+ id: string;
4230
+ provider: string;
4231
+ model: string;
4232
+ model_type?: string;
4233
+ path: string;
4234
+ duration: number;
4235
+ request_type?: string;
4236
+ request_content_type?: string;
4237
+ status_code: number;
4238
+ response_content_type?: string;
4239
+ success: boolean;
4240
+ cached: boolean;
4241
+ tokens_in?: number;
4242
+ tokens_out?: number;
4243
+ metadata?: Record<string, number | string | boolean | null | bigint>;
4244
+ step?: number;
4245
+ cost?: number;
4246
+ custom_cost?: boolean;
4247
+ request_size: number;
4248
+ request_head?: string;
4249
+ request_head_complete: boolean;
4250
+ response_size: number;
4251
+ response_head?: string;
4252
+ response_head_complete: boolean;
4253
+ created_at: Date;
4254
+ };
4255
+ export type AIGatewayProviders =
4256
+ | "workers-ai"
4257
+ | "anthropic"
4258
+ | "aws-bedrock"
4259
+ | "azure-openai"
4260
+ | "google-vertex-ai"
4261
+ | "huggingface"
4262
+ | "openai"
4263
+ | "perplexity-ai"
4264
+ | "replicate"
4265
+ | "groq"
4266
+ | "cohere"
4267
+ | "google-ai-studio"
4268
+ | "mistral"
4269
+ | "grok"
4270
+ | "openrouter";
4271
+ export type AIGatewayHeaders = {
4272
+ "cf-aig-metadata":
4273
+ | Record<string, number | string | boolean | null | bigint>
4274
+ | string;
4275
+ "cf-aig-custom-cost":
4276
+ | {
4277
+ per_token_in?: number;
4278
+ per_token_out?: number;
4279
+ }
4280
+ | {
4281
+ total_cost?: number;
4282
+ }
4283
+ | string;
4284
+ "cf-aig-cache-ttl": number | string;
4285
+ "cf-aig-skip-cache": boolean | string;
4286
+ "cf-aig-cache-key": string;
4287
+ "cf-aig-collect-log": boolean | string;
4288
+ Authorization: string;
4289
+ "Content-Type": string;
4290
+ [key: string]: string | number | boolean | object;
4291
+ };
4292
+ export type AIGatewayUniversalRequest = {
4293
+ provider: AIGatewayProviders | string; // eslint-disable-line
4294
+ endpoint: string;
4295
+ headers: Partial<AIGatewayHeaders>;
4296
+ query: unknown;
4297
+ };
4298
+ export interface AiGatewayInternalError extends Error {}
4299
+ export interface AiGatewayLogNotFound extends Error {}
4300
+ export declare abstract class AiGateway {
4301
+ patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
4302
+ getLog(logId: string): Promise<AiGatewayLog>;
3642
4303
  run(
3643
- model: BaseAiImageToTextModels,
3644
- inputs: BaseAiImageToText["inputs"],
3645
- options?: AiOptions,
3646
- ): Promise<BaseAiImageToText["postProcessedOutputs"]>;
4304
+ data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
4305
+ ): Promise<Response>;
3647
4306
  }
3648
4307
  export interface BasicImageTransformations {
3649
4308
  /**
@@ -4661,7 +5320,7 @@ export declare abstract class D1PreparedStatement {
4661
5320
  bind(...values: unknown[]): D1PreparedStatement;
4662
5321
  first<T = unknown>(colName: string): Promise<T | null>;
4663
5322
  first<T = Record<string, unknown>>(): Promise<T | null>;
4664
- run(): Promise<D1Response>;
5323
+ run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4665
5324
  all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4666
5325
  raw<T = unknown[]>(options: {
4667
5326
  columnNames: true;
@@ -4717,6 +5376,12 @@ export interface ForwardableEmailMessage extends EmailMessage {
4717
5376
  * @returns A promise that resolves when the email message is forwarded.
4718
5377
  */
4719
5378
  forward(rcptTo: string, headers?: Headers): Promise<void>;
5379
+ /**
5380
+ * Reply to the sender of this email message with a new EmailMessage object.
5381
+ * @param message The reply message.
5382
+ * @returns A promise that resolves when the email message is replied.
5383
+ */
5384
+ reply(message: EmailMessage): Promise<void>;
4720
5385
  }
4721
5386
  /**
4722
5387
  * A binding that allows a Worker to send email messages.
@@ -4779,6 +5444,128 @@ export interface Hyperdrive {
4779
5444
  */
4780
5445
  readonly database: string;
4781
5446
  }
5447
+ // Copyright (c) 2024 Cloudflare, Inc.
5448
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5449
+ // https://opensource.org/licenses/Apache-2.0
5450
+ export type ImageInfoResponse =
5451
+ | {
5452
+ format: "image/svg+xml";
5453
+ }
5454
+ | {
5455
+ format: string;
5456
+ fileSize: number;
5457
+ width: number;
5458
+ height: number;
5459
+ };
5460
+ export type ImageTransform = {
5461
+ fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
5462
+ gravity?:
5463
+ | "left"
5464
+ | "right"
5465
+ | "top"
5466
+ | "bottom"
5467
+ | "center"
5468
+ | "auto"
5469
+ | "entropy"
5470
+ | "face"
5471
+ | {
5472
+ x?: number;
5473
+ y?: number;
5474
+ mode: "remainder" | "box-center";
5475
+ };
5476
+ trim?: {
5477
+ top?: number;
5478
+ bottom?: number;
5479
+ left?: number;
5480
+ right?: number;
5481
+ width?: number;
5482
+ height?: number;
5483
+ border?:
5484
+ | boolean
5485
+ | {
5486
+ color?: string;
5487
+ tolerance?: number;
5488
+ keep?: number;
5489
+ };
5490
+ };
5491
+ width?: number;
5492
+ height?: number;
5493
+ background?: string;
5494
+ rotate?: number;
5495
+ sharpen?: number;
5496
+ blur?: number;
5497
+ contrast?: number;
5498
+ brightness?: number;
5499
+ gamma?: number;
5500
+ border?: {
5501
+ color?: string;
5502
+ width?: number;
5503
+ top?: number;
5504
+ bottom?: number;
5505
+ left?: number;
5506
+ right?: number;
5507
+ };
5508
+ zoom?: number;
5509
+ };
5510
+ export type ImageOutputOptions = {
5511
+ format:
5512
+ | "image/jpeg"
5513
+ | "image/png"
5514
+ | "image/gif"
5515
+ | "image/webp"
5516
+ | "image/avif"
5517
+ | "rgb"
5518
+ | "rgba";
5519
+ quality?: number;
5520
+ background?: string;
5521
+ };
5522
+ export interface ImagesBinding {
5523
+ /**
5524
+ * Get image metadata (type, width and height)
5525
+ * @throws {@link ImagesError} with code 9412 if input is not an image
5526
+ * @param stream The image bytes
5527
+ */
5528
+ info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
5529
+ /**
5530
+ * Begin applying a series of transformations to an image
5531
+ * @param stream The image bytes
5532
+ * @returns A transform handle
5533
+ */
5534
+ input(stream: ReadableStream<Uint8Array>): ImageTransformer;
5535
+ }
5536
+ export interface ImageTransformer {
5537
+ /**
5538
+ * Apply transform next, returning a transform handle.
5539
+ * You can then apply more transformations or retrieve the output.
5540
+ * @param transform
5541
+ */
5542
+ transform(transform: ImageTransform): ImageTransformer;
5543
+ /**
5544
+ * Retrieve the image that results from applying the transforms to the
5545
+ * provided input
5546
+ * @param options Options that apply to the output e.g. output format
5547
+ */
5548
+ output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
5549
+ }
5550
+ export interface ImageTransformationResult {
5551
+ /**
5552
+ * The image as a response, ready to store in cache or return to users
5553
+ */
5554
+ response(): Response;
5555
+ /**
5556
+ * The content type of the returned image
5557
+ */
5558
+ contentType(): string;
5559
+ /**
5560
+ * The bytes of the response
5561
+ */
5562
+ image(): ReadableStream<Uint8Array>;
5563
+ }
5564
+ export interface ImagesError extends Error {
5565
+ readonly code: number;
5566
+ readonly message: string;
5567
+ readonly stack?: string;
5568
+ }
4782
5569
  export type Params<P extends string = any> = Record<P, string | string[]>;
4783
5570
  export type EventContext<Env, P extends string, Data> = {
4784
5571
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -4822,6 +5609,30 @@ export type PagesPluginFunction<
4822
5609
  > = (
4823
5610
  context: EventPluginContext<Env, Params, Data, PluginArgs>,
4824
5611
  ) => Response | Promise<Response>;
5612
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5613
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5614
+ // https://opensource.org/licenses/Apache-2.0
5615
+ export declare abstract class PipelineTransform {
5616
+ /**
5617
+ * transformJson recieves an array of javascript objects which can be
5618
+ * mutated and returned to the pipeline
5619
+ * @param data The data to be mutated
5620
+ * @returns A promise containing the mutated data
5621
+ */
5622
+ public transformJson(data: object[]): Promise<object[]>;
5623
+ }
5624
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5625
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5626
+ // https://opensource.org/licenses/Apache-2.0
5627
+ export interface Pipeline {
5628
+ /**
5629
+ * send takes an array of javascript objects which are
5630
+ * then received by the pipeline for processing
5631
+ *
5632
+ * @param data The data to be sent
5633
+ */
5634
+ send(data: object[]): Promise<void>;
5635
+ }
4825
5636
  // PubSubMessage represents an incoming PubSub message.
4826
5637
  // The message includes metadata about the broker, the client, and the payload
4827
5638
  // itself.
@@ -4882,6 +5693,7 @@ export declare namespace Rpc {
4882
5693
  export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
4883
5694
  export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
4884
5695
  export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
5696
+ export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
4885
5697
  export interface RpcTargetBranded {
4886
5698
  [__RPC_TARGET_BRAND]: never;
4887
5699
  }
@@ -4891,13 +5703,20 @@ export declare namespace Rpc {
4891
5703
  export interface DurableObjectBranded {
4892
5704
  [__DURABLE_OBJECT_BRAND]: never;
4893
5705
  }
5706
+ export interface WorkflowEntrypointBranded {
5707
+ [__WORKFLOW_ENTRYPOINT_BRAND]: never;
5708
+ }
4894
5709
  export type EntrypointBranded =
4895
5710
  | WorkerEntrypointBranded
4896
- | DurableObjectBranded;
5711
+ | DurableObjectBranded
5712
+ | WorkflowEntrypointBranded;
4897
5713
  // Types that can be used through `Stub`s
4898
5714
  export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
4899
5715
  // Types that can be passed over RPC
4900
- type Serializable =
5716
+ // The reason for using a generic type here is to build a serializable subset of structured
5717
+ // cloneable composite types. This allows types defined with the "interface" keyword to pass the
5718
+ // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
5719
+ type Serializable<T> =
4901
5720
  // Structured cloneables
4902
5721
  | void
4903
5722
  | undefined
@@ -4913,11 +5732,14 @@ export declare namespace Rpc {
4913
5732
  | Error
4914
5733
  | RegExp
4915
5734
  // Structured cloneable composites
4916
- | Map<Serializable, Serializable>
4917
- | Set<Serializable>
4918
- | ReadonlyArray<Serializable>
5735
+ | Map<
5736
+ T extends Map<infer U, unknown> ? Serializable<U> : never,
5737
+ T extends Map<unknown, infer U> ? Serializable<U> : never
5738
+ >
5739
+ | Set<T extends Set<infer U> ? Serializable<U> : never>
5740
+ | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
4919
5741
  | {
4920
- [key: string | number]: Serializable;
5742
+ [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
4921
5743
  }
4922
5744
  // Special types
4923
5745
  | ReadableStream<Uint8Array>
@@ -4947,7 +5769,7 @@ export declare namespace Rpc {
4947
5769
  : T extends ReadonlyArray<infer V>
4948
5770
  ? ReadonlyArray<Stubify<V>>
4949
5771
  : T extends {
4950
- [key: string | number]: unknown;
5772
+ [key: string | number]: any;
4951
5773
  }
4952
5774
  ? {
4953
5775
  [K in keyof T]: Stubify<T[K]>;
@@ -4990,7 +5812,7 @@ export declare namespace Rpc {
4990
5812
  // Intersecting with `(Maybe)Provider` allows pipelining.
4991
5813
  type Result<R> = R extends Stubable
4992
5814
  ? Promise<Stub<R>> & Provider<R>
4993
- : R extends Serializable
5815
+ : R extends Serializable<R>
4994
5816
  ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
4995
5817
  : never;
4996
5818
  // Type for method or property on an RPC interface.
@@ -5019,6 +5841,198 @@ export declare namespace Rpc {
5019
5841
  >]: MethodOrProperty<T[K]>;
5020
5842
  };
5021
5843
  }
5844
+ export declare namespace TailStream {
5845
+ interface Header {
5846
+ readonly name: string;
5847
+ readonly value: string;
5848
+ }
5849
+ interface FetchEventInfo {
5850
+ readonly type: "fetch";
5851
+ readonly method: string;
5852
+ readonly url: string;
5853
+ readonly cfJson: string;
5854
+ readonly headers: Header[];
5855
+ }
5856
+ interface JsRpcEventInfo {
5857
+ readonly type: "jsrpc";
5858
+ readonly methodName: string;
5859
+ }
5860
+ interface ScheduledEventInfo {
5861
+ readonly type: "scheduled";
5862
+ readonly scheduledTime: Date;
5863
+ readonly cron: string;
5864
+ }
5865
+ interface AlarmEventInfo {
5866
+ readonly type: "alarm";
5867
+ readonly scheduledTime: Date;
5868
+ }
5869
+ interface QueueEventInfo {
5870
+ readonly type: "queue";
5871
+ readonly queueName: string;
5872
+ readonly batchSize: number;
5873
+ }
5874
+ interface EmailEventInfo {
5875
+ readonly type: "email";
5876
+ readonly mailFrom: string;
5877
+ readonly rcptTo: string;
5878
+ readonly rawSize: number;
5879
+ }
5880
+ interface TraceEventInfo {
5881
+ readonly type: "trace";
5882
+ readonly traces: (string | null)[];
5883
+ }
5884
+ interface HibernatableWebSocketEventInfoMessage {
5885
+ readonly type: "message";
5886
+ }
5887
+ interface HibernatableWebSocketEventInfoError {
5888
+ readonly type: "error";
5889
+ }
5890
+ interface HibernatableWebSocketEventInfoClose {
5891
+ readonly type: "close";
5892
+ readonly code: number;
5893
+ readonly wasClean: boolean;
5894
+ }
5895
+ interface HibernatableWebSocketEventInfo {
5896
+ readonly type: "hibernatableWebSocket";
5897
+ readonly info:
5898
+ | HibernatableWebSocketEventInfoClose
5899
+ | HibernatableWebSocketEventInfoError
5900
+ | HibernatableWebSocketEventInfoMessage;
5901
+ }
5902
+ interface Resume {
5903
+ readonly type: "resume";
5904
+ readonly attachment?: any;
5905
+ }
5906
+ interface CustomEventInfo {
5907
+ readonly type: "custom";
5908
+ }
5909
+ interface FetchResponseInfo {
5910
+ readonly type: "fetch";
5911
+ readonly statusCode: number;
5912
+ }
5913
+ type EventOutcome =
5914
+ | "ok"
5915
+ | "canceled"
5916
+ | "exception"
5917
+ | "unknown"
5918
+ | "killSwitch"
5919
+ | "daemonDown"
5920
+ | "exceededCpu"
5921
+ | "exceededMemory"
5922
+ | "loadShed"
5923
+ | "responseStreamDisconnected"
5924
+ | "scriptNotFound";
5925
+ interface ScriptVersion {
5926
+ readonly id: string;
5927
+ readonly tag?: string;
5928
+ readonly message?: string;
5929
+ }
5930
+ interface Trigger {
5931
+ readonly traceId: string;
5932
+ readonly invocationId: string;
5933
+ readonly spanId: string;
5934
+ }
5935
+ interface Onset {
5936
+ readonly type: "onset";
5937
+ readonly dispatchNamespace?: string;
5938
+ readonly entrypoint?: string;
5939
+ readonly scriptName?: string;
5940
+ readonly scriptTags?: string[];
5941
+ readonly scriptVersion?: ScriptVersion;
5942
+ readonly trigger?: Trigger;
5943
+ readonly info:
5944
+ | FetchEventInfo
5945
+ | JsRpcEventInfo
5946
+ | ScheduledEventInfo
5947
+ | AlarmEventInfo
5948
+ | QueueEventInfo
5949
+ | EmailEventInfo
5950
+ | TraceEventInfo
5951
+ | HibernatableWebSocketEventInfo
5952
+ | Resume
5953
+ | CustomEventInfo;
5954
+ }
5955
+ interface Outcome {
5956
+ readonly type: "outcome";
5957
+ readonly outcome: EventOutcome;
5958
+ readonly cpuTime: number;
5959
+ readonly wallTime: number;
5960
+ }
5961
+ interface Hibernate {
5962
+ readonly type: "hibernate";
5963
+ }
5964
+ interface SpanOpen {
5965
+ readonly type: "spanOpen";
5966
+ readonly op?: string;
5967
+ readonly info?: FetchEventInfo | JsRpcEventInfo | Attribute[];
5968
+ }
5969
+ interface SpanClose {
5970
+ readonly type: "spanClose";
5971
+ readonly outcome: EventOutcome;
5972
+ }
5973
+ interface DiagnosticChannelEvent {
5974
+ readonly type: "diagnosticChannel";
5975
+ readonly channel: string;
5976
+ readonly message: any;
5977
+ }
5978
+ interface Exception {
5979
+ readonly type: "exception";
5980
+ readonly name: string;
5981
+ readonly message: string;
5982
+ readonly stack?: string;
5983
+ }
5984
+ interface Log {
5985
+ readonly type: "log";
5986
+ readonly level: "debug" | "error" | "info" | "log" | "warn";
5987
+ readonly message: string;
5988
+ }
5989
+ interface Return {
5990
+ readonly type: "return";
5991
+ readonly info?: FetchResponseInfo | Attribute[];
5992
+ }
5993
+ interface Link {
5994
+ readonly type: "link";
5995
+ readonly label?: string;
5996
+ readonly traceId: string;
5997
+ readonly invocationId: string;
5998
+ readonly spanId: string;
5999
+ }
6000
+ interface Attribute {
6001
+ readonly type: "attribute";
6002
+ readonly name: string;
6003
+ readonly value: string | string[] | boolean | boolean[] | number | number[];
6004
+ }
6005
+ type Mark =
6006
+ | DiagnosticChannelEvent
6007
+ | Exception
6008
+ | Log
6009
+ | Return
6010
+ | Link
6011
+ | Attribute[];
6012
+ interface TailEvent {
6013
+ readonly traceId: string;
6014
+ readonly invocationId: string;
6015
+ readonly spanId: string;
6016
+ readonly timestamp: Date;
6017
+ readonly sequence: number;
6018
+ readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | Mark;
6019
+ }
6020
+ type TailEventHandler = (event: TailEvent) => void | Promise<void>;
6021
+ type TailEventHandlerName =
6022
+ | "onset"
6023
+ | "outcome"
6024
+ | "hibernate"
6025
+ | "spanOpen"
6026
+ | "spanClose"
6027
+ | "diagnosticChannel"
6028
+ | "exception"
6029
+ | "log"
6030
+ | "return"
6031
+ | "link"
6032
+ | "attribute";
6033
+ type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
6034
+ type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
6035
+ }
5022
6036
  // Copyright (c) 2022-2023 Cloudflare, Inc.
5023
6037
  // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5024
6038
  // https://opensource.org/licenses/Apache-2.0
@@ -5062,11 +6076,21 @@ export type VectorizeVectorMetadataFilter = {
5062
6076
  * Distance metrics determine how other "similar" vectors are determined.
5063
6077
  */
5064
6078
  export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
6079
+ /**
6080
+ * Metadata return levels for a Vectorize query.
6081
+ *
6082
+ * Default to "none".
6083
+ *
6084
+ * @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.
6085
+ * @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).
6086
+ * @property none No indexed metadata will be returned.
6087
+ */
6088
+ export type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
5065
6089
  export interface VectorizeQueryOptions {
5066
6090
  topK?: number;
5067
6091
  namespace?: string;
5068
6092
  returnValues?: boolean;
5069
- returnMetadata?: boolean;
6093
+ returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
5070
6094
  filter?: VectorizeVectorMetadataFilter;
5071
6095
  }
5072
6096
  /**
@@ -5082,6 +6106,9 @@ export type VectorizeIndexConfig =
5082
6106
  };
5083
6107
  /**
5084
6108
  * Metadata about an existing index.
6109
+ *
6110
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6111
+ * See {@link VectorizeIndexInfo} for its post-beta equivalent.
5085
6112
  */
5086
6113
  export interface VectorizeIndexDetails {
5087
6114
  /** The unique ID of the index */
@@ -5095,6 +6122,19 @@ export interface VectorizeIndexDetails {
5095
6122
  /** The number of records containing vectors within the index. */
5096
6123
  vectorsCount: number;
5097
6124
  }
6125
+ /**
6126
+ * Metadata about an existing index.
6127
+ */
6128
+ export interface VectorizeIndexInfo {
6129
+ /** The number of records containing vectors within the index. */
6130
+ vectorCount: number;
6131
+ /** Number of dimensions the index has been configured for. */
6132
+ dimensions: number;
6133
+ /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
6134
+ processedUpToDatetime: number;
6135
+ /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
6136
+ processedUpToMutation: number;
6137
+ }
5098
6138
  /**
5099
6139
  * Represents a single vector value set along with its associated metadata.
5100
6140
  */
@@ -5105,7 +6145,7 @@ export interface VectorizeVector {
5105
6145
  values: VectorFloatArray | number[];
5106
6146
  /** The namespace this vector belongs to. */
5107
6147
  namespace?: string;
5108
- /** Metadata associated with the vector. Includes the values of the other fields and potentially additional details. */
6148
+ /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
5109
6149
  metadata?: Record<string, VectorizeVectorMetadata>;
5110
6150
  }
5111
6151
  /**
@@ -5117,7 +6157,7 @@ export type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
5117
6157
  score: number;
5118
6158
  };
5119
6159
  /**
5120
- * A set of vector {@link VectorizeMatch} for a particular query.
6160
+ * A set of matching {@link VectorizeMatch} for a particular query.
5121
6161
  */
5122
6162
  export interface VectorizeMatches {
5123
6163
  matches: VectorizeMatch[];
@@ -5126,6 +6166,9 @@ export interface VectorizeMatches {
5126
6166
  /**
5127
6167
  * Results of an operation that performed a mutation on a set of vectors.
5128
6168
  * Here, `ids` is a list of vectors that were successfully processed.
6169
+ *
6170
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6171
+ * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
5129
6172
  */
5130
6173
  export interface VectorizeVectorMutation {
5131
6174
  /* List of ids of vectors that were successfully processed. */
@@ -5134,14 +6177,19 @@ export interface VectorizeVectorMutation {
5134
6177
  count: number;
5135
6178
  }
5136
6179
  /**
5137
- * Results of an operation that performed a mutation on a set of vectors
5138
- * with the v2 version of Vectorize.
5139
- * Here, `mutationId` is the identifier for the last mutation processed by Vectorize.
6180
+ * Result type indicating a mutation on the Vectorize Index.
6181
+ * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
5140
6182
  */
5141
- export interface VectorizeVectorMutationV2 {
5142
- /* The identifier for the last mutation processed by Vectorize. */
6183
+ export interface VectorizeAsyncMutation {
6184
+ /** The unique identifier for the async mutation operation containing the changeset. */
5143
6185
  mutationId: string;
5144
6186
  }
6187
+ /**
6188
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6189
+ *
6190
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6191
+ * See {@link Vectorize} for its new implementation.
6192
+ */
5145
6193
  export declare abstract class VectorizeIndex {
5146
6194
  /**
5147
6195
  * Get information about the currently bound index.
@@ -5156,7 +6204,7 @@ export declare abstract class VectorizeIndex {
5156
6204
  */
5157
6205
  public query(
5158
6206
  vector: VectorFloatArray | number[],
5159
- options: VectorizeQueryOptions,
6207
+ options?: VectorizeQueryOptions,
5160
6208
  ): Promise<VectorizeMatches>;
5161
6209
  /**
5162
6210
  * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
@@ -5183,6 +6231,62 @@ export declare abstract class VectorizeIndex {
5183
6231
  */
5184
6232
  public getByIds(ids: string[]): Promise<VectorizeVector[]>;
5185
6233
  }
6234
+ /**
6235
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6236
+ *
6237
+ * Mutations in this version are async, returning a mutation id.
6238
+ */
6239
+ export declare abstract class Vectorize {
6240
+ /**
6241
+ * Get information about the currently bound index.
6242
+ * @returns A promise that resolves with information about the current index.
6243
+ */
6244
+ public describe(): Promise<VectorizeIndexInfo>;
6245
+ /**
6246
+ * Use the provided vector to perform a similarity search across the index.
6247
+ * @param vector Input vector that will be used to drive the similarity search.
6248
+ * @param options Configuration options to massage the returned data.
6249
+ * @returns A promise that resolves with matched and scored vectors.
6250
+ */
6251
+ public query(
6252
+ vector: VectorFloatArray | number[],
6253
+ options?: VectorizeQueryOptions,
6254
+ ): Promise<VectorizeMatches>;
6255
+ /**
6256
+ * Use the provided vector-id to perform a similarity search across the index.
6257
+ * @param vectorId Id for a vector in the index against which the index should be queried.
6258
+ * @param options Configuration options to massage the returned data.
6259
+ * @returns A promise that resolves with matched and scored vectors.
6260
+ */
6261
+ public queryById(
6262
+ vectorId: string,
6263
+ options?: VectorizeQueryOptions,
6264
+ ): Promise<VectorizeMatches>;
6265
+ /**
6266
+ * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
6267
+ * @param vectors List of vectors that will be inserted.
6268
+ * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
6269
+ */
6270
+ public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6271
+ /**
6272
+ * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
6273
+ * @param vectors List of vectors that will be upserted.
6274
+ * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
6275
+ */
6276
+ public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6277
+ /**
6278
+ * Delete a list of vectors with a matching id.
6279
+ * @param ids List of vector ids that should be deleted.
6280
+ * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
6281
+ */
6282
+ public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
6283
+ /**
6284
+ * Get a list of vectors with a matching id.
6285
+ * @param ids List of vector ids that should be returned.
6286
+ * @returns A promise that resolves with the raw unscored vectors matching the id set.
6287
+ */
6288
+ public getByIds(ids: string[]): Promise<VectorizeVector[]>;
6289
+ }
5186
6290
  /**
5187
6291
  * The interface for "version_metadata" binding
5188
6292
  * providing metadata about the Worker Version using this binding.
@@ -5233,3 +6337,70 @@ export interface DispatchNamespace {
5233
6337
  options?: DynamicDispatchOptions,
5234
6338
  ): Fetcher;
5235
6339
  }
6340
+ export declare abstract class Workflow<PARAMS = unknown> {
6341
+ /**
6342
+ * Get a handle to an existing instance of the Workflow.
6343
+ * @param id Id for the instance of this Workflow
6344
+ * @returns A promise that resolves with a handle for the Instance
6345
+ */
6346
+ public get(id: string): Promise<WorkflowInstance>;
6347
+ /**
6348
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
6349
+ * @param options Options when creating an instance including id and params
6350
+ * @returns A promise that resolves with a handle for the Instance
6351
+ */
6352
+ public create(
6353
+ options?: WorkflowInstanceCreateOptions<PARAMS>,
6354
+ ): Promise<WorkflowInstance>;
6355
+ }
6356
+ export interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
6357
+ /**
6358
+ * An id for your Workflow instance. Must be unique within the Workflow.
6359
+ */
6360
+ id?: string;
6361
+ /**
6362
+ * The event payload the Workflow instance is triggered with
6363
+ */
6364
+ params?: PARAMS;
6365
+ }
6366
+ export type InstanceStatus = {
6367
+ status:
6368
+ | "queued" // means that instance is waiting to be started (see concurrency limits)
6369
+ | "running"
6370
+ | "paused"
6371
+ | "errored"
6372
+ | "terminated" // user terminated the instance while it was running
6373
+ | "complete"
6374
+ | "waiting" // instance is hibernating and waiting for sleep or event to finish
6375
+ | "waitingForPause" // instance is finishing the current work to pause
6376
+ | "unknown";
6377
+ error?: string;
6378
+ output?: object;
6379
+ };
6380
+ export interface WorkflowError {
6381
+ code?: number;
6382
+ message: string;
6383
+ }
6384
+ export declare abstract class WorkflowInstance {
6385
+ public id: string;
6386
+ /**
6387
+ * Pause the instance.
6388
+ */
6389
+ public pause(): Promise<void>;
6390
+ /**
6391
+ * Resume the instance. If it is already running, an error will be thrown.
6392
+ */
6393
+ public resume(): Promise<void>;
6394
+ /**
6395
+ * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
6396
+ */
6397
+ public terminate(): Promise<void>;
6398
+ /**
6399
+ * Restart the instance.
6400
+ */
6401
+ public restart(): Promise<void>;
6402
+ /**
6403
+ * Returns the current status of the instance.
6404
+ */
6405
+ public status(): Promise<InstanceStatus>;
6406
+ }