@workflow/world-testing 4.0.1-beta.36 → 4.0.1-beta.37

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.
@@ -1525,7 +1525,7 @@ var require_token_util = __commonJS({
1525
1525
  saveToken: /* @__PURE__ */ __name(() => saveToken, "saveToken")
1526
1526
  });
1527
1527
  module2.exports = __toCommonJS2(token_util_exports);
1528
- var path4 = __toESM2(require("path"));
1528
+ var path5 = __toESM2(require("path"));
1529
1529
  var fs2 = __toESM2(require("fs"));
1530
1530
  var import_token_error = require_token_error();
1531
1531
  var import_token_io = require_token_io();
@@ -1535,7 +1535,7 @@ var require_token_util = __commonJS({
1535
1535
  if (!dataDir) {
1536
1536
  return null;
1537
1537
  }
1538
- return path4.join(dataDir, vercelFolder);
1538
+ return path5.join(dataDir, vercelFolder);
1539
1539
  }
1540
1540
  __name(getVercelDataDir, "getVercelDataDir");
1541
1541
  function getVercelCliToken() {
@@ -1543,7 +1543,7 @@ var require_token_util = __commonJS({
1543
1543
  if (!dataDir) {
1544
1544
  return null;
1545
1545
  }
1546
- const tokenPath = path4.join(dataDir, "auth.json");
1546
+ const tokenPath = path5.join(dataDir, "auth.json");
1547
1547
  if (!fs2.existsSync(tokenPath)) {
1548
1548
  return null;
1549
1549
  }
@@ -1590,7 +1590,7 @@ var require_token_util = __commonJS({
1590
1590
  throw new import_token_error.VercelOidcTokenError("Unable to find root directory");
1591
1591
  }
1592
1592
  try {
1593
- const prjPath = path4.join(dir, ".vercel", "project.json");
1593
+ const prjPath = path5.join(dir, ".vercel", "project.json");
1594
1594
  if (!fs2.existsSync(prjPath)) {
1595
1595
  throw new import_token_error.VercelOidcTokenError("project.json not found");
1596
1596
  }
@@ -1614,9 +1614,9 @@ var require_token_util = __commonJS({
1614
1614
  if (!dir) {
1615
1615
  throw new import_token_error.VercelOidcTokenError("Unable to find user data directory");
1616
1616
  }
1617
- const tokenPath = path4.join(dir, "com.vercel.token", `${projectId}.json`);
1617
+ const tokenPath = path5.join(dir, "com.vercel.token", `${projectId}.json`);
1618
1618
  const tokenJson = JSON.stringify(token);
1619
- fs2.mkdirSync(path4.dirname(tokenPath), {
1619
+ fs2.mkdirSync(path5.dirname(tokenPath), {
1620
1620
  mode: 504,
1621
1621
  recursive: true
1622
1622
  });
@@ -1635,7 +1635,7 @@ var require_token_util = __commonJS({
1635
1635
  if (!dir) {
1636
1636
  return null;
1637
1637
  }
1638
- const tokenPath = path4.join(dir, "com.vercel.token", `${projectId}.json`);
1638
+ const tokenPath = path5.join(dir, "com.vercel.token", `${projectId}.json`);
1639
1639
  if (!fs2.existsSync(tokenPath)) {
1640
1640
  return null;
1641
1641
  }
@@ -2908,14 +2908,14 @@ var require_util = __commonJS({
2908
2908
  }
2909
2909
  const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
2910
2910
  let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
2911
- let path4 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
2911
+ let path5 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
2912
2912
  if (origin[origin.length - 1] === "/") {
2913
2913
  origin = origin.slice(0, origin.length - 1);
2914
2914
  }
2915
- if (path4 && path4[0] !== "/") {
2916
- path4 = `/${path4}`;
2915
+ if (path5 && path5[0] !== "/") {
2916
+ path5 = `/${path5}`;
2917
2917
  }
2918
- return new URL(`${origin}${path4}`);
2918
+ return new URL(`${origin}${path5}`);
2919
2919
  }
2920
2920
  if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
2921
2921
  throw new InvalidArgumentError("Invalid URL protocol: the URL must start with `http:` or `https:`.");
@@ -3401,20 +3401,20 @@ var require_diagnostics = __commonJS({
3401
3401
  debuglog("connection to %s using %s%s errored - %s", `${host}${port ? `:${port}` : ""}`, protocol, version3, error45.message);
3402
3402
  });
3403
3403
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
3404
- const { request: { method, path: path4, origin } } = evt;
3405
- debuglog("sending request to %s %s/%s", method, origin, path4);
3404
+ const { request: { method, path: path5, origin } } = evt;
3405
+ debuglog("sending request to %s %s/%s", method, origin, path5);
3406
3406
  });
3407
3407
  diagnosticsChannel.channel("undici:request:headers").subscribe((evt) => {
3408
- const { request: { method, path: path4, origin }, response: { statusCode } } = evt;
3409
- debuglog("received response to %s %s/%s - HTTP %d", method, origin, path4, statusCode);
3408
+ const { request: { method, path: path5, origin }, response: { statusCode } } = evt;
3409
+ debuglog("received response to %s %s/%s - HTTP %d", method, origin, path5, statusCode);
3410
3410
  });
3411
3411
  diagnosticsChannel.channel("undici:request:trailers").subscribe((evt) => {
3412
- const { request: { method, path: path4, origin } } = evt;
3413
- debuglog("trailers received from %s %s/%s", method, origin, path4);
3412
+ const { request: { method, path: path5, origin } } = evt;
3413
+ debuglog("trailers received from %s %s/%s", method, origin, path5);
3414
3414
  });
3415
3415
  diagnosticsChannel.channel("undici:request:error").subscribe((evt) => {
3416
- const { request: { method, path: path4, origin }, error: error45 } = evt;
3417
- debuglog("request to %s %s/%s errored - %s", method, origin, path4, error45.message);
3416
+ const { request: { method, path: path5, origin }, error: error45 } = evt;
3417
+ debuglog("request to %s %s/%s errored - %s", method, origin, path5, error45.message);
3418
3418
  });
3419
3419
  isClientSet = true;
3420
3420
  }
@@ -3434,8 +3434,8 @@ var require_diagnostics = __commonJS({
3434
3434
  debuglog("connection to %s%s using %s%s errored - %s", host, port ? `:${port}` : "", protocol, version3, error45.message);
3435
3435
  });
3436
3436
  diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
3437
- const { request: { method, path: path4, origin } } = evt;
3438
- debuglog("sending request to %s %s/%s", method, origin, path4);
3437
+ const { request: { method, path: path5, origin } } = evt;
3438
+ debuglog("sending request to %s %s/%s", method, origin, path5);
3439
3439
  });
3440
3440
  }
3441
3441
  diagnosticsChannel.channel("undici:websocket:open").subscribe((evt) => {
@@ -3476,14 +3476,14 @@ var require_request = __commonJS({
3476
3476
  static {
3477
3477
  __name(this, "Request");
3478
3478
  }
3479
- constructor(origin, { path: path4, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, throwOnError, expectContinue, servername }, handler) {
3480
- if (typeof path4 !== "string") {
3479
+ constructor(origin, { path: path5, method, body, headers, query, idempotent, blocking, upgrade, headersTimeout, bodyTimeout, reset, throwOnError, expectContinue, servername }, handler) {
3480
+ if (typeof path5 !== "string") {
3481
3481
  throw new InvalidArgumentError("path must be a string");
3482
3482
  }
3483
- else if (path4[0] !== "/" && !(path4.startsWith("http://") || path4.startsWith("https://")) && method !== "CONNECT") {
3483
+ else if (path5[0] !== "/" && !(path5.startsWith("http://") || path5.startsWith("https://")) && method !== "CONNECT") {
3484
3484
  throw new InvalidArgumentError("path must be an absolute URL or start with a slash");
3485
3485
  }
3486
- else if (invalidPathRegex.test(path4)) {
3486
+ else if (invalidPathRegex.test(path5)) {
3487
3487
  throw new InvalidArgumentError("invalid request path");
3488
3488
  }
3489
3489
  if (typeof method !== "string") {
@@ -3555,7 +3555,7 @@ var require_request = __commonJS({
3555
3555
  this.completed = false;
3556
3556
  this.aborted = false;
3557
3557
  this.upgrade = upgrade || null;
3558
- this.path = query ? buildURL(path4, query) : path4;
3558
+ this.path = query ? buildURL(path5, query) : path5;
3559
3559
  this.origin = origin;
3560
3560
  this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
3561
3561
  this.blocking = blocking == null ? false : blocking;
@@ -7720,7 +7720,7 @@ var require_client_h1 = __commonJS({
7720
7720
  var timers = require_timers();
7721
7721
  var { RequestContentLengthMismatchError, ResponseContentLengthMismatchError, RequestAbortedError, HeadersTimeoutError, HeadersOverflowError, SocketError, InformationalError, BodyTimeoutError, HTTPParserError, ResponseExceededMaxSizeError } = require_errors();
7722
7722
  var { kUrl, kReset, kClient, kParser, kBlocking, kRunning, kPending, kSize, kWriting, kQueue, kNoRef, kKeepAliveDefaultTimeout, kHostHeader, kPendingIdx, kRunningIdx, kError, kPipelining, kSocket, kKeepAliveTimeoutValue, kMaxHeadersSize, kKeepAliveMaxTimeout, kKeepAliveTimeoutThreshold, kHeadersTimeout, kBodyTimeout, kStrictContentLength, kMaxRequests, kCounter, kMaxResponseSize, kOnError, kResume, kHTTPContext } = require_symbols();
7723
- var constants = require_constants2();
7723
+ var constants2 = require_constants2();
7724
7724
  var EMPTY_BUF = Buffer.alloc(0);
7725
7725
  var FastBuffer = Buffer[Symbol.species];
7726
7726
  var addListener = util.addListener;
@@ -7796,7 +7796,7 @@ var require_client_h1 = __commonJS({
7796
7796
  constructor(client, socket, { exports: exports3 }) {
7797
7797
  assert2(Number.isFinite(client[kMaxHeadersSize]) && client[kMaxHeadersSize] > 0);
7798
7798
  this.llhttp = exports3;
7799
- this.ptr = this.llhttp.llhttp_alloc(constants.TYPE.RESPONSE);
7799
+ this.ptr = this.llhttp.llhttp_alloc(constants2.TYPE.RESPONSE);
7800
7800
  this.client = client;
7801
7801
  this.socket = socket;
7802
7802
  this.timeout = null;
@@ -7895,21 +7895,21 @@ var require_client_h1 = __commonJS({
7895
7895
  currentBufferRef = null;
7896
7896
  }
7897
7897
  const offset = llhttp.llhttp_get_error_pos(this.ptr) - currentBufferPtr;
7898
- if (ret === constants.ERROR.PAUSED_UPGRADE) {
7898
+ if (ret === constants2.ERROR.PAUSED_UPGRADE) {
7899
7899
  this.onUpgrade(data.slice(offset));
7900
7900
  }
7901
- else if (ret === constants.ERROR.PAUSED) {
7901
+ else if (ret === constants2.ERROR.PAUSED) {
7902
7902
  this.paused = true;
7903
7903
  socket.unshift(data.slice(offset));
7904
7904
  }
7905
- else if (ret !== constants.ERROR.OK) {
7905
+ else if (ret !== constants2.ERROR.OK) {
7906
7906
  const ptr = llhttp.llhttp_get_error_reason(this.ptr);
7907
7907
  let message = "";
7908
7908
  if (ptr) {
7909
7909
  const len = new Uint8Array(llhttp.memory.buffer, ptr).indexOf(0);
7910
7910
  message = "Response does not match the HTTP/1.1 protocol (" + Buffer.from(llhttp.memory.buffer, ptr, len).toString() + ")";
7911
7911
  }
7912
- throw new HTTPParserError(message, constants.ERROR[ret], data.slice(offset));
7912
+ throw new HTTPParserError(message, constants2.ERROR[ret], data.slice(offset));
7913
7913
  }
7914
7914
  }
7915
7915
  catch (err) {
@@ -8099,7 +8099,7 @@ var require_client_h1 = __commonJS({
8099
8099
  socket[kBlocking] = false;
8100
8100
  client[kResume]();
8101
8101
  }
8102
- return pause ? constants.ERROR.PAUSED : 0;
8102
+ return pause ? constants2.ERROR.PAUSED : 0;
8103
8103
  }
8104
8104
  onBody(buf) {
8105
8105
  const { client, socket, statusCode, maxResponseSize } = this;
@@ -8121,7 +8121,7 @@ var require_client_h1 = __commonJS({
8121
8121
  }
8122
8122
  this.bytesRead += buf.length;
8123
8123
  if (request.onData(buf) === false) {
8124
- return constants.ERROR.PAUSED;
8124
+ return constants2.ERROR.PAUSED;
8125
8125
  }
8126
8126
  }
8127
8127
  onMessageComplete() {
@@ -8156,15 +8156,15 @@ var require_client_h1 = __commonJS({
8156
8156
  if (socket[kWriting]) {
8157
8157
  assert2(client[kRunning] === 0);
8158
8158
  util.destroy(socket, new InformationalError("reset"));
8159
- return constants.ERROR.PAUSED;
8159
+ return constants2.ERROR.PAUSED;
8160
8160
  }
8161
8161
  else if (!shouldKeepAlive) {
8162
8162
  util.destroy(socket, new InformationalError("reset"));
8163
- return constants.ERROR.PAUSED;
8163
+ return constants2.ERROR.PAUSED;
8164
8164
  }
8165
8165
  else if (socket[kReset] && client[kRunning] === 0) {
8166
8166
  util.destroy(socket, new InformationalError("reset"));
8167
- return constants.ERROR.PAUSED;
8167
+ return constants2.ERROR.PAUSED;
8168
8168
  }
8169
8169
  else if (client[kPipelining] == null || client[kPipelining] === 1) {
8170
8170
  setImmediate(() => client[kResume]());
@@ -8338,7 +8338,7 @@ var require_client_h1 = __commonJS({
8338
8338
  }
8339
8339
  __name(shouldSendContentLength, "shouldSendContentLength");
8340
8340
  function writeH1(client, request) {
8341
- const { method, path: path4, host, upgrade, blocking, reset } = request;
8341
+ const { method, path: path5, host, upgrade, blocking, reset } = request;
8342
8342
  let { body, headers, contentLength } = request;
8343
8343
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
8344
8344
  if (util.isFormDataLike(body)) {
@@ -8406,7 +8406,7 @@ var require_client_h1 = __commonJS({
8406
8406
  if (blocking) {
8407
8407
  socket[kBlocking] = true;
8408
8408
  }
8409
- let header = `${method} ${path4} HTTP/1.1\r
8409
+ let header = `${method} ${path5} HTTP/1.1\r
8410
8410
  `;
8411
8411
  if (typeof host === "string") {
8412
8412
  header += `host: ${host}\r
@@ -8970,7 +8970,7 @@ var require_client_h2 = __commonJS({
8970
8970
  __name(shouldSendContentLength, "shouldSendContentLength");
8971
8971
  function writeH2(client, request) {
8972
8972
  const session = client[kHTTP2Session];
8973
- const { method, path: path4, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
8973
+ const { method, path: path5, host, upgrade, expectContinue, signal, headers: reqHeaders } = request;
8974
8974
  let { body } = request;
8975
8975
  if (upgrade) {
8976
8976
  util.errorRequest(client, request, new Error("Upgrade not supported for H2"));
@@ -9045,7 +9045,7 @@ var require_client_h2 = __commonJS({
9045
9045
  });
9046
9046
  return true;
9047
9047
  }
9048
- headers[HTTP2_HEADER_PATH] = path4;
9048
+ headers[HTTP2_HEADER_PATH] = path5;
9049
9049
  headers[HTTP2_HEADER_SCHEME] = "https";
9050
9050
  const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
9051
9051
  if (body && typeof body.read === "function") {
@@ -9383,9 +9383,9 @@ var require_redirect_handler = __commonJS({
9383
9383
  return this.handler.onHeaders(statusCode, headers, resume, statusText);
9384
9384
  }
9385
9385
  const { origin, pathname, search } = util.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
9386
- const path4 = search ? `${pathname}${search}` : pathname;
9386
+ const path5 = search ? `${pathname}${search}` : pathname;
9387
9387
  this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
9388
- this.opts.path = path4;
9388
+ this.opts.path = path5;
9389
9389
  this.opts.origin = origin;
9390
9390
  this.opts.maxRedirections = 0;
9391
9391
  this.opts.query = null;
@@ -10642,8 +10642,8 @@ var require_proxy_agent = __commonJS({
10642
10642
  if (onHeaders)
10643
10643
  onHeaders.call(this, statusCode, data, resume);
10644
10644
  };
10645
- const { origin, path: path4 = "/", headers = {} } = opts;
10646
- opts.path = origin + path4;
10645
+ const { origin, path: path5 = "/", headers = {} } = opts;
10646
+ opts.path = origin + path5;
10647
10647
  if (!("host" in headers) && !("Host" in headers)) {
10648
10648
  const { host } = new URL2(origin);
10649
10649
  headers.host = host;
@@ -12690,13 +12690,13 @@ var require_mock_utils = __commonJS({
12690
12690
  return true;
12691
12691
  }
12692
12692
  __name(matchHeaders, "matchHeaders");
12693
- function safeUrl(path4) {
12694
- if (typeof path4 !== "string") {
12695
- return path4;
12693
+ function safeUrl(path5) {
12694
+ if (typeof path5 !== "string") {
12695
+ return path5;
12696
12696
  }
12697
- const pathSegments = path4.split("?");
12697
+ const pathSegments = path5.split("?");
12698
12698
  if (pathSegments.length !== 2) {
12699
- return path4;
12699
+ return path5;
12700
12700
  }
12701
12701
  const qp = new URLSearchParams(pathSegments.pop());
12702
12702
  qp.sort();
@@ -12706,8 +12706,8 @@ var require_mock_utils = __commonJS({
12706
12706
  ].join("?");
12707
12707
  }
12708
12708
  __name(safeUrl, "safeUrl");
12709
- function matchKey(mockDispatch2, { path: path4, method, body, headers }) {
12710
- const pathMatch = matchValue(mockDispatch2.path, path4);
12709
+ function matchKey(mockDispatch2, { path: path5, method, body, headers }) {
12710
+ const pathMatch = matchValue(mockDispatch2.path, path5);
12711
12711
  const methodMatch = matchValue(mockDispatch2.method, method);
12712
12712
  const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
12713
12713
  const headersMatch = matchHeaders(mockDispatch2, headers);
@@ -12735,7 +12735,7 @@ var require_mock_utils = __commonJS({
12735
12735
  function getMockDispatch(mockDispatches, key) {
12736
12736
  const basePath = key.query ? buildURL(key.path, key.query) : key.path;
12737
12737
  const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
12738
- let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path4 }) => matchValue(safeUrl(path4), resolvedPath));
12738
+ let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path5 }) => matchValue(safeUrl(path5), resolvedPath));
12739
12739
  if (matchedMockDispatches.length === 0) {
12740
12740
  throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
12741
12741
  }
@@ -12793,9 +12793,9 @@ var require_mock_utils = __commonJS({
12793
12793
  }
12794
12794
  __name(deleteMockDispatch, "deleteMockDispatch");
12795
12795
  function buildKey(opts) {
12796
- const { path: path4, method, body, headers, query } = opts;
12796
+ const { path: path5, method, body, headers, query } = opts;
12797
12797
  return {
12798
- path: path4,
12798
+ path: path5,
12799
12799
  method,
12800
12800
  body,
12801
12801
  headers,
@@ -13295,10 +13295,10 @@ var require_pending_interceptors_formatter = __commonJS({
13295
13295
  });
13296
13296
  }
13297
13297
  format(pendingInterceptors) {
13298
- const withPrettyHeaders = pendingInterceptors.map(({ method, path: path4, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13298
+ const withPrettyHeaders = pendingInterceptors.map(({ method, path: path5, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
13299
13299
  Method: method,
13300
13300
  Origin: origin,
13301
- Path: path4,
13301
+ Path: path5,
13302
13302
  "Status code": statusCode,
13303
13303
  Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
13304
13304
  Invocations: timesInvoked,
@@ -18286,9 +18286,9 @@ var require_util6 = __commonJS({
18286
18286
  }
18287
18287
  }
18288
18288
  __name(validateCookieValue, "validateCookieValue");
18289
- function validateCookiePath(path4) {
18290
- for (let i = 0; i < path4.length; ++i) {
18291
- const code = path4.charCodeAt(i);
18289
+ function validateCookiePath(path5) {
18290
+ for (let i = 0; i < path5.length; ++i) {
18291
+ const code = path5.charCodeAt(i);
18292
18292
  if (code < 32 || // exclude CTLs (0-31)
18293
18293
  code === 127 || // DEL
18294
18294
  code === 59) {
@@ -21014,11 +21014,11 @@ var require_undici = __commonJS({
21014
21014
  if (typeof opts.path !== "string") {
21015
21015
  throw new InvalidArgumentError("invalid opts.path");
21016
21016
  }
21017
- let path4 = opts.path;
21017
+ let path5 = opts.path;
21018
21018
  if (!opts.path.startsWith("/")) {
21019
- path4 = `/${path4}`;
21019
+ path5 = `/${path5}`;
21020
21020
  }
21021
- url2 = new URL(util.parseOrigin(url2).origin + path4);
21021
+ url2 = new URL(util.parseOrigin(url2).origin + path5);
21022
21022
  }
21023
21023
  else {
21024
21024
  if (!opts) {
@@ -24522,8 +24522,31 @@ async function addition(num, num2) {
24522
24522
  __name(addition, "addition");
24523
24523
  addition.workflowId = "workflow//workflows/addition.ts//addition";
24524
24524
  registerStepFunction("step//workflows/addition.ts//add", add);
24525
- // ../utils/dist/index.js
24526
- var import_ms = __toESM(require_ms(), 1);
24525
+ // workflows/noop.ts
24526
+ var count = 0;
24527
+ async function noop(_i) {
24528
+ count++;
24529
+ return count;
24530
+ }
24531
+ __name(noop, "noop");
24532
+ async function brokenWf() {
24533
+ throw new Error("You attempted to execute workflow brokenWf function directly. To start a workflow, use start(brokenWf) from workflow/api");
24534
+ }
24535
+ __name(brokenWf, "brokenWf");
24536
+ brokenWf.workflowId = "workflow//workflows/noop.ts//brokenWf";
24537
+ registerStepFunction("step//workflows/noop.ts//noop", noop);
24538
+ // workflows/null-byte.ts
24539
+ async function nullByteStep() {
24540
+ return "null byte \0";
24541
+ }
24542
+ __name(nullByteStep, "nullByteStep");
24543
+ async function nullByteWorkflow() {
24544
+ throw new Error("You attempted to execute workflow nullByteWorkflow function directly. To start a workflow, use start(nullByteWorkflow) from workflow/api");
24545
+ }
24546
+ __name(nullByteWorkflow, "nullByteWorkflow");
24547
+ nullByteWorkflow.workflowId = "workflow//workflows/null-byte.ts//nullByteWorkflow";
24548
+ registerStepFunction("step//workflows/null-byte.ts//nullByteStep", nullByteStep);
24549
+ // ../utils/dist/promise.js
24527
24550
  function once(fn) {
24528
24551
  const result = {
24529
24552
  get value() {
@@ -24537,6 +24560,8 @@ function once(fn) {
24537
24560
  return result;
24538
24561
  }
24539
24562
  __name(once, "once");
24563
+ // ../utils/dist/time.js
24564
+ var import_ms = __toESM(require_ms(), 1);
24540
24565
  function parseDurationToDate(param) {
24541
24566
  if (typeof param === "string") {
24542
24567
  const durationMs = (0, import_ms.default)(param);
@@ -25361,7 +25386,7 @@ function monotonicFactory(prng) {
25361
25386
  __name(monotonicFactory, "monotonicFactory");
25362
25387
  // ../core/dist/runtime/world.js
25363
25388
  var import_node_module = require("node:module");
25364
- var import_node_path4 = require("node:path");
25389
+ var import_node_path5 = require("node:path");
25365
25390
  // ../utils/dist/get-port.js
25366
25391
  var import_promises = require("node:fs/promises");
25367
25392
  var import_node_util = require("node:util");
@@ -25636,6 +25661,165 @@ async function resolveBaseUrl(config3) {
25636
25661
  throw new Error("Unable to resolve base URL for workflow queue.");
25637
25662
  }
25638
25663
  __name(resolveBaseUrl, "resolveBaseUrl");
25664
+ // ../world-local/dist/init.js
25665
+ var import_node_fs = require("node:fs");
25666
+ var import_node_path = __toESM(require("node:path"), 1);
25667
+ var PACKAGE_NAME = "@workflow/world-local";
25668
+ var PACKAGE_VERSION = "4.0.1-beta.20";
25669
+ var VERSION_FILENAME = "version.txt";
25670
+ var DataDirAccessError = class extends Error {
25671
+ static {
25672
+ __name(this, "DataDirAccessError");
25673
+ }
25674
+ dataDir;
25675
+ code;
25676
+ constructor(message, dataDir, code) {
25677
+ super(message);
25678
+ this.name = "DataDirAccessError";
25679
+ this.dataDir = dataDir;
25680
+ this.code = code;
25681
+ }
25682
+ };
25683
+ var DataDirVersionError = class extends Error {
25684
+ static {
25685
+ __name(this, "DataDirVersionError");
25686
+ }
25687
+ oldVersion;
25688
+ newVersion;
25689
+ suggestedVersion;
25690
+ constructor(message, oldVersion, newVersion, suggestedVersion) {
25691
+ super(message);
25692
+ this.name = "DataDirVersionError";
25693
+ this.oldVersion = oldVersion;
25694
+ this.newVersion = newVersion;
25695
+ this.suggestedVersion = suggestedVersion;
25696
+ }
25697
+ };
25698
+ function parseVersion(versionString) {
25699
+ const match = versionString.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);
25700
+ if (!match) {
25701
+ throw new Error(`Invalid version string: "${versionString}"`);
25702
+ }
25703
+ return {
25704
+ major: parseInt(match[1], 10),
25705
+ minor: parseInt(match[2], 10),
25706
+ patch: parseInt(match[3], 10),
25707
+ prerelease: match[4],
25708
+ raw: versionString
25709
+ };
25710
+ }
25711
+ __name(parseVersion, "parseVersion");
25712
+ function formatVersion(version3) {
25713
+ const base = `${version3.major}.${version3.minor}.${version3.patch}`;
25714
+ return version3.prerelease ? `${base}-${version3.prerelease}` : base;
25715
+ }
25716
+ __name(formatVersion, "formatVersion");
25717
+ function parseVersionFile(content) {
25718
+ const trimmed = content.trim();
25719
+ const lastAtIndex = trimmed.lastIndexOf("@");
25720
+ if (lastAtIndex <= 0) {
25721
+ throw new Error(`Invalid version file content: "${content}"`);
25722
+ }
25723
+ const packageName = trimmed.substring(0, lastAtIndex);
25724
+ const versionString = trimmed.substring(lastAtIndex + 1);
25725
+ return {
25726
+ packageName,
25727
+ version: parseVersion(versionString)
25728
+ };
25729
+ }
25730
+ __name(parseVersionFile, "parseVersionFile");
25731
+ function formatVersionFile(packageName, version3) {
25732
+ return `${packageName}@${formatVersion(version3)}`;
25733
+ }
25734
+ __name(formatVersionFile, "formatVersionFile");
25735
+ function upgradeVersion(oldVersion, newVersion) {
25736
+ console.log(`[world-local] Upgrading from version ${formatVersion(oldVersion)} to ${formatVersion(newVersion)}`);
25737
+ }
25738
+ __name(upgradeVersion, "upgradeVersion");
25739
+ function ensureDataDir(dataDir) {
25740
+ const absolutePath = import_node_path.default.resolve(dataDir);
25741
+ try {
25742
+ (0, import_node_fs.mkdirSync)(absolutePath, {
25743
+ recursive: true
25744
+ });
25745
+ }
25746
+ catch (error45) {
25747
+ const nodeError = error45;
25748
+ if (nodeError.code !== "EEXIST") {
25749
+ throw new DataDirAccessError(`Failed to create data directory "${absolutePath}": ${nodeError.message}`, absolutePath, nodeError.code);
25750
+ }
25751
+ }
25752
+ try {
25753
+ (0, import_node_fs.accessSync)(absolutePath, import_node_fs.constants.R_OK);
25754
+ }
25755
+ catch (error45) {
25756
+ const nodeError = error45;
25757
+ throw new DataDirAccessError(`Data directory "${absolutePath}" is not readable: ${nodeError.message}`, absolutePath, nodeError.code);
25758
+ }
25759
+ const testFile = import_node_path.default.join(absolutePath, `.workflow-write-test-${Date.now()}`);
25760
+ try {
25761
+ (0, import_node_fs.writeFileSync)(testFile, "");
25762
+ (0, import_node_fs.unlinkSync)(testFile);
25763
+ }
25764
+ catch (error45) {
25765
+ const nodeError = error45;
25766
+ throw new DataDirAccessError(`Data directory "${absolutePath}" is not writable: ${nodeError.message}`, absolutePath, nodeError.code);
25767
+ }
25768
+ }
25769
+ __name(ensureDataDir, "ensureDataDir");
25770
+ function readVersionFile(dataDir) {
25771
+ const versionFilePath = import_node_path.default.join(import_node_path.default.resolve(dataDir), VERSION_FILENAME);
25772
+ try {
25773
+ const content = (0, import_node_fs.readFileSync)(versionFilePath, "utf-8");
25774
+ return parseVersionFile(content);
25775
+ }
25776
+ catch (error45) {
25777
+ const nodeError = error45;
25778
+ if (nodeError.code === "ENOENT") {
25779
+ return null;
25780
+ }
25781
+ throw error45;
25782
+ }
25783
+ }
25784
+ __name(readVersionFile, "readVersionFile");
25785
+ function writeVersionFile(dataDir, version3) {
25786
+ const versionFilePath = import_node_path.default.join(import_node_path.default.resolve(dataDir), VERSION_FILENAME);
25787
+ const content = formatVersionFile(PACKAGE_NAME, version3);
25788
+ (0, import_node_fs.writeFileSync)(versionFilePath, content);
25789
+ }
25790
+ __name(writeVersionFile, "writeVersionFile");
25791
+ function getSuggestedDowngradeVersion(oldVersion, suggestedVersion) {
25792
+ if (suggestedVersion) {
25793
+ return suggestedVersion;
25794
+ }
25795
+ return formatVersion(oldVersion);
25796
+ }
25797
+ __name(getSuggestedDowngradeVersion, "getSuggestedDowngradeVersion");
25798
+ function initDataDir(dataDir) {
25799
+ ensureDataDir(dataDir);
25800
+ const currentVersion = parseVersion(PACKAGE_VERSION);
25801
+ const existingVersionInfo = readVersionFile(dataDir);
25802
+ if (existingVersionInfo === null) {
25803
+ writeVersionFile(dataDir, currentVersion);
25804
+ return;
25805
+ }
25806
+ const { version: oldVersion } = existingVersionInfo;
25807
+ if (formatVersion(oldVersion) === formatVersion(currentVersion)) {
25808
+ return;
25809
+ }
25810
+ try {
25811
+ upgradeVersion(oldVersion, currentVersion);
25812
+ writeVersionFile(dataDir, currentVersion);
25813
+ }
25814
+ catch (error45) {
25815
+ const suggestedVersion = error45 instanceof DataDirVersionError ? error45.suggestedVersion : void 0;
25816
+ const downgradeTarget = getSuggestedDowngradeVersion(oldVersion, suggestedVersion);
25817
+ console.error(`[world-local] Failed to upgrade data directory from version ${formatVersion(oldVersion)} to ${formatVersion(currentVersion)}:`, error45 instanceof Error ? error45.message : error45);
25818
+ console.error(`[world-local] Data is not compatible with the current version. Please downgrade to ${PACKAGE_NAME}@${downgradeTarget}`);
25819
+ throw error45;
25820
+ }
25821
+ }
25822
+ __name(initDataDir, "initDataDir");
25639
25823
  // ../world-local/dist/queue.js
25640
25824
  var import_promises2 = require("node:timers/promises");
25641
25825
  // ../../node_modules/.pnpm/mixpart@0.0.5-alpha.1/node_modules/mixpart/dist/index.mjs
@@ -28023,10 +28207,10 @@ function cloneDef(schema) {
28023
28207
  return mergeDefs(schema._zod.def);
28024
28208
  }
28025
28209
  __name(cloneDef, "cloneDef");
28026
- function getElementAtPath(obj, path4) {
28027
- if (!path4)
28210
+ function getElementAtPath(obj, path5) {
28211
+ if (!path5)
28028
28212
  return obj;
28029
- return path4.reduce((acc, key) => acc?.[key], obj);
28213
+ return path5.reduce((acc, key) => acc?.[key], obj);
28030
28214
  }
28031
28215
  __name(getElementAtPath, "getElementAtPath");
28032
28216
  function promiseAllObject(promisesObj) {
@@ -28467,11 +28651,11 @@ function aborted(x, startIndex = 0) {
28467
28651
  return false;
28468
28652
  }
28469
28653
  __name(aborted, "aborted");
28470
- function prefixIssues(path4, issues) {
28654
+ function prefixIssues(path5, issues) {
28471
28655
  return issues.map((iss) => {
28472
28656
  var _a;
28473
28657
  (_a = iss).path ?? (_a.path = []);
28474
- iss.path.unshift(path4);
28658
+ iss.path.unshift(path5);
28475
28659
  return iss;
28476
28660
  });
28477
28661
  }
@@ -28686,7 +28870,7 @@ function treeifyError(error45, _mapper) {
28686
28870
  const result = {
28687
28871
  errors: []
28688
28872
  };
28689
- const processError = /* @__PURE__ */ __name((error46, path4 = []) => {
28873
+ const processError = /* @__PURE__ */ __name((error46, path5 = []) => {
28690
28874
  var _a, _b;
28691
28875
  for (const issue2 of error46.issues) {
28692
28876
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -28706,7 +28890,7 @@ function treeifyError(error45, _mapper) {
28706
28890
  }
28707
28891
  else {
28708
28892
  const fullpath = [
28709
- ...path4,
28893
+ ...path5,
28710
28894
  ...issue2.path
28711
28895
  ];
28712
28896
  if (fullpath.length === 0) {
@@ -28746,8 +28930,8 @@ function treeifyError(error45, _mapper) {
28746
28930
  __name(treeifyError, "treeifyError");
28747
28931
  function toDotPath(_path) {
28748
28932
  const segs = [];
28749
- const path4 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
28750
- for (const seg of path4) {
28933
+ const path5 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
28934
+ for (const seg of path5) {
28751
28935
  if (typeof seg === "number")
28752
28936
  segs.push(`[${seg}]`);
28753
28937
  else if (typeof seg === "symbol")
@@ -41494,7 +41678,7 @@ function createQueue(config3) {
41494
41678
  };
41495
41679
  }, "createQueueHandler");
41496
41680
  const getDeploymentId = /* @__PURE__ */ __name(async () => {
41497
- return "dpl_local";
41681
+ return `dpl_local@${PACKAGE_VERSION}`;
41498
41682
  }, "getDeploymentId");
41499
41683
  return {
41500
41684
  queue,
@@ -41504,10 +41688,10 @@ function createQueue(config3) {
41504
41688
  }
41505
41689
  __name(createQueue, "createQueue");
41506
41690
  // ../world-local/dist/storage.js
41507
- var import_node_path2 = __toESM(require("node:path"), 1);
41691
+ var import_node_path3 = __toESM(require("node:path"), 1);
41508
41692
  // ../world-local/dist/fs.js
41509
- var import_node_fs = require("node:fs");
41510
- var import_node_path = __toESM(require("node:path"), 1);
41693
+ var import_node_fs2 = require("node:fs");
41694
+ var import_node_path2 = __toESM(require("node:path"), 1);
41511
41695
  var ulid3 = monotonicFactory(() => Math.random());
41512
41696
  var Ulid = external_exports.string().ulid();
41513
41697
  var createdFilesCache = /* @__PURE__ */ new Set();
@@ -41521,7 +41705,7 @@ function ulidToDate(maybeUlid) {
41521
41705
  __name(ulidToDate, "ulidToDate");
41522
41706
  async function ensureDir(dirPath) {
41523
41707
  try {
41524
- await import_node_fs.promises.mkdir(dirPath, {
41708
+ await import_node_fs2.promises.mkdir(dirPath, {
41525
41709
  recursive: true
41526
41710
  });
41527
41711
  }
@@ -41541,7 +41725,7 @@ async function write(filePath, data, opts) {
41541
41725
  });
41542
41726
  }
41543
41727
  try {
41544
- await import_node_fs.promises.access(filePath);
41728
+ await import_node_fs2.promises.access(filePath);
41545
41729
  createdFilesCache.add(filePath);
41546
41730
  throw new WorkflowAPIError(`File ${filePath} already exists and 'overwrite' is false`, {
41547
41731
  status: 409
@@ -41556,15 +41740,15 @@ async function write(filePath, data, opts) {
41556
41740
  const tempPath = `${filePath}.tmp.${ulid3()}`;
41557
41741
  let tempFileCreated = false;
41558
41742
  try {
41559
- await ensureDir(import_node_path.default.dirname(filePath));
41560
- await import_node_fs.promises.writeFile(tempPath, data);
41743
+ await ensureDir(import_node_path2.default.dirname(filePath));
41744
+ await import_node_fs2.promises.writeFile(tempPath, data);
41561
41745
  tempFileCreated = true;
41562
- await import_node_fs.promises.rename(tempPath, filePath);
41746
+ await import_node_fs2.promises.rename(tempPath, filePath);
41563
41747
  createdFilesCache.add(filePath);
41564
41748
  }
41565
41749
  catch (error45) {
41566
41750
  if (tempFileCreated) {
41567
- await import_node_fs.promises.unlink(tempPath).catch(() => {
41751
+ await import_node_fs2.promises.unlink(tempPath).catch(() => {
41568
41752
  });
41569
41753
  }
41570
41754
  throw error45;
@@ -41573,7 +41757,7 @@ async function write(filePath, data, opts) {
41573
41757
  __name(write, "write");
41574
41758
  async function readJSON(filePath, decoder) {
41575
41759
  try {
41576
- const content = await import_node_fs.promises.readFile(filePath, "utf-8");
41760
+ const content = await import_node_fs2.promises.readFile(filePath, "utf-8");
41577
41761
  return decoder.parse(JSON.parse(content));
41578
41762
  }
41579
41763
  catch (error45) {
@@ -41584,13 +41768,13 @@ async function readJSON(filePath, decoder) {
41584
41768
  }
41585
41769
  __name(readJSON, "readJSON");
41586
41770
  async function readBuffer(filePath) {
41587
- const content = await import_node_fs.promises.readFile(filePath);
41771
+ const content = await import_node_fs2.promises.readFile(filePath);
41588
41772
  return content;
41589
41773
  }
41590
41774
  __name(readBuffer, "readBuffer");
41591
41775
  async function deleteJSON(filePath) {
41592
41776
  try {
41593
- await import_node_fs.promises.unlink(filePath);
41777
+ await import_node_fs2.promises.unlink(filePath);
41594
41778
  }
41595
41779
  catch (error45) {
41596
41780
  if (error45.code !== "ENOENT")
@@ -41600,7 +41784,7 @@ async function deleteJSON(filePath) {
41600
41784
  __name(deleteJSON, "deleteJSON");
41601
41785
  async function listJSONFiles(dirPath) {
41602
41786
  try {
41603
- const files = await import_node_fs.promises.readdir(dirPath);
41787
+ const files = await import_node_fs2.promises.readdir(dirPath);
41604
41788
  return files.filter((f) => f.endsWith(".json")).map((f) => f.replace(".json", ""));
41605
41789
  }
41606
41790
  catch (error45) {
@@ -41648,7 +41832,7 @@ async function paginatedFileSystemQuery(config3) {
41648
41832
  }
41649
41833
  const validItems = [];
41650
41834
  for (const fileId of candidateFileIds) {
41651
- const filePath = import_node_path.default.join(directory, `${fileId}.json`);
41835
+ const filePath = import_node_path2.default.join(directory, `${fileId}.json`);
41652
41836
  let item = null;
41653
41837
  try {
41654
41838
  item = await readJSON(filePath, schema);
@@ -41765,10 +41949,10 @@ var getObjectCreatedAt = /* @__PURE__ */ __name((idPrefix) => (filename) => {
41765
41949
  }, "getObjectCreatedAt");
41766
41950
  function createHooksStorage(basedir) {
41767
41951
  async function findHookByToken(token) {
41768
- const hooksDir = import_node_path2.default.join(basedir, "hooks");
41952
+ const hooksDir = import_node_path3.default.join(basedir, "hooks");
41769
41953
  const files = await listJSONFiles(hooksDir);
41770
41954
  for (const file2 of files) {
41771
- const hookPath = import_node_path2.default.join(hooksDir, `${file2}.json`);
41955
+ const hookPath = import_node_path3.default.join(hooksDir, `${file2}.json`);
41772
41956
  const hook = await readJSON(hookPath, HookSchema);
41773
41957
  if (hook && hook.token === token) {
41774
41958
  return hook;
@@ -41793,14 +41977,14 @@ function createHooksStorage(basedir) {
41793
41977
  environment: "local",
41794
41978
  createdAt: now
41795
41979
  };
41796
- const hookPath = import_node_path2.default.join(basedir, "hooks", `${data.hookId}.json`);
41980
+ const hookPath = import_node_path3.default.join(basedir, "hooks", `${data.hookId}.json`);
41797
41981
  HookSchema.parse(result);
41798
41982
  await writeJSON(hookPath, result);
41799
41983
  return result;
41800
41984
  }
41801
41985
  __name(create, "create");
41802
41986
  async function get(hookId, params) {
41803
- const hookPath = import_node_path2.default.join(basedir, "hooks", `${hookId}.json`);
41987
+ const hookPath = import_node_path3.default.join(basedir, "hooks", `${hookId}.json`);
41804
41988
  const hook = await readJSON(hookPath, HookSchema);
41805
41989
  if (!hook) {
41806
41990
  throw new Error(`Hook ${hookId} not found`);
@@ -41818,7 +42002,7 @@ function createHooksStorage(basedir) {
41818
42002
  }
41819
42003
  __name(getByToken, "getByToken");
41820
42004
  async function list(params) {
41821
- const hooksDir = import_node_path2.default.join(basedir, "hooks");
42005
+ const hooksDir = import_node_path3.default.join(basedir, "hooks");
41822
42006
  const resolveData = params.resolveData || DEFAULT_RESOLVE_DATA_OPTION;
41823
42007
  const result = await paginatedFileSystemQuery({
41824
42008
  directory: hooksDir,
@@ -41845,7 +42029,7 @@ function createHooksStorage(basedir) {
41845
42029
  }
41846
42030
  __name(list, "list");
41847
42031
  async function dispose(hookId) {
41848
- const hookPath = import_node_path2.default.join(basedir, "hooks", `${hookId}.json`);
42032
+ const hookPath = import_node_path3.default.join(basedir, "hooks", `${hookId}.json`);
41849
42033
  const hook = await readJSON(hookPath, HookSchema);
41850
42034
  if (!hook) {
41851
42035
  throw new Error(`Hook ${hookId} not found`);
@@ -41864,10 +42048,10 @@ function createHooksStorage(basedir) {
41864
42048
  }
41865
42049
  __name(createHooksStorage, "createHooksStorage");
41866
42050
  async function deleteAllHooksForRun(basedir, runId) {
41867
- const hooksDir = import_node_path2.default.join(basedir, "hooks");
42051
+ const hooksDir = import_node_path3.default.join(basedir, "hooks");
41868
42052
  const files = await listJSONFiles(hooksDir);
41869
42053
  for (const file2 of files) {
41870
- const hookPath = import_node_path2.default.join(hooksDir, `${file2}.json`);
42054
+ const hookPath = import_node_path3.default.join(hooksDir, `${file2}.json`);
41871
42055
  const hook = await readJSON(hookPath, HookSchema);
41872
42056
  if (hook && hook.runId === runId) {
41873
42057
  await deleteJSON(hookPath);
@@ -41895,13 +42079,13 @@ function createStorage(basedir) {
41895
42079
  createdAt: now,
41896
42080
  updatedAt: now
41897
42081
  };
41898
- const runPath = import_node_path2.default.join(basedir, "runs", `${runId}.json`);
42082
+ const runPath = import_node_path3.default.join(basedir, "runs", `${runId}.json`);
41899
42083
  WorkflowRunSchema.parse(result);
41900
42084
  await writeJSON(runPath, result);
41901
42085
  return result;
41902
42086
  },
41903
42087
  async get(id, params) {
41904
- const runPath = import_node_path2.default.join(basedir, "runs", `${id}.json`);
42088
+ const runPath = import_node_path3.default.join(basedir, "runs", `${id}.json`);
41905
42089
  const run = await readJSON(runPath, WorkflowRunSchema);
41906
42090
  if (!run) {
41907
42091
  throw new WorkflowRunNotFoundError(id);
@@ -41919,7 +42103,7 @@ function createStorage(basedir) {
41919
42103
  * used in single-process scenarios.
41920
42104
  */
41921
42105
  async update(id, data) {
41922
- const runPath = import_node_path2.default.join(basedir, "runs", `${id}.json`);
42106
+ const runPath = import_node_path3.default.join(basedir, "runs", `${id}.json`);
41923
42107
  const run = await readJSON(runPath, WorkflowRunSchema);
41924
42108
  if (!run) {
41925
42109
  throw new WorkflowRunNotFoundError(id);
@@ -41949,7 +42133,7 @@ function createStorage(basedir) {
41949
42133
  async list(params) {
41950
42134
  const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
41951
42135
  const result = await paginatedFileSystemQuery({
41952
- directory: import_node_path2.default.join(basedir, "runs"),
42136
+ directory: import_node_path3.default.join(basedir, "runs"),
41953
42137
  schema: WorkflowRunSchema,
41954
42138
  filter: /* @__PURE__ */ __name((run) => {
41955
42139
  if (params?.workflowName && run.workflowName !== params.workflowName) {
@@ -42018,14 +42202,14 @@ function createStorage(basedir) {
42018
42202
  updatedAt: now
42019
42203
  };
42020
42204
  const compositeKey = `${runId}-${data.stepId}`;
42021
- const stepPath = import_node_path2.default.join(basedir, "steps", `${compositeKey}.json`);
42205
+ const stepPath = import_node_path3.default.join(basedir, "steps", `${compositeKey}.json`);
42022
42206
  StepSchema.parse(result);
42023
42207
  await writeJSON(stepPath, result);
42024
42208
  return result;
42025
42209
  },
42026
42210
  async get(runId, stepId, params) {
42027
42211
  if (!runId) {
42028
- const fileIds = await listJSONFiles(import_node_path2.default.join(basedir, "steps"));
42212
+ const fileIds = await listJSONFiles(import_node_path3.default.join(basedir, "steps"));
42029
42213
  const fileId = fileIds.find((fileId2) => fileId2.endsWith(`-${stepId}`));
42030
42214
  if (!fileId) {
42031
42215
  throw new Error(`Step ${stepId} not found`);
@@ -42033,7 +42217,7 @@ function createStorage(basedir) {
42033
42217
  runId = fileId.split("-")[0];
42034
42218
  }
42035
42219
  const compositeKey = `${runId}-${stepId}`;
42036
- const stepPath = import_node_path2.default.join(basedir, "steps", `${compositeKey}.json`);
42220
+ const stepPath = import_node_path3.default.join(basedir, "steps", `${compositeKey}.json`);
42037
42221
  const step = await readJSON(stepPath, StepSchema);
42038
42222
  if (!step) {
42039
42223
  throw new Error(`Step ${stepId} in run ${runId} not found`);
@@ -42050,7 +42234,7 @@ function createStorage(basedir) {
42050
42234
  */
42051
42235
  async update(runId, stepId, data) {
42052
42236
  const compositeKey = `${runId}-${stepId}`;
42053
- const stepPath = import_node_path2.default.join(basedir, "steps", `${compositeKey}.json`);
42237
+ const stepPath = import_node_path3.default.join(basedir, "steps", `${compositeKey}.json`);
42054
42238
  const step = await readJSON(stepPath, StepSchema);
42055
42239
  if (!step) {
42056
42240
  throw new Error(`Step ${stepId} in run ${runId} not found`);
@@ -42076,7 +42260,7 @@ function createStorage(basedir) {
42076
42260
  async list(params) {
42077
42261
  const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
42078
42262
  const result = await paginatedFileSystemQuery({
42079
- directory: import_node_path2.default.join(basedir, "steps"),
42263
+ directory: import_node_path3.default.join(basedir, "steps"),
42080
42264
  schema: StepSchema,
42081
42265
  filePrefix: `${params.runId}-`,
42082
42266
  sortOrder: params.pagination?.sortOrder ?? "desc",
@@ -42110,7 +42294,7 @@ function createStorage(basedir) {
42110
42294
  createdAt: now
42111
42295
  };
42112
42296
  const compositeKey = `${runId}-${eventId}`;
42113
- const eventPath = import_node_path2.default.join(basedir, "events", `${compositeKey}.json`);
42297
+ const eventPath = import_node_path3.default.join(basedir, "events", `${compositeKey}.json`);
42114
42298
  EventSchema.parse(result);
42115
42299
  await writeJSON(eventPath, result);
42116
42300
  const resolveData = params?.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
@@ -42120,7 +42304,7 @@ function createStorage(basedir) {
42120
42304
  const { runId } = params;
42121
42305
  const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
42122
42306
  const result = await paginatedFileSystemQuery({
42123
- directory: import_node_path2.default.join(basedir, "events"),
42307
+ directory: import_node_path3.default.join(basedir, "events"),
42124
42308
  schema: EventSchema,
42125
42309
  filePrefix: `${runId}-`,
42126
42310
  // Events in chronological order (oldest first) by default,
@@ -42146,7 +42330,7 @@ function createStorage(basedir) {
42146
42330
  const correlationId = params.correlationId;
42147
42331
  const resolveData = params.resolveData ?? DEFAULT_RESOLVE_DATA_OPTION;
42148
42332
  const result = await paginatedFileSystemQuery({
42149
- directory: import_node_path2.default.join(basedir, "events"),
42333
+ directory: import_node_path3.default.join(basedir, "events"),
42150
42334
  schema: EventSchema,
42151
42335
  // No filePrefix - search all events
42152
42336
  filter: /* @__PURE__ */ __name((event) => event.correlationId === correlationId, "filter"),
@@ -42177,7 +42361,7 @@ function createStorage(basedir) {
42177
42361
  __name(createStorage, "createStorage");
42178
42362
  // ../world-local/dist/streamer.js
42179
42363
  var import_node_events = require("node:events");
42180
- var import_node_path3 = __toESM(require("node:path"), 1);
42364
+ var import_node_path4 = __toESM(require("node:path"), 1);
42181
42365
  var monotonicUlid2 = monotonicFactory(() => Math.random());
42182
42366
  var RunStreamsSchema = external_exports.object({
42183
42367
  streams: external_exports.array(external_exports.string())
@@ -42209,7 +42393,7 @@ function createStreamer(basedir) {
42209
42393
  if (registeredStreams.has(cacheKey)) {
42210
42394
  return;
42211
42395
  }
42212
- const runStreamsPath = import_node_path3.default.join(basedir, "streams", "runs", `${runId}.json`);
42396
+ const runStreamsPath = import_node_path4.default.join(basedir, "streams", "runs", `${runId}.json`);
42213
42397
  const existing = await readJSON(runStreamsPath, RunStreamsSchema);
42214
42398
  const streams = existing?.streams ?? [];
42215
42399
  if (!streams.includes(streamName)) {
@@ -42242,7 +42426,7 @@ function createStreamer(basedir) {
42242
42426
  chunk: chunkBuffer,
42243
42427
  eof: false
42244
42428
  });
42245
- const chunkPath = import_node_path3.default.join(basedir, "streams", "chunks", `${name}-${chunkId}.json`);
42429
+ const chunkPath = import_node_path4.default.join(basedir, "streams", "chunks", `${name}-${chunkId}.json`);
42246
42430
  await write(chunkPath, serialized);
42247
42431
  const chunkData = Uint8Array.from(chunkBuffer);
42248
42432
  streamEmitter.emit(`chunk:${name}`, {
@@ -42255,7 +42439,7 @@ function createStreamer(basedir) {
42255
42439
  const runId = await _runId;
42256
42440
  await registerStreamForRun(runId, name);
42257
42441
  const chunkId = `chnk_${monotonicUlid2()}`;
42258
- const chunkPath = import_node_path3.default.join(basedir, "streams", "chunks", `${name}-${chunkId}.json`);
42442
+ const chunkPath = import_node_path4.default.join(basedir, "streams", "chunks", `${name}-${chunkId}.json`);
42259
42443
  await write(chunkPath, serializeChunk({
42260
42444
  chunk: Buffer.from([]),
42261
42445
  eof: true
@@ -42265,12 +42449,12 @@ function createStreamer(basedir) {
42265
42449
  });
42266
42450
  },
42267
42451
  async listStreamsByRunId(runId) {
42268
- const runStreamsPath = import_node_path3.default.join(basedir, "streams", "runs", `${runId}.json`);
42452
+ const runStreamsPath = import_node_path4.default.join(basedir, "streams", "runs", `${runId}.json`);
42269
42453
  const data = await readJSON(runStreamsPath, RunStreamsSchema);
42270
42454
  return data?.streams ?? [];
42271
42455
  },
42272
42456
  async readFromStream(name, startIndex = 0) {
42273
- const chunksDir = import_node_path3.default.join(basedir, "streams", "chunks");
42457
+ const chunksDir = import_node_path4.default.join(basedir, "streams", "chunks");
42274
42458
  let removeListeners = /* @__PURE__ */ __name(() => {
42275
42459
  }, "removeListeners");
42276
42460
  return new ReadableStream({
@@ -42278,6 +42462,7 @@ function createStreamer(basedir) {
42278
42462
  const deliveredChunkIds = /* @__PURE__ */ new Set();
42279
42463
  const bufferedEventChunks = [];
42280
42464
  let isReadingFromDisk = true;
42465
+ let pendingClose = false;
42281
42466
  const chunkListener = /* @__PURE__ */ __name((event) => {
42282
42467
  deliveredChunkIds.add(event.chunkId);
42283
42468
  if (event.chunkData.byteLength === 0) {
@@ -42294,6 +42479,10 @@ function createStreamer(basedir) {
42294
42479
  }
42295
42480
  }, "chunkListener");
42296
42481
  const closeListener = /* @__PURE__ */ __name(() => {
42482
+ if (isReadingFromDisk) {
42483
+ pendingClose = true;
42484
+ return;
42485
+ }
42297
42486
  streamEmitter.off(`chunk:${name}`, chunkListener);
42298
42487
  streamEmitter.off(`close:${name}`, closeListener);
42299
42488
  try {
@@ -42314,7 +42503,7 @@ function createStreamer(basedir) {
42314
42503
  if (deliveredChunkIds.has(chunkId)) {
42315
42504
  continue;
42316
42505
  }
42317
- const chunk = deserializeChunk(await readBuffer(import_node_path3.default.join(chunksDir, `${file2}.json`)));
42506
+ const chunk = deserializeChunk(await readBuffer(import_node_path4.default.join(chunksDir, `${file2}.json`)));
42318
42507
  if (chunk?.eof === true) {
42319
42508
  isComplete = true;
42320
42509
  break;
@@ -42337,6 +42526,15 @@ function createStreamer(basedir) {
42337
42526
  }
42338
42527
  return;
42339
42528
  }
42529
+ if (pendingClose) {
42530
+ streamEmitter.off(`chunk:${name}`, chunkListener);
42531
+ streamEmitter.off(`close:${name}`, closeListener);
42532
+ try {
42533
+ controller.close();
42534
+ }
42535
+ catch {
42536
+ }
42537
+ }
42340
42538
  },
42341
42539
  cancel() {
42342
42540
  removeListeners();
@@ -42356,7 +42554,10 @@ function createLocalWorld(args) {
42356
42554
  return {
42357
42555
  ...createQueue(mergedConfig),
42358
42556
  ...createStorage(mergedConfig.dataDir),
42359
- ...createStreamer(mergedConfig.dataDir)
42557
+ ...createStreamer(mergedConfig.dataDir),
42558
+ async start() {
42559
+ await initDataDir(mergedConfig.dataDir);
42560
+ }
42360
42561
  };
42361
42562
  }
42362
42563
  __name(createLocalWorld, "createLocalWorld");
@@ -42364,7 +42565,7 @@ __name(createLocalWorld, "createLocalWorld");
42364
42565
  var import_node_os = __toESM(require("node:os"), 1);
42365
42566
  var import_oidc2 = __toESM(require_dist(), 1);
42366
42567
  // ../world-vercel/dist/version.js
42367
- var version2 = "4.0.1-beta.22";
42568
+ var version2 = "4.0.1-beta.23";
42368
42569
  // ../world-vercel/dist/utils.js
42369
42570
  var DEFAULT_RESOLVE_DATA_OPTION2 = "all";
42370
42571
  function dateToStringReplacer(_key, value) {
@@ -43158,7 +43359,7 @@ function createVercelWorld(config3) {
43158
43359
  }
43159
43360
  __name(createVercelWorld, "createVercelWorld");
43160
43361
  // ../core/dist/runtime/world.js
43161
- var require2 = (0, import_node_module.createRequire)((0, import_node_path4.join)(process.cwd(), "index.js"));
43362
+ var require2 = (0, import_node_module.createRequire)((0, import_node_path5.join)(process.cwd(), "index.js"));
43162
43363
  var WorldCache = Symbol.for("@workflow/world//cache");
43163
43364
  var StubbedWorldCache = Symbol.for("@workflow/world//stubbedCache");
43164
43365
  var globalSymbols = globalThis;
@@ -44094,30 +44295,6 @@ async function writeEvent(writable, event, payload) {
44094
44295
  }
44095
44296
  __name(writeEvent, "writeEvent");
44096
44297
  registerStepFunction("step//workflows/hooks.ts//writeEvent", writeEvent);
44097
- // workflows/null-byte.ts
44098
- async function nullByteStep() {
44099
- return "null byte \0";
44100
- }
44101
- __name(nullByteStep, "nullByteStep");
44102
- async function nullByteWorkflow() {
44103
- throw new Error("You attempted to execute workflow nullByteWorkflow function directly. To start a workflow, use start(nullByteWorkflow) from workflow/api");
44104
- }
44105
- __name(nullByteWorkflow, "nullByteWorkflow");
44106
- nullByteWorkflow.workflowId = "workflow//workflows/null-byte.ts//nullByteWorkflow";
44107
- registerStepFunction("step//workflows/null-byte.ts//nullByteStep", nullByteStep);
44108
- // workflows/noop.ts
44109
- var count = 0;
44110
- async function noop(_i) {
44111
- count++;
44112
- return count;
44113
- }
44114
- __name(noop, "noop");
44115
- async function brokenWf() {
44116
- throw new Error("You attempted to execute workflow brokenWf function directly. To start a workflow, use start(brokenWf) from workflow/api");
44117
- }
44118
- __name(brokenWf, "brokenWf");
44119
- brokenWf.workflowId = "workflow//workflows/noop.ts//brokenWf";
44120
- registerStepFunction("step//workflows/noop.ts//noop", noop);
44121
44298
  // workflows/retriable-and-fatal.ts
44122
44299
  async function retryableAndFatalErrorWorkflow() {
44123
44300
  throw new Error("You attempted to execute workflow retryableAndFatalErrorWorkflow function directly. To start a workflow, use start(retryableAndFatalErrorWorkflow) from workflow/api");
@@ -44178,15 +44355,27 @@ var webhookLogger = createLogger("webhook");
44178
44355
  var eventsLogger = createLogger("events");
44179
44356
  var adapterLogger = createLogger("adapter");
44180
44357
  // ../core/dist/runtime/helpers.js
44358
+ var HEALTH_CHECK_CORS_HEADERS = {
44359
+ "Access-Control-Allow-Origin": "*",
44360
+ "Access-Control-Allow-Methods": "POST, OPTIONS, GET, HEAD",
44361
+ "Access-Control-Allow-Headers": "Content-Type"
44362
+ };
44181
44363
  function withHealthCheck(handler) {
44182
44364
  return async (req) => {
44183
44365
  const url2 = new URL(req.url);
44184
44366
  const isHealthCheck = url2.searchParams.has("__health");
44185
44367
  if (isHealthCheck) {
44368
+ if (req.method === "OPTIONS") {
44369
+ return new Response(null, {
44370
+ status: 204,
44371
+ headers: HEALTH_CHECK_CORS_HEADERS
44372
+ });
44373
+ }
44186
44374
  return new Response(`Workflow DevKit "${url2.pathname}" endpoint is healthy`, {
44187
44375
  status: 200,
44188
44376
  headers: {
44189
- "Content-Type": "text/plain"
44377
+ "Content-Type": "text/plain",
44378
+ ...HEALTH_CHECK_CORS_HEADERS
44190
44379
  }
44191
44380
  });
44192
44381
  }