@calliopelabs/cli 0.8.20 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (402) hide show
  1. package/dist/agents/agent-config-loader.d.ts +60 -0
  2. package/dist/agents/agent-config-loader.d.ts.map +1 -0
  3. package/dist/agents/agent-config-loader.js +402 -0
  4. package/dist/agents/agent-config-loader.js.map +1 -0
  5. package/dist/agents/agent-config-presets.d.ts +10 -0
  6. package/dist/agents/agent-config-presets.d.ts.map +1 -0
  7. package/dist/agents/agent-config-presets.js +940 -0
  8. package/dist/agents/agent-config-presets.js.map +1 -0
  9. package/dist/agents/agent-config-types.d.ts +145 -0
  10. package/dist/agents/agent-config-types.d.ts.map +1 -0
  11. package/dist/agents/agent-config-types.js +12 -0
  12. package/dist/agents/agent-config-types.js.map +1 -0
  13. package/dist/{agterm → agents}/agent-detection.d.ts +1 -1
  14. package/dist/{agterm → agents}/agent-detection.d.ts.map +1 -1
  15. package/dist/{agterm → agents}/agent-detection.js +21 -5
  16. package/dist/agents/agent-detection.js.map +1 -0
  17. package/dist/agents/aggregator.d.ts +19 -0
  18. package/dist/agents/aggregator.d.ts.map +1 -0
  19. package/dist/agents/aggregator.js +141 -0
  20. package/dist/agents/aggregator.js.map +1 -0
  21. package/dist/{agterm → agents}/cli-backend.d.ts +1 -1
  22. package/dist/{agterm → agents}/cli-backend.d.ts.map +1 -1
  23. package/dist/{agterm → agents}/cli-backend.js +90 -12
  24. package/dist/agents/cli-backend.js.map +1 -0
  25. package/dist/agents/council-types.d.ts +113 -0
  26. package/dist/agents/council-types.d.ts.map +1 -0
  27. package/dist/agents/council-types.js +81 -0
  28. package/dist/agents/council-types.js.map +1 -0
  29. package/dist/agents/council.d.ts +107 -0
  30. package/dist/agents/council.d.ts.map +1 -0
  31. package/dist/agents/council.js +586 -0
  32. package/dist/agents/council.js.map +1 -0
  33. package/dist/agents/decomposer.d.ts +33 -0
  34. package/dist/agents/decomposer.d.ts.map +1 -0
  35. package/dist/agents/decomposer.js +138 -0
  36. package/dist/agents/decomposer.js.map +1 -0
  37. package/dist/agents/dynamic-tools.d.ts +52 -0
  38. package/dist/agents/dynamic-tools.d.ts.map +1 -0
  39. package/dist/agents/dynamic-tools.js +395 -0
  40. package/dist/agents/dynamic-tools.js.map +1 -0
  41. package/dist/agents/index.d.ts +29 -0
  42. package/dist/agents/index.d.ts.map +1 -0
  43. package/dist/agents/index.js +29 -0
  44. package/dist/agents/index.js.map +1 -0
  45. package/dist/agents/installer.d.ts +39 -0
  46. package/dist/agents/installer.d.ts.map +1 -0
  47. package/dist/agents/installer.js +205 -0
  48. package/dist/agents/installer.js.map +1 -0
  49. package/dist/{agterm → agents}/orchestrator.d.ts +7 -2
  50. package/dist/agents/orchestrator.d.ts.map +1 -0
  51. package/dist/{agterm → agents}/orchestrator.js +22 -2
  52. package/dist/agents/orchestrator.js.map +1 -0
  53. package/dist/agents/sdk-backend.d.ts +63 -0
  54. package/dist/agents/sdk-backend.d.ts.map +1 -0
  55. package/dist/agents/sdk-backend.js +489 -0
  56. package/dist/agents/sdk-backend.js.map +1 -0
  57. package/dist/agents/swarm-types.d.ts +83 -0
  58. package/dist/agents/swarm-types.d.ts.map +1 -0
  59. package/dist/agents/swarm-types.js +20 -0
  60. package/dist/agents/swarm-types.js.map +1 -0
  61. package/dist/agents/swarm.d.ts +74 -0
  62. package/dist/agents/swarm.d.ts.map +1 -0
  63. package/dist/agents/swarm.js +307 -0
  64. package/dist/agents/swarm.js.map +1 -0
  65. package/dist/{agterm → agents}/tools.d.ts +7 -5
  66. package/dist/agents/tools.d.ts.map +1 -0
  67. package/dist/agents/tools.js +776 -0
  68. package/dist/agents/tools.js.map +1 -0
  69. package/dist/{agterm → agents}/types.d.ts +14 -2
  70. package/dist/agents/types.d.ts.map +1 -0
  71. package/dist/{agterm → agents}/types.js +2 -2
  72. package/dist/agents/types.js.map +1 -0
  73. package/dist/api-server.d.ts +26 -0
  74. package/dist/api-server.d.ts.map +1 -0
  75. package/dist/api-server.js +230 -0
  76. package/dist/api-server.js.map +1 -0
  77. package/dist/auto-checkpoint.d.ts +35 -0
  78. package/dist/auto-checkpoint.d.ts.map +1 -0
  79. package/dist/auto-checkpoint.js +143 -0
  80. package/dist/auto-checkpoint.js.map +1 -0
  81. package/dist/auto-compressor.d.ts +44 -0
  82. package/dist/auto-compressor.d.ts.map +1 -0
  83. package/dist/auto-compressor.js +145 -0
  84. package/dist/auto-compressor.js.map +1 -0
  85. package/dist/background-jobs.d.ts +45 -0
  86. package/dist/background-jobs.d.ts.map +1 -0
  87. package/dist/background-jobs.js +122 -0
  88. package/dist/background-jobs.js.map +1 -0
  89. package/dist/bin.d.ts +6 -2
  90. package/dist/bin.d.ts.map +1 -1
  91. package/dist/bin.js +127 -24
  92. package/dist/bin.js.map +1 -1
  93. package/dist/checkpoint.d.ts +49 -0
  94. package/dist/checkpoint.d.ts.map +1 -0
  95. package/dist/checkpoint.js +219 -0
  96. package/dist/checkpoint.js.map +1 -0
  97. package/dist/circuit-breaker/breaker.d.ts +80 -0
  98. package/dist/circuit-breaker/breaker.d.ts.map +1 -0
  99. package/dist/circuit-breaker/breaker.js +408 -0
  100. package/dist/circuit-breaker/breaker.js.map +1 -0
  101. package/dist/circuit-breaker/defaults.d.ts +8 -0
  102. package/dist/circuit-breaker/defaults.d.ts.map +1 -0
  103. package/dist/circuit-breaker/defaults.js +35 -0
  104. package/dist/circuit-breaker/defaults.js.map +1 -0
  105. package/dist/circuit-breaker/index.d.ts +9 -0
  106. package/dist/circuit-breaker/index.d.ts.map +1 -0
  107. package/dist/circuit-breaker/index.js +8 -0
  108. package/dist/circuit-breaker/index.js.map +1 -0
  109. package/dist/circuit-breaker/types.d.ts +77 -0
  110. package/dist/circuit-breaker/types.d.ts.map +1 -0
  111. package/dist/circuit-breaker/types.js +8 -0
  112. package/dist/circuit-breaker/types.js.map +1 -0
  113. package/dist/circuit-breaker.d.ts +8 -0
  114. package/dist/circuit-breaker.d.ts.map +1 -0
  115. package/dist/circuit-breaker.js +7 -0
  116. package/dist/circuit-breaker.js.map +1 -0
  117. package/dist/cli/agent.d.ts +9 -0
  118. package/dist/cli/agent.d.ts.map +1 -0
  119. package/dist/cli/agent.js +262 -0
  120. package/dist/cli/agent.js.map +1 -0
  121. package/dist/cli/commands.d.ts +12 -0
  122. package/dist/cli/commands.d.ts.map +1 -0
  123. package/dist/{cli.js → cli/commands.js} +285 -422
  124. package/dist/cli/commands.js.map +1 -0
  125. package/dist/cli/index.d.ts +8 -0
  126. package/dist/cli/index.d.ts.map +1 -0
  127. package/dist/cli/index.js +222 -0
  128. package/dist/cli/index.js.map +1 -0
  129. package/dist/cli/types.d.ts +30 -0
  130. package/dist/cli/types.d.ts.map +1 -0
  131. package/dist/cli/types.js +20 -0
  132. package/dist/cli/types.js.map +1 -0
  133. package/dist/companions.d.ts +54 -0
  134. package/dist/companions.d.ts.map +1 -0
  135. package/dist/companions.js +440 -0
  136. package/dist/companions.js.map +1 -0
  137. package/dist/config.d.ts +23 -1
  138. package/dist/config.d.ts.map +1 -1
  139. package/dist/config.js +95 -22
  140. package/dist/config.js.map +1 -1
  141. package/dist/diff.d.ts +27 -0
  142. package/dist/diff.d.ts.map +1 -1
  143. package/dist/diff.js +415 -10
  144. package/dist/diff.js.map +1 -1
  145. package/dist/errors.d.ts.map +1 -1
  146. package/dist/errors.js +20 -11
  147. package/dist/errors.js.map +1 -1
  148. package/dist/git-status.d.ts +23 -0
  149. package/dist/git-status.d.ts.map +1 -0
  150. package/dist/git-status.js +92 -0
  151. package/dist/git-status.js.map +1 -0
  152. package/dist/headless.d.ts +25 -0
  153. package/dist/headless.d.ts.map +1 -0
  154. package/dist/headless.js +182 -0
  155. package/dist/headless.js.map +1 -0
  156. package/dist/hud/api.d.ts +35 -0
  157. package/dist/hud/api.d.ts.map +1 -0
  158. package/dist/hud/api.js +448 -0
  159. package/dist/hud/api.js.map +1 -0
  160. package/dist/hud/palettes.d.ts +9 -0
  161. package/dist/hud/palettes.d.ts.map +1 -0
  162. package/dist/hud/palettes.js +280 -0
  163. package/dist/hud/palettes.js.map +1 -0
  164. package/dist/hud/skins.d.ts +12 -0
  165. package/dist/hud/skins.d.ts.map +1 -0
  166. package/dist/hud/skins.js +365 -0
  167. package/dist/hud/skins.js.map +1 -0
  168. package/dist/hud/theme-packs/api.d.ts +51 -0
  169. package/dist/hud/theme-packs/api.d.ts.map +1 -0
  170. package/dist/hud/theme-packs/api.js +145 -0
  171. package/dist/hud/theme-packs/api.js.map +1 -0
  172. package/dist/hud/theme-packs/index.d.ts +18 -0
  173. package/dist/hud/theme-packs/index.d.ts.map +1 -0
  174. package/dist/hud/theme-packs/index.js +38 -0
  175. package/dist/hud/theme-packs/index.js.map +1 -0
  176. package/dist/hud/theme-packs/types.d.ts +29 -0
  177. package/dist/hud/theme-packs/types.d.ts.map +1 -0
  178. package/dist/hud/theme-packs/types.js +9 -0
  179. package/dist/hud/theme-packs/types.js.map +1 -0
  180. package/dist/hud/types.d.ts +182 -0
  181. package/dist/hud/types.d.ts.map +1 -0
  182. package/dist/hud/types.js +7 -0
  183. package/dist/hud/types.js.map +1 -0
  184. package/dist/idle-eviction.d.ts +34 -0
  185. package/dist/idle-eviction.d.ts.map +1 -0
  186. package/dist/idle-eviction.js +78 -0
  187. package/dist/idle-eviction.js.map +1 -0
  188. package/dist/index.d.ts +9 -3
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +9 -3
  191. package/dist/index.js.map +1 -1
  192. package/dist/iteration-ledger.d.ts +105 -0
  193. package/dist/iteration-ledger.d.ts.map +1 -0
  194. package/dist/iteration-ledger.js +237 -0
  195. package/dist/iteration-ledger.js.map +1 -0
  196. package/dist/markdown.d.ts.map +1 -1
  197. package/dist/markdown.js +1 -27
  198. package/dist/markdown.js.map +1 -1
  199. package/dist/mcp.d.ts +35 -0
  200. package/dist/mcp.d.ts.map +1 -1
  201. package/dist/mcp.js +291 -7
  202. package/dist/mcp.js.map +1 -1
  203. package/dist/memory.d.ts.map +1 -1
  204. package/dist/memory.js +12 -2
  205. package/dist/memory.js.map +1 -1
  206. package/dist/model-detection.d.ts +5 -0
  207. package/dist/model-detection.d.ts.map +1 -1
  208. package/dist/model-detection.js +278 -10
  209. package/dist/model-detection.js.map +1 -1
  210. package/dist/model-router.d.ts.map +1 -1
  211. package/dist/model-router.js +33 -11
  212. package/dist/model-router.js.map +1 -1
  213. package/dist/plugins.d.ts +8 -0
  214. package/dist/plugins.d.ts.map +1 -1
  215. package/dist/plugins.js +97 -6
  216. package/dist/plugins.js.map +1 -1
  217. package/dist/providers/anthropic.d.ts +10 -0
  218. package/dist/providers/anthropic.d.ts.map +1 -0
  219. package/dist/providers/anthropic.js +221 -0
  220. package/dist/providers/anthropic.js.map +1 -0
  221. package/dist/providers/bedrock.d.ts +17 -0
  222. package/dist/providers/bedrock.d.ts.map +1 -0
  223. package/dist/providers/bedrock.js +574 -0
  224. package/dist/providers/bedrock.js.map +1 -0
  225. package/dist/providers/compat.d.ts +13 -0
  226. package/dist/providers/compat.d.ts.map +1 -0
  227. package/dist/providers/compat.js +202 -0
  228. package/dist/providers/compat.js.map +1 -0
  229. package/dist/providers/google.d.ts +10 -0
  230. package/dist/providers/google.d.ts.map +1 -0
  231. package/dist/providers/google.js +203 -0
  232. package/dist/providers/google.js.map +1 -0
  233. package/dist/providers/index.d.ts +23 -0
  234. package/dist/providers/index.d.ts.map +1 -0
  235. package/dist/providers/index.js +145 -0
  236. package/dist/providers/index.js.map +1 -0
  237. package/dist/providers/ollama.d.ts +17 -0
  238. package/dist/providers/ollama.d.ts.map +1 -0
  239. package/dist/providers/ollama.js +289 -0
  240. package/dist/providers/ollama.js.map +1 -0
  241. package/dist/providers/openai.d.ts +121 -0
  242. package/dist/providers/openai.d.ts.map +1 -0
  243. package/dist/providers/openai.js +485 -0
  244. package/dist/providers/openai.js.map +1 -0
  245. package/dist/providers/types.d.ts +63 -0
  246. package/dist/providers/types.d.ts.map +1 -0
  247. package/dist/providers/types.js +164 -0
  248. package/dist/providers/types.js.map +1 -0
  249. package/dist/sandbox-native.d.ts +59 -0
  250. package/dist/sandbox-native.d.ts.map +1 -0
  251. package/dist/sandbox-native.js +292 -0
  252. package/dist/sandbox-native.js.map +1 -0
  253. package/dist/sandbox.d.ts +2 -2
  254. package/dist/sandbox.d.ts.map +1 -1
  255. package/dist/sandbox.js +59 -13
  256. package/dist/sandbox.js.map +1 -1
  257. package/dist/scope.d.ts +3 -1
  258. package/dist/scope.d.ts.map +1 -1
  259. package/dist/scope.js +13 -1
  260. package/dist/scope.js.map +1 -1
  261. package/dist/session-timeout.d.ts +31 -0
  262. package/dist/session-timeout.d.ts.map +1 -0
  263. package/dist/session-timeout.js +100 -0
  264. package/dist/session-timeout.js.map +1 -0
  265. package/dist/setup.d.ts.map +1 -1
  266. package/dist/setup.js +29 -17
  267. package/dist/setup.js.map +1 -1
  268. package/dist/smart-router.d.ts +73 -0
  269. package/dist/smart-router.d.ts.map +1 -0
  270. package/dist/smart-router.js +332 -0
  271. package/dist/smart-router.js.map +1 -0
  272. package/dist/storage.d.ts +19 -0
  273. package/dist/storage.d.ts.map +1 -1
  274. package/dist/storage.js +164 -1
  275. package/dist/storage.js.map +1 -1
  276. package/dist/streaming.d.ts +4 -0
  277. package/dist/streaming.d.ts.map +1 -1
  278. package/dist/streaming.js +12 -0
  279. package/dist/streaming.js.map +1 -1
  280. package/dist/styles.d.ts +32 -0
  281. package/dist/styles.d.ts.map +1 -1
  282. package/dist/styles.js +91 -0
  283. package/dist/styles.js.map +1 -1
  284. package/dist/summarization.d.ts +1 -1
  285. package/dist/summarization.js +4 -4
  286. package/dist/summarization.js.map +1 -1
  287. package/dist/terminal-image.d.ts +115 -0
  288. package/dist/terminal-image.d.ts.map +1 -0
  289. package/dist/terminal-image.js +766 -0
  290. package/dist/terminal-image.js.map +1 -0
  291. package/dist/terminal-recording.d.ts +55 -0
  292. package/dist/terminal-recording.d.ts.map +1 -0
  293. package/dist/terminal-recording.js +182 -0
  294. package/dist/terminal-recording.js.map +1 -0
  295. package/dist/themes.d.ts +19 -35
  296. package/dist/themes.d.ts.map +1 -1
  297. package/dist/themes.js +101 -210
  298. package/dist/themes.js.map +1 -1
  299. package/dist/tmux.d.ts +35 -0
  300. package/dist/tmux.d.ts.map +1 -0
  301. package/dist/tmux.js +106 -0
  302. package/dist/tmux.js.map +1 -0
  303. package/dist/tools.d.ts +3 -3
  304. package/dist/tools.d.ts.map +1 -1
  305. package/dist/tools.js +587 -45
  306. package/dist/tools.js.map +1 -1
  307. package/dist/trust.d.ts +53 -0
  308. package/dist/trust.d.ts.map +1 -0
  309. package/dist/trust.js +154 -0
  310. package/dist/trust.js.map +1 -0
  311. package/dist/types.d.ts +7 -3
  312. package/dist/types.d.ts.map +1 -1
  313. package/dist/types.js +70 -32
  314. package/dist/types.js.map +1 -1
  315. package/dist/ui/agent.d.ts +61 -0
  316. package/dist/ui/agent.d.ts.map +1 -0
  317. package/dist/ui/agent.js +768 -0
  318. package/dist/ui/agent.js.map +1 -0
  319. package/dist/ui/chat-input.d.ts +32 -0
  320. package/dist/ui/chat-input.d.ts.map +1 -0
  321. package/dist/ui/chat-input.js +355 -0
  322. package/dist/ui/chat-input.js.map +1 -0
  323. package/dist/ui/commands.d.ts +92 -0
  324. package/dist/ui/commands.d.ts.map +1 -0
  325. package/dist/ui/commands.js +3006 -0
  326. package/dist/ui/commands.js.map +1 -0
  327. package/dist/ui/completions.d.ts +22 -0
  328. package/dist/ui/completions.d.ts.map +1 -0
  329. package/dist/ui/completions.js +215 -0
  330. package/dist/ui/completions.js.map +1 -0
  331. package/dist/ui/components.d.ts +38 -0
  332. package/dist/ui/components.d.ts.map +1 -0
  333. package/dist/ui/components.js +422 -0
  334. package/dist/ui/components.js.map +1 -0
  335. package/dist/ui/context.d.ts +12 -0
  336. package/dist/ui/context.d.ts.map +1 -0
  337. package/dist/ui/context.js +102 -0
  338. package/dist/ui/context.js.map +1 -0
  339. package/dist/ui/error-boundary.d.ts +33 -0
  340. package/dist/ui/error-boundary.d.ts.map +1 -0
  341. package/dist/ui/error-boundary.js +94 -0
  342. package/dist/ui/error-boundary.js.map +1 -0
  343. package/dist/ui/frame.d.ts +13 -0
  344. package/dist/ui/frame.d.ts.map +1 -0
  345. package/dist/ui/frame.js +89 -0
  346. package/dist/ui/frame.js.map +1 -0
  347. package/dist/ui/index.d.ts +12 -0
  348. package/dist/ui/index.d.ts.map +1 -0
  349. package/dist/ui/index.js +928 -0
  350. package/dist/ui/index.js.map +1 -0
  351. package/dist/ui/messages.d.ts +19 -0
  352. package/dist/ui/messages.d.ts.map +1 -0
  353. package/dist/ui/messages.js +181 -0
  354. package/dist/ui/messages.js.map +1 -0
  355. package/dist/ui/modals.d.ts +52 -0
  356. package/dist/ui/modals.d.ts.map +1 -0
  357. package/dist/ui/modals.js +204 -0
  358. package/dist/ui/modals.js.map +1 -0
  359. package/dist/ui/pack-picker.d.ts +12 -0
  360. package/dist/ui/pack-picker.d.ts.map +1 -0
  361. package/dist/ui/pack-picker.js +101 -0
  362. package/dist/ui/pack-picker.js.map +1 -0
  363. package/dist/ui/status-bar.d.ts +20 -0
  364. package/dist/ui/status-bar.d.ts.map +1 -0
  365. package/dist/ui/status-bar.js +41 -0
  366. package/dist/ui/status-bar.js.map +1 -0
  367. package/dist/ui/theme-picker.d.ts +24 -0
  368. package/dist/ui/theme-picker.d.ts.map +1 -0
  369. package/dist/ui/theme-picker.js +190 -0
  370. package/dist/ui/theme-picker.js.map +1 -0
  371. package/dist/ui/types.d.ts +62 -0
  372. package/dist/ui/types.d.ts.map +1 -0
  373. package/dist/ui/types.js +7 -0
  374. package/dist/ui/types.js.map +1 -0
  375. package/dist/version-check.d.ts.map +1 -1
  376. package/dist/version-check.js +1 -9
  377. package/dist/version-check.js.map +1 -1
  378. package/package.json +8 -3
  379. package/dist/agterm/agent-detection.js.map +0 -1
  380. package/dist/agterm/cli-backend.js.map +0 -1
  381. package/dist/agterm/index.d.ts +0 -12
  382. package/dist/agterm/index.d.ts.map +0 -1
  383. package/dist/agterm/index.js +0 -15
  384. package/dist/agterm/index.js.map +0 -1
  385. package/dist/agterm/orchestrator.d.ts.map +0 -1
  386. package/dist/agterm/orchestrator.js.map +0 -1
  387. package/dist/agterm/tools.d.ts.map +0 -1
  388. package/dist/agterm/tools.js +0 -278
  389. package/dist/agterm/tools.js.map +0 -1
  390. package/dist/agterm/types.d.ts.map +0 -1
  391. package/dist/agterm/types.js.map +0 -1
  392. package/dist/cli.d.ts +0 -14
  393. package/dist/cli.d.ts.map +0 -1
  394. package/dist/cli.js.map +0 -1
  395. package/dist/providers.d.ts +0 -51
  396. package/dist/providers.d.ts.map +0 -1
  397. package/dist/providers.js +0 -1146
  398. package/dist/providers.js.map +0 -1
  399. package/dist/ui-cli.d.ts +0 -17
  400. package/dist/ui-cli.d.ts.map +0 -1
  401. package/dist/ui-cli.js +0 -3730
  402. package/dist/ui-cli.js.map +0 -1
@@ -0,0 +1,776 @@
1
+ /**
2
+ * Calliope Agents — Tools
3
+ *
4
+ * Tool definitions for spawn_agent, check_agent, and list_agents.
5
+ */
6
+ import { orchestrator } from './orchestrator.js';
7
+ import { swarmManager } from './swarm.js';
8
+ import { getAvailableAgents, detectAgents } from './agent-detection.js';
9
+ import { getAvailableExecutors } from './sdk-backend.js';
10
+ import { getAgent, getTeam, listAgentDefs, listTeamDefs, mapEngineToAgentType } from './agent-config-loader.js';
11
+ import { councilManager } from './council.js';
12
+ import { COUNCIL_TEMPLATES } from './council-types.js';
13
+ import { getDynamicToolDefs, isDynamicTool, executeDynamicTool, DYNAMIC_TOOL_NAMES, executeMetaTool, dynamicToolRegistry } from './dynamic-tools.js';
14
+ /**
15
+ * Build dynamic tool description with available agents
16
+ */
17
+ function buildSpawnAgentDescription() {
18
+ const available = getAvailableAgents();
19
+ const agentList = available.length > 0
20
+ ? available.join(', ')
21
+ : 'none detected (check CLI installation and API keys)';
22
+ return `Spawn a sub-agent CLI to handle a task autonomously.
23
+
24
+ Available agents: ${agentList}
25
+
26
+ Agent descriptions:
27
+ - calliope: Calliope CLI (self) - Full-featured agent with all tools, runs in god mode
28
+ - claude: Claude Code CLI - Best for complex coding, file operations, analysis
29
+ - gemini: Gemini CLI - Good for research, explanation, creative tasks
30
+ - codex: Codex CLI - Specialized for code generation and completion
31
+
32
+ Options:
33
+ - background: true = returns immediately with taskId, false = waits for completion
34
+ - priority: critical > high > normal > low (affects queue ordering)
35
+ - provider: Override the provider (e.g., ollama, anthropic, openai, google) — calliope agent only
36
+ - model: Override the model (e.g., devstral, llama3.3, gpt-4o) — calliope agent only
37
+ - executor: Backend to use: cli (default, spawns process), claude-sdk (in-process Claude Agent SDK), openai-sdk (in-process OpenAI Agents JS), google-adk (in-process Google ADK)
38
+
39
+ SDK executors run in-process (faster, no CLI spawn overhead) and support all providers.
40
+ Install optional: npm install @anthropic-ai/claude-agent-sdk @openai/agents @google/adk
41
+
42
+ Use check_agent with the taskId to monitor background tasks.`;
43
+ }
44
+ /**
45
+ * Get agent tool definitions
46
+ * Returns tools dynamically based on available agents
47
+ */
48
+ export function getAgtermTools() {
49
+ // Dynamic tools: meta-tools (create/list/remove) + user-created tools
50
+ const dynamicMeta = getDynamicToolDefs();
51
+ const dynamicUserTools = dynamicToolRegistry.getToolDefinitions();
52
+ return [
53
+ ...dynamicMeta,
54
+ ...dynamicUserTools,
55
+ {
56
+ name: 'spawn_agent',
57
+ description: buildSpawnAgentDescription(),
58
+ parameters: {
59
+ type: 'object',
60
+ properties: {
61
+ prompt: {
62
+ type: 'string',
63
+ description: 'The task description for the sub-agent',
64
+ },
65
+ agent: {
66
+ type: 'string',
67
+ description: 'Which agent CLI to use: calliope (self), claude, gemini, or codex',
68
+ enum: ['calliope', 'claude', 'gemini', 'codex'],
69
+ },
70
+ background: {
71
+ type: 'string', // Using string to be compatible with boolean parsing
72
+ description: 'Run in background (returns task ID immediately) or wait for completion. Default: false',
73
+ enum: ['true', 'false'],
74
+ },
75
+ priority: {
76
+ type: 'string',
77
+ description: 'Task priority for queue ordering. Default: normal',
78
+ enum: ['low', 'normal', 'high', 'critical'],
79
+ },
80
+ provider: {
81
+ type: 'string',
82
+ description: 'Override provider for calliope subagents (e.g., ollama, anthropic, openai, google)',
83
+ },
84
+ model: {
85
+ type: 'string',
86
+ description: 'Override model for calliope subagents (e.g., devstral, llama3.3, gpt-4o)',
87
+ },
88
+ executor: {
89
+ type: 'string',
90
+ description: 'Execution backend: cli (default), claude-sdk (Claude Agent SDK), openai-sdk (OpenAI Agents JS), google-adk (Google ADK)',
91
+ enum: ['cli', 'claude-sdk', 'openai-sdk', 'google-adk'],
92
+ },
93
+ agentDef: {
94
+ type: 'string',
95
+ description: 'Name of a defined agent from .calliope/agents/ (overrides provider/model/executor with agent definition values)',
96
+ },
97
+ timeout: {
98
+ type: 'number',
99
+ description: 'Task timeout in milliseconds (overrides global default)',
100
+ },
101
+ },
102
+ required: ['prompt'],
103
+ },
104
+ },
105
+ {
106
+ name: 'check_agent',
107
+ description: 'Check the status and result of a spawned sub-agent task. Use the taskId returned from spawn_agent.',
108
+ parameters: {
109
+ type: 'object',
110
+ properties: {
111
+ taskId: {
112
+ type: 'string',
113
+ description: 'The task ID returned from spawn_agent',
114
+ },
115
+ },
116
+ required: ['taskId'],
117
+ },
118
+ },
119
+ {
120
+ name: 'list_agents',
121
+ description: 'List available sub-agent CLIs and their status. Also shows orchestrator statistics.',
122
+ parameters: {
123
+ type: 'object',
124
+ properties: {},
125
+ },
126
+ },
127
+ {
128
+ name: 'cancel_agent',
129
+ description: 'Cancel a running or queued sub-agent task.',
130
+ parameters: {
131
+ type: 'object',
132
+ properties: {
133
+ taskId: {
134
+ type: 'string',
135
+ description: 'The task ID to cancel',
136
+ },
137
+ },
138
+ required: ['taskId'],
139
+ },
140
+ },
141
+ {
142
+ name: 'start_swarm',
143
+ description: `Start a swarm to decompose a complex task into parallel subtasks.
144
+ An overseer agent breaks the task down, then worker agents execute subtasks concurrently.
145
+ Results are aggregated into a single response.
146
+
147
+ Strategies:
148
+ - parallel: Independent subtasks, all run at once
149
+ - sequential: Ordered steps, each depends on previous
150
+ - map-reduce: Map phase (parallel) then merge results
151
+ - pipeline: Stages that transform output sequentially
152
+
153
+ Aggregation:
154
+ - concatenate: Ordered concatenation with headers
155
+ - merge-dedupe: Combine and remove duplicates
156
+ - summarize: Key points from each subtask
157
+ - structured: Organized report format`,
158
+ parameters: {
159
+ type: 'object',
160
+ properties: {
161
+ prompt: {
162
+ type: 'string',
163
+ description: 'The complex task to decompose and execute',
164
+ },
165
+ strategy: {
166
+ type: 'string',
167
+ description: 'Decomposition strategy (default: parallel)',
168
+ enum: ['parallel', 'sequential', 'map-reduce', 'pipeline'],
169
+ },
170
+ aggregation: {
171
+ type: 'string',
172
+ description: 'How to merge results (default: concatenate)',
173
+ enum: ['concatenate', 'merge-dedupe', 'summarize', 'structured'],
174
+ },
175
+ maxWorkers: {
176
+ type: 'number',
177
+ description: 'Maximum concurrent workers (default: 3)',
178
+ },
179
+ workerAgent: {
180
+ type: 'string',
181
+ description: 'Agent type for workers (default: claude)',
182
+ enum: ['calliope', 'claude', 'gemini', 'codex'],
183
+ },
184
+ useSmartRouting: {
185
+ type: 'string',
186
+ description: 'Use smart routing to select best agent per subtask (default: false)',
187
+ enum: ['true', 'false'],
188
+ },
189
+ team: {
190
+ type: 'string',
191
+ description: 'Name of a team definition from .calliope/agents/teams/ (auto-configures strategy, workers, and coordination)',
192
+ },
193
+ },
194
+ required: ['prompt'],
195
+ },
196
+ },
197
+ {
198
+ name: 'check_swarm',
199
+ description: 'Check the status of a swarm session. Shows subtask progress and results.',
200
+ parameters: {
201
+ type: 'object',
202
+ properties: {
203
+ sessionId: {
204
+ type: 'string',
205
+ description: 'The swarm session ID',
206
+ },
207
+ },
208
+ required: ['sessionId'],
209
+ },
210
+ },
211
+ {
212
+ name: 'cancel_swarm',
213
+ description: 'Cancel a running swarm session and all its subtasks.',
214
+ parameters: {
215
+ type: 'object',
216
+ properties: {
217
+ sessionId: {
218
+ type: 'string',
219
+ description: 'The swarm session ID to cancel',
220
+ },
221
+ },
222
+ required: ['sessionId'],
223
+ },
224
+ },
225
+ {
226
+ name: 'start_council',
227
+ description: `Start a coordinated agent swarm where multiple agents work toward a shared objective.
228
+
229
+ Coordination Modes:
230
+ - competitive: Agents work independently, best result wins
231
+ - collaborative: Pipeline — each agent builds on and executes from previous work
232
+ - consensus: Agents propose, vote, then ALL execute the winning approach
233
+ - overseer: Lead decomposes, delegates subtasks, reviews and coordinates completion
234
+
235
+ Templates: ${Object.keys(COUNCIL_TEMPLATES).join(', ')}
236
+ Use a template name to auto-configure agents and mode.`,
237
+ parameters: {
238
+ type: 'object',
239
+ properties: {
240
+ prompt: {
241
+ type: 'string',
242
+ description: 'The objective for the agent swarm to work on',
243
+ },
244
+ template: {
245
+ type: 'string',
246
+ description: 'Use a pre-built template (code-review, architecture, security-audit, brainstorm, debate)',
247
+ enum: Object.keys(COUNCIL_TEMPLATES),
248
+ },
249
+ mode: {
250
+ type: 'string',
251
+ description: 'Coordination mode (if not using template)',
252
+ enum: ['competitive', 'collaborative', 'consensus', 'overseer'],
253
+ },
254
+ team: {
255
+ type: 'string',
256
+ description: 'Name of a team definition from .calliope/agents/teams/ (auto-configures members, mode, and settings)',
257
+ },
258
+ },
259
+ required: ['prompt'],
260
+ },
261
+ },
262
+ {
263
+ name: 'check_council',
264
+ description: 'Check the status of a coordinated agent swarm. Shows progress and results.',
265
+ parameters: {
266
+ type: 'object',
267
+ properties: {
268
+ sessionId: {
269
+ type: 'string',
270
+ description: 'The council session ID',
271
+ },
272
+ },
273
+ required: ['sessionId'],
274
+ },
275
+ },
276
+ {
277
+ name: 'cancel_council',
278
+ description: 'Cancel a running coordinated agent swarm.',
279
+ parameters: {
280
+ type: 'object',
281
+ properties: {
282
+ sessionId: {
283
+ type: 'string',
284
+ description: 'The council session ID to cancel',
285
+ },
286
+ },
287
+ required: ['sessionId'],
288
+ },
289
+ },
290
+ {
291
+ name: 'run_command',
292
+ description: `Execute a Calliope CLI slash command programmatically. This lets you use your own capabilities:
293
+
294
+ Available commands:
295
+ - /swarm <task> — Decompose and parallelize a task
296
+ - /swarm coord <objective> — Start coordinated multi-agent team
297
+ - /agents — Show agent status
298
+ - /agents defs — List agent definitions
299
+ - /agents teams — List team definitions
300
+ - /agents init — Scaffold .calliope/agents/
301
+ - /build-agent <name> — Create an agent definition
302
+ - /build-team <name> — Create a team definition
303
+ - /install-agents — Install missing agent CLIs/SDKs
304
+ - /scope — Show current file scope
305
+ - /find <query> — Search the codebase
306
+ - /branch — Git branch management
307
+
308
+ The command runs as if the user typed it. Output is returned as the tool result.`,
309
+ parameters: {
310
+ type: 'object',
311
+ properties: {
312
+ command: {
313
+ type: 'string',
314
+ description: 'The slash command to execute, e.g. "/swarm coord review this codebase --mode competitive"',
315
+ },
316
+ },
317
+ required: ['command'],
318
+ },
319
+ },
320
+ ];
321
+ }
322
+ /**
323
+ * Calliope Agents — tool names for quick lookup
324
+ */
325
+ export const AGTERM_TOOL_NAMES = ['spawn_agent', 'check_agent', 'list_agents', 'cancel_agent', 'start_swarm', 'check_swarm', 'cancel_swarm', 'start_council', 'check_council', 'cancel_council', 'run_command', ...DYNAMIC_TOOL_NAMES];
326
+ /**
327
+ * Command dispatcher — set by the UI layer so the agent can invoke slash commands.
328
+ * Returns the command output as a string.
329
+ */
330
+ let commandDispatcher = null;
331
+ export function setCommandDispatcher(dispatcher) {
332
+ commandDispatcher = dispatcher;
333
+ }
334
+ export function getCommandDispatcher() {
335
+ return commandDispatcher;
336
+ }
337
+ /**
338
+ * Check if a tool name is an agent tool
339
+ */
340
+ export function isAgtermTool(name) {
341
+ return AGTERM_TOOL_NAMES.includes(name) || isDynamicTool(name);
342
+ }
343
+ /**
344
+ * Execute an agent tool
345
+ */
346
+ export async function executeAgtermTool(toolCall, cwd) {
347
+ const { id, name, arguments: args } = toolCall;
348
+ // Handle dynamic tool meta-tools (create/list/remove)
349
+ if (DYNAMIC_TOOL_NAMES.includes(name)) {
350
+ return executeMetaTool(toolCall, cwd);
351
+ }
352
+ // Handle user-created dynamic tools
353
+ if (isDynamicTool(name)) {
354
+ return executeDynamicTool(toolCall, cwd);
355
+ }
356
+ // Set the working directory for the orchestrator
357
+ orchestrator.setCwd(cwd);
358
+ try {
359
+ let result;
360
+ switch (name) {
361
+ case 'spawn_agent': {
362
+ const prompt = String(args.prompt || '');
363
+ let agent = args.agent || 'calliope';
364
+ const background = args.background === 'true' || args.background === true;
365
+ const priority = args.priority || 'normal';
366
+ let model = args.model ? String(args.model) : undefined;
367
+ let provider = args.provider ? String(args.provider) : undefined;
368
+ let executor = args.executor || 'cli';
369
+ let systemPrompt;
370
+ let taskTimeout = args.timeout ? Number(args.timeout) : undefined;
371
+ if (!prompt) {
372
+ return {
373
+ toolCallId: id,
374
+ result: 'Error: prompt is required',
375
+ isError: true,
376
+ };
377
+ }
378
+ // Resolve agent definition if provided
379
+ if (args.agentDef) {
380
+ const def = getAgent(String(args.agentDef), cwd);
381
+ if (!def) {
382
+ return {
383
+ toolCallId: id,
384
+ result: `Error: Agent definition '${args.agentDef}' not found.\nAvailable: ${listAgentDefs(cwd).map(a => a.name).join(', ')}`,
385
+ isError: true,
386
+ };
387
+ }
388
+ // Agent def values are defaults — explicit params override
389
+ systemPrompt = def.instructions;
390
+ executor = args.executor || def.engine || executor;
391
+ model = model || def.model;
392
+ provider = provider || def.provider;
393
+ agent = args.agent || mapEngineToAgentType(def.engine, def.provider);
394
+ if (!taskTimeout && def.limits?.timeout)
395
+ taskTimeout = def.limits.timeout;
396
+ }
397
+ // For SDK executors, agent availability check is different (runs in-process)
398
+ if (executor === 'cli') {
399
+ const availableAgents = getAvailableAgents();
400
+ if (!availableAgents.includes(agent)) {
401
+ const agentInfo = detectAgents().find(a => a.type === agent);
402
+ const reason = agentInfo?.reason || 'not installed or configured';
403
+ return {
404
+ toolCallId: id,
405
+ result: `Error: Agent '${agent}' is not available (${reason}).\nAvailable agents: ${availableAgents.join(', ') || 'none'}`,
406
+ isError: true,
407
+ };
408
+ }
409
+ }
410
+ try {
411
+ const task = await orchestrator.spawnAgent(prompt, agent, {
412
+ background,
413
+ priority,
414
+ cwd,
415
+ model,
416
+ provider,
417
+ executor,
418
+ systemPrompt,
419
+ timeout: taskTimeout,
420
+ });
421
+ if (background) {
422
+ result = `Sub-agent (${agent}) spawned in background.
423
+ Task ID: ${task.id}
424
+ Status: ${task.status}
425
+ Priority: ${task.priority}
426
+
427
+ Use check_agent("${task.id}") to monitor progress.`;
428
+ }
429
+ else {
430
+ if (task.status === 'completed') {
431
+ result = `[${agent}] Task completed successfully.
432
+
433
+ ${task.result || '(no output)'}`;
434
+ }
435
+ else {
436
+ result = `[${agent}] Task ${task.status}.
437
+
438
+ ${task.error || task.result || '(no output)'}`;
439
+ }
440
+ }
441
+ }
442
+ catch (err) {
443
+ return {
444
+ toolCallId: id,
445
+ result: `Error spawning agent: ${err instanceof Error ? err.message : String(err)}`,
446
+ isError: true,
447
+ };
448
+ }
449
+ break;
450
+ }
451
+ case 'check_agent': {
452
+ const taskId = String(args.taskId || '');
453
+ if (!taskId) {
454
+ return {
455
+ toolCallId: id,
456
+ result: 'Error: taskId is required',
457
+ isError: true,
458
+ };
459
+ }
460
+ const task = orchestrator.getTask(taskId);
461
+ if (!task) {
462
+ result = `Task not found: ${taskId}`;
463
+ }
464
+ else {
465
+ const lines = [
466
+ `Task: ${task.id}`,
467
+ `Agent: ${task.agent}`,
468
+ `Status: ${task.status}`,
469
+ `Priority: ${task.priority}`,
470
+ `Depth: ${task.depth}`,
471
+ ];
472
+ if (task.startedAt) {
473
+ lines.push(`Started: ${task.startedAt.toISOString()}`);
474
+ }
475
+ if (task.completedAt) {
476
+ lines.push(`Completed: ${task.completedAt.toISOString()}`);
477
+ }
478
+ if (task.childIds.length > 0) {
479
+ lines.push(`Children: ${task.childIds.length}`);
480
+ }
481
+ lines.push('');
482
+ if (task.result) {
483
+ lines.push('Result:');
484
+ lines.push(task.result);
485
+ }
486
+ if (task.error) {
487
+ lines.push('Error:');
488
+ lines.push(task.error);
489
+ }
490
+ result = lines.join('\n');
491
+ }
492
+ break;
493
+ }
494
+ case 'list_agents': {
495
+ const agents = detectAgents();
496
+ const agentLines = agents.map(a => {
497
+ const status = a.available ? '✓ Ready' : `✗ ${a.reason}`;
498
+ return ` ${a.type}: ${status}`;
499
+ });
500
+ const stats = orchestrator.getStats();
501
+ const statsLines = [
502
+ ` Running: ${stats.runningTasks}`,
503
+ ` Queued: ${stats.queuedTasks}`,
504
+ ` Completed: ${stats.completedTasks}`,
505
+ ` Failed: ${stats.failedTasks}`,
506
+ ` Total: ${stats.totalTasks}`,
507
+ ` Max Depth Used: ${stats.maxDepthUsed}`,
508
+ ];
509
+ const executors = await getAvailableExecutors();
510
+ const executorLines = executors.map(e => ` ${e}: ✓ Ready`);
511
+ result = `Available Agents:\n${agentLines.join('\n')}\n\nExecutor Backends:\n${executorLines.join('\n')}\n\nOrchestrator Stats:\n${statsLines.join('\n')}`;
512
+ break;
513
+ }
514
+ case 'cancel_agent': {
515
+ const taskId = String(args.taskId || '');
516
+ if (!taskId) {
517
+ return {
518
+ toolCallId: id,
519
+ result: 'Error: taskId is required',
520
+ isError: true,
521
+ };
522
+ }
523
+ const task = orchestrator.getTask(taskId);
524
+ if (!task) {
525
+ result = `Task not found: ${taskId}`;
526
+ }
527
+ else {
528
+ await orchestrator.cancelTask(taskId);
529
+ result = `Task ${taskId} cancelled.`;
530
+ }
531
+ break;
532
+ }
533
+ case 'start_swarm': {
534
+ const prompt = String(args.prompt || '');
535
+ if (!prompt) {
536
+ return {
537
+ toolCallId: id,
538
+ result: 'Error: prompt is required',
539
+ isError: true,
540
+ };
541
+ }
542
+ const strategy = args.strategy || 'parallel';
543
+ const aggregation = args.aggregation || 'concatenate';
544
+ const maxWorkers = typeof args.maxWorkers === 'number' ? args.maxWorkers : 3;
545
+ const workerAgent = args.workerAgent || 'claude';
546
+ const useSmartRouting = args.useSmartRouting === 'true' || args.useSmartRouting === true;
547
+ try {
548
+ const session = await swarmManager.startSwarm(prompt, { decomposition: strategy, aggregation, maxWorkers, workerAgent, useSmartRouting }, cwd);
549
+ result = `Swarm started.
550
+ Session ID: ${session.id}
551
+ Strategy: ${strategy} → ${aggregation}
552
+ Workers: ${maxWorkers}x ${workerAgent}
553
+ Status: ${session.status}
554
+
555
+ Use check_swarm("${session.id}") to monitor progress.`;
556
+ }
557
+ catch (err) {
558
+ return {
559
+ toolCallId: id,
560
+ result: `Error starting swarm: ${err instanceof Error ? err.message : String(err)}`,
561
+ isError: true,
562
+ };
563
+ }
564
+ break;
565
+ }
566
+ case 'check_swarm': {
567
+ const sessionId = String(args.sessionId || '');
568
+ if (!sessionId) {
569
+ return {
570
+ toolCallId: id,
571
+ result: 'Error: sessionId is required',
572
+ isError: true,
573
+ };
574
+ }
575
+ const session = swarmManager.getSession(sessionId);
576
+ if (!session) {
577
+ result = `Swarm session not found: ${sessionId}`;
578
+ }
579
+ else {
580
+ result = swarmManager.formatSessionStatus(session);
581
+ if (session.status === 'completed' && session.result) {
582
+ result += `\n\nResult:\n${session.result}`;
583
+ }
584
+ if (session.status === 'failed' && session.error) {
585
+ result += `\n\nError: ${session.error}`;
586
+ }
587
+ }
588
+ break;
589
+ }
590
+ case 'cancel_swarm': {
591
+ const sessionId = String(args.sessionId || '');
592
+ if (!sessionId) {
593
+ return {
594
+ toolCallId: id,
595
+ result: 'Error: sessionId is required',
596
+ isError: true,
597
+ };
598
+ }
599
+ const cancelled = await swarmManager.cancelSwarm(sessionId);
600
+ result = cancelled
601
+ ? `Swarm session ${sessionId} cancelled.`
602
+ : `Swarm session not found: ${sessionId}`;
603
+ break;
604
+ }
605
+ case 'start_council': {
606
+ const prompt = String(args.prompt || '');
607
+ if (!prompt) {
608
+ return {
609
+ toolCallId: id,
610
+ result: 'Error: prompt is required',
611
+ isError: true,
612
+ };
613
+ }
614
+ const template = args.template;
615
+ const teamName = args.team;
616
+ try {
617
+ let session;
618
+ if (teamName) {
619
+ // Resolve team definition
620
+ const resolvedTeam = getTeam(teamName, cwd);
621
+ if (!resolvedTeam) {
622
+ return {
623
+ toolCallId: id,
624
+ result: `Error: Team '${teamName}' not found.\nAvailable: ${listTeamDefs(cwd).map(t => t.name).join(', ')}`,
625
+ isError: true,
626
+ };
627
+ }
628
+ const { randomUUID: uuid } = await import('crypto');
629
+ const members = resolvedTeam.members.map(m => ({
630
+ id: uuid(),
631
+ name: m.name,
632
+ agent: m.agent,
633
+ role: m.role,
634
+ weight: m.weight,
635
+ }));
636
+ const councilConfig = {
637
+ mode: resolvedTeam.mode,
638
+ members,
639
+ ...(resolvedTeam.council?.tieBreaker && { tieBreaker: resolvedTeam.council.tieBreaker }),
640
+ ...(resolvedTeam.council?.maxRounds && { maxRounds: resolvedTeam.council.maxRounds }),
641
+ ...(resolvedTeam.council?.consensusThreshold && { consensusThreshold: resolvedTeam.council.consensusThreshold }),
642
+ };
643
+ const effectivePrompt = resolvedTeam.promptPrefix
644
+ ? `${resolvedTeam.promptPrefix}\n\n${prompt}`
645
+ : prompt;
646
+ session = await councilManager.startCouncil(effectivePrompt, councilConfig, cwd);
647
+ }
648
+ else if (template && COUNCIL_TEMPLATES[template]) {
649
+ session = await councilManager.startFromTemplate(template, prompt, cwd);
650
+ }
651
+ else {
652
+ const mode = args.mode || 'competitive';
653
+ // Create default members based on mode
654
+ const { randomUUID: uuid } = await import('crypto');
655
+ const members = [
656
+ { id: uuid(), name: 'Agent A', agent: 'claude', weight: 1.0 },
657
+ { id: uuid(), name: 'Agent B', agent: 'claude', weight: 1.0 },
658
+ { id: uuid(), name: 'Agent C', agent: 'claude', weight: 1.0 },
659
+ ];
660
+ session = await councilManager.startCouncil(prompt, { mode, members }, cwd);
661
+ }
662
+ result = `Coordinated swarm started.
663
+ Session ID: ${session.id}
664
+ Mode: ${session.config.mode}
665
+ Agents: ${session.config.members.map(m => m.name).join(', ')}${template ? `\nTemplate: ${template}` : ''}
666
+ Status: ${session.status}
667
+
668
+ Use check_council("${session.id}") to monitor progress.`;
669
+ }
670
+ catch (err) {
671
+ return {
672
+ toolCallId: id,
673
+ result: `Error starting coordination: ${err instanceof Error ? err.message : String(err)}`,
674
+ isError: true,
675
+ };
676
+ }
677
+ break;
678
+ }
679
+ case 'check_council': {
680
+ const sessionId = String(args.sessionId || '');
681
+ if (!sessionId) {
682
+ return {
683
+ toolCallId: id,
684
+ result: 'Error: sessionId is required',
685
+ isError: true,
686
+ };
687
+ }
688
+ const session = councilManager.getSession(sessionId);
689
+ if (!session) {
690
+ result = `Council session not found: ${sessionId}`;
691
+ }
692
+ else {
693
+ result = councilManager.formatSessionStatus(session);
694
+ if (session.status === 'completed' && session.result) {
695
+ result += `\n\nResult:\n${session.result}`;
696
+ }
697
+ if (session.status === 'failed' && session.error) {
698
+ result += `\n\nError: ${session.error}`;
699
+ }
700
+ }
701
+ break;
702
+ }
703
+ case 'cancel_council': {
704
+ const sessionId = String(args.sessionId || '');
705
+ if (!sessionId) {
706
+ return {
707
+ toolCallId: id,
708
+ result: 'Error: sessionId is required',
709
+ isError: true,
710
+ };
711
+ }
712
+ const cancelledCouncil = await councilManager.cancelCouncil(sessionId);
713
+ result = cancelledCouncil
714
+ ? `Council session ${sessionId} cancelled.`
715
+ : `Council session not found: ${sessionId}`;
716
+ break;
717
+ }
718
+ case 'run_command': {
719
+ const command = String(args.command || '').trim();
720
+ if (!command) {
721
+ return {
722
+ toolCallId: id,
723
+ result: 'Error: command is required',
724
+ isError: true,
725
+ };
726
+ }
727
+ if (!command.startsWith('/')) {
728
+ return {
729
+ toolCallId: id,
730
+ result: 'Error: command must start with / (e.g., /swarm, /agents, /build-agent)',
731
+ isError: true,
732
+ };
733
+ }
734
+ // Block dangerous commands the agent shouldn't self-invoke
735
+ const blocked = ['/exit', '/quit', '/clear', '/unstick'];
736
+ if (blocked.some(b => command.startsWith(b))) {
737
+ return {
738
+ toolCallId: id,
739
+ result: `Error: command "${command.split(' ')[0]}" cannot be invoked by the agent.`,
740
+ isError: true,
741
+ };
742
+ }
743
+ if (!commandDispatcher) {
744
+ return {
745
+ toolCallId: id,
746
+ result: 'Error: command dispatcher not initialized. This tool requires the full CLI environment.',
747
+ isError: true,
748
+ };
749
+ }
750
+ try {
751
+ result = await commandDispatcher(command);
752
+ }
753
+ catch (err) {
754
+ return {
755
+ toolCallId: id,
756
+ result: `Error executing command: ${err instanceof Error ? err.message : String(err)}`,
757
+ isError: true,
758
+ };
759
+ }
760
+ break;
761
+ }
762
+ default:
763
+ return {
764
+ toolCallId: id,
765
+ result: `Unknown agent tool: ${name}`,
766
+ isError: true,
767
+ };
768
+ }
769
+ return { toolCallId: id, result };
770
+ }
771
+ catch (error) {
772
+ const msg = error instanceof Error ? error.message : String(error);
773
+ return { toolCallId: id, result: `Error: ${msg}`, isError: true };
774
+ }
775
+ }
776
+ //# sourceMappingURL=tools.js.map