@swarmify/agents-cli 1.13.3 → 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 -1071
  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
package/dist/lib/hooks.js DELETED
@@ -1,846 +0,0 @@
1
- /**
2
- * Hook management -- discovery, registration, and syncing of event hooks.
3
- *
4
- * Hooks are shell scripts in ~/.agents/hooks/ that fire on agent events
5
- * (tool calls, session start, etc.). Each hook directory contains a manifest
6
- * (agents.yaml) declaring events, matchers, and timeout. This module handles
7
- * parsing those manifests, registering hooks into agent-native settings files,
8
- * and syncing them across version switches.
9
- */
10
- import * as fs from 'fs';
11
- import * as path from 'path';
12
- import * as yaml from 'yaml';
13
- import * as TOML from 'smol-toml';
14
- import { AGENTS, HOOKS_CAPABLE_AGENTS } from './agents.js';
15
- import { getAgentsDir, getHooksDir as getCentralHooksDir, getProjectAgentsDir } from './state.js';
16
- import { getEffectiveHome, getVersionHomePath, listInstalledVersions } from './versions.js';
17
- const SCRIPT_EXTENSIONS = new Set([
18
- '.sh',
19
- '.bash',
20
- '.zsh',
21
- '.py',
22
- '.js',
23
- '.ts',
24
- '.mjs',
25
- '.cjs',
26
- '.rb',
27
- '.pl',
28
- '.ps1',
29
- '.cmd',
30
- '.bat',
31
- ]);
32
- function isExecutable(mode) {
33
- return (mode & 0o111) !== 0;
34
- }
35
- function getHooksDir(agentId) {
36
- const agent = AGENTS[agentId];
37
- const home = getEffectiveHome(agentId);
38
- return path.join(home, `.${agentId}`, agent.hooksDir);
39
- }
40
- function getProjectHooksDirs(agentId, cwd) {
41
- const agent = AGENTS[agentId];
42
- const dirs = [];
43
- const projectAgentsDir = getProjectAgentsDir(cwd);
44
- if (projectAgentsDir) {
45
- dirs.push(path.join(projectAgentsDir, 'hooks'));
46
- }
47
- dirs.push(path.join(cwd, `.${agentId}`, agent.hooksDir));
48
- return dirs;
49
- }
50
- function ensureDir(dir) {
51
- if (!fs.existsSync(dir)) {
52
- fs.mkdirSync(dir, { recursive: true });
53
- }
54
- }
55
- function removeHookFiles(dir, name) {
56
- if (!fs.existsSync(dir)) {
57
- return;
58
- }
59
- const files = fs.readdirSync(dir);
60
- for (const file of files) {
61
- const ext = path.extname(file);
62
- const base = path.basename(file, ext);
63
- if (base === name) {
64
- const fullPath = path.join(dir, file);
65
- const stat = fs.statSync(fullPath);
66
- if (stat.isFile()) {
67
- fs.unlinkSync(fullPath);
68
- }
69
- }
70
- }
71
- }
72
- function listHookEntriesFromDir(dir) {
73
- if (!fs.existsSync(dir)) {
74
- return [];
75
- }
76
- const files = [];
77
- for (const file of fs.readdirSync(dir)) {
78
- const fullPath = path.join(dir, file);
79
- const stat = fs.statSync(fullPath);
80
- if (!stat.isFile())
81
- continue;
82
- const ext = path.extname(file);
83
- const base = path.basename(file, ext);
84
- files.push({
85
- name: file,
86
- base,
87
- ext,
88
- fullPath,
89
- isExec: isExecutable(stat.mode),
90
- });
91
- }
92
- const grouped = new Map();
93
- for (const file of files) {
94
- const list = grouped.get(file.base) || [];
95
- list.push(file);
96
- grouped.set(file.base, list);
97
- }
98
- const entries = [];
99
- for (const [base, group] of grouped) {
100
- group.sort((a, b) => a.name.localeCompare(b.name));
101
- const script = group.find((f) => f.isExec) ||
102
- group.find((f) => SCRIPT_EXTENSIONS.has(f.ext.toLowerCase())) ||
103
- group[0];
104
- if (!script)
105
- continue;
106
- const data = group.find((f) => f !== script);
107
- entries.push({
108
- name: base,
109
- scriptPath: script.fullPath,
110
- dataFile: data ? data.fullPath : undefined,
111
- });
112
- }
113
- entries.sort((a, b) => a.name.localeCompare(b.name));
114
- return entries;
115
- }
116
- function buildHookMap(entries) {
117
- const map = new Map();
118
- for (const entry of entries) {
119
- map.set(entry.name, entry);
120
- }
121
- return map;
122
- }
123
- function copyHook(entry, targetDir) {
124
- ensureDir(targetDir);
125
- removeHookFiles(targetDir, entry.name);
126
- const scriptTarget = path.join(targetDir, path.basename(entry.scriptPath));
127
- fs.copyFileSync(entry.scriptPath, scriptTarget);
128
- const scriptStat = fs.statSync(entry.scriptPath);
129
- fs.chmodSync(scriptTarget, scriptStat.mode);
130
- if (entry.dataFile) {
131
- const dataTarget = path.join(targetDir, path.basename(entry.dataFile));
132
- fs.copyFileSync(entry.dataFile, dataTarget);
133
- }
134
- }
135
- /**
136
- * Check if a hook exists for an agent.
137
- */
138
- export function hookExists(agentId, hookName) {
139
- const agent = AGENTS[agentId];
140
- if (!agent.supportsHooks) {
141
- return false;
142
- }
143
- const hooksDir = getHooksDir(agentId);
144
- if (!fs.existsSync(hooksDir)) {
145
- return false;
146
- }
147
- const files = fs.readdirSync(hooksDir);
148
- return files.some((file) => {
149
- const ext = path.extname(file);
150
- const baseName = path.basename(file, ext);
151
- return baseName === hookName && SCRIPT_EXTENSIONS.has(ext);
152
- });
153
- }
154
- /**
155
- * Normalize content for comparison (trim, normalize line endings).
156
- */
157
- function normalizeContent(content) {
158
- return content.replace(/\r\n/g, '\n').trim();
159
- }
160
- /**
161
- * Get the installed hook entry for an agent.
162
- */
163
- function getInstalledHookEntry(agentId, hookName) {
164
- const hooksDir = getHooksDir(agentId);
165
- const entries = listHookEntriesFromDir(hooksDir);
166
- return entries.find((e) => e.name === hookName) || null;
167
- }
168
- /**
169
- * Check if installed hook content matches source hook content.
170
- * Compares both script file and data file (if present).
171
- */
172
- export function hookContentMatches(agentId, hookName, sourceEntry) {
173
- const agent = AGENTS[agentId];
174
- if (!agent.supportsHooks) {
175
- return false;
176
- }
177
- const installedEntry = getInstalledHookEntry(agentId, hookName);
178
- if (!installedEntry) {
179
- return false;
180
- }
181
- try {
182
- const installedScript = fs.readFileSync(installedEntry.scriptPath, 'utf-8');
183
- const sourceScript = fs.readFileSync(sourceEntry.scriptPath, 'utf-8');
184
- if (normalizeContent(installedScript) !== normalizeContent(sourceScript)) {
185
- return false;
186
- }
187
- const hasInstalledData = !!installedEntry.dataFile;
188
- const hasSourceData = !!sourceEntry.dataFile;
189
- if (hasInstalledData !== hasSourceData) {
190
- return false;
191
- }
192
- if (hasInstalledData && hasSourceData) {
193
- const installedData = fs.readFileSync(installedEntry.dataFile, 'utf-8');
194
- const sourceData = fs.readFileSync(sourceEntry.dataFile, 'utf-8');
195
- if (normalizeContent(installedData) !== normalizeContent(sourceData)) {
196
- return false;
197
- }
198
- }
199
- return true;
200
- }
201
- catch {
202
- return false;
203
- }
204
- }
205
- export function listInstalledHooksWithScope(agentId, cwd = process.cwd(), options) {
206
- const agent = AGENTS[agentId];
207
- if (!agent.supportsHooks) {
208
- return [];
209
- }
210
- const results = [];
211
- const seen = new Set();
212
- const addHook = (hook, scope, agentId) => {
213
- if (seen.has(hook.name))
214
- return;
215
- results.push({
216
- name: hook.name,
217
- path: hook.scriptPath,
218
- dataFile: hook.dataFile,
219
- scope,
220
- agent: agentId,
221
- });
222
- seen.add(hook.name);
223
- };
224
- // Project-scoped hooks (project .agents overrides agent-specific dirs)
225
- const projectDirs = getProjectHooksDirs(agentId, cwd);
226
- for (const dir of projectDirs) {
227
- const projectHooks = listHookEntriesFromDir(dir);
228
- for (const hook of projectHooks) {
229
- addHook(hook, 'project', agentId);
230
- }
231
- }
232
- // User-scoped hooks (version-aware when home is provided)
233
- const home = options?.home || getEffectiveHome(agentId);
234
- const userDir = path.join(home, `.${agentId}`, agent.hooksDir);
235
- const userHooks = listHookEntriesFromDir(userDir);
236
- for (const hook of userHooks) {
237
- addHook(hook, 'user', agentId);
238
- }
239
- return results;
240
- }
241
- export async function installHooks(source, agents, options = {}) {
242
- const installed = [];
243
- const errors = [];
244
- const scope = options.scope || 'user';
245
- const cwd = process.cwd();
246
- const hooksDir = path.join(source, 'hooks');
247
- const hooks = listHookEntriesFromDir(hooksDir);
248
- const uniqueAgents = Array.from(new Set(agents));
249
- for (const agentId of uniqueAgents) {
250
- const agent = AGENTS[agentId];
251
- if (!agent || !agent.supportsHooks) {
252
- errors.push(`${agentId}:Agent does not support hooks`);
253
- continue;
254
- }
255
- const targetDir = scope === 'project' ? getProjectHooksDirs(agentId, cwd)[0] : getHooksDir(agentId);
256
- for (const entry of hooks) {
257
- try {
258
- copyHook(entry, targetDir);
259
- installed.push(`${entry.name}:${agentId}`);
260
- }
261
- catch (err) {
262
- errors.push(`${entry.name}:${agentId}:${err.message}`);
263
- }
264
- }
265
- }
266
- return { installed, errors };
267
- }
268
- /**
269
- * Path to the hooks dir of a specific version home (not the active one).
270
- */
271
- export function getVersionHooksDir(agent, version) {
272
- const home = getVersionHomePath(agent, version);
273
- return path.join(home, `.${agent}`, AGENTS[agent].hooksDir);
274
- }
275
- /**
276
- * List hook entries in a specific version home.
277
- */
278
- export function listHooksInVersionHome(agent, version) {
279
- return listHookEntriesFromDir(getVersionHooksDir(agent, version));
280
- }
281
- /**
282
- * Check if a hook installed in a specific version matches central content.
283
- */
284
- function versionHookMatches(agent, version, hookName) {
285
- const central = listHookEntriesFromDir(getCentralHooksDir()).find((e) => e.name === hookName);
286
- if (!central)
287
- return false;
288
- const installed = listHooksInVersionHome(agent, version).find((e) => e.name === hookName);
289
- if (!installed)
290
- return false;
291
- try {
292
- if (normalizeContent(fs.readFileSync(installed.scriptPath, 'utf-8')) !==
293
- normalizeContent(fs.readFileSync(central.scriptPath, 'utf-8'))) {
294
- return false;
295
- }
296
- if (!!installed.dataFile !== !!central.dataFile)
297
- return false;
298
- if (installed.dataFile && central.dataFile) {
299
- if (normalizeContent(fs.readFileSync(installed.dataFile, 'utf-8')) !==
300
- normalizeContent(fs.readFileSync(central.dataFile, 'utf-8'))) {
301
- return false;
302
- }
303
- }
304
- return true;
305
- }
306
- catch {
307
- return false;
308
- }
309
- }
310
- /**
311
- * Compare a version home's hooks against central. Returns the reconciliation diff.
312
- */
313
- export function diffVersionHooks(agent, version) {
314
- const central = new Set(listHookEntriesFromDir(getCentralHooksDir()).map((e) => e.name));
315
- const installed = new Set(listHooksInVersionHome(agent, version).map((e) => e.name));
316
- const toAdd = [];
317
- const toUpdate = [];
318
- const matched = [];
319
- const orphans = [];
320
- for (const name of central) {
321
- if (!installed.has(name)) {
322
- toAdd.push(name);
323
- }
324
- else if (!versionHookMatches(agent, version, name)) {
325
- toUpdate.push(name);
326
- }
327
- else {
328
- matched.push(name);
329
- }
330
- }
331
- for (const name of installed) {
332
- if (!central.has(name))
333
- orphans.push(name);
334
- }
335
- return { agent, version, toAdd: toAdd.sort(), toUpdate: toUpdate.sort(), matched, orphans: orphans.sort() };
336
- }
337
- /**
338
- * Install a single hook from central into a specific version home.
339
- */
340
- export function installHookToVersion(agent, version, hookName) {
341
- const central = listHookEntriesFromDir(getCentralHooksDir()).find((e) => e.name === hookName);
342
- if (!central) {
343
- return { success: false, error: `Hook '${hookName}' not found in central` };
344
- }
345
- const targetDir = getVersionHooksDir(agent, version);
346
- try {
347
- fs.mkdirSync(targetDir, { recursive: true });
348
- copyHook(central, targetDir);
349
- }
350
- catch (err) {
351
- return { success: false, error: err.message };
352
- }
353
- return { success: true };
354
- }
355
- /**
356
- * Remove a single hook (script + data file) from a specific version home.
357
- */
358
- export function removeHookFromVersion(agent, version, hookName) {
359
- try {
360
- removeHookFiles(getVersionHooksDir(agent, version), hookName);
361
- }
362
- catch (err) {
363
- return { success: false, error: err.message };
364
- }
365
- return { success: true };
366
- }
367
- /**
368
- * Iterate all (agent, version) pairs that support hooks and are installed,
369
- * optionally scoped to a single agent/version.
370
- */
371
- export function iterHooksCapableVersions(filter) {
372
- const pairs = [];
373
- const hookAgents = HOOKS_CAPABLE_AGENTS;
374
- const agents = filter?.agent ? [filter.agent] : hookAgents;
375
- for (const agent of agents) {
376
- if (!hookAgents.includes(agent))
377
- continue;
378
- const versions = listInstalledVersions(agent);
379
- for (const version of versions) {
380
- if (filter?.version && filter.version !== version)
381
- continue;
382
- pairs.push({ agent, version });
383
- }
384
- }
385
- return pairs;
386
- }
387
- export async function removeHook(name, agents) {
388
- const removed = [];
389
- const errors = [];
390
- const uniqueAgents = Array.from(new Set(agents));
391
- for (const agentId of uniqueAgents) {
392
- const agent = AGENTS[agentId];
393
- if (!agent || !agent.supportsHooks) {
394
- errors.push(`${agentId}:Agent does not support hooks`);
395
- continue;
396
- }
397
- try {
398
- const dir = getHooksDir(agentId);
399
- const filesBefore = fs.existsSync(dir) ? fs.readdirSync(dir) : [];
400
- removeHookFiles(dir, name);
401
- const filesAfter = fs.existsSync(dir) ? fs.readdirSync(dir) : [];
402
- if (filesBefore.length !== filesAfter.length) {
403
- removed.push(`${name}:${agentId}`);
404
- }
405
- }
406
- catch (err) {
407
- errors.push(`${name}:${agentId}:${err.message}`);
408
- }
409
- }
410
- return { removed, errors };
411
- }
412
- /**
413
- * Get detailed info about a hook from central storage.
414
- */
415
- export function getHookInfo(name) {
416
- const centralDir = getCentralHooksDir();
417
- const hookPath = path.join(centralDir, name);
418
- if (!fs.existsSync(hookPath)) {
419
- return null;
420
- }
421
- // Read hook content - it could be a file or directory
422
- let content = '';
423
- const stat = fs.statSync(hookPath);
424
- if (stat.isFile()) {
425
- content = fs.readFileSync(hookPath, 'utf-8');
426
- }
427
- else if (stat.isDirectory()) {
428
- // For directory hooks, list the files
429
- const files = fs.readdirSync(hookPath);
430
- content = `Directory hook containing:\n${files.map((f) => ` - ${f}`).join('\n')}`;
431
- }
432
- return {
433
- name,
434
- path: hookPath,
435
- content,
436
- };
437
- }
438
- export function discoverHooksFromRepo(repoPath) {
439
- const hooksDir = path.join(repoPath, 'hooks');
440
- return listHookEntriesFromDir(hooksDir).map((h) => h.name);
441
- }
442
- /**
443
- * Get the source hook entry from repo.
444
- */
445
- export function getSourceHookEntry(repoPath, hookName) {
446
- const hooksDir = path.join(repoPath, 'hooks');
447
- const entries = listHookEntriesFromDir(hooksDir);
448
- return entries.find((e) => e.name === hookName) || null;
449
- }
450
- /**
451
- * Install hooks to central ~/.agents/hooks/ directory.
452
- * Shims will symlink this to per-agent directories for synced agents.
453
- */
454
- export async function installHooksCentrally(source) {
455
- const installed = [];
456
- const errors = [];
457
- const centralDir = getCentralHooksDir();
458
- if (!fs.existsSync(centralDir)) {
459
- fs.mkdirSync(centralDir, { recursive: true });
460
- }
461
- // Collect all hooks from shared directory
462
- const sharedDir = path.join(source, 'hooks');
463
- const sharedHooks = listHookEntriesFromDir(sharedDir);
464
- for (const entry of sharedHooks) {
465
- try {
466
- copyHook(entry, centralDir);
467
- installed.push(entry.name);
468
- }
469
- catch (err) {
470
- errors.push(`${entry.name}: ${err.message}`);
471
- }
472
- }
473
- return { installed, errors };
474
- }
475
- /**
476
- * List hooks from central ~/.agents/hooks/ directory.
477
- */
478
- export function listCentralHooks() {
479
- return listHookEntriesFromDir(getCentralHooksDir());
480
- }
481
- /**
482
- * Parse ~/.agents/hooks.yaml manifest.
483
- * Returns hook definitions with lifecycle event metadata.
484
- */
485
- export function parseHookManifest() {
486
- const manifestPath = path.join(getAgentsDir(), 'hooks.yaml');
487
- if (!fs.existsSync(manifestPath)) {
488
- return {};
489
- }
490
- try {
491
- const content = fs.readFileSync(manifestPath, 'utf-8');
492
- const parsed = yaml.parse(content);
493
- return parsed || {};
494
- }
495
- catch {
496
- return {};
497
- }
498
- }
499
- // Codex events that support a matcher field (matches tool name or session type).
500
- // UserPromptSubmit and Stop never include a matcher.
501
- const CODEX_MATCHER_EVENTS = new Set(['PreToolUse', 'PostToolUse', 'SessionStart']);
502
- /**
503
- * Register hooks as lifecycle events in an agent's config.
504
- * Reads hooks.yaml manifest, merges into the agent's config file(s).
505
- * Only manages hooks whose command paths are under ~/.agents/hooks/.
506
- * Does not remove user-added hooks.
507
- *
508
- * @param agentsDirOverride - Override the agents dir (used in tests to inject a temp path).
509
- */
510
- export function registerHooksToSettings(agentId, versionHome, hookManifest, agentsDirOverride) {
511
- const manifest = hookManifest || parseHookManifest();
512
- if (Object.keys(manifest).length === 0) {
513
- return { registered: [], errors: [] };
514
- }
515
- const agentsDir = agentsDirOverride ?? getAgentsDir();
516
- if (agentId === 'claude') {
517
- return registerHooksForClaude(versionHome, manifest, agentsDir);
518
- }
519
- if (agentId === 'codex') {
520
- return registerHooksForCodex(versionHome, manifest, agentsDir);
521
- }
522
- if (agentId === 'gemini') {
523
- return registerHooksForGemini(versionHome, manifest, agentsDir);
524
- }
525
- return { registered: [], errors: [] };
526
- }
527
- /**
528
- * Gemini has no native UserPromptSubmit event — map it to BeforeAgent,
529
- * the closest lifecycle phase that fires before the model sees the prompt.
530
- * Note: gemini's BeforeAgent can only APPEND via additionalContext — it
531
- * cannot replace the prompt. The hook script branches on caller to emit
532
- * the correct protocol.
533
- */
534
- const GEMINI_EVENT_MAP = {
535
- UserPromptSubmit: 'BeforeAgent',
536
- };
537
- function registerHooksForClaude(versionHome, manifest, agentsDir) {
538
- const registered = [];
539
- const errors = [];
540
- const configDir = path.join(versionHome, '.claude');
541
- const settingsPath = path.join(configDir, 'settings.json');
542
- let config = {};
543
- if (fs.existsSync(settingsPath)) {
544
- try {
545
- config = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
546
- }
547
- catch {
548
- errors.push('Failed to parse settings.json');
549
- return { registered, errors };
550
- }
551
- }
552
- if (!config.hooks || typeof config.hooks !== 'object') {
553
- config.hooks = {};
554
- }
555
- const hooks = config.hooks;
556
- // Build set of all command paths the current manifest will register.
557
- // Used to garbage-collect stale entries left behind after hook renames.
558
- const managedHooksPrefix = path.join(agentsDir, 'hooks') + path.sep;
559
- const currentManifestPaths = new Set();
560
- for (const hookDef of Object.values(manifest)) {
561
- if (hookDef.agents && !hookDef.agents.includes('claude'))
562
- continue;
563
- if (!hookDef.events || hookDef.events.length === 0)
564
- continue;
565
- currentManifestPaths.add(path.join(agentsDir, 'hooks', hookDef.script));
566
- }
567
- // Remove stale entries: any hook command under ~/.agents/hooks/ that isn't
568
- // in the current manifest is a leftover from a renamed/deleted hook script.
569
- for (const eventEntries of Object.values(hooks)) {
570
- if (!Array.isArray(eventEntries))
571
- continue;
572
- for (const group of eventEntries) {
573
- if (!group.hooks)
574
- continue;
575
- group.hooks = group.hooks.filter((h) => !h.command.startsWith(managedHooksPrefix) || currentManifestPaths.has(h.command));
576
- }
577
- }
578
- // Remove empty matcher groups left after cleanup
579
- for (const [event, eventEntries] of Object.entries(hooks)) {
580
- if (!Array.isArray(eventEntries))
581
- continue;
582
- hooks[event] = eventEntries.filter((g) => g.hooks && g.hooks.length > 0);
583
- }
584
- for (const [name, hookDef] of Object.entries(manifest)) {
585
- if (hookDef.agents && !hookDef.agents.includes('claude'))
586
- continue;
587
- if (!hookDef.events || hookDef.events.length === 0)
588
- continue;
589
- const commandPath = path.join(agentsDir, 'hooks', hookDef.script);
590
- if (!fs.existsSync(commandPath)) {
591
- errors.push(`${name}: script not found at ${commandPath}`);
592
- continue;
593
- }
594
- for (const event of hookDef.events) {
595
- if (!hooks[event]) {
596
- hooks[event] = [];
597
- }
598
- const eventEntries = hooks[event];
599
- const matcher = hookDef.matcher || '';
600
- const timeout = hookDef.timeout || 600;
601
- let matcherGroup = eventEntries.find((e) => (e.matcher || '') === matcher);
602
- if (!matcherGroup) {
603
- matcherGroup = { matcher, hooks: [] };
604
- eventEntries.push(matcherGroup);
605
- }
606
- if (!matcherGroup.hooks) {
607
- matcherGroup.hooks = [];
608
- }
609
- const existingIdx = matcherGroup.hooks.findIndex((h) => h.command === commandPath);
610
- const hookEntry = { type: 'command', command: commandPath, timeout };
611
- if (existingIdx >= 0) {
612
- matcherGroup.hooks[existingIdx] = hookEntry;
613
- }
614
- else {
615
- matcherGroup.hooks.push(hookEntry);
616
- }
617
- registered.push(`${name} -> ${event}`);
618
- }
619
- }
620
- try {
621
- fs.mkdirSync(configDir, { recursive: true });
622
- fs.writeFileSync(settingsPath, JSON.stringify(config, null, 2), 'utf-8');
623
- }
624
- catch (err) {
625
- errors.push(`Failed to write settings.json: ${err.message}`);
626
- }
627
- return { registered, errors };
628
- }
629
- function registerHooksForCodex(versionHome, manifest, agentsDir) {
630
- const registered = [];
631
- const errors = [];
632
- const configDir = path.join(versionHome, '.codex');
633
- const hooksPath = path.join(configDir, 'hooks.json');
634
- const configPath = path.join(configDir, 'config.toml');
635
- // Read existing hooks.json — must have top-level "hooks" wrapper key
636
- let hooksFile = { hooks: {} };
637
- if (fs.existsSync(hooksPath)) {
638
- try {
639
- const existing = JSON.parse(fs.readFileSync(hooksPath, 'utf-8'));
640
- if (existing &&
641
- typeof existing === 'object' &&
642
- !Array.isArray(existing) &&
643
- existing.hooks &&
644
- typeof existing.hooks === 'object') {
645
- hooksFile = existing;
646
- }
647
- }
648
- catch {
649
- errors.push('Failed to parse hooks.json');
650
- return { registered, errors };
651
- }
652
- }
653
- // Build set of current manifest command paths for codex to GC stale entries
654
- const managedHooksPrefix = path.join(agentsDir, 'hooks') + path.sep;
655
- const currentManifestPaths = new Set();
656
- for (const hookDef of Object.values(manifest)) {
657
- if (hookDef.agents && !hookDef.agents.includes('codex'))
658
- continue;
659
- if (!hookDef.events || hookDef.events.length === 0)
660
- continue;
661
- currentManifestPaths.add(path.join(agentsDir, 'hooks', hookDef.script));
662
- }
663
- // Remove stale entries from all event groups
664
- for (const eventGroups of Object.values(hooksFile.hooks)) {
665
- for (const group of eventGroups) {
666
- if (!group.hooks)
667
- continue;
668
- group.hooks = group.hooks.filter((h) => !h.command.startsWith(managedHooksPrefix) || currentManifestPaths.has(h.command));
669
- }
670
- }
671
- for (const [event, eventGroups] of Object.entries(hooksFile.hooks)) {
672
- hooksFile.hooks[event] = eventGroups.filter((g) => g.hooks && g.hooks.length > 0);
673
- }
674
- for (const [name, hookDef] of Object.entries(manifest)) {
675
- if (hookDef.agents && !hookDef.agents.includes('codex'))
676
- continue;
677
- if (!hookDef.events || hookDef.events.length === 0)
678
- continue;
679
- const commandPath = path.join(agentsDir, 'hooks', hookDef.script);
680
- if (!fs.existsSync(commandPath)) {
681
- errors.push(`${name}: script not found at ${commandPath}`);
682
- continue;
683
- }
684
- const timeout = hookDef.timeout || 600;
685
- for (const event of hookDef.events) {
686
- if (!hooksFile.hooks[event]) {
687
- hooksFile.hooks[event] = [];
688
- }
689
- const eventGroups = hooksFile.hooks[event];
690
- // PreToolUse / PostToolUse / SessionStart use a matcher field.
691
- // UserPromptSubmit / Stop never include a matcher.
692
- const usesMatcher = CODEX_MATCHER_EVENTS.has(event);
693
- const matcherValue = usesMatcher ? (hookDef.matcher ?? '') : undefined;
694
- // Find the group for this matcher (or the sole no-matcher group)
695
- let group;
696
- if (matcherValue !== undefined) {
697
- group = eventGroups.find((g) => (g.matcher ?? '') === matcherValue);
698
- if (!group) {
699
- group = matcherValue ? { matcher: matcherValue, hooks: [] } : { hooks: [] };
700
- eventGroups.push(group);
701
- }
702
- }
703
- else {
704
- group = eventGroups.find((g) => g.matcher === undefined);
705
- if (!group) {
706
- group = { hooks: [] };
707
- eventGroups.push(group);
708
- }
709
- }
710
- if (!group.hooks) {
711
- group.hooks = [];
712
- }
713
- const existingIdx = group.hooks.findIndex((h) => h.command === commandPath);
714
- const hookEntry = { type: 'command', command: commandPath, timeout };
715
- if (existingIdx >= 0) {
716
- group.hooks[existingIdx] = hookEntry;
717
- }
718
- else {
719
- group.hooks.push(hookEntry);
720
- }
721
- registered.push(`${name} -> ${event}`);
722
- }
723
- }
724
- if (registered.length === 0) {
725
- return { registered, errors };
726
- }
727
- try {
728
- fs.mkdirSync(configDir, { recursive: true });
729
- fs.writeFileSync(hooksPath, JSON.stringify(hooksFile, null, 2), 'utf-8');
730
- }
731
- catch (err) {
732
- errors.push(`Failed to write hooks.json: ${err.message}`);
733
- return { registered, errors };
734
- }
735
- // Ensure [features] codex_hooks = true in config.toml
736
- try {
737
- let tomlConfig = {};
738
- if (fs.existsSync(configPath)) {
739
- try {
740
- tomlConfig = TOML.parse(fs.readFileSync(configPath, 'utf-8'));
741
- }
742
- catch { /* start fresh if corrupt */ }
743
- }
744
- if (!tomlConfig.features || typeof tomlConfig.features !== 'object') {
745
- tomlConfig.features = {};
746
- }
747
- tomlConfig.features.codex_hooks = true;
748
- fs.writeFileSync(configPath, TOML.stringify(tomlConfig), 'utf-8');
749
- }
750
- catch (err) {
751
- errors.push(`Failed to update config.toml: ${err.message}`);
752
- }
753
- return { registered, errors };
754
- }
755
- function registerHooksForGemini(versionHome, manifest, agentsDir) {
756
- const registered = [];
757
- const errors = [];
758
- const configDir = path.join(versionHome, '.gemini');
759
- const settingsPath = path.join(configDir, 'settings.json');
760
- let config = {};
761
- if (fs.existsSync(settingsPath)) {
762
- try {
763
- config = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
764
- }
765
- catch {
766
- errors.push('Failed to parse gemini settings.json');
767
- return { registered, errors };
768
- }
769
- }
770
- if (!config.hooks || typeof config.hooks !== 'object') {
771
- config.hooks = {};
772
- }
773
- const hooks = config.hooks;
774
- // Build set of current manifest command paths for gemini to GC stale entries
775
- const managedHooksPrefix = path.join(agentsDir, 'hooks') + path.sep;
776
- const currentManifestPaths = new Set();
777
- for (const hookDef of Object.values(manifest)) {
778
- if (hookDef.agents && !hookDef.agents.includes('gemini'))
779
- continue;
780
- if (!hookDef.events || hookDef.events.length === 0)
781
- continue;
782
- currentManifestPaths.add(path.join(agentsDir, 'hooks', hookDef.script));
783
- }
784
- // Remove stale entries
785
- for (const eventEntries of Object.values(hooks)) {
786
- if (!Array.isArray(eventEntries))
787
- continue;
788
- for (const group of eventEntries) {
789
- if (!group.hooks)
790
- continue;
791
- group.hooks = group.hooks.filter((h) => !h.command.startsWith(managedHooksPrefix) || currentManifestPaths.has(h.command));
792
- }
793
- }
794
- for (const [event, eventEntries] of Object.entries(hooks)) {
795
- if (!Array.isArray(eventEntries))
796
- continue;
797
- hooks[event] = eventEntries.filter((g) => g.hooks && g.hooks.length > 0);
798
- }
799
- for (const [name, hookDef] of Object.entries(manifest)) {
800
- if (hookDef.agents && !hookDef.agents.includes('gemini'))
801
- continue;
802
- if (!hookDef.events || hookDef.events.length === 0)
803
- continue;
804
- const commandPath = path.join(agentsDir, 'hooks', hookDef.script);
805
- if (!fs.existsSync(commandPath)) {
806
- errors.push(`${name}: script not found at ${commandPath}`);
807
- continue;
808
- }
809
- // Gemini timeouts are in milliseconds; manifest timeouts are seconds.
810
- const timeoutMs = (hookDef.timeout || 600) * 1000;
811
- for (const event of hookDef.events) {
812
- const geminiEvent = GEMINI_EVENT_MAP[event] ?? event;
813
- if (!hooks[geminiEvent]) {
814
- hooks[geminiEvent] = [];
815
- }
816
- const eventEntries = hooks[geminiEvent];
817
- const matcher = hookDef.matcher || '';
818
- let matcherGroup = eventEntries.find((e) => (e.matcher || '') === matcher);
819
- if (!matcherGroup) {
820
- matcherGroup = { matcher, hooks: [] };
821
- eventEntries.push(matcherGroup);
822
- }
823
- if (!matcherGroup.hooks) {
824
- matcherGroup.hooks = [];
825
- }
826
- const existingIdx = matcherGroup.hooks.findIndex((h) => h.command === commandPath);
827
- const hookEntry = { name, type: 'command', command: commandPath, timeout: timeoutMs };
828
- if (existingIdx >= 0) {
829
- matcherGroup.hooks[existingIdx] = hookEntry;
830
- }
831
- else {
832
- matcherGroup.hooks.push(hookEntry);
833
- }
834
- registered.push(`${name} -> ${geminiEvent}`);
835
- }
836
- }
837
- try {
838
- fs.mkdirSync(configDir, { recursive: true });
839
- fs.writeFileSync(settingsPath, JSON.stringify(config, null, 2), 'utf-8');
840
- }
841
- catch (err) {
842
- errors.push(`Failed to write gemini settings.json: ${err.message}`);
843
- }
844
- return { registered, errors };
845
- }
846
- //# sourceMappingURL=hooks.js.map