@threadbase-sh/streamer 1.21.0 → 1.22.0

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.
package/dist/cli.cjs CHANGED
@@ -24089,6 +24089,27 @@ var init_zod = __esm({
24089
24089
  }
24090
24090
  });
24091
24091
 
24092
+ // src/lifecycle/constants.ts
24093
+ function installDir() {
24094
+ return process.env.THREADBASE_INSTALL_DIR ?? (0, import_node_path3.join)((0, import_node_os2.homedir)(), ".threadbase");
24095
+ }
24096
+ function markerPath() {
24097
+ return (0, import_node_path3.join)(installDir(), "prod-suspended.json");
24098
+ }
24099
+ function prefsPath() {
24100
+ return (0, import_node_path3.join)(installDir(), "dev-prefs.json");
24101
+ }
24102
+ var import_node_os2, import_node_path3, LAUNCHD_LABEL, TASK_NAME;
24103
+ var init_constants = __esm({
24104
+ "src/lifecycle/constants.ts"() {
24105
+ "use strict";
24106
+ import_node_os2 = require("os");
24107
+ import_node_path3 = require("path");
24108
+ LAUNCHD_LABEL = "com.ronen.threadbase";
24109
+ TASK_NAME = process.env.THREADBASE_TASK_NAME ?? "Threadbase";
24110
+ }
24111
+ });
24112
+
24092
24113
  // node_modules/pino-std-serializers/lib/err-helpers.js
24093
24114
  var require_err_helpers = __commonJS({
24094
24115
  "node_modules/pino-std-serializers/lib/err-helpers.js"(exports2, module2) {
@@ -26078,7 +26099,7 @@ var require_thread_stream = __commonJS({
26078
26099
  var { version: version2 } = require_package();
26079
26100
  var { EventEmitter: EventEmitter6 } = require("events");
26080
26101
  var { Worker: Worker2 } = require("worker_threads");
26081
- var { join: join25 } = require("path");
26102
+ var { join: join26 } = require("path");
26082
26103
  var { pathToFileURL } = require("url");
26083
26104
  var { wait } = require_wait();
26084
26105
  var {
@@ -26129,7 +26150,7 @@ var require_thread_stream = __commonJS({
26129
26150
  function createWorker(stream, opts) {
26130
26151
  const { filename, workerData } = opts;
26131
26152
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
26132
- const toExecute = bundlerOverrides["thread-stream-worker"] || join25(__dirname, "lib", "worker.js");
26153
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join26(__dirname, "lib", "worker.js");
26133
26154
  const worker = new Worker2(toExecute, {
26134
26155
  ...opts.workerOpts,
26135
26156
  name: opts.workerOpts?.name || "thread-stream",
@@ -26597,7 +26618,7 @@ var require_transport = __commonJS({
26597
26618
  var { createRequire } = require("module");
26598
26619
  var { existsSync: existsSync11 } = require("fs");
26599
26620
  var getCallers = require_caller();
26600
- var { join: join25, isAbsolute: isAbsolute3, sep: sep2 } = require("path");
26621
+ var { join: join26, isAbsolute: isAbsolute3, sep: sep2 } = require("path");
26601
26622
  var { fileURLToPath: fileURLToPath3 } = require("url");
26602
26623
  var sleep = require_atomic_sleep();
26603
26624
  var onExit = require_on_exit_leak_free();
@@ -26750,7 +26771,7 @@ var require_transport = __commonJS({
26750
26771
  throw new Error("only one of target or targets can be specified");
26751
26772
  }
26752
26773
  if (targets) {
26753
- target = bundlerOverrides["pino-worker"] || join25(__dirname, "worker.js");
26774
+ target = bundlerOverrides["pino-worker"] || join26(__dirname, "worker.js");
26754
26775
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
26755
26776
  return {
26756
26777
  ...dest,
@@ -26768,7 +26789,7 @@ var require_transport = __commonJS({
26768
26789
  });
26769
26790
  });
26770
26791
  } else if (pipeline2) {
26771
- target = bundlerOverrides["pino-worker"] || join25(__dirname, "worker.js");
26792
+ target = bundlerOverrides["pino-worker"] || join26(__dirname, "worker.js");
26772
26793
  options.pipelines = [pipeline2.map((dest) => {
26773
26794
  return {
26774
26795
  ...dest,
@@ -26791,7 +26812,7 @@ var require_transport = __commonJS({
26791
26812
  return origin;
26792
26813
  }
26793
26814
  if (origin === "pino/file") {
26794
- return join25(__dirname, "..", "file.js");
26815
+ return join26(__dirname, "..", "file.js");
26795
26816
  }
26796
26817
  let fixTarget2;
26797
26818
  for (const filePath of callers) {
@@ -27772,7 +27793,7 @@ var require_safe_stable_stringify = __commonJS({
27772
27793
  return circularValue;
27773
27794
  }
27774
27795
  let res = "";
27775
- let join25 = ",";
27796
+ let join26 = ",";
27776
27797
  const originalIndentation = indentation;
27777
27798
  if (Array.isArray(value)) {
27778
27799
  if (value.length === 0) {
@@ -27786,7 +27807,7 @@ var require_safe_stable_stringify = __commonJS({
27786
27807
  indentation += spacer;
27787
27808
  res += `
27788
27809
  ${indentation}`;
27789
- join25 = `,
27810
+ join26 = `,
27790
27811
  ${indentation}`;
27791
27812
  }
27792
27813
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -27794,13 +27815,13 @@ ${indentation}`;
27794
27815
  for (; i < maximumValuesToStringify - 1; i++) {
27795
27816
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27796
27817
  res += tmp2 !== void 0 ? tmp2 : "null";
27797
- res += join25;
27818
+ res += join26;
27798
27819
  }
27799
27820
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
27800
27821
  res += tmp !== void 0 ? tmp : "null";
27801
27822
  if (value.length - 1 > maximumBreadth) {
27802
27823
  const removedKeys = value.length - maximumBreadth - 1;
27803
- res += `${join25}"... ${getItemCount(removedKeys)} not stringified"`;
27824
+ res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
27804
27825
  }
27805
27826
  if (spacer !== "") {
27806
27827
  res += `
@@ -27821,7 +27842,7 @@ ${originalIndentation}`;
27821
27842
  let separator = "";
27822
27843
  if (spacer !== "") {
27823
27844
  indentation += spacer;
27824
- join25 = `,
27845
+ join26 = `,
27825
27846
  ${indentation}`;
27826
27847
  whitespace = " ";
27827
27848
  }
@@ -27835,13 +27856,13 @@ ${indentation}`;
27835
27856
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
27836
27857
  if (tmp !== void 0) {
27837
27858
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
27838
- separator = join25;
27859
+ separator = join26;
27839
27860
  }
27840
27861
  }
27841
27862
  if (keyLength > maximumBreadth) {
27842
27863
  const removedKeys = keyLength - maximumBreadth;
27843
27864
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
27844
- separator = join25;
27865
+ separator = join26;
27845
27866
  }
27846
27867
  if (spacer !== "" && separator.length > 1) {
27847
27868
  res = `
@@ -27882,7 +27903,7 @@ ${originalIndentation}`;
27882
27903
  }
27883
27904
  const originalIndentation = indentation;
27884
27905
  let res = "";
27885
- let join25 = ",";
27906
+ let join26 = ",";
27886
27907
  if (Array.isArray(value)) {
27887
27908
  if (value.length === 0) {
27888
27909
  return "[]";
@@ -27895,7 +27916,7 @@ ${originalIndentation}`;
27895
27916
  indentation += spacer;
27896
27917
  res += `
27897
27918
  ${indentation}`;
27898
- join25 = `,
27919
+ join26 = `,
27899
27920
  ${indentation}`;
27900
27921
  }
27901
27922
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -27903,13 +27924,13 @@ ${indentation}`;
27903
27924
  for (; i < maximumValuesToStringify - 1; i++) {
27904
27925
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
27905
27926
  res += tmp2 !== void 0 ? tmp2 : "null";
27906
- res += join25;
27927
+ res += join26;
27907
27928
  }
27908
27929
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
27909
27930
  res += tmp !== void 0 ? tmp : "null";
27910
27931
  if (value.length - 1 > maximumBreadth) {
27911
27932
  const removedKeys = value.length - maximumBreadth - 1;
27912
- res += `${join25}"... ${getItemCount(removedKeys)} not stringified"`;
27933
+ res += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
27913
27934
  }
27914
27935
  if (spacer !== "") {
27915
27936
  res += `
@@ -27922,7 +27943,7 @@ ${originalIndentation}`;
27922
27943
  let whitespace = "";
27923
27944
  if (spacer !== "") {
27924
27945
  indentation += spacer;
27925
- join25 = `,
27946
+ join26 = `,
27926
27947
  ${indentation}`;
27927
27948
  whitespace = " ";
27928
27949
  }
@@ -27931,7 +27952,7 @@ ${indentation}`;
27931
27952
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
27932
27953
  if (tmp !== void 0) {
27933
27954
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
27934
- separator = join25;
27955
+ separator = join26;
27935
27956
  }
27936
27957
  }
27937
27958
  if (spacer !== "" && separator.length > 1) {
@@ -27989,20 +28010,20 @@ ${originalIndentation}`;
27989
28010
  indentation += spacer;
27990
28011
  let res2 = `
27991
28012
  ${indentation}`;
27992
- const join26 = `,
28013
+ const join27 = `,
27993
28014
  ${indentation}`;
27994
28015
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
27995
28016
  let i = 0;
27996
28017
  for (; i < maximumValuesToStringify - 1; i++) {
27997
28018
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
27998
28019
  res2 += tmp2 !== void 0 ? tmp2 : "null";
27999
- res2 += join26;
28020
+ res2 += join27;
28000
28021
  }
28001
28022
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
28002
28023
  res2 += tmp !== void 0 ? tmp : "null";
28003
28024
  if (value.length - 1 > maximumBreadth) {
28004
28025
  const removedKeys = value.length - maximumBreadth - 1;
28005
- res2 += `${join26}"... ${getItemCount(removedKeys)} not stringified"`;
28026
+ res2 += `${join27}"... ${getItemCount(removedKeys)} not stringified"`;
28006
28027
  }
28007
28028
  res2 += `
28008
28029
  ${originalIndentation}`;
@@ -28018,16 +28039,16 @@ ${originalIndentation}`;
28018
28039
  return '"[Object]"';
28019
28040
  }
28020
28041
  indentation += spacer;
28021
- const join25 = `,
28042
+ const join26 = `,
28022
28043
  ${indentation}`;
28023
28044
  let res = "";
28024
28045
  let separator = "";
28025
28046
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
28026
28047
  if (isTypedArrayWithEntries(value)) {
28027
- res += stringifyTypedArray(value, join25, maximumBreadth);
28048
+ res += stringifyTypedArray(value, join26, maximumBreadth);
28028
28049
  keys = keys.slice(value.length);
28029
28050
  maximumPropertiesToStringify -= value.length;
28030
- separator = join25;
28051
+ separator = join26;
28031
28052
  }
28032
28053
  if (deterministic) {
28033
28054
  keys = sort(keys, comparator);
@@ -28038,13 +28059,13 @@ ${indentation}`;
28038
28059
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
28039
28060
  if (tmp !== void 0) {
28040
28061
  res += `${separator}${strEscape(key2)}: ${tmp}`;
28041
- separator = join25;
28062
+ separator = join26;
28042
28063
  }
28043
28064
  }
28044
28065
  if (keyLength > maximumBreadth) {
28045
28066
  const removedKeys = keyLength - maximumBreadth;
28046
28067
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
28047
- separator = join25;
28068
+ separator = join26;
28048
28069
  }
28049
28070
  if (separator !== "") {
28050
28071
  res = `
@@ -124397,27 +124418,6 @@ var require_semver2 = __commonJS({
124397
124418
  }
124398
124419
  });
124399
124420
 
124400
- // src/lifecycle/constants.ts
124401
- function installDir() {
124402
- return process.env.THREADBASE_INSTALL_DIR ?? (0, import_node_path22.join)((0, import_node_os4.homedir)(), ".threadbase");
124403
- }
124404
- function markerPath() {
124405
- return (0, import_node_path22.join)(installDir(), "prod-suspended.json");
124406
- }
124407
- function prefsPath() {
124408
- return (0, import_node_path22.join)(installDir(), "dev-prefs.json");
124409
- }
124410
- var import_node_os4, import_node_path22, LAUNCHD_LABEL, TASK_NAME;
124411
- var init_constants = __esm({
124412
- "src/lifecycle/constants.ts"() {
124413
- "use strict";
124414
- import_node_os4 = require("os");
124415
- import_node_path22 = require("path");
124416
- LAUNCHD_LABEL = "com.ronen.threadbase";
124417
- TASK_NAME = process.env.THREADBASE_TASK_NAME ?? "Threadbase";
124418
- }
124419
- });
124420
-
124421
124421
  // src/lifecycle/launchd.ts
124422
124422
  var launchd_exports = {};
124423
124423
  __export(launchd_exports, {
@@ -124487,8 +124487,8 @@ function darwinPlistPath() {
124487
124487
  return `${process.env.HOME}/Library/LaunchAgents/${resolveLoadedLabel()}.plist`;
124488
124488
  }
124489
124489
  function getLogPaths() {
124490
- const dir = (0, import_node_path23.join)(installDir(), "logs");
124491
- return { stdout: (0, import_node_path23.join)(dir, "stdout.log"), stderr: (0, import_node_path23.join)(dir, "stderr.log") };
124490
+ const dir = (0, import_node_path24.join)(installDir(), "logs");
124491
+ return { stdout: (0, import_node_path24.join)(dir, "stdout.log"), stderr: (0, import_node_path24.join)(dir, "stderr.log") };
124492
124492
  }
124493
124493
  function getAgentPid() {
124494
124494
  try {
@@ -124508,12 +124508,12 @@ function getAgentPid() {
124508
124508
  return null;
124509
124509
  }
124510
124510
  }
124511
- var import_node_child_process4, import_node_path23, BREW_LAUNCHD_LABEL2;
124511
+ var import_node_child_process4, import_node_path24, BREW_LAUNCHD_LABEL2;
124512
124512
  var init_launchd = __esm({
124513
124513
  "src/lifecycle/launchd.ts"() {
124514
124514
  "use strict";
124515
124515
  import_node_child_process4 = require("child_process");
124516
- import_node_path23 = require("path");
124516
+ import_node_path24 = require("path");
124517
124517
  init_constants();
124518
124518
  BREW_LAUNCHD_LABEL2 = "homebrew.mxcl.tb-streamer";
124519
124519
  }
@@ -124538,9 +124538,9 @@ var init_marker_schema = __esm({
124538
124538
 
124539
124539
  // src/lifecycle/marker.ts
124540
124540
  function readMarker() {
124541
- if (!(0, import_node_fs19.existsSync)(markerPath())) return null;
124541
+ if (!(0, import_node_fs20.existsSync)(markerPath())) return null;
124542
124542
  try {
124543
- const raw2 = (0, import_node_fs19.readFileSync)(markerPath(), "utf8");
124543
+ const raw2 = (0, import_node_fs20.readFileSync)(markerPath(), "utf8");
124544
124544
  const parsed = JSON.parse(raw2);
124545
124545
  return MarkerSchema.parse(parsed);
124546
124546
  } catch (err) {
@@ -124552,21 +124552,21 @@ function readMarker() {
124552
124552
  }
124553
124553
  function writeMarker(marker) {
124554
124554
  MarkerSchema.parse(marker);
124555
- (0, import_node_fs19.mkdirSync)((0, import_node_path24.dirname)(markerPath()), { recursive: true });
124555
+ (0, import_node_fs20.mkdirSync)((0, import_node_path25.dirname)(markerPath()), { recursive: true });
124556
124556
  const tmp = `${markerPath()}.tmp`;
124557
- (0, import_node_fs19.writeFileSync)(tmp, `${JSON.stringify(marker, null, 2)}
124557
+ (0, import_node_fs20.writeFileSync)(tmp, `${JSON.stringify(marker, null, 2)}
124558
124558
  `, { mode: 384 });
124559
- (0, import_node_fs19.renameSync)(tmp, markerPath());
124559
+ (0, import_node_fs20.renameSync)(tmp, markerPath());
124560
124560
  }
124561
124561
  function clearMarker() {
124562
- if ((0, import_node_fs19.existsSync)(markerPath())) (0, import_node_fs19.rmSync)(markerPath());
124562
+ if ((0, import_node_fs20.existsSync)(markerPath())) (0, import_node_fs20.rmSync)(markerPath());
124563
124563
  }
124564
- var import_node_fs19, import_node_path24, log3;
124564
+ var import_node_fs20, import_node_path25, log3;
124565
124565
  var init_marker = __esm({
124566
124566
  "src/lifecycle/marker.ts"() {
124567
124567
  "use strict";
124568
- import_node_fs19 = require("fs");
124569
- import_node_path24 = require("path");
124568
+ import_node_fs20 = require("fs");
124569
+ import_node_path25 = require("path");
124570
124570
  init_logger();
124571
124571
  init_constants();
124572
124572
  init_marker_schema();
@@ -124661,9 +124661,9 @@ var init_platform = __esm({
124661
124661
  // src/lifecycle/prefs.ts
124662
124662
  function readPrefs() {
124663
124663
  const path2 = prefsPath();
124664
- if (!(0, import_node_fs21.existsSync)(path2)) return { repos: {} };
124664
+ if (!(0, import_node_fs22.existsSync)(path2)) return { repos: {} };
124665
124665
  try {
124666
- return PrefsSchema.parse(JSON.parse((0, import_node_fs21.readFileSync)(path2, "utf8")));
124666
+ return PrefsSchema.parse(JSON.parse((0, import_node_fs22.readFileSync)(path2, "utf8")));
124667
124667
  } catch (err) {
124668
124668
  log5.warn(`prefs at ${path2} are malformed; treating as empty`, {
124669
124669
  error: err instanceof Error ? err.message : String(err)
@@ -124673,11 +124673,11 @@ function readPrefs() {
124673
124673
  }
124674
124674
  function savePrefs(p2) {
124675
124675
  const path2 = prefsPath();
124676
- (0, import_node_fs21.mkdirSync)((0, import_node_path25.dirname)(path2), { recursive: true });
124676
+ (0, import_node_fs22.mkdirSync)((0, import_node_path26.dirname)(path2), { recursive: true });
124677
124677
  const tmp = `${path2}.tmp`;
124678
- (0, import_node_fs21.writeFileSync)(tmp, `${JSON.stringify(p2, null, 2)}
124678
+ (0, import_node_fs22.writeFileSync)(tmp, `${JSON.stringify(p2, null, 2)}
124679
124679
  `, { mode: 384 });
124680
- (0, import_node_fs21.renameSync)(tmp, path2);
124680
+ (0, import_node_fs22.renameSync)(tmp, path2);
124681
124681
  }
124682
124682
  function writePrefForRepo(repoToplevel, choice) {
124683
124683
  const p2 = readPrefs();
@@ -124698,14 +124698,14 @@ function forgetRepo(repoToplevel) {
124698
124698
  }
124699
124699
  function forgetAll() {
124700
124700
  const path2 = prefsPath();
124701
- if ((0, import_node_fs21.existsSync)(path2)) (0, import_node_fs21.rmSync)(path2);
124701
+ if ((0, import_node_fs22.existsSync)(path2)) (0, import_node_fs22.rmSync)(path2);
124702
124702
  }
124703
- var import_node_fs21, import_node_path25, log5, PrefsSchema;
124703
+ var import_node_fs22, import_node_path26, log5, PrefsSchema;
124704
124704
  var init_prefs = __esm({
124705
124705
  "src/lifecycle/prefs.ts"() {
124706
124706
  "use strict";
124707
- import_node_fs21 = require("fs");
124708
- import_node_path25 = require("path");
124707
+ import_node_fs22 = require("fs");
124708
+ import_node_path26 = require("path");
124709
124709
  init_zod();
124710
124710
  init_logger();
124711
124711
  init_constants();
@@ -128384,6 +128384,23 @@ function loadUpdateConfig(opts = {}) {
128384
128384
  return UpdateConfigSchema.parse(parsed);
128385
128385
  }
128386
128386
 
128387
+ // src/devLog.ts
128388
+ var import_node_fs3 = require("fs");
128389
+ var import_node_path4 = require("path");
128390
+ init_constants();
128391
+ function devLogPath() {
128392
+ return (0, import_node_path4.join)(installDir(), "logs", "dev.log");
128393
+ }
128394
+ function appendDevSessionMarker() {
128395
+ try {
128396
+ const path2 = devLogPath();
128397
+ (0, import_node_fs3.mkdirSync)((0, import_node_path4.join)(installDir(), "logs"), { recursive: true });
128398
+ (0, import_node_fs3.appendFileSync)(path2, `=== dev session started ${(/* @__PURE__ */ new Date()).toISOString()} ===
128399
+ `, "utf8");
128400
+ } catch {
128401
+ }
128402
+ }
128403
+
128387
128404
  // src/lan-url.ts
128388
128405
  var import_os2 = require("os");
128389
128406
  function resolveServerUrl({ publicUrl, port }) {
@@ -129428,7 +129445,7 @@ var sysPath2 = __toESM(require("path"), 1);
129428
129445
  // node_modules/@threadbase-sh/scanner/node_modules/readdirp/esm/index.js
129429
129446
  var import_promises = require("fs/promises");
129430
129447
  var import_node_stream = require("stream");
129431
- var import_node_path3 = require("path");
129448
+ var import_node_path5 = require("path");
129432
129449
  var EntryTypes = {
129433
129450
  FILE_TYPE: "files",
129434
129451
  DIR_TYPE: "directories",
@@ -129503,7 +129520,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
129503
129520
  this._wantsDir = type ? DIR_TYPES.has(type) : false;
129504
129521
  this._wantsFile = type ? FILE_TYPES.has(type) : false;
129505
129522
  this._wantsEverything = type === EntryTypes.EVERYTHING_TYPE;
129506
- this._root = (0, import_node_path3.resolve)(root);
129523
+ this._root = (0, import_node_path5.resolve)(root);
129507
129524
  this._isDirent = !opts.alwaysStat;
129508
129525
  this._statsProp = this._isDirent ? "dirent" : "stats";
129509
129526
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
@@ -129574,8 +129591,8 @@ var ReaddirpStream = class extends import_node_stream.Readable {
129574
129591
  let entry;
129575
129592
  const basename9 = this._isDirent ? dirent.name : dirent;
129576
129593
  try {
129577
- const fullPath = (0, import_node_path3.resolve)((0, import_node_path3.join)(path2, basename9));
129578
- entry = { path: (0, import_node_path3.relative)(this._root, fullPath), fullPath, basename: basename9 };
129594
+ const fullPath = (0, import_node_path5.resolve)((0, import_node_path5.join)(path2, basename9));
129595
+ entry = { path: (0, import_node_path5.relative)(this._root, fullPath), fullPath, basename: basename9 };
129579
129596
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
129580
129597
  } catch (err) {
129581
129598
  this._onError(err);
@@ -129609,7 +129626,7 @@ var ReaddirpStream = class extends import_node_stream.Readable {
129609
129626
  }
129610
129627
  if (entryRealPathStats.isDirectory()) {
129611
129628
  const len = entryRealPath.length;
129612
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path3.sep) {
129629
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path5.sep) {
129613
129630
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
129614
129631
  recursiveError.code = RECURSIVE_ERROR_CODE;
129615
129632
  return this._onError(recursiveError);
@@ -134045,7 +134062,7 @@ function readAgentConfig(env = process.env) {
134045
134062
 
134046
134063
  // src/agent/conversation-writer.ts
134047
134064
  var import_promises7 = require("fs/promises");
134048
- var import_node_path4 = require("path");
134065
+ var import_node_path6 = require("path");
134049
134066
  function createConversationWriter(opts) {
134050
134067
  const { baseDir } = opts;
134051
134068
  return {
@@ -134053,8 +134070,8 @@ function createConversationWriter(opts) {
134053
134070
  if (!args.content || args.content.length === 0) {
134054
134071
  throw new Error("ConversationWriter: refusing to write empty assistant turn");
134055
134072
  }
134056
- const file2 = (0, import_node_path4.join)(baseDir, `${args.sessionId}.jsonl`);
134057
- await (0, import_promises7.mkdir)((0, import_node_path4.dirname)(file2), { recursive: true });
134073
+ const file2 = (0, import_node_path6.join)(baseDir, `${args.sessionId}.jsonl`);
134074
+ await (0, import_promises7.mkdir)((0, import_node_path6.dirname)(file2), { recursive: true });
134058
134075
  const record2 = {
134059
134076
  role: "assistant",
134060
134077
  turnId: args.turnId,
@@ -134253,8 +134270,8 @@ async function handleSendAgentInput(sessionId, body, deps) {
134253
134270
  }
134254
134271
 
134255
134272
  // src/agent/handle-start-agent-session.ts
134256
- var import_node_fs3 = require("fs");
134257
- var import_node_path5 = require("path");
134273
+ var import_node_fs4 = require("fs");
134274
+ var import_node_path7 = require("path");
134258
134275
  function validateBody(body) {
134259
134276
  if (body === null || body === void 0 || typeof body !== "object") {
134260
134277
  return { ok: false };
@@ -134284,8 +134301,8 @@ async function handleStartAgentSession(body, deps) {
134284
134301
  }
134285
134302
  let conversationId = parsed.conversationId;
134286
134303
  if (conversationId) {
134287
- const jsonlPath = (0, import_node_path5.join)(deps.conversationsDir, `${conversationId}.jsonl`);
134288
- if (!(0, import_node_fs3.existsSync)(jsonlPath)) {
134304
+ const jsonlPath = (0, import_node_path7.join)(deps.conversationsDir, `${conversationId}.jsonl`);
134305
+ if (!(0, import_node_fs4.existsSync)(jsonlPath)) {
134289
134306
  return {
134290
134307
  status: 404,
134291
134308
  body: agentErrorResponse(
@@ -136515,8 +136532,8 @@ var createConversationRoutes = (deps) => {
136515
136532
  };
136516
136533
 
136517
136534
  // src/version.ts
136518
- var import_node_fs4 = require("fs");
136519
- var import_node_path6 = require("path");
136535
+ var import_node_fs5 = require("fs");
136536
+ var import_node_path8 = require("path");
136520
136537
  var cached2;
136521
136538
  function getVersion() {
136522
136539
  if (cached2 !== void 0) return cached2;
@@ -136525,22 +136542,22 @@ function getVersion() {
136525
136542
  }
136526
136543
  function resolveVersion() {
136527
136544
  const scriptPath = process.argv[1] ?? "";
136528
- const here = scriptPath ? (0, import_node_path6.dirname)(scriptPath) : process.cwd();
136545
+ const here = scriptPath ? (0, import_node_path8.dirname)(scriptPath) : process.cwd();
136529
136546
  let realHere = here;
136530
136547
  try {
136531
- realHere = (0, import_node_path6.dirname)((0, import_node_fs4.realpathSync)(scriptPath));
136548
+ realHere = (0, import_node_path8.dirname)((0, import_node_fs5.realpathSync)(scriptPath));
136532
136549
  } catch {
136533
136550
  }
136534
- const searchDirs = realHere === here ? [here, (0, import_node_path6.join)(here, "..")] : [here, (0, import_node_path6.join)(here, ".."), realHere, (0, import_node_path6.join)(realHere, "..")];
136551
+ const searchDirs = realHere === here ? [here, (0, import_node_path8.join)(here, "..")] : [here, (0, import_node_path8.join)(here, ".."), realHere, (0, import_node_path8.join)(realHere, "..")];
136535
136552
  for (const dir of searchDirs) {
136536
136553
  try {
136537
- const v3 = (0, import_node_fs4.readFileSync)((0, import_node_path6.join)(dir, "version.txt"), "utf8").trim();
136554
+ const v3 = (0, import_node_fs5.readFileSync)((0, import_node_path8.join)(dir, "version.txt"), "utf8").trim();
136538
136555
  if (v3) return v3;
136539
136556
  } catch {
136540
136557
  }
136541
136558
  }
136542
136559
  try {
136543
- const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path6.join)(here, "..", "package.json"), "utf8"));
136560
+ const pkg = JSON.parse((0, import_node_fs5.readFileSync)((0, import_node_path8.join)(here, "..", "package.json"), "utf8"));
136544
136561
  if (pkg.version) return `${pkg.version}+source`;
136545
136562
  } catch {
136546
136563
  }
@@ -139177,13 +139194,13 @@ function seal(plaintext, recipientPublicKeyBase64) {
139177
139194
 
139178
139195
  // node_modules/chokidar/index.js
139179
139196
  var import_node_events2 = require("events");
139180
- var import_node_fs6 = require("fs");
139197
+ var import_node_fs7 = require("fs");
139181
139198
  var import_promises11 = require("fs/promises");
139182
139199
  var sp2 = __toESM(require("path"), 1);
139183
139200
 
139184
139201
  // node_modules/readdirp/index.js
139185
139202
  var import_promises9 = require("fs/promises");
139186
- var import_node_path7 = require("path");
139203
+ var import_node_path9 = require("path");
139187
139204
  var import_node_stream2 = require("stream");
139188
139205
  var EntryTypes2 = {
139189
139206
  FILE_TYPE: "files",
@@ -139273,7 +139290,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
139273
139290
  this._wantsDir = type ? DIR_TYPES2.has(type) : false;
139274
139291
  this._wantsFile = type ? FILE_TYPES2.has(type) : false;
139275
139292
  this._wantsEverything = type === EntryTypes2.EVERYTHING_TYPE;
139276
- this._root = (0, import_node_path7.resolve)(root);
139293
+ this._root = (0, import_node_path9.resolve)(root);
139277
139294
  this._isDirent = !opts.alwaysStat;
139278
139295
  this._statsProp = this._isDirent ? "dirent" : "stats";
139279
139296
  this._rdOptions = { encoding: "utf8", withFileTypes: this._isDirent };
@@ -139344,8 +139361,8 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
139344
139361
  let entry;
139345
139362
  const basename9 = this._isDirent ? dirent.name : dirent;
139346
139363
  try {
139347
- const fullPath = (0, import_node_path7.resolve)((0, import_node_path7.join)(path2, basename9));
139348
- entry = { path: (0, import_node_path7.relative)(this._root, fullPath), fullPath, basename: basename9 };
139364
+ const fullPath = (0, import_node_path9.resolve)((0, import_node_path9.join)(path2, basename9));
139365
+ entry = { path: (0, import_node_path9.relative)(this._root, fullPath), fullPath, basename: basename9 };
139349
139366
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
139350
139367
  } catch (err) {
139351
139368
  this._onError(err);
@@ -139379,7 +139396,7 @@ var ReaddirpStream2 = class extends import_node_stream2.Readable {
139379
139396
  }
139380
139397
  if (entryRealPathStats.isDirectory()) {
139381
139398
  const len = entryRealPath.length;
139382
- if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path7.sep) {
139399
+ if (full.startsWith(entryRealPath) && full.substr(len, 1) === import_node_path9.sep) {
139383
139400
  const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
139384
139401
  recursiveError.code = RECURSIVE_ERROR_CODE2;
139385
139402
  return this._onError(recursiveError);
@@ -139415,9 +139432,9 @@ function readdirp2(root, options = {}) {
139415
139432
  }
139416
139433
 
139417
139434
  // node_modules/chokidar/handler.js
139418
- var import_node_fs5 = require("fs");
139435
+ var import_node_fs6 = require("fs");
139419
139436
  var import_promises10 = require("fs/promises");
139420
- var import_node_os2 = require("os");
139437
+ var import_node_os3 = require("os");
139421
139438
  var sp = __toESM(require("path"), 1);
139422
139439
  var STR_DATA2 = "data";
139423
139440
  var STR_END2 = "end";
@@ -139429,7 +139446,7 @@ var isWindows3 = pl2 === "win32";
139429
139446
  var isMacos2 = pl2 === "darwin";
139430
139447
  var isLinux2 = pl2 === "linux";
139431
139448
  var isFreeBSD2 = pl2 === "freebsd";
139432
- var isIBMi2 = (0, import_node_os2.type)() === "OS400";
139449
+ var isIBMi2 = (0, import_node_os3.type)() === "OS400";
139433
139450
  var EVENTS2 = {
139434
139451
  ALL: "all",
139435
139452
  READY: "ready",
@@ -139753,7 +139770,7 @@ function createFsWatchInstance2(path2, options, listener, errHandler, emitRaw) {
139753
139770
  }
139754
139771
  };
139755
139772
  try {
139756
- return (0, import_node_fs5.watch)(path2, {
139773
+ return (0, import_node_fs6.watch)(path2, {
139757
139774
  persistent: options.persistent
139758
139775
  }, handleEvent);
139759
139776
  } catch (error51) {
@@ -139836,7 +139853,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
139836
139853
  let cont = FsWatchFileInstances2.get(fullPath);
139837
139854
  const copts = cont && cont.options;
139838
139855
  if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
139839
- (0, import_node_fs5.unwatchFile)(fullPath);
139856
+ (0, import_node_fs6.unwatchFile)(fullPath);
139840
139857
  cont = void 0;
139841
139858
  }
139842
139859
  if (cont) {
@@ -139847,7 +139864,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
139847
139864
  listeners: listener,
139848
139865
  rawEmitters: rawEmitter,
139849
139866
  options,
139850
- watcher: (0, import_node_fs5.watchFile)(fullPath, options, (curr, prev) => {
139867
+ watcher: (0, import_node_fs6.watchFile)(fullPath, options, (curr, prev) => {
139851
139868
  foreach2(cont.rawEmitters, (rawEmitter2) => {
139852
139869
  rawEmitter2(EV2.CHANGE, fullPath, { curr, prev });
139853
139870
  });
@@ -139864,7 +139881,7 @@ var setFsWatchFileListener2 = (path2, fullPath, options, handlers) => {
139864
139881
  delFromSet2(cont, KEY_RAW2, rawEmitter);
139865
139882
  if (isEmptySet2(cont.listeners)) {
139866
139883
  FsWatchFileInstances2.delete(fullPath);
139867
- (0, import_node_fs5.unwatchFile)(fullPath);
139884
+ (0, import_node_fs6.unwatchFile)(fullPath);
139868
139885
  cont.options = cont.watcher = void 0;
139869
139886
  Object.freeze(cont);
139870
139887
  }
@@ -140734,7 +140751,7 @@ var FSWatcher2 = class extends import_node_events2.EventEmitter {
140734
140751
  const now = /* @__PURE__ */ new Date();
140735
140752
  const writes = this._pendingWrites;
140736
140753
  function awaitWriteFinishFn(prevStat) {
140737
- (0, import_node_fs6.stat)(fullPath, (err, curStat) => {
140754
+ (0, import_node_fs7.stat)(fullPath, (err, curStat) => {
140738
140755
  if (err || !writes.has(path2)) {
140739
140756
  if (err && err.code !== "ENOENT")
140740
140757
  awfEmit(err);
@@ -142602,10 +142619,17 @@ var StreamerServer = class {
142602
142619
  });
142603
142620
  }
142604
142621
  rotateApiKey() {
142622
+ const oldKey = this.apiKey;
142605
142623
  const newKey = generateApiKey();
142606
142624
  const persisted = this.apiKeySource === "config";
142607
142625
  if (persisted) setApiKey(newKey);
142608
142626
  this.apiKey = newKey;
142627
+ this.log.info("API key rotated", {
142628
+ event: "auth.api_key_rotated",
142629
+ oldKeyMasked: `${oldKey.slice(0, 6)}\u2026`,
142630
+ newKeyMasked: `${newKey.slice(0, 6)}\u2026`,
142631
+ persisted
142632
+ });
142609
142633
  return { newKey, persisted };
142610
142634
  }
142611
142635
  checkRateLimit(map2, key, limit, windowMs) {
@@ -144085,7 +144109,7 @@ async function checkForUpdate(opts) {
144085
144109
  }
144086
144110
 
144087
144111
  // src/updater/install.ts
144088
- var import_node_fs18 = require("fs");
144112
+ var import_node_fs19 = require("fs");
144089
144113
 
144090
144114
  // src/updater/active-sessions.ts
144091
144115
  async function countActiveSessions(opts) {
@@ -144138,8 +144162,8 @@ function isBrewInstall(scriptPath = process.argv[1] ?? "") {
144138
144162
 
144139
144163
  // src/updater/download.ts
144140
144164
  var import_node_crypto4 = require("crypto");
144141
- var import_node_fs7 = require("fs");
144142
- var import_node_path8 = require("path");
144165
+ var import_node_fs8 = require("fs");
144166
+ var import_node_path10 = require("path");
144143
144167
  var import_promises15 = require("stream/promises");
144144
144168
 
144145
144169
  // src/updater/manifest.ts
@@ -144199,13 +144223,13 @@ async function downloadAndVerify(opts) {
144199
144223
  `Manifest references ${artifact.filename} but it is not attached to the release`
144200
144224
  );
144201
144225
  }
144202
- (0, import_node_fs7.mkdirSync)((0, import_node_path8.dirname)(targetPath), { recursive: true });
144226
+ (0, import_node_fs8.mkdirSync)((0, import_node_path10.dirname)(targetPath), { recursive: true });
144203
144227
  const res = await fetch(asset.browserDownloadUrl);
144204
144228
  if (!res.ok || !res.body) {
144205
144229
  throw new Error(`Failed to download ${artifact.filename}: ${res.status} ${res.statusText}`);
144206
144230
  }
144207
144231
  const hash2 = (0, import_node_crypto4.createHash)("sha256");
144208
- const out = (0, import_node_fs7.createWriteStream)(targetPath);
144232
+ const out = (0, import_node_fs8.createWriteStream)(targetPath);
144209
144233
  let bytes = 0;
144210
144234
  const measured = new TransformStream({
144211
144235
  transform(chunk, controller) {
@@ -144217,19 +144241,19 @@ async function downloadAndVerify(opts) {
144217
144241
  try {
144218
144242
  await (0, import_promises15.pipeline)(res.body.pipeThrough(measured), out);
144219
144243
  } catch (err) {
144220
- (0, import_node_fs7.rmSync)(targetPath, { force: true });
144244
+ (0, import_node_fs8.rmSync)(targetPath, { force: true });
144221
144245
  throw err;
144222
144246
  }
144223
144247
  const actual = hash2.digest("hex");
144224
144248
  if (actual !== artifact.sha256) {
144225
- (0, import_node_fs7.rmSync)(targetPath, { force: true });
144249
+ (0, import_node_fs8.rmSync)(targetPath, { force: true });
144226
144250
  throw new Error(
144227
144251
  `sha256 mismatch for ${artifact.filename}: expected ${artifact.sha256}, got ${actual}`
144228
144252
  );
144229
144253
  }
144230
- const stat10 = (0, import_node_fs7.statSync)(targetPath);
144254
+ const stat10 = (0, import_node_fs8.statSync)(targetPath);
144231
144255
  if (stat10.size !== artifact.size) {
144232
- (0, import_node_fs7.rmSync)(targetPath, { force: true });
144256
+ (0, import_node_fs8.rmSync)(targetPath, { force: true });
144233
144257
  throw new Error(
144234
144258
  `size mismatch for ${artifact.filename}: expected ${artifact.size}, got ${stat10.size}`
144235
144259
  );
@@ -144238,17 +144262,17 @@ async function downloadAndVerify(opts) {
144238
144262
  }
144239
144263
 
144240
144264
  // src/updater/paths.ts
144241
- var import_node_os3 = require("os");
144242
- var import_node_path9 = require("path");
144243
- var THREADBASE_ROOT = (0, import_node_path9.join)((0, import_node_os3.homedir)(), ".threadbase");
144244
- var RELEASES_DIR = (0, import_node_path9.join)(THREADBASE_ROOT, "releases");
144245
- var CURRENT_SYMLINK = (0, import_node_path9.join)(THREADBASE_ROOT, "current");
144246
- var DOWNLOAD_DIR = (0, import_node_path9.join)(THREADBASE_ROOT, "releases", ".tmp");
144265
+ var import_node_os4 = require("os");
144266
+ var import_node_path11 = require("path");
144267
+ var THREADBASE_ROOT = (0, import_node_path11.join)((0, import_node_os4.homedir)(), ".threadbase");
144268
+ var RELEASES_DIR = (0, import_node_path11.join)(THREADBASE_ROOT, "releases");
144269
+ var CURRENT_SYMLINK = (0, import_node_path11.join)(THREADBASE_ROOT, "current");
144270
+ var DOWNLOAD_DIR = (0, import_node_path11.join)(THREADBASE_ROOT, "releases", ".tmp");
144247
144271
  function releaseDir(version2) {
144248
- return (0, import_node_path9.join)(RELEASES_DIR, version2);
144272
+ return (0, import_node_path11.join)(RELEASES_DIR, version2);
144249
144273
  }
144250
144274
  function downloadPath(version2, filename) {
144251
- return (0, import_node_path9.join)(DOWNLOAD_DIR, `${version2}-${filename}`);
144275
+ return (0, import_node_path11.join)(DOWNLOAD_DIR, `${version2}-${filename}`);
144252
144276
  }
144253
144277
 
144254
144278
  // src/updater/restart.ts
@@ -144329,75 +144353,75 @@ async function stopService(opts = {}) {
144329
144353
  }
144330
144354
 
144331
144355
  // src/updater/stamp-version.ts
144332
- var import_node_fs8 = require("fs");
144333
- var import_node_path10 = require("path");
144356
+ var import_node_fs9 = require("fs");
144357
+ var import_node_path12 = require("path");
144334
144358
  function stampVersionTxt(destDir, version2) {
144335
- const distDir = (0, import_node_path10.join)(destDir, "dist");
144336
- (0, import_node_fs8.mkdirSync)(distDir, { recursive: true });
144337
- (0, import_node_fs8.writeFileSync)((0, import_node_path10.join)(distDir, "version.txt"), `${version2}+update
144359
+ const distDir = (0, import_node_path12.join)(destDir, "dist");
144360
+ (0, import_node_fs9.mkdirSync)(distDir, { recursive: true });
144361
+ (0, import_node_fs9.writeFileSync)((0, import_node_path12.join)(distDir, "version.txt"), `${version2}+update
144338
144362
  `);
144339
144363
  }
144340
144364
 
144341
144365
  // src/updater/swap.ts
144342
- var import_node_fs9 = require("fs");
144343
- var import_node_path11 = require("path");
144366
+ var import_node_fs10 = require("fs");
144367
+ var import_node_path13 = require("path");
144344
144368
  var import_semver2 = __toESM(require_semver2(), 1);
144345
144369
  var KEEP_LAST_N = 2;
144346
144370
  function swapCurrent(version2) {
144347
144371
  const target = releaseDir(version2);
144348
- if (!(0, import_node_fs9.existsSync)(target)) {
144372
+ if (!(0, import_node_fs10.existsSync)(target)) {
144349
144373
  throw new Error(`Cannot swap to ${version2}: ${target} does not exist`);
144350
144374
  }
144351
144375
  if (process.platform === "win32") {
144352
144376
  const tmp = `${CURRENT_SYMLINK}.new`;
144353
- (0, import_node_fs9.rmSync)(tmp, { recursive: true, force: true });
144354
- (0, import_node_fs9.cpSync)(target, tmp, { recursive: true });
144355
- if ((0, import_node_fs9.existsSync)(CURRENT_SYMLINK)) {
144356
- (0, import_node_fs9.rmSync)(CURRENT_SYMLINK, { recursive: true, force: true });
144377
+ (0, import_node_fs10.rmSync)(tmp, { recursive: true, force: true });
144378
+ (0, import_node_fs10.cpSync)(target, tmp, { recursive: true });
144379
+ if ((0, import_node_fs10.existsSync)(CURRENT_SYMLINK)) {
144380
+ (0, import_node_fs10.rmSync)(CURRENT_SYMLINK, { recursive: true, force: true });
144357
144381
  }
144358
- (0, import_node_fs9.renameSync)(tmp, CURRENT_SYMLINK);
144359
- (0, import_node_fs9.copyFileSync)((0, import_node_path11.join)(CURRENT_SYMLINK, "dist", "cli.cjs"), (0, import_node_path11.join)(THREADBASE_ROOT, "cli.js"));
144382
+ (0, import_node_fs10.renameSync)(tmp, CURRENT_SYMLINK);
144383
+ (0, import_node_fs10.copyFileSync)((0, import_node_path13.join)(CURRENT_SYMLINK, "dist", "cli.cjs"), (0, import_node_path13.join)(THREADBASE_ROOT, "cli.js"));
144360
144384
  return;
144361
144385
  }
144362
144386
  const tmpLink = `${CURRENT_SYMLINK}.new`;
144363
- if ((0, import_node_fs9.existsSync)(tmpLink) || lstatSafeIsSymlink(tmpLink)) {
144364
- (0, import_node_fs9.unlinkSync)(tmpLink);
144387
+ if ((0, import_node_fs10.existsSync)(tmpLink) || lstatSafeIsSymlink(tmpLink)) {
144388
+ (0, import_node_fs10.unlinkSync)(tmpLink);
144365
144389
  }
144366
- (0, import_node_fs9.symlinkSync)(target, tmpLink);
144367
- (0, import_node_fs9.renameSync)(tmpLink, CURRENT_SYMLINK);
144368
- const cliJs = (0, import_node_path11.join)(THREADBASE_ROOT, "cli.js");
144390
+ (0, import_node_fs10.symlinkSync)(target, tmpLink);
144391
+ (0, import_node_fs10.renameSync)(tmpLink, CURRENT_SYMLINK);
144392
+ const cliJs = (0, import_node_path13.join)(THREADBASE_ROOT, "cli.js");
144369
144393
  const tmpCliJs = `${cliJs}.new`;
144370
- if ((0, import_node_fs9.existsSync)(tmpCliJs) || lstatSafeIsSymlink(tmpCliJs)) (0, import_node_fs9.unlinkSync)(tmpCliJs);
144371
- (0, import_node_fs9.symlinkSync)((0, import_node_path11.join)(target, "dist", "cli.cjs"), tmpCliJs);
144372
- (0, import_node_fs9.renameSync)(tmpCliJs, cliJs);
144394
+ if ((0, import_node_fs10.existsSync)(tmpCliJs) || lstatSafeIsSymlink(tmpCliJs)) (0, import_node_fs10.unlinkSync)(tmpCliJs);
144395
+ (0, import_node_fs10.symlinkSync)((0, import_node_path13.join)(target, "dist", "cli.cjs"), tmpCliJs);
144396
+ (0, import_node_fs10.renameSync)(tmpCliJs, cliJs);
144373
144397
  }
144374
144398
  function lstatSafeIsSymlink(path2) {
144375
144399
  try {
144376
- return (0, import_node_fs9.lstatSync)(path2).isSymbolicLink();
144400
+ return (0, import_node_fs10.lstatSync)(path2).isSymbolicLink();
144377
144401
  } catch {
144378
144402
  return false;
144379
144403
  }
144380
144404
  }
144381
144405
  function pruneOldReleases(activeVersion, keep = KEEP_LAST_N) {
144382
- if (!(0, import_node_fs9.existsSync)(RELEASES_DIR)) return [];
144383
- const entries = (0, import_node_fs9.readdirSync)(RELEASES_DIR, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).filter((name) => import_semver2.default.valid(name) !== null);
144406
+ if (!(0, import_node_fs10.existsSync)(RELEASES_DIR)) return [];
144407
+ const entries = (0, import_node_fs10.readdirSync)(RELEASES_DIR, { withFileTypes: true }).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name).filter((name) => import_semver2.default.valid(name) !== null);
144384
144408
  const sorted = entries.sort((a, b2) => import_semver2.default.rcompare(a, b2));
144385
144409
  const toKeep = new Set(sorted.slice(0, keep));
144386
144410
  toKeep.add(activeVersion);
144387
144411
  const removed = [];
144388
144412
  for (const name of sorted) {
144389
144413
  if (toKeep.has(name)) continue;
144390
- (0, import_node_fs9.rmSync)(releaseDir(name), { recursive: true, force: true });
144414
+ (0, import_node_fs10.rmSync)(releaseDir(name), { recursive: true, force: true });
144391
144415
  removed.push(name);
144392
144416
  }
144393
144417
  return removed;
144394
144418
  }
144395
144419
  function ensureReleasesDir() {
144396
- (0, import_node_fs9.mkdirSync)(RELEASES_DIR, { recursive: true });
144420
+ (0, import_node_fs10.mkdirSync)(RELEASES_DIR, { recursive: true });
144397
144421
  }
144398
144422
 
144399
144423
  // src/updater/unpack.ts
144400
- var import_node_fs16 = require("fs");
144424
+ var import_node_fs17 = require("fs");
144401
144425
 
144402
144426
  // node_modules/tar/dist/esm/index.min.js
144403
144427
  var import_events4 = __toESM(require("events"), 1);
@@ -144405,35 +144429,35 @@ var import_fs24 = __toESM(require("fs"), 1);
144405
144429
  var import_node_events3 = require("events");
144406
144430
  var import_node_stream3 = __toESM(require("stream"), 1);
144407
144431
  var import_node_string_decoder = require("string_decoder");
144408
- var import_node_path12 = __toESM(require("path"), 1);
144409
- var import_node_fs10 = __toESM(require("fs"), 1);
144432
+ var import_node_path14 = __toESM(require("path"), 1);
144433
+ var import_node_fs11 = __toESM(require("fs"), 1);
144410
144434
  var import_path20 = require("path");
144411
144435
  var import_events5 = require("events");
144412
144436
  var import_assert = __toESM(require("assert"), 1);
144413
144437
  var import_buffer = require("buffer");
144414
144438
  var Ps = __toESM(require("zlib"), 1);
144415
144439
  var import_zlib = __toESM(require("zlib"), 1);
144416
- var import_node_path13 = require("path");
144417
- var import_node_path14 = require("path");
144440
+ var import_node_path15 = require("path");
144441
+ var import_node_path16 = require("path");
144418
144442
  var import_fs25 = __toESM(require("fs"), 1);
144419
144443
  var import_fs26 = __toESM(require("fs"), 1);
144420
144444
  var import_path21 = __toESM(require("path"), 1);
144421
- var import_node_path15 = require("path");
144445
+ var import_node_path17 = require("path");
144422
144446
  var import_path22 = __toESM(require("path"), 1);
144423
- var import_node_fs11 = __toESM(require("fs"), 1);
144447
+ var import_node_fs12 = __toESM(require("fs"), 1);
144424
144448
  var import_node_assert = __toESM(require("assert"), 1);
144425
144449
  var import_node_crypto5 = require("crypto");
144426
- var import_node_fs12 = __toESM(require("fs"), 1);
144427
- var import_node_path16 = __toESM(require("path"), 1);
144428
- var import_fs27 = __toESM(require("fs"), 1);
144429
144450
  var import_node_fs13 = __toESM(require("fs"), 1);
144430
- var import_node_path17 = __toESM(require("path"), 1);
144431
- var import_node_fs14 = __toESM(require("fs"), 1);
144432
- var import_promises16 = __toESM(require("fs/promises"), 1);
144433
144451
  var import_node_path18 = __toESM(require("path"), 1);
144434
- var import_node_path19 = require("path");
144452
+ var import_fs27 = __toESM(require("fs"), 1);
144453
+ var import_node_fs14 = __toESM(require("fs"), 1);
144454
+ var import_node_path19 = __toESM(require("path"), 1);
144435
144455
  var import_node_fs15 = __toESM(require("fs"), 1);
144456
+ var import_promises16 = __toESM(require("fs/promises"), 1);
144436
144457
  var import_node_path20 = __toESM(require("path"), 1);
144458
+ var import_node_path21 = require("path");
144459
+ var import_node_fs16 = __toESM(require("fs"), 1);
144460
+ var import_node_path22 = __toESM(require("path"), 1);
144437
144461
  var zr = Object.defineProperty;
144438
144462
  var Ur = (s3, t2) => {
144439
144463
  for (var e in t2) zr(s3, e, { get: t2[e], enumerable: true });
@@ -145327,12 +145351,12 @@ var F2 = class {
145327
145351
  }
145328
145352
  };
145329
145353
  var un = (s3, t2) => {
145330
- let i = s3, r = "", n, o = import_node_path13.posix.parse(s3).root || ".";
145354
+ let i = s3, r = "", n, o = import_node_path15.posix.parse(s3).root || ".";
145331
145355
  if (Buffer.byteLength(i) < 100) n = [i, r, false];
145332
145356
  else {
145333
- r = import_node_path13.posix.dirname(i), i = import_node_path13.posix.basename(i);
145357
+ r = import_node_path15.posix.dirname(i), i = import_node_path15.posix.basename(i);
145334
145358
  do
145335
- Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t2 ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t2 ? n = [i.slice(0, 99), r, true] : (i = import_node_path13.posix.join(import_node_path13.posix.basename(r), i), r = import_node_path13.posix.dirname(r));
145359
+ Buffer.byteLength(i) <= 100 && Buffer.byteLength(r) <= t2 ? n = [i, r, false] : Buffer.byteLength(i) > 100 && Buffer.byteLength(r) <= t2 ? n = [i.slice(0, 99), r, true] : (i = import_node_path15.posix.join(import_node_path15.posix.basename(r), i), r = import_node_path15.posix.dirname(r));
145336
145360
  while (r !== o && n === void 0);
145337
145361
  n || (n = [s3.slice(0, 99), "", true]);
145338
145362
  }
@@ -145378,7 +145402,7 @@ var ft = class s {
145378
145402
  if (t2 === "") return Buffer.allocUnsafe(0);
145379
145403
  let e = Buffer.byteLength(t2), i = 512 * Math.ceil(1 + e / 512), r = Buffer.allocUnsafe(i);
145380
145404
  for (let n = 0; n < 512; n++) r[n] = 0;
145381
- new F2({ path: ("PaxHeader/" + (0, import_node_path14.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t2, 512, e, "utf8");
145405
+ new F2({ path: ("PaxHeader/" + (0, import_node_path16.basename)(this.path ?? "")).slice(0, 99), mode: this.mode || 420, uid: this.uid, gid: this.gid, size: e, mtime: this.mtime, type: this.global ? "GlobalExtendedHeader" : "ExtendedHeader", linkpath: "", uname: this.uname || "", gname: this.gname || "", devmaj: 0, devmin: 0, atime: this.atime, ctime: this.ctime }).encode(r), r.write(t2, 512, e, "utf8");
145382
145406
  for (let n = e + 512; n < r.length; n++) r[n] = 0;
145383
145407
  return r;
145384
145408
  }
@@ -145797,15 +145821,15 @@ var Qi = (s3, t2) => {
145797
145821
  var Mn = (s3) => {
145798
145822
  let t2 = new rt(s3), e = s3.file, i;
145799
145823
  try {
145800
- i = import_node_fs10.default.openSync(e, "r");
145801
- let r = import_node_fs10.default.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
145824
+ i = import_node_fs11.default.openSync(e, "r");
145825
+ let r = import_node_fs11.default.fstatSync(i), n = s3.maxReadSize || 16 * 1024 * 1024;
145802
145826
  if (r.size < n) {
145803
- let o = Buffer.allocUnsafe(r.size), h = import_node_fs10.default.readSync(i, o, 0, r.size, 0);
145827
+ let o = Buffer.allocUnsafe(r.size), h = import_node_fs11.default.readSync(i, o, 0, r.size, 0);
145804
145828
  t2.end(h === o.byteLength ? o : o.subarray(0, h));
145805
145829
  } else {
145806
145830
  let o = 0, h = Buffer.allocUnsafe(n);
145807
145831
  for (; o < r.size; ) {
145808
- let a = import_node_fs10.default.readSync(i, h, 0, n, o);
145832
+ let a = import_node_fs11.default.readSync(i, h, 0, n, o);
145809
145833
  if (a === 0) break;
145810
145834
  o += a, t2.write(h.subarray(0, a));
145811
145835
  }
@@ -145813,7 +145837,7 @@ var Mn = (s3) => {
145813
145837
  }
145814
145838
  } finally {
145815
145839
  if (typeof i == "number") try {
145816
- import_node_fs10.default.closeSync(i);
145840
+ import_node_fs11.default.closeSync(i);
145817
145841
  } catch {
145818
145842
  }
145819
145843
  }
@@ -145821,7 +145845,7 @@ var Mn = (s3) => {
145821
145845
  var Bn = (s3, t2) => {
145822
145846
  let e = new rt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
145823
145847
  return new Promise((o, h) => {
145824
- e.on("error", h), e.on("end", o), import_node_fs10.default.stat(r, (a, l) => {
145848
+ e.on("error", h), e.on("end", o), import_node_fs11.default.stat(r, (a, l) => {
145825
145849
  if (a) h(a);
145826
145850
  else {
145827
145851
  let c = new _t(r, { readSize: i, size: l.size });
@@ -145834,7 +145858,7 @@ var Ct = K2(Mn, Bn, (s3) => new rt(s3), (s3) => new rt(s3), (s3, t2) => {
145834
145858
  t2?.length && Qi(s3, t2), s3.noResume || vn(s3);
145835
145859
  });
145836
145860
  var Ji = (s3, t2, e) => (s3 &= 4095, e && (s3 = (s3 | 384) & -19), t2 && (s3 & 256 && (s3 |= 64), s3 & 32 && (s3 |= 8), s3 & 4 && (s3 |= 1)), s3);
145837
- var { isAbsolute: zn, parse: qs } = import_node_path15.win32;
145861
+ var { isAbsolute: zn, parse: qs } = import_node_path17.win32;
145838
145862
  var ce = (s3) => {
145839
145863
  let t2 = "", e = qs(s3);
145840
145864
  for (; zn(s3) || e.root; ) {
@@ -146543,11 +146567,11 @@ var $n = (s3, t2) => {
146543
146567
  };
146544
146568
  var fr = (s3, t2) => {
146545
146569
  t2.forEach((e) => {
146546
- e.charAt(0) === "@" ? Ct({ file: import_node_path12.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
146570
+ e.charAt(0) === "@" ? Ct({ file: import_node_path14.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
146547
146571
  }), s3.end();
146548
146572
  };
146549
146573
  var dr = async (s3, t2) => {
146550
- for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path12.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
146574
+ for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path14.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => {
146551
146575
  s3.add(i);
146552
146576
  } }) : s3.add(e);
146553
146577
  s3.end();
@@ -146574,29 +146598,29 @@ var ur = !Er && typeof mr == "number" ? mr | Sr | wr | yr : null;
146574
146598
  var us = ur !== null ? () => ur : jn ? (s3) => s3 < to ? eo : "w" : () => "w";
146575
146599
  var ps = (s3, t2, e) => {
146576
146600
  try {
146577
- return import_node_fs13.default.lchownSync(s3, t2, e);
146601
+ return import_node_fs14.default.lchownSync(s3, t2, e);
146578
146602
  } catch (i) {
146579
146603
  if (i?.code !== "ENOENT") throw i;
146580
146604
  }
146581
146605
  };
146582
146606
  var Ei = (s3, t2, e, i) => {
146583
- import_node_fs13.default.lchown(s3, t2, e, (r) => {
146607
+ import_node_fs14.default.lchown(s3, t2, e, (r) => {
146584
146608
  i(r && r?.code !== "ENOENT" ? r : null);
146585
146609
  });
146586
146610
  };
146587
146611
  var io = (s3, t2, e, i, r) => {
146588
- if (t2.isDirectory()) Es(import_node_path17.default.resolve(s3, t2.name), e, i, (n) => {
146612
+ if (t2.isDirectory()) Es(import_node_path19.default.resolve(s3, t2.name), e, i, (n) => {
146589
146613
  if (n) return r(n);
146590
- let o = import_node_path17.default.resolve(s3, t2.name);
146614
+ let o = import_node_path19.default.resolve(s3, t2.name);
146591
146615
  Ei(o, e, i, r);
146592
146616
  });
146593
146617
  else {
146594
- let n = import_node_path17.default.resolve(s3, t2.name);
146618
+ let n = import_node_path19.default.resolve(s3, t2.name);
146595
146619
  Ei(n, e, i, r);
146596
146620
  }
146597
146621
  };
146598
146622
  var Es = (s3, t2, e, i) => {
146599
- import_node_fs13.default.readdir(s3, { withFileTypes: true }, (r, n) => {
146623
+ import_node_fs14.default.readdir(s3, { withFileTypes: true }, (r, n) => {
146600
146624
  if (r) {
146601
146625
  if (r.code === "ENOENT") return i();
146602
146626
  if (r.code !== "ENOTDIR" && r.code !== "ENOTSUP") return i(r);
@@ -146612,12 +146636,12 @@ var Es = (s3, t2, e, i) => {
146612
146636
  });
146613
146637
  };
146614
146638
  var so = (s3, t2, e, i) => {
146615
- t2.isDirectory() && ws(import_node_path17.default.resolve(s3, t2.name), e, i), ps(import_node_path17.default.resolve(s3, t2.name), e, i);
146639
+ t2.isDirectory() && ws(import_node_path19.default.resolve(s3, t2.name), e, i), ps(import_node_path19.default.resolve(s3, t2.name), e, i);
146616
146640
  };
146617
146641
  var ws = (s3, t2, e) => {
146618
146642
  let i;
146619
146643
  try {
146620
- i = import_node_fs13.default.readdirSync(s3, { withFileTypes: true });
146644
+ i = import_node_fs14.default.readdirSync(s3, { withFileTypes: true });
146621
146645
  } catch (r) {
146622
146646
  let n = r;
146623
146647
  if (n?.code === "ENOENT") return;
@@ -146651,32 +146675,32 @@ var St = class extends Error {
146651
146675
  }
146652
146676
  };
146653
146677
  var no = (s3, t2) => {
146654
- import_node_fs14.default.stat(s3, (e, i) => {
146678
+ import_node_fs15.default.stat(s3, (e, i) => {
146655
146679
  (e || !i.isDirectory()) && (e = new Se(s3, e?.code || "ENOTDIR")), t2(e);
146656
146680
  });
146657
146681
  };
146658
146682
  var gr = (s3, t2, e) => {
146659
146683
  s3 = f(s3);
146660
146684
  let i = t2.umask ?? 18, r = t2.mode | 448, n = (r & i) !== 0, o = t2.uid, h = t2.gid, a = typeof o == "number" && typeof h == "number" && (o !== t2.processUid || h !== t2.processGid), l = t2.preserve, c = t2.unlink, d = f(t2.cwd), S2 = (E2, x2) => {
146661
- E2 ? e(E2) : x2 && a ? Es(x2, o, h, (Le) => S2(Le)) : n ? import_node_fs14.default.chmod(s3, r, e) : e();
146685
+ E2 ? e(E2) : x2 && a ? Es(x2, o, h, (Le) => S2(Le)) : n ? import_node_fs15.default.chmod(s3, r, e) : e();
146662
146686
  };
146663
146687
  if (s3 === d) return no(s3, S2);
146664
146688
  if (l) return import_promises16.default.mkdir(s3, { mode: r, recursive: true }).then((E2) => S2(null, E2 ?? void 0), S2);
146665
- let D2 = f(import_node_path18.default.relative(d, s3)).split("/");
146689
+ let D2 = f(import_node_path20.default.relative(d, s3)).split("/");
146666
146690
  Ss(d, D2, r, c, d, void 0, S2);
146667
146691
  };
146668
146692
  var Ss = (s3, t2, e, i, r, n, o) => {
146669
146693
  if (t2.length === 0) return o(null, n);
146670
- let h = t2.shift(), a = f(import_node_path18.default.resolve(s3 + "/" + h));
146671
- import_node_fs14.default.mkdir(a, e, br(a, t2, e, i, r, n, o));
146694
+ let h = t2.shift(), a = f(import_node_path20.default.resolve(s3 + "/" + h));
146695
+ import_node_fs15.default.mkdir(a, e, br(a, t2, e, i, r, n, o));
146672
146696
  };
146673
146697
  var br = (s3, t2, e, i, r, n, o) => (h) => {
146674
- h ? import_node_fs14.default.lstat(s3, (a, l) => {
146698
+ h ? import_node_fs15.default.lstat(s3, (a, l) => {
146675
146699
  if (a) a.path = a.path && f(a.path), o(a);
146676
146700
  else if (l.isDirectory()) Ss(s3, t2, e, i, r, n, o);
146677
- else if (i) import_node_fs14.default.unlink(s3, (c) => {
146701
+ else if (i) import_node_fs15.default.unlink(s3, (c) => {
146678
146702
  if (c) return o(c);
146679
- import_node_fs14.default.mkdir(s3, e, br(s3, t2, e, i, r, n, o));
146703
+ import_node_fs15.default.mkdir(s3, e, br(s3, t2, e, i, r, n, o));
146680
146704
  });
146681
146705
  else {
146682
146706
  if (l.isSymbolicLink()) return o(new St(s3, s3 + "/" + t2.join("/")));
@@ -146687,7 +146711,7 @@ var br = (s3, t2, e, i, r, n, o) => (h) => {
146687
146711
  var oo = (s3) => {
146688
146712
  let t2 = false, e;
146689
146713
  try {
146690
- t2 = import_node_fs14.default.statSync(s3).isDirectory();
146714
+ t2 = import_node_fs15.default.statSync(s3).isDirectory();
146691
146715
  } catch (i) {
146692
146716
  e = i?.code;
146693
146717
  } finally {
@@ -146697,20 +146721,20 @@ var oo = (s3) => {
146697
146721
  var _r = (s3, t2) => {
146698
146722
  s3 = f(s3);
146699
146723
  let e = t2.umask ?? 18, i = t2.mode | 448, r = (i & e) !== 0, n = t2.uid, o = t2.gid, h = typeof n == "number" && typeof o == "number" && (n !== t2.processUid || o !== t2.processGid), a = t2.preserve, l = t2.unlink, c = f(t2.cwd), d = (E2) => {
146700
- E2 && h && ws(E2, n, o), r && import_node_fs14.default.chmodSync(s3, i);
146724
+ E2 && h && ws(E2, n, o), r && import_node_fs15.default.chmodSync(s3, i);
146701
146725
  };
146702
146726
  if (s3 === c) return oo(c), d();
146703
- if (a) return d(import_node_fs14.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
146704
- let T2 = f(import_node_path18.default.relative(c, s3)).split("/"), D2;
146727
+ if (a) return d(import_node_fs15.default.mkdirSync(s3, { mode: i, recursive: true }) ?? void 0);
146728
+ let T2 = f(import_node_path20.default.relative(c, s3)).split("/"), D2;
146705
146729
  for (let E2 = T2.shift(), x2 = c; E2 && (x2 += "/" + E2); E2 = T2.shift()) {
146706
- x2 = f(import_node_path18.default.resolve(x2));
146730
+ x2 = f(import_node_path20.default.resolve(x2));
146707
146731
  try {
146708
- import_node_fs14.default.mkdirSync(x2, i), D2 = D2 || x2;
146732
+ import_node_fs15.default.mkdirSync(x2, i), D2 = D2 || x2;
146709
146733
  } catch {
146710
- let Le = import_node_fs14.default.lstatSync(x2);
146734
+ let Le = import_node_fs15.default.lstatSync(x2);
146711
146735
  if (Le.isDirectory()) continue;
146712
146736
  if (l) {
146713
- import_node_fs14.default.unlinkSync(x2), import_node_fs14.default.mkdirSync(x2, i), D2 = D2 || x2;
146737
+ import_node_fs15.default.unlinkSync(x2), import_node_fs15.default.mkdirSync(x2, i), D2 = D2 || x2;
146714
146738
  continue;
146715
146739
  } else if (Le.isSymbolicLink()) return new St(x2, x2 + "/" + T2.join("/"));
146716
146740
  }
@@ -146732,14 +146756,14 @@ var ho = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
146732
146756
  var ao = ho === "win32";
146733
146757
  var lo = (s3) => s3.split("/").slice(0, -1).reduce((e, i) => {
146734
146758
  let r = e.at(-1);
146735
- return r !== void 0 && (i = (0, import_node_path19.join)(r, i)), e.push(i || "/"), e;
146759
+ return r !== void 0 && (i = (0, import_node_path21.join)(r, i)), e.push(i || "/"), e;
146736
146760
  }, []);
146737
146761
  var yi = class {
146738
146762
  #t = /* @__PURE__ */ new Map();
146739
146763
  #i = /* @__PURE__ */ new Map();
146740
146764
  #s = /* @__PURE__ */ new Set();
146741
146765
  reserve(t2, e) {
146742
- t2 = ao ? ["win32 parallelization disabled"] : t2.map((r) => ut((0, import_node_path19.join)(Tr(r))));
146766
+ t2 = ao ? ["win32 parallelization disabled"] : t2.map((r) => ut((0, import_node_path21.join)(Tr(r))));
146743
146767
  let i = new Set(t2.map((r) => lo(r)).reduce((r, n) => r.concat(n)));
146744
146768
  this.#i.set(e, { dirs: i, paths: t2 });
146745
146769
  for (let r of t2) {
@@ -146829,17 +146853,17 @@ var fo = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform;
146829
146853
  var Te = fo === "win32";
146830
146854
  var mo = 1024;
146831
146855
  var uo = (s3, t2) => {
146832
- if (!Te) return import_node_fs12.default.unlink(s3, t2);
146856
+ if (!Te) return import_node_fs13.default.unlink(s3, t2);
146833
146857
  let e = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
146834
- import_node_fs12.default.rename(s3, e, (i) => {
146858
+ import_node_fs13.default.rename(s3, e, (i) => {
146835
146859
  if (i) return t2(i);
146836
- import_node_fs12.default.unlink(e, t2);
146860
+ import_node_fs13.default.unlink(e, t2);
146837
146861
  });
146838
146862
  };
146839
146863
  var po = (s3) => {
146840
- if (!Te) return import_node_fs12.default.unlinkSync(s3);
146864
+ if (!Te) return import_node_fs13.default.unlinkSync(s3);
146841
146865
  let t2 = s3 + ".DELETE." + (0, import_node_crypto5.randomBytes)(16).toString("hex");
146842
- import_node_fs12.default.renameSync(s3, t2), import_node_fs12.default.unlinkSync(t2);
146866
+ import_node_fs13.default.renameSync(s3, t2), import_node_fs13.default.unlinkSync(t2);
146843
146867
  };
146844
146868
  var vr = (s3, t2, e) => s3 !== void 0 && s3 === s3 >>> 0 ? s3 : t2 !== void 0 && t2 === t2 >>> 0 ? t2 : e;
146845
146869
  var Xt = class extends rt {
@@ -146879,7 +146903,7 @@ var Xt = class extends rt {
146879
146903
  if (t2.preserveOwner) throw new TypeError("cannot preserve owner in archive and also set owner explicitly");
146880
146904
  this.uid = t2.uid, this.gid = t2.gid, this.setOwner = true;
146881
146905
  } else this.uid = void 0, this.gid = void 0, this.setOwner = false;
146882
- this.preserveOwner = t2.preserveOwner === void 0 && typeof t2.uid != "number" ? process.getuid?.() === 0 : !!t2.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t2.maxDepth == "number" ? t2.maxDepth : mo, this.forceChown = t2.forceChown === true, this.win32 = !!t2.win32 || Te, this.newer = !!t2.newer, this.keep = !!t2.keep, this.noMtime = !!t2.noMtime, this.preservePaths = !!t2.preservePaths, this.unlink = !!t2.unlink, this.cwd = f(import_node_path16.default.resolve(t2.cwd || process.cwd())), this.strip = Number(t2.strip) || 0, this.processUmask = this.chmod ? typeof t2.processUmask == "number" ? t2.processUmask : Lr() : 0, this.umask = typeof t2.umask == "number" ? t2.umask : this.processUmask, this.dmode = t2.dmode || 511 & ~this.umask, this.fmode = t2.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
146906
+ this.preserveOwner = t2.preserveOwner === void 0 && typeof t2.uid != "number" ? process.getuid?.() === 0 : !!t2.preserveOwner, this.processUid = (this.preserveOwner || this.setOwner) && process.getuid ? process.getuid() : void 0, this.processGid = (this.preserveOwner || this.setOwner) && process.getgid ? process.getgid() : void 0, this.maxDepth = typeof t2.maxDepth == "number" ? t2.maxDepth : mo, this.forceChown = t2.forceChown === true, this.win32 = !!t2.win32 || Te, this.newer = !!t2.newer, this.keep = !!t2.keep, this.noMtime = !!t2.noMtime, this.preservePaths = !!t2.preservePaths, this.unlink = !!t2.unlink, this.cwd = f(import_node_path18.default.resolve(t2.cwd || process.cwd())), this.strip = Number(t2.strip) || 0, this.processUmask = this.chmod ? typeof t2.processUmask == "number" ? t2.processUmask : Lr() : 0, this.umask = typeof t2.umask == "number" ? t2.umask : this.processUmask, this.dmode = t2.dmode || 511 & ~this.umask, this.fmode = t2.fmode || 438 & ~this.umask, this.on("entry", (e) => this[Dr](e));
146883
146907
  }
146884
146908
  warn(t2, e, i = {}) {
146885
146909
  return (t2 === "TAR_BAD_ARCHIVE" || t2 === "TAR_ABORT") && (i.recoverable = false), super.warn(t2, e, i);
@@ -146893,7 +146917,7 @@ var Xt = class extends rt {
146893
146917
  let [n, o] = ce(i), h = o.replaceAll(/\\/g, "/").split("/");
146894
146918
  if (h.includes("..") || Te && /^[a-z]:\.\.$/i.test(h[0] ?? "")) {
146895
146919
  if (e === "path" || r === "Link") return this.warn("TAR_ENTRY_ERROR", `${e} contains '..'`, { entry: t2, [e]: i }), false;
146896
- let a = import_node_path16.default.posix.dirname(t2.path), l = import_node_path16.default.posix.normalize(import_node_path16.default.posix.join(a, h.join("/")));
146920
+ let a = import_node_path18.default.posix.dirname(t2.path), l = import_node_path18.default.posix.normalize(import_node_path18.default.posix.join(a, h.join("/")));
146897
146921
  if (l.startsWith("../") || l === "..") return this.warn("TAR_ENTRY_ERROR", `${e} escapes extraction directory`, { entry: t2, [e]: i }), false;
146898
146922
  }
146899
146923
  return n && (t2[e] = String(o), this.warn("TAR_ENTRY_INFO", `stripping ${n} from absolute ${e}`, { entry: t2, [e]: i })), true;
@@ -146911,12 +146935,12 @@ var Xt = class extends rt {
146911
146935
  }
146912
146936
  if (isFinite(this.maxDepth) && i.length > this.maxDepth) return this.warn("TAR_ENTRY_ERROR", "path excessively deep", { entry: t2, path: e, depth: i.length, maxDepth: this.maxDepth }), false;
146913
146937
  if (!this[Rs](t2, "path") || !this[Rs](t2, "linkpath")) return false;
146914
- if (t2.absolute = import_node_path16.default.isAbsolute(t2.path) ? f(import_node_path16.default.resolve(t2.path)) : f(import_node_path16.default.resolve(this.cwd, t2.path)), !this.preservePaths && typeof t2.absolute == "string" && t2.absolute.indexOf(this.cwd + "/") !== 0 && t2.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t2, path: f(t2.path), resolvedPath: t2.absolute, cwd: this.cwd }), false;
146938
+ if (t2.absolute = import_node_path18.default.isAbsolute(t2.path) ? f(import_node_path18.default.resolve(t2.path)) : f(import_node_path18.default.resolve(this.cwd, t2.path)), !this.preservePaths && typeof t2.absolute == "string" && t2.absolute.indexOf(this.cwd + "/") !== 0 && t2.absolute !== this.cwd) return this.warn("TAR_ENTRY_ERROR", "path escaped extraction target", { entry: t2, path: f(t2.path), resolvedPath: t2.absolute, cwd: this.cwd }), false;
146915
146939
  if (t2.absolute === this.cwd && t2.type !== "Directory" && t2.type !== "GNUDumpDir") return false;
146916
146940
  if (this.win32) {
146917
- let { root: r } = import_node_path16.default.win32.parse(String(t2.absolute));
146941
+ let { root: r } = import_node_path18.default.win32.parse(String(t2.absolute));
146918
146942
  t2.absolute = r + ts(String(t2.absolute).slice(r.length));
146919
- let { root: n } = import_node_path16.default.win32.parse(t2.path);
146943
+ let { root: n } = import_node_path18.default.win32.parse(t2.path);
146920
146944
  t2.path = n + ts(t2.path.slice(n.length));
146921
146945
  }
146922
146946
  return true;
@@ -146955,16 +146979,16 @@ var Xt = class extends rt {
146955
146979
  [Ts](t2, e) {
146956
146980
  let i = typeof t2.mode == "number" ? t2.mode & 4095 : this.fmode, r = new et(String(t2.absolute), { flags: us(t2.size), mode: i, autoClose: false });
146957
146981
  r.on("error", (a) => {
146958
- r.fd && import_node_fs12.default.close(r.fd, () => {
146982
+ r.fd && import_node_fs13.default.close(r.fd, () => {
146959
146983
  }), r.write = () => true, this[O2](a, t2), e();
146960
146984
  });
146961
146985
  let n = 1, o = (a) => {
146962
146986
  if (a) {
146963
- r.fd && import_node_fs12.default.close(r.fd, () => {
146987
+ r.fd && import_node_fs13.default.close(r.fd, () => {
146964
146988
  }), this[O2](a, t2), e();
146965
146989
  return;
146966
146990
  }
146967
- --n === 0 && r.fd !== void 0 && import_node_fs12.default.close(r.fd, (l) => {
146991
+ --n === 0 && r.fd !== void 0 && import_node_fs13.default.close(r.fd, (l) => {
146968
146992
  l ? this[O2](l, t2) : this[$t](), e();
146969
146993
  });
146970
146994
  };
@@ -146973,12 +146997,12 @@ var Xt = class extends rt {
146973
146997
  if (typeof l == "number" && t2.mtime && !this.noMtime) {
146974
146998
  n++;
146975
146999
  let c = t2.atime || /* @__PURE__ */ new Date(), d = t2.mtime;
146976
- import_node_fs12.default.futimes(l, c, d, (S2) => S2 ? import_node_fs12.default.utimes(a, c, d, (T2) => o(T2 && S2)) : o());
147000
+ import_node_fs13.default.futimes(l, c, d, (S2) => S2 ? import_node_fs13.default.utimes(a, c, d, (T2) => o(T2 && S2)) : o());
146977
147001
  }
146978
147002
  if (typeof l == "number" && this[ge](t2)) {
146979
147003
  n++;
146980
147004
  let c = this[be](t2), d = this[_e](t2);
146981
- typeof c == "number" && typeof d == "number" && import_node_fs12.default.fchown(l, c, d, (S2) => S2 ? import_node_fs12.default.chown(a, c, d, (T2) => o(T2 && S2)) : o());
147005
+ typeof c == "number" && typeof d == "number" && import_node_fs13.default.fchown(l, c, d, (S2) => S2 ? import_node_fs13.default.chown(a, c, d, (T2) => o(T2 && S2)) : o());
146982
147006
  }
146983
147007
  o();
146984
147008
  });
@@ -146997,20 +147021,20 @@ var Xt = class extends rt {
146997
147021
  let n = 1, o = () => {
146998
147022
  --n === 0 && (e(), this[$t](), t2.resume());
146999
147023
  };
147000
- t2.mtime && !this.noMtime && (n++, import_node_fs12.default.utimes(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime, o)), this[ge](t2) && (n++, import_node_fs12.default.chown(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)), o)), o();
147024
+ t2.mtime && !this.noMtime && (n++, import_node_fs13.default.utimes(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime, o)), this[ge](t2) && (n++, import_node_fs13.default.chown(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)), o)), o();
147001
147025
  });
147002
147026
  }
147003
147027
  [Cr](t2) {
147004
147028
  t2.unsupported = true, this.warn("TAR_ENTRY_UNSUPPORTED", `unsupported entry type: ${t2.type}`, { entry: t2 }), t2.resume();
147005
147029
  }
147006
147030
  [Ar](t2, e) {
147007
- let i = f(import_node_path16.default.relative(this.cwd, import_node_path16.default.resolve(import_node_path16.default.dirname(String(t2.absolute)), String(t2.linkpath)))).split("/");
147031
+ let i = f(import_node_path18.default.relative(this.cwd, import_node_path18.default.resolve(import_node_path18.default.dirname(String(t2.absolute)), String(t2.linkpath)))).split("/");
147008
147032
  this[Re](t2, this.cwd, i, () => this[gi](t2, String(t2.linkpath), "symlink", e), (r) => {
147009
147033
  this[O2](r, t2), e();
147010
147034
  });
147011
147035
  }
147012
147036
  [Ir](t2, e) {
147013
- let i = f(import_node_path16.default.resolve(this.cwd, String(t2.linkpath))), r = f(String(t2.linkpath)).split("/");
147037
+ let i = f(import_node_path18.default.resolve(this.cwd, String(t2.linkpath))), r = f(String(t2.linkpath)).split("/");
147014
147038
  this[Re](t2, this.cwd, r, () => this[gi](t2, i, "link", e), (n) => {
147015
147039
  this[O2](n, t2), e();
147016
147040
  });
@@ -147018,10 +147042,10 @@ var Xt = class extends rt {
147018
147042
  [Re](t2, e, i, r, n) {
147019
147043
  let o = i.shift();
147020
147044
  if (this.preservePaths || o === void 0) return r();
147021
- let h = import_node_path16.default.resolve(e, o);
147022
- import_node_fs12.default.lstat(h, (a, l) => {
147045
+ let h = import_node_path18.default.resolve(e, o);
147046
+ import_node_fs13.default.lstat(h, (a, l) => {
147023
147047
  if (a) return r();
147024
- if (l?.isSymbolicLink()) return n(new St(h, import_node_path16.default.resolve(h, i.join("/"))));
147048
+ if (l?.isSymbolicLink()) return n(new St(h, import_node_path18.default.resolve(h, i.join("/"))));
147025
147049
  this[Re](t2, h, i, r, n);
147026
147050
  });
147027
147051
  }
@@ -147055,7 +147079,7 @@ var Xt = class extends rt {
147055
147079
  });
147056
147080
  }, n = () => {
147057
147081
  if (t2.absolute !== this.cwd) {
147058
- let h = f(import_node_path16.default.dirname(String(t2.absolute)));
147082
+ let h = f(import_node_path18.default.dirname(String(t2.absolute)));
147059
147083
  if (h !== this.cwd) return this[yt](h, this.dmode, (a) => {
147060
147084
  if (a) {
147061
147085
  this[O2](a, t2), i();
@@ -147066,7 +147090,7 @@ var Xt = class extends rt {
147066
147090
  }
147067
147091
  o();
147068
147092
  }, o = () => {
147069
- import_node_fs12.default.lstat(String(t2.absolute), (h, a) => {
147093
+ import_node_fs13.default.lstat(String(t2.absolute), (h, a) => {
147070
147094
  if (a && (this.keep || this.newer && a.mtime > (t2.mtime ?? a.mtime))) {
147071
147095
  this[Ls](t2), i();
147072
147096
  return;
@@ -147075,9 +147099,9 @@ var Xt = class extends rt {
147075
147099
  if (a.isDirectory()) {
147076
147100
  if (t2.type === "Directory") {
147077
147101
  let l = this.chmod && t2.mode && (a.mode & 4095) !== t2.mode, c = (d) => this[P2](d ?? null, t2, i);
147078
- return l ? import_node_fs12.default.chmod(String(t2.absolute), Number(t2.mode), c) : c();
147102
+ return l ? import_node_fs13.default.chmod(String(t2.absolute), Number(t2.mode), c) : c();
147079
147103
  }
147080
- if (t2.absolute !== this.cwd) return import_node_fs12.default.rmdir(String(t2.absolute), (l) => this[P2](l ?? null, t2, i));
147104
+ if (t2.absolute !== this.cwd) return import_node_fs13.default.rmdir(String(t2.absolute), (l) => this[P2](l ?? null, t2, i));
147081
147105
  }
147082
147106
  if (t2.absolute === this.cwd) return this[P2](null, t2, i);
147083
147107
  uo(String(t2.absolute), (l) => this[P2](l ?? null, t2, i));
@@ -147105,7 +147129,7 @@ var Xt = class extends rt {
147105
147129
  }
147106
147130
  }
147107
147131
  [gi](t2, e, i, r) {
147108
- import_node_fs12.default[i](e, String(t2.absolute), (n) => {
147132
+ import_node_fs13.default[i](e, String(t2.absolute), (n) => {
147109
147133
  n ? this[O2](n, t2) : (this[$t](), t2.resume()), r();
147110
147134
  });
147111
147135
  }
@@ -147130,23 +147154,23 @@ var xe = class extends Xt {
147130
147154
  this[Oe] = true;
147131
147155
  }
147132
147156
  if (t2.absolute !== this.cwd) {
147133
- let n = f(import_node_path16.default.dirname(String(t2.absolute)));
147157
+ let n = f(import_node_path18.default.dirname(String(t2.absolute)));
147134
147158
  if (n !== this.cwd) {
147135
147159
  let o = this[yt](n, this.dmode);
147136
147160
  if (o) return this[O2](o, t2);
147137
147161
  }
147138
147162
  }
147139
- let [e, i] = ye(() => import_node_fs12.default.lstatSync(String(t2.absolute)));
147163
+ let [e, i] = ye(() => import_node_fs13.default.lstatSync(String(t2.absolute)));
147140
147164
  if (i && (this.keep || this.newer && i.mtime > (t2.mtime ?? i.mtime))) return this[Ls](t2);
147141
147165
  if (e || this[Os](t2, i)) return this[P2](null, t2);
147142
147166
  if (i.isDirectory()) {
147143
147167
  if (t2.type === "Directory") {
147144
147168
  let o = this.chmod && t2.mode && (i.mode & 4095) !== t2.mode, [h] = o ? ye(() => {
147145
- import_node_fs12.default.chmodSync(String(t2.absolute), Number(t2.mode));
147169
+ import_node_fs13.default.chmodSync(String(t2.absolute), Number(t2.mode));
147146
147170
  }) : [];
147147
147171
  return this[P2](h, t2);
147148
147172
  }
147149
- let [n] = ye(() => import_node_fs12.default.rmdirSync(String(t2.absolute)));
147173
+ let [n] = ye(() => import_node_fs13.default.rmdirSync(String(t2.absolute)));
147150
147174
  this[P2](n, t2);
147151
147175
  }
147152
147176
  let [r] = t2.absolute === this.cwd ? [] : ye(() => po(String(t2.absolute)));
@@ -147156,21 +147180,21 @@ var xe = class extends Xt {
147156
147180
  let i = typeof t2.mode == "number" ? t2.mode & 4095 : this.fmode, r = (h) => {
147157
147181
  let a;
147158
147182
  try {
147159
- import_node_fs12.default.closeSync(n);
147183
+ import_node_fs13.default.closeSync(n);
147160
147184
  } catch (l) {
147161
147185
  a = l;
147162
147186
  }
147163
147187
  (h || a) && this[O2](h || a, t2), e();
147164
147188
  }, n;
147165
147189
  try {
147166
- n = import_node_fs12.default.openSync(String(t2.absolute), us(t2.size), i);
147190
+ n = import_node_fs13.default.openSync(String(t2.absolute), us(t2.size), i);
147167
147191
  } catch (h) {
147168
147192
  return r(h);
147169
147193
  }
147170
147194
  let o = this.transform && this.transform(t2) || t2;
147171
147195
  o !== t2 && (o.on("error", (h) => this[O2](h, t2)), t2.pipe(o)), o.on("data", (h) => {
147172
147196
  try {
147173
- import_node_fs12.default.writeSync(n, h, 0, h.length);
147197
+ import_node_fs13.default.writeSync(n, h, 0, h.length);
147174
147198
  } catch (a) {
147175
147199
  r(a);
147176
147200
  }
@@ -147179,10 +147203,10 @@ var xe = class extends Xt {
147179
147203
  if (t2.mtime && !this.noMtime) {
147180
147204
  let a = t2.atime || /* @__PURE__ */ new Date(), l = t2.mtime;
147181
147205
  try {
147182
- import_node_fs12.default.futimesSync(n, a, l);
147206
+ import_node_fs13.default.futimesSync(n, a, l);
147183
147207
  } catch (c) {
147184
147208
  try {
147185
- import_node_fs12.default.utimesSync(String(t2.absolute), a, l);
147209
+ import_node_fs13.default.utimesSync(String(t2.absolute), a, l);
147186
147210
  } catch {
147187
147211
  h = c;
147188
147212
  }
@@ -147191,10 +147215,10 @@ var xe = class extends Xt {
147191
147215
  if (this[ge](t2)) {
147192
147216
  let a = this[be](t2), l = this[_e](t2);
147193
147217
  try {
147194
- import_node_fs12.default.fchownSync(n, Number(a), Number(l));
147218
+ import_node_fs13.default.fchownSync(n, Number(a), Number(l));
147195
147219
  } catch (c) {
147196
147220
  try {
147197
- import_node_fs12.default.chownSync(String(t2.absolute), Number(a), Number(l));
147221
+ import_node_fs13.default.chownSync(String(t2.absolute), Number(a), Number(l));
147198
147222
  } catch {
147199
147223
  h = h || c;
147200
147224
  }
@@ -147210,11 +147234,11 @@ var xe = class extends Xt {
147210
147234
  return;
147211
147235
  }
147212
147236
  if (t2.mtime && !this.noMtime) try {
147213
- import_node_fs12.default.utimesSync(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime);
147237
+ import_node_fs13.default.utimesSync(String(t2.absolute), t2.atime || /* @__PURE__ */ new Date(), t2.mtime);
147214
147238
  } catch {
147215
147239
  }
147216
147240
  if (this[ge](t2)) try {
147217
- import_node_fs12.default.chownSync(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)));
147241
+ import_node_fs13.default.chownSync(String(t2.absolute), Number(this[be](t2)), Number(this[_e](t2)));
147218
147242
  } catch {
147219
147243
  }
147220
147244
  e(), t2.resume();
@@ -147230,30 +147254,30 @@ var xe = class extends Xt {
147230
147254
  if (this.preservePaths || i.length === 0) return r();
147231
147255
  let o = e;
147232
147256
  for (let h of i) {
147233
- o = import_node_path16.default.resolve(o, h);
147234
- let [a, l] = ye(() => import_node_fs12.default.lstatSync(o));
147257
+ o = import_node_path18.default.resolve(o, h);
147258
+ let [a, l] = ye(() => import_node_fs13.default.lstatSync(o));
147235
147259
  if (a) return r();
147236
- if (l.isSymbolicLink()) return n(new St(o, import_node_path16.default.resolve(e, i.join("/"))));
147260
+ if (l.isSymbolicLink()) return n(new St(o, import_node_path18.default.resolve(e, i.join("/"))));
147237
147261
  }
147238
147262
  r();
147239
147263
  }
147240
147264
  [gi](t2, e, i, r) {
147241
147265
  let n = `${i}Sync`;
147242
147266
  try {
147243
- import_node_fs12.default[n](e, String(t2.absolute)), r(), t2.resume();
147267
+ import_node_fs13.default[n](e, String(t2.absolute)), r(), t2.resume();
147244
147268
  } catch (o) {
147245
147269
  return this[O2](o, t2);
147246
147270
  }
147247
147271
  }
147248
147272
  };
147249
147273
  var Eo = (s3) => {
147250
- let t2 = new xe(s3), e = s3.file, i = import_node_fs11.default.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
147274
+ let t2 = new xe(s3), e = s3.file, i = import_node_fs12.default.statSync(e), r = s3.maxReadSize || 16 * 1024 * 1024;
147251
147275
  new Be(e, { readSize: r, size: i.size }).pipe(t2);
147252
147276
  };
147253
147277
  var wo = (s3, t2) => {
147254
147278
  let e = new Xt(s3), i = s3.maxReadSize || 16 * 1024 * 1024, r = s3.file;
147255
147279
  return new Promise((o, h) => {
147256
- e.on("error", h), e.on("close", o), import_node_fs11.default.stat(r, (a, l) => {
147280
+ e.on("error", h), e.on("close", o), import_node_fs12.default.stat(r, (a, l) => {
147257
147281
  if (a) h(a);
147258
147282
  else {
147259
147283
  let c = new _t(r, { readSize: i, size: l.size });
@@ -147269,15 +147293,15 @@ var yo = (s3, t2) => {
147269
147293
  let e = new kt(s3), i = true, r, n;
147270
147294
  try {
147271
147295
  try {
147272
- r = import_node_fs15.default.openSync(s3.file, "r+");
147296
+ r = import_node_fs16.default.openSync(s3.file, "r+");
147273
147297
  } catch (a) {
147274
- if (a?.code === "ENOENT") r = import_node_fs15.default.openSync(s3.file, "w+");
147298
+ if (a?.code === "ENOENT") r = import_node_fs16.default.openSync(s3.file, "w+");
147275
147299
  else throw a;
147276
147300
  }
147277
- let o = import_node_fs15.default.fstatSync(r), h = Buffer.alloc(512);
147301
+ let o = import_node_fs16.default.fstatSync(r), h = Buffer.alloc(512);
147278
147302
  t: for (n = 0; n < o.size; n += 512) {
147279
147303
  for (let c = 0, d = 0; c < 512; c += d) {
147280
- if (d = import_node_fs15.default.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
147304
+ if (d = import_node_fs16.default.readSync(r, h, c, h.length - c, n + c), n === 0 && h[0] === 31 && h[1] === 139) throw new Error("cannot append to compressed archives");
147281
147305
  if (!d) break t;
147282
147306
  }
147283
147307
  let a = new F2(h);
@@ -147289,7 +147313,7 @@ var yo = (s3, t2) => {
147289
147313
  i = false, Ro(s3, e, n, r, t2);
147290
147314
  } finally {
147291
147315
  if (i) try {
147292
- import_node_fs15.default.closeSync(r);
147316
+ import_node_fs16.default.closeSync(r);
147293
147317
  } catch {
147294
147318
  }
147295
147319
  }
@@ -147302,29 +147326,29 @@ var go = (s3, t2) => {
147302
147326
  t2 = Array.from(t2);
147303
147327
  let e = new wt(s3), i = (n, o, h) => {
147304
147328
  let a = (T2, D2) => {
147305
- T2 ? import_node_fs15.default.close(n, (E2) => h(T2)) : h(null, D2);
147329
+ T2 ? import_node_fs16.default.close(n, (E2) => h(T2)) : h(null, D2);
147306
147330
  }, l = 0;
147307
147331
  if (o === 0) return a(null, 0);
147308
147332
  let c = 0, d = Buffer.alloc(512), S2 = (T2, D2) => {
147309
147333
  if (T2 || D2 === void 0) return a(T2);
147310
- if (c += D2, c < 512 && D2) return import_node_fs15.default.read(n, d, c, d.length - c, l + c, S2);
147334
+ if (c += D2, c < 512 && D2) return import_node_fs16.default.read(n, d, c, d.length - c, l + c, S2);
147311
147335
  if (l === 0 && d[0] === 31 && d[1] === 139) return a(new Error("cannot append to compressed archives"));
147312
147336
  if (c < 512) return a(null, l);
147313
147337
  let E2 = new F2(d);
147314
147338
  if (!E2.cksumValid) return a(null, l);
147315
147339
  let x2 = 512 * Math.ceil((E2.size ?? 0) / 512);
147316
147340
  if (l + x2 + 512 > o || (l += x2 + 512, l >= o)) return a(null, l);
147317
- s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c = 0, import_node_fs15.default.read(n, d, 0, 512, l, S2);
147341
+ s3.mtimeCache && E2.mtime && s3.mtimeCache.set(String(E2.path), E2.mtime), c = 0, import_node_fs16.default.read(n, d, 0, 512, l, S2);
147318
147342
  };
147319
- import_node_fs15.default.read(n, d, 0, 512, l, S2);
147343
+ import_node_fs16.default.read(n, d, 0, 512, l, S2);
147320
147344
  };
147321
147345
  return new Promise((n, o) => {
147322
147346
  e.on("error", o);
147323
147347
  let h = "r+", a = (l, c) => {
147324
- if (l && l.code === "ENOENT" && h === "r+") return h = "w+", import_node_fs15.default.open(s3.file, h, a);
147348
+ if (l && l.code === "ENOENT" && h === "r+") return h = "w+", import_node_fs16.default.open(s3.file, h, a);
147325
147349
  if (l || !c) return o(l);
147326
- import_node_fs15.default.fstat(c, (d, S2) => {
147327
- if (d) return import_node_fs15.default.close(c, () => o(d));
147350
+ import_node_fs16.default.fstat(c, (d, S2) => {
147351
+ if (d) return import_node_fs16.default.close(c, () => o(d));
147328
147352
  i(c, S2.size, (T2, D2) => {
147329
147353
  if (T2) return o(T2);
147330
147354
  let E2 = new et(s3.file, { fd: c, start: D2 });
@@ -147332,16 +147356,16 @@ var go = (s3, t2) => {
147332
147356
  });
147333
147357
  });
147334
147358
  };
147335
- import_node_fs15.default.open(s3.file, h, a);
147359
+ import_node_fs16.default.open(s3.file, h, a);
147336
147360
  });
147337
147361
  };
147338
147362
  var bo = (s3, t2) => {
147339
147363
  t2.forEach((e) => {
147340
- e.charAt(0) === "@" ? Ct({ file: import_node_path20.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
147364
+ e.charAt(0) === "@" ? Ct({ file: import_node_path22.default.resolve(s3.cwd, e.slice(1)), sync: true, noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
147341
147365
  }), s3.end();
147342
147366
  };
147343
147367
  var _o = async (s3, t2) => {
147344
- for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path20.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
147368
+ for (let e of t2) e.charAt(0) === "@" ? await Ct({ file: import_node_path22.default.resolve(String(s3.cwd), e.slice(1)), noResume: true, onReadEntry: (i) => s3.add(i) }) : s3.add(e);
147345
147369
  s3.end();
147346
147370
  };
147347
147371
  var vt = K2(yo, go, () => {
@@ -147364,19 +147388,19 @@ var To = (s3) => {
147364
147388
  // src/updater/unpack.ts
147365
147389
  async function unpackTarball(opts) {
147366
147390
  const { tarballPath, destDir } = opts;
147367
- (0, import_node_fs16.rmSync)(destDir, { recursive: true, force: true });
147368
- (0, import_node_fs16.mkdirSync)(destDir, { recursive: true });
147391
+ (0, import_node_fs17.rmSync)(destDir, { recursive: true, force: true });
147392
+ (0, import_node_fs17.mkdirSync)(destDir, { recursive: true });
147369
147393
  await So({ file: tarballPath, cwd: destDir });
147370
147394
  }
147371
147395
 
147372
147396
  // src/updater/update-log.ts
147373
- var import_node_fs17 = require("fs");
147374
- var import_node_path21 = require("path");
147375
- var LOG_PATH = (0, import_node_path21.join)(THREADBASE_ROOT, "update.log");
147397
+ var import_node_fs18 = require("fs");
147398
+ var import_node_path23 = require("path");
147399
+ var LOG_PATH = (0, import_node_path23.join)(THREADBASE_ROOT, "update.log");
147376
147400
  function appendUpdateLog(line) {
147377
147401
  try {
147378
- (0, import_node_fs17.mkdirSync)(THREADBASE_ROOT, { recursive: true });
147379
- (0, import_node_fs17.appendFileSync)(LOG_PATH, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
147402
+ (0, import_node_fs18.mkdirSync)(THREADBASE_ROOT, { recursive: true });
147403
+ (0, import_node_fs18.appendFileSync)(LOG_PATH, `${(/* @__PURE__ */ new Date()).toISOString()} ${line}
147380
147404
  `, "utf8");
147381
147405
  } catch {
147382
147406
  }
@@ -147447,7 +147471,7 @@ async function runInstall(opts) {
147447
147471
  }
147448
147472
  }
147449
147473
  ensureReleasesDir();
147450
- (0, import_node_fs18.mkdirSync)(DOWNLOAD_DIR, { recursive: true });
147474
+ (0, import_node_fs19.mkdirSync)(DOWNLOAD_DIR, { recursive: true });
147451
147475
  const tarballPath = downloadPath(targetVersion, artifact.filename);
147452
147476
  await downloadAndVerify({ manifest, assets: target.assets, targetPath: tarballPath });
147453
147477
  const destDir = releaseDir(targetVersion);
@@ -147481,7 +147505,7 @@ async function runInstall(opts) {
147481
147505
 
147482
147506
  // cli/prod.ts
147483
147507
  var import_node_child_process6 = require("child_process");
147484
- var import_node_fs20 = require("fs");
147508
+ var import_node_fs21 = require("fs");
147485
147509
  init_constants();
147486
147510
  init_launchd();
147487
147511
  init_marker();
@@ -147567,7 +147591,7 @@ async function runProdDoctor(opts) {
147567
147591
  return { findings, repairs };
147568
147592
  }
147569
147593
  var defaultSpawnTail = ({ files, lines, follow }) => {
147570
- const existing = files.filter((f2) => (0, import_node_fs20.existsSync)(f2));
147594
+ const existing = files.filter((f2) => (0, import_node_fs21.existsSync)(f2));
147571
147595
  if (existing.length === 0) {
147572
147596
  return Promise.resolve({
147573
147597
  ok: false,
@@ -147621,8 +147645,8 @@ function registerProdCommands(program3) {
147621
147645
  const prod = new Command("prod").description(
147622
147646
  "Manage the launchd-supervised prod streamer"
147623
147647
  );
147624
- prod.command("start").description("Restore prod after a user-held suspension").option("--preserve-logs", "Keep existing stdout + stderr logs", false).action(async (opts) => {
147625
- if (opts.preserveLogs !== true) clearSupervisorLogs();
147648
+ prod.command("start").description("Restore prod after a user-held suspension").option("--clear-logs", "Clear existing stdout + stderr logs", false).action(async (opts) => {
147649
+ if (opts.clearLogs === true) clearSupervisorLogs();
147626
147650
  const r = await runProdStart();
147627
147651
  log4.info(r.message, void 0, "console");
147628
147652
  if (!r.ok) process.exitCode = 1;
@@ -147640,10 +147664,10 @@ function registerProdCommands(program3) {
147640
147664
  ];
147641
147665
  log4.info(parts.join("\n "), void 0, "console");
147642
147666
  });
147643
- prod.command("restart").description("Stop + restart the supervised streamer (re-reads service definition)").option("--preserve-logs", "Keep existing stdout + stderr logs", false).action(async (opts) => {
147667
+ prod.command("restart").description("Stop + restart the supervised streamer (re-reads service definition)").option("--clear-logs", "Clear existing stdout + stderr logs", false).action(async (opts) => {
147644
147668
  const sup = getSupervisor();
147645
147669
  const specPath = process.platform === "darwin" ? darwinPlistPath() : "";
147646
- if (opts.preserveLogs !== true) clearSupervisorLogs();
147670
+ if (opts.clearLogs === true) clearSupervisorLogs();
147647
147671
  sup.bootoutAgent();
147648
147672
  sup.bootstrapAgent(specPath);
147649
147673
  const what = process.platform === "darwin" ? `agent restarted from ${specPath}` : `task '${TASK_NAME}' restarted`;
@@ -147697,6 +147721,7 @@ program2.command("serve").description("Start the streamer server").option("-p, -
147697
147721
  const apiKey = opts.apiKey ?? loadOrCreateApiKey();
147698
147722
  const publicUrl = opts.publicUrl ?? loadPublicUrl() ?? null;
147699
147723
  const isProdInvocation = opts.prod === true || process.ppid === 1;
147724
+ if (!isProdInvocation) appendDevSessionMarker();
147700
147725
  let resolvedPort = requestedPort;
147701
147726
  if (!isProdInvocation) {
147702
147727
  const { resolveDevPlan: resolveDevPlan2, detectProdActive: detectProdActive2, isPortInUse: isPortInUse2, findFreePort: findFreePort2, takeoverProd: takeoverProd2 } = await Promise.resolve().then(() => (init_dev_takeover(), dev_takeover_exports));
@@ -147787,8 +147812,8 @@ program2.command("cache").description("Manage the local SQLite conversation cach
147787
147812
  `${process.env.HOME}/.threadbase/cache`
147788
147813
  ).action((opts) => {
147789
147814
  const { rmSync: rmSync6, existsSync: existsSync11 } = require("fs");
147790
- const { join: join25 } = require("path");
147791
- const dbPath = join25(opts.cacheDir, "cache.db");
147815
+ const { join: join26 } = require("path");
147816
+ const dbPath = join26(opts.cacheDir, "cache.db");
147792
147817
  for (const suffix of ["", "-shm", "-wal"]) {
147793
147818
  const f2 = dbPath + suffix;
147794
147819
  if (existsSync11(f2)) {