@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,245 @@
1
+ "use strict";
2
+ /**
3
+ * Agent — thin entry point that drives the desktop using the unified
4
+ * agent loop (runAgent) with the configured model. The pipeline morph
5
+ * machinery has been removed; a capable configured model self-drives
6
+ * the full toolbox.
7
+ *
8
+ * Construction is intentionally minimal — the agent owns the desktop /
9
+ * a11y / OCR primitives and forwards everything else to runAgent.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Agent = void 0;
13
+ const native_desktop_1 = require("../platform/native-desktop");
14
+ const accessibility_1 = require("../platform/accessibility");
15
+ const ocr_engine_1 = require("../platform/ocr-engine");
16
+ const doctor_1 = require("../surface/doctor");
17
+ const agent_1 = require("./agent-loop/agent");
18
+ const platform_1 = require("../platform");
19
+ const banner_1 = require("./banner");
20
+ /**
21
+ * Provider-agnostic Anthropic-endpoint detector. Anthropic native endpoints
22
+ * use the `/messages` API shape; everything else (OpenAI, Groq, Together,
23
+ * Kimi, DeepSeek, Ollama, Gemini-via-OpenAI-compat) uses `/chat/completions`.
24
+ * Local endpoints and Ollama always take the OpenAI-compat path even if their
25
+ * host happens to match an Anthropic-ish substring.
26
+ */
27
+ function isAnthropicEndpoint(baseUrl) {
28
+ if (!baseUrl)
29
+ return false;
30
+ if (baseUrl.includes('localhost'))
31
+ return false;
32
+ if (baseUrl.includes('11434'))
33
+ return false; // Ollama default port
34
+ return baseUrl.includes('anthropic.com');
35
+ }
36
+ class Agent {
37
+ desktop;
38
+ a11y;
39
+ ocrEngine;
40
+ config;
41
+ resolvedConfig = null;
42
+ hasApiKey;
43
+ state = {
44
+ status: 'idle',
45
+ stepsCompleted: 0,
46
+ stepsTotal: 0,
47
+ };
48
+ aborted = false;
49
+ /** Cancels the in-flight LLM fetch on abort(). Fresh per executeTask(). */
50
+ abortCtl = null;
51
+ /** The in-flight task promise — lets /stop wait for the abort to settle. */
52
+ currentRun = null;
53
+ taskExecutionLocked = false;
54
+ constructor(config, resolvedConfig) {
55
+ this.config = config;
56
+ this.resolvedConfig = resolvedConfig ?? null;
57
+ this.desktop = new native_desktop_1.NativeDesktop(config);
58
+ this.a11y = new accessibility_1.AccessibilityBridge();
59
+ this.ocrEngine = new ocr_engine_1.OcrEngine();
60
+ // hasApiKey gates the offline-mode banner — true if any cloud key is
61
+ // configured. Local LLM (Ollama) is always available via the loop,
62
+ // so absence of cloud keys just means we'll print an offline notice.
63
+ const hasCloudKey = !!(config.ai.apiKey && config.ai.apiKey.length > 0);
64
+ const hasVisionKey = !!(config.ai.visionApiKey && config.ai.visionApiKey.length > 0);
65
+ this.hasApiKey = hasCloudKey || hasVisionKey;
66
+ if (!this.hasApiKey) {
67
+ console.log(`⚡ Running in offline mode (no API key).`);
68
+ console.log(` To unlock AI, set AI_API_KEY (or run: clawdcursor doctor)`);
69
+ }
70
+ }
71
+ async connect() {
72
+ await this.desktop.connect();
73
+ // Warm up the PSRunner bridge so assembly loading happens in background
74
+ this.a11y.warmup().catch(() => { });
75
+ // Touch the OCR engine so any first-call latency is paid up front.
76
+ void this.ocrEngine;
77
+ }
78
+ /** Safety-net timeout — only fires if task is truly stuck (stagnation + abort didn't catch it) */
79
+ static TASK_TIMEOUT_MS = 12 * 60 * 1000; // 12 minutes
80
+ async executeTask(task) {
81
+ // Atomic concurrency guard — boolean lock prevents TOCTOU race
82
+ // where two simultaneous /task requests both see status === 'idle'
83
+ if (this.taskExecutionLocked || this.state.status !== 'idle') {
84
+ return {
85
+ success: false,
86
+ steps: [{ action: 'error', description: 'Agent is busy', success: false, timestamp: Date.now() }],
87
+ duration: 0,
88
+ };
89
+ }
90
+ this.taskExecutionLocked = true;
91
+ this.aborted = false;
92
+ this.abortCtl = new AbortController();
93
+ const startTime = Date.now();
94
+ // Wrap the entire task with a global wall-clock timeout.
95
+ let timeoutHandle = null;
96
+ const timeoutPromise = new Promise((resolve) => {
97
+ timeoutHandle = setTimeout(() => {
98
+ this.aborted = true;
99
+ console.warn(`\n⏱ Task timed out after ${Agent.TASK_TIMEOUT_MS / 60000} minutes`);
100
+ resolve({
101
+ success: false,
102
+ steps: [{ action: 'error', description: `Task timed out after ${Agent.TASK_TIMEOUT_MS / 60000} minutes`, success: false, timestamp: Date.now() }],
103
+ duration: Date.now() - startTime,
104
+ });
105
+ }, Agent.TASK_TIMEOUT_MS);
106
+ });
107
+ // Transparency: the on-screen banner stays up for the WHOLE task so a
108
+ // human at the machine always knows automation is live (and can
109
+ // double-click it to stop). Pin/unpin — tool-activity touches must not
110
+ // hide it mid-task.
111
+ banner_1.controlBanner.pin();
112
+ try {
113
+ this.currentRun = this._executeTask(task, startTime);
114
+ return await Promise.race([this.currentRun, timeoutPromise]);
115
+ }
116
+ finally {
117
+ if (timeoutHandle !== null)
118
+ clearTimeout(timeoutHandle);
119
+ this.taskExecutionLocked = false;
120
+ this.currentRun = null;
121
+ banner_1.controlBanner.unpin();
122
+ }
123
+ }
124
+ /**
125
+ * Wait until the in-flight task settles (or the timeout elapses). Used by
126
+ * the /stop path so an abort can print its "aborted by user"
127
+ * acknowledgment before the process exits — previously stop was a hard
128
+ * kill 500ms after the HTTP response, mid-turn, with zero output.
129
+ */
130
+ async waitForIdle(timeoutMs) {
131
+ const run = this.currentRun;
132
+ if (!run)
133
+ return;
134
+ await Promise.race([
135
+ run.then(() => undefined, () => undefined),
136
+ new Promise(resolve => setTimeout(resolve, timeoutMs)),
137
+ ]);
138
+ }
139
+ /**
140
+ * Thin task executor — runs the unified agent loop with the configured model.
141
+ * No pipeline morph, no mode ladder, no verifier. A capable model self-drives
142
+ * the full toolbox.
143
+ */
144
+ async _executeTask(task, startTime) {
145
+ // Resolve the LLM configuration from the disk config + CLI overlay.
146
+ const pipelineConfig = (0, doctor_1.loadPipelineConfig)(this.resolvedConfig);
147
+ const hasTextModel = !!(pipelineConfig?.layer2.model && pipelineConfig.layer2.baseUrl);
148
+ const hasVisionModel = !!(pipelineConfig?.layer3?.model && pipelineConfig?.layer3?.baseUrl);
149
+ // Build direct LLM configs for the unified agent. Prefer text; fall back
150
+ // to vision model if text is absent (vision models handle tool_use too).
151
+ const textConfig = hasTextModel && pipelineConfig
152
+ ? {
153
+ baseUrl: pipelineConfig.layer2.baseUrl,
154
+ model: pipelineConfig.layer2.model,
155
+ apiKey: pipelineConfig.layer2.apiKey || pipelineConfig.apiKey || '',
156
+ isAnthropic: isAnthropicEndpoint(pipelineConfig.layer2.baseUrl),
157
+ maxTokens: 1024,
158
+ }
159
+ : undefined;
160
+ const visionLayer = pipelineConfig?.layer3;
161
+ const visionConfig = hasVisionModel && visionLayer && pipelineConfig
162
+ ? {
163
+ baseUrl: visionLayer.baseUrl,
164
+ model: visionLayer.model,
165
+ apiKey: visionLayer.apiKey || pipelineConfig.apiKey || '',
166
+ isAnthropic: isAnthropicEndpoint(visionLayer.baseUrl),
167
+ maxTokens: 1024,
168
+ }
169
+ : undefined;
170
+ if (!hasTextModel && !hasVisionModel) {
171
+ console.log('⚡ No AI model configured. Run `clawdcursor doctor` to configure a provider.');
172
+ }
173
+ // Clear lastResult at task start so a poller can't read a stale result
174
+ // from a prior run while a new task is in flight.
175
+ this.state = { ...this.state, status: 'thinking', currentTask: task, stepsCompleted: 0, stepsTotal: 0, lastResult: undefined };
176
+ // Get the platform adapter. Lazy-initialised per call (cheap re-call).
177
+ const adapter = await (0, platform_1.getPlatform)();
178
+ // Resolve CDP driver if wired externally.
179
+ const cdp = this.cdpDriver ?? null;
180
+ // Resolve UIMapHolder if wired externally (by cli.ts daemon setup).
181
+ const uiMaps = this.uiMapHolder ?? undefined;
182
+ // Run the thin agent loop with the FULL toolbox.
183
+ // The agent loop prefers a11y-first (cheapest) and only calls screenshot
184
+ // when it genuinely needs pixels.
185
+ const agentResult = await (0, agent_1.runAgent)({
186
+ task,
187
+ isAborted: () => this.aborted,
188
+ abortSignal: this.abortCtl?.signal,
189
+ }, {
190
+ adapter,
191
+ llm: { text: textConfig, vision: visionConfig },
192
+ cdp,
193
+ uiMaps,
194
+ });
195
+ const steps = agentResult.steps.length > 0
196
+ ? agentResult.steps.map(s => ({
197
+ action: s.toolName,
198
+ description: s.result.text,
199
+ success: s.result.success,
200
+ timestamp: Date.now(),
201
+ layer: 'unified',
202
+ method: s.toolName,
203
+ latencyMs: s.durationMs,
204
+ }))
205
+ : [{
206
+ action: agentResult.exit,
207
+ description: agentResult.text,
208
+ success: agentResult.success,
209
+ timestamp: Date.now(),
210
+ layer: 'unified',
211
+ }];
212
+ if (agentResult.text) {
213
+ console.log(` ${agentResult.text}`);
214
+ }
215
+ const taskResult = {
216
+ success: agentResult.success,
217
+ steps,
218
+ duration: Date.now() - startTime,
219
+ };
220
+ this.state = { ...this.state, status: 'idle', lastResult: taskResult };
221
+ return taskResult;
222
+ }
223
+ abort() {
224
+ this.aborted = true;
225
+ // Cancel the in-flight LLM fetch too — the cooperative flag alone only
226
+ // takes effect at the next loop checkpoint, i.e. after the current
227
+ // (up to 45s) LLM call returns.
228
+ this.abortCtl?.abort();
229
+ this.state = { status: 'idle', stepsCompleted: 0, stepsTotal: 0 };
230
+ }
231
+ getState() {
232
+ return { ...this.state };
233
+ }
234
+ getDesktop() {
235
+ return this.desktop;
236
+ }
237
+ getA11y() {
238
+ return this.a11y;
239
+ }
240
+ disconnect() {
241
+ this.desktop.disconnect();
242
+ }
243
+ }
244
+ exports.Agent = Agent;
245
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/core/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,+DAA2D;AAC3D,6DAAgE;AAChE,uDAAmD;AACnD,8CAAuD;AACvD,8CAA8C;AAC9C,0CAA0C;AAC1C,qCAAyC;AAIzC;;;;;;GAMG;AACH,SAAS,mBAAmB,CAAC,OAA2B;IACtD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;QAAE,OAAO,KAAK,CAAC;IAChD,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,sBAAsB;IACnE,OAAO,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;AAC3C,CAAC;AAED,MAAa,KAAK;IACR,OAAO,CAAgB;IACvB,IAAI,CAAsB;IAC1B,SAAS,CAAY;IACrB,MAAM,CAAc;IACpB,cAAc,G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,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;;AA5OH,sBA6OC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * App categorization data — the single source of truth for app-pattern
3
+ * matching across clawdcursor.
4
+ *
5
+ * Why this file exists. v0.9's agnostic-audit subagent flagged three
6
+ * places where app-specific patterns were inlined as regexes deep inside
7
+ * other modules:
8
+ * - src/core/router/webview2.ts hardcoded the WebView2 settle list
9
+ * - src/core/safety.ts hardcoded the sensitive-app list
10
+ * - src/tools/electron_bridge.ts had its own KNOWN_APPS array
11
+ *
12
+ * Each of those was small, but together they meant "the list of apps
13
+ * clawdcursor knows about" was scattered across three files in three
14
+ * directories. Adding a new app required changing code in N places and
15
+ * was easy to miss. Worse, the names duplicated (Outlook appeared in
16
+ * both WebView2 and sensitive lists, with slightly different wording).
17
+ *
18
+ * This module consolidates the app-data so:
19
+ * - Categorization decisions live next to one another.
20
+ * - The agent loop / pipeline never imports this file — only the
21
+ * small helper modules that need to make a categorization call do.
22
+ * - Adding a new app means editing one row in one file.
23
+ *
24
+ * Anti-design note. This file is intentionally not exported from any
25
+ * index. Importers reach in explicitly so it's clear at the call-site
26
+ * that they're consulting app-category data, not running app-specific
27
+ * logic. The autonomous pipeline (agent loop, decomposer, verifier,
28
+ * preprocessor) does NOT import from here and never should — those
29
+ * components stay model- and app-agnostic by construction.
30
+ */
31
+ /**
32
+ * Apps that render their UI inside Chromium / Edge WebView2 / Electron.
33
+ * For these the OS-level UI Automation tree is sparse — clawdcursor needs
34
+ * a longer settle window after launch and may need to attach via CDP
35
+ * (`relaunch_with_cdp`) to read the real DOM.
36
+ *
37
+ * Matched against process name OR alias name (case-insensitive substring).
38
+ * Adding a new app here is the only change needed to give it the longer
39
+ * WebView2 settle treatment.
40
+ */
41
+ export declare const WEBVIEW2_APPS: readonly string[];
42
+ /**
43
+ * Apps where any unlabeled click/keystroke is potentially destructive —
44
+ * email send, banking transfer, password manager autofill, private
45
+ * messaging hit-send. The safety gate elevates click-family tools to
46
+ * `confirm` when active app matches one of these AND no target label
47
+ * was supplied.
48
+ *
49
+ * Matched against active-window process name (case-insensitive substring).
50
+ * This is the canonical sensitive list; the `clawdcursor consent` flow
51
+ * also surfaces these categories to the user at install time.
52
+ */
53
+ export declare const SENSITIVE_APPS: readonly string[];
54
+ /**
55
+ * Build a case-insensitive regex from a list of substring patterns.
56
+ * Used by callers that need the regex form (e.g. the existing
57
+ * webview2 helper and safety gate both `.test()` a process name).
58
+ *
59
+ * Word-boundary `\b` is used so we don't false-match (`mail` inside
60
+ * `gmail` is fine because both are listed; but `signal` doesn't match
61
+ * `signaling`).
62
+ */
63
+ export declare function buildAppRegex(patterns: readonly string[]): RegExp;
64
+ /** Convenience: regex form of {@link WEBVIEW2_APPS}. */
65
+ export declare const WEBVIEW2_APPS_PATTERN: RegExp;
66
+ /** Convenience: regex form of {@link SENSITIVE_APPS}. */
67
+ export declare const SENSITIVE_APPS_PATTERN: RegExp;
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ /**
3
+ * App categorization data — the single source of truth for app-pattern
4
+ * matching across clawdcursor.
5
+ *
6
+ * Why this file exists. v0.9's agnostic-audit subagent flagged three
7
+ * places where app-specific patterns were inlined as regexes deep inside
8
+ * other modules:
9
+ * - src/core/router/webview2.ts hardcoded the WebView2 settle list
10
+ * - src/core/safety.ts hardcoded the sensitive-app list
11
+ * - src/tools/electron_bridge.ts had its own KNOWN_APPS array
12
+ *
13
+ * Each of those was small, but together they meant "the list of apps
14
+ * clawdcursor knows about" was scattered across three files in three
15
+ * directories. Adding a new app required changing code in N places and
16
+ * was easy to miss. Worse, the names duplicated (Outlook appeared in
17
+ * both WebView2 and sensitive lists, with slightly different wording).
18
+ *
19
+ * This module consolidates the app-data so:
20
+ * - Categorization decisions live next to one another.
21
+ * - The agent loop / pipeline never imports this file — only the
22
+ * small helper modules that need to make a categorization call do.
23
+ * - Adding a new app means editing one row in one file.
24
+ *
25
+ * Anti-design note. This file is intentionally not exported from any
26
+ * index. Importers reach in explicitly so it's clear at the call-site
27
+ * that they're consulting app-category data, not running app-specific
28
+ * logic. The autonomous pipeline (agent loop, decomposer, verifier,
29
+ * preprocessor) does NOT import from here and never should — those
30
+ * components stay model- and app-agnostic by construction.
31
+ */
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ exports.SENSITIVE_APPS_PATTERN = exports.WEBVIEW2_APPS_PATTERN = exports.SENSITIVE_APPS = exports.WEBVIEW2_APPS = void 0;
34
+ exports.buildAppRegex = buildAppRegex;
35
+ /**
36
+ * Apps that render their UI inside Chromium / Edge WebView2 / Electron.
37
+ * For these the OS-level UI Automation tree is sparse — clawdcursor needs
38
+ * a longer settle window after launch and may need to attach via CDP
39
+ * (`relaunch_with_cdp`) to read the real DOM.
40
+ *
41
+ * Matched against process name OR alias name (case-insensitive substring).
42
+ * Adding a new app here is the only change needed to give it the longer
43
+ * WebView2 settle treatment.
44
+ */
45
+ exports.WEBVIEW2_APPS = [
46
+ 'olk', // Microsoft New Outlook (Win11)
47
+ 'outlook',
48
+ 'teams', // Microsoft Teams
49
+ 'slack',
50
+ 'discord',
51
+ 'spotify',
52
+ 'vscode', // VS Code
53
+ 'code', // VS Code on macOS / Linux
54
+ 'obsidian',
55
+ 'notion',
56
+ ];
57
+ /**
58
+ * Apps where any unlabeled click/keystroke is potentially destructive —
59
+ * email send, banking transfer, password manager autofill, private
60
+ * messaging hit-send. The safety gate elevates click-family tools to
61
+ * `confirm` when active app matches one of these AND no target label
62
+ * was supplied.
63
+ *
64
+ * Matched against active-window process name (case-insensitive substring).
65
+ * This is the canonical sensitive list; the `clawdcursor consent` flow
66
+ * also surfaces these categories to the user at install time.
67
+ */
68
+ exports.SENSITIVE_APPS = [
69
+ // Email
70
+ 'outlook',
71
+ 'olk',
72
+ 'mail',
73
+ 'gmail',
74
+ 'thunderbird',
75
+ // Finance
76
+ 'banking',
77
+ // Password managers
78
+ '1password',
79
+ 'lastpass',
80
+ 'bitwarden',
81
+ 'keeper',
82
+ 'dashlane',
83
+ // Private messaging
84
+ 'signal',
85
+ 'whatsapp',
86
+ 'messages',
87
+ 'telegram',
88
+ 'imessage',
89
+ 'wickr',
90
+ ];
91
+ /**
92
+ * Build a case-insensitive regex from a list of substring patterns.
93
+ * Used by callers that need the regex form (e.g. the existing
94
+ * webview2 helper and safety gate both `.test()` a process name).
95
+ *
96
+ * Word-boundary `\b` is used so we don't false-match (`mail` inside
97
+ * `gmail` is fine because both are listed; but `signal` doesn't match
98
+ * `signaling`).
99
+ */
100
+ function buildAppRegex(patterns) {
101
+ const alt = patterns.map(p => p.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|');
102
+ return new RegExp(`\\b(?:${alt})\\b`, 'i');
103
+ }
104
+ /** Convenience: regex form of {@link WEBVIEW2_APPS}. */
105
+ exports.WEBVIEW2_APPS_PATTERN = buildAppRegex(exports.WEBVIEW2_APPS);
106
+ /** Convenience: regex form of {@link SENSITIVE_APPS}. */
107
+ exports.SENSITIVE_APPS_PATTERN = buildAppRegex(exports.SENSITIVE_APPS);
108
+ //# sourceMappingURL=app-categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-categories.js","sourceRoot":"","sources":["../../src/core/app-categories.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;;;AAqEH,sCAGC;AAtED;;;;;;;;;GASG;AACU,QAAA,aAAa,GAAsB;IAC9C,KAAK,EAAQ,gCAAgC;IAC7C,SAAS;IACT,OAAO,EAAM,kBAAkB;IAC/B,OAAO;IACP,SAAS;IACT,SAAS;IACT,QAAQ,EAAK,UAAU;IACvB,MAAM,EAAO,2BAA2B;IACxC,UAAU;IACV,QAAQ;CACT,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,cAAc,GAAsB;IAC/C,QAAQ;IACR,SAAS;IACT,KAAK;IACL,MAAM;IACN,OAAO;IACP,aAAa;IACb,UAAU;IACV,SAAS;IACT,oBAAoB;IACpB,WAAW;IACX,UAAU;IACV,WAAW;IACX,QAAQ;IACR,UAAU;IACV,oBAAoB;IACpB,QAAQ;IACR,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,OAAO;CACR,CAAC;AAEF;;;;;;;;GAQG;AACH,SAAgB,aAAa,CAAC,QAA2B;IACvD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClF,OAAO,IAAI,MAAM,CAAC,SAAS,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,wDAAwD;AAC3C,QAAA,qBAAqB,GAAW,aAAa,CAAC,qBAAa,CAAC,CAAC;AAE1E,yDAAyD;AAC5C,QAAA,sBAAsB,GAAW,aAAa,CAAC,sBAAc,CAAC,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Control banner — the on-screen "desktop control in progress" indicators:
3
+ * - scripts/banner.ps1: topmost, no-activate pill with a blinking red dot;
4
+ * carries the double-click → stop affordance.
5
+ * - scripts/edge-glow.ps1: a full-screen, click-through amber glow that pulses
6
+ * on all four screen edges. Pure ambient signal; spawned/killed in lockstep
7
+ * with the pill so the two are always in sync. Opt out via CLAWD_NO_GLOW=1.
8
+ *
9
+ * Transparency contract: whenever an agent is actively driving this desktop,
10
+ * a human at the machine sees it — and can kill it (double-click → the parent
11
+ * runs the `clawdcursor stop` flow). Two lifecycles feed it:
12
+ *
13
+ * - pin()/unpin(): the autonomous task loop pins the banner for the whole
14
+ * task (agent.executeTask). A pinned banner ignores idle timers.
15
+ * - touch(): every consequential (safetyTier ≥ 1) MCP tool call pokes the
16
+ * banner; it shows on the first poke and auto-hides after IDLE_HIDE_MS of
17
+ * inactivity. This covers EXTERNAL agents (editor-hosted over stdio or
18
+ * HTTP /mcp) where there is no task boundary to hook.
19
+ *
20
+ * Windows-only today (WinForms via the warm PowerShell host); macOS/Linux are
21
+ * silent no-ops — the API is platform-neutral so adapters can land later.
22
+ * Disable via `--no-banner` or CLAWD_NO_BANNER=1.
23
+ */
24
+ import { type ChildProcess } from 'child_process';
25
+ type Spawner = () => ChildProcess;
26
+ declare class ControlBanner {
27
+ private child;
28
+ private glowChild;
29
+ private idleTimer;
30
+ private pinned;
31
+ private enabled;
32
+ private glowEnabled;
33
+ private onStopRequested;
34
+ private spawner;
35
+ private glowSpawner;
36
+ /** Wire the double-click → stop callback (the `clawdcursor stop` flow). */
37
+ configure(opts: {
38
+ onStopRequested?: () => void;
39
+ }): void;
40
+ /** Hard enable/disable (CLI --no-banner / config). Disabling hides immediately. */
41
+ setEnabled(v: boolean): void;
42
+ isVisible(): boolean;
43
+ /** Show and keep shown until unpin() — the autonomous-task lifecycle. */
44
+ pin(): void;
45
+ /** Release the task pin; hides unless tool activity re-touches it. */
46
+ unpin(): void;
47
+ /**
48
+ * Activity poke from a consequential tool call: show now, auto-hide after
49
+ * IDLE_HIDE_MS without further pokes. No-op on the timer while pinned.
50
+ */
51
+ touch(idleMs?: number): void;
52
+ private exitHookInstalled;
53
+ private show;
54
+ /** The "control in progress" pill — also the BANNER_STOP / kill-switch source. */
55
+ private spawnPill;
56
+ /** The ambient screen-edge glow — pure visual, click-through, no stdout. */
57
+ private spawnGlow;
58
+ private installExitHook;
59
+ private killGlow;
60
+ private forceHide;
61
+ private clearIdleTimer;
62
+ __setSpawnerForTests(s: Spawner): void;
63
+ __setGlowSpawnerForTests(s: Spawner): void;
64
+ __setPlatformEnabledForTests(v: boolean): void;
65
+ __setGlowEnabledForTests(v: boolean): void;
66
+ __resetForTests(): void;
67
+ }
68
+ /** Singleton — one banner per process (daemon or stdio MCP server). */
69
+ export declare const controlBanner: ControlBanner;
70
+ export {};