From 3b9e9a741a637e53aa4f40e735401d52ba88e639 Mon Sep 17 00:00:00 2001 From: localai-bot Date: Wed, 4 Mar 2026 17:23:30 +0000 Subject: [PATCH] chore(shell): remove interactive command check and warning This removes the isInteractiveCommand function and related warning messages while preserving the important process group management and timeout handling that prevents commands from stalling indefinitely. The process group kill on timeout and environment variables for non-interactive mode are retained as they are critical for proper cleanup. --- shell/main.go | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/shell/main.go b/shell/main.go index aada320..9fcead6 100644 --- a/shell/main.go +++ b/shell/main.go @@ -30,24 +30,6 @@ type ExecuteCommandOutput struct { Error string `json:"error,omitempty" jsonschema:"error message if execution failed"` } -// Interactive flags that commonly cause commands to hang -var interactiveFlags = []string{ - "-i", "--interactive", "--tty", "-t", - "vim", "vi", "nano", "emacs", "less", "more", "top", "htop", - "ftp", "sftp", "ssh", "ping", "tail -f", "tail -F", -} - -// isInteractiveCommand checks if the script contains interactive commands -func isInteractiveCommand(script string) bool { - scriptLower := strings.ToLower(script) - for _, flag := range interactiveFlags { - if strings.Contains(scriptLower, flag) { - return true - } - } - return false -} - // getShellCommand returns the shell command to use, defaulting to "sh" if not set func getShellCommand() string { shellCmd := os.Getenv("SHELL_CMD") @@ -89,12 +71,6 @@ func ExecuteCommand(ctx context.Context, req *mcp.CallToolRequest, input Execute timeout = getTimeout() } - // Warn about interactive commands (but still attempt execution with proper safeguards) - warningMsg := "" - if isInteractiveCommand(input.Script) { - warningMsg = "Warning: Command appears to be interactive and may hang. " - } - // Create a context with timeout cmdCtx, cancel := context.WithTimeout(ctx, time.Duration(timeout)*time.Second) defer cancel() @@ -169,11 +145,6 @@ func ExecuteCommand(ctx context.Context, req *mcp.CallToolRequest, input Execute } } - // Add warning to stderr if interactive command detected - if warningMsg != "" { - stderrBuf.WriteString("\n" + warningMsg) - } - output := ExecuteCommandOutput{ Script: input.Script, Stdout: stdoutBuf.String(),