@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,568 @@
1
+ "use strict";
2
+ /**
3
+ * SafetyLayer — unified gate for every agent action (v0.8.1 rebuild).
4
+ *
5
+ * v0.8.0's `src/safety.ts` classified only by description-string match, which
6
+ * the audit correctly flagged as trivially bypassable (a `mouse_click(x,y)` on
7
+ * a Send button never contains the word "send"). V2 orchestrator didn't call
8
+ * SafetyLayer at all, and the `/action` REST endpoint bypassed it entirely.
9
+ *
10
+ * v0.8.1 fixes the chokepoint problem:
11
+ * - Pure function `evaluate(action, context) → Decision` keyed on the ACTION
12
+ * TYPE, not on description prose. A mouse_click on a button whose OCR
13
+ * label matches a Confirm-tier pattern elevates to Confirm. A key combo
14
+ * in BLOCKED_KEYS returns Block.
15
+ * - Registry-driven coverage test (`safety-coverage.test.ts`) enforces
16
+ * that every MCP tool handler invokes `evaluate` before its first side
17
+ * effect.
18
+ * - Decision is observable via the audit log (`safety.decision` events).
19
+ *
20
+ * Model-agnostic: no LLM calls. Pure rule engine.
21
+ */
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.evaluate = evaluate;
24
+ exports.isAllowed = isAllowed;
25
+ exports.evaluateInput = evaluateInput;
26
+ const keys_blocklist_1 = require("../tools/playbooks/keys-blocklist");
27
+ const logger_1 = require("./observability/logger");
28
+ const correlation_1 = require("./observability/correlation");
29
+ const app_categories_1 = require("./app-categories");
30
+ /**
31
+ * URI schemes that only COMPOSE or NAVIGATE — they open a draft/app/page but
32
+ * cannot execute code, delete data, or COMPLETE an irreversible action without
33
+ * a further user step (you still have to hit send/call). Safe to open without
34
+ * confirmation. Everything NOT listed keeps the confirm gate, deliberately:
35
+ * • file: — on Windows can launch an executable.
36
+ * • vscode/vscode-insiders — vscode:// is an extension/workspace execution
37
+ * surface (Remote SSH, workspace tasks, git clone, ext sub-commands).
38
+ * • obsidian — obsidian://advanced-uri can run plugin/shell cmds.
39
+ * • zoommtg/msteams — auto-JOIN a meeting (mic/camera) — completes an
40
+ * action; not mere navigation.
41
+ * • any unknown custom scheme — handler is unvetted.
42
+ * (Security audit 2026-06-08 trimmed vscode/obsidian/zoommtg/msteams.)
43
+ */
44
+ const BENIGN_URI_SCHEMES = new Set([
45
+ 'mailto', 'tel', 'sms', 'smsto', 'facetime', 'facetime-audio',
46
+ 'webcal', 'http', 'https', 'slack', 'spotify',
47
+ // ms-settings: NAVIGATES to a Settings page (like https) — opening the page
48
+ // changes nothing; the user still has to act. Unblocks "open <X> settings".
49
+ 'ms-settings',
50
+ ]);
51
+ function uriSchemeOf(uri) {
52
+ const m = String(uri ?? '').trim().match(/^([a-z][a-z0-9+.-]*):/i);
53
+ return m ? m[1].toLowerCase() : '';
54
+ }
55
+ // ── Conversions ──────────────────────────────────────────────────────────────
56
+ /** Map the legacy string Tier to a numeric tier. */
57
+ function tierToNumeric(t) {
58
+ switch (t) {
59
+ case 'read': return 0;
60
+ case 'input': return 1;
61
+ case 'destructive': return 2;
62
+ case 'system': return 3;
63
+ }
64
+ }
65
+ /** Map a numeric tier back to the legacy Tier string for internal rule engine. */
66
+ function numericToTierString(n) {
67
+ switch (n) {
68
+ case 0: return 'read';
69
+ case 1: return 'input';
70
+ case 2: return 'destructive';
71
+ case 3: return 'system';
72
+ }
73
+ }
74
+ /** Convert the internal `Decision` to the canonical `SafetyDecision`. */
75
+ function toSafetyDecision(d) {
76
+ const tier = tierToNumeric(d.tier);
77
+ if (d.decision === 'allow') {
78
+ return { allow: true, tier, suggestedAction: 'proceed' };
79
+ }
80
+ if (d.decision === 'block') {
81
+ return { allow: false, reason: d.reason, tier, suggestedAction: 'block' };
82
+ }
83
+ // confirm
84
+ return { allow: false, reason: d.reason, tier, suggestedAction: 'warn' };
85
+ }
86
+ /**
87
+ * Patterns in a target element's OCR/a11y label that elevate the tier to
88
+ * Confirm. Matched case-insensitively. Derived from v0.6.3 sensitive-app
89
+ * policy + v0.8.0 audit findings.
90
+ */
91
+ const CONFIRM_LABEL_PATTERNS = [
92
+ /\bsend\b/i, // email, message, wire transfer
93
+ /\bdelete\b/i, // destructive
94
+ /\bremove\b/i,
95
+ /\btrash\b/i,
96
+ /\berase\b/i,
97
+ /\buninstall\b/i,
98
+ /\bdrop\s+(database|table)/i,
99
+ /\bshut\s*down\b/i,
100
+ /\brestart\b/i,
101
+ /\blog\s*out\b/i,
102
+ /\bsign\s*out\b/i,
103
+ /\bpurchase\b/i,
104
+ /\bbuy\b/i,
105
+ /\bcheckout\b/i,
106
+ /\bpay\b/i,
107
+ /\btransfer\b/i,
108
+ /\bpublish\b/i,
109
+ /\bconfirm\b/i, // confirm dialogs themselves — require user
110
+ ];
111
+ // Canonical tools that type ARBITRARY TEXT. Their text payload is content,
112
+ // not a control label, so CONFIRM_LABEL_PATTERNS must NOT run against it —
113
+ // otherwise typing a sentence that merely contains "confirm" / "send" / etc.
114
+ // spuriously trips the confirm gate (#124: "verification to confirm reliable
115
+ // desktop automation" elevated to destructive tier). This is a denylist, not
116
+ // an allowlist: any tool NOT listed here stays gated by default, so a future
117
+ // click/activation tool can never silently lose label-pattern coverage — the
118
+ // worst a missing entry can do is add benign friction, never remove safety.
119
+ const TYPING_TOOLS = new Set(['type_text', 'cdp_type']);
120
+ // Sensitive-app list lives at src/core/app-categories.ts as the single
121
+ // source of truth — imported at the top of this file. Edit there, not here.
122
+ /** Tool name → default tier. */
123
+ const TOOL_TIER = {
124
+ // Read — always allow
125
+ 'read_screen': 'read',
126
+ 'ocr_read_screen': 'read',
127
+ 'smart_read': 'read',
128
+ 'desktop_screenshot': 'read',
129
+ 'desktop_screenshot_region': 'read',
130
+ 'get_screen_size': 'read',
131
+ 'get_windows': 'read',
132
+ 'get_active_window': 'read',
133
+ 'get_focused_element': 'read',
134
+ 'find_element': 'read',
135
+ 'read_clipboard': 'read',
136
+ 'cdp_page_context': 'read',
137
+ 'cdp_read_text': 'read',
138
+ 'cdp_list_tabs': 'read',
139
+ 'browser_read': 'read', // agent-loop CDP read — DOM text/elements, no side effects
140
+ 'shortcuts_list': 'read',
141
+ 'build_uri': 'read', // pure string construction — no side effects
142
+ // Input — allow with label check
143
+ 'mouse_click': 'input',
144
+ 'mouse_double_click': 'input',
145
+ 'mouse_right_click': 'input',
146
+ 'mouse_hover': 'input',
147
+ 'mouse_scroll': 'input',
148
+ 'mouse_drag': 'input',
149
+ 'type_text': 'input',
150
+ 'smart_type': 'input',
151
+ 'smart_click': 'input',
152
+ 'invoke_element': 'input',
153
+ 'key_press': 'input',
154
+ 'write_clipboard': 'destructive', // matches its declared safetyTier:2 (overwrites the user's clipboard); the tool's own tier already wins, this keeps the fallback consistent
155
+ 'cdp_click': 'input',
156
+ 'cdp_type': 'input',
157
+ 'cdp_select_option': 'input',
158
+ 'cdp_scroll': 'input',
159
+ 'cdp_wait_for_selector': 'input',
160
+ 'cdp_switch_tab': 'input',
161
+ 'cdp_connect': 'input',
162
+ // Agent-loop CDP browser tools (dedicated agent-owned instance, DOM-driven).
163
+ 'browser_connect': 'input',
164
+ 'browser_navigate': 'input',
165
+ 'browser_click': 'input',
166
+ 'browser_type': 'input',
167
+ 'navigate_browser': 'input',
168
+ 'focus_window': 'input',
169
+ 'minimize_window': 'input',
170
+ 'shortcuts_execute': 'input',
171
+ // System — always confirm (or block)
172
+ 'cdp_evaluate': 'system',
173
+ 'open_app': 'input',
174
+ 'wait': 'read',
175
+ 'delegate_to_agent': 'input',
176
+ // Pipeline-internal actions
177
+ 'a11y_click': 'input',
178
+ 'a11y_set_value': 'input',
179
+ 'click': 'input',
180
+ 'type': 'input',
181
+ 'press': 'input',
182
+ 'scroll': 'input',
183
+ 'drag': 'input',
184
+ 'move': 'input', // hover — cursor move only, no click/keys
185
+ 'screenshot': 'read',
186
+ 'read_text': 'read', // OCR perception — no side effects (smart_click already mapped above)
187
+ // `batch` is an inert wrapper — it gates EACH of its steps through this same
188
+ // evaluator at runtime, so the wrapper call itself is allow-tier.
189
+ 'batch': 'read',
190
+ 'done': 'read',
191
+ 'give_up': 'read',
192
+ 'cannot_read': 'read',
193
+ // Tranche 1B — new MCP tools (extras.ts)
194
+ 'mouse_move_relative': 'input',
195
+ 'mouse_middle_click': 'input',
196
+ 'mouse_triple_click': 'input',
197
+ 'mouse_down': 'input',
198
+ 'mouse_up': 'input',
199
+ 'mouse_scroll_horizontal': 'input',
200
+ 'mouse_drag_stepped': 'input',
201
+ 'key_down': 'input',
202
+ 'key_up': 'input',
203
+ 'maximize_window': 'input',
204
+ 'minimize_window_to_taskbar': 'input',
205
+ 'restore_window': 'input',
206
+ 'close_window': 'destructive', // polite request, but the user may not want this on autopilot
207
+ 'resize_window': 'input',
208
+ 'list_displays': 'read',
209
+ 'focus_element': 'input',
210
+ 'wait_for_element': 'read',
211
+ 'open_file': 'input',
212
+ 'open_url': 'input',
213
+ 'get_system_time': 'read',
214
+ 'switch_tab_os': 'input',
215
+ 'undo_last': 'input',
216
+ // Tranche 2 — a11y depth tools
217
+ 'a11y_expand': 'input',
218
+ 'a11y_collapse': 'input',
219
+ 'a11y_toggle': 'input',
220
+ 'a11y_select': 'input',
221
+ 'a11y_get_element': 'read',
222
+ 'a11y_get_value': 'read',
223
+ 'verify': 'read', // harness-executed assertions — read primitives only
224
+ 'compile_ui': 'read', // compiles a11y+OCR+vision into a fused UI map — no side effects
225
+ 'find_action_button': 'read', // semantic finder — no side effects
226
+ 'find_input_field': 'read', // semantic finder — no side effects
227
+ 'get_element_state': 'read',
228
+ 'a11y_list_children': 'read',
229
+ // v0.8.2 — Electron/WebView2 bridge tools
230
+ 'detect_webview_apps': 'read',
231
+ 'relaunch_with_cdp': 'destructive', // closes the app — app may prompt to save
232
+ // URI escape hatch + guide-write — match their granular safetyTier (2).
233
+ 'open_uri': 'destructive', // dispatches to an arbitrary registered handler (file: can execute)
234
+ 'learn_app': 'destructive', // writes a guide to ~/.clawdcursor
235
+ // Tranche 3 — compact compound MCP surface. When an agent calls one of
236
+ // these, the real action is decided by the `action` arg (already
237
+ // unpacked above via unpackCompoundTool for the unified-agent compound
238
+ // tools: mouse/keyboard/window). These public-MCP names share the
239
+ // same canonicalization philosophy — tier defaults to 'input' and the
240
+ // delegated granular tool's tier kicks in during actual dispatch.
241
+ 'computer': 'input',
242
+ 'accessibility': 'read',
243
+ 'window': 'input',
244
+ 'system': 'input',
245
+ 'browser': 'input',
246
+ 'task': 'input',
247
+ };
248
+ /**
249
+ * Map a compound-tool call (Tranche 2.5 vision agent) to its canonical
250
+ * granular name for tier lookup. `mouse({action:"click"})` resolves to
251
+ * `mouse_click`, `keyboard({action:"press"})` to `key_press`, etc.
252
+ *
253
+ * Without this, compound tools default to 'input' tier because
254
+ * `TOOL_TIER` is keyed on the canonical names. The mapping keeps the
255
+ * existing tier map as the single source of truth — no compound-specific
256
+ * tier entries needed.
257
+ */
258
+ function unpackCompoundTool(tool, args) {
259
+ // Tranche 3 public-MCP compound tools: computer/accessibility/window/
260
+ // system/browser/task. These are dispatched inside compact.ts and the
261
+ // granular delegate handles the real action — but for the audit log
262
+ // we want to surface the granular name here so forensic trails make
263
+ // sense. Mapping mirrors compact.ts's ACTION_MAP tables.
264
+ const publicCompoundMap = {
265
+ computer: {
266
+ screenshot: 'desktop_screenshot', screenshot_region: 'desktop_screenshot_region',
267
+ click: 'mouse_click', double_click: 'mouse_double_click', right_click: 'mouse_right_click',
268
+ middle_click: 'mouse_middle_click', triple_click: 'mouse_triple_click',
269
+ hover: 'mouse_hover', move: 'mouse_hover', move_relative: 'mouse_move_relative',
270
+ scroll: 'mouse_scroll', scroll_horizontal: 'mouse_scroll_horizontal',
271
+ drag: 'mouse_drag', drag_path: 'mouse_drag_stepped',
272
+ mouse_down: 'mouse_down', mouse_up: 'mouse_up',
273
+ type: 'type_text', key: 'key_press', key_press: 'key_press',
274
+ key_down: 'key_down', key_up: 'key_up', wait: 'wait',
275
+ },
276
+ accessibility: {
277
+ read_tree: 'read_screen', find: 'find_element', get_element: 'a11y_get_element',
278
+ focused: 'get_focused_element', invoke: 'invoke_element', focus: 'focus_element',
279
+ set_value: 'set_field_value', get_value: 'a11y_get_value',
280
+ expand: 'a11y_expand', collapse: 'a11y_collapse',
281
+ toggle: 'a11y_toggle', select: 'a11y_select', state: 'get_element_state',
282
+ list_children: 'a11y_list_children', wait_for: 'wait_for_element',
283
+ smart_click: 'smart_click', smart_type: 'smart_type', smart_read: 'smart_read',
284
+ },
285
+ window: {
286
+ list: 'get_windows', active: 'get_active_window', focus: 'focus_window',
287
+ maximize: 'maximize_window', minimize: 'minimize_window_to_taskbar',
288
+ restore: 'restore_window', close: 'close_window', resize: 'resize_window',
289
+ list_displays: 'list_displays', screen_size: 'get_screen_size',
290
+ open_app: 'open_app', open_file: 'open_file', open_url: 'open_url',
291
+ switch_tab: 'switch_tab_os', navigate: 'navigate_browser',
292
+ },
293
+ system: {
294
+ clipboard_read: 'read_clipboard', clipboard_write: 'write_clipboard',
295
+ system_time: 'get_system_time', ocr: 'ocr_read_screen', undo: 'undo_last',
296
+ shortcuts_list: 'shortcuts_list', shortcuts_run: 'shortcuts_execute',
297
+ delegate: 'delegate_to_agent',
298
+ // v0.8.2
299
+ detect_webview: 'detect_webview_apps',
300
+ relaunch_with_cdp: 'relaunch_with_cdp',
301
+ // URI escape hatches + guide-write (added to the compound surface)
302
+ build_uri: 'build_uri', open_uri: 'open_uri', learn_app: 'learn_app',
303
+ },
304
+ browser: {
305
+ connect: 'cdp_connect', page_context: 'cdp_page_context', read_text: 'cdp_read_text',
306
+ click: 'cdp_click', type: 'cdp_type', select_option: 'cdp_select_option',
307
+ evaluate: 'cdp_evaluate', wait_for: 'cdp_wait_for_selector',
308
+ list_tabs: 'cdp_list_tabs', switch_tab: 'cdp_switch_tab', scroll: 'cdp_scroll',
309
+ },
310
+ };
311
+ const actionArg = typeof args.action === 'string' ? args.action : '';
312
+ if (tool in publicCompoundMap && actionArg) {
313
+ const mapped = publicCompoundMap[tool][actionArg];
314
+ if (mapped)
315
+ return mapped;
316
+ }
317
+ if (tool === 'task')
318
+ return 'delegate_to_agent';
319
+ if (tool !== 'mouse' && tool !== 'keyboard' && tool !== 'window')
320
+ return tool;
321
+ const action = typeof args.action === 'string' ? args.action : '';
322
+ if (tool === 'mouse') {
323
+ switch (action) {
324
+ case 'click': return 'mouse_click';
325
+ case 'double_click': return 'mouse_double_click';
326
+ case 'right_click': return 'mouse_right_click';
327
+ case 'middle_click': return 'mouse_middle_click';
328
+ case 'triple_click': return 'mouse_triple_click';
329
+ case 'move':
330
+ case 'hover': return 'mouse_hover';
331
+ case 'move_relative': return 'mouse_move_relative';
332
+ case 'down': return 'mouse_down';
333
+ case 'up': return 'mouse_up';
334
+ case 'scroll': return 'mouse_scroll';
335
+ case 'drag': return 'mouse_drag';
336
+ case 'drag_stepped': return 'mouse_drag_stepped';
337
+ default: return 'mouse_click'; // safe default
338
+ }
339
+ }
340
+ if (tool === 'keyboard') {
341
+ switch (action) {
342
+ case 'press': return 'key_press';
343
+ case 'down': return 'key_down';
344
+ case 'up': return 'key_up';
345
+ case 'type': return 'type_text';
346
+ default: return 'key_press';
347
+ }
348
+ }
349
+ // window
350
+ switch (action) {
351
+ case 'focus': return 'focus_window';
352
+ case 'maximize': return 'maximize_window';
353
+ case 'minimize': return 'minimize_window';
354
+ case 'restore': return 'restore_window';
355
+ case 'close': return 'close_window';
356
+ case 'resize': return 'resize_window';
357
+ case 'list': return 'get_windows';
358
+ case 'list_displays': return 'list_displays';
359
+ default: return 'focus_window';
360
+ }
361
+ }
362
+ /**
363
+ * Evaluate an action. Pure function — no side effects other than the
364
+ * `safety.decision` audit log.
365
+ *
366
+ * When `ctx.toolSafetyTier` is provided (set from `ToolDefinition.safetyTier`),
367
+ * it overrides the TOOL_TIER name-lookup for the base tier so the gate
368
+ * uses the tool's own declared tier rather than guessing from the name.
369
+ * Blocked-key and cdp_evaluate checks still run unconditionally.
370
+ */
371
+ function evaluate(ctx) {
372
+ // Unpack compound tool calls (vision agent's mouse/keyboard/window)
373
+ // into the canonical granular name so tier lookup hits the same map
374
+ // that drives granular tools.
375
+ const canonicalTool = unpackCompoundTool(ctx.tool, ctx.args);
376
+ // PR6: prefer the tool's declared safetyTier; fall back to name lookup.
377
+ // IMPORTANT: when the surface tool is a compound (canonicalTool !== ctx.tool),
378
+ // the specific action may map to a HIGHER tier than the surface default
379
+ // (e.g. browser({action:'evaluate'}) → cdp_evaluate → 'system'). In that
380
+ // case we always use the canonical TOOL_TIER so the compound unpack works
381
+ // correctly. The toolSafetyTier override only applies to granular tools where
382
+ // no further unpacking occurs.
383
+ const isCompoundUnpacked = canonicalTool !== ctx.tool;
384
+ const tier = (!isCompoundUnpacked && ctx.toolSafetyTier !== undefined)
385
+ ? numericToTierString(ctx.toolSafetyTier)
386
+ : (TOOL_TIER[canonicalTool] ?? 'input');
387
+ const correlationId = (0, correlation_1.getCorrelationId)();
388
+ const emit = (decision) => {
389
+ // When a compound tool was unpacked, log BOTH names so the audit
390
+ // trail shows the canonical action (for tier forensics) and the
391
+ // surface tool the LLM actually called (for debugging).
392
+ const logMeta = { tool: ctx.tool, ...decision, correlationId };
393
+ if (canonicalTool !== ctx.tool)
394
+ logMeta.canonicalTool = canonicalTool;
395
+ logger_1.logger.info('safety.decision', logMeta);
396
+ return decision;
397
+ };
398
+ // 1. Keyboard combos: if blocked, reject immediately.
399
+ // Check the full set of keyboard-emitting surfaces: `key_press`,
400
+ // `press` (pipeline-internal), and the compound `keyboard` tool
401
+ // after unpacking (canonicalTool = 'key_press').
402
+ const isKeyboardSurface = ctx.tool === 'key_press' || ctx.tool === 'press' ||
403
+ canonicalTool === 'key_press' || canonicalTool === 'key_down';
404
+ if (isKeyboardSurface) {
405
+ const combo = typeof ctx.args.combo === 'string' ? ctx.args.combo
406
+ : typeof ctx.args.key === 'string' ? ctx.args.key : undefined;
407
+ if (combo !== undefined) {
408
+ const tier = (0, keys_blocklist_1.keyBlockTier)(combo);
409
+ // HARD block (lock/force-quit/shutdown) has no path; consequential combos
410
+ // (close window/tab, show desktop, launchers) are confirm-able instead of
411
+ // dead-ended (v1.6.0 — the old list hard-blocked win+d/ctrl+w).
412
+ if (tier === 'block') {
413
+ return emit({ decision: 'block', tier: 'destructive', reason: (0, keys_blocklist_1.keyBlockReason)(combo, 'block') });
414
+ }
415
+ if (tier === 'confirm') {
416
+ return emit({ decision: 'confirm', tier: 'destructive', reason: (0, keys_blocklist_1.keyBlockReason)(combo, 'confirm') });
417
+ }
418
+ }
419
+ }
420
+ // 2. cdp_evaluate is ungated in v0.8.0 (audit C5). Require Confirm here;
421
+ // full allowArbitraryJs config gate lands in v0.8.2.
422
+ if (ctx.tool === 'cdp_evaluate') {
423
+ return emit({
424
+ decision: 'confirm',
425
+ tier: 'system',
426
+ reason: 'cdp_evaluate runs arbitrary JS in the active page — requires user approval',
427
+ });
428
+ }
429
+ // 2b. open_uri tier is SCHEME-dependent. Benign compose/navigate schemes
430
+ // (mailto/tel/sms/webcal/http/https/...) cannot execute or delete — allow.
431
+ // file: (executes on Windows) and unknown custom schemes keep the confirm
432
+ // gate. This unblocks the OS URI escape hatches for headless runs without
433
+ // weakening the gate against executing/unknown handlers.
434
+ if (canonicalTool === 'open_uri') {
435
+ const scheme = uriSchemeOf(ctx.args.uri);
436
+ if (BENIGN_URI_SCHEMES.has(scheme)) {
437
+ return emit({ decision: 'allow', tier: 'input' });
438
+ }
439
+ return emit({
440
+ decision: 'confirm',
441
+ tier: 'destructive',
442
+ reason: scheme
443
+ ? `open_uri to "${scheme}:" — handler may execute or be destructive (e.g. file: can run a program); needs confirmation`
444
+ : 'open_uri with no/invalid scheme — needs confirmation',
445
+ });
446
+ }
447
+ // 3. Read tier: always allow.
448
+ if (tier === 'read') {
449
+ return emit({ decision: 'allow', tier });
450
+ }
451
+ // 4. System tier: always confirm (catch-all).
452
+ if (tier === 'system') {
453
+ return emit({ decision: 'confirm', tier, reason: `${ctx.tool} is a system-tier action` });
454
+ }
455
+ // 4b. Destructive tier: confirm. Matches the tool-registry tag for
456
+ // explicitly-destructive verbs (close_window, etc.) so the gate
457
+ // fires even when there's no label match.
458
+ if (tier === 'destructive') {
459
+ return emit({ decision: 'confirm', tier, reason: `${ctx.tool} is a destructive-tier action` });
460
+ }
461
+ // 5. Input tier with a Confirm-pattern target label.
462
+ // Skip for typing tools: their `targetLabel` is the text being typed
463
+ // (content), not the label of a control being activated. Clicking a
464
+ // button labelled "Send"/"Delete" is destructive; typing those words
465
+ // into a field is not. See TYPING_TOOLS above (#124).
466
+ if (ctx.targetLabel && !TYPING_TOOLS.has(canonicalTool)) {
467
+ for (const pattern of CONFIRM_LABEL_PATTERNS) {
468
+ if (pattern.test(ctx.targetLabel)) {
469
+ // Intent-matched bypass: if the user's task text contains the
470
+ // target label (case-insensitive, word-bounded) AND the same
471
+ // confirm-pattern fires on that task text, the user has given
472
+ // explicit consent for this exact destructive action. Examples:
473
+ // task="hit send" + target="Send" → bypass
474
+ // task="delete the row" + target="Delete" → bypass
475
+ // task="open my inbox" + target="Send" → confirm (no intent match)
476
+ // This keeps the safety layer protective against hallucinated
477
+ // destructive clicks while letting legitimate user-requested
478
+ // actions through. Pattern-matched, not model-specific.
479
+ if (ctx.userTaskText && pattern.test(ctx.userTaskText)) {
480
+ logger_1.logger.info('safety.intent_match.bypass', {
481
+ tool: ctx.tool,
482
+ targetLabel: ctx.targetLabel,
483
+ pattern: pattern.source,
484
+ correlationId,
485
+ });
486
+ return emit({ decision: 'allow', tier: 'input' });
487
+ }
488
+ return emit({
489
+ decision: 'confirm',
490
+ tier: 'destructive',
491
+ reason: `target "${ctx.targetLabel}" matches destructive pattern ${pattern.source}`,
492
+ });
493
+ }
494
+ }
495
+ }
496
+ // 6. Sensitive-app elevation: clicks/typing inside email/banking/messaging
497
+ // apps. The previous implementation here only LOGGED — the code comment
498
+ // promised elevation but the function fell through to allow. That left
499
+ // a real gap: an agent could click anywhere in Outlook / 1Password /
500
+ // Mail with no target label and the safety layer treated it as a
501
+ // plain Input action.
502
+ //
503
+ // New policy:
504
+ // - Sensitive app + click-family tool + NO/EMPTY target label
505
+ // → `confirm` (we can't tell if this lands on "Send" / "Delete")
506
+ // - Sensitive app + click-family tool + non-destructive target label
507
+ // → allow (e.g. invoke_element name="Reply" is fine; destructive
508
+ // target names are already caught by step 5 above)
509
+ // - Sensitive app + non-click tool (read, screenshot, focus, etc.)
510
+ // → allow (reads stay free)
511
+ if (ctx.activeApp && app_categories_1.SENSITIVE_APPS_PATTERN.test(ctx.activeApp)) {
512
+ const clickFamily = ['smart_click', 'cdp_click', 'mouse_click', 'a11y_click', 'click', 'invoke_element'];
513
+ if (clickFamily.includes(ctx.tool)) {
514
+ const labelEmpty = !ctx.targetLabel || String(ctx.targetLabel).trim().length === 0;
515
+ if (labelEmpty) {
516
+ logger_1.logger.debug('safety.sensitive_app.elevated', { app: ctx.activeApp, tool: ctx.tool, correlationId });
517
+ return emit({
518
+ decision: 'confirm',
519
+ tier: 'destructive',
520
+ reason: `Sensitive app (${ctx.activeApp}) + ${ctx.tool} with no target label — cannot verify the action isn't destructive (Send/Delete/Transfer). Ask the user.`,
521
+ });
522
+ }
523
+ // Has a label and it didn't match a destructive pattern in step 5 — let it through.
524
+ logger_1.logger.debug('safety.sensitive_app.allowed_with_label', { app: ctx.activeApp, tool: ctx.tool, label: ctx.targetLabel, correlationId });
525
+ }
526
+ }
527
+ // 7. Default allow at input tier.
528
+ return emit({ decision: 'allow', tier });
529
+ }
530
+ /**
531
+ * Convenience predicate. Returns true if the decision allows the action to
532
+ * proceed without user confirmation.
533
+ */
534
+ function isAllowed(d) {
535
+ return d.decision === 'allow';
536
+ }
537
+ // ── PR6: canonical evaluate() signature ─────────────────────────────────────
538
+ /**
539
+ * Canonical single safety gate used by every call site (PR6).
540
+ *
541
+ * Accepts the PR6 interface shape:
542
+ * { toolName, args, ctx? }
543
+ *
544
+ * Returns a `SafetyDecision` with `allow: boolean` so callers don't need to
545
+ * inspect the legacy `decision` string. The gate is the ONLY place that
546
+ * decides allow/block — no inline `if (toolName === 'desktop_screenshot')`
547
+ * branching anywhere else.
548
+ *
549
+ * Call sites:
550
+ * 1. `src/core/agent-loop/agent.ts` — agent loop, every tool call
551
+ * 2. `src/tools/safety-gate.ts` — MCP wrapper + REST execute middleware
552
+ *
553
+ * The `safetyTier` field is read from the tool's `ToolDefinition.safetyTier`
554
+ * by the caller before passing here; when absent the gate falls back to the
555
+ * internal TOOL_TIER name-lookup table.
556
+ */
557
+ function evaluateInput(input) {
558
+ const legacyCtx = {
559
+ tool: input.toolName,
560
+ args: input.args,
561
+ targetLabel: input.ctx?.targetLabel,
562
+ activeApp: input.ctx?.activeApp,
563
+ userTaskText: input.ctx?.userIntent,
564
+ toolSafetyTier: input.safetyTier,
565
+ };
566
+ return toSafetyDecision(evaluate(legacyCtx));
567
+ }
568
+ //# sourceMappingURL=safety.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safety.js","sourceRoot":"","sources":["../../src/core/safety.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;AAqaH,4BAwKC;AAMD,8BAEC;AAuBD,sCAmBC;AA7nBD,sEAAiF;AACjF,mDAAgD;AAChD,6DAA+D;AAC/D,qDAA4E;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS;IACzC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB;IAC7D,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS;IAC7C,4EAA4E;IAC5E,4EAA4E;IAC5E,aAAa;CACd,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,GAAY;IAC/B,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACnE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACrC,CAAC;AAmCD,gFAAgF;AAEhF,oDAAoD;AACpD,SAAS,aAAa,CAAC,CAAO;IAC5B,QAAQ,CAAC,EAAE,CAAC;QACV,KAAK,MAAM,CAAC,CAAQ,OAAO,CAAC,CAAC;QAC7B,KAAK,OAAO,CAAC,CAAO,OAAO,CAAC,CAAC;QAC7B,KAAK,aAAa,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7B,KAAK,QAAQ,CAAC,CAAM,OAAO,CAAC,CAAC;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