https://github.com/fafrd/aquarium Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code + Explore + All features + Documentation + GitHub Skills + Blog * Solutions + For + Enterprise + Teams + Startups + Education + By Solution + CI/CD & Automation + DevOps + DevSecOps + Case Studies + Customer Stories + Resources * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles + Repositories + Topics + Trending + Collections * Pricing [ ] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} fafrd / aquarium Public * Notifications * Fork 3 * Star 163 AI-controlled Linux Containers License GPL-3.0 license 163 stars 3 forks Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Security * Insights fafrd/aquarium This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 1 branch 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/f] Use Git or checkout with SVN using the web URL. [gh repo clone fafrd/] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @fafrd fafrd add example ... d6b3c58 Mar 24, 2023 add example d6b3c58 Git stats * 43 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .vscode actor ai logger .gitignore Dockerfile LICENSE.txt README.md go.mod go.sum main.go View code [ ] Bot Aquarium Usage Build Start Logs How it works Agent loop more examples Todo README.md Bot Aquarium This project gives a large language model (LLM) control of a Linux machine. In the example below, we start with the prompt: You now have control of an Ubuntu Linux server. Your goal is to run a Minecraft server. Do not respond with any judgement, questions or explanations. You will give commands and I will respond with current terminal output. Respond with a linux command to give to the server. The AI first does a sudo apt-get update, then installs openjdk-8-jre-headless. Each time it runs a command we return the result of this command back to OpenAI and ask for a summary of what happened, then use this summary as part of the next prompt. asciicast Inspired by xkcd.com/350 and Optimality is the tiger, agents are its teeth Usage Build docker network create aquarium docker build -t aquarium . go build Start Pass your prompt in the form of a goal. For example, --goal "Your goal is to run a minecraft server." OPENAI_API_KEY=$OPENAI_API_KEY ./aquarium --goal "Your goal is to run a Minecraft server." arguments ./aquarium -h Usage of ./aquarium: -debug Enable logging of AI prompts to debug.log -goal string Goal to give the AI. This will be injected within the following statement: > You now have control of an Ubuntu Linux server. > [YOUR GOAL WILL BE INSERTED HERE] > Do not respond with any judgement, questions or explanations. You will give commands and I will respond with current terminal output. > > Respond with a linux command to give to the server. (default "Your goal is to execute a verbose port scan of amazon.com.") -limit int Maximum number of commands the AI should run. (default 30) -preserve-container Persist docker container after program exits. -split-limit int When parsing long responses, we split up the response into chunks and ask the AI to summarize each chunk. split-limit is the maximum number of times we will split the response. (default 3) Logs The left side of the screen contains general information about the state of the program. The right side contains the terminal, as seen by the AI. These are written to aquarium.log and terminal.log. Calls to OpenAI are not logged unless you add the --debug flag. API requests and responses will be appended to debug.log. How it works Agent loop 1. Send the OpenAI api the list of commands (and their outcomes) executed so far, asking it what command should run next 2. Execute command in docker VM 3. Read output of previous command- send this to OpenAI and ask text-davinci-003 for a summary of what happened 1. If the output was too long, OpenAI api will return a 400 2. Recursively break down the output into chunks, ask it for a summary of each chunk 3. Ask OpenAI for a summary-of-summaries to get a final answer about what this command did more examples Prompt: Your goal is to execute a verbose port scan of amazon.com. The bot replies with nmap -v amazon.com. nmap is not installed; we return the failure to the AI, which then installs it and continues. Prompt: Your goal is to install a ngircd server. (an IRC server software) Installs the software, helpfully allows port 6667 through the firewall, then tries to run sudo -i and gets stuck. Screenshot 2023-03-24 at 6 26 21 PM Todo * There's no success criteria- the program doesn't know when to stop. The flag -limit controls how many commands are run (default 30) * The AI cannot give input to running programs. For example, if you ask it to SSH into a server using a password, it will hang at the password prompt. For apt-get, i've hacked around this issue by injecting -y to prevent asking the user for input. * I don't have a perfect way to detect when the command completes; right now I'm taking the # of running processes beforehand, running the command, then I poll the num procs until it returns back to the original value. This is a brittle solution * The terminal output handling is imperfect. Some commands, like wget, use \r to write the progress bar... I rewrite that as a \n instead. I also don't have any support for terminal colors, which i'm suppressing with ansi2txt * I haven't tried this with GPT-3 or GPT-4 yet, only text-davinci-003. OpenAI doesn't yet support text completion with gpt-4 (only conversational chat) so it would require restructuring the prompt. About AI-controlled Linux Containers Resources Readme License GPL-3.0 license Stars 163 stars Watchers 5 watching Forks 3 forks Releases No releases published Packages 0 No packages published Contributors 2 * @fafrd fafrd Kian * @chris-abbott chris-abbott Languages * Go 98.6% * Dockerfile 1.4% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.