@phnx-labs/agents-cli 1.22.83 → 1.22.85

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 (291) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/README.md +80 -53
  3. package/dist/bootstrap.d.ts +7 -6
  4. package/dist/bootstrap.js +20 -27
  5. package/dist/cli/command-registry.js +5 -1
  6. package/dist/commands/accounts.d.ts +6 -13
  7. package/dist/commands/accounts.js +330 -143
  8. package/dist/commands/apply.js +1 -1
  9. package/dist/commands/auth-mint.d.ts +7 -3
  10. package/dist/commands/auth-mint.js +21 -9
  11. package/dist/commands/auth.js +2 -3
  12. package/dist/commands/browser.js +10 -10
  13. package/dist/commands/daemon.d.ts +7 -3
  14. package/dist/commands/daemon.js +40 -25
  15. package/dist/commands/doctor.js +28 -2
  16. package/dist/commands/exec.js +87 -39
  17. package/dist/commands/fleet-capture.js +21 -2
  18. package/dist/commands/harness-wizard.js +2 -2
  19. package/dist/commands/lease.js +7 -12
  20. package/dist/commands/profiles.d.ts +2 -2
  21. package/dist/commands/profiles.js +20 -13
  22. package/dist/commands/repo.js +3 -3
  23. package/dist/commands/run-account-picker.d.ts +3 -3
  24. package/dist/commands/run-account-picker.js +29 -30
  25. package/dist/commands/secrets-passthrough.d.ts +20 -0
  26. package/dist/commands/secrets-passthrough.js +43 -0
  27. package/dist/commands/sessions-trace.d.ts +11 -0
  28. package/dist/commands/sessions-trace.js +71 -0
  29. package/dist/commands/setup-accounts.d.ts +3 -2
  30. package/dist/commands/setup-accounts.js +4 -4
  31. package/dist/commands/setup-secrets.d.ts +16 -21
  32. package/dist/commands/setup-secrets.js +43 -224
  33. package/dist/commands/ssh.js +2 -2
  34. package/dist/commands/sync.js +1 -1
  35. package/dist/commands/update.d.ts +10 -0
  36. package/dist/commands/update.js +43 -40
  37. package/dist/commands/versions.d.ts +11 -11
  38. package/dist/commands/versions.js +131 -83
  39. package/dist/commands/view.d.ts +1 -9
  40. package/dist/commands/view.js +41 -55
  41. package/dist/commands/webhook.js +5 -5
  42. package/dist/commands/workflows.js +2 -1
  43. package/dist/index.d.ts +12 -12
  44. package/dist/index.js +13 -42
  45. package/dist/lib/account-capabilities.d.ts +1 -1
  46. package/dist/lib/account-capabilities.js +1 -1
  47. package/dist/lib/account-catalog.d.ts +121 -6
  48. package/dist/lib/account-catalog.js +421 -7
  49. package/dist/lib/account-registry.d.ts +8 -30
  50. package/dist/lib/account-registry.js +36 -79
  51. package/dist/lib/account-schema.d.ts +1 -1
  52. package/dist/lib/account-schema.js +1 -1
  53. package/dist/lib/accounting/account-pool-collect.js +16 -4
  54. package/dist/lib/accounting/rotate.d.ts +20 -7
  55. package/dist/lib/accounting/rotate.js +89 -13
  56. package/dist/lib/accounting/usage.js +11 -16
  57. package/dist/lib/accounts/add.d.ts +138 -0
  58. package/dist/lib/accounts/add.js +651 -0
  59. package/dist/lib/accounts/migrate.d.ts +117 -0
  60. package/dist/lib/accounts/migrate.js +536 -0
  61. package/dist/lib/accounts/slots.d.ts +13 -0
  62. package/dist/lib/accounts/slots.js +100 -0
  63. package/dist/lib/agent-spec/agents.d.ts +16 -0
  64. package/dist/lib/agent-spec/agents.js +32 -4
  65. package/dist/lib/app-bundle-install.js +5 -4
  66. package/dist/lib/auth-health.d.ts +3 -0
  67. package/dist/lib/auth-health.js +11 -0
  68. package/dist/lib/auth-mint.d.ts +52 -16
  69. package/dist/lib/auth-mint.js +117 -39
  70. package/dist/lib/browser/chrome.d.ts +1 -1
  71. package/dist/lib/browser/chrome.js +5 -5
  72. package/dist/lib/byok-usage.js +3 -3
  73. package/dist/lib/claude-account-token.d.ts +47 -3
  74. package/dist/lib/claude-account-token.js +172 -50
  75. package/dist/lib/cloud/antigravity.js +4 -4
  76. package/dist/lib/cloud/cursor.js +4 -4
  77. package/dist/lib/crabbox/cli.d.ts +1 -1
  78. package/dist/lib/crabbox/cli.js +6 -6
  79. package/dist/lib/crabbox/runtimes.d.ts +3 -3
  80. package/dist/lib/crabbox/runtimes.js +5 -5
  81. package/dist/lib/daemon/account-state-daemon-service.d.ts +37 -1
  82. package/dist/lib/daemon/account-state-daemon-service.js +199 -3
  83. package/dist/lib/daemon/auth-sync-service.js +28 -1
  84. package/dist/lib/daemon/daemon.d.ts +6 -16
  85. package/dist/lib/daemon/daemon.js +52 -97
  86. package/dist/lib/daemon/daemon.test-fixture.d.ts +7 -9
  87. package/dist/lib/daemon/daemon.test-fixture.js +22 -40
  88. package/dist/lib/daemon/harness-update-service.d.ts +1 -1
  89. package/dist/lib/daemon/harness-update-service.js +1 -1
  90. package/dist/lib/daemon/runner.d.ts +15 -3
  91. package/dist/lib/daemon/runner.js +49 -24
  92. package/dist/lib/daemon-health.d.ts +1 -2
  93. package/dist/lib/daemon-health.js +7 -6
  94. package/dist/lib/daemon-services.d.ts +1 -1
  95. package/dist/lib/daemon-services.js +1 -11
  96. package/dist/lib/daemon-ticks.js +23 -2
  97. package/dist/lib/daemon-webhooks.d.ts +8 -7
  98. package/dist/lib/daemon-webhooks.js +10 -9
  99. package/dist/lib/device-config.js +1 -1
  100. package/dist/lib/devices/doctor-findings.d.ts +1 -1
  101. package/dist/lib/devices/harness-inventory.d.ts +39 -0
  102. package/dist/lib/devices/harness-inventory.js +126 -4
  103. package/dist/lib/doctor-diff.js +2 -1
  104. package/dist/lib/exec-account-home.d.ts +38 -0
  105. package/dist/lib/exec-account-home.js +164 -0
  106. package/dist/lib/exec.d.ts +30 -0
  107. package/dist/lib/exec.js +101 -31
  108. package/dist/lib/feed/activity-stream.d.ts +60 -0
  109. package/dist/lib/feed/activity-stream.js +271 -0
  110. package/dist/lib/feed/activity.d.ts +7 -0
  111. package/dist/lib/feed/activity.js +10 -4
  112. package/dist/lib/feed/watch.d.ts +9 -3
  113. package/dist/lib/feed/watch.js +72 -36
  114. package/dist/lib/fleet/apply.d.ts +2 -2
  115. package/dist/lib/fleet/apply.js +4 -4
  116. package/dist/lib/fleet/auth-sync.js +4 -3
  117. package/dist/lib/fleet-shared-repo-sync.js +6 -9
  118. package/dist/lib/fleet-shared-state.d.ts +6 -0
  119. package/dist/lib/harness/adapter.d.ts +7 -7
  120. package/dist/lib/harness/adapter.js +10 -6
  121. package/dist/lib/harness/adapters/grok.js +8 -3
  122. package/dist/lib/harness/adapters/muse.js +1 -1
  123. package/dist/lib/harness/adapters/opencode.js +12 -3
  124. package/dist/lib/harness-auth-capabilities.d.ts +61 -0
  125. package/dist/lib/harness-auth-capabilities.js +52 -0
  126. package/dist/lib/helper-versions.d.ts +6 -4
  127. package/dist/lib/helper-versions.js +5 -4
  128. package/dist/lib/hosts/credential-transport.d.ts +10 -0
  129. package/dist/lib/hosts/credential-transport.js +37 -0
  130. package/dist/lib/hosts/dispatch.d.ts +7 -0
  131. package/dist/lib/hosts/dispatch.js +13 -6
  132. package/dist/lib/identity/client.d.ts +3 -3
  133. package/dist/lib/identity/client.js +3 -3
  134. package/dist/lib/installations/index.d.ts +1 -1
  135. package/dist/lib/installations/index.js +1 -1
  136. package/dist/lib/installations/migrate.js +9 -0
  137. package/dist/lib/installations/resolve.js +1 -1
  138. package/dist/lib/installations/shims.d.ts +15 -0
  139. package/dist/lib/installations/shims.js +69 -0
  140. package/dist/lib/installations/store.d.ts +43 -0
  141. package/dist/lib/installations/store.js +75 -7
  142. package/dist/lib/installations/versions.js +1 -1
  143. package/dist/lib/menubar/install-menubar.d.ts +3 -3
  144. package/dist/lib/menubar/install-menubar.js +3 -3
  145. package/dist/lib/native-accounts.d.ts +35 -0
  146. package/dist/lib/native-accounts.js +41 -0
  147. package/dist/lib/net-close.d.ts +11 -0
  148. package/dist/lib/net-close.js +25 -0
  149. package/dist/lib/openclaw-keychain.js +27 -1
  150. package/dist/lib/profiles.js +22 -9
  151. package/dist/lib/project-resources.js +1 -1
  152. package/dist/lib/reserved-stores.d.ts +53 -0
  153. package/dist/lib/reserved-stores.js +120 -0
  154. package/dist/lib/secrets-client.d.ts +191 -0
  155. package/dist/lib/secrets-client.js +710 -0
  156. package/dist/lib/secrets-policy.d.ts +222 -0
  157. package/dist/lib/secrets-policy.js +483 -0
  158. package/dist/lib/secrets-types.d.ts +188 -0
  159. package/dist/lib/secrets-types.js +24 -0
  160. package/dist/lib/service-manifest.js +3 -4
  161. package/dist/lib/session/active.d.ts +38 -4
  162. package/dist/lib/session/active.js +36 -4
  163. package/dist/lib/session/bash-command.js +10 -0
  164. package/dist/lib/session/db.d.ts +65 -2
  165. package/dist/lib/session/db.js +178 -18
  166. package/dist/lib/session/mirror.d.ts +5 -0
  167. package/dist/lib/session/mirror.js +166 -0
  168. package/dist/lib/session/parse.d.ts +49 -0
  169. package/dist/lib/session/parse.js +324 -30
  170. package/dist/lib/session/prompt.d.ts +93 -2
  171. package/dist/lib/session/prompt.js +266 -15
  172. package/dist/lib/session/remote/peer-stream.d.ts +47 -0
  173. package/dist/lib/session/remote/peer-stream.js +142 -0
  174. package/dist/lib/session/remote/watch.d.ts +1 -1
  175. package/dist/lib/session/remote/watch.js +41 -42
  176. package/dist/lib/session/session-cache.d.ts +9 -0
  177. package/dist/lib/session/session-cache.js +40 -2
  178. package/dist/lib/session/sync/config.js +2 -2
  179. package/dist/lib/session/timeline-pass.d.ts +129 -0
  180. package/dist/lib/session/timeline-pass.js +323 -0
  181. package/dist/lib/session/timeline.d.ts +182 -0
  182. package/dist/lib/session/timeline.js +636 -0
  183. package/dist/lib/session/types.d.ts +155 -1
  184. package/dist/lib/sha256-asset.d.ts +11 -16
  185. package/dist/lib/sha256-asset.js +11 -16
  186. package/dist/lib/share/config.js +14 -5
  187. package/dist/lib/signin-badge.d.ts +26 -0
  188. package/dist/lib/signin-badge.js +42 -0
  189. package/dist/lib/staleness/detectors/workflows.js +3 -105
  190. package/dist/lib/staleness/writers/workflows.js +2 -1
  191. package/dist/lib/state.d.ts +7 -4
  192. package/dist/lib/state.js +18 -7
  193. package/dist/lib/summarizer/pass.d.ts +2 -0
  194. package/dist/lib/summarizer/pass.js +14 -1
  195. package/dist/lib/summarizer/summarize.d.ts +7 -0
  196. package/dist/lib/summarizer/summarize.js +3 -0
  197. package/dist/lib/sync-umbrella.js +2 -2
  198. package/dist/lib/teams/agents.js +1 -1
  199. package/dist/lib/types.d.ts +74 -33
  200. package/dist/lib/view-types.d.ts +6 -3
  201. package/dist/lib/workflows-registry.d.ts +71 -0
  202. package/dist/lib/workflows-registry.js +280 -0
  203. package/dist/lib/workflows.d.ts +21 -21
  204. package/dist/lib/workflows.js +12 -327
  205. package/package.json +2 -3
  206. package/scripts/postinstall.js +4 -29
  207. package/dist/commands/secrets-import.d.ts +0 -18
  208. package/dist/commands/secrets-import.js +0 -74
  209. package/dist/commands/secrets-migrate.d.ts +0 -25
  210. package/dist/commands/secrets-migrate.js +0 -334
  211. package/dist/commands/secrets-rotate-passphrase.d.ts +0 -17
  212. package/dist/commands/secrets-rotate-passphrase.js +0 -96
  213. package/dist/commands/secrets-sync.d.ts +0 -11
  214. package/dist/commands/secrets-sync.js +0 -153
  215. package/dist/commands/secrets-vault.d.ts +0 -10
  216. package/dist/commands/secrets-vault.js +0 -130
  217. package/dist/commands/secrets.d.ts +0 -212
  218. package/dist/commands/secrets.js +0 -3030
  219. package/dist/lib/accounts/connect.d.ts +0 -170
  220. package/dist/lib/accounts/connect.js +0 -383
  221. package/dist/lib/daemon/keychain-reap-service.d.ts +0 -17
  222. package/dist/lib/daemon/keychain-reap-service.js +0 -32
  223. package/dist/lib/daemon/secrets-broker-service.d.ts +0 -21
  224. package/dist/lib/daemon/secrets-broker-service.js +0 -51
  225. package/dist/lib/secrets/agent.d.ts +0 -358
  226. package/dist/lib/secrets/agent.js +0 -1291
  227. package/dist/lib/secrets/audit.d.ts +0 -46
  228. package/dist/lib/secrets/audit.js +0 -101
  229. package/dist/lib/secrets/bundles.d.ts +0 -290
  230. package/dist/lib/secrets/bundles.js +0 -1547
  231. package/dist/lib/secrets/download-keychain.d.ts +0 -47
  232. package/dist/lib/secrets/download-keychain.js +0 -70
  233. package/dist/lib/secrets/drivers/rush.d.ts +0 -14
  234. package/dist/lib/secrets/drivers/rush.js +0 -90
  235. package/dist/lib/secrets/fallback.d.ts +0 -48
  236. package/dist/lib/secrets/fallback.js +0 -48
  237. package/dist/lib/secrets/filestore.d.ts +0 -222
  238. package/dist/lib/secrets/filestore.js +0 -1099
  239. package/dist/lib/secrets/headless.d.ts +0 -43
  240. package/dist/lib/secrets/headless.js +0 -56
  241. package/dist/lib/secrets/icloud-import.d.ts +0 -79
  242. package/dist/lib/secrets/icloud-import.js +0 -206
  243. package/dist/lib/secrets/index.d.ts +0 -451
  244. package/dist/lib/secrets/index.js +0 -1568
  245. package/dist/lib/secrets/install-helper.d.ts +0 -72
  246. package/dist/lib/secrets/install-helper.js +0 -245
  247. package/dist/lib/secrets/lease.d.ts +0 -25
  248. package/dist/lib/secrets/lease.js +0 -44
  249. package/dist/lib/secrets/linux.d.ts +0 -77
  250. package/dist/lib/secrets/linux.js +0 -393
  251. package/dist/lib/secrets/list-filter.d.ts +0 -109
  252. package/dist/lib/secrets/list-filter.js +0 -261
  253. package/dist/lib/secrets/mcp.d.ts +0 -93
  254. package/dist/lib/secrets/mcp.js +0 -211
  255. package/dist/lib/secrets/profiles.d.ts +0 -10
  256. package/dist/lib/secrets/profiles.js +0 -13
  257. package/dist/lib/secrets/push.d.ts +0 -133
  258. package/dist/lib/secrets/push.js +0 -273
  259. package/dist/lib/secrets/rc-hygiene.d.ts +0 -63
  260. package/dist/lib/secrets/rc-hygiene.js +0 -143
  261. package/dist/lib/secrets/read-backoff.d.ts +0 -27
  262. package/dist/lib/secrets/read-backoff.js +0 -64
  263. package/dist/lib/secrets/reaper.d.ts +0 -90
  264. package/dist/lib/secrets/reaper.js +0 -243
  265. package/dist/lib/secrets/remote.d.ts +0 -152
  266. package/dist/lib/secrets/remote.js +0 -344
  267. package/dist/lib/secrets/reserved-sync.d.ts +0 -66
  268. package/dist/lib/secrets/reserved-sync.js +0 -147
  269. package/dist/lib/secrets/scope.d.ts +0 -26
  270. package/dist/lib/secrets/scope.js +0 -29
  271. package/dist/lib/secrets/session-store.d.ts +0 -107
  272. package/dist/lib/secrets/session-store.js +0 -342
  273. package/dist/lib/secrets/sync-backend.d.ts +0 -48
  274. package/dist/lib/secrets/sync-backend.js +0 -13
  275. package/dist/lib/secrets/sync-commands.d.ts +0 -21
  276. package/dist/lib/secrets/sync-commands.js +0 -21
  277. package/dist/lib/secrets/sync.d.ts +0 -48
  278. package/dist/lib/secrets/sync.js +0 -237
  279. package/dist/lib/secrets/unlock-hints.d.ts +0 -27
  280. package/dist/lib/secrets/unlock-hints.js +0 -36
  281. package/dist/lib/secrets/usage-db.d.ts +0 -46
  282. package/dist/lib/secrets/usage-db.js +0 -96
  283. package/dist/lib/secrets/vault-age-helper.d.ts +0 -1
  284. package/dist/lib/secrets/vault-age-helper.js +0 -34
  285. package/dist/lib/secrets/vault.d.ts +0 -49
  286. package/dist/lib/secrets/vault.js +0 -399
  287. package/dist/lib/secrets/windows.d.ts +0 -81
  288. package/dist/lib/secrets/windows.js +0 -556
  289. package/scripts/install-helper.js +0 -97
  290. /package/dist/lib/{secrets/sync-passphrase.d.ts → sync-passphrase.d.ts} +0 -0
  291. /package/dist/lib/{secrets/sync-passphrase.js → sync-passphrase.js} +0 -0
@@ -15,7 +15,7 @@ import * as yaml from 'yaml';
15
15
  import { loadDevices } from '../lib/devices/registry.js';
16
16
  import { readMeta, updateMeta, getDevicePinsPath } from '../lib/state.js';
17
17
  import { machineId } from '../lib/machine-id.js';
18
- import { listBundles } from '../lib/secrets/bundles.js';
18
+ import { listBundles, SecretsClientError } from '../lib/secrets-client.js';
19
19
  import { listJobs } from '../lib/scheduling/routines.js';
20
20
  import { captureFleet } from '../lib/fleet/capture.js';
21
21
  /** Read THIS machine's pins file into `name -> [id@latest]`. Only used with
@@ -37,6 +37,25 @@ function agentsFromPins(names) {
37
37
  const ids = pins?.agents ? Object.keys(pins.agents) : [];
38
38
  return ids.length > 0 ? { [self]: ids.map((id) => `${id}@latest`) } : {};
39
39
  }
40
+ /**
41
+ * The names to snapshot into `fleet.secretsBundles` — best-effort. Capture's
42
+ * primary job (device/agent/routine snapshot) is unrelated to secrets, so a
43
+ * missing standalone `secrets` install (DIST-1: no fallback engine) degrades
44
+ * this ONE optional field to empty with a warning rather than failing the
45
+ * whole capture. A real store error still surfaces.
46
+ */
47
+ async function captureSecretsBundleNames() {
48
+ try {
49
+ return (await listBundles()).map((b) => b.name);
50
+ }
51
+ catch (err) {
52
+ if (err instanceof SecretsClientError && err.code === 'SECRETS_BIN_MISSING') {
53
+ console.error(chalk.yellow('warning: standalone `secrets` CLI not installed — capturing with no secrets bundles.'));
54
+ return [];
55
+ }
56
+ throw err;
57
+ }
58
+ }
40
59
  async function runCapture(opts) {
41
60
  const meta = readMeta();
42
61
  // Roster: every registered device name.
@@ -68,7 +87,7 @@ async function runCapture(opts) {
68
87
  // Browser profiles are intentionally NOT captured — the central `browser:`
69
88
  // block already syncs via the repo, and its ssh:// endpoints can carry
70
89
  // `user@host`, which must never be copied into the fleet: block.
71
- secretsBundles: listBundles().map((b) => b.name),
90
+ secretsBundles: await captureSecretsBundleNames(),
72
91
  routines: listJobs().map((j) => j.name),
73
92
  };
74
93
  // Discovery decisions and dismissals are device-scoped now (PHNX-3315): they
@@ -29,7 +29,7 @@
29
29
  import chalk from 'chalk';
30
30
  import { baseUrlEnvKeyForHost, authEnvKeyForHost, modelEnvKeyForHost, validateProfileName, listProfiles, } from '../lib/profiles.js';
31
31
  import { listPresets, getPreset } from '../lib/profiles-presets.js';
32
- import { listBundles } from '../lib/secrets/bundles.js';
32
+ import { listBundles } from '../lib/secrets-client.js';
33
33
  import { AGENTS, ALL_AGENT_IDS, isSelfUpdatingAgent, resolveAgentName } from '../lib/agents.js';
34
34
  import { readAccountRegistry } from '../lib/account-registry.js';
35
35
  /**
@@ -127,7 +127,7 @@ function knownProviders() {
127
127
  * is today's behavior, lifted verbatim; RUSH-2220 enriches the bundle browse.
128
128
  */
129
129
  async function askKeySource(io, draft, provider) {
130
- const bundles = listBundles();
130
+ const bundles = await listBundles();
131
131
  const source = bundles.length > 0
132
132
  ? await io.select({
133
133
  message: `How should '${provider}' get its key?`,
@@ -11,8 +11,7 @@ import chalk from 'chalk';
11
11
  import { showUrl } from '../lib/open-url.js';
12
12
  import { crabboxList, crabboxStop, reapSafeOrphans, reapOrphans, setLeaseSecretsBundle } from '../lib/crabbox/cli.js';
13
13
  import { isInteractiveTerminal, isPromptCancelled } from './utils.js';
14
- import { bundleExists, readBundle, writeBundle, keychainRef, bundleItemStore } from '../lib/secrets/bundles.js';
15
- import { secretsKeychainItem } from '../lib/secrets/index.js';
14
+ import { bundleExists, keychainRef, readBundle, secretsKeychainItem, writeBundleWithItems } from '../lib/secrets-client.js';
16
15
  function fmtIdle(box) {
17
16
  if (box.lastTouchedAt === null)
18
17
  return 'idle ?';
@@ -108,13 +107,11 @@ async function captureTailscaleAuthKey() {
108
107
  console.error(chalk.dim('Skipped Tailscale setup — public-IP leases only.'));
109
108
  return;
110
109
  }
111
- const bundle = bundleExists(TAILSCALE_BUNDLE)
112
- ? readBundle(TAILSCALE_BUNDLE)
110
+ const bundle = (await bundleExists(TAILSCALE_BUNDLE))
111
+ ? await readBundle(TAILSCALE_BUNDLE)
113
112
  : { name: TAILSCALE_BUNDLE, description: 'Tailscale ephemeral auth key for crabbox tailnet leases', vars: {} };
114
- const store = bundleItemStore(bundle.backend);
115
- store.set(secretsKeychainItem(TAILSCALE_BUNDLE, TAILSCALE_KEY), key);
116
113
  bundle.vars[TAILSCALE_KEY] = keychainRef(TAILSCALE_KEY);
117
- writeBundle(bundle);
114
+ await writeBundleWithItems(bundle, new Map([[secretsKeychainItem(TAILSCALE_BUNDLE, TAILSCALE_KEY), key]]));
118
115
  console.error(chalk.green(`✔ Stored Tailscale auth key in keychain bundle '${TAILSCALE_BUNDLE}'.`));
119
116
  console.error(chalk.dim(' Add --tailscale to a lease (reuse defaults to it) to reach the box over your tailnet.'));
120
117
  }
@@ -176,13 +173,11 @@ export async function runLeaseSetup(opts = {}) {
176
173
  else
177
174
  spinner.succeed('Token valid — Hetzner API reachable.');
178
175
  // Store into the `hetzner.com` keychain bundle (mirrors writeSyncBundle).
179
- const bundle = bundleExists(HETZNER_BUNDLE)
180
- ? readBundle(HETZNER_BUNDLE)
176
+ const bundle = (await bundleExists(HETZNER_BUNDLE))
177
+ ? await readBundle(HETZNER_BUNDLE)
181
178
  : { name: HETZNER_BUNDLE, description: 'Hetzner Cloud API token for crabbox leases', vars: {} };
182
- const store = bundleItemStore(bundle.backend);
183
- store.set(secretsKeychainItem(HETZNER_BUNDLE, HCLOUD_KEY), token);
184
179
  bundle.vars[HCLOUD_KEY] = keychainRef(HCLOUD_KEY);
185
- writeBundle(bundle);
180
+ await writeBundleWithItems(bundle, new Map([[secretsKeychainItem(HETZNER_BUNDLE, HCLOUD_KEY), token]]));
186
181
  setLeaseSecretsBundle(HETZNER_BUNDLE);
187
182
  console.error(chalk.green(`\n✔ Stored in keychain bundle '${HETZNER_BUNDLE}' and set as the default lease provider.`));
188
183
  console.error(chalk.dim(' Run `agents run <agent> "…" --lease` — no env var, no flag needed.'));
@@ -38,8 +38,8 @@ export interface AddProfileOptions {
38
38
  *
39
39
  * Reads the bundle value via {@link getKeychainToken} — this pops Touch ID on
40
40
  * macOS once, for that bundle-namespaced item (`agents-cli.secrets.*`, gated by
41
- * `keychainItemRequiresUserPresence` in `../lib/secrets/index.ts`) — then writes
42
- * it to `keychainItemName(provider)`, a plain `agents-cli.<provider>.token`
41
+ * the standalone's user-presence rule for `agents-cli.secrets.*` items) — then writes
42
+ * it to `profileKeychainItem(provider)`, a plain `agents-cli.<provider>.token`
43
43
  * item. That item matches neither the `agents-cli.secrets.` nor
44
44
  * `agents-cli.bundles.` prefix, so every later read of the harness's own key is
45
45
  * silent — no repeat Touch ID prompt.
@@ -10,9 +10,7 @@ import chalk from 'chalk';
10
10
  import { readStdinSync } from '../lib/format.js';
11
11
  import { writeProfile, profileFromPreset, profileFromHostModel, baseUrlEnvKeyForHost, authEnvKeyForHost, validateProfileName, profileExists, } from '../lib/profiles.js';
12
12
  import { getPreset, listPresets } from '../lib/profiles-presets.js';
13
- import { hasKeychainToken, keychainItemName, setKeychainToken, getKeychainToken, } from '../lib/secrets/profiles.js';
14
- import { parseBundleValue, secretsKeychainItem } from '../lib/secrets/index.js';
15
- import { readBundle } from '../lib/secrets/bundles.js';
13
+ import { getKeychainToken, hasKeychainToken, isSecretsClientError, parseBundleValue, profileKeychainItem, readBundle, secretsKeychainItem, setKeychainToken, } from '../lib/secrets-client.js';
16
14
  import { isInteractiveTerminal } from './utils.js';
17
15
  import { ALL_AGENT_IDS } from '../lib/agents.js';
18
16
  import { findAccount } from '../lib/account-registry.js';
@@ -28,7 +26,7 @@ export function buildProfileFromCollection(name, preset, collected, version) {
28
26
  env: { ...preset.env, ...collected },
29
27
  auth: {
30
28
  envVar: preset.authEnvVar,
31
- keychainItem: keychainItemName(preset.provider),
29
+ keychainItem: profileKeychainItem(preset.provider),
32
30
  },
33
31
  authOptional: preset.authOptional,
34
32
  description: preset.description,
@@ -47,8 +45,8 @@ async function promptForSecret(message) {
47
45
  /** Read all available data from stdin synchronously, trimmed. */
48
46
  /** Ensure a provider API key exists in keychain, prompting or reading stdin if missing. */
49
47
  export async function ensureProviderToken(provider, signupUrl, fromStdin) {
50
- const item = keychainItemName(provider);
51
- if (hasKeychainToken(item)) {
48
+ const item = profileKeychainItem(provider);
49
+ if (await hasKeychainToken(item)) {
52
50
  return;
53
51
  }
54
52
  let token;
@@ -62,7 +60,7 @@ export async function ensureProviderToken(provider, signupUrl, fromStdin) {
62
60
  const hint = signupUrl ? ` (get one at ${signupUrl})` : '';
63
61
  token = await promptForSecret(`Enter API key for ${provider}${hint}`);
64
62
  }
65
- setKeychainToken(item, token);
63
+ await setKeychainToken(item, token);
66
64
  console.log(chalk.green(`Stored in keychain: ${item}`));
67
65
  }
68
66
  /**
@@ -72,8 +70,8 @@ export async function ensureProviderToken(provider, signupUrl, fromStdin) {
72
70
  *
73
71
  * Reads the bundle value via {@link getKeychainToken} — this pops Touch ID on
74
72
  * macOS once, for that bundle-namespaced item (`agents-cli.secrets.*`, gated by
75
- * `keychainItemRequiresUserPresence` in `../lib/secrets/index.ts`) — then writes
76
- * it to `keychainItemName(provider)`, a plain `agents-cli.<provider>.token`
73
+ * the standalone's user-presence rule for `agents-cli.secrets.*` items) — then writes
74
+ * it to `profileKeychainItem(provider)`, a plain `agents-cli.<provider>.token`
77
75
  * item. That item matches neither the `agents-cli.secrets.` nor
78
76
  * `agents-cli.bundles.` prefix, so every later read of the harness's own key is
79
77
  * silent — no repeat Touch ID prompt.
@@ -106,7 +104,16 @@ export async function applyFromSecrets(profile, spec, explicitAuthProvider, opts
106
104
  const sep = spec.indexOf(':');
107
105
  const bundleName = sep === -1 ? spec : spec.slice(0, sep);
108
106
  const requestedKey = sep === -1 ? undefined : spec.slice(sep + 1);
109
- const bundle = readBundle(bundleName);
107
+ let bundle;
108
+ try {
109
+ bundle = await readBundle(bundleName);
110
+ }
111
+ catch (err) {
112
+ // The standalone reports only a code; name the bundle the user asked for.
113
+ if (!isSecretsClientError(err, 'NOT_FOUND'))
114
+ throw err;
115
+ throw new Error(`Secrets bundle '${bundleName}' not found. List bundles with 'agents secrets list'.`);
116
+ }
110
117
  const keys = Object.keys(bundle.vars);
111
118
  const key = requestedKey ?? (keys.length === 1 ? keys[0] : undefined);
112
119
  if (!key) {
@@ -123,7 +130,7 @@ export async function applyFromSecrets(profile, spec, explicitAuthProvider, opts
123
130
  value = parsed.literal;
124
131
  }
125
132
  else if (parsed.ref.provider === 'keychain') {
126
- value = getKeychainToken(secretsKeychainItem(bundle.name, parsed.ref.value));
133
+ value = await getKeychainToken(secretsKeychainItem(bundle.name, parsed.ref.value));
127
134
  }
128
135
  else {
129
136
  throw new Error(`Bundle '${bundleName}' key '${key}' is a '${parsed.ref.provider}:' reference, not a keychain-backed secret — --from-secrets only copies keychain-backed values.`);
@@ -134,8 +141,8 @@ export async function applyFromSecrets(profile, spec, explicitAuthProvider, opts
134
141
  `on a fork, so it never silently overwrites the source harness's shared keychain item.`);
135
142
  }
136
143
  const provider = explicitAuthProvider || (profile.auth ? profile.provider : undefined) || bundleName;
137
- const item = keychainItemName(provider);
138
- setKeychainToken(item, value);
144
+ const item = profileKeychainItem(provider);
145
+ await setKeychainToken(item, value);
139
146
  if (!profile.auth) {
140
147
  const envVar = authEnvKeyForHost(profile.host.agent);
141
148
  if (!envVar) {
@@ -64,7 +64,7 @@ async function publishUserRepoAccountState(provisionAuth) {
64
64
  if (usage.error)
65
65
  console.error(chalk.yellow(`Usage snapshot: ${usage.error}`));
66
66
  if (provisionAuth) {
67
- const { syncReservedAuthBundle } = await import('../lib/secrets/reserved-sync.js');
67
+ const { syncReservedAuthBundle } = await import('../lib/secrets-policy.js');
68
68
  const auth = await syncReservedAuthBundle();
69
69
  if (auth.pushed.length > 0)
70
70
  console.log(chalk.gray(`Auth bundle: pushed to ${auth.pushed.join(', ')}`));
@@ -72,7 +72,7 @@ async function publishUserRepoAccountState(provisionAuth) {
72
72
  console.error(chalk.yellow(`Auth bundle: ${err.device}: ${err.message}`));
73
73
  return;
74
74
  }
75
- const { publishReservedAuthVerdict } = await import('../lib/secrets/reserved-sync.js');
75
+ const { publishReservedAuthVerdict } = await import('../lib/secrets-policy.js');
76
76
  const auth = await publishReservedAuthVerdict();
77
77
  if (auth.error)
78
78
  console.error(chalk.yellow(`Auth verdict: ${auth.device}: ${auth.error}`));
@@ -85,7 +85,7 @@ async function consumeUserRepoAccountState() {
85
85
  console.log(chalk.gray(`Usage snapshot: merged ${usage.merged} row(s) from ${usage.sources.join(', ')}`));
86
86
  for (const err of usage.errors)
87
87
  console.error(chalk.yellow(`Usage snapshot: ${err.device}: ${err.message}`));
88
- const { syncReservedAuthBundle } = await import('../lib/secrets/reserved-sync.js');
88
+ const { syncReservedAuthBundle } = await import('../lib/secrets-policy.js');
89
89
  const auth = await syncReservedAuthBundle();
90
90
  if (auth.pushed.length > 0)
91
91
  console.log(chalk.gray(`Auth bundle: pushed to ${auth.pushed.join(', ')}`));
@@ -12,7 +12,7 @@ export interface RunAccountChoice {
12
12
  */
13
13
  signInRequired: boolean;
14
14
  }
15
- /** One named account row for `agents accounts switch` (reuses this picker's layout). */
15
+ /** One named account row for `agents accounts default` (reuses this picker's layout). */
16
16
  export interface SwitchAccountRow {
17
17
  accountName: string;
18
18
  kind: 'provider' | 'native';
@@ -25,8 +25,8 @@ export declare function formatAccountLimits(candidate: RotateCandidate): string;
25
25
  /** Build aligned picker rows with usable accounts first and unsafe rows disabled. */
26
26
  export declare function buildRunAccountChoices(candidates: RotateCandidate[], globalDefault: string | null): RunAccountChoice[];
27
27
  /**
28
- * Aligned picker rows for `accounts switch`. Same columns as the run picker
29
- * (identity, status, limits) but the value is the named account to set-default.
28
+ * Aligned picker rows for `accounts default`. Same columns as the run picker
29
+ * (identity, status, limits) but the value is the named account to make default.
30
30
  * Rows stay selectable: setting a default is not a launch.
31
31
  */
32
32
  export declare function buildSwitchAccountChoices(rows: SwitchAccountRow[]): RunAccountChoice[];
@@ -4,6 +4,7 @@ import { agentLabel } from '../lib/agents.js';
4
4
  import { loginHint } from '../lib/signin-badge.js';
5
5
  import { collectRunCandidates, readinessFromCandidate, isSignInRecoverable, } from '../lib/accounting/rotate.js';
6
6
  import { compareVersions, getGlobalDefault } from '../lib/installations/versions.js';
7
+ import { verdictLabel } from '../lib/auth-health.js';
7
8
  import { isInteractiveTerminal, isPromptCancelled, requireInteractiveSelection } from './utils.js';
8
9
  const CANCEL_SELECTION = '__agents_cancel_account_selection__';
9
10
  const WINDOW_ORDER = ['session', 'week', 'sonnet_week', 'month'];
@@ -65,28 +66,28 @@ export function buildRunAccountChoices(candidates, globalDefault) {
65
66
  const readiness = readinessFromCandidate(candidate);
66
67
  const disabled = disabledReason(candidate, readiness);
67
68
  const signInRequired = isSignInRecoverable(readiness);
68
- const version = candidate.version === globalDefault
69
- ? `${candidate.version} (default)`
70
- : candidate.version;
71
- // `revoked` is signed-in-but-rejected, so it reads as a re-login rather
72
- // than "logged out"; every throttle is still a signed-in account.
73
- const authReason = readiness.ready ? null : readiness.reason;
74
- const status = authReason === 'revoked'
69
+ const account = candidate.nativeAccount
70
+ || candidate.accountLabel
71
+ || 'account unavailable';
72
+ const marked = candidate.version === globalDefault && !candidate.nativeAccount
73
+ ? `${account} (default)`
74
+ : account;
75
+ const verdict = !readiness.ready && readiness.reason === 'revoked'
75
76
  ? 'needs re-login'
76
- : authReason === 'signed_out'
77
+ : !readiness.ready && readiness.reason === 'signed_out'
77
78
  ? 'logged out'
78
- : 'logged in';
79
+ : candidate.authVerdict
80
+ ? verdictLabel(candidate.authVerdict).toLowerCase()
81
+ : 'live';
79
82
  return {
80
83
  candidate,
81
- account: candidate.accountLabel || 'account unavailable',
82
- version,
83
- status,
84
- plan: candidate.usageSnapshot?.plan ?? candidate.plan ?? 'plan unavailable',
84
+ account: marked,
85
+ verdict,
85
86
  // An auth-blocked row shows what picking it DOES; its quota is moot until
86
87
  // there is a credential to spend it with.
87
- limits: authReason === 'revoked'
88
+ limits: !readiness.ready && readiness.reason === 'revoked'
88
89
  ? 'launch to re-authenticate'
89
- : authReason === 'signed_out'
90
+ : !readiness.ready && readiness.reason === 'signed_out'
90
91
  ? 'launch to sign in'
91
92
  : formatAccountLimits(candidate),
92
93
  disabled,
@@ -107,23 +108,22 @@ export function buildRunAccountChoices(candidates, globalDefault) {
107
108
  return compareVersions(b.candidate.version, a.candidate.version);
108
109
  });
109
110
  const accountWidth = Math.max(0, ...rows.map((row) => row.account.length));
110
- const versionWidth = Math.max(0, ...rows.map((row) => row.version.length));
111
- const statusWidth = Math.max(0, ...rows.map((row) => row.status.length));
112
- const planWidth = Math.max(0, ...rows.map((row) => row.plan.length));
111
+ const verdictWidth = Math.max(0, ...rows.map((row) => row.verdict.length));
113
112
  return rows.map((row) => ({
114
113
  name: [
115
114
  row.account.padEnd(accountWidth),
116
- row.version.padEnd(versionWidth),
117
- row.status.padEnd(statusWidth),
118
- row.plan.padEnd(planWidth),
115
+ row.verdict.padEnd(verdictWidth),
119
116
  row.limits,
120
117
  ].join(' '),
121
- value: row.candidate.version,
118
+ value: row.candidate.nativeAccount ?? row.candidate.version,
122
119
  disabled: row.disabled,
123
120
  ready: row.ready,
124
121
  signInRequired: row.signInRequired,
125
122
  }));
126
123
  }
124
+ function candidatePickerValue(candidate) {
125
+ return candidate.nativeAccount ?? candidate.version;
126
+ }
127
127
  function switchRowStatus(row) {
128
128
  if (!row.candidate) {
129
129
  return {
@@ -151,8 +151,8 @@ function switchRowStatus(row) {
151
151
  return { status, limits, ready: readiness.ready };
152
152
  }
153
153
  /**
154
- * Aligned picker rows for `accounts switch`. Same columns as the run picker
155
- * (identity, status, limits) but the value is the named account to set-default.
154
+ * Aligned picker rows for `accounts default`. Same columns as the run picker
155
+ * (identity, status, limits) but the value is the named account to make default.
156
156
  * Rows stay selectable: setting a default is not a launch.
157
157
  */
158
158
  export function buildSwitchAccountChoices(rows) {
@@ -184,12 +184,11 @@ export function buildSwitchAccountChoices(rows) {
184
184
  export async function pickSwitchAccount(agent, rows) {
185
185
  if (!isInteractiveTerminal()) {
186
186
  requireInteractiveSelection(`Selecting a ${agentLabel(agent)} account`, [
187
- `agents accounts switch ${agent} <account>`,
188
- `agents accounts set-default ${agent} <account>`,
187
+ `agents accounts default ${agent} <account>`,
189
188
  ]);
190
189
  }
191
190
  if (rows.length === 0) {
192
- throw new Error(`No named accounts for ${agent}. Add one with 'agents accounts add <name> --provider <p>' or 'agents accounts name ${agent}@<version> <name>'.`);
191
+ throw new Error(`No named accounts for ${agent}. Add one with 'agents accounts add ${agent} [name]'.`);
193
192
  }
194
193
  const choices = buildSwitchAccountChoices(rows).map(({ ready: _ready, signInRequired: _signInRequired, ...choice }) => choice);
195
194
  try {
@@ -292,16 +291,16 @@ export async function pickRunAccountCandidate(agent) {
292
291
  });
293
292
  }
294
293
  try {
295
- const version = await select({
294
+ const picked = await select({
296
295
  message: needsSignIn
297
296
  ? `Select a ${agentLabel(agent)} account for this run (pick a logged-out one to sign in):`
298
297
  : `Select a ${agentLabel(agent)} account for this run:`,
299
298
  choices: promptChoices,
300
299
  loop: false,
301
300
  });
302
- if (version === CANCEL_SELECTION)
301
+ if (picked === CANCEL_SELECTION)
303
302
  return null;
304
- return candidates.find((candidate) => candidate.version === version) ?? null;
303
+ return candidates.find((candidate) => candidatePickerValue(candidate) === picked) ?? null;
305
304
  }
306
305
  catch (err) {
307
306
  if (isPromptCancelled(err))
@@ -0,0 +1,20 @@
1
+ /**
2
+ * `agents secrets` — thin passthrough to the standalone `secrets` CLI
3
+ * (PHNX-3989, DIST-1). Every bundle/keychain/vault operation now lives in
4
+ * `@phnx-labs/secrets-cli`, not in this repo; this command re-declares no
5
+ * subcommand or flag of its own. `agents secrets <anything>` execs the
6
+ * installed executable with the same argv, `SECRETS_HOME` defaulted to this
7
+ * box's existing store (`buildServeEnv`, matching the process client's own
8
+ * default so an interactive `secrets list` and an injected `readBundle` see
9
+ * the same store), and `SECRETS_SCOPE`/`SECRETS_CONTEXT` passed through
10
+ * unmodified from the ambient environment — this is the operator's own
11
+ * terminal, not an injected agent exec, so there is no separate scope to
12
+ * compute here (that stays in `lib/exec.ts` for the run/inject path).
13
+ *
14
+ * A missing executable fails loud with install guidance — no fallback to the
15
+ * retired in-repo engine (`commands/secrets.ts` and its siblings), which stays
16
+ * in the tree, unregistered, until every consumer has moved off it (tasks.md
17
+ * item 7).
18
+ */
19
+ import type { Command } from 'commander';
20
+ export declare function registerSecretsCommands(program: Command): void;
@@ -0,0 +1,43 @@
1
+ import chalk from 'chalk';
2
+ import { spawnSync } from 'node:child_process';
3
+ import { buildServeEnv, invocation, resolveSecretsBin, SecretsClientError } from '../lib/secrets-client.js';
4
+ const INSTALL_HINT = 'npm i -g @phnx-labs/secrets-cli';
5
+ export function registerSecretsCommands(program) {
6
+ program
7
+ .command('secrets')
8
+ .description('Named bundles of env variables — passthrough to the standalone `secrets` CLI. Run `agents secrets --help` (or `agents setup secrets`) for the full subcommand list.')
9
+ .allowUnknownOption()
10
+ .allowExcessArguments()
11
+ // Hand `-h`/`--help` through too — the real subcommand help lives in the
12
+ // installed `secrets` binary, not in this passthrough.
13
+ .helpOption(false)
14
+ .action(() => {
15
+ let bin;
16
+ try {
17
+ bin = resolveSecretsBin();
18
+ }
19
+ catch (err) {
20
+ if (err instanceof SecretsClientError && err.code === 'SECRETS_BIN_MISSING') {
21
+ console.error(chalk.red('The standalone `secrets` CLI is not installed.'));
22
+ console.error(chalk.gray(`Install it, then re-run this command:`));
23
+ console.error(chalk.cyan(` ${INSTALL_HINT}`));
24
+ process.exit(1);
25
+ }
26
+ throw err;
27
+ }
28
+ // Everything after the literal `secrets` token on the real argv — the
29
+ // subcommand + its own flags, verbatim, never re-parsed by commander.
30
+ const secretsIndex = process.argv.indexOf('secrets');
31
+ const forwarded = secretsIndex >= 0 ? process.argv.slice(secretsIndex + 1) : [];
32
+ const { command, prefix } = invocation(bin);
33
+ const res = spawnSync(command, [...prefix, ...forwarded], {
34
+ stdio: 'inherit',
35
+ env: buildServeEnv(),
36
+ });
37
+ if (res.error) {
38
+ console.error(chalk.red(`Failed to run \`secrets\`: ${res.error.message}`));
39
+ process.exit(1);
40
+ }
41
+ process.exit(res.status ?? 1);
42
+ });
43
+ }
@@ -1,4 +1,5 @@
1
1
  import type { Command } from 'commander';
2
+ import type { SessionMeta } from '../lib/session/types.js';
2
3
  import type { SessionTrajectory } from '../lib/session/trajectory.js';
3
4
  import type { TrajectoryComparison, TrajectoryDivergence, TrajectorySummary } from '../lib/session/trajectory-compare.js';
4
5
  import type { TrajectoryStep } from '../lib/session/trajectory.js';
@@ -50,6 +51,7 @@ interface TraceOptions {
50
51
  output?: string;
51
52
  open?: boolean;
52
53
  errorsOnly?: boolean;
54
+ steps?: boolean;
53
55
  redact?: boolean;
54
56
  all?: boolean;
55
57
  since?: string;
@@ -73,6 +75,15 @@ export declare function chooseFormat(options: TraceOptions, isTTY: boolean): Ren
73
75
  * clear message. Pure, so the boundaries are unit-tested without the command.
74
76
  */
75
77
  export declare function decideTraceLayout(options: Pick<TraceOptions, 'tree' | 'compare'>, selectorCount: number, resolvedCount: number): 'single' | 'compare' | 'lineage';
78
+ /**
79
+ * Render one session's narration-anchored step list — the same fold the daemon
80
+ * caches and the sidebar renders, computed here from the transcript so the
81
+ * command works for any session, live or closed, cached or not.
82
+ */
83
+ export declare function renderSessionSteps(session: SessionMeta, options?: {
84
+ redact?: boolean;
85
+ knownSecrets?: readonly string[];
86
+ }): string;
76
87
  /** Attach the trace behaviour to a command node (canonical or top-level alias). */
77
88
  export declare function configureTraceCommand(cmd: Command): Command;
78
89
  /** Canonical `agents sessions trace <selectors...>`. */
@@ -23,6 +23,8 @@ import { knownSecretValuesFromEnv } from '../lib/redact.js';
23
23
  import { getCacheDir } from '../lib/state.js';
24
24
  import { discoverSessions } from '../lib/session/discover.js';
25
25
  import { parseSession } from '../lib/session/parse.js';
26
+ import { foldTimeline, projectSessionFiles, projectTimeline } from '../lib/session/timeline.js';
27
+ import { parseTimelineEvents } from '../lib/session/timeline-pass.js';
26
28
  import { buildTrajectory } from '../lib/session/trajectory.js';
27
29
  import { diffTrajectories } from '../lib/session/trajectory-compare.js';
28
30
  import { buildLineage } from '../lib/session/trajectory-lineage.js';
@@ -134,6 +136,53 @@ export function decideTraceLayout(options, selectorCount, resolvedCount) {
134
136
  }
135
137
  return 'single';
136
138
  }
139
+ /** One step's counters, rendered as the sidebar renders them: `6 run · 2 blocked`. */
140
+ function stepDetail(step) {
141
+ const mix = Object.entries(step.mix ?? {})
142
+ .filter(([, count]) => (count ?? 0) > 0)
143
+ .sort((a, b) => (b[1] ?? 0) - (a[1] ?? 0))
144
+ .map(([verb, count]) => `${count} ${verb}`);
145
+ return [
146
+ ...mix,
147
+ step.failed ? `${step.failed} failed` : '',
148
+ step.blocked ? `${step.blocked} blocked` : '',
149
+ ...(step.marks ?? []),
150
+ ].filter(Boolean).join(' · ');
151
+ }
152
+ /**
153
+ * Render one session's narration-anchored step list — the same fold the daemon
154
+ * caches and the sidebar renders, computed here from the transcript so the
155
+ * command works for any session, live or closed, cached or not.
156
+ */
157
+ export function renderSessionSteps(session, options = {}) {
158
+ const state = foldTimeline(parseTimelineEvents(session.filePath, session.agent), undefined, {});
159
+ const timeline = projectTimeline(state, undefined, state.steps.length, options);
160
+ if (!timeline.steps.length) {
161
+ return `No steps folded for ${session.shortId || session.id}` +
162
+ `${timeline.reason ? ` — ${timeline.reason}` : ''}\n`;
163
+ }
164
+ const startMs = state.firstMs ?? Date.parse(timeline.steps[0].at);
165
+ const lines = timeline.steps.map((step, index) => {
166
+ const offsetS = Math.max(0, Math.round((Date.parse(step.at) - startMs) / 1000));
167
+ const detail = stepDetail(step);
168
+ return [
169
+ String(index + 1).padStart(2),
170
+ `+${offsetS}s`.padStart(7),
171
+ step.source.slice(0, 4).padEnd(4),
172
+ step.text,
173
+ detail ? `· ${detail}` : '',
174
+ ].filter(Boolean).join(' ');
175
+ });
176
+ const files = projectSessionFiles(state);
177
+ const footer = [
178
+ `${timeline.steps.length} steps`,
179
+ `${timeline.tools} tools`,
180
+ timeline.failed ? `${timeline.failed} failed` : '',
181
+ timeline.blocked ? `${timeline.blocked} blocked` : '',
182
+ files ? `${files.total} file${files.total === 1 ? '' : 's'} changed` : '',
183
+ ].filter(Boolean).join(' · ');
184
+ return `${lines.join('\n')}\n\n${footer}\n`;
185
+ }
137
186
  /** Attach the trace behaviour to a command node (canonical or top-level alias). */
138
187
  export function configureTraceCommand(cmd) {
139
188
  cmd
@@ -144,6 +193,7 @@ export function configureTraceCommand(cmd) {
144
193
  .option('-o, --output <path>', 'Write the rendering to a path instead of opening/printing')
145
194
  .option('--no-open', 'Do not open the HTML; print its path instead')
146
195
  .option('--errors-only', 'Collapse the text trajectory to error steps and their neighbours')
196
+ .option('--steps', 'Print the narration-anchored step list the sidebar shows (the same fold as the session row)')
147
197
  .option('--compare', 'Force the compare layout for exactly two selectors (this is also the default for two)')
148
198
  .option('--tree', 'Render the lineage of one session — it and every session it spawned')
149
199
  .option('--no-redact', 'Local-only: skip secret redaction of derived labels (never for a shared file)')
@@ -161,6 +211,9 @@ agents sessions trace a1b2c3d4 --text
161
211
  # Just the failures and their neighbours — for a triaging agent
162
212
  agents sessions trace a1b2c3d4 --text --errors-only
163
213
 
214
+ # What the agent said it was doing, step by step — the sidebar's timeline as text
215
+ agents sessions trace a1b2c3d4 --steps
216
+
164
217
  # The stable JSON envelope for the AGI EXT Fleet panel or a tool
165
218
  agents sessions trace a1b2c3d4 --json
166
219
 
@@ -223,6 +276,9 @@ Three or more selectors, and --tree with more than one selector, fail loud.`,
223
276
  // count — a single content-search selector matching two sessions must NOT
224
277
  // silently become a compare. All the fail-loud boundaries live in the pure
225
278
  // decideTraceLayout so they are unit-tested (see sessions-trace.test.ts).
279
+ if (options.steps && selectors.length > 1) {
280
+ throw new Error('--steps renders one session\'s step list; pass a single selector.');
281
+ }
226
282
  const layout = decideTraceLayout(options, selectors.length, sessions.length);
227
283
  const redact = options.redact !== false;
228
284
  const knownSecrets = redact ? knownSecretValuesFromEnv() : undefined;
@@ -333,6 +389,21 @@ Three or more selectors, and --tree with more than one selector, fail loud.`,
333
389
  }
334
390
  // One selector — the single-session trajectory.
335
391
  const session = sessions[0];
392
+ // --steps is the CLI door to the timeline fold the sidebar renders, so an
393
+ // agent can read what a session DID without the extension (PHNX-3939). It is
394
+ // a different model from the trajectory (narration beats, not tool steps),
395
+ // so it short-circuits before buildTrajectory rather than reshaping it.
396
+ if (options.steps) {
397
+ const out = renderSessionSteps(session, { redact, knownSecrets });
398
+ if (options.output) {
399
+ fs.writeFileSync(options.output, out, { mode: 0o600 });
400
+ process.stderr.write(chalk.green(`Wrote step list to ${options.output}\n`));
401
+ }
402
+ else {
403
+ process.stdout.write(out);
404
+ }
405
+ return;
406
+ }
336
407
  const model = buildOne(session);
337
408
  if (format === 'json') {
338
409
  const out = JSON.stringify(buildTraceEnvelope([model]), null, 2) + '\n';
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * `agents setup accounts` — mint a Claude setup-token so unattended usage/probe
3
- * is not stuck on "usage pending". Delegates to the same mint engine as
4
- * `agents accounts mint` / `agents auth mint`.
3
+ * is not stuck on "usage pending". Delegates to the same mint engine as the
4
+ * mint step of `agents accounts add claude [name]` /
5
+ * `agents accounts login claude#<name>`.
5
6
  */
6
7
  import type { Command } from 'commander';
7
8
  export declare function runAccountsSetupWizard(): Promise<void>;
@@ -6,13 +6,13 @@ export async function runAccountsSetupWizard() {
6
6
  const status = hasMintedSetupToken();
7
7
  if (status.ready) {
8
8
  console.log(chalk.green(`Setup-token already minted (${status.detail}).`));
9
- console.log(chalk.gray('Re-mint with: agents accounts mint claude'));
9
+ console.log(chalk.gray('Re-mint with: agents accounts login claude#<name>'));
10
10
  return;
11
11
  }
12
12
  if (!isInteractiveTerminal()) {
13
13
  console.log(chalk.yellow('No Claude setup-token on this machine.'));
14
- console.log(chalk.gray('Mint one with: agents accounts mint claude'));
15
- console.log(chalk.gray('Already have a token: agents accounts mint claude --token-stdin'));
14
+ console.log(chalk.gray('Mint one with: agents accounts add claude [name]'));
15
+ console.log(chalk.gray('Already have a token: agents accounts add claude [name]'));
16
16
  process.exitCode = 1;
17
17
  return;
18
18
  }
@@ -21,7 +21,7 @@ export async function runAccountsSetupWizard() {
21
21
  default: true,
22
22
  });
23
23
  if (!proceed) {
24
- console.log(chalk.gray('Skipped. Run `agents accounts mint claude` when ready.'));
24
+ console.log(chalk.gray('Skipped. Run `agents accounts add claude [name]` when ready.'));
25
25
  return;
26
26
  }
27
27
  const result = await mintAndSeed({ harness: 'claude' });