@runfusion/fusion 0.0.6 → 0.1.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/bin.js CHANGED
@@ -138,7 +138,7 @@ var init_settings_schema = __esm({
138
138
  worktreeRebaseRemote: "",
139
139
  strictScopeEnforcement: false,
140
140
  buildRetryCount: 0,
141
- verificationFixRetries: 1,
141
+ verificationFixRetries: 3,
142
142
  buildTimeoutMs: 3e5,
143
143
  requirePlanApproval: false,
144
144
  specStalenessEnabled: false,
@@ -37141,9 +37141,9 @@ var require_pump = __commonJS({
37141
37141
  "use strict";
37142
37142
  var once3 = require_once();
37143
37143
  var eos = require_end_of_stream();
37144
- var fs;
37144
+ var fs2;
37145
37145
  try {
37146
- fs = __require("fs");
37146
+ fs2 = __require("fs");
37147
37147
  } catch (e) {
37148
37148
  }
37149
37149
  var noop = function() {
@@ -37154,8 +37154,8 @@ var require_pump = __commonJS({
37154
37154
  };
37155
37155
  var isFS = function(stream) {
37156
37156
  if (!ancient) return false;
37157
- if (!fs) return false;
37158
- return (stream instanceof (fs.ReadStream || noop) || stream instanceof (fs.WriteStream || noop)) && isFn(stream.close);
37157
+ if (!fs2) return false;
37158
+ return (stream instanceof (fs2.ReadStream || noop) || stream instanceof (fs2.WriteStream || noop)) && isFn(stream.close);
37159
37159
  };
37160
37160
  var isRequest = function(stream) {
37161
37161
  return stream.setHeader && isFn(stream.abort);
@@ -37369,7 +37369,7 @@ var require_pend = __commonJS({
37369
37369
  var require_fd_slicer = __commonJS({
37370
37370
  "../../node_modules/.pnpm/fd-slicer@1.1.0/node_modules/fd-slicer/index.js"(exports) {
37371
37371
  "use strict";
37372
- var fs = __require("fs");
37372
+ var fs2 = __require("fs");
37373
37373
  var util = __require("util");
37374
37374
  var stream = __require("stream");
37375
37375
  var Readable2 = stream.Readable;
@@ -37394,7 +37394,7 @@ var require_fd_slicer = __commonJS({
37394
37394
  FdSlicer.prototype.read = function(buffer, offset, length, position, callback) {
37395
37395
  var self2 = this;
37396
37396
  self2.pend.go(function(cb) {
37397
- fs.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
37397
+ fs2.read(self2.fd, buffer, offset, length, position, function(err, bytesRead, buffer2) {
37398
37398
  cb();
37399
37399
  callback(err, bytesRead, buffer2);
37400
37400
  });
@@ -37403,7 +37403,7 @@ var require_fd_slicer = __commonJS({
37403
37403
  FdSlicer.prototype.write = function(buffer, offset, length, position, callback) {
37404
37404
  var self2 = this;
37405
37405
  self2.pend.go(function(cb) {
37406
- fs.write(self2.fd, buffer, offset, length, position, function(err, written, buffer2) {
37406
+ fs2.write(self2.fd, buffer, offset, length, position, function(err, written, buffer2) {
37407
37407
  cb();
37408
37408
  callback(err, written, buffer2);
37409
37409
  });
@@ -37424,7 +37424,7 @@ var require_fd_slicer = __commonJS({
37424
37424
  if (self2.refCount > 0) return;
37425
37425
  if (self2.refCount < 0) throw new Error("invalid unref");
37426
37426
  if (self2.autoClose) {
37427
- fs.close(self2.fd, onCloseDone);
37427
+ fs2.close(self2.fd, onCloseDone);
37428
37428
  }
37429
37429
  function onCloseDone(err) {
37430
37430
  if (err) {
@@ -37461,7 +37461,7 @@ var require_fd_slicer = __commonJS({
37461
37461
  self2.context.pend.go(function(cb) {
37462
37462
  if (self2.destroyed) return cb();
37463
37463
  var buffer = new Buffer(toRead);
37464
- fs.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
37464
+ fs2.read(self2.context.fd, buffer, 0, toRead, self2.pos, function(err, bytesRead) {
37465
37465
  if (err) {
37466
37466
  self2.destroy(err);
37467
37467
  } else if (bytesRead === 0) {
@@ -37508,7 +37508,7 @@ var require_fd_slicer = __commonJS({
37508
37508
  }
37509
37509
  self2.context.pend.go(function(cb) {
37510
37510
  if (self2.destroyed) return cb();
37511
- fs.write(self2.context.fd, buffer, 0, buffer.length, self2.pos, function(err2, bytes) {
37511
+ fs2.write(self2.context.fd, buffer, 0, buffer.length, self2.pos, function(err2, bytes) {
37512
37512
  if (err2) {
37513
37513
  self2.destroy();
37514
37514
  cb();
@@ -37937,7 +37937,7 @@ var require_buffer_crc32 = __commonJS({
37937
37937
  var require_yauzl = __commonJS({
37938
37938
  "../../node_modules/.pnpm/yauzl@2.10.0/node_modules/yauzl/index.js"(exports) {
37939
37939
  "use strict";
37940
- var fs = __require("fs");
37940
+ var fs2 = __require("fs");
37941
37941
  var zlib = __require("zlib");
37942
37942
  var fd_slicer = require_fd_slicer();
37943
37943
  var crc32 = require_buffer_crc32();
@@ -37967,10 +37967,10 @@ var require_yauzl = __commonJS({
37967
37967
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
37968
37968
  if (options.strictFileNames == null) options.strictFileNames = false;
37969
37969
  if (callback == null) callback = defaultCallback;
37970
- fs.open(path4, "r", function(err, fd) {
37970
+ fs2.open(path4, "r", function(err, fd) {
37971
37971
  if (err) return callback(err);
37972
37972
  fromFd(fd, options, function(err2, zipfile) {
37973
- if (err2) fs.close(fd, defaultCallback);
37973
+ if (err2) fs2.close(fd, defaultCallback);
37974
37974
  callback(err2, zipfile);
37975
37975
  });
37976
37976
  });
@@ -37987,7 +37987,7 @@ var require_yauzl = __commonJS({
37987
37987
  if (options.validateEntrySizes == null) options.validateEntrySizes = true;
37988
37988
  if (options.strictFileNames == null) options.strictFileNames = false;
37989
37989
  if (callback == null) callback = defaultCallback;
37990
- fs.fstat(fd, function(err, stats) {
37990
+ fs2.fstat(fd, function(err, stats) {
37991
37991
  if (err) return callback(err);
37992
37992
  var reader = fd_slicer.createFromFd(fd, { autoClose: true });
37993
37993
  fromRandomAccessReader(reader, stats.size, options, callback);
@@ -38568,7 +38568,7 @@ var require_extract_zip = __commonJS({
38568
38568
  "../../node_modules/.pnpm/extract-zip@2.0.1/node_modules/extract-zip/index.js"(exports, module) {
38569
38569
  "use strict";
38570
38570
  var debug = require_src()("extract-zip");
38571
- var { createWriteStream: createWriteStream2, promises: fs } = __require("fs");
38571
+ var { createWriteStream: createWriteStream2, promises: fs2 } = __require("fs");
38572
38572
  var getStream = require_get_stream();
38573
38573
  var path4 = __require("path");
38574
38574
  var { promisify: promisify14 } = __require("util");
@@ -38609,8 +38609,8 @@ var require_extract_zip = __commonJS({
38609
38609
  }
38610
38610
  const destDir = path4.dirname(path4.join(this.opts.dir, entry.fileName));
38611
38611
  try {
38612
- await fs.mkdir(destDir, { recursive: true });
38613
- const canonicalDestDir = await fs.realpath(destDir);
38612
+ await fs2.mkdir(destDir, { recursive: true });
38613
+ const canonicalDestDir = await fs2.realpath(destDir);
38614
38614
  const relativeDestDir = path4.relative(this.opts.dir, canonicalDestDir);
38615
38615
  if (relativeDestDir.split(path4.sep).includes("..")) {
38616
38616
  throw new Error(`Out of bound path "${canonicalDestDir}" found while processing file ${entry.fileName}`);
@@ -38654,14 +38654,14 @@ var require_extract_zip = __commonJS({
38654
38654
  mkdirOptions.mode = procMode;
38655
38655
  }
38656
38656
  debug("mkdir", { dir: destDir, ...mkdirOptions });
38657
- await fs.mkdir(destDir, mkdirOptions);
38657
+ await fs2.mkdir(destDir, mkdirOptions);
38658
38658
  if (isDir) return;
38659
38659
  debug("opening read stream", dest);
38660
38660
  const readStream = await promisify14(this.zipfile.openReadStream.bind(this.zipfile))(entry);
38661
38661
  if (symlink) {
38662
38662
  const link = await getStream(readStream);
38663
38663
  debug("creating symlink", link, dest);
38664
- await fs.symlink(link, dest);
38664
+ await fs2.symlink(link, dest);
38665
38665
  } else {
38666
38666
  await pipeline(readStream, createWriteStream2(dest, { mode: procMode }));
38667
38667
  }
@@ -38693,8 +38693,8 @@ var require_extract_zip = __commonJS({
38693
38693
  if (!path4.isAbsolute(opts.dir)) {
38694
38694
  throw new Error("Target directory is expected to be absolute");
38695
38695
  }
38696
- await fs.mkdir(opts.dir, { recursive: true });
38697
- opts.dir = await fs.realpath(opts.dir);
38696
+ await fs2.mkdir(opts.dir, { recursive: true });
38697
+ opts.dir = await fs2.realpath(opts.dir);
38698
38698
  return new Extractor(zipPath, opts).extract();
38699
38699
  };
38700
38700
  }
@@ -45553,14 +45553,14 @@ var require_parser = __commonJS({
45553
45553
  case "scalar":
45554
45554
  case "single-quoted-scalar":
45555
45555
  case "double-quoted-scalar": {
45556
- const fs = this.flowScalar(this.type);
45556
+ const fs2 = this.flowScalar(this.type);
45557
45557
  if (atNextItem || it.value) {
45558
- map2.items.push({ start, key: fs, sep: [] });
45558
+ map2.items.push({ start, key: fs2, sep: [] });
45559
45559
  this.onKeyLine = true;
45560
45560
  } else if (it.sep) {
45561
- this.stack.push(fs);
45561
+ this.stack.push(fs2);
45562
45562
  } else {
45563
- Object.assign(it, { key: fs, sep: [] });
45563
+ Object.assign(it, { key: fs2, sep: [] });
45564
45564
  this.onKeyLine = true;
45565
45565
  }
45566
45566
  return;
@@ -45688,13 +45688,13 @@ var require_parser = __commonJS({
45688
45688
  case "scalar":
45689
45689
  case "single-quoted-scalar":
45690
45690
  case "double-quoted-scalar": {
45691
- const fs = this.flowScalar(this.type);
45691
+ const fs2 = this.flowScalar(this.type);
45692
45692
  if (!it || it.value)
45693
- fc.items.push({ start: [], key: fs, sep: [] });
45693
+ fc.items.push({ start: [], key: fs2, sep: [] });
45694
45694
  else if (it.sep)
45695
- this.stack.push(fs);
45695
+ this.stack.push(fs2);
45696
45696
  else
45697
- Object.assign(it, { key: fs, sep: [] });
45697
+ Object.assign(it, { key: fs2, sep: [] });
45698
45698
  return;
45699
45699
  }
45700
45700
  case "flow-map-end":
@@ -49975,7 +49975,7 @@ var require_windowsPtyAgent = __commonJS({
49975
49975
  "use strict";
49976
49976
  Object.defineProperty(exports, "__esModule", { value: true });
49977
49977
  exports.argsToCommandLine = exports.WindowsPtyAgent = void 0;
49978
- var fs = __require("fs");
49978
+ var fs2 = __require("fs");
49979
49979
  var os3 = __require("os");
49980
49980
  var path4 = __require("path");
49981
49981
  var child_process_1 = __require("child_process");
@@ -50034,7 +50034,7 @@ var require_windowsPtyAgent = __commonJS({
50034
50034
  this._outSocket.on("connect", function() {
50035
50035
  _this._outSocket.emit("ready_datapipe");
50036
50036
  });
50037
- var inSocketFD = fs.openSync(term.conin, "w");
50037
+ var inSocketFD = fs2.openSync(term.conin, "w");
50038
50038
  this._inSocket = new net_1.Socket({
50039
50039
  fd: inSocketFD,
50040
50040
  readable: false,
@@ -50468,7 +50468,7 @@ var require_unixTerminal = __commonJS({
50468
50468
  })();
50469
50469
  Object.defineProperty(exports, "__esModule", { value: true });
50470
50470
  exports.UnixTerminal = void 0;
50471
- var fs = __require("fs");
50471
+ var fs2 = __require("fs");
50472
50472
  var path4 = __require("path");
50473
50473
  var tty = __require("tty");
50474
50474
  var terminal_1 = require_terminal();
@@ -50731,7 +50731,7 @@ var require_unixTerminal = __commonJS({
50731
50731
  return;
50732
50732
  }
50733
50733
  var task = this._writeQueue[0];
50734
- fs.write(this._fd, task.buffer, task.offset, function(err, written) {
50734
+ fs2.write(this._fd, task.buffer, task.offset, function(err, written) {
50735
50735
  if (err) {
50736
50736
  if ("code" in err && err.code === "EAGAIN") {
50737
50737
  _this._writeImmediate = setImmediate(function() {
@@ -50793,7 +50793,8 @@ var require_lib = __commonJS({
50793
50793
  import { EventEmitter as EventEmitter17 } from "events";
50794
50794
  import * as os2 from "os";
50795
50795
  import * as path from "path";
50796
- import { existsSync as existsSync17, chmodSync } from "node:fs";
50796
+ import * as fs from "node:fs";
50797
+ import { createRequire } from "node:module";
50797
50798
  import { join as join22, dirname as dirname7 } from "node:path";
50798
50799
  function getNativePrebuildName() {
50799
50800
  const platform3 = process.platform === "darwin" ? "darwin" : process.platform === "linux" ? "linux" : process.platform === "win32" ? "win32" : "unknown";
@@ -50802,9 +50803,9 @@ function getNativePrebuildName() {
50802
50803
  }
50803
50804
  function findInstalledNodePtyNativeDir() {
50804
50805
  try {
50805
- const packageJsonPath = __require.resolve("node-pty/package.json");
50806
+ const packageJsonPath = require2.resolve("node-pty/package.json");
50806
50807
  const nativeDir = join22(dirname7(packageJsonPath), "prebuilds", getNativePrebuildName());
50807
- return existsSync17(join22(nativeDir, "pty.node")) ? nativeDir : null;
50808
+ return fs.existsSync(join22(nativeDir, "pty.node")) ? nativeDir : null;
50808
50809
  } catch {
50809
50810
  return null;
50810
50811
  }
@@ -50830,12 +50831,11 @@ function ensureNodePtyNativePermissions() {
50830
50831
  const helperPath = join22(nativeDir, "spawn-helper");
50831
50832
  const nativeModulePath = join22(nativeDir, "pty.node");
50832
50833
  try {
50833
- if (existsSync17(helperPath)) {
50834
- chmodSync(helperPath, 493);
50835
- }
50836
- if (existsSync17(nativeModulePath)) {
50837
- chmodSync(nativeModulePath, 493);
50838
- }
50834
+ fs.chmodSync(helperPath, 493);
50835
+ } catch {
50836
+ }
50837
+ try {
50838
+ fs.chmodSync(nativeModulePath, 493);
50839
50839
  } catch (err) {
50840
50840
  console.warn("[terminal] Failed to repair node-pty native permissions:", {
50841
50841
  nativeDir,
@@ -50848,18 +50848,19 @@ function findStagedNativeDir() {
50848
50848
  const prebuildName = getNativePrebuildName();
50849
50849
  if (process.env.FUSION_RUNTIME_DIR) {
50850
50850
  const envPath = join22(process.env.FUSION_RUNTIME_DIR, prebuildName);
50851
- if (existsSync17(join22(envPath, "pty.node"))) {
50851
+ if (fs.existsSync(join22(envPath, "pty.node"))) {
50852
50852
  return envPath;
50853
50853
  }
50854
50854
  }
50855
50855
  const execDir = dirname7(process.execPath);
50856
50856
  const nextToBinary = join22(execDir, "runtime", prebuildName);
50857
- if (existsSync17(join22(nextToBinary, "pty.node"))) {
50857
+ if (fs.existsSync(join22(nextToBinary, "pty.node"))) {
50858
50858
  return nextToBinary;
50859
50859
  }
50860
50860
  return null;
50861
50861
  }
50862
50862
  async function loadPtyModule() {
50863
+ ensureNodePtyNativePermissions();
50863
50864
  if (ptyModule) {
50864
50865
  return ptyModule;
50865
50866
  }
@@ -50874,7 +50875,7 @@ async function loadPtyModule() {
50874
50875
  }
50875
50876
  process.env.FUSION_NATIVE_ASSETS_PATH = nativeDir;
50876
50877
  const nativePath = join22(nativeDir, "pty.node");
50877
- if (existsSync17(nativePath)) {
50878
+ if (fs.existsSync(nativePath)) {
50878
50879
  try {
50879
50880
  const nativeModule = { exports: {} };
50880
50881
  process.dlopen(nativeModule, nativePath);
@@ -50886,7 +50887,6 @@ async function loadPtyModule() {
50886
50887
  }
50887
50888
  }
50888
50889
  try {
50889
- ensureNodePtyNativePermissions();
50890
50890
  const mod = await Promise.resolve().then(() => __toESM(require_lib(), 1));
50891
50891
  ptyModule = mod;
50892
50892
  return ptyModule;
@@ -50912,13 +50912,14 @@ function getTerminalService(projectRoot, maxSessions) {
50912
50912
  terminalServices.set(resolvedRoot, service);
50913
50913
  return service;
50914
50914
  }
50915
- var isBunBinary, ptyModule, ptyLoadError, MAX_SCROLLBACK_SIZE, MIN_MAX_SESSIONS, MAX_MAX_SESSIONS, DEFAULT_MAX_SESSIONS, OUTPUT_THROTTLE_MS, OUTPUT_BATCH_SIZE, STALE_SESSION_THRESHOLD_MS, SESSION_ID_PATTERN, ALLOWED_SHELL_PATHS, STRIP_ENV_VARS, TerminalService, terminalServices;
50915
+ var isBunBinary, ptyModule, ptyLoadError, require2, MAX_SCROLLBACK_SIZE, MIN_MAX_SESSIONS, MAX_MAX_SESSIONS, DEFAULT_MAX_SESSIONS, OUTPUT_THROTTLE_MS, OUTPUT_BATCH_SIZE, STALE_SESSION_THRESHOLD_MS, SESSION_ID_PATTERN, ALLOWED_SHELL_PATHS, STRIP_ENV_VARS, TerminalService, terminalServices;
50916
50916
  var init_terminal_service = __esm({
50917
50917
  "../dashboard/src/terminal-service.ts"() {
50918
50918
  "use strict";
50919
50919
  isBunBinary = typeof Bun !== "undefined" && !!Bun.embeddedFiles;
50920
50920
  ptyModule = null;
50921
50921
  ptyLoadError = null;
50922
+ require2 = createRequire(import.meta.url);
50922
50923
  MAX_SCROLLBACK_SIZE = 5e4;
50923
50924
  MIN_MAX_SESSIONS = 1;
50924
50925
  MAX_MAX_SESSIONS = 100;
@@ -51008,13 +51009,13 @@ var init_terminal_service = __esm({
51008
51009
  const normalizedUserShell = this.isWindows ? userShell.toLowerCase() : userShell;
51009
51010
  for (const allowed of allowedShells) {
51010
51011
  const normalizedAllowed = this.isWindows ? allowed.toLowerCase() : allowed;
51011
- if (normalizedAllowed === normalizedUserShell && existsSync17(allowed)) {
51012
+ if (normalizedAllowed === normalizedUserShell && fs.existsSync(allowed)) {
51012
51013
  return { shell: allowed, args: getShellArgs(allowed) };
51013
51014
  }
51014
51015
  }
51015
51016
  }
51016
51017
  for (const shell of allowedShells) {
51017
- if (existsSync17(shell)) {
51018
+ if (fs.existsSync(shell)) {
51018
51019
  return { shell, args: getShellArgs(shell) };
51019
51020
  }
51020
51021
  }
@@ -51035,7 +51036,7 @@ var init_terminal_service = __esm({
51035
51036
  detectedShell,
51036
51037
  detectedArgs,
51037
51038
  envShell: process.env.SHELL ?? null,
51038
- allowedShells: this.getAllowedShells().filter((shellPath) => existsSync17(shellPath))
51039
+ allowedShells: this.getAllowedShells().filter((shellPath) => fs.existsSync(shellPath))
51039
51040
  };
51040
51041
  }
51041
51042
  /**
@@ -51056,7 +51057,7 @@ var init_terminal_service = __esm({
51056
51057
  return this.projectRoot;
51057
51058
  }
51058
51059
  try {
51059
- const stat11 = await import("node:fs/promises").then((fs) => fs.stat(cwd));
51060
+ const stat11 = await import("node:fs/promises").then((fs2) => fs2.stat(cwd));
51060
51061
  if (stat11.isDirectory()) {
51061
51062
  return cwd;
51062
51063
  }
@@ -51219,7 +51220,7 @@ var init_terminal_service = __esm({
51219
51220
  addSpawnAttempt(shell, [], "retry-without-login");
51220
51221
  }
51221
51222
  for (const allowedShell of this.getAllowedShells()) {
51222
- if (allowedShell === shell || !existsSync17(allowedShell)) continue;
51223
+ if (allowedShell === shell || !fs.existsSync(allowedShell)) continue;
51223
51224
  const shellName = path.basename(allowedShell).toLowerCase().replace(".exe", "");
51224
51225
  const fallbackArgs = shellName === "bash" || shellName === "zsh" ? [] : [];
51225
51226
  addSpawnAttempt(allowedShell, fallbackArgs, "allowed-fallback");
@@ -65286,7 +65287,7 @@ async function aiMergeTask(store, rootDir, taskId, options = {}) {
65286
65287
  } catch (error) {
65287
65288
  if (error.name === "VerificationError") {
65288
65289
  const verificationErr = error;
65289
- const maxFixRetries = Math.min(settings.verificationFixRetries ?? 1, 3);
65290
+ const maxFixRetries = Math.min(settings.verificationFixRetries ?? 3, 3);
65290
65291
  if (maxFixRetries > 0 && (verificationErr.verificationResult.testResult || verificationErr.verificationResult.buildResult)) {
65291
65292
  mergerLog.log(`${taskId}: deterministic verification failed \u2014 attempting in-merge fix (up to ${maxFixRetries} attempts)`);
65292
65293
  await store.logEntry(taskId, `Verification failed during merge \u2014 attempting in-merge fix (up to ${maxFixRetries} attempts)`);
@@ -65331,7 +65332,7 @@ async function aiMergeTask(store, rootDir, taskId, options = {}) {
65331
65332
  throw error;
65332
65333
  }
65333
65334
  if (error.message?.includes("Build verification failed")) {
65334
- const maxFixRetries = Math.min(settings.verificationFixRetries ?? 1, 3);
65335
+ const maxFixRetries = Math.min(settings.verificationFixRetries ?? 3, 3);
65335
65336
  if (maxFixRetries > 0 && (effectiveTestCommand || effectiveBuildCommand)) {
65336
65337
  mergerLog.log(`${taskId}: build verification failed \u2014 attempting in-merge fix`);
65337
65338
  await store.logEntry(taskId, `Build verification failed during merge \u2014 attempting in-merge fix`);
@@ -77329,8 +77330,13 @@ ${taskDetail.prompt}` : "No PROMPT.md available.",
77329
77330
  this.assignedListener = async (agent, taskId) => {
77330
77331
  if (!this.running) return;
77331
77332
  try {
77332
- if (!isHeartbeatManaged(agent) || !isTickableState(agent.state)) {
77333
- heartbeatLog.log(`Assignment trigger skipped for ${agent.id} (state=${agent.state})`);
77333
+ if (!isHeartbeatManaged(agent)) {
77334
+ heartbeatLog.log(`Assignment trigger skipped for ${agent.id} (ephemeral/internal)`);
77335
+ return;
77336
+ }
77337
+ const runtimeConfig = agent.runtimeConfig ?? {};
77338
+ if (runtimeConfig.enabled === false) {
77339
+ heartbeatLog.log(`Assignment trigger skipped for ${agent.id} (disabled)`);
77334
77340
  return;
77335
77341
  }
77336
77342
  const activeRun = await this.store.getActiveHeartbeatRun(agent.id);
@@ -77789,6 +77795,10 @@ var init_self_healing = __esm({
77789
77795
  const result = await readLog("HEAD");
77790
77796
  stdout = result.stdout;
77791
77797
  }
77798
+ if (!stdout.trim() && task.baseCommitSha) {
77799
+ const result = await readLog("HEAD");
77800
+ stdout = result.stdout;
77801
+ }
77792
77802
  const firstLine = stdout.trim().split("\n").find(Boolean);
77793
77803
  if (!firstLine) return null;
77794
77804
  const [sha, subject] = firstLine.split("");
@@ -79650,10 +79660,10 @@ var init_in_process_runtime = __esm({
79650
79660
  this.taskStore
79651
79661
  );
79652
79662
  this.triggerScheduler.start();
79653
- const isTickable = (agent) => !isEphemeralAgent(agent) && (agent.state === "active" || agent.state === "running");
79663
+ const isHeartbeatEnabledAgent = (agent) => !isEphemeralAgent(agent) && agent.runtimeConfig?.enabled !== false;
79654
79664
  this.agentCreatedListener = (agent) => {
79655
79665
  if (!this.triggerScheduler) return;
79656
- if (!isTickable(agent)) return;
79666
+ if (!isHeartbeatEnabledAgent(agent)) return;
79657
79667
  const rc = agent.runtimeConfig;
79658
79668
  this.triggerScheduler.registerAgent(agent.id, {
79659
79669
  heartbeatIntervalMs: rc?.heartbeatIntervalMs,
@@ -79664,9 +79674,9 @@ var init_in_process_runtime = __esm({
79664
79674
  this.agentStore.on("agent:created", this.agentCreatedListener);
79665
79675
  this.agentUpdatedListener = (agent) => {
79666
79676
  if (!this.triggerScheduler) return;
79667
- if (!isTickable(agent)) {
79677
+ if (!isHeartbeatEnabledAgent(agent)) {
79668
79678
  this.triggerScheduler.unregisterAgent(agent.id);
79669
- runtimeLog.log(`Unregistered agent ${agent.id} from heartbeat triggers (state=${agent.state})`);
79679
+ runtimeLog.log(`Unregistered agent ${agent.id} from heartbeat triggers`);
79670
79680
  return;
79671
79681
  }
79672
79682
  const rc = agent.runtimeConfig;
@@ -79674,7 +79684,7 @@ var init_in_process_runtime = __esm({
79674
79684
  heartbeatIntervalMs: rc?.heartbeatIntervalMs,
79675
79685
  maxConcurrentRuns: rc?.maxConcurrentRuns
79676
79686
  });
79677
- runtimeLog.log(`Re-registered agent ${agent.id} for heartbeat triggers (state=${agent.state})`);
79687
+ runtimeLog.log(`Re-registered agent ${agent.id} for heartbeat triggers`);
79678
79688
  };
79679
79689
  this.agentStore.on("agent:updated", this.agentUpdatedListener);
79680
79690
  this.ephemeralTerminationListener = (agentId, from, to) => {
@@ -79709,7 +79719,7 @@ var init_in_process_runtime = __esm({
79709
79719
  const agents = await this.agentStore.listAgents();
79710
79720
  let registeredCount = 0;
79711
79721
  for (const agent of agents) {
79712
- if (!isTickable(agent)) continue;
79722
+ if (!isHeartbeatEnabledAgent(agent)) continue;
79713
79723
  const rc = agent.runtimeConfig;
79714
79724
  this.triggerScheduler.registerAgent(agent.id, {
79715
79725
  heartbeatIntervalMs: rc?.heartbeatIntervalMs,
@@ -88192,13 +88202,13 @@ var require_readdir_glob = __commonJS({
88192
88202
  "../../node_modules/.pnpm/readdir-glob@1.1.3/node_modules/readdir-glob/index.js"(exports, module) {
88193
88203
  "use strict";
88194
88204
  module.exports = readdirGlob;
88195
- var fs = __require("fs");
88205
+ var fs2 = __require("fs");
88196
88206
  var { EventEmitter: EventEmitter33 } = __require("events");
88197
88207
  var { Minimatch } = require_minimatch();
88198
88208
  var { resolve: resolve29 } = __require("path");
88199
88209
  function readdir11(dir2, strict) {
88200
88210
  return new Promise((resolve30, reject2) => {
88201
- fs.readdir(dir2, { withFileTypes: true }, (err, files) => {
88211
+ fs2.readdir(dir2, { withFileTypes: true }, (err, files) => {
88202
88212
  if (err) {
88203
88213
  switch (err.code) {
88204
88214
  case "ENOTDIR":
@@ -88231,7 +88241,7 @@ var require_readdir_glob = __commonJS({
88231
88241
  }
88232
88242
  function stat11(file, followSymlinks) {
88233
88243
  return new Promise((resolve30, reject2) => {
88234
- const statFunc = followSymlinks ? fs.stat : fs.lstat;
88244
+ const statFunc = followSymlinks ? fs2.stat : fs2.lstat;
88235
88245
  statFunc(file, (err, stats) => {
88236
88246
  if (err) {
88237
88247
  switch (err.code) {
@@ -90294,54 +90304,54 @@ var require_polyfills = __commonJS({
90294
90304
  }
90295
90305
  var chdir;
90296
90306
  module.exports = patch;
90297
- function patch(fs) {
90307
+ function patch(fs2) {
90298
90308
  if (constants2.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
90299
- patchLchmod(fs);
90300
- }
90301
- if (!fs.lutimes) {
90302
- patchLutimes(fs);
90303
- }
90304
- fs.chown = chownFix(fs.chown);
90305
- fs.fchown = chownFix(fs.fchown);
90306
- fs.lchown = chownFix(fs.lchown);
90307
- fs.chmod = chmodFix(fs.chmod);
90308
- fs.fchmod = chmodFix(fs.fchmod);
90309
- fs.lchmod = chmodFix(fs.lchmod);
90310
- fs.chownSync = chownFixSync(fs.chownSync);
90311
- fs.fchownSync = chownFixSync(fs.fchownSync);
90312
- fs.lchownSync = chownFixSync(fs.lchownSync);
90313
- fs.chmodSync = chmodFixSync(fs.chmodSync);
90314
- fs.fchmodSync = chmodFixSync(fs.fchmodSync);
90315
- fs.lchmodSync = chmodFixSync(fs.lchmodSync);
90316
- fs.stat = statFix(fs.stat);
90317
- fs.fstat = statFix(fs.fstat);
90318
- fs.lstat = statFix(fs.lstat);
90319
- fs.statSync = statFixSync(fs.statSync);
90320
- fs.fstatSync = statFixSync(fs.fstatSync);
90321
- fs.lstatSync = statFixSync(fs.lstatSync);
90322
- if (fs.chmod && !fs.lchmod) {
90323
- fs.lchmod = function(path4, mode, cb) {
90309
+ patchLchmod(fs2);
90310
+ }
90311
+ if (!fs2.lutimes) {
90312
+ patchLutimes(fs2);
90313
+ }
90314
+ fs2.chown = chownFix(fs2.chown);
90315
+ fs2.fchown = chownFix(fs2.fchown);
90316
+ fs2.lchown = chownFix(fs2.lchown);
90317
+ fs2.chmod = chmodFix(fs2.chmod);
90318
+ fs2.fchmod = chmodFix(fs2.fchmod);
90319
+ fs2.lchmod = chmodFix(fs2.lchmod);
90320
+ fs2.chownSync = chownFixSync(fs2.chownSync);
90321
+ fs2.fchownSync = chownFixSync(fs2.fchownSync);
90322
+ fs2.lchownSync = chownFixSync(fs2.lchownSync);
90323
+ fs2.chmodSync = chmodFixSync(fs2.chmodSync);
90324
+ fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
90325
+ fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
90326
+ fs2.stat = statFix(fs2.stat);
90327
+ fs2.fstat = statFix(fs2.fstat);
90328
+ fs2.lstat = statFix(fs2.lstat);
90329
+ fs2.statSync = statFixSync(fs2.statSync);
90330
+ fs2.fstatSync = statFixSync(fs2.fstatSync);
90331
+ fs2.lstatSync = statFixSync(fs2.lstatSync);
90332
+ if (fs2.chmod && !fs2.lchmod) {
90333
+ fs2.lchmod = function(path4, mode, cb) {
90324
90334
  if (cb) process.nextTick(cb);
90325
90335
  };
90326
- fs.lchmodSync = function() {
90336
+ fs2.lchmodSync = function() {
90327
90337
  };
90328
90338
  }
90329
- if (fs.chown && !fs.lchown) {
90330
- fs.lchown = function(path4, uid, gid, cb) {
90339
+ if (fs2.chown && !fs2.lchown) {
90340
+ fs2.lchown = function(path4, uid, gid, cb) {
90331
90341
  if (cb) process.nextTick(cb);
90332
90342
  };
90333
- fs.lchownSync = function() {
90343
+ fs2.lchownSync = function() {
90334
90344
  };
90335
90345
  }
90336
90346
  if (platform3 === "win32") {
90337
- fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
90347
+ fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : (function(fs$rename) {
90338
90348
  function rename6(from, to, cb) {
90339
90349
  var start = Date.now();
90340
90350
  var backoff = 0;
90341
90351
  fs$rename(from, to, function CB(er) {
90342
90352
  if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
90343
90353
  setTimeout(function() {
90344
- fs.stat(to, function(stater, st) {
90354
+ fs2.stat(to, function(stater, st) {
90345
90355
  if (stater && stater.code === "ENOENT")
90346
90356
  fs$rename(from, to, CB);
90347
90357
  else
@@ -90357,9 +90367,9 @@ var require_polyfills = __commonJS({
90357
90367
  }
90358
90368
  if (Object.setPrototypeOf) Object.setPrototypeOf(rename6, fs$rename);
90359
90369
  return rename6;
90360
- })(fs.rename);
90370
+ })(fs2.rename);
90361
90371
  }
90362
- fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
90372
+ fs2.read = typeof fs2.read !== "function" ? fs2.read : (function(fs$read) {
90363
90373
  function read(fd, buffer, offset, length, position, callback_) {
90364
90374
  var callback;
90365
90375
  if (callback_ && typeof callback_ === "function") {
@@ -90367,22 +90377,22 @@ var require_polyfills = __commonJS({
90367
90377
  callback = function(er, _2, __) {
90368
90378
  if (er && er.code === "EAGAIN" && eagCounter < 10) {
90369
90379
  eagCounter++;
90370
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
90380
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
90371
90381
  }
90372
90382
  callback_.apply(this, arguments);
90373
90383
  };
90374
90384
  }
90375
- return fs$read.call(fs, fd, buffer, offset, length, position, callback);
90385
+ return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
90376
90386
  }
90377
90387
  if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
90378
90388
  return read;
90379
- })(fs.read);
90380
- fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : /* @__PURE__ */ (function(fs$readSync) {
90389
+ })(fs2.read);
90390
+ fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : /* @__PURE__ */ (function(fs$readSync) {
90381
90391
  return function(fd, buffer, offset, length, position) {
90382
90392
  var eagCounter = 0;
90383
90393
  while (true) {
90384
90394
  try {
90385
- return fs$readSync.call(fs, fd, buffer, offset, length, position);
90395
+ return fs$readSync.call(fs2, fd, buffer, offset, length, position);
90386
90396
  } catch (er) {
90387
90397
  if (er.code === "EAGAIN" && eagCounter < 10) {
90388
90398
  eagCounter++;
@@ -90392,10 +90402,10 @@ var require_polyfills = __commonJS({
90392
90402
  }
90393
90403
  }
90394
90404
  };
90395
- })(fs.readSync);
90396
- function patchLchmod(fs2) {
90397
- fs2.lchmod = function(path4, mode, callback) {
90398
- fs2.open(
90405
+ })(fs2.readSync);
90406
+ function patchLchmod(fs3) {
90407
+ fs3.lchmod = function(path4, mode, callback) {
90408
+ fs3.open(
90399
90409
  path4,
90400
90410
  constants2.O_WRONLY | constants2.O_SYMLINK,
90401
90411
  mode,
@@ -90404,80 +90414,80 @@ var require_polyfills = __commonJS({
90404
90414
  if (callback) callback(err);
90405
90415
  return;
90406
90416
  }
90407
- fs2.fchmod(fd, mode, function(err2) {
90408
- fs2.close(fd, function(err22) {
90417
+ fs3.fchmod(fd, mode, function(err2) {
90418
+ fs3.close(fd, function(err22) {
90409
90419
  if (callback) callback(err2 || err22);
90410
90420
  });
90411
90421
  });
90412
90422
  }
90413
90423
  );
90414
90424
  };
90415
- fs2.lchmodSync = function(path4, mode) {
90416
- var fd = fs2.openSync(path4, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
90425
+ fs3.lchmodSync = function(path4, mode) {
90426
+ var fd = fs3.openSync(path4, constants2.O_WRONLY | constants2.O_SYMLINK, mode);
90417
90427
  var threw = true;
90418
90428
  var ret;
90419
90429
  try {
90420
- ret = fs2.fchmodSync(fd, mode);
90430
+ ret = fs3.fchmodSync(fd, mode);
90421
90431
  threw = false;
90422
90432
  } finally {
90423
90433
  if (threw) {
90424
90434
  try {
90425
- fs2.closeSync(fd);
90435
+ fs3.closeSync(fd);
90426
90436
  } catch (er) {
90427
90437
  }
90428
90438
  } else {
90429
- fs2.closeSync(fd);
90439
+ fs3.closeSync(fd);
90430
90440
  }
90431
90441
  }
90432
90442
  return ret;
90433
90443
  };
90434
90444
  }
90435
- function patchLutimes(fs2) {
90436
- if (constants2.hasOwnProperty("O_SYMLINK") && fs2.futimes) {
90437
- fs2.lutimes = function(path4, at, mt, cb) {
90438
- fs2.open(path4, constants2.O_SYMLINK, function(er, fd) {
90445
+ function patchLutimes(fs3) {
90446
+ if (constants2.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
90447
+ fs3.lutimes = function(path4, at, mt, cb) {
90448
+ fs3.open(path4, constants2.O_SYMLINK, function(er, fd) {
90439
90449
  if (er) {
90440
90450
  if (cb) cb(er);
90441
90451
  return;
90442
90452
  }
90443
- fs2.futimes(fd, at, mt, function(er2) {
90444
- fs2.close(fd, function(er22) {
90453
+ fs3.futimes(fd, at, mt, function(er2) {
90454
+ fs3.close(fd, function(er22) {
90445
90455
  if (cb) cb(er2 || er22);
90446
90456
  });
90447
90457
  });
90448
90458
  });
90449
90459
  };
90450
- fs2.lutimesSync = function(path4, at, mt) {
90451
- var fd = fs2.openSync(path4, constants2.O_SYMLINK);
90460
+ fs3.lutimesSync = function(path4, at, mt) {
90461
+ var fd = fs3.openSync(path4, constants2.O_SYMLINK);
90452
90462
  var ret;
90453
90463
  var threw = true;
90454
90464
  try {
90455
- ret = fs2.futimesSync(fd, at, mt);
90465
+ ret = fs3.futimesSync(fd, at, mt);
90456
90466
  threw = false;
90457
90467
  } finally {
90458
90468
  if (threw) {
90459
90469
  try {
90460
- fs2.closeSync(fd);
90470
+ fs3.closeSync(fd);
90461
90471
  } catch (er) {
90462
90472
  }
90463
90473
  } else {
90464
- fs2.closeSync(fd);
90474
+ fs3.closeSync(fd);
90465
90475
  }
90466
90476
  }
90467
90477
  return ret;
90468
90478
  };
90469
- } else if (fs2.futimes) {
90470
- fs2.lutimes = function(_a, _b, _c, cb) {
90479
+ } else if (fs3.futimes) {
90480
+ fs3.lutimes = function(_a, _b, _c, cb) {
90471
90481
  if (cb) process.nextTick(cb);
90472
90482
  };
90473
- fs2.lutimesSync = function() {
90483
+ fs3.lutimesSync = function() {
90474
90484
  };
90475
90485
  }
90476
90486
  }
90477
90487
  function chmodFix(orig) {
90478
90488
  if (!orig) return orig;
90479
90489
  return function(target, mode, cb) {
90480
- return orig.call(fs, target, mode, function(er) {
90490
+ return orig.call(fs2, target, mode, function(er) {
90481
90491
  if (chownErOk(er)) er = null;
90482
90492
  if (cb) cb.apply(this, arguments);
90483
90493
  });
@@ -90487,7 +90497,7 @@ var require_polyfills = __commonJS({
90487
90497
  if (!orig) return orig;
90488
90498
  return function(target, mode) {
90489
90499
  try {
90490
- return orig.call(fs, target, mode);
90500
+ return orig.call(fs2, target, mode);
90491
90501
  } catch (er) {
90492
90502
  if (!chownErOk(er)) throw er;
90493
90503
  }
@@ -90496,7 +90506,7 @@ var require_polyfills = __commonJS({
90496
90506
  function chownFix(orig) {
90497
90507
  if (!orig) return orig;
90498
90508
  return function(target, uid, gid, cb) {
90499
- return orig.call(fs, target, uid, gid, function(er) {
90509
+ return orig.call(fs2, target, uid, gid, function(er) {
90500
90510
  if (chownErOk(er)) er = null;
90501
90511
  if (cb) cb.apply(this, arguments);
90502
90512
  });
@@ -90506,7 +90516,7 @@ var require_polyfills = __commonJS({
90506
90516
  if (!orig) return orig;
90507
90517
  return function(target, uid, gid) {
90508
90518
  try {
90509
- return orig.call(fs, target, uid, gid);
90519
+ return orig.call(fs2, target, uid, gid);
90510
90520
  } catch (er) {
90511
90521
  if (!chownErOk(er)) throw er;
90512
90522
  }
@@ -90526,13 +90536,13 @@ var require_polyfills = __commonJS({
90526
90536
  }
90527
90537
  if (cb) cb.apply(this, arguments);
90528
90538
  }
90529
- return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
90539
+ return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
90530
90540
  };
90531
90541
  }
90532
90542
  function statFixSync(orig) {
90533
90543
  if (!orig) return orig;
90534
90544
  return function(target, options) {
90535
- var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
90545
+ var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
90536
90546
  if (stats) {
90537
90547
  if (stats.uid < 0) stats.uid += 4294967296;
90538
90548
  if (stats.gid < 0) stats.gid += 4294967296;
@@ -90562,7 +90572,7 @@ var require_legacy_streams = __commonJS({
90562
90572
  "use strict";
90563
90573
  var Stream = __require("stream").Stream;
90564
90574
  module.exports = legacy;
90565
- function legacy(fs) {
90575
+ function legacy(fs2) {
90566
90576
  return {
90567
90577
  ReadStream,
90568
90578
  WriteStream
@@ -90605,7 +90615,7 @@ var require_legacy_streams = __commonJS({
90605
90615
  });
90606
90616
  return;
90607
90617
  }
90608
- fs.open(this.path, this.flags, this.mode, function(err, fd) {
90618
+ fs2.open(this.path, this.flags, this.mode, function(err, fd) {
90609
90619
  if (err) {
90610
90620
  self2.emit("error", err);
90611
90621
  self2.readable = false;
@@ -90644,7 +90654,7 @@ var require_legacy_streams = __commonJS({
90644
90654
  this.busy = false;
90645
90655
  this._queue = [];
90646
90656
  if (this.fd === null) {
90647
- this._open = fs.open;
90657
+ this._open = fs2.open;
90648
90658
  this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
90649
90659
  this.flush();
90650
90660
  }
@@ -90680,7 +90690,7 @@ var require_clone = __commonJS({
90680
90690
  var require_graceful_fs = __commonJS({
90681
90691
  "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module) {
90682
90692
  "use strict";
90683
- var fs = __require("fs");
90693
+ var fs2 = __require("fs");
90684
90694
  var polyfills = require_polyfills();
90685
90695
  var legacy = require_legacy_streams();
90686
90696
  var clone = require_clone();
@@ -90712,12 +90722,12 @@ var require_graceful_fs = __commonJS({
90712
90722
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
90713
90723
  console.error(m);
90714
90724
  };
90715
- if (!fs[gracefulQueue]) {
90725
+ if (!fs2[gracefulQueue]) {
90716
90726
  queue2 = global[gracefulQueue] || [];
90717
- publishQueue(fs, queue2);
90718
- fs.close = (function(fs$close) {
90727
+ publishQueue(fs2, queue2);
90728
+ fs2.close = (function(fs$close) {
90719
90729
  function close(fd, cb) {
90720
- return fs$close.call(fs, fd, function(err) {
90730
+ return fs$close.call(fs2, fd, function(err) {
90721
90731
  if (!err) {
90722
90732
  resetQueue();
90723
90733
  }
@@ -90729,40 +90739,40 @@ var require_graceful_fs = __commonJS({
90729
90739
  value: fs$close
90730
90740
  });
90731
90741
  return close;
90732
- })(fs.close);
90733
- fs.closeSync = (function(fs$closeSync) {
90742
+ })(fs2.close);
90743
+ fs2.closeSync = (function(fs$closeSync) {
90734
90744
  function closeSync(fd) {
90735
- fs$closeSync.apply(fs, arguments);
90745
+ fs$closeSync.apply(fs2, arguments);
90736
90746
  resetQueue();
90737
90747
  }
90738
90748
  Object.defineProperty(closeSync, previousSymbol, {
90739
90749
  value: fs$closeSync
90740
90750
  });
90741
90751
  return closeSync;
90742
- })(fs.closeSync);
90752
+ })(fs2.closeSync);
90743
90753
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
90744
90754
  process.on("exit", function() {
90745
- debug(fs[gracefulQueue]);
90746
- __require("assert").equal(fs[gracefulQueue].length, 0);
90755
+ debug(fs2[gracefulQueue]);
90756
+ __require("assert").equal(fs2[gracefulQueue].length, 0);
90747
90757
  });
90748
90758
  }
90749
90759
  }
90750
90760
  var queue2;
90751
90761
  if (!global[gracefulQueue]) {
90752
- publishQueue(global, fs[gracefulQueue]);
90753
- }
90754
- module.exports = patch(clone(fs));
90755
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs.__patched) {
90756
- module.exports = patch(fs);
90757
- fs.__patched = true;
90758
- }
90759
- function patch(fs2) {
90760
- polyfills(fs2);
90761
- fs2.gracefulify = patch;
90762
- fs2.createReadStream = createReadStream2;
90763
- fs2.createWriteStream = createWriteStream2;
90764
- var fs$readFile = fs2.readFile;
90765
- fs2.readFile = readFile24;
90762
+ publishQueue(global, fs2[gracefulQueue]);
90763
+ }
90764
+ module.exports = patch(clone(fs2));
90765
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
90766
+ module.exports = patch(fs2);
90767
+ fs2.__patched = true;
90768
+ }
90769
+ function patch(fs3) {
90770
+ polyfills(fs3);
90771
+ fs3.gracefulify = patch;
90772
+ fs3.createReadStream = createReadStream2;
90773
+ fs3.createWriteStream = createWriteStream2;
90774
+ var fs$readFile = fs3.readFile;
90775
+ fs3.readFile = readFile24;
90766
90776
  function readFile24(path4, options, cb) {
90767
90777
  if (typeof options === "function")
90768
90778
  cb = options, options = null;
@@ -90778,8 +90788,8 @@ var require_graceful_fs = __commonJS({
90778
90788
  });
90779
90789
  }
90780
90790
  }
90781
- var fs$writeFile = fs2.writeFile;
90782
- fs2.writeFile = writeFile16;
90791
+ var fs$writeFile = fs3.writeFile;
90792
+ fs3.writeFile = writeFile16;
90783
90793
  function writeFile16(path4, data, options, cb) {
90784
90794
  if (typeof options === "function")
90785
90795
  cb = options, options = null;
@@ -90795,9 +90805,9 @@ var require_graceful_fs = __commonJS({
90795
90805
  });
90796
90806
  }
90797
90807
  }
90798
- var fs$appendFile = fs2.appendFile;
90808
+ var fs$appendFile = fs3.appendFile;
90799
90809
  if (fs$appendFile)
90800
- fs2.appendFile = appendFile3;
90810
+ fs3.appendFile = appendFile3;
90801
90811
  function appendFile3(path4, data, options, cb) {
90802
90812
  if (typeof options === "function")
90803
90813
  cb = options, options = null;
@@ -90813,9 +90823,9 @@ var require_graceful_fs = __commonJS({
90813
90823
  });
90814
90824
  }
90815
90825
  }
90816
- var fs$copyFile = fs2.copyFile;
90826
+ var fs$copyFile = fs3.copyFile;
90817
90827
  if (fs$copyFile)
90818
- fs2.copyFile = copyFile;
90828
+ fs3.copyFile = copyFile;
90819
90829
  function copyFile(src, dest, flags, cb) {
90820
90830
  if (typeof flags === "function") {
90821
90831
  cb = flags;
@@ -90833,8 +90843,8 @@ var require_graceful_fs = __commonJS({
90833
90843
  });
90834
90844
  }
90835
90845
  }
90836
- var fs$readdir = fs2.readdir;
90837
- fs2.readdir = readdir11;
90846
+ var fs$readdir = fs3.readdir;
90847
+ fs3.readdir = readdir11;
90838
90848
  var noReaddirOptionVersions = /^v[0-5]\./;
90839
90849
  function readdir11(path4, options, cb) {
90840
90850
  if (typeof options === "function")
@@ -90875,21 +90885,21 @@ var require_graceful_fs = __commonJS({
90875
90885
  }
90876
90886
  }
90877
90887
  if (process.version.substr(0, 4) === "v0.8") {
90878
- var legStreams = legacy(fs2);
90888
+ var legStreams = legacy(fs3);
90879
90889
  ReadStream = legStreams.ReadStream;
90880
90890
  WriteStream = legStreams.WriteStream;
90881
90891
  }
90882
- var fs$ReadStream = fs2.ReadStream;
90892
+ var fs$ReadStream = fs3.ReadStream;
90883
90893
  if (fs$ReadStream) {
90884
90894
  ReadStream.prototype = Object.create(fs$ReadStream.prototype);
90885
90895
  ReadStream.prototype.open = ReadStream$open;
90886
90896
  }
90887
- var fs$WriteStream = fs2.WriteStream;
90897
+ var fs$WriteStream = fs3.WriteStream;
90888
90898
  if (fs$WriteStream) {
90889
90899
  WriteStream.prototype = Object.create(fs$WriteStream.prototype);
90890
90900
  WriteStream.prototype.open = WriteStream$open;
90891
90901
  }
90892
- Object.defineProperty(fs2, "ReadStream", {
90902
+ Object.defineProperty(fs3, "ReadStream", {
90893
90903
  get: function() {
90894
90904
  return ReadStream;
90895
90905
  },
@@ -90899,7 +90909,7 @@ var require_graceful_fs = __commonJS({
90899
90909
  enumerable: true,
90900
90910
  configurable: true
90901
90911
  });
90902
- Object.defineProperty(fs2, "WriteStream", {
90912
+ Object.defineProperty(fs3, "WriteStream", {
90903
90913
  get: function() {
90904
90914
  return WriteStream;
90905
90915
  },
@@ -90910,7 +90920,7 @@ var require_graceful_fs = __commonJS({
90910
90920
  configurable: true
90911
90921
  });
90912
90922
  var FileReadStream = ReadStream;
90913
- Object.defineProperty(fs2, "FileReadStream", {
90923
+ Object.defineProperty(fs3, "FileReadStream", {
90914
90924
  get: function() {
90915
90925
  return FileReadStream;
90916
90926
  },
@@ -90921,7 +90931,7 @@ var require_graceful_fs = __commonJS({
90921
90931
  configurable: true
90922
90932
  });
90923
90933
  var FileWriteStream = WriteStream;
90924
- Object.defineProperty(fs2, "FileWriteStream", {
90934
+ Object.defineProperty(fs3, "FileWriteStream", {
90925
90935
  get: function() {
90926
90936
  return FileWriteStream;
90927
90937
  },
@@ -90970,13 +90980,13 @@ var require_graceful_fs = __commonJS({
90970
90980
  });
90971
90981
  }
90972
90982
  function createReadStream2(path4, options) {
90973
- return new fs2.ReadStream(path4, options);
90983
+ return new fs3.ReadStream(path4, options);
90974
90984
  }
90975
90985
  function createWriteStream2(path4, options) {
90976
- return new fs2.WriteStream(path4, options);
90986
+ return new fs3.WriteStream(path4, options);
90977
90987
  }
90978
- var fs$open = fs2.open;
90979
- fs2.open = open;
90988
+ var fs$open = fs3.open;
90989
+ fs3.open = open;
90980
90990
  function open(path4, flags, mode, cb) {
90981
90991
  if (typeof mode === "function")
90982
90992
  cb = mode, mode = null;
@@ -90992,20 +91002,20 @@ var require_graceful_fs = __commonJS({
90992
91002
  });
90993
91003
  }
90994
91004
  }
90995
- return fs2;
91005
+ return fs3;
90996
91006
  }
90997
91007
  function enqueue(elem) {
90998
91008
  debug("ENQUEUE", elem[0].name, elem[1]);
90999
- fs[gracefulQueue].push(elem);
91009
+ fs2[gracefulQueue].push(elem);
91000
91010
  retry2();
91001
91011
  }
91002
91012
  var retryTimer;
91003
91013
  function resetQueue() {
91004
91014
  var now = Date.now();
91005
- for (var i = 0; i < fs[gracefulQueue].length; ++i) {
91006
- if (fs[gracefulQueue][i].length > 2) {
91007
- fs[gracefulQueue][i][3] = now;
91008
- fs[gracefulQueue][i][4] = now;
91015
+ for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
91016
+ if (fs2[gracefulQueue][i].length > 2) {
91017
+ fs2[gracefulQueue][i][3] = now;
91018
+ fs2[gracefulQueue][i][4] = now;
91009
91019
  }
91010
91020
  }
91011
91021
  retry2();
@@ -91013,9 +91023,9 @@ var require_graceful_fs = __commonJS({
91013
91023
  function retry2() {
91014
91024
  clearTimeout(retryTimer);
91015
91025
  retryTimer = void 0;
91016
- if (fs[gracefulQueue].length === 0)
91026
+ if (fs2[gracefulQueue].length === 0)
91017
91027
  return;
91018
- var elem = fs[gracefulQueue].shift();
91028
+ var elem = fs2[gracefulQueue].shift();
91019
91029
  var fn = elem[0];
91020
91030
  var args = elem[1];
91021
91031
  var err = elem[2];
@@ -91037,7 +91047,7 @@ var require_graceful_fs = __commonJS({
91037
91047
  debug("RETRY", fn.name, args);
91038
91048
  fn.apply(null, args.concat([startTime]));
91039
91049
  } else {
91040
- fs[gracefulQueue].push(elem);
91050
+ fs2[gracefulQueue].push(elem);
91041
91051
  }
91042
91052
  }
91043
91053
  if (retryTimer === void 0) {
@@ -106230,8 +106240,8 @@ var require_commonjs4 = __commonJS({
106230
106240
  *
106231
106241
  * @internal
106232
106242
  */
106233
- constructor(cwd = process.cwd(), pathImpl, sep6, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS } = {}) {
106234
- this.#fs = fsFromOption(fs);
106243
+ constructor(cwd = process.cwd(), pathImpl, sep6, { nocase, childrenCacheSize = 16 * 1024, fs: fs2 = defaultFS } = {}) {
106244
+ this.#fs = fsFromOption(fs2);
106235
106245
  if (cwd instanceof URL || cwd.startsWith("file://")) {
106236
106246
  cwd = (0, node_url_1.fileURLToPath)(cwd);
106237
106247
  }
@@ -106790,8 +106800,8 @@ var require_commonjs4 = __commonJS({
106790
106800
  /**
106791
106801
  * @internal
106792
106802
  */
106793
- newRoot(fs) {
106794
- return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
106803
+ newRoot(fs2) {
106804
+ return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs2 });
106795
106805
  }
106796
106806
  /**
106797
106807
  * Return true if the provided path string is an absolute path
@@ -106820,8 +106830,8 @@ var require_commonjs4 = __commonJS({
106820
106830
  /**
106821
106831
  * @internal
106822
106832
  */
106823
- newRoot(fs) {
106824
- return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs });
106833
+ newRoot(fs2) {
106834
+ return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs2 });
106825
106835
  }
106826
106836
  /**
106827
106837
  * Return true if the provided path string is an absolute path
@@ -108007,7 +108017,7 @@ var require_commonjs5 = __commonJS({
108007
108017
  var require_file = __commonJS({
108008
108018
  "../../node_modules/.pnpm/archiver-utils@5.0.2/node_modules/archiver-utils/file.js"(exports, module) {
108009
108019
  "use strict";
108010
- var fs = require_graceful_fs();
108020
+ var fs2 = require_graceful_fs();
108011
108021
  var path4 = __require("path");
108012
108022
  var flatten = require_flatten();
108013
108023
  var difference = require_difference();
@@ -108034,7 +108044,7 @@ var require_file = __commonJS({
108034
108044
  };
108035
108045
  file.exists = function() {
108036
108046
  var filepath = path4.join.apply(path4, arguments);
108037
- return fs.existsSync(filepath);
108047
+ return fs2.existsSync(filepath);
108038
108048
  };
108039
108049
  file.expand = function(...args) {
108040
108050
  var options = isPlainObject(args[0]) ? args.shift() : {};
@@ -108052,7 +108062,7 @@ var require_file = __commonJS({
108052
108062
  if (typeof options.filter === "function") {
108053
108063
  return options.filter(filepath);
108054
108064
  } else {
108055
- return fs.statSync(filepath)[options.filter]();
108065
+ return fs2.statSync(filepath)[options.filter]();
108056
108066
  }
108057
108067
  } catch (e) {
108058
108068
  return false;
@@ -108161,7 +108171,7 @@ var require_file = __commonJS({
108161
108171
  var require_archiver_utils = __commonJS({
108162
108172
  "../../node_modules/.pnpm/archiver-utils@5.0.2/node_modules/archiver-utils/index.js"(exports, module) {
108163
108173
  "use strict";
108164
- var fs = require_graceful_fs();
108174
+ var fs2 = require_graceful_fs();
108165
108175
  var path4 = __require("path");
108166
108176
  var isStream = require_is_stream();
108167
108177
  var lazystream = require_lazystream();
@@ -108210,7 +108220,7 @@ var require_archiver_utils = __commonJS({
108210
108220
  };
108211
108221
  utils.lazyReadStream = function(filepath) {
108212
108222
  return new lazystream.Readable(function() {
108213
- return fs.createReadStream(filepath);
108223
+ return fs2.createReadStream(filepath);
108214
108224
  });
108215
108225
  };
108216
108226
  utils.normalizeInputSource = function(source) {
@@ -108238,7 +108248,7 @@ var require_archiver_utils = __commonJS({
108238
108248
  callback = base;
108239
108249
  base = dirpath;
108240
108250
  }
108241
- fs.readdir(dirpath, function(err, list) {
108251
+ fs2.readdir(dirpath, function(err, list) {
108242
108252
  var i = 0;
108243
108253
  var file;
108244
108254
  var filepath;
@@ -108251,7 +108261,7 @@ var require_archiver_utils = __commonJS({
108251
108261
  return callback(null, results);
108252
108262
  }
108253
108263
  filepath = path4.join(dirpath, file);
108254
- fs.stat(filepath, function(err2, stats) {
108264
+ fs2.stat(filepath, function(err2, stats) {
108255
108265
  results.push({
108256
108266
  path: filepath,
108257
108267
  relative: path4.relative(base, filepath).replace(/\\/g, "/"),
@@ -108315,7 +108325,7 @@ var require_error = __commonJS({
108315
108325
  var require_core = __commonJS({
108316
108326
  "../../node_modules/.pnpm/archiver@7.0.1/node_modules/archiver/lib/core.js"(exports, module) {
108317
108327
  "use strict";
108318
- var fs = __require("fs");
108328
+ var fs2 = __require("fs");
108319
108329
  var glob2 = require_readdir_glob();
108320
108330
  var async = (init_async(), __toCommonJS(async_exports));
108321
108331
  var path4 = __require("path");
@@ -108379,7 +108389,7 @@ var require_core = __commonJS({
108379
108389
  data.sourcePath = filepath;
108380
108390
  task.data = data;
108381
108391
  this._entriesCount++;
108382
- if (data.stats && data.stats instanceof fs.Stats) {
108392
+ if (data.stats && data.stats instanceof fs2.Stats) {
108383
108393
  task = this._updateQueueTaskWithStats(task, data.stats);
108384
108394
  if (task) {
108385
108395
  if (data.stats.size) {
@@ -108550,7 +108560,7 @@ var require_core = __commonJS({
108550
108560
  callback();
108551
108561
  return;
108552
108562
  }
108553
- fs.lstat(task.filepath, function(err, stats) {
108563
+ fs2.lstat(task.filepath, function(err, stats) {
108554
108564
  if (this._state.aborted) {
108555
108565
  setImmediate(callback);
108556
108566
  return;
@@ -108593,7 +108603,7 @@ var require_core = __commonJS({
108593
108603
  task.data.sourceType = "buffer";
108594
108604
  task.source = Buffer.concat([]);
108595
108605
  } else if (stats.isSymbolicLink() && this._moduleSupports("symlink")) {
108596
- var linkPath = fs.readlinkSync(task.filepath);
108606
+ var linkPath = fs2.readlinkSync(task.filepath);
108597
108607
  var dirName = path4.dirname(task.filepath);
108598
108608
  task.data.type = "symlink";
108599
108609
  task.data.linkname = path4.relative(dirName, path4.resolve(dirName, linkPath));
@@ -132288,7 +132298,7 @@ function setupTerminalWebSocket(app, server, store, options) {
132288
132298
  if (pathname !== "/api/terminal/ws") {
132289
132299
  return;
132290
132300
  }
132291
- if (wsDaemonToken && !authenticateUpgradeRequest(wsDaemonToken, req)) {
132301
+ if (wsDaemonToken && !options?.noAuth && !authenticateUpgradeRequest(wsDaemonToken, req)) {
132292
132302
  socket.write("HTTP/1.1 401 Unauthorized\r\nConnection: close\r\n\r\n");
132293
132303
  socket.destroy();
132294
132304
  return;
@@ -132479,7 +132489,7 @@ function setupBadgeWebSocket(app, server, store, options) {
132479
132489
  if (pathname !== "/api/ws") {
132480
132490
  return;
132481
132491
  }
132482
- if (badgeWsDaemonToken && !authenticateUpgradeRequest(badgeWsDaemonToken, req)) {
132492
+ if (badgeWsDaemonToken && !options?.noAuth && !authenticateUpgradeRequest(badgeWsDaemonToken, req)) {
132483
132493
  socket.write("HTTP/1.1 401 Unauthorized\r\nConnection: close\r\n\r\n");
132484
132494
  socket.destroy();
132485
132495
  return;
@@ -133738,6 +133748,696 @@ var init_project_context = __esm({
133738
133748
  }
133739
133749
  });
133740
133750
 
133751
+ // src/commands/dashboard-tui.ts
133752
+ import * as readline from "node:readline";
133753
+ function moveCursorTo(x, y) {
133754
+ process.stdout.write(`\x1B[${y};${x}H`);
133755
+ }
133756
+ function clearLine() {
133757
+ process.stdout.write("\x1B[2K");
133758
+ }
133759
+ function clearScreen() {
133760
+ process.stdout.write("\x1B[2J");
133761
+ }
133762
+ function hideCursor() {
133763
+ process.stdout.write("\x1B[?25l");
133764
+ }
133765
+ function showCursor() {
133766
+ process.stdout.write("\x1B[?25h");
133767
+ }
133768
+ function enableAlternateScreen() {
133769
+ process.stdout.write("\x1B[?47h");
133770
+ }
133771
+ function disableAlternateScreen() {
133772
+ process.stdout.write("\x1B[?47l");
133773
+ }
133774
+ function colorize(text, color) {
133775
+ const colors = {
133776
+ reset: "\x1B[0m",
133777
+ bold: "\x1B[1m",
133778
+ dim: "\x1B[2m",
133779
+ red: "\x1B[31m",
133780
+ green: "\x1B[32m",
133781
+ yellow: "\x1B[33m",
133782
+ blue: "\x1B[34m",
133783
+ magenta: "\x1B[35m",
133784
+ cyan: "\x1B[36m",
133785
+ white: "\x1B[37m",
133786
+ gray: "\x1B[90m",
133787
+ brightRed: "\x1B[91m",
133788
+ brightGreen: "\x1B[92m",
133789
+ brightYellow: "\x1B[93m",
133790
+ brightBlue: "\x1B[94m",
133791
+ brightMagenta: "\x1B[95m",
133792
+ brightCyan: "\x1B[96m"
133793
+ };
133794
+ return `${colors[color] || ""}${text}${colors.reset}`;
133795
+ }
133796
+ function formatTimestamp3(date) {
133797
+ const h = date.getHours().toString().padStart(2, "0");
133798
+ const m = date.getMinutes().toString().padStart(2, "0");
133799
+ const s = date.getSeconds().toString().padStart(2, "0");
133800
+ const ms = date.getMilliseconds().toString().padStart(3, "0");
133801
+ return `${h}:${m}:${s}.${ms}`;
133802
+ }
133803
+ function formatUptime(ms) {
133804
+ const seconds = Math.floor(ms / 1e3);
133805
+ const minutes = Math.floor(seconds / 60);
133806
+ const hours = Math.floor(minutes / 60);
133807
+ const days = Math.floor(hours / 24);
133808
+ if (days > 0) return `${days}d ${hours % 24}h ${minutes % 60}m`;
133809
+ if (hours > 0) return `${hours}h ${minutes % 60}m ${seconds % 60}s`;
133810
+ if (minutes > 0) return `${minutes}m ${seconds % 60}s`;
133811
+ return `${seconds}s`;
133812
+ }
133813
+ function visibleLength(str) {
133814
+ return str.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, "").length;
133815
+ }
133816
+ function visibleTruncate(text, maxWidth) {
133817
+ if (maxWidth <= 0) return "";
133818
+ const currentLength = visibleLength(text);
133819
+ if (currentLength <= maxWidth) return text;
133820
+ const ansiRegex = /\x1b\[[0-9;]*[a-zA-Z]/g;
133821
+ let result = "";
133822
+ let visibleCount = 0;
133823
+ let match;
133824
+ const ansiMatches = [];
133825
+ while ((match = ansiRegex.exec(text)) !== null) {
133826
+ ansiMatches.push({
133827
+ start: match.index,
133828
+ end: match.index + match[0].length,
133829
+ seq: match[0]
133830
+ });
133831
+ }
133832
+ for (let i = 0; i < text.length; i++) {
133833
+ const char = text[i];
133834
+ const ansiMatch = ansiMatches.find((m) => m.start === i);
133835
+ if (ansiMatch) {
133836
+ result += ansiMatch.seq;
133837
+ continue;
133838
+ }
133839
+ visibleCount++;
133840
+ result += char;
133841
+ if (visibleCount >= maxWidth - 3) {
133842
+ break;
133843
+ }
133844
+ }
133845
+ if (visibleCount >= maxWidth - 3 && visibleCount < currentLength) {
133846
+ result += "...";
133847
+ }
133848
+ return result;
133849
+ }
133850
+ function centerText(text, width, padChar = " ") {
133851
+ const visibleLen = visibleLength(text);
133852
+ const padding = Math.max(0, width - visibleLen);
133853
+ const leftPad = Math.floor(padding / 2);
133854
+ const rightPad = padding - leftPad;
133855
+ return padChar.repeat(leftPad) + text + padChar.repeat(rightPad);
133856
+ }
133857
+ function padRight(text, width) {
133858
+ if (width <= 0) return "";
133859
+ const visibleLen = visibleLength(text);
133860
+ return text + " ".repeat(Math.max(0, width - visibleLen));
133861
+ }
133862
+ function isTTYAvailable() {
133863
+ return Boolean(process.stdout.isTTY && process.stdin.isTTY);
133864
+ }
133865
+ var MAX_LOG_ENTRIES, LogRingBuffer, SECTION_ORDER, DashboardTUI, DashboardLogSink;
133866
+ var init_dashboard_tui = __esm({
133867
+ "src/commands/dashboard-tui.ts"() {
133868
+ "use strict";
133869
+ MAX_LOG_ENTRIES = 1e3;
133870
+ LogRingBuffer = class {
133871
+ entries = [];
133872
+ count = 0;
133873
+ push(entry) {
133874
+ if (this.entries.length < MAX_LOG_ENTRIES) {
133875
+ this.entries.push(entry);
133876
+ } else {
133877
+ this.entries[this.count % MAX_LOG_ENTRIES] = entry;
133878
+ }
133879
+ this.count++;
133880
+ }
133881
+ getAll() {
133882
+ if (this.count <= MAX_LOG_ENTRIES) {
133883
+ return this.entries.slice();
133884
+ }
133885
+ const start = this.count % MAX_LOG_ENTRIES;
133886
+ return [
133887
+ ...this.entries.slice(start),
133888
+ ...this.entries.slice(0, start)
133889
+ ];
133890
+ }
133891
+ clear() {
133892
+ this.entries = [];
133893
+ this.count = 0;
133894
+ }
133895
+ get total() {
133896
+ return this.count;
133897
+ }
133898
+ };
133899
+ SECTION_ORDER = ["logs", "system", "utilities", "stats", "settings"];
133900
+ DashboardTUI = class {
133901
+ activeSection = "logs";
133902
+ logBuffer;
133903
+ systemInfo = null;
133904
+ taskStats = null;
133905
+ settings = null;
133906
+ callbacks = null;
133907
+ isRunning = false;
133908
+ rl = null;
133909
+ originalHandlers = /* @__PURE__ */ new Map();
133910
+ lastRenderHeight = 0;
133911
+ showHelp = false;
133912
+ uptimeTimer = null;
133913
+ resizeHandler = null;
133914
+ constructor() {
133915
+ this.logBuffer = new LogRingBuffer();
133916
+ }
133917
+ // ── Public API ─────────────────────────────────────────────────────────────
133918
+ /** Returns whether the TUI is currently running */
133919
+ get running() {
133920
+ return this.isRunning;
133921
+ }
133922
+ setCallbacks(callbacks) {
133923
+ this.callbacks = callbacks;
133924
+ }
133925
+ setSystemInfo(info) {
133926
+ this.systemInfo = info;
133927
+ this.render();
133928
+ }
133929
+ setTaskStats(stats) {
133930
+ this.taskStats = stats;
133931
+ this.render();
133932
+ }
133933
+ setSettings(settings) {
133934
+ this.settings = settings;
133935
+ this.render();
133936
+ }
133937
+ addLog(entry) {
133938
+ this.logBuffer.push({
133939
+ ...entry,
133940
+ timestamp: /* @__PURE__ */ new Date()
133941
+ });
133942
+ this.render();
133943
+ }
133944
+ log(message, prefix) {
133945
+ this.addLog({ level: "info", message, prefix });
133946
+ }
133947
+ warn(message, prefix) {
133948
+ this.addLog({ level: "warn", message, prefix });
133949
+ }
133950
+ error(message, prefix) {
133951
+ this.addLog({ level: "error", message, prefix });
133952
+ }
133953
+ async start() {
133954
+ if (this.isRunning) return;
133955
+ this.isRunning = true;
133956
+ enableAlternateScreen();
133957
+ hideCursor();
133958
+ this.saveSignalHandlers();
133959
+ this.rl = readline.createInterface({
133960
+ input: process.stdin,
133961
+ output: process.stdout,
133962
+ terminal: true
133963
+ });
133964
+ process.stdin.setRawMode?.(true);
133965
+ process.stdin.resume();
133966
+ process.stdin.setEncoding("utf8");
133967
+ readline.emitKeypressEvents(process.stdin);
133968
+ process.stdin.on("keypress", (str, key) => {
133969
+ if (str) {
133970
+ this.handleKeypress(str);
133971
+ } else if (key.ctrl && key.name === "c") {
133972
+ this.handleKeypress("");
133973
+ } else if (key.name === "right") {
133974
+ this.handleKeypress("\x1B[C");
133975
+ } else if (key.name === "left") {
133976
+ this.handleKeypress("\x1B[D");
133977
+ } else if (key.name === "up") {
133978
+ this.handleKeypress("\x1B[A");
133979
+ } else if (key.name === "down") {
133980
+ this.handleKeypress("\x1B[B");
133981
+ } else if (key.name === "escape") {
133982
+ this.handleKeypress("\x1B");
133983
+ }
133984
+ });
133985
+ this.uptimeTimer = setInterval(() => {
133986
+ if (this.isRunning) {
133987
+ this.renderFooter();
133988
+ }
133989
+ }, 5e3);
133990
+ this.resizeHandler = () => {
133991
+ if (this.isRunning) {
133992
+ this.render();
133993
+ }
133994
+ };
133995
+ process.stdout.on("resize", this.resizeHandler);
133996
+ this.render();
133997
+ }
133998
+ async stop() {
133999
+ if (!this.isRunning) return;
134000
+ this.isRunning = false;
134001
+ if (this.uptimeTimer) {
134002
+ clearInterval(this.uptimeTimer);
134003
+ this.uptimeTimer = null;
134004
+ }
134005
+ if (this.resizeHandler) {
134006
+ process.stdout.off("resize", this.resizeHandler);
134007
+ this.resizeHandler = null;
134008
+ }
134009
+ this.restoreTerminal();
134010
+ this.restoreSignalHandlers();
134011
+ if (this.rl) {
134012
+ this.rl.close();
134013
+ this.rl = null;
134014
+ }
134015
+ }
134016
+ // ── Private: Signal Handling ───────────────────────────────────────────────
134017
+ saveSignalHandlers() {
134018
+ const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
134019
+ for (const sig of signals) {
134020
+ const listeners = process.listeners(sig);
134021
+ if (listeners.length > 0) {
134022
+ this.originalHandlers.set(sig, listeners[listeners.length - 1]);
134023
+ }
134024
+ }
134025
+ }
134026
+ restoreSignalHandlers() {
134027
+ for (const [sig, handler] of this.originalHandlers) {
134028
+ process.on(sig, handler);
134029
+ }
134030
+ this.originalHandlers.clear();
134031
+ }
134032
+ // ── Private: Terminal Restoration ────────────────────────────────────────
134033
+ restoreTerminal() {
134034
+ showCursor();
134035
+ disableAlternateScreen();
134036
+ process.stdout.write("\n");
134037
+ process.stdin.pause?.();
134038
+ process.stdin.setRawMode?.(false);
134039
+ }
134040
+ // ── Private: Key Handling ────────────────────────────────────────────────
134041
+ handleKeypress(key) {
134042
+ if (key === "") {
134043
+ void this.stop();
134044
+ process.exit(0);
134045
+ return;
134046
+ }
134047
+ if (key === "q" || key === "Q") {
134048
+ void this.stop();
134049
+ process.exit(0);
134050
+ return;
134051
+ }
134052
+ if (key === "?" || key === "h" || key === "H") {
134053
+ this.showHelp = !this.showHelp;
134054
+ this.render();
134055
+ return;
134056
+ }
134057
+ if (key >= "1" && key <= "5") {
134058
+ const index2 = parseInt(key, 10) - 1;
134059
+ if (index2 >= 0 && index2 < SECTION_ORDER.length) {
134060
+ this.activeSection = SECTION_ORDER[index2];
134061
+ this.showHelp = false;
134062
+ this.render();
134063
+ }
134064
+ return;
134065
+ }
134066
+ if (key === "\x1B[C" || key === "n" || key === "N") {
134067
+ const currentIndex = SECTION_ORDER.indexOf(this.activeSection);
134068
+ this.activeSection = SECTION_ORDER[(currentIndex + 1) % SECTION_ORDER.length];
134069
+ this.showHelp = false;
134070
+ this.render();
134071
+ return;
134072
+ }
134073
+ if (key === "\x1B[D" || key === "p" || key === "P") {
134074
+ const currentIndex = SECTION_ORDER.indexOf(this.activeSection);
134075
+ this.activeSection = SECTION_ORDER[(currentIndex - 1 + SECTION_ORDER.length) % SECTION_ORDER.length];
134076
+ this.showHelp = false;
134077
+ this.render();
134078
+ return;
134079
+ }
134080
+ if (this.activeSection === "utilities") {
134081
+ this.handleUtilityKeypress(key);
134082
+ }
134083
+ }
134084
+ async handleUtilityKeypress(key) {
134085
+ if (!this.callbacks) return;
134086
+ switch (key.toLowerCase()) {
134087
+ case "r":
134088
+ await this.callbacks.onRefreshStats();
134089
+ break;
134090
+ case "c":
134091
+ this.callbacks.onClearLogs();
134092
+ this.logBuffer.clear();
134093
+ this.render();
134094
+ break;
134095
+ case "t":
134096
+ if (this.systemInfo) {
134097
+ const newPaused = this.systemInfo.engineMode !== "paused";
134098
+ const newSettings = await this.callbacks.onTogglePause(newPaused);
134099
+ const newEngineMode = newSettings.enginePaused ? "paused" : "active";
134100
+ this.setSystemInfo({ ...this.systemInfo, engineMode: newEngineMode });
134101
+ this.setSettings(newSettings);
134102
+ }
134103
+ break;
134104
+ }
134105
+ }
134106
+ // ── Private: Rendering ───────────────────────────────────────────────────
134107
+ render() {
134108
+ if (!this.isRunning) return;
134109
+ clearScreen();
134110
+ moveCursorTo(1, 1);
134111
+ this.renderHeader();
134112
+ this.renderSection();
134113
+ this.renderFooter();
134114
+ if (this.showHelp) {
134115
+ this.renderHelpOverlay();
134116
+ }
134117
+ }
134118
+ renderHeader() {
134119
+ const cols = process.stdout.columns || 80;
134120
+ const title = colorize(" fn board ", "cyan");
134121
+ const titleLen = visibleLength(title);
134122
+ process.stdout.write(title);
134123
+ if (cols >= 70) {
134124
+ for (let i = 0; i < SECTION_ORDER.length; i++) {
134125
+ const section = SECTION_ORDER[i];
134126
+ const isActive = section === this.activeSection;
134127
+ const num = (i + 1).toString();
134128
+ const label = section.charAt(0).toUpperCase() + section.slice(1);
134129
+ const tabText = `[${num}] ${label}`;
134130
+ const style = isActive ? "brightBlue" : "dim";
134131
+ process.stdout.write(colorize(` ${tabText} `, style));
134132
+ }
134133
+ } else if (cols >= 40) {
134134
+ const shortLabels = {
134135
+ logs: "L",
134136
+ system: "S",
134137
+ utilities: "U",
134138
+ stats: "St",
134139
+ settings: "Se"
134140
+ };
134141
+ for (let i = 0; i < SECTION_ORDER.length; i++) {
134142
+ const section = SECTION_ORDER[i];
134143
+ const isActive = section === this.activeSection;
134144
+ const num = (i + 1).toString();
134145
+ const shortLabel = shortLabels[section];
134146
+ const tabText = `[${num}]${shortLabel}`;
134147
+ const style = isActive ? "brightBlue" : "dim";
134148
+ process.stdout.write(colorize(` ${tabText} `, style));
134149
+ }
134150
+ } else {
134151
+ const activeIndex = SECTION_ORDER.indexOf(this.activeSection);
134152
+ const activeLabel = this.activeSection.charAt(0).toUpperCase() + this.activeSection.slice(1);
134153
+ process.stdout.write(colorize(` [${activeIndex + 1}]${activeLabel} `, "brightBlue"));
134154
+ process.stdout.write(colorize(" [n/p]nav ", "dim"));
134155
+ }
134156
+ const tabsLength = SECTION_ORDER.reduce((acc, s, i) => {
134157
+ let label;
134158
+ if (cols >= 70) {
134159
+ label = s.charAt(0).toUpperCase() + s.slice(1);
134160
+ } else if (cols >= 40) {
134161
+ const shortLabels = {
134162
+ logs: "L",
134163
+ system: "S",
134164
+ utilities: "U",
134165
+ stats: "St",
134166
+ settings: "Se"
134167
+ };
134168
+ label = shortLabels[s];
134169
+ } else {
134170
+ label = s.charAt(0).toUpperCase() + s.slice(1);
134171
+ }
134172
+ const tabText = `[${i + 1}]${label} `;
134173
+ return acc + tabText.length;
134174
+ }, 0);
134175
+ const headerLen = titleLen + tabsLength;
134176
+ const remaining = cols - headerLen;
134177
+ if (remaining > 0) {
134178
+ process.stdout.write(" ".repeat(remaining));
134179
+ }
134180
+ process.stdout.write("\n");
134181
+ process.stdout.write(colorize("\u2500".repeat(Math.max(20, cols)), "dim") + "\n");
134182
+ }
134183
+ renderSection() {
134184
+ switch (this.activeSection) {
134185
+ case "logs":
134186
+ this.renderLogsSection();
134187
+ break;
134188
+ case "system":
134189
+ this.renderSystemSection();
134190
+ break;
134191
+ case "utilities":
134192
+ this.renderUtilitiesSection();
134193
+ break;
134194
+ case "stats":
134195
+ this.renderStatsSection();
134196
+ break;
134197
+ case "settings":
134198
+ this.renderSettingsSection();
134199
+ break;
134200
+ }
134201
+ }
134202
+ renderLogsSection() {
134203
+ const cols = process.stdout.columns || 80;
134204
+ const entries = this.logBuffer.getAll();
134205
+ const maxRows = Math.max(1, (process.stdout.rows ?? 38) - 8);
134206
+ process.stdout.write(colorize("\n LOGS\n", "bold"));
134207
+ process.stdout.write(colorize(` Ring buffer: ${this.logBuffer.total}/${MAX_LOG_ENTRIES} entries
134208
+
134209
+ `, "dim"));
134210
+ if (entries.length === 0) {
134211
+ process.stdout.write(colorize(" No log entries yet.\n", "dim"));
134212
+ return;
134213
+ }
134214
+ const displayEntries = entries.slice(-maxRows).reverse();
134215
+ for (const entry of displayEntries) {
134216
+ const ts = colorize(formatTimestamp3(entry.timestamp), "dim");
134217
+ const prefix = entry.prefix ? colorize(`[${entry.prefix}]`, "gray") : "";
134218
+ const levelChar = entry.level === "error" ? colorize("\u2717", "brightRed") : entry.level === "warn" ? colorize("\u26A0", "brightYellow") : colorize("\u2713", "brightGreen");
134219
+ const messageWidth = Math.max(8, cols - 40);
134220
+ const message = visibleTruncate(entry.message, messageWidth);
134221
+ const line = ` ${ts} ${levelChar} ${prefix ? prefix + " " : ""}${message}`;
134222
+ process.stdout.write(visibleTruncate(line, cols - 1) + "\n");
134223
+ }
134224
+ }
134225
+ renderSystemSection() {
134226
+ if (!this.systemInfo) {
134227
+ process.stdout.write(colorize("\n System information not available.\n", "dim"));
134228
+ return;
134229
+ }
134230
+ const cols = process.stdout.columns || 80;
134231
+ const info = this.systemInfo;
134232
+ const rows = [];
134233
+ rows.push(colorize("\n SYSTEM INFORMATION\n", "bold"));
134234
+ rows.push("");
134235
+ const labelWidth = 12;
134236
+ const availableValueWidth = Math.max(8, cols - labelWidth - 1);
134237
+ rows.push(` ${colorize("Host:", "white")} ${info.host}`);
134238
+ rows.push(` ${colorize("Port:", "white")} ${info.port}`);
134239
+ rows.push(` ${colorize("URL:", "white")} ${colorize(visibleTruncate(info.baseUrl, availableValueWidth), "brightCyan")}`);
134240
+ rows.push("");
134241
+ if (info.authEnabled) {
134242
+ rows.push(` ${colorize("Auth:", "white")} ${colorize("bearer token required", "yellow")}`);
134243
+ if (info.authToken) {
134244
+ rows.push(` ${colorize("Token:", "white")} ${visibleTruncate(info.authToken, availableValueWidth)}`);
134245
+ }
134246
+ if (info.tokenizedUrl) {
134247
+ rows.push(` ${colorize("Open:", "white")} ${visibleTruncate(info.tokenizedUrl, availableValueWidth)}`);
134248
+ rows.push(colorize(" (browser stores token, click once)", "dim"));
134249
+ }
134250
+ } else {
134251
+ rows.push(` ${colorize("Auth:", "white")} ${colorize("disabled (--no-auth)", "dim")}`);
134252
+ }
134253
+ rows.push("");
134254
+ rows.push(` ${colorize("AI Engine:", "white")} ${info.engineMode === "dev" ? colorize("\u2717 disabled (dev mode)", "yellow") : info.engineMode === "paused" ? colorize("\u23F8 paused", "brightYellow") : colorize("\u2713 active", "brightGreen")}`);
134255
+ rows.push(` ${colorize("File Watcher:", "white")} ${info.fileWatcher ? colorize("\u2713 active", "brightGreen") : colorize("\u2717 inactive", "brightRed")}`);
134256
+ rows.push(` ${colorize("Uptime:", "white")} ${formatUptime(Date.now() - info.startTimeMs)}`);
134257
+ for (const row of rows) {
134258
+ process.stdout.write(visibleTruncate(row, cols) + "\n");
134259
+ }
134260
+ }
134261
+ renderUtilitiesSection() {
134262
+ const cols = process.stdout.columns || 80;
134263
+ const actions = [
134264
+ { id: "refresh", label: "Refresh Stats", key: "r", description: "Re-fetch task and agent counts" },
134265
+ { id: "clear", label: "Clear Logs", key: "c", description: "Clear the log ring buffer" },
134266
+ { id: "pause", label: "Toggle Engine Pause", key: "t", description: "Pause/resume AI engine automation" },
134267
+ { id: "help", label: "Help", key: "?", description: "Show keyboard shortcuts" }
134268
+ ];
134269
+ process.stdout.write(colorize("\n UTILITIES\n", "bold"));
134270
+ process.stdout.write(colorize(" Press key to execute action\n\n", "dim"));
134271
+ const prefixWidth = 2 + 3 + 1 + 20 + 3;
134272
+ const descriptionWidth = Math.max(8, cols - prefixWidth - 1);
134273
+ for (const action of actions) {
134274
+ const keyDisplay = colorize(`[${action.key}]`, "brightYellow");
134275
+ const label = colorize(action.label.padEnd(20), "white");
134276
+ const description = visibleTruncate(action.description, descriptionWidth);
134277
+ const line = ` ${keyDisplay} ${label} - ${description}`;
134278
+ process.stdout.write(visibleTruncate(line, cols - 1) + "\n");
134279
+ }
134280
+ }
134281
+ renderStatsSection() {
134282
+ const cols = process.stdout.columns || 80;
134283
+ if (!this.taskStats) {
134284
+ process.stdout.write(colorize("\n Statistics not available.\n", "dim"));
134285
+ return;
134286
+ }
134287
+ const stats = this.taskStats;
134288
+ const rows = [];
134289
+ rows.push(colorize("\n STATISTICS\n", "bold"));
134290
+ rows.push("");
134291
+ rows.push(` ${colorize("Total Tasks:", "white")} ${stats.total}`);
134292
+ rows.push("");
134293
+ rows.push(` ${colorize("By Column:", "dim")}`);
134294
+ for (const [column, count] of Object.entries(stats.byColumn)) {
134295
+ const colName = column.replace("-", " ").replace(/\b\w/g, (l) => l.toUpperCase());
134296
+ const activeMark = (column === "in-progress" || column === "in-review") && count > 0 ? colorize(" \u25CF", "brightGreen") : "";
134297
+ rows.push(` ${colName}: ${count}${activeMark}`);
134298
+ }
134299
+ rows.push("");
134300
+ rows.push(` ${colorize("Active Tasks:", "white")} ${stats.active} (in-progress + in-review)`);
134301
+ rows.push("");
134302
+ rows.push(` ${colorize("Agents:", "dim")}`);
134303
+ rows.push(` Idle: ${stats.agents.idle}`);
134304
+ rows.push(` Active: ${stats.agents.active}`);
134305
+ rows.push(` Running: ${stats.agents.running}`);
134306
+ rows.push(` Error: ${stats.agents.error}`);
134307
+ for (const row of rows) {
134308
+ process.stdout.write(visibleTruncate(row, cols) + "\n");
134309
+ }
134310
+ }
134311
+ renderSettingsSection() {
134312
+ const cols = process.stdout.columns || 80;
134313
+ if (!this.settings) {
134314
+ process.stdout.write(colorize("\n Settings not available.\n", "dim"));
134315
+ return;
134316
+ }
134317
+ const s = this.settings;
134318
+ const rows = [];
134319
+ rows.push(colorize("\n SETTINGS\n", "bold"));
134320
+ rows.push("");
134321
+ const settingsList = [
134322
+ ["maxConcurrent", s.maxConcurrent.toString()],
134323
+ ["maxWorktrees", s.maxWorktrees.toString()],
134324
+ ["autoMerge", s.autoMerge ? "enabled" : "disabled"],
134325
+ ["mergeStrategy", s.mergeStrategy],
134326
+ ["pollIntervalMs", `${s.pollIntervalMs}ms`],
134327
+ ["enginePaused", s.enginePaused ? "yes" : "no"],
134328
+ ["globalPause", s.globalPause ? "yes" : "no"]
134329
+ ];
134330
+ const keyWidth = Math.max(...settingsList.map(([k]) => k.length));
134331
+ for (const [key, value] of settingsList) {
134332
+ const keyPad = key.padEnd(keyWidth);
134333
+ const isEnabled = value === "enabled" || value === "yes";
134334
+ const isDisabled = value === "disabled" || value === "no";
134335
+ const valueColor = isEnabled ? "brightGreen" : isDisabled ? "brightYellow" : "white";
134336
+ rows.push(` ${colorize(keyPad, "gray")} ${colorize(value, valueColor)}`);
134337
+ }
134338
+ for (const row of rows) {
134339
+ process.stdout.write(visibleTruncate(row, cols) + "\n");
134340
+ }
134341
+ }
134342
+ renderFooter() {
134343
+ const cols = process.stdout.columns || 80;
134344
+ const footerY = Math.max(1, (process.stdout.rows ?? 22) - 2);
134345
+ moveCursorTo(1, footerY);
134346
+ clearLine();
134347
+ const status = this.systemInfo ? `${this.systemInfo.baseUrl} | ${formatUptime(Date.now() - this.systemInfo.startTimeMs)}` : "";
134348
+ const left = colorize("Press ? for help", "dim");
134349
+ const right = colorize(visibleTruncate(status, Math.max(20, cols - 20)), "dim");
134350
+ const leftLen = visibleLength(left);
134351
+ const rightLen = visibleLength(right);
134352
+ process.stdout.write(left);
134353
+ const padding = Math.max(1, cols - leftLen - rightLen - 2);
134354
+ process.stdout.write(" ".repeat(padding));
134355
+ process.stdout.write(right);
134356
+ process.stdout.write("\n");
134357
+ }
134358
+ renderHelpOverlay() {
134359
+ const cols = process.stdout.columns || 80;
134360
+ const rows = process.stdout.rows || 24;
134361
+ const boxWidth = Math.min(62, Math.max(cols - 4, 20));
134362
+ const useBoxDrawing = cols >= boxWidth + 4;
134363
+ let helpLines;
134364
+ if (useBoxDrawing) {
134365
+ helpLines = [
134366
+ colorize("\u250C" + "\u2500".repeat(boxWidth) + "\u2510", "brightBlue"),
134367
+ colorize("\u2502" + centerText("KEYBOARD SHORTCUTS", boxWidth, " ") + "\u2502", "brightBlue"),
134368
+ colorize("\u251C" + "\u2500".repeat(boxWidth) + "\u2524", "brightBlue"),
134369
+ colorize("\u2502 [1-5] Switch to tab by number" + padRight("", boxWidth - 39) + "\u2502", "white"),
134370
+ colorize("\u2502 [n] / \u2192 Next tab" + padRight("", boxWidth - 25) + "\u2502", "white"),
134371
+ colorize("\u2502 [p] / \u2190 Previous tab" + padRight("", boxWidth - 27) + "\u2502", "white"),
134372
+ colorize("\u2502 [r] Refresh stats (Utilities)" + padRight("", boxWidth - 36) + "\u2502", "white"),
134373
+ colorize("\u2502 [c] Clear logs (Utilities)" + padRight("", boxWidth - 33) + "\u2502", "white"),
134374
+ colorize("\u2502 [t] Toggle engine pause (Utilities)" + padRight("", boxWidth - 42) + "\u2502", "white"),
134375
+ colorize("\u2502 [?] / [h] Toggle help" + padRight("", boxWidth - 24) + "\u2502", "white"),
134376
+ colorize("\u2502 [q] Quit" + padRight("", boxWidth - 15) + "\u2502", "white"),
134377
+ colorize("\u2502 [Ctrl+C] Force quit" + padRight("", boxWidth - 22) + "\u2502", "white"),
134378
+ colorize("\u2514" + "\u2500".repeat(boxWidth) + "\u2518", "brightBlue")
134379
+ ];
134380
+ } else {
134381
+ const maxLineWidth = cols - 2;
134382
+ helpLines = [
134383
+ visibleTruncate(colorize("KEYBOARD SHORTCUTS", "brightBlue"), maxLineWidth),
134384
+ visibleTruncate(colorize(" [1-5] Switch tab | [n/p] Next/Prev | [q] Quit", "white"), maxLineWidth),
134385
+ visibleTruncate(colorize(" [r] Refresh | [c] Clear logs | [t] Toggle engine", "white"), maxLineWidth),
134386
+ visibleTruncate(colorize(" [?/h] Help | [Ctrl+C] Force quit", "white"), maxLineWidth)
134387
+ ];
134388
+ }
134389
+ const compactBoxWidth = useBoxDrawing ? boxWidth : Math.max(...helpLines.map(visibleLength));
134390
+ const boxHeight = helpLines.length;
134391
+ const safeStartX = Math.max(1, Math.floor((cols - compactBoxWidth) / 2));
134392
+ const safeStartY = Math.max(1, Math.floor((rows - boxHeight) / 2));
134393
+ const clearTop = Math.max(1, safeStartY - 1);
134394
+ const clearBottom = Math.min(rows, safeStartY + boxHeight);
134395
+ for (let y = clearTop; y <= clearBottom; y++) {
134396
+ moveCursorTo(1, y);
134397
+ clearLine();
134398
+ }
134399
+ for (let i = 0; i < helpLines.length; i++) {
134400
+ moveCursorTo(safeStartX, safeStartY + i);
134401
+ process.stdout.write(helpLines[i]);
134402
+ }
134403
+ }
134404
+ };
134405
+ DashboardLogSink = class {
134406
+ tui = null;
134407
+ isTTY;
134408
+ constructor(tui) {
134409
+ this.tui = tui ?? null;
134410
+ this.isTTY = tui?.running ?? false;
134411
+ }
134412
+ setTUI(tui) {
134413
+ this.tui = tui;
134414
+ this.isTTY = true;
134415
+ }
134416
+ log(message, prefix) {
134417
+ if (this.tui && this.isTTY) {
134418
+ this.tui.log(message, prefix);
134419
+ } else {
134420
+ console.log(prefix ? `[${prefix}] ${message}` : message);
134421
+ }
134422
+ }
134423
+ warn(message, prefix) {
134424
+ if (this.tui && this.isTTY) {
134425
+ this.tui.warn(message, prefix);
134426
+ } else {
134427
+ console.warn(prefix ? `[${prefix}] ${message}` : message);
134428
+ }
134429
+ }
134430
+ error(message, prefix) {
134431
+ if (this.tui && this.isTTY) {
134432
+ this.tui.error(message, prefix);
134433
+ } else {
134434
+ console.error(prefix ? `[${prefix}] ${message}` : message);
134435
+ }
134436
+ }
134437
+ };
134438
+ }
134439
+ });
134440
+
133741
134441
  // src/commands/dashboard.ts
133742
134442
  var dashboard_exports = {};
133743
134443
  __export(dashboard_exports, {
@@ -133753,7 +134453,7 @@ function formatBytes2(bytes) {
133753
134453
  if (bytes < 1024 * 1024 * 1024) return `${Math.round(bytes / (1024 * 1024))}MB`;
133754
134454
  return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}GB`;
133755
134455
  }
133756
- function formatUptime(ms) {
134456
+ function formatUptime2(ms) {
133757
134457
  const seconds = Math.floor(ms / 1e3);
133758
134458
  const minutes = Math.floor(seconds / 60);
133759
134459
  const hours = Math.floor(minutes / 60);
@@ -133790,7 +134490,7 @@ function logDiagnostics(prefix, startTime, dbHealthCheck) {
133790
134490
  } catch {
133791
134491
  }
133792
134492
  }
133793
- const logLine = `[${prefix}] diagnostics: uptime=${formatUptime(uptime)} rss=${formatBytes2(mem.rss)} heap=${formatBytes2(mem.heapUsed)}/${formatBytes2(mem.heapTotal)} external=${formatBytes2(mem.external)} arrayBuffers=${formatBytes2(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}${listenerInfo}`;
134493
+ const logLine = `[${prefix}] diagnostics: uptime=${formatUptime2(uptime)} rss=${formatBytes2(mem.rss)} heap=${formatBytes2(mem.heapUsed)}/${formatBytes2(mem.heapTotal)} external=${formatBytes2(mem.external)} arrayBuffers=${formatBytes2(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}${listenerInfo}`;
133794
134494
  console.log(logLine);
133795
134495
  }
133796
134496
  function ensureProcessDiagnostics() {
@@ -133813,11 +134513,11 @@ function ensureProcessDiagnostics() {
133813
134513
  requestCount = process._getActiveRequests?.()?.length ?? -1;
133814
134514
  } catch {
133815
134515
  }
133816
- console.log(`[dashboard] beforeExit code=${code} uptime=${formatUptime(uptime)} handles=${handleCount} requests=${requestCount}`);
134516
+ console.log(`[dashboard] beforeExit code=${code} uptime=${formatUptime2(uptime)} handles=${handleCount} requests=${requestCount}`);
133817
134517
  });
133818
134518
  process.on("exit", (code) => {
133819
134519
  const uptime = Date.now() - diagnosticStartTime;
133820
- console.log(`[dashboard] exit code=${code} uptime=${formatUptime(uptime)}`);
134520
+ console.log(`[dashboard] exit code=${code} uptime=${formatUptime2(uptime)}`);
133821
134521
  });
133822
134522
  process.on("uncaughtExceptionMonitor", (error) => {
133823
134523
  console.error(`[dashboard] uncaught exception pid=${process.pid}: ${error.stack || error.message}`);
@@ -133863,7 +134563,73 @@ async function runDashboard(port, opts = {}) {
133863
134563
  }
133864
134564
  }
133865
134565
  const cwd = await resolveRuntimeProjectPath();
133866
- const store = new TaskStore(cwd);
134566
+ const isTTY = isTTYAvailable();
134567
+ let tui;
134568
+ const dashboardStartedAt = Date.now();
134569
+ let store;
134570
+ let agentStore;
134571
+ const logSink = new DashboardLogSink();
134572
+ if (isTTY) {
134573
+ tui = new DashboardTUI();
134574
+ tui.setCallbacks({
134575
+ onRefreshStats: async () => {
134576
+ if (store && agentStore) {
134577
+ const tasks = await store.listTasks({ slim: true, includeArchived: false });
134578
+ const counts = /* @__PURE__ */ new Map();
134579
+ for (const task of tasks) {
134580
+ counts.set(task.column, (counts.get(task.column) ?? 0) + 1);
134581
+ }
134582
+ const active = tasks.filter(
134583
+ (task) => task.column === "in-progress" || task.column === "in-review"
134584
+ ).length;
134585
+ const agents = await agentStore.listAgents();
134586
+ const agentStats = { idle: 0, active: 0, running: 0, error: 0 };
134587
+ for (const agent of agents) {
134588
+ const state = agent.state;
134589
+ if (state in agentStats) {
134590
+ agentStats[state]++;
134591
+ }
134592
+ }
134593
+ tui.setTaskStats({
134594
+ total: tasks.length,
134595
+ byColumn: Object.fromEntries(counts),
134596
+ active,
134597
+ agents: agentStats
134598
+ });
134599
+ }
134600
+ },
134601
+ onClearLogs: () => {
134602
+ },
134603
+ onTogglePause: async (paused) => {
134604
+ if (store) {
134605
+ await store.updateSettings({ enginePaused: paused });
134606
+ tui.log(`Engine ${paused ? "paused" : "resumed"}`);
134607
+ const fullSettings = await store.getSettings();
134608
+ return {
134609
+ maxConcurrent: fullSettings.maxConcurrent ?? 1,
134610
+ maxWorktrees: fullSettings.maxWorktrees ?? 2,
134611
+ autoMerge: fullSettings.autoMerge ?? false,
134612
+ mergeStrategy: fullSettings.mergeStrategy ?? "direct",
134613
+ pollIntervalMs: fullSettings.pollIntervalMs ?? 6e4,
134614
+ enginePaused: fullSettings.enginePaused ?? false,
134615
+ globalPause: fullSettings.globalPause ?? false
134616
+ };
134617
+ }
134618
+ return {
134619
+ maxConcurrent: 1,
134620
+ maxWorktrees: 2,
134621
+ autoMerge: false,
134622
+ mergeStrategy: "direct",
134623
+ pollIntervalMs: 6e4,
134624
+ enginePaused: paused,
134625
+ globalPause: false
134626
+ };
134627
+ }
134628
+ });
134629
+ await tui.start();
134630
+ logSink.setTUI(tui);
134631
+ }
134632
+ store = new TaskStore(cwd);
133867
134633
  await store.init();
133868
134634
  await store.watch();
133869
134635
  setDiagnosticDbHealthCheck(() => store.healthCheck());
@@ -133875,15 +134641,78 @@ async function runDashboard(port, opts = {}) {
133875
134641
  "settings:updated": store.listenerCount("settings:updated"),
133876
134642
  "agent:log": store.listenerCount("agent:log")
133877
134643
  }));
134644
+ let tuiRefreshPending = false;
134645
+ let tuiRefreshDebounceTimer = null;
134646
+ async function refreshTUIStats() {
134647
+ if (!tui || !isTTY) return;
134648
+ if (!store || !agentStore) return;
134649
+ if (tuiRefreshPending) return;
134650
+ tuiRefreshPending = true;
134651
+ try {
134652
+ const tasks = await store.listTasks({ slim: true, includeArchived: false });
134653
+ const counts = /* @__PURE__ */ new Map();
134654
+ for (const task of tasks) {
134655
+ counts.set(task.column, (counts.get(task.column) ?? 0) + 1);
134656
+ }
134657
+ const active = tasks.filter(
134658
+ (task) => task.column === "in-progress" || task.column === "in-review"
134659
+ ).length;
134660
+ const agents = await agentStore.listAgents();
134661
+ const agentStats = { idle: 0, active: 0, running: 0, error: 0 };
134662
+ for (const agent of agents) {
134663
+ const state = agent.state;
134664
+ if (state in agentStats) {
134665
+ agentStats[state]++;
134666
+ }
134667
+ }
134668
+ tui.setTaskStats({
134669
+ total: tasks.length,
134670
+ byColumn: Object.fromEntries(counts),
134671
+ active,
134672
+ agents: agentStats
134673
+ });
134674
+ } finally {
134675
+ tuiRefreshPending = false;
134676
+ }
134677
+ }
134678
+ async function refreshTUISettings() {
134679
+ if (!tui || !isTTY) return;
134680
+ if (!store) return;
134681
+ try {
134682
+ const settings = await store.getSettings();
134683
+ tui.setSettings({
134684
+ maxConcurrent: settings.maxConcurrent ?? 1,
134685
+ maxWorktrees: settings.maxWorktrees ?? 2,
134686
+ autoMerge: settings.autoMerge ?? false,
134687
+ mergeStrategy: settings.mergeStrategy ?? "direct",
134688
+ pollIntervalMs: settings.pollIntervalMs ?? 6e4,
134689
+ enginePaused: settings.enginePaused ?? false,
134690
+ globalPause: settings.globalPause ?? false
134691
+ });
134692
+ } catch {
134693
+ }
134694
+ }
134695
+ function scheduleStatsRefresh() {
134696
+ if (tuiRefreshDebounceTimer) {
134697
+ clearTimeout(tuiRefreshDebounceTimer);
134698
+ }
134699
+ tuiRefreshDebounceTimer = setTimeout(() => {
134700
+ void refreshTUIStats();
134701
+ }, 500);
134702
+ }
133878
134703
  const handlers = [];
133879
134704
  const disposeCallbacks = [];
133880
134705
  let disposed = false;
133881
134706
  let shutdownInProgress = false;
133882
- const dashboardStartedAt = Date.now();
133883
134707
  async function logShutdownDiagnostics(reason) {
133884
134708
  const uptimeSeconds = Math.round((Date.now() - dashboardStartedAt) / 1e3);
133885
134709
  let taskSummary = "tasks=unknown";
133886
134710
  try {
134711
+ if (!store) {
134712
+ taskSummary = "tasks=unavailable (store not initialized)";
134713
+ console.log(`[dashboard] shutdown requested reason=${reason} pid=${process.pid} ppid=${process.ppid} uptime=${uptimeSeconds}s ${taskSummary}`);
134714
+ return;
134715
+ }
133887
134716
  const tasks = await store.listTasks({ slim: true, includeArchived: false });
133888
134717
  const counts = /* @__PURE__ */ new Map();
133889
134718
  for (const task of tasks) {
@@ -133907,8 +134736,20 @@ async function runDashboard(port, opts = {}) {
133907
134736
  }
133908
134737
  const automationStore = new AutomationStore(cwd);
133909
134738
  await automationStore.init();
133910
- const agentStore = new AgentStore({ rootDir: store.getFusionDir() });
134739
+ agentStore = new AgentStore({ rootDir: store.getFusionDir() });
133911
134740
  await agentStore.init();
134741
+ if (tui && isTTY) {
134742
+ registerHandler(store, "task:created", scheduleStatsRefresh);
134743
+ registerHandler(store, "task:moved", scheduleStatsRefresh);
134744
+ registerHandler(store, "task:updated", scheduleStatsRefresh);
134745
+ registerHandler(store, "task:deleted", scheduleStatsRefresh);
134746
+ registerHandler(store, "settings:updated", () => {
134747
+ void refreshTUISettings();
134748
+ });
134749
+ registerHandler(agentStore, "agent:created", scheduleStatsRefresh);
134750
+ registerHandler(agentStore, "agent:updated", scheduleStatsRefresh);
134751
+ registerHandler(agentStore, "agent:deleted", scheduleStatsRefresh);
134752
+ }
133912
134753
  const pluginStore = new PluginStore(store.getFusionDir());
133913
134754
  await pluginStore.init();
133914
134755
  const pluginLoader = new PluginLoader({
@@ -133919,7 +134760,7 @@ async function runDashboard(port, opts = {}) {
133919
134760
  let triggerScheduler;
133920
134761
  if (opts.paused) {
133921
134762
  await store.updateSettings({ enginePaused: true });
133922
- console.log("[engine] Starting in paused mode \u2014 automation disabled");
134763
+ logSink.log("Starting in paused mode \u2014 automation disabled", "engine");
133923
134764
  }
133924
134765
  const onMergeImpl = (taskId) => aiMergeTask(store, cwd, taskId, {
133925
134766
  agentStore,
@@ -133964,14 +134805,14 @@ async function runDashboard(port, opts = {}) {
133964
134805
  join48(cwd, ".fusion", "disabled-auto-extension-discovery")
133965
134806
  );
133966
134807
  for (const { path: path4, error } of extensionsResult.errors) {
133967
- console.log(`[extensions] Failed to load ${path4}: ${error}`);
134808
+ logSink.log(`Failed to load ${path4}: ${error}`, "extensions");
133968
134809
  }
133969
134810
  for (const { name, config, extensionPath } of extensionsResult.runtime.pendingProviderRegistrations) {
133970
134811
  try {
133971
134812
  modelRegistry.registerProvider(name, config);
133972
134813
  } catch (error) {
133973
134814
  const message = error instanceof Error ? error.message : String(error);
133974
- console.log(`[extensions] Failed to register provider from ${extensionPath}: ${message}`);
134815
+ logSink.log(`Failed to register provider from ${extensionPath}: ${message}`, "extensions");
133975
134816
  }
133976
134817
  }
133977
134818
  extensionsResult.runtime.pendingProviderRegistrations = [];
@@ -134011,15 +134852,15 @@ async function runDashboard(port, opts = {}) {
134011
134852
  api: "openai-completions",
134012
134853
  models: orModels
134013
134854
  });
134014
- console.log(`[openrouter] Synced ${orModels.length} models from OpenRouter API`);
134855
+ logSink.log(`Synced ${orModels.length} models from OpenRouter API`, "openrouter");
134015
134856
  } catch (err) {
134016
134857
  const message = err instanceof Error ? err.message : String(err);
134017
- console.log(`[openrouter] Failed to sync models: ${message}`);
134858
+ logSink.log(`Failed to sync models: ${message}`, "openrouter");
134018
134859
  }
134019
134860
  })();
134020
134861
  } catch (error) {
134021
134862
  const message = error instanceof Error ? error.message : String(error);
134022
- console.log(`[extensions] Failed to discover extensions: ${message}`);
134863
+ logSink.log(`Failed to discover extensions: ${message}`, "extensions");
134023
134864
  createExtensionRuntime2();
134024
134865
  modelRegistry.refresh();
134025
134866
  }
@@ -134031,6 +134872,13 @@ async function runDashboard(port, opts = {}) {
134031
134872
  function dispose() {
134032
134873
  if (disposed) return;
134033
134874
  disposed = true;
134875
+ if (tuiRefreshDebounceTimer) {
134876
+ clearTimeout(tuiRefreshDebounceTimer);
134877
+ tuiRefreshDebounceTimer = null;
134878
+ }
134879
+ if (tui) {
134880
+ void tui.stop();
134881
+ }
134034
134882
  for (const { target, event, handler } of handlers) {
134035
134883
  target.off(event, handler);
134036
134884
  }
@@ -134168,10 +135016,10 @@ async function runDashboard(port, opts = {}) {
134168
135016
  taskStore: store,
134169
135017
  rootDir: cwd,
134170
135018
  onMissed: (agentId) => {
134171
- console.log(`[engine] Agent ${agentId} missed heartbeat`);
135019
+ logSink.log(`Agent ${agentId} missed heartbeat`, "engine");
134172
135020
  },
134173
135021
  onTerminated: (agentId) => {
134174
- console.log(`[engine] Agent ${agentId} terminated (unresponsive)`);
135022
+ logSink.log(`Agent ${agentId} terminated (unresponsive)`, "engine");
134175
135023
  }
134176
135024
  });
134177
135025
  heartbeatMonitorImpl.start();
@@ -134203,10 +135051,11 @@ async function runDashboard(port, opts = {}) {
134203
135051
  });
134204
135052
  }
134205
135053
  if (agents.length > 0) {
134206
- console.log(`[engine] Registered ${triggerScheduler.getRegisteredAgents().length} agents for heartbeat triggers`);
135054
+ logSink.log(`Registered ${triggerScheduler.getRegisteredAgents().length} agents for heartbeat triggers`, "engine");
134207
135055
  }
134208
135056
  } catch (err) {
134209
- console.log(`[engine] HeartbeatMonitor initialization failed (continuing without agent monitoring):`, err);
135057
+ const message = err instanceof Error ? err.message : String(err);
135058
+ logSink.log(`HeartbeatMonitor initialization failed (continuing without agent monitoring): ${message}`, "engine");
134210
135059
  }
134211
135060
  app = createServer(store, {
134212
135061
  onMerge,
@@ -134342,32 +135191,89 @@ async function runDashboard(port, opts = {}) {
134342
135191
  const displayHost = selectedHost === "0.0.0.0" || selectedHost === "::" ? selectedHost : "localhost";
134343
135192
  const baseUrl = `http://${displayHost}:${actualPort}`;
134344
135193
  const tokenizedUrl = dashboardAuthToken ? `${baseUrl}/?token=${encodeURIComponent(dashboardAuthToken)}` : baseUrl;
134345
- console.log();
134346
- console.log(` fn board`);
134347
- console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
134348
- console.log(` \u2192 ${baseUrl}`);
134349
- if (dashboardAuthToken) {
134350
- console.log(` Auth: bearer token required`);
134351
- console.log(` Token: ${dashboardAuthToken}`);
134352
- console.log(` Open: ${tokenizedUrl}`);
134353
- console.log(` (the browser stores the token so you only need to click once)`);
134354
- } else {
134355
- console.log(` Auth: disabled (--no-auth)`);
134356
- }
134357
- console.log();
134358
- console.log(` Tasks stored in .fusion/tasks/`);
134359
- console.log(` Merge: AI-assisted (conflict resolution + commit messages)`);
134360
- if (opts.dev) {
134361
- console.log(` AI engine: \u2717 disabled (dev mode)`);
135194
+ if (isTTY && tui) {
135195
+ const settings = await store.getSettings();
135196
+ const engineMode = opts.dev ? "dev" : settings.enginePaused ? "paused" : "active";
135197
+ const systemInfo = {
135198
+ host: displayHost,
135199
+ port: actualPort,
135200
+ baseUrl,
135201
+ authEnabled: Boolean(dashboardAuthToken),
135202
+ authToken: dashboardAuthToken,
135203
+ tokenizedUrl: dashboardAuthToken ? tokenizedUrl : void 0,
135204
+ engineMode,
135205
+ fileWatcher: true,
135206
+ startTimeMs: dashboardStartedAt
135207
+ };
135208
+ tui.setSystemInfo(systemInfo);
135209
+ tui.setSettings({
135210
+ maxConcurrent: settings.maxConcurrent ?? 1,
135211
+ maxWorktrees: settings.maxWorktrees ?? 2,
135212
+ autoMerge: settings.autoMerge ?? false,
135213
+ mergeStrategy: settings.mergeStrategy ?? "direct",
135214
+ pollIntervalMs: settings.pollIntervalMs ?? 6e4,
135215
+ enginePaused: settings.enginePaused ?? false,
135216
+ globalPause: settings.globalPause ?? false
135217
+ });
135218
+ const tasks = await store.listTasks({ slim: true, includeArchived: false });
135219
+ const counts = /* @__PURE__ */ new Map();
135220
+ for (const task of tasks) {
135221
+ counts.set(task.column, (counts.get(task.column) ?? 0) + 1);
135222
+ }
135223
+ const active = tasks.filter(
135224
+ (task) => task.column === "in-progress" || task.column === "in-review"
135225
+ ).length;
135226
+ const agents = await agentStore.listAgents();
135227
+ const agentStats = { idle: 0, active: 0, running: 0, error: 0 };
135228
+ for (const agent of agents) {
135229
+ const state = agent.state;
135230
+ if (state in agentStats) {
135231
+ agentStats[state]++;
135232
+ }
135233
+ }
135234
+ tui.setTaskStats({
135235
+ total: tasks.length,
135236
+ byColumn: Object.fromEntries(counts),
135237
+ active,
135238
+ agents: agentStats
135239
+ });
135240
+ tui.log(`Dashboard started at ${baseUrl}`);
135241
+ if (engineMode === "active") {
135242
+ tui.log("AI engine active");
135243
+ } else if (engineMode === "dev") {
135244
+ tui.log("AI engine disabled (dev mode)");
135245
+ } else {
135246
+ tui.log("AI engine paused");
135247
+ }
135248
+ tui.log("File watcher active");
134362
135249
  } else {
134363
- console.log(` AI engine: \u2713 active`);
134364
- console.log(` \u2022 triage: auto-specifying tasks`);
134365
- console.log(` \u2022 scheduler: dependency-aware execution`);
134366
- console.log(` \u2022 cron: scheduled task execution`);
135250
+ console.log();
135251
+ console.log(` fn board`);
135252
+ console.log(` \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500`);
135253
+ console.log(` \u2192 ${baseUrl}`);
135254
+ if (dashboardAuthToken) {
135255
+ console.log(` Auth: bearer token required`);
135256
+ console.log(` Token: ${dashboardAuthToken}`);
135257
+ console.log(` Open: ${tokenizedUrl}`);
135258
+ console.log(` (the browser stores the token so you only need to click once)`);
135259
+ } else {
135260
+ console.log(` Auth: disabled (--no-auth)`);
135261
+ }
135262
+ console.log();
135263
+ console.log(` Tasks stored in .fusion/tasks/`);
135264
+ console.log(` Merge: AI-assisted (conflict resolution + commit messages)`);
135265
+ if (opts.dev) {
135266
+ console.log(` AI engine: \u2717 disabled (dev mode)`);
135267
+ } else {
135268
+ console.log(` AI engine: \u2713 active`);
135269
+ console.log(` \u2022 triage: auto-specifying tasks`);
135270
+ console.log(` \u2022 scheduler: dependency-aware execution`);
135271
+ console.log(` \u2022 cron: scheduled task execution`);
135272
+ }
135273
+ console.log(` File watcher: \u2713 active`);
135274
+ console.log(` Press Ctrl+C to stop`);
135275
+ console.log();
134367
135276
  }
134368
- console.log(` File watcher: \u2713 active`);
134369
- console.log(` Press Ctrl+C to stop`);
134370
- console.log();
134371
135277
  });
134372
135278
  return { dispose };
134373
135279
  }
@@ -134384,6 +135290,7 @@ var init_dashboard = __esm({
134384
135290
  init_provider_auth();
134385
135291
  init_auth_paths2();
134386
135292
  init_project_context();
135293
+ init_dashboard_tui();
134387
135294
  processDiagnosticsRegistered = false;
134388
135295
  diagnosticIntervalHandle = null;
134389
135296
  DIAGNOSTIC_INTERVAL_MS = 30 * 60 * 1e3;
@@ -134400,7 +135307,7 @@ __export(node_exports, {
134400
135307
  formatBytes: () => formatBytes3,
134401
135308
  formatLastActivity: () => formatLastActivity,
134402
135309
  formatStatusBar: () => formatStatusBar,
134403
- formatUptime: () => formatUptime2,
135310
+ formatUptime: () => formatUptime3,
134404
135311
  isValidNodeName: () => isValidNodeName,
134405
135312
  maskApiKey: () => maskApiKey,
134406
135313
  runMeshStatus: () => runMeshStatus,
@@ -134413,7 +135320,7 @@ __export(node_exports, {
134413
135320
  runNodeRemove: () => runNodeRemove,
134414
135321
  runNodeShow: () => runNodeShow
134415
135322
  });
134416
- import { createInterface as createInterface2 } from "node:readline/promises";
135323
+ import { createInterface as createInterface3 } from "node:readline/promises";
134417
135324
  function maskApiKey(key) {
134418
135325
  if (!key) return "none";
134419
135326
  if (key.length < 4) return "****";
@@ -134430,7 +135337,7 @@ function formatBytes3(bytes) {
134430
135337
  if (value >= 10) return `${value.toFixed(1)} ${units[i]}`;
134431
135338
  return `${value.toFixed(2)} ${units[i]}`;
134432
135339
  }
134433
- function formatUptime2(ms) {
135340
+ function formatUptime3(ms) {
134434
135341
  if (ms < 0) return "0s";
134435
135342
  const seconds = Math.floor(ms / 1e3);
134436
135343
  const minutes = Math.floor(seconds / 60);
@@ -134608,7 +135515,7 @@ async function runNodeDisconnect(name, options = {}) {
134608
135515
  process.exit(1);
134609
135516
  }
134610
135517
  if (!options.force) {
134611
- const rl = createInterface2({ input: process.stdin, output: process.stdout });
135518
+ const rl = createInterface3({ input: process.stdin, output: process.stdout });
134612
135519
  const answer = await rl.question(`Disconnect node '${node.name}'? [y/N] `);
134613
135520
  rl.close();
134614
135521
  if (answer.trim().toLowerCase() !== "y") {
@@ -134678,7 +135585,7 @@ async function runNodeShow(name, options = {}) {
134678
135585
  console.log(` CPU Usage: ${formatStatusBar(metrics.cpuUsage)}`);
134679
135586
  console.log(` Memory: ${formatBytes3(metrics.memoryUsed)} / ${formatBytes3(metrics.memoryTotal)}`);
134680
135587
  console.log(` Storage: ${formatBytes3(metrics.storageUsed)} / ${formatBytes3(metrics.storageTotal)}`);
134681
- console.log(` Uptime: ${formatUptime2(metrics.uptime)}`);
135588
+ console.log(` Uptime: ${formatUptime3(metrics.uptime)}`);
134682
135589
  console.log(` Reported: ${formatLastActivity(metrics.reportedAt)}`);
134683
135590
  } else {
134684
135591
  console.log();
@@ -134834,7 +135741,7 @@ function formatBytes4(bytes) {
134834
135741
  if (bytes < 1024 * 1024 * 1024) return `${Math.round(bytes / (1024 * 1024))}MB`;
134835
135742
  return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}GB`;
134836
135743
  }
134837
- function formatUptime3(ms) {
135744
+ function formatUptime4(ms) {
134838
135745
  const seconds = Math.floor(ms / 1e3);
134839
135746
  const minutes = Math.floor(seconds / 60);
134840
135747
  const hours = Math.floor(minutes / 60);
@@ -134869,7 +135776,7 @@ function logDiagnostics2(prefix, dbHealthCheck) {
134869
135776
  } catch {
134870
135777
  }
134871
135778
  }
134872
- const logLine = `[${prefix}] diagnostics: uptime=${formatUptime3(uptime)} rss=${formatBytes4(mem.rss)} heap=${formatBytes4(mem.heapUsed)}/${formatBytes4(mem.heapTotal)} external=${formatBytes4(mem.external)} arrayBuffers=${formatBytes4(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}${listenerInfo}`;
135779
+ const logLine = `[${prefix}] diagnostics: uptime=${formatUptime4(uptime)} rss=${formatBytes4(mem.rss)} heap=${formatBytes4(mem.heapUsed)}/${formatBytes4(mem.heapTotal)} external=${formatBytes4(mem.external)} arrayBuffers=${formatBytes4(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}${listenerInfo}`;
134873
135780
  console.log(logLine);
134874
135781
  }
134875
135782
  function stopDiagnosticInterval2() {
@@ -134896,11 +135803,11 @@ function ensureProcessDiagnostics2() {
134896
135803
  requestCount = process._getActiveRequests?.()?.length ?? -1;
134897
135804
  } catch {
134898
135805
  }
134899
- console.log(`[serve] beforeExit code=${code} uptime=${formatUptime3(uptime)} handles=${handleCount} requests=${requestCount}`);
135806
+ console.log(`[serve] beforeExit code=${code} uptime=${formatUptime4(uptime)} handles=${handleCount} requests=${requestCount}`);
134900
135807
  });
134901
135808
  process.on("exit", (code) => {
134902
135809
  const uptime = Date.now() - serveStartTime;
134903
- console.log(`[serve] exit code=${code} uptime=${formatUptime3(uptime)}`);
135810
+ console.log(`[serve] exit code=${code} uptime=${formatUptime4(uptime)}`);
134904
135811
  });
134905
135812
  process.on("uncaughtExceptionMonitor", (error) => {
134906
135813
  console.error(`[serve] uncaught exception pid=${process.pid}: ${error.stack || error.message}`);
@@ -135335,7 +136242,7 @@ function formatBytes5(bytes) {
135335
136242
  if (bytes < 1024 * 1024 * 1024) return `${Math.round(bytes / (1024 * 1024))}MB`;
135336
136243
  return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}GB`;
135337
136244
  }
135338
- function formatUptime4(ms) {
136245
+ function formatUptime5(ms) {
135339
136246
  const seconds = Math.floor(ms / 1e3);
135340
136247
  const minutes = Math.floor(seconds / 60);
135341
136248
  const hours = Math.floor(minutes / 60);
@@ -135363,7 +136270,7 @@ function logDiagnostics3(dbHealthCheck) {
135363
136270
  dbHealth = "error";
135364
136271
  }
135365
136272
  }
135366
- const logLine = `[daemon] diagnostics: uptime=${formatUptime4(uptime)} rss=${formatBytes5(mem.rss)} heap=${formatBytes5(mem.heapUsed)}/${formatBytes5(mem.heapTotal)} external=${formatBytes5(mem.external)} arrayBuffers=${formatBytes5(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}`;
136273
+ const logLine = `[daemon] diagnostics: uptime=${formatUptime5(uptime)} rss=${formatBytes5(mem.rss)} heap=${formatBytes5(mem.heapUsed)}/${formatBytes5(mem.heapTotal)} external=${formatBytes5(mem.external)} arrayBuffers=${formatBytes5(mem.arrayBuffers)} handles=${handleCount} requests=${requestCount} db=${dbHealth}`;
135367
136274
  console.log(logLine);
135368
136275
  }
135369
136276
  function maskToken(token) {
@@ -135706,7 +136613,7 @@ __export(desktop_exports, {
135706
136613
  import { spawn as spawn4 } from "node:child_process";
135707
136614
  import { once as once2 } from "node:events";
135708
136615
  import { join as join51 } from "node:path";
135709
- import { createRequire } from "node:module";
136616
+ import { createRequire as createRequire2 } from "node:module";
135710
136617
  function runCommand(command, args, cwd) {
135711
136618
  return new Promise((resolve29, reject2) => {
135712
136619
  const child = spawn4(command, args, {
@@ -135769,7 +136676,7 @@ function resolveElectronBinary() {
135769
136676
  if (process.env.FUSION_ELECTRON_BINARY) {
135770
136677
  return process.env.FUSION_ELECTRON_BINARY;
135771
136678
  }
135772
- return require2("electron");
136679
+ return require3("electron");
135773
136680
  }
135774
136681
  function terminateProcess(child, signal = "SIGTERM") {
135775
136682
  if (!child || child.killed) {
@@ -135827,13 +136734,13 @@ async function runDesktop(options = {}) {
135827
136734
  void shutdown(code ?? 0);
135828
136735
  });
135829
136736
  }
135830
- var require2;
136737
+ var require3;
135831
136738
  var init_desktop = __esm({
135832
136739
  "src/commands/desktop.ts"() {
135833
136740
  "use strict";
135834
136741
  init_src();
135835
136742
  init_src3();
135836
- require2 = createRequire(import.meta.url);
136743
+ require3 = createRequire2(import.meta.url);
135837
136744
  }
135838
136745
  });
135839
136746
 
@@ -135866,7 +136773,7 @@ __export(task_exports, {
135866
136773
  runTaskUnpause: () => runTaskUnpause,
135867
136774
  runTaskUpdate: () => runTaskUpdate
135868
136775
  });
135869
- import { createInterface as createInterface3 } from "node:readline/promises";
136776
+ import { createInterface as createInterface4 } from "node:readline/promises";
135870
136777
  import { watchFile, unwatchFile, statSync as statSync7, existsSync as existsSync35, readFileSync as readFileSync14 } from "node:fs";
135871
136778
  import { join as join52 } from "node:path";
135872
136779
  function asLocalProjectContext(store) {
@@ -135935,7 +136842,7 @@ async function runTaskCreate(descriptionArg, attachFiles, depends, projectName)
135935
136842
  let description = descriptionArg;
135936
136843
  const projectContext = await getProjectContext(projectName);
135937
136844
  if (!description) {
135938
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
136845
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
135939
136846
  description = await rl.question("Task description: ");
135940
136847
  rl.close();
135941
136848
  }
@@ -136036,11 +136943,11 @@ async function runTaskLog(id, message, outcome, projectName) {
136036
136943
  console.log(` \u2713 ${id}: logged "${message}"`);
136037
136944
  console.log();
136038
136945
  }
136039
- function formatTimestamp3(timestamp) {
136946
+ function formatTimestamp4(timestamp) {
136040
136947
  return new Date(timestamp).toLocaleTimeString();
136041
136948
  }
136042
136949
  function formatLogEntry(entry) {
136043
- const ts = formatTimestamp3(entry.timestamp);
136950
+ const ts = formatTimestamp4(entry.timestamp);
136044
136951
  const agent = entry.agent ? `[${entry.agent.toUpperCase()}] ` : "";
136045
136952
  switch (entry.type) {
136046
136953
  case "text":
@@ -136272,7 +137179,7 @@ async function runTaskRefine(id, feedbackArg, projectName) {
136272
137179
  const store = await getStore(projectName);
136273
137180
  let feedback = feedbackArg;
136274
137181
  if (feedback === void 0) {
136275
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137182
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136276
137183
  feedback = await rl.question("What needs to be refined? ");
136277
137184
  rl.close();
136278
137185
  }
@@ -136344,7 +137251,7 @@ async function runTaskDelete(id, force, projectName) {
136344
137251
  return;
136345
137252
  }
136346
137253
  if (!force) {
136347
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137254
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136348
137255
  const answer = await rl.question(`Are you sure you want to delete ${id}? [y/N] `);
136349
137256
  rl.close();
136350
137257
  const trimmed = answer.trim().toLowerCase();
@@ -136408,7 +137315,7 @@ async function runTaskImportGitHubInteractive(ownerRepo, options = {}, projectNa
136408
137315
  console.log(` ${i + 1}. #${issue.number} ${issue.title.slice(0, 80)}${issue.title.length > 80 ? "\u2026" : ""}${status}`);
136409
137316
  }
136410
137317
  console.log();
136411
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137318
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136412
137319
  let selectedIndices = [];
136413
137320
  let validInput = false;
136414
137321
  while (!validInput) {
@@ -136551,7 +137458,7 @@ async function runTaskComment(id, message, author = "user", projectName) {
136551
137458
  const store = await getStore(projectName);
136552
137459
  let text = message;
136553
137460
  if (text === void 0) {
136554
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137461
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136555
137462
  text = await rl.question("Comment: ");
136556
137463
  rl.close();
136557
137464
  }
@@ -136594,7 +137501,7 @@ async function runTaskSteer(id, message, projectName) {
136594
137501
  const store = await getStore(projectName);
136595
137502
  let text = message;
136596
137503
  if (text === void 0) {
136597
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137504
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136598
137505
  text = await rl.question("Message: ");
136599
137506
  rl.close();
136600
137507
  }
@@ -136724,7 +137631,7 @@ async function promptText(question) {
136724
137631
  console.log(` ${question.description}`);
136725
137632
  }
136726
137633
  console.log(" (Enter your response. Type DONE on its own line when finished):\n");
136727
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137634
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136728
137635
  const lines = [];
136729
137636
  return new Promise((resolve29) => {
136730
137637
  const askLine = () => {
@@ -136758,7 +137665,7 @@ async function promptSingleSelect(question) {
136758
137665
  console.log(` ${opt.description}`);
136759
137666
  }
136760
137667
  }
136761
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137668
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136762
137669
  while (true) {
136763
137670
  const answer = await rl.question("\n Select (1-" + question.options.length + "): ");
136764
137671
  const num = parseInt(answer.trim(), 10);
@@ -136786,7 +137693,7 @@ async function promptMultiSelect(question) {
136786
137693
  console.log(` ${opt.description}`);
136787
137694
  }
136788
137695
  }
136789
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137696
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136790
137697
  while (true) {
136791
137698
  const answer = await rl.question("\n Select (comma-separated): ");
136792
137699
  const nums = answer.split(",").map((s) => parseInt(s.trim(), 10)).filter((n) => !isNaN(n));
@@ -136809,7 +137716,7 @@ async function promptConfirm(question) {
136809
137716
  if (question.description) {
136810
137717
  console.log(` ${question.description}`);
136811
137718
  }
136812
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137719
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136813
137720
  const answer = await rl.question("\n [Y/n]: ");
136814
137721
  rl.close();
136815
137722
  const trimmed = answer.trim().toLowerCase();
@@ -136874,7 +137781,7 @@ function wrapText(text, width) {
136874
137781
  async function runTaskPlan(initialPlanArg, yesFlag = false, projectName) {
136875
137782
  let initialPlan = initialPlanArg;
136876
137783
  if (!initialPlan) {
136877
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137784
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136878
137785
  console.log("\n Let's plan your task. What would you like to accomplish?\n");
136879
137786
  initialPlan = await rl.question(" Describe your idea: ");
136880
137787
  rl.close();
@@ -136975,7 +137882,7 @@ async function runTaskPlan(initialPlanArg, yesFlag = false, projectName) {
136975
137882
  displaySummary(result.data);
136976
137883
  let confirmed = yesFlag;
136977
137884
  if (!yesFlag) {
136978
- const rl = createInterface3({ input: process.stdin, output: process.stdout });
137885
+ const rl = createInterface4({ input: process.stdin, output: process.stdout });
136979
137886
  const answer = await rl.question(" Create this task? [Y/n]: ");
136980
137887
  rl.close();
136981
137888
  const trimmed = answer.trim().toLowerCase();
@@ -137459,7 +138366,7 @@ __export(git_exports, {
137459
138366
  });
137460
138367
  import { exec as exec10 } from "node:child_process";
137461
138368
  import { promisify as promisify12 } from "node:util";
137462
- import { createInterface as createInterface4 } from "node:readline/promises";
138369
+ import { createInterface as createInterface5 } from "node:readline/promises";
137463
138370
  async function resolveGitCwd(projectName) {
137464
138371
  if (projectName) {
137465
138372
  return (await resolveProject(projectName)).projectPath;
@@ -137647,7 +138554,7 @@ async function runGitPull(options = {}) {
137647
138554
  console.log();
137648
138555
  console.log(" \u26A0 Warning: You have uncommitted changes.");
137649
138556
  console.log(` Branch: ${status.branch}`);
137650
- const rl = createInterface4({ input: process.stdin, output: process.stdout });
138557
+ const rl = createInterface5({ input: process.stdin, output: process.stdout });
137651
138558
  const answer = await rl.question(" Continue with pull? [y/N] ");
137652
138559
  rl.close();
137653
138560
  const trimmed = answer.trim().toLowerCase();
@@ -137698,7 +138605,7 @@ async function runGitPush(options = {}) {
137698
138605
  }
137699
138606
  if (!options.skipConfirm) {
137700
138607
  console.log();
137701
- const rl = createInterface4({ input: process.stdin, output: process.stdout });
138608
+ const rl = createInterface5({ input: process.stdin, output: process.stdout });
137702
138609
  const answer = await rl.question(` Push branch ${status.branch} to remote? [Y/n] `);
137703
138610
  rl.close();
137704
138611
  const trimmed = answer.trim().toLowerCase();
@@ -137835,7 +138742,7 @@ var init_backup2 = __esm({
137835
138742
  // src/project-resolver.ts
137836
138743
  import { existsSync as existsSync37, statSync as statSync8 } from "node:fs";
137837
138744
  import { dirname as dirname18, resolve as resolve24, normalize as normalize4 } from "node:path";
137838
- import { createInterface as createInterface5 } from "node:readline/promises";
138745
+ import { createInterface as createInterface6 } from "node:readline/promises";
137839
138746
  async function getCentralCore() {
137840
138747
  if (!centralCoreInstance) {
137841
138748
  centralCoreInstance = new CentralCore();
@@ -137866,7 +138773,7 @@ function findKbDir(startPath) {
137866
138773
  return null;
137867
138774
  }
137868
138775
  async function promptProjectSelection(projects, message = "Select a project:") {
137869
- const rl = createInterface5({ input: process.stdin, output: process.stdout });
138776
+ const rl = createInterface6({ input: process.stdin, output: process.stdout });
137870
138777
  console.log(`
137871
138778
  ${message}`);
137872
138779
  for (let i = 0; i < projects.length; i++) {
@@ -137883,7 +138790,7 @@ async function promptProjectSelection(projects, message = "Select a project:") {
137883
138790
  }
137884
138791
  }
137885
138792
  async function promptConfirm2(message, defaultYes = false) {
137886
- const rl = createInterface5({ input: process.stdin, output: process.stdout });
138793
+ const rl = createInterface6({ input: process.stdin, output: process.stdout });
137887
138794
  const prompt = defaultYes ? "[Y/n]" : "[y/N]";
137888
138795
  const answer = await rl.question(` ${message} ${prompt}: `);
137889
138796
  rl.close();
@@ -137943,7 +138850,7 @@ Run \`fn project remove ` + match.name + "` to clean up the registry entry.",
137943
138850
  Found fn project at ${kbDir} but it's not registered.`);
137944
138851
  const shouldRegister = await promptConfirm2("Register this project now?", true);
137945
138852
  if (shouldRegister) {
137946
- const rl = createInterface5({ input: process.stdin, output: process.stdout });
138853
+ const rl = createInterface6({ input: process.stdin, output: process.stdout });
137947
138854
  const defaultName = kbDir.split("/").pop() || "unnamed";
137948
138855
  const name = await rl.question(` Project name [${defaultName}]: `);
137949
138856
  rl.close();
@@ -138104,12 +139011,12 @@ __export(mission_exports, {
138104
139011
  runMissionShow: () => runMissionShow,
138105
139012
  runSliceAdd: () => runSliceAdd
138106
139013
  });
138107
- import { createInterface as createInterface6 } from "node:readline/promises";
139014
+ import { createInterface as createInterface7 } from "node:readline/promises";
138108
139015
  async function promptForTitleAndDescription(titleArg, titlePrompt, descriptionPrompt) {
138109
139016
  let title = titleArg;
138110
139017
  let description;
138111
139018
  if (!title) {
138112
- const rl = createInterface6({ input: process.stdin, output: process.stdout });
139019
+ const rl = createInterface7({ input: process.stdin, output: process.stdout });
138113
139020
  title = await rl.question(titlePrompt);
138114
139021
  if (!title?.trim()) {
138115
139022
  rl.close();
@@ -138238,7 +139145,7 @@ async function runMissionDelete(id, force, projectName) {
138238
139145
  process.exit(1);
138239
139146
  }
138240
139147
  if (!force) {
138241
- const rl = createInterface6({ input: process.stdin, output: process.stdout });
139148
+ const rl = createInterface7({ input: process.stdin, output: process.stdout });
138242
139149
  const answer = await rl.question(`Are you sure you want to delete ${id}: "${mission.title}"? [y/N] `);
138243
139150
  rl.close();
138244
139151
  const trimmed = answer.trim().toLowerCase();
@@ -138339,7 +139246,7 @@ async function runFeatureAdd(sliceId, titleArg, descriptionArg, acceptanceCriter
138339
139246
  let description = descriptionArg?.trim() || void 0;
138340
139247
  let acceptanceCriteria = acceptanceCriteriaArg?.trim() || void 0;
138341
139248
  if (!title) {
138342
- const rl = createInterface6({ input: process.stdin, output: process.stdout });
139249
+ const rl = createInterface7({ input: process.stdin, output: process.stdout });
138343
139250
  title = await rl.question("Feature title: ");
138344
139251
  if (!title?.trim()) {
138345
139252
  rl.close();
@@ -138433,7 +139340,7 @@ __export(project_exports, {
138433
139340
  });
138434
139341
  import { resolve as resolve25, isAbsolute as isAbsolute13, relative as relative11, basename as basename11 } from "node:path";
138435
139342
  import { existsSync as existsSync38, statSync as statSync9 } from "node:fs";
138436
- import { createInterface as createInterface7 } from "node:readline/promises";
139343
+ import { createInterface as createInterface8 } from "node:readline/promises";
138437
139344
  function formatDisplayPath(projectPath) {
138438
139345
  const rel = relative11(process.cwd(), projectPath);
138439
139346
  if (rel && !rel.startsWith("..") && rel !== "") {
@@ -138554,7 +139461,7 @@ async function runProjectAdd(name, path4, options = {}) {
138554
139461
  let projectName = name;
138555
139462
  let projectPath = path4;
138556
139463
  if (!projectName || !projectPath || options.interactive) {
138557
- const rl = createInterface7({ input: process.stdin, output: process.stdout });
139464
+ const rl = createInterface8({ input: process.stdin, output: process.stdout });
138558
139465
  if (!projectPath) {
138559
139466
  const defaultPath = process.cwd();
138560
139467
  const pathInput = await rl.question(` Project path [${defaultPath}]: `);
@@ -138679,7 +139586,7 @@ async function runProjectRemove(name, options = {}) {
138679
139586
  process.exit(1);
138680
139587
  }
138681
139588
  if (!options.force) {
138682
- const rl = createInterface7({ input: process.stdin, output: process.stdout });
139589
+ const rl = createInterface8({ input: process.stdin, output: process.stdout });
138683
139590
  const answer = await rl.question(`Unregister project '${project.name}'? [y/N] `);
138684
139591
  rl.close();
138685
139592
  if (answer.trim().toLowerCase() !== "y") {
@@ -139651,7 +140558,7 @@ __export(plugin_exports, {
139651
140558
  import { existsSync as existsSync41 } from "node:fs";
139652
140559
  import { join as join55 } from "node:path";
139653
140560
  import { readFile as readFile23 } from "node:fs/promises";
139654
- import * as readline from "node:readline";
140561
+ import * as readline2 from "node:readline";
139655
140562
  async function getProjectPath6(projectName) {
139656
140563
  if (projectName) {
139657
140564
  const context = await resolveProject(projectName);
@@ -139791,7 +140698,7 @@ async function runPluginUninstall(id, options) {
139791
140698
  console.log(` This will stop and remove the plugin.`);
139792
140699
  console.log();
139793
140700
  const response = await new Promise((resolve29) => {
139794
- const rl = readline.createInterface({
140701
+ const rl = readline2.createInterface({
139795
140702
  input: process.stdin,
139796
140703
  output: process.stdout
139797
140704
  });
@@ -140309,7 +141216,7 @@ var init_native_patch = __esm({
140309
141216
 
140310
141217
  // src/bin.ts
140311
141218
  import { existsSync as existsSync44, mkdtempSync as mkdtempSync2, readFileSync as readFileSync17, symlinkSync as symlinkSync2, writeFileSync as writeFileSync6 } from "node:fs";
140312
- import { createRequire as createRequire2 } from "node:module";
141219
+ import { createRequire as createRequire3 } from "node:module";
140313
141220
  import { join as join58, dirname as dirname20 } from "node:path";
140314
141221
  import { tmpdir as tmpdir4 } from "node:os";
140315
141222
  var isBunBinary3 = typeof Bun !== "undefined" && !!Bun.embeddedFiles;
@@ -140324,8 +141231,8 @@ function configurePiPackage() {
140324
141231
  type: "module"
140325
141232
  };
140326
141233
  try {
140327
- const require3 = createRequire2(import.meta.url);
140328
- const piPackagePath = require3.resolve("@mariozechner/pi-coding-agent/package.json");
141234
+ const require4 = createRequire3(import.meta.url);
141235
+ const piPackagePath = require4.resolve("@mariozechner/pi-coding-agent/package.json");
140329
141236
  const piPackageDir = dirname20(piPackagePath);
140330
141237
  packageJson = JSON.parse(readFileSync17(piPackagePath, "utf-8"));
140331
141238
  for (const entry of ["dist", "docs", "examples", "README.md", "CHANGELOG.md"]) {