@mseep/clawdcursor 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/CHANGELOG.md +2264 -0
  2. package/LICENSE +21 -0
  3. package/README.md +385 -0
  4. package/SECURITY.md +44 -0
  5. package/SKILL.md +503 -0
  6. package/dist/core/agent-loop/agent.d.ts +42 -0
  7. package/dist/core/agent-loop/agent.js +1023 -0
  8. package/dist/core/agent-loop/agent.js.map +1 -0
  9. package/dist/core/agent-loop/batch-tool.d.ts +25 -0
  10. package/dist/core/agent-loop/batch-tool.js +218 -0
  11. package/dist/core/agent-loop/batch-tool.js.map +1 -0
  12. package/dist/core/agent-loop/coord-scale.d.ts +72 -0
  13. package/dist/core/agent-loop/coord-scale.js +89 -0
  14. package/dist/core/agent-loop/coord-scale.js.map +1 -0
  15. package/dist/core/agent-loop/focus-guard.d.ts +24 -0
  16. package/dist/core/agent-loop/focus-guard.js +29 -0
  17. package/dist/core/agent-loop/focus-guard.js.map +1 -0
  18. package/dist/core/agent-loop/project-mcp.d.ts +97 -0
  19. package/dist/core/agent-loop/project-mcp.js +253 -0
  20. package/dist/core/agent-loop/project-mcp.js.map +1 -0
  21. package/dist/core/agent-loop/prompt.d.ts +45 -0
  22. package/dist/core/agent-loop/prompt.js +426 -0
  23. package/dist/core/agent-loop/prompt.js.map +1 -0
  24. package/dist/core/agent-loop/tool-meta.d.ts +93 -0
  25. package/dist/core/agent-loop/tool-meta.js +651 -0
  26. package/dist/core/agent-loop/tool-meta.js.map +1 -0
  27. package/dist/core/agent-loop/tools.d.ts +38 -0
  28. package/dist/core/agent-loop/tools.js +2134 -0
  29. package/dist/core/agent-loop/tools.js.map +1 -0
  30. package/dist/core/agent-loop/types.d.ts +170 -0
  31. package/dist/core/agent-loop/types.js +12 -0
  32. package/dist/core/agent-loop/types.js.map +1 -0
  33. package/dist/core/agent.d.ts +51 -0
  34. package/dist/core/agent.js +245 -0
  35. package/dist/core/agent.js.map +1 -0
  36. package/dist/core/app-categories.d.ts +67 -0
  37. package/dist/core/app-categories.js +108 -0
  38. package/dist/core/app-categories.js.map +1 -0
  39. package/dist/core/banner.d.ts +70 -0
  40. package/dist/core/banner.js +245 -0
  41. package/dist/core/banner.js.map +1 -0
  42. package/dist/core/classify/capability.d.ts +45 -0
  43. package/dist/core/classify/capability.js +78 -0
  44. package/dist/core/classify/capability.js.map +1 -0
  45. package/dist/core/decompose/llm-decomposer.d.ts +35 -0
  46. package/dist/core/decompose/llm-decomposer.js +156 -0
  47. package/dist/core/decompose/llm-decomposer.js.map +1 -0
  48. package/dist/core/decompose/parser.d.ts +27 -0
  49. package/dist/core/decompose/parser.js +101 -0
  50. package/dist/core/decompose/parser.js.map +1 -0
  51. package/dist/core/observability/correlation.d.ts +19 -0
  52. package/dist/core/observability/correlation.js +36 -0
  53. package/dist/core/observability/correlation.js.map +1 -0
  54. package/dist/core/observability/cost-meter.d.ts +51 -0
  55. package/dist/core/observability/cost-meter.js +134 -0
  56. package/dist/core/observability/cost-meter.js.map +1 -0
  57. package/dist/core/observability/logger.d.ts +61 -0
  58. package/dist/core/observability/logger.js +550 -0
  59. package/dist/core/observability/logger.js.map +1 -0
  60. package/dist/core/router/aliases.d.ts +50 -0
  61. package/dist/core/router/aliases.js +104 -0
  62. package/dist/core/router/aliases.js.map +1 -0
  63. package/dist/core/router/normalize.d.ts +41 -0
  64. package/dist/core/router/normalize.js +80 -0
  65. package/dist/core/router/normalize.js.map +1 -0
  66. package/dist/core/safety.d.ts +126 -0
  67. package/dist/core/safety.js +568 -0
  68. package/dist/core/safety.js.map +1 -0
  69. package/dist/core/sense/a11y-resolver.d.ts +73 -0
  70. package/dist/core/sense/a11y-resolver.js +76 -0
  71. package/dist/core/sense/a11y-resolver.js.map +1 -0
  72. package/dist/core/sense/fingerprint.d.ts +41 -0
  73. package/dist/core/sense/fingerprint.js +123 -0
  74. package/dist/core/sense/fingerprint.js.map +1 -0
  75. package/dist/core/sense/rank.d.ts +70 -0
  76. package/dist/core/sense/rank.js +192 -0
  77. package/dist/core/sense/rank.js.map +1 -0
  78. package/dist/core/sense/reactive-check.d.ts +40 -0
  79. package/dist/core/sense/reactive-check.js +48 -0
  80. package/dist/core/sense/reactive-check.js.map +1 -0
  81. package/dist/core/sense/snapshot.d.ts +19 -0
  82. package/dist/core/sense/snapshot.js +100 -0
  83. package/dist/core/sense/snapshot.js.map +1 -0
  84. package/dist/core/sense/types.d.ts +66 -0
  85. package/dist/core/sense/types.js +9 -0
  86. package/dist/core/sense/types.js.map +1 -0
  87. package/dist/core/sense/ui-map-anchors.d.ts +7 -0
  88. package/dist/core/sense/ui-map-anchors.js +24 -0
  89. package/dist/core/sense/ui-map-anchors.js.map +1 -0
  90. package/dist/core/sense/ui-map-elements.d.ts +5 -0
  91. package/dist/core/sense/ui-map-elements.js +33 -0
  92. package/dist/core/sense/ui-map-elements.js.map +1 -0
  93. package/dist/core/sense/ui-map-find.d.ts +56 -0
  94. package/dist/core/sense/ui-map-find.js +153 -0
  95. package/dist/core/sense/ui-map-find.js.map +1 -0
  96. package/dist/core/sense/ui-map-fuse.d.ts +4 -0
  97. package/dist/core/sense/ui-map-fuse.js +44 -0
  98. package/dist/core/sense/ui-map-fuse.js.map +1 -0
  99. package/dist/core/sense/ui-map-geom.d.ts +3 -0
  100. package/dist/core/sense/ui-map-geom.js +16 -0
  101. package/dist/core/sense/ui-map-geom.js.map +1 -0
  102. package/dist/core/sense/ui-map-holder.d.ts +58 -0
  103. package/dist/core/sense/ui-map-holder.js +87 -0
  104. package/dist/core/sense/ui-map-holder.js.map +1 -0
  105. package/dist/core/sense/ui-map-normalize.d.ts +19 -0
  106. package/dist/core/sense/ui-map-normalize.js +65 -0
  107. package/dist/core/sense/ui-map-normalize.js.map +1 -0
  108. package/dist/core/sense/ui-map-render.d.ts +4 -0
  109. package/dist/core/sense/ui-map-render.js +34 -0
  110. package/dist/core/sense/ui-map-render.js.map +1 -0
  111. package/dist/core/sense/ui-map-resolve.d.ts +41 -0
  112. package/dist/core/sense/ui-map-resolve.js +59 -0
  113. package/dist/core/sense/ui-map-resolve.js.map +1 -0
  114. package/dist/core/sense/ui-map-types.d.ts +66 -0
  115. package/dist/core/sense/ui-map-types.js +11 -0
  116. package/dist/core/sense/ui-map-types.js.map +1 -0
  117. package/dist/core/sense/ui-map.d.ts +29 -0
  118. package/dist/core/sense/ui-map.js +113 -0
  119. package/dist/core/sense/ui-map.js.map +1 -0
  120. package/dist/core/verify/assertions.d.ts +132 -0
  121. package/dist/core/verify/assertions.js +284 -0
  122. package/dist/core/verify/assertions.js.map +1 -0
  123. package/dist/index.d.ts +21 -0
  124. package/dist/index.js +24 -0
  125. package/dist/index.js.map +1 -0
  126. package/dist/llm/browser-config.d.ts +36 -0
  127. package/dist/llm/browser-config.js +83 -0
  128. package/dist/llm/browser-config.js.map +1 -0
  129. package/dist/llm/client.d.ts +268 -0
  130. package/dist/llm/client.js +1094 -0
  131. package/dist/llm/client.js.map +1 -0
  132. package/dist/llm/config.d.ts +79 -0
  133. package/dist/llm/config.js +375 -0
  134. package/dist/llm/config.js.map +1 -0
  135. package/dist/llm/credentials.d.ts +35 -0
  136. package/dist/llm/credentials.js +491 -0
  137. package/dist/llm/credentials.js.map +1 -0
  138. package/dist/llm/external-creds.d.ts +42 -0
  139. package/dist/llm/external-creds.js +169 -0
  140. package/dist/llm/external-creds.js.map +1 -0
  141. package/dist/llm/providers.d.ts +123 -0
  142. package/dist/llm/providers.js +717 -0
  143. package/dist/llm/providers.js.map +1 -0
  144. package/dist/paths.d.ts +31 -0
  145. package/dist/paths.js +147 -0
  146. package/dist/paths.js.map +1 -0
  147. package/dist/platform/accessibility.d.ts +139 -0
  148. package/dist/platform/accessibility.js +670 -0
  149. package/dist/platform/accessibility.js.map +1 -0
  150. package/dist/platform/cdp-driver.d.ts +318 -0
  151. package/dist/platform/cdp-driver.js +1179 -0
  152. package/dist/platform/cdp-driver.js.map +1 -0
  153. package/dist/platform/index.d.ts +11 -0
  154. package/dist/platform/index.js +69 -0
  155. package/dist/platform/index.js.map +1 -0
  156. package/dist/platform/keys.d.ts +17 -0
  157. package/dist/platform/keys.js +129 -0
  158. package/dist/platform/keys.js.map +1 -0
  159. package/dist/platform/launch-poll.d.ts +101 -0
  160. package/dist/platform/launch-poll.js +177 -0
  161. package/dist/platform/launch-poll.js.map +1 -0
  162. package/dist/platform/linux.d.ts +173 -0
  163. package/dist/platform/linux.js +1253 -0
  164. package/dist/platform/linux.js.map +1 -0
  165. package/dist/platform/macos.d.ts +136 -0
  166. package/dist/platform/macos.js +976 -0
  167. package/dist/platform/macos.js.map +1 -0
  168. package/dist/platform/native-desktop.d.ts +145 -0
  169. package/dist/platform/native-desktop.js +936 -0
  170. package/dist/platform/native-desktop.js.map +1 -0
  171. package/dist/platform/native-helper.d.ts +130 -0
  172. package/dist/platform/native-helper.js +592 -0
  173. package/dist/platform/native-helper.js.map +1 -0
  174. package/dist/platform/ocr-engine.d.ts +78 -0
  175. package/dist/platform/ocr-engine.js +363 -0
  176. package/dist/platform/ocr-engine.js.map +1 -0
  177. package/dist/platform/ps-runner.d.ts +28 -0
  178. package/dist/platform/ps-runner.js +228 -0
  179. package/dist/platform/ps-runner.js.map +1 -0
  180. package/dist/platform/types.d.ts +397 -0
  181. package/dist/platform/types.js +15 -0
  182. package/dist/platform/types.js.map +1 -0
  183. package/dist/platform/uri-handler.d.ts +75 -0
  184. package/dist/platform/uri-handler.js +273 -0
  185. package/dist/platform/uri-handler.js.map +1 -0
  186. package/dist/platform/wayland-backend.d.ts +53 -0
  187. package/dist/platform/wayland-backend.js +348 -0
  188. package/dist/platform/wayland-backend.js.map +1 -0
  189. package/dist/platform/windows.d.ts +232 -0
  190. package/dist/platform/windows.js +1210 -0
  191. package/dist/platform/windows.js.map +1 -0
  192. package/dist/postbuild.d.ts +10 -0
  193. package/dist/postbuild.js +98 -0
  194. package/dist/postbuild.js.map +1 -0
  195. package/dist/schema/snapshot.d.ts +33 -0
  196. package/dist/schema/snapshot.js +90 -0
  197. package/dist/schema/snapshot.js.map +1 -0
  198. package/dist/shortcuts.d.ts +30 -0
  199. package/dist/shortcuts.js +261 -0
  200. package/dist/shortcuts.js.map +1 -0
  201. package/dist/surface/cli.d.ts +7 -0
  202. package/dist/surface/cli.js +1556 -0
  203. package/dist/surface/cli.js.map +1 -0
  204. package/dist/surface/dashboard.d.ts +8 -0
  205. package/dist/surface/dashboard.js +1193 -0
  206. package/dist/surface/dashboard.js.map +1 -0
  207. package/dist/surface/doctor.d.ts +29 -0
  208. package/dist/surface/doctor.js +1514 -0
  209. package/dist/surface/doctor.js.map +1 -0
  210. package/dist/surface/format.d.ts +10 -0
  211. package/dist/surface/format.js +37 -0
  212. package/dist/surface/format.js.map +1 -0
  213. package/dist/surface/http-utility.d.ts +65 -0
  214. package/dist/surface/http-utility.js +336 -0
  215. package/dist/surface/http-utility.js.map +1 -0
  216. package/dist/surface/mcp-server.d.ts +91 -0
  217. package/dist/surface/mcp-server.js +280 -0
  218. package/dist/surface/mcp-server.js.map +1 -0
  219. package/dist/surface/onboarding.d.ts +15 -0
  220. package/dist/surface/onboarding.js +184 -0
  221. package/dist/surface/onboarding.js.map +1 -0
  222. package/dist/surface/pidfile.d.ts +79 -0
  223. package/dist/surface/pidfile.js +263 -0
  224. package/dist/surface/pidfile.js.map +1 -0
  225. package/dist/surface/readiness.d.ts +45 -0
  226. package/dist/surface/readiness.js +230 -0
  227. package/dist/surface/readiness.js.map +1 -0
  228. package/dist/surface/report.d.ts +68 -0
  229. package/dist/surface/report.js +341 -0
  230. package/dist/surface/report.js.map +1 -0
  231. package/dist/surface/skill-register.d.ts +14 -0
  232. package/dist/surface/skill-register.js +150 -0
  233. package/dist/surface/skill-register.js.map +1 -0
  234. package/dist/surface/version.d.ts +6 -0
  235. package/dist/surface/version.js +27 -0
  236. package/dist/surface/version.js.map +1 -0
  237. package/dist/tools/a11y.d.ts +8 -0
  238. package/dist/tools/a11y.js +545 -0
  239. package/dist/tools/a11y.js.map +1 -0
  240. package/dist/tools/a11y_depth.d.ts +19 -0
  241. package/dist/tools/a11y_depth.js +455 -0
  242. package/dist/tools/a11y_depth.js.map +1 -0
  243. package/dist/tools/agent.d.ts +15 -0
  244. package/dist/tools/agent.js +248 -0
  245. package/dist/tools/agent.js.map +1 -0
  246. package/dist/tools/batch.d.ts +46 -0
  247. package/dist/tools/batch.js +230 -0
  248. package/dist/tools/batch.js.map +1 -0
  249. package/dist/tools/cdp.d.ts +8 -0
  250. package/dist/tools/cdp.js +233 -0
  251. package/dist/tools/cdp.js.map +1 -0
  252. package/dist/tools/compact.d.ts +63 -0
  253. package/dist/tools/compact.js +418 -0
  254. package/dist/tools/compact.js.map +1 -0
  255. package/dist/tools/cost-class.d.ts +38 -0
  256. package/dist/tools/cost-class.js +117 -0
  257. package/dist/tools/cost-class.js.map +1 -0
  258. package/dist/tools/desktop.d.ts +9 -0
  259. package/dist/tools/desktop.js +346 -0
  260. package/dist/tools/desktop.js.map +1 -0
  261. package/dist/tools/electron_bridge.d.ts +41 -0
  262. package/dist/tools/electron_bridge.js +261 -0
  263. package/dist/tools/electron_bridge.js.map +1 -0
  264. package/dist/tools/extras.d.ts +22 -0
  265. package/dist/tools/extras.js +942 -0
  266. package/dist/tools/extras.js.map +1 -0
  267. package/dist/tools/favorites.d.ts +13 -0
  268. package/dist/tools/favorites.js +137 -0
  269. package/dist/tools/favorites.js.map +1 -0
  270. package/dist/tools/introspection.d.ts +13 -0
  271. package/dist/tools/introspection.js +55 -0
  272. package/dist/tools/introspection.js.map +1 -0
  273. package/dist/tools/ocr.d.ts +8 -0
  274. package/dist/tools/ocr.js +66 -0
  275. package/dist/tools/ocr.js.map +1 -0
  276. package/dist/tools/orchestration.d.ts +7 -0
  277. package/dist/tools/orchestration.js +377 -0
  278. package/dist/tools/orchestration.js.map +1 -0
  279. package/dist/tools/playbooks/extract-compose.d.ts +22 -0
  280. package/dist/tools/playbooks/extract-compose.js +85 -0
  281. package/dist/tools/playbooks/extract-compose.js.map +1 -0
  282. package/dist/tools/playbooks/find-replace.d.ts +11 -0
  283. package/dist/tools/playbooks/find-replace.js +56 -0
  284. package/dist/tools/playbooks/find-replace.js.map +1 -0
  285. package/dist/tools/playbooks/index.d.ts +63 -0
  286. package/dist/tools/playbooks/index.js +70 -0
  287. package/dist/tools/playbooks/index.js.map +1 -0
  288. package/dist/tools/playbooks/keys-blocklist.d.ts +24 -0
  289. package/dist/tools/playbooks/keys-blocklist.js +89 -0
  290. package/dist/tools/playbooks/keys-blocklist.js.map +1 -0
  291. package/dist/tools/registry.d.ts +40 -0
  292. package/dist/tools/registry.js +560 -0
  293. package/dist/tools/registry.js.map +1 -0
  294. package/dist/tools/safety-gate.d.ts +16 -0
  295. package/dist/tools/safety-gate.js +70 -0
  296. package/dist/tools/safety-gate.js.map +1 -0
  297. package/dist/tools/scheduler.d.ts +76 -0
  298. package/dist/tools/scheduler.js +413 -0
  299. package/dist/tools/scheduler.js.map +1 -0
  300. package/dist/tools/shortcuts.d.ts +13 -0
  301. package/dist/tools/shortcuts.js +205 -0
  302. package/dist/tools/shortcuts.js.map +1 -0
  303. package/dist/tools/smart.d.ts +15 -0
  304. package/dist/tools/smart.js +785 -0
  305. package/dist/tools/smart.js.map +1 -0
  306. package/dist/tools/types.d.ts +174 -0
  307. package/dist/tools/types.js +67 -0
  308. package/dist/tools/types.js.map +1 -0
  309. package/dist/tools/window-text.d.ts +15 -0
  310. package/dist/tools/window-text.js +39 -0
  311. package/dist/tools/window-text.js.map +1 -0
  312. package/dist/types.d.ts +122 -0
  313. package/dist/types.js +41 -0
  314. package/dist/types.js.map +1 -0
  315. package/native/Package.swift +38 -0
  316. package/native/README.md +113 -0
  317. package/native/Sources/ClawdCursorHelper/main.swift +602 -0
  318. package/native/Sources/ClawdCursorHost/main.swift +182 -0
  319. package/native/Sources/PermissionCheck/main.swift +53 -0
  320. package/native/Sources/ScreenshotHelper/main.swift +219 -0
  321. package/native/build.sh +139 -0
  322. package/native/entitlements.plist +12 -0
  323. package/package.json +115 -0
  324. package/scripts/banner.ps1 +112 -0
  325. package/scripts/coord-accuracy.ps1 +140 -0
  326. package/scripts/coord-uwp.ps1 +80 -0
  327. package/scripts/edge-glow.ps1 +180 -0
  328. package/scripts/find-element.ps1 +198 -0
  329. package/scripts/get-foreground-window.ps1 +71 -0
  330. package/scripts/get-screen-context.ps1 +183 -0
  331. package/scripts/get-windows.ps1 +66 -0
  332. package/scripts/install-panic-hotkey.ps1 +46 -0
  333. package/scripts/interact-element.ps1 +431 -0
  334. package/scripts/invoke-element.ps1 +314 -0
  335. package/scripts/linux/atspi-bridge.py +356 -0
  336. package/scripts/linux/ocr-recognize.py +154 -0
  337. package/scripts/mac/_window-picker.jxa +163 -0
  338. package/scripts/mac/find-element.jxa +0 -0
  339. package/scripts/mac/find-element.sh +161 -0
  340. package/scripts/mac/focus-window.jxa +284 -0
  341. package/scripts/mac/get-focused-element.jxa +102 -0
  342. package/scripts/mac/get-foreground-window.jxa +173 -0
  343. package/scripts/mac/get-screen-context.jxa +197 -0
  344. package/scripts/mac/get-ui-tree.sh +141 -0
  345. package/scripts/mac/get-windows.jxa +117 -0
  346. package/scripts/mac/interact-element.sh +235 -0
  347. package/scripts/mac/invoke-element.jxa +408 -0
  348. package/scripts/mac/ocr-recognize.swift +124 -0
  349. package/scripts/ocr-recognize.ps1 +102 -0
  350. package/scripts/postinstall-native.js +48 -0
  351. package/scripts/ps-bridge.ps1 +830 -0
  352. package/scripts/smoke-mcp.ps1 +119 -0
  353. package/scripts/sync-version.ts +178 -0
  354. package/scripts/verify-install.js +81 -0
@@ -0,0 +1,113 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compileUIMap = compileUIMap;
4
+ exports.defaultCompileDeps = defaultCompileDeps;
5
+ const ui_map_elements_1 = require("./ui-map-elements");
6
+ const ui_map_fuse_1 = require("./ui-map-fuse");
7
+ const ui_map_anchors_1 = require("./ui-map-anchors");
8
+ const ui_map_normalize_1 = require("./ui-map-normalize");
9
+ const ui_map_geom_1 = require("./ui-map-geom");
10
+ const snapshot_1 = require("./snapshot");
11
+ const ocr_engine_1 = require("../../platform/ocr-engine");
12
+ const SPARSE_A11Y_MAX = 0; // ≤ this many named a11y elements ⇒ "sparse"
13
+ const LOW_CONFIDENCE = 0.5; // below this on a needed element ⇒ vision-worthy
14
+ function namedCount(snap) {
15
+ return snap.elements.filter(e => (e.name ?? '').trim().length > 0).length;
16
+ }
17
+ async function compileUIMap(deps, hints) {
18
+ const maxCost = hints.max_cost ?? 'ocr_ok';
19
+ const sourcesUsed = ['window'];
20
+ const snap = await deps.captureSnapshot();
21
+ if (snap.sources.includes('a11y'))
22
+ sourcesUsed.push('a11y');
23
+ let elements = snap.elements.map((se, i) => (0, ui_map_elements_1.a11yToUI)(se, `el_${i}`));
24
+ // Lazy OCR: only when a11y is sparse OR a requested target_text isn't present.
25
+ const sparse = namedCount(snap) <= SPARSE_A11Y_MAX;
26
+ const wantText = hints.target_text ? hints.target_text.trim().toLowerCase() : '';
27
+ const a11yHasTarget = wantText
28
+ ? elements.some(e => (e.normalized_text ?? '').includes(wantText))
29
+ : true;
30
+ const ocrAllowed = maxCost === 'ocr_ok' || maxCost === 'vision_ok';
31
+ if (ocrAllowed && (sparse || !a11yHasTarget)) {
32
+ const ocrRes = await Promise.resolve(deps.ocr()).catch(() => null);
33
+ if (ocrRes && ocrRes.elements.length > 0) {
34
+ sourcesUsed.push('ocr');
35
+ const base = elements.length;
36
+ elements = (0, ui_map_fuse_1.fuse)([...elements, ...ocrRes.elements.map((oe, i) => (0, ui_map_elements_1.ocrToUI)(oe, `el_${base + i}`))]);
37
+ }
38
+ }
39
+ // Lazy vision: only when allowed AND nothing usable surfaced from a11y+OCR.
40
+ const visionAllowed = maxCost === 'vision_ok';
41
+ const nothingActionable = !elements.some(e => e.actionable && e.confidence >= LOW_CONFIDENCE);
42
+ if (visionAllowed && nothingActionable) {
43
+ const shot = await Promise.resolve(deps.vision()).catch(() => null);
44
+ if (shot)
45
+ sourcesUsed.push('vision');
46
+ }
47
+ // Re-id ids contiguously after fusion so el_NN is dense within this snapshot.
48
+ elements = elements.map((e, i) => ({ ...e, id: `el_${i}` }));
49
+ // Mark the focused element so the focused anchor resolves. The platform's
50
+ // focused element carries name, role AND bounds — match it into the fused map
51
+ // by name+role, disambiguating ties (and empty-name canvas/editor surfaces)
52
+ // via nearest bounds (spec §5: role + normalized_text + nearest bounds).
53
+ const focused = await deps.getFocusedElement().catch(() => null);
54
+ if (focused) {
55
+ const fname = (0, ui_map_normalize_1.normText)(focused.name);
56
+ const frole = (0, ui_map_normalize_1.normalizeRole)(focused.controlType);
57
+ const fb = focused.bounds;
58
+ const fbounds = fb && fb.width > 0 && fb.height > 0 ? [fb.x, fb.y, fb.width, fb.height] : null;
59
+ const named = fname !== ''
60
+ ? elements.filter(e => e.normalized_text === fname && e.role === frole)
61
+ : [];
62
+ const bestByIou = (els, b) => els.length === 0 ? undefined
63
+ : els.reduce((best, e) => ((0, ui_map_geom_1.iou)(e.bounds, b) > (0, ui_map_geom_1.iou)(best.bounds, b) ? e : best), els[0]);
64
+ let hit;
65
+ if (named.length === 1) {
66
+ hit = named[0];
67
+ }
68
+ else if (named.length > 1) {
69
+ hit = fbounds ? bestByIou(named, fbounds) : named[0];
70
+ }
71
+ else if (fbounds) {
72
+ // No name match (or empty name) — fall back to the nearest overlapping
73
+ // element, but only accept a real overlap to avoid false positives.
74
+ const cand = bestByIou(elements, fbounds);
75
+ if (cand && (0, ui_map_geom_1.iou)(cand.bounds, fbounds) > 0)
76
+ hit = cand;
77
+ }
78
+ if (hit)
79
+ hit.state = { ...hit.state, focused: true };
80
+ }
81
+ const screen = await deps.getScreenSize();
82
+ const aw = snap.activeWindow;
83
+ return {
84
+ snapshot_id: deps.snapshotId,
85
+ platform: snap.platform,
86
+ active_app: aw?.processName ?? '',
87
+ process_id: aw ? String(aw.processId) : undefined,
88
+ window_title: aw?.title ?? '',
89
+ window_bounds: aw ? [aw.bounds.x, aw.bounds.y, aw.bounds.width, aw.bounds.height] : [0, 0, 0, 0],
90
+ coordinate_space: 'screen',
91
+ scale_factor: screen.dpiRatio,
92
+ compiled_at: String(deps.now),
93
+ sources_used: sourcesUsed,
94
+ elements,
95
+ anchors: (0, ui_map_anchors_1.computeAnchors)(elements, deps.prevAnchors),
96
+ truncation: { total_elements: elements.length, returned_elements: elements.length },
97
+ };
98
+ }
99
+ let _ocr = null;
100
+ function ocrEngine() { return (_ocr ??= new ocr_engine_1.OcrEngine()); }
101
+ /** Production deps wired to a real adapter. now/snapshotId are caller-passed
102
+ * (the agent loop owns the clock + the obs_N counter). */
103
+ function defaultCompileDeps(adapter, now, snapshotId, prevAnchors) {
104
+ return {
105
+ captureSnapshot: () => (0, snapshot_1.captureSnapshot)(adapter),
106
+ ocr: () => ocrEngine().recognizeScreen(),
107
+ vision: () => adapter.screenshot({ maxWidth: 1280 }),
108
+ getScreenSize: () => adapter.getScreenSize(),
109
+ getFocusedElement: () => adapter.getFocusedElement(),
110
+ now, snapshotId, prevAnchors,
111
+ };
112
+ }
113
+ //# sourceMappingURL=ui-map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-map.js","sourceRoot":"","sources":["../../../src/core/sense/ui-map.ts"],"names":[],"mappings":";;AAyCA,oCAoFC;AAOD,gDAWC;AArID,uDAAsD;AACtD,+CAAqC;AACrC,qDAAkD;AAClD,yDAA6D;AAC7D,+CAAoC;AACpC,yCAA6C;AAC7C,0DAAsD;AAEtD,MAAM,eAAe,GAAG,CAAC,CAAC,CAAU,6CAA6C;AACjF,MAAM,cAAc,GAAG,GAAG,CAAC,CAAS,iDAAiD;AAkBrF,SAAS,UAAU,CAAC,IAAc;IAChC,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG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----------------------
6
+ * Task verification used to be model-claimed: `done(evidence)` took a prose
7
+ * string and the guards only checked it for length/hedging — nothing
8
+ * re-checked reality. In the 2026-06-06 live Outlook run the model looked at
9
+ * a real screenshot, "verified" a recipient that was never committed, and the
10
+ * task died 12 turns later at send time.
11
+ *
12
+ * THE DESIGN
13
+ * ----------
14
+ * The model PROPOSES machine-checkable proofs; the harness EXECUTES them
15
+ * against ground truth. No LLM judgment, no screenshot tokens. The checks
16
+ * mirror the perception cost ladder — strongest/cheapest first:
17
+ *
18
+ * out-of-band artifacts file_exists / file_contains / clipboard_contains
19
+ * OS window facts window_title_contains / app_running
20
+ * UIA element facts element_exists / element_value_contains
21
+ * pixel-derived text ocr_contains (the only check that touches pixels)
22
+ *
23
+ * LAYERING
24
+ * --------
25
+ * This module is pure core: it depends on PlatformAdapter (reads only) and
26
+ * node:fs — never on tools, the agent loop, or the MCP surface. It is mounted
27
+ * twice: by the System B `verify` tool (which projects to the MCP surface for
28
+ * external agents) and by the `done(assertions)` completion gate.
29
+ */
30
+ import type { PlatformAdapter } from '../../platform/types';
31
+ export type Assertion = {
32
+ type: 'window_title_contains';
33
+ value: string;
34
+ } | {
35
+ type: 'app_running';
36
+ name: string;
37
+ } | {
38
+ type: 'element_exists';
39
+ name: string;
40
+ } | {
41
+ type: 'element_value_contains';
42
+ name: string;
43
+ value: string;
44
+ } | {
45
+ type: 'clipboard_contains';
46
+ value: string;
47
+ } | {
48
+ type: 'file_exists';
49
+ path: string;
50
+ } | {
51
+ type: 'file_contains';
52
+ path: string;
53
+ value: string;
54
+ } | {
55
+ type: 'ocr_contains';
56
+ value: string;
57
+ } | {
58
+ type: 'file_changed_since_start';
59
+ path: string;
60
+ };
61
+ export interface AssertionDeps {
62
+ adapter: PlatformAdapter;
63
+ /** Lazy OCR reader — only invoked for `ocr_contains` (the one pixel-derived
64
+ * check). Left unwired in contexts without an OCR engine; the assertion
65
+ * then fails with an explanatory detail instead of throwing. */
66
+ ocrText?: () => Promise<string>;
67
+ /** Epoch-ms timestamp of task start. Required by `file_changed_since_start`
68
+ * (the proof that a mutating task actually wrote the file it claims to). */
69
+ taskStartedAt?: number;
70
+ }
71
+ export interface AssertionOutcome {
72
+ index: number;
73
+ /** Compact human/LLM-readable restatement, e.g. `element_value_contains("To", "a@b.com")`. */
74
+ summary: string;
75
+ ok: boolean;
76
+ /** Why it failed (or what matched) — includes the ACTUAL observed value so
77
+ * a failing model can correct course instead of retrying blind. */
78
+ detail: string;
79
+ }
80
+ export interface VerifyReport {
81
+ ok: boolean;
82
+ passed: number;
83
+ failed: number;
84
+ outcomes: AssertionOutcome[];
85
+ }
86
+ /** Hard cap — verification is a proof, not a checklist dump. */
87
+ export declare const MAX_ASSERTIONS = 8;
88
+ /**
89
+ * Validate raw model input into a typed assertion list. Returns `{error}`
90
+ * (never throws) so tool handlers can reject with a corrective message.
91
+ */
92
+ export declare function parseAssertions(raw: unknown): {
93
+ assertions: Assertion[];
94
+ } | {
95
+ error: string;
96
+ };
97
+ /**
98
+ * Execute every assertion against current ground truth. Per-assertion errors
99
+ * (UIA down, fs error) fail THAT assertion with the error text — the function
100
+ * itself never throws.
101
+ */
102
+ export declare function checkAssertions(assertions: Assertion[], deps: AssertionDeps): Promise<VerifyReport>;
103
+ /** Compact ✓/✗ report — readable by humans and cheap for LLM context. */
104
+ export declare function renderReport(report: VerifyReport): string;
105
+ export interface TaskBaseline {
106
+ startedAt: number;
107
+ /** Lower-cased OCR text of the screen at task start. */
108
+ ocrText: string;
109
+ /** Lower-cased window titles present at task start. */
110
+ windowTitles: string[];
111
+ /** Lower-cased process names with a window at task start. */
112
+ processNames: string[];
113
+ /** Lower-cased clipboard contents at task start. */
114
+ clipboard: string;
115
+ }
116
+ /** Capture the cheap baseline artifacts at task start. Best-effort: any source
117
+ * that fails contributes an empty value rather than throwing. */
118
+ export declare function captureTaskBaseline(adapter: PlatformAdapter, ocrText?: () => Promise<string>): Promise<TaskBaseline>;
119
+ /**
120
+ * Was this assertion ALREADY satisfied at task start?
121
+ * true — provably true at baseline (non-discriminating: proves nothing changed)
122
+ * false — provably NOT true at baseline (discriminating: the task made it true)
123
+ * null — undeterminable from the cheap baseline (element/file checks) → trusted
124
+ */
125
+ export declare function wasTrueAtBaseline(a: Assertion, b: TaskBaseline): boolean | null;
126
+ /**
127
+ * Given a PASSING report, is at least one passing assertion discriminating
128
+ * (not provably true at baseline)? Returns true when the evidence genuinely
129
+ * reflects a change, false when EVERY passing proof was already true before
130
+ * the task acted.
131
+ */
132
+ export declare function hasDiscriminatingEvidence(assertions: Assertion[], report: VerifyReport, baseline: TaskBaseline): boolean;
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ /**
3
+ * Assertion engine — harness-executed task verification.
4
+ *
5
+ * THE PROBLEM THIS SOLVES
6
+ * -----------------------
7
+ * Task verification used to be model-claimed: `done(evidence)` took a prose
8
+ * string and the guards only checked it for length/hedging — nothing
9
+ * re-checked reality. In the 2026-06-06 live Outlook run the model looked at
10
+ * a real screenshot, "verified" a recipient that was never committed, and the
11
+ * task died 12 turns later at send time.
12
+ *
13
+ * THE DESIGN
14
+ * ----------
15
+ * The model PROPOSES machine-checkable proofs; the harness EXECUTES them
16
+ * against ground truth. No LLM judgment, no screenshot tokens. The checks
17
+ * mirror the perception cost ladder — strongest/cheapest first:
18
+ *
19
+ * out-of-band artifacts file_exists / file_contains / clipboard_contains
20
+ * OS window facts window_title_contains / app_running
21
+ * UIA element facts element_exists / element_value_contains
22
+ * pixel-derived text ocr_contains (the only check that touches pixels)
23
+ *
24
+ * LAYERING
25
+ * --------
26
+ * This module is pure core: it depends on PlatformAdapter (reads only) and
27
+ * node:fs — never on tools, the agent loop, or the MCP surface. It is mounted
28
+ * twice: by the System B `verify` tool (which projects to the MCP surface for
29
+ * external agents) and by the `done(assertions)` completion gate.
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.MAX_ASSERTIONS = void 0;
33
+ exports.parseAssertions = parseAssertions;
34
+ exports.checkAssertions = checkAssertions;
35
+ exports.renderReport = renderReport;
36
+ exports.captureTaskBaseline = captureTaskBaseline;
37
+ exports.wasTrueAtBaseline = wasTrueAtBaseline;
38
+ exports.hasDiscriminatingEvidence = hasDiscriminatingEvidence;
39
+ const node_fs_1 = require("node:fs");
40
+ const node_os_1 = require("node:os");
41
+ /** Hard cap — verification is a proof, not a checklist dump. */
42
+ exports.MAX_ASSERTIONS = 8;
43
+ /** Required string fields per assertion type. Single source of truth for
44
+ * parse validation AND the error message listing valid types. */
45
+ const FIELDS_BY_TYPE = {
46
+ window_title_contains: ['value'],
47
+ app_running: ['name'],
48
+ element_exists: ['name'],
49
+ element_value_contains: ['name', 'value'],
50
+ clipboard_contains: ['value'],
51
+ file_exists: ['path'],
52
+ file_contains: ['path', 'value'],
53
+ ocr_contains: ['value'],
54
+ file_changed_since_start: ['path'],
55
+ };
56
+ // ─── Parsing / validation ────────────────────────────────────────────────────
57
+ /**
58
+ * Validate raw model input into a typed assertion list. Returns `{error}`
59
+ * (never throws) so tool handlers can reject with a corrective message.
60
+ */
61
+ function parseAssertions(raw) {
62
+ if (!Array.isArray(raw)) {
63
+ return { error: `assertions must be an array of {type, ...} objects (got ${typeof raw}). Valid types: ${Object.keys(FIELDS_BY_TYPE).join(', ')}.` };
64
+ }
65
+ if (raw.length === 0) {
66
+ return { error: 'assertions array is empty — provide at least one machine-checkable proof.' };
67
+ }
68
+ if (raw.length > exports.MAX_ASSERTIONS) {
69
+ return { error: `too many assertions (${raw.length} > ${exports.MAX_ASSERTIONS}) — verify the few facts that actually prove the task.` };
70
+ }
71
+ const assertions = [];
72
+ for (let i = 0; i < raw.length; i++) {
73
+ const a = raw[i];
74
+ if (!a || typeof a !== 'object') {
75
+ return { error: `assertion ${i} is not an object.` };
76
+ }
77
+ const type = String(a.type ?? '');
78
+ const fields = FIELDS_BY_TYPE[type];
79
+ if (!fields) {
80
+ return { error: `assertion ${i} has unknown type "${type}". Valid types: ${Object.keys(FIELDS_BY_TYPE).join(', ')}.` };
81
+ }
82
+ for (const f of fields) {
83
+ if (typeof a[f] !== 'string' || a[f].length === 0) {
84
+ return { error: `assertion ${i} (${type}) is missing required string field "${f}".` };
85
+ }
86
+ }
87
+ assertions.push(a);
88
+ }
89
+ return { assertions };
90
+ }
91
+ // ─── Execution ───────────────────────────────────────────────────────────────
92
+ const norm = (s) => s.toLowerCase();
93
+ const containsCI = (haystack, needle) => norm(haystack).includes(norm(needle));
94
+ const truncate = (s, n) => (s.length > n ? `${s.slice(0, n - 1)}…` : s);
95
+ /** Expand a leading `~` so model-supplied paths like `~/Documents/x.txt` work. */
96
+ function expandHome(p) {
97
+ return p.startsWith('~') ? (0, node_os_1.homedir)() + p.slice(1) : p;
98
+ }
99
+ /** Cap file_contains reads — verification targets are documents, not dumps. */
100
+ const MAX_FILE_BYTES = 1024 * 1024;
101
+ async function checkOne(a, deps) {
102
+ const { adapter } = deps;
103
+ switch (a.type) {
104
+ case 'window_title_contains': {
105
+ const wins = await adapter.listWindows();
106
+ const hit = wins.find(w => containsCI(w.title ?? '', a.value));
107
+ if (hit)
108
+ return { ok: true, detail: `matched "${truncate(hit.title, 60)}"` };
109
+ const titles = wins.slice(0, 5).map(w => `"${truncate(w.title, 40)}"`).join(', ');
110
+ return { ok: false, detail: `no open window title contains "${a.value}" (open: ${titles || 'none'})` };
111
+ }
112
+ case 'app_running': {
113
+ const wins = await adapter.listWindows();
114
+ const hit = wins.find(w => containsCI(w.processName ?? '', a.name));
115
+ return hit
116
+ ? { ok: true, detail: `process "${hit.processName}" has a window` }
117
+ : { ok: false, detail: `no window belongs to a process matching "${a.name}"` };
118
+ }
119
+ case 'element_exists': {
120
+ const hits = await adapter.findElements({ name: a.name });
121
+ return hits.length > 0
122
+ ? { ok: true, detail: `${hits.length} element(s) named "${a.name}"` }
123
+ : { ok: false, detail: `no accessibility element named "${a.name}" (sparse-tree app? try ocr_contains)` };
124
+ }
125
+ case 'element_value_contains': {
126
+ const res = await adapter.invokeElement({ name: a.name, action: 'get-value' });
127
+ if (!res.success)
128
+ return { ok: false, detail: `"${a.name}" has no readable value` };
129
+ const value = String(res.data?.value ?? '');
130
+ return containsCI(value, a.value)
131
+ ? { ok: true, detail: `"${a.name}" = "${truncate(value, 80)}"` }
132
+ : { ok: false, detail: `"${a.name}" = "${truncate(value, 80)}" — does not contain "${a.value}"` };
133
+ }
134
+ case 'clipboard_contains': {
135
+ const clip = await adapter.readClipboard();
136
+ return containsCI(clip ?? '', a.value)
137
+ ? { ok: true, detail: 'clipboard matches' }
138
+ : { ok: false, detail: `clipboard is "${truncate(clip ?? '', 60)}" — does not contain "${a.value}"` };
139
+ }
140
+ case 'file_exists': {
141
+ try {
142
+ const st = await node_fs_1.promises.stat(expandHome(a.path));
143
+ return { ok: true, detail: `exists (${st.size} bytes)` };
144
+ }
145
+ catch {
146
+ return { ok: false, detail: `no file at "${a.path}"` };
147
+ }
148
+ }
149
+ case 'file_contains': {
150
+ let content;
151
+ try {
152
+ const fh = await node_fs_1.promises.open(expandHome(a.path), 'r');
153
+ try {
154
+ const buf = Buffer.alloc(MAX_FILE_BYTES);
155
+ const { bytesRead } = await fh.read(buf, 0, MAX_FILE_BYTES, 0);
156
+ content = buf.subarray(0, bytesRead).toString('utf8');
157
+ }
158
+ finally {
159
+ await fh.close();
160
+ }
161
+ }
162
+ catch {
163
+ return { ok: false, detail: `cannot read "${a.path}"` };
164
+ }
165
+ return containsCI(content, a.value)
166
+ ? { ok: true, detail: 'file content matches' }
167
+ : { ok: false, detail: `file does not contain "${a.value}" (read ${Math.min(content.length, MAX_FILE_BYTES)} chars)` };
168
+ }
169
+ case 'ocr_contains': {
170
+ if (!deps.ocrText)
171
+ return { ok: false, detail: 'OCR is not wired in this context — use element/window assertions instead' };
172
+ const text = await deps.ocrText();
173
+ return containsCI(text, a.value)
174
+ ? { ok: true, detail: 'visible on screen (OCR)' }
175
+ : { ok: false, detail: `OCR text does not contain "${a.value}"` };
176
+ }
177
+ case 'file_changed_since_start': {
178
+ // The proof that a mutating task actually WROTE the file it claims to —
179
+ // catches "claimed success, nothing happened" for file effects (a live
180
+ // wallpaper task 'verified' via the clock while the wallpaper file went
181
+ // untouched). Discriminating by construction: at task start nothing has
182
+ // been modified-since-start yet.
183
+ if (deps.taskStartedAt === undefined) {
184
+ return { ok: false, detail: 'no task-start timestamp in this context — file_changed_since_start only works inside a task run' };
185
+ }
186
+ try {
187
+ const st = await node_fs_1.promises.stat(expandHome(a.path));
188
+ const delta = Math.round((st.mtimeMs - deps.taskStartedAt) / 1000);
189
+ return st.mtimeMs > deps.taskStartedAt
190
+ ? { ok: true, detail: `modified ${delta}s into the task` }
191
+ : { ok: false, detail: `NOT modified since the task started (mtime is ${Math.abs(delta)}s older than task start) — your action did not change this file` };
192
+ }
193
+ catch {
194
+ return { ok: false, detail: `no file at "${a.path}"` };
195
+ }
196
+ }
197
+ }
198
+ }
199
+ function summarize(a) {
200
+ const args = FIELDS_BY_TYPE[a.type]
201
+ .map(f => `"${truncate(String(a[f]), 40)}"`)
202
+ .join(', ');
203
+ return `${a.type}(${args})`;
204
+ }
205
+ /**
206
+ * Execute every assertion against current ground truth. Per-assertion errors
207
+ * (UIA down, fs error) fail THAT assertion with the error text — the function
208
+ * itself never throws.
209
+ */
210
+ async function checkAssertions(assertions, deps) {
211
+ const outcomes = [];
212
+ for (let i = 0; i < assertions.length; i++) {
213
+ const a = assertions[i];
214
+ let ok;
215
+ let detail;
216
+ try {
217
+ ({ ok, detail } = await checkOne(a, deps));
218
+ }
219
+ catch (err) {
220
+ ok = false;
221
+ detail = `check failed: ${err instanceof Error ? err.message : String(err)}`;
222
+ }
223
+ outcomes.push({ index: i, summary: summarize(a), ok, detail });
224
+ }
225
+ const passed = outcomes.filter(o => o.ok).length;
226
+ return { ok: passed === outcomes.length, passed, failed: outcomes.length - passed, outcomes };
227
+ }
228
+ /** Compact ✓/✗ report — readable by humans and cheap for LLM context. */
229
+ function renderReport(report) {
230
+ return report.outcomes
231
+ .map(o => `${o.ok ? '✓' : '✗'} ${o.summary} — ${o.detail}`)
232
+ .join('\n');
233
+ }
234
+ /** Capture the cheap baseline artifacts at task start. Best-effort: any source
235
+ * that fails contributes an empty value rather than throwing. */
236
+ async function captureTaskBaseline(adapter, ocrText) {
237
+ const startedAt = Date.now();
238
+ let windowTitles = [];
239
+ let processNames = [];
240
+ try {
241
+ const wins = await adapter.listWindows();
242
+ windowTitles = wins.map(w => (w.title ?? '').toLowerCase());
243
+ processNames = wins.map(w => (w.processName ?? '').toLowerCase());
244
+ }
245
+ catch { /* empty */ }
246
+ let clipboard = '';
247
+ try {
248
+ clipboard = ((await adapter.readClipboard()) ?? '').toLowerCase();
249
+ }
250
+ catch { /* empty */ }
251
+ let ocr = '';
252
+ try {
253
+ ocr = ocrText ? (await ocrText()).toLowerCase() : '';
254
+ }
255
+ catch { /* empty */ }
256
+ return { startedAt, ocrText: ocr, windowTitles, processNames, clipboard };
257
+ }
258
+ /**
259
+ * Was this assertion ALREADY satisfied at task start?
260
+ * true — provably true at baseline (non-discriminating: proves nothing changed)
261
+ * false — provably NOT true at baseline (discriminating: the task made it true)
262
+ * null — undeterminable from the cheap baseline (element/file checks) → trusted
263
+ */
264
+ function wasTrueAtBaseline(a, b) {
265
+ const has = (h, n) => h.includes(n.toLowerCase());
266
+ switch (a.type) {
267
+ case 'ocr_contains': return has(b.ocrText, a.value);
268
+ case 'clipboard_contains': return has(b.clipboard, a.value);
269
+ case 'window_title_contains': return b.windowTitles.some(t => has(t, a.value));
270
+ case 'app_running': return b.processNames.some(p => has(p, a.name));
271
+ case 'file_changed_since_start': return false; // by construction: nothing is changed-since-start at start
272
+ default: return null; // element_*, file_exists, file_contains — trust
273
+ }
274
+ }
275
+ /**
276
+ * Given a PASSING report, is at least one passing assertion discriminating
277
+ * (not provably true at baseline)? Returns true when the evidence genuinely
278
+ * reflects a change, false when EVERY passing proof was already true before
279
+ * the task acted.
280
+ */
281
+ function hasDiscriminatingEvidence(assertions, report, baseline) {
282
+ return assertions.some((a, i) => report.outcomes[i]?.ok === true && wasTrueAtBaseline(a, baseline) !== true);
283
+ }
284
+ //# sourceMappingURL=assertions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../../src/core/verify/assertions.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;;;AAsEH,0CA6BC;AAwHD,0CAgBC;AAGD,oCAIC;AA6BD,kDAiBC;AAQD,8CAUC;AAQD,8DAQC;AAhUD,qCAAyC;AACzC,qCAAkC;AA4ClC,gEAAgE;AACnD,QAAA,cAAc,GAAG,CAAC,CAAC;AAEhC;kEACkE;AAClE,MAAM,cAAc,GAAiD;IACnE,qBAAqB,EAAE,CAAC,OAAO,CAAC;IAChC,WAAW,EAAE,CAAC,MAAM,CAAC;IACrB,cAAc,EAAE,CAAC,MAAM,CAAC;IACxB,sBAAsB,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IACzC,kBAAkB,EAAE,CAAC,OAAO,CAAC;IAC7B,WAAW,EAAE,CAAC,MAAM,CAAC;IACrB,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IAChC,YAAY,EAAE,CAAC,OAAO,CAAC;IACvB,wBAAwB,EAAE,CAAC,MAAM,CAAC;CACnC,CAAC;AAEF,gFAAgF;AAEhF;;;GAGG;AACH,SAAgB,eAAe,CAAC,GAAY;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,KAAK,EAAE,2DAA2D,OAAO,GAAG,mBAAmB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;IACtJ,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,KAAK,EAAE,2EAA2E,EAAE,CAAC;IAChG,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,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,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;QAClE,KAAK,uBAAuB,CAAC,CAAI,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,KAAK,aAAa,CAAC,CAAc,OAAO,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACjF,KAAK,0BAA0B,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,2DAA2D;QAC1G,OAAO,CAAC,CAAyB,OAAO,IAAI,CAAC,CAAE,gDAAgD;IACjG,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CACvC,UAAuB,EACvB,MAAoB,EACpB,QAAsB;IAEtB,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAC9B,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,IAAI,IAAI,iBAAiB,CAAC,CAAC,EAAE,QAAQ,CAAC,KAAK,IAAI,CAC3E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Back-compat entry point — DO NOT add logic here.
4
+ *
5
+ * v0.x published the CLI at `dist/index.js`. v1.0 moved the real entry to
6
+ * `dist/surface/cli.js` (see package.json "bin"). Some users had hard-pinned
7
+ * `node <pkg>/dist/index.js <args>` into an MCP host config — e.g. Claude
8
+ * Code's `.claude.json` — and a routine `npm i -g clawdcursor` upgrade then
9
+ * silently broke their launch, because the file they pointed at no longer
10
+ * existed. The MCP server simply failed to start with no obvious cause.
11
+ *
12
+ * This shim re-runs the real CLI so those pinned paths keep working across the
13
+ * move. `surface/cli` calls `program.parse()` on load, so importing it here is
14
+ * enough — the original `process.argv` flows straight through.
15
+ *
16
+ * New configs should launch the `clawdcursor` bin directly
17
+ * (`"command": "clawdcursor", "args": ["mcp", "--compact"]`) or install the
18
+ * Claude Code plugin, both of which resolve through npm and never pin a deep
19
+ * dist path. See README.md / SKILL.md.
20
+ */
21
+ import './surface/cli';
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ /**
5
+ * Back-compat entry point — DO NOT add logic here.
6
+ *
7
+ * v0.x published the CLI at `dist/index.js`. v1.0 moved the real entry to
8
+ * `dist/surface/cli.js` (see package.json "bin"). Some users had hard-pinned
9
+ * `node <pkg>/dist/index.js <args>` into an MCP host config — e.g. Claude
10
+ * Code's `.claude.json` — and a routine `npm i -g clawdcursor` upgrade then
11
+ * silently broke their launch, because the file they pointed at no longer
12
+ * existed. The MCP server simply failed to start with no obvious cause.
13
+ *
14
+ * This shim re-runs the real CLI so those pinned paths keep working across the
15
+ * move. `surface/cli` calls `program.parse()` on load, so importing it here is
16
+ * enough — the original `process.argv` flows straight through.
17
+ *
18
+ * New configs should launch the `clawdcursor` bin directly
19
+ * (`"command": "clawdcursor", "args": ["mcp", "--compact"]`) or install the
20
+ * Claude Code plugin, both of which resolve through npm and never pin a deep
21
+ * dist path. See README.md / SKILL.md.
22
+ */
23
+ require("./surface/cli");
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,yBAAuB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Browser Configuration — centralised helpers for browser detection and CDP port.
3
+ *
4
+ * All files that need to know which browser processes to match, what CDP port
5
+ * to connect to, or where the browser executable lives should import from here
6
+ * instead of hardcoding values.
7
+ */
8
+ import type { ClawdConfig } from '../types';
9
+ export declare const DEFAULT_CDP_PORT = 9223;
10
+ /**
11
+ * Port for the AGENT-OWNED dedicated browser instance (the one CDPDriver
12
+ * launches itself with `--user-data-dir=~/.clawdcursor/cdp-profile`).
13
+ *
14
+ * Deliberately DIFFERENT from DEFAULT_CDP_PORT (9223): ownership is encoded in
15
+ * the port. 9223 is reserved for browsers the USER put on the wire (their own
16
+ * launch flags, `relaunch_with_cdp`, the browser relay) — attaching there means
17
+ * "driving the user's session" and gets new-tab discipline. Sharing one port
18
+ * for both meant the driver could not tell its own instance from the user's:
19
+ * whoever squatted 9223 won, and a lingering agent instance the user adopted
20
+ * (music, browsing) got its tabs hijacked (root-cause fix 2026-06-11).
21
+ */
22
+ export declare const AGENT_CDP_PORT: number;
23
+ /** Get configured browser executable path, or null for auto-detection */
24
+ export declare function getBrowserExePath(config?: ClawdConfig): string | null;
25
+ /** Get list of browser process names to match against */
26
+ export declare function getBrowserProcessNames(config?: ClawdConfig): string[];
27
+ /** Get CDP debugging port */
28
+ export declare function getCDPPort(config?: ClawdConfig): number;
29
+ /** Build a regex matching browser process names */
30
+ export declare function getBrowserProcessRegex(config?: ClawdConfig): RegExp;
31
+ /** Get default Chrome executable paths for the current platform */
32
+ export declare function getChromePaths(): string[];
33
+ /** Get default Edge executable paths for the current platform */
34
+ export declare function getEdgePaths(): string[];
35
+ /** Get browser executable paths, respecting config overrides. Tries custom path first, then defaults. */
36
+ export declare function getBrowserPaths(browser: 'chrome' | 'edge', config?: ClawdConfig): string[];