orion-super-agent-dev 0.1.14 → 0.1.15

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.
Binary file
Binary file
Binary file
Binary file
@@ -5551,6 +5551,24 @@ var import_fs2 = require("fs");
5551
5551
  var import_fs = require("fs");
5552
5552
  var import_path = require("path");
5553
5553
  var tmpSeq = 0;
5554
+ var RENAME_CONTENTION = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
5555
+ function retriesRenameContention(code, platform = process.platform) {
5556
+ return platform === "win32" && code !== void 0 && RENAME_CONTENTION.has(code);
5557
+ }
5558
+ async function renameWhenUnlocked(tmp, target) {
5559
+ const ATTEMPTS = 20;
5560
+ const DELAY_MS = 5;
5561
+ for (let attempt = 1; ; attempt++) {
5562
+ try {
5563
+ await import_fs.promises.rename(tmp, target);
5564
+ return;
5565
+ } catch (err2) {
5566
+ const code = err2.code;
5567
+ if (attempt >= ATTEMPTS || !retriesRenameContention(code)) throw err2;
5568
+ await new Promise((resolve5) => setTimeout(resolve5, DELAY_MS));
5569
+ }
5570
+ }
5571
+ }
5554
5572
  async function atomicWriteFile(targetPath, content, options = {}) {
5555
5573
  const encoding = options.encoding ?? "utf8";
5556
5574
  let target = targetPath;
@@ -5576,7 +5594,7 @@ async function atomicWriteFile(targetPath, content, options = {}) {
5576
5594
  await handle4.close();
5577
5595
  }
5578
5596
  if (targetExists && targetMode !== void 0) await import_fs.promises.chmod(tmp, targetMode);
5579
- await import_fs.promises.rename(tmp, target);
5597
+ await renameWhenUnlocked(tmp, target);
5580
5598
  } catch {
5581
5599
  await import_fs.promises.unlink(tmp).catch(() => {
5582
5600
  });