From 009172586713eab31b327243421a8d9932618c23 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 18 Oct 2026 01:16:15 +0000 Subject: [PATCH] fix(host): the upgrade agent starts and stops the code sandbox's gateway sandbox.py has asked the upgrade agent for the sandbox profile since #495, but the agent only knew mcp, browser and monitoring, so Settings fell back to the line to run by hand. The profile's three containers (openshell-init, openshell-key, openshell-gateway) join services_of, with a test, and the docs say which agent knows it. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01HXPWXcSCQb9hWPr7xkZu7B --- CHANGELOG.md | 4 ++++ docs/assistant.md | 8 ++++---- docs/updates.md | 3 ++- packaging/host/lens-upgrade.sh | 4 +++- packaging/host/test-services.sh | 18 ++++++++++++++---- 5 files changed, 27 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c5511ef1..58a3a2669 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ The backend (`fastapi_backend`) and the frontend (`nextjs-frontend`) are version ## Unreleased +- **The upgrade agent starts the code sandbox's gateway.** Settings → Code sandbox → Run the gateway on this machine + now works on installs with an upgrade agent: the agent knows the `sandbox` profile and starts or stops its three + containers, as it does the MCP runner, the browser and monitoring. An older agent still says to run the line by hand + until it has updated itself ([The gateway](docs/assistant.md#the-gateway)). - **Deep research.** Give the assistant a goal (`/research `, `research: true` on a question, `POST /api/v1/chats//research`, its `start_research` tool, or MCP) and it plans the research: up to three follow-up questions, the sub-questions, where it looks (the archive, the graph, notes, the web, the code sandbox), the tool diff --git a/docs/assistant.md b/docs/assistant.md index 1fcac9860..7bca43769 100644 --- a/docs/assistant.md +++ b/docs/assistant.md @@ -462,8 +462,8 @@ docker compose -f docker-compose.prod.yml --profile sandbox up -d openshell-gate - **Size.** About 300 MB of images on disk (the gateway, the supervisor and the sandbox runtime), downloaded the first time it starts, plus `sandbox.image`. Each sandbox is a container with its own CPU, memory and process limits. -In progress: the upgrade agent that starts the profile ships with the agent's next release; until this machine's agent -knows the `sandbox` profile, Settings says to start it by hand and shows the line above. +The upgrade agent knows the `sandbox` profile from this release on; a machine whose agent is older (it updates itself +with the next release it installs) says so in Settings and shows the line above to run by hand until then. Refine later: automations' agent runs without a conversation get no sandbox yet; running admins' Python extension tools in the sandbox so people who aren't admins can write them; asking the person before a run reaches a host that @@ -774,8 +774,8 @@ machine** under **Ready-made** in **Add MCP server**, then **Add Browser**, whic ### Optional containers -The MCP runner, the browser and monitoring ([Prometheus and Grafana](prometheus.md)) are containers Lens can run next -to it, off until an admin turns one on. The web app can't start containers itself, so the machine's upgrade agent does +The MCP runner, the browser, the [code sandbox](#the-gateway)'s gateway and monitoring +([Prometheus and Grafana](prometheus.md)) are containers Lens can run next to it, off until an admin turns one on. The web app can't start containers itself, so the machine's upgrade agent does ([Updates](updates.md)): it adds the profile to `COMPOSE_PROFILES` in Lens's `.env`, or takes it out, and starts or stops that profile's containers, one change at a time. Without an agent (Lens wasn't installed with `install.sh`), the switch shows the line to run on the machine instead. Agents use the same switches: `GET /api/v1/admin/services` and diff --git a/docs/updates.md b/docs/updates.md index 0710dc95a..dd65857d9 100644 --- a/docs/updates.md +++ b/docs/updates.md @@ -64,7 +64,8 @@ request, and the API refuses a release older than the one running (restore a bac The same agent turns Lens's [optional containers](assistant.md#optional-containers) on and off: a request with `action=services`, a `profile` and `turn=on` or `off` (in the same inbox file, the one every agent watches) adds or removes that profile in `COMPOSE_PROFILES` in `.env` and starts or stops its containers, and nothing else. The -profiles are fixed in the agent: `mcp` (the MCP runner), `browser` (the browser and its proxy) and `monitoring` +profiles are fixed in the agent: `mcp` (the MCP runner), `browser` (the browser and its proxy), `sandbox` (the +[code sandbox](assistant.md#the-gateway)'s gateway, its certificates and the client's key) and `monitoring` ([Charts and history](prometheus.md#prometheus-and-grafana-ready-made): Prometheus, node-exporter and Grafana); it refuses any other. It reports in `services-status` and `services.log`. A request from an older Lens, with `monitoring=on` or `off` and no profile, still works. diff --git a/packaging/host/lens-upgrade.sh b/packaging/host/lens-upgrade.sh index 8ec10f437..823ca7625 100755 --- a/packaging/host/lens-upgrade.sh +++ b/packaging/host/lens-upgrade.sh @@ -13,7 +13,8 @@ # ran before and starts that (rolled-back). Run by hand: sh packaging/host/lens-upgrade.sh # # A request with action=services turns one of Lens's optional containers on or off instead (profile= -# turn=on|off): the MCP runner (mcp), the browser (browser, docs/assistant.md) or monitoring (docs/prometheus.md). It +# turn=on|off): the MCP runner (mcp), the browser (browser, docs/assistant.md), the code sandbox's gateway (sandbox, +# docs/assistant.md) or monitoring (docs/prometheus.md). It # adds or removes the profile in COMPOSE_PROFILES in .env and starts or stops that profile's containers, those named in # services_of below and nothing else, and says how it went in .lens-control/services-status. A request from before # profiles, monitoring=on|off, is the monitoring profile. It comes in the same file as an upgrade, the one every agent @@ -27,6 +28,7 @@ services_of() { monitoring) echo "prometheus node-exporter grafana" ;; mcp) echo "mcp" ;; browser) echo "browser browser-proxy" ;; + sandbox) echo "openshell-init openshell-key openshell-gateway" ;; # the certificates, the client's key, the gateway esac } diff --git a/packaging/host/test-services.sh b/packaging/host/test-services.sh index 189b14d4b..81933e0ad 100644 --- a/packaging/host/test-services.sh +++ b/packaging/host/test-services.sh @@ -52,26 +52,36 @@ ask id=b2 action=services profile=browser turn=off case "$(last)" in *"--profile browser rm -s -f browser browser-proxy") ;; *) fail "ran: $(last)" ;; esac ok "the MCP runner and the browser are turned on and off apart" -# 3. Turning on what is on already leaves it in COMPOSE_PROFILES once +# 3. The code sandbox's gateway on, then off: its three containers (the certificates, the client's key, the gateway) +ask id=s1 action=services profile=sandbox turn=on +[ "$(said state)" = "done" ] && [ "$(said profile)" = sandbox ] || fail "status: $(cat "$inst/.lens-control/services-status")" +[ "$(profiles)" = matterbridge,mcp,sandbox ] || fail "COMPOSE_PROFILES is $(profiles)" +case "$(last)" in *"--profile sandbox up -d openshell-init openshell-key openshell-gateway") ;; *) fail "ran: $(last)" ;; esac +ask id=s2 action=services profile=sandbox turn=off +[ "$(said state)" = "done" ] && [ "$(profiles)" = matterbridge,mcp ] || fail "COMPOSE_PROFILES is $(profiles)" +case "$(last)" in *"--profile sandbox rm -s -f openshell-init openshell-key openshell-gateway") ;; *) fail "ran: $(last)" ;; esac +ok "the code sandbox's gateway starts and stops its three containers" + +# 4. Turning on what is on already leaves it in COMPOSE_PROFILES once ask id=m2 action=services profile=mcp turn=on [ "$(profiles)" = matterbridge,mcp ] || fail "COMPOSE_PROFILES is $(profiles)" ok "a profile turned on twice is in COMPOSE_PROFILES once" -# 4. A request from before profiles (monitoring=on) is the monitoring profile, with Grafana's port in the status +# 5. A request from before profiles (monitoring=on) is the monitoring profile, with Grafana's port in the status ask id=g1 action=services monitoring=on [ "$(said state)" = "done" ] && [ "$(said profile)" = monitoring ] && [ "$(said grafana_port)" = 3005 ] || fail "status: $(cat "$inst/.lens-control/services-status")" [ "$(profiles)" = matterbridge,mcp,monitoring ] || fail "COMPOSE_PROFILES is $(profiles)" case "$(last)" in *"--profile monitoring up -d prometheus node-exporter grafana") ;; *) fail "ran: $(last)" ;; esac ok "monitoring=on still turns monitoring on" -# 5. With HTTPS on, the HTTPS compose file comes too +# 6. With HTTPS on, the HTTPS compose file comes too echo LENS_HTTPS=1 >>"$inst/.env" ask id=m3 action=services profile=mcp turn=off case "$(last)" in *"-f docker-compose.prod.yml -f docker-compose.https.yml --profile mcp rm -s -f mcp") ;; *) fail "ran: $(last)" ;; esac [ "$(profiles)" = matterbridge,monitoring ] || fail "COMPOSE_PROFILES is $(profiles)" ok "the HTTPS compose file comes along when HTTPS is on" -# 6. Anything else is refused and runs nothing: a profile it doesn't know, a turn that isn't on or off, a microsandbox +# 7. Anything else is refused and runs nothing: a profile it doesn't know, a turn that isn't on or off, a microsandbox calls="$(wc -l <"$work/calls")" ask id=x1 action=services profile=matterbridge turn=on [ "$(said state)" = failed ] || fail "a profile it doesn't know: $(said state)"