Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.
#!/command/with-contenv sh
# The Bot's browser. Bound to loopback: its only caller is the API beside it.
#
# `EMBEDDED_COMPUTER=on` is the default, because one container that just works is what this image is
# for. Off, this service exits 0 immediately and s6 leaves it alone, the same way `postgres` does,
# and the API reaches a computer elsewhere through `AGENT_COMPUTER_URL` or a supervisor.
#
# That switch is what lets this image be a stateless replica. A browser is a few hundred megabytes of
# memory holding one Bot's logins, so an API pod carrying one is neither stateless nor cheap to run
# several of: scaling the API would scale the browsers with it, and every replica would hold a
# profile directory that matters to exactly one Bot.
#
# `with-contenv` is not decoration. Without it s6 starts a service with none of the container's
# environment, and the failure is a config error naming a variable that is plainly set.
#
# COMPUTER_MEMORY_HIGH_PERCENT stays on here, and here it counts everything in this container: the
# database and the API server as well as the browsers, because the cgroup the computer reads is the
# container's. That is deliberate. The kernel's out-of-memory kill counts all of it too and can take
# the database down, so closing a browser nobody is using, before memory gets there, is how the
# database is protected. Set it to 0 to leave memory to the kernel.
set -eu
if [ "${EMBEDDED_COMPUTER:-on}" != "on" ]; then
exec /bin/true
fi
cd /app/agent-computer
set --
for name in \
PATH LANG LANGUAGE TERM TERMINFO COLORTERM DISPLAY \
HTTP_PROXY HTTPS_PROXY NO_PROXY ALL_PROXY FTP_PROXY \
http_proxy https_proxy no_proxy all_proxy ftp_proxy \
BUN_INSTALL PLAYWRIGHT_BROWSERS_PATH SPIFFE_ENDPOINT_SOCKET \
COMPUTER_TOKEN COMPUTER_BOT_ID COMPUTER_BROWSER_MODE COMPUTER_MAX_BROWSERS \
COMPUTER_BROWSER_IDLE_MS COMPUTER_SANDBOX COMPUTER_SHELL_ENV COMPUTER_STOPPED \
COMPUTER_SEPARATE_WORKSPACES COMPUTER_MEMORY_HIGH_PERCENT COMPUTER_TAB_IDLE_MS \
ACTION_TIMEOUT_MS NAVIGATION_TIMEOUT_MS AGENT_COMPUTER_ALLOW_PRIVATE_HOSTS
do
eval "isset=\${$name+x}"
[ -n "${isset:-}" ] && eval "set -- \"\$@\" \"$name=\${$name}\""
done
for name in $(printenv | sed -n 's/=.*//p' | grep -E '^(LC_[A-Za-z0-9_]+|EGRESS_PROXY_[A-Za-z0-9_]+)$' || true); do
eval "set -- \"\$@\" \"$name=\${$name}\""
done
if [ -n "${COMPUTER_SHELL_ENV:-}" ]; then
oldifs=$IFS
IFS=,
for name in $COMPUTER_SHELL_ENV; do
IFS=$oldifs
name=$(printf %s "$name" | tr -d '[:space:]')
case "$name" in
'' | *[!A-Za-z0-9_]*) IFS=, ; continue ;;
esac
eval "isset=\${$name+x}"
[ -n "${isset:-}" ] && eval "set -- \"\$@\" \"$name=\${$name}\""
IFS=,
done
IFS=$oldifs
fi
exec s6-setuidgid pwuser env -i "$@" \
HOME=/home/pwuser PORT=4100 WORKSPACE_DIR=/workspace PROFILES_DIR="${PROFILES_DIR:-/profiles}" \
/usr/local/bin/bun src/index.ts