@hivey/cli 0.9.74 → 0.9.75

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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hivey/cli",
3
- "version": "0.9.74",
3
+ "version": "0.9.75",
4
4
  "description": "All your AI swarms, one terminal: a workspace and lead agent for teams of Claude Code and Codex agents",
5
5
  "keywords": [
6
6
  "hivey",
@@ -17,7 +17,10 @@ Desktop pets that act out what hivey's agents do. Choose one (or none) with `hiv
17
17
  - `pet.py`: `hivey pet` (build, install to `~/Applications`, switch, off, show). The
18
18
  choice is in `~/.hivey/pet.json`; `hivey update` runs `hivey pet refresh` to rebuild it when
19
19
  its source changed.
20
- - Chat: clicking a pet opens `HiveyChat` (a box above it); Enter sends the text to the hivey
20
+ - Click: right-click → On click ▸ picks what a click does (`PetClick`, shared): open the agent fleet
21
+ (default; `hivey agent-map fleet` refreshes and fronts the fleet tab already open in Chrome, or opens
22
+ it in a new Chrome window) or the chat box. The menu's "Open agent fleet" and "Chat with hivey" items do either anytime.
23
+ - Chat: "Chat with hivey" (or a click, when picked) opens `HiveyChat` (a box above it); Enter sends the text to the hivey
21
24
  agent (`hivey msg send hivey/master`), whose reply to `human` the pet shows and says
22
25
  (`replyLine`). Other agents' replies are announced as "<agent> replied.".
23
26
  - Lifecycle: every hivey window writes `~/.hivey/windows/<pid>` while open and runs
@@ -34,7 +34,8 @@ Professional "harness" look: a dark graphite satin sphere (key light upper-left,
34
34
  - `build.sh` — builds universal (arm64 + x86_64, macOS 12+) ad-hoc-signed `Hivey System.app` and `dist/HiveySystem.zip` for sharing. Run after every change.
35
35
 
36
36
  ## Behavior
37
- - Click = chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
37
+ - Click = the action picked in right-click → On click ▸ (`PetClick`, shared): **Open agent fleet** (default; `hivey agent-map fleet` reloads and fronts the fleet tab already open in Chrome, or opens it in a new Chrome window) or **Open chat box**. The menu also has "Open agent fleet" and "Chat with hivey" items, whatever the click does.
38
+ - Chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
38
39
  - Lives in the hivey repo (`pets/hivey-dot/`). Built and installed by `hivey pet use hivey-dot` (into `~/Applications`; the other pets are quit); `./build.sh` compiles `main.swift` with the shared `../shared/HiveyWatch.swift`.
39
40
  - Right-click: hivey status line ("hivey: N agents, M working"), Watch hivey, Speak aloud, Effects (preview only) ▸ (plays the pet's moves; nothing happens in hivey), Switch pet ▸ (Hivey / Hivey Prompt / Hivey, via `hivey pet use`), Turn off pet (`hivey pet off`), Quit.
40
41
  - Watches hivey through the shared `HiveyWatcher` (every 2s: `hivey swarm list --json` + `hivey msg log --json`, default session, never starts a server, nothing replayed on first look). Spoken aloud: "<slug> is starting.", "<agent> needs you.", "<agent> replied."; "<agent> finished." is bubble-only; one line per look, most urgent first.
@@ -43,7 +44,7 @@ Professional "harness" look: a dark graphite satin sphere (key light upper-left,
43
44
  - Event CLI: `Hivey.app/Contents/MacOS/hivey agent|leave|swarm|pulse|done ["text"]` (DistributedNotification `com.hivey.pet.event`).
44
45
  - On launch: fades in, small restrained lift + mint glow, says "Welcome! I'm Hivey." (bubble + voice). Always visible, floats above windows, on all Spaces.
45
46
  - Idle: agents travel the signal wave (`signalPoint`, depth-sorted behind/in front of Hivey), breathing, blinking, eyes follow the cursor, occasional message pulse between agents.
46
- - Click = small lift + glow, and the chat box opens (see above).
47
+ - Click = small lift + glow, then the click action (see above).
47
48
  - Effects (preview only) ▸: New agent (dot flies out, max 9), Swarm formation (dots arc above Hivey, frequent pulses, 5s), Task finished (lift + glow), Quit.
48
49
  - A crew-motion variant (no orbit; idle groups, errands, listen/swarm/tidy formations) was tried on 2026-10-02 and rejected — user prefers the orbit.
49
50
  - Drag = move (position autosaved as `HiveyPet`).
@@ -508,6 +508,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
508
508
  private let hiveyItem = NSMenuItem(title: "hivey: looking…", action: nil, keyEquivalent: "")
509
509
  private let watcher = HiveyWatcher()
510
510
  private let chat = HiveyChat()
511
+ private lazy var clicks = PetClickMenu(
512
+ chat: { [weak self] in guard let self else { return }; chat.toggle(above: window) },
513
+ say: { [weak self] in self?.say($0, aloud: false) })
511
514
  private lazy var switcher = PetSwitcher(current: "hivey-dot", say: { [weak self] in self?.say($0, aloud: false) },
512
515
  turnOffHere: { [weak self] in self?.turnOff() })
513
516
  private var watching: Bool {
@@ -561,14 +564,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
561
564
  effectsItem.submenu = effects
562
565
  menu.addItem(effectsItem)
563
566
  menu.addItem(.separator())
567
+ clicks.addItems(to: menu)
568
+ menu.addItem(.separator())
564
569
  switcher.addItems(to: menu)
565
570
  menu.addItem(withTitle: "Quit Hivey", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")
566
571
  pet.menu = menu
567
- // Click: talk to the hivey agent (a chat box above the pet); drag still moves it
572
+ // Click: the agent fleet page or the chat box (On click ▸); drag still moves it
568
573
  pet.onPoke = { [weak self] in
569
574
  guard let self else { return }
570
575
  pet.celebrate()
571
- chat.toggle(above: window)
576
+ clicks.click() // right-click → On click ▸: agent fleet (default) or chat box
572
577
  }
573
578
  chat.say = { [weak self] text, aloud in self?.say(text, aloud: aloud) }
574
579
  chat.onSent = { [weak self] in self?.pet.pulse() }
@@ -39,7 +39,8 @@ A living, three-dimensional "H": the software conductor whose body shows how it
39
39
  - `build.sh` — builds universal (arm64 + x86_64, macOS 12+) ad-hoc-signed `Hivey.app` and `dist/Hivey.zip`. Run after every change.
40
40
 
41
41
  ## Behavior
42
- - Click = chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
42
+ - Click = the action picked in right-click → On click ▸ (`PetClick`, shared): **Open agent fleet** (default; `hivey agent-map fleet` reloads and fronts the fleet tab already open in Chrome, or opens it in a new Chrome window) or **Open chat box**. The menu also has "Open agent fleet" and "Chat with hivey" items, whatever the click does.
43
+ - Chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
43
44
  - Lives in the hivey repo (`pets/hivey-h/`). Built and installed by `hivey pet use hivey-h` (into `~/Applications`; the other pets are quit); `./build.sh` compiles `main.swift` with the shared `../shared/HiveyWatch.swift`.
44
45
  - Right-click: hivey status line ("hivey: N agents, M working"), Watch hivey, Speak aloud, Effects (preview only) ▸ (plays the pet's moves; nothing happens in hivey), Switch pet ▸ (Hivey / Hivey Prompt / Hivey, via `hivey pet use`), Turn off pet (`hivey pet off`), Quit.
45
46
  - Watches hivey through the shared `HiveyWatcher` (every 2s: `hivey swarm list --json` + `hivey msg log --json`, default session, never starts a server, nothing replayed on first look). Spoken aloud: "<slug> is starting.", "<agent> needs you.", "<agent> replied."; "<agent> finished." is bubble-only; one line per look, most urgent first.
@@ -492,6 +492,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
492
492
  private let hiveyItem = NSMenuItem(title: "hivey: looking…", action: nil, keyEquivalent: "")
493
493
  private let watcher = HiveyWatcher()
494
494
  private let chat = HiveyChat()
495
+ private lazy var clicks = PetClickMenu(
496
+ chat: { [weak self] in guard let self else { return }; chat.toggle(above: window) },
497
+ say: { [weak self] in self?.say($0, aloud: false) })
495
498
  private lazy var switcher = PetSwitcher(current: "hivey-h", say: { [weak self] in self?.say($0, aloud: false) },
496
499
  turnOffHere: { [weak self] in self?.turnOff() })
497
500
  private var watching: Bool {
@@ -543,14 +546,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
543
546
  effectsItem.submenu = effects
544
547
  menu.addItem(effectsItem)
545
548
  menu.addItem(.separator())
549
+ clicks.addItems(to: menu)
550
+ menu.addItem(.separator())
546
551
  switcher.addItems(to: menu)
547
552
  menu.addItem(withTitle: "Quit Hivey", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")
548
553
  pet.menu = menu
549
- // Click: talk to the hivey agent (a chat box above the pet); drag still moves it
554
+ // Click: the agent fleet page or the chat box (On click ▸); drag still moves it
550
555
  pet.onPoke = { [weak self] in
551
556
  guard let self else { return }
552
557
  pet.listen()
553
- chat.toggle(above: window)
558
+ clicks.click() // right-click → On click ▸: agent fleet (default) or chat box
554
559
  }
555
560
  chat.say = { [weak self] text, aloud in self?.say(text, aloud: aloud) }
556
561
  chat.onSent = { [weak self] in self?.pet.listen(for: 3) }
@@ -35,7 +35,8 @@ A three-dimensional satin sphere: deep charcoal-teal body, crisp mint `>_` face,
35
35
  - `build.sh` — builds universal (arm64 + x86_64, macOS 12+) ad-hoc-signed `Hivey Prompt.app` and `dist/HiveyPrompt.zip`. Run after every change.
36
36
 
37
37
  ## Behavior
38
- - Click = chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
38
+ - Click = the action picked in right-click → On click ▸ (`PetClick`, shared): **Open agent fleet** (default; `hivey agent-map fleet` reloads and fronts the fleet tab already open in Chrome, or opens it in a new Chrome window) or **Open chat box**. The menu also has "Open agent fleet" and "Chat with hivey" items, whatever the click does.
39
+ - Chat box above the pet (`HiveyChat`): Enter sends to the hivey agent (`hivey msg send hivey/master`), Esc / clicking away closes; the agent's reply to `human` is shown in the bubble and said aloud. Drag still moves the pet.
39
40
  - Lives in the hivey repo (`pets/hivey-prompt/`). Built and installed by `hivey pet use hivey-prompt` (into `~/Applications`; the other pets are quit); `./build.sh` compiles `main.swift` with the shared `../shared/HiveyWatch.swift`.
40
41
  - Right-click: hivey status line ("hivey: N agents, M working"), Watch hivey, Speak aloud, Effects (preview only) ▸ (plays the pet's moves; nothing happens in hivey), Switch pet ▸ (Hivey / Hivey Prompt / Hivey, via `hivey pet use`), Turn off pet (`hivey pet off`), Quit.
41
42
  - Watches hivey through the shared `HiveyWatcher` (every 2s: `hivey swarm list --json` + `hivey msg log --json`, default session, never starts a server, nothing replayed on first look). Spoken aloud: "<slug> is starting.", "<agent> needs you.", "<agent> replied."; "<agent> finished." is bubble-only; one line per look, most urgent first.
@@ -445,6 +445,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
445
445
  private let hiveyItem = NSMenuItem(title: "hivey: looking…", action: nil, keyEquivalent: "")
446
446
  private let watcher = HiveyWatcher()
447
447
  private let chat = HiveyChat()
448
+ private lazy var clicks = PetClickMenu(
449
+ chat: { [weak self] in guard let self else { return }; chat.toggle(above: window) },
450
+ say: { [weak self] in self?.say($0, aloud: false) })
448
451
  private lazy var switcher = PetSwitcher(current: "hivey-prompt", say: { [weak self] in self?.say($0, aloud: false) },
449
452
  turnOffHere: { [weak self] in self?.turnOff() })
450
453
  private var watching: Bool {
@@ -499,14 +502,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
499
502
  effectsItem.submenu = effects
500
503
  menu.addItem(effectsItem)
501
504
  menu.addItem(.separator())
505
+ clicks.addItems(to: menu)
506
+ menu.addItem(.separator())
502
507
  switcher.addItems(to: menu)
503
508
  menu.addItem(withTitle: "Quit Hivey Prompt", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")
504
509
  pet.menu = menu
505
- // Click: talk to the hivey agent (a chat box above the pet); drag still moves it
510
+ // Click: the agent fleet page or the chat box (On click ▸); drag still moves it
506
511
  pet.onPoke = { [weak self] in
507
512
  guard let self else { return }
508
513
  pet.attend()
509
- chat.toggle(above: window)
514
+ clicks.click() // right-click → On click ▸: agent fleet (default) or chat box
510
515
  }
511
516
  chat.say = { [weak self] text, aloud in self?.say(text, aloud: aloud) }
512
517
  chat.onSent = { [weak self] in self?.pet.attend() }
@@ -242,28 +242,102 @@ final class PetSwitcher: NSObject {
242
242
  @objc private func turnOff() {
243
243
  if !runHivey(["pet", "off"]) { turnOffHere() }
244
244
  }
245
+ }
245
246
 
246
- /// Runs `hivey <args>` detached (it may outlive this pet); false when hivey isn't installed.
247
- private func runHivey(_ args: [String]) -> Bool {
248
- guard let hivey = HiveyWatcher().findHivey() else { return false }
249
- let p = Process()
250
- p.executableURL = URL(fileURLWithPath: hivey)
251
- p.arguments = args
252
- p.currentDirectoryURL = URL(fileURLWithPath: NSHomeDirectory())
253
- // What happened lands in ~/.hivey/pet.log (a switch builds for a minute; errors matter)
254
- let log = URL(fileURLWithPath: NSHomeDirectory() + "/.hivey/pet.log")
255
- try? FileManager.default.createDirectory(at: log.deletingLastPathComponent(), withIntermediateDirectories: true)
256
- if !FileManager.default.fileExists(atPath: log.path) { FileManager.default.createFile(atPath: log.path, contents: nil) }
257
- if let handle = try? FileHandle(forWritingTo: log) {
258
- handle.seekToEndOfFile()
259
- handle.write(Data("\n\(Date()) hivey \(args.joined(separator: " "))\n".utf8))
260
- p.standardOutput = handle
261
- p.standardError = handle
262
- } else {
263
- p.standardOutput = FileHandle.nullDevice
264
- p.standardError = FileHandle.nullDevice
247
+ /// Runs `hivey <args>` detached (it may outlive this pet); false when hivey isn't installed.
248
+ func runHivey(_ args: [String]) -> Bool {
249
+ guard let hivey = HiveyWatcher().findHivey() else { return false }
250
+ let p = Process()
251
+ p.executableURL = URL(fileURLWithPath: hivey)
252
+ p.arguments = args
253
+ p.currentDirectoryURL = URL(fileURLWithPath: NSHomeDirectory())
254
+ // What happened lands in ~/.hivey/pet.log (a switch builds for a minute; errors matter)
255
+ let log = URL(fileURLWithPath: NSHomeDirectory() + "/.hivey/pet.log")
256
+ try? FileManager.default.createDirectory(at: log.deletingLastPathComponent(), withIntermediateDirectories: true)
257
+ if !FileManager.default.fileExists(atPath: log.path) { FileManager.default.createFile(atPath: log.path, contents: nil) }
258
+ if let handle = try? FileHandle(forWritingTo: log) {
259
+ handle.seekToEndOfFile()
260
+ handle.write(Data("\n\(Date()) hivey \(args.joined(separator: " "))\n".utf8))
261
+ p.standardOutput = handle
262
+ p.standardError = handle
263
+ } else {
264
+ p.standardOutput = FileHandle.nullDevice
265
+ p.standardError = FileHandle.nullDevice
266
+ }
267
+ return (try? p.run()) != nil
268
+ }
269
+
270
+ // MARK: - What a click on the pet does
271
+
272
+ /// The pet's click action, picked in its right-click menu (On click ▸) and kept per pet.
273
+ enum PetClick: String, CaseIterable {
274
+ /// Bring up the agent fleet page: the Chrome tab already showing it, refreshed, or a new one
275
+ case fleet
276
+ /// The chat box above the pet (`HiveyChat`)
277
+ case chat
278
+
279
+ var title: String {
280
+ switch self {
281
+ case .fleet: return "Open agent fleet"
282
+ case .chat: return "Open chat box"
265
283
  }
266
- return (try? p.run()) != nil
284
+ }
285
+
286
+ static var current: PetClick {
287
+ get { UserDefaults.standard.string(forKey: "clickAction").flatMap(PetClick.init) ?? .fleet }
288
+ set { UserDefaults.standard.set(newValue.rawValue, forKey: "clickAction") }
289
+ }
290
+ }
291
+
292
+ /// "Open agent fleet", "Chat with hivey" and "On click ▸" for a pet's right-click menu, and the
293
+ /// click itself. The fleet runs `hivey agent-map fleet`, which reloads and fronts an open fleet
294
+ /// tab in Chrome or opens one.
295
+ final class PetClickMenu: NSObject {
296
+ private let chat: () -> Void
297
+ private let say: (String) -> Void
298
+ private var choiceItems: [NSMenuItem] = []
299
+
300
+ /// `chat`: open/close the chat box; `say`: a bubble line from the pet
301
+ init(chat: @escaping () -> Void, say: @escaping (String) -> Void) {
302
+ self.chat = chat
303
+ self.say = say
304
+ }
305
+
306
+ func click() {
307
+ switch PetClick.current {
308
+ case .fleet: openFleet()
309
+ case .chat: chat()
310
+ }
311
+ }
312
+
313
+ func addItems(to menu: NSMenu) {
314
+ menu.addItem(withTitle: "Open agent fleet", action: #selector(fleetItem), keyEquivalent: "").target = self
315
+ menu.addItem(withTitle: "Chat with hivey", action: #selector(chatItem), keyEquivalent: "").target = self
316
+ let onClick = NSMenuItem(title: "On click", action: nil, keyEquivalent: "")
317
+ let submenu = NSMenu()
318
+ for action in PetClick.allCases {
319
+ let item = submenu.addItem(withTitle: action.title, action: #selector(choose(_:)), keyEquivalent: "")
320
+ item.target = self
321
+ item.representedObject = action.rawValue
322
+ item.state = action == PetClick.current ? .on : .off
323
+ choiceItems.append(item)
324
+ }
325
+ onClick.submenu = submenu
326
+ menu.addItem(onClick)
327
+ }
328
+
329
+ func openFleet() {
330
+ guard runHivey(["agent-map", "fleet"]) else { say("I need hivey to open the fleet."); return }
331
+ say("Opening the agent fleet…")
332
+ }
333
+
334
+ @objc private func fleetItem() { openFleet() }
335
+ @objc private func chatItem() { chat() }
336
+
337
+ @objc private func choose(_ item: NSMenuItem) {
338
+ guard let raw = item.representedObject as? String, let action = PetClick(rawValue: raw) else { return }
339
+ PetClick.current = action
340
+ for choice in choiceItems { choice.state = choice.representedObject as? String == raw ? .on : .off }
267
341
  }
268
342
  }
269
343
 
@@ -185,7 +185,7 @@ hivey agent-map schedule install [--at 06:30] [--model sonnet] # | remove | st
185
185
 
186
186
  ## Agent fleet (what every agent does now)
187
187
 
188
- `hivey agent-map fleet` (or `fleet`; hivey menu → agent fleet) opens http://127.0.0.1:42817/fleet/ (old /fleet/ links redirect there; files in `reports/fleet/`): every live
188
+ `hivey agent-map fleet` (or `fleet`; hivey menu → agent fleet) opens http://127.0.0.1:42817/fleet/ (old /fleet/ links redirect there; files in `reports/fleet/`; a fleet tab already open in Chrome is reloaded and brought to the front, otherwise it opens in a new Chrome window, not a tab in yours; the desktop pet's click does the same by default): every live
189
189
  agent in hivey at a desk in a 3D fleet, one room per space, and one spaceship per hivey session (`hivey session list`: the default session flies the classic frigate, the others a carrier, an explorer or a recoloured frigate, their name painted on the hull; a stopped session's ship has cold engines and its agents asleep at their desks, read from its saved `session.json`; a running one's engines burn). Click an agent to open its session in a terminal: the one already showing it, or a new Terminal/iTerm window running `hivey session attach <name>`, which also starts a stopped session. Click the name painted on a ship's hull for its menu (hover shows its agent count): open/start the session, or stop it (a second click confirms; `hivey session stop` ends all its agents and closes its terminal; never the default session). The space outside is one of six scenes (violet, emerald, crimson, deep blue, golden twin suns, a singularity with its lensed accretion disk), chosen with the page's 🌌 setting: a new one on every load, or always the one you pick (saved with the ⏱ setting; `?space=1..6` in the address overrides it). Drag the hull name to move the ship; positions are kept in `~/.hivey/agent-map/fleet-settings.json` with the ⏱ setting. Open, compact and clear reach the agent through its own session's socket. The details panel (right-click an agent, or ⓘ) has a 📚 Wiki section: the agent's own `<name>-wiki/` (in its folder, or the folder named after its space under `~/agents` or `~/swarms`), its 8 newest pages and reports and its latest `log.md` entries; click one to open it in Obsidian (`obsidian://open`; a wiki that is not an Obsidian vault yet opens in the default Markdown app). After a /compact the context shown is the compacted size until the agent's next reply. Solo agents, extra sessions in a space and
190
190
  each swarm's coordinator get a desk; a swarm's workers and critics stand beside their coordinator's desk.
191
191
 
@@ -674,6 +674,61 @@ def write(data: dict) -> None:
674
674
  os.replace(tmp, OUT / "fleet.json")
675
675
 
676
676
 
677
+ # A fleet tab already open in Chrome is reloaded and brought to the front; otherwise Chrome
678
+ # opens it in a new window of its own (not a tab in one of the user's windows). Without Chrome (or without permission to script it) the default browser opens it.
679
+ CHROME_FOCUS_SCRIPT = """
680
+ on run argv
681
+ set theURL to item 1 of argv
682
+ tell application "Google Chrome"
683
+ repeat with w in windows
684
+ set i to 0
685
+ repeat with t in tabs of w
686
+ set i to i + 1
687
+ set u to URL of t
688
+ if (u starts with "http://127.0.0.1:" or u starts with "http://localhost:") and (u contains "/fleet" or u contains "/office") then
689
+ try
690
+ set minimized of w to false
691
+ end try
692
+ set active tab index of w to i
693
+ set index of w to 1
694
+ tell t to reload
695
+ activate
696
+ return "refreshed the open tab"
697
+ end if
698
+ end repeat
699
+ end repeat
700
+ set w to make new window
701
+ set URL of active tab of w to theURL
702
+ activate
703
+ return "opened a new Chrome window"
704
+ end tell
705
+ end run
706
+ """
707
+
708
+
709
+ def chrome_running() -> bool:
710
+ p = subprocess.run(["pgrep", "-x", "Google Chrome"], capture_output=True)
711
+ return p.returncode == 0
712
+
713
+
714
+ def show_in_browser(url: str) -> str:
715
+ """Puts the fleet page in front of the user: the open Chrome tab refreshed, or a new window."""
716
+ if sys.platform == "darwin":
717
+ if chrome_running():
718
+ try:
719
+ p = subprocess.run(["osascript", "-e", CHROME_FOCUS_SCRIPT, url],
720
+ capture_output=True, text=True, timeout=20)
721
+ if p.returncode == 0:
722
+ return p.stdout.strip() or "opened in Chrome"
723
+ except subprocess.TimeoutExpired:
724
+ pass
725
+ elif subprocess.run(["open", "-na", "Google Chrome", "--args", "--new-window", url],
726
+ capture_output=True).returncode == 0:
727
+ return "opened a new Chrome window"
728
+ subprocess.run(["open", url], capture_output=True)
729
+ return "opened in the default browser"
730
+
731
+
677
732
  def open_page(model: str) -> int:
678
733
  import serve
679
734
  data = OUT / "fleet.json"
@@ -687,8 +742,8 @@ def open_page(model: str) -> int:
687
742
  if not fresh:
688
743
  serve.request_fleet_refresh(port)
689
744
  url = f"http://127.0.0.1:{port}/fleet/"
690
- subprocess.run(["open", url], capture_output=True)
691
- print(f"agent fleet: {url}")
745
+ how = show_in_browser(url)
746
+ print(f"agent fleet: {url} ({how})")
692
747
  return 0
693
748
 
694
749