@phnx-labs/agents-cli 1.22.93 → 1.22.95

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 (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/commands/browser.d.ts +1 -0
  3. package/dist/commands/browser.js +156 -11
  4. package/dist/lib/browser/arc-discovery.d.ts +60 -0
  5. package/dist/lib/browser/arc-discovery.js +187 -0
  6. package/dist/lib/browser/arc-dom.d.ts +14 -0
  7. package/dist/lib/browser/arc-dom.js +121 -0
  8. package/dist/lib/browser/chrome.d.ts +17 -0
  9. package/dist/lib/browser/chrome.js +121 -16
  10. package/dist/lib/browser/chromium-discovery.d.ts +27 -0
  11. package/dist/lib/browser/chromium-discovery.js +96 -0
  12. package/dist/lib/browser/drivers/arc.d.ts +57 -0
  13. package/dist/lib/browser/drivers/arc.js +281 -0
  14. package/dist/lib/browser/drivers/firefox.d.ts +103 -0
  15. package/dist/lib/browser/drivers/firefox.js +377 -0
  16. package/dist/lib/browser/drivers/local.d.ts +8 -0
  17. package/dist/lib/browser/drivers/local.js +38 -3
  18. package/dist/lib/browser/firefox-discovery.d.ts +68 -0
  19. package/dist/lib/browser/firefox-discovery.js +162 -0
  20. package/dist/lib/browser/profiles.d.ts +39 -1
  21. package/dist/lib/browser/profiles.js +239 -9
  22. package/dist/lib/browser/refs.d.ts +2 -0
  23. package/dist/lib/browser/refs.js +2 -1
  24. package/dist/lib/browser/resolve-target.d.ts +2 -0
  25. package/dist/lib/browser/resolve-target.js +14 -0
  26. package/dist/lib/browser/runtime-state.js +9 -1
  27. package/dist/lib/browser/service.d.ts +86 -3
  28. package/dist/lib/browser/service.js +1045 -42
  29. package/dist/lib/browser/types.d.ts +85 -2
  30. package/dist/lib/daemon/usage-sync-service.js +12 -0
  31. package/dist/lib/open-url.js +6 -0
  32. package/dist/lib/types.d.ts +20 -1
  33. package/package.json +1 -1
@@ -1,4 +1,56 @@
1
- export type BrowserType = 'chrome' | 'comet' | 'chromium' | 'brave' | 'edge' | 'arc' | 'custom';
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
+ }
2
54
  /**
3
55
  * The user-facing name of a profile — what `agents browser profiles list`
4
56
  * prints and what `--profile <name>` takes. ALWAYS bare: it never carries an
@@ -127,6 +179,8 @@ export interface BrowserProfile {
127
179
  * `resolveProfileDataDir(profile)` rather than reading directly.
128
180
  */
129
181
  userDataDir?: string;
182
+ /** Chromium profile directory inside `userDataDir` for a discovered native profile (PHNX-4042). */
183
+ profileDirectory?: string;
130
184
  chrome?: ChromeOptions;
131
185
  secrets?: string;
132
186
  viewport?: {
@@ -139,6 +193,28 @@ export interface BrowserProfile {
139
193
  logDir?: string;
140
194
  /** Optional SSH host where logDir lives, e.g. "user@remote-host". */
141
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;
142
218
  }
143
219
  /** Parsed form of `BrowserProfile.targetFilter`. */
144
220
  export interface TargetFilter {
@@ -154,6 +230,10 @@ export interface ChromeOptions {
154
230
  x?: number;
155
231
  y?: number;
156
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;
157
237
  }
158
238
  export interface Task {
159
239
  id: string;
@@ -176,11 +256,12 @@ export interface Task {
176
256
  * {@link parseConnectionKey} to get the user-facing name out of it.
177
257
  */
178
258
  profile: ConnectionKey;
259
+ /** shortId -> CDP target id, or native tab id mirrored from arcNative.tabs. */
179
260
  tabs: Record<string, string>;
180
261
  /**
181
262
  * Tabs this task DRIVES but did not create, by shortId — a tab that already
182
263
  * existed in the browser and was reused because the browser cannot open new
183
- * ones (Arc: `Target.createTarget` crashes it, #2778/#2786). Every close path
264
+ * ones (legacy CDP Arc is one example). Every close path
184
265
  * skips these: the task never opened the tab, so closing it on `done` would
185
266
  * take away something that was there first. Same rule `adoptTabShowing`
186
267
  * states for unowned pages, kept when reuse is unavoidable rather than
@@ -235,6 +316,8 @@ export interface Task {
235
316
  * it. See RefSnapshot / RefDescriptor.
236
317
  */
237
318
  refDescriptors?: Record<string, import('./refs.js').RefSnapshot>;
319
+ /** Durable stable native ids and crash-intent ledger for an Arc task. */
320
+ arcNative?: ArcNativeTaskState;
238
321
  }
239
322
  export interface TabInfo {
240
323
  id: string;
@@ -32,6 +32,18 @@ export class UsageSyncService extends BasePeriodicService {
32
32
  const { consumeUsageSnapshotsFromSharedStore, publishUsageSnapshotToSharedStore } = await import('../accounting/usage-sync.js');
33
33
  const { consumeSessionMirrorFromSharedStore, publishSessionMirrorToSharedStore } = await import('../session/mirror.js');
34
34
  // Publish every owned field BEFORE the single git exchange so they ride one commit.
35
+ // Discovered native browser profiles (Arc Spaces, Comet profiles) go into this
36
+ // device's declaration first, so every other box lists them with WHERE=<here>
37
+ // and routes a `--profile` for one of them to this machine (PHNX-4042).
38
+ const { publishDiscoveredProfiles } = await import('../browser/profiles.js');
39
+ const profiles = await publishDiscoveredProfiles().catch((error) => ({
40
+ published: [],
41
+ errors: { publish: error instanceof Error ? error.message : String(error) },
42
+ }));
43
+ if (profiles.published.length > 0)
44
+ ctx.log('INFO', `browser-profiles: published ${profiles.published.join(', ')} to this device's declaration`);
45
+ for (const [browser, message] of Object.entries(profiles.errors))
46
+ ctx.log('WARN', `browser-profiles: ${browser}: ${message}`);
35
47
  const published = await publishUsageSnapshotToSharedStore();
36
48
  if (published.changed)
37
49
  ctx.log('INFO', `usage-sync: published usage snapshot to ${published.path}`);
@@ -135,6 +135,12 @@ export async function resolveViewer(opts = {}) {
135
135
  console.error(`[viewer] "${resolved}" is Arc, which cannot open a new viewer tab — using the OS browser.`);
136
136
  return 'os';
137
137
  }
138
+ if (profile.browser === 'firefox') {
139
+ // agents drives Firefox headless over BiDi for its own read-back; a page a
140
+ // human is meant to read goes to the visible OS browser, not the headless one.
141
+ console.error(`[viewer] "${resolved}" is a headless-automation Firefox profile — using the OS browser.`);
142
+ return 'os';
143
+ }
138
144
  if (!isProfileLaunchableHere(profile)) {
139
145
  console.error(`[viewer] "${resolved}" cannot launch on this machine — using the OS browser.`);
140
146
  return 'os';
@@ -1245,7 +1245,7 @@ export interface HostEntry {
1245
1245
  /** Browser profile definition stored in agents.yaml. */
1246
1246
  export interface BrowserProfileConfig {
1247
1247
  description?: string;
1248
- browser: 'chrome' | 'comet' | 'chromium' | 'brave' | 'edge' | 'arc' | 'custom';
1248
+ browser: 'chrome' | 'comet' | 'chromium' | 'brave' | 'edge' | 'arc' | 'firefox' | 'custom';
1249
1249
  binary?: string;
1250
1250
  electron?: boolean;
1251
1251
  /**
@@ -1290,6 +1290,12 @@ export interface BrowserProfileConfig {
1290
1290
  * ownership guard compares a running instance against to reject a port-squatter.
1291
1291
  */
1292
1292
  userDataDir?: string;
1293
+ /**
1294
+ * Chromium profile directory inside {@link userDataDir} (`Default`,
1295
+ * `Profile 1`, ...) for a profile discovered from the browser's own store
1296
+ * (PHNX-4042). Launch passes it as `--profile-directory`.
1297
+ */
1298
+ profileDirectory?: string;
1293
1299
  chrome?: {
1294
1300
  headless?: boolean;
1295
1301
  args?: string[];
@@ -1303,6 +1309,19 @@ export interface BrowserProfileConfig {
1303
1309
  logDir?: string;
1304
1310
  /** Optional SSH host where logDir lives, e.g. "user@remote-host". */
1305
1311
  logHost?: string;
1312
+ /** Stable native identity for an Arc Space profile; display names are never addresses. */
1313
+ arc?: {
1314
+ profileId: string;
1315
+ profileName: string;
1316
+ spaceId: string;
1317
+ spaceTitle: string;
1318
+ };
1319
+ /** The `profiles.ini` entry a discovered Firefox profile is pinned to (PHNX-4043); the dir is `userDataDir`. */
1320
+ firefox?: {
1321
+ profileName: string;
1322
+ iniPath: string;
1323
+ isDefault: boolean;
1324
+ };
1306
1325
  }
1307
1326
  /** Options controlling which agents and resources are synced during `agents sync` / `agents use`. */
1308
1327
  export interface SyncOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phnx-labs/agents-cli",
3
- "version": "1.22.93",
3
+ "version": "1.22.95",
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",