@workflow/web 5.0.0-beta.42 → 5.0.0-beta.43

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.
@@ -13,12 +13,12 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
13
13
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
14
14
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
15
15
  var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
16
- var _a2, _b, _c, _d, _listeners, _onabort, _reader, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn, _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn, _worldPromise, _Run_instances, lazyWorldPromise_get, _encryptionKeyPromise, _resilientStart, getEncryptionKey_fn, getEncryptionKeyLazily_fn, pollReturnValue_fn;
16
+ var _a2, _b, _c, _d, _listeners, _onabort, _reader, _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, canAdoptWithSpace_fn, canAdopt_fn, canAdoptType_fn, adoptWithSpace_fn, adopt_fn, canUsurpType_fn, canUsurp_fn, usurp_fn, flatten_fn, partsToRegExp_fn, parseGlob_fn, _Minimatch_instances, matchGlobstar_fn, matchGlobStarBodySections_fn, matchOne_fn, _worldPromise, _Run_instances, lazyWorldPromise_get, _encryptionKeyPromise, _resilientStart, getEncryptionKey_fn, getEncryptionKeyLazily_fn, resolveTerminalReturnValue_fn, pollReturnValue_fn;
17
17
  import { createRequire as __wkfCreateRequire } from "node:module";
18
18
  if (typeof require === "undefined") {
19
19
  globalThis.require = __wkfCreateRequire(import.meta.url);
20
20
  }
21
- import require$$0$5, { PassThrough } from "node:stream";
21
+ import require$$0$5, { PassThrough, Transform as Transform$1 } from "node:stream";
22
22
  import require$$0$1, { Stream } from "stream";
23
23
  import require$$0 from "util";
24
24
  import require$$1 from "crypto";
@@ -36,22 +36,23 @@ import { promises } from "node:fs";
36
36
  import os, { tmpdir, homedir } from "node:os";
37
37
  import { execFile } from "node:child_process";
38
38
  import { setTimeout as setTimeout$1 } from "node:timers/promises";
39
+ import require$$0$7, { Buffer as Buffer$2 } from "node:buffer";
40
+ import http from "node:http";
41
+ import https from "node:https";
42
+ import zlib from "node:zlib";
39
43
  import require$$0$2 from "events";
40
44
  import require$$0$4 from "node:assert";
41
45
  import require$$1$1 from "node:net";
42
- import require$$2$1 from "node:http";
43
46
  import require$$5 from "node:querystring";
44
47
  import require$$0$3, { EventEmitter } from "node:events";
45
48
  import require$$0$6 from "node:diagnostics_channel";
46
49
  import require$$4 from "node:tls";
47
- import require$$0$7 from "node:buffer";
48
- import require$$3$1 from "node:zlib";
49
50
  import require$$5$1 from "node:perf_hooks";
50
51
  import require$$8 from "node:util/types";
51
52
  import require$$1$2 from "node:sqlite";
52
- import require$$2$2 from "node:worker_threads";
53
+ import require$$2$1 from "node:worker_threads";
53
54
  import require$$1$4 from "node:console";
54
- import require$$2$3 from "node:timers";
55
+ import require$$2$2 from "node:timers";
55
56
  import require$$1$5 from "node:dns";
56
57
  import * as path$2 from "path";
57
58
  import path__default from "path";
@@ -59,7 +60,7 @@ import * as fs from "fs";
59
60
  import fs__default from "fs";
60
61
  import require$$0$9 from "constants";
61
62
  import require$$5$2 from "assert";
62
- import require$$2$4 from "os";
63
+ import require$$2$3 from "os";
63
64
  import * as net from "net";
64
65
  import assert$1 from "node:assert/strict";
65
66
  import express from "express";
@@ -929,7 +930,7 @@ function requireReact_development() {
929
930
  ), ctor.default;
930
931
  throw payload._result;
931
932
  }
932
- function resolveDispatcher() {
933
+ function resolveDispatcher2() {
933
934
  var dispatcher2 = ReactSharedInternals.H;
934
935
  null === dispatcher2 && console.error(
935
936
  "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -1103,7 +1104,7 @@ function requireReact_development() {
1103
1104
  deprecatedAPIs = Object.freeze({
1104
1105
  __proto__: null,
1105
1106
  c: function(size2) {
1106
- return resolveDispatcher().useMemoCache(size2);
1107
+ return resolveDispatcher2().useMemoCache(size2);
1107
1108
  }
1108
1109
  });
1109
1110
  exports.Children = {
@@ -1414,39 +1415,39 @@ function requireReact_development() {
1414
1415
  }
1415
1416
  };
1416
1417
  exports.unstable_useCacheRefresh = function() {
1417
- return resolveDispatcher().useCacheRefresh();
1418
+ return resolveDispatcher2().useCacheRefresh();
1418
1419
  };
1419
1420
  exports.use = function(usable) {
1420
- return resolveDispatcher().use(usable);
1421
+ return resolveDispatcher2().use(usable);
1421
1422
  };
1422
1423
  exports.useActionState = function(action2, initialState, permalink) {
1423
- return resolveDispatcher().useActionState(
1424
+ return resolveDispatcher2().useActionState(
1424
1425
  action2,
1425
1426
  initialState,
1426
1427
  permalink
1427
1428
  );
1428
1429
  };
1429
1430
  exports.useCallback = function(callback, deps) {
1430
- return resolveDispatcher().useCallback(callback, deps);
1431
+ return resolveDispatcher2().useCallback(callback, deps);
1431
1432
  };
1432
1433
  exports.useContext = function(Context) {
1433
- var dispatcher2 = resolveDispatcher();
1434
+ var dispatcher2 = resolveDispatcher2();
1434
1435
  Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
1435
1436
  "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
1436
1437
  );
1437
1438
  return dispatcher2.useContext(Context);
1438
1439
  };
1439
1440
  exports.useDebugValue = function(value, formatterFn) {
1440
- return resolveDispatcher().useDebugValue(value, formatterFn);
1441
+ return resolveDispatcher2().useDebugValue(value, formatterFn);
1441
1442
  };
1442
1443
  exports.useDeferredValue = function(value, initialValue) {
1443
- return resolveDispatcher().useDeferredValue(value, initialValue);
1444
+ return resolveDispatcher2().useDeferredValue(value, initialValue);
1444
1445
  };
1445
1446
  exports.useEffect = function(create2, createDeps, update) {
1446
1447
  null == create2 && console.warn(
1447
1448
  "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1448
1449
  );
1449
- var dispatcher2 = resolveDispatcher();
1450
+ var dispatcher2 = resolveDispatcher2();
1450
1451
  if ("function" === typeof update)
1451
1452
  throw Error(
1452
1453
  "useEffect CRUD overload is not enabled in this build of React."
@@ -1454,47 +1455,47 @@ function requireReact_development() {
1454
1455
  return dispatcher2.useEffect(create2, createDeps);
1455
1456
  };
1456
1457
  exports.useId = function() {
1457
- return resolveDispatcher().useId();
1458
+ return resolveDispatcher2().useId();
1458
1459
  };
1459
1460
  exports.useImperativeHandle = function(ref, create2, deps) {
1460
- return resolveDispatcher().useImperativeHandle(ref, create2, deps);
1461
+ return resolveDispatcher2().useImperativeHandle(ref, create2, deps);
1461
1462
  };
1462
1463
  exports.useInsertionEffect = function(create2, deps) {
1463
1464
  null == create2 && console.warn(
1464
1465
  "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1465
1466
  );
1466
- return resolveDispatcher().useInsertionEffect(create2, deps);
1467
+ return resolveDispatcher2().useInsertionEffect(create2, deps);
1467
1468
  };
1468
1469
  exports.useLayoutEffect = function(create2, deps) {
1469
1470
  null == create2 && console.warn(
1470
1471
  "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1471
1472
  );
1472
- return resolveDispatcher().useLayoutEffect(create2, deps);
1473
+ return resolveDispatcher2().useLayoutEffect(create2, deps);
1473
1474
  };
1474
1475
  exports.useMemo = function(create2, deps) {
1475
- return resolveDispatcher().useMemo(create2, deps);
1476
+ return resolveDispatcher2().useMemo(create2, deps);
1476
1477
  };
1477
1478
  exports.useOptimistic = function(passthrough, reducer) {
1478
- return resolveDispatcher().useOptimistic(passthrough, reducer);
1479
+ return resolveDispatcher2().useOptimistic(passthrough, reducer);
1479
1480
  };
1480
1481
  exports.useReducer = function(reducer, initialArg, init2) {
1481
- return resolveDispatcher().useReducer(reducer, initialArg, init2);
1482
+ return resolveDispatcher2().useReducer(reducer, initialArg, init2);
1482
1483
  };
1483
1484
  exports.useRef = function(initialValue) {
1484
- return resolveDispatcher().useRef(initialValue);
1485
+ return resolveDispatcher2().useRef(initialValue);
1485
1486
  };
1486
1487
  exports.useState = function(initialState) {
1487
- return resolveDispatcher().useState(initialState);
1488
+ return resolveDispatcher2().useState(initialState);
1488
1489
  };
1489
1490
  exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
1490
- return resolveDispatcher().useSyncExternalStore(
1491
+ return resolveDispatcher2().useSyncExternalStore(
1491
1492
  subscribe,
1492
1493
  getSnapshot,
1493
1494
  getServerSnapshot
1494
1495
  );
1495
1496
  };
1496
1497
  exports.useTransition = function() {
1497
- return resolveDispatcher().useTransition();
1498
+ return resolveDispatcher2().useTransition();
1498
1499
  };
1499
1500
  exports.version = "19.1.0";
1500
1501
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
@@ -9725,7 +9726,7 @@ function requireReactDom_development() {
9725
9726
  function getValueDescriptorExpectingEnumForWarning(thing) {
9726
9727
  return null === thing ? "`null`" : void 0 === thing ? "`undefined`" : "" === thing ? "an empty string" : "string" === typeof thing ? JSON.stringify(thing) : "number" === typeof thing ? "`" + thing + "`" : 'something with type "' + typeof thing + '"';
9727
9728
  }
9728
- function resolveDispatcher() {
9729
+ function resolveDispatcher2() {
9729
9730
  var dispatcher2 = ReactSharedInternals.H;
9730
9731
  null === dispatcher2 && console.error(
9731
9732
  "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
@@ -9917,10 +9918,10 @@ function requireReactDom_development() {
9917
9918
  return fn2(a2);
9918
9919
  };
9919
9920
  reactDom_development.useFormState = function(action2, initialState, permalink) {
9920
- return resolveDispatcher().useFormState(action2, initialState, permalink);
9921
+ return resolveDispatcher2().useFormState(action2, initialState, permalink);
9921
9922
  };
9922
9923
  reactDom_development.useFormStatus = function() {
9923
- return resolveDispatcher().useHostTransitionStatus();
9924
+ return resolveDispatcher2().useHostTransitionStatus();
9924
9925
  };
9925
9926
  reactDom_development.version = "19.1.0";
9926
9927
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
@@ -57794,6 +57795,18 @@ function envNumber(name2, fallback, options = {}) {
57794
57795
  }
57795
57796
  return parsed;
57796
57797
  }
57798
+ function envFlag(name2, fallback, env2 = process.env) {
57799
+ const raw2 = env2[name2];
57800
+ if (raw2 === void 0 || raw2 === "")
57801
+ return fallback;
57802
+ const normalized = raw2.toLowerCase();
57803
+ if (normalized === "0" || normalized === "false")
57804
+ return false;
57805
+ if (normalized === "1" || normalized === "true")
57806
+ return true;
57807
+ warnOnce(`${name2}=${raw2}`, `Ignoring ${name2}: expected 0/1/true/false; using default ${fallback}`);
57808
+ return fallback;
57809
+ }
57797
57810
  const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
57798
57811
  function getMaxEventsPerRun() {
57799
57812
  const maxEvents = envNumber("WORKFLOW_MAX_EVENTS", DEFAULT_MAX_EVENTS_PER_RUN, { integer: true });
@@ -58057,6 +58070,11 @@ const HookSchema = object$1({
58057
58070
  // is active.
58058
58071
  resumeCapabilities: HookResumeCapabilitiesSchema.optional()
58059
58072
  });
58073
+ const NODE_HTTP_ENV_VAR = "WORKFLOW_NODE_HTTP";
58074
+ const NODE_HTTP_DEFAULT = false;
58075
+ function isNodeHttpEnabled(env2 = process.env) {
58076
+ return envFlag(NODE_HTTP_ENV_VAR, NODE_HTTP_DEFAULT, env2);
58077
+ }
58060
58078
  async function reenqueueActiveRuns(runs, enqueue, label, namespace2) {
58061
58079
  const workflowQueuePrefix = getQueueTopicPrefix("workflow", resolveQueueNamespace(namespace2));
58062
58080
  let reenqueued = 0;
@@ -60283,12 +60301,12 @@ function getNodeZlib$2() {
60283
60301
  }
60284
60302
  function decompressSyncIfAvailable(format2, payload) {
60285
60303
  try {
60286
- const zlib = getNodeZlib$2();
60287
- if (format2 === SerializationFormat.GZIP && (zlib == null ? void 0 : zlib.gunzipSync)) {
60288
- return new Uint8Array(zlib.gunzipSync(payload));
60304
+ const zlib2 = getNodeZlib$2();
60305
+ if (format2 === SerializationFormat.GZIP && (zlib2 == null ? void 0 : zlib2.gunzipSync)) {
60306
+ return new Uint8Array(zlib2.gunzipSync(payload));
60289
60307
  }
60290
- if (format2 === SerializationFormat.ZSTD && (zlib == null ? void 0 : zlib.zstdDecompressSync)) {
60291
- return new Uint8Array(zlib.zstdDecompressSync(payload));
60308
+ if (format2 === SerializationFormat.ZSTD && (zlib2 == null ? void 0 : zlib2.zstdDecompressSync)) {
60309
+ return new Uint8Array(zlib2.zstdDecompressSync(payload));
60292
60310
  }
60293
60311
  } catch {
60294
60312
  }
@@ -60886,7 +60904,7 @@ function replaceEncryptedAndExpiredWithMarkers(resource) {
60886
60904
  }
60887
60905
  async function hydrateResourceIOAsync(resource, key) {
60888
60906
  const { hydrateDataWithKey: hydrateDataWithKey2, deriveRunPayloadKeys: deriveRunPayloadKeys2 } = await Promise.resolve().then(() => serializationFormat);
60889
- const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-dRi0VqoM.js");
60907
+ const { ensureZstdDecoderRegistered } = await import("./zstd-browser-decoder-D8JD_nwS.js");
60890
60908
  ensureZstdDecoderRegistered();
60891
60909
  const cryptoKey = key ? await deriveRunPayloadKeys2(key) : void 0;
60892
60910
  const revivers = getRevivers();
@@ -62310,6 +62328,33 @@ function getMiddleTruncateCopyTextFromSelectionText({ prefixText, selectionText,
62310
62328
  });
62311
62329
  return mappedText === null ? null : leading + mappedText + trailing;
62312
62330
  }
62331
+ const pendingMeasurements = /* @__PURE__ */ new Map();
62332
+ let measurementFrame = 0;
62333
+ function flushMeasurements() {
62334
+ measurementFrame = 0;
62335
+ const reads = [...pendingMeasurements.values()];
62336
+ pendingMeasurements.clear();
62337
+ const measures = reads.map((read2) => read2());
62338
+ for (const measure of measures) {
62339
+ measure == null ? void 0 : measure();
62340
+ }
62341
+ }
62342
+ function scheduleMeasurement(key, { read: read2, measure }) {
62343
+ pendingMeasurements.set(key, () => {
62344
+ const measurement = read2();
62345
+ return measurement === null ? null : () => measure(measurement);
62346
+ });
62347
+ if (measurementFrame === 0) {
62348
+ measurementFrame = requestAnimationFrame(flushMeasurements);
62349
+ }
62350
+ }
62351
+ function cancelMeasurement(key) {
62352
+ pendingMeasurements.delete(key);
62353
+ if (pendingMeasurements.size === 0 && measurementFrame !== 0) {
62354
+ cancelAnimationFrame(measurementFrame);
62355
+ measurementFrame = 0;
62356
+ }
62357
+ }
62313
62358
  const useIsomorphicLayoutEffect$3 = typeof window === "undefined" ? reactExports.useEffect : reactExports.useLayoutEffect;
62314
62359
  function createFullState(value, graphemes) {
62315
62360
  return {
@@ -62327,7 +62372,13 @@ function useMiddleTruncate(value) {
62327
62372
  const ref = reactExports.useRef(null);
62328
62373
  const measureRef = reactExports.useRef(null);
62329
62374
  const [state, setState] = reactExports.useState(() => fullState);
62330
- const rafRef = reactExports.useRef(0);
62375
+ const measurementKeyRef = reactExports.useRef({});
62376
+ const textMeasurementCacheRef = reactExports.useRef({
62377
+ typography: "",
62378
+ value,
62379
+ widths: /* @__PURE__ */ new Map()
62380
+ });
62381
+ const lastMeasurementRef = reactExports.useRef(null);
62331
62382
  const updateState = reactExports.useCallback((nextState) => {
62332
62383
  setState((currentState) => {
62333
62384
  if (currentState.displayText === nextState.displayText && currentState.isTruncated === nextState.isTruncated && currentState.prefixText === nextState.prefixText && currentState.prefixGraphemeCount === nextState.prefixGraphemeCount && currentState.suffixText === nextState.suffixText && currentState.suffixGraphemeCount === nextState.suffixGraphemeCount) {
@@ -62336,26 +62387,68 @@ function useMiddleTruncate(value) {
62336
62387
  return nextState;
62337
62388
  });
62338
62389
  }, []);
62339
- const recalculate = reactExports.useCallback(() => {
62390
+ const readMeasurement = reactExports.useCallback(() => {
62340
62391
  const el = ref.current;
62341
62392
  const measureEl = measureRef.current;
62342
62393
  if (!el || !measureEl)
62394
+ return null;
62395
+ const availableWidth = el.clientWidth;
62396
+ const style2 = getComputedStyle(measureEl);
62397
+ return {
62398
+ availableWidth,
62399
+ typography: [
62400
+ style2.fontFamily,
62401
+ style2.fontFeatureSettings,
62402
+ style2.fontKerning,
62403
+ style2.fontSize,
62404
+ style2.fontStretch,
62405
+ style2.fontStyle,
62406
+ style2.fontVariationSettings,
62407
+ style2.fontWeight,
62408
+ style2.letterSpacing,
62409
+ style2.textTransform
62410
+ ].join("\0")
62411
+ };
62412
+ }, []);
62413
+ const recalculate = reactExports.useCallback(({ availableWidth, typography }) => {
62414
+ const measureEl = measureRef.current;
62415
+ if (!measureEl)
62343
62416
  return;
62344
- const available = el.clientWidth;
62345
- if (available <= 0) {
62417
+ const lastMeasurement = lastMeasurementRef.current;
62418
+ if ((lastMeasurement == null ? void 0 : lastMeasurement.availableWidth) === availableWidth && lastMeasurement.typography === typography && lastMeasurement.value === value) {
62419
+ return;
62420
+ }
62421
+ lastMeasurementRef.current = {
62422
+ availableWidth,
62423
+ typography,
62424
+ value
62425
+ };
62426
+ if (availableWidth <= 0) {
62346
62427
  updateState(fullState);
62347
62428
  return;
62348
62429
  }
62430
+ const textMeasurementCache = textMeasurementCacheRef.current;
62431
+ if (textMeasurementCache.typography !== typography || textMeasurementCache.value !== value) {
62432
+ textMeasurementCache.typography = typography;
62433
+ textMeasurementCache.value = value;
62434
+ textMeasurementCache.widths.clear();
62435
+ }
62349
62436
  const measure = (text2) => {
62437
+ const cachedWidth = textMeasurementCache.widths.get(text2);
62438
+ if (cachedWidth !== void 0) {
62439
+ return cachedWidth;
62440
+ }
62350
62441
  measureEl.textContent = text2;
62351
- return measureEl.scrollWidth;
62442
+ const width = measureEl.scrollWidth;
62443
+ textMeasurementCache.widths.set(text2, width);
62444
+ return width;
62352
62445
  };
62353
62446
  const fullWidth = measure(value);
62354
- if (fullWidth <= available) {
62447
+ if (fullWidth <= availableWidth) {
62355
62448
  updateState(fullState);
62356
62449
  return;
62357
62450
  }
62358
- const result = middleTruncate(graphemes, available, measure, fullWidth);
62451
+ const result = middleTruncate(graphemes, availableWidth, measure, fullWidth);
62359
62452
  updateState({
62360
62453
  displayText: result.text,
62361
62454
  isTruncated: result.truncated,
@@ -62366,33 +62459,45 @@ function useMiddleTruncate(value) {
62366
62459
  });
62367
62460
  }, [fullState, graphemes, updateState, value]);
62368
62461
  useIsomorphicLayoutEffect$3(() => {
62369
- recalculate();
62370
- }, [recalculate]);
62462
+ const measurement = readMeasurement();
62463
+ if (measurement) {
62464
+ recalculate(measurement);
62465
+ }
62466
+ }, [readMeasurement, recalculate]);
62371
62467
  reactExports.useEffect(() => {
62372
62468
  var _a3;
62373
62469
  const el = ref.current;
62374
62470
  if (!el)
62375
62471
  return;
62376
- const debouncedRecalc = () => {
62377
- cancelAnimationFrame(rafRef.current);
62378
- rafRef.current = requestAnimationFrame(recalculate);
62472
+ const measurementKey = measurementKeyRef.current;
62473
+ const scheduleRecalculation = () => {
62474
+ scheduleMeasurement(measurementKey, {
62475
+ read: readMeasurement,
62476
+ measure: recalculate
62477
+ });
62379
62478
  };
62380
- const ro2 = typeof ResizeObserver !== "undefined" ? new ResizeObserver(debouncedRecalc) : null;
62479
+ const ro2 = typeof ResizeObserver !== "undefined" ? new ResizeObserver(scheduleRecalculation) : null;
62381
62480
  ro2 == null ? void 0 : ro2.observe(el);
62382
- window.addEventListener("resize", debouncedRecalc);
62481
+ if (!ro2) {
62482
+ window.addEventListener("resize", scheduleRecalculation);
62483
+ }
62383
62484
  const onFontsLoaded = () => {
62384
- debouncedRecalc();
62485
+ textMeasurementCacheRef.current.widths.clear();
62486
+ lastMeasurementRef.current = null;
62487
+ scheduleRecalculation();
62385
62488
  };
62386
62489
  const fontSet = "fonts" in document ? document.fonts : null;
62387
62490
  (_a3 = fontSet == null ? void 0 : fontSet.addEventListener) == null ? void 0 : _a3.call(fontSet, "loadingdone", onFontsLoaded);
62388
62491
  return () => {
62389
62492
  var _a4;
62390
62493
  ro2 == null ? void 0 : ro2.disconnect();
62391
- window.removeEventListener("resize", debouncedRecalc);
62392
- cancelAnimationFrame(rafRef.current);
62494
+ if (!ro2) {
62495
+ window.removeEventListener("resize", scheduleRecalculation);
62496
+ }
62497
+ cancelMeasurement(measurementKey);
62393
62498
  (_a4 = fontSet == null ? void 0 : fontSet.removeEventListener) == null ? void 0 : _a4.call(fontSet, "loadingdone", onFontsLoaded);
62394
62499
  };
62395
- }, [recalculate]);
62500
+ }, [readMeasurement, recalculate]);
62396
62501
  return {
62397
62502
  ref,
62398
62503
  measureRef,
@@ -62408,12 +62513,18 @@ function getRangeOffsets(container, range2) {
62408
62513
  if (!container.contains(range2.startContainer) || !container.contains(range2.endContainer)) {
62409
62514
  return null;
62410
62515
  }
62411
- const startRange = document.createRange();
62412
- startRange.selectNodeContents(container);
62413
- startRange.setEnd(range2.startContainer, range2.startOffset);
62414
- const endRange = document.createRange();
62415
- endRange.selectNodeContents(container);
62416
- endRange.setEnd(range2.endContainer, range2.endOffset);
62516
+ let startRange;
62517
+ let endRange;
62518
+ try {
62519
+ startRange = document.createRange();
62520
+ startRange.selectNodeContents(container);
62521
+ startRange.setEnd(range2.startContainer, range2.startOffset);
62522
+ endRange = document.createRange();
62523
+ endRange.selectNodeContents(container);
62524
+ endRange.setEnd(range2.endContainer, range2.endOffset);
62525
+ } catch {
62526
+ return null;
62527
+ }
62417
62528
  return {
62418
62529
  end: endRange.toString().length,
62419
62530
  start: startRange.toString().length
@@ -62435,7 +62546,7 @@ function MiddleTruncate({ value, className, onCopy: onCopyProp, ...props }) {
62435
62546
  const range2 = selection2.getRangeAt(0);
62436
62547
  const visibleEl = visibleRef.current;
62437
62548
  let copyText = null;
62438
- if (e.currentTarget.contains(range2.startContainer) && e.currentTarget.contains(range2.endContainer) && visibleEl) {
62549
+ if (selectionText.includes(ELLIPSIS) && e.currentTarget.contains(range2.startContainer) && e.currentTarget.contains(range2.endContainer) && visibleEl) {
62439
62550
  const offsets = getRangeOffsets(visibleEl, range2);
62440
62551
  if (offsets) {
62441
62552
  copyText = getMiddleTruncateCopyText({
@@ -91644,7 +91755,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
91644
91755
  var et = ({ className: e, language: t, style: o, isIncomplete: n, ...s2 }) => jsxRuntimeExports.jsx("div", { className: f("my-4 flex w-full flex-col gap-2 rounded-xl border border-border bg-sidebar p-2", e), "data-incomplete": n || void 0, "data-language": t, "data-streamdown": "code-block", style: { contentVisibility: "auto", containIntrinsicSize: "auto 200px", ...o }, ...s2 });
91645
91756
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
91646
91757
  var ot = ({ language: e }) => jsxRuntimeExports.jsx("div", { className: "flex h-8 items-center text-muted-foreground text-xs", "data-language": e, "data-streamdown": "code-block-header", children: jsxRuntimeExports.jsx("span", { className: "ml-1 font-mono lowercase", children: e }) });
91647
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DMhwZQgG.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
91758
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-B1Smd86a.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
91648
91759
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
91649
91760
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
91650
91761
  return jsxRuntimeExports.jsx(Se.Provider, { value: { code: e }, children: jsxRuntimeExports.jsxs(et, { isIncomplete: s2, language: t, children: [jsxRuntimeExports.jsx(ot, { language: t }), n ? jsxRuntimeExports.jsx("div", { className: "pointer-events-none sticky top-2 z-10 -mt-10 flex h-8 items-center justify-end", children: jsxRuntimeExports.jsx("div", { className: "pointer-events-auto flex shrink-0 items-center gap-2 rounded-md border border-sidebar bg-sidebar/80 px-1.5 py-1 supports-[backdrop-filter]:bg-sidebar/70 supports-[backdrop-filter]:backdrop-blur", "data-streamdown": "code-block-actions", children: n }) }) : null, jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: jsxRuntimeExports.jsx(Qe, { className: o, language: t, result: c, ...r2 }), children: jsxRuntimeExports.jsx(dn, { className: o, code: i, language: t, raw: c, ...r2 }) })] }) });
@@ -91966,7 +92077,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
91966
92077
  }, []), jsxRuntimeExports.jsxs("div", { className: "relative", ref: i, children: [jsxRuntimeExports.jsx("button", { className: f("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50", t), disabled: c, onClick: () => r2(!s2), title: "Download table", type: "button", children: e != null ? e : jsxRuntimeExports.jsx(Z, { size: 14 }) }), s2 ? jsxRuntimeExports.jsxs("div", { className: "absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg", children: [jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("csv"), title: "Download table as CSV", type: "button", children: "CSV" }), jsxRuntimeExports.jsx("button", { className: "w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40", onClick: () => a2("markdown"), title: "Download table as Markdown", type: "button", children: "Markdown" })] }) : null] });
91967
92078
  };
91968
92079
  var Vt = ({ children: e, className: t, showControls: o, ...n }) => jsxRuntimeExports.jsxs("div", { className: "my-4 flex flex-col gap-2 rounded-lg border border-border bg-sidebar p-2", "data-streamdown": "table-wrapper", children: [o ? jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-end gap-1", children: [jsxRuntimeExports.jsx(Ht, {}), jsxRuntimeExports.jsx(Dt, {})] }) : null, jsxRuntimeExports.jsx("div", { className: "border-collapse overflow-x-auto overscroll-y-auto rounded-md border border-border bg-background", children: jsxRuntimeExports.jsx("table", { className: f("w-full divide-y divide-border", t), "data-streamdown": "table", ...n, children: e }) })] });
91969
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CK9fLYE8.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
92080
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CwYR558N.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
91970
92081
  function ke(e, t) {
91971
92082
  if (!(e != null && e.position || t != null && t.position)) return true;
91972
92083
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -102693,6 +102804,15 @@ function createReconnectingFramedStream(runId, name2, startIndex) {
102693
102804
  connectMs = Date.now() - connectStart;
102694
102805
  reader = stream.getReader();
102695
102806
  }
102807
+ async function isVerifiedComplete() {
102808
+ try {
102809
+ const world = await getWorldLazy();
102810
+ const info = await world.streams.getInfo(runId, name2);
102811
+ return info.done && currentStartIndex + consumedFrames > info.tailIndex;
102812
+ } catch {
102813
+ return true;
102814
+ }
102815
+ }
102696
102816
  async function reconnect() {
102697
102817
  if (reader) {
102698
102818
  await reader.cancel().catch(() => {
@@ -102753,6 +102873,15 @@ function createReconnectingFramedStream(runId, name2, startIndex) {
102753
102873
  }
102754
102874
  if (result.done || !result.value) {
102755
102875
  reader = void 0;
102876
+ if (reconnectSupported && !await isVerifiedComplete()) {
102877
+ try {
102878
+ await reconnect();
102879
+ } catch (reconnectErr) {
102880
+ controller.error(reconnectErr);
102881
+ return;
102882
+ }
102883
+ continue;
102884
+ }
102756
102885
  if (readStart !== void 0) {
102757
102886
  recordStreamReadComplete(readStart, runId, name2, chunksDelivered, bytesDelivered, totalReconnectCount);
102758
102887
  }
@@ -104064,7 +104193,7 @@ function getStreamAndRequestRevivers(allRevivers) {
104064
104193
  return extra;
104065
104194
  }
104066
104195
  `cinst_${ulid$3()}`;
104067
- const version$1 = "5.0.0-beta.42";
104196
+ const version$1 = "5.0.0-beta.43";
104068
104197
  const DEFAULT_HEALTH_CHECK_TIMEOUT = 3e4;
104069
104198
  const SAFE_WORKFLOW_NAME_PATTERN = /^[a-zA-Z0-9_\-./@]+$/;
104070
104199
  function getWorkflowQueueName(workflowName, namespace2) {
@@ -105243,6 +105372,263 @@ function instrumentObject$1(prefix, o) {
105243
105372
  }
105244
105373
  return handlers2;
105245
105374
  }
105375
+ function createNodeHttpAgents(options) {
105376
+ const shared = {
105377
+ keepAlive: true,
105378
+ keepAliveMsecs: options.keepAliveMs,
105379
+ maxSockets: options.maxSockets
105380
+ };
105381
+ return { http: new http.Agent(shared), https: new https.Agent(shared) };
105382
+ }
105383
+ function destroyNodeHttpAgents(agents) {
105384
+ agents.http.destroy();
105385
+ agents.https.destroy();
105386
+ }
105387
+ const NULL_BODY_STATUSES = /* @__PURE__ */ new Set([204, 205, 304]);
105388
+ const ACCEPTED_ENCODINGS = "gzip, deflate, br";
105389
+ const TIMEOUT_CODE = "ETIMEDOUT";
105390
+ function transportError(message2, code2) {
105391
+ return Object.assign(new Error(message2), { code: code2 });
105392
+ }
105393
+ function toOutgoingHeaders(headers2) {
105394
+ const outgoing = {};
105395
+ headers2 == null ? void 0 : headers2.forEach((value, name2) => {
105396
+ outgoing[name2] = value;
105397
+ });
105398
+ return outgoing;
105399
+ }
105400
+ function toResponseHeaders(message2) {
105401
+ const headers2 = new Headers();
105402
+ for (const [name2, value] of Object.entries(message2.headers)) {
105403
+ if (value === void 0)
105404
+ continue;
105405
+ if (Array.isArray(value)) {
105406
+ for (const entry2 of value)
105407
+ headers2.append(name2, entry2);
105408
+ } else {
105409
+ headers2.append(name2, value);
105410
+ }
105411
+ }
105412
+ return headers2;
105413
+ }
105414
+ const ZLIB_OPTIONS = {
105415
+ flush: zlib.constants.Z_SYNC_FLUSH,
105416
+ finishFlush: zlib.constants.Z_SYNC_FLUSH
105417
+ };
105418
+ const BROTLI_OPTIONS = {
105419
+ flush: zlib.constants.BROTLI_OPERATION_FLUSH,
105420
+ finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
105421
+ };
105422
+ class InflateAuto extends Transform$1 {
105423
+ constructor() {
105424
+ super(...arguments);
105425
+ __publicField(this, "inner");
105426
+ }
105427
+ _transform(chunk, _encoding, callback) {
105428
+ if (!this.inner) {
105429
+ if (chunk.length === 0) {
105430
+ callback();
105431
+ return;
105432
+ }
105433
+ const inner = (chunk[0] & 15) === 8 ? zlib.createInflate(ZLIB_OPTIONS) : zlib.createInflateRaw(ZLIB_OPTIONS);
105434
+ inner.on("data", (decoded) => this.push(decoded));
105435
+ inner.on("end", () => this.push(null));
105436
+ inner.on("error", (error2) => this.destroy(error2));
105437
+ this.inner = inner;
105438
+ }
105439
+ this.inner.write(chunk, callback);
105440
+ }
105441
+ /**
105442
+ * Overriding `_final` keeps the readable side open past the end of the
105443
+ * writable one, so the last inflated bytes still reach the consumer. It is
105444
+ * closed by the inner stream's `end`, or here when there was no body at all.
105445
+ */
105446
+ _final(callback) {
105447
+ if (this.inner) {
105448
+ this.inner.end();
105449
+ } else {
105450
+ this.push(null);
105451
+ }
105452
+ callback();
105453
+ }
105454
+ _destroy(error2, callback) {
105455
+ var _a3;
105456
+ (_a3 = this.inner) == null ? void 0 : _a3.destroy();
105457
+ callback(error2);
105458
+ }
105459
+ }
105460
+ function decodeBody(message2) {
105461
+ var _a3;
105462
+ const encoding2 = (_a3 = message2.headers["content-encoding"]) == null ? void 0 : _a3.toLowerCase().trim();
105463
+ if (!encoding2 || encoding2 === "identity")
105464
+ return message2;
105465
+ let decoder2;
105466
+ if (encoding2 === "gzip" || encoding2 === "x-gzip") {
105467
+ decoder2 = zlib.createGunzip(ZLIB_OPTIONS);
105468
+ } else if (encoding2 === "deflate") {
105469
+ decoder2 = new InflateAuto();
105470
+ } else if (encoding2 === "br") {
105471
+ decoder2 = zlib.createBrotliDecompress(BROTLI_OPTIONS);
105472
+ } else {
105473
+ return message2;
105474
+ }
105475
+ message2.on("error", (error2) => decoder2.destroy(error2));
105476
+ message2.on("close", () => {
105477
+ if (message2.complete)
105478
+ return;
105479
+ decoder2.destroy(transportError("socket hang up", "ECONNRESET"));
105480
+ });
105481
+ decoder2.on("close", () => {
105482
+ if (!message2.complete)
105483
+ message2.destroy();
105484
+ });
105485
+ return message2.pipe(decoder2);
105486
+ }
105487
+ function toWebStream(source, hooks) {
105488
+ let closed = false;
105489
+ const finish = (fn2) => {
105490
+ if (closed)
105491
+ return;
105492
+ closed = true;
105493
+ hooks.done();
105494
+ fn2();
105495
+ };
105496
+ return new ReadableStream({
105497
+ start(controller) {
105498
+ source.on("data", (chunk) => {
105499
+ hooks.progress();
105500
+ controller.enqueue(new Uint8Array(chunk));
105501
+ if ((controller.desiredSize ?? 1) <= 0)
105502
+ source.pause();
105503
+ });
105504
+ source.on("end", () => finish(() => controller.close()));
105505
+ source.on("error", (error2) => finish(() => controller.error(hooks.failure(error2))));
105506
+ source.on("close", () => finish(() => controller.error(hooks.failure())));
105507
+ },
105508
+ pull() {
105509
+ source.resume();
105510
+ },
105511
+ cancel(reason) {
105512
+ var _a3;
105513
+ finish(() => {
105514
+ });
105515
+ (_a3 = source.destroy) == null ? void 0 : _a3.call(source, reason instanceof Error ? reason : void 0);
105516
+ }
105517
+ });
105518
+ }
105519
+ function nodeHttpFetch(url2, init2 = {}) {
105520
+ const { method = "GET", headers: headers2, body: body2, signal, agents, headersTimeoutMs, bodyTimeoutMs } = init2;
105521
+ const target2 = new URL(url2);
105522
+ const secure = target2.protocol === "https:";
105523
+ if (!secure && target2.protocol !== "http:") {
105524
+ return Promise.reject(new TypeError(`node:http transport cannot request ${target2.protocol}// URLs`));
105525
+ }
105526
+ const outgoing = toOutgoingHeaders(headers2);
105527
+ const payload = body2 == null ? void 0 : typeof body2 === "string" ? Buffer$2.from(body2, "utf8") : Buffer$2.from(body2.buffer, body2.byteOffset, body2.byteLength);
105528
+ if (payload)
105529
+ outgoing["content-length"] = String(payload.byteLength);
105530
+ if (!("accept-encoding" in outgoing)) {
105531
+ outgoing["accept-encoding"] = ACCEPTED_ENCODINGS;
105532
+ }
105533
+ return new Promise((resolve2, reject) => {
105534
+ if (signal == null ? void 0 : signal.aborted) {
105535
+ reject(signal.reason);
105536
+ return;
105537
+ }
105538
+ let settled = false;
105539
+ let headersTimer;
105540
+ let bodyTimer;
105541
+ let teardownReason;
105542
+ const clearTimers = () => {
105543
+ clearTimeout(headersTimer);
105544
+ clearTimeout(bodyTimer);
105545
+ headersTimer = void 0;
105546
+ bodyTimer = void 0;
105547
+ };
105548
+ const request2 = (secure ? https : http).request(target2, {
105549
+ method,
105550
+ headers: outgoing,
105551
+ agent: agents ? secure ? agents.https : agents.http : void 0
105552
+ });
105553
+ const abort = () => {
105554
+ if ((signal == null ? void 0 : signal.reason) instanceof Error)
105555
+ teardownReason = signal.reason;
105556
+ request2.destroy(signal == null ? void 0 : signal.reason);
105557
+ };
105558
+ signal == null ? void 0 : signal.addEventListener("abort", abort, { once: true });
105559
+ const detach = () => {
105560
+ signal == null ? void 0 : signal.removeEventListener("abort", abort);
105561
+ };
105562
+ const fail = (error2) => {
105563
+ clearTimers();
105564
+ detach();
105565
+ if (settled)
105566
+ return;
105567
+ settled = true;
105568
+ reject(error2);
105569
+ };
105570
+ if (headersTimeoutMs) {
105571
+ request2.on("socket", () => {
105572
+ headersTimer = setTimeout(() => {
105573
+ request2.destroy(transportError(`no response headers within ${headersTimeoutMs}ms`, TIMEOUT_CODE));
105574
+ }, headersTimeoutMs);
105575
+ });
105576
+ }
105577
+ request2.on("error", fail);
105578
+ request2.on("response", (message2) => {
105579
+ clearTimeout(headersTimer);
105580
+ headersTimer = void 0;
105581
+ const status = message2.statusCode ?? 0;
105582
+ if (status < 200 || status > 599) {
105583
+ request2.destroy();
105584
+ fail(transportError(`origin returned an unusable status line (${status})`, "UNSUPPORTED_STATUS"));
105585
+ return;
105586
+ }
105587
+ const responseHeaders = toResponseHeaders(message2);
105588
+ const statusText = message2.statusMessage ?? "";
105589
+ const bodiless = NULL_BODY_STATUSES.has(status) || method.toUpperCase() === "HEAD";
105590
+ if (bodiless) {
105591
+ message2.resume();
105592
+ clearTimers();
105593
+ detach();
105594
+ settled = true;
105595
+ resolve2(new Response(null, { status, statusText, headers: responseHeaders }));
105596
+ return;
105597
+ }
105598
+ const armBodyTimer = () => {
105599
+ if (!bodyTimeoutMs)
105600
+ return;
105601
+ clearTimeout(bodyTimer);
105602
+ bodyTimer = setTimeout(() => {
105603
+ teardownReason = transportError(`no response body progress for ${bodyTimeoutMs}ms`, TIMEOUT_CODE);
105604
+ request2.destroy(teardownReason);
105605
+ }, bodyTimeoutMs);
105606
+ };
105607
+ armBodyTimer();
105608
+ const decoded = decodeBody(message2);
105609
+ if (decoded !== message2) {
105610
+ responseHeaders.delete("content-encoding");
105611
+ responseHeaders.delete("content-length");
105612
+ }
105613
+ const stream = toWebStream(decoded, {
105614
+ progress: armBodyTimer,
105615
+ done: () => {
105616
+ clearTimers();
105617
+ detach();
105618
+ },
105619
+ // A deliberate teardown (body deadline, caller abort) reaches the
105620
+ // socket as a plain reset, so the reason we tore it down for wins over
105621
+ // whatever the socket reported.
105622
+ failure: (cause) => teardownReason ?? cause ?? transportError("socket hang up", "ECONNRESET")
105623
+ });
105624
+ settled = true;
105625
+ resolve2(new Response(stream, { status, statusText, headers: responseHeaders }));
105626
+ });
105627
+ if (payload)
105628
+ request2.write(payload);
105629
+ request2.end();
105630
+ });
105631
+ }
105246
105632
  var lib = {};
105247
105633
  var hasRequiredLib;
105248
105634
  function requireLib() {
@@ -106411,7 +106797,7 @@ function requireUtil$5() {
106411
106797
  hasRequiredUtil$5 = 1;
106412
106798
  const assert2 = require$$0$4;
106413
106799
  const { kDestroyed, kBodyUsed, kListeners, kBody } = requireSymbols();
106414
- const { IncomingMessage } = require$$2$1;
106800
+ const { IncomingMessage } = http;
106415
106801
  const stream = require$$0$5;
106416
106802
  const net2 = require$$1$1;
106417
106803
  const { stringify: stringify2 } = require$$5;
@@ -109738,8 +110124,8 @@ function requireRuntimeFeatures() {
109738
110124
  __proto__: null,
109739
110125
  "node:crypto": () => crypto$1,
109740
110126
  "node:sqlite": () => require$$1$2,
109741
- "node:worker_threads": () => require$$2$2,
109742
- "node:zlib": () => require$$3$1
110127
+ "node:worker_threads": () => require$$2$1,
110128
+ "node:zlib": () => zlib
109743
110129
  };
109744
110130
  function detectRuntimeFeatureByNodeModule(moduleName) {
109745
110131
  try {
@@ -109963,7 +110349,7 @@ function requireWebidl() {
109963
110349
  return "Object";
109964
110350
  }
109965
110351
  };
109966
- webidl.util.markAsUncloneable = runtimeFeatures2.has("markAsUncloneable") ? require$$2$2.markAsUncloneable : () => {
110352
+ webidl.util.markAsUncloneable = runtimeFeatures2.has("markAsUncloneable") ? require$$2$1.markAsUncloneable : () => {
109967
110353
  };
109968
110354
  webidl.util.ConvertToInt = function(V2, bitLength, signedness, flags) {
109969
110355
  let upperBound;
@@ -110446,7 +110832,7 @@ function requireUtil$4() {
110446
110832
  if (hasRequiredUtil$4) return util$4;
110447
110833
  hasRequiredUtil$4 = 1;
110448
110834
  const { Transform: Transform2 } = require$$0$5;
110449
- const zlib = require$$3$1;
110835
+ const zlib$1 = zlib;
110450
110836
  const { redirectStatusSet, referrerPolicyTokens, badPortsSet } = requireConstants$3();
110451
110837
  const { getGlobalOrigin } = requireGlobal$1();
110452
110838
  const { collectAnHTTPQuotedString, parseMIMEType } = requireDataUrl();
@@ -111054,7 +111440,7 @@ function requireUtil$4() {
111054
111440
  callback();
111055
111441
  return;
111056
111442
  }
111057
- this._inflateStream = (chunk[0] & 15) === 8 ? zlib.createInflate(__privateGet(this, _zlibOptions)) : zlib.createInflateRaw(__privateGet(this, _zlibOptions));
111443
+ this._inflateStream = (chunk[0] & 15) === 8 ? zlib$1.createInflate(__privateGet(this, _zlibOptions)) : zlib$1.createInflateRaw(__privateGet(this, _zlibOptions));
111058
111444
  this._inflateStream.on("data", this.push.bind(this));
111059
111445
  this._inflateStream.on("end", () => this.push(null));
111060
111446
  this._inflateStream.on("error", (err) => this.destroy(err));
@@ -114022,7 +114408,7 @@ function requireClient() {
114022
114408
  hasRequiredClient = 1;
114023
114409
  const assert2 = require$$0$4;
114024
114410
  const net2 = require$$1$1;
114025
- const http = require$$2$1;
114411
+ const http$1 = http;
114026
114412
  const util2 = requireUtil$5();
114027
114413
  const { ClientStats } = requireStats();
114028
114414
  const { channels } = requireDiagnostics();
@@ -114080,7 +114466,7 @@ function requireClient() {
114080
114466
  const connectH1 = requireClientH1();
114081
114467
  const connectH2 = requireClientH2();
114082
114468
  const kClosedResolve = Symbol("kClosedResolve");
114083
- const getDefaultNodeMaxHeaderSize = http && http.maxHeaderSize && Number.isInteger(http.maxHeaderSize) && http.maxHeaderSize > 0 ? () => http.maxHeaderSize : () => {
114469
+ const getDefaultNodeMaxHeaderSize = http$1 && http$1.maxHeaderSize && Number.isInteger(http$1.maxHeaderSize) && http$1.maxHeaderSize > 0 ? () => http$1.maxHeaderSize : () => {
114084
114470
  throw new InvalidArgumentError("http module not available or http.maxHeaderSize invalid");
114085
114471
  };
114086
114472
  const noop3 = () => {
@@ -118084,7 +118470,7 @@ function requireMockUtils() {
118084
118470
  kTotalDispatchCount
118085
118471
  } = requireMockSymbols();
118086
118472
  const { serializePathWithQuery } = requireUtil$5();
118087
- const { STATUS_CODES } = require$$2$1;
118473
+ const { STATUS_CODES } = http;
118088
118474
  const {
118089
118475
  types: {
118090
118476
  isPromise
@@ -119255,7 +119641,7 @@ function requireSnapshotRecorder() {
119255
119641
  hasRequiredSnapshotRecorder = 1;
119256
119642
  const { writeFile: writeFile2, readFile: readFile2, mkdir: mkdir2 } = fs$1;
119257
119643
  const { dirname: dirname2, resolve: resolve2 } = path$3;
119258
- const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require$$2$3;
119644
+ const { setTimeout: setTimeout2, clearTimeout: clearTimeout2 } = require$$2$2;
119259
119645
  const { InvalidArgumentError, UndiciError } = requireErrors();
119260
119646
  const { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = requireSnapshotUtils();
119261
119647
  function formatRequestKey(opts, headerFilters, matchOptions = {}) {
@@ -123150,7 +123536,7 @@ function requireDecompress() {
123150
123536
  var _decompressors, _skipStatusCodes, _skipErrorResponses, _DecompressHandler_instances, shouldSkipDecompression_fn, createDecompressionChain_fn, setupDecompressorEvents_fn, setupSingleDecompressor_fn, setupMultipleDecompressors_fn, cleanupDecompressors_fn;
123151
123537
  if (hasRequiredDecompress) return decompress$1;
123152
123538
  hasRequiredDecompress = 1;
123153
- const { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = require$$3$1;
123539
+ const { createInflate, createGunzip, createBrotliDecompress, createZstdDecompress } = zlib;
123154
123540
  const { pipeline } = require$$0$5;
123155
123541
  const DecoratorHandler = requireDecoratorHandler();
123156
123542
  const { runtimeFeatures: runtimeFeatures2 } = requireRuntimeFeatures();
@@ -126011,7 +126397,7 @@ function requireFetch() {
126011
126397
  } = requireResponse();
126012
126398
  const { HeadersList } = requireHeaders();
126013
126399
  const { Request: Request2, cloneRequest, getRequestDispatcher, getRequestState } = requireRequest();
126014
- const zlib = require$$3$1;
126400
+ const zlib$1 = zlib;
126015
126401
  const {
126016
126402
  makePolicyContainer,
126017
126403
  clonePolicyContainer,
@@ -126061,7 +126447,7 @@ function requireFetch() {
126061
126447
  const { dataURLProcessor, serializeAMimeType, minimizeSupportedMimeType } = requireDataUrl();
126062
126448
  const { getGlobalDispatcher } = requireGlobal();
126063
126449
  const { webidl } = requireWebidl();
126064
- const { STATUS_CODES } = require$$2$1;
126450
+ const { STATUS_CODES } = http;
126065
126451
  const { bytesMatch } = requireSubresourceIntegrity();
126066
126452
  const { createDeferredPromise } = requirePromise();
126067
126453
  const { isomorphicEncode } = requireInfra();
@@ -127005,28 +127391,28 @@ function requireFetch() {
127005
127391
  for (let i = codings.length - 1; i >= 0; --i) {
127006
127392
  const coding = codings[i].trim();
127007
127393
  if (coding === "x-gzip" || coding === "gzip") {
127008
- decoders.push(zlib.createGunzip({
127394
+ decoders.push(zlib$1.createGunzip({
127009
127395
  // Be less strict when decoding compressed responses, since sometimes
127010
127396
  // servers send slightly invalid responses that are still accepted
127011
127397
  // by common browsers.
127012
127398
  // Always using Z_SYNC_FLUSH is what cURL does.
127013
- flush: zlib.constants.Z_SYNC_FLUSH,
127014
- finishFlush: zlib.constants.Z_SYNC_FLUSH
127399
+ flush: zlib$1.constants.Z_SYNC_FLUSH,
127400
+ finishFlush: zlib$1.constants.Z_SYNC_FLUSH
127015
127401
  }));
127016
127402
  } else if (coding === "deflate") {
127017
127403
  decoders.push(createInflate({
127018
- flush: zlib.constants.Z_SYNC_FLUSH,
127019
- finishFlush: zlib.constants.Z_SYNC_FLUSH
127404
+ flush: zlib$1.constants.Z_SYNC_FLUSH,
127405
+ finishFlush: zlib$1.constants.Z_SYNC_FLUSH
127020
127406
  }));
127021
127407
  } else if (coding === "br") {
127022
- decoders.push(zlib.createBrotliDecompress({
127023
- flush: zlib.constants.BROTLI_OPERATION_FLUSH,
127024
- finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
127408
+ decoders.push(zlib$1.createBrotliDecompress({
127409
+ flush: zlib$1.constants.BROTLI_OPERATION_FLUSH,
127410
+ finishFlush: zlib$1.constants.BROTLI_OPERATION_FLUSH
127025
127411
  }));
127026
127412
  } else if (coding === "zstd" && hasZstd) {
127027
- decoders.push(zlib.createZstdDecompress({
127028
- flush: zlib.constants.ZSTD_e_continue,
127029
- finishFlush: zlib.constants.ZSTD_e_end
127413
+ decoders.push(zlib$1.createZstdDecompress({
127414
+ flush: zlib$1.constants.ZSTD_e_continue,
127415
+ finishFlush: zlib$1.constants.ZSTD_e_end
127030
127416
  }));
127031
127417
  } else {
127032
127418
  decoders.length = 0;
@@ -129105,7 +129491,7 @@ function requirePermessageDeflate() {
129105
129491
  var _inflate, _options2, _maxPayloadSize;
129106
129492
  if (hasRequiredPermessageDeflate) return permessageDeflate;
129107
129493
  hasRequiredPermessageDeflate = 1;
129108
- const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = require$$3$1;
129494
+ const { createInflateRaw, Z_DEFAULT_WINDOWBITS } = zlib;
129109
129495
  const { isValidClientWindowBits } = requireUtil$1();
129110
129496
  const { MessageSizeExceededError } = requireErrors();
129111
129497
  const tail = Buffer.from([0, 0, 255, 255]);
@@ -131402,7 +131788,12 @@ function isDetachedArrayBufferQueueError(error2) {
131402
131788
  return false;
131403
131789
  }
131404
131790
  function createQueue$2(config2) {
131405
- const httpAgent = new undiciExports.Agent(getQueueAgentOptions());
131791
+ const agentOptions = getQueueAgentOptions();
131792
+ const nodeHttpAgents = isNodeHttpEnabled() ? createNodeHttpAgents({
131793
+ maxSockets: agentOptions.connections,
131794
+ keepAliveMs: agentOptions.keepAliveTimeout
131795
+ }) : void 0;
131796
+ const httpAgent = nodeHttpAgents ? void 0 : new undiciExports.Agent(agentOptions);
131406
131797
  const transport = new TypedJsonTransport();
131407
131798
  const generateId2 = monotonicFactory();
131408
131799
  const semaphore = new libExports.Sema(WORKFLOW_LOCAL_QUEUE_CONCURRENCY);
@@ -131463,13 +131854,24 @@ function createQueue$2(config2) {
131463
131854
  response2 = await directHandler(req);
131464
131855
  } else {
131465
131856
  const baseUrl = await resolveBaseUrl$1(config2);
131466
- response2 = await fetch(createWorkflowUrl(baseUrl, { type: "flow" }), {
131857
+ const url2 = createWorkflowUrl(baseUrl, { type: "flow" });
131858
+ response2 = nodeHttpAgents ? await nodeHttpFetch(url2, {
131467
131859
  method: "POST",
131468
- duplex: "half",
131469
- dispatcher: httpAgent,
131470
- headers: headers2,
131471
- body: body2
131472
- });
131860
+ headers: new Headers(headers2),
131861
+ body: body2,
131862
+ agents: nodeHttpAgents,
131863
+ headersTimeoutMs: agentOptions.headersTimeout,
131864
+ bodyTimeoutMs: agentOptions.bodyTimeout
131865
+ }) : (
131866
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici v7 dispatcher types don't match @types/node's RequestInit
131867
+ await fetch(url2, {
131868
+ method: "POST",
131869
+ duplex: "half",
131870
+ dispatcher: httpAgent,
131871
+ headers: headers2,
131872
+ body: body2
131873
+ })
131874
+ );
131473
131875
  }
131474
131876
  delivery++;
131475
131877
  text2 = await response2.text();
@@ -131596,7 +131998,9 @@ function createQueue$2(config2) {
131596
131998
  if (closeSignal.aborted)
131597
131999
  return;
131598
132000
  closeController.abort();
131599
- await httpAgent.close();
132001
+ if (nodeHttpAgents)
132002
+ destroyNodeHttpAgents(nodeHttpAgents);
132003
+ await (httpAgent == null ? void 0 : httpAgent.close());
131600
132004
  }
131601
132005
  };
131602
132006
  }
@@ -135791,7 +136195,7 @@ function createWorld$2(args) {
135791
136195
  const basedir = mergedConfig.dataDir;
135792
136196
  const hooksDir = path$3.join(basedir, "hooks");
135793
136197
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
135794
- const { HookSchema: HookSchema2 } = await import("./index-DsnQrgwB.js");
136198
+ const { HookSchema: HookSchema2 } = await import("./index-CSsrecUx.js");
135795
136199
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
135796
136200
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
135797
136201
  if (hook == null ? void 0 : hook.token) {
@@ -135974,8 +136378,8 @@ function requireGetVercelOidcToken() {
135974
136378
  }
135975
136379
  try {
135976
136380
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
135977
- await import("./token-util-CighjZkT.js").then((n) => n.t),
135978
- await import("./token-sFDUVNm0.js").then((n) => n.t)
136381
+ await import("./token-util-BhmVdeCX.js").then((n) => n.t),
136382
+ await import("./token-COK7oHMh.js").then((n) => n.t)
135979
136383
  ]);
135980
136384
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
135981
136385
  await refreshToken(options);
@@ -136090,7 +136494,7 @@ function requireTokenIo() {
136090
136494
  tokenIo = __toCommonJS(token_io_exports);
136091
136495
  var import_path2 = __toESM(path__default);
136092
136496
  var import_fs2 = __toESM(fs__default);
136093
- var import_os2 = __toESM(require$$2$4);
136497
+ var import_os2 = __toESM(require$$2$3);
136094
136498
  var import_token_error = requireTokenError();
136095
136499
  function findRootDir() {
136096
136500
  try {
@@ -136242,7 +136646,7 @@ function requireOauth() {
136242
136646
  refreshTokenRequest: () => refreshTokenRequest
136243
136647
  });
136244
136648
  oauth = __toCommonJS(oauth_exports);
136245
- var import_os2 = require$$2$4;
136649
+ var import_os2 = require$$2$3;
136246
136650
  const VERCEL_ISSUER = "https://vercel.com";
136247
136651
  const VERCEL_CLI_CLIENT_ID = "cl_HYyOPBNtFMfHhaUn9L4QPfTZz6TP47bp";
136248
136652
  const userAgent = `@vercel/oidc node-${process.version} ${(0, import_os2.platform)()} (${(0, import_os2.arch)()}) ${(0, import_os2.hostname)()}`;
@@ -136541,10 +136945,13 @@ var distExports = requireDist();
136541
136945
  let _dispatcher;
136542
136946
  let _streamDispatcher;
136543
136947
  let _streamCloseDispatcher;
136948
+ let _nodeHttpAgents;
136544
136949
  const BASE_AGENT_OPTIONS = {
136545
136950
  connections: 8,
136546
136951
  keepAliveTimeout: 1e4
136547
136952
  };
136953
+ const NODE_HTTP_HEADERS_TIMEOUT_MS = 3e5;
136954
+ const NODE_HTTP_BODY_TIMEOUT_MS = 3e5;
136548
136955
  const H2_MAX_IN_FLIGHT_STREAMS = 100;
136549
136956
  const H2_STREAM_WINDOW_BYTES = 4 * 1024 * 1024;
136550
136957
  const H2_CONNECTION_WINDOW_BYTES = 16 * 1024 * 1024;
@@ -136704,17 +137111,36 @@ const eventsRecycler = createDispatcherRecycler(() => createEventsDispatcher(),
136704
137111
  function noteEventsTransportOutcome(dispatcher2, error2) {
136705
137112
  eventsRecycler.note(dispatcher2, error2);
136706
137113
  }
137114
+ function resolveDispatcher(config2, buildDefault) {
137115
+ if (config2 == null ? void 0 : config2.dispatcher)
137116
+ return config2.dispatcher;
137117
+ return isNodeHttpEnabled() ? void 0 : buildDefault();
137118
+ }
137119
+ function getNodeHttpAgents(config2) {
137120
+ if (config2 == null ? void 0 : config2.dispatcher)
137121
+ return void 0;
137122
+ if (!isNodeHttpEnabled())
137123
+ return void 0;
137124
+ _nodeHttpAgents ?? (_nodeHttpAgents = createNodeHttpAgents({
137125
+ maxSockets: BASE_AGENT_OPTIONS.connections,
137126
+ keepAliveMs: BASE_AGENT_OPTIONS.keepAliveTimeout
137127
+ }));
137128
+ return _nodeHttpAgents;
137129
+ }
136707
137130
  function getDispatcher(config2) {
137131
+ return resolveDispatcher(config2, getDefaultDispatcher);
137132
+ }
137133
+ function getQueueDispatcher(config2) {
136708
137134
  return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
136709
137135
  }
136710
137136
  function getEventsDispatcher(config2) {
136711
- return (config2 == null ? void 0 : config2.dispatcher) ?? eventsRecycler.get();
137137
+ return resolveDispatcher(config2, () => eventsRecycler.get());
136712
137138
  }
136713
137139
  function getStreamDispatcher(config2) {
136714
- return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamDispatcher();
137140
+ return resolveDispatcher(config2, getDefaultStreamDispatcher);
136715
137141
  }
136716
137142
  function getStreamCloseDispatcher(config2) {
136717
- return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamCloseDispatcher();
137143
+ return resolveDispatcher(config2, getDefaultStreamCloseDispatcher);
136718
137144
  }
136719
137145
  function makeRetryDispatcher(agentOptions, retryOptions) {
136720
137146
  return new undiciExports.RetryAgent(new undiciExports.Agent(agentOptions), retryOptions);
@@ -136863,6 +137289,7 @@ const WorkflowStreamName = SemanticConvention("workflow.stream.name");
136863
137289
  const WorkflowStreamOperation = SemanticConvention("workflow.stream.operation");
136864
137290
  const WorkflowStreamStartIndex = SemanticConvention("workflow.stream.start_index");
136865
137291
  const WorkflowEventsTransport = SemanticConvention("workflow.events.transport");
137292
+ const WorkflowHttpTransport = SemanticConvention("workflow.http.transport");
136866
137293
  const WorkflowEventType = SemanticConvention("workflow.event.type");
136867
137294
  const WorkflowClientVersion = SemanticConvention("workflow.client.version");
136868
137295
  const StepStsoMs = SemanticConvention("step.stso_ms");
@@ -137016,7 +137443,23 @@ async function instrumentedFetch(opts) {
137016
137443
  const start2 = Date.now();
137017
137444
  let response2;
137018
137445
  try {
137019
- response2 = await fetch(url2, {
137446
+ const nodeAgents = dispatcher2 ? void 0 : getNodeHttpAgents();
137447
+ span == null ? void 0 : span.setAttributes({
137448
+ ...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
137449
+ });
137450
+ response2 = nodeAgents ? await nodeHttpFetch(url2, {
137451
+ method,
137452
+ headers: headers2,
137453
+ body: body2,
137454
+ signal,
137455
+ agents: nodeAgents,
137456
+ // Match undici's per-phase defaults (which the undici agents
137457
+ // inherit implicitly): without these the node:http path arms no
137458
+ // stalled-socket deadline, and a `timeoutMs: null` caller would
137459
+ // have no deadline at all.
137460
+ headersTimeoutMs: NODE_HTTP_HEADERS_TIMEOUT_MS,
137461
+ bodyTimeoutMs: NODE_HTTP_BODY_TIMEOUT_MS
137462
+ }) : await fetch(url2, {
137020
137463
  method,
137021
137464
  headers: headers2,
137022
137465
  body: body2,
@@ -137059,7 +137502,7 @@ async function instrumentedFetch(opts) {
137059
137502
  return response2;
137060
137503
  });
137061
137504
  }
137062
- const version = "5.0.0-beta.38";
137505
+ const version = "5.0.0-beta.39";
137063
137506
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
137064
137507
  const MAX_BODY_PARSE_RETRIES = 2;
137065
137508
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -137075,7 +137518,8 @@ const TRANSIENT_TRANSPORT_ERROR_CODES = /* @__PURE__ */ new Set([
137075
137518
  "ECONNREFUSED",
137076
137519
  "ENOTFOUND",
137077
137520
  "EAI_AGAIN",
137078
- "EPIPE"
137521
+ "EPIPE",
137522
+ "ETIMEDOUT"
137079
137523
  ]);
137080
137524
  function getTransientTransportCode(error2) {
137081
137525
  let current = error2;
@@ -137176,7 +137620,7 @@ async function getHttpConfig(config2) {
137176
137620
  return { baseUrl, headers: headers2, usingProxy };
137177
137621
  }
137178
137622
  async function makeRequest({ endpoint, options = {}, config: config2 = {}, schema, data, onResponse, retryConnectTimeout = false }) {
137179
- const method = options.method || "GET";
137623
+ const method = (options.method || "GET").toUpperCase();
137180
137624
  const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
137181
137625
  const url2 = `${baseUrl}${endpoint}`;
137182
137626
  return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
@@ -137193,23 +137637,33 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
137193
137637
  headers2.set("Content-Type", "application/cbor");
137194
137638
  body2 = encode$1(data);
137195
137639
  }
137196
- const canRetryRead = IDEMPOTENT_METHODS.has(method.toUpperCase());
137640
+ const canRetryRead = IDEMPOTENT_METHODS.has(method);
137197
137641
  let parseResult;
137198
137642
  let responseDiagnostics = "";
137199
137643
  for (let attempt = 0; ; attempt++) {
137200
137644
  headers2.set("X-Request-Time", Date.now().toString());
137201
137645
  const timeoutSignal = AbortSignal.timeout(getRequestTimeoutMs());
137202
137646
  const signal = options.signal ? AbortSignal.any([options.signal, timeoutSignal]) : timeoutSignal;
137203
- const request2 = new Request(url2, {
137204
- ...options,
137205
- body: body2,
137206
- headers: headers2,
137207
- signal
137208
- });
137209
137647
  const fetchStart = Date.now();
137210
137648
  let response2;
137211
137649
  try {
137212
- response2 = await fetch(request2, {
137650
+ const nodeAgents = getNodeHttpAgents(config2);
137651
+ span == null ? void 0 : span.setAttributes({
137652
+ ...WorkflowHttpTransport(nodeAgents ? "node-http" : "undici")
137653
+ });
137654
+ response2 = nodeAgents ? await nodeHttpFetch(url2, {
137655
+ method,
137656
+ headers: headers2,
137657
+ body: body2,
137658
+ signal,
137659
+ agents: nodeAgents,
137660
+ // Match undici's per-phase defaults (which the undici agents
137661
+ // inherit implicitly): without these the node:http path arms
137662
+ // no stalled-socket deadline.
137663
+ headersTimeoutMs: NODE_HTTP_HEADERS_TIMEOUT_MS,
137664
+ bodyTimeoutMs: NODE_HTTP_BODY_TIMEOUT_MS
137665
+ }) : await fetch(new Request(url2, { ...options, body: body2, headers: headers2, signal }), {
137666
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici v7 dispatcher types don't match @types/node's RequestInit
137213
137667
  dispatcher: getDispatcher(config2)
137214
137668
  });
137215
137669
  } catch (error2) {
@@ -137226,10 +137680,10 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
137226
137680
  await new Promise((resolve2) => setTimeout(resolve2, BODY_PARSE_RETRY_BASE_MS));
137227
137681
  continue;
137228
137682
  }
137229
- const transportError = new WorkflowWorldError(`${method} ${endpoint} transport failure after ${elapsed}ms (${transportCode})`, { url: url2, code: "TRANSPORT", cause: error2 });
137683
+ const transportError2 = new WorkflowWorldError(`${method} ${endpoint} transport failure after ${elapsed}ms (${transportCode})`, { url: url2, code: "TRANSPORT", cause: error2 });
137230
137684
  span == null ? void 0 : span.setAttributes({ ...ErrorType("TRANSPORT") });
137231
- (_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, transportError);
137232
- throw transportError;
137685
+ (_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, transportError2);
137686
+ throw transportError2;
137233
137687
  }
137234
137688
  throw error2;
137235
137689
  }
@@ -137242,9 +137696,9 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
137242
137696
  if (!response2.ok) {
137243
137697
  const errorData = await parseResponseBody(response2).then((r2) => r2.data).catch(() => ({}));
137244
137698
  const errorCode = errorData.code ?? errorData.error;
137245
- logCurlRepro(request2.method, url2, headers2);
137699
+ logCurlRepro(method, url2, headers2);
137246
137700
  const retryAfter = parseRetryAfter(response2.headers.get("Retry-After"));
137247
- const defaultMessage = (errorData.message || `${request2.method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`) + responseDiagnostics;
137701
+ const defaultMessage = (errorData.message || `${method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`) + responseDiagnostics;
137248
137702
  const error2 = errorForResponse(response2.status, defaultMessage, {
137249
137703
  url: url2,
137250
137704
  code: errorCode,
@@ -137823,7 +138277,7 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
137823
138277
  };
137824
138278
  }
137825
138279
  async function getDeadline() {
137826
- const { getDeadline: getDeadline2 } = await import("./index-ByPjQpgH.js").then((n) => n.i);
138280
+ const { getDeadline: getDeadline2 } = await import("./index-Ck5CB_wQ.js").then((n) => n.i);
137827
138281
  return getDeadline2();
137828
138282
  }
137829
138283
  const WORKFLOW_SERVER_SERVICE = {
@@ -137905,6 +138359,7 @@ function instrumentObject(prefix, o) {
137905
138359
  const f2 = o[key];
137906
138360
  const methodName = String(key);
137907
138361
  handlers2[key] = async (...args) => {
138362
+ var _a3;
137908
138363
  let spanName = `${prefix}.${methodName}`;
137909
138364
  if (prefix === "world.events" && methodName === "create") {
137910
138365
  const eventType = extractEventType(args);
@@ -137912,13 +138367,36 @@ function instrumentObject(prefix, o) {
137912
138367
  spanName = `${prefix}.${methodName} ${eventType}`;
137913
138368
  }
137914
138369
  }
138370
+ let batchAttributes;
138371
+ if (prefix === "world.events" && methodName === "createBatch") {
138372
+ const events2 = args[1];
138373
+ if (Array.isArray(events2)) {
138374
+ const counts = /* @__PURE__ */ new Map();
138375
+ for (const item of events2) {
138376
+ const eventType = (_a3 = item == null ? void 0 : item.event) == null ? void 0 : _a3.eventType;
138377
+ if (typeof eventType === "string") {
138378
+ counts.set(eventType, (counts.get(eventType) ?? 0) + 1);
138379
+ }
138380
+ }
138381
+ batchAttributes = {
138382
+ "workflow.batch.size": events2.length,
138383
+ // Sorted by type, so the same batch composition always renders
138384
+ // the same string. Map iteration is first-seen order, which
138385
+ // depends on frame order — a pre-claimed fold leads with a
138386
+ // pair while a pure eager fold leads with its creates — and an
138387
+ // unstable string is not groupable as a telemetry dimension.
138388
+ "workflow.batch.shape": [...counts].sort(([a2], [b2]) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0).map(([type, count2]) => `${type}:${count2}`).join(",")
138389
+ };
138390
+ }
138391
+ }
137915
138392
  return trace(spanName, { kind: await getSpanKind("CLIENT") }, async (span) => {
137916
138393
  span == null ? void 0 : span.setAttributes({
137917
138394
  ...PeerService(WORKFLOW_SERVER_SERVICE.peerService),
137918
138395
  ...RpcSystem(WORKFLOW_SERVER_SERVICE.rpcSystem),
137919
138396
  ...RpcService(WORKFLOW_SERVER_SERVICE.rpcService),
137920
138397
  ...RpcMethod(spanName),
137921
- ...extractWorkflowAttributes(prefix, methodName, args)
138398
+ ...extractWorkflowAttributes(prefix, methodName, args),
138399
+ ...batchAttributes
137922
138400
  });
137923
138401
  const result = await f2(...args);
137924
138402
  const resultRunId = getRunIdFromResult(result);
@@ -140370,14 +140848,6 @@ var MessageAlreadyProcessedError = class extends Error {
140370
140848
  this.name = "MessageAlreadyProcessedError";
140371
140849
  }
140372
140850
  };
140373
- var DuplicateMessageError = class extends Error {
140374
- constructor(message2, idempotencyKey) {
140375
- super(message2);
140376
- __publicField(this, "idempotencyKey");
140377
- this.name = "DuplicateMessageError";
140378
- this.idempotencyKey = idempotencyKey;
140379
- }
140380
- };
140381
140851
  var ConsumerDiscoveryError = class extends Error {
140382
140852
  constructor(message2, deploymentId) {
140383
140853
  super(message2);
@@ -141330,6 +141800,14 @@ function filePathToUrlPath(filePath) {
141330
141800
  }
141331
141801
  return urlPath;
141332
141802
  }
141803
+ function importAtRuntime(absolutePath) {
141804
+ return import(
141805
+ /* webpackIgnore: true */
141806
+ /* turbopackIgnore: true */
141807
+ /* @vite-ignore */
141808
+ absolutePath
141809
+ );
141810
+ }
141333
141811
  async function ensureHandlersLoaded(topicName, options = {}) {
141334
141812
  const diagnostics2 = {
141335
141813
  triedPorts: collectPrimePorts(),
@@ -141356,7 +141834,7 @@ async function ensureHandlersLoaded(topicName, options = {}) {
141356
141834
  if (!alreadyRegistered) {
141357
141835
  const absolutePath = path$2.resolve(process.cwd(), route.filePath);
141358
141836
  try {
141359
- await import(absolutePath);
141837
+ await importAtRuntime(absolutePath);
141360
141838
  } catch (error2) {
141361
141839
  diagnostics2.importFailures.push({
141362
141840
  filePath: route.filePath,
@@ -141891,7 +142369,9 @@ function throwCommonHttpError(status, statusText, errorText, operation, badReque
141891
142369
  errorText || `Server error: ${status} ${statusText}`
141892
142370
  );
141893
142371
  }
141894
- throw new Error(`Failed to ${operation}: ${status} ${statusText}`);
142372
+ throw new Error(
142373
+ errorText || `Failed to ${operation}: ${status} ${statusText}`
142374
+ );
141895
142375
  }
141896
142376
  function parseQueueHeaders(headers2) {
141897
142377
  const messageId = headers2.get("Vqs-Message-Id");
@@ -142062,7 +142542,7 @@ Cause: ${cause}`
142062
142542
  }
142063
142543
  console.debug("[VQS Debug] Request:", JSON.stringify(logData, null, 2));
142064
142544
  }
142065
- init2.headers.set("User-Agent", `@vercel/queue/${"0.4.0"}`);
142545
+ init2.headers.set("User-Agent", `@vercel/queue/${"0.5.0"}`);
142066
142546
  init2.headers.set("Vqs-Client-Ts", (/* @__PURE__ */ new Date()).toISOString());
142067
142547
  const fetchInit = this.dispatcher ? { ...init2, dispatcher: this.dispatcher } : init2;
142068
142548
  const response2 = await fetch(url2, fetchInit);
@@ -142133,17 +142613,12 @@ Cause: ${cause}`
142133
142613
  const response2 = await this.fetch(this.buildUrl(queueName), {
142134
142614
  method: "POST",
142135
142615
  body: body2,
142136
- headers: headers2
142616
+ headers: headers2,
142617
+ ...body2 instanceof ReadableStream && { duplex: "half" }
142137
142618
  });
142138
142619
  if (!response2.ok) {
142139
142620
  const errorText = await response2.text();
142140
- if (response2.status === 409) {
142141
- throw new DuplicateMessageError(
142142
- errorText || "Duplicate idempotency key detected",
142143
- idempotencyKey
142144
- );
142145
- }
142146
- if (response2.status === 502) {
142621
+ if (response2.status === 502 && response2.headers.get("Vqs-Error-Code") === "consumer_discovery_failed") {
142147
142622
  throw new ConsumerDiscoveryError(
142148
142623
  errorText || "Consumer discovery failed",
142149
142624
  deploymentId
@@ -142750,7 +143225,7 @@ const wsEventsChannelForInvocation = (runId, config2) => {
142750
143225
  open() {
142751
143226
  if (!runId || !isWsEventsTransportEnabled())
142752
143227
  return;
142753
- claim = import("./ws-transport-DaZsgQ2B.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
143228
+ claim = import("./ws-transport-BCfcEhAO.js").then(({ openWsChannel }) => openWsChannel(runId, config2)).catch(() => void 0);
142754
143229
  },
142755
143230
  /**
142756
143231
  * Awaited, unlike the open: work scheduled after the handler returns is not
@@ -142836,7 +143311,7 @@ function createQueue$1(config2) {
142836
143311
  const jsonTransport = new JsonTransport2();
142837
143312
  const dualTransport = new DualTransport();
142838
143313
  const clientOptions = {
142839
- dispatcher: getDispatcher(config2),
143314
+ dispatcher: getQueueDispatcher(config2),
142840
143315
  transport: dualTransport,
142841
143316
  ...usingProxy && {
142842
143317
  // final path will be /queues-proxy/api/v3/topic/...
@@ -142881,28 +143356,19 @@ function createQueue$1(config2) {
142881
143356
  deploymentId: opts == null ? void 0 : opts.deploymentId
142882
143357
  };
142883
143358
  const sanitizedQueueName = getPhysicalQueueName(queueName, payload).replace(/[^A-Za-z0-9-_]/g, "-");
142884
- try {
142885
- const { messageId } = await client2.send(sanitizedQueueName, wrapper, {
142886
- idempotencyKey: opts == null ? void 0 : opts.idempotencyKey,
142887
- delaySeconds: opts == null ? void 0 : opts.delaySeconds,
142888
- headers: {
142889
- ...getHeadersFromPayload(payload),
142890
- ...opts == null ? void 0 : opts.headers
142891
- }
142892
- });
142893
- return {
142894
- // messageId may be null when VQS fails over to a different region —
142895
- // the event is ingested but the responding region cannot return an ID.
142896
- messageId: messageId ? MessageId.parse(messageId) : null
142897
- };
142898
- } catch (error2) {
142899
- if (error2 instanceof DuplicateMessageError) {
142900
- return {
142901
- messageId: MessageId.parse(`msg_duplicate_${error2.idempotencyKey ?? (opts == null ? void 0 : opts.idempotencyKey) ?? "unknown"}`)
142902
- };
143359
+ const { messageId } = await client2.send(sanitizedQueueName, wrapper, {
143360
+ idempotencyKey: opts == null ? void 0 : opts.idempotencyKey,
143361
+ delaySeconds: opts == null ? void 0 : opts.delaySeconds,
143362
+ headers: {
143363
+ ...getHeadersFromPayload(payload),
143364
+ ...opts == null ? void 0 : opts.headers
142903
143365
  }
142904
- throw error2;
142905
- }
143366
+ });
143367
+ return {
143368
+ // messageId may be null when the queue fails over to a different region:
143369
+ // the event is ingested but the responding region cannot return an ID.
143370
+ messageId: messageId ? MessageId.parse(messageId) : null
143371
+ };
142906
143372
  };
142907
143373
  const createQueueHandler = (_prefix, handler) => {
142908
143374
  const client2 = new QueueClient(clientOptions);
@@ -143171,6 +143637,9 @@ function createThrottleWaiter(eventType) {
143171
143637
  }
143172
143638
  function isEligibleForTransientRetry(eventType, options) {
143173
143639
  var _a3;
143640
+ if ((options == null ? void 0 : options.batchIdempotent) !== void 0) {
143641
+ return options.batchIdempotent;
143642
+ }
143174
143643
  return eventType === "hook_received" && (options == null ? void 0 : options.idempotentHookResume) === true || (((_a3 = EVENT_RETRY_ELIGIBILITY[eventType]) == null ? void 0 : _a3.retryable) ?? false);
143175
143644
  }
143176
143645
  async function withEventPostRetry(fn2, eventType, options) {
@@ -143223,16 +143692,24 @@ async function* decodeFrames(source) {
143223
143692
  const chunks = Symbol.asyncIterator in source ? source[Symbol.asyncIterator]() : readerToIterator(source.getReader());
143224
143693
  let buffer2 = new Uint8Array(0);
143225
143694
  const refill = async (needed) => {
143226
- while (buffer2.byteLength < needed) {
143227
- const { done, value } = await chunks.next();
143228
- if (done)
143695
+ if (buffer2.byteLength >= needed)
143696
+ return true;
143697
+ const parts = [buffer2];
143698
+ let byteLength = buffer2.byteLength;
143699
+ while (byteLength < needed) {
143700
+ const chunk = await chunks.next();
143701
+ if (chunk.done)
143229
143702
  return false;
143230
- if (!value || value.byteLength === 0)
143703
+ if (chunk.value.byteLength === 0)
143231
143704
  continue;
143232
- const next2 = new Uint8Array(buffer2.byteLength + value.byteLength);
143233
- next2.set(buffer2, 0);
143234
- next2.set(value, buffer2.byteLength);
143235
- buffer2 = next2;
143705
+ parts.push(chunk.value);
143706
+ byteLength += chunk.value.byteLength;
143707
+ }
143708
+ buffer2 = new Uint8Array(byteLength);
143709
+ let offset2 = 0;
143710
+ for (const part of parts) {
143711
+ buffer2.set(part, offset2);
143712
+ offset2 += part.byteLength;
143236
143713
  }
143237
143714
  return true;
143238
143715
  };
@@ -143322,8 +143799,8 @@ function hasSerializedDataFormatPrefix(value) {
143322
143799
  return format2 !== null && SERIALIZED_DATA_FORMAT_PREFIXES.has(format2);
143323
143800
  }
143324
143801
  function decompress(format2, payload) {
143325
- const zlib = getNodeZlib();
143326
- const decompress2 = format2 === ZSTD_FORMAT_PREFIX ? zlib == null ? void 0 : zlib.zstdDecompressSync : zlib == null ? void 0 : zlib.gunzipSync;
143802
+ const zlib2 = getNodeZlib();
143803
+ const decompress2 = format2 === ZSTD_FORMAT_PREFIX ? zlib2 == null ? void 0 : zlib2.zstdDecompressSync : zlib2 == null ? void 0 : zlib2.gunzipSync;
143327
143804
  if (!decompress2) {
143328
143805
  throw new WorkflowWorldError(`Received ${format2}-compressed workflow data, but this Node.js runtime does not support ${format2} decompression. Use a compatible Node.js runtime or request unresolved data.`);
143329
143806
  }
@@ -143784,6 +144261,56 @@ async function createWorkflowRunStartedEventV4(input, config2) {
143784
144261
  }
143785
144262
  return { events: events2, ...page, maxEvents: maxEvents.data };
143786
144263
  }
144264
+ const BatchItemFailureSchema = object$1({
144265
+ status: number$3().int(),
144266
+ error: string$3(),
144267
+ message: string$3()
144268
+ });
144269
+ async function createWorkflowRunEventsBatchV4(input, config2) {
144270
+ assert$1(input.events.length > 0, "v4 createEventBatch: empty batch");
144271
+ const { baseUrl, headers: baseHeaders } = await getHttpConfig(config2);
144272
+ const headers2 = new Headers(baseHeaders);
144273
+ headers2.set("Content-Type", "application/octet-stream");
144274
+ const frames = input.events.map((event) => encodeFrame(buildPostFrameMeta(event), event.payload ?? new Uint8Array(0)));
144275
+ let total = 0;
144276
+ for (const frame2 of frames)
144277
+ total += frame2.byteLength;
144278
+ const body2 = new Uint8Array(total);
144279
+ let offset2 = 0;
144280
+ for (const frame2 of frames) {
144281
+ body2.set(frame2, offset2);
144282
+ offset2 += frame2.byteLength;
144283
+ }
144284
+ const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(input.runId)}/events/batch`;
144285
+ const response2 = await fetchV4(url2, { method: "POST", headers: headers2, body: body2 }, config2, "createEventBatch", {
144286
+ ...WorkflowEventsTransport("http"),
144287
+ "workflow.batch.bytes": body2.byteLength
144288
+ });
144289
+ const bodyBytes = new Uint8Array(await response2.arrayBuffer());
144290
+ const decoded = bodyBytes.byteLength > 0 ? decode$1(bodyBytes) : {};
144291
+ if (!Array.isArray(decoded.results) || decoded.results.length !== input.events.length) {
144292
+ throw new WorkflowWorldError(`v4 createEventBatch: response \`results\` length (${Array.isArray(decoded.results) ? decoded.results.length : "non-array"}) != ${input.events.length} submitted frames`, { code: "SCHEMA_VALIDATION" });
144293
+ }
144294
+ const results = decoded.results.map((raw2, index2) => {
144295
+ const failure = BatchItemFailureSchema.safeParse(raw2);
144296
+ if (failure.success && failure.data.status !== 200) {
144297
+ return failure.data;
144298
+ }
144299
+ if ((raw2 == null ? void 0 : raw2.status) !== 200) {
144300
+ throw new WorkflowWorldError(`v4 createEventBatch: result at index ${index2} is neither a success (status 200) nor a well-formed failure`, { code: "SCHEMA_VALIDATION" });
144301
+ }
144302
+ const eventType = input.events[index2].eventType;
144303
+ const parsed = CreateEventV4BodySchemas[eventType].safeParse(raw2);
144304
+ if (!parsed.success) {
144305
+ throw new WorkflowWorldError(`v4 createEventBatch: invalid result body at index ${index2} (${eventType})`, { code: "SCHEMA_VALIDATION", cause: parsed.error });
144306
+ }
144307
+ if (parsed.data.event.eventType !== eventType) {
144308
+ throw new WorkflowWorldError(`v4 createEventBatch: result at index ${index2} carries a ${parsed.data.event.eventType} event, expected ${eventType}`, { code: "SCHEMA_VALIDATION" });
144309
+ }
144310
+ return { status: 200, ...parsed.data };
144311
+ });
144312
+ return { results };
144313
+ }
143787
144314
  function replyMetaToHeaderRecord(meta2) {
143788
144315
  const out = {};
143789
144316
  if (typeof meta2.eventId === "string")
@@ -143802,7 +144329,7 @@ function wsReplyStatus(reply, endpoint) {
143802
144329
  return status;
143803
144330
  }
143804
144331
  async function postEventFrameOverWs(input, config2) {
143805
- const { resolveWsTransport } = await import("./ws-transport-DaZsgQ2B.js");
144332
+ const { resolveWsTransport } = await import("./ws-transport-BCfcEhAO.js");
143806
144333
  const { runId } = input;
143807
144334
  const resolved = resolveWsTransport(runId, config2);
143808
144335
  if (!resolved)
@@ -144273,6 +144800,59 @@ async function getWorkflowRunEvents(params, config2) {
144273
144800
  hasMore: result.hasMore
144274
144801
  };
144275
144802
  }
144803
+ async function createWorkflowRunEventBatch(runId, events2, params, config2) {
144804
+ if (events2.length === 0) {
144805
+ throw new WorkflowWorldError("world-vercel: createBatch requires at least one event", { status: 400 });
144806
+ }
144807
+ if (events2.some(({ event }) => event.eventType === "hook_received")) {
144808
+ throw new WorkflowWorldError("world-vercel: hook_received cannot be batched (it has no entity condition, so a batch retry would append the delivery twice); send it through the single-event path", { status: 400 });
144809
+ }
144810
+ const inputs = events2.map(({ event, occurredAt, computeInstanceId }) => {
144811
+ const { payload, meta: meta2 } = splitEventDataForV4(event);
144812
+ return {
144813
+ runId,
144814
+ eventType: event.eventType,
144815
+ specVersion: event.specVersion ?? 2,
144816
+ ...event.correlationId ? { correlationId: event.correlationId } : {},
144817
+ // Under slot identity this is the source of the durable createdAt, so
144818
+ // the caller's logical time is what every replay observes.
144819
+ occurredAt: occurredAt ?? /* @__PURE__ */ new Date(),
144820
+ // Per-event compute attribution (pre-claimed inline starts) — rides the
144821
+ // frame meta exactly like the single POST's CreateEventParams field.
144822
+ ...computeInstanceId !== void 0 ? { computeInstanceId } : {},
144823
+ // Batch responses carry entities for bookkeeping, not payload reads —
144824
+ // default to lazy refs unless the caller explicitly asks for resolved
144825
+ // data (the same `resolveData` mapping the read paths use).
144826
+ remoteRefBehavior: (params == null ? void 0 : params.resolveData) === "all" ? "resolve" : "lazy",
144827
+ // Per-write request attribution, exactly like the single POST's
144828
+ // `params.requestId` → `vercelId` threading — stamped per frame so
144829
+ // batched usage facts carry the same attribution.
144830
+ ...(params == null ? void 0 : params.requestId) ? { vercelId: params.requestId } : {},
144831
+ payload,
144832
+ ...meta2
144833
+ };
144834
+ });
144835
+ const retryConvergent = events2.every(({ event }) => event.eventType !== "step_started" && event.eventType !== "step_retrying");
144836
+ const wire = await withEventPostRetry(() => createWorkflowRunEventsBatchV4({ runId, events: inputs }, config2), events2[0].event.eventType, { batchIdempotent: retryConvergent });
144837
+ return {
144838
+ results: wire.results.map((item) => {
144839
+ if (item.error !== void 0) {
144840
+ return {
144841
+ status: item.status,
144842
+ error: item.error,
144843
+ message: item.message
144844
+ };
144845
+ }
144846
+ return {
144847
+ status: 200,
144848
+ event: item.event,
144849
+ ...item.run ? { run: item.run } : {},
144850
+ ...item.step ? { step: item.step } : {},
144851
+ ...item.wait ? { wait: item.wait } : {}
144852
+ };
144853
+ })
144854
+ };
144855
+ }
144276
144856
  async function createWorkflowRunEvent(id2, data, params, config2) {
144277
144857
  var _a3, _b2;
144278
144858
  try {
@@ -144533,6 +145113,7 @@ function createStorage(config2) {
144533
145113
  },
144534
145114
  events: {
144535
145115
  create: (runId, data, params) => createWorkflowRunEvent(runId, data, params, config2),
145116
+ createBatch: (runId, events2, params) => createWorkflowRunEventBatch(runId, events2, params, config2),
144536
145117
  get: (runId, eventId, params) => getEvent(runId, eventId, params, config2),
144537
145118
  list: (params) => getWorkflowRunEvents(params, config2),
144538
145119
  listByCorrelationId: (params) => getWorkflowRunEvents(params, config2)
@@ -144946,7 +145527,7 @@ const getWorld = async () => {
144946
145527
  const GetWorldFnKey = Symbol.for("@workflow/world//getWorldFn");
144947
145528
  globalThis[GetWorldFnKey] ?? (globalThis[GetWorldFnKey] = getWorld);
144948
145529
  function waitUntil(promise2) {
144949
- void import("./index-ByPjQpgH.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
145530
+ void import("./index-Ck5CB_wQ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
144950
145531
  waitUntil2(promise2);
144951
145532
  });
144952
145533
  }
@@ -148366,6 +148947,10 @@ async function wakeUpRun$2(world, runId, options) {
148366
148947
  }
148367
148948
  }
148368
148949
  const RETURN_VALUE_POLL_INTERVAL_MS = 1e3;
148950
+ const PAYLOAD_TERMINAL_RUN_STATUSES = /* @__PURE__ */ new Set([
148951
+ "completed",
148952
+ "failed"
148953
+ ]);
148369
148954
  function getReturnValuePollIntervalMs() {
148370
148955
  return envNumber("WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS", RETURN_VALUE_POLL_INTERVAL_MS, { integer: true, min: 1 });
148371
148956
  }
@@ -148448,7 +149033,7 @@ const _Run = class _Run {
148448
149033
  */
148449
149034
  get status() {
148450
149035
  "use step";
148451
- return __privateGet(this, _Run_instances, lazyWorldPromise_get).then((world) => world.runs.get(this.runId).then((run2) => run2.status));
149036
+ return __privateGet(this, _Run_instances, lazyWorldPromise_get).then((world) => world.runs.get(this.runId, { resolveData: "none" }).then((run2) => run2.status));
148452
149037
  }
148453
149038
  /**
148454
149039
  * The return value of the workflow run.
@@ -148541,13 +149126,13 @@ _resilientStart = new WeakMap();
148541
149126
  * to be resolved once.
148542
149127
  * @internal
148543
149128
  */
148544
- getEncryptionKey_fn = function() {
149129
+ getEncryptionKey_fn = function(run2) {
148545
149130
  if (!__privateGet(this, _encryptionKeyPromise)) {
148546
149131
  __privateSet(this, _encryptionKeyPromise, (async () => {
148547
149132
  var _a3;
148548
149133
  const world = await __privateGet(this, _Run_instances, lazyWorldPromise_get);
148549
- const run2 = await world.runs.get(this.runId);
148550
- const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, run2));
149134
+ const runData = run2 ?? await world.runs.get(this.runId);
149135
+ const rawKey = await ((_a3 = world.getEncryptionKeyForRun) == null ? void 0 : _a3.call(world, runData));
148551
149136
  return rawKey ? await deriveRunPayloadKeys(rawKey) : void 0;
148552
149137
  })());
148553
149138
  }
@@ -148562,6 +149147,28 @@ getEncryptionKey_fn = function() {
148562
149147
  getEncryptionKeyLazily_fn = function() {
148563
149148
  return () => __privateMethod(this, _Run_instances, getEncryptionKey_fn).call(this);
148564
149149
  };
149150
+ resolveTerminalReturnValue_fn = async function(run2) {
149151
+ if (run2.status === "completed") {
149152
+ const encryptionKey = await __privateMethod(this, _Run_instances, getEncryptionKey_fn).call(this, run2);
149153
+ return await hydrateWorkflowReturnValue(run2.output, this.runId, encryptionKey);
149154
+ }
149155
+ if (run2.status === "cancelled") {
149156
+ throw new WorkflowRunCancelledError(this.runId);
149157
+ }
149158
+ if (run2.status === "failed") {
149159
+ const encryptionKey = await __privateMethod(this, _Run_instances, getEncryptionKey_fn).call(this, run2);
149160
+ let hydratedError;
149161
+ try {
149162
+ hydratedError = await hydrateRunError(run2.error, this.runId, encryptionKey);
149163
+ } catch {
149164
+ hydratedError = new Error("Failed to hydrate workflow run error");
149165
+ }
149166
+ throw new WorkflowRunFailedError(this.runId, hydratedError, {
149167
+ errorCode: run2.errorCode
149168
+ });
149169
+ }
149170
+ throw new WorkflowRunNotCompletedError(this.runId, run2.status);
149171
+ };
148565
149172
  pollReturnValue_fn = async function() {
148566
149173
  const world = await __privateGet(this, _Run_instances, lazyWorldPromise_get);
148567
149174
  let notFoundRetries = 0;
@@ -148569,27 +149176,19 @@ pollReturnValue_fn = async function() {
148569
149176
  const NOT_FOUND_DELAYS = [1e3, 3e3, 6e3];
148570
149177
  while (true) {
148571
149178
  try {
148572
- const run2 = await world.runs.get(this.runId);
148573
- if (run2.status === "completed") {
148574
- const encryptionKey = await __privateMethod(this, _Run_instances, getEncryptionKey_fn).call(this);
148575
- return await hydrateWorkflowReturnValue(run2.output, this.runId, encryptionKey);
148576
- }
148577
- if (run2.status === "cancelled") {
149179
+ const runMetadata = await world.runs.get(this.runId, {
149180
+ resolveData: "none"
149181
+ });
149182
+ if (runMetadata.status === "cancelled") {
148578
149183
  throw new WorkflowRunCancelledError(this.runId);
148579
149184
  }
148580
- if (run2.status === "failed") {
148581
- const encryptionKey = await __privateMethod(this, _Run_instances, getEncryptionKey_fn).call(this);
148582
- let hydratedError;
148583
- try {
148584
- hydratedError = await hydrateRunError(run2.error, this.runId, encryptionKey);
148585
- } catch {
148586
- hydratedError = new Error("Failed to hydrate workflow run error");
148587
- }
148588
- throw new WorkflowRunFailedError(this.runId, hydratedError, {
148589
- errorCode: run2.errorCode
149185
+ if (PAYLOAD_TERMINAL_RUN_STATUSES.has(runMetadata.status)) {
149186
+ const run2 = await world.runs.get(this.runId, {
149187
+ resolveData: "all"
148590
149188
  });
149189
+ return await __privateMethod(this, _Run_instances, resolveTerminalReturnValue_fn).call(this, run2);
148591
149190
  }
148592
- throw new WorkflowRunNotCompletedError(this.runId, run2.status);
149191
+ throw new WorkflowRunNotCompletedError(this.runId, runMetadata.status);
148593
149192
  } catch (error2) {
148594
149193
  if (WorkflowRunNotCompletedError.is(error2)) {
148595
149194
  await new Promise((resolve2) => setTimeout(resolve2, getReturnValuePollIntervalMs()));
@@ -171817,7 +172416,7 @@ const route4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProper
171817
172416
  __proto__: null,
171818
172417
  loader
171819
172418
  }, Symbol.toStringTag, { value: "Module" }));
171820
- const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-BfhMCbkz.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/root-Bl5xphvU.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-C6CuMqQu.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-DKz7lp2q.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-cf88886b.js", "version": "cf88886b", "sri": void 0 };
172419
+ const serverManifest = { "entry": { "module": "/assets/entry.client-LwI3HNYl.js", "imports": ["/assets/index-PFjW8YjQ.js"], "css": [] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": true, "module": "/assets/root-BfhMCbkz.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/root-Bl5xphvU.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/home": { "id": "routes/home", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/home-C6CuMqQu.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/loader-circle-BOxaTUjK.js"], "css": ["/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/run-detail": { "id": "routes/run-detail", "parentId": "root", "path": "run/:runId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": false, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": true, "hasErrorBoundary": false, "module": "/assets/run-detail-BG_1K2Hq.js", "imports": ["/assets/index-PFjW8YjQ.js", "/assets/workflow-graph-viewer-CxrWityD.js", "/assets/mermaid-3ZIDBTTL-gEw-Ch1C.js", "/assets/arrow-up-right-D39pnGsD.js"], "css": ["/assets/run-detail-CWoGxu_0.css", "/assets/workflow-graph-viewer-DnlNuQQH.css", "/assets/mermaid-3ZIDBTTL-D8CjRQta.css"], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.rpc": { "id": "routes/api.rpc", "parentId": "root", "path": "api/rpc", "index": void 0, "caseSensitive": void 0, "hasAction": true, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.rpc-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 }, "routes/api.stream.$streamId": { "id": "routes/api.stream.$streamId", "parentId": "root", "path": "api/stream/:streamId", "index": void 0, "caseSensitive": void 0, "hasAction": false, "hasLoader": true, "hasClientAction": false, "hasClientLoader": false, "hasClientMiddleware": false, "hasDefaultExport": false, "hasErrorBoundary": false, "module": "/assets/api.stream._streamId-l0sNRNKZ.js", "imports": [], "css": [], "clientActionModule": void 0, "clientLoaderModule": void 0, "clientMiddlewareModule": void 0, "hydrateFallbackModule": void 0 } }, "url": "/assets/manifest-157e28f1.js", "version": "157e28f1", "sri": void 0 };
171821
172420
  const assetsBuildDirectory = "build/client";
171822
172421
  const basename = "/";
171823
172422
  const future = { "unstable_optimizeDeps": false, "unstable_subResourceIntegrity": false, "unstable_trailingSlashAwareDataRequests": false, "unstable_previewServerPrerendering": false, "v8_middleware": false, "v8_splitRouteModules": false, "v8_viteEnvironmentApi": false };
@@ -172026,7 +172625,7 @@ function createFetchHandler(basename2 = "/") {
172026
172625
  return (request2) => handler(request2, loadContext);
172027
172626
  }
172028
172627
  export {
172029
- STEP_EVENT_TYPES as $,
172628
+ SPEC_VERSION_SUPPORTS_COMPRESSION as $,
172030
172629
  ANALYTICS_EVENTS_GET_MANY_LIMIT as A,
172031
172630
  BULK_CANCEL_MAX_RUN_IDS as B,
172032
172631
  CHILD_ENTITY_CREATION_EVENT_TYPES as C,
@@ -172037,102 +172636,106 @@ export {
172037
172636
  HookSchema as H,
172038
172637
  HookCreatedEventSchema as I,
172039
172638
  HookResumeCapabilitiesSchema as J,
172040
- PaginatedResponseSchema as K,
172639
+ NODE_HTTP_DEFAULT as K,
172041
172640
  LegacySerializedDataSchemaV1 as L,
172042
172641
  MessageId as M,
172043
172642
  Nt as N,
172044
- QueuePrefix as O,
172643
+ NODE_HTTP_ENV_VAR as O,
172045
172644
  PARENT_RUN_ID_ATTRIBUTE as P,
172046
- QueuePayloadSchema as Q,
172047
- RESERVED_ATTRIBUTE_KEY_PREFIX as R,
172048
- ROOT_RUN_ID_ATTRIBUTE as S,
172049
- RunInputSchema as T,
172050
- SPEC_VERSION_CURRENT as U,
172051
- SPEC_VERSION_LEGACY as V,
172052
- SPEC_VERSION_MAX_SUPPORTED as W,
172053
- SPEC_VERSION_SUPPORTS_ATTRIBUTES as X,
172054
- SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as Y,
172055
- SPEC_VERSION_SUPPORTS_COMPRESSION as Z,
172056
- SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as _,
172645
+ PaginatedResponseSchema as Q,
172646
+ QueuePayloadSchema as R,
172647
+ QueuePrefix as S,
172648
+ RESERVED_ATTRIBUTE_KEY_PREFIX as T,
172649
+ ROOT_RUN_ID_ATTRIBUTE as U,
172650
+ RunInputSchema as V,
172651
+ SPEC_VERSION_CURRENT as W,
172652
+ SPEC_VERSION_LEGACY as X,
172653
+ SPEC_VERSION_MAX_SUPPORTED as Y,
172654
+ SPEC_VERSION_SUPPORTS_ATTRIBUTES as Z,
172655
+ SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT as _,
172057
172656
  ATTRIBUTE_KEY_MAX_LENGTH as a,
172058
- injectTraceContextIntoHeaders as a$,
172059
- SerializedDataSchema as a0,
172060
- StepSchema as a1,
172061
- StepStatusSchema as a2,
172062
- StructuredErrorSchema as a3,
172063
- TERMINAL_RUN_EVENT_TYPES as a4,
172064
- TERMINAL_STEP_EVENT_TYPES as a5,
172065
- TERMINAL_STEP_STATUSES as a6,
172066
- TERMINAL_WORKFLOW_RUN_STATUSES as a7,
172067
- TerminalRunEventTypeSchema as a8,
172068
- TerminalStepStatusSchema as a9,
172069
- isTerminalStepEventType as aA,
172070
- isTerminalStepStatus as aB,
172071
- isTerminalWorkflowRunStatus as aC,
172072
- isWaitEventType as aD,
172073
- parseQueueName as aE,
172074
- reenqueueActiveRuns as aF,
172075
- requiresNewerWorld as aG,
172076
- resolveQueueNamespace as aH,
172077
- slotToEventId as aI,
172078
- stripEventDataRefs as aJ,
172079
- ulidToDate as aK,
172080
- validateAttributeChanges as aL,
172081
- validateAttributeKey as aM,
172082
- validateAttributeValue as aN,
172083
- validateUlidTimestamp as aO,
172084
- workflowRunIdSchema as aP,
172085
- reactExports as aQ,
172086
- R as aR,
172087
- Ks as aS,
172088
- jsxRuntimeExports as aT,
172089
- Qe as aU,
172090
- registerZstdDecoder as aV,
172091
- isWsEventsTransportEnabled as aW,
172092
- getHttpUrl as aX,
172093
- getHttpConfig as aY,
172094
- headersToRecord as aZ,
172095
- getRequestTimeoutMs as a_,
172096
- TerminalWorkflowRunStatusSchema as aa,
172097
- ValidQueueName as ab,
172098
- WAIT_EVENT_TYPES as ac,
172099
- WaitSchema as ad,
172100
- WaitStatusSchema as ae,
172101
- WorkflowInvokePayloadSchema as af,
172102
- WorkflowRunBaseSchema as ag,
172103
- WorkflowRunSchema as ah,
172104
- WorkflowRunStatusSchema as ai,
172105
- applyAttributeChanges as aj,
172106
- entityEventClass as ak,
172107
- envNumber as al,
172108
- eventIdToSlot as am,
172109
- getEventDataPayloadField as an,
172110
- getEventDataRefFields as ao,
172111
- getMaxEventsPerRun as ap,
172112
- getQueueTopicPrefix as aq,
172113
- isChildEntityCreationEvent as ar,
172114
- isChildEntityCreationEventType as as,
172115
- isHookEventRequiringExistence as at,
172116
- isHookLifecycleEventType as au,
172117
- isLegacySpecVersion as av,
172118
- isSlotBody as aw,
172119
- isSlotEventId as ax,
172120
- isStepEventType as ay,
172121
- isTerminalRunEventType as az,
172657
+ getHttpUrl as a$,
172658
+ SPEC_VERSION_SUPPORTS_SLOT_IDENTITY as a0,
172659
+ STEP_EVENT_TYPES as a1,
172660
+ SerializedDataSchema as a2,
172661
+ StepSchema as a3,
172662
+ StepStatusSchema as a4,
172663
+ StructuredErrorSchema as a5,
172664
+ TERMINAL_RUN_EVENT_TYPES as a6,
172665
+ TERMINAL_STEP_EVENT_TYPES as a7,
172666
+ TERMINAL_STEP_STATUSES as a8,
172667
+ TERMINAL_WORKFLOW_RUN_STATUSES as a9,
172668
+ isSlotBody as aA,
172669
+ isSlotEventId as aB,
172670
+ isStepEventType as aC,
172671
+ isTerminalRunEventType as aD,
172672
+ isTerminalStepEventType as aE,
172673
+ isTerminalStepStatus as aF,
172674
+ isTerminalWorkflowRunStatus as aG,
172675
+ isWaitEventType as aH,
172676
+ parseQueueName as aI,
172677
+ reenqueueActiveRuns as aJ,
172678
+ requiresNewerWorld as aK,
172679
+ resolveQueueNamespace as aL,
172680
+ slotToEventId as aM,
172681
+ stripEventDataRefs as aN,
172682
+ ulidToDate as aO,
172683
+ validateAttributeChanges as aP,
172684
+ validateAttributeKey as aQ,
172685
+ validateAttributeValue as aR,
172686
+ validateUlidTimestamp as aS,
172687
+ workflowRunIdSchema as aT,
172688
+ reactExports as aU,
172689
+ R as aV,
172690
+ Ks as aW,
172691
+ jsxRuntimeExports as aX,
172692
+ Qe as aY,
172693
+ registerZstdDecoder as aZ,
172694
+ isWsEventsTransportEnabled as a_,
172695
+ TerminalRunEventTypeSchema as aa,
172696
+ TerminalStepStatusSchema as ab,
172697
+ TerminalWorkflowRunStatusSchema as ac,
172698
+ ValidQueueName as ad,
172699
+ WAIT_EVENT_TYPES as ae,
172700
+ WaitSchema as af,
172701
+ WaitStatusSchema as ag,
172702
+ WorkflowInvokePayloadSchema as ah,
172703
+ WorkflowRunBaseSchema as ai,
172704
+ WorkflowRunSchema as aj,
172705
+ WorkflowRunStatusSchema as ak,
172706
+ applyAttributeChanges as al,
172707
+ entityEventClass as am,
172708
+ envFlag as an,
172709
+ envNumber as ao,
172710
+ eventIdToSlot as ap,
172711
+ getEventDataPayloadField as aq,
172712
+ getEventDataRefFields as ar,
172713
+ getMaxEventsPerRun as as,
172714
+ getQueueTopicPrefix as at,
172715
+ isChildEntityCreationEvent as au,
172716
+ isChildEntityCreationEventType as av,
172717
+ isHookEventRequiringExistence as aw,
172718
+ isHookLifecycleEventType as ax,
172719
+ isLegacySpecVersion as ay,
172720
+ isNodeHttpEnabled as az,
172122
172721
  ATTRIBUTE_MAX_PER_RUN as b,
172123
- withHttpClientSpan as b0,
172124
- ErrorType as b1,
172125
- WorkflowWsReconnectAttempt as b2,
172126
- NetworkProtocolName as b3,
172127
- WorkflowEventsTransport as b4,
172128
- distExports as b5,
172129
- decodeFrames as b6,
172130
- getDefaultExportFromCjs as b7,
172131
- requireTokenUtil as b8,
172132
- requireTokenError as b9,
172133
- getAugmentedNamespace as ba,
172134
- app as bb,
172135
- createFetchHandler as bc,
172722
+ getHttpConfig as b0,
172723
+ headersToRecord as b1,
172724
+ getRequestTimeoutMs as b2,
172725
+ injectTraceContextIntoHeaders as b3,
172726
+ withHttpClientSpan as b4,
172727
+ ErrorType as b5,
172728
+ WorkflowWsReconnectAttempt as b6,
172729
+ NetworkProtocolName as b7,
172730
+ WorkflowEventsTransport as b8,
172731
+ distExports as b9,
172732
+ decodeFrames as ba,
172733
+ getDefaultExportFromCjs as bb,
172734
+ requireTokenUtil as bc,
172735
+ requireTokenError as bd,
172736
+ getAugmentedNamespace as be,
172737
+ app as bf,
172738
+ createFetchHandler as bg,
172136
172739
  ATTRIBUTE_VALUE_MAX_BYTES as c,
172137
172740
  AnalyticsAttributeKeySchema as d,
172138
172741
  AnalyticsEventSchema as e,