@workflow/world-testing 5.0.0-beta.40 → 5.0.0-beta.42

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.
@@ -406,7 +406,7 @@ function buildFramedDetails(hint2, slug) {
406
406
  });
407
407
  return out;
408
408
  }
409
- var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
409
+ var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, RunExpiredError, StreamExpiredError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
410
410
  var init_dist2 = __esm({
411
411
  "../errors/dist/index.js"() {
412
412
  "use strict";
@@ -682,6 +682,27 @@ Caused by: ${options.cause.stack}`;
682
682
  return isError(value) && value.name === "RunExpiredError";
683
683
  }
684
684
  };
685
+ StreamExpiredError = class extends WorkflowWorldError {
686
+ static {
687
+ __name(this, "StreamExpiredError");
688
+ }
689
+ runId;
690
+ streamId;
691
+ expiredAt;
692
+ constructor(message, runId, streamId, expiredAt) {
693
+ super(message, {
694
+ status: 410,
695
+ code: "stream-expired"
696
+ });
697
+ this.runId = runId;
698
+ this.streamId = streamId;
699
+ this.expiredAt = expiredAt;
700
+ this.name = "StreamExpiredError";
701
+ }
702
+ static is(value) {
703
+ return isError(value) && value.name === "StreamExpiredError";
704
+ }
705
+ };
685
706
  ThrottleError = class extends WorkflowWorldError {
686
707
  static {
687
708
  __name(this, "ThrottleError");
@@ -17399,7 +17420,7 @@ function getQueueTopicPrefix(kind, namespace) {
17399
17420
  }
17400
17421
  return "__wkf_workflow_";
17401
17422
  }
17402
- var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, HookResumeInputSchema, WorkflowInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
17423
+ var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, StepDispatchInputSchema, HookResumeInputSchema, HookResumeTimingSchema, WorkflowInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
17403
17424
  var init_queue = __esm({
17404
17425
  "../world/dist/queue.js"() {
17405
17426
  "use strict";
@@ -17446,6 +17467,19 @@ var init_queue = __esm({
17446
17467
  */
17447
17468
  environment: external_exports.string().optional()
17448
17469
  });
17470
+ StepDispatchInputSchema = external_exports.object({
17471
+ /**
17472
+ * The serialized step input, reused verbatim from the direct write. Always
17473
+ * binary: producers only attach `stepInput` when the dehydrated input is a
17474
+ * `Uint8Array` and the run's queue transport preserves bytes (CBOR).
17475
+ * Validated here so a malformed or transport-mangled payload fails the
17476
+ * message parse instead of being silently written into a `step_created` as
17477
+ * non-binary data. `Buffer` is a `Uint8Array` subclass and passes.
17478
+ */
17479
+ input: external_exports.custom((value) => value instanceof Uint8Array, {
17480
+ message: "stepInput.input must be a Uint8Array"
17481
+ })
17482
+ });
17449
17483
  HookResumeInputSchema = external_exports.object({
17450
17484
  /** Stable idempotency key minted once per `resumeHook()` call. */
17451
17485
  resumeId: external_exports.string(),
@@ -17467,7 +17501,33 @@ var init_queue = __esm({
17467
17501
  * `(runId, resumeId)` constraint — required because the v4 payload ref is not
17468
17502
  * content-stable server-side.
17469
17503
  */
17470
- payloadDigest: external_exports.string()
17504
+ payloadDigest: external_exports.string(),
17505
+ /**
17506
+ * The deployment the run is pinned to, from the producer's resume context.
17507
+ * Lets the consumer detect a misrouted delivery with a cheap ambient
17508
+ * deployment-id comparison BEFORE its hoisted `hook_received` replay-preload
17509
+ * write — only a detected mismatch pays for the authoritative run fetch and
17510
+ * the deployment-affinity guard. Optional for queued-message compatibility:
17511
+ * messages from older producers omit it and simply skip the pre-write
17512
+ * check (the authoritative guard before replay still protects them).
17513
+ */
17514
+ deploymentId: external_exports.string().optional()
17515
+ });
17516
+ HookResumeTimingSchema = external_exports.object({
17517
+ /** Epoch ms at entry into `resumeHook()` — the start of the TTR window. */
17518
+ resumeRequestedAtMs: external_exports.number(),
17519
+ /** Epoch ms immediately before the queue publish was requested. */
17520
+ queuePublishRequestedAtMs: external_exports.number(),
17521
+ /** Which `resumeHook()` dispatch path ran: `parallel` or `sequential`. */
17522
+ strategy: external_exports.string().optional(),
17523
+ /** Epoch ms the final consumer's queue handler was entered. */
17524
+ consumerStartedAtMs: external_exports.number().optional(),
17525
+ /** Epoch ms this invocation's first replay pass began. */
17526
+ replayStartedAtMs: external_exports.number().optional(),
17527
+ /** Epoch ms replay first encountered a durable step after the resume. */
17528
+ nextStepEncounteredAtMs: external_exports.number().optional(),
17529
+ /** How the consumer initialized replay state: see `ResumeSetupSource`. */
17530
+ setupSource: external_exports.string().optional()
17471
17531
  });
17472
17532
  WorkflowInvokePayloadSchema = external_exports.object({
17473
17533
  runId: external_exports.string(),
@@ -17502,7 +17562,28 @@ var init_queue = __esm({
17502
17562
  * fast path. A consumer that understands this field idempotently ensures the
17503
17563
  * `hook_received` event exists (keyed by `resumeId`) before replaying.
17504
17564
  */
17505
- hookInput: HookResumeInputSchema.optional()
17565
+ hookInput: HookResumeInputSchema.optional(),
17566
+ /**
17567
+ * Resilient step dispatch data, only present alongside `stepId` when the
17568
+ * producer parallelized the `step_created` write with this queue publish. A
17569
+ * consumer that understands this field idempotently ensures the
17570
+ * `step_created` event exists (keyed by `stepId`) before executing the step.
17571
+ */
17572
+ stepInput: StepDispatchInputSchema.optional(),
17573
+ /**
17574
+ * Hook-resume TTR timing. Present on both `resumeHook()` dispatch paths
17575
+ * (unlike `hookInput`, which only rides the parallel fast path), and
17576
+ * forwarded onto a dispatched step message when the resuming invocation
17577
+ * hands the next durable step to another invocation. Purely observational —
17578
+ * see {@link HookResumeTimingSchema}.
17579
+ *
17580
+ * `.catch(undefined)` because this field must never be able to fail the
17581
+ * parse of the invocation payload: a malformed value (a NaN boundary, a
17582
+ * shape change from a future producer) would otherwise throw on every
17583
+ * delivery of that message and burn the run's delivery budget over a
17584
+ * telemetry field. Anything unparseable degrades to "no measurement".
17585
+ */
17586
+ hookResumeTiming: HookResumeTimingSchema.optional().catch(void 0)
17506
17587
  });
17507
17588
  HealthCheckPayloadSchema = external_exports.object({
17508
17589
  __healthCheck: external_exports.literal(true),
@@ -17637,11 +17718,20 @@ var init_shared = __esm({
17637
17718
  }
17638
17719
  });
17639
17720
 
17721
+ // ../world/dist/slot-identity.js
17722
+ var MAX_EVENT_SLOT;
17723
+ var init_slot_identity = __esm({
17724
+ "../world/dist/slot-identity.js"() {
17725
+ "use strict";
17726
+ MAX_EVENT_SLOT = Number.MAX_SAFE_INTEGER;
17727
+ }
17728
+ });
17729
+
17640
17730
  // ../world/dist/spec-version.js
17641
17731
  function isLegacySpecVersion(v) {
17642
17732
  return v === void 0 || v === null || v <= SPEC_VERSION_LEGACY;
17643
17733
  }
17644
- var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_CURRENT;
17734
+ var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_SUPPORTS_SLOT_IDENTITY, SPEC_VERSION_CURRENT, SPEC_VERSION_MAX_SUPPORTED;
17645
17735
  var init_spec_version = __esm({
17646
17736
  "../world/dist/spec-version.js"() {
17647
17737
  "use strict";
@@ -17649,7 +17739,9 @@ var init_spec_version = __esm({
17649
17739
  SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
17650
17740
  SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
17651
17741
  SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
17652
- SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_COMPRESSION;
17742
+ SPEC_VERSION_SUPPORTS_SLOT_IDENTITY = 6;
17743
+ SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17744
+ SPEC_VERSION_MAX_SUPPORTED = SPEC_VERSION_SUPPORTS_SLOT_IDENTITY;
17653
17745
  __name(isLegacySpecVersion, "isLegacySpecVersion");
17654
17746
  }
17655
17747
  });
@@ -17806,6 +17898,7 @@ var init_ulid = __esm({
17806
17898
  "../world/dist/ulid.js"() {
17807
17899
  "use strict";
17808
17900
  init_zod();
17901
+ init_slot_identity();
17809
17902
  UlidSchema = external_exports.string().ulid();
17810
17903
  workflowRunIdSchema = external_exports.templateLiteral([
17811
17904
  "wrun_",
@@ -17830,6 +17923,7 @@ var init_dist4 = __esm({
17830
17923
  init_runs();
17831
17924
  init_serialization();
17832
17925
  init_shared();
17926
+ init_slot_identity();
17833
17927
  init_spec_version();
17834
17928
  init_steps();
17835
17929
  init_ulid();
@@ -19537,11 +19631,12 @@ var init_private = __esm({
19537
19631
 
19538
19632
  // ../core/dist/runtime/world-compatibility.js
19539
19633
  function assertWorldSupportsRuntimeProtocol(world) {
19540
- if (world.specVersion === SPEC_VERSION_CURRENT) {
19634
+ const declared = world.specVersion;
19635
+ if (declared !== void 0 && declared !== null && declared >= SPEC_VERSION_CURRENT && declared <= SPEC_VERSION_MAX_SUPPORTED) {
19541
19636
  return;
19542
19637
  }
19543
- const supportedVersion = world.specVersion ?? "none";
19544
- throw new WorkflowRuntimeError(`This Workflow runtime requires a World with matching spec version ${SPEC_VERSION_CURRENT}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
19638
+ const supportedVersion = declared ?? "none";
19639
+ throw new WorkflowRuntimeError(`This Workflow runtime supports Worlds with spec version ${SPEC_VERSION_CURRENT} through ${SPEC_VERSION_MAX_SUPPORTED}, but the configured World declares spec version ${supportedVersion}. Install a World package version compatible with the current Workflow runtime.`);
19545
19640
  }
19546
19641
  var init_world_compatibility = __esm({
19547
19642
  "../core/dist/runtime/world-compatibility.js"() {
@@ -20484,7 +20579,7 @@ function getReviversForMode(mode, global2 = globalThis, extraRevivers) {
20484
20579
  }
20485
20580
  return base;
20486
20581
  }
20487
- var encoder, decoder, devalueCodec;
20582
+ var encoder, decoder, MAX_SPARSE_ARRAY_LENGTH, parseOptions, devalueCodec;
20488
20583
  var init_codec_devalue = __esm({
20489
20584
  "../core/dist/serialization/codec-devalue.js"() {
20490
20585
  "use strict";
@@ -20496,6 +20591,17 @@ var init_codec_devalue = __esm({
20496
20591
  init_types();
20497
20592
  encoder = new TextEncoder();
20498
20593
  decoder = new TextDecoder();
20594
+ MAX_SPARSE_ARRAY_LENGTH = 1e5;
20595
+ parseOptions = {
20596
+ operations: {
20597
+ createSparseArray(length) {
20598
+ if (length > MAX_SPARSE_ARRAY_LENGTH) {
20599
+ throw new RangeError(`Sparse array length ${length} exceeds the maximum of ${MAX_SPARSE_ARRAY_LENGTH}`);
20600
+ }
20601
+ return default_parse_operations.createSparseArray(length);
20602
+ }
20603
+ }
20604
+ };
20499
20605
  __name(getReducersForMode, "getReducersForMode");
20500
20606
  __name(getReviversForMode, "getReviversForMode");
20501
20607
  devalueCodec = {
@@ -20510,11 +20616,11 @@ var init_codec_devalue = __esm({
20510
20616
  deserialize(data, mode, options) {
20511
20617
  const revivers = getReviversForMode(mode, options?.global, options?.extraRevivers);
20512
20618
  const str = decoder.decode(data);
20513
- return parse3(str, revivers);
20619
+ return parse3(str, revivers, parseOptions);
20514
20620
  },
20515
20621
  deserializeLegacy(data, mode, options) {
20516
20622
  const revivers = getReviversForMode(mode, options?.global, options?.extraRevivers);
20517
- return unflatten(data, revivers);
20623
+ return unflatten(data, revivers, parseOptions);
20518
20624
  }
20519
20625
  };
20520
20626
  }
@@ -21035,7 +21141,7 @@ function SemanticConvention(...names) {
21035
21141
  value
21036
21142
  ]));
21037
21143
  }
21038
- var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, WebhookHandlersTriggered, WorkflowSuspensionState, WorkflowSuspensionHookCount, WorkflowSuspensionStepCount, WorkflowSuspensionWaitCount, HttpRequestMethod, HttpRoute, UrlFull, ServerAddress, ServerPort, HttpResponseStatusCode, ErrorType, WorldParseFormat, WorkflowEventsPagesLoaded, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21144
+ var WorkflowName, WorkflowOperation, WorkflowRunId, WorkflowRunStatus, WorkflowStartedAt, WorkflowEventsCount, WorkflowExecutionMode, WorkflowParkedEventsCount, WorkflowParkedEventId, WorkflowParkedEventType, WorkflowArgumentsCount, WorkflowResultType, WorkflowTracePropagated, WorkflowVm, QuickJSOutcome, QuickJSEventsPreloaded, QuickJSEventsFetchedCount, QuickJSEventsFetchedPages, QuickJSPendingOpsCount, QuickJSInlineSteps, WorkflowTraceMode, WorkflowTurbo, WorkflowErrorName, WorkflowErrorMessage, WorkflowErrorCode, WorkflowStepsCreated, WorkflowHooksCreated, WorkflowWaitsCreated, WorkflowOwnedRecoverySteps, WorkflowBackstopWakesArmed, WorkflowRouteType, WorkflowRouteHandlerCached, WorkflowRouteInvocationCount, WorkflowRouteEntrypointAgeMs, WorkflowRouteModuleBodyInitMs, FaasInstance, StepName, StepId, StepAttempt, StepStatus, StepMaxRetries, StepTracePropagated, StepTtfsMs, StepStsoMs, StepRsfsMs, StepFinalSchedulingReplayMs, StepLatencyOptimizations, StepSkipped, StepSkipReason, StepArgumentsCount, StepResultType, StepErrorName, StepErrorMessage, StepFatalError, StepRetryExhausted, StepRetryTimeoutSeconds, StepRetryWillRetry, MessagingSystem, MessagingDestinationName, MessagingMessageId, MessagingOperationType, QueueOverheadMs, DeploymentId, WorkflowRunPinnedDeploymentId, WorkflowDeploymentMismatchRetryCount, WorkflowDeploymentMismatchRecovered, HookToken, HookId, HookFound, HookResilientResume, HookResilientResumeMaterialized, HookResumeSetupSource, StepResilientDispatchRecovered, StepResilientDispatchMaterialized, 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, QueueDeserializeTimeMs, QueueExecutionTimeMs, QueueSerializeTimeMs, SerializationOperation, SerializationCompressed, SerializationCodec, SerializationUncompressedBytes, SerializationStoredBytes, SerializationCompressionRatio, SerializationGuestCodeExecutions, SerializationGuestCodeDetails, PeerService, RpcSystem, RpcService, RpcMethod, ErrorRetryable, ErrorCategory;
21039
21145
  var init_semantic_conventions = __esm({
21040
21146
  "../core/dist/telemetry/semantic-conventions.js"() {
21041
21147
  "use strict";
@@ -21047,6 +21153,9 @@ var init_semantic_conventions = __esm({
21047
21153
  WorkflowStartedAt = SemanticConvention("workflow.started_at");
21048
21154
  WorkflowEventsCount = SemanticConvention("workflow.events.count");
21049
21155
  WorkflowExecutionMode = SemanticConvention("workflow.execution.mode");
21156
+ WorkflowParkedEventsCount = SemanticConvention("workflow.events.parked.count");
21157
+ WorkflowParkedEventId = SemanticConvention("workflow.events.parked.event_id");
21158
+ WorkflowParkedEventType = SemanticConvention("workflow.events.parked.event_type");
21050
21159
  WorkflowArgumentsCount = SemanticConvention("workflow.arguments.count");
21051
21160
  WorkflowResultType = SemanticConvention("workflow.result.type");
21052
21161
  WorkflowTracePropagated = SemanticConvention("workflow.trace.propagated");
@@ -21109,6 +21218,20 @@ var init_semantic_conventions = __esm({
21109
21218
  HookResilientResume = SemanticConvention("workflow.hook.resilient_resume");
21110
21219
  HookResilientResumeMaterialized = SemanticConvention("workflow.hook.resilient_resume_materialized");
21111
21220
  HookResumeSetupSource = SemanticConvention("workflow.resume_setup_source");
21221
+ StepResilientDispatchRecovered = SemanticConvention("workflow.step.resilient_dispatch_recovered");
21222
+ StepResilientDispatchMaterialized = SemanticConvention("workflow.step.resilient_dispatch_materialized");
21223
+ ResumeTotalMs = SemanticConvention("workflow.resume.total_ms");
21224
+ ResumeProducerPrepMs = SemanticConvention("workflow.resume.phase.producer_prep_ms");
21225
+ ResumeQueueDeliveryMs = SemanticConvention("workflow.resume.phase.queue_delivery_ms");
21226
+ ResumeSetupMs = SemanticConvention("workflow.resume.phase.resume_setup_ms");
21227
+ ResumeReplayMs = SemanticConvention("workflow.resume.phase.replay_ms");
21228
+ ResumeStepDispatchMs = SemanticConvention("workflow.resume.phase.step_dispatch_ms");
21229
+ ResumeStepClaimMs = SemanticConvention("workflow.resume.phase.step_claim_ms");
21230
+ ResumeStepPrepareMs = SemanticConvention("workflow.resume.phase.step_prepare_ms");
21231
+ ResumeTrigger = SemanticConvention("workflow.resume.trigger");
21232
+ ResumeStrategy = SemanticConvention("workflow.resume.strategy");
21233
+ ResumeSetupSource = SemanticConvention("workflow.resume.setup_source");
21234
+ ResumeStepExecution = SemanticConvention("workflow.resume.step_execution");
21112
21235
  WebhookHandlersTriggered = SemanticConvention("webhook.handlers.triggered");
21113
21236
  WorkflowSuspensionState = SemanticConvention("workflow.suspension.state");
21114
21237
  WorkflowSuspensionHookCount = SemanticConvention("workflow.suspension.hook_count");
@@ -23835,7 +23958,7 @@ var require_parse_options = __commonJS({
23835
23958
  loose: true
23836
23959
  });
23837
23960
  var emptyOpts = Object.freeze({});
23838
- var parseOptions = /* @__PURE__ */ __name((options) => {
23961
+ var parseOptions2 = /* @__PURE__ */ __name((options) => {
23839
23962
  if (!options) {
23840
23963
  return emptyOpts;
23841
23964
  }
@@ -23844,7 +23967,7 @@ var require_parse_options = __commonJS({
23844
23967
  }
23845
23968
  return options;
23846
23969
  }, "parseOptions");
23847
- module.exports = parseOptions;
23970
+ module.exports = parseOptions2;
23848
23971
  }
23849
23972
  });
23850
23973
 
@@ -23880,14 +24003,14 @@ var require_semver2 = __commonJS({
23880
24003
  var debug = require_debug();
23881
24004
  var { MAX_LENGTH, MAX_SAFE_INTEGER } = require_constants();
23882
24005
  var { safeRe: re, t } = require_re();
23883
- var parseOptions = require_parse_options();
24006
+ var parseOptions2 = require_parse_options();
23884
24007
  var { compareIdentifiers } = require_identifiers();
23885
24008
  var SemVer = class _SemVer {
23886
24009
  static {
23887
24010
  __name(this, "SemVer");
23888
24011
  }
23889
24012
  constructor(version3, options) {
23890
- options = parseOptions(options);
24013
+ options = parseOptions2(options);
23891
24014
  if (version3 instanceof _SemVer) {
23892
24015
  if (version3.loose === !!options.loose && version3.includePrerelease === !!options.includePrerelease) {
23893
24016
  return version3;
@@ -24587,7 +24710,7 @@ var require_range = __commonJS({
24587
24710
  __name(this, "Range");
24588
24711
  }
24589
24712
  constructor(range, options) {
24590
- options = parseOptions(options);
24713
+ options = parseOptions2(options);
24591
24714
  if (range instanceof _Range) {
24592
24715
  if (range.loose === !!options.loose && range.includePrerelease === !!options.includePrerelease) {
24593
24716
  return range;
@@ -24738,7 +24861,7 @@ var require_range = __commonJS({
24738
24861
  module.exports = Range;
24739
24862
  var LRU = require_lrucache();
24740
24863
  var cache = new LRU();
24741
- var parseOptions = require_parse_options();
24864
+ var parseOptions2 = require_parse_options();
24742
24865
  var Comparator = require_comparator();
24743
24866
  var debug = require_debug();
24744
24867
  var SemVer = require_semver2();
@@ -24976,7 +25099,7 @@ var require_comparator = __commonJS({
24976
25099
  return ANY;
24977
25100
  }
24978
25101
  constructor(comp, options) {
24979
- options = parseOptions(options);
25102
+ options = parseOptions2(options);
24980
25103
  if (comp instanceof _Comparator) {
24981
25104
  if (comp.loose === !!options.loose) {
24982
25105
  return comp;
@@ -25044,7 +25167,7 @@ var require_comparator = __commonJS({
25044
25167
  }
25045
25168
  return new Range(this.value, options).test(comp.semver);
25046
25169
  }
25047
- options = parseOptions(options);
25170
+ options = parseOptions2(options);
25048
25171
  if (options.includePrerelease && (this.value === "<0.0.0-0" || comp.value === "<0.0.0-0")) {
25049
25172
  return false;
25050
25173
  }
@@ -25070,7 +25193,7 @@ var require_comparator = __commonJS({
25070
25193
  }
25071
25194
  };
25072
25195
  module.exports = Comparator;
25073
- var parseOptions = require_parse_options();
25196
+ var parseOptions2 = require_parse_options();
25074
25197
  var { safeRe: re, t } = require_re();
25075
25198
  var cmp = require_cmp();
25076
25199
  var debug = require_debug();
@@ -25783,7 +25906,7 @@ var version2;
25783
25906
  var init_version = __esm({
25784
25907
  "../core/dist/version.js"() {
25785
25908
  "use strict";
25786
- version2 = "5.0.0-beta.40";
25909
+ version2 = "5.0.0-beta.42";
25787
25910
  }
25788
25911
  });
25789
25912
 
@@ -30982,9 +31105,9 @@ async function getHookByToken(token) {
30982
31105
  return hook;
30983
31106
  }
30984
31107
  async function resumeHook(tokenOrHook, payload, encryptionKeyOverride) {
30985
- return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false);
31108
+ return resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, false, Date.now());
30986
31109
  }
30987
- async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp) {
31110
+ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookFreshlyLookedUp, resumeRequestedAtMs) {
30988
31111
  return await waitedUntil(() => {
30989
31112
  return trace("hook.resume", async (span) => {
30990
31113
  const world = await getWorldLazy();
@@ -31076,9 +31199,15 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31076
31199
  }
31077
31200
  throw err;
31078
31201
  }
31202
+ const queuePublishRequestedAtMs = Date.now();
31079
31203
  await world.queue(queueName, {
31080
31204
  runId: hook.runId,
31081
- traceCarrier: resumeContext.traceCarrier ?? void 0
31205
+ traceCarrier: resumeContext.traceCarrier ?? void 0,
31206
+ hookResumeTiming: {
31207
+ resumeRequestedAtMs,
31208
+ queuePublishRequestedAtMs,
31209
+ strategy: "sequential"
31210
+ }
31082
31211
  }, queueOptions);
31083
31212
  return hook;
31084
31213
  }
@@ -31087,6 +31216,29 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31087
31216
  span?.setAttributes({
31088
31217
  "workflow.hook.resume_id": resumeId
31089
31218
  });
31219
+ const publishInvocation = /* @__PURE__ */ __name(() => {
31220
+ const queuePublishRequestedAtMs = Date.now();
31221
+ return world.queue(queueName, {
31222
+ runId: hook.runId,
31223
+ traceCarrier: resumeContext.traceCarrier ?? void 0,
31224
+ hookInput: {
31225
+ resumeId,
31226
+ hookId: hook.hookId,
31227
+ token: hook.token,
31228
+ payload: dehydratedPayload,
31229
+ payloadDigest,
31230
+ // Deployment affinity for the consumer's cheap pre-write
31231
+ // check: lets a misrouted delivery re-route before its
31232
+ // hoisted hook_received write instead of after.
31233
+ deploymentId: resumeContext.deploymentId
31234
+ },
31235
+ hookResumeTiming: {
31236
+ resumeRequestedAtMs,
31237
+ queuePublishRequestedAtMs,
31238
+ strategy: "parallel"
31239
+ }
31240
+ }, queueOptions);
31241
+ }, "publishInvocation");
31090
31242
  const [eventResult, queueResult] = await Promise.allSettled([
31091
31243
  world.events.create(hook.runId, {
31092
31244
  eventType: "hook_received",
@@ -31098,17 +31250,7 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31098
31250
  resumeId,
31099
31251
  resumePayloadDigest: payloadDigest
31100
31252
  }),
31101
- world.queue(queueName, {
31102
- runId: hook.runId,
31103
- traceCarrier: resumeContext.traceCarrier ?? void 0,
31104
- hookInput: {
31105
- resumeId,
31106
- hookId: hook.hookId,
31107
- token: hook.token,
31108
- payload: dehydratedPayload,
31109
- payloadDigest
31110
- }
31111
- }, queueOptions)
31253
+ publishInvocation()
31112
31254
  ]);
31113
31255
  if (queueResult.status === "rejected") {
31114
31256
  throw queueResult.reason;
@@ -31151,6 +31293,7 @@ async function resumeHookImpl(tokenOrHook, payload, encryptionKeyOverride, hookF
31151
31293
  });
31152
31294
  }
31153
31295
  async function resumeWebhook(token, request) {
31296
+ const resumeRequestedAtMs = Date.now();
31154
31297
  const { hook, encryptionKey } = await getHookByTokenWithKey(token);
31155
31298
  if (hook.isWebhook === false) {
31156
31299
  throw new HookNotFoundError(token);
@@ -31174,7 +31317,7 @@ async function resumeWebhook(token, request) {
31174
31317
  status: 202
31175
31318
  });
31176
31319
  }
31177
- await resumeHookImpl(hook, request, encryptionKey, true);
31320
+ await resumeHookImpl(hook, request, encryptionKey, true, resumeRequestedAtMs);
31178
31321
  if (responseReadable) {
31179
31322
  const reader = responseReadable.getReader();
31180
31323
  const chunk = await reader.read();
@@ -31548,7 +31691,8 @@ function createReconnectingFramedStream(runId, name, startIndex) {
31548
31691
  try {
31549
31692
  await connect();
31550
31693
  return;
31551
- } catch {
31694
+ } catch (error48) {
31695
+ if (StreamExpiredError.is(error48)) throw error48;
31552
31696
  }
31553
31697
  }
31554
31698
  }
@@ -33318,9 +33462,6 @@ async function start(workflow, argsOrOptions, options) {
33318
33462
  }
33319
33463
  } else {
33320
33464
  const result = runCreatedResult.value;
33321
- if (!result.run) {
33322
- throw new WorkflowRuntimeError("Missing 'run' in server response for 'run_created' event");
33323
- }
33324
33465
  if (!v1Compat && result.run.runId !== runId) {
33325
33466
  throw new WorkflowRuntimeError(`Server returned different runId than requested: expected ${runId}, got ${result.run.runId}`);
33326
33467
  }
@@ -33334,7 +33475,7 @@ async function start(workflow, argsOrOptions, options) {
33334
33475
  span?.setAttributes({
33335
33476
  ...WorkflowRunId(runId),
33336
33477
  ...DeploymentId(deploymentId),
33337
- ...runCreatedResult.status === "fulfilled" && runCreatedResult.value.run ? WorkflowRunStatus(runCreatedResult.value.run.status) : {}
33478
+ ...runCreatedResult.status === "fulfilled" ? WorkflowRunStatus(runCreatedResult.value.run.status) : {}
33338
33479
  });
33339
33480
  return new Run(runId, {
33340
33481
  resilientStart
@@ -33351,7 +33492,7 @@ __name(start, "start");
33351
33492
  value: "start",
33352
33493
  configurable: true
33353
33494
  });
33354
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.40//start");
33495
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.42//start");
33355
33496
 
33356
33497
  // ../core/dist/runtime/runs.js
33357
33498
  async function wakeUpRun(world, runId, options) {
@@ -33366,7 +33507,7 @@ async function wakeUpRun(world, runId, options) {
33366
33507
  const eventsResult = await world.events.list({
33367
33508
  runId,
33368
33509
  pagination: {
33369
- limit: 1e3,
33510
+ sortOrder: "asc",
33370
33511
  ...cursor ? {
33371
33512
  cursor
33372
33513
  } : {}
@@ -33695,7 +33836,7 @@ var Run = class _Run {
33695
33836
  value: "wakeUp",
33696
33837
  configurable: true
33697
33838
  });
33698
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#wakeUp");
33839
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#wakeUp");
33699
33840
  (function(__wf_fn, __wf_id) {
33700
33841
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33701
33842
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33704,7 +33845,7 @@ var Run = class _Run {
33704
33845
  value: "cancel",
33705
33846
  configurable: true
33706
33847
  });
33707
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#cancel");
33848
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#cancel");
33708
33849
  (function(__wf_fn, __wf_id) {
33709
33850
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33710
33851
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33713,7 +33854,7 @@ var Run = class _Run {
33713
33854
  value: "getReadable",
33714
33855
  configurable: true
33715
33856
  });
33716
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#getReadable");
33857
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#getReadable");
33717
33858
  (function(__wf_fn, __wf_id) {
33718
33859
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33719
33860
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33722,7 +33863,7 @@ var Run = class _Run {
33722
33863
  value: "exists",
33723
33864
  configurable: true
33724
33865
  });
33725
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#exists");
33866
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#exists");
33726
33867
  (function(__wf_fn, __wf_id) {
33727
33868
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33728
33869
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33731,7 +33872,7 @@ var Run = class _Run {
33731
33872
  value: "status",
33732
33873
  configurable: true
33733
33874
  });
33734
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#status");
33875
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#status");
33735
33876
  (function(__wf_fn, __wf_id) {
33736
33877
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33737
33878
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33740,7 +33881,7 @@ var Run = class _Run {
33740
33881
  value: "returnValue",
33741
33882
  configurable: true
33742
33883
  });
33743
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#returnValue");
33884
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#returnValue");
33744
33885
  (function(__wf_fn, __wf_id) {
33745
33886
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33746
33887
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33749,7 +33890,7 @@ var Run = class _Run {
33749
33890
  value: "workflowName",
33750
33891
  configurable: true
33751
33892
  });
33752
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#workflowName");
33893
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#workflowName");
33753
33894
  (function(__wf_fn, __wf_id) {
33754
33895
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33755
33896
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33758,7 +33899,7 @@ var Run = class _Run {
33758
33899
  value: "createdAt",
33759
33900
  configurable: true
33760
33901
  });
33761
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#createdAt");
33902
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#createdAt");
33762
33903
  (function(__wf_fn, __wf_id) {
33763
33904
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33764
33905
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33767,7 +33908,7 @@ var Run = class _Run {
33767
33908
  value: "startedAt",
33768
33909
  configurable: true
33769
33910
  });
33770
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#startedAt");
33911
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#startedAt");
33771
33912
  (function(__wf_fn, __wf_id) {
33772
33913
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33773
33914
  __wf_reg.set(__wf_id, __wf_fn);
@@ -33776,7 +33917,7 @@ var Run = class _Run {
33776
33917
  value: "completedAt",
33777
33918
  configurable: true
33778
33919
  });
33779
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.40//Run#completedAt");
33920
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.42//Run#completedAt");
33780
33921
  (function(__wf_cls, __wf_id) {
33781
33922
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
33782
33923
  __wf_reg.set(__wf_id, __wf_cls);
@@ -33786,7 +33927,7 @@ var Run = class _Run {
33786
33927
  enumerable: false,
33787
33928
  configurable: false
33788
33929
  });
33789
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.40//Run");
33930
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.42//Run");
33790
33931
 
33791
33932
  // ../workflow/dist/stdlib.js
33792
33933
  async function fetch2(...args) {