superbased 1.6.4 → 2.0.0
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/README.md +169 -36
- package/SUPERBASED_SKILL.md +1196 -22
- package/dist/electron/core/input-injection/index.d.ts +6 -0
- package/dist/electron/core/input-injection/index.d.ts.map +1 -0
- package/dist/electron/core/input-injection/index.js +31 -0
- package/dist/electron/core/input-injection/index.js.map +1 -0
- package/dist/electron/core/input-injection/macos.d.ts +3 -0
- package/dist/electron/core/input-injection/macos.d.ts.map +1 -0
- package/dist/electron/core/input-injection/macos.js +14 -0
- package/dist/electron/core/input-injection/macos.js.map +1 -0
- package/dist/electron/core/input-injection/windows.d.ts +3 -0
- package/dist/electron/core/input-injection/windows.d.ts.map +1 -0
- package/dist/electron/core/input-injection/windows.js +119 -0
- package/dist/electron/core/input-injection/windows.js.map +1 -0
- package/dist/electron/core/json-store.d.ts +22 -0
- package/dist/electron/core/json-store.d.ts.map +1 -1
- package/dist/electron/core/json-store.js +61 -47
- package/dist/electron/core/json-store.js.map +1 -1
- package/dist/electron/core/platform.d.ts +1 -0
- package/dist/electron/core/platform.d.ts.map +1 -1
- package/dist/electron/core/serialize-schema.d.ts +35 -0
- package/dist/electron/core/serialize-schema.d.ts.map +1 -0
- package/dist/electron/core/serialize-schema.js +89 -0
- package/dist/electron/core/serialize-schema.js.map +1 -0
- package/dist/electron/core/settings-schema.d.ts +81 -0
- package/dist/electron/core/settings-schema.d.ts.map +1 -0
- package/dist/electron/core/settings-schema.js +1357 -0
- package/dist/electron/core/settings-schema.js.map +1 -0
- package/dist/electron/logger.d.ts.map +1 -1
- package/dist/electron/logger.js +22 -8
- package/dist/electron/logger.js.map +1 -1
- package/dist/electron/main.js +417 -133
- package/dist/electron/modules/accessibility/macos-provider.d.ts +8 -0
- package/dist/electron/modules/accessibility/macos-provider.d.ts.map +1 -0
- package/dist/electron/modules/accessibility/macos-provider.js +94 -0
- package/dist/electron/modules/accessibility/macos-provider.js.map +1 -0
- package/dist/electron/modules/accessibility/provider.d.ts +12 -0
- package/dist/electron/modules/accessibility/provider.d.ts.map +1 -0
- package/dist/electron/modules/accessibility/provider.js +52 -0
- package/dist/electron/modules/accessibility/provider.js.map +1 -0
- package/dist/electron/modules/accessibility/types.d.ts +63 -0
- package/dist/electron/modules/accessibility/types.d.ts.map +1 -0
- package/dist/electron/modules/accessibility/types.js +6 -0
- package/dist/electron/modules/accessibility/types.js.map +1 -0
- package/dist/electron/modules/accessibility/windows-provider.d.ts +8 -0
- package/dist/electron/modules/accessibility/windows-provider.d.ts.map +1 -0
- package/dist/electron/modules/accessibility/windows-provider.js +85 -0
- package/dist/electron/modules/accessibility/windows-provider.js.map +1 -0
- package/dist/electron/modules/api-server.d.ts +4 -1
- package/dist/electron/modules/api-server.d.ts.map +1 -1
- package/dist/electron/modules/api-server.js +1349 -219
- package/dist/electron/modules/api-server.js.map +1 -1
- package/dist/electron/modules/auth.d.ts +14 -0
- package/dist/electron/modules/auth.d.ts.map +1 -1
- package/dist/electron/modules/auth.js +43 -0
- package/dist/electron/modules/auth.js.map +1 -1
- package/dist/electron/modules/azure-speech-realtime.d.ts.map +1 -1
- package/dist/electron/modules/azure-speech-realtime.js +56 -0
- package/dist/electron/modules/azure-speech-realtime.js.map +1 -1
- package/dist/electron/modules/capture.d.ts +8 -0
- package/dist/electron/modules/capture.d.ts.map +1 -1
- package/dist/electron/modules/capture.js +33 -0
- package/dist/electron/modules/capture.js.map +1 -1
- package/dist/electron/modules/compose-screenshots.d.ts +8 -0
- package/dist/electron/modules/compose-screenshots.d.ts.map +1 -0
- package/dist/electron/modules/compose-screenshots.js +86 -0
- package/dist/electron/modules/compose-screenshots.js.map +1 -0
- package/dist/electron/modules/context-menu-detect.d.ts +47 -0
- package/dist/electron/modules/context-menu-detect.d.ts.map +1 -0
- package/dist/electron/modules/context-menu-detect.js +272 -0
- package/dist/electron/modules/context-menu-detect.js.map +1 -0
- package/dist/electron/modules/dictation.d.ts.map +1 -1
- package/dist/electron/modules/dictation.js +12 -7
- package/dist/electron/modules/dictation.js.map +1 -1
- package/dist/electron/modules/gif-util.d.ts +9 -0
- package/dist/electron/modules/gif-util.d.ts.map +1 -0
- package/dist/electron/modules/gif-util.js +63 -0
- package/dist/electron/modules/gif-util.js.map +1 -0
- package/dist/electron/modules/gui-automation-errors.d.ts +11 -0
- package/dist/electron/modules/gui-automation-errors.d.ts.map +1 -0
- package/dist/electron/modules/gui-automation-errors.js +79 -0
- package/dist/electron/modules/gui-automation-errors.js.map +1 -0
- package/dist/electron/modules/gui-automation-telemetry.d.ts +38 -0
- package/dist/electron/modules/gui-automation-telemetry.d.ts.map +1 -0
- package/dist/electron/modules/gui-automation-telemetry.js +200 -0
- package/dist/electron/modules/gui-automation-telemetry.js.map +1 -0
- package/dist/electron/modules/gui-automation.d.ts +1143 -0
- package/dist/electron/modules/gui-automation.d.ts.map +1 -0
- package/dist/electron/modules/gui-automation.js +8769 -0
- package/dist/electron/modules/gui-automation.js.map +1 -0
- package/dist/electron/modules/hotkeys.d.ts +2 -1
- package/dist/electron/modules/hotkeys.d.ts.map +1 -1
- package/dist/electron/modules/hotkeys.js +25 -1
- package/dist/electron/modules/hotkeys.js.map +1 -1
- package/dist/electron/modules/human-input/index.d.ts +35 -0
- package/dist/electron/modules/human-input/index.d.ts.map +1 -0
- package/dist/electron/modules/human-input/index.js +163 -0
- package/dist/electron/modules/human-input/index.js.map +1 -0
- package/dist/electron/modules/human-input/keyboard/timing.d.ts +38 -0
- package/dist/electron/modules/human-input/keyboard/timing.d.ts.map +1 -0
- package/dist/electron/modules/human-input/keyboard/timing.js +57 -0
- package/dist/electron/modules/human-input/keyboard/timing.js.map +1 -0
- package/dist/electron/modules/human-input/mouse/path.d.ts +24 -0
- package/dist/electron/modules/human-input/mouse/path.d.ts.map +1 -0
- package/dist/electron/modules/human-input/mouse/path.js +80 -0
- package/dist/electron/modules/human-input/mouse/path.js.map +1 -0
- package/dist/electron/modules/human-input/mouse/velocity.d.ts +48 -0
- package/dist/electron/modules/human-input/mouse/velocity.d.ts.map +1 -0
- package/dist/electron/modules/human-input/mouse/velocity.js +93 -0
- package/dist/electron/modules/human-input/mouse/velocity.js.map +1 -0
- package/dist/electron/modules/human-input/profiles.d.ts +90 -0
- package/dist/electron/modules/human-input/profiles.d.ts.map +1 -0
- package/dist/electron/modules/human-input/profiles.js +124 -0
- package/dist/electron/modules/human-input/profiles.js.map +1 -0
- package/dist/electron/modules/human-input/rng.d.ts +16 -0
- package/dist/electron/modules/human-input/rng.d.ts.map +1 -0
- package/dist/electron/modules/human-input/rng.js +101 -0
- package/dist/electron/modules/human-input/rng.js.map +1 -0
- package/dist/electron/modules/human-input/salt.d.ts +15 -0
- package/dist/electron/modules/human-input/salt.d.ts.map +1 -0
- package/dist/electron/modules/human-input/salt.js +48 -0
- package/dist/electron/modules/human-input/salt.js.map +1 -0
- package/dist/electron/modules/image-utils.d.ts +20 -0
- package/dist/electron/modules/image-utils.d.ts.map +1 -0
- package/dist/electron/modules/image-utils.js +80 -0
- package/dist/electron/modules/image-utils.js.map +1 -0
- package/dist/electron/modules/ollama/capability.d.ts +32 -0
- package/dist/electron/modules/ollama/capability.d.ts.map +1 -0
- package/dist/electron/modules/ollama/capability.js +117 -0
- package/dist/electron/modules/ollama/capability.js.map +1 -0
- package/dist/electron/modules/ollama/client.d.ts +14 -0
- package/dist/electron/modules/ollama/client.d.ts.map +1 -0
- package/dist/electron/modules/ollama/client.js +134 -0
- package/dist/electron/modules/ollama/client.js.map +1 -0
- package/dist/electron/modules/ollama/detector.d.ts +29 -0
- package/dist/electron/modules/ollama/detector.d.ts.map +1 -0
- package/dist/electron/modules/ollama/detector.js +177 -0
- package/dist/electron/modules/ollama/detector.js.map +1 -0
- package/dist/electron/modules/ollama/dispatcher.d.ts +36 -0
- package/dist/electron/modules/ollama/dispatcher.d.ts.map +1 -0
- package/dist/electron/modules/ollama/dispatcher.js +97 -0
- package/dist/electron/modules/ollama/dispatcher.js.map +1 -0
- package/dist/electron/modules/ollama/router.d.ts +51 -0
- package/dist/electron/modules/ollama/router.d.ts.map +1 -0
- package/dist/electron/modules/ollama/router.js +201 -0
- package/dist/electron/modules/ollama/router.js.map +1 -0
- package/dist/electron/modules/pin-window.d.ts.map +1 -1
- package/dist/electron/modules/pin-window.js +2 -1
- package/dist/electron/modules/pin-window.js.map +1 -1
- package/dist/electron/modules/platform/dpi.d.ts +2 -0
- package/dist/electron/modules/platform/dpi.d.ts.map +1 -0
- package/dist/electron/modules/platform/dpi.js +48 -0
- package/dist/electron/modules/platform/dpi.js.map +1 -0
- package/dist/electron/modules/platform/errors.d.ts +13 -0
- package/dist/electron/modules/platform/errors.d.ts.map +1 -0
- package/dist/electron/modules/platform/errors.js +36 -0
- package/dist/electron/modules/platform/errors.js.map +1 -0
- package/dist/electron/modules/platform/index.d.ts +24 -0
- package/dist/electron/modules/platform/index.d.ts.map +1 -0
- package/dist/electron/modules/platform/index.js +133 -0
- package/dist/electron/modules/platform/index.js.map +1 -0
- package/dist/electron/modules/platform/interfaces.d.ts +140 -0
- package/dist/electron/modules/platform/interfaces.d.ts.map +1 -0
- package/dist/electron/modules/platform/interfaces.js +14 -0
- package/dist/electron/modules/platform/interfaces.js.map +1 -0
- package/dist/electron/modules/platform/macos/ax.d.ts +15 -0
- package/dist/electron/modules/platform/macos/ax.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/ax.js +222 -0
- package/dist/electron/modules/platform/macos/ax.js.map +1 -0
- package/dist/electron/modules/platform/macos/capture.d.ts +14 -0
- package/dist/electron/modules/platform/macos/capture.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/capture.js +106 -0
- package/dist/electron/modules/platform/macos/capture.js.map +1 -0
- package/dist/electron/modules/platform/macos/input.d.ts +16 -0
- package/dist/electron/modules/platform/macos/input.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/input.js +342 -0
- package/dist/electron/modules/platform/macos/input.js.map +1 -0
- package/dist/electron/modules/platform/macos/launch.d.ts +10 -0
- package/dist/electron/modules/platform/macos/launch.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/launch.js +114 -0
- package/dist/electron/modules/platform/macos/launch.js.map +1 -0
- package/dist/electron/modules/platform/macos/session.d.ts +8 -0
- package/dist/electron/modules/platform/macos/session.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/session.js +17 -0
- package/dist/electron/modules/platform/macos/session.js.map +1 -0
- package/dist/electron/modules/platform/macos/window.d.ts +31 -0
- package/dist/electron/modules/platform/macos/window.d.ts.map +1 -0
- package/dist/electron/modules/platform/macos/window.js +271 -0
- package/dist/electron/modules/platform/macos/window.js.map +1 -0
- package/dist/electron/modules/platform/shared.d.ts +10 -0
- package/dist/electron/modules/platform/shared.d.ts.map +1 -0
- package/dist/electron/modules/platform/shared.js +201 -0
- package/dist/electron/modules/platform/shared.js.map +1 -0
- package/dist/electron/modules/platform/types.d.ts +182 -0
- package/dist/electron/modules/platform/types.d.ts.map +1 -0
- package/dist/electron/modules/platform/types.js +24 -0
- package/dist/electron/modules/platform/types.js.map +1 -0
- package/dist/electron/modules/platform/windows/ax.d.ts +15 -0
- package/dist/electron/modules/platform/windows/ax.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/ax.js +277 -0
- package/dist/electron/modules/platform/windows/ax.js.map +1 -0
- package/dist/electron/modules/platform/windows/capture.d.ts +14 -0
- package/dist/electron/modules/platform/windows/capture.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/capture.js +115 -0
- package/dist/electron/modules/platform/windows/capture.js.map +1 -0
- package/dist/electron/modules/platform/windows/input.d.ts +17 -0
- package/dist/electron/modules/platform/windows/input.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/input.js +422 -0
- package/dist/electron/modules/platform/windows/input.js.map +1 -0
- package/dist/electron/modules/platform/windows/launch.d.ts +10 -0
- package/dist/electron/modules/platform/windows/launch.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/launch.js +185 -0
- package/dist/electron/modules/platform/windows/launch.js.map +1 -0
- package/dist/electron/modules/platform/windows/session.d.ts +8 -0
- package/dist/electron/modules/platform/windows/session.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/session.js +87 -0
- package/dist/electron/modules/platform/windows/session.js.map +1 -0
- package/dist/electron/modules/platform/windows/tray.d.ts +13 -0
- package/dist/electron/modules/platform/windows/tray.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/tray.js +390 -0
- package/dist/electron/modules/platform/windows/tray.js.map +1 -0
- package/dist/electron/modules/platform/windows/window.d.ts +30 -0
- package/dist/electron/modules/platform/windows/window.d.ts.map +1 -0
- package/dist/electron/modules/platform/windows/window.js +444 -0
- package/dist/electron/modules/platform/windows/window.js.map +1 -0
- package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.d.ts +15 -0
- package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.d.ts.map +1 -0
- package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.js +62 -0
- package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.js.map +1 -0
- package/dist/electron/modules/recording/providers/provider-factory.d.ts.map +1 -1
- package/dist/electron/modules/recording/providers/provider-factory.js +13 -7
- package/dist/electron/modules/recording/providers/provider-factory.js.map +1 -1
- package/dist/electron/modules/scroll-calibration.d.ts +152 -0
- package/dist/electron/modules/scroll-calibration.d.ts.map +1 -0
- package/dist/electron/modules/scroll-calibration.js +271 -0
- package/dist/electron/modules/scroll-calibration.js.map +1 -0
- package/dist/electron/modules/scroll-capture.d.ts +3 -1
- package/dist/electron/modules/scroll-capture.d.ts.map +1 -1
- package/dist/electron/modules/scroll-capture.js +21 -72
- package/dist/electron/modules/scroll-capture.js.map +1 -1
- package/dist/electron/modules/sequence-locate.d.ts +126 -0
- package/dist/electron/modules/sequence-locate.d.ts.map +1 -0
- package/dist/electron/modules/sequence-locate.js +356 -0
- package/dist/electron/modules/sequence-locate.js.map +1 -0
- package/dist/electron/modules/store.d.ts +15 -56
- package/dist/electron/modules/store.d.ts.map +1 -1
- package/dist/electron/modules/store.js +84 -58
- package/dist/electron/modules/store.js.map +1 -1
- package/dist/electron/modules/stt/capability-probe.d.ts +67 -0
- package/dist/electron/modules/stt/capability-probe.d.ts.map +1 -0
- package/dist/electron/modules/stt/capability-probe.js +331 -0
- package/dist/electron/modules/stt/capability-probe.js.map +1 -0
- package/dist/electron/modules/stt/macos-engine.d.ts +20 -0
- package/dist/electron/modules/stt/macos-engine.d.ts.map +1 -0
- package/dist/electron/modules/stt/macos-engine.js +231 -0
- package/dist/electron/modules/stt/macos-engine.js.map +1 -0
- package/dist/electron/modules/stt/model-manager.d.ts +87 -0
- package/dist/electron/modules/stt/model-manager.d.ts.map +1 -0
- package/dist/electron/modules/stt/model-manager.js +321 -0
- package/dist/electron/modules/stt/model-manager.js.map +1 -0
- package/dist/electron/modules/stt/router.d.ts +35 -0
- package/dist/electron/modules/stt/router.d.ts.map +1 -0
- package/dist/electron/modules/stt/router.js +232 -0
- package/dist/electron/modules/stt/router.js.map +1 -0
- package/dist/electron/modules/stt/sherpa-engine.d.ts +43 -0
- package/dist/electron/modules/stt/sherpa-engine.d.ts.map +1 -0
- package/dist/electron/modules/stt/sherpa-engine.js +521 -0
- package/dist/electron/modules/stt/sherpa-engine.js.map +1 -0
- package/dist/electron/modules/stt/types.d.ts +72 -0
- package/dist/electron/modules/stt/types.d.ts.map +1 -0
- package/dist/electron/modules/stt/types.js +16 -0
- package/dist/electron/modules/stt/types.js.map +1 -0
- package/dist/electron/modules/stt/winrt-engine.d.ts +20 -0
- package/dist/electron/modules/stt/winrt-engine.d.ts.map +1 -0
- package/dist/electron/modules/stt/winrt-engine.js +238 -0
- package/dist/electron/modules/stt/winrt-engine.js.map +1 -0
- package/dist/electron/modules/template-match.d.ts +62 -0
- package/dist/electron/modules/template-match.d.ts.map +1 -0
- package/dist/electron/modules/template-match.js +205 -0
- package/dist/electron/modules/template-match.js.map +1 -0
- package/dist/electron/modules/tray.d.ts +2 -0
- package/dist/electron/modules/tray.d.ts.map +1 -1
- package/dist/electron/modules/tray.js +136 -8
- package/dist/electron/modules/tray.js.map +1 -1
- package/dist/electron/modules/undo-stack.d.ts +22 -0
- package/dist/electron/modules/undo-stack.d.ts.map +1 -0
- package/dist/electron/modules/undo-stack.js +41 -0
- package/dist/electron/modules/undo-stack.js.map +1 -0
- package/dist/electron/modules/watchers/active-window-watcher.d.ts +5 -0
- package/dist/electron/modules/watchers/active-window-watcher.d.ts.map +1 -0
- package/dist/electron/modules/watchers/active-window-watcher.js +152 -0
- package/dist/electron/modules/watchers/active-window-watcher.js.map +1 -0
- package/dist/electron/modules/watchers/clipboard-watcher.d.ts +5 -0
- package/dist/electron/modules/watchers/clipboard-watcher.d.ts.map +1 -0
- package/dist/electron/modules/watchers/clipboard-watcher.js +90 -0
- package/dist/electron/modules/watchers/clipboard-watcher.js.map +1 -0
- package/dist/electron/modules/watchers/file-watcher.d.ts +5 -0
- package/dist/electron/modules/watchers/file-watcher.d.ts.map +1 -0
- package/dist/electron/modules/watchers/file-watcher.js +91 -0
- package/dist/electron/modules/watchers/file-watcher.js.map +1 -0
- package/dist/electron/modules/watchers/registry.d.ts +34 -0
- package/dist/electron/modules/watchers/registry.d.ts.map +1 -0
- package/dist/electron/modules/watchers/registry.js +108 -0
- package/dist/electron/modules/watchers/registry.js.map +1 -0
- package/dist/electron/modules/watchers/screen-region-service.d.ts +18 -0
- package/dist/electron/modules/watchers/screen-region-service.d.ts.map +1 -0
- package/dist/electron/modules/watchers/screen-region-service.js +126 -0
- package/dist/electron/modules/watchers/screen-region-service.js.map +1 -0
- package/dist/electron/modules/watchers/screen-region-watcher.d.ts +6 -0
- package/dist/electron/modules/watchers/screen-region-watcher.d.ts.map +1 -0
- package/dist/electron/modules/watchers/screen-region-watcher.js +70 -0
- package/dist/electron/modules/watchers/screen-region-watcher.js.map +1 -0
- package/dist/electron/modules/window-activate.d.ts +103 -0
- package/dist/electron/modules/window-activate.d.ts.map +1 -0
- package/dist/electron/modules/window-activate.js +630 -0
- package/dist/electron/modules/window-activate.js.map +1 -0
- package/dist/electron/modules/window-input.d.ts +43 -0
- package/dist/electron/modules/window-input.d.ts.map +1 -0
- package/dist/electron/modules/window-input.js +623 -0
- package/dist/electron/modules/window-input.js.map +1 -0
- package/dist/electron/modules/window-resolver.d.ts +35 -0
- package/dist/electron/modules/window-resolver.d.ts.map +1 -0
- package/dist/electron/modules/window-resolver.js +210 -0
- package/dist/electron/modules/window-resolver.js.map +1 -0
- package/dist/headless/electron/core/input-injection/index.js +30 -0
- package/dist/headless/electron/core/input-injection/macos.js +13 -0
- package/dist/headless/electron/core/input-injection/windows.js +118 -0
- package/dist/headless/electron/core/json-store.js +61 -47
- package/dist/headless/electron/core/serialize-schema.js +88 -0
- package/dist/headless/electron/core/settings-schema.js +1356 -0
- package/dist/headless/electron/logger.js +22 -8
- package/dist/headless/electron/modules/accessibility/macos-provider.js +93 -0
- package/dist/headless/electron/modules/accessibility/provider.js +51 -0
- package/dist/headless/electron/modules/accessibility/types.js +5 -0
- package/dist/headless/electron/modules/accessibility/windows-provider.js +84 -0
- package/dist/headless/electron/modules/api-server.js +1349 -219
- package/dist/headless/electron/modules/auth.js +43 -0
- package/dist/headless/electron/modules/azure-speech-realtime.js +56 -0
- package/dist/headless/electron/modules/capture.js +33 -0
- package/dist/headless/electron/modules/context-menu-detect.js +271 -0
- package/dist/headless/electron/modules/dictation.js +12 -7
- package/dist/headless/electron/modules/gui-automation-errors.js +78 -0
- package/dist/headless/electron/modules/gui-automation-telemetry.js +199 -0
- package/dist/headless/electron/modules/gui-automation.js +8768 -0
- package/dist/headless/electron/modules/human-input/keyboard/timing.js +56 -0
- package/dist/headless/electron/modules/human-input/mouse/path.js +79 -0
- package/dist/headless/electron/modules/human-input/mouse/velocity.js +92 -0
- package/dist/headless/electron/modules/human-input/profiles.js +123 -0
- package/dist/headless/electron/modules/human-input/rng.js +100 -0
- package/dist/headless/electron/modules/human-input/salt.js +47 -0
- package/dist/headless/electron/modules/image-utils.js +79 -0
- package/dist/headless/electron/modules/ollama/capability.js +116 -0
- package/dist/headless/electron/modules/ollama/client.js +133 -0
- package/dist/headless/electron/modules/ollama/detector.js +176 -0
- package/dist/headless/electron/modules/ollama/dispatcher.js +96 -0
- package/dist/headless/electron/modules/ollama/router.js +200 -0
- package/dist/headless/electron/modules/platform/dpi.js +47 -0
- package/dist/headless/electron/modules/platform/errors.js +35 -0
- package/dist/headless/electron/modules/platform/index.js +132 -0
- package/dist/headless/electron/modules/platform/interfaces.js +13 -0
- package/dist/headless/electron/modules/platform/macos/ax.js +221 -0
- package/dist/headless/electron/modules/platform/macos/capture.js +105 -0
- package/dist/headless/electron/modules/platform/macos/input.js +341 -0
- package/dist/headless/electron/modules/platform/macos/launch.js +113 -0
- package/dist/headless/electron/modules/platform/macos/session.js +16 -0
- package/dist/headless/electron/modules/platform/macos/window.js +270 -0
- package/dist/headless/electron/modules/platform/shared.js +200 -0
- package/dist/headless/electron/modules/platform/types.js +23 -0
- package/dist/headless/electron/modules/platform/windows/ax.js +276 -0
- package/dist/headless/electron/modules/platform/windows/capture.js +114 -0
- package/dist/headless/electron/modules/platform/windows/input.js +421 -0
- package/dist/headless/electron/modules/platform/windows/launch.js +184 -0
- package/dist/headless/electron/modules/platform/windows/session.js +86 -0
- package/dist/headless/electron/modules/platform/windows/tray.js +389 -0
- package/dist/headless/electron/modules/platform/windows/window.js +443 -0
- package/dist/headless/electron/modules/recording/providers/change-detect-shared-wrapper.js +61 -0
- package/dist/headless/electron/modules/recording/providers/provider-factory.js +13 -7
- package/dist/headless/electron/modules/scroll-calibration.js +270 -0
- package/dist/headless/electron/modules/sequence-locate.js +355 -0
- package/dist/headless/electron/modules/store.js +84 -58
- package/dist/headless/electron/modules/stt/capability-probe.js +330 -0
- package/dist/headless/electron/modules/stt/macos-engine.js +230 -0
- package/dist/headless/electron/modules/stt/model-manager.js +320 -0
- package/dist/headless/electron/modules/stt/router.js +231 -0
- package/dist/headless/electron/modules/stt/sherpa-engine.js +520 -0
- package/dist/headless/electron/modules/stt/types.js +15 -0
- package/dist/headless/electron/modules/stt/winrt-engine.js +237 -0
- package/dist/headless/electron/modules/template-match.js +204 -0
- package/dist/headless/electron/modules/undo-stack.js +40 -0
- package/dist/headless/electron/modules/watchers/active-window-watcher.js +151 -0
- package/dist/headless/electron/modules/watchers/clipboard-watcher.js +89 -0
- package/dist/headless/electron/modules/watchers/file-watcher.js +90 -0
- package/dist/headless/electron/modules/watchers/registry.js +107 -0
- package/dist/headless/electron/modules/watchers/screen-region-service.js +125 -0
- package/dist/headless/electron/modules/watchers/screen-region-watcher.js +69 -0
- package/dist/headless/electron/modules/window-activate.js +629 -0
- package/dist/headless/electron/modules/window-input.js +622 -0
- package/dist/headless/electron/modules/window-resolver.js +209 -0
- package/dist/headless/headless/cli.js +60 -7
- package/dist/headless/headless/config-cmd.js +306 -0
- package/dist/headless/headless/doctor.js +599 -0
- package/dist/headless/headless/ollama-cmd.js +211 -0
- package/dist/headless/headless/platform-headless.js +13 -1
- package/dist/headless/headless/server.js +38 -2
- package/dist/headless/headless/stt-cmd.js +213 -0
- package/dist/headless/headless/tui/index.mjs +7 -0
- package/dist/headless/headless/tui/plain-dump.js +41 -0
- package/dist/headless/headless/tui/settings-app.mjs +744 -0
- package/dist/headless/headless/tui/setup-wizard.mjs +257 -0
- package/dist/headless/headless/tui-bridge.js +80 -0
- package/dist/headless/shared/constants.js +3 -1
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +3 -1
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/types.d.ts +8 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/mcp-server/dist/api-client.js +257 -6
- package/mcp-server/dist/index.js +1566 -46
- package/mcp-server/dist/project-sense.js +161 -0
- package/mcp-server/dist/tool-categories.js +161 -0
- package/mcp-server/package.json +8 -2
- package/package.json +33 -5
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Direct-to-window input via Win32 PostMessage — bypasses focus entirely.
|
|
3
|
+
//
|
|
4
|
+
// nut-js uses global SendInput which goes to whatever has FOREGROUND focus
|
|
5
|
+
// when it fires. That loses races against VS Code's TUI reclaiming focus
|
|
6
|
+
// after the user grants tool-call permission. PostMessage WM_CHAR /
|
|
7
|
+
// WM_KEYDOWN target a specific hwnd's input queue regardless of foreground,
|
|
8
|
+
// removing the race.
|
|
9
|
+
//
|
|
10
|
+
// Limitations (documented for callers + agent):
|
|
11
|
+
// - Works reliably for windows with standard Win32 edit controls
|
|
12
|
+
// (Notepad classic, most native dialogs, many text editors).
|
|
13
|
+
// - Modern UWP / Electron / Chrome apps often DON'T process WM_CHAR for
|
|
14
|
+
// synthetic input — they need real OS-level keyboard events. For those
|
|
15
|
+
// callers should fall back to nut-js (no window= param).
|
|
16
|
+
// - Doesn't trigger global keyboard hooks. Some app shortcuts (Win+V,
|
|
17
|
+
// PrtScn) won't activate.
|
|
18
|
+
// - Multi-byte / dead-key sequences not handled — single-char WM_CHAR.
|
|
19
|
+
//
|
|
20
|
+
// macOS / Linux equivalents are NOT shipped here — the focus race is a
|
|
21
|
+
// Windows-specific problem driven by VS Code's terminal behavior on Win11.
|
|
22
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
25
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
26
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
27
|
+
}
|
|
28
|
+
Object.defineProperty(o, k2, desc);
|
|
29
|
+
}) : (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
o[k2] = m[k];
|
|
32
|
+
}));
|
|
33
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
34
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
35
|
+
}) : function(o, v) {
|
|
36
|
+
o["default"] = v;
|
|
37
|
+
});
|
|
38
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
39
|
+
var ownKeys = function(o) {
|
|
40
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
41
|
+
var ar = [];
|
|
42
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
43
|
+
return ar;
|
|
44
|
+
};
|
|
45
|
+
return ownKeys(o);
|
|
46
|
+
};
|
|
47
|
+
return function (mod) {
|
|
48
|
+
if (mod && mod.__esModule) return mod;
|
|
49
|
+
var result = {};
|
|
50
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
51
|
+
__setModuleDefault(result, mod);
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
})();
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.getForegroundWindowHwnd = getForegroundWindowHwnd;
|
|
57
|
+
exports.restoreForegroundWindow = restoreForegroundWindow;
|
|
58
|
+
exports.typeIntoWindow = typeIntoWindow;
|
|
59
|
+
exports.sendComboToWindow = sendComboToWindow;
|
|
60
|
+
const fs = __importStar(require("fs"));
|
|
61
|
+
const os = __importStar(require("os"));
|
|
62
|
+
const path = __importStar(require("path"));
|
|
63
|
+
const childProcess = __importStar(require("child_process"));
|
|
64
|
+
// ── Focus preservation (Windows) ──
|
|
65
|
+
//
|
|
66
|
+
// UIA SetValue and PostMessage WM_CHAR shouldn't theoretically steal focus,
|
|
67
|
+
// but in practice modern WinUI controls (RichEditD2DPT) often do. To preserve
|
|
68
|
+
// the user's focus context (e.g., the AI editor where they're chatting), we
|
|
69
|
+
// snapshot the foreground hwnd before the operation and restore it after.
|
|
70
|
+
async function getForegroundWindowHwnd() {
|
|
71
|
+
if (process.platform !== 'win32')
|
|
72
|
+
return undefined;
|
|
73
|
+
try {
|
|
74
|
+
const out = childProcess.execSync(`powershell -ExecutionPolicy Bypass -Command "Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;public class FG{[DllImport(\\"user32.dll\\")]public static extern IntPtr GetForegroundWindow();}'; [FG]::GetForegroundWindow().ToInt64()"`, { encoding: 'utf-8', timeout: 3000, stdio: 'pipe' });
|
|
75
|
+
return out.trim();
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Prefer `restoreWindowVerified` from `./window-activate` — that
|
|
83
|
+
* one verifies via GetForegroundWindow and retries up to 3 times, matching
|
|
84
|
+
* the robustness of the forward activation path. This one-shot variant
|
|
85
|
+
* silently drops the restore when Windows' idle-input-timeout refuses
|
|
86
|
+
* SetForegroundWindow. Kept for backwards compatibility with callers that
|
|
87
|
+
* only need a best-effort boolean result.
|
|
88
|
+
*/
|
|
89
|
+
async function restoreForegroundWindow(hwnd) {
|
|
90
|
+
if (process.platform !== 'win32' || !hwnd || hwnd === '0')
|
|
91
|
+
return false;
|
|
92
|
+
const script = path.join(os.tmpdir(), `superbased-restorefg-${Date.now()}.ps1`);
|
|
93
|
+
fs.writeFileSync(script, `
|
|
94
|
+
param([long]$Hwnd)
|
|
95
|
+
Add-Type -TypeDefinition @'
|
|
96
|
+
using System; using System.Runtime.InteropServices;
|
|
97
|
+
public class WinRestore {
|
|
98
|
+
[DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();
|
|
99
|
+
[DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);
|
|
100
|
+
[DllImport("user32.dll")] public static extern bool BringWindowToTop(IntPtr h);
|
|
101
|
+
[DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);
|
|
102
|
+
[DllImport("kernel32.dll")] public static extern uint GetCurrentThreadId();
|
|
103
|
+
[DllImport("user32.dll")] public static extern bool AttachThreadInput(uint a, uint b, bool attach);
|
|
104
|
+
[DllImport("user32.dll")] public static extern void keybd_event(byte vk, byte scan, uint flags, UIntPtr extra);
|
|
105
|
+
public static void Restore(IntPtr target) {
|
|
106
|
+
IntPtr cur = GetForegroundWindow();
|
|
107
|
+
uint dummy; uint fgThread = GetWindowThreadProcessId(cur, out dummy);
|
|
108
|
+
uint myThread = GetCurrentThreadId();
|
|
109
|
+
AttachThreadInput(myThread, fgThread, true);
|
|
110
|
+
keybd_event(0x12, 0, 1, UIntPtr.Zero);
|
|
111
|
+
keybd_event(0x12, 0, 3, UIntPtr.Zero);
|
|
112
|
+
SetForegroundWindow(target);
|
|
113
|
+
BringWindowToTop(target);
|
|
114
|
+
AttachThreadInput(myThread, fgThread, false);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
'@
|
|
118
|
+
[WinRestore]::Restore([IntPtr]::new($Hwnd))
|
|
119
|
+
`);
|
|
120
|
+
try {
|
|
121
|
+
childProcess.execSync(`powershell -ExecutionPolicy Bypass -File "${script}" -Hwnd ${hwnd}`, { timeout: 3000, stdio: 'pipe' });
|
|
122
|
+
try {
|
|
123
|
+
fs.unlinkSync(script);
|
|
124
|
+
}
|
|
125
|
+
catch { /* cleanup */ }
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
try {
|
|
130
|
+
fs.unlinkSync(script);
|
|
131
|
+
}
|
|
132
|
+
catch { /* cleanup */ }
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Type `text` into `parentHwnd` via WM_CHAR PostMessage. Tries to find an
|
|
138
|
+
* edit-control child first; falls back to the parent hwnd if no Edit child.
|
|
139
|
+
* Returns immediately if not on Windows.
|
|
140
|
+
*/
|
|
141
|
+
async function typeIntoWindow(parentHwnd, text, opts) {
|
|
142
|
+
if (process.platform !== 'win32') {
|
|
143
|
+
return { ok: false, method: 'unsupported_platform', error: 'PostMessage typing is Windows-only' };
|
|
144
|
+
}
|
|
145
|
+
if (!parentHwnd) {
|
|
146
|
+
return { ok: false, method: 'postmessage_wmchar', error: 'parent hwnd required' };
|
|
147
|
+
}
|
|
148
|
+
if (!text) {
|
|
149
|
+
return { ok: true, method: 'postmessage_wmchar', charsSent: 0, targetHwnd: parentHwnd };
|
|
150
|
+
}
|
|
151
|
+
const replace = opts?.replace === true;
|
|
152
|
+
const script = path.join(os.tmpdir(), `superbased-typewindow-${Date.now()}.ps1`);
|
|
153
|
+
// Encode text as a UTF-16 char-code array so we sidestep all PowerShell
|
|
154
|
+
// escaping concerns (newlines, quotes, backticks, $ signs, etc.).
|
|
155
|
+
const charCodes = Array.from(text).map((c) => c.codePointAt(0)).join(',');
|
|
156
|
+
fs.writeFileSync(script, `
|
|
157
|
+
param([long]$Hwnd, [string]$CharsCsv, [switch]$Replace)
|
|
158
|
+
Add-Type -TypeDefinition @'
|
|
159
|
+
using System;
|
|
160
|
+
using System.Runtime.InteropServices;
|
|
161
|
+
public class WinInput {
|
|
162
|
+
[DllImport("user32.dll", SetLastError=true)]
|
|
163
|
+
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
164
|
+
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
|
|
165
|
+
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr child, string cls, string title);
|
|
166
|
+
[DllImport("user32.dll")]
|
|
167
|
+
public static extern bool IsWindow(IntPtr hWnd);
|
|
168
|
+
public const uint WM_CHAR = 0x0102;
|
|
169
|
+
public const uint WM_KEYDOWN = 0x0100;
|
|
170
|
+
public const uint WM_KEYUP = 0x0101;
|
|
171
|
+
public static IntPtr ResolveTarget(IntPtr parent) {
|
|
172
|
+
// Common edit-control class names. Notepad classic uses "Edit"; many
|
|
173
|
+
// dialogs use "Edit" too. Newer Win11 Notepad uses RichEdit50W or
|
|
174
|
+
// similar — caller will need a different path for those.
|
|
175
|
+
string[] classes = new string[]{ "Edit", "RICHEDIT50W", "RICHEDIT60W", "RichEdit20W" };
|
|
176
|
+
foreach (string cls in classes) {
|
|
177
|
+
IntPtr child = FindWindowEx(parent, IntPtr.Zero, cls, null);
|
|
178
|
+
if (child != IntPtr.Zero) return child;
|
|
179
|
+
}
|
|
180
|
+
return parent;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
'@
|
|
184
|
+
$h = [IntPtr]::new($Hwnd)
|
|
185
|
+
if (-not [WinInput]::IsWindow($h)) { Write-Output "ERROR:invalid_hwnd"; exit 1 }
|
|
186
|
+
$target = [WinInput]::ResolveTarget($h)
|
|
187
|
+
|
|
188
|
+
# Replace semantic on the PostMessage path: send WM_KEYDOWN/WM_KEYUP for Ctrl+A
|
|
189
|
+
# + Delete to the resolved Edit child BEFORE the WM_CHAR burst. Classic Win32
|
|
190
|
+
# Edit / RichEdit50W / RichEdit60W controls process WM_KEYDOWN, so Ctrl+A +
|
|
191
|
+
# Delete clears the existing text. Modern WinUI controls (Win11 Notepad's
|
|
192
|
+
# RichEditD2DPT) don't process WM_KEYDOWN via PostMessage — ResolveTarget
|
|
193
|
+
# falls back to the parent there, caller falls through to UIA, and UIA's
|
|
194
|
+
# SetValue(\$decoded) (not \$valueBefore + \$decoded) handles the replace
|
|
195
|
+
# cleanly on that path. No-op here when not targeting a classic Edit control.
|
|
196
|
+
if ($Replace) {
|
|
197
|
+
# VK_CONTROL=0x11, A=0x41, VK_DELETE=0x2E
|
|
198
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYDOWN, [IntPtr]::new(0x11), [IntPtr]::Zero)
|
|
199
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYDOWN, [IntPtr]::new(0x41), [IntPtr]::Zero)
|
|
200
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYUP, [IntPtr]::new(0x41), [IntPtr]::Zero)
|
|
201
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYUP, [IntPtr]::new(0x11), [IntPtr]::Zero)
|
|
202
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYDOWN, [IntPtr]::new(0x2E), [IntPtr]::Zero)
|
|
203
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_KEYUP, [IntPtr]::new(0x2E), [IntPtr]::Zero)
|
|
204
|
+
Start-Sleep -Milliseconds 30
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
$codes = $CharsCsv -split ','
|
|
208
|
+
foreach ($c in $codes) {
|
|
209
|
+
[void][WinInput]::PostMessage($target, [WinInput]::WM_CHAR, [IntPtr]::new([int]$c), [IntPtr]::Zero)
|
|
210
|
+
}
|
|
211
|
+
$target.ToInt64()
|
|
212
|
+
`);
|
|
213
|
+
let pmResult;
|
|
214
|
+
try {
|
|
215
|
+
const out = childProcess.execSync(`powershell -ExecutionPolicy Bypass -File "${script}" -Hwnd ${parentHwnd} -CharsCsv "${charCodes}"${replace ? ' -Replace' : ''}`, { encoding: 'utf-8', timeout: 10_000, stdio: 'pipe' }).trim();
|
|
216
|
+
try {
|
|
217
|
+
fs.unlinkSync(script);
|
|
218
|
+
}
|
|
219
|
+
catch { /* cleanup */ }
|
|
220
|
+
if (out.startsWith('ERROR:')) {
|
|
221
|
+
pmResult = { ok: false, method: 'postmessage_wmchar', error: out.replace('ERROR:', ''), targetHwnd: parentHwnd };
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
pmResult = {
|
|
225
|
+
ok: true,
|
|
226
|
+
method: 'postmessage_wmchar',
|
|
227
|
+
charsSent: text.length,
|
|
228
|
+
targetHwnd: out, // resolved hwnd (Edit child if found; else parent)
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
try {
|
|
234
|
+
fs.unlinkSync(script);
|
|
235
|
+
}
|
|
236
|
+
catch { /* cleanup */ }
|
|
237
|
+
pmResult = {
|
|
238
|
+
ok: false,
|
|
239
|
+
method: 'postmessage_wmchar',
|
|
240
|
+
error: err.message || String(err),
|
|
241
|
+
targetHwnd: parentHwnd,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// If PostMessage resolved to the parent (no Edit-class child found), the
|
|
245
|
+
// app is almost certainly a modern UWP/WinUI app where WM_CHAR has nowhere
|
|
246
|
+
// to land. Fall through to UIA SetValue, which interacts with XAML/UWP
|
|
247
|
+
// controls via Microsoft's accessibility API. UIA doesn't need focus.
|
|
248
|
+
const fellThroughToParent = pmResult.ok && pmResult.targetHwnd === parentHwnd;
|
|
249
|
+
if (pmResult.ok && !fellThroughToParent)
|
|
250
|
+
return pmResult;
|
|
251
|
+
const uiaResult = await uiaTypeIntoWindow(parentHwnd, text, { replace });
|
|
252
|
+
if (uiaResult.ok) {
|
|
253
|
+
return { ...uiaResult, fallback: pmResult };
|
|
254
|
+
}
|
|
255
|
+
// Both failed — return PostMessage result (likely contains a clearer error
|
|
256
|
+
// than UIA's "no value pattern" message) with UIA detail in fallback.
|
|
257
|
+
return { ...pmResult, fallback: uiaResult };
|
|
258
|
+
}
|
|
259
|
+
// UIA-based typing — three sequential strategies, each with diagnostics so we
|
|
260
|
+
// can see which element was targeted and whether the change actually stuck.
|
|
261
|
+
//
|
|
262
|
+
// Strategy ladder:
|
|
263
|
+
// 1. ValuePattern.SetValue — fastest, works for TextBox / classic Edit
|
|
264
|
+
// mapped via UIA
|
|
265
|
+
// 2. UIA SetFocus + clipboard paste via PostMessage Ctrl+V — for
|
|
266
|
+
// virtualized controls (modern Notepad's RichEditBox) where SetValue
|
|
267
|
+
// silently no-ops or the data model updates but UI doesn't repaint
|
|
268
|
+
// 3. (deferred) — TextPattern.RangeFromAnnotation insert; not yet wired
|
|
269
|
+
//
|
|
270
|
+
// Returns rich diagnostics: which UIA element was selected (Name /
|
|
271
|
+
// AutomationId / ClassName), the value before and after, and which strategy
|
|
272
|
+
// succeeded. The caller surfaces all of this in details.diagnostic.
|
|
273
|
+
async function uiaTypeIntoWindow(parentHwnd, text, opts) {
|
|
274
|
+
const script = path.join(os.tmpdir(), `superbased-uia-${Date.now()}.ps1`);
|
|
275
|
+
const textB64 = Buffer.from(text, 'utf-16le').toString('base64');
|
|
276
|
+
const replace = opts?.replace === true;
|
|
277
|
+
fs.writeFileSync(script, `
|
|
278
|
+
param([long]$Hwnd, [string]$TextB64, [switch]$Replace)
|
|
279
|
+
Add-Type -AssemblyName UIAutomationClient
|
|
280
|
+
Add-Type -AssemblyName UIAutomationTypes
|
|
281
|
+
Add-Type -AssemblyName System.Windows.Forms
|
|
282
|
+
Add-Type -TypeDefinition @'
|
|
283
|
+
using System; using System.Runtime.InteropServices;
|
|
284
|
+
public class WinSend {
|
|
285
|
+
[DllImport("user32.dll", SetLastError=true)]
|
|
286
|
+
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
287
|
+
[DllImport("user32.dll", SetLastError=true)]
|
|
288
|
+
public static extern void keybd_event(byte vk, byte scan, uint flags, UIntPtr extra);
|
|
289
|
+
public const uint WM_KEYDOWN = 0x0100;
|
|
290
|
+
public const uint WM_KEYUP = 0x0101;
|
|
291
|
+
}
|
|
292
|
+
'@
|
|
293
|
+
|
|
294
|
+
$decoded = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($TextB64))
|
|
295
|
+
$h = [IntPtr]::new($Hwnd)
|
|
296
|
+
|
|
297
|
+
function To-JSON {
|
|
298
|
+
param($obj)
|
|
299
|
+
return ($obj | ConvertTo-Json -Compress -Depth 4)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
try {
|
|
303
|
+
$root = [System.Windows.Automation.AutomationElement]::FromHandle($h)
|
|
304
|
+
} catch {
|
|
305
|
+
Write-Output (To-JSON @{ phase = 'from_handle'; ok = $false; error = $_.Exception.Message })
|
|
306
|
+
exit 1
|
|
307
|
+
}
|
|
308
|
+
if (-not $root) { Write-Output (To-JSON @{ phase = 'from_handle'; ok = $false; error = 'null root' }); exit 1 }
|
|
309
|
+
|
|
310
|
+
# Find the target — Edit first (TextBox), then Document (RichEditBox / modern Notepad)
|
|
311
|
+
$tryTypes = @(
|
|
312
|
+
@{ name = 'Edit'; ct = [System.Windows.Automation.ControlType]::Edit },
|
|
313
|
+
@{ name = 'Document'; ct = [System.Windows.Automation.ControlType]::Document }
|
|
314
|
+
)
|
|
315
|
+
$target = $null
|
|
316
|
+
$matchedKind = ''
|
|
317
|
+
foreach ($t in $tryTypes) {
|
|
318
|
+
$cond = New-Object System.Windows.Automation.PropertyCondition([System.Windows.Automation.AutomationElement]::ControlTypeProperty, $t.ct)
|
|
319
|
+
$found = $root.FindFirst([System.Windows.Automation.TreeScope]::Descendants, $cond)
|
|
320
|
+
if ($found) { $target = $found; $matchedKind = $t.name; break }
|
|
321
|
+
}
|
|
322
|
+
if (-not $target) {
|
|
323
|
+
Write-Output (To-JSON @{ phase = 'find'; ok = $false; error = 'no Edit or Document descendant'; kind = ''; root = $root.Current.Name })
|
|
324
|
+
exit 1
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
# Capture identifiers BEFORE any mutation
|
|
328
|
+
$elemName = $target.Current.Name
|
|
329
|
+
$elemAutoId = $target.Current.AutomationId
|
|
330
|
+
$elemClass = $target.Current.ClassName
|
|
331
|
+
$elemFrameworkId = $target.Current.FrameworkId
|
|
332
|
+
|
|
333
|
+
# Try ValuePattern
|
|
334
|
+
$vpAttr = [System.Windows.Automation.ValuePattern]::Pattern
|
|
335
|
+
$vpRef = $null
|
|
336
|
+
$gotVp = $target.TryGetCurrentPattern($vpAttr, [ref]$vpRef)
|
|
337
|
+
$valueBefore = $null
|
|
338
|
+
$valueAfter = $null
|
|
339
|
+
$strategy = $null
|
|
340
|
+
|
|
341
|
+
if ($gotVp -and $vpRef) {
|
|
342
|
+
$valueBefore = $vpRef.Current.Value
|
|
343
|
+
if ($null -eq $valueBefore) { $valueBefore = '' }
|
|
344
|
+
# $Replace:$true → SetValue replaces the entire content (\$decoded alone).
|
|
345
|
+
# $Replace:$false → SetValue appends (\$valueBefore + \$decoded) — preserves
|
|
346
|
+
# the long-standing default where the type tool adds to whatever is already
|
|
347
|
+
# in the field unless the caller explicitly opts into clearFirst/replace.
|
|
348
|
+
$toSet = if ($Replace) { $decoded } else { $valueBefore + $decoded }
|
|
349
|
+
$expectedAfter = $toSet
|
|
350
|
+
try {
|
|
351
|
+
$vpRef.SetValue($toSet)
|
|
352
|
+
Start-Sleep -Milliseconds 80
|
|
353
|
+
$valueAfter = $vpRef.Current.Value
|
|
354
|
+
if ($null -eq $valueAfter) { $valueAfter = '' }
|
|
355
|
+
$strategy = if ($Replace) { 'value_setvalue_replace' } else { 'value_setvalue' }
|
|
356
|
+
} catch {
|
|
357
|
+
Write-Output (To-JSON @{ phase = 'setvalue'; ok = $false; error = $_.Exception.Message; kind = $matchedKind; name = $elemName; autoId = $elemAutoId; cls = $elemClass; framework = $elemFrameworkId; valueBefore = $valueBefore; replace = $Replace })
|
|
358
|
+
exit 1
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
# Did the underlying value change to what we asked for?
|
|
362
|
+
if ($valueAfter -eq $expectedAfter) {
|
|
363
|
+
Write-Output (To-JSON @{ phase = 'done'; ok = $true; strategy = $strategy; kind = $matchedKind; name = $elemName; autoId = $elemAutoId; cls = $elemClass; framework = $elemFrameworkId; valueBeforeLen = $valueBefore.Length; valueAfterLen = $valueAfter.Length; appended = $decoded.Length; replace = $Replace })
|
|
364
|
+
exit 0
|
|
365
|
+
}
|
|
366
|
+
# SetValue returned OK but the value didn't actually update — the control
|
|
367
|
+
# is virtualized or readonly. Fall through to clipboard paste strategy.
|
|
368
|
+
$strategy = 'value_setvalue_noop'
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
# Strategy 2: SetFocus on the UIA element + clipboard paste via Ctrl+V.
|
|
372
|
+
# Works for virtualized text controls (modern Notepad) that ignore SetValue.
|
|
373
|
+
try {
|
|
374
|
+
[System.Windows.Forms.Clipboard]::SetText($decoded)
|
|
375
|
+
} catch {
|
|
376
|
+
Write-Output (To-JSON @{ phase = 'clipboard_set'; ok = $false; error = $_.Exception.Message; previousStrategy = $strategy; kind = $matchedKind; name = $elemName; autoId = $elemAutoId; cls = $elemClass; valueBefore = $valueBefore })
|
|
377
|
+
exit 1
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
try {
|
|
381
|
+
$target.SetFocus()
|
|
382
|
+
Start-Sleep -Milliseconds 150
|
|
383
|
+
} catch {
|
|
384
|
+
Write-Output (To-JSON @{ phase = 'set_focus'; ok = $false; error = $_.Exception.Message; previousStrategy = $strategy; kind = $matchedKind; name = $elemName; autoId = $elemAutoId; cls = $elemClass })
|
|
385
|
+
exit 1
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
# Replace semantic on the clipboard-paste path: Ctrl+A selects everything in
|
|
389
|
+
# the focused control, then Ctrl+V pastes the new clipboard content — which
|
|
390
|
+
# replaces the selection. When not replacing, skip the Ctrl+A so paste
|
|
391
|
+
# appends at the current caret.
|
|
392
|
+
try {
|
|
393
|
+
if ($Replace) {
|
|
394
|
+
[WinSend]::keybd_event(0x11, 0, 0, [UIntPtr]::Zero) # Ctrl down
|
|
395
|
+
[WinSend]::keybd_event(0x41, 0, 0, [UIntPtr]::Zero) # A down
|
|
396
|
+
Start-Sleep -Milliseconds 20
|
|
397
|
+
[WinSend]::keybd_event(0x41, 0, 2, [UIntPtr]::Zero) # A up
|
|
398
|
+
[WinSend]::keybd_event(0x11, 0, 2, [UIntPtr]::Zero) # Ctrl up
|
|
399
|
+
Start-Sleep -Milliseconds 30
|
|
400
|
+
}
|
|
401
|
+
[WinSend]::keybd_event(0x11, 0, 0, [UIntPtr]::Zero) # Ctrl down
|
|
402
|
+
[WinSend]::keybd_event(0x56, 0, 0, [UIntPtr]::Zero) # V down
|
|
403
|
+
Start-Sleep -Milliseconds 30
|
|
404
|
+
[WinSend]::keybd_event(0x56, 0, 2, [UIntPtr]::Zero) # V up
|
|
405
|
+
[WinSend]::keybd_event(0x11, 0, 2, [UIntPtr]::Zero) # Ctrl up
|
|
406
|
+
Start-Sleep -Milliseconds 100
|
|
407
|
+
} catch {
|
|
408
|
+
Write-Output (To-JSON @{ phase = 'send_paste'; ok = $false; error = $_.Exception.Message; previousStrategy = $strategy; kind = $matchedKind; name = $elemName; autoId = $elemAutoId; cls = $elemClass })
|
|
409
|
+
exit 1
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
# If we have a ValuePattern, try to read back the value to verify
|
|
413
|
+
if ($vpRef) {
|
|
414
|
+
$valueAfter = $vpRef.Current.Value
|
|
415
|
+
if ($null -eq $valueAfter) { $valueAfter = '' }
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
Write-Output (To-JSON @{
|
|
419
|
+
phase = 'done'; ok = $true;
|
|
420
|
+
strategy = if ($Replace) { 'setfocus_clipboard_paste_replace' } else { 'setfocus_clipboard_paste' };
|
|
421
|
+
previousStrategy = $strategy;
|
|
422
|
+
kind = $matchedKind;
|
|
423
|
+
name = $elemName; autoId = $elemAutoId; cls = $elemClass; framework = $elemFrameworkId;
|
|
424
|
+
valueBeforeLen = if ($null -ne $valueBefore) { $valueBefore.Length } else { -1 };
|
|
425
|
+
valueAfterLen = if ($null -ne $valueAfter) { $valueAfter.Length } else { -1 };
|
|
426
|
+
appended = $decoded.Length;
|
|
427
|
+
replace = $Replace;
|
|
428
|
+
})
|
|
429
|
+
exit 0
|
|
430
|
+
`);
|
|
431
|
+
try {
|
|
432
|
+
const out = childProcess.execSync(`powershell -ExecutionPolicy Bypass -File "${script}" -Hwnd ${parentHwnd} -TextB64 "${textB64}"${replace ? ' -Replace' : ''}`, { encoding: 'utf-8', timeout: 20_000, stdio: 'pipe' }).trim();
|
|
433
|
+
try {
|
|
434
|
+
fs.unlinkSync(script);
|
|
435
|
+
}
|
|
436
|
+
catch { /* cleanup */ }
|
|
437
|
+
let diag;
|
|
438
|
+
try {
|
|
439
|
+
diag = JSON.parse(out);
|
|
440
|
+
}
|
|
441
|
+
catch {
|
|
442
|
+
return { ok: false, method: 'uia_setvalue', error: `UIA returned non-JSON: ${out.slice(0, 200)}`, targetHwnd: parentHwnd };
|
|
443
|
+
}
|
|
444
|
+
const diagJson = JSON.stringify(diag);
|
|
445
|
+
if (diag.ok) {
|
|
446
|
+
const stratStr = String(diag.strategy || '');
|
|
447
|
+
return {
|
|
448
|
+
ok: true,
|
|
449
|
+
method: stratStr.startsWith('setfocus_clipboard_paste') ? 'uia_keys' : 'uia_setvalue',
|
|
450
|
+
charsSent: text.length,
|
|
451
|
+
targetHwnd: parentHwnd,
|
|
452
|
+
diagnostic: diagJson, // top-level — survives spread in caller
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return {
|
|
456
|
+
ok: false,
|
|
457
|
+
method: 'uia_setvalue',
|
|
458
|
+
error: `UIA failed at phase=${diag.phase}: ${diag.error || 'unknown'}`,
|
|
459
|
+
diagnostic: diagJson,
|
|
460
|
+
targetHwnd: parentHwnd,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
catch (err) {
|
|
464
|
+
try {
|
|
465
|
+
fs.unlinkSync(script);
|
|
466
|
+
}
|
|
467
|
+
catch { /* cleanup */ }
|
|
468
|
+
return {
|
|
469
|
+
ok: false,
|
|
470
|
+
method: 'uia_setvalue',
|
|
471
|
+
error: err.message || String(err),
|
|
472
|
+
targetHwnd: parentHwnd,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Send a key combo to `parentHwnd` via WM_KEYDOWN/WM_KEYUP PostMessage.
|
|
478
|
+
* Resolves modifier + main key from the combo string. Same caveats as type:
|
|
479
|
+
* works for standard Win32 controls, won't fire global app hotkeys.
|
|
480
|
+
*
|
|
481
|
+
* Modifier mapping reuses the same names as gui-automation.resolveKey:
|
|
482
|
+
* Ctrl/Control, Shift, Alt/Option, Cmd/Meta/Win/Super (translated to Ctrl
|
|
483
|
+
* on Windows since there is no Cmd key).
|
|
484
|
+
*/
|
|
485
|
+
async function sendComboToWindow(parentHwnd, combo) {
|
|
486
|
+
if (process.platform !== 'win32') {
|
|
487
|
+
return { ok: false, method: 'unsupported_platform', error: 'PostMessage hotkey is Windows-only' };
|
|
488
|
+
}
|
|
489
|
+
if (!parentHwnd) {
|
|
490
|
+
return { ok: false, method: 'postmessage_keydown', error: 'parent hwnd required' };
|
|
491
|
+
}
|
|
492
|
+
// Parse combo → list of VK codes
|
|
493
|
+
const parts = combo.split('+').map((p) => p.trim()).filter(Boolean);
|
|
494
|
+
const vks = [];
|
|
495
|
+
for (const part of parts) {
|
|
496
|
+
const vk = nameToVK(part);
|
|
497
|
+
if (vk === undefined) {
|
|
498
|
+
return { ok: false, method: 'postmessage_keydown', error: `unrecognized key: "${part}"` };
|
|
499
|
+
}
|
|
500
|
+
vks.push(vk);
|
|
501
|
+
}
|
|
502
|
+
const script = path.join(os.tmpdir(), `superbased-keywindow-${Date.now()}.ps1`);
|
|
503
|
+
const vkCsv = vks.join(',');
|
|
504
|
+
fs.writeFileSync(script, `
|
|
505
|
+
param([long]$Hwnd, [string]$VkCsv)
|
|
506
|
+
Add-Type -TypeDefinition @'
|
|
507
|
+
using System;
|
|
508
|
+
using System.Runtime.InteropServices;
|
|
509
|
+
public class WinKey {
|
|
510
|
+
[DllImport("user32.dll", SetLastError=true)]
|
|
511
|
+
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
|
|
512
|
+
[DllImport("user32.dll", SetLastError=true, CharSet=CharSet.Auto)]
|
|
513
|
+
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr child, string cls, string title);
|
|
514
|
+
[DllImport("user32.dll")]
|
|
515
|
+
public static extern bool IsWindow(IntPtr hWnd);
|
|
516
|
+
public const uint WM_KEYDOWN = 0x0100;
|
|
517
|
+
public const uint WM_KEYUP = 0x0101;
|
|
518
|
+
public static IntPtr ResolveTarget(IntPtr parent) {
|
|
519
|
+
string[] classes = new string[]{ "Edit", "RICHEDIT50W", "RICHEDIT60W", "RichEdit20W" };
|
|
520
|
+
foreach (string cls in classes) {
|
|
521
|
+
IntPtr child = FindWindowEx(parent, IntPtr.Zero, cls, null);
|
|
522
|
+
if (child != IntPtr.Zero) return child;
|
|
523
|
+
}
|
|
524
|
+
return parent;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
'@
|
|
528
|
+
$h = [IntPtr]::new($Hwnd)
|
|
529
|
+
if (-not [WinKey]::IsWindow($h)) { Write-Output "ERROR:invalid_hwnd"; exit 1 }
|
|
530
|
+
$target = [WinKey]::ResolveTarget($h)
|
|
531
|
+
$vks = ($VkCsv -split ',') | ForEach-Object { [int]$_ }
|
|
532
|
+
# Press all keys in order
|
|
533
|
+
foreach ($vk in $vks) {
|
|
534
|
+
[void][WinKey]::PostMessage($target, [WinKey]::WM_KEYDOWN, [IntPtr]::new($vk), [IntPtr]::Zero)
|
|
535
|
+
}
|
|
536
|
+
# Release in reverse
|
|
537
|
+
[array]::Reverse($vks)
|
|
538
|
+
foreach ($vk in $vks) {
|
|
539
|
+
[void][WinKey]::PostMessage($target, [WinKey]::WM_KEYUP, [IntPtr]::new($vk), [IntPtr]::Zero)
|
|
540
|
+
}
|
|
541
|
+
$target.ToInt64()
|
|
542
|
+
`);
|
|
543
|
+
try {
|
|
544
|
+
const out = childProcess.execSync(`powershell -ExecutionPolicy Bypass -File "${script}" -Hwnd ${parentHwnd} -VkCsv "${vkCsv}"`, { encoding: 'utf-8', timeout: 5_000, stdio: 'pipe' }).trim();
|
|
545
|
+
try {
|
|
546
|
+
fs.unlinkSync(script);
|
|
547
|
+
}
|
|
548
|
+
catch { /* cleanup */ }
|
|
549
|
+
if (out.startsWith('ERROR:')) {
|
|
550
|
+
return { ok: false, method: 'postmessage_keydown', error: out.replace('ERROR:', ''), targetHwnd: parentHwnd };
|
|
551
|
+
}
|
|
552
|
+
return { ok: true, method: 'postmessage_keydown', targetHwnd: out };
|
|
553
|
+
}
|
|
554
|
+
catch (err) {
|
|
555
|
+
try {
|
|
556
|
+
fs.unlinkSync(script);
|
|
557
|
+
}
|
|
558
|
+
catch { /* cleanup */ }
|
|
559
|
+
return {
|
|
560
|
+
ok: false,
|
|
561
|
+
method: 'postmessage_keydown',
|
|
562
|
+
error: err.message || String(err),
|
|
563
|
+
targetHwnd: parentHwnd,
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
// Win32 virtual-key codes for the combo names supported by gui-automation.
|
|
568
|
+
// Lowercase letters/digits map to ASCII uppercase since VK_A..VK_Z = 0x41..0x5A.
|
|
569
|
+
function nameToVK(name) {
|
|
570
|
+
const k = name.replace(/[{}]/g, '').trim();
|
|
571
|
+
const lower = k.toLowerCase();
|
|
572
|
+
// Modifiers — Cmd/Meta/Win/Super all map to LWIN (0x5B); on Windows there
|
|
573
|
+
// is no real "Cmd" so we treat it as the platform mod (Ctrl) per parity with
|
|
574
|
+
// the existing nut-js resolver. CmdOrCtrl resolves to Ctrl on Windows.
|
|
575
|
+
if (lower === 'cmd' || lower === 'meta' || lower === 'win' || lower === 'super')
|
|
576
|
+
return 0x5B; // VK_LWIN
|
|
577
|
+
if (lower === 'ctrl' || lower === 'control')
|
|
578
|
+
return 0x11; // VK_CONTROL
|
|
579
|
+
if (lower === 'cmdorctrl' || lower === 'commandorcontrol')
|
|
580
|
+
return 0x11; // VK_CONTROL on Windows
|
|
581
|
+
if (lower === 'shift')
|
|
582
|
+
return 0x10; // VK_SHIFT
|
|
583
|
+
if (lower === 'alt' || lower === 'option')
|
|
584
|
+
return 0x12; // VK_MENU
|
|
585
|
+
if (lower === 'enter' || lower === 'return')
|
|
586
|
+
return 0x0D; // VK_RETURN
|
|
587
|
+
if (lower === 'tab')
|
|
588
|
+
return 0x09; // VK_TAB
|
|
589
|
+
if (lower === 'esc' || lower === 'escape')
|
|
590
|
+
return 0x1B; // VK_ESCAPE
|
|
591
|
+
if (lower === 'space' || lower === 'spacebar')
|
|
592
|
+
return 0x20; // VK_SPACE
|
|
593
|
+
if (lower === 'backspace')
|
|
594
|
+
return 0x08; // VK_BACK
|
|
595
|
+
if (lower === 'delete' || lower === 'del')
|
|
596
|
+
return 0x2E; // VK_DELETE
|
|
597
|
+
if (lower === 'left')
|
|
598
|
+
return 0x25;
|
|
599
|
+
if (lower === 'right')
|
|
600
|
+
return 0x27;
|
|
601
|
+
if (lower === 'up')
|
|
602
|
+
return 0x26;
|
|
603
|
+
if (lower === 'down')
|
|
604
|
+
return 0x28;
|
|
605
|
+
if (lower === 'home')
|
|
606
|
+
return 0x24;
|
|
607
|
+
if (lower === 'end')
|
|
608
|
+
return 0x23;
|
|
609
|
+
if (lower === 'pageup' || lower === 'pgup')
|
|
610
|
+
return 0x21;
|
|
611
|
+
if (lower === 'pagedown' || lower === 'pgdn')
|
|
612
|
+
return 0x22;
|
|
613
|
+
const fMatch = lower.match(/^f([1-9]|1[0-2])$/);
|
|
614
|
+
if (fMatch)
|
|
615
|
+
return 0x70 + (Number(fMatch[1]) - 1); // VK_F1..VK_F12
|
|
616
|
+
if (k.length === 1) {
|
|
617
|
+
const code = k.toUpperCase().charCodeAt(0);
|
|
618
|
+
if (code >= 0x30 && code <= 0x5A)
|
|
619
|
+
return code; // 0..9 and A..Z
|
|
620
|
+
}
|
|
621
|
+
return undefined;
|
|
622
|
+
}
|