@phnx-labs/agents-cli 1.22.117 → 1.22.118

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 (248) hide show
  1. package/CHANGELOG.md +235 -0
  2. package/dist/bootstrap.js +4 -11
  3. package/dist/commands/browser.d.ts +52 -70
  4. package/dist/commands/browser.js +192 -3562
  5. package/dist/commands/daemon.d.ts +39 -2
  6. package/dist/commands/daemon.js +72 -73
  7. package/dist/commands/events.js +1 -1
  8. package/dist/commands/exec.js +53 -1
  9. package/dist/commands/repo.js +13 -49
  10. package/dist/commands/route.js +5 -5
  11. package/dist/commands/routines.js +39 -12
  12. package/dist/commands/sessions-render.d.ts +1 -1
  13. package/dist/commands/sessions-render.js +0 -1
  14. package/dist/commands/sessions.test-fixture.d.ts +0 -1
  15. package/dist/commands/sessions.test-fixture.js +0 -37
  16. package/dist/commands/setup-browser.d.ts +17 -12
  17. package/dist/commands/setup-browser.js +52 -87
  18. package/dist/commands/setup-preferences.d.ts +0 -17
  19. package/dist/commands/setup-preferences.js +18 -49
  20. package/dist/commands/setup.js +9 -9
  21. package/dist/commands/ssh.js +10 -1
  22. package/dist/commands/sync.js +6 -44
  23. package/dist/commands/teams.js +0 -1
  24. package/dist/commands/update.d.ts +19 -0
  25. package/dist/commands/update.js +34 -6
  26. package/dist/commands/view.d.ts +12 -1
  27. package/dist/commands/view.js +47 -2
  28. package/dist/index.js +107 -26
  29. package/dist/lib/account-capabilities.js +0 -2
  30. package/dist/lib/account-catalog.d.ts +38 -0
  31. package/dist/lib/account-catalog.js +110 -26
  32. package/dist/lib/account-provider-registry.js +1 -1
  33. package/dist/lib/account-registry.d.ts +1 -1
  34. package/dist/lib/account-registry.js +36 -2
  35. package/dist/lib/accounting/rotate.js +22 -8
  36. package/dist/lib/accounting/usage-ingest.d.ts +6 -1
  37. package/dist/lib/accounting/usage-ingest.js +115 -45
  38. package/dist/lib/accounting/usage-sync.d.ts +134 -31
  39. package/dist/lib/accounting/usage-sync.js +227 -66
  40. package/dist/lib/accounting/usage.d.ts +16 -3
  41. package/dist/lib/accounting/usage.js +26 -8
  42. package/dist/lib/accounts/slots.d.ts +8 -0
  43. package/dist/lib/accounts/slots.js +17 -0
  44. package/dist/lib/add-dir.js +0 -1
  45. package/dist/lib/agent-cli-commands.js +0 -1
  46. package/dist/lib/agent-spec/agents.d.ts +6 -7
  47. package/dist/lib/agent-spec/agents.js +6 -60
  48. package/dist/lib/auth-health.d.ts +69 -1
  49. package/dist/lib/auth-health.js +133 -4
  50. package/dist/lib/browser/context.d.ts +82 -0
  51. package/dist/lib/browser/context.js +88 -0
  52. package/dist/lib/browser/paths.d.ts +25 -0
  53. package/dist/lib/browser/paths.js +51 -0
  54. package/dist/lib/browser/record.d.ts +38 -0
  55. package/dist/lib/browser/record.js +57 -0
  56. package/dist/lib/browser/sessions-list.js +1 -2
  57. package/dist/lib/browser-client.d.ts +158 -0
  58. package/dist/lib/browser-client.js +234 -0
  59. package/dist/lib/channels/owner-sink.d.ts +1 -18
  60. package/dist/lib/channels/owner-sink.js +29 -82
  61. package/dist/lib/channels/providers/rush.d.ts +7 -7
  62. package/dist/lib/channels/providers/rush.js +127 -57
  63. package/dist/lib/claude-statusline.d.ts +1 -1
  64. package/dist/lib/claude-statusline.js +15 -3
  65. package/dist/lib/commands.js +1 -1
  66. package/dist/lib/crabbox/lease.js +1 -1
  67. package/dist/lib/crabbox/runtimes.js +1 -3
  68. package/dist/lib/daemon/account-state-daemon-service.js +1 -0
  69. package/dist/lib/daemon/auth-sync-service.d.ts +21 -18
  70. package/dist/lib/daemon/auth-sync-service.js +37 -43
  71. package/dist/lib/daemon/daemon.d.ts +25 -14
  72. package/dist/lib/daemon/daemon.js +92 -154
  73. package/dist/lib/daemon/runner.d.ts +2 -2
  74. package/dist/lib/daemon/runner.js +32 -9
  75. package/dist/lib/daemon/self-update-service.d.ts +35 -34
  76. package/dist/lib/daemon/self-update-service.js +40 -36
  77. package/dist/lib/daemon/service.d.ts +12 -8
  78. package/dist/lib/daemon/supervisor.d.ts +65 -54
  79. package/dist/lib/daemon/supervisor.js +136 -171
  80. package/dist/lib/daemon/testdata/process-view-start.js +5 -2
  81. package/dist/lib/daemon/usage-sync-service.d.ts +21 -30
  82. package/dist/lib/daemon/usage-sync-service.js +46 -78
  83. package/dist/lib/daemon-health.d.ts +22 -5
  84. package/dist/lib/daemon-health.js +47 -3
  85. package/dist/lib/daemon-services.d.ts +1 -1
  86. package/dist/lib/daemon-services.js +0 -10
  87. package/dist/lib/daemon-ticks.js +4 -2
  88. package/dist/lib/devices/doctor-findings.js +8 -11
  89. package/dist/lib/devices/harness-inventory.js +14 -5
  90. package/dist/lib/exec-account-home.js +5 -0
  91. package/dist/lib/exec.js +0 -11
  92. package/dist/lib/feed/events.js +0 -1
  93. package/dist/lib/feed/tool-activity.js +5 -2
  94. package/dist/lib/fleet-shared-state.d.ts +45 -0
  95. package/dist/lib/fleet-shared-state.js +78 -9
  96. package/dist/lib/fs-atomic.js +25 -0
  97. package/dist/lib/harness-auth-capabilities.js +0 -1
  98. package/dist/lib/helper-versions.js +1 -1
  99. package/dist/lib/hooks/cache.d.ts +7 -0
  100. package/dist/lib/hooks/cache.js +27 -2
  101. package/dist/lib/hooks/install.js +7 -1
  102. package/dist/lib/hosts/ready.d.ts +38 -8
  103. package/dist/lib/hosts/ready.js +62 -14
  104. package/dist/lib/installations/active-check.d.ts +27 -0
  105. package/dist/lib/installations/active-check.js +61 -0
  106. package/dist/lib/installations/migrate.js +6 -3
  107. package/dist/lib/installations/shims.js +9 -7
  108. package/dist/lib/installations/update.js +21 -15
  109. package/dist/lib/installations/versions.js +12 -1
  110. package/dist/lib/manifest.js +1 -1
  111. package/dist/lib/models.js +0 -2
  112. package/dist/lib/open-url.js +28 -54
  113. package/dist/lib/profiles.js +0 -2
  114. package/dist/lib/refresh.js +1 -1
  115. package/dist/lib/routine-readiness.d.ts +35 -0
  116. package/dist/lib/routine-readiness.js +74 -16
  117. package/dist/lib/rules/compile.js +6 -0
  118. package/dist/lib/sandbox.js +0 -2
  119. package/dist/lib/secrets-policy.d.ts +89 -11
  120. package/dist/lib/secrets-policy.js +175 -28
  121. package/dist/lib/session/db.d.ts +1 -1
  122. package/dist/lib/session/db.js +65 -18
  123. package/dist/lib/session/discover.js +1 -283
  124. package/dist/lib/session/mirror.d.ts +4 -3
  125. package/dist/lib/session/mirror.js +4 -3
  126. package/dist/lib/session/parse.d.ts +0 -2
  127. package/dist/lib/session/parse.js +1 -138
  128. package/dist/lib/session/throughput.d.ts +1 -3
  129. package/dist/lib/session/throughput.js +0 -20
  130. package/dist/lib/session/types.d.ts +2 -2
  131. package/dist/lib/session/types.js +2 -2
  132. package/dist/lib/sessions-client.d.ts +60 -1
  133. package/dist/lib/sessions-client.js +227 -4
  134. package/dist/lib/setup-tool-status.js +5 -10
  135. package/dist/lib/signin-badge.d.ts +3 -2
  136. package/dist/lib/signin-badge.js +6 -3
  137. package/dist/lib/smart-launch.js +4 -1
  138. package/dist/lib/staleness/detectors/commands.d.ts +1 -1
  139. package/dist/lib/staleness/detectors/hooks.d.ts +1 -1
  140. package/dist/lib/staleness/detectors/mcp.d.ts +1 -1
  141. package/dist/lib/staleness/detectors/permissions.d.ts +1 -1
  142. package/dist/lib/staleness/detectors/plugins.d.ts +1 -1
  143. package/dist/lib/staleness/detectors/rules.d.ts +1 -1
  144. package/dist/lib/staleness/detectors/skills.d.ts +1 -1
  145. package/dist/lib/staleness/detectors/subagents.d.ts +1 -1
  146. package/dist/lib/staleness/detectors/workflows.d.ts +1 -1
  147. package/dist/lib/staleness/writers/commands.d.ts +1 -1
  148. package/dist/lib/staleness/writers/hooks.d.ts +1 -1
  149. package/dist/lib/staleness/writers/mcp.d.ts +1 -1
  150. package/dist/lib/staleness/writers/permissions.d.ts +1 -1
  151. package/dist/lib/staleness/writers/plugins.d.ts +1 -1
  152. package/dist/lib/staleness/writers/rules.d.ts +1 -1
  153. package/dist/lib/staleness/writers/skills.d.ts +1 -1
  154. package/dist/lib/staleness/writers/sources.js +5 -0
  155. package/dist/lib/staleness/writers/subagents.d.ts +1 -1
  156. package/dist/lib/staleness/writers/workflows.d.ts +1 -1
  157. package/dist/lib/state.d.ts +6 -4
  158. package/dist/lib/state.js +7 -17
  159. package/dist/lib/teams/parsers.d.ts +1 -1
  160. package/dist/lib/teams/parsers.js +1 -136
  161. package/dist/lib/teams/placement-probe.js +50 -15
  162. package/dist/lib/teams/scheduler.d.ts +7 -0
  163. package/dist/lib/types.d.ts +10 -1
  164. package/dist/lib/types.js +1 -1
  165. package/dist/lib/view-types.d.ts +32 -0
  166. package/dist/lib/watchdog/read.js +0 -1
  167. package/dist/lib/watchdog/rotate.js +1 -2
  168. package/dist/lib/watchdog/runner.js +2 -2
  169. package/dist/lib/watchdog/watchdog.d.ts +1 -1
  170. package/dist/lib/watchdog/watchdogTail.js +0 -31
  171. package/package.json +1 -1
  172. package/scripts/postinstall.js +8 -8
  173. package/dist/browser.d.ts +0 -2
  174. package/dist/browser.js +0 -17
  175. package/dist/commands/browser-picker.d.ts +0 -18
  176. package/dist/commands/browser-picker.js +0 -97
  177. package/dist/lib/browser/arc-discovery.d.ts +0 -52
  178. package/dist/lib/browser/arc-discovery.js +0 -197
  179. package/dist/lib/browser/arc-dom.d.ts +0 -14
  180. package/dist/lib/browser/arc-dom.js +0 -121
  181. package/dist/lib/browser/caller-identity.d.ts +0 -40
  182. package/dist/lib/browser/caller-identity.js +0 -175
  183. package/dist/lib/browser/cdp.d.ts +0 -51
  184. package/dist/lib/browser/cdp.js +0 -254
  185. package/dist/lib/browser/chrome.d.ts +0 -141
  186. package/dist/lib/browser/chrome.js +0 -704
  187. package/dist/lib/browser/chromium-discovery.d.ts +0 -28
  188. package/dist/lib/browser/chromium-discovery.js +0 -96
  189. package/dist/lib/browser/devices.d.ts +0 -34
  190. package/dist/lib/browser/devices.js +0 -61
  191. package/dist/lib/browser/domain-skills.d.ts +0 -71
  192. package/dist/lib/browser/domain-skills.js +0 -195
  193. package/dist/lib/browser/drivers/arc.d.ts +0 -40
  194. package/dist/lib/browser/drivers/arc.js +0 -276
  195. package/dist/lib/browser/drivers/firefox.d.ts +0 -99
  196. package/dist/lib/browser/drivers/firefox.js +0 -377
  197. package/dist/lib/browser/drivers/local.d.ts +0 -55
  198. package/dist/lib/browser/drivers/local.js +0 -266
  199. package/dist/lib/browser/drivers/ssh.d.ts +0 -120
  200. package/dist/lib/browser/drivers/ssh.js +0 -467
  201. package/dist/lib/browser/editor.d.ts +0 -3
  202. package/dist/lib/browser/editor.js +0 -50
  203. package/dist/lib/browser/ffmpeg.d.ts +0 -12
  204. package/dist/lib/browser/ffmpeg.js +0 -184
  205. package/dist/lib/browser/firefox-discovery.d.ts +0 -69
  206. package/dist/lib/browser/firefox-discovery.js +0 -162
  207. package/dist/lib/browser/har.d.ts +0 -85
  208. package/dist/lib/browser/har.js +0 -77
  209. package/dist/lib/browser/hygiene.d.ts +0 -97
  210. package/dist/lib/browser/hygiene.js +0 -153
  211. package/dist/lib/browser/index.d.ts +0 -5
  212. package/dist/lib/browser/index.js +0 -5
  213. package/dist/lib/browser/input.d.ts +0 -7
  214. package/dist/lib/browser/input.js +0 -92
  215. package/dist/lib/browser/ipc.d.ts +0 -204
  216. package/dist/lib/browser/ipc.js +0 -1453
  217. package/dist/lib/browser/login-detection.d.ts +0 -87
  218. package/dist/lib/browser/login-detection.js +0 -274
  219. package/dist/lib/browser/profiles.d.ts +0 -422
  220. package/dist/lib/browser/profiles.js +0 -1157
  221. package/dist/lib/browser/refs.d.ts +0 -89
  222. package/dist/lib/browser/refs.js +0 -191
  223. package/dist/lib/browser/registry.d.ts +0 -70
  224. package/dist/lib/browser/registry.js +0 -252
  225. package/dist/lib/browser/remote-control.d.ts +0 -59
  226. package/dist/lib/browser/remote-control.js +0 -85
  227. package/dist/lib/browser/resolve-target.d.ts +0 -66
  228. package/dist/lib/browser/resolve-target.js +0 -264
  229. package/dist/lib/browser/runtime-state.d.ts +0 -291
  230. package/dist/lib/browser/runtime-state.js +0 -584
  231. package/dist/lib/browser/secret-ref.d.ts +0 -10
  232. package/dist/lib/browser/secret-ref.js +0 -14
  233. package/dist/lib/browser/service.d.ts +0 -812
  234. package/dist/lib/browser/service.js +0 -4693
  235. package/dist/lib/browser/stream.d.ts +0 -17
  236. package/dist/lib/browser/stream.js +0 -72
  237. package/dist/lib/browser/task-index.d.ts +0 -78
  238. package/dist/lib/browser/task-index.js +0 -199
  239. package/dist/lib/browser/types.d.ts +0 -647
  240. package/dist/lib/browser/types.js +0 -61
  241. package/dist/lib/browser/upload.d.ts +0 -29
  242. package/dist/lib/browser/upload.js +0 -298
  243. package/dist/lib/daemon/browser-ipc-service.d.ts +0 -20
  244. package/dist/lib/daemon/browser-ipc-service.js +0 -46
  245. package/dist/lib/daemon/browser-task-reap-service.d.ts +0 -14
  246. package/dist/lib/daemon/browser-task-reap-service.js +0 -26
  247. package/dist/lib/fleet-shared-repo-sync.d.ts +0 -55
  248. package/dist/lib/fleet-shared-repo-sync.js +0 -490
@@ -1,422 +0,0 @@
1
- import type { BrowserProfileConfig } from '../types.js';
2
- import type { BrowserProfile, ProfileName } from './types.js';
3
- export type { BrowserProfile } from './types.js';
4
- export { declaringDevices, profileKind, profileRegistry, type ProfileDeclaration, } from './registry.js';
5
- /**
6
- * Name of the profile the setup wizards pin as this machine's default browser
7
- * (`agents setup`, `agents setup browser`). Older builds also auto-created it
8
- * silently on the first `agents browser start`; PHNX-3296 removed that — see
9
- * {@link ensureDefaultBrowserProfile}.
10
- *
11
- * It is `auto-chrome`, NOT `default`, since RUSH-2709: `default` used to be
12
- * both this concrete profile AND the alias meaning "whatever profile the user
13
- * configured", so `--profile default` landed on a literal Chrome on one command
14
- * and on the user's configured Comet on another. The alias now lives alone in
15
- * {@link DEFAULT_PROFILE_ALIAS} and resolves in exactly one place
16
- * ({@link resolveProfileRef}).
17
- */
18
- export declare const DEFAULT_BROWSER_PROFILE_NAME = "auto-chrome";
19
- /**
20
- * What older builds named the auto-detected profile. Still honored everywhere:
21
- * a user whose machine already carries a `default` profile keeps using it (and
22
- * its running browser + runtime dirs) rather than having a second one created
23
- * beside it.
24
- */
25
- export declare const LEGACY_DEFAULT_BROWSER_PROFILE_NAME = "default";
26
- /**
27
- * The reserved ALIAS. `--profile default` (and a `browser.profile` config value
28
- * of `default`) means "the configured default profile", not a profile called
29
- * `default` — unless a profile literally named `default` exists, which still
30
- * wins, so no existing config breaks.
31
- */
32
- export declare const DEFAULT_PROFILE_ALIAS = "default";
33
- export type BrowserProfileWithDeclarations = BrowserProfile & {
34
- devices: string[];
35
- };
36
- /**
37
- * The device-local configured default profile name (set via
38
- * `agents browser use`), or undefined when unset. When set, it
39
- * is the profile `agents browser start` resolves to for BOTH the no-`--profile`
40
- * path and an explicit `--profile default`. Stored as this machine's
41
- * `browser.profile` device-config key (the per-device doc's `config:` block —
42
- * see lib/device-config.ts).
43
- */
44
- export declare function getConfiguredDefaultProfileName(): string | undefined;
45
- export declare function getBrowserRuntimeDir(): string;
46
- export declare function getProfileRuntimeDir(name: string): string;
47
- /**
48
- * True when a profile attaches to a browser the user already launched and MUST
49
- * NOT spawn its own (PHNX-3967). Arc is inherently attach-only — it is
50
- * single-instance and relaunching it just produces a stray window, never a
51
- * second debuggable process (issue #2779) — regardless of an explicit policy.
52
- * Any other browser is attach-only only when the profile says so.
53
- */
54
- export declare function isAttachOnlyProfile(profile: Pick<BrowserProfile, 'browser' | 'launchPolicy'>): boolean;
55
- /**
56
- * The DURABLE `--user-data-dir` for a profile (PHNX-3967). An explicit
57
- * `profile.userDataDir` wins; otherwise a per-profile dir under
58
- * `~/.agents/.history/browser-profiles/<name>/chrome-data`, which is outside
59
- * `~/.agents/.cache` so a one-time sign-in survives quit+relaunch and the
60
- * `profiles remove` cache sweep. This is the dir the canonical Comet is launched
61
- * with and the value the ownership guard compares a running instance against.
62
- *
63
- * Note this is distinct from {@link getProfileRuntimeDir}'s cache `chrome-data`,
64
- * which `launchBrowser` uses for a `launch`-policy profile it spawns itself.
65
- */
66
- export declare function resolveProfileDataDir(profile: Pick<BrowserProfile, 'name' | 'userDataDir'>): string;
67
- /**
68
- * Normalize a `--user-data-dir` path for the attach-only ownership comparison
69
- * (PHNX-3967): the real path when it resolves on this box, else the literal with
70
- * trailing slashes stripped. The single source both the runtime guard
71
- * (`drivers/local.ts` `verifyEndpointOwnership`) and `browser profiles doctor`
72
- * use, so they can never disagree about whether a running instance is foreign.
73
- */
74
- export declare function normalizeDataDir(dir: string): string;
75
- /**
76
- * Default destination for browser downloads for a profile. Set browser-global at
77
- * connect time (see BrowserService), so downloads land here even when the agent
78
- * never calls `browser download --path`. Keyed by the same composite name as the
79
- * runtime dir, so every profile is one self-contained tree.
80
- */
81
- export declare function getProfileDownloadsDir(name: string): string;
82
- /**
83
- * Per-profile directory for a task's captured artifacts (screenshots, PDFs,
84
- * recordings). Replaces the legacy global `browser/sessions/<task>/` root — the
85
- * one-shot migration in migrate.ts folds old captures into here.
86
- */
87
- export declare function getProfileSessionsDir(name: string, task: string): string;
88
- /**
89
- * Every browser profile this Mac already has, as agents-cli profiles:
90
- *
91
- * - each Arc Space (PHNX-2399): a Space carries its Arc profile's cookies and
92
- * logins, so it IS the browser profile agents pick with `--profile`;
93
- * - each Comet profile from Comet's own `Local State` (PHNX-4042): pinned to
94
- * Comet's user-data dir and profile directory, so the window agents open is
95
- * the owner's window and a sign-in done once serves both.
96
- *
97
- * No second concept: agents see one `--profile` list. Discovery reads files
98
- * the browsers rewrite on every change, so a torn read is an ordinary event,
99
- * not corruption. It is reported as `errors` rather than thrown: the profile
100
- * store serves every browser on this machine, and a momentary Arc read must
101
- * never take the Comet or Chrome rows down with it. An error surfaces where a
102
- * profile of that browser is actually asked for by name.
103
- */
104
- export interface DiscoveredProfiles {
105
- profiles: BrowserProfileWithDeclarations[];
106
- /** Per-browser discovery failures, keyed by the profile-name prefix (`arc`, `comet`). */
107
- errors: Record<string, string>;
108
- }
109
- export declare function discoverNativeProfiles(): DiscoveredProfiles;
110
- /**
111
- * Publish every discovered native profile that this device has not declared
112
- * yet into its device declaration (`~/.agents/devices/<device>/agents.yaml`),
113
- * which the fleet shared-store sync carries to every other box (PHNX-4042).
114
- * That is what lets `agents browser profiles list` on a worker show this
115
- * Mac's `arc-*` and `comet-*` rows with WHERE=<this device>, and a start from
116
- * there route here. Idempotent; a discovery error skips that browser.
117
- */
118
- export declare function publishDiscoveredProfiles(): Promise<{
119
- published: string[];
120
- errors: Record<string, string>;
121
- }>;
122
- /** Whether this name has persisted agents-cli metadata on the current device. */
123
- export declare function isProfileDeclaredHere(name: string): boolean;
124
- export declare function listProfiles(): Promise<BrowserProfileWithDeclarations[]>;
125
- export declare function getProfile(name: string): Promise<BrowserProfileWithDeclarations | null>;
126
- /** Persist only the agents-cli alias for an auto-discovered native profile; never the browser's own data. */
127
- export declare function persistDiscoveredProfile(name: string): Promise<void>;
128
- /**
129
- * True when `profile` can actually launch or attach on THIS machine.
130
- *
131
- * A remote (`ssh://`) profile runs its browser on the far host, so a local
132
- * binary check doesn't apply — assume launchable. A local profile must have its
133
- * configured browser/binary present on disk here; a `default` profile
134
- * auto-created on a different OS (e.g. a macOS Chrome path reused on Linux — the
135
- * "Custom binary not found" failure) fails this check so the caller re-detects
136
- * for the current machine.
137
- */
138
- export declare function isProfileLaunchableHere(profile: BrowserProfile): boolean;
139
- /**
140
- * The auto-detected profile this machine already carries, under either name —
141
- * the current `auto-chrome` or the `default` an older build wrote. Callers that
142
- * ask "is a default profile set up here?" MUST use this rather than probing one
143
- * name, or a machine that predates the RUSH-2709 rename grows a second one.
144
- */
145
- export declare function getAutoDetectedProfile(): Promise<BrowserProfile | null>;
146
- /**
147
- * Resolve what a caller typed after `--profile` to a real, BARE profile name.
148
- * Every command — stop, status, navigate, tab, use, and (through
149
- * {@link resolveProfileRefForStart}) start — routes through this one function,
150
- * which is the whole point: before RUSH-2709 only `start` honored the reserved
151
- * `default` alias, so `--profile default` meant three different profiles across
152
- * three commands.
153
- *
154
- * Order:
155
- * 1. A profile that literally bears the given name always wins — including
156
- * one a user genuinely named `default`, which resolves to itself.
157
- * 2. `default` (the alias) or no argument at all → the configured
158
- * `browser.profile` for this machine, if it names a profile that exists.
159
- * 3. → the auto-detected profile ({@link DEFAULT_BROWSER_PROFILE_NAME}), or
160
- * its legacy `default`-named predecessor when that is what is on disk.
161
- * 4. Otherwise the input is returned unchanged (so the caller reports its own
162
- * `Profile "x" not found`), or `undefined` when nothing was passed.
163
- *
164
- * It never creates a profile, never warns, and never checks whether the profile
165
- * can launch HERE. That is deliberate: for most callers `--profile` is a FILTER
166
- * (`status`, `tasks`, `navigate --task`), where an absent flag means "no filter"
167
- * and rewriting or warning about the user's config would be wrong. Note the
168
- * corollary at those call sites — pass a ref only when the user gave one; do not
169
- * resolve `undefined` into a concrete profile, or an unscoped listing silently
170
- * becomes a scoped one.
171
- */
172
- export declare function resolveProfileRef(ref?: string): Promise<string | undefined>;
173
- /**
174
- * `start`'s resolver. Same order as {@link resolveProfileRef} for an explicit
175
- * name, but the IMPLICIT path (no `--profile`, or the bare `default` alias with
176
- * no profile of that name) goes through {@link ensureDefaultBrowserProfile} —
177
- * which additionally verifies the resolved default can launch on THIS machine.
178
- * An undeclared configured default is an error. A declared default whose
179
- * browser isn't installed here warns and falls through to an existing profile,
180
- * else the actionable throw below.
181
- *
182
- * `start` is the only command that launches a browser, so it is the only one
183
- * that may do those things; routing a filter-only command through this would
184
- * warn about config the user never asked it to touch.
185
- *
186
- * Throws ({@link noDefaultBrowserError}) when the configured default is
187
- * undeclared, or when no profile exists that can launch here.
188
- */
189
- export declare function resolveProfileRefForStart(ref?: string): Promise<string>;
190
- /**
191
- * The error a bare `agents browser start` raises when this machine has no
192
- * launchable default browser. Its own function so the wording — the one thing
193
- * the user reads when a browser won't start — stays in one place and is
194
- * testable without spawning anything.
195
- *
196
- * Since PHNX-3296 this is a hard stop, NOT a silent auto-create. The old
197
- * behavior probed the installed Chromium-family browsers and minted a
198
- * logged-out `auto-chrome` profile on the spot; agents then drove a signed-out
199
- * Chrome that popped up on the user's Mac unbidden. Which browser agents drive
200
- * is a choice the user makes once, in `agents setup` — never one this code
201
- * makes for them.
202
- */
203
- export declare function noDefaultBrowserError(): Error;
204
- /**
205
- * Resolve the profile a bare `agents browser start` uses.
206
- *
207
- * Order: (1) the device-local configured default (`agents browser use <name>`)
208
- * when it names a profile that exists and can launch here; (2) an existing
209
- * auto-detected profile (`auto-chrome`, or a legacy `default`) that can launch
210
- * here. When neither resolves, THROW ({@link noDefaultBrowserError}) rather than
211
- * detect-and-create — see that function for why (PHNX-3296).
212
- *
213
- * Two failure modes at the configured-default step are not the same:
214
- * - No device declares the name (including a leftover central `browser:`
215
- * entry that was never claimed) → throw. Falling back to a minted profile
216
- * would hand the agent a logged-out browser while `browser.profile` still
217
- * names the credentialed one.
218
- * - The name is declared, but its browser/binary is not installed HERE →
219
- * warn and fall through to an existing profile, else the actionable throw.
220
- * That is a missing binary on this box, not a missing identity.
221
- *
222
- * This RECOGNIZES a pre-existing `auto-chrome`/legacy `default` so installs that
223
- * already carry one keep resolving it (and its running browser + runtime dirs),
224
- * but it never CREATES one.
225
- */
226
- export declare function ensureDefaultBrowserProfile(): Promise<BrowserProfile>;
227
- /**
228
- * Compute the LOCAL port a profile will occupy at runtime:
229
- * - `cdp://127.0.0.1:N` → N (we listen on N directly)
230
- * - `ssh://host?port=N` → N (the SSH tunnel binds local N → remote N now)
231
- * - `ws[s]://`, `http[s]://` → undefined (we don't claim a local port)
232
- *
233
- * This is what callers should compare to detect collisions; the (host,
234
- * port) tuple is no longer enough because SSH profiles do compete with
235
- * cdp:// profiles for local ports under the new tunnel scheme.
236
- */
237
- export declare function effectiveLocalPort(profile: BrowserProfile): number | undefined;
238
- /**
239
- * Find a port in 9222–9399 that is not already claimed by ANY existing
240
- * profile (cdp:// or ssh://) and is not in use by any OS process. The
241
- * SSH change to bind locally on `?port=N` means we no longer get to
242
- * skip remote profiles in this scan.
243
- */
244
- export declare function findFreeProfilePort(): Promise<number>;
245
- export declare function hasSshEndpoint(endpoints: BrowserProfileConfig['endpoints']): boolean;
246
- /**
247
- * Whether the automatic central-tombstone drain (PHNX-3315) may claim `config`
248
- * into THIS device's doc during `agents sync`.
249
- *
250
- * Only REMOTE (`ssh://`) profiles qualify. An `ssh://` endpoint names a specific
251
- * host, so the profile is fungible by design — any box resolves it to the same
252
- * browser, and a concurrent double-claim across machines is harmless. A
253
- * local/`cdp://` profile has NO per-machine ownership signal: "that browser is
254
- * installed here" is not "I hold this profile's credentialed session", so two
255
- * boxes with the same common browser installed would each auto-claim the same
256
- * tombstone on their first post-merge sync and flip it identity->fungible
257
- * fleet-wide (the exact logged-out-browser failure this module exists to prevent
258
- * — PHNX-3315 review). Local/cdp tombstones stay central for the explicit
259
- * `agents browser profiles claim`.
260
- */
261
- export declare function shouldAutoClaimCentralProfile(config: BrowserProfileConfig): boolean;
262
- /**
263
- * Refuse a profile whose LOCAL port another profile already owns.
264
- *
265
- * Every CDP/SSH profile ends up listening on (or tunneling to) the same LOCAL
266
- * port number as the one configured in the endpoint URL — SSH profiles reuse
267
- * `?port=N` locally, so we no longer scope by host. Two profiles that would
268
- * need the same local port can't both run at the same time.
269
- *
270
- * `opts.ignore` is the profile's own name on an edit. Without it every edit
271
- * collides with itself, since the stored copy still owns the port being kept.
272
- */
273
- export declare function assertLocalPortFree(profile: BrowserProfile, opts?: {
274
- ignore?: string;
275
- }): void;
276
- /** Declare a profile on this device. The same name may be declared by peers. */
277
- export declare function createProfile(profile: BrowserProfile): Promise<void>;
278
- export declare function updateProfile(profile: BrowserProfile): Promise<void>;
279
- /** Fields an existing profile may be edited in place.
280
- *
281
- * Deliberately a SUBSET of {@link BrowserProfile}. `name` and `browser` are
282
- * identity, not settings: both key the on-disk runtime dir
283
- * ({@link getProfileRuntimeDir}) and any live `<name>@<endpoint>` connection, so
284
- * changing either orphans the cached browser data. Delete and recreate instead.
285
- */
286
- export type EditableProfileFields = Partial<Pick<BrowserProfile, 'description' | 'binary' | 'electron' | 'targetFilter' | 'endpoints' | 'launchPolicy' | 'userDataDir' | 'chrome' | 'secrets' | 'viewport' | 'arc'>>;
287
- export interface EditProfileResult {
288
- profile: BrowserProfile;
289
- devices: string[];
290
- /** Field names that actually changed. Empty means the edit was a no-op. */
291
- changed: string[];
292
- }
293
- /**
294
- * Merge `patch` onto the stored profile and persist it in the store it already
295
- * lives in (see {@link updateProfile} for the scope rules).
296
- *
297
- * Runs {@link createProfile}'s validations against the MERGED record, not just
298
- * the patched fields — a binary edit re-resolves the browser path, a
299
- * targetFilter edit re-checks the electron gate, and the local-port scan runs
300
- * with this profile excluded so an unchanged port is not a self-collision.
301
- */
302
- export declare function editProfile(name: string, patch: EditableProfileFields): Promise<EditProfileResult>;
303
- /**
304
- * Throw if `name` cannot be used for a NEW profile.
305
- *
306
- * Shared by `profiles create` and {@link renameProfile} so the two cannot drift
307
- * — the shape rule used to live inline in the command, which is how `rename`
308
- * would have accepted a name `create` rejects.
309
- *
310
- * `default` is refused because it is the reserved ALIAS meaning "whatever
311
- * profile this machine is configured to use" (RUSH-2709). A literal profile by
312
- * that name makes `--profile default` mean two different things.
313
- */
314
- export declare function assertRegistrableProfileName(name: string): void;
315
- /**
316
- * Rename a profile, taking its on-disk state with it.
317
- *
318
- * `editProfile` deliberately refuses a name change, and this is why: the name
319
- * keys the runtime dir ({@link getProfileRuntimeDir}), every fork/endpoint dir
320
- * derived from it, and the `browser.profile` pointer. Delete-and-recreate — the
321
- * only route before this — silently abandons the browser's `--user-data-dir`,
322
- * which is where a profile's logins live. On a real agent browser that is
323
- * gigabytes of session state and every account it has ever signed into.
324
- *
325
- * Refuses when the profile is in use: moving a `--user-data-dir` out from under
326
- * a running browser corrupts it.
327
- */
328
- export declare function renameProfile(from: ProfileName, to: ProfileName): Promise<{
329
- devices: string[];
330
- movedDirs: string[];
331
- repointedDefault: boolean;
332
- repointedViewer: boolean;
333
- /** Peers still pinning the OLD name, and which key each used. */
334
- stalePins: Array<{
335
- device: string;
336
- key: 'browser.profile' | 'browser.viewer';
337
- }>;
338
- }>;
339
- export declare function deleteProfile(name: string): Promise<void>;
340
- /**
341
- * Pad `text` to exactly `width` visible characters, truncating with an ellipsis
342
- * when it does not fit. `padEnd` alone does NOT bound a long value — it returns
343
- * the string unchanged when it already exceeds the width, which is what pushed
344
- * every later column out of alignment on a name longer than 20 characters
345
- * (RUSH-2710). Every column here goes through this, never a bare `padEnd`.
346
- */
347
- export declare function padColumn(text: string, width: number): string;
348
- /**
349
- * Render the `agents browser profiles list` table.
350
- *
351
- * Pure (no fs, no config reads) so the alignment and the default-marking rules
352
- * are unit-testable without a configured machine.
353
- *
354
- * Two things used to be called "default" in this listing with no way to tell
355
- * them apart (RUSH-2710): the profile literally NAMED `default` (the
356
- * auto-detected one), and whichever profile this machine resolves a bare
357
- * `agents browser start` to (`agents browser use <name>`). They
358
- * are frequently different profiles. Now only the second is a marker — a `*` in
359
- * a leading column, explained by a legend line — so the name column carries just
360
- * the name and `default` in it always means the profile of that name.
361
- *
362
- * WHERE lists the devices whose own files declare the name.
363
- */
364
- export declare function formatProfilesTable(rows: BrowserProfileWithDeclarations[], configuredDefault?: string): string[];
365
- /**
366
- * Resolve a profile's endpoint presets into a normalized map regardless of
367
- * whether the YAML uses the legacy `string[]` shape or the new map shape.
368
- * The legacy entries get auto-named `endpoint-0`, `endpoint-1`, ... .
369
- */
370
- export declare function getEndpointPresets(profile: BrowserProfile): Record<string, import('./types.js').EndpointPreset>;
371
- /**
372
- * Pick the endpoint preset to use. Order:
373
- * 1. Explicit name passed in (errors if unknown)
374
- * 2. `profile.defaultEndpoint` if set
375
- * 3. First entry (preserves legacy string[] behavior)
376
- *
377
- * Returns the resolved name + the preset (with per-endpoint overrides
378
- * already applied to binary / targetFilter), so callers don't have to
379
- * remember the precedence rules.
380
- */
381
- export declare function resolveEndpoint(profile: BrowserProfile, endpointName?: string): {
382
- name: string;
383
- target: string;
384
- binary?: string;
385
- targetFilter?: string;
386
- };
387
- /**
388
- * Extract the (host, port) pair intended by the profile's default endpoint.
389
- * Returns undefined for endpoint shapes that don't carry a port (e.g. ws:// without one).
390
- *
391
- * Ports are scoped by host: a `cdp://127.0.0.1:9222` profile (local Chrome on
392
- * this machine) and an `ssh://remote-host:9222` profile (Comet on a remote
393
- * host) point at different physical ports — the host disambiguates them.
394
- *
395
- * Accepts both `scheme://host:port` and `scheme://host?port=N` shapes (the
396
- * latter is the documented form in `types.ts` for `ssh://`). Without this,
397
- * `ssh://remote-host?port=18805` would silently fall back to 9222 and every
398
- * `?port=`-style SSH profile would collide on creation.
399
- */
400
- export declare function extractConfiguredEndpoint(profile: BrowserProfile): {
401
- host: string;
402
- port: number;
403
- } | undefined;
404
- /**
405
- * Shared endpoint parser used by both the collision-detection code path and
406
- * the connection drivers. Returning a single normalized `(host, port)` here
407
- * keeps `extractConfiguredEndpoint` and the SSH driver from drifting on URL
408
- * conventions (which is how `?port=N` ended up being silently ignored).
409
- */
410
- export declare function parseEndpointUrl(endpoint: string): {
411
- host: string;
412
- port: number;
413
- } | undefined;
414
- /**
415
- * Extract the port intended by the profile's default endpoint.
416
- * Returns undefined for endpoint shapes that don't carry a port (e.g. ws:// without one).
417
- *
418
- * Note: this loses the host dimension — for collision detection use
419
- * `extractConfiguredEndpoint` instead, which returns the (host, port) pair.
420
- */
421
- export declare function extractConfiguredPort(profile: BrowserProfile): number | undefined;
422
- export declare function isLocalHost(host: string): boolean;