glovebox

io.github.vpatel9202由 GitHub 账号 vpatel9202 发布v0.3.2更新于 Nov 4, 2026

Computer use for coding agents on macOS: JS scripts, accessibility diffs, background input.

已验证STDIO仅桌面浏览器自动化开发者工具

概览

AI 生成的概览

通过持久 JavaScript 会话操控 macOS 桌面应用,让助手用脚本执行界面操作并读取无障碍树差异,而非截图。

可以做什么
  • 在持久会话中运行 JavaScript,启动或查找应用,并点击、输入、滚动、拖拽和设置数值
  • 以文本形式读取应用的无障碍树,后续读取只显示变化,也可获取截图
  • 在一次调用中批量执行多个操作加一次读取,绑定和辅助函数在调用之间保留
  • 重置会话以清除所有绑定,用于脚本卡住或需要干净状态时
适用场景
适合 macOS 上的编码助手需要操作真实桌面应用时,包括在你继续使用其他应用的同时进行后台输入,以及用无障碍文本差异替代截图以降低成本。不适用于 Windows 或 Linux,也不适合需要免构建的已公证二进制的场景。
运行要求
仅限 macOS(面向 macOS 14+ 构建,仅在 macOS 27 Apple 芯片上测试)。需要 Node 20.10+ 和 Xcode 命令行工具以构建辅助应用;该辅助应用需授予“辅助功能”和“屏幕录制”权限,输入监控为可选项。以 npm 包形式本地安装并通过 stdio 运行,无需 API 密钥或账号。
安装前请注意
它不是沙箱:批准某个应用即批准其全部内容,允许浏览器就等于让助手使用你已登录的所有网站,且不会筛查页面内容中的提示注入。终端、密码管理器和系统设置默认被阻止,需显式允许。操作会记录到本地日志文件,后台输入使用两个私有 macOS 调用,另有一个已知问题:后台应用弹出菜单打开时,你的按键可能落入该应用。

安装

在 SourceWeft 中

  1. 打开 控制台中的 glovebox,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

glovebox

[CI] [npm] [License: MIT] [Platform: macOS]

Computer use for coding agents on macOS: one JavaScript call per step, accessibility diffs instead of screenshots, and your screen stays yours.

[Someone browses Wikipedia in Safari while an agent works Calculator and types the result into TextEdit in the background]

js
const calc = await gb.getApp("Calculator");await calc.pressKey("Escape");await calc.typeText("6*7=");await calc.getAXState();
Calculator — window 0 "Calculator" — image 460x816 — changes since last read (~ changed, + added):~					8 scroll area id=StandardInputView;value:42~						9 text "Edit field" value="42"

On the next call, calc is still bound. An agent writes a few lines per step instead of making one tool call per click, and reads what changed instead of a fresh picture of the window.

  • A script per step, not a tool call per click. Bindings and helper functions persist across calls, so one call can click, type, loop, and read.
  • Diffs, not screenshots. The default read is the accessibility tree as text, and later reads show only changes. Screenshots and pixel clicks are there when the tree is empty (Citrix, canvases).
  • Background by default. Keys, clicks, drags, and scrolls reach the app while you keep working in another one. Your cursor stays put, and a drawn cursor shows what the agent is doing.

In an author-run test of six setups on 12 tasks (2 runs each), glovebox had the lowest total cost, $0.57 against $1.41 to $5.67, and the fewest round trips and the most passes.

What to know first: macOS only, tested on macOS 27 on Apple silicon. You need the Xcode command line tools to build a small helper app, and you grant it Accessibility and Screen Recording. Background input uses two private macOS calls, with a foreground fallback. Only Claude Code has been tested end to end. Despite the name, this is not a sandbox, and it is unrelated to glovebox-mcp.

Quickstart

Requires Node 20.10+ and the Xcode command line tools (xcode-select --install).

bash
npm install -g @vashp2029/gloveboxglovebox signing --create   # optional: macOS keeps the grants across helper rebuildsglovebox setup              # builds the helper, walks through permissionsglovebox doctor             # every line should say okglovebox smoke              # a real end-to-end test on Calculatorclaude mcp add --scope user glovebox -- glovebox mcp

setup builds Glovebox Helper.app into ~/.glovebox/ and asks you to turn it on under System Settings > Privacy & Security > Accessibility and Screen & System Audio Recording. Input Monitoring is optional and only enables Escape-to-stop. The helper is its own app, so one grant covers every agent and terminal. signing --create makes a self-signed certificate in your login keychain that signs only the helper. Without it, macOS treats each rebuild as a new app; see the upgrade note.

Works with: Claude Code (tested end to end). Codex, Grok CLI, OpenCode, Gemini CLI, and Cursor have documented configs that have not been exercised. Any agent that can run shell commands can use glovebox run. See docs/agents.md.

Why not Claude Code's built-in computer use?

If it fits your setup, it is the easier choice: nothing to install, supported by Anthropic, and it keeps your terminal out of screenshots. glovebox is for the cases where it does not fit. From Anthropic's docs, checked 2026-11-03:

Claude Code built-inglovebox
Your other appsHidden while Claude worksStay visible; input goes to the target app in the background
Default readDownscaled screenshotAccessibility text diff
Who can use itPro, Max, or Ultra through claude.ai; not Team, Enterprise, Bedrock, Google Cloud, or FoundryAnyone; it never talks to a model or an account
Scripted runsNot in -p modeThe benchmark drives it unattended from a script; claude -p itself not yet tested
SessionsOne at a time, enforced by a lock fileNo global lock; named sessions run side by side
Remembering approvalsThis session onlyAllow for This Session or Always Allow
BrowsersView-onlyFull control once you approve the browser, which is more power and more risk

Claude Code's built-in tool was not in the benchmark below, so this table compares documented behavior, not measured results.

Benchmark

Twelve macOS tasks, six setups, two runs each, 2026-11-03. Same model (Claude Sonnet 5.5, medium effort), prompt, and agent loop for every setup; only the tool changes. Task prompts name no tool, and a separate check that doesn't use the tool under test decides each result.

SetupPassedRound tripsImages returnedCost at list price
glovebox24/2412821$0.57
Codex cua_repl, driven by Claude20/2416630$1.41
Anthropic toolset, run by glovebox22/24187179$1.65
agent-desktop22/2420422$2.32
open-computer-use21/24244385$2.76
Peekaboo20/24359183$5.67

[Median round trips and cost per task for each setup]

Where glovebox did not win. It was not cheapest on finder-rename ($0.061 against $0.041 for Codex cua_repl). It did not have the fewest round trips on 3 of the 12 tasks, or the fastest time on 3 of the 12. On remote-desktop it took 36 seconds against 22 and 23 for two others.

How much to trust this:

  • I wrote the tasks and ran the test, on one Mac, in one sitting. Several tasks (bulk-entry, remote-desktop, coexistence) were designed around things glovebox set out to do.
  • With two runs per task, pass counts mean little: 24/24 against 20/24 is not statistically significant. The cost gap is the sturdier result, because it holds task by task: glovebox cost less than each other setup on at least 11 of 12 tasks.
  • The glovebox tested is the code released as 0.3.0. Result files say 0.2.0, because the version had not been bumped yet.
  • "Anthropic toolset" is Anthropic's API computer-use toolset, executed through glovebox's foreground route. It failed coexistence because of that route, so that result doesn't describe a shipping product. "Codex cua_repl" measures the tool shape under Claude, not Codex with its own model.
  • Peekaboo's first pass was rerun with foreground input allowed, which helped it. Its two bulk-entry failures were my $0.75 per-run budget cap stopping the run. agent-desktop ran through its CLI, not its MCP mode.

Method, per-task numbers, and raw results: bench/ and bench/results/v2/summary.md.

How it compares

Checked against each project's README and docs on 2026-11-03. "—" means I could not confirm it from those.

PlatformsActions per callState between callsDefault readDiffed readsBackground inputNeeds
gloveboxmacOSmany (one script)persistent JS sessionaccessibility textyesyesXcode CLT to build the helper
Claude Code built-inmacOS (CLI)——screenshot—no, hides other appsPro, Max, or Ultra
Codex computer usemacOS, Windowsmany (one script)persistent JS sessionaccessibility textyesyes on macOSChatGPT app and plugin
lcumacOS (Apple silicon), Linuxas Codex; it runs Codex's runtimeas Codexas Codexas Codex—ChatGPT app installed
agent-desktopmacOS, Windows, Linuxone per command, plus batchrefs tied to a snapshotaccessibility tree JSON—yesHomebrew or npm
PeekaboomacOS 15+one per commandelement IDs from a snapshotscreenshot or JSON UI map—yesHomebrew or npm
open-computer-usemacOS, Linux, Windowsone per MCP call; CLI has sequences—app state——npm
computer-use-mcpmacOS 14+one per callelement IDsscreenshot and tree per action—yesnotarized binary
cua-drivermacOS, Windows, Linux————yessee its docs

Pick something else if you need Windows or Linux (agent-desktop, cua-driver, lcu), a notarized binary with no build step (computer-use-mcp), or want OpenAI's actual runtime and already have the ChatGPT app (lcu).

Safety

The first time a session touches an app, you get a dialog: Allow for This Session, Always Allow, or Deny. Terminals, password managers, System Settings, and a few others are blocked unless you run glovebox allow <bundle id>; the list is in SECURITY.md. A script that had to bring an app forward stops if you switch away. Scripts running in the background keep going while you use other apps, and Escape stops any script if you grant Input Monitoring. Every action is logged to ~/.glovebox/actions.log.

An approved app is approved for everything in it: allowing a browser lets the agent use every site you are signed in to. glovebox does not screen page content for prompt injection. Treat it like giving someone remote control of that app. Details: SECURITY.md.

Known issue: while a background app's pop-up menu is open, macOS sends your keystrokes to that app, so a word you type can land in it (details).

How it works

agent ──MCP stdio──▶ glovebox mcp ──▶ kernel (persistent JS session)agent ──shell──▶ glovebox run ──▶ daemon ──▶ kernel        │                                                            ▼ Unix socket                                        Glovebox Helper.app (Swift: AX, CGEvent,                                        ScreenCaptureKit, approval dialogs)

Background input uses two private macOS (SkyLight) functions, looked up at runtime with a foreground fallback; glovebox doctor reports which route you have. Everything else is public API. No OpenAI, Anthropic, or other vendor binaries.

Status

PlatformStatus
macOSWorks. Built for macOS 14+; tested only on macOS 27 (Apple silicon).
WindowsPlanned (UI Automation). See roadmap.
LinuxPlanned (AT-SPI; Wayland limited). See roadmap.

Run for real, not mocked: glovebox smoke and smoke --full over MCP (batched steps, persistent bindings, diffs, pixel clicks, and background click, drag, and scroll with another app frontmost), and Claude Code attached through glovebox mcp. Full list: docs/testing.md.

The API in one screen

  • gb.getApp(name) launches or finds an app without stealing focus. gb.listApps().
  • app.getAXState() returns the accessibility tree as text; later reads are diffs. {frames: true} adds element boxes, {disableDiffing: true} the full tree.
  • app.getScreenshot() is the only way to get an image.
  • app.click(target), doubleClick, rightClick, scroll, drag, setValue, focus, selectText, performSecondaryAction.
  • app.pressKey("ctrl+a") uses xdotool names (super is Cmd). app.typeText("text\n").
  • app.waitForChange() and app.settle() wait for a late update.
  • A target is an element index from the tree or [x, y] pixels in the window image, which is the screenshot's pixel space.

Full reference: docs/api.md, or help() inside a session.

Docs

License

MIT

来源:README.md,提交 3cabd5b

工具

2

js

Run JavaScript in a persistent computer-use session. Put a whole step in one call: several actions, then one read. Top-level const/let/function/await persist across calls until js_reset (redeclaring is fine). const calc = await gb.getApp("Calculator"); // name, bundle id, or "pid:123"; launches if needed, does not steal focus await calc.pressKey("Escape"); // xdotool syntax: Return, Tab, ctrl+a, super+c (super = Cmd) await calc.typeText("12*3="); // "\n" presses Return await calc.getAXState(); // text accessibility tree; later reads return only changes Reads: getAXState({disableDiffing, frames, menus, window}) returns "<index> <role> \"label\" value=..." lines. frames:true adds @x,y wxh in image pixels. getScreenshot() and getAXStateAndScreenshot() are the only calls that return an image. Every read emits its output; pass {emit:false} to just get the value. Actions: click(target, {button, count, modifiers}), doubleClick, rightClick, scroll(target, dy), drag(from, to), setValue(index, v), focus(index), selectText(index, {start, length}), performSecondaryAction(index, "Show Menu"), listActions(index), activate(), windows(), frame(index), center(index). A target is an element index from the tree, or [x, y] pixels in the window image (same space as the screenshot and frames). Prefer indices; use pixels when the tree has nothing useful (remote desktops, canvases). Input stays in the background (focus and the user's cursor don't move); pass {foreground: true} to an action if an app ignores it. gb.listApps() lists running apps. console.log adds text to the result. help() or help("click") prints the full API. If a result says "Stopped:" the user took over (switched apps or pressed Escape): stop and ask before continuing.

输入参数code必填titletimeout_ms

js_reset

Restart the session and drop every binding. Use when a script is stuck or you want a clean slate.

无需输入参数。

版本历史

1
  1. v0.3.2最新Nov 4, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分