@phnx-labs/agents-cli 1.22.117 → 1.22.119

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 (271) hide show
  1. package/CHANGELOG.md +301 -0
  2. package/dist/bootstrap.js +4 -11
  3. package/dist/commands/accounts.js +7 -4
  4. package/dist/commands/browser.d.ts +52 -70
  5. package/dist/commands/browser.js +192 -3562
  6. package/dist/commands/daemon.d.ts +39 -2
  7. package/dist/commands/daemon.js +72 -73
  8. package/dist/commands/events.js +1 -1
  9. package/dist/commands/exec.js +53 -1
  10. package/dist/commands/projects.js +92 -7
  11. package/dist/commands/repo.js +13 -49
  12. package/dist/commands/route.js +5 -5
  13. package/dist/commands/routines.js +39 -12
  14. package/dist/commands/sessions-render.d.ts +1 -1
  15. package/dist/commands/sessions-render.js +0 -1
  16. package/dist/commands/sessions.test-fixture.d.ts +0 -1
  17. package/dist/commands/sessions.test-fixture.js +0 -37
  18. package/dist/commands/setup-browser.d.ts +17 -12
  19. package/dist/commands/setup-browser.js +52 -87
  20. package/dist/commands/setup-preferences.d.ts +0 -17
  21. package/dist/commands/setup-preferences.js +18 -49
  22. package/dist/commands/setup.js +9 -9
  23. package/dist/commands/ssh.js +10 -1
  24. package/dist/commands/sync.js +6 -44
  25. package/dist/commands/teams.js +0 -1
  26. package/dist/commands/update.d.ts +19 -0
  27. package/dist/commands/update.js +34 -6
  28. package/dist/commands/view.d.ts +12 -1
  29. package/dist/commands/view.js +47 -2
  30. package/dist/index.js +107 -26
  31. package/dist/lib/account-capabilities.js +0 -2
  32. package/dist/lib/account-catalog.d.ts +38 -0
  33. package/dist/lib/account-catalog.js +110 -26
  34. package/dist/lib/account-provider-registry.js +1 -1
  35. package/dist/lib/account-registry.d.ts +1 -1
  36. package/dist/lib/account-registry.js +36 -2
  37. package/dist/lib/accounting/rotate.js +22 -8
  38. package/dist/lib/accounting/usage-ingest.d.ts +6 -1
  39. package/dist/lib/accounting/usage-ingest.js +115 -45
  40. package/dist/lib/accounting/usage-sync.d.ts +134 -31
  41. package/dist/lib/accounting/usage-sync.js +227 -66
  42. package/dist/lib/accounting/usage.d.ts +16 -3
  43. package/dist/lib/accounting/usage.js +26 -8
  44. package/dist/lib/accounts/add.d.ts +3 -1
  45. package/dist/lib/accounts/add.js +24 -13
  46. package/dist/lib/accounts/slots.d.ts +8 -0
  47. package/dist/lib/accounts/slots.js +17 -0
  48. package/dist/lib/add-dir.js +0 -1
  49. package/dist/lib/agent-cli-commands.js +0 -1
  50. package/dist/lib/agent-spec/agents.d.ts +6 -7
  51. package/dist/lib/agent-spec/agents.js +7 -60
  52. package/dist/lib/auth-health.d.ts +69 -1
  53. package/dist/lib/auth-health.js +133 -4
  54. package/dist/lib/browser/context.d.ts +82 -0
  55. package/dist/lib/browser/context.js +88 -0
  56. package/dist/lib/browser/paths.d.ts +25 -0
  57. package/dist/lib/browser/paths.js +51 -0
  58. package/dist/lib/browser/record.d.ts +38 -0
  59. package/dist/lib/browser/record.js +57 -0
  60. package/dist/lib/browser/sessions-list.js +1 -2
  61. package/dist/lib/browser-client.d.ts +158 -0
  62. package/dist/lib/browser-client.js +234 -0
  63. package/dist/lib/channels/owner-sink.d.ts +1 -18
  64. package/dist/lib/channels/owner-sink.js +29 -82
  65. package/dist/lib/channels/providers/rush.d.ts +7 -7
  66. package/dist/lib/channels/providers/rush.js +127 -57
  67. package/dist/lib/claude-account-token.d.ts +7 -1
  68. package/dist/lib/claude-account-token.js +26 -4
  69. package/dist/lib/claude-statusline.d.ts +1 -1
  70. package/dist/lib/claude-statusline.js +15 -3
  71. package/dist/lib/commands.js +1 -1
  72. package/dist/lib/crabbox/lease.js +1 -1
  73. package/dist/lib/crabbox/runtimes.js +1 -3
  74. package/dist/lib/daemon/account-state-daemon-service.js +1 -0
  75. package/dist/lib/daemon/auth-sync-service.d.ts +21 -18
  76. package/dist/lib/daemon/auth-sync-service.js +37 -43
  77. package/dist/lib/daemon/daemon.d.ts +25 -14
  78. package/dist/lib/daemon/daemon.js +92 -154
  79. package/dist/lib/daemon/runner.d.ts +2 -2
  80. package/dist/lib/daemon/runner.js +32 -9
  81. package/dist/lib/daemon/self-update-service.d.ts +35 -34
  82. package/dist/lib/daemon/self-update-service.js +40 -36
  83. package/dist/lib/daemon/service.d.ts +12 -8
  84. package/dist/lib/daemon/supervisor.d.ts +65 -54
  85. package/dist/lib/daemon/supervisor.js +136 -171
  86. package/dist/lib/daemon/testdata/process-view-start.js +5 -2
  87. package/dist/lib/daemon/usage-sync-service.d.ts +21 -30
  88. package/dist/lib/daemon/usage-sync-service.js +46 -78
  89. package/dist/lib/daemon-health.d.ts +22 -5
  90. package/dist/lib/daemon-health.js +47 -3
  91. package/dist/lib/daemon-services.d.ts +1 -1
  92. package/dist/lib/daemon-services.js +0 -10
  93. package/dist/lib/daemon-ticks.js +4 -2
  94. package/dist/lib/devices/doctor-findings.js +8 -11
  95. package/dist/lib/devices/harness-inventory.js +14 -5
  96. package/dist/lib/exec-account-home.js +5 -0
  97. package/dist/lib/exec.js +10 -13
  98. package/dist/lib/feed/events.js +0 -1
  99. package/dist/lib/feed/tool-activity.js +5 -2
  100. package/dist/lib/fleet-shared-state.d.ts +45 -0
  101. package/dist/lib/fleet-shared-state.js +78 -9
  102. package/dist/lib/fs-atomic.js +25 -0
  103. package/dist/lib/github/pr-mergeable.d.ts +4 -2
  104. package/dist/lib/github/pr-mergeable.js +5 -3
  105. package/dist/lib/github/project-prs.d.ts +58 -3
  106. package/dist/lib/github/project-prs.js +205 -7
  107. package/dist/lib/harness/adapters/cursor.js +14 -4
  108. package/dist/lib/harness-auth-capabilities.d.ts +4 -3
  109. package/dist/lib/harness-auth-capabilities.js +1 -2
  110. package/dist/lib/helper-versions.js +1 -1
  111. package/dist/lib/hooks/cache.d.ts +7 -0
  112. package/dist/lib/hooks/cache.js +27 -2
  113. package/dist/lib/hooks/install.js +7 -1
  114. package/dist/lib/hosts/ready.d.ts +38 -8
  115. package/dist/lib/hosts/ready.js +62 -14
  116. package/dist/lib/installations/active-check.d.ts +27 -0
  117. package/dist/lib/installations/active-check.js +61 -0
  118. package/dist/lib/installations/migrate.js +6 -3
  119. package/dist/lib/installations/shims.d.ts +1 -1
  120. package/dist/lib/installations/shims.js +32 -12
  121. package/dist/lib/installations/store.d.ts +9 -0
  122. package/dist/lib/installations/store.js +24 -0
  123. package/dist/lib/installations/update.js +21 -15
  124. package/dist/lib/installations/versions.js +15 -3
  125. package/dist/lib/manifest.js +1 -1
  126. package/dist/lib/models.js +0 -2
  127. package/dist/lib/open-url.js +28 -54
  128. package/dist/lib/profiles.js +0 -2
  129. package/dist/lib/projects.d.ts +16 -0
  130. package/dist/lib/projects.js +31 -0
  131. package/dist/lib/refresh.js +1 -1
  132. package/dist/lib/routine-readiness.d.ts +35 -0
  133. package/dist/lib/routine-readiness.js +74 -16
  134. package/dist/lib/rules/compile.js +6 -0
  135. package/dist/lib/sandbox.js +0 -2
  136. package/dist/lib/secrets-policy.d.ts +89 -11
  137. package/dist/lib/secrets-policy.js +175 -28
  138. package/dist/lib/session/active.d.ts +17 -6
  139. package/dist/lib/session/active.js +105 -49
  140. package/dist/lib/session/db.d.ts +1 -1
  141. package/dist/lib/session/db.js +65 -18
  142. package/dist/lib/session/discover.js +1 -283
  143. package/dist/lib/session/mirror.d.ts +4 -3
  144. package/dist/lib/session/mirror.js +4 -3
  145. package/dist/lib/session/parse.d.ts +0 -2
  146. package/dist/lib/session/parse.js +1 -138
  147. package/dist/lib/session/pid-registry.d.ts +6 -3
  148. package/dist/lib/session/pid-registry.js +18 -8
  149. package/dist/lib/session/remote/watch.d.ts +1 -1
  150. package/dist/lib/session/remote/watch.js +7 -3
  151. package/dist/lib/session/throughput.d.ts +1 -3
  152. package/dist/lib/session/throughput.js +0 -20
  153. package/dist/lib/session/types.d.ts +2 -2
  154. package/dist/lib/session/types.js +2 -2
  155. package/dist/lib/sessions-client.d.ts +60 -1
  156. package/dist/lib/sessions-client.js +227 -4
  157. package/dist/lib/setup-tool-status.js +5 -10
  158. package/dist/lib/signin-badge.d.ts +3 -2
  159. package/dist/lib/signin-badge.js +6 -3
  160. package/dist/lib/smart-launch.js +4 -1
  161. package/dist/lib/staleness/detectors/commands.d.ts +1 -1
  162. package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
  163. package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
  164. package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
  165. package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
  166. package/dist/lib/staleness/detectors/rules.d.ts +1 -1
  167. package/dist/lib/staleness/detectors/skills.d.ts +1 -1
  168. package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
  169. package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
  170. package/dist/lib/staleness/writers/commands.d.ts +1 -1
  171. package/dist/lib/staleness/writers/hooks.d.ts +1 -1
  172. package/dist/lib/staleness/writers/mcp.d.ts +1 -1
  173. package/dist/lib/staleness/writers/permissions.d.ts +1 -1
  174. package/dist/lib/staleness/writers/plugins.d.ts +1 -1
  175. package/dist/lib/staleness/writers/rules.d.ts +1 -1
  176. package/dist/lib/staleness/writers/skills.d.ts +1 -1
  177. package/dist/lib/staleness/writers/sources.js +5 -0
  178. package/dist/lib/staleness/writers/subagents.d.ts +1 -1
  179. package/dist/lib/staleness/writers/workflows.d.ts +1 -1
  180. package/dist/lib/state.d.ts +6 -4
  181. package/dist/lib/state.js +7 -17
  182. package/dist/lib/teams/parsers.d.ts +1 -1
  183. package/dist/lib/teams/parsers.js +1 -136
  184. package/dist/lib/teams/placement-probe.js +50 -15
  185. package/dist/lib/teams/scheduler.d.ts +7 -0
  186. package/dist/lib/types.d.ts +16 -1
  187. package/dist/lib/types.js +1 -1
  188. package/dist/lib/view-types.d.ts +32 -0
  189. package/dist/lib/watchdog/read.js +0 -1
  190. package/dist/lib/watchdog/rotate.js +1 -2
  191. package/dist/lib/watchdog/runner.js +2 -2
  192. package/dist/lib/watchdog/watchdog.d.ts +1 -1
  193. package/dist/lib/watchdog/watchdogTail.js +0 -31
  194. package/package.json +1 -1
  195. package/scripts/postinstall.js +8 -8
  196. package/dist/browser.d.ts +0 -2
  197. package/dist/browser.js +0 -17
  198. package/dist/commands/browser-picker.d.ts +0 -18
  199. package/dist/commands/browser-picker.js +0 -97
  200. package/dist/lib/browser/arc-discovery.d.ts +0 -52
  201. package/dist/lib/browser/arc-discovery.js +0 -197
  202. package/dist/lib/browser/arc-dom.d.ts +0 -14
  203. package/dist/lib/browser/arc-dom.js +0 -121
  204. package/dist/lib/browser/caller-identity.d.ts +0 -40
  205. package/dist/lib/browser/caller-identity.js +0 -175
  206. package/dist/lib/browser/cdp.d.ts +0 -51
  207. package/dist/lib/browser/cdp.js +0 -254
  208. package/dist/lib/browser/chrome.d.ts +0 -141
  209. package/dist/lib/browser/chrome.js +0 -704
  210. package/dist/lib/browser/chromium-discovery.d.ts +0 -28
  211. package/dist/lib/browser/chromium-discovery.js +0 -96
  212. package/dist/lib/browser/devices.d.ts +0 -34
  213. package/dist/lib/browser/devices.js +0 -61
  214. package/dist/lib/browser/domain-skills.d.ts +0 -71
  215. package/dist/lib/browser/domain-skills.js +0 -195
  216. package/dist/lib/browser/drivers/arc.d.ts +0 -40
  217. package/dist/lib/browser/drivers/arc.js +0 -276
  218. package/dist/lib/browser/drivers/firefox.d.ts +0 -99
  219. package/dist/lib/browser/drivers/firefox.js +0 -377
  220. package/dist/lib/browser/drivers/local.d.ts +0 -55
  221. package/dist/lib/browser/drivers/local.js +0 -266
  222. package/dist/lib/browser/drivers/ssh.d.ts +0 -120
  223. package/dist/lib/browser/drivers/ssh.js +0 -467
  224. package/dist/lib/browser/editor.d.ts +0 -3
  225. package/dist/lib/browser/editor.js +0 -50
  226. package/dist/lib/browser/ffmpeg.d.ts +0 -12
  227. package/dist/lib/browser/ffmpeg.js +0 -184
  228. package/dist/lib/browser/firefox-discovery.d.ts +0 -69
  229. package/dist/lib/browser/firefox-discovery.js +0 -162
  230. package/dist/lib/browser/har.d.ts +0 -85
  231. package/dist/lib/browser/har.js +0 -77
  232. package/dist/lib/browser/hygiene.d.ts +0 -97
  233. package/dist/lib/browser/hygiene.js +0 -153
  234. package/dist/lib/browser/index.d.ts +0 -5
  235. package/dist/lib/browser/index.js +0 -5
  236. package/dist/lib/browser/input.d.ts +0 -7
  237. package/dist/lib/browser/input.js +0 -92
  238. package/dist/lib/browser/ipc.d.ts +0 -204
  239. package/dist/lib/browser/ipc.js +0 -1453
  240. package/dist/lib/browser/login-detection.d.ts +0 -87
  241. package/dist/lib/browser/login-detection.js +0 -274
  242. package/dist/lib/browser/profiles.d.ts +0 -422
  243. package/dist/lib/browser/profiles.js +0 -1157
  244. package/dist/lib/browser/refs.d.ts +0 -89
  245. package/dist/lib/browser/refs.js +0 -191
  246. package/dist/lib/browser/registry.d.ts +0 -70
  247. package/dist/lib/browser/registry.js +0 -252
  248. package/dist/lib/browser/remote-control.d.ts +0 -59
  249. package/dist/lib/browser/remote-control.js +0 -85
  250. package/dist/lib/browser/resolve-target.d.ts +0 -66
  251. package/dist/lib/browser/resolve-target.js +0 -264
  252. package/dist/lib/browser/runtime-state.d.ts +0 -291
  253. package/dist/lib/browser/runtime-state.js +0 -584
  254. package/dist/lib/browser/secret-ref.d.ts +0 -10
  255. package/dist/lib/browser/secret-ref.js +0 -14
  256. package/dist/lib/browser/service.d.ts +0 -812
  257. package/dist/lib/browser/service.js +0 -4693
  258. package/dist/lib/browser/stream.d.ts +0 -17
  259. package/dist/lib/browser/stream.js +0 -72
  260. package/dist/lib/browser/task-index.d.ts +0 -78
  261. package/dist/lib/browser/task-index.js +0 -199
  262. package/dist/lib/browser/types.d.ts +0 -647
  263. package/dist/lib/browser/types.js +0 -61
  264. package/dist/lib/browser/upload.d.ts +0 -29
  265. package/dist/lib/browser/upload.js +0 -298
  266. package/dist/lib/daemon/browser-ipc-service.d.ts +0 -20
  267. package/dist/lib/daemon/browser-ipc-service.js +0 -46
  268. package/dist/lib/daemon/browser-task-reap-service.d.ts +0 -14
  269. package/dist/lib/daemon/browser-task-reap-service.js +0 -26
  270. package/dist/lib/fleet-shared-repo-sync.d.ts +0 -55
  271. package/dist/lib/fleet-shared-repo-sync.js +0 -490
@@ -1,647 +0,0 @@
1
- import type { ArcNativeTabRef } from './drivers/arc.js';
2
- export type { ArcNativeTabRef } from './drivers/arc.js';
3
- export type BrowserType = 'chrome' | 'comet' | 'chromium' | 'brave' | 'edge' | 'arc' | 'firefox' | 'custom';
4
- /**
5
- * The transport backend a live browser connection uses (PHNX-2399).
6
- * - `cdp` — Chrome DevTools Protocol (the existing path for all Chromium-family browsers).
7
- * - `arc-native` — Apple Events via `osascript` (the native Arc path, no CDP port required).
8
- * - `bidi` — WebDriver BiDi over a WebSocket (Firefox, PHNX-4043; Firefox 129+
9
- * ships no CDP at all).
10
- *
11
- * Load-bearing: every action method on `BrowserService` that calls `conn.cdp.send()`
12
- * must check `conn.backend` and route to the native driver instead when it is
13
- * `arc-native` or `bidi`. Unsupported verbs throw `ArcNativeCapabilityError` /
14
- * `FirefoxCapabilityError`.
15
- */
16
- export type BackendKind = 'cdp' | 'arc-native' | 'bidi';
17
- /**
18
- * Stable native identity carried by an Arc profile declaration (PHNX-2399).
19
- * One agents-cli profile is one Arc Space: the Space already carries its Arc
20
- * profile (cookies, logins), so agents never learn a second "space" concept.
21
- */
22
- export interface ArcNativeProfileIdentity {
23
- /** Arc's profile directory basename the Space belongs to. Authoritative id. */
24
- profileId: string;
25
- /** Display-only Arc profile name from Local State. Never used for addressing. */
26
- profileName: string;
27
- /** Stable Space id used for every native operation. */
28
- spaceId: string;
29
- /** Display-only Space title. */
30
- spaceTitle: string;
31
- }
32
- /** A crash-safe native create intent persisted before Arc is asked to mutate. */
33
- export interface ArcNativeCreateIntent {
34
- tabId: string;
35
- markerUrl: string;
36
- targetUrl: string;
37
- createdAt: number;
38
- /** Active tab before creation, restored only if the owned tab stayed active. */
39
- previousTabId?: string;
40
- /** Written immediately after the driver returns, before final navigation. */
41
- ref?: ArcNativeTabRef;
42
- }
43
- /** Durable Arc state owned by one browser task. */
44
- export interface ArcNativeTaskState {
45
- profileId: string;
46
- /** Original Arc window id. A tab moved elsewhere is never adopted. */
47
- windowId: string;
48
- spaceId: string;
49
- /** Display-only snapshot for status output. */
50
- spaceTitle: string;
51
- tabs: Record<string, ArcNativeTabRef>;
52
- createIntents?: Record<string, ArcNativeCreateIntent>;
53
- }
54
- /**
55
- * The user-facing name of a profile — what `agents browser profiles list`
56
- * prints and what `--profile <name>` takes. ALWAYS bare: it never carries an
57
- * `@<endpoint>` suffix or a `.<fork>` suffix. `BrowserProfile.name` is one.
58
- */
59
- export type ProfileName = string;
60
- /**
61
- * The key of an endpoint preset within a profile (`endpoint-0`, `local`, …) —
62
- * see {@link EndpointPreset} and `getEndpointPresets`.
63
- */
64
- export type EndpointName = string;
65
- /**
66
- * The RUNTIME key a live browser is registered under: `<profile>@<endpoint>`,
67
- * plus an optional `.<n>` fork suffix for Electron forks. It keys
68
- * `BrowserService.connections`, the profile's runtime dir, its `tasks.json`,
69
- * and its capture dirs — so one YAML profile can run at several endpoints
70
- * concurrently without colliding on disk.
71
- *
72
- * It is BRANDED on purpose. Before RUSH-2709 both this and a {@link ProfileName}
73
- * were bare `string`s and `start()` overwrote `BrowserProfile.name` with the
74
- * composite, so a connection key leaked into every user-facing listing and six
75
- * consumers each invented their own rule for turning one back into the other.
76
- * The brand makes `connections.get(someProfileName)` — the exact miss behind
77
- * `status --profile comet-local` returning EMPTY for a live
78
- * `comet-local@endpoint-0` — a compile error. Build one ONLY with
79
- * {@link connectionKey} (deriving) or {@link asConnectionKey} (adopting a name
80
- * that is already a runtime key, e.g. a directory read off disk).
81
- */
82
- export type ConnectionKey = string & {
83
- readonly __connectionKey: unique symbol;
84
- };
85
- /** The single site that derives a {@link ConnectionKey} from its two parts. */
86
- export declare function connectionKey(profile: ProfileName, endpoint: EndpointName): ConnectionKey;
87
- /**
88
- * Adopt a string that IS already a runtime key — a runtime directory name, a
89
- * `tasks.json` `profile` field, a fork key. Never use it to launder a bare
90
- * profile name into a key; use {@link connectionKey} for that.
91
- */
92
- export declare function asConnectionKey(raw: string): ConnectionKey;
93
- /**
94
- * Split a {@link ConnectionKey} back into its parts. The inverse of
95
- * {@link connectionKey}, and the ONE rule every consumer uses to decide whether
96
- * a runtime key belongs to a profile.
97
- *
98
- * Tolerates the legacy shape still on disk: a pre-composite key that is just
99
- * the bare profile name (`comet-local`).
100
- *
101
- * A key with no `@` is read as a WHOLE profile name, never as `<name>.<fork>`,
102
- * because nothing constrains a profile's name (`createProfile` checks only for
103
- * a duplicate name and a port collision). Reading the trailing digits as a fork
104
- * would let `stop --profile chrome` claim the runtime dirs of a separate
105
- * profile named `chrome.2` and kill its browser. A fork is only ever created
106
- * from a composite base (`forkElectronProfile` appends to a `<p>@<e>` key), so
107
- * the `@`-bearing branch below is the one that must understand forks.
108
- */
109
- export declare function parseConnectionKey(key: string): {
110
- profile: ProfileName;
111
- endpoint?: EndpointName;
112
- fork?: number;
113
- };
114
- /** True when `key` is a runtime key of `profile`. The only reconciliation rule. */
115
- export declare function keyBelongsToProfile(key: string, profile: ProfileName): boolean;
116
- /**
117
- * A single named endpoint preset within a profile. Lets one profile cover
118
- * the local + remote variants of the same app (e.g. an Electron app on this
119
- * Mac vs. on a remote host) instead of forcing two parallel profiles.
120
- *
121
- * Per-endpoint overrides take precedence over profile-level fields.
122
- */
123
- export interface EndpointPreset {
124
- /**
125
- * CDP URL — `cdp://host:port` or `ssh://host?port=N`.
126
- *
127
- * For an SSH target whose remote is Windows, append `&os=windows` (e.g.
128
- * `ssh://user@host?port=9222&os=windows`). The driver then speaks the
129
- * Windows dialect (launch via WMI Win32_Process.Create so the browser
130
- * survives the ssh session, teardown via Get-NetTCPConnection/Stop-Process)
131
- * instead of the POSIX default. The query param is the single source of
132
- * truth for remote-OS selection.
133
- */
134
- target: string;
135
- /** Override the profile-level binary (e.g. a remote host has no local binary). */
136
- binary?: string;
137
- /** Override the profile-level targetFilter (Electron app builds may diverge). */
138
- targetFilter?: string;
139
- }
140
- export interface BrowserProfile {
141
- /**
142
- * The user-facing profile name, ALWAYS bare — never `name@endpoint`. The
143
- * runtime key that carries the endpoint is a separate value
144
- * ({@link ConnectionKey}); nothing may write one here.
145
- */
146
- name: ProfileName;
147
- description?: string;
148
- browser: BrowserType;
149
- binary?: string;
150
- electron?: boolean;
151
- /**
152
- * `url:<substring>` or `title:<substring>`. Picks which CDP page target
153
- * represents the visible UI for Electron apps with multiple WebContents.
154
- */
155
- targetFilter?: string;
156
- /**
157
- * Endpoint presets. Accepts two shapes for backward compatibility:
158
- * - Legacy: `string[]` of CDP URLs; first entry is the default.
159
- * - New: `{ [presetName]: EndpointPreset }`, with optional `defaultEndpoint`.
160
- * Normalize via `resolveEndpoint(profile, name?)` instead of reading directly.
161
- */
162
- endpoints: string[] | Record<string, EndpointPreset>;
163
- defaultEndpoint?: string;
164
- /**
165
- * How agents obtain a live browser for this profile (PHNX-3967):
166
- * - `launch` (default when absent): spawn the browser under a managed
167
- * `--user-data-dir` when nothing is serving CDP on the port.
168
- * - `attach-only`: NEVER spawn a rival window — attach to a browser the user
169
- * already started with remote debugging, else fail loud with a relaunch
170
- * hint. Arc is inherently attach-only; a canonical signed-in Comet uses it.
171
- * Pairs with a durable {@link userDataDir}.
172
- */
173
- launchPolicy?: 'attach-only' | 'launch';
174
- /**
175
- * Absolute durable `--user-data-dir` for this profile (PHNX-3967). When absent,
176
- * an attach-only profile resolves a default durable dir outside `.cache` so a
177
- * one-time sign-in survives relaunch. The value the ownership guard compares a
178
- * running instance against to reject a port-squatter. Resolve via
179
- * `resolveProfileDataDir(profile)` rather than reading directly.
180
- */
181
- userDataDir?: string;
182
- /** Chromium profile directory inside `userDataDir` for a discovered native profile (PHNX-4042). */
183
- profileDirectory?: string;
184
- chrome?: ChromeOptions;
185
- secrets?: string;
186
- viewport?: {
187
- width: number;
188
- height: number;
189
- x?: number;
190
- y?: number;
191
- };
192
- /** Directory holding source-side JSONL logs (e.g. ~/.rush/logs). */
193
- logDir?: string;
194
- /** Optional SSH host where logDir lives, e.g. "user@remote-host". */
195
- logHost?: string;
196
- /** Native Arc identity. Present only for an `arc-native:` profile. */
197
- arc?: ArcNativeProfileIdentity;
198
- /**
199
- * The Firefox profile this agents-cli profile is pinned to (PHNX-4043).
200
- * Present only for a `bidi:` profile discovered from `profiles.ini`; the
201
- * directory itself is {@link userDataDir}, which is what Firefox is launched
202
- * with (`--profile <dir>`).
203
- */
204
- firefox?: FirefoxProfileIdentity;
205
- }
206
- /**
207
- * Stable identity of a Firefox profile discovered from `profiles.ini` (PHNX-4043).
208
- * One agents-cli profile is one Firefox profile: it already carries the cookies
209
- * and logins, so agents never learn a second concept.
210
- */
211
- export interface FirefoxProfileIdentity {
212
- /** The `Name=` of the `[ProfileN]` section. Display + slug source only. */
213
- profileName: string;
214
- /** The `profiles.ini` the entry was read from. Display only. */
215
- iniPath: string;
216
- /** Whether `profiles.ini` marks the entry `Default=1`. Display only. */
217
- isDefault: boolean;
218
- }
219
- /** Parsed form of `BrowserProfile.targetFilter`. */
220
- export interface TargetFilter {
221
- kind: 'url' | 'title';
222
- value: string;
223
- }
224
- export interface ChromeOptions {
225
- headless?: boolean;
226
- args?: string[];
227
- viewport?: {
228
- width: number;
229
- height: number;
230
- x?: number;
231
- y?: number;
232
- };
233
- /** The browser's own user-data dir; set only for a discovered native profile (PHNX-4042). */
234
- userDataDir?: string;
235
- /** Chromium profile directory inside `userDataDir` (`Default`, `Profile 1`, ...). */
236
- profileDirectory?: string;
237
- }
238
- export interface Task {
239
- id: string;
240
- /**
241
- * Unique addressable handle used as the tasks map key, capture-dir name, and
242
- * the value agents export as `$AGENTS_BROWSER_TASK`. Prefer the short `id`
243
- * for auto-generated tasks; an explicit `--task` name still wins.
244
- */
245
- name: string;
246
- /**
247
- * Human-readable label for `browser status`. Derived once from `--title`,
248
- * else the first navigated host, else `untitled`. Distinct from `name` so a
249
- * short machine id can stay addressable while status stays readable.
250
- */
251
- label?: string;
252
- /**
253
- * The RUNTIME key of the browser this task lives on (`<profile>@<endpoint>`),
254
- * not the bare profile name — it addresses the runtime dir this task's
255
- * `tasks.json` and captures are written under. Use
256
- * {@link parseConnectionKey} to get the user-facing name out of it.
257
- */
258
- profile: ConnectionKey;
259
- /** shortId -> CDP target id, or native tab id mirrored from arcNative.tabs. */
260
- tabs: Record<string, string>;
261
- /**
262
- * Tabs this task DRIVES but did not create, by shortId — a tab that already
263
- * existed in the browser and was reused because the browser cannot open new
264
- * ones (legacy CDP Arc is one example). Every close path
265
- * skips these: the task never opened the tab, so closing it on `done` would
266
- * take away something that was there first. Same rule `adoptTabShowing`
267
- * states for unowned pages, kept when reuse is unavoidable rather than
268
- * optional.
269
- */
270
- borrowedTabs?: string[];
271
- currentTabId?: string;
272
- createdAt: number;
273
- /**
274
- * When this task last did anything. Stamped at creation (equal to
275
- * `createdAt`) and refreshed by every task-scoped action, because every one
276
- * of them resolves the task through `BrowserService.findTask`.
277
- *
278
- * Read by the idle half of the abandoned-task reaper (`hygiene.ts`): a task
279
- * nobody has driven for `idleMs` is stopped so its tabs stop piling up in the
280
- * profile window (RUSH-2622).
281
- *
282
- * Persisted in tasks.json. Tasks written before RUSH-2622 carry none;
283
- * `loadTaskState` normalizes those to `createdAt` on read, so every task in
284
- * memory has one and the reaper never has to guess.
285
- */
286
- lastActionAt: number;
287
- pid: number;
288
- /**
289
- * Resolved actor id (`resolveActor().id`) stamped at task start — WHO launched
290
- * this browser task (a person/agent identity, stable across runs). Forwarded
291
- * from the caller over IPC — the daemon is shared, so it cannot resolve the
292
- * caller's actor itself. Optional: tasks persisted before RUSH-2020 carry none.
293
- */
294
- owner?: string;
295
- /**
296
- * The caller's per-run launch id (`$AGENT_LAUNCH_ID`, minted by exec.ts for
297
- * every harness) stamped at task start — WHICH run created this task. Distinct
298
- * from `owner`: two runs by the same actor get different launchIds, which is
299
- * the scope the current-task default and `status --mine` filter on. Forwarded
300
- * from the caller over IPC. Optional: tasks from before this shipped carry none.
301
- */
302
- launchId?: string;
303
- /**
304
- * The agent session that started this task (`$AGENT_SESSION_ID`), forwarded
305
- * from the caller at `start`. The durable copy lives in the `browser_sessions`
306
- * table, which survives `stop`; this in-memory/tasks.json copy is the live one
307
- * (RUSH-2549).
308
- */
309
- sessionId?: string;
310
- /**
311
- * Per-tab snapshot of the last ref listing captured for that tab
312
- * (shortId -> {descriptors, opts}). Persisted to tasks.json so a later
313
- * `click`/`type <ref>` can self-heal a drifted ref — the cached `opts` let
314
- * the action rebuild its node map with the SAME accessibility filter the
315
- * listing was numbered against. Owned by `refs()`; actions never overwrite
316
- * it. See RefSnapshot / RefDescriptor.
317
- */
318
- refDescriptors?: Record<string, import('./refs.js').RefSnapshot>;
319
- /** Durable stable native ids and crash-intent ledger for an Arc task. */
320
- arcNative?: ArcNativeTaskState;
321
- }
322
- export interface TabInfo {
323
- id: string;
324
- url: string;
325
- title: string;
326
- task: string;
327
- /** Whether this is the task's current tab (the one URL-less verbs act on). */
328
- current?: boolean;
329
- }
330
- /**
331
- * One row of `agents browser tabs --all`: a top-level tab open in the profile's
332
- * browser. Owned by an agents-cli task → `task` names it and `id` is that
333
- * task's short tab id; otherwise (the owner's own tab, or a tab from another
334
- * tool) `task` is absent and `id` is the browser's own tab id.
335
- */
336
- export interface ProfileTabInfo {
337
- id: string;
338
- url: string;
339
- title: string;
340
- task?: string;
341
- /** The queried task's current tab. */
342
- current?: boolean;
343
- }
344
- export interface ProfileStatus {
345
- /**
346
- * The BARE profile name — what the user passed to `--profile` and what
347
- * `status` prints. The endpoint is reported separately in {@link endpoint};
348
- * the raw runtime key (if a caller genuinely needs it) is {@link key}.
349
- */
350
- name: ProfileName;
351
- /** Endpoint preset this browser is running at, when the key carries one. */
352
- endpoint?: EndpointName;
353
- /** The runtime key backing this status: `<profile>@<endpoint>[.<fork>]`. */
354
- key?: ConnectionKey;
355
- running: boolean;
356
- port?: number;
357
- pid?: number;
358
- /** The port declared in the profile's first endpoint, when it differs from the running port. */
359
- configuredPort?: number;
360
- tasks: TaskStatus[];
361
- /**
362
- * Why this profile's live state could not be read, when it could not be.
363
- *
364
- * `status` is read-only, so one unreadable profile must not hide the others:
365
- * the profile is still listed, with what is known from disk, and this says
366
- * what is missing. Absent means the read succeeded — it is never set to paper
367
- * over a failure that did not happen.
368
- */
369
- unavailable?: string;
370
- }
371
- export interface TaskStatus {
372
- id: string;
373
- name: string;
374
- /** Human label for status tables; falls back to name when absent. */
375
- label?: string;
376
- tabCount: number;
377
- currentTabId?: string;
378
- createdAt: number;
379
- endedAt?: number;
380
- domains?: string[];
381
- tabs?: Array<{
382
- id: string;
383
- url: string;
384
- title?: string;
385
- current?: boolean;
386
- task?: string;
387
- }>;
388
- /**
389
- * Why this task's live tabs could not be enumerated, when they could not be.
390
- *
391
- * Set together with an ABSENT {@link tabs} — the recorded {@link tabCount}
392
- * still reports what the task owns on disk, but nothing claims those tabs are
393
- * live, because that is exactly what could not be verified. An Arc tab moved
394
- * to another window or Space is the case this exists for.
395
- */
396
- unavailable?: string;
397
- }
398
- export interface HistoricalTask {
399
- id: string;
400
- name: string;
401
- profile: string;
402
- createdAt: number;
403
- endedAt: number;
404
- domains: string[];
405
- tabCount: number;
406
- /** Actor id who launched the task (RUSH-2020); absent for pre-RUSH-2020 history. */
407
- owner?: string;
408
- }
409
- /**
410
- * Why the reaper stopped a task. `session-dead` — the agent session (or run)
411
- * that started it is provably gone; `idle` — nothing has driven it for the
412
- * idle window. See `hygiene.ts`.
413
- */
414
- export type ReapReason = 'session-dead' | 'idle';
415
- /** One task the reaper stopped (or, under `dryRun`, would have stopped). */
416
- export interface ReapedTask {
417
- task: string;
418
- profile: string;
419
- reason: ReapReason;
420
- }
421
- export interface ReapResult {
422
- closed: ReapedTask[];
423
- /** Tasks left alone this pass: still live, still inside the idle window, or recording. */
424
- skipped: number;
425
- }
426
- export type IPCAction = 'start' | 'show' | 'gc' | 'record-start' | 'record-stop' | 'done' | 'stop' | 'status' | 'history' | 'navigate' | 'tab-add' | 'tab-focus' | 'tab-close' | 'tab-list' | 'evaluate' | 'screenshot' | 'pdf' | 'refs' | 'click' | 'type' | 'press' | 'hover' | 'scroll' | 'set-viewport' | 'set-device' | 'console' | 'errors' | 'requests' | 'response-body' | 'wait' | 'set-download-path' | 'wait-download' | 'upload' | 'getAppLogs' | 'version' | 'request-self-update';
427
- export interface IPCRequest {
428
- action: IPCAction;
429
- task?: string;
430
- taskName?: string;
431
- /** tab-list: every tab open in the profile browser, not only the task's own. */
432
- all?: boolean;
433
- profile?: string;
434
- url?: string;
435
- tabId?: string;
436
- expr?: string;
437
- path?: string;
438
- ref?: number;
439
- atX?: number;
440
- atY?: number;
441
- text?: string;
442
- key?: string;
443
- scrollX?: number;
444
- scrollY?: number;
445
- scrollAtX?: number;
446
- scrollAtY?: number;
447
- interactive?: boolean;
448
- limit?: number;
449
- width?: number;
450
- height?: number;
451
- deviceName?: string;
452
- mobile?: boolean;
453
- deviceScaleFactor?: number;
454
- level?: 'log' | 'info' | 'warn' | 'error';
455
- clear?: boolean;
456
- filter?: string;
457
- urlPattern?: string;
458
- maxChars?: number;
459
- waitType?: 'time' | 'selector' | 'url' | 'function' | 'load';
460
- waitValue?: string | number;
461
- timeout?: number;
462
- downloadPath?: string;
463
- files?: string[];
464
- trigger?: number;
465
- uploadMode?: 'auto' | 'input' | 'drop' | 'chooser';
466
- quality?: 'compressed' | 'raw';
467
- endpoint?: string;
468
- fps?: number;
469
- duration?: number;
470
- maxMb?: number;
471
- source?: string;
472
- lines?: number;
473
- message?: string;
474
- since?: string;
475
- until?: string;
476
- appLevel?: string;
477
- skipDomainSkill?: boolean;
478
- /**
479
- * Explicit human label for a new task (`agents browser start --title …`).
480
- * When omitted, the label is derived from the first navigated host.
481
- */
482
- title?: string;
483
- /**
484
- * Browser start: always open a new tab. Without it, `start --url` reclaims a
485
- * tab that an ABANDONED task is still holding on this exact URL rather than
486
- * opening a duplicate (RUSH-2622). A tab held by a live task, or one nobody's
487
- * task owns (the user's own), is never taken either way — set this when the
488
- * caller wants its own tab regardless.
489
- */
490
- fresh?: boolean;
491
- idleMinutes?: number;
492
- dryRun?: boolean;
493
- actor?: string;
494
- launchId?: string;
495
- /**
496
- * The calling agent session (`$AGENT_SESSION_ID` / `$AGENTS_SESSION_ID`) —
497
- * the id that answers "which agent drove this task" and the one persisted to
498
- * `browser_sessions` (RUSH-2549).
499
- *
500
- * This is the primary identity, not a spare: `launchId` alone was the join
501
- * key, and a fleet measurement found it present on only 2 of 5 live agent
502
- * processes while a session id was on 5 of 5 — every agent reaching the
503
- * browser carries one. It is the same env `stampProvenance()` already reads
504
- * for `computer.action` events, so both tool surfaces key on one signal.
505
- */
506
- sessionId?: string;
507
- /**
508
- * True when the CLI process that issued this request was itself dispatched to
509
- * this machine by a fleet `--device` hop.
510
- *
511
- * Stamped client-side for the same reason actor/launchId are — and
512
- * additionally because the daemon may have been auto-started BY a fleet-remote
513
- * CLI and inherited AGENTS_FLEET_REMOTE for its whole life (startDetached
514
- * passes `env: opts.env ?? process.env`). The daemon's own env is therefore
515
- * not a truthful signal about the CURRENT caller; only the request is.
516
- */
517
- fleetRemote?: boolean;
518
- /**
519
- * SERVER-INTERNAL, never trusted off the wire (PHNX-2399). When a page verb's
520
- * `bindTask` implicitly CREATED the task and `start` already opened the URL,
521
- * the daemon stamps the resulting {@link PageOpenResult} here so the handler
522
- * reports that first open truthfully (adopt → created:false, Arc/Electron
523
- * reuse → created:false, fresh tab → created:true) WITHOUT re-executing the
524
- * URL. `bindTask` clears any client-supplied value before binding.
525
- */
526
- firstOpen?: PageOpenResult;
527
- }
528
- /**
529
- * The outcome of opening/showing a URL on a task tab (PHNX-2399): the ONE shared
530
- * shape `navigate` / `tab add` / `start`'s first-open all report, so no surface
531
- * has to re-derive created/refreshed from ad-hoc booleans.
532
- * - `created` — a NEW page target was opened.
533
- * - `refreshed` — an existing OWNED tab showing this URL was reloaded in place.
534
- * - neither — an existing tab was reused as-is (adopted abandoned tab, or
535
- * navigated the current tab to a different URL).
536
- * `created` and `refreshed` are mutually exclusive.
537
- */
538
- export interface PageOpenResult {
539
- tabId?: string;
540
- created: boolean;
541
- refreshed: boolean;
542
- message?: string;
543
- }
544
- export interface IPCResponse {
545
- ok: boolean;
546
- error?: string;
547
- task?: string;
548
- tabId?: string;
549
- /**
550
- * navigate / tab-add: whether this action OPENED a new page target (true) or
551
- * acted on an existing owned tab (false). A same-task reopen — the requested
552
- * URL was already live in one of the task's own tabs — reports `created: false`
553
- * with `refreshed: true`, so the caller can say "opened" vs "refreshed" honestly.
554
- */
555
- created?: boolean;
556
- /**
557
- * navigate / tab-add: the requested URL was already open in an owned tab, so
558
- * that SAME tab was reloaded in place (same tabId) rather than a duplicate
559
- * opened. Mutually exclusive with `created: true`.
560
- */
561
- refreshed?: boolean;
562
- /**
563
- * start: a same-name retry matched an existing task and REUSED it (task-level,
564
- * distinct from the page-level `created`/`refreshed`). A no-URL retry is
565
- * `reused: true` with `refreshed: undefined` — it did no page operation, so it
566
- * must NOT read as a refresh (PHNX-2399).
567
- */
568
- reused?: boolean;
569
- windowTargetId?: string;
570
- /** `tab-list` rows; `task` is absent for a tab no agents-cli task owns (`--all`). */
571
- tabs?: ProfileTabInfo[];
572
- profiles?: ProfileStatus[];
573
- history?: HistoricalTask[];
574
- /** `gc`: what the abandoned-task reaper closed (or would close under dryRun). */
575
- reaped?: ReapResult;
576
- result?: unknown;
577
- path?: string;
578
- bytes?: number;
579
- width?: number;
580
- height?: number;
581
- refs?: string;
582
- nodes?: RefNodeJson[];
583
- /** Human-readable note surfaced to the CLI (e.g. a self-heal notice on click). */
584
- message?: string;
585
- port?: number;
586
- pid?: number;
587
- fps?: number;
588
- durationCapSec?: number;
589
- maxMb?: number;
590
- durationMs?: number;
591
- stopReason?: 'manual' | 'duration-cap' | 'size-cap';
592
- logs?: ConsoleEntry[];
593
- errors?: ErrorEntry[];
594
- requests?: NetworkRequest[];
595
- body?: string;
596
- downloadPath?: string;
597
- devices?: string[];
598
- uploadMode?: 'input' | 'drop' | 'chooser';
599
- appLogs?: any[];
600
- version?: string;
601
- selfUpdateTriggered?: boolean;
602
- reason?: string;
603
- skill?: {
604
- name: string;
605
- path: string;
606
- content: string;
607
- hostname: string;
608
- };
609
- }
610
- export interface ConsoleEntry {
611
- level: 'log' | 'info' | 'warn' | 'error';
612
- text: string;
613
- timestamp: number;
614
- url?: string;
615
- line?: number;
616
- }
617
- export interface ErrorEntry {
618
- message: string;
619
- stack?: string;
620
- timestamp: number;
621
- url?: string;
622
- line?: number;
623
- }
624
- export interface NetworkRequest {
625
- id: string;
626
- url: string;
627
- method: string;
628
- status?: number;
629
- mimeType?: string;
630
- timestamp: number;
631
- }
632
- export interface RefNodeJson {
633
- ref: number;
634
- role: string;
635
- name: string;
636
- attrs: string[];
637
- editor?: string;
638
- }
639
- export interface DeviceDescriptor {
640
- width: number;
641
- height: number;
642
- deviceScaleFactor: number;
643
- mobile: boolean;
644
- }
645
- export declare function isValidTaskId(id: string): boolean;
646
- export declare function generateTaskId(): string;
647
- export declare function generateShortId(): string;