@phnx-labs/agents-cli 1.23.17 → 1.23.18

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 (204) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +140 -165
  3. package/dist/bootstrap.js +10 -16
  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 +1 -1
  10. package/dist/commands/config.js +0 -4
  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 +5 -5
  15. package/dist/commands/exec.js +10 -22
  16. package/dist/commands/feed.d.ts +1 -1
  17. package/dist/commands/feed.js +3 -3
  18. package/dist/commands/focus.d.ts +1 -4
  19. package/dist/commands/focus.js +12 -13
  20. package/dist/commands/fork.d.ts +0 -1
  21. package/dist/commands/fork.js +7 -16
  22. package/dist/commands/harness-wizard.js +1 -1
  23. package/dist/commands/harness.js +1 -1
  24. package/dist/commands/insights.d.ts +0 -1
  25. package/dist/commands/insights.js +3 -7
  26. package/dist/commands/open.js +1 -1
  27. package/dist/commands/output.js +1 -1
  28. package/dist/commands/profiles.d.ts +1 -1
  29. package/dist/commands/profiles.js +2 -2
  30. package/dist/commands/projects.js +1 -1
  31. package/dist/commands/prune.js +1 -1
  32. package/dist/commands/ps.d.ts +0 -1
  33. package/dist/commands/ps.js +63 -18
  34. package/dist/commands/routines.js +1 -1
  35. package/dist/commands/send.js +1 -1
  36. package/dist/commands/sessions-backfill.d.ts +0 -1
  37. package/dist/commands/sessions-backfill.js +3 -6
  38. package/dist/commands/sessions-browser.d.ts +0 -10
  39. package/dist/commands/sessions-browser.js +19 -25
  40. package/dist/commands/sessions-migrate.d.ts +2 -2
  41. package/dist/commands/sessions-migrate.js +13 -13
  42. package/dist/commands/sessions-optimize.d.ts +0 -1
  43. package/dist/commands/sessions-optimize.js +0 -3
  44. package/dist/commands/sessions-picker.js +11 -11
  45. package/dist/commands/sessions-resume.d.ts +16 -15
  46. package/dist/commands/sessions-resume.js +101 -269
  47. package/dist/commands/sessions-stats.d.ts +0 -1
  48. package/dist/commands/sessions-stats.js +5 -8
  49. package/dist/commands/sessions-stop.d.ts +1 -1
  50. package/dist/commands/sessions-stop.js +6 -6
  51. package/dist/commands/sessions-trace.d.ts +1 -1
  52. package/dist/commands/sessions-trace.js +40 -17
  53. package/dist/commands/sessions-watch.js +2 -2
  54. package/dist/commands/sessions.test-fixture.d.ts +1 -0
  55. package/dist/commands/sessions.test-fixture.js +14 -0
  56. package/dist/commands/setup-browser.js +4 -4
  57. package/dist/commands/setup-computer.js +4 -4
  58. package/dist/commands/setup-fleet.js +1 -1
  59. package/dist/commands/setup-preferences.js +1 -1
  60. package/dist/commands/{sessions-backup-setup.d.ts → setup-session-backup.d.ts} +2 -2
  61. package/dist/commands/{sessions-backup-setup.js → setup-session-backup.js} +8 -8
  62. package/dist/commands/setup.js +3 -1
  63. package/dist/commands/ssh.js +4 -5
  64. package/dist/commands/sync.js +1 -1
  65. package/dist/commands/teams.js +2 -2
  66. package/dist/commands/utils.d.ts +0 -1
  67. package/dist/commands/utils.js +0 -10
  68. package/dist/index.js +0 -71
  69. package/dist/lib/analytics/mix-commands.js +1 -1
  70. package/dist/lib/auth-mint.js +2 -2
  71. package/dist/lib/browser-client.d.ts +0 -1
  72. package/dist/lib/browser-client.js +0 -3
  73. package/dist/lib/cloud/antigravity.js +1 -1
  74. package/dist/lib/cloud/cursor.js +3 -3
  75. package/dist/lib/cloudflare/creds.js +2 -2
  76. package/dist/lib/computer/context.d.ts +4 -21
  77. package/dist/lib/computer/context.js +3 -24
  78. package/dist/lib/computer/policy.d.ts +0 -10
  79. package/dist/lib/computer/policy.js +0 -28
  80. package/dist/lib/computer-client.d.ts +0 -44
  81. package/dist/lib/computer-client.js +17 -121
  82. package/dist/lib/config-keys.d.ts +1 -1
  83. package/dist/lib/config-keys.js +0 -3
  84. package/dist/lib/crabbox/cli.js +1 -1
  85. package/dist/lib/device-config.js +5 -28
  86. package/dist/lib/devices/connect.d.ts +1 -1
  87. package/dist/lib/devices/connect.js +3 -6
  88. package/dist/lib/devices/doctor-findings.d.ts +2 -1
  89. package/dist/lib/devices/doctor-findings.js +4 -4
  90. package/dist/lib/exec.js +1 -1
  91. package/dist/lib/feed/activity.js +1 -1
  92. package/dist/lib/fleet/apply.js +1 -1
  93. package/dist/lib/help.d.ts +0 -1
  94. package/dist/lib/help.js +2 -10
  95. package/dist/lib/hosts/option.js +1 -1
  96. package/dist/lib/hosts/passthrough.d.ts +0 -1
  97. package/dist/lib/hosts/passthrough.js +2 -26
  98. package/dist/lib/hosts/reconnect.js +5 -5
  99. package/dist/lib/hosts/remote-cmd.d.ts +3 -5
  100. package/dist/lib/hosts/remote-cmd.js +15 -20
  101. package/dist/lib/hosts/remote-session-id.js +1 -1
  102. package/dist/lib/installations/active-check.js +1 -1
  103. package/dist/lib/installations/migrate.js +4 -15
  104. package/dist/lib/installations/versions.js +1 -1
  105. package/dist/lib/launch-log.js +3 -6
  106. package/dist/lib/owner-notify.d.ts +1 -6
  107. package/dist/lib/owner-notify.js +0 -2
  108. package/dist/lib/paths.d.ts +0 -1
  109. package/dist/lib/paths.js +0 -8
  110. package/dist/lib/permissions.js +1 -1
  111. package/dist/lib/redact.d.ts +0 -1
  112. package/dist/lib/redact.js +0 -4
  113. package/dist/lib/remote-agents-json.d.ts +3 -1
  114. package/dist/lib/remote-agents-json.js +8 -6
  115. package/dist/lib/reserved-stores.js +1 -1
  116. package/dist/lib/scheduling/routines.d.ts +0 -1
  117. package/dist/lib/scheduling/routines.js +1 -1
  118. package/dist/lib/session/active.d.ts +1 -1
  119. package/dist/lib/session/db.js +3 -3
  120. package/dist/lib/session/detached.d.ts +0 -1
  121. package/dist/lib/session/detached.js +0 -23
  122. package/dist/lib/session/discover.d.ts +2 -2
  123. package/dist/lib/session/presentation.d.ts +0 -7
  124. package/dist/lib/session/presentation.js +4 -4
  125. package/dist/lib/session/projection.js +1 -1
  126. package/dist/lib/session/remote/remote-list.d.ts +2 -0
  127. package/dist/lib/session/remote/remote-list.js +3 -2
  128. package/dist/lib/session/remote/watch.js +4 -5
  129. package/dist/lib/session/remote-active.js +1 -1
  130. package/dist/lib/session/resume-command.d.ts +0 -1
  131. package/dist/lib/session/resume-command.js +1 -4
  132. package/dist/lib/session/resume-owner.d.ts +0 -2
  133. package/dist/lib/session/resume-owner.js +0 -6
  134. package/dist/lib/session/selection.d.ts +4 -5
  135. package/dist/lib/session/selection.js +2 -2
  136. package/dist/lib/session/sync/config.d.ts +0 -25
  137. package/dist/lib/session/sync/config.js +0 -62
  138. package/dist/lib/session/sync/managed-config.d.ts +0 -1
  139. package/dist/lib/session/sync/managed-config.js +0 -3
  140. package/dist/lib/session/sync/worker-template.js +1 -1
  141. package/dist/lib/sessions-client.d.ts +0 -16
  142. package/dist/lib/sessions-client.js +1 -187
  143. package/dist/lib/startup/command-registry.d.ts +2 -0
  144. package/dist/lib/startup/command-registry.js +36 -3
  145. package/dist/lib/startup/root-command.d.ts +0 -1
  146. package/dist/lib/startup/root-command.js +0 -21
  147. package/dist/lib/sync-umbrella.js +1 -1
  148. package/dist/lib/terminal/resolve.js +1 -1
  149. package/dist/lib/watchdog/rotate.js +1 -1
  150. package/dist/lib/watchdog/watchdog.d.ts +1 -1
  151. package/dist/lib/watchdog/watchdog.js +2 -2
  152. package/package.json +1 -1
  153. package/dist/commands/browser.d.ts +0 -7
  154. package/dist/commands/browser.js +0 -139
  155. package/dist/commands/computer.d.ts +0 -48
  156. package/dist/commands/computer.js +0 -244
  157. package/dist/commands/resume.d.ts +0 -23
  158. package/dist/commands/resume.js +0 -158
  159. package/dist/commands/secrets-passthrough.d.ts +0 -3
  160. package/dist/commands/secrets-passthrough.js +0 -52
  161. package/dist/commands/sessions-bookmark.d.ts +0 -2
  162. package/dist/commands/sessions-bookmark.js +0 -92
  163. package/dist/commands/sessions-export.d.ts +0 -31
  164. package/dist/commands/sessions-export.js +0 -409
  165. package/dist/commands/sessions-import.d.ts +0 -6
  166. package/dist/commands/sessions-import.js +0 -343
  167. package/dist/commands/sessions-inject.d.ts +0 -14
  168. package/dist/commands/sessions-inject.js +0 -143
  169. package/dist/commands/sessions-picker-factory.d.ts +0 -24
  170. package/dist/commands/sessions-picker-factory.js +0 -59
  171. package/dist/commands/sessions-render.d.ts +0 -11
  172. package/dist/commands/sessions-render.js +0 -119
  173. package/dist/commands/sessions-share.d.ts +0 -15
  174. package/dist/commands/sessions-share.js +0 -171
  175. package/dist/commands/sessions.d.ts +0 -122
  176. package/dist/commands/sessions.js +0 -1760
  177. package/dist/lib/address.d.ts +0 -39
  178. package/dist/lib/address.js +0 -128
  179. package/dist/lib/computer/record.d.ts +0 -6
  180. package/dist/lib/computer/record.js +0 -25
  181. package/dist/lib/openclaw-keychain.d.ts +0 -43
  182. package/dist/lib/openclaw-keychain.js +0 -227
  183. package/dist/lib/session/bundle.d.ts +0 -76
  184. package/dist/lib/session/bundle.js +0 -146
  185. package/dist/lib/session/remote/remote-bundle.d.ts +0 -7
  186. package/dist/lib/session/remote/remote-bundle.js +0 -40
  187. package/dist/lib/session/remote/remote.d.ts +0 -35
  188. package/dist/lib/session/remote/remote.js +0 -198
  189. package/dist/lib/session/remote-bundle.d.ts +0 -1
  190. package/dist/lib/session/remote-bundle.js +0 -1
  191. package/dist/lib/session/remote.d.ts +0 -1
  192. package/dist/lib/session/remote.js +0 -1
  193. package/dist/lib/session/sync/agents.d.ts +0 -24
  194. package/dist/lib/session/sync/agents.js +0 -0
  195. package/dist/lib/session/sync/backend.d.ts +0 -22
  196. package/dist/lib/session/sync/backend.js +0 -44
  197. package/dist/lib/session/sync/managed-key.d.ts +0 -5
  198. package/dist/lib/session/sync/managed-key.js +0 -87
  199. package/dist/lib/session/sync/net-client.d.ts +0 -29
  200. package/dist/lib/session/sync/net-client.js +0 -87
  201. package/dist/lib/session/sync/r2.d.ts +0 -20
  202. package/dist/lib/session/sync/r2.js +0 -103
  203. package/dist/lib/session/sync/transcript-crypto.d.ts +0 -41
  204. package/dist/lib/session/sync/transcript-crypto.js +0 -115
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.23.17",
3
+ "version": "1.23.18",
4
4
  "description": "One CLI for all your AI coding agents - versions, config, cloud dispatch, sessions, and teams (now with first-class Grok Build CLI support)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,7 +0,0 @@
1
- import { Command } from 'commander';
2
- export declare const BROWSER_PASSTHROUGH_VERBS: ReadonlyArray<{
3
- name: string;
4
- description: string;
5
- }>;
6
- export declare function peekDevice(argv: string[]): string | undefined;
7
- export declare function registerBrowserCommand(program: Command): void;
@@ -1,139 +0,0 @@
1
- import { forwardsHelp, registerCommandGroups, setHelpSections } from '../lib/help.js';
2
- import { buildBrowserContext } from '../lib/browser/context.js';
3
- import { isBrowserClientError, resolveBrowserBin, runBrowser, } from '../lib/browser-client.js';
4
- const BROWSER_HELP_GROUPS = [
5
- { title: 'Session lifecycle', names: ['use', 'start', 'done', 'status', 'prune'] },
6
- { title: 'Fast action loop', names: ['stream'] },
7
- { title: 'Drive the page', names: ['navigate', 'tabs', 'screenshot', 'evaluate', 'click', 'type', 'press', 'wait'] },
8
- { title: 'Capture evidence', names: ['console', 'errors', 'requests', 'responsebody', 'record', 'pdf', 'logs'] },
9
- { title: 'History and discovery', names: ['sessions', 'history', 'refs'] },
10
- { title: 'Other', names: ['profiles', 'remote-control', 'stop', 'show', 'tab', 'ps', 'tasks', 'hover', 'scroll', 'upload', 'set', 'devices', 'download', 'waitdownload'] },
11
- ];
12
- export const BROWSER_PASSTHROUGH_VERBS = [
13
- { name: 'use', description: 'Pick the profile `agents browser start` uses when no --profile is passed' },
14
- { name: 'start', description: 'Start a browser task — --profile/--url/--record/--title, and --device <name> to bind a remote box' },
15
- { name: 'done', description: 'Complete a task and close its tabs (resolves from caller identity when --task is omitted)' },
16
- { name: 'status', description: 'Show browser service state and running browser tasks' },
17
- { name: 'prune', description: 'Close tabs for abandoned tasks and mark them done — the reaper the daemon runs, on demand' },
18
- { name: 'stream', description: 'Keep one process + IPC socket open; read NDJSON requests from stdin, write NDJSON responses' },
19
- { name: 'navigate', description: 'Navigate the current tab to a URL (creates a task and tab when none exist)' },
20
- { name: 'tabs', description: 'List tabs open for the current task; --all shows every tab in the profile browser' },
21
- { name: 'screenshot', description: 'Take a screenshot — auto-saved per task; --output only to pick a specific path' },
22
- { name: 'evaluate', description: 'Evaluate JavaScript in the current tab' },
23
- { name: 'click', description: 'Click an element by ref, or raw coordinates with --at X,Y' },
24
- { name: 'type', description: 'Type text into an element by ref' },
25
- { name: 'press', description: 'Press a key (Enter, Tab, Escape, …)' },
26
- { name: 'wait', description: 'Wait for a condition' },
27
- { name: 'console', description: 'Read console logs from a tab' },
28
- { name: 'errors', description: 'Read page errors from a tab' },
29
- { name: 'requests', description: 'Read captured network requests; --format har emits a HAR 1.2 document' },
30
- { name: 'responsebody', description: 'Wait for and read a response body by URL pattern' },
31
- { name: 'record', description: 'Record a video of the page (record start / record stop)' },
32
- { name: 'pdf', description: 'Export the current tab as PDF via CDP — auto-saved under sessions/<task>/ when omitted' },
33
- { name: 'logs', description: 'Read merged rush-app + rush-cli logs for a task' },
34
- { name: 'sessions', description: 'Browse captured screenshots, PDFs, recordings and downloads, grouped by task' },
35
- { name: 'history', description: 'Show recent browser task history' },
36
- { name: 'refs', description: 'Get DOM refs for interactive elements' },
37
- { name: 'profiles', description: 'Manage browser profiles (create / list / edit / rename / show / remove / use / …)' },
38
- { name: 'remote-control', description: 'Allow or deny other fleet machines driving THIS machine\'s browser (on/off; default off)' },
39
- { name: 'stop', description: 'Stop a task and close its tabs; --profile detaches the profile; --service stops the IPC service' },
40
- { name: 'show', description: 'Open a URL for a human to read (goes to browser.viewer; binds no task)' },
41
- { name: 'tab', description: 'Manage tabs (tab add / tab focus <id> / tab close [id])' },
42
- { name: 'ps', description: 'List every browser/electron/tunnel process agents has tracked — works without the daemon' },
43
- { name: 'tasks', description: 'List all browser tasks' },
44
- { name: 'hover', description: 'Hover over an element by ref' },
45
- { name: 'scroll', description: 'Scroll the page by a pixel amount (negatives scroll up/left)' },
46
- { name: 'upload', description: 'Upload file(s) — hidden inputs, drag-drop targets, and OS chooser interception' },
47
- { name: 'set', description: 'Set browser emulation options (set viewport / set device / set devices)' },
48
- { name: 'devices', description: 'List available device emulation presets' },
49
- { name: 'download', description: 'Set the download directory for a task' },
50
- { name: 'waitdownload', description: 'Wait for a download to complete' },
51
- ];
52
- export function peekDevice(argv) {
53
- for (let i = 0; i < argv.length; i++) {
54
- const arg = argv[i];
55
- if (arg === '--device')
56
- return argv[i + 1];
57
- if (arg.startsWith('--device='))
58
- return arg.slice('--device='.length);
59
- }
60
- return undefined;
61
- }
62
- async function forwardToBrowser(opts) {
63
- try {
64
- resolveBrowserBin();
65
- }
66
- catch (err) {
67
- if (isBrowserClientError(err)) {
68
- console.error(err.message);
69
- return { exitCode: 1, stdout: '' };
70
- }
71
- throw err;
72
- }
73
- const context = await buildBrowserContext({ device: opts.device });
74
- return runBrowser({
75
- argv: opts.argv,
76
- context,
77
- capture: opts.capture,
78
- });
79
- }
80
- async function forwardAndExit(opts) {
81
- const { exitCode } = await forwardToBrowser(opts);
82
- if (exitCode !== 0)
83
- process.exit(exitCode);
84
- }
85
- function registerPassthroughVerbs(program) {
86
- for (const verb of BROWSER_PASSTHROUGH_VERBS) {
87
- forwardsHelp(program
88
- .command(verb.name)
89
- .description(verb.description)
90
- .allowUnknownOption(true)
91
- .allowExcessArguments(true)
92
- .action(async (_opts, cmd) => {
93
- const argv = [verb.name, ...cmd.args];
94
- const device = verb.name === 'start' ? peekDevice(cmd.args) : undefined;
95
- await forwardAndExit({ argv, device });
96
- }));
97
- }
98
- }
99
- export function registerBrowserCommand(program) {
100
- const browser = program
101
- .command('browser')
102
- .description('Drive a real browser (Chrome/Brave/Edge/Firefox/Arc) over CDP/BiDi — navigate, screenshot, click, capture; --device to drive a remote box');
103
- registerPassthroughVerbs(browser);
104
- registerCommandGroups(browser, BROWSER_HELP_GROUPS);
105
- setHelpSections(browser, {
106
- examples: `
107
- # One-time: install the engine, then pick a profile
108
- npm i -g @phnx-labs/browser-cli
109
- agents browser profiles create work --browser chromium
110
- agents browser use work
111
-
112
- # Start a task, drive it, capture, close
113
- agents browser start --profile work
114
- agents browser navigate https://example.com
115
- agents browser screenshot -o /tmp/shot.png
116
- agents browser done
117
-
118
- # A remote box over the fleet (device bound at start)
119
- agents browser start --device box --profile work
120
- agents browser navigate https://example.com
121
- agents browser done
122
- `,
123
- notes: `
124
- The engine is the standalone \`browser\` CLI (npm i -g @phnx-labs/browser-cli);
125
- agents-cli supplies --device fleet resolution, remote-control consent, and the
126
- agent-session link on the feed. Per-verb flags are the engine's — \`agents browser
127
- screenshot --help\` asks it directly.
128
-
129
- \`--device\` is bound once at \`start\`; page verbs run against the task's bound
130
- device. \`--device local\` forces this machine.
131
-
132
- Another fleet machine may drive this browser only after \`agents browser
133
- remote-control on\` here (device-local, never synced; default off).
134
-
135
- \`agents browser sessions\` is the engine's own task and capture history
136
- (\`browser sessions --help\`); the feed stream reads the same rows.
137
- `,
138
- });
139
- }
@@ -1,48 +0,0 @@
1
- /**
2
- * `agents computer` — the consumer surface over the standalone `computer` CLI
3
- * (PHNX-4075).
4
- *
5
- * WHAT THIS FILE IS NOW. Every verb below forwards its arguments verbatim to the
6
- * standalone engine and propagates its exit code. agents-cli contributes four
7
- * things the engine cannot know:
8
- *
9
- * 1. the permissions allow list, rendered from `Computer(<bundle-id>)` rules
10
- * in the agents resource layer (`lib/computer/policy.ts`);
11
- * 2. the peer allow list, and `--device <name>` resolved against the fleet —
12
- * both carried in the fd-3 context (`lib/computer/context.ts`);
13
- * 3. the acting actor and agent session, likewise on fd 3;
14
- * 4. a recorder for the action events the engine streams back on fd 4
15
- * (`lib/computer/record.ts`).
16
- *
17
- * The remote path is the ENGINE's. `--device <name>` is resolved against the
18
- * fleet here — that is what the registry, ssh identity and platform check are
19
- * for — and then forwarded to the engine verbatim, which matches the alias
20
- * against `context.target` and owns everything downstream of it: pushing the
21
- * Windows helper, minting and storing its auth token, opening the `ssh -L`
22
- * tunnel, and hydrating its own transport from the state it wrote. agents-cli
23
- * keeps no tunnel state and publishes no endpoint: a `COMPUTER_HELPER_TCP` from
24
- * here would carry a port without the token the daemon demands, so the verb
25
- * would fail `auth_failed` against a tunnel that was up the whole time.
26
- *
27
- * WHY VERB FLAGS ARE NOT REDECLARED HERE. Each passthrough verb declares only
28
- * `--device` — the one flag the consumer must intercept — and takes everything
29
- * else as opaque operands via `allowUnknownOption`. Mirroring the engine's flags
30
- * would create a second, silently drifting copy of its surface: a flag added
31
- * upstream would be rejected here as unknown until someone noticed. The engine
32
- * also owns per-verb `--help` for the same reason. What agents-cli keeps is the
33
- * verb CATALOG — names, one-line descriptions, help groups — because that is
34
- * what makes the surface discoverable from `agents computer --help`, and a
35
- * verb the engine drops should fail loud here rather than silently vanish.
36
- */
37
- import { Command } from 'commander';
38
- export declare const COMPUTER_PASSTHROUGH_VERBS: ReadonlyArray<{
39
- name: string;
40
- description: string;
41
- }>;
42
- export declare function shouldBlockOffPlatform(opts: {
43
- platform: NodeJS.Platform;
44
- tcpConfigured: boolean;
45
- vncConfigured?: boolean;
46
- device?: string;
47
- }): boolean;
48
- export declare function registerComputerCommand(program: Command): void;
@@ -1,244 +0,0 @@
1
- /**
2
- * `agents computer` — the consumer surface over the standalone `computer` CLI
3
- * (PHNX-4075).
4
- *
5
- * WHAT THIS FILE IS NOW. Every verb below forwards its arguments verbatim to the
6
- * standalone engine and propagates its exit code. agents-cli contributes four
7
- * things the engine cannot know:
8
- *
9
- * 1. the permissions allow list, rendered from `Computer(<bundle-id>)` rules
10
- * in the agents resource layer (`lib/computer/policy.ts`);
11
- * 2. the peer allow list, and `--device <name>` resolved against the fleet —
12
- * both carried in the fd-3 context (`lib/computer/context.ts`);
13
- * 3. the acting actor and agent session, likewise on fd 3;
14
- * 4. a recorder for the action events the engine streams back on fd 4
15
- * (`lib/computer/record.ts`).
16
- *
17
- * The remote path is the ENGINE's. `--device <name>` is resolved against the
18
- * fleet here — that is what the registry, ssh identity and platform check are
19
- * for — and then forwarded to the engine verbatim, which matches the alias
20
- * against `context.target` and owns everything downstream of it: pushing the
21
- * Windows helper, minting and storing its auth token, opening the `ssh -L`
22
- * tunnel, and hydrating its own transport from the state it wrote. agents-cli
23
- * keeps no tunnel state and publishes no endpoint: a `COMPUTER_HELPER_TCP` from
24
- * here would carry a port without the token the daemon demands, so the verb
25
- * would fail `auth_failed` against a tunnel that was up the whole time.
26
- *
27
- * WHY VERB FLAGS ARE NOT REDECLARED HERE. Each passthrough verb declares only
28
- * `--device` — the one flag the consumer must intercept — and takes everything
29
- * else as opaque operands via `allowUnknownOption`. Mirroring the engine's flags
30
- * would create a second, silently drifting copy of its surface: a flag added
31
- * upstream would be rejected here as unknown until someone noticed. The engine
32
- * also owns per-verb `--help` for the same reason. What agents-cli keeps is the
33
- * verb CATALOG — names, one-line descriptions, help groups — because that is
34
- * what makes the surface discoverable from `agents computer --help`, and a
35
- * verb the engine drops should fail loud here rather than silently vanish.
36
- */
37
- import { forwardsHelp, registerCommandGroups, setHelpSections } from '../lib/help.js';
38
- import { loadComputerAllowList, loadDefaultPeers, resolveTcpEndpoint, resolveVncEndpoint, } from '../lib/computer/policy.js';
39
- import { forwardToComputer } from '../lib/computer-client.js';
40
- const COMPUTER_HELP_GROUPS = [
41
- { title: 'Installation', names: ['setup'] },
42
- { title: 'Daemon lifecycle', names: ['start', 'stop', 'reload', 'status'] },
43
- { title: 'Autonomous', names: ['run'] },
44
- { title: 'Observe', names: ['apps', 'describe', 'screenshot', 'get-text'] },
45
- { title: 'Interact', names: ['launch', 'raise', 'click', 'right-click', 'type', 'type-text', 'key', 'drag', 'scroll', 'ax-action', 'focus', 'wait'] },
46
- { title: 'History and discovery', names: ['sessions'] },
47
- ];
48
- export const COMPUTER_PASSTHROUGH_VERBS = [
49
- { name: 'run', description: 'Autonomously drive an app from a natural-language task (model loop over the computer verbs)' },
50
- { name: 'apps', description: 'List running apps the policy allows, with pid and bundle id' },
51
- { name: 'describe', description: 'Dump an app\'s accessibility tree — the element ids the interact verbs target' },
52
- { name: 'screenshot', description: 'Capture a window (default: largest), enumerate windows (--list), or the whole display (--display)' },
53
- { name: 'get-text', description: 'Read the text content of an element or a whole window' },
54
- { name: 'launch', description: 'Launch an allow-listed app by bundle id and wait for it to be ready' },
55
- { name: 'raise', description: 'Bring an app to the front' },
56
- { name: 'click', description: 'Click an element by id, or a coordinate pair' },
57
- { name: 'right-click', description: 'Right-click an element by id, or a coordinate pair' },
58
- { name: 'type', description: 'Type into a focused element by id' },
59
- { name: 'type-text', description: 'Type a literal string at the current focus' },
60
- { name: 'key', description: 'Send a key or chord (e.g. cmd+s, escape)' },
61
- { name: 'drag', description: 'Drag from one point or element to another' },
62
- { name: 'scroll', description: 'Scroll an element or the window under a coordinate' },
63
- { name: 'ax-action', description: 'Perform a raw accessibility action on an element' },
64
- { name: 'focus', description: 'Move keyboard focus to an element' },
65
- { name: 'wait', description: 'Wait for an element or condition to appear before continuing' },
66
- ];
67
- export function shouldBlockOffPlatform(opts) {
68
- if (opts.platform === 'darwin')
69
- return false;
70
- if (opts.tcpConfigured)
71
- return false;
72
- if (opts.vncConfigured)
73
- return false;
74
- if (opts.device)
75
- return false;
76
- return true;
77
- }
78
- async function forwardAndExit(opts) {
79
- const { exitCode } = await forwardToComputer(opts);
80
- if (exitCode !== 0)
81
- process.exit(exitCode);
82
- }
83
- export function registerComputerCommand(program) {
84
- const computer = program
85
- .command('computer')
86
- .description('Drive macOS apps via Accessibility, a Linux GUI desktop with --vnc, or a remote Windows device with --device — screenshot, click, type')
87
- .option('--vnc <host:port>', 'Drive a GUI desktop over VNC/RFB (x11vnc/Xvnc; port defaults to 5901) instead of a native helper')
88
- .option('--vnc-password <password>', 'VNC password for --vnc (or set COMPUTER_HELPER_VNC_PASSWORD)')
89
- .hook('preAction', async (_thisCommand, actionCommand) => {
90
- const globals = actionCommand.optsWithGlobals();
91
- if (globals.vnc) {
92
- process.env.COMPUTER_HELPER_VNC = globals.vnc;
93
- if (globals.vncPassword)
94
- process.env.COMPUTER_HELPER_VNC_PASSWORD = globals.vncPassword;
95
- }
96
- const device = globals.device;
97
- if (actionCommand.name() !== 'sessions' && shouldBlockOffPlatform({
98
- platform: process.platform,
99
- tcpConfigured: resolveTcpEndpoint() != null,
100
- vncConfigured: resolveVncEndpoint() != null,
101
- device: device || (actionCommand.args.some(arg => arg === '--host' || arg.startsWith('--host=')) ? 'direct-host' : undefined),
102
- })) {
103
- console.error('agents computer: macOS only for local driving — it uses the macOS Accessibility API.');
104
- console.error('For a Linux GUI desktop over VNC: `agents computer --vnc <host:port> screenshot`.');
105
- console.error('For a remote Windows device: register it with `agents devices`, then use --device (or set COMPUTER_HELPER_TCP).');
106
- process.exit(1);
107
- }
108
- });
109
- registerComputerSubcommands(computer);
110
- registerCommandGroups(computer, COMPUTER_HELP_GROUPS);
111
- setHelpSections(computer, {
112
- examples: `
113
- # One-time: install the engine, the helper, and the TCC grants
114
- npm i -g @phnx-labs/computer-cli
115
- agents setup computer
116
-
117
- # Allow an app, then reload so the daemon picks it up
118
- # ~/.agents/permissions/groups/computer.yaml: allow: ["Computer(com.apple.notes)"]
119
- agents computer reload
120
-
121
- # Observe, then act
122
- agents computer apps --json
123
- agents computer describe --bundle com.apple.notes
124
- agents computer click --bundle com.apple.notes --id <element-id>
125
-
126
- # A remote Windows device over the fleet
127
- agents computer setup --device win-mini
128
- agents computer start --device win-mini
129
- agents computer screenshot --device win-mini -o /tmp/win.png
130
- agents computer stop --device win-mini
131
- `,
132
- notes: `
133
- The engine is the standalone \`computer\` CLI (npm i -g @phnx-labs/computer-cli);
134
- agents-cli supplies the permission allow list, --device fleet resolution, and
135
- the agent-session link on the feed. Per-verb flags are the engine's — \`agents computer
136
- click --help\` asks it directly.
137
-
138
- Apps are deny-by-default: a verb only reaches an app named by a
139
- Computer(<bundle-id>) rule in ~/.agents/permissions/groups/. Edit a group,
140
- then \`agents computer reload\`.
141
-
142
- \`agents computer sessions\` is the engine's own run history
143
- (\`computer sessions --help\`); the feed stream reads the same rows.
144
- `,
145
- });
146
- }
147
- function registerComputerSubcommands(program) {
148
- registerSetupCommand(program);
149
- registerStartCommand(program);
150
- registerStopCommand(program);
151
- registerReloadCommand(program);
152
- registerStatusCommand(program);
153
- registerPassthroughVerbs(program);
154
- registerSessionsCommand(program);
155
- registerCommandGroups(program, COMPUTER_HELP_GROUPS);
156
- }
157
- function registerPassthroughVerbs(program) {
158
- for (const verb of COMPUTER_PASSTHROUGH_VERBS) {
159
- forwardsHelp(program
160
- .command(verb.name)
161
- .description(verb.description)
162
- .option('--device <name>', 'Drive a remote Windows device registered with `agents devices` (the engine connects or provisions it on demand)')
163
- .allowUnknownOption(true)
164
- .allowExcessArguments(true)
165
- .action(async (opts, cmd) => {
166
- await forwardAndExit({ argv: [verb.name, ...cmd.args], device: opts.device });
167
- }));
168
- }
169
- }
170
- function registerSetupCommand(program) {
171
- forwardsHelp(program
172
- .command('setup')
173
- .alias('install-helper')
174
- .description('Install the helper — locally to /Applications/ (macOS), or to a remote Windows device with --device')
175
- .option('--device <name>', 'Provision a remote Windows device (push the exe + register a LOGON task) instead of installing locally')
176
- .allowUnknownOption(true)
177
- .allowExcessArguments(true)
178
- .action(async (opts, cmd) => {
179
- await forwardAndExit({ argv: ['setup', ...cmd.args], device: opts.device, record: false });
180
- }));
181
- }
182
- function registerStartCommand(program) {
183
- forwardsHelp(program
184
- .command('start')
185
- .description('Activate the helper daemon — local launchd (macOS) or a remote Windows tunnel with --device')
186
- .option('--device <name>', 'Start the remote Windows daemon and its tunnel instead of the local launchd service')
187
- .allowUnknownOption(true)
188
- .allowExcessArguments(true)
189
- .action(async (opts, cmd) => {
190
- await forwardAndExit({ argv: ['start', ...cmd.args], device: opts.device, record: false });
191
- }));
192
- }
193
- function registerStopCommand(program) {
194
- forwardsHelp(program
195
- .command('stop')
196
- .description('Deactivate the helper daemon — local launchd (macOS) or a remote Windows tunnel with --device')
197
- .option('--device <name>', 'Tear down the remote tunnel and unregister the scheduled task')
198
- .allowUnknownOption(true)
199
- .allowExcessArguments(true)
200
- .action(async (opts, cmd) => {
201
- await forwardAndExit({ argv: ['stop', ...cmd.args], device: opts.device, record: false });
202
- }));
203
- }
204
- function registerReloadCommand(program) {
205
- forwardsHelp(program
206
- .command('reload')
207
- .description('Reload the allow-list policy (SIGHUP the local daemon) — or restart a remote Windows daemon with --device')
208
- .option('--device <name>', 'Restart the remote Windows daemon (its scheduled task) instead of SIGHUPing the local one')
209
- .allowUnknownOption(true)
210
- .allowExcessArguments(true)
211
- .action(async (opts, cmd) => {
212
- await forwardAndExit({ argv: ['reload', ...cmd.args], device: opts.device, record: false });
213
- }));
214
- }
215
- function registerStatusCommand(program) {
216
- forwardsHelp(program
217
- .command('status')
218
- .description('Report install state, daemon state, and Accessibility trust — or a remote Windows daemon with --device')
219
- .option('--device <name>', 'Report the remote Windows daemon (tunnel + liveness) instead of the local helper')
220
- .allowUnknownOption(true)
221
- .allowExcessArguments(true)
222
- .action(async (opts, cmd) => {
223
- const json = cmd.args.includes('--json');
224
- if (!json && !opts.device) {
225
- const allowed = loadComputerAllowList();
226
- const preview = allowed.slice(0, 5).join(', ');
227
- const suffix = allowed.length > 5 ? ` (+${allowed.length - 5} more)` : '';
228
- console.log(`policy: ${allowed.length} app${allowed.length === 1 ? '' : 's'} allowed${allowed.length > 0 ? `: ${preview}${suffix}` : ''}`);
229
- console.log(`peers: ${loadDefaultPeers().length} caller(s) (peer-auth on socket)`);
230
- }
231
- await forwardAndExit({ argv: ['status', ...cmd.args], device: opts.device, record: false });
232
- }));
233
- }
234
- function registerSessionsCommand(program) {
235
- program
236
- .command('sessions')
237
- .description('Browse computer-driving history, grouped by run — the engine\'s own picker')
238
- .allowUnknownOption(true)
239
- .allowExcessArguments(true)
240
- .helpOption(false)
241
- .action(async (_opts, cmd) => {
242
- await forwardAndExit({ argv: ['sessions', ...cmd.args], record: false });
243
- });
244
- }
@@ -1,23 +0,0 @@
1
- import type { SessionMeta } from '@phnx-labs/sessions-cli/reader';
2
- export declare function resumeLocalFallbackSource(session: SessionMeta, self?: string): SessionMeta;
3
- export interface StrictResumeOptions {
4
- agent?: string;
5
- mode?: string;
6
- account?: string;
7
- model?: string;
8
- interactive?: boolean;
9
- headless?: boolean;
10
- cwd?: string;
11
- quiet?: boolean;
12
- here?: boolean;
13
- local?: boolean;
14
- }
15
- export declare function buildResumeRemoteArgs(sessionId: string, prompt: string | undefined, options: StrictResumeOptions): string[];
16
- export declare function buildResumeRunArgs(session: {
17
- id: string;
18
- agent: string;
19
- version?: string;
20
- }, prompt: string | undefined, options: StrictResumeOptions): string[];
21
- export declare function wantsStrictResume(prompt: string | undefined, options: StrictResumeOptions): boolean;
22
- export declare function runStrictResume(sessionId: string, prompt: string | undefined, options: StrictResumeOptions): Promise<void>;
23
- export declare function stillRunningNotice(shortId: string, pid: number, host: string): string;
@@ -1,158 +0,0 @@
1
- import { spawn } from 'child_process';
2
- import chalk from 'chalk';
3
- import { resolveSessionMetadataValue } from '../lib/session/selection.js';
4
- import { sessionOwnerDevice, consumeResumePinned, RESUME_PINNED_ENV } from '../lib/session/resume-owner.js';
5
- import { machineId } from '../lib/machine-id.js';
6
- import { takeOverDetachedSession } from '../lib/session/detached.js';
7
- import { liveSessionProcesses, writePidSessionEntry } from '../lib/session/pid-registry.js';
8
- import { launchIdentityEnv } from '../lib/launch-identity.js';
9
- const RESUME_SOURCE_ENV = 'AGENTS_RESUME_SOURCE_JSON';
10
- export function resumeLocalFallbackSource(session, self = machineId()) {
11
- return { ...session, machine: self };
12
- }
13
- export function buildResumeRemoteArgs(sessionId, prompt, options) {
14
- const args = ['sessions', 'resume', sessionId, ...(prompt === undefined ? [] : [prompt])];
15
- if (options.agent)
16
- args.push('--agent', options.agent);
17
- if (options.account)
18
- args.push('--account', options.account);
19
- if (options.model)
20
- args.push('--model', options.model);
21
- if (options.mode)
22
- args.push('--mode', options.mode);
23
- if (options.interactive)
24
- args.push('--interactive');
25
- if (options.headless)
26
- args.push('--headless');
27
- if (options.cwd)
28
- args.push('--cwd', options.cwd);
29
- if (options.quiet)
30
- args.push('--quiet');
31
- return args;
32
- }
33
- export function buildResumeRunArgs(session, prompt, options) {
34
- const spec = session.agent;
35
- const args = ['run', spec, ...(prompt === undefined ? [] : [prompt]), '--resume', session.id];
36
- if (options.account)
37
- args.push('--account', options.account);
38
- if (options.model)
39
- args.push('--model', options.model);
40
- if (options.mode)
41
- args.push('--mode', options.mode);
42
- if (options.interactive)
43
- args.push('--interactive');
44
- if (options.headless)
45
- args.push('--headless');
46
- if (options.cwd)
47
- args.push('--cwd', options.cwd);
48
- if (options.quiet)
49
- args.push('--quiet');
50
- return args;
51
- }
52
- function consumeResumeSource() {
53
- const raw = process.env[RESUME_SOURCE_ENV];
54
- delete process.env[RESUME_SOURCE_ENV];
55
- if (!raw)
56
- return undefined;
57
- try {
58
- const value = JSON.parse(raw);
59
- if (typeof value?.id === 'string' && typeof value?.agent === 'string')
60
- return value;
61
- }
62
- catch {
63
- }
64
- return undefined;
65
- }
66
- export function wantsStrictResume(prompt, options) {
67
- return (prompt !== undefined ||
68
- !!options.mode ||
69
- !!options.interactive ||
70
- !!options.headless ||
71
- !!options.cwd ||
72
- !!options.here);
73
- }
74
- export async function runStrictResume(sessionId, prompt, options) {
75
- const routedHop = consumeResumePinned();
76
- const pinnedHere = routedHop || !!options.here;
77
- const routedSource = routedHop ? consumeResumeSource() : undefined;
78
- if (routedSource && routedSource.id !== sessionId.trim()) {
79
- console.error(chalk.red(`Resume routing metadata names session ${routedSource.id}, not requested session ${sessionId.trim()}.`));
80
- process.exitCode = 1;
81
- return;
82
- }
83
- const outcome = await resolveSessionMetadataValue(sessionId.trim(), { agent: options.agent, local: pinnedHere || options.local });
84
- if (outcome.kind === 'partial') {
85
- const offline = outcome.failedPeers;
86
- console.error(chalk.yellow(`Warning: ${offline.length} device(s) unreachable, not checked: ${offline.join(', ')}`));
87
- console.error(chalk.red(`No session matching "${sessionId}" on any reachable device (${offline.length} unreachable, not checked).`));
88
- console.error(chalk.gray(' If it lives on an offline box, wake it (agents devices) or run there: agents ssh <device>'));
89
- process.exitCode = 1;
90
- return;
91
- }
92
- if (outcome.kind === 'not-found') {
93
- console.error(chalk.red(`No session matching "${sessionId}".`));
94
- process.exitCode = 1;
95
- return;
96
- }
97
- if (outcome.kind === 'ambiguous') {
98
- console.error(chalk.red(`"${sessionId}" matches ${outcome.candidates.length} sessions. Pass the full session id.`));
99
- process.exitCode = 1;
100
- return;
101
- }
102
- const owner = pinnedHere ? undefined : sessionOwnerDevice(outcome.session);
103
- if (owner) {
104
- if (!options.quiet) {
105
- process.stderr.write(chalk.gray(`[agents] session ${outcome.session.shortId} belongs to ${owner} → resuming there\n`));
106
- }
107
- writePidSessionEntry({
108
- pid: process.pid,
109
- agent: outcome.session.agent,
110
- sessionId: outcome.session.id,
111
- cwd: outcome.session.cwd,
112
- terminalId: launchIdentityEnv().AGENT_TERMINAL_ID,
113
- machine: owner,
114
- startedAtMs: Date.now(),
115
- });
116
- const { runOnPeer } = await import('../lib/session/remote-list.js');
117
- const rc = await runOnPeer(buildResumeRemoteArgs(outcome.session.id, prompt, options), owner, {
118
- tty: !!process.stdout.isTTY,
119
- env: {
120
- [RESUME_PINNED_ENV]: '1',
121
- [RESUME_SOURCE_ENV]: JSON.stringify(outcome.session),
122
- },
123
- sessionId: outcome.session.id,
124
- });
125
- if (rc === 'no-target' || rc === 'unreachable') {
126
- if (!options.quiet) {
127
- process.stderr.write(chalk.yellow(`[agents] session ${outcome.session.shortId} belongs to ${owner}, which is unreachable; checking for local transcript content before offering replay\n`));
128
- }
129
- process.exitCode = await delegateLocalResume(resumeLocalFallbackSource(outcome.session), prompt, options);
130
- }
131
- return;
132
- }
133
- const localSession = pinnedHere ? resumeLocalFallbackSource(outcome.session) : outcome.session;
134
- await takeOverDetachedSession(localSession.id);
135
- if (!options.quiet) {
136
- for (const running of liveSessionProcesses(localSession.id)) {
137
- process.stderr.write(chalk.yellow(stillRunningNotice(localSession.shortId, running.pid, machineId())));
138
- }
139
- }
140
- process.exitCode = await delegateLocalResume(localSession, prompt, options);
141
- }
142
- export function stillRunningNotice(shortId, pid, host) {
143
- return `An older copy of ${shortId} is still running on ${host} (pid ${pid}). It was left alone.\n`;
144
- }
145
- async function delegateLocalResume(session, prompt, options) {
146
- const args = buildResumeRunArgs(session, prompt, options);
147
- const child = spawn(process.execPath, [process.argv[1], ...args], {
148
- stdio: 'inherit',
149
- env: {
150
- ...process.env,
151
- [RESUME_SOURCE_ENV]: JSON.stringify(session),
152
- },
153
- });
154
- return new Promise((resolve) => {
155
- child.once('error', () => resolve(127));
156
- child.once('exit', (code, signal) => resolve(code ?? (signal ? 1 : 0)));
157
- });
158
- }
@@ -1,3 +0,0 @@
1
- import type { Command } from 'commander';
2
- export declare function rewriteDeviceToHost(argv: string[]): Promise<string[]>;
3
- export declare function registerSecretsCommands(program: Command): void;