Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <goal>`, `research: true` on a question, `POST
/api/v1/chats/<id>/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
Expand Down
8 changes: 4 additions & 4 deletions docs/assistant.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion docs/updates.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion packaging/host/lens-upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
# ran before and starts that (rolled-back). Run by hand: sh packaging/host/lens-upgrade.sh <install folder>
#
# A request with action=services turns one of Lens's optional containers on or off instead (profile=<name>
# 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
Expand All @@ -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
}

Expand Down
18 changes: 14 additions & 4 deletions packaging/host/test-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
Loading