@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,248 @@
1
+ "use strict";
2
+ /**
3
+ * Agent-control tools — drive the autonomous Agent from outside the daemon.
4
+ *
5
+ * These are the MCP equivalents of the legacy REST routes that lived in
6
+ * src/server.ts (POST /task, POST /abort, GET /status, GET /screenshot,
7
+ * GET /task-logs, GET /task-logs/current). Each tool reaches into
8
+ * `ctx.agent` — populated by the daemon when it constructs the MCP server,
9
+ * and undefined when running through stdio MCP without a live agent.
10
+ *
11
+ * Tools that require an agent return an `isError` result with a clear
12
+ * message rather than throwing — clients shouldn't crash because they
13
+ * called submit_task on a stdio MCP that has no Pipeline wired.
14
+ */
15
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
27
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
28
+ }) : function(o, v) {
29
+ o["default"] = v;
30
+ });
31
+ var __importStar = (this && this.__importStar) || (function () {
32
+ var ownKeys = function(o) {
33
+ ownKeys = Object.getOwnPropertyNames || function (o) {
34
+ var ar = [];
35
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
36
+ return ar;
37
+ };
38
+ return ownKeys(o);
39
+ };
40
+ return function (mod) {
41
+ if (mod && mod.__esModule) return mod;
42
+ var result = {};
43
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
44
+ __setModuleDefault(result, mod);
45
+ return result;
46
+ };
47
+ })();
48
+ Object.defineProperty(exports, "__esModule", { value: true });
49
+ exports.getAgentTools = getAgentTools;
50
+ const fs = __importStar(require("fs"));
51
+ function needAgent(tool) {
52
+ return {
53
+ text: `${tool}: no autonomous agent is attached to this MCP context. ` +
54
+ `This tool needs \`clawdcursor agent\` running WITH an LLM configured. ` +
55
+ `Tools-only contexts (stdio \`clawdcursor mcp\`, or \`agent --no-llm\`) cannot use it — ` +
56
+ `drive the desktop yourself with the other tools instead: the compound ` +
57
+ `computer/accessibility/window/system/browser tools (compact surface), ` +
58
+ `or the granular mouse_click/type_text/… tools.`,
59
+ isError: true,
60
+ };
61
+ }
62
+ function getAgentTools() {
63
+ return [
64
+ {
65
+ name: 'submit_task',
66
+ description: 'Submit a natural-language task to the autonomous agent. The agent ' +
67
+ 'classifies, decomposes, and executes the task through the unified ' +
68
+ 'pipeline (a11y → text-agent → vision fallback). Returns immediately ' +
69
+ 'with `accepted: true`; poll agent_status to track progress. ' +
70
+ 'Runs locally on a cheap model — prefer this over driving the ' +
71
+ 'mouse_*/screenshot tools yourself to save tokens.',
72
+ parameters: {
73
+ task: { type: 'string', description: 'Natural-language task', required: true },
74
+ },
75
+ category: 'orchestration',
76
+ compactGroup: 'task',
77
+ safetyTier: 1,
78
+ handler: async ({ task }, ctx) => {
79
+ if (!ctx.agent)
80
+ return needAgent('submit_task');
81
+ const trimmed = String(task ?? '').trim();
82
+ if (!trimmed) {
83
+ return { text: 'submit_task: task must be a non-empty string', isError: true };
84
+ }
85
+ if (trimmed.length > 2000) {
86
+ return { text: 'submit_task: task is too long (max 2000 chars)', isError: true };
87
+ }
88
+ const state = ctx.agent.getState();
89
+ if (state.status !== 'idle') {
90
+ return {
91
+ text: `Agent is busy (status=${state.status}). Wait or call abort_task first.`,
92
+ isError: true,
93
+ };
94
+ }
95
+ // Fire-and-poll: kick off the task, return acceptance immediately.
96
+ // The agent updates its own state; clients use agent_status to track.
97
+ ctx.agent.executeTask(trimmed).catch((err) => {
98
+ // Errors are surfaced via agent state + the daemon's log buffer.
99
+ // Don't re-throw here — submit_task already returned.
100
+ console.error('submit_task: pipeline error', err?.message ?? err);
101
+ });
102
+ return { text: JSON.stringify({ accepted: true, task: trimmed }) };
103
+ },
104
+ },
105
+ {
106
+ name: 'abort_task',
107
+ description: 'Signal the running task to abort. The pipeline checks `isAborted()` ' +
108
+ 'between steps; long-running LLM calls may take a few seconds to ' +
109
+ 'wind down. agent_status will return `idle` once the abort has settled.',
110
+ parameters: {},
111
+ category: 'orchestration',
112
+ compactGroup: 'task',
113
+ safetyTier: 1,
114
+ handler: async (_params, ctx) => {
115
+ if (!ctx.agent)
116
+ return needAgent('abort_task');
117
+ ctx.agent.abort();
118
+ return { text: JSON.stringify({ aborted: true }) };
119
+ },
120
+ },
121
+ {
122
+ name: 'agent_status',
123
+ description: 'Return the autonomous agent\'s current state: status (idle | thinking | ' +
124
+ 'acting | waiting_confirm), currentTask, currentStep, stepsCompleted, ' +
125
+ 'stepsTotal. Cheap (synchronous read) — safe to poll at 1–2 Hz.',
126
+ parameters: {},
127
+ category: 'orchestration',
128
+ compactGroup: 'system',
129
+ safetyTier: 0,
130
+ handler: async (_params, ctx) => {
131
+ if (!ctx.agent) {
132
+ // Stdio MCP — there's no daemon. Surface a sentinel state so
133
+ // clients can degrade gracefully instead of crashing.
134
+ return {
135
+ text: JSON.stringify({
136
+ status: 'no_agent',
137
+ stepsCompleted: 0,
138
+ stepsTotal: 0,
139
+ }),
140
+ };
141
+ }
142
+ return { text: JSON.stringify(ctx.agent.getState()) };
143
+ },
144
+ },
145
+ {
146
+ name: 'screenshot_full',
147
+ description: 'Capture the full primary display. Returns base64 image bytes plus a ' +
148
+ '`format` field (`jpeg` by default, `png` if configured); the MCP ' +
149
+ '`image.mimeType` is set to match. Equivalent to desktop_screenshot ' +
150
+ 'but returns the full frame unconditionally (no region cropping). ' +
151
+ 'Useful for the dashboard\'s /screenshot REST replacement.',
152
+ parameters: {},
153
+ category: 'perception',
154
+ compactGroup: 'computer',
155
+ safetyTier: 0,
156
+ handler: async (_params, ctx) => {
157
+ try {
158
+ await ctx.ensureInitialized();
159
+ const frame = await ctx.desktop.captureForLLM();
160
+ // captureForLLM returns { buffer, scaleFactor, llmWidth, llmHeight,
161
+ // format }. Format is configured per-capture (`'jpeg'` by default,
162
+ // sometimes `'png'`); use it to set the correct mimeType instead
163
+ // of the previous hardcoded 'image/png' which lied for the JPEG path.
164
+ const b64 = Buffer.isBuffer(frame.buffer)
165
+ ? frame.buffer.toString('base64')
166
+ : Buffer.from(frame.buffer).toString('base64');
167
+ const mimeType = frame.format === 'png' ? 'image/png' : 'image/jpeg';
168
+ return {
169
+ text: JSON.stringify({
170
+ scaleFactor: frame.scaleFactor,
171
+ llmWidth: frame.llmWidth,
172
+ llmHeight: frame.llmHeight,
173
+ format: frame.format,
174
+ }),
175
+ image: { data: b64, mimeType },
176
+ };
177
+ }
178
+ catch (err) {
179
+ return { text: `Screenshot failed: ${err.message}`, isError: true };
180
+ }
181
+ },
182
+ },
183
+ {
184
+ name: 'task_logs_list',
185
+ description: 'List the last 50 task summaries from the daemon\'s structured log. ' +
186
+ 'Each summary contains task text, correlation ID, start/end timestamps, ' +
187
+ 'and final status. Returns [] when no logger is attached.',
188
+ parameters: {},
189
+ category: 'orchestration',
190
+ compactGroup: 'system',
191
+ safetyTier: 0,
192
+ handler: async (_params, ctx) => {
193
+ if (!ctx.agent)
194
+ return { text: '[]' };
195
+ try {
196
+ const logger = ctx.agent.logger;
197
+ if (!logger || typeof logger.getRecentSummaries !== 'function') {
198
+ return { text: '[]' };
199
+ }
200
+ return { text: JSON.stringify(logger.getRecentSummaries(50)) };
201
+ }
202
+ catch {
203
+ return { text: '[]' };
204
+ }
205
+ },
206
+ },
207
+ {
208
+ name: 'task_logs_current',
209
+ description: 'Return the structured log entries for the currently-executing task ' +
210
+ '(or the most recent if no task is running). Each entry is a JSONL ' +
211
+ 'event from the pipeline trace.',
212
+ parameters: {},
213
+ category: 'orchestration',
214
+ compactGroup: 'system',
215
+ safetyTier: 0,
216
+ handler: async (_params, ctx) => {
217
+ if (!ctx.agent) {
218
+ return { text: 'task_logs_current: no agent attached', isError: true };
219
+ }
220
+ try {
221
+ const logger = ctx.agent.logger;
222
+ const logPath = logger?.getCurrentLogPath?.();
223
+ if (!logPath || !fs.existsSync(logPath)) {
224
+ return { text: 'task_logs_current: no current log file', isError: true };
225
+ }
226
+ const content = fs.readFileSync(logPath, 'utf-8');
227
+ const entries = content
228
+ .trim()
229
+ .split('\n')
230
+ .map((l) => {
231
+ try {
232
+ return JSON.parse(l);
233
+ }
234
+ catch {
235
+ return null;
236
+ }
237
+ })
238
+ .filter(Boolean);
239
+ return { text: JSON.stringify(entries) };
240
+ }
241
+ catch (err) {
242
+ return { text: `task_logs_current: ${err.message}`, isError: true };
243
+ }
244
+ },
245
+ },
246
+ ];
247
+ }
248
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBH,sCA0LC;AAzMD,uCAAyB;AAGzB,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO;QACL,IAAI,EAAE,GAAG,IAAI,yDAAyD;YAChE,wEAAwE;YACxE,yFAAyF;YACzF,wEAAwE;YACxE,wEAAwE;YACxE,gDAAgD;QACtD,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa;IAC3B,OAAO;QACL;YACE,IAAI,EAAE,aAAa;YACnB,WAAW,EACT,oEAAoE;gBACpE,oEAAoE;gBACpE,sEAAsE;gBACtE,8DAA8D;gBAC9D,+DAA+D;gBAC/D,mDAAmD;YACrD,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE,QAAQ,EAAE,IAAI,EAAE;aAC/E;YACD,QAAQ,EAAE,eAAe;YACzB,YAAY,EAAE,MAAM;YACpB,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;gBAC/B,IAAI,CAAC,GAAG,CAAC,KAAK;oBAAE,OAAO,SAAS,CAAC,aAAa,CAAC,CAAC;gBAChD,MAAM,OAAO,GAAG,MAAM,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C,OAAO,EAAE,OAAO,CAAC,CAAC;oBAClD,MAAM,OAAO,GAAG,OAAO;yBACpB,IAAI,EAAE;yBACN,KAAK,CAAC,IAAI,CAAC;yBACX,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE;wBACjB,IAAI,CAAC;4BAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;wBAAC,CAAC;wBAAC,MAAM,CAAC;4BAAC,OAAO,IAAI,CAAC;wBAAC,CAAC;oBACtD,CAAC,CAAC;yBACD,MAAM,CAAC,OAAO,CAAC,CAAC;oBACnB,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;gBAC3C,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,EAAE,IAAI,EAAE,sBAAuB,GAAa,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;gBACjF,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,46 @@
1
+ import type { ToolContext, ToolDefinition } from './types';
2
+ /** A lightweight, declarative precondition checked (by re-perceiving) before a step runs. */
3
+ export interface BatchGuard {
4
+ /** An a11y element with this name must be present in the current UI. */
5
+ element?: string;
6
+ /** The foreground/active window's title or processName must contain this (case-insensitive). */
7
+ window?: string;
8
+ }
9
+ export interface BatchStep {
10
+ /** Tool name — a compound (`computer`/`window`/…) with `arguments.action`, or a granular tool. */
11
+ name: string;
12
+ arguments?: Record<string, unknown>;
13
+ /** Optional precondition; if it fails the batch halts here and reports back. */
14
+ expect?: BatchGuard;
15
+ /** Canonical alias for `expect` (matches the agent-loop batch). An `expect`
16
+ * ASSERTION ARRAY belongs inside `arguments` instead — the projected tool
17
+ * handlers verify it post-action. */
18
+ precheck?: BatchGuard;
19
+ /** Optional human label for the trace. */
20
+ label?: string;
21
+ }
22
+ type StepStatus = 'ok' | 'guard_failed' | 'blocked' | 'needs_confirm' | 'error' | 'unknown_tool' | 'skipped';
23
+ export interface StepOutcome {
24
+ i: number;
25
+ label: string;
26
+ status: StepStatus;
27
+ text: string;
28
+ }
29
+ export interface BatchResult {
30
+ total: number;
31
+ completed: number;
32
+ allDone: boolean;
33
+ stoppedAt?: number;
34
+ stopReason?: string;
35
+ steps: StepOutcome[];
36
+ }
37
+ /**
38
+ * Run an ordered list of guarded tool calls, halting on the first guard miss,
39
+ * safety stop, or step error. Reuses the real safety gate + tool handlers.
40
+ */
41
+ export declare function executeBatch(steps: BatchStep[], ctx: ToolContext, opts?: {
42
+ allowConfirm?: boolean;
43
+ maxSteps?: number;
44
+ }): Promise<BatchResult>;
45
+ export declare function getBatchTools(): ToolDefinition[];
46
+ export {};
@@ -0,0 +1,230 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeBatch = executeBatch;
4
+ exports.getBatchTools = getBatchTools;
5
+ /**
6
+ * Guarded action-sequence executor + the `batch` tool.
7
+ *
8
+ * Lets an AI driving clawdcursor (over MCP, or the autonomous loop) submit an
9
+ * ORDERED LIST of tool calls that run in one shot — collapsing N round-trips
10
+ * into one — WITHOUT a code sandbox. It is DECLARATIVE on purpose:
11
+ *
12
+ * - Each step is `{ name, arguments, expect? }` — a normal tool call plus an
13
+ * optional precondition guard. No arbitrary code → no injection-as-control-
14
+ * flow, no element-handle staleness (every step re-queries by name), no
15
+ * opaque partial-execution blob.
16
+ * - Every step routes through the SAME `evaluateToolCall` safety gate and the
17
+ * SAME `getTool().handler` execution path the MCP server uses per call.
18
+ * - Between steps the executor RE-PERCEIVES to check each step's `expect`
19
+ * guard; on any guard miss / safety stop / step error it HALTS and returns
20
+ * a structured trace so the caller re-plans from real state (the morph
21
+ * ladder's recovery, just coarser).
22
+ *
23
+ * This is the "batched planning" middle path: most of Code Mode's efficiency,
24
+ * none of the sandbox's hard problems (see the architecture review).
25
+ */
26
+ const registry_1 = require("./registry");
27
+ const safety_gate_1 = require("./safety-gate");
28
+ const window_text_1 = require("./window-text");
29
+ /** Resolve a step's tool by name from EITHER surface — a granular tool
30
+ * (`mouse_click`, `open_app`, …) or a compound tool (`computer`, `window`, …)
31
+ * — so a batch works whether the caller drives the 97-tool or 6-compound API. */
32
+ function resolveAnyTool(name) {
33
+ return (0, registry_1.getTool)(name) ?? (0, registry_1.getCompactTools)().find(t => t.name === name);
34
+ }
35
+ const DEFAULT_MAX_STEPS = 12;
36
+ function labelFor(step) {
37
+ if (step.label)
38
+ return step.label;
39
+ const action = step.arguments?.action;
40
+ return action ? `${step.name}.${String(action)}` : step.name;
41
+ }
42
+ /** Re-perceive and evaluate a step's precondition guard. Returns ok=false with a reason on miss. */
43
+ async function checkGuard(guard, ctx) {
44
+ if (guard.window) {
45
+ const t = (0, registry_1.getTool)('get_active_window');
46
+ if (t) {
47
+ const r = await t.handler({}, ctx).catch((e) => ({ text: String(e), isError: true }));
48
+ // Window-aware normalization: real titles carry invisible Unicode (Edge's
49
+ // NBSP in "Microsoft Edge") that defeats a plain substring compare (#bug
50
+ // 2026-06-11).
51
+ if (!(0, window_text_1.windowTextIncludes)(r.text, guard.window)) {
52
+ return { ok: false, detail: `foreground window is not "${guard.window}" (got: ${(r.text || '').slice(0, 90)})` };
53
+ }
54
+ }
55
+ }
56
+ if (guard.element) {
57
+ const t = (0, registry_1.getTool)('find_element');
58
+ if (t) {
59
+ const r = await t.handler({ name: guard.element }, ctx).catch((e) => ({ text: String(e), isError: true }));
60
+ // Element presence is decided by find_element's own absence markers, not
61
+ // by title matching — leave this ASCII-literal (the window guard above is
62
+ // where the invisible-Unicode normalization matters).
63
+ const txt = (r.text || '').toLowerCase();
64
+ const missing = r.isError || txt.includes('not found') || txt.includes('no match') || txt.includes('no element') || /\b0 (match|element)/.test(txt);
65
+ if (missing)
66
+ return { ok: false, detail: `element "${guard.element}" not present` };
67
+ }
68
+ }
69
+ return { ok: true, detail: '' };
70
+ }
71
+ /**
72
+ * Run an ordered list of guarded tool calls, halting on the first guard miss,
73
+ * safety stop, or step error. Reuses the real safety gate + tool handlers.
74
+ */
75
+ async function executeBatch(steps, ctx, opts = {}) {
76
+ const cap = opts.maxSteps ?? DEFAULT_MAX_STEPS;
77
+ const outcomes = [];
78
+ let completed = 0;
79
+ const halt = (i, reason) => ({ total: steps.length, completed, allDone: false, stoppedAt: i, stopReason: reason, steps: outcomes });
80
+ for (let i = 0; i < steps.length; i++) {
81
+ const step = steps[i];
82
+ const label = labelFor(step);
83
+ if (i >= cap) {
84
+ outcomes.push({ i, label, status: 'skipped', text: `not run — batch capped at ${cap} steps` });
85
+ return halt(i, `batch capped at ${cap} steps; submit the remainder as a new batch`);
86
+ }
87
+ const tool = resolveAnyTool(step.name);
88
+ if (!tool) {
89
+ outcomes.push({ i, label, status: 'unknown_tool', text: `tool "${step.name}" is not registered` });
90
+ return halt(i, `unknown tool "${step.name}"`);
91
+ }
92
+ // Precondition: re-perceive and verify the step's expectation.
93
+ // `precheck` is the canonical name (parity with the agent-loop batch);
94
+ // `expect` remains the documented MCP alias for back-compat.
95
+ const guard = step.precheck ?? step.expect;
96
+ if (guard) {
97
+ const g = await checkGuard(guard, ctx);
98
+ if (!g.ok) {
99
+ outcomes.push({ i, label, status: 'guard_failed', text: `precondition failed: ${g.detail}` });
100
+ return halt(i, `precondition failed at step ${i} — re-plan from current state`);
101
+ }
102
+ }
103
+ const args = step.arguments ?? {};
104
+ // Safety — identical gate to a normal tools/call (incl. el_NN → label
105
+ // resolution via the shared holder, same as the direct MCP path).
106
+ const safetyErr = (0, safety_gate_1.evaluateToolCall)(tool, args, { uiMaps: ctx.uiMaps });
107
+ if (safetyErr) {
108
+ const isConfirm = (safetyErr.text || '').includes('safety confirm');
109
+ if (!(isConfirm && opts.allowConfirm)) {
110
+ outcomes.push({ i, label, status: isConfirm ? 'needs_confirm' : 'blocked', text: safetyErr.text });
111
+ return halt(i, isConfirm ? `step ${i} needs confirmation (re-submit with allowConfirm:true if intended)` : `step ${i} blocked by safety`);
112
+ }
113
+ }
114
+ // Execute via the real handler.
115
+ let res;
116
+ try {
117
+ res = await tool.handler(args, ctx);
118
+ }
119
+ catch (e) {
120
+ res = { text: `threw: ${e instanceof Error ? e.message : String(e)}`, isError: true };
121
+ }
122
+ if (res.isError) {
123
+ outcomes.push({ i, label, status: 'error', text: (res.text || '').slice(0, 200) });
124
+ return halt(i, `step ${i} (${label}) errored`);
125
+ }
126
+ outcomes.push({ i, label, status: 'ok', text: (res.text || '').slice(0, 160) });
127
+ completed++;
128
+ }
129
+ return { total: steps.length, completed, allDone: completed === steps.length, steps: outcomes };
130
+ }
131
+ /** Pre-flight: scan each step's safety tier WITHOUT executing. */
132
+ function dryRunScan(steps) {
133
+ return steps.map((step, i) => {
134
+ const label = labelFor(step);
135
+ const tool = resolveAnyTool(step.name);
136
+ if (!tool)
137
+ return { i, label, gate: 'unknown-tool' };
138
+ const err = (0, safety_gate_1.evaluateToolCall)(tool, step.arguments ?? {});
139
+ const gate = !err ? 'allow' : (err.text.includes('safety confirm') ? 'confirm' : 'block');
140
+ return { i, label, gate };
141
+ });
142
+ }
143
+ function renderResult(r) {
144
+ const lines = r.steps.map(s => ` ${s.i}. [${s.status}] ${s.label} — ${s.text}`);
145
+ const head = r.allDone
146
+ ? `batch: all ${r.total} steps completed.`
147
+ : `batch: ${r.completed}/${r.total} completed, halted at step ${r.stoppedAt} — ${r.stopReason}`;
148
+ return `${head}\n${lines.join('\n')}`;
149
+ }
150
+ function getBatchTools() {
151
+ return [
152
+ {
153
+ name: 'batch',
154
+ description: 'Run an ORDERED LIST of tool calls in one shot (collapses many round-trips into one). Each step is ' +
155
+ '{ name, arguments, expect? }. `name`+`arguments` is a normal tool call (compound like ' +
156
+ '{"name":"computer","arguments":{"action":"type","text":"hi"}} or a granular tool). Optional `expect` ' +
157
+ 'is a precondition checked by RE-PERCEIVING before the step runs: {"window":"notepad"} (foreground ' +
158
+ 'window must match) or {"element":"Send"} (a11y element must be present). The batch HALTS on the first ' +
159
+ 'failed precondition, safety stop, or step error and returns a per-step trace so you re-plan from real ' +
160
+ 'state. Every step goes through the same safety gate as a direct call. Use `expect` to guarantee you ' +
161
+ 'act on the right window/element instead of guessing. Set dryRun:true to pre-scan safety tiers without ' +
162
+ 'executing; allowConfirm:true to let confirm-tier steps proceed.',
163
+ parameters: {
164
+ steps: {
165
+ type: 'array',
166
+ required: true,
167
+ description: 'Ordered steps to run. Each step is a normal tool call: { "name": "<tool>", "arguments": {...}, "expect"?: {"window"?,"element"?} }. (A JSON-encoded string of the same array is also accepted.)',
168
+ items: {
169
+ type: 'object',
170
+ properties: {
171
+ name: { type: 'string', description: 'Tool to call — a compound ("computer"/"window"/...) or a granular tool.' },
172
+ arguments: { type: 'object', description: 'Arguments for that tool, e.g. {"action":"type","text":"hi"}. May include an `expect` ASSERTION ARRAY (post-condition) — verified after the step by the tool itself.' },
173
+ expect: { type: 'object', description: 'Optional precondition re-checked by perceiving before the step: {"window":"..."} or {"element":"..."}. (`precheck` is an accepted alias.)' },
174
+ },
175
+ required: ['name'],
176
+ },
177
+ },
178
+ allowConfirm: { type: 'boolean', description: 'Allow confirm-tier steps to run (default false → halt at them).', required: false },
179
+ dryRun: { type: 'boolean', description: 'Only report each step\'s safety tier; do not execute.', required: false },
180
+ maxSteps: { type: 'number', description: `Hard cap on executed steps (default ${DEFAULT_MAX_STEPS}).`, required: false },
181
+ },
182
+ category: 'orchestration',
183
+ compactGroup: 'system',
184
+ safetyTier: 0, // the batch itself is inert; each STEP is gated individually at runtime.
185
+ handler: async (params, ctx) => {
186
+ // `steps` arrives as a JSON string (constrained schema) or, from clients
187
+ // that pass rich JSON, a real array. Accept both.
188
+ let steps;
189
+ const raw = params.steps;
190
+ if (typeof raw === 'string') {
191
+ try {
192
+ steps = JSON.parse(raw);
193
+ }
194
+ catch {
195
+ return { text: 'batch: `steps` must be a valid JSON array.', isError: true };
196
+ }
197
+ }
198
+ else if (Array.isArray(raw)) {
199
+ steps = raw;
200
+ }
201
+ else {
202
+ return { text: 'batch: `steps` must be a JSON array of { name, arguments, expect? }.', isError: true };
203
+ }
204
+ if (!Array.isArray(steps) || steps.length === 0) {
205
+ return { text: 'batch: `steps` must be a non-empty array of { name, arguments, expect? }.', isError: true };
206
+ }
207
+ for (const s of steps) {
208
+ if (!s || typeof s.name !== 'string') {
209
+ return { text: 'batch: every step needs a string `name` (the tool to call).', isError: true };
210
+ }
211
+ }
212
+ if (params.dryRun) {
213
+ const scan = dryRunScan(steps);
214
+ const willStop = scan.find(s => s.gate === 'confirm' || s.gate === 'block' || s.gate === 'unknown-tool');
215
+ return {
216
+ text: `batch (dry run): ${steps.length} steps.\n` +
217
+ scan.map(s => ` ${s.i}. [${s.gate}] ${s.label}`).join('\n') +
218
+ (willStop ? `\nNote: without allowConfirm, the batch would halt at step ${willStop.i} ([${willStop.gate}]).` : '\nAll steps would be allowed.'),
219
+ };
220
+ }
221
+ const result = await executeBatch(steps, ctx, {
222
+ allowConfirm: params.allowConfirm === true,
223
+ maxSteps: typeof params.maxSteps === 'number' ? params.maxSteps : undefined,
224
+ });
225
+ return { text: renderResult(result), isError: !result.allDone };
226
+ },
227
+ },
228
+ ];
229
+ }
230
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../src/tools/batch.ts"],"names":[],"mappings":";;AA6GA,oCAqEC;AAsBD,sCA4EC;AApRD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,yCAAsD;AACtD,+CAAiD;AACjD,+CAAmD;AAGnD;;kFAEkF;AAClF,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAA,kBAAO,EAAC,IAAI,CAAC,IAAI,IAAA,0BAAe,GAAE,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AACvE,CAAC;AAqCD,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,SAAS,QAAQ,CAAC,IAAe;IAC/B,IAAI,IAAI,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AAY,KAAK,IAAI;oBAC1C,QAAQ,EAAE,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;iBAC5E,CAAC,CAAC;gBACH,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YAClE,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Browser CDP tools — interact with web page DOM via Chrome DevTools Protocol.
3
+ *
4
+ * Structured access to browser page elements without screenshots.
5
+ * Requires: Edge/Chrome running with --remote-debugging-port
6
+ */
7
+ import type { ToolDefinition } from './types';
8
+ export declare function getCdpTools(): ToolDefinition[];