@phnx-labs/agents-cli 1.23.17 → 1.23.19

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 (251) hide show
  1. package/CHANGELOG.md +239 -0
  2. package/README.md +140 -165
  3. package/dist/bootstrap.js +11 -17
  4. package/dist/cli/command-registry.d.ts +1 -2
  5. package/dist/cli/command-registry.js +1 -10
  6. package/dist/commands/accounts.js +7 -7
  7. package/dist/commands/cloud-transcripts.d.ts +0 -1
  8. package/dist/commands/cloud-transcripts.js +2 -2
  9. package/dist/commands/cloud.js +2 -2
  10. package/dist/commands/config.js +1 -5
  11. package/dist/commands/cost.js +1 -1
  12. package/dist/commands/daemon-index.js +0 -1
  13. package/dist/commands/detach.d.ts +1 -1
  14. package/dist/commands/detach.js +10 -6
  15. package/dist/commands/doctor.js +11 -7
  16. package/dist/commands/exec.d.ts +0 -17
  17. package/dist/commands/exec.js +26 -72
  18. package/dist/commands/feed.d.ts +1 -1
  19. package/dist/commands/feed.js +3 -3
  20. package/dist/commands/focus.d.ts +11 -6
  21. package/dist/commands/focus.js +91 -31
  22. package/dist/commands/fork.d.ts +0 -1
  23. package/dist/commands/fork.js +7 -16
  24. package/dist/commands/harness-wizard.js +1 -1
  25. package/dist/commands/harness.js +1 -1
  26. package/dist/commands/insights.d.ts +0 -1
  27. package/dist/commands/insights.js +3 -7
  28. package/dist/commands/open.js +1 -1
  29. package/dist/commands/output.js +1 -1
  30. package/dist/commands/profiles.d.ts +1 -1
  31. package/dist/commands/profiles.js +2 -2
  32. package/dist/commands/projects-todo.js +10 -5
  33. package/dist/commands/projects.js +1 -1
  34. package/dist/commands/prune.js +1 -1
  35. package/dist/commands/ps.d.ts +8 -3
  36. package/dist/commands/ps.js +238 -110
  37. package/dist/commands/routines.js +1 -1
  38. package/dist/commands/send.js +1 -1
  39. package/dist/commands/sessions-backfill.d.ts +0 -1
  40. package/dist/commands/sessions-backfill.js +3 -6
  41. package/dist/commands/sessions-browser.d.ts +0 -10
  42. package/dist/commands/sessions-browser.js +19 -25
  43. package/dist/commands/sessions-migrate.d.ts +2 -2
  44. package/dist/commands/sessions-migrate.js +13 -13
  45. package/dist/commands/sessions-optimize.d.ts +0 -1
  46. package/dist/commands/sessions-optimize.js +0 -3
  47. package/dist/commands/sessions-picker.d.ts +0 -7
  48. package/dist/commands/sessions-picker.js +16 -310
  49. package/dist/commands/sessions-resume.d.ts +16 -15
  50. package/dist/commands/sessions-resume.js +101 -269
  51. package/dist/commands/sessions-stats.d.ts +0 -1
  52. package/dist/commands/sessions-stats.js +5 -8
  53. package/dist/commands/sessions-stop.d.ts +1 -1
  54. package/dist/commands/sessions-stop.js +8 -8
  55. package/dist/commands/sessions-trace.d.ts +1 -1
  56. package/dist/commands/sessions-trace.js +40 -17
  57. package/dist/commands/sessions-watch.js +2 -2
  58. package/dist/commands/sessions.test-fixture.d.ts +1 -0
  59. package/dist/commands/sessions.test-fixture.js +14 -0
  60. package/dist/commands/setup-browser.js +4 -4
  61. package/dist/commands/setup-computer.js +4 -4
  62. package/dist/commands/setup-fleet.js +1 -1
  63. package/dist/commands/setup-preferences.js +1 -1
  64. package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
  65. package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
  66. package/dist/commands/setup.js +3 -1
  67. package/dist/commands/ssh.js +4 -5
  68. package/dist/commands/sync.js +1 -1
  69. package/dist/commands/teams.js +2 -2
  70. package/dist/commands/utils.d.ts +0 -1
  71. package/dist/commands/utils.js +0 -10
  72. package/dist/index.js +0 -71
  73. package/dist/lib/account-registry.d.ts +3 -0
  74. package/dist/lib/account-registry.js +40 -0
  75. package/dist/lib/accounting/usage-sync.d.ts +1 -0
  76. package/dist/lib/accounting/usage-sync.js +20 -3
  77. package/dist/lib/accounting/usage.d.ts +4 -1
  78. package/dist/lib/accounting/usage.js +38 -6
  79. package/dist/lib/agent-spec/agents.js +12 -11
  80. package/dist/lib/analytics/mix-commands.js +1 -1
  81. package/dist/lib/auth-mint.js +2 -2
  82. package/dist/lib/browser-client.d.ts +0 -1
  83. package/dist/lib/browser-client.js +0 -3
  84. package/dist/lib/cloud/antigravity.js +1 -1
  85. package/dist/lib/cloud/cursor.js +3 -3
  86. package/dist/lib/cloud/store.d.ts +5 -1
  87. package/dist/lib/cloud/store.js +10 -3
  88. package/dist/lib/cloudflare/creds.js +2 -2
  89. package/dist/lib/computer/context.d.ts +4 -21
  90. package/dist/lib/computer/context.js +3 -24
  91. package/dist/lib/computer/policy.d.ts +0 -10
  92. package/dist/lib/computer/policy.js +0 -28
  93. package/dist/lib/computer-client.d.ts +0 -44
  94. package/dist/lib/computer-client.js +17 -121
  95. package/dist/lib/config-keys.d.ts +2 -2
  96. package/dist/lib/config-keys.js +1 -3
  97. package/dist/lib/crabbox/cli.js +1 -1
  98. package/dist/lib/daemon/account-state-daemon-service.js +9 -2
  99. package/dist/lib/daemon/self-update-service.js +1 -1
  100. package/dist/lib/device-config.d.ts +2 -1
  101. package/dist/lib/device-config.js +26 -39
  102. package/dist/lib/devices/connect.d.ts +1 -1
  103. package/dist/lib/devices/connect.js +3 -6
  104. package/dist/lib/devices/doctor-findings.d.ts +2 -1
  105. package/dist/lib/devices/doctor-findings.js +4 -4
  106. package/dist/lib/devices/health.d.ts +6 -0
  107. package/dist/lib/devices/health.js +11 -4
  108. package/dist/lib/exec.js +1 -1
  109. package/dist/lib/feed/activity.js +1 -1
  110. package/dist/lib/feed/watch.js +2 -1
  111. package/dist/lib/fleet/apply.d.ts +1 -1
  112. package/dist/lib/fleet/apply.js +6 -3
  113. package/dist/lib/fleet-shared-state.d.ts +2 -0
  114. package/dist/lib/fleet-shared-state.js +3 -1
  115. package/dist/lib/github/project-prs.js +14 -1
  116. package/dist/lib/help.d.ts +0 -1
  117. package/dist/lib/help.js +2 -10
  118. package/dist/lib/helper-versions.js +1 -1
  119. package/dist/lib/hosts/option.js +1 -1
  120. package/dist/lib/hosts/passthrough.d.ts +0 -1
  121. package/dist/lib/hosts/passthrough.js +2 -26
  122. package/dist/lib/hosts/reconnect.js +5 -5
  123. package/dist/lib/hosts/remote-cmd.d.ts +3 -5
  124. package/dist/lib/hosts/remote-cmd.js +15 -20
  125. package/dist/lib/hosts/remote-session-id.js +1 -1
  126. package/dist/lib/installations/active-check.js +1 -1
  127. package/dist/lib/installations/migrate.js +4 -15
  128. package/dist/lib/installations/versions.js +5 -4
  129. package/dist/lib/launch-log.js +3 -6
  130. package/dist/lib/owner-notify.d.ts +1 -6
  131. package/dist/lib/owner-notify.js +0 -2
  132. package/dist/lib/paths.d.ts +0 -1
  133. package/dist/lib/paths.js +0 -8
  134. package/dist/lib/permissions.js +1 -1
  135. package/dist/lib/project-root.d.ts +1 -0
  136. package/dist/lib/project-root.js +11 -3
  137. package/dist/lib/projects.js +2 -2
  138. package/dist/lib/quick-todo.d.ts +5 -1
  139. package/dist/lib/quick-todo.js +14 -1
  140. package/dist/lib/redact.d.ts +0 -1
  141. package/dist/lib/redact.js +0 -4
  142. package/dist/lib/remote-agents-json.d.ts +3 -1
  143. package/dist/lib/remote-agents-json.js +12 -8
  144. package/dist/lib/reserved-stores.js +1 -1
  145. package/dist/lib/scheduling/routines.d.ts +0 -1
  146. package/dist/lib/scheduling/routines.js +1 -1
  147. package/dist/lib/self-update.d.ts +1 -1
  148. package/dist/lib/self-update.js +59 -2
  149. package/dist/lib/session/active.d.ts +1 -1
  150. package/dist/lib/session/db.js +4 -4
  151. package/dist/lib/session/detached.d.ts +0 -1
  152. package/dist/lib/session/detached.js +0 -23
  153. package/dist/lib/session/discover.d.ts +2 -2
  154. package/dist/lib/session/glance-files.d.ts +21 -0
  155. package/dist/lib/session/glance-files.js +123 -0
  156. package/dist/lib/session/presentation.d.ts +3 -7
  157. package/dist/lib/session/presentation.js +4 -4
  158. package/dist/lib/session/preview-digest.d.ts +13 -0
  159. package/dist/lib/session/preview-digest.js +328 -0
  160. package/dist/lib/session/projection.js +1 -1
  161. package/dist/lib/session/remote/remote-list.d.ts +5 -2
  162. package/dist/lib/session/remote/remote-list.js +15 -8
  163. package/dist/lib/session/remote/watch.d.ts +2 -0
  164. package/dist/lib/session/remote/watch.js +90 -10
  165. package/dist/lib/session/remote-active.js +1 -1
  166. package/dist/lib/session/resume-command.d.ts +0 -1
  167. package/dist/lib/session/resume-command.js +1 -4
  168. package/dist/lib/session/resume-owner.d.ts +0 -2
  169. package/dist/lib/session/resume-owner.js +0 -6
  170. package/dist/lib/session/selection.d.ts +4 -5
  171. package/dist/lib/session/selection.js +2 -2
  172. package/dist/lib/session/sync/config.d.ts +0 -25
  173. package/dist/lib/session/sync/config.js +0 -62
  174. package/dist/lib/session/sync/managed-config.d.ts +0 -1
  175. package/dist/lib/session/sync/managed-config.js +0 -3
  176. package/dist/lib/session/sync/worker-template.js +1 -1
  177. package/dist/lib/sessions-client.d.ts +0 -16
  178. package/dist/lib/sessions-client.js +1 -187
  179. package/dist/lib/smart-launch.js +6 -1
  180. package/dist/lib/startup/command-registry.d.ts +2 -0
  181. package/dist/lib/startup/command-registry.js +36 -3
  182. package/dist/lib/startup/root-command.d.ts +0 -1
  183. package/dist/lib/startup/root-command.js +0 -21
  184. package/dist/lib/sync-umbrella.js +1 -1
  185. package/dist/lib/teams/placement-probe.d.ts +2 -0
  186. package/dist/lib/teams/placement-probe.js +8 -3
  187. package/dist/lib/terminal/engine.d.ts +2 -0
  188. package/dist/lib/terminal/engine.js +5 -3
  189. package/dist/lib/terminal/index.d.ts +1 -1
  190. package/dist/lib/terminal/index.js +1 -1
  191. package/dist/lib/terminal/resolve.js +1 -1
  192. package/dist/lib/terminal/run-surface.d.ts +1 -0
  193. package/dist/lib/terminal/run-surface.js +9 -0
  194. package/dist/lib/watchdog/rotate.js +1 -1
  195. package/dist/lib/watchdog/watchdog.d.ts +1 -1
  196. package/dist/lib/watchdog/watchdog.js +2 -2
  197. package/package.json +1 -1
  198. package/dist/commands/browser.d.ts +0 -7
  199. package/dist/commands/browser.js +0 -139
  200. package/dist/commands/computer.d.ts +0 -48
  201. package/dist/commands/computer.js +0 -244
  202. package/dist/commands/resume.d.ts +0 -23
  203. package/dist/commands/resume.js +0 -158
  204. package/dist/commands/secrets-passthrough.d.ts +0 -3
  205. package/dist/commands/secrets-passthrough.js +0 -52
  206. package/dist/commands/sessions-bookmark.d.ts +0 -2
  207. package/dist/commands/sessions-bookmark.js +0 -92
  208. package/dist/commands/sessions-export.d.ts +0 -31
  209. package/dist/commands/sessions-export.js +0 -409
  210. package/dist/commands/sessions-import.d.ts +0 -6
  211. package/dist/commands/sessions-import.js +0 -343
  212. package/dist/commands/sessions-inject.d.ts +0 -14
  213. package/dist/commands/sessions-inject.js +0 -143
  214. package/dist/commands/sessions-picker-factory.d.ts +0 -24
  215. package/dist/commands/sessions-picker-factory.js +0 -59
  216. package/dist/commands/sessions-render.d.ts +0 -11
  217. package/dist/commands/sessions-render.js +0 -119
  218. package/dist/commands/sessions-share.d.ts +0 -15
  219. package/dist/commands/sessions-share.js +0 -171
  220. package/dist/commands/sessions.d.ts +0 -122
  221. package/dist/commands/sessions.js +0 -1760
  222. package/dist/lib/address.d.ts +0 -39
  223. package/dist/lib/address.js +0 -128
  224. package/dist/lib/computer/record.d.ts +0 -6
  225. package/dist/lib/computer/record.js +0 -25
  226. package/dist/lib/onepassword.d.ts +0 -57
  227. package/dist/lib/onepassword.js +0 -140
  228. package/dist/lib/openclaw-keychain.d.ts +0 -43
  229. package/dist/lib/openclaw-keychain.js +0 -227
  230. package/dist/lib/session/bundle.d.ts +0 -76
  231. package/dist/lib/session/bundle.js +0 -146
  232. package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
  233. package/dist/lib/session/remote/remote-bundle.js +0 -40
  234. package/dist/lib/session/remote/remote.d.ts +0 -35
  235. package/dist/lib/session/remote/remote.js +0 -198
  236. package/dist/lib/session/remote-bundle.d.ts +0 -1
  237. package/dist/lib/session/remote-bundle.js +0 -1
  238. package/dist/lib/session/remote.d.ts +0 -1
  239. package/dist/lib/session/remote.js +0 -1
  240. package/dist/lib/session/sync/agents.d.ts +0 -24
  241. package/dist/lib/session/sync/agents.js +0 -0
  242. package/dist/lib/session/sync/backend.d.ts +0 -22
  243. package/dist/lib/session/sync/backend.js +0 -44
  244. package/dist/lib/session/sync/managed-key.d.ts +0 -5
  245. package/dist/lib/session/sync/managed-key.js +0 -87
  246. package/dist/lib/session/sync/net-client.d.ts +0 -29
  247. package/dist/lib/session/sync/net-client.js +0 -87
  248. package/dist/lib/session/sync/r2.d.ts +0 -20
  249. package/dist/lib/session/sync/r2.js +0 -103
  250. package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
  251. package/dist/lib/session/sync/transcript-crypto.js +0 -115
@@ -1348,6 +1348,7 @@ function serializeClaudeUsageSnapshot(snapshot) {
1348
1348
  ? {
1349
1349
  reason: snapshot.unavailable.reason,
1350
1350
  resetsAt: snapshot.unavailable.resetsAt?.toISOString(),
1351
+ notedAt: snapshot.unavailable.notedAt?.toISOString(),
1351
1352
  }
1352
1353
  : undefined,
1353
1354
  windows: persistedWindows.map((window) => ({
@@ -1398,13 +1399,20 @@ function deserializeClaudeUsageSnapshot(snapshot, now) {
1398
1399
  : undefined,
1399
1400
  };
1400
1401
  }
1402
+ export const OUT_OF_CREDITS_REPROBE_MS = 60 * 60 * 1000;
1403
+ function liveOutOfCredits(cached, now) {
1404
+ const noted = parseDateValue(cached.notedAt);
1405
+ if (!noted || now.getTime() - noted.getTime() >= OUT_OF_CREDITS_REPROBE_MS)
1406
+ return undefined;
1407
+ return { reason: 'out_of_credits', notedAt: noted };
1408
+ }
1401
1409
  function carryForwardUnavailable(prior, live) {
1402
1410
  if (live)
1403
1411
  return live;
1404
1412
  if (!prior)
1405
1413
  return undefined;
1406
1414
  if (prior.reason === 'out_of_credits')
1407
- return { reason: 'out_of_credits' };
1415
+ return liveOutOfCredits(prior, new Date());
1408
1416
  const reset = parseDateValue(prior.resetsAt);
1409
1417
  return reset && reset.getTime() > Date.now()
1410
1418
  ? { reason: 'session_limit', resetsAt: reset }
@@ -1414,7 +1422,7 @@ function deserializeUnavailable(cached, now) {
1414
1422
  if (!cached)
1415
1423
  return undefined;
1416
1424
  if (cached.reason === 'out_of_credits')
1417
- return { reason: 'out_of_credits' };
1425
+ return liveOutOfCredits(cached, now);
1418
1426
  const reset = parseDateValue(cached.resetsAt);
1419
1427
  return reset && reset.getTime() > now.getTime()
1420
1428
  ? { reason: 'session_limit', resetsAt: reset }
@@ -1430,13 +1438,16 @@ function hasLiveModelRefusal(modelRefusals, now) {
1430
1438
  return !reset || reset.getTime() > now.getTime();
1431
1439
  });
1432
1440
  }
1433
- export function noteClaudeOutOfCredits(usageKey, cachePath = getClaudeUsageCachePath()) {
1441
+ export function noteClaudeOutOfCredits(usageKey, cachePath = getClaudeUsageCachePath(), now = new Date()) {
1434
1442
  try {
1435
1443
  ensureLockTarget(cachePath, '{}');
1436
1444
  withFileLock(cachePath, () => {
1437
1445
  const cache = readClaudeUsageCacheFile(cachePath);
1438
1446
  const existing = cache[usageKey] ?? { capturedAt: null, windows: [] };
1439
- cache[usageKey] = { ...existing, unavailable: { reason: 'out_of_credits' } };
1447
+ cache[usageKey] = {
1448
+ ...existing,
1449
+ unavailable: { reason: 'out_of_credits', notedAt: now.toISOString() },
1450
+ };
1440
1451
  atomicWriteFileSync(cachePath, JSON.stringify(cache, null, 2), 'utf-8');
1441
1452
  });
1442
1453
  }
@@ -1933,6 +1944,10 @@ async function getGrokUsageInfo(options) {
1933
1944
  return usageNoRecentUsageInfo();
1934
1945
  }
1935
1946
  const now = new Date();
1947
+ const unavailable = match.exhaustedAt
1948
+ && now.getTime() - match.exhaustedAt.getTime() < OUT_OF_CREDITS_REPROBE_MS
1949
+ ? { reason: 'out_of_credits', notedAt: match.exhaustedAt }
1950
+ : undefined;
1936
1951
  const windows = match.windows.filter((window) => isCachedUsageWindowFresh(window, match.capturedAt, now));
1937
1952
  const staleWindows = match.windows.filter((window) => !isCachedUsageWindowFresh(window, match.capturedAt, now));
1938
1953
  const version = options?.cliVersion;
@@ -1948,6 +1963,7 @@ async function getGrokUsageInfo(options) {
1948
1963
  staleWindows: staleWindows.length > 0 ? staleWindows : undefined,
1949
1964
  plan: match.subscriptionTier,
1950
1965
  refreshHint,
1966
+ unavailable,
1951
1967
  },
1952
1968
  error: null,
1953
1969
  };
@@ -2174,6 +2190,7 @@ async function readMuseLocalSessionUsage(base) {
2174
2190
  async function readLatestGrokBilling(filePath) {
2175
2191
  return new Promise((resolve) => {
2176
2192
  let latest = null;
2193
+ let exhaustedAt = null;
2177
2194
  const stream = fs.createReadStream(filePath, { encoding: 'utf-8' });
2178
2195
  const rl = readline.createInterface({ input: stream, crlfDelay: Infinity });
2179
2196
  rl.on('line', (line) => {
@@ -2184,6 +2201,12 @@ async function readLatestGrokBilling(filePath) {
2184
2201
  const ctx = parsed.ctx && typeof parsed.ctx === 'object' && !Array.isArray(parsed.ctx)
2185
2202
  ? parsed.ctx
2186
2203
  : null;
2204
+ if (parsed.msg === 'shell.turn.inference_failed'
2205
+ && ctx?.status_code === 402
2206
+ && /balance exhausted/i.test(String(ctx.message ?? ''))) {
2207
+ exhaustedAt = parseDateValue(parsed.ts) ?? exhaustedAt;
2208
+ return;
2209
+ }
2187
2210
  if (parsed.msg === 'billing: fetched credits config' && ctx?.config) {
2188
2211
  const config = ctx.config;
2189
2212
  const windows = [];
@@ -2207,13 +2230,22 @@ async function readLatestGrokBilling(filePath) {
2207
2230
  windows,
2208
2231
  identity: grokIdentityFromBillingPayload(parsed),
2209
2232
  };
2233
+ exhaustedAt = null;
2210
2234
  }
2211
2235
  }
2212
2236
  catch {
2213
2237
  }
2214
2238
  });
2215
- rl.on('close', () => resolve(latest));
2216
- rl.on('error', () => resolve(latest));
2239
+ const settle = () => {
2240
+ if (exhaustedAt) {
2241
+ resolve({ ...(latest ?? { capturedAt: exhaustedAt, windows: [], identity: null }), exhaustedAt });
2242
+ }
2243
+ else {
2244
+ resolve(latest);
2245
+ }
2246
+ };
2247
+ rl.on('close', settle);
2248
+ rl.on('error', settle);
2217
2249
  });
2218
2250
  }
2219
2251
  export function normalizeCursorUsage(data) {
@@ -16,6 +16,7 @@ import { registeredNativeAccountForEmail, parseNativeIdentityKey } from '../nati
16
16
  import { resolveVersion, getVersionHomePath, getBinaryPath } from '../installations/versions.js';
17
17
  import { supports } from '../capabilities.js';
18
18
  import { MCP_TARGETS } from '../mcp-registry.js';
19
+ import { HARNESS_AUTH } from '../harness-auth-capabilities.js';
19
20
  import { VERSION_RE } from './primitives.js';
20
21
  const execFileAsync = promisify(execFile);
21
22
  const HOME = os.homedir();
@@ -937,14 +938,14 @@ export function isAccountSlotDir(dir) {
937
938
  const resolved = path.resolve(dir);
938
939
  return resolved === root || resolved.startsWith(root + path.sep);
939
940
  }
940
- function resolveAccountCredentialPath(base, ...segments) {
941
+ function resolveAccountCredentialPath(agent, base, ...segments) {
941
942
  const perVersion = path.join(base, ...segments);
942
943
  try {
943
944
  if (fs.existsSync(perVersion))
944
945
  return perVersion;
945
946
  }
946
947
  catch { }
947
- if (isAccountSlotDir(base))
948
+ if (isAccountSlotDir(base) || HARNESS_AUTH[agent].slotEnv)
948
949
  return null;
949
950
  const active = path.join(process.env.AGENTS_REAL_HOME || os.homedir(), ...segments);
950
951
  if (active !== perVersion) {
@@ -995,8 +996,8 @@ export function credentialPresence(agentId, versionHome) {
995
996
  return { perVersion, active, knownLocation };
996
997
  }
997
998
  export function decryptDroidAuthPayload(base) {
998
- const filePath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.file');
999
- const keyPath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.key');
999
+ const filePath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.file');
1000
+ const keyPath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.key');
1000
1001
  if (!filePath || !keyPath)
1001
1002
  return null;
1002
1003
  return decryptDroidAuthFile(filePath, keyPath);
@@ -1423,7 +1424,7 @@ export async function getAccountInfo(agentId, home) {
1423
1424
  };
1424
1425
  }
1425
1426
  case 'cursor': {
1426
- const cfgPath = resolveAccountCredentialPath(base, '.cursor', 'cli-config.json');
1427
+ const cfgPath = resolveAccountCredentialPath('cursor', base, '.cursor', 'cli-config.json');
1427
1428
  if (!cfgPath)
1428
1429
  return { ...empty, lastActive };
1429
1430
  try {
@@ -1433,7 +1434,7 @@ export async function getAccountInfo(agentId, home) {
1433
1434
  const accountId = normalizeIdentityPart(authInfo?.authId ?? authInfo?.userId);
1434
1435
  if (!email && !accountId)
1435
1436
  return { ...empty, lastActive };
1436
- const authPath = resolveAccountCredentialPath(base, '.cursor', 'auth.json');
1437
+ const authPath = resolveAccountCredentialPath('cursor', base, '.cursor', 'auth.json');
1437
1438
  let hasToken = false;
1438
1439
  if (authPath) {
1439
1440
  try {
@@ -1451,7 +1452,7 @@ export async function getAccountInfo(agentId, home) {
1451
1452
  return { ...empty, lastActive };
1452
1453
  }
1453
1454
  case 'grok': {
1454
- const authPath = resolveAccountCredentialPath(base, '.grok', 'auth.json');
1455
+ const authPath = resolveAccountCredentialPath('grok', base, '.grok', 'auth.json');
1455
1456
  if (!authPath)
1456
1457
  return { ...empty, lastActive };
1457
1458
  try {
@@ -1473,7 +1474,7 @@ export async function getAccountInfo(agentId, home) {
1473
1474
  return { ...empty, lastActive };
1474
1475
  }
1475
1476
  case 'antigravity': {
1476
- const tokenPath = resolveAccountCredentialPath(base, '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
1477
+ const tokenPath = resolveAccountCredentialPath('antigravity', base, '.gemini', 'antigravity-cli', 'antigravity-oauth-token');
1477
1478
  if (tokenPath) {
1478
1479
  const data = JSON.parse(await fs.promises.readFile(tokenPath, 'utf-8'));
1479
1480
  if (typeof data?.token?.refresh_token === 'string' && data.token.refresh_token) {
@@ -1488,7 +1489,7 @@ export async function getAccountInfo(agentId, home) {
1488
1489
  return { ...empty, lastActive };
1489
1490
  }
1490
1491
  case 'kimi': {
1491
- const credPath = resolveAccountCredentialPath(base, '.kimi-code', 'credentials', 'kimi-code.json');
1492
+ const credPath = resolveAccountCredentialPath('kimi', base, '.kimi-code', 'credentials', 'kimi-code.json');
1492
1493
  if (!credPath)
1493
1494
  return { ...empty, lastActive };
1494
1495
  const data = JSON.parse(await fs.promises.readFile(credPath, 'utf-8'));
@@ -1516,7 +1517,7 @@ export async function getAccountInfo(agentId, home) {
1516
1517
  };
1517
1518
  }
1518
1519
  // An unreadable encrypted payload still counts conservatively when its auth file exists.
1519
- const authPath = resolveAccountCredentialPath(base, '.factory', 'auth.v2.file');
1520
+ const authPath = resolveAccountCredentialPath('droid', base, '.factory', 'auth.v2.file');
1520
1521
  if (!authPath)
1521
1522
  return { ...empty, lastActive };
1522
1523
  return { ...empty, signedIn: true, lastActive };
@@ -1541,7 +1542,7 @@ export async function getAccountInfo(agentId, home) {
1541
1542
  const accountKey = buildIdentityKey(agentId, [['auth', 'env']]);
1542
1543
  return { ...empty, signedIn: true, accountId: 'env', accountKey, lastActive };
1543
1544
  }
1544
- const authPath = resolveAccountCredentialPath(base, '.config', 'muse', 'auth.json');
1545
+ const authPath = resolveAccountCredentialPath('muse', base, '.config', 'muse', 'auth.json');
1545
1546
  if (!authPath)
1546
1547
  return { ...empty, lastActive };
1547
1548
  const data = JSON.parse(await fs.promises.readFile(authPath, 'utf-8'));
@@ -108,7 +108,7 @@ export function registerMixCommands(parent) {
108
108
  (\`agents insights mix harness-mix\`) for just that section; \`--list\` names them.
109
109
  This is the cheap counter path. Behavioural report (transcript content, account split)
110
110
  is bare \`agents insights\`. Latency is \`agents insights perf\`; quota is \`agents view\`.
111
- Skill/slash-command popularity is \`agents sessions stats\`.
111
+ Skill/slash-command popularity is \`agents insights resources\`.
112
112
  `,
113
113
  });
114
114
  parent.command('query')
@@ -142,7 +142,7 @@ export function seedReservedAuthToken(email, token) {
142
142
  if (bundleExistsSync(AUTH_BUNDLE)) {
143
143
  const backend = bundleBackendSync(AUTH_BUNDLE);
144
144
  if (backend !== 'file') {
145
- throw new Error(`Reserved bundle '${AUTH_BUNDLE}' exists with backend '${backend}', but usage/probe only reads a FILE-backed auth bundle. Recreate it with: agents secrets create ${AUTH_BUNDLE} --backend file --policy never --i-understand --force`);
145
+ throw new Error(`Reserved bundle '${AUTH_BUNDLE}' exists with backend '${backend}', but usage/probe only reads a FILE-backed auth bundle. Recreate it with: secrets create ${AUTH_BUNDLE} --backend file --policy never --i-understand --force`);
146
146
  }
147
147
  const bundle = readBundleSync(AUTH_BUNDLE);
148
148
  if (key in bundle.vars) {
@@ -215,7 +215,7 @@ export function writeReservedStoreItem(name, key, value, description) {
215
215
  if (bundleExistsSync(name)) {
216
216
  const backend = bundleBackendSync(name);
217
217
  if (backend !== 'file') {
218
- throw new Error(`Reserved store '${name}' exists with backend '${backend}', but worker provisioning only reads a FILE-backed store. Recreate it with: agents secrets delete ${name} --yes`);
218
+ throw new Error(`Reserved store '${name}' exists with backend '${backend}', but worker provisioning only reads a FILE-backed store. Recreate it with: secrets delete ${name} --yes`);
219
219
  }
220
220
  const bundle = readBundleSync(name);
221
221
  if (key in bundle.vars) {
@@ -3,7 +3,6 @@ export declare class BrowserClientError extends Error {
3
3
  code: string;
4
4
  constructor(code: string, message: string);
5
5
  }
6
- export declare function isBrowserClientError(err: unknown): err is BrowserClientError;
7
6
  export declare function isStandaloneBrowser(bin: string): boolean;
8
7
  export declare function resolveBrowserBin(): string;
9
8
  export declare function browserInstalled(): boolean;
@@ -12,9 +12,6 @@ export class BrowserClientError extends Error {
12
12
  this.name = 'BrowserClientError';
13
13
  }
14
14
  }
15
- export function isBrowserClientError(err) {
16
- return err instanceof BrowserClientError;
17
- }
18
15
  let cachedBin;
19
16
  function browserEntrypoint(bin) {
20
17
  if (!/\.(cmd|ps1)$/i.test(bin))
@@ -42,7 +42,7 @@ export class AntigravityCloudProvider {
42
42
  if (env[k])
43
43
  return env[k];
44
44
  }
45
- throw new Error(`Secrets bundle '${this.secretsBundle}' has no ${KEY_NAMES.join(' or ')}. Add one: agents secrets add ${this.secretsBundle} GEMINI_API_KEY`);
45
+ throw new Error(`Secrets bundle '${this.secretsBundle}' has no ${KEY_NAMES.join(' or ')}. Add one: secrets add ${this.secretsBundle} GEMINI_API_KEY`);
46
46
  }
47
47
  catch (err) {
48
48
  throw new Error(`Could not read Gemini API key from bundle '${this.secretsBundle}': ${err.message}`);
@@ -92,7 +92,7 @@ export function cursorApiError(action, status, text) {
92
92
  return new Error(`Cursor Cloud Agents requires a paid Cursor plan; this API key belongs to a plan without Cloud Agents access. ${message}`);
93
93
  }
94
94
  if (status === 401 || code === 'unauthorized' || code === 'api_key_not_found') {
95
- return new Error(`Cursor Cloud authentication failed (${status}${code ? ` ${code}` : ''}). Check CURSOR_API_KEY in the configured agents secrets bundle. ${message}`);
95
+ return new Error(`Cursor Cloud authentication failed (${status}${code ? ` ${code}` : ''}). Check CURSOR_API_KEY in the configured secrets bundle. ${message}`);
96
96
  }
97
97
  return new Error(`Cursor Cloud ${action} failed (${status}${code ? ` ${code}` : ''}): ${message}`);
98
98
  }
@@ -112,7 +112,7 @@ export class CursorCloudProvider {
112
112
  const { env } = await readAndResolveBundleEnv(this.secretsBundle, { caller: 'cloud:cursor', agentOnly: true });
113
113
  if (env[KEY_NAME])
114
114
  return env[KEY_NAME];
115
- throw new Error(`Secrets bundle '${this.secretsBundle}' has no ${KEY_NAME}. Add one: agents secrets add ${this.secretsBundle} ${KEY_NAME}`);
115
+ throw new Error(`Secrets bundle '${this.secretsBundle}' has no ${KEY_NAME}. Add one: secrets add ${this.secretsBundle} ${KEY_NAME}`);
116
116
  }
117
117
  catch (err) {
118
118
  throw new Error(`Could not read Cursor API key from bundle '${this.secretsBundle}': ${err.message}`);
@@ -120,7 +120,7 @@ export class CursorCloudProvider {
120
120
  }
121
121
  if (process.env[KEY_NAME])
122
122
  return process.env[KEY_NAME];
123
- throw new Error(`Cursor cloud needs an API key. Set cloud.providers.cursor.secretsBundle in ~/.agents/agents.yaml after running: agents secrets add cursor ${KEY_NAME}`);
123
+ throw new Error(`Cursor cloud needs an API key. Set cloud.providers.cursor.secretsBundle in ~/.agents/agents.yaml after running: secrets add cursor ${KEY_NAME}`);
124
124
  }
125
125
  capabilities() {
126
126
  const available = this.hasKeySource();
@@ -8,4 +8,8 @@ export declare function listTasks(filter?: {
8
8
  status?: CloudTaskStatus;
9
9
  limit?: number;
10
10
  }): CloudTask[];
11
- export declare function listActiveTasks(): CloudTask[];
11
+ export declare const CLOUD_TASK_STALE_MS: number;
12
+ export declare function listActiveTasks(opts?: {
13
+ includeStale?: boolean;
14
+ nowMs?: number;
15
+ }): CloudTask[];
@@ -90,9 +90,16 @@ export function listTasks(filter) {
90
90
  return rows.map(rowToTask);
91
91
  }
92
92
  const TERMINAL_STATUSES = ['completed', 'failed', 'cancelled'];
93
- export function listActiveTasks() {
94
- const placeholders = TERMINAL_STATUSES.map(() => '?').join(', ');
95
- const rows = db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${placeholders}) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES);
93
+ const WORKING_STATUSES = ['queued', 'allocating', 'running'];
94
+ export const CLOUD_TASK_STALE_MS = 24 * 60 * 60 * 1000;
95
+ export function listActiveTasks(opts = {}) {
96
+ const terminal = TERMINAL_STATUSES.map(() => '?').join(', ');
97
+ if (opts.includeStale) {
98
+ return db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${terminal}) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES).map(rowToTask);
99
+ }
100
+ const working = WORKING_STATUSES.map(() => '?').join(', ');
101
+ const cutoff = new Date((opts.nowMs ?? Date.now()) - CLOUD_TASK_STALE_MS).toISOString();
102
+ const rows = db().prepare(`SELECT * FROM tasks WHERE status NOT IN (${terminal}) AND (status NOT IN (${working}) OR updated_at >= ?) ORDER BY created_at DESC`).all(...TERMINAL_STATUSES, ...WORKING_STATUSES, cutoff);
96
103
  return rows.map(rowToTask);
97
104
  }
98
105
  function rowToTask(row) {
@@ -7,7 +7,7 @@ export function readCloudflareCreds(bundle = DEFAULT_CF_BUNDLE, override) {
7
7
  if (!bundleExists(bundle)) {
8
8
  throw new Error(`The '${bundle}' bundle does not exist. ` +
9
9
  `Pass credentials directly with --token <t> [--account <id>], or create it: ` +
10
- `agents secrets add ${bundle} CLOUDFLARE_API_TOKEN`);
10
+ `secrets add ${bundle} CLOUDFLARE_API_TOKEN`);
11
11
  }
12
12
  const { env } = readAndResolveBundleEnv(bundle, {
13
13
  caller: 'cloudflare',
@@ -26,7 +26,7 @@ export function readCloudflareCreds(bundle = DEFAULT_CF_BUNDLE, override) {
26
26
  throw new Error(`No Cloudflare API token in the '${bundle}' bundle ` +
27
27
  `(keys present: ${keys.length ? keys.join(', ') : 'none'}). ` +
28
28
  `Pass it directly with --token <t> [--account <id>], or add it: ` +
29
- `agents secrets add ${bundle} CLOUDFLARE_API_TOKEN`);
29
+ `secrets add ${bundle} CLOUDFLARE_API_TOKEN`);
30
30
  }
31
31
  return { apiToken, accountId };
32
32
  }
@@ -2,8 +2,8 @@
2
2
  * context.ts — everything agents-cli knows that the standalone `computer`
3
3
  * engine cannot work out for itself, serialized as one JSON object onto fd 3.
4
4
  *
5
- * This is the whole contract of the consumer half, and it is deliberately four
6
- * fields wide. The engine accepts exactly this shape:
5
+ * This is the whole contract of the consumer half, and it is deliberately
6
+ * small. The engine accepts exactly this shape:
7
7
  *
8
8
  * version `1`. The engine matches on it; a field added later must be
9
9
  * optional so an older engine keeps working.
@@ -11,10 +11,6 @@
11
11
  * rules in the agents permissions resource layer. The engine
12
12
  * would have to re-learn resource layering to compute this.
13
13
  * peers which executables the daemon accepts a connection from.
14
- * target the `--device <name>` target, resolved against the fleet:
15
- * devices registry, ssh identity, platform. The engine matches
16
- * its own `--device <alias>` against this instead of reading a
17
- * registry it does not have. Absent for a local invocation.
18
14
  * session who is acting — actor id and agent session — so an action
19
15
  * lands in the right session history.
20
16
  *
@@ -34,14 +30,6 @@
34
30
  * so the engine never re-enters agents-cli and there is exactly one direction of
35
31
  * dependency.
36
32
  */
37
- export interface ComputerTargetContext {
38
- alias: string;
39
- host: string;
40
- user: string;
41
- hostname: string;
42
- platform: string;
43
- sshArgs: string[];
44
- }
45
33
  interface ComputerSessionContext {
46
34
  sessionId?: string;
47
35
  launchId?: string;
@@ -55,14 +43,9 @@ interface ComputerContext {
55
43
  peers: {
56
44
  allow: string[];
57
45
  };
58
- target?: ComputerTargetContext;
59
46
  session: ComputerSessionContext;
60
47
  }
61
- interface BuildContextOptions {
62
- device?: string;
63
- host?: string;
48
+ export declare function buildComputerContext(opts?: {
64
49
  computerBin?: string;
65
- target?: ComputerTargetContext;
66
- }
67
- export declare function buildComputerContext(opts?: BuildContextOptions): Promise<ComputerContext>;
50
+ }): Promise<ComputerContext>;
68
51
  export {};
@@ -2,8 +2,8 @@
2
2
  * context.ts — everything agents-cli knows that the standalone `computer`
3
3
  * engine cannot work out for itself, serialized as one JSON object onto fd 3.
4
4
  *
5
- * This is the whole contract of the consumer half, and it is deliberately four
6
- * fields wide. The engine accepts exactly this shape:
5
+ * This is the whole contract of the consumer half, and it is deliberately
6
+ * small. The engine accepts exactly this shape:
7
7
  *
8
8
  * version `1`. The engine matches on it; a field added later must be
9
9
  * optional so an older engine keeps working.
@@ -11,10 +11,6 @@
11
11
  * rules in the agents permissions resource layer. The engine
12
12
  * would have to re-learn resource layering to compute this.
13
13
  * peers which executables the daemon accepts a connection from.
14
- * target the `--device <name>` target, resolved against the fleet:
15
- * devices registry, ssh identity, platform. The engine matches
16
- * its own `--device <alias>` against this instead of reading a
17
- * registry it does not have. Absent for a local invocation.
18
14
  * session who is acting — actor id and agent session — so an action
19
15
  * lands in the right session history.
20
16
  *
@@ -36,7 +32,6 @@
36
32
  */
37
33
  import { resolveActor } from '../actor.js';
38
34
  import { loadComputerAllowList, loadDefaultPeers } from './policy.js';
39
- import { resolveRemoteDevice } from '../ssh-tunnel.js';
40
35
  function agentSessionId(env = process.env) {
41
36
  return env.CODEX_THREAD_ID
42
37
  || env.CLAUDE_CODE_SESSION_ID
@@ -47,27 +42,11 @@ function agentSessionId(env = process.env) {
47
42
  || undefined;
48
43
  }
49
44
  export async function buildComputerContext(opts = {}) {
50
- let target = opts.target;
51
- if (!target && opts.device) {
52
- const resolved = await resolveRemoteDevice(opts.device, {
53
- expectPlatform: 'windows',
54
- forWhat: '`agents computer --device` drives the Windows computer-helper daemon, so it',
55
- });
56
- target = {
57
- alias: opts.device,
58
- host: resolved.target,
59
- user: resolved.user,
60
- hostname: resolved.host,
61
- platform: resolved.device.platform,
62
- sshArgs: resolved.identityArgs,
63
- };
64
- }
65
45
  return {
66
46
  version: 1,
67
- ...(!opts.device && !opts.host && !process.env.COMPUTER_HELPER_TCP && !process.env.COMPUTER_HELPER_VNC
47
+ ...(!process.env.COMPUTER_HELPER_TCP && !process.env.COMPUTER_HELPER_VNC
68
48
  ? { permissions: { allow: loadComputerAllowList() } } : {}),
69
49
  peers: { allow: loadDefaultPeers({ computerBin: opts.computerBin }) },
70
- ...(target ? { target } : {}),
71
50
  session: {
72
51
  sessionId: agentSessionId(),
73
52
  launchId: process.env.AGENT_LAUNCH_ID,
@@ -2,13 +2,3 @@ export declare function loadComputerAllowList(): string[];
2
2
  export declare function loadDefaultPeers(opts?: {
3
3
  computerBin?: string;
4
4
  }): string[];
5
- export declare function resolveTcpEndpoint(): {
6
- host: string;
7
- port: number;
8
- token: string | null;
9
- } | null;
10
- export declare function resolveVncEndpoint(): {
11
- host: string;
12
- port: number;
13
- password: string;
14
- } | null;
@@ -77,31 +77,3 @@ export function loadDefaultPeers(opts = {}) {
77
77
  }
78
78
  return [...out].sort();
79
79
  }
80
- function parseVncEndpoint(raw) {
81
- if (!raw || raw.length === 0)
82
- return null;
83
- const idx = raw.lastIndexOf(':');
84
- const host = idx >= 0 ? raw.slice(0, idx) : raw;
85
- const portStr = idx >= 0 ? raw.slice(idx + 1) : '5901';
86
- const port = Number(portStr);
87
- if (!Number.isInteger(port) || port <= 0 || port > 65535)
88
- return null;
89
- return { host: host || '127.0.0.1', port };
90
- }
91
- export function resolveTcpEndpoint() {
92
- const raw = process.env.COMPUTER_HELPER_TCP;
93
- if (!raw || raw.length === 0)
94
- return null;
95
- const [hostPart, portPart] = raw.includes(':') ? raw.split(':') : ['127.0.0.1', raw];
96
- const port = Number(portPart);
97
- if (!Number.isInteger(port) || port <= 0)
98
- return null;
99
- const token = process.env.COMPUTER_HELPER_TOKEN;
100
- return { host: hostPart || '127.0.0.1', port, token: token && token.length > 0 ? token : null };
101
- }
102
- export function resolveVncEndpoint() {
103
- const parsed = parseVncEndpoint(process.env.COMPUTER_HELPER_VNC);
104
- if (!parsed)
105
- return null;
106
- return { ...parsed, password: process.env.COMPUTER_HELPER_VNC_PASSWORD ?? '' };
107
- }
@@ -1,6 +1,4 @@
1
- import { type ComputerTargetContext } from './computer/context.js';
2
1
  export declare const COMPUTER_CONTEXT_FD = 3;
3
- export declare const COMPUTER_EVENTS_FD = 4;
4
2
  export declare class ComputerClientError extends Error {
5
3
  code: string;
6
4
  constructor(code: string, message: string);
@@ -12,47 +10,6 @@ export declare function invocation(bin: string): {
12
10
  command: string;
13
11
  prefix: string[];
14
12
  };
15
- export interface ComputerActionEvent {
16
- event?: string;
17
- command: string;
18
- invocationId?: string;
19
- pid?: number;
20
- targetPid?: number;
21
- bundle?: string;
22
- host?: string;
23
- task?: string;
24
- sessionId?: string;
25
- launchId?: string;
26
- actor?: string;
27
- [key: string]: unknown;
28
- }
29
- export declare function parseEventLines(buffer: string): {
30
- events: ComputerActionEvent[];
31
- rest: string;
32
- };
33
- interface RunComputerOptions {
34
- argv: string[];
35
- context: unknown;
36
- onEvent?: (event: ComputerActionEvent) => void;
37
- capture?: boolean;
38
- }
39
- interface RunComputerResult {
40
- exitCode: number;
41
- stdout: string;
42
- }
43
- export declare function runComputer(opts: RunComputerOptions): Promise<RunComputerResult>;
44
- export declare function withHostFlag(argv: string[], host?: string): string[];
45
- export declare function resolveDeviceHost(device: string): Promise<{
46
- host: string;
47
- target: ComputerTargetContext;
48
- }>;
49
- export interface ForwardToComputerOptions {
50
- argv: string[];
51
- device?: string;
52
- record?: boolean;
53
- capture?: boolean;
54
- }
55
- export declare function forwardToComputer(opts: ForwardToComputerOptions): Promise<RunComputerResult>;
56
13
  export declare function installComputerHelperMacLocal(): Promise<void>;
57
14
  export declare function activateComputerHelperMacLocal(): Promise<{
58
15
  trusted: boolean;
@@ -60,4 +17,3 @@ export declare function activateComputerHelperMacLocal(): Promise<{
60
17
  export declare function parseTrustFromStatusJson(stdout: string): boolean;
61
18
  export declare function probeComputerTrust(): Promise<boolean>;
62
19
  export declare function _resetComputerClientForTest(): void;
63
- export {};