Skip to content

Commit 86d2c8f

Browse files
Merge remote-tracking branch 'amDosion/feat/computer-use-windows'
2 parents 1314650 + ca086b0 commit 86d2c8f

39 files changed

Lines changed: 9446 additions & 752 deletions

DEV-LOG.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,75 @@
11
# DEV-LOG
22

3+
## Computer Use Windows 增强:窗口绑定截图 + UI Automation + OCR (2026-04-03)
4+
5+
在三平台基础实现之上,利用 Windows 原生 API 增强 Computer Use 的 Windows 专属能力。
6+
7+
**新增文件:**
8+
9+
| 文件 | 行数 | 说明 |
10+
|------|------|------|
11+
| `src/utils/computerUse/win32/windowCapture.ts` || `PrintWindow` 窗口绑定截图,支持被遮挡/后台窗口 |
12+
| `src/utils/computerUse/win32/windowEnum.ts` || `EnumWindows` 精确窗口枚举(HWND + PID + 标题) |
13+
| `src/utils/computerUse/win32/uiAutomation.ts` || `IUIAutomation` UI 元素树读取、按钮点击、文本写入、坐标识别 |
14+
| `src/utils/computerUse/win32/ocr.ts` || `Windows.Media.Ocr` 截图+文字识别(英语+中文) |
15+
16+
**修改文件:**
17+
18+
| 文件 | 变更 |
19+
|------|------|
20+
| `packages/@ant/computer-use-swift/src/backends/win32.ts` | `listRunning` 改用 EnumWindows;新增 `captureWindowTarget` 窗口级截图 |
21+
22+
**验证结果(Windows x64):**
23+
- 窗口枚举:38 个可见窗口 ✅
24+
- 窗口截图:VS Code 2575x1415, 444KB ✅(PrintWindow, 即使被遮挡)
25+
- UI Automation:坐标元素识别 ✅
26+
- OCR:识别 VS Code 界面文字,34 行 ✅
27+
28+
---
29+
30+
## Enable Computer Use — macOS + Windows + Linux (2026-04-03)
31+
32+
恢复 Computer Use 屏幕操控功能。参考项目仅 macOS,本次扩展为三平台支持。
33+
34+
**Phase 1 — MCP server stub 替换:**
35+
从参考项目复制 `@ant/computer-use-mcp` 完整实现(12 文件,6517 行)。
36+
37+
**Phase 2 — 移除 src/ 中 8 处 macOS 硬编码:**
38+
39+
| 文件 | 改动 |
40+
|------|------|
41+
| `src/main.tsx:1605` | 去掉 `getPlatform() === 'macos'` |
42+
| `src/utils/computerUse/swiftLoader.ts` | 移除 darwin-only throw |
43+
| `src/utils/computerUse/executor.ts` | 平台守卫扩展为 darwin+win32+linux;剪贴板按平台分发(pbcopy→PowerShell→xclip);paste 快捷键 command→ctrl |
44+
| `src/utils/computerUse/drainRunLoop.ts` | 非 darwin 直接执行 fn() |
45+
| `src/utils/computerUse/escHotkey.ts` | 非 darwin 返回 false(Ctrl+C fallback) |
46+
| `src/utils/computerUse/hostAdapter.ts` | 非 darwin 权限检查返回 granted |
47+
| `src/utils/computerUse/common.ts` | platform + screenshotFiltering 动态化 |
48+
| `src/utils/computerUse/gates.ts` | enabled:true + hasRequiredSubscription→true |
49+
50+
**Phase 3 — input/swift 包 dispatcher + backends 三平台架构:**
51+
52+
```
53+
packages/@ant/computer-use-{input,swift}/src/
54+
├── index.ts ← dispatcher
55+
├── types.ts ← 共享接口
56+
└── backends/
57+
├── darwin.ts ← macOS AppleScript(原样拆出,不改逻辑)
58+
├── win32.ts ← Windows PowerShell
59+
└── linux.ts ← Linux xdotool/scrot/xrandr/wmctrl
60+
```
61+
62+
**编译开关:** `CHICAGO_MCP` 加入 DEFAULT_FEATURES + DEFAULT_BUILD_FEATURES
63+
64+
**验证结果(Windows x64):**
65+
- `isSupported: true`
66+
- 鼠标定位 + 前台窗口信息 ✅
67+
- 双显示器检测 2560x1440 × 2 ✅
68+
- 全屏截图 3MB base64 ✅
69+
- `bun run build` 463 files ✅
70+
71+
---
72+
373
## Enable Voice Mode / VOICE_MODE (2026-04-03)
474

575
恢复 `/voice` 语音输入功能。`src/` 下所有 voice 相关源码已与官方一致(0 行差异),问题出在:① `VOICE_MODE` 编译开关未开,命令不显示;② `audio-capture-napi` 是 SoX 子进程 stub(Windows 不支持),缺少官方原生 `.node` 二进制。

build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ rmSync(outdir, { recursive: true, force: true });
1010

1111
// Default features that match the official CLI build.
1212
// Additional features can be enabled via FEATURE_<NAME>=1 env vars.
13-
const DEFAULT_BUILD_FEATURES = ["AGENT_TRIGGERS_REMOTE", "VOICE_MODE"];
13+
const DEFAULT_BUILD_FEATURES = ["AGENT_TRIGGERS_REMOTE", "CHICAGO_MCP", "VOICE_MODE"];
1414

1515
// Collect FEATURE_* env vars → Bun.build features
1616
const envFeatures = Object.keys(process.env)

0 commit comments

Comments
 (0)