@swarmify/agents-cli 1.13.4 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (567) hide show
  1. package/README.md +2 -319
  2. package/bin/agents.js +2 -0
  3. package/package.json +13 -79
  4. package/scripts/postinstall.js +4 -71
  5. package/CHANGELOG.md +0 -316
  6. package/LICENSE +0 -21
  7. package/dist/commands/__tests__/sessions-tail.test.d.ts +0 -2
  8. package/dist/commands/__tests__/sessions-tail.test.d.ts.map +0 -1
  9. package/dist/commands/__tests__/sessions-tail.test.js +0 -108
  10. package/dist/commands/__tests__/sessions-tail.test.js.map +0 -1
  11. package/dist/commands/__tests__/sessions.test.d.ts +0 -2
  12. package/dist/commands/__tests__/sessions.test.d.ts.map +0 -1
  13. package/dist/commands/__tests__/sessions.test.js +0 -636
  14. package/dist/commands/__tests__/sessions.test.js.map +0 -1
  15. package/dist/commands/cloud.d.ts +0 -11
  16. package/dist/commands/cloud.d.ts.map +0 -1
  17. package/dist/commands/cloud.js +0 -363
  18. package/dist/commands/cloud.js.map +0 -1
  19. package/dist/commands/commands.d.ts +0 -12
  20. package/dist/commands/commands.d.ts.map +0 -1
  21. package/dist/commands/commands.js +0 -629
  22. package/dist/commands/commands.js.map +0 -1
  23. package/dist/commands/daemon.d.ts +0 -11
  24. package/dist/commands/daemon.d.ts.map +0 -1
  25. package/dist/commands/daemon.js +0 -119
  26. package/dist/commands/daemon.js.map +0 -1
  27. package/dist/commands/drive.d.ts +0 -11
  28. package/dist/commands/drive.d.ts.map +0 -1
  29. package/dist/commands/drive.js +0 -175
  30. package/dist/commands/drive.js.map +0 -1
  31. package/dist/commands/exec.d.ts +0 -11
  32. package/dist/commands/exec.d.ts.map +0 -1
  33. package/dist/commands/exec.js +0 -251
  34. package/dist/commands/exec.js.map +0 -1
  35. package/dist/commands/factory.d.ts +0 -11
  36. package/dist/commands/factory.d.ts.map +0 -1
  37. package/dist/commands/factory.js +0 -445
  38. package/dist/commands/factory.js.map +0 -1
  39. package/dist/commands/fork.d.ts +0 -11
  40. package/dist/commands/fork.d.ts.map +0 -1
  41. package/dist/commands/fork.js +0 -147
  42. package/dist/commands/fork.js.map +0 -1
  43. package/dist/commands/hooks.d.ts +0 -12
  44. package/dist/commands/hooks.d.ts.map +0 -1
  45. package/dist/commands/hooks.js +0 -690
  46. package/dist/commands/hooks.js.map +0 -1
  47. package/dist/commands/init.d.ts +0 -15
  48. package/dist/commands/init.d.ts.map +0 -1
  49. package/dist/commands/init.js +0 -137
  50. package/dist/commands/init.js.map +0 -1
  51. package/dist/commands/mcp.d.ts +0 -12
  52. package/dist/commands/mcp.d.ts.map +0 -1
  53. package/dist/commands/mcp.js +0 -583
  54. package/dist/commands/mcp.js.map +0 -1
  55. package/dist/commands/models.d.ts +0 -11
  56. package/dist/commands/models.d.ts.map +0 -1
  57. package/dist/commands/models.js +0 -170
  58. package/dist/commands/models.js.map +0 -1
  59. package/dist/commands/packages.d.ts +0 -11
  60. package/dist/commands/packages.d.ts.map +0 -1
  61. package/dist/commands/packages.js +0 -551
  62. package/dist/commands/packages.js.map +0 -1
  63. package/dist/commands/permissions.d.ts +0 -12
  64. package/dist/commands/permissions.d.ts.map +0 -1
  65. package/dist/commands/permissions.js +0 -724
  66. package/dist/commands/permissions.js.map +0 -1
  67. package/dist/commands/plugins.d.ts +0 -11
  68. package/dist/commands/plugins.d.ts.map +0 -1
  69. package/dist/commands/plugins.js +0 -393
  70. package/dist/commands/plugins.js.map +0 -1
  71. package/dist/commands/profiles.d.ts +0 -12
  72. package/dist/commands/profiles.d.ts.map +0 -1
  73. package/dist/commands/profiles.js +0 -255
  74. package/dist/commands/profiles.js.map +0 -1
  75. package/dist/commands/pty.d.ts +0 -21
  76. package/dist/commands/pty.d.ts.map +0 -1
  77. package/dist/commands/pty.js +0 -391
  78. package/dist/commands/pty.js.map +0 -1
  79. package/dist/commands/pull.d.ts +0 -11
  80. package/dist/commands/pull.d.ts.map +0 -1
  81. package/dist/commands/pull.js +0 -456
  82. package/dist/commands/pull.js.map +0 -1
  83. package/dist/commands/push.d.ts +0 -11
  84. package/dist/commands/push.d.ts.map +0 -1
  85. package/dist/commands/push.js +0 -188
  86. package/dist/commands/push.js.map +0 -1
  87. package/dist/commands/refresh-memory.d.ts +0 -16
  88. package/dist/commands/refresh-memory.d.ts.map +0 -1
  89. package/dist/commands/refresh-memory.js +0 -52
  90. package/dist/commands/refresh-memory.js.map +0 -1
  91. package/dist/commands/resource-view.d.ts +0 -39
  92. package/dist/commands/resource-view.d.ts.map +0 -1
  93. package/dist/commands/resource-view.js +0 -197
  94. package/dist/commands/resource-view.js.map +0 -1
  95. package/dist/commands/routines.d.ts +0 -11
  96. package/dist/commands/routines.d.ts.map +0 -1
  97. package/dist/commands/routines.js +0 -590
  98. package/dist/commands/routines.js.map +0 -1
  99. package/dist/commands/rules.d.ts +0 -12
  100. package/dist/commands/rules.d.ts.map +0 -1
  101. package/dist/commands/rules.js +0 -489
  102. package/dist/commands/rules.js.map +0 -1
  103. package/dist/commands/secrets.d.ts +0 -11
  104. package/dist/commands/secrets.d.ts.map +0 -1
  105. package/dist/commands/secrets.js +0 -352
  106. package/dist/commands/secrets.js.map +0 -1
  107. package/dist/commands/sessions-picker.d.ts +0 -18
  108. package/dist/commands/sessions-picker.d.ts.map +0 -1
  109. package/dist/commands/sessions-picker.js +0 -265
  110. package/dist/commands/sessions-picker.js.map +0 -1
  111. package/dist/commands/sessions-tail.d.ts +0 -20
  112. package/dist/commands/sessions-tail.d.ts.map +0 -1
  113. package/dist/commands/sessions-tail.js +0 -236
  114. package/dist/commands/sessions-tail.js.map +0 -1
  115. package/dist/commands/sessions.d.ts +0 -18
  116. package/dist/commands/sessions.d.ts.map +0 -1
  117. package/dist/commands/sessions.js +0 -1173
  118. package/dist/commands/sessions.js.map +0 -1
  119. package/dist/commands/skills.d.ts +0 -12
  120. package/dist/commands/skills.d.ts.map +0 -1
  121. package/dist/commands/skills.js +0 -717
  122. package/dist/commands/skills.js.map +0 -1
  123. package/dist/commands/status.d.ts +0 -10
  124. package/dist/commands/status.d.ts.map +0 -1
  125. package/dist/commands/status.js +0 -26
  126. package/dist/commands/status.js.map +0 -1
  127. package/dist/commands/subagents.d.ts +0 -11
  128. package/dist/commands/subagents.d.ts.map +0 -1
  129. package/dist/commands/subagents.js +0 -361
  130. package/dist/commands/subagents.js.map +0 -1
  131. package/dist/commands/sync.d.ts +0 -11
  132. package/dist/commands/sync.d.ts.map +0 -1
  133. package/dist/commands/sync.js +0 -70
  134. package/dist/commands/sync.js.map +0 -1
  135. package/dist/commands/teams-picker.d.ts +0 -18
  136. package/dist/commands/teams-picker.d.ts.map +0 -1
  137. package/dist/commands/teams-picker.js +0 -290
  138. package/dist/commands/teams-picker.js.map +0 -1
  139. package/dist/commands/teams.d.ts +0 -18
  140. package/dist/commands/teams.d.ts.map +0 -1
  141. package/dist/commands/teams.js +0 -1144
  142. package/dist/commands/teams.js.map +0 -1
  143. package/dist/commands/utils.d.ts +0 -45
  144. package/dist/commands/utils.d.ts.map +0 -1
  145. package/dist/commands/utils.js +0 -106
  146. package/dist/commands/utils.js.map +0 -1
  147. package/dist/commands/versions.d.ts +0 -11
  148. package/dist/commands/versions.d.ts.map +0 -1
  149. package/dist/commands/versions.js +0 -701
  150. package/dist/commands/versions.js.map +0 -1
  151. package/dist/commands/view.d.ts +0 -43
  152. package/dist/commands/view.d.ts.map +0 -1
  153. package/dist/commands/view.js +0 -894
  154. package/dist/commands/view.js.map +0 -1
  155. package/dist/index.d.ts +0 -9
  156. package/dist/index.d.ts.map +0 -1
  157. package/dist/index.js +0 -496
  158. package/dist/index.js.map +0 -1
  159. package/dist/lib/__tests__/bugfixes.test.d.ts +0 -2
  160. package/dist/lib/__tests__/bugfixes.test.d.ts.map +0 -1
  161. package/dist/lib/__tests__/bugfixes.test.js +0 -192
  162. package/dist/lib/__tests__/bugfixes.test.js.map +0 -1
  163. package/dist/lib/__tests__/exec.test.d.ts +0 -2
  164. package/dist/lib/__tests__/exec.test.d.ts.map +0 -1
  165. package/dist/lib/__tests__/exec.test.js +0 -446
  166. package/dist/lib/__tests__/exec.test.js.map +0 -1
  167. package/dist/lib/__tests__/git-sync.test.d.ts +0 -2
  168. package/dist/lib/__tests__/git-sync.test.d.ts.map +0 -1
  169. package/dist/lib/__tests__/git-sync.test.js +0 -138
  170. package/dist/lib/__tests__/git-sync.test.js.map +0 -1
  171. package/dist/lib/__tests__/hooks.test.d.ts +0 -2
  172. package/dist/lib/__tests__/hooks.test.d.ts.map +0 -1
  173. package/dist/lib/__tests__/hooks.test.js +0 -203
  174. package/dist/lib/__tests__/hooks.test.js.map +0 -1
  175. package/dist/lib/__tests__/memory-compile.test.d.ts +0 -2
  176. package/dist/lib/__tests__/memory-compile.test.d.ts.map +0 -1
  177. package/dist/lib/__tests__/memory-compile.test.js +0 -95
  178. package/dist/lib/__tests__/memory-compile.test.js.map +0 -1
  179. package/dist/lib/__tests__/models.test.d.ts +0 -2
  180. package/dist/lib/__tests__/models.test.d.ts.map +0 -1
  181. package/dist/lib/__tests__/models.test.js +0 -239
  182. package/dist/lib/__tests__/models.test.js.map +0 -1
  183. package/dist/lib/__tests__/rotate.test.d.ts +0 -2
  184. package/dist/lib/__tests__/rotate.test.d.ts.map +0 -1
  185. package/dist/lib/__tests__/rotate.test.js +0 -80
  186. package/dist/lib/__tests__/rotate.test.js.map +0 -1
  187. package/dist/lib/__tests__/secrets-bundles.test.d.ts +0 -2
  188. package/dist/lib/__tests__/secrets-bundles.test.d.ts.map +0 -1
  189. package/dist/lib/__tests__/secrets-bundles.test.js +0 -104
  190. package/dist/lib/__tests__/secrets-bundles.test.js.map +0 -1
  191. package/dist/lib/__tests__/secrets.test.d.ts +0 -2
  192. package/dist/lib/__tests__/secrets.test.d.ts.map +0 -1
  193. package/dist/lib/__tests__/secrets.test.js +0 -90
  194. package/dist/lib/__tests__/secrets.test.js.map +0 -1
  195. package/dist/lib/__tests__/shims.test.d.ts +0 -2
  196. package/dist/lib/__tests__/shims.test.d.ts.map +0 -1
  197. package/dist/lib/__tests__/shims.test.js +0 -57
  198. package/dist/lib/__tests__/shims.test.js.map +0 -1
  199. package/dist/lib/__tests__/usage.test.d.ts +0 -2
  200. package/dist/lib/__tests__/usage.test.d.ts.map +0 -1
  201. package/dist/lib/__tests__/usage.test.js +0 -220
  202. package/dist/lib/__tests__/usage.test.js.map +0 -1
  203. package/dist/lib/__tests__/versions.test.d.ts +0 -2
  204. package/dist/lib/__tests__/versions.test.d.ts.map +0 -1
  205. package/dist/lib/__tests__/versions.test.js +0 -63
  206. package/dist/lib/__tests__/versions.test.js.map +0 -1
  207. package/dist/lib/agents.d.ts +0 -158
  208. package/dist/lib/agents.d.ts.map +0 -1
  209. package/dist/lib/agents.js +0 -1159
  210. package/dist/lib/agents.js.map +0 -1
  211. package/dist/lib/artifact-actions.d.ts +0 -27
  212. package/dist/lib/artifact-actions.d.ts.map +0 -1
  213. package/dist/lib/artifact-actions.js +0 -58
  214. package/dist/lib/artifact-actions.js.map +0 -1
  215. package/dist/lib/cloud/codex.d.ts +0 -26
  216. package/dist/lib/cloud/codex.d.ts.map +0 -1
  217. package/dist/lib/cloud/codex.js +0 -237
  218. package/dist/lib/cloud/codex.js.map +0 -1
  219. package/dist/lib/cloud/factory.d.ts +0 -32
  220. package/dist/lib/cloud/factory.d.ts.map +0 -1
  221. package/dist/lib/cloud/factory.js +0 -43
  222. package/dist/lib/cloud/factory.js.map +0 -1
  223. package/dist/lib/cloud/registry.d.ts +0 -16
  224. package/dist/lib/cloud/registry.d.ts.map +0 -1
  225. package/dist/lib/cloud/registry.js +0 -68
  226. package/dist/lib/cloud/registry.js.map +0 -1
  227. package/dist/lib/cloud/rush.d.ts +0 -37
  228. package/dist/lib/cloud/rush.d.ts.map +0 -1
  229. package/dist/lib/cloud/rush.js +0 -230
  230. package/dist/lib/cloud/rush.js.map +0 -1
  231. package/dist/lib/cloud/rush.test.d.ts +0 -2
  232. package/dist/lib/cloud/rush.test.d.ts.map +0 -1
  233. package/dist/lib/cloud/rush.test.js +0 -63
  234. package/dist/lib/cloud/rush.test.js.map +0 -1
  235. package/dist/lib/cloud/store.d.ts +0 -23
  236. package/dist/lib/cloud/store.d.ts.map +0 -1
  237. package/dist/lib/cloud/store.js +0 -116
  238. package/dist/lib/cloud/store.js.map +0 -1
  239. package/dist/lib/cloud/stream.d.ts +0 -24
  240. package/dist/lib/cloud/stream.d.ts.map +0 -1
  241. package/dist/lib/cloud/stream.js +0 -145
  242. package/dist/lib/cloud/stream.js.map +0 -1
  243. package/dist/lib/cloud/types.d.ts +0 -109
  244. package/dist/lib/cloud/types.d.ts.map +0 -1
  245. package/dist/lib/cloud/types.js +0 -33
  246. package/dist/lib/cloud/types.js.map +0 -1
  247. package/dist/lib/cloud/types.test.d.ts +0 -2
  248. package/dist/lib/cloud/types.test.d.ts.map +0 -1
  249. package/dist/lib/cloud/types.test.js +0 -41
  250. package/dist/lib/cloud/types.test.js.map +0 -1
  251. package/dist/lib/commands.d.ts +0 -141
  252. package/dist/lib/commands.d.ts.map +0 -1
  253. package/dist/lib/commands.js +0 -514
  254. package/dist/lib/commands.js.map +0 -1
  255. package/dist/lib/convert.d.ts +0 -21
  256. package/dist/lib/convert.d.ts.map +0 -1
  257. package/dist/lib/convert.js +0 -54
  258. package/dist/lib/convert.js.map +0 -1
  259. package/dist/lib/daemon.d.ts +0 -43
  260. package/dist/lib/daemon.d.ts.map +0 -1
  261. package/dist/lib/daemon.js +0 -332
  262. package/dist/lib/daemon.js.map +0 -1
  263. package/dist/lib/drive-sync.d.ts +0 -46
  264. package/dist/lib/drive-sync.d.ts.map +0 -1
  265. package/dist/lib/drive-sync.js +0 -209
  266. package/dist/lib/drive-sync.js.map +0 -1
  267. package/dist/lib/exec.d.ts +0 -101
  268. package/dist/lib/exec.d.ts.map +0 -1
  269. package/dist/lib/exec.js +0 -450
  270. package/dist/lib/exec.js.map +0 -1
  271. package/dist/lib/factory/__tests__/config.test.d.ts +0 -2
  272. package/dist/lib/factory/__tests__/config.test.d.ts.map +0 -1
  273. package/dist/lib/factory/__tests__/config.test.js +0 -128
  274. package/dist/lib/factory/__tests__/config.test.js.map +0 -1
  275. package/dist/lib/factory/config.d.ts +0 -49
  276. package/dist/lib/factory/config.d.ts.map +0 -1
  277. package/dist/lib/factory/config.js +0 -127
  278. package/dist/lib/factory/config.js.map +0 -1
  279. package/dist/lib/factory.d.ts +0 -57
  280. package/dist/lib/factory.d.ts.map +0 -1
  281. package/dist/lib/factory.js +0 -107
  282. package/dist/lib/factory.js.map +0 -1
  283. package/dist/lib/git.d.ts +0 -157
  284. package/dist/lib/git.d.ts.map +0 -1
  285. package/dist/lib/git.js +0 -647
  286. package/dist/lib/git.js.map +0 -1
  287. package/dist/lib/help.d.ts +0 -10
  288. package/dist/lib/help.d.ts.map +0 -1
  289. package/dist/lib/help.js +0 -66
  290. package/dist/lib/help.js.map +0 -1
  291. package/dist/lib/hooks.d.ts +0 -125
  292. package/dist/lib/hooks.d.ts.map +0 -1
  293. package/dist/lib/hooks.js +0 -846
  294. package/dist/lib/hooks.js.map +0 -1
  295. package/dist/lib/ledger/__tests__/local.test.d.ts +0 -2
  296. package/dist/lib/ledger/__tests__/local.test.d.ts.map +0 -1
  297. package/dist/lib/ledger/__tests__/local.test.js +0 -177
  298. package/dist/lib/ledger/__tests__/local.test.js.map +0 -1
  299. package/dist/lib/ledger/__tests__/sync.test.d.ts +0 -2
  300. package/dist/lib/ledger/__tests__/sync.test.d.ts.map +0 -1
  301. package/dist/lib/ledger/__tests__/sync.test.js +0 -117
  302. package/dist/lib/ledger/__tests__/sync.test.js.map +0 -1
  303. package/dist/lib/ledger/index.d.ts +0 -18
  304. package/dist/lib/ledger/index.d.ts.map +0 -1
  305. package/dist/lib/ledger/index.js +0 -32
  306. package/dist/lib/ledger/index.js.map +0 -1
  307. package/dist/lib/ledger/local.d.ts +0 -22
  308. package/dist/lib/ledger/local.d.ts.map +0 -1
  309. package/dist/lib/ledger/local.js +0 -333
  310. package/dist/lib/ledger/local.js.map +0 -1
  311. package/dist/lib/ledger/r2.d.ts +0 -41
  312. package/dist/lib/ledger/r2.d.ts.map +0 -1
  313. package/dist/lib/ledger/r2.js +0 -335
  314. package/dist/lib/ledger/r2.js.map +0 -1
  315. package/dist/lib/ledger/sync.d.ts +0 -33
  316. package/dist/lib/ledger/sync.d.ts.map +0 -1
  317. package/dist/lib/ledger/sync.js +0 -106
  318. package/dist/lib/ledger/sync.js.map +0 -1
  319. package/dist/lib/ledger/types.d.ts +0 -100
  320. package/dist/lib/ledger/types.d.ts.map +0 -1
  321. package/dist/lib/ledger/types.js +0 -21
  322. package/dist/lib/ledger/types.js.map +0 -1
  323. package/dist/lib/manifest.d.ts +0 -14
  324. package/dist/lib/manifest.d.ts.map +0 -1
  325. package/dist/lib/manifest.js +0 -48
  326. package/dist/lib/manifest.js.map +0 -1
  327. package/dist/lib/markdown.d.ts +0 -5
  328. package/dist/lib/markdown.d.ts.map +0 -1
  329. package/dist/lib/markdown.js +0 -17
  330. package/dist/lib/markdown.js.map +0 -1
  331. package/dist/lib/mcp.d.ts +0 -64
  332. package/dist/lib/mcp.d.ts.map +0 -1
  333. package/dist/lib/mcp.js +0 -327
  334. package/dist/lib/mcp.js.map +0 -1
  335. package/dist/lib/memory-compile.d.ts +0 -65
  336. package/dist/lib/memory-compile.d.ts.map +0 -1
  337. package/dist/lib/memory-compile.js +0 -174
  338. package/dist/lib/memory-compile.js.map +0 -1
  339. package/dist/lib/memory.d.ts +0 -64
  340. package/dist/lib/memory.d.ts.map +0 -1
  341. package/dist/lib/memory.js +0 -275
  342. package/dist/lib/memory.js.map +0 -1
  343. package/dist/lib/models.d.ts +0 -98
  344. package/dist/lib/models.d.ts.map +0 -1
  345. package/dist/lib/models.js +0 -728
  346. package/dist/lib/models.js.map +0 -1
  347. package/dist/lib/permissions.d.ts +0 -227
  348. package/dist/lib/permissions.d.ts.map +0 -1
  349. package/dist/lib/permissions.js +0 -1085
  350. package/dist/lib/permissions.js.map +0 -1
  351. package/dist/lib/picker.d.ts +0 -27
  352. package/dist/lib/picker.d.ts.map +0 -1
  353. package/dist/lib/picker.js +0 -110
  354. package/dist/lib/picker.js.map +0 -1
  355. package/dist/lib/plugins.d.ts +0 -80
  356. package/dist/lib/plugins.d.ts.map +0 -1
  357. package/dist/lib/plugins.js +0 -556
  358. package/dist/lib/plugins.js.map +0 -1
  359. package/dist/lib/profiles-keychain.d.ts +0 -11
  360. package/dist/lib/profiles-keychain.d.ts.map +0 -1
  361. package/dist/lib/profiles-keychain.js +0 -14
  362. package/dist/lib/profiles-keychain.js.map +0 -1
  363. package/dist/lib/profiles-presets.d.ts +0 -25
  364. package/dist/lib/profiles-presets.d.ts.map +0 -1
  365. package/dist/lib/profiles-presets.js +0 -104
  366. package/dist/lib/profiles-presets.js.map +0 -1
  367. package/dist/lib/profiles.d.ts +0 -70
  368. package/dist/lib/profiles.d.ts.map +0 -1
  369. package/dist/lib/profiles.js +0 -145
  370. package/dist/lib/profiles.js.map +0 -1
  371. package/dist/lib/pty-client.d.ts +0 -23
  372. package/dist/lib/pty-client.d.ts.map +0 -1
  373. package/dist/lib/pty-client.js +0 -181
  374. package/dist/lib/pty-client.js.map +0 -1
  375. package/dist/lib/pty-server.d.ts +0 -21
  376. package/dist/lib/pty-server.d.ts.map +0 -1
  377. package/dist/lib/pty-server.js +0 -427
  378. package/dist/lib/pty-server.js.map +0 -1
  379. package/dist/lib/registry.d.ts +0 -45
  380. package/dist/lib/registry.d.ts.map +0 -1
  381. package/dist/lib/registry.js +0 -220
  382. package/dist/lib/registry.js.map +0 -1
  383. package/dist/lib/resources.d.ts +0 -55
  384. package/dist/lib/resources.d.ts.map +0 -1
  385. package/dist/lib/resources.js +0 -103
  386. package/dist/lib/resources.js.map +0 -1
  387. package/dist/lib/rotate.d.ts +0 -58
  388. package/dist/lib/rotate.d.ts.map +0 -1
  389. package/dist/lib/rotate.js +0 -93
  390. package/dist/lib/rotate.js.map +0 -1
  391. package/dist/lib/routines.d.ts +0 -99
  392. package/dist/lib/routines.d.ts.map +0 -1
  393. package/dist/lib/routines.js +0 -352
  394. package/dist/lib/routines.js.map +0 -1
  395. package/dist/lib/runner.d.ts +0 -26
  396. package/dist/lib/runner.d.ts.map +0 -1
  397. package/dist/lib/runner.js +0 -325
  398. package/dist/lib/runner.js.map +0 -1
  399. package/dist/lib/sandbox.d.ts +0 -26
  400. package/dist/lib/sandbox.d.ts.map +0 -1
  401. package/dist/lib/sandbox.js +0 -218
  402. package/dist/lib/sandbox.js.map +0 -1
  403. package/dist/lib/scheduler.d.ts +0 -26
  404. package/dist/lib/scheduler.d.ts.map +0 -1
  405. package/dist/lib/scheduler.js +0 -77
  406. package/dist/lib/scheduler.js.map +0 -1
  407. package/dist/lib/secrets-bundles.d.ts +0 -38
  408. package/dist/lib/secrets-bundles.d.ts.map +0 -1
  409. package/dist/lib/secrets-bundles.js +0 -176
  410. package/dist/lib/secrets-bundles.js.map +0 -1
  411. package/dist/lib/secrets.d.ts +0 -53
  412. package/dist/lib/secrets.d.ts.map +0 -1
  413. package/dist/lib/secrets.js +0 -140
  414. package/dist/lib/secrets.js.map +0 -1
  415. package/dist/lib/session/__tests__/db.test.d.ts +0 -2
  416. package/dist/lib/session/__tests__/db.test.d.ts.map +0 -1
  417. package/dist/lib/session/__tests__/db.test.js +0 -54
  418. package/dist/lib/session/__tests__/db.test.js.map +0 -1
  419. package/dist/lib/session/__tests__/discover.test.d.ts +0 -2
  420. package/dist/lib/session/__tests__/discover.test.d.ts.map +0 -1
  421. package/dist/lib/session/__tests__/discover.test.js +0 -63
  422. package/dist/lib/session/__tests__/discover.test.js.map +0 -1
  423. package/dist/lib/session/__tests__/prompt.test.d.ts +0 -2
  424. package/dist/lib/session/__tests__/prompt.test.d.ts.map +0 -1
  425. package/dist/lib/session/__tests__/prompt.test.js +0 -44
  426. package/dist/lib/session/__tests__/prompt.test.js.map +0 -1
  427. package/dist/lib/session/__tests__/render.test.d.ts +0 -2
  428. package/dist/lib/session/__tests__/render.test.d.ts.map +0 -1
  429. package/dist/lib/session/__tests__/render.test.js +0 -602
  430. package/dist/lib/session/__tests__/render.test.js.map +0 -1
  431. package/dist/lib/session/active.d.ts +0 -44
  432. package/dist/lib/session/active.d.ts.map +0 -1
  433. package/dist/lib/session/active.js +0 -379
  434. package/dist/lib/session/active.js.map +0 -1
  435. package/dist/lib/session/artifacts.d.ts +0 -15
  436. package/dist/lib/session/artifacts.d.ts.map +0 -1
  437. package/dist/lib/session/artifacts.js +0 -86
  438. package/dist/lib/session/artifacts.js.map +0 -1
  439. package/dist/lib/session/db.d.ts +0 -140
  440. package/dist/lib/session/db.d.ts.map +0 -1
  441. package/dist/lib/session/db.js +0 -599
  442. package/dist/lib/session/db.js.map +0 -1
  443. package/dist/lib/session/discover.d.ts +0 -72
  444. package/dist/lib/session/discover.d.ts.map +0 -1
  445. package/dist/lib/session/discover.js +0 -1315
  446. package/dist/lib/session/discover.js.map +0 -1
  447. package/dist/lib/session/parse.d.ts +0 -34
  448. package/dist/lib/session/parse.d.ts.map +0 -1
  449. package/dist/lib/session/parse.js +0 -663
  450. package/dist/lib/session/parse.js.map +0 -1
  451. package/dist/lib/session/prompt.d.ts +0 -13
  452. package/dist/lib/session/prompt.d.ts.map +0 -1
  453. package/dist/lib/session/prompt.js +0 -79
  454. package/dist/lib/session/prompt.js.map +0 -1
  455. package/dist/lib/session/prompt.test.d.ts +0 -2
  456. package/dist/lib/session/prompt.test.d.ts.map +0 -1
  457. package/dist/lib/session/prompt.test.js +0 -57
  458. package/dist/lib/session/prompt.test.js.map +0 -1
  459. package/dist/lib/session/render.d.ts +0 -103
  460. package/dist/lib/session/render.d.ts.map +0 -1
  461. package/dist/lib/session/render.js +0 -798
  462. package/dist/lib/session/render.js.map +0 -1
  463. package/dist/lib/session/team-filter.d.ts +0 -35
  464. package/dist/lib/session/team-filter.d.ts.map +0 -1
  465. package/dist/lib/session/team-filter.js +0 -75
  466. package/dist/lib/session/team-filter.js.map +0 -1
  467. package/dist/lib/session/team-filter.test.d.ts +0 -2
  468. package/dist/lib/session/team-filter.test.d.ts.map +0 -1
  469. package/dist/lib/session/team-filter.test.js +0 -157
  470. package/dist/lib/session/team-filter.test.js.map +0 -1
  471. package/dist/lib/session/types.d.ts +0 -84
  472. package/dist/lib/session/types.d.ts.map +0 -1
  473. package/dist/lib/session/types.js +0 -11
  474. package/dist/lib/session/types.js.map +0 -1
  475. package/dist/lib/shims.d.ts +0 -272
  476. package/dist/lib/shims.d.ts.map +0 -1
  477. package/dist/lib/shims.js +0 -1322
  478. package/dist/lib/shims.js.map +0 -1
  479. package/dist/lib/skills.d.ts +0 -142
  480. package/dist/lib/skills.d.ts.map +0 -1
  481. package/dist/lib/skills.js +0 -791
  482. package/dist/lib/skills.js.map +0 -1
  483. package/dist/lib/state.d.ts +0 -87
  484. package/dist/lib/state.d.ts.map +0 -1
  485. package/dist/lib/state.js +0 -333
  486. package/dist/lib/state.js.map +0 -1
  487. package/dist/lib/subagents.d.ts +0 -84
  488. package/dist/lib/subagents.d.ts.map +0 -1
  489. package/dist/lib/subagents.js +0 -410
  490. package/dist/lib/subagents.js.map +0 -1
  491. package/dist/lib/teams/__tests__/oracle.test.d.ts +0 -2
  492. package/dist/lib/teams/__tests__/oracle.test.d.ts.map +0 -1
  493. package/dist/lib/teams/__tests__/oracle.test.js +0 -89
  494. package/dist/lib/teams/__tests__/oracle.test.js.map +0 -1
  495. package/dist/lib/teams/__tests__/supervisor.test.d.ts +0 -2
  496. package/dist/lib/teams/__tests__/supervisor.test.d.ts.map +0 -1
  497. package/dist/lib/teams/__tests__/supervisor.test.js +0 -179
  498. package/dist/lib/teams/__tests__/supervisor.test.js.map +0 -1
  499. package/dist/lib/teams/agents.d.ts +0 -247
  500. package/dist/lib/teams/agents.d.ts.map +0 -1
  501. package/dist/lib/teams/agents.js +0 -1244
  502. package/dist/lib/teams/agents.js.map +0 -1
  503. package/dist/lib/teams/api.d.ts +0 -91
  504. package/dist/lib/teams/api.d.ts.map +0 -1
  505. package/dist/lib/teams/api.js +0 -239
  506. package/dist/lib/teams/api.js.map +0 -1
  507. package/dist/lib/teams/cloud.d.ts +0 -11
  508. package/dist/lib/teams/cloud.d.ts.map +0 -1
  509. package/dist/lib/teams/cloud.js +0 -169
  510. package/dist/lib/teams/cloud.js.map +0 -1
  511. package/dist/lib/teams/debug.d.ts +0 -8
  512. package/dist/lib/teams/debug.d.ts.map +0 -1
  513. package/dist/lib/teams/debug.js +0 -12
  514. package/dist/lib/teams/debug.js.map +0 -1
  515. package/dist/lib/teams/file_ops.d.ts +0 -13
  516. package/dist/lib/teams/file_ops.d.ts.map +0 -1
  517. package/dist/lib/teams/file_ops.js +0 -66
  518. package/dist/lib/teams/file_ops.js.map +0 -1
  519. package/dist/lib/teams/index.d.ts +0 -16
  520. package/dist/lib/teams/index.d.ts.map +0 -1
  521. package/dist/lib/teams/index.js +0 -15
  522. package/dist/lib/teams/index.js.map +0 -1
  523. package/dist/lib/teams/oracle.d.ts +0 -20
  524. package/dist/lib/teams/oracle.d.ts.map +0 -1
  525. package/dist/lib/teams/oracle.js +0 -59
  526. package/dist/lib/teams/oracle.js.map +0 -1
  527. package/dist/lib/teams/parsers.d.ts +0 -9
  528. package/dist/lib/teams/parsers.d.ts.map +0 -1
  529. package/dist/lib/teams/parsers.js +0 -837
  530. package/dist/lib/teams/parsers.js.map +0 -1
  531. package/dist/lib/teams/persistence.d.ts +0 -43
  532. package/dist/lib/teams/persistence.d.ts.map +0 -1
  533. package/dist/lib/teams/persistence.js +0 -299
  534. package/dist/lib/teams/persistence.js.map +0 -1
  535. package/dist/lib/teams/ralph.d.ts +0 -8
  536. package/dist/lib/teams/ralph.d.ts.map +0 -1
  537. package/dist/lib/teams/ralph.js +0 -59
  538. package/dist/lib/teams/ralph.js.map +0 -1
  539. package/dist/lib/teams/registry.d.ts +0 -18
  540. package/dist/lib/teams/registry.d.ts.map +0 -1
  541. package/dist/lib/teams/registry.js +0 -68
  542. package/dist/lib/teams/registry.js.map +0 -1
  543. package/dist/lib/teams/summarizer.d.ts +0 -73
  544. package/dist/lib/teams/summarizer.d.ts.map +0 -1
  545. package/dist/lib/teams/summarizer.js +0 -780
  546. package/dist/lib/teams/summarizer.js.map +0 -1
  547. package/dist/lib/teams/supervisor.d.ts +0 -49
  548. package/dist/lib/teams/supervisor.d.ts.map +0 -1
  549. package/dist/lib/teams/supervisor.js +0 -74
  550. package/dist/lib/teams/supervisor.js.map +0 -1
  551. package/dist/lib/template.d.ts +0 -27
  552. package/dist/lib/template.d.ts.map +0 -1
  553. package/dist/lib/template.js +0 -60
  554. package/dist/lib/template.js.map +0 -1
  555. package/dist/lib/types.d.ts +0 -331
  556. package/dist/lib/types.d.ts.map +0 -1
  557. package/dist/lib/types.js +0 -29
  558. package/dist/lib/types.js.map +0 -1
  559. package/dist/lib/usage.d.ts +0 -105
  560. package/dist/lib/usage.d.ts.map +0 -1
  561. package/dist/lib/usage.js +0 -686
  562. package/dist/lib/usage.js.map +0 -1
  563. package/dist/lib/versions.d.ts +0 -253
  564. package/dist/lib/versions.d.ts.map +0 -1
  565. package/dist/lib/versions.js +0 -1796
  566. package/dist/lib/versions.js.map +0 -1
  567. package/scripts/rebuild-sqlite.sh +0 -46
@@ -1,1159 +0,0 @@
1
- /**
2
- * Core agent configuration and detection module.
3
- *
4
- * Defines the canonical registry of all supported AI coding agents (Claude, Codex,
5
- * Gemini, Cursor, OpenCode, OpenClaw, Copilot, Amp, Kiro, Goose, Roo) with their
6
- * CLI commands, config paths, capability flags, and MCP integration points.
7
- *
8
- * Provides functions for detecting installed CLIs, resolving version-managed binaries,
9
- * reading account/auth info, and managing MCP server registrations across agents.
10
- */
11
- import { exec } from 'child_process';
12
- import { promisify } from 'util';
13
- import * as fs from 'fs';
14
- import * as path from 'path';
15
- import * as os from 'os';
16
- import * as TOML from 'smol-toml';
17
- import chalk from 'chalk';
18
- import { walkForFiles } from './session/discover.js';
19
- import { getVersionsDir, getShimsDir } from './state.js';
20
- import { resolveVersion, getVersionHomePath, getBinaryPath } from './versions.js';
21
- import { loadClaudeOauth } from './usage.js';
22
- const execAsync = promisify(exec);
23
- const HOME = os.homedir();
24
- /** Minimum Codex CLI version that supports hooks. */
25
- export const CODEX_HOOKS_MIN_VERSION = '0.116.0';
26
- const CLI_VERSION_CACHE_PATH = path.join(HOME, '.agents', '.cli-version-cache.json');
27
- let cliVersionCache = null;
28
- function loadCliVersionCache() {
29
- if (cliVersionCache)
30
- return cliVersionCache;
31
- try {
32
- cliVersionCache = JSON.parse(fs.readFileSync(CLI_VERSION_CACHE_PATH, 'utf-8'));
33
- }
34
- catch {
35
- /* missing or corrupt cache, rebuild */
36
- cliVersionCache = {};
37
- }
38
- return cliVersionCache;
39
- }
40
- function saveCliVersionCache() {
41
- if (!cliVersionCache)
42
- return;
43
- try {
44
- const dir = path.dirname(CLI_VERSION_CACHE_PATH);
45
- if (!fs.existsSync(dir))
46
- fs.mkdirSync(dir, { recursive: true });
47
- fs.writeFileSync(CLI_VERSION_CACHE_PATH, JSON.stringify(cliVersionCache));
48
- }
49
- catch {
50
- /* best-effort cache persist */
51
- }
52
- }
53
- /** Synchronous PATH search -- no subprocess. Returns first matching binary path. */
54
- function findInPath(command) {
55
- const pathEnv = process.env.PATH || '';
56
- const pathExt = process.platform === 'win32' ? (process.env.PATHEXT || '').split(';') : [''];
57
- for (const dir of pathEnv.split(path.delimiter)) {
58
- if (!dir)
59
- continue;
60
- for (const ext of pathExt) {
61
- const full = path.join(dir, command + ext);
62
- try {
63
- const stat = fs.statSync(full);
64
- if (stat.isFile())
65
- return full;
66
- }
67
- catch {
68
- /* not in this dir */
69
- }
70
- }
71
- }
72
- return null;
73
- }
74
- /**
75
- * Master registry of all supported agents keyed by AgentId.
76
- *
77
- * Each entry defines the agent's CLI command, npm package, config directory layout,
78
- * instructions file name, slash-command format, and capability flags. This is the
79
- * single source of truth for agent metadata consumed throughout the codebase.
80
- */
81
- export const AGENTS = {
82
- claude: {
83
- id: 'claude',
84
- name: 'Claude',
85
- color: 'magenta',
86
- cliCommand: 'claude',
87
- npmPackage: '@anthropic-ai/claude-code',
88
- configDir: path.join(HOME, '.claude'),
89
- homeFiles: ['.claude.json'],
90
- commandsDir: path.join(HOME, '.claude', 'commands'),
91
- commandsSubdir: 'commands',
92
- skillsDir: path.join(HOME, '.claude', 'skills'),
93
- hooksDir: 'hooks',
94
- instructionsFile: 'CLAUDE.md',
95
- format: 'markdown',
96
- variableSyntax: '$ARGUMENTS',
97
- supportsHooks: true,
98
- capabilities: { hooks: true, mcp: true, allowlist: true, skills: true, commands: true, plugins: true, memoryImports: true },
99
- },
100
- codex: {
101
- id: 'codex',
102
- name: 'Codex',
103
- color: 'green',
104
- cliCommand: 'codex',
105
- npmPackage: '@openai/codex',
106
- configDir: path.join(HOME, '.codex'),
107
- commandsDir: path.join(HOME, '.codex', 'prompts'),
108
- commandsSubdir: 'prompts',
109
- skillsDir: path.join(HOME, '.codex', 'skills'),
110
- hooksDir: 'hooks',
111
- instructionsFile: 'AGENTS.md',
112
- format: 'markdown',
113
- variableSyntax: '$ARGUMENTS',
114
- supportsHooks: true,
115
- capabilities: { hooks: true, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
116
- },
117
- gemini: {
118
- id: 'gemini',
119
- name: 'Gemini',
120
- color: 'blue',
121
- cliCommand: 'gemini',
122
- npmPackage: '@google/gemini-cli',
123
- configDir: path.join(HOME, '.gemini'),
124
- commandsDir: path.join(HOME, '.gemini', 'commands'),
125
- commandsSubdir: 'commands',
126
- skillsDir: path.join(HOME, '.gemini', 'skills'),
127
- hooksDir: 'hooks',
128
- instructionsFile: 'GEMINI.md',
129
- format: 'toml',
130
- variableSyntax: '{{args}}',
131
- supportsHooks: true,
132
- nativeAgentsSkillsDir: true,
133
- capabilities: { hooks: true, mcp: true, allowlist: false, skills: true, commands: true, plugins: false, memoryImports: true },
134
- },
135
- cursor: {
136
- id: 'cursor',
137
- name: 'Cursor',
138
- color: 'cyan',
139
- cliCommand: 'cursor-agent',
140
- npmPackage: '',
141
- installScript: 'curl https://cursor.com/install -fsS | bash && mv ~/.local/bin/agent ~/.local/bin/cursor-agent && grep -q "/.local/bin" ~/.zshrc || echo \'export PATH="$HOME/.local/bin:$PATH"\' >> ~/.zshrc',
142
- configDir: path.join(HOME, '.cursor'),
143
- commandsDir: path.join(HOME, '.cursor', 'commands'),
144
- commandsSubdir: 'commands',
145
- skillsDir: path.join(HOME, '.cursor', 'skills'),
146
- hooksDir: 'hooks',
147
- instructionsFile: '.cursorrules',
148
- format: 'markdown',
149
- variableSyntax: '$ARGUMENTS',
150
- supportsHooks: false,
151
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
152
- },
153
- opencode: {
154
- id: 'opencode',
155
- name: 'OpenCode',
156
- color: 'yellowBright',
157
- cliCommand: 'opencode',
158
- npmPackage: 'opencode-ai',
159
- configDir: path.join(HOME, '.opencode'),
160
- commandsDir: path.join(HOME, '.opencode', 'commands'),
161
- commandsSubdir: 'commands',
162
- skillsDir: path.join(HOME, '.opencode', 'skills'),
163
- hooksDir: 'hooks',
164
- instructionsFile: 'AGENTS.md',
165
- format: 'markdown',
166
- variableSyntax: '$ARGUMENTS',
167
- supportsHooks: false,
168
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
169
- },
170
- openclaw: {
171
- id: 'openclaw',
172
- name: 'OpenClaw',
173
- color: 'redBright',
174
- cliCommand: 'openclaw',
175
- npmPackage: 'openclaw',
176
- configDir: path.join(HOME, '.openclaw'),
177
- commandsDir: '', // OpenClaw uses Gateway-based slash commands, not file-based
178
- commandsSubdir: '',
179
- skillsDir: path.join(HOME, '.openclaw', 'skills'),
180
- hooksDir: 'hooks',
181
- instructionsFile: 'workspace/AGENTS.md', // Primary memory file (also has SOUL.md, IDENTITY.md, etc.)
182
- format: 'markdown',
183
- variableSyntax: '{{ARGUMENTS}}',
184
- supportsHooks: true,
185
- capabilities: { hooks: true, mcp: true, allowlist: false, skills: true, commands: false, plugins: true },
186
- },
187
- copilot: {
188
- id: 'copilot',
189
- name: 'Copilot',
190
- color: 'whiteBright',
191
- cliCommand: 'copilot',
192
- npmPackage: '@github/copilot',
193
- configDir: path.join(HOME, '.copilot'),
194
- commandsDir: path.join(HOME, '.copilot', 'commands'),
195
- commandsSubdir: 'commands',
196
- skillsDir: path.join(HOME, '.copilot', 'skills'),
197
- hooksDir: 'hooks',
198
- instructionsFile: 'AGENTS.md',
199
- format: 'markdown',
200
- variableSyntax: '$ARGUMENTS',
201
- supportsHooks: false,
202
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
203
- },
204
- amp: {
205
- id: 'amp',
206
- name: 'Amp',
207
- color: 'blueBright',
208
- cliCommand: 'amp',
209
- npmPackage: '@sourcegraph/amp',
210
- configDir: path.join(HOME, '.config', 'amp'),
211
- commandsDir: path.join(HOME, '.config', 'amp', 'commands'),
212
- commandsSubdir: 'commands',
213
- skillsDir: path.join(HOME, '.config', 'amp', 'skills'),
214
- hooksDir: 'hooks',
215
- instructionsFile: 'AGENTS.md',
216
- format: 'markdown',
217
- variableSyntax: '$ARGUMENTS',
218
- supportsHooks: false,
219
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
220
- },
221
- kiro: {
222
- id: 'kiro',
223
- name: 'Kiro',
224
- color: 'greenBright',
225
- cliCommand: 'kiro-cli',
226
- npmPackage: '',
227
- installScript: 'brew install --cask kiro-cli',
228
- configDir: path.join(HOME, '.kiro'),
229
- commandsDir: path.join(HOME, '.kiro', 'commands'),
230
- commandsSubdir: 'commands',
231
- skillsDir: path.join(HOME, '.kiro', 'skills'),
232
- hooksDir: 'hooks',
233
- instructionsFile: 'AGENTS.md',
234
- format: 'markdown',
235
- variableSyntax: '$ARGUMENTS',
236
- supportsHooks: false,
237
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
238
- },
239
- goose: {
240
- id: 'goose',
241
- name: 'Goose',
242
- color: 'magentaBright',
243
- cliCommand: 'goose',
244
- npmPackage: '',
245
- installScript: 'brew install block-goose-cli',
246
- configDir: path.join(HOME, '.config', 'goose'),
247
- commandsDir: path.join(HOME, '.config', 'goose', 'commands'),
248
- commandsSubdir: 'commands',
249
- skillsDir: path.join(HOME, '.config', 'goose', 'skills'),
250
- hooksDir: 'hooks',
251
- instructionsFile: 'AGENTS.md',
252
- format: 'markdown',
253
- variableSyntax: '$ARGUMENTS',
254
- supportsHooks: false,
255
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: false, commands: false, plugins: false },
256
- },
257
- roo: {
258
- id: 'roo',
259
- name: 'Roo Code',
260
- color: 'cyanBright',
261
- cliCommand: 'roo',
262
- npmPackage: '',
263
- installScript: 'curl -fsSL https://raw.githubusercontent.com/RooCodeInc/Roo-Code/main/apps/cli/install.sh | sh',
264
- configDir: path.join(HOME, '.roo'),
265
- commandsDir: path.join(HOME, '.roo', 'commands'),
266
- commandsSubdir: 'commands',
267
- skillsDir: path.join(HOME, '.roo', 'skills'),
268
- hooksDir: 'hooks',
269
- instructionsFile: 'AGENTS.md',
270
- format: 'markdown',
271
- variableSyntax: '$ARGUMENTS',
272
- supportsHooks: false,
273
- capabilities: { hooks: false, mcp: true, allowlist: false, skills: true, commands: true, plugins: false },
274
- },
275
- };
276
- /** All registered agent IDs derived from the AGENTS registry. */
277
- export const ALL_AGENT_IDS = Object.keys(AGENTS);
278
- /** Agents that support MCP (Model Context Protocol) server integration. */
279
- export const MCP_CAPABLE_AGENTS = ALL_AGENT_IDS.filter((id) => AGENTS[id].capabilities.mcp);
280
- /** Agents that support skills (SKILL.md + rules/ bundles). */
281
- export const SKILLS_CAPABLE_AGENTS = ALL_AGENT_IDS.filter((id) => AGENTS[id].capabilities.skills);
282
- /** Agents that support file-based slash commands. */
283
- export const COMMANDS_CAPABLE_AGENTS = ALL_AGENT_IDS.filter((id) => AGENTS[id].capabilities.commands);
284
- /** Agents that support event hooks (pre/post lifecycle callbacks). */
285
- export const HOOKS_CAPABLE_AGENTS = ['claude', 'codex', 'gemini', 'openclaw'];
286
- /** Agents that support the plugin system. */
287
- export const PLUGINS_CAPABLE_AGENTS = ALL_AGENT_IDS.filter((id) => AGENTS[id].capabilities.plugins);
288
- /** Get the chalk color function for an agent. Works for any AgentId or SessionAgentId. */
289
- export function colorAgent(agentId) {
290
- const agent = AGENTS[agentId];
291
- if (!agent)
292
- return chalk.white;
293
- return chalk[agent.color];
294
- }
295
- /** Return the agent's display name, colored. */
296
- export function agentLabel(agentId) {
297
- const agent = AGENTS[agentId];
298
- if (!agent)
299
- return agentId;
300
- return chalk[agent.color](agent.name);
301
- }
302
- /** Check whether the given agent's CLI binary is present on PATH. */
303
- export async function isCliInstalled(agentId) {
304
- const agent = AGENTS[agentId];
305
- return findInPath(agent.cliCommand) !== null;
306
- }
307
- /** Return the installed CLI version for the given agent, or null if not found. */
308
- export async function getCliVersion(agentId) {
309
- const agent = AGENTS[agentId];
310
- const binaryPath = findInPath(agent.cliCommand);
311
- if (!binaryPath)
312
- return null;
313
- return getCachedVersionForBinary(agentId, binaryPath);
314
- }
315
- /** Return the absolute path to the agent's CLI binary on PATH, or null. */
316
- export async function getCliPath(agentId) {
317
- return findInPath(AGENTS[agentId].cliCommand);
318
- }
319
- /** Look up version from cache by (binary, mtime). On miss or stale, spawn `--version` and cache. */
320
- async function getCachedVersionForBinary(agentId, binaryPath) {
321
- let mtime = 0;
322
- try {
323
- mtime = fs.statSync(binaryPath).mtimeMs;
324
- }
325
- catch {
326
- /* binary vanished between findInPath and statSync */
327
- return null;
328
- }
329
- const cache = loadCliVersionCache();
330
- const cached = cache[agentId];
331
- if (cached && cached.binaryPath === binaryPath && cached.mtime === mtime) {
332
- return cached.version;
333
- }
334
- const agent = AGENTS[agentId];
335
- let version = null;
336
- try {
337
- const { stdout } = await execAsync(`${agent.cliCommand} --version`, { timeout: 3000 });
338
- if (agentId === 'openclaw') {
339
- const match = stdout.match(/openclaw\/(\d+\.\d+\.\d+)/);
340
- version = match ? match[1] : stdout.trim();
341
- }
342
- else {
343
- const match = stdout.match(/(\d+\.\d+\.\d+)/);
344
- version = match ? match[1] : stdout.trim();
345
- }
346
- }
347
- catch {
348
- /* version command failed */
349
- version = null;
350
- }
351
- cache[agentId] = { binaryPath, mtime, version };
352
- saveCliVersionCache();
353
- return version;
354
- }
355
- /**
356
- * Resolve the full CLI state for an agent: whether it is installed, its version,
357
- * and the path to the binary. Checks version-managed installs first, then falls
358
- * back to a plain PATH lookup.
359
- */
360
- export async function getCliState(agentId) {
361
- // Fast path: if version-managed, derive state from filesystem (no subprocesses)
362
- const agent = AGENTS[agentId];
363
- const agentVersionsDir = path.join(getVersionsDir(), agentId);
364
- if (fs.existsSync(agentVersionsDir)) {
365
- // Use resolved version (project manifest -> global default)
366
- const resolvedVer = resolveVersion(agentId, process.cwd());
367
- if (resolvedVer) {
368
- const binaryPath = path.join(agentVersionsDir, resolvedVer, 'node_modules', '.bin', agent.cliCommand);
369
- if (fs.existsSync(binaryPath)) {
370
- const shimPath = path.join(getShimsDir(), agent.cliCommand);
371
- return {
372
- installed: true,
373
- version: resolvedVer,
374
- path: fs.existsSync(shimPath) ? shimPath : binaryPath,
375
- };
376
- }
377
- }
378
- // Fallback: if no default set or resolved version not installed, return first available
379
- const entries = fs.readdirSync(agentVersionsDir, { withFileTypes: true });
380
- for (const entry of entries) {
381
- if (entry.isDirectory()) {
382
- const binaryPath = path.join(agentVersionsDir, entry.name, 'node_modules', '.bin', agent.cliCommand);
383
- if (fs.existsSync(binaryPath)) {
384
- const shimPath = path.join(getShimsDir(), agent.cliCommand);
385
- return {
386
- installed: true,
387
- version: entry.name,
388
- path: fs.existsSync(shimPath) ? shimPath : binaryPath,
389
- };
390
- }
391
- }
392
- }
393
- }
394
- // Non-version-managed: single PATH lookup + cached version read
395
- const binaryPath = findInPath(agent.cliCommand);
396
- if (!binaryPath) {
397
- return { installed: false, version: null, path: null };
398
- }
399
- return {
400
- installed: true,
401
- version: await getCachedVersionForBinary(agentId, binaryPath),
402
- path: binaryPath,
403
- };
404
- }
405
- /** Resolve CLI state for all registered agents in parallel. */
406
- export async function getAllCliStates() {
407
- const states = {};
408
- const results = await Promise.all(ALL_AGENT_IDS.map(async (agentId) => ({
409
- agentId,
410
- state: await getCliState(agentId),
411
- })));
412
- for (const { agentId, state } of results) {
413
- states[agentId] = state;
414
- }
415
- return states;
416
- }
417
- /** Check whether the agent's config directory exists on disk. */
418
- export function isConfigured(agentId) {
419
- const agent = AGENTS[agentId];
420
- return fs.existsSync(agent.configDir);
421
- }
422
- /** Create the agent's slash-commands directory if it does not exist. */
423
- export function ensureCommandsDir(agentId) {
424
- const agent = AGENTS[agentId];
425
- if (!fs.existsSync(agent.commandsDir)) {
426
- fs.mkdirSync(agent.commandsDir, { recursive: true });
427
- }
428
- }
429
- /** Create the agent's skills directory if it does not exist. */
430
- export function ensureSkillsDir(agentId) {
431
- const agent = AGENTS[agentId];
432
- if (!fs.existsSync(agent.skillsDir)) {
433
- fs.mkdirSync(agent.skillsDir, { recursive: true });
434
- }
435
- }
436
- /** Return the email address associated with the agent's auth config, or null. */
437
- export async function getAccountEmail(agentId, home) {
438
- const info = await getAccountInfo(agentId, home);
439
- return info.email;
440
- }
441
- /**
442
- * Extract full account information (identity, plan, usage status, credits) from
443
- * the agent's local auth/config files. Supports Claude, Codex, and Gemini.
444
- */
445
- export async function getAccountInfo(agentId, home) {
446
- const base = home || os.homedir();
447
- const empty = {
448
- accountKey: null,
449
- usageKey: null,
450
- accountId: null,
451
- organizationId: null,
452
- userId: null,
453
- email: null,
454
- plan: null,
455
- usageStatus: null,
456
- overageCredits: null,
457
- lastActive: null,
458
- };
459
- const configFiles = {
460
- claude: path.join(base, '.claude.json'),
461
- codex: path.join(base, '.codex', 'auth.json'),
462
- gemini: path.join(base, '.gemini', 'google_accounts.json'),
463
- };
464
- const lastActive = resolveLastActive(agentId, base, configFiles[agentId]);
465
- try {
466
- switch (agentId) {
467
- case 'claude': {
468
- // Claude reads/writes config at $CLAUDE_CONFIG_DIR/.claude.json when set,
469
- // falling back to $HOME/.claude.json. Our shim sets CLAUDE_CONFIG_DIR to
470
- // the per-version .claude dir, so prefer that file; fall back to home-level
471
- // for versions ever launched without the shim (IDE extension, direct binary).
472
- const configDirFile = path.join(base, '.claude', '.claude.json');
473
- const homeLevelFile = path.join(base, '.claude.json');
474
- const activeFile = fs.existsSync(configDirFile) ? configDirFile : homeLevelFile;
475
- const data = JSON.parse(await fs.promises.readFile(activeFile, 'utf-8'));
476
- const oa = data.oauthAccount;
477
- const accountId = normalizeIdentityPart(oa?.accountUuid);
478
- const organizationId = normalizeIdentityPart(oa?.organizationUuid);
479
- const email = oa?.emailAddress || null;
480
- const accountKey = buildIdentityKey(agentId, [
481
- ['account', accountId],
482
- ['org', organizationId],
483
- ]);
484
- const usageKey = buildIdentityKey(agentId, [['org', organizationId]]);
485
- let plan = null;
486
- const keychainOauth = await loadClaudeOauth(home);
487
- if (keychainOauth?.subscriptionType) {
488
- plan = keychainOauth.subscriptionType.charAt(0).toUpperCase()
489
- + keychainOauth.subscriptionType.slice(1);
490
- }
491
- else if (oa?.billingType === 'stripe_subscription') {
492
- plan = 'Pro';
493
- }
494
- else if (oa?.billingType) {
495
- plan = oa.billingType;
496
- }
497
- let usageStatus = null;
498
- const reason = data.cachedExtraUsageDisabledReason;
499
- if (reason === 'out_of_credits')
500
- usageStatus = 'out_of_credits';
501
- else if (reason)
502
- usageStatus = 'rate_limited';
503
- else
504
- usageStatus = 'available';
505
- let overageCredits = null;
506
- const orgId = oa?.organizationUuid;
507
- const creditCache = orgId && data.overageCreditGrantCache?.[orgId];
508
- if (creditCache?.info?.available && creditCache.info.amount_minor_units) {
509
- overageCredits = {
510
- amount: creditCache.info.amount_minor_units / 100,
511
- currency: creditCache.info.currency || 'USD',
512
- };
513
- }
514
- return {
515
- accountKey,
516
- usageKey,
517
- accountId,
518
- organizationId,
519
- userId: null,
520
- email,
521
- plan,
522
- usageStatus,
523
- overageCredits,
524
- lastActive,
525
- };
526
- }
527
- case 'codex': {
528
- const data = JSON.parse(await fs.promises.readFile(path.join(base, '.codex', 'auth.json'), 'utf-8'));
529
- const token = data.tokens?.id_token || data.tokens?.access_token;
530
- if (!token)
531
- return { ...empty, lastActive };
532
- const decoded = decodeJwtPayload(token);
533
- if (!decoded)
534
- return { ...empty, lastActive };
535
- const email = decoded.email || null;
536
- // Plan and subscription from OpenAI auth claim
537
- const authClaim = decoded['https://api.openai.com/auth'] || {};
538
- const accountId = normalizeIdentityPart(authClaim.chatgpt_account_id);
539
- const userId = normalizeIdentityPart(authClaim.chatgpt_user_id || authClaim.user_id);
540
- const organizationId = normalizeIdentityPart(getCodexDefaultOrgId(authClaim));
541
- const accountKey = buildIdentityKey(agentId, [
542
- ['account', accountId],
543
- ['user', userId],
544
- ['org', organizationId],
545
- ]);
546
- const rawPlan = authClaim.chatgpt_plan_type;
547
- const plan = rawPlan ? rawPlan.charAt(0).toUpperCase() + rawPlan.slice(1) : null;
548
- // Subscription status: expired = out_of_credits
549
- let usageStatus = null;
550
- const activeUntil = authClaim.chatgpt_subscription_active_until;
551
- if (activeUntil) {
552
- const expired = new Date(activeUntil).getTime() < Date.now();
553
- usageStatus = expired ? 'out_of_credits' : 'available';
554
- }
555
- return {
556
- accountKey,
557
- usageKey: accountKey,
558
- accountId,
559
- organizationId,
560
- userId,
561
- email,
562
- plan,
563
- usageStatus,
564
- overageCredits: null,
565
- lastActive,
566
- };
567
- }
568
- case 'gemini': {
569
- const data = JSON.parse(await fs.promises.readFile(path.join(base, '.gemini', 'google_accounts.json'), 'utf-8'));
570
- return { ...empty, email: data.active || null, lastActive };
571
- }
572
- default:
573
- return { ...empty, lastActive };
574
- }
575
- }
576
- catch {
577
- /* auth/config file missing or unreadable */
578
- return { ...empty, lastActive };
579
- }
580
- }
581
- /** Determine when the agent was last used by checking session file mtimes, falling back to config mtime. */
582
- function resolveLastActive(agentId, base, configPath) {
583
- const sessionDir = getSessionDir(agentId, base);
584
- const sessionExt = getSessionExtension(agentId);
585
- if (sessionDir && sessionExt) {
586
- const latestSession = getLatestFileMtime(sessionDir, sessionExt);
587
- if (latestSession) {
588
- return latestSession;
589
- }
590
- }
591
- if (!configPath)
592
- return null;
593
- try {
594
- return fs.statSync(configPath).mtime;
595
- }
596
- catch {
597
- return null;
598
- }
599
- }
600
- /** Return the root directory where the agent stores session files, or null if unknown. */
601
- function getSessionDir(agentId, base) {
602
- switch (agentId) {
603
- case 'claude':
604
- return path.join(base, '.claude', 'projects');
605
- case 'codex':
606
- return path.join(base, '.codex', 'sessions');
607
- case 'gemini':
608
- return path.join(base, '.gemini', 'tmp');
609
- default:
610
- return null;
611
- }
612
- }
613
- /** Return the file extension used for session files by the given agent. */
614
- function getSessionExtension(agentId) {
615
- switch (agentId) {
616
- case 'claude':
617
- case 'codex':
618
- return '.jsonl';
619
- case 'gemini':
620
- return '.json';
621
- default:
622
- return null;
623
- }
624
- }
625
- /** Walk a directory for files matching the extension and return the mtime of the most recent one. */
626
- function getLatestFileMtime(dir, ext) {
627
- if (!fs.existsSync(dir))
628
- return null;
629
- const [latest] = walkForFiles(dir, ext, 1);
630
- if (!latest)
631
- return null;
632
- try {
633
- return fs.statSync(latest).mtime;
634
- }
635
- catch {
636
- return null;
637
- }
638
- }
639
- /** Decode the payload section of a JWT token without verifying its signature. */
640
- function decodeJwtPayload(token) {
641
- const payload = token.split('.')[1];
642
- if (!payload)
643
- return null;
644
- try {
645
- return JSON.parse(Buffer.from(payload, 'base64url').toString());
646
- }
647
- catch {
648
- return null;
649
- }
650
- }
651
- /** Extract the default organization ID from a Codex/OpenAI auth claim. */
652
- function getCodexDefaultOrgId(authClaim) {
653
- const organizations = authClaim?.organizations;
654
- if (!Array.isArray(organizations))
655
- return null;
656
- const first = organizations[0];
657
- return typeof first?.id === 'string' ? first.id : null;
658
- }
659
- /** Trim and normalize an identity string, returning null for empty or non-string values. */
660
- function normalizeIdentityPart(value) {
661
- if (typeof value !== 'string')
662
- return null;
663
- const trimmed = value.trim();
664
- return trimmed || null;
665
- }
666
- /** Build a composite identity key like "claude:account=abc:org=xyz" from labeled parts. */
667
- function buildIdentityKey(agentId, parts) {
668
- const encoded = parts
669
- .filter(([, value]) => value)
670
- .map(([label, value]) => `${label}=${value}`);
671
- if (encoded.length === 0)
672
- return null;
673
- return `${agentId}:${encoded.join(':')}`;
674
- }
675
- /** Check whether a named MCP server is registered with the agent's CLI. */
676
- export async function isMcpRegistered(agentId, mcpName) {
677
- const agent = AGENTS[agentId];
678
- if (!agent.capabilities.mcp || !(await isCliInstalled(agentId))) {
679
- return false;
680
- }
681
- try {
682
- const { stdout } = await execAsync(`${agent.cliCommand} mcp list`);
683
- return stdout.toLowerCase().includes(mcpName.toLowerCase());
684
- }
685
- catch {
686
- /* mcp list command failed */
687
- return false;
688
- }
689
- }
690
- /** Register an MCP server with an agent's CLI via `mcp add`. */
691
- export async function registerMcp(agentId, name, command, scope = 'user', transport = 'stdio', options) {
692
- const agent = AGENTS[agentId];
693
- if (!agent.capabilities.mcp) {
694
- return { success: false, error: 'Agent does not support MCP' };
695
- }
696
- if (!options?.binary && !(await isCliInstalled(agentId))) {
697
- return { success: false, error: 'CLI not installed' };
698
- }
699
- try {
700
- // Use explicit binary path when provided (bypasses shim for version-managed agents)
701
- const bin = options?.binary || agent.cliCommand;
702
- let cmd;
703
- if (agentId === 'claude') {
704
- cmd = `${bin} mcp add --transport ${transport} --scope ${scope} "${name}" -- ${command}`;
705
- }
706
- else {
707
- cmd = `${bin} mcp add "${name}" -- ${command}`;
708
- }
709
- // When home is specified, override HOME so MCP config writes to the version's config dir
710
- const env = options?.home ? { ...process.env, HOME: options.home } : undefined;
711
- await execAsync(cmd, env ? { env } : undefined);
712
- return { success: true };
713
- }
714
- catch (err) {
715
- return { success: false, error: err.message };
716
- }
717
- }
718
- /** Unregister (remove) a named MCP server from an agent's CLI config. */
719
- export async function unregisterMcp(agentId, name, options) {
720
- const agent = AGENTS[agentId];
721
- if (!agent.capabilities.mcp) {
722
- return { success: false, error: 'Agent does not support MCP' };
723
- }
724
- if (!options?.binary && !(await isCliInstalled(agentId))) {
725
- return { success: false, error: 'CLI not installed' };
726
- }
727
- try {
728
- const bin = options?.binary || agent.cliCommand;
729
- const env = options?.home ? { ...process.env, HOME: options.home } : undefined;
730
- await execAsync(`${bin} mcp remove "${name}"`, env ? { env } : undefined);
731
- return { success: true };
732
- }
733
- catch (err) {
734
- return { success: false, error: err.message };
735
- }
736
- }
737
- /**
738
- * Register an MCP server across multiple agent targets, including both direct
739
- * (non-version-managed) agents and specific version-managed installs.
740
- */
741
- export async function registerMcpToTargets(targets, name, command, scope = 'user', transport = 'stdio') {
742
- const results = [];
743
- for (const agentId of targets.directAgents) {
744
- const result = await registerMcp(agentId, name, command, scope, transport);
745
- results.push({ agentId, success: result.success, error: result.error });
746
- }
747
- for (const [agentId, versions] of targets.versionSelections) {
748
- for (const version of versions) {
749
- const result = await registerMcp(agentId, name, command, scope, transport, {
750
- home: getVersionHomePath(agentId, version),
751
- binary: getBinaryPath(agentId, version),
752
- });
753
- results.push({ agentId, version, success: result.success, error: result.error });
754
- }
755
- }
756
- return results;
757
- }
758
- /**
759
- * Unregister an MCP server from multiple agent targets, including both direct
760
- * agents and specific version-managed installs.
761
- */
762
- export async function unregisterMcpFromTargets(targets, name) {
763
- const results = [];
764
- for (const agentId of targets.directAgents) {
765
- const result = await unregisterMcp(agentId, name);
766
- results.push({ agentId, success: result.success, error: result.error });
767
- }
768
- for (const [agentId, versions] of targets.versionSelections) {
769
- for (const version of versions) {
770
- const result = await unregisterMcp(agentId, name, {
771
- home: getVersionHomePath(agentId, version),
772
- binary: getBinaryPath(agentId, version),
773
- });
774
- results.push({ agentId, version, success: result.success, error: result.error });
775
- }
776
- }
777
- return results;
778
- }
779
- /**
780
- * Extract version from npm package specification.
781
- * Examples: @swarmify/agents-mcp@latest -> latest
782
- * @swarmify/agents-mcp@1.2.3 -> 1.2.3
783
- * some-package -> undefined
784
- */
785
- function extractNpmVersion(args) {
786
- // Find npm package argument (looks like @scope/package@version or package@version)
787
- for (const arg of args) {
788
- // Match @scope/package@version or package@version
789
- const match = arg.match(/@([^@]+)$|^([^@]+)@(.+)$/);
790
- if (match) {
791
- // @scope/package@version pattern
792
- const versionMatch = arg.match(/@([^@/]+)$/);
793
- if (versionMatch) {
794
- return versionMatch[1];
795
- }
796
- }
797
- }
798
- return undefined;
799
- }
800
- /**
801
- * Strip JSON comments for JSONC parsing.
802
- * Only removes comments outside of strings.
803
- */
804
- function stripJsonComments(content) {
805
- let result = '';
806
- let inString = false;
807
- let escape = false;
808
- let i = 0;
809
- while (i < content.length) {
810
- const char = content[i];
811
- const next = content[i + 1];
812
- if (escape) {
813
- result += char;
814
- escape = false;
815
- i++;
816
- continue;
817
- }
818
- if (char === '\\' && inString) {
819
- result += char;
820
- escape = true;
821
- i++;
822
- continue;
823
- }
824
- if (char === '"') {
825
- inString = !inString;
826
- result += char;
827
- i++;
828
- continue;
829
- }
830
- if (!inString) {
831
- // Check for single-line comment
832
- if (char === '/' && next === '/') {
833
- // Skip until end of line
834
- while (i < content.length && content[i] !== '\n') {
835
- i++;
836
- }
837
- continue;
838
- }
839
- // Check for multi-line comment
840
- if (char === '/' && next === '*') {
841
- i += 2;
842
- while (i < content.length && !(content[i] === '*' && content[i + 1] === '/')) {
843
- i++;
844
- }
845
- i += 2; // Skip */
846
- continue;
847
- }
848
- }
849
- result += char;
850
- i++;
851
- }
852
- return result;
853
- }
854
- /**
855
- * Parse MCP servers from a JSON/JSONC config file.
856
- */
857
- function parseMcpFromJsonConfig(configPath) {
858
- if (!fs.existsSync(configPath)) {
859
- return {};
860
- }
861
- try {
862
- let content = fs.readFileSync(configPath, 'utf-8');
863
- // Handle JSONC (JSON with comments)
864
- if (configPath.endsWith('.jsonc')) {
865
- content = stripJsonComments(content);
866
- }
867
- const config = JSON.parse(content);
868
- // Claude uses mcpServers, others may use mcp_servers or mcp
869
- return config.mcpServers || config.mcp_servers || config.mcp || {};
870
- }
871
- catch {
872
- /* JSON config corrupt or unreadable */
873
- return {};
874
- }
875
- }
876
- /**
877
- * Parse MCP servers from a TOML config file (Codex).
878
- * Codex stores MCPs as [mcp_servers.ServerName] sections.
879
- */
880
- function parseMcpFromTomlConfig(configPath) {
881
- if (!fs.existsSync(configPath)) {
882
- return {};
883
- }
884
- try {
885
- const content = fs.readFileSync(configPath, 'utf-8');
886
- const config = TOML.parse(content);
887
- // Codex uses mcp_servers as a table with server names as keys
888
- const mcpServers = config.mcp_servers;
889
- return mcpServers || {};
890
- }
891
- catch {
892
- /* TOML config corrupt or unreadable */
893
- return {};
894
- }
895
- }
896
- /**
897
- * Parse MCP servers from OpenCode's JSONC config.
898
- * OpenCode stores MCPs in the "mcp" object with different structure.
899
- */
900
- function parseMcpFromOpenCodeConfig(configPath) {
901
- if (!fs.existsSync(configPath)) {
902
- return {};
903
- }
904
- try {
905
- const content = stripJsonComments(fs.readFileSync(configPath, 'utf-8'));
906
- const config = JSON.parse(content);
907
- const mcpConfig = config.mcp;
908
- if (!mcpConfig)
909
- return {};
910
- // Convert OpenCode format to our McpConfigEntry format
911
- const result = {};
912
- for (const [name, entry] of Object.entries(mcpConfig)) {
913
- if (entry.type === 'local' && entry.command) {
914
- // Local MCP: command is an array like ["npx", "-y", "@pkg@version"]
915
- result[name] = {
916
- command: entry.command[0],
917
- args: entry.command.slice(1),
918
- };
919
- }
920
- else if (entry.type === 'remote' && entry.url) {
921
- // Remote MCP: HTTP URL
922
- result[name] = {
923
- url: entry.url,
924
- };
925
- }
926
- }
927
- return result;
928
- }
929
- catch {
930
- /* OpenCode JSONC config corrupt or unreadable */
931
- return {};
932
- }
933
- }
934
- /**
935
- * Get user-scoped MCP config path for an agent.
936
- */
937
- function getUserMcpConfigPath(agentId) {
938
- const agent = AGENTS[agentId];
939
- switch (agentId) {
940
- case 'claude':
941
- // Claude user-scoped MCPs are in ~/.claude.json (global user config)
942
- return path.join(HOME, '.claude.json');
943
- case 'codex':
944
- // Codex uses TOML config
945
- return path.join(agent.configDir, 'config.toml');
946
- case 'opencode':
947
- // OpenCode uses JSONC config
948
- return path.join(agent.configDir, 'opencode.jsonc');
949
- case 'cursor':
950
- // Cursor uses mcp.json
951
- return path.join(agent.configDir, 'mcp.json');
952
- case 'openclaw':
953
- // OpenClaw uses openclaw.json
954
- return path.join(agent.configDir, 'openclaw.json');
955
- default:
956
- // Gemini and others use settings.json
957
- return path.join(agent.configDir, 'settings.json');
958
- }
959
- }
960
- /**
961
- * Get MCP config path for a specific HOME directory (used for version-managed agents).
962
- */
963
- export function getMcpConfigPathForHome(agentId, home) {
964
- switch (agentId) {
965
- case 'claude':
966
- return path.join(home, '.claude.json');
967
- case 'codex':
968
- return path.join(home, '.codex', 'config.toml');
969
- case 'opencode':
970
- return path.join(home, '.opencode', 'opencode.jsonc');
971
- case 'cursor':
972
- return path.join(home, '.cursor', 'mcp.json');
973
- case 'openclaw':
974
- return path.join(home, '.openclaw', 'openclaw.json');
975
- case 'copilot':
976
- return path.join(home, '.copilot', 'mcp-config.json');
977
- case 'amp':
978
- return path.join(home, '.config', 'amp', 'settings.json');
979
- case 'kiro':
980
- return path.join(home, '.kiro', 'settings', 'mcp.json');
981
- case 'goose':
982
- return path.join(home, '.config', 'goose', 'config.yaml');
983
- case 'roo':
984
- return path.join(home, '.roo', 'mcp.json');
985
- default:
986
- return path.join(home, `.${agentId}`, 'settings.json');
987
- }
988
- }
989
- /**
990
- * Get project-scoped MCP config path for an agent.
991
- */
992
- function getProjectMcpConfigPath(agentId, cwd = process.cwd()) {
993
- switch (agentId) {
994
- case 'claude':
995
- // Claude uses .mcp.json at project root for project-scoped MCPs
996
- return path.join(cwd, '.mcp.json');
997
- case 'codex':
998
- return path.join(cwd, `.${agentId}`, 'config.toml');
999
- case 'opencode':
1000
- return path.join(cwd, `.${agentId}`, 'opencode.jsonc');
1001
- case 'cursor':
1002
- return path.join(cwd, `.${agentId}`, 'mcp.json');
1003
- case 'openclaw':
1004
- return path.join(cwd, `.${agentId}`, 'openclaw.json');
1005
- case 'gemini':
1006
- return path.join(cwd, `.${agentId}`, 'settings.json');
1007
- case 'copilot':
1008
- return path.join(cwd, '.copilot', 'mcp-config.json');
1009
- case 'amp':
1010
- return path.join(cwd, '.amp', 'settings.json');
1011
- case 'kiro':
1012
- return path.join(cwd, '.kiro', 'settings', 'mcp.json');
1013
- case 'goose':
1014
- return path.join(cwd, '.goose', 'config.yaml');
1015
- case 'roo':
1016
- return path.join(cwd, '.roo', 'mcp.json');
1017
- default:
1018
- return path.join(cwd, `.${agentId}`, 'settings.json');
1019
- }
1020
- }
1021
- /**
1022
- * Parse MCP servers from OpenClaw's JSON config.
1023
- * OpenClaw stores MCPs under mcp.servers with a similar structure to other agents.
1024
- */
1025
- function parseMcpFromOpenClawConfig(configPath) {
1026
- if (!fs.existsSync(configPath)) {
1027
- return {};
1028
- }
1029
- try {
1030
- const content = fs.readFileSync(configPath, 'utf-8');
1031
- const config = JSON.parse(content);
1032
- // OpenClaw uses mcp.servers for MCP configuration
1033
- const mcpServers = config.mcp?.servers;
1034
- if (!mcpServers)
1035
- return {};
1036
- const result = {};
1037
- for (const [name, entry] of Object.entries(mcpServers)) {
1038
- if (entry.command) {
1039
- result[name] = {
1040
- command: entry.command,
1041
- args: entry.args,
1042
- env: entry.env,
1043
- };
1044
- }
1045
- else if (entry.url) {
1046
- result[name] = {
1047
- url: entry.url,
1048
- type: entry.transport || 'sse',
1049
- };
1050
- }
1051
- }
1052
- return result;
1053
- }
1054
- catch {
1055
- /* OpenClaw JSON config corrupt or unreadable */
1056
- return {};
1057
- }
1058
- }
1059
- /**
1060
- * Parse MCP config based on agent type.
1061
- */
1062
- export function parseMcpConfig(agentId, configPath) {
1063
- switch (agentId) {
1064
- case 'codex':
1065
- return parseMcpFromTomlConfig(configPath);
1066
- case 'opencode':
1067
- return parseMcpFromOpenCodeConfig(configPath);
1068
- case 'openclaw':
1069
- return parseMcpFromOpenClawConfig(configPath);
1070
- default:
1071
- return parseMcpFromJsonConfig(configPath);
1072
- }
1073
- }
1074
- /**
1075
- * List installed MCP servers with scope information.
1076
- * Pass options.home to read from a version-managed agent's home directory.
1077
- */
1078
- export function listInstalledMcpsWithScope(agentId, cwd = process.cwd(), options) {
1079
- const results = [];
1080
- // Helper to build full command string
1081
- const buildCommand = (config) => {
1082
- if (config.command && config.args?.length) {
1083
- return `${config.command} ${config.args.join(' ')}`;
1084
- }
1085
- return config.command || (config.args ? config.args.join(' ') : undefined);
1086
- };
1087
- // User-scoped MCPs (version-aware when home is provided)
1088
- const userConfigPath = options?.home
1089
- ? getMcpConfigPathForHome(agentId, options.home)
1090
- : getUserMcpConfigPath(agentId);
1091
- const userMcps = parseMcpConfig(agentId, userConfigPath);
1092
- for (const [name, config] of Object.entries(userMcps)) {
1093
- results.push({
1094
- name,
1095
- scope: 'user',
1096
- command: buildCommand(config),
1097
- version: config.args ? extractNpmVersion(config.args) : undefined,
1098
- });
1099
- }
1100
- // Project-scoped MCPs
1101
- const projectConfigPath = getProjectMcpConfigPath(agentId, cwd);
1102
- const projectMcps = parseMcpConfig(agentId, projectConfigPath);
1103
- for (const [name, config] of Object.entries(projectMcps)) {
1104
- // Skip if already in user scope (project can override, but we show both)
1105
- results.push({
1106
- name,
1107
- scope: 'project',
1108
- command: buildCommand(config),
1109
- version: config.args ? extractNpmVersion(config.args) : undefined,
1110
- });
1111
- }
1112
- return results;
1113
- }
1114
- /** Map of agent name aliases and shorthand identifiers to canonical AgentId values. */
1115
- export const AGENT_NAME_ALIASES = {
1116
- claude: 'claude',
1117
- 'claude-code': 'claude',
1118
- cc: 'claude',
1119
- codex: 'codex',
1120
- 'openai-codex': 'codex',
1121
- cx: 'codex',
1122
- gemini: 'gemini',
1123
- 'gemini-cli': 'gemini',
1124
- gx: 'gemini',
1125
- cursor: 'cursor',
1126
- 'cursor-agent': 'cursor',
1127
- cr: 'cursor',
1128
- opencode: 'opencode',
1129
- oc: 'opencode',
1130
- openclaw: 'openclaw',
1131
- claw: 'openclaw',
1132
- ocl: 'openclaw',
1133
- copilot: 'copilot',
1134
- 'copilot-cli': 'copilot',
1135
- 'github-copilot': 'copilot',
1136
- gh: 'copilot',
1137
- amp: 'amp',
1138
- sourcegraph: 'amp',
1139
- kiro: 'kiro',
1140
- 'kiro-cli': 'kiro',
1141
- goose: 'goose',
1142
- 'block-goose': 'goose',
1143
- roo: 'roo',
1144
- 'roo-code': 'roo',
1145
- roocode: 'roo',
1146
- };
1147
- /** Resolve a user-provided agent name (alias, shorthand, or canonical) to its AgentId. */
1148
- export function resolveAgentName(input) {
1149
- return AGENT_NAME_ALIASES[input.toLowerCase()] || null;
1150
- }
1151
- /** Check whether the input string matches any known agent name or alias. */
1152
- export function isAgentName(input) {
1153
- return resolveAgentName(input) !== null;
1154
- }
1155
- /** Format an error message for an unrecognized agent name, listing valid options. */
1156
- export function formatAgentError(agentName, validAgents = ALL_AGENT_IDS) {
1157
- return `Unknown agent '${agentName}'. Valid agents: ${validAgents.join(', ')}`;
1158
- }
1159
- //# sourceMappingURL=agents.js.map