@harusame64/desktop-touch-mcp 0.15.2 → 0.15.3

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 (3) hide show
  1. package/README.ja.md +42 -6
  2. package/README.md +66 -7
  3. package/package.json +1 -1
package/README.ja.md CHANGED
@@ -7,14 +7,15 @@
7
7
  > **「Claude CLI にスクショを毎回コピーしていたあなたへ。」**
8
8
 
9
9
  Claude がデスクトップを直接見て、直接操作する。
10
- マウス・キーボード・スクリーンショット・Windows UI Automation・Chrome DevTools Protocol・ターミナル・SmartScroll・Reactive Perception Graph を統合した 56 のツールを提供する MCP サーバーです。
10
+ マウス・キーボード・スクリーンショット・Windows UI Automation・Chrome DevTools Protocol・ターミナル・SmartScroll・Reactive Perception Graph を統合した 57 のツールを提供する MCP サーバーです。
11
11
 
12
- > *ウィンドウキャプチャに MPEG P フレーム方式の差分処理を適用。初回フレーム以降は変化したウィンドウのみを送信するため、一般的な自動化ループでトークン使用量を約 6080% 削減できます。*
12
+ > *v0.15: Rust ネイティブエンジンにより**平均 82 倍高速化** — UIA フォーカス取得 2ms、SSE2 SIMD 画像差分 1315 倍速。設定不要:エンジンは自動ロード、不在時は PowerShell に透過フォールバック。*
13
13
 
14
14
  ---
15
15
 
16
16
  ## 特徴
17
17
 
18
+ - **⚡ 高性能 Rust ネイティブコア** — UIA ブリッジと画像差分エンジンを Rust (`napi-rs` + `windows-rs`) で実装し、ネイティブ `.node` アドオンとしてロード。専用 MTA スレッドからの直接 COM 呼び出しにより PowerShell プロセス起動を排除 — `getFocusedElement` は **2ms**(160 倍高速)、`getUiElements` はバッチ型 BFS アルゴリズムでクロスプロセス RPC を最小化し **約 100ms** で完了。画像差分は **SSE2 SIMD** で 13〜15 倍のスループット。ネイティブエンジンが利用不可の場合、全関数が PowerShell に透過フォールバック — 設定不要。
18
19
  - **LLM ネイティブ設計** — 人間の操作を模倣するのではなく、「LLM がいかにコンテキストを消費せず高速に動けるか」を前提に設計。`run_macro` による複数操作の一括実行(API 往復の削減)と、**MPEG P-frame 方式のレイヤー差分** (`diffMode`) を組み合わせることで、無駄な画像転送や推論ループを極限まで削ぎ落とす。
19
20
  - **Reactive Perception Graph** — ウィンドウやブラウザタブに `lensId` を登録し、以後の action tool に渡すだけで、操作前の安全 guard と操作後の `post.perception` フィードバックを受け取れます。`screenshot` / `get_context` の反復を減らし、別ウィンドウへの誤入力や古い座標クリックを防ぎます。
20
21
  - **日本語/CJK 完全対応** — ウィンドウタイトル取得に Win32 `GetWindowTextW` を使用。nut-js の文字化けを回避。IME バイパス入力にも対応。
@@ -22,6 +23,8 @@ Claude がデスクトップを直接見て、直接操作する。
22
23
  - **座標変換不要の 1:1 モード** — `dotByDot=true` で WebP 1:1 キャプチャ。画像上のピクセル座標 = 画面座標なのでスケール計算が不要。
23
24
  - **ブラウザキャプチャのデータ削減** — `grayscale=true`、`dotByDotMaxDimension=1280`、`windowTitle + region` の部分切り出しで、ブラウザ chrome や不要な余白を除外。重いキャプチャで 50〜70% 程度の削減を狙えます。
24
25
  - **UIA アクション要素抽出** — `detail="text"` でボタン・入力欄の名前と `clickAt` 座標を JSON で返すため、画像を見なくても操作できる。
26
+ - **Chromium スマートフォールバック** — Chrome/Edge/Brave に対して `detail="text"` を使うと、低速な UIA を自動スキップし Windows OCR を実行。`hints.chromiumGuard` + `hints.ocrFallbackFired` で経路を判別可能。
27
+ - **CLI 自動ドック** — `dock_window` でウィンドウを画面隅にスナップ&最前面固定。`DESKTOP_TOUCH_DOCK_TITLE='@parent'` を設定すると、MCP 起動時にプロセスツリーを辿って Claude CLI をホストするターミナルを自動ドック。
25
28
  - **緊急停止 (Failsafe)** — マウスを**画面左上コーナー (0,0 付近 10px)** に移動すると MCP サーバーが即座に終了。
26
29
 
27
30
  ---
@@ -32,7 +35,7 @@ Claude がデスクトップを直接見て、直接操作する。
32
35
  |---|---|
33
36
  | OS | Windows 10 / 11 (64-bit) |
34
37
  | Node.js | v20 以上推奨 (v22+ で動作確認済み) |
35
- | PowerShell | 5.1 以上 (Windows 標準同梱) |
38
+ | PowerShell | 5.1 以上 (Windows 標準同梱) — Rust ネイティブエンジン不在時のフォールバック用 |
36
39
  | Claude CLI | `claude` コマンドが使えること |
37
40
 
38
41
  > **注意:** nut-js のネイティブバインディングは Visual C++ 再頒布可能パッケージを必要とします。
@@ -107,7 +110,7 @@ npm install
107
110
 
108
111
  ---
109
112
 
110
- ## ツール一覧 (56 ツール)
113
+ ## ツール一覧 (57 ツール)
111
114
 
112
115
  > 📖 **詳細リファレンス**: [`docs/system-overview.md`](docs/system-overview.md) — 各ツールのパラメータ・応答形式・座標計算・レイヤーバッファ・技術ノートを網羅(英語)。
113
116
 
@@ -179,6 +182,7 @@ DOM を触る `browser_*` ツールは `includeContext:false` で末尾の `acti
179
182
  | `get_context` | フォーカス中ウィンドウ・要素・カーソル・ページ状態を軽量取得 |
180
183
  | `get_history` | 直近ツール履歴を取得 |
181
184
  | `get_document_state` | Chromeページ状態(URL/title/readyState/scroll)をCDPで取得 |
185
+ | `engine_status` | 各サブシステムの動作バックエンドを返す:`uia`(Rust native または powershell)/ `imageDiff`(Rust SSE2 または typescript)。診断用 — パフォーマンス調査時に1回呼ぶ |
182
186
  | `wait_until` | window/focus/terminal/browser DOM などの状態変化をサーバー側で待機 |
183
187
  | `events_subscribe` / `events_poll` / `events_unsubscribe` / `events_list` | ウィンドウ出現・消滅・フォーカス変化を購読/取得 |
184
188
 
@@ -320,7 +324,7 @@ screenshot(diffMode=true) → 変化した窓だけ確認(~160 t
320
324
 
321
325
  ### PowerShell インジェクション対策
322
326
 
323
- UIA ブリッジの `-like` パターンには `escapeLike()` でワイルドカード文字 (`*`, `?`, `[`, `]`) をエスケープ済み。
327
+ UIA ブリッジの PowerShell フォールバックパスでは、`-like` パターンに `escapeLike()` でワイルドカード文字 (`*`, `?`, `[`, `]`) をエスケープ済み。v0.15 以降、UIA の主パスは Rust ネイティブエンジン(直接 COM 呼び出し)のため、PowerShell は補助的なフォールバックとしてのみ使用されます。
324
328
 
325
329
  ---
326
330
 
@@ -403,12 +407,44 @@ Windows のフォアグラウンド保護機能により、ピン固定された
403
407
  | 制限 | 詳細 | 回避策 |
404
408
  |---|---|---|
405
409
  | ゲーム・動画プレイヤーの背面キャプチャが黒またはハング | DirectX フルスクリーン等は `PW_RENDERFULLCONTENT (flag=2)` でもキャプチャ不可な場合がある | `screenshot_background(fullContent=false)` で旧フラグに切り替え、それでも黒なら前面キャプチャ (`screenshot`) を使用 |
406
- | UIA 呼び出しのオーバーヘッド | PowerShell 経由のため 1 回約 300ms。`workspace_snapshot` 内は 2s タイムアウトに短縮 | 操作前に `workspace_snapshot` で一括取得し、以降は `diffMode` で差分確認 |
410
+ | UIA 呼び出しのオーバーヘッド | Rust ネイティブ: フォーカス取得 ~2ms、ツリー走査 ~100ms。PowerShell フォールバック: ~300ms | 操作前に `workspace_snapshot` で一括取得し、以降は `diffMode` で差分確認 |
407
411
  | Chrome / WinUI3 の UIA 要素が空 | Chromium は UIA を限定的にしか公開しない | `browser_connect` + `browser_find_element` で DOM ベースのクリックを使用。視覚確認のみなら `screenshot(detail="image")` |
408
412
  | レイヤーバッファの TTL | 90 秒操作なしでバッファが自動クリア → 次回 `diffMode` が I-frame になる | 長い待機後は `workspace_snapshot` で明示的にリセット |
409
413
 
410
414
  ---
411
415
 
416
+ ## パフォーマンス (v0.15)
417
+
418
+ ### UIA ブリッジ — Rust ネイティブ vs PowerShell
419
+
420
+ | 関数 | Rust Native | PowerShell | 高速化 |
421
+ |---|---|---|---|
422
+ | `getFocusedElement` | **2.2 ms** | 366 ms | 🚀 **163.9×** |
423
+ | `getUiElements` | **106.5 ms** | 346 ms | 🚀 **3.3×** |
424
+ | **平均** | | | **🚀 ~82×** |
425
+
426
+ ### 画像差分エンジン — Rust SSE2 SIMD vs TypeScript
427
+
428
+ | 関数 | Rust SSE2 | TypeScript | 高速化 |
429
+ |---|---|---|---|
430
+ | `computeChangeFraction` (1080p) | **0.26 ms** | 3.8 ms | 🚀 **~15×** |
431
+ | `dHash` (1080p) | **0.09 ms** | 1.2 ms | 🚀 **~13×** |
432
+
433
+ ### アーキテクチャ概要
434
+
435
+ ```
436
+ Claude CLI → MCP Server (TypeScript)
437
+ ├── Rust Native Engine (.node addon)
438
+ │ ├── UIA: 専用 MTA スレッド → 直接 COM 呼び出し
439
+ │ └── Image: SSE2 SIMD カーネル
440
+ └── PowerShell フォールバック(自動切替)
441
+ ```
442
+
443
+ - **バッチ型 BFS**: `FindAllBuildCache(TreeScope_Children)` による階層ごとの一括フェッチ。`maxElements` 到達で即打ち切りし、巨大ツリーでもスケーラブル。
444
+ - **自動フォールバック**: ネイティブエンジンが利用不可の場合、全関数が PowerShell に透過切替 — 設定不要。
445
+
446
+ ---
447
+
412
448
  ## パフォーマンス目安
413
449
 
414
450
  | モード | 転送トークン | 用途 |
package/README.md CHANGED
@@ -6,14 +6,15 @@
6
6
 
7
7
  > **Stop pasting screenshots. Let Claude see and control your desktop directly.**
8
8
 
9
- An MCP server that gives Claude eyes and hands on Windows — 56 tools covering screenshots, mouse, keyboard, Windows UI Automation, Chrome DevTools Protocol, clipboard, desktop notifications, SmartScroll, and a Reactive Perception Graph for safe multi-step automation, designed from the ground up for LLM efficiency.
9
+ An MCP server that gives Claude eyes and hands on Windows — 57 tools covering screenshots, mouse, keyboard, Windows UI Automation, Chrome DevTools Protocol, clipboard, desktop notifications, SmartScroll, and a Reactive Perception Graph for safe multi-step automation, designed from the ground up for LLM efficiency.
10
10
 
11
- > *Applies MPEG P-frame diffing to window capture: only changed windows are sent after the first frame, cutting token usage by ~6080% in typical automation loops.*
11
+ > *v0.15: **82× average speedup** via Rust native engine UIA focus queries in 2 ms, SSE2-accelerated image diffing at 1315× native speed. Zero-config: the engine auto-loads when present, with transparent PowerShell fallback.*
12
12
 
13
13
  ---
14
14
 
15
15
  ## Features
16
16
 
17
+ - **⚡ High-performance Rust Native Core** — The UIA bridge and image-diff engine are written in Rust (`napi-rs` + `windows-rs`) and loaded as a native `.node` addon. Direct COM calls from a dedicated MTA thread eliminate PowerShell process spawning — `getFocusedElement` completes in **2 ms** (160× faster), and `getUiElements` returns full trees in **~100 ms** with a batch BFS algorithm that minimizes cross-process RPC. Image-diff operations use **SSE2 SIMD** for 13–15× throughput. When the native engine is unavailable, every function transparently falls back to PowerShell — zero config required.
17
18
  - **LLM-native design** — Built around how LLMs think, not how humans click. `run_macro` batches multiple operations into a single API call; `diffMode` sends only the windows that changed since the last frame. Minimal tokens, minimal round-trips.
18
19
  - **Reactive Perception Graph** — Register a `lensId` for a window or browser tab, pass it to action tools, and get guard-checked `post.perception` feedback after each action. It reduces repeated `screenshot` / `get_context` calls and prevents wrong-window typing or stale-coordinate clicks.
19
20
  - **Full CJK support** — Uses Win32 `GetWindowTextW` for window titles, avoiding nut-js garbling. IME bypass input supported for Japanese/Chinese/Korean environments.
@@ -33,7 +34,7 @@ An MCP server that gives Claude eyes and hands on Windows — 56 tools covering
33
34
  |---|---|
34
35
  | OS | Windows 10 / 11 (64-bit) |
35
36
  | Node.js | v20+ recommended (tested on v22+) |
36
- | PowerShell | 5.1+ (bundled with Windows) |
37
+ | PowerShell | 5.1+ (bundled with Windows) — used only as fallback when the Rust native engine is unavailable |
37
38
  | Claude CLI | `claude` command must be available |
38
39
 
39
40
  > **Note:** nut-js native bindings require the Visual C++ Redistributable.
@@ -109,7 +110,7 @@ For a local checkout, register the built server directly:
109
110
 
110
111
  ---
111
112
 
112
- ## Tools (56 total)
113
+ ## Tools (57 total)
113
114
 
114
115
  > 📖 **Full command reference**: [`docs/system-overview.md`](docs/system-overview.md) — every tool's parameters, response shape, coordinate math, layer-buffer strategy, and engineering notes in one place.
115
116
 
@@ -176,6 +177,22 @@ All `browser_*` tools that touch the DOM accept `includeContext:false` to omit t
176
177
  | `workspace_snapshot` | All windows: thumbnails + UI summaries in one call |
177
178
  | `workspace_launch` | Launch an app and auto-detect the new window |
178
179
 
180
+ ### Context / Wait / History (8)
181
+ | Tool | Description |
182
+ |---|---|
183
+ | `get_context` | Lightweight snapshot of focused window, element, cursor, and page state |
184
+ | `get_history` | Retrieve recent tool invocation history |
185
+ | `get_document_state` | Chrome page state (URL/title/readyState/scroll) via CDP |
186
+ | `engine_status` | Returns which backend is active: `uia` (native Rust or powershell) and `imageDiff` (native Rust SSE2 or typescript). Diagnostic — call once per session when troubleshooting performance |
187
+ | `wait_until` | Server-side wait for window/focus/terminal/browser DOM state changes |
188
+ | `events_subscribe` / `events_poll` / `events_unsubscribe` / `events_list` | Subscribe to and poll window appearance/disappearance/focus events |
189
+
190
+ ### Terminal (2)
191
+ | Tool | Description |
192
+ |---|---|
193
+ | `terminal_read` | Read text from Windows Terminal / PowerShell / cmd / WSL via UIA/OCR. Supports `sinceMarker` for diff reads |
194
+ | `terminal_send` | Send commands to a terminal. Uses clipboard paste by default for IME safety |
195
+
179
196
  ### Pin / Macro (3)
180
197
  | Tool | Description |
181
198
  |---|---|
@@ -193,7 +210,7 @@ All `browser_*` tools that touch the DOM accept `includeContext:false` to omit t
193
210
  |---|---|
194
211
  | `notification_show` | Show a Windows system tray balloon notification — useful to alert the user when a long-running task finishes |
195
212
 
196
- ### Scroll (1)
213
+ ### Scroll (2)
197
214
  | Tool | Description |
198
215
  |---|---|
199
216
  | `scroll_to_element` | Scroll a named element into the viewport without computing scroll amounts. Chrome path: `selector` + `block` alignment. Native path: `name` + `windowTitle` via UIA ScrollItemPattern |
@@ -398,7 +415,7 @@ Script extensions (`.bat`, `.ps1`, `.vbs`, etc.) are rejected. Arguments contain
398
415
 
399
416
  ### PowerShell injection protection
400
417
 
401
- All `-like` patterns in the UIA bridge are sanitized with `escapeLike()`, which escapes wildcard characters (`*`, `?`, `[`, `]`) before they reach PowerShell.
418
+ All `-like` patterns in the UIA bridge PowerShell fallback path are sanitized with `escapeLike()`, which escapes wildcard characters (`*`, `?`, `[`, `]`) before they reach PowerShell. When the Rust native engine is active, PowerShell is not invoked for UIA operations.
402
419
 
403
420
  ### Allowlist for `workspace_launch`
404
421
 
@@ -594,12 +611,54 @@ Returns `{ ok: true, result: "...", post: { perception: { status: "ok", ... } }
594
611
 
595
612
  ---
596
613
 
614
+ ## Performance (v0.15 — Rust Native Engine)
615
+
616
+ The Rust native engine (`@harusame64/desktop-touch-engine`) replaces PowerShell process spawning with direct COM calls over a persistent MTA thread. It loads automatically as a `.node` addon — no configuration needed.
617
+
618
+ ### UIA Benchmark (vs PowerShell baseline)
619
+
620
+ | Function | Rust Native | PowerShell | Speedup |
621
+ |---|---|---|---|
622
+ | `getFocusedElement` | **2.2 ms** | 366 ms | **163.9×** |
623
+ | `getUiElements` (Explorer, ~60 elements) | **106.5 ms** | 346 ms | **3.3×** |
624
+ | **Weighted average** | | | **~82×** |
625
+
626
+ ### Image Diff Benchmark (SSE2 SIMD)
627
+
628
+ | Function | Rust (SSE2) | TypeScript | Speedup |
629
+ |---|---|---|---|
630
+ | `computeChangeFraction` (1920×1080) | **0.26 ms** | 3.8 ms | **~15×** |
631
+ | `dHash` (perceptual hash) | **0.09 ms** | 1.2 ms | **~13×** |
632
+
633
+ ### Architecture
634
+
635
+ ```
636
+ Claude CLI / MCP Client
637
+ │ stdio or HTTP (MCP protocol)
638
+
639
+ desktop-touch-mcp (TypeScript)
640
+
641
+ ├── Rust Native Engine (.node addon) ← NEW in v0.15
642
+ │ ├── UIA: 13 functions via napi-rs + windows-rs 0.62
643
+ │ │ └── Dedicated COM thread (MTA) + batch BFS algorithm
644
+ │ └── Image: SSE2 SIMD pixel diff + perceptual hashing
645
+
646
+ └── PowerShell Fallback (automatic)
647
+ └── Activates transparently if .node is unavailable
648
+ ```
649
+
650
+ ### Why `getUiElements` is 3.3× (not 160×)
651
+
652
+ The 160× speedup on `getFocusedElement` comes from eliminating PowerShell process startup (~200 ms) and .NET assembly loading. For `getUiElements`, the bottleneck shifts to the **UIA provider** inside the target application (e.g., Explorer) — it must enumerate its UI tree regardless of who asks. The Rust engine uses a **batch BFS algorithm** (`FindAllBuildCache` + `TreeScope_Children`) that minimizes cross-process RPC calls and supports `maxElements` early exit, making it dramatically faster on large trees (VS Code, browsers with 1000+ elements).
653
+
654
+ ---
655
+
597
656
  ## Known limitations
598
657
 
599
658
  | Limitation | Detail | Workaround |
600
659
  |---|---|---|
601
660
  | Games / video players may return black or hang in background capture | DirectX fullscreen apps may not work even with `PW_RENDERFULLCONTENT` | Retry with `screenshot_background(fullContent=false)`; if still black, use foreground `screenshot` |
602
- | UIA call overhead | ~300ms per call via PowerShell; `workspace_snapshot` uses a 2s timeout internally | Batch with `workspace_snapshot` upfront, then use `diffMode` for incremental checks |
661
+ | UIA call overhead | ~2 ms (focus) / ~100 ms (tree) via Rust native engine; ~300 ms via PowerShell fallback | Rust engine loads automatically; `workspace_snapshot` uses a 2 s timeout internally |
603
662
  | Chrome / WinUI3 UIA elements are empty | Chromium exposes only limited UIA | `screenshot(detail='text')` auto-detects Chromium and falls back to Windows OCR (`hints.chromiumGuard=true`). For richer DOM access use `browser_connect` + `browser_find_element` |
604
663
  | Chromium title-regex misses when sites rewrite `document.title` | Guard relies on the ` - Google Chrome` suffix being present; some sites push it off the end of a long title | Title is treated as plain Chrome (UIA runs). OCR path is still reachable via `ocrFallback='always'` or when UIA returns `<5` elements (`uiaSparse`) |
605
664
  | `browser_*` CDP tools need Chrome launched with `--remote-debugging-port` | If Chrome is already running on the default profile without the flag, `browser_launch` / `browser_connect` fail. The CDP E2E suite (`tests/e2e/browser-cdp.test.ts`) will also fail in that state | Close Chrome first, then `browser_launch` will relaunch it in debug mode, or start Chrome manually with `--remote-debugging-port=9222 --user-data-dir=C:\tmp\cdp` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harusame64/desktop-touch-mcp",
3
- "version": "0.15.2",
3
+ "version": "0.15.3",
4
4
  "mcpName": "io.github.Harusame64/desktop-touch-mcp",
5
5
  "description": "LLM-native Windows computer-use MCP server with 56 tools for screenshots, UIA, mouse/keyboard, Chrome CDP, terminal, SmartScroll, and perception guards",
6
6
  "engines": {