@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
+ 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 @@ 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 @@ 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;
@@ -364,7 +366,7 @@ declare function structuredClone<T>(
364
366
  declare function reportError(error: any): void;
365
367
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/fetch) */
366
368
  declare function fetch(
367
- input: RequestInfo,
369
+ input: RequestInfo | URL,
368
370
  init?: RequestInit<RequestInitCfProperties>,
369
371
  ): Promise<Response>;
370
372
  declare const self: ServiceWorkerGlobalScope;
@@ -391,12 +393,14 @@ declare const scheduler: Scheduler;
391
393
  * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
392
394
  */
393
395
  declare const performance: Performance;
396
+ declare const Cloudflare: Cloudflare;
394
397
  declare const origin: string;
395
398
  declare const navigator: Navigator;
396
399
  interface TestController {}
397
400
  interface ExecutionContext {
398
401
  waitUntil(promise: Promise<any>): void;
399
402
  passThroughOnException(): void;
403
+ props: any;
400
404
  abort(reason?: any): void;
401
405
  }
402
406
  type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
@@ -414,6 +418,11 @@ type ExportedHandlerTraceHandler<Env = unknown> = (
414
418
  env: Env,
415
419
  ctx: ExecutionContext,
416
420
  ) => void | Promise<void>;
421
+ type ExportedHandlerTailStreamHandler<Env = unknown> = (
422
+ event: TailStream.TailEvent,
423
+ env: Env,
424
+ ctx: ExecutionContext,
425
+ ) => TailStream.TailEventHandlerType | Promise<TailStream.TailEventHandlerType>;
417
426
  type ExportedHandlerScheduledHandler<Env = unknown> = (
418
427
  controller: ScheduledController,
419
428
  env: Env,
@@ -437,6 +446,7 @@ interface ExportedHandler<
437
446
  fetch?: ExportedHandlerFetchHandler<Env, CfHostMetadata>;
438
447
  tail?: ExportedHandlerTailHandler<Env>;
439
448
  trace?: ExportedHandlerTraceHandler<Env>;
449
+ tailStream?: ExportedHandlerTailStreamHandler<Env>;
440
450
  scheduled?: ExportedHandlerScheduledHandler<Env>;
441
451
  test?: ExportedHandlerTestHandler<Env>;
442
452
  email?: EmailExportedHandler<Env>;
@@ -460,8 +470,9 @@ declare abstract class Navigator {
460
470
  | string
461
471
  | (ArrayBuffer | ArrayBufferView)
462
472
  | Blob
473
+ | FormData
463
474
  | URLSearchParams
464
- | FormData,
475
+ | URLSearchParams,
465
476
  ): boolean;
466
477
  readonly userAgent: string;
467
478
  readonly gpu: GPU;
@@ -482,9 +493,12 @@ interface AlarmInvocationInfo {
482
493
  readonly isRetry: boolean;
483
494
  readonly retryCount: number;
484
495
  }
496
+ interface Cloudflare {
497
+ readonly compatibilityFlags: Record<string, boolean>;
498
+ }
485
499
  interface DurableObject {
486
500
  fetch(request: Request): Response | Promise<Response>;
487
- alarm?(): void | Promise<void>;
501
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
488
502
  webSocketMessage?(
489
503
  ws: WebSocket,
490
504
  message: string | ArrayBuffer,
@@ -633,6 +647,9 @@ interface DurableObjectStorage {
633
647
  getCurrentBookmark(): Promise<string>;
634
648
  getBookmarkForTime(timestamp: number | Date): Promise<string>;
635
649
  onNextSessionRestoreBookmark(bookmark: string): Promise<string>;
650
+ waitForBookmark(bookmark: string): Promise<void>;
651
+ readonly primary?: DurableObjectStub;
652
+ ensureReplicas(): void;
636
653
  }
637
654
  interface DurableObjectListOptions {
638
655
  start?: string;
@@ -1003,14 +1020,17 @@ declare abstract class CacheStorage {
1003
1020
  */
1004
1021
  declare abstract class Cache {
1005
1022
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#delete) */
1006
- delete(request: RequestInfo, options?: CacheQueryOptions): Promise<boolean>;
1023
+ delete(
1024
+ request: RequestInfo | URL,
1025
+ options?: CacheQueryOptions,
1026
+ ): Promise<boolean>;
1007
1027
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#match) */
1008
1028
  match(
1009
- request: RequestInfo,
1029
+ request: RequestInfo | URL,
1010
1030
  options?: CacheQueryOptions,
1011
1031
  ): Promise<Response | undefined>;
1012
1032
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/cache/#put) */
1013
- put(request: RequestInfo, response: Response): Promise<void>;
1033
+ put(request: RequestInfo | URL, response: Response): Promise<void>;
1014
1034
  }
1015
1035
  interface CacheQueryOptions {
1016
1036
  ignoreMethod?: boolean;
@@ -1433,20 +1453,44 @@ interface Element {
1433
1453
  hasAttribute(name: string): boolean;
1434
1454
  setAttribute(name: string, value: string): Element;
1435
1455
  removeAttribute(name: string): Element;
1436
- before(content: string, options?: ContentOptions): Element;
1437
- after(content: string, options?: ContentOptions): Element;
1438
- prepend(content: string, options?: ContentOptions): Element;
1439
- append(content: string, options?: ContentOptions): Element;
1440
- replace(content: string, options?: ContentOptions): Element;
1456
+ before(
1457
+ content: string | ReadableStream | Response,
1458
+ options?: ContentOptions,
1459
+ ): Element;
1460
+ after(
1461
+ content: string | ReadableStream | Response,
1462
+ options?: ContentOptions,
1463
+ ): Element;
1464
+ prepend(
1465
+ content: string | ReadableStream | Response,
1466
+ options?: ContentOptions,
1467
+ ): Element;
1468
+ append(
1469
+ content: string | ReadableStream | Response,
1470
+ options?: ContentOptions,
1471
+ ): Element;
1472
+ replace(
1473
+ content: string | ReadableStream | Response,
1474
+ options?: ContentOptions,
1475
+ ): Element;
1441
1476
  remove(): Element;
1442
1477
  removeAndKeepContent(): Element;
1443
- setInnerContent(content: string, options?: ContentOptions): Element;
1478
+ setInnerContent(
1479
+ content: string | ReadableStream | Response,
1480
+ options?: ContentOptions,
1481
+ ): Element;
1444
1482
  onEndTag(handler: (tag: EndTag) => void | Promise<void>): void;
1445
1483
  }
1446
1484
  interface EndTag {
1447
1485
  name: string;
1448
- before(content: string, options?: ContentOptions): EndTag;
1449
- after(content: string, options?: ContentOptions): EndTag;
1486
+ before(
1487
+ content: string | ReadableStream | Response,
1488
+ options?: ContentOptions,
1489
+ ): EndTag;
1490
+ after(
1491
+ content: string | ReadableStream | Response,
1492
+ options?: ContentOptions,
1493
+ ): EndTag;
1450
1494
  remove(): EndTag;
1451
1495
  }
1452
1496
  interface Comment {
@@ -1461,9 +1505,18 @@ interface Text {
1461
1505
  readonly text: string;
1462
1506
  readonly lastInTextNode: boolean;
1463
1507
  readonly removed: boolean;
1464
- before(content: string, options?: ContentOptions): Text;
1465
- after(content: string, options?: ContentOptions): Text;
1466
- replace(content: string, options?: ContentOptions): Text;
1508
+ before(
1509
+ content: string | ReadableStream | Response,
1510
+ options?: ContentOptions,
1511
+ ): Text;
1512
+ after(
1513
+ content: string | ReadableStream | Response,
1514
+ options?: ContentOptions,
1515
+ ): Text;
1516
+ replace(
1517
+ content: string | ReadableStream | Response,
1518
+ options?: ContentOptions,
1519
+ ): Text;
1467
1520
  remove(): Text;
1468
1521
  }
1469
1522
  interface DocumentEnd {
@@ -1547,28 +1600,34 @@ declare abstract class Body {
1547
1600
  *
1548
1601
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1549
1602
  */
1550
- declare class Response extends Body {
1551
- constructor(body?: BodyInit | null, init?: ResponseInit);
1552
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirect_static) */
1553
- static redirect(url: string, status?: number): Response;
1554
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/json_static) */
1555
- static json(any: any, maybeInit?: ResponseInit | Response): Response;
1603
+ declare var Response: {
1604
+ prototype: Response;
1605
+ new (body?: BodyInit | null, init?: ResponseInit): Response;
1606
+ redirect(url: string, status?: number): Response;
1607
+ json(any: any, maybeInit?: ResponseInit | Response): Response;
1608
+ };
1609
+ /**
1610
+ * This Fetch API interface represents the response to a request.
1611
+ *
1612
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response)
1613
+ */
1614
+ interface Response extends Body {
1556
1615
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/clone) */
1557
1616
  clone(): Response;
1558
1617
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status) */
1559
- get status(): number;
1618
+ status: number;
1560
1619
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText) */
1561
- get statusText(): string;
1620
+ statusText: string;
1562
1621
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/headers) */
1563
- get headers(): Headers;
1622
+ headers: Headers;
1564
1623
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/ok) */
1565
- get ok(): boolean;
1624
+ ok: boolean;
1566
1625
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/redirected) */
1567
- get redirected(): boolean;
1626
+ redirected: boolean;
1568
1627
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/url) */
1569
- get url(): string;
1570
- get webSocket(): WebSocket | null;
1571
- get cf(): any | undefined;
1628
+ url: string;
1629
+ webSocket: WebSocket | null;
1630
+ cf: any | undefined;
1572
1631
  }
1573
1632
  interface ResponseInit {
1574
1633
  status?: number;
@@ -1580,18 +1639,26 @@ interface ResponseInit {
1580
1639
  }
1581
1640
  type RequestInfo<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>> =
1582
1641
  | Request<CfHostMetadata, Cf>
1583
- | string
1584
- | URL;
1642
+ | string;
1585
1643
  /**
1586
1644
  * This Fetch API interface represents a resource request.
1587
1645
  *
1588
1646
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1589
1647
  */
1590
- declare class Request<
1591
- CfHostMetadata = unknown,
1592
- Cf = CfProperties<CfHostMetadata>,
1593
- > extends Body {
1594
- constructor(input: RequestInfo<CfProperties>, init?: RequestInit<Cf>);
1648
+ declare var Request: {
1649
+ prototype: Request;
1650
+ new <CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>(
1651
+ input: RequestInfo<CfProperties> | URL,
1652
+ init?: RequestInit<Cf>,
1653
+ ): Request<CfHostMetadata, Cf>;
1654
+ };
1655
+ /**
1656
+ * This Fetch API interface represents a resource request.
1657
+ *
1658
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request)
1659
+ */
1660
+ interface Request<CfHostMetadata = unknown, Cf = CfProperties<CfHostMetadata>>
1661
+ extends Body {
1595
1662
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/clone) */
1596
1663
  clone(): Request<CfHostMetadata, Cf>;
1597
1664
  /**
@@ -1599,45 +1666,51 @@ declare class Request<
1599
1666
  *
1600
1667
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/method)
1601
1668
  */
1602
- get method(): string;
1669
+ method: string;
1603
1670
  /**
1604
1671
  * Returns the URL of request as a string.
1605
1672
  *
1606
1673
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/url)
1607
1674
  */
1608
- get url(): string;
1675
+ url: string;
1609
1676
  /**
1610
1677
  * 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.
1611
1678
  *
1612
1679
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/headers)
1613
1680
  */
1614
- get headers(): Headers;
1681
+ headers: Headers;
1615
1682
  /**
1616
1683
  * 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.
1617
1684
  *
1618
1685
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/redirect)
1619
1686
  */
1620
- get redirect(): string;
1621
- get fetcher(): Fetcher | null;
1687
+ redirect: string;
1688
+ fetcher: Fetcher | null;
1622
1689
  /**
1623
1690
  * Returns the signal associated with request, which is an AbortSignal object indicating whether or not request has been aborted, and its abort event handler.
1624
1691
  *
1625
1692
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/signal)
1626
1693
  */
1627
- get signal(): AbortSignal;
1628
- get cf(): Cf | undefined;
1694
+ signal: AbortSignal;
1695
+ cf: Cf | undefined;
1629
1696
  /**
1630
1697
  * 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]
1631
1698
  *
1632
1699
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/integrity)
1633
1700
  */
1634
- get integrity(): string;
1701
+ integrity: string;
1635
1702
  /**
1636
1703
  * Returns a boolean indicating whether or not request can outlive the global in which it was created.
1637
1704
  *
1638
1705
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/keepalive)
1639
1706
  */
1640
- get keepalive(): boolean;
1707
+ keepalive: boolean;
1708
+ /**
1709
+ * Returns the cache mode associated with request, which is a string indicating how the request will interact with the browser's cache when fetching.
1710
+ *
1711
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/cache)
1712
+ */
1713
+ cache?: "no-store" | "no-cache";
1641
1714
  }
1642
1715
  interface RequestInit<Cf = CfProperties> {
1643
1716
  /* A string to set request's method. */
@@ -1650,6 +1723,8 @@ interface RequestInit<Cf = CfProperties> {
1650
1723
  redirect?: string;
1651
1724
  fetcher?: Fetcher | null;
1652
1725
  cf?: Cf;
1726
+ /* A string indicating how the request will interact with the browser's cache to set request's cache. */
1727
+ cache?: "no-store" | "no-cache";
1653
1728
  /* A cryptographic hash of the resource to be fetched by request. Sets request's integrity. */
1654
1729
  integrity?: string;
1655
1730
  /* An AbortSignal to set request's signal. */
@@ -1663,7 +1738,7 @@ type Fetcher<
1663
1738
  > = (T extends Rpc.EntrypointBranded
1664
1739
  ? Rpc.Provider<T, Reserved | "fetch" | "connect" | "queue" | "scheduled">
1665
1740
  : unknown) & {
1666
- fetch(input: RequestInfo, init?: RequestInit): Promise<Response>;
1741
+ fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
1667
1742
  connect(address: SocketAddress | string, options?: SocketOptions): Socket;
1668
1743
  queue(
1669
1744
  queueName: string,
@@ -1921,6 +1996,7 @@ interface R2MultipartUpload {
1921
1996
  uploadPart(
1922
1997
  partNumber: number,
1923
1998
  value: ReadableStream | (ArrayBuffer | ArrayBufferView) | string | Blob,
1999
+ options?: R2UploadPartOptions,
1924
2000
  ): Promise<R2UploadedPart>;
1925
2001
  abort(): Promise<void>;
1926
2002
  complete(uploadedParts: R2UploadedPart[]): Promise<R2Object>;
@@ -1941,6 +2017,7 @@ declare abstract class R2Object {
1941
2017
  readonly customMetadata?: Record<string, string>;
1942
2018
  readonly range?: R2Range;
1943
2019
  readonly storageClass: string;
2020
+ readonly ssecKeyMd5?: string;
1944
2021
  writeHttpMetadata(headers: Headers): void;
1945
2022
  }
1946
2023
  interface R2ObjectBody extends R2Object {
@@ -1973,6 +2050,7 @@ interface R2Conditional {
1973
2050
  interface R2GetOptions {
1974
2051
  onlyIf?: R2Conditional | Headers;
1975
2052
  range?: R2Range | Headers;
2053
+ ssecKey?: ArrayBuffer | string;
1976
2054
  }
1977
2055
  interface R2PutOptions {
1978
2056
  onlyIf?: R2Conditional | Headers;
@@ -1984,11 +2062,13 @@ interface R2PutOptions {
1984
2062
  sha384?: ArrayBuffer | string;
1985
2063
  sha512?: ArrayBuffer | string;
1986
2064
  storageClass?: string;
2065
+ ssecKey?: ArrayBuffer | string;
1987
2066
  }
1988
2067
  interface R2MultipartOptions {
1989
2068
  httpMetadata?: R2HTTPMetadata | Headers;
1990
2069
  customMetadata?: Record<string, string>;
1991
2070
  storageClass?: string;
2071
+ ssecKey?: ArrayBuffer | string;
1992
2072
  }
1993
2073
  interface R2Checksums {
1994
2074
  readonly md5?: ArrayBuffer;
@@ -2025,6 +2105,9 @@ type R2Objects = {
2025
2105
  truncated: false;
2026
2106
  }
2027
2107
  );
2108
+ interface R2UploadPartOptions {
2109
+ ssecKey?: ArrayBuffer | string;
2110
+ }
2028
2111
  declare abstract class JsRpcProperty {
2029
2112
  then(handler: Function, errorHandler?: Function): any;
2030
2113
  catch(errorHandler: Function): any;
@@ -2432,6 +2515,7 @@ interface TraceItem {
2432
2515
  | null;
2433
2516
  readonly eventTimestamp: number | null;
2434
2517
  readonly logs: TraceLog[];
2518
+ readonly spans: OTelSpan[];
2435
2519
  readonly exceptions: TraceException[];
2436
2520
  readonly diagnosticsChannelEvents: TraceDiagnosticChannelEvent[];
2437
2521
  readonly scriptName: string | null;
@@ -2440,6 +2524,8 @@ interface TraceItem {
2440
2524
  readonly dispatchNamespace?: string;
2441
2525
  readonly scriptTags?: string[];
2442
2526
  readonly outcome: string;
2527
+ readonly executionModel: string;
2528
+ readonly truncated: boolean;
2443
2529
  }
2444
2530
  interface TraceItemAlarmEventInfo {
2445
2531
  readonly scheduledTime: Date;
@@ -2503,6 +2589,18 @@ interface TraceLog {
2503
2589
  readonly level: string;
2504
2590
  readonly message: any;
2505
2591
  }
2592
+ interface OTelSpan {
2593
+ readonly spanId: string;
2594
+ readonly parentSpanId: string;
2595
+ readonly operation: string;
2596
+ readonly tags: OTelSpanTag[];
2597
+ readonly startTime: Date;
2598
+ readonly endTime: Date;
2599
+ }
2600
+ interface OTelSpanTag {
2601
+ key: string;
2602
+ value: boolean | (number | bigint) | number | string;
2603
+ }
2506
2604
  interface TraceException {
2507
2605
  readonly timestamp: number;
2508
2606
  readonly message: string;
@@ -2579,6 +2677,10 @@ declare class URL {
2579
2677
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/canParse_static) */
2580
2678
  static canParse(url: string, base?: string): boolean;
2581
2679
  static parse(url: string, base?: string): URL | null;
2680
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/createObjectURL_static) */
2681
+ static createObjectURL(object: File | Blob): string;
2682
+ /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URL/revokeObjectURL_static) */
2683
+ static revokeObjectURL(object_url: string): void;
2582
2684
  }
2583
2685
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/URLSearchParams) */
2584
2686
  declare class URLSearchParams {
@@ -2752,8 +2854,24 @@ type WebSocketEventMap = {
2752
2854
  *
2753
2855
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2754
2856
  */
2755
- declare class WebSocket extends EventTarget<WebSocketEventMap> {
2756
- constructor(url: string, protocols?: string[] | string);
2857
+ declare var WebSocket: {
2858
+ prototype: WebSocket;
2859
+ new (url: string, protocols?: string[] | string): WebSocket;
2860
+ readonly READY_STATE_CONNECTING: number;
2861
+ readonly CONNECTING: number;
2862
+ readonly READY_STATE_OPEN: number;
2863
+ readonly OPEN: number;
2864
+ readonly READY_STATE_CLOSING: number;
2865
+ readonly CLOSING: number;
2866
+ readonly READY_STATE_CLOSED: number;
2867
+ readonly CLOSED: number;
2868
+ };
2869
+ /**
2870
+ * Provides the API for creating and managing a WebSocket connection to a server, as well as for sending and receiving data on the connection.
2871
+ *
2872
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket)
2873
+ */
2874
+ interface WebSocket extends EventTarget<WebSocketEventMap> {
2757
2875
  accept(): void;
2758
2876
  /**
2759
2877
  * Transmits data using the WebSocket connection. data can be a string, a Blob, an ArrayBuffer, or an ArrayBufferView.
@@ -2769,38 +2887,30 @@ declare class WebSocket extends EventTarget<WebSocketEventMap> {
2769
2887
  close(code?: number, reason?: string): void;
2770
2888
  serializeAttachment(attachment: any): void;
2771
2889
  deserializeAttachment(): any | null;
2772
- static readonly READY_STATE_CONNECTING: number;
2773
- static readonly CONNECTING: number;
2774
- static readonly READY_STATE_OPEN: number;
2775
- static readonly OPEN: number;
2776
- static readonly READY_STATE_CLOSING: number;
2777
- static readonly CLOSING: number;
2778
- static readonly READY_STATE_CLOSED: number;
2779
- static readonly CLOSED: number;
2780
2890
  /**
2781
2891
  * Returns the state of the WebSocket object's connection. It can have the values described below.
2782
2892
  *
2783
2893
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/readyState)
2784
2894
  */
2785
- get readyState(): number;
2895
+ readyState: number;
2786
2896
  /**
2787
2897
  * Returns the URL that was used to establish the WebSocket connection.
2788
2898
  *
2789
2899
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/url)
2790
2900
  */
2791
- get url(): string | null;
2901
+ url: string | null;
2792
2902
  /**
2793
2903
  * 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.
2794
2904
  *
2795
2905
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/protocol)
2796
2906
  */
2797
- get protocol(): string | null;
2907
+ protocol: string | null;
2798
2908
  /**
2799
2909
  * Returns the extensions selected by the server, if any.
2800
2910
  *
2801
2911
  * [MDN Reference](https://developer.mozilla.org/docs/Web/API/WebSocket/extensions)
2802
2912
  */
2803
- get extensions(): string | null;
2913
+ extensions: string | null;
2804
2914
  }
2805
2915
  declare const WebSocketPair: {
2806
2916
  new (): {
@@ -2809,7 +2919,10 @@ declare const WebSocketPair: {
2809
2919
  };
2810
2920
  };
2811
2921
  interface SqlStorage {
2812
- exec(query: string, ...bindings: any[]): SqlStorageCursor;
2922
+ exec<T extends Record<string, SqlStorageValue>>(
2923
+ query: string,
2924
+ ...bindings: any[]
2925
+ ): SqlStorageCursor<T>;
2813
2926
  prepare(query: string): SqlStorageStatement;
2814
2927
  ingest(query: string): SqlStorageIngestResult;
2815
2928
  get databaseSize(): number;
@@ -2817,14 +2930,27 @@ interface SqlStorage {
2817
2930
  Statement: typeof SqlStorageStatement;
2818
2931
  }
2819
2932
  declare abstract class SqlStorageStatement {}
2820
- declare abstract class SqlStorageCursor {
2821
- raw(): IterableIterator<((ArrayBuffer | string | number) | null)[]>;
2822
- get columnNames(): string[];
2933
+ type SqlStorageValue = ArrayBuffer | string | number | null;
2934
+ declare abstract class SqlStorageCursor<
2935
+ T extends Record<string, SqlStorageValue>,
2936
+ > {
2937
+ next():
2938
+ | {
2939
+ done?: false;
2940
+ value: T;
2941
+ }
2942
+ | {
2943
+ done: true;
2944
+ value?: never;
2945
+ };
2946
+ toArray(): T[];
2947
+ one(): T;
2948
+ raw<U extends SqlStorageValue[]>(): IterableIterator<U>;
2949
+ columnNames: string[];
2823
2950
  get rowsRead(): number;
2824
2951
  get rowsWritten(): number;
2825
- [Symbol.iterator](): IterableIterator<
2826
- Record<string, (ArrayBuffer | string | number) | null>
2827
- >;
2952
+ get reusedCachedQueryForTest(): boolean;
2953
+ [Symbol.iterator](): IterableIterator<T>;
2828
2954
  }
2829
2955
  interface SqlStorageIngestResult {
2830
2956
  remainder: string;
@@ -3369,7 +3495,7 @@ interface GPUOrigin3DDict {
3369
3495
  z?: number;
3370
3496
  }
3371
3497
  /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource) */
3372
- declare class EventSource {
3498
+ declare class EventSource extends EventTarget {
3373
3499
  constructor(url: string, init?: EventSourceEventSourceInit);
3374
3500
  /**
3375
3501
  * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
@@ -3468,10 +3594,10 @@ declare abstract class BaseAiSentenceSimilarity {
3468
3594
  inputs: AiSentenceSimilarityInput;
3469
3595
  postProcessedOutputs: AiSentenceSimilarityOutput;
3470
3596
  }
3471
- type AiSpeechRecognitionInput = {
3597
+ type AiAutomaticSpeechRecognitionInput = {
3472
3598
  audio: number[];
3473
3599
  };
3474
- type AiSpeechRecognitionOutput = {
3600
+ type AiAutomaticSpeechRecognitionOutput = {
3475
3601
  text?: string;
3476
3602
  words?: {
3477
3603
  word: string;
@@ -3480,9 +3606,9 @@ type AiSpeechRecognitionOutput = {
3480
3606
  }[];
3481
3607
  vtt?: string;
3482
3608
  };
3483
- declare abstract class BaseAiSpeechRecognition {
3484
- inputs: AiSpeechRecognitionInput;
3485
- postProcessedOutputs: AiSpeechRecognitionOutput;
3609
+ declare abstract class BaseAiAutomaticSpeechRecognition {
3610
+ inputs: AiAutomaticSpeechRecognitionInput;
3611
+ postProcessedOutputs: AiAutomaticSpeechRecognitionOutput;
3486
3612
  }
3487
3613
  type AiSummarizationInput = {
3488
3614
  input_text: string;
@@ -3518,16 +3644,36 @@ declare abstract class BaseAiTextEmbeddings {
3518
3644
  postProcessedOutputs: AiTextEmbeddingsOutput;
3519
3645
  }
3520
3646
  type RoleScopedChatInput = {
3521
- role: "user" | "assistant" | "system" | "tool";
3647
+ role:
3648
+ | "user"
3649
+ | "assistant"
3650
+ | "system"
3651
+ | "tool"
3652
+ | (string & NonNullable<unknown>);
3522
3653
  content: string;
3654
+ name?: string;
3655
+ };
3656
+ type AiTextGenerationToolLegacyInput = {
3657
+ name: string;
3658
+ description: string;
3659
+ parameters?: {
3660
+ type: "object" | (string & NonNullable<unknown>);
3661
+ properties: {
3662
+ [key: string]: {
3663
+ type: string;
3664
+ description?: string;
3665
+ };
3666
+ };
3667
+ required: string[];
3668
+ };
3523
3669
  };
3524
3670
  type AiTextGenerationToolInput = {
3525
- type: "function";
3671
+ type: "function" | (string & NonNullable<unknown>);
3526
3672
  function: {
3527
3673
  name: string;
3528
3674
  description: string;
3529
3675
  parameters?: {
3530
- type: "object";
3676
+ type: "object" | (string & NonNullable<unknown>);
3531
3677
  properties: {
3532
3678
  [key: string]: {
3533
3679
  type: string;
@@ -3538,6 +3684,10 @@ type AiTextGenerationToolInput = {
3538
3684
  };
3539
3685
  };
3540
3686
  };
3687
+ type AiTextGenerationFunctionsInput = {
3688
+ name: string;
3689
+ code: string;
3690
+ };
3541
3691
  type AiTextGenerationInput = {
3542
3692
  prompt?: string;
3543
3693
  raw?: boolean;
@@ -3551,7 +3701,11 @@ type AiTextGenerationInput = {
3551
3701
  frequency_penalty?: number;
3552
3702
  presence_penalty?: number;
3553
3703
  messages?: RoleScopedChatInput[];
3554
- tools?: AiTextGenerationToolInput[];
3704
+ tools?:
3705
+ | AiTextGenerationToolInput[]
3706
+ | AiTextGenerationToolLegacyInput[]
3707
+ | (object & NonNullable<unknown>);
3708
+ functions?: AiTextGenerationFunctionsInput[];
3555
3709
  };
3556
3710
  type AiTextGenerationOutput =
3557
3711
  | {
@@ -3566,15 +3720,33 @@ declare abstract class BaseAiTextGeneration {
3566
3720
  inputs: AiTextGenerationInput;
3567
3721
  postProcessedOutputs: AiTextGenerationOutput;
3568
3722
  }
3723
+ type AiTextToSpeechInput = {
3724
+ prompt: string;
3725
+ lang?: string;
3726
+ };
3727
+ type AiTextToSpeechOutput =
3728
+ | Uint8Array
3729
+ | {
3730
+ audio: string;
3731
+ };
3732
+ declare abstract class BaseAiTextToSpeech {
3733
+ inputs: AiTextToSpeechInput;
3734
+ postProcessedOutputs: AiTextToSpeechOutput;
3735
+ }
3569
3736
  type AiTextToImageInput = {
3570
3737
  prompt: string;
3738
+ negative_prompt?: string;
3739
+ height?: number;
3740
+ width?: number;
3571
3741
  image?: number[];
3742
+ image_b64?: string;
3572
3743
  mask?: number[];
3573
3744
  num_steps?: number;
3574
3745
  strength?: number;
3575
3746
  guidance?: number;
3747
+ seed?: number;
3576
3748
  };
3577
- type AiTextToImageOutput = Uint8Array;
3749
+ type AiTextToImageOutput = ReadableStream<Uint8Array>;
3578
3750
  declare abstract class BaseAiTextToImage {
3579
3751
  inputs: AiTextToImageInput;
3580
3752
  postProcessedOutputs: AiTextToImageOutput;
@@ -3591,126 +3763,613 @@ declare abstract class BaseAiTranslation {
3591
3763
  inputs: AiTranslationInput;
3592
3764
  postProcessedOutputs: AiTranslationOutput;
3593
3765
  }
3766
+ type Ai_Cf_Openai_Whisper_Input =
3767
+ | string
3768
+ | {
3769
+ /**
3770
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3771
+ */
3772
+ audio: number[];
3773
+ };
3774
+ interface Ai_Cf_Openai_Whisper_Output {
3775
+ /**
3776
+ * The transcription
3777
+ */
3778
+ text: string;
3779
+ word_count?: number;
3780
+ words?: {
3781
+ word?: string;
3782
+ /**
3783
+ * The second this word begins in the recording
3784
+ */
3785
+ start?: number;
3786
+ /**
3787
+ * The ending second when the word completes
3788
+ */
3789
+ end?: number;
3790
+ }[];
3791
+ vtt?: string;
3792
+ }
3793
+ declare abstract class Base_Ai_Cf_Openai_Whisper {
3794
+ inputs: Ai_Cf_Openai_Whisper_Input;
3795
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Output;
3796
+ }
3797
+ type Ai_Cf_Openai_Whisper_Tiny_En_Input =
3798
+ | string
3799
+ | {
3800
+ /**
3801
+ * An array of integers that represent the audio data constrained to 8-bit unsigned integer values
3802
+ */
3803
+ audio: number[];
3804
+ };
3805
+ interface Ai_Cf_Openai_Whisper_Tiny_En_Output {
3806
+ /**
3807
+ * The transcription
3808
+ */
3809
+ text: string;
3810
+ word_count?: number;
3811
+ words?: {
3812
+ word?: string;
3813
+ /**
3814
+ * The second this word begins in the recording
3815
+ */
3816
+ start?: number;
3817
+ /**
3818
+ * The ending second when the word completes
3819
+ */
3820
+ end?: number;
3821
+ }[];
3822
+ vtt?: string;
3823
+ }
3824
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Tiny_En {
3825
+ inputs: Ai_Cf_Openai_Whisper_Tiny_En_Input;
3826
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Tiny_En_Output;
3827
+ }
3828
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input {
3829
+ /**
3830
+ * Base64 encoded value of the audio data.
3831
+ */
3832
+ audio: string;
3833
+ /**
3834
+ * Supported tasks are 'translate' or 'transcribe'.
3835
+ */
3836
+ task?: string;
3837
+ /**
3838
+ * The language of the audio being transcribed or translated.
3839
+ */
3840
+ language?: string;
3841
+ /**
3842
+ * Preprocess the audio with a voice activity detection model.
3843
+ */
3844
+ vad_filter?: string;
3845
+ /**
3846
+ * A text prompt to help provide context to the model on the contents of the audio.
3847
+ */
3848
+ initial_prompt?: string;
3849
+ /**
3850
+ * The prefix it appended the the beginning of the output of the transcription and can guide the transcription result.
3851
+ */
3852
+ prefix?: string;
3853
+ }
3854
+ interface Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output {
3855
+ transcription_info?: {
3856
+ /**
3857
+ * The language of the audio being transcribed or translated.
3858
+ */
3859
+ language?: string;
3860
+ /**
3861
+ * The confidence level or probability of the detected language being accurate, represented as a decimal between 0 and 1.
3862
+ */
3863
+ language_probability?: number;
3864
+ /**
3865
+ * The total duration of the original audio file, in seconds.
3866
+ */
3867
+ duration?: number;
3868
+ /**
3869
+ * The duration of the audio after applying Voice Activity Detection (VAD) to remove silent or irrelevant sections, in seconds.
3870
+ */
3871
+ duration_after_vad?: number;
3872
+ };
3873
+ /**
3874
+ * The complete transcription of the audio.
3875
+ */
3876
+ text: string;
3877
+ /**
3878
+ * The total number of words in the transcription.
3879
+ */
3880
+ word_count?: number;
3881
+ segments?: {
3882
+ /**
3883
+ * The starting time of the segment within the audio, in seconds.
3884
+ */
3885
+ start?: number;
3886
+ /**
3887
+ * The ending time of the segment within the audio, in seconds.
3888
+ */
3889
+ end?: number;
3890
+ /**
3891
+ * The transcription of the segment.
3892
+ */
3893
+ text?: string;
3894
+ /**
3895
+ * The temperature used in the decoding process, controlling randomness in predictions. Lower values result in more deterministic outputs.
3896
+ */
3897
+ temperature?: number;
3898
+ /**
3899
+ * The average log probability of the predictions for the words in this segment, indicating overall confidence.
3900
+ */
3901
+ avg_logprob?: number;
3902
+ /**
3903
+ * The compression ratio of the input to the output, measuring how much the text was compressed during the transcription process.
3904
+ */
3905
+ compression_ratio?: number;
3906
+ /**
3907
+ * The probability that the segment contains no speech, represented as a decimal between 0 and 1.
3908
+ */
3909
+ no_speech_prob?: number;
3910
+ words?: {
3911
+ /**
3912
+ * The individual word transcribed from the audio.
3913
+ */
3914
+ word?: string;
3915
+ /**
3916
+ * The starting time of the word within the audio, in seconds.
3917
+ */
3918
+ start?: number;
3919
+ /**
3920
+ * The ending time of the word within the audio, in seconds.
3921
+ */
3922
+ end?: number;
3923
+ }[];
3924
+ };
3925
+ /**
3926
+ * The transcription in WebVTT format, which includes timing and text information for use in subtitles.
3927
+ */
3928
+ vtt?: string;
3929
+ }
3930
+ declare abstract class Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo {
3931
+ inputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Input;
3932
+ postProcessedOutputs: Ai_Cf_Openai_Whisper_Large_V3_Turbo_Output;
3933
+ }
3934
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input {
3935
+ /**
3936
+ * A text description of the image you want to generate.
3937
+ */
3938
+ prompt: string;
3939
+ /**
3940
+ * The number of diffusion steps; higher values can improve quality but take longer.
3941
+ */
3942
+ steps?: number;
3943
+ }
3944
+ interface Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output {
3945
+ /**
3946
+ * The generated image in Base64 format.
3947
+ */
3948
+ image?: string;
3949
+ }
3950
+ declare abstract class Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell {
3951
+ inputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Input;
3952
+ postProcessedOutputs: Ai_Cf_Black_Forest_Labs_Flux_1_Schnell_Output;
3953
+ }
3954
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input = Prompt | Messages;
3955
+ interface Prompt {
3956
+ /**
3957
+ * The input text prompt for the model to generate a response.
3958
+ */
3959
+ prompt: string;
3960
+ image?: number[] | (string & NonNullable<unknown>);
3961
+ /**
3962
+ * If true, a chat template is not applied and you must adhere to the specific model's expected formatting.
3963
+ */
3964
+ raw?: boolean;
3965
+ /**
3966
+ * If true, the response will be streamed back incrementally using SSE, Server Sent Events.
3967
+ */
3968
+ stream?: boolean;
3969
+ /**
3970
+ * The maximum number of tokens to generate in the response.
3971
+ */
3972
+ max_tokens?: number;
3973
+ /**
3974
+ * Controls the randomness of the output; higher values produce more random results.
3975
+ */
3976
+ temperature?: number;
3977
+ /**
3978
+ * 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.
3979
+ */
3980
+ top_p?: number;
3981
+ /**
3982
+ * 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.
3983
+ */
3984
+ top_k?: number;
3985
+ /**
3986
+ * Random seed for reproducibility of the generation.
3987
+ */
3988
+ seed?: number;
3989
+ /**
3990
+ * Penalty for repeated tokens; higher values discourage repetition.
3991
+ */
3992
+ repetition_penalty?: number;
3993
+ /**
3994
+ * Decreases the likelihood of the model repeating the same lines verbatim.
3995
+ */
3996
+ frequency_penalty?: number;
3997
+ /**
3998
+ * Increases the likelihood of the model introducing new topics.
3999
+ */
4000
+ presence_penalty?: number;
4001
+ /**
4002
+ * Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.
4003
+ */
4004
+ lora?: string;
4005
+ }
4006
+ interface Messages {
4007
+ /**
4008
+ * An array of message objects representing the conversation history.
4009
+ */
4010
+ messages: {
4011
+ /**
4012
+ * The role of the message sender (e.g., 'user', 'assistant', 'system', 'tool').
4013
+ */
4014
+ role: string;
4015
+ /**
4016
+ * The content of the message as a string.
4017
+ */
4018
+ content: string;
4019
+ }[];
4020
+ image?: number[] | string;
4021
+ functions?: {
4022
+ name: string;
4023
+ code: string;
4024
+ }[];
4025
+ /**
4026
+ * A list of tools available for the assistant to use.
4027
+ */
4028
+ tools?: (
4029
+ | {
4030
+ /**
4031
+ * The name of the tool. More descriptive the better.
4032
+ */
4033
+ name: string;
4034
+ /**
4035
+ * A brief description of what the tool does.
4036
+ */
4037
+ description: string;
4038
+ /**
4039
+ * Schema defining the parameters accepted by the tool.
4040
+ */
4041
+ parameters: {
4042
+ /**
4043
+ * The type of the parameters object (usually 'object').
4044
+ */
4045
+ type: string;
4046
+ /**
4047
+ * List of required parameter names.
4048
+ */
4049
+ required?: string[];
4050
+ /**
4051
+ * Definitions of each parameter.
4052
+ */
4053
+ properties: {
4054
+ [k: string]: {
4055
+ /**
4056
+ * The data type of the parameter.
4057
+ */
4058
+ type: string;
4059
+ /**
4060
+ * A description of the expected parameter.
4061
+ */
4062
+ description: string;
4063
+ };
4064
+ };
4065
+ };
4066
+ }
4067
+ | {
4068
+ /**
4069
+ * Specifies the type of tool (e.g., 'function').
4070
+ */
4071
+ type: string;
4072
+ /**
4073
+ * Details of the function tool.
4074
+ */
4075
+ function: {
4076
+ /**
4077
+ * The name of the function.
4078
+ */
4079
+ name: string;
4080
+ /**
4081
+ * A brief description of what the function does.
4082
+ */
4083
+ description: string;
4084
+ /**
4085
+ * Schema defining the parameters accepted by the function.
4086
+ */
4087
+ parameters: {
4088
+ /**
4089
+ * The type of the parameters object (usually 'object').
4090
+ */
4091
+ type: string;
4092
+ /**
4093
+ * List of required parameter names.
4094
+ */
4095
+ required?: string[];
4096
+ /**
4097
+ * Definitions of each parameter.
4098
+ */
4099
+ properties: {
4100
+ [k: string]: {
4101
+ /**
4102
+ * The data type of the parameter.
4103
+ */
4104
+ type: string;
4105
+ /**
4106
+ * A description of the expected parameter.
4107
+ */
4108
+ description: string;
4109
+ };
4110
+ };
4111
+ };
4112
+ };
4113
+ }
4114
+ )[];
4115
+ /**
4116
+ * If true, the response will be streamed back incrementally.
4117
+ */
4118
+ stream?: boolean;
4119
+ /**
4120
+ * The maximum number of tokens to generate in the response.
4121
+ */
4122
+ max_tokens?: number;
4123
+ /**
4124
+ * Controls the randomness of the output; higher values produce more random results.
4125
+ */
4126
+ temperature?: number;
4127
+ /**
4128
+ * 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.
4129
+ */
4130
+ top_p?: number;
4131
+ /**
4132
+ * 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.
4133
+ */
4134
+ top_k?: number;
4135
+ /**
4136
+ * Random seed for reproducibility of the generation.
4137
+ */
4138
+ seed?: number;
4139
+ /**
4140
+ * Penalty for repeated tokens; higher values discourage repetition.
4141
+ */
4142
+ repetition_penalty?: number;
4143
+ /**
4144
+ * Decreases the likelihood of the model repeating the same lines verbatim.
4145
+ */
4146
+ frequency_penalty?: number;
4147
+ /**
4148
+ * Increases the likelihood of the model introducing new topics.
4149
+ */
4150
+ presence_penalty?: number;
4151
+ }
4152
+ type Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output =
4153
+ | {
4154
+ /**
4155
+ * The generated text response from the model
4156
+ */
4157
+ response?: string;
4158
+ /**
4159
+ * An array of tool calls requests made during the response generation
4160
+ */
4161
+ tool_calls?: {
4162
+ /**
4163
+ * The arguments passed to be passed to the tool call request
4164
+ */
4165
+ arguments?: object;
4166
+ /**
4167
+ * The name of the tool to be called
4168
+ */
4169
+ name?: string;
4170
+ }[];
4171
+ }
4172
+ | ReadableStream;
4173
+ declare abstract class Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct {
4174
+ inputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Input;
4175
+ postProcessedOutputs: Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct_Output;
4176
+ }
4177
+ interface AiModels {
4178
+ "@cf/huggingface/distilbert-sst-2-int8": BaseAiTextClassification;
4179
+ "@cf/stabilityai/stable-diffusion-xl-base-1.0": BaseAiTextToImage;
4180
+ "@cf/runwayml/stable-diffusion-v1-5-inpainting": BaseAiTextToImage;
4181
+ "@cf/runwayml/stable-diffusion-v1-5-img2img": BaseAiTextToImage;
4182
+ "@cf/lykon/dreamshaper-8-lcm": BaseAiTextToImage;
4183
+ "@cf/bytedance/stable-diffusion-xl-lightning": BaseAiTextToImage;
4184
+ "@cf/baai/bge-base-en-v1.5": BaseAiTextEmbeddings;
4185
+ "@cf/baai/bge-small-en-v1.5": BaseAiTextEmbeddings;
4186
+ "@cf/baai/bge-large-en-v1.5": BaseAiTextEmbeddings;
4187
+ "@cf/microsoft/resnet-50": BaseAiImageClassification;
4188
+ "@cf/facebook/detr-resnet-50": BaseAiObjectDetection;
4189
+ "@cf/meta/llama-2-7b-chat-int8": BaseAiTextGeneration;
4190
+ "@cf/mistral/mistral-7b-instruct-v0.1": BaseAiTextGeneration;
4191
+ "@cf/meta/llama-2-7b-chat-fp16": BaseAiTextGeneration;
4192
+ "@hf/thebloke/llama-2-13b-chat-awq": BaseAiTextGeneration;
4193
+ "@hf/thebloke/mistral-7b-instruct-v0.1-awq": BaseAiTextGeneration;
4194
+ "@hf/thebloke/zephyr-7b-beta-awq": BaseAiTextGeneration;
4195
+ "@hf/thebloke/openhermes-2.5-mistral-7b-awq": BaseAiTextGeneration;
4196
+ "@hf/thebloke/neural-chat-7b-v3-1-awq": BaseAiTextGeneration;
4197
+ "@hf/thebloke/llamaguard-7b-awq": BaseAiTextGeneration;
4198
+ "@hf/thebloke/deepseek-coder-6.7b-base-awq": BaseAiTextGeneration;
4199
+ "@hf/thebloke/deepseek-coder-6.7b-instruct-awq": BaseAiTextGeneration;
4200
+ "@cf/deepseek-ai/deepseek-math-7b-instruct": BaseAiTextGeneration;
4201
+ "@cf/defog/sqlcoder-7b-2": BaseAiTextGeneration;
4202
+ "@cf/openchat/openchat-3.5-0106": BaseAiTextGeneration;
4203
+ "@cf/tiiuae/falcon-7b-instruct": BaseAiTextGeneration;
4204
+ "@cf/thebloke/discolm-german-7b-v1-awq": BaseAiTextGeneration;
4205
+ "@cf/qwen/qwen1.5-0.5b-chat": BaseAiTextGeneration;
4206
+ "@cf/qwen/qwen1.5-7b-chat-awq": BaseAiTextGeneration;
4207
+ "@cf/qwen/qwen1.5-14b-chat-awq": BaseAiTextGeneration;
4208
+ "@cf/tinyllama/tinyllama-1.1b-chat-v1.0": BaseAiTextGeneration;
4209
+ "@cf/microsoft/phi-2": BaseAiTextGeneration;
4210
+ "@cf/qwen/qwen1.5-1.8b-chat": BaseAiTextGeneration;
4211
+ "@cf/mistral/mistral-7b-instruct-v0.2-lora": BaseAiTextGeneration;
4212
+ "@hf/nousresearch/hermes-2-pro-mistral-7b": BaseAiTextGeneration;
4213
+ "@hf/nexusflow/starling-lm-7b-beta": BaseAiTextGeneration;
4214
+ "@hf/google/gemma-7b-it": BaseAiTextGeneration;
4215
+ "@cf/meta-llama/llama-2-7b-chat-hf-lora": BaseAiTextGeneration;
4216
+ "@cf/google/gemma-2b-it-lora": BaseAiTextGeneration;
4217
+ "@cf/google/gemma-7b-it-lora": BaseAiTextGeneration;
4218
+ "@hf/mistral/mistral-7b-instruct-v0.2": BaseAiTextGeneration;
4219
+ "@cf/meta/llama-3-8b-instruct": BaseAiTextGeneration;
4220
+ "@cf/fblgit/una-cybertron-7b-v2-bf16": BaseAiTextGeneration;
4221
+ "@cf/meta/llama-3-8b-instruct-awq": BaseAiTextGeneration;
4222
+ "@hf/meta-llama/meta-llama-3-8b-instruct": BaseAiTextGeneration;
4223
+ "@cf/meta/llama-3.1-8b-instruct": BaseAiTextGeneration;
4224
+ "@cf/meta/llama-3.1-8b-instruct-fp8": BaseAiTextGeneration;
4225
+ "@cf/meta/llama-3.1-8b-instruct-awq": BaseAiTextGeneration;
4226
+ "@cf/meta/llama-3.2-3b-instruct": BaseAiTextGeneration;
4227
+ "@cf/meta/llama-3.2-1b-instruct": BaseAiTextGeneration;
4228
+ "@cf/meta/llama-3.3-70b-instruct-fp8-fast": BaseAiTextGeneration;
4229
+ "@cf/meta/m2m100-1.2b": BaseAiTranslation;
4230
+ "@cf/facebook/bart-large-cnn": BaseAiSummarization;
4231
+ "@cf/unum/uform-gen2-qwen-500m": BaseAiImageToText;
4232
+ "@cf/llava-hf/llava-1.5-7b-hf": BaseAiImageToText;
4233
+ "@cf/openai/whisper": Base_Ai_Cf_Openai_Whisper;
4234
+ "@cf/openai/whisper-tiny-en": Base_Ai_Cf_Openai_Whisper_Tiny_En;
4235
+ "@cf/openai/whisper-large-v3-turbo": Base_Ai_Cf_Openai_Whisper_Large_V3_Turbo;
4236
+ "@cf/black-forest-labs/flux-1-schnell": Base_Ai_Cf_Black_Forest_Labs_Flux_1_Schnell;
4237
+ "@cf/meta/llama-3.2-11b-vision-instruct": Base_Ai_Cf_Meta_Llama_3_2_11B_Vision_Instruct;
4238
+ }
4239
+ type AiOptions = {
4240
+ gateway?: GatewayOptions;
4241
+ prefix?: string;
4242
+ extraHeaders?: object;
4243
+ };
4244
+ type AiModelsSearchParams = {
4245
+ author?: string;
4246
+ hide_experimental?: boolean;
4247
+ page?: number;
4248
+ per_page?: number;
4249
+ search?: string;
4250
+ source?: number;
4251
+ task?: string;
4252
+ };
4253
+ type AiModelsSearchObject = {
4254
+ id: string;
4255
+ source: number;
4256
+ name: string;
4257
+ description: string;
4258
+ task: {
4259
+ id: string;
4260
+ name: string;
4261
+ description: string;
4262
+ };
4263
+ tags: string[];
4264
+ properties: {
4265
+ property_id: string;
4266
+ value: string;
4267
+ }[];
4268
+ };
4269
+ interface InferenceUpstreamError extends Error {}
4270
+ interface AiInternalError extends Error {}
4271
+ type AiModelListType = Record<string, any>;
4272
+ declare abstract class Ai<AiModelList extends AiModelListType = AiModels> {
4273
+ aiGatewayLogId: string | null;
4274
+ gateway(gatewayId: string): AiGateway;
4275
+ run<Name extends keyof AiModelList>(
4276
+ model: Name,
4277
+ inputs: AiModelList[Name]["inputs"],
4278
+ options?: AiOptions,
4279
+ ): Promise<AiModelList[Name]["postProcessedOutputs"]>;
4280
+ public models(params?: AiModelsSearchParams): Promise<AiModelsSearchObject[]>;
4281
+ }
3594
4282
  type GatewayOptions = {
3595
4283
  id: string;
4284
+ cacheKey?: string;
3596
4285
  cacheTtl?: number;
3597
4286
  skipCache?: boolean;
3598
4287
  metadata?: Record<string, number | string | boolean | null | bigint>;
4288
+ collectLog?: boolean;
3599
4289
  };
3600
- type AiOptions = {
3601
- gateway?: GatewayOptions;
3602
- prefix?: string;
3603
- extraHeaders?: object;
4290
+ type AiGatewayPatchLog = {
4291
+ score?: number | null;
4292
+ feedback?: -1 | 1 | null;
4293
+ metadata?: Record<string, number | string | boolean | null | bigint> | null;
3604
4294
  };
3605
- type BaseAiTextClassificationModels = "@cf/huggingface/distilbert-sst-2-int8";
3606
- type BaseAiTextToImageModels =
3607
- | "@cf/stabilityai/stable-diffusion-xl-base-1.0"
3608
- | "@cf/runwayml/stable-diffusion-v1-5-inpainting"
3609
- | "@cf/runwayml/stable-diffusion-v1-5-img2img"
3610
- | "@cf/lykon/dreamshaper-8-lcm"
3611
- | "@cf/bytedance/stable-diffusion-xl-lightning";
3612
- type BaseAiTextEmbeddingsModels =
3613
- | "@cf/baai/bge-small-en-v1.5"
3614
- | "@cf/baai/bge-base-en-v1.5"
3615
- | "@cf/baai/bge-large-en-v1.5";
3616
- type BaseAiSpeechRecognitionModels =
3617
- | "@cf/openai/whisper"
3618
- | "@cf/openai/whisper-tiny-en"
3619
- | "@cf/openai/whisper-sherpa";
3620
- type BaseAiImageClassificationModels = "@cf/microsoft/resnet-50";
3621
- type BaseAiObjectDetectionModels = "@cf/facebook/detr-resnet-50";
3622
- type BaseAiTextGenerationModels =
3623
- | "@cf/meta/llama-3-8b-instruct"
3624
- | "@cf/meta/llama-3-8b-instruct-awq"
3625
- | "@cf/meta/llama-2-7b-chat-int8"
3626
- | "@cf/mistral/mistral-7b-instruct-v0.1"
3627
- | "@cf/mistral/mistral-7b-instruct-v0.2-lora"
3628
- | "@cf/meta/llama-2-7b-chat-fp16"
3629
- | "@hf/thebloke/llama-2-13b-chat-awq"
3630
- | "@hf/thebloke/zephyr-7b-beta-awq"
3631
- | "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
3632
- | "@hf/thebloke/codellama-7b-instruct-awq"
3633
- | "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
3634
- | "@hf/thebloke/neural-chat-7b-v3-1-awq"
3635
- | "@hf/thebloke/llamaguard-7b-awq"
3636
- | "@hf/thebloke/deepseek-coder-6.7b-base-awq"
3637
- | "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"
3638
- | "@hf/nousresearch/hermes-2-pro-mistral-7b"
3639
- | "@hf/mistral/mistral-7b-instruct-v0.2"
3640
- | "@hf/google/gemma-7b-it"
3641
- | "@hf/nexusflow/starling-lm-7b-beta"
3642
- | "@cf/deepseek-ai/deepseek-math-7b-instruct"
3643
- | "@cf/defog/sqlcoder-7b-2"
3644
- | "@cf/openchat/openchat-3.5-0106"
3645
- | "@cf/tiiuae/falcon-7b-instruct"
3646
- | "@cf/thebloke/discolm-german-7b-v1-awq"
3647
- | "@cf/qwen/qwen1.5-0.5b-chat"
3648
- | "@cf/qwen/qwen1.5-1.8b-chat"
3649
- | "@cf/qwen/qwen1.5-7b-chat-awq"
3650
- | "@cf/qwen/qwen1.5-14b-chat-awq"
3651
- | "@cf/tinyllama/tinyllama-1.1b-chat-v1.0"
3652
- | "@cf/microsoft/phi-2"
3653
- | "@cf/google/gemma-2b-it-lora"
3654
- | "@cf/google/gemma-7b-it-lora"
3655
- | "@cf/meta-llama/llama-2-7b-chat-hf-lora"
3656
- | "@cf/fblgit/una-cybertron-7b-v2-bf16"
3657
- | "@cf/fblgit/una-cybertron-7b-v2-awq";
3658
- type BaseAiTranslationModels = "@cf/meta/m2m100-1.2b";
3659
- type BaseAiSummarizationModels = "@cf/facebook/bart-large-cnn";
3660
- type BaseAiImageToTextModels =
3661
- | "@cf/unum/uform-gen2-qwen-500m"
3662
- | "@cf/llava-hf/llava-1.5-7b-hf";
3663
- declare abstract class Ai {
3664
- run(
3665
- model: BaseAiTextClassificationModels,
3666
- inputs: BaseAiTextClassification["inputs"],
3667
- options?: AiOptions,
3668
- ): Promise<BaseAiTextClassification["postProcessedOutputs"]>;
3669
- run(
3670
- model: BaseAiTextToImageModels,
3671
- inputs: BaseAiTextToImage["inputs"],
3672
- options?: AiOptions,
3673
- ): Promise<BaseAiTextToImage["postProcessedOutputs"]>;
3674
- run(
3675
- model: BaseAiTextEmbeddingsModels,
3676
- inputs: BaseAiTextEmbeddings["inputs"],
3677
- options?: AiOptions,
3678
- ): Promise<BaseAiTextEmbeddings["postProcessedOutputs"]>;
3679
- run(
3680
- model: BaseAiSpeechRecognitionModels,
3681
- inputs: BaseAiSpeechRecognition["inputs"],
3682
- options?: AiOptions,
3683
- ): Promise<BaseAiSpeechRecognition["postProcessedOutputs"]>;
3684
- run(
3685
- model: BaseAiImageClassificationModels,
3686
- inputs: BaseAiImageClassification["inputs"],
3687
- options?: AiOptions,
3688
- ): Promise<BaseAiImageClassification["postProcessedOutputs"]>;
3689
- run(
3690
- model: BaseAiObjectDetectionModels,
3691
- inputs: BaseAiObjectDetection["inputs"],
3692
- options?: AiOptions,
3693
- ): Promise<BaseAiObjectDetection["postProcessedOutputs"]>;
3694
- run(
3695
- model: BaseAiTextGenerationModels,
3696
- inputs: BaseAiTextGeneration["inputs"],
3697
- options?: AiOptions,
3698
- ): Promise<BaseAiTextGeneration["postProcessedOutputs"]>;
3699
- run(
3700
- model: BaseAiTranslationModels,
3701
- inputs: BaseAiTranslation["inputs"],
3702
- options?: AiOptions,
3703
- ): Promise<BaseAiTranslation["postProcessedOutputs"]>;
3704
- run(
3705
- model: BaseAiSummarizationModels,
3706
- inputs: BaseAiSummarization["inputs"],
3707
- options?: AiOptions,
3708
- ): Promise<BaseAiSummarization["postProcessedOutputs"]>;
4295
+ type AiGatewayLog = {
4296
+ id: string;
4297
+ provider: string;
4298
+ model: string;
4299
+ model_type?: string;
4300
+ path: string;
4301
+ duration: number;
4302
+ request_type?: string;
4303
+ request_content_type?: string;
4304
+ status_code: number;
4305
+ response_content_type?: string;
4306
+ success: boolean;
4307
+ cached: boolean;
4308
+ tokens_in?: number;
4309
+ tokens_out?: number;
4310
+ metadata?: Record<string, number | string | boolean | null | bigint>;
4311
+ step?: number;
4312
+ cost?: number;
4313
+ custom_cost?: boolean;
4314
+ request_size: number;
4315
+ request_head?: string;
4316
+ request_head_complete: boolean;
4317
+ response_size: number;
4318
+ response_head?: string;
4319
+ response_head_complete: boolean;
4320
+ created_at: Date;
4321
+ };
4322
+ type AIGatewayProviders =
4323
+ | "workers-ai"
4324
+ | "anthropic"
4325
+ | "aws-bedrock"
4326
+ | "azure-openai"
4327
+ | "google-vertex-ai"
4328
+ | "huggingface"
4329
+ | "openai"
4330
+ | "perplexity-ai"
4331
+ | "replicate"
4332
+ | "groq"
4333
+ | "cohere"
4334
+ | "google-ai-studio"
4335
+ | "mistral"
4336
+ | "grok"
4337
+ | "openrouter";
4338
+ type AIGatewayHeaders = {
4339
+ "cf-aig-metadata":
4340
+ | Record<string, number | string | boolean | null | bigint>
4341
+ | string;
4342
+ "cf-aig-custom-cost":
4343
+ | {
4344
+ per_token_in?: number;
4345
+ per_token_out?: number;
4346
+ }
4347
+ | {
4348
+ total_cost?: number;
4349
+ }
4350
+ | string;
4351
+ "cf-aig-cache-ttl": number | string;
4352
+ "cf-aig-skip-cache": boolean | string;
4353
+ "cf-aig-cache-key": string;
4354
+ "cf-aig-collect-log": boolean | string;
4355
+ Authorization: string;
4356
+ "Content-Type": string;
4357
+ [key: string]: string | number | boolean | object;
4358
+ };
4359
+ type AIGatewayUniversalRequest = {
4360
+ provider: AIGatewayProviders | string; // eslint-disable-line
4361
+ endpoint: string;
4362
+ headers: Partial<AIGatewayHeaders>;
4363
+ query: unknown;
4364
+ };
4365
+ interface AiGatewayInternalError extends Error {}
4366
+ interface AiGatewayLogNotFound extends Error {}
4367
+ declare abstract class AiGateway {
4368
+ patchLog(logId: string, data: AiGatewayPatchLog): Promise<void>;
4369
+ getLog(logId: string): Promise<AiGatewayLog>;
3709
4370
  run(
3710
- model: BaseAiImageToTextModels,
3711
- inputs: BaseAiImageToText["inputs"],
3712
- options?: AiOptions,
3713
- ): Promise<BaseAiImageToText["postProcessedOutputs"]>;
4371
+ data: AIGatewayUniversalRequest | AIGatewayUniversalRequest[],
4372
+ ): Promise<Response>;
3714
4373
  }
3715
4374
  interface BasicImageTransformations {
3716
4375
  /**
@@ -4716,7 +5375,7 @@ declare abstract class D1PreparedStatement {
4716
5375
  bind(...values: unknown[]): D1PreparedStatement;
4717
5376
  first<T = unknown>(colName: string): Promise<T | null>;
4718
5377
  first<T = Record<string, unknown>>(): Promise<T | null>;
4719
- run(): Promise<D1Response>;
5378
+ run<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4720
5379
  all<T = Record<string, unknown>>(): Promise<D1Result<T>>;
4721
5380
  raw<T = unknown[]>(options: {
4722
5381
  columnNames: true;
@@ -4772,6 +5431,12 @@ interface ForwardableEmailMessage extends EmailMessage {
4772
5431
  * @returns A promise that resolves when the email message is forwarded.
4773
5432
  */
4774
5433
  forward(rcptTo: string, headers?: Headers): Promise<void>;
5434
+ /**
5435
+ * Reply to the sender of this email message with a new EmailMessage object.
5436
+ * @param message The reply message.
5437
+ * @returns A promise that resolves when the email message is replied.
5438
+ */
5439
+ reply(message: EmailMessage): Promise<void>;
4775
5440
  }
4776
5441
  /**
4777
5442
  * A binding that allows a Worker to send email messages.
@@ -4841,6 +5506,128 @@ interface Hyperdrive {
4841
5506
  */
4842
5507
  readonly database: string;
4843
5508
  }
5509
+ // Copyright (c) 2024 Cloudflare, Inc.
5510
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5511
+ // https://opensource.org/licenses/Apache-2.0
5512
+ type ImageInfoResponse =
5513
+ | {
5514
+ format: "image/svg+xml";
5515
+ }
5516
+ | {
5517
+ format: string;
5518
+ fileSize: number;
5519
+ width: number;
5520
+ height: number;
5521
+ };
5522
+ type ImageTransform = {
5523
+ fit?: "scale-down" | "contain" | "pad" | "squeeze" | "cover" | "crop";
5524
+ gravity?:
5525
+ | "left"
5526
+ | "right"
5527
+ | "top"
5528
+ | "bottom"
5529
+ | "center"
5530
+ | "auto"
5531
+ | "entropy"
5532
+ | "face"
5533
+ | {
5534
+ x?: number;
5535
+ y?: number;
5536
+ mode: "remainder" | "box-center";
5537
+ };
5538
+ trim?: {
5539
+ top?: number;
5540
+ bottom?: number;
5541
+ left?: number;
5542
+ right?: number;
5543
+ width?: number;
5544
+ height?: number;
5545
+ border?:
5546
+ | boolean
5547
+ | {
5548
+ color?: string;
5549
+ tolerance?: number;
5550
+ keep?: number;
5551
+ };
5552
+ };
5553
+ width?: number;
5554
+ height?: number;
5555
+ background?: string;
5556
+ rotate?: number;
5557
+ sharpen?: number;
5558
+ blur?: number;
5559
+ contrast?: number;
5560
+ brightness?: number;
5561
+ gamma?: number;
5562
+ border?: {
5563
+ color?: string;
5564
+ width?: number;
5565
+ top?: number;
5566
+ bottom?: number;
5567
+ left?: number;
5568
+ right?: number;
5569
+ };
5570
+ zoom?: number;
5571
+ };
5572
+ type ImageOutputOptions = {
5573
+ format:
5574
+ | "image/jpeg"
5575
+ | "image/png"
5576
+ | "image/gif"
5577
+ | "image/webp"
5578
+ | "image/avif"
5579
+ | "rgb"
5580
+ | "rgba";
5581
+ quality?: number;
5582
+ background?: string;
5583
+ };
5584
+ interface ImagesBinding {
5585
+ /**
5586
+ * Get image metadata (type, width and height)
5587
+ * @throws {@link ImagesError} with code 9412 if input is not an image
5588
+ * @param stream The image bytes
5589
+ */
5590
+ info(stream: ReadableStream<Uint8Array>): Promise<ImageInfoResponse>;
5591
+ /**
5592
+ * Begin applying a series of transformations to an image
5593
+ * @param stream The image bytes
5594
+ * @returns A transform handle
5595
+ */
5596
+ input(stream: ReadableStream<Uint8Array>): ImageTransformer;
5597
+ }
5598
+ interface ImageTransformer {
5599
+ /**
5600
+ * Apply transform next, returning a transform handle.
5601
+ * You can then apply more transformations or retrieve the output.
5602
+ * @param transform
5603
+ */
5604
+ transform(transform: ImageTransform): ImageTransformer;
5605
+ /**
5606
+ * Retrieve the image that results from applying the transforms to the
5607
+ * provided input
5608
+ * @param options Options that apply to the output e.g. output format
5609
+ */
5610
+ output(options: ImageOutputOptions): Promise<ImageTransformationResult>;
5611
+ }
5612
+ interface ImageTransformationResult {
5613
+ /**
5614
+ * The image as a response, ready to store in cache or return to users
5615
+ */
5616
+ response(): Response;
5617
+ /**
5618
+ * The content type of the returned image
5619
+ */
5620
+ contentType(): string;
5621
+ /**
5622
+ * The bytes of the response
5623
+ */
5624
+ image(): ReadableStream<Uint8Array>;
5625
+ }
5626
+ interface ImagesError extends Error {
5627
+ readonly code: number;
5628
+ readonly message: string;
5629
+ readonly stack?: string;
5630
+ }
4844
5631
  type Params<P extends string = any> = Record<P, string | string[]>;
4845
5632
  type EventContext<Env, P extends string, Data> = {
4846
5633
  request: Request<unknown, IncomingRequestCfProperties<unknown>>;
@@ -4887,6 +5674,30 @@ type PagesPluginFunction<
4887
5674
  declare module "assets:*" {
4888
5675
  export const onRequest: PagesFunction;
4889
5676
  }
5677
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5678
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5679
+ // https://opensource.org/licenses/Apache-2.0
5680
+ declare abstract class PipelineTransform {
5681
+ /**
5682
+ * transformJson recieves an array of javascript objects which can be
5683
+ * mutated and returned to the pipeline
5684
+ * @param data The data to be mutated
5685
+ * @returns A promise containing the mutated data
5686
+ */
5687
+ public transformJson(data: object[]): Promise<object[]>;
5688
+ }
5689
+ // Copyright (c) 2022-2023 Cloudflare, Inc.
5690
+ // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5691
+ // https://opensource.org/licenses/Apache-2.0
5692
+ interface Pipeline {
5693
+ /**
5694
+ * send takes an array of javascript objects which are
5695
+ * then received by the pipeline for processing
5696
+ *
5697
+ * @param data The data to be sent
5698
+ */
5699
+ send(data: object[]): Promise<void>;
5700
+ }
4890
5701
  // PubSubMessage represents an incoming PubSub message.
4891
5702
  // The message includes metadata about the broker, the client, and the payload
4892
5703
  // itself.
@@ -4947,6 +5758,7 @@ declare namespace Rpc {
4947
5758
  export const __RPC_TARGET_BRAND: "__RPC_TARGET_BRAND";
4948
5759
  export const __WORKER_ENTRYPOINT_BRAND: "__WORKER_ENTRYPOINT_BRAND";
4949
5760
  export const __DURABLE_OBJECT_BRAND: "__DURABLE_OBJECT_BRAND";
5761
+ export const __WORKFLOW_ENTRYPOINT_BRAND: "__WORKFLOW_ENTRYPOINT_BRAND";
4950
5762
  export interface RpcTargetBranded {
4951
5763
  [__RPC_TARGET_BRAND]: never;
4952
5764
  }
@@ -4956,13 +5768,20 @@ declare namespace Rpc {
4956
5768
  export interface DurableObjectBranded {
4957
5769
  [__DURABLE_OBJECT_BRAND]: never;
4958
5770
  }
5771
+ export interface WorkflowEntrypointBranded {
5772
+ [__WORKFLOW_ENTRYPOINT_BRAND]: never;
5773
+ }
4959
5774
  export type EntrypointBranded =
4960
5775
  | WorkerEntrypointBranded
4961
- | DurableObjectBranded;
5776
+ | DurableObjectBranded
5777
+ | WorkflowEntrypointBranded;
4962
5778
  // Types that can be used through `Stub`s
4963
5779
  export type Stubable = RpcTargetBranded | ((...args: any[]) => any);
4964
5780
  // Types that can be passed over RPC
4965
- type Serializable =
5781
+ // The reason for using a generic type here is to build a serializable subset of structured
5782
+ // cloneable composite types. This allows types defined with the "interface" keyword to pass the
5783
+ // serializable check as well. Otherwise, only types defined with the "type" keyword would pass.
5784
+ type Serializable<T> =
4966
5785
  // Structured cloneables
4967
5786
  | void
4968
5787
  | undefined
@@ -4978,11 +5797,14 @@ declare namespace Rpc {
4978
5797
  | Error
4979
5798
  | RegExp
4980
5799
  // Structured cloneable composites
4981
- | Map<Serializable, Serializable>
4982
- | Set<Serializable>
4983
- | ReadonlyArray<Serializable>
5800
+ | Map<
5801
+ T extends Map<infer U, unknown> ? Serializable<U> : never,
5802
+ T extends Map<unknown, infer U> ? Serializable<U> : never
5803
+ >
5804
+ | Set<T extends Set<infer U> ? Serializable<U> : never>
5805
+ | ReadonlyArray<T extends ReadonlyArray<infer U> ? Serializable<U> : never>
4984
5806
  | {
4985
- [key: string | number]: Serializable;
5807
+ [K in keyof T]: K extends number | string ? Serializable<T[K]> : never;
4986
5808
  }
4987
5809
  // Special types
4988
5810
  | ReadableStream<Uint8Array>
@@ -5012,7 +5834,7 @@ declare namespace Rpc {
5012
5834
  : T extends ReadonlyArray<infer V>
5013
5835
  ? ReadonlyArray<Stubify<V>>
5014
5836
  : T extends {
5015
- [key: string | number]: unknown;
5837
+ [key: string | number]: any;
5016
5838
  }
5017
5839
  ? {
5018
5840
  [K in keyof T]: Stubify<T[K]>;
@@ -5055,7 +5877,7 @@ declare namespace Rpc {
5055
5877
  // Intersecting with `(Maybe)Provider` allows pipelining.
5056
5878
  type Result<R> = R extends Stubable
5057
5879
  ? Promise<Stub<R>> & Provider<R>
5058
- : R extends Serializable
5880
+ : R extends Serializable<R>
5059
5881
  ? Promise<Stubify<R> & MaybeDisposable<R>> & MaybeProvider<R>
5060
5882
  : never;
5061
5883
  // Type for method or property on an RPC interface.
@@ -5115,7 +5937,7 @@ declare module "cloudflare:workers" {
5115
5937
  protected env: Env;
5116
5938
  constructor(ctx: DurableObjectState, env: Env);
5117
5939
  fetch?(request: Request): Response | Promise<Response>;
5118
- alarm?(): void | Promise<void>;
5940
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
5119
5941
  webSocketMessage?(
5120
5942
  ws: WebSocket,
5121
5943
  message: string | ArrayBuffer,
@@ -5128,6 +5950,60 @@ declare module "cloudflare:workers" {
5128
5950
  ): void | Promise<void>;
5129
5951
  webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
5130
5952
  }
5953
+ export type WorkflowDurationLabel =
5954
+ | "second"
5955
+ | "minute"
5956
+ | "hour"
5957
+ | "day"
5958
+ | "week"
5959
+ | "month"
5960
+ | "year";
5961
+ export type WorkflowSleepDuration =
5962
+ | `${number} ${WorkflowDurationLabel}${"s" | ""}`
5963
+ | number;
5964
+ export type WorkflowDelayDuration = WorkflowSleepDuration;
5965
+ export type WorkflowTimeoutDuration = WorkflowSleepDuration;
5966
+ export type WorkflowBackoff = "constant" | "linear" | "exponential";
5967
+ export type WorkflowStepConfig = {
5968
+ retries?: {
5969
+ limit: number;
5970
+ delay: WorkflowDelayDuration | number;
5971
+ backoff?: WorkflowBackoff;
5972
+ };
5973
+ timeout?: WorkflowTimeoutDuration | number;
5974
+ };
5975
+ export type WorkflowEvent<T> = {
5976
+ payload: Readonly<T>;
5977
+ timestamp: Date;
5978
+ instanceId: string;
5979
+ };
5980
+ export abstract class WorkflowStep {
5981
+ do<T extends Rpc.Serializable<T>>(
5982
+ name: string,
5983
+ callback: () => Promise<T>,
5984
+ ): Promise<T>;
5985
+ do<T extends Rpc.Serializable<T>>(
5986
+ name: string,
5987
+ config: WorkflowStepConfig,
5988
+ callback: () => Promise<T>,
5989
+ ): Promise<T>;
5990
+ sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
5991
+ sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
5992
+ }
5993
+ export abstract class WorkflowEntrypoint<
5994
+ Env = unknown,
5995
+ T extends Rpc.Serializable<T> | unknown = unknown,
5996
+ > implements Rpc.WorkflowEntrypointBranded
5997
+ {
5998
+ [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
5999
+ protected ctx: ExecutionContext;
6000
+ protected env: Env;
6001
+ constructor(ctx: ExecutionContext, env: Env);
6002
+ run(
6003
+ event: Readonly<WorkflowEvent<T>>,
6004
+ step: WorkflowStep,
6005
+ ): Promise<unknown>;
6006
+ }
5131
6007
  }
5132
6008
  declare module "cloudflare:sockets" {
5133
6009
  function _connect(
@@ -5136,6 +6012,198 @@ declare module "cloudflare:sockets" {
5136
6012
  ): Socket;
5137
6013
  export { _connect as connect };
5138
6014
  }
6015
+ declare namespace TailStream {
6016
+ interface Header {
6017
+ readonly name: string;
6018
+ readonly value: string;
6019
+ }
6020
+ interface FetchEventInfo {
6021
+ readonly type: "fetch";
6022
+ readonly method: string;
6023
+ readonly url: string;
6024
+ readonly cfJson: string;
6025
+ readonly headers: Header[];
6026
+ }
6027
+ interface JsRpcEventInfo {
6028
+ readonly type: "jsrpc";
6029
+ readonly methodName: string;
6030
+ }
6031
+ interface ScheduledEventInfo {
6032
+ readonly type: "scheduled";
6033
+ readonly scheduledTime: Date;
6034
+ readonly cron: string;
6035
+ }
6036
+ interface AlarmEventInfo {
6037
+ readonly type: "alarm";
6038
+ readonly scheduledTime: Date;
6039
+ }
6040
+ interface QueueEventInfo {
6041
+ readonly type: "queue";
6042
+ readonly queueName: string;
6043
+ readonly batchSize: number;
6044
+ }
6045
+ interface EmailEventInfo {
6046
+ readonly type: "email";
6047
+ readonly mailFrom: string;
6048
+ readonly rcptTo: string;
6049
+ readonly rawSize: number;
6050
+ }
6051
+ interface TraceEventInfo {
6052
+ readonly type: "trace";
6053
+ readonly traces: (string | null)[];
6054
+ }
6055
+ interface HibernatableWebSocketEventInfoMessage {
6056
+ readonly type: "message";
6057
+ }
6058
+ interface HibernatableWebSocketEventInfoError {
6059
+ readonly type: "error";
6060
+ }
6061
+ interface HibernatableWebSocketEventInfoClose {
6062
+ readonly type: "close";
6063
+ readonly code: number;
6064
+ readonly wasClean: boolean;
6065
+ }
6066
+ interface HibernatableWebSocketEventInfo {
6067
+ readonly type: "hibernatableWebSocket";
6068
+ readonly info:
6069
+ | HibernatableWebSocketEventInfoClose
6070
+ | HibernatableWebSocketEventInfoError
6071
+ | HibernatableWebSocketEventInfoMessage;
6072
+ }
6073
+ interface Resume {
6074
+ readonly type: "resume";
6075
+ readonly attachment?: any;
6076
+ }
6077
+ interface CustomEventInfo {
6078
+ readonly type: "custom";
6079
+ }
6080
+ interface FetchResponseInfo {
6081
+ readonly type: "fetch";
6082
+ readonly statusCode: number;
6083
+ }
6084
+ type EventOutcome =
6085
+ | "ok"
6086
+ | "canceled"
6087
+ | "exception"
6088
+ | "unknown"
6089
+ | "killSwitch"
6090
+ | "daemonDown"
6091
+ | "exceededCpu"
6092
+ | "exceededMemory"
6093
+ | "loadShed"
6094
+ | "responseStreamDisconnected"
6095
+ | "scriptNotFound";
6096
+ interface ScriptVersion {
6097
+ readonly id: string;
6098
+ readonly tag?: string;
6099
+ readonly message?: string;
6100
+ }
6101
+ interface Trigger {
6102
+ readonly traceId: string;
6103
+ readonly invocationId: string;
6104
+ readonly spanId: string;
6105
+ }
6106
+ interface Onset {
6107
+ readonly type: "onset";
6108
+ readonly dispatchNamespace?: string;
6109
+ readonly entrypoint?: string;
6110
+ readonly scriptName?: string;
6111
+ readonly scriptTags?: string[];
6112
+ readonly scriptVersion?: ScriptVersion;
6113
+ readonly trigger?: Trigger;
6114
+ readonly info:
6115
+ | FetchEventInfo
6116
+ | JsRpcEventInfo
6117
+ | ScheduledEventInfo
6118
+ | AlarmEventInfo
6119
+ | QueueEventInfo
6120
+ | EmailEventInfo
6121
+ | TraceEventInfo
6122
+ | HibernatableWebSocketEventInfo
6123
+ | Resume
6124
+ | CustomEventInfo;
6125
+ }
6126
+ interface Outcome {
6127
+ readonly type: "outcome";
6128
+ readonly outcome: EventOutcome;
6129
+ readonly cpuTime: number;
6130
+ readonly wallTime: number;
6131
+ }
6132
+ interface Hibernate {
6133
+ readonly type: "hibernate";
6134
+ }
6135
+ interface SpanOpen {
6136
+ readonly type: "spanOpen";
6137
+ readonly op?: string;
6138
+ readonly info?: FetchEventInfo | JsRpcEventInfo | Attribute[];
6139
+ }
6140
+ interface SpanClose {
6141
+ readonly type: "spanClose";
6142
+ readonly outcome: EventOutcome;
6143
+ }
6144
+ interface DiagnosticChannelEvent {
6145
+ readonly type: "diagnosticChannel";
6146
+ readonly channel: string;
6147
+ readonly message: any;
6148
+ }
6149
+ interface Exception {
6150
+ readonly type: "exception";
6151
+ readonly name: string;
6152
+ readonly message: string;
6153
+ readonly stack?: string;
6154
+ }
6155
+ interface Log {
6156
+ readonly type: "log";
6157
+ readonly level: "debug" | "error" | "info" | "log" | "warn";
6158
+ readonly message: string;
6159
+ }
6160
+ interface Return {
6161
+ readonly type: "return";
6162
+ readonly info?: FetchResponseInfo | Attribute[];
6163
+ }
6164
+ interface Link {
6165
+ readonly type: "link";
6166
+ readonly label?: string;
6167
+ readonly traceId: string;
6168
+ readonly invocationId: string;
6169
+ readonly spanId: string;
6170
+ }
6171
+ interface Attribute {
6172
+ readonly type: "attribute";
6173
+ readonly name: string;
6174
+ readonly value: string | string[] | boolean | boolean[] | number | number[];
6175
+ }
6176
+ type Mark =
6177
+ | DiagnosticChannelEvent
6178
+ | Exception
6179
+ | Log
6180
+ | Return
6181
+ | Link
6182
+ | Attribute[];
6183
+ interface TailEvent {
6184
+ readonly traceId: string;
6185
+ readonly invocationId: string;
6186
+ readonly spanId: string;
6187
+ readonly timestamp: Date;
6188
+ readonly sequence: number;
6189
+ readonly event: Onset | Outcome | Hibernate | SpanOpen | SpanClose | Mark;
6190
+ }
6191
+ type TailEventHandler = (event: TailEvent) => void | Promise<void>;
6192
+ type TailEventHandlerName =
6193
+ | "onset"
6194
+ | "outcome"
6195
+ | "hibernate"
6196
+ | "spanOpen"
6197
+ | "spanClose"
6198
+ | "diagnosticChannel"
6199
+ | "exception"
6200
+ | "log"
6201
+ | "return"
6202
+ | "link"
6203
+ | "attribute";
6204
+ type TailEventHandlerObject = Record<TailEventHandlerName, TailEventHandler>;
6205
+ type TailEventHandlerType = TailEventHandler | TailEventHandlerObject;
6206
+ }
5139
6207
  // Copyright (c) 2022-2023 Cloudflare, Inc.
5140
6208
  // Licensed under the Apache 2.0 license found in the LICENSE file or at:
5141
6209
  // https://opensource.org/licenses/Apache-2.0
@@ -5179,11 +6247,21 @@ type VectorizeVectorMetadataFilter = {
5179
6247
  * Distance metrics determine how other "similar" vectors are determined.
5180
6248
  */
5181
6249
  type VectorizeDistanceMetric = "euclidean" | "cosine" | "dot-product";
6250
+ /**
6251
+ * Metadata return levels for a Vectorize query.
6252
+ *
6253
+ * Default to "none".
6254
+ *
6255
+ * @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.
6256
+ * @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).
6257
+ * @property none No indexed metadata will be returned.
6258
+ */
6259
+ type VectorizeMetadataRetrievalLevel = "all" | "indexed" | "none";
5182
6260
  interface VectorizeQueryOptions {
5183
6261
  topK?: number;
5184
6262
  namespace?: string;
5185
6263
  returnValues?: boolean;
5186
- returnMetadata?: boolean;
6264
+ returnMetadata?: boolean | VectorizeMetadataRetrievalLevel;
5187
6265
  filter?: VectorizeVectorMetadataFilter;
5188
6266
  }
5189
6267
  /**
@@ -5199,6 +6277,9 @@ type VectorizeIndexConfig =
5199
6277
  };
5200
6278
  /**
5201
6279
  * Metadata about an existing index.
6280
+ *
6281
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6282
+ * See {@link VectorizeIndexInfo} for its post-beta equivalent.
5202
6283
  */
5203
6284
  interface VectorizeIndexDetails {
5204
6285
  /** The unique ID of the index */
@@ -5212,6 +6293,19 @@ interface VectorizeIndexDetails {
5212
6293
  /** The number of records containing vectors within the index. */
5213
6294
  vectorsCount: number;
5214
6295
  }
6296
+ /**
6297
+ * Metadata about an existing index.
6298
+ */
6299
+ interface VectorizeIndexInfo {
6300
+ /** The number of records containing vectors within the index. */
6301
+ vectorCount: number;
6302
+ /** Number of dimensions the index has been configured for. */
6303
+ dimensions: number;
6304
+ /** ISO 8601 datetime of the last processed mutation on in the index. All changes before this mutation will be reflected in the index state. */
6305
+ processedUpToDatetime: number;
6306
+ /** UUIDv4 of the last mutation processed by the index. All changes before this mutation will be reflected in the index state. */
6307
+ processedUpToMutation: number;
6308
+ }
5215
6309
  /**
5216
6310
  * Represents a single vector value set along with its associated metadata.
5217
6311
  */
@@ -5222,7 +6316,7 @@ interface VectorizeVector {
5222
6316
  values: VectorFloatArray | number[];
5223
6317
  /** The namespace this vector belongs to. */
5224
6318
  namespace?: string;
5225
- /** Metadata associated with the vector. Includes the values of the other fields and potentially additional details. */
6319
+ /** Metadata associated with the vector. Includes the values of other fields and potentially additional details. */
5226
6320
  metadata?: Record<string, VectorizeVectorMetadata>;
5227
6321
  }
5228
6322
  /**
@@ -5234,7 +6328,7 @@ type VectorizeMatch = Pick<Partial<VectorizeVector>, "values"> &
5234
6328
  score: number;
5235
6329
  };
5236
6330
  /**
5237
- * A set of vector {@link VectorizeMatch} for a particular query.
6331
+ * A set of matching {@link VectorizeMatch} for a particular query.
5238
6332
  */
5239
6333
  interface VectorizeMatches {
5240
6334
  matches: VectorizeMatch[];
@@ -5243,6 +6337,9 @@ interface VectorizeMatches {
5243
6337
  /**
5244
6338
  * Results of an operation that performed a mutation on a set of vectors.
5245
6339
  * Here, `ids` is a list of vectors that were successfully processed.
6340
+ *
6341
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6342
+ * See {@link VectorizeAsyncMutation} for its post-beta equivalent.
5246
6343
  */
5247
6344
  interface VectorizeVectorMutation {
5248
6345
  /* List of ids of vectors that were successfully processed. */
@@ -5251,14 +6348,19 @@ interface VectorizeVectorMutation {
5251
6348
  count: number;
5252
6349
  }
5253
6350
  /**
5254
- * Results of an operation that performed a mutation on a set of vectors
5255
- * with the v2 version of Vectorize.
5256
- * Here, `mutationId` is the identifier for the last mutation processed by Vectorize.
6351
+ * Result type indicating a mutation on the Vectorize Index.
6352
+ * Actual mutations are processed async where the `mutationId` is the unique identifier for the operation.
5257
6353
  */
5258
- interface VectorizeVectorMutationV2 {
5259
- /* The identifier for the last mutation processed by Vectorize. */
6354
+ interface VectorizeAsyncMutation {
6355
+ /** The unique identifier for the async mutation operation containing the changeset. */
5260
6356
  mutationId: string;
5261
6357
  }
6358
+ /**
6359
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6360
+ *
6361
+ * This type is exclusively for the Vectorize **beta** and will be deprecated once Vectorize RC is released.
6362
+ * See {@link Vectorize} for its new implementation.
6363
+ */
5262
6364
  declare abstract class VectorizeIndex {
5263
6365
  /**
5264
6366
  * Get information about the currently bound index.
@@ -5273,7 +6375,7 @@ declare abstract class VectorizeIndex {
5273
6375
  */
5274
6376
  public query(
5275
6377
  vector: VectorFloatArray | number[],
5276
- options: VectorizeQueryOptions,
6378
+ options?: VectorizeQueryOptions,
5277
6379
  ): Promise<VectorizeMatches>;
5278
6380
  /**
5279
6381
  * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
@@ -5300,6 +6402,62 @@ declare abstract class VectorizeIndex {
5300
6402
  */
5301
6403
  public getByIds(ids: string[]): Promise<VectorizeVector[]>;
5302
6404
  }
6405
+ /**
6406
+ * A Vectorize Vector Search Index for querying vectors/embeddings.
6407
+ *
6408
+ * Mutations in this version are async, returning a mutation id.
6409
+ */
6410
+ declare abstract class Vectorize {
6411
+ /**
6412
+ * Get information about the currently bound index.
6413
+ * @returns A promise that resolves with information about the current index.
6414
+ */
6415
+ public describe(): Promise<VectorizeIndexInfo>;
6416
+ /**
6417
+ * Use the provided vector to perform a similarity search across the index.
6418
+ * @param vector Input vector that will be used to drive the similarity search.
6419
+ * @param options Configuration options to massage the returned data.
6420
+ * @returns A promise that resolves with matched and scored vectors.
6421
+ */
6422
+ public query(
6423
+ vector: VectorFloatArray | number[],
6424
+ options?: VectorizeQueryOptions,
6425
+ ): Promise<VectorizeMatches>;
6426
+ /**
6427
+ * Use the provided vector-id to perform a similarity search across the index.
6428
+ * @param vectorId Id for a vector in the index against which the index should be queried.
6429
+ * @param options Configuration options to massage the returned data.
6430
+ * @returns A promise that resolves with matched and scored vectors.
6431
+ */
6432
+ public queryById(
6433
+ vectorId: string,
6434
+ options?: VectorizeQueryOptions,
6435
+ ): Promise<VectorizeMatches>;
6436
+ /**
6437
+ * Insert a list of vectors into the index dataset. If a provided id exists, an error will be thrown.
6438
+ * @param vectors List of vectors that will be inserted.
6439
+ * @returns A promise that resolves with a unique identifier of a mutation containing the insert changeset.
6440
+ */
6441
+ public insert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6442
+ /**
6443
+ * Upsert a list of vectors into the index dataset. If a provided id exists, it will be replaced with the new values.
6444
+ * @param vectors List of vectors that will be upserted.
6445
+ * @returns A promise that resolves with a unique identifier of a mutation containing the upsert changeset.
6446
+ */
6447
+ public upsert(vectors: VectorizeVector[]): Promise<VectorizeAsyncMutation>;
6448
+ /**
6449
+ * Delete a list of vectors with a matching id.
6450
+ * @param ids List of vector ids that should be deleted.
6451
+ * @returns A promise that resolves with a unique identifier of a mutation containing the delete changeset.
6452
+ */
6453
+ public deleteByIds(ids: string[]): Promise<VectorizeAsyncMutation>;
6454
+ /**
6455
+ * Get a list of vectors with a matching id.
6456
+ * @param ids List of vector ids that should be returned.
6457
+ * @returns A promise that resolves with the raw unscored vectors matching the id set.
6458
+ */
6459
+ public getByIds(ids: string[]): Promise<VectorizeVector[]>;
6460
+ }
5303
6461
  /**
5304
6462
  * The interface for "version_metadata" binding
5305
6463
  * providing metadata about the Worker Version using this binding.
@@ -5350,3 +6508,79 @@ interface DispatchNamespace {
5350
6508
  options?: DynamicDispatchOptions,
5351
6509
  ): Fetcher;
5352
6510
  }
6511
+ declare module "cloudflare:workflows" {
6512
+ /**
6513
+ * NonRetryableError allows for a user to throw a fatal error
6514
+ * that makes a Workflow instance fail immediately without triggering a retry
6515
+ */
6516
+ export class NonRetryableError extends Error {
6517
+ public constructor(message: string, name?: string);
6518
+ }
6519
+ }
6520
+ declare abstract class Workflow<PARAMS = unknown> {
6521
+ /**
6522
+ * Get a handle to an existing instance of the Workflow.
6523
+ * @param id Id for the instance of this Workflow
6524
+ * @returns A promise that resolves with a handle for the Instance
6525
+ */
6526
+ public get(id: string): Promise<WorkflowInstance>;
6527
+ /**
6528
+ * Create a new instance and return a handle to it. If a provided id exists, an error will be thrown.
6529
+ * @param options Options when creating an instance including id and params
6530
+ * @returns A promise that resolves with a handle for the Instance
6531
+ */
6532
+ public create(
6533
+ options?: WorkflowInstanceCreateOptions<PARAMS>,
6534
+ ): Promise<WorkflowInstance>;
6535
+ }
6536
+ interface WorkflowInstanceCreateOptions<PARAMS = unknown> {
6537
+ /**
6538
+ * An id for your Workflow instance. Must be unique within the Workflow.
6539
+ */
6540
+ id?: string;
6541
+ /**
6542
+ * The event payload the Workflow instance is triggered with
6543
+ */
6544
+ params?: PARAMS;
6545
+ }
6546
+ type InstanceStatus = {
6547
+ status:
6548
+ | "queued" // means that instance is waiting to be started (see concurrency limits)
6549
+ | "running"
6550
+ | "paused"
6551
+ | "errored"
6552
+ | "terminated" // user terminated the instance while it was running
6553
+ | "complete"
6554
+ | "waiting" // instance is hibernating and waiting for sleep or event to finish
6555
+ | "waitingForPause" // instance is finishing the current work to pause
6556
+ | "unknown";
6557
+ error?: string;
6558
+ output?: object;
6559
+ };
6560
+ interface WorkflowError {
6561
+ code?: number;
6562
+ message: string;
6563
+ }
6564
+ declare abstract class WorkflowInstance {
6565
+ public id: string;
6566
+ /**
6567
+ * Pause the instance.
6568
+ */
6569
+ public pause(): Promise<void>;
6570
+ /**
6571
+ * Resume the instance. If it is already running, an error will be thrown.
6572
+ */
6573
+ public resume(): Promise<void>;
6574
+ /**
6575
+ * Terminate the instance. If it is errored, terminated or complete, an error will be thrown.
6576
+ */
6577
+ public terminate(): Promise<void>;
6578
+ /**
6579
+ * Restart the instance.
6580
+ */
6581
+ public restart(): Promise<void>;
6582
+ /**
6583
+ * Returns the current status of the instance.
6584
+ */
6585
+ public status(): Promise<InstanceStatus>;
6586
+ }