faster-mac-use 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.4
2
+ Name: faster-mac-use
3
+ Version: 0.1.0
4
+ Summary: Background-first, multi-cursor browser and native macOS computer-use engine for AI agents
5
+ Author: Lifan Chen
6
+ License: MIT
7
+ Project-URL: Homepage, https://clifan.com/faster-mac-use/
8
+ Project-URL: Repository, https://github.com/lifan-builds/faster-mac-use
9
+ Project-URL: Documentation, https://github.com/lifan-builds/faster-mac-use/blob/main/docs/architecture_and_benchmarks.md
10
+ Keywords: mcp,computer-use,macos,accessibility,browser-automation,cua,ai-agents,webmcp
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: playwright>=1.40.0
15
+ Provides-Extra: benchmarks
16
+ Requires-Dist: tiktoken>=0.7.0; extra == "benchmarks"
17
+ Dynamic: license-file
18
+
19
+ # Faster Mac Use (`fmu`)
20
+
21
+ Background-first, multi-cursor browser and native macOS computer-use engine for AI agents, modeled after and extending OpenAI Codex's `cua_repl` architecture.
22
+
23
+ - **Website & Interactive Benchmark Explorer:** [https://clifan.com/faster-mac-use/](https://clifan.com/faster-mac-use/)
24
+ - **Architecture & 5-Workload Benchmark Report:** [`docs/architecture_and_benchmarks.md`](docs/architecture_and_benchmarks.md)
25
+
26
+ ![Faster Mac Use 3-Cursor Parallel Swarm vs @playwright/mcp Live Token Counter](docs/assets/swarm-vs-mcp-demo.svg)
27
+
28
+ ## Why `faster-mac-use`?
29
+
30
+ Most computer-use tools force a painful choice:
31
+ - **Pixel screenshot loops** (`computer` tool) hijack your physical mouse cursor, steal window focus, and burn 40kโ€“80k tokens across 10โ€“30 turns.
32
+ - **Standard Accessibility/Playwright MCPs** (`@playwright/mcp`, `chrome-devtools-mcp`) inject 4,000โ€“12,500 tokens of tool schemas upfront and return full ARIA trees on every click.
33
+ - **Single-session REPLs** (`cua_repl`) are fast for one agent, but serialize multi-agent workflows and fall back to screenshots on custom-rendered macOS windows or HTML5 `<canvas>` apps.
34
+
35
+ `faster-mac-use` combines a **268-token single-tool MCP/CLI schema**, a **stateful async `cua_repl` sandbox**, **persistent `@u1..@uN` / `@a1..@aN` element UIDs with pre-registered table folding**, **push-based `AXObserver` `< 1 ms` dirty-subtree diffs**, **auto-synthesized Virtual WebMCP site macros (`~/.fmu/macros/`)**, **0-vision-token `<canvas>` & macOS window OCR**, **outbound MV3 extension WebSocket bridging for live logged-in Chrome `"๐Ÿค– Agent"` tab groups (zero Chrome 144 popups)**, and **true multi-cursor parallel execution** โ€” verified at **0.0 px physical cursor movement** and **0 focus changes**.
36
+
37
+ | Workload | `faster-mac-use` (Cumulative Tokens / Engine Time) | OpenAI Codex `cua_repl` Ref | `@playwright/mcp` / Stacked MCPs | Anthropic Pixel CUA |
38
+ | :--- | :--- | :--- | :--- | :--- |
39
+ | **A. Enterprise SaaS Console (10 ops)** | **1,290 tok / 94 ms** (Native WebMCP)<br>**1,290 tok / 97 ms** (Virtual WebMCP Macro)<br>**2,024 tok / 133 ms** (DOM Diff) | 5,732 tok / 359 ms | 231,125 tok / 1,850 ms | 83,215 tok / 3,400 ms |
40
+ | **B. macOS Native Calculator (11 ops)** | **1,264 tok / 395 ms** (`< 1 ms` `AXObserver` diff) | 1,502 tok / 554 ms | 48,477 tok / 12,718 ms (`ocu`) | โ€” |
41
+ | **C. Hybrid Web + macOS (14 ops)** | **2,179 tok / 335 ms** | 2,437 tok / 568 ms | 129,010 tok / 3,200 ms | โ€” |
42
+ | **D. 3-Agent Multi-Cursor Swarm (25 ops)** | **1,510 tok / 326 ms** (2 turns) | 15,923 tok / 1,122 ms (6 turns) | 293,950 tok / 4,850 ms | 430,800 tok / 7,600 ms |
43
+ | **E. Long-Horizon 30-Op + Window OCR** | **4,584 tok / 494 ms** (0 vision tok) | 8,355 tok / 942 ms | 400,725 tok / 6,100 ms | 620,535 tok / 9,200 ms |
44
+
45
+ ---
46
+
47
+ ## Core Architecture
48
+
49
+ 1. **Tier 1 โ€” Native Browser Engine ([`BrowserEngine`](src/fmu/browser_engine.py))**
50
+ - **Dual-Mode Zero-Popup Chrome Control**:
51
+ - **Live Logged-In Chrome via Outbound MV3 Extension WebSocket Bridge (`ws://127.0.0.1:19222/ext`)**: [`extension/background.js`](extension/background.js) connects outward to `/tmp/fmu-runtime.sock`'s single-owner `ExtensionWebSocketBridge` (`fmu mcp` proxies calls through the daemon so port `19222` is never contested; inspectable via `{"bridgeStatus": true}` / `await cua.getBridgeStatus()`) and drives unfocused, per-agent color-coded **`"๐Ÿค– Agent"` Tab Groups** (`active: false`, with multi-window `window`, `windowId`, and `reuseExisting` tab targeting) via `chrome.debugger` / `chrome.scripting` / `chrome.tabGroups` with **zero Chrome 144 `DevToolsActivePort` `"Allow remote debugging?"` modal popups**. When `mode: "extension"` (or `"live"` / `requireExtension: true`) is requested while disconnected, `fmu` fails fast with an actionable setup diagnostic; when default `mode: "chrome"` targets an external URL without the extension connected, `fmu` tags the header `bridge="headless-fallback"` and emits an explicit `! warning:` (and `! errors:` if `els=0`) instead of silently failing in an unauthenticated session.
52
+ - **Zero-Config Background Worker (`mode: "headless"` & local dev URLs)**: When running in `"headless"` mode or against local/test URLs without the extension bridge, `fmu` uses a thread-safe background Playwright worker (`fmu-pw-worker`) with per-tab background focus and lifecycle emulation (`Emulation.setFocusEmulationEnabled({enabled: true})` + `Page.setWebLifecycleState({state: "active"})`).
53
+ - **Persistent `WeakMap` UIDs (`@u1..@uN`) + Pre-Registered Table Row Folding (`foldTables`)**: Indexes all table rows in `uidToRef` so agents can target folded rows by label or UID while cutting initial dense table snapshots by >2.5ร—.
54
+ - **Native WebMCP (`navigator.modelContext`) + Auto-Synthesized Virtual WebMCP Macros (`~/.fmu/macros/`)**: Detects page-registered WebMCP tools and allows agents to synthesize multi-step DOM trajectories into reusable 1-turn Virtual WebMCP tools (`await tab.saveMacro(name, steps, desc)` -> `await tab.callTool(name, args)`), auto-loaded per domain in the `# web ... webmcp=[...]` header.
55
+ - **In-Browser `<canvas>` / WebGL Semantic OCR Fusion**: Clip-captures `<canvas>` elements via CDP and runs Apple Silicon `Vision.framework` (`VNRecognizeTextRequest`) via `fmu-ax` to inject clickable `@ocr1..@ocrN canvas-text "..." (x,y) [wxh]` targets directly into the web snapshot (`await tab.ocr()` or automatic canvas detection) with **0 VLM image tokens**.
56
+ - **Deterministic Rich-Text Editing & Zero-Dialog File Uploads**: Replaces (or appends with `append: true`) multi-block `contenteditable` / Draft.js / ProseMirror editors in `< 50 ms` without touching the system clipboard, and intercepts `<input type="file">` uploads via CDP (`DOM.setFileInputFiles`) so native macOS `NSOpenPanel` dialogs never open or get blocked by AppKit/TCC.
57
+
58
+ 2. **Tier 2 โ€” Native macOS Accessibility, Push-Based `AXObserver` & Vision OCR ([`fmu_ax.swift`](src/fmu/native/fmu_ax.swift) / [`MacNativeEngine`](src/fmu/mac_engine.py))**
59
+ - **Persistent Unix Socket Daemon (`/tmp/fmu-ax.sock`, universal2 binary `bin/fmu-ax`)**: Keeps a warm 4,000-element `AXUIElement` LRU cache, PID/window cache, per-agent `+/~/-` diff baselines, and per-agent virtual cursors (`VirtualCursorState`) across turns.
60
+ - **Push-Based `AXObserver` Dirty-Subtree Tracking**: Subscribes to `kAXValueChangedNotification`, `kAXTitleChangedNotification`, `kAXCreatedNotification`, `kAXUIElementDestroyedNotification`, and window/layout notifications on a dedicated `CFRunLoop` thread (`fmu-ax-observer`). Turn 2+ unchanged or leaf-dirty snapshots short-circuit full AX tree walks in **`< 1 ms`** (`obs=` sequence telemetry).
61
+ - **Batched Attribute Reads, Non-Destructive Clipboard Hygiene & Multi-Window Guards**: Batches reads via `AXUIElementCopyMultipleAttributeValues`, lazily wakes background Electron/Chromium AX trees (`AXManualAccessibility = true`), never overwrites `NSPasteboard.general` on `op: "set"` (verifying `AXTextArea` read-back and detecting `NSOpenPanel` TCC-disabled `Open` buttons), and guards `CGEvent.postToPid` key routing when targeting a non-main window of a multi-window process.
62
+ - **0-Vision-Token Apple Silicon Window & Canvas OCR**: Built-in `CGWindowListCreateImage` + `ImageIO` + `VNRecognizeTextRequest` engine (`op: "ocr"` / `await app.ocr()`) extracts clickable text and bounding boxes in `< 70 ms`.
63
+ - **Real-Time Pixel `fmu Live View` HUD & One-Click Menu Bar Stop**: Streams live pixels of the actual controlled background Chrome tab (`Page.startScreencast` + async post-action `Page.captureScreenshot` over `ws://127.0.0.1:19222/ext`) or native macOS app window (`ScreenCaptureKit`) into a non-activating floating PiP monitor with target cursor reticles, `โคข` HD Zoom (`460px` / `740px`, `{"toggleZoom": true}`), `๐ŸŽฏ Highlight` (`fmu --highlight`), draggable positioning, and instant `โน Stop` / `โ–ถ Resume` (`fmu --stop` / `fmu --resume`).
64
+
65
+ 3. **Tier 3 โ€” Unified Multi-Cursor / Multi-Agent Stateful REPL, Warm Daemon & Context Hygiene ([`FasterMacUseRuntime`](src/fmu/cua_runtime.py))**
66
+ - **268-Token Single-Tool Schema & Strict `steps` Validation**: Supports OpenAI Codex-style stateful `cua_repl` scripts (`cua.createBrowserTab`, `cua.getTab`, `cua.getApp`, `cua.getBridgeStatus`, `cua.saveMacro`, `cua.listMacros`, `cua.getState`, `cua.getCursors`), 1-trip declarative `steps` batches (with `op`/`uid` and `action`/`target`/`text` normalization plus explicit error reporting on missing or unsupported `"op"`), and concurrent multi-agent swarms (`{"parallel": [{"agent": "agent-1", "code": "..."}, ...]}`).
67
+ - **Per-Agent Isolation & Stale-Observation Masking**: Each `AgentSession` has independent REPL handles, virtual cursor `(x, y)` coordinates (`tab.moveCursor` / `app.moveCursor`), and `ContextWindowTracker` 18-token tombstones that replace superseded snapshots to prevent quadratic O(Nยฒ) context growth.
68
+ - **50Hz Hardware Intrusion Guard ([`BackgroundIntrusionGuard`](src/fmu/guard.py))**: Polls CoreGraphics (`CGEventGetLocation` + `CGEventSourceSecondsSinceLastEventType`) and `lsappinfo front` at 50Hz to prove `0.0 px` cursor displacement and `0` automated focus changes.
69
+
70
+ ---
71
+
72
+ ## Quick Start
73
+
74
+ ### 1. Install (1-Line `uvx` / `uv tool` / `pip` / Homebrew)
75
+ ```bash
76
+ # Option A: Run or install directly from GitHub via uv / pip (includes universal2 fmu-ax binary + auto-compiler fallback)
77
+ uvx --from git+https://github.com/lifan-builds/faster-mac-use.git fmu mcp
78
+ uv tool install git+https://github.com/lifan-builds/faster-mac-use.git
79
+ pip install git+https://github.com/lifan-builds/faster-mac-use.git
80
+
81
+ # Option B: Clone for development
82
+ git clone https://github.com/lifan-builds/faster-mac-use.git
83
+ cd faster-mac-use
84
+ pip install -e .
85
+
86
+ # Option C: Homebrew Formula
87
+ brew install --Formula ./Formula/faster-mac-use.rb
88
+ ```
89
+
90
+ ### 2. Add to Your MCP Client (Claude Code, Codex, Cursor, Antigravity)
91
+ ```json
92
+ {
93
+ "mcpServers": {
94
+ "faster-mac-use": {
95
+ "command": "fmu",
96
+ "args": ["mcp"]
97
+ }
98
+ }
99
+ }
100
+ ```
101
+ *(Or point `"command"` to `/path/to/faster-mac-use/bin/fmu`.)*
102
+
103
+ ### 3. CLI Usage (`fmu` or `./bin/fmu`)
104
+ ```bash
105
+ # Native macOS Calculator in background (zero focus steal, <1ms AXObserver diff on Turn 2+)
106
+ ./bin/fmu '{"surface":"app","app":"Calculator","steps":[{"op":"key","name":"escape"},{"op":"click","name":"7"},{"op":"click","name":"Multiply"},{"op":"click","name":"6"},{"op":"click","name":"Equals"}]}'
107
+
108
+ # Codex-style stateful cua_repl script + Virtual WebMCP macro recording
109
+ ./bin/fmu '{"code":"let tab = await cua.createBrowserTab(\"chrome\", \"https://example.com\", {sessionName: \"๐Ÿค– Agent\"}); await tab.saveMacro(\"quick_lookup\", [{op: \"click\", uid: \"More information\"}], \"Click More info\");"}'
110
+
111
+ # Multi-cursor / multi-agent parallel execution across Chrome tabs + native macOS apps
112
+ ./bin/fmu '{"parallel":[{"agent":"agent-1","code":"let t = await cua.createBrowserTab(\"chrome\", \"https://example.com\"); await t.move(\"More information\");"},{"agent":"agent-2","code":"let a = await cua.getApp(\"Calculator\"); await a.pressKey(\"escape\"); await a.click(\"8\");"}]}'
113
+
114
+ # Review real-world p50/p95/p99 latency, sub-phase breakdowns, and token efficiency (~/.fmu/logs)
115
+ ./bin/fmu --perf 7
116
+ ```
117
+
118
+ ### 4. Run the 28-Test Unit & Integration Suite
119
+ ```bash
120
+ PYTHONPATH=src python3 tests/test_fmu.py
121
+ ```
122
+
123
+ ### 5. Run the 5-Workload Competitor Benchmark Suite
124
+ ```bash
125
+ PYTHONPATH=src python3 benchmarks/run_benchmarks.py
126
+ ```
127
+ Results are written to [`benchmarks/results/latest_benchmark.md`](benchmarks/results/latest_benchmark.md) and [`benchmarks/results/latest_benchmark.json`](benchmarks/results/latest_benchmark.json).
128
+
129
+ ## License
130
+
131
+ MIT ยฉ [Lifan Chen](https://clifan.com)
@@ -0,0 +1,14 @@
1
+ faster_mac_use-0.1.0.dist-info/licenses/LICENSE,sha256=Chg0pDyXXeHILYxPJ113Xj5EwGLAZTDB-ESZ9KbZgP0,1067
2
+ fmu/__init__.py,sha256=-R_EZBq48lEXwBQbbaQVRgJ7FsEzdvv4bM1L7Q6dQr8,133
3
+ fmu/browser_engine.py,sha256=E9L0_AiYb88xkR63gm8nM13TEOvGsV7lYpFJ57HyEr8,235889
4
+ fmu/cli.py,sha256=PQ_lX5EzJF1CkxIcpYoFioAXV_YPTfzSOCXVAhptU9Q,13145
5
+ fmu/cua_runtime.py,sha256=gHxjh8A8yWV3ncxjDfI72nX5GSnBVwFauwEfRHA8U30,97481
6
+ fmu/guard.py,sha256=n6-h3_fmfgrGBcPzreDkxJskaHo-09DcQUhBqj-udnI,8185
7
+ fmu/mac_engine.py,sha256=68LtjFLL8yNarSPz4LYu7XhP2qo22o3ftk80wMBJ1mo,17588
8
+ fmu/telemetry.py,sha256=MmdOwtDEG_EuWRv7JQqzA6SkMgAkZatjY9hkzn09cmg,18441
9
+ fmu/native/fmu_ax.swift,sha256=4g5hLBA2XU2Srdqp8F9Etp0t7wpET2cgY91osLPNBcA,206150
10
+ faster_mac_use-0.1.0.dist-info/METADATA,sha256=3QEzt61aAOuMaILrGCezY0TTFuRs-lF2MEeTZYjvoCI,12507
11
+ faster_mac_use-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
12
+ faster_mac_use-0.1.0.dist-info/entry_points.txt,sha256=d3I1YXutwY4O1p0fH-HI61G91OIoDN6XT7vo6bobnew,37
13
+ faster_mac_use-0.1.0.dist-info/top_level.txt,sha256=Z-FIY3pxn0UK2Wxi9IJ7fKoLSraaxuNGi1eokiE0ShM,4
14
+ faster_mac_use-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ fmu = fmu.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lifan Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ fmu
fmu/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Faster Mac Use (fmu): Background-first Browser ('๐Ÿค– Agent' Tab Group) & macOS Accessibility engine."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+