@phnx-labs/agents-cli 1.22.116 → 1.22.118

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 (254) hide show
  1. package/CHANGELOG.md +247 -0
  2. package/dist/bootstrap.js +4 -11
  3. package/dist/commands/browser.d.ts +52 -70
  4. package/dist/commands/browser.js +192 -3562
  5. package/dist/commands/daemon.d.ts +39 -2
  6. package/dist/commands/daemon.js +72 -73
  7. package/dist/commands/events.js +1 -1
  8. package/dist/commands/exec.d.ts +18 -0
  9. package/dist/commands/exec.js +104 -12
  10. package/dist/commands/repo.js +13 -49
  11. package/dist/commands/route.js +5 -5
  12. package/dist/commands/routines.js +39 -12
  13. package/dist/commands/sessions-render.d.ts +1 -1
  14. package/dist/commands/sessions-render.js +0 -1
  15. package/dist/commands/sessions.test-fixture.d.ts +0 -1
  16. package/dist/commands/sessions.test-fixture.js +0 -37
  17. package/dist/commands/setup-browser.d.ts +17 -12
  18. package/dist/commands/setup-browser.js +52 -87
  19. package/dist/commands/setup-preferences.d.ts +0 -17
  20. package/dist/commands/setup-preferences.js +18 -49
  21. package/dist/commands/setup-term.d.ts +4 -3
  22. package/dist/commands/setup-term.js +5 -4
  23. package/dist/commands/setup.js +11 -11
  24. package/dist/commands/ssh.js +10 -1
  25. package/dist/commands/sync.js +6 -44
  26. package/dist/commands/teams.js +0 -1
  27. package/dist/commands/update.d.ts +19 -0
  28. package/dist/commands/update.js +34 -6
  29. package/dist/commands/view.d.ts +12 -1
  30. package/dist/commands/view.js +47 -2
  31. package/dist/index.js +107 -26
  32. package/dist/lib/account-capabilities.js +0 -2
  33. package/dist/lib/account-catalog.d.ts +38 -0
  34. package/dist/lib/account-catalog.js +110 -26
  35. package/dist/lib/account-provider-registry.js +1 -1
  36. package/dist/lib/account-registry.d.ts +1 -1
  37. package/dist/lib/account-registry.js +36 -2
  38. package/dist/lib/accounting/rotate.js +22 -8
  39. package/dist/lib/accounting/usage-ingest.d.ts +6 -1
  40. package/dist/lib/accounting/usage-ingest.js +115 -45
  41. package/dist/lib/accounting/usage-sync.d.ts +134 -31
  42. package/dist/lib/accounting/usage-sync.js +227 -66
  43. package/dist/lib/accounting/usage.d.ts +16 -3
  44. package/dist/lib/accounting/usage.js +26 -8
  45. package/dist/lib/accounts/slots.d.ts +8 -0
  46. package/dist/lib/accounts/slots.js +17 -0
  47. package/dist/lib/add-dir.js +0 -1
  48. package/dist/lib/agent-cli-commands.js +0 -1
  49. package/dist/lib/agent-spec/agents.d.ts +6 -7
  50. package/dist/lib/agent-spec/agents.js +6 -60
  51. package/dist/lib/auth-health.d.ts +69 -1
  52. package/dist/lib/auth-health.js +133 -4
  53. package/dist/lib/browser/context.d.ts +82 -0
  54. package/dist/lib/browser/context.js +88 -0
  55. package/dist/lib/browser/paths.d.ts +25 -0
  56. package/dist/lib/browser/paths.js +51 -0
  57. package/dist/lib/browser/record.d.ts +38 -0
  58. package/dist/lib/browser/record.js +57 -0
  59. package/dist/lib/browser/sessions-list.js +1 -2
  60. package/dist/lib/browser-client.d.ts +158 -0
  61. package/dist/lib/browser-client.js +234 -0
  62. package/dist/lib/channels/owner-sink.d.ts +1 -18
  63. package/dist/lib/channels/owner-sink.js +29 -82
  64. package/dist/lib/channels/providers/rush.d.ts +7 -7
  65. package/dist/lib/channels/providers/rush.js +127 -57
  66. package/dist/lib/claude-statusline.d.ts +1 -1
  67. package/dist/lib/claude-statusline.js +15 -3
  68. package/dist/lib/commands.js +1 -1
  69. package/dist/lib/crabbox/lease.js +1 -1
  70. package/dist/lib/crabbox/runtimes.js +1 -3
  71. package/dist/lib/daemon/account-state-daemon-service.js +1 -0
  72. package/dist/lib/daemon/auth-sync-service.d.ts +21 -18
  73. package/dist/lib/daemon/auth-sync-service.js +37 -43
  74. package/dist/lib/daemon/daemon.d.ts +25 -14
  75. package/dist/lib/daemon/daemon.js +92 -154
  76. package/dist/lib/daemon/runner.d.ts +2 -2
  77. package/dist/lib/daemon/runner.js +32 -9
  78. package/dist/lib/daemon/self-update-service.d.ts +35 -34
  79. package/dist/lib/daemon/self-update-service.js +40 -36
  80. package/dist/lib/daemon/service.d.ts +12 -8
  81. package/dist/lib/daemon/supervisor.d.ts +65 -54
  82. package/dist/lib/daemon/supervisor.js +136 -171
  83. package/dist/lib/daemon/testdata/process-view-start.js +5 -2
  84. package/dist/lib/daemon/usage-sync-service.d.ts +21 -30
  85. package/dist/lib/daemon/usage-sync-service.js +46 -78
  86. package/dist/lib/daemon-health.d.ts +22 -5
  87. package/dist/lib/daemon-health.js +47 -3
  88. package/dist/lib/daemon-services.d.ts +1 -1
  89. package/dist/lib/daemon-services.js +0 -10
  90. package/dist/lib/daemon-ticks.js +4 -2
  91. package/dist/lib/devices/doctor-findings.js +8 -11
  92. package/dist/lib/devices/harness-inventory.js +14 -5
  93. package/dist/lib/exec-account-home.js +5 -0
  94. package/dist/lib/exec.js +0 -11
  95. package/dist/lib/feed/events.js +0 -1
  96. package/dist/lib/feed/tool-activity.js +5 -2
  97. package/dist/lib/fleet-shared-state.d.ts +45 -0
  98. package/dist/lib/fleet-shared-state.js +78 -9
  99. package/dist/lib/fs-atomic.js +25 -0
  100. package/dist/lib/harness-auth-capabilities.js +0 -1
  101. package/dist/lib/helper-versions.js +1 -1
  102. package/dist/lib/hooks/cache.d.ts +7 -0
  103. package/dist/lib/hooks/cache.js +27 -2
  104. package/dist/lib/hooks/install.js +7 -1
  105. package/dist/lib/hosts/ready.d.ts +38 -8
  106. package/dist/lib/hosts/ready.js +62 -14
  107. package/dist/lib/hosts/remote-cmd.js +1 -0
  108. package/dist/lib/installations/active-check.d.ts +27 -0
  109. package/dist/lib/installations/active-check.js +61 -0
  110. package/dist/lib/installations/migrate.js +6 -3
  111. package/dist/lib/installations/shims.js +9 -7
  112. package/dist/lib/installations/update.js +21 -15
  113. package/dist/lib/installations/versions.js +12 -1
  114. package/dist/lib/manifest.js +1 -1
  115. package/dist/lib/models.js +0 -2
  116. package/dist/lib/open-url.js +28 -54
  117. package/dist/lib/placement.d.ts +2 -0
  118. package/dist/lib/placement.js +5 -0
  119. package/dist/lib/profiles.js +0 -2
  120. package/dist/lib/refresh.js +1 -1
  121. package/dist/lib/routine-readiness.d.ts +35 -0
  122. package/dist/lib/routine-readiness.js +74 -16
  123. package/dist/lib/rules/compile.js +6 -0
  124. package/dist/lib/sandbox.js +0 -2
  125. package/dist/lib/secrets-policy.d.ts +89 -11
  126. package/dist/lib/secrets-policy.js +175 -28
  127. package/dist/lib/session/db.d.ts +1 -1
  128. package/dist/lib/session/db.js +65 -18
  129. package/dist/lib/session/discover.js +1 -283
  130. package/dist/lib/session/mirror.d.ts +4 -3
  131. package/dist/lib/session/mirror.js +4 -3
  132. package/dist/lib/session/parse.d.ts +0 -2
  133. package/dist/lib/session/parse.js +1 -138
  134. package/dist/lib/session/throughput.d.ts +1 -3
  135. package/dist/lib/session/throughput.js +0 -20
  136. package/dist/lib/session/types.d.ts +2 -2
  137. package/dist/lib/session/types.js +2 -2
  138. package/dist/lib/sessions-client.d.ts +60 -1
  139. package/dist/lib/sessions-client.js +227 -4
  140. package/dist/lib/setup-tool-status.js +8 -12
  141. package/dist/lib/signin-badge.d.ts +3 -2
  142. package/dist/lib/signin-badge.js +6 -3
  143. package/dist/lib/smart-launch.js +4 -1
  144. package/dist/lib/staleness/detectors/commands.d.ts +1 -1
  145. package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
  146. package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
  147. package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
  148. package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
  149. package/dist/lib/staleness/detectors/rules.d.ts +1 -1
  150. package/dist/lib/staleness/detectors/skills.d.ts +1 -1
  151. package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
  152. package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
  153. package/dist/lib/staleness/writers/commands.d.ts +1 -1
  154. package/dist/lib/staleness/writers/hooks.d.ts +1 -1
  155. package/dist/lib/staleness/writers/mcp.d.ts +1 -1
  156. package/dist/lib/staleness/writers/permissions.d.ts +1 -1
  157. package/dist/lib/staleness/writers/plugins.d.ts +1 -1
  158. package/dist/lib/staleness/writers/rules.d.ts +1 -1
  159. package/dist/lib/staleness/writers/skills.d.ts +1 -1
  160. package/dist/lib/staleness/writers/sources.js +5 -0
  161. package/dist/lib/staleness/writers/subagents.d.ts +1 -1
  162. package/dist/lib/staleness/writers/workflows.d.ts +1 -1
  163. package/dist/lib/state.d.ts +6 -4
  164. package/dist/lib/state.js +7 -17
  165. package/dist/lib/teams/parsers.d.ts +1 -1
  166. package/dist/lib/teams/parsers.js +1 -136
  167. package/dist/lib/teams/placement-probe.js +50 -15
  168. package/dist/lib/teams/scheduler.d.ts +7 -0
  169. package/dist/lib/types.d.ts +10 -1
  170. package/dist/lib/types.js +1 -1
  171. package/dist/lib/view-types.d.ts +32 -0
  172. package/dist/lib/watchdog/read.js +0 -1
  173. package/dist/lib/watchdog/rotate.js +1 -2
  174. package/dist/lib/watchdog/runner.js +2 -2
  175. package/dist/lib/watchdog/watchdog.d.ts +1 -1
  176. package/dist/lib/watchdog/watchdogTail.js +0 -31
  177. package/package.json +1 -1
  178. package/scripts/postinstall.js +8 -8
  179. package/dist/browser.d.ts +0 -2
  180. package/dist/browser.js +0 -17
  181. package/dist/commands/browser-picker.d.ts +0 -18
  182. package/dist/commands/browser-picker.js +0 -97
  183. package/dist/lib/browser/arc-discovery.d.ts +0 -52
  184. package/dist/lib/browser/arc-discovery.js +0 -197
  185. package/dist/lib/browser/arc-dom.d.ts +0 -14
  186. package/dist/lib/browser/arc-dom.js +0 -121
  187. package/dist/lib/browser/caller-identity.d.ts +0 -40
  188. package/dist/lib/browser/caller-identity.js +0 -175
  189. package/dist/lib/browser/cdp.d.ts +0 -51
  190. package/dist/lib/browser/cdp.js +0 -254
  191. package/dist/lib/browser/chrome.d.ts +0 -141
  192. package/dist/lib/browser/chrome.js +0 -704
  193. package/dist/lib/browser/chromium-discovery.d.ts +0 -28
  194. package/dist/lib/browser/chromium-discovery.js +0 -96
  195. package/dist/lib/browser/devices.d.ts +0 -34
  196. package/dist/lib/browser/devices.js +0 -61
  197. package/dist/lib/browser/domain-skills.d.ts +0 -71
  198. package/dist/lib/browser/domain-skills.js +0 -195
  199. package/dist/lib/browser/drivers/arc.d.ts +0 -40
  200. package/dist/lib/browser/drivers/arc.js +0 -276
  201. package/dist/lib/browser/drivers/firefox.d.ts +0 -99
  202. package/dist/lib/browser/drivers/firefox.js +0 -377
  203. package/dist/lib/browser/drivers/local.d.ts +0 -55
  204. package/dist/lib/browser/drivers/local.js +0 -266
  205. package/dist/lib/browser/drivers/ssh.d.ts +0 -120
  206. package/dist/lib/browser/drivers/ssh.js +0 -467
  207. package/dist/lib/browser/editor.d.ts +0 -3
  208. package/dist/lib/browser/editor.js +0 -50
  209. package/dist/lib/browser/ffmpeg.d.ts +0 -12
  210. package/dist/lib/browser/ffmpeg.js +0 -184
  211. package/dist/lib/browser/firefox-discovery.d.ts +0 -69
  212. package/dist/lib/browser/firefox-discovery.js +0 -162
  213. package/dist/lib/browser/har.d.ts +0 -85
  214. package/dist/lib/browser/har.js +0 -77
  215. package/dist/lib/browser/hygiene.d.ts +0 -97
  216. package/dist/lib/browser/hygiene.js +0 -153
  217. package/dist/lib/browser/index.d.ts +0 -5
  218. package/dist/lib/browser/index.js +0 -5
  219. package/dist/lib/browser/input.d.ts +0 -7
  220. package/dist/lib/browser/input.js +0 -92
  221. package/dist/lib/browser/ipc.d.ts +0 -204
  222. package/dist/lib/browser/ipc.js +0 -1453
  223. package/dist/lib/browser/login-detection.d.ts +0 -87
  224. package/dist/lib/browser/login-detection.js +0 -274
  225. package/dist/lib/browser/profiles.d.ts +0 -422
  226. package/dist/lib/browser/profiles.js +0 -1157
  227. package/dist/lib/browser/refs.d.ts +0 -89
  228. package/dist/lib/browser/refs.js +0 -191
  229. package/dist/lib/browser/registry.d.ts +0 -70
  230. package/dist/lib/browser/registry.js +0 -252
  231. package/dist/lib/browser/remote-control.d.ts +0 -59
  232. package/dist/lib/browser/remote-control.js +0 -85
  233. package/dist/lib/browser/resolve-target.d.ts +0 -66
  234. package/dist/lib/browser/resolve-target.js +0 -264
  235. package/dist/lib/browser/runtime-state.d.ts +0 -291
  236. package/dist/lib/browser/runtime-state.js +0 -584
  237. package/dist/lib/browser/secret-ref.d.ts +0 -10
  238. package/dist/lib/browser/secret-ref.js +0 -14
  239. package/dist/lib/browser/service.d.ts +0 -812
  240. package/dist/lib/browser/service.js +0 -4693
  241. package/dist/lib/browser/stream.d.ts +0 -17
  242. package/dist/lib/browser/stream.js +0 -72
  243. package/dist/lib/browser/task-index.d.ts +0 -78
  244. package/dist/lib/browser/task-index.js +0 -199
  245. package/dist/lib/browser/types.d.ts +0 -647
  246. package/dist/lib/browser/types.js +0 -61
  247. package/dist/lib/browser/upload.d.ts +0 -29
  248. package/dist/lib/browser/upload.js +0 -298
  249. package/dist/lib/daemon/browser-ipc-service.d.ts +0 -20
  250. package/dist/lib/daemon/browser-ipc-service.js +0 -46
  251. package/dist/lib/daemon/browser-task-reap-service.d.ts +0 -14
  252. package/dist/lib/daemon/browser-task-reap-service.js +0 -26
  253. package/dist/lib/fleet-shared-repo-sync.d.ts +0 -55
  254. package/dist/lib/fleet-shared-repo-sync.js +0 -490
@@ -2,11 +2,12 @@
2
2
  * `agents daemon` — runtime, hosted services, and failure visibility for the
3
3
  * always-on daemon (RUSH-2354).
4
4
  *
5
- * The daemon holds the routines scheduler, the browser IPC server, and the
5
+ * The daemon holds the routines scheduler, the session/usage sync, and the
6
6
  * watchdog pass — but until this command group existed it had no user-facing
7
7
  * surface: no way to see it, restart it, or turn it off. The secrets broker
8
8
  * moved out of this daemon entirely with the standalone `secrets` engine
9
- * (PHNX-3989 OWN-1); `agents daemon status` only probes its reachability.
9
+ * (PHNX-3989 OWN-1), and the browser IPC server with the standalone `browser`
10
+ * CLI (PHNX-4101); `agents daemon status` only probes the broker's reachability.
10
11
  * `daemon.ts` (the runtime) has always implemented every mechanism this file
11
12
  * wires up; nothing here is new machinery, only the missing CLI surface.
12
13
  *
@@ -17,6 +18,42 @@
17
18
  * duplicating it.
18
19
  */
19
20
  import type { Command } from 'commander';
21
+ import { type SubsystemHealth } from '../lib/daemon-health.js';
20
22
  /** Elapsed wall-clock seconds since `pid` started, or null if unavailable (best-effort, POSIX only). */
21
23
  export declare function uptimeSeconds(pid: number): number | null;
24
+ interface SecretsBrokerHealth {
25
+ reachable: boolean;
26
+ /**
27
+ * True when this box routes `keychain`-backend items to the standalone's
28
+ * encrypted file store (a headless worker with no reachable keyring). The
29
+ * broker exists only to hold an UNLOCKED keychain across reads without a
30
+ * Touch ID prompt — a file-backed box reads every secret one-shot with no
31
+ * broker at all, so an absent broker there is normal, not a fault (PHNX-4116).
32
+ */
33
+ fileBacked: boolean;
34
+ /**
35
+ * Always `null` — the broker's socket now lives entirely inside the
36
+ * standalone `secrets` engine's own process (PHNX-3989 OWN-1); the daemon
37
+ * neither hosts it nor knows its transport details. Kept in the shape for
38
+ * `--json` compatibility.
39
+ */
40
+ socketPath: string | null;
41
+ heldBundles: number | null;
42
+ /**
43
+ * Always `null` — no daemon service writes a health record for the broker
44
+ * anymore (the daemon does not host or supervise it). Kept in the shape for
45
+ * `--json` compatibility.
46
+ */
47
+ record: SubsystemHealth | null;
48
+ }
49
+ /**
50
+ * The `secrets broker` health line. Reachable → healthy. Unreachable is a FAULT
51
+ * (`down`) only when the store is keychain-backed — there the broker is what
52
+ * holds the unlocked keychain across reads. On a file-backed box (every
53
+ * headless worker) no broker is needed: secrets read one-shot, so an absent
54
+ * broker is expected and reads as INFO, not `down` (PHNX-4116). Pure, so the
55
+ * three cases are unit-tested with no live daemon.
56
+ */
57
+ export declare function secretsBrokerHealthLine(secrets: SecretsBrokerHealth): string;
22
58
  export declare function registerDaemonCommand(program: Command): void;
59
+ export {};
@@ -2,11 +2,12 @@
2
2
  * `agents daemon` — runtime, hosted services, and failure visibility for the
3
3
  * always-on daemon (RUSH-2354).
4
4
  *
5
- * The daemon holds the routines scheduler, the browser IPC server, and the
5
+ * The daemon holds the routines scheduler, the session/usage sync, and the
6
6
  * watchdog pass — but until this command group existed it had no user-facing
7
7
  * surface: no way to see it, restart it, or turn it off. The secrets broker
8
8
  * moved out of this daemon entirely with the standalone `secrets` engine
9
- * (PHNX-3989 OWN-1); `agents daemon status` only probes its reachability.
9
+ * (PHNX-3989 OWN-1), and the browser IPC server with the standalone `browser`
10
+ * CLI (PHNX-4101); `agents daemon status` only probes the broker's reachability.
10
11
  * `daemon.ts` (the runtime) has always implemented every mechanism this file
11
12
  * wires up; nothing here is new machinery, only the missing CLI surface.
12
13
  *
@@ -21,10 +22,10 @@ import { execFileSync } from 'child_process';
21
22
  import * as fs from 'fs';
22
23
  import * as path from 'path';
23
24
  import { setHelpSections } from '../lib/help.js';
24
- import { getDaemonStatus, isDaemonRunning, isDaemonWedged, readDaemonLog, startDaemon, stopDaemon, signalDaemonReload, findSurvivingStateDirDaemons, getDaemonLogPath, isDaemonAutostartCircuitOpen, RedirectedHomeDaemonError, } from '../lib/daemon/daemon.js';
25
+ import { getDaemonStatus, isDaemonRunning, readDaemonLog, startDaemon, stopDaemon, signalDaemonReload, findSurvivingStateDirDaemons, getDaemonLogPath, isDaemonAutostartCircuitOpen, RedirectedHomeDaemonError, } from '../lib/daemon/daemon.js';
25
26
  import { listDaemonRunProcesses } from '../lib/daemon/leaked-daemons.js';
26
27
  import { getConfigValue, setConfigValue, isDaemonEnabled } from '../lib/device-config.js';
27
- import { readSubsystemHealth, readAllSubsystemHealth, SUBSYSTEM_BROWSER_IPC, SUBSYSTEM_DAEMON_START, } from '../lib/daemon-health.js';
28
+ import { readSubsystemHealth, readAllSubsystemHealth, SUBSYSTEM_DAEMON_START, } from '../lib/daemon-health.js';
28
29
  import { DAEMON_SERVICE_IDS, listDaemonServiceStates, setDaemonServiceEnabled, getDaemonServicesConfigPath, queueDaemonServiceRestart, } from '../lib/daemon-services.js';
29
30
  import { listJobs, getLatestRun } from '../lib/scheduling/routines.js';
30
31
  import { JobScheduler } from '../lib/scheduler.js';
@@ -293,25 +294,24 @@ function humanDuration(seconds) {
293
294
  }
294
295
  /** Reachability probe only — the daemon does not host, supervise, or take over the broker (OWN-1). */
295
296
  async function probeSecretsBroker() {
297
+ const { agentPing, agentStatus, keychainUsesFileFallback } = await import('../lib/secrets-client.js');
296
298
  try {
297
- const { agentPing, agentStatus } = await import('../lib/secrets-client.js');
298
299
  const ping = await agentPing();
299
- if (!ping.reachable)
300
- return { reachable: false, socketPath: null, heldBundles: null, record: null };
301
- const entries = await agentStatus();
302
- return { reachable: true, socketPath: null, heldBundles: entries.length, record: null };
300
+ if (ping.reachable) {
301
+ const entries = await agentStatus();
302
+ return { reachable: true, fileBacked: false, socketPath: null, heldBundles: entries.length, record: null };
303
+ }
303
304
  }
304
- catch {
305
- return { reachable: false, socketPath: null, heldBundles: null, record: null };
305
+ catch { /* fall through to the unreachable classification below */ }
306
+ // Unreachable: distinguish "broker needed and absent" (a keychain-backed box)
307
+ // from "no broker needed" (a file-backed worker reads secrets one-shot). An
308
+ // unknown store defaults to broker-needed, the louder verdict.
309
+ let fileBacked = false;
310
+ try {
311
+ fileBacked = await keychainUsesFileFallback();
306
312
  }
307
- }
308
- async function probeBrowserIPC() {
309
- const record = readSubsystemHealth(SUBSYSTEM_BROWSER_IPC);
310
- const { isBrowserServiceReachable, getSocketPath } = await import('../lib/browser/ipc.js');
311
- const { listAllProfileSnapshots } = await import('../lib/browser/runtime-state.js');
312
- const bound = await isBrowserServiceReachable();
313
- const sessionCount = listAllProfileSnapshots().filter((s) => s.pidAlive && s.daemonAlive).length;
314
- return { bound, socketPath: getSocketPath(), sessionCount, record };
313
+ catch { /* unknown → not file-backed */ }
314
+ return { reachable: false, fileBacked, socketPath: null, heldBundles: null, record: null };
315
315
  }
316
316
  function schedulerSummary() {
317
317
  const jobs = listJobs();
@@ -357,6 +357,23 @@ function healthLine(label, live, record) {
357
357
  : '';
358
358
  return ` ${chalk.red('down')} ${label} ${detail}`;
359
359
  }
360
+ /**
361
+ * The `secrets broker` health line. Reachable → healthy. Unreachable is a FAULT
362
+ * (`down`) only when the store is keychain-backed — there the broker is what
363
+ * holds the unlocked keychain across reads. On a file-backed box (every
364
+ * headless worker) no broker is needed: secrets read one-shot, so an absent
365
+ * broker is expected and reads as INFO, not `down` (PHNX-4116). Pure, so the
366
+ * three cases are unit-tested with no live daemon.
367
+ */
368
+ export function secretsBrokerHealthLine(secrets) {
369
+ if (secrets.reachable) {
370
+ return healthLine(`secrets broker (${secrets.socketPath}, ${secrets.heldBundles} bundle(s) held)`, true, secrets.record);
371
+ }
372
+ if (secrets.fileBacked) {
373
+ return ` ${chalk.cyan('info')} secrets agent not running (file-backed stores)`;
374
+ }
375
+ return healthLine('secrets broker (unreachable)', false, secrets.record);
376
+ }
360
377
  async function runStatus(opts) {
361
378
  const status = getDaemonStatus();
362
379
  const enabled = isDaemonEnabled();
@@ -378,7 +395,7 @@ async function runStatus(opts) {
378
395
  const staleTiers = staleDaemons(processes, pid ?? null, registeredPids);
379
396
  const stale = staleTiers.visible;
380
397
  const ownerEntryGone = owner ? entryIsGone(owner) : false;
381
- const [secrets, browserIpc] = await Promise.all([probeSecretsBroker(), probeBrowserIPC()]);
398
+ const secrets = await probeSecretsBroker();
382
399
  const scheduler = schedulerSummary();
383
400
  if (opts.json) {
384
401
  console.log(JSON.stringify({
@@ -386,6 +403,9 @@ async function runStatus(opts) {
386
403
  pid,
387
404
  uptimeSeconds: uptime,
388
405
  heartbeatAgeMs,
406
+ restarts24h: status.restarts24h,
407
+ lastRestartCause: status.lastRestartCause,
408
+ lastRestartAt: status.lastRestartAt,
389
409
  logPath: status.logPath,
390
410
  binaryPath: owner?.entry ?? status.binaryPath,
391
411
  binaryVersion: owner?.version ?? null,
@@ -409,12 +429,6 @@ async function runStatus(opts) {
409
429
  heldBundles: secrets.heldBundles,
410
430
  health: secrets.record,
411
431
  },
412
- browserIpc: {
413
- bound: browserIpc.bound,
414
- socketPath: browserIpc.socketPath,
415
- sessionCount: browserIpc.sessionCount,
416
- health: browserIpc.record,
417
- },
418
432
  },
419
433
  scheduler: {
420
434
  enabled: getConfigValue('scheduler.enabled').value !== false,
@@ -427,9 +441,8 @@ async function runStatus(opts) {
427
441
  return;
428
442
  }
429
443
  const stateLabel = state === 'running' ? chalk.green('running')
430
- : state === 'wedged' ? chalk.red('wedged')
431
- : state === 'disabled' ? chalk.yellow('disabled')
432
- : chalk.gray('stopped');
444
+ : state === 'disabled' ? chalk.yellow('disabled')
445
+ : chalk.gray('stopped');
433
446
  console.log(chalk.bold('Identity\n'));
434
447
  console.log(` State: ${stateLabel}`);
435
448
  if (pid)
@@ -438,6 +451,12 @@ async function runStatus(opts) {
438
451
  console.log(` Uptime: ${humanDuration(uptime)}`);
439
452
  if (heartbeatAgeMs !== null)
440
453
  console.log(` Heartbeat: ${Math.round(heartbeatAgeMs / 1000)}s ago`);
454
+ if (status.restarts24h > 0) {
455
+ const when = status.lastRestartAt ? ` (last ${new Date(status.lastRestartAt).toLocaleString()})` : '';
456
+ console.log(` Restarts: ${status.restarts24h} in the last 24h${when}`);
457
+ if (status.lastRestartCause)
458
+ console.log(` Last cause: ${chalk.gray(status.lastRestartCause)}`);
459
+ }
441
460
  const binaryLabel = owner?.entry ?? status.binaryPath ?? 'unknown';
442
461
  console.log(` Binary: ${ownerEntryGone ? chalk.red(`${binaryLabel} (MISSING from disk)`) : chalk.gray(binaryLabel)}`);
443
462
  console.log(` Version: ${chalk.gray(owner?.version ?? 'unknown')}`);
@@ -476,17 +495,13 @@ async function runStatus(opts) {
476
495
  console.log(chalk.gray('\n Only one install should own the daemon. Stop the stray(s): kill <pid>'));
477
496
  }
478
497
  console.log(chalk.bold('\nHealth\n'));
479
- console.log(healthLine(`secrets broker ${secrets.reachable ? `(${secrets.socketPath}, ${secrets.heldBundles} bundle(s) held)` : '(unreachable)'}`, secrets.reachable, secrets.record));
480
- console.log(healthLine(`browser IPC ${browserIpc.bound ? `(${browserIpc.socketPath}, ${browserIpc.sessionCount} session(s))` : '(unbound)'}`, browserIpc.bound, browserIpc.record));
498
+ console.log(secretsBrokerHealthLine(secrets));
481
499
  const schedulerEnabled = getConfigValue('scheduler.enabled').value !== false;
482
500
  console.log(` ${schedulerEnabled ? chalk.green('enabled') : chalk.yellow('disabled')} scheduler — ${scheduler.enabledCount}/${scheduler.routineCount} routine(s) enabled` +
483
501
  (scheduler.nextFire ? `, next ${scheduler.nextFire.toLocaleString()}` : ''));
484
502
  if (scheduler.failingCount > 0) {
485
503
  console.log(chalk.red(` ${scheduler.failingCount} routine(s) failing their last run — see: agents routines stats`));
486
504
  }
487
- if (state === 'wedged') {
488
- console.log(chalk.red('\nThe daemon is wedged (heartbeat stale). Restart: agents daemon restart'));
489
- }
490
505
  }
491
506
  /**
492
507
  * Combine the persisted enable/disable toggles with whatever health the
@@ -503,8 +518,8 @@ function buildServiceRows(daemonRunning) {
503
518
  // A persisted supervisor state (health.json) is only trustworthy while the
504
519
  // daemon is actually up. If it is not running (crash / kill -9 / never
505
520
  // started), every service is stopped no matter what the last-written record
506
- // says — trusting a stale 'running'/'parked'/'idle' here would print a
507
- // report that contradicts the live-probed socket rows below (RUSH-2368).
521
+ // says — trusting a stale 'running'/'idle' here would print a report that
522
+ // contradicts the live-probed socket rows below (RUSH-2368).
508
523
  const state = daemonRunning
509
524
  ? (h?.state ?? (s.enabled ? 'running (unsupervised)' : 'stopped'))
510
525
  : 'stopped';
@@ -524,8 +539,6 @@ function buildServiceRows(daemonRunning) {
524
539
  function serviceStateLabel(state) {
525
540
  if (state === 'running')
526
541
  return chalk.green('running');
527
- if (state === 'parked')
528
- return chalk.red('parked');
529
542
  if (state === 'stopped')
530
543
  return chalk.gray('stopped');
531
544
  if (state === 'idle')
@@ -533,13 +546,12 @@ function serviceStateLabel(state) {
533
546
  return chalk.yellow(state); // 'running (unsupervised)' or any future label
534
547
  }
535
548
  async function runServices(opts) {
536
- const [secrets, browserIpc] = await Promise.all([probeSecretsBroker(), probeBrowserIPC()]);
549
+ const secrets = await probeSecretsBroker();
537
550
  const rows = buildServiceRows(isDaemonRunning());
538
551
  if (opts.json) {
539
552
  console.log(JSON.stringify({
540
553
  // Existing fields — unchanged shape, agents/CI consume these directly.
541
554
  secretsBroker: { reachable: secrets.reachable, socketPath: secrets.socketPath, heldBundles: secrets.heldBundles, health: secrets.record },
542
- browserIpc: { bound: browserIpc.bound, socketPath: browserIpc.socketPath, sessionCount: browserIpc.sessionCount, health: browserIpc.record },
543
555
  // Additive: every registered service, supervised or legacy.
544
556
  services: rows,
545
557
  }, null, 2));
@@ -554,8 +566,7 @@ async function runServices(opts) {
554
566
  console.log(chalk.gray(` last-error: ${row.lastError}`));
555
567
  }
556
568
  console.log(chalk.bold('\nHosted sockets\n'));
557
- console.log(healthLine(`secrets broker ${secrets.reachable ? `(${secrets.socketPath}, ${secrets.heldBundles} bundle(s) held)` : '(unreachable)'}`, secrets.reachable, secrets.record));
558
- console.log(healthLine(`browser IPC ${browserIpc.bound ? `(${browserIpc.socketPath}, ${browserIpc.sessionCount} session(s))` : '(unbound)'}`, browserIpc.bound, browserIpc.record));
569
+ console.log(secretsBrokerHealthLine(secrets));
559
570
  console.log(chalk.gray('\nScheduled routines run through `agents routines` — see: agents routines stats'));
560
571
  console.log(chalk.gray('agents daemon services enable|disable|restart <id> apply live for supervised services.'));
561
572
  }
@@ -633,8 +644,6 @@ async function runDoctor(opts) {
633
644
  const problems = [];
634
645
  if (!status.running && enabled)
635
646
  problems.push('Daemon is not running. Start it: agents daemon start');
636
- if (status.running && isDaemonWedged())
637
- problems.push('Daemon is wedged (heartbeat stale). Restart: agents daemon restart');
638
647
  // RUSH-2418: an open auto-start circuit breaker is the FIRST thing to report
639
648
  // for a stopped daemon — otherwise the only advice is "agents daemon start",
640
649
  // which is the exact action the breaker just refused, with no hint that a
@@ -672,12 +681,6 @@ async function runDoctor(opts) {
672
681
  if (secrets.record && secrets.record.consecutiveFailures > 0) {
673
682
  problems.push(`Secrets broker has ${secrets.record.consecutiveFailures} consecutive failure(s): ${secrets.record.lastError}`);
674
683
  }
675
- const browserIpc = await probeBrowserIPC();
676
- if (!browserIpc.bound)
677
- problems.push('Browser IPC is unbound.');
678
- if (browserIpc.record && browserIpc.record.consecutiveFailures > 0) {
679
- problems.push(`Browser IPC has ${browserIpc.record.consecutiveFailures} consecutive failure(s): ${browserIpc.record.lastError}`);
680
- }
681
684
  const scheduler = schedulerSummary();
682
685
  if (scheduler.failingCount > 0) {
683
686
  problems.push(`${scheduler.failingCount} routine(s) failing their last run. See: agents routines stats`);
@@ -841,7 +844,7 @@ function runWebhooksList(json) {
841
844
  export function registerDaemonCommand(program) {
842
845
  const cmd = program
843
846
  .command('daemon')
844
- .description('The always-on daemon: browser IPC, watchdog, and the routines scheduler. Bare `agents daemon` shows status.')
847
+ .description('The always-on daemon: watchdog, session/usage sync, and the routines scheduler. Bare `agents daemon` shows status.')
845
848
  .option('--json', 'Emit as JSON')
846
849
  .action(async (opts, command) => {
847
850
  await runStatus({ json: command.optsWithGlobals().json === true });
@@ -870,12 +873,12 @@ export function registerDaemonCommand(program) {
870
873
  agents daemon services
871
874
 
872
875
  # Toggle or restart a service live — applies without a daemon restart
873
- # for supervisor-managed services (browser-ipc, account-state,
874
- # session-index, monitors' off-transition, watchdog, device-probe,
875
- # self-heal, state-dir-check)
876
- agents daemon services disable browser-ipc
877
- agents daemon services enable browser-ipc
878
- agents daemon services restart browser-ipc
876
+ # for supervisor-managed services (account-state, session-index,
877
+ # monitors' off-transition, watchdog, device-probe, self-heal,
878
+ # state-dir-check)
879
+ agents daemon services disable account-state
880
+ agents daemon services enable account-state
881
+ agents daemon services restart account-state
879
882
 
880
883
  # Host a signed webhook receiver here, supervised and restarted on crash
881
884
  agents daemon webhooks add --secrets-bundle linear-webhook
@@ -912,12 +915,10 @@ export function registerDaemonCommand(program) {
912
915
 
913
916
  'agents daemon services enable|disable|restart <id>' applies live (no
914
917
  daemon restart) for supervisor-managed services that were registered at
915
- boot. browser-ipc is also registered while disabled, specifically so a
916
- browser client can enable it live. The inline scheduler re-evaluates its
917
- toggle on every reload as well. A boot-disabled service other than
918
- browser-ipc, the monitor on-transition, and webhook-receiver still need an
919
- operator 'agents daemon restart'. 'agents daemon services' names which
920
- case you're in per row.
918
+ boot. The inline scheduler re-evaluates its toggle on every reload as
919
+ well. A boot-disabled service other than the monitor on-transition and
920
+ webhook-receiver still needs an operator 'agents daemon restart'. 'agents
921
+ daemon services' names which case you're in per row.
921
922
  `,
922
923
  });
923
924
  cmd.command('status')
@@ -1033,16 +1034,15 @@ export function registerDaemonCommand(program) {
1033
1034
  agents daemon services list
1034
1035
 
1035
1036
  # Toggle or restart live — no daemon restart for a supervisor-managed
1036
- # service (browser-ipc, account-state, session-index)
1037
- agents daemon services disable browser-ipc
1038
- agents daemon services enable browser-ipc
1039
- agents daemon services restart browser-ipc
1037
+ # service (account-state, session-index)
1038
+ agents daemon services disable account-state
1039
+ agents daemon services enable account-state
1040
+ agents daemon services restart account-state
1040
1041
  `,
1041
1042
  notes: `
1042
1043
  A service disabled at daemon boot is normally not registered on the
1043
- supervisor, so enabling it needs an operator restart. browser-ipc is the
1044
- exception: it is registered stopped and can be enabled live. The inline
1045
- scheduler also applies enable/disable on reload; webhook-receiver and the
1044
+ supervisor, so enabling it needs an operator restart. The inline
1045
+ scheduler applies enable/disable on reload; webhook-receiver and the
1046
1046
  monitor on-transition still require 'agents daemon restart'. Each row in
1047
1047
  the plain-text view names which case it is; 'supervised: true/false' does
1048
1048
  the same in --json.
@@ -1077,9 +1077,8 @@ export function registerDaemonCommand(program) {
1077
1077
  * Apply an enable/disable toggle live (RUSH-3193 P4): persist it, then signal
1078
1078
  * the running daemon to reload — its handler diffs the toggle and drives
1079
1079
  * `supervisor.start/stop(id)` for a supervised service, so no restart is
1080
- * needed for supervisor-managed services registered at boot. browser-ipc is
1081
- * registered even when disabled so it can be enabled live; the inline
1082
- * scheduler also re-evaluates its toggle on reload. webhook-receiver,
1080
+ * needed for supervisor-managed services registered at boot. The inline
1081
+ * scheduler re-evaluates its toggle on reload. webhook-receiver,
1083
1082
  * monitors' on-transition, and other boot-disabled services still need a
1084
1083
  * deliberate operator restart — the daemon's own reload log says so.
1085
1084
  */
@@ -203,7 +203,7 @@ export function addEventsReadOptions(command) {
203
203
  .option('--command <path>', 'Only this command path — prefix match (e.g. "teams create")')
204
204
  .option('--event <type>', 'Only this typed event (repeatable, e.g. secrets.get, run.dispatched, pr.opened)', collect, [])
205
205
  .option('--agent <name>', 'Only events tagged with this agent')
206
- .option('--caller <kind>', 'Only this caller kind (claude-code, codex, gemini, cursor, terminal, script)')
206
+ .option('--caller <kind>', 'Only this caller kind (claude-code, codex, cursor, terminal, script)')
207
207
  .option('--level <level>', 'Only this level: audit, warn, info, debug')
208
208
  .option('--session <id>', 'Only events from this session (the provenance sessionId) — e.g. trace which session read a secret')
209
209
  .option('--bundle <name>', 'Only events carrying this bundle in their payload — e.g. `--module secrets --bundle share` for every read of the share bundle')
@@ -62,6 +62,7 @@ interface ExecCommandActionOptions {
62
62
  until?: string;
63
63
  interval?: string;
64
64
  where?: string;
65
+ local?: boolean;
65
66
  host?: string;
66
67
  device?: string;
67
68
  on?: string;
@@ -130,6 +131,20 @@ export declare function hostTargetGiven(options: {
130
131
  on?: string;
131
132
  computer?: string;
132
133
  }): string[];
134
+ /**
135
+ * Turn a host target that names THIS machine into an explicit local pin: the
136
+ * host-family flags are cleared and `local` is set, so no dispatch path
137
+ * self-SSHes and the bare-interactive default (`bareInteractiveRunDefaultsToDeviceAuto`)
138
+ * sees a decided placement. Returns true when the pin was applied. Pure over
139
+ * the `isSelf` predicate so the rule is testable without a device registry.
140
+ */
141
+ export declare function pinLocalWhenTargetIsSelf(options: {
142
+ host?: string;
143
+ device?: string;
144
+ on?: string;
145
+ computer?: string;
146
+ local?: boolean;
147
+ }, isSelf: (name: string) => boolean): boolean;
133
148
  /**
134
149
  * Return every option whose selection semantics conflict with an account
135
150
  * choice (`agent#`). Device routing is deliberately absent: the marker rides
@@ -159,6 +174,7 @@ export declare function runDevicePickerConflicts(options: {
159
174
  device?: string;
160
175
  on?: string;
161
176
  computer?: string;
177
+ local?: boolean;
162
178
  }): string[];
163
179
  export { RUN_AUTO_KEYWORD };
164
180
  /**
@@ -179,6 +195,7 @@ export declare function runAutoDefaultsToAffinity(options: {
179
195
  device?: string;
180
196
  on?: string;
181
197
  computer?: string;
198
+ local?: boolean;
182
199
  }, env?: NodeJS.ProcessEnv): boolean;
183
200
  /**
184
201
  * Whether a bare human-facing `agents run <harness>` — no prompt, so an
@@ -210,6 +227,7 @@ export declare function bareInteractiveRunDefaultsToDeviceAuto(options: {
210
227
  lease?: string | boolean;
211
228
  box?: string;
212
229
  cloud?: boolean;
230
+ local?: boolean;
213
231
  }, run: {
214
232
  prompt?: string;
215
233
  devicePickerRequested?: boolean;