diff --git a/openhands/wrapper/main.go b/openhands/wrapper/main.go index f80497e..38beb2a 100644 --- a/openhands/wrapper/main.go +++ b/openhands/wrapper/main.go @@ -39,13 +39,28 @@ func main() { // --------------------------------------------------------------------------- func cmdSetup() { + // 1. Check if openhands CLI exists; if not, try to install it. openhandsPath, err := exec.LookPath("openhands") if err != nil { - fmt.Fprintln(os.Stderr, "Error: openhands CLI not found on PATH.") - fmt.Fprintln(os.Stderr, "Install it with: pip install openhands-ai") - os.Exit(1) + fmt.Fprintln(os.Stderr, "OpenHands CLI not found. Installing...") + install := exec.Command("sh", "-c", "curl -fsSL https://install.openhands.dev/install.sh | sh") + install.Stdin = os.Stdin + install.Stdout = os.Stdout + install.Stderr = os.Stderr + install.Env = os.Environ() + if installErr := install.Run(); installErr != nil { + fmt.Fprintln(os.Stderr, "Failed to install OpenHands CLI.") + fmt.Fprintln(os.Stderr, "Install it manually: curl -fsSL https://install.openhands.dev/install.sh | sh") + os.Exit(1) + } + openhandsPath, err = exec.LookPath("openhands") + if err != nil { + fmt.Fprintln(os.Stderr, "OpenHands CLI still not found after install.") + os.Exit(1) + } } + // 2. Run openhands login. fmt.Fprintln(os.Stderr, "Starting OpenHands CLI login...") fmt.Fprintln(os.Stderr, "If a browser window does not open, copy the URL from the output below.") fmt.Fprintln(os.Stderr) @@ -54,8 +69,6 @@ func cmdSetup() { cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr - // Inherit full environment so DISPLAY/WAYLAND_DISPLAY are available - // for browser opening on Linux. cmd.Env = os.Environ() if err := cmd.Run(); err != nil { diff --git a/strawpot_openhands/AGENT.md b/strawpot_openhands/AGENT.md index bf1d3c8..3d1a1cc 100644 --- a/strawpot_openhands/AGENT.md +++ b/strawpot_openhands/AGENT.md @@ -10,13 +10,11 @@ metadata: macos: curl -fsSL https://raw.githubusercontent.com/strawpot/strawpot_openhands_cli/main/strawpot_openhands/install.sh | sh linux: curl -fsSL https://raw.githubusercontent.com/strawpot/strawpot_openhands_cli/main/strawpot_openhands/install.sh | sh tools: - pip: - description: Python package manager (https://python.org) openhands: - description: OpenHands CLI + description: OpenHands CLI (https://github.com/OpenHands/OpenHands-CLI) install: - macos: pip install openhands-ai - linux: pip install openhands-ai + macos: "curl -fsSL https://install.openhands.dev/install.sh | sh" + linux: "curl -fsSL https://install.openhands.dev/install.sh | sh" params: model: type: string