@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.
- package/dist/agents/agent-config-loader.d.ts +60 -0
- package/dist/agents/agent-config-loader.d.ts.map +1 -0
- package/dist/agents/agent-config-loader.js +402 -0
- package/dist/agents/agent-config-loader.js.map +1 -0
- package/dist/agents/agent-config-presets.d.ts +10 -0
- package/dist/agents/agent-config-presets.d.ts.map +1 -0
- package/dist/agents/agent-config-presets.js +940 -0
- package/dist/agents/agent-config-presets.js.map +1 -0
- package/dist/agents/agent-config-types.d.ts +145 -0
- package/dist/agents/agent-config-types.d.ts.map +1 -0
- package/dist/agents/agent-config-types.js +12 -0
- package/dist/agents/agent-config-types.js.map +1 -0
- package/dist/{agterm → agents}/agent-detection.d.ts +1 -1
- package/dist/{agterm → agents}/agent-detection.d.ts.map +1 -1
- package/dist/{agterm → agents}/agent-detection.js +21 -5
- package/dist/agents/agent-detection.js.map +1 -0
- package/dist/agents/aggregator.d.ts +19 -0
- package/dist/agents/aggregator.d.ts.map +1 -0
- package/dist/agents/aggregator.js +141 -0
- package/dist/agents/aggregator.js.map +1 -0
- package/dist/{agterm → agents}/cli-backend.d.ts +1 -1
- package/dist/{agterm → agents}/cli-backend.d.ts.map +1 -1
- package/dist/{agterm → agents}/cli-backend.js +90 -12
- package/dist/agents/cli-backend.js.map +1 -0
- package/dist/agents/council-types.d.ts +113 -0
- package/dist/agents/council-types.d.ts.map +1 -0
- package/dist/agents/council-types.js +81 -0
- package/dist/agents/council-types.js.map +1 -0
- package/dist/agents/council.d.ts +107 -0
- package/dist/agents/council.d.ts.map +1 -0
- package/dist/agents/council.js +586 -0
- package/dist/agents/council.js.map +1 -0
- package/dist/agents/decomposer.d.ts +33 -0
- package/dist/agents/decomposer.d.ts.map +1 -0
- package/dist/agents/decomposer.js +138 -0
- package/dist/agents/decomposer.js.map +1 -0
- package/dist/agents/dynamic-tools.d.ts +52 -0
- package/dist/agents/dynamic-tools.d.ts.map +1 -0
- package/dist/agents/dynamic-tools.js +395 -0
- package/dist/agents/dynamic-tools.js.map +1 -0
- package/dist/agents/index.d.ts +29 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +29 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/agents/installer.d.ts +39 -0
- package/dist/agents/installer.d.ts.map +1 -0
- package/dist/agents/installer.js +205 -0
- package/dist/agents/installer.js.map +1 -0
- package/dist/{agterm → agents}/orchestrator.d.ts +7 -2
- package/dist/agents/orchestrator.d.ts.map +1 -0
- package/dist/{agterm → agents}/orchestrator.js +22 -2
- package/dist/agents/orchestrator.js.map +1 -0
- package/dist/agents/sdk-backend.d.ts +63 -0
- package/dist/agents/sdk-backend.d.ts.map +1 -0
- package/dist/agents/sdk-backend.js +489 -0
- package/dist/agents/sdk-backend.js.map +1 -0
- package/dist/agents/swarm-types.d.ts +83 -0
- package/dist/agents/swarm-types.d.ts.map +1 -0
- package/dist/agents/swarm-types.js +20 -0
- package/dist/agents/swarm-types.js.map +1 -0
- package/dist/agents/swarm.d.ts +74 -0
- package/dist/agents/swarm.d.ts.map +1 -0
- package/dist/agents/swarm.js +307 -0
- package/dist/agents/swarm.js.map +1 -0
- package/dist/{agterm → agents}/tools.d.ts +7 -5
- package/dist/agents/tools.d.ts.map +1 -0
- package/dist/agents/tools.js +776 -0
- package/dist/agents/tools.js.map +1 -0
- package/dist/{agterm → agents}/types.d.ts +14 -2
- package/dist/agents/types.d.ts.map +1 -0
- package/dist/{agterm → agents}/types.js +2 -2
- package/dist/agents/types.js.map +1 -0
- package/dist/api-server.d.ts +26 -0
- package/dist/api-server.d.ts.map +1 -0
- package/dist/api-server.js +230 -0
- package/dist/api-server.js.map +1 -0
- package/dist/auto-checkpoint.d.ts +35 -0
- package/dist/auto-checkpoint.d.ts.map +1 -0
- package/dist/auto-checkpoint.js +143 -0
- package/dist/auto-checkpoint.js.map +1 -0
- package/dist/auto-compressor.d.ts +44 -0
- package/dist/auto-compressor.d.ts.map +1 -0
- package/dist/auto-compressor.js +145 -0
- package/dist/auto-compressor.js.map +1 -0
- package/dist/background-jobs.d.ts +45 -0
- package/dist/background-jobs.d.ts.map +1 -0
- package/dist/background-jobs.js +122 -0
- package/dist/background-jobs.js.map +1 -0
- package/dist/bin.d.ts +6 -2
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +127 -24
- package/dist/bin.js.map +1 -1
- package/dist/checkpoint.d.ts +49 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +219 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/circuit-breaker/breaker.d.ts +80 -0
- package/dist/circuit-breaker/breaker.d.ts.map +1 -0
- package/dist/circuit-breaker/breaker.js +408 -0
- package/dist/circuit-breaker/breaker.js.map +1 -0
- package/dist/circuit-breaker/defaults.d.ts +8 -0
- package/dist/circuit-breaker/defaults.d.ts.map +1 -0
- package/dist/circuit-breaker/defaults.js +35 -0
- package/dist/circuit-breaker/defaults.js.map +1 -0
- package/dist/circuit-breaker/index.d.ts +9 -0
- package/dist/circuit-breaker/index.d.ts.map +1 -0
- package/dist/circuit-breaker/index.js +8 -0
- package/dist/circuit-breaker/index.js.map +1 -0
- package/dist/circuit-breaker/types.d.ts +77 -0
- package/dist/circuit-breaker/types.d.ts.map +1 -0
- package/dist/circuit-breaker/types.js +8 -0
- package/dist/circuit-breaker/types.js.map +1 -0
- package/dist/circuit-breaker.d.ts +8 -0
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +7 -0
- package/dist/circuit-breaker.js.map +1 -0
- package/dist/cli/agent.d.ts +9 -0
- package/dist/cli/agent.d.ts.map +1 -0
- package/dist/cli/agent.js +262 -0
- package/dist/cli/agent.js.map +1 -0
- package/dist/cli/commands.d.ts +12 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/{cli.js → cli/commands.js} +285 -422
- package/dist/cli/commands.js.map +1 -0
- package/dist/cli/index.d.ts +8 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +222 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/types.d.ts +30 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/types.js +20 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/companions.d.ts +54 -0
- package/dist/companions.d.ts.map +1 -0
- package/dist/companions.js +440 -0
- package/dist/companions.js.map +1 -0
- package/dist/config.d.ts +23 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +95 -22
- package/dist/config.js.map +1 -1
- package/dist/diff.d.ts +27 -0
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +415 -10
- package/dist/diff.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +20 -11
- package/dist/errors.js.map +1 -1
- package/dist/git-status.d.ts +23 -0
- package/dist/git-status.d.ts.map +1 -0
- package/dist/git-status.js +92 -0
- package/dist/git-status.js.map +1 -0
- package/dist/headless.d.ts +25 -0
- package/dist/headless.d.ts.map +1 -0
- package/dist/headless.js +182 -0
- package/dist/headless.js.map +1 -0
- package/dist/hud/api.d.ts +35 -0
- package/dist/hud/api.d.ts.map +1 -0
- package/dist/hud/api.js +448 -0
- package/dist/hud/api.js.map +1 -0
- package/dist/hud/palettes.d.ts +9 -0
- package/dist/hud/palettes.d.ts.map +1 -0
- package/dist/hud/palettes.js +280 -0
- package/dist/hud/palettes.js.map +1 -0
- package/dist/hud/skins.d.ts +12 -0
- package/dist/hud/skins.d.ts.map +1 -0
- package/dist/hud/skins.js +365 -0
- package/dist/hud/skins.js.map +1 -0
- package/dist/hud/theme-packs/api.d.ts +51 -0
- package/dist/hud/theme-packs/api.d.ts.map +1 -0
- package/dist/hud/theme-packs/api.js +145 -0
- package/dist/hud/theme-packs/api.js.map +1 -0
- package/dist/hud/theme-packs/index.d.ts +18 -0
- package/dist/hud/theme-packs/index.d.ts.map +1 -0
- package/dist/hud/theme-packs/index.js +38 -0
- package/dist/hud/theme-packs/index.js.map +1 -0
- package/dist/hud/theme-packs/types.d.ts +29 -0
- package/dist/hud/theme-packs/types.d.ts.map +1 -0
- package/dist/hud/theme-packs/types.js +9 -0
- package/dist/hud/theme-packs/types.js.map +1 -0
- package/dist/hud/types.d.ts +182 -0
- package/dist/hud/types.d.ts.map +1 -0
- package/dist/hud/types.js +7 -0
- package/dist/hud/types.js.map +1 -0
- package/dist/idle-eviction.d.ts +34 -0
- package/dist/idle-eviction.d.ts.map +1 -0
- package/dist/idle-eviction.js +78 -0
- package/dist/idle-eviction.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -3
- package/dist/index.js.map +1 -1
- package/dist/iteration-ledger.d.ts +105 -0
- package/dist/iteration-ledger.d.ts.map +1 -0
- package/dist/iteration-ledger.js +237 -0
- package/dist/iteration-ledger.js.map +1 -0
- package/dist/markdown.d.ts.map +1 -1
- package/dist/markdown.js +1 -27
- package/dist/markdown.js.map +1 -1
- package/dist/mcp.d.ts +35 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +291 -7
- package/dist/mcp.js.map +1 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/memory.js +12 -2
- package/dist/memory.js.map +1 -1
- package/dist/model-detection.d.ts +5 -0
- package/dist/model-detection.d.ts.map +1 -1
- package/dist/model-detection.js +278 -10
- package/dist/model-detection.js.map +1 -1
- package/dist/model-router.d.ts.map +1 -1
- package/dist/model-router.js +33 -11
- package/dist/model-router.js.map +1 -1
- package/dist/plugins.d.ts +8 -0
- package/dist/plugins.d.ts.map +1 -1
- package/dist/plugins.js +97 -6
- package/dist/plugins.js.map +1 -1
- package/dist/providers/anthropic.d.ts +10 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +221 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/bedrock.d.ts +17 -0
- package/dist/providers/bedrock.d.ts.map +1 -0
- package/dist/providers/bedrock.js +574 -0
- package/dist/providers/bedrock.js.map +1 -0
- package/dist/providers/compat.d.ts +13 -0
- package/dist/providers/compat.d.ts.map +1 -0
- package/dist/providers/compat.js +202 -0
- package/dist/providers/compat.js.map +1 -0
- package/dist/providers/google.d.ts +10 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +203 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +23 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +145 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/ollama.d.ts +17 -0
- package/dist/providers/ollama.d.ts.map +1 -0
- package/dist/providers/ollama.js +289 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/openai.d.ts +121 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +485 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/types.d.ts +63 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +164 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/sandbox-native.d.ts +59 -0
- package/dist/sandbox-native.d.ts.map +1 -0
- package/dist/sandbox-native.js +292 -0
- package/dist/sandbox-native.js.map +1 -0
- package/dist/sandbox.d.ts +2 -2
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +59 -13
- package/dist/sandbox.js.map +1 -1
- package/dist/scope.d.ts +3 -1
- package/dist/scope.d.ts.map +1 -1
- package/dist/scope.js +13 -1
- package/dist/scope.js.map +1 -1
- package/dist/session-timeout.d.ts +31 -0
- package/dist/session-timeout.d.ts.map +1 -0
- package/dist/session-timeout.js +100 -0
- package/dist/session-timeout.js.map +1 -0
- package/dist/setup.d.ts.map +1 -1
- package/dist/setup.js +29 -17
- package/dist/setup.js.map +1 -1
- package/dist/smart-router.d.ts +73 -0
- package/dist/smart-router.d.ts.map +1 -0
- package/dist/smart-router.js +332 -0
- package/dist/smart-router.js.map +1 -0
- package/dist/storage.d.ts +19 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +164 -1
- package/dist/storage.js.map +1 -1
- package/dist/streaming.d.ts +4 -0
- package/dist/streaming.d.ts.map +1 -1
- package/dist/streaming.js +12 -0
- package/dist/streaming.js.map +1 -1
- package/dist/styles.d.ts +32 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +91 -0
- package/dist/styles.js.map +1 -1
- package/dist/summarization.d.ts +1 -1
- package/dist/summarization.js +4 -4
- package/dist/summarization.js.map +1 -1
- package/dist/terminal-image.d.ts +115 -0
- package/dist/terminal-image.d.ts.map +1 -0
- package/dist/terminal-image.js +766 -0
- package/dist/terminal-image.js.map +1 -0
- package/dist/terminal-recording.d.ts +55 -0
- package/dist/terminal-recording.d.ts.map +1 -0
- package/dist/terminal-recording.js +182 -0
- package/dist/terminal-recording.js.map +1 -0
- package/dist/themes.d.ts +19 -35
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +101 -210
- package/dist/themes.js.map +1 -1
- package/dist/tmux.d.ts +35 -0
- package/dist/tmux.d.ts.map +1 -0
- package/dist/tmux.js +106 -0
- package/dist/tmux.js.map +1 -0
- package/dist/tools.d.ts +3 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +587 -45
- package/dist/tools.js.map +1 -1
- package/dist/trust.d.ts +53 -0
- package/dist/trust.d.ts.map +1 -0
- package/dist/trust.js +154 -0
- package/dist/trust.js.map +1 -0
- package/dist/types.d.ts +7 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +70 -32
- package/dist/types.js.map +1 -1
- package/dist/ui/agent.d.ts +61 -0
- package/dist/ui/agent.d.ts.map +1 -0
- package/dist/ui/agent.js +768 -0
- package/dist/ui/agent.js.map +1 -0
- package/dist/ui/chat-input.d.ts +32 -0
- package/dist/ui/chat-input.d.ts.map +1 -0
- package/dist/ui/chat-input.js +355 -0
- package/dist/ui/chat-input.js.map +1 -0
- package/dist/ui/commands.d.ts +92 -0
- package/dist/ui/commands.d.ts.map +1 -0
- package/dist/ui/commands.js +3006 -0
- package/dist/ui/commands.js.map +1 -0
- package/dist/ui/completions.d.ts +22 -0
- package/dist/ui/completions.d.ts.map +1 -0
- package/dist/ui/completions.js +215 -0
- package/dist/ui/completions.js.map +1 -0
- package/dist/ui/components.d.ts +38 -0
- package/dist/ui/components.d.ts.map +1 -0
- package/dist/ui/components.js +422 -0
- package/dist/ui/components.js.map +1 -0
- package/dist/ui/context.d.ts +12 -0
- package/dist/ui/context.d.ts.map +1 -0
- package/dist/ui/context.js +102 -0
- package/dist/ui/context.js.map +1 -0
- package/dist/ui/error-boundary.d.ts +33 -0
- package/dist/ui/error-boundary.d.ts.map +1 -0
- package/dist/ui/error-boundary.js +94 -0
- package/dist/ui/error-boundary.js.map +1 -0
- package/dist/ui/frame.d.ts +13 -0
- package/dist/ui/frame.d.ts.map +1 -0
- package/dist/ui/frame.js +89 -0
- package/dist/ui/frame.js.map +1 -0
- package/dist/ui/index.d.ts +12 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +928 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/messages.d.ts +19 -0
- package/dist/ui/messages.d.ts.map +1 -0
- package/dist/ui/messages.js +181 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/modals.d.ts +52 -0
- package/dist/ui/modals.d.ts.map +1 -0
- package/dist/ui/modals.js +204 -0
- package/dist/ui/modals.js.map +1 -0
- package/dist/ui/pack-picker.d.ts +12 -0
- package/dist/ui/pack-picker.d.ts.map +1 -0
- package/dist/ui/pack-picker.js +101 -0
- package/dist/ui/pack-picker.js.map +1 -0
- package/dist/ui/status-bar.d.ts +20 -0
- package/dist/ui/status-bar.d.ts.map +1 -0
- package/dist/ui/status-bar.js +41 -0
- package/dist/ui/status-bar.js.map +1 -0
- package/dist/ui/theme-picker.d.ts +24 -0
- package/dist/ui/theme-picker.d.ts.map +1 -0
- package/dist/ui/theme-picker.js +190 -0
- package/dist/ui/theme-picker.js.map +1 -0
- package/dist/ui/types.d.ts +62 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +7 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/version-check.d.ts.map +1 -1
- package/dist/version-check.js +1 -9
- package/dist/version-check.js.map +1 -1
- package/package.json +8 -3
- package/dist/agterm/agent-detection.js.map +0 -1
- package/dist/agterm/cli-backend.js.map +0 -1
- package/dist/agterm/index.d.ts +0 -12
- package/dist/agterm/index.d.ts.map +0 -1
- package/dist/agterm/index.js +0 -15
- package/dist/agterm/index.js.map +0 -1
- package/dist/agterm/orchestrator.d.ts.map +0 -1
- package/dist/agterm/orchestrator.js.map +0 -1
- package/dist/agterm/tools.d.ts.map +0 -1
- package/dist/agterm/tools.js +0 -278
- package/dist/agterm/tools.js.map +0 -1
- package/dist/agterm/types.d.ts.map +0 -1
- package/dist/agterm/types.js.map +0 -1
- package/dist/cli.d.ts +0 -14
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/providers.d.ts +0 -51
- package/dist/providers.d.ts.map +0 -1
- package/dist/providers.js +0 -1146
- package/dist/providers.js.map +0 -1
- package/dist/ui-cli.d.ts +0 -17
- package/dist/ui-cli.d.ts.map +0 -1
- package/dist/ui-cli.js +0 -3730
- 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
|