/**
 * execute — Run shell commands in a persistent terminal.
 *
 * Inspired by VS Code Copilot's run_in_terminal:
 * - `isBackground` for long-running processes (servers, watchers)
 * - `explanation` for human-readable display of what the command does
 * - `goal` for short description shown in UI before the command runs
 * - `cwd` for setting working directory
 * - `timeout` with sensible defaults
 *
 * The terminal is visible to the user and persists between calls.
 */
import { createTerminalRunTool } from "../terminal-tools.js";
export function createExecuteTool(registry, secretInput) {
    // Delegate to the existing terminal.run implementation
    const inner = createTerminalRunTool(registry, undefined, undefined, secretInput);
    return {
        name: "execute",
        description: "Run a shell command in a persistent terminal visible to the user. " +
            "Set isBackground: true for long-running processes (servers, watchers). " +
            "Use timeout: 0 for commands that may take a long time.",
        tier: "core",
        category: "terminal",
        source: "builtin",
        parameters: {
            type: "object",
            properties: {
                command: {
                    type: "string",
                    description: "The shell command to run.",
                },
                explanation: {
                    type: "string",
                    description: "What the command does (shown to user).",
                },
                goal: {
                    type: "string",
                    description: "Short goal label for UI.",
                },
                isBackground: {
                    type: "boolean",
                    description: "True for long-running processes (servers, watchers).",
                },
                cwd: {
                    type: "string",
                    description: "Working directory (defaults to workspace root).",
                },
                terminalId: {
                    type: "string",
                    description: "Reuse a specific terminal by ID.",
                },
                timeout: {
                    type: "number",
                    description: "Timeout in ms (default 30000). Use 0 for no timeout.",
                },
                sandbox: {
                    type: "boolean",
                    description: "Run inside Docker sandbox container.",
                },
                sandboxMountMode: {
                    type: "string",
                    description: "Sandbox mount mode: none, read-only, read-write.",
                    enum: ["none", "read-only", "read-write"],
                },
            },
            required: ["command", "explanation"],
        },
        async execute(input, context) {
            // Forward all params to the inner terminal.run tool
            return inner.execute({
                command: input.command,
                terminalId: input.terminalId,
                timeout: input.timeout,
                cwd: input.cwd,
                sandbox: input.sandbox,
                sandboxMountMode: input.sandboxMountMode,
                // Pass background flag if the inner tool supports it
                ...(input.isBackground != null ? { isBackground: input.isBackground } : {}),
            }, context);
        },
    };
}
//# sourceMappingURL=execute.js.map