@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,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URI-scheme handler resolution + verified launch (Windows).
|
|
3
|
+
*
|
|
4
|
+
* Why this exists: the obvious dispatch routes (`explorer.exe mailto:...`,
|
|
5
|
+
* `rundll32 url.dll,FileProtocolHandler`, `cmd /c start "" "mailto:..."`)
|
|
6
|
+
* silently fail to open a compose window for New Outlook (`olk.exe`). The
|
|
7
|
+
* shell-routed paths return without error, no new window appears, and
|
|
8
|
+
* the agent thinks the dispatch worked. The only reliable Windows path
|
|
9
|
+
* is to resolve the registered handler executable and invoke IT directly
|
|
10
|
+
* with the URI as an argument.
|
|
11
|
+
*
|
|
12
|
+
* This module:
|
|
13
|
+
* 1. Resolves the user's default handler for a URI scheme by walking
|
|
14
|
+
* HKCU UserChoice -> HKCR ProgId -> shell\open\command.
|
|
15
|
+
* 2. Falls back to a known-good list of common handlers when the
|
|
16
|
+
* registry lookup fails (New Outlook is the main case today).
|
|
17
|
+
* 3. Launches the handler with the URI and VERIFIES a new visible
|
|
18
|
+
* top-level window appeared in the handler process within a
|
|
19
|
+
* bounded timeout. Returns honest success/failure.
|
|
20
|
+
*
|
|
21
|
+
* macOS and Linux already have reliable shell dispatch (`open` and
|
|
22
|
+
* `xdg-open`), so this module is Windows-only. Callers should keep
|
|
23
|
+
* using the platform-native dispatchers there.
|
|
24
|
+
*/
|
|
25
|
+
/**
|
|
26
|
+
* Resolve the executable path for the user's default handler of `scheme`
|
|
27
|
+
* (e.g. "mailto", "http", "tel"). Returns null when no handler is
|
|
28
|
+
* registered or when the registry lookup fails for any reason.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolveSchemeHandlerExecutable(scheme: string): Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Is `scheme` a registered URI protocol in HKCR (has a `URL Protocol` value)?
|
|
33
|
+
* Some schemes (ms-settings:, ms-windows-store:, …) ARE registered but route
|
|
34
|
+
* through a `DelegateExecute` COM handler with an EMPTY shell\open\command — so
|
|
35
|
+
* resolveSchemeHandlerExecutable() returns null even though the OS can open
|
|
36
|
+
* them. Only ShellExecute (Start-Process) honors DelegateExecute. This lets the
|
|
37
|
+
* caller decide to fall back to a shell dispatch instead of failing outright.
|
|
38
|
+
*/
|
|
39
|
+
export declare function isRegisteredUriScheme(scheme: string): Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* Dispatch a URI via ShellExecute (PowerShell `Start-Process`) — the ONLY path
|
|
42
|
+
* that honors `DelegateExecute` COM handlers (ms-settings: et al.) — and verify
|
|
43
|
+
* a NEW visible top-level window appeared by diffing the full window list
|
|
44
|
+
* before/after. The handler process is unknown (SystemSettings.exe for
|
|
45
|
+
* ms-settings, etc.), so this diffs ALL windows rather than one process.
|
|
46
|
+
*
|
|
47
|
+
* The URI (agent-controlled) is passed via an ENV VAR, never interpolated into
|
|
48
|
+
* the command string — no shell-injection surface.
|
|
49
|
+
*/
|
|
50
|
+
export declare function shellDispatchUriAndVerify(uri: string, listWindows: () => Promise<Array<{
|
|
51
|
+
title?: string;
|
|
52
|
+
handle?: number | string;
|
|
53
|
+
}>>, opts?: {
|
|
54
|
+
waitMs?: number;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
windowOpened: boolean;
|
|
57
|
+
title?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Launch the resolved handler with the URI and verify that a NEW visible
|
|
62
|
+
* top-level window appeared in the handler process. Returns:
|
|
63
|
+
* { success: true, windowOpened: true, hwndLabel } when a new window appeared.
|
|
64
|
+
* { success: true, windowOpened: false } when the handler ran but no new window appeared
|
|
65
|
+
* (handler probably routed to an existing instance silently).
|
|
66
|
+
* { success: false, error } when the launch itself failed.
|
|
67
|
+
*/
|
|
68
|
+
export declare function launchHandlerAndVerify(exePath: string, uri: string, opts?: {
|
|
69
|
+
waitMs?: number;
|
|
70
|
+
}): Promise<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
windowOpened: boolean;
|
|
73
|
+
hwndLabel?: string;
|
|
74
|
+
error?: string;
|
|
75
|
+
}>;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* URI-scheme handler resolution + verified launch (Windows).
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: the obvious dispatch routes (`explorer.exe mailto:...`,
|
|
6
|
+
* `rundll32 url.dll,FileProtocolHandler`, `cmd /c start "" "mailto:..."`)
|
|
7
|
+
* silently fail to open a compose window for New Outlook (`olk.exe`). The
|
|
8
|
+
* shell-routed paths return without error, no new window appears, and
|
|
9
|
+
* the agent thinks the dispatch worked. The only reliable Windows path
|
|
10
|
+
* is to resolve the registered handler executable and invoke IT directly
|
|
11
|
+
* with the URI as an argument.
|
|
12
|
+
*
|
|
13
|
+
* This module:
|
|
14
|
+
* 1. Resolves the user's default handler for a URI scheme by walking
|
|
15
|
+
* HKCU UserChoice -> HKCR ProgId -> shell\open\command.
|
|
16
|
+
* 2. Falls back to a known-good list of common handlers when the
|
|
17
|
+
* registry lookup fails (New Outlook is the main case today).
|
|
18
|
+
* 3. Launches the handler with the URI and VERIFIES a new visible
|
|
19
|
+
* top-level window appeared in the handler process within a
|
|
20
|
+
* bounded timeout. Returns honest success/failure.
|
|
21
|
+
*
|
|
22
|
+
* macOS and Linux already have reliable shell dispatch (`open` and
|
|
23
|
+
* `xdg-open`), so this module is Windows-only. Callers should keep
|
|
24
|
+
* using the platform-native dispatchers there.
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.resolveSchemeHandlerExecutable = resolveSchemeHandlerExecutable;
|
|
28
|
+
exports.isRegisteredUriScheme = isRegisteredUriScheme;
|
|
29
|
+
exports.shellDispatchUriAndVerify = shellDispatchUriAndVerify;
|
|
30
|
+
exports.launchHandlerAndVerify = launchHandlerAndVerify;
|
|
31
|
+
const node_child_process_1 = require("node:child_process");
|
|
32
|
+
const node_util_1 = require("node:util");
|
|
33
|
+
const execFileAsync = (0, node_util_1.promisify)(node_child_process_1.execFile);
|
|
34
|
+
/**
|
|
35
|
+
* Resolve the executable path for the user's default handler of `scheme`
|
|
36
|
+
* (e.g. "mailto", "http", "tel"). Returns null when no handler is
|
|
37
|
+
* registered or when the registry lookup fails for any reason.
|
|
38
|
+
*/
|
|
39
|
+
async function resolveSchemeHandlerExecutable(scheme) {
|
|
40
|
+
if (process.platform !== 'win32')
|
|
41
|
+
return null;
|
|
42
|
+
const s = scheme.toLowerCase();
|
|
43
|
+
// Step 1: HKCU\SOFTWARE\Microsoft\Windows\Shell\Associations\UrlAssociations\<scheme>\UserChoice
|
|
44
|
+
// -> ProgId
|
|
45
|
+
const userChoicePath = `HKCU\\SOFTWARE\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\${s}\\UserChoice`;
|
|
46
|
+
let progId = null;
|
|
47
|
+
try {
|
|
48
|
+
const { stdout } = await execFileAsync('reg', ['query', userChoicePath, '/v', 'ProgId'], { timeout: 3000 });
|
|
49
|
+
const m = stdout.match(/ProgId\s+REG_SZ\s+(.+?)[\r\n]/);
|
|
50
|
+
if (m)
|
|
51
|
+
progId = m[1].trim();
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// No UserChoice — fall through.
|
|
55
|
+
}
|
|
56
|
+
// Step 2: HKCR\<ProgId>\Shell\open\command -> (default)
|
|
57
|
+
if (progId) {
|
|
58
|
+
const cmdPath = `HKCR\\${progId}\\Shell\\open\\command`;
|
|
59
|
+
try {
|
|
60
|
+
const { stdout } = await execFileAsync('reg', ['query', cmdPath, '/ve'], { timeout: 3000 });
|
|
61
|
+
const m = stdout.match(/\(Default\)\s+REG_(?:SZ|EXPAND_SZ)\s+(.+?)[\r\n]/);
|
|
62
|
+
if (m) {
|
|
63
|
+
const exe = extractExecutableFromCommand(m[1]);
|
|
64
|
+
if (exe)
|
|
65
|
+
return exe;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// ProgId points at a UWP app that doesn't expose shell\open\command
|
|
70
|
+
// (Microsoft.OutlookForWindows for example). Fall through to the
|
|
71
|
+
// known-handler list below.
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Step 3: known-handler fallbacks. Add new entries here as needed.
|
|
75
|
+
return resolveKnownHandlerForScheme(s);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Parse a Windows shell command-line string and pull out the executable
|
|
79
|
+
* path. Handles quoted paths, environment variable expansion (%ProgramFiles%),
|
|
80
|
+
* and strips trailing placeholder arguments like %1.
|
|
81
|
+
*/
|
|
82
|
+
function extractExecutableFromCommand(cmd) {
|
|
83
|
+
const trimmed = cmd.trim();
|
|
84
|
+
let exe;
|
|
85
|
+
if (trimmed.startsWith('"')) {
|
|
86
|
+
const end = trimmed.indexOf('"', 1);
|
|
87
|
+
if (end < 0)
|
|
88
|
+
return null;
|
|
89
|
+
exe = trimmed.slice(1, end);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const spaceIdx = trimmed.indexOf(' ');
|
|
93
|
+
exe = spaceIdx < 0 ? trimmed : trimmed.slice(0, spaceIdx);
|
|
94
|
+
}
|
|
95
|
+
// Expand %VAR% references.
|
|
96
|
+
exe = exe.replace(/%([^%]+)%/g, (_, v) => process.env[v] ?? `%${v}%`);
|
|
97
|
+
return exe || null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Look up a known-good handler executable for a scheme when the registry
|
|
101
|
+
* walk fails. UWP-packaged handlers (modern Outlook, Mail, etc.) don't
|
|
102
|
+
* expose a classic shell\open\command, so we have to know the executable
|
|
103
|
+
* location ourselves.
|
|
104
|
+
*/
|
|
105
|
+
function resolveKnownHandlerForScheme(scheme) {
|
|
106
|
+
if (scheme !== 'mailto')
|
|
107
|
+
return null;
|
|
108
|
+
// 1. Already-running New Outlook (`olk.exe`). Pull its path off the
|
|
109
|
+
// live process when possible — that's the version actually installed.
|
|
110
|
+
try {
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
112
|
+
const { execSync } = require('node:child_process');
|
|
113
|
+
const out = execSync('wmic process where "name=\'olk.exe\'" get ExecutablePath /value', { timeout: 3000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
114
|
+
const m = out.match(/ExecutablePath=(.+)/);
|
|
115
|
+
if (m && m[1].trim())
|
|
116
|
+
return m[1].trim();
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// wmic missing or olk not running.
|
|
120
|
+
}
|
|
121
|
+
// 2. Glob WindowsApps for the latest Microsoft.OutlookForWindows install.
|
|
122
|
+
try {
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
124
|
+
const { readdirSync, existsSync } = require('node:fs');
|
|
125
|
+
const base = 'C:\\Program Files\\WindowsApps';
|
|
126
|
+
if (existsSync(base)) {
|
|
127
|
+
const dirs = readdirSync(base).filter(d => d.startsWith('Microsoft.OutlookForWindows_'));
|
|
128
|
+
if (dirs.length) {
|
|
129
|
+
// Most-recent install wins (filesystem readdir order isn't sorted).
|
|
130
|
+
dirs.sort();
|
|
131
|
+
const exe = `${base}\\${dirs[dirs.length - 1]}\\olk.exe`;
|
|
132
|
+
if (existsSync(exe))
|
|
133
|
+
return exe;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// No permission to enumerate WindowsApps — that's fine.
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Is `scheme` a registered URI protocol in HKCR (has a `URL Protocol` value)?
|
|
144
|
+
* Some schemes (ms-settings:, ms-windows-store:, …) ARE registered but route
|
|
145
|
+
* through a `DelegateExecute` COM handler with an EMPTY shell\open\command — so
|
|
146
|
+
* resolveSchemeHandlerExecutable() returns null even though the OS can open
|
|
147
|
+
* them. Only ShellExecute (Start-Process) honors DelegateExecute. This lets the
|
|
148
|
+
* caller decide to fall back to a shell dispatch instead of failing outright.
|
|
149
|
+
*/
|
|
150
|
+
async function isRegisteredUriScheme(scheme) {
|
|
151
|
+
if (process.platform !== 'win32')
|
|
152
|
+
return false;
|
|
153
|
+
const s = scheme.toLowerCase().replace(/[^a-z0-9+.-]/g, ''); // defensive: scheme charset only
|
|
154
|
+
if (!s)
|
|
155
|
+
return false;
|
|
156
|
+
try {
|
|
157
|
+
const { stdout } = await execFileAsync('reg', ['query', `HKCR\\${s}`, '/v', 'URL Protocol'], { timeout: 3000 });
|
|
158
|
+
return /URL Protocol/i.test(stdout);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Dispatch a URI via ShellExecute (PowerShell `Start-Process`) — the ONLY path
|
|
166
|
+
* that honors `DelegateExecute` COM handlers (ms-settings: et al.) — and verify
|
|
167
|
+
* a NEW visible top-level window appeared by diffing the full window list
|
|
168
|
+
* before/after. The handler process is unknown (SystemSettings.exe for
|
|
169
|
+
* ms-settings, etc.), so this diffs ALL windows rather than one process.
|
|
170
|
+
*
|
|
171
|
+
* The URI (agent-controlled) is passed via an ENV VAR, never interpolated into
|
|
172
|
+
* the command string — no shell-injection surface.
|
|
173
|
+
*/
|
|
174
|
+
async function shellDispatchUriAndVerify(uri, listWindows, opts = {}) {
|
|
175
|
+
if (process.platform !== 'win32')
|
|
176
|
+
return { windowOpened: false, error: 'windows-only' };
|
|
177
|
+
const waitMs = opts.waitMs ?? 5000;
|
|
178
|
+
const snapshot = async () => {
|
|
179
|
+
const m = new Map();
|
|
180
|
+
try {
|
|
181
|
+
for (const w of await listWindows())
|
|
182
|
+
m.set(String(w.handle), w.title ?? '');
|
|
183
|
+
}
|
|
184
|
+
catch { /* empty */ }
|
|
185
|
+
return m;
|
|
186
|
+
};
|
|
187
|
+
const before = await snapshot();
|
|
188
|
+
try {
|
|
189
|
+
const child = (0, node_child_process_1.spawn)('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', 'Start-Process -FilePath $env:CLAWD_URI'], { detached: true, stdio: 'ignore', windowsHide: true, env: { ...process.env, CLAWD_URI: uri } });
|
|
190
|
+
child.unref();
|
|
191
|
+
child.on('error', () => { });
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
return { windowOpened: false, error: err instanceof Error ? err.message : String(err) };
|
|
195
|
+
}
|
|
196
|
+
const deadline = Date.now() + waitMs;
|
|
197
|
+
while (Date.now() < deadline) {
|
|
198
|
+
await new Promise(r => setTimeout(r, 300));
|
|
199
|
+
const after = await snapshot();
|
|
200
|
+
for (const [handle, title] of after) {
|
|
201
|
+
if (!before.has(handle))
|
|
202
|
+
return { windowOpened: true, title };
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return { windowOpened: false };
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Snapshot all visible top-level windows belonging to the given process
|
|
209
|
+
* name (case-insensitive). Returns a Set of HWND-like identifiers so the
|
|
210
|
+
* caller can diff "before" vs "after" launching a handler.
|
|
211
|
+
*/
|
|
212
|
+
async function snapshotProcessWindows(processNameLower) {
|
|
213
|
+
if (process.platform !== 'win32')
|
|
214
|
+
return new Set();
|
|
215
|
+
try {
|
|
216
|
+
// Use PowerShell to enumerate; it's already a dependency for the
|
|
217
|
+
// a11y bridge so we're not adding a new runtime.
|
|
218
|
+
//
|
|
219
|
+
// processNameLower flows in from registry / WindowsApps lookups (not
|
|
220
|
+
// LLM-controlled), but defense-in-depth: double single-quotes to
|
|
221
|
+
// escape any embedded apostrophe so it can't break out of the PS
|
|
222
|
+
// string literal. Same pattern as Windows.psQuote.
|
|
223
|
+
const safeName = processNameLower.replace(/'/g, "''");
|
|
224
|
+
const { stdout } = await execFileAsync('powershell.exe', [
|
|
225
|
+
'-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command',
|
|
226
|
+
`Get-Process | Where-Object { $_.MainWindowHandle -ne 0 -and $_.MainWindowTitle -ne '' -and $_.ProcessName.ToLower() -eq '${safeName}' } | ForEach-Object { "$($_.MainWindowHandle)|$($_.MainWindowTitle)" }`,
|
|
227
|
+
], { timeout: 3000 });
|
|
228
|
+
return new Set(stdout.split(/\r?\n/).map(l => l.trim()).filter(Boolean));
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return new Set();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Launch the resolved handler with the URI and verify that a NEW visible
|
|
236
|
+
* top-level window appeared in the handler process. Returns:
|
|
237
|
+
* { success: true, windowOpened: true, hwndLabel } when a new window appeared.
|
|
238
|
+
* { success: true, windowOpened: false } when the handler ran but no new window appeared
|
|
239
|
+
* (handler probably routed to an existing instance silently).
|
|
240
|
+
* { success: false, error } when the launch itself failed.
|
|
241
|
+
*/
|
|
242
|
+
async function launchHandlerAndVerify(exePath, uri, opts = {}) {
|
|
243
|
+
const waitMs = opts.waitMs ?? 5000;
|
|
244
|
+
// Derive the process name (lowercased, no extension) so we can diff
|
|
245
|
+
// its visible windows before vs after.
|
|
246
|
+
const exeBaseLower = exePath.split(/[\\/]/).pop().replace(/\.exe$/i, '').toLowerCase();
|
|
247
|
+
const before = await snapshotProcessWindows(exeBaseLower);
|
|
248
|
+
try {
|
|
249
|
+
// detached + ignored stdio so we don't keep a pipe open to the GUI
|
|
250
|
+
// app. unref() lets the daemon exit cleanly later. Any synchronous
|
|
251
|
+
// spawn error throws into the catch below; the 'error' event handler
|
|
252
|
+
// is registered so async failures don't crash the process either.
|
|
253
|
+
const child = (0, node_child_process_1.spawn)(exePath, [uri], { detached: true, stdio: 'ignore', windowsHide: false });
|
|
254
|
+
child.unref();
|
|
255
|
+
child.on('error', () => { });
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
return { success: false, windowOpened: false, error: err instanceof Error ? err.message : String(err) };
|
|
259
|
+
}
|
|
260
|
+
// Poll for a new visible top-level window. Compose windows take 500ms-2s
|
|
261
|
+
// to mount in New Outlook depending on cold/warm state.
|
|
262
|
+
const deadline = Date.now() + waitMs;
|
|
263
|
+
while (Date.now() < deadline) {
|
|
264
|
+
await new Promise(r => setTimeout(r, 250));
|
|
265
|
+
const after = await snapshotProcessWindows(exeBaseLower);
|
|
266
|
+
const fresh = [...after].find(label => !before.has(label));
|
|
267
|
+
if (fresh) {
|
|
268
|
+
return { success: true, windowOpened: true, hwndLabel: fresh };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return { success: true, windowOpened: false };
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=uri-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uri-handler.js","sourceRoot":"","sources":["../../src/platform/uri-handler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAYH,wEAmCC;AA4ED,sDAUC;AAYD,8DAmCC;AA0CD,wDAoCC;AAhQD,2DAAqD;AACrD,yCAAsC;AAEtC,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,6BAAQ,CAAC,CAAC;AAE1C;;;;GAIG;AACI,KAAK,UAAU,8BAA8B,CAAC,MAAc;IACjE,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC9C,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAE/B,iGAAiG;IACjG,cAAc;IACd,MAAM,cAAc,GAAG,6EAA6E,CAAC,cAAc,CAAC;IACpH,IAAI,MAAM,GAAkB,IAAI,CAAC;IACjC,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,a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AAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;IAC1G,CAAC;IAED,yEAAyE;IACzE,wDAAwD;IACxD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC;IACrC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,MAAM,sBAAsB,CAAC,YAAY,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3D,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wayland input routing via ydotool / wtype.
|
|
3
|
+
*
|
|
4
|
+
* The Linux adapter's nut-js path silently fails on most Wayland
|
|
5
|
+
* compositors because synthetic input events are blocked at the
|
|
6
|
+
* compositor layer unless injected through a privileged daemon.
|
|
7
|
+
* This module provides a minimal backend that routes mouse + keyboard
|
|
8
|
+
* operations through `ydotool` (requires `ydotoold` running with
|
|
9
|
+
* uinput access) or `wtype` (keyboard-only).
|
|
10
|
+
*
|
|
11
|
+
* Detection order at construction:
|
|
12
|
+
* 1. `ydotool` + socket reachable → preferred (mouse + keyboard)
|
|
13
|
+
* 2. `wtype` → keyboard-only fallback
|
|
14
|
+
* 3. neither → `none`; caller must return graceful error
|
|
15
|
+
*
|
|
16
|
+
* ydotool reference:
|
|
17
|
+
* mousemove --absolute <x> <y>
|
|
18
|
+
* click 0xC0 (left) 0xC1 (right) 0xC2 (middle)
|
|
19
|
+
* key <code>:1 (down) <code>:0 (up)
|
|
20
|
+
* type --delay 10 "text"
|
|
21
|
+
* mousemove -x <dx> -y <dy> (relative)
|
|
22
|
+
*
|
|
23
|
+
* All command construction goes through `execFile` (not shell), so
|
|
24
|
+
* there is NO shell interpolation of user text — clawdcursor typing
|
|
25
|
+
* a string with `$` or backticks is safe.
|
|
26
|
+
*/
|
|
27
|
+
/** Which backend the LinuxAdapter should use on Wayland. */
|
|
28
|
+
export type WaylandInputKind = 'ydotool' | 'wtype-keyboard-only' | 'none';
|
|
29
|
+
export declare class WaylandBackend {
|
|
30
|
+
readonly kind: WaylandInputKind;
|
|
31
|
+
private readonly mod2code;
|
|
32
|
+
constructor(kind: WaylandInputKind);
|
|
33
|
+
static detect(hasBinary: (name: string) => Promise<boolean>): Promise<WaylandBackend>;
|
|
34
|
+
canMouse(): boolean;
|
|
35
|
+
canKeyboard(): boolean;
|
|
36
|
+
mouseMoveAbsolute(x: number, y: number): Promise<void>;
|
|
37
|
+
mouseMoveRelative(dx: number, dy: number): Promise<void>;
|
|
38
|
+
/** `click` is a down+up in one ydotool call. For separate down/up, use mouseDown/mouseUp. */
|
|
39
|
+
mouseClick(button?: 'left' | 'right' | 'middle', count?: number): Promise<void>;
|
|
40
|
+
mouseDown(button?: 'left' | 'right' | 'middle'): Promise<void>;
|
|
41
|
+
mouseUp(button?: 'left' | 'right' | 'middle'): Promise<void>;
|
|
42
|
+
mouseScroll(direction: 'up' | 'down' | 'left' | 'right', amount?: number): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Press a key combo. On ydotool we map each component to a Linux
|
|
45
|
+
* keycode and emit paired down/up events. On wtype we use wtype's
|
|
46
|
+
* native combo syntax (e.g. `wtype -M ctrl -k s`).
|
|
47
|
+
*/
|
|
48
|
+
keyPress(combo: string): Promise<void>;
|
|
49
|
+
keyDown(key: string): Promise<void>;
|
|
50
|
+
keyUp(key: string): Promise<void>;
|
|
51
|
+
typeText(text: string): Promise<void>;
|
|
52
|
+
private keyToCode;
|
|
53
|
+
}
|