micro-models-agent 2.16.1 → 2.17.2

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 (428) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +8 -3
  3. package/dist/assets/app.js +1 -314
  4. package/dist/assets/hljs.js +5 -1244
  5. package/dist/assets/index.html +11 -0
  6. package/dist/assets/js/api.js +1 -28
  7. package/dist/assets/js/core/menus.js +1 -0
  8. package/dist/assets/js/core/store/feed.js +1 -0
  9. package/dist/assets/js/core/store/index.js +1 -0
  10. package/dist/assets/js/core/store/session.js +1 -0
  11. package/dist/assets/js/core/store/settings.js +1 -0
  12. package/dist/assets/js/core/store/tabs.js +1 -0
  13. package/dist/assets/js/dialog.js +1 -105
  14. package/dist/assets/js/dom.js +1 -178
  15. package/dist/assets/js/feed/core.js +1 -0
  16. package/dist/assets/js/feed/history.js +1 -0
  17. package/dist/assets/js/feed/plan.js +1 -0
  18. package/dist/assets/js/feed/question.js +3 -0
  19. package/dist/assets/js/feed/sidebar.js +1 -0
  20. package/dist/assets/js/feed/stream.js +1 -0
  21. package/dist/assets/js/feed/turn.js +5 -0
  22. package/dist/assets/js/feed.js +1 -1250
  23. package/dist/assets/js/format.js +2 -122
  24. package/dist/assets/js/i18n.js +1 -46
  25. package/dist/assets/js/rail.js +1 -114
  26. package/dist/assets/js/session/cmdk.js +1 -0
  27. package/dist/assets/js/session/composer.js +1 -0
  28. package/dist/assets/js/session/sessions-menu.js +1 -0
  29. package/dist/assets/js/session/tabs.js +1 -0
  30. package/dist/assets/js/settings/controls.js +1 -0
  31. package/dist/assets/js/settings/editors.js +1 -0
  32. package/dist/assets/js/settings/form.js +1 -0
  33. package/dist/assets/js/settings/modal.js +1 -0
  34. package/dist/assets/js/settings/panels.js +1 -0
  35. package/dist/assets/js/settings/providers.js +1 -0
  36. package/dist/assets/js/settings/search.js +1 -0
  37. package/dist/assets/js/settings/subdialog.js +1 -0
  38. package/dist/assets/js/settings/write.js +1 -0
  39. package/dist/assets/js/settings.js +1 -1914
  40. package/dist/assets/js/sidebar/core.js +1 -0
  41. package/dist/assets/js/sidebar/lsp.js +2 -0
  42. package/dist/assets/js/sidebar/map.js +1 -0
  43. package/dist/assets/js/sidebar/state.js +1 -0
  44. package/dist/assets/js/sidebar/trace.js +5 -0
  45. package/dist/assets/js/sidebar.js +1 -705
  46. package/dist/assets/js/store.js +1 -82
  47. package/dist/assets/js/subdialog.js +1 -0
  48. package/dist/assets/md.js +1 -291
  49. package/dist/assets/setup.js +3 -816
  50. package/dist/assets/smd.js +29 -1665
  51. package/dist/assets/styles.css +1 -1598
  52. package/dist/certification/certifications.json +1 -494
  53. package/dist/i18n/en.json +1 -1851
  54. package/dist/i18n/ru.json +1 -1854
  55. package/dist/main.js +815 -55797
  56. package/dist/modules/browser/bridge-server.mjs +2 -252
  57. package/package.json +10 -5
  58. package/dist/assets/js/settings-controls.js +0 -452
  59. package/dist/assets/js/tabs.js +0 -867
  60. package/dist/cli/cache-line.js +0 -31
  61. package/dist/cli/command-suggest.js +0 -39
  62. package/dist/cli/commands.js +0 -781
  63. package/dist/cli/completer.js +0 -268
  64. package/dist/cli/index.js +0 -3
  65. package/dist/cli/json-payload.js +0 -32
  66. package/dist/cli/main.js +0 -346
  67. package/dist/cli/onboarding-commands.js +0 -126
  68. package/dist/cli/plugin-commands.js +0 -38
  69. package/dist/cli/relaunch.js +0 -40
  70. package/dist/cli/repl-commands-lsp.js +0 -75
  71. package/dist/cli/repl-commands-skills.js +0 -105
  72. package/dist/cli/repl-commands.js +0 -1218
  73. package/dist/cli/repl.js +0 -1238
  74. package/dist/cli/run-result.js +0 -38
  75. package/dist/cli/security-commands.js +0 -177
  76. package/dist/cli/setup-order.js +0 -6
  77. package/dist/cli/setup-prompt.js +0 -50
  78. package/dist/cli/setup.js +0 -161
  79. package/dist/cli/web-command.js +0 -98
  80. package/dist/config/budget.js +0 -48
  81. package/dist/config/config.js +0 -345
  82. package/dist/config/defaults.js +0 -197
  83. package/dist/config/domains.js +0 -135
  84. package/dist/config/env.js +0 -46
  85. package/dist/config/experts.js +0 -17
  86. package/dist/config/index.js +0 -5
  87. package/dist/config/paths.js +0 -56
  88. package/dist/config/redact.js +0 -44
  89. package/dist/config/registry-extra.js +0 -334
  90. package/dist/config/registry.js +0 -584
  91. package/dist/config/security.js +0 -212
  92. package/dist/config/timeouts.js +0 -74
  93. package/dist/config/types.js +0 -1
  94. package/dist/config/utils.js +0 -57
  95. package/dist/core/agent/artifact-progress.js +0 -59
  96. package/dist/core/agent/artifact-resolve.js +0 -79
  97. package/dist/core/agent/audit-gate.js +0 -53
  98. package/dist/core/agent/compaction.js +0 -89
  99. package/dist/core/agent/constants.js +0 -90
  100. package/dist/core/agent/context-log.js +0 -454
  101. package/dist/core/agent/context-renderer.js +0 -45
  102. package/dist/core/agent/critic-gate.js +0 -132
  103. package/dist/core/agent/hallucination-gate.js +0 -197
  104. package/dist/core/agent/loop-state.js +0 -68
  105. package/dist/core/agent/prefix-monitor.js +0 -101
  106. package/dist/core/agent/reasoning-resolver.js +0 -65
  107. package/dist/core/agent/token-tracker.js +0 -99
  108. package/dist/core/agent/tool-batch.js +0 -312
  109. package/dist/core/agent/tool-images.js +0 -18
  110. package/dist/core/agent/tool-output.js +0 -116
  111. package/dist/core/agent/tool-pairing.js +0 -60
  112. package/dist/core/agent-moe.js +0 -248
  113. package/dist/core/agent.js +0 -1299
  114. package/dist/core/bootstrap/agent-phase.js +0 -66
  115. package/dist/core/bootstrap/config-phase.js +0 -86
  116. package/dist/core/bootstrap/modules-phase.js +0 -269
  117. package/dist/core/bootstrap/provider-phase.js +0 -183
  118. package/dist/core/bootstrap/session-phase.js +0 -204
  119. package/dist/core/bootstrap/state.js +0 -94
  120. package/dist/core/bootstrap/workspace-phase.js +0 -115
  121. package/dist/core/bootstrap.js +0 -112
  122. package/dist/core/crash-handler.js +0 -62
  123. package/dist/core/environment.js +0 -224
  124. package/dist/core/host-plan.js +0 -43
  125. package/dist/core/host.js +0 -23
  126. package/dist/core/index.js +0 -3
  127. package/dist/core/prompt-builder.js +0 -95
  128. package/dist/core/prompt-overflow.js +0 -306
  129. package/dist/core/session-logger.js +0 -375
  130. package/dist/core/system-prompt.js +0 -117
  131. package/dist/core/types.js +0 -1
  132. package/dist/core/version.js +0 -28
  133. package/dist/core/web-host.js +0 -34
  134. package/dist/core/workspace.js +0 -80
  135. package/dist/i18n/index.js +0 -80
  136. package/dist/index.js +0 -30
  137. package/dist/llm/cache-usage.js +0 -76
  138. package/dist/llm/image-utils.js +0 -138
  139. package/dist/llm/index.js +0 -4
  140. package/dist/llm/llm-errors.js +0 -50
  141. package/dist/llm/model-loader.js +0 -86
  142. package/dist/llm/models-dev.js +0 -121
  143. package/dist/llm/openai-compat.js +0 -756
  144. package/dist/llm/orchestrator.js +0 -294
  145. package/dist/llm/provider-budget.js +0 -68
  146. package/dist/llm/provider-context.js +0 -233
  147. package/dist/llm/provider.js +0 -9
  148. package/dist/llm/response.js +0 -44
  149. package/dist/llm/stream-state.js +0 -26
  150. package/dist/llm/token-counter.js +0 -83
  151. package/dist/llm/types.js +0 -1
  152. package/dist/logger/app-logger.js +0 -212
  153. package/dist/logger/file-log.js +0 -160
  154. package/dist/logger/index.js +0 -2
  155. package/dist/migration/backup.js +0 -56
  156. package/dist/migration/detect.js +0 -61
  157. package/dist/migration/index.js +0 -3
  158. package/dist/modules/artifacts/store.js +0 -62
  159. package/dist/modules/browser/actions.js +0 -79
  160. package/dist/modules/browser/bridge-client.js +0 -203
  161. package/dist/modules/browser/bridge-path.js +0 -10
  162. package/dist/modules/browser/console-buffer.js +0 -37
  163. package/dist/modules/browser/cookie-store.js +0 -29
  164. package/dist/modules/browser/driver-types.js +0 -1
  165. package/dist/modules/browser/driver.js +0 -186
  166. package/dist/modules/browser/index.js +0 -9
  167. package/dist/modules/browser/module.js +0 -30
  168. package/dist/modules/browser/session.js +0 -322
  169. package/dist/modules/browser/snapshot.js +0 -154
  170. package/dist/modules/browser/types.js +0 -13
  171. package/dist/modules/certification/cli.js +0 -264
  172. package/dist/modules/certification/fact-checker.js +0 -90
  173. package/dist/modules/certification/loader.js +0 -127
  174. package/dist/modules/certification/manifest.js +0 -231
  175. package/dist/modules/certification/runner.js +0 -233
  176. package/dist/modules/certification/scenarios.js +0 -586
  177. package/dist/modules/certification/syntax-scenarios.js +0 -50
  178. package/dist/modules/certification/types.js +0 -1
  179. package/dist/modules/context/chunk-query.js +0 -122
  180. package/dist/modules/context/fact-extractor.js +0 -170
  181. package/dist/modules/context/history.js +0 -15
  182. package/dist/modules/context/index.js +0 -2
  183. package/dist/modules/context/manager.js +0 -482
  184. package/dist/modules/critic/client.js +0 -176
  185. package/dist/modules/critic/evidence.js +0 -81
  186. package/dist/modules/critic/provider.js +0 -45
  187. package/dist/modules/critic/tools.js +0 -78
  188. package/dist/modules/critic/types.js +0 -1
  189. package/dist/modules/execution/audit-runners.js +0 -206
  190. package/dist/modules/execution/auditor.js +0 -222
  191. package/dist/modules/execution/execution-plugin.js +0 -478
  192. package/dist/modules/execution/index.js +0 -8
  193. package/dist/modules/execution/input-from.js +0 -70
  194. package/dist/modules/execution/module.js +0 -891
  195. package/dist/modules/execution/moe-executor.js +0 -443
  196. package/dist/modules/execution/plan-actions.js +0 -642
  197. package/dist/modules/execution/plan-checks.js +0 -35
  198. package/dist/modules/execution/plan-coverage.js +0 -71
  199. package/dist/modules/execution/plan-persister.js +0 -46
  200. package/dist/modules/execution/plan-steps.js +0 -31
  201. package/dist/modules/execution/plan-store.js +0 -274
  202. package/dist/modules/execution/plan-tool.js +0 -249
  203. package/dist/modules/execution/plan-validator.js +0 -197
  204. package/dist/modules/execution/planner.js +0 -103
  205. package/dist/modules/execution/stuck-detector.js +0 -834
  206. package/dist/modules/execution/tracker.js +0 -92
  207. package/dist/modules/execution/transient-error.js +0 -30
  208. package/dist/modules/execution/types.js +0 -1
  209. package/dist/modules/execution/verifier.js +0 -343
  210. package/dist/modules/execution/windows-commands.js +0 -52
  211. package/dist/modules/hallucination/artifact-claim.js +0 -93
  212. package/dist/modules/hallucination/confidence.js +0 -81
  213. package/dist/modules/hallucination/consistency.js +0 -37
  214. package/dist/modules/hallucination/detector.js +0 -57
  215. package/dist/modules/hallucination/factual.js +0 -205
  216. package/dist/modules/hallucination/index.js +0 -6
  217. package/dist/modules/hallucination/js-identifiers.js +0 -261
  218. package/dist/modules/hallucination/llm-judge.js +0 -116
  219. package/dist/modules/hallucination/success-claim.js +0 -59
  220. package/dist/modules/index.js +0 -5
  221. package/dist/modules/indexer/cache.js +0 -88
  222. package/dist/modules/indexer/index.js +0 -4
  223. package/dist/modules/indexer/map-command.js +0 -33
  224. package/dist/modules/indexer/map-select.js +0 -87
  225. package/dist/modules/indexer/module.js +0 -293
  226. package/dist/modules/indexer/project-profile.js +0 -184
  227. package/dist/modules/indexer/symbols.js +0 -189
  228. package/dist/modules/indexer/walker.js +0 -285
  229. package/dist/modules/lsp/check-tool.js +0 -61
  230. package/dist/modules/lsp/client.js +0 -406
  231. package/dist/modules/lsp/command.js +0 -53
  232. package/dist/modules/lsp/config.js +0 -189
  233. package/dist/modules/lsp/index.js +0 -4
  234. package/dist/modules/lsp/module.js +0 -295
  235. package/dist/modules/lsp/probe.js +0 -86
  236. package/dist/modules/lsp/project-root.js +0 -69
  237. package/dist/modules/lsp/startup-check.js +0 -154
  238. package/dist/modules/lsp/types.js +0 -1
  239. package/dist/modules/mcp/client.js +0 -445
  240. package/dist/modules/mcp/index.js +0 -4
  241. package/dist/modules/mcp/module.js +0 -295
  242. package/dist/modules/mcp/registry.js +0 -20
  243. package/dist/modules/memory/index.js +0 -2
  244. package/dist/modules/memory/module.js +0 -101
  245. package/dist/modules/memory/search.js +0 -45
  246. package/dist/modules/memory/store.js +0 -107
  247. package/dist/modules/onboarding/init.js +0 -47
  248. package/dist/modules/onboarding/meet.js +0 -30
  249. package/dist/modules/onboarding/mode.js +0 -30
  250. package/dist/modules/onboarding/prompts.js +0 -43
  251. package/dist/modules/pipelines/engine.js +0 -70
  252. package/dist/modules/pipelines/index.js +0 -4
  253. package/dist/modules/pipelines/parser.js +0 -59
  254. package/dist/modules/pipelines/template.js +0 -18
  255. package/dist/modules/plugins/builtin/lint-on-write.js +0 -377
  256. package/dist/modules/plugins/builtin/notify.js +0 -11
  257. package/dist/modules/plugins/index.js +0 -2
  258. package/dist/modules/plugins/loader.js +0 -85
  259. package/dist/modules/plugins/manager.js +0 -244
  260. package/dist/modules/plugins/types.js +0 -1
  261. package/dist/modules/pricing/index.js +0 -70
  262. package/dist/modules/pricing/prices.js +0 -147
  263. package/dist/modules/processes/detect.js +0 -34
  264. package/dist/modules/processes/index.js +0 -4
  265. package/dist/modules/processes/kill-tree.js +0 -52
  266. package/dist/modules/processes/registry.js +0 -294
  267. package/dist/modules/processes/runner.js +0 -23
  268. package/dist/modules/providers/cache.js +0 -23
  269. package/dist/modules/providers/capabilities.js +0 -28
  270. package/dist/modules/providers/create.js +0 -21
  271. package/dist/modules/providers/factory.js +0 -28
  272. package/dist/modules/providers/fallback.js +0 -81
  273. package/dist/modules/providers/health.js +0 -47
  274. package/dist/modules/providers/index.js +0 -6
  275. package/dist/modules/providers/manager.js +0 -207
  276. package/dist/modules/providers/naming.js +0 -15
  277. package/dist/modules/providers/preflight.js +0 -71
  278. package/dist/modules/providers/presets.js +0 -232
  279. package/dist/modules/providers/registry.js +0 -27
  280. package/dist/modules/providers/types.js +0 -1
  281. package/dist/modules/reasoning/policy.js +0 -42
  282. package/dist/modules/reasoning/probe.js +0 -116
  283. package/dist/modules/registry.js +0 -48
  284. package/dist/modules/security/audit-log.js +0 -119
  285. package/dist/modules/security/audit-notifier.js +0 -267
  286. package/dist/modules/security/command-validator.js +0 -272
  287. package/dist/modules/security/content-scanner.js +0 -53
  288. package/dist/modules/security/data-sanitizer.js +0 -82
  289. package/dist/modules/security/encryption.js +0 -216
  290. package/dist/modules/security/index.js +0 -15
  291. package/dist/modules/security/network-validator.js +0 -236
  292. package/dist/modules/security/path-validator.js +0 -261
  293. package/dist/modules/security/protected-paths.js +0 -73
  294. package/dist/modules/security/rate-limiter.js +0 -98
  295. package/dist/modules/security/security-policies.js +0 -499
  296. package/dist/modules/security/session-encryption.js +0 -182
  297. package/dist/modules/security/session-isolation.js +0 -75
  298. package/dist/modules/session/auto-name.js +0 -63
  299. package/dist/modules/session/export.js +0 -98
  300. package/dist/modules/session/index.js +0 -4
  301. package/dist/modules/session/manager.js +0 -234
  302. package/dist/modules/session/module.js +0 -33
  303. package/dist/modules/session/store.js +0 -295
  304. package/dist/modules/session/types.js +0 -1
  305. package/dist/modules/setup/answers.js +0 -35
  306. package/dist/modules/setup/apply.js +0 -79
  307. package/dist/modules/setup/discovery.js +0 -72
  308. package/dist/modules/skills/index.js +0 -3
  309. package/dist/modules/skills/loader.js +0 -86
  310. package/dist/modules/skills/matcher.js +0 -27
  311. package/dist/modules/skills/module.js +0 -141
  312. package/dist/modules/types.js +0 -1
  313. package/dist/modules/updater/changelog-reader.js +0 -93
  314. package/dist/modules/updater/checker.js +0 -101
  315. package/dist/modules/updater/dev-detect.js +0 -18
  316. package/dist/modules/updater/index.js +0 -4
  317. package/dist/modules/updater/module.js +0 -129
  318. package/dist/modules/user-profile/compressor.js +0 -18
  319. package/dist/modules/user-profile/index.js +0 -2
  320. package/dist/modules/user-profile/profile.js +0 -77
  321. package/dist/modules/webui/answer-api.js +0 -29
  322. package/dist/modules/webui/assets.js +0 -50
  323. package/dist/modules/webui/body.js +0 -21
  324. package/dist/modules/webui/commands-settings.js +0 -209
  325. package/dist/modules/webui/commands-shared.js +0 -60
  326. package/dist/modules/webui/commands.js +0 -174
  327. package/dist/modules/webui/config-api.js +0 -134
  328. package/dist/modules/webui/file-api.js +0 -202
  329. package/dist/modules/webui/forward.js +0 -159
  330. package/dist/modules/webui/history-api.js +0 -112
  331. package/dist/modules/webui/host-state.js +0 -60
  332. package/dist/modules/webui/i18n-api.js +0 -9
  333. package/dist/modules/webui/limits.js +0 -6
  334. package/dist/modules/webui/log-forward.js +0 -20
  335. package/dist/modules/webui/memory-commands.js +0 -64
  336. package/dist/modules/webui/model-cache.js +0 -18
  337. package/dist/modules/webui/module.js +0 -148
  338. package/dist/modules/webui/persist.js +0 -24
  339. package/dist/modules/webui/prompt-io.js +0 -97
  340. package/dist/modules/webui/providers-api.js +0 -337
  341. package/dist/modules/webui/providers-view.js +0 -56
  342. package/dist/modules/webui/reasoning-view.js +0 -15
  343. package/dist/modules/webui/run-agent.js +0 -81
  344. package/dist/modules/webui/server.js +0 -284
  345. package/dist/modules/webui/sessions-api.js +0 -178
  346. package/dist/modules/webui/settings-api.js +0 -561
  347. package/dist/modules/webui/setup-api.js +0 -201
  348. package/dist/modules/webui/state.js +0 -74
  349. package/dist/modules/webui/util.js +0 -261
  350. package/dist/output/bus.js +0 -37
  351. package/dist/output/channel.js +0 -285
  352. package/dist/output/format.js +0 -15
  353. package/dist/output/index.js +0 -8
  354. package/dist/output/json-sink.js +0 -24
  355. package/dist/output/machine.js +0 -9
  356. package/dist/output/session-sink.js +0 -27
  357. package/dist/output/types.js +0 -1
  358. package/dist/tools/approve.js +0 -41
  359. package/dist/tools/attach-image.js +0 -102
  360. package/dist/tools/auto-fixer.js +0 -180
  361. package/dist/tools/auto-tags.js +0 -83
  362. package/dist/tools/bash.js +0 -649
  363. package/dist/tools/browser.js +0 -160
  364. package/dist/tools/chunk-query.js +0 -112
  365. package/dist/tools/create-dir.js +0 -60
  366. package/dist/tools/delete-file.js +0 -67
  367. package/dist/tools/download-file.js +0 -142
  368. package/dist/tools/edit-file.js +0 -136
  369. package/dist/tools/enable-tools.js +0 -59
  370. package/dist/tools/executor.js +0 -304
  371. package/dist/tools/file-info.js +0 -49
  372. package/dist/tools/filter-tools.js +0 -17
  373. package/dist/tools/glob-tool.js +0 -37
  374. package/dist/tools/grep-tool.js +0 -142
  375. package/dist/tools/hidden-tools-block.js +0 -37
  376. package/dist/tools/index.js +0 -88
  377. package/dist/tools/list-dir.js +0 -53
  378. package/dist/tools/load-skill.js +0 -51
  379. package/dist/tools/mcp-call.js +0 -80
  380. package/dist/tools/meet-done.js +0 -14
  381. package/dist/tools/move-file.js +0 -94
  382. package/dist/tools/path-utils.js +0 -108
  383. package/dist/tools/pipeline-run.js +0 -167
  384. package/dist/tools/preview.js +0 -2
  385. package/dist/tools/process-ids.js +0 -31
  386. package/dist/tools/process-kill.js +0 -33
  387. package/dist/tools/process-list.js +0 -38
  388. package/dist/tools/process-log.js +0 -49
  389. package/dist/tools/process-wait.js +0 -63
  390. package/dist/tools/prompt-io.js +0 -29
  391. package/dist/tools/question.js +0 -288
  392. package/dist/tools/read-file.js +0 -200
  393. package/dist/tools/recall.js +0 -124
  394. package/dist/tools/registry.js +0 -48
  395. package/dist/tools/remember.js +0 -72
  396. package/dist/tools/scope-check.js +0 -32
  397. package/dist/tools/scope-request.js +0 -96
  398. package/dist/tools/search-history.js +0 -88
  399. package/dist/tools/session-info.js +0 -46
  400. package/dist/tools/set-thinking.js +0 -75
  401. package/dist/tools/subagent.js +0 -257
  402. package/dist/tools/syntax-validator.js +0 -379
  403. package/dist/tools/types.js +0 -1
  404. package/dist/tools/user-input.js +0 -134
  405. package/dist/tools/web-browse.js +0 -93
  406. package/dist/tools/web-fetch.js +0 -108
  407. package/dist/tools/web-search.js +0 -107
  408. package/dist/tools/write-file.js +0 -128
  409. package/dist/ui/action-log.js +0 -13
  410. package/dist/ui/box.js +0 -78
  411. package/dist/ui/colors.js +0 -6
  412. package/dist/ui/diff.js +0 -189
  413. package/dist/ui/index.js +0 -7
  414. package/dist/ui/line-editor.js +0 -1083
  415. package/dist/ui/line-math.js +0 -98
  416. package/dist/ui/md-formatter.js +0 -322
  417. package/dist/ui/output.js +0 -19
  418. package/dist/ui/plan-view.js +0 -109
  419. package/dist/ui/renderer.js +0 -589
  420. package/dist/ui/spinner.js +0 -91
  421. package/dist/ui/table.js +0 -142
  422. package/dist/ui/theme.js +0 -143
  423. package/dist/utils/child-run.js +0 -20
  424. package/dist/utils/error.js +0 -4
  425. package/dist/utils/index.js +0 -6
  426. package/dist/utils/retry.js +0 -17
  427. package/dist/utils/sleep.js +0 -23
  428. package/dist/utils/truncate.js +0 -9
@@ -1,116 +0,0 @@
1
- import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
2
- import { join, dirname } from "path";
3
- import { globalMmaDir } from "../../config/paths";
4
- import { readEnv } from "../../config/env";
5
- import { REASONING_CACHE_TTL_MS as CACHE_TTL_MS } from "../../config/timeouts";
6
- const PROBE_MESSAGES = [
7
- { role: "user", content: "Reply with exactly: ok" },
8
- ];
9
- /** Путь дискового кэша: ~/.mma/reasoning-cache.json (переопределяется MMA_REASONING_CACHE). */
10
- function cachePath() {
11
- return readEnv("REASONING_CACHE") ?? join(globalMmaDir(), "reasoning-cache.json");
12
- }
13
- /** In-memory L1-кэш (быстрый путь в пределах процесса). */
14
- const memCache = new Map();
15
- /**
16
- * Проверяет, уважает ли бэкенд механизм reasoning effort.
17
- * Шлёт тривиальный запрос с уровнем "none": если reasoning_content всё равно
18
- * появился — механизм игнорируется.
19
- * @returns `true` — механизм уважается, `false` — игнорируется,
20
- * `null` — транзиентная ошибка (вызывающий НЕ должен кэшировать).
21
- */
22
- export async function probeReasoningSupport(provider, strategy, signal) {
23
- if (strategy === "none")
24
- return false;
25
- // "openai-effort" — стандартное поле OpenAI. Sentinel "none", которым проба
26
- // измеряет подавление, транспорт вырезает (strict OpenAI на "none" отвечает
27
- // 400), поэтому измерить нечем — считаем механизм поддерживаемым. Если
28
- // бэкенд поле игнорирует, это безопасно (effort просто не влияет).
29
- if (strategy === "openai-effort")
30
- return true;
31
- try {
32
- let hasReasoning = false;
33
- for await (const chunk of provider.chat(PROBE_MESSAGES, undefined, signal, {
34
- maxTokens: 32,
35
- reasoningEffort: "none",
36
- reasoningStrategy: strategy,
37
- })) {
38
- if (chunk.type === "reasoning")
39
- hasReasoning = true;
40
- }
41
- // reasoning_content появился вопреки "none" — механизм игнорируется
42
- return !hasReasoning;
43
- }
44
- catch {
45
- // Транзиентная ошибка (сеть/авторизация/стрим) — НЕ сообщаем "не поддерживается".
46
- // Возврат null запрещает вызывающему кэшировать, чтобы разовый сбой
47
- // не отключал reasoning-механизм на весь 24ч TTL.
48
- return null;
49
- }
50
- }
51
- /** Ключ кэша пробы: baseUrl + модель. */
52
- export function cacheKey(baseUrl, model) {
53
- return `${baseUrl}|${model}`;
54
- }
55
- /**
56
- * Читает кэшированный результат пробы. Сначала память, потом диск.
57
- * Возвращает `undefined` при промахе или протухании (>24ч).
58
- */
59
- export function getCachedProbeResult(key) {
60
- // L1: память
61
- const mem = memCache.get(key);
62
- if (mem && Date.now() - mem.ts < CACHE_TTL_MS) {
63
- return mem.result;
64
- }
65
- // L2: диск
66
- const disk = readDiskCache();
67
- const entry = disk[key];
68
- if (entry) {
69
- const age = Date.now() - new Date(entry.ts).getTime();
70
- if (age < CACHE_TTL_MS) {
71
- memCache.set(key, { result: entry.result, ts: Date.now() });
72
- return entry.result;
73
- }
74
- }
75
- return undefined;
76
- }
77
- /**
78
- * Кладет результат пробы в память и на диск.
79
- */
80
- export function setCachedProbeResult(key, result) {
81
- const now = new Date().toISOString();
82
- memCache.set(key, { result, ts: Date.now() });
83
- const disk = readDiskCache();
84
- disk[key] = { result, ts: now };
85
- writeDiskCache(disk);
86
- }
87
- /** Сбрасывает кэш пробы (память + дисковый файл). */
88
- export function resetProbeCache() {
89
- memCache.clear();
90
- const path = cachePath();
91
- if (existsSync(path)) {
92
- writeFileSync(path, "{}", "utf-8");
93
- }
94
- }
95
- function readDiskCache() {
96
- try {
97
- const path = cachePath();
98
- if (existsSync(path)) {
99
- return JSON.parse(readFileSync(path, "utf-8"));
100
- }
101
- }
102
- catch {
103
- // Битый кэш — начинаем с чистого
104
- }
105
- return {};
106
- }
107
- function writeDiskCache(data) {
108
- try {
109
- const path = cachePath();
110
- mkdirSync(dirname(path), { recursive: true });
111
- writeFileSync(path, JSON.stringify(data, null, 2), "utf-8");
112
- }
113
- catch {
114
- // Best-effort: сбой записи на диск не должен ронять агента
115
- }
116
- }
@@ -1,48 +0,0 @@
1
- export class ModuleRegistry {
2
- modules = new Map();
3
- register(mod) {
4
- this.modules.set(mod.name, mod);
5
- return this;
6
- }
7
- get(name) {
8
- return this.modules.get(name);
9
- }
10
- listModules() {
11
- return Array.from(this.modules.keys()).sort();
12
- }
13
- collectPromptBlocks(exclude = []) {
14
- const blocks = [];
15
- for (const [name, mod] of this.modules) {
16
- if (exclude.includes(name))
17
- continue;
18
- if (mod.getSystemPromptBlock) {
19
- const block = mod.getSystemPromptBlock();
20
- if (block)
21
- blocks.push(block);
22
- }
23
- }
24
- return blocks;
25
- }
26
- collectToolDefinitions() {
27
- const tools = [];
28
- for (const mod of this.modules.values()) {
29
- if (mod.getToolDefinitions) {
30
- const defs = mod.getToolDefinitions();
31
- if (defs)
32
- tools.push(...defs);
33
- }
34
- }
35
- return tools;
36
- }
37
- collectPlugins() {
38
- const plugins = [];
39
- for (const mod of this.modules.values()) {
40
- if (mod.getPlugin) {
41
- const plugin = mod.getPlugin();
42
- if (plugin)
43
- plugins.push(plugin);
44
- }
45
- }
46
- return plugins;
47
- }
48
- }
@@ -1,119 +0,0 @@
1
- // Аудит-лог: запись действий агента в audit.jsonl (глобально или в каталог сессии).
2
- import { existsSync, mkdirSync, appendFileSync } from "fs";
3
- import { globalAuditNotifier } from "./audit-notifier";
4
- import { auditLogFile, globalLogsDir } from "../../config/paths";
5
- let _globalAuditDir = globalLogsDir();
6
- let _sessionAuditDir = null;
7
- function getAuditDir() {
8
- return _sessionAuditDir ?? _globalAuditDir;
9
- }
10
- /**
11
- * Назначить каталог аудита для сессии: записи идут туда вместо глобального.
12
- */
13
- export function setAuditSessionDir(dir) {
14
- _sessionAuditDir = dir;
15
- if (!existsSync(dir)) {
16
- mkdirSync(dir, { recursive: true, mode: 0o700 });
17
- }
18
- }
19
- /** Сбросить каталог сессии — возврат к глобальному каталогу аудита. */
20
- export function clearAuditSessionDir() {
21
- _sessionAuditDir = null;
22
- }
23
- /** Назначить глобальный каталог аудита (когда каталог сессии не активен). */
24
- export function setGlobalAuditDir(dir) {
25
- _globalAuditDir = dir;
26
- if (!existsSync(dir)) {
27
- mkdirSync(dir, { recursive: true, mode: 0o700 });
28
- }
29
- }
30
- /**
31
- * Записать запись аудита в audit.jsonl и уведомить notifier.
32
- * Ошибки записи/уведомления глушатся — аудит не должен ронять агента.
33
- */
34
- export function logAudit(entry) {
35
- const dir = getAuditDir();
36
- if (!existsSync(dir)) {
37
- mkdirSync(dir, { recursive: true, mode: 0o700 });
38
- }
39
- try {
40
- const logEntry = JSON.stringify(entry);
41
- appendFileSync(auditLogFile(dir), `${logEntry}\n`, "utf8");
42
- }
43
- catch {
44
- // молча: невозможность записи не должна ломать агента
45
- }
46
- // Уведомить нотификатор аудита, если включён
47
- try {
48
- globalAuditNotifier.notify(entry);
49
- }
50
- catch {
51
- // молча: падение нотификации не должно ломать агента
52
- }
53
- }
54
- /** Залогировать вызов тула. */
55
- export function logToolCall(sessionId, tool, success, details) {
56
- logAudit({
57
- timestamp: new Date().toISOString(),
58
- sessionId,
59
- action: "tool_call",
60
- tool,
61
- success,
62
- details,
63
- });
64
- }
65
- /** Залогировать запись файла. */
66
- export function logFileWrite(sessionId, path, success, details) {
67
- logAudit({
68
- timestamp: new Date().toISOString(),
69
- sessionId,
70
- action: "file_write",
71
- path,
72
- success,
73
- details,
74
- });
75
- }
76
- /** Залогировать удаление файла. */
77
- export function logFileDelete(sessionId, path, success, details) {
78
- logAudit({
79
- timestamp: new Date().toISOString(),
80
- sessionId,
81
- action: "file_delete",
82
- path,
83
- success,
84
- details,
85
- });
86
- }
87
- /** Залогировать выполнение bash-команды. */
88
- export function logBashCommand(sessionId, command, success, details) {
89
- logAudit({
90
- timestamp: new Date().toISOString(),
91
- sessionId,
92
- action: "bash_command",
93
- command,
94
- success,
95
- details,
96
- });
97
- }
98
- /** Залогировать сетевой запрос. */
99
- export function logNetworkRequest(sessionId, url, success, details) {
100
- logAudit({
101
- timestamp: new Date().toISOString(),
102
- sessionId,
103
- action: "network_request",
104
- url,
105
- success,
106
- details,
107
- });
108
- }
109
- /** Залогировать срабатывание security-блока. */
110
- export function logSecurityBlock(sessionId, _action, reason, details) {
111
- logAudit({
112
- timestamp: new Date().toISOString(),
113
- sessionId,
114
- action: "security_block",
115
- success: false,
116
- reason,
117
- details,
118
- });
119
- }
@@ -1,267 +0,0 @@
1
- // Нотификации о security-событиях: файл + webhook с ретраями и очередью.
2
- import { writeFileSync, appendFileSync, existsSync, mkdirSync } from "fs";
3
- import { join, dirname } from "path";
4
- import { backoffDelay } from "../../utils/retry";
5
- import { defaultOutputBus } from "../../output";
6
- /** Веса severity для сравнения. */
7
- const SEVERITY_WEIGHTS = {
8
- low: 1,
9
- medium: 2,
10
- high: 3,
11
- critical: 4,
12
- };
13
- /** Дефолтный конфиг нотификатора (выключен). */
14
- export const DEFAULT_AUDIT_NOTIFIER_CONFIG = {
15
- enabled: false,
16
- filePath: join(globalLogsDir(), "audit-notifications.jsonl"),
17
- webhookTimeout: 5000,
18
- minSeverity: "medium",
19
- eventTypes: [
20
- "security_block",
21
- "bash_command",
22
- "file_operation",
23
- "network_request",
24
- "authentication",
25
- "configuration_change",
26
- ],
27
- maxRetries: 3,
28
- };
29
- /** Нотификатор security-событий: файл + webhook с ретраями. */
30
- export class AuditNotifier {
31
- config;
32
- retryQueue = [];
33
- isProcessing = false;
34
- constructor(config) {
35
- this.config = { ...DEFAULT_AUDIT_NOTIFIER_CONFIG, ...config };
36
- this.ensureLogDirectory();
37
- }
38
- /** Включён ли нотификатор. */
39
- isEnabled() {
40
- return this.config.enabled;
41
- }
42
- /** Включить нотификатор. */
43
- enable() {
44
- this.config.enabled = true;
45
- }
46
- /** Выключить нотификатор. */
47
- disable() {
48
- this.config.enabled = false;
49
- }
50
- /** Обновить конфиг. */
51
- updateConfig(config) {
52
- this.config = { ...this.config, ...config };
53
- this.ensureLogDirectory();
54
- }
55
- /** Гарантировать каталог лога. */
56
- ensureLogDirectory() {
57
- if (this.config.filePath) {
58
- const dir = dirname(this.config.filePath);
59
- mkdirSync(dir, { recursive: true });
60
- }
61
- }
62
- /** Подпадает ли тип события под нотификацию. */
63
- shouldNotify(eventType) {
64
- if (!this.config.enabled)
65
- return false;
66
- return this.config.eventTypes?.includes(eventType) ?? false;
67
- }
68
- /** Дотягивает ли severity до порога. */
69
- shouldNotifySeverity(severity) {
70
- const minSeverity = this.config.minSeverity ?? "medium";
71
- const minWeight = SEVERITY_WEIGHTS[minSeverity];
72
- const eventWeight = SEVERITY_WEIGHTS[severity];
73
- return eventWeight >= minWeight;
74
- }
75
- /** Нотифицировать аудит-событие: файл + webhook, падение — в retry-очередь. */
76
- async notify(entry) {
77
- if (!this.config.enabled)
78
- return null;
79
- const eventType = this.mapEventType(entry.action);
80
- if (!eventType || !this.shouldNotify(eventType))
81
- return null;
82
- const severity = this.determineSeverity(entry);
83
- if (!this.shouldNotifySeverity(severity))
84
- return null;
85
- const notification = {
86
- timestamp: new Date().toISOString(),
87
- eventType,
88
- severity,
89
- message: entry.details || entry.reason || entry.action,
90
- details: entry.details ? { details: entry.details } : undefined,
91
- sessionId: entry.sessionId,
92
- };
93
- // Пишем в файл
94
- this.writeToFile(notification);
95
- // Шлём в webhook, если задан
96
- if (this.config.webhookUrl) {
97
- try {
98
- await this.sendToWebhook(notification);
99
- }
100
- catch (error) {
101
- defaultOutputBus.log("warn", "audit", `[AuditNotifier] Webhook failed, adding to retry queue: ${error instanceof Error ? error.message : String(error)}`, { persist: true });
102
- this.addToRetryQueue(notification);
103
- }
104
- }
105
- return notification;
106
- }
107
- /** Маппинг action записи аудита в тип события нотификации. */
108
- mapEventType(action) {
109
- const typeMap = {
110
- tool_call: "tool_call",
111
- bash_command: "bash_command",
112
- file_write: "file_operation",
113
- file_delete: "file_operation",
114
- network_request: "network_request",
115
- security_block: "security_block",
116
- };
117
- return typeMap[action] || null;
118
- }
119
- /** Severity из записи аудита (по типу action). */
120
- determineSeverity(entry) {
121
- // Дефолтная severity по типу action
122
- const typeSeverity = {
123
- security_block: "high",
124
- bash_command: "high",
125
- file_delete: "medium",
126
- file_write: "medium",
127
- network_request: "medium",
128
- tool_call: "low",
129
- session_start: "low",
130
- session_end: "low",
131
- };
132
- return typeSeverity[entry.action] || "low";
133
- }
134
- /** Записать нотификацию в файл. */
135
- writeToFile(notification) {
136
- if (!this.config.filePath)
137
- return;
138
- try {
139
- const line = JSON.stringify(notification);
140
- appendFileSync(this.config.filePath, `${line}\n`, "utf8");
141
- }
142
- catch (error) {
143
- defaultOutputBus.log("error", "audit", `[AuditNotifier] Failed to write to file: ${error instanceof Error ? error.message : String(error)}`, { persist: true });
144
- }
145
- }
146
- /**
147
- * Отправить нотификацию в webhook. Падение бросает исключение — политику
148
- * ретраев решает вызывающий (notify() кладёт в очередь, processRetryQueue()
149
- * считает попытки).
150
- */
151
- async sendToWebhook(notification) {
152
- if (!this.config.webhookUrl)
153
- return;
154
- const controller = new AbortController();
155
- const timeoutId = setTimeout(() => controller.abort(), this.config.webhookTimeout);
156
- try {
157
- const response = await fetch(this.config.webhookUrl, {
158
- method: "POST",
159
- headers: { "Content-Type": "application/json" },
160
- body: JSON.stringify(notification),
161
- signal: controller.signal,
162
- });
163
- if (!response.ok) {
164
- throw new Error(`Webhook returned ${response.status}`);
165
- }
166
- }
167
- finally {
168
- clearTimeout(timeoutId);
169
- }
170
- }
171
- /** Положить нотификацию в retry-очередь. */
172
- addToRetryQueue(notification) {
173
- this.retryQueue.push({ entry: notification, retries: 0 });
174
- if (!this.isProcessing) {
175
- this.processRetryQueue();
176
- }
177
- }
178
- /** Разобрать retry-очередь (бэкофф, лимит попыток). */
179
- async processRetryQueue() {
180
- if (this.retryQueue.length === 0 || this.isProcessing)
181
- return;
182
- this.isProcessing = true;
183
- try {
184
- while (this.retryQueue.length > 0) {
185
- const item = this.retryQueue[0];
186
- if (item.retries >= (this.config.maxRetries ?? 3)) {
187
- defaultOutputBus.log("error", "audit", `[AuditNotifier] Max retries exceeded for notification: ${JSON.stringify(item.entry)}`, { persist: true });
188
- this.retryQueue.shift();
189
- continue;
190
- }
191
- try {
192
- await this.sendToWebhook(item.entry);
193
- this.retryQueue.shift();
194
- }
195
- catch (error) {
196
- // sendToWebhook сам в очередь не кладёт — счётчик ретраев реально
197
- // растёт, и maxRetries достижим.
198
- item.retries++;
199
- defaultOutputBus.log("warn", "audit", `[AuditNotifier] Webhook retry ${item.retries} failed: ${error instanceof Error ? error.message : String(error)}`, { persist: true });
200
- // Экспоненциальный бэкофф перед следующей попыткой того же head-элемента.
201
- const delay = backoffDelay(item.retries, 1000);
202
- await new Promise((resolve) => setTimeout(resolve, delay));
203
- }
204
- }
205
- }
206
- finally {
207
- this.isProcessing = false;
208
- }
209
- }
210
- /** Прочитать нотификации из файла (последние N). */
211
- readNotifications(limit = 100) {
212
- if (!this.config.filePath || !existsSync(this.config.filePath)) {
213
- return [];
214
- }
215
- try {
216
- const content = readFileSync(this.config.filePath, "utf8");
217
- const lines = content.split("\n").filter(Boolean);
218
- return lines.slice(-limit).map((line) => JSON.parse(line));
219
- }
220
- catch (error) {
221
- defaultOutputBus.log("error", "audit", `[AuditNotifier] Failed to read notifications: ${error instanceof Error ? error.message : String(error)}`, { persist: true });
222
- return [];
223
- }
224
- }
225
- /** Очистить нотификации (файл + очередь). */
226
- clearNotifications() {
227
- if (this.config.filePath) {
228
- writeFileSync(this.config.filePath, "", "utf8");
229
- }
230
- this.retryQueue = [];
231
- }
232
- /** Статистика нотификаций: всего, по severity, по типам. */
233
- getStats() {
234
- const notifications = this.readNotifications();
235
- const bySeverity = { low: 0, medium: 0, high: 0, critical: 0 };
236
- const byType = {
237
- tool_call: 0,
238
- tool_result: 0,
239
- bash_command: 0,
240
- file_operation: 0,
241
- network_request: 0,
242
- security_block: 0,
243
- authentication: 0,
244
- configuration_change: 0,
245
- session_start: 0,
246
- session_end: 0,
247
- };
248
- for (const n of notifications) {
249
- bySeverity[n.severity] = (bySeverity[n.severity] || 0) + 1;
250
- byType[n.eventType] = (byType[n.eventType] || 0) + 1;
251
- }
252
- return {
253
- total: notifications.length,
254
- bySeverity,
255
- byType,
256
- };
257
- }
258
- }
259
- /** Глобальный инстанс нотификатора аудита. */
260
- export const globalAuditNotifier = new AuditNotifier();
261
- /** Создать нотификатор аудита с кастомным конфигом. */
262
- export function createAuditNotifier(config) {
263
- return new AuditNotifier(config);
264
- }
265
- // Импорт readFileSync для readNotifications
266
- import { readFileSync } from "fs";
267
- import { globalLogsDir } from "../../config/paths";