@phnx-labs/agents-cli 1.23.21 → 1.23.23

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 (176) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +17 -0
  3. package/dist/bootstrap.js +5 -4
  4. package/dist/cli/command-registry.js +2 -0
  5. package/dist/commands/config.js +16 -0
  6. package/dist/commands/daemon.js +3 -3
  7. package/dist/commands/doctor.js +10 -19
  8. package/dist/commands/events.js +1 -14
  9. package/dist/commands/feed-watch.js +5 -2
  10. package/dist/commands/go.js +2 -2
  11. package/dist/commands/lead.d.ts +3 -0
  12. package/dist/commands/lead.js +280 -0
  13. package/dist/commands/projects.js +3 -2
  14. package/dist/commands/ps-roster.d.ts +2 -12
  15. package/dist/commands/ps-roster.js +5 -87
  16. package/dist/commands/ps.js +3 -1
  17. package/dist/commands/repo.js +12 -12
  18. package/dist/commands/resource-view.js +5 -5
  19. package/dist/commands/sessions-browser.js +2 -2
  20. package/dist/commands/sessions-watch.js +5 -2
  21. package/dist/commands/setup-secrets.d.ts +3 -4
  22. package/dist/commands/setup-secrets.js +15 -46
  23. package/dist/commands/setup-session-backup.js +1 -1
  24. package/dist/commands/ssh.d.ts +0 -4
  25. package/dist/commands/ssh.js +14 -81
  26. package/dist/commands/teams-picker.js +1 -12
  27. package/dist/commands/teams.js +1 -13
  28. package/dist/commands/view.d.ts +1 -40
  29. package/dist/commands/view.js +9 -330
  30. package/dist/commands/watchdog.js +4 -4
  31. package/dist/index.js +4 -0
  32. package/dist/lib/accounting/usage.d.ts +0 -1
  33. package/dist/lib/accounting/usage.js +1 -112
  34. package/dist/lib/accounts/add.js +1 -1
  35. package/dist/lib/accounts/migrate.js +1 -1
  36. package/dist/lib/auto-pull-worker.js +2 -16
  37. package/dist/lib/auto-pull.d.ts +1 -0
  38. package/dist/lib/auto-pull.js +27 -0
  39. package/dist/lib/browser-client.js +2 -11
  40. package/dist/lib/cloud/codex.js +3 -0
  41. package/dist/lib/commands.d.ts +0 -6
  42. package/dist/lib/commands.js +3 -116
  43. package/dist/lib/comms-render.d.ts +1 -7
  44. package/dist/lib/comms-render.js +0 -19
  45. package/dist/lib/computer-client.js +2 -11
  46. package/dist/lib/config-keys.d.ts +7 -3
  47. package/dist/lib/config-keys.js +15 -2
  48. package/dist/lib/crabbox/runtimes.d.ts +0 -14
  49. package/dist/lib/crabbox/runtimes.js +0 -80
  50. package/dist/lib/daemon/attention-notify-service.d.ts +53 -28
  51. package/dist/lib/daemon/attention-notify-service.js +232 -53
  52. package/dist/lib/daemon/daemon.js +1 -2
  53. package/dist/lib/daemon/feed-stream-service.js +2 -4
  54. package/dist/lib/device-config.d.ts +0 -5
  55. package/dist/lib/device-config.js +20 -27
  56. package/dist/lib/devices/doctor-findings.d.ts +2 -1
  57. package/dist/lib/devices/doctor-findings.js +12 -1
  58. package/dist/lib/devices/fleet.d.ts +6 -0
  59. package/dist/lib/devices/fleet.js +15 -0
  60. package/dist/lib/devices/harness-inventory.d.ts +9 -0
  61. package/dist/lib/devices/harness-inventory.js +66 -0
  62. package/dist/lib/exec.js +1 -3
  63. package/dist/lib/feed/attention.d.ts +16 -1
  64. package/dist/lib/feed/attention.js +63 -1
  65. package/dist/lib/feed/feed.d.ts +1 -1
  66. package/dist/lib/feed/feed.js +12 -2
  67. package/dist/lib/feed/hub.d.ts +9 -0
  68. package/dist/lib/feed/hub.js +27 -1
  69. package/dist/lib/feed/notify-schedule.d.ts +16 -0
  70. package/dist/lib/feed/notify-schedule.js +62 -0
  71. package/dist/lib/feed/ticket-priority.d.ts +4 -0
  72. package/dist/lib/feed/ticket-priority.js +30 -0
  73. package/dist/lib/feed/watch.d.ts +1 -0
  74. package/dist/lib/feed/watch.js +27 -3
  75. package/dist/lib/feed-ranking.d.ts +1 -0
  76. package/dist/lib/feed-ranking.js +3 -1
  77. package/dist/lib/format.d.ts +0 -2
  78. package/dist/lib/format.js +0 -8
  79. package/dist/lib/helper-versions.js +1 -1
  80. package/dist/lib/hooks/cache.d.ts +1 -0
  81. package/dist/lib/hooks/cache.js +12 -1
  82. package/dist/lib/installations/duplicate-prune.d.ts +37 -0
  83. package/dist/lib/installations/duplicate-prune.js +85 -0
  84. package/dist/lib/installations/inventory-json.d.ts +20 -0
  85. package/dist/lib/installations/inventory-json.js +252 -0
  86. package/dist/lib/installations/shims.d.ts +0 -18
  87. package/dist/lib/installations/shims.js +1 -257
  88. package/dist/lib/lead/brief.d.ts +49 -0
  89. package/dist/lib/lead/brief.js +173 -0
  90. package/dist/lib/lead/client.d.ts +21 -0
  91. package/dist/lib/lead/client.js +167 -0
  92. package/dist/lib/lead/confirm.d.ts +22 -0
  93. package/dist/lib/lead/confirm.js +73 -0
  94. package/dist/lib/lead/events.d.ts +106 -0
  95. package/dist/lib/lead/events.js +188 -0
  96. package/dist/lib/lead/harness.d.ts +29 -0
  97. package/dist/lib/lead/harness.js +107 -0
  98. package/dist/lib/lead/host.d.ts +132 -0
  99. package/dist/lib/lead/host.js +675 -0
  100. package/dist/lib/lead/paths.d.ts +22 -0
  101. package/dist/lib/lead/paths.js +69 -0
  102. package/dist/lib/lead/refs.d.ts +17 -0
  103. package/dist/lib/lead/refs.js +75 -0
  104. package/dist/lib/lead/roster.d.ts +26 -0
  105. package/dist/lib/lead/roster.js +121 -0
  106. package/dist/lib/lead/shapes.d.ts +23 -0
  107. package/dist/lib/lead/shapes.js +95 -0
  108. package/dist/lib/lead/store.d.ts +46 -0
  109. package/dist/lib/lead/store.js +77 -0
  110. package/dist/lib/lead/tools.d.ts +18 -0
  111. package/dist/lib/lead/tools.js +106 -0
  112. package/dist/lib/lead/visibility.d.ts +16 -0
  113. package/dist/lib/lead/visibility.js +77 -0
  114. package/dist/lib/mailbox.d.ts +0 -18
  115. package/dist/lib/mailbox.js +0 -170
  116. package/dist/lib/menubar/notify-desktop.d.ts +5 -0
  117. package/dist/lib/menubar/notify-desktop.js +24 -0
  118. package/dist/lib/models.js +1 -19
  119. package/dist/lib/permissions.d.ts +0 -6
  120. package/dist/lib/permissions.js +0 -140
  121. package/dist/lib/platform/process.d.ts +1 -0
  122. package/dist/lib/platform/process.js +5 -0
  123. package/dist/lib/probe.js +13 -1
  124. package/dist/lib/project-status.js +4 -3
  125. package/dist/lib/projects.d.ts +9 -0
  126. package/dist/lib/projects.js +61 -3
  127. package/dist/lib/scheduling/routines.d.ts +1 -13
  128. package/dist/lib/scheduling/routines.js +1 -37
  129. package/dist/lib/secrets-cli.d.ts +3 -3
  130. package/dist/lib/secrets-cli.js +1 -1
  131. package/dist/lib/secrets-client.d.ts +4 -37
  132. package/dist/lib/secrets-client.js +19 -265
  133. package/dist/lib/session/active.d.ts +18 -8
  134. package/dist/lib/session/active.js +94 -18
  135. package/dist/lib/session/db.d.ts +0 -16
  136. package/dist/lib/session/db.js +1 -134
  137. package/dist/lib/session/detached.d.ts +0 -1
  138. package/dist/lib/session/detached.js +0 -18
  139. package/dist/lib/session/pending-work.d.ts +21 -0
  140. package/dist/lib/session/pending-work.js +284 -0
  141. package/dist/lib/session/remote/remote-list.d.ts +0 -3
  142. package/dist/lib/session/remote/remote-list.js +1 -23
  143. package/dist/lib/session/remote/watch.d.ts +5 -0
  144. package/dist/lib/session/remote/watch.js +19 -2
  145. package/dist/lib/session/session-cache.d.ts +1 -1
  146. package/dist/lib/session/session-cache.js +12 -5
  147. package/dist/lib/session/sync/provision.js +1 -2
  148. package/dist/lib/smart-launch.js +7 -2
  149. package/dist/lib/snapshot.js +3 -4
  150. package/dist/lib/ssh-exec.d.ts +0 -40
  151. package/dist/lib/ssh-exec.js +0 -108
  152. package/dist/lib/ssh-tunnel.d.ts +0 -6
  153. package/dist/lib/ssh-tunnel.js +0 -42
  154. package/dist/lib/standalone-tools.js +12 -1
  155. package/dist/lib/startup/command-registry.js +1 -1
  156. package/dist/lib/startup/spellcheck.d.ts +0 -1
  157. package/dist/lib/startup/spellcheck.js +1 -20
  158. package/dist/lib/state.d.ts +0 -6
  159. package/dist/lib/state.js +1 -14
  160. package/dist/lib/teams/delivery.d.ts +1 -0
  161. package/dist/lib/teams/delivery.js +13 -0
  162. package/dist/lib/types.d.ts +0 -37
  163. package/dist/lib/types.js +0 -9
  164. package/dist/lib/watchdog/log.d.ts +1 -1
  165. package/dist/lib/watchdog/log.js +6 -4
  166. package/package.json +2 -1
  167. package/dist/lib/artifact-actions.d.ts +0 -7
  168. package/dist/lib/artifact-actions.js +0 -39
  169. package/dist/lib/session/sync/managed-config.d.ts +0 -3
  170. package/dist/lib/session/sync/managed-config.js +0 -3
  171. package/dist/lib/session/sync/worker-template.d.ts +0 -1
  172. package/dist/lib/session/sync/worker-template.js +0 -807
  173. package/dist/lib/storage/selection.d.ts +0 -8
  174. package/dist/lib/storage/selection.js +0 -10
  175. package/dist/lib/watchdog/index.d.ts +0 -3
  176. package/dist/lib/watchdog/index.js +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,120 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.23.23
4
+
5
+ - **The daemon no longer restarts in a loop on a busy Mac when it posts banners for the whole fleet.** With `interactive.host` set to this machine, `attention-notify` ran its hourly mailbox sweep inside its 10-second tick, and in that mode the sweep began with a full session scan. On a Mac at load ~120 the scan took over 100 s, the daemon restarted for the overrun, and the restarted service ran the sweep again on its first tick (50 restarts in a day on the owner's laptop). The scan now runs beside the tick, one at a time, and the first sweep waits an hour after the service starts. Source: `cli/src/lib/daemon/attention-notify-service.ts`.
6
+
7
+ ## 1.23.22
8
+
9
+ - **Secrets calls go through the published `@phnx-labs/secrets-cli/client`, and an unset `SECRETS_HOME` is no longer forced to `~/.agents` (PHNX-4227). Requires the `secrets` engine 0.4.0 or newer.**
10
+ agents-cli kept a private copy of the process client for `secrets __serve`; it
11
+ now imports the one secrets-cli 0.4.0 publishes (exact-pinned) and keeps only its
12
+ typed wrappers, so the two cannot drift. Timeouts, the
13
+ `AGENTS_SECRETS_PASSPHRASE` alias, one `secrets __serve` process per request,
14
+ and engine stderr going to `secrets-serve.log` under the agents logs directory
15
+ (never the terminal) are unchanged. Every response now carries the engine's
16
+ contract, so an engine older than 0.4.0 fails every secrets read with
17
+ `ENGINE_INCOMPATIBLE` instead of reporting a missing bundle from another root.
18
+ Upgrade each machine, fleet workers included, with
19
+ `agents setup tools --tool secrets` (or `npm i -g @phnx-labs/secrets-cli@0.4.0`);
20
+ `agents doctor` reports an old engine as the critical
21
+ `secrets-engine-incompatible` finding, locally and for fleet devices. Every
22
+ internal secrets read and the agents launched by `agents run` leave an unset
23
+ `SECRETS_HOME` unset, so the standalone uses its own default root
24
+ (`~/.agents/.secrets`, which adopts the earlier `~/.agents` and `~/.secrets`
25
+ stores on first use and follows `AGENTS_REAL_HOME` when a harness such as
26
+ Cursor swaps `HOME`); an explicit `SECRETS_HOME` still wins. A bundle push
27
+ (`agents accounts login --fleet`, the worker `auth-sync` provisioning) likewise
28
+ stops pinning the receiver to `~/.agents`, so the bundle lands in the default
29
+ root the worker's agents-cli now reads; an explicit `remoteSecretsHome` still
30
+ wins. The standalone `agents setup tools` installs is raised from 0.1.8 to
31
+ 0.4.0. `agents setup secrets` enforces that floor through the same
32
+ `ensureToolPins` path instead of accepting any `secrets` on PATH, and an
33
+ explicit `SECRETS_BIN` below it fails with the version it read rather than
34
+ installing over PATH. Source: `cli/src/lib/secrets-client.ts`,
35
+ `cli/src/lib/exec.ts`, `cli/src/lib/secrets-cli.ts`,
36
+ `cli/src/lib/standalone-tools.ts`, `cli/src/commands/setup-secrets.ts`,
37
+ `cli/src/commands/doctor.ts`, `cli/src/lib/devices/doctor-findings.ts`,
38
+ `cli/package.json`, `cli/tests/secrets-standalone.ts`.
39
+
40
+ - **Agent asks carry an urgency.** `agents feed watch --json` attention rows carry `urgency`
41
+ (`urgent`, `high`, `normal`, `low`) and, when there is one, `urgencyReason`
42
+ ("Blocks a release (npm publish)", "High ticket PHNX-3890"). An ask that holds up a release,
43
+ deploy or merge is urgent; otherwise the linked ticket's Linear priority decides; otherwise
44
+ normal. A ticket's priority is read at most once per 30 minutes.
45
+ Source: `cli/src/lib/feed/attention.ts`, `cli/src/lib/feed/ticket-priority.ts`.
46
+ - **Banner schedules per urgency, with reminders.** New user-scope keys
47
+ `menubar.menu.notifyUrgent`, `notifyHigh`, `notifyNormal` and `notifyLow` set when an ask's
48
+ Mac banner posts: times such as `0m`, `15m`, `1h` measured from when the ask opened (the
49
+ first posts the banner, later ones remind), plus `stay` and `sound`, or just `sidebar` for no
50
+ banner. Defaults: urgent `["0m","15m","30m","stay","sound"]`, high `["0m","30m","stay"]`,
51
+ normal `["5m","1h"]`, low `["sidebar"]`. `agents config set` rejects anything else. The daemon
52
+ withdraws a banner when its ask resolves, and about 10 seconds after posting for a level
53
+ without `stay`. A reminder replaces the earlier banner and says "Still waiting · 15 min".
54
+ Source: `cli/src/lib/daemon/attention-notify-service.ts`, `cli/src/lib/feed/notify-schedule.ts`.
55
+ - **Fleet asks reach the machine you sit at.** With `interactive.host` set to this machine,
56
+ this machine posts banners for every device's asks, read from the daemon's shared fleet
57
+ stream; any other machine then posts none. Unset keeps each machine posting its own.
58
+ - **AGI Menu argv.** Banners now pass `--level`, `--sound` and `--reminder <n>`, and a resolved
59
+ ask is withdrawn with `"AGI Menu" --notify --withdraw <key>`. Needs AGI Menu
60
+ 1.19.0, which this release installs (the `menubar` floor moves to 1.19.0). Source: `cli/src/lib/menubar/notify-desktop.ts`, `cli/docs/menubar.md`.
61
+ - **Claude permission asks name their command.** A Claude permission ask reads "Claude needs
62
+ approval to run Bash: <command>" instead of "Claude needs your permission".
63
+ Source: `cli/src/lib/feed/feed.ts` (the next `agents feed` run rewrites the installed hook).
64
+ - **Stale asks leave.** The daemon runs the mailbox gc hourly, so an open ask whose session is
65
+ gone is removed a day later without `agents feed --dispatch`, and `agents feed` ranking caps an
66
+ ask's idle time at 24 hours so a weeks-old ask no longer tops the list.
67
+ Source: `cli/src/lib/daemon/attention-notify-service.ts`, `cli/src/lib/feed-ranking.ts`.
68
+
69
+ - **Session rows say what a session is still waiting on.** `agents feed watch --json`,
70
+ `agents ps watch --json` and `agents ps --json` rows carry `pending`
71
+ (`{subagents, shells, monitors}`, each `[{id, description, startedAtMs}]`): only work running
72
+ now, read from the transcript — subagents whose status is `running`, Claude background shells
73
+ (`run_in_background`, or a call the harness moved to the background) with no completion
74
+ notification and no successful `TaskStop`, and `Monitor` watches that have not ended or
75
+ expired. It is absent when nothing is pending. Everything counts only while the harness
76
+ process is alive and only when that process started it, so a resumed or forked session does
77
+ not inherit a dead run's shell. An `idle` row with `pending` is waiting on itself, not on you; `subAgentCount` is
78
+ still the cumulative total and says nothing about liveness.
79
+ Source: `cli/src/lib/session/pending-work.ts`, `cli/src/lib/session/session-cache.ts`.
80
+ - **Rows carry `effort` and `fast` when the transcript records them.** Claude rows take
81
+ `effort` from the latest reply's `effort` and `fast` from its `usage.speed`; Codex rows take
82
+ `effort` from the latest `turn_context`. Each is absent when the session does not say;
83
+ `effort` is one of `low`, `medium`, `high`, `xhigh`, `max`.
84
+ Source: `cli/src/lib/session/pending-work.ts`.
85
+ - **Project aliases.** A project definition may list `aliases:` — former names of the project.
86
+ A session that resolves to a former name, or a peer row that still reports one, is filed under
87
+ the current name (`confirmedProject`, the path-derived `project` key, the feed's project
88
+ bucket, `agents projects status`). Matching is case-insensitive. An alias that names another
89
+ live project, forms a cycle, or is claimed by two definitions is ignored with a warning.
90
+ Source: `cli/src/lib/projects.ts`, `cli/src/lib/feed/watch.ts`, `cli/src/lib/session/remote/watch.ts`.
91
+
92
+ - **`--since` accepts weeks and rejects values it cannot read.** `agents daemon logs --since 1week`
93
+ used to print nothing, because the parser had no week unit and an unreadable value silently
94
+ meant "now". `daemon logs` and `events` now share one parser that takes `1w`/`1week`/`2weeks`
95
+ and ISO dates, and an unparseable `--since` exits non-zero with `Invalid --since value`. A bare
96
+ number now means seconds, so `events --since 2024` is 2024 seconds ago, not 1 January 2024;
97
+ write the full ISO date (`2024-01-01`).
98
+ Source: `cli/src/lib/hooks/cache.ts`, `cli/src/commands/daemon.ts`, `cli/src/commands/events.ts`.
99
+ - **A signal-killed process no longer exits 0.** After a self-upgrade, `agents` re-runs your
100
+ command; if that child was killed by a signal, the CLI exited 0. It now exits 128+signal
101
+ (143 for SIGTERM), the same code the `browser` and `computer` forwarders report.
102
+ Source: `cli/src/lib/platform/process.ts`, `cli/src/bootstrap.ts`.
103
+ - **The watchdog log follows `AGENTS_LOGS_DIR`.** `watchdog.log` was always written to
104
+ `~/.agents/.cache/logs`, even when `AGENTS_LOGS_DIR` pointed elsewhere; `agents watchdog history`
105
+ now reads and reports the same logs directory every other log uses.
106
+ Source: `cli/src/lib/watchdog/log.ts`.
107
+ - **Smaller fixes.** `agents cloud` with an unrunnable `codex` binary now fails with
108
+ `could not run …` instead of an unhandled spawn error; two background auto-pull workers no
109
+ longer both take a fresh repo lock (the lock is created with `O_EXCL`); `agents teams` pickers color a PR-open teammate the
110
+ same magenta everywhere; `agents repo status` columns stay aligned with wide (CJK/emoji) names.
111
+ Source: `cli/src/lib/cloud/codex.ts`, `cli/src/lib/auto-pull.ts`, `cli/src/lib/teams/delivery.ts`,
112
+ `cli/src/commands/repo.ts`.
113
+
114
+ - **`agents lead`: a warm per-project Lead you can ask, with an NDJSON stream for UIs.** `agents lead ask --project <name> [--voice <secs>] [--json] -- <text>` sends one message to a long-lived headless Claude for that project and streams `turn`, `status`, `tool`, `text`, `confirm`, `done` (with `summary`, `refs` and `timing`) and `error` events. A detached host per project, started on demand, keeps the stream-json Claude process warm, resumes it with `--resume` after a crash, and rotates to a fresh session with `memory.md` past 60% context. The Lead runs with isolated settings (no user or project settings, hooks or MCP servers), in `~/.agents/lead/<project>/`, with a minimal environment, and can only call fixed-shape `agents lead tool` commands (`roster`, `dispatch`, `start`, `send`, `stop`, `linear`, `remember`); compound shell commands are denied. A stop it requests becomes a confirm token for `agents lead confirm <token>` that expires after 10 minutes. `agents lead history|status|stop` complete the group, and `lead.model` (default `sonnet`) picks the model. Source: `cli/src/commands/lead.ts`, `cli/src/lib/lead/`, `cli/docs/lead.md`.
115
+
116
+ - **Lead sessions no longer show up as ordinary sessions.** A project Lead (`agents lead`) runs a headless Claude session of its own, and `agents ps`, `agents ps watch --json` and `agents feed watch --json` listed it like any other agent, so AGI EXT and the FastWispr bubble rendered it as a session card. Live and history rows for a session whose cwd is under `~/.agents/lead`, or whose id is a Lead host's session, now carry `lead: true`, and those three surfaces leave them out by default; `--include-lead` shows them for debugging. The session index is unchanged, so `sessions` still finds a Lead's transcript. Source: `cli/src/lib/lead/visibility.ts`, `cli/src/lib/session/active.ts`, `cli/src/lib/session/remote/watch.ts`, `cli/src/commands/ps.ts`, `cli/src/commands/sessions-watch.ts`, `cli/src/commands/feed-watch.ts`.
117
+
3
118
  ## 1.23.21
4
119
 
5
120
  - **`agents projects prs` reads open PRs in one GraphQL query per repository or owner.**
package/README.md CHANGED
@@ -549,6 +549,23 @@ agents config set summarizer.model qwen2.5:3b
549
549
 
550
550
  Top-level questions and waiting notifications publish one atomic open-block record per session, including the mailbox id, host, runtime, and every answer option. The default view collapses agents under the **outcome** they serve (Linear ticket, PR, worktree slug, or Unassigned) so a 1,100-agent fleet reads as dozens of deliverables. Answered, resumed, and stopped blocks clear automatically; Task subagents are excluded. The rendered reply command uses the same mailbox id with `agents send --channel mailbox`, so the decision routes back to the agent that asked it.
551
551
 
552
+ ### Talk to a project Lead
553
+
554
+ ```bash
555
+ agents lead ask --project rush -- what is running? # starts the warm Lead on first use
556
+ agents lead ask --project rush --json -- put Claude on PHNX-4365
557
+ agents lead confirm c_0123456789abcdef # a stop the Lead held for you
558
+ agents lead history --project rush --json
559
+ agents lead status --json
560
+ agents lead stop --project rush
561
+ ```
562
+
563
+ The Lead is one long-lived headless Claude per project that dispatches and manages agents. It runs
564
+ with isolated settings and can only call fixed-shape `agents lead tool` commands (roster, dispatch,
565
+ start, send, stop, linear, remember). It cannot edit files, and a stop runs only through a confirm token. A per-project host keeps it warm across callers, so a
566
+ follow-up turn skips the harness boot. `--json` streams the NDJSON events the AGI EXT and bubble
567
+ clients render. Reference: [cli/docs/lead.md](cli/docs/lead.md).
568
+
552
569
  ### Auto-nudge stalls
553
570
 
554
571
  ```bash
package/dist/bootstrap.js CHANGED
@@ -25,6 +25,7 @@ import { COMMAND_LOADERS, LAZY_COMMAND_NAMES, KNOWN_TOP_LEVEL_COMMANDS, RETIRED_
25
25
  import { closestTopLevelCommand } from './lib/startup/spellcheck.js';
26
26
  import { applyGlobalHelpConventions, FRONT_DOOR_COMMAND_GROUPS, registerCommandGroups, setCompactRootHelp, } from './lib/help.js';
27
27
  import { renderWhatsNew } from './lib/whats-new.js';
28
+ import { childExitCode } from './lib/platform/index.js';
28
29
  import { getCliLaunch } from './lib/cli-entry.js';
29
30
  import { emit, emitFriction, redactArgs } from './lib/feed/events.js';
30
31
  import { stampProvenance } from './lib/event-provenance.js';
@@ -273,7 +274,7 @@ async function installResolvedPackage(metadata) {
273
274
  async function promptUpgrade(latestVersion, mayPrompt) {
274
275
  const { default: ora } = await import('ora');
275
276
  const { confirm, select } = await import('@inquirer/prompts');
276
- const { isInteractiveTerminal, isPromptCancelled } = await import('./commands/utils.js');
277
+ const { isInteractiveTerminal, isPromptCancelled } = await import('./lib/format.js');
277
278
  if (!mayPrompt || !isInteractiveTerminal()) {
278
279
  console.error(chalk.yellow(`Update available: ${VERSION} -> ${latestVersion}. Run: agents upgrade --yes`));
279
280
  return;
@@ -316,7 +317,7 @@ async function promptUpgrade(latestVersion, mayPrompt) {
316
317
  stdio: 'inherit',
317
318
  shell: false,
318
319
  });
319
- process.exit(result.status ?? 0);
320
+ process.exit(childExitCode(result.status, result.signal));
320
321
  }
321
322
  catch (err) {
322
323
  if (isPromptCancelled(err))
@@ -353,7 +354,7 @@ async function checkForUpdates(mayPrompt) {
353
354
  await promptUpgrade(cache.latestVersion, mayPrompt);
354
355
  }
355
356
  catch (err) {
356
- const { isPromptCancelled } = await import('./commands/utils.js');
357
+ const { isPromptCancelled } = await import('./lib/format.js');
357
358
  if (isPromptCancelled(err))
358
359
  return;
359
360
  }
@@ -480,7 +481,7 @@ function registerInternalCommand(p) {
480
481
  async function runUpgrade(version, options) {
481
482
  const { default: ora } = await import('ora');
482
483
  const { confirm } = await import('@inquirer/prompts');
483
- const { isInteractiveTerminal, isPromptCancelled } = await import('./commands/utils.js');
484
+ const { isInteractiveTerminal, isPromptCancelled } = await import('./lib/format.js');
484
485
  const target = version ?? 'latest';
485
486
  let spinner = ora(version ? `Resolving ${NPM_PACKAGE_NAME}@${target}...` : 'Checking for updates...').start();
486
487
  try {
@@ -46,6 +46,7 @@ export const loadTeams = async () => (await import('../commands/teams.js')).regi
46
46
  const loadCloud = async () => (await import('../commands/cloud.js')).registerCloudCommands;
47
47
  const loadPs = async () => (await import('../commands/ps.js')).registerPsCommand;
48
48
  const loadSend = async () => (await import('../commands/send.js')).registerSendCommand;
49
+ const loadLead = async () => (await import('../commands/lead.js')).registerLeadCommand;
49
50
  const loadFeed = async () => (await import('../commands/feed.js')).registerFeedCommand;
50
51
  const loadAccounts = async () => (await import('../commands/accounts.js')).registerAccountsCommand;
51
52
  const loadDaemon = async () => (await import('../commands/daemon.js')).registerDaemonCommand;
@@ -110,6 +111,7 @@ export const COMMAND_LOADERS = {
110
111
  ps: [loadPs],
111
112
  send: [loadSend],
112
113
  feed: [loadFeed],
114
+ lead: [loadLead],
113
115
  daemon: [loadDaemon],
114
116
  auth: [loadAuth],
115
117
  recordings: [loadRecordings],
@@ -51,6 +51,8 @@ function parseValue(key, parsed, raw) {
51
51
  return parsed.property === 'enabled' ? parseBool(raw, key) : raw.trim();
52
52
  case 'updates':
53
53
  return parseBool(raw, key);
54
+ case 'lead':
55
+ return raw.trim();
54
56
  case 'menubar': {
55
57
  const spec = configKeySpec(formatConfigKey(parsed));
56
58
  if (spec.type === 'bool')
@@ -152,6 +154,9 @@ function setConfig(parsed, value) {
152
154
  setConfigValue(formatConfigKey(parsed), value);
153
155
  return;
154
156
  }
157
+ case 'lead':
158
+ setConfigValue('lead.model', value);
159
+ return;
155
160
  case 'device': {
156
161
  const configName = devicePropertyToConfigName(parsed.property);
157
162
  if (parsed.property === 'notes') {
@@ -223,6 +228,11 @@ function unsetConfig(parsed) {
223
228
  unsetConfigValue(name);
224
229
  return had;
225
230
  }
231
+ case 'lead': {
232
+ const had = getConfigValue('lead.model').value !== undefined;
233
+ unsetConfigValue('lead.model');
234
+ return had;
235
+ }
226
236
  case 'device': {
227
237
  const configName = devicePropertyToConfigName(parsed.property);
228
238
  const had = getConfigValue(configName, { device: parsed.device }).value !== undefined;
@@ -258,6 +268,8 @@ function getConfig(parsed) {
258
268
  return parsed.agent ? rawAgentAutoUpdateSetting(parsed.agent) : rawGlobalAutoUpdateSetting();
259
269
  case 'menubar':
260
270
  return getConfigValue(formatConfigKey(parsed)).value;
271
+ case 'lead':
272
+ return getConfigValue('lead.model').value;
261
273
  case 'device': {
262
274
  const configName = devicePropertyToConfigName(parsed.property);
263
275
  return getConfigValue(configName, { device: parsed.device }).value;
@@ -332,6 +344,10 @@ function* listCentralConfigEntries() {
332
344
  yield { key, value, hint: configKeyStorageHint(parseConfigKey(key)) };
333
345
  }
334
346
  }
347
+ const leadModel = getConfigValue('lead.model').value;
348
+ if (leadModel !== undefined) {
349
+ yield { key: 'lead.model', value: leadModel, hint: configKeyStorageHint(parseConfigKey('lead.model')) };
350
+ }
335
351
  const globalAutoUpdate = rawGlobalAutoUpdateSetting();
336
352
  if (globalAutoUpdate !== undefined) {
337
353
  yield { key: 'updates.auto', value: globalAutoUpdate, hint: configKeyStorageHint(parseConfigKey('updates.auto')) };
@@ -12,7 +12,7 @@ import { LOG_LEVELS, levelRank, parseLogLevel } from '../lib/daemon/diagnostics.
12
12
  import { listJobs, getLatestRun } from '../lib/scheduling/routines.js';
13
13
  import { JobScheduler } from '../lib/scheduler.js';
14
14
  import { followFile } from '../lib/log-follow.js';
15
- import { parseDuration } from '../lib/hooks/cache.js';
15
+ import { parseSince } from '../lib/hooks/cache.js';
16
16
  import { registerDaemonIndexCommand } from './daemon-index.js';
17
17
  function startDaemonClean() {
18
18
  try {
@@ -416,7 +416,7 @@ function runLogLevel(level, opts) {
416
416
  }
417
417
  async function runLogs(opts) {
418
418
  assertLogLevelOption(opts.level);
419
- const sinceMs = opts.since ? Date.now() - (parseDuration(opts.since) ?? 0) * 1000 : undefined;
419
+ const sinceMs = opts.since ? parseSince(opts.since).getTime() : undefined;
420
420
  const lineCount = opts.lines ? parseInt(opts.lines, 10) : 50;
421
421
  if (opts.follow) {
422
422
  const logPath = getDaemonLogPath();
@@ -784,7 +784,7 @@ export function registerDaemonCommand(program) {
784
784
  .option('-n, --lines <number>', 'Show this many recent lines', '50')
785
785
  .option('-f, --follow', 'Stream new lines as they are written (like tail -f)')
786
786
  .option('--level <level>', 'Minimum level to show: debug | info | warn | error')
787
- .option('--since <dur>', 'Only lines newer than this (e.g. 1h, 30m)')
787
+ .option('--since <dur>', 'Only lines newer than this (e.g. 1h, 30m, 1w, or an ISO date)')
788
788
  .option('--json', 'Emit each line as JSON')
789
789
  .action(async (opts, command) => {
790
790
  const merged = command.optsWithGlobals();
@@ -36,29 +36,21 @@ import { listCliStatus, listCliStatusAsync } from '../lib/cli-resources.js';
36
36
  import { setHelpSections } from '../lib/help.js';
37
37
  import { getEffectiveExecutionPolicy } from '../lib/platform/winpath.js';
38
38
  import { auditWindowsSshEnrollment, diagnoseWindowsSshFailure } from '../lib/devices/windows-ssh-enrollment.js';
39
- import { scanUserRcFilesSync, masterPassphraseInEnvSync, isSecretsTransportError, } from '../lib/secrets-client.js';
39
+ import { scanUserRcFilesSync, masterPassphraseInEnvSync, isSecretsClientError, isSecretsTransportError, } from '../lib/secrets-client.js';
40
40
  import { terminalWidth, truncateToWidth, stringWidth, padToWidth } from '../lib/session/width.js';
41
41
  import { readRepoBehindMarkers } from '../lib/auto-pull.js';
42
42
  import { detectAgentsBinaryShadows } from '../lib/binary-shadow.js';
43
43
  import * as fs from 'fs';
44
44
  const AGENT_NAMES = Object.fromEntries(ALL_AGENT_IDS.map((id) => [id, AGENTS[id].name]));
45
- function scanUserRcFiles() {
45
+ function readSecretsSignals() {
46
46
  try {
47
- return scanUserRcFilesSync();
47
+ return { rcSecrets: scanUserRcFilesSync(), masterPassphraseInEnv: masterPassphraseInEnvSync() };
48
48
  }
49
49
  catch (error) {
50
+ if (isSecretsClientError(error, 'ENGINE_INCOMPATIBLE'))
51
+ return { secretsEngineIncompatible: true };
50
52
  if (isSecretsTransportError(error))
51
- return [];
52
- throw error;
53
- }
54
- }
55
- function masterPassphraseInEnv() {
56
- try {
57
- return masterPassphraseInEnvSync();
58
- }
59
- catch (error) {
60
- if (isSecretsTransportError(error))
61
- return false;
53
+ return {};
62
54
  throw error;
63
55
  }
64
56
  }
@@ -131,7 +123,7 @@ function printWrappedLine(prefix, text) {
131
123
  * file and line. Run `agents doctor` on that box for the specifics — the
132
124
  * message says so.
133
125
  */
134
- const REMOTE_FORWARDED_KINDS = ['rc-secret-export', 'env-secret-export', 'auth-bundle-wrong-backend', 'ssh-key-enrollment'];
126
+ const REMOTE_FORWARDED_KINDS = ['rc-secret-export', 'env-secret-export', 'auth-bundle-wrong-backend', 'secrets-engine-incompatible', 'ssh-key-enrollment'];
135
127
  const REMOTE_SECRET_MESSAGE = {
136
128
  'rc-secret-export': 'a credential-shaped export was found in this box\'s shell rc files'
137
129
  + ' — run `agents doctor` there for the file and line',
@@ -139,6 +131,7 @@ const REMOTE_SECRET_MESSAGE = {
139
131
  + ' — run `agents doctor` there for detail',
140
132
  'auth-bundle-wrong-backend': "reserved secrets bundle 'auth' exists but is not file-backed"
141
133
  + ' — run `agents doctor` there to recreate it',
134
+ 'secrets-engine-incompatible': 'this box\'s `secrets` engine predates the 0.4.0 contract, so every secrets read fails',
142
135
  'ssh-key-enrollment': 'Windows OpenSSH key enrollment is invalid'
143
136
  + ' — run `agents doctor` on this box for the effective path or ACL failure',
144
137
  };
@@ -376,8 +369,7 @@ async function runDevicesDoctor(opts) {
376
369
  cliMissing: localCliMissing,
377
370
  duplicateHooks: inspectDuplicateVersionHooks(cwd),
378
371
  hostClis: toHostCliInput(listCliStatus(cwd)),
379
- rcSecrets: scanUserRcFiles(),
380
- masterPassphraseInEnv: masterPassphraseInEnv(),
372
+ ...readSecretsSignals(),
381
373
  authBundleWrongBackend: !inspectReservedAuthBundle().ok,
382
374
  execPolicy: process.platform === 'win32'
383
375
  ? { platform: process.platform, policy: getEffectiveExecutionPolicy() }
@@ -1232,8 +1224,7 @@ export function registerDoctorCommand(program) {
1232
1224
  cliMissing,
1233
1225
  duplicateHooks,
1234
1226
  hostClis: toHostCliInput(hostClis),
1235
- rcSecrets: scanUserRcFiles(),
1236
- masterPassphraseInEnv: masterPassphraseInEnv(),
1227
+ ...readSecretsSignals(),
1237
1228
  authBundleWrongBackend: !inspectReservedAuthBundle().ok,
1238
1229
  execPolicy: process.platform === 'win32'
1239
1230
  ? { platform: process.platform, policy: getEffectiveExecutionPolicy() }
@@ -4,6 +4,7 @@ import { getLogsPath, stats, rotate } from '../lib/feed/events.js';
4
4
  import { readUnifiedEvents } from '../lib/event-stream.js';
5
5
  import { parseFamilyList, EVENT_FAMILIES } from '../lib/event-families.js';
6
6
  import { ingestBatch } from '../lib/events-ingest.js';
7
+ import { parseSince } from '../lib/hooks/cache.js';
7
8
  import { setHelpSections } from '../lib/help.js';
8
9
  import { registerAuditCommands } from './audit.js';
9
10
  import { registerEventsLogsCommand } from './events-logs.js';
@@ -20,20 +21,6 @@ export function capRecords(fetched, limit) {
20
21
  return { records: fetched, truncated: false };
21
22
  return { records: fetched.slice(0, limit), truncated: true };
22
23
  }
23
- function parseSince(s) {
24
- const m = s.match(/^(\d+)([smhdw])$/);
25
- if (m) {
26
- const n = parseInt(m[1], 10);
27
- const unitMs = {
28
- s: 1000, m: 60_000, h: 3_600_000, d: 86_400_000, w: 604_800_000,
29
- };
30
- return new Date(Date.now() - n * unitMs[m[2]]);
31
- }
32
- const ms = Date.parse(s);
33
- if (isNaN(ms))
34
- throw new Error(`Invalid --since value: ${s} (use e.g. 2h, 7d, or an ISO date)`);
35
- return new Date(ms);
36
- }
37
24
  function originLabel(r) {
38
25
  if (r.transport === 'ssh') {
39
26
  return chalk.yellow(`ssh${r.sshClientIp ? ' ' + r.sshClientIp : ''}`);
@@ -1,6 +1,7 @@
1
1
  import { setHelpSections } from '../lib/help.js';
2
2
  import { streamFeedFromHub, waitForHub } from '../lib/feed/hub-server.js';
3
3
  import { ensureDaemonStarted } from '../lib/daemon/daemon.js';
4
+ import { hideLeadInFeedEnvelope, leadSessionIds } from '../lib/lead/visibility.js';
4
5
  async function attachToHub(signal, emit, scope) {
5
6
  try {
6
7
  await streamFeedFromHub({ signal, emit, scope });
@@ -25,7 +26,8 @@ async function attachToHub(signal, emit, scope) {
25
26
  }
26
27
  export function registerFeedWatchCommand(parent) {
27
28
  const command = parent.command('watch').description('Stream the canonical agent, attention, tool, and activity projection as NDJSON')
28
- .option('--json', 'Emit versioned NDJSON envelopes').option('--local', 'Watch only this machine');
29
+ .option('--json', 'Emit versioned NDJSON envelopes').option('--local', 'Watch only this machine')
30
+ .option('--include-lead', 'Also stream project Lead sessions (agents lead), which are hidden by default');
29
31
  setHelpSections(command, {
30
32
  examples: `agents feed watch --json\nagents feed watch --json --local`,
31
33
  notes: 'Order by streamId + sequence. Unavailable scopes retain their last rows until reset on reconnect. '
@@ -46,7 +48,8 @@ export function registerFeedWatchCommand(parent) {
46
48
  writeFailure = error;
47
49
  controller.abort();
48
50
  };
49
- const emit = (event) => process.stdout.write(`${JSON.stringify(event)}\n`);
51
+ const leadIds = leadSessionIds();
52
+ const emit = (event) => process.stdout.write(`${JSON.stringify(opts.includeLead ? event : hideLeadInFeedEnvelope(event, leadIds))}\n`);
50
53
  process.once('SIGINT', stop);
51
54
  process.once('SIGTERM', stop);
52
55
  process.stdout.on('error', stopOnClosedConsumer);
@@ -2,14 +2,14 @@ import chalk from 'chalk';
2
2
  import path from 'path';
3
3
  import { execFile } from 'child_process';
4
4
  import { promisify } from 'util';
5
- import { getActiveSessions, findSessionFileForKind, listTerminalsActive, sessionProcessIsLocal, sessionProcessHost } from '../lib/session/active.js';
5
+ import { dedupeByMachineSession, getActiveSessions, findSessionFileForKind, listTerminalsActive, sessionProcessIsLocal, sessionProcessHost } from '../lib/session/active.js';
6
6
  import { isSessionIdShape } from '../lib/session/pid-registry.js';
7
7
  import { gatherRemoteActive } from '../lib/session/remote-active.js';
8
8
  import { discoverSessions } from '../lib/session/discover.js';
9
9
  import { deriveShortId } from '../lib/session/short-id.js';
10
10
  import { formatPickerLabel, pickerColumnsFor } from '../lib/session/presentation.js';
11
11
  import { mergeLocalFirst, filterSessionsByQuery, isUniqueEnoughSelector } from '../lib/session/selection.js';
12
- import { dedupeByMachineSession, matchesLiveStatus } from './ps-roster.js';
12
+ import { matchesLiveStatus } from './ps-roster.js';
13
13
  import { buildPreview, pickSessionInteractive } from './sessions-picker.js';
14
14
  import { multiItemPicker } from '../lib/picker.js';
15
15
  import { isPromptCancelled } from './utils.js';
@@ -0,0 +1,3 @@
1
+ import type { Command } from 'commander';
2
+ export declare function registerLeadToolCommands(lead: Command): void;
3
+ export declare function registerLeadCommand(program: Command): void;