two-stroke 7.11.4 → 7.11.5

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.
package/package.json CHANGED
@@ -10,18 +10,18 @@
10
10
  "type-check": "./bin/type-check.mjs"
11
11
  },
12
12
  "dependencies": {
13
- "@cloudflare/vitest-pool-workers": "^0.18.8",
13
+ "@cloudflare/vitest-pool-workers": "^0.21.3",
14
14
  "@sentry/cli": "^3.6.2",
15
- "@typescript-eslint/eslint-plugin": "^8.65.0",
16
- "@typescript-eslint/parser": "^8.65.0",
17
- "@vitest/runner": "^4.1.8",
18
- "@vitest/snapshot": "^4.1.8",
15
+ "@typescript-eslint/eslint-plugin": "^8.67.0",
16
+ "@typescript-eslint/parser": "^8.67.0",
17
+ "@vitest/runner": "^4.1.10",
18
+ "@vitest/snapshot": "^4.1.10",
19
19
  "eslint-config-prettier": "^10.1.8",
20
- "eslint-config-two-stroke": "^1.5.9",
20
+ "eslint-config-two-stroke": "^1.5.10",
21
21
  "eslint-config-typescript": "^3.0.0",
22
- "jose": "^6.2.4",
22
+ "jose": "^6.2.8",
23
23
  "mime": "^4.1.0",
24
- "miniflare": "^4.20260722.0",
24
+ "miniflare": "5.20260811.1-alpha",
25
25
  "msw": "^2.14.6",
26
26
  "openapi-fetch": "^0.17.0",
27
27
  "openapi-typescript": "^7.13.0",
@@ -56,10 +56,10 @@
56
56
  "url": "https://github.com/change-engine/two-stroke"
57
57
  },
58
58
  "type": "module",
59
- "version": "7.11.4",
59
+ "version": "7.11.5",
60
60
  "devDependencies": {
61
61
  "@types/eslint": "^9.6.1",
62
- "eslint": "^10.8.0",
62
+ "eslint": "^10.8.1",
63
63
  "prettier": "^3.9.6",
64
64
  "typescript": "^6.0.3",
65
65
  "vitest": "^4.1.10"
@@ -1,16 +1,9 @@
1
1
  /* eslint-disable */
2
- // Generated by Wrangler by running `wrangler types` (hash: 257ab1035028648fc82c85d44bb6571e)
3
- // Runtime types generated with workerd@1.20260708.1 2025-09-15 disable_nodejs_fs_module,nodejs_compat
2
+ // Generated by Wrangler by running `wrangler types` (hash: a586733b457304f7909e3b75aa9b2082)
3
+ // Runtime types generated with workerd@1.20260811.1 2025-09-15 disable_nodejs_fs_module,nodejs_compat
4
4
  interface __BaseEnv_Env {
5
- KINESIS_STREAM_NAME_V2: string;
6
- LABS_PRIVATE_KEY: string;
7
- SENTRY_DSN: string;
8
- SENTRY_ENVIRONMENT: string;
9
- SENTRY_TRACES_SAMPLE_RATE: string;
10
- SLACK_SUPABASE_PUBLIC_KEY: string;
11
- TOKEN_AUDIENCE: string;
12
- TOKEN_HASH: string;
13
- TOKEN_ISSUER: string;
5
+ TOKEN_ISSUER: "fake";
6
+ TOKEN_AUDIENCE: "fake";
14
7
  }
15
8
  declare namespace Cloudflare {
16
9
  interface GlobalProps {
@@ -23,7 +16,7 @@ type StringifyValues<EnvType extends Record<string, unknown>> = {
23
16
  [Binding in keyof EnvType]: EnvType[Binding] extends string ? EnvType[Binding] : string;
24
17
  };
25
18
  declare namespace NodeJS {
26
- interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "KINESIS_STREAM_NAME_V2" | "LABS_PRIVATE_KEY" | "SENTRY_DSN" | "SENTRY_ENVIRONMENT" | "SENTRY_TRACES_SAMPLE_RATE" | "SLACK_SUPABASE_PUBLIC_KEY" | "TOKEN_AUDIENCE" | "TOKEN_HASH" | "TOKEN_ISSUER">> {}
19
+ interface ProcessEnv extends StringifyValues<Pick<Cloudflare.Env, "TOKEN_ISSUER" | "TOKEN_AUDIENCE">> {}
27
20
  }
28
21
 
29
22
  // Begin runtime types
@@ -450,6 +443,7 @@ interface ExecutionContext<Props = unknown> {
450
443
  cache?: CacheContext;
451
444
  readonly access?: CloudflareAccessContext;
452
445
  tracing: Tracing;
446
+ abort(reason?: any): void;
453
447
  }
454
448
  type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown, Props = unknown> = (request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>, env: Env, ctx: ExecutionContext<Props>) => Response | Promise<Response>;
455
449
  type ExportedHandlerConnectHandler<Env = unknown, Props = unknown> = (socket: Socket, env: Env, ctx: ExecutionContext<Props>) => void | Promise<void>;
@@ -2782,6 +2776,12 @@ interface TraceLog {
2782
2776
  readonly timestamp: number;
2783
2777
  readonly level: string;
2784
2778
  readonly message: any;
2779
+ readonly errorInfo?: (TraceLogErrorInfo | null)[];
2780
+ }
2781
+ interface TraceLogErrorInfo {
2782
+ name: string;
2783
+ message: string;
2784
+ stack?: string;
2785
2785
  }
2786
2786
  interface TraceException {
2787
2787
  readonly timestamp: number;
@@ -3322,18 +3322,26 @@ interface ContainerExecOptions {
3322
3322
  cwd?: string;
3323
3323
  env?: Record<string, string>;
3324
3324
  user?: string;
3325
+ signal?: AbortSignal;
3326
+ pty?: boolean | ContainerExecPtyOptions;
3325
3327
  stdin?: ReadableStream | "pipe";
3326
3328
  stdout?: "pipe" | "ignore";
3327
3329
  stderr?: "pipe" | "ignore" | "combined";
3328
3330
  }
3331
+ interface ContainerExecPtyOptions {
3332
+ cols?: number;
3333
+ rows?: number;
3334
+ }
3329
3335
  interface ExecProcess {
3330
3336
  readonly stdin: WritableStream | null;
3331
3337
  readonly stdout: ReadableStream | null;
3332
3338
  readonly stderr: ReadableStream | null;
3333
3339
  readonly pid: number;
3340
+ readonly isPty: boolean;
3334
3341
  readonly exitCode: Promise<number>;
3335
3342
  output(): Promise<ExecOutput>;
3336
3343
  kill(signal?: number): void;
3344
+ resize(cols: number, rows: number): void;
3337
3345
  }
3338
3346
  interface Container {
3339
3347
  get running(): boolean;
@@ -3380,6 +3388,11 @@ interface ContainerStartupOptions {
3380
3388
  directorySnapshots?: ContainerDirectorySnapshotRestoreParams[];
3381
3389
  containerSnapshot?: ContainerSnapshot;
3382
3390
  }
3391
+ interface ContainerStartResources {
3392
+ vcpu: number;
3393
+ memoryMib: number;
3394
+ diskMb: number;
3395
+ }
3383
3396
  /**
3384
3397
  * The **`MessagePort`** interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
3385
3398
  *
@@ -3520,11 +3533,13 @@ declare abstract class Performance {
3520
3533
  interface Tracing {
3521
3534
  enterSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;
3522
3535
  startActiveSpan<T, A extends unknown[]>(name: string, callback: (span: Span, ...args: A) => T, ...args: A): T;
3536
+ startSpan(name: string): Span;
3523
3537
  Span: typeof Span;
3524
3538
  }
3525
3539
  declare abstract class Span {
3526
3540
  get isTraced(): boolean;
3527
- setAttribute(key: string, value?: (boolean | number | string)): void;
3541
+ setAttribute(key: string, value: boolean | number | string): this;
3542
+ setAttributes(attributes: Record<string, boolean | number | string | undefined>): this;
3528
3543
  end(): void;
3529
3544
  }
3530
3545
  /**
@@ -4164,6 +4179,13 @@ type AiSearchListItemsParams = {
4164
4179
  source?: string;
4165
4180
  /** JSON-encoded Vectorize filter for metadata filtering. */
4166
4181
  metadata_filter?: string;
4182
+ /** Filter items by their unique ID. Returns at most one item. */
4183
+ item_id?: string;
4184
+ /**
4185
+ * Filter items by their exact key (object key / filename). Keys are unique
4186
+ * per source, so combine with `source` to disambiguate across data sources.
4187
+ */
4188
+ key?: string;
4167
4189
  };
4168
4190
  type AiSearchListItemsResponse = {
4169
4191
  result: AiSearchItemInfo[];
@@ -12452,6 +12474,15 @@ interface Hyperdrive {
12452
12474
  * for your database.
12453
12475
  */
12454
12476
  readonly host: string;
12477
+ /*
12478
+ * A synthetic IPv4 address (in the reserved 240.0.0.0/4 range) that, like the
12479
+ * host field, is only valid within the context of the currently running
12480
+ * Worker and, when passed into the `connect()` function from the
12481
+ * "cloudflare:sockets" module, will connect to the Hyperdrive instance for
12482
+ * your database. This is provided for database drivers that require the host
12483
+ * to be an IP literal rather than a hostname.
12484
+ */
12485
+ readonly ip: string;
12455
12486
  /*
12456
12487
  * The port that must be paired the the host field when connecting.
12457
12488
  */
@@ -13138,6 +13169,26 @@ declare namespace CloudflareWorkersModule {
13138
13169
  timeout?: WorkflowTimeoutDuration | number;
13139
13170
  sensitive?: WorkflowStepSensitivity;
13140
13171
  };
13172
+ // Internal discriminators used only for `WorkflowStep.do` overload
13173
+ // resolution. They mirror `WorkflowStepConfig` but pin `retries.delay` to a
13174
+ // single kind so the callback context can be narrowed based on the shape of
13175
+ // the config argument (rather than on an inferred type parameter, which is
13176
+ // lost when the caller supplies an explicit return-type argument). Not
13177
+ // exported: they must not widen the public type surface.
13178
+ type WorkflowStepConfigWithStaticDelay = Omit<WorkflowStepConfig, 'retries'> & {
13179
+ retries?: {
13180
+ limit: number;
13181
+ delay: WorkflowDelayDuration | number;
13182
+ backoff?: WorkflowBackoff;
13183
+ };
13184
+ };
13185
+ type WorkflowStepConfigWithDelayFunction = Omit<WorkflowStepConfig, 'retries'> & {
13186
+ retries: {
13187
+ limit: number;
13188
+ delay: WorkflowDelayFunction;
13189
+ backoff?: WorkflowBackoff;
13190
+ };
13191
+ };
13141
13192
  export type WorkflowStepRollbackConfig = Pick<WorkflowStepConfig, 'retries' | 'timeout'>;
13142
13193
  export type WorkflowCronSchedule = {
13143
13194
  /** Cron expression that triggered this event. */
@@ -13175,23 +13226,35 @@ declare namespace CloudflareWorkersModule {
13175
13226
  sensitive?: WorkflowStepSensitivity;
13176
13227
  };
13177
13228
  };
13178
- export type WorkflowRollbackContext<T = unknown> = {
13179
- ctx: WorkflowStepContext;
13229
+ // The rollback handler receives the step context, so it mirrors the same
13230
+ // delay discriminant as the step callback: when the step was configured with
13231
+ // a dynamic delay function the resolved `config.retries.delay` is omitted,
13232
+ // otherwise it is present. `Delay` is threaded from the `WorkflowStep.do`
13233
+ // overload that matched the step config.
13234
+ export type WorkflowRollbackContext<T = unknown, Delay = WorkflowDelayDuration | number> = {
13235
+ ctx: WorkflowStepContext<Delay>;
13180
13236
  error: Error;
13181
13237
  output: T | undefined;
13182
13238
  /** @deprecated Use `ctx.step.name` and `ctx.step.count` instead. */
13183
13239
  stepName: string;
13184
13240
  };
13185
- export type WorkflowRollbackHandler<T = unknown> = (ctx: WorkflowRollbackContext<T>) => Promise<void>;
13186
- export type WorkflowStepRollbackOptions<T = unknown> = {
13187
- rollback: WorkflowRollbackHandler<T>;
13241
+ export type WorkflowRollbackHandler<T = unknown, Delay = WorkflowDelayDuration | number> = (ctx: WorkflowRollbackContext<T, Delay>) => Promise<void>;
13242
+ export type WorkflowStepRollbackOptions<T = unknown, Delay = WorkflowDelayDuration | number> = {
13243
+ rollback: WorkflowRollbackHandler<T, Delay>;
13188
13244
  rollbackConfig?: WorkflowStepRollbackConfig;
13189
13245
  };
13190
13246
  export abstract class WorkflowStep {
13191
13247
  do<T extends Rpc.Serializable<T>>(name: string, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;
13192
- do<T extends Rpc.Serializable<T>, const C extends WorkflowStepConfig>(name: string, config: C, callback: (ctx: WorkflowStepContext<C['retries'] extends {
13193
- delay: infer D;
13194
- } ? D : WorkflowDelayDuration | number>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;
13248
+ // The config overloads discriminate on the shape of `config.retries.delay`
13249
+ // so the callback context reflects whether the resolved delay is present
13250
+ // (static delay) or omitted (dynamic delay function). Each has a single
13251
+ // type parameter, so an explicit return-type argument (`do<T>(...)`) still
13252
+ // resolves here. ORDERING IS LOAD-BEARING: the broad `WorkflowStepConfig`
13253
+ // fallback MUST remain last, otherwise it shadows the discriminating
13254
+ // overloads and narrowing is silently lost.
13255
+ do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithDelayFunction, callback: (ctx: WorkflowStepContext<WorkflowDelayFunction>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayFunction>): Promise<T>;
13256
+ do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfigWithStaticDelay, callback: (ctx: WorkflowStepContext<WorkflowDelayDuration | number>) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T, WorkflowDelayDuration | number>): Promise<T>;
13257
+ do<T extends Rpc.Serializable<T>>(name: string, config: WorkflowStepConfig, callback: (ctx: WorkflowStepContext) => Promise<T>, rollbackOptions?: WorkflowStepRollbackOptions<T>): Promise<T>;
13195
13258
  sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
13196
13259
  sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
13197
13260
  waitForEvent<T extends Rpc.Serializable<T>>(name: string, options: {
@@ -13966,11 +14029,12 @@ type MarkdownDocument = {
13966
14029
  name: string;
13967
14030
  blob: Blob;
13968
14031
  };
14032
+ type OutputFormat = 'markdown' | 'text';
13969
14033
  type ConversionResponse = {
13970
14034
  id: string;
13971
14035
  name: string;
13972
14036
  mimeType: string;
13973
- format: 'markdown';
14037
+ format: OutputFormat;
13974
14038
  tokens: number;
13975
14039
  data: string;
13976
14040
  } | {
@@ -13987,7 +14051,11 @@ type EmbeddedImageConversionOptions = ImageConversionOptions & {
13987
14051
  convert?: boolean;
13988
14052
  maxConvertedImages?: number;
13989
14053
  };
14054
+ type ConversionOutputOptions = {
14055
+ format?: OutputFormat;
14056
+ };
13990
14057
  type ConversionOptions = {
14058
+ output?: ConversionOutputOptions;
13991
14059
  html?: {
13992
14060
  images?: EmbeddedImageConversionOptions & {
13993
14061
  convertOGImage?: boolean;
@@ -14136,11 +14204,22 @@ declare namespace TailStream {
14136
14204
  readonly message: string;
14137
14205
  readonly stack?: string;
14138
14206
  }
14139
- interface Log {
14207
+ interface TailStreamErrorInfo {
14208
+ readonly name: string;
14209
+ readonly message: string;
14210
+ readonly stack?: string;
14211
+ }
14212
+ type Log = {
14140
14213
  readonly type: "log";
14141
14214
  readonly level: "debug" | "error" | "info" | "log" | "warn";
14215
+ readonly errorInfo?: readonly (TailStreamErrorInfo | null)[];
14216
+ } & ({
14142
14217
  readonly message: object;
14143
- }
14218
+ readonly truncated?: false;
14219
+ } | {
14220
+ readonly message: string;
14221
+ readonly truncated: true;
14222
+ });
14144
14223
  interface DroppedEventsDiagnostic {
14145
14224
  readonly diagnosticsType: "droppedEvents";
14146
14225
  readonly count: number;
@@ -14618,7 +14697,25 @@ declare abstract class Workflow<PARAMS = unknown> {
14618
14697
  * @returns A promise that resolves with a list of handles for the created instances.
14619
14698
  */
14620
14699
  public createBatch(batch: WorkflowInstanceCreateOptions<PARAMS>[]): Promise<WorkflowInstance[]>;
14700
+ /**
14701
+ * Delete a batch of Workflow instances and their stored state.
14702
+ * `deleteBatch` is limited to 100 instances at a time. Duplicate IDs are deleted once.
14703
+ * The result contains one entry for each input position; IDs that do not exist are returned as per-instance errors.
14704
+ * @param instanceIds IDs of the Workflow instances to delete
14705
+ * @returns A promise that resolves with the successfully deleted instances and any per-instance errors.
14706
+ */
14707
+ public deleteBatch(instanceIds: string[]): Promise<WorkflowBatchDeleteResult>;
14621
14708
  }
14709
+ type WorkflowBatchDeleteResult = {
14710
+ deleted: {
14711
+ id: string;
14712
+ }[];
14713
+ errors: {
14714
+ id: string;
14715
+ code: number;
14716
+ message: string;
14717
+ }[];
14718
+ };
14622
14719
  type WorkflowDurationLabel = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
14623
14720
  type WorkflowSleepDuration = `${number} ${WorkflowDurationLabel}${'s' | ''}` | number;
14624
14721
  type WorkflowRetentionDuration = WorkflowSleepDuration;
@@ -14705,6 +14802,10 @@ declare abstract class WorkflowInstance {
14705
14802
  * @param options Options for the restart, including an optional step to restart from.
14706
14803
  */
14707
14804
  public restart(options?: WorkflowInstanceRestartOptions): Promise<void>;
14805
+ /**
14806
+ * Delete the instance and its stored state.
14807
+ */
14808
+ public delete(): Promise<void>;
14708
14809
  /**
14709
14810
  * Returns the current status of the instance.
14710
14811
  */