@phnx-labs/agents-cli 1.23.13 → 1.23.15

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 (164) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +30 -59
  3. package/dist/cli/command-registry.js +0 -24
  4. package/dist/commands/accounts.js +3 -3
  5. package/dist/commands/daemon.js +5 -147
  6. package/dist/commands/doctor.js +7 -0
  7. package/dist/commands/events-logs.d.ts +2 -0
  8. package/dist/commands/{logs.js → events-logs.js} +28 -127
  9. package/dist/commands/events.js +3 -1
  10. package/dist/commands/exec.d.ts +0 -1
  11. package/dist/commands/exec.js +3 -11
  12. package/dist/commands/feed.d.ts +1 -1
  13. package/dist/commands/feed.js +4 -7
  14. package/dist/commands/mcp.js +1 -1
  15. package/dist/commands/menubar.js +12 -226
  16. package/dist/commands/projects.js +1 -2
  17. package/dist/commands/{trash.d.ts → prune-trash.d.ts} +1 -1
  18. package/dist/commands/{trash.js → prune-trash.js} +8 -8
  19. package/dist/commands/prune.js +3 -1
  20. package/dist/commands/send.js +2 -5
  21. package/dist/commands/sessions.js +1 -1
  22. package/dist/commands/ssh.js +2 -2
  23. package/dist/commands/utils.d.ts +1 -5
  24. package/dist/commands/utils.js +1 -7
  25. package/dist/lib/agent-spec/agents.d.ts +0 -2
  26. package/dist/lib/agent-spec/agents.js +0 -12
  27. package/dist/lib/agent-spec/index.d.ts +0 -4
  28. package/dist/lib/agent-spec/index.js +0 -4
  29. package/dist/lib/commands.d.ts +1 -5
  30. package/dist/lib/commands.js +2 -69
  31. package/dist/lib/comms-render.d.ts +0 -7
  32. package/dist/lib/comms-render.js +0 -41
  33. package/dist/lib/config-keys.d.ts +1 -1
  34. package/dist/lib/config-keys.js +8 -0
  35. package/dist/lib/daemon/daemon.js +1 -6
  36. package/dist/lib/daemon-services.d.ts +1 -1
  37. package/dist/lib/daemon-services.js +0 -5
  38. package/dist/lib/device-config.d.ts +2 -0
  39. package/dist/lib/device-config.js +81 -8
  40. package/dist/lib/devices/doctor-findings.d.ts +6 -1
  41. package/dist/lib/devices/doctor-findings.js +34 -1
  42. package/dist/lib/git.d.ts +1 -0
  43. package/dist/lib/git.js +5 -0
  44. package/dist/lib/hooks/install.d.ts +0 -7
  45. package/dist/lib/hooks/install.js +0 -55
  46. package/dist/lib/hosts/passthrough.js +2 -4
  47. package/dist/lib/hosts/progress.js +2 -2
  48. package/dist/lib/hosts/remote-cmd.js +0 -1
  49. package/dist/lib/installations/migrate.d.ts +1 -0
  50. package/dist/lib/installations/migrate.js +18 -1
  51. package/dist/lib/installations/versions.js +2 -2
  52. package/dist/lib/loop.js +1 -1
  53. package/dist/lib/mailbox-target.d.ts +0 -31
  54. package/dist/lib/mailbox-target.js +0 -37
  55. package/dist/lib/mcp-lookup.d.ts +7 -0
  56. package/dist/lib/mcp-lookup.js +71 -0
  57. package/dist/lib/mcp.d.ts +0 -8
  58. package/dist/lib/mcp.js +0 -47
  59. package/dist/lib/menubar/install-menubar.d.ts +0 -15
  60. package/dist/lib/menubar/install-menubar.js +24 -118
  61. package/dist/lib/menubar/resolve-version.d.ts +9 -10
  62. package/dist/lib/menubar/resolve-version.js +70 -30
  63. package/dist/lib/paths.d.ts +0 -1
  64. package/dist/lib/paths.js +0 -18
  65. package/dist/lib/plugins/skills.d.ts +0 -10
  66. package/dist/lib/plugins/skills.js +2 -165
  67. package/dist/lib/project-pull.js +1 -2
  68. package/dist/lib/resources.d.ts +1 -1
  69. package/dist/lib/routines-project.js +1 -1
  70. package/dist/lib/session/local-tmux-attach.js +2 -2
  71. package/dist/lib/startup/command-registry.js +20 -7
  72. package/dist/lib/teams/agents.js +1 -1
  73. package/dist/lib/teams/placement-probe.d.ts +9 -0
  74. package/dist/lib/teams/placement-probe.js +20 -15
  75. package/dist/lib/triggers/webhook.d.ts +2 -59
  76. package/dist/lib/triggers/webhook.js +2 -422
  77. package/package.json +2 -1
  78. package/dist/commands/funnel.d.ts +0 -2
  79. package/dist/commands/funnel.js +0 -77
  80. package/dist/commands/logs.d.ts +0 -2
  81. package/dist/commands/mailboxes.d.ts +0 -2
  82. package/dist/commands/mailboxes.js +0 -400
  83. package/dist/commands/message.d.ts +0 -2
  84. package/dist/commands/message.js +0 -259
  85. package/dist/commands/packages-materialize.d.ts +0 -6
  86. package/dist/commands/packages-materialize.js +0 -90
  87. package/dist/commands/packages.d.ts +0 -5
  88. package/dist/commands/packages.js +0 -763
  89. package/dist/commands/route.d.ts +0 -2
  90. package/dist/commands/route.js +0 -259
  91. package/dist/commands/testdata/feed-hub.d.ts +0 -1
  92. package/dist/commands/testdata/feed-hub.js +0 -11
  93. package/dist/commands/tmux.d.ts +0 -7
  94. package/dist/commands/tmux.js +0 -529
  95. package/dist/commands/traces.d.ts +0 -2
  96. package/dist/commands/traces.js +0 -204
  97. package/dist/commands/webhook.d.ts +0 -5
  98. package/dist/commands/webhook.js +0 -105
  99. package/dist/lib/agent-spec/materialize.d.ts +0 -3
  100. package/dist/lib/agent-spec/materialize.js +0 -277
  101. package/dist/lib/agent-spec/package-resolve.d.ts +0 -4
  102. package/dist/lib/agent-spec/package-resolve.js +0 -231
  103. package/dist/lib/agent-spec/package-schema.d.ts +0 -3
  104. package/dist/lib/agent-spec/package-schema.js +0 -136
  105. package/dist/lib/agent-spec/package-types.d.ts +0 -94
  106. package/dist/lib/agent-spec/package-types.js +0 -10
  107. package/dist/lib/daemon/testdata/process-view-daemon.d.ts +0 -1
  108. package/dist/lib/daemon/testdata/process-view-daemon.js +0 -12
  109. package/dist/lib/daemon/testdata/process-view-start.d.ts +0 -1
  110. package/dist/lib/daemon/testdata/process-view-start.js +0 -41
  111. package/dist/lib/daemon/webhook-receiver-service.d.ts +0 -8
  112. package/dist/lib/daemon/webhook-receiver-service.js +0 -16
  113. package/dist/lib/daemon-webhooks.d.ts +0 -48
  114. package/dist/lib/daemon-webhooks.js +0 -177
  115. package/dist/lib/funnel.d.ts +0 -6
  116. package/dist/lib/funnel.js +0 -31
  117. package/dist/lib/net-close.d.ts +0 -2
  118. package/dist/lib/net-close.js +0 -20
  119. package/dist/lib/packages/output-home.d.ts +0 -9
  120. package/dist/lib/packages/output-home.js +0 -89
  121. package/dist/lib/registry.d.ts +0 -65
  122. package/dist/lib/registry.js +0 -432
  123. package/dist/lib/routers.d.ts +0 -25
  124. package/dist/lib/routers.js +0 -122
  125. package/dist/lib/run-trace-sync.d.ts +0 -7
  126. package/dist/lib/run-trace-sync.js +0 -35
  127. package/dist/lib/session/testdata/pid-registry-namespace.d.ts +0 -1
  128. package/dist/lib/session/testdata/pid-registry-namespace.js +0 -25
  129. package/dist/lib/session/testdata/process-view-namespace.d.ts +0 -1
  130. package/dist/lib/session/testdata/process-view-namespace.js +0 -56
  131. package/dist/lib/session/testdata/process-view-private.d.ts +0 -1
  132. package/dist/lib/session/testdata/process-view-private.js +0 -11
  133. package/dist/lib/testdata/daemon-health-writer.d.ts +0 -1
  134. package/dist/lib/testdata/daemon-health-writer.js +0 -8
  135. package/dist/lib/testdata/owner-notify-api.d.ts +0 -23
  136. package/dist/lib/testdata/owner-notify-api.js +0 -82
  137. package/dist/lib/testdata/refresh-coordinator-worker.d.ts +0 -1
  138. package/dist/lib/testdata/refresh-coordinator-worker.js +0 -23
  139. package/dist/lib/traces/backend.d.ts +0 -8
  140. package/dist/lib/traces/backend.js +0 -33
  141. package/dist/lib/traces/classify.d.ts +0 -40
  142. package/dist/lib/traces/classify.js +0 -70
  143. package/dist/lib/traces/config.d.ts +0 -2
  144. package/dist/lib/traces/config.js +0 -2
  145. package/dist/lib/traces/insights.d.ts +0 -30
  146. package/dist/lib/traces/insights.js +0 -198
  147. package/dist/lib/traces/phenotype.d.ts +0 -18
  148. package/dist/lib/traces/phenotype.js +0 -335
  149. package/dist/lib/traces/provision.d.ts +0 -16
  150. package/dist/lib/traces/provision.js +0 -25
  151. package/dist/lib/traces/schema2-build.d.ts +0 -28
  152. package/dist/lib/traces/schema2-build.js +0 -496
  153. package/dist/lib/traces/schema2-danger.d.ts +0 -7
  154. package/dist/lib/traces/schema2-danger.js +0 -123
  155. package/dist/lib/traces/schema2.d.ts +0 -139
  156. package/dist/lib/traces/schema2.js +0 -20
  157. package/dist/lib/traces/segments.d.ts +0 -73
  158. package/dist/lib/traces/segments.js +0 -236
  159. package/dist/lib/traces/sync.d.ts +0 -197
  160. package/dist/lib/traces/sync.js +0 -654
  161. package/dist/lib/traces/worker-template.d.ts +0 -1
  162. package/dist/lib/traces/worker-template.js +0 -292
  163. package/dist/lib/triggers/handlers.d.ts +0 -66
  164. package/dist/lib/triggers/handlers.js +0 -383
@@ -0,0 +1,2 @@
1
+ import type { Command } from 'commander';
2
+ export declare function registerEventsLogsCommand(events: Command): void;
@@ -6,8 +6,7 @@ import { runSessions } from '../lib/sessions-client.js';
6
6
  import { showHostTaskLog, hostTaskLogJson } from '../lib/hosts/logs.js';
7
7
  import { listTasks } from '../lib/hosts/tasks.js';
8
8
  import { itemPicker } from '../lib/picker.js';
9
- import { stats, getLogsPath, rotate, } from '../lib/feed/events.js';
10
- import { addEventsReadOptions, runEventsCommand } from './events.js';
9
+ import { setHelpSections } from '../lib/help.js';
11
10
  import { sessionHeadline } from '../lib/session/title.js';
12
11
  function candidateLabel(c) {
13
12
  if (c.kind === 'task') {
@@ -133,137 +132,39 @@ async function runLogs(id, opts) {
133
132
  return;
134
133
  await showCandidate(picked.item, follow, full, !!opts.json);
135
134
  }
136
- function parseSince(s) {
137
- const m = s.match(/^(\d+)([smhdw])$/);
138
- if (m) {
139
- const n = parseInt(m[1], 10);
140
- const unitMs = {
141
- s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000, w: 604_800_000,
142
- };
143
- return new Date(Date.now() - n * unitMs[m[2]]);
144
- }
145
- const ms = Date.parse(s);
146
- if (isNaN(ms))
147
- throw new Error(`Invalid --since value: ${s} (use e.g. 2h, 7d, or an ISO date)`);
148
- return new Date(ms);
149
- }
150
- function levelColor(level) {
151
- if (level === 'audit')
152
- return chalk.magenta(level);
153
- if (level === 'warn')
154
- return chalk.yellow(level);
155
- if (level === 'debug')
156
- return chalk.gray(level);
157
- return chalk.blue(level);
158
- }
159
- function humanBytes(bytes) {
160
- if (bytes < 1024)
161
- return `${bytes} B`;
162
- if (bytes < 1024 * 1024)
163
- return `${(bytes / 1024).toFixed(1)} KB`;
164
- return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
165
- }
166
- async function runStats(opts) {
167
- let days = 7;
168
- if (opts.since) {
169
- try {
170
- const d = parseSince(opts.since);
171
- days = Math.max(1, Math.ceil((Date.now() - d.getTime()) / 86_400_000));
172
- }
173
- catch (err) {
174
- console.error(chalk.red(err.message));
175
- process.exit(2);
176
- }
177
- }
178
- const s = stats({ days });
179
- if (opts.json) {
180
- console.log(JSON.stringify(s, null, 2));
181
- return;
182
- }
183
- console.log(chalk.bold(`Audit statistics (last ${days} day${days === 1 ? '' : 's'})\n`));
184
- console.log(` Total events: ${s.totalEvents}`);
185
- console.log(` Log files: ${s.fileCount} (${humanBytes(s.totalBytes)})`);
186
- console.log(` Log path: ${chalk.gray(getLogsPath())}`);
187
- if (Object.keys(s.byLevel).length) {
188
- console.log(chalk.bold('\n By level:'));
189
- for (const [k, v] of Object.entries(s.byLevel).sort((a, b) => b[1] - a[1])) {
190
- console.log(` ${levelColor(k).padEnd(20)} ${v}`);
191
- }
192
- }
193
- if (Object.keys(s.byEvent).length) {
194
- console.log(chalk.bold('\n By event (top 15):'));
195
- for (const [k, v] of Object.entries(s.byEvent).sort((a, b) => b[1] - a[1]).slice(0, 15)) {
196
- console.log(` ${chalk.cyan(k).padEnd(30)} ${v}`);
197
- }
198
- }
199
- if (Object.keys(s.byModule).length) {
200
- console.log(chalk.bold('\n By module:'));
201
- for (const [k, v] of Object.entries(s.byModule).sort((a, b) => b[1] - a[1])) {
202
- console.log(` ${k.padEnd(20)} ${v}`);
203
- }
204
- }
205
- if (Object.keys(s.byUser).length) {
206
- console.log(chalk.bold('\n By user:'));
207
- for (const [k, v] of Object.entries(s.byUser).sort((a, b) => b[1] - a[1])) {
208
- console.log(` ${k.padEnd(30)} ${v}`);
209
- }
210
- }
211
- if (Object.keys(s.byActor).length) {
212
- console.log(chalk.bold('\n By actor:'));
213
- for (const [k, v] of Object.entries(s.byActor).sort((a, b) => b[1] - a[1])) {
214
- console.log(` ${k.padEnd(30)} ${v}`);
215
- }
216
- }
217
- console.log();
218
- }
219
- export function registerLogsCommand(program) {
220
- const logsCmd = program
135
+ export function registerEventsLogsCommand(events) {
136
+ const logs = events
221
137
  .command('logs [id]')
222
- .description('Show a run log, audit trail, or stats. Subcommands: audit, stats, rotate.')
138
+ .description('Show the log of a dispatched run or a session')
223
139
  .option('--device <name>', 'Scope to runs dispatched to a device')
224
140
  .option('-a, --agent <agent>', 'Filter by agent (e.g. claude, codex@0.116.0)')
225
141
  .option('--version <version>', 'Filter by agent version')
226
142
  .option('--session <id>', 'Select a session/run by id (same as the positional id)')
227
143
  .option('-f, --follow', 'Follow live output')
228
144
  .option('-m, --full', 'Show the full raw transcript / stdout instead of the concise summary')
229
- .option('--json', 'Machine-readable JSON: a host task as { kind, task, log }, a session as the redacted { session, events } (same shape as `sessions <id> --json`)')
230
- .action((id, opts) => runLogs(id, opts));
231
- addEventsReadOptions(logsCmd
232
- .command('audit')
233
- .description('Alias for `agents events audit`'))
234
- .addHelpText('after', `
235
- Examples:
236
- agents logs audit Recent activity across everything
237
- agents logs audit --module teams Team lifecycle (create / add / disband)
238
- agents logs audit --module secrets Every secret accessed or revealed
239
- agents logs audit --level audit Only audit-level events
240
- agents logs audit --command "teams create" Just team creations
241
- agents logs audit --event secrets.get --since 7d --json
242
- agents logs audit -f Live tail`)
243
- .action((_options, command) => runEventsCommand(command.optsWithGlobals(), true));
244
- logsCmd
245
- .command('stats')
246
- .description('Show aggregate audit statistics')
247
- .option('--since <time>', 'Window size (e.g. 7d, 30d; default 7d)')
248
- .option('--json', 'Output stats as JSON')
249
- .action(async (opts) => runStats(opts));
250
- logsCmd
251
- .command('rotate')
252
- .description('Apply event retention and the storage ceiling immediately')
253
- .option('--days <n>', 'Retention period in days (default 7)', '7')
254
- .option('--max-mb <n>', 'Total event storage ceiling in MiB (default 50)', '50')
255
- .action((opts) => {
256
- const days = Math.max(1, parseInt(opts.days ?? '7', 10) || 7);
257
- const maxMb = Math.max(1, parseInt(opts.maxMb ?? '50', 10) || 50);
258
- const result = rotate(days, maxMb * 1024 * 1024);
259
- const removed = result.removedByAge + result.removedBySize;
260
- if (removed > 0) {
261
- console.log(`Removed ${removed} event file${removed === 1 ? '' : 's'} ` +
262
- `(${result.removedByAge} by age, ${result.removedBySize} by size); ` +
263
- `reclaimed ${humanBytes(result.bytesReclaimed)}.`);
264
- }
265
- else {
266
- console.log(chalk.gray(`No event files removed (retention ${days} days, ceiling ${maxMb} MiB).`));
267
- }
145
+ .option('--json', 'Machine-readable JSON: a host task as { kind, task, log }, a session as the redacted { session, events }')
146
+ .action((id, _opts, command) => runLogs(id, command.optsWithGlobals()));
147
+ setHelpSections(logs, {
148
+ examples: `
149
+ # Follow one dispatched run. The id is the one agents devices ps prints.
150
+ agents events logs <id> -f
151
+
152
+ # Runs dispatched to one device. One match shows; several ask you to pick.
153
+ agents events logs --device gpu-box
154
+
155
+ # The full raw transcript or stdout, instead of the concise summary.
156
+ agents events logs <id> --full
157
+
158
+ # Machine-readable. A host task is { kind, task, log }.
159
+ agents events logs <id> --json
160
+ `,
161
+ notes: `
162
+ With no id, this lists host tasks (and, unless --device is set, indexed
163
+ sessions) that match --agent and --version. --session <id> selects the
164
+ same run as the positional id.
165
+
166
+ --device filters those runs on this machine. It does not send the command
167
+ to that device; pass the id from agents devices ps to read one run.
168
+ `,
268
169
  });
269
170
  }
@@ -6,6 +6,7 @@ import { parseFamilyList, EVENT_FAMILIES } from '../lib/event-families.js';
6
6
  import { ingestBatch } from '../lib/events-ingest.js';
7
7
  import { setHelpSections } from '../lib/help.js';
8
8
  import { registerAuditCommands } from './audit.js';
9
+ import { registerEventsLogsCommand } from './events-logs.js';
9
10
  export function resolveEventsLimit(raw) {
10
11
  const token = raw ?? '50';
11
12
  const value = token.trim() === '' ? NaN : Number(token);
@@ -309,7 +310,7 @@ Examples:
309
310
  agents events stats
310
311
  agents events rotate --days 7
311
312
  agents events audit Alias of: events --include runs
312
- agents logs Run log viewer (also aliases events audit/stats/rotate)`)
313
+ agents events logs <run-id> -f Follow one dispatched run's log`)
313
314
  .action((_options, command) => runEventsCommand(command.optsWithGlobals()));
314
315
  registerEmitSubcommand(events);
315
316
  events
@@ -325,6 +326,7 @@ Examples:
325
326
  .option('--max-mb <n>', 'Total event storage ceiling in MiB (default 50)', '50')
326
327
  .action((opts) => runEventsRotate(opts));
327
328
  registerAuditCommands(events);
329
+ registerEventsLogsCommand(events);
328
330
  }
329
331
  export function runEventsRotate(opts) {
330
332
  const days = Math.max(1, parseInt(opts.days ?? '7', 10) || 7);
@@ -24,7 +24,6 @@ interface ExecCommandActionOptions {
24
24
  sessionId?: string;
25
25
  name?: string;
26
26
  notify?: boolean;
27
- traceSync?: boolean;
28
27
  terminal?: string | boolean;
29
28
  verbose?: boolean;
30
29
  raw?: boolean;
@@ -443,9 +443,8 @@ export function registerRunCommand(program) {
443
443
  .option('--since <time>', 'With a bare --resume: only sessions newer than this (default 30d; e.g. 2h, 7d, 4w, or ISO date)')
444
444
  .option('-n, --limit <n>', 'With a bare --resume: maximum sessions loaded into the picker (default 200)')
445
445
  .option('--session-id <id>', 'Force a NEW conversation to use this exact session UUID (Claude only). This CREATES a session — to resume an existing one, use --resume.', parseExplicitSessionId)
446
- .option('--name <slug>', 'Name the run — seeds the session label so it shows up as `<name>` in `agents sessions` and resolves by it (and `agents hosts logs <name>` for --device runs) instead of an opaque id. An agent-generated title later refines the label; your name shows until then. Optional.')
446
+ .option('--name <slug>', 'Name the run — seeds the session label so it shows up as `<name>` in `agents sessions` and resolves by it (and `agents events logs <name>` for --device runs) instead of an opaque id. An agent-generated title later refines the label; your name shows until then. Optional.')
447
447
  .option('--notify', 'Post a desktop notification when a headless run finishes. Fired by this process on exit, so it survives whatever launched the run (the menu bar dispatching it, a terminal you closed).')
448
- .option('--no-trace-sync', 'Skip the run-exit trace auto-sync for this run. Auto-sync fires by default only for local runs and only once you have run `agents traces sync` at least once (also silenced by AGENTS_NO_TRACE_SYNC=1).')
449
448
  .option('--terminal [backend]', "Open this run in a real terminal tab instead of here. Without a value the terminal is detected from your live sessions (`agents sessions --active` host), so it lands where you already work — Ghostty for a Ghostty user, iTerm for an iTerm user. Name one to force it: iterm | ghostty | terminal | tmux | vscodium-agent. This is how the menu bar's New Session opens.")
450
449
  .option('--verbose', 'Show detailed execution logs')
451
450
  .option('--raw', 'Keep this interactive run direct when the device has opted into tmux wrapping. A no-op under the default tmux-off configuration; equivalent to AGENTS_NO_TMUX=1.')
@@ -468,7 +467,7 @@ export function registerRunCommand(program) {
468
467
  .option('--local', 'Run on this machine. A bare interactive run otherwise places itself like --device auto; --local pins it here. Same as --where local or --device <this machine>.')
469
468
  .option('-D, --device <name>', 'Offload this run onto another machine over SSH — a registered device, or user@host. Pass "auto" to pick the least-loaded reachable device where the requested agent is installed and signed in, keeping the run local when no remote is better, or "interactive" for the machine pinned as interactive.host (the box a human is sitting at). Naming this machine runs locally, no SSH. Same as --where device:<name>. See `agents devices`.')
470
469
  .option('--remote-cwd <dir>', "Explicit device working directory for --device runs, used VERBATIM (overrides --cwd; usually --cwd suffices — it re-roots a local-home path onto the remote home). Pass a single-quoted '$HOME/…' or a valid remote absolute path; a local ~ expands here and won't exist there (/Users/you vs /home/you).")
471
- .option('--no-follow', 'With --device, dispatch detached and return immediately (track via `agents hosts ps/logs`).')
470
+ .option('--no-follow', 'With --device, dispatch detached and return immediately (track via `agents devices ps` and `agents events logs`).')
472
471
  .option('--any', 'With --device <cap> (a capability tag), pick any matching device instead of erroring when several match.')
473
472
  .option('--copy-creds', 'Deprecated refusal: native OAuth/session credentials cannot be copied between devices. Use `agents accounts sync <account> --device <device>` for a portable provider credential.')
474
473
  .option('--lease [backend]', "Run on a cloud box (via crabbox) and tear it down after — reuses a warm box from the repo's profile pool when one is ready (--fresh forces a new box). Optional backend selects the cloud (hetzner/aws/do). Same as --where lease[:backend]. Unlike --device, no machine is registered.")
@@ -1285,13 +1284,6 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
1285
1284
  }
1286
1285
  }
1287
1286
  const hostGiven = hostTargetGiven(options);
1288
- if (prompt !== undefined &&
1289
- hostGiven.length === 0 &&
1290
- !options.lease &&
1291
- !options.box) {
1292
- const { armRunFinishTraceSync } = await import('../lib/run-trace-sync.js');
1293
- armRunFinishTraceSync({ disabled: options.traceSync === false });
1294
- }
1295
1287
  options.cwd = await resolveRunCwd(options, { forRemote: hostGiven.length > 0 });
1296
1288
  if (hostGiven.length > 0) {
1297
1289
  if (new Set(hostGiven).size > 1) {
@@ -1522,7 +1514,7 @@ ${formatModeSupportTable().split('\n').map((line) => ` ${line}`).join('\n
1522
1514
  const handle = task.name ?? task.id;
1523
1515
  console.log(chalk.green(`Dispatched to ${host.name}${task.name ? ` as "${task.name}"` : ''}.`) + '\n' +
1524
1516
  chalk.gray(` Status: agents sessions ${handle}`) + chalk.gray(' (compact digest — use this)') + '\n' +
1525
- chalk.gray(` Raw log: agents logs ${handle} -f`) + chalk.gray(' (heavy, only if needed)'));
1517
+ chalk.gray(` Raw log: agents events logs ${handle} -f`) + chalk.gray(' (heavy, only if needed)'));
1526
1518
  process.exit(0);
1527
1519
  }
1528
1520
  if (exitCode === -1)
@@ -5,7 +5,7 @@ import { filterBlocksForFeed } from '../lib/ask-classifier.js';
5
5
  import { type FeedSessionSignal } from '../lib/feed-ranking.js';
6
6
  export declare const FEED_POST_HELP = "\nExamples:\n # Title (subject) + body. Phone broadcasts put title first, body after a\n # blank line, then a \"Sent from agent/session on host\" footer.\n agents feed post --title \"CHANGELOG pushed\" \"Watching CI and mac-mini E2E\"\n agents feed post --title \"Cover ready\" \"render at ./out/cover.png\" --attach ./out/cover.png\n agents feed post --title \"Ready for review\" \"PR opened, waiting on prix-cloud\" --json\n\n # Worth interrupting someone over - reaches sinks gated on minLevel: important:\n agents feed post --title \"npm token expired\" \"Cannot publish the release\" --level important\n\n # Also raise a local desktop banner on THIS machine (same notifier as run\n # --notify), on top of any configured broadcast - useful when you are at the box:\n agents feed post --title \"Build green\" \"all checks passed\" --notify\n\n # Stuck: opens a needs-you block and always broadcasts at important:\n agents feed post --title \"Force-push denied\" \"git-guard blocked PR #1749\" --blocked\n agents feed post --title \"Publish or wait?\" \"npm publish now or after review\" --blocked --option publish --option wait\n agents feed post --title \"Delete preview env?\" \"stale preview still running\" --blocked --default \"leave it\"\n\n # Exhaust self-serve FIRST. A block is for what you genuinely cannot do:\n # a credential only the user holds, a decision only they can make, an\n # approval only they can give. Not \"should I do the obvious next step?\".\n\n # Outside a run, pass the session explicitly:\n agents feed post --title \"Manual note\" \"context for the next agent\" --session 00998b0e-2d15-4d2f-a58b-974a886c9b47\n\nIdentity (session, agent, host, runtime, pid, launchId) is stamped automatically\nand rides the phone footer of feed.broadcast {message}. Domain facts (tickets,\nPRs) are not CLI flags - the ticket is joined from the session index at post\ntime. No em-dashes in title/body - they are scrubbed on the way out.\n\nConfigure where a post is mirrored under feed.broadcast in agents.yaml - see\ndocs/observability.md. A channel sink may set message: with placeholders such\nas {message} and {ticket}; a missing placeholder skips that sink. A milestone is always recorded, but it does not reach\nthe owner when the sink has minLevel: important. Add --level important for a\nphone-worthy successful update. Use --blocked only when work cannot continue.\nWith no sinks configured, an important post or a block reaches the owner through\nyour account (agents auth login); a block is a needs_you event and bypasses\nquiet hours. The account's preferences pick email, Slack or iMessage.\n";
7
7
  export declare function formatFeedMastheadRight(blocks: OpenBlock[]): string;
8
- export declare function formatFeedReplyHint(mailboxId: string): string;
8
+ export declare function formatFeedReplyHint(block: Pick<OpenBlock, 'host' | 'sessionId' | 'generation' | 'ts'>): string;
9
9
  export declare function parseRemoteFeed(stdout: string, machine: string): OpenBlock[];
10
10
  export declare function mergeFeedBlocks(...groups: OpenBlock[][]): OpenBlock[];
11
11
  type FeedControlAction = 'pause' | 'kill';
@@ -6,7 +6,6 @@ import { postFeedStatus } from '../lib/feed-post.js';
6
6
  import { linearIssueUrl } from '@phnx-labs/sessions-cli/reader';
7
7
  import { parseFeedPostLevel, planFeedBroadcast, runFeedBroadcast, effectiveBroadcastConfig, withDesktopNotify, blockBroadcastContext, blockDeliveryFailure, } from '../lib/feed-broadcast.js';
8
8
  import { getSessionById, resolveFullSessionId } from '../lib/session/db.js';
9
- import { fireTraceSyncInBackground } from '../lib/run-trace-sync.js';
10
9
  import { readMeta } from '../lib/state.js';
11
10
  import { enrichBlocksFromSessions, groupBlocksByOutcome, isUnambiguousOutcomeAnswer, openBlocksForOutcome, stampBlockOutcomes, } from '../lib/feed-outcome.js';
12
11
  import { classifyBlock, filterBlocksForFeed, suppressionDigest, } from '../lib/ask-classifier.js';
@@ -71,8 +70,9 @@ export function formatFeedMastheadRight(blocks) {
71
70
  const agents = new Set(blocks.map((b) => b.mailboxId)).size;
72
71
  return `${blocks.length} block${blocks.length === 1 ? '' : 's'} · ${agents} agent${agents === 1 ? '' : 's'}`;
73
72
  }
74
- export function formatFeedReplyHint(mailboxId) {
75
- return `↳ ag message ${mailboxId} "…"`;
73
+ export function formatFeedReplyHint(block) {
74
+ const key = `${block.host}/${block.sessionId}/${block.generation ?? block.ts}`;
75
+ return `↳ ag feed answer ${key} --text "…"`;
76
76
  }
77
77
  export function parseRemoteFeed(stdout, machine) {
78
78
  let parsed;
@@ -220,7 +220,7 @@ function renderBlock(b, localHost, indent = '') {
220
220
  console.log(`${indent} ${chalk.dim(`inspect: ag sessions ${b.sessionId}`)}`);
221
221
  }
222
222
  if (!b.answer && !b.parkedAt && b.kind !== 'control') {
223
- console.log(`${indent} ${chalk.dim(formatFeedReplyHint(b.mailboxId))}`);
223
+ console.log(`${indent} ${chalk.dim(formatFeedReplyHint(b))}`);
224
224
  }
225
225
  console.log();
226
226
  }
@@ -662,8 +662,6 @@ async function broadcastPostedEvent(event, level, meta, notify = false) {
662
662
  .filter((href) => /^https?:\/\//i.test(href)),
663
663
  eventKey: `${session}:${event.ts}`,
664
664
  }, meta);
665
- if (level === 'important')
666
- fireTraceSyncInBackground();
667
665
  return runFeedBroadcast(planned, meta);
668
666
  }
669
667
  async function broadcastBlock(block, extras, meta, notify = false) {
@@ -673,7 +671,6 @@ async function broadcastBlock(block, extras, meta, notify = false) {
673
671
  const sessionId = resolveFullSessionId(block.sessionId) ?? block.sessionId;
674
672
  const ticket = getSessionById(sessionId)?.ticketId;
675
673
  const ctx = blockBroadcastContext({ ...block, sessionId, ticket: block.ticket ?? ticket }, extras);
676
- fireTraceSyncInBackground();
677
674
  return runFeedBroadcast(planFeedBroadcast(config, ctx, meta), meta);
678
675
  }
679
676
  function reportBroadcast(outcomes) {
@@ -237,7 +237,7 @@ Examples:
237
237
  return;
238
238
  }
239
239
  if (commandOrUrl.length === 0) {
240
- const { getMcpServerInfo, mcpEntryToInstallSpec } = await import('../lib/registry.js');
240
+ const { getMcpServerInfo, mcpEntryToInstallSpec } = await import('../lib/mcp-lookup.js');
241
241
  const spinner = ora(`Looking up '${name}' in MCP registries…`).start();
242
242
  try {
243
243
  const entry = await getMcpServerInfo(name);
@@ -1,98 +1,11 @@
1
1
  import chalk from 'chalk';
2
2
  import { setHelpSections } from '../lib/help.js';
3
- import { updateMenubarHelperIfNewer, enableMenubarService, disableMenubarService, getMenubarStatus, restartMenubarHelper, runMenubarSetup, buildMenubarDoctorReport, } from '../lib/menubar/install-menubar.js';
4
- function notMac() {
5
- if (process.platform !== 'darwin') {
6
- console.log(chalk.yellow('AGI Menu is macOS only.'));
7
- return true;
8
- }
9
- return false;
10
- }
11
- function printStatus(s, opts = {}) {
12
- const yn = (b) => (b ? chalk.green('yes') : chalk.gray('no'));
13
- console.log(chalk.bold('AGI Menu\n'));
14
- console.log(` running ${yn(s.running)}`);
15
- console.log(` service installed ${yn(s.serviceInstalled)}`);
16
- if (opts.brief) {
17
- console.log(chalk.gray('\n setup | restart | enable | disable | status'));
18
- return;
19
- }
20
- console.log(` app installed ${s.installedApp ? chalk.gray(s.installedApp) : chalk.gray('no')}`);
21
- console.log(` helper installed ${s.installedVersion ? chalk.gray(s.installedVersion) : chalk.gray('unknown')}`);
22
- console.log(` helper available ${chalk.gray(s.currentVersion)}`);
23
- console.log(` CLI version ${chalk.gray(s.cliVersion)}`);
24
- const pendingSource = s.disabledByUser
25
- ? chalk.gray('none (disabled by user — `agents menubar enable` fetches it)')
26
- : chalk.yellow(`not fetched yet — the background sync downloads ${s.currentVersion}; \`agents menubar setup\` fetches it now`);
27
- console.log(` bundle source ${s.source ? chalk.gray(s.source) : pendingSource}`);
28
- console.log(` disabled by user ${yn(s.disabledByUser)}`);
29
- if (s.instances.length > 1) {
30
- console.log(chalk.yellow(`\n ${s.instances.length} copies of AGI Menu are running — that is the duplicate menu-bar icon:`));
31
- for (const p of s.instances)
32
- console.log(chalk.gray(` ${p.pid} ${p.executable}`));
33
- console.log(chalk.gray(' Fix it with `agents menubar setup`.'));
34
- }
35
- if (s.foreignInstances.length > 0) {
36
- const n = s.foreignInstances.length;
37
- console.log(chalk.yellow(`\n ${n} other AGI Menu process${n === 1 ? '' : 'es'} running — ${n === 1 ? 'it' : 'they'} may hold Cmd-Shift-V/O instead of the installed one:`));
38
- for (const p of s.foreignInstances)
39
- console.log(chalk.gray(` ${p.pid} ${p.executable}`));
40
- console.log(chalk.gray(' End them with `agents menubar setup`.'));
41
- }
42
- if (s.stale) {
43
- console.log(chalk.yellow('\n Installed AGI Menu is stale — `agents menubar setup` updates it now.'));
44
- }
45
- else if (!s.serviceInstalled && !s.disabledByUser) {
46
- console.log(chalk.gray('\n Set it up with `agents menubar setup`.'));
47
- }
48
- }
49
- function printSetupResult(r) {
50
- console.log(chalk.bold('AGI Menu setup\n'));
51
- for (const step of r.steps) {
52
- const mark = step.outcome === 'failed' ? chalk.red('✗')
53
- : step.outcome === 'changed' ? chalk.green('+') : chalk.green('✓');
54
- console.log(` ${mark} ${step.name.padEnd(15)} ${chalk.gray(step.detail)}`);
55
- }
56
- console.log();
57
- if (r.configured) {
58
- console.log(chalk.green('AGI Menu configured.') + chalk.gray(' One agents mark, started at login.'));
59
- }
60
- else {
61
- console.log(chalk.red('AGI Menu not fully configured.') + chalk.gray(' See the failed step above.'));
62
- }
63
- }
64
- function printDoctorReport(r) {
65
- console.log(chalk.bold('AGI Menu doctor\n'));
66
- console.log(` install path ${r.installPath ? chalk.gray(r.installPath) : chalk.red('not installed')}`);
67
- console.log(` helper installed ${r.installedVersion ? chalk.gray(r.installedVersion) : chalk.gray('unknown')}`);
68
- console.log(` helper available ${chalk.gray(r.currentVersion)}${r.versionMatches ? '' : chalk.yellow(' (newer helper available — `agents menubar setup` installs it)')}`);
69
- console.log(` CLI version ${chalk.gray(r.cliVersion)}`);
70
- const identity = r.signingIdentity === 'developer-id'
71
- ? chalk.green('Developer ID (update-stable)')
72
- : r.signingIdentity === 'ad-hoc'
73
- ? chalk.red('ad-hoc (unstable — Accessibility grant breaks on every update)')
74
- : chalk.gray('unknown (nothing installed)');
75
- console.log(` signing identity ${identity}`);
76
- console.log(` running ${r.running ? chalk.green('yes') : chalk.gray('no')}`);
77
- if (r.staleRunningProcess.length > 0) {
78
- for (const p of r.staleRunningProcess) {
79
- const mark = p.stale
80
- ? chalk.red('started BEFORE the on-disk bundle — running the OLD binary')
81
- : chalk.green('matches the on-disk bundle');
82
- console.log(` pid ${String(p.pid).padEnd(10)} ${mark}`);
83
- }
84
- }
85
- if (r.accessibilityHintNeeded) {
86
- console.log(chalk.yellow('\n Accessibility grant may not be trusted for the current binary.'));
87
- console.log(chalk.gray(' Run `agents menubar setup` to reinstall + restart the helper, then grant access:'));
88
- console.log(chalk.gray(' open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility"'));
89
- }
90
- }
3
+ import { updateMenubarHelperIfNewer, disableMenubarService, restartMenubarHelper, } from '../lib/menubar/install-menubar.js';
91
4
  export function registerMenubarCommands(program) {
92
5
  const menubar = program
93
- .command('menubar')
94
- .description('Manage AGI Menu (running sessions, agents awaiting input, routines)');
95
- const update = menubar.command('update')
6
+ .command('menubar', { hidden: true })
7
+ .description('AGI Menu lifecycle hooks the helper calls (status lives in `agents doctor`)');
8
+ const update = menubar.command('update', { hidden: true })
96
9
  .description('Check for or install the newest AGI Menu release')
97
10
  .option('--check', 'Check only; do not download, install, or restart the app')
98
11
  .option('--json', 'Emit machine-readable update status')
@@ -119,7 +32,7 @@ export function registerMenubarCommands(program) {
119
32
  after this command exits. Check-only never installs or restarts the app.
120
33
  `,
121
34
  });
122
- const restart = menubar.command('restart')
35
+ const restart = menubar.command('restart', { hidden: true })
123
36
  .description('Restart the running AGI Menu through its login item')
124
37
  .option('--json', 'Emit machine-readable restart result')
125
38
  .action(async (options) => {
@@ -140,61 +53,8 @@ export function registerMenubarCommands(program) {
140
53
  Restarts AGI Menu with launchctl kickstart -k and waits up to 15 seconds
141
54
  for exactly one new process. The kickstart runs in its own session, so
142
55
  the restart completes even when AGI Menu itself requested it. A turned-off
143
- AGI Menu is refused rather than started; \`agents menubar setup\` turns it on.
144
- `,
145
- });
146
- const setup = menubar
147
- .command('setup')
148
- .description('Configure AGI Menu end-to-end: one instance, started at login')
149
- .option('--check', 'Report the current state, change nothing')
150
- .option('--json', 'Emit machine-readable JSON')
151
- .action(async (options) => {
152
- if (options.check) {
153
- const s = getMenubarStatus();
154
- if (options.json) {
155
- process.stdout.write(JSON.stringify(s) + '\n');
156
- return;
157
- }
158
- if (notMac())
159
- return;
160
- printStatus(s);
161
- return;
162
- }
163
- if (!options.json && notMac())
164
- return;
165
- const r = await runMenubarSetup();
166
- if (options.json) {
167
- process.stdout.write(JSON.stringify(r) + '\n');
168
- }
169
- else {
170
- printSetupResult(r);
171
- }
172
- if (!r.configured)
173
- process.exitCode = 1;
174
- });
175
- setHelpSections(setup, {
176
- examples: `
177
- # Configure AGI Menu end-to-end (idempotent — safe to re-run)
178
- agents menubar setup
179
-
180
- # Two agents marks in the menu bar? This ends the duplicate.
181
- agents menubar setup
182
-
183
- # See the current state without changing anything
184
- agents menubar setup --check
185
- `,
186
- notes: `
187
- Configures, in order: every running helper ended, AGI Menu at
188
- ~/Library/Application Support/agents-cli/MenubarHelper.app, its code
189
- signature, the launchd login item (com.phnx-labs.agents-menubar —
190
- RunAtLoad, relaunched after a crash but not after Quit), then verifies
191
- exactly one helper came back up.
192
-
193
- Every running helper is ended and launchd restarts one, so the survivor is
194
- always the login-managed copy. Exits nonzero if it cannot reach that state.
195
-
196
- Setup clears a previous \`agents menubar disable\`. To turn AGI Menu off
197
- again, run \`agents menubar disable\`.
56
+ AGI Menu is refused rather than started; \`agents config set menubar.enabled true\`
57
+ turns it on.
198
58
  `,
199
59
  });
200
60
  menubar
@@ -206,88 +66,14 @@ export function registerMenubarCommands(program) {
206
66
  process.stdout.write(`${JSON.stringify(await computeMenubarSnapshot())}\n`);
207
67
  });
208
68
  menubar
209
- .command('enable')
210
- .description('Install and start AGI Menu (launches at login)')
211
- .action(async () => {
212
- if (notMac())
213
- return;
214
- let ok = false;
215
- try {
216
- ok = await enableMenubarService({ clearOptOut: true });
217
- }
218
- catch (e) {
219
- console.log(chalk.red(`Could not enable AGI Menu: ${e.message}`));
220
- return;
221
- }
222
- if (!ok) {
223
- console.log(chalk.red('Could not enable: no AGI Menu bundle ships with this install.'));
224
- console.log(chalk.gray(' This build may predate the helper, or be a non-macOS package.'));
225
- return;
226
- }
227
- console.log(chalk.green('AGI Menu enabled.') + chalk.gray(' Look for the agents mark in your menu bar.'));
228
- });
229
- menubar
230
- .command('disable')
231
- .description('Stop and remove AGI Menu (stays off across upgrades)')
69
+ .command('disable', { hidden: true })
70
+ .description('Set menubar.enabled false and remove the AGI Menu login item')
232
71
  .action(() => {
233
- if (notMac())
234
- return;
235
- disableMenubarService();
236
- console.log(chalk.green('AGI Menu disabled.') + chalk.gray(' Re-enable any time with `agents menubar setup`.'));
237
- });
238
- menubar
239
- .command('status')
240
- .description('Show whether AGI Menu is installed and running')
241
- .option('--json', 'Emit machine-readable JSON')
242
- .action((options) => {
243
- const s = getMenubarStatus();
244
- if (options.json) {
245
- process.stdout.write(JSON.stringify(s) + '\n');
246
- return;
247
- }
248
- if (s.platform !== 'darwin') {
249
- console.log(chalk.yellow('AGI Menu is macOS only.'));
250
- return;
251
- }
252
- printStatus(s);
253
- });
254
- const doctor = menubar
255
- .command('doctor')
256
- .description('Diagnose AGI Menu: install path, version skew, signing identity, stale process')
257
- .option('--json', 'Emit machine-readable JSON')
258
- .action((options) => {
259
- const r = buildMenubarDoctorReport();
260
- if (options.json) {
261
- process.stdout.write(JSON.stringify(r) + '\n');
262
- return;
263
- }
264
- if (r.platform !== 'darwin') {
72
+ if (process.platform !== 'darwin') {
265
73
  console.log(chalk.yellow('AGI Menu is macOS only.'));
266
74
  return;
267
75
  }
268
- printDoctorReport(r);
269
- });
270
- setHelpSections(doctor, {
271
- examples: `
272
- # Why did Accessibility ask again after an update?
273
- agents menubar doctor
274
- `,
275
- notes: `
276
- Read-only — never installs, restarts, or resets anything. Reports the
277
- installed bundle's signing identity (ad-hoc signing breaks the
278
- Accessibility grant on every update; Developer ID is stable across
279
- updates) and whether a live helper pid started before the on-disk
280
- bundle's last write — the sign that a running process is still the
281
- binary an update just replaced. \`agents menubar setup\` is the fix for
282
- anything this flags.
283
- `,
284
- });
285
- menubar.action(() => {
286
- const s = getMenubarStatus();
287
- if (s.platform !== 'darwin') {
288
- console.log(chalk.yellow('AGI Menu is macOS only.'));
289
- return;
290
- }
291
- printStatus(s, { brief: true });
76
+ disableMenubarService();
77
+ console.log(chalk.green('AGI Menu disabled.') + chalk.gray(' Re-enable with `agents config set menubar.enabled true`.'));
292
78
  });
293
79
  }
@@ -3,8 +3,7 @@ import * as fs from 'fs';
3
3
  import * as path from 'path';
4
4
  import { execFileSync, spawnSync } from 'child_process';
5
5
  import { setHelpSections } from '../lib/help.js';
6
- import { getMainRepoRoot } from '../lib/git.js';
7
- import { parseOwnerRepoFromRemote } from '../lib/registry.js';
6
+ import { getMainRepoRoot, parseOwnerRepoFromRemote } from '../lib/git.js';
8
7
  import { truncate } from '../lib/format.js';
9
8
  import { expandLocalHome, getProjectRoot, toHomeRelative } from '../lib/project-root.js';
10
9
  import { machineId } from '../lib/machine-id.js';
@@ -1,3 +1,3 @@
1
1
  import type { Command } from 'commander';
2
2
  export declare function restoreVersion(target: string): void;
3
- export declare function registerTrashCommands(program: Command): void;
3
+ export declare function registerPruneTrashCommands(prune: Command): void;