@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;
@@ -361,7 +363,7 @@ export declare function structuredClone<T>(
361
363
  export declare function reportError(error: any): void;
362
364
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
363
365
  export declare function fetch(
364
- input: RequestInfo,
366
+ input: RequestInfo | URL,
365
367
  init?: RequestInit<RequestInitCfProperties>,
366
368
  ): Promise<Response>;
367
369
  export declare const self: ServiceWorkerGlobalScope;
@@ -388,12 +390,14 @@ export declare const scheduler: Scheduler;
388
390
  * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
389
391
  */
390
392
  export declare const performance: Performance;
393
+ export declare const Cloudflare: Cloudflare;
391
394
  export declare const origin: string;
392
395
  export declare const navigator: Navigator;
393
396
  export interface TestController {}
394
397
  export interface ExecutionContext {
395
398
  waitUntil(promise: Promise<any>): void;
396
399
  passThroughOnException(): void;
400
+ props: any;
397
401
  }
398
402
  export type ExportedHandlerFetchHandler<
399
403
  Env = unknown,
@@ -413,6 +417,11 @@ export type ExportedHandlerTraceHandler<Env = unknown> = (
413
417
  env: Env,
414
418
  ctx: ExecutionContext,
415
419
  ) => void | Promise<void>;
420
+ export type ExportedHandlerTailStreamHandler<Env = unknown> = (
421
+ event: TailStream.TailEvent,
422
+ env: Env,
423
+ ctx: ExecutionContext,
424
+ ) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
416
425
  export type ExportedHandlerScheduledHandler<Env = unknown> = (
417
426
  controller: ScheduledController,
418
427
  env: Env,
@@ -436,6 +445,7 @@ export interface ExportedHandler<
436
445
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
437
446
  tail?: ExportedHandlerTailHandler<Env>;
438
447
  trace?: ExportedHandlerTraceHandler<Env>;
448
+ tailStream?: ExportedHandlerTailStreamHandler<Env>;
439
449
  scheduled?: ExportedHandlerScheduledHandler<Env>;
440
450
  test?: ExportedHandlerTestHandler<Env>;
441
451
  email?: EmailExportedHandler<Env>;
@@ -459,8 +469,9 @@ export declare abstract class Navigator {
459
469
  | string
460
470
  | (ArrayBuffer | ArrayBufferView)
461
471
  | Blob
472
+ | FormData
462
473
  | URLSearchParams
463
- | FormData,
474
+ | URLSearchParams,
464
475
  ): boolean;
465
476
  readonly userAgent: string;
466
477
  readonly gpu: GPU;
@@ -481,9 +492,12 @@ export interface AlarmInvocationInfo {
481
492
  readonly isRetry: boolean;
482
493
  readonly retryCount: number;
483
494
  }
495
+ export interface Cloudflare {
496
+ readonly compatibilityFlags: Record<string, boolean>;
497
+ }
484
498
  export interface DurableObject {
485
499
  fetch(request: Request): Response | Promise<Response>;
486
- alarm?(): void | Promise<void>;
500
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
487
501
  webSocketMessage?(
488
502
  ws: WebSocket,
489
503
  message: string | ArrayBuffer,
@@ -556,6 +570,7 @@ export interface DurableObjectState {
556
570
  setHibernatableWebSocketEventTimeout(timeoutMs?: number): void;
557
571
  getHibernatableWebSocketEventTimeout(): number | null;
558
572
  getTags(ws: WebSocket): string[];
573
+ abort(reason?: string): void;
559
574
  }
560
575
  export interface DurableObjectTransaction {
561
576
  get<T = unknown>(
@@ -622,7 +637,11 @@ export interface DurableObjectStorage {
622
637
  ): Promise<void>;
623
638
  deleteAlarm(options?: DurableObjectSetAlarmOptions): Promise<void>;
624
639
  sync(): Promise<void>;
640
+ sql: SqlStorage;
625
641
  transactionSync<T>(closure: () => T): T;
642
+ getCurrentBookmark(): Promise<string>;
643
+ getBookmarkForTime(timestamp: number | Date): Promise<string>;
644
+ onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
626
645
  }
627
646
  export interface DurableObjectListOptions {
628
647
  start?: string;
@@ -993,14 +1012,17 @@ export declare abstract class CacheStorage {
993
1012
  */
994
1013
  export declare abstract class Cache {
995
1014
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
996
- delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
1015
+ delete(
1016
+ request: RequestInfo | URL,
1017
+ options?: CacheQueryOptions,
1018
+ ): Promise<boolean>;
997
1019
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
998
1020
  match(
999
- request: RequestInfo,
1021
+ request: RequestInfo | URL,
1000
1022
  options?: CacheQueryOptions,
1001
1023
  ): Promise<Response | undefined>;
1002
1024
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1003
- put(request: RequestInfo, response: Response): Promise<void>;
1025
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
1004
1026
  }
1005
1027
  export interface CacheQueryOptions {
1006
1028
  ignoreMethod?: boolean;
@@ -1423,20 +1445,44 @@ export interface Element {
1423
1445
  hasAttribute(name: string): boolean;
1424
1446
  setAttribute(name: string, value: string): Element;
1425
1447
  removeAttribute(name: string): Element;
1426
- before(content: string, options?: ContentOptions): Element;
1427
- after(content: string, options?: ContentOptions): Element;
1428
- prepend(content: string, options?: ContentOptions): Element;
1429
- append(content: string, options?: ContentOptions): Element;
1430
- replace(content: string, options?: ContentOptions): Element;
1448
+ before(
1449
+ content: string | ReadableStream | Response,
1450
+ options?: ContentOptions,
1451
+ ): Element;
1452
+ after(
1453
+ content: string | ReadableStream | Response,
1454
+ options?: ContentOptions,
1455
+ ): Element;
1456
+ prepend(
1457
+ content: string | ReadableStream | Response,
1458
+ options?: ContentOptions,
1459
+ ): Element;
1460
+ append(
1461
+ content: string | ReadableStream | Response,
1462
+ options?: ContentOptions,
1463
+ ): Element;
1464
+ replace(
1465
+ content: string | ReadableStream | Response,
1466
+ options?: ContentOptions,
1467
+ ): Element;
1431
1468
  remove(): Element;
1432
1469
  removeAndKeepContent(): Element;
1433
- setInnerContent(content: string, options?: ContentOptions): Element;
1470
+ setInnerContent(
1471
+ content: string | ReadableStream | Response,
1472
+ options?: ContentOptions,
1473
+ ): Element;
1434
1474
  onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1435
1475
  }
1436
1476
  export interface EndTag {
1437
1477
  name: string;
1438
- before(content: string, options?: ContentOptions): EndTag;
1439
- after(content: string, options?: ContentOptions): EndTag;
1478
+ before(
1479
+ content: string | ReadableStream | Response,
1480
+ options?: ContentOptions,
1481
+ ): EndTag;
1482
+ after(
1483
+ content: string | ReadableStream | Response,
1484
+ options?: ContentOptions,
1485
+ ): EndTag;
1440
1486
  remove(): EndTag;
1441
1487
  }
1442
1488
  export interface Comment {
@@ -1451,9 +1497,18 @@ export interface Text {
1451
1497
  readonly text: string;
1452
1498
  readonly lastInTextNode: boolean;
1453
1499
  readonly removed: boolean;
1454
- before(content: string, options?: ContentOptions): Text;
1455
- after(content: string, options?: ContentOptions): Text;
1456
- replace(content: string, options?: ContentOptions): Text;
1500
+ before(
1501
+ content: string | ReadableStream | Response,
1502
+ options?: ContentOptions,
1503
+ ): Text;
1504
+ after(
1505
+ content: string | ReadableStream | Response,
1506
+ options?: ContentOptions,
1507
+ ): Text;
1508
+ replace(
1509
+ content: string | ReadableStream | Response,
1510
+ options?: ContentOptions,
1511
+ ): Text;
1457
1512
  remove(): Text;
1458
1513
  }
1459
1514
  export interface DocumentEnd {
@@ -1535,28 +1590,34 @@ export declare abstract class Body {
1535
1590
  *
1536
1591
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1537
1592
  */
1538
- export declare class Response extends Body {
1539
- constructor(body?: BodyInit | null, init?: ResponseInit);
1540
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1541
- static redirect(url: string, status?: number): Response;
1542
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
1543
- static json(any: any, maybeInit?: ResponseInit | Response): Response;
1593
+ export declare var Response: {
1594
+ prototype: Response;
1595
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
1596
+ redirect(url: string, status?: number): Response;
1597
+ json(any: any, maybeInit?: ResponseInit | Response): Response;
1598
+ };
1599
+ /**
1600
+ * This Fetch API interface represents the response to a request.
1601
+ *
1602
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1603
+ */
1604
+ export interface Response extends Body {
1544
1605
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1545
1606
  clone(): Response;
1546
1607
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1547
- get status(): number;
1608
+ status: number;
1548
1609
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1549
- get statusText(): string;
1610
+ statusText: string;
1550
1611
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1551
- get headers(): Headers;
1612
+ headers: Headers;
1552
1613
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1553
- get ok(): boolean;
1614
+ ok: boolean;
1554
1615
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1555
- get redirected(): boolean;
1616
+ redirected: boolean;
1556
1617
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1557
- get url(): string;
1558
- get webSocket(): WebSocket | null;
1559
- get cf(): any | undefined;
1618
+ url: string;
1619
+ webSocket: WebSocket | null;
1620
+ cf: any | undefined;
1560
1621
  }
1561
1622
  export interface ResponseInit {
1562
1623
  status?: number;
@@ -1569,17 +1630,28 @@ export interface ResponseInit {
1569
1630
  export type RequestInfo<
1570
1631
  CfHostMetadata = unknown,
1571
1632
  Cf = CfProperties<CfHostMetadata>,
1572
- > = Request<CfHostMetadata, Cf> | string | URL;
1633
+ > = Request<CfHostMetadata, Cf> | string;
1634
+ /**
1635
+ * This Fetch API interface represents a resource request.
1636
+ *
1637
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1638
+ */
1639
+ export declare var Request: {
1640
+ prototype: Request;
1641
+ new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
1642
+ input: RequestInfo<CfProperties> | URL,
1643
+ init?: RequestInit<Cf>,
1644
+ ): Request<CfHostMetadata, Cf>;
1645
+ };
1573
1646
  /**
1574
1647
  * This Fetch API interface represents a resource request.
1575
1648
  *
1576
1649
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1577
1650
  */
1578
- export declare class Request<
1651
+ export interface Request<
1579
1652
  CfHostMetadata = unknown,
1580
1653
  Cf = CfProperties<CfHostMetadata>,
1581
1654
  > extends Body {
1582
- constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1583
1655
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1584
1656
  clone(): Request<CfHostMetadata, Cf>;
1585
1657
  /**
@@ -1587,45 +1659,45 @@ export declare class Request<
1587
1659
  *
1588
1660
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1589
1661
  */
1590
- get method(): string;
1662
+ method: string;
1591
1663
  /**
1592
1664
  * Returns the URL of request as a string.
1593
1665
  *
1594
1666
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1595
1667
  */
1596
- get url(): string;
1668
+ url: string;
1597
1669
  /**
1598
1670
  * 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.
1599
1671
  *
1600
1672
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1601
1673
  */
1602
- get headers(): Headers;
1674
+ headers: Headers;
1603
1675
  /**
1604
1676
  * 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.
1605
1677
  *
1606
1678
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1607
1679
  */
1608
- get redirect(): string;
1609
- get fetcher(): Fetcher | null;
1680
+ redirect: string;
1681
+ fetcher: Fetcher | null;
1610
1682
  /**
1611
1683
  * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1612
1684
  *
1613
1685
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1614
1686
  */
1615
- get signal(): AbortSignal;
1616
- get cf(): Cf | undefined;
1687
+ signal: AbortSignal;
1688
+ cf: Cf | undefined;
1617
1689
  /**
1618
1690
  * 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]
1619
1691
  *
1620
1692
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1621
1693
  */
1622
- get integrity(): string;
1694
+ integrity: string;
1623
1695
  /**
1624
1696
  * Returns a boolean indicating whether or not request can outlive the global in which it was created.
1625
1697
  *
1626
1698
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1627
1699
  */
1628
- get keepalive(): boolean;
1700
+ keepalive: boolean;
1629
1701
  }
1630
1702
  export interface RequestInit<Cf = CfProperties> {
1631
1703
  /* A string to set request's method. */
@@ -1652,7 +1724,7 @@ export type Fetcher<
1652
1724
  > = (T extends Rpc.EntrypointBranded
1653
1725
  ? Rpc.Provider<T, Reserved | "fetch" | "connect">
1654
1726
  : unknown) & {
1655
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1727
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1656
1728
  connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1657
1729
  };
1658
1730
  export interface FetcherPutOptions {
@@ -1873,6 +1945,7 @@ export interface R2MultipartUpload {
1873
1945
  uploadPart(
1874
1946
  partNumber: number,
1875
1947
  value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
1948
+ options?: R2UploadPartOptions,
1876
1949
  ): Promise<R2UploadedPart>;
1877
1950
  abort(): Promise<void>;
1878
1951
  complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
@@ -1893,6 +1966,7 @@ export declare abstract class R2Object {
1893
1966
  readonly customMetadata?: Record<string, string>;
1894
1967
  readonly range?: R2Range;
1895
1968
  readonly storageClass: string;
1969
+ readonly ssecKeyMd5?: string;
1896
1970
  writeHttpMetadata(headers: Headers): void;
1897
1971
  }
1898
1972
  export interface R2ObjectBody extends R2Object {
@@ -1925,6 +1999,7 @@ export interface R2Conditional {
1925
1999
  export interface R2GetOptions {
1926
2000
  onlyIf?: R2Conditional | Headers;
1927
2001
  range?: R2Range | Headers;
2002
+ ssecKey?: ArrayBuffer | string;
1928
2003
  }
1929
2004
  export interface R2PutOptions {
1930
2005
  onlyIf?: R2Conditional | Headers;
@@ -1936,11 +2011,13 @@ export interface R2PutOptions {
1936
2011
  sha384?: ArrayBuffer | string;
1937
2012
  sha512?: ArrayBuffer | string;
1938
2013
  storageClass?: string;
2014
+ ssecKey?: ArrayBuffer | string;
1939
2015
  }
1940
2016
  export interface R2MultipartOptions {
1941
2017
  httpMetadata?: R2HTTPMetadata | Headers;
1942
2018
  customMetadata?: Record<string, string>;
1943
2019
  storageClass?: string;
2020
+ ssecKey?: ArrayBuffer | string;
1944
2021
  }
1945
2022
  export interface R2Checksums {
1946
2023
  readonly md5?: ArrayBuffer;
@@ -1977,6 +2054,9 @@ export type R2Objects = {
1977
2054
  truncated: false;
1978
2055
  }
1979
2056
  );
2057
+ export interface R2UploadPartOptions {
2058
+ ssecKey?: ArrayBuffer | string;
2059
+ }
1980
2060
  export declare abstract class ScheduledEvent extends ExtendableEvent {
1981
2061
  readonly scheduledTime: number;
1982
2062
  readonly cron: string;
@@ -2390,6 +2470,8 @@ export interface TraceItem {
2390
2470
  readonly dispatchNamespace?: string;
2391
2471
  readonly scriptTags?: string[];
2392
2472
  readonly outcome: string;
2473
+ readonly executionModel: string;
2474
+ readonly truncated: boolean;
2393
2475
  }
2394
2476
  export interface TraceItemAlarmEventInfo {
2395
2477
  readonly scheduledTime: Date;
@@ -2703,8 +2785,24 @@ export type WebSocketEventMap = {
2703
2785
  *
2704
2786
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2705
2787
  */
2706
- export declare class WebSocket extends EventTarget<WebSocketEventMap> {
2707
- constructor(url: string, protocols?: string[] | string);
2788
+ export declare var WebSocket: {
2789
+ prototype: WebSocket;
2790
+ new (url: string, protocols?: string[] | string): WebSocket;
2791
+ readonly READY_STATE_CONNECTING: number;
2792
+ readonly CONNECTING: number;
2793
+ readonly READY_STATE_OPEN: number;
2794
+ readonly OPEN: number;
2795
+ readonly READY_STATE_CLOSING: number;
2796
+ readonly CLOSING: number;
2797
+ readonly READY_STATE_CLOSED: number;
2798
+ readonly CLOSED: number;
2799
+ };
2800
+ /**
2801
+ * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2802
+ *
2803
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2804
+ */
2805
+ export interface WebSocket extends EventTarget<WebSocketEventMap> {
2708
2806
  accept(): void;
2709
2807
  /**
2710
2808
  * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
@@ -2720,38 +2818,30 @@ export declare class WebSocket extends EventTarget<WebSocketEventMap> {
2720
2818
  close(code?: number, reason?: string): void;
2721
2819
  serializeAttachment(attachment: any): void;
2722
2820
  deserializeAttachment(): any | null;
2723
- static readonly READY_STATE_CONNECTING: number;
2724
- static readonly CONNECTING: number;
2725
- static readonly READY_STATE_OPEN: number;
2726
- static readonly OPEN: number;
2727
- static readonly READY_STATE_CLOSING: number;
2728
- static readonly CLOSING: number;
2729
- static readonly READY_STATE_CLOSED: number;
2730
- static readonly CLOSED: number;
2731
2821
  /**
2732
2822
  * Returns the state of the WebSocket object's connection. It can have the values described below.
2733
2823
  *
2734
2824
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2735
2825
  */
2736
- get readyState(): number;
2826
+ readyState: number;
2737
2827
  /**
2738
2828
  * Returns the URL that was used to establish the WebSocket connection.
2739
2829
  *
2740
2830
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2741
2831
  */
2742
- get url(): string | null;
2832
+ url: string | null;
2743
2833
  /**
2744
2834
  * 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.
2745
2835
  *
2746
2836
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2747
2837
  */
2748
- get protocol(): string | null;
2838
+ protocol: string | null;
2749
2839
  /**
2750
2840
  * Returns the extensions selected by the server, if any.
2751
2841
  *
2752
2842
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2753
2843
  */
2754
- get extensions(): string | null;
2844
+ extensions: string | null;
2755
2845
  }
2756
2846
  export declare const WebSocketPair: {
2757
2847
  new (): {
@@ -2759,6 +2849,37 @@ export declare const WebSocketPair: {
2759
2849
  1: WebSocket;
2760
2850
  };
2761
2851
  };
2852
+ export interface SqlStorage {
2853
+ exec<T extends Record<string, SqlStorageValue>>(
2854
+ query: string,
2855
+ ...bindings: any[]
2856
+ ): SqlStorageCursor<T>;
2857
+ get databaseSize(): number;
2858
+ Cursor: typeof SqlStorageCursor;
2859
+ Statement: typeof SqlStorageStatement;
2860
+ }
2861
+ export declare abstract class SqlStorageStatement {}
2862
+ export type SqlStorageValue = ArrayBuffer | string | number | null;
2863
+ export declare abstract class SqlStorageCursor<
2864
+ T extends Record<string, SqlStorageValue>,
2865
+ > {
2866
+ next():
2867
+ | {
2868
+ done?: false;
2869
+ value: T;
2870
+ }
2871
+ | {
2872
+ done: true;
2873
+ value?: never;
2874
+ };
2875
+ toArray(): T[];
2876
+ one(): T;
2877
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2878
+ columnNames: string[];
2879
+ get rowsRead(): number;
2880
+ get rowsWritten(): number;
2881
+ [Symbol.iterator](): IterableIterator<T>;
2882
+ }
2762
2883
  export interface Socket {
2763
2884
  get readable(): ReadableStream;
2764
2885
  get writable(): WritableStream;
@@ -3296,7 +3417,7 @@ export interface GPUOrigin3DDict {
3296
3417
  z?: number;
3297
3418
  }
3298
3419
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3299
- export declare class EventSource {
3420
+ export declare class EventSource extends EventTarget {
3300
3421
  constructor(url: string, init?: EventSourceEventSourceInit);
3301
3422
  /**
3302
3423
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -3395,10 +3516,10 @@ export declare abstract class BaseAiSentenceSimilarity {
3395
3516
  inputs: AiSentenceSimilarityInput;
3396
3517
  postProcessedOutputs: AiSentenceSimilarityOutput;
3397
3518
  }
3398
- export type AiSpeechRecognitionInput = {
3519
+ export type AiAutomaticSpeechRecognitionInput = {
3399
3520
  audio: number[];
3400
3521
  };
3401
- export type AiSpeechRecognitionOutput = {
3522
+ export type AiAutomaticSpeechRecognitionOutput = {
3402
3523
  text?: string;
3403
3524
  words?: {
3404
3525
  word: string;
@@ -3407,9 +3528,9 @@ export type AiSpeechRecognitionOutput = {
3407
3528
  }[];
3408
3529
  vtt?: string;
3409
3530
  };
3410
- export declare abstract class BaseAiSpeechRecognition {
3411
- inputs: AiSpeechRecognitionInput;
3412
- postProcessedOutputs: AiSpeechRecognitionOutput;
3531
+ export declare abstract class BaseAiAutomaticSpeechRecognition {
3532
+ inputs: AiAutomaticSpeechRecognitionInput;
3533
+ postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3413
3534
  }
3414
3535
  export type AiSummarizationInput = {
3415
3536
  input_text: string;
@@ -3445,16 +3566,36 @@ export declare abstract class BaseAiTextEmbeddings {
3445
3566
  postProcessedOutputs: AiTextEmbeddingsOutput;
3446
3567
  }
3447
3568
  export type RoleScopedChatInput = {
3448
- role: "user" | "assistant" | "system" | "tool";
3569
+ role:
3570
+ | "user"
3571
+ | "assistant"
3572
+ | "system"
3573
+ | "tool"
3574
+ | (string & NonNullable<unknown>);
3449
3575
  content: string;
3576
+ name?: string;
3577
+ };
3578
+ export type AiTextGenerationToolLegacyInput = {
3579
+ name: string;
3580
+ description: string;
3581
+ parameters?: {
3582
+ type: "object" | (string & NonNullable<unknown>);
3583
+ properties: {
3584
+ [key: string]: {
3585
+ type: string;
3586
+ description?: string;
3587
+ };
3588
+ };
3589
+ required: string[];
3590
+ };
3450
3591
  };
3451
3592
  export type AiTextGenerationToolInput = {
3452
- type: "function";
3593
+ type: "function" | (string & NonNullable<unknown>);
3453
3594
  function: {
3454
3595
  name: string;
3455
3596
  description: string;
3456
3597
  parameters?: {
3457
- type: "object";
3598
+ type: "object" | (string & NonNullable<unknown>);
3458
3599
  properties: {
3459
3600
  [key: string]: {
3460
3601
  type: string;
@@ -3465,6 +3606,10 @@ export type AiTextGenerationToolInput = {
3465
3606
  };
3466
3607
  };
3467
3608
  };
3609
+ export type AiTextGenerationFunctionsInput = {
3610
+ name: string;
3611
+ code: string;
3612
+ };
3468
3613
  export type AiTextGenerationInput = {
3469
3614
  prompt?: string;
3470
3615
  raw?: boolean;
@@ -3478,7 +3623,11 @@ export type AiTextGenerationInput = {
3478
3623
  frequency_penalty?: number;
3479
3624
  presence_penalty?: number;
3480
3625
  messages?: RoleScopedChatInput[];
3481
- tools?: AiTextGenerationToolInput[];
3626
+ tools?:
3627
+ | AiTextGenerationToolInput[]
3628
+ | AiTextGenerationToolLegacyInput[]
3629
+ | (object & NonNullable<unknown>);
3630
+ functions?: AiTextGenerationFunctionsInput[];
3482
3631
  };
3483
3632
  export type AiTextGenerationOutput =
3484
3633
  | {
@@ -3493,15 +3642,33 @@ export declare abstract class BaseAiTextGeneration {
3493
3642
  inputs: AiTextGenerationInput;
3494
3643
  postProcessedOutputs: AiTextGenerationOutput;
3495
3644
  }
3645
+ export type AiTextToSpeechInput = {
3646
+ prompt: string;
3647
+ lang?: string;
3648
+ };
3649
+ export type AiTextToSpeechOutput =
3650
+ | Uint8Array
3651
+ | {
3652
+ audio: string;
3653
+ };
3654
+ export declare abstract class BaseAiTextToSpeech {
3655
+ inputs: AiTextToSpeechInput;
3656
+ postProcessedOutputs: AiTextToSpeechOutput;
3657
+ }
3496
3658
  export type AiTextToImageInput = {
3497
3659
  prompt: string;
3660
+ negative_prompt?: string;
3661
+ height?: number;
3662
+ width?: number;
3498
3663
  image?: number[];
3664
+ image_b64?: string;
3499
3665
  mask?: number[];
3500
3666
  num_steps?: number;
3501
3667
  strength?: number;
3502
3668
  guidance?: number;
3669
+ seed?: number;
3503
3670
  };
3504
- export type AiTextToImageOutput = Uint8Array;
3671
+ export type AiTextToImageOutput = ReadableStream<Uint8Array>;
3505
3672
  export declare abstract class BaseAiTextToImage {
3506
3673
  inputs: AiTextToImageInput;
3507
3674
  postProcessedOutputs: AiTextToImageOutput;
@@ -3518,127 +3685,615 @@ export declare abstract class BaseAiTranslation {
3518
3685
  inputs: AiTranslationInput;
3519
3686
  postProcessedOutputs: AiTranslationOutput;
3520
3687
  }
3688
+ export type Ai_Cf_Openai_Whisper_Input =
3689
+ | string
3690
+ | {
3691
+ /**
3692
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3693
+ */
3694
+ audio: number[];
3695
+ };
3696
+ export interface Ai_Cf_Openai_Whisper_Output {
3697
+ /**
3698
+ * The transcription
3699
+ */
3700
+ text: string;
3701
+ word_count?: number;
3702
+ words?: {
3703
+ word?: string;
3704
+ /**
3705
+ * The second this word begins in the recording
3706
+ */
3707
+ start?: number;
3708
+ /**
3709
+ * The ending second when the word completes
3710
+ */
3711
+ end?: number;
3712
+ }[];
3713
+ vtt?: string;
3714
+ }
3715
+ export declare abstract class Base_Ai_Cf_Openai_Whisper {
3716
+ inputs: Ai_Cf_Openai_Whisper_Input;
3717
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
3718
+ }
3719
+ export type Ai_Cf_Openai_Whisper_Tiny_En_Input =
3720
+ | string
3721
+ | {
3722
+ /**
3723
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3724
+ */
3725
+ audio: number[];
3726
+ };
3727
+ export interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3728
+ /**
3729
+ * The transcription
3730
+ */
3731
+ text: string;
3732
+ word_count?: number;
3733
+ words?: {
3734
+ word?: string;
3735
+ /**
3736
+ * The second this word begins in the recording
3737
+ */
3738
+ start?: number;
3739
+ /**
3740
+ * The ending second when the word completes
3741
+ */
3742
+ end?: number;
3743
+ }[];
3744
+ vtt?: string;
3745
+ }
3746
+ export declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3747
+ inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3748
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3749
+ }
3750
+ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3751
+ /**
3752
+ * Base64 encoded value of the audio data.
3753
+ */
3754
+ audio: string;
3755
+ /**
3756
+ * Supported tasks are 'translate' or 'transcribe'.
3757
+ */
3758
+ task?: string;
3759
+ /**
3760
+ * The language of the audio being transcribed or translated.
3761
+ */
3762
+ language?: string;
3763
+ /**
3764
+ * Preprocess the audio with a voice activity detection model.
3765
+ */
3766
+ vad_filter?: string;
3767
+ /**
3768
+ * A text prompt to help provide context to the model on the contents of the audio.
3769
+ */
3770
+ initial_prompt?: string;
3771
+ /**
3772
+ * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3773
+ */
3774
+ prefix?: string;
3775
+ }
3776
+ export interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3777
+ transcription_info?: {
3778
+ /**
3779
+ * The language of the audio being transcribed or translated.
3780
+ */
3781
+ language?: string;
3782
+ /**
3783
+ * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3784
+ */
3785
+ language_probability?: number;
3786
+ /**
3787
+ * The total duration of the original audio file, in seconds.
3788
+ */
3789
+ duration?: number;
3790
+ /**
3791
+ * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3792
+ */
3793
+ duration_after_vad?: number;
3794
+ };
3795
+ /**
3796
+ * The complete transcription of the audio.
3797
+ */
3798
+ text: string;
3799
+ /**
3800
+ * The total number of words in the transcription.
3801
+ */
3802
+ word_count?: number;
3803
+ segments?: {
3804
+ /**
3805
+ * The starting time of the segment within the audio, in seconds.
3806
+ */
3807
+ start?: number;
3808
+ /**
3809
+ * The ending time of the segment within the audio, in seconds.
3810
+ */
3811
+ end?: number;
3812
+ /**
3813
+ * The transcription of the segment.
3814
+ */
3815
+ text?: string;
3816
+ /**
3817
+ * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3818
+ */
3819
+ temperature?: number;
3820
+ /**
3821
+ * The average log probability of the predictions for the words in this segment, indicating overall confidence.
3822
+ */
3823
+ avg_logprob?: number;
3824
+ /**
3825
+ * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3826
+ */
3827
+ compression_ratio?: number;
3828
+ /**
3829
+ * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3830
+ */
3831
+ no_speech_prob?: number;
3832
+ words?: {
3833
+ /**
3834
+ * The individual word transcribed from the audio.
3835
+ */
3836
+ word?: string;
3837
+ /**
3838
+ * The starting time of the word within the audio, in seconds.
3839
+ */
3840
+ start?: number;
3841
+ /**
3842
+ * The ending time of the word within the audio, in seconds.
3843
+ */
3844
+ end?: number;
3845
+ }[];
3846
+ };
3847
+ /**
3848
+ * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3849
+ */
3850
+ vtt?: string;
3851
+ }
3852
+ export declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3853
+ inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3854
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3855
+ }
3856
+ export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3857
+ /**
3858
+ * A text description of the image you want to generate.
3859
+ */
3860
+ prompt: string;
3861
+ /**
3862
+ * The number of diffusion steps; higher values can improve quality but take longer.
3863
+ */
3864
+ steps?: number;
3865
+ }
3866
+ export interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3867
+ /**
3868
+ * The generated image in Base64 format.
3869
+ */
3870
+ image?: string;
3871
+ }
3872
+ export declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3873
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3874
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3875
+ }
3876
+ export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3877
+ export interface Prompt {
3878
+ /**
3879
+ * The input text prompt for the model to generate a response.
3880
+ */
3881
+ prompt: string;
3882
+ image?: number[] | (string & NonNullable<unknown>);
3883
+ /**
3884
+ * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3885
+ */
3886
+ raw?: boolean;
3887
+ /**
3888
+ * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3889
+ */
3890
+ stream?: boolean;
3891
+ /**
3892
+ * The maximum number of tokens to generate in the response.
3893
+ */
3894
+ max_tokens?: number;
3895
+ /**
3896
+ * Controls the randomness of the output; higher values produce more random results.
3897
+ */
3898
+ temperature?: number;
3899
+ /**
3900
+ * 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.
3901
+ */
3902
+ top_p?: number;
3903
+ /**
3904
+ * 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.
3905
+ */
3906
+ top_k?: number;
3907
+ /**
3908
+ * Random seed for reproducibility of the generation.
3909
+ */
3910
+ seed?: number;
3911
+ /**
3912
+ * Penalty for repeated tokens; higher values discourage repetition.
3913
+ */
3914
+ repetition_penalty?: number;
3915
+ /**
3916
+ * Decreases the likelihood of the model repeating the same lines verbatim.
3917
+ */
3918
+ frequency_penalty?: number;
3919
+ /**
3920
+ * Increases the likelihood of the model introducing new topics.
3921
+ */
3922
+ presence_penalty?: number;
3923
+ /**
3924
+ * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
3925
+ */
3926
+ lora?: string;
3927
+ }
3928
+ export interface Messages {
3929
+ /**
3930
+ * An array of message objects representing the conversation history.
3931
+ */
3932
+ messages: {
3933
+ /**
3934
+ * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
3935
+ */
3936
+ role: string;
3937
+ /**
3938
+ * The content of the message as a string.
3939
+ */
3940
+ content: string;
3941
+ }[];
3942
+ image?: number[] | string;
3943
+ functions?: {
3944
+ name: string;
3945
+ code: string;
3946
+ }[];
3947
+ /**
3948
+ * A list of tools available for the assistant to use.
3949
+ */
3950
+ tools?: (
3951
+ | {
3952
+ /**
3953
+ * The name of the tool. More descriptive the better.
3954
+ */
3955
+ name: string;
3956
+ /**
3957
+ * A brief description of what the tool does.
3958
+ */
3959
+ description: string;
3960
+ /**
3961
+ * Schema defining the parameters accepted by the tool.
3962
+ */
3963
+ parameters: {
3964
+ /**
3965
+ * The type of the parameters object (usually 'object').
3966
+ */
3967
+ type: string;
3968
+ /**
3969
+ * List of required parameter names.
3970
+ */
3971
+ required?: string[];
3972
+ /**
3973
+ * Definitions of each parameter.
3974
+ */
3975
+ properties: {
3976
+ [k: string]: {
3977
+ /**
3978
+ * The data type of the parameter.
3979
+ */
3980
+ type: string;
3981
+ /**
3982
+ * A description of the expected parameter.
3983
+ */
3984
+ description: string;
3985
+ };
3986
+ };
3987
+ };
3988
+ }
3989
+ | {
3990
+ /**
3991
+ * Specifies the type of tool (e.g., 'function').
3992
+ */
3993
+ type: string;
3994
+ /**
3995
+ * Details of the function tool.
3996
+ */
3997
+ function: {
3998
+ /**
3999
+ * The name of the function.
4000
+ */
4001
+ name: string;
4002
+ /**
4003
+ * A brief description of what the function does.
4004
+ */
4005
+ description: string;
4006
+ /**
4007
+ * Schema defining the parameters accepted by the function.
4008
+ */
4009
+ parameters: {
4010
+ /**
4011
+ * The type of the parameters object (usually 'object').
4012
+ */
4013
+ type: string;
4014
+ /**
4015
+ * List of required parameter names.
4016
+ */
4017
+ required?: string[];
4018
+ /**
4019
+ * Definitions of each parameter.
4020
+ */
4021
+ properties: {
4022
+ [k: string]: {
4023
+ /**
4024
+ * The data type of the parameter.
4025
+ */
4026
+ type: string;
4027
+ /**
4028
+ * A description of the expected parameter.
4029
+ */
4030
+ description: string;
4031
+ };
4032
+ };
4033
+ };
4034
+ };
4035
+ }
4036
+ )[];
4037
+ /**
4038
+ * If true, the response will be streamed back incrementally.
4039
+ */
4040
+ stream?: boolean;
4041
+ /**
4042
+ * The maximum number of tokens to generate in the response.
4043
+ */
4044
+ max_tokens?: number;
4045
+ /**
4046
+ * Controls the randomness of the output; higher values produce more random results.
4047
+ */
4048
+ temperature?: number;
4049
+ /**
4050
+ * 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.
4051
+ */
4052
+ top_p?: number;
4053
+ /**
4054
+ * 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.
4055
+ */
4056
+ top_k?: number;
4057
+ /**
4058
+ * Random seed for reproducibility of the generation.
4059
+ */
4060
+ seed?: number;
4061
+ /**
4062
+ * Penalty for repeated tokens; higher values discourage repetition.
4063
+ */
4064
+ repetition_penalty?: number;
4065
+ /**
4066
+ * Decreases the likelihood of the model repeating the same lines verbatim.
4067
+ */
4068
+ frequency_penalty?: number;
4069
+ /**
4070
+ * Increases the likelihood of the model introducing new topics.
4071
+ */
4072
+ presence_penalty?: number;
4073
+ }
4074
+ export type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
4075
+ | {
4076
+ /**
4077
+ * The generated text response from the model
4078
+ */
4079
+ response?: string;
4080
+ /**
4081
+ * An array of tool calls requests made during the response generation
4082
+ */
4083
+ tool_calls?: {
4084
+ /**
4085
+ * The arguments passed to be passed to the tool call request
4086
+ */
4087
+ arguments?: object;
4088
+ /**
4089
+ * The name of the tool to be called
4090
+ */
4091
+ name?: string;
4092
+ }[];
4093
+ }
4094
+ | ReadableStream;
4095
+ export declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4096
+ inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4097
+ postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4098
+ }
4099
+ export interface AiModels {
4100
+ "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
4101
+ "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
4102
+ "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
4103
+ "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
4104
+ "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
4105
+ "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
4106
+ "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
4107
+ "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
4108
+ "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
4109
+ "@cf/microsoft/resnet-50": BaseAiImageClassification;
4110
+ "@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
4111
+ "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
4112
+ "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
4113
+ "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
4114
+ "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
4115
+ "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
4116
+ "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
4117
+ "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
4118
+ "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
4119
+ "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
4120
+ "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
4121
+ "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
4122
+ "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
4123
+ "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
4124
+ "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
4125
+ "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
4126
+ "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
4127
+ "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
4128
+ "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
4129
+ "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
4130
+ "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
4131
+ "@cf/microsoft/phi-2": BaseAiTextGeneration;
4132
+ "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
4133
+ "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
4134
+ "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
4135
+ "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
4136
+ "@hf/google/gemma-7b-it": BaseAiTextGeneration;
4137
+ "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
4138
+ "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
4139
+ "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
4140
+ "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
4141
+ "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
4142
+ "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
4143
+ "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
4144
+ "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
4145
+ "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
4146
+ "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
4147
+ "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
4148
+ "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
4149
+ "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
4150
+ "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
4151
+ "@cf/meta/m2m100-1.2b": BaseAiTranslation;
4152
+ "@cf/facebook/bart-large-cnn": BaseAiSummarization;
4153
+ "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
4154
+ "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
4155
+ "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
4156
+ "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
4157
+ "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
4158
+ "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
4159
+ "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
4160
+ }
4161
+ export type AiOptions = {
4162
+ gateway?: GatewayOptions;
4163
+ prefix?: string;
4164
+ extraHeaders?: object;
4165
+ };
4166
+ export type AiModelsSearchParams = {
4167
+ author?: string;
4168
+ hide_experimental?: boolean;
4169
+ page?: number;
4170
+ per_page?: number;
4171
+ search?: string;
4172
+ source?: number;
4173
+ task?: string;
4174
+ };
4175
+ export type AiModelsSearchObject = {
4176
+ id: string;
4177
+ source: number;
4178
+ name: string;
4179
+ description: string;
4180
+ task: {
4181
+ id: string;
4182
+ name: string;
4183
+ description: string;
4184
+ };
4185
+ tags: string[];
4186
+ properties: {
4187
+ property_id: string;
4188
+ value: string;
4189
+ }[];
4190
+ };
4191
+ export interface InferenceUpstreamError extends Error {}
4192
+ export interface AiInternalError extends Error {}
4193
+ export type AiModelListType = Record<string, any>;
4194
+ export declare abstract class Ai<
4195
+ AiModelList extends AiModelListType = AiModels,
4196
+ > {
4197
+ aiGatewayLogId: string | null;
4198
+ gateway(gatewayId: string): AiGateway;
4199
+ run<Name extends keyof AiModelList>(
4200
+ model: Name,
4201
+ inputs: AiModelList[Name]["inputs"],
4202
+ options?: AiOptions,
4203
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
4204
+ public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
4205
+ }
3521
4206
  export type GatewayOptions = {
3522
4207
  id: string;
4208
+ cacheKey?: string;
3523
4209
  cacheTtl?: number;
3524
4210
  skipCache?: boolean;
3525
4211
  metadata?: Record<string, number | string | boolean | null | bigint>;
4212
+ collectLog?: boolean;
3526
4213
  };
3527
- export type AiOptions = {
3528
- gateway?: GatewayOptions;
3529
- prefix?: string;
3530
- extraHeaders?: object;
4214
+ export type AiGatewayPatchLog = {
4215
+ score?: number | null;
4216
+ feedback?: -1 | 1 | null;
4217
+ metadata?: Record<string, number | string | boolean | null | bigint> | null;
3531
4218
  };
3532
- export type BaseAiTextClassificationModels =
3533
- "@cf/huggingface/distilbert-sst-2-int8";
3534
- export type BaseAiTextToImageModels =
3535
- | "@cf/stabilityai/stable-diffusion-xl-base-1.0"
3536
- | "@cf/runwayml/stable-diffusion-v1-5-inpainting"
3537
- | "@cf/runwayml/stable-diffusion-v1-5-img2img"
3538
- | "@cf/lykon/dreamshaper-8-lcm"
3539
- | "@cf/bytedance/stable-diffusion-xl-lightning";
3540
- export type BaseAiTextEmbeddingsModels =
3541
- | "@cf/baai/bge-small-en-v1.5"
3542
- | "@cf/baai/bge-base-en-v1.5"
3543
- | "@cf/baai/bge-large-en-v1.5";
3544
- export type BaseAiSpeechRecognitionModels =
3545
- | "@cf/openai/whisper"
3546
- | "@cf/openai/whisper-tiny-en"
3547
- | "@cf/openai/whisper-sherpa";
3548
- export type BaseAiImageClassificationModels = "@cf/microsoft/resnet-50";
3549
- export type BaseAiObjectDetectionModels = "@cf/facebook/detr-resnet-50";
3550
- export type BaseAiTextGenerationModels =
3551
- | "@cf/meta/llama-3-8b-instruct"
3552
- | "@cf/meta/llama-3-8b-instruct-awq"
3553
- | "@cf/meta/llama-2-7b-chat-int8"
3554
- | "@cf/mistral/mistral-7b-instruct-v0.1"
3555
- | "@cf/mistral/mistral-7b-instruct-v0.2-lora"
3556
- | "@cf/meta/llama-2-7b-chat-fp16"
3557
- | "@hf/thebloke/llama-2-13b-chat-awq"
3558
- | "@hf/thebloke/zephyr-7b-beta-awq"
3559
- | "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
3560
- | "@hf/thebloke/codellama-7b-instruct-awq"
3561
- | "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
3562
- | "@hf/thebloke/neural-chat-7b-v3-1-awq"
3563
- | "@hf/thebloke/llamaguard-7b-awq"
3564
- | "@hf/thebloke/deepseek-coder-6.7b-base-awq"
3565
- | "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
3566
- | "@hf/nousresearch/hermes-2-pro-mistral-7b"
3567
- | "@hf/mistral/mistral-7b-instruct-v0.2"
3568
- | "@hf/google/gemma-7b-it"
3569
- | "@hf/nexusflow/starling-lm-7b-beta"
3570
- | "@cf/deepseek-ai/deepseek-math-7b-instruct"
3571
- | "@cf/defog/sqlcoder-7b-2"
3572
- | "@cf/openchat/openchat-3.5-0106"
3573
- | "@cf/tiiuae/falcon-7b-instruct"
3574
- | "@cf/thebloke/discolm-german-7b-v1-awq"
3575
- | "@cf/qwen/qwen1.5-0.5b-chat"
3576
- | "@cf/qwen/qwen1.5-1.8b-chat"
3577
- | "@cf/qwen/qwen1.5-7b-chat-awq"
3578
- | "@cf/qwen/qwen1.5-14b-chat-awq"
3579
- | "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
3580
- | "@cf/microsoft/phi-2"
3581
- | "@cf/google/gemma-2b-it-lora"
3582
- | "@cf/google/gemma-7b-it-lora"
3583
- | "@cf/meta-llama/llama-2-7b-chat-hf-lora"
3584
- | "@cf/fblgit/una-cybertron-7b-v2-bf16"
3585
- | "@cf/fblgit/una-cybertron-7b-v2-awq";
3586
- export type BaseAiTranslationModels = "@cf/meta/m2m100-1.2b";
3587
- export type BaseAiSummarizationModels = "@cf/facebook/bart-large-cnn";
3588
- export type BaseAiImageToTextModels =
3589
- | "@cf/unum/uform-gen2-qwen-500m"
3590
- | "@cf/llava-hf/llava-1.5-7b-hf";
3591
- export declare abstract class Ai {
3592
- run(
3593
- model: BaseAiTextClassificationModels,
3594
- inputs: BaseAiTextClassification["inputs"],
3595
- options?: AiOptions,
3596
- ): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
3597
- run(
3598
- model: BaseAiTextToImageModels,
3599
- inputs: BaseAiTextToImage["inputs"],
3600
- options?: AiOptions,
3601
- ): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
3602
- run(
3603
- model: BaseAiTextEmbeddingsModels,
3604
- inputs: BaseAiTextEmbeddings["inputs"],
3605
- options?: AiOptions,
3606
- ): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
3607
- run(
3608
- model: BaseAiSpeechRecognitionModels,
3609
- inputs: BaseAiSpeechRecognition["inputs"],
3610
- options?: AiOptions,
3611
- ): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
3612
- run(
3613
- model: BaseAiImageClassificationModels,
3614
- inputs: BaseAiImageClassification["inputs"],
3615
- options?: AiOptions,
3616
- ): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
3617
- run(
3618
- model: BaseAiObjectDetectionModels,
3619
- inputs: BaseAiObjectDetection["inputs"],
3620
- options?: AiOptions,
3621
- ): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
3622
- run(
3623
- model: BaseAiTextGenerationModels,
3624
- inputs: BaseAiTextGeneration["inputs"],
3625
- options?: AiOptions,
3626
- ): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
3627
- run(
3628
- model: BaseAiTranslationModels,
3629
- inputs: BaseAiTranslation["inputs"],
3630
- options?: AiOptions,
3631
- ): Promise<BaseAiTranslation["postProcessedOutputs"]>;
3632
- run(
3633
- model: BaseAiSummarizationModels,
3634
- inputs: BaseAiSummarization["inputs"],
3635
- options?: AiOptions,
3636
- ): Promise<BaseAiSummarization["postProcessedOutputs"]>;
4219
+ export type AiGatewayLog = {
4220
+ id: string;
4221
+ provider: string;
4222
+ model: string;
4223
+ model_type?: string;
4224
+ path: string;
4225
+ duration: number;
4226
+ request_type?: string;
4227
+ request_content_type?: string;
4228
+ status_code: number;
4229
+ response_content_type?: string;
4230
+ success: boolean;
4231
+ cached: boolean;
4232
+ tokens_in?: number;
4233
+ tokens_out?: number;
4234
+ metadata?: Record<string, number | string | boolean | null | bigint>;
4235
+ step?: number;
4236
+ cost?: number;
4237
+ custom_cost?: boolean;
4238
+ request_size: number;
4239
+ request_head?: string;
4240
+ request_head_complete: boolean;
4241
+ response_size: number;
4242
+ response_head?: string;
4243
+ response_head_complete: boolean;
4244
+ created_at: Date;
4245
+ };
4246
+ export type AIGatewayProviders =
4247
+ | "workers-ai"
4248
+ | "anthropic"
4249
+ | "aws-bedrock"
4250
+ | "azure-openai"
4251
+ | "google-vertex-ai"
4252
+ | "huggingface"
4253
+ | "openai"
4254
+ | "perplexity-ai"
4255
+ | "replicate"
4256
+ | "groq"
4257
+ | "cohere"
4258
+ | "google-ai-studio"
4259
+ | "mistral"
4260
+ | "grok"
4261
+ | "openrouter";
4262
+ export type AIGatewayHeaders = {
4263
+ "cf-aig-metadata":
4264
+ | Record<string, number | string | boolean | null | bigint>
4265
+ | string;
4266
+ "cf-aig-custom-cost":
4267
+ | {
4268
+ per_token_in?: number;
4269
+ per_token_out?: number;
4270
+ }
4271
+ | {
4272
+ total_cost?: number;
4273
+ }
4274
+ | string;
4275
+ "cf-aig-cache-ttl": number | string;
4276
+ "cf-aig-skip-cache": boolean | string;
4277
+ "cf-aig-cache-key": string;
4278
+ "cf-aig-collect-log": boolean | string;
4279
+ Authorization: string;
4280
+ "Content-Type": string;
4281
+ [key: string]: string | number | boolean | object;
4282
+ };
4283
+ export type AIGatewayUniversalRequest = {
4284
+ provider: AIGatewayProviders | string; // eslint-disable-line
4285
+ endpoint: string;
4286
+ headers: Partial<AIGatewayHeaders>;
4287
+ query: unknown;
4288
+ };
4289
+ export interface AiGatewayInternalError extends Error {}
4290
+ export interface AiGatewayLogNotFound extends Error {}
4291
+ export declare abstract class AiGateway {
4292
+ patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
4293
+ getLog(logId: string): Promise<AiGatewayLog>;
3637
4294
  run(
3638
- model: BaseAiImageToTextModels,
3639
- inputs: BaseAiImageToText["inputs"],
3640
- options?: AiOptions,
3641
- ): Promise<BaseAiImageToText["postProcessedOutputs"]>;
4295
+ data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
4296
+ ): Promise<Response>;
3642
4297
  }
3643
4298
  export interface BasicImageTransformations {
3644
4299
  /**
@@ -4656,7 +5311,7 @@ export declare abstract class D1PreparedStatement {
4656
5311
  bind(...values: unknown[]): D1PreparedStatement;
4657
5312
  first<T = unknown>(colName: string): Promise<T | null>;
4658
5313
  first<T = Record<string, unknown>>(): Promise<T | null>;
4659
- run(): Promise<D1Response>;
5314
+ run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4660
5315
  all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4661
5316
  raw<T = unknown[]>(options: {
4662
5317
  columnNames: true;
@@ -4712,6 +5367,12 @@ export interface ForwardableEmailMessage extends EmailMessage {
4712
5367
  * @returns A promise that resolves when the email message is forwarded.
4713
5368
  */
4714
5369
  forward(rcptTo: string, headers?: Headers): Promise<void>;
5370
+ /**
5371
+ * Reply to the sender of this email message with a new EmailMessage object.
5372
+ * @param message The reply message.
5373
+ * @returns A promise that resolves when the email message is replied.
5374
+ */
5375
+ reply(message: EmailMessage): Promise<void>;
4715
5376
  }
4716
5377
  /**
4717
5378
  * A binding that allows a Worker to send email messages.
@@ -4774,6 +5435,128 @@ export interface Hyperdrive {
4774
5435
  */
4775
5436
  readonly database: string;
4776
5437
  }
5438
+ // Copyright (c) 2024 Cloudflare, Inc.
5439
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5440
+ // https://opensource.org/licenses/Apache-2.0
5441
+ export type ImageInfoResponse =
5442
+ | {
5443
+ format: "image/svg+xml";
5444
+ }
5445
+ | {
5446
+ format: string;
5447
+ fileSize: number;
5448
+ width: number;
5449
+ height: number;
5450
+ };
5451
+ export type ImageTransform = {
5452
+ fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
5453
+ gravity?:
5454
+ | "left"
5455
+ | "right"
5456
+ | "top"
5457
+ | "bottom"
5458
+ | "center"
5459
+ | "auto"
5460
+ | "entropy"
5461
+ | "face"
5462
+ | {
5463
+ x?: number;
5464
+ y?: number;
5465
+ mode: "remainder" | "box-center";
5466
+ };
5467
+ trim?: {
5468
+ top?: number;
5469
+ bottom?: number;
5470
+ left?: number;
5471
+ right?: number;
5472
+ width?: number;
5473
+ height?: number;
5474
+ border?:
5475
+ | boolean
5476
+ | {
5477
+ color?: string;
5478
+ tolerance?: number;
5479
+ keep?: number;
5480
+ };
5481
+ };
5482
+ width?: number;
5483
+ height?: number;
5484
+ background?: string;
5485
+ rotate?: number;
5486
+ sharpen?: number;
5487
+ blur?: number;
5488
+ contrast?: number;
5489
+ brightness?: number;
5490
+ gamma?: number;
5491
+ border?: {
5492
+ color?: string;
5493
+ width?: number;
5494
+ top?: number;
5495
+ bottom?: number;
5496
+ left?: number;
5497
+ right?: number;
5498
+ };
5499
+ zoom?: number;
5500
+ };
5501
+ export type ImageOutputOptions = {
5502
+ format:
5503
+ | "image/jpeg"
5504
+ | "image/png"
5505
+ | "image/gif"
5506
+ | "image/webp"
5507
+ | "image/avif"
5508
+ | "rgb"
5509
+ | "rgba";
5510
+ quality?: number;
5511
+ background?: string;
5512
+ };
5513
+ export interface ImagesBinding {
5514
+ /**
5515
+ * Get image metadata (type, width and height)
5516
+ * @throws {@link ImagesError} with code 9412 if input is not an image
5517
+ * @param stream The image bytes
5518
+ */
5519
+ info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
5520
+ /**
5521
+ * Begin applying a series of transformations to an image
5522
+ * @param stream The image bytes
5523
+ * @returns A transform handle
5524
+ */
5525
+ input(stream: ReadableStream<Uint8Array>): ImageTransformer;
5526
+ }
5527
+ export interface ImageTransformer {
5528
+ /**
5529
+ * Apply transform next, returning a transform handle.
5530
+ * You can then apply more transformations or retrieve the output.
5531
+ * @param transform
5532
+ */
5533
+ transform(transform: ImageTransform): ImageTransformer;
5534
+ /**
5535
+ * Retrieve the image that results from applying the transforms to the
5536
+ * provided input
5537
+ * @param options Options that apply to the output e.g. output format
5538
+ */
5539
+ output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
5540
+ }
5541
+ export interface ImageTransformationResult {
5542
+ /**
5543
+ * The image as a response, ready to store in cache or return to users
5544
+ */
5545
+ response(): Response;
5546
+ /**
5547
+ * The content type of the returned image
5548
+ */
5549
+ contentType(): string;
5550
+ /**
5551
+ * The bytes of the response
5552
+ */
5553
+ image(): ReadableStream<Uint8Array>;
5554
+ }
5555
+ export interface ImagesError extends Error {
5556
+ readonly code: number;
5557
+ readonly message: string;
5558
+ readonly stack?: string;
5559
+ }
4777
5560
  export type Params<P extends string = any> = Record<P, string | string[]>;
4778
5561
  export type EventContext<Env, P extends string, Data> = {
4779
5562
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -4817,6 +5600,30 @@ export type PagesPluginFunction<
4817
5600
  > = (
4818
5601
  context: EventPluginContext<Env, Params, Data, PluginArgs>,
4819
5602
  ) => Response | Promise<Response>;
5603
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5604
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5605
+ // https://opensource.org/licenses/Apache-2.0
5606
+ export declare abstract class PipelineTransform {
5607
+ /**
5608
+ * transformJson recieves an array of javascript objects which can be
5609
+ * mutated and returned to the pipeline
5610
+ * @param data The data to be mutated
5611
+ * @returns A promise containing the mutated data
5612
+ */
5613
+ public transformJson(data: object[]): Promise<object[]>;
5614
+ }
5615
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5616
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5617
+ // https://opensource.org/licenses/Apache-2.0
5618
+ export interface Pipeline {
5619
+ /**
5620
+ * send takes an array of javascript objects which are
5621
+ * then received by the pipeline for processing
5622
+ *
5623
+ * @param data The data to be sent
5624
+ */
5625
+ send(data: object[]): Promise<void>;
5626
+ }
4820
5627
  // PubSubMessage represents an incoming PubSub message.
4821
5628
  // The message includes metadata about the broker, the client, and the payload
4822
5629
  // itself.
@@ -4877,6 +5684,7 @@ export declare namespace Rpc {
4877
5684
  export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
4878
5685
  export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
4879
5686
  export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
5687
+ export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
4880
5688
  export interface RpcTargetBranded {
4881
5689
  [__RPC_TARGET_BRAND]: never;
4882
5690
  }
@@ -4886,13 +5694,20 @@ export declare namespace Rpc {
4886
5694
  export interface DurableObjectBranded {
4887
5695
  [__DURABLE_OBJECT_BRAND]: never;
4888
5696
  }
5697
+ export interface WorkflowEntrypointBranded {
5698
+ [__WORKFLOW_ENTRYPOINT_BRAND]: never;
5699
+ }
4889
5700
  export type EntrypointBranded =
4890
5701
  | WorkerEntrypointBranded
4891
- | DurableObjectBranded;
5702
+ | DurableObjectBranded
5703
+ | WorkflowEntrypointBranded;
4892
5704
  // Types that can be used through `Stub`s
4893
5705
  export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
4894
5706
  // Types that can be passed over RPC
4895
- type Serializable =
5707
+ // The reason for using a generic type here is to build a serializable subset of structured
5708
+ // cloneable composite types. This allows types defined with the "interface" keyword to pass the
5709
+ // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
5710
+ type Serializable<T> =
4896
5711
  // Structured cloneables
4897
5712
  | void
4898
5713
  | undefined
@@ -4908,11 +5723,14 @@ export declare namespace Rpc {
4908
5723
  | Error
4909
5724
  | RegExp
4910
5725
  // Structured cloneable composites
4911
- | Map<Serializable, Serializable>
4912
- | Set<Serializable>
4913
- | ReadonlyArray<Serializable>
5726
+ | Map<
5727
+ T extends Map<infer U, unknown> ? Serializable<U> : never,
5728
+ T extends Map<unknown, infer U> ? Serializable<U> : never
5729
+ >
5730
+ | Set<T extends Set<infer U> ? Serializable<U> : never>
5731
+ | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
4914
5732
  | {
4915
- [key: string | number]: Serializable;
5733
+ [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
4916
5734
  }
4917
5735
  // Special types
4918
5736
  | ReadableStream<Uint8Array>
@@ -4942,7 +5760,7 @@ export declare namespace Rpc {
4942
5760
  : T extends ReadonlyArray<infer V>
4943
5761
  ? ReadonlyArray<Stubify<V>>
4944
5762
  : T extends {
4945
- [key: string | number]: unknown;
5763
+ [key: string | number]: any;
4946
5764
  }
4947
5765
  ? {
4948
5766
  [K in keyof T]: Stubify<T[K]>;
@@ -4985,7 +5803,7 @@ export declare namespace Rpc {
4985
5803
  // Intersecting with `(Maybe)Provider` allows pipelining.
4986
5804
  type Result<R> = R extends Stubable
4987
5805
  ? Promise<Stub<R>> & Provider<R>
4988
- : R extends Serializable
5806
+ : R extends Serializable<R>
4989
5807
  ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
4990
5808
  : never;
4991
5809
  // Type for method or property on an RPC interface.
@@ -5014,6 +5832,198 @@ export declare namespace Rpc {
5014
5832
  >]: MethodOrProperty<T[K]>;
5015
5833
  };
5016
5834
  }
5835
+ export declare namespace TailStream {
5836
+ interface Header {
5837
+ readonly name: string;
5838
+ readonly value: string;
5839
+ }
5840
+ interface FetchEventInfo {
5841
+ readonly type: "fetch";
5842
+ readonly method: string;
5843
+ readonly url: string;
5844
+ readonly cfJson: string;
5845
+ readonly headers: Header[];
5846
+ }
5847
+ interface JsRpcEventInfo {
5848
+ readonly type: "jsrpc";
5849
+ readonly methodName: string;
5850
+ }
5851
+ interface ScheduledEventInfo {
5852
+ readonly type: "scheduled";
5853
+ readonly scheduledTime: Date;
5854
+ readonly cron: string;
5855
+ }
5856
+ interface AlarmEventInfo {
5857
+ readonly type: "alarm";
5858
+ readonly scheduledTime: Date;
5859
+ }
5860
+ interface QueueEventInfo {
5861
+ readonly type: "queue";
5862
+ readonly queueName: string;
5863
+ readonly batchSize: number;
5864
+ }
5865
+ interface EmailEventInfo {
5866
+ readonly type: "email";
5867
+ readonly mailFrom: string;
5868
+ readonly rcptTo: string;
5869
+ readonly rawSize: number;
5870
+ }
5871
+ interface TraceEventInfo {
5872
+ readonly type: "trace";
5873
+ readonly traces: (string | null)[];
5874
+ }
5875
+ interface HibernatableWebSocketEventInfoMessage {
5876
+ readonly type: "message";
5877
+ }
5878
+ interface HibernatableWebSocketEventInfoError {
5879
+ readonly type: "error";
5880
+ }
5881
+ interface HibernatableWebSocketEventInfoClose {
5882
+ readonly type: "close";
5883
+ readonly code: number;
5884
+ readonly wasClean: boolean;
5885
+ }
5886
+ interface HibernatableWebSocketEventInfo {
5887
+ readonly type: "hibernatableWebSocket";
5888
+ readonly info:
5889
+ | HibernatableWebSocketEventInfoClose
5890
+ | HibernatableWebSocketEventInfoError
5891
+ | HibernatableWebSocketEventInfoMessage;
5892
+ }
5893
+ interface Resume {
5894
+ readonly type: "resume";
5895
+ readonly attachment?: any;
5896
+ }
5897
+ interface CustomEventInfo {
5898
+ readonly type: "custom";
5899
+ }
5900
+ interface FetchResponseInfo {
5901
+ readonly type: "fetch";
5902
+ readonly statusCode: number;
5903
+ }
5904
+ type EventOutcome =
5905
+ | "ok"
5906
+ | "canceled"
5907
+ | "exception"
5908
+ | "unknown"
5909
+ | "killSwitch"
5910
+ | "daemonDown"
5911
+ | "exceededCpu"
5912
+ | "exceededMemory"
5913
+ | "loadShed"
5914
+ | "responseStreamDisconnected"
5915
+ | "scriptNotFound";
5916
+ interface ScriptVersion {
5917
+ readonly id: string;
5918
+ readonly tag?: string;
5919
+ readonly message?: string;
5920
+ }
5921
+ interface Trigger {
5922
+ readonly traceId: string;
5923
+ readonly invocationId: string;
5924
+ readonly spanId: string;
5925
+ }
5926
+ interface Onset {
5927
+ readonly type: "onset";
5928
+ readonly dispatchNamespace?: string;
5929
+ readonly entrypoint?: string;
5930
+ readonly scriptName?: string;
5931
+ readonly scriptTags?: string[];
5932
+ readonly scriptVersion?: ScriptVersion;
5933
+ readonly trigger?: Trigger;
5934
+ readonly info:
5935
+ | FetchEventInfo
5936
+ | JsRpcEventInfo
5937
+ | ScheduledEventInfo
5938
+ | AlarmEventInfo
5939
+ | QueueEventInfo
5940
+ | EmailEventInfo
5941
+ | TraceEventInfo
5942
+ | HibernatableWebSocketEventInfo
5943
+ | Resume
5944
+ | CustomEventInfo;
5945
+ }
5946
+ interface Outcome {
5947
+ readonly type: "outcome";
5948
+ readonly outcome: EventOutcome;
5949
+ readonly cpuTime: number;
5950
+ readonly wallTime: number;
5951
+ }
5952
+ interface Hibernate {
5953
+ readonly type: "hibernate";
5954
+ }
5955
+ interface SpanOpen {
5956
+ readonly type: "spanOpen";
5957
+ readonly op?: string;
5958
+ readonly info?: FetchEventInfo | JsRpcEventInfo | Attribute[];
5959
+ }
5960
+ interface SpanClose {
5961
+ readonly type: "spanClose";
5962
+ readonly outcome: EventOutcome;
5963
+ }
5964
+ interface DiagnosticChannelEvent {
5965
+ readonly type: "diagnosticChannel";
5966
+ readonly channel: string;
5967
+ readonly message: any;
5968
+ }
5969
+ interface Exception {
5970
+ readonly type: "exception";
5971
+ readonly name: string;
5972
+ readonly message: string;
5973
+ readonly stack?: string;
5974
+ }
5975
+ interface Log {
5976
+ readonly type: "log";
5977
+ readonly level: "debug" | "error" | "info" | "log" | "warn";
5978
+ readonly message: string;
5979
+ }
5980
+ interface Return {
5981
+ readonly type: "return";
5982
+ readonly info?: FetchResponseInfo | Attribute[];
5983
+ }
5984
+ interface Link {
5985
+ readonly type: "link";
5986
+ readonly label?: string;
5987
+ readonly traceId: string;
5988
+ readonly invocationId: string;
5989
+ readonly spanId: string;
5990
+ }
5991
+ interface Attribute {
5992
+ readonly type: "attribute";
5993
+ readonly name: string;
5994
+ readonly value: string | string[] | boolean | boolean[] | number | number[];
5995
+ }
5996
+ type Mark =
5997
+ | DiagnosticChannelEvent
5998
+ | Exception
5999
+ | Log
6000
+ | Return
6001
+ | Link
6002
+ | Attribute[];
6003
+ interface TailEvent {
6004
+ readonly traceId: string;
6005
+ readonly invocationId: string;
6006
+ readonly spanId: string;
6007
+ readonly timestamp: Date;
6008
+ readonly sequence: number;
6009
+ readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | Mark;
6010
+ }
6011
+ type TailEventHandler = (event: TailEvent) => void | Promise<void>;
6012
+ type TailEventHandlerName =
6013
+ | "onset"
6014
+ | "outcome"
6015
+ | "hibernate"
6016
+ | "spanOpen"
6017
+ | "spanClose"
6018
+ | "diagnosticChannel"
6019
+ | "exception"
6020
+ | "log"
6021
+ | "return"
6022
+ | "link"
6023
+ | "attribute";
6024
+ type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
6025
+ type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
6026
+ }
5017
6027
  // Copyright (c) 2022-2023 Cloudflare, Inc.
5018
6028
  // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5019
6029
  // https://opensource.org/licenses/Apache-2.0
@@ -5057,11 +6067,21 @@ export type VectorizeVectorMetadataFilter = {
5057
6067
  * Distance metrics determine how other "similar" vectors are determined.
5058
6068
  */
5059
6069
  export type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
6070
+ /**
6071
+ * Metadata return levels for a Vectorize query.
6072
+ *
6073
+ * Default to "none".
6074
+ *
6075
+ * @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.
6076
+ * @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).
6077
+ * @property none No indexed metadata will be returned.
6078
+ */
6079
+ export type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
5060
6080
  export interface VectorizeQueryOptions {
5061
6081
  topK?: number;
5062
6082
  namespace?: string;
5063
6083
  returnValues?: boolean;
5064
- returnMetadata?: boolean;
6084
+ returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
5065
6085
  filter?: VectorizeVectorMetadataFilter;
5066
6086
  }
5067
6087
  /**
@@ -5077,6 +6097,9 @@ export type VectorizeIndexConfig =
5077
6097
  };
5078
6098
  /**
5079
6099
  * Metadata about an existing index.
6100
+ *
6101
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6102
+ * See {@link VectorizeIndexInfo} for its post-beta equivalent.
5080
6103
  */
5081
6104
  export interface VectorizeIndexDetails {
5082
6105
  /** The unique ID of the index */
@@ -5090,6 +6113,19 @@ export interface VectorizeIndexDetails {
5090
6113
  /** The number of records containing vectors within the index. */
5091
6114
  vectorsCount: number;
5092
6115
  }
6116
+ /**
6117
+ * Metadata about an existing index.
6118
+ */
6119
+ export interface VectorizeIndexInfo {
6120
+ /** The number of records containing vectors within the index. */
6121
+ vectorCount: number;
6122
+ /** Number of dimensions the index has been configured for. */
6123
+ dimensions: number;
6124
+ /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
6125
+ processedUpToDatetime: number;
6126
+ /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
6127
+ processedUpToMutation: number;
6128
+ }
5093
6129
  /**
5094
6130
  * Represents a single vector value set along with its associated metadata.
5095
6131
  */
@@ -5100,7 +6136,7 @@ export interface VectorizeVector {
5100
6136
  values: VectorFloatArray | number[];
5101
6137
  /** The namespace this vector belongs to. */
5102
6138
  namespace?: string;
5103
- /** Metadata associated with the vector. Includes the values of the other fields and potentially additional details. */
6139
+ /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
5104
6140
  metadata?: Record<string, VectorizeVectorMetadata>;
5105
6141
  }
5106
6142
  /**
@@ -5112,7 +6148,7 @@ export type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
5112
6148
  score: number;
5113
6149
  };
5114
6150
  /**
5115
- * A set of vector {@link VectorizeMatch} for a particular query.
6151
+ * A set of matching {@link VectorizeMatch} for a particular query.
5116
6152
  */
5117
6153
  export interface VectorizeMatches {
5118
6154
  matches: VectorizeMatch[];
@@ -5121,6 +6157,9 @@ export interface VectorizeMatches {
5121
6157
  /**
5122
6158
  * Results of an operation that performed a mutation on a set of vectors.
5123
6159
  * Here, `ids` is a list of vectors that were successfully processed.
6160
+ *
6161
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6162
+ * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
5124
6163
  */
5125
6164
  export interface VectorizeVectorMutation {
5126
6165
  /* List of ids of vectors that were successfully processed. */
@@ -5129,14 +6168,19 @@ export interface VectorizeVectorMutation {
5129
6168
  count: number;
5130
6169
  }
5131
6170
  /**
5132
- * Results of an operation that performed a mutation on a set of vectors
5133
- * with the v2 version of Vectorize.
5134
- * Here, `mutationId` is the identifier for the last mutation processed by Vectorize.
6171
+ * Result type indicating a mutation on the Vectorize Index.
6172
+ * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
5135
6173
  */
5136
- export interface VectorizeVectorMutationV2 {
5137
- /* The identifier for the last mutation processed by Vectorize. */
6174
+ export interface VectorizeAsyncMutation {
6175
+ /** The unique identifier for the async mutation operation containing the changeset. */
5138
6176
  mutationId: string;
5139
6177
  }
6178
+ /**
6179
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6180
+ *
6181
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6182
+ * See {@link Vectorize} for its new implementation.
6183
+ */
5140
6184
  export declare abstract class VectorizeIndex {
5141
6185
  /**
5142
6186
  * Get information about the currently bound index.
@@ -5151,7 +6195,7 @@ export declare abstract class VectorizeIndex {
5151
6195
  */
5152
6196
  public query(
5153
6197
  vector: VectorFloatArray | number[],
5154
- options: VectorizeQueryOptions,
6198
+ options?: VectorizeQueryOptions,
5155
6199
  ): Promise<VectorizeMatches>;
5156
6200
  /**
5157
6201
  * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
@@ -5178,6 +6222,62 @@ export declare abstract class VectorizeIndex {
5178
6222
  */
5179
6223
  public getByIds(ids: string[]): Promise<VectorizeVector[]>;
5180
6224
  }
6225
+ /**
6226
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6227
+ *
6228
+ * Mutations in this version are async, returning a mutation id.
6229
+ */
6230
+ export declare abstract class Vectorize {
6231
+ /**
6232
+ * Get information about the currently bound index.
6233
+ * @returns A promise that resolves with information about the current index.
6234
+ */
6235
+ public describe(): Promise<VectorizeIndexInfo>;
6236
+ /**
6237
+ * Use the provided vector to perform a similarity search across the index.
6238
+ * @param vector Input vector that will be used to drive the similarity search.
6239
+ * @param options Configuration options to massage the returned data.
6240
+ * @returns A promise that resolves with matched and scored vectors.
6241
+ */
6242
+ public query(
6243
+ vector: VectorFloatArray | number[],
6244
+ options?: VectorizeQueryOptions,
6245
+ ): Promise<VectorizeMatches>;
6246
+ /**
6247
+ * Use the provided vector-id to perform a similarity search across the index.
6248
+ * @param vectorId Id for a vector in the index against which the index should be queried.
6249
+ * @param options Configuration options to massage the returned data.
6250
+ * @returns A promise that resolves with matched and scored vectors.
6251
+ */
6252
+ public queryById(
6253
+ vectorId: string,
6254
+ options?: VectorizeQueryOptions,
6255
+ ): Promise<VectorizeMatches>;
6256
+ /**
6257
+ * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
6258
+ * @param vectors List of vectors that will be inserted.
6259
+ * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
6260
+ */
6261
+ public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6262
+ /**
6263
+ * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
6264
+ * @param vectors List of vectors that will be upserted.
6265
+ * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
6266
+ */
6267
+ public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6268
+ /**
6269
+ * Delete a list of vectors with a matching id.
6270
+ * @param ids List of vector ids that should be deleted.
6271
+ * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
6272
+ */
6273
+ public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
6274
+ /**
6275
+ * Get a list of vectors with a matching id.
6276
+ * @param ids List of vector ids that should be returned.
6277
+ * @returns A promise that resolves with the raw unscored vectors matching the id set.
6278
+ */
6279
+ public getByIds(ids: string[]): Promise<VectorizeVector[]>;
6280
+ }
5181
6281
  /**
5182
6282
  * The interface for "version_metadata" binding
5183
6283
  * providing metadata about the Worker Version using this binding.
@@ -5228,3 +6328,70 @@ export interface DispatchNamespace {
5228
6328
  options?: DynamicDispatchOptions,
5229
6329
  ): Fetcher;
5230
6330
  }
6331
+ export declare abstract class Workflow<PARAMS = unknown> {
6332
+ /**
6333
+ * Get a handle to an existing instance of the Workflow.
6334
+ * @param id Id for the instance of this Workflow
6335
+ * @returns A promise that resolves with a handle for the Instance
6336
+ */
6337
+ public get(id: string): Promise<WorkflowInstance>;
6338
+ /**
6339
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
6340
+ * @param options Options when creating an instance including id and params
6341
+ * @returns A promise that resolves with a handle for the Instance
6342
+ */
6343
+ public create(
6344
+ options?: WorkflowInstanceCreateOptions<PARAMS>,
6345
+ ): Promise<WorkflowInstance>;
6346
+ }
6347
+ export interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
6348
+ /**
6349
+ * An id for your Workflow instance. Must be unique within the Workflow.
6350
+ */
6351
+ id?: string;
6352
+ /**
6353
+ * The event payload the Workflow instance is triggered with
6354
+ */
6355
+ params?: PARAMS;
6356
+ }
6357
+ export type InstanceStatus = {
6358
+ status:
6359
+ | "queued" // means that instance is waiting to be started (see concurrency limits)
6360
+ | "running"
6361
+ | "paused"
6362
+ | "errored"
6363
+ | "terminated" // user terminated the instance while it was running
6364
+ | "complete"
6365
+ | "waiting" // instance is hibernating and waiting for sleep or event to finish
6366
+ | "waitingForPause" // instance is finishing the current work to pause
6367
+ | "unknown";
6368
+ error?: string;
6369
+ output?: object;
6370
+ };
6371
+ export interface WorkflowError {
6372
+ code?: number;
6373
+ message: string;
6374
+ }
6375
+ export declare abstract class WorkflowInstance {
6376
+ public id: string;
6377
+ /**
6378
+ * Pause the instance.
6379
+ */
6380
+ public pause(): Promise<void>;
6381
+ /**
6382
+ * Resume the instance. If it is already running, an error will be thrown.
6383
+ */
6384
+ public resume(): Promise<void>;
6385
+ /**
6386
+ * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
6387
+ */
6388
+ public terminate(): Promise<void>;
6389
+ /**
6390
+ * Restart the instance.
6391
+ */
6392
+ public restart(): Promise<void>;
6393
+ /**
6394
+ * Returns the current status of the instance.
6395
+ */
6396
+ public status(): Promise<InstanceStatus>;
6397
+ }