@phnx-labs/agents-cli 1.22.121 → 1.22.123

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 (247) hide show
  1. package/CHANGELOG.md +316 -0
  2. package/README.md +53 -53
  3. package/dist/bootstrap.js +22 -17
  4. package/dist/cli/command-registry.d.ts +0 -1
  5. package/dist/cli/command-registry.js +2 -12
  6. package/dist/commands/auth.js +13 -4
  7. package/dist/commands/browser.js +3 -4
  8. package/dist/commands/cloud-transcripts.d.ts +7 -0
  9. package/dist/commands/cloud-transcripts.js +100 -0
  10. package/dist/commands/cloud.js +5 -0
  11. package/dist/commands/computer.d.ts +0 -12
  12. package/dist/commands/computer.js +14 -124
  13. package/dist/commands/config.js +5 -4
  14. package/dist/commands/daemon-index.d.ts +2 -0
  15. package/dist/commands/daemon-index.js +44 -0
  16. package/dist/commands/daemon.js +13 -8
  17. package/dist/commands/doctor.js +3 -4
  18. package/dist/commands/exec.d.ts +5 -0
  19. package/dist/commands/exec.js +35 -7
  20. package/dist/commands/feed-watch.js +12 -0
  21. package/dist/commands/feed.d.ts +1 -1
  22. package/dist/commands/feed.js +7 -4
  23. package/dist/commands/insights.js +3 -1
  24. package/dist/commands/inspect.js +1 -1
  25. package/dist/commands/logs.js +2 -1
  26. package/dist/commands/mailboxes.js +1 -1
  27. package/dist/commands/models.js +1 -1
  28. package/dist/commands/projects.js +3 -3
  29. package/dist/commands/prune.js +6 -28
  30. package/dist/commands/ps-roster.d.ts +0 -1
  31. package/dist/commands/ps-roster.js +2 -21
  32. package/dist/commands/ps.js +13 -1
  33. package/dist/commands/recordings.d.ts +2 -0
  34. package/dist/commands/recordings.js +117 -0
  35. package/dist/commands/routines.js +1 -1
  36. package/dist/commands/secrets-passthrough.js +3 -3
  37. package/dist/commands/send.js +33 -20
  38. package/dist/commands/sessions-backfill.d.ts +1 -0
  39. package/dist/commands/sessions-backfill.js +48 -13
  40. package/dist/commands/sessions-migrate.d.ts +1 -1
  41. package/dist/commands/sessions-migrate.js +11 -10
  42. package/dist/commands/sessions-optimize.d.ts +1 -0
  43. package/dist/commands/sessions-optimize.js +7 -4
  44. package/dist/commands/sessions-resume.js +8 -1
  45. package/dist/commands/sessions-stats.d.ts +2 -0
  46. package/dist/commands/sessions-stats.js +24 -7
  47. package/dist/commands/sessions.d.ts +5 -11
  48. package/dist/commands/sessions.js +8 -236
  49. package/dist/commands/setup-computer.js +1 -2
  50. package/dist/commands/setup-mine.js +0 -1
  51. package/dist/commands/setup.js +1 -1
  52. package/dist/commands/sync.js +101 -1
  53. package/dist/commands/teams.js +2 -2
  54. package/dist/commands/testdata/feed-hub.js +11 -0
  55. package/dist/commands/trash.d.ts +0 -1
  56. package/dist/commands/trash.js +74 -10
  57. package/dist/lib/accounting/usage-sync.js +7 -0
  58. package/dist/lib/agent-modes.d.ts +1 -1
  59. package/dist/lib/agent-modes.js +11 -5
  60. package/dist/lib/auth-mint.d.ts +4 -0
  61. package/dist/lib/auth-mint.js +6 -4
  62. package/dist/lib/browser/native-history.test-fixture.d.ts +12 -0
  63. package/dist/lib/browser/native-history.test-fixture.js +43 -0
  64. package/dist/lib/browser/paths.d.ts +5 -0
  65. package/dist/lib/browser/paths.js +7 -1
  66. package/dist/lib/browser/sessions-list.d.ts +28 -1
  67. package/dist/lib/browser/sessions-list.js +137 -25
  68. package/dist/lib/channels/providers/rush.d.ts +2 -1
  69. package/dist/lib/channels/providers/rush.js +2 -2
  70. package/dist/lib/channels/providers/session.d.ts +1 -0
  71. package/dist/lib/channels/providers/session.js +23 -12
  72. package/dist/lib/channels/registry.d.ts +9 -2
  73. package/dist/lib/channels/send.d.ts +5 -10
  74. package/dist/lib/channels/send.js +88 -50
  75. package/dist/lib/cloud/rush.d.ts +6 -0
  76. package/dist/lib/cloud/rush.js +18 -3
  77. package/dist/lib/computer-client.d.ts +19 -0
  78. package/dist/lib/computer-client.js +104 -0
  79. package/dist/lib/config-keys.d.ts +5 -1
  80. package/dist/lib/config-keys.js +14 -11
  81. package/dist/lib/daemon/auth-sync-service.js +13 -0
  82. package/dist/lib/daemon/daemon.js +20 -23
  83. package/dist/lib/daemon/owner-device-delivery-service.d.ts +10 -0
  84. package/dist/lib/daemon/owner-device-delivery-service.js +28 -0
  85. package/dist/lib/daemon-services.d.ts +2 -1
  86. package/dist/lib/daemon-services.js +17 -10
  87. package/dist/lib/daemon-webhooks.d.ts +1 -1
  88. package/dist/lib/daemon-webhooks.js +1 -1
  89. package/dist/lib/device-config.d.ts +4 -1
  90. package/dist/lib/device-config.js +58 -8
  91. package/dist/lib/devices/doctor-findings.d.ts +2 -3
  92. package/dist/lib/devices/doctor-findings.js +10 -19
  93. package/dist/lib/event-provenance.d.ts +1 -0
  94. package/dist/lib/event-provenance.js +2 -0
  95. package/dist/lib/exec.d.ts +1 -0
  96. package/dist/lib/exec.js +20 -15
  97. package/dist/lib/feed/pr-status.d.ts +5 -1
  98. package/dist/lib/feed/pr-status.js +44 -3
  99. package/dist/lib/feed/tool-activity.js +9 -6
  100. package/dist/lib/feed/tools.d.ts +4 -1
  101. package/dist/lib/feed/tools.js +8 -11
  102. package/dist/lib/feed-broadcast.d.ts +5 -3
  103. package/dist/lib/feed-broadcast.js +47 -36
  104. package/dist/lib/fleet-shared-state.d.ts +5 -0
  105. package/dist/lib/fleet-shared-state.js +8 -0
  106. package/dist/lib/github/project-prs.d.ts +4 -1
  107. package/dist/lib/github/project-prs.js +20 -7
  108. package/dist/lib/help.d.ts +1 -0
  109. package/dist/lib/help.js +8 -0
  110. package/dist/lib/helper-versions.js +1 -1
  111. package/dist/lib/hosts/passthrough.js +5 -9
  112. package/dist/lib/hosts/remote-cmd.d.ts +2 -7
  113. package/dist/lib/hosts/remote-cmd.js +14 -22
  114. package/dist/lib/hosts/routing-flag.d.ts +22 -0
  115. package/dist/lib/hosts/routing-flag.js +127 -14
  116. package/dist/lib/identity/index.d.ts +22 -0
  117. package/dist/lib/identity/index.js +3 -0
  118. package/dist/lib/installations/migrate.d.ts +7 -0
  119. package/dist/lib/installations/migrate.js +99 -88
  120. package/dist/lib/installations/versions.js +2 -2
  121. package/dist/lib/launch-identity.d.ts +6 -1
  122. package/dist/lib/launch-identity.js +12 -2
  123. package/dist/lib/menubar/install-menubar.d.ts +1 -0
  124. package/dist/lib/menubar/install-menubar.js +8 -5
  125. package/dist/lib/menubar/snapshot.js +2 -3
  126. package/dist/lib/notify.d.ts +7 -14
  127. package/dist/lib/notify.js +29 -75
  128. package/dist/lib/owner-message.d.ts +4 -6
  129. package/dist/lib/owner-message.js +12 -11
  130. package/dist/lib/owner-notify-tokens.d.ts +49 -0
  131. package/dist/lib/owner-notify-tokens.js +214 -0
  132. package/dist/lib/owner-notify.d.ts +75 -0
  133. package/dist/lib/owner-notify.js +144 -0
  134. package/dist/lib/plugins/plugins.d.ts +7 -1
  135. package/dist/lib/plugins/plugins.js +26 -5
  136. package/dist/lib/pr-land-detach.js +2 -2
  137. package/dist/lib/recordings/config.d.ts +11 -0
  138. package/dist/lib/recordings/config.js +54 -0
  139. package/dist/lib/recordings/identity.d.ts +12 -0
  140. package/dist/lib/recordings/identity.js +57 -0
  141. package/dist/lib/recordings/ledger.d.ts +16 -0
  142. package/dist/lib/recordings/ledger.js +141 -0
  143. package/dist/lib/recordings/model.d.ts +29 -0
  144. package/dist/lib/recordings/model.js +28 -0
  145. package/dist/lib/recordings/pipeline.d.ts +44 -0
  146. package/dist/lib/recordings/pipeline.js +272 -0
  147. package/dist/lib/recordings/process.d.ts +17 -0
  148. package/dist/lib/recordings/process.js +94 -0
  149. package/dist/lib/recordings/service.d.ts +15 -0
  150. package/dist/lib/recordings/service.js +45 -0
  151. package/dist/lib/recordings/settle.d.ts +21 -0
  152. package/dist/lib/recordings/settle.js +92 -0
  153. package/dist/lib/recordings/transcode.d.ts +13 -0
  154. package/dist/lib/recordings/transcode.js +44 -0
  155. package/dist/lib/refresh.js +4 -1
  156. package/dist/lib/reminders.d.ts +0 -1
  157. package/dist/lib/reminders.js +1 -1
  158. package/dist/lib/reserved-stores.d.ts +3 -0
  159. package/dist/lib/reserved-stores.js +13 -0
  160. package/dist/lib/routine-notify-owner.d.ts +3 -23
  161. package/dist/lib/routine-notify-owner.js +26 -107
  162. package/dist/lib/rush-api.d.ts +1 -0
  163. package/dist/lib/rush-api.js +1 -0
  164. package/dist/lib/scheduling/routines.d.ts +1 -1
  165. package/dist/lib/scheduling/routines.js +1 -1
  166. package/dist/lib/session/active.d.ts +18 -2
  167. package/dist/lib/session/active.js +47 -37
  168. package/dist/lib/session/cloud.js +18 -45
  169. package/dist/lib/session/db.d.ts +3 -1
  170. package/dist/lib/session/db.js +64 -32
  171. package/dist/lib/session/glance-files.d.ts +4 -3
  172. package/dist/lib/session/glance-files.js +31 -0
  173. package/dist/lib/session/inject-target.js +12 -2
  174. package/dist/lib/session/pid-registry.d.ts +2 -0
  175. package/dist/lib/session/pid-registry.js +6 -2
  176. package/dist/lib/session/presentation.d.ts +21 -0
  177. package/dist/lib/session/presentation.js +198 -0
  178. package/dist/lib/session/projection.js +9 -2
  179. package/dist/lib/sqlite.d.ts +3 -1
  180. package/dist/lib/sqlite.js +7 -3
  181. package/dist/lib/staleness/index.js +12 -0
  182. package/dist/lib/staleness/types.d.ts +5 -0
  183. package/dist/lib/standalone-tools.js +1 -1
  184. package/dist/lib/startup/command-registry.js +10 -5
  185. package/dist/lib/state.d.ts +2 -5
  186. package/dist/lib/state.js +3 -11
  187. package/dist/lib/sync-delete.d.ts +21 -0
  188. package/dist/lib/sync-delete.js +113 -0
  189. package/dist/lib/terminal/inject.js +1 -1
  190. package/dist/lib/testdata/owner-notify-api.d.ts +36 -0
  191. package/dist/lib/testdata/owner-notify-api.js +102 -0
  192. package/dist/lib/trash.d.ts +14 -0
  193. package/dist/lib/trash.js +75 -0
  194. package/dist/lib/types.d.ts +0 -34
  195. package/package.json +1 -3
  196. package/dist/commands/feedback.d.ts +0 -2
  197. package/dist/commands/feedback.js +0 -68
  198. package/dist/commands/humans.d.ts +0 -2
  199. package/dist/commands/humans.js +0 -83
  200. package/dist/commands/modes.d.ts +0 -2
  201. package/dist/commands/modes.js +0 -134
  202. package/dist/commands/monitors.d.ts +0 -2
  203. package/dist/commands/monitors.js +0 -1070
  204. package/dist/commands/reminders.d.ts +0 -2
  205. package/dist/commands/reminders.js +0 -49
  206. package/dist/lib/channels/owner-forward.d.ts +0 -25
  207. package/dist/lib/channels/owner-forward.js +0 -78
  208. package/dist/lib/channels/owner-sink.d.ts +0 -10
  209. package/dist/lib/channels/owner-sink.js +0 -26
  210. package/dist/lib/daemon/monitor-engine-service.d.ts +0 -13
  211. package/dist/lib/daemon/monitor-engine-service.js +0 -25
  212. package/dist/lib/humans.d.ts +0 -12
  213. package/dist/lib/humans.js +0 -64
  214. package/dist/lib/monitors/config.d.ts +0 -77
  215. package/dist/lib/monitors/config.js +0 -405
  216. package/dist/lib/monitors/dispatch.d.ts +0 -10
  217. package/dist/lib/monitors/dispatch.js +0 -72
  218. package/dist/lib/monitors/engine.d.ts +0 -45
  219. package/dist/lib/monitors/engine.js +0 -243
  220. package/dist/lib/monitors/fingerprint.d.ts +0 -3
  221. package/dist/lib/monitors/fingerprint.js +0 -43
  222. package/dist/lib/monitors/pid-watch.d.ts +0 -4
  223. package/dist/lib/monitors/pid-watch.js +0 -14
  224. package/dist/lib/monitors/remote.d.ts +0 -31
  225. package/dist/lib/monitors/remote.js +0 -63
  226. package/dist/lib/monitors/sources/command.d.ts +0 -4
  227. package/dist/lib/monitors/sources/command.js +0 -20
  228. package/dist/lib/monitors/sources/device.d.ts +0 -3
  229. package/dist/lib/monitors/sources/device.js +0 -31
  230. package/dist/lib/monitors/sources/failure.d.ts +0 -5
  231. package/dist/lib/monitors/sources/failure.js +0 -25
  232. package/dist/lib/monitors/sources/file.d.ts +0 -4
  233. package/dist/lib/monitors/sources/file.js +0 -46
  234. package/dist/lib/monitors/sources/http.d.ts +0 -3
  235. package/dist/lib/monitors/sources/http.js +0 -25
  236. package/dist/lib/monitors/sources/index.d.ts +0 -5
  237. package/dist/lib/monitors/sources/index.js +0 -22
  238. package/dist/lib/monitors/sources/poll.d.ts +0 -1
  239. package/dist/lib/monitors/sources/poll.js +0 -1
  240. package/dist/lib/monitors/sources/types.d.ts +0 -9
  241. package/dist/lib/monitors/sources/webhook.d.ts +0 -3
  242. package/dist/lib/monitors/sources/webhook.js +0 -3
  243. package/dist/lib/monitors/sources/ws.d.ts +0 -4
  244. package/dist/lib/monitors/sources/ws.js +0 -35
  245. package/dist/lib/monitors/state.d.ts +0 -51
  246. package/dist/lib/monitors/state.js +0 -221
  247. /package/dist/{lib/monitors/sources/types.js → commands/testdata/feed-hub.d.ts} +0 -0
@@ -1,5 +1,4 @@
1
1
  import type { Meta } from './types.js';
2
- export declare function getHumansFilePath(): string;
3
2
  export declare const META_HEADER = "# agents-cli metadata\n# Auto-generated - do not edit manually\n# https://github.com/phnx-labs/agi-cli\n# yaml-language-server: $schema=https://raw.githubusercontent.com/phnx-labs/agi-cli/main/cli/schema/agents-yaml.schema.json\n\n";
4
3
  export declare function getAgentsDir(): string;
5
4
  export declare function getSystemAgentsDir(): string;
@@ -66,9 +65,6 @@ export declare function getSystemWebhooksDir(): string;
66
65
  export declare function getProjectRoutinesDir(cwd?: string): string | null;
67
66
  export declare function getProjectWebhooksDir(cwd?: string): string | null;
68
67
  export declare function getRunsDir(): string;
69
- export declare function getMonitorsDir(): string;
70
- export declare function getSystemMonitorsDir(): string;
71
- export declare function getMonitorsHistoryDir(): string;
72
68
  export declare function getMailboxRootDir(): string;
73
69
  export declare function getFeedDir(): string;
74
70
  export declare function getActivityDir(): string;
@@ -118,6 +114,7 @@ export declare function getTrashHooksDir(): string;
118
114
  export declare function getTrashPluginsDir(): string;
119
115
  export declare function getTrashSubagentsDir(): string;
120
116
  export declare function getTrashWorkflowsDir(): string;
117
+ export declare function getTrashFilesDir(): string;
121
118
  export declare function getExtraRepoDir(alias: string): string;
122
119
  export declare function resolveExtraRepoDir(alias: string, config?: {
123
120
  path?: string;
@@ -132,7 +129,7 @@ export declare function createDefaultMeta(): Meta;
132
129
  export declare function getDeviceMetaPath(): string;
133
130
  export declare function getVersionResourcesPath(): string;
134
131
  export declare function withMetaLock<T>(fn: () => T): T;
135
- export declare function commitCentralConfig(userDir: string): boolean;
132
+ export declare function commitCentralConfig(userDir: string, rel?: string, message?: string): boolean;
136
133
  export declare function hasStaleMetaHeader(): boolean;
137
134
  export declare function readTopLevelUserMeta(): Record<string, unknown> | null;
138
135
  export declare function writeMetaUnlocked(meta: Meta): boolean;
package/dist/lib/state.js CHANGED
@@ -22,8 +22,6 @@ const SYSTEM_AGENTS_DIR = path.join(USER_AGENTS_DIR, '.system');
22
22
  const LEGACY_SYSTEM_AGENTS_DIR = path.join(HOME, '.agents-system');
23
23
  const META_FILE = path.join(USER_AGENTS_DIR, 'agents.yaml');
24
24
  const SYSTEM_META_FILE = path.join(SYSTEM_AGENTS_DIR, 'agents.yaml');
25
- const HUMANS_FILE = path.join(USER_AGENTS_DIR, 'humans.yaml');
26
- export function getHumansFilePath() { return process.env.AGENTS_HUMANS_FILE ?? HUMANS_FILE; }
27
25
  const SYSTEM_COMMANDS_DIR = path.join(SYSTEM_AGENTS_DIR, 'commands');
28
26
  const SYSTEM_HOOKS_DIR = path.join(SYSTEM_AGENTS_DIR, 'hooks');
29
27
  const SYSTEM_SKILLS_DIR = path.join(SYSTEM_AGENTS_DIR, 'skills');
@@ -34,7 +32,6 @@ const SYSTEM_SUBAGENTS_DIR = path.join(SYSTEM_AGENTS_DIR, 'subagents');
34
32
  const SYSTEM_WORKFLOWS_DIR = path.join(SYSTEM_AGENTS_DIR, 'workflows');
35
33
  const SYSTEM_PLUGINS_DIR = path.join(SYSTEM_AGENTS_DIR, 'plugins');
36
34
  const SYSTEM_ROUTINES_DIR = path.join(SYSTEM_AGENTS_DIR, 'routines');
37
- const SYSTEM_MONITORS_DIR = path.join(SYSTEM_AGENTS_DIR, 'monitors');
38
35
  const SYSTEM_WEBHOOKS_DIR = path.join(SYSTEM_AGENTS_DIR, 'webhooks');
39
36
  const SYSTEM_PROMPTCUTS_FILE = path.join(SYSTEM_AGENTS_DIR, 'hooks', 'promptcuts.yaml');
40
37
  const SYSTEM_MCP_CONFIG_FILE = path.join(SYSTEM_AGENTS_DIR, 'mcp.json');
@@ -43,7 +40,6 @@ const HISTORY_DIR = path.join(USER_AGENTS_DIR, '.history');
43
40
  const CACHE_DIR = path.join(USER_AGENTS_DIR, '.cache');
44
41
  const ROUTINES_DIR = path.join(USER_AGENTS_DIR, 'routines');
45
42
  const WEBHOOKS_DIR = path.join(USER_AGENTS_DIR, 'webhooks');
46
- const MONITORS_DIR = path.join(USER_AGENTS_DIR, 'monitors');
47
43
  const TEAMS_DIR = path.join(USER_AGENTS_DIR, 'teams');
48
44
  const PROJECTS_DIR = path.join(USER_AGENTS_DIR, 'projects');
49
45
  const DAEMON_CONFIG_DIR = path.join(USER_AGENTS_DIR, 'daemon');
@@ -52,7 +48,6 @@ const SESSIONS_DB_PATH = path.join(SESSIONS_DIR, 'sessions.db');
52
48
  const ANALYTICS_DIR = path.join(HISTORY_DIR, 'analytics');
53
49
  const VERSIONS_DIR = path.join(HISTORY_DIR, 'versions');
54
50
  const RUNS_DIR = path.join(HISTORY_DIR, 'runs');
55
- const MONITORS_HISTORY_DIR = path.join(HISTORY_DIR, 'monitors');
56
51
  const TEAMS_AGENTS_DIR = path.join(HISTORY_DIR, 'teams', 'agents');
57
52
  const BACKUPS_DIR = path.join(HISTORY_DIR, 'backups');
58
53
  const TRASH_DIR = path.join(HISTORY_DIR, 'trash');
@@ -283,9 +278,6 @@ export function getProjectWebhooksDir(cwd = process.cwd()) {
283
278
  return path.join(projectAgentsDir, 'webhooks');
284
279
  }
285
280
  export function getRunsDir() { return RUNS_DIR; }
286
- export function getMonitorsDir() { return process.env.AGENTS_MONITORS_DIR ?? MONITORS_DIR; }
287
- export function getSystemMonitorsDir() { return process.env.AGENTS_SYSTEM_MONITORS_DIR ?? SYSTEM_MONITORS_DIR; }
288
- export function getMonitorsHistoryDir() { return MONITORS_HISTORY_DIR; }
289
281
  export function getMailboxRootDir() { return MAILBOX_DIR; }
290
282
  export function getFeedDir() { return FEED_DIR; }
291
283
  export function getActivityDir() { return ACTIVITY_DIR; }
@@ -355,6 +347,7 @@ export function getTrashHooksDir() { return path.join(TRASH_DIR, 'hooks'); }
355
347
  export function getTrashPluginsDir() { return path.join(TRASH_DIR, 'plugins'); }
356
348
  export function getTrashSubagentsDir() { return path.join(TRASH_DIR, 'subagents'); }
357
349
  export function getTrashWorkflowsDir() { return path.join(TRASH_DIR, 'workflows'); }
350
+ export function getTrashFilesDir() { return path.join(TRASH_DIR, 'files'); }
358
351
  export function getExtraRepoDir(alias) {
359
352
  return path.join(HOME, `.agents-${alias}`);
360
353
  }
@@ -484,8 +477,7 @@ function writeIfChanged(filePath, content) {
484
477
  atomicWriteFileSync(filePath, content);
485
478
  return true;
486
479
  }
487
- export function commitCentralConfig(userDir) {
488
- const rel = 'agents.yaml';
480
+ export function commitCentralConfig(userDir, rel = 'agents.yaml', message = 'chore(config): update agents.yaml') {
489
481
  try {
490
482
  execFileSync('git', ['-C', userDir, 'rev-parse', '--is-inside-work-tree'], { stdio: 'ignore' });
491
483
  }
@@ -500,7 +492,7 @@ export function commitCentralConfig(userDir) {
500
492
  }
501
493
  catch { }
502
494
  execFileSync('git', ['-C', userDir, '-c', 'commit.gpgsign=false', 'commit', '--no-verify',
503
- '-m', 'chore(config): update agents.yaml', '--', rel], { stdio: 'ignore' });
495
+ '-m', message, '--', rel], { stdio: 'ignore' });
504
496
  return true;
505
497
  }
506
498
  catch {
@@ -0,0 +1,21 @@
1
+ import type { AgentId } from './types.js';
2
+ export interface RepoRemovalReport {
3
+ agent: AgentId;
4
+ version: string;
5
+ removed: {
6
+ plugins: string[];
7
+ commands: string[];
8
+ skills: string[];
9
+ };
10
+ kept: {
11
+ notFromRepo: string[];
12
+ stillProvided: string[];
13
+ };
14
+ }
15
+ export declare function pruneRepoRemovals(args: {
16
+ agent: AgentId;
17
+ version: string;
18
+ repo: string;
19
+ cwd: string;
20
+ dryRun: boolean;
21
+ }): RepoRemovalReport;
@@ -0,0 +1,113 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { supports } from './capabilities.js';
4
+ import { getEnabledExtraRepos, getProjectAgentsDir, getSystemAgentsDir, getSystemPluginsDir, getUserAgentsDir } from './state.js';
5
+ import { getVersionHomePath } from './installations/versions.js';
6
+ import { listResources } from './resources.js';
7
+ import { removeCommandFromVersion } from './commands.js';
8
+ import { removeSkillFromVersion } from './plugins/skills.js';
9
+ import { cleanOrphanedPluginSkills, discoverPlugins, listVersionMarketplaceNames } from './plugins/plugins.js';
10
+ import { marketplaceNameFor, marketplaceRoot } from './plugins/plugin-marketplace.js';
11
+ import { loadManifest, saveManifest } from './staleness/index.js';
12
+ import { getDetector } from './staleness/registry.js';
13
+ function repoSource(repo, cwd) {
14
+ let root;
15
+ let spec;
16
+ if (repo === 'project') {
17
+ root = getProjectAgentsDir(cwd);
18
+ spec = { kind: 'project', root: root ? path.join(root, 'plugins') : '' };
19
+ }
20
+ else if (repo === 'user') {
21
+ root = getUserAgentsDir();
22
+ spec = { kind: 'user' };
23
+ }
24
+ else if (repo === 'system') {
25
+ root = getSystemAgentsDir();
26
+ spec = { kind: 'system', root: getSystemPluginsDir() };
27
+ }
28
+ else {
29
+ const extra = getEnabledExtraRepos().find((e) => e.alias === repo);
30
+ root = extra?.dir ?? null;
31
+ spec = { kind: 'extra', alias: repo, root: extra ? path.join(extra.dir, 'plugins') : '' };
32
+ }
33
+ if (!root || !fs.existsSync(root)) {
34
+ throw new Error(`The '${repo}' repo has no checkout on this machine, so nothing can be proven to have come from it.`);
35
+ }
36
+ return { root, marketplace: marketplaceNameFor(spec) };
37
+ }
38
+ function within(dir, p) {
39
+ const rel = path.relative(dir, p);
40
+ return rel !== '' && !rel.startsWith('..') && !path.isAbsolute(rel);
41
+ }
42
+ export function pruneRepoRemovals(args) {
43
+ const { agent, version, repo, cwd, dryRun } = args;
44
+ const versionHome = getVersionHomePath(agent, version);
45
+ const { root, marketplace } = repoSource(repo, cwd);
46
+ const report = {
47
+ agent,
48
+ version,
49
+ removed: { plugins: [], commands: [], skills: [] },
50
+ kept: { notFromRepo: [], stillProvided: [] },
51
+ };
52
+ if (supports(agent, 'plugins', version).ok) {
53
+ report.removed.plugins = cleanOrphanedPluginSkills(agent, versionHome, discoverPlugins({ cwd }), version, { marketplace, cwd, dryRun });
54
+ for (const name of listVersionMarketplaceNames(agent, versionHome)) {
55
+ if (name === marketplace)
56
+ continue;
57
+ const dir = path.join(marketplaceRoot(name, agent, versionHome), 'plugins');
58
+ if (!fs.existsSync(dir))
59
+ continue;
60
+ for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
61
+ if (e.isDirectory() && !e.name.startsWith('.'))
62
+ report.kept.notFromRepo.push(`plugin ${e.name}`);
63
+ }
64
+ }
65
+ }
66
+ const manifest = loadManifest(agent, version);
67
+ const provenance = {
68
+ commands: Object.fromEntries(Object.entries({ ...manifest?.retired?.commands, ...manifest?.commands }).map(([n, e]) => [n, e.source.path])),
69
+ skills: Object.fromEntries(Object.entries({ ...manifest?.retired?.skills, ...manifest?.skills }).map(([n, e]) => [n, e.dirPath])),
70
+ };
71
+ const kinds = [
72
+ { kind: 'commands', label: 'command', remove: removeCommandFromVersion },
73
+ { kind: 'skills', label: 'skill', remove: removeSkillFromVersion },
74
+ ];
75
+ for (const { kind, label, remove } of kinds) {
76
+ const detector = getDetector(kind, agent);
77
+ if (!detector || !supports(agent, kind, version).ok)
78
+ continue;
79
+ const provided = new Set(listResources(kind, cwd).map((r) => r.name));
80
+ const kindDir = path.join(root, kind);
81
+ for (const name of detector.list({ version, versionHome, cwd })) {
82
+ const source = provenance[kind][name];
83
+ if (!source || !within(kindDir, source)) {
84
+ report.kept.notFromRepo.push(`${label} ${name}`);
85
+ continue;
86
+ }
87
+ if (fs.existsSync(source))
88
+ continue;
89
+ if (provided.has(name)) {
90
+ report.kept.stillProvided.push(`${label} ${name}`);
91
+ continue;
92
+ }
93
+ if (!dryRun) {
94
+ const result = remove(agent, version, name);
95
+ if (!result.success)
96
+ throw new Error(`could not trash ${label} '${name}' from ${agent}@${version}: ${result.error}`);
97
+ if (manifest) {
98
+ delete manifest[kind][name];
99
+ if (manifest.retired)
100
+ delete manifest.retired[kind][name];
101
+ if (kind === 'commands' && manifest.writtenCommands) {
102
+ manifest.writtenCommands = manifest.writtenCommands.filter((c) => c !== name);
103
+ }
104
+ }
105
+ }
106
+ report.removed[kind].push(name);
107
+ }
108
+ }
109
+ if (manifest && !dryRun && (report.removed.commands.length > 0 || report.removed.skills.length > 0)) {
110
+ saveManifest(agent, version, manifest);
111
+ }
112
+ return report;
113
+ }
@@ -18,7 +18,7 @@ export function tmuxSendKeysArgv(pane, keys, opts = {}) {
18
18
  argv.push('send-keys', '-t', pane);
19
19
  if (opts.literal)
20
20
  argv.push('-l');
21
- argv.push(keys);
21
+ argv.push('--', keys);
22
22
  return argv;
23
23
  }
24
24
  export function tmuxInjectSpecs(target, text, o) {
@@ -0,0 +1,36 @@
1
+ export interface RecordedRequest {
2
+ method: string;
3
+ path: string;
4
+ bearer: string | null;
5
+ body: unknown;
6
+ }
7
+ interface DeviceToken {
8
+ id: string;
9
+ token: string;
10
+ device: string;
11
+ createdAt: string;
12
+ }
13
+ interface Delivery {
14
+ id: string;
15
+ address: string;
16
+ body: string;
17
+ createdAt: string;
18
+ claimedBy?: string;
19
+ result?: {
20
+ ok: boolean;
21
+ error?: string;
22
+ };
23
+ }
24
+ export interface OwnerNotifyApi {
25
+ url: string;
26
+ requests: RecordedRequest[];
27
+ sessionToken: string;
28
+ deviceTokens: DeviceToken[];
29
+ deliveries: Delivery[];
30
+ dedupKeys: string[];
31
+ imessageAddress: string | null;
32
+ preferencesStatus: number;
33
+ close(): Promise<void>;
34
+ }
35
+ export declare function startOwnerNotifyApi(sessionToken?: string): Promise<OwnerNotifyApi>;
36
+ export {};
@@ -0,0 +1,102 @@
1
+ import * as http from 'node:http';
2
+ const EVENTS = new Set(['needs_you', 'completed', 'failed', 'spend_threshold', 'message']);
3
+ function send(res, status, body) {
4
+ res.writeHead(status, { 'Content-Type': 'application/json' });
5
+ res.end(body === undefined ? undefined : JSON.stringify(body));
6
+ }
7
+ export async function startOwnerNotifyApi(sessionToken = 'phx-session-token') {
8
+ let seq = 0;
9
+ const seen = new Set();
10
+ const api = {
11
+ url: '',
12
+ requests: [],
13
+ sessionToken,
14
+ deviceTokens: [],
15
+ deliveries: [],
16
+ dedupKeys: [],
17
+ imessageAddress: '+15555550100',
18
+ preferencesStatus: 200,
19
+ close: async () => { },
20
+ };
21
+ const server = http.createServer((req, res) => {
22
+ let raw = '';
23
+ req.on('data', (chunk) => { raw += chunk.toString('utf-8'); });
24
+ req.on('end', () => {
25
+ const url = new URL(req.url ?? '/', 'http://fixture');
26
+ const bearer = req.headers.authorization?.replace(/^Bearer /, '') ?? null;
27
+ const body = raw ? JSON.parse(raw) : null;
28
+ api.requests.push({ method: req.method ?? '', path: url.pathname, bearer, body });
29
+ const device = api.deviceTokens.find((t) => t.token === bearer);
30
+ const isSession = bearer === api.sessionToken;
31
+ if (!isSession && !device)
32
+ return send(res, 401, { error: 'Unauthorized', code: 'UNAUTHORIZED' });
33
+ const tokenId = url.pathname.match(/^\/api\/v1\/auth\/tokens\/([^/]+)$/);
34
+ if (tokenId && req.method === 'DELETE') {
35
+ if (!isSession)
36
+ return send(res, 403, { error: 'device_token_forbidden' });
37
+ const before = api.deviceTokens.length;
38
+ api.deviceTokens = api.deviceTokens.filter((t) => t.id !== decodeURIComponent(tokenId[1]));
39
+ return send(res, before === api.deviceTokens.length ? 404 : 204);
40
+ }
41
+ if (url.pathname === '/api/v1/auth/tokens') {
42
+ if (!isSession)
43
+ return send(res, 403, { error: 'device_token_forbidden' });
44
+ if (req.method === 'GET') {
45
+ return send(res, 200, api.deviceTokens.map((t) => ({ id: t.id, kind: 'device', device: t.device, scopes: ['notify'], createdAt: t.createdAt })));
46
+ }
47
+ const name = String(body?.device);
48
+ api.deviceTokens = api.deviceTokens.filter((t) => t.device !== name);
49
+ const minted = { id: `tok-${++seq}`, token: `phx-device-${name}-${seq}`, device: name, createdAt: new Date().toISOString() };
50
+ api.deviceTokens.push(minted);
51
+ return send(res, 201, { id: minted.id, token: minted.token, kind: 'device', device: name, scopes: ['notify'], createdAt: minted.createdAt });
52
+ }
53
+ if (url.pathname === '/me/preferences' && req.method === 'PUT') {
54
+ if (!isSession)
55
+ return send(res, 403, { error: 'device_token_scope', code: 'DEVICE_TOKEN_SCOPE' });
56
+ return api.preferencesStatus === 200
57
+ ? send(res, 200, { ok: true })
58
+ : send(res, api.preferencesStatus, { error: 'unknown event: message', code: 'INVALID_EVENT' });
59
+ }
60
+ if (url.pathname === '/me/notifications' && req.method === 'POST') {
61
+ if (!body || !EVENTS.has(String(body.event)) || typeof body.title !== 'string' || typeof body.body !== 'string' || typeof body.dedupKey !== 'string') {
62
+ return send(res, 400, { error: 'invalid notification', code: 'INVALID_BODY' });
63
+ }
64
+ api.dedupKeys.push(body.dedupKey);
65
+ const key = `${body.event}\0${body.dedupKey}`;
66
+ if (seen.has(key))
67
+ return send(res, 200, { dispatchId: null, delivered: [], queued: [], skipped: [], suppressed: 'duplicate' });
68
+ seen.add(key);
69
+ const queued = api.imessageAddress ? ['imessage'] : [];
70
+ if (api.imessageAddress) {
71
+ api.deliveries.push({ id: `dlv-${++seq}`, address: api.imessageAddress, body: String(body.body), createdAt: new Date().toISOString() });
72
+ }
73
+ return send(res, 200, {
74
+ dispatchId: `dsp-${++seq}`,
75
+ delivered: ['slack'],
76
+ queued,
77
+ skipped: api.imessageAddress ? [] : [{ channel: 'imessage', reason: 'no imessage destination' }],
78
+ suppressed: null,
79
+ });
80
+ }
81
+ if (url.pathname === '/me/device-deliveries/claim' && req.method === 'POST') {
82
+ const claimed = api.deliveries.filter((d) => !d.claimedBy && !d.result).slice(0, Number(body?.limit ?? 10));
83
+ for (const d of claimed)
84
+ d.claimedBy = String(body?.device);
85
+ return send(res, 200, { deliveries: claimed.map((d) => ({ id: d.id, channel: 'imessage', address: d.address, body: d.body, createdAt: d.createdAt })) });
86
+ }
87
+ const result = url.pathname.match(/^\/me\/device-deliveries\/([^/]+)\/result$/);
88
+ if (result && req.method === 'POST') {
89
+ const delivery = api.deliveries.find((d) => d.id === decodeURIComponent(result[1]));
90
+ if (!delivery)
91
+ return send(res, 404, { error: 'not found' });
92
+ delivery.result = { ok: Boolean(body?.ok), ...(typeof body?.error === 'string' ? { error: body.error } : {}) };
93
+ return send(res, 204);
94
+ }
95
+ return send(res, 404, { error: `no route ${req.method} ${url.pathname}` });
96
+ });
97
+ });
98
+ await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
99
+ api.url = `http://127.0.0.1:${server.address().port}`;
100
+ api.close = () => new Promise((resolve) => server.close(() => resolve()));
101
+ return api;
102
+ }
@@ -0,0 +1,14 @@
1
+ export interface TrashItem {
2
+ path: string;
3
+ trashedAtMs: number;
4
+ }
5
+ export declare function listTrashItems(root?: string): TrashItem[];
6
+ export declare function emptyTrash(opts?: {
7
+ olderThanMs?: number;
8
+ now?: number;
9
+ root?: string;
10
+ }): {
11
+ removed: TrashItem[];
12
+ kept: number;
13
+ };
14
+ export declare function moveFileToTrash(file: string): string;
@@ -0,0 +1,75 @@
1
+ import * as fs from 'fs';
2
+ import * as path from 'path';
3
+ import { getTrashDir, getTrashFilesDir } from './state.js';
4
+ const ITEM_DEPTH = {
5
+ versions: 3,
6
+ homes: 3,
7
+ hooks: 4,
8
+ commands: 3,
9
+ skills: 3,
10
+ subagents: 3,
11
+ plugins: 1,
12
+ workflows: 1,
13
+ files: 1,
14
+ };
15
+ function childrenAtDepth(dir, depth) {
16
+ if (depth === 0)
17
+ return [dir];
18
+ let names;
19
+ try {
20
+ if (!fs.statSync(dir).isDirectory())
21
+ return [];
22
+ names = fs.readdirSync(dir);
23
+ }
24
+ catch {
25
+ return [];
26
+ }
27
+ return names.flatMap((name) => childrenAtDepth(path.join(dir, name), depth - 1));
28
+ }
29
+ export function listTrashItems(root = getTrashDir()) {
30
+ let names;
31
+ try {
32
+ names = fs.readdirSync(root);
33
+ }
34
+ catch {
35
+ return [];
36
+ }
37
+ return names
38
+ .flatMap((name) => childrenAtDepth(path.join(root, name), ITEM_DEPTH[name] ?? 0))
39
+ .map((item) => ({ path: item, trashedAtMs: fs.lstatSync(item).ctimeMs }));
40
+ }
41
+ function removeEmptyParents(item, root) {
42
+ for (let dir = path.dirname(item); dir !== root && dir.startsWith(root); dir = path.dirname(dir)) {
43
+ try {
44
+ if (fs.readdirSync(dir).length > 0)
45
+ return;
46
+ fs.rmdirSync(dir);
47
+ }
48
+ catch {
49
+ return;
50
+ }
51
+ }
52
+ }
53
+ export function emptyTrash(opts = {}) {
54
+ const root = opts.root ?? getTrashDir();
55
+ const now = opts.now ?? Date.now();
56
+ const items = listTrashItems(root);
57
+ const removed = [];
58
+ for (const item of items) {
59
+ if (opts.olderThanMs !== undefined && now - item.trashedAtMs < opts.olderThanMs)
60
+ continue;
61
+ fs.rmSync(item.path, { recursive: true, force: true });
62
+ removeEmptyParents(item.path, root);
63
+ removed.push(item);
64
+ }
65
+ return { removed, kept: items.length - removed.length };
66
+ }
67
+ export function moveFileToTrash(file) {
68
+ const dir = getTrashFilesDir();
69
+ fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
70
+ const ext = path.extname(file);
71
+ const stamp = new Date().toISOString().replace(/[:.]/g, '-');
72
+ const dest = path.join(dir, `${path.basename(file, ext)}-${stamp}${ext}`);
73
+ fs.renameSync(file, dest);
74
+ return dest;
75
+ }
@@ -527,43 +527,9 @@ export interface Meta {
527
527
  templateHash?: string;
528
528
  };
529
529
  notify?: {
530
- owner?: {
531
- channel: string;
532
- to: string;
533
- };
534
530
  transports?: Record<string, string>;
535
531
  };
536
532
  }
537
- export interface HumanChannel {
538
- id: string;
539
- transport: string;
540
- to?: string;
541
- watch?: boolean;
542
- cmd?: string;
543
- creds?: string;
544
- intrusive?: boolean;
545
- }
546
- export interface HumanPolicy {
547
- low?: string[];
548
- normal?: string[];
549
- critical?: string[];
550
- }
551
- export interface HumanOwner {
552
- name?: string;
553
- timezone?: string;
554
- quiet_hours?: string;
555
- default_severity?: 'low' | 'normal' | 'critical';
556
- notify?: {
557
- channel: string;
558
- to: string;
559
- };
560
- channels?: HumanChannel[];
561
- policy?: HumanPolicy;
562
- }
563
- export interface HumansConfig {
564
- version: 1;
565
- owner?: HumanOwner;
566
- }
567
533
  export interface HostEntry {
568
534
  source: 'ssh-config' | 'inline';
569
535
  address?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.22.121",
3
+ "version": "1.22.123",
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",
@@ -105,7 +105,6 @@
105
105
  "satori": "0.12.2",
106
106
  "simple-git": "3.36.0",
107
107
  "smol-toml": "1.7.0",
108
- "ws": "^8.21.0",
109
108
  "yaml": "2.9.0",
110
109
  "yoga-wasm-web": "^0.3.3"
111
110
  },
@@ -116,7 +115,6 @@
116
115
  "@types/marked-terminal": "6.1.1",
117
116
  "@types/node": "26.1.0",
118
117
  "@types/ssh2": "1.15.5",
119
- "@types/ws": "^8.18.1",
120
118
  "miniflare": "4.20260730.0",
121
119
  "ssh2": "1.17.0",
122
120
  "tsx": "4.23.0",
@@ -1,2 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function registerFeedbackCommand(program: Command): void;
@@ -1,68 +0,0 @@
1
- import { arch, platform, release } from 'node:os';
2
- import { createRequire } from 'node:module';
3
- import chalk from 'chalk';
4
- import { showUrl } from '../lib/open-url.js';
5
- const REPO = 'phnx-labs/agi-cli';
6
- const DISCUSSION_BASE = `https://github.com/${REPO}/discussions/new`;
7
- const ISSUE_BASE = `https://github.com/${REPO}/issues/new`;
8
- function readCliVersion() {
9
- try {
10
- const require = createRequire(import.meta.url);
11
- const pkg = require('../../package.json');
12
- return pkg.version ?? 'unknown';
13
- }
14
- catch {
15
- return 'unknown';
16
- }
17
- }
18
- function buildPrefill(kind, summary) {
19
- const version = readCliVersion();
20
- const os = `${platform()} ${release()} (${arch()})`;
21
- const node = process.version;
22
- const body = [
23
- summary.trim() ? `${summary.trim()}\n` : '<!-- describe what you ran into / what you want -->\n',
24
- '---',
25
- '',
26
- '**Environment**',
27
- '',
28
- `- agents-cli: \`${version}\``,
29
- `- OS: \`${os}\``,
30
- `- Node: \`${node}\``,
31
- '',
32
- '<!-- For bugs: include the exact command you ran and the full output. -->',
33
- '<!-- For ideas: include a concrete use case. -->'
34
- ].join('\n');
35
- if (kind === 'bug') {
36
- const url = `${ISSUE_BASE}?template=bug_report.yml&title=${encodeURIComponent(summary || 'Bug: ')}`;
37
- return { url, body };
38
- }
39
- const category = kind === 'idea' ? 'ideas' : 'q-a';
40
- const url = `${DISCUSSION_BASE}?category=${category}&title=${encodeURIComponent(summary || '')}&body=${encodeURIComponent(body)}`;
41
- return { url, body };
42
- }
43
- export function registerFeedbackCommand(program) {
44
- program
45
- .command('feedback [summary...]')
46
- .description('Open a pre-filled feedback Discussion or bug report')
47
- .option('-b, --bug', 'File as a bug report (opens issue tracker)')
48
- .option('-i, --idea', 'File as a feature idea (Discussions → Ideas)')
49
- .option('-q, --question', 'Ask a question (Discussions → Q&A)')
50
- .option('--print', 'Print the URL instead of opening it')
51
- .action(async (summary, opts) => {
52
- const kind = opts.bug ? 'bug' : opts.idea ? 'idea' : 'question';
53
- const summaryText = (summary ?? []).join(' ').trim();
54
- const { url } = buildPrefill(kind, summaryText);
55
- if (opts.print) {
56
- console.log(url);
57
- return;
58
- }
59
- const opened = (await showUrl(url)).via !== 'none';
60
- if (opened) {
61
- console.log(chalk.dim(`Opened ${kind} form in your browser:\n ${url}`));
62
- }
63
- else {
64
- console.log(chalk.yellow('Could not auto-open a browser. Paste this URL:'));
65
- console.log(` ${url}`);
66
- }
67
- });
68
- }
@@ -1,2 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function registerHumansCommands(program: Command): void;