This project enables an AI assistant to control your computer, including executing commands, moving the mouse, typing, and more. Running this code can be very dangerous. Neither I nor Anthropic take any liability for any damage to your computer, data loss, security breaches, or any other harm that may result from using this software. Use it at your own risk. Proceed only if you fully understand the implications and are willing to accept all responsibility.
This project is adapted from the Anthropic Quickstarts, specifically the computer-use-demo
, modified to run on macOS systems.
This demo showcases an AI assistant capable of controlling a computer through natural language commands. The assistant can perform tasks like moving the mouse, typing text, taking screenshots, and executing bash commands.
git clone https://github.com/newideas99/Anthropic-Computer-Use-MacOS.git
cd Anthropic-Computer-Use-MacOS
Make the setup.sh
script executable if it isn't already:
chmod +x setup.sh
Run the setup script:
./setup.sh
Note: The script will:
Some functionalities require accessibility permissions.
/path/to/computer-use-demo-mac/.venv/bin/python
Important: Ensure both your terminal application and the Python interpreter have accessibility permissions.
.env
in the project root directory and add your API key:echo "ANTHROPIC_API_KEY=your_api_key_here" > .env
Alternatively, you can export the API key as an environment variable in your shell:
export ANTHROPIC_API_KEY=your_api_key_here
You can customize the system prompt by editing the SYSTEM_PROMPT
in computer_use_demo/loop.py
:
SYSTEM_PROMPT = f"""<SYSTEM_CAPABILITY>
* You are utilizing a macOS system with internet access.
* You can install applications using Homebrew.
* Use `curl` instead of `wget`.
* The current date is {datetime.today().strftime('%A, %B %-d, %Y')}.
</SYSTEM_CAPABILITY>
"""
Activate your virtual environment if you haven't already:
source .venv/bin/activate
Run the Streamlit application:
streamlit run app.py
This will start the application and provide you with a local URL (e.g., http://localhost:8501) to access the interface in your browser.
.env
file, enter your Anthropic API key in the sidebar.ls -la
in the terminal."Permission Denied Errors
sudo
if required, but use caution.ModuleNotFoundError
ValueError in get_screen_size
get_screen_size
method in computer.py
has been updated to handle macOS output. Ensure you have the latest code.Accessibility Permissions Not Working
Streamlit Warnings About Watchdog
Watchdog
module for better performance.setup.sh
script installs Watchdog. If you still see warnings, ensure it's installed in your virtual environment:pip install watchdog
This project is licensed under the MIT License. See the LICENSE file for details.
Disclaimer: This project is for educational purposes. Be extremely cautious when granting applications accessibility permissions, and ensure you understand the implications of allowing an AI assistant to control your computer. Neither I nor Anthropic take any liability for any damage to your computer, data loss, security breaches, or any other harm that may result from using this software. Use it at your own risk.
Important Note: By using this software, you acknowledge that running code which allows an AI to control your computer can pose significant risks, including unintended execution of commands, data corruption, or exposure of sensitive information. Ensure that you run this software in a controlled environment, such as a virtual machine or a non-critical system, and understand all the potential consequences.
Stay Safe: Always monitor the assistant's actions carefully. Do not provide sensitive information or access to critical systems.