fix: errored ssh output (#158)

fix: explain ssh output
This commit is contained in:
AKSizov
2025-05-15 22:08:50 +00:00
committed by GitHub
parent a03098b01e
commit a3977c2b1c

View File

@@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"log" "log"
"strings"
"github.com/mudler/LocalAGI/core/types" "github.com/mudler/LocalAGI/core/types"
"github.com/mudler/LocalAGI/pkg/config" "github.com/mudler/LocalAGI/pkg/config"
@@ -165,12 +166,15 @@ func sshCommand(privateKey, command, user, host string) (string, error) {
defer session.Close() defer session.Close()
// Run a command // Run a command
output, err := session.CombinedOutput(command) cmdOut, err := session.CombinedOutput(command)
if err != nil { result := string(cmdOut)
return "", fmt.Errorf("failed to run: %v", err) if strings.TrimSpace(result) == "" {
result += "\nCommand has exited with no output"
} }
if err != nil {
return string(output), nil result += "\nError: " + err.Error()
}
return result, nil
} }
func (a *ShellAction) Plannable() bool { func (a *ShellAction) Plannable() bool {