@workflow/world-testing 5.1.2 → 5.1.3

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.
@@ -934,8 +934,8 @@ Caused by: ${options.cause.stack}`;
934
934
  static {
935
935
  __name(this, "EntityConflictError");
936
936
  }
937
- constructor(message) {
938
- super(message);
937
+ constructor(message, options) {
938
+ super(message, options);
939
939
  this.name = "EntityConflictError";
940
940
  }
941
941
  static is(value) {
@@ -24550,7 +24550,7 @@ var init_events = __esm({
24550
24550
  function isTerminalWorkflowRunStatus(status) {
24551
24551
  return TERMINAL_WORKFLOW_RUN_STATUSES.includes(status);
24552
24552
  }
24553
- var WorkflowRunStatusSchema, TerminalWorkflowRunStatusSchema, TERMINAL_WORKFLOW_RUN_STATUSES, WorkflowRunBaseSchema, WorkflowRunSchema, BULK_CANCEL_MAX_RUN_IDS, BulkCancelWorkflowRunsRequestSchema, BulkCancelWorkflowRunResultSchema, BulkCancelWorkflowRunsResultSchema;
24553
+ var WorkflowRunStatusSchema, TerminalWorkflowRunStatusSchema, TERMINAL_WORKFLOW_RUN_STATUSES, WorkflowRunBaseSchema, WorkflowRunSchema, BULK_CANCEL_MAX_RUN_IDS, BulkCancelWorkflowRunsRequestSchema, BulkCancelWorkflowRunResultSchema, BulkCancelWorkflowRunsResultSchema, DELETE_RUNS_DATA_MAX_RUN_IDS, DeleteRunsDataRequestSchema, DeleteRunDataResultSchema, DeleteRunsDataResultSchema;
24554
24554
  var init_runs = __esm({
24555
24555
  "../world/dist/runs.js"() {
24556
24556
  "use strict";
@@ -24750,6 +24750,54 @@ var init_runs = __esm({
24750
24750
  }),
24751
24751
  results: external_exports.array(BulkCancelWorkflowRunResultSchema)
24752
24752
  });
24753
+ DELETE_RUNS_DATA_MAX_RUN_IDS = 100;
24754
+ DeleteRunsDataRequestSchema = external_exports.object({
24755
+ runIds: external_exports.array(external_exports.string()).min(1).max(DELETE_RUNS_DATA_MAX_RUN_IDS).refine((ids) => new Set(ids).size === ids.length, {
24756
+ message: "runIds must not contain duplicates"
24757
+ })
24758
+ });
24759
+ DeleteRunDataResultSchema = external_exports.discriminatedUnion("outcome", [
24760
+ external_exports.object({
24761
+ runId: external_exports.string(),
24762
+ outcome: external_exports.literal("deleted")
24763
+ }),
24764
+ external_exports.object({
24765
+ runId: external_exports.string(),
24766
+ outcome: external_exports.literal("already_deleted")
24767
+ }),
24768
+ external_exports.object({
24769
+ runId: external_exports.string(),
24770
+ outcome: external_exports.literal("skipped"),
24771
+ reason: external_exports.string(),
24772
+ status: external_exports.string()
24773
+ }),
24774
+ external_exports.object({
24775
+ runId: external_exports.string(),
24776
+ outcome: external_exports.literal("not_created")
24777
+ }),
24778
+ external_exports.object({
24779
+ runId: external_exports.string(),
24780
+ outcome: external_exports.literal("not_found")
24781
+ }),
24782
+ external_exports.object({
24783
+ runId: external_exports.string(),
24784
+ outcome: external_exports.literal("failed"),
24785
+ code: external_exports.string(),
24786
+ retryable: external_exports.boolean()
24787
+ })
24788
+ ]);
24789
+ DeleteRunsDataResultSchema = external_exports.object({
24790
+ summary: external_exports.object({
24791
+ requested: external_exports.number(),
24792
+ deleted: external_exports.number(),
24793
+ alreadyDeleted: external_exports.number(),
24794
+ skipped: external_exports.number(),
24795
+ notCreated: external_exports.number(),
24796
+ notFound: external_exports.number(),
24797
+ failed: external_exports.number()
24798
+ }),
24799
+ results: external_exports.array(DeleteRunDataResultSchema)
24800
+ });
24753
24801
  }
24754
24802
  });
24755
24803
 
@@ -25101,7 +25149,7 @@ function mintedSpecVersion(env = process.env, options = {}) {
25101
25149
  }
25102
25150
  return version5;
25103
25151
  }
25104
- warnOnce(`${SPEC_VERSION_ENV_VAR}=${requested}`, `Ignoring ${SPEC_VERSION_ENV_VAR}=${JSON.stringify(requested)}: expected an integer from ${SPEC_VERSION_SUPPORTS_SLOT_IDENTITY} to ${SPEC_VERSION_MAX_SUPPORTED}.`);
25152
+ warnOnce(`${SPEC_VERSION_ENV_VAR}=${requested}`, `Ignoring ${SPEC_VERSION_ENV_VAR}=${JSON.stringify(requested)}: expected an integer from ${SPEC_VERSION_SUPPORTS_SLOT_IDENTITY} to ${SPEC_VERSION_MAX_SUPPORTED}, so new runs use spec ${fallback}.`);
25105
25153
  }
25106
25154
  return fallback;
25107
25155
  }
@@ -25553,7 +25601,16 @@ var init_queue = __esm({
25553
25601
  * delivery of that message and burn the run's delivery budget over a
25554
25602
  * telemetry field. Anything unparseable degrades to "no measurement".
25555
25603
  */
25556
- hookResumeTiming: HookResumeTimingSchema.optional().catch(void 0)
25604
+ hookResumeTiming: HookResumeTimingSchema.optional().catch(void 0),
25605
+ /**
25606
+ * The event an out-of-band writer committed before it sent this wake (a
25607
+ * `resumeHook()`'s `hook_received`). An orchestrator that consumed the log
25608
+ * only below it knows the wake has something new, so it skips the tail
25609
+ * read that decides a no-op wake. A hint only: absent from other wakes and
25610
+ * older producers, and `.catch(undefined)` so a malformed value never fails
25611
+ * the payload's parse.
25612
+ */
25613
+ wakeEventId: external_exports.string().optional().catch(void 0)
25557
25614
  });
25558
25615
  HealthCheckPayloadSchema = external_exports.object({
25559
25616
  __healthCheck: external_exports.literal(true),
@@ -25603,6 +25660,7 @@ var init_queue = __esm({
25603
25660
  runInput: "drop",
25604
25661
  requestedAt: "drop",
25605
25662
  hookResumeTiming: "drop",
25663
+ wakeEventId: "drop",
25606
25664
  recovery: "drop",
25607
25665
  invoke: "drop",
25608
25666
  requestId: "drop",
@@ -28510,7 +28568,7 @@ function SemanticConvention(...names) {
28510
28568
  value
28511
28569
  ]));
28512
28570
  }
28513
- var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowDynamic, WorkflowStartHook, WorkflowStartHookRetentionUntil, WorkflowStartHookOutcome, WorkflowStartHookConflictingRunId, WorkflowStartHookRejectionReason, WorkflowStartHookErrorCode, WorkflowStartHookConfirmAttempts, WorkflowStartHookEnqueueFailed, WorkflowStartHookTrigger, WorkflowDynamicSourceHash, WorkflowDynamicCodeBytes, WorkflowDynamicCodeStorage, WorkflowBundleCompileCacheHit, WorkflowReplayLoadSource, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowParkedStartHookEventsCount, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, QuickJSSnapshotRestored, QuickJSSnapshotDeltaEvents, QuickJSSnapshotRestoreMs, QuickJSSnapshotFallbackReason, QuickJSSnapshotSaveMs, QuickJSSnapshotPlaintextBytes, QuickJSSnapshotStoredBytes, WorkflowTraceMode, WorkflowTurbo, WorkflowNoopDelivery, WorkflowSuperseded, WorkflowDeliveryAttempt, WorkflowDeliveryCount, WorkflowDeliveryExitReason, WorkflowDeliveryHandoff, WorkflowConsecutiveFenceRefusals, WorkflowReenqueueCount, WorkflowReenqueueSkippedTooOld, WorkflowReenqueueRecovery, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowStepsFailedSerialization, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowInlineEarlyAdvances, WorkflowInlineRunningAtTerminal, WorkflowInlineDiscardedOutcomes, WorkflowInlineSlotsHeldBack, WorkflowDispatchRepublishSkipped, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepStartStrategy, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, MessagingBatchMessageCount, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, WorkflowRunSpecVersion, WorkflowRunSpecVersionSource, WorkflowCapabilityProbeLatencyMs, WorkflowCapabilityProbeCached, WorkflowCapabilityProbeError, HookToken, HookId, HookFound, HookResilientResume, HookLookupResult, HookResumeCommitted, HookWakePublished, HookResilientResumeMaterialized, HookResumeSetupSource, StepDispatchPrologue, StepDeliveryDecision, StepDeliveryReason, StepDeliveryLogRead, StepDeliveryTimeoutSeconds, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, WorkflowEventsLoadStoppedAtLimit, WorkflowEventsLimit, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
28571
+ var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowDynamic, WorkflowStartHook, WorkflowStartHookRetentionUntil, WorkflowStartHookOutcome, WorkflowStartHookConflictingRunId, WorkflowStartHookRejectionReason, WorkflowStartHookErrorCode, WorkflowStartHookConfirmAttempts, WorkflowStartHookEnqueueFailed, WorkflowStartHookTrigger, WorkflowDynamicSourceHash, WorkflowDynamicCodeBytes, WorkflowDynamicCodeStorage, WorkflowBundleCompileCacheHit, WorkflowReplayLoadSource, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowParkedStartHookEventsCount, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, QuickJSSnapshotRestored, QuickJSSnapshotDeltaEvents, QuickJSSnapshotRestoreMs, QuickJSSnapshotFallbackReason, QuickJSSnapshotSaveMs, QuickJSSnapshotPlaintextBytes, QuickJSSnapshotStoredBytes, WorkflowTraceMode, WorkflowTurbo, WorkflowStartHookFirstDelivery, WorkflowStartHookFirstDeliveryFallback, WorkflowStartHookFirstDeliveryRunEnded, WorkflowNoopDelivery, WorkflowNoopDeliveryReason, WorkflowLingerWaitMs, WorkflowLingerStepMs, WorkflowLingerHookMs, WorkflowNoopCheckSkipped, WorkflowSuperseded, WorkflowStartConflictRestart, WorkflowTurboSkippedMessageAgeMs, WorkflowReplayedFirstDelivery, WorkflowDeliveryAttempt, WorkflowDeliveryCount, WorkflowDeliveryExitReason, WorkflowDeliveryHandoff, WorkflowConsecutiveFenceRefusals, WorkflowReenqueueCount, WorkflowReenqueueSkippedTooOld, WorkflowReenqueueRecovery, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowStepsFailedSerialization, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowInlineEarlyAdvances, WorkflowInlineRunningAtTerminal, WorkflowInlineDiscardedOutcomes, WorkflowInlineSlotsHeldBack, WorkflowDispatchRepublishSkipped, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepStartStrategy, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, MessagingBatchMessageCount, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, WorkflowRunSpecVersion, WorkflowRunSpecVersionSource, WorkflowCapabilityProbeLatencyMs, WorkflowCapabilityProbeCached, WorkflowCapabilityProbeError, HookToken, HookId, HookFound, HookResilientResume, HookLookupResult, HookResumeCommitted, HookWakePublished, HookResilientResumeMaterialized, HookResumeSetupSource, StepDispatchPrologue, StepDeliveryDecision, StepDeliveryReason, StepDeliveryLogRead, StepDeliveryTimeoutSeconds, ResumeTotalMs, ResumeProducerPrepMs, ResumeQueueDeliveryMs, ResumeSetupMs, ResumeReplayMs, ResumeStepDispatchMs, ResumeStepClaimMs, ResumeStepPrepareMs, ResumeTrigger, ResumeStrategy, ResumeSetupSource, ResumeStepExecution, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, WorkflowEventsLoadStoppedAtLimit, WorkflowEventsLimit, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
28514
28572
  var init_semantic_conventions = __esm({
28515
28573
  "../core/dist/telemetry/semantic-conventions.js"() {
28516
28574
  "use strict";
@@ -28560,8 +28618,19 @@ var init_semantic_conventions = __esm({
28560
28618
  QuickJSSnapshotStoredBytes = SemanticConvention("workflow.quickjs.snapshot.stored_bytes");
28561
28619
  WorkflowTraceMode = SemanticConvention("workflow.trace.mode");
28562
28620
  WorkflowTurbo = SemanticConvention("workflow.turbo");
28621
+ WorkflowStartHookFirstDelivery = SemanticConvention("workflow.start_hook.first_delivery");
28622
+ WorkflowStartHookFirstDeliveryFallback = SemanticConvention("workflow.start_hook.first_delivery.fallback");
28623
+ WorkflowStartHookFirstDeliveryRunEnded = SemanticConvention("workflow.start_hook.first_delivery.run_ended");
28563
28624
  WorkflowNoopDelivery = SemanticConvention("workflow.noop_delivery");
28625
+ WorkflowNoopDeliveryReason = SemanticConvention("workflow.noop_delivery.reason");
28626
+ WorkflowLingerWaitMs = SemanticConvention("workflow.linger.wait_ms");
28627
+ WorkflowLingerStepMs = SemanticConvention("workflow.linger.step_ms");
28628
+ WorkflowLingerHookMs = SemanticConvention("workflow.linger.hook_ms");
28629
+ WorkflowNoopCheckSkipped = SemanticConvention("workflow.noop_check_skipped");
28564
28630
  WorkflowSuperseded = SemanticConvention("workflow.superseded");
28631
+ WorkflowStartConflictRestart = SemanticConvention("workflow.start_conflict_restart");
28632
+ WorkflowTurboSkippedMessageAgeMs = SemanticConvention("workflow.turbo_skipped_message_age_ms");
28633
+ WorkflowReplayedFirstDelivery = SemanticConvention("workflow.replayed_first_delivery");
28565
28634
  WorkflowDeliveryAttempt = SemanticConvention("workflow.delivery.attempt");
28566
28635
  WorkflowDeliveryCount = SemanticConvention("workflow.delivery.count");
28567
28636
  WorkflowDeliveryExitReason = SemanticConvention("workflow.delivery.exit_reason");
@@ -32396,6 +32465,19 @@ function stateSourceId(event) {
32396
32465
  if (event === "run-input") return "run";
32397
32466
  return event.eventType === "hook_received" && event.eventId ? `hook:${event.eventId}` : void 0;
32398
32467
  }
32468
+ function sourceString(node2, path8) {
32469
+ if (!Array.isArray(path8)) return void 0;
32470
+ let at2 = node2;
32471
+ for (const key of path8) {
32472
+ if (typeof at2 === "string" || at2 === void 0) return void 0;
32473
+ if (typeof key !== "string" && typeof key !== "number") return void 0;
32474
+ at2 = at2.get(key);
32475
+ }
32476
+ return typeof at2 === "string" ? at2 : void 0;
32477
+ }
32478
+ function jsonLength(value) {
32479
+ return JSON.stringify(value).length;
32480
+ }
32399
32481
  function base64Bytes(value) {
32400
32482
  const text = globalThis.atob(value === "." ? "" : value);
32401
32483
  const bytes = new Uint8Array(text.length);
@@ -32448,9 +32530,10 @@ function hasBrand(check2) {
32448
32530
  return false;
32449
32531
  }
32450
32532
  }
32451
- function holdsOnlyState(leaf, depth) {
32533
+ function holdsOnlyState(leaf, depth, leaves) {
32452
32534
  const tag = Object.prototype.toString.call(leaf);
32453
32535
  if (tag !== "[object Map]" && tag !== "[object Set]") return true;
32536
+ if ((leaves.get(leaf) ?? -1) >= depth) return true;
32454
32537
  if (depth > MAX_DEPTH) return false;
32455
32538
  let ok = true;
32456
32539
  const check2 = /* @__PURE__ */ __name((entry) => {
@@ -32461,23 +32544,25 @@ function holdsOnlyState(leaf, depth) {
32461
32544
  }
32462
32545
  if (frozenState.has(entry)) return;
32463
32546
  if (isTrustedLeaf(entry)) {
32464
- if (!holdsOnlyState(entry, depth + 1)) ok = false;
32547
+ if (!holdsOnlyState(entry, depth + 1, leaves)) ok = false;
32465
32548
  return;
32466
32549
  }
32467
- if (!isFrozenState(entry, depth + 1)) ok = false;
32550
+ if (!isFrozenState(entry, depth + 1, leaves)) ok = false;
32468
32551
  }, "check");
32469
32552
  if (tag === "[object Map]") Map.prototype.forEach.call(leaf, (value, key) => {
32470
32553
  check2(key);
32471
32554
  check2(value);
32472
32555
  });
32473
32556
  else Set.prototype.forEach.call(leaf, (value) => check2(value));
32557
+ if (ok) leaves.set(leaf, depth);
32474
32558
  return ok;
32475
32559
  }
32476
- function isFrozenState(value, depth = 0) {
32560
+ function isFrozenState(value, depth = 0, leaves) {
32477
32561
  if (value === null || typeof value !== "object") return false;
32478
32562
  if (frozenState.has(value)) return true;
32479
32563
  if (depth > MAX_DEPTH || !Object.isFrozen(value)) return false;
32480
32564
  if (!Array.isArray(value) && !isPlainObject2(value)) return false;
32565
+ leaves ??= /* @__PURE__ */ new Map();
32481
32566
  for (const key of Object.keys(value)) {
32482
32567
  const descriptor = Object.getOwnPropertyDescriptor(value, key);
32483
32568
  if (descriptor === void 0 || !("value" in descriptor)) return false;
@@ -32490,10 +32575,10 @@ function isFrozenState(value, depth = 0) {
32490
32575
  }
32491
32576
  if (frozenState.has(child)) continue;
32492
32577
  if (isTrustedLeaf(child)) {
32493
- if (!holdsOnlyState(child, depth + 1)) return false;
32578
+ if (!holdsOnlyState(child, depth + 1, leaves)) return false;
32494
32579
  continue;
32495
32580
  }
32496
- if (!isFrozenState(child, depth + 1)) return false;
32581
+ if (!isFrozenState(child, depth + 1, leaves)) return false;
32497
32582
  }
32498
32583
  frozenState.add(value);
32499
32584
  return true;
@@ -32531,7 +32616,7 @@ function bindStateContextData(data2, context) {
32531
32616
  function stateContextForData(data2) {
32532
32617
  return data2 !== null && typeof data2 === "object" ? bindings.data.get(data2) : void 0;
32533
32618
  }
32534
- var STATE_REF_REDUCER, STATE_SOURCE_REDUCER, SNAPSHOT_MIN_BYTES, SNAPSHOT_MAX_RECORDS, SOURCE_STRING_MIN, MAX_ID, MAX_PATH, MAX_DEPTH, MAX_RECENT_INPUTS, WorkflowStateMissingError, STATE_REFS_FIELD, StateSourceRef, OPAQUE, DEVALUE_BUILTIN_TAGS, typedArray, VALUE_REVIVERS, frozenState, StateContext, bindings;
32619
+ var STATE_REF_REDUCER, STATE_SOURCE_REDUCER, SNAPSHOT_MIN_BYTES, SNAPSHOT_MAX_RECORDS, SOURCE_STRING_MIN, MAX_SOURCE_STRINGS, MAX_ID, MAX_PATH, MAX_DEPTH, MAX_SCAN, MAX_RECENT_INPUTS, WorkflowStateMissingError, STATE_REFS_FIELD, EMPTY_SOURCE, StateSourceRef, OPAQUE, DEVALUE_BUILTIN_TAGS, typedArray, VALUE_REVIVERS, frozenState, StateContext, bindings;
32535
32620
  var init_state_refs = __esm({
32536
32621
  "../core/dist/serialization/state-refs.js"() {
32537
32622
  "use strict";
@@ -32543,9 +32628,11 @@ var init_state_refs = __esm({
32543
32628
  SNAPSHOT_MIN_BYTES = 64 * 1024;
32544
32629
  SNAPSHOT_MAX_RECORDS = 1e3;
32545
32630
  SOURCE_STRING_MIN = 128;
32631
+ MAX_SOURCE_STRINGS = 1e4;
32546
32632
  MAX_ID = 256;
32547
32633
  MAX_PATH = 64;
32548
32634
  MAX_DEPTH = 256;
32635
+ MAX_SCAN = 1e5;
32549
32636
  MAX_RECENT_INPUTS = 4;
32550
32637
  WorkflowStateMissingError = class extends Error {
32551
32638
  static {
@@ -32555,6 +32642,9 @@ var init_state_refs = __esm({
32555
32642
  };
32556
32643
  STATE_REFS_FIELD = "stateRefs";
32557
32644
  __name(stateSourceId, "stateSourceId");
32645
+ EMPTY_SOURCE = /* @__PURE__ */ new Map();
32646
+ __name(sourceString, "sourceString");
32647
+ __name(jsonLength, "jsonLength");
32558
32648
  StateSourceRef = class {
32559
32649
  static {
32560
32650
  __name(this, "StateSourceRef");
@@ -32702,6 +32792,11 @@ var init_state_refs = __esm({
32702
32792
  * changes must still resolve to the strings that were stored.
32703
32793
  */
32704
32794
  sources = /* @__PURE__ */ new Map();
32795
+ /**
32796
+ * Where each indexed string is held, for writing references to it. At most
32797
+ * {@link MAX_SOURCE_STRINGS}, and only strings longer than their reference:
32798
+ * the rest are written as they are.
32799
+ */
32705
32800
  strings = /* @__PURE__ */ new Map();
32706
32801
  /**
32707
32802
  * The context a step's output is written against (see `forStep`): its
@@ -33014,30 +33109,45 @@ var init_state_refs = __esm({
33014
33109
  addSource(id, value) {
33015
33110
  checkedId(id, "state source id");
33016
33111
  if (this.sources.has(id)) return;
33017
- const captured = /* @__PURE__ */ new Map();
33018
- this.sources.set(id, captured);
33019
- const walk = /* @__PURE__ */ __name((v, path8) => {
33020
- if (path8.length > MAX_PATH) return;
33112
+ const path8 = [];
33113
+ const read3 = /* @__PURE__ */ new Map();
33114
+ const idBytes = jsonLength(id);
33115
+ const walk = /* @__PURE__ */ __name((v, pathBytes) => {
33116
+ if (path8.length > MAX_PATH) return void 0;
33021
33117
  if (typeof v === "string") {
33022
- if (v.length < SOURCE_STRING_MIN) return;
33023
- captured.set(JSON.stringify(path8), v);
33024
- if (!this.strings.has(v)) this.strings.set(v, {
33118
+ if (v.length < SOURCE_STRING_MIN) return void 0;
33119
+ if (idBytes + pathBytes < v.length && this.strings.size < MAX_SOURCE_STRINGS && !this.strings.has(v)) this.strings.set(v, {
33025
33120
  id,
33026
- path: path8
33121
+ path: path8.slice()
33027
33122
  });
33028
- } else if (Array.isArray(v)) {
33029
- for (let i2 = 0; i2 < v.length; i2++) walk(v[i2], [
33030
- ...path8,
33031
- i2
33032
- ]);
33123
+ return v;
33124
+ }
33125
+ if (v === null || typeof v !== "object") return void 0;
33126
+ const depth = path8.length;
33127
+ let atDepth = read3.get(v);
33128
+ if (atDepth?.has(depth)) return atDepth.get(depth);
33129
+ if (atDepth === void 0) {
33130
+ atDepth = /* @__PURE__ */ new Map();
33131
+ read3.set(v, atDepth);
33132
+ }
33133
+ let node2;
33134
+ const visit2 = /* @__PURE__ */ __name((key, child) => {
33135
+ path8.push(key);
33136
+ const found = walk(child, pathBytes + 1 + (typeof key === "number" ? String(key).length : jsonLength(key)));
33137
+ path8.pop();
33138
+ if (found === void 0) return;
33139
+ node2 ??= /* @__PURE__ */ new Map();
33140
+ node2.set(key, found);
33141
+ }, "visit");
33142
+ if (Array.isArray(v)) {
33143
+ for (let i2 = 0; i2 < v.length; i2++) visit2(i2, v[i2]);
33033
33144
  } else if (isPlainObject2(v)) {
33034
- for (const key of Object.keys(v)) walk(v[key], [
33035
- ...path8,
33036
- key
33037
- ]);
33145
+ for (const key of Object.keys(v)) visit2(key, v[key]);
33038
33146
  }
33147
+ atDepth.set(depth, node2);
33148
+ return node2;
33039
33149
  }, "walk");
33040
- walk(value, []);
33150
+ this.sources.set(id, walk(value, 2) ?? EMPTY_SOURCE);
33041
33151
  }
33042
33152
  reviveSource(d) {
33043
33153
  const id = checkedId(d.id, "state source id");
@@ -33070,7 +33180,7 @@ var init_state_refs = __esm({
33070
33180
  if (v instanceof StateSourceRef) {
33071
33181
  const captured = this.sources.get(v.id);
33072
33182
  if (captured === void 0) throw new WorkflowStateMissingError(`Missing workflow state source ${v.id}`);
33073
- const value = captured.get(JSON.stringify(v.path));
33183
+ const value = sourceString(captured, v.path);
33074
33184
  if (value === void 0) throw new WorkflowStateMissingError("Missing workflow state source field");
33075
33185
  return value;
33076
33186
  }
@@ -33094,23 +33204,44 @@ var init_state_refs = __esm({
33094
33204
  this.placeholders.add(text);
33095
33205
  return text;
33096
33206
  }
33097
- holdsPlaceholder(value, depth = 0) {
33098
- if (typeof value === "string") return this.placeholders.has(value);
33099
- if (depth > 256 || value === null || typeof value !== "object") return false;
33100
- for (const child of childrenOf(value)) if (this.holdsPlaceholder(child, depth + 1)) return true;
33101
- return false;
33207
+ /**
33208
+ * Whether a value holds a placeholder. Each object is read once (again only
33209
+ * if reached nearer the top, where the depth limit cuts less), so a value
33210
+ * that holds one object many times is not read once per path to it. Past
33211
+ * {@link MAX_SCAN} objects it is taken to hold one: such a value is then
33212
+ * not remembered, which inspection only needs to rebuild it again.
33213
+ */
33214
+ holdsPlaceholder(value) {
33215
+ const seen = /* @__PURE__ */ new Map();
33216
+ let budget = MAX_SCAN;
33217
+ const scan = /* @__PURE__ */ __name((v, depth) => {
33218
+ if (typeof v === "string") return this.placeholders.has(v);
33219
+ if (depth > MAX_DEPTH || v === null || typeof v !== "object") return false;
33220
+ if ((seen.get(v) ?? Infinity) <= depth) return false;
33221
+ seen.set(v, depth);
33222
+ if (--budget < 0) return true;
33223
+ for (const child of childrenOf(v)) if (scan(child, depth + 1)) return true;
33224
+ return false;
33225
+ }, "scan");
33226
+ return scan(value, 0);
33102
33227
  }
33103
- assertKnownTypes(value, depth = 0) {
33228
+ assertKnownTypes(value) {
33104
33229
  if (this.allowPlaceholders) return;
33105
- if (depth > 256 || value === null || typeof value !== "object") return;
33106
- if (value[OPAQUE] === true) throw new Error("Workflow state holds a value that cannot be recovered without running workflow code");
33107
- const tag = Object.prototype.toString.call(value);
33108
- if (tag === "[object Map]") Map.prototype.forEach.call(value, (entry, key) => {
33109
- this.assertKnownTypes(key, depth + 1);
33110
- this.assertKnownTypes(entry, depth + 1);
33111
- });
33112
- else if (tag === "[object Set]") Set.prototype.forEach.call(value, (entry) => this.assertKnownTypes(entry, depth + 1));
33113
- else for (const key of Object.keys(value)) this.assertKnownTypes(value[key], depth + 1);
33230
+ const seen = /* @__PURE__ */ new Map();
33231
+ const check2 = /* @__PURE__ */ __name((v, depth) => {
33232
+ if (depth > MAX_DEPTH || v === null || typeof v !== "object") return;
33233
+ if ((seen.get(v) ?? Infinity) <= depth) return;
33234
+ seen.set(v, depth);
33235
+ if (v[OPAQUE] === true) throw new Error("Workflow state holds a value that cannot be recovered without running workflow code");
33236
+ const tag = Object.prototype.toString.call(v);
33237
+ if (tag === "[object Map]") Map.prototype.forEach.call(v, (entry, key) => {
33238
+ check2(key, depth + 1);
33239
+ check2(entry, depth + 1);
33240
+ });
33241
+ else if (tag === "[object Set]") Set.prototype.forEach.call(v, (entry) => check2(entry, depth + 1));
33242
+ else for (const key of Object.keys(v)) check2(v[key], depth + 1);
33243
+ }, "check");
33244
+ check2(value, 0);
33114
33245
  }
33115
33246
  /**
33116
33247
  * Cold recovery: reads the state records of one decoded payload (JSON text after
@@ -36312,7 +36443,7 @@ var version2;
36312
36443
  var init_version = __esm({
36313
36444
  "../core/dist/version.js"() {
36314
36445
  "use strict";
36315
- version2 = "5.6.1";
36446
+ version2 = "5.7.0";
36316
36447
  }
36317
36448
  });
36318
36449
 
@@ -36327,9 +36458,9 @@ function awaitChildRunCompletion(childRunId, parentRunId, readValue, readFinishe
36327
36458
  if (!parentRunId) return void 0;
36328
36459
  const g = globalThis;
36329
36460
  const createHook2 = g[WORKFLOW_CREATE_HOOK];
36330
- const sleep5 = g[WORKFLOW_SLEEP];
36461
+ const sleep6 = g[WORKFLOW_SLEEP];
36331
36462
  const ctx = g[WORKFLOW_CONTEXT];
36332
- if (typeof createHook2 !== "function" || typeof sleep5 !== "function" || ctx?.workflowRunId !== parentRunId) {
36463
+ if (typeof createHook2 !== "function" || typeof sleep6 !== "function" || ctx?.workflowRunId !== parentRunId) {
36333
36464
  return void 0;
36334
36465
  }
36335
36466
  let d = g[DISPATCHER];
@@ -36363,7 +36494,7 @@ function awaitChildRunCompletion(childRunId, parentRunId, readValue, readFinishe
36363
36494
  dispatcher.wake?.();
36364
36495
  if (!dispatcher.running) {
36365
36496
  dispatcher.running = true;
36366
- void dispatch(dispatcher, parent, createHook2, sleep5, readFinished);
36497
+ void dispatch(dispatcher, parent, createHook2, sleep6, readFinished);
36367
36498
  }
36368
36499
  await done;
36369
36500
  }
@@ -36420,7 +36551,7 @@ function disarm(d, hook) {
36420
36551
  d.armGeneration++;
36421
36552
  hook[HOOK_RELEASE_AWAITER]?.();
36422
36553
  }
36423
- async function dispatch(d, parentRunId, createHook2, sleep5, readFinished) {
36554
+ async function dispatch(d, parentRunId, createHook2, sleep6, readFinished) {
36424
36555
  d.hook ??= createHook2({
36425
36556
  token: childRunCompletionToken(parentRunId),
36426
36557
  isSystem: true
@@ -36448,7 +36579,7 @@ async function dispatch(d, parentRunId, createHook2, sleep5, readFinished) {
36448
36579
  }
36449
36580
  arm(d, hook);
36450
36581
  if (d.safety === void 0) {
36451
- const safety2 = sleep5(safetyCheckDelayMs(d.safetyIndex));
36582
+ const safety2 = sleep6(safetyCheckDelayMs(d.safetyIndex));
36452
36583
  d.safety = safety2;
36453
36584
  void safety2.then(() => {
36454
36585
  if (d.safety === safety2) d.safety = void 0;
@@ -36947,7 +37078,9 @@ var init_codec = __esm({
36947
37078
 
36948
37079
  // ../world-local/dist/legacy-data.js
36949
37080
  import fs from "node:fs";
37081
+ import { readdir as readdir2, rm, rmdir, unlink } from "node:fs/promises";
36950
37082
  import path2 from "node:path";
37083
+ import { setTimeout as sleep } from "node:timers/promises";
36951
37084
  function legacyEntriesIn(dataDir) {
36952
37085
  return LEGACY_ENTRIES.filter((entry) => {
36953
37086
  try {
@@ -36970,7 +37103,82 @@ function noticeLegacyData(dataDir) {
36970
37103
  const dir = path2.resolve(dataDir);
36971
37104
  console.info(`[world-local] Runs recorded by an earlier version of @workflow/world-local are no longer read (this version keeps its data in ${path2.join(dir, "world.db")}), so the CLI and the web UI do not list them. Their files are still in ${legacy.map((entry) => path2.join(dir, entry)).join(", ")}, and can be deleted.`);
36972
37105
  }
36973
- var LEGACY_ENTRIES;
37106
+ async function removeLegacyData(dataDir, tag) {
37107
+ const entries = legacyEntriesIn(dataDir).map((entry) => path2.join(
37108
+ /* turbopackIgnore: true */
37109
+ dataDir,
37110
+ entry
37111
+ ));
37112
+ if (tag === void 0) {
37113
+ await Promise.all(entries.map((dir) => (
37114
+ // Windows refuses, for a moment, to remove what another clear() or
37115
+ // a virus scanner still has open: `maxRetries` waits for it.
37116
+ rm(dir, {
37117
+ recursive: true,
37118
+ force: true,
37119
+ maxRetries: 5
37120
+ })
37121
+ )));
37122
+ return;
37123
+ }
37124
+ const suffixes = [
37125
+ `.${tag}.json`,
37126
+ `.${tag}.bin`
37127
+ ];
37128
+ const gone = /* @__PURE__ */ __name((error62) => error62.code === "ENOENT", "gone");
37129
+ const removeDir = /* @__PURE__ */ __name((dir) => settled(() => rmdir(dir)).catch((error62) => {
37130
+ if (gone(error62) || error62.code === "ENOTEMPTY") return;
37131
+ throw error62;
37132
+ }), "removeDir");
37133
+ const kept = [];
37134
+ const removeTagged = /* @__PURE__ */ __name(async (dir) => {
37135
+ let entries2;
37136
+ try {
37137
+ entries2 = await settled(() => readdir2(dir, {
37138
+ withFileTypes: true
37139
+ }));
37140
+ } catch (error62) {
37141
+ if (gone(error62)) return false;
37142
+ throw error62;
37143
+ }
37144
+ let left = 0;
37145
+ for (const entry of entries2) {
37146
+ const at2 = path2.join(
37147
+ /* turbopackIgnore: true */
37148
+ dir,
37149
+ entry.name
37150
+ );
37151
+ if (entry.isDirectory()) {
37152
+ if (await removeTagged(at2)) await removeDir(at2);
37153
+ else left++;
37154
+ } else if (entry.isFile() && suffixes.some((suffix) => entry.name.endsWith(suffix))) {
37155
+ await settled(() => unlink(at2)).catch((error62) => {
37156
+ if (!gone(error62)) throw error62;
37157
+ });
37158
+ } else {
37159
+ left++;
37160
+ }
37161
+ }
37162
+ if (left > 0) kept.push(dir);
37163
+ return left === 0;
37164
+ }, "removeTagged");
37165
+ for (const dir of entries) {
37166
+ if (await removeTagged(dir)) await removeDir(dir);
37167
+ }
37168
+ for (const dir of kept) await removeDir(dir);
37169
+ }
37170
+ async function settled(operation) {
37171
+ for (let attempt = 1; ; attempt++) {
37172
+ try {
37173
+ return await operation();
37174
+ } catch (error62) {
37175
+ const code2 = error62.code;
37176
+ if (code2 !== "EPERM" && code2 !== "EBUSY" || attempt === SETTLE_ATTEMPTS) throw error62;
37177
+ }
37178
+ await sleep(attempt * 10);
37179
+ }
37180
+ }
37181
+ var LEGACY_ENTRIES, SETTLE_ATTEMPTS;
36974
37182
  var init_legacy_data = __esm({
36975
37183
  "../world-local/dist/legacy-data.js"() {
36976
37184
  "use strict";
@@ -36986,6 +37194,9 @@ var init_legacy_data = __esm({
36986
37194
  ];
36987
37195
  __name(legacyEntriesIn, "legacyEntriesIn");
36988
37196
  __name(noticeLegacyData, "noticeLegacyData");
37197
+ __name(removeLegacyData, "removeLegacyData");
37198
+ SETTLE_ATTEMPTS = 20;
37199
+ __name(settled, "settled");
36989
37200
  }
36990
37201
  });
36991
37202
 
@@ -37674,7 +37885,7 @@ var init_db = __esm({
37674
37885
 
37675
37886
  // ../world-local/dist/init.js
37676
37887
  import { randomBytes } from "node:crypto";
37677
- import { access, constants, mkdir, readFile as readFile2, unlink, writeFile } from "node:fs/promises";
37888
+ import { access, constants, mkdir, readFile as readFile2, unlink as unlink2, writeFile } from "node:fs/promises";
37678
37889
  import path4 from "node:path";
37679
37890
  import { fileURLToPath } from "node:url";
37680
37891
  function getModuleDir() {
@@ -37759,7 +37970,7 @@ async function ensureDataDir(dataDir) {
37759
37970
  const testFile = path4.join(absolutePath, `.workflow-write-test-${process.pid}-${randomBytes(6).toString("hex")}`);
37760
37971
  try {
37761
37972
  await writeFile(testFile, "");
37762
- await unlink(testFile).catch((e) => {
37973
+ await unlink2(testFile).catch((e) => {
37763
37974
  if (e.code !== "ENOENT") throw e;
37764
37975
  });
37765
37976
  } catch (error62) {
@@ -38388,7 +38599,7 @@ function nodeHttpFetch(url2, init = {}) {
38388
38599
  reject(signal.reason);
38389
38600
  return;
38390
38601
  }
38391
- let settled = false;
38602
+ let settled2 = false;
38392
38603
  let headersTimer;
38393
38604
  let bodyTimer;
38394
38605
  let teardownReason;
@@ -38416,8 +38627,8 @@ function nodeHttpFetch(url2, init = {}) {
38416
38627
  const fail = /* @__PURE__ */ __name((error62) => {
38417
38628
  clearTimers();
38418
38629
  detach();
38419
- if (settled) return;
38420
- settled = true;
38630
+ if (settled2) return;
38631
+ settled2 = true;
38421
38632
  reject(error62);
38422
38633
  }, "fail");
38423
38634
  if (headersTimeoutMs) {
@@ -38444,7 +38655,7 @@ function nodeHttpFetch(url2, init = {}) {
38444
38655
  message.resume();
38445
38656
  clearTimers();
38446
38657
  detach();
38447
- settled = true;
38658
+ settled2 = true;
38448
38659
  resolve2(new Response(null, {
38449
38660
  status,
38450
38661
  statusText,
@@ -38477,7 +38688,7 @@ function nodeHttpFetch(url2, init = {}) {
38477
38688
  // whatever the socket reported.
38478
38689
  failure: /* @__PURE__ */ __name((cause) => teardownReason ?? cause ?? transportError("socket hang up", "ECONNRESET"), "failure")
38479
38690
  });
38480
- settled = true;
38691
+ settled2 = true;
38481
38692
  resolve2(new Response(stream, {
38482
38693
  status,
38483
38694
  statusText,
@@ -66266,6 +66477,9 @@ function resumeOf(message) {
66266
66477
  hookResumeTiming: message.hookResumeTiming,
66267
66478
  ...message.traceCarrier !== void 0 && {
66268
66479
  traceCarrier: message.traceCarrier
66480
+ },
66481
+ ...message.wakeEventId !== void 0 && {
66482
+ wakeEventId: message.wakeEventId
66269
66483
  }
66270
66484
  };
66271
66485
  }
@@ -66316,12 +66530,15 @@ function createQueue(config3, options = {}) {
66316
66530
  });
66317
66531
  }, "deliveryUrl");
66318
66532
  const rerunBody = /* @__PURE__ */ __name((message, resume) => {
66319
- const { hookResumeTiming: _consumed, ...rest } = message;
66533
+ const { hookResumeTiming: _consumed, wakeEventId: _consumedWake, ...rest } = message;
66320
66534
  return transport.serialize(resume ? {
66321
66535
  ...rest,
66322
66536
  hookResumeTiming: resume.hookResumeTiming,
66323
66537
  ...resume.traceCarrier !== void 0 && {
66324
66538
  traceCarrier: resume.traceCarrier
66539
+ },
66540
+ ...resume.wakeEventId !== void 0 && {
66541
+ wakeEventId: resume.wakeEventId
66325
66542
  }
66326
66543
  } : rest);
66327
66544
  }, "rerunBody");
@@ -66860,7 +67077,7 @@ var init_queue2 = __esm({
66860
67077
 
66861
67078
  // ../world-local/dist/queue-auth-key.js
66862
67079
  import { randomBytes as randomBytes2 } from "node:crypto";
66863
- import { chmod, readFile as readFile3, rename, rm, writeFile as writeFile2 } from "node:fs/promises";
67080
+ import { chmod, readFile as readFile3, rename, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
66864
67081
  import path5 from "node:path";
66865
67082
  function stateFor(dir) {
66866
67083
  const { byDir } = keyFiles();
@@ -66898,7 +67115,7 @@ async function writeQueueAuthKeyFile(dir, key) {
66898
67115
  await chmod(tmp, 384);
66899
67116
  await rename(tmp, path5.join(dir, QUEUE_AUTH_KEY_FILE));
66900
67117
  } catch (error62) {
66901
- await rm(tmp, {
67118
+ await rm2(tmp, {
66902
67119
  force: true
66903
67120
  }).catch(() => {
66904
67121
  });
@@ -67039,28 +67256,19 @@ function purgesUserDataOnFinish2(attributes) {
67039
67256
  }
67040
67257
  return retention.mode === "none";
67041
67258
  }
67259
+ function ranPurge(run2) {
67260
+ if (run2 === void 0 || !isTerminalWorkflowRunStatus(run2.status)) {
67261
+ return false;
67262
+ }
67263
+ if (readRunRetention(run2.attributes).mode === "none") return true;
67264
+ return run2.expiredAt !== void 0 && new Date(run2.expiredAt).getTime() <= Date.now();
67265
+ }
67042
67266
  function purgeRunData(db, runId) {
67043
67267
  for (const row of db.all("SELECT step_id, doc FROM steps WHERE run_id = ?", runId)) {
67044
- const step = decode3(row.doc);
67045
- step.input = void 0;
67046
- step.output = void 0;
67047
- step.error = void 0;
67048
- db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode3(step), runId, row.step_id);
67268
+ writeScrubbedStep(db, runId, row.step_id, row.doc);
67049
67269
  }
67050
67270
  for (const row of db.all("SELECT seq, doc FROM events WHERE run_id = ?", runId)) {
67051
- const event = decode3(row.doc);
67052
- const eventData = event.eventData;
67053
- if (!eventData || typeof eventData !== "object") continue;
67054
- for (const field of getEventDataRefFields(String(event.eventType))) {
67055
- delete eventData[field];
67056
- }
67057
- if (event.eventType === "run_created" || event.eventType === "run_started") {
67058
- delete eventData.dynamicWorkflowCode;
67059
- delete eventData.dynamicWorkflowCodeRef;
67060
- const startHook = eventData.startHook;
67061
- if (startHook && typeof startHook === "object") delete startHook.metadata;
67062
- }
67063
- db.run("UPDATE events SET doc = ? WHERE run_id = ? AND seq = ?", encode3(event), runId, row.seq);
67271
+ writeScrubbedEvent(db, runId, row.seq, row.doc);
67064
67272
  }
67065
67273
  for (const row of db.all("SELECT hook_id, doc FROM hooks WHERE run_id = ?", runId)) {
67066
67274
  const hook = decode3(row.doc);
@@ -67068,6 +67276,40 @@ function purgeRunData(db, runId) {
67068
67276
  db.run("UPDATE hooks SET doc = ? WHERE hook_id = ?", encode3(hook), row.hook_id);
67069
67277
  }
67070
67278
  purgeRunStreams(db, runId);
67279
+ db.run("DELETE FROM snapshots WHERE run_id = ?", runId);
67280
+ }
67281
+ function purgeLateStepWrite(db, runId, stepId, seq) {
67282
+ const stepRow = db.get("SELECT doc FROM steps WHERE run_id = ? AND step_id = ?", runId, stepId);
67283
+ if (stepRow) {
67284
+ const step = decode3(stepRow.doc);
67285
+ step.output = void 0;
67286
+ step.error = void 0;
67287
+ db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode3(step), runId, stepId);
67288
+ }
67289
+ const event = db.get("SELECT doc FROM events WHERE run_id = ? AND seq = ?", runId, seq);
67290
+ if (event) writeScrubbedEvent(db, runId, seq, event.doc);
67291
+ }
67292
+ function writeScrubbedStep(db, runId, stepId, doc) {
67293
+ const step = decode3(doc);
67294
+ step.input = void 0;
67295
+ step.output = void 0;
67296
+ step.error = void 0;
67297
+ db.run("UPDATE steps SET doc = ? WHERE run_id = ? AND step_id = ?", encode3(step), runId, stepId);
67298
+ }
67299
+ function writeScrubbedEvent(db, runId, seq, doc) {
67300
+ const event = decode3(doc);
67301
+ const eventData = event.eventData;
67302
+ if (!eventData || typeof eventData !== "object") return;
67303
+ for (const field of getEventDataRefFields(String(event.eventType))) {
67304
+ delete eventData[field];
67305
+ }
67306
+ if (event.eventType === "run_created" || event.eventType === "run_started") {
67307
+ delete eventData.dynamicWorkflowCode;
67308
+ delete eventData.dynamicWorkflowCodeRef;
67309
+ const startHook = eventData.startHook;
67310
+ if (startHook && typeof startHook === "object") delete startHook.metadata;
67311
+ }
67312
+ db.run("UPDATE events SET doc = ? WHERE run_id = ? AND seq = ?", encode3(event), runId, seq);
67071
67313
  }
67072
67314
  function purgeRunStreams(db, runId) {
67073
67315
  const names = db.all("SELECT DISTINCT name, tag FROM stream_chunks WHERE run_id = ?", runId);
@@ -67082,7 +67324,11 @@ var init_run_retention = __esm({
67082
67324
  init_dist4();
67083
67325
  init_codec();
67084
67326
  __name(purgesUserDataOnFinish2, "purgesUserDataOnFinish");
67327
+ __name(ranPurge, "ranPurge");
67085
67328
  __name(purgeRunData, "purgeRunData");
67329
+ __name(purgeLateStepWrite, "purgeLateStepWrite");
67330
+ __name(writeScrubbedStep, "writeScrubbedStep");
67331
+ __name(writeScrubbedEvent, "writeScrubbedEvent");
67086
67332
  __name(purgeRunStreams, "purgeRunStreams");
67087
67333
  }
67088
67334
  });
@@ -67096,10 +67342,10 @@ function waitForRunTerminalSignal(runId, timeoutMs, signal) {
67096
67342
  if (timeoutMs <= 0 || signal?.aborted) return Promise.resolve();
67097
67343
  return new Promise((resolve2) => {
67098
67344
  const key = `run:${runId}`;
67099
- let settled = false;
67345
+ let settled2 = false;
67100
67346
  const settle2 = /* @__PURE__ */ __name(() => {
67101
- if (settled) return;
67102
- settled = true;
67347
+ if (settled2) return;
67348
+ settled2 = true;
67103
67349
  clearTimeout(timer);
67104
67350
  emitter.off(key, settle2);
67105
67351
  signal?.removeEventListener("abort", settle2);
@@ -67242,6 +67488,11 @@ var init_store = __esm({
67242
67488
  seqInBand: Number(row.seq_in_band)
67243
67489
  };
67244
67490
  }
67491
+ /** A run's status alone, without decoding its document. */
67492
+ getRunStatus(runId) {
67493
+ const row = this.db.get(`SELECT status FROM runs WHERE run_id = ? AND ${tagClause("tag", this.tag)}`, runId, ...tagParams(this.tag));
67494
+ return row?.status ?? null;
67495
+ }
67245
67496
  /** A run regardless of tag: the owner of a hook token can be any run. */
67246
67497
  getRunAnyTag(runId) {
67247
67498
  const row = this.db.get("SELECT doc, tag, seq, seq_in_band FROM runs WHERE run_id = ?", runId);
@@ -68046,16 +68297,31 @@ function createEventsStorage(db, tag) {
68046
68297
  db.run(`INSERT INTO hook_resumes (run_id, resume_id, hook_id, seq, payload_digest)
68047
68298
  VALUES (?, ?, ?, ?, ?)`, runId, params.resumeId, data2.correlationId, Number(stored.eventId.slice("evnt_".length)), params.resumePayloadDigest ?? null);
68048
68299
  }
68300
+ const lateOnPurgedRun = !runPurged && step !== void 0 && (data2.eventType === "step_completed" || data2.eventType === "step_failed" || data2.eventType === "step_retrying") && ranPurge(runForLateStepCheck());
68301
+ let reported = stored;
68049
68302
  if (runPurged) {
68050
68303
  purgeRunData(db, runId);
68051
68304
  effects.push(() => db.checkpoint());
68305
+ } else if (lateOnPurgedRun && step) {
68306
+ const seq = Number(stored.eventId.slice("evnt_".length));
68307
+ purgeLateStepWrite(db, runId, step.stepId, seq);
68308
+ effects.push(() => db.checkpoint());
68309
+ step = store.getStep(runId, step.stepId) ?? step;
68310
+ reported = store.getEventAt(runId, seq) ?? stored;
68052
68311
  }
68053
- return finish(stored, resultRun, {
68312
+ return finish(reported, resultRun, {
68054
68313
  step,
68055
68314
  hook,
68056
68315
  wait,
68057
68316
  stepCreatedLazily
68058
68317
  });
68318
+ function runForLateStepCheck() {
68319
+ if (run2) return run2;
68320
+ const status = store.getRunStatus(runId);
68321
+ if (!status || !isTerminalWorkflowRunStatus(status)) return void 0;
68322
+ return store.getRun(runId)?.run;
68323
+ }
68324
+ __name(runForLateStepCheck, "runForLateStepCheck");
68059
68325
  function finish(committed, finalRun, extra = {}) {
68060
68326
  let delta;
68061
68327
  if (data2.eventType === "run_started" && finalRun && !params?.skipPreload) {
@@ -68611,6 +68877,31 @@ function createRunsStorage(db, tag) {
68611
68877
  if (!row) throw new WorkflowRunNotFoundError(id);
68612
68878
  return filterRunData(row.run, params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION);
68613
68879
  }, "get");
68880
+ function deleteRunData(runId) {
68881
+ const row = store.getRun(runId);
68882
+ if (!row) return {
68883
+ runId,
68884
+ outcome: "not_found"
68885
+ };
68886
+ const { run: run2 } = row;
68887
+ if (!isTerminalWorkflowRunStatus(run2.status)) {
68888
+ return {
68889
+ runId,
68890
+ outcome: "skipped",
68891
+ reason: "run_not_terminal",
68892
+ status: run2.status
68893
+ };
68894
+ }
68895
+ const now2 = /* @__PURE__ */ new Date();
68896
+ const alreadyDeleted = run2.expiredAt !== void 0 && run2.expiredAt.getTime() <= now2.getTime();
68897
+ if (!alreadyDeleted) store.updateRun(withRunPayloadsPurged(run2, now2));
68898
+ purgeRunData(db, runId);
68899
+ return {
68900
+ runId,
68901
+ outcome: alreadyDeleted ? "already_deleted" : "deleted"
68902
+ };
68903
+ }
68904
+ __name(deleteRunData, "deleteRunData");
68614
68905
  return {
68615
68906
  get,
68616
68907
  /**
@@ -68703,7 +68994,53 @@ function createRunsStorage(db, tag) {
68703
68994
  attributes
68704
68995
  };
68705
68996
  });
68706
- }, "experimentalSetAttributes")
68997
+ }, "experimentalSetAttributes"),
68998
+ /**
68999
+ * Delete the data of many finished runs. See
69000
+ * `Storage['runs'].deleteDataMany`.
69001
+ */
69002
+ deleteDataMany: /* @__PURE__ */ __name(async (request) => {
69003
+ const { runIds: runIds2 } = DeleteRunsDataRequestSchema.parse(request);
69004
+ const results = [];
69005
+ for (const runId of runIds2) {
69006
+ try {
69007
+ assertSafeEntityId("runId", runId);
69008
+ } catch {
69009
+ results.push({
69010
+ runId,
69011
+ outcome: "not_found"
69012
+ });
69013
+ continue;
69014
+ }
69015
+ try {
69016
+ results.push(await db.transactAsync(() => deleteRunData(runId)));
69017
+ } catch (error62) {
69018
+ console.error(`[world-local] Failed to delete the data of run "${runId}":`, error62);
69019
+ results.push({
69020
+ runId,
69021
+ outcome: "failed",
69022
+ code: "internal_error",
69023
+ retryable: true
69024
+ });
69025
+ }
69026
+ }
69027
+ if (results.some((r) => r.outcome === "deleted" || r.outcome === "already_deleted")) {
69028
+ db.checkpoint();
69029
+ }
69030
+ const count2 = /* @__PURE__ */ __name((outcome) => results.filter((result) => result.outcome === outcome).length, "count");
69031
+ return {
69032
+ summary: {
69033
+ requested: runIds2.length,
69034
+ deleted: count2("deleted"),
69035
+ alreadyDeleted: count2("already_deleted"),
69036
+ skipped: count2("skipped"),
69037
+ notCreated: count2("not_created"),
69038
+ notFound: count2("not_found"),
69039
+ failed: count2("failed")
69040
+ },
69041
+ results
69042
+ };
69043
+ }, "deleteDataMany")
68707
69044
  };
68708
69045
  }
68709
69046
  var init_runs_storage = __esm({
@@ -68714,7 +69051,9 @@ var init_runs_storage = __esm({
68714
69051
  init_config();
68715
69052
  init_codec();
68716
69053
  init_ids();
69054
+ init_events_storage();
68717
69055
  init_filters();
69056
+ init_run_retention();
68718
69057
  init_run_status_signal();
68719
69058
  init_store();
68720
69059
  __name(createRunsStorage, "createRunsStorage");
@@ -68875,10 +69214,19 @@ function createStreamer(basedir, tag) {
68875
69214
  } : void 0;
68876
69215
  }
68877
69216
  __name(lastRow, "lastRow");
69217
+ function runWasPurged(runId) {
69218
+ const row = db.get("SELECT doc FROM runs WHERE run_id = ?", runId);
69219
+ return row !== void 0 && ranPurge(decode3(row.doc));
69220
+ }
69221
+ __name(runWasPurged, "runWasPurged");
68878
69222
  async function append(runId, name, chunks, eof) {
68879
69223
  const appended = await db.transactAsync(() => {
68880
69224
  const last = lastRow(name);
68881
69225
  if (last?.eof) return false;
69226
+ if (!last && runWasPurged(runId)) {
69227
+ db.run("INSERT INTO stream_chunks (name, idx, run_id, tag, data, eof) VALUES (?, 0, ?, ?, NULL, 1)", name, runId, tag ?? null);
69228
+ return true;
69229
+ }
68882
69230
  let idx = last?.idx ?? 0;
68883
69231
  for (const chunk of chunks) {
68884
69232
  idx++;
@@ -68993,86 +69341,98 @@ function createStreamer(basedir, tag) {
68993
69341
  };
68994
69342
  },
68995
69343
  async get(_runId, name, startIndex = 0) {
68996
- let teardown = /* @__PURE__ */ __name(() => {
68997
- }, "teardown");
69344
+ let lastIdx = startIndex;
68998
69345
  let closed = false;
68999
- return new ReadableStream({
69000
- start(controller) {
69001
- let resolvedStart = startIndex;
69002
- if (typeof startIndex === "number" && startIndex < 0) {
69003
- resolvedStart = Math.max(0, info(name).count + startIndex);
69004
- }
69005
- let lastIdx = resolvedStart;
69006
- let reading = false;
69007
- let failures = 0;
69008
- let timer = null;
69009
- const key = signalKey(db, name);
69010
- const finish = /* @__PURE__ */ __name(() => {
69011
- if (closed) return;
69012
- closed = true;
69013
- teardown();
69014
- try {
69015
- controller.close();
69016
- } catch {
69017
- }
69018
- }, "finish");
69019
- const drain = /* @__PURE__ */ __name(() => {
69020
- if (closed || reading) return;
69021
- reading = true;
69022
- try {
69023
- for (const row of rowsAfter(name, lastIdx)) {
69024
- lastIdx = row.idx;
69025
- if (row.eof) {
69026
- finish();
69027
- return;
69028
- }
69029
- if (row.data && row.data.byteLength > 0) {
69030
- controller.enqueue(row.data);
69031
- }
69346
+ let failures = 0;
69347
+ let wake = null;
69348
+ let timer = null;
69349
+ const key = signalKey(db, name);
69350
+ const onSignal = /* @__PURE__ */ __name(() => wake?.(), "onSignal");
69351
+ const stopWaiting = /* @__PURE__ */ __name(() => {
69352
+ wake = null;
69353
+ signals.emitter.off(key, onSignal);
69354
+ if (timer) {
69355
+ clearInterval(timer);
69356
+ timer = null;
69357
+ }
69358
+ }, "stopWaiting");
69359
+ const read3 = /* @__PURE__ */ __name((controller) => {
69360
+ const finish = /* @__PURE__ */ __name(() => {
69361
+ closed = true;
69362
+ try {
69363
+ controller.close();
69364
+ } catch {
69365
+ }
69366
+ }, "finish");
69367
+ try {
69368
+ let delivered = false;
69369
+ for (; ; ) {
69370
+ const rows = rowsAfter(name, lastIdx, READ_BATCH_CHUNKS);
69371
+ failures = 0;
69372
+ for (const row of rows) {
69373
+ lastIdx = row.idx;
69374
+ if (row.eof) {
69375
+ finish();
69376
+ return true;
69032
69377
  }
69033
- failures = 0;
69034
- const last = lastRow(name);
69035
- if (last?.eof && last.idx <= lastIdx) finish();
69036
- } catch (error62) {
69037
- failures++;
69038
- if (!closed && failures >= MAX_CONSECUTIVE_READ_FAILURES) {
69039
- closed = true;
69040
- teardown();
69041
- controller.error(error62);
69378
+ if (row.data && row.data.byteLength > 0) {
69379
+ controller.enqueue(row.data);
69380
+ delivered = true;
69042
69381
  }
69043
- } finally {
69044
- reading = false;
69045
69382
  }
69046
- }, "drain");
69047
- teardown = /* @__PURE__ */ __name(() => {
69048
- signals.emitter.off(key, drain);
69049
- if (timer) {
69050
- clearInterval(timer);
69051
- timer = null;
69052
- }
69053
- }, "teardown");
69054
- signals.emitter.on(key, drain);
69055
- drain();
69056
- if (!closed) {
69057
- timer = setInterval(drain, POLL_INTERVAL_MS);
69383
+ if (delivered) return true;
69384
+ if (rows.length < READ_BATCH_CHUNKS) break;
69385
+ }
69386
+ const last = lastRow(name);
69387
+ if (last?.eof && last.idx <= lastIdx) {
69388
+ finish();
69389
+ return true;
69058
69390
  }
69391
+ return false;
69392
+ } catch (error62) {
69393
+ failures++;
69394
+ if (failures < MAX_CONSECUTIVE_READ_FAILURES) return false;
69395
+ closed = true;
69396
+ controller.error(error62);
69397
+ return true;
69398
+ }
69399
+ }, "read");
69400
+ return new ReadableStream({
69401
+ start() {
69402
+ if (startIndex < 0) lastIdx = Math.max(0, info(name).count + startIndex);
69403
+ },
69404
+ async pull(controller) {
69405
+ if (closed || read3(controller)) return;
69406
+ await new Promise((resolve2) => {
69407
+ wake = /* @__PURE__ */ __name(() => {
69408
+ if (!closed && !read3(controller)) return;
69409
+ stopWaiting();
69410
+ resolve2();
69411
+ }, "wake");
69412
+ signals.emitter.on(key, onSignal);
69413
+ timer = setInterval(onSignal, POLL_INTERVAL_MS);
69414
+ });
69059
69415
  },
69060
69416
  cancel() {
69061
69417
  closed = true;
69062
- teardown();
69418
+ wake?.();
69419
+ stopWaiting();
69063
69420
  }
69064
69421
  });
69065
69422
  }
69066
69423
  }
69067
69424
  };
69068
69425
  }
69069
- var POLL_INTERVAL_MS, MAX_CONSECUTIVE_READ_FAILURES, signals;
69426
+ var POLL_INTERVAL_MS, READ_BATCH_CHUNKS, MAX_CONSECUTIVE_READ_FAILURES, signals;
69070
69427
  var init_streamer = __esm({
69071
69428
  "../world-local/dist/streamer.js"() {
69072
69429
  "use strict";
69073
69430
  init_dist();
69431
+ init_codec();
69074
69432
  init_db();
69433
+ init_run_retention();
69075
69434
  POLL_INTERVAL_MS = 100;
69435
+ READ_BATCH_CHUNKS = 16;
69076
69436
  MAX_CONSECUTIVE_READ_FAILURES = 50;
69077
69437
  signals = globalSingleton("@workflow/world-local//streamSignals", 1, () => {
69078
69438
  const emitter2 = new EventEmitter2();
@@ -69259,6 +69619,7 @@ function createWorld(args) {
69259
69619
  db.run("DELETE FROM stream_chunks WHERE tag = ?", tag);
69260
69620
  db.run("DELETE FROM runs WHERE tag = ?", tag);
69261
69621
  });
69622
+ await removeLegacyData(mergedConfig.dataDir, tag);
69262
69623
  await db.reclaimFreePages();
69263
69624
  }
69264
69625
  };
@@ -69276,6 +69637,7 @@ var init_dist5 = __esm({
69276
69637
  init_db();
69277
69638
  init_init();
69278
69639
  init_instrumentObject();
69640
+ init_legacy_data();
69279
69641
  init_orphaned_steps();
69280
69642
  init_queue2();
69281
69643
  init_queue_auth_key();
@@ -73116,7 +73478,7 @@ var version3;
73116
73478
  var init_version2 = __esm({
73117
73479
  "../world-vercel/dist/version.js"() {
73118
73480
  "use strict";
73119
- version3 = "5.6.1";
73481
+ version3 = "5.7.0";
73120
73482
  }
73121
73483
  });
73122
73484
 
@@ -78890,7 +79252,7 @@ var require_errors2 = __commonJS({
78890
79252
  toVercelCliError: /* @__PURE__ */ __name(() => toVercelCliError, "toVercelCliError")
78891
79253
  });
78892
79254
  module.exports = __toCommonJS(errors_exports2);
78893
- var import_promises5 = __require("node:fs/promises");
79255
+ var import_promises7 = __require("node:fs/promises");
78894
79256
  var VercelCliError2 = class extends Error {
78895
79257
  static {
78896
79258
  __name(this, "VercelCliError");
@@ -78933,7 +79295,7 @@ var require_errors2 = __commonJS({
78933
79295
  __name(getCliNotFoundMessage, "getCliNotFoundMessage");
78934
79296
  async function assertValidCwd(cwd) {
78935
79297
  try {
78936
- if (!(await (0, import_promises5.stat)(cwd)).isDirectory()) {
79298
+ if (!(await (0, import_promises7.stat)(cwd)).isDirectory()) {
78937
79299
  throw new Error("not a directory");
78938
79300
  }
78939
79301
  } catch {
@@ -81308,12 +81670,12 @@ var require_fsutils = __commonJS({
81308
81670
  statIfExists: /* @__PURE__ */ __name(() => statIfExists, "statIfExists")
81309
81671
  });
81310
81672
  module.exports = __toCommonJS(fsutils_exports);
81311
- var import_promises5 = __require("node:fs/promises");
81673
+ var import_promises7 = __require("node:fs/promises");
81312
81674
  var import_node_path6 = __toESM2(__require("node:path"));
81313
81675
  var import_errutils = require_errutils();
81314
81676
  async function getCanonicalPath(filePath) {
81315
81677
  try {
81316
- return await (0, import_promises5.realpath)(filePath);
81678
+ return await (0, import_promises7.realpath)(filePath);
81317
81679
  } catch {
81318
81680
  return filePath;
81319
81681
  }
@@ -81339,7 +81701,7 @@ var require_fsutils = __commonJS({
81339
81701
  async function statIfExists(filePath) {
81340
81702
  try {
81341
81703
  return {
81342
- stats: await (0, import_promises5.stat)(filePath)
81704
+ stats: await (0, import_promises7.stat)(filePath)
81343
81705
  };
81344
81706
  } catch (error62) {
81345
81707
  if ((0, import_errutils.isMissingPathError)(error62)) {
@@ -81429,7 +81791,7 @@ var require_safety = __commonJS({
81429
81791
  getUnsafeStatsReason: /* @__PURE__ */ __name(() => getUnsafeStatsReason, "getUnsafeStatsReason")
81430
81792
  });
81431
81793
  module.exports = __toCommonJS(safety_exports);
81432
- var import_promises5 = __require("node:fs/promises");
81794
+ var import_promises7 = __require("node:fs/promises");
81433
81795
  var import_node_path6 = __toESM2(__require("node:path"));
81434
81796
  var import_errutils = require_errutils();
81435
81797
  var import_fsutils = require_fsutils();
@@ -81519,7 +81881,7 @@ var require_safety = __commonJS({
81519
81881
  }
81520
81882
  __name(getUnsafePackageFileReason, "getUnsafePackageFileReason");
81521
81883
  async function getUnsafeDirectoryReason(directory) {
81522
- const stats = await (0, import_promises5.stat)(directory);
81884
+ const stats = await (0, import_promises7.stat)(directory);
81523
81885
  if (!stats.isDirectory()) {
81524
81886
  return "not a directory";
81525
81887
  }
@@ -81527,7 +81889,7 @@ var require_safety = __commonJS({
81527
81889
  }
81528
81890
  __name(getUnsafeDirectoryReason, "getUnsafeDirectoryReason");
81529
81891
  async function getUnsafeFileReason(filePath) {
81530
- const stats = await (0, import_promises5.stat)(filePath);
81892
+ const stats = await (0, import_promises7.stat)(filePath);
81531
81893
  if (!stats.isFile()) {
81532
81894
  return "not a file";
81533
81895
  }
@@ -81604,7 +81966,7 @@ var require_lookup = __commonJS({
81604
81966
  toVercelCliInvocation: /* @__PURE__ */ __name(() => toVercelCliInvocation, "toVercelCliInvocation")
81605
81967
  });
81606
81968
  module.exports = __toCommonJS(lookup_exports);
81607
- var import_promises5 = __require("node:fs/promises");
81969
+ var import_promises7 = __require("node:fs/promises");
81608
81970
  var import_node_path6 = __toESM2(__require("node:path"));
81609
81971
  var import_envpath = require_envpath();
81610
81972
  var import_errutils = require_errutils();
@@ -81708,7 +82070,7 @@ var require_lookup = __commonJS({
81708
82070
  __name(getPathCommandCandidate, "getPathCommandCandidate");
81709
82071
  async function canAccessCommandCandidate(candidate, localBinSearch, diagnostics) {
81710
82072
  try {
81711
- await (0, import_promises5.access)(candidate, process.platform === "win32" ? import_promises5.constants.F_OK : import_promises5.constants.F_OK | import_promises5.constants.X_OK);
82073
+ await (0, import_promises7.access)(candidate, process.platform === "win32" ? import_promises7.constants.F_OK : import_promises7.constants.F_OK | import_promises7.constants.X_OK);
81712
82074
  return true;
81713
82075
  } catch (error62) {
81714
82076
  if (!(0, import_errutils.isMissingPathError)(error62)) {
@@ -81727,10 +82089,10 @@ var require_lookup = __commonJS({
81727
82089
  }
81728
82090
  __name(recordInaccessibleLocalBinCandidate, "recordInaccessibleLocalBinCandidate");
81729
82091
  async function resolveCommandCandidate(command, candidate, localBinSearch, diagnostics) {
81730
- if (!(await (0, import_promises5.stat)(candidate)).isFile()) {
82092
+ if (!(await (0, import_promises7.stat)(candidate)).isFile()) {
81731
82093
  return null;
81732
82094
  }
81733
- const realPath = await (0, import_promises5.realpath)(candidate);
82095
+ const realPath = await (0, import_promises7.realpath)(candidate);
81734
82096
  const localBinCandidate = await classifyPathLocalBinCandidate(candidate, localBinSearch.directories);
81735
82097
  if (!localBinCandidate) {
81736
82098
  return {
@@ -81834,7 +82196,7 @@ var require_lookup = __commonJS({
81834
82196
  async function getProjectRootMarker(directory) {
81835
82197
  const gitPath = import_node_path6.default.join(directory, ".git");
81836
82198
  try {
81837
- await (0, import_promises5.stat)(gitPath);
82199
+ await (0, import_promises7.stat)(gitPath);
81838
82200
  return {
81839
82201
  path: gitPath
81840
82202
  };
@@ -81847,12 +82209,12 @@ var require_lookup = __commonJS({
81847
82209
  const resolvedFilePath = import_node_path6.default.resolve(filePath);
81848
82210
  let canonicalFilePath = resolvedFilePath;
81849
82211
  try {
81850
- canonicalFilePath = import_node_path6.default.join(await (0, import_promises5.realpath)(import_node_path6.default.dirname(resolvedFilePath)), import_node_path6.default.basename(resolvedFilePath));
82212
+ canonicalFilePath = import_node_path6.default.join(await (0, import_promises7.realpath)(import_node_path6.default.dirname(resolvedFilePath)), import_node_path6.default.basename(resolvedFilePath));
81851
82213
  } catch {
81852
82214
  }
81853
82215
  for (let localBinDirectory of localBinDirectories) {
81854
82216
  try {
81855
- localBinDirectory = await (0, import_promises5.realpath)(localBinDirectory);
82217
+ localBinDirectory = await (0, import_promises7.realpath)(localBinDirectory);
81856
82218
  } catch {
81857
82219
  }
81858
82220
  if (canonicalFilePath.startsWith(`${localBinDirectory}${import_node_path6.default.sep}`)) {
@@ -81868,7 +82230,7 @@ var require_lookup = __commonJS({
81868
82230
  candidateDirectory
81869
82231
  ];
81870
82232
  try {
81871
- const canonicalDirectory = await (0, import_promises5.realpath)(candidateDirectory);
82233
+ const canonicalDirectory = await (0, import_promises7.realpath)(candidateDirectory);
81872
82234
  if (!directories.includes(canonicalDirectory)) {
81873
82235
  directories.push(canonicalDirectory);
81874
82236
  }
@@ -81933,8 +82295,8 @@ var require_lookup = __commonJS({
81933
82295
  __name(getLocalVercelPackageBin, "getLocalVercelPackageBin");
81934
82296
  async function getLocalVercelPackage(nodeModulesDirectory) {
81935
82297
  const packageDirectory = import_node_path6.default.join(nodeModulesDirectory, "vercel");
81936
- const realNodeModulesDirectory = await (0, import_promises5.realpath)(nodeModulesDirectory);
81937
- const realPackageDirectory = await (0, import_promises5.realpath)(packageDirectory);
82298
+ const realNodeModulesDirectory = await (0, import_promises7.realpath)(nodeModulesDirectory);
82299
+ const realPackageDirectory = await (0, import_promises7.realpath)(packageDirectory);
81938
82300
  if (!(0, import_fsutils.isSubpath)(realNodeModulesDirectory, realPackageDirectory)) {
81939
82301
  return {
81940
82302
  reason: "local vercel package resolves outside local node_modules"
@@ -81955,7 +82317,7 @@ var require_lookup = __commonJS({
81955
82317
  __name(getLocalVercelPackage, "getLocalVercelPackage");
81956
82318
  async function readLocalVercelPackageJson(realPackageDirectory) {
81957
82319
  const packageJsonPath = import_node_path6.default.join(realPackageDirectory, "package.json");
81958
- const realPackageJsonPath = await (0, import_promises5.realpath)(packageJsonPath);
82320
+ const realPackageJsonPath = await (0, import_promises7.realpath)(packageJsonPath);
81959
82321
  if (!(0, import_fsutils.isSubpath)(realPackageDirectory, realPackageJsonPath)) {
81960
82322
  return {
81961
82323
  reason: "local vercel package.json resolves outside package"
@@ -81967,7 +82329,7 @@ var require_lookup = __commonJS({
81967
82329
  reason: `local vercel package.json is unsafe: ${unsafePackageJsonReason}`
81968
82330
  };
81969
82331
  }
81970
- const packageJson = JSON.parse(await (0, import_promises5.readFile)(realPackageJsonPath, "utf8"));
82332
+ const packageJson = JSON.parse(await (0, import_promises7.readFile)(realPackageJsonPath, "utf8"));
81971
82333
  if (packageJson.name !== "vercel") {
81972
82334
  return {
81973
82335
  reason: 'local vercel package.json does not have name "vercel"'
@@ -81987,7 +82349,7 @@ var require_lookup = __commonJS({
81987
82349
  };
81988
82350
  }
81989
82351
  const declaredBinPath = import_node_path6.default.resolve(realPackageDirectory, binTarget);
81990
- const realDeclaredBinPath = await (0, import_promises5.realpath)(declaredBinPath);
82352
+ const realDeclaredBinPath = await (0, import_promises7.realpath)(declaredBinPath);
81991
82353
  if (!(0, import_fsutils.isSubpath)(realPackageDirectory, realDeclaredBinPath)) {
81992
82354
  return {
81993
82355
  reason: "local vercel package bin resolves outside package"
@@ -82001,7 +82363,7 @@ var require_lookup = __commonJS({
82001
82363
  }
82002
82364
  if (process.platform !== "win32" && !(0, import_fsutils.isNodeScript)(realDeclaredBinPath)) {
82003
82365
  try {
82004
- await (0, import_promises5.access)(realDeclaredBinPath, import_promises5.constants.F_OK | import_promises5.constants.X_OK);
82366
+ await (0, import_promises7.access)(realDeclaredBinPath, import_promises7.constants.F_OK | import_promises7.constants.X_OK);
82005
82367
  } catch (error62) {
82006
82368
  return {
82007
82369
  reason: `local vercel package bin is not executable: ${(0, import_errutils.getErrorMessage)(error62)}`
@@ -88363,7 +88725,7 @@ var require_get_vercel_oidc_token_with_refresh = __commonJS({
88363
88725
  getVercelOidcToken: /* @__PURE__ */ __name(() => getVercelOidcToken8, "getVercelOidcToken")
88364
88726
  });
88365
88727
  module.exports = __toCommonJS(get_vercel_oidc_token_with_refresh_exports);
88366
- var import_promises5 = __require("node:fs/promises");
88728
+ var import_promises7 = __require("node:fs/promises");
88367
88729
  var import_exchange_vercel_oidc_token = require_exchange_vercel_oidc_token();
88368
88730
  var import_get_context = require_get_context3();
88369
88731
  var import_get_vercel_oidc_token_sync = require_get_vercel_oidc_token_sync();
@@ -88413,7 +88775,7 @@ ${error62.message}`;
88413
88775
  if (!tokenFile) {
88414
88776
  return null;
88415
88777
  }
88416
- const token = (await (0, import_promises5.readFile)(tokenFile, "utf8")).trim();
88778
+ const token = (await (0, import_promises7.readFile)(tokenFile, "utf8")).trim();
88417
88779
  if (!token) {
88418
88780
  throw new import_token_error.VercelOidcTokenError(`The Vercel OIDC token file is empty: ${tokenFile}`);
88419
88781
  }
@@ -93901,7 +94263,7 @@ function createThrottleWaiter(target2, budget, beforeWait) {
93901
94263
  waitedMs += waitMs;
93902
94264
  console.warn(`[workflow] Throttled (429) ${target2}; retrying in-process in ${waitMs / 1e3}s`);
93903
94265
  await beforeWait?.();
93904
- await sleep(waitMs, signal);
94266
+ await sleep2(waitMs, signal);
93905
94267
  };
93906
94268
  }
93907
94269
  function createStartHookRunPendingWaiter(target2, startedAtMs = Date.now()) {
@@ -93929,7 +94291,7 @@ function createStartHookRunPendingWaiter(target2, startedAtMs = Date.now()) {
93929
94291
  waitMs,
93930
94292
  waitedMs
93931
94293
  });
93932
- await sleep(waitMs);
94294
+ await sleep2(waitMs);
93933
94295
  };
93934
94296
  }
93935
94297
  function throttleBudgetFor(eventType, options) {
@@ -94001,12 +94363,12 @@ async function withEventPostRetry(fn, eventType, options) {
94001
94363
  backoffMs: backoff,
94002
94364
  error: errorMarker(err)
94003
94365
  });
94004
- await sleep(backoff);
94366
+ await sleep2(backoff);
94005
94367
  retried = true;
94006
94368
  }
94007
94369
  }
94008
94370
  }
94009
- var ReplayEventObserverError, AfterCommitError, STEP_OUTCOME_EVENT_TYPES, EVENT_RETRY_ELIGIBILITY, START_HOOK_RUN_PENDING_CODE, START_HOOK_RUN_PENDING_BUDGET_MS, DEFAULT_START_HOOK_RUN_PENDING_RETRY_AFTER_SECONDS, MAX_EVENT_POST_RETRIES, THROTTLE_RETRY_BUDGET_MS, THROTTLE_DEADLINE_RESERVE_MS, THROTTLE_RETRY_MAX_BUDGET_MS, DEFAULT_THROTTLE_RETRY_AFTER_SECONDS, EVENT_POST_RETRY_BASE_MS, EVENT_POST_RETRY_JITTER_MS, TRANSIENT_CODES, sleep, RETRY_DEBUG_ENABLED;
94371
+ var ReplayEventObserverError, AfterCommitError, STEP_OUTCOME_EVENT_TYPES, EVENT_RETRY_ELIGIBILITY, START_HOOK_RUN_PENDING_CODE, START_HOOK_RUN_PENDING_BUDGET_MS, DEFAULT_START_HOOK_RUN_PENDING_RETRY_AFTER_SECONDS, MAX_EVENT_POST_RETRIES, THROTTLE_RETRY_BUDGET_MS, THROTTLE_DEADLINE_RESERVE_MS, THROTTLE_RETRY_MAX_BUDGET_MS, DEFAULT_THROTTLE_RETRY_AFTER_SECONDS, EVENT_POST_RETRY_BASE_MS, EVENT_POST_RETRY_JITTER_MS, TRANSIENT_CODES, sleep2, RETRY_DEBUG_ENABLED;
94010
94372
  var init_event_retry = __esm({
94011
94373
  "../world-vercel/dist/event-retry.js"() {
94012
94374
  "use strict";
@@ -94164,7 +94526,7 @@ var init_event_retry = __esm({
94164
94526
  ]);
94165
94527
  __name(collectErrorMarkers, "collectErrorMarkers");
94166
94528
  __name(isRetryableEventPostError, "isRetryableEventPostError");
94167
- sleep = /* @__PURE__ */ __name((ms2, signal) => new Promise((resolve2, reject) => {
94529
+ sleep2 = /* @__PURE__ */ __name((ms2, signal) => new Promise((resolve2, reject) => {
94168
94530
  if (signal?.aborted) {
94169
94531
  reject(signal.reason);
94170
94532
  return;
@@ -94416,7 +94778,10 @@ function httpLog(method, label, response, ms2) {
94416
94778
  }
94417
94779
  function logCurlRepro(method, url2, headers) {
94418
94780
  if (!process.env.DEBUG) return;
94419
- const stringifiedHeaders = Array.from(headers.entries()).filter(([key]) => key.toLowerCase() !== "authorization").map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
94781
+ const stringifiedHeaders = Array.from(headers.entries()).filter(([key]) => {
94782
+ const name = key.toLowerCase();
94783
+ return name !== "authorization" && name !== "x-vercel-workflow-api-url";
94784
+ }).map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
94420
94785
  console.error(`Failed to fetch, reproduce with:
94421
94786
  curl -X ${method} ${stringifiedHeaders} "${url2}"`);
94422
94787
  }
@@ -94478,7 +94843,16 @@ function errorForResponse(status, message, opts = {}) {
94478
94843
  code: START_HOOK_CANDIDATE_CANCELLED
94479
94844
  });
94480
94845
  }
94481
- if (status === 409) return new EntityConflictError(message);
94846
+ if (status === 409) {
94847
+ return new EntityConflictError(message, {
94848
+ ...code2 !== void 0 ? {
94849
+ code: code2
94850
+ } : {},
94851
+ ...url2 !== void 0 ? {
94852
+ url: url2
94853
+ } : {}
94854
+ });
94855
+ }
94482
94856
  if (status === 410) {
94483
94857
  if (code2 === "stream-expired") {
94484
94858
  const streamDetails = details && typeof details === "object" ? details : void 0;
@@ -94599,7 +94973,7 @@ async function fetchStreamAppend(request, signal) {
94599
94973
  if (retry === STREAM_APPEND_MAX_RETRIES || !code2 || !STREAM_APPEND_CONNECT_ERROR_CODES.has(code2)) {
94600
94974
  throw error62;
94601
94975
  }
94602
- await sleep(500 * 2 ** retry, signal);
94976
+ await sleep2(500 * 2 ** retry, signal);
94603
94977
  continue;
94604
94978
  }
94605
94979
  if (response.status !== 429 || isFirewallChallenge429(response.status, response.headers.get("x-vercel-mitigated")) || retry === STREAM_APPEND_MAX_RETRIES) {
@@ -99328,10 +99702,10 @@ function isPortListening(port) {
99328
99702
  host: "localhost",
99329
99703
  port
99330
99704
  });
99331
- let settled = false;
99705
+ let settled2 = false;
99332
99706
  const finish = /* @__PURE__ */ __name((listening) => {
99333
- if (settled) return;
99334
- settled = true;
99707
+ if (settled2) return;
99708
+ settled2 = true;
99335
99709
  socket.destroy();
99336
99710
  resolve2(listening);
99337
99711
  }, "finish");
@@ -101966,11 +102340,11 @@ async function withQueueSendRetry(send, options = {}) {
101966
102340
  throw error62;
101967
102341
  }
101968
102342
  options.onRetry?.(error62, attempt, delayMs);
101969
- await sleep2(delayMs);
102343
+ await sleep3(delayMs);
101970
102344
  }
101971
102345
  }
101972
102346
  }
101973
- var QUEUE_SEND_MAX_ATTEMPTS, QUEUE_SEND_RETRY_DELAYS_MS, QUEUE_SEND_RETRY_JITTER_MS, QUEUE_SEND_RETRY_BUDGET_MS, QUEUE_SEND_MAX_RETRY_AFTER_MS, sleep2;
102347
+ var QUEUE_SEND_MAX_ATTEMPTS, QUEUE_SEND_RETRY_DELAYS_MS, QUEUE_SEND_RETRY_JITTER_MS, QUEUE_SEND_RETRY_BUDGET_MS, QUEUE_SEND_MAX_RETRY_AFTER_MS, sleep3;
101974
102348
  var init_queue_send_retry = __esm({
101975
102349
  "../world-vercel/dist/queue-send-retry.js"() {
101976
102350
  "use strict";
@@ -101985,7 +102359,7 @@ var init_queue_send_retry = __esm({
101985
102359
  QUEUE_SEND_MAX_RETRY_AFTER_MS = 5e3;
101986
102360
  __name(queueErrorName, "queueErrorName");
101987
102361
  __name(queueSendRetryDelayMs, "queueSendRetryDelayMs");
101988
- sleep2 = /* @__PURE__ */ __name((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)), "sleep");
102362
+ sleep3 = /* @__PURE__ */ __name((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)), "sleep");
101989
102363
  __name(withQueueSendRetry, "withQueueSendRetry");
101990
102364
  }
101991
102365
  });
@@ -104291,6 +104665,9 @@ function buildPostFrameMeta(input2) {
104291
104665
  if (input2.replayDivergenceCount !== void 0) {
104292
104666
  meta3.replayDivergenceCount = input2.replayDivergenceCount;
104293
104667
  }
104668
+ if (input2.replayDivergenceEventIds !== void 0) {
104669
+ meta3.replayDivergenceEventIds = input2.replayDivergenceEventIds;
104670
+ }
104294
104671
  if (input2.resumePayloadDigest !== void 0) {
104295
104672
  meta3.resumePayloadDigest = input2.resumePayloadDigest;
104296
104673
  }
@@ -105630,6 +106007,57 @@ async function cancelWorkflowRuns(request, config3) {
105630
106007
  results: orderedResults
105631
106008
  };
105632
106009
  }
106010
+ function deleteRunDataResultFromWire(result) {
106011
+ switch (result.outcome) {
106012
+ case "purged":
106013
+ return {
106014
+ runId: result.runId,
106015
+ outcome: "deleted"
106016
+ };
106017
+ case "already_purged":
106018
+ return {
106019
+ runId: result.runId,
106020
+ outcome: "already_deleted"
106021
+ };
106022
+ default:
106023
+ return result;
106024
+ }
106025
+ }
106026
+ async function deleteWorkflowRunsData(request, config3) {
106027
+ const { runIds: runIds2 } = DeleteRunsDataRequestSchema.parse(request);
106028
+ const response = await makeRequest({
106029
+ endpoint: "/v4/runs/purge",
106030
+ options: {
106031
+ method: "POST"
106032
+ },
106033
+ data: {
106034
+ runIds: runIds2
106035
+ },
106036
+ config: config3,
106037
+ schema: DeleteRunsDataWireResultSchema
106038
+ });
106039
+ const resultByRunId = new Map(response.results.map((result) => [
106040
+ result.runId,
106041
+ result
106042
+ ]));
106043
+ const isBijection = resultByRunId.size === response.results.length && response.results.length === runIds2.length && runIds2.every((runId) => resultByRunId.has(runId));
106044
+ if (!isBijection) {
106045
+ throw new WorkflowWorldError(`Delete-data response did not contain exactly one result per requested run ID (requested ${runIds2.length}, received ${response.results.length}).`);
106046
+ }
106047
+ const { purged, alreadyPurged, ...summary } = response.summary;
106048
+ return {
106049
+ summary: {
106050
+ requested: summary.requested,
106051
+ deleted: purged,
106052
+ alreadyDeleted: alreadyPurged,
106053
+ skipped: summary.skipped,
106054
+ notCreated: summary.notCreated,
106055
+ notFound: summary.notFound,
106056
+ failed: summary.failed
106057
+ },
106058
+ results: runIds2.map((runId) => deleteRunDataResultFromWire(resultByRunId.get(runId)))
106059
+ };
106060
+ }
105633
106061
  async function experimentalSetAttributes(runId, changes, options, config3) {
105634
106062
  try {
105635
106063
  const response = await makeRequest({
@@ -105656,7 +106084,7 @@ async function experimentalSetAttributes(runId, changes, options, config3) {
105656
106084
  throw error62;
105657
106085
  }
105658
106086
  }
105659
- var WorkflowRunWireBaseSchema, WorkflowRunWireSchema, WorkflowRunWireWithRefsSchema, WAIT_TIMEOUT_HEADROOM_MS, LONG_POLL_UNSUPPORTED_TTL_MS, longPoll, ExperimentalSetAttributesResponseSchema;
106087
+ var WorkflowRunWireBaseSchema, WorkflowRunWireSchema, WorkflowRunWireWithRefsSchema, WAIT_TIMEOUT_HEADROOM_MS, LONG_POLL_UNSUPPORTED_TTL_MS, longPoll, DeleteRunsDataWireResultSchema, ExperimentalSetAttributesResponseSchema;
105660
106088
  var init_runs2 = __esm({
105661
106089
  "../world-vercel/dist/runs.js"() {
105662
106090
  "use strict";
@@ -105717,6 +106145,49 @@ var init_runs2 = __esm({
105717
106145
  __name(getWorkflowRuns, "getWorkflowRuns");
105718
106146
  __name(cancelWorkflowRunV1, "cancelWorkflowRunV1");
105719
106147
  __name(cancelWorkflowRuns, "cancelWorkflowRuns");
106148
+ DeleteRunsDataWireResultSchema = external_exports.object({
106149
+ summary: external_exports.object({
106150
+ requested: external_exports.number(),
106151
+ purged: external_exports.number(),
106152
+ alreadyPurged: external_exports.number(),
106153
+ skipped: external_exports.number(),
106154
+ notCreated: external_exports.number(),
106155
+ notFound: external_exports.number(),
106156
+ failed: external_exports.number()
106157
+ }),
106158
+ results: external_exports.array(external_exports.discriminatedUnion("outcome", [
106159
+ external_exports.object({
106160
+ runId: external_exports.string(),
106161
+ outcome: external_exports.literal("purged")
106162
+ }),
106163
+ external_exports.object({
106164
+ runId: external_exports.string(),
106165
+ outcome: external_exports.literal("already_purged")
106166
+ }),
106167
+ external_exports.object({
106168
+ runId: external_exports.string(),
106169
+ outcome: external_exports.literal("skipped"),
106170
+ reason: external_exports.string(),
106171
+ status: external_exports.string()
106172
+ }),
106173
+ external_exports.object({
106174
+ runId: external_exports.string(),
106175
+ outcome: external_exports.literal("not_created")
106176
+ }),
106177
+ external_exports.object({
106178
+ runId: external_exports.string(),
106179
+ outcome: external_exports.literal("not_found")
106180
+ }),
106181
+ external_exports.object({
106182
+ runId: external_exports.string(),
106183
+ outcome: external_exports.literal("failed"),
106184
+ code: external_exports.string(),
106185
+ retryable: external_exports.boolean()
106186
+ })
106187
+ ]))
106188
+ });
106189
+ __name(deleteRunDataResultFromWire, "deleteRunDataResultFromWire");
106190
+ __name(deleteWorkflowRunsData, "deleteWorkflowRunsData");
105720
106191
  ExperimentalSetAttributesResponseSchema = external_exports.object({
105721
106192
  attributes: external_exports.record(external_exports.string(), external_exports.string())
105722
106193
  });
@@ -106172,6 +106643,7 @@ async function createWorkflowRunEventInner(id, data2, params, config3) {
106172
106643
  expectedSeqInBand: params.expectedSeqInBand
106173
106644
  } : {},
106174
106645
  replayDivergenceCount: params?.replayDivergenceCount,
106646
+ replayDivergenceEventIds: params?.replayDivergenceEventIds,
106175
106647
  // In-band writer fence. The backend refuses a stale in-band write with
106176
106648
  // 412 `in-band-superseded` (InBandSupersededError).
106177
106649
  ...params?.inBand !== void 0 ? {
@@ -106828,7 +107300,8 @@ function createStorage2(config3) {
106828
107300
  getMany: /* @__PURE__ */ __name((ids, params) => getWorkflowRuns(ids, params, config3), "getMany"),
106829
107301
  list: /* @__PURE__ */ __name((params) => listWorkflowRuns(params, config3), "list"),
106830
107302
  experimentalSetAttributes: /* @__PURE__ */ __name((runId, changes, options) => experimentalSetAttributes(runId, changes, options, config3), "experimentalSetAttributes"),
106831
- cancelMany: /* @__PURE__ */ __name((request) => cancelWorkflowRuns(request, config3), "cancelMany")
107303
+ cancelMany: /* @__PURE__ */ __name((request) => cancelWorkflowRuns(request, config3), "cancelMany"),
107304
+ deleteDataMany: /* @__PURE__ */ __name((request) => deleteWorkflowRunsData(request, config3), "deleteDataMany")
106832
107305
  },
106833
107306
  steps: {
106834
107307
  get: /* @__PURE__ */ __name((runId, stepId, params) => getStep(runId, stepId, params, config3), "get"),
@@ -107050,10 +107523,10 @@ function beginNormalWsClose(ws, reason) {
107050
107523
  if (ws.readyState === 3) return;
107051
107524
  let timedOut = false;
107052
107525
  const observed = new Promise((resolve2) => {
107053
- let settled = false;
107526
+ let settled2 = false;
107054
107527
  const finish = /* @__PURE__ */ __name(() => {
107055
- if (settled) return;
107056
- settled = true;
107528
+ if (settled2) return;
107529
+ settled2 = true;
107057
107530
  clearTimeout(timer);
107058
107531
  resolve2();
107059
107532
  }, "finish");
@@ -109172,8 +109645,9 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
109172
109645
  requireHookResumeDedup: true
109173
109646
  } : {}
109174
109647
  }), "write");
109648
+ let committedEventId;
109175
109649
  try {
109176
- await write(canClaimResume, resolvedHandle && canClaimResume);
109650
+ committedEventId = (await write(canClaimResume, resolvedHandle && canClaimResume))?.event?.eventId;
109177
109651
  } catch (err) {
109178
109652
  if (WorkflowWorldError.is(err) && err.code === "HOOK_RESUME_RETRY_REFUSED") {
109179
109653
  throw err;
@@ -109219,7 +109693,7 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
109219
109693
  hook = fresh;
109220
109694
  const freshDedup = (fresh.resumeCapabilities?.hookResumeDedupVersion ?? 0) >= HOOK_RESUME_DEDUP_VERSION || world.capabilities?.hookResumeDedup === true;
109221
109695
  try {
109222
- await write(freshDedup, false);
109696
+ committedEventId = (await write(freshDedup, false))?.event?.eventId;
109223
109697
  } catch (fallbackError) {
109224
109698
  if (isHookGoneError(fallbackError)) throw new HookNotFoundError(hook.token);
109225
109699
  throw fallbackError;
@@ -109238,6 +109712,9 @@ async function resumeHookAttempt(world, span, tokenOrHook, payload, encryptionKe
109238
109712
  runSpecVersion: resumeContext.runSpecVersion
109239
109713
  },
109240
109714
  traceCarrier: resumeContext.traceCarrier ?? void 0,
109715
+ ...committedEventId !== void 0 && {
109716
+ wakeEventId: committedEventId
109717
+ },
109241
109718
  hookResumeTiming: {
109242
109719
  resumeRequestedAtMs,
109243
109720
  queuePublishRequestedAtMs,
@@ -110340,17 +110817,18 @@ function cancelAbortReaders(...values) {
110340
110817
  __name(walk, "walk");
110341
110818
  for (const v of values) walk(v);
110342
110819
  }
110343
- function setupAbortStreamReader(controller, runId, streamName, ops) {
110820
+ function setupAbortStreamReader(controller, runId, streamName, ops, cryptoKey) {
110344
110821
  const readerCancel = new AbortController();
110345
110822
  ops.push((async () => {
110346
110823
  let reader;
110347
110824
  try {
110348
110825
  const readable = new WorkflowServerReadableStream(runId, streamName);
110349
110826
  reader = readable.getReader();
110350
- const ctxForKey = contextStorage.getStore();
110827
+ let keyPromise;
110351
110828
  let decoded;
110352
110829
  const decodePacket = /* @__PURE__ */ __name(async (packet) => {
110353
- decoded = await hydrateStepArguments(packet, runId, ctxForKey?.encryptionKey);
110830
+ keyPromise ??= resolveEncryptionKey(cryptoKey);
110831
+ decoded = await hydrateStepArguments(packet, runId, await keyPromise);
110354
110832
  }, "decodePacket");
110355
110833
  const result = await Promise.race([
110356
110834
  readAbortStreamPacket(reader, decodePacket),
@@ -110405,13 +110883,13 @@ function copyAbortInternals(src2, dest) {
110405
110883
  d[ABORT_READER_CANCEL] = s[ABORT_READER_CANCEL];
110406
110884
  }
110407
110885
  }
110408
- function reviveAbortController(value, ops, runId) {
110886
+ function reviveAbortController(value, ops, runId, cryptoKey) {
110409
110887
  const controller = new AbortController();
110410
110888
  if (value.aborted) {
110411
110889
  tagAbortPair(controller, value);
110412
110890
  controller.abort(value.reason);
110413
110891
  } else if (value.streamName) {
110414
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops);
110892
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
110415
110893
  tagAbortPair(controller, value, readerCancel);
110416
110894
  } else {
110417
110895
  tagAbortPair(controller, value);
@@ -110452,13 +110930,13 @@ function reviveAbortController(value, ops, runId) {
110452
110930
  };
110453
110931
  return controller;
110454
110932
  }
110455
- function reviveAbortSignal(value, ops, runId) {
110933
+ function reviveAbortSignal(value, ops, runId, cryptoKey) {
110456
110934
  const controller = new AbortController();
110457
110935
  if (value.aborted) {
110458
110936
  tagAbortPair(controller, value);
110459
110937
  controller.abort(value.reason);
110460
110938
  } else if (value.streamName) {
110461
- const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops);
110939
+ const readerCancel = setupAbortStreamReader(controller, runId, value.streamName, ops, cryptoKey);
110462
110940
  tagAbortPair(controller, value, readerCancel);
110463
110941
  } else {
110464
110942
  tagAbortPair(controller, value);
@@ -110670,8 +111148,8 @@ function getExternalRevivers(global2 = globalThis, ops, runId, cryptoKey, option
110670
111148
  encryptionPublicKey: value.encryptionPublicKey
110671
111149
  });
110672
111150
  }, "WritableStream"),
110673
- AbortController: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController(value, ops, runId), "AbortController"),
110674
- AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId), "AbortSignal")
111151
+ AbortController: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value) : reviveAbortController(value, ops, runId, cryptoKey), "AbortController"),
111152
+ AbortSignal: /* @__PURE__ */ __name((value) => options?.liveAbortSignals === false ? reviveAbortSnapshot(value).signal : reviveAbortSignal(value, ops, runId, cryptoKey), "AbortSignal")
110675
111153
  };
110676
111154
  }
110677
111155
  function getWorkflowRevivers(global2 = globalThis) {
@@ -110959,8 +111437,8 @@ function getStepRevivers(global2 = globalThis, ops, runId, cryptoKey, deployment
110959
111437
  }
110960
111438
  return writable;
110961
111439
  }, "WritableStream"),
110962
- AbortController: /* @__PURE__ */ __name((value) => reviveAbortController(value, ops, runId), "AbortController"),
110963
- AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal(value, ops, runId), "AbortSignal")
111440
+ AbortController: /* @__PURE__ */ __name((value) => reviveAbortController(value, ops, runId, cryptoKey), "AbortController"),
111441
+ AbortSignal: /* @__PURE__ */ __name((value) => reviveAbortSignal(value, ops, runId, cryptoKey), "AbortSignal")
110964
111442
  };
110965
111443
  }
110966
111444
  async function maybeEncrypt(data2, key) {
@@ -111579,9 +112057,9 @@ var init_serialization2 = __esm({
111579
112057
  startDispatch();
111580
112058
  return;
111581
112059
  }
111582
- const settled = drainWaiters;
112060
+ const settled2 = drainWaiters;
111583
112061
  drainWaiters = [];
111584
- for (const w of settled) w.resolve();
112062
+ for (const w of settled2) w.resolve();
111585
112063
  }, (error62) => {
111586
112064
  inFlight = null;
111587
112065
  sinkError ??= error62;
@@ -111953,6 +112431,7 @@ init_dist4();
111953
112431
  init_logger();
111954
112432
  init_encryption2();
111955
112433
  init_serialization2();
112434
+ init_context_storage();
111956
112435
 
111957
112436
  // ../core/dist/runtime/dynamic-workflow.js
111958
112437
  init_dist2();
@@ -119366,7 +119845,7 @@ var START_HOOK_CONFIRM_DELAYS_MS = [
119366
119845
  300,
119367
119846
  900
119368
119847
  ];
119369
- var sleep3 = /* @__PURE__ */ __name((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)), "sleep");
119848
+ var sleep4 = /* @__PURE__ */ __name((ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2)), "sleep");
119370
119849
  function finalInStep(error62) {
119371
119850
  if (contextStorage.getStore()?.workflowMetadata !== void 0 && error62 instanceof Error) {
119372
119851
  Object.defineProperty(error62, "fatal", {
@@ -119810,7 +120289,7 @@ async function start(workflow, argsOrOptions, options) {
119810
120289
  throw error62;
119811
120290
  }
119812
120291
  if (attempt < START_HOOK_CONFIRM_DELAYS_MS.length) {
119813
- await sleep3(START_HOOK_CONFIRM_DELAYS_MS[attempt]);
120292
+ await sleep4(START_HOOK_CONFIRM_DELAYS_MS[attempt]);
119814
120293
  continue;
119815
120294
  }
119816
120295
  recordConfirmAttempts();
@@ -119833,7 +120312,7 @@ async function start(workflow, argsOrOptions, options) {
119833
120312
  break;
119834
120313
  } catch (error62) {
119835
120314
  if (!isPermanentWorldError(error62) && attempt2 < START_HOOK_CONFIRM_DELAYS_MS.length) {
119836
- await sleep3(START_HOOK_CONFIRM_DELAYS_MS[attempt2]);
120315
+ await sleep4(START_HOOK_CONFIRM_DELAYS_MS[attempt2]);
119837
120316
  continue;
119838
120317
  }
119839
120318
  recordStartHookOutcome(span, "uncertain");
@@ -119941,7 +120420,7 @@ __name(start, "start");
119941
120420
  value: "start",
119942
120421
  configurable: true
119943
120422
  });
119944
- })(start, "step//@workflow/core/runtime/start@5.6.1//start");
120423
+ })(start, "step//@workflow/core/runtime/start@5.7.0//start");
119945
120424
 
119946
120425
  // ../core/dist/runtime/runs.js
119947
120426
  function isSingleOrchestratorRun(run2) {
@@ -119969,6 +120448,100 @@ async function wakeRunAfterOutOfBandWrite(world, run2) {
119969
120448
  }
119970
120449
  }
119971
120450
  __name(wakeRunAfterOutOfBandWrite, "wakeRunAfterOutOfBandWrite");
120451
+ async function deleteRuns(world, runIds2) {
120452
+ if (runIds2.length === 0) {
120453
+ throw new FatalError("deleteRuns requires at least one run ID.");
120454
+ }
120455
+ if (runIds2.length > DELETE_RUNS_DATA_MAX_RUN_IDS) {
120456
+ throw new FatalError(`deleteRuns accepts at most ${DELETE_RUNS_DATA_MAX_RUN_IDS} run IDs (received ${runIds2.length}).`);
120457
+ }
120458
+ if (new Set(runIds2).size !== runIds2.length) {
120459
+ throw new FatalError("deleteRuns requires unique run IDs (duplicates found).");
120460
+ }
120461
+ if (!world.runs.deleteDataMany) {
120462
+ throw new FatalError("The configured World does not support deleting run data.");
120463
+ }
120464
+ const { deleteDataMany } = world.runs;
120465
+ const request = /* @__PURE__ */ __name((ids) => deleteDataMany.call(world.runs, {
120466
+ runIds: ids
120467
+ }), "request");
120468
+ const inStep = contextStorage.getStore() !== void 0;
120469
+ let results = await requestRunDataDeletion(request, runIds2, inStep);
120470
+ if (inStep) {
120471
+ let retryable = retryableFailures(results);
120472
+ if (retryable.length > 0) {
120473
+ await new Promise((resolve2) => setTimeout(resolve2, DELETE_RUNS_IN_CALL_RETRY_DELAY_MS));
120474
+ const retried = await requestRunDataDeletion(request, retryable.map((result) => result.runId), inStep);
120475
+ const retriedById = new Map(retried.map((r) => [
120476
+ r.runId,
120477
+ r
120478
+ ]));
120479
+ results = results.map((result) => retriedById.get(result.runId) ?? result);
120480
+ retryable = retryableFailures(results);
120481
+ }
120482
+ if (retryable.length > 0) {
120483
+ const codes = [
120484
+ ...new Set(retryable.map((result) => result.code))
120485
+ ];
120486
+ throw new RetryableError(`Deleting the data of ${describeRunIds(retryable.map((result) => result.runId))} failed (${codes.join(", ")}) and will be retried.`, {
120487
+ retryAfter: DELETE_RUNS_STEP_RETRY_DELAY_MS
120488
+ });
120489
+ }
120490
+ }
120491
+ return {
120492
+ summary: summarizeRunDataDeletion(results),
120493
+ results
120494
+ };
120495
+ }
120496
+ __name(deleteRuns, "deleteRuns");
120497
+ var DELETE_RUNS_IN_CALL_RETRY_DELAY_MS = 1e3;
120498
+ var DELETE_RUNS_STEP_RETRY_DELAY_MS = 1e4;
120499
+ async function requestRunDataDeletion(request, runIds2, inStep) {
120500
+ let response;
120501
+ try {
120502
+ response = await request(runIds2);
120503
+ } catch (err) {
120504
+ if (inStep && ThrottleError.is(err)) {
120505
+ throw new RetryableError(`The World rate-limited deleting the data of ${describeRunIds(runIds2)}.`, {
120506
+ retryAfter: typeof err.retryAfter === "number" ? err.retryAfter * 1e3 : DELETE_RUNS_STEP_RETRY_DELAY_MS
120507
+ });
120508
+ }
120509
+ throw err;
120510
+ }
120511
+ const resultByRunId = new Map(response.results.map((result) => [
120512
+ result.runId,
120513
+ result
120514
+ ]));
120515
+ if (resultByRunId.size !== response.results.length || response.results.length !== runIds2.length || !runIds2.every((runId) => resultByRunId.has(runId))) {
120516
+ const unanswered = runIds2.filter((runId) => !resultByRunId.has(runId));
120517
+ throw new Error(`The World did not answer the deletion of the data of ${describeRunIds(unanswered.length > 0 ? unanswered : runIds2)} with exactly one result per run (requested ${runIds2.length}, received ${response.results.length}).`);
120518
+ }
120519
+ return runIds2.map((runId) => resultByRunId.get(runId));
120520
+ }
120521
+ __name(requestRunDataDeletion, "requestRunDataDeletion");
120522
+ function retryableFailures(results) {
120523
+ return results.filter((result) => result.outcome === "failed" && result.retryable);
120524
+ }
120525
+ __name(retryableFailures, "retryableFailures");
120526
+ function summarizeRunDataDeletion(results) {
120527
+ const count2 = /* @__PURE__ */ __name((outcome) => results.filter((result) => result.outcome === outcome).length, "count");
120528
+ return {
120529
+ requested: results.length,
120530
+ deleted: count2("deleted"),
120531
+ alreadyDeleted: count2("already_deleted"),
120532
+ skipped: count2("skipped"),
120533
+ notCreated: count2("not_created"),
120534
+ notFound: count2("not_found"),
120535
+ failed: count2("failed")
120536
+ };
120537
+ }
120538
+ __name(summarizeRunDataDeletion, "summarizeRunDataDeletion");
120539
+ function describeRunIds(runIds2) {
120540
+ const shown = runIds2.slice(0, 3).join(", ");
120541
+ const more = runIds2.length > 3 ? ` and ${runIds2.length - 3} more` : "";
120542
+ return `${runIds2.length === 1 ? "run" : "runs"} ${shown}${more}`;
120543
+ }
120544
+ __name(describeRunIds, "describeRunIds");
119972
120545
  var MAX_TRACKED_WAKE_UP_RUNS = 1e3;
119973
120546
  var wakeUps = globalSingleton("@workflow/core//pendingWakeUpWaits", 1, () => ({
119974
120547
  byRun: /* @__PURE__ */ new Map()
@@ -120293,6 +120866,38 @@ var Run = class _Run {
120293
120866
  await wakeRunAfterOutOfBandWrite(world, run2);
120294
120867
  await afterRunCancelled(world, run2);
120295
120868
  }
120869
+ /**
120870
+ * Deletes the stored data of the finished run: its input, output and
120871
+ * error, its steps' and events' payloads, its hook payloads, and its
120872
+ * stream contents, as if it had been started with
120873
+ * `experimental_retention: 0`. This cannot be undone.
120874
+ *
120875
+ * Metadata is not deleted: the run stays listed, and so do its steps,
120876
+ * events and hooks, with their IDs, names, statuses, timestamps and the
120877
+ * run's attributes. Only their payloads go, reading back as expired.
120878
+ *
120879
+ * Only a finished run has its data deleted. A run that has not finished
120880
+ * is answered `skipped` and left running: cancel it first (see
120881
+ * {@link Run.cancel}) to delete its data now.
120882
+ *
120883
+ * Runs as a step. Inside a workflow, a retryable failure (or the World
120884
+ * rate-limiting the request) throws a `RetryableError`, so the step
120885
+ * retries; deletion is idempotent, so a retry finishes what the failed
120886
+ * attempt left. Called outside a workflow, a `failed` result is returned
120887
+ * as is.
120888
+ *
120889
+ * @returns the run's outcome: `deleted`, `already_deleted` (its data was
120890
+ * already gone), `skipped` (with the run's `status`), `not_created`,
120891
+ * `not_found`, or `failed` (with `code`, and `retryable` when retrying
120892
+ * can succeed).
120893
+ * @throws if the configured World does not support deleting run data.
120894
+ */
120895
+ async delete() {
120896
+ const { results } = await deleteRuns(await this.#lazyWorldPromise, [
120897
+ this.runId
120898
+ ]);
120899
+ return results[0];
120900
+ }
120296
120901
  /**
120297
120902
  * Whether the workflow run exists.
120298
120903
  */
@@ -120581,7 +121186,7 @@ var Run = class _Run {
120581
121186
  value: "readFinishedRunIds",
120582
121187
  configurable: true
120583
121188
  });
120584
- })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.6.1//Run.readFinishedRunIds");
121189
+ })(Run.readFinishedRunIds, "step//@workflow/core/runtime/run@5.7.0//Run.readFinishedRunIds");
120585
121190
  (function(__wf_fn, __wf_id) {
120586
121191
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120587
121192
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120590,7 +121195,7 @@ var Run = class _Run {
120590
121195
  value: "wakeUp",
120591
121196
  configurable: true
120592
121197
  });
120593
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.6.1//Run#wakeUp");
121198
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.7.0//Run#wakeUp");
120594
121199
  (function(__wf_fn, __wf_id) {
120595
121200
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120596
121201
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120599,7 +121204,16 @@ var Run = class _Run {
120599
121204
  value: "cancel",
120600
121205
  configurable: true
120601
121206
  });
120602
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.6.1//Run#cancel");
121207
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.7.0//Run#cancel");
121208
+ (function(__wf_fn, __wf_id) {
121209
+ var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
121210
+ __wf_reg.set(__wf_id, __wf_fn);
121211
+ __wf_fn.stepId = __wf_id;
121212
+ Object.defineProperty(__wf_fn, "name", {
121213
+ value: "delete",
121214
+ configurable: true
121215
+ });
121216
+ })(Run.prototype["delete"], "step//@workflow/core/runtime/run@5.7.0//Run#delete");
120603
121217
  (function(__wf_fn, __wf_id) {
120604
121218
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120605
121219
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120608,7 +121222,7 @@ var Run = class _Run {
120608
121222
  value: "readReturnValue",
120609
121223
  configurable: true
120610
121224
  });
120611
- })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.6.1//Run#readReturnValue");
121225
+ })(Run.prototype["readReturnValue"], "step//@workflow/core/runtime/run@5.7.0//Run#readReturnValue");
120612
121226
  (function(__wf_fn, __wf_id) {
120613
121227
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120614
121228
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120617,7 +121231,7 @@ var Run = class _Run {
120617
121231
  value: "getReadable",
120618
121232
  configurable: true
120619
121233
  });
120620
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.6.1//Run#getReadable");
121234
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.7.0//Run#getReadable");
120621
121235
  (function(__wf_fn, __wf_id) {
120622
121236
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120623
121237
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120626,7 +121240,7 @@ var Run = class _Run {
120626
121240
  value: "getWritable",
120627
121241
  configurable: true
120628
121242
  });
120629
- })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.6.1//Run#getWritable");
121243
+ })(Run.prototype["getWritable"], "step//@workflow/core/runtime/run@5.7.0//Run#getWritable");
120630
121244
  (function(__wf_fn, __wf_id) {
120631
121245
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120632
121246
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120635,7 +121249,7 @@ var Run = class _Run {
120635
121249
  value: "exists",
120636
121250
  configurable: true
120637
121251
  });
120638
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.6.1//Run#exists");
121252
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.7.0//Run#exists");
120639
121253
  (function(__wf_fn, __wf_id) {
120640
121254
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120641
121255
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120644,7 +121258,7 @@ var Run = class _Run {
120644
121258
  value: "status",
120645
121259
  configurable: true
120646
121260
  });
120647
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.6.1//Run#status");
121261
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.7.0//Run#status");
120648
121262
  (function(__wf_fn, __wf_id) {
120649
121263
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120650
121264
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120653,7 +121267,7 @@ var Run = class _Run {
120653
121267
  value: "workflowName",
120654
121268
  configurable: true
120655
121269
  });
120656
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.6.1//Run#workflowName");
121270
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.7.0//Run#workflowName");
120657
121271
  (function(__wf_fn, __wf_id) {
120658
121272
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120659
121273
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120662,7 +121276,7 @@ var Run = class _Run {
120662
121276
  value: "createdAt",
120663
121277
  configurable: true
120664
121278
  });
120665
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.6.1//Run#createdAt");
121279
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#createdAt");
120666
121280
  (function(__wf_fn, __wf_id) {
120667
121281
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120668
121282
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120671,7 +121285,7 @@ var Run = class _Run {
120671
121285
  value: "startedAt",
120672
121286
  configurable: true
120673
121287
  });
120674
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.6.1//Run#startedAt");
121288
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#startedAt");
120675
121289
  (function(__wf_fn, __wf_id) {
120676
121290
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120677
121291
  __wf_reg.set(__wf_id, __wf_fn);
@@ -120680,7 +121294,7 @@ var Run = class _Run {
120680
121294
  value: "completedAt",
120681
121295
  configurable: true
120682
121296
  });
120683
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.6.1//Run#completedAt");
121297
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.7.0//Run#completedAt");
120684
121298
  (function(__wf_cls, __wf_id) {
120685
121299
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
120686
121300
  __wf_reg.set(__wf_id, __wf_cls);
@@ -120690,7 +121304,7 @@ var Run = class _Run {
120690
121304
  enumerable: false,
120691
121305
  configurable: false
120692
121306
  });
120693
- })(Run, "class//@workflow/core/runtime/run@5.6.1//Run");
121307
+ })(Run, "class//@workflow/core/runtime/run@5.7.0//Run");
120694
121308
 
120695
121309
  // ../workflow/dist/stdlib.js
120696
121310
  async function fetch2(...args) {