- Replaced the previous file extension checks with a unified parsing function for sandbox configuration, improving code clarity and maintainability. - Introduced a new HostExecConfig structure to manage local execution settings, allowing for more granular control over command execution permissions. - Removed deprecated Moapi API files and related functionality, simplifying the codebase and reducing maintenance overhead. - Updated the Tai node registration process to ensure local capabilities are accurately reflected based on the environment, enhancing overall system robustness.
37 lines
839 B
Go
37 lines
839 B
Go
package tai
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
goruntime "runtime"
|
|
|
|
"github.com/yaoapp/yao/tai/types"
|
|
)
|
|
|
|
// CollectSystemInfo gathers system information for the local host.
|
|
// The result is identical in structure to what a remote Tai node reports
|
|
// via the ServerInfo gRPC service, keeping local and remote nodes symmetric.
|
|
func CollectSystemInfo() types.SystemInfo {
|
|
hostname, _ := os.Hostname()
|
|
return types.SystemInfo{
|
|
OS: goruntime.GOOS,
|
|
Arch: goruntime.GOARCH,
|
|
Hostname: hostname,
|
|
NumCPU: goruntime.NumCPU(),
|
|
Shell: detectShell(),
|
|
TempDir: os.TempDir(),
|
|
}
|
|
}
|
|
|
|
func detectShell() string {
|
|
if goruntime.GOOS != "windows" {
|
|
return "sh"
|
|
}
|
|
if _, err := exec.LookPath("pwsh"); err == nil {
|
|
return "pwsh"
|
|
}
|
|
if _, err := exec.LookPath("powershell"); err == nil {
|
|
return "powershell"
|
|
}
|
|
return "cmd.exe"
|
|
}
|