@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,97 @@
1
+ /**
2
+ * project-mcp.ts — Project System B (agent-loop) UnifiedTools onto the
3
+ * System A (MCP/REST) ToolDefinition surface.
4
+ *
5
+ * PURELY ADDITIVE. This module is not yet imported by any production path.
6
+ * Wire-in happens in a later step (Step 3).
7
+ *
8
+ * The three public exports:
9
+ *
10
+ * jsonSchemaToParamDefs(inputSchema)
11
+ * Convert a UnifiedTool.inputSchema (raw JSON Schema object) into the
12
+ * Record<string, ParameterDef> shape ToolDefinition expects.
13
+ *
14
+ * toolContextToAgent(ctx)
15
+ * Build a synthetic AgentToolContext from a ToolContext so a projected
16
+ * handler can call the System B execute() function.
17
+ *
18
+ * unifiedToToolResult(r)
19
+ * Map a UnifiedToolResult back to the ToolResult shape the MCP surface
20
+ * expects, including base64-encoding any screenshot.
21
+ *
22
+ * projectToToolDefinition(t)
23
+ * Assemble a complete ToolDefinition from a UnifiedTool + TOOL_META.
24
+ * The handler bridges ToolContext → AgentToolContext → UnifiedToolResult →
25
+ * ToolResult in a single async call.
26
+ */
27
+ import type { UnifiedTool, UnifiedToolResult, AgentToolContext } from './types';
28
+ import type { ToolDefinition, ToolContext, ToolResult, ParameterDef } from '../../tools/types';
29
+ /**
30
+ * Convert a UnifiedTool JSON-Schema inputSchema into the
31
+ * Record<string, ParameterDef> shape that ToolDefinition.parameters expects.
32
+ *
33
+ * Supported JSON Schema property types: "string" | "number" | "boolean" | "array".
34
+ * Properties missing a supported type default to "string" with a note.
35
+ * The `required` array in the schema is used to set ParameterDef.required.
36
+ * `enum` is preserved when all values are strings.
37
+ *
38
+ * Description resolution order (per parameter):
39
+ * 1. System B inputSchema property's own description (if non-empty).
40
+ * 2. `paramDescriptions[key]` harvested from the corresponding System A
41
+ * ToolDefinition (passed as the optional second argument).
42
+ * 3. Empty string fallback.
43
+ *
44
+ * @param inputSchema - The raw JSON Schema object from UnifiedTool.inputSchema.
45
+ * @param paramDescriptions - Optional per-parameter fallback descriptions
46
+ * harvested from the System A ToolDefinition (TOOL_META[name].paramDescriptions).
47
+ * @returns A Record mapping parameter names to ParameterDef instances.
48
+ */
49
+ export declare function jsonSchemaToParamDefs(inputSchema: UnifiedTool['inputSchema'], paramDescriptions?: Record<string, string>): Record<string, ParameterDef>;
50
+ /**
51
+ * Build a synthetic AgentToolContext from a ToolContext.
52
+ *
53
+ * Called once per projected handler invocation. Awaits
54
+ * ctx.ensureInitialized() first to guarantee subsystems are ready
55
+ * before the System B tool execute() accesses ctx.platform.*.
56
+ *
57
+ * Fields that are absent from ToolContext (task, mode, screenshotsCaptured)
58
+ * are given safe neutral defaults so the System B tools don't crash.
59
+ *
60
+ * @param ctx - The ToolContext injected by the MCP server / REST handler.
61
+ * @returns A fully populated AgentToolContext ready for System B tool execute().
62
+ */
63
+ export declare function toolContextToAgent(ctx: ToolContext): Promise<AgentToolContext>;
64
+ /**
65
+ * Convert a UnifiedToolResult to the ToolResult shape the MCP surface expects.
66
+ *
67
+ * - success=false maps to isError=true.
68
+ * - screenshot (ScreenshotResult with a Buffer) is base64-encoded and returned
69
+ * as { data, mimeType } in the image field — mirroring how the agent loop
70
+ * and the existing MCP server serialize images.
71
+ * - All other UnifiedToolResult fields (stop, terminalExit, targetLabel) are
72
+ * consumed internally and not forwarded — they are agent-loop concerns.
73
+ *
74
+ * @param r - The UnifiedToolResult from a System B tool execute() call.
75
+ * @returns A ToolResult ready for the MCP / REST transport.
76
+ */
77
+ export declare function unifiedToToolResult(r: UnifiedToolResult): ToolResult;
78
+ /**
79
+ * Project a System B UnifiedTool into a System A ToolDefinition.
80
+ *
81
+ * Assembles:
82
+ * - name: TOOL_META[t.name].mcpName ?? t.name
83
+ * - description: t.description (System B already has good descriptions)
84
+ * - parameters: via jsonSchemaToParamDefs(t.inputSchema)
85
+ * - category, compactGroup, safetyTier, costClass, cheaperAlternatives: from TOOL_META
86
+ * - handler: bridges ToolContext → AgentToolContext → t.execute() → ToolResult
87
+ *
88
+ * Terminal actions (done, give_up, cannot_read) and vision compound tools
89
+ * (mouse, keyboard, window) should NOT be passed to this function — they have
90
+ * no counterpart on the MCP surface or have their own projection path.
91
+ *
92
+ * Throws if t.name has no TOOL_META entry (enforced by the coverage test).
93
+ *
94
+ * @param t - A UnifiedTool from buildUnifiedTools().
95
+ * @returns A fully populated ToolDefinition ready for getTools() or direct MCP use.
96
+ */
97
+ export declare function projectToToolDefinition(t: UnifiedTool): ToolDefinition;
@@ -0,0 +1,253 @@
1
+ "use strict";
2
+ /**
3
+ * project-mcp.ts — Project System B (agent-loop) UnifiedTools onto the
4
+ * System A (MCP/REST) ToolDefinition surface.
5
+ *
6
+ * PURELY ADDITIVE. This module is not yet imported by any production path.
7
+ * Wire-in happens in a later step (Step 3).
8
+ *
9
+ * The three public exports:
10
+ *
11
+ * jsonSchemaToParamDefs(inputSchema)
12
+ * Convert a UnifiedTool.inputSchema (raw JSON Schema object) into the
13
+ * Record<string, ParameterDef> shape ToolDefinition expects.
14
+ *
15
+ * toolContextToAgent(ctx)
16
+ * Build a synthetic AgentToolContext from a ToolContext so a projected
17
+ * handler can call the System B execute() function.
18
+ *
19
+ * unifiedToToolResult(r)
20
+ * Map a UnifiedToolResult back to the ToolResult shape the MCP surface
21
+ * expects, including base64-encoding any screenshot.
22
+ *
23
+ * projectToToolDefinition(t)
24
+ * Assemble a complete ToolDefinition from a UnifiedTool + TOOL_META.
25
+ * The handler bridges ToolContext → AgentToolContext → UnifiedToolResult →
26
+ * ToolResult in a single async call.
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.jsonSchemaToParamDefs = jsonSchemaToParamDefs;
30
+ exports.toolContextToAgent = toolContextToAgent;
31
+ exports.unifiedToToolResult = unifiedToToolResult;
32
+ exports.projectToToolDefinition = projectToToolDefinition;
33
+ const tool_meta_1 = require("./tool-meta");
34
+ const reactive_check_1 = require("../sense/reactive-check");
35
+ const ocr_engine_1 = require("../../platform/ocr-engine");
36
+ // Lazy OCR singleton for ocr_contains assertions in MCP-route expect checks.
37
+ let _mcpOcr = null;
38
+ function mcpOcr() { return (_mcpOcr ??= new ocr_engine_1.OcrEngine()); }
39
+ // ─── Helpers ─────────────────────────────────────────────────────────────────
40
+ /**
41
+ * Convert a UnifiedTool JSON-Schema inputSchema into the
42
+ * Record<string, ParameterDef> shape that ToolDefinition.parameters expects.
43
+ *
44
+ * Supported JSON Schema property types: "string" | "number" | "boolean" | "array".
45
+ * Properties missing a supported type default to "string" with a note.
46
+ * The `required` array in the schema is used to set ParameterDef.required.
47
+ * `enum` is preserved when all values are strings.
48
+ *
49
+ * Description resolution order (per parameter):
50
+ * 1. System B inputSchema property's own description (if non-empty).
51
+ * 2. `paramDescriptions[key]` harvested from the corresponding System A
52
+ * ToolDefinition (passed as the optional second argument).
53
+ * 3. Empty string fallback.
54
+ *
55
+ * @param inputSchema - The raw JSON Schema object from UnifiedTool.inputSchema.
56
+ * @param paramDescriptions - Optional per-parameter fallback descriptions
57
+ * harvested from the System A ToolDefinition (TOOL_META[name].paramDescriptions).
58
+ * @returns A Record mapping parameter names to ParameterDef instances.
59
+ */
60
+ function jsonSchemaToParamDefs(inputSchema, paramDescriptions) {
61
+ const result = {};
62
+ const props = inputSchema.properties ?? {};
63
+ const required = new Set(inputSchema.required ?? []);
64
+ for (const [key, raw] of Object.entries(props)) {
65
+ const prop = raw;
66
+ const rawType = typeof prop.type === 'string' ? prop.type : 'string';
67
+ // Narrow to ParameterDef's allowed types; fall back to 'string'.
68
+ const type = rawType === 'number' || rawType === 'boolean' || rawType === 'array' ? rawType : 'string';
69
+ // Prefer System B's own description; fall back to harvested System A description.
70
+ const ownDescription = typeof prop.description === 'string' ? prop.description : '';
71
+ const description = ownDescription || paramDescriptions?.[key] || '';
72
+ const def = {
73
+ type,
74
+ description,
75
+ required: required.has(key),
76
+ };
77
+ // Preserve the element schema for array params (ParameterDef.items),
78
+ // e.g. verify's `assertions: {type:'array', items:{type:'object'}}`.
79
+ if (type === 'array' && prop.items && typeof prop.items === 'object') {
80
+ def.items = prop.items;
81
+ }
82
+ // Preserve enum when all values are strings (ParameterDef only supports string enum).
83
+ if (Array.isArray(prop.enum)) {
84
+ const strEnum = prop.enum.filter(v => typeof v === 'string');
85
+ if (strEnum.length > 0)
86
+ def.enum = strEnum;
87
+ }
88
+ // Preserve numeric constraints.
89
+ if (typeof prop.minimum === 'number')
90
+ def.minimum = prop.minimum;
91
+ if (typeof prop.maximum === 'number')
92
+ def.maximum = prop.maximum;
93
+ result[key] = def;
94
+ }
95
+ return result;
96
+ }
97
+ /**
98
+ * Build a synthetic AgentToolContext from a ToolContext.
99
+ *
100
+ * Called once per projected handler invocation. Awaits
101
+ * ctx.ensureInitialized() first to guarantee subsystems are ready
102
+ * before the System B tool execute() accesses ctx.platform.*.
103
+ *
104
+ * Fields that are absent from ToolContext (task, mode, screenshotsCaptured)
105
+ * are given safe neutral defaults so the System B tools don't crash.
106
+ *
107
+ * @param ctx - The ToolContext injected by the MCP server / REST handler.
108
+ * @returns A fully populated AgentToolContext ready for System B tool execute().
109
+ */
110
+ async function toolContextToAgent(ctx) {
111
+ // Guarantee all subsystems are initialized (lazy init gate).
112
+ await ctx.ensureInitialized();
113
+ // Derive the platform adapter. The `platform` field was added in Tranche 1A
114
+ // and is present on every modern ToolContext. Guard defensively for tests.
115
+ const platform = ctx.platform;
116
+ if (!platform) {
117
+ throw new Error('toolContextToAgent: ctx.platform is not initialized. ' +
118
+ 'Ensure clawdcursor is running with a supported OS adapter.');
119
+ }
120
+ // Derive screen dimensions. System B tools use ctx.screen for coordinate math.
121
+ // ToolContext exposes getScreenSize() on ctx.desktop (NativeDesktop).
122
+ let screen;
123
+ try {
124
+ const size = ctx.desktop.getScreenSize();
125
+ const msf = ctx.getMouseScaleFactor(); // image → logical (mouse) scale
126
+ const ssf = ctx.getScreenshotScaleFactor(); // image → physical pixel scale
127
+ // msf ≈ physicalWidth / imageWidth (typically 1 on standard, 2 on HiDPI).
128
+ // We reconstruct logical and physical from physical size + ratio.
129
+ const physicalWidth = size.width;
130
+ const physicalHeight = size.height;
131
+ // Logical = physical / DPI ratio. DPI ratio = physical / logical = ssf / msf.
132
+ // For the typical case both scale factors are 1, leaving logical == physical.
133
+ const dpiRatio = ssf > 0 ? ssf / msf : 1;
134
+ const logicalWidth = dpiRatio > 0 ? Math.round(physicalWidth / dpiRatio) : physicalWidth;
135
+ const logicalHeight = dpiRatio > 0 ? Math.round(physicalHeight / dpiRatio) : physicalHeight;
136
+ screen = { logicalWidth, logicalHeight, physicalWidth, physicalHeight, dpiRatio };
137
+ }
138
+ catch {
139
+ // Fallback to a sane default if getScreenSize throws (e.g. in tests).
140
+ screen = { logicalWidth: 1920, logicalHeight: 1080, physicalWidth: 1920, physicalHeight: 1080, dpiRatio: 1 };
141
+ }
142
+ return {
143
+ platform,
144
+ task: '', // No task context available in the MCP surface layer.
145
+ screen,
146
+ screenshotsCaptured: { n: 0 },
147
+ cdp: ctx.cdp ?? null,
148
+ targetWindow: undefined,
149
+ activeApp: undefined,
150
+ uiMaps: ctx.uiMaps,
151
+ };
152
+ }
153
+ /**
154
+ * Convert a UnifiedToolResult to the ToolResult shape the MCP surface expects.
155
+ *
156
+ * - success=false maps to isError=true.
157
+ * - screenshot (ScreenshotResult with a Buffer) is base64-encoded and returned
158
+ * as { data, mimeType } in the image field — mirroring how the agent loop
159
+ * and the existing MCP server serialize images.
160
+ * - All other UnifiedToolResult fields (stop, terminalExit, targetLabel) are
161
+ * consumed internally and not forwarded — they are agent-loop concerns.
162
+ *
163
+ * @param r - The UnifiedToolResult from a System B tool execute() call.
164
+ * @returns A ToolResult ready for the MCP / REST transport.
165
+ */
166
+ function unifiedToToolResult(r) {
167
+ const result = {
168
+ text: r.text,
169
+ isError: !r.success,
170
+ };
171
+ if (r.screenshot) {
172
+ // ScreenshotResult.buffer is a Buffer containing raw image bytes (PNG per
173
+ // the platform/types.ts interface; the agent loop captures via screenshot()
174
+ // which returns PNG). The MCP image field expects base64-encoded string data.
175
+ result.image = {
176
+ data: r.screenshot.buffer.toString('base64'),
177
+ mimeType: 'image/png',
178
+ };
179
+ }
180
+ return result;
181
+ }
182
+ /**
183
+ * Project a System B UnifiedTool into a System A ToolDefinition.
184
+ *
185
+ * Assembles:
186
+ * - name: TOOL_META[t.name].mcpName ?? t.name
187
+ * - description: t.description (System B already has good descriptions)
188
+ * - parameters: via jsonSchemaToParamDefs(t.inputSchema)
189
+ * - category, compactGroup, safetyTier, costClass, cheaperAlternatives: from TOOL_META
190
+ * - handler: bridges ToolContext → AgentToolContext → t.execute() → ToolResult
191
+ *
192
+ * Terminal actions (done, give_up, cannot_read) and vision compound tools
193
+ * (mouse, keyboard, window) should NOT be passed to this function — they have
194
+ * no counterpart on the MCP surface or have their own projection path.
195
+ *
196
+ * Throws if t.name has no TOOL_META entry (enforced by the coverage test).
197
+ *
198
+ * @param t - A UnifiedTool from buildUnifiedTools().
199
+ * @returns A fully populated ToolDefinition ready for getTools() or direct MCP use.
200
+ */
201
+ function projectToToolDefinition(t) {
202
+ const meta = tool_meta_1.TOOL_META[t.name];
203
+ if (!meta) {
204
+ throw new Error(`projectToToolDefinition: no TOOL_META entry for System B tool "${t.name}". ` +
205
+ 'Add an entry to src/core/agent-loop/tool-meta.ts.');
206
+ }
207
+ const name = meta.mcpName ?? t.name;
208
+ const parameters = jsonSchemaToParamDefs(t.inputSchema, meta.paramDescriptions);
209
+ const handler = async (params, ctx) => {
210
+ const agentCtx = await toolContextToAgent(ctx);
211
+ let result = await t.execute(params, agentCtx);
212
+ const executed = result.success;
213
+ // Honor a caller-supplied `expect` assertion array. The projected schemas
214
+ // advertise it (same as the agent loop), so an external agent passing
215
+ // post-conditions over MCP must get them VERIFIED — they were silently
216
+ // dropped before (audit 2026-06-10, finding E). Hard check only: the
217
+ // loop-side soft "no observable change" net needs per-turn fingerprints
218
+ // the MCP route doesn't track.
219
+ if (params.expect !== undefined && params.expect !== null) {
220
+ const reactive = await (0, reactive_check_1.reactiveCheck)({
221
+ expect: params.expect,
222
+ toolText: result.text,
223
+ toolSuccess: result.success,
224
+ changesScreen: false,
225
+ observedChange: true,
226
+ adapter: agentCtx.platform,
227
+ ocrText: async () => (await mcpOcr().recognizeScreen()).fullText ?? '',
228
+ }).catch(() => null);
229
+ if (reactive)
230
+ result = { ...result, success: reactive.success, text: reactive.text };
231
+ }
232
+ // Invalidate the shared UIMap holder only when the screen-changing action
233
+ // actually TOOK (pre-expect outcome — a DEVIATION still means the input
234
+ // was dispatched). A rejected el_NN ref / failed dispatch changed nothing
235
+ // and must not stale a still-valid map (parity with the agent loop's
236
+ // outcome-gated invalidation; audit finding E/A1).
237
+ if (t.changesScreen && executed)
238
+ ctx.uiMaps?.invalidate();
239
+ return unifiedToToolResult(result);
240
+ };
241
+ return {
242
+ name,
243
+ description: t.description,
244
+ parameters,
245
+ category: meta.category,
246
+ compactGroup: meta.compactGroup,
247
+ safetyTier: meta.safetyTier,
248
+ costClass: meta.costClass,
249
+ cheaperAlternatives: meta.cheaperAlternatives,
250
+ handler,
251
+ };
252
+ }
253
+ //# sourceMappingURL=project-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-mcp.js","sourceRoot":"","sources":["../../../src/core/agent-loop/project-mcp.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;AAkCH,sDAwCC;AAeD,gDA8CC;AAeD,kDAiBC;AAqBD,0DAyDC;AAjPD,2CAAwC;AACxC,4DAAwD;AACxD,0DAAsD;AAEtD,6EAA6E;AAC7E,IAAI,OAAO,GAAqB,IAAI,CAAC;AACrC,SAAS,MAAM,KAAgB,OAAO,CAAC,OAAO,KAAK,IAAI,sBAAS,EAAE,CAAC,CAAC,CAAC,CAAC;AAEtE,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,qBAAqB,CACnC,WAAuC,EACvC,iBAA0C;IAE1C,MAAM,MAAM,GAAiC,EAAE,CAAC;IAChD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,IAAI,EAAE,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,GAA8B,CAAC;QA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C,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;YACrB,IAAI,QAAQ;gBAAE,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;QACvF,CAAC;QACD,0EAA0E;QAC1E,wEAAwE;QACxE,0EAA0E;QAC1E,qEAAqE;QACrE,mDAAmD;QACnD,IAAI,CAAC,CAAC,aAAa,IAAI,QAAQ;YAAE,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;QAC1D,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,WAAW,EAAE,CAAC,CAAC,WAAW;QAC1B,UAAU;QACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,YAAY,EAAE,IAAI,CAAC,YAAY;QAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;QAC7C,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Unified-agent system prompt + perception renderer.
3
+ *
4
+ * A single compact prompt (~70 lines) for the thin agent loop: accessibility-
5
+ * first, screenshot only on demand. No per-mode variation, no app-specific
6
+ * rules, no model names — the autonomous pipeline and its blind/hybrid/vision
7
+ * rungs were removed in v1.0.0 (a capable model is its own pipeline).
8
+ *
9
+ * Prompt-injection defense: screen content is wrapped in
10
+ * `<untrusted-screen-content>` delimiters and the prompt explicitly tells
11
+ * the model to treat anything inside as data, never as instructions.
12
+ */
13
+ import type { AgentStep } from './types';
14
+ import type { Snapshot } from '../sense/types';
15
+ /**
16
+ * Wrap screen content in explicit delimiters to make prompt-injection defense
17
+ * auditable. Callers feed this into the user message, not the system prompt.
18
+ */
19
+ export declare function wrapUntrustedScreenContent(text: string): string;
20
+ /**
21
+ * Build the system prompt. Compact; kept under budget so the token budget
22
+ * goes to snapshots + tool results, not rules.
23
+ *
24
+ * The thin agent loop is accessibility-first: screenshot only on demand.
25
+ */
26
+ export declare function buildSystemPrompt(): string;
27
+ /**
28
+ * Render a Snapshot as compact text for the user message. Ranks by
29
+ * role-priority (rank.ts) so the most actionable elements survive
30
+ * truncation. Respects the secure-field redaction in the Snapshot type.
31
+ *
32
+ * Zero app-specific rules. A new LOB app follows the same a11y contract
33
+ * and renders cleanly.
34
+ */
35
+ export declare function renderSnapshot(snapshot: Snapshot, opts?: {
36
+ elementCap?: number;
37
+ screenWidth?: number;
38
+ screenHeight?: number;
39
+ focusProcessId?: number;
40
+ }): string;
41
+ /**
42
+ * Build a compact recent-history line block for the user message.
43
+ * Keeps only the last `keep` turns to stay under the token budget.
44
+ */
45
+ export declare function renderHistory(steps: AgentStep[], keep?: number): string;