@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
@@ -8,14 +8,11 @@ import { composeWin32CommandLine, needsWindowsShell } from '../platform/index.js
8
8
  import { getShimsDir } from '../state.js';
9
9
  import { sessionAgentSupportsResume, sessionRecoveryRunArgs } from './recovery.js';
10
10
  import { sessionOwnerDevice } from './resume-owner.js';
11
- export function buildCanonicalResumeCommand(sessionId) {
12
- return ['agents', 'sessions', 'resume', sessionId];
13
- }
14
11
  export async function resumeSessionInPlace(session) {
15
12
  const owner = sessionOwnerDevice(session);
16
13
  if (owner) {
17
14
  console.error(chalk.red(`Session ${session.shortId} belongs to ${owner} — it cannot resume on this machine.`));
18
- console.error(chalk.gray(` Resume it there: agents sessions resume ${session.id}`));
15
+ console.error(chalk.gray(` Resume it there: agents run auto --resume ${session.id}`));
19
16
  process.exitCode = 1;
20
17
  return;
21
18
  }
@@ -1,4 +1,2 @@
1
1
  import type { SessionMeta } from '@phnx-labs/sessions-cli/reader';
2
- export declare const RESUME_PINNED_ENV = "AGENTS_RESUME_PINNED";
3
- export declare function consumeResumePinned(): boolean;
4
2
  export declare function sessionOwnerDevice(session: Pick<SessionMeta, 'machine'>): string | undefined;
@@ -1,10 +1,4 @@
1
1
  import { isSelfHost } from '../devices/self-host.js';
2
- export const RESUME_PINNED_ENV = 'AGENTS_RESUME_PINNED';
3
- export function consumeResumePinned() {
4
- const pinned = process.env[RESUME_PINNED_ENV] === '1';
5
- delete process.env[RESUME_PINNED_ENV];
6
- return pinned;
7
- }
8
2
  export function sessionOwnerDevice(session) {
9
3
  const owner = session.machine?.trim();
10
4
  if (!owner)
@@ -2,7 +2,7 @@ import type { SessionAgentId, SessionMeta } from '@phnx-labs/sessions-cli/reader
2
2
  import { type ActiveSession } from './active.js';
3
3
  import { loadLocalActiveSessions } from './session-cache.js';
4
4
  import { gatherRemoteList, runOnPeer } from './remote/remote-list.js';
5
- export interface SessionFilterOptions {
5
+ interface SessionFilterOptions {
6
6
  agent?: string;
7
7
  version?: string;
8
8
  sessionVersion?: string;
@@ -42,8 +42,7 @@ export declare function resolveSessionQuery(pool: SessionMeta[], query: string,
42
42
  }): SessionQueryResolution;
43
43
  export declare function filterSessionsByQuery(sessions: SessionMeta[], query: string | undefined, scope?: SessionSearchScope): SessionMeta[];
44
44
  export declare function applyScopeFilters(sessions: SessionMeta[], scope: SessionSearchScope): SessionMeta[];
45
- export declare function scopedContentIndex(sessions: SessionMeta[], query: string, scope?: SessionSearchScope): Map<string, SessionMeta>;
46
- export interface FleetResolveDeps {
45
+ interface FleetResolveDeps {
47
46
  gatherRemoteList: typeof gatherRemoteList;
48
47
  runOnPeer: typeof runOnPeer;
49
48
  }
@@ -51,7 +50,7 @@ interface FleetHit {
51
50
  machine: string;
52
51
  session: SessionMeta;
53
52
  }
54
- export interface FleetSessionCandidate {
53
+ interface FleetSessionCandidate {
55
54
  id: string;
56
55
  hits: FleetHit[];
57
56
  }
@@ -78,7 +77,7 @@ export declare function metadataResolveOutcome(localMatches: SessionMeta[], remo
78
77
  }, selector: string): MetadataResolveOutcome;
79
78
  export declare function isLocallyDefinitiveMatch(session: SessionMeta, self: string): boolean;
80
79
  export declare function preferOwnerAttribution(localMatches: SessionMeta[], remoteSessions: SessionMeta[], self: string): SessionMeta[];
81
- export type LiveMetadataDeps = {
80
+ type LiveMetadataDeps = {
82
81
  loadActive?: typeof loadLocalActiveSessions;
83
82
  loadFleetActive?: () => ActiveSession[];
84
83
  };
@@ -250,7 +250,7 @@ export function applyScopeFilters(sessions, scope) {
250
250
  }
251
251
  return filtered;
252
252
  }
253
- export function scopedContentIndex(sessions, query, scope) {
253
+ function scopedContentIndex(sessions, query, scope) {
254
254
  const hits = searchContentIndex(sessions, query);
255
255
  if (!scope || (!scope.agent && !scope.project && !scope.routine))
256
256
  return hits;
@@ -316,7 +316,7 @@ function indexedRowsForSelector(selector, scope) {
316
316
  return applyScopeFilters(indexed, scope);
317
317
  }
318
318
  export function metadataResolveForwardedArgs(selector, scope) {
319
- const args = ['sessions', '--resolve-safe-v1', selector, '--json', '--all', '--local'];
319
+ const args = ['ps', 'resolve', selector, '--json', '--local'];
320
320
  if (scope.agent)
321
321
  args.push('--agent', scope.agent);
322
322
  if (scope.project)
@@ -1,26 +1 @@
1
- /**
2
- * R2 credential resolution + this machine's stable identity. Two consumers read
3
- * these fields: `agents sessions export --encrypt` / `import` use only the shared
4
- * `R2_SYNC_ENC_KEY` transcript key (`resolveSyncEncKey`), falling back to an
5
- * ephemeral key when no bundle is configured; and the off-box backup target
6
- * (`agents sessions export --to-r2` / `import --from-r2`, RUSH-2437) uses the full
7
- * credential set (account/bucket/access keys/endpoint) to talk to R2 through the
8
- * network client in `./r2.ts`. The `--to-r2`/`--from-r2` paths gate on
9
- * `isSyncConfigured()` and fail loud when the bundle is absent (no silent
10
- * fallback). This is a pure on-demand backup target, NOT the retired R2/CRDT
11
- * background sync. Credentials come from the `r2.backups` secrets bundle (OS
12
- * keychain on macOS, libsecret on Linux) — never from env or disk.
13
- */
14
- export declare const SYNC_BUNDLE = "r2.backups";
15
- export interface R2Config {
16
- accountId: string;
17
- bucket: string;
18
- accessKeyId: string;
19
- secretAccessKey: string;
20
- endpoint: string;
21
- syncEncKey?: string;
22
- }
23
- export declare function clearR2ConfigCache(): void;
24
- export declare function loadR2Config(): R2Config;
25
- export declare function isSyncConfigured(_now?: number): boolean;
26
1
  export { machineId, normalizeHost } from '../../machine-id.js';
@@ -1,63 +1 @@
1
- /**
2
- * R2 credential resolution + this machine's stable identity. Two consumers read
3
- * these fields: `agents sessions export --encrypt` / `import` use only the shared
4
- * `R2_SYNC_ENC_KEY` transcript key (`resolveSyncEncKey`), falling back to an
5
- * ephemeral key when no bundle is configured; and the off-box backup target
6
- * (`agents sessions export --to-r2` / `import --from-r2`, RUSH-2437) uses the full
7
- * credential set (account/bucket/access keys/endpoint) to talk to R2 through the
8
- * network client in `./r2.ts`. The `--to-r2`/`--from-r2` paths gate on
9
- * `isSyncConfigured()` and fail loud when the bundle is absent (no silent
10
- * fallback). This is a pure on-demand backup target, NOT the retired R2/CRDT
11
- * background sync. Credentials come from the `r2.backups` secrets bundle (OS
12
- * keychain on macOS, libsecret on Linux) — never from env or disk.
13
- */
14
- import { readAndResolveBundleEnvSync } from '../../secrets-client.js';
15
- export const SYNC_BUNDLE = 'r2.backups';
16
- function resolveR2Config() {
17
- const { env } = readAndResolveBundleEnvSync(SYNC_BUNDLE, { caller: 'session-transport', agentOnly: true });
18
- const accountId = env.R2_ACCOUNT_ID?.trim();
19
- const bucket = env.R2_BUCKET_NAME?.trim();
20
- const accessKeyId = env.R2_ACCESS_KEY_ID?.trim();
21
- const secretAccessKey = env.R2_SECRET_ACCESS_KEY?.trim();
22
- const syncEncKey = env.R2_SYNC_ENC_KEY?.trim() || undefined;
23
- const missing = [
24
- !accountId && 'R2_ACCOUNT_ID',
25
- !bucket && 'R2_BUCKET_NAME',
26
- !accessKeyId && 'R2_ACCESS_KEY_ID',
27
- !secretAccessKey && 'R2_SECRET_ACCESS_KEY',
28
- ].filter(Boolean);
29
- if (missing.length > 0) {
30
- throw new Error(`Session R2 transport: bundle '${SYNC_BUNDLE}' is missing ${missing.join(', ')}. ` +
31
- `Add them with: agents secrets add ${SYNC_BUNDLE} <KEY>`);
32
- }
33
- return {
34
- accountId: accountId,
35
- bucket: bucket,
36
- accessKeyId: accessKeyId,
37
- secretAccessKey: secretAccessKey,
38
- endpoint: env.R2_ENDPOINT?.trim() || `https://${accountId}.r2.cloudflarestorage.com`,
39
- syncEncKey,
40
- };
41
- }
42
- let cachedConfig = null;
43
- export function clearR2ConfigCache() {
44
- cachedConfig = null;
45
- }
46
- export function loadR2Config() {
47
- if (cachedConfig)
48
- return cachedConfig;
49
- cachedConfig = resolveR2Config();
50
- return cachedConfig;
51
- }
52
- export function isSyncConfigured(_now = Date.now()) {
53
- if (cachedConfig)
54
- return true;
55
- try {
56
- loadR2Config();
57
- return true;
58
- }
59
- catch {
60
- return false;
61
- }
62
- }
63
1
  export { machineId, normalizeHost } from '../../machine-id.js';
@@ -1,4 +1,3 @@
1
1
  export declare const DEFAULT_SESSIONS_DOMAIN = "sessions.agents-cli.sh";
2
2
  export declare const DEFAULT_SESSIONS_WORKER_NAME = "agents-sessions";
3
3
  export declare const DEFAULT_SESSIONS_BUCKET_NAME = "agents-sessions";
4
- export declare function managedSessionsBaseUrl(): string;
@@ -1,6 +1,3 @@
1
1
  export const DEFAULT_SESSIONS_DOMAIN = 'sessions.agents-cli.sh';
2
2
  export const DEFAULT_SESSIONS_WORKER_NAME = 'agents-sessions';
3
3
  export const DEFAULT_SESSIONS_BUCKET_NAME = 'agents-sessions';
4
- export function managedSessionsBaseUrl() {
5
- return `https://${DEFAULT_SESSIONS_DOMAIN}`;
6
- }
@@ -1,5 +1,5 @@
1
1
  export function renderSessionsWorkerScript() {
2
- return `// GENERATED by agents-cli agents sessions — do not edit; edit
2
+ return `// GENERATED by agents setup session-backup — do not edit; edit
3
3
  // src/lib/session/sync/worker-template.ts and re-provision.
4
4
  export const hooks = {
5
5
  verifyPhoenixToken: defaultVerifyPhoenixToken,
@@ -8,20 +8,4 @@ export declare function invocation(bin: string): {
8
8
  prefix: string[];
9
9
  };
10
10
  export declare function runSessions(argv: string[]): Promise<number>;
11
- export declare function usesFilterFlags(args: string[]): boolean;
12
- export declare function usesHostFlag(args: string[]): boolean;
13
- export declare function sessionsBinSupports(bin: string, minVersion: string): boolean;
14
- export declare function sessionsBinSupportsFilters(bin: string): boolean;
15
- export declare function sessionsBinSupportsHost(bin: string): boolean;
16
- export declare function isReadQuery(args: string[], opts?: {
17
- filters?: boolean;
18
- host?: boolean;
19
- }): boolean;
20
- export declare function planDeviceHostRead(args: string[], opts?: {
21
- filters?: boolean;
22
- }): {
23
- device: string;
24
- readArgs: string[];
25
- } | null;
26
11
  export declare function _resetSessionsClientForTest(): void;
27
- export declare const SESSIONS_INSTALL_HINT = "npm i -g @phnx-labs/sessions-cli";
@@ -1,13 +1,9 @@
1
- import { spawn, spawnSync } from 'node:child_process';
1
+ import { spawn } from 'node:child_process';
2
2
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
3
3
  import { createRequire } from 'node:module';
4
4
  import path from 'node:path';
5
5
  import { findInPath } from './agent-spec/agents.js';
6
- import { compareVersions } from './agent-spec/primitives.js';
7
- import { stripRoutingFlags } from './hosts/remote-cmd.js';
8
6
  const INSTALL_HINT = 'npm i -g @phnx-labs/sessions-cli';
9
- const SESSIONS_FILTERS_MIN_VERSION = '0.2.0';
10
- const SESSIONS_HOST_MIN_VERSION = '0.2.1';
11
7
  export class SessionsClientError extends Error {
12
8
  code;
13
9
  constructor(code, message) {
@@ -40,7 +36,6 @@ function dependencySessionsBin() {
40
36
  }
41
37
  return realpathSync(abs);
42
38
  }
43
- // Skip the legacy agents shim to avoid recursive sessions passthrough.
44
39
  export function resolveSessionsBin() {
45
40
  if (cachedBin)
46
41
  return cachedBin;
@@ -80,187 +75,6 @@ export function runSessions(argv) {
80
75
  });
81
76
  });
82
77
  }
83
- const READ_FLAGS = new Set([
84
- '--json',
85
- '--local',
86
- '--no-interactive',
87
- ]);
88
- const FILTER_BOOL_FLAGS = new Set([
89
- '--claude',
90
- '--codex',
91
- '--kimi',
92
- '--antigravity',
93
- '--grok',
94
- '--opencode',
95
- ]);
96
- const FILTER_VALUE_FLAGS = new Set([
97
- '--project',
98
- '--since',
99
- '--until',
100
- '--sort',
101
- ]);
102
- export function usesFilterFlags(args) {
103
- return args.some((arg) => {
104
- if (arg === '-p' || arg === '-a')
105
- return true;
106
- if (FILTER_BOOL_FLAGS.has(arg))
107
- return true;
108
- for (const vf of FILTER_VALUE_FLAGS) {
109
- if (arg === vf || arg.startsWith(`${vf}=`))
110
- return true;
111
- }
112
- return false;
113
- });
114
- }
115
- export function usesHostFlag(args) {
116
- return args.some((arg) => arg === '--host' || arg.startsWith('--host='));
117
- }
118
- let cachedProbedVersion;
119
- function probeSessionsVersion(bin) {
120
- if (cachedProbedVersion !== undefined)
121
- return cachedProbedVersion;
122
- const { command, prefix } = invocation(bin);
123
- const res = spawnSync(command, [...prefix, '--version'], { encoding: 'utf8', timeout: 3000 });
124
- const version = (res.stdout ?? '').trim();
125
- cachedProbedVersion = !res.error && /^\d+\.\d+\.\d+/.test(version) ? version : null;
126
- return cachedProbedVersion;
127
- }
128
- // Failed or old version probes stay in the in-repo engine because an old CLI may treat unknown flags as FTS terms.
129
- export function sessionsBinSupports(bin, minVersion) {
130
- const version = probeSessionsVersion(bin);
131
- return version !== null && compareVersions(version, minVersion) >= 0;
132
- }
133
- export function sessionsBinSupportsFilters(bin) {
134
- return sessionsBinSupports(bin, SESSIONS_FILTERS_MIN_VERSION);
135
- }
136
- export function sessionsBinSupportsHost(bin) {
137
- return sessionsBinSupports(bin, SESSIONS_HOST_MIN_VERSION);
138
- }
139
- const ENGINE_VERBS = new Set([
140
- 'resume',
141
- 'detach',
142
- 'stop',
143
- 'inject',
144
- 'fork',
145
- 'backfill',
146
- 'migrate',
147
- 'share',
148
- 'export',
149
- 'import',
150
- 'optimize',
151
- 'trace',
152
- 'insights',
153
- 'bookmark',
154
- 'tail',
155
- 'watch',
156
- 'preview',
157
- 'focus',
158
- 'render',
159
- 'stats',
160
- 'migrations',
161
- 'export',
162
- ]);
163
- export function isReadQuery(args, opts = {}) {
164
- if (args.length === 0)
165
- return false;
166
- const valueFlags = new Set(['--limit', '--agent']);
167
- const boolFlags = new Set(READ_FLAGS);
168
- if (opts.filters) {
169
- for (const vf of FILTER_VALUE_FLAGS)
170
- valueFlags.add(vf);
171
- for (const bf of FILTER_BOOL_FLAGS)
172
- boolFlags.add(bf);
173
- }
174
- if (opts.host)
175
- valueFlags.add('--host');
176
- for (let i = 0; i < args.length; i++) {
177
- const arg = args[i];
178
- if (opts.filters && (arg === '-a' || arg === '-p')) {
179
- i += 1;
180
- continue;
181
- }
182
- let matchedValue = false;
183
- for (const vf of valueFlags) {
184
- if (arg === vf) {
185
- i += 1;
186
- matchedValue = true;
187
- break;
188
- }
189
- if (arg.startsWith(`${vf}=`)) {
190
- matchedValue = true;
191
- break;
192
- }
193
- }
194
- if (matchedValue)
195
- continue;
196
- if (arg.startsWith('-')) {
197
- if (!boolFlags.has(arg))
198
- return false;
199
- continue;
200
- }
201
- if (ENGINE_VERBS.has(arg))
202
- return false;
203
- }
204
- return true;
205
- }
206
- function scanDeviceFlag(args) {
207
- let count = 0;
208
- let value;
209
- let valueEndIndex;
210
- for (let i = 0; i < args.length; i++) {
211
- const a = args[i];
212
- let matched = false;
213
- let v;
214
- let endIdx = i;
215
- if (a === '--device' || a === '-D') {
216
- matched = true;
217
- v = args[i + 1];
218
- endIdx = i + 1;
219
- }
220
- else if (a.startsWith('--device=')) {
221
- matched = true;
222
- v = a.slice('--device='.length);
223
- }
224
- else if (a.startsWith('-D=')) {
225
- matched = true;
226
- v = a.slice(3);
227
- }
228
- else if (/^-D.+/.test(a)) {
229
- matched = true;
230
- v = a.slice(2);
231
- }
232
- if (matched) {
233
- count += 1;
234
- if (count === 1) {
235
- value = v;
236
- valueEndIndex = endIdx;
237
- }
238
- }
239
- }
240
- return { count, value, valueEndIndex };
241
- }
242
- // Collapse --device to --host only for one unambiguous read; multi/fleet/lifecycle queries remain on in-repo fan-out.
243
- export function planDeviceHostRead(args, opts = {}) {
244
- const { count, value, valueEndIndex } = scanDeviceFlag(args);
245
- if (count !== 1)
246
- return null;
247
- if (value === undefined || value === '' || value.startsWith('-'))
248
- return null;
249
- if (usesHostFlag(args))
250
- return null;
251
- const lower = value.toLowerCase();
252
- if (lower === 'all' || lower === 'fleet')
253
- return null;
254
- const next = valueEndIndex !== undefined ? args[valueEndIndex + 1] : undefined;
255
- if (next !== undefined && !next.startsWith('-'))
256
- return null;
257
- const readArgs = stripRoutingFlags(args, [{ long: 'device', short: 'D', takesValue: true }]);
258
- if (!isReadQuery(readArgs, { filters: opts.filters }))
259
- return null;
260
- return { device: value, readArgs };
261
- }
262
78
  export function _resetSessionsClientForTest() {
263
79
  cachedBin = undefined;
264
- cachedProbedVersion = undefined;
265
80
  }
266
- export const SESSIONS_INSTALL_HINT = INSTALL_HINT;
@@ -56,7 +56,12 @@ export function formatNoHealthyDeviceError(pool, signals, agent) {
56
56
  const excluded = pool.map((key) => {
57
57
  const signal = signals.get(key);
58
58
  let reason;
59
- if (signal?.reachable === true) {
59
+ if (signal?.reachable === true && signal.headroom !== 'loaded' && signal.installed === undefined) {
60
+ if (signal.timedOut)
61
+ timedOutCount++;
62
+ reason = signal.timedOut ? 'readiness probe timed out' : 'readiness probe did not answer';
63
+ }
64
+ else if (signal?.reachable === true) {
60
65
  reason = signal.headroom === 'loaded'
61
66
  ? 'overloaded'
62
67
  : signal.installed !== true || signal.signedIn !== true
@@ -1,3 +1,5 @@
1
1
  export declare const KNOWN_TOP_LEVEL_COMMANDS: ReadonlySet<string>;
2
2
  export declare const RETIRED_TOP_LEVEL_COMMANDS: ReadonlySet<string>;
3
+ export declare const REMOVED_TOOL_GROUPS: ReadonlySet<string>;
4
+ export declare function removedToolGroupMessage(group: string, rest: readonly string[]): string | undefined;
3
5
  export declare function isKnownTopLevelCommand(name: string): boolean;
@@ -4,10 +4,10 @@ const LOADED_COMMAND_NAMES = [
4
4
  'remove', 'rm', 'purge', 'update', 'prune', 'import',
5
5
  'routines', 'projects', 'run', '_callback', 'open', 'fork', 'config',
6
6
  'models', 'doctor',
7
- 'harness', 'harnesses', 'secrets', 'menubar', 'sync',
7
+ 'harness', 'harnesses', 'menubar', 'sync',
8
8
  'refresh-rules', 'factory', 'insights', 'trace',
9
- 'watchdog', 'browser', 'computer', 'events',
10
- 'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade', 'sessions',
9
+ 'watchdog', 'events',
10
+ 'ssh', 'devices', 'fleet', 'repos', 'repo', 'setup', 'uninstall', 'upgrade',
11
11
  'teams', 'cloud', 'ps', 'send', 'feed',
12
12
  'daemon', 'recordings',
13
13
  ];
@@ -70,6 +70,39 @@ export const RETIRED_TOP_LEVEL_COMMANDS = new Set([
70
70
  'logs',
71
71
  'trash',
72
72
  ]);
73
+ const STANDALONE_TOOL_GROUPS = ['browser', 'computer', 'secrets', 'sessions'];
74
+ const MOVED_SESSIONS_VERBS = {
75
+ resume: 'agents run auto --resume <id>',
76
+ focus: 'agents ps focus',
77
+ stop: 'agents ps stop',
78
+ detach: 'agents ps detach',
79
+ migrate: 'agents ps migrate',
80
+ migrations: 'agents ps migrations',
81
+ preview: 'agents ps preview',
82
+ watch: 'agents ps watch --json',
83
+ inject: 'agents send --channel session --to <id> --text <text>',
84
+ fork: 'agents fork',
85
+ backfill: 'agents daemon index backfill',
86
+ optimize: 'agents daemon index optimize',
87
+ stats: 'agents insights resources',
88
+ insights: 'agents insights',
89
+ 'backup-setup': 'agents setup session-backup',
90
+ };
91
+ export const REMOVED_TOOL_GROUPS = new Set(STANDALONE_TOOL_GROUPS);
92
+ export function removedToolGroupMessage(group, rest) {
93
+ if (!REMOVED_TOOL_GROUPS.has(group))
94
+ return undefined;
95
+ const verb = group === 'sessions' ? rest.find((arg) => Object.hasOwn(MOVED_SESSIONS_VERBS, arg)) : undefined;
96
+ const moved = verb === undefined ? undefined : MOVED_SESSIONS_VERBS[verb];
97
+ if (moved)
98
+ return `error: 'agents sessions ${verb}' was removed; use '${moved}'.`;
99
+ if (group === 'sessions' && rest.some((arg) => arg === '--active' || arg === '--roots')) {
100
+ return rest.includes('--roots')
101
+ ? `error: 'agents sessions --roots' was removed; use 'agents daemon index roots'.`
102
+ : `error: 'agents sessions --active' was removed; use 'agents ps'.`;
103
+ }
104
+ return `error: 'agents ${group}' was removed; use the standalone '${group}' CLI (${group} --help).`;
105
+ }
73
106
  export function isKnownTopLevelCommand(name) {
74
107
  return KNOWN_TOP_LEVEL_COMMANDS.has(name);
75
108
  }
@@ -1,3 +1,2 @@
1
1
  import type { Command } from 'commander';
2
2
  export declare function configureRootCommand(program: Command, name: string, version: string): Command;
3
- export declare function normalizeResumeDeviceArgs(args: string[]): string[];
@@ -8,24 +8,3 @@ export function configureRootCommand(program, name, version) {
8
8
  .helpOption('-h, --help', 'Show help')
9
9
  .addHelpCommand(false);
10
10
  }
11
- export function normalizeResumeDeviceArgs(args) {
12
- if (args[0] !== 'sessions' || args[1] !== 'resume')
13
- return args;
14
- let options = true;
15
- return args.map((arg, index) => {
16
- if (index < 2 || !options)
17
- return arg;
18
- if (arg === '--') {
19
- options = false;
20
- return arg;
21
- }
22
- if (arg === '--device' || arg === '--devices' || arg === '-D')
23
- return '--resume-device';
24
- if (arg.startsWith('--device=') || arg.startsWith('--devices=')) {
25
- return `--resume-device=${arg.slice(arg.indexOf('=') + 1)}`;
26
- }
27
- if (arg.startsWith('-D'))
28
- return `--resume-device=${arg.slice(arg[2] === '=' ? 3 : 2)}`;
29
- return arg;
30
- });
31
- }
@@ -59,7 +59,7 @@ export async function runUmbrellaSync(args) {
59
59
  result.secrets = {
60
60
  pulled: 0,
61
61
  skipped: true,
62
- reason: `no passphrase — set ${SYNC_PASSPHRASE_ENV} or run \`agents secrets vault unlock\` (#366)`,
62
+ reason: `no passphrase — set ${SYNC_PASSPHRASE_ENV} or run \`secrets vault unlock\` (#366)`,
63
63
  errors: [],
64
64
  };
65
65
  log(`secrets: skipped (no passphrase — set ${SYNC_PASSPHRASE_ENV})`);
@@ -9,6 +9,8 @@ interface ReadinessInfo {
9
9
  installed: boolean | undefined;
10
10
  signedIn: boolean | undefined;
11
11
  pickerEligible: boolean | undefined;
12
+ reason?: string;
13
+ timedOut?: boolean;
12
14
  }
13
15
  export declare function mergePlacementSignal(stats: DeviceStats | undefined, readiness: ReadinessInfo | undefined): DevicePlacementSignal;
14
16
  export declare function probePoolSignals(pool: string[], agent?: AgentType, opts?: {
@@ -3,6 +3,7 @@ import { buildFleetStatePayload } from '../accounting/usage-sync.js';
3
3
  import { probeFleetStats, headroom } from '../devices/health.js';
4
4
  import { loadDevicesSync } from '../devices/registry.js';
5
5
  import { buildSshInvocation, writeAskpassShim } from '../devices/connect.js';
6
+ import { resolveDeviceProfile } from '../devices/resolve-profile.js';
6
7
  import { buildReadyProbeCommand, parseReadyProbe, viewAgentAccountEligibility, viewHasAgent, } from '../hosts/ready.js';
7
8
  import { collectRunCandidates, isSignInRecoverable, readinessFromCandidate, } from '../accounting/rotate.js';
8
9
  import { localMachineId } from '../origin-machine.js';
@@ -23,7 +24,7 @@ function probeRemoteReadiness(device, agent, usagePayload) {
23
24
  let env;
24
25
  try {
25
26
  const shim = writeAskpassShim();
26
- const cmd = buildReadyProbeCommand(device.shell === 'powershell' ? 'windows' : undefined, { ingestUsage: true });
27
+ const cmd = buildReadyProbeCommand(resolveDeviceProfile(device).shell === 'powershell' ? 'windows' : undefined, { ingestUsage: true });
27
28
  ({ args, env } = buildSshInvocation(device, [cmd], shim, {}, { agentOnly: true }));
28
29
  }
29
30
  catch {
@@ -45,7 +46,8 @@ function probeRemoteReadiness(device, agent, usagePayload) {
45
46
  clearTimeout(killTimer);
46
47
  resolve(value);
47
48
  };
48
- const timer = setTimeout(() => child.kill('SIGTERM'), READY_PROBE_TIMEOUT_MS);
49
+ let timedOut = false;
50
+ const timer = setTimeout(() => { timedOut = true; child.kill('SIGTERM'); }, READY_PROBE_TIMEOUT_MS);
49
51
  const killTimer = setTimeout(() => { if (!settled)
50
52
  child.kill('SIGKILL'); }, READY_PROBE_TIMEOUT_MS + 250);
51
53
  killTimer.unref?.();
@@ -54,6 +56,8 @@ function probeRemoteReadiness(device, agent, usagePayload) {
54
56
  child.stderr.resume();
55
57
  child.on('error', () => finish(unknown));
56
58
  child.on('close', (code) => {
59
+ if (timedOut)
60
+ return finish({ ...unknown, timedOut: true });
57
61
  if (code !== 0 || !stdout)
58
62
  return finish(unknown);
59
63
  const probe = parseReadyProbe(stdout);
@@ -75,13 +79,14 @@ export function mergePlacementSignal(stats, readiness) {
75
79
  const reachable = readiness?.answered === true ? true : stats?.reachable;
76
80
  return {
77
81
  reachable,
78
- timedOut: reachable === true ? undefined : stats?.timedOut,
82
+ timedOut: reachable === true ? readiness?.timedOut : stats?.timedOut,
79
83
  headroom: stats ? headroom(stats) : undefined,
80
84
  loadPercent: stats?.loadPercent,
81
85
  memPercent: stats?.memPercent,
82
86
  installed: readiness?.installed,
83
87
  signedIn: readiness?.signedIn,
84
88
  pickerEligible: readiness?.pickerEligible,
89
+ reason: readiness?.reason,
85
90
  };
86
91
  }
87
92
  export async function probePoolSignals(pool, agent, opts = {}) {
@@ -1,12 +1,14 @@
1
1
  import type { Backend, EngineContext, LaunchRequest, LaunchResult, LaunchSpec } from './types.js';
2
2
  import { type Packing } from './policy.js';
3
3
  import { type HostResolver } from './transport.js';
4
+ import { type SpawnAck } from './backends/vscodium-agent.js';
4
5
  export declare function specsForRequest(req: LaunchRequest, nonce?: string): LaunchSpec[];
5
6
  export interface OpenOptions {
6
7
  resolveHost?: HostResolver;
7
8
  ctx?: EngineContext;
8
9
  ackTimeoutMs?: number;
9
10
  }
11
+ export declare function ackFailure(ack: SpawnAck | undefined, req: LaunchRequest, timeoutMs: number): string | undefined;
10
12
  export declare function openSurface(req: LaunchRequest, opts?: OpenOptions): Promise<LaunchResult>;
11
13
  export interface SurfaceItem {
12
14
  cwd: string;
@@ -31,9 +31,11 @@ function ackReader(nonce) {
31
31
  }
32
32
  };
33
33
  }
34
- function ackFailure(ack, req, timeoutMs) {
35
- if (!ack)
36
- return `VSCodium didn't confirm a tab within ${Math.round(timeoutMs / 1000)}s`;
34
+ export function ackFailure(ack, req, timeoutMs) {
35
+ if (!ack) {
36
+ return `VSCodium did not confirm the tab within ${Math.round(timeoutMs / 1000)}s; ` +
37
+ `if VSCodium is asking "Allow 'Agents' extension to open this URI?", approve it and try again`;
38
+ }
37
39
  if (!ackLandedIn(ack, req.project)) {
38
40
  const where = ack.workspaceName ?? (ack.windowFolders.join(', ') || 'an unknown window');
39
41
  const why = ack.reason ? ` (${ack.reason})` : '';
@@ -10,5 +10,5 @@ export { backendCarriesPaste, injectIntoTerminal, tmuxSendKeysArgv, tmuxInjectSp
10
10
  export { resolveInjectTarget, resolveInjectTargetForSession, type InjectResolution, type InjectRail, type ResolveOptions, } from './resolve.js';
11
11
  export { iLoginShell } from './shell.js';
12
12
  export { shellQuote } from './quote.js';
13
- export { parseTerminalFlag, stripTerminalFlag, buildRunCommand, openRunInTerminal, toHostSamples, TERMINAL_FLAG_BACKENDS } from './run-surface.js';
13
+ export { parseTerminalFlag, stripTerminalFlag, buildRunCommand, openRunInTerminal, toHostSamples, liveHostSamples, TERMINAL_FLAG_BACKENDS } from './run-surface.js';
14
14
  export type { OpenRunSurfaceParams, OpenRunSurfaceResult } from './run-surface.js';