(host: SlashCommandHost, args: string)
| 13 | import type { SlashCommandHost } from './dispatch'; |
| 14 | |
| 15 | export async function handleSwarmCommand(host: SlashCommandHost, args: string): Promise<void> { |
| 16 | if (host.session === undefined) { |
| 17 | host.showError(NO_ACTIVE_SESSION_MESSAGE); |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | const prompt = args.trim(); |
| 22 | const mode = swarmModeSubcommand(prompt); |
| 23 | if (mode !== undefined) { |
| 24 | await applySwarmMode(host, mode, `/swarm ${prompt}`); |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | if (prompt.length === 0) { |
| 29 | await applySwarmMode(host, !host.state.appState.swarmMode, '/swarm'); |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | if (host.state.appState.model.trim().length === 0) { |
| 34 | host.showError(LLM_NOT_SET_MESSAGE); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | if (host.state.appState.permissionMode === 'manual') { |
| 39 | showSwarmStartPermissionPrompt(host, `/swarm ${prompt}`, 'Swarm task not started.', (choice) => |
| 40 | startSwarmWithPermission(host, prompt, choice), |
| 41 | ); |
| 42 | return; |
| 43 | } |
| 44 | |
| 45 | await startSwarmTask(host, prompt); |
| 46 | } |
| 47 | |
| 48 | function showSwarmStartPermissionPrompt( |
| 49 | host: SlashCommandHost, |
no test coverage detected