### Shell commands for OpenHands SDK setup and execution Source: https://docs.all-hands.dev/sdk This sequence of shell commands outlines the setup process for the OpenHands SDK. It includes cloning the repository, navigating into the directory, building the project with `make build` to install dependencies, and finally running the 'Hello World' example script using `uv`. ```bash # Clone the repository git clone https://github.com/All-Hands-AI/agent-sdk.git cd agent-sdk # Install dependencies and setup development environment make build # Verify installation uv run python examples/01_hello_world.py ``` -------------------------------- ### Install and Launch OpenHands with pip CLI Source: https://docs.all-hands.dev/openhands/usage/run-openhands/local-setup Installs OpenHands using pip and launches the GUI server. Note that uv is still required for default MCP servers to function correctly. Requires Python 3.12+. ```bash # Install OpenHands pip install openhands # Launch the GUI server openhands serve ``` -------------------------------- ### Install Websocat for WebSocket Testing Source: https://docs.all-hands.dev/openhands/usage/developers/websocket-connection Provides installation instructions for websocat, a command-line tool for interacting with WebSockets. It includes commands for macOS using Homebrew and Linux using a direct download. ```bash # On macOS brew install websocat # On Linux curl -L https://github.com/vi/websocat/releases/download/v1.11.0/websocat.x86_64-unknown-linux-musl > websocat chmod +x websocat sudo mv websocat /usr/local/bin/ ``` -------------------------------- ### OpenHands Repository Setup Script (.openhands/setup.sh) Source: https://docs.all-hands.dev/openhands/usage/customization/repository A bash script that runs automatically when OpenHands starts working with a repository. It's used for tasks like installing dependencies, setting environment variables, and performing initial project setup. Ensure the script has execute permissions. ```bash #!/bin/bash export MY_ENV_VAR="my value" sudo apt-get update sudo apt-get install -y lsof cd frontend && npm install ; cd .. ``` -------------------------------- ### Example OpenHands Command Execution Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness An example of a complete command-line execution of OpenHands. This command specifies 10 iterations, a task to write a bash script, uses the CodeActAgent, and loads the LLM configuration from the 'llm' section of `config.toml`. ```bash poetry run python ./openhands/core/main.py \ -i 10 \ -t "Write me a bash script that prints hello world." \ -c CodeActAgent \ -l llm ``` -------------------------------- ### Start SuperGateway Proxy Servers (Bash) Source: https://docs.all-hands.dev/openhands/usage/settings/mcp-settings This snippet shows how to start SuperGateway proxy servers for both filesystem and fetch MCP servers. These commands are intended to be run in separate terminals. They convert stdio-based MCP servers into HTTP/SSE endpoints. ```bash # Terminal 1: Filesystem server proxy supergateway --stdio "npx @modelcontextprotocol/server-filesystem /" --port 8080 # Terminal 2: Fetch server proxy supergateway --stdio "uvx mcp-server-fetch" --port 8081 ``` -------------------------------- ### Example: Start OpenHands with Local Runtime (Headless) Source: https://docs.all-hands.dev/openhands/usage/runtimes/local This example demonstrates how to initiate OpenHands using the local runtime in headless mode. It first sets the necessary environment variables for the runtime and volume mapping, then executes the main Python module with a specific task. ```bash export RUNTIME=local export SANDBOX_VOLUMES=/my_folder/myproject:/workspace:rw poetry run python -m openhands.core.main -t "write a bash script that prints hi" ``` -------------------------------- ### Launch OpenHands GUI with uv CLI Source: https://docs.all-hands.dev/openhands/usage/run-openhands/local-setup Launches the OpenHands GUI server using the uvx command. Supports GPU acceleration with nvidia-docker and mounting the current directory into the container. Requires Python 3.12. ```bash # Launch the GUI server uvx --python 3.12 openhands serve # Or with GPU support (requires nvidia-docker) uvx --python 3.12 openhands serve --gpu # Or with current directory mounted uvx --python 3.12 openhands serve --mount-cwd ``` -------------------------------- ### Launch OpenHands GUI Server via CLI Source: https://docs.all-hands.dev/openhands/usage/run-openhands/gui-mode Launches the OpenHands GUI server using the 'serve' command. This command checks for Docker, pulls necessary images, and starts the server. It utilizes the default configuration directory and starts the GUI at http://localhost:3000. Prerequisites include having the OpenHands CLI or uv installed, or using Docker directly. ```bash openhands serve ``` -------------------------------- ### Run OpenHands Locally with Docker (Windows) Source: https://docs.all-hands.dev/openhands/usage/runtimes/daytona Initiates the OpenHands runtime on Windows by downloading and executing an installation script via PowerShell. This command fetches the latest Windows release of OpenHands, installs it, and runs it using Docker. Requires PowerShell and internet access. ```powershell powershell -Command "irm https://get.daytona.io/openhands-windows | iex" ``` -------------------------------- ### OpenHands Server Log Output Source: https://docs.all-hands.dev/openhands/usage/llms/local-llms This is an example log output from the OpenHands application upon successful startup. It indicates that the Docker image is up to date, the server process has started, and the application is running on http://0.0.0.0:3000. ```log Digest: sha256:e72f9baecb458aedb9afc2cd5bc935118d1868719e55d50da73190d3a85c674f Status: Image is up to date for docker.all-hands.dev/all-hands-ai/openhands:0.59 Starting OpenHands... Running OpenHands as root 14:22:13 - openhands:INFO: server_config.py:50 - Using config class None INFO: Started server process [8] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:3000 (Press CTRL+C to quit) ``` -------------------------------- ### GET /api/user/installations Source: https://docs.all-hands.dev/api-reference/get-user-installations Retrieves a list of user installations. You can filter the installations by providing a specific provider. ```APIDOC ## GET /api/user/installations ### Description Retrieves a list of user installations. You can filter the installations by providing a specific provider. ### Method GET ### Endpoint /api/user/installations ### Parameters #### Query Parameters - **provider** (enum) - Required - The provider for which to retrieve installations. Allowed values: github, gitlab, bitbucket, enterprise_sso. #### Request Body This endpoint does not accept a request body. ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **items** (array) - A list of user installation identifiers. #### Response Example ```json { "example": [ "" ] } ``` #### Error Response (422) - **detail** (array) - Details about the validation error. - **loc** (array) - The location of the error in the request. - **msg** (string) - The error message. - **type** (string) - The type of error. #### Error Response Example ```json { "example": { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } } ``` ``` -------------------------------- ### Run OpenHands Directly with Docker Source: https://docs.all-hands.dev/openhands/usage/run-openhands/local-setup Pulls the OpenHands Docker image and runs it directly. This command configures necessary environment variables, mounts volumes for persistent data and Docker socket access, and maps the application port. ```bash docker pull docker.all-hands.dev/all-hands-ai/runtime:0.59-nikolaik docker run -it --rm --pull=always \ -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.59-nikolaik \ -e LOG_ALL_EVENTS=true \ -v /var/run/docker.sock:/var/run/docker.sock \ -v ~/.openhands:/.openhands \ -p 3000:3000 \ --add-host host.docker.internal:host-gateway \ --name openhands-app \ docker.all-hands.dev/all-hands-ai/openhands:0.59 ``` -------------------------------- ### Configure Direct Stdio Servers (TOML) Source: https://docs.all-hands.dev/openhands/usage/settings/mcp-settings This TOML configuration demonstrates how to set up direct stdio connections to MCP servers. It's recommended for development and testing only. Examples include a basic fetch server and a filesystem server with environment variables. ```toml [mcp] # Direct stdio servers - use only for development/testing stdio_servers = [ # Basic stdio server {name="fetch", command="uvx", args=["mcp-server-fetch"]}, # Stdio server with environment variables { name="filesystem", command="npx", args=["@modelcontextprotocol/server-filesystem", "/"], env={ "DEBUG": "true" } } ] ``` -------------------------------- ### Run OpenHands Locally with Docker (Mac/Linux) Source: https://docs.all-hands.dev/openhands/usage/runtimes/daytona Downloads and executes the OpenHands runtime script from Daytona on macOS and Linux. It automatically fetches the latest OpenHands release, pulls the necessary Docker image, and starts the container. Requires curl and bash. ```bash bash -i <(curl -sL https://get.daytona.io/openhands) ``` -------------------------------- ### Install ArcticInference for vLLM Source: https://docs.all-hands.dev/openhands/usage/llms/local-llms Installs the ArcticInference library, which patches vLLM for potentially faster inference speeds using speculative decoding. ```bash pip install git+https://github.com/snowflakedb/ArcticInference.git ``` -------------------------------- ### Install and Launch OpenHands using pip Source: https://docs.all-hands.dev/usage/run-openhands/local-setup This option demonstrates installing OpenHands using pip and then launching the GUI server. Note that uv is still recommended for certain default MCP servers to function correctly. Requires Python 3.12+. ```bash # Install OpenHands pip install openhands # Launch the GUI server openhands serve ``` -------------------------------- ### Install Poetry (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Installs the Poetry dependency management tool using a PowerShell command. It downloads and executes the installer script. ```powershell (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python - ``` -------------------------------- ### Initialize Runtime Environment - Python Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness A placeholder function to set up the evaluation environment within the provided `Runtime` instance. This function can be customized to configure environment variables, prepare necessary files, or perform other setup tasks before the agent execution begins. ```python from openhands.runtime.runtime import Runtime def initialize_runtime(runtime: Runtime, instance: pd.Series): # Set up your evaluation environment here # For example, setting environment variables, preparing files, etc. pass ``` -------------------------------- ### Start Conversation using TypeScript/JavaScript (fetch) Source: https://docs.all-hands.dev/modules/usage/cloud/cloud-api Example of initiating a new conversation with the OpenHands API using the fetch API in TypeScript/JavaScript. This shows how to construct the POST request with necessary headers and a JSON body. ```typescript const apiKey = "YOUR_API_KEY"; const url = "https://app.all-hands.dev/api/conversations"; const headers = { "Authorization": `Bearer ${apiKey}`, "Content-Type": "application/json" }; const data = { "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", "repository": "yourusername/your-repo" }; fetch(url, { method: "POST", headers: headers, body: JSON.stringify(data) }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error('Error:', error)); ``` -------------------------------- ### Start Conversation using cURL Source: https://docs.all-hands.dev/modules/usage/cloud/cloud-api Example of initiating a new conversation with the OpenHands API using cURL. This request requires an API key for authorization and specifies the initial user message and repository. ```shell curl -X POST "https://app.all-hands.dev/api/conversations" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", "repository": "yourusername/your-repo" }' ``` -------------------------------- ### Install E2B CLI with NPM Source: https://docs.all-hands.dev/usage/runtimes/e2b Installs the latest version of the E2B command-line interface globally using NPM. This tool is used for managing and interacting with E2B sandboxes. ```bash npm install -g @e2b/cli@latest ``` -------------------------------- ### Start Conversation using Python (requests) Source: https://docs.all-hands.dev/modules/usage/cloud/cloud-api Example of initiating a new conversation with the OpenHands API using Python's requests library. This demonstrates sending a POST request with JSON payload and authorization headers. ```python import requests api_key = "YOUR_API_KEY" url = "https://app.all-hands.dev/api/conversations" headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" } data = { "initial_user_msg": "Check whether there is any incorrect information in the README.md file and send a PR to fix it if so.", "repository": "yourusername/your-repo" } response = requests.post(url, headers=headers, json=data) print(response.json()) ``` -------------------------------- ### Run OpenHands in Development Mode Source: https://docs.all-hands.dev/openhands/usage/llms/local-llms Builds and starts the OpenHands application in development mode. This requires following instructions in the Development.md file for building the application. ```bash make run ``` -------------------------------- ### Install Third-Party Runtimes for OpenHands Source: https://docs.all-hands.dev/openhands/usage/runtimes/overview Installs the necessary extra dependencies for using third-party runtimes with OpenHands. This command allows integration with runtimes like E2B, Modal, Runloop, and Daytona. ```bash pip install openhands-ai[third_party_runtimes] ``` -------------------------------- ### Connect to OpenHands WebSocket with JavaScript (Socket.IO) Source: https://docs.all-hands.dev/openhands/usage/developers/websocket-connection Establishes a WebSocket connection to the OpenHands API using the socket.io-client library. It handles connection, disconnection, and receiving events. This example requires the 'socket.io-client' package. ```javascript import { io } from "socket.io-client"; const socket = io("http://localhost:3000", { transports: ["websocket"], query: { conversation_id: "your-conversation-id", latest_event_id: -1, providers_set: "github,gitlab" // Optional } }); socket.on("connect", () => { console.log("Connected to OpenHands WebSocket"); }); socket.on("oh_event", (event) => { console.log("Received event:", event); }); socket.on("connect_error", (error) => { console.error("Connection error:", error); }); socket.on("disconnect", (reason) => { console.log("Disconnected:", reason); }); ``` -------------------------------- ### Handle Agent Events from OpenHands WebSocket (JavaScript) Source: https://docs.all-hands.dev/openhands/usage/developers/websocket-connection Provides an example of how to listen for and process events received from the OpenHands agent via the WebSocket. It shows how to differentiate between message events and action results. ```javascript // Assuming 'socket' is an established WebSocket connection socket.on("oh_event", (event) => { if (event.source === "agent" && event.type === "message") { console.log("Agent says:", event.message); } else if (event.action === "run") { console.log("Command executed:", event.args.command); console.log("Result:", event.result); } }); ``` -------------------------------- ### Import OpenHands and Evaluation Utilities Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness Imports essential modules from OpenHands and the evaluation utilities for setting up and running benchmarks. This includes classes for agents, controllers, runtimes, configurations, and specific evaluation components. ```python import openhands.agenthub from evaluation.utils.shared import ( EvalMetadata, EvalOutput, make_metadata, prepare_dataset, reset_logger_for_multiprocessing, run_evaluation, ) from openhands.controller.state.state import State from openhands.core.config import ( AppConfig, SandboxConfig, get_llm_config_arg, parse_arguments, ) from openhands.core.logger import openhands_logger as logger from openhands.core.main import create_runtime, run_controller from openhands.events.action import CmdRunAction from openhands.events.observation import CmdOutputObservation, ErrorObservation from openhands.runtime.runtime import Runtime ``` -------------------------------- ### Configure SSE and SHTTP Servers (TOML) Source: https://docs.all-hands.dev/openhands/usage/settings/mcp-settings This TOML configuration defines how OpenHands connects to MCP servers using SSE and SHTTP protocols. It includes examples for basic URLs, proxy endpoints, and servers with custom timeouts and API keys. The SSE servers section illustrates recommended proxy tool usage. ```toml [mcp] # SSE Servers - Recommended approach using proxy tools sse_servers = [ # Basic SSE server with just a URL "http://example.com:8080/mcp", # SuperGateway proxy for fetch server "http://localhost:8081/sse", # External MCP service with authentication {url="https://api.example.com/mcp/sse", api_key="your-api-key"} ] # SHTTP Servers - Modern streamable HTTP transport (recommended) shttp_servers = [ # Basic SHTTP server with default 60s timeout "https://api.example.com/mcp/shttp", # Server with custom timeout for heavy operations { url = "https://files.example.com/mcp/shttp", api_key = "your-api-key", timeout = 1800 # 30 minutes for large file processing } ] ``` -------------------------------- ### API Response Example for Conversation Creation Source: https://docs.all-hands.dev/openhands/usage/cloud/cloud-api Illustrates the JSON structure returned by the OpenHands Cloud API after successfully starting a new conversation. It includes the status of the operation and a unique identifier for the conversation. ```json { "status": "ok", "conversation_id": "abc1234" } ``` -------------------------------- ### Verify Git Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Checks if Git has been successfully installed and added to the system's PATH. This command verifies Git's availability for cloning repositories. ```powershell git --version ``` -------------------------------- ### Create Custom Docker Image with Ruby Source: https://docs.all-hands.dev/openhands/usage/advanced/custom-sandbox-guide This snippet demonstrates how to create a custom Dockerfile to install Ruby within a Debian-based image for the OpenHands sandbox. It starts from a base Python-Node.js image and adds Ruby using apt-get. It assumes a Debian-based distribution. ```dockerfile FROM nikolaik/python-nodejs:python3.12-nodejs22 # Install required packages RUN apt-get update && apt-get install -y ruby ``` -------------------------------- ### API Response for Conversation Creation Source: https://docs.all-hands.dev/modules/usage/cloud/cloud-api Example of a successful JSON response from the OpenHands API after starting a new conversation. It includes the status and the unique identifier for the created conversation. ```json { "status": "ok", "conversation_id": "abc1234" } ``` -------------------------------- ### Build Frontend for OpenHands Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl This command sequence navigates to the frontend directory, installs dependencies using npm, and then builds the frontend assets. These assets are served by the backend. ```powershell cd frontend npm install npm run build cd .. ``` -------------------------------- ### Verify Poetry Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Checks if Poetry has been installed correctly and is accessible. This command verifies that Poetry is available in the system's PATH. ```powershell poetry --version ``` -------------------------------- ### Install OpenHands Dependencies (Poetry) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Installs all project dependencies for OpenHands using Poetry. This includes pythonnet for Windows PowerShell integration and other necessary libraries. ```powershell poetry install ``` -------------------------------- ### Verify .NET Core Runtime Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Confirms the installation of the .NET Core Runtime by displaying its information. This is crucial for PowerShell integration with pythonnet. ```powershell dotnet --info ``` -------------------------------- ### Install .NET SDK 8 using winget Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Installs the .NET SDK version 8 using the Windows Package Manager (winget). This is a prerequisite for the OpenHands CLI on Windows, as it provides the necessary .NET Core runtime for PowerShell integration. An alternative is manual download from the official Microsoft website. ```powershell winget install Microsoft.DotNet.SDK.8 ``` -------------------------------- ### Install and Run via uv - Bash Source: https://docs.all-hands.dev/openhands/usage/run-openhands/cli-mode This command uses 'uvx' to install and run OpenHands with a specific Python version (3.12). This method requires Python 3.12+ and uv to be installed. ```bash uvx --python 3.12 openhands ``` -------------------------------- ### GET /api/settings Source: https://docs.all-hands.dev/api-reference/load-settings Retrieves the current settings for the All-Hands.dev project. This includes configurations for language, agent, LLM, security, and more. ```APIDOC ## GET /api/settings ### Description Retrieves the current settings for the All-Hands.dev project. This includes configurations for language, agent, LLM, security, and more. ### Method GET ### Endpoint /api/settings ### Parameters #### Query Parameters None #### Request Body None ### Response #### Success Response (200) - **language** (string | null) - The default language for the project. - **agent** (string | null) - The name of the agent used for tasks. - **max_iterations** (integer | null) - The maximum number of iterations for task execution. - **security_analyzer** (string | null) - The security analyzer to be used. - **confirmation_mode** (boolean | null) - Whether confirmation mode is enabled. - **llm_model** (string | null) - The language model to be used. - **llm_api_key** (string (password) | null) - The API key for the language model. - **llm_base_url** (string | null) - The base URL for the language model API. - **remote_runtime_resource_factor** (integer | null) - Resource factor for remote runtime. - **secrets_store** (object | null) - Configuration for the secrets store (UserSecrets-Output). - **enable_default_condenser** (boolean) - Whether the default condenser is enabled (defaults to true). - **enable_sound_notifications** (boolean) - Whether sound notifications are enabled (defaults to false). - **enable_proactive_conversation_starters** (boolean) - Whether proactive conversation starters are enabled (defaults to true). - **enable_solvability_analysis** (boolean) - Whether solvability analysis is enabled (defaults to true). - **user_consents_to_analytics** (boolean | null) - Whether the user consents to analytics. - **sandbox_base_container_image** (string | null) - The base container image for the sandbox. - **sandbox_runtime_container_image** (string | null) - The runtime container image for the sandbox. - **mcp_config** (object | null) - MCP configuration. - **search_api_key** (string (password) | null) - The API key for the search service. - **sandbox_api_key** (string (password) | null) - The API key for the sandbox environment. - **max_budget_per_task** (number | null) - The maximum budget per task. #### Response Example ```json { "language": "en", "agent": "default-agent", "max_iterations": 10, "security_analyzer": "none", "confirmation_mode": false, "llm_model": "gpt-4", "llm_api_key": "sk-********", "llm_base_url": null, "remote_runtime_resource_factor": 1, "secrets_store": { "type": "env" }, "enable_default_condenser": true, "enable_sound_notifications": false, "enable_proactive_conversation_starters": true, "enable_solvability_analysis": true, "user_consents_to_analytics": true, "sandbox_base_container_image": "ubuntu:latest", "sandbox_runtime_container_image": "ubuntu:latest", "mcp_config": { "enabled": true }, "search_api_key": null, "sandbox_api_key": null, "max_budget_per_task": 100 } ``` ``` -------------------------------- ### Verify Node.js and npm Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Verifies the installation of Node.js and its package manager, npm. This ensures that the frontend dependencies for OpenHands can be managed. ```powershell node --version npm --version ``` -------------------------------- ### Run OpenHands from Command Line Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness This Bash script demonstrates how to execute the OpenHands core script from the command line. It outlines the command structure with placeholders for maximum iterations, task description, agent class, and LLM configuration. ```bash poetry run python ./openhands/core/main.py \ -i \ -t "" \ -c \ -l ``` -------------------------------- ### Install uv Package Manager Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Installs the uv Python package manager using PowerShell. This command bypasses the execution policy to download and execute an installation script from a remote URL. It requires Administrator privileges. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Start OpenHands Backend Server Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Starts the OpenHands backend server using PowerShell 7 (pwsh). It sets the runtime to 'local' and configures uvicorn to serve the application on host 0.0.0.0 and port 3000 with hot reloading, excluding the './workspace' directory from reloads. Ensure PowerShell 7 is used to avoid 'System.Management.Automation' errors. ```powershell # Make sure to use PowerShell 7 (pwsh) instead of Windows PowerShell pwsh $env:RUNTIME="local"; poetry run uvicorn openhands.server.listen:app --host 0.0.0.0 --port 3000 --reload --reload-exclude "./workspace" ``` -------------------------------- ### Serve Ollama with Extended Context Length Source: https://docs.all-hands.dev/openhands/usage/llms/local-llms Starts the Ollama server with a significantly increased context length to accommodate larger prompts and improve agent behavior. It also configures the host, port, and keep-alive settings. ```bash OLLAMA_CONTEXT_LENGTH=32768 OLLAMA_HOST=0.0.0.0:11434 OLLAMA_KEEP_ALIVE=-1 nohup ollama serve & ``` -------------------------------- ### Verify PowerShell 7 Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Checks if PowerShell 7 is installed and accessible. Running this command in a new terminal confirms the correct installation and PATH configuration for PowerShell 7. ```powershell pwsh --version ``` -------------------------------- ### Launch OpenHands using uv CLI Launcher Source: https://docs.all-hands.dev/usage/run-openhands/local-setup This snippet shows how to launch the OpenHands GUI server using the uv command-line tool. It supports different configurations, including GPU support and mounting the current directory. Ensure uv is installed and Python 3.12+ is available. ```bash # Launch the GUI server uvx --python 3.12 openhands serve # Or with GPU support (requires nvidia-docker) uvx --python 3.12 openhands serve --gpu # Or with current directory mounted uvx --python 3.12 openhands serve --mount-cwd ``` -------------------------------- ### GET /api/user/repositories Source: https://docs.all-hands.dev/api-reference/get-user-repositories Retrieves a list of repositories associated with the authenticated user. Supports filtering by provider, sorting, and pagination. ```APIDOC ## GET /api/user/repositories ### Description Retrieves a list of repositories associated with the authenticated user. Supports filtering by provider, sorting, and pagination. ### Method GET ### Endpoint https://app.all-hands.dev/api/user/repositories ### Parameters #### Query Parameters - **sort** (string) - Optional - Controls the sorting order of repositories. Defaults to 'pushed'. - **selected_provider** (enum) - Optional - Filters repositories by the Git provider (e.g., 'github', 'gitlab', 'bitbucket', 'enterprise_sso'). - **page** (integer) - Optional - Specifies the page number for paginated results. - **per_page** (integer) - Optional - Determines the number of repositories to return per page. - **installation_id** (string) - Optional - The installation ID for enterprise SSO providers. ### Request Example ```json { "example": "(No request body for GET request)" } ``` ### Response #### Success Response (200) - **items** (array of Repository) - A list of repository objects. - **id** (string) - The unique identifier of the repository. - **full_name** (string) - The full name of the repository (e.g., 'owner/repo-name'). - **git_provider** (ProviderType) - The Git provider of the repository (e.g., 'github', 'gitlab'). - **is_public** (boolean) - Indicates if the repository is public. - **stargazers_count** (integer) - The number of stars the repository has. - **link_header** (string) - Link header for pagination. - **pushed_at** (string) - Timestamp of the last push to the repository. - **owner_type** (OwnerType) - The type of the repository owner (e.g., 'user', 'organization'). - **main_branch** (string) - The name of the main branch. #### Response Example ```json { "example": [ { "id": "", "full_name": "", "git_provider": "github", "is_public": true, "stargazers_count": 123, "link_header": "", "pushed_at": "", "owner_type": "user", "main_branch": "" } ] } ``` #### Error Response (422) - **detail** (array of ValidationError) - A list of validation errors. - **loc** (array) - The location of the error in the request. - **msg** (string) - The error message. - **type** (string) - The type of the error. #### Error Response Example ```json { "example": { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } } ``` ``` -------------------------------- ### Verify Python Installation (PowerShell) Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl Verifies the installation of Python by checking its version. This command is run in PowerShell after Python has been added to the system's PATH. ```powershell python --version ``` -------------------------------- ### POST /api/conversations/{conversation_id}/start Source: https://docs.all-hands.dev/api-reference/start-conversation Starts an agent loop for a conversation. If the conversation is already running, it returns the existing agent loop info. ```APIDOC ## POST /api/conversations/{conversation_id}/start ### Description Starts an agent loop for a conversation. If the conversation is already running, it will return the existing agent loop info. ### Method POST ### Endpoint https://app.all-hands.dev/api/conversations/{conversation_id}/start ### Parameters #### Path Parameters - **conversation_id** (string) - Required - The unique identifier for the conversation. #### Query Parameters None #### Request Body - **providers_set** (array of ProviderType) - Required - A set of providers to use for the conversation. ### Request Example ```json { "providers_set": [ "github" ] } ``` ### Response #### Success Response (200) - **status** (string) - The status of the operation. - **conversation_id** (string) - The ID of the conversation. - **message** (string | null) - An optional message related to the conversation status. - **conversation_status** (ConversationStatus | null) - The current status of the conversation. #### Response Example ```json { "status": "", "conversation_id": "", "message": "", "conversation_status": "STARTING" } ``` #### Error Response (422) - **detail** (array of ValidationError) - Details about validation errors. #### Error Response Example ```json { "detail": [ { "loc": [ "" ], "msg": "", "type": "" } ] } ``` ``` -------------------------------- ### GET /websites/all-hands_dev/settings Source: https://docs.all-hands.dev/api-reference/load-settings Retrieves the current user settings, including API keys, model configurations, and notification preferences. ```APIDOC ## GET /websites/all-hands_dev/settings ### Description Retrieves the current user settings, including API keys, model configurations, and notification preferences. ### Method GET ### Endpoint /websites/all-hands_dev/settings ### Parameters This endpoint does not accept any path or query parameters. ### Request Body This endpoint does not accept a request body. ### Request Example ```json { "example": "No request body needed for this GET request." } ``` ### Response #### Success Response (200) - **language** (string) - The user's preferred language. - **agent** (string) - The default agent configuration. - **max_iterations** (integer) - The maximum number of iterations for agent tasks. - **security_analyzer** (string) - The security analyzer configuration. - **confirmation_mode** (boolean) - Whether confirmation mode is enabled. - **llm_model** (string) - The language model to use. - **llm_api_key** (string) - The API key for the language model. - **llm_base_url** (string) - The base URL for the language model API. - **remote_runtime_resource_factor** (integer) - Resource factor for remote runtime. - **secrets_store** (object) - Configuration for secrets storage. - **provider_tokens** (object) - Provider-specific tokens. - **custom_secrets** (object) - Custom secrets. - **enable_default_condenser** (boolean) - Whether to enable the default condenser. - **enable_sound_notifications** (boolean) - Whether to enable sound notifications. - **enable_proactive_conversation_starters** (boolean) - Whether to enable proactive conversation starters. - **enable_solvability_analysis** (boolean) - Whether to enable solvability analysis. - **user_consents_to_analytics** (boolean) - Whether the user consents to analytics. - **sandbox_base_container_image** (string) - The base container image for the sandbox. - **sandbox_runtime_container_image** (string) - The runtime container image for the sandbox. - **mcp_config** (object) - Message Control Protocol (MCP) configuration. - **sse_servers** (array) - List of MCP SSE server configurations. - **url** (string) - URL of the SSE server. - **api_key** (string) - API key for the SSE server. - **stdio_servers** (array) - List of MCP stdio server configurations. - **name** (string) - Name of the stdio server. - **command** (string) - Command to run the stdio server. - **args** (array of strings) - Arguments for the stdio server command. - **env** (object) - Environment variables for the stdio server. - **shttp_servers** (array) - List of MCP shttp server configurations. - **url** (string) - URL of the shttp server. - **api_key** (string) - API key for the shttp server. - **search_api_key** (string) - The API key for the search service. - **sandbox_api_key** (string) - The API key for the sandbox environment. - **max_budget_per_task** (integer) - The maximum budget allowed per task. - **email** (string) - The user's email address. - **email_verified** (boolean) - Whether the user's email has been verified. - **git_user_name** (string) - The user's Git username. - **git_user_email** (string) - The user's Git user email. - **provider_tokens_set** (object) - Indicates if provider tokens have been set. - **llm_api_key_set** (boolean) - Indicates if the LLM API key has been set. - **search_api_key_set** (boolean) - Indicates if the search API key has been set. #### Response Example (200) ```json { "language": "en", "agent": "default_agent", "max_iterations": 100, "security_analyzer": "basic", "confirmation_mode": true, "llm_model": "gpt-4", "llm_api_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "llm_base_url": "https://api.openai.com/v1", "remote_runtime_resource_factor": 1, "secrets_store": { "provider_tokens": {}, "custom_secrets": {} }, "enable_default_condenser": true, "enable_sound_notifications": false, "enable_proactive_conversation_starters": true, "enable_solvability_analysis": true, "user_consents_to_analytics": true, "sandbox_base_container_image": "ubuntu:latest", "sandbox_runtime_container_image": "ubuntu:latest", "mcp_config": { "sse_servers": [ { "url": "https://mcp.example.com/sse", "api_key": "mcp_sse_key" } ], "stdio_servers": [ { "name": "stdio_server_1", "command": "/usr/bin/stdio_server", "args": ["--port", "8080"], "env": {} } ], "shttp_servers": [ { "url": "https://mcp.example.com/shttp", "api_key": "mcp_shttp_key" } ] }, "search_api_key": "search_key_xxxxxxxxxx", "sandbox_api_key": "sandbox_key_xxxxxxxxxx", "max_budget_per_task": 1000, "email": "user@example.com", "email_verified": true, "git_user_name": "gituser", "git_user_email": "gituser@example.com", "provider_tokens_set": {}, "llm_api_key_set": true, "search_api_key_set": false } ``` #### Error Response (401) - **Description**: Invalid token. - **Response Example**: ```json {} ``` #### Error Response (404) - **Description**: Settings not found. - **Response Example**: ```json {} ``` ``` -------------------------------- ### Run the Full Evaluation Workflow - Python Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness Orchestrates the entire evaluation process. It prepares metadata and the dataset, then calls `run_evaluation` to process all instances in parallel using the defined `process_instance` function. Results are saved to a specified output file. ```python import os # Assuming make_metadata, prepare_dataset, run_evaluation, process_instance are defined # and llm_config, dataset_name, agent_class, max_iterations, eval_note, eval_output_dir, # your_dataset, eval_n_limit, num_workers are available in the scope metadata = make_metadata(llm_config, dataset_name, agent_class, max_iterations, eval_note, eval_output_dir) output_file = os.path.join(metadata.eval_output_dir, 'output.jsonl') instances = prepare_dataset(your_dataset, output_file, eval_n_limit) await run_evaluation( instances, metadata, output_file, num_workers, process_instance ) ``` -------------------------------- ### Run OpenHands with PowerShell 7 Source: https://docs.all-hands.dev/openhands/usage/windows-without-wsl This sequence of commands demonstrates how to launch OpenHands using PowerShell 7. It involves starting PowerShell 7, navigating to the project directory, setting an environment variable, and running the uvicorn server for local development. ```powershell pwsh cd path\to\openhands $env:RUNTIME="local"; poetry run uvicorn openhands.server.listen:app --host 0.0.0.0 --port 3000 --reload --reload-exclude "./workspace" ``` -------------------------------- ### GET /api/options/config Source: https://docs.all-hands.dev/api-reference/get-config Retrieves the current configuration settings for the application. ```APIDOC ## GET /api/options/config ### Description Get current config. ### Method GET ### Endpoint /api/options/config ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **Response Get Config Api Options Config Get** (object) - Successful Response #### Response Example ```json {} ``` ### Authentication Requires an API key in the `X-Session-API-Key` header. ``` -------------------------------- ### OpenAPI Definition for GET /api/user/info Source: https://docs.all-hands.dev/api-reference/get-user This OpenAPI specification defines the GET /api/user/info endpoint. It includes details on request parameters, security (API key header), response schema for a successful user object, and server URLs for production and local development. The response includes user ID, login, avatar URL, company, name, and email. ```yaml paths: /api/user/info: get: servers: - url: https://app.all-hands.dev description: Production server - url: http://localhost:3000 description: Local development server request: security: - title: APIKeyHeader parameters: header: X-Session-API-Key: type: apiKey response: '200': application/json: schema: type: object properties: id: type: string title: Id login: type: string title: Login avatar_url: type: string title: Avatar Url company: anyOf: - type: string - type: 'null' title: Company name: anyOf: - type: string - type: 'null' title: Name email: anyOf: - type: string - type: 'null' title: Email requiredProperties: - id - login - avatar_url examples: example: value: id: "" login: "" avatar_url: "" company: "" name: "" email: "" description: Successful Response components: schemas: {} ``` -------------------------------- ### Create Docker Network and Run Redis for Sidecar Source: https://docs.all-hands.dev/openhands/usage/runtimes/docker This snippet demonstrates creating a custom Docker network named 'openhands-sccache' and running a Redis container on this network. This setup is a prerequisite for attaching sandbox containers to this network using SANDBOX_ADDITIONAL_NETWORKS. ```bash docker network create openhands-sccache docker run -d \ --hostname openhandsredis \ --network openhands-sccache \ redis ``` -------------------------------- ### OpenAPI Specification for Get Repository Microagents Source: https://docs.all-hands.dev/api-reference/get-repository-microagents This OpenAPI specification defines the GET /api/user/repository/{repository_name}/microagents endpoint. It details the request parameters, including the repository name, and the structure of the successful JSON response, which lists microagents with their name, path, and creation timestamp. It also defines the error response for validation errors. ```yaml openapi: 3.0.0 info: title: Get Repository Microagents API version: 1.0.0 paths: /api/user/repository/{repository_name}/microagents: get: summary: Get list of microagents in a repository parameters: - name: repository_name in: path required: true schema: type: string description: The name of the repository to scan for microagents. responses: '200': description: A list of microagents found in the repository. content: application/json: schema: type: array items: $ref: '#/components/schemas/MicroagentResponse' '422': description: Validation error if the repository name is invalid. content: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' components: schemas: MicroagentResponse: type: object properties: name: type: string description: The name of the microagent. path: type: string description: The path to the microagent within the repository. created_at: type: string format: date-time description: The timestamp when the microagent was created. required: - name - path - created_at ValidationError: type: object properties: loc: type: array items: oneOf: - type: string - type: integer description: Location of the error in the request. msg: type: string description: The error message. type: type: string description: The type of error. required: - loc - msg - type HTTPValidationError: type: object properties: detail: type: array items: $ref: '#/components/schemas/ValidationError' description: A list of validation errors. ``` -------------------------------- ### Python User Response Function for SWE-Bench Evaluation Source: https://docs.all-hands.dev/openhands/usage/developers/evaluation-harness Implements a user response function for SWE-Bench evaluations. It provides a default message to guide the agent's work, checks conversation history to determine if the agent should be allowed to give up after multiple attempts to communicate, and returns a tailored message. ```python def codeact_user_response(state: State | None) -> str: msg = ( 'Please continue working on the task on whatever approach you think is suitable.\n' 'If you think you have solved the task, please first send your answer to user through message and then exit .\n' 'IMPORTANT: YOU SHOULD NEVER ASK FOR HUMAN HELP.\n' ) if state and state.history: # check if the agent has tried to talk to the user 3 times, if so, let the agent know it can give up user_msgs = [ event for event in state.history if isinstance(event, MessageAction) and event.source == 'user' ] if len(user_msgs) >= 2: # let the agent know that it can give up when it has tried 3 times return ( msg + 'If you want to give up, run: exit .\n' ) return msg ``` -------------------------------- ### GET /api/options/security-analyzers Source: https://docs.all-hands.dev/api-reference/list-security-analyzers Retrieves a list of all supported security analyzers. ```APIDOC ## GET /api/options/security-analyzers ### Description Lists all the security analyzers that are currently supported by the system. ### Method GET ### Endpoint /api/options/security-analyzers ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **array** (array of strings) - A list of supported security analyzer identifiers. #### Response Example ```json [ "analyzer1", "analyzer2" ] ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.