superbased 1.6.3 → 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.
Files changed (423) hide show
  1. package/README.md +169 -36
  2. package/SUPERBASED_SKILL.md +1196 -22
  3. package/dist/electron/core/input-injection/index.d.ts +6 -0
  4. package/dist/electron/core/input-injection/index.d.ts.map +1 -0
  5. package/dist/electron/core/input-injection/index.js +31 -0
  6. package/dist/electron/core/input-injection/index.js.map +1 -0
  7. package/dist/electron/core/input-injection/macos.d.ts +3 -0
  8. package/dist/electron/core/input-injection/macos.d.ts.map +1 -0
  9. package/dist/electron/core/input-injection/macos.js +14 -0
  10. package/dist/electron/core/input-injection/macos.js.map +1 -0
  11. package/dist/electron/core/input-injection/windows.d.ts +3 -0
  12. package/dist/electron/core/input-injection/windows.d.ts.map +1 -0
  13. package/dist/electron/core/input-injection/windows.js +119 -0
  14. package/dist/electron/core/input-injection/windows.js.map +1 -0
  15. package/dist/electron/core/json-store.d.ts +22 -0
  16. package/dist/electron/core/json-store.d.ts.map +1 -1
  17. package/dist/electron/core/json-store.js +61 -47
  18. package/dist/electron/core/json-store.js.map +1 -1
  19. package/dist/electron/core/platform.d.ts +1 -0
  20. package/dist/electron/core/platform.d.ts.map +1 -1
  21. package/dist/electron/core/serialize-schema.d.ts +35 -0
  22. package/dist/electron/core/serialize-schema.d.ts.map +1 -0
  23. package/dist/electron/core/serialize-schema.js +89 -0
  24. package/dist/electron/core/serialize-schema.js.map +1 -0
  25. package/dist/electron/core/settings-schema.d.ts +81 -0
  26. package/dist/electron/core/settings-schema.d.ts.map +1 -0
  27. package/dist/electron/core/settings-schema.js +1357 -0
  28. package/dist/electron/core/settings-schema.js.map +1 -0
  29. package/dist/electron/logger.d.ts.map +1 -1
  30. package/dist/electron/logger.js +22 -8
  31. package/dist/electron/logger.js.map +1 -1
  32. package/dist/electron/main.js +417 -133
  33. package/dist/electron/modules/accessibility/macos-provider.d.ts +8 -0
  34. package/dist/electron/modules/accessibility/macos-provider.d.ts.map +1 -0
  35. package/dist/electron/modules/accessibility/macos-provider.js +94 -0
  36. package/dist/electron/modules/accessibility/macos-provider.js.map +1 -0
  37. package/dist/electron/modules/accessibility/provider.d.ts +12 -0
  38. package/dist/electron/modules/accessibility/provider.d.ts.map +1 -0
  39. package/dist/electron/modules/accessibility/provider.js +52 -0
  40. package/dist/electron/modules/accessibility/provider.js.map +1 -0
  41. package/dist/electron/modules/accessibility/types.d.ts +63 -0
  42. package/dist/electron/modules/accessibility/types.d.ts.map +1 -0
  43. package/dist/electron/modules/accessibility/types.js +6 -0
  44. package/dist/electron/modules/accessibility/types.js.map +1 -0
  45. package/dist/electron/modules/accessibility/windows-provider.d.ts +8 -0
  46. package/dist/electron/modules/accessibility/windows-provider.d.ts.map +1 -0
  47. package/dist/electron/modules/accessibility/windows-provider.js +85 -0
  48. package/dist/electron/modules/accessibility/windows-provider.js.map +1 -0
  49. package/dist/electron/modules/api-server.d.ts +4 -1
  50. package/dist/electron/modules/api-server.d.ts.map +1 -1
  51. package/dist/electron/modules/api-server.js +1414 -218
  52. package/dist/electron/modules/api-server.js.map +1 -1
  53. package/dist/electron/modules/auth.d.ts +14 -0
  54. package/dist/electron/modules/auth.d.ts.map +1 -1
  55. package/dist/electron/modules/auth.js +43 -0
  56. package/dist/electron/modules/auth.js.map +1 -1
  57. package/dist/electron/modules/azure-speech-realtime.d.ts.map +1 -1
  58. package/dist/electron/modules/azure-speech-realtime.js +56 -0
  59. package/dist/electron/modules/azure-speech-realtime.js.map +1 -1
  60. package/dist/electron/modules/capture.d.ts +8 -0
  61. package/dist/electron/modules/capture.d.ts.map +1 -1
  62. package/dist/electron/modules/capture.js +33 -0
  63. package/dist/electron/modules/capture.js.map +1 -1
  64. package/dist/electron/modules/compose-screenshots.d.ts +8 -0
  65. package/dist/electron/modules/compose-screenshots.d.ts.map +1 -0
  66. package/dist/electron/modules/compose-screenshots.js +86 -0
  67. package/dist/electron/modules/compose-screenshots.js.map +1 -0
  68. package/dist/electron/modules/context-menu-detect.d.ts +47 -0
  69. package/dist/electron/modules/context-menu-detect.d.ts.map +1 -0
  70. package/dist/electron/modules/context-menu-detect.js +272 -0
  71. package/dist/electron/modules/context-menu-detect.js.map +1 -0
  72. package/dist/electron/modules/dictation.d.ts.map +1 -1
  73. package/dist/electron/modules/dictation.js +12 -7
  74. package/dist/electron/modules/dictation.js.map +1 -1
  75. package/dist/electron/modules/gif-util.d.ts +9 -0
  76. package/dist/electron/modules/gif-util.d.ts.map +1 -0
  77. package/dist/electron/modules/gif-util.js +63 -0
  78. package/dist/electron/modules/gif-util.js.map +1 -0
  79. package/dist/electron/modules/gui-automation-errors.d.ts +11 -0
  80. package/dist/electron/modules/gui-automation-errors.d.ts.map +1 -0
  81. package/dist/electron/modules/gui-automation-errors.js +79 -0
  82. package/dist/electron/modules/gui-automation-errors.js.map +1 -0
  83. package/dist/electron/modules/gui-automation-telemetry.d.ts +38 -0
  84. package/dist/electron/modules/gui-automation-telemetry.d.ts.map +1 -0
  85. package/dist/electron/modules/gui-automation-telemetry.js +200 -0
  86. package/dist/electron/modules/gui-automation-telemetry.js.map +1 -0
  87. package/dist/electron/modules/gui-automation.d.ts +1143 -0
  88. package/dist/electron/modules/gui-automation.d.ts.map +1 -0
  89. package/dist/electron/modules/gui-automation.js +8769 -0
  90. package/dist/electron/modules/gui-automation.js.map +1 -0
  91. package/dist/electron/modules/hotkeys.d.ts +2 -1
  92. package/dist/electron/modules/hotkeys.d.ts.map +1 -1
  93. package/dist/electron/modules/hotkeys.js +25 -1
  94. package/dist/electron/modules/hotkeys.js.map +1 -1
  95. package/dist/electron/modules/human-input/index.d.ts +35 -0
  96. package/dist/electron/modules/human-input/index.d.ts.map +1 -0
  97. package/dist/electron/modules/human-input/index.js +163 -0
  98. package/dist/electron/modules/human-input/index.js.map +1 -0
  99. package/dist/electron/modules/human-input/keyboard/timing.d.ts +38 -0
  100. package/dist/electron/modules/human-input/keyboard/timing.d.ts.map +1 -0
  101. package/dist/electron/modules/human-input/keyboard/timing.js +57 -0
  102. package/dist/electron/modules/human-input/keyboard/timing.js.map +1 -0
  103. package/dist/electron/modules/human-input/mouse/path.d.ts +24 -0
  104. package/dist/electron/modules/human-input/mouse/path.d.ts.map +1 -0
  105. package/dist/electron/modules/human-input/mouse/path.js +80 -0
  106. package/dist/electron/modules/human-input/mouse/path.js.map +1 -0
  107. package/dist/electron/modules/human-input/mouse/velocity.d.ts +48 -0
  108. package/dist/electron/modules/human-input/mouse/velocity.d.ts.map +1 -0
  109. package/dist/electron/modules/human-input/mouse/velocity.js +93 -0
  110. package/dist/electron/modules/human-input/mouse/velocity.js.map +1 -0
  111. package/dist/electron/modules/human-input/profiles.d.ts +90 -0
  112. package/dist/electron/modules/human-input/profiles.d.ts.map +1 -0
  113. package/dist/electron/modules/human-input/profiles.js +124 -0
  114. package/dist/electron/modules/human-input/profiles.js.map +1 -0
  115. package/dist/electron/modules/human-input/rng.d.ts +16 -0
  116. package/dist/electron/modules/human-input/rng.d.ts.map +1 -0
  117. package/dist/electron/modules/human-input/rng.js +101 -0
  118. package/dist/electron/modules/human-input/rng.js.map +1 -0
  119. package/dist/electron/modules/human-input/salt.d.ts +15 -0
  120. package/dist/electron/modules/human-input/salt.d.ts.map +1 -0
  121. package/dist/electron/modules/human-input/salt.js +48 -0
  122. package/dist/electron/modules/human-input/salt.js.map +1 -0
  123. package/dist/electron/modules/image-utils.d.ts +20 -0
  124. package/dist/electron/modules/image-utils.d.ts.map +1 -0
  125. package/dist/electron/modules/image-utils.js +80 -0
  126. package/dist/electron/modules/image-utils.js.map +1 -0
  127. package/dist/electron/modules/ollama/capability.d.ts +32 -0
  128. package/dist/electron/modules/ollama/capability.d.ts.map +1 -0
  129. package/dist/electron/modules/ollama/capability.js +117 -0
  130. package/dist/electron/modules/ollama/capability.js.map +1 -0
  131. package/dist/electron/modules/ollama/client.d.ts +14 -0
  132. package/dist/electron/modules/ollama/client.d.ts.map +1 -0
  133. package/dist/electron/modules/ollama/client.js +134 -0
  134. package/dist/electron/modules/ollama/client.js.map +1 -0
  135. package/dist/electron/modules/ollama/detector.d.ts +29 -0
  136. package/dist/electron/modules/ollama/detector.d.ts.map +1 -0
  137. package/dist/electron/modules/ollama/detector.js +177 -0
  138. package/dist/electron/modules/ollama/detector.js.map +1 -0
  139. package/dist/electron/modules/ollama/dispatcher.d.ts +36 -0
  140. package/dist/electron/modules/ollama/dispatcher.d.ts.map +1 -0
  141. package/dist/electron/modules/ollama/dispatcher.js +97 -0
  142. package/dist/electron/modules/ollama/dispatcher.js.map +1 -0
  143. package/dist/electron/modules/ollama/router.d.ts +51 -0
  144. package/dist/electron/modules/ollama/router.d.ts.map +1 -0
  145. package/dist/electron/modules/ollama/router.js +201 -0
  146. package/dist/electron/modules/ollama/router.js.map +1 -0
  147. package/dist/electron/modules/pin-window.d.ts.map +1 -1
  148. package/dist/electron/modules/pin-window.js +2 -1
  149. package/dist/electron/modules/pin-window.js.map +1 -1
  150. package/dist/electron/modules/platform/dpi.d.ts +2 -0
  151. package/dist/electron/modules/platform/dpi.d.ts.map +1 -0
  152. package/dist/electron/modules/platform/dpi.js +48 -0
  153. package/dist/electron/modules/platform/dpi.js.map +1 -0
  154. package/dist/electron/modules/platform/errors.d.ts +13 -0
  155. package/dist/electron/modules/platform/errors.d.ts.map +1 -0
  156. package/dist/electron/modules/platform/errors.js +36 -0
  157. package/dist/electron/modules/platform/errors.js.map +1 -0
  158. package/dist/electron/modules/platform/index.d.ts +24 -0
  159. package/dist/electron/modules/platform/index.d.ts.map +1 -0
  160. package/dist/electron/modules/platform/index.js +133 -0
  161. package/dist/electron/modules/platform/index.js.map +1 -0
  162. package/dist/electron/modules/platform/interfaces.d.ts +140 -0
  163. package/dist/electron/modules/platform/interfaces.d.ts.map +1 -0
  164. package/dist/electron/modules/platform/interfaces.js +14 -0
  165. package/dist/electron/modules/platform/interfaces.js.map +1 -0
  166. package/dist/electron/modules/platform/macos/ax.d.ts +15 -0
  167. package/dist/electron/modules/platform/macos/ax.d.ts.map +1 -0
  168. package/dist/electron/modules/platform/macos/ax.js +222 -0
  169. package/dist/electron/modules/platform/macos/ax.js.map +1 -0
  170. package/dist/electron/modules/platform/macos/capture.d.ts +14 -0
  171. package/dist/electron/modules/platform/macos/capture.d.ts.map +1 -0
  172. package/dist/electron/modules/platform/macos/capture.js +106 -0
  173. package/dist/electron/modules/platform/macos/capture.js.map +1 -0
  174. package/dist/electron/modules/platform/macos/input.d.ts +16 -0
  175. package/dist/electron/modules/platform/macos/input.d.ts.map +1 -0
  176. package/dist/electron/modules/platform/macos/input.js +342 -0
  177. package/dist/electron/modules/platform/macos/input.js.map +1 -0
  178. package/dist/electron/modules/platform/macos/launch.d.ts +10 -0
  179. package/dist/electron/modules/platform/macos/launch.d.ts.map +1 -0
  180. package/dist/electron/modules/platform/macos/launch.js +114 -0
  181. package/dist/electron/modules/platform/macos/launch.js.map +1 -0
  182. package/dist/electron/modules/platform/macos/session.d.ts +8 -0
  183. package/dist/electron/modules/platform/macos/session.d.ts.map +1 -0
  184. package/dist/electron/modules/platform/macos/session.js +17 -0
  185. package/dist/electron/modules/platform/macos/session.js.map +1 -0
  186. package/dist/electron/modules/platform/macos/window.d.ts +31 -0
  187. package/dist/electron/modules/platform/macos/window.d.ts.map +1 -0
  188. package/dist/electron/modules/platform/macos/window.js +271 -0
  189. package/dist/electron/modules/platform/macos/window.js.map +1 -0
  190. package/dist/electron/modules/platform/shared.d.ts +10 -0
  191. package/dist/electron/modules/platform/shared.d.ts.map +1 -0
  192. package/dist/electron/modules/platform/shared.js +201 -0
  193. package/dist/electron/modules/platform/shared.js.map +1 -0
  194. package/dist/electron/modules/platform/types.d.ts +182 -0
  195. package/dist/electron/modules/platform/types.d.ts.map +1 -0
  196. package/dist/electron/modules/platform/types.js +24 -0
  197. package/dist/electron/modules/platform/types.js.map +1 -0
  198. package/dist/electron/modules/platform/windows/ax.d.ts +15 -0
  199. package/dist/electron/modules/platform/windows/ax.d.ts.map +1 -0
  200. package/dist/electron/modules/platform/windows/ax.js +277 -0
  201. package/dist/electron/modules/platform/windows/ax.js.map +1 -0
  202. package/dist/electron/modules/platform/windows/capture.d.ts +14 -0
  203. package/dist/electron/modules/platform/windows/capture.d.ts.map +1 -0
  204. package/dist/electron/modules/platform/windows/capture.js +115 -0
  205. package/dist/electron/modules/platform/windows/capture.js.map +1 -0
  206. package/dist/electron/modules/platform/windows/input.d.ts +17 -0
  207. package/dist/electron/modules/platform/windows/input.d.ts.map +1 -0
  208. package/dist/electron/modules/platform/windows/input.js +422 -0
  209. package/dist/electron/modules/platform/windows/input.js.map +1 -0
  210. package/dist/electron/modules/platform/windows/launch.d.ts +10 -0
  211. package/dist/electron/modules/platform/windows/launch.d.ts.map +1 -0
  212. package/dist/electron/modules/platform/windows/launch.js +185 -0
  213. package/dist/electron/modules/platform/windows/launch.js.map +1 -0
  214. package/dist/electron/modules/platform/windows/session.d.ts +8 -0
  215. package/dist/electron/modules/platform/windows/session.d.ts.map +1 -0
  216. package/dist/electron/modules/platform/windows/session.js +87 -0
  217. package/dist/electron/modules/platform/windows/session.js.map +1 -0
  218. package/dist/electron/modules/platform/windows/tray.d.ts +13 -0
  219. package/dist/electron/modules/platform/windows/tray.d.ts.map +1 -0
  220. package/dist/electron/modules/platform/windows/tray.js +390 -0
  221. package/dist/electron/modules/platform/windows/tray.js.map +1 -0
  222. package/dist/electron/modules/platform/windows/window.d.ts +30 -0
  223. package/dist/electron/modules/platform/windows/window.d.ts.map +1 -0
  224. package/dist/electron/modules/platform/windows/window.js +444 -0
  225. package/dist/electron/modules/platform/windows/window.js.map +1 -0
  226. package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.d.ts +15 -0
  227. package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.d.ts.map +1 -0
  228. package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.js +62 -0
  229. package/dist/electron/modules/recording/providers/change-detect-shared-wrapper.js.map +1 -0
  230. package/dist/electron/modules/recording/providers/provider-factory.d.ts.map +1 -1
  231. package/dist/electron/modules/recording/providers/provider-factory.js +13 -7
  232. package/dist/electron/modules/recording/providers/provider-factory.js.map +1 -1
  233. package/dist/electron/modules/scroll-calibration.d.ts +152 -0
  234. package/dist/electron/modules/scroll-calibration.d.ts.map +1 -0
  235. package/dist/electron/modules/scroll-calibration.js +271 -0
  236. package/dist/electron/modules/scroll-calibration.js.map +1 -0
  237. package/dist/electron/modules/scroll-capture.d.ts +3 -1
  238. package/dist/electron/modules/scroll-capture.d.ts.map +1 -1
  239. package/dist/electron/modules/scroll-capture.js +21 -72
  240. package/dist/electron/modules/scroll-capture.js.map +1 -1
  241. package/dist/electron/modules/sequence-locate.d.ts +126 -0
  242. package/dist/electron/modules/sequence-locate.d.ts.map +1 -0
  243. package/dist/electron/modules/sequence-locate.js +356 -0
  244. package/dist/electron/modules/sequence-locate.js.map +1 -0
  245. package/dist/electron/modules/store.d.ts +15 -56
  246. package/dist/electron/modules/store.d.ts.map +1 -1
  247. package/dist/electron/modules/store.js +84 -58
  248. package/dist/electron/modules/store.js.map +1 -1
  249. package/dist/electron/modules/stt/capability-probe.d.ts +67 -0
  250. package/dist/electron/modules/stt/capability-probe.d.ts.map +1 -0
  251. package/dist/electron/modules/stt/capability-probe.js +331 -0
  252. package/dist/electron/modules/stt/capability-probe.js.map +1 -0
  253. package/dist/electron/modules/stt/macos-engine.d.ts +20 -0
  254. package/dist/electron/modules/stt/macos-engine.d.ts.map +1 -0
  255. package/dist/electron/modules/stt/macos-engine.js +231 -0
  256. package/dist/electron/modules/stt/macos-engine.js.map +1 -0
  257. package/dist/electron/modules/stt/model-manager.d.ts +87 -0
  258. package/dist/electron/modules/stt/model-manager.d.ts.map +1 -0
  259. package/dist/electron/modules/stt/model-manager.js +321 -0
  260. package/dist/electron/modules/stt/model-manager.js.map +1 -0
  261. package/dist/electron/modules/stt/router.d.ts +35 -0
  262. package/dist/electron/modules/stt/router.d.ts.map +1 -0
  263. package/dist/electron/modules/stt/router.js +232 -0
  264. package/dist/electron/modules/stt/router.js.map +1 -0
  265. package/dist/electron/modules/stt/sherpa-engine.d.ts +43 -0
  266. package/dist/electron/modules/stt/sherpa-engine.d.ts.map +1 -0
  267. package/dist/electron/modules/stt/sherpa-engine.js +521 -0
  268. package/dist/electron/modules/stt/sherpa-engine.js.map +1 -0
  269. package/dist/electron/modules/stt/types.d.ts +72 -0
  270. package/dist/electron/modules/stt/types.d.ts.map +1 -0
  271. package/dist/electron/modules/stt/types.js +16 -0
  272. package/dist/electron/modules/stt/types.js.map +1 -0
  273. package/dist/electron/modules/stt/winrt-engine.d.ts +20 -0
  274. package/dist/electron/modules/stt/winrt-engine.d.ts.map +1 -0
  275. package/dist/electron/modules/stt/winrt-engine.js +238 -0
  276. package/dist/electron/modules/stt/winrt-engine.js.map +1 -0
  277. package/dist/electron/modules/template-match.d.ts +62 -0
  278. package/dist/electron/modules/template-match.d.ts.map +1 -0
  279. package/dist/electron/modules/template-match.js +205 -0
  280. package/dist/electron/modules/template-match.js.map +1 -0
  281. package/dist/electron/modules/tray.d.ts +2 -0
  282. package/dist/electron/modules/tray.d.ts.map +1 -1
  283. package/dist/electron/modules/tray.js +136 -8
  284. package/dist/electron/modules/tray.js.map +1 -1
  285. package/dist/electron/modules/undo-stack.d.ts +22 -0
  286. package/dist/electron/modules/undo-stack.d.ts.map +1 -0
  287. package/dist/electron/modules/undo-stack.js +41 -0
  288. package/dist/electron/modules/undo-stack.js.map +1 -0
  289. package/dist/electron/modules/watchers/active-window-watcher.d.ts +5 -0
  290. package/dist/electron/modules/watchers/active-window-watcher.d.ts.map +1 -0
  291. package/dist/electron/modules/watchers/active-window-watcher.js +152 -0
  292. package/dist/electron/modules/watchers/active-window-watcher.js.map +1 -0
  293. package/dist/electron/modules/watchers/clipboard-watcher.d.ts +5 -0
  294. package/dist/electron/modules/watchers/clipboard-watcher.d.ts.map +1 -0
  295. package/dist/electron/modules/watchers/clipboard-watcher.js +90 -0
  296. package/dist/electron/modules/watchers/clipboard-watcher.js.map +1 -0
  297. package/dist/electron/modules/watchers/file-watcher.d.ts +5 -0
  298. package/dist/electron/modules/watchers/file-watcher.d.ts.map +1 -0
  299. package/dist/electron/modules/watchers/file-watcher.js +91 -0
  300. package/dist/electron/modules/watchers/file-watcher.js.map +1 -0
  301. package/dist/electron/modules/watchers/registry.d.ts +34 -0
  302. package/dist/electron/modules/watchers/registry.d.ts.map +1 -0
  303. package/dist/electron/modules/watchers/registry.js +108 -0
  304. package/dist/electron/modules/watchers/registry.js.map +1 -0
  305. package/dist/electron/modules/watchers/screen-region-service.d.ts +18 -0
  306. package/dist/electron/modules/watchers/screen-region-service.d.ts.map +1 -0
  307. package/dist/electron/modules/watchers/screen-region-service.js +126 -0
  308. package/dist/electron/modules/watchers/screen-region-service.js.map +1 -0
  309. package/dist/electron/modules/watchers/screen-region-watcher.d.ts +6 -0
  310. package/dist/electron/modules/watchers/screen-region-watcher.d.ts.map +1 -0
  311. package/dist/electron/modules/watchers/screen-region-watcher.js +70 -0
  312. package/dist/electron/modules/watchers/screen-region-watcher.js.map +1 -0
  313. package/dist/electron/modules/window-activate.d.ts +103 -0
  314. package/dist/electron/modules/window-activate.d.ts.map +1 -0
  315. package/dist/electron/modules/window-activate.js +630 -0
  316. package/dist/electron/modules/window-activate.js.map +1 -0
  317. package/dist/electron/modules/window-input.d.ts +43 -0
  318. package/dist/electron/modules/window-input.d.ts.map +1 -0
  319. package/dist/electron/modules/window-input.js +623 -0
  320. package/dist/electron/modules/window-input.js.map +1 -0
  321. package/dist/electron/modules/window-resolver.d.ts +35 -0
  322. package/dist/electron/modules/window-resolver.d.ts.map +1 -0
  323. package/dist/electron/modules/window-resolver.js +210 -0
  324. package/dist/electron/modules/window-resolver.js.map +1 -0
  325. package/dist/headless/electron/core/input-injection/index.js +30 -0
  326. package/dist/headless/electron/core/input-injection/macos.js +13 -0
  327. package/dist/headless/electron/core/input-injection/windows.js +118 -0
  328. package/dist/headless/electron/core/json-store.js +61 -47
  329. package/dist/headless/electron/core/serialize-schema.js +88 -0
  330. package/dist/headless/electron/core/settings-schema.js +1356 -0
  331. package/dist/headless/electron/logger.js +22 -8
  332. package/dist/headless/electron/modules/accessibility/macos-provider.js +93 -0
  333. package/dist/headless/electron/modules/accessibility/provider.js +51 -0
  334. package/dist/headless/electron/modules/accessibility/types.js +5 -0
  335. package/dist/headless/electron/modules/accessibility/windows-provider.js +84 -0
  336. package/dist/headless/electron/modules/api-server.js +1414 -218
  337. package/dist/headless/electron/modules/auth.js +43 -0
  338. package/dist/headless/electron/modules/azure-speech-realtime.js +56 -0
  339. package/dist/headless/electron/modules/capture.js +33 -0
  340. package/dist/headless/electron/modules/context-menu-detect.js +271 -0
  341. package/dist/headless/electron/modules/dictation.js +12 -7
  342. package/dist/headless/electron/modules/gui-automation-errors.js +78 -0
  343. package/dist/headless/electron/modules/gui-automation-telemetry.js +199 -0
  344. package/dist/headless/electron/modules/gui-automation.js +8768 -0
  345. package/dist/headless/electron/modules/human-input/keyboard/timing.js +56 -0
  346. package/dist/headless/electron/modules/human-input/mouse/path.js +79 -0
  347. package/dist/headless/electron/modules/human-input/mouse/velocity.js +92 -0
  348. package/dist/headless/electron/modules/human-input/profiles.js +123 -0
  349. package/dist/headless/electron/modules/human-input/rng.js +100 -0
  350. package/dist/headless/electron/modules/human-input/salt.js +47 -0
  351. package/dist/headless/electron/modules/image-utils.js +79 -0
  352. package/dist/headless/electron/modules/ollama/capability.js +116 -0
  353. package/dist/headless/electron/modules/ollama/client.js +133 -0
  354. package/dist/headless/electron/modules/ollama/detector.js +176 -0
  355. package/dist/headless/electron/modules/ollama/dispatcher.js +96 -0
  356. package/dist/headless/electron/modules/ollama/router.js +200 -0
  357. package/dist/headless/electron/modules/platform/dpi.js +47 -0
  358. package/dist/headless/electron/modules/platform/errors.js +35 -0
  359. package/dist/headless/electron/modules/platform/index.js +132 -0
  360. package/dist/headless/electron/modules/platform/interfaces.js +13 -0
  361. package/dist/headless/electron/modules/platform/macos/ax.js +221 -0
  362. package/dist/headless/electron/modules/platform/macos/capture.js +105 -0
  363. package/dist/headless/electron/modules/platform/macos/input.js +341 -0
  364. package/dist/headless/electron/modules/platform/macos/launch.js +113 -0
  365. package/dist/headless/electron/modules/platform/macos/session.js +16 -0
  366. package/dist/headless/electron/modules/platform/macos/window.js +270 -0
  367. package/dist/headless/electron/modules/platform/shared.js +200 -0
  368. package/dist/headless/electron/modules/platform/types.js +23 -0
  369. package/dist/headless/electron/modules/platform/windows/ax.js +276 -0
  370. package/dist/headless/electron/modules/platform/windows/capture.js +114 -0
  371. package/dist/headless/electron/modules/platform/windows/input.js +421 -0
  372. package/dist/headless/electron/modules/platform/windows/launch.js +184 -0
  373. package/dist/headless/electron/modules/platform/windows/session.js +86 -0
  374. package/dist/headless/electron/modules/platform/windows/tray.js +389 -0
  375. package/dist/headless/electron/modules/platform/windows/window.js +443 -0
  376. package/dist/headless/electron/modules/recording/providers/change-detect-shared-wrapper.js +61 -0
  377. package/dist/headless/electron/modules/recording/providers/provider-factory.js +13 -7
  378. package/dist/headless/electron/modules/scroll-calibration.js +270 -0
  379. package/dist/headless/electron/modules/sequence-locate.js +355 -0
  380. package/dist/headless/electron/modules/store.js +84 -58
  381. package/dist/headless/electron/modules/stt/capability-probe.js +330 -0
  382. package/dist/headless/electron/modules/stt/macos-engine.js +230 -0
  383. package/dist/headless/electron/modules/stt/model-manager.js +320 -0
  384. package/dist/headless/electron/modules/stt/router.js +231 -0
  385. package/dist/headless/electron/modules/stt/sherpa-engine.js +520 -0
  386. package/dist/headless/electron/modules/stt/types.js +15 -0
  387. package/dist/headless/electron/modules/stt/winrt-engine.js +237 -0
  388. package/dist/headless/electron/modules/template-match.js +204 -0
  389. package/dist/headless/electron/modules/undo-stack.js +40 -0
  390. package/dist/headless/electron/modules/watchers/active-window-watcher.js +151 -0
  391. package/dist/headless/electron/modules/watchers/clipboard-watcher.js +89 -0
  392. package/dist/headless/electron/modules/watchers/file-watcher.js +90 -0
  393. package/dist/headless/electron/modules/watchers/registry.js +107 -0
  394. package/dist/headless/electron/modules/watchers/screen-region-service.js +125 -0
  395. package/dist/headless/electron/modules/watchers/screen-region-watcher.js +69 -0
  396. package/dist/headless/electron/modules/window-activate.js +629 -0
  397. package/dist/headless/electron/modules/window-input.js +622 -0
  398. package/dist/headless/electron/modules/window-resolver.js +209 -0
  399. package/dist/headless/headless/cli.js +60 -7
  400. package/dist/headless/headless/config-cmd.js +306 -0
  401. package/dist/headless/headless/doctor.js +599 -0
  402. package/dist/headless/headless/ollama-cmd.js +211 -0
  403. package/dist/headless/headless/platform-headless.js +13 -1
  404. package/dist/headless/headless/server.js +38 -2
  405. package/dist/headless/headless/stt-cmd.js +213 -0
  406. package/dist/headless/headless/tui/index.mjs +7 -0
  407. package/dist/headless/headless/tui/plain-dump.js +41 -0
  408. package/dist/headless/headless/tui/settings-app.mjs +744 -0
  409. package/dist/headless/headless/tui/setup-wizard.mjs +257 -0
  410. package/dist/headless/headless/tui-bridge.js +80 -0
  411. package/dist/headless/shared/constants.js +3 -1
  412. package/dist/shared/constants.d.ts +2 -0
  413. package/dist/shared/constants.d.ts.map +1 -1
  414. package/dist/shared/constants.js +3 -1
  415. package/dist/shared/constants.js.map +1 -1
  416. package/dist/shared/types.d.ts +8 -0
  417. package/dist/shared/types.d.ts.map +1 -1
  418. package/mcp-server/dist/api-client.js +257 -6
  419. package/mcp-server/dist/index.js +1660 -61
  420. package/mcp-server/dist/project-sense.js +161 -0
  421. package/mcp-server/dist/tool-categories.js +161 -0
  422. package/mcp-server/package.json +8 -2
  423. package/package.json +33 -5
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+ // Shared calibration helpers for scrolling — extracted from scroll-capture.ts
3
+ // so both the auto-scroll-capture flow (long-page stitched screenshots) and
4
+ // superbased_scroll (agent-driven single-call scroll with atEnd signal) can
5
+ // share the pixel-correlation math, the duplicate-frame check, AND the
6
+ // Win32 wheel-event scroll (nut-js synthetic wheel events are dropped by
7
+ // many Electron / React scroll containers; real Win32 mouse_event is not).
8
+ //
9
+ // The pure math helpers (quickCompare, measurePixelOffset, constants) are
10
+ // reusable from any context. win32Scroll shells out to PowerShell and is
11
+ // Windows-only.
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.PAGE_SCROLL_OVERLAP = exports.MIN_STRIP_VARIANCE = exports.END_OF_CONTENT_SIMILARITY = void 0;
17
+ exports.quickCompare = quickCompare;
18
+ exports.stripVariance = stripVariance;
19
+ exports.measurePixelOffset = measurePixelOffset;
20
+ exports.buildStickyRowMask = buildStickyRowMask;
21
+ exports.win32Scroll = win32Scroll;
22
+ exports.win32HScroll = win32HScroll;
23
+ const child_process_1 = require("child_process");
24
+ const logger_1 = __importDefault(require("../logger"));
25
+ /**
26
+ * Fast similarity check between two byte buffers. Samples one byte every 200
27
+ * bytes and returns the ratio of matches (0..1). Used to detect
28
+ * end-of-content (subsequent capture identical to the previous frame) during
29
+ * scroll-capture stitching AND to flag `atEnd` for the agent after a
30
+ * superbased_scroll call.
31
+ *
32
+ * 0.95 is the canonical threshold — matches the auto-scroll-capture stop
33
+ * criterion. Above that: the viewport didn't change (likely hit end of
34
+ * scrollable content). Below: the scroll moved something.
35
+ *
36
+ * Note: PNG-compressed buffers won't be byte-identical for visually identical
37
+ * frames because the zlib stream can differ. quickCompare on raw PNGs is a
38
+ * best-effort signal; pair with a higher threshold (0.95+) to avoid false
39
+ * positives on compression jitter. For precise comparison, decode to raw
40
+ * pixels first.
41
+ */
42
+ function quickCompare(buf1, buf2) {
43
+ if (buf1.equals(buf2))
44
+ return 1.0;
45
+ const step = 200;
46
+ const len = Math.min(buf1.length, buf2.length);
47
+ let matches = 0;
48
+ let samples = 0;
49
+ for (let i = 0; i < len; i += step) {
50
+ samples++;
51
+ if (buf1[i] === buf2[i])
52
+ matches++;
53
+ }
54
+ return samples > 0 ? matches / samples : 0;
55
+ }
56
+ /**
57
+ * Default end-of-content threshold for quickCompare on PNG buffers. Shared
58
+ * between scroll-capture.ts and superbased_scroll's atEnd diagnostic.
59
+ */
60
+ exports.END_OF_CONTENT_SIMILARITY = 0.95;
61
+ /**
62
+ * Approximate stddev of a raw RGB(A) strip via every-Nth-byte sampling.
63
+ * Used to reject "solid color" strips from multi-strip correlation —
64
+ * a strip with no visual features will score 1.0 at offset=0 (pre == post
65
+ * == same-color) and falsely report "no movement" even when the rest of
66
+ * the window scrolled.
67
+ *
68
+ * Returns stddev on a 0..255 scale. Thresholds:
69
+ * - < 6 — effectively solid color (background column). Reject.
70
+ * - 6..12 — low texture (gradient, translucent panel). Risky; caller can decide.
71
+ * - > 12 — real content (text, icons, colored UI). Trust the correlation.
72
+ */
73
+ function stripVariance(strip, sampleStride = 20) {
74
+ let n = 0;
75
+ let sum = 0;
76
+ let sumSq = 0;
77
+ for (let i = 0; i < strip.length; i += sampleStride) {
78
+ const v = strip[i];
79
+ if (v === undefined)
80
+ continue;
81
+ sum += v;
82
+ sumSq += v * v;
83
+ n++;
84
+ }
85
+ if (n === 0)
86
+ return 0;
87
+ const mean = sum / n;
88
+ const variance = (sumSq / n) - (mean * mean);
89
+ return Math.sqrt(Math.max(0, variance));
90
+ }
91
+ /**
92
+ * Minimum stddev for a strip to be accepted into multi-strip correlation.
93
+ * Tuned against the user's round-3 trace where a solid-background strip
94
+ * pinned offset=0 and produced a false atEnd=true signal even though the
95
+ * textured strips had clear vertical movement.
96
+ */
97
+ exports.MIN_STRIP_VARIANCE = 8;
98
+ /**
99
+ * Pixel-correlation offset measurement: given raw RGB strips from a pre-scroll
100
+ * and post-scroll capture, find the vertical offset that best aligns them.
101
+ * Returns { offsetPx, score } — offsetPx is the number of pixels the content
102
+ * moved upward, score is the correlation confidence (0..1).
103
+ *
104
+ * Search range: offset ∈ [minOffset, maxSearch]. minOffset defaults to 0 so
105
+ * "no movement" (offset=0) can be detected as a high-score match — used by
106
+ * superbased_scroll's atEnd signal (if offset=0 scores high, the viewport
107
+ * didn't move = end of content). For calibration, the caller should set
108
+ * minOffset >= 10 to reject accidental high scores from static areas.
109
+ *
110
+ * Used by:
111
+ * - scroll-capture.ts calibrateScroll() — measures pixels-per-tick for
112
+ * the long-page stitched-screenshot flow.
113
+ * - gui-automation.ts calibratePixelsPerScroll() — same, for MCP
114
+ * superbased_scroll unit='page'.
115
+ * - gui-automation.ts scroll() atEnd detection — checks offset=0 match.
116
+ *
117
+ * stripHeight: rows in both strips (must match).
118
+ * stripWidth: columns in both strips (must match).
119
+ * channels: bytes per pixel (3 = RGB, 4 = RGBA).
120
+ * minOffset: smallest offset to test (default 0 — include no-movement case).
121
+ * maxSearchFraction: cap offset at this fraction of stripHeight (default 0.6).
122
+ * maxSearchCap: absolute pixel cap on the search range (default 500).
123
+ * The search range is `min(stripHeight × fraction, cap)`. Raise the cap
124
+ * for contexts that can legitimately see large scrolls (e.g. a
125
+ * 5-tick calibration scroll on Chrome 150% DPI with default wheel
126
+ * settings can move 750+ px; at the 500 default the measurement is
127
+ * truncated and reports a smaller-than-actual offset). Perf cost
128
+ * scales linearly with the cap.
129
+ * stickyRowMask: optional boolean[] of length stripHeight. Rows flagged
130
+ * `true` are skipped from scoring at every offset. Used to remove the
131
+ * contribution of fixed-position UI chrome (URL bar, cookie banners,
132
+ * floating overlays) from the correlation — without masking, static
133
+ * rows inflate offset=0's score because they byte-match at offset=0
134
+ * regardless of how much the rest of the strip scrolled.
135
+ */
136
+ function measurePixelOffset(strip1, strip2, opts) {
137
+ const { stripWidth, stripHeight, channels } = opts;
138
+ const rowBytes = stripWidth * channels;
139
+ const minOffset = Math.max(0, opts.minOffset ?? 0);
140
+ const maxSearch = Math.min(Math.round(stripHeight * (opts.maxSearchFraction ?? 0.6)), opts.maxSearchCap ?? 500);
141
+ const stickyRowMask = opts.stickyRowMask;
142
+ let bestOffset = minOffset;
143
+ let bestScore = 0;
144
+ for (let offset = minOffset; offset <= maxSearch; offset++) {
145
+ const compareRows = stripHeight - offset;
146
+ if (compareRows < 30)
147
+ break;
148
+ let matchSum = 0;
149
+ let totalSamples = 0;
150
+ for (let row = 0; row < compareRows; row += 2) {
151
+ // Skip rows known to be sticky (fixed-position chrome / overlays).
152
+ // Without this, sticky rows would contribute perfect matches at
153
+ // offset=0 and zero matches at offset>0, artificially biasing the
154
+ // score toward offset=0.
155
+ if (stickyRowMask && stickyRowMask[row])
156
+ continue;
157
+ const idx1Start = (row + offset) * rowBytes;
158
+ const idx2Start = row * rowBytes;
159
+ for (let b = 0; b < rowBytes; b += 3) {
160
+ const v1 = strip1[idx1Start + b];
161
+ const v2 = strip2[idx2Start + b];
162
+ if (v1 !== undefined && v2 !== undefined) {
163
+ totalSamples++;
164
+ if (Math.abs(v1 - v2) < 15)
165
+ matchSum++;
166
+ }
167
+ }
168
+ }
169
+ const score = totalSamples > 0 ? matchSum / totalSamples : 0;
170
+ if (score > bestScore) {
171
+ bestScore = score;
172
+ bestOffset = offset;
173
+ }
174
+ }
175
+ return { offsetPx: bestOffset, score: bestScore };
176
+ }
177
+ /**
178
+ * Build a per-row "sticky" mask from a strip pair. A row is flagged
179
+ * sticky when every byte at row index R is identical between strip1
180
+ * (pre-scroll) and strip2 (post-scroll) — i.e. the content at Y=R
181
+ * didn't move with the scroll. Typical examples: URL/tab bar, cookie
182
+ * banners, floating modals, footer widgets.
183
+ *
184
+ * Operates on raw pixel buffers (no compression jitter), so strict
185
+ * byte equality is the correct test. Fast: short-circuits on the first
186
+ * byte difference per row.
187
+ *
188
+ * Pass the returned mask to measurePixelOffset to exclude sticky rows
189
+ * from correlation scoring.
190
+ */
191
+ function buildStickyRowMask(strip1, strip2, stripWidth, stripHeight, channels) {
192
+ const rowBytes = stripWidth * channels;
193
+ const mask = new Array(stripHeight);
194
+ for (let row = 0; row < stripHeight; row++) {
195
+ const start = row * rowBytes;
196
+ let identical = true;
197
+ for (let i = 0; i < rowBytes; i++) {
198
+ if (strip1[start + i] !== strip2[start + i]) {
199
+ identical = false;
200
+ break;
201
+ }
202
+ }
203
+ mask[row] = identical;
204
+ }
205
+ return mask;
206
+ }
207
+ /**
208
+ * Scroll the window under the cursor via Win32 mouse_event. Each WHEEL_DELTA
209
+ * (120) = one "wheel click" — typically 3 text lines in most apps. Positive
210
+ * ticks = scroll DOWN, negative = scroll UP (matches nut-js conventions;
211
+ * we negate internally because Win32 signs WHEEL_DELTA upward).
212
+ *
213
+ * Why prefer this over nut-js: nut-js sends synthetic wheel events via
214
+ * SendInput. Many Electron / Chromium / React scroll containers have
215
+ * handlers that check `WheelEvent.isTrusted` or ignore synthetic events
216
+ * entirely, so the scroll no-ops silently. Win32 mouse_event bypasses
217
+ * SendInput and writes directly to the input queue — scrolls land.
218
+ *
219
+ * Shells out to PowerShell. ~100-200ms cold-start overhead per call. One
220
+ * call can scroll many ticks at once (Windows handles multi-tick wheel
221
+ * deltas natively), so batch when possible.
222
+ */
223
+ function win32Scroll(ticks) {
224
+ if (process.platform !== 'win32')
225
+ return false;
226
+ if (!Number.isFinite(ticks) || ticks === 0)
227
+ return false;
228
+ const delta = -Math.round(ticks) * 120;
229
+ const cmd = `powershell -NoProfile -Command "Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;public class M{[DllImport(\\\"user32.dll\\\")]public static extern void mouse_event(uint f,int x,int y,int d,int e);public const uint W=0x0800;}';[M]::mouse_event([M]::W,0,0,${delta},0)"`;
230
+ try {
231
+ (0, child_process_1.execSync)(cmd, { windowsHide: true, timeout: 3000, stdio: 'pipe' });
232
+ return true;
233
+ }
234
+ catch (err) {
235
+ logger_1.default.warn('[scroll-calibration] win32Scroll failed:', err);
236
+ return false;
237
+ }
238
+ }
239
+ /**
240
+ * 2.5 — horizontal wheel via MOUSEEVENTF_HWHEEL (0x01000). Distinct from
241
+ * Shift+Wheel — apps like Excel / Chromium distinguish real HWheel from
242
+ * modified vertical wheel, and only the real HWheel path routes through
243
+ * the horizontal scroll bar consistently. Positive ticks = scroll RIGHT,
244
+ * negative = scroll LEFT (Windows signs HWHEEL_DELTA rightward; we keep
245
+ * the same convention as win32Scroll's down-positive to match our API).
246
+ *
247
+ * Same shell-out + cost profile as win32Scroll (~100-200ms cold-start).
248
+ */
249
+ function win32HScroll(ticks) {
250
+ if (process.platform !== 'win32')
251
+ return false;
252
+ if (!Number.isFinite(ticks) || ticks === 0)
253
+ return false;
254
+ const delta = Math.round(ticks) * 120;
255
+ const cmd = `powershell -NoProfile -Command "Add-Type -TypeDefinition 'using System;using System.Runtime.InteropServices;public class M{[DllImport(\\\"user32.dll\\\")]public static extern void mouse_event(uint f,int x,int y,int d,int e);public const uint H=0x01000;}';[M]::mouse_event([M]::H,0,0,${delta},0)"`;
256
+ try {
257
+ (0, child_process_1.execSync)(cmd, { windowsHide: true, timeout: 3000, stdio: 'pipe' });
258
+ return true;
259
+ }
260
+ catch (err) {
261
+ logger_1.default.warn('[scroll-calibration] win32HScroll failed:', err);
262
+ return false;
263
+ }
264
+ }
265
+ /**
266
+ * Default overlap fraction used by both scroll-capture's stitched flow AND
267
+ * superbased_scroll's unit='page' calculation. 10% overlap gives the
268
+ * redundancy the stitch needs while keeping per-page movement predictable.
269
+ */
270
+ exports.PAGE_SCROLL_OVERLAP = 0.10;
@@ -0,0 +1,355 @@
1
+ "use strict";
2
+ // Step-time target resolution for sequences — the core of design principle 3
3
+ // (step-time target resolution) and principle 11 (reliability pyramid for
4
+ // locators). See GUI_AUTOMATION_ROADMAP.md §0.2 / §0.3.
5
+ //
6
+ // Scope in this commit (0.1–0.3):
7
+ // - LocateSpec type (reliability pyramid: automationId → role+name → label →
8
+ // imageTemplate → pixelColor → relative)
9
+ // - LocateCache: single ui_dump at sequence entry, 1000ms TTL, explicit
10
+ // refreshLocate invalidation, state-changing step auto-invalidation
11
+ // - resolveLocate: automationId / role+name / label / relative implemented;
12
+ // imageTemplate (S4) and pixelColor (S2) return UNSUPPORTED_YET stubs
13
+ // - Pre-click AX verify hook (called before every coord-requiring step when
14
+ // the cached element carries an automationId)
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ var __importDefault = (this && this.__importDefault) || function (mod) {
49
+ return (mod && mod.__esModule) ? mod : { "default": mod };
50
+ };
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.LocateError = exports.LocateCache = void 0;
53
+ exports.isStateChangingHotkey = isStateChangingHotkey;
54
+ exports.isStateChangingAction = isStateChangingAction;
55
+ exports.resolveLocate = resolveLocate;
56
+ exports.verifyCachedCoord = verifyCachedCoord;
57
+ const logger_1 = __importDefault(require("../logger"));
58
+ const platform_1 = require("./platform");
59
+ class LocateCache {
60
+ ttlMs;
61
+ dumpFn;
62
+ byTarget = new Map();
63
+ constructor(opts) {
64
+ this.ttlMs = opts.ttlMs ?? 1000;
65
+ this.dumpFn = opts.dumpFn;
66
+ }
67
+ /** Fetch a (possibly fresh) cache entry for the target. Refreshes on TTL expiry. */
68
+ async get(handle) {
69
+ const key = handle ?? '__fullscreen__';
70
+ const cached = this.byTarget.get(key);
71
+ const now = Date.now();
72
+ if (cached && now - cached.dumpedAtMs < this.ttlMs)
73
+ return cached;
74
+ const fresh = await this.dumpFn(handle);
75
+ const entry = { ...fresh, dumpedAtMs: now };
76
+ this.byTarget.set(key, entry);
77
+ return entry;
78
+ }
79
+ /** Force a re-dump next time get() is called for this handle. */
80
+ invalidate(handle) {
81
+ const key = handle ?? '__fullscreen__';
82
+ this.byTarget.delete(key);
83
+ }
84
+ /** Nuke every target's cache (e.g. on resize_window or window_state across any target). */
85
+ invalidateAll() {
86
+ this.byTarget.clear();
87
+ }
88
+ }
89
+ exports.LocateCache = LocateCache;
90
+ // ── State-changing hotkey combos that auto-invalidate the locate cache ──
91
+ // Rule 7 from design principles — we allow narrow, predictable auto-invalidation.
92
+ const STATE_CHANGING_COMBOS = new Set([
93
+ 'ctrl+s',
94
+ 'cmd+s',
95
+ 'ctrl+o',
96
+ 'cmd+o',
97
+ 'ctrl+n',
98
+ 'cmd+n',
99
+ 'ctrl+r',
100
+ 'cmd+r',
101
+ 'ctrl+t',
102
+ 'cmd+t',
103
+ 'ctrl+w',
104
+ 'cmd+w',
105
+ 'ctrl+tab',
106
+ 'ctrl+shift+tab',
107
+ 'cmd+tab',
108
+ 'f5',
109
+ 'alt+f4',
110
+ ].map((s) => s.toLowerCase()));
111
+ function isStateChangingHotkey(combo) {
112
+ return STATE_CHANGING_COMBOS.has(combo.trim().toLowerCase());
113
+ }
114
+ /**
115
+ * True when the given action has inherent UI-layout impact such that any
116
+ * locate cache entry for the affected target should be invalidated BEFORE
117
+ * subsequent steps run. Called by the sequence runner between steps.
118
+ */
119
+ function isStateChangingAction(action) {
120
+ // 4.1 — ax_invoke reshapes UI in most cases (Toggle flips state, Expand/
121
+ // Collapse reveals/hides children, SelectionItem.Select rebuilds a list).
122
+ // Flagging it here invalidates the locate cache after the step so the next
123
+ // locate step re-dumps. Invoke and Value.SetValue can also shift focus,
124
+ // which is equivalent; conservative default is the safer choice.
125
+ return action === 'resize_window' || action === 'window_state' || action === 'context_menu_select' || action === 'ax_invoke';
126
+ }
127
+ /**
128
+ * Resolve a LocateSpec to virtual-screen coords. Pyramid rung order is
129
+ * explicit per spec rule — no implicit fallback to lower rungs unless the
130
+ * caller sets `fallback: 'cascade'` on an `automationId` spec.
131
+ */
132
+ async function resolveLocate(spec, ctx) {
133
+ if ('automationId' in spec) {
134
+ return resolveByAutomationId(spec.automationId, spec.fallback ?? 'strict', ctx);
135
+ }
136
+ if ('role' in spec) {
137
+ return resolveByRoleAndName(spec.role, spec.name, spec.caseSensitive ?? false, ctx);
138
+ }
139
+ if ('label' in spec) {
140
+ return resolveByLabel(spec.label, spec.caseSensitive ?? false, ctx);
141
+ }
142
+ if ('relative' in spec) {
143
+ return resolveByRelative(spec.relative, ctx);
144
+ }
145
+ if ('imageTemplate' in spec) {
146
+ return resolveByImageTemplate(spec.imageTemplate, spec.threshold, spec.region, spec.ignoreDpiScale, spec.ignoreTheme);
147
+ }
148
+ if ('pixelColor' in spec) {
149
+ return resolveByPixelColor(spec.pixelColor, spec.near);
150
+ }
151
+ throw new LocateError('LOCATE_NO_MATCH', `unknown locate spec: ${JSON.stringify(spec)}`);
152
+ }
153
+ async function resolveByAutomationId(id, fallback, ctx) {
154
+ if (!ctx.handle) {
155
+ throw new LocateError('LOCATE_NO_MATCH', 'automationId requires a target handle — pass targets[] + defaultTarget or window/processName');
156
+ }
157
+ try {
158
+ const node = await platform_1.platform.accessibility.findByAutomationId(ctx.handle, id);
159
+ if (node?.frame) {
160
+ return {
161
+ x: node.frame.x + node.frame.width / 2,
162
+ y: node.frame.y + node.frame.height / 2,
163
+ rung: 'automationId',
164
+ bbox: { ...node.frame },
165
+ automationId: id,
166
+ role: node.role,
167
+ };
168
+ }
169
+ }
170
+ catch (err) {
171
+ logger_1.default.warn('[sequence-locate] automationId lookup failed:', err.message);
172
+ }
173
+ if (fallback === 'strict') {
174
+ throw new LocateError('LOCATE_NO_MATCH', `automationId="${id}" not found`);
175
+ }
176
+ // Cascade: fall through to role/label by checking the cached ui_dump.
177
+ throw new LocateError('LOCATE_NO_MATCH', `automationId="${id}" not found (cascade fallback not yet populated — ship in 0.10)`);
178
+ }
179
+ async function resolveByRoleAndName(role, name, caseSensitive, ctx) {
180
+ if (!ctx.handle) {
181
+ throw new LocateError('LOCATE_NO_MATCH', 'role+name requires a target handle');
182
+ }
183
+ try {
184
+ const node = await platform_1.platform.accessibility.findByRoleAndName(ctx.handle, role, name, { caseSensitive });
185
+ if (node?.frame) {
186
+ return {
187
+ x: node.frame.x + node.frame.width / 2,
188
+ y: node.frame.y + node.frame.height / 2,
189
+ rung: 'role+name',
190
+ bbox: { ...node.frame },
191
+ role: node.role,
192
+ };
193
+ }
194
+ }
195
+ catch (err) {
196
+ logger_1.default.warn('[sequence-locate] role+name lookup failed:', err.message);
197
+ }
198
+ throw new LocateError('LOCATE_NO_MATCH', `role="${role}" name="${name}" not found`);
199
+ }
200
+ async function resolveByLabel(label, caseSensitive, ctx) {
201
+ const entry = await ctx.cache.get(ctx.handle);
202
+ const norm = (s) => (caseSensitive ? s : s.toLowerCase());
203
+ const needle = norm(label);
204
+ const candidates = entry.textElements.filter((el) => norm(el.text) === needle);
205
+ if (candidates.length === 0) {
206
+ // Substring fallback — bounded by confidence tie-break.
207
+ const subs = entry.textElements.filter((el) => norm(el.text).includes(needle));
208
+ if (subs.length === 0) {
209
+ throw new LocateError('LOCATE_NO_MATCH', `label="${label}" not visible in cached ui_dump`);
210
+ }
211
+ if (subs.length > 1) {
212
+ const top = subs.sort((a, b) => b.confidence - a.confidence);
213
+ const [first, second] = top;
214
+ if (second && Math.abs(first.confidence - second.confidence) < 0.1) {
215
+ throw new LocateError('LOCATE_AMBIGUOUS', `label="${label}" matches ${subs.length} elements; narrow with role+name or automationId`);
216
+ }
217
+ }
218
+ const hit = subs[0];
219
+ return {
220
+ x: hit.center.x,
221
+ y: hit.center.y,
222
+ rung: 'label',
223
+ bbox: { ...hit.bbox },
224
+ };
225
+ }
226
+ if (candidates.length > 1) {
227
+ throw new LocateError('LOCATE_AMBIGUOUS', `label="${label}" matches ${candidates.length} elements; narrow with role+name or automationId`);
228
+ }
229
+ const hit = candidates[0];
230
+ return {
231
+ x: hit.center.x,
232
+ y: hit.center.y,
233
+ rung: 'label',
234
+ bbox: { ...hit.bbox },
235
+ };
236
+ }
237
+ // ── 2.4 locate.pixelColor ──
238
+ //
239
+ // Minimal semantics: read the pixel AT `near` (virtual-screen coords) and
240
+ // return it if it matches the expected #RRGGBB hex. No scanning / spiral —
241
+ // a full "find the nearest pixel of this color" scan would be costly and
242
+ // rarely what agents actually want (the common use is "check this specific
243
+ // point is the right color"). Callers who need area scanning should use
244
+ // find_image (3.5) or pixel_color + a manual loop.
245
+ function parsePixelColorHex(hex) {
246
+ const h = hex.trim().replace(/^#/, '');
247
+ if (h.length !== 6 && h.length !== 8)
248
+ return null;
249
+ const r = parseInt(h.slice(0, 2), 16);
250
+ const g = parseInt(h.slice(2, 4), 16);
251
+ const b = parseInt(h.slice(4, 6), 16);
252
+ if ([r, g, b].some((n) => Number.isNaN(n)))
253
+ return null;
254
+ return { r, g, b };
255
+ }
256
+ // ── 3.5 locate.imageTemplate ──
257
+ //
258
+ // Routes through findImage() so the tool + the sequence locate resolver share
259
+ // one code path (metadata guards, NCC, scaling). The standalone tool exposes
260
+ // more knobs (multi / maxMatches); the resolver returns the top match only,
261
+ // since the caller is asking "where is this element" (singular). A zero-match
262
+ // or metadata-refusal surfaces as `LOCATE_NO_MATCH` — agents can branch on
263
+ // that errorCode and fall back to a lower pyramid rung.
264
+ async function resolveByImageTemplate(templatePath, threshold, region, ignoreDpiScale, ignoreTheme) {
265
+ const { findImage } = await Promise.resolve().then(() => __importStar(require('./gui-automation')));
266
+ const result = await findImage({
267
+ templatePath,
268
+ threshold,
269
+ region,
270
+ ignoreDpiScale,
271
+ ignoreTheme,
272
+ multi: false,
273
+ // Sequences run inside an already-approved window; re-gating at locate
274
+ // time would double-prompt. Pass confirm:true + a fake caller to clear
275
+ // the gate the same way inner sequence steps do.
276
+ confirm: true,
277
+ caller: 'sequence-locate',
278
+ });
279
+ if (!result.ok) {
280
+ throw new LocateError(result.errorCode === 'LOCATE_NO_MATCH' ? 'LOCATE_NO_MATCH' : 'LOCATE_NO_MATCH', result.error ?? `imageTemplate "${templatePath}" not found`);
281
+ }
282
+ const details = result.details;
283
+ const top = details?.matches?.[0];
284
+ if (!top) {
285
+ throw new LocateError('LOCATE_NO_MATCH', `imageTemplate "${templatePath}" returned no matches`);
286
+ }
287
+ return {
288
+ x: top.center.x,
289
+ y: top.center.y,
290
+ rung: 'imageTemplate',
291
+ bbox: { x: top.x, y: top.y, width: top.width, height: top.height },
292
+ };
293
+ }
294
+ async function resolveByPixelColor(expected, near) {
295
+ const want = parsePixelColorHex(expected);
296
+ if (!want) {
297
+ throw new LocateError('LOCATE_NO_MATCH', `pixelColor expected="${expected}" — use #RRGGBB`);
298
+ }
299
+ try {
300
+ const rgba = await platform_1.platform.capture.readPixel(near.x, near.y);
301
+ if (rgba.r === want.r && rgba.g === want.g && rgba.b === want.b) {
302
+ return { x: near.x, y: near.y, rung: 'pixelColor' };
303
+ }
304
+ throw new LocateError('LOCATE_NO_MATCH', `pixelColor at (${near.x}, ${near.y}) was ${rgba.hex}, expected ${expected}`);
305
+ }
306
+ catch (err) {
307
+ if (err instanceof LocateError)
308
+ throw err;
309
+ const msg = err.message ?? String(err);
310
+ throw new LocateError('LOCATE_NO_MATCH', `pixelColor read failed: ${msg}`);
311
+ }
312
+ }
313
+ function resolveByRelative(spec, ctx) {
314
+ const anchor = ctx.history.get(spec.to);
315
+ if (!anchor) {
316
+ throw new LocateError('LOCATE_NO_MATCH', `relative.to="${spec.to}" — no prior step with that name produced coords`);
317
+ }
318
+ return {
319
+ x: anchor.center.x + spec.dx,
320
+ y: anchor.center.y + spec.dy,
321
+ rung: 'relative',
322
+ };
323
+ }
324
+ // ── Pre-click AX verify ──
325
+ //
326
+ // Called by the sequence runner before executing a coord-producing step whose
327
+ // cached locate had an automationId. If the automationId no longer resolves to
328
+ // the expected bbox, the cache is stale — the runner invalidates and retries
329
+ // once before raising LOCATE_NO_MATCH.
330
+ async function verifyCachedCoord(handle, previous) {
331
+ if (!handle || !previous.automationId)
332
+ return true;
333
+ try {
334
+ const node = await platform_1.platform.accessibility.findByAutomationId(handle, previous.automationId);
335
+ if (!node?.frame || !previous.bbox)
336
+ return true; // best-effort; don't block on missing frame data
337
+ const cx = node.frame.x + node.frame.width / 2;
338
+ const cy = node.frame.y + node.frame.height / 2;
339
+ // Accept if center is within the previous bbox (tolerates minor relayout).
340
+ return Math.abs(cx - previous.x) <= previous.bbox.width / 2 + 4 &&
341
+ Math.abs(cy - previous.y) <= previous.bbox.height / 2 + 4;
342
+ }
343
+ catch {
344
+ return true; // verify is best-effort — don't false-positive an invalidation
345
+ }
346
+ }
347
+ class LocateError extends Error {
348
+ code;
349
+ constructor(code, message) {
350
+ super(message);
351
+ this.name = 'LocateError';
352
+ this.code = code;
353
+ }
354
+ }
355
+ exports.LocateError = LocateError;