import { runPauseScreen } from "../modes/components/pause-screen"; import { shutdownHandlerTui } from "./builtin-lifecycle"; import { commandConsumed, errorMessage, usage } from "./helpers/parse"; import type { SlashCommandSpec } from "./types"; export const BUILTIN_CONTROL_SLASH_COMMANDS: ReadonlyArray = [ { name: "force", description: "Force next turn to use a specific tool", aliases: ["force:"], inlineHint: " [prompt]", allowArgs: true, getTuiAutocompleteDescription: runtime => { const count = runtime.ctx.session.getActiveToolNames().length; return count === 0 ? "Force: no active tools" : `Force: ${count} active tools`; }, handle: async (command, runtime) => { const spaceIdx = command.args.indexOf(" "); const toolName = spaceIdx === -1 ? command.args : command.args.slice(0, spaceIdx); const prompt = spaceIdx === -1 ? "" : command.args.slice(spaceIdx + 1).trim(); if (!toolName) return usage("Usage: /force: [prompt]", runtime); try { runtime.session.setForcedToolChoice(toolName); } catch (err) { return usage(errorMessage(err), runtime); } await runtime.output(`Next turn forced to use ${toolName}.`); return prompt ? { prompt } : commandConsumed(); }, handleTui: (command, runtime) => { const spaceIdx = command.args.indexOf(" "); const toolName = spaceIdx === -1 ? command.args : command.args.slice(0, spaceIdx); const prompt = spaceIdx === -1 ? "" : command.args.slice(spaceIdx + 1).trim(); if (!toolName) { runtime.ctx.showError("Usage: /force: [prompt]"); runtime.ctx.editor.setText(""); return; } try { runtime.ctx.session.setForcedToolChoice(toolName); runtime.ctx.showStatus(`Next turn forced to use ${toolName}.`); } catch (error) { runtime.ctx.showError(errorMessage(error)); runtime.ctx.editor.setText(""); return; } runtime.ctx.editor.setText(""); // If a prompt was provided, pass it through as input if (prompt) return { prompt }; }, }, { name: "live", description: "Start Codex-backed realtime voice mode", handleTui: async (_command, runtime) => { runtime.ctx.editor.setText(""); await runtime.ctx.handleLiveCommand(); }, }, { name: "pause", description: "Freeze all agents (main, subagents, advisor) until resumed", handleTui: async (_command, runtime) => { runtime.ctx.editor.setText(""); await runPauseScreen(runtime.ctx); }, }, { name: "quit", aliases: ["q"], description: "Quit the application", handleTui: shutdownHandlerTui, }, ];