@phnx-labs/agents-cli 1.20.71 → 1.20.73

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 (238) hide show
  1. package/CHANGELOG.md +325 -1
  2. package/README.md +40 -4
  3. package/dist/bin/agents +0 -0
  4. package/dist/commands/activity.d.ts +12 -0
  5. package/dist/commands/activity.js +68 -0
  6. package/dist/commands/apply.d.ts +13 -0
  7. package/dist/commands/apply.js +28 -3
  8. package/dist/commands/browser.js +1 -1
  9. package/dist/commands/cloud.js +21 -11
  10. package/dist/commands/commands.js +2 -0
  11. package/dist/commands/doctor.js +8 -4
  12. package/dist/commands/events.d.ts +11 -10
  13. package/dist/commands/events.js +30 -21
  14. package/dist/commands/exec.d.ts +34 -0
  15. package/dist/commands/exec.js +337 -39
  16. package/dist/commands/feed.d.ts +13 -0
  17. package/dist/commands/feed.js +130 -29
  18. package/dist/commands/hq.d.ts +2 -0
  19. package/dist/commands/hq.js +58 -0
  20. package/dist/commands/lease.d.ts +19 -0
  21. package/dist/commands/lease.js +138 -11
  22. package/dist/commands/login.d.ts +2 -0
  23. package/dist/commands/login.js +123 -0
  24. package/dist/commands/logs.js +39 -10
  25. package/dist/commands/mcp.js +2 -0
  26. package/dist/commands/mine.d.ts +27 -0
  27. package/dist/commands/mine.js +207 -0
  28. package/dist/commands/monitors.js +79 -49
  29. package/dist/commands/plugins.js +1 -0
  30. package/dist/commands/profiles.js +158 -0
  31. package/dist/commands/repo.js +2 -60
  32. package/dist/commands/resource-view.d.ts +2 -0
  33. package/dist/commands/resource-view.js +8 -0
  34. package/dist/commands/resources.d.ts +5 -0
  35. package/dist/commands/resources.js +95 -0
  36. package/dist/commands/routines.d.ts +2 -0
  37. package/dist/commands/routines.js +139 -37
  38. package/dist/commands/secrets.js +234 -47
  39. package/dist/commands/send.d.ts +15 -0
  40. package/dist/commands/send.js +62 -0
  41. package/dist/commands/sessions-tail.d.ts +1 -0
  42. package/dist/commands/sessions-tail.js +20 -9
  43. package/dist/commands/sessions.d.ts +6 -0
  44. package/dist/commands/sessions.js +26 -3
  45. package/dist/commands/setup-mine.d.ts +18 -0
  46. package/dist/commands/setup-mine.js +106 -0
  47. package/dist/commands/setup-share.js +2 -2
  48. package/dist/commands/setup.js +3 -1
  49. package/dist/commands/share.d.ts +8 -1
  50. package/dist/commands/share.js +122 -37
  51. package/dist/commands/skills.js +2 -0
  52. package/dist/commands/ssh.d.ts +9 -0
  53. package/dist/commands/ssh.js +196 -26
  54. package/dist/commands/status.js +8 -2
  55. package/dist/commands/subagents.js +3 -1
  56. package/dist/commands/sync.js +1 -1
  57. package/dist/commands/teams.js +11 -2
  58. package/dist/commands/uninstall.d.ts +11 -0
  59. package/dist/commands/uninstall.js +158 -0
  60. package/dist/commands/utils.d.ts +29 -0
  61. package/dist/commands/utils.js +24 -0
  62. package/dist/commands/versions.js +120 -11
  63. package/dist/index.js +83 -12
  64. package/dist/lib/activity.d.ts +124 -0
  65. package/dist/lib/activity.js +542 -0
  66. package/dist/lib/agents.js +16 -5
  67. package/dist/lib/artifact-actions.d.ts +1 -1
  68. package/dist/lib/artifact-actions.js +1 -1
  69. package/dist/lib/ask-classifier.d.ts +2 -1
  70. package/dist/lib/ask-classifier.js +3 -3
  71. package/dist/lib/auth-health.d.ts +32 -4
  72. package/dist/lib/auth-health.js +40 -1
  73. package/dist/lib/auto-pull.js +8 -1
  74. package/dist/lib/brand.d.ts +40 -0
  75. package/dist/lib/brand.js +122 -0
  76. package/dist/lib/browser/drivers/ssh.js +4 -7
  77. package/dist/lib/browser/service.js +6 -8
  78. package/dist/lib/channels/providers/index.d.ts +2 -0
  79. package/dist/lib/channels/providers/index.js +20 -0
  80. package/dist/lib/channels/providers/mailbox.d.ts +2 -0
  81. package/dist/lib/channels/providers/mailbox.js +26 -0
  82. package/dist/lib/channels/providers/openclaw-telegram.d.ts +2 -0
  83. package/dist/lib/channels/providers/openclaw-telegram.js +34 -0
  84. package/dist/lib/channels/providers/rush.d.ts +6 -0
  85. package/dist/lib/channels/providers/rush.js +55 -0
  86. package/dist/lib/channels/registry.d.ts +42 -0
  87. package/dist/lib/channels/registry.js +20 -0
  88. package/dist/lib/channels/resolve.d.ts +11 -0
  89. package/dist/lib/channels/resolve.js +12 -0
  90. package/dist/lib/cli-resources.d.ts +18 -0
  91. package/dist/lib/cli-resources.js +53 -4
  92. package/dist/lib/cloud/codex.js +6 -3
  93. package/dist/lib/cloud/factory.d.ts +1 -0
  94. package/dist/lib/cloud/factory.js +10 -4
  95. package/dist/lib/cloud/rush.d.ts +3 -1
  96. package/dist/lib/cloud/rush.js +6 -1
  97. package/dist/lib/cloud/types.d.ts +2 -0
  98. package/dist/lib/codex-home.d.ts +35 -0
  99. package/dist/lib/codex-home.js +136 -0
  100. package/dist/lib/crabbox/cli.d.ts +44 -0
  101. package/dist/lib/crabbox/cli.js +120 -20
  102. package/dist/lib/crabbox/lease.d.ts +52 -1
  103. package/dist/lib/crabbox/lease.js +117 -16
  104. package/dist/lib/crabbox/progress.d.ts +31 -0
  105. package/dist/lib/crabbox/progress.js +76 -0
  106. package/dist/lib/crabbox/runtimes.d.ts +4 -0
  107. package/dist/lib/crabbox/runtimes.js +33 -8
  108. package/dist/lib/crabbox/setup-copy.d.ts +87 -0
  109. package/dist/lib/crabbox/setup-copy.js +127 -0
  110. package/dist/lib/daemon.d.ts +14 -5
  111. package/dist/lib/daemon.js +52 -9
  112. package/dist/lib/drive-sync.js +6 -3
  113. package/dist/lib/event-stream.d.ts +36 -0
  114. package/dist/lib/event-stream.js +68 -0
  115. package/dist/lib/events.d.ts +1 -1
  116. package/dist/lib/exec.d.ts +11 -0
  117. package/dist/lib/exec.js +23 -2
  118. package/dist/lib/feed-policy.d.ts +1 -1
  119. package/dist/lib/feed-policy.js +14 -9
  120. package/dist/lib/feed-ranking.d.ts +32 -0
  121. package/dist/lib/feed-ranking.js +224 -0
  122. package/dist/lib/feed.d.ts +35 -2
  123. package/dist/lib/feed.js +66 -3
  124. package/dist/lib/fleet/auth-sync.d.ts +53 -0
  125. package/dist/lib/fleet/auth-sync.js +92 -0
  126. package/dist/lib/fleet/remote-login.d.ts +187 -0
  127. package/dist/lib/fleet/remote-login.js +556 -0
  128. package/dist/lib/format.d.ts +30 -3
  129. package/dist/lib/format.js +34 -5
  130. package/dist/lib/fs-atomic.d.ts +7 -2
  131. package/dist/lib/fs-atomic.js +8 -12
  132. package/dist/lib/git.d.ts +16 -0
  133. package/dist/lib/git.js +79 -2
  134. package/dist/lib/heal.js +11 -3
  135. package/dist/lib/hosts/logs.d.ts +12 -0
  136. package/dist/lib/hosts/logs.js +18 -0
  137. package/dist/lib/hosts/progress.d.ts +28 -10
  138. package/dist/lib/hosts/progress.js +79 -22
  139. package/dist/lib/hosts/remote-cmd.js +4 -0
  140. package/dist/lib/hq/floor.d.ts +87 -0
  141. package/dist/lib/hq/floor.js +226 -0
  142. package/dist/lib/menubar/install-menubar.js +14 -20
  143. package/dist/lib/notify.d.ts +1 -0
  144. package/dist/lib/notify.js +3 -3
  145. package/dist/lib/open-url.d.ts +2 -0
  146. package/dist/lib/open-url.js +19 -0
  147. package/dist/lib/openclaw-keychain.d.ts +56 -0
  148. package/dist/lib/openclaw-keychain.js +236 -0
  149. package/dist/lib/overdue.js +10 -0
  150. package/dist/lib/permissions.d.ts +44 -1
  151. package/dist/lib/permissions.js +284 -7
  152. package/dist/lib/project-launch.d.ts +6 -12
  153. package/dist/lib/project-launch.js +13 -228
  154. package/dist/lib/project-resources.d.ts +7 -0
  155. package/dist/lib/project-resources.js +291 -0
  156. package/dist/lib/pty-client.d.ts +27 -0
  157. package/dist/lib/pty-client.js +136 -10
  158. package/dist/lib/refresh.js +14 -10
  159. package/dist/lib/resource-profiles.d.ts +26 -0
  160. package/dist/lib/resource-profiles.js +157 -0
  161. package/dist/lib/resources/permissions.js +7 -1
  162. package/dist/lib/resources/types.d.ts +1 -1
  163. package/dist/lib/resources.d.ts +1 -1
  164. package/dist/lib/resources.js +32 -3
  165. package/dist/lib/routines.d.ts +11 -0
  166. package/dist/lib/routines.js +56 -15
  167. package/dist/lib/runner.d.ts +1 -0
  168. package/dist/lib/runner.js +66 -5
  169. package/dist/lib/secrets/bundles.d.ts +16 -3
  170. package/dist/lib/secrets/bundles.js +206 -37
  171. package/dist/lib/secrets/icloud-import.d.ts +2 -2
  172. package/dist/lib/secrets/icloud-import.js +9 -6
  173. package/dist/lib/secrets/mcp.js +1 -1
  174. package/dist/lib/secrets/vault-age-helper.d.ts +1 -0
  175. package/dist/lib/secrets/vault-age-helper.js +34 -0
  176. package/dist/lib/secrets/vault.d.ts +49 -0
  177. package/dist/lib/secrets/vault.js +397 -0
  178. package/dist/lib/self-heal/checks/path.js +3 -1
  179. package/dist/lib/self-heal/checks/shadowing.js +10 -2
  180. package/dist/lib/self-heal/checks/shims.js +19 -11
  181. package/dist/lib/session/cloud.d.ts +2 -2
  182. package/dist/lib/session/cloud.js +2 -2
  183. package/dist/lib/session/db.d.ts +4 -0
  184. package/dist/lib/session/db.js +44 -7
  185. package/dist/lib/session/discover.d.ts +2 -0
  186. package/dist/lib/session/discover.js +114 -3
  187. package/dist/lib/session/stream-render.d.ts +3 -0
  188. package/dist/lib/session/stream-render.js +130 -0
  189. package/dist/lib/session/types.d.ts +6 -0
  190. package/dist/lib/share/analytics.d.ts +13 -0
  191. package/dist/lib/share/analytics.js +45 -0
  192. package/dist/lib/share/config.d.ts +19 -5
  193. package/dist/lib/share/config.js +44 -8
  194. package/dist/lib/share/provision.d.ts +58 -6
  195. package/dist/lib/share/provision.js +97 -22
  196. package/dist/lib/share/publish.d.ts +36 -13
  197. package/dist/lib/share/publish.js +55 -8
  198. package/dist/lib/share/worker-template.js +83 -17
  199. package/dist/lib/shims.d.ts +36 -0
  200. package/dist/lib/shims.js +120 -16
  201. package/dist/lib/ssh-exec.d.ts +14 -0
  202. package/dist/lib/ssh-exec.js +57 -0
  203. package/dist/lib/staleness/detectors/hooks.js +25 -1
  204. package/dist/lib/staleness/detectors/permissions.js +66 -0
  205. package/dist/lib/staleness/detectors/workflows.js +20 -0
  206. package/dist/lib/staleness/writers/hooks.js +58 -4
  207. package/dist/lib/staleness/writers/permissions.js +2 -2
  208. package/dist/lib/staleness/writers/skills.js +1 -1
  209. package/dist/lib/staleness/writers/sources.d.ts +10 -1
  210. package/dist/lib/staleness/writers/sources.js +68 -1
  211. package/dist/lib/star-nudge.d.ts +45 -0
  212. package/dist/lib/star-nudge.js +91 -0
  213. package/dist/lib/startup/command-registry.d.ts +7 -1
  214. package/dist/lib/startup/command-registry.js +19 -3
  215. package/dist/lib/state.d.ts +2 -0
  216. package/dist/lib/state.js +3 -0
  217. package/dist/lib/subagents-registry.d.ts +2 -0
  218. package/dist/lib/subagents-registry.js +3 -0
  219. package/dist/lib/teams/parsers.js +214 -6
  220. package/dist/lib/teams/supervisor.d.ts +7 -0
  221. package/dist/lib/teams/supervisor.js +2 -1
  222. package/dist/lib/template.d.ts +1 -1
  223. package/dist/lib/template.js +1 -1
  224. package/dist/lib/triggers/webhook.js +36 -3
  225. package/dist/lib/types.d.ts +73 -0
  226. package/dist/lib/uninstall.d.ts +84 -0
  227. package/dist/lib/uninstall.js +347 -0
  228. package/dist/lib/usage.d.ts +13 -1
  229. package/dist/lib/usage.js +32 -14
  230. package/dist/lib/version.d.ts +40 -0
  231. package/dist/lib/version.js +94 -16
  232. package/dist/lib/versions.d.ts +27 -0
  233. package/dist/lib/versions.js +248 -79
  234. package/dist/lib/workflows.d.ts +2 -0
  235. package/dist/lib/workflows.js +88 -0
  236. package/package.json +2 -1
  237. package/dist/commands/daemon.d.ts +0 -10
  238. package/dist/commands/daemon.js +0 -121
@@ -376,6 +376,7 @@ function containsFlowDiagram(content) {
376
376
  return /```(?:mermaid|d2)\b/i.test(content);
377
377
  }
378
378
  const KIMI_WORKFLOW_MARKER = 'agents_workflow';
379
+ const OPENCLAW_WORKFLOW_MARKER_ENV = 'AGENTS_CLI_WORKFLOW';
379
380
  /** Convert a canonical agents-cli workflow bundle into a Kimi flow skill. */
380
381
  export function transformWorkflowForKimi(workflowPath, name) {
381
382
  const fm = parseWorkflowFrontmatter(workflowPath);
@@ -414,6 +415,35 @@ export function transformWorkflowForAntigravity(workflowPath, name) {
414
415
  }).trim();
415
416
  return `---\n${frontmatter}\n---\n\n${body.trim()}\n`;
416
417
  }
418
+ /** Convert a canonical agents-cli workflow bundle into an OpenClaw Lobster file. */
419
+ export function transformWorkflowForOpenClaw(workflowPath, name) {
420
+ const fm = parseWorkflowFrontmatter(workflowPath);
421
+ if (!fm)
422
+ throw new Error(`Invalid WORKFLOW.md in ${workflowPath}`);
423
+ const body = getWorkflowBody(workflowPath) || fm.description || name;
424
+ return yaml.stringify({
425
+ name: fm.name || name,
426
+ args: {
427
+ agent: {
428
+ default: 'main',
429
+ },
430
+ prompt: {
431
+ default: '',
432
+ },
433
+ },
434
+ env: {
435
+ [OPENCLAW_WORKFLOW_MARKER_ENV]: name,
436
+ AGENTS_WORKFLOW_DESCRIPTION: fm.description || name,
437
+ AGENTS_WORKFLOW_BODY: body.trim(),
438
+ },
439
+ steps: [
440
+ {
441
+ id: 'run_openclaw',
442
+ command: 'openclaw agent --agent "$LOBSTER_ARG_AGENT" --message "$(printf \'%s\\n\\n%s\\n\' "$AGENTS_WORKFLOW_BODY" "$LOBSTER_ARG_PROMPT")"',
443
+ },
444
+ ],
445
+ });
446
+ }
417
447
  function expandWorkflowPath(ref) {
418
448
  if (ref === '~')
419
449
  return process.env.HOME ?? ref;
@@ -590,6 +620,8 @@ function workflowTargetRoot(agent, versionHome) {
590
620
  return path.join(versionHome, '.kimi-code', 'skills');
591
621
  if (agent === 'antigravity')
592
622
  return antigravityWorkflowsDir();
623
+ if (agent === 'openclaw')
624
+ return path.join(versionHome, '.openclaw', 'workflows');
593
625
  return path.join(versionHome, 'workflows');
594
626
  }
595
627
  /** List workflow names synced into a specific agent version home. */
@@ -630,6 +662,20 @@ export function listWorkflowsForAgent(agent, versionHome) {
630
662
  return [];
631
663
  }
632
664
  }
665
+ if (agent === 'openclaw') {
666
+ const dir = workflowTargetRoot(agent, versionHome);
667
+ if (!fs.existsSync(dir))
668
+ return [];
669
+ try {
670
+ return fs.readdirSync(dir, { withFileTypes: true })
671
+ .filter(d => d.isFile() && d.name.endsWith('.lobster') && !d.name.startsWith('.'))
672
+ .map(d => d.name.slice(0, -'.lobster'.length))
673
+ .filter(base => openclawWorkflowMarker(path.join(dir, `${base}.lobster`)) === base);
674
+ }
675
+ catch {
676
+ return [];
677
+ }
678
+ }
633
679
  const workflowsDir = workflowTargetRoot(agent, versionHome);
634
680
  if (!fs.existsSync(workflowsDir))
635
681
  return [];
@@ -764,6 +810,19 @@ export function syncWorkflowToVersion(workflowPath, name, agent, versionHome) {
764
810
  fs.writeFileSync(targetFile, transformWorkflowForAntigravity(workflowPath, name), 'utf-8');
765
811
  return { success: true };
766
812
  }
813
+ if (agent === 'openclaw') {
814
+ const targetDir = workflowTargetRoot(agent, versionHome);
815
+ const targetFile = path.join(targetDir, `${name}.lobster`);
816
+ if (fs.existsSync(targetFile)) {
817
+ const marker = openclawWorkflowMarker(targetFile);
818
+ if (marker !== name) {
819
+ return { success: false, error: `OpenClaw workflow '${name}' already exists and is not managed by agents-cli` };
820
+ }
821
+ }
822
+ fs.mkdirSync(targetDir, { recursive: true });
823
+ fs.writeFileSync(targetFile, transformWorkflowForOpenClaw(workflowPath, name), 'utf-8');
824
+ return { success: true };
825
+ }
767
826
  const targetDir = path.join(workflowTargetRoot(agent, versionHome), name);
768
827
  fs.mkdirSync(workflowTargetRoot(agent, versionHome), { recursive: true });
769
828
  if (fs.existsSync(targetDir)) {
@@ -812,6 +871,22 @@ export function removeWorkflowFromVersion(agent, version, name) {
812
871
  return { success: false, error: err.message };
813
872
  }
814
873
  }
874
+ if (agent === 'openclaw') {
875
+ const targetFile = path.join(workflowTargetRoot(agent, versionHome), `${name}.lobster`);
876
+ if (!fs.existsSync(targetFile)) {
877
+ return { success: false, error: `Workflow '${name}' not synced to ${agent}@${version}` };
878
+ }
879
+ if (openclawWorkflowMarker(targetFile) !== name) {
880
+ return { success: false, error: `OpenClaw workflow '${name}' is not managed by agents-cli` };
881
+ }
882
+ try {
883
+ fs.rmSync(targetFile, { force: true });
884
+ return { success: true };
885
+ }
886
+ catch (err) {
887
+ return { success: false, error: err.message };
888
+ }
889
+ }
815
890
  const targetPath = path.join(workflowTargetRoot(agent, versionHome), name);
816
891
  if (!fs.existsSync(targetPath)) {
817
892
  return { success: false, error: `Workflow '${name}' not synced to ${agent}@${version}` };
@@ -860,6 +935,19 @@ function antigravityWorkflowMarker(filePath) {
860
935
  return null;
861
936
  }
862
937
  }
938
+ function openclawWorkflowMarker(filePath) {
939
+ try {
940
+ const parsed = yaml.parse(fs.readFileSync(filePath, 'utf-8'));
941
+ if (!parsed || typeof parsed !== 'object' || !parsed.env || typeof parsed.env !== 'object' || Array.isArray(parsed.env)) {
942
+ return null;
943
+ }
944
+ const marker = parsed.env[OPENCLAW_WORKFLOW_MARKER_ENV];
945
+ return typeof marker === 'string' ? marker : null;
946
+ }
947
+ catch {
948
+ return null;
949
+ }
950
+ }
863
951
  /** Iterate all installed (agent, version) pairs that support workflows. */
864
952
  export function iterWorkflowsCapableVersions(filter) {
865
953
  const result = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.20.71",
3
+ "version": "1.20.73",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -89,6 +89,7 @@
89
89
  "@types/proper-lockfile": "4.1.4",
90
90
  "@xterm/headless": "6.0.0",
91
91
  "@zed-industries/agent-client-protocol": "0.4.5",
92
+ "age-encryption": "0.3.0",
92
93
  "aws4fetch": "1.0.20",
93
94
  "chalk": "5.6.2",
94
95
  "commander": "15.0.0",
@@ -1,10 +0,0 @@
1
- /**
2
- * Deprecated daemon commands.
3
- *
4
- * Registers the hidden `agents daemon` command tree as backward-compatible
5
- * aliases for `agents routines` scheduler lifecycle commands. Scheduled
6
- * for removal in v2.0.
7
- */
8
- import type { Command } from 'commander';
9
- /** Register the deprecated `agents daemon` command tree. */
10
- export declare function registerDaemonCommands(program: Command): void;
@@ -1,121 +0,0 @@
1
- /**
2
- * Deprecated daemon commands.
3
- *
4
- * Registers the hidden `agents daemon` command tree as backward-compatible
5
- * aliases for `agents routines` scheduler lifecycle commands. Scheduled
6
- * for removal in v2.0.
7
- */
8
- import chalk from 'chalk';
9
- import * as path from 'path';
10
- import { startDaemon, stopDaemon, isDaemonRunning, readDaemonPid, readDaemonLog, runDaemon, } from '../lib/daemon.js';
11
- import { listJobs as listAllJobs } from '../lib/routines.js';
12
- import { JobScheduler } from '../lib/scheduler.js';
13
- /** Print a deprecation warning pointing to the replacement command. */
14
- function warnDeprecated(subcommand, replacement) {
15
- console.log(chalk.yellow(`\u26a0 'agents daemon ${subcommand}' is deprecated and will be removed in v2.0. Use '${replacement}' instead.\n`));
16
- }
17
- /** Register the deprecated `agents daemon` command tree. */
18
- export function registerDaemonCommands(program) {
19
- const daemonCmd = program
20
- .command('daemon', { hidden: true })
21
- .description('[DEPRECATED] Use `agents routines start|stop|status|scheduler-logs` instead. Kept for backward compatibility; will be removed in v2.0.')
22
- .addHelpText('after', `
23
- DEPRECATED: The 'agents daemon' commands are scheduled for removal in v2.0.
24
-
25
- Migration:
26
- agents daemon start -> agents routines start
27
- agents daemon stop -> agents routines stop
28
- agents daemon status -> agents routines status
29
- agents daemon logs -> agents routines scheduler-logs
30
-
31
- The scheduler now auto-starts when you run 'agents routines add', so in most cases
32
- you never need to start it manually.
33
- `);
34
- daemonCmd
35
- .command('start')
36
- .description('[DEPRECATED] Use `agents routines start`.')
37
- .action(() => {
38
- warnDeprecated('start', 'agents routines start');
39
- const result = startDaemon();
40
- if (result.method === 'already-running') {
41
- console.log(chalk.yellow(`Daemon already running (PID: ${result.pid})`));
42
- }
43
- else if (result.pid) {
44
- console.log(chalk.green(`Daemon started (PID: ${result.pid}, method: ${result.method})`));
45
- }
46
- else {
47
- console.log(chalk.yellow('Daemon start dispatched but no PID surfaced. Check `agents routines status`.'));
48
- }
49
- });
50
- daemonCmd
51
- .command('stop')
52
- .description('[DEPRECATED] Use `agents routines stop`.')
53
- .action(() => {
54
- warnDeprecated('stop', 'agents routines stop');
55
- if (!isDaemonRunning()) {
56
- console.log(chalk.yellow('Daemon is not running'));
57
- return;
58
- }
59
- stopDaemon();
60
- console.log(chalk.green('Daemon stopped'));
61
- });
62
- daemonCmd
63
- .command('status')
64
- .description('[DEPRECATED] Use `agents routines status`.')
65
- .action(() => {
66
- warnDeprecated('status', 'agents routines status');
67
- const running = isDaemonRunning();
68
- const pid = readDaemonPid();
69
- console.log(chalk.bold('Daemon Status\n'));
70
- console.log(` Status: ${running ? chalk.green('running') : chalk.gray('stopped')}`);
71
- if (pid)
72
- console.log(` PID: ${pid}`);
73
- const jobs = listAllJobs();
74
- const enabled = jobs.filter((j) => j.enabled);
75
- console.log(` Jobs: ${enabled.length} enabled / ${jobs.length} total`);
76
- if (running && enabled.length > 0) {
77
- const scheduler = new JobScheduler(async () => { });
78
- scheduler.loadAll();
79
- const scheduled = scheduler.listScheduled();
80
- console.log(chalk.bold('\n Scheduled Jobs\n'));
81
- for (const job of scheduled) {
82
- const next = job.nextRun ? job.nextRun.toLocaleString() : 'unknown';
83
- console.log(` ${chalk.cyan(job.name.padEnd(24))} next: ${chalk.gray(next)}`);
84
- }
85
- scheduler.stopAll();
86
- }
87
- });
88
- daemonCmd
89
- .command('logs')
90
- .description('[DEPRECATED] Use `agents routines scheduler-logs`.')
91
- .option('-n, --lines <number>', 'Show this many recent lines (default: 50)', '50')
92
- .option('-f, --follow', 'Stream log output in real time (like tail -f)')
93
- .action(async (options) => {
94
- warnDeprecated('logs', 'agents routines scheduler-logs');
95
- if (options.follow) {
96
- const { getDaemonDir } = await import('../lib/state.js');
97
- const { followFile } = await import('../lib/log-follow.js');
98
- const logPath = path.join(getDaemonDir(), 'logs.jsonl');
99
- const recent = readDaemonLog(parseInt(options.lines, 10));
100
- if (recent)
101
- console.log(recent);
102
- const stop = followFile(logPath, (text) => process.stdout.write(text), { fromEnd: true });
103
- process.on('SIGINT', () => { stop(); process.exit(0); });
104
- return;
105
- }
106
- const lines = parseInt(options.lines, 10);
107
- const output = readDaemonLog(lines);
108
- if (output) {
109
- console.log(output);
110
- }
111
- else {
112
- console.log(chalk.gray('No daemon logs'));
113
- }
114
- });
115
- daemonCmd
116
- .command('_run', { hidden: true })
117
- .description('Run daemon in foreground (internal)')
118
- .action(async () => {
119
- await runDaemon();
120
- });
121
- }