@workflow/world-testing 4.1.28 → 4.1.29

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.
@@ -45391,6 +45391,1650 @@ ${captureLines}` : capture.stack;
45391
45391
  }
45392
45392
  });
45393
45393
 
45394
+ // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
45395
+ var require_polyfills = __commonJS({
45396
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports2, module2) {
45397
+ var constants2 = require("constants");
45398
+ var origCwd = process.cwd;
45399
+ var cwd = null;
45400
+ var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
45401
+ process.cwd = function() {
45402
+ if (!cwd)
45403
+ cwd = origCwd.call(process);
45404
+ return cwd;
45405
+ };
45406
+ try {
45407
+ process.cwd();
45408
+ } catch (er) {
45409
+ }
45410
+ if (typeof process.chdir === "function") {
45411
+ chdir = process.chdir;
45412
+ process.chdir = function(d) {
45413
+ cwd = null;
45414
+ chdir.call(process, d);
45415
+ };
45416
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
45417
+ }
45418
+ var chdir;
45419
+ module2.exports = patch;
45420
+ function patch(fs6) {
45421
+ if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
45422
+ patchLchmod(fs6);
45423
+ }
45424
+ if (!fs6.lutimes) {
45425
+ patchLutimes(fs6);
45426
+ }
45427
+ fs6.chown = chownFix(fs6.chown);
45428
+ fs6.fchown = chownFix(fs6.fchown);
45429
+ fs6.lchown = chownFix(fs6.lchown);
45430
+ fs6.chmod = chmodFix(fs6.chmod);
45431
+ fs6.fchmod = chmodFix(fs6.fchmod);
45432
+ fs6.lchmod = chmodFix(fs6.lchmod);
45433
+ fs6.chownSync = chownFixSync(fs6.chownSync);
45434
+ fs6.fchownSync = chownFixSync(fs6.fchownSync);
45435
+ fs6.lchownSync = chownFixSync(fs6.lchownSync);
45436
+ fs6.chmodSync = chmodFixSync(fs6.chmodSync);
45437
+ fs6.fchmodSync = chmodFixSync(fs6.fchmodSync);
45438
+ fs6.lchmodSync = chmodFixSync(fs6.lchmodSync);
45439
+ fs6.stat = statFix(fs6.stat);
45440
+ fs6.fstat = statFix(fs6.fstat);
45441
+ fs6.lstat = statFix(fs6.lstat);
45442
+ fs6.statSync = statFixSync(fs6.statSync);
45443
+ fs6.fstatSync = statFixSync(fs6.fstatSync);
45444
+ fs6.lstatSync = statFixSync(fs6.lstatSync);
45445
+ if (fs6.chmod && !fs6.lchmod) {
45446
+ fs6.lchmod = function(path12, mode, cb) {
45447
+ if (cb) process.nextTick(cb);
45448
+ };
45449
+ fs6.lchmodSync = function() {
45450
+ };
45451
+ }
45452
+ if (fs6.chown && !fs6.lchown) {
45453
+ fs6.lchown = function(path12, uid, gid, cb) {
45454
+ if (cb) process.nextTick(cb);
45455
+ };
45456
+ fs6.lchownSync = function() {
45457
+ };
45458
+ }
45459
+ if (platform === "win32") {
45460
+ fs6.rename = typeof fs6.rename !== "function" ? fs6.rename : (function(fs$rename) {
45461
+ function rename(from, to, cb) {
45462
+ var start2 = Date.now();
45463
+ var backoff = 0;
45464
+ fs$rename(from, to, /* @__PURE__ */ __name(function CB(er) {
45465
+ if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start2 < 6e4) {
45466
+ setTimeout(function() {
45467
+ fs6.stat(to, function(stater, st) {
45468
+ if (stater && stater.code === "ENOENT")
45469
+ fs$rename(from, to, CB);
45470
+ else
45471
+ cb(er);
45472
+ });
45473
+ }, backoff);
45474
+ if (backoff < 100)
45475
+ backoff += 10;
45476
+ return;
45477
+ }
45478
+ if (cb) cb(er);
45479
+ }, "CB"));
45480
+ }
45481
+ __name(rename, "rename");
45482
+ if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
45483
+ return rename;
45484
+ })(fs6.rename);
45485
+ }
45486
+ fs6.read = typeof fs6.read !== "function" ? fs6.read : (function(fs$read) {
45487
+ function read2(fd, buffer2, offset, length, position3, callback_) {
45488
+ var callback;
45489
+ if (callback_ && typeof callback_ === "function") {
45490
+ var eagCounter = 0;
45491
+ callback = /* @__PURE__ */ __name(function(er, _, __) {
45492
+ if (er && er.code === "EAGAIN" && eagCounter < 10) {
45493
+ eagCounter++;
45494
+ return fs$read.call(fs6, fd, buffer2, offset, length, position3, callback);
45495
+ }
45496
+ callback_.apply(this, arguments);
45497
+ }, "callback");
45498
+ }
45499
+ return fs$read.call(fs6, fd, buffer2, offset, length, position3, callback);
45500
+ }
45501
+ __name(read2, "read");
45502
+ if (Object.setPrototypeOf) Object.setPrototypeOf(read2, fs$read);
45503
+ return read2;
45504
+ })(fs6.read);
45505
+ fs6.readSync = typeof fs6.readSync !== "function" ? fs6.readSync : /* @__PURE__ */ (function(fs$readSync) {
45506
+ return function(fd, buffer2, offset, length, position3) {
45507
+ var eagCounter = 0;
45508
+ while (true) {
45509
+ try {
45510
+ return fs$readSync.call(fs6, fd, buffer2, offset, length, position3);
45511
+ } catch (er) {
45512
+ if (er.code === "EAGAIN" && eagCounter < 10) {
45513
+ eagCounter++;
45514
+ continue;
45515
+ }
45516
+ throw er;
45517
+ }
45518
+ }
45519
+ };
45520
+ })(fs6.readSync);
45521
+ function patchLchmod(fs7) {
45522
+ fs7.lchmod = function(path12, mode, callback) {
45523
+ fs7.open(
45524
+ path12,
45525
+ constants2.O_WRONLY | constants2.O_SYMLINK,
45526
+ mode,
45527
+ function(err, fd) {
45528
+ if (err) {
45529
+ if (callback) callback(err);
45530
+ return;
45531
+ }
45532
+ fs7.fchmod(fd, mode, function(err2) {
45533
+ fs7.close(fd, function(err22) {
45534
+ if (callback) callback(err2 || err22);
45535
+ });
45536
+ });
45537
+ }
45538
+ );
45539
+ };
45540
+ fs7.lchmodSync = function(path12, mode) {
45541
+ var fd = fs7.openSync(path12, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
45542
+ var threw = true;
45543
+ var ret;
45544
+ try {
45545
+ ret = fs7.fchmodSync(fd, mode);
45546
+ threw = false;
45547
+ } finally {
45548
+ if (threw) {
45549
+ try {
45550
+ fs7.closeSync(fd);
45551
+ } catch (er) {
45552
+ }
45553
+ } else {
45554
+ fs7.closeSync(fd);
45555
+ }
45556
+ }
45557
+ return ret;
45558
+ };
45559
+ }
45560
+ __name(patchLchmod, "patchLchmod");
45561
+ function patchLutimes(fs7) {
45562
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs7.futimes) {
45563
+ fs7.lutimes = function(path12, at, mt, cb) {
45564
+ fs7.open(path12, constants2.O_SYMLINK, function(er, fd) {
45565
+ if (er) {
45566
+ if (cb) cb(er);
45567
+ return;
45568
+ }
45569
+ fs7.futimes(fd, at, mt, function(er2) {
45570
+ fs7.close(fd, function(er22) {
45571
+ if (cb) cb(er2 || er22);
45572
+ });
45573
+ });
45574
+ });
45575
+ };
45576
+ fs7.lutimesSync = function(path12, at, mt) {
45577
+ var fd = fs7.openSync(path12, constants2.O_SYMLINK);
45578
+ var ret;
45579
+ var threw = true;
45580
+ try {
45581
+ ret = fs7.futimesSync(fd, at, mt);
45582
+ threw = false;
45583
+ } finally {
45584
+ if (threw) {
45585
+ try {
45586
+ fs7.closeSync(fd);
45587
+ } catch (er) {
45588
+ }
45589
+ } else {
45590
+ fs7.closeSync(fd);
45591
+ }
45592
+ }
45593
+ return ret;
45594
+ };
45595
+ } else if (fs7.futimes) {
45596
+ fs7.lutimes = function(_a3, _b, _c, cb) {
45597
+ if (cb) process.nextTick(cb);
45598
+ };
45599
+ fs7.lutimesSync = function() {
45600
+ };
45601
+ }
45602
+ }
45603
+ __name(patchLutimes, "patchLutimes");
45604
+ function chmodFix(orig) {
45605
+ if (!orig) return orig;
45606
+ return function(target2, mode, cb) {
45607
+ return orig.call(fs6, target2, mode, function(er) {
45608
+ if (chownErOk(er)) er = null;
45609
+ if (cb) cb.apply(this, arguments);
45610
+ });
45611
+ };
45612
+ }
45613
+ __name(chmodFix, "chmodFix");
45614
+ function chmodFixSync(orig) {
45615
+ if (!orig) return orig;
45616
+ return function(target2, mode) {
45617
+ try {
45618
+ return orig.call(fs6, target2, mode);
45619
+ } catch (er) {
45620
+ if (!chownErOk(er)) throw er;
45621
+ }
45622
+ };
45623
+ }
45624
+ __name(chmodFixSync, "chmodFixSync");
45625
+ function chownFix(orig) {
45626
+ if (!orig) return orig;
45627
+ return function(target2, uid, gid, cb) {
45628
+ return orig.call(fs6, target2, uid, gid, function(er) {
45629
+ if (chownErOk(er)) er = null;
45630
+ if (cb) cb.apply(this, arguments);
45631
+ });
45632
+ };
45633
+ }
45634
+ __name(chownFix, "chownFix");
45635
+ function chownFixSync(orig) {
45636
+ if (!orig) return orig;
45637
+ return function(target2, uid, gid) {
45638
+ try {
45639
+ return orig.call(fs6, target2, uid, gid);
45640
+ } catch (er) {
45641
+ if (!chownErOk(er)) throw er;
45642
+ }
45643
+ };
45644
+ }
45645
+ __name(chownFixSync, "chownFixSync");
45646
+ function statFix(orig) {
45647
+ if (!orig) return orig;
45648
+ return function(target2, options, cb) {
45649
+ if (typeof options === "function") {
45650
+ cb = options;
45651
+ options = null;
45652
+ }
45653
+ function callback(er, stats) {
45654
+ if (stats) {
45655
+ if (stats.uid < 0) stats.uid += 4294967296;
45656
+ if (stats.gid < 0) stats.gid += 4294967296;
45657
+ }
45658
+ if (cb) cb.apply(this, arguments);
45659
+ }
45660
+ __name(callback, "callback");
45661
+ return options ? orig.call(fs6, target2, options, callback) : orig.call(fs6, target2, callback);
45662
+ };
45663
+ }
45664
+ __name(statFix, "statFix");
45665
+ function statFixSync(orig) {
45666
+ if (!orig) return orig;
45667
+ return function(target2, options) {
45668
+ var stats = options ? orig.call(fs6, target2, options) : orig.call(fs6, target2);
45669
+ if (stats) {
45670
+ if (stats.uid < 0) stats.uid += 4294967296;
45671
+ if (stats.gid < 0) stats.gid += 4294967296;
45672
+ }
45673
+ return stats;
45674
+ };
45675
+ }
45676
+ __name(statFixSync, "statFixSync");
45677
+ function chownErOk(er) {
45678
+ if (!er)
45679
+ return true;
45680
+ if (er.code === "ENOSYS")
45681
+ return true;
45682
+ var nonroot = !process.getuid || process.getuid() !== 0;
45683
+ if (nonroot) {
45684
+ if (er.code === "EINVAL" || er.code === "EPERM")
45685
+ return true;
45686
+ }
45687
+ return false;
45688
+ }
45689
+ __name(chownErOk, "chownErOk");
45690
+ }
45691
+ __name(patch, "patch");
45692
+ }
45693
+ });
45694
+
45695
+ // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
45696
+ var require_legacy_streams = __commonJS({
45697
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports2, module2) {
45698
+ var Stream = require("stream").Stream;
45699
+ module2.exports = legacy;
45700
+ function legacy(fs6) {
45701
+ return {
45702
+ ReadStream,
45703
+ WriteStream
45704
+ };
45705
+ function ReadStream(path12, options) {
45706
+ if (!(this instanceof ReadStream)) return new ReadStream(path12, options);
45707
+ Stream.call(this);
45708
+ var self2 = this;
45709
+ this.path = path12;
45710
+ this.fd = null;
45711
+ this.readable = true;
45712
+ this.paused = false;
45713
+ this.flags = "r";
45714
+ this.mode = 438;
45715
+ this.bufferSize = 64 * 1024;
45716
+ options = options || {};
45717
+ var keys = Object.keys(options);
45718
+ for (var index = 0, length = keys.length; index < length; index++) {
45719
+ var key = keys[index];
45720
+ this[key] = options[key];
45721
+ }
45722
+ if (this.encoding) this.setEncoding(this.encoding);
45723
+ if (this.start !== void 0) {
45724
+ if ("number" !== typeof this.start) {
45725
+ throw TypeError("start must be a Number");
45726
+ }
45727
+ if (this.end === void 0) {
45728
+ this.end = Infinity;
45729
+ } else if ("number" !== typeof this.end) {
45730
+ throw TypeError("end must be a Number");
45731
+ }
45732
+ if (this.start > this.end) {
45733
+ throw new Error("start must be <= end");
45734
+ }
45735
+ this.pos = this.start;
45736
+ }
45737
+ if (this.fd !== null) {
45738
+ process.nextTick(function() {
45739
+ self2._read();
45740
+ });
45741
+ return;
45742
+ }
45743
+ fs6.open(this.path, this.flags, this.mode, function(err, fd) {
45744
+ if (err) {
45745
+ self2.emit("error", err);
45746
+ self2.readable = false;
45747
+ return;
45748
+ }
45749
+ self2.fd = fd;
45750
+ self2.emit("open", fd);
45751
+ self2._read();
45752
+ });
45753
+ }
45754
+ __name(ReadStream, "ReadStream");
45755
+ function WriteStream(path12, options) {
45756
+ if (!(this instanceof WriteStream)) return new WriteStream(path12, options);
45757
+ Stream.call(this);
45758
+ this.path = path12;
45759
+ this.fd = null;
45760
+ this.writable = true;
45761
+ this.flags = "w";
45762
+ this.encoding = "binary";
45763
+ this.mode = 438;
45764
+ this.bytesWritten = 0;
45765
+ options = options || {};
45766
+ var keys = Object.keys(options);
45767
+ for (var index = 0, length = keys.length; index < length; index++) {
45768
+ var key = keys[index];
45769
+ this[key] = options[key];
45770
+ }
45771
+ if (this.start !== void 0) {
45772
+ if ("number" !== typeof this.start) {
45773
+ throw TypeError("start must be a Number");
45774
+ }
45775
+ if (this.start < 0) {
45776
+ throw new Error("start must be >= zero");
45777
+ }
45778
+ this.pos = this.start;
45779
+ }
45780
+ this.busy = false;
45781
+ this._queue = [];
45782
+ if (this.fd === null) {
45783
+ this._open = fs6.open;
45784
+ this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
45785
+ this.flush();
45786
+ }
45787
+ }
45788
+ __name(WriteStream, "WriteStream");
45789
+ }
45790
+ __name(legacy, "legacy");
45791
+ }
45792
+ });
45793
+
45794
+ // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
45795
+ var require_clone = __commonJS({
45796
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js"(exports2, module2) {
45797
+ "use strict";
45798
+ module2.exports = clone2;
45799
+ var getPrototypeOf = Object.getPrototypeOf || function(obj) {
45800
+ return obj.__proto__;
45801
+ };
45802
+ function clone2(obj) {
45803
+ if (obj === null || typeof obj !== "object")
45804
+ return obj;
45805
+ if (obj instanceof Object)
45806
+ var copy = { __proto__: getPrototypeOf(obj) };
45807
+ else
45808
+ var copy = /* @__PURE__ */ Object.create(null);
45809
+ Object.getOwnPropertyNames(obj).forEach(function(key) {
45810
+ Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
45811
+ });
45812
+ return copy;
45813
+ }
45814
+ __name(clone2, "clone");
45815
+ }
45816
+ });
45817
+
45818
+ // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
45819
+ var require_graceful_fs = __commonJS({
45820
+ "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports2, module2) {
45821
+ var fs6 = require("fs");
45822
+ var polyfills = require_polyfills();
45823
+ var legacy = require_legacy_streams();
45824
+ var clone2 = require_clone();
45825
+ var util = require("util");
45826
+ var gracefulQueue;
45827
+ var previousSymbol;
45828
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
45829
+ gracefulQueue = /* @__PURE__ */ Symbol.for("graceful-fs.queue");
45830
+ previousSymbol = /* @__PURE__ */ Symbol.for("graceful-fs.previous");
45831
+ } else {
45832
+ gracefulQueue = "___graceful-fs.queue";
45833
+ previousSymbol = "___graceful-fs.previous";
45834
+ }
45835
+ function noop() {
45836
+ }
45837
+ __name(noop, "noop");
45838
+ function publishQueue(context2, queue2) {
45839
+ Object.defineProperty(context2, gracefulQueue, {
45840
+ get: /* @__PURE__ */ __name(function() {
45841
+ return queue2;
45842
+ }, "get")
45843
+ });
45844
+ }
45845
+ __name(publishQueue, "publishQueue");
45846
+ var debug2 = noop;
45847
+ if (util.debuglog)
45848
+ debug2 = util.debuglog("gfs4");
45849
+ else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
45850
+ debug2 = /* @__PURE__ */ __name(function() {
45851
+ var m = util.format.apply(util, arguments);
45852
+ m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
45853
+ console.error(m);
45854
+ }, "debug");
45855
+ if (!fs6[gracefulQueue]) {
45856
+ queue = global[gracefulQueue] || [];
45857
+ publishQueue(fs6, queue);
45858
+ fs6.close = (function(fs$close) {
45859
+ function close(fd, cb) {
45860
+ return fs$close.call(fs6, fd, function(err) {
45861
+ if (!err) {
45862
+ resetQueue();
45863
+ }
45864
+ if (typeof cb === "function")
45865
+ cb.apply(this, arguments);
45866
+ });
45867
+ }
45868
+ __name(close, "close");
45869
+ Object.defineProperty(close, previousSymbol, {
45870
+ value: fs$close
45871
+ });
45872
+ return close;
45873
+ })(fs6.close);
45874
+ fs6.closeSync = (function(fs$closeSync) {
45875
+ function closeSync(fd) {
45876
+ fs$closeSync.apply(fs6, arguments);
45877
+ resetQueue();
45878
+ }
45879
+ __name(closeSync, "closeSync");
45880
+ Object.defineProperty(closeSync, previousSymbol, {
45881
+ value: fs$closeSync
45882
+ });
45883
+ return closeSync;
45884
+ })(fs6.closeSync);
45885
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
45886
+ process.on("exit", function() {
45887
+ debug2(fs6[gracefulQueue]);
45888
+ require("assert").equal(fs6[gracefulQueue].length, 0);
45889
+ });
45890
+ }
45891
+ }
45892
+ var queue;
45893
+ if (!global[gracefulQueue]) {
45894
+ publishQueue(global, fs6[gracefulQueue]);
45895
+ }
45896
+ module2.exports = patch(clone2(fs6));
45897
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs6.__patched) {
45898
+ module2.exports = patch(fs6);
45899
+ fs6.__patched = true;
45900
+ }
45901
+ function patch(fs7) {
45902
+ polyfills(fs7);
45903
+ fs7.gracefulify = patch;
45904
+ fs7.createReadStream = createReadStream;
45905
+ fs7.createWriteStream = createWriteStream;
45906
+ var fs$readFile = fs7.readFile;
45907
+ fs7.readFile = readFile3;
45908
+ function readFile3(path12, options, cb) {
45909
+ if (typeof options === "function")
45910
+ cb = options, options = null;
45911
+ return go$readFile(path12, options, cb);
45912
+ function go$readFile(path13, options2, cb2, startTime) {
45913
+ return fs$readFile(path13, options2, function(err) {
45914
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
45915
+ enqueue([go$readFile, [path13, options2, cb2], err, startTime || Date.now(), Date.now()]);
45916
+ else {
45917
+ if (typeof cb2 === "function")
45918
+ cb2.apply(this, arguments);
45919
+ }
45920
+ });
45921
+ }
45922
+ __name(go$readFile, "go$readFile");
45923
+ }
45924
+ __name(readFile3, "readFile");
45925
+ var fs$writeFile = fs7.writeFile;
45926
+ fs7.writeFile = writeFile2;
45927
+ function writeFile2(path12, data, options, cb) {
45928
+ if (typeof options === "function")
45929
+ cb = options, options = null;
45930
+ return go$writeFile(path12, data, options, cb);
45931
+ function go$writeFile(path13, data2, options2, cb2, startTime) {
45932
+ return fs$writeFile(path13, data2, options2, function(err) {
45933
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
45934
+ enqueue([go$writeFile, [path13, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
45935
+ else {
45936
+ if (typeof cb2 === "function")
45937
+ cb2.apply(this, arguments);
45938
+ }
45939
+ });
45940
+ }
45941
+ __name(go$writeFile, "go$writeFile");
45942
+ }
45943
+ __name(writeFile2, "writeFile");
45944
+ var fs$appendFile = fs7.appendFile;
45945
+ if (fs$appendFile)
45946
+ fs7.appendFile = appendFile;
45947
+ function appendFile(path12, data, options, cb) {
45948
+ if (typeof options === "function")
45949
+ cb = options, options = null;
45950
+ return go$appendFile(path12, data, options, cb);
45951
+ function go$appendFile(path13, data2, options2, cb2, startTime) {
45952
+ return fs$appendFile(path13, data2, options2, function(err) {
45953
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
45954
+ enqueue([go$appendFile, [path13, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
45955
+ else {
45956
+ if (typeof cb2 === "function")
45957
+ cb2.apply(this, arguments);
45958
+ }
45959
+ });
45960
+ }
45961
+ __name(go$appendFile, "go$appendFile");
45962
+ }
45963
+ __name(appendFile, "appendFile");
45964
+ var fs$copyFile = fs7.copyFile;
45965
+ if (fs$copyFile)
45966
+ fs7.copyFile = copyFile;
45967
+ function copyFile(src2, dest, flags, cb) {
45968
+ if (typeof flags === "function") {
45969
+ cb = flags;
45970
+ flags = 0;
45971
+ }
45972
+ return go$copyFile(src2, dest, flags, cb);
45973
+ function go$copyFile(src3, dest2, flags2, cb2, startTime) {
45974
+ return fs$copyFile(src3, dest2, flags2, function(err) {
45975
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
45976
+ enqueue([go$copyFile, [src3, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
45977
+ else {
45978
+ if (typeof cb2 === "function")
45979
+ cb2.apply(this, arguments);
45980
+ }
45981
+ });
45982
+ }
45983
+ __name(go$copyFile, "go$copyFile");
45984
+ }
45985
+ __name(copyFile, "copyFile");
45986
+ var fs$readdir = fs7.readdir;
45987
+ fs7.readdir = readdir2;
45988
+ var noReaddirOptionVersions = /^v[0-5]\./;
45989
+ function readdir2(path12, options, cb) {
45990
+ if (typeof options === "function")
45991
+ cb = options, options = null;
45992
+ var go$readdir = noReaddirOptionVersions.test(process.version) ? /* @__PURE__ */ __name(function go$readdir2(path13, options2, cb2, startTime) {
45993
+ return fs$readdir(path13, fs$readdirCallback(
45994
+ path13,
45995
+ options2,
45996
+ cb2,
45997
+ startTime
45998
+ ));
45999
+ }, "go$readdir") : /* @__PURE__ */ __name(function go$readdir2(path13, options2, cb2, startTime) {
46000
+ return fs$readdir(path13, options2, fs$readdirCallback(
46001
+ path13,
46002
+ options2,
46003
+ cb2,
46004
+ startTime
46005
+ ));
46006
+ }, "go$readdir");
46007
+ return go$readdir(path12, options, cb);
46008
+ function fs$readdirCallback(path13, options2, cb2, startTime) {
46009
+ return function(err, files) {
46010
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
46011
+ enqueue([
46012
+ go$readdir,
46013
+ [path13, options2, cb2],
46014
+ err,
46015
+ startTime || Date.now(),
46016
+ Date.now()
46017
+ ]);
46018
+ else {
46019
+ if (files && files.sort)
46020
+ files.sort();
46021
+ if (typeof cb2 === "function")
46022
+ cb2.call(this, err, files);
46023
+ }
46024
+ };
46025
+ }
46026
+ __name(fs$readdirCallback, "fs$readdirCallback");
46027
+ }
46028
+ __name(readdir2, "readdir");
46029
+ if (process.version.substr(0, 4) === "v0.8") {
46030
+ var legStreams = legacy(fs7);
46031
+ ReadStream = legStreams.ReadStream;
46032
+ WriteStream = legStreams.WriteStream;
46033
+ }
46034
+ var fs$ReadStream = fs7.ReadStream;
46035
+ if (fs$ReadStream) {
46036
+ ReadStream.prototype = Object.create(fs$ReadStream.prototype);
46037
+ ReadStream.prototype.open = ReadStream$open;
46038
+ }
46039
+ var fs$WriteStream = fs7.WriteStream;
46040
+ if (fs$WriteStream) {
46041
+ WriteStream.prototype = Object.create(fs$WriteStream.prototype);
46042
+ WriteStream.prototype.open = WriteStream$open;
46043
+ }
46044
+ Object.defineProperty(fs7, "ReadStream", {
46045
+ get: /* @__PURE__ */ __name(function() {
46046
+ return ReadStream;
46047
+ }, "get"),
46048
+ set: /* @__PURE__ */ __name(function(val) {
46049
+ ReadStream = val;
46050
+ }, "set"),
46051
+ enumerable: true,
46052
+ configurable: true
46053
+ });
46054
+ Object.defineProperty(fs7, "WriteStream", {
46055
+ get: /* @__PURE__ */ __name(function() {
46056
+ return WriteStream;
46057
+ }, "get"),
46058
+ set: /* @__PURE__ */ __name(function(val) {
46059
+ WriteStream = val;
46060
+ }, "set"),
46061
+ enumerable: true,
46062
+ configurable: true
46063
+ });
46064
+ var FileReadStream = ReadStream;
46065
+ Object.defineProperty(fs7, "FileReadStream", {
46066
+ get: /* @__PURE__ */ __name(function() {
46067
+ return FileReadStream;
46068
+ }, "get"),
46069
+ set: /* @__PURE__ */ __name(function(val) {
46070
+ FileReadStream = val;
46071
+ }, "set"),
46072
+ enumerable: true,
46073
+ configurable: true
46074
+ });
46075
+ var FileWriteStream = WriteStream;
46076
+ Object.defineProperty(fs7, "FileWriteStream", {
46077
+ get: /* @__PURE__ */ __name(function() {
46078
+ return FileWriteStream;
46079
+ }, "get"),
46080
+ set: /* @__PURE__ */ __name(function(val) {
46081
+ FileWriteStream = val;
46082
+ }, "set"),
46083
+ enumerable: true,
46084
+ configurable: true
46085
+ });
46086
+ function ReadStream(path12, options) {
46087
+ if (this instanceof ReadStream)
46088
+ return fs$ReadStream.apply(this, arguments), this;
46089
+ else
46090
+ return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
46091
+ }
46092
+ __name(ReadStream, "ReadStream");
46093
+ function ReadStream$open() {
46094
+ var that = this;
46095
+ open(that.path, that.flags, that.mode, function(err, fd) {
46096
+ if (err) {
46097
+ if (that.autoClose)
46098
+ that.destroy();
46099
+ that.emit("error", err);
46100
+ } else {
46101
+ that.fd = fd;
46102
+ that.emit("open", fd);
46103
+ that.read();
46104
+ }
46105
+ });
46106
+ }
46107
+ __name(ReadStream$open, "ReadStream$open");
46108
+ function WriteStream(path12, options) {
46109
+ if (this instanceof WriteStream)
46110
+ return fs$WriteStream.apply(this, arguments), this;
46111
+ else
46112
+ return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
46113
+ }
46114
+ __name(WriteStream, "WriteStream");
46115
+ function WriteStream$open() {
46116
+ var that = this;
46117
+ open(that.path, that.flags, that.mode, function(err, fd) {
46118
+ if (err) {
46119
+ that.destroy();
46120
+ that.emit("error", err);
46121
+ } else {
46122
+ that.fd = fd;
46123
+ that.emit("open", fd);
46124
+ }
46125
+ });
46126
+ }
46127
+ __name(WriteStream$open, "WriteStream$open");
46128
+ function createReadStream(path12, options) {
46129
+ return new fs7.ReadStream(path12, options);
46130
+ }
46131
+ __name(createReadStream, "createReadStream");
46132
+ function createWriteStream(path12, options) {
46133
+ return new fs7.WriteStream(path12, options);
46134
+ }
46135
+ __name(createWriteStream, "createWriteStream");
46136
+ var fs$open = fs7.open;
46137
+ fs7.open = open;
46138
+ function open(path12, flags, mode, cb) {
46139
+ if (typeof mode === "function")
46140
+ cb = mode, mode = null;
46141
+ return go$open(path12, flags, mode, cb);
46142
+ function go$open(path13, flags2, mode2, cb2, startTime) {
46143
+ return fs$open(path13, flags2, mode2, function(err, fd) {
46144
+ if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
46145
+ enqueue([go$open, [path13, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
46146
+ else {
46147
+ if (typeof cb2 === "function")
46148
+ cb2.apply(this, arguments);
46149
+ }
46150
+ });
46151
+ }
46152
+ __name(go$open, "go$open");
46153
+ }
46154
+ __name(open, "open");
46155
+ return fs7;
46156
+ }
46157
+ __name(patch, "patch");
46158
+ function enqueue(elem) {
46159
+ debug2("ENQUEUE", elem[0].name, elem[1]);
46160
+ fs6[gracefulQueue].push(elem);
46161
+ retry();
46162
+ }
46163
+ __name(enqueue, "enqueue");
46164
+ var retryTimer;
46165
+ function resetQueue() {
46166
+ var now = Date.now();
46167
+ for (var i = 0; i < fs6[gracefulQueue].length; ++i) {
46168
+ if (fs6[gracefulQueue][i].length > 2) {
46169
+ fs6[gracefulQueue][i][3] = now;
46170
+ fs6[gracefulQueue][i][4] = now;
46171
+ }
46172
+ }
46173
+ retry();
46174
+ }
46175
+ __name(resetQueue, "resetQueue");
46176
+ function retry() {
46177
+ clearTimeout(retryTimer);
46178
+ retryTimer = void 0;
46179
+ if (fs6[gracefulQueue].length === 0)
46180
+ return;
46181
+ var elem = fs6[gracefulQueue].shift();
46182
+ var fn = elem[0];
46183
+ var args = elem[1];
46184
+ var err = elem[2];
46185
+ var startTime = elem[3];
46186
+ var lastTime = elem[4];
46187
+ if (startTime === void 0) {
46188
+ debug2("RETRY", fn.name, args);
46189
+ fn.apply(null, args);
46190
+ } else if (Date.now() - startTime >= 6e4) {
46191
+ debug2("TIMEOUT", fn.name, args);
46192
+ var cb = args.pop();
46193
+ if (typeof cb === "function")
46194
+ cb.call(null, err);
46195
+ } else {
46196
+ var sinceAttempt = Date.now() - lastTime;
46197
+ var sinceStart = Math.max(lastTime - startTime, 1);
46198
+ var desiredDelay = Math.min(sinceStart * 1.2, 100);
46199
+ if (sinceAttempt >= desiredDelay) {
46200
+ debug2("RETRY", fn.name, args);
46201
+ fn.apply(null, args.concat([startTime]));
46202
+ } else {
46203
+ fs6[gracefulQueue].push(elem);
46204
+ }
46205
+ }
46206
+ if (retryTimer === void 0) {
46207
+ retryTimer = setTimeout(retry, 0);
46208
+ }
46209
+ }
46210
+ __name(retry, "retry");
46211
+ }
46212
+ });
46213
+
46214
+ // ../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry_operation.js
46215
+ var require_retry_operation = __commonJS({
46216
+ "../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry_operation.js"(exports2, module2) {
46217
+ function RetryOperation(timeouts, options) {
46218
+ if (typeof options === "boolean") {
46219
+ options = { forever: options };
46220
+ }
46221
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
46222
+ this._timeouts = timeouts;
46223
+ this._options = options || {};
46224
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
46225
+ this._fn = null;
46226
+ this._errors = [];
46227
+ this._attempts = 1;
46228
+ this._operationTimeout = null;
46229
+ this._operationTimeoutCb = null;
46230
+ this._timeout = null;
46231
+ this._operationStart = null;
46232
+ if (this._options.forever) {
46233
+ this._cachedTimeouts = this._timeouts.slice(0);
46234
+ }
46235
+ }
46236
+ __name(RetryOperation, "RetryOperation");
46237
+ module2.exports = RetryOperation;
46238
+ RetryOperation.prototype.reset = function() {
46239
+ this._attempts = 1;
46240
+ this._timeouts = this._originalTimeouts;
46241
+ };
46242
+ RetryOperation.prototype.stop = function() {
46243
+ if (this._timeout) {
46244
+ clearTimeout(this._timeout);
46245
+ }
46246
+ this._timeouts = [];
46247
+ this._cachedTimeouts = null;
46248
+ };
46249
+ RetryOperation.prototype.retry = function(err) {
46250
+ if (this._timeout) {
46251
+ clearTimeout(this._timeout);
46252
+ }
46253
+ if (!err) {
46254
+ return false;
46255
+ }
46256
+ var currentTime = (/* @__PURE__ */ new Date()).getTime();
46257
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
46258
+ this._errors.unshift(new Error("RetryOperation timeout occurred"));
46259
+ return false;
46260
+ }
46261
+ this._errors.push(err);
46262
+ var timeout = this._timeouts.shift();
46263
+ if (timeout === void 0) {
46264
+ if (this._cachedTimeouts) {
46265
+ this._errors.splice(this._errors.length - 1, this._errors.length);
46266
+ this._timeouts = this._cachedTimeouts.slice(0);
46267
+ timeout = this._timeouts.shift();
46268
+ } else {
46269
+ return false;
46270
+ }
46271
+ }
46272
+ var self2 = this;
46273
+ var timer = setTimeout(function() {
46274
+ self2._attempts++;
46275
+ if (self2._operationTimeoutCb) {
46276
+ self2._timeout = setTimeout(function() {
46277
+ self2._operationTimeoutCb(self2._attempts);
46278
+ }, self2._operationTimeout);
46279
+ if (self2._options.unref) {
46280
+ self2._timeout.unref();
46281
+ }
46282
+ }
46283
+ self2._fn(self2._attempts);
46284
+ }, timeout);
46285
+ if (this._options.unref) {
46286
+ timer.unref();
46287
+ }
46288
+ return true;
46289
+ };
46290
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
46291
+ this._fn = fn;
46292
+ if (timeoutOps) {
46293
+ if (timeoutOps.timeout) {
46294
+ this._operationTimeout = timeoutOps.timeout;
46295
+ }
46296
+ if (timeoutOps.cb) {
46297
+ this._operationTimeoutCb = timeoutOps.cb;
46298
+ }
46299
+ }
46300
+ var self2 = this;
46301
+ if (this._operationTimeoutCb) {
46302
+ this._timeout = setTimeout(function() {
46303
+ self2._operationTimeoutCb();
46304
+ }, self2._operationTimeout);
46305
+ }
46306
+ this._operationStart = (/* @__PURE__ */ new Date()).getTime();
46307
+ this._fn(this._attempts);
46308
+ };
46309
+ RetryOperation.prototype.try = function(fn) {
46310
+ console.log("Using RetryOperation.try() is deprecated");
46311
+ this.attempt(fn);
46312
+ };
46313
+ RetryOperation.prototype.start = function(fn) {
46314
+ console.log("Using RetryOperation.start() is deprecated");
46315
+ this.attempt(fn);
46316
+ };
46317
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
46318
+ RetryOperation.prototype.errors = function() {
46319
+ return this._errors;
46320
+ };
46321
+ RetryOperation.prototype.attempts = function() {
46322
+ return this._attempts;
46323
+ };
46324
+ RetryOperation.prototype.mainError = function() {
46325
+ if (this._errors.length === 0) {
46326
+ return null;
46327
+ }
46328
+ var counts = {};
46329
+ var mainError = null;
46330
+ var mainErrorCount = 0;
46331
+ for (var i = 0; i < this._errors.length; i++) {
46332
+ var error48 = this._errors[i];
46333
+ var message = error48.message;
46334
+ var count = (counts[message] || 0) + 1;
46335
+ counts[message] = count;
46336
+ if (count >= mainErrorCount) {
46337
+ mainError = error48;
46338
+ mainErrorCount = count;
46339
+ }
46340
+ }
46341
+ return mainError;
46342
+ };
46343
+ }
46344
+ });
46345
+
46346
+ // ../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry.js
46347
+ var require_retry2 = __commonJS({
46348
+ "../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/lib/retry.js"(exports2) {
46349
+ var RetryOperation = require_retry_operation();
46350
+ exports2.operation = function(options) {
46351
+ var timeouts = exports2.timeouts(options);
46352
+ return new RetryOperation(timeouts, {
46353
+ forever: options && options.forever,
46354
+ unref: options && options.unref,
46355
+ maxRetryTime: options && options.maxRetryTime
46356
+ });
46357
+ };
46358
+ exports2.timeouts = function(options) {
46359
+ if (options instanceof Array) {
46360
+ return [].concat(options);
46361
+ }
46362
+ var opts = {
46363
+ retries: 10,
46364
+ factor: 2,
46365
+ minTimeout: 1 * 1e3,
46366
+ maxTimeout: Infinity,
46367
+ randomize: false
46368
+ };
46369
+ for (var key in options) {
46370
+ opts[key] = options[key];
46371
+ }
46372
+ if (opts.minTimeout > opts.maxTimeout) {
46373
+ throw new Error("minTimeout is greater than maxTimeout");
46374
+ }
46375
+ var timeouts = [];
46376
+ for (var i = 0; i < opts.retries; i++) {
46377
+ timeouts.push(this.createTimeout(i, opts));
46378
+ }
46379
+ if (options && options.forever && !timeouts.length) {
46380
+ timeouts.push(this.createTimeout(i, opts));
46381
+ }
46382
+ timeouts.sort(function(a, b) {
46383
+ return a - b;
46384
+ });
46385
+ return timeouts;
46386
+ };
46387
+ exports2.createTimeout = function(attempt, opts) {
46388
+ var random = opts.randomize ? Math.random() + 1 : 1;
46389
+ var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
46390
+ timeout = Math.min(timeout, opts.maxTimeout);
46391
+ return timeout;
46392
+ };
46393
+ exports2.wrap = function(obj, options, methods) {
46394
+ if (options instanceof Array) {
46395
+ methods = options;
46396
+ options = null;
46397
+ }
46398
+ if (!methods) {
46399
+ methods = [];
46400
+ for (var key in obj) {
46401
+ if (typeof obj[key] === "function") {
46402
+ methods.push(key);
46403
+ }
46404
+ }
46405
+ }
46406
+ for (var i = 0; i < methods.length; i++) {
46407
+ var method = methods[i];
46408
+ var original = obj[method];
46409
+ obj[method] = (/* @__PURE__ */ __name(function retryWrapper(original2) {
46410
+ var op = exports2.operation(options);
46411
+ var args = Array.prototype.slice.call(arguments, 1);
46412
+ var callback = args.pop();
46413
+ args.push(function(err) {
46414
+ if (op.retry(err)) {
46415
+ return;
46416
+ }
46417
+ if (err) {
46418
+ arguments[0] = op.mainError();
46419
+ }
46420
+ callback.apply(this, arguments);
46421
+ });
46422
+ op.attempt(function() {
46423
+ original2.apply(obj, args);
46424
+ });
46425
+ }, "retryWrapper")).bind(obj, original);
46426
+ obj[method].options = options;
46427
+ }
46428
+ };
46429
+ }
46430
+ });
46431
+
46432
+ // ../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/index.js
46433
+ var require_retry3 = __commonJS({
46434
+ "../../node_modules/.pnpm/retry@0.12.0/node_modules/retry/index.js"(exports2, module2) {
46435
+ module2.exports = require_retry2();
46436
+ }
46437
+ });
46438
+
46439
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js
46440
+ var require_signals = __commonJS({
46441
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports2, module2) {
46442
+ module2.exports = [
46443
+ "SIGABRT",
46444
+ "SIGALRM",
46445
+ "SIGHUP",
46446
+ "SIGINT",
46447
+ "SIGTERM"
46448
+ ];
46449
+ if (process.platform !== "win32") {
46450
+ module2.exports.push(
46451
+ "SIGVTALRM",
46452
+ "SIGXCPU",
46453
+ "SIGXFSZ",
46454
+ "SIGUSR2",
46455
+ "SIGTRAP",
46456
+ "SIGSYS",
46457
+ "SIGQUIT",
46458
+ "SIGIOT"
46459
+ // should detect profiler and enable/disable accordingly.
46460
+ // see #21
46461
+ // 'SIGPROF'
46462
+ );
46463
+ }
46464
+ if (process.platform === "linux") {
46465
+ module2.exports.push(
46466
+ "SIGIO",
46467
+ "SIGPOLL",
46468
+ "SIGPWR",
46469
+ "SIGSTKFLT",
46470
+ "SIGUNUSED"
46471
+ );
46472
+ }
46473
+ }
46474
+ });
46475
+
46476
+ // ../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js
46477
+ var require_signal_exit = __commonJS({
46478
+ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports2, module2) {
46479
+ var process3 = global.process;
46480
+ var processOk = /* @__PURE__ */ __name(function(process4) {
46481
+ return process4 && typeof process4 === "object" && typeof process4.removeListener === "function" && typeof process4.emit === "function" && typeof process4.reallyExit === "function" && typeof process4.listeners === "function" && typeof process4.kill === "function" && typeof process4.pid === "number" && typeof process4.on === "function";
46482
+ }, "processOk");
46483
+ if (!processOk(process3)) {
46484
+ module2.exports = function() {
46485
+ return function() {
46486
+ };
46487
+ };
46488
+ } else {
46489
+ assert2 = require("assert");
46490
+ signals = require_signals();
46491
+ isWin = /^win/i.test(process3.platform);
46492
+ EE = require("events");
46493
+ if (typeof EE !== "function") {
46494
+ EE = EE.EventEmitter;
46495
+ }
46496
+ if (process3.__signal_exit_emitter__) {
46497
+ emitter = process3.__signal_exit_emitter__;
46498
+ } else {
46499
+ emitter = process3.__signal_exit_emitter__ = new EE();
46500
+ emitter.count = 0;
46501
+ emitter.emitted = {};
46502
+ }
46503
+ if (!emitter.infinite) {
46504
+ emitter.setMaxListeners(Infinity);
46505
+ emitter.infinite = true;
46506
+ }
46507
+ module2.exports = function(cb, opts) {
46508
+ if (!processOk(global.process)) {
46509
+ return function() {
46510
+ };
46511
+ }
46512
+ assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
46513
+ if (loaded === false) {
46514
+ load();
46515
+ }
46516
+ var ev = "exit";
46517
+ if (opts && opts.alwaysLast) {
46518
+ ev = "afterexit";
46519
+ }
46520
+ var remove = /* @__PURE__ */ __name(function() {
46521
+ emitter.removeListener(ev, cb);
46522
+ if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) {
46523
+ unload();
46524
+ }
46525
+ }, "remove");
46526
+ emitter.on(ev, cb);
46527
+ return remove;
46528
+ };
46529
+ unload = /* @__PURE__ */ __name(function unload2() {
46530
+ if (!loaded || !processOk(global.process)) {
46531
+ return;
46532
+ }
46533
+ loaded = false;
46534
+ signals.forEach(function(sig) {
46535
+ try {
46536
+ process3.removeListener(sig, sigListeners[sig]);
46537
+ } catch (er) {
46538
+ }
46539
+ });
46540
+ process3.emit = originalProcessEmit;
46541
+ process3.reallyExit = originalProcessReallyExit;
46542
+ emitter.count -= 1;
46543
+ }, "unload");
46544
+ module2.exports.unload = unload;
46545
+ emit = /* @__PURE__ */ __name(function emit2(event, code, signal) {
46546
+ if (emitter.emitted[event]) {
46547
+ return;
46548
+ }
46549
+ emitter.emitted[event] = true;
46550
+ emitter.emit(event, code, signal);
46551
+ }, "emit");
46552
+ sigListeners = {};
46553
+ signals.forEach(function(sig) {
46554
+ sigListeners[sig] = /* @__PURE__ */ __name(function listener() {
46555
+ if (!processOk(global.process)) {
46556
+ return;
46557
+ }
46558
+ var listeners = process3.listeners(sig);
46559
+ if (listeners.length === emitter.count) {
46560
+ unload();
46561
+ emit("exit", null, sig);
46562
+ emit("afterexit", null, sig);
46563
+ if (isWin && sig === "SIGHUP") {
46564
+ sig = "SIGINT";
46565
+ }
46566
+ process3.kill(process3.pid, sig);
46567
+ }
46568
+ }, "listener");
46569
+ });
46570
+ module2.exports.signals = function() {
46571
+ return signals;
46572
+ };
46573
+ loaded = false;
46574
+ load = /* @__PURE__ */ __name(function load2() {
46575
+ if (loaded || !processOk(global.process)) {
46576
+ return;
46577
+ }
46578
+ loaded = true;
46579
+ emitter.count += 1;
46580
+ signals = signals.filter(function(sig) {
46581
+ try {
46582
+ process3.on(sig, sigListeners[sig]);
46583
+ return true;
46584
+ } catch (er) {
46585
+ return false;
46586
+ }
46587
+ });
46588
+ process3.emit = processEmit;
46589
+ process3.reallyExit = processReallyExit;
46590
+ }, "load");
46591
+ module2.exports.load = load;
46592
+ originalProcessReallyExit = process3.reallyExit;
46593
+ processReallyExit = /* @__PURE__ */ __name(function processReallyExit2(code) {
46594
+ if (!processOk(global.process)) {
46595
+ return;
46596
+ }
46597
+ process3.exitCode = code || /* istanbul ignore next */
46598
+ 0;
46599
+ emit("exit", process3.exitCode, null);
46600
+ emit("afterexit", process3.exitCode, null);
46601
+ originalProcessReallyExit.call(process3, process3.exitCode);
46602
+ }, "processReallyExit");
46603
+ originalProcessEmit = process3.emit;
46604
+ processEmit = /* @__PURE__ */ __name(function processEmit2(ev, arg) {
46605
+ if (ev === "exit" && processOk(global.process)) {
46606
+ if (arg !== void 0) {
46607
+ process3.exitCode = arg;
46608
+ }
46609
+ var ret = originalProcessEmit.apply(this, arguments);
46610
+ emit("exit", process3.exitCode, null);
46611
+ emit("afterexit", process3.exitCode, null);
46612
+ return ret;
46613
+ } else {
46614
+ return originalProcessEmit.apply(this, arguments);
46615
+ }
46616
+ }, "processEmit");
46617
+ }
46618
+ var assert2;
46619
+ var signals;
46620
+ var isWin;
46621
+ var EE;
46622
+ var emitter;
46623
+ var unload;
46624
+ var emit;
46625
+ var sigListeners;
46626
+ var loaded;
46627
+ var load;
46628
+ var originalProcessReallyExit;
46629
+ var processReallyExit;
46630
+ var originalProcessEmit;
46631
+ var processEmit;
46632
+ }
46633
+ });
46634
+
46635
+ // ../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js
46636
+ var require_mtime_precision = __commonJS({
46637
+ "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/mtime-precision.js"(exports2, module2) {
46638
+ "use strict";
46639
+ var cacheSymbol = /* @__PURE__ */ Symbol();
46640
+ function probe(file2, fs6, callback) {
46641
+ const cachedPrecision = fs6[cacheSymbol];
46642
+ if (cachedPrecision) {
46643
+ return fs6.stat(file2, (err, stat) => {
46644
+ if (err) {
46645
+ return callback(err);
46646
+ }
46647
+ callback(null, stat.mtime, cachedPrecision);
46648
+ });
46649
+ }
46650
+ const mtime = new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
46651
+ fs6.utimes(file2, mtime, mtime, (err) => {
46652
+ if (err) {
46653
+ return callback(err);
46654
+ }
46655
+ fs6.stat(file2, (err2, stat) => {
46656
+ if (err2) {
46657
+ return callback(err2);
46658
+ }
46659
+ const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
46660
+ Object.defineProperty(fs6, cacheSymbol, { value: precision });
46661
+ callback(null, stat.mtime, precision);
46662
+ });
46663
+ });
46664
+ }
46665
+ __name(probe, "probe");
46666
+ function getMtime(precision) {
46667
+ let now = Date.now();
46668
+ if (precision === "s") {
46669
+ now = Math.ceil(now / 1e3) * 1e3;
46670
+ }
46671
+ return new Date(now);
46672
+ }
46673
+ __name(getMtime, "getMtime");
46674
+ module2.exports.probe = probe;
46675
+ module2.exports.getMtime = getMtime;
46676
+ }
46677
+ });
46678
+
46679
+ // ../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js
46680
+ var require_lockfile = __commonJS({
46681
+ "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/lockfile.js"(exports2, module2) {
46682
+ "use strict";
46683
+ var path12 = require("path");
46684
+ var fs6 = require_graceful_fs();
46685
+ var retry = require_retry3();
46686
+ var onExit = require_signal_exit();
46687
+ var mtimePrecision = require_mtime_precision();
46688
+ var locks = {};
46689
+ function getLockFile(file2, options) {
46690
+ return options.lockfilePath || `${file2}.lock`;
46691
+ }
46692
+ __name(getLockFile, "getLockFile");
46693
+ function resolveCanonicalPath(file2, options, callback) {
46694
+ if (!options.realpath) {
46695
+ return callback(null, path12.resolve(file2));
46696
+ }
46697
+ options.fs.realpath(file2, callback);
46698
+ }
46699
+ __name(resolveCanonicalPath, "resolveCanonicalPath");
46700
+ function acquireLock(file2, options, callback) {
46701
+ const lockfilePath = getLockFile(file2, options);
46702
+ options.fs.mkdir(lockfilePath, (err) => {
46703
+ if (!err) {
46704
+ return mtimePrecision.probe(lockfilePath, options.fs, (err2, mtime, mtimePrecision2) => {
46705
+ if (err2) {
46706
+ options.fs.rmdir(lockfilePath, () => {
46707
+ });
46708
+ return callback(err2);
46709
+ }
46710
+ callback(null, mtime, mtimePrecision2);
46711
+ });
46712
+ }
46713
+ if (err.code !== "EEXIST") {
46714
+ return callback(err);
46715
+ }
46716
+ if (options.stale <= 0) {
46717
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
46718
+ }
46719
+ options.fs.stat(lockfilePath, (err2, stat) => {
46720
+ if (err2) {
46721
+ if (err2.code === "ENOENT") {
46722
+ return acquireLock(file2, { ...options, stale: 0 }, callback);
46723
+ }
46724
+ return callback(err2);
46725
+ }
46726
+ if (!isLockStale(stat, options)) {
46727
+ return callback(Object.assign(new Error("Lock file is already being held"), { code: "ELOCKED", file: file2 }));
46728
+ }
46729
+ removeLock(file2, options, (err3) => {
46730
+ if (err3) {
46731
+ return callback(err3);
46732
+ }
46733
+ acquireLock(file2, { ...options, stale: 0 }, callback);
46734
+ });
46735
+ });
46736
+ });
46737
+ }
46738
+ __name(acquireLock, "acquireLock");
46739
+ function isLockStale(stat, options) {
46740
+ return stat.mtime.getTime() < Date.now() - options.stale;
46741
+ }
46742
+ __name(isLockStale, "isLockStale");
46743
+ function removeLock(file2, options, callback) {
46744
+ options.fs.rmdir(getLockFile(file2, options), (err) => {
46745
+ if (err && err.code !== "ENOENT") {
46746
+ return callback(err);
46747
+ }
46748
+ callback();
46749
+ });
46750
+ }
46751
+ __name(removeLock, "removeLock");
46752
+ function updateLock(file2, options) {
46753
+ const lock3 = locks[file2];
46754
+ if (lock3.updateTimeout) {
46755
+ return;
46756
+ }
46757
+ lock3.updateDelay = lock3.updateDelay || options.update;
46758
+ lock3.updateTimeout = setTimeout(() => {
46759
+ lock3.updateTimeout = null;
46760
+ options.fs.stat(lock3.lockfilePath, (err, stat) => {
46761
+ const isOverThreshold = lock3.lastUpdate + options.stale < Date.now();
46762
+ if (err) {
46763
+ if (err.code === "ENOENT" || isOverThreshold) {
46764
+ return setLockAsCompromised(file2, lock3, Object.assign(err, { code: "ECOMPROMISED" }));
46765
+ }
46766
+ lock3.updateDelay = 1e3;
46767
+ return updateLock(file2, options);
46768
+ }
46769
+ const isMtimeOurs = lock3.mtime.getTime() === stat.mtime.getTime();
46770
+ if (!isMtimeOurs) {
46771
+ return setLockAsCompromised(
46772
+ file2,
46773
+ lock3,
46774
+ Object.assign(
46775
+ new Error("Unable to update lock within the stale threshold"),
46776
+ { code: "ECOMPROMISED" }
46777
+ )
46778
+ );
46779
+ }
46780
+ const mtime = mtimePrecision.getMtime(lock3.mtimePrecision);
46781
+ options.fs.utimes(lock3.lockfilePath, mtime, mtime, (err2) => {
46782
+ const isOverThreshold2 = lock3.lastUpdate + options.stale < Date.now();
46783
+ if (lock3.released) {
46784
+ return;
46785
+ }
46786
+ if (err2) {
46787
+ if (err2.code === "ENOENT" || isOverThreshold2) {
46788
+ return setLockAsCompromised(file2, lock3, Object.assign(err2, { code: "ECOMPROMISED" }));
46789
+ }
46790
+ lock3.updateDelay = 1e3;
46791
+ return updateLock(file2, options);
46792
+ }
46793
+ lock3.mtime = mtime;
46794
+ lock3.lastUpdate = Date.now();
46795
+ lock3.updateDelay = null;
46796
+ updateLock(file2, options);
46797
+ });
46798
+ });
46799
+ }, lock3.updateDelay);
46800
+ if (lock3.updateTimeout.unref) {
46801
+ lock3.updateTimeout.unref();
46802
+ }
46803
+ }
46804
+ __name(updateLock, "updateLock");
46805
+ function setLockAsCompromised(file2, lock3, err) {
46806
+ lock3.released = true;
46807
+ if (lock3.updateTimeout) {
46808
+ clearTimeout(lock3.updateTimeout);
46809
+ }
46810
+ if (locks[file2] === lock3) {
46811
+ delete locks[file2];
46812
+ }
46813
+ lock3.options.onCompromised(err);
46814
+ }
46815
+ __name(setLockAsCompromised, "setLockAsCompromised");
46816
+ function lock2(file2, options, callback) {
46817
+ options = {
46818
+ stale: 1e4,
46819
+ update: null,
46820
+ realpath: true,
46821
+ retries: 0,
46822
+ fs: fs6,
46823
+ onCompromised: /* @__PURE__ */ __name((err) => {
46824
+ throw err;
46825
+ }, "onCompromised"),
46826
+ ...options
46827
+ };
46828
+ options.retries = options.retries || 0;
46829
+ options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
46830
+ options.stale = Math.max(options.stale || 0, 2e3);
46831
+ options.update = options.update == null ? options.stale / 2 : options.update || 0;
46832
+ options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
46833
+ resolveCanonicalPath(file2, options, (err, file3) => {
46834
+ if (err) {
46835
+ return callback(err);
46836
+ }
46837
+ const operation = retry.operation(options.retries);
46838
+ operation.attempt(() => {
46839
+ acquireLock(file3, options, (err2, mtime, mtimePrecision2) => {
46840
+ if (operation.retry(err2)) {
46841
+ return;
46842
+ }
46843
+ if (err2) {
46844
+ return callback(operation.mainError());
46845
+ }
46846
+ const lock3 = locks[file3] = {
46847
+ lockfilePath: getLockFile(file3, options),
46848
+ mtime,
46849
+ mtimePrecision: mtimePrecision2,
46850
+ options,
46851
+ lastUpdate: Date.now()
46852
+ };
46853
+ updateLock(file3, options);
46854
+ callback(null, (releasedCallback) => {
46855
+ if (lock3.released) {
46856
+ return releasedCallback && releasedCallback(Object.assign(new Error("Lock is already released"), { code: "ERELEASED" }));
46857
+ }
46858
+ unlock(file3, { ...options, realpath: false }, releasedCallback);
46859
+ });
46860
+ });
46861
+ });
46862
+ });
46863
+ }
46864
+ __name(lock2, "lock");
46865
+ function unlock(file2, options, callback) {
46866
+ options = {
46867
+ fs: fs6,
46868
+ realpath: true,
46869
+ ...options
46870
+ };
46871
+ resolveCanonicalPath(file2, options, (err, file3) => {
46872
+ if (err) {
46873
+ return callback(err);
46874
+ }
46875
+ const lock3 = locks[file3];
46876
+ if (!lock3) {
46877
+ return callback(Object.assign(new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
46878
+ }
46879
+ lock3.updateTimeout && clearTimeout(lock3.updateTimeout);
46880
+ lock3.released = true;
46881
+ delete locks[file3];
46882
+ removeLock(file3, options, callback);
46883
+ });
46884
+ }
46885
+ __name(unlock, "unlock");
46886
+ function check2(file2, options, callback) {
46887
+ options = {
46888
+ stale: 1e4,
46889
+ realpath: true,
46890
+ fs: fs6,
46891
+ ...options
46892
+ };
46893
+ options.stale = Math.max(options.stale || 0, 2e3);
46894
+ resolveCanonicalPath(file2, options, (err, file3) => {
46895
+ if (err) {
46896
+ return callback(err);
46897
+ }
46898
+ options.fs.stat(getLockFile(file3, options), (err2, stat) => {
46899
+ if (err2) {
46900
+ return err2.code === "ENOENT" ? callback(null, false) : callback(err2);
46901
+ }
46902
+ return callback(null, !isLockStale(stat, options));
46903
+ });
46904
+ });
46905
+ }
46906
+ __name(check2, "check");
46907
+ function getLocks() {
46908
+ return locks;
46909
+ }
46910
+ __name(getLocks, "getLocks");
46911
+ onExit(() => {
46912
+ for (const file2 in locks) {
46913
+ const options = locks[file2].options;
46914
+ try {
46915
+ options.fs.rmdirSync(getLockFile(file2, options));
46916
+ } catch (e) {
46917
+ }
46918
+ }
46919
+ });
46920
+ module2.exports.lock = lock2;
46921
+ module2.exports.unlock = unlock;
46922
+ module2.exports.check = check2;
46923
+ module2.exports.getLocks = getLocks;
46924
+ }
46925
+ });
46926
+
46927
+ // ../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js
46928
+ var require_adapter = __commonJS({
46929
+ "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/lib/adapter.js"(exports2, module2) {
46930
+ "use strict";
46931
+ var fs6 = require_graceful_fs();
46932
+ function createSyncFs(fs7) {
46933
+ const methods = ["mkdir", "realpath", "stat", "rmdir", "utimes"];
46934
+ const newFs = { ...fs7 };
46935
+ methods.forEach((method) => {
46936
+ newFs[method] = (...args) => {
46937
+ const callback = args.pop();
46938
+ let ret;
46939
+ try {
46940
+ ret = fs7[`${method}Sync`](...args);
46941
+ } catch (err) {
46942
+ return callback(err);
46943
+ }
46944
+ callback(null, ret);
46945
+ };
46946
+ });
46947
+ return newFs;
46948
+ }
46949
+ __name(createSyncFs, "createSyncFs");
46950
+ function toPromise(method) {
46951
+ return (...args) => new Promise((resolve3, reject) => {
46952
+ args.push((err, result) => {
46953
+ if (err) {
46954
+ reject(err);
46955
+ } else {
46956
+ resolve3(result);
46957
+ }
46958
+ });
46959
+ method(...args);
46960
+ });
46961
+ }
46962
+ __name(toPromise, "toPromise");
46963
+ function toSync(method) {
46964
+ return (...args) => {
46965
+ let err;
46966
+ let result;
46967
+ args.push((_err, _result) => {
46968
+ err = _err;
46969
+ result = _result;
46970
+ });
46971
+ method(...args);
46972
+ if (err) {
46973
+ throw err;
46974
+ }
46975
+ return result;
46976
+ };
46977
+ }
46978
+ __name(toSync, "toSync");
46979
+ function toSyncOptions(options) {
46980
+ options = { ...options };
46981
+ options.fs = createSyncFs(options.fs || fs6);
46982
+ if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) {
46983
+ throw Object.assign(new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
46984
+ }
46985
+ return options;
46986
+ }
46987
+ __name(toSyncOptions, "toSyncOptions");
46988
+ module2.exports = {
46989
+ toPromise,
46990
+ toSync,
46991
+ toSyncOptions
46992
+ };
46993
+ }
46994
+ });
46995
+
46996
+ // ../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/index.js
46997
+ var require_proper_lockfile = __commonJS({
46998
+ "../../node_modules/.pnpm/proper-lockfile@4.1.2/node_modules/proper-lockfile/index.js"(exports2, module2) {
46999
+ "use strict";
47000
+ var lockfile = require_lockfile();
47001
+ var { toPromise, toSync, toSyncOptions } = require_adapter();
47002
+ async function lock2(file2, options) {
47003
+ const release = await toPromise(lockfile.lock)(file2, options);
47004
+ return toPromise(release);
47005
+ }
47006
+ __name(lock2, "lock");
47007
+ function lockSync(file2, options) {
47008
+ const release = toSync(lockfile.lock)(file2, toSyncOptions(options));
47009
+ return toSync(release);
47010
+ }
47011
+ __name(lockSync, "lockSync");
47012
+ function unlock(file2, options) {
47013
+ return toPromise(lockfile.unlock)(file2, options);
47014
+ }
47015
+ __name(unlock, "unlock");
47016
+ function unlockSync(file2, options) {
47017
+ return toSync(lockfile.unlock)(file2, toSyncOptions(options));
47018
+ }
47019
+ __name(unlockSync, "unlockSync");
47020
+ function check2(file2, options) {
47021
+ return toPromise(lockfile.check)(file2, options);
47022
+ }
47023
+ __name(check2, "check");
47024
+ function checkSync(file2, options) {
47025
+ return toSync(lockfile.check)(file2, toSyncOptions(options));
47026
+ }
47027
+ __name(checkSync, "checkSync");
47028
+ module2.exports = lock2;
47029
+ module2.exports.lock = lock2;
47030
+ module2.exports.unlock = unlock;
47031
+ module2.exports.lockSync = lockSync;
47032
+ module2.exports.unlockSync = unlockSync;
47033
+ module2.exports.check = check2;
47034
+ module2.exports.checkSync = checkSync;
47035
+ }
47036
+ });
47037
+
45394
47038
  // ../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js
45395
47039
  var require_get_context = __commonJS({
45396
47040
  "../../node_modules/.pnpm/@vercel+oidc@3.2.0/node_modules/@vercel/oidc/dist/get-context.js"(exports2, module2) {
@@ -51605,7 +53249,7 @@ init_dist();
51605
53249
  init_node();
51606
53250
 
51607
53251
  // ../core/dist/version.js
51608
- var version2 = "4.8.13";
53252
+ var version2 = "4.8.14";
51609
53253
 
51610
53254
  // ../core/dist/runtime/world.js
51611
53255
  var import_node_module = require("node:module");
@@ -51868,6 +53512,26 @@ function once2(fn) {
51868
53512
  return result;
51869
53513
  }
51870
53514
  __name(once2, "once");
53515
+ function withInProcessLock(locks, key, fn) {
53516
+ const prev = locks.get(key);
53517
+ const taskBox = {};
53518
+ const task = (async () => {
53519
+ if (prev) {
53520
+ await prev.catch(() => void 0);
53521
+ }
53522
+ try {
53523
+ return await fn();
53524
+ } finally {
53525
+ if (locks.get(key) === taskBox.task) {
53526
+ locks.delete(key);
53527
+ }
53528
+ }
53529
+ })();
53530
+ taskBox.task = task;
53531
+ locks.set(key, task);
53532
+ return task;
53533
+ }
53534
+ __name(withInProcessLock, "withInProcessLock");
51871
53535
 
51872
53536
  // ../world-local/dist/config.js
51873
53537
  var getDataDirFromEnv = /* @__PURE__ */ __name(() => {
@@ -53617,26 +55281,6 @@ async function pinCanonicalEventIdForLegacyClaim(basedir, token, runId, hookId,
53617
55281
  return existing?.eventId ?? null;
53618
55282
  }
53619
55283
  __name(pinCanonicalEventIdForLegacyClaim, "pinCanonicalEventIdForLegacyClaim");
53620
- function withInProcessLock(locks, key, fn) {
53621
- const prev = locks.get(key);
53622
- const taskBox = {};
53623
- const task = (async () => {
53624
- if (prev) {
53625
- await prev.catch(() => void 0);
53626
- }
53627
- try {
53628
- return await fn();
53629
- } finally {
53630
- if (locks.get(key) === taskBox.task) {
53631
- locks.delete(key);
53632
- }
53633
- }
53634
- })();
53635
- taskBox.task = task;
53636
- locks.set(key, task);
53637
- return task;
53638
- }
53639
- __name(withInProcessLock, "withInProcessLock");
53640
55284
  async function deleteAllWaitsForRun(basedir, runId) {
53641
55285
  const waitsDir = import_node_path5.default.join(basedir, "waits");
53642
55286
  const files = await listJSONFiles(waitsDir);
@@ -54495,12 +56139,18 @@ __name(createStorage, "createStorage");
54495
56139
  var import_node_events = require("node:events");
54496
56140
  var import_promises5 = __toESM(require("node:fs/promises"), 1);
54497
56141
  var import_node_path8 = __toESM(require("node:path"), 1);
56142
+ var import_proper_lockfile = __toESM(require_proper_lockfile(), 1);
54498
56143
  init_node();
54499
56144
  init_zod();
54500
56145
  var monotonicUlid2 = monotonicFactory(() => Math.random());
54501
56146
  var RunStreamsSchema = external_exports.object({
54502
56147
  streams: external_exports.array(external_exports.string())
54503
56148
  });
56149
+ var RUN_STREAMS_LOCK_OPTIONS = {
56150
+ realpath: false,
56151
+ stale: 1e4,
56152
+ retries: { retries: 150, factor: 1, minTimeout: 100, maxTimeout: 100 }
56153
+ };
54504
56154
  var EOF_MARKER = 1;
54505
56155
  function isEofByte(byte) {
54506
56156
  return byte === EOF_MARKER;
@@ -54559,23 +56209,69 @@ function createStreamer(basedir, tag) {
54559
56209
  const tagSuffix = tag ? `.${tag}` : "";
54560
56210
  const streamEmitter = new import_node_events.EventEmitter();
54561
56211
  const registeredStreams = /* @__PURE__ */ new Set();
54562
- async function registerStreamForRun(runId, streamName) {
56212
+ const runStreamsLocks = /* @__PURE__ */ new Map();
56213
+ let warnedRunStreamsLockFailure = false;
56214
+ async function readRunStreams(runId) {
56215
+ const data = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
56216
+ return data?.streams ?? [];
56217
+ }
56218
+ __name(readRunStreams, "readRunStreams");
56219
+ async function registerStreamForRun(runId, streamName, { verify = false } = {}) {
54563
56220
  assertSafeEntityId("runId", runId);
54564
56221
  assertSafeEntityId("streamName", streamName);
54565
56222
  const cacheKey = `${runId}:${streamName}`;
54566
56223
  if (registeredStreams.has(cacheKey)) {
54567
- return;
56224
+ if (!verify)
56225
+ return;
56226
+ const listed = await readRunStreams(runId).catch(() => null);
56227
+ if (listed === null || listed.includes(streamName))
56228
+ return;
56229
+ registeredStreams.delete(cacheKey);
54568
56230
  }
54569
56231
  const runStreamsPath = taggedPath(basedir, "streams/runs", runId, tag);
54570
- const existing = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
54571
- const streams = existing?.streams ?? [];
54572
- if (!streams.includes(streamName)) {
54573
- streams.push(streamName);
54574
- await writeJSON(runStreamsPath, { streams }, { overwrite: true });
54575
- }
54576
- registeredStreams.add(cacheKey);
56232
+ await withInProcessLock(runStreamsLocks, runStreamsPath, async () => {
56233
+ if (registeredStreams.has(cacheKey))
56234
+ return;
56235
+ if (await addToRunStreams(runStreamsPath, runId, streamName)) {
56236
+ registeredStreams.add(cacheKey);
56237
+ }
56238
+ });
54577
56239
  }
54578
56240
  __name(registerStreamForRun, "registerStreamForRun");
56241
+ async function addToRunStreams(runStreamsPath, runId, streamName) {
56242
+ await import_promises5.default.mkdir(import_node_path8.default.dirname(runStreamsPath), { recursive: true });
56243
+ let compromised = false;
56244
+ let release;
56245
+ try {
56246
+ release = await (0, import_proper_lockfile.lock)(runStreamsPath, {
56247
+ ...RUN_STREAMS_LOCK_OPTIONS,
56248
+ // The default handler throws from a timer, which would crash the
56249
+ // process.
56250
+ onCompromised: /* @__PURE__ */ __name(() => {
56251
+ compromised = true;
56252
+ }, "onCompromised")
56253
+ });
56254
+ } catch (error48) {
56255
+ if (!warnedRunStreamsLockFailure) {
56256
+ warnedRunStreamsLockFailure = true;
56257
+ console.warn(`[world-local] Could not lock the stream index of run ${runId}; updating it without the lock:`, error48 instanceof Error ? error48.message : error48);
56258
+ }
56259
+ }
56260
+ try {
56261
+ const streams = await readRunStreams(runId);
56262
+ if (!streams.includes(streamName)) {
56263
+ streams.push(streamName);
56264
+ await writeJSON(runStreamsPath, { streams }, { overwrite: true });
56265
+ }
56266
+ } finally {
56267
+ if (release && !compromised) {
56268
+ await release().catch(() => {
56269
+ });
56270
+ }
56271
+ }
56272
+ return !compromised;
56273
+ }
56274
+ __name(addToRunStreams, "addToRunStreams");
54579
56275
  function toBuffer(chunk) {
54580
56276
  if (typeof chunk === "string") {
54581
56277
  return Buffer.from(new TextEncoder().encode(chunk));
@@ -54587,6 +56283,9 @@ function createStreamer(basedir, tag) {
54587
56283
  }
54588
56284
  __name(toBuffer, "toBuffer");
54589
56285
  return {
56286
+ clearCache() {
56287
+ registeredStreams.clear();
56288
+ },
54590
56289
  async writeToStream(name, _runId, chunk) {
54591
56290
  const chunkId = `chnk_${monotonicUlid2()}`;
54592
56291
  const runId = await _runId;
@@ -54637,15 +56336,14 @@ function createStreamer(basedir, tag) {
54637
56336
  async closeStream(name, _runId) {
54638
56337
  const chunkId = `chnk_${monotonicUlid2()}`;
54639
56338
  const runId = await _runId;
54640
- await registerStreamForRun(runId, name);
56339
+ await registerStreamForRun(runId, name, { verify: true });
54641
56340
  const chunkPath = import_node_path8.default.join(basedir, "streams", "chunks", `${name}-${chunkId}${tagSuffix}.bin`);
54642
56341
  await write(chunkPath, serializeChunk({ chunk: Buffer.from([]), eof: true }));
54643
56342
  streamEmitter.emit(`close:${name}`, { streamName: name });
54644
56343
  },
54645
56344
  async listStreamsByRunId(runId) {
54646
56345
  assertSafeEntityId("runId", runId);
54647
- const data = await readJSONWithFallback(basedir, "streams/runs", runId, RunStreamsSchema, tag);
54648
- return data?.streams ?? [];
56346
+ return readRunStreams(runId);
54649
56347
  },
54650
56348
  async getStreamChunks(name, _runId, options) {
54651
56349
  const limit = options?.limit ?? 100;
@@ -54908,13 +56606,14 @@ function createLocalWorld(args) {
54908
56606
  const tag = mergedConfig.tag;
54909
56607
  const queue = createQueue(mergedConfig);
54910
56608
  const { clearCache: clearStorageCache, ...storage } = createStorage(mergedConfig.dataDir, tag);
56609
+ const { clearCache: clearStreamerCache, ...streamer } = createStreamer(mergedConfig.dataDir, tag);
54911
56610
  const recoverActiveRuns = resolveRecoverActiveRuns(mergedConfig);
54912
56611
  return {
54913
56612
  specVersion: SPEC_VERSION_CURRENT,
54914
56613
  ...queue,
54915
56614
  ...storage,
54916
56615
  ...instrumentObject("world.streams", {
54917
- ...createStreamer(mergedConfig.dataDir, tag),
56616
+ ...streamer,
54918
56617
  ...mergedConfig.streamFlushIntervalMs !== void 0 && {
54919
56618
  streamFlushIntervalMs: mergedConfig.streamFlushIntervalMs
54920
56619
  }
@@ -54976,6 +56675,7 @@ function createLocalWorld(args) {
54976
56675
  await (0, import_promises6.rm)(mergedConfig.dataDir, { recursive: true, force: true });
54977
56676
  await initDataDir(mergedConfig.dataDir);
54978
56677
  }
56678
+ clearStreamerCache();
54979
56679
  }
54980
56680
  };
54981
56681
  }
@@ -55155,9 +56855,10 @@ function getEventsRetryAgentOptions() {
55155
56855
  }
55156
56856
  __name(getEventsRetryAgentOptions, "getEventsRetryAgentOptions");
55157
56857
  var STREAM_RETRY_OPTIONS = {
55158
- retryAfter: true,
56858
+ maxRetries: 0,
55159
56859
  methods: ["PUT"],
55160
- statusCodes: [429]
56860
+ statusCodes: [],
56861
+ errorCodes: []
55161
56862
  };
55162
56863
  var STREAM_CLOSE_RETRY_OPTIONS = {
55163
56864
  retryAfter: true,
@@ -55462,6 +57163,7 @@ var UrlFull2 = SemanticConvention3("url.full");
55462
57163
  var ServerAddress2 = SemanticConvention3("server.address");
55463
57164
  var ServerPort2 = SemanticConvention3("server.port");
55464
57165
  var HttpResponseStatusCode2 = SemanticConvention3("http.response.status_code");
57166
+ var HttpRequestResendCount = SemanticConvention3("http.request.resend_count");
55465
57167
  var ErrorType2 = SemanticConvention3("error.type");
55466
57168
  var WorldParseFormat2 = SemanticConvention3("workflow.world.parse.format");
55467
57169
  var PeerService3 = SemanticConvention3("peer.service");
@@ -55589,7 +57291,10 @@ function parseRetryAfter(value) {
55589
57291
  if (!value)
55590
57292
  return void 0;
55591
57293
  const parsed = parseInt(value, 10);
55592
- return Number.isNaN(parsed) ? void 0 : parsed;
57294
+ if (!Number.isNaN(parsed))
57295
+ return parsed;
57296
+ const date5 = Date.parse(value);
57297
+ return Number.isNaN(date5) ? void 0 : Math.max(0, Math.ceil((date5 - Date.now()) / 1e3));
55593
57298
  }
55594
57299
  __name(parseRetryAfter, "parseRetryAfter");
55595
57300
  function errorForResponse(status, message, opts = {}) {
@@ -55650,16 +57355,80 @@ function httpClientSpanAttributes(args) {
55650
57355
  };
55651
57356
  }
55652
57357
  __name(httpClientSpanAttributes, "httpClientSpanAttributes");
57358
+ var STREAM_APPEND_MAX_RETRIES = 5;
57359
+ var STREAM_APPEND_CONNECT_ERROR_CODES = /* @__PURE__ */ new Set([
57360
+ "ECONNREFUSED",
57361
+ "ENOTFOUND",
57362
+ "EAI_AGAIN",
57363
+ "UND_ERR_CONNECT_TIMEOUT"
57364
+ ]);
57365
+ var STREAM_APPEND_THROTTLE_BUDGET_MS = 3e4;
57366
+ var STREAM_APPEND_MIN_THROTTLE_WAIT_MS = 1e3;
57367
+ var STREAM_APPEND_DEADLINE_RESERVE_MS = 1e4;
57368
+ function streamAppendDeadlineReserveMs(timeoutMs) {
57369
+ return Math.min(STREAM_APPEND_DEADLINE_RESERVE_MS, timeoutMs / 2);
57370
+ }
57371
+ __name(streamAppendDeadlineReserveMs, "streamAppendDeadlineReserveMs");
57372
+ var sleep = /* @__PURE__ */ __name((ms2, signal) => new Promise((resolve3, reject) => {
57373
+ if (signal?.aborted) {
57374
+ reject(signal.reason);
57375
+ return;
57376
+ }
57377
+ const onAbort = /* @__PURE__ */ __name(() => {
57378
+ clearTimeout(timer);
57379
+ reject(signal?.reason);
57380
+ }, "onAbort");
57381
+ const timer = setTimeout(() => {
57382
+ signal?.removeEventListener("abort", onAbort);
57383
+ resolve3();
57384
+ }, ms2);
57385
+ signal?.addEventListener("abort", onAbort, { once: true });
57386
+ }), "sleep");
57387
+ async function fetchStreamAppend(request, { signal, deadlineMs, reserveMs = 0, onResend } = {}) {
57388
+ const resendFits = /* @__PURE__ */ __name((waitMs) => deadlineMs === void 0 || deadlineMs - (Date.now() + waitMs) >= reserveMs, "resendFits");
57389
+ let throttledMs = 0;
57390
+ for (let retry = 0; ; retry++) {
57391
+ if (retry > 0)
57392
+ onResend?.(retry);
57393
+ let response;
57394
+ try {
57395
+ response = await request();
57396
+ } catch (error48) {
57397
+ const code = getTransientTransportCode(error48);
57398
+ const backoffMs = 500 * 2 ** retry;
57399
+ if (retry === STREAM_APPEND_MAX_RETRIES || !code || !STREAM_APPEND_CONNECT_ERROR_CODES.has(code) || !resendFits(backoffMs)) {
57400
+ throw error48;
57401
+ }
57402
+ console.warn(`[workflow] Stream append connection failed (${code}); retrying in-process in ${backoffMs / 1e3}s`);
57403
+ await sleep(backoffMs, signal);
57404
+ continue;
57405
+ }
57406
+ if (response.status !== 429 || isFirewallChallenge429(response.status, response.headers.get("x-vercel-mitigated")) || retry === STREAM_APPEND_MAX_RETRIES) {
57407
+ return response;
57408
+ }
57409
+ const retryAfter = parseRetryAfter(response.headers.get("Retry-After"));
57410
+ const waitMs = Math.max(STREAM_APPEND_MIN_THROTTLE_WAIT_MS, (retryAfter ?? 0) * 1e3);
57411
+ if (throttledMs + waitMs > STREAM_APPEND_THROTTLE_BUDGET_MS || !resendFits(waitMs)) {
57412
+ return response;
57413
+ }
57414
+ throttledMs += waitMs;
57415
+ console.warn(`[workflow] Throttled (429) appending stream chunks; retrying in-process in ${waitMs / 1e3}s${formatVercelDiagnostics(response.headers)}`);
57416
+ await response.body?.cancel().catch(() => {
57417
+ });
57418
+ await sleep(waitMs, signal);
57419
+ }
57420
+ }
57421
+ __name(fetchStreamAppend, "fetchStreamAppend");
55653
57422
  async function instrumentedFetch(opts) {
55654
- const { method, url: url2, headers, body, dispatcher, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome, deferTransportSuccessUntilBody = false } = opts;
57423
+ const { method, url: url2, headers, body, dispatcher, peerService = "workflow-server", timeoutMs = REQUEST_TIMEOUT_MS, signal: callerSignal, retryStreamAppend = false, injectTraceContext = true, cacheBust = true, logLabel, buildError, onTransportOutcome, deferTransportSuccessUntilBody = false } = opts;
55655
57424
  const label = logLabel ?? url2;
55656
57425
  validateHttpUrl(url2);
57426
+ const retryAppend = retryStreamAppend && method === "PUT" && !!dispatcher;
57427
+ const requestBody = retryAppend && body instanceof Uint8Array ? Uint8Array.from(body) : body;
55657
57428
  return trace4(`http ${method}`, { kind: await getSpanKind3("CLIENT") }, async (span) => {
55658
57429
  span?.setAttributes(httpClientSpanAttributes({ method, url: url2, peerService }));
55659
57430
  if (injectTraceContext)
55660
57431
  await injectTraceContextIntoHeaders(headers);
55661
- if (cacheBust)
55662
- headers.set("X-Request-Time", Date.now().toString());
55663
57432
  const timeoutSignal = timeoutMs != null ? AbortSignal.timeout(timeoutMs) : void 0;
55664
57433
  const signal = callerSignal && timeoutSignal ? AbortSignal.any([callerSignal, timeoutSignal]) : callerSignal ?? timeoutSignal;
55665
57434
  const nodeAgents = dispatcher ? void 0 : getNodeHttpAgents();
@@ -55668,11 +57437,14 @@ async function instrumentedFetch(opts) {
55668
57437
  });
55669
57438
  const start2 = Date.now();
55670
57439
  let response;
55671
- try {
55672
- response = nodeAgents ? await nodeHttpFetch(url2, {
57440
+ const request = /* @__PURE__ */ __name(() => {
57441
+ signal?.throwIfAborted();
57442
+ if (cacheBust)
57443
+ headers.set("X-Request-Time", Date.now().toString());
57444
+ return nodeAgents ? nodeHttpFetch(url2, {
55673
57445
  method,
55674
57446
  headers,
55675
- body,
57447
+ body: requestBody,
55676
57448
  signal,
55677
57449
  agents: nodeAgents,
55678
57450
  // Same per-phase deadlines the undici agents are configured
@@ -55680,14 +57452,22 @@ async function instrumentedFetch(opts) {
55680
57452
  // deadline, and a `timeoutMs: null` caller would have no deadline
55681
57453
  // at all.
55682
57454
  ...getNodeHttpPhaseTimeouts()
55683
- }) : await fetch(url2, {
57455
+ }) : fetch(url2, {
55684
57456
  method,
55685
57457
  headers,
55686
- body,
57458
+ body: requestBody,
55687
57459
  signal,
55688
57460
  // eslint-disable-next-line @typescript-eslint/no-explicit-any -- undici dispatcher type doesn't match @types/node's RequestInit
55689
57461
  dispatcher
55690
57462
  });
57463
+ }, "request");
57464
+ try {
57465
+ response = await (retryAppend ? fetchStreamAppend(request, {
57466
+ signal,
57467
+ deadlineMs: timeoutMs != null ? start2 + timeoutMs : void 0,
57468
+ reserveMs: timeoutMs != null ? streamAppendDeadlineReserveMs(timeoutMs) : void 0,
57469
+ onResend: /* @__PURE__ */ __name((count) => span?.setAttributes({ ...HttpRequestResendCount(count) }), "onResend")
57470
+ }) : request());
55691
57471
  } catch (error48) {
55692
57472
  const elapsed = Date.now() - start2;
55693
57473
  onTransportOutcome?.(error48);
@@ -62886,7 +64666,7 @@ var import_oidc3 = __toESM(require_dist(), 1);
62886
64666
  init_dist();
62887
64667
 
62888
64668
  // ../world-vercel/dist/version.js
62889
- var version3 = "4.7.7";
64669
+ var version3 = "4.7.8";
62890
64670
 
62891
64671
  // ../world-vercel/dist/utils.js
62892
64672
  var WORKFLOW_SERVER_URL_OVERRIDE = "";
@@ -63579,7 +65359,7 @@ function isRetryableEventPostError(err) {
63579
65359
  return collectErrorMarkers(err).some((m) => TRANSIENT_CODES.has(m));
63580
65360
  }
63581
65361
  __name(isRetryableEventPostError, "isRetryableEventPostError");
63582
- var sleep = /* @__PURE__ */ __name((ms2) => new Promise((resolve3) => setTimeout(resolve3, ms2)), "sleep");
65362
+ var sleep2 = /* @__PURE__ */ __name((ms2) => new Promise((resolve3) => setTimeout(resolve3, ms2)), "sleep");
63583
65363
  var RETRY_DEBUG_ENABLED = typeof process !== "undefined" && typeof process.env.DEBUG === "string" && (process.env.DEBUG.includes("workflow:") || process.env.DEBUG === "*");
63584
65364
  function logRetry(message, fields) {
63585
65365
  if (!RETRY_DEBUG_ENABLED)
@@ -63610,7 +65390,7 @@ async function withEventPostRetry(fn, eventType) {
63610
65390
  backoffMs: backoff,
63611
65391
  error: errorMarker(err)
63612
65392
  });
63613
- await sleep(backoff);
65393
+ await sleep2(backoff);
63614
65394
  continue;
63615
65395
  }
63616
65396
  if (transient) {
@@ -64580,6 +66360,7 @@ async function fetchStreamMutation(url2, init, operation, config3) {
64580
66360
  // idempotent (unlike chunk appends), so it gets the dispatcher that
64581
66361
  // retries 5xx, which the server's close-barrier protocol depends on.
64582
66362
  dispatcher: operation === "close" ? getStreamCloseDispatcher(config3) : getStreamDispatcher(config3),
66363
+ retryStreamAppend: operation === "write" && !config3?.dispatcher,
64583
66364
  timeoutMs: getStreamMutationTimeoutMs(),
64584
66365
  logLabel: url2.pathname,
64585
66366
  buildError: /* @__PURE__ */ __name(async (res) => createStreamRequestError(operation, url2, res, await res.text()), "buildError")
@@ -68438,27 +70219,21 @@ function getWorkflowRunStreamId(runId, namespace) {
68438
70219
  }
68439
70220
  __name(getWorkflowRunStreamId, "getWorkflowRunStreamId");
68440
70221
 
68441
- // ../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/url-alphabet/index.js
68442
- var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
68443
-
68444
- // ../../node_modules/.pnpm/nanoid@5.1.6/node_modules/nanoid/index.js
68445
- function customRandom(alphabet, defaultSize, getRandom) {
68446
- let mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1;
68447
- let step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
68448
- return (size = defaultSize) => {
68449
- if (!size) return "";
70222
+ // ../core/dist/seeded-nanoid.js
70223
+ var URL_ALPHABET = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
70224
+ var ID_SIZE = 21;
70225
+ var BYTES_PER_ID = 34;
70226
+ function createSeededNanoid(random) {
70227
+ return () => {
70228
+ const bytes = new Uint8Array(BYTES_PER_ID).map(() => 256 * random());
68450
70229
  let id = "";
68451
- while (true) {
68452
- let bytes = getRandom(step);
68453
- let i = step;
68454
- while (i--) {
68455
- id += alphabet[bytes[i] & mask] || "";
68456
- if (id.length >= size) return id;
68457
- }
70230
+ for (let i = BYTES_PER_ID - 1; id.length < ID_SIZE; i--) {
70231
+ id += URL_ALPHABET[bytes[i] & 63];
68458
70232
  }
70233
+ return id;
68459
70234
  };
68460
70235
  }
68461
- __name(customRandom, "customRandom");
70236
+ __name(createSeededNanoid, "createSeededNanoid");
68462
70237
 
68463
70238
  // ../core/dist/workflow.js
68464
70239
  init_node();
@@ -69783,7 +71558,7 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey, st
69783
71558
  });
69784
71559
  const workflowDiscontinuation = withResolvers();
69785
71560
  const ulid5 = monotonicFactory(() => vmGlobalThis.Math.random());
69786
- const generateNanoid = customRandom(urlAlphabet, 21, (size) => new Uint8Array(size).map(() => 256 * vmGlobalThis.Math.random()));
71561
+ const generateNanoid = createSeededNanoid(() => vmGlobalThis.Math.random());
69787
71562
  const promiseQueueHolder = { current: Promise.resolve() };
69788
71563
  const deliveryIdleHolder = { current: /* @__PURE__ */ __name(() => true, "current") };
69789
71564
  let clock = +startedAt;
@@ -69837,10 +71612,10 @@ async function runWorkflow(workflowCode2, workflowRun, events, encryptionKey, st
69837
71612
  });
69838
71613
  const useStep = createUseStep(workflowContext);
69839
71614
  const createHook = createCreateHook(workflowContext);
69840
- const sleep2 = createSleep(workflowContext);
71615
+ const sleep3 = createSleep(workflowContext);
69841
71616
  vmGlobalThis[WORKFLOW_USE_STEP] = useStep;
69842
71617
  vmGlobalThis[WORKFLOW_CREATE_HOOK] = createHook;
69843
- vmGlobalThis[WORKFLOW_SLEEP] = sleep2;
71618
+ vmGlobalThis[WORKFLOW_SLEEP] = sleep3;
69844
71619
  vmGlobalThis[WORKFLOW_GET_STREAM_ID] = (namespace) => getWorkflowRunStreamId(workflowRun.runId, namespace);
69845
71620
  const ctx = {
69846
71621
  workflowName: workflowRun.workflowName,