@songsid/agend 2.1.4-beta.2 → 2.1.4-beta.20

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.
Files changed (128) hide show
  1. package/dist/agent-endpoint.js +1 -1
  2. package/dist/agent-endpoint.js.map +1 -1
  3. package/dist/backend/antigravity.d.ts +1 -0
  4. package/dist/backend/antigravity.js +4 -0
  5. package/dist/backend/antigravity.js.map +1 -1
  6. package/dist/backend/claude-code.js +23 -2
  7. package/dist/backend/claude-code.js.map +1 -1
  8. package/dist/backend/codex.d.ts +17 -0
  9. package/dist/backend/codex.js +122 -7
  10. package/dist/backend/codex.js.map +1 -1
  11. package/dist/backend/kiro.d.ts +1 -0
  12. package/dist/backend/kiro.js +14 -0
  13. package/dist/backend/kiro.js.map +1 -1
  14. package/dist/backend/opencode.d.ts +27 -11
  15. package/dist/backend/opencode.js +48 -37
  16. package/dist/backend/opencode.js.map +1 -1
  17. package/dist/backend/types.d.ts +14 -0
  18. package/dist/backend/types.js +7 -0
  19. package/dist/backend/types.js.map +1 -1
  20. package/dist/channel/adapters/discord.js +72 -25
  21. package/dist/channel/adapters/discord.js.map +1 -1
  22. package/dist/channel/adapters/telegram.js +5 -3
  23. package/dist/channel/adapters/telegram.js.map +1 -1
  24. package/dist/channel/mcp-server.js +6 -20
  25. package/dist/channel/mcp-server.js.map +1 -1
  26. package/dist/channel/mcp-tools.js +4 -2
  27. package/dist/channel/mcp-tools.js.map +1 -1
  28. package/dist/channel/types.d.ts +1 -1
  29. package/dist/classic-channel-manager.d.ts +40 -3
  30. package/dist/classic-channel-manager.js +218 -31
  31. package/dist/classic-channel-manager.js.map +1 -1
  32. package/dist/cli.js +159 -36
  33. package/dist/cli.js.map +1 -1
  34. package/dist/completion-install.d.ts +70 -0
  35. package/dist/completion-install.js +152 -0
  36. package/dist/completion-install.js.map +1 -0
  37. package/dist/completion.d.ts +7 -1
  38. package/dist/completion.js +14 -4
  39. package/dist/completion.js.map +1 -1
  40. package/dist/config-validator.js +38 -7
  41. package/dist/config-validator.js.map +1 -1
  42. package/dist/config.d.ts +2 -0
  43. package/dist/config.js +10 -1
  44. package/dist/config.js.map +1 -1
  45. package/dist/daemon.d.ts +171 -5
  46. package/dist/daemon.js +696 -82
  47. package/dist/daemon.js.map +1 -1
  48. package/dist/doctor.d.ts +26 -0
  49. package/dist/doctor.js +216 -0
  50. package/dist/doctor.js.map +1 -0
  51. package/dist/fleet-context.d.ts +14 -0
  52. package/dist/fleet-manager.d.ts +231 -10
  53. package/dist/fleet-manager.js +1798 -493
  54. package/dist/fleet-manager.js.map +1 -1
  55. package/dist/fleet-yaml-slim.d.ts +10 -0
  56. package/dist/fleet-yaml-slim.js +59 -0
  57. package/dist/fleet-yaml-slim.js.map +1 -0
  58. package/dist/general-knowledge/skills/backend-providers/SKILL.md +114 -0
  59. package/dist/general-knowledge/skills/cross-instance-messaging/SKILL.md +3 -1
  60. package/dist/general-knowledge/skills/delegation-playbook/SKILL.md +52 -0
  61. package/dist/general-knowledge/skills/development-workflow/SKILL.md +28 -0
  62. package/dist/general-knowledge/skills/fleet-config/SKILL.md +1 -0
  63. package/dist/general-knowledge/skills/fleet-health/SKILL.md +1 -0
  64. package/dist/general-knowledge/skills/fleet-restart/SKILL.md +1 -0
  65. package/dist/general-knowledge/skills/instance-lifecycle/SKILL.md +1 -0
  66. package/dist/general-knowledge/skills/model-discovery/SKILL.md +64 -16
  67. package/dist/general-knowledge/skills/multi-channel/SKILL.md +1 -0
  68. package/dist/general-knowledge/skills/scheduling/SKILL.md +1 -0
  69. package/dist/general-knowledge/skills/session-management/SKILL.md +1 -0
  70. package/dist/general-knowledge/skills/tui-effort/SKILL.md +1 -0
  71. package/dist/general-knowledge/skills/worker-collaboration/SKILL.md +30 -0
  72. package/dist/instance-lifecycle.d.ts +8 -0
  73. package/dist/instance-lifecycle.js +46 -25
  74. package/dist/instance-lifecycle.js.map +1 -1
  75. package/dist/instructions.d.ts +12 -0
  76. package/dist/instructions.js +33 -0
  77. package/dist/instructions.js.map +1 -1
  78. package/dist/locale.js +656 -220
  79. package/dist/locale.js.map +1 -1
  80. package/dist/outbound-handlers.d.ts +8 -0
  81. package/dist/outbound-handlers.js +44 -5
  82. package/dist/outbound-handlers.js.map +1 -1
  83. package/dist/outbound-schemas.d.ts +5 -0
  84. package/dist/outbound-schemas.js +7 -0
  85. package/dist/outbound-schemas.js.map +1 -1
  86. package/dist/quickstart.js +25 -0
  87. package/dist/quickstart.js.map +1 -1
  88. package/dist/restart-progress.d.ts +9 -1
  89. package/dist/restart-progress.js +30 -6
  90. package/dist/restart-progress.js.map +1 -1
  91. package/dist/scheduler/db.d.ts +5 -0
  92. package/dist/scheduler/db.js +35 -0
  93. package/dist/scheduler/db.js.map +1 -1
  94. package/dist/service-installer.d.ts +11 -0
  95. package/dist/service-installer.js +84 -18
  96. package/dist/service-installer.js.map +1 -1
  97. package/dist/settings-api.js +1 -1
  98. package/dist/settings-api.js.map +1 -1
  99. package/dist/tips.d.ts +39 -0
  100. package/dist/tips.js +351 -0
  101. package/dist/tips.js.map +1 -0
  102. package/dist/tool-progress.d.ts +40 -0
  103. package/dist/tool-progress.js +289 -0
  104. package/dist/tool-progress.js.map +1 -0
  105. package/dist/topic-commands.d.ts +28 -4
  106. package/dist/topic-commands.js +217 -65
  107. package/dist/topic-commands.js.map +1 -1
  108. package/dist/transcript-monitor.d.ts +15 -2
  109. package/dist/transcript-monitor.js +63 -17
  110. package/dist/transcript-monitor.js.map +1 -1
  111. package/dist/transcript-sources.d.ts +106 -0
  112. package/dist/transcript-sources.js +428 -0
  113. package/dist/transcript-sources.js.map +1 -0
  114. package/dist/types.d.ts +11 -0
  115. package/dist/ui/dashboard.html +55 -32
  116. package/dist/ui/settings.html +120 -51
  117. package/dist/ui/view.html +23 -15
  118. package/dist/update-marker.d.ts +30 -0
  119. package/dist/update-marker.js +71 -20
  120. package/dist/update-marker.js.map +1 -1
  121. package/dist/update-progress.d.ts +6 -0
  122. package/dist/update-progress.js +29 -0
  123. package/dist/update-progress.js.map +1 -0
  124. package/dist/usage/usage-api.d.ts +8 -2
  125. package/dist/usage/usage-api.js +24 -3
  126. package/dist/usage/usage-api.js.map +1 -1
  127. package/dist/workflow-templates/default.md +2 -1
  128. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -16,9 +16,11 @@ import { hasPausedMarker } from "./pause-marker.js";
16
16
  import { clampContextPercent, parseContextPercent } from "./context-percent.js";
17
17
  import { COMPLETION_SHELLS, completionScript } from "./completion.js";
18
18
  import { getUpdateSelector, lookupTargetVersion, reportUpdateRestart, shouldSkipUpdate, } from "./update-check.js";
19
- import { clearUpdateMarker, markUpdateInProgress } from "./update-marker.js";
19
+ import { clearUpdateMarker, markUpdateInProgress, setUpdateProgressStage } from "./update-marker.js";
20
20
  import { acquireFleetLock, releaseProcessFleetLock, setProcessFleetLock } from "./fleet-lock.js";
21
21
  import { SYSTEMD_RESTART_TIMEOUT_MS } from "./service-installer.js";
22
+ import { loadRawFleetConfig } from "./config.js";
23
+ import { setLocale, t } from "./locale.js";
22
24
  /** Prefix tmux args with -L when socket isolation is active. */
23
25
  function tmuxArgs(args) {
24
26
  const socket = getTmuxSocketName();
@@ -28,6 +30,14 @@ const __filename = fileURLToPath(import.meta.url);
28
30
  const __dirname = dirname(__filename);
29
31
  const DATA_DIR = getAgendHome();
30
32
  const FLEET_CONFIG_PATH = join(DATA_DIR, "fleet.yaml");
33
+ // CLI commands run outside FleetManager. Honor an explicit fleet locale while
34
+ // keeping the historical English CLI default when config is missing/unset.
35
+ try {
36
+ const configuredLocale = loadRawFleetConfig(FLEET_CONFIG_PATH).defaults?.locale;
37
+ if (configuredLocale === "en" || configuredLocale === "zh-TW")
38
+ setLocale(configuredLocale);
39
+ }
40
+ catch { /* malformed or missing config: keep the English CLI default */ }
31
41
  const program = new Command();
32
42
  function claimFleetSingleton() {
33
43
  try {
@@ -824,9 +834,18 @@ program
824
834
  if (check === "mcp") {
825
835
  await doctorMcp();
826
836
  }
827
- else {
837
+ else if (check) {
828
838
  console.log("Usage: agend doctor mcp");
829
839
  console.log(" mcp — Check fleet MCP health (IPC sockets, MCP configs, backends)");
840
+ process.exitCode = 2;
841
+ }
842
+ else {
843
+ const { inspectService } = await import("./service-installer.js");
844
+ const { collectDoctorReport, formatDoctorReport } = await import("./doctor.js");
845
+ const report = await collectDoctorReport(DATA_DIR, inspectService());
846
+ console.log(formatDoctorReport(report));
847
+ if (report.errors > 0)
848
+ process.exitCode = 1;
830
849
  }
831
850
  });
832
851
  async function doctorMcp() {
@@ -1157,6 +1176,7 @@ program
1157
1176
  const targetVersion = lookupTargetVersion(tag);
1158
1177
  if (shouldSkipUpdate(pkgVersion, targetVersion, opts.force)) {
1159
1178
  console.log(`\n ✓ Already up to date (v${pkgVersion})\n`);
1179
+ setUpdateProgressStage(DATA_DIR, "complete", { version: pkgVersion });
1160
1180
  return;
1161
1181
  }
1162
1182
  if (targetVersion) {
@@ -1173,10 +1193,13 @@ program
1173
1193
  // dies here does not silence real alerts.
1174
1194
  markUpdateInProgress(DATA_DIR);
1175
1195
  const failUpdate = (message) => {
1176
- clearUpdateMarker(DATA_DIR);
1196
+ if (!setUpdateProgressStage(DATA_DIR, "failed", { error: message.trim() })) {
1197
+ clearUpdateMarker(DATA_DIR);
1198
+ }
1177
1199
  console.error(message);
1178
1200
  process.exit(1);
1179
1201
  };
1202
+ setUpdateProgressStage(DATA_DIR, "downloading");
1180
1203
  // Detect and remove stale npm link (local build that shadows global install)
1181
1204
  try {
1182
1205
  const agendPath = execSync("which agend", { encoding: "utf-8", stdio: "pipe" }).trim();
@@ -1264,11 +1287,15 @@ program
1264
1287
  }
1265
1288
  const newVersion = (verifyResult.stdout ?? "").trim();
1266
1289
  console.log(` ✓ Installed: ${newVersion}`);
1290
+ setUpdateProgressStage(DATA_DIR, "installed", { version: newVersion.replace(/^v/, "") });
1267
1291
  // ── Update service file ──
1268
1292
  if (agendPath) {
1269
1293
  try {
1270
1294
  // Use the NEW binary to install service (old binary's templates may be deleted)
1271
- const installResult = spawnSync(agendPath, ["install"], { encoding: "utf-8", timeout: 15000 });
1295
+ // `agend install` activates by default. During update the existing
1296
+ // restart stage owns stop/start and progress reporting, so only refresh
1297
+ // the service file here to avoid restarting the fleet twice.
1298
+ const installResult = spawnSync(agendPath, ["install", "--no-activate"], { encoding: "utf-8", timeout: 15000 });
1272
1299
  if (installResult.status === 0) {
1273
1300
  console.log(` ✓ Service updated`);
1274
1301
  }
@@ -1280,6 +1307,20 @@ program
1280
1307
  console.log(` ⚠ Service file update failed (non-fatal): ${e.message}`);
1281
1308
  }
1282
1309
  }
1310
+ // ── Refresh installed shell completions ──
1311
+ // The completion script embeds this version's subcommand names, so a
1312
+ // previously installed static file goes stale on update. --refresh only
1313
+ // rewrites artifacts that already exist — an update never starts
1314
+ // installing completions the user didn't ask for. Run through the NEW
1315
+ // binary so the regenerated names are the new version's.
1316
+ try {
1317
+ spawnSync(agendPath, ["completion", "install", "--refresh"], {
1318
+ encoding: "utf-8",
1319
+ timeout: 15_000,
1320
+ stdio: "ignore",
1321
+ });
1322
+ }
1323
+ catch { /* cosmetic — never block an update on completion refresh */ }
1283
1324
  // ── Restart fleet ──
1284
1325
  // Run the restart through the NEWLY-INSTALLED binary (agendPath), not inline.
1285
1326
  // The inline restart would execute the OLD binary's code — exactly the logic
@@ -1287,6 +1328,7 @@ program
1287
1328
  // restart` (new binary) does the 4-environment service detection (system
1288
1329
  // systemd → user systemd → launchd → detached pid).
1289
1330
  console.log(" Restarting fleet...");
1331
+ setUpdateProgressStage(DATA_DIR, "stopping", { version: newVersion.replace(/^v/, "") });
1290
1332
  // `agend restart` may synchronously wait for a Type=notify service to finish
1291
1333
  // a multi-minute stop/start and send READY=1. Keep this parent wrapper alive
1292
1334
  // longer than the restart command's own bounded wait.
@@ -1298,7 +1340,9 @@ program
1298
1340
  if (!reportUpdateRestart(restartResult.status)) {
1299
1341
  // No new fleet is coming up to clear the marker — do it here, or the next
1300
1342
  // 15 minutes of genuine crashes would go unreported.
1301
- clearUpdateMarker(DATA_DIR);
1343
+ if (!setUpdateProgressStage(DATA_DIR, "failed", { error: "fleet restart failed" })) {
1344
+ clearUpdateMarker(DATA_DIR);
1345
+ }
1302
1346
  process.exitCode = 1;
1303
1347
  }
1304
1348
  });
@@ -1324,8 +1368,9 @@ program
1324
1368
  // === Install/Uninstall ===
1325
1369
  program
1326
1370
  .command("install")
1327
- .description("Install as system service")
1328
- .option("--activate", "Stop manual fleet and load the service immediately")
1371
+ .description(t("install.description"))
1372
+ .option("--activate", "Deprecated; service activation is now the default")
1373
+ .option("--no-activate", "Write the service file without activating it")
1329
1374
  .action(async (opts) => {
1330
1375
  const { installService, activateService, detectPlatform } = await import("./service-installer.js");
1331
1376
  const execPath = process.argv[1];
@@ -1336,33 +1381,81 @@ program
1336
1381
  workingDirectory: DATA_DIR,
1337
1382
  logPath: join(DATA_DIR, "fleet.log"),
1338
1383
  });
1339
- console.log(`Service installed at: ${svcPath}`);
1340
- if (opts.activate) {
1384
+ console.log(t("install.path", svcPath));
1385
+ if (opts.activate !== false) {
1341
1386
  const pidPath = join(DATA_DIR, "fleet.pid");
1342
- activateService(svcPath, pidPath);
1343
- console.log("Service activated.");
1344
- }
1345
- else {
1346
- const plat = detectPlatform();
1347
- if (plat === "macos") {
1348
- console.log(`Run: launchctl load ${svcPath}`);
1387
+ try {
1388
+ activateService(svcPath, pidPath);
1389
+ console.log(t("install.running"));
1349
1390
  }
1350
- else {
1351
- console.log(`Run: systemctl --user enable --now com.agend.fleet`);
1391
+ catch (err) {
1392
+ console.error(t("install.start_failed", err.message));
1393
+ const plat = detectPlatform();
1394
+ if (plat === "macos") {
1395
+ console.error(`Run manually: launchctl load ${svcPath}`);
1396
+ }
1397
+ else {
1398
+ console.error("Run manually: systemctl --user daemon-reload && systemctl --user enable --now com.agend.fleet");
1399
+ }
1400
+ process.exitCode = 1;
1352
1401
  }
1353
1402
  }
1403
+ else {
1404
+ console.log(t("install.updated"));
1405
+ }
1354
1406
  });
1355
1407
  program
1356
1408
  .command("uninstall")
1357
- .description("Remove system service")
1358
- .action(async () => {
1359
- const { uninstallService } = await import("./service-installer.js");
1360
- const removed = uninstallService("com.agend.fleet");
1361
- if (removed) {
1362
- console.log("Service uninstalled");
1409
+ .description(t("uninstall.description"))
1410
+ .option("-f, --force", t("uninstall.force_help"))
1411
+ .action(async (opts) => {
1412
+ const { inspectService, isServiceRemovalConfirmed, uninstallService } = await import("./service-installer.js");
1413
+ const service = inspectService("com.agend.fleet");
1414
+ if (!service.installed) {
1415
+ console.log(t("uninstall.none"));
1416
+ return;
1363
1417
  }
1364
- else {
1365
- console.log("No service found to uninstall");
1418
+ const state = (value, yes, no) => value == null ? t("uninstall.unknown") : value ? yes : no;
1419
+ console.log(t("uninstall.found"));
1420
+ console.log(` ${t("uninstall.manager", service.manager ?? t("uninstall.unknown"))}`);
1421
+ console.log(` ${t("uninstall.path", service.path ?? t("uninstall.unknown"))}`);
1422
+ console.log(` ${t("uninstall.enabled", state(service.enabled, t("uninstall.yes"), t("uninstall.no")))}`);
1423
+ console.log(` ${t("uninstall.active", state(service.active, t("uninstall.running"), t("uninstall.inactive")))}`);
1424
+ if (!opts.force && !process.stdin.isTTY) {
1425
+ console.log(t("uninstall.non_interactive"));
1426
+ process.exitCode = 1;
1427
+ return;
1428
+ }
1429
+ if (!opts.force) {
1430
+ const { createInterface } = await import("node:readline/promises");
1431
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
1432
+ let answer = "";
1433
+ try {
1434
+ answer = await rl.question(t("uninstall.confirm"));
1435
+ }
1436
+ catch {
1437
+ console.log(t("uninstall.cancelled_force"));
1438
+ return;
1439
+ }
1440
+ finally {
1441
+ rl.close();
1442
+ }
1443
+ if (!isServiceRemovalConfirmed(answer)) {
1444
+ console.log(t("uninstall.cancelled"));
1445
+ return;
1446
+ }
1447
+ }
1448
+ try {
1449
+ if (uninstallService("com.agend.fleet")) {
1450
+ console.log(t("uninstall.removed"));
1451
+ }
1452
+ else {
1453
+ console.log(t("uninstall.none"));
1454
+ }
1455
+ }
1456
+ catch (err) {
1457
+ console.error(t("uninstall.failed", err.message));
1458
+ process.exitCode = 1;
1366
1459
  }
1367
1460
  });
1368
1461
  program
@@ -2380,29 +2473,59 @@ program
2380
2473
  });
2381
2474
  program
2382
2475
  .command("completion")
2383
- .description("Print a shell completion script (bash or zsh)")
2384
- .argument("<shell>", `Shell to generate for (${COMPLETION_SHELLS.join(", ")})`)
2476
+ .description("Print a shell completion script, or install it (bash or zsh)")
2477
+ .argument("<target>", `"install", or a shell to print for (${COMPLETION_SHELLS.join(", ")})`)
2478
+ .argument("[shell]", "with install: limit to one shell (default: detect)")
2479
+ .option("--modify-rc", "with install: authorize adding the zsh eval line to ~/.zshrc")
2480
+ .option("--refresh", "with install: only rewrite artifacts that already exist (used by agend update)")
2385
2481
  .addHelpText("after", `
2386
- Install:
2482
+ Recommended:
2483
+ agend completion install # bash: static file, no rc edit; zsh: prints what to do
2484
+ agend completion install --modify-rc # also add the zsh line to ~/.zshrc
2485
+
2486
+ Manual (fallback):
2387
2487
  bash echo 'eval "$(agend completion bash)"' >> ~/.bashrc
2388
2488
  zsh echo 'eval "$(agend completion zsh)"' >> ~/.zshrc
2389
2489
 
2390
2490
  Then reload the shell. Tab-completes instance names for \`agend attach\` and
2391
2491
  \`agend fleet start|stop|restart\`, and subcommands elsewhere.`)
2392
- .action((shell) => {
2393
- if (!COMPLETION_SHELLS.includes(shell)) {
2394
- console.error(`Unsupported shell: ${shell}. Supported: ${COMPLETION_SHELLS.join(", ")}`);
2395
- process.exit(2);
2396
- }
2492
+ .action(async (target, shellArg, opts) => {
2397
2493
  // Subcommand names come from commander itself, so the script can't drift
2398
2494
  // out of sync with the CLI the way a hardcoded list would.
2399
2495
  const fleetCmd = program.commands.find(c => c.name() === "fleet");
2400
- console.log(completionScript(shell, {
2496
+ const spec = {
2401
2497
  topLevel: program.commands.map(c => c.name()),
2402
2498
  fleetSub: fleetCmd?.commands.map(c => c.name()) ?? [],
2403
2499
  instanceCommands: ["attach"],
2404
2500
  fleetInstanceCommands: ["start", "stop", "restart"],
2405
- }));
2501
+ };
2502
+ if (target === "install") {
2503
+ const { detectShells, installCompletions } = await import("./completion-install.js");
2504
+ const { zshCompletion } = await import("./completion.js");
2505
+ if (shellArg && !COMPLETION_SHELLS.includes(shellArg)) {
2506
+ console.error(`Unsupported shell: ${shellArg}. Supported: ${COMPLETION_SHELLS.join(", ")}`);
2507
+ process.exit(2);
2508
+ }
2509
+ const shells = shellArg ? [shellArg] : detectShells();
2510
+ if (shells.length === 0) {
2511
+ console.log(" No bash or zsh detected — nothing to install.");
2512
+ return;
2513
+ }
2514
+ const results = installCompletions({ bash: completionScript("bash", spec), zshFpath: zshCompletion(spec, "fpath") }, shells, { modifyRc: opts.modifyRc, refresh: opts.refresh });
2515
+ for (const r of results) {
2516
+ if (r.status === "hint")
2517
+ console.log(` ${r.shell}: ${r.hint}`);
2518
+ else if (r.status === "skipped") { /* refresh mode, nothing was installed before */ }
2519
+ else
2520
+ console.log(` ${r.shell}: completion ${r.status}${r.path ? ` (${r.path})` : ""}`);
2521
+ }
2522
+ return;
2523
+ }
2524
+ if (!COMPLETION_SHELLS.includes(target)) {
2525
+ console.error(`Unsupported target: ${target}. Supported: install, ${COMPLETION_SHELLS.join(", ")}`);
2526
+ process.exit(2);
2527
+ }
2528
+ console.log(completionScript(target, spec));
2406
2529
  });
2407
2530
  program
2408
2531
  .command("health").description("Fleet health check — shows problems and diagnostics")