@workflow/world-testing 5.0.0-beta.25 → 5.0.0-beta.27

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.
@@ -333,9 +333,26 @@ var init_dist = __esm({
333
333
  });
334
334
 
335
335
  // ../errors/dist/error-codes.js
336
+ var RUN_ERROR_CODES;
336
337
  var init_error_codes = __esm({
337
338
  "../errors/dist/error-codes.js"() {
338
339
  "use strict";
340
+ RUN_ERROR_CODES = {
341
+ /** Error thrown in user workflow or step code */
342
+ USER_ERROR: "USER_ERROR",
343
+ /** Internal runtime error (missing timestamps, runtime invariant failures) */
344
+ RUNTIME_ERROR: "RUNTIME_ERROR",
345
+ /** Event log contains orphaned or mismatched events and cannot be replayed */
346
+ CORRUPTED_EVENT_LOG: "CORRUPTED_EVENT_LOG",
347
+ /** One replay could not consume the event log deterministically; retryable */
348
+ REPLAY_DIVERGENCE: "REPLAY_DIVERGENCE",
349
+ /** Run exceeded the maximum number of queue deliveries */
350
+ MAX_DELIVERIES_EXCEEDED: "MAX_DELIVERIES_EXCEEDED",
351
+ /** Workflow replay exceeded the maximum allowed duration */
352
+ REPLAY_TIMEOUT: "REPLAY_TIMEOUT",
353
+ /** World response violated the SDK contract and cannot be retried safely */
354
+ WORLD_CONTRACT_ERROR: "WORLD_CONTRACT_ERROR"
355
+ };
339
356
  }
340
357
  });
341
358
 
@@ -369,7 +386,7 @@ function buildFramedDetails(hint2, slug) {
369
386
  });
370
387
  return out;
371
388
  }
372
- var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
389
+ var BASE_URL, ERROR_SLUGS, WorkflowError, WorkflowWorldError, WorkflowRunFailedError, WorkflowRunNotCompletedError, WorkflowRuntimeError, RuntimeDecryptionError, SerializationError, StepNotRegisteredError, WorkflowNotRegisteredError, WorkflowRunNotFoundError, HookConflictError, HookNotFoundError, EntityConflictError, ThrottleError, WorkflowRunCancelledError, FatalError, RetryableError, FATAL_ERROR_KEY, RETRYABLE_ERROR_KEY, HOOK_CONFLICT_ERROR_KEY, RUNTIME_DECRYPTION_ERROR_KEY;
373
390
  var init_dist2 = __esm({
374
391
  "../errors/dist/index.js"() {
375
392
  "use strict";
@@ -498,8 +515,6 @@ Caused by: ${options.cause.stack}`;
498
515
  static {
499
516
  __name(this, "RuntimeDecryptionError");
500
517
  }
501
- /** Optional structured context about the failed encrypt/decrypt call. */
502
- context;
503
518
  constructor(message, options) {
504
519
  super(message, {
505
520
  cause: options?.cause,
@@ -540,6 +555,38 @@ Caused by: ${options.cause.stack}`;
540
555
  return isError(value) && value.name === "SerializationError";
541
556
  }
542
557
  };
558
+ StepNotRegisteredError = class extends WorkflowRuntimeError {
559
+ static {
560
+ __name(this, "StepNotRegisteredError");
561
+ }
562
+ stepName;
563
+ constructor(stepName) {
564
+ super(`Step "${stepName}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`, {
565
+ slug: ERROR_SLUGS.STEP_NOT_REGISTERED
566
+ });
567
+ this.name = "StepNotRegisteredError";
568
+ this.stepName = stepName;
569
+ }
570
+ static is(value) {
571
+ return isError(value) && value.name === "StepNotRegisteredError";
572
+ }
573
+ };
574
+ WorkflowNotRegisteredError = class extends WorkflowRuntimeError {
575
+ static {
576
+ __name(this, "WorkflowNotRegisteredError");
577
+ }
578
+ workflowName;
579
+ constructor(workflowName) {
580
+ super(`Workflow "${workflowName}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`, {
581
+ slug: ERROR_SLUGS.WORKFLOW_NOT_REGISTERED
582
+ });
583
+ this.name = "WorkflowNotRegisteredError";
584
+ this.workflowName = workflowName;
585
+ }
586
+ static is(value) {
587
+ return isError(value) && value.name === "WorkflowNotRegisteredError";
588
+ }
589
+ };
543
590
  WorkflowRunNotFoundError = class extends WorkflowError {
544
591
  static {
545
592
  __name(this, "WorkflowRunNotFoundError");
@@ -16445,7 +16492,7 @@ var init_serialization = __esm({
16445
16492
  });
16446
16493
 
16447
16494
  // ../world/dist/events.js
16448
- var EventTypeSchema, BaseEventSchema, StepCompletedEventSchema, StepFailedEventSchema, StepRetryingEventSchema, StepStartedEventSchema, StepCreatedEventSchema, HookCreatedEventSchema, HookReceivedEventSchema, HookDisposedEventSchema, HookConflictEventSchema, WaitCreatedEventSchema, WaitCompletedEventSchema, AttributeWriterSchema, AttrSetEventSchema, RunCreatedEventSchema, RunStartedEventSchema, RunCompletedEventSchema, RunFailedEventSchema, RunCancelledEventSchema, CreateEventSchema, AllEventsSchema, EventSchema;
16495
+ var EventTypeSchema, TerminalRunEventTypeSchema, TERMINAL_RUN_EVENT_TYPES, BaseEventSchema, StepCompletedEventSchema, StepFailedEventSchema, StepRetryingEventSchema, StepStartedEventSchema, StepCreatedEventSchema, HookCreatedEventSchema, HookReceivedEventSchema, HookDisposedEventSchema, HookConflictEventSchema, WaitCreatedEventSchema, WaitCompletedEventSchema, AttributeWriterSchema, AttrSetEventSchema, RunCreatedEventSchema, RunStartedEventSchema, RunCompletedEventSchema, RunFailedEventSchema, RunCancelledEventSchema, CreateEventSchema, AllEventsSchema, EventSchema;
16449
16496
  var init_events = __esm({
16450
16497
  "../world/dist/events.js"() {
16451
16498
  "use strict";
@@ -16476,6 +16523,12 @@ var init_events = __esm({
16476
16523
  "wait_created",
16477
16524
  "wait_completed"
16478
16525
  ]);
16526
+ TerminalRunEventTypeSchema = EventTypeSchema.extract([
16527
+ "run_completed",
16528
+ "run_failed",
16529
+ "run_cancelled"
16530
+ ]);
16531
+ TERMINAL_RUN_EVENT_TYPES = TerminalRunEventTypeSchema.options;
16479
16532
  BaseEventSchema = external_exports.object({
16480
16533
  eventType: EventTypeSchema,
16481
16534
  correlationId: external_exports.string().optional(),
@@ -16704,134 +16757,8 @@ var init_events = __esm({
16704
16757
  }
16705
16758
  });
16706
16759
 
16707
- // ../world/dist/hooks.js
16708
- var HookSchema;
16709
- var init_hooks = __esm({
16710
- "../world/dist/hooks.js"() {
16711
- "use strict";
16712
- init_zod();
16713
- init_serialization();
16714
- HookSchema = external_exports.object({
16715
- runId: external_exports.string(),
16716
- hookId: external_exports.string(),
16717
- token: external_exports.string(),
16718
- ownerId: external_exports.string(),
16719
- projectId: external_exports.string(),
16720
- environment: external_exports.string(),
16721
- metadata: SerializedDataSchema.optional(),
16722
- createdAt: external_exports.coerce.date(),
16723
- // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
16724
- specVersion: external_exports.number().optional(),
16725
- isWebhook: external_exports.boolean().optional(),
16726
- isSystem: external_exports.boolean().optional()
16727
- });
16728
- }
16729
- });
16730
-
16731
- // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/index.js
16732
- var init_classic = __esm({
16733
- "../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/index.js"() {
16734
- "use strict";
16735
- init_external();
16736
- init_external();
16737
- }
16738
- });
16739
-
16740
- // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/index.js
16741
- var init_v4 = __esm({
16742
- "../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/index.js"() {
16743
- "use strict";
16744
- init_classic();
16745
- init_classic();
16746
- }
16747
- });
16748
-
16749
- // ../world/dist/queue.js
16750
- function resolveQueueNamespace(namespace) {
16751
- return namespace ?? process.env.WORKFLOW_QUEUE_NAMESPACE ?? void 0;
16752
- }
16753
- function getQueueTopicPrefix(kind, namespace) {
16754
- if (namespace !== void 0) {
16755
- QueueNamespace.parse(namespace);
16756
- return `__${namespace}_wkf_${kind}_`;
16757
- }
16758
- return `__wkf_${kind}_`;
16759
- }
16760
- var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, WorkflowInvokePayloadSchema, StepInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
16761
- var init_queue = __esm({
16762
- "../world/dist/queue.js"() {
16763
- "use strict";
16764
- init_v4();
16765
- QueuePrefix = external_exports.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_$/, "Must match __wkf_{workflow|step}_ or __{namespace}_wkf_{workflow|step}_");
16766
- ValidQueueName = external_exports.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_.+$/, "Must be a valid queue name with a recognized prefix");
16767
- QueueNamespace = external_exports.string().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
16768
- __name(resolveQueueNamespace, "resolveQueueNamespace");
16769
- __name(getQueueTopicPrefix, "getQueueTopicPrefix");
16770
- MessageId = external_exports.string().brand().describe("A stored queue message ID");
16771
- TraceCarrierSchema = external_exports.record(external_exports.string(), external_exports.string());
16772
- RunInputSchema = external_exports.object({
16773
- input: external_exports.unknown(),
16774
- deploymentId: external_exports.string(),
16775
- workflowName: external_exports.string(),
16776
- specVersion: external_exports.number(),
16777
- executionContext: external_exports.record(external_exports.string(), external_exports.any()).optional(),
16778
- /** Initial plaintext run attributes, for resilient run creation. */
16779
- attributes: external_exports.record(external_exports.string(), external_exports.string()).optional(),
16780
- /**
16781
- * Permits reserved `$`-prefixed keys in `attributes`, mirrored from the
16782
- * `start()` option so resilient run creation validates the same way as
16783
- * the original `run_created` attempt.
16784
- */
16785
- allowReservedAttributes: external_exports.literal(true).optional()
16786
- });
16787
- WorkflowInvokePayloadSchema = external_exports.object({
16788
- runId: external_exports.string(),
16789
- traceCarrier: TraceCarrierSchema.optional(),
16790
- requestedAt: external_exports.coerce.date().optional(),
16791
- /** Consecutive replay divergences in this recovery chain and latest position. */
16792
- replayDivergence: external_exports.object({
16793
- eventId: external_exports.string(),
16794
- count: external_exports.number().int().positive()
16795
- }).optional(),
16796
- /** Number of times this message has been re-enqueued due to server errors (5xx) */
16797
- serverErrorRetryCount: external_exports.number().int().optional(),
16798
- /** Step ID for inline step execution in combined handler. If provided, the flow execution
16799
- * will jump directly to execute the step with the given ID before doing an event replay. */
16800
- stepId: external_exports.string().optional(),
16801
- /** Step name, sent alongside stepId to avoid loading the event log just to resolve the name. */
16802
- stepName: external_exports.string().optional(),
16803
- /** Run creation data, only present on the first queue delivery from start() */
16804
- runInput: RunInputSchema.optional()
16805
- });
16806
- StepInvokePayloadSchema = external_exports.object({
16807
- workflowName: external_exports.string(),
16808
- workflowRunId: external_exports.string(),
16809
- workflowStartedAt: external_exports.number(),
16810
- stepId: external_exports.string(),
16811
- traceCarrier: TraceCarrierSchema.optional(),
16812
- requestedAt: external_exports.coerce.date().optional()
16813
- });
16814
- HealthCheckPayloadSchema = external_exports.object({
16815
- __healthCheck: external_exports.literal(true),
16816
- correlationId: external_exports.string()
16817
- });
16818
- QueuePayloadSchema = external_exports.union([
16819
- WorkflowInvokePayloadSchema,
16820
- StepInvokePayloadSchema,
16821
- HealthCheckPayloadSchema
16822
- ]);
16823
- }
16824
- });
16825
-
16826
- // ../world/dist/recovery.js
16827
- var init_recovery = __esm({
16828
- "../world/dist/recovery.js"() {
16829
- "use strict";
16830
- }
16831
- });
16832
-
16833
16760
  // ../world/dist/runs.js
16834
- var WorkflowRunStatusSchema, WorkflowRunBaseSchema, WorkflowRunSchema;
16761
+ var WorkflowRunStatusSchema, TerminalWorkflowRunStatusSchema, TERMINAL_WORKFLOW_RUN_STATUSES, WorkflowRunBaseSchema, WorkflowRunSchema;
16835
16762
  var init_runs = __esm({
16836
16763
  "../world/dist/runs.js"() {
16837
16764
  "use strict";
@@ -16844,6 +16771,12 @@ var init_runs = __esm({
16844
16771
  "failed",
16845
16772
  "cancelled"
16846
16773
  ]);
16774
+ TerminalWorkflowRunStatusSchema = WorkflowRunStatusSchema.extract([
16775
+ "completed",
16776
+ "failed",
16777
+ "cancelled"
16778
+ ]);
16779
+ TERMINAL_WORKFLOW_RUN_STATUSES = TerminalWorkflowRunStatusSchema.options;
16847
16780
  WorkflowRunBaseSchema = external_exports.object({
16848
16781
  runId: external_exports.string(),
16849
16782
  status: WorkflowRunStatusSchema,
@@ -16948,50 +16881,8 @@ var init_runs = __esm({
16948
16881
  }
16949
16882
  });
16950
16883
 
16951
- // ../world/dist/shared.js
16952
- var zodJsonSchema, StructuredErrorSchema;
16953
- var init_shared = __esm({
16954
- "../world/dist/shared.js"() {
16955
- "use strict";
16956
- init_zod();
16957
- zodJsonSchema = external_exports.lazy(() => {
16958
- return external_exports.union([
16959
- external_exports.string(),
16960
- external_exports.number(),
16961
- external_exports.boolean(),
16962
- external_exports.null(),
16963
- external_exports.array(zodJsonSchema),
16964
- external_exports.record(external_exports.string(), zodJsonSchema)
16965
- ]);
16966
- });
16967
- StructuredErrorSchema = external_exports.object({
16968
- message: external_exports.string(),
16969
- stack: external_exports.string().optional(),
16970
- code: external_exports.string().optional()
16971
- });
16972
- }
16973
- });
16974
-
16975
- // ../world/dist/spec-version.js
16976
- function isLegacySpecVersion(v) {
16977
- return v === void 0 || v === null || v <= SPEC_VERSION_LEGACY;
16978
- }
16979
- var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_EVENT_SOURCING, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_CURRENT;
16980
- var init_spec_version = __esm({
16981
- "../world/dist/spec-version.js"() {
16982
- "use strict";
16983
- SPEC_VERSION_LEGACY = 1;
16984
- SPEC_VERSION_SUPPORTS_EVENT_SOURCING = 2;
16985
- SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
16986
- SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
16987
- SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
16988
- SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_COMPRESSION;
16989
- __name(isLegacySpecVersion, "isLegacySpecVersion");
16990
- }
16991
- });
16992
-
16993
16884
  // ../world/dist/steps.js
16994
- var StepStatusSchema, StepSchema;
16885
+ var StepStatusSchema, StepSchema, TerminalStepStatusSchema, TERMINAL_STEP_STATUSES;
16995
16886
  var init_steps = __esm({
16996
16887
  "../world/dist/steps.js"() {
16997
16888
  "use strict";
@@ -17055,6 +16946,342 @@ var init_steps = __esm({
17055
16946
  // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
17056
16947
  specVersion: external_exports.number().optional()
17057
16948
  });
16949
+ TerminalStepStatusSchema = StepStatusSchema.extract([
16950
+ "completed",
16951
+ "failed",
16952
+ "cancelled"
16953
+ ]);
16954
+ TERMINAL_STEP_STATUSES = TerminalStepStatusSchema.options;
16955
+ }
16956
+ });
16957
+
16958
+ // ../world/dist/waits.js
16959
+ var WaitStatusSchema, WaitSchema;
16960
+ var init_waits = __esm({
16961
+ "../world/dist/waits.js"() {
16962
+ "use strict";
16963
+ init_zod();
16964
+ WaitStatusSchema = external_exports.enum([
16965
+ "waiting",
16966
+ "completed"
16967
+ ]);
16968
+ WaitSchema = external_exports.object({
16969
+ waitId: external_exports.string(),
16970
+ runId: external_exports.string(),
16971
+ status: WaitStatusSchema,
16972
+ resumeAt: external_exports.coerce.date().optional(),
16973
+ completedAt: external_exports.coerce.date().optional(),
16974
+ createdAt: external_exports.coerce.date(),
16975
+ updatedAt: external_exports.coerce.date(),
16976
+ specVersion: external_exports.number().optional()
16977
+ });
16978
+ }
16979
+ });
16980
+
16981
+ // ../world/dist/analytics.js
16982
+ var NullableDateSchema, NullableStringSchema, NullableBooleanSchema, AnalyticsRunSchema, AnalyticsStepSchema, AnalyticsEventSchema, AnalyticsHookSchema, AnalyticsWaitSchema;
16983
+ var init_analytics = __esm({
16984
+ "../world/dist/analytics.js"() {
16985
+ "use strict";
16986
+ init_zod();
16987
+ init_events();
16988
+ init_runs();
16989
+ init_steps();
16990
+ init_waits();
16991
+ NullableDateSchema = external_exports.coerce.date().nullable().optional();
16992
+ NullableStringSchema = external_exports.string().nullable().optional();
16993
+ NullableBooleanSchema = external_exports.boolean().nullable().optional();
16994
+ AnalyticsRunSchema = external_exports.object({
16995
+ runId: external_exports.string(),
16996
+ status: WorkflowRunStatusSchema,
16997
+ deploymentId: external_exports.string(),
16998
+ workflowName: external_exports.string(),
16999
+ specVersion: external_exports.coerce.number().optional(),
17000
+ attributes: external_exports.record(external_exports.string(), external_exports.string()).default({}),
17001
+ createdAt: external_exports.coerce.date(),
17002
+ updatedAt: external_exports.coerce.date(),
17003
+ startedAt: NullableDateSchema,
17004
+ completedAt: NullableDateSchema,
17005
+ errorCode: NullableStringSchema,
17006
+ workflowCoreVersion: NullableStringSchema,
17007
+ workflowEncryptionEnabled: NullableBooleanSchema
17008
+ });
17009
+ AnalyticsStepSchema = external_exports.object({
17010
+ runId: external_exports.string(),
17011
+ stepId: external_exports.string(),
17012
+ stepName: NullableStringSchema,
17013
+ status: StepStatusSchema,
17014
+ attempt: external_exports.number().optional(),
17015
+ createdAt: external_exports.coerce.date(),
17016
+ updatedAt: external_exports.coerce.date(),
17017
+ startedAt: NullableDateSchema,
17018
+ completedAt: NullableDateSchema,
17019
+ retryAfter: NullableDateSchema,
17020
+ errorCode: NullableStringSchema,
17021
+ workflowCoreVersion: NullableStringSchema,
17022
+ workflowEncryptionEnabled: NullableBooleanSchema
17023
+ });
17024
+ AnalyticsEventSchema = external_exports.object({
17025
+ runId: external_exports.string(),
17026
+ eventId: external_exports.string(),
17027
+ eventType: EventTypeSchema,
17028
+ correlationId: NullableStringSchema,
17029
+ entityId: NullableStringSchema,
17030
+ stepName: NullableStringSchema,
17031
+ workflowName: external_exports.string(),
17032
+ deploymentId: external_exports.string(),
17033
+ specVersion: external_exports.coerce.number().optional(),
17034
+ runCreatedAt: external_exports.coerce.date(),
17035
+ createdAt: external_exports.coerce.date(),
17036
+ region: NullableStringSchema,
17037
+ vercelId: NullableStringSchema,
17038
+ requestId: NullableStringSchema,
17039
+ resumeAt: NullableDateSchema,
17040
+ retryAfter: NullableDateSchema,
17041
+ errorCode: NullableStringSchema,
17042
+ workflowCoreVersion: NullableStringSchema,
17043
+ isWebhook: NullableBooleanSchema,
17044
+ isSystem: NullableBooleanSchema,
17045
+ workflowEncryptionEnabled: NullableBooleanSchema
17046
+ });
17047
+ AnalyticsHookSchema = external_exports.object({
17048
+ runId: external_exports.string(),
17049
+ hookId: external_exports.string(),
17050
+ status: external_exports.enum([
17051
+ "created",
17052
+ "received",
17053
+ "disposed",
17054
+ "conflict"
17055
+ ]),
17056
+ createdAt: external_exports.coerce.date(),
17057
+ updatedAt: external_exports.coerce.date(),
17058
+ receivedAt: NullableDateSchema,
17059
+ disposedAt: NullableDateSchema,
17060
+ isWebhook: NullableBooleanSchema,
17061
+ isSystem: NullableBooleanSchema,
17062
+ workflowCoreVersion: NullableStringSchema,
17063
+ workflowEncryptionEnabled: NullableBooleanSchema
17064
+ });
17065
+ AnalyticsWaitSchema = external_exports.object({
17066
+ runId: external_exports.string(),
17067
+ waitId: external_exports.string(),
17068
+ status: WaitStatusSchema,
17069
+ resumeAt: NullableDateSchema,
17070
+ createdAt: external_exports.coerce.date(),
17071
+ updatedAt: external_exports.coerce.date(),
17072
+ completedAt: NullableDateSchema,
17073
+ workflowCoreVersion: NullableStringSchema,
17074
+ workflowEncryptionEnabled: NullableBooleanSchema
17075
+ });
17076
+ }
17077
+ });
17078
+
17079
+ // ../world/dist/env-config.js
17080
+ function warnOnce(key, message) {
17081
+ if (warnedEnvValues.has(key)) return;
17082
+ warnedEnvValues.add(key);
17083
+ console.warn(`[workflow] ${message}`);
17084
+ }
17085
+ function envNumber(name, fallback, options = {}) {
17086
+ const raw = process.env[name];
17087
+ if (raw === void 0 || raw === "") return fallback;
17088
+ const { min = 0, max, integer: integer2 = false } = options;
17089
+ const parsed = Number(raw);
17090
+ if (!Number.isFinite(parsed) || integer2 && !Number.isInteger(parsed)) {
17091
+ warnOnce(`${name}=${raw}`, `Ignoring ${name}: not a ${integer2 ? "finite integer" : "finite number"}; using default ${fallback}`);
17092
+ return fallback;
17093
+ }
17094
+ if (parsed < min) {
17095
+ warnOnce(`${name}=${raw}`, `${name} below minimum ${min}; clamped`);
17096
+ return min;
17097
+ }
17098
+ if (max !== void 0 && parsed > max) {
17099
+ warnOnce(`${name}=${raw}`, `${name} above maximum ${max}; clamped`);
17100
+ return max;
17101
+ }
17102
+ return parsed;
17103
+ }
17104
+ var warnedEnvValues;
17105
+ var init_env_config = __esm({
17106
+ "../world/dist/env-config.js"() {
17107
+ "use strict";
17108
+ warnedEnvValues = /* @__PURE__ */ new Set();
17109
+ __name(warnOnce, "warnOnce");
17110
+ __name(envNumber, "envNumber");
17111
+ }
17112
+ });
17113
+
17114
+ // ../world/dist/hooks.js
17115
+ var HookSchema;
17116
+ var init_hooks = __esm({
17117
+ "../world/dist/hooks.js"() {
17118
+ "use strict";
17119
+ init_zod();
17120
+ init_serialization();
17121
+ HookSchema = external_exports.object({
17122
+ runId: external_exports.string(),
17123
+ hookId: external_exports.string(),
17124
+ token: external_exports.string(),
17125
+ ownerId: external_exports.string(),
17126
+ projectId: external_exports.string(),
17127
+ environment: external_exports.string(),
17128
+ metadata: SerializedDataSchema.optional(),
17129
+ createdAt: external_exports.coerce.date(),
17130
+ // Optional in database for backwards compatibility, defaults to 1 (legacy) when reading
17131
+ specVersion: external_exports.number().optional(),
17132
+ isWebhook: external_exports.boolean().optional(),
17133
+ isSystem: external_exports.boolean().optional()
17134
+ });
17135
+ }
17136
+ });
17137
+
17138
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/index.js
17139
+ var init_classic = __esm({
17140
+ "../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/index.js"() {
17141
+ "use strict";
17142
+ init_external();
17143
+ init_external();
17144
+ }
17145
+ });
17146
+
17147
+ // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/index.js
17148
+ var init_v4 = __esm({
17149
+ "../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/index.js"() {
17150
+ "use strict";
17151
+ init_classic();
17152
+ init_classic();
17153
+ }
17154
+ });
17155
+
17156
+ // ../world/dist/queue.js
17157
+ function resolveQueueNamespace(namespace) {
17158
+ return namespace ?? process.env.WORKFLOW_QUEUE_NAMESPACE ?? void 0;
17159
+ }
17160
+ function getQueueTopicPrefix(kind, namespace) {
17161
+ if (namespace !== void 0) {
17162
+ QueueNamespace.parse(namespace);
17163
+ return `__${namespace}_wkf_${kind}_`;
17164
+ }
17165
+ return `__wkf_${kind}_`;
17166
+ }
17167
+ var QueuePrefix, ValidQueueName, QueueNamespace, MessageId, TraceCarrierSchema, RunInputSchema, WorkflowInvokePayloadSchema, StepInvokePayloadSchema, HealthCheckPayloadSchema, QueuePayloadSchema;
17168
+ var init_queue = __esm({
17169
+ "../world/dist/queue.js"() {
17170
+ "use strict";
17171
+ init_v4();
17172
+ QueuePrefix = external_exports.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_$/, "Must match __wkf_{workflow|step}_ or __{namespace}_wkf_{workflow|step}_");
17173
+ ValidQueueName = external_exports.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_(?:workflow|step)_.+$/, "Must be a valid queue name with a recognized prefix");
17174
+ QueueNamespace = external_exports.string().regex(/^[a-z][a-z0-9]*$/, "Must be lowercase alphanumeric, starting with a letter");
17175
+ __name(resolveQueueNamespace, "resolveQueueNamespace");
17176
+ __name(getQueueTopicPrefix, "getQueueTopicPrefix");
17177
+ MessageId = external_exports.string().brand().describe("A stored queue message ID");
17178
+ TraceCarrierSchema = external_exports.record(external_exports.string(), external_exports.string());
17179
+ RunInputSchema = external_exports.object({
17180
+ input: external_exports.unknown(),
17181
+ deploymentId: external_exports.string(),
17182
+ workflowName: external_exports.string(),
17183
+ specVersion: external_exports.number(),
17184
+ executionContext: external_exports.record(external_exports.string(), external_exports.any()).optional(),
17185
+ /** Initial plaintext run attributes, for resilient run creation. */
17186
+ attributes: external_exports.record(external_exports.string(), external_exports.string()).optional(),
17187
+ /**
17188
+ * Permits reserved `$`-prefixed keys in `attributes`, mirrored from the
17189
+ * `start()` option so resilient run creation validates the same way as
17190
+ * the original `run_created` attempt.
17191
+ */
17192
+ allowReservedAttributes: external_exports.literal(true).optional()
17193
+ });
17194
+ WorkflowInvokePayloadSchema = external_exports.object({
17195
+ runId: external_exports.string(),
17196
+ traceCarrier: TraceCarrierSchema.optional(),
17197
+ requestedAt: external_exports.coerce.date().optional(),
17198
+ /** Consecutive replay divergences in this recovery chain and latest position. */
17199
+ replayDivergence: external_exports.object({
17200
+ eventId: external_exports.string(),
17201
+ count: external_exports.number().int().positive()
17202
+ }).optional(),
17203
+ /** Number of times this message has been re-enqueued due to server errors (5xx) */
17204
+ serverErrorRetryCount: external_exports.number().int().optional(),
17205
+ /** Step ID for inline step execution in combined handler. If provided, the flow execution
17206
+ * will jump directly to execute the step with the given ID before doing an event replay. */
17207
+ stepId: external_exports.string().optional(),
17208
+ /** Step name, sent alongside stepId to avoid loading the event log just to resolve the name. */
17209
+ stepName: external_exports.string().optional(),
17210
+ /** Run creation data, only present on the first queue delivery from start() */
17211
+ runInput: RunInputSchema.optional()
17212
+ });
17213
+ StepInvokePayloadSchema = external_exports.object({
17214
+ workflowName: external_exports.string(),
17215
+ workflowRunId: external_exports.string(),
17216
+ workflowStartedAt: external_exports.number(),
17217
+ stepId: external_exports.string(),
17218
+ traceCarrier: TraceCarrierSchema.optional(),
17219
+ requestedAt: external_exports.coerce.date().optional()
17220
+ });
17221
+ HealthCheckPayloadSchema = external_exports.object({
17222
+ __healthCheck: external_exports.literal(true),
17223
+ correlationId: external_exports.string()
17224
+ });
17225
+ QueuePayloadSchema = external_exports.union([
17226
+ WorkflowInvokePayloadSchema,
17227
+ StepInvokePayloadSchema,
17228
+ HealthCheckPayloadSchema
17229
+ ]);
17230
+ }
17231
+ });
17232
+
17233
+ // ../world/dist/recovery.js
17234
+ var init_recovery = __esm({
17235
+ "../world/dist/recovery.js"() {
17236
+ "use strict";
17237
+ }
17238
+ });
17239
+
17240
+ // ../world/dist/shared.js
17241
+ var zodJsonSchema, PageInfoSchema, StructuredErrorSchema;
17242
+ var init_shared = __esm({
17243
+ "../world/dist/shared.js"() {
17244
+ "use strict";
17245
+ init_zod();
17246
+ zodJsonSchema = external_exports.lazy(() => {
17247
+ return external_exports.union([
17248
+ external_exports.string(),
17249
+ external_exports.number(),
17250
+ external_exports.boolean(),
17251
+ external_exports.null(),
17252
+ external_exports.array(zodJsonSchema),
17253
+ external_exports.record(external_exports.string(), zodJsonSchema)
17254
+ ]);
17255
+ });
17256
+ PageInfoSchema = external_exports.object({
17257
+ currentLookbackDays: external_exports.number(),
17258
+ maxLookbackDays: external_exports.number(),
17259
+ currentWindowStart: external_exports.coerce.date(),
17260
+ maxWindowStart: external_exports.coerce.date(),
17261
+ upgradeAvailable: external_exports.boolean()
17262
+ });
17263
+ StructuredErrorSchema = external_exports.object({
17264
+ message: external_exports.string(),
17265
+ stack: external_exports.string().optional(),
17266
+ code: external_exports.string().optional()
17267
+ });
17268
+ }
17269
+ });
17270
+
17271
+ // ../world/dist/spec-version.js
17272
+ function isLegacySpecVersion(v) {
17273
+ return v === void 0 || v === null || v <= SPEC_VERSION_LEGACY;
17274
+ }
17275
+ var SPEC_VERSION_LEGACY, SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT, SPEC_VERSION_SUPPORTS_ATTRIBUTES, SPEC_VERSION_SUPPORTS_COMPRESSION, SPEC_VERSION_CURRENT;
17276
+ var init_spec_version = __esm({
17277
+ "../world/dist/spec-version.js"() {
17278
+ "use strict";
17279
+ SPEC_VERSION_LEGACY = 1;
17280
+ SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT = 3;
17281
+ SPEC_VERSION_SUPPORTS_ATTRIBUTES = 4;
17282
+ SPEC_VERSION_SUPPORTS_COMPRESSION = 5;
17283
+ SPEC_VERSION_CURRENT = SPEC_VERSION_SUPPORTS_COMPRESSION;
17284
+ __name(isLegacySpecVersion, "isLegacySpecVersion");
17058
17285
  }
17059
17286
  });
17060
17287
 
@@ -17216,34 +17443,13 @@ var init_ulid = __esm({
17216
17443
  }
17217
17444
  });
17218
17445
 
17219
- // ../world/dist/waits.js
17220
- var WaitStatusSchema, WaitSchema;
17221
- var init_waits = __esm({
17222
- "../world/dist/waits.js"() {
17223
- "use strict";
17224
- init_zod();
17225
- WaitStatusSchema = external_exports.enum([
17226
- "waiting",
17227
- "completed"
17228
- ]);
17229
- WaitSchema = external_exports.object({
17230
- waitId: external_exports.string(),
17231
- runId: external_exports.string(),
17232
- status: WaitStatusSchema,
17233
- resumeAt: external_exports.coerce.date().optional(),
17234
- completedAt: external_exports.coerce.date().optional(),
17235
- createdAt: external_exports.coerce.date(),
17236
- updatedAt: external_exports.coerce.date(),
17237
- specVersion: external_exports.number().optional()
17238
- });
17239
- }
17240
- });
17241
-
17242
17446
  // ../world/dist/index.js
17243
17447
  var init_dist4 = __esm({
17244
17448
  "../world/dist/index.js"() {
17245
17449
  "use strict";
17450
+ init_analytics();
17246
17451
  init_attributes();
17452
+ init_env_config();
17247
17453
  init_events();
17248
17454
  init_hooks();
17249
17455
  init_queue();
@@ -18033,7 +18239,7 @@ function pollWritableLock(writable, state) {
18033
18239
  clearInterval(intervalId);
18034
18240
  state.writablePollingInterval = void 0;
18035
18241
  }
18036
- }, LOCK_POLL_INTERVAL_MS);
18242
+ }, getLockPollIntervalMs());
18037
18243
  state.writablePollingInterval = intervalId;
18038
18244
  }
18039
18245
  function pollReadableLock(readable, state) {
@@ -18052,7 +18258,7 @@ function pollReadableLock(readable, state) {
18052
18258
  clearInterval(intervalId);
18053
18259
  state.readablePollingInterval = void 0;
18054
18260
  }
18055
- }, LOCK_POLL_INTERVAL_MS);
18261
+ }, getLockPollIntervalMs());
18056
18262
  state.readablePollingInterval = intervalId;
18057
18263
  }
18058
18264
  async function flushablePipe(source, sink, state) {
@@ -18104,13 +18310,18 @@ async function flushablePipe(source, sink, state) {
18104
18310
  writer.releaseLock();
18105
18311
  }
18106
18312
  }
18107
- var LOCK_POLL_INTERVAL_MS;
18313
+ var LOCK_POLL_INTERVAL_MS, getLockPollIntervalMs;
18108
18314
  var init_flushable_stream = __esm({
18109
18315
  "../core/dist/flushable-stream.js"() {
18110
18316
  "use strict";
18111
18317
  init_dist2();
18112
18318
  init_dist();
18319
+ init_dist4();
18113
18320
  LOCK_POLL_INTERVAL_MS = 10;
18321
+ getLockPollIntervalMs = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_LOCK_POLL_INTERVAL_MS", LOCK_POLL_INTERVAL_MS, {
18322
+ integer: true,
18323
+ min: 1
18324
+ }), "getLockPollIntervalMs");
18114
18325
  __name(createFlushableState, "createFlushableState");
18115
18326
  __name(isWritableUnlockedNotClosed, "isWritableUnlockedNotClosed");
18116
18327
  __name(isReadableUnlockedNotClosed, "isReadableUnlockedNotClosed");
@@ -18196,16 +18407,41 @@ var init_private = __esm({
18196
18407
  }
18197
18408
  });
18198
18409
 
18410
+ // ../core/dist/runtime/world-compatibility.js
18411
+ function assertWorldSupportsRuntimeProtocol(world) {
18412
+ if (world.specVersion === SPEC_VERSION_CURRENT) {
18413
+ return;
18414
+ }
18415
+ const supportedVersion = world.specVersion ?? "none";
18416
+ 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.`);
18417
+ }
18418
+ var init_world_compatibility = __esm({
18419
+ "../core/dist/runtime/world-compatibility.js"() {
18420
+ "use strict";
18421
+ init_dist2();
18422
+ init_dist4();
18423
+ __name(assertWorldSupportsRuntimeProtocol, "assertWorldSupportsRuntimeProtocol");
18424
+ }
18425
+ });
18426
+
18199
18427
  // ../core/dist/runtime/get-world-lazy.js
18200
18428
  async function getWorldLazy() {
18201
18429
  const g = globalThis;
18202
- if (g[WorldCacheKey]) return g[WorldCacheKey];
18430
+ if (g[WorldCacheKey]) {
18431
+ assertWorldSupportsRuntimeProtocol(g[WorldCacheKey]);
18432
+ return g[WorldCacheKey];
18433
+ }
18203
18434
  if (g[WorldCachePromiseKey]) {
18204
18435
  g[WorldCacheKey] = await g[WorldCachePromiseKey];
18436
+ assertWorldSupportsRuntimeProtocol(g[WorldCacheKey]);
18205
18437
  return g[WorldCacheKey];
18206
18438
  }
18207
18439
  const getWorldFn = g[GetWorldFnKey];
18208
- if (getWorldFn) return getWorldFn();
18440
+ if (getWorldFn) {
18441
+ const world = await getWorldFn();
18442
+ assertWorldSupportsRuntimeProtocol(world);
18443
+ return world;
18444
+ }
18209
18445
  const worldPath = [
18210
18446
  "./world",
18211
18447
  "js"
@@ -18217,6 +18453,7 @@ var WorldCacheKey, WorldCachePromiseKey, GetWorldFnKey;
18217
18453
  var init_get_world_lazy = __esm({
18218
18454
  "../core/dist/runtime/get-world-lazy.js"() {
18219
18455
  "use strict";
18456
+ init_world_compatibility();
18220
18457
  WorldCacheKey = /* @__PURE__ */ Symbol.for("@workflow/world//cache");
18221
18458
  WorldCachePromiseKey = /* @__PURE__ */ Symbol.for("@workflow/world//cachePromise");
18222
18459
  GetWorldFnKey = /* @__PURE__ */ Symbol.for("@workflow/world//getWorldFn");
@@ -21891,6 +22128,7 @@ var EventConsumerResult;
21891
22128
  var init_events_consumer = __esm({
21892
22129
  "../core/dist/events-consumer.js"() {
21893
22130
  "use strict";
22131
+ init_dist4();
21894
22132
  init_logger();
21895
22133
  (function(EventConsumerResult2) {
21896
22134
  EventConsumerResult2[EventConsumerResult2["Consumed"] = 0] = "Consumed";
@@ -24007,7 +24245,7 @@ var version2;
24007
24245
  var init_version = __esm({
24008
24246
  "../core/dist/version.js"() {
24009
24247
  "use strict";
24010
- version2 = "5.0.0-beta.25";
24248
+ version2 = "5.0.0-beta.27";
24011
24249
  }
24012
24250
  });
24013
24251
 
@@ -25742,14 +25980,16 @@ function createReconnectingFramedStream(runId, name, startIndex) {
25742
25980
  currentStartIndex += consumedFrames;
25743
25981
  consumedFrames = 0;
25744
25982
  buffer2 = new Uint8Array(0);
25983
+ const maxReconnects = getFramedStreamMaxReconnects();
25984
+ const maxTotalReconnects = getFramedStreamMaxTotalReconnects();
25745
25985
  for (; ; ) {
25746
25986
  reconnectCount++;
25747
25987
  totalReconnectCount++;
25748
- if (reconnectCount > FRAMED_STREAM_MAX_RECONNECTS) {
25749
- throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${FRAMED_STREAM_MAX_RECONNECTS})`);
25988
+ if (reconnectCount > maxReconnects) {
25989
+ throw new Error(`Stream "${name}" exceeded maximum reconnection attempts (${maxReconnects})`);
25750
25990
  }
25751
- if (totalReconnectCount > FRAMED_STREAM_MAX_TOTAL_RECONNECTS) {
25752
- throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${FRAMED_STREAM_MAX_TOTAL_RECONNECTS})`);
25991
+ if (totalReconnectCount > maxTotalReconnects) {
25992
+ throw new Error(`Stream "${name}" exceeded maximum total reconnection attempts (${maxTotalReconnects})`);
25753
25993
  }
25754
25994
  try {
25755
25995
  await connect();
@@ -26642,11 +26882,12 @@ function getStreamAndRequestRevivers(allRevivers) {
26642
26882
  }
26643
26883
  return extra;
26644
26884
  }
26645
- var defaultUlid, FRAME_HEADER_SIZE, MAX_FRAME_SIZE, WorkflowServerReadableStream, FRAMED_STREAM_MAX_RECONNECTS, FRAMED_STREAM_MAX_TOTAL_RECONNECTS, STREAM_FLUSH_INTERVAL_MS, WorkflowServerWritableStream, STREAM_AND_REQUEST_KEYS;
26885
+ var defaultUlid, FRAME_HEADER_SIZE, MAX_FRAME_SIZE, WorkflowServerReadableStream, FRAMED_STREAM_MAX_RECONNECTS, getFramedStreamMaxReconnects, FRAMED_STREAM_MAX_TOTAL_RECONNECTS, getFramedStreamMaxTotalReconnects, STREAM_FLUSH_INTERVAL_MS, getStreamFlushIntervalMs, WorkflowServerWritableStream, STREAM_AND_REQUEST_KEYS;
26646
26886
  var init_serialization2 = __esm({
26647
26887
  "../core/dist/serialization.js"() {
26648
26888
  "use strict";
26649
26889
  init_dist2();
26890
+ init_dist4();
26650
26891
  init_devalue();
26651
26892
  init_node();
26652
26893
  init_encryption();
@@ -26722,9 +26963,20 @@ var init_serialization2 = __esm({
26722
26963
  }
26723
26964
  };
26724
26965
  FRAMED_STREAM_MAX_RECONNECTS = 50;
26966
+ getFramedStreamMaxReconnects = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS", FRAMED_STREAM_MAX_RECONNECTS, {
26967
+ integer: true,
26968
+ min: 1
26969
+ }), "getFramedStreamMaxReconnects");
26725
26970
  FRAMED_STREAM_MAX_TOTAL_RECONNECTS = 1e3;
26971
+ getFramedStreamMaxTotalReconnects = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS", FRAMED_STREAM_MAX_TOTAL_RECONNECTS, {
26972
+ integer: true,
26973
+ min: 1
26974
+ }), "getFramedStreamMaxTotalReconnects");
26726
26975
  __name(createReconnectingFramedStream, "createReconnectingFramedStream");
26727
26976
  STREAM_FLUSH_INTERVAL_MS = 10;
26977
+ getStreamFlushIntervalMs = /* @__PURE__ */ __name(() => envNumber("WORKFLOW_STREAM_FLUSH_INTERVAL_MS", STREAM_FLUSH_INTERVAL_MS, {
26978
+ integer: true
26979
+ }), "getStreamFlushIntervalMs");
26728
26980
  WorkflowServerWritableStream = class extends WritableStream {
26729
26981
  static {
26730
26982
  __name(this, "WorkflowServerWritableStream");
@@ -26770,7 +27022,7 @@ var init_serialization2 = __esm({
26770
27022
  const chunksToFlush = buffer2.slice();
26771
27023
  const world = await worldPromise;
26772
27024
  if (resolvedFlushIntervalMs === void 0) {
26773
- resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? STREAM_FLUSH_INTERVAL_MS;
27025
+ resolvedFlushIntervalMs = world.streamFlushIntervalMs ?? getStreamFlushIntervalMs();
26774
27026
  }
26775
27027
  if (typeof world.streams.writeMulti === "function" && chunksToFlush.length > 1) {
26776
27028
  await world.streams.writeMulti(runId, name, chunksToFlush);
@@ -26793,7 +27045,7 @@ var init_serialization2 = __esm({
26793
27045
  }, (err) => {
26794
27046
  for (const w of currentWaiters) w.reject(err);
26795
27047
  });
26796
- }, resolvedFlushIntervalMs ?? STREAM_FLUSH_INTERVAL_MS);
27048
+ }, resolvedFlushIntervalMs ?? getStreamFlushIntervalMs());
26797
27049
  }, "scheduleFlush");
26798
27050
  super({
26799
27051
  async write(chunk) {
@@ -27015,6 +27267,43 @@ __name(normalizeAttributeChanges, "normalizeAttributeChanges");
27015
27267
 
27016
27268
  // ../core/dist/runtime/start.js
27017
27269
  init_capabilities();
27270
+
27271
+ // ../core/dist/classify-error.js
27272
+ init_dist2();
27273
+ var WORLD_CONTRACT_ERROR_CODES = /* @__PURE__ */ new Set([
27274
+ "PARSE_ERROR",
27275
+ "SCHEMA_VALIDATION",
27276
+ RUN_ERROR_CODES.WORLD_CONTRACT_ERROR
27277
+ ]);
27278
+ var RETRYABLE_WORLD_ERROR_CODES = /* @__PURE__ */ new Set([
27279
+ "TRANSPORT",
27280
+ "TIMEOUT"
27281
+ ]);
27282
+ var RUNTIME_ERROR_CHECKS = [
27283
+ WorkflowRuntimeError.is,
27284
+ StepNotRegisteredError.is,
27285
+ WorkflowNotRegisteredError.is,
27286
+ // SDK-level encryption failures (most notably AES-GCM auth-tag
27287
+ // mismatches surfacing as a native `OperationError` from
27288
+ // `AESCipherJob.onDone`) are wrapped in `RuntimeDecryptionError` at
27289
+ // the encryption module boundary.
27290
+ RuntimeDecryptionError.is
27291
+ ];
27292
+ function isRetryableWorldError(err) {
27293
+ if (ThrottleError.is(err)) {
27294
+ return true;
27295
+ }
27296
+ if (!WorkflowWorldError.is(err)) {
27297
+ return false;
27298
+ }
27299
+ if (err.status !== void 0 && err.status >= 500) {
27300
+ return true;
27301
+ }
27302
+ return err.code !== void 0 && RETRYABLE_WORLD_ERROR_CODES.has(err.code);
27303
+ }
27304
+ __name(isRetryableWorldError, "isRetryableWorldError");
27305
+
27306
+ // ../core/dist/runtime/start.js
27018
27307
  init_encryption();
27019
27308
  init_logger();
27020
27309
  init_serialization2();
@@ -27024,6 +27313,7 @@ init_version();
27024
27313
  init_get_world_lazy();
27025
27314
  init_helpers();
27026
27315
  init_wait_until();
27316
+ init_world_compatibility();
27027
27317
  var CROSS_DEPLOYMENT_CAPABILITY_PROBE_TIMEOUT_MS = 2e3;
27028
27318
  var ulid3 = monotonicFactory();
27029
27319
  var hasWarnedLatestNoOp = false;
@@ -27051,7 +27341,8 @@ async function start(workflow, argsOrOptions, options) {
27051
27341
  span?.setAttributes({
27052
27342
  ...WorkflowArgumentsCount(args.length)
27053
27343
  });
27054
- const world = opts?.world ?? await getWorldLazy();
27344
+ const world = opts.world ?? await getWorldLazy();
27345
+ assertWorldSupportsRuntimeProtocol(world);
27055
27346
  const currentDeploymentId = await world.getDeploymentId();
27056
27347
  let deploymentId = opts.deploymentId ?? currentDeploymentId;
27057
27348
  if (deploymentId === "latest") {
@@ -27087,7 +27378,7 @@ async function start(workflow, argsOrOptions, options) {
27087
27378
  const ops = [];
27088
27379
  const runId = `wrun_${ulid3()}`;
27089
27380
  const traceCarrier = await serializeTraceCarrier();
27090
- const specVersion = opts.specVersion ?? world.specVersion ?? SPEC_VERSION_SUPPORTS_EVENT_SOURCING;
27381
+ const specVersion = opts.specVersion ?? world.specVersion;
27091
27382
  const v1Compat = isLegacySpecVersion(specVersion);
27092
27383
  const allowReservedAttributes = opts.allowReservedAttributes === true;
27093
27384
  let attributes;
@@ -27167,7 +27458,7 @@ async function start(workflow, argsOrOptions, options) {
27167
27458
  if (runCreatedResult.status === "rejected") {
27168
27459
  const err = runCreatedResult.reason;
27169
27460
  if (EntityConflictError.is(err)) {
27170
- } else if (isRetryableStartError(err)) {
27461
+ } else if (isRetryableWorldError(err)) {
27171
27462
  resilientStart = true;
27172
27463
  runtimeLogger.warn("Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.", {
27173
27464
  workflowRunId: runId,
@@ -27211,13 +27502,7 @@ __name(start, "start");
27211
27502
  value: "start",
27212
27503
  configurable: true
27213
27504
  });
27214
- })(start, "step//@workflow/core/runtime/start@5.0.0-beta.25//start");
27215
- function isRetryableStartError(err) {
27216
- if (ThrottleError.is(err)) return true;
27217
- if (WorkflowWorldError.is(err) && err.status && err.status >= 500) return true;
27218
- return false;
27219
- }
27220
- __name(isRetryableStartError, "isRetryableStartError");
27505
+ })(start, "step//@workflow/core/runtime/start@5.0.0-beta.27//start");
27221
27506
 
27222
27507
  // ../core/dist/runtime/runs.js
27223
27508
  async function wakeUpRun(world, runId, options) {
@@ -27544,7 +27829,7 @@ var Run = class _Run {
27544
27829
  value: "wakeUp",
27545
27830
  configurable: true
27546
27831
  });
27547
- })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#wakeUp");
27832
+ })(Run.prototype["wakeUp"], "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#wakeUp");
27548
27833
  (function(__wf_fn, __wf_id) {
27549
27834
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27550
27835
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27553,7 +27838,7 @@ var Run = class _Run {
27553
27838
  value: "cancel",
27554
27839
  configurable: true
27555
27840
  });
27556
- })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#cancel");
27841
+ })(Run.prototype["cancel"], "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#cancel");
27557
27842
  (function(__wf_fn, __wf_id) {
27558
27843
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27559
27844
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27562,7 +27847,7 @@ var Run = class _Run {
27562
27847
  value: "getReadable",
27563
27848
  configurable: true
27564
27849
  });
27565
- })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#getReadable");
27850
+ })(Run.prototype["getReadable"], "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#getReadable");
27566
27851
  (function(__wf_fn, __wf_id) {
27567
27852
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27568
27853
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27571,7 +27856,7 @@ var Run = class _Run {
27571
27856
  value: "exists",
27572
27857
  configurable: true
27573
27858
  });
27574
- })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#exists");
27859
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "exists").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#exists");
27575
27860
  (function(__wf_fn, __wf_id) {
27576
27861
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27577
27862
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27580,7 +27865,7 @@ var Run = class _Run {
27580
27865
  value: "status",
27581
27866
  configurable: true
27582
27867
  });
27583
- })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#status");
27868
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "status").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#status");
27584
27869
  (function(__wf_fn, __wf_id) {
27585
27870
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27586
27871
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27589,7 +27874,7 @@ var Run = class _Run {
27589
27874
  value: "returnValue",
27590
27875
  configurable: true
27591
27876
  });
27592
- })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#returnValue");
27877
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "returnValue").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#returnValue");
27593
27878
  (function(__wf_fn, __wf_id) {
27594
27879
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27595
27880
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27598,7 +27883,7 @@ var Run = class _Run {
27598
27883
  value: "workflowName",
27599
27884
  configurable: true
27600
27885
  });
27601
- })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#workflowName");
27886
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "workflowName").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#workflowName");
27602
27887
  (function(__wf_fn, __wf_id) {
27603
27888
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27604
27889
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27607,7 +27892,7 @@ var Run = class _Run {
27607
27892
  value: "createdAt",
27608
27893
  configurable: true
27609
27894
  });
27610
- })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#createdAt");
27895
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "createdAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#createdAt");
27611
27896
  (function(__wf_fn, __wf_id) {
27612
27897
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27613
27898
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27616,7 +27901,7 @@ var Run = class _Run {
27616
27901
  value: "startedAt",
27617
27902
  configurable: true
27618
27903
  });
27619
- })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#startedAt");
27904
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "startedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#startedAt");
27620
27905
  (function(__wf_fn, __wf_id) {
27621
27906
  var __wf_sym = /* @__PURE__ */ Symbol.for("@workflow/core//registeredSteps"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27622
27907
  __wf_reg.set(__wf_id, __wf_fn);
@@ -27625,7 +27910,7 @@ var Run = class _Run {
27625
27910
  value: "completedAt",
27626
27911
  configurable: true
27627
27912
  });
27628
- })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.25//Run#completedAt");
27913
+ })(Object.getOwnPropertyDescriptor(Run.prototype, "completedAt").get, "step//@workflow/core/runtime/run@5.0.0-beta.27//Run#completedAt");
27629
27914
  (function(__wf_cls, __wf_id) {
27630
27915
  var __wf_sym = /* @__PURE__ */ Symbol.for("workflow-class-registry"), __wf_reg = globalThis[__wf_sym] || (globalThis[__wf_sym] = /* @__PURE__ */ new Map());
27631
27916
  __wf_reg.set(__wf_id, __wf_cls);
@@ -27635,7 +27920,7 @@ var Run = class _Run {
27635
27920
  enumerable: false,
27636
27921
  configurable: false
27637
27922
  });
27638
- })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.25//Run");
27923
+ })(Run, "class//@workflow/core/runtime/run@5.0.0-beta.27//Run");
27639
27924
 
27640
27925
  // ../workflow/dist/stdlib.js
27641
27926
  async function fetch2(...args) {