agentflow-core 0.6.2 → 0.7.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.
@@ -390,7 +390,19 @@ function discoverProcessConfig(dirs) {
390
390
  }
391
391
  if (!processName && !pidFile && !workersFile) return null;
392
392
  if (!processName) processName = "agent";
393
- return { processName, pidFile, workersFile };
393
+ let systemdUnit;
394
+ try {
395
+ const unitName = `${processName}.service`;
396
+ const result = execSync(
397
+ `systemctl --user show ${unitName} --property=LoadState --no-pager 2>/dev/null`,
398
+ { encoding: "utf8", timeout: 3e3 }
399
+ );
400
+ if (result.includes("LoadState=loaded")) {
401
+ systemdUnit = unitName;
402
+ }
403
+ } catch {
404
+ }
405
+ return { processName, pidFile, workersFile, systemdUnit };
394
406
  }
395
407
  function auditProcesses(config) {
396
408
  const pidFile = auditPidFile(config);
@@ -952,7 +964,7 @@ function flushLines(lines) {
952
964
  var prevFileCount = 0;
953
965
  var newExecCount = 0;
954
966
  var sessionStart = Date.now();
955
- var firstRender = true;
967
+ var liveRunning = false;
956
968
  var cachedAuditConfig = null;
957
969
  var cachedAuditResult = null;
958
970
  var lastAuditTime = 0;
@@ -1148,10 +1160,6 @@ function render(config) {
1148
1160
  }
1149
1161
  const termWidth = process.stdout.columns || 120;
1150
1162
  const detailWidth = Math.max(20, termWidth - 60);
1151
- if (firstRender) {
1152
- process.stdout.write("\x1B[2J");
1153
- firstRender = false;
1154
- }
1155
1163
  const L = [];
1156
1164
  writeLine(L, `${C.bold}${C.cyan}\u2554${"\u2550".repeat(70)}\u2557${C.reset}`);
1157
1165
  writeLine(
@@ -1346,6 +1354,9 @@ function startLive(argv) {
1346
1354
  console.warn(`Skipping non-existent: ${invalid.join(", ")}`);
1347
1355
  }
1348
1356
  config.dirs = valid;
1357
+ process.stdout.write("\x1B[?1049h");
1358
+ process.stdout.write("\x1B[?25l");
1359
+ liveRunning = true;
1349
1360
  render(config);
1350
1361
  let debounce = null;
1351
1362
  for (const dir of config.dirs) {
@@ -1358,8 +1369,20 @@ function startLive(argv) {
1358
1369
  }
1359
1370
  }
1360
1371
  setInterval(() => render(config), config.refreshMs);
1372
+ const cleanup = () => {
1373
+ if (liveRunning) {
1374
+ liveRunning = false;
1375
+ process.stdout.write("\x1B[?25h");
1376
+ process.stdout.write("\x1B[?1049l");
1377
+ }
1378
+ };
1361
1379
  process.on("SIGINT", () => {
1362
- console.log("\n" + C.dim + "Monitor stopped." + C.reset);
1380
+ cleanup();
1381
+ console.log(C.dim + "Monitor stopped." + C.reset);
1382
+ process.exit(0);
1383
+ });
1384
+ process.on("SIGTERM", () => {
1385
+ cleanup();
1363
1386
  process.exit(0);
1364
1387
  });
1365
1388
  }
package/dist/cli.cjs CHANGED
@@ -429,7 +429,19 @@ function discoverProcessConfig(dirs) {
429
429
  }
430
430
  if (!processName && !pidFile && !workersFile) return null;
431
431
  if (!processName) processName = "agent";
432
- return { processName, pidFile, workersFile };
432
+ let systemdUnit;
433
+ try {
434
+ const unitName = `${processName}.service`;
435
+ const result = (0, import_node_child_process.execSync)(
436
+ `systemctl --user show ${unitName} --property=LoadState --no-pager 2>/dev/null`,
437
+ { encoding: "utf8", timeout: 3e3 }
438
+ );
439
+ if (result.includes("LoadState=loaded")) {
440
+ systemdUnit = unitName;
441
+ }
442
+ } catch {
443
+ }
444
+ return { processName, pidFile, workersFile, systemdUnit };
433
445
  }
434
446
  function auditProcesses(config) {
435
447
  const pidFile = auditPidFile(config);
@@ -989,7 +1001,7 @@ function flushLines(lines) {
989
1001
  var prevFileCount = 0;
990
1002
  var newExecCount = 0;
991
1003
  var sessionStart = Date.now();
992
- var firstRender = true;
1004
+ var liveRunning = false;
993
1005
  var cachedAuditConfig = null;
994
1006
  var cachedAuditResult = null;
995
1007
  var lastAuditTime = 0;
@@ -1185,10 +1197,6 @@ function render(config) {
1185
1197
  }
1186
1198
  const termWidth = process.stdout.columns || 120;
1187
1199
  const detailWidth = Math.max(20, termWidth - 60);
1188
- if (firstRender) {
1189
- process.stdout.write("\x1B[2J");
1190
- firstRender = false;
1191
- }
1192
1200
  const L = [];
1193
1201
  writeLine(L, `${C.bold}${C.cyan}\u2554${"\u2550".repeat(70)}\u2557${C.reset}`);
1194
1202
  writeLine(
@@ -1383,6 +1391,9 @@ function startLive(argv) {
1383
1391
  console.warn(`Skipping non-existent: ${invalid.join(", ")}`);
1384
1392
  }
1385
1393
  config.dirs = valid;
1394
+ process.stdout.write("\x1B[?1049h");
1395
+ process.stdout.write("\x1B[?25l");
1396
+ liveRunning = true;
1386
1397
  render(config);
1387
1398
  let debounce = null;
1388
1399
  for (const dir of config.dirs) {
@@ -1395,8 +1406,20 @@ function startLive(argv) {
1395
1406
  }
1396
1407
  }
1397
1408
  setInterval(() => render(config), config.refreshMs);
1409
+ const cleanup = () => {
1410
+ if (liveRunning) {
1411
+ liveRunning = false;
1412
+ process.stdout.write("\x1B[?25h");
1413
+ process.stdout.write("\x1B[?1049l");
1414
+ }
1415
+ };
1398
1416
  process.on("SIGINT", () => {
1399
- console.log("\n" + C.dim + "Monitor stopped." + C.reset);
1417
+ cleanup();
1418
+ console.log(C.dim + "Monitor stopped." + C.reset);
1419
+ process.exit(0);
1420
+ });
1421
+ process.on("SIGTERM", () => {
1422
+ cleanup();
1400
1423
  process.exit(0);
1401
1424
  });
1402
1425
  }
package/dist/cli.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  startWatch,
10
10
  toAsciiTree,
11
11
  toTimeline
12
- } from "./chunk-BXZC5ZMJ.js";
12
+ } from "./chunk-5PRHVYYD.js";
13
13
  import "./chunk-DY7YHFIB.js";
14
14
 
15
15
  // src/cli.ts
package/dist/index.cjs CHANGED
@@ -878,7 +878,19 @@ function discoverProcessConfig(dirs) {
878
878
  }
879
879
  if (!processName && !pidFile && !workersFile) return null;
880
880
  if (!processName) processName = "agent";
881
- return { processName, pidFile, workersFile };
881
+ let systemdUnit;
882
+ try {
883
+ const unitName = `${processName}.service`;
884
+ const result = (0, import_node_child_process.execSync)(
885
+ `systemctl --user show ${unitName} --property=LoadState --no-pager 2>/dev/null`,
886
+ { encoding: "utf8", timeout: 3e3 }
887
+ );
888
+ if (result.includes("LoadState=loaded")) {
889
+ systemdUnit = unitName;
890
+ }
891
+ } catch {
892
+ }
893
+ return { processName, pidFile, workersFile, systemdUnit };
882
894
  }
883
895
  function auditProcesses(config) {
884
896
  const pidFile = auditPidFile(config);
@@ -1438,7 +1450,7 @@ function flushLines(lines) {
1438
1450
  var prevFileCount = 0;
1439
1451
  var newExecCount = 0;
1440
1452
  var sessionStart = Date.now();
1441
- var firstRender = true;
1453
+ var liveRunning = false;
1442
1454
  var cachedAuditConfig = null;
1443
1455
  var cachedAuditResult = null;
1444
1456
  var lastAuditTime = 0;
@@ -1634,10 +1646,6 @@ function render(config) {
1634
1646
  }
1635
1647
  const termWidth = process.stdout.columns || 120;
1636
1648
  const detailWidth = Math.max(20, termWidth - 60);
1637
- if (firstRender) {
1638
- process.stdout.write("\x1B[2J");
1639
- firstRender = false;
1640
- }
1641
1649
  const L = [];
1642
1650
  writeLine(L, `${C.bold}${C.cyan}\u2554${"\u2550".repeat(70)}\u2557${C.reset}`);
1643
1651
  writeLine(
@@ -1832,6 +1840,9 @@ function startLive(argv) {
1832
1840
  console.warn(`Skipping non-existent: ${invalid.join(", ")}`);
1833
1841
  }
1834
1842
  config.dirs = valid;
1843
+ process.stdout.write("\x1B[?1049h");
1844
+ process.stdout.write("\x1B[?25l");
1845
+ liveRunning = true;
1835
1846
  render(config);
1836
1847
  let debounce = null;
1837
1848
  for (const dir of config.dirs) {
@@ -1844,8 +1855,20 @@ function startLive(argv) {
1844
1855
  }
1845
1856
  }
1846
1857
  setInterval(() => render(config), config.refreshMs);
1858
+ const cleanup = () => {
1859
+ if (liveRunning) {
1860
+ liveRunning = false;
1861
+ process.stdout.write("\x1B[?25h");
1862
+ process.stdout.write("\x1B[?1049l");
1863
+ }
1864
+ };
1847
1865
  process.on("SIGINT", () => {
1848
- console.log("\n" + C.dim + "Monitor stopped." + C.reset);
1866
+ cleanup();
1867
+ console.log(C.dim + "Monitor stopped." + C.reset);
1868
+ process.exit(0);
1869
+ });
1870
+ process.on("SIGTERM", () => {
1871
+ cleanup();
1849
1872
  process.exit(0);
1850
1873
  });
1851
1874
  }
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  stitchTrace,
24
24
  toAsciiTree,
25
25
  toTimeline
26
- } from "./chunk-BXZC5ZMJ.js";
26
+ } from "./chunk-5PRHVYYD.js";
27
27
  import {
28
28
  graphToJson,
29
29
  loadGraph
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentflow-core",
3
- "version": "0.6.2",
3
+ "version": "0.7.0",
4
4
  "description": "Monitor any AI agent system. Auto-detects failures, sends alerts, audits OS processes. Zero config, zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",