@workflow/world-testing 5.0.5 → 5.0.6

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.
@@ -446,7 +446,9 @@ var init_dist2 = __esm({
446
446
  STEP_NOT_REGISTERED: "step-not-registered",
447
447
  WORKFLOW_NOT_REGISTERED: "workflow-not-registered",
448
448
  RUNTIME_DECRYPTION_FAILED: "runtime-decryption-failed",
449
- DEPLOYMENT_MISMATCH: "deployment-mismatch"
449
+ DEPLOYMENT_MISMATCH: "deployment-mismatch",
450
+ MAX_EVENTS_EXCEEDED: "max-events-exceeded",
451
+ REPLAY_TIMEOUT: "replay-timeout"
450
452
  };
451
453
  WorkflowError = class extends Error {
452
454
  static {
@@ -25973,6 +25975,19 @@ var init_queue = __esm({
25973
25975
  * probe response. That lets the caller seal the workflow arguments without
25974
25976
  * a separate key lookup. Absent for probes issued for other reasons (CLI
25975
25977
  * health command, dashboard), in which case no key is returned.
25978
+ *
25979
+ * Deliberately not named `runId`: `runId` is the only required field of
25980
+ * `WorkflowInvokePayloadSchema`, and 4.x deployments parse queue payloads
25981
+ * with a union that tries the invoke schema before the health check. A
25982
+ * probe carrying `runId` is read there as "replay this run", which POSTs
25983
+ * `run_started` for a run that does not exist yet (404) and retries the
25984
+ * delivery, so the probe never answers.
25985
+ */
25986
+ probeRunId: external_exports.string().optional(),
25987
+ /**
25988
+ * Legacy spelling of {@link probeRunId}, sent by 5.x callers released
25989
+ * before the rename. Accepted so those callers still get a public key
25990
+ * back from this deployment; never sent.
25976
25991
  */
25977
25992
  runId: external_exports.string().optional()
25978
25993
  }));
@@ -32653,7 +32668,7 @@ var version2;
32653
32668
  var init_version = __esm({
32654
32669
  "../core/dist/version.js"() {
32655
32670
  "use strict";
32656
- version2 = "5.2.2";
32671
+ version2 = "5.2.3";
32657
32672
  }
32658
32673
  });
32659
32674
 
@@ -32788,8 +32803,11 @@ async function healthCheck(world, options) {
32788
32803
  await world.queue(queueName, {
32789
32804
  __healthCheck: true,
32790
32805
  correlationId,
32806
+ // Sent as `probeRunId`, never `runId`: a 4.x responder would parse a
32807
+ // `runId`-bearing probe as a run invocation (see
32808
+ // `HealthCheckPayloadSchema`).
32791
32809
  ...options?.runId ? {
32792
- runId: options.runId
32810
+ probeRunId: options.runId
32793
32811
  } : {}
32794
32812
  }, {
32795
32813
  // Use JSON transport so the health check works against both
@@ -37946,7 +37964,9 @@ async function resolveHookResumeInfo(hook) {
37946
37964
  source: "hook"
37947
37965
  };
37948
37966
  }
37949
- const run2 = await (await getWorldLazy()).runs.get(hook.runId);
37967
+ const run2 = await (await getWorldLazy()).runs.get(hook.runId, {
37968
+ resolveData: "none"
37969
+ });
37950
37970
  return {
37951
37971
  resumeContext: resumeContextFromRun(run2),
37952
37972
  source: "run_fallback",
@@ -37955,7 +37975,7 @@ async function resolveHookResumeInfo(hook) {
37955
37975
  }
37956
37976
  async function resolveHookEncryptionKey(hook, info) {
37957
37977
  const world = await getWorldLazy();
37958
- const rawKey = info.run ? await world.getEncryptionKeyForRun?.(info.run) : await world.getEncryptionKeyForRun?.(hook.runId, {
37978
+ const rawKey = await world.getEncryptionKeyForRun?.(hook.runId, {
37959
37979
  deploymentId: info.resumeContext.deploymentId
37960
37980
  });
37961
37981
  return rawKey ? await importKey(rawKey) : void 0;
@@ -37971,7 +37991,7 @@ function withLazyMetadata(raw) {
37971
37991
  const hydrate = /* @__PURE__ */ __name(async () => {
37972
37992
  const world = await getWorldLazy();
37973
37993
  const info = await resolveHookResumeInfo(raw);
37974
- const rawKey = info.run ? await world.getEncryptionKeyForRun?.(info.run) : await world.getEncryptionKeyForRun?.(raw.runId, {
37994
+ const rawKey = await world.getEncryptionKeyForRun?.(raw.runId, {
37975
37995
  deploymentId: info.resumeContext.deploymentId
37976
37996
  });
37977
37997
  encryptionKey = rawKey ? await deriveRunPayloadKeys(rawKey) : void 0;
@@ -39314,9 +39334,12 @@ async function getForwardedWritableEncryptionKey(runId, deploymentId, encryption
39314
39334
  if (ownerPublicKey) return sealTo(ownerPublicKey);
39315
39335
  const world = await getWorldLazy();
39316
39336
  if (!world.getEncryptionKeyForRun) return void 0;
39317
- const rawKey = deploymentId ? await world.getEncryptionKeyForRun(runId, {
39318
- deploymentId
39319
- }) : await world.getEncryptionKeyForRun(await world.runs.get(runId));
39337
+ const ownerDeploymentId = deploymentId ?? (await world.runs.get(runId, {
39338
+ resolveData: "none"
39339
+ })).deploymentId;
39340
+ const rawKey = await world.getEncryptionKeyForRun(runId, {
39341
+ deploymentId: ownerDeploymentId
39342
+ });
39320
39343
  return rawKey ? await importKey(rawKey, [
39321
39344
  "encrypt"
39322
39345
  ]) : void 0;
@@ -47369,6 +47392,7 @@ function getWorkflowVmFromEnv(env = process.env) {
47369
47392
  throw new WorkflowRuntimeError(`Invalid WORKFLOW_VM value: "${raw}". Expected one of: ${WORKFLOW_VMS.join(", ")}.`);
47370
47393
  }
47371
47394
  __name(getWorkflowVmFromEnv, "getWorkflowVmFromEnv");
47395
+ var DEFAULT_QUICKJS_SNAPSHOT_THRESHOLD = 1e3;
47372
47396
  function getSnapshotThresholdFromEnv(env = process.env) {
47373
47397
  const raw = env.WORKFLOW_SNAPSHOT_THRESHOLD;
47374
47398
  if (raw === void 0 || raw === "") return void 0;
@@ -47379,6 +47403,12 @@ function getSnapshotThresholdFromEnv(env = process.env) {
47379
47403
  return parsed;
47380
47404
  }
47381
47405
  __name(getSnapshotThresholdFromEnv, "getSnapshotThresholdFromEnv");
47406
+ function getSnapshotThresholdForStart(workflowVm, env = process.env) {
47407
+ const fromEnv = getSnapshotThresholdFromEnv(env);
47408
+ if (fromEnv !== void 0) return fromEnv;
47409
+ return workflowVm === "quickjs" ? DEFAULT_QUICKJS_SNAPSHOT_THRESHOLD : void 0;
47410
+ }
47411
+ __name(getSnapshotThresholdForStart, "getSnapshotThresholdForStart");
47382
47412
 
47383
47413
  // ../core/dist/runtime/start.js
47384
47414
  init_wait_until();
@@ -47679,7 +47709,7 @@ async function start(workflow, argsOrOptions, options) {
47679
47709
  encryptionPublicKey = rawKey ? bytesToBase64((await deriveRunKeyPair(rawKey)).publicKey) : void 0;
47680
47710
  }
47681
47711
  const workflowVm = getWorkflowVmFromEnv();
47682
- const snapshotThreshold = getSnapshotThresholdFromEnv();
47712
+ const snapshotThreshold = getSnapshotThresholdForStart(workflowVm);
47683
47713
  const queueNamespace = resolveQueueNamespace(opts.namespace);
47684
47714
  const executionContext = {
47685
47715
  traceCarrier,
@@ -47852,7 +47882,7 @@ __name(start, "start");
47852
47882
  value: "start",
47853
47883
  configurable: true
47854
47884
  });
47855
- })(start, "step//@workflow/core/runtime/start@5.2.2//start");
47885
+ })(start, "step//@workflow/core/runtime/start@5.2.3//start");
47856
47886
 
47857
47887
  // ../core/dist/runtime/runs.js
47858
47888
  async function wakeUpRun(world, runId, options) {
@@ -48033,8 +48063,18 @@ var Run = class _Run {
48033
48063
  if (!this.#encryptionKeyPromise) {
48034
48064
  this.#encryptionKeyPromise = (async () => {
48035
48065
  const world = await this.#lazyWorldPromise;
48036
- const runData = run2 ?? await world.runs.get(this.runId);
48037
- const rawKey = await world.getEncryptionKeyForRun?.(runData);
48066
+ if (!world.getEncryptionKeyForRun) return void 0;
48067
+ let rawKey;
48068
+ if (run2) {
48069
+ rawKey = await world.getEncryptionKeyForRun(run2);
48070
+ } else {
48071
+ const { deploymentId } = await world.runs.get(this.runId, {
48072
+ resolveData: "none"
48073
+ });
48074
+ rawKey = await world.getEncryptionKeyForRun(this.runId, {
48075
+ deploymentId
48076
+ });
48077
+ }
48038
48078
  return rawKey ? await deriveRunPayloadKeys(rawKey) : void 0;
48039
48079
  })();
48040
48080
  }
@@ -48326,7 +48366,7 @@ var Run = class _Run {
48326
48366
  value: "wakeUp",
48327
48367
  configurable: true
48328
48368
  });
48329
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.2.2//Run#wakeUp");
48369
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.2.3//Run#wakeUp");
48330
48370
  (function(__wf_fn, __wf_id) {
48331
48371
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48332
48372
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48335,7 +48375,7 @@ var Run = class _Run {
48335
48375
  value: "cancel",
48336
48376
  configurable: true
48337
48377
  });
48338
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.2.2//Run#cancel");
48378
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.2.3//Run#cancel");
48339
48379
  (function(__wf_fn, __wf_id) {
48340
48380
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48341
48381
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48344,7 +48384,7 @@ var Run = class _Run {
48344
48384
  value: "getReadable",
48345
48385
  configurable: true
48346
48386
  });
48347
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.2.2//Run#getReadable");
48387
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.2.3//Run#getReadable");
48348
48388
  (function(__wf_fn, __wf_id) {
48349
48389
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48350
48390
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48353,7 +48393,7 @@ var Run = class _Run {
48353
48393
  value: "getWritable",
48354
48394
  configurable: true
48355
48395
  });
48356
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.2.2//Run#getWritable");
48396
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.2.3//Run#getWritable");
48357
48397
  (function(__wf_fn, __wf_id) {
48358
48398
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48359
48399
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48362,7 +48402,7 @@ var Run = class _Run {
48362
48402
  value: "exists",
48363
48403
  configurable: true
48364
48404
  });
48365
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.2.2//Run#exists");
48405
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.2.3//Run#exists");
48366
48406
  (function(__wf_fn, __wf_id) {
48367
48407
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48368
48408
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48371,7 +48411,7 @@ var Run = class _Run {
48371
48411
  value: "status",
48372
48412
  configurable: true
48373
48413
  });
48374
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.2.2//Run#status");
48414
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.2.3//Run#status");
48375
48415
  (function(__wf_fn, __wf_id) {
48376
48416
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48377
48417
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48380,7 +48420,7 @@ var Run = class _Run {
48380
48420
  value: "returnValue",
48381
48421
  configurable: true
48382
48422
  });
48383
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.2.2//Run#returnValue");
48423
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.2.3//Run#returnValue");
48384
48424
  (function(__wf_fn, __wf_id) {
48385
48425
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48386
48426
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48389,7 +48429,7 @@ var Run = class _Run {
48389
48429
  value: "workflowName",
48390
48430
  configurable: true
48391
48431
  });
48392
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.2.2//Run#workflowName");
48432
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.2.3//Run#workflowName");
48393
48433
  (function(__wf_fn, __wf_id) {
48394
48434
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48395
48435
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48398,7 +48438,7 @@ var Run = class _Run {
48398
48438
  value: "createdAt",
48399
48439
  configurable: true
48400
48440
  });
48401
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.2.2//Run#createdAt");
48441
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.2.3//Run#createdAt");
48402
48442
  (function(__wf_fn, __wf_id) {
48403
48443
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48404
48444
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48407,7 +48447,7 @@ var Run = class _Run {
48407
48447
  value: "startedAt",
48408
48448
  configurable: true
48409
48449
  });
48410
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.2.2//Run#startedAt");
48450
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.2.3//Run#startedAt");
48411
48451
  (function(__wf_fn, __wf_id) {
48412
48452
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48413
48453
  __wf_reg.set(__wf_id, __wf_fn);
@@ -48416,7 +48456,7 @@ var Run = class _Run {
48416
48456
  value: "completedAt",
48417
48457
  configurable: true
48418
48458
  });
48419
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.2.2//Run#completedAt");
48459
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.2.3//Run#completedAt");
48420
48460
  (function(__wf_cls, __wf_id) {
48421
48461
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
48422
48462
  __wf_reg.set(__wf_id, __wf_cls);
@@ -48426,7 +48466,7 @@ var Run = class _Run {
48426
48466
  enumerable: false,
48427
48467
  configurable: false
48428
48468
  });
48429
- })(Run, "class//@workflow/core/runtime/run@5.2.2//Run");
48469
+ })(Run, "class//@workflow/core/runtime/run@5.2.3//Run");
48430
48470
 
48431
48471
  // ../workflow/dist/stdlib.js
48432
48472
  async function fetch2(...args) {