@mseep/clawdcursor 1.5.5
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.
- package/CHANGELOG.md +2264 -0
- package/LICENSE +21 -0
- package/README.md +385 -0
- package/SECURITY.md +44 -0
- package/SKILL.md +503 -0
- package/dist/core/agent-loop/agent.d.ts +42 -0
- package/dist/core/agent-loop/agent.js +1023 -0
- package/dist/core/agent-loop/agent.js.map +1 -0
- package/dist/core/agent-loop/batch-tool.d.ts +25 -0
- package/dist/core/agent-loop/batch-tool.js +218 -0
- package/dist/core/agent-loop/batch-tool.js.map +1 -0
- package/dist/core/agent-loop/coord-scale.d.ts +72 -0
- package/dist/core/agent-loop/coord-scale.js +89 -0
- package/dist/core/agent-loop/coord-scale.js.map +1 -0
- package/dist/core/agent-loop/focus-guard.d.ts +24 -0
- package/dist/core/agent-loop/focus-guard.js +29 -0
- package/dist/core/agent-loop/focus-guard.js.map +1 -0
- package/dist/core/agent-loop/project-mcp.d.ts +97 -0
- package/dist/core/agent-loop/project-mcp.js +253 -0
- package/dist/core/agent-loop/project-mcp.js.map +1 -0
- package/dist/core/agent-loop/prompt.d.ts +45 -0
- package/dist/core/agent-loop/prompt.js +426 -0
- package/dist/core/agent-loop/prompt.js.map +1 -0
- package/dist/core/agent-loop/tool-meta.d.ts +93 -0
- package/dist/core/agent-loop/tool-meta.js +651 -0
- package/dist/core/agent-loop/tool-meta.js.map +1 -0
- package/dist/core/agent-loop/tools.d.ts +38 -0
- package/dist/core/agent-loop/tools.js +2134 -0
- package/dist/core/agent-loop/tools.js.map +1 -0
- package/dist/core/agent-loop/types.d.ts +170 -0
- package/dist/core/agent-loop/types.js +12 -0
- package/dist/core/agent-loop/types.js.map +1 -0
- package/dist/core/agent.d.ts +51 -0
- package/dist/core/agent.js +245 -0
- package/dist/core/agent.js.map +1 -0
- package/dist/core/app-categories.d.ts +67 -0
- package/dist/core/app-categories.js +108 -0
- package/dist/core/app-categories.js.map +1 -0
- package/dist/core/banner.d.ts +70 -0
- package/dist/core/banner.js +245 -0
- package/dist/core/banner.js.map +1 -0
- package/dist/core/classify/capability.d.ts +45 -0
- package/dist/core/classify/capability.js +78 -0
- package/dist/core/classify/capability.js.map +1 -0
- package/dist/core/decompose/llm-decomposer.d.ts +35 -0
- package/dist/core/decompose/llm-decomposer.js +156 -0
- package/dist/core/decompose/llm-decomposer.js.map +1 -0
- package/dist/core/decompose/parser.d.ts +27 -0
- package/dist/core/decompose/parser.js +101 -0
- package/dist/core/decompose/parser.js.map +1 -0
- package/dist/core/observability/correlation.d.ts +19 -0
- package/dist/core/observability/correlation.js +36 -0
- package/dist/core/observability/correlation.js.map +1 -0
- package/dist/core/observability/cost-meter.d.ts +51 -0
- package/dist/core/observability/cost-meter.js +134 -0
- package/dist/core/observability/cost-meter.js.map +1 -0
- package/dist/core/observability/logger.d.ts +61 -0
- package/dist/core/observability/logger.js +550 -0
- package/dist/core/observability/logger.js.map +1 -0
- package/dist/core/router/aliases.d.ts +50 -0
- package/dist/core/router/aliases.js +104 -0
- package/dist/core/router/aliases.js.map +1 -0
- package/dist/core/router/normalize.d.ts +41 -0
- package/dist/core/router/normalize.js +80 -0
- package/dist/core/router/normalize.js.map +1 -0
- package/dist/core/safety.d.ts +126 -0
- package/dist/core/safety.js +568 -0
- package/dist/core/safety.js.map +1 -0
- package/dist/core/sense/a11y-resolver.d.ts +73 -0
- package/dist/core/sense/a11y-resolver.js +76 -0
- package/dist/core/sense/a11y-resolver.js.map +1 -0
- package/dist/core/sense/fingerprint.d.ts +41 -0
- package/dist/core/sense/fingerprint.js +123 -0
- package/dist/core/sense/fingerprint.js.map +1 -0
- package/dist/core/sense/rank.d.ts +70 -0
- package/dist/core/sense/rank.js +192 -0
- package/dist/core/sense/rank.js.map +1 -0
- package/dist/core/sense/reactive-check.d.ts +40 -0
- package/dist/core/sense/reactive-check.js +48 -0
- package/dist/core/sense/reactive-check.js.map +1 -0
- package/dist/core/sense/snapshot.d.ts +19 -0
- package/dist/core/sense/snapshot.js +100 -0
- package/dist/core/sense/snapshot.js.map +1 -0
- package/dist/core/sense/types.d.ts +66 -0
- package/dist/core/sense/types.js +9 -0
- package/dist/core/sense/types.js.map +1 -0
- package/dist/core/sense/ui-map-anchors.d.ts +7 -0
- package/dist/core/sense/ui-map-anchors.js +24 -0
- package/dist/core/sense/ui-map-anchors.js.map +1 -0
- package/dist/core/sense/ui-map-elements.d.ts +5 -0
- package/dist/core/sense/ui-map-elements.js +33 -0
- package/dist/core/sense/ui-map-elements.js.map +1 -0
- package/dist/core/sense/ui-map-find.d.ts +56 -0
- package/dist/core/sense/ui-map-find.js +153 -0
- package/dist/core/sense/ui-map-find.js.map +1 -0
- package/dist/core/sense/ui-map-fuse.d.ts +4 -0
- package/dist/core/sense/ui-map-fuse.js +44 -0
- package/dist/core/sense/ui-map-fuse.js.map +1 -0
- package/dist/core/sense/ui-map-geom.d.ts +3 -0
- package/dist/core/sense/ui-map-geom.js +16 -0
- package/dist/core/sense/ui-map-geom.js.map +1 -0
- package/dist/core/sense/ui-map-holder.d.ts +58 -0
- package/dist/core/sense/ui-map-holder.js +87 -0
- package/dist/core/sense/ui-map-holder.js.map +1 -0
- package/dist/core/sense/ui-map-normalize.d.ts +19 -0
- package/dist/core/sense/ui-map-normalize.js +65 -0
- package/dist/core/sense/ui-map-normalize.js.map +1 -0
- package/dist/core/sense/ui-map-render.d.ts +4 -0
- package/dist/core/sense/ui-map-render.js +34 -0
- package/dist/core/sense/ui-map-render.js.map +1 -0
- package/dist/core/sense/ui-map-resolve.d.ts +41 -0
- package/dist/core/sense/ui-map-resolve.js +59 -0
- package/dist/core/sense/ui-map-resolve.js.map +1 -0
- package/dist/core/sense/ui-map-types.d.ts +66 -0
- package/dist/core/sense/ui-map-types.js +11 -0
- package/dist/core/sense/ui-map-types.js.map +1 -0
- package/dist/core/sense/ui-map.d.ts +29 -0
- package/dist/core/sense/ui-map.js +113 -0
- package/dist/core/sense/ui-map.js.map +1 -0
- package/dist/core/verify/assertions.d.ts +132 -0
- package/dist/core/verify/assertions.js +284 -0
- package/dist/core/verify/assertions.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/browser-config.d.ts +36 -0
- package/dist/llm/browser-config.js +83 -0
- package/dist/llm/browser-config.js.map +1 -0
- package/dist/llm/client.d.ts +268 -0
- package/dist/llm/client.js +1094 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/config.d.ts +79 -0
- package/dist/llm/config.js +375 -0
- package/dist/llm/config.js.map +1 -0
- package/dist/llm/credentials.d.ts +35 -0
- package/dist/llm/credentials.js +491 -0
- package/dist/llm/credentials.js.map +1 -0
- package/dist/llm/external-creds.d.ts +42 -0
- package/dist/llm/external-creds.js +169 -0
- package/dist/llm/external-creds.js.map +1 -0
- package/dist/llm/providers.d.ts +123 -0
- package/dist/llm/providers.js +717 -0
- package/dist/llm/providers.js.map +1 -0
- package/dist/paths.d.ts +31 -0
- package/dist/paths.js +147 -0
- package/dist/paths.js.map +1 -0
- package/dist/platform/accessibility.d.ts +139 -0
- package/dist/platform/accessibility.js +670 -0
- package/dist/platform/accessibility.js.map +1 -0
- package/dist/platform/cdp-driver.d.ts +318 -0
- package/dist/platform/cdp-driver.js +1179 -0
- package/dist/platform/cdp-driver.js.map +1 -0
- package/dist/platform/index.d.ts +11 -0
- package/dist/platform/index.js +69 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/keys.d.ts +17 -0
- package/dist/platform/keys.js +129 -0
- package/dist/platform/keys.js.map +1 -0
- package/dist/platform/launch-poll.d.ts +101 -0
- package/dist/platform/launch-poll.js +177 -0
- package/dist/platform/launch-poll.js.map +1 -0
- package/dist/platform/linux.d.ts +173 -0
- package/dist/platform/linux.js +1253 -0
- package/dist/platform/linux.js.map +1 -0
- package/dist/platform/macos.d.ts +136 -0
- package/dist/platform/macos.js +976 -0
- package/dist/platform/macos.js.map +1 -0
- package/dist/platform/native-desktop.d.ts +145 -0
- package/dist/platform/native-desktop.js +936 -0
- package/dist/platform/native-desktop.js.map +1 -0
- package/dist/platform/native-helper.d.ts +130 -0
- package/dist/platform/native-helper.js +592 -0
- package/dist/platform/native-helper.js.map +1 -0
- package/dist/platform/ocr-engine.d.ts +78 -0
- package/dist/platform/ocr-engine.js +363 -0
- package/dist/platform/ocr-engine.js.map +1 -0
- package/dist/platform/ps-runner.d.ts +28 -0
- package/dist/platform/ps-runner.js +228 -0
- package/dist/platform/ps-runner.js.map +1 -0
- package/dist/platform/types.d.ts +397 -0
- package/dist/platform/types.js +15 -0
- package/dist/platform/types.js.map +1 -0
- package/dist/platform/uri-handler.d.ts +75 -0
- package/dist/platform/uri-handler.js +273 -0
- package/dist/platform/uri-handler.js.map +1 -0
- package/dist/platform/wayland-backend.d.ts +53 -0
- package/dist/platform/wayland-backend.js +348 -0
- package/dist/platform/wayland-backend.js.map +1 -0
- package/dist/platform/windows.d.ts +232 -0
- package/dist/platform/windows.js +1210 -0
- package/dist/platform/windows.js.map +1 -0
- package/dist/postbuild.d.ts +10 -0
- package/dist/postbuild.js +98 -0
- package/dist/postbuild.js.map +1 -0
- package/dist/schema/snapshot.d.ts +33 -0
- package/dist/schema/snapshot.js +90 -0
- package/dist/schema/snapshot.js.map +1 -0
- package/dist/shortcuts.d.ts +30 -0
- package/dist/shortcuts.js +261 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/surface/cli.d.ts +7 -0
- package/dist/surface/cli.js +1556 -0
- package/dist/surface/cli.js.map +1 -0
- package/dist/surface/dashboard.d.ts +8 -0
- package/dist/surface/dashboard.js +1193 -0
- package/dist/surface/dashboard.js.map +1 -0
- package/dist/surface/doctor.d.ts +29 -0
- package/dist/surface/doctor.js +1514 -0
- package/dist/surface/doctor.js.map +1 -0
- package/dist/surface/format.d.ts +10 -0
- package/dist/surface/format.js +37 -0
- package/dist/surface/format.js.map +1 -0
- package/dist/surface/http-utility.d.ts +65 -0
- package/dist/surface/http-utility.js +336 -0
- package/dist/surface/http-utility.js.map +1 -0
- package/dist/surface/mcp-server.d.ts +91 -0
- package/dist/surface/mcp-server.js +280 -0
- package/dist/surface/mcp-server.js.map +1 -0
- package/dist/surface/onboarding.d.ts +15 -0
- package/dist/surface/onboarding.js +184 -0
- package/dist/surface/onboarding.js.map +1 -0
- package/dist/surface/pidfile.d.ts +79 -0
- package/dist/surface/pidfile.js +263 -0
- package/dist/surface/pidfile.js.map +1 -0
- package/dist/surface/readiness.d.ts +45 -0
- package/dist/surface/readiness.js +230 -0
- package/dist/surface/readiness.js.map +1 -0
- package/dist/surface/report.d.ts +68 -0
- package/dist/surface/report.js +341 -0
- package/dist/surface/report.js.map +1 -0
- package/dist/surface/skill-register.d.ts +14 -0
- package/dist/surface/skill-register.js +150 -0
- package/dist/surface/skill-register.js.map +1 -0
- package/dist/surface/version.d.ts +6 -0
- package/dist/surface/version.js +27 -0
- package/dist/surface/version.js.map +1 -0
- package/dist/tools/a11y.d.ts +8 -0
- package/dist/tools/a11y.js +545 -0
- package/dist/tools/a11y.js.map +1 -0
- package/dist/tools/a11y_depth.d.ts +19 -0
- package/dist/tools/a11y_depth.js +455 -0
- package/dist/tools/a11y_depth.js.map +1 -0
- package/dist/tools/agent.d.ts +15 -0
- package/dist/tools/agent.js +248 -0
- package/dist/tools/agent.js.map +1 -0
- package/dist/tools/batch.d.ts +46 -0
- package/dist/tools/batch.js +230 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/cdp.d.ts +8 -0
- package/dist/tools/cdp.js +233 -0
- package/dist/tools/cdp.js.map +1 -0
- package/dist/tools/compact.d.ts +63 -0
- package/dist/tools/compact.js +418 -0
- package/dist/tools/compact.js.map +1 -0
- package/dist/tools/cost-class.d.ts +38 -0
- package/dist/tools/cost-class.js +117 -0
- package/dist/tools/cost-class.js.map +1 -0
- package/dist/tools/desktop.d.ts +9 -0
- package/dist/tools/desktop.js +346 -0
- package/dist/tools/desktop.js.map +1 -0
- package/dist/tools/electron_bridge.d.ts +41 -0
- package/dist/tools/electron_bridge.js +261 -0
- package/dist/tools/electron_bridge.js.map +1 -0
- package/dist/tools/extras.d.ts +22 -0
- package/dist/tools/extras.js +942 -0
- package/dist/tools/extras.js.map +1 -0
- package/dist/tools/favorites.d.ts +13 -0
- package/dist/tools/favorites.js +137 -0
- package/dist/tools/favorites.js.map +1 -0
- package/dist/tools/introspection.d.ts +13 -0
- package/dist/tools/introspection.js +55 -0
- package/dist/tools/introspection.js.map +1 -0
- package/dist/tools/ocr.d.ts +8 -0
- package/dist/tools/ocr.js +66 -0
- package/dist/tools/ocr.js.map +1 -0
- package/dist/tools/orchestration.d.ts +7 -0
- package/dist/tools/orchestration.js +377 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/playbooks/extract-compose.d.ts +22 -0
- package/dist/tools/playbooks/extract-compose.js +85 -0
- package/dist/tools/playbooks/extract-compose.js.map +1 -0
- package/dist/tools/playbooks/find-replace.d.ts +11 -0
- package/dist/tools/playbooks/find-replace.js +56 -0
- package/dist/tools/playbooks/find-replace.js.map +1 -0
- package/dist/tools/playbooks/index.d.ts +63 -0
- package/dist/tools/playbooks/index.js +70 -0
- package/dist/tools/playbooks/index.js.map +1 -0
- package/dist/tools/playbooks/keys-blocklist.d.ts +24 -0
- package/dist/tools/playbooks/keys-blocklist.js +89 -0
- package/dist/tools/playbooks/keys-blocklist.js.map +1 -0
- package/dist/tools/registry.d.ts +40 -0
- package/dist/tools/registry.js +560 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/safety-gate.d.ts +16 -0
- package/dist/tools/safety-gate.js +70 -0
- package/dist/tools/safety-gate.js.map +1 -0
- package/dist/tools/scheduler.d.ts +76 -0
- package/dist/tools/scheduler.js +413 -0
- package/dist/tools/scheduler.js.map +1 -0
- package/dist/tools/shortcuts.d.ts +13 -0
- package/dist/tools/shortcuts.js +205 -0
- package/dist/tools/shortcuts.js.map +1 -0
- package/dist/tools/smart.d.ts +15 -0
- package/dist/tools/smart.js +785 -0
- package/dist/tools/smart.js.map +1 -0
- package/dist/tools/types.d.ts +174 -0
- package/dist/tools/types.js +67 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/window-text.d.ts +15 -0
- package/dist/tools/window-text.js +39 -0
- package/dist/tools/window-text.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.js +41 -0
- package/dist/types.js.map +1 -0
- package/native/Package.swift +38 -0
- package/native/README.md +113 -0
- package/native/Sources/ClawdCursorHelper/main.swift +602 -0
- package/native/Sources/ClawdCursorHost/main.swift +182 -0
- package/native/Sources/PermissionCheck/main.swift +53 -0
- package/native/Sources/ScreenshotHelper/main.swift +219 -0
- package/native/build.sh +139 -0
- package/native/entitlements.plist +12 -0
- package/package.json +115 -0
- package/scripts/banner.ps1 +112 -0
- package/scripts/coord-accuracy.ps1 +140 -0
- package/scripts/coord-uwp.ps1 +80 -0
- package/scripts/edge-glow.ps1 +180 -0
- package/scripts/find-element.ps1 +198 -0
- package/scripts/get-foreground-window.ps1 +71 -0
- package/scripts/get-screen-context.ps1 +183 -0
- package/scripts/get-windows.ps1 +66 -0
- package/scripts/install-panic-hotkey.ps1 +46 -0
- package/scripts/interact-element.ps1 +431 -0
- package/scripts/invoke-element.ps1 +314 -0
- package/scripts/linux/atspi-bridge.py +356 -0
- package/scripts/linux/ocr-recognize.py +154 -0
- package/scripts/mac/_window-picker.jxa +163 -0
- package/scripts/mac/find-element.jxa +0 -0
- package/scripts/mac/find-element.sh +161 -0
- package/scripts/mac/focus-window.jxa +284 -0
- package/scripts/mac/get-focused-element.jxa +102 -0
- package/scripts/mac/get-foreground-window.jxa +173 -0
- package/scripts/mac/get-screen-context.jxa +197 -0
- package/scripts/mac/get-ui-tree.sh +141 -0
- package/scripts/mac/get-windows.jxa +117 -0
- package/scripts/mac/interact-element.sh +235 -0
- package/scripts/mac/invoke-element.jxa +408 -0
- package/scripts/mac/ocr-recognize.swift +124 -0
- package/scripts/ocr-recognize.ps1 +102 -0
- package/scripts/postinstall-native.js +48 -0
- package/scripts/ps-bridge.ps1 +830 -0
- package/scripts/smoke-mcp.ps1 +119 -0
- package/scripts/sync-version.ts +178 -0
- package/scripts/verify-install.js +81 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OcrEngine — OS-level OCR bridge.
|
|
3
|
+
*
|
|
4
|
+
* Takes a screenshot (or region), returns structured OCR results with bounding boxes.
|
|
5
|
+
* Coordinates are in REAL screen pixels — no scaleFactor conversion needed.
|
|
6
|
+
*
|
|
7
|
+
* Windows: Windows.Media.Ocr via PowerShell one-shot (scripts/ocr-recognize.ps1).
|
|
8
|
+
* macOS: Apple Vision framework via Swift script (scripts/mac/ocr-recognize.swift).
|
|
9
|
+
* Linux: Tesseract OCR via Python script (scripts/linux/ocr-recognize.py).
|
|
10
|
+
*
|
|
11
|
+
* Caching: last result is kept for 300ms. Invalidated on any action execution.
|
|
12
|
+
*/
|
|
13
|
+
export interface OcrElement {
|
|
14
|
+
text: string;
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
confidence: number;
|
|
20
|
+
line: number;
|
|
21
|
+
}
|
|
22
|
+
export interface OcrResult {
|
|
23
|
+
elements: OcrElement[];
|
|
24
|
+
fullText: string;
|
|
25
|
+
durationMs: number;
|
|
26
|
+
}
|
|
27
|
+
export declare class OcrEngine {
|
|
28
|
+
private cachedResult;
|
|
29
|
+
private cacheTimestamp;
|
|
30
|
+
private available;
|
|
31
|
+
/**
|
|
32
|
+
* Check if OS-level OCR is available on this platform.
|
|
33
|
+
* Never throws.
|
|
34
|
+
*/
|
|
35
|
+
isAvailable(): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Invalidate the cached OCR result.
|
|
38
|
+
* Call after any action execution so the next read is fresh.
|
|
39
|
+
*/
|
|
40
|
+
invalidateCache(): void;
|
|
41
|
+
/**
|
|
42
|
+
* OCR the entire screen. Returns cached result if within 300ms window.
|
|
43
|
+
* Never throws — returns EMPTY_RESULT on failure and degrades gracefully.
|
|
44
|
+
*/
|
|
45
|
+
recognizeScreen(): Promise<OcrResult>;
|
|
46
|
+
/**
|
|
47
|
+
* OCR a rectangular region of the screen.
|
|
48
|
+
* Coordinates are in real screen pixels (input and output).
|
|
49
|
+
* Never throws.
|
|
50
|
+
*/
|
|
51
|
+
recognizeRegion(x: number, y: number, w: number, h: number): Promise<OcrResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Dispatch to the platform-specific OCR implementation.
|
|
54
|
+
*/
|
|
55
|
+
private runOcr;
|
|
56
|
+
/**
|
|
57
|
+
* Windows: spawn PowerShell to invoke Windows.Media.Ocr WinRT API.
|
|
58
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
59
|
+
*/
|
|
60
|
+
private runWindowsOcr;
|
|
61
|
+
/**
|
|
62
|
+
* macOS: run Swift script that uses Apple Vision framework (VNRecognizeTextRequest).
|
|
63
|
+
* Requires macOS 10.15+ and Xcode command-line tools (swift).
|
|
64
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
65
|
+
*/
|
|
66
|
+
private runMacOcr;
|
|
67
|
+
/**
|
|
68
|
+
* Linux: run Python script that uses Tesseract OCR.
|
|
69
|
+
* Requires: tesseract-ocr package + python3.
|
|
70
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
71
|
+
*/
|
|
72
|
+
private runLinuxOcr;
|
|
73
|
+
/**
|
|
74
|
+
* Shared JSON parser for macOS/Linux OCR output.
|
|
75
|
+
* Both scripts emit the same { elements, fullText } format.
|
|
76
|
+
*/
|
|
77
|
+
private parseOcrJson;
|
|
78
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OcrEngine — OS-level OCR bridge.
|
|
4
|
+
*
|
|
5
|
+
* Takes a screenshot (or region), returns structured OCR results with bounding boxes.
|
|
6
|
+
* Coordinates are in REAL screen pixels — no scaleFactor conversion needed.
|
|
7
|
+
*
|
|
8
|
+
* Windows: Windows.Media.Ocr via PowerShell one-shot (scripts/ocr-recognize.ps1).
|
|
9
|
+
* macOS: Apple Vision framework via Swift script (scripts/mac/ocr-recognize.swift).
|
|
10
|
+
* Linux: Tesseract OCR via Python script (scripts/linux/ocr-recognize.py).
|
|
11
|
+
*
|
|
12
|
+
* Caching: last result is kept for 300ms. Invalidated on any action execution.
|
|
13
|
+
*/
|
|
14
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(o, k2, desc);
|
|
21
|
+
}) : (function(o, m, k, k2) {
|
|
22
|
+
if (k2 === undefined) k2 = k;
|
|
23
|
+
o[k2] = m[k];
|
|
24
|
+
}));
|
|
25
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
+
}) : function(o, v) {
|
|
28
|
+
o["default"] = v;
|
|
29
|
+
});
|
|
30
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
31
|
+
var ownKeys = function(o) {
|
|
32
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
33
|
+
var ar = [];
|
|
34
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
35
|
+
return ar;
|
|
36
|
+
};
|
|
37
|
+
return ownKeys(o);
|
|
38
|
+
};
|
|
39
|
+
return function (mod) {
|
|
40
|
+
if (mod && mod.__esModule) return mod;
|
|
41
|
+
var result = {};
|
|
42
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
43
|
+
__setModuleDefault(result, mod);
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
48
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
49
|
+
};
|
|
50
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
|
+
exports.OcrEngine = void 0;
|
|
52
|
+
const os = __importStar(require("os"));
|
|
53
|
+
const path = __importStar(require("path"));
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const crypto = __importStar(require("crypto"));
|
|
56
|
+
const child_process_1 = require("child_process");
|
|
57
|
+
const util_1 = require("util");
|
|
58
|
+
const nut_js_1 = require("@nut-tree-fork/nut-js");
|
|
59
|
+
const sharp_1 = __importDefault(require("sharp"));
|
|
60
|
+
const paths_1 = require("../paths");
|
|
61
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
62
|
+
const SCRIPTS_DIR = path.join((0, paths_1.getPackageRoot)(), 'scripts');
|
|
63
|
+
const OCR_SCRIPT = path.join(SCRIPTS_DIR, 'ocr-recognize.ps1');
|
|
64
|
+
const MAC_OCR_SCRIPT = path.join(SCRIPTS_DIR, 'mac', 'ocr-recognize.swift');
|
|
65
|
+
const LINUX_OCR_SCRIPT = path.join(SCRIPTS_DIR, 'linux', 'ocr-recognize.py');
|
|
66
|
+
const CACHE_TTL_MS = 300;
|
|
67
|
+
const OCR_TIMEOUT = 15000; // 15s — WinRT assembly load + recognition
|
|
68
|
+
const MAC_OCR_TIMEOUT = 20000; // 20s — Swift compilation on first run
|
|
69
|
+
const LINUX_OCR_TIMEOUT = 30000; // 30s — Tesseract can be slow on large images
|
|
70
|
+
const MAX_BUFFER = 4 * 1024 * 1024; // 4MB — large screens with dense text
|
|
71
|
+
const EMPTY_RESULT = Object.freeze({ elements: [], fullText: '', durationMs: 0 });
|
|
72
|
+
// ─── OcrEngine ────────────────────────────────────────────────────────────────
|
|
73
|
+
class OcrEngine {
|
|
74
|
+
cachedResult = null;
|
|
75
|
+
cacheTimestamp = 0;
|
|
76
|
+
available = null;
|
|
77
|
+
/**
|
|
78
|
+
* Check if OS-level OCR is available on this platform.
|
|
79
|
+
* Never throws.
|
|
80
|
+
*/
|
|
81
|
+
isAvailable() {
|
|
82
|
+
if (this.available !== null)
|
|
83
|
+
return this.available;
|
|
84
|
+
if (process.platform === 'win32') {
|
|
85
|
+
// Windows.Media.Ocr ships with Windows 10+.
|
|
86
|
+
// Actual availability (language packs) is verified on first recognizeScreen() call.
|
|
87
|
+
this.available = true;
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (process.platform === 'darwin') {
|
|
91
|
+
// macOS: Apple Vision framework via Swift script.
|
|
92
|
+
// Available on macOS 10.15+ (Catalina and later).
|
|
93
|
+
// swift is always present on macOS with Xcode CLI tools.
|
|
94
|
+
try {
|
|
95
|
+
const { execFileSync } = require('child_process');
|
|
96
|
+
execFileSync('which', ['swift'], { timeout: 3000, stdio: 'pipe' });
|
|
97
|
+
this.available = fs.existsSync(MAC_OCR_SCRIPT);
|
|
98
|
+
if (this.available) {
|
|
99
|
+
console.log('[OCR] macOS Vision framework available via Swift');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
this.available = false;
|
|
104
|
+
}
|
|
105
|
+
return this.available;
|
|
106
|
+
}
|
|
107
|
+
if (process.platform === 'linux') {
|
|
108
|
+
// Linux: Tesseract OCR via Python script.
|
|
109
|
+
// Requires: sudo apt install tesseract-ocr && python3
|
|
110
|
+
try {
|
|
111
|
+
const { execFileSync } = require('child_process');
|
|
112
|
+
execFileSync('which', ['tesseract'], { timeout: 3000, stdio: 'pipe' });
|
|
113
|
+
execFileSync('which', ['python3'], { timeout: 3000, stdio: 'pipe' });
|
|
114
|
+
this.available = fs.existsSync(LINUX_OCR_SCRIPT);
|
|
115
|
+
if (this.available) {
|
|
116
|
+
console.log('[OCR] Linux Tesseract OCR available');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
this.available = false;
|
|
121
|
+
}
|
|
122
|
+
return this.available;
|
|
123
|
+
}
|
|
124
|
+
this.available = false;
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Invalidate the cached OCR result.
|
|
129
|
+
* Call after any action execution so the next read is fresh.
|
|
130
|
+
*/
|
|
131
|
+
invalidateCache() {
|
|
132
|
+
this.cachedResult = null;
|
|
133
|
+
this.cacheTimestamp = 0;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* OCR the entire screen. Returns cached result if within 300ms window.
|
|
137
|
+
* Never throws — returns EMPTY_RESULT on failure and degrades gracefully.
|
|
138
|
+
*/
|
|
139
|
+
async recognizeScreen() {
|
|
140
|
+
if (!this.isAvailable())
|
|
141
|
+
return { ...EMPTY_RESULT };
|
|
142
|
+
// Return cached if fresh
|
|
143
|
+
const now = Date.now();
|
|
144
|
+
if (this.cachedResult && (now - this.cacheTimestamp) < CACHE_TTL_MS) {
|
|
145
|
+
return this.cachedResult;
|
|
146
|
+
}
|
|
147
|
+
const start = Date.now();
|
|
148
|
+
try {
|
|
149
|
+
// Capture full-resolution screenshot via nut-js
|
|
150
|
+
const img = await nut_js_1.screen.grab();
|
|
151
|
+
if (!this.cachedResult) {
|
|
152
|
+
// Log image dimensions on first capture to diagnose coordinate space issues
|
|
153
|
+
console.log(`[OCR] Screenshot captured: ${img.width}x${img.height}px`);
|
|
154
|
+
}
|
|
155
|
+
const pngBuffer = await (0, sharp_1.default)(img.data, {
|
|
156
|
+
raw: { width: img.width, height: img.height, channels: 4 },
|
|
157
|
+
}).png().toBuffer();
|
|
158
|
+
// Release the raw RGBA buffer immediately after processing
|
|
159
|
+
img.data = null;
|
|
160
|
+
// Save to temp file — OS OCR reads from disk
|
|
161
|
+
const tmpPath = path.join(os.tmpdir(), `clawdcursor-ocr-${process.pid}-${crypto.randomUUID().slice(0, 8)}.png`);
|
|
162
|
+
fs.writeFileSync(tmpPath, pngBuffer);
|
|
163
|
+
try {
|
|
164
|
+
const result = await this.runOcr(tmpPath);
|
|
165
|
+
result.durationMs = Date.now() - start;
|
|
166
|
+
// Cache
|
|
167
|
+
this.cachedResult = result;
|
|
168
|
+
this.cacheTimestamp = Date.now();
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
try {
|
|
173
|
+
fs.unlinkSync(tmpPath);
|
|
174
|
+
}
|
|
175
|
+
catch { /* non-fatal */ }
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
console.error(`[OCR] recognizeScreen failed: ${err?.message}`);
|
|
180
|
+
// If first call ever fails, mark unavailable so pipeline degrades to vision LLM
|
|
181
|
+
if (this.cachedResult === null) {
|
|
182
|
+
this.available = false;
|
|
183
|
+
}
|
|
184
|
+
return { ...EMPTY_RESULT, durationMs: Date.now() - start };
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* OCR a rectangular region of the screen.
|
|
189
|
+
* Coordinates are in real screen pixels (input and output).
|
|
190
|
+
* Never throws.
|
|
191
|
+
*/
|
|
192
|
+
async recognizeRegion(x, y, w, h) {
|
|
193
|
+
if (!this.isAvailable())
|
|
194
|
+
return { ...EMPTY_RESULT };
|
|
195
|
+
const start = Date.now();
|
|
196
|
+
try {
|
|
197
|
+
const img = await nut_js_1.screen.grab();
|
|
198
|
+
// Clamp to screen bounds
|
|
199
|
+
const rx = Math.max(0, Math.min(x, img.width - 1));
|
|
200
|
+
const ry = Math.max(0, Math.min(y, img.height - 1));
|
|
201
|
+
const rw = Math.min(w, img.width - rx);
|
|
202
|
+
const rh = Math.min(h, img.height - ry);
|
|
203
|
+
const pngBuffer = await (0, sharp_1.default)(img.data, {
|
|
204
|
+
raw: { width: img.width, height: img.height, channels: 4 },
|
|
205
|
+
})
|
|
206
|
+
.extract({ left: rx, top: ry, width: rw, height: rh })
|
|
207
|
+
.png()
|
|
208
|
+
.toBuffer();
|
|
209
|
+
// Release the raw RGBA buffer immediately after processing
|
|
210
|
+
img.data = null;
|
|
211
|
+
const tmpPath = path.join(os.tmpdir(), `clawdcursor-ocr-region-${process.pid}-${crypto.randomUUID().slice(0, 8)}.png`);
|
|
212
|
+
fs.writeFileSync(tmpPath, pngBuffer);
|
|
213
|
+
try {
|
|
214
|
+
const result = await this.runOcr(tmpPath);
|
|
215
|
+
result.durationMs = Date.now() - start;
|
|
216
|
+
// Offset coordinates back to full-screen space
|
|
217
|
+
for (const el of result.elements) {
|
|
218
|
+
el.x += rx;
|
|
219
|
+
el.y += ry;
|
|
220
|
+
}
|
|
221
|
+
return result;
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
try {
|
|
225
|
+
fs.unlinkSync(tmpPath);
|
|
226
|
+
}
|
|
227
|
+
catch { /* non-fatal */ }
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch (err) {
|
|
231
|
+
console.error(`[OCR] recognizeRegion failed: ${err?.message}`);
|
|
232
|
+
return { ...EMPTY_RESULT, durationMs: Date.now() - start };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// ─── Private ──────────────────────────────────────────────────────────────
|
|
236
|
+
/**
|
|
237
|
+
* Dispatch to the platform-specific OCR implementation.
|
|
238
|
+
*/
|
|
239
|
+
async runOcr(imagePath) {
|
|
240
|
+
if (process.platform === 'win32') {
|
|
241
|
+
return this.runWindowsOcr(imagePath);
|
|
242
|
+
}
|
|
243
|
+
if (process.platform === 'darwin') {
|
|
244
|
+
return this.runMacOcr(imagePath);
|
|
245
|
+
}
|
|
246
|
+
if (process.platform === 'linux') {
|
|
247
|
+
return this.runLinuxOcr(imagePath);
|
|
248
|
+
}
|
|
249
|
+
return { ...EMPTY_RESULT };
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Windows: spawn PowerShell to invoke Windows.Media.Ocr WinRT API.
|
|
253
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
254
|
+
*/
|
|
255
|
+
async runWindowsOcr(imagePath) {
|
|
256
|
+
const { stdout } = await execFileAsync('powershell.exe', [
|
|
257
|
+
'-NoProfile',
|
|
258
|
+
'-NonInteractive',
|
|
259
|
+
'-ExecutionPolicy', 'Bypass',
|
|
260
|
+
'-File', OCR_SCRIPT,
|
|
261
|
+
imagePath,
|
|
262
|
+
], {
|
|
263
|
+
timeout: OCR_TIMEOUT,
|
|
264
|
+
maxBuffer: MAX_BUFFER,
|
|
265
|
+
windowsHide: true,
|
|
266
|
+
});
|
|
267
|
+
const trimmed = stdout.trim();
|
|
268
|
+
if (!trimmed) {
|
|
269
|
+
throw new Error('PowerShell OCR script returned empty output');
|
|
270
|
+
}
|
|
271
|
+
// Sanitize control characters that PowerShell's ConvertTo-Json may leave unescaped
|
|
272
|
+
// (e.g. bell \x07 from OCR'd icons). Keep \t, \n, \r which are valid in JSON.
|
|
273
|
+
const sanitized = trimmed.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, '');
|
|
274
|
+
const data = JSON.parse(sanitized);
|
|
275
|
+
if (data.error) {
|
|
276
|
+
throw new Error(data.error);
|
|
277
|
+
}
|
|
278
|
+
const rawElements = Array.isArray(data.elements) ? data.elements : [];
|
|
279
|
+
const elements = rawElements.map((el) => ({
|
|
280
|
+
text: String(el.text ?? ''),
|
|
281
|
+
x: Number(el.x) || 0,
|
|
282
|
+
y: Number(el.y) || 0,
|
|
283
|
+
width: Number(el.width) || 0,
|
|
284
|
+
height: Number(el.height) || 0,
|
|
285
|
+
confidence: Number(el.confidence) || 0,
|
|
286
|
+
line: Number(el.line) || 0,
|
|
287
|
+
}));
|
|
288
|
+
return {
|
|
289
|
+
elements,
|
|
290
|
+
fullText: String(data.fullText ?? ''),
|
|
291
|
+
durationMs: 0, // filled by caller
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* macOS: run Swift script that uses Apple Vision framework (VNRecognizeTextRequest).
|
|
296
|
+
* Requires macOS 10.15+ and Xcode command-line tools (swift).
|
|
297
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
298
|
+
*/
|
|
299
|
+
async runMacOcr(imagePath) {
|
|
300
|
+
const { stdout } = await execFileAsync('swift', [
|
|
301
|
+
MAC_OCR_SCRIPT,
|
|
302
|
+
imagePath,
|
|
303
|
+
], {
|
|
304
|
+
timeout: MAC_OCR_TIMEOUT,
|
|
305
|
+
maxBuffer: MAX_BUFFER,
|
|
306
|
+
});
|
|
307
|
+
const trimmed = stdout.trim();
|
|
308
|
+
if (!trimmed) {
|
|
309
|
+
throw new Error('Swift OCR script returned empty output');
|
|
310
|
+
}
|
|
311
|
+
const data = JSON.parse(trimmed);
|
|
312
|
+
if (data.error) {
|
|
313
|
+
throw new Error(data.error);
|
|
314
|
+
}
|
|
315
|
+
return this.parseOcrJson(data);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Linux: run Python script that uses Tesseract OCR.
|
|
319
|
+
* Requires: tesseract-ocr package + python3.
|
|
320
|
+
* The script outputs a single JSON line with { elements, fullText }.
|
|
321
|
+
*/
|
|
322
|
+
async runLinuxOcr(imagePath) {
|
|
323
|
+
const { stdout } = await execFileAsync('python3', [
|
|
324
|
+
LINUX_OCR_SCRIPT,
|
|
325
|
+
imagePath,
|
|
326
|
+
], {
|
|
327
|
+
timeout: LINUX_OCR_TIMEOUT,
|
|
328
|
+
maxBuffer: MAX_BUFFER,
|
|
329
|
+
});
|
|
330
|
+
const trimmed = stdout.trim();
|
|
331
|
+
if (!trimmed) {
|
|
332
|
+
throw new Error('Python OCR script returned empty output');
|
|
333
|
+
}
|
|
334
|
+
const data = JSON.parse(trimmed);
|
|
335
|
+
if (data.error) {
|
|
336
|
+
throw new Error(data.error);
|
|
337
|
+
}
|
|
338
|
+
return this.parseOcrJson(data);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Shared JSON parser for macOS/Linux OCR output.
|
|
342
|
+
* Both scripts emit the same { elements, fullText } format.
|
|
343
|
+
*/
|
|
344
|
+
parseOcrJson(data) {
|
|
345
|
+
const rawElements = Array.isArray(data.elements) ? data.elements : [];
|
|
346
|
+
const elements = rawElements.map((el) => ({
|
|
347
|
+
text: String(el.text ?? ''),
|
|
348
|
+
x: Number(el.x) || 0,
|
|
349
|
+
y: Number(el.y) || 0,
|
|
350
|
+
width: Number(el.width) || 0,
|
|
351
|
+
height: Number(el.height) || 0,
|
|
352
|
+
confidence: Number(el.confidence) || 0,
|
|
353
|
+
line: Number(el.line) || 0,
|
|
354
|
+
}));
|
|
355
|
+
return {
|
|
356
|
+
elements,
|
|
357
|
+
fullText: String(data.fullText ?? ''),
|
|
358
|
+
durationMs: 0, // filled by caller
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
exports.OcrEngine = OcrEngine;
|
|
363
|
+
//# sourceMappingURL=ocr-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ocr-engine.js","sourceRoot":"","sources":["../../src/platform/ocr-engine.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,+CAAiC;AACjC,iDAAyC;AACzC,+BAAiC;AACjC,kDAA+C;AAC/C,kDAA0B;AAC1B,oCAA0C;AAE1C,MAAM,aAAa,GAAG,IAAA,gBAAS,EAAC,wBAAQ,CAAC,CAAC;AAE1C,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,sBAAc,GAAE,EAAE,SAAS,CAAC,CAAC;AAC3D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,mBAAmB,CAAC,CAAC;AAC/D,MAAM,cAAc,GAAG,IAAI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mB;SACnC,CAAC;IACJ,CAAC;CACF;AAxTD,8BAwTC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PSRunner — Persistent PowerShell UIA bridge.
|
|
3
|
+
*
|
|
4
|
+
* Keeps one powershell.exe alive for the entire session.
|
|
5
|
+
* UI Automation assemblies are loaded once at startup (~800ms).
|
|
6
|
+
* Each subsequent command costs only the actual work — no 200-500ms spawn overhead.
|
|
7
|
+
*
|
|
8
|
+
* Protocol: newline-delimited JSON on stdin/stdout.
|
|
9
|
+
* Send: {"cmd":"invoke-element","processId":123,...}\n
|
|
10
|
+
* Recv: {"success":true,...}\n
|
|
11
|
+
*
|
|
12
|
+
* Commands are serialized (one at a time), queued if a call is in-flight.
|
|
13
|
+
*/
|
|
14
|
+
export declare class PSRunner {
|
|
15
|
+
private proc;
|
|
16
|
+
private rl;
|
|
17
|
+
private ready;
|
|
18
|
+
private dead;
|
|
19
|
+
private queue;
|
|
20
|
+
private current;
|
|
21
|
+
private startPromise;
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
private _start;
|
|
24
|
+
run(command: Record<string, unknown>): Promise<unknown>;
|
|
25
|
+
private _drain;
|
|
26
|
+
stop(): void;
|
|
27
|
+
}
|
|
28
|
+
export declare const psRunner: PSRunner;
|