fix: use cmd /c on Windows for shell command execution

The exec tool was hardcoded to use 'sh -c' which doesn't exist on Windows,
causing all tool calls to fail silently in gateway mode.
This commit is contained in:
mxrain
2026-02-12 14:21:04 +08:00
committed by lxowalle
parent 1d143fa10a
commit 53c69ae41e

View File

@@ -8,6 +8,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
"time"
)
@@ -91,7 +92,12 @@ func (t *ExecTool) Execute(ctx context.Context, args map[string]interface{}) (st
cmdCtx, cancel := context.WithTimeout(ctx, t.timeout)
defer cancel()
cmd := exec.CommandContext(cmdCtx, "sh", "-c", command)
var cmd *exec.Cmd
if runtime.GOOS == "windows" {
cmd = exec.CommandContext(cmdCtx, "cmd", "/c", command)
} else {
cmd = exec.CommandContext(cmdCtx, "sh", "-c", command)
}
if cwd != "" {
cmd.Dir = cwd
}