@cloudflare/workers-types 5.20260804.1 → 5.20260808.1

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.
@@ -503,6 +503,7 @@ interface ExecutionContext<Props = unknown> {
503
503
  readonly override?: string;
504
504
  };
505
505
  readonly access?: CloudflareAccessContext;
506
+ mapVirtualHost(fetcher: Fetcher, port: number): string;
506
507
  tracing: Tracing;
507
508
  abort(reason?: any): void;
508
509
  }
@@ -3414,6 +3415,12 @@ interface TraceLog {
3414
3415
  readonly timestamp: number;
3415
3416
  readonly level: string;
3416
3417
  readonly message: any;
3418
+ readonly errorInfo?: (TraceLogErrorInfo | null)[];
3419
+ }
3420
+ interface TraceLogErrorInfo {
3421
+ name: string;
3422
+ message: string;
3423
+ stack?: string;
3417
3424
  }
3418
3425
  interface TraceException {
3419
3426
  readonly timestamp: number;
@@ -3981,18 +3988,26 @@ interface ContainerExecOptions {
3981
3988
  cwd?: string;
3982
3989
  env?: Record<string, string>;
3983
3990
  user?: string;
3991
+ signal?: AbortSignal;
3992
+ pty?: boolean | ContainerExecPtyOptions;
3984
3993
  stdin?: ReadableStream | "pipe";
3985
3994
  stdout?: "pipe" | "ignore";
3986
3995
  stderr?: "pipe" | "ignore" | "combined";
3987
3996
  }
3997
+ interface ContainerExecPtyOptions {
3998
+ cols?: number;
3999
+ rows?: number;
4000
+ }
3988
4001
  interface ExecProcess {
3989
4002
  readonly stdin: WritableStream | null;
3990
4003
  readonly stdout: ReadableStream | null;
3991
4004
  readonly stderr: ReadableStream | null;
3992
4005
  readonly pid: number;
4006
+ readonly isPty: boolean;
3993
4007
  readonly exitCode: Promise<number>;
3994
4008
  output(): Promise<ExecOutput>;
3995
4009
  kill(signal?: number): void;
4010
+ resize(cols: number, rows: number): void;
3996
4011
  }
3997
4012
  interface Container {
3998
4013
  get running(): boolean;
@@ -4014,6 +4029,7 @@ interface Container {
4014
4029
  exec(cmd: string[], options?: ContainerExecOptions): Promise<ExecProcess>;
4015
4030
  interceptOutboundTcp(addr: string, binding: Fetcher): Promise<void>;
4016
4031
  inspect(): Promise<ContainerInfo | null>;
4032
+ setLabels(labels: Record<string, string>): Promise<void>;
4017
4033
  }
4018
4034
  interface ContainerDirectorySnapshot {
4019
4035
  id: string;
@@ -4037,19 +4053,39 @@ interface ContainerSnapshot {
4037
4053
  interface ContainerSnapshotOptions {
4038
4054
  name?: string;
4039
4055
  }
4040
- interface ContainerStartupOptions {
4056
+ type ContainerStartupOptions = {
4041
4057
  entrypoint?: string[];
4042
4058
  enableInternet: boolean;
4043
4059
  env?: Record<string, string>;
4044
4060
  hardTimeout?: number | bigint;
4061
+ instance?:
4062
+ | "lite"
4063
+ | "standard-1"
4064
+ | "standard-2"
4065
+ | "standard-3"
4066
+ | "standard-4"
4067
+ | ContainerStartResources;
4045
4068
  labels?: Record<string, string>;
4046
4069
  directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
4047
- containerSnapshot?: ContainerSnapshot;
4048
- }
4070
+ } & (
4071
+ | {
4072
+ image: string;
4073
+ containerSnapshot?: never;
4074
+ }
4075
+ | {
4076
+ image?: never;
4077
+ containerSnapshot?: ContainerSnapshot;
4078
+ }
4079
+ );
4049
4080
  interface ContainerInfo {
4050
4081
  labels: Record<string, string>;
4051
4082
  image: string;
4052
4083
  }
4084
+ interface ContainerStartResources {
4085
+ vcpu: number;
4086
+ memoryMib: number;
4087
+ diskMb: number;
4088
+ }
4053
4089
  /**
4054
4090
  * The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
4055
4091
  * Available only in secure contexts.
@@ -4744,11 +4780,15 @@ interface Tracing {
4744
4780
  callback: (span: Span, ...args: A) => T,
4745
4781
  ...args: A
4746
4782
  ): T;
4783
+ startSpan(name: string): Span;
4747
4784
  Span: typeof Span;
4748
4785
  }
4749
4786
  declare abstract class Span {
4750
4787
  get isTraced(): boolean;
4751
- setAttribute(key: string, value?: boolean | number | string): void;
4788
+ setAttribute(key: string, value: boolean | number | string): this;
4789
+ setAttributes(
4790
+ attributes: Record<string, boolean | number | string | undefined>,
4791
+ ): this;
4752
4792
  end(): void;
4753
4793
  }
4754
4794
  /**
@@ -5424,6 +5464,13 @@ type AiSearchListItemsParams = {
5424
5464
  source?: string;
5425
5465
  /** JSON-encoded Vectorize filter for metadata filtering. */
5426
5466
  metadata_filter?: string;
5467
+ /** Filter items by their unique ID. Returns at most one item. */
5468
+ item_id?: string;
5469
+ /**
5470
+ * Filter items by their exact key (object key / filename). Keys are unique
5471
+ * per source, so combine with `source` to disambiguate across data sources.
5472
+ */
5473
+ key?: string;
5427
5474
  };
5428
5475
  type AiSearchListItemsResponse = {
5429
5476
  result: AiSearchItemInfo[];
@@ -14572,6 +14619,15 @@ interface Hyperdrive {
14572
14619
  * for your database.
14573
14620
  */
14574
14621
  readonly host: string;
14622
+ /*
14623
+ * A synthetic IPv4 address (in the reserved 240.0.0.0/4 range) that, like the
14624
+ * host field, is only valid within the context of the currently running
14625
+ * Worker and, when passed into the `connect()` function from the
14626
+ * "cloudflare:sockets" module, will connect to the Hyperdrive instance for
14627
+ * your database. This is provided for database drivers that require the host
14628
+ * to be an IP literal rather than a hostname.
14629
+ */
14630
+ readonly ip: string;
14575
14631
  /*
14576
14632
  * The port that must be paired the the host field when connecting.
14577
14633
  */
@@ -15410,6 +15466,32 @@ declare namespace CloudflareWorkersModule {
15410
15466
  timeout?: WorkflowTimeoutDuration | number;
15411
15467
  sensitive?: WorkflowStepSensitivity;
15412
15468
  };
15469
+ // Internal discriminators used only for `WorkflowStep.do` overload
15470
+ // resolution. They mirror `WorkflowStepConfig` but pin `retries.delay` to a
15471
+ // single kind so the callback context can be narrowed based on the shape of
15472
+ // the config argument (rather than on an inferred type parameter, which is
15473
+ // lost when the caller supplies an explicit return-type argument). Not
15474
+ // exported: they must not widen the public type surface.
15475
+ type WorkflowStepConfigWithStaticDelay = Omit<
15476
+ WorkflowStepConfig,
15477
+ "retries"
15478
+ > & {
15479
+ retries?: {
15480
+ limit: number;
15481
+ delay: WorkflowDelayDuration | number;
15482
+ backoff?: WorkflowBackoff;
15483
+ };
15484
+ };
15485
+ type WorkflowStepConfigWithDelayFunction = Omit<
15486
+ WorkflowStepConfig,
15487
+ "retries"
15488
+ > & {
15489
+ retries: {
15490
+ limit: number;
15491
+ delay: WorkflowDelayFunction;
15492
+ backoff?: WorkflowBackoff;
15493
+ };
15494
+ };
15413
15495
  export type WorkflowStepRollbackConfig = Pick<
15414
15496
  WorkflowStepConfig,
15415
15497
  "retries" | "timeout"
@@ -15452,18 +15534,30 @@ declare namespace CloudflareWorkersModule {
15452
15534
  sensitive?: WorkflowStepSensitivity;
15453
15535
  };
15454
15536
  };
15455
- export type WorkflowRollbackContext<T = unknown> = {
15456
- ctx: WorkflowStepContext;
15537
+ // The rollback handler receives the step context, so it mirrors the same
15538
+ // delay discriminant as the step callback: when the step was configured with
15539
+ // a dynamic delay function the resolved `config.retries.delay` is omitted,
15540
+ // otherwise it is present. `Delay` is threaded from the `WorkflowStep.do`
15541
+ // overload that matched the step config.
15542
+ export type WorkflowRollbackContext<
15543
+ T = unknown,
15544
+ Delay = WorkflowDelayDuration | number,
15545
+ > = {
15546
+ ctx: WorkflowStepContext<Delay>;
15457
15547
  error: Error;
15458
15548
  output: T | undefined;
15459
15549
  /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */
15460
15550
  stepName: string;
15461
15551
  };
15462
- export type WorkflowRollbackHandler<T = unknown> = (
15463
- ctx: WorkflowRollbackContext<T>,
15464
- ) => Promise<void>;
15465
- export type WorkflowStepRollbackOptions<T = unknown> = {
15466
- rollback: WorkflowRollbackHandler<T>;
15552
+ export type WorkflowRollbackHandler<
15553
+ T = unknown,
15554
+ Delay = WorkflowDelayDuration | number,
15555
+ > = (ctx: WorkflowRollbackContext<T, Delay>) => Promise<void>;
15556
+ export type WorkflowStepRollbackOptions<
15557
+ T = unknown,
15558
+ Delay = WorkflowDelayDuration | number,
15559
+ > = {
15560
+ rollback: WorkflowRollbackHandler<T, Delay>;
15467
15561
  rollbackConfig?: WorkflowStepRollbackConfig;
15468
15562
  };
15469
15563
  export abstract class WorkflowStep {
@@ -15472,18 +15566,34 @@ declare namespace CloudflareWorkersModule {
15472
15566
  callback: (ctx: WorkflowStepContext) => Promise<T>,
15473
15567
  rollbackOptions?: WorkflowStepRollbackOptions<T>,
15474
15568
  ): Promise<T>;
15475
- do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(
15569
+ // The config overloads discriminate on the shape of `config.retries.delay`
15570
+ // so the callback context reflects whether the resolved delay is present
15571
+ // (static delay) or omitted (dynamic delay function). Each has a single
15572
+ // type parameter, so an explicit return-type argument (`do<T>(...)`) still
15573
+ // resolves here. ORDERING IS LOAD-BEARING: the broad `WorkflowStepConfig`
15574
+ // fallback MUST remain last, otherwise it shadows the discriminating
15575
+ // overloads and narrowing is silently lost.
15576
+ do<T extends Rpc.Serializable<T>>(
15476
15577
  name: string,
15477
- config: C,
15578
+ config: WorkflowStepConfigWithDelayFunction,
15579
+ callback: (ctx: WorkflowStepContext<WorkflowDelayFunction>) => Promise<T>,
15580
+ rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayFunction>,
15581
+ ): Promise<T>;
15582
+ do<T extends Rpc.Serializable<T>>(
15583
+ name: string,
15584
+ config: WorkflowStepConfigWithStaticDelay,
15478
15585
  callback: (
15479
- ctx: WorkflowStepContext<
15480
- C["retries"] extends {
15481
- delay: infer D;
15482
- }
15483
- ? D
15484
- : WorkflowDelayDuration | number
15485
- >,
15586
+ ctx: WorkflowStepContext<WorkflowDelayDuration | number>,
15486
15587
  ) => Promise<T>,
15588
+ rollbackOptions?: WorkflowStepRollbackOptions<
15589
+ T,
15590
+ WorkflowDelayDuration | number
15591
+ >,
15592
+ ): Promise<T>;
15593
+ do<T extends Rpc.Serializable<T>>(
15594
+ name: string,
15595
+ config: WorkflowStepConfig,
15596
+ callback: (ctx: WorkflowStepContext) => Promise<T>,
15487
15597
  rollbackOptions?: WorkflowStepRollbackOptions<T>,
15488
15598
  ): Promise<T>;
15489
15599
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
@@ -16302,12 +16412,13 @@ type MarkdownDocument = {
16302
16412
  name: string;
16303
16413
  blob: Blob;
16304
16414
  };
16415
+ type OutputFormat = "markdown" | "text";
16305
16416
  type ConversionResponse =
16306
16417
  | {
16307
16418
  id: string;
16308
16419
  name: string;
16309
16420
  mimeType: string;
16310
- format: "markdown";
16421
+ format: OutputFormat;
16311
16422
  tokens: number;
16312
16423
  data: string;
16313
16424
  }
@@ -16325,7 +16436,11 @@ type EmbeddedImageConversionOptions = ImageConversionOptions & {
16325
16436
  convert?: boolean;
16326
16437
  maxConvertedImages?: number;
16327
16438
  };
16439
+ type ConversionOutputOptions = {
16440
+ format?: OutputFormat;
16441
+ };
16328
16442
  type ConversionOptions = {
16443
+ output?: ConversionOutputOptions;
16329
16444
  html?: {
16330
16445
  images?: EmbeddedImageConversionOptions & {
16331
16446
  convertOGImage?: boolean;
@@ -16506,11 +16621,25 @@ declare namespace TailStream {
16506
16621
  readonly message: string;
16507
16622
  readonly stack?: string;
16508
16623
  }
16509
- interface Log {
16624
+ interface TailStreamErrorInfo {
16625
+ readonly name: string;
16626
+ readonly message: string;
16627
+ readonly stack?: string;
16628
+ }
16629
+ type Log = {
16510
16630
  readonly type: "log";
16511
16631
  readonly level: "debug" | "error" | "info" | "log" | "warn";
16512
- readonly message: object;
16513
- }
16632
+ readonly errorInfo?: readonly (TailStreamErrorInfo | null)[];
16633
+ } & (
16634
+ | {
16635
+ readonly message: object;
16636
+ readonly truncated?: false;
16637
+ }
16638
+ | {
16639
+ readonly message: string;
16640
+ readonly truncated: true;
16641
+ }
16642
+ );
16514
16643
  interface DroppedEventsDiagnostic {
16515
16644
  readonly diagnosticsType: "droppedEvents";
16516
16645
  readonly count: number;
@@ -17046,7 +17175,25 @@ declare abstract class Workflow<PARAMS = unknown> {
17046
17175
  public createBatch(
17047
17176
  batch: WorkflowInstanceCreateOptions<PARAMS>[],
17048
17177
  ): Promise<WorkflowInstance[]>;
17178
+ /**
17179
+ * Delete a batch of Workflow instances and their stored state.
17180
+ * `deleteBatch` is limited to 100 instances at a time. Duplicate IDs are deleted once.
17181
+ * The result contains one entry for each input position; IDs that do not exist are returned as per-instance errors.
17182
+ * @param instanceIds IDs of the Workflow instances to delete
17183
+ * @returns A promise that resolves with the successfully deleted instances and any per-instance errors.
17184
+ */
17185
+ public deleteBatch(instanceIds: string[]): Promise<WorkflowBatchDeleteResult>;
17049
17186
  }
17187
+ type WorkflowBatchDeleteResult = {
17188
+ deleted: {
17189
+ id: string;
17190
+ }[];
17191
+ errors: {
17192
+ id: string;
17193
+ code: number;
17194
+ message: string;
17195
+ }[];
17196
+ };
17050
17197
  type WorkflowDurationLabel =
17051
17198
  | "second"
17052
17199
  | "minute"
@@ -17147,6 +17294,10 @@ declare abstract class WorkflowInstance {
17147
17294
  * @param options Options for the restart, including an optional step to restart from.
17148
17295
  */
17149
17296
  public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
17297
+ /**
17298
+ * Delete the instance and its stored state.
17299
+ */
17300
+ public delete(): Promise<void>;
17150
17301
  /**
17151
17302
  * Returns the current status of the instance.
17152
17303
  */
@@ -505,6 +505,7 @@ export interface ExecutionContext<Props = unknown> {
505
505
  readonly override?: string;
506
506
  };
507
507
  readonly access?: CloudflareAccessContext;
508
+ mapVirtualHost(fetcher: Fetcher, port: number): string;
508
509
  tracing: Tracing;
509
510
  abort(reason?: any): void;
510
511
  }
@@ -3424,6 +3425,12 @@ export interface TraceLog {
3424
3425
  readonly timestamp: number;
3425
3426
  readonly level: string;
3426
3427
  readonly message: any;
3428
+ readonly errorInfo?: (TraceLogErrorInfo | null)[];
3429
+ }
3430
+ export interface TraceLogErrorInfo {
3431
+ name: string;
3432
+ message: string;
3433
+ stack?: string;
3427
3434
  }
3428
3435
  export interface TraceException {
3429
3436
  readonly timestamp: number;
@@ -3991,18 +3998,26 @@ export interface ContainerExecOptions {
3991
3998
  cwd?: string;
3992
3999
  env?: Record<string, string>;
3993
4000
  user?: string;
4001
+ signal?: AbortSignal;
4002
+ pty?: boolean | ContainerExecPtyOptions;
3994
4003
  stdin?: ReadableStream | "pipe";
3995
4004
  stdout?: "pipe" | "ignore";
3996
4005
  stderr?: "pipe" | "ignore" | "combined";
3997
4006
  }
4007
+ export interface ContainerExecPtyOptions {
4008
+ cols?: number;
4009
+ rows?: number;
4010
+ }
3998
4011
  export interface ExecProcess {
3999
4012
  readonly stdin: WritableStream | null;
4000
4013
  readonly stdout: ReadableStream | null;
4001
4014
  readonly stderr: ReadableStream | null;
4002
4015
  readonly pid: number;
4016
+ readonly isPty: boolean;
4003
4017
  readonly exitCode: Promise<number>;
4004
4018
  output(): Promise<ExecOutput>;
4005
4019
  kill(signal?: number): void;
4020
+ resize(cols: number, rows: number): void;
4006
4021
  }
4007
4022
  export interface Container {
4008
4023
  get running(): boolean;
@@ -4024,6 +4039,7 @@ export interface Container {
4024
4039
  exec(cmd: string[], options?: ContainerExecOptions): Promise<ExecProcess>;
4025
4040
  interceptOutboundTcp(addr: string, binding: Fetcher): Promise<void>;
4026
4041
  inspect(): Promise<ContainerInfo | null>;
4042
+ setLabels(labels: Record<string, string>): Promise<void>;
4027
4043
  }
4028
4044
  export interface ContainerDirectorySnapshot {
4029
4045
  id: string;
@@ -4047,19 +4063,39 @@ export interface ContainerSnapshot {
4047
4063
  export interface ContainerSnapshotOptions {
4048
4064
  name?: string;
4049
4065
  }
4050
- export interface ContainerStartupOptions {
4066
+ export type ContainerStartupOptions = {
4051
4067
  entrypoint?: string[];
4052
4068
  enableInternet: boolean;
4053
4069
  env?: Record<string, string>;
4054
4070
  hardTimeout?: number | bigint;
4071
+ instance?:
4072
+ | "lite"
4073
+ | "standard-1"
4074
+ | "standard-2"
4075
+ | "standard-3"
4076
+ | "standard-4"
4077
+ | ContainerStartResources;
4055
4078
  labels?: Record<string, string>;
4056
4079
  directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
4057
- containerSnapshot?: ContainerSnapshot;
4058
- }
4080
+ } & (
4081
+ | {
4082
+ image: string;
4083
+ containerSnapshot?: never;
4084
+ }
4085
+ | {
4086
+ image?: never;
4087
+ containerSnapshot?: ContainerSnapshot;
4088
+ }
4089
+ );
4059
4090
  export interface ContainerInfo {
4060
4091
  labels: Record<string, string>;
4061
4092
  image: string;
4062
4093
  }
4094
+ export interface ContainerStartResources {
4095
+ vcpu: number;
4096
+ memoryMib: number;
4097
+ diskMb: number;
4098
+ }
4063
4099
  /**
4064
4100
  * The **`FileSystemHandle`** interface of the File System API is an object which represents a file or directory entry.
4065
4101
  * Available only in secure contexts.
@@ -4754,11 +4790,15 @@ export interface Tracing {
4754
4790
  callback: (span: Span, ...args: A) => T,
4755
4791
  ...args: A
4756
4792
  ): T;
4793
+ startSpan(name: string): Span;
4757
4794
  Span: typeof Span;
4758
4795
  }
4759
4796
  export declare abstract class Span {
4760
4797
  get isTraced(): boolean;
4761
- setAttribute(key: string, value?: boolean | number | string): void;
4798
+ setAttribute(key: string, value: boolean | number | string): this;
4799
+ setAttributes(
4800
+ attributes: Record<string, boolean | number | string | undefined>,
4801
+ ): this;
4762
4802
  end(): void;
4763
4803
  }
4764
4804
  /**
@@ -5435,6 +5475,13 @@ export type AiSearchListItemsParams = {
5435
5475
  source?: string;
5436
5476
  /** JSON-encoded Vectorize filter for metadata filtering. */
5437
5477
  metadata_filter?: string;
5478
+ /** Filter items by their unique ID. Returns at most one item. */
5479
+ item_id?: string;
5480
+ /**
5481
+ * Filter items by their exact key (object key / filename). Keys are unique
5482
+ * per source, so combine with `source` to disambiguate across data sources.
5483
+ */
5484
+ key?: string;
5438
5485
  };
5439
5486
  export type AiSearchListItemsResponse = {
5440
5487
  result: AiSearchItemInfo[];
@@ -14599,6 +14646,15 @@ export interface Hyperdrive {
14599
14646
  * for your database.
14600
14647
  */
14601
14648
  readonly host: string;
14649
+ /*
14650
+ * A synthetic IPv4 address (in the reserved 240.0.0.0/4 range) that, like the
14651
+ * host field, is only valid within the context of the currently running
14652
+ * Worker and, when passed into the `connect()` function from the
14653
+ * "cloudflare:sockets" module, will connect to the Hyperdrive instance for
14654
+ * your database. This is provided for database drivers that require the host
14655
+ * to be an IP literal rather than a hostname.
14656
+ */
14657
+ readonly ip: string;
14602
14658
  /*
14603
14659
  * The port that must be paired the the host field when connecting.
14604
14660
  */
@@ -15388,6 +15444,32 @@ export declare namespace CloudflareWorkersModule {
15388
15444
  timeout?: WorkflowTimeoutDuration | number;
15389
15445
  sensitive?: WorkflowStepSensitivity;
15390
15446
  };
15447
+ // Internal discriminators used only for `WorkflowStep.do` overload
15448
+ // resolution. They mirror `WorkflowStepConfig` but pin `retries.delay` to a
15449
+ // single kind so the callback context can be narrowed based on the shape of
15450
+ // the config argument (rather than on an inferred type parameter, which is
15451
+ // lost when the caller supplies an explicit return-type argument). Not
15452
+ // exported: they must not widen the public type surface.
15453
+ type WorkflowStepConfigWithStaticDelay = Omit<
15454
+ WorkflowStepConfig,
15455
+ "retries"
15456
+ > & {
15457
+ retries?: {
15458
+ limit: number;
15459
+ delay: WorkflowDelayDuration | number;
15460
+ backoff?: WorkflowBackoff;
15461
+ };
15462
+ };
15463
+ type WorkflowStepConfigWithDelayFunction = Omit<
15464
+ WorkflowStepConfig,
15465
+ "retries"
15466
+ > & {
15467
+ retries: {
15468
+ limit: number;
15469
+ delay: WorkflowDelayFunction;
15470
+ backoff?: WorkflowBackoff;
15471
+ };
15472
+ };
15391
15473
  export type WorkflowStepRollbackConfig = Pick<
15392
15474
  WorkflowStepConfig,
15393
15475
  "retries" | "timeout"
@@ -15430,18 +15512,30 @@ export declare namespace CloudflareWorkersModule {
15430
15512
  sensitive?: WorkflowStepSensitivity;
15431
15513
  };
15432
15514
  };
15433
- export type WorkflowRollbackContext<T = unknown> = {
15434
- ctx: WorkflowStepContext;
15515
+ // The rollback handler receives the step context, so it mirrors the same
15516
+ // delay discriminant as the step callback: when the step was configured with
15517
+ // a dynamic delay function the resolved `config.retries.delay` is omitted,
15518
+ // otherwise it is present. `Delay` is threaded from the `WorkflowStep.do`
15519
+ // overload that matched the step config.
15520
+ export type WorkflowRollbackContext<
15521
+ T = unknown,
15522
+ Delay = WorkflowDelayDuration | number,
15523
+ > = {
15524
+ ctx: WorkflowStepContext<Delay>;
15435
15525
  error: Error;
15436
15526
  output: T | undefined;
15437
15527
  /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */
15438
15528
  stepName: string;
15439
15529
  };
15440
- export type WorkflowRollbackHandler<T = unknown> = (
15441
- ctx: WorkflowRollbackContext<T>,
15442
- ) => Promise<void>;
15443
- export type WorkflowStepRollbackOptions<T = unknown> = {
15444
- rollback: WorkflowRollbackHandler<T>;
15530
+ export type WorkflowRollbackHandler<
15531
+ T = unknown,
15532
+ Delay = WorkflowDelayDuration | number,
15533
+ > = (ctx: WorkflowRollbackContext<T, Delay>) => Promise<void>;
15534
+ export type WorkflowStepRollbackOptions<
15535
+ T = unknown,
15536
+ Delay = WorkflowDelayDuration | number,
15537
+ > = {
15538
+ rollback: WorkflowRollbackHandler<T, Delay>;
15445
15539
  rollbackConfig?: WorkflowStepRollbackConfig;
15446
15540
  };
15447
15541
  export abstract class WorkflowStep {
@@ -15450,18 +15544,34 @@ export declare namespace CloudflareWorkersModule {
15450
15544
  callback: (ctx: WorkflowStepContext) => Promise<T>,
15451
15545
  rollbackOptions?: WorkflowStepRollbackOptions<T>,
15452
15546
  ): Promise<T>;
15453
- do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(
15547
+ // The config overloads discriminate on the shape of `config.retries.delay`
15548
+ // so the callback context reflects whether the resolved delay is present
15549
+ // (static delay) or omitted (dynamic delay function). Each has a single
15550
+ // type parameter, so an explicit return-type argument (`do<T>(...)`) still
15551
+ // resolves here. ORDERING IS LOAD-BEARING: the broad `WorkflowStepConfig`
15552
+ // fallback MUST remain last, otherwise it shadows the discriminating
15553
+ // overloads and narrowing is silently lost.
15554
+ do<T extends Rpc.Serializable<T>>(
15454
15555
  name: string,
15455
- config: C,
15556
+ config: WorkflowStepConfigWithDelayFunction,
15557
+ callback: (ctx: WorkflowStepContext<WorkflowDelayFunction>) => Promise<T>,
15558
+ rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayFunction>,
15559
+ ): Promise<T>;
15560
+ do<T extends Rpc.Serializable<T>>(
15561
+ name: string,
15562
+ config: WorkflowStepConfigWithStaticDelay,
15456
15563
  callback: (
15457
- ctx: WorkflowStepContext<
15458
- C["retries"] extends {
15459
- delay: infer D;
15460
- }
15461
- ? D
15462
- : WorkflowDelayDuration | number
15463
- >,
15564
+ ctx: WorkflowStepContext<WorkflowDelayDuration | number>,
15464
15565
  ) => Promise<T>,
15566
+ rollbackOptions?: WorkflowStepRollbackOptions<
15567
+ T,
15568
+ WorkflowDelayDuration | number
15569
+ >,
15570
+ ): Promise<T>;
15571
+ do<T extends Rpc.Serializable<T>>(
15572
+ name: string,
15573
+ config: WorkflowStepConfig,
15574
+ callback: (ctx: WorkflowStepContext) => Promise<T>,
15465
15575
  rollbackOptions?: WorkflowStepRollbackOptions<T>,
15466
15576
  ): Promise<T>;
15467
15577
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
@@ -16270,12 +16380,13 @@ export type MarkdownDocument = {
16270
16380
  name: string;
16271
16381
  blob: Blob;
16272
16382
  };
16383
+ export type OutputFormat = "markdown" | "text";
16273
16384
  export type ConversionResponse =
16274
16385
  | {
16275
16386
  id: string;
16276
16387
  name: string;
16277
16388
  mimeType: string;
16278
- format: "markdown";
16389
+ format: OutputFormat;
16279
16390
  tokens: number;
16280
16391
  data: string;
16281
16392
  }
@@ -16293,7 +16404,11 @@ export type EmbeddedImageConversionOptions = ImageConversionOptions & {
16293
16404
  convert?: boolean;
16294
16405
  maxConvertedImages?: number;
16295
16406
  };
16407
+ export type ConversionOutputOptions = {
16408
+ format?: OutputFormat;
16409
+ };
16296
16410
  export type ConversionOptions = {
16411
+ output?: ConversionOutputOptions;
16297
16412
  html?: {
16298
16413
  images?: EmbeddedImageConversionOptions & {
16299
16414
  convertOGImage?: boolean;
@@ -16474,11 +16589,25 @@ export declare namespace TailStream {
16474
16589
  readonly message: string;
16475
16590
  readonly stack?: string;
16476
16591
  }
16477
- interface Log {
16592
+ interface TailStreamErrorInfo {
16593
+ readonly name: string;
16594
+ readonly message: string;
16595
+ readonly stack?: string;
16596
+ }
16597
+ type Log = {
16478
16598
  readonly type: "log";
16479
16599
  readonly level: "debug" | "error" | "info" | "log" | "warn";
16480
- readonly message: object;
16481
- }
16600
+ readonly errorInfo?: readonly (TailStreamErrorInfo | null)[];
16601
+ } & (
16602
+ | {
16603
+ readonly message: object;
16604
+ readonly truncated?: false;
16605
+ }
16606
+ | {
16607
+ readonly message: string;
16608
+ readonly truncated: true;
16609
+ }
16610
+ );
16482
16611
  interface DroppedEventsDiagnostic {
16483
16612
  readonly diagnosticsType: "droppedEvents";
16484
16613
  readonly count: number;
@@ -17005,7 +17134,25 @@ export declare abstract class Workflow<PARAMS = unknown> {
17005
17134
  public createBatch(
17006
17135
  batch: WorkflowInstanceCreateOptions<PARAMS>[],
17007
17136
  ): Promise<WorkflowInstance[]>;
17137
+ /**
17138
+ * Delete a batch of Workflow instances and their stored state.
17139
+ * `deleteBatch` is limited to 100 instances at a time. Duplicate IDs are deleted once.
17140
+ * The result contains one entry for each input position; IDs that do not exist are returned as per-instance errors.
17141
+ * @param instanceIds IDs of the Workflow instances to delete
17142
+ * @returns A promise that resolves with the successfully deleted instances and any per-instance errors.
17143
+ */
17144
+ public deleteBatch(instanceIds: string[]): Promise<WorkflowBatchDeleteResult>;
17008
17145
  }
17146
+ export type WorkflowBatchDeleteResult = {
17147
+ deleted: {
17148
+ id: string;
17149
+ }[];
17150
+ errors: {
17151
+ id: string;
17152
+ code: number;
17153
+ message: string;
17154
+ }[];
17155
+ };
17009
17156
  export type WorkflowDurationLabel =
17010
17157
  | "second"
17011
17158
  | "minute"
@@ -17106,6 +17253,10 @@ export declare abstract class WorkflowInstance {
17106
17253
  * @param options Options for the restart, including an optional step to restart from.
17107
17254
  */
17108
17255
  public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
17256
+ /**
17257
+ * Delete the instance and its stored state.
17258
+ */
17259
+ public delete(): Promise<void>;
17109
17260
  /**
17110
17261
  * Returns the current status of the instance.
17111
17262
  */