rookery-agent 0.1.0 → 0.2.0

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 (669) hide show
  1. package/README.md +467 -367
  2. package/docs/migration.md +88 -88
  3. package/docs/updates.md +112 -0
  4. package/package.json +11 -3
  5. package/packages/cli/dist/commands/config.js +2 -2
  6. package/packages/cli/dist/commands/doctor.d.ts.map +1 -1
  7. package/packages/cli/dist/commands/doctor.js +13 -9
  8. package/packages/cli/dist/commands/doctor.js.map +1 -1
  9. package/packages/cli/dist/commands/memory.js +1 -1
  10. package/packages/cli/dist/commands/org.d.ts +2 -2
  11. package/packages/cli/dist/commands/org.d.ts.map +1 -1
  12. package/packages/cli/dist/commands/org.js +19 -17
  13. package/packages/cli/dist/commands/org.js.map +1 -1
  14. package/packages/cli/dist/commands/serve.js +1 -1
  15. package/packages/cli/dist/commands/serve.js.map +1 -1
  16. package/packages/cli/dist/commands/shared.d.ts.map +1 -1
  17. package/packages/cli/dist/commands/shared.js +2 -1
  18. package/packages/cli/dist/commands/shared.js.map +1 -1
  19. package/packages/cli/dist/commands/tasks.d.ts.map +1 -1
  20. package/packages/cli/dist/commands/tasks.js +25 -11
  21. package/packages/cli/dist/commands/tasks.js.map +1 -1
  22. package/packages/cli/dist/commands/tools.js +1 -1
  23. package/packages/cli/dist/commands/tools.js.map +1 -1
  24. package/packages/cli/dist/index.js +13 -13
  25. package/packages/cli/dist/index.js.map +1 -1
  26. package/packages/cli/dist/repl.d.ts +12 -0
  27. package/packages/cli/dist/repl.d.ts.map +1 -1
  28. package/packages/cli/dist/repl.js +170 -16
  29. package/packages/cli/dist/repl.js.map +1 -1
  30. package/packages/cli/dist/tui/App.d.ts +7 -3
  31. package/packages/cli/dist/tui/App.d.ts.map +1 -1
  32. package/packages/cli/dist/tui/App.js +182 -16
  33. package/packages/cli/dist/tui/App.js.map +1 -1
  34. package/packages/cli/dist/tui/commands.d.ts +7 -0
  35. package/packages/cli/dist/tui/commands.d.ts.map +1 -1
  36. package/packages/cli/dist/tui/commands.js +70 -8
  37. package/packages/cli/dist/tui/commands.js.map +1 -1
  38. package/packages/cli/dist/tui/components/AssignmentsView.js +4 -4
  39. package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -1
  40. package/packages/cli/dist/tui/components/Banner.d.ts +11 -2
  41. package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -1
  42. package/packages/cli/dist/tui/components/Banner.js +7 -10
  43. package/packages/cli/dist/tui/components/Banner.js.map +1 -1
  44. package/packages/cli/dist/tui/components/CodeBlock.js +2 -2
  45. package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -1
  46. package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -1
  47. package/packages/cli/dist/tui/components/InputBox.js +4 -4
  48. package/packages/cli/dist/tui/components/InputBox.js.map +1 -1
  49. package/packages/cli/dist/tui/components/Logo.d.ts +56 -0
  50. package/packages/cli/dist/tui/components/Logo.d.ts.map +1 -0
  51. package/packages/cli/dist/tui/components/Logo.js +50 -0
  52. package/packages/cli/dist/tui/components/Logo.js.map +1 -0
  53. package/packages/cli/dist/tui/components/Markdown.js +8 -8
  54. package/packages/cli/dist/tui/components/Markdown.js.map +1 -1
  55. package/packages/cli/dist/tui/components/Message.d.ts +1 -1
  56. package/packages/cli/dist/tui/components/Message.d.ts.map +1 -1
  57. package/packages/cli/dist/tui/components/Message.js +5 -4
  58. package/packages/cli/dist/tui/components/Message.js.map +1 -1
  59. package/packages/cli/dist/tui/components/QuestionView.d.ts +29 -0
  60. package/packages/cli/dist/tui/components/QuestionView.d.ts.map +1 -0
  61. package/packages/cli/dist/tui/components/QuestionView.js +53 -0
  62. package/packages/cli/dist/tui/components/QuestionView.js.map +1 -0
  63. package/packages/cli/dist/tui/components/SlashPalette.d.ts +5 -2
  64. package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -1
  65. package/packages/cli/dist/tui/components/SlashPalette.js +2 -2
  66. package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -1
  67. package/packages/cli/dist/tui/components/StatusLine.d.ts +0 -2
  68. package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -1
  69. package/packages/cli/dist/tui/components/StatusLine.js +8 -5
  70. package/packages/cli/dist/tui/components/StatusLine.js.map +1 -1
  71. package/packages/cli/dist/tui/components/ToolGroup.js +2 -2
  72. package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -1
  73. package/packages/cli/dist/tui/components/WatchView.d.ts +21 -0
  74. package/packages/cli/dist/tui/components/WatchView.d.ts.map +1 -0
  75. package/packages/cli/dist/tui/components/WatchView.js +36 -0
  76. package/packages/cli/dist/tui/components/WatchView.js.map +1 -0
  77. package/packages/cli/dist/tui/history.d.ts +20 -0
  78. package/packages/cli/dist/tui/history.d.ts.map +1 -0
  79. package/packages/cli/dist/tui/history.js +105 -0
  80. package/packages/cli/dist/tui/history.js.map +1 -0
  81. package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -1
  82. package/packages/cli/dist/tui/hooks/useSlash.js +3 -2
  83. package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -1
  84. package/packages/cli/dist/tui/hooks/useTurn.d.ts +58 -1
  85. package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -1
  86. package/packages/cli/dist/tui/hooks/useTurn.js +214 -36
  87. package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -1
  88. package/packages/cli/dist/tui/hooks/useWatch.d.ts +52 -0
  89. package/packages/cli/dist/tui/hooks/useWatch.d.ts.map +1 -0
  90. package/packages/cli/dist/tui/hooks/useWatch.js +145 -0
  91. package/packages/cli/dist/tui/hooks/useWatch.js.map +1 -0
  92. package/packages/cli/dist/tui/inkTheme.d.ts +19 -0
  93. package/packages/cli/dist/tui/inkTheme.d.ts.map +1 -0
  94. package/packages/cli/dist/tui/inkTheme.js +81 -0
  95. package/packages/cli/dist/tui/inkTheme.js.map +1 -0
  96. package/packages/cli/dist/tui/theme.d.ts +39 -29
  97. package/packages/cli/dist/tui/theme.d.ts.map +1 -1
  98. package/packages/cli/dist/tui/theme.js +35 -25
  99. package/packages/cli/dist/tui/theme.js.map +1 -1
  100. package/packages/cli/dist/tui/types.d.ts +56 -3
  101. package/packages/cli/dist/tui/types.d.ts.map +1 -1
  102. package/packages/cli/dist/tui/types.js +85 -0
  103. package/packages/cli/dist/tui/types.js.map +1 -1
  104. package/packages/cli/dist/ui/modelNames.d.ts +51 -0
  105. package/packages/cli/dist/ui/modelNames.d.ts.map +1 -0
  106. package/packages/cli/dist/ui/modelNames.js +134 -0
  107. package/packages/cli/dist/ui/modelNames.js.map +1 -0
  108. package/packages/cli/dist/ui/render.d.ts.map +1 -1
  109. package/packages/cli/dist/ui/render.js +17 -8
  110. package/packages/cli/dist/ui/render.js.map +1 -1
  111. package/packages/cli/dist/ui/speech.js +5 -0
  112. package/packages/cli/dist/ui/speech.js.map +1 -1
  113. package/packages/cli/dist/ui/theme.d.ts +33 -9
  114. package/packages/cli/dist/ui/theme.d.ts.map +1 -1
  115. package/packages/cli/dist/ui/theme.js +33 -9
  116. package/packages/cli/dist/ui/theme.js.map +1 -1
  117. package/packages/cli/package.json +1 -1
  118. package/packages/core/dist/agents/persona.d.ts.map +1 -1
  119. package/packages/core/dist/agents/persona.js +4 -1
  120. package/packages/core/dist/agents/persona.js.map +1 -1
  121. package/packages/core/dist/computer/accessibility.d.ts +78 -0
  122. package/packages/core/dist/computer/accessibility.d.ts.map +1 -0
  123. package/packages/core/dist/computer/accessibility.js +270 -0
  124. package/packages/core/dist/computer/accessibility.js.map +1 -0
  125. package/packages/core/dist/computer/assemblies.d.ts +17 -0
  126. package/packages/core/dist/computer/assemblies.d.ts.map +1 -0
  127. package/packages/core/dist/computer/assemblies.js +55 -0
  128. package/packages/core/dist/computer/assemblies.js.map +1 -0
  129. package/packages/core/dist/computer/browser-init.d.ts +9 -0
  130. package/packages/core/dist/computer/browser-init.d.ts.map +1 -0
  131. package/packages/core/dist/computer/browser-init.js +133 -0
  132. package/packages/core/dist/computer/browser-init.js.map +1 -0
  133. package/packages/core/dist/computer/cursor.d.ts +30 -0
  134. package/packages/core/dist/computer/cursor.d.ts.map +1 -0
  135. package/packages/core/dist/computer/cursor.js +30 -0
  136. package/packages/core/dist/computer/cursor.js.map +1 -0
  137. package/packages/core/dist/computer/mcp-server.js +524 -82
  138. package/packages/core/dist/computer/mcp-server.js.map +1 -1
  139. package/packages/core/dist/computer/powershell.d.ts +4 -0
  140. package/packages/core/dist/computer/powershell.d.ts.map +1 -1
  141. package/packages/core/dist/computer/powershell.js +471 -81
  142. package/packages/core/dist/computer/powershell.js.map +1 -1
  143. package/packages/core/dist/computer/screen-text.d.ts +82 -0
  144. package/packages/core/dist/computer/screen-text.d.ts.map +1 -0
  145. package/packages/core/dist/computer/screen-text.js +243 -0
  146. package/packages/core/dist/computer/screen-text.js.map +1 -0
  147. package/packages/core/dist/computer/sketch.d.ts +66 -0
  148. package/packages/core/dist/computer/sketch.d.ts.map +1 -0
  149. package/packages/core/dist/computer/sketch.js +540 -0
  150. package/packages/core/dist/computer/sketch.js.map +1 -0
  151. package/packages/core/dist/computer/tools.d.ts +8 -8
  152. package/packages/core/dist/computer/tools.d.ts.map +1 -1
  153. package/packages/core/dist/computer/tools.js +186 -31
  154. package/packages/core/dist/computer/tools.js.map +1 -1
  155. package/packages/core/dist/computer/validation.d.ts +555 -0
  156. package/packages/core/dist/computer/validation.d.ts.map +1 -0
  157. package/packages/core/dist/computer/validation.js +111 -0
  158. package/packages/core/dist/computer/validation.js.map +1 -0
  159. package/packages/core/dist/computer/windows-cursor.d.ts +14 -0
  160. package/packages/core/dist/computer/windows-cursor.d.ts.map +1 -0
  161. package/packages/core/dist/computer/windows-cursor.js +713 -0
  162. package/packages/core/dist/computer/windows-cursor.js.map +1 -0
  163. package/packages/core/dist/config.d.ts.map +1 -1
  164. package/packages/core/dist/config.js +284 -10
  165. package/packages/core/dist/config.js.map +1 -1
  166. package/packages/core/dist/cron/scheduler.d.ts +49 -3
  167. package/packages/core/dist/cron/scheduler.d.ts.map +1 -1
  168. package/packages/core/dist/cron/scheduler.js +268 -25
  169. package/packages/core/dist/cron/scheduler.js.map +1 -1
  170. package/packages/core/dist/cron/store.d.ts +19 -1
  171. package/packages/core/dist/cron/store.d.ts.map +1 -1
  172. package/packages/core/dist/cron/store.js +36 -8
  173. package/packages/core/dist/cron/store.js.map +1 -1
  174. package/packages/core/dist/external/claude-code.d.ts +4 -0
  175. package/packages/core/dist/external/claude-code.d.ts.map +1 -0
  176. package/packages/core/dist/external/claude-code.js +111 -0
  177. package/packages/core/dist/external/claude-code.js.map +1 -0
  178. package/packages/core/dist/external/discovery.d.ts +33 -0
  179. package/packages/core/dist/external/discovery.d.ts.map +1 -0
  180. package/packages/core/dist/external/discovery.js +144 -0
  181. package/packages/core/dist/external/discovery.js.map +1 -0
  182. package/packages/core/dist/external/homes.d.ts +26 -0
  183. package/packages/core/dist/external/homes.d.ts.map +1 -0
  184. package/packages/core/dist/external/homes.js +49 -0
  185. package/packages/core/dist/external/homes.js.map +1 -0
  186. package/packages/core/dist/external/shared.d.ts +201 -0
  187. package/packages/core/dist/external/shared.d.ts.map +1 -0
  188. package/packages/core/dist/external/shared.js +308 -0
  189. package/packages/core/dist/external/shared.js.map +1 -0
  190. package/packages/core/dist/gateway/policy.d.ts +100 -2
  191. package/packages/core/dist/gateway/policy.d.ts.map +1 -1
  192. package/packages/core/dist/gateway/policy.js +270 -6
  193. package/packages/core/dist/gateway/policy.js.map +1 -1
  194. package/packages/core/dist/index.d.ts +36 -10
  195. package/packages/core/dist/index.d.ts.map +1 -1
  196. package/packages/core/dist/index.js +64 -10
  197. package/packages/core/dist/index.js.map +1 -1
  198. package/packages/core/dist/memory/db.d.ts +1 -1
  199. package/packages/core/dist/memory/db.d.ts.map +1 -1
  200. package/packages/core/dist/memory/db.js +741 -1
  201. package/packages/core/dist/memory/db.js.map +1 -1
  202. package/packages/core/dist/memory/dream/admission.d.ts +124 -0
  203. package/packages/core/dist/memory/dream/admission.d.ts.map +1 -0
  204. package/packages/core/dist/memory/dream/admission.js +116 -0
  205. package/packages/core/dist/memory/dream/admission.js.map +1 -0
  206. package/packages/core/dist/memory/dream/candidate.d.ts +152 -0
  207. package/packages/core/dist/memory/dream/candidate.d.ts.map +1 -0
  208. package/packages/core/dist/memory/dream/candidate.js +547 -0
  209. package/packages/core/dist/memory/dream/candidate.js.map +1 -0
  210. package/packages/core/dist/memory/dream/evaluate.d.ts +394 -0
  211. package/packages/core/dist/memory/dream/evaluate.d.ts.map +1 -0
  212. package/packages/core/dist/memory/dream/evaluate.js +1032 -0
  213. package/packages/core/dist/memory/dream/evaluate.js.map +1 -0
  214. package/packages/core/dist/memory/dream/frame.d.ts +61 -0
  215. package/packages/core/dist/memory/dream/frame.d.ts.map +1 -0
  216. package/packages/core/dist/memory/dream/frame.js +292 -0
  217. package/packages/core/dist/memory/dream/frame.js.map +1 -0
  218. package/packages/core/dist/memory/dream/label.d.ts +370 -0
  219. package/packages/core/dist/memory/dream/label.d.ts.map +1 -0
  220. package/packages/core/dist/memory/dream/label.js +439 -0
  221. package/packages/core/dist/memory/dream/label.js.map +1 -0
  222. package/packages/core/dist/memory/dream/measure.d.ts +114 -0
  223. package/packages/core/dist/memory/dream/measure.d.ts.map +1 -0
  224. package/packages/core/dist/memory/dream/measure.js +205 -0
  225. package/packages/core/dist/memory/dream/measure.js.map +1 -0
  226. package/packages/core/dist/memory/dream/policy.d.ts +21 -0
  227. package/packages/core/dist/memory/dream/policy.d.ts.map +1 -0
  228. package/packages/core/dist/memory/dream/policy.js +157 -0
  229. package/packages/core/dist/memory/dream/policy.js.map +1 -0
  230. package/packages/core/dist/memory/dream/probe.d.ts +202 -0
  231. package/packages/core/dist/memory/dream/probe.d.ts.map +1 -0
  232. package/packages/core/dist/memory/dream/probe.js +671 -0
  233. package/packages/core/dist/memory/dream/probe.js.map +1 -0
  234. package/packages/core/dist/memory/dream/promote.d.ts +312 -0
  235. package/packages/core/dist/memory/dream/promote.d.ts.map +1 -0
  236. package/packages/core/dist/memory/dream/promote.js +528 -0
  237. package/packages/core/dist/memory/dream/promote.js.map +1 -0
  238. package/packages/core/dist/memory/dream/score.d.ts +103 -0
  239. package/packages/core/dist/memory/dream/score.d.ts.map +1 -0
  240. package/packages/core/dist/memory/dream/score.js +334 -0
  241. package/packages/core/dist/memory/dream/score.js.map +1 -0
  242. package/packages/core/dist/memory/dream/slots.d.ts +193 -0
  243. package/packages/core/dist/memory/dream/slots.d.ts.map +1 -0
  244. package/packages/core/dist/memory/dream/slots.js +0 -0
  245. package/packages/core/dist/memory/dream/slots.js.map +1 -0
  246. package/packages/core/dist/memory/dream/trajectory.d.ts +262 -0
  247. package/packages/core/dist/memory/dream/trajectory.d.ts.map +1 -0
  248. package/packages/core/dist/memory/dream/trajectory.js +366 -0
  249. package/packages/core/dist/memory/dream/trajectory.js.map +1 -0
  250. package/packages/core/dist/memory/extractor.d.ts +7 -0
  251. package/packages/core/dist/memory/extractor.d.ts.map +1 -1
  252. package/packages/core/dist/memory/extractor.js +35 -12
  253. package/packages/core/dist/memory/extractor.js.map +1 -1
  254. package/packages/core/dist/memory/gate.d.ts +43 -7
  255. package/packages/core/dist/memory/gate.d.ts.map +1 -1
  256. package/packages/core/dist/memory/gate.js +91 -4
  257. package/packages/core/dist/memory/gate.js.map +1 -1
  258. package/packages/core/dist/memory/recall.d.ts +57 -0
  259. package/packages/core/dist/memory/recall.d.ts.map +1 -1
  260. package/packages/core/dist/memory/recall.js +60 -123
  261. package/packages/core/dist/memory/recall.js.map +1 -1
  262. package/packages/core/dist/memory/sleep.d.ts +131 -4
  263. package/packages/core/dist/memory/sleep.d.ts.map +1 -1
  264. package/packages/core/dist/memory/sleep.js +2384 -65
  265. package/packages/core/dist/memory/sleep.js.map +1 -1
  266. package/packages/core/dist/memory/store.d.ts +564 -10
  267. package/packages/core/dist/memory/store.d.ts.map +1 -1
  268. package/packages/core/dist/memory/store.js +1673 -102
  269. package/packages/core/dist/memory/store.js.map +1 -1
  270. package/packages/core/dist/org/controller.d.ts +282 -3
  271. package/packages/core/dist/org/controller.d.ts.map +1 -1
  272. package/packages/core/dist/org/controller.js +2334 -237
  273. package/packages/core/dist/org/controller.js.map +1 -1
  274. package/packages/core/dist/org/ponytail.d.ts +1 -1
  275. package/packages/core/dist/org/ponytail.js +1 -1
  276. package/packages/core/dist/org/project-mcp.d.ts +3 -3
  277. package/packages/core/dist/org/prompts.d.ts +41 -28
  278. package/packages/core/dist/org/prompts.d.ts.map +1 -1
  279. package/packages/core/dist/org/prompts.js +281 -94
  280. package/packages/core/dist/org/prompts.js.map +1 -1
  281. package/packages/core/dist/org/questions.d.ts +104 -0
  282. package/packages/core/dist/org/questions.d.ts.map +1 -0
  283. package/packages/core/dist/org/questions.js +136 -0
  284. package/packages/core/dist/org/questions.js.map +1 -0
  285. package/packages/core/dist/org/review.d.ts +100 -0
  286. package/packages/core/dist/org/review.d.ts.map +1 -0
  287. package/packages/core/dist/org/review.js +256 -0
  288. package/packages/core/dist/org/review.js.map +1 -0
  289. package/packages/core/dist/org/store.d.ts +249 -2
  290. package/packages/core/dist/org/store.d.ts.map +1 -1
  291. package/packages/core/dist/org/store.js +787 -13
  292. package/packages/core/dist/org/store.js.map +1 -1
  293. package/packages/core/dist/org/tools.d.ts +26 -2
  294. package/packages/core/dist/org/tools.d.ts.map +1 -1
  295. package/packages/core/dist/org/tools.js +352 -63
  296. package/packages/core/dist/org/tools.js.map +1 -1
  297. package/packages/core/dist/providers/catalogue.d.ts +1 -1
  298. package/packages/core/dist/providers/catalogue.d.ts.map +1 -1
  299. package/packages/core/dist/providers/catalogue.js +2 -2
  300. package/packages/core/dist/providers/catalogue.js.map +1 -1
  301. package/packages/core/dist/providers/claude-code.d.ts +18 -3
  302. package/packages/core/dist/providers/claude-code.d.ts.map +1 -1
  303. package/packages/core/dist/providers/claude-code.js +490 -40
  304. package/packages/core/dist/providers/claude-code.js.map +1 -1
  305. package/packages/core/dist/providers/claude-tui.d.ts +175 -0
  306. package/packages/core/dist/providers/claude-tui.d.ts.map +1 -0
  307. package/packages/core/dist/providers/claude-tui.js +683 -0
  308. package/packages/core/dist/providers/claude-tui.js.map +1 -0
  309. package/packages/core/dist/providers/codex-auth.d.ts +15 -0
  310. package/packages/core/dist/providers/codex-auth.d.ts.map +1 -0
  311. package/packages/core/dist/providers/codex-auth.js +127 -0
  312. package/packages/core/dist/providers/codex-auth.js.map +1 -0
  313. package/packages/core/dist/providers/codex-bridge.d.ts +58 -0
  314. package/packages/core/dist/providers/codex-bridge.d.ts.map +1 -0
  315. package/packages/core/dist/providers/codex-bridge.js +375 -0
  316. package/packages/core/dist/providers/codex-bridge.js.map +1 -0
  317. package/packages/core/dist/providers/codex-translate.d.ts +75 -0
  318. package/packages/core/dist/providers/codex-translate.d.ts.map +1 -0
  319. package/packages/core/dist/providers/codex-translate.js +383 -0
  320. package/packages/core/dist/providers/codex-translate.js.map +1 -0
  321. package/packages/core/dist/providers/model-gateway.d.ts +56 -0
  322. package/packages/core/dist/providers/model-gateway.d.ts.map +1 -0
  323. package/packages/core/dist/providers/model-gateway.js +119 -0
  324. package/packages/core/dist/providers/model-gateway.js.map +1 -0
  325. package/packages/core/dist/providers/process.d.ts +3 -1
  326. package/packages/core/dist/providers/process.d.ts.map +1 -1
  327. package/packages/core/dist/providers/process.js +3 -3
  328. package/packages/core/dist/providers/process.js.map +1 -1
  329. package/packages/core/dist/providers/profiles.d.ts +11 -0
  330. package/packages/core/dist/providers/profiles.d.ts.map +1 -0
  331. package/packages/core/dist/providers/profiles.js +28 -0
  332. package/packages/core/dist/providers/profiles.js.map +1 -0
  333. package/packages/core/dist/providers/provider-catalog.d.ts +72 -0
  334. package/packages/core/dist/providers/provider-catalog.d.ts.map +1 -0
  335. package/packages/core/dist/providers/provider-catalog.js +144 -0
  336. package/packages/core/dist/providers/provider-catalog.js.map +1 -0
  337. package/packages/core/dist/providers/quota.d.ts +40 -1
  338. package/packages/core/dist/providers/quota.d.ts.map +1 -1
  339. package/packages/core/dist/providers/quota.js +288 -25
  340. package/packages/core/dist/providers/quota.js.map +1 -1
  341. package/packages/core/dist/providers/registry.d.ts +46 -3
  342. package/packages/core/dist/providers/registry.d.ts.map +1 -1
  343. package/packages/core/dist/providers/registry.js +148 -13
  344. package/packages/core/dist/providers/registry.js.map +1 -1
  345. package/packages/core/dist/providers/router.d.ts +28 -0
  346. package/packages/core/dist/providers/router.d.ts.map +1 -0
  347. package/packages/core/dist/providers/router.js +88 -0
  348. package/packages/core/dist/providers/router.js.map +1 -0
  349. package/packages/core/dist/providers/user-settings-guard.d.ts +12 -0
  350. package/packages/core/dist/providers/user-settings-guard.d.ts.map +1 -0
  351. package/packages/core/dist/providers/user-settings-guard.js +130 -0
  352. package/packages/core/dist/providers/user-settings-guard.js.map +1 -0
  353. package/packages/core/dist/runtime.d.ts +140 -6
  354. package/packages/core/dist/runtime.d.ts.map +1 -1
  355. package/packages/core/dist/runtime.js +1312 -225
  356. package/packages/core/dist/runtime.js.map +1 -1
  357. package/packages/core/dist/skills/builtin.d.ts +34 -0
  358. package/packages/core/dist/skills/builtin.d.ts.map +1 -0
  359. package/packages/core/dist/skills/builtin.js +305 -0
  360. package/packages/core/dist/skills/builtin.js.map +1 -0
  361. package/packages/core/dist/skills/shelf.d.ts +30 -0
  362. package/packages/core/dist/skills/shelf.d.ts.map +1 -0
  363. package/packages/core/dist/skills/shelf.js +159 -0
  364. package/packages/core/dist/skills/shelf.js.map +1 -0
  365. package/packages/core/dist/skills/store.d.ts +66 -4
  366. package/packages/core/dist/skills/store.d.ts.map +1 -1
  367. package/packages/core/dist/skills/store.js +105 -18
  368. package/packages/core/dist/skills/store.js.map +1 -1
  369. package/packages/core/dist/skills/suggest.d.ts +21 -0
  370. package/packages/core/dist/skills/suggest.d.ts.map +1 -0
  371. package/packages/core/dist/skills/suggest.js +150 -0
  372. package/packages/core/dist/skills/suggest.js.map +1 -0
  373. package/packages/core/dist/tools/catalog.d.ts +1 -3
  374. package/packages/core/dist/tools/catalog.d.ts.map +1 -1
  375. package/packages/core/dist/tools/catalog.js +38 -26
  376. package/packages/core/dist/tools/catalog.js.map +1 -1
  377. package/packages/core/dist/tools/hub.d.ts +136 -10
  378. package/packages/core/dist/tools/hub.d.ts.map +1 -1
  379. package/packages/core/dist/tools/hub.js +418 -24
  380. package/packages/core/dist/tools/hub.js.map +1 -1
  381. package/packages/core/dist/turns/journal.d.ts +78 -0
  382. package/packages/core/dist/turns/journal.d.ts.map +1 -0
  383. package/packages/core/dist/turns/journal.js +104 -0
  384. package/packages/core/dist/turns/journal.js.map +1 -0
  385. package/packages/core/dist/types.d.ts +1598 -12
  386. package/packages/core/dist/types.d.ts.map +1 -1
  387. package/packages/core/dist/types.js.map +1 -1
  388. package/packages/core/dist/util/blocks.d.ts +41 -0
  389. package/packages/core/dist/util/blocks.d.ts.map +1 -0
  390. package/packages/core/dist/util/blocks.js +175 -0
  391. package/packages/core/dist/util/blocks.js.map +1 -0
  392. package/packages/core/dist/util/queue.d.ts +12 -0
  393. package/packages/core/dist/util/queue.d.ts.map +1 -1
  394. package/packages/core/dist/util/queue.js +16 -0
  395. package/packages/core/dist/util/queue.js.map +1 -1
  396. package/packages/core/dist/util/time.d.ts +39 -0
  397. package/packages/core/dist/util/time.d.ts.map +1 -0
  398. package/packages/core/dist/util/time.js +71 -0
  399. package/packages/core/dist/util/time.js.map +1 -0
  400. package/packages/core/package.json +1 -1
  401. package/packages/server/dist/auth.d.ts +14 -1
  402. package/packages/server/dist/auth.d.ts.map +1 -1
  403. package/packages/server/dist/auth.js +19 -0
  404. package/packages/server/dist/auth.js.map +1 -1
  405. package/packages/server/dist/context.d.ts +35 -1
  406. package/packages/server/dist/context.d.ts.map +1 -1
  407. package/packages/server/dist/context.js +28 -8
  408. package/packages/server/dist/context.js.map +1 -1
  409. package/packages/server/dist/gateways/attachments.d.ts +32 -0
  410. package/packages/server/dist/gateways/attachments.d.ts.map +1 -0
  411. package/packages/server/dist/gateways/attachments.js +167 -0
  412. package/packages/server/dist/gateways/attachments.js.map +1 -0
  413. package/packages/server/dist/gateways/markdown.d.ts +9 -0
  414. package/packages/server/dist/gateways/markdown.d.ts.map +1 -0
  415. package/packages/server/dist/gateways/markdown.js +170 -0
  416. package/packages/server/dist/gateways/markdown.js.map +1 -0
  417. package/packages/server/dist/gateways/push.d.ts +1 -1
  418. package/packages/server/dist/gateways/push.d.ts.map +1 -1
  419. package/packages/server/dist/gateways/push.js +347 -6
  420. package/packages/server/dist/gateways/push.js.map +1 -1
  421. package/packages/server/dist/gateways/telegram-api.d.ts +70 -1
  422. package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -1
  423. package/packages/server/dist/gateways/telegram-api.js +140 -1
  424. package/packages/server/dist/gateways/telegram-api.js.map +1 -1
  425. package/packages/server/dist/gateways/telegram.d.ts +158 -1
  426. package/packages/server/dist/gateways/telegram.d.ts.map +1 -1
  427. package/packages/server/dist/gateways/telegram.js +1471 -78
  428. package/packages/server/dist/gateways/telegram.js.map +1 -1
  429. package/packages/server/dist/gateways/threads.d.ts +79 -0
  430. package/packages/server/dist/gateways/threads.d.ts.map +1 -0
  431. package/packages/server/dist/gateways/threads.js +279 -0
  432. package/packages/server/dist/gateways/threads.js.map +1 -0
  433. package/packages/server/dist/index.d.ts +2 -1
  434. package/packages/server/dist/index.d.ts.map +1 -1
  435. package/packages/server/dist/index.js +2 -1
  436. package/packages/server/dist/index.js.map +1 -1
  437. package/packages/server/dist/listeners/imap.d.ts +13 -0
  438. package/packages/server/dist/listeners/imap.d.ts.map +1 -0
  439. package/packages/server/dist/listeners/imap.js +0 -0
  440. package/packages/server/dist/listeners/imap.js.map +1 -0
  441. package/packages/server/dist/listeners/registry.d.ts +18 -0
  442. package/packages/server/dist/listeners/registry.d.ts.map +1 -0
  443. package/packages/server/dist/listeners/registry.js +88 -0
  444. package/packages/server/dist/listeners/registry.js.map +1 -0
  445. package/packages/server/dist/listeners/types.d.ts +55 -0
  446. package/packages/server/dist/listeners/types.d.ts.map +1 -0
  447. package/packages/server/dist/listeners/types.js +2 -0
  448. package/packages/server/dist/listeners/types.js.map +1 -0
  449. package/packages/server/dist/main.js +15 -1
  450. package/packages/server/dist/main.js.map +1 -1
  451. package/packages/server/dist/routes/chat.d.ts +7 -3
  452. package/packages/server/dist/routes/chat.d.ts.map +1 -1
  453. package/packages/server/dist/routes/chat.js +8 -17
  454. package/packages/server/dist/routes/chat.js.map +1 -1
  455. package/packages/server/dist/routes/config.d.ts.map +1 -1
  456. package/packages/server/dist/routes/config.js +39 -7
  457. package/packages/server/dist/routes/config.js.map +1 -1
  458. package/packages/server/dist/routes/cron.d.ts.map +1 -1
  459. package/packages/server/dist/routes/cron.js +65 -8
  460. package/packages/server/dist/routes/cron.js.map +1 -1
  461. package/packages/server/dist/routes/dream.d.ts +22 -0
  462. package/packages/server/dist/routes/dream.d.ts.map +1 -0
  463. package/packages/server/dist/routes/dream.js +152 -0
  464. package/packages/server/dist/routes/dream.js.map +1 -0
  465. package/packages/server/dist/routes/hooks.d.ts +18 -0
  466. package/packages/server/dist/routes/hooks.d.ts.map +1 -0
  467. package/packages/server/dist/routes/hooks.js +62 -0
  468. package/packages/server/dist/routes/hooks.js.map +1 -0
  469. package/packages/server/dist/routes/listeners.d.ts +10 -0
  470. package/packages/server/dist/routes/listeners.d.ts.map +1 -0
  471. package/packages/server/dist/routes/listeners.js +12 -0
  472. package/packages/server/dist/routes/listeners.js.map +1 -0
  473. package/packages/server/dist/routes/memories.d.ts.map +1 -1
  474. package/packages/server/dist/routes/memories.js +55 -3
  475. package/packages/server/dist/routes/memories.js.map +1 -1
  476. package/packages/server/dist/routes/org.d.ts.map +1 -1
  477. package/packages/server/dist/routes/org.js +284 -48
  478. package/packages/server/dist/routes/org.js.map +1 -1
  479. package/packages/server/dist/routes/profile.d.ts.map +1 -1
  480. package/packages/server/dist/routes/profile.js +6 -3
  481. package/packages/server/dist/routes/profile.js.map +1 -1
  482. package/packages/server/dist/routes/providers.d.ts.map +1 -1
  483. package/packages/server/dist/routes/providers.js +66 -7
  484. package/packages/server/dist/routes/providers.js.map +1 -1
  485. package/packages/server/dist/routes/questions.d.ts +45 -0
  486. package/packages/server/dist/routes/questions.d.ts.map +1 -0
  487. package/packages/server/dist/routes/questions.js +73 -0
  488. package/packages/server/dist/routes/questions.js.map +1 -0
  489. package/packages/server/dist/routes/sessions.d.ts.map +1 -1
  490. package/packages/server/dist/routes/sessions.js +26 -6
  491. package/packages/server/dist/routes/sessions.js.map +1 -1
  492. package/packages/server/dist/routes/sleep.d.ts.map +1 -1
  493. package/packages/server/dist/routes/sleep.js +71 -2
  494. package/packages/server/dist/routes/sleep.js.map +1 -1
  495. package/packages/server/dist/routes/terminals.d.ts +25 -0
  496. package/packages/server/dist/routes/terminals.d.ts.map +1 -0
  497. package/packages/server/dist/routes/terminals.js +35 -0
  498. package/packages/server/dist/routes/terminals.js.map +1 -0
  499. package/packages/server/dist/routes/tools.d.ts.map +1 -1
  500. package/packages/server/dist/routes/tools.js +140 -6
  501. package/packages/server/dist/routes/tools.js.map +1 -1
  502. package/packages/server/dist/routes/updates.d.ts +10 -0
  503. package/packages/server/dist/routes/updates.d.ts.map +1 -0
  504. package/packages/server/dist/routes/updates.js +22 -0
  505. package/packages/server/dist/routes/updates.js.map +1 -0
  506. package/packages/server/dist/routes/ws.d.ts +11 -5
  507. package/packages/server/dist/routes/ws.d.ts.map +1 -1
  508. package/packages/server/dist/routes/ws.js +162 -28
  509. package/packages/server/dist/routes/ws.js.map +1 -1
  510. package/packages/server/dist/schemas.d.ts +1125 -211
  511. package/packages/server/dist/schemas.d.ts.map +1 -1
  512. package/packages/server/dist/schemas.js +300 -12
  513. package/packages/server/dist/schemas.js.map +1 -1
  514. package/packages/server/dist/server.d.ts +7 -1
  515. package/packages/server/dist/server.d.ts.map +1 -1
  516. package/packages/server/dist/server.js +186 -3
  517. package/packages/server/dist/server.js.map +1 -1
  518. package/packages/server/dist/services/stream.d.ts +89 -5
  519. package/packages/server/dist/services/stream.d.ts.map +1 -1
  520. package/packages/server/dist/services/stream.js +9 -20
  521. package/packages/server/dist/services/stream.js.map +1 -1
  522. package/packages/server/dist/services/stt.d.ts +65 -0
  523. package/packages/server/dist/services/stt.d.ts.map +1 -0
  524. package/packages/server/dist/services/stt.js +306 -0
  525. package/packages/server/dist/services/stt.js.map +1 -0
  526. package/packages/server/dist/services/turns.d.ts +49 -0
  527. package/packages/server/dist/services/turns.d.ts.map +1 -0
  528. package/packages/server/dist/services/turns.js +138 -0
  529. package/packages/server/dist/services/turns.js.map +1 -0
  530. package/packages/server/dist/services/updates.d.ts +99 -0
  531. package/packages/server/dist/services/updates.d.ts.map +1 -0
  532. package/packages/server/dist/services/updates.js +316 -0
  533. package/packages/server/dist/services/updates.js.map +1 -0
  534. package/packages/server/package.json +1 -1
  535. package/packages/web/dist/app-icon.svg +2 -0
  536. package/packages/web/dist/apple-touch-icon.png +0 -0
  537. package/packages/web/dist/assets/abnfDiagram-O67JEVCF-B4qWcqra.js +1 -0
  538. package/packages/web/dist/assets/arc-CQult7TN.js +1 -0
  539. package/packages/web/dist/assets/architectureDiagram-NJMV4G6O-DFTRvl66.js +36 -0
  540. package/packages/web/dist/assets/blockDiagram-BEXU5L5S-TCFoK_k-.js +140 -0
  541. package/packages/web/dist/assets/c4Diagram-YGBWAQC7-i5_GqhJa.js +38 -0
  542. package/packages/web/dist/assets/channel-D_4EmqNR.js +1 -0
  543. package/packages/web/dist/assets/chunk-2Q5K7J3B-BK6I2wfW.js +1 -0
  544. package/packages/web/dist/assets/chunk-3FUC2YCW-Dw-TfKT0.js +2 -0
  545. package/packages/web/dist/assets/chunk-5VM5RSS4-AE_XRNTT.js +15 -0
  546. package/packages/web/dist/assets/chunk-GTNCS2PH-DO18WaaJ.js +88 -0
  547. package/packages/web/dist/assets/chunk-GWA4HPMP-3rdjszP_.js +1 -0
  548. package/packages/web/dist/assets/chunk-JWPE2WC7-C93LH2D0.js +1 -0
  549. package/packages/web/dist/assets/chunk-NETBCI7D-Dj7O3-H-.js +1 -0
  550. package/packages/web/dist/assets/chunk-WEXAMYUT-BRFvQUIn.js +1 -0
  551. package/packages/web/dist/assets/chunk-XXDRQBXY-CXx6HMbz.js +1 -0
  552. package/packages/web/dist/assets/classDiagram-v2-NBCMYWYE-BGXszxjn.js +217 -0
  553. package/packages/web/dist/assets/cose-bilkent-JH36ORCC-BAuXqkne.js +1 -0
  554. package/packages/web/dist/assets/cynefin-OW5HDTMX-plNzhY7J.js +178 -0
  555. package/packages/web/dist/assets/cynefinDiagram-VND7K2PF-DuPlljFS.js +62 -0
  556. package/packages/web/dist/assets/cytoscape.esm-Ix0LnXOy.js +331 -0
  557. package/packages/web/dist/assets/dagre-6A5THRUB-CXzwdR-6.js +4 -0
  558. package/packages/web/dist/assets/diagram-22UHCM2B-B7iv_V2D.js +200 -0
  559. package/packages/web/dist/assets/diagram-3UASUU5V-BMvi7gSi.js +24 -0
  560. package/packages/web/dist/assets/diagram-ATOU4E4O-NJ7EB5Qg.js +3 -0
  561. package/packages/web/dist/assets/diagram-CDSNMT55-DccMMNJ-.js +30 -0
  562. package/packages/web/dist/assets/diagram-MLGK6HIB-BbwGHK4g.js +24 -0
  563. package/packages/web/dist/assets/diagram-MPIPVDR6-BbSSZfM3.js +41 -0
  564. package/packages/web/dist/assets/draco_decoder-C32yEggz.wasm +0 -0
  565. package/packages/web/dist/assets/draco_decoder-Z1_iN-Ht.wasm +0 -0
  566. package/packages/web/dist/assets/draco_decoder-fzg4nYZr.js +34 -0
  567. package/packages/web/dist/assets/draco_wasm_wrapper-DxJM36Ib.js +117 -0
  568. package/packages/web/dist/assets/draco_wasm_wrapper-fZCQGLGb.js +116 -0
  569. package/packages/web/dist/assets/ebnfDiagram-ZINNZB2B-BBfPNM85.js +1 -0
  570. package/packages/web/dist/assets/elk-276RUBZZ-dM3Y1d2a.js +27 -0
  571. package/packages/web/dist/assets/erDiagram-OPXOYQCR-iWrUegxy.js +99 -0
  572. package/packages/web/dist/assets/flowDiagram-KWPJA3E3-B6DYlbkV.js +213 -0
  573. package/packages/web/dist/assets/ganttDiagram-FUAMR5RP-D7dSWZcC.js +292 -0
  574. package/packages/web/dist/assets/gitGraphDiagram-X574FWY7-DguFgcbW.js +106 -0
  575. package/packages/web/dist/assets/graph-Bn3Yngep.js +1 -0
  576. package/packages/web/dist/assets/index-B1QvSHA5.js +660 -0
  577. package/packages/web/dist/assets/index-zwMuaz90.css +32 -0
  578. package/packages/web/dist/assets/infoDiagram-VRGFBTTK-CuiuO3uo.js +2 -0
  579. package/packages/web/dist/assets/ishikawaDiagram-OU5B5YK6-wBS1_40m.js +70 -0
  580. package/packages/web/dist/assets/journeyDiagram-ZHPQQLJL-Bd1YE2gP.js +139 -0
  581. package/packages/web/dist/assets/kanban-definition-PNTS6WVX-BlQzv_X1.js +89 -0
  582. package/packages/web/dist/assets/katex-C5jXJg4s.js +257 -0
  583. package/packages/web/dist/assets/mermaid.core-p3CwmLUb.js +313 -0
  584. package/packages/web/dist/assets/mindmap-definition-NLK3R4M7-BlticnKl.js +96 -0
  585. package/packages/web/dist/assets/pegDiagram-GJSIUBJH-BbXsP47B.js +1 -0
  586. package/packages/web/dist/assets/pieDiagram-5QR66LMP-BooBSBug.js +39 -0
  587. package/packages/web/dist/assets/quadrantDiagram-O4NWA36T-CkXC6VCh.js +7 -0
  588. package/packages/web/dist/assets/railroadDiagram-XR7U4H2S-BphzYiW-.js +1 -0
  589. package/packages/web/dist/assets/requirementDiagram-PLB6GJNP-PWpD4zpQ.js +84 -0
  590. package/packages/web/dist/assets/sankeyDiagram-IPEJSGJF-5Qm39Vfz.js +40 -0
  591. package/packages/web/dist/assets/scene-D4LPicHk.js +4620 -0
  592. package/packages/web/dist/assets/sequenceDiagram-PO4LG4MO-DA673J_w.js +169 -0
  593. package/packages/web/dist/assets/sizeCapture-INFHLROL-1KsNwBhd.js +1 -0
  594. package/packages/web/dist/assets/stateDiagram-v2-GCMORJYK-D7O0UyHr.js +291 -0
  595. package/packages/web/dist/assets/swimlanes-2SLR337P-culFSb1R.js +1 -0
  596. package/packages/web/dist/assets/swimlanesDiagram-TC7HE7FX-kzTmK2BP.js +8 -0
  597. package/packages/web/dist/assets/timeline-definition-EJHVYXUP-6GIO5p-k.js +120 -0
  598. package/packages/web/dist/assets/usecaseDiagram-POWQR4AR-BAGHDBzZ.js +370 -0
  599. package/packages/web/dist/assets/vennDiagram-UO4OBE2U-PbtBvPRE.js +34 -0
  600. package/packages/web/dist/assets/wardleyDiagram-VNRHLVJA-9scbtDvX.js +78 -0
  601. package/packages/web/dist/assets/xychartDiagram-PMCCYNJV-C51PiF4p.js +7 -0
  602. package/packages/web/dist/draco/draco_decoder.js +33 -0
  603. package/packages/web/dist/draco/draco_decoder.wasm +0 -0
  604. package/packages/web/dist/draco/draco_wasm_wrapper.js +116 -0
  605. package/packages/web/dist/favicon-16.png +0 -0
  606. package/packages/web/dist/favicon-32.png +0 -0
  607. package/packages/web/dist/favicon-48.png +0 -0
  608. package/packages/web/dist/favicon.ico +0 -0
  609. package/packages/web/dist/favicon.svg +1 -1
  610. package/packages/web/dist/icon-192.png +0 -0
  611. package/packages/web/dist/icon-512.png +0 -0
  612. package/packages/web/dist/index.html +12 -4
  613. package/packages/web/dist/logo-light.svg +1 -1
  614. package/packages/web/dist/logo-mono.svg +2 -0
  615. package/packages/web/dist/logo-stacked-light.svg +2 -0
  616. package/packages/web/dist/logo-stacked.svg +2 -0
  617. package/packages/web/dist/logo-white.svg +2 -0
  618. package/packages/web/dist/logo.svg +1 -1
  619. package/packages/web/dist/mark-light.svg +1 -1
  620. package/packages/web/dist/mark-mono.svg +2 -0
  621. package/packages/web/dist/mark-small-light.svg +2 -0
  622. package/packages/web/dist/mark-small.svg +2 -0
  623. package/packages/web/dist/mark-white.svg +2 -0
  624. package/packages/web/dist/mark.svg +1 -1
  625. package/packages/web/dist/models/LICENSE.txt +5 -0
  626. package/packages/web/dist/models/brain.glb +0 -0
  627. package/packages/web/dist/site.webmanifest +23 -0
  628. package/packages/web/dist/wordmark-light.svg +2 -0
  629. package/packages/web/dist/wordmark.svg +2 -0
  630. package/packages/web/package.json +1 -1
  631. package/scripts/rookery.mjs +204 -122
  632. package/scripts/updater.mjs +227 -0
  633. package/packages/cli/dist/tui/components/Wordmark.d.ts +0 -35
  634. package/packages/cli/dist/tui/components/Wordmark.d.ts.map +0 -1
  635. package/packages/cli/dist/tui/components/Wordmark.js +0 -81
  636. package/packages/cli/dist/tui/components/Wordmark.js.map +0 -1
  637. package/packages/core/dist/agents/orchestrator.d.ts +0 -24
  638. package/packages/core/dist/agents/orchestrator.d.ts.map +0 -1
  639. package/packages/core/dist/agents/orchestrator.js +0 -88
  640. package/packages/core/dist/agents/orchestrator.js.map +0 -1
  641. package/packages/core/dist/agents/roles.d.ts +0 -21
  642. package/packages/core/dist/agents/roles.d.ts.map +0 -1
  643. package/packages/core/dist/agents/roles.js +0 -81
  644. package/packages/core/dist/agents/roles.js.map +0 -1
  645. package/packages/core/dist/agents/team.d.ts +0 -105
  646. package/packages/core/dist/agents/team.d.ts.map +0 -1
  647. package/packages/core/dist/agents/team.js +0 -623
  648. package/packages/core/dist/agents/team.js.map +0 -1
  649. package/packages/core/dist/providers/codex.d.ts +0 -10
  650. package/packages/core/dist/providers/codex.d.ts.map +0 -1
  651. package/packages/core/dist/providers/codex.js +0 -375
  652. package/packages/core/dist/providers/codex.js.map +0 -1
  653. package/packages/core/dist/tools/browser.d.ts +0 -20
  654. package/packages/core/dist/tools/browser.d.ts.map +0 -1
  655. package/packages/core/dist/tools/browser.js +0 -72
  656. package/packages/core/dist/tools/browser.js.map +0 -1
  657. package/packages/server/dist/routes/agents.d.ts +0 -5
  658. package/packages/server/dist/routes/agents.d.ts.map +0 -1
  659. package/packages/server/dist/routes/agents.js +0 -6
  660. package/packages/server/dist/routes/agents.js.map +0 -1
  661. package/packages/server/dist/routes/team.d.ts +0 -11
  662. package/packages/server/dist/routes/team.d.ts.map +0 -1
  663. package/packages/server/dist/routes/team.js +0 -36
  664. package/packages/server/dist/routes/team.js.map +0 -1
  665. package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +0 -1163
  666. package/packages/web/dist/assets/index-IBSTzK7-.js +0 -1255
  667. package/packages/web/dist/assets/index-qUXUui7W.css +0 -1
  668. package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +0 -4
  669. package/packages/web/dist/assets/three.module-cmFfBtHS.js +0 -4228
@@ -7,112 +7,492 @@
7
7
  * need. It speaks the same sliver of MCP (initialize, tools/list, tools/call,
8
8
  * ping) and keeps one PowerShell alive for the length of the turn.
9
9
  */
10
- import { mkdirSync } from 'node:fs';
10
+ import { appendFileSync, mkdirSync } from 'node:fs';
11
11
  import { join } from 'node:path';
12
12
  import { createInterface } from 'node:readline';
13
+ import { setTimeout as delay } from 'node:timers/promises';
14
+ import { describeAct, describeControl, describeSnapshot } from './accessibility.js';
13
15
  import { parseKeySequence } from './keys.js';
14
16
  import { PowerShellSession, psQuote } from './powershell.js';
15
17
  import { COMPUTER_SERVER_NAME, COMPUTER_TOOLS } from './tools.js';
18
+ import { describeScreen, describeSettle, describeWindow, findText, pickMatch, } from './screen-text.js';
19
+ import { clipStrokes, fitViewBox, multiply, svgStrokes, svgViewBox } from './sketch.js';
20
+ import { batchObservation, validateComputerCall } from './validation.js';
16
21
  const PROTOCOL_FALLBACK = '2025-06-18';
17
- const MAX_WIDTH = Math.max(320, Number(process.env.ROOKERY_COMPUTER_MAX_WIDTH) || 1280);
22
+ const MAX_WIDTH = Math.min(3840, Math.max(320, Number(process.env.ROOKERY_COMPUTER_MAX_WIDTH) || 1280));
18
23
  const RUN_DIR = process.env.ROOKERY_COMPUTER_DIR ? join(process.env.ROOKERY_COMPUTER_DIR, 'run') : '';
24
+ const BACKGROUND = process.env.ROOKERY_COMPUTER_MODE === 'background';
19
25
  const shell = new PowerShellSession();
26
+ // Warm the worker and its cursor while the model is still writing its first call;
27
+ // the first action then finds everything loaded. A failure here surfaces on that call.
28
+ if (process.platform === 'win32')
29
+ shell.run('Rk-Overlay; @{}').catch(() => undefined);
30
+ let stopped = false;
31
+ let queue = Promise.resolve();
32
+ const pending = new Set();
33
+ const observations = new Set(['screenshot', 'screen_info', 'list_windows', 'snapshot', 'read_screen', 'find_text', 'stop']);
20
34
  /* --------------------------------- mapping -------------------------------- */
21
- /** Screenshot pixels to real screen pixels: the last shot's scale, or the current one. */
35
+ /**
36
+ * The view: what the last desktop capture showed, and how its pixels map to
37
+ * the screen. Every coordinate the model sends or reads refers to it. A
38
+ * zoomed screenshot narrows it to a region; read_screen and a plain
39
+ * screenshot widen it back to the whole desktop. Whether the screen still
40
+ * looks like that is the worker's business: its guard compares the window in
41
+ * front with what it saw at the end of its own last action or observation.
42
+ */
22
43
  let view = null;
23
- async function mapping() {
24
- if (view)
25
- return view;
26
- const info = await shell.run('Rk-ScreenInfo');
27
- view = { scale: Math.min(1, MAX_WIDTH / info.width), left: info.left, top: info.top };
28
- return view;
29
- }
30
- async function toScreen(x, y) {
31
- const m = await mapping();
32
- const px = Number(x);
33
- const py = Number(y);
34
- if (!Number.isFinite(px) || !Number.isFinite(py))
35
- throw new Error('x and y must be numbers.');
36
- return [Math.round(m.left + px / m.scale), Math.round(m.top + py / m.scale)];
37
- }
38
- const text = (args, key) => typeof args[key] === 'string' ? args[key] : '';
39
- const num = (args, key, fallback) => {
40
- const value = Number(args[key]);
41
- return Number.isFinite(value) ? value : fallback;
42
- };
44
+ function toScreen(x, y) {
45
+ if (!view)
46
+ throw new Error('Take a desktop screenshot or read_screen before using coordinates. Window screenshots use different coordinates.');
47
+ if (x >= view.width || y >= view.height)
48
+ throw new Error('Coordinates are outside the last desktop screenshot (' + view.width + 'x' + view.height + ').');
49
+ return [Math.round(view.left + x / view.scale), Math.round(view.top + y / view.scale)];
50
+ }
51
+ /** A physical point as the model would write it: in pixels of the current view. */
52
+ function toView(x, y) {
53
+ if (!view)
54
+ return x + ',' + y + ' (screen pixels)';
55
+ return Math.round((x - view.left) * view.scale) + ',' + Math.round((y - view.top) * view.scale);
56
+ }
57
+ /** How a worker report in physical pixels is printed: through the view, or the whole desktop when there is none. */
58
+ function mapping(screen) {
59
+ return view ?? { left: screen.left, top: screen.top, scale: Math.min(1, MAX_WIDTH / screen.width) };
60
+ }
61
+ /** The screen's text lines in the current view, for error messages: the same coordinates the other listings use. */
62
+ function visible(screen, limit = 40) {
63
+ const map = mapping(screen);
64
+ return describeScreen(screen, map.scale, limit, map);
65
+ }
66
+ /** Observations the worker has not made since it was last restarted after a timeout. */
67
+ let restartsSeen = 0;
68
+ /** Physical actions currently dispatched to the worker. */
69
+ let inputInFlight = 0;
70
+ /**
71
+ * A worker killed mid-action (stop, timeout, end of turn) cannot run its own
72
+ * cleanup, so a drag's button or a shortcut's modifier would stay down for the
73
+ * user. A fresh worker lets go of whatever is still held.
74
+ */
75
+ async function releaseHeld(timeoutMs = 10_000) {
76
+ await shell.run('Rk-Release', timeoutMs).catch(() => undefined);
77
+ }
78
+ /** Serialize physical input across Rookery processes; the worker's guard refuses a changed desktop. */
79
+ async function physical(expression, timeoutMs = 30_000) {
80
+ inputInFlight++;
81
+ try {
82
+ await shell.run('$mutex = New-Object System.Threading.Mutex($false, "Local\\RookeryComputerInput"); ' +
83
+ '$locked = $false; try { try { $locked = $mutex.WaitOne(0) } catch [System.Threading.AbandonedMutexException] { $locked = $true }; ' +
84
+ 'if (-not $locked) { throw "Another Rookery session is using desktop input." }; Rk-Guard; ' + expression +
85
+ ' } finally { if ($locked) { $mutex.ReleaseMutex() }; $mutex.Dispose() }', timeoutMs);
86
+ }
87
+ catch (error) {
88
+ if (!shell.running && !closing)
89
+ await releaseHeld();
90
+ if (shell.restarts > restartsSeen && /before physical input/.test(error.message)) {
91
+ throw new Error('The worker was restarted after a timed-out action, so it has not seen the screen since. Take a fresh screenshot or read_screen before continuing.');
92
+ }
93
+ throw error;
94
+ }
95
+ finally {
96
+ inputInFlight--;
97
+ }
98
+ }
99
+ /** After smoothing; the SVG input is bounded by size, not by what it expands to. */
100
+ const DRAWN_POINTS = 60_000;
101
+ /** Physical pixels one pen-down may cover before it is continued as a new stroke. */
102
+ const MAX_STROKE = 2000;
103
+ /**
104
+ * The draw tool's strokes in physical pixels, clipped to the area (or the
105
+ * whole screenshot), rounded and packed the way the native Draw reads them:
106
+ * stroke count, then per stroke its point count and x, y pairs.
107
+ */
108
+ function planDrawing(args) {
109
+ if (!view)
110
+ throw new Error('Take a desktop screenshot before drawing.');
111
+ const { scale, left, top, width, height } = view;
112
+ const area = args.area ?? { x: 0, y: 0, width: width - 1, height: height - 1 };
113
+ if (area.x + area.width > width || area.y + area.height > height)
114
+ throw new Error('The area reaches outside the last desktop screenshot.');
115
+ const toPhysical = [1 / scale, 0, 0, 1 / scale, left, top];
116
+ const strokes = (args.strokes ?? []).map((stroke) => stroke.flatMap(([x, y]) => [left + x / scale, top + y / scale]));
117
+ if (args.svg) {
118
+ strokes.push(...svgStrokes(args.svg, {
119
+ transform: multiply(toPhysical, fitViewBox(svgViewBox(args.svg), area)),
120
+ tolerance: 0.35,
121
+ hatch: args.hatch && { spacing: args.hatch.spacing / scale, angle: args.hatch.angle, cross: args.hatch.cross },
122
+ }));
123
+ }
124
+ const clip = { x: left + area.x / scale, y: top + area.y / scale, width: area.width / scale, height: area.height / scale };
125
+ const packed = [0];
126
+ let points = 0;
127
+ let ink = 0;
128
+ const emit = (rounded) => {
129
+ packed[0]++;
130
+ packed.push(rounded.length / 2);
131
+ for (const value of rounded)
132
+ packed.push(value);
133
+ points += rounded.length / 2;
134
+ };
135
+ for (const stroke of clipStrokes(strokes, clip)) {
136
+ let rounded = [];
137
+ let length = 0;
138
+ for (let i = 0; i + 1 < stroke.length; i += 2) {
139
+ const x = Math.round(stroke[i]), y = Math.round(stroke[i + 1]);
140
+ const n = rounded.length;
141
+ if (n && rounded[n - 2] === x && rounded[n - 1] === y)
142
+ continue;
143
+ const step = n ? Math.hypot(x - rounded[n - 2], y - rounded[n - 1]) : 0;
144
+ // Some brushes keep only the tail of a very long stroke; continue it as a new one instead.
145
+ if (length + step > MAX_STROKE && n >= 4) {
146
+ emit(rounded);
147
+ rounded = [rounded[n - 2], rounded[n - 1]];
148
+ length = 0;
149
+ }
150
+ ink += step;
151
+ length += step;
152
+ rounded.push(x, y);
153
+ }
154
+ emit(rounded);
155
+ }
156
+ if (!packed[0])
157
+ throw new Error('Nothing to draw: every shape has stroke="none" or lies outside the area.');
158
+ if (points > DRAWN_POINTS)
159
+ throw new Error('Too detailed: ' + points + ' points after smoothing (limit ' + DRAWN_POINTS + '). Split the picture into several draw calls.');
160
+ return {
161
+ packed: Buffer.from(new Int32Array(packed).buffer).toString('base64'),
162
+ strokes: packed[0],
163
+ points,
164
+ // Ink runs at about 3.5 px/ms; each stroke adds a hop and two short holds.
165
+ timeoutMs: 30_000 + ink / 2.5 + packed[0] * 250,
166
+ };
167
+ }
43
168
  /* ---------------------------------- tools --------------------------------- */
44
- async function call(name, args) {
169
+ /**
170
+ * The screen's text, without touching the view: for clicking by text and
171
+ * waiting. Before an action, the guard runs first when there is a baseline,
172
+ * so a window the user switched to is refused rather than read and clicked;
173
+ * with no baseline yet (a turn's first call), the reading establishes one.
174
+ */
175
+ async function ocr(guarded = false) {
176
+ return shell.run((guarded ? 'if ($null -ne $script:rkForeground) { Rk-Guard }; ' : '') + 'Rk-ReadScreen ' + (stopped ? '$false' : '$true'), 20_000);
177
+ }
178
+ /**
179
+ * Recognise the screen's text. Like a screenshot, it becomes the view that
180
+ * physical input maps through, so its coordinates can be clicked directly.
181
+ */
182
+ async function readScreen() {
183
+ const screen = await ocr();
184
+ const scale = Math.min(1, MAX_WIDTH / screen.width);
185
+ view = { scale, left: screen.left, top: screen.top, width: Math.round(screen.width * scale), height: Math.round(screen.height * scale) };
186
+ restartsSeen = shell.restarts;
187
+ return { screen, scale };
188
+ }
189
+ /** A match's centre in physical pixels. */
190
+ function centre(match) {
191
+ return [Math.round(match.x + match.width / 2), Math.round(match.y + match.height / 2)];
192
+ }
193
+ /** One line per text match: where it is in the current view, and what the screen says there. */
194
+ function listMatches(matches) {
195
+ return matches.map((m, i) => (i + 1) + '. ' + toView(...centre(m)) + ' "' + m.text + '"' + (m.approximate ? ' (approximate)' : '') + (m.foreground ? '' : ' (outside the active window)')).join('\n');
196
+ }
197
+ /** Controls named exactly like the phrase in one window, with refs act accepts. */
198
+ async function findControls(window, name) {
199
+ return shell.run('Rk-FindControls ' + window + ' ' + psQuote(name), 20_000);
200
+ }
201
+ function listControls(found, from = 0) {
202
+ const map = mapping(found.screen);
203
+ return found.controls.map((control, i) => (from + i + 1) + '. ' + describeControl(control, map)).join('\n');
204
+ }
205
+ /** Wait, but not past a stop. */
206
+ async function pause(ms) {
207
+ const until = Date.now() + ms;
208
+ while (Date.now() < until) {
209
+ if (stopped)
210
+ throw new Error('Computer use stopped.');
211
+ await delay(Math.min(50, until - Date.now()));
212
+ }
213
+ }
214
+ /**
215
+ * What a physical action returns: the screen once it has stopped changing,
216
+ * so the model sees the result without a second round trip, and never a
217
+ * half-drawn frame from a fixed sleep. With nothing to observe, a short
218
+ * settle still runs: it records what the action left in front, so a dialog
219
+ * the action opened is not mistaken for the user switching windows, and it
220
+ * tells the model when nothing visibly happened.
221
+ */
222
+ async function settled(observe) {
223
+ const result = await shell.run(observe === 'none' ? 'Rk-Settle 40 600 80' : 'Rk-Settle', 5_000);
224
+ const note = { type: 'text', text: describeSettle(result) };
225
+ if (observe === 'none')
226
+ return [note];
227
+ const seen = await perform(validateComputerCall(observe === 'text' ? 'read_screen' : 'screenshot', {}, BACKGROUND));
228
+ return [note, ...seen];
229
+ }
230
+ async function call(command) {
231
+ const content = await perform(command);
232
+ // A batch observes once at its own end; background-only mode has nothing on the desktop to settle.
233
+ if (command.name === 'batch' || BACKGROUND)
234
+ return content;
235
+ // An automation action can open a dialog a moment later; the settle records it as the model's own doing.
236
+ const observe = command.name === 'act' ? 'none' : 'observe' in command.args ? command.args.observe : null;
237
+ if (observe === null)
238
+ return content;
239
+ try {
240
+ return [...content, ...(await settled(observe))];
241
+ }
242
+ catch (error) {
243
+ // The input was sent; losing its result would invite a second, duplicate action.
244
+ return [...content, { type: 'text', text: 'The action was sent, but observing afterwards failed: ' + error.message + ' Take a screenshot before continuing.' }];
245
+ }
246
+ }
247
+ async function perform(command) {
248
+ const { name, args } = command;
249
+ if (stopped && !observations.has(name))
250
+ throw new Error('Computer use stopped. Start a new turn to resume.');
45
251
  switch (name) {
252
+ case 'stop':
253
+ stopped = true;
254
+ view = null;
255
+ shell.close();
256
+ return [{ type: 'text', text: 'Computer use stopped. Current and queued actions cancelled.' }];
257
+ case 'snapshot': {
258
+ const result = await shell.run('Rk-Snapshot ' + args.window + ' ' + args.maxNodes + ' ' + args.depth + ' ' + (stopped ? '$false' : '$true'), 15_000);
259
+ return [{ type: 'text', text: describeSnapshot(result, mapping(result.screen)) }];
260
+ }
261
+ case 'act': {
262
+ // The desktop view stays: physical input re-checks foreground and bounds before it moves.
263
+ const result = await shell.run('Rk-Act ' + psQuote(args.ref) + ' ' + psQuote(args.action) + ' ' + psQuote(args.value ?? ''), 15_000);
264
+ if (BACKGROUND && result.focusChanged) {
265
+ stopped = true;
266
+ shell.close();
267
+ throw new Error(describeAct(result) + ' Background-only mode stopped all further actions; inspect the result before retrying in a new turn.');
268
+ }
269
+ return [{ type: 'text', text: describeAct(result) }];
270
+ }
271
+ case 'batch': {
272
+ // Steps run blind; each still settles briefly, and the batch observes once at its end.
273
+ const actions = args.actions.map((step) => {
274
+ const action = validateComputerCall(step.tool, step.arguments, BACKGROUND);
275
+ if ('observe' in action.args)
276
+ action.args.observe = 'none';
277
+ return action;
278
+ });
279
+ const done = [];
280
+ for (const action of actions) {
281
+ const started = performance.now();
282
+ try {
283
+ const content = await call(action);
284
+ const said = content.map((part) => (part.type === 'text' ? part.text : '')).join(' ').trim();
285
+ done.push((done.length + 1) + '. ' + action.name + ': ' + said + ' (' + Math.round(performance.now() - started) + ' ms)');
286
+ }
287
+ catch (error) {
288
+ const step = done.length + 1;
289
+ const skipped = actions.length - step;
290
+ throw new Error('Step ' + step + ' of ' + actions.length + ' (' + action.name + ') failed: ' + error.message +
291
+ (done.length ? '\nCompleted before it:\n' + done.join('\n') : '') +
292
+ (skipped ? '\nSkipped: step' + (skipped > 1 ? 's ' + (step + 1) + '-' + actions.length : ' ' + actions.length) + '.' : '') +
293
+ '\nNothing was rolled back.');
294
+ }
295
+ }
296
+ const report = { type: 'text', text: done.join('\n') };
297
+ const observe = args.observe ?? batchObservation(args.window, BACKGROUND);
298
+ if (observe === 'none')
299
+ return [report];
300
+ const tool = observe === 'text' ? 'read_screen' : observe;
301
+ try {
302
+ return [report, ...(await call(validateComputerCall(tool, args.window && tool !== 'read_screen' ? { window: args.window } : {}, BACKGROUND)))];
303
+ }
304
+ catch (error) {
305
+ throw new Error(done.join('\n') + '\nAll steps completed; the final ' + observe + ' failed: ' + error.message);
306
+ }
307
+ }
46
308
  case 'screenshot': {
47
309
  if (RUN_DIR)
48
310
  mkdirSync(RUN_DIR, { recursive: true });
49
- const path = RUN_DIR ? join(RUN_DIR, 'last-screenshot.png') : '';
50
- const shot = await shell.run('Rk-Screenshot ' + MAX_WIDTH + ' ' + psQuote(path), 60_000);
51
- view = { scale: shot.scale, left: shot.left, top: shot.top };
311
+ const path = RUN_DIR ? join(RUN_DIR, 'computer-' + process.pid + '.jpg') : '';
312
+ let region = '$null';
313
+ const previous = view;
314
+ if (args.region) {
315
+ if (!previous)
316
+ throw new Error('A region is measured in pixels of the last desktop screenshot; take one first.');
317
+ const r = args.region;
318
+ if (r.x + r.width > previous.width || r.y + r.height > previous.height)
319
+ throw new Error('The region reaches outside the last desktop screenshot (' + previous.width + 'x' + previous.height + ').');
320
+ region = '@(' + [
321
+ Math.round(previous.left + r.x / previous.scale), Math.round(previous.top + r.y / previous.scale),
322
+ Math.max(1, Math.round(r.width / previous.scale)), Math.max(1, Math.round(r.height / previous.scale)),
323
+ ].join(',') + ')';
324
+ }
325
+ const shot = await shell.run('Rk-Screenshot ' + MAX_WIDTH + ' ' + psQuote(path) + ' ' + (args.window ?? 0) + ' ' + (stopped ? '$false' : '$true') + ' ' + region + ' ' + (args.screen ?? 0), 15_000);
326
+ if (!args.window) {
327
+ view = { scale: shot.scale, left: shot.left, top: shot.top, width: shot.width, height: shot.height };
328
+ restartsSeen = shell.restarts;
329
+ }
330
+ const pointer = shot.cursorX >= 0 && shot.cursorY >= 0 && shot.cursorX < shot.width && shot.cursorY < shot.height
331
+ ? 'Pointer at ' + shot.cursorX + ',' + shot.cursorY + '.'
332
+ : 'Pointer outside this view.';
333
+ let what;
334
+ if (args.window)
335
+ what = 'Window capture (app-dependent); virtual cursor marks the last UIA target. Observe with snapshot if blank.';
336
+ else if (args.region) {
337
+ const zoom = shot.scale / previous.scale;
338
+ what = 'Zoomed ' + zoom.toFixed(1) + 'x into the region ' + args.region.x + ',' + args.region.y + ' ' + args.region.width + 'x' + args.region.height +
339
+ ' of the previous screenshot. Coordinates now refer to this image until the next desktop screenshot or read_screen. ' + pointer;
340
+ }
341
+ else if (args.screen)
342
+ what = 'Display ' + args.screen + ' only; coordinates now refer to this image. ' + pointer;
343
+ else
344
+ what = pointer;
52
345
  return [
53
- { type: 'image', data: shot.png, mimeType: 'image/png' },
346
+ { type: 'image', data: shot.jpeg, mimeType: 'image/jpeg' },
54
347
  {
55
348
  type: 'text',
56
349
  text: 'Screenshot ' + shot.width + 'x' + shot.height + ' px' +
57
- (shot.scale < 1 ? ' (screen scaled by ' + shot.scale.toFixed(3) + ')' : '') +
58
- '. Pointer at ' + shot.cursorX + ',' + shot.cursorY + '.' +
350
+ (shot.scale < 1 ? ' (screen scaled by ' + shot.scale.toFixed(3) + ')' : '') + '. ' + what +
351
+ (args.window ? '' : ' Active window: ' + describeWindow(shot.active) + '.') +
59
352
  (path ? ' Saved as ' + path + '.' : ''),
60
353
  },
61
354
  ];
62
355
  }
63
356
  case 'screen_info': {
64
357
  const info = await shell.run('Rk-ScreenInfo');
65
- const m = await mapping();
358
+ const m = { scale: Math.min(1, MAX_WIDTH / info.width) };
66
359
  return [
67
360
  {
68
361
  type: 'text',
69
362
  text: 'Screenshot size ' + Math.round(info.width * m.scale) + 'x' + Math.round(info.height * m.scale) +
70
363
  ' px, scale ' + m.scale.toFixed(3) + ' of ' + info.width + 'x' + info.height + ' real pixels.\n' +
71
364
  info.screens
72
- .map((s) => '- ' + s.name + (s.primary ? ' (primary)' : '') + ': ' + s.width + 'x' + s.height + ' at ' + s.x + ',' + s.y)
73
- .join('\n'),
365
+ .map((s, i) => '- screen ' + (i + 1) + ': ' + s.name + (s.primary ? ' (primary)' : '') + ': ' + s.width + 'x' + s.height + ' at ' + s.x + ',' + s.y)
366
+ .join('\n') + '\nObserver: ' + JSON.stringify(info.observer),
74
367
  },
75
368
  ];
76
369
  }
370
+ case 'read_screen': {
371
+ const { screen, scale } = await readScreen();
372
+ return [{ type: 'text', text: 'Screen text (OCR), centre x,y in screenshot pixels. Active window: ' + describeWindow(screen.active) + '.\n' + describeScreen(screen, scale) }];
373
+ }
374
+ case 'find_text': {
375
+ const lines = [];
376
+ let screen = null;
377
+ if (!BACKGROUND) {
378
+ ({ screen } = await readScreen());
379
+ const matches = findText(screen, args.text);
380
+ if (matches.length)
381
+ lines.push(listMatches(matches));
382
+ }
383
+ // Controls by accessible name: the given window, else the active one when OCR saw nothing.
384
+ const window = args.window ?? (lines.length ? 0 : screen?.foreground ?? 0);
385
+ if (window) {
386
+ const found = await findControls(window, args.text);
387
+ if (found.controls.length)
388
+ lines.push((lines.length ? 'Controls named ' : 'No visible text, but controls named ') + JSON.stringify(args.text) + ':\n' + listControls(found));
389
+ }
390
+ if (!lines.length) {
391
+ return [{ type: 'text', text: 'No text or control named "' + args.text + '"' + (window ? ' in window ' + window : '') + '.' + (screen ? ' Visible text:\n' + visible(screen) : '') }];
392
+ }
393
+ return [{ type: 'text', text: lines.join('\n') }];
394
+ }
395
+ case 'wait_for': {
396
+ const started = Date.now();
397
+ const what = JSON.stringify(args.text);
398
+ let screen = null;
399
+ for (;;) {
400
+ let where = '';
401
+ if (args.window) {
402
+ const found = await findControls(args.window, args.text);
403
+ if (found.controls.length)
404
+ where = listControls(found);
405
+ }
406
+ else {
407
+ ({ screen } = await readScreen());
408
+ const matches = findText(screen, args.text);
409
+ if (matches.length)
410
+ where = listMatches(matches);
411
+ }
412
+ const seconds = Math.round((Date.now() - started) / 100) / 10;
413
+ if (Boolean(where) !== args.gone) {
414
+ return [{ type: 'text', text: what + (args.gone ? ' is gone' : ' is on screen') + ' after ' + seconds + ' s.' + (where ? '\n' + where : '') }];
415
+ }
416
+ if (Date.now() - started >= args.timeoutSec * 1000) {
417
+ throw new Error('Timed out after ' + args.timeoutSec + ' s: ' + what + (args.gone ? ' is still on screen.' : ' did not appear.') +
418
+ (screen ? '\nVisible text:\n' + visible(screen) : ''));
419
+ }
420
+ await pause(400);
421
+ }
422
+ }
423
+ case 'hand_over': {
424
+ const timeout = args.timeoutSec * 1000;
425
+ const result = await shell.run('Rk-HandOver ' + psQuote(args.reason) + ' ' + timeout, timeout + 15_000);
426
+ const outcome = { type: 'text', text: result.outcome + ' Waited ' + Math.round(result.waitedMs / 1000) + ' s.' };
427
+ // Background-only mode may not capture the desktop; the model snapshots its window instead.
428
+ return BACKGROUND ? [outcome] : [outcome, ...(await settled('screenshot'))];
429
+ }
77
430
  case 'click': {
78
- const [x, y] = await toScreen(args.x, args.y);
79
- const button = ['left', 'right', 'middle'].includes(text(args, 'button')) ? text(args, 'button') : 'left';
80
- const count = num(args, 'count', 1) >= 2 ? 2 : 1;
81
- await shell.run('Rk-Click ' + x + ' ' + y + ' ' + psQuote(button) + ' ' + count);
82
- return [{ type: 'text', text: (count === 2 ? 'Double-clicked' : 'Clicked') + ' ' + button + ' at ' + args.x + ',' + args.y + '.' }];
431
+ const { button, count } = args;
432
+ const clicked = (what) => [{ type: 'text', text: (count === 2 ? 'Double-clicked ' : 'Clicked ') + (button === 'left' ? '' : 'with the ' + button + ' button ') + what + '.' }];
433
+ let sx, sy, what;
434
+ if (args.text !== undefined) {
435
+ // The view stays as it is: the point comes from what is on screen now, not from the model's coordinates.
436
+ const screen = await ocr(true);
437
+ const matches = findText(screen, args.text);
438
+ let picked = pickMatch(matches, args.text, args.index);
439
+ if (typeof picked === 'string' && !matches.length && args.index === undefined && screen.foreground) {
440
+ // Icon buttons and menu items have names without visible text.
441
+ const found = await findControls(screen.foreground, args.text);
442
+ const control = found.controls[0];
443
+ if (found.controls.length === 1 && control) {
444
+ const [x, y, width, height] = control.bounds;
445
+ [sx, sy] = [Math.round(x + width / 2), Math.round(y + height / 2)];
446
+ await physical('Rk-Click ' + sx + ' ' + sy + ' ' + psQuote(button) + ' ' + count);
447
+ return clicked(control.role + ' "' + control.name + '" at ' + toView(sx, sy));
448
+ }
449
+ if (found.controls.length > 1)
450
+ picked = found.controls.length + ' controls are named "' + args.text + '" and none shows the text; click one of their centres:\n' + listControls(found);
451
+ }
452
+ if (typeof picked === 'string') {
453
+ throw new Error(picked + '\n' + (matches.length ? listMatches(matches) : 'Visible text:\n' + visible(screen)));
454
+ }
455
+ [sx, sy] = centre(picked);
456
+ what = '"' + picked.text + '" at ' + toView(sx, sy) + (picked.foreground ? '' : ' (outside the active window)');
457
+ }
458
+ else {
459
+ [sx, sy] = toScreen(args.x, args.y);
460
+ what = args.x + ',' + args.y;
461
+ }
462
+ await physical('Rk-Click ' + sx + ' ' + sy + ' ' + psQuote(button) + ' ' + count);
463
+ return clicked(what);
83
464
  }
84
465
  case 'move_mouse': {
85
- const [x, y] = await toScreen(args.x, args.y);
86
- await shell.run('Rk-Move ' + x + ' ' + y);
466
+ const [x, y] = toScreen(args.x, args.y);
467
+ await physical('Rk-Move ' + x + ' ' + y);
87
468
  return [{ type: 'text', text: 'Pointer at ' + args.x + ',' + args.y + '.' }];
88
469
  }
89
470
  case 'drag': {
90
- const [x1, y1] = await toScreen(args.fromX, args.fromY);
91
- const [x2, y2] = await toScreen(args.toX, args.toY);
92
- await shell.run('Rk-Drag ' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2);
471
+ const [x1, y1] = toScreen(args.fromX, args.fromY);
472
+ const [x2, y2] = toScreen(args.toX, args.toY);
473
+ await physical('Rk-Drag ' + x1 + ' ' + y1 + ' ' + x2 + ' ' + y2);
93
474
  return [{ type: 'text', text: 'Dragged from ' + args.fromX + ',' + args.fromY + ' to ' + args.toX + ',' + args.toY + '.' }];
94
475
  }
476
+ case 'draw': {
477
+ const plan = planDrawing(args);
478
+ await physical('Rk-Draw ' + psQuote(plan.packed) + ' ' + psQuote(args.button), plan.timeoutMs);
479
+ return [{ type: 'text', text: 'Drew ' + plan.strokes + (plan.strokes === 1 ? ' stroke' : ' strokes') + ' through ' + plan.points + ' points.' }];
480
+ }
95
481
  case 'scroll': {
96
- const [x, y] = await toScreen(args.x, args.y);
97
- const direction = ['up', 'down', 'left', 'right'].includes(text(args, 'direction')) ? text(args, 'direction') : 'down';
98
- const amount = Math.min(20, Math.max(1, Math.round(num(args, 'amount', 3))));
99
- await shell.run('Rk-Scroll ' + x + ' ' + y + ' ' + psQuote(direction) + ' ' + amount);
482
+ const [x, y] = toScreen(args.x, args.y);
483
+ const { direction, amount } = args;
484
+ await physical('Rk-Scroll ' + x + ' ' + y + ' ' + psQuote(direction) + ' ' + amount);
100
485
  return [{ type: 'text', text: 'Scrolled ' + direction + ' by ' + amount + '.' }];
101
486
  }
102
487
  case 'type_text': {
103
- const value = text(args, 'text');
104
- if (!value)
105
- throw new Error('Nothing to type.');
106
- await shell.run('Rk-Type ' + psQuote(value), 120_000);
107
- return [{ type: 'text', text: 'Typed ' + value.length + ' characters.' }];
488
+ await physical('Rk-Type ' + psQuote(args.text));
489
+ return [{ type: 'text', text: 'Typed ' + args.text.length + ' characters.' }];
108
490
  }
109
491
  case 'press_keys': {
110
- const combos = parseKeySequence(text(args, 'keys'));
111
- if (!combos.length)
112
- throw new Error('Which keys?');
492
+ const combos = parseKeySequence(args.keys);
113
493
  const literal = '@(' + combos.map((combo) => ',@(' + combo.join(',') + ')').join(';') + ')';
114
- await shell.run('Rk-Keys ' + literal);
115
- return [{ type: 'text', text: 'Pressed ' + text(args, 'keys') + '.' }];
494
+ await physical('Rk-Keys ' + literal);
495
+ return [{ type: 'text', text: 'Pressed ' + args.keys + '.' }];
116
496
  }
117
497
  case 'list_windows': {
118
498
  const rows = await shell.run('Rk-Windows');
@@ -123,37 +503,39 @@ async function call(name, args) {
123
503
  {
124
504
  type: 'text',
125
505
  text: list
126
- .map((w) => '- ' + (w.active ? '[active] ' : '') + w.title + ' (' + w.process + ') ' + w.width + 'x' + w.height + ' at ' + w.x + ',' + w.y)
506
+ .map((w) => '- window=' + w.handle + ' ' + (w.active ? '[active] ' : '') + JSON.stringify(w.title) + ' (' + w.process + ') ' +
507
+ (w.minimized ? 'minimized' : w.width + 'x' + w.height + ' at ' + w.x + ',' + w.y))
127
508
  .join('\n'),
128
509
  },
129
510
  ];
130
511
  }
131
512
  case 'focus_window': {
132
- const needle = text(args, 'title');
133
- if (!needle)
134
- throw new Error('Which window?');
135
- const result = await shell.run('Rk-Focus ' + psQuote(needle));
136
- return [{ type: 'text', text: (result.ok ? 'Focused ' : 'Tried to focus ') + '"' + result.title + '".' }];
513
+ view = null;
514
+ const result = await shell.run('Rk-Focus ' + psQuote(args.title ?? '') + ' ' + (args.window ?? 0));
515
+ return [{ type: 'text', text: 'Focused ' + describeWindow(result) + '.' }];
137
516
  }
138
517
  case 'open': {
139
- const target = text(args, 'target');
140
- if (!target)
141
- throw new Error('What should be opened?');
142
- await shell.run('Rk-Open ' + psQuote(target));
143
- return [{ type: 'text', text: 'Opened ' + target + '.' }];
518
+ view = null;
519
+ const result = await shell.run('Rk-Open ' + psQuote(args.target), 15_000);
520
+ if (!result.changed) {
521
+ // Nothing to type into yet: say so as an error, so the model does not send input to whatever is in front.
522
+ throw new Error('Opened ' + args.target + ', but no window came to the front within 3 s' +
523
+ (result.behind ? ': ' + describeWindow(result.behind) + ' stayed behind ' : '; the active window is still ') + describeWindow(result.active) +
524
+ '. Nothing was typed. Use focus_window with the handle, or wait_for, then take a screenshot.');
525
+ }
526
+ return [{ type: 'text', text: 'Opened ' + args.target + '. Active window is now ' + describeWindow(result.active) + '.' }];
144
527
  }
145
528
  case 'clipboard': {
146
- if (text(args, 'action') === 'set') {
147
- await shell.run('Rk-ClipSet ' + psQuote(text(args, 'text')));
148
- return [{ type: 'text', text: 'Clipboard set (' + text(args, 'text').length + ' characters).' }];
529
+ if (args.action === 'set') {
530
+ await shell.run('Rk-ClipSet ' + psQuote(args.text ?? ''));
531
+ return [{ type: 'text', text: 'Clipboard set (' + args.text.length + ' characters).' }];
149
532
  }
150
533
  const result = await shell.run('Rk-ClipGet');
151
534
  return [{ type: 'text', text: result.text ? result.text.slice(0, 20_000) : '(clipboard is empty)' }];
152
535
  }
153
536
  case 'wait': {
154
- const ms = Math.min(30_000, Math.max(0, Math.round(num(args, 'ms', 1000))));
155
- await new Promise((resolve) => setTimeout(resolve, ms));
156
- return [{ type: 'text', text: 'Waited ' + ms + ' ms.' }];
537
+ await pause(args.ms);
538
+ return [{ type: 'text', text: 'Waited ' + args.ms + ' ms.' }];
157
539
  }
158
540
  default:
159
541
  throw new Error('Unknown tool ' + name + '.');
@@ -165,6 +547,10 @@ function send(message) {
165
547
  }
166
548
  async function handle(message) {
167
549
  const { id, method, params } = message;
550
+ if (method === 'notifications/cancelled' && pending.has(params?.requestId)) {
551
+ await call({ name: 'stop', args: {} });
552
+ return;
553
+ }
168
554
  if (id === undefined)
169
555
  return;
170
556
  try {
@@ -175,7 +561,7 @@ async function handle(message) {
175
561
  result: {
176
562
  protocolVersion: params?.protocolVersion ?? PROTOCOL_FALLBACK,
177
563
  capabilities: { tools: {} },
178
- serverInfo: { name: COMPUTER_SERVER_NAME, version: '0.1.0' },
564
+ serverInfo: { name: COMPUTER_SERVER_NAME, version: '0.2.0' },
179
565
  },
180
566
  });
181
567
  return;
@@ -192,11 +578,42 @@ async function handle(message) {
192
578
  send({ id, result: { content: [{ type: 'text', text: 'Computer control is available on Windows only.' }], isError: true } });
193
579
  return;
194
580
  }
195
- try {
196
- send({ id, result: { content: await call(name, args), isError: false } });
197
- }
198
- catch (error) {
199
- send({ id, result: { content: [{ type: 'text', text: error.message }], isError: true } });
581
+ pending.add(id);
582
+ const execute = async () => {
583
+ const started = performance.now();
584
+ let failure;
585
+ try {
586
+ const content = await call(validateComputerCall(name, args, BACKGROUND));
587
+ content.push({ type: 'text', text: JSON.stringify({ durationMs: Math.round(performance.now() - started), mode: BACKGROUND ? 'background' : 'desktop' }) });
588
+ send({ id, result: { content, isError: false } });
589
+ }
590
+ catch (error) {
591
+ failure = error.message;
592
+ send({ id, result: { content: [{ type: 'text', text: failure }], isError: true } });
593
+ }
594
+ finally {
595
+ pending.delete(id);
596
+ if (RUN_DIR) {
597
+ // The audit says which tool, how long, and why it failed; never what was typed or seen.
598
+ const steps = name === 'batch' && Array.isArray(args.actions) ? args.actions.length : undefined;
599
+ try {
600
+ mkdirSync(RUN_DIR, { recursive: true });
601
+ appendFileSync(join(RUN_DIR, 'computer-audit.jsonl'), JSON.stringify({
602
+ at: new Date().toISOString(), session: process.pid, tool: name, ...(steps === undefined ? {} : { steps }),
603
+ durationMs: Math.round(performance.now() - started), isError: failure !== undefined,
604
+ ...(failure === undefined ? {} : { error: failure.split('\n')[0].replace(/"[^"]*"/g, '"…"').slice(0, 200) }),
605
+ }) + '\n');
606
+ }
607
+ catch { /* Audit storage failure must not retry an already-dispatched action. */ }
608
+ }
609
+ }
610
+ };
611
+ if (name === 'stop')
612
+ await execute();
613
+ else {
614
+ const task = queue.then(execute);
615
+ queue = task.catch(() => undefined);
616
+ await task;
200
617
  }
201
618
  return;
202
619
  }
@@ -215,14 +632,39 @@ input.on('line', (line) => {
215
632
  let message;
216
633
  try {
217
634
  message = JSON.parse(line);
635
+ if (!message || typeof message !== 'object' || Array.isArray(message))
636
+ return;
218
637
  }
219
638
  catch {
220
639
  return;
221
640
  }
222
641
  void handle(message);
223
642
  });
224
- input.on('close', () => {
643
+ /**
644
+ * The turn is over when the CLI closes our stdin. The cursor fades out
645
+ * first, bounded so a stuck action cannot hold the exit, and a drag or
646
+ * shortcut cut off mid-way lets go of what it held; a hard kill skips this,
647
+ * and the worker then ends itself with this process instead.
648
+ */
649
+ let closing = false;
650
+ async function shutdown() {
651
+ if (closing)
652
+ return;
653
+ closing = true;
654
+ if (shell.running) {
655
+ await Promise.race([
656
+ shell.run('Rk-CursorDismiss; @{}', 2000).catch(() => undefined),
657
+ delay(700),
658
+ ]);
659
+ }
660
+ const held = inputInFlight > 0;
661
+ shell.close();
662
+ if (held)
663
+ await releaseHeld(3000);
225
664
  shell.close();
226
665
  process.exit(0);
227
- });
666
+ }
667
+ input.on('close', () => void shutdown());
668
+ process.on('SIGINT', () => void shutdown());
669
+ process.on('SIGTERM', () => void shutdown());
228
670
  //# sourceMappingURL=mcp-server.js.map