This is a WebSocket server that executes tasks using an agent.
- Initialize the frontend code
- Install Python 3.12 (
brew install python
for those using homebrew) - Install pipx: (
brew install pipx
followed bypipx ensurepath
) - Install poetry: (
pipx install poetry
)
First build a distribution of the frontend code (From the project root directory):
cd frontend
npm install
npm run build
cd ..
Next run poetry shell
(So you don't have to repeat poetry run
)
uvicorn openhands.server.listen:app --reload --port 3000
You can use websocat
to test the server.
websocat ws://127.0.0.1:3000/ws
{"action": "start", "args": {"task": "write a bash script that prints hello"}}
LLM_API_KEY=sk-... # Your OpenAI API Key
LLM_MODEL=gpt-4o # Default model for the agent to use
WORKSPACE_BASE=/path/to/your/workspace # Default absolute path to workspace
There are two types of messages that can be sent to, or received from, the server:
- Actions
- Observations
An action has three parts:
action
: The action to be takenargs
: The arguments for the actionmessage
: A friendly message that can be put in the chat log
There are several kinds of actions. Their arguments are listed below. This list may grow over time.
initialize
- initializes the agent. Only sent by client.model
- the name of the model to usedirectory
- the path to the workspaceagent_cls
- the class of the agent to use
start
- starts a new development task. Only sent by the client.task
- the task to start
read
- reads the content of a file.path
- the path of the file to read
write
- writes the content to a file.path
- the path of the file to writecontent
- the content to write to the file
run
- runs a command.command
- the command to run
browse
- opens a web page.url
- the URL to open
think
- Allows the agent to make a plan, set a goal, or record thoughtsthought
- the thought to record
finish
- agent signals that the task is completed
An observation has four parts:
observation
: The observation typecontent
: A string representing the observed dataextras
: additional structured datamessage
: A friendly message that can be put in the chat log
There are several kinds of observations. Their extras are listed below. This list may grow over time.
read
- the content of a filepath
- the path of the file read
browse
- the HTML content of a urlurl
- the URL opened
run
- the output of a commandcommand
- the command runexit_code
- the exit code of the command
chat
- a message from the user