micro-models-agent 0.3.0 → 0.5.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 (349) hide show
  1. package/README.md +436 -436
  2. package/dist/agent/loop.d.ts +5 -5
  3. package/dist/agent/loop.d.ts.map +1 -1
  4. package/dist/agent/loop.js +422 -246
  5. package/dist/agent/loop.js.map +1 -1
  6. package/dist/agent/system-prompt.d.ts +3 -3
  7. package/dist/agent/system-prompt.d.ts.map +1 -1
  8. package/dist/agent/system-prompt.js +383 -278
  9. package/dist/agent/system-prompt.js.map +1 -1
  10. package/dist/cli/config.d.ts +1 -1
  11. package/dist/cli/config.d.ts.map +1 -1
  12. package/dist/cli/config.js +53 -28
  13. package/dist/cli/config.js.map +1 -1
  14. package/dist/config/config.d.ts +2 -1
  15. package/dist/config/config.d.ts.map +1 -1
  16. package/dist/config/config.js +75 -54
  17. package/dist/config/config.js.map +1 -1
  18. package/dist/config/types.d.ts +3 -1
  19. package/dist/config/types.d.ts.map +1 -1
  20. package/dist/logger.d.ts +10 -3
  21. package/dist/logger.d.ts.map +1 -1
  22. package/dist/logger.js +89 -38
  23. package/dist/logger.js.map +1 -1
  24. package/dist/plugins/builtin/lint-on-write/index.ts +96 -96
  25. package/dist/plugins/builtin/notify/index.js +6 -6
  26. package/dist/plugins/builtin/notify/index.ts +104 -104
  27. package/dist/setup-wizard.d.ts +1 -1
  28. package/dist/setup-wizard.d.ts.map +1 -1
  29. package/dist/setup-wizard.js +137 -105
  30. package/dist/setup-wizard.js.map +1 -1
  31. package/dist/skills/builtin/agent-test/SKILL.md +68 -68
  32. package/dist/skills/builtin/grill-me/SKILL.md +46 -46
  33. package/dist/skills/builtin/web-scraping/SKILL.md +422 -422
  34. package/dist/subagent/chat.d.ts +7 -0
  35. package/dist/subagent/chat.d.ts.map +1 -0
  36. package/dist/subagent/chat.js +257 -0
  37. package/dist/subagent/chat.js.map +1 -0
  38. package/dist/subagent/context.d.ts +2 -0
  39. package/dist/subagent/context.d.ts.map +1 -0
  40. package/dist/subagent/context.js +64 -0
  41. package/dist/subagent/context.js.map +1 -0
  42. package/dist/subagent/definition.d.ts +3 -0
  43. package/dist/subagent/definition.d.ts.map +1 -0
  44. package/dist/subagent/definition.js +22 -0
  45. package/dist/subagent/definition.js.map +1 -0
  46. package/dist/subagent/errors.d.ts +7 -0
  47. package/dist/subagent/errors.d.ts.map +1 -0
  48. package/dist/subagent/errors.js +64 -0
  49. package/dist/subagent/errors.js.map +1 -0
  50. package/dist/subagent/validation.d.ts +11 -0
  51. package/dist/subagent/validation.d.ts.map +1 -0
  52. package/dist/subagent/validation.js +77 -0
  53. package/dist/subagent/validation.js.map +1 -0
  54. package/dist/tools/native/project-map.d.ts +2 -2
  55. package/dist/tools/native/project-map.d.ts.map +1 -1
  56. package/dist/tools/native/project-map.js +85 -57
  57. package/dist/tools/native/project-map.js.map +1 -1
  58. package/dist/tools/native/scaffold.js +113 -113
  59. package/dist/tools/subagent.d.ts +14 -57
  60. package/dist/tools/subagent.d.ts.map +1 -1
  61. package/dist/tools/subagent.js +112 -559
  62. package/dist/tools/subagent.js.map +1 -1
  63. package/dist/tools/web-browse.js +7 -7
  64. package/dist/ui/ink/components/App.d.ts +0 -1
  65. package/dist/ui/ink/components/App.d.ts.map +1 -1
  66. package/dist/ui/ink/components/App.js +2 -8
  67. package/dist/ui/ink/components/App.js.map +1 -1
  68. package/dist/ui/ink/components/Conversation.d.ts +1 -2
  69. package/dist/ui/ink/components/Conversation.d.ts.map +1 -1
  70. package/dist/ui/ink/components/Conversation.js +8 -2
  71. package/dist/ui/ink/components/Conversation.js.map +1 -1
  72. package/dist/ui/ink/components/MessageBlock.d.ts +13 -1
  73. package/dist/ui/ink/components/MessageBlock.d.ts.map +1 -1
  74. package/dist/ui/ink/components/MessageBlock.js +15 -27
  75. package/dist/ui/ink/components/MessageBlock.js.map +1 -1
  76. package/dist/ui/ink/components/PromptInput.d.ts +11 -0
  77. package/dist/ui/ink/components/PromptInput.d.ts.map +1 -1
  78. package/dist/ui/ink/components/PromptInput.js +18 -141
  79. package/dist/ui/ink/components/PromptInput.js.map +1 -1
  80. package/dist/ui/ink/components/SelectInput.d.ts.map +1 -1
  81. package/dist/ui/ink/components/SelectInput.js +3 -2
  82. package/dist/ui/ink/components/SelectInput.js.map +1 -1
  83. package/dist/ui/ink/components/StatusBar.d.ts.map +1 -1
  84. package/dist/ui/ink/components/StatusBar.js +14 -6
  85. package/dist/ui/ink/components/StatusBar.js.map +1 -1
  86. package/dist/ui/ink/components/StreamBlock.d.ts.map +1 -1
  87. package/dist/ui/ink/components/StreamBlock.js +3 -3
  88. package/dist/ui/ink/components/StreamBlock.js.map +1 -1
  89. package/dist/ui/ink/components/Tags.d.ts +8 -11
  90. package/dist/ui/ink/components/Tags.d.ts.map +1 -1
  91. package/dist/ui/ink/components/Tags.js +4 -16
  92. package/dist/ui/ink/components/Tags.js.map +1 -1
  93. package/dist/ui/ink/components/ToolCallBlock.d.ts +12 -0
  94. package/dist/ui/ink/components/ToolCallBlock.d.ts.map +1 -1
  95. package/dist/ui/ink/components/ToolCallBlock.js +8 -24
  96. package/dist/ui/ink/components/ToolCallBlock.js.map +1 -1
  97. package/dist/ui/ink/renderer.d.ts +0 -1
  98. package/dist/ui/ink/renderer.d.ts.map +1 -1
  99. package/dist/ui/ink/renderer.js +1 -4
  100. package/dist/ui/ink/renderer.js.map +1 -1
  101. package/package.json +47 -47
  102. package/dist/async-map.d.ts +0 -6
  103. package/dist/async-map.d.ts.map +0 -1
  104. package/dist/async-map.js +0 -16
  105. package/dist/async-map.js.map +0 -1
  106. package/dist/blog-api/types/index.d.ts +0 -2
  107. package/dist/blog-api/types/index.d.ts.map +0 -1
  108. package/dist/blog-api/types/index.js +0 -2
  109. package/dist/blog-api/types/index.js.map +0 -1
  110. package/dist/examples.d.ts +0 -22
  111. package/dist/examples.d.ts.map +0 -1
  112. package/dist/examples.js +0 -45
  113. package/dist/examples.js.map +0 -1
  114. package/dist/fibonacci.d.ts +0 -19
  115. package/dist/fibonacci.d.ts.map +0 -1
  116. package/dist/fibonacci.js +0 -61
  117. package/dist/fibonacci.js.map +0 -1
  118. package/dist/parfymerie-landing/src/App.d.ts +0 -4
  119. package/dist/parfymerie-landing/src/App.d.ts.map +0 -1
  120. package/dist/parfymerie-landing/src/App.js +0 -12
  121. package/dist/parfymerie-landing/src/App.js.map +0 -1
  122. package/dist/parfymerie-landing/src/main.d.ts +0 -2
  123. package/dist/parfymerie-landing/src/main.d.ts.map +0 -1
  124. package/dist/parfymerie-landing/src/main.js +0 -7
  125. package/dist/parfymerie-landing/src/main.js.map +0 -1
  126. package/dist/parfymerie-landing/vite.config.d.ts +0 -3
  127. package/dist/parfymerie-landing/vite.config.d.ts.map +0 -1
  128. package/dist/parfymerie-landing/vite.config.js +0 -7
  129. package/dist/parfymerie-landing/vite.config.js.map +0 -1
  130. package/dist/repl.d.ts +0 -5
  131. package/dist/repl.d.ts.map +0 -1
  132. package/dist/repl.js +0 -472
  133. package/dist/repl.js.map +0 -1
  134. package/dist/sort.d.ts +0 -8
  135. package/dist/sort.d.ts.map +0 -1
  136. package/dist/sort.js +0 -36
  137. package/dist/sort.js.map +0 -1
  138. package/dist/stack.d.ts +0 -9
  139. package/dist/stack.d.ts.map +0 -1
  140. package/dist/stack.js +0 -22
  141. package/dist/stack.js.map +0 -1
  142. package/dist/test-run.d.ts +0 -2
  143. package/dist/test-run.d.ts.map +0 -1
  144. package/dist/test-run.js +0 -13
  145. package/dist/test-run.js.map +0 -1
  146. package/dist/ui/components/diff-view.d.ts +0 -8
  147. package/dist/ui/components/diff-view.d.ts.map +0 -1
  148. package/dist/ui/components/diff-view.js +0 -25
  149. package/dist/ui/components/diff-view.js.map +0 -1
  150. package/dist/ui/double-press.d.ts +0 -9
  151. package/dist/ui/double-press.d.ts.map +0 -1
  152. package/dist/ui/double-press.js +0 -18
  153. package/dist/ui/double-press.js.map +0 -1
  154. package/dist/ui/ink/components/ActivityLog.d.ts +0 -12
  155. package/dist/ui/ink/components/ActivityLog.d.ts.map +0 -1
  156. package/dist/ui/ink/components/ActivityLog.js +0 -11
  157. package/dist/ui/ink/components/ActivityLog.js.map +0 -1
  158. package/dist/ui/ink/components/AgentStatus.d.ts +0 -13
  159. package/dist/ui/ink/components/AgentStatus.d.ts.map +0 -1
  160. package/dist/ui/ink/components/AgentStatus.js +0 -20
  161. package/dist/ui/ink/components/AgentStatus.js.map +0 -1
  162. package/dist/ui/ink/components/BottomBar.d.ts +0 -12
  163. package/dist/ui/ink/components/BottomBar.d.ts.map +0 -1
  164. package/dist/ui/ink/components/BottomBar.js +0 -22
  165. package/dist/ui/ink/components/BottomBar.js.map +0 -1
  166. package/dist/ui/ink/components/CheckboxInput.d.ts +0 -21
  167. package/dist/ui/ink/components/CheckboxInput.d.ts.map +0 -1
  168. package/dist/ui/ink/components/CheckboxInput.js +0 -36
  169. package/dist/ui/ink/components/CheckboxInput.js.map +0 -1
  170. package/dist/ui/ink/components/InputBox.d.ts +0 -25
  171. package/dist/ui/ink/components/InputBox.d.ts.map +0 -1
  172. package/dist/ui/ink/components/InputBox.js +0 -91
  173. package/dist/ui/ink/components/InputBox.js.map +0 -1
  174. package/dist/ui/ink/components/ModeSelector.d.ts +0 -8
  175. package/dist/ui/ink/components/ModeSelector.d.ts.map +0 -1
  176. package/dist/ui/ink/components/ModeSelector.js +0 -13
  177. package/dist/ui/ink/components/ModeSelector.js.map +0 -1
  178. package/dist/ui/ink/components/QuestionBox.d.ts +0 -14
  179. package/dist/ui/ink/components/QuestionBox.d.ts.map +0 -1
  180. package/dist/ui/ink/components/QuestionBox.js +0 -35
  181. package/dist/ui/ink/components/QuestionBox.js.map +0 -1
  182. package/dist/ui/ink/components/RadioInput.d.ts +0 -17
  183. package/dist/ui/ink/components/RadioInput.d.ts.map +0 -1
  184. package/dist/ui/ink/components/RadioInput.js +0 -30
  185. package/dist/ui/ink/components/RadioInput.js.map +0 -1
  186. package/dist/ui/ink/components/SliderInput.d.ts +0 -20
  187. package/dist/ui/ink/components/SliderInput.d.ts.map +0 -1
  188. package/dist/ui/ink/components/SliderInput.js +0 -40
  189. package/dist/ui/ink/components/SliderInput.js.map +0 -1
  190. package/dist/ui/ink/components/StartupScreen.d.ts +0 -19
  191. package/dist/ui/ink/components/StartupScreen.d.ts.map +0 -1
  192. package/dist/ui/ink/components/StartupScreen.js +0 -9
  193. package/dist/ui/ink/components/StartupScreen.js.map +0 -1
  194. package/dist/ui/ink/components/WelcomeScreen.d.ts +0 -10
  195. package/dist/ui/ink/components/WelcomeScreen.d.ts.map +0 -1
  196. package/dist/ui/ink/components/WelcomeScreen.js +0 -8
  197. package/dist/ui/ink/components/WelcomeScreen.js.map +0 -1
  198. package/dist/ui/ink/components/Window.d.ts +0 -30
  199. package/dist/ui/ink/components/Window.d.ts.map +0 -1
  200. package/dist/ui/ink/components/Window.js +0 -9
  201. package/dist/ui/ink/components/Window.js.map +0 -1
  202. package/dist/ui/ink/components/ui/_core.d.ts +0 -113
  203. package/dist/ui/ink/components/ui/_core.d.ts.map +0 -1
  204. package/dist/ui/ink/components/ui/_core.js +0 -83
  205. package/dist/ui/ink/components/ui/_core.js.map +0 -1
  206. package/dist/ui/ink/components/ui/autocomplete/Autocomplete.d.ts +0 -23
  207. package/dist/ui/ink/components/ui/autocomplete/Autocomplete.d.ts.map +0 -1
  208. package/dist/ui/ink/components/ui/autocomplete/Autocomplete.js +0 -56
  209. package/dist/ui/ink/components/ui/autocomplete/Autocomplete.js.map +0 -1
  210. package/dist/ui/ink/components/ui/autocomplete/index.d.ts +0 -3
  211. package/dist/ui/ink/components/ui/autocomplete/index.d.ts.map +0 -1
  212. package/dist/ui/ink/components/ui/autocomplete/index.js +0 -2
  213. package/dist/ui/ink/components/ui/autocomplete/index.js.map +0 -1
  214. package/dist/ui/ink/components/ui/badge/Badge.d.ts +0 -13
  215. package/dist/ui/ink/components/ui/badge/Badge.d.ts.map +0 -1
  216. package/dist/ui/ink/components/ui/badge/Badge.js +0 -17
  217. package/dist/ui/ink/components/ui/badge/Badge.js.map +0 -1
  218. package/dist/ui/ink/components/ui/badge/index.d.ts +0 -3
  219. package/dist/ui/ink/components/ui/badge/index.d.ts.map +0 -1
  220. package/dist/ui/ink/components/ui/badge/index.js +0 -2
  221. package/dist/ui/ink/components/ui/badge/index.js.map +0 -1
  222. package/dist/ui/ink/components/ui/divider/Divider.d.ts +0 -12
  223. package/dist/ui/ink/components/ui/divider/Divider.d.ts.map +0 -1
  224. package/dist/ui/ink/components/ui/divider/Divider.js +0 -27
  225. package/dist/ui/ink/components/ui/divider/Divider.js.map +0 -1
  226. package/dist/ui/ink/components/ui/divider/index.d.ts +0 -3
  227. package/dist/ui/ink/components/ui/divider/index.d.ts.map +0 -1
  228. package/dist/ui/ink/components/ui/divider/index.js +0 -2
  229. package/dist/ui/ink/components/ui/divider/index.js.map +0 -1
  230. package/dist/ui/ink/components/ui/header/Header.d.ts +0 -13
  231. package/dist/ui/ink/components/ui/header/Header.d.ts.map +0 -1
  232. package/dist/ui/ink/components/ui/header/Header.js +0 -33
  233. package/dist/ui/ink/components/ui/header/Header.js.map +0 -1
  234. package/dist/ui/ink/components/ui/header/index.d.ts +0 -3
  235. package/dist/ui/ink/components/ui/header/index.d.ts.map +0 -1
  236. package/dist/ui/ink/components/ui/header/index.js +0 -2
  237. package/dist/ui/ink/components/ui/header/index.js.map +0 -1
  238. package/dist/ui/ink/components/ui/json-viewer/JSONViewer.d.ts +0 -14
  239. package/dist/ui/ink/components/ui/json-viewer/JSONViewer.d.ts.map +0 -1
  240. package/dist/ui/ink/components/ui/json-viewer/JSONViewer.js +0 -144
  241. package/dist/ui/ink/components/ui/json-viewer/JSONViewer.js.map +0 -1
  242. package/dist/ui/ink/components/ui/json-viewer/index.d.ts +0 -3
  243. package/dist/ui/ink/components/ui/json-viewer/index.d.ts.map +0 -1
  244. package/dist/ui/ink/components/ui/json-viewer/index.js +0 -2
  245. package/dist/ui/ink/components/ui/json-viewer/index.js.map +0 -1
  246. package/dist/ui/ink/components/ui/key-hint/KeyHint.d.ts +0 -14
  247. package/dist/ui/ink/components/ui/key-hint/KeyHint.d.ts.map +0 -1
  248. package/dist/ui/ink/components/ui/key-hint/KeyHint.js +0 -5
  249. package/dist/ui/ink/components/ui/key-hint/KeyHint.js.map +0 -1
  250. package/dist/ui/ink/components/ui/key-hint/index.d.ts +0 -3
  251. package/dist/ui/ink/components/ui/key-hint/index.d.ts.map +0 -1
  252. package/dist/ui/ink/components/ui/key-hint/index.js +0 -2
  253. package/dist/ui/ink/components/ui/key-hint/index.js.map +0 -1
  254. package/dist/ui/ink/components/ui/markdown/Markdown.d.ts +0 -11
  255. package/dist/ui/ink/components/ui/markdown/Markdown.d.ts.map +0 -1
  256. package/dist/ui/ink/components/ui/markdown/Markdown.js +0 -129
  257. package/dist/ui/ink/components/ui/markdown/Markdown.js.map +0 -1
  258. package/dist/ui/ink/components/ui/markdown/index.d.ts +0 -3
  259. package/dist/ui/ink/components/ui/markdown/index.d.ts.map +0 -1
  260. package/dist/ui/ink/components/ui/markdown/index.js +0 -2
  261. package/dist/ui/ink/components/ui/markdown/index.js.map +0 -1
  262. package/dist/ui/ink/components/ui/scroll-area/ScrollArea.d.ts +0 -21
  263. package/dist/ui/ink/components/ui/scroll-area/ScrollArea.d.ts.map +0 -1
  264. package/dist/ui/ink/components/ui/scroll-area/ScrollArea.js +0 -42
  265. package/dist/ui/ink/components/ui/scroll-area/ScrollArea.js.map +0 -1
  266. package/dist/ui/ink/components/ui/scroll-area/index.d.ts +0 -3
  267. package/dist/ui/ink/components/ui/scroll-area/index.d.ts.map +0 -1
  268. package/dist/ui/ink/components/ui/scroll-area/index.js +0 -2
  269. package/dist/ui/ink/components/ui/scroll-area/index.js.map +0 -1
  270. package/dist/ui/ink/components/ui/select/Select.d.ts +0 -19
  271. package/dist/ui/ink/components/ui/select/Select.d.ts.map +0 -1
  272. package/dist/ui/ink/components/ui/select/Select.js +0 -73
  273. package/dist/ui/ink/components/ui/select/Select.js.map +0 -1
  274. package/dist/ui/ink/components/ui/select/index.d.ts +0 -3
  275. package/dist/ui/ink/components/ui/select/index.d.ts.map +0 -1
  276. package/dist/ui/ink/components/ui/select/index.js +0 -2
  277. package/dist/ui/ink/components/ui/select/index.js.map +0 -1
  278. package/dist/ui/ink/components/ui/spinner/Spinner.d.ts +0 -14
  279. package/dist/ui/ink/components/ui/spinner/Spinner.d.ts.map +0 -1
  280. package/dist/ui/ink/components/ui/spinner/Spinner.js +0 -16
  281. package/dist/ui/ink/components/ui/spinner/Spinner.js.map +0 -1
  282. package/dist/ui/ink/components/ui/spinner/index.d.ts +0 -3
  283. package/dist/ui/ink/components/ui/spinner/index.d.ts.map +0 -1
  284. package/dist/ui/ink/components/ui/spinner/index.js +0 -2
  285. package/dist/ui/ink/components/ui/spinner/index.js.map +0 -1
  286. package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.d.ts +0 -12
  287. package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.d.ts.map +0 -1
  288. package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.js +0 -39
  289. package/dist/ui/ink/components/ui/status-indicator/StatusIndicator.js.map +0 -1
  290. package/dist/ui/ink/components/ui/status-indicator/index.d.ts +0 -3
  291. package/dist/ui/ink/components/ui/status-indicator/index.d.ts.map +0 -1
  292. package/dist/ui/ink/components/ui/status-indicator/index.js +0 -2
  293. package/dist/ui/ink/components/ui/status-indicator/index.js.map +0 -1
  294. package/dist/ui/ink/components/ui/streaming-text/StreamingText.d.ts +0 -13
  295. package/dist/ui/ink/components/ui/streaming-text/StreamingText.d.ts.map +0 -1
  296. package/dist/ui/ink/components/ui/streaming-text/StreamingText.js +0 -22
  297. package/dist/ui/ink/components/ui/streaming-text/StreamingText.js.map +0 -1
  298. package/dist/ui/ink/components/ui/streaming-text/index.d.ts +0 -3
  299. package/dist/ui/ink/components/ui/streaming-text/index.d.ts.map +0 -1
  300. package/dist/ui/ink/components/ui/streaming-text/index.js +0 -2
  301. package/dist/ui/ink/components/ui/streaming-text/index.js.map +0 -1
  302. package/dist/ui/ink/components/ui/tabs/Tabs.d.ts +0 -20
  303. package/dist/ui/ink/components/ui/tabs/Tabs.d.ts.map +0 -1
  304. package/dist/ui/ink/components/ui/tabs/Tabs.js +0 -53
  305. package/dist/ui/ink/components/ui/tabs/Tabs.js.map +0 -1
  306. package/dist/ui/ink/components/ui/tabs/index.d.ts +0 -3
  307. package/dist/ui/ink/components/ui/tabs/index.d.ts.map +0 -1
  308. package/dist/ui/ink/components/ui/tabs/index.js +0 -2
  309. package/dist/ui/ink/components/ui/tabs/index.js.map +0 -1
  310. package/dist/ui/ink/components/ui/text-input/TextInput.d.ts +0 -22
  311. package/dist/ui/ink/components/ui/text-input/TextInput.d.ts.map +0 -1
  312. package/dist/ui/ink/components/ui/text-input/TextInput.js +0 -57
  313. package/dist/ui/ink/components/ui/text-input/TextInput.js.map +0 -1
  314. package/dist/ui/ink/components/ui/text-input/index.d.ts +0 -3
  315. package/dist/ui/ink/components/ui/text-input/index.d.ts.map +0 -1
  316. package/dist/ui/ink/components/ui/text-input/index.js +0 -2
  317. package/dist/ui/ink/components/ui/text-input/index.js.map +0 -1
  318. package/dist/ui/ink/components/ui/token-counter/TokenCounter.d.ts +0 -17
  319. package/dist/ui/ink/components/ui/token-counter/TokenCounter.d.ts.map +0 -1
  320. package/dist/ui/ink/components/ui/token-counter/TokenCounter.js +0 -38
  321. package/dist/ui/ink/components/ui/token-counter/TokenCounter.js.map +0 -1
  322. package/dist/ui/ink/components/ui/token-counter/index.d.ts +0 -3
  323. package/dist/ui/ink/components/ui/token-counter/index.d.ts.map +0 -1
  324. package/dist/ui/ink/components/ui/token-counter/index.js +0 -2
  325. package/dist/ui/ink/components/ui/token-counter/index.js.map +0 -1
  326. package/dist/ui/ink/components/ui/typewriter/Typewriter.d.ts +0 -14
  327. package/dist/ui/ink/components/ui/typewriter/Typewriter.d.ts.map +0 -1
  328. package/dist/ui/ink/components/ui/typewriter/Typewriter.js +0 -57
  329. package/dist/ui/ink/components/ui/typewriter/Typewriter.js.map +0 -1
  330. package/dist/ui/ink/components/ui/typewriter/index.d.ts +0 -3
  331. package/dist/ui/ink/components/ui/typewriter/index.d.ts.map +0 -1
  332. package/dist/ui/ink/components/ui/typewriter/index.js +0 -2
  333. package/dist/ui/ink/components/ui/typewriter/index.js.map +0 -1
  334. package/dist/ui/opentui-renderer.d.ts +0 -53
  335. package/dist/ui/opentui-renderer.d.ts.map +0 -1
  336. package/dist/ui/opentui-renderer.js +0 -463
  337. package/dist/ui/opentui-renderer.js.map +0 -1
  338. package/dist/utils/memoize.d.ts +0 -14
  339. package/dist/utils/memoize.d.ts.map +0 -1
  340. package/dist/utils/memoize.js +0 -51
  341. package/dist/utils/memoize.js.map +0 -1
  342. package/dist/utils/types.d.ts +0 -6
  343. package/dist/utils/types.d.ts.map +0 -1
  344. package/dist/utils/types.js +0 -2
  345. package/dist/utils/types.js.map +0 -1
  346. package/dist/utils.d.ts +0 -22
  347. package/dist/utils.d.ts.map +0 -1
  348. package/dist/utils.js +0 -81
  349. package/dist/utils.js.map +0 -1
package/dist/logger.js CHANGED
@@ -1,19 +1,11 @@
1
- import { appendFileSync, mkdirSync, existsSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { homedir } from 'node:os';
4
- /**
5
- * Логирование в файл.
6
- *
7
- * Все логи пишутся в ~/.mma/logs/:
8
- * - Сессионные логи: <sessionId>.log
9
- * - Дневные логи: YYYY-MM-DD.log
10
- *
11
- * Уровни: INFO, WARN, ERROR, DEBUG.
12
- * Специальные логи: LLM request/response, tool calls.
13
- *
14
- * @module logger
15
- */
16
- const LOGS_DIR = join(homedir(), '.mma', 'logs');
1
+ import { appendFileSync, mkdirSync, existsSync, readdirSync, statSync, unlinkSync, renameSync, } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ const LOGS_DIR = join(homedir(), ".mma", "logs");
5
+ const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5 MB на файл
6
+ const MAX_LOG_FILES = 30; // макс. количество файлов в директории
7
+ const DEFAULT_MAX_DAYS = 30; // макс. возраст файла в днях
8
+ const TOOL_OUTPUT_LIMIT = 2000; // макс. символов вывода тула в логе
17
9
  let _sessionLogPath = null;
18
10
  let _statusWriter = null;
19
11
  let _logRenderer = null;
@@ -33,6 +25,7 @@ function ensureDir() {
33
25
  export function initSessionLog(sessionId) {
34
26
  ensureDir();
35
27
  _sessionLogPath = join(LOGS_DIR, `${sessionId}.log`);
28
+ cleanupOldLogs();
36
29
  }
37
30
  export function getLogPath() {
38
31
  if (_sessionLogPath)
@@ -48,22 +41,44 @@ export function closeSessionLog() {
48
41
  function timestamp() {
49
42
  return new Date().toISOString();
50
43
  }
44
+ /** Ротировать файл если превышен лимит размера */
45
+ function rotateIfNeeded(filePath) {
46
+ if (!existsSync(filePath))
47
+ return;
48
+ const size = statSync(filePath).size;
49
+ if (size < MAX_LOG_SIZE)
50
+ return;
51
+ let idx = 1;
52
+ while (existsSync(`${filePath}.${idx}`))
53
+ idx++;
54
+ renameSync(filePath, `${filePath}.${idx}`);
55
+ }
51
56
  export function log(level, tag, message) {
52
57
  ensureDir();
58
+ const fp = getLogPath();
59
+ rotateIfNeeded(fp);
53
60
  const line = `[${timestamp()}] [${level}] [${tag}] ${message}\n`;
54
- appendFileSync(getLogPath(), line, 'utf-8');
61
+ appendFileSync(fp, line, "utf-8");
55
62
  _logRenderer?.(level, tag, message);
56
63
  }
57
- export function logInfo(tag, message) { log('INFO', tag, message); }
58
- export function logWarn(tag, message) { log('WARN', tag, message); }
59
- export function logError(tag, message) { log('ERROR', tag, message); }
60
- export function logDebug(tag, message) { log('DEBUG', tag, message); }
64
+ export function logInfo(tag, message) {
65
+ log("INFO", tag, message);
66
+ }
67
+ export function logWarn(tag, message) {
68
+ log("WARN", tag, message);
69
+ }
70
+ export function logError(tag, message) {
71
+ log("ERROR", tag, message);
72
+ }
73
+ export function logDebug(tag, message) {
74
+ log("DEBUG", tag, message);
75
+ }
61
76
  export function logLLMRequest(model, messagesCount, promptPreview, caller) {
62
- const tag = caller ? `LLM/${caller}` : 'LLM';
77
+ const tag = caller ? `LLM/${caller}` : "LLM";
63
78
  logInfo(tag, `→ ${model} | ${messagesCount} messages | "${promptPreview.slice(0, 100)}"`);
64
79
  }
65
80
  export function logLLMResponse(model, responseLength, genTimeMs, error, caller) {
66
- const tag = caller ? `LLM/${caller}` : 'LLM';
81
+ const tag = caller ? `LLM/${caller}` : "LLM";
67
82
  if (error) {
68
83
  logError(tag, `← ${model} | ${responseLength} chars | ${genTimeMs}ms | ERROR: ${error}`);
69
84
  }
@@ -72,33 +87,69 @@ export function logLLMResponse(model, responseLength, genTimeMs, error, caller)
72
87
  }
73
88
  }
74
89
  export function logToolCall(tool, preview, result) {
75
- const previewTrimmed = preview.length > 80 ? preview.slice(0, 80) + '...' : preview;
90
+ const previewTrimmed = preview.length > 200 ? preview.slice(0, 200) + "..." : preview;
76
91
  if (result !== undefined) {
77
- const resultTrimmed = result.length > 100 ? result.slice(0, 100) + '...' : result;
78
- logInfo('TOOL', `${tool} | ${previewTrimmed} → ${resultTrimmed}`);
92
+ const resultTrimmed = result.length > 200 ? result.slice(0, 200) + "..." : result;
93
+ logInfo("TOOL", `${tool} | ${previewTrimmed} → ${resultTrimmed}`);
79
94
  }
80
95
  else {
81
- logInfo('TOOL', `${tool} | ${previewTrimmed}`);
96
+ logInfo("TOOL", `${tool} | ${previewTrimmed}`);
82
97
  }
83
98
  }
99
+ /** Запись полного вывода тула в лог (уровень DEBUG) */
100
+ export function logToolOutput(tool, output, exitCode) {
101
+ const trimmed = output.length > TOOL_OUTPUT_LIMIT
102
+ ? output.slice(0, TOOL_OUTPUT_LIMIT) +
103
+ `\n... (truncated ${output.length - TOOL_OUTPUT_LIMIT} chars)`
104
+ : output;
105
+ logDebug("TOOL_OUTPUT", `${tool} exit:${exitCode}\n${trimmed}`);
106
+ }
84
107
  export function logREPL(tag, content) {
85
- const trimmed = content.length > 200 ? content.slice(0, 200) + '...' : content;
108
+ const trimmed = content.length > 400 ? content.slice(0, 400) + "..." : content;
86
109
  logInfo(`REPL/${tag}`, trimmed);
87
110
  }
88
- export function cleanupOldLogs(maxDays = 7) {
111
+ /**
112
+ * Очистка старых логов.
113
+ * - Удаляет файлы старше maxDays
114
+ * - Оставляет не более maxFiles самых свежих .log файлов
115
+ */
116
+ export function cleanupOldLogs(maxDays = DEFAULT_MAX_DAYS, maxFiles = MAX_LOG_FILES) {
89
117
  ensureDir();
90
- const { readdirSync, unlinkSync } = require('node:fs');
91
118
  const now = Date.now();
92
- for (const file of readdirSync(LOGS_DIR)) {
93
- if (!file.endsWith('.log'))
94
- continue;
95
- const filePath = join(LOGS_DIR, file);
96
- const stat = existsSync(filePath) ? require('node:fs').statSync(filePath) : null;
97
- if (stat && (now - stat.mtimeMs) > maxDays * 24 * 60 * 60 * 1000) {
119
+ // 1. Удалить по возрасту
120
+ const files = readdirSync(LOGS_DIR)
121
+ .filter((f) => f.endsWith(".log") || /\.log\.\d+$/.test(f))
122
+ .map((f) => ({
123
+ name: f,
124
+ path: join(LOGS_DIR, f),
125
+ mtime: statSync(join(LOGS_DIR, f)).mtimeMs,
126
+ }))
127
+ .sort((a, b) => b.mtime - a.mtime); // newest first
128
+ for (const f of files) {
129
+ if (now - f.mtime > maxDays * 24 * 60 * 60 * 1000) {
98
130
  try {
99
- unlinkSync(filePath);
131
+ unlinkSync(f.path);
132
+ }
133
+ catch {
134
+ /* ignore */
100
135
  }
101
- catch { /* ignore */ }
136
+ }
137
+ }
138
+ // 2. Удалить лишние (свежие, но больше maxFiles штук)
139
+ const remaining = readdirSync(LOGS_DIR)
140
+ .filter((f) => f.endsWith(".log") || /\.log\.\d+$/.test(f))
141
+ .map((f) => ({
142
+ name: f,
143
+ path: join(LOGS_DIR, f),
144
+ mtime: statSync(join(LOGS_DIR, f)).mtimeMs,
145
+ }))
146
+ .sort((a, b) => b.mtime - a.mtime);
147
+ for (let i = maxFiles; i < remaining.length; i++) {
148
+ try {
149
+ unlinkSync(remaining[i].path);
150
+ }
151
+ catch {
152
+ /* ignore */
102
153
  }
103
154
  }
104
155
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC;;;;;;;;;;;GAWG;AAEH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD,IAAI,eAAe,GAAkB,IAAI,CAAC;AAC1C,IAAI,aAAa,GAAmC,IAAI,CAAC;AACzD,IAAI,YAAY,GAAmE,IAAI,CAAC;AAExF,MAAM,UAAU,eAAe,CAAC,MAAsC;IACpE,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAwE;IACrG,YAAY,GAAG,QAAQ,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,SAAS;IAChB,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,SAAS,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,SAAS,EAAE,CAAC;IACZ,eAAe,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,SAAS,MAAM,CAAC,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,eAAe;QAAE,OAAO,eAAe,CAAC;IAC5C,SAAS,EAAE,CAAC;IACZ,MAAM,GAAG,GAA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AC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC1D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACX,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACvB,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO;KAC3C,CAAC,CAAC;SACF,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IAErC,KAAK,IAAI,CAAC,GAAG,QAAQ,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QAAC,MAAM,CAAC;YACP,YAAY;QACd,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,97 +1,97 @@
1
- import { execSync } from 'node:child_process';
2
- import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import type { AgentPlugin, PluginContext } from '../../types.js';
5
-
6
- /**
7
- * Плагин lint-on-write.
8
- *
9
- * После каждого write_file/edit_file запускает линтер
10
- * и добавляет ошибки в tool result (модель видит их сразу).
11
- *
12
- * Линтер определяется автоматически (eslint → biome → prettier).
13
- *
14
- * @module plugins/builtin/lint-on-write
15
- */
16
-
17
- const LINTER_DETECT_COMMANDS = [
18
- { name: 'eslint', cmd: 'npx eslint --version' },
19
- { name: 'biome', cmd: 'npx @biomejs/biome --version' },
20
- { name: 'prettier', cmd: 'npx prettier --version' },
21
- ];
22
-
23
- function detectLinter(cwd: string, cacheFile: string): string | null {
24
- const cachePath = join(cwd, cacheFile);
25
- if (existsSync(cachePath)) {
26
- try {
27
- const cached = readFileSync(cachePath, 'utf-8').trim();
28
- if (cached) return cached;
29
- } catch { /* ignore */ }
30
- }
31
- for (const { name, cmd } of LINTER_DETECT_COMMANDS) {
32
- try {
33
- execSync(cmd, { cwd, timeout: 5000, windowsHide: true, stdio: 'pipe' });
34
- try { writeFileSync(cachePath, name, 'utf-8'); } catch { /* ignore */ }
35
- return name;
36
- } catch { /* not found */ }
37
- }
38
- return null;
39
- }
40
-
41
- function runLinter(linter: string, filePath: string, cwd: string): string | null {
42
- try {
43
- let cmd: string;
44
- switch (linter) {
45
- case 'eslint': cmd = `npx eslint "${filePath}" --format compact`; break;
46
- case 'biome': cmd = `npx @biomejs/biome check "${filePath}"`; break;
47
- case 'prettier': cmd = `npx prettier --check "${filePath}"`; break;
48
- default: return null;
49
- }
50
- execSync(cmd, { cwd, timeout: 15000, windowsHide: true, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
51
- return null;
52
- } catch (e: any) {
53
- const output = e.stdout?.toString() || e.stderr?.toString() || '';
54
- return output ? output.slice(0, 1000) : null;
55
- }
56
- }
57
-
58
- // Module-level linter cache
59
- let cachedLinter: string | null = null;
60
-
61
- export default function createLintOnWrite(): AgentPlugin {
62
- return {
63
- name: 'lint-on-write',
64
- version: '1.0.0',
65
- description: 'Auto-run linter after write_file/edit_file',
66
- onActivate(ctx: PluginContext) {
67
- ctx.logger.info('lint-on-write: active (linter detected on first file write)');
68
- },
69
- on(_event: string, _handler: any) { /* via PluginManager.on() */ },
70
- onDeactivate() { cachedLinter = null; },
71
- getPromptSection() {
72
- return '## Lint-on-Write Plugin\nAfter writing/editing .ts/.tsx/.js/.jsx files, lint errors (if any) are automatically appended to the tool result.';
73
- },
74
- };
75
- }
76
-
77
- /**
78
- * Обработчик tool:after — вызывается через PluginManager.on().
79
- * Экспортируется для регистрации в loop.ts.
80
- */
81
- export function handleToolAfter(
82
- toolName: string,
83
- args: Record<string, unknown>,
84
- _result: { stdout: string; stderr: string; exitCode: number },
85
- cwd: string,
86
- cacheFile: string,
87
- ): string | null {
88
- if (toolName !== 'write_file' && toolName !== 'edit_file') return null;
89
- const filePath = String(args.path ?? '');
90
- if (!filePath || !/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath)) return null;
91
-
92
- const linter = cachedLinter ?? detectLinter(cwd, cacheFile);
93
- if (!linter) return null;
94
- cachedLinter = linter;
95
-
96
- return runLinter(linter, filePath, cwd);
1
+ import { execSync } from 'node:child_process';
2
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import type { AgentPlugin, PluginContext } from '../../types.js';
5
+
6
+ /**
7
+ * Плагин lint-on-write.
8
+ *
9
+ * После каждого write_file/edit_file запускает линтер
10
+ * и добавляет ошибки в tool result (модель видит их сразу).
11
+ *
12
+ * Линтер определяется автоматически (eslint → biome → prettier).
13
+ *
14
+ * @module plugins/builtin/lint-on-write
15
+ */
16
+
17
+ const LINTER_DETECT_COMMANDS = [
18
+ { name: 'eslint', cmd: 'npx eslint --version' },
19
+ { name: 'biome', cmd: 'npx @biomejs/biome --version' },
20
+ { name: 'prettier', cmd: 'npx prettier --version' },
21
+ ];
22
+
23
+ function detectLinter(cwd: string, cacheFile: string): string | null {
24
+ const cachePath = join(cwd, cacheFile);
25
+ if (existsSync(cachePath)) {
26
+ try {
27
+ const cached = readFileSync(cachePath, 'utf-8').trim();
28
+ if (cached) return cached;
29
+ } catch { /* ignore */ }
30
+ }
31
+ for (const { name, cmd } of LINTER_DETECT_COMMANDS) {
32
+ try {
33
+ execSync(cmd, { cwd, timeout: 5000, windowsHide: true, stdio: 'pipe' });
34
+ try { writeFileSync(cachePath, name, 'utf-8'); } catch { /* ignore */ }
35
+ return name;
36
+ } catch { /* not found */ }
37
+ }
38
+ return null;
39
+ }
40
+
41
+ function runLinter(linter: string, filePath: string, cwd: string): string | null {
42
+ try {
43
+ let cmd: string;
44
+ switch (linter) {
45
+ case 'eslint': cmd = `npx eslint "${filePath}" --format compact`; break;
46
+ case 'biome': cmd = `npx @biomejs/biome check "${filePath}"`; break;
47
+ case 'prettier': cmd = `npx prettier --check "${filePath}"`; break;
48
+ default: return null;
49
+ }
50
+ execSync(cmd, { cwd, timeout: 15000, windowsHide: true, encoding: 'utf-8', stdio: ['pipe', 'pipe', 'pipe'] });
51
+ return null;
52
+ } catch (e: any) {
53
+ const output = e.stdout?.toString() || e.stderr?.toString() || '';
54
+ return output ? output.slice(0, 1000) : null;
55
+ }
56
+ }
57
+
58
+ // Module-level linter cache
59
+ let cachedLinter: string | null = null;
60
+
61
+ export default function createLintOnWrite(): AgentPlugin {
62
+ return {
63
+ name: 'lint-on-write',
64
+ version: '1.0.0',
65
+ description: 'Auto-run linter after write_file/edit_file',
66
+ onActivate(ctx: PluginContext) {
67
+ ctx.logger.info('lint-on-write: active (linter detected on first file write)');
68
+ },
69
+ on(_event: string, _handler: any) { /* via PluginManager.on() */ },
70
+ onDeactivate() { cachedLinter = null; },
71
+ getPromptSection() {
72
+ return '## Lint-on-Write Plugin\nAfter writing/editing .ts/.tsx/.js/.jsx files, lint errors (if any) are automatically appended to the tool result.';
73
+ },
74
+ };
75
+ }
76
+
77
+ /**
78
+ * Обработчик tool:after — вызывается через PluginManager.on().
79
+ * Экспортируется для регистрации в loop.ts.
80
+ */
81
+ export function handleToolAfter(
82
+ toolName: string,
83
+ args: Record<string, unknown>,
84
+ _result: { stdout: string; stderr: string; exitCode: number },
85
+ cwd: string,
86
+ cacheFile: string,
87
+ ): string | null {
88
+ if (toolName !== 'write_file' && toolName !== 'edit_file') return null;
89
+ const filePath = String(args.path ?? '');
90
+ if (!filePath || !/\.(ts|tsx|js|jsx|mjs|cjs)$/.test(filePath)) return null;
91
+
92
+ const linter = cachedLinter ?? detectLinter(cwd, cacheFile);
93
+ if (!linter) return null;
94
+ cachedLinter = linter;
95
+
96
+ return runLinter(linter, filePath, cwd);
97
97
  }
@@ -22,12 +22,12 @@ function sendNotification(title, body) {
22
22
  // Write temp .ps1 file to avoid $ escaping issues in shell
23
23
  const safeTitle = title.replace(/'/g, "''");
24
24
  const safeBody = body.replace(/'/g, "''");
25
- const psScript = `Add-Type -AssemblyName System.Windows.Forms
26
- $n = New-Object System.Windows.Forms.NotifyIcon
27
- $n.Icon = [System.Drawing.SystemIcons]::Information
28
- $n.Visible = $true
29
- $n.ShowBalloonTip(5000, '${safeTitle}', '${safeBody}', [System.Windows.Forms.ToolTipIcon]::Info)
30
- Start-Sleep -Seconds 2
25
+ const psScript = `Add-Type -AssemblyName System.Windows.Forms
26
+ $n = New-Object System.Windows.Forms.NotifyIcon
27
+ $n.Icon = [System.Drawing.SystemIcons]::Information
28
+ $n.Visible = $true
29
+ $n.ShowBalloonTip(5000, '${safeTitle}', '${safeBody}', [System.Windows.Forms.ToolTipIcon]::Info)
30
+ Start-Sleep -Seconds 2
31
31
  $n.Dispose()`;
32
32
  const tmpFile = join(tmpdir(), `mma-notify-${Date.now()}.ps1`);
33
33
  writeFileSync(tmpFile, psScript, 'utf-8');
@@ -1,105 +1,105 @@
1
- import { execSync } from 'node:child_process';
2
- import { writeFileSync, unlinkSync } from 'node:fs';
3
- import { join } from 'node:path';
4
- import { tmpdir } from 'node:os';
5
- import { platform } from 'node:os';
6
- import type { AgentPlugin, PluginContext } from '../../types.js';
7
-
8
- /**
9
- * Плагин notify — OS desktop-уведомления.
10
- *
11
- * Отправляет toast-уведомление при:
12
- * - agent:done — задача выполнена
13
- * - tool:blocked — агент заблокирован
14
- * - tool:after (question) — агент ждёт ответа
15
- *
16
- * Zero-dependency: shell-out по платформе.
17
- *
18
- * @module plugins/builtin/notify
19
- */
20
-
21
- function sendNotification(title: string, body: string): void {
22
- const p = platform();
23
- try {
24
- if (p === 'win32') {
25
- // Write temp .ps1 file to avoid $ escaping issues in shell
26
- const safeTitle = title.replace(/'/g, "''");
27
- const safeBody = body.replace(/'/g, "''");
28
- const psScript = `Add-Type -AssemblyName System.Windows.Forms
29
- $n = New-Object System.Windows.Forms.NotifyIcon
30
- $n.Icon = [System.Drawing.SystemIcons]::Information
31
- $n.Visible = $true
32
- $n.ShowBalloonTip(5000, '${safeTitle}', '${safeBody}', [System.Windows.Forms.ToolTipIcon]::Info)
33
- Start-Sleep -Seconds 2
34
- $n.Dispose()`;
35
- const tmpFile = join(tmpdir(), `mma-notify-${Date.now()}.ps1`);
36
- writeFileSync(tmpFile, psScript, 'utf-8');
37
- try {
38
- execSync(`powershell -ExecutionPolicy Bypass -File "${tmpFile}"`, {
39
- timeout: 8000,
40
- windowsHide: true,
41
- stdio: 'pipe',
42
- });
43
- } finally {
44
- try { unlinkSync(tmpFile); } catch { /* ignore */ }
45
- }
46
- } else if (p === 'darwin') {
47
- execSync(`osascript -e 'display notification "${body.replace(/"/g, '\\"')}" with title "${title.replace(/"/g, '\\"')}"'`, {
48
- timeout: 5000,
49
- stdio: 'pipe',
50
- });
51
- } else {
52
- // Linux
53
- execSync(`notify-send "${title.replace(/"/g, '\\"')}" "${body.replace(/"/g, '\\"')}"`, {
54
- timeout: 5000,
55
- stdio: 'pipe',
56
- });
57
- }
58
- } catch {
59
- // Best-effort
60
- }
61
- }
62
-
63
- export default function createNotify(): AgentPlugin {
64
- let ctx: PluginContext | null = null;
65
- let config = { onDone: true, onBlocked: true, onQuestion: true };
66
-
67
- return {
68
- name: 'notify',
69
- version: '1.0.0',
70
- description: 'OS desktop notifications for agent events',
71
-
72
- onActivate(pluginCtx: PluginContext) {
73
- ctx = pluginCtx;
74
- if (pluginCtx.config) {
75
- config = { ...config, ...pluginCtx.config as Record<string, unknown> } as typeof config;
76
- }
77
- pluginCtx.logger.info(`notify: active (done=${config.onDone}, blocked=${config.onBlocked}, question=${config.onQuestion})`);
78
- },
79
-
80
- onDeactivate() {
81
- ctx = null;
82
- },
83
-
84
- getPromptSection() {
85
- return '## Notify Plugin\nDesktop notifications are enabled. You don\'t need to notify the user about completion — it happens automatically.';
86
- },
87
- };
88
- }
89
-
90
- /**
91
- * Обработчики событий — вызываются извне через PluginManager.on().
92
- */
93
- export function handleAgentDone(): void {
94
- sendNotification('MMA', 'Agent finished the task');
95
- }
96
-
97
- export function handleToolBlocked(toolName: string, _args: unknown): void {
98
- sendNotification('MMA', `Tool blocked: ${toolName}`);
99
- }
100
-
101
- export function handleToolAfter(toolName: string, _args: unknown, result: { exitCode: number }): void {
102
- if (toolName === 'question') {
103
- sendNotification('MMA', 'Agent needs your answer');
104
- }
1
+ import { execSync } from 'node:child_process';
2
+ import { writeFileSync, unlinkSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { tmpdir } from 'node:os';
5
+ import { platform } from 'node:os';
6
+ import type { AgentPlugin, PluginContext } from '../../types.js';
7
+
8
+ /**
9
+ * Плагин notify — OS desktop-уведомления.
10
+ *
11
+ * Отправляет toast-уведомление при:
12
+ * - agent:done — задача выполнена
13
+ * - tool:blocked — агент заблокирован
14
+ * - tool:after (question) — агент ждёт ответа
15
+ *
16
+ * Zero-dependency: shell-out по платформе.
17
+ *
18
+ * @module plugins/builtin/notify
19
+ */
20
+
21
+ function sendNotification(title: string, body: string): void {
22
+ const p = platform();
23
+ try {
24
+ if (p === 'win32') {
25
+ // Write temp .ps1 file to avoid $ escaping issues in shell
26
+ const safeTitle = title.replace(/'/g, "''");
27
+ const safeBody = body.replace(/'/g, "''");
28
+ const psScript = `Add-Type -AssemblyName System.Windows.Forms
29
+ $n = New-Object System.Windows.Forms.NotifyIcon
30
+ $n.Icon = [System.Drawing.SystemIcons]::Information
31
+ $n.Visible = $true
32
+ $n.ShowBalloonTip(5000, '${safeTitle}', '${safeBody}', [System.Windows.Forms.ToolTipIcon]::Info)
33
+ Start-Sleep -Seconds 2
34
+ $n.Dispose()`;
35
+ const tmpFile = join(tmpdir(), `mma-notify-${Date.now()}.ps1`);
36
+ writeFileSync(tmpFile, psScript, 'utf-8');
37
+ try {
38
+ execSync(`powershell -ExecutionPolicy Bypass -File "${tmpFile}"`, {
39
+ timeout: 8000,
40
+ windowsHide: true,
41
+ stdio: 'pipe',
42
+ });
43
+ } finally {
44
+ try { unlinkSync(tmpFile); } catch { /* ignore */ }
45
+ }
46
+ } else if (p === 'darwin') {
47
+ execSync(`osascript -e 'display notification "${body.replace(/"/g, '\\"')}" with title "${title.replace(/"/g, '\\"')}"'`, {
48
+ timeout: 5000,
49
+ stdio: 'pipe',
50
+ });
51
+ } else {
52
+ // Linux
53
+ execSync(`notify-send "${title.replace(/"/g, '\\"')}" "${body.replace(/"/g, '\\"')}"`, {
54
+ timeout: 5000,
55
+ stdio: 'pipe',
56
+ });
57
+ }
58
+ } catch {
59
+ // Best-effort
60
+ }
61
+ }
62
+
63
+ export default function createNotify(): AgentPlugin {
64
+ let ctx: PluginContext | null = null;
65
+ let config = { onDone: true, onBlocked: true, onQuestion: true };
66
+
67
+ return {
68
+ name: 'notify',
69
+ version: '1.0.0',
70
+ description: 'OS desktop notifications for agent events',
71
+
72
+ onActivate(pluginCtx: PluginContext) {
73
+ ctx = pluginCtx;
74
+ if (pluginCtx.config) {
75
+ config = { ...config, ...pluginCtx.config as Record<string, unknown> } as typeof config;
76
+ }
77
+ pluginCtx.logger.info(`notify: active (done=${config.onDone}, blocked=${config.onBlocked}, question=${config.onQuestion})`);
78
+ },
79
+
80
+ onDeactivate() {
81
+ ctx = null;
82
+ },
83
+
84
+ getPromptSection() {
85
+ return '## Notify Plugin\nDesktop notifications are enabled. You don\'t need to notify the user about completion — it happens automatically.';
86
+ },
87
+ };
88
+ }
89
+
90
+ /**
91
+ * Обработчики событий — вызываются извне через PluginManager.on().
92
+ */
93
+ export function handleAgentDone(): void {
94
+ sendNotification('MMA', 'Agent finished the task');
95
+ }
96
+
97
+ export function handleToolBlocked(toolName: string, _args: unknown): void {
98
+ sendNotification('MMA', `Tool blocked: ${toolName}`);
99
+ }
100
+
101
+ export function handleToolAfter(toolName: string, _args: unknown, result: { exitCode: number }): void {
102
+ if (toolName === 'question') {
103
+ sendNotification('MMA', 'Agent needs your answer');
104
+ }
105
105
  }
@@ -1,3 +1,3 @@
1
- import type { AppConfig } from './config/types.js';
1
+ import type { AppConfig } from "./config/types.js";
2
2
  export declare function runSetupWizard(force?: boolean): Promise<AppConfig>;
3
3
  //# sourceMappingURL=setup-wizard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup-wizard.d.ts","sourceRoot":"","sources":["../src/setup-wizard.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAuWnD,wBAAsB,cAAc,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CA+DtE"}
1
+ {"version":3,"file":"setup-wizard.d.ts","sourceRoot":"","sources":["../src/setup-wizard.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAqbnD,wBAAsB,cAAc,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAgFtE"}