@workflow/web 4.1.15 → 4.1.16

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.
@@ -14,7 +14,11 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
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
16
  var _a2, _b, _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, _reader;
17
- import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-C0o0w-Mo.js";
17
+ import { createRequire as __wkfCreateRequire } from "node:module";
18
+ if (typeof globalThis.require === "undefined") {
19
+ globalThis.require = __wkfCreateRequire(import.meta.url);
20
+ }
21
+ import { a as requireReact, S as ServerRouter, c as createReadableStreamFromReadable, r as reactExports, g as getDefaultExportFromCjs, R as React, b as ReactExports, w as withComponentProps, d as withErrorBoundaryProps, M as Meta, L as Links, e as ScrollRestoration, f as Scripts, O as Outlet, u as useNavigate, h as useSearchParams, i as Link$1, j as useRouteError, k as isRouteErrorResponse, l as useLocation, m as useParams } from "./app-GbUkc_Xp.js";
18
22
  import require$$0$5, { PassThrough } from "node:stream";
19
23
  import require$$0 from "util";
20
24
  import require$$1 from "crypto";
@@ -81828,7 +81832,7 @@ var tn = f("block", "before:content-[counter(line)]", "before:inline-block", "be
81828
81832
  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 });
81829
81833
  var Se = reactExports.createContext({ code: "" }), de = () => reactExports.useContext(Se);
81830
81834
  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 }) });
81831
- var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-DyZmWYQX.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81835
+ var cn$1 = /\n+$/, dn = reactExports.lazy(() => import("./highlighted-body-B3W2YXNL-A5X3ZwtB.js").then((e) => ({ default: e.HighlightedCodeBlockBody }))), rt = ({ code: e, language: t, className: o, children: n, isIncomplete: s2 = false, ...r2 }) => {
81832
81836
  let i = reactExports.useMemo(() => e.replace(cn$1, ""), [e]), c = reactExports.useMemo(() => ({ bg: "transparent", fg: "inherit", tokens: i.split(`
81833
81837
  `).map((a2) => [{ content: a2, color: "inherit", bgColor: "transparent", htmlStyle: {}, offset: 0 }]) }), [i]);
81834
81838
  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 }) })] }) });
@@ -82150,7 +82154,7 @@ var Dt = ({ children: e, className: t, onDownload: o, onError: n }) => {
82150
82154
  }, []), 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] });
82151
82155
  };
82152
82156
  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 }) })] });
82153
- var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-Cf251uS3.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82157
+ var Jn = reactExports.lazy(() => import("./mermaid-3ZIDBTTL-CJ4kkLUP.js").then((e) => ({ default: e.Mermaid }))), Kn = /language-([^\s]+)/;
82154
82158
  function ke(e, t) {
82155
82159
  if (!(e != null && e.position || t != null && t.position)) return true;
82156
82160
  if (!(e != null && e.position && (t != null && t.position))) return false;
@@ -91897,7 +91901,7 @@ async function withTraceContext(traceCarrier, fn2) {
91897
91901
  }
91898
91902
  const OtelApi = once$1(async () => {
91899
91903
  try {
91900
- return await import("./index-meg9qk8y.js");
91904
+ return await import("./index-hBO56emR.js");
91901
91905
  } catch {
91902
91906
  runtimeLogger.info("OpenTelemetry not available, tracing will be disabled");
91903
91907
  return null;
@@ -92042,7 +92046,7 @@ createLogger("build", {
92042
92046
  debugNamespace: "workflow:build"
92043
92047
  });
92044
92048
  const MAX_QUEUE_DELIVERIES = 48;
92045
- const version$1 = "4.7.0";
92049
+ const version$1 = "4.8.0";
92046
92050
  const execFileAsync = promisify(execFile);
92047
92051
  function parsePort$1(value, radix = 10) {
92048
92052
  const port = parseInt(value, radix);
@@ -92497,7 +92501,7 @@ async function readFirstByte(filePath) {
92497
92501
  }
92498
92502
  async function deleteJSON(filePath) {
92499
92503
  try {
92500
- await promises.unlink(filePath);
92504
+ await withWindowsRetry(() => promises.unlink(filePath));
92501
92505
  } catch (error2) {
92502
92506
  if (error2.code !== "ENOENT")
92503
92507
  throw error2;
@@ -92802,7 +92806,7 @@ async function initDataDir(dataDir) {
92802
92806
  let otelApiPromise$1 = null;
92803
92807
  async function getOtelApi$1() {
92804
92808
  if (!otelApiPromise$1) {
92805
- otelApiPromise$1 = import("./index-meg9qk8y.js").catch(() => null);
92809
+ otelApiPromise$1 = import("./index-hBO56emR.js").catch(() => null);
92806
92810
  }
92807
92811
  return otelApiPromise$1;
92808
92812
  }
@@ -100042,8 +100046,8 @@ function requireClientH1() {
100042
100046
  return this.createError(ret, EMPTY_BUF);
100043
100047
  }
100044
100048
  createError(ret, data) {
100045
- const { llhttp, contentLength, bytesRead } = this;
100046
- if (contentLength && bytesRead !== parseInt(contentLength, 10)) {
100049
+ const { llhttp, contentLength: contentLength2, bytesRead } = this;
100050
+ if (contentLength2 && bytesRead !== parseInt(contentLength2, 10)) {
100047
100051
  return new ResponseContentLengthMismatchError();
100048
100052
  }
100049
100053
  const ptr = llhttp.llhttp_get_error_reason(this.ptr);
@@ -100296,7 +100300,7 @@ function requireClientH1() {
100296
100300
  * @returns {number}
100297
100301
  */
100298
100302
  onMessageComplete() {
100299
- const { client: client2, socket, statusCode, upgrade, headers: headers2, contentLength, bytesRead, shouldKeepAlive } = this;
100303
+ const { client: client2, socket, statusCode, upgrade, headers: headers2, contentLength: contentLength2, bytesRead, shouldKeepAlive } = this;
100300
100304
  if (socket.destroyed && (!statusCode || shouldKeepAlive)) {
100301
100305
  return -1;
100302
100306
  }
@@ -100318,7 +100322,7 @@ function requireClientH1() {
100318
100322
  if (statusCode < 200) {
100319
100323
  return 0;
100320
100324
  }
100321
- if (request2.method !== "HEAD" && contentLength && bytesRead !== parseInt(contentLength, 10)) {
100325
+ if (request2.method !== "HEAD" && contentLength2 && bytesRead !== parseInt(contentLength2, 10)) {
100322
100326
  util2.destroy(socket, new ResponseContentLengthMismatchError());
100323
100327
  return -1;
100324
100328
  }
@@ -100573,7 +100577,7 @@ function requireClientH1() {
100573
100577
  }
100574
100578
  function writeH1(client2, request2) {
100575
100579
  const { method, path: path2, host, upgrade, blocking, reset } = request2;
100576
- let { body: body2, headers: headers2, contentLength } = request2;
100580
+ let { body: body2, headers: headers2, contentLength: contentLength2 } = request2;
100577
100581
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
100578
100582
  if (util2.isFormDataLike(body2)) {
100579
100583
  if (!extractBody) {
@@ -100584,7 +100588,7 @@ function requireClientH1() {
100584
100588
  headers2.push("content-type", contentType);
100585
100589
  }
100586
100590
  body2 = bodyStream.stream;
100587
- contentLength = bodyStream.length;
100591
+ contentLength2 = bodyStream.length;
100588
100592
  } else if (util2.isBlobLike(body2) && request2.contentType == null && body2.type) {
100589
100593
  headers2.push("content-type", body2.type);
100590
100594
  }
@@ -100592,14 +100596,14 @@ function requireClientH1() {
100592
100596
  body2.read(0);
100593
100597
  }
100594
100598
  const bodyLength = util2.bodyLength(body2);
100595
- contentLength = bodyLength ?? contentLength;
100596
- if (contentLength === null) {
100597
- contentLength = request2.contentLength;
100599
+ contentLength2 = bodyLength ?? contentLength2;
100600
+ if (contentLength2 === null) {
100601
+ contentLength2 = request2.contentLength;
100598
100602
  }
100599
- if (contentLength === 0 && !expectsPayload) {
100600
- contentLength = null;
100603
+ if (contentLength2 === 0 && !expectsPayload) {
100604
+ contentLength2 = null;
100601
100605
  }
100602
- if (shouldSendContentLength(method) && contentLength > 0 && request2.contentLength !== null && request2.contentLength !== contentLength) {
100606
+ if (shouldSendContentLength(method) && contentLength2 > 0 && request2.contentLength !== null && request2.contentLength !== contentLength2) {
100603
100607
  if (client2[kStrictContentLength]) {
100604
100608
  util2.errorRequest(client2, request2, new RequestContentLengthMismatchError());
100605
100609
  return false;
@@ -100678,28 +100682,28 @@ upgrade: ${upgrade}\r
100678
100682
  channels.sendHeaders.publish({ request: request2, headers: header, socket });
100679
100683
  }
100680
100684
  if (!body2 || bodyLength === 0) {
100681
- writeBuffer2(abort, null, client2, request2, socket, contentLength, header, expectsPayload);
100685
+ writeBuffer2(abort, null, client2, request2, socket, contentLength2, header, expectsPayload);
100682
100686
  } else if (util2.isBuffer(body2)) {
100683
- writeBuffer2(abort, body2, client2, request2, socket, contentLength, header, expectsPayload);
100687
+ writeBuffer2(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
100684
100688
  } else if (util2.isBlobLike(body2)) {
100685
100689
  if (typeof body2.stream === "function") {
100686
- writeIterable(abort, body2.stream(), client2, request2, socket, contentLength, header, expectsPayload);
100690
+ writeIterable(abort, body2.stream(), client2, request2, socket, contentLength2, header, expectsPayload);
100687
100691
  } else {
100688
- writeBlob(abort, body2, client2, request2, socket, contentLength, header, expectsPayload);
100692
+ writeBlob(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
100689
100693
  }
100690
100694
  } else if (util2.isStream(body2)) {
100691
- writeStream(abort, body2, client2, request2, socket, contentLength, header, expectsPayload);
100695
+ writeStream(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
100692
100696
  } else if (util2.isIterable(body2)) {
100693
- writeIterable(abort, body2, client2, request2, socket, contentLength, header, expectsPayload);
100697
+ writeIterable(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload);
100694
100698
  } else {
100695
100699
  assert2(false);
100696
100700
  }
100697
100701
  return true;
100698
100702
  }
100699
- function writeStream(abort, body2, client2, request2, socket, contentLength, header, expectsPayload) {
100700
- assert2(contentLength !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
100703
+ function writeStream(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
100704
+ assert2(contentLength2 !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
100701
100705
  let finished = false;
100702
- const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header });
100706
+ const writer = new AsyncWriter({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header });
100703
100707
  const onData = function(chunk) {
100704
100708
  if (finished) {
100705
100709
  return;
@@ -100765,22 +100769,22 @@ upgrade: ${upgrade}\r
100765
100769
  setImmediate(onClose);
100766
100770
  }
100767
100771
  }
100768
- function writeBuffer2(abort, body2, client2, request2, socket, contentLength, header, expectsPayload) {
100772
+ function writeBuffer2(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
100769
100773
  try {
100770
100774
  if (!body2) {
100771
- if (contentLength === 0) {
100775
+ if (contentLength2 === 0) {
100772
100776
  socket.write(`${header}content-length: 0\r
100773
100777
  \r
100774
100778
  `, "latin1");
100775
100779
  } else {
100776
- assert2(contentLength === null, "no body must not have content length");
100780
+ assert2(contentLength2 === null, "no body must not have content length");
100777
100781
  socket.write(`${header}\r
100778
100782
  `, "latin1");
100779
100783
  }
100780
100784
  } else if (util2.isBuffer(body2)) {
100781
- assert2(contentLength === body2.byteLength, "buffer body must have content length");
100785
+ assert2(contentLength2 === body2.byteLength, "buffer body must have content length");
100782
100786
  socket.cork();
100783
- socket.write(`${header}content-length: ${contentLength}\r
100787
+ socket.write(`${header}content-length: ${contentLength2}\r
100784
100788
  \r
100785
100789
  `, "latin1");
100786
100790
  socket.write(body2);
@@ -100796,15 +100800,15 @@ upgrade: ${upgrade}\r
100796
100800
  abort(err);
100797
100801
  }
100798
100802
  }
100799
- async function writeBlob(abort, body2, client2, request2, socket, contentLength, header, expectsPayload) {
100800
- assert2(contentLength === body2.size, "blob body must have content length");
100803
+ async function writeBlob(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
100804
+ assert2(contentLength2 === body2.size, "blob body must have content length");
100801
100805
  try {
100802
- if (contentLength != null && contentLength !== body2.size) {
100806
+ if (contentLength2 != null && contentLength2 !== body2.size) {
100803
100807
  throw new RequestContentLengthMismatchError();
100804
100808
  }
100805
100809
  const buffer2 = Buffer.from(await body2.arrayBuffer());
100806
100810
  socket.cork();
100807
- socket.write(`${header}content-length: ${contentLength}\r
100811
+ socket.write(`${header}content-length: ${contentLength2}\r
100808
100812
  \r
100809
100813
  `, "latin1");
100810
100814
  socket.write(buffer2);
@@ -100819,8 +100823,8 @@ upgrade: ${upgrade}\r
100819
100823
  abort(err);
100820
100824
  }
100821
100825
  }
100822
- async function writeIterable(abort, body2, client2, request2, socket, contentLength, header, expectsPayload) {
100823
- assert2(contentLength !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
100826
+ async function writeIterable(abort, body2, client2, request2, socket, contentLength2, header, expectsPayload) {
100827
+ assert2(contentLength2 !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
100824
100828
  let callback = null;
100825
100829
  function onDrain() {
100826
100830
  if (callback) {
@@ -100838,7 +100842,7 @@ upgrade: ${upgrade}\r
100838
100842
  }
100839
100843
  });
100840
100844
  socket.on("close", onDrain).on("drain", onDrain);
100841
- const writer = new AsyncWriter({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header });
100845
+ const writer = new AsyncWriter({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header });
100842
100846
  try {
100843
100847
  for await (const chunk of body2) {
100844
100848
  if (socket[kError]) {
@@ -100867,10 +100871,10 @@ upgrade: ${upgrade}\r
100867
100871
  * @param {boolean} arg.expectsPayload
100868
100872
  * @param {string} arg.header
100869
100873
  */
100870
- constructor({ abort, socket, request: request2, contentLength, client: client2, expectsPayload, header }) {
100874
+ constructor({ abort, socket, request: request2, contentLength: contentLength2, client: client2, expectsPayload, header }) {
100871
100875
  this.socket = socket;
100872
100876
  this.request = request2;
100873
- this.contentLength = contentLength;
100877
+ this.contentLength = contentLength2;
100874
100878
  this.client = client2;
100875
100879
  this.bytesWritten = 0;
100876
100880
  this.expectsPayload = expectsPayload;
@@ -100883,7 +100887,7 @@ upgrade: ${upgrade}\r
100883
100887
  * @returns
100884
100888
  */
100885
100889
  write(chunk) {
100886
- const { socket, request: request2, contentLength, client: client2, bytesWritten, expectsPayload, header } = this;
100890
+ const { socket, request: request2, contentLength: contentLength2, client: client2, bytesWritten, expectsPayload, header } = this;
100887
100891
  if (socket[kError]) {
100888
100892
  throw socket[kError];
100889
100893
  }
@@ -100894,7 +100898,7 @@ upgrade: ${upgrade}\r
100894
100898
  if (!len) {
100895
100899
  return true;
100896
100900
  }
100897
- if (contentLength !== null && bytesWritten + len > contentLength) {
100901
+ if (contentLength2 !== null && bytesWritten + len > contentLength2) {
100898
100902
  if (client2[kStrictContentLength]) {
100899
100903
  throw new RequestContentLengthMismatchError();
100900
100904
  }
@@ -100905,16 +100909,16 @@ upgrade: ${upgrade}\r
100905
100909
  if (!expectsPayload && request2.reset !== false) {
100906
100910
  socket[kReset] = true;
100907
100911
  }
100908
- if (contentLength === null) {
100912
+ if (contentLength2 === null) {
100909
100913
  socket.write(`${header}transfer-encoding: chunked\r
100910
100914
  `, "latin1");
100911
100915
  } else {
100912
- socket.write(`${header}content-length: ${contentLength}\r
100916
+ socket.write(`${header}content-length: ${contentLength2}\r
100913
100917
  \r
100914
100918
  `, "latin1");
100915
100919
  }
100916
100920
  }
100917
- if (contentLength === null) {
100921
+ if (contentLength2 === null) {
100918
100922
  socket.write(`\r
100919
100923
  ${len.toString(16)}\r
100920
100924
  `, "latin1");
@@ -100936,7 +100940,7 @@ ${len.toString(16)}\r
100936
100940
  * @returns {void}
100937
100941
  */
100938
100942
  end() {
100939
- const { socket, contentLength, client: client2, bytesWritten, expectsPayload, header, request: request2 } = this;
100943
+ const { socket, contentLength: contentLength2, client: client2, bytesWritten, expectsPayload, header, request: request2 } = this;
100940
100944
  request2.onRequestSent();
100941
100945
  socket[kWriting] = false;
100942
100946
  if (socket[kError]) {
@@ -100954,10 +100958,10 @@ ${len.toString(16)}\r
100954
100958
  socket.write(`${header}\r
100955
100959
  `, "latin1");
100956
100960
  }
100957
- } else if (contentLength === null) {
100961
+ } else if (contentLength2 === null) {
100958
100962
  socket.write("\r\n0\r\n\r\n", "latin1");
100959
100963
  }
100960
- if (contentLength !== null && bytesWritten !== contentLength) {
100964
+ if (contentLength2 !== null && bytesWritten !== contentLength2) {
100961
100965
  if (client2[kStrictContentLength]) {
100962
100966
  throw new RequestContentLengthMismatchError();
100963
100967
  } else {
@@ -101410,30 +101414,30 @@ function requireClientH2() {
101410
101414
  if (body2 && typeof body2.read === "function") {
101411
101415
  body2.read(0);
101412
101416
  }
101413
- let contentLength = util2.bodyLength(body2);
101417
+ let contentLength2 = util2.bodyLength(body2);
101414
101418
  if (util2.isFormDataLike(body2)) {
101415
101419
  extractBody ?? (extractBody = requireBody().extractBody);
101416
101420
  const [bodyStream, contentType] = extractBody(body2);
101417
101421
  headers2["content-type"] = contentType;
101418
101422
  body2 = bodyStream.stream;
101419
- contentLength = bodyStream.length;
101423
+ contentLength2 = bodyStream.length;
101420
101424
  }
101421
- if (contentLength == null) {
101422
- contentLength = request2.contentLength;
101425
+ if (contentLength2 == null) {
101426
+ contentLength2 = request2.contentLength;
101423
101427
  }
101424
101428
  if (!expectsPayload) {
101425
- contentLength = null;
101429
+ contentLength2 = null;
101426
101430
  }
101427
- if (shouldSendContentLength(method) && contentLength > 0 && request2.contentLength != null && request2.contentLength !== contentLength) {
101431
+ if (shouldSendContentLength(method) && contentLength2 > 0 && request2.contentLength != null && request2.contentLength !== contentLength2) {
101428
101432
  if (client2[kStrictContentLength]) {
101429
101433
  util2.errorRequest(client2, request2, new RequestContentLengthMismatchError());
101430
101434
  return false;
101431
101435
  }
101432
101436
  process.emitWarning(new RequestContentLengthMismatchError());
101433
101437
  }
101434
- if (contentLength != null) {
101435
- assert2(body2 || contentLength === 0, "no body must not have content length");
101436
- headers2[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength}`;
101438
+ if (contentLength2 != null) {
101439
+ assert2(body2 || contentLength2 === 0, "no body must not have content length");
101440
+ headers2[HTTP2_HEADER_CONTENT_LENGTH] = `${contentLength2}`;
101437
101441
  }
101438
101442
  session.ref();
101439
101443
  if (channels.sendHeaders.hasSubscribers) {
@@ -101532,7 +101536,7 @@ function requireClientH2() {
101532
101536
  });
101533
101537
  return true;
101534
101538
  function writeBodyH2() {
101535
- if (!body2 || contentLength === 0) {
101539
+ if (!body2 || contentLength2 === 0) {
101536
101540
  writeBuffer2(
101537
101541
  abort,
101538
101542
  stream,
@@ -101540,7 +101544,7 @@ function requireClientH2() {
101540
101544
  client2,
101541
101545
  request2,
101542
101546
  client2[kSocket],
101543
- contentLength,
101547
+ contentLength2,
101544
101548
  expectsPayload
101545
101549
  );
101546
101550
  } else if (util2.isBuffer(body2)) {
@@ -101551,7 +101555,7 @@ function requireClientH2() {
101551
101555
  client2,
101552
101556
  request2,
101553
101557
  client2[kSocket],
101554
- contentLength,
101558
+ contentLength2,
101555
101559
  expectsPayload
101556
101560
  );
101557
101561
  } else if (util2.isBlobLike(body2)) {
@@ -101563,7 +101567,7 @@ function requireClientH2() {
101563
101567
  client2,
101564
101568
  request2,
101565
101569
  client2[kSocket],
101566
- contentLength,
101570
+ contentLength2,
101567
101571
  expectsPayload
101568
101572
  );
101569
101573
  } else {
@@ -101574,7 +101578,7 @@ function requireClientH2() {
101574
101578
  client2,
101575
101579
  request2,
101576
101580
  client2[kSocket],
101577
- contentLength,
101581
+ contentLength2,
101578
101582
  expectsPayload
101579
101583
  );
101580
101584
  }
@@ -101587,7 +101591,7 @@ function requireClientH2() {
101587
101591
  body2,
101588
101592
  client2,
101589
101593
  request2,
101590
- contentLength
101594
+ contentLength2
101591
101595
  );
101592
101596
  } else if (util2.isIterable(body2)) {
101593
101597
  writeIterable(
@@ -101597,7 +101601,7 @@ function requireClientH2() {
101597
101601
  client2,
101598
101602
  request2,
101599
101603
  client2[kSocket],
101600
- contentLength,
101604
+ contentLength2,
101601
101605
  expectsPayload
101602
101606
  );
101603
101607
  } else {
@@ -101605,10 +101609,10 @@ function requireClientH2() {
101605
101609
  }
101606
101610
  }
101607
101611
  }
101608
- function writeBuffer2(abort, h2stream, body2, client2, request2, socket, contentLength, expectsPayload) {
101612
+ function writeBuffer2(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
101609
101613
  try {
101610
101614
  if (body2 != null && util2.isBuffer(body2)) {
101611
- assert2(contentLength === body2.byteLength, "buffer body must have content length");
101615
+ assert2(contentLength2 === body2.byteLength, "buffer body must have content length");
101612
101616
  h2stream.cork();
101613
101617
  h2stream.write(body2);
101614
101618
  h2stream.uncork();
@@ -101624,8 +101628,8 @@ function requireClientH2() {
101624
101628
  abort(error2);
101625
101629
  }
101626
101630
  }
101627
- function writeStream(abort, socket, expectsPayload, h2stream, body2, client2, request2, contentLength) {
101628
- assert2(contentLength !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
101631
+ function writeStream(abort, socket, expectsPayload, h2stream, body2, client2, request2, contentLength2) {
101632
+ assert2(contentLength2 !== 0 || client2[kRunning] === 0, "stream body cannot be pipelined");
101629
101633
  const pipe2 = pipeline(
101630
101634
  body2,
101631
101635
  h2stream,
@@ -101648,10 +101652,10 @@ function requireClientH2() {
101648
101652
  request2.onBodySent(chunk);
101649
101653
  }
101650
101654
  }
101651
- async function writeBlob(abort, h2stream, body2, client2, request2, socket, contentLength, expectsPayload) {
101652
- assert2(contentLength === body2.size, "blob body must have content length");
101655
+ async function writeBlob(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
101656
+ assert2(contentLength2 === body2.size, "blob body must have content length");
101653
101657
  try {
101654
- if (contentLength != null && contentLength !== body2.size) {
101658
+ if (contentLength2 != null && contentLength2 !== body2.size) {
101655
101659
  throw new RequestContentLengthMismatchError();
101656
101660
  }
101657
101661
  const buffer2 = Buffer.from(await body2.arrayBuffer());
@@ -101669,8 +101673,8 @@ function requireClientH2() {
101669
101673
  abort(err);
101670
101674
  }
101671
101675
  }
101672
- async function writeIterable(abort, h2stream, body2, client2, request2, socket, contentLength, expectsPayload) {
101673
- assert2(contentLength !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
101676
+ async function writeIterable(abort, h2stream, body2, client2, request2, socket, contentLength2, expectsPayload) {
101677
+ assert2(contentLength2 !== 0 || client2[kRunning] === 0, "iterator body cannot be pipelined");
101674
101678
  let callback = null;
101675
101679
  function onDrain() {
101676
101680
  if (callback) {
@@ -104310,8 +104314,8 @@ function requireRetryHandler() {
104310
104314
  this.end = end;
104311
104315
  }
104312
104316
  if (this.end == null) {
104313
- const contentLength = headers2["content-length"];
104314
- this.end = contentLength != null ? Number(contentLength) - 1 : null;
104317
+ const contentLength2 = headers2["content-length"];
104318
+ this.end = contentLength2 != null ? Number(contentLength2) - 1 : null;
104315
104319
  }
104316
104320
  assert2(Number.isFinite(this.start));
104317
104321
  assert2(
@@ -104527,7 +104531,7 @@ function requireReadable() {
104527
104531
  resume,
104528
104532
  abort,
104529
104533
  contentType = "",
104530
- contentLength,
104534
+ contentLength: contentLength2,
104531
104535
  highWaterMark = 64 * 1024
104532
104536
  // Same as nodejs fs streams.
104533
104537
  }) {
@@ -104543,7 +104547,7 @@ function requireReadable() {
104543
104547
  this[kBody] = null;
104544
104548
  this[kUsed] = false;
104545
104549
  this[kContentType] = contentType;
104546
- this[kContentLength] = Number.isFinite(contentLength) ? contentLength : null;
104550
+ this[kContentLength] = Number.isFinite(contentLength2) ? contentLength2 : null;
104547
104551
  this[kReading] = false;
104548
104552
  }
104549
104553
  /**
@@ -104983,12 +104987,12 @@ function requireApiRequest() {
104983
104987
  }
104984
104988
  const parsedHeaders = responseHeaders === "raw" ? util2.parseHeaders(rawHeaders) : headers2;
104985
104989
  const contentType = parsedHeaders["content-type"];
104986
- const contentLength = parsedHeaders["content-length"];
104990
+ const contentLength2 = parsedHeaders["content-length"];
104987
104991
  const res = new Readable({
104988
104992
  resume,
104989
104993
  abort,
104990
104994
  contentType,
104991
- contentLength: this.method !== "HEAD" && contentLength ? Number(contentLength) : null,
104995
+ contentLength: this.method !== "HEAD" && contentLength2 ? Number(contentLength2) : null,
104992
104996
  highWaterMark
104993
104997
  });
104994
104998
  if (this.removeAbortListener) {
@@ -106208,8 +106212,8 @@ function requireMockInterceptor() {
106208
106212
  }
106209
106213
  createMockScopeDispatchData({ statusCode, data, responseOptions }) {
106210
106214
  const responseData = getResponseData(data);
106211
- const contentLength = this[kContentLength] ? { "content-length": responseData.length } : {};
106212
- const headers2 = { ...this[kDefaultHeaders], ...contentLength, ...responseOptions.headers };
106215
+ const contentLength2 = this[kContentLength] ? { "content-length": responseData.length } : {};
106216
+ const headers2 = { ...this[kDefaultHeaders], ...contentLength2, ...responseOptions.headers };
106213
106217
  const trailers = { ...this[kDefaultTrailers], ...responseOptions.trailers };
106214
106218
  return { statusCode, data, headers: headers2, trailers };
106215
106219
  }
@@ -108052,10 +108056,10 @@ function requireDump() {
108052
108056
  return super.onRequestStart(controller, context);
108053
108057
  }
108054
108058
  onResponseStart(controller, statusCode, headers2, statusMessage) {
108055
- const contentLength = headers2["content-length"];
108056
- if (contentLength != null && contentLength > __privateGet(this, _maxSize2)) {
108059
+ const contentLength2 = headers2["content-length"];
108060
+ if (contentLength2 != null && contentLength2 > __privateGet(this, _maxSize2)) {
108057
108061
  throw new RequestAbortedError(
108058
- `Response size (${contentLength}) larger than maxSize (${__privateGet(this, _maxSize2)})`
108062
+ `Response size (${contentLength2}) larger than maxSize (${__privateGet(this, _maxSize2)})`
108059
108063
  );
108060
108064
  }
108061
108065
  if (this.aborted === true) {
@@ -113874,18 +113878,18 @@ function requireFetch() {
113874
113878
  httpFetchParams.request = httpRequest;
113875
113879
  }
113876
113880
  const includeCredentials = request2.credentials === "include" || request2.credentials === "same-origin" && request2.responseTainting === "basic";
113877
- const contentLength = httpRequest.body ? httpRequest.body.length : null;
113881
+ const contentLength2 = httpRequest.body ? httpRequest.body.length : null;
113878
113882
  let contentLengthHeaderValue = null;
113879
113883
  if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) {
113880
113884
  contentLengthHeaderValue = "0";
113881
113885
  }
113882
- if (contentLength != null) {
113883
- contentLengthHeaderValue = isomorphicEncode(`${contentLength}`);
113886
+ if (contentLength2 != null) {
113887
+ contentLengthHeaderValue = isomorphicEncode(`${contentLength2}`);
113884
113888
  }
113885
113889
  if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) {
113886
113890
  httpRequest.headersList.append("content-length", contentLengthHeaderValue, true);
113887
113891
  }
113888
- if (contentLength != null && httpRequest.keepalive) ;
113892
+ if (contentLength2 != null && httpRequest.keepalive) ;
113889
113893
  if (webidl.is.URL(httpRequest.referrer)) {
113890
113894
  httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true);
113891
113895
  }
@@ -119017,6 +119021,12 @@ async function handleLegacyEvent(basedir, runId, data, currentRun, params) {
119017
119021
  throw new Error(`Event type '${data.eventType}' not supported for legacy runs (specVersion: ${currentRun.specVersion || "undefined"}). Please upgrade 'workflow' package.`);
119018
119022
  }
119019
119023
  }
119024
+ const DEFAULT_MAX_EVENTS_PER_RUN = 25e3;
119025
+ function getMaxEventsPerRun() {
119026
+ const raw2 = process.env.WORKFLOW_MAX_EVENTS;
119027
+ const parsed = raw2 !== void 0 ? Number(raw2) : Number.NaN;
119028
+ return Number.isInteger(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_EVENTS_PER_RUN;
119029
+ }
119020
119030
  const HookTokenClaimSchema = object$1({
119021
119031
  // The token-claim writer below has always persisted `hookId`, but
119022
119032
  // this read schema previously omitted it, which is the bug fixed
@@ -119248,7 +119258,8 @@ function createEventsStorage(basedir, tag) {
119248
119258
  const resolveData2 = (params == null ? void 0 : params.resolveData) ?? DEFAULT_RESOLVE_DATA_OPTION$1;
119249
119259
  return {
119250
119260
  event: stripEventDataRefs(event2, resolveData2),
119251
- run: currentRun
119261
+ run: currentRun,
119262
+ ...currentRun ? { maxEvents: getMaxEventsPerRun() } : {}
119252
119263
  };
119253
119264
  }
119254
119265
  if (data.eventType === "run_started") {
@@ -119331,7 +119342,7 @@ function createEventsStorage(basedir, tag) {
119331
119342
  } else if (data.eventType === "run_started") {
119332
119343
  if (currentRun) {
119333
119344
  if (currentRun.status === "running") {
119334
- return { run: currentRun };
119345
+ return { run: currentRun, maxEvents: getMaxEventsPerRun() };
119335
119346
  }
119336
119347
  run2 = {
119337
119348
  runId: currentRun.runId,
@@ -119714,7 +119725,9 @@ function createEventsStorage(basedir, tag) {
119714
119725
  wait: wait2,
119715
119726
  events: events2,
119716
119727
  cursor,
119717
- hasMore
119728
+ hasMore,
119729
+ // Per-run event ceiling (mirrors the Vercel World).
119730
+ ...run2 ? { maxEvents: getMaxEventsPerRun() } : {}
119718
119731
  };
119719
119732
  }
119720
119733
  },
@@ -120303,7 +120316,7 @@ function createLocalWorld(args) {
120303
120316
  const basedir = mergedConfig.dataDir;
120304
120317
  const hooksDir = path$3.join(basedir, "hooks");
120305
120318
  const taggedHookFiles = await listTaggedFiles(hooksDir, tag);
120306
- const { HookSchema: HookSchema2 } = await import("./index-D86iFXiQ.js");
120319
+ const { HookSchema: HookSchema2 } = await import("./index-DUMo8iW2.js");
120307
120320
  await Promise.all(taggedHookFiles.map(async (hookFile) => {
120308
120321
  const hook = await readJSON(path$3.join(hooksDir, hookFile), HookSchema2);
120309
120322
  if (hook == null ? void 0 : hook.token) {
@@ -120338,6 +120351,175 @@ function createLocalWorld(args) {
120338
120351
  }
120339
120352
  };
120340
120353
  }
120354
+ let _dispatcher;
120355
+ let _eventsDispatcher;
120356
+ let _streamDispatcher;
120357
+ let _streamCloseDispatcher;
120358
+ const DEFAULT_HEADERS_TIMEOUT_MS = 3e4;
120359
+ const DEFAULT_BODY_TIMEOUT_MS = 3e4;
120360
+ function envTimeoutMs(name2, fallback) {
120361
+ const raw2 = process.env[name2];
120362
+ if (raw2 === void 0 || raw2 === "")
120363
+ return fallback;
120364
+ const parsed = Number.parseInt(raw2, 10);
120365
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
120366
+ }
120367
+ const RETRY_ERROR_CODES = [
120368
+ "ECONNRESET",
120369
+ "ECONNREFUSED",
120370
+ "ENOTFOUND",
120371
+ "ENETDOWN",
120372
+ "ENETUNREACH",
120373
+ "EHOSTDOWN",
120374
+ "EHOSTUNREACH",
120375
+ "EPIPE",
120376
+ "UND_ERR_SOCKET",
120377
+ "UND_ERR_HEADERS_TIMEOUT",
120378
+ "UND_ERR_BODY_TIMEOUT"
120379
+ ];
120380
+ const MAX_RETRIES = 2;
120381
+ function getBaseAgentOptions() {
120382
+ return {
120383
+ connections: 8,
120384
+ keepAliveTimeout: 1e4,
120385
+ headersTimeout: envTimeoutMs("WORKFLOW_VERCEL_HEADERS_TIMEOUT_MS", DEFAULT_HEADERS_TIMEOUT_MS),
120386
+ bodyTimeout: envTimeoutMs("WORKFLOW_VERCEL_BODY_TIMEOUT_MS", DEFAULT_BODY_TIMEOUT_MS)
120387
+ };
120388
+ }
120389
+ const H2_MAX_IN_FLIGHT_STREAMS = 100;
120390
+ const H2_STREAM_WINDOW_BYTES = 4 * 1024 * 1024;
120391
+ const H2_CONNECTION_WINDOW_BYTES = 16 * 1024 * 1024;
120392
+ function getAgentOptions() {
120393
+ return {
120394
+ ...getBaseAgentOptions(),
120395
+ allowH2: false,
120396
+ // HTTP/1.1 pipelining is disabled (pipelining: 1) because it causes
120397
+ // head-of-line blocking that deadlocks the webhook respondWith mechanism.
120398
+ pipelining: 1
120399
+ };
120400
+ }
120401
+ function getEventsAgentOptions() {
120402
+ return {
120403
+ ...getBaseAgentOptions(),
120404
+ allowH2: true,
120405
+ pipelining: H2_MAX_IN_FLIGHT_STREAMS,
120406
+ initialWindowSize: H2_STREAM_WINDOW_BYTES,
120407
+ connectionWindowSize: H2_CONNECTION_WINDOW_BYTES
120408
+ };
120409
+ }
120410
+ function getStreamAgentOptions() {
120411
+ return {
120412
+ ...getBaseAgentOptions(),
120413
+ allowH2: true,
120414
+ pipelining: 1
120415
+ };
120416
+ }
120417
+ function getRetryAgentOptions() {
120418
+ return {
120419
+ // Observe Retry-After header if received
120420
+ retryAfter: true,
120421
+ // Retry 5xx in-process (genuine transient blips recover fast), but NOT
120422
+ // 429. The Vercel firewall issues a challenge as a 429: our
120423
+ // server-to-server client cannot solve a challenge, so in-process
120424
+ // retries just re-trigger it ~5× per request and amplify load against
120425
+ // an already-overloaded firewall during an incident. Letting 429 pass
120426
+ // through surfaces it immediately to makeRequest — which maps it to a
120427
+ // ThrottleError carrying the `x-vercel-mitigated` / `x-vercel-id`
120428
+ // headers — and the queue does the (backed-off) retry instead.
120429
+ // (undici default is [500, 502, 503, 504, 429].)
120430
+ statusCodes: [500, 502, 503, 504],
120431
+ errorCodes: RETRY_ERROR_CODES,
120432
+ maxRetries: MAX_RETRIES
120433
+ };
120434
+ }
120435
+ const STREAM_RETRY_OPTIONS = {
120436
+ retryAfter: true,
120437
+ methods: ["PUT"],
120438
+ statusCodes: [429]
120439
+ };
120440
+ const STREAM_CLOSE_RETRY_OPTIONS = {
120441
+ retryAfter: true,
120442
+ methods: ["PUT"],
120443
+ statusCodes: [429, 500, 502, 503, 504]
120444
+ };
120445
+ const H2_REBUFFER_MAX_BYTES = 1 << 20;
120446
+ function h2MultiplexEnabled() {
120447
+ return process.env.WORKFLOW_H2_MULTIPLEX !== "0";
120448
+ }
120449
+ function contentLength(headers2) {
120450
+ if (!headers2 || typeof headers2 !== "object" || Array.isArray(headers2)) {
120451
+ return Number.NaN;
120452
+ }
120453
+ const record2 = headers2;
120454
+ const raw2 = record2["content-length"] ?? record2["Content-Length"];
120455
+ return typeof raw2 === "string" || typeof raw2 === "number" ? Number(raw2) : Number.NaN;
120456
+ }
120457
+ function h2MultiplexInterceptor(dispatch2) {
120458
+ return (opts, handler) => {
120459
+ const body2 = opts.body;
120460
+ const isAsyncIterable = !!body2 && typeof body2 !== "string" && !Buffer.isBuffer(body2) && typeof body2[Symbol.asyncIterator] === "function";
120461
+ const length = contentLength(opts.headers);
120462
+ if (!isAsyncIterable || !(length >= 0) || length > H2_REBUFFER_MAX_BYTES) {
120463
+ return dispatch2({ ...opts, idempotent: true }, handler);
120464
+ }
120465
+ void (async () => {
120466
+ var _a3;
120467
+ try {
120468
+ const chunks = [];
120469
+ for await (const chunk of body2) {
120470
+ chunks.push(Buffer.from(chunk));
120471
+ }
120472
+ dispatch2({ ...opts, body: Buffer.concat(chunks), idempotent: true }, handler);
120473
+ } catch (error2) {
120474
+ (_a3 = handler.onError) == null ? void 0 : _a3.call(handler, error2);
120475
+ }
120476
+ })();
120477
+ return true;
120478
+ };
120479
+ }
120480
+ function getDispatcher(config2) {
120481
+ return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
120482
+ }
120483
+ function getEventsDispatcher(config2) {
120484
+ return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultEventsDispatcher();
120485
+ }
120486
+ function getStreamDispatcher(config2) {
120487
+ return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamDispatcher();
120488
+ }
120489
+ function getStreamCloseDispatcher(config2) {
120490
+ return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultStreamCloseDispatcher();
120491
+ }
120492
+ function createEventsDispatcher(agentOverrides) {
120493
+ const agent2 = new undiciExports.RetryAgent(new undiciExports.Agent({ ...getEventsAgentOptions(), ...agentOverrides }), getRetryAgentOptions());
120494
+ if (!h2MultiplexEnabled()) {
120495
+ return agent2;
120496
+ }
120497
+ return withBoundLifecycle(agent2, agent2.compose(h2MultiplexInterceptor));
120498
+ }
120499
+ function withBoundLifecycle(agent2, composed) {
120500
+ return new Proxy(composed, {
120501
+ get: (target2, key) => key === "close" || key === "destroy" ? agent2[key].bind(agent2) : target2[key]
120502
+ });
120503
+ }
120504
+ function createStreamDispatcher(retryOptions, agentOverrides) {
120505
+ return new undiciExports.RetryAgent(new undiciExports.Agent({ ...getStreamAgentOptions(), ...agentOverrides }), retryOptions);
120506
+ }
120507
+ function getDefaultDispatcher() {
120508
+ _dispatcher ?? (_dispatcher = new undiciExports.RetryAgent(new undiciExports.Agent(getAgentOptions()), getRetryAgentOptions()));
120509
+ return _dispatcher;
120510
+ }
120511
+ function getDefaultEventsDispatcher() {
120512
+ _eventsDispatcher ?? (_eventsDispatcher = createEventsDispatcher());
120513
+ return _eventsDispatcher;
120514
+ }
120515
+ function getDefaultStreamDispatcher() {
120516
+ _streamDispatcher ?? (_streamDispatcher = createStreamDispatcher(STREAM_RETRY_OPTIONS));
120517
+ return _streamDispatcher;
120518
+ }
120519
+ function getDefaultStreamCloseDispatcher() {
120520
+ _streamCloseDispatcher ?? (_streamCloseDispatcher = createStreamDispatcher(STREAM_CLOSE_RETRY_OPTIONS));
120521
+ return _streamCloseDispatcher;
120522
+ }
120341
120523
  var getContext_1;
120342
120524
  var hasRequiredGetContext;
120343
120525
  function requireGetContext() {
@@ -120456,8 +120638,8 @@ function requireGetVercelOidcToken() {
120456
120638
  }
120457
120639
  try {
120458
120640
  const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
120459
- await import("./token-util-BCX_82dS.js").then((n) => n.t),
120460
- await import("./token-wXB5G-Q6.js").then((n) => n.t)
120641
+ await import("./token-util-BVCPBo_Y.js").then((n) => n.t),
120642
+ await import("./token-BdngUnpg.js").then((n) => n.t)
120461
120643
  ]);
120462
120644
  if (!token || isExpired(getTokenPayload(token), options == null ? void 0 : options.expirationBufferMs)) {
120463
120645
  await refreshToken(options);
@@ -121020,69 +121202,220 @@ function requireDist() {
121020
121202
  return dist;
121021
121203
  }
121022
121204
  var distExports = requireDist();
121023
- let _dispatcher;
121024
- const DEFAULT_HEADERS_TIMEOUT_MS = 3e4;
121025
- const DEFAULT_BODY_TIMEOUT_MS = 3e4;
121026
- function envTimeoutMs(name2, fallback) {
121027
- const raw2 = process.env[name2];
121028
- if (raw2 === void 0 || raw2 === "")
121029
- return fallback;
121030
- const parsed = Number.parseInt(raw2, 10);
121031
- return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
121205
+ let otelApiPromise = null;
121206
+ async function getOtelApi() {
121207
+ if (!otelApiPromise) {
121208
+ otelApiPromise = import("./index-hBO56emR.js").catch(() => null);
121209
+ }
121210
+ return otelApiPromise;
121032
121211
  }
121033
- const RETRY_ERROR_CODES = [
121034
- "ECONNRESET",
121035
- "ECONNREFUSED",
121036
- "ENOTFOUND",
121037
- "ENETDOWN",
121038
- "ENETUNREACH",
121039
- "EHOSTDOWN",
121040
- "EHOSTUNREACH",
121041
- "EPIPE",
121042
- "UND_ERR_SOCKET",
121043
- "UND_ERR_HEADERS_TIMEOUT",
121044
- "UND_ERR_BODY_TIMEOUT"
121212
+ let tracerPromise = null;
121213
+ async function getTracer() {
121214
+ if (!tracerPromise) {
121215
+ tracerPromise = getOtelApi().then((otel) => otel ? otel.trace.getTracer("workflow") : null);
121216
+ }
121217
+ return tracerPromise;
121218
+ }
121219
+ async function trace(spanName2, ...args) {
121220
+ const [tracer, otel] = await Promise.all([getTracer(), getOtelApi()]);
121221
+ const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
121222
+ if (!fn2)
121223
+ throw new Error("Function to trace must be provided");
121224
+ if (!tracer || !otel) {
121225
+ return await fn2();
121226
+ }
121227
+ return tracer.startActiveSpan(spanName2, opts, async (span) => {
121228
+ try {
121229
+ const result = await fn2(span);
121230
+ span.setStatus({ code: otel.SpanStatusCode.OK });
121231
+ return result;
121232
+ } catch (e) {
121233
+ span.setStatus({
121234
+ code: otel.SpanStatusCode.ERROR,
121235
+ message: e.message
121236
+ });
121237
+ throw e;
121238
+ } finally {
121239
+ span.end();
121240
+ }
121241
+ });
121242
+ }
121243
+ async function getSpanKind(field) {
121244
+ const otel = await getOtelApi();
121245
+ if (!otel)
121246
+ return void 0;
121247
+ return otel.SpanKind[field];
121248
+ }
121249
+ async function injectTraceContextIntoHeaders(headers2) {
121250
+ const otel = await getOtelApi();
121251
+ if (!otel)
121252
+ return;
121253
+ const carrier = {};
121254
+ otel.propagation.inject(otel.context.active(), carrier);
121255
+ for (const [key, value] of Object.entries(carrier)) {
121256
+ headers2.set(key, value);
121257
+ }
121258
+ }
121259
+ function SemanticConvention(...names) {
121260
+ return (value) => Object.fromEntries(names.map((name2) => [name2, value]));
121261
+ }
121262
+ const HttpRequestMethod = SemanticConvention("http.request.method");
121263
+ const UrlFull = SemanticConvention("url.full");
121264
+ const ServerAddress = SemanticConvention("server.address");
121265
+ const ServerPort = SemanticConvention("server.port");
121266
+ const HttpResponseStatusCode = SemanticConvention("http.response.status_code");
121267
+ const ErrorType = SemanticConvention("error.type");
121268
+ const WorldParseFormat = SemanticConvention("workflow.world.parse.format");
121269
+ const PeerService = SemanticConvention("peer.service");
121270
+ const RpcSystem = SemanticConvention("rpc.system");
121271
+ const RpcService = SemanticConvention("rpc.service");
121272
+ const RpcMethod = SemanticConvention("rpc.method");
121273
+ const WorkflowRunId = SemanticConvention("workflow.run.id");
121274
+ const StepId = SemanticConvention("step.id");
121275
+ const REQUEST_TIMEOUT_MS = 6e4;
121276
+ const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
121277
+ const DIAGNOSTIC_HEADERS = [
121278
+ "x-vercel-id",
121279
+ "x-vercel-error",
121280
+ "x-vercel-mitigated"
121045
121281
  ];
121046
- const MAX_RETRIES = 2;
121047
- function getAgentOptions() {
121048
- return {
121049
- connections: 8,
121050
- keepAliveTimeout: 1e4,
121051
- // H2 is specifically incompatible with SvelteKit on Vercel prod. Everything else
121052
- // runs fine.
121053
- // TODO: Investigate/fix the failure on SvelteKit so we can re-enable H2.
121054
- allowH2: false,
121055
- // HTTP/1.1 pipelining is disabled (pipelining: 1) because it causes
121056
- // head-of-line blocking that deadlocks the webhook respondWith mechanism.
121057
- pipelining: 1,
121058
- headersTimeout: envTimeoutMs("WORKFLOW_VERCEL_HEADERS_TIMEOUT_MS", DEFAULT_HEADERS_TIMEOUT_MS),
121059
- bodyTimeout: envTimeoutMs("WORKFLOW_VERCEL_BODY_TIMEOUT_MS", DEFAULT_BODY_TIMEOUT_MS)
121060
- };
121282
+ function getVercelDiagnostics(headers2) {
121283
+ return DIAGNOSTIC_HEADERS.flatMap((header) => {
121284
+ const value = headers2.get(header);
121285
+ return value ? [`${header}=${value}`] : [];
121286
+ });
121061
121287
  }
121062
- function getDispatcher(config2) {
121063
- return (config2 == null ? void 0 : config2.dispatcher) ?? getDefaultDispatcher();
121288
+ function formatVercelDiagnostics(headers2) {
121289
+ const diagnostics2 = getVercelDiagnostics(headers2);
121290
+ return diagnostics2.length > 0 ? ` (${diagnostics2.join("; ")})` : "";
121064
121291
  }
121065
- function getDefaultDispatcher() {
121066
- if (!_dispatcher) {
121067
- const retryOptions = {
121068
- // Observe Retry-After header if received
121069
- retryAfter: true,
121070
- // Retry 5xx in-process (genuine transient blips recover fast), but NOT
121071
- // 429. The Vercel firewall issues a challenge as a 429: our
121072
- // server-to-server client cannot solve a challenge, so in-process
121073
- // retries just re-trigger it ~5× per request and amplify load against
121074
- // an already-overloaded firewall during an incident. Letting 429 pass
121075
- // through surfaces it immediately to makeRequest which maps it to a
121076
- // ThrottleError carrying the `x-vercel-mitigated` / `x-vercel-id`
121077
- // headers and the queue does the (backed-off) retry instead.
121078
- // (undici default is [500, 502, 503, 504, 429].)
121079
- statusCodes: [500, 502, 503, 504],
121080
- errorCodes: RETRY_ERROR_CODES,
121081
- maxRetries: MAX_RETRIES
121292
+ function httpLog(method, label, response2, ms2) {
121293
+ if (!HTTP_DEBUG_ENABLED)
121294
+ return;
121295
+ const diagnostics2 = getVercelDiagnostics(response2.headers);
121296
+ const suffix = diagnostics2.length > 0 ? `; ${diagnostics2.join("; ")}` : "";
121297
+ console.debug(`[workflow:world-vercel:http] ${method} ${label} -> ${response2.status} (${ms2}ms${suffix})`);
121298
+ }
121299
+ function logCurlRepro(method, url2, headers2) {
121300
+ if (!process.env.DEBUG)
121301
+ return;
121302
+ const stringifiedHeaders = Array.from(headers2.entries()).filter(([key]) => key.toLowerCase() !== "authorization").map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
121303
+ console.error(`Failed to fetch, reproduce with:
121304
+ curl -X ${method} ${stringifiedHeaders} "${url2}"`);
121305
+ }
121306
+ function parseRetryAfter(value) {
121307
+ if (!value)
121308
+ return void 0;
121309
+ const parsed = parseInt(value, 10);
121310
+ return Number.isNaN(parsed) ? void 0 : parsed;
121311
+ }
121312
+ function errorForResponse(status, message2, opts = {}) {
121313
+ const { retryAfter, code: code2, url: url2, mitigated } = opts;
121314
+ if (status === 409)
121315
+ return new EntityConflictError(message2);
121316
+ if (status === 410)
121317
+ return new RunExpiredError(message2);
121318
+ if (status === 412)
121319
+ return new PreconditionFailedError(message2, { retryAfter });
121320
+ if (status === 425)
121321
+ return new TooEarlyError(message2, { retryAfter });
121322
+ if (status === 429) {
121323
+ if (isFirewallChallenge429(status, mitigated)) {
121324
+ return new WorkflowWorldError(`${message2} (x-vercel-mitigated=challenge)`, {
121325
+ url: url2,
121326
+ status,
121327
+ code: "TRANSPORT",
121328
+ retryAfter
121329
+ });
121330
+ }
121331
+ return new ThrottleError(message2, { retryAfter });
121332
+ }
121333
+ return new WorkflowWorldError(message2, { url: url2, status, code: code2, retryAfter });
121334
+ }
121335
+ function isFirewallChallenge429(status, mitigated) {
121336
+ return status === 429 && mitigated === "challenge";
121337
+ }
121338
+ async function resolveVercelApiToken(opts) {
121339
+ return (opts == null ? void 0 : opts.token) ?? process.env.VERCEL_TOKEN ?? await distExports.getVercelOidcToken().catch(() => null);
121340
+ }
121341
+ function parseServer(url2) {
121342
+ try {
121343
+ const parsed = new URL(url2);
121344
+ return {
121345
+ serverAddress: parsed.hostname,
121346
+ serverPort: parsed.port ? parseInt(parsed.port, 10) : parsed.protocol === "https:" ? 443 : 80
121082
121347
  };
121083
- _dispatcher = new undiciExports.RetryAgent(new undiciExports.Agent(getAgentOptions()), retryOptions);
121348
+ } catch {
121349
+ return {};
121084
121350
  }
121085
- return _dispatcher;
121351
+ }
121352
+ function httpClientSpanAttributes(args) {
121353
+ const { method, url: url2, peerService } = args;
121354
+ const { serverAddress, serverPort } = parseServer(url2);
121355
+ return {
121356
+ ...HttpRequestMethod(method),
121357
+ ...UrlFull(url2),
121358
+ ...serverAddress ? ServerAddress(serverAddress) : {},
121359
+ ...serverPort ? ServerPort(serverPort) : {},
121360
+ ...PeerService(peerService),
121361
+ ...RpcSystem("http"),
121362
+ ...RpcService(peerService)
121363
+ };
121364
+ }
121365
+ async function instrumentedFetch(opts) {
121366
+ const { method, url: url2, headers: headers2, body: body2, dispatcher: dispatcher2, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError } = opts;
121367
+ const label = logLabel ?? url2;
121368
+ return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
121369
+ var _a3, _b2, _c;
121370
+ span == null ? void 0 : span.setAttributes(httpClientSpanAttributes({ method, url: url2, peerService }));
121371
+ if (injectTraceContext)
121372
+ await injectTraceContextIntoHeaders(headers2);
121373
+ if (cacheBust)
121374
+ headers2.set("X-Request-Time", Date.now().toString());
121375
+ const timeoutSignal = timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0;
121376
+ const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
121377
+ const start2 = Date.now();
121378
+ let response2;
121379
+ try {
121380
+ response2 = await fetch(url2, {
121381
+ method,
121382
+ headers: headers2,
121383
+ body: body2,
121384
+ signal,
121385
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici dispatcher type doesn't match @types/node's RequestInit
121386
+ dispatcher: dispatcher2
121387
+ });
121388
+ } catch (error2) {
121389
+ const elapsed = Date.now() - start2;
121390
+ if (error2 instanceof Error && (error2.name === "TimeoutError" || error2.name === "AbortError")) {
121391
+ const timeoutError = new WorkflowWorldError(`${method} ${label} timed out after ${elapsed}ms`, { url: url2, cause: error2 });
121392
+ span == null ? void 0 : span.setAttributes({ ...ErrorType("TIMEOUT") });
121393
+ (_a3 = span == null ? void 0 : span.recordException) == null ? void 0 : _a3.call(span, timeoutError);
121394
+ throw timeoutError;
121395
+ }
121396
+ throw error2;
121397
+ }
121398
+ const ms2 = Date.now() - start2;
121399
+ httpLog(method, label, response2, ms2);
121400
+ span == null ? void 0 : span.setAttributes({ ...HttpResponseStatusCode(response2.status) });
121401
+ if (!response2.ok) {
121402
+ span == null ? void 0 : span.setAttributes({ ...ErrorType(`HTTP ${response2.status}`) });
121403
+ logCurlRepro(method, url2, headers2);
121404
+ if (buildError) {
121405
+ const error3 = await buildError(response2);
121406
+ (_b2 = span == null ? void 0 : span.recordException) == null ? void 0 : _b2.call(span, error3);
121407
+ throw error3;
121408
+ }
121409
+ const text2 = await response2.text().catch(() => "");
121410
+ const error2 = errorForResponse(response2.status, `${method} ${label} -> HTTP ${response2.status}: ${response2.statusText}${text2 ? ` ${text2}` : ""}${formatVercelDiagnostics(response2.headers)}`, {
121411
+ url: url2,
121412
+ retryAfter: parseRetryAfter(response2.headers.get("Retry-After"))
121413
+ });
121414
+ (_c = span == null ? void 0 : span.recordException) == null ? void 0 : _c.call(span, error2);
121415
+ throw error2;
121416
+ }
121417
+ return response2;
121418
+ });
121086
121419
  }
121087
121420
  const KEY_BYTES = 32;
121088
121421
  async function deriveRunKey(deploymentKey, projectId, runId) {
@@ -121108,7 +121441,7 @@ async function deriveRunKey(deploymentKey, projectId, runId) {
121108
121441
  return new Uint8Array(derivedBits);
121109
121442
  }
121110
121443
  async function fetchRunKey(deploymentId, projectId, runId, options) {
121111
- const token = (options == null ? void 0 : options.token) ?? process.env.VERCEL_TOKEN ?? await distExports.getVercelOidcToken().catch(() => null);
121444
+ const token = await resolveVercelApiToken({ token: options == null ? void 0 : options.token });
121112
121445
  if (!token) {
121113
121446
  throw new Error("Cannot fetch run key: no OIDC token or VERCEL_TOKEN available");
121114
121447
  }
@@ -121116,23 +121449,25 @@ async function fetchRunKey(deploymentId, projectId, runId, options) {
121116
121449
  if (options == null ? void 0 : options.teamId) {
121117
121450
  params.set("teamId", options.teamId);
121118
121451
  }
121119
- const response2 = await fetch(`https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`, {
121452
+ const response2 = await instrumentedFetch({
121120
121453
  method: "GET",
121121
- headers: {
121122
- Authorization: `Bearer ${token}`
121123
- },
121124
- // @ts-expect-error -- undici dispatcher is accepted by Node.js fetch but not in @types/node's RequestInit
121125
- dispatcher: getDispatcher({ dispatcher: options == null ? void 0 : options.dispatcher })
121126
- });
121127
- if (!response2.ok) {
121128
- let body2;
121129
- try {
121130
- body2 = await response2.text();
121131
- } catch {
121132
- body2 = "<unable to read response body>";
121454
+ url: `https://api.vercel.com/v1/workflow/run-key/${deploymentId}?${params}`,
121455
+ headers: new Headers({ Authorization: `Bearer ${token}` }),
121456
+ dispatcher: getDispatcher({ dispatcher: options == null ? void 0 : options.dispatcher }),
121457
+ peerService: "vercel-api",
121458
+ // Preserve the prior no-timeout behavior for this Vercel-API call; the
121459
+ // shared RetryAgent still handles transient/5xx retries.
121460
+ timeoutMs: null,
121461
+ buildError: async (res) => {
121462
+ let body2;
121463
+ try {
121464
+ body2 = await res.text();
121465
+ } catch {
121466
+ body2 = "<unable to read response body>";
121467
+ }
121468
+ return new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`);
121133
121469
  }
121134
- throw new Error(`Failed to fetch run key for ${runId} (deployment ${deploymentId}): HTTP ${response2.status} ${response2.statusText}${body2 ? ` — ${body2}` : ""}`);
121135
- }
121470
+ });
121136
121471
  const data = await response2.json();
121137
121472
  const result = object$1({ key: string$3().nullable() }).safeParse(data);
121138
121473
  if (!result.success) {
@@ -121177,66 +121512,6 @@ function createGetEncryptionKeyForRun(projectId, teamId, token, dispatcher2) {
121177
121512
  });
121178
121513
  };
121179
121514
  }
121180
- let otelApiPromise = null;
121181
- async function getOtelApi() {
121182
- if (!otelApiPromise) {
121183
- otelApiPromise = import("./index-meg9qk8y.js").catch(() => null);
121184
- }
121185
- return otelApiPromise;
121186
- }
121187
- let tracerPromise = null;
121188
- async function getTracer() {
121189
- if (!tracerPromise) {
121190
- tracerPromise = getOtelApi().then((otel) => otel ? otel.trace.getTracer("workflow") : null);
121191
- }
121192
- return tracerPromise;
121193
- }
121194
- async function trace(spanName2, ...args) {
121195
- const [tracer, otel] = await Promise.all([getTracer(), getOtelApi()]);
121196
- const { fn: fn2, opts } = typeof args[0] === "function" ? { fn: args[0], opts: {} } : { fn: args[1], opts: args[0] };
121197
- if (!fn2)
121198
- throw new Error("Function to trace must be provided");
121199
- if (!tracer || !otel) {
121200
- return await fn2();
121201
- }
121202
- return tracer.startActiveSpan(spanName2, opts, async (span) => {
121203
- try {
121204
- const result = await fn2(span);
121205
- span.setStatus({ code: otel.SpanStatusCode.OK });
121206
- return result;
121207
- } catch (e) {
121208
- span.setStatus({
121209
- code: otel.SpanStatusCode.ERROR,
121210
- message: e.message
121211
- });
121212
- throw e;
121213
- } finally {
121214
- span.end();
121215
- }
121216
- });
121217
- }
121218
- async function getSpanKind(field) {
121219
- const otel = await getOtelApi();
121220
- if (!otel)
121221
- return void 0;
121222
- return otel.SpanKind[field];
121223
- }
121224
- function SemanticConvention(...names) {
121225
- return (value) => Object.fromEntries(names.map((name2) => [name2, value]));
121226
- }
121227
- const HttpRequestMethod = SemanticConvention("http.request.method");
121228
- const UrlFull = SemanticConvention("url.full");
121229
- const ServerAddress = SemanticConvention("server.address");
121230
- const ServerPort = SemanticConvention("server.port");
121231
- const HttpResponseStatusCode = SemanticConvention("http.response.status_code");
121232
- const ErrorType = SemanticConvention("error.type");
121233
- const WorldParseFormat = SemanticConvention("workflow.world.parse.format");
121234
- const PeerService = SemanticConvention("peer.service");
121235
- const RpcSystem = SemanticConvention("rpc.system");
121236
- const RpcService = SemanticConvention("rpc.service");
121237
- const RpcMethod = SemanticConvention("rpc.method");
121238
- const WorkflowRunId = SemanticConvention("workflow.run.id");
121239
- const StepId = SemanticConvention("step.id");
121240
121515
  const WORKFLOW_SERVER_SERVICE = {
121241
121516
  peerService: "workflow-server",
121242
121517
  rpcSystem: "http",
@@ -125833,26 +126108,7 @@ var QueueClient = class {
125833
126108
  setApi(this, new ApiClient({ ...options, region }));
125834
126109
  }
125835
126110
  };
125836
- const version = "4.6.0";
125837
- const HTTP_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
125838
- function httpLog(method, endpoint, response2, ms2) {
125839
- if (HTTP_DEBUG_ENABLED) {
125840
- const responseContext = getResponseDiagnosticHeaders(response2);
125841
- const diagnosticSuffix = responseContext.length > 0 ? `; ${responseContext.join("; ")}` : "";
125842
- console.debug(`[workflow:world-vercel:http] ${method} ${endpoint} -> ${response2.status} (${ms2}ms${diagnosticSuffix})`);
125843
- }
125844
- }
125845
- function getResponseDiagnosticHeaders(response2) {
125846
- return ["x-vercel-id", "x-vercel-error", "x-vercel-mitigated"].flatMap((header) => {
125847
- const value = response2.headers.get(header);
125848
- return value ? [`${header}=${value}`] : [];
125849
- });
125850
- }
125851
- function formatResponseDiagnostics(response2) {
125852
- const headers2 = getResponseDiagnosticHeaders(response2);
125853
- return headers2.length > 0 ? ` (${headers2.join("; ")})` : "";
125854
- }
125855
- const REQUEST_TIMEOUT_MS = 6e4;
126111
+ const version = "4.6.1";
125856
126112
  const IDEMPOTENT_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
125857
126113
  const MAX_BODY_PARSE_RETRIES = 2;
125858
126114
  const BODY_PARSE_RETRY_BASE_MS = 100;
@@ -125990,27 +126246,15 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
125990
126246
  const method = options.method || "GET";
125991
126247
  const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
125992
126248
  const url2 = `${baseUrl}${endpoint}`;
125993
- let serverAddress;
125994
- let serverPort;
125995
- try {
125996
- const parsedUrl = new URL(url2);
125997
- serverAddress = parsedUrl.hostname;
125998
- serverPort = parsedUrl.port ? parseInt(parsedUrl.port, 10) : parsedUrl.protocol === "https:" ? 443 : 80;
125999
- } catch {
126000
- }
126001
126249
  return trace(`http ${method}`, { kind: await getSpanKind("CLIENT") }, async (span) => {
126002
- var _a3, _b2;
126003
- span == null ? void 0 : span.setAttributes({
126004
- ...HttpRequestMethod(method),
126005
- ...UrlFull(url2),
126006
- ...serverAddress && ServerAddress(serverAddress),
126007
- ...serverPort && ServerPort(serverPort),
126008
- // Peer service for Datadog service maps
126009
- ...PeerService("workflow-server"),
126010
- ...RpcSystem("http"),
126011
- ...RpcService("workflow-server")
126012
- });
126250
+ var _a3, _b2, _c;
126251
+ span == null ? void 0 : span.setAttributes(httpClientSpanAttributes({
126252
+ method,
126253
+ url: url2,
126254
+ peerService: "workflow-server"
126255
+ }));
126013
126256
  headers2.set("Accept", "application/cbor");
126257
+ await injectTraceContextIntoHeaders(headers2);
126014
126258
  let body2;
126015
126259
  if (data !== void 0) {
126016
126260
  headers2.set("Content-Type", "application/cbor");
@@ -126057,64 +126301,27 @@ async function makeRequest({ endpoint, options = {}, config: config2 = {}, schem
126057
126301
  throw error2;
126058
126302
  }
126059
126303
  const fetchMs = Date.now() - fetchStart;
126060
- responseDiagnostics = formatResponseDiagnostics(response2);
126304
+ responseDiagnostics = formatVercelDiagnostics(response2.headers);
126061
126305
  httpLog(method, endpoint, response2, fetchMs);
126062
126306
  span == null ? void 0 : span.setAttributes({
126063
126307
  ...HttpResponseStatusCode(response2.status)
126064
126308
  });
126065
126309
  if (!response2.ok) {
126066
126310
  const errorData = await parseResponseBody(response2).then((r2) => r2.data).catch(() => ({}));
126067
- if (process.env.DEBUG) {
126068
- const stringifiedHeaders = Array.from(headers2.entries()).filter(([key]) => key.toLowerCase() !== "authorization").map(([key, value]) => `-H "${key}: ${value}"`).join(" ");
126069
- console.error(`Failed to fetch, reproduce with:
126070
- curl -X ${request2.method} ${stringifiedHeaders} "${url2}"`);
126071
- }
126072
- let retryAfter;
126073
- const retryAfterHeader = response2.headers.get("Retry-After");
126074
- if (retryAfterHeader) {
126075
- const parsed = parseInt(retryAfterHeader, 10);
126076
- if (!Number.isNaN(parsed)) {
126077
- retryAfter = parsed;
126078
- }
126079
- }
126311
+ logCurlRepro(request2.method, url2, headers2);
126312
+ const retryAfter = parseRetryAfter(response2.headers.get("Retry-After"));
126080
126313
  const defaultMessage = (errorData.message || `${request2.method} ${endpoint} -> HTTP ${response2.status}: ${response2.statusText}`) + responseDiagnostics;
126081
- const throwWithTrace = (error2) => {
126082
- var _a4;
126083
- span == null ? void 0 : span.setAttributes({
126084
- ...ErrorType(errorData.code || `HTTP ${response2.status}`)
126085
- });
126086
- (_a4 = span == null ? void 0 : span.recordException) == null ? void 0 : _a4.call(span, error2);
126087
- throw error2;
126088
- };
126089
- if (response2.status === 409) {
126090
- throwWithTrace(new EntityConflictError(defaultMessage));
126091
- }
126092
- if (response2.status === 410) {
126093
- throwWithTrace(new RunExpiredError(defaultMessage));
126094
- }
126095
- if (response2.status === 412) {
126096
- throwWithTrace(new PreconditionFailedError(defaultMessage, { retryAfter }));
126097
- }
126098
- if (response2.status === 425) {
126099
- throwWithTrace(new TooEarlyError(defaultMessage, { retryAfter }));
126100
- }
126101
- if (response2.status === 429) {
126102
- if (response2.headers.get("x-vercel-mitigated") === "challenge") {
126103
- throwWithTrace(new WorkflowWorldError(`${defaultMessage} (x-vercel-mitigated=challenge)`, {
126104
- url: url2,
126105
- status: response2.status,
126106
- code: "TRANSPORT",
126107
- retryAfter
126108
- }));
126109
- }
126110
- throwWithTrace(new ThrottleError(defaultMessage, { retryAfter }));
126111
- }
126112
- throwWithTrace(new WorkflowWorldError(defaultMessage, {
126314
+ const error2 = errorForResponse(response2.status, defaultMessage, {
126113
126315
  url: url2,
126114
- status: response2.status,
126115
126316
  code: errorData.code,
126116
- retryAfter
126117
- }));
126317
+ retryAfter,
126318
+ mitigated: response2.headers.get("x-vercel-mitigated")
126319
+ });
126320
+ span == null ? void 0 : span.setAttributes({
126321
+ ...ErrorType(errorData.code || `HTTP ${response2.status}`)
126322
+ });
126323
+ (_c = span == null ? void 0 : span.recordException) == null ? void 0 : _c.call(span, error2);
126324
+ throw error2;
126118
126325
  }
126119
126326
  onResponse == null ? void 0 : onResponse(response2);
126120
126327
  try {
@@ -126399,28 +126606,30 @@ function createResolveLatestDeploymentId(config2) {
126399
126606
  if (!currentDeploymentId) {
126400
126607
  throw new Error("Cannot resolve latest deployment: VERCEL_DEPLOYMENT_ID environment variable is not set");
126401
126608
  }
126402
- const token = (config2 == null ? void 0 : config2.token) ?? process.env.VERCEL_TOKEN ?? await distExports.getVercelOidcToken().catch(() => null);
126609
+ const token = await resolveVercelApiToken(config2);
126403
126610
  if (!token) {
126404
126611
  throw new Error("Cannot resolve latest deployment: no OIDC token or VERCEL_TOKEN available");
126405
126612
  }
126406
126613
  const url2 = `https://api.vercel.com/v1/workflow/resolve-latest-deployment/${encodeURIComponent(currentDeploymentId)}`;
126407
- const response2 = await fetch(url2, {
126614
+ const response2 = await instrumentedFetch({
126408
126615
  method: "GET",
126409
- headers: {
126410
- Authorization: `Bearer ${token}`
126411
- },
126412
- // @ts-expect-error -- undici dispatcher is accepted by Node.js fetch but not in @types/node's RequestInit
126413
- dispatcher: getDispatcher(config2)
126414
- });
126415
- if (!response2.ok) {
126416
- let body2;
126417
- try {
126418
- body2 = await response2.text();
126419
- } catch {
126420
- body2 = "<unable to read response body>";
126616
+ url: url2,
126617
+ headers: new Headers({ Authorization: `Bearer ${token}` }),
126618
+ dispatcher: getDispatcher(config2),
126619
+ peerService: "vercel-api",
126620
+ // Preserve the prior no-timeout behavior for this Vercel-API call; the
126621
+ // shared RetryAgent still handles transient/5xx retries.
126622
+ timeoutMs: null,
126623
+ buildError: async (res) => {
126624
+ let body2;
126625
+ try {
126626
+ body2 = await res.text();
126627
+ } catch {
126628
+ body2 = "<unable to read response body>";
126629
+ }
126630
+ return new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${res.status} ${res.statusText}${body2 ? ` — ${body2}` : ""}`);
126421
126631
  }
126422
- throw new Error(`Failed to resolve latest deployment for ${currentDeploymentId}: HTTP ${response2.status} ${response2.statusText}${body2 ? ` — ${body2}` : ""}`);
126423
- }
126632
+ });
126424
126633
  const data = await response2.json();
126425
126634
  const result = ResolveLatestDeploymentResponseSchema.safeParse(data);
126426
126635
  if (!result.success) {
@@ -126632,42 +126841,75 @@ async function* decodeFrames(source) {
126632
126841
  buffer2 = buffer2.subarray(n);
126633
126842
  return out;
126634
126843
  };
126635
- while (true) {
126636
- if (!await refill(4))
126637
- return;
126638
- const metaLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
126639
- take(4);
126640
- if (!await refill(metaLen)) {
126641
- throw new Error("decodeFrames: truncated meta block");
126642
- }
126643
- const meta2 = decode(take(metaLen));
126644
- if (!await refill(4)) {
126645
- throw new Error("decodeFrames: truncated body length");
126646
- }
126647
- const bodyLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
126648
- take(4);
126649
- if (bodyLen > 0) {
126650
- if (!await refill(bodyLen)) {
126844
+ try {
126845
+ while (true) {
126846
+ if (!await refill(4))
126847
+ return;
126848
+ const metaLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
126849
+ take(4);
126850
+ if (!await refill(metaLen)) {
126851
+ throw new Error("decodeFrames: truncated meta block");
126852
+ }
126853
+ const meta2 = decode(take(metaLen));
126854
+ if (!await refill(4)) {
126855
+ throw new Error("decodeFrames: truncated body length");
126856
+ }
126857
+ const bodyLen = new DataView(buffer2.buffer, buffer2.byteOffset, 4).getUint32(0, false);
126858
+ take(4);
126859
+ if (bodyLen > 0 && !await refill(bodyLen)) {
126651
126860
  throw new Error("decodeFrames: truncated body bytes");
126652
126861
  }
126653
126862
  yield { meta: meta2, body: buffer2.slice(0, bodyLen) };
126654
126863
  take(bodyLen);
126655
- } else {
126656
- yield { meta: meta2, body: new Uint8Array(0) };
126864
+ if (meta2._end === 1)
126865
+ return;
126657
126866
  }
126658
- if (meta2._end === 1)
126659
- return;
126867
+ } finally {
126868
+ closeQuietly(() => {
126869
+ var _a3;
126870
+ return (_a3 = chunks.return) == null ? void 0 : _a3.call(chunks);
126871
+ });
126872
+ }
126873
+ }
126874
+ function closeQuietly(close) {
126875
+ try {
126876
+ void Promise.resolve(close()).catch(() => {
126877
+ });
126878
+ } catch {
126660
126879
  }
126661
126880
  }
126662
126881
  async function* readerToIterator(reader) {
126663
- while (true) {
126664
- const { done, value } = await reader.read();
126665
- if (done)
126666
- return;
126667
- if (value)
126668
- yield value;
126882
+ try {
126883
+ while (true) {
126884
+ const { done, value } = await reader.read();
126885
+ if (done)
126886
+ return;
126887
+ if (value)
126888
+ yield value;
126889
+ }
126890
+ } finally {
126891
+ closeQuietly(() => reader.cancel());
126669
126892
  }
126670
126893
  }
126894
+ async function fetchV4(url2, init2, config2, opName) {
126895
+ return instrumentedFetch({
126896
+ method: init2.method,
126897
+ url: url2,
126898
+ headers: init2.headers,
126899
+ body: init2.body,
126900
+ dispatcher: getEventsDispatcher(config2),
126901
+ timeoutMs: null,
126902
+ logLabel: opName,
126903
+ buildError: async (response2) => errorFromV4Response(response2.status, headersToRecord(response2.headers), await response2.text(), opName, url2)
126904
+ });
126905
+ }
126906
+ function headersToRecord(headers2) {
126907
+ const out = {};
126908
+ headers2.forEach((value, key) => {
126909
+ out[key] = value;
126910
+ });
126911
+ return out;
126912
+ }
126671
126913
  const V4_RESPONSE_HEADERS = {
126672
126914
  eventId: "x-wf-event-id",
126673
126915
  runId: "x-wf-run-id",
@@ -126718,7 +126960,7 @@ function buildPostFrameMeta(input) {
126718
126960
  }
126719
126961
  return meta2;
126720
126962
  }
126721
- function throwForErrorResponse(statusCode, responseHeaders, errorBody, opName, url2) {
126963
+ function errorFromV4Response(statusCode, responseHeaders, errorBody, opName, url2) {
126722
126964
  let message2 = `v4 ${opName} failed: HTTP ${statusCode}`;
126723
126965
  let code2;
126724
126966
  try {
@@ -126731,37 +126973,12 @@ function throwForErrorResponse(statusCode, responseHeaders, errorBody, opName, u
126731
126973
  if (errorBody)
126732
126974
  message2 += ` ${errorBody}`;
126733
126975
  }
126734
- let retryAfter;
126735
- const retryAfterHeader = readHeader(responseHeaders, "retry-after");
126736
- if (retryAfterHeader) {
126737
- const parsed = parseInt(retryAfterHeader, 10);
126738
- if (!Number.isNaN(parsed))
126739
- retryAfter = parsed;
126740
- }
126741
- if (statusCode === 409)
126742
- throw new EntityConflictError(message2);
126743
- if (statusCode === 410)
126744
- throw new RunExpiredError(message2);
126745
- if (statusCode === 412)
126746
- throw new PreconditionFailedError(message2, { retryAfter });
126747
- if (statusCode === 425)
126748
- throw new TooEarlyError(message2, { retryAfter });
126749
- if (statusCode === 429) {
126750
- if (readHeader(responseHeaders, "x-vercel-mitigated") === "challenge") {
126751
- throw new WorkflowWorldError(`${message2} (x-vercel-mitigated=challenge)`, {
126752
- status: statusCode,
126753
- code: "TRANSPORT",
126754
- url: url2,
126755
- retryAfter
126756
- });
126757
- }
126758
- throw new ThrottleError(message2, { retryAfter });
126759
- }
126760
- throw new WorkflowWorldError(message2, {
126761
- status: statusCode,
126976
+ const retryAfter = parseRetryAfter(readHeader(responseHeaders, "retry-after"));
126977
+ return errorForResponse(statusCode, message2, {
126978
+ retryAfter,
126762
126979
  code: code2,
126763
126980
  url: url2,
126764
- retryAfter
126981
+ mitigated: readHeader(responseHeaders, "x-vercel-mitigated")
126765
126982
  });
126766
126983
  }
126767
126984
  async function createWorkflowRunEventV4(input, config2) {
@@ -126770,26 +126987,14 @@ async function createWorkflowRunEventV4(input, config2) {
126770
126987
  headers2.set("Content-Type", "application/octet-stream");
126771
126988
  const frame2 = encodeFrame(buildPostFrameMeta(input), input.payload ?? new Uint8Array(0));
126772
126989
  const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(input.runId)}/events/${encodeURIComponent(input.eventType)}`;
126773
- const response2 = await undiciExports.request(url2, {
126774
- method: "POST",
126775
- headers: Object.fromEntries(headers2.entries()),
126776
- body: frame2,
126777
- // getDispatcher() is typed `unknown` (undici's Dispatcher type is
126778
- // version-specific across @types/node majors); cast to the undici
126779
- // Dispatcher this module's own `request` expects.
126780
- dispatcher: getDispatcher(config2)
126781
- });
126782
- if (response2.statusCode < 200 || response2.statusCode >= 300) {
126783
- const errorBody = await response2.body.text();
126784
- throwForErrorResponse(response2.statusCode, response2.headers, errorBody, "createEvent", url2);
126785
- }
126786
- const eventId = response2.headers[V4_RESPONSE_HEADERS.eventId];
126787
- const runId = response2.headers[V4_RESPONSE_HEADERS.runId];
126788
- const createdAt = response2.headers[V4_RESPONSE_HEADERS.createdAt];
126990
+ const response2 = await fetchV4(url2, { method: "POST", headers: headers2, body: frame2 }, config2, "createEvent");
126991
+ const eventId = response2.headers.get(V4_RESPONSE_HEADERS.eventId);
126992
+ const runId = response2.headers.get(V4_RESPONSE_HEADERS.runId);
126993
+ const createdAt = response2.headers.get(V4_RESPONSE_HEADERS.createdAt);
126789
126994
  if (typeof eventId !== "string" || typeof runId !== "string" || typeof createdAt !== "string") {
126790
126995
  throw new Error("v4 createEvent: response missing required x-wf-* headers");
126791
126996
  }
126792
- const bodyBytes = new Uint8Array(await response2.body.arrayBuffer());
126997
+ const bodyBytes = new Uint8Array(await response2.arrayBuffer());
126793
126998
  const body2 = bodyBytes.byteLength > 0 ? decode(bodyBytes) : {};
126794
126999
  return { eventId, runId, createdAt, body: body2 };
126795
127000
  }
@@ -126804,19 +127009,8 @@ function readHeader(responseHeaders, name2) {
126804
127009
  async function getEventV4(runId, eventId, config2) {
126805
127010
  const { baseUrl, headers: headers2 } = await getHttpConfig(config2);
126806
127011
  const url2 = `${baseUrl}/v4/runs/${encodeURIComponent(runId)}/events/${encodeURIComponent(eventId)}`;
126807
- const response2 = await undiciExports.request(url2, {
126808
- method: "GET",
126809
- headers: Object.fromEntries(headers2.entries()),
126810
- // getDispatcher() is typed `unknown` (undici's Dispatcher type is
126811
- // version-specific across @types/node majors); cast to the undici
126812
- // Dispatcher this module's own `request` expects.
126813
- dispatcher: getDispatcher(config2)
126814
- });
126815
- if (response2.statusCode < 200 || response2.statusCode >= 300) {
126816
- const errorBody = await response2.body.text();
126817
- throwForErrorResponse(response2.statusCode, response2.headers, errorBody, "getEvent", url2);
126818
- }
126819
- const contentType = readHeader(response2.headers, "content-type");
127012
+ const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, "getEvent");
127013
+ const contentType = response2.headers.get("content-type");
126820
127014
  if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
126821
127015
  throw new Error(`v4 getEvent: expected ${V4_FRAME_CONTENT_TYPE}, got ${contentType ?? "(none)"}`);
126822
127016
  }
@@ -126827,19 +127021,8 @@ async function getEventV4(runId, eventId, config2) {
126827
127021
  throw new Error(`v4 getEvent: empty frame stream for ${eventId}`);
126828
127022
  }
126829
127023
  async function consumeListFrameStream(url2, headers2, config2, opName) {
126830
- const response2 = await undiciExports.request(url2, {
126831
- method: "GET",
126832
- headers: Object.fromEntries(headers2.entries()),
126833
- // getDispatcher() is typed `unknown` (undici's Dispatcher type is
126834
- // version-specific across @types/node majors); cast to the undici
126835
- // Dispatcher this module's own `request` expects.
126836
- dispatcher: getDispatcher(config2)
126837
- });
126838
- if (response2.statusCode < 200 || response2.statusCode >= 300) {
126839
- const errorBody = await response2.body.text();
126840
- throwForErrorResponse(response2.statusCode, response2.headers, errorBody, opName, url2);
126841
- }
126842
- const contentType = readHeader(response2.headers, "content-type");
127024
+ const response2 = await fetchV4(url2, { method: "GET", headers: headers2 }, config2, opName);
127025
+ const contentType = response2.headers.get("content-type");
126843
127026
  if (!(contentType == null ? void 0 : contentType.startsWith(V4_FRAME_CONTENT_TYPE))) {
126844
127027
  throw new Error(`v4 ${opName}: expected ${V4_FRAME_CONTENT_TYPE}, got ${contentType ?? "(none)"}`);
126845
127028
  }
@@ -127347,7 +127530,9 @@ async function createWorkflowRunEventInner(id2, data, params, config2) {
127347
127530
  wait: body2.wait,
127348
127531
  events: body2.events ? body2.events.map(coerceEventDates) : void 0,
127349
127532
  cursor: body2.cursor ?? void 0,
127350
- hasMore: body2.hasMore
127533
+ hasMore: body2.hasMore,
127534
+ // Server-supplied per-run event ceiling; absent from older servers.
127535
+ ...typeof body2.maxEvents === "number" ? { maxEvents: body2.maxEvents } : {}
127351
127536
  };
127352
127537
  }
127353
127538
  function filterHookData(hook, resolveData) {
@@ -127461,30 +127646,28 @@ function getStreamMutationTimeoutMs() {
127461
127646
  }
127462
127647
  return DEFAULT_STREAM_MUTATION_TIMEOUT_MS;
127463
127648
  }
127464
- async function fetchStreamMutation(url2, init2, operation) {
127465
- const timeoutMs = getStreamMutationTimeoutMs();
127466
- try {
127467
- return await fetch(url2, {
127468
- ...init2,
127469
- signal: AbortSignal.timeout(timeoutMs)
127470
- });
127471
- } catch (err) {
127472
- if (err instanceof Error && (err.name === "AbortError" || err.name === "TimeoutError")) {
127473
- throw new Error(`Stream ${operation} timed out after ${timeoutMs}ms`, {
127474
- cause: err
127475
- });
127476
- }
127477
- throw err;
127478
- }
127649
+ async function fetchStreamMutation(url2, init2, operation, config2) {
127650
+ const response2 = await instrumentedFetch({
127651
+ method: init2.method,
127652
+ url: url2.toString(),
127653
+ headers: init2.headers,
127654
+ body: init2.body,
127655
+ // Stream mutations go through the dedicated H2 stream dispatchers rather
127656
+ // than the global agent — see the note at the top of this file. Close is
127657
+ // idempotent (unlike chunk appends), so it gets the dispatcher that
127658
+ // retries 5xx, which the server's close-barrier protocol depends on.
127659
+ dispatcher: operation === "close" ? getStreamCloseDispatcher(config2) : getStreamDispatcher(config2),
127660
+ timeoutMs: getStreamMutationTimeoutMs(),
127661
+ logLabel: url2.pathname,
127662
+ buildError: async (res) => createStreamRequestError(operation, url2, res, await res.text())
127663
+ });
127664
+ await response2.text();
127479
127665
  }
127480
127666
  function createStreamRequestError(operation, url2, response2, text2) {
127481
- const context = [`PUT ${url2.origin}${url2.pathname}`];
127482
- for (const header of ["x-vercel-id", "x-vercel-error"]) {
127483
- const value = response2.headers.get(header);
127484
- if (value) {
127485
- context.push(`${header}=${value}`);
127486
- }
127487
- }
127667
+ const context = [
127668
+ `PUT ${url2.origin}${url2.pathname}`,
127669
+ ...getVercelDiagnostics(response2.headers)
127670
+ ];
127488
127671
  return new Error(`Stream ${operation} failed: HTTP ${response2.status} (${context.join("; ")}): ${text2}`);
127489
127672
  }
127490
127673
  function encodeMultiChunks(chunks) {
@@ -127526,15 +127709,11 @@ function createStreamer(config2) {
127526
127709
  const resolvedRunId = await runId;
127527
127710
  const httpConfig = await getHttpConfig(config2);
127528
127711
  const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
127529
- const response2 = await fetchStreamMutation(url2, {
127712
+ await fetchStreamMutation(url2, {
127530
127713
  method: "PUT",
127531
127714
  body: chunk,
127532
127715
  headers: httpConfig.headers
127533
- }, "write");
127534
- const text2 = await response2.text();
127535
- if (!response2.ok) {
127536
- throw createStreamRequestError("write", url2, response2, text2);
127537
- }
127716
+ }, "write", config2);
127538
127717
  },
127539
127718
  async writeToStreamMulti(name2, runId, chunks) {
127540
127719
  if (chunks.length === 0)
@@ -127546,15 +127725,11 @@ function createStreamer(config2) {
127546
127725
  const batch = chunks.slice(i, i + MAX_CHUNKS_PER_REQUEST);
127547
127726
  const body2 = encodeMultiChunks(batch);
127548
127727
  const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
127549
- const response2 = await fetchStreamMutation(url2, {
127728
+ await fetchStreamMutation(url2, {
127550
127729
  method: "PUT",
127551
127730
  body: body2,
127552
127731
  headers: httpConfig.headers
127553
- }, "write");
127554
- const text2 = await response2.text();
127555
- if (!response2.ok) {
127556
- throw createStreamRequestError("write", url2, response2, text2);
127557
- }
127732
+ }, "write", config2);
127558
127733
  }
127559
127734
  },
127560
127735
  async closeStream(name2, runId) {
@@ -127562,14 +127737,10 @@ function createStreamer(config2) {
127562
127737
  const httpConfig = await getHttpConfig(config2);
127563
127738
  httpConfig.headers.set("X-Stream-Done", "true");
127564
127739
  const url2 = getStreamUrl(name2, resolvedRunId, httpConfig);
127565
- const response2 = await fetchStreamMutation(url2, {
127740
+ await fetchStreamMutation(url2, {
127566
127741
  method: "PUT",
127567
127742
  headers: httpConfig.headers
127568
- }, "close");
127569
- const text2 = await response2.text();
127570
- if (!response2.ok) {
127571
- throw createStreamRequestError("close", url2, response2, text2);
127572
- }
127743
+ }, "close", config2);
127573
127744
  },
127574
127745
  async readFromStream(name2, startIndex) {
127575
127746
  const httpConfig = await getHttpConfig(config2);
@@ -127578,13 +127749,16 @@ function createStreamer(config2) {
127578
127749
  url2.searchParams.set("startIndex", String(startIndex));
127579
127750
  }
127580
127751
  const abortController = new AbortController();
127581
- const response2 = await fetch(url2, {
127752
+ const response2 = await instrumentedFetch({
127753
+ method: "GET",
127754
+ url: url2.toString(),
127582
127755
  headers: httpConfig.headers,
127583
- signal: abortController.signal
127756
+ dispatcher: void 0,
127757
+ timeoutMs: null,
127758
+ signal: abortController.signal,
127759
+ logLabel: url2.pathname,
127760
+ buildError: (res) => new Error(`Failed to fetch stream: ${res.status}`)
127584
127761
  });
127585
- if (!response2.ok) {
127586
- throw new Error(`Failed to fetch stream: ${response2.status}`);
127587
- }
127588
127762
  if (!response2.body) {
127589
127763
  throw new Error("No response body for stream");
127590
127764
  }
@@ -127640,12 +127814,15 @@ function createStreamer(config2) {
127640
127814
  async listStreamsByRunId(runId) {
127641
127815
  const httpConfig = await getHttpConfig(config2);
127642
127816
  const url2 = new URL(`${httpConfig.baseUrl}/v2/runs/${encodeURIComponent(runId)}/streams`);
127643
- const response2 = await fetch(url2, {
127644
- headers: httpConfig.headers
127817
+ const response2 = await instrumentedFetch({
127818
+ method: "GET",
127819
+ url: url2.toString(),
127820
+ headers: httpConfig.headers,
127821
+ dispatcher: void 0,
127822
+ timeoutMs: null,
127823
+ logLabel: url2.pathname,
127824
+ buildError: (res) => new Error(`Failed to list streams: ${res.status}`)
127645
127825
  });
127646
- if (!response2.ok) {
127647
- throw new Error(`Failed to list streams: ${response2.status}`);
127648
- }
127649
127826
  return await response2.json();
127650
127827
  }
127651
127828
  };
@@ -132172,7 +132349,7 @@ function getRunCapabilities(workflowCoreVersion) {
132172
132349
  return result;
132173
132350
  }
132174
132351
  function waitUntil(promise2) {
132175
- void import("./index-B8YoYr9f.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
132352
+ void import("./index-CMfOrLiJ.js").then((n) => n.i).then(({ waitUntil: waitUntil2 }) => {
132176
132353
  waitUntil2(promise2);
132177
132354
  });
132178
132355
  }