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.
Carry the per-Bot egress proxy as far as the process that reads it (#250)
beardtheliona46b5f91d246
diff --git a/.env.example b/.env.exampleindex bfd61b36..e749f1eb 100644--- a/.env.example+++ b/.env.example@@ -230,8 +230,13 @@ COMPUTER_TOKEN=## This is attribution, not anonymity, and it is not a boundary by itself: it gives a security team a# per-Bot address for network rules alongside AGENT_COMPUTER_POLICY.-# EGRESS_PROXY_DEFAULT=http://user:[email protected]:8080-# EGRESS_PROXY_SALES_BOT=http://sales.proxy.internal:8080+#+# These go in `egress.env` beside this file, NOT here. The names are per-Bot, so Compose cannot+# list them the way it lists every variable below, and it hands a container only what it is told to.+# In `.env` they reach no process and the browser goes out directly with nothing saying so.+#+# EGRESS_PROXY_DEFAULT=http://user:[email protected]:8080+# EGRESS_PROXY_SALES_BOT=http://sales.proxy.internal:8080# The managed coworker AG-UI endpoint. Optional: use an HTTP(S) URL, and set MANAGED_AGENT_TOKENdiff --git a/.gitignore b/.gitignoreindex f1e6ae03..bfc1237c 100644--- a/.gitignore+++ b/.gitignore@@ -11,6 +11,8 @@ docs/plans/.env.env.*!.env.example+# Per-Bot egress proxies. Carries credentials in the URL, like .env does.+egress.envnode_modules/**/dist/app/src/lib/generated/application-config.tsdiff --git a/CHANGELOG.md b/CHANGELOG.mdindex 805817b0..350328b9 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -231,6 +231,27 @@ credential is refused rather than quietly attached to fail on its next call.Curated servers keep working as they did. Their URL comes from the catalogue rather than therequest, and a per-instance hostname is matched against the vendor's own anchored pattern beforeanything is stored, so re-adding one cannot point it at an address of the caller's choosing.+### A configured egress proxy reaches the browser that uses it++`EGRESS_PROXY_DEFAULT` and `EGRESS_PROXY_<BOT>` were documented as the way to give a Bot a stable+outbound address, and Compose passed neither to anything. `docker-compose.yml` named no egress+variable and had no `env_file`, so the shared computer resolved every Bot to no proxy and went out+directly, and under the supervisor the same emptiness meant there was nothing to forward into the+computers it creates.++The failure was silent, which for a setting whose purpose is to give a security team a per-Bot+address for network rules is the worst of the available failures. The stack started, the browser+left by the host, and the Computers screen reported "Leaves directly" because it was reading the+same empty environment.++They now live in `egress.env`, which both the computer and the supervisor are given. A file rather+than more `environment:` entries because `EGRESS_PROXY_<BOT>` is derived from a Bot's id and there+is no fixed set of names to list; a file of its own rather than `.env` because that one holds the+deployment's secrets and the container running a browser and a Bot's shell is deliberately not+given them. It is optional, so a deployment with no proxy is unchanged, and gitignored, because a+proxy URL can carry a password.++**Move these two out of `.env` and into `egress.env`.** In `.env` they reach no process.### Knowledge searches instead of guessingdiff --git a/docker-compose.yml b/docker-compose.ymlindex e2e7cfbc..b420e933 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -61,6 +61,15 @@ services:# Loopback only. This process drives a browser holding real logins; COMPUTER_TOKEN is the# request control, and loopback keeps the surface off routed networks.- "127.0.0.1:${COMPUTER_PORT:-4100}:4100"+ # Per-Bot egress, in a file of its own because the names are not knowable here.+ #+ # `EGRESS_PROXY_<BOT>` is derived from the Bot's id, so there is no fixed list to write out the+ # way COMPUTER_TOKEN is. Not `.env`: that holds the deployment's secrets, and this container+ # drives a browser and runs a Bot's shell, so it is given what it needs and not the rest.+ # Optional, because going out directly is the ordinary case and must still start.+ env_file:+ - path: ./egress.env+ required: falseenvironment:# The secret every caller must present. The container refuses to start without it.COMPUTER_TOKEN: ${COMPUTER_TOKEN:-}@@ -143,6 +152,11 @@ services:build:context: .dockerfile: supervisor/Dockerfile+ # The same file, because this process does not read these itself: it forwards every EGRESS_PROXY+ # key out of its own environment into each computer it creates, so it has to be given them first.+ env_file:+ - path: ./egress.env+ required: falseenvironment:PORT: "4300"# Shared with the API server. The Bot-level verb set is the boundary; this token keeps otherdiff --git a/docs/configuration.md b/docs/configuration.mdindex be7ff85b..a8291d3c 100644--- a/docs/configuration.md+++ b/docs/configuration.md@@ -191,8 +191,8 @@ where `<provider>` is `google`, `microsoft` or `okta`.- `WORKSPACE_DIR`- `PROFILES_DIR`- `COMPUTER_BOT_ID`-- `EGRESS_PROXY_DEFAULT`-- `EGRESS_PROXY_<BOT_ID>`+- `EGRESS_PROXY_DEFAULT` (in `egress.env`, see below)+- `EGRESS_PROXY_<BOT_ID>` (in `egress.env`, see below)- `COMPUTER_SHELL_ENV`A command on the computer inherits PATH, locale and terminal names, and the proxy variables, not@@ -200,6 +200,24 @@ the rest of the process environment. Userinfo is stripped from a proxy URL, so a`HTTP_PROXY` is not in `env`. `COMPUTER_SHELL_ENV` is a comma-separated list of extra names topass. Naming a secret or a credentialed proxy there is an operator's decision; the default does not.+### Per-Bot egress++The two egress variables live in `egress.env` at the repository root, not in `.env`. `EGRESS_PROXY_<BOT_ID>`+is derived from a Bot's id, so there is no fixed set of names for Compose to list the way it lists+every other variable, and Compose passes a container only the names it is given. A file of its own+rather than `.env` because that one holds the deployment's secrets and neither the browser container+nor the supervisor is given those.++```sh+# egress.env+EGRESS_PROXY_DEFAULT=http://user:[email protected]:8080+EGRESS_PROXY_SALES_BOT=http://sales.proxy.internal:8080+```++The file is optional and gitignored. Without it every Bot's browser goes out directly, which is the+default. Both the shared computer and the supervisor are given it: the computer resolves its own+proxy from these names, and the supervisor forwards them into each computer it creates.+The supervisor also reads:- `COMPUTER_IMAGE`diff --git a/tests/compose.test.ts b/tests/compose.test.tsindex ac18455f..b7261b3e 100644--- a/tests/compose.test.ts+++ b/tests/compose.test.ts@@ -121,3 +121,35 @@ test("runs migrations after PostgreSQL becomes healthy", () => {expect(compose).toContain("condition: service_healthy");expect(compose).toContain('"drizzle-kit", "migrate"');});++/**+ * Per-Bot egress reaches the processes that read it.+ *+ * `EGRESS_PROXY_<BOT>` and `EGRESS_PROXY_DEFAULT` are resolved from `process.env` by the computer+ * itself (`agent-computer/src/egress.ts`), and the supervisor forwards every `EGRESS_PROXY` key out+ * of its own environment into each computer it creates (`supervisor/src/index.ts`). Compose gives a+ * container only what its `environment:` and `env_file:` blocks name, and for a long time neither+ * named these, so an operator who configured a proxy per the documentation got a browser that went+ * out directly and no error saying so.+ *+ * A file rather than `environment:` entries because the names are per-Bot and therefore not knowable+ * here, and a file of its own rather than `.env` because that one holds the deployment's secrets and+ * the browser container is deliberately not given them.+ */+test("carries per-Bot egress into the computer and the supervisor", () => {+ const compose = readFileSync(+ join(import.meta.dir, "..", "docker-compose.yml"),+ "utf8",+ );++ // Both halves: the shared computer reads them itself, and the supervisor passes them on.+ const services = compose.split(/^ {2}(?=\S)/m);+ for (const name of ["agent-computer:", "supervisor:"]) {+ const service = services.find((block) => block.startsWith(name));+ expect(service).toBeDefined();+ expect(service).toContain("egress.env");+ }++ // Optional, because a deployment with no proxy is the ordinary case and must still start.+ expect(compose).toContain("required: false");+});