@belboy47/brc-agent 0.0.0-stage → 2.0.17-lab.1

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 (413) hide show
  1. package/LICENSE +30 -0
  2. package/LICENSE-desktop-commander +21 -0
  3. package/NOTICE +13 -0
  4. package/README.md +58 -2
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +354 -0
  7. package/dist/cli.js.map +1 -0
  8. package/dist/context.d.ts +31 -0
  9. package/dist/context.js +11 -0
  10. package/dist/context.js.map +1 -0
  11. package/dist/core/command-manager.d.ts +8 -0
  12. package/dist/core/command-manager.js +242 -0
  13. package/dist/core/command-manager.js.map +1 -0
  14. package/dist/core/config-field-definitions.d.ts +41 -0
  15. package/dist/core/config-field-definitions.js +38 -0
  16. package/dist/core/config-field-definitions.js.map +1 -0
  17. package/dist/core/config-manager.d.ts +102 -0
  18. package/dist/core/config-manager.js +451 -0
  19. package/dist/core/config-manager.js.map +1 -0
  20. package/dist/core/config.d.ts +6 -0
  21. package/dist/core/config.js +20 -0
  22. package/dist/core/config.js.map +1 -0
  23. package/dist/core/custom-stdio.d.ts +9 -0
  24. package/dist/core/custom-stdio.js +2 -0
  25. package/dist/core/custom-stdio.js.map +1 -0
  26. package/dist/core/error-handlers.d.ts +7 -0
  27. package/dist/core/error-handlers.js +16 -0
  28. package/dist/core/error-handlers.js.map +1 -0
  29. package/dist/core/file-transfer.d.ts +16 -0
  30. package/dist/core/file-transfer.js +316 -0
  31. package/dist/core/file-transfer.js.map +1 -0
  32. package/dist/core/handlers/edit-search-handlers.d.ts +6 -0
  33. package/dist/core/handlers/edit-search-handlers.js +7 -0
  34. package/dist/core/handlers/edit-search-handlers.js.map +1 -0
  35. package/dist/core/handlers/filesystem-handlers.d.ts +38 -0
  36. package/dist/core/handlers/filesystem-handlers.js +535 -0
  37. package/dist/core/handlers/filesystem-handlers.js.map +1 -0
  38. package/dist/core/handlers/history-handlers.d.ts +12 -0
  39. package/dist/core/handlers/history-handlers.js +68 -0
  40. package/dist/core/handlers/history-handlers.js.map +1 -0
  41. package/dist/core/handlers/index.d.ts +7 -0
  42. package/dist/core/handlers/index.js +9 -0
  43. package/dist/core/handlers/index.js.map +1 -0
  44. package/dist/core/handlers/process-handlers.d.ts +9 -0
  45. package/dist/core/handlers/process-handlers.js +16 -0
  46. package/dist/core/handlers/process-handlers.js.map +1 -0
  47. package/dist/core/handlers/search-handlers.d.ts +17 -0
  48. package/dist/core/handlers/search-handlers.js +336 -0
  49. package/dist/core/handlers/search-handlers.js.map +1 -0
  50. package/dist/core/handlers/terminal-handlers.d.ts +21 -0
  51. package/dist/core/handlers/terminal-handlers.js +36 -0
  52. package/dist/core/handlers/terminal-handlers.js.map +1 -0
  53. package/dist/core/handlers/transfer-handlers.d.ts +4 -0
  54. package/dist/core/handlers/transfer-handlers.js +76 -0
  55. package/dist/core/handlers/transfer-handlers.js.map +1 -0
  56. package/dist/core/search-manager.d.ts +162 -0
  57. package/dist/core/search-manager.js +929 -0
  58. package/dist/core/search-manager.js.map +1 -0
  59. package/dist/core/terminal-manager.d.ts +126 -0
  60. package/dist/core/terminal-manager.js +671 -0
  61. package/dist/core/terminal-manager.js.map +1 -0
  62. package/dist/core/tool-definitions.d.ts +9 -0
  63. package/dist/core/tool-definitions.js +1020 -0
  64. package/dist/core/tool-definitions.js.map +1 -0
  65. package/dist/core/tools/config.d.ts +97 -0
  66. package/dist/core/tools/config.js +265 -0
  67. package/dist/core/tools/config.js.map +1 -0
  68. package/dist/core/tools/edit.d.ts +49 -0
  69. package/dist/core/tools/edit.js +540 -0
  70. package/dist/core/tools/edit.js.map +1 -0
  71. package/dist/core/tools/feedback.d.ts +8 -0
  72. package/dist/core/tools/feedback.js +133 -0
  73. package/dist/core/tools/feedback.js.map +1 -0
  74. package/dist/core/tools/filesystem.d.ts +84 -0
  75. package/dist/core/tools/filesystem.js +991 -0
  76. package/dist/core/tools/filesystem.js.map +1 -0
  77. package/dist/core/tools/fuzzySearch.d.ts +14 -0
  78. package/dist/core/tools/fuzzySearch.js +141 -0
  79. package/dist/core/tools/fuzzySearch.js.map +1 -0
  80. package/dist/core/tools/fuzzySearchCore.d.ts +52 -0
  81. package/dist/core/tools/fuzzySearchCore.js +126 -0
  82. package/dist/core/tools/fuzzySearchCore.js.map +1 -0
  83. package/dist/core/tools/improved-process-tools.d.ts +24 -0
  84. package/dist/core/tools/improved-process-tools.js +645 -0
  85. package/dist/core/tools/improved-process-tools.js.map +1 -0
  86. package/dist/core/tools/mime-types.d.ts +3 -0
  87. package/dist/core/tools/mime-types.js +29 -0
  88. package/dist/core/tools/mime-types.js.map +1 -0
  89. package/dist/core/tools/pdf/extract-images.d.ts +34 -0
  90. package/dist/core/tools/pdf/extract-images.js +133 -0
  91. package/dist/core/tools/pdf/extract-images.js.map +1 -0
  92. package/dist/core/tools/pdf/index.d.ts +6 -0
  93. package/dist/core/tools/pdf/index.js +4 -0
  94. package/dist/core/tools/pdf/index.js.map +1 -0
  95. package/dist/core/tools/pdf/lib/pdf2md.d.ts +36 -0
  96. package/dist/core/tools/pdf/lib/pdf2md.js +77 -0
  97. package/dist/core/tools/pdf/lib/pdf2md.js.map +1 -0
  98. package/dist/core/tools/pdf/manipulations.d.ts +13 -0
  99. package/dist/core/tools/pdf/manipulations.js +100 -0
  100. package/dist/core/tools/pdf/manipulations.js.map +1 -0
  101. package/dist/core/tools/pdf/markdown.d.ts +26 -0
  102. package/dist/core/tools/pdf/markdown.js +276 -0
  103. package/dist/core/tools/pdf/markdown.js.map +1 -0
  104. package/dist/core/tools/pdf/utils.d.ts +12 -0
  105. package/dist/core/tools/pdf/utils.js +35 -0
  106. package/dist/core/tools/pdf/utils.js.map +1 -0
  107. package/dist/core/tools/process.d.ts +17 -0
  108. package/dist/core/tools/process.js +88 -0
  109. package/dist/core/tools/process.js.map +1 -0
  110. package/dist/core/tools/prompts.d.ts +28 -0
  111. package/dist/core/tools/prompts.js +260 -0
  112. package/dist/core/tools/prompts.js.map +1 -0
  113. package/dist/core/tools/schemas.d.ts +594 -0
  114. package/dist/core/tools/schemas.js +282 -0
  115. package/dist/core/tools/schemas.js.map +1 -0
  116. package/dist/core/tools/usage.d.ts +5 -0
  117. package/dist/core/tools/usage.js +25 -0
  118. package/dist/core/tools/usage.js.map +1 -0
  119. package/dist/core/types.d.ts +83 -0
  120. package/dist/core/types.js +2 -0
  121. package/dist/core/types.js.map +1 -0
  122. package/dist/core/ui/file-preview/shared/preview-file-types.d.ts +5 -0
  123. package/dist/core/ui/file-preview/shared/preview-file-types.js +60 -0
  124. package/dist/core/ui/file-preview/shared/preview-file-types.js.map +1 -0
  125. package/dist/core/utils/ab-test.d.ts +12 -0
  126. package/dist/core/utils/ab-test.js +105 -0
  127. package/dist/core/utils/ab-test.js.map +1 -0
  128. package/dist/core/utils/capture.d.ts +12 -0
  129. package/dist/core/utils/capture.js +38 -0
  130. package/dist/core/utils/capture.js.map +1 -0
  131. package/dist/core/utils/dockerPrompt.d.ts +17 -0
  132. package/dist/core/utils/dockerPrompt.js +54 -0
  133. package/dist/core/utils/dockerPrompt.js.map +1 -0
  134. package/dist/core/utils/feature-flags.d.ts +59 -0
  135. package/dist/core/utils/feature-flags.js +218 -0
  136. package/dist/core/utils/feature-flags.js.map +1 -0
  137. package/dist/core/utils/files/base.d.ts +173 -0
  138. package/dist/core/utils/files/base.js +6 -0
  139. package/dist/core/utils/files/base.js.map +1 -0
  140. package/dist/core/utils/files/binary.d.ts +21 -0
  141. package/dist/core/utils/files/binary.js +66 -0
  142. package/dist/core/utils/files/binary.js.map +1 -0
  143. package/dist/core/utils/files/docx.d.ts +47 -0
  144. package/dist/core/utils/files/docx.js +678 -0
  145. package/dist/core/utils/files/docx.js.map +1 -0
  146. package/dist/core/utils/files/excel.d.ts +24 -0
  147. package/dist/core/utils/files/excel.js +438 -0
  148. package/dist/core/utils/files/excel.js.map +1 -0
  149. package/dist/core/utils/files/factory.d.ts +29 -0
  150. package/dist/core/utils/files/factory.js +103 -0
  151. package/dist/core/utils/files/factory.js.map +1 -0
  152. package/dist/core/utils/files/image.d.ts +21 -0
  153. package/dist/core/utils/files/image.js +79 -0
  154. package/dist/core/utils/files/image.js.map +1 -0
  155. package/dist/core/utils/files/index.d.ts +9 -0
  156. package/dist/core/utils/files/index.js +15 -0
  157. package/dist/core/utils/files/index.js.map +1 -0
  158. package/dist/core/utils/files/pdf.d.ts +32 -0
  159. package/dist/core/utils/files/pdf.js +141 -0
  160. package/dist/core/utils/files/pdf.js.map +1 -0
  161. package/dist/core/utils/files/text.d.ts +70 -0
  162. package/dist/core/utils/files/text.js +552 -0
  163. package/dist/core/utils/files/text.js.map +1 -0
  164. package/dist/core/utils/fuzzySearchLogger.d.ts +26 -0
  165. package/dist/core/utils/fuzzySearchLogger.js +9 -0
  166. package/dist/core/utils/fuzzySearchLogger.js.map +1 -0
  167. package/dist/core/utils/lineEndingHandler.d.ts +21 -0
  168. package/dist/core/utils/lineEndingHandler.js +78 -0
  169. package/dist/core/utils/lineEndingHandler.js.map +1 -0
  170. package/dist/core/utils/logger.d.ts +17 -0
  171. package/dist/core/utils/logger.js +5 -0
  172. package/dist/core/utils/logger.js.map +1 -0
  173. package/dist/core/utils/mcp-ui-ab-test.d.ts +13 -0
  174. package/dist/core/utils/mcp-ui-ab-test.js +63 -0
  175. package/dist/core/utils/mcp-ui-ab-test.js.map +1 -0
  176. package/dist/core/utils/open-browser.d.ts +9 -0
  177. package/dist/core/utils/open-browser.js +47 -0
  178. package/dist/core/utils/open-browser.js.map +1 -0
  179. package/dist/core/utils/process-detection.d.ts +23 -0
  180. package/dist/core/utils/process-detection.js +151 -0
  181. package/dist/core/utils/process-detection.js.map +1 -0
  182. package/dist/core/utils/ripgrep-resolver.d.ts +9 -0
  183. package/dist/core/utils/ripgrep-resolver.js +96 -0
  184. package/dist/core/utils/ripgrep-resolver.js.map +1 -0
  185. package/dist/core/utils/system-info.d.ts +72 -0
  186. package/dist/core/utils/system-info.js +723 -0
  187. package/dist/core/utils/system-info.js.map +1 -0
  188. package/dist/core/utils/toolHistory.d.ts +31 -0
  189. package/dist/core/utils/toolHistory.js +17 -0
  190. package/dist/core/utils/toolHistory.js.map +1 -0
  191. package/dist/core/utils/trackTools.d.ts +1 -0
  192. package/dist/core/utils/trackTools.js +3 -0
  193. package/dist/core/utils/trackTools.js.map +1 -0
  194. package/dist/core/utils/unsupportedParams.d.ts +24 -0
  195. package/dist/core/utils/unsupportedParams.js +67 -0
  196. package/dist/core/utils/unsupportedParams.js.map +1 -0
  197. package/dist/core/utils/usageTracker.d.ts +125 -0
  198. package/dist/core/utils/usageTracker.js +475 -0
  199. package/dist/core/utils/usageTracker.js.map +1 -0
  200. package/dist/core/utils/welcome-onboarding.d.ts +11 -0
  201. package/dist/core/utils/welcome-onboarding.js +100 -0
  202. package/dist/core/utils/welcome-onboarding.js.map +1 -0
  203. package/dist/core/utils/withTimeout.d.ts +28 -0
  204. package/dist/core/utils/withTimeout.js +86 -0
  205. package/dist/core/utils/withTimeout.js.map +1 -0
  206. package/dist/core/version.d.ts +1 -0
  207. package/dist/core/version.js +2 -0
  208. package/dist/core/version.js.map +1 -0
  209. package/dist/dispatcher.d.ts +7 -0
  210. package/dist/dispatcher.js +179 -0
  211. package/dist/dispatcher.js.map +1 -0
  212. package/dist/index.d.ts +6 -0
  213. package/dist/index.js +7 -0
  214. package/dist/index.js.map +1 -0
  215. package/dist/plugins/cli-commands.d.ts +5 -0
  216. package/dist/plugins/cli-commands.js +240 -0
  217. package/dist/plugins/cli-commands.js.map +1 -0
  218. package/dist/plugins/defaults.d.ts +62 -0
  219. package/dist/plugins/defaults.js +260 -0
  220. package/dist/plugins/defaults.js.map +1 -0
  221. package/dist/plugins/first-run.d.ts +16 -0
  222. package/dist/plugins/first-run.js +89 -0
  223. package/dist/plugins/first-run.js.map +1 -0
  224. package/dist/plugins/host.d.ts +20 -0
  225. package/dist/plugins/host.js +175 -0
  226. package/dist/plugins/host.js.map +1 -0
  227. package/dist/plugins/installer.d.ts +21 -0
  228. package/dist/plugins/installer.js +350 -0
  229. package/dist/plugins/installer.js.map +1 -0
  230. package/dist/plugins/locate.d.ts +15 -0
  231. package/dist/plugins/locate.js +99 -0
  232. package/dist/plugins/locate.js.map +1 -0
  233. package/dist/plugins/manager.d.ts +32 -0
  234. package/dist/plugins/manager.js +139 -0
  235. package/dist/plugins/manager.js.map +1 -0
  236. package/dist/plugins/paths.d.ts +32 -0
  237. package/dist/plugins/paths.js +49 -0
  238. package/dist/plugins/paths.js.map +1 -0
  239. package/dist/plugins/python.d.ts +55 -0
  240. package/dist/plugins/python.js +234 -0
  241. package/dist/plugins/python.js.map +1 -0
  242. package/dist/plugins/store.d.ts +12 -0
  243. package/dist/plugins/store.js +76 -0
  244. package/dist/plugins/store.js.map +1 -0
  245. package/dist/plugins/types.d.ts +112 -0
  246. package/dist/plugins/types.js +9 -0
  247. package/dist/plugins/types.js.map +1 -0
  248. package/dist/plugins/util.d.ts +37 -0
  249. package/dist/plugins/util.js +283 -0
  250. package/dist/plugins/util.js.map +1 -0
  251. package/dist/runtime/activity.d.ts +49 -0
  252. package/dist/runtime/activity.js +158 -0
  253. package/dist/runtime/activity.js.map +1 -0
  254. package/dist/runtime/browser-workflow.d.ts +21 -0
  255. package/dist/runtime/browser-workflow.js +51 -0
  256. package/dist/runtime/browser-workflow.js.map +1 -0
  257. package/dist/runtime/code-graph.d.ts +156 -0
  258. package/dist/runtime/code-graph.js +330 -0
  259. package/dist/runtime/code-graph.js.map +1 -0
  260. package/dist/runtime/code-structure.d.ts +53 -0
  261. package/dist/runtime/code-structure.js +152 -0
  262. package/dist/runtime/code-structure.js.map +1 -0
  263. package/dist/runtime/coding-session.d.ts +97 -0
  264. package/dist/runtime/coding-session.js +142 -0
  265. package/dist/runtime/coding-session.js.map +1 -0
  266. package/dist/runtime/docker-client.d.ts +47 -0
  267. package/dist/runtime/docker-client.js +40 -0
  268. package/dist/runtime/docker-client.js.map +1 -0
  269. package/dist/runtime/errors.d.ts +9 -0
  270. package/dist/runtime/errors.js +56 -0
  271. package/dist/runtime/errors.js.map +1 -0
  272. package/dist/runtime/failure-log.d.ts +22 -0
  273. package/dist/runtime/failure-log.js +112 -0
  274. package/dist/runtime/failure-log.js.map +1 -0
  275. package/dist/runtime/fast-batch.d.ts +55 -0
  276. package/dist/runtime/fast-batch.js +104 -0
  277. package/dist/runtime/fast-batch.js.map +1 -0
  278. package/dist/runtime/file-safety.d.ts +7 -0
  279. package/dist/runtime/file-safety.js +134 -0
  280. package/dist/runtime/file-safety.js.map +1 -0
  281. package/dist/runtime/generic-code.d.ts +9 -0
  282. package/dist/runtime/generic-code.js +123 -0
  283. package/dist/runtime/generic-code.js.map +1 -0
  284. package/dist/runtime/graph-outline.d.ts +54 -0
  285. package/dist/runtime/graph-outline.js +118 -0
  286. package/dist/runtime/graph-outline.js.map +1 -0
  287. package/dist/runtime/harness.d.ts +61 -0
  288. package/dist/runtime/harness.js +102 -0
  289. package/dist/runtime/harness.js.map +1 -0
  290. package/dist/runtime/instruction-context.d.ts +23 -0
  291. package/dist/runtime/instruction-context.js +136 -0
  292. package/dist/runtime/instruction-context.js.map +1 -0
  293. package/dist/runtime/lab-mode.d.ts +4 -0
  294. package/dist/runtime/lab-mode.js +18 -0
  295. package/dist/runtime/lab-mode.js.map +1 -0
  296. package/dist/runtime/languages.d.ts +30 -0
  297. package/dist/runtime/languages.js +59 -0
  298. package/dist/runtime/languages.js.map +1 -0
  299. package/dist/runtime/nav-cache.d.ts +2 -0
  300. package/dist/runtime/nav-cache.js +12 -0
  301. package/dist/runtime/nav-cache.js.map +1 -0
  302. package/dist/runtime/operations.d.ts +40 -0
  303. package/dist/runtime/operations.js +86 -0
  304. package/dist/runtime/operations.js.map +1 -0
  305. package/dist/runtime/platform-capabilities.d.ts +20 -0
  306. package/dist/runtime/platform-capabilities.js +36 -0
  307. package/dist/runtime/platform-capabilities.js.map +1 -0
  308. package/dist/runtime/program-runner.d.ts +4 -0
  309. package/dist/runtime/program-runner.js +73 -0
  310. package/dist/runtime/program-runner.js.map +1 -0
  311. package/dist/runtime/project-context.d.ts +53 -0
  312. package/dist/runtime/project-context.js +90 -0
  313. package/dist/runtime/project-context.js.map +1 -0
  314. package/dist/runtime/project-files.d.ts +2 -0
  315. package/dist/runtime/project-files.js +3 -0
  316. package/dist/runtime/project-files.js.map +1 -0
  317. package/dist/runtime/project-index.d.ts +40 -0
  318. package/dist/runtime/project-index.js +158 -0
  319. package/dist/runtime/project-index.js.map +1 -0
  320. package/dist/runtime/resource-limits.d.ts +42 -0
  321. package/dist/runtime/resource-limits.js +50 -0
  322. package/dist/runtime/resource-limits.js.map +1 -0
  323. package/dist/runtime/scratch-budget.d.ts +11 -0
  324. package/dist/runtime/scratch-budget.js +107 -0
  325. package/dist/runtime/scratch-budget.js.map +1 -0
  326. package/dist/runtime/search-diagnostics.d.ts +3 -0
  327. package/dist/runtime/search-diagnostics.js +45 -0
  328. package/dist/runtime/search-diagnostics.js.map +1 -0
  329. package/dist/runtime/toolchains.d.ts +25 -0
  330. package/dist/runtime/toolchains.js +70 -0
  331. package/dist/runtime/toolchains.js.map +1 -0
  332. package/dist/runtime/worker-coordination.d.ts +314 -0
  333. package/dist/runtime/worker-coordination.js +564 -0
  334. package/dist/runtime/worker-coordination.js.map +1 -0
  335. package/dist/runtime/workspace.d.ts +151 -0
  336. package/dist/runtime/workspace.js +267 -0
  337. package/dist/runtime/workspace.js.map +1 -0
  338. package/dist/service.d.ts +3 -0
  339. package/dist/service.js +102 -0
  340. package/dist/service.js.map +1 -0
  341. package/dist/terminal-setup.d.ts +33 -0
  342. package/dist/terminal-setup.js +219 -0
  343. package/dist/terminal-setup.js.map +1 -0
  344. package/dist/terminal-shortcuts.d.ts +22 -0
  345. package/dist/terminal-shortcuts.js +145 -0
  346. package/dist/terminal-shortcuts.js.map +1 -0
  347. package/dist/terminal-ui.d.ts +20 -0
  348. package/dist/terminal-ui.js +53 -0
  349. package/dist/terminal-ui.js.map +1 -0
  350. package/dist/tools/ast-grep.d.ts +132 -0
  351. package/dist/tools/ast-grep.js +625 -0
  352. package/dist/tools/ast-grep.js.map +1 -0
  353. package/dist/tools/brc-tools.d.ts +112 -0
  354. package/dist/tools/brc-tools.js +599 -0
  355. package/dist/tools/brc-tools.js.map +1 -0
  356. package/dist/tools/check-tools.d.ts +4 -0
  357. package/dist/tools/check-tools.js +29 -0
  358. package/dist/tools/check-tools.js.map +1 -0
  359. package/dist/tools/coding-tools.d.ts +33 -0
  360. package/dist/tools/coding-tools.js +190 -0
  361. package/dist/tools/coding-tools.js.map +1 -0
  362. package/dist/tools/command-shell.d.ts +17 -0
  363. package/dist/tools/command-shell.js +84 -0
  364. package/dist/tools/command-shell.js.map +1 -0
  365. package/dist/tools/dev-extras.d.ts +42 -0
  366. package/dist/tools/dev-extras.js +135 -0
  367. package/dist/tools/dev-extras.js.map +1 -0
  368. package/dist/tools/edit-tools.d.ts +4 -0
  369. package/dist/tools/edit-tools.js +293 -0
  370. package/dist/tools/edit-tools.js.map +1 -0
  371. package/dist/tools/fast-exec.d.ts +11 -0
  372. package/dist/tools/fast-exec.js +202 -0
  373. package/dist/tools/fast-exec.js.map +1 -0
  374. package/dist/tools/image-tools.d.ts +37 -0
  375. package/dist/tools/image-tools.js +293 -0
  376. package/dist/tools/image-tools.js.map +1 -0
  377. package/dist/tools/jobs.d.ts +227 -0
  378. package/dist/tools/jobs.js +608 -0
  379. package/dist/tools/jobs.js.map +1 -0
  380. package/dist/tools/ops-tools.d.ts +8 -0
  381. package/dist/tools/ops-tools.js +58 -0
  382. package/dist/tools/ops-tools.js.map +1 -0
  383. package/dist/tools/plugin-tools.d.ts +38 -0
  384. package/dist/tools/plugin-tools.js +133 -0
  385. package/dist/tools/plugin-tools.js.map +1 -0
  386. package/dist/tools/rtk.d.ts +60 -0
  387. package/dist/tools/rtk.js +245 -0
  388. package/dist/tools/rtk.js.map +1 -0
  389. package/dist/tools/sandbox-tools.d.ts +41 -0
  390. package/dist/tools/sandbox-tools.js +146 -0
  391. package/dist/tools/sandbox-tools.js.map +1 -0
  392. package/dist/tools/worker-tools.d.ts +231 -0
  393. package/dist/tools/worker-tools.js +55 -0
  394. package/dist/tools/worker-tools.js.map +1 -0
  395. package/dist/tools/workspace-batch.d.ts +262 -0
  396. package/dist/tools/workspace-batch.js +188 -0
  397. package/dist/tools/workspace-batch.js.map +1 -0
  398. package/dist/transport/pairing.d.ts +22 -0
  399. package/dist/transport/pairing.js +154 -0
  400. package/dist/transport/pairing.js.map +1 -0
  401. package/dist/transport/plugin-admin.d.ts +33 -0
  402. package/dist/transport/plugin-admin.js +156 -0
  403. package/dist/transport/plugin-admin.js.map +1 -0
  404. package/dist/transport/relay-url.d.ts +3 -0
  405. package/dist/transport/relay-url.js +38 -0
  406. package/dist/transport/relay-url.js.map +1 -0
  407. package/dist/transport/result-budget.d.ts +11 -0
  408. package/dist/transport/result-budget.js +45 -0
  409. package/dist/transport/result-budget.js.map +1 -0
  410. package/dist/transport/ws-client.d.ts +64 -0
  411. package/dist/transport/ws-client.js +242 -0
  412. package/dist/transport/ws-client.js.map +1 -0
  413. package/package.json +70 -5
@@ -0,0 +1,62 @@
1
+ import type { PluginRecord, PluginStatus } from './types.js';
2
+ export type DefaultPluginDef = Omit<PluginRecord, 'status'> & {
3
+ status?: PluginStatus;
4
+ };
5
+ export interface DefaultsContext {
6
+ platform: NodeJS.Platform;
7
+ env: NodeJS.ProcessEnv;
8
+ /** Installed browser Playwright should drive (null: Playwright's own Chromium). */
9
+ browser: 'chrome' | 'msedge' | null;
10
+ }
11
+ export declare const DEFAULT_PLUGIN_IDS: readonly ["playwright", "computer-use", "ast-grep", "rtk", "serena", "markitdown"];
12
+ export declare const PINNED: {
13
+ playwright: {
14
+ package: string;
15
+ version: string;
16
+ bin: string;
17
+ };
18
+ computerUse: {
19
+ package: string;
20
+ version: string;
21
+ bin: string;
22
+ };
23
+ astGrep: {
24
+ package: string;
25
+ version: string;
26
+ bin: string;
27
+ };
28
+ serena: {
29
+ package: string;
30
+ version: string;
31
+ command: string;
32
+ };
33
+ markitdown: {
34
+ package: string;
35
+ version: string;
36
+ command: string;
37
+ };
38
+ rtk: {
39
+ version: string;
40
+ };
41
+ };
42
+ /** Google Chrome or Microsoft Edge at their standard install locations (fs checks only). */
43
+ export declare function detectBrowser(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): 'chrome' | 'msedge' | null;
44
+ export declare function hasDisplay(platform: NodeJS.Platform, env: NodeJS.ProcessEnv): boolean;
45
+ export declare function currentDefaultsContext(): DefaultsContext;
46
+ export interface PinnedVersions {
47
+ playwright: string;
48
+ computerUse: string;
49
+ astGrep: string;
50
+ serena: string;
51
+ markitdown: string;
52
+ rtk: {
53
+ version: string;
54
+ sha256: Record<string, string>;
55
+ };
56
+ }
57
+ export declare function pinnedVersions(): PinnedVersions;
58
+ /** The default plugin definitions for this machine (platform rules applied). */
59
+ export declare function defaultPluginDefs(ctx?: DefaultsContext, v?: PinnedVersions): DefaultPluginDef[];
60
+ export declare function defaultPluginDef(id: string, ctx?: DefaultsContext, v?: PinnedVersions): DefaultPluginDef | undefined;
61
+ /** Re-resolve the latest version of every default plugin. */
62
+ export declare function resolveLatestVersions(): Promise<PinnedVersions>;
@@ -0,0 +1,260 @@
1
+ /**
2
+ * BRC default plugins, with exact pinned versions (looked up 2026-11-16):
3
+ *
4
+ * playwright npm @playwright/mcp 0.0.85 (Apache-2.0) browser automation, all platforms
5
+ * computer-use npm computer-use-mcp 1.8.0 (MIT, nut.js fork) screen/mouse/keyboard; disabled on macOS,
6
+ * unsupported on Linux without a display
7
+ * ast-grep binary via npm @ast-grep/cli 0.51.2 (MIT) used by BRC's ast-grep tool
8
+ * rtk binary rtk-oss 1.2.0 from github.com/rtk-ai/rtk used by BRC's rtk tool. The rtk-oss build is
9
+ * fully open source (Apache-2.0/MIT); the standard
10
+ * rtk build bundles a BSL-1.1 engine, so we avoid it
11
+ * serena pypi serena-agent 2.1.0 (oraios, GPL-3.0+) symbol-level code navigation/editing
12
+ * markitdown pypi markitdown-mcp 0.0.1a8 (Microsoft, MIT) Office/PDF/HTML -> Markdown
13
+ *
14
+ * Playwright browser: an installed Google Chrome (--browser chrome) or else Microsoft Edge
15
+ * (--browser msedge), so nothing is downloaded at install time. With neither, it uses Playwright's
16
+ * Chromium, which the AI can fetch on first use with the plugin's browser_install tool; it lands
17
+ * in $BRC_HOME/plugins/ms-playwright (PLAYWRIGHT_BROWSERS_PATH). The browser profile is kept in
18
+ * $BRC_HOME/plugins/playwright-profile, output files in $BRC_HOME/plugins/playwright-output.
19
+ *
20
+ * Serena keeps its own config, logs and memories in ~/.serena (it has no home-dir override for
21
+ * that), the one place a default plugin writes outside $BRC_HOME.
22
+ *
23
+ * rtk sha256 values are the GitHub release asset digests, cross-checked against the release's
24
+ * checksums.txt and re-hashed after downloading.
25
+ */
26
+ import fs from 'node:fs';
27
+ import os from 'node:os';
28
+ import path from 'node:path';
29
+ import { pluginPaths } from './paths.js';
30
+ export const DEFAULT_PLUGIN_IDS = ['playwright', 'computer-use', 'ast-grep', 'rtk', 'serena', 'markitdown'];
31
+ export const PINNED = {
32
+ playwright: { package: '@playwright/mcp', version: '0.0.85', bin: 'playwright-mcp' },
33
+ computerUse: { package: 'computer-use-mcp', version: '1.8.0', bin: 'computer-use-mcp' },
34
+ astGrep: { package: '@ast-grep/cli', version: '0.51.2', bin: 'ast-grep' },
35
+ serena: { package: 'serena-agent', version: '2.1.0', command: 'serena' },
36
+ markitdown: { package: 'markitdown-mcp', version: '0.0.1a8', command: 'markitdown-mcp' },
37
+ rtk: { version: '1.2.0' },
38
+ };
39
+ // rtk-oss: the fully open-source (Apache-2.0/MIT) build. Archives contain rtk(.exe) + LICENSE.
40
+ const RTK_ASSETS = {
41
+ 'win32-x64': 'rtk-oss-x86_64-pc-windows-msvc.zip',
42
+ 'darwin-x64': 'rtk-oss-x86_64-apple-darwin.tar.gz',
43
+ 'darwin-arm64': 'rtk-oss-aarch64-apple-darwin.tar.gz',
44
+ 'linux-x64': 'rtk-oss-x86_64-unknown-linux-musl.tar.gz', // static musl build
45
+ 'linux-arm64': 'rtk-oss-aarch64-unknown-linux-musl.tar.gz',
46
+ };
47
+ // sha256 from the v1.2.0 release's checksums.txt; win32-x64 and linux-x64 re-hashed after download.
48
+ const RTK_SHA256 = {
49
+ 'win32-x64': 'd105aaaa55822252f04ac28989e9069c1ea61755ca561940d887cb0b89c785fc',
50
+ 'darwin-x64': '48f8cee63ae0b4853f9a77d7839e62ffcca18ef88c408f8a93d4e69986b1ab82',
51
+ 'darwin-arm64': '1959bd6d89a729ccdee176b7141490bbe750820f032c74f29a752576f2495254',
52
+ 'linux-x64': 'a28407dc13038bdc9c2a1f5a047b0c636e0c1d495b15523576e2adb992a06a17',
53
+ 'linux-arm64': '9786c61dbbea704e1468ee7060930d3b45b67f79ba2babfb73463e85340628d9',
54
+ };
55
+ function rtkDownloads(version, sha) {
56
+ const out = {};
57
+ for (const [key, asset] of Object.entries(RTK_ASSETS)) {
58
+ if (!sha[key])
59
+ continue;
60
+ out[key] = { url: `https://github.com/rtk-ai/rtk/releases/download/v${version}/${asset}`, sha256: sha[key] };
61
+ }
62
+ return out;
63
+ }
64
+ /** Google Chrome or Microsoft Edge at their standard install locations (fs checks only). */
65
+ export function detectBrowser(platform = process.platform, env = process.env) {
66
+ const exists = (p) => !!p && fs.existsSync(p);
67
+ if (platform === 'win32') {
68
+ const roots = [env.LOCALAPPDATA, env.PROGRAMFILES, env['PROGRAMFILES(X86)'], env.ProgramFiles, env['ProgramFiles(x86)']].filter(Boolean);
69
+ if (roots.some((r) => exists(path.join(r, 'Google', 'Chrome', 'Application', 'chrome.exe'))))
70
+ return 'chrome';
71
+ if (roots.some((r) => exists(path.join(r, 'Microsoft', 'Edge', 'Application', 'msedge.exe'))))
72
+ return 'msedge';
73
+ return null;
74
+ }
75
+ if (platform === 'darwin') {
76
+ const apps = ['/Applications', path.join(os.homedir(), 'Applications')];
77
+ if (apps.some((a) => exists(path.join(a, 'Google Chrome.app', 'Contents', 'MacOS', 'Google Chrome'))))
78
+ return 'chrome';
79
+ if (apps.some((a) => exists(path.join(a, 'Microsoft Edge.app', 'Contents', 'MacOS', 'Microsoft Edge'))))
80
+ return 'msedge';
81
+ return null;
82
+ }
83
+ if (['/opt/google/chrome/chrome', '/usr/bin/google-chrome', '/usr/bin/google-chrome-stable'].some(exists))
84
+ return 'chrome';
85
+ if (['/opt/microsoft/msedge/msedge', '/usr/bin/microsoft-edge', '/usr/bin/microsoft-edge-stable'].some(exists))
86
+ return 'msedge';
87
+ return null;
88
+ }
89
+ export function hasDisplay(platform, env) {
90
+ if (platform !== 'linux')
91
+ return true;
92
+ return !!(env.DISPLAY || env.WAYLAND_DISPLAY);
93
+ }
94
+ export function currentDefaultsContext() {
95
+ return { platform: process.platform, env: process.env, browser: detectBrowser() };
96
+ }
97
+ export function pinnedVersions() {
98
+ return {
99
+ playwright: PINNED.playwright.version,
100
+ computerUse: PINNED.computerUse.version,
101
+ astGrep: PINNED.astGrep.version,
102
+ serena: PINNED.serena.version,
103
+ markitdown: PINNED.markitdown.version,
104
+ rtk: { version: PINNED.rtk.version, sha256: RTK_SHA256 },
105
+ };
106
+ }
107
+ /** The default plugin definitions for this machine (platform rules applied). */
108
+ export function defaultPluginDefs(ctx = currentDefaultsContext(), v = pinnedVersions()) {
109
+ const display = hasDisplay(ctx.platform, ctx.env);
110
+ const pwArgs = [
111
+ '--browser', ctx.browser ?? 'chromium',
112
+ '--user-data-dir', path.join(pluginPaths.root(), 'playwright-profile'),
113
+ // Snapshots/screenshots would otherwise go to <cwd>/.playwright-mcp (System32 for a service).
114
+ '--output-dir', path.join(pluginPaths.root(), 'playwright-output'),
115
+ ];
116
+ if (!display)
117
+ pwArgs.push('--headless');
118
+ const computerUse = {
119
+ id: 'computer-use',
120
+ name: 'Computer use',
121
+ description: 'See the screen and control mouse and keyboard (screenshots, clicks, typing).',
122
+ source: { type: 'npm', package: PINNED.computerUse.package, version: v.computerUse, bin: PINNED.computerUse.bin },
123
+ enabled: ctx.platform !== 'darwin', // macOS needs Screen Recording + Accessibility permission first
124
+ origin: 'default',
125
+ };
126
+ if (!display) {
127
+ computerUse.status = 'unsupported';
128
+ computerUse.error = 'no graphical display on this machine (DISPLAY / WAYLAND_DISPLAY not set)';
129
+ }
130
+ return [
131
+ {
132
+ id: 'playwright',
133
+ name: 'Playwright browser',
134
+ description: 'Drive a web browser: open pages, click, type, read page snapshots, screenshots.',
135
+ source: { type: 'npm', package: PINNED.playwright.package, version: v.playwright, bin: PINNED.playwright.bin, args: pwArgs },
136
+ enabled: true,
137
+ origin: 'default',
138
+ env: { PLAYWRIGHT_BROWSERS_PATH: pluginPaths.playwrightBrowsersDir() },
139
+ },
140
+ computerUse,
141
+ {
142
+ id: 'ast-grep',
143
+ name: 'ast-grep',
144
+ description: 'Structural code search and rewrite (used by BRC\'s ast-grep tool).',
145
+ source: { type: 'binary', binName: 'ast-grep', version: v.astGrep, npmPackage: PINNED.astGrep.package },
146
+ enabled: true,
147
+ origin: 'default',
148
+ },
149
+ {
150
+ id: 'rtk',
151
+ name: 'rtk',
152
+ description: 'Token-saving command output filter (used by BRC\'s rtk tool).',
153
+ source: { type: 'binary', binName: 'rtk', version: v.rtk.version, downloads: rtkDownloads(v.rtk.version, v.rtk.sha256) },
154
+ enabled: true,
155
+ origin: 'default',
156
+ },
157
+ {
158
+ id: 'serena',
159
+ name: 'Serena',
160
+ description: 'Semantic code navigation and editing via language servers (find symbols, references, rename).',
161
+ source: {
162
+ type: 'pypi', package: PINNED.serena.package, version: v.serena, command: PINNED.serena.command,
163
+ // --agent-interface tools: one MCP tool per operation (30 tools) instead of the default
164
+ // Python-REPL interface (3 tools); no dashboard browser tab / GUI log window on the device.
165
+ args: ['start-mcp-server', '--transport', 'stdio', '--context', 'desktop-app', '--agent-interface', 'tools', '--open-web-dashboard', 'false', '--enable-gui-log-window', 'false'],
166
+ },
167
+ enabled: true,
168
+ origin: 'default',
169
+ },
170
+ {
171
+ id: 'markitdown',
172
+ name: 'MarkItDown',
173
+ description: 'Convert files and URLs (PDF, Word, Excel, PowerPoint, HTML, images...) to Markdown.',
174
+ source: { type: 'pypi', package: PINNED.markitdown.package, version: v.markitdown, command: PINNED.markitdown.command },
175
+ enabled: true,
176
+ origin: 'default',
177
+ },
178
+ ];
179
+ }
180
+ export function defaultPluginDef(id, ctx, v) {
181
+ return defaultPluginDefs(ctx, v).find((d) => d.id === id);
182
+ }
183
+ // ---------------------------------------------------------------------------
184
+ // --update-plugins: latest versions (network)
185
+ // ---------------------------------------------------------------------------
186
+ async function getJson(url) {
187
+ const res = await fetch(url, { headers: { accept: 'application/json', 'user-agent': 'brc-agent' }, signal: AbortSignal.timeout(30_000) });
188
+ if (!res.ok)
189
+ throw new Error(`GET ${url}: HTTP ${res.status}`);
190
+ return res.json();
191
+ }
192
+ const npmLatest = async (pkg) => String((await getJson(`https://registry.npmjs.org/${pkg.replace('/', '%2F')}/latest`)).version);
193
+ const pypiLatest = async (pkg) => String((await getJson(`https://pypi.org/pypi/${pkg}/json`)).info.version);
194
+ async function rtkChecksums(version) {
195
+ const sums = {};
196
+ const res = await fetch(`https://github.com/rtk-ai/rtk/releases/download/v${version}/checksums.txt`, { signal: AbortSignal.timeout(30_000) });
197
+ if (!res.ok)
198
+ return sums;
199
+ for (const line of (await res.text()).split(/\r?\n/)) {
200
+ const m = /^([0-9a-f]{64})\s+\*?(\S+)$/.exec(line.trim());
201
+ if (m)
202
+ sums[m[2]] = m[1];
203
+ }
204
+ return sums;
205
+ }
206
+ /**
207
+ * Latest rtk release with sha256 for each platform asset: the GitHub API asset digest,
208
+ * cross-checked with the release's checksums.txt. Without API access (rate limit) the
209
+ * release is found via the /releases/latest redirect and checksums.txt alone is used.
210
+ */
211
+ async function rtkLatest() {
212
+ let version;
213
+ let digests = {};
214
+ try {
215
+ const headers = process.env.GITHUB_TOKEN ? { authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {};
216
+ const res = await fetch('https://api.github.com/repos/rtk-ai/rtk/releases/latest', { headers: { accept: 'application/json', 'user-agent': 'brc-agent', ...headers }, signal: AbortSignal.timeout(30_000) });
217
+ if (!res.ok)
218
+ throw new Error(`HTTP ${res.status}`);
219
+ const rel = (await res.json());
220
+ version = String(rel.tag_name).replace(/^v/, '');
221
+ for (const a of rel.assets)
222
+ if (a.digest?.startsWith('sha256:'))
223
+ digests[a.name] = a.digest.slice(7);
224
+ }
225
+ catch {
226
+ const res = await fetch('https://github.com/rtk-ai/rtk/releases/latest', { redirect: 'manual', signal: AbortSignal.timeout(30_000) });
227
+ const tag = /\/tag\/v?([^/?#]+)/.exec(res.headers.get('location') ?? '')?.[1];
228
+ if (!tag)
229
+ throw new Error('cannot determine the latest rtk release');
230
+ version = tag;
231
+ digests = {};
232
+ }
233
+ const sums = await rtkChecksums(version);
234
+ const sha256 = {};
235
+ for (const [key, name] of Object.entries(RTK_ASSETS)) {
236
+ const digest = digests[name];
237
+ const listed = sums[name];
238
+ if (digest && listed && digest !== listed)
239
+ throw new Error(`rtk ${version}: checksum mismatch for ${name} (digest ${digest}, checksums.txt ${listed})`);
240
+ const sha = digest ?? listed;
241
+ if (sha)
242
+ sha256[key] = sha;
243
+ }
244
+ if (!Object.keys(sha256).length)
245
+ throw new Error(`rtk ${version}: no verifiable assets`);
246
+ return { version, sha256 };
247
+ }
248
+ /** Re-resolve the latest version of every default plugin. */
249
+ export async function resolveLatestVersions() {
250
+ const [playwright, computerUse, astGrep, serena, markitdown, rtk] = await Promise.all([
251
+ npmLatest(PINNED.playwright.package),
252
+ npmLatest(PINNED.computerUse.package),
253
+ npmLatest(PINNED.astGrep.package),
254
+ pypiLatest(PINNED.serena.package),
255
+ pypiLatest(PINNED.markitdown.package),
256
+ rtkLatest(),
257
+ ]);
258
+ return { playwright, computerUse, astGrep, serena, markitdown, rtk };
259
+ }
260
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["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,CAAC,CAAC,MAAM;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,OAAO,wBAAwB,CAAC,CAAC;IACzF,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,qBAAqB;IACzC,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACpF,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;QACpC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC;QACrC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QACjC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;QACjC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC;QACrC,SAAS,EAAE;KACZ,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AACvE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { InstallLog } from './types.js';
2
+ export interface EnsureDefaultsResult {
3
+ /** Why nothing was done (e.g. "BRC_PLUGINS=none"). */
4
+ skipped?: string;
5
+ firstRun: boolean;
6
+ /** Plugins defined by this call (first run only). */
7
+ defined: string[];
8
+ /** Plugins queued for (re)installation. */
9
+ queued: string[];
10
+ /** Resolves when all queued installs have finished (never rejects). */
11
+ done: Promise<void>;
12
+ }
13
+ export interface EnsureDefaultsOptions {
14
+ concurrency?: number;
15
+ }
16
+ export declare function ensureDefaultPlugins(log?: InstallLog, opts?: EnsureDefaultsOptions): Promise<EnsureDefaultsResult>;
@@ -0,0 +1,89 @@
1
+ /**
2
+ * BRC plugins: default plugin set-up at agent start.
3
+ *
4
+ * First start (no firstRunAt in plugins.json): define the default plugins for this platform and
5
+ * install them in the background (2 at a time), then record firstRunAt.
6
+ *
7
+ * Later starts: no network and no probing - only plugins.json plus an existence check of each
8
+ * installed plugin's main executable. Re-installs only what is missing on disk, failed, or left
9
+ * pending/installing by an interrupted run. needs-user plugins get one cheap "is Python there
10
+ * now?" check per start; a default plugin marked unsupported for lack of a display is retried
11
+ * when a display appears.
12
+ *
13
+ * Skipped entirely with BRC_PLUGINS=none (cli.ts also skips it for --no-plugins).
14
+ */
15
+ import { currentDefaultsContext, defaultPluginDefs, hasDisplay } from './defaults.js';
16
+ import { pluginFilesPresent } from './locate.js';
17
+ import { definePlugin, installPlugin } from './manager.js';
18
+ import { pythonAvailableNow } from './python.js';
19
+ import { loadPlugins, patchPlugin, updatePlugins } from './store.js';
20
+ /** Does an installed / interrupted plugin need (re)installing? Filesystem checks only. */
21
+ function needsRepair(rec) {
22
+ switch (rec.status) {
23
+ case 'pending':
24
+ case 'installing':
25
+ case 'failed':
26
+ return true;
27
+ case 'installed':
28
+ return !pluginFilesPresent(rec);
29
+ default:
30
+ return false; // needs-user / unsupported are handled separately
31
+ }
32
+ }
33
+ function runQueue(ids, concurrency, log) {
34
+ const queue = [...ids];
35
+ const worker = async () => {
36
+ for (let id = queue.shift(); id; id = queue.shift()) {
37
+ try {
38
+ await installPlugin(id, log);
39
+ }
40
+ catch (e) {
41
+ log('warn', `plugin ${id}: ${e instanceof Error ? e.message : String(e)}`);
42
+ }
43
+ }
44
+ };
45
+ return Promise.all(Array.from({ length: Math.max(1, Math.min(concurrency, ids.length)) }, worker)).then(() => { });
46
+ }
47
+ export async function ensureDefaultPlugins(log = () => { }, opts = {}) {
48
+ if ((process.env.BRC_PLUGINS ?? '').toLowerCase() === 'none') {
49
+ return { skipped: 'BRC_PLUGINS=none', firstRun: false, defined: [], queued: [], done: Promise.resolve() };
50
+ }
51
+ const concurrency = opts.concurrency ?? 2;
52
+ const state = loadPlugins();
53
+ const firstRun = !state.firstRunAt;
54
+ const defined = [];
55
+ if (firstRun) {
56
+ for (const def of defaultPluginDefs(currentDefaultsContext())) {
57
+ if (state.plugins[def.id])
58
+ continue; // keep whatever the user or an interrupted run left
59
+ await definePlugin(def);
60
+ defined.push(def.id);
61
+ }
62
+ }
63
+ const records = Object.values(loadPlugins().plugins);
64
+ const queued = records.filter(needsRepair).map((r) => r.id);
65
+ // Default plugins marked unsupported only because there was no display: retry when one exists.
66
+ for (const rec of records) {
67
+ if (rec.status === 'unsupported' && rec.origin === 'default' && /no graphical display/.test(rec.error ?? '') && hasDisplay(process.platform, process.env)) {
68
+ await patchPlugin(rec.id, { status: 'pending', error: undefined });
69
+ queued.push(rec.id);
70
+ }
71
+ }
72
+ // needs-user (Python missing): one cheap check per start.
73
+ const waiting = records.filter((r) => r.status === 'needs-user');
74
+ if (waiting.some((r) => r.source.type === 'pypi') && (await pythonAvailableNow())) {
75
+ for (const r of waiting)
76
+ if (r.source.type === 'pypi')
77
+ queued.push(r.id);
78
+ }
79
+ if (queued.length)
80
+ log('info', `plugins: installing ${queued.join(', ')} in the background`);
81
+ const done = runQueue(queued, concurrency, log)
82
+ .then(async () => {
83
+ if (firstRun)
84
+ await updatePlugins((s) => { s.firstRunAt = new Date().toISOString(); });
85
+ })
86
+ .catch((e) => log('warn', `plugin set-up: ${e instanceof Error ? e.message : String(e)}`));
87
+ return { firstRun, defined, queued, done };
88
+ }
89
+ //# sourceMappingURL=first-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-run.js","sourceRoot":"","sources":["../../../packages/agent/src/plugins/first-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACtF,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,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,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACzF,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC7F,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { PluginRecord, PluginToolInfo } from './types.js';
2
+ export interface LaunchSpec {
3
+ command: string;
4
+ args: string[];
5
+ env: Record<string, string>;
6
+ cwd?: string;
7
+ }
8
+ /** How to start a plugin's MCP server. Throws if the source is not launchable as MCP. */
9
+ export declare function resolveLaunch(rec: PluginRecord): LaunchSpec;
10
+ /** Tools offered by a plugin. Uses the cache unless refresh=true (or nothing is cached). */
11
+ export declare function getPluginTools(id: string, refresh?: boolean): Promise<PluginToolInfo[]>;
12
+ export interface PluginCallResult {
13
+ content: Array<Record<string, unknown>>;
14
+ isError?: boolean;
15
+ }
16
+ /** Call one tool of a plugin. Reconnects once if the plugin process had died. */
17
+ export declare function callPluginTool(id: string, tool: string, args: Record<string, unknown>): Promise<PluginCallResult>;
18
+ export declare function stopPlugin(id: string): Promise<void>;
19
+ export declare function stopAllPlugins(): Promise<void>;
20
+ export declare function runningPluginIds(): string[];
@@ -0,0 +1,175 @@
1
+ /**
2
+ * BRC plugin host: runs installed MCP servers on this device and calls their tools.
3
+ *
4
+ * - Lazy: a plugin process starts the first time one of its tools is listed or called,
5
+ * then stays running for later calls (agent start-up cost is unchanged).
6
+ * - Self-healing: if the process exits or the connection breaks, the next call reconnects.
7
+ * - Idle plugins are stopped after BRC_PLUGIN_IDLE_MS (default 30 min) to free memory.
8
+ * - Tool lists are cached in plugins.json after the first start.
9
+ */
10
+ import fs from 'node:fs';
11
+ import path from 'node:path';
12
+ const loadSdk = async () => {
13
+ const [{ Client }, { StdioClientTransport }, { StreamableHTTPClientTransport }] = await Promise.all([
14
+ import('@modelcontextprotocol/sdk/client/index.js'),
15
+ import('@modelcontextprotocol/sdk/client/stdio.js'),
16
+ import('@modelcontextprotocol/sdk/client/streamableHttp.js'),
17
+ ]);
18
+ return { Client, StdioClientTransport, StreamableHTTPClientTransport };
19
+ };
20
+ import { exeName, pluginPaths, uvEnv } from './paths.js';
21
+ import { getPlugin, patchPlugin } from './store.js';
22
+ const START_TIMEOUT_MS = Number(process.env.BRC_PLUGIN_START_TIMEOUT_MS) || 60_000;
23
+ const IDLE_MS = Number(process.env.BRC_PLUGIN_IDLE_MS) || 30 * 60_000;
24
+ const CALL_TIMEOUT_MS = 105_000; // below the relay's 120 s per-call timeout
25
+ /** How to start a plugin's MCP server. Throws if the source is not launchable as MCP. */
26
+ export function resolveLaunch(rec) {
27
+ const env = {};
28
+ for (const [k, v] of Object.entries(process.env))
29
+ if (typeof v === 'string')
30
+ env[k] = v;
31
+ Object.assign(env, rec.env ?? {});
32
+ const s = rec.source;
33
+ switch (s.type) {
34
+ case 'npm': {
35
+ const bin = s.bin ?? s.package.replace(/^@[^/]+\//, '');
36
+ const shim = path.join(pluginPaths.npmBinDir(), exeName(bin, 'npm-shim'));
37
+ return { command: shim, args: s.args ?? [], env };
38
+ }
39
+ case 'pypi': {
40
+ const cmd = s.command ?? s.package;
41
+ const exe = path.join(pluginPaths.uvBinDir(), exeName(cmd));
42
+ return { command: exe, args: s.args ?? [], env: { ...env, ...uvEnv() } };
43
+ }
44
+ case 'command':
45
+ return { command: s.command, args: s.args ?? [], env, cwd: s.cwd };
46
+ default:
47
+ throw new Error(`plugin "${rec.id}" (${s.type}) is not a local MCP server`);
48
+ }
49
+ }
50
+ const running = new Map();
51
+ const starting = new Map();
52
+ function withTimeout(p, ms, what) {
53
+ let t;
54
+ return Promise.race([
55
+ p.finally(() => clearTimeout(t)),
56
+ new Promise((_, rej) => { t = setTimeout(() => rej(new Error(`${what} timed out after ${ms} ms`)), ms); t.unref?.(); }),
57
+ ]);
58
+ }
59
+ function armIdle(id, r) {
60
+ if (r.idleTimer)
61
+ clearTimeout(r.idleTimer);
62
+ r.idleTimer = setTimeout(() => { void stopPlugin(id); }, IDLE_MS);
63
+ r.idleTimer.unref?.();
64
+ }
65
+ async function start(rec) {
66
+ const { Client, StdioClientTransport, StreamableHTTPClientTransport } = await loadSdk();
67
+ let transport;
68
+ if (rec.source.type === 'remote') {
69
+ transport = new StreamableHTTPClientTransport(new URL(rec.source.url), {
70
+ requestInit: rec.source.headers ? { headers: rec.source.headers } : undefined,
71
+ });
72
+ }
73
+ else {
74
+ const spec = resolveLaunch(rec);
75
+ if (!path.isAbsolute(spec.command) || fs.existsSync(spec.command)) {
76
+ // ok: absolute path that exists, or a bare command resolved from PATH by the OS
77
+ }
78
+ else {
79
+ throw new Error(`plugin "${rec.id}" is not installed (missing ${spec.command})`);
80
+ }
81
+ fs.mkdirSync(pluginPaths.logDir(), { recursive: true });
82
+ const stdio = new StdioClientTransport({ command: spec.command, args: spec.args, env: spec.env, cwd: spec.cwd, stderr: 'pipe' });
83
+ // Keep the plugin's stderr in a log file (useful for "why did it fail").
84
+ const logStream = fs.createWriteStream(path.join(pluginPaths.logDir(), `${rec.id}.log`), { flags: 'a' });
85
+ stdio.stderr?.pipe(logStream);
86
+ transport = stdio;
87
+ }
88
+ const client = new Client({ name: 'brc-agent', version: '2' }, { capabilities: {} });
89
+ const r = { client, transport, lastUsed: Date.now(), closed: false };
90
+ transport.onclose = () => { r.closed = true; if (running.get(rec.id) === r)
91
+ running.delete(rec.id); };
92
+ try {
93
+ await withTimeout(client.connect(transport), START_TIMEOUT_MS, `starting plugin "${rec.id}"`);
94
+ }
95
+ catch (e) {
96
+ try {
97
+ await client.close();
98
+ }
99
+ catch { /* ignore */ }
100
+ throw e;
101
+ }
102
+ return r;
103
+ }
104
+ async function ensureRunning(id) {
105
+ const live = running.get(id);
106
+ if (live && !live.closed)
107
+ return live;
108
+ const pending = starting.get(id);
109
+ if (pending)
110
+ return pending;
111
+ const rec = getPlugin(id);
112
+ if (!rec)
113
+ throw new Error(`unknown plugin "${id}"`);
114
+ if (!rec.enabled)
115
+ throw new Error(`plugin "${id}" is disabled`);
116
+ if (rec.status !== 'installed') {
117
+ throw new Error(`plugin "${id}" is not ready (status: ${rec.status}${rec.error ? `: ${rec.error}` : ''}${rec.userAction ? `; to fix: ${rec.userAction}` : ''})`);
118
+ }
119
+ if (rec.source.type === 'binary')
120
+ throw new Error(`plugin "${id}" is a program used by BRC tools, not an MCP server`);
121
+ const p = start(rec).then((r) => { running.set(id, r); armIdle(id, r); return r; }).finally(() => starting.delete(id));
122
+ starting.set(id, p);
123
+ return p;
124
+ }
125
+ /** Tools offered by a plugin. Uses the cache unless refresh=true (or nothing is cached). */
126
+ export async function getPluginTools(id, refresh = false) {
127
+ const rec = getPlugin(id);
128
+ if (!refresh && rec?.toolsCache?.length)
129
+ return rec.toolsCache;
130
+ const r = await ensureRunning(id);
131
+ const res = await withTimeout(r.client.listTools(), START_TIMEOUT_MS, `listing tools of "${id}"`);
132
+ const tools = res.tools.map((t) => ({ name: t.name, description: t.description, inputSchema: t.inputSchema }));
133
+ r.tools = tools;
134
+ r.lastUsed = Date.now();
135
+ armIdle(id, r);
136
+ await patchPlugin(id, { toolsCache: tools, toolsCachedAt: new Date().toISOString() });
137
+ return tools;
138
+ }
139
+ /** Call one tool of a plugin. Reconnects once if the plugin process had died. */
140
+ export async function callPluginTool(id, tool, args) {
141
+ for (let attempt = 0; attempt < 2; attempt++) {
142
+ const r = await ensureRunning(id);
143
+ try {
144
+ r.lastUsed = Date.now();
145
+ armIdle(id, r);
146
+ const res = await r.client.callTool({ name: tool, arguments: args }, undefined, { timeout: CALL_TIMEOUT_MS });
147
+ return { content: res.content ?? [], isError: !!res.isError };
148
+ }
149
+ catch (e) {
150
+ if (r.closed && attempt === 0)
151
+ continue; // process died mid-call: restart once
152
+ throw e;
153
+ }
154
+ }
155
+ throw new Error(`plugin "${id}" could not be reached`);
156
+ }
157
+ export async function stopPlugin(id) {
158
+ const r = running.get(id);
159
+ running.delete(id);
160
+ if (!r)
161
+ return;
162
+ if (r.idleTimer)
163
+ clearTimeout(r.idleTimer);
164
+ try {
165
+ await r.client.close();
166
+ }
167
+ catch { /* ignore */ }
168
+ }
169
+ export async function stopAllPlugins() {
170
+ await Promise.all([...running.keys()].map((id) => stopPlugin(id)));
171
+ }
172
+ export function runningPluginIds() {
173
+ return [...running.keys()];
174
+ }
175
+ //# sourceMappingURL=host.js.map