Files
loki/scripts/hetzner/loki-box-runner@.service
CatoandClaude Sonnet 5.5 59cd3e7b10 feat(terminal): a plain shell on the builder, operator-only behind the PIN (#1449)
* feat(terminal): a plain shell on the builder, operator-only behind the PIN

Sessions -> Plain shell opens a real bash login shell in a PTY the builder
owns: no project, no agent, no inject wrapper. It is one more kind of session
on the existing transport (open_shell command, peek-stream, the rawkey lane,
tab-memory), not a second terminal.

Security: operator account only (browser session, never a bearer token); a PIN
must be set and the shell's own unlock (10 min idle, 60 max) entered; opens
rate-limited and capped at 3 per builder; no queued command except
open/close/peek may name a shell tab (queue, validator and injectPty); tenant
and sealed builders never offer one; shell environment carries no engine keys.
Every open/close/denied/unlock is on an append-only audit trail with no
content. Threat model: docs/architecture/plain-shell.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

* test(terminal): keep the repo's gates true for the plain shell

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

* docs(plain-shell): name where provision-service.py lives

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-27 20:14:13 +01:00

58 lines
2.6 KiB
Desktop File

[Unit]
# One private builder per account (docs/architecture/private-builders.md).
# %i is the tenant's short id — the first eight characters of their user id —
# and the unit runs as the system user lk-%i in /home/lk-%i, with its own
# runner token, its own clones, its own agent sign-ins. Nothing of the app,
# the other tenants or the box's secrets is reachable from inside it.
# Installed by scripts/hetzner/new-tenant.sh and refreshed by the deploy
# (scripts/deploy-hetzner.sh); instances are created by reconcile-tenants.sh
# from users.private_builder.
Description=Loki private builder for tenant %i
After=network-online.target loki-app.service
Wants=network-online.target
StartLimitIntervalSec=0
[Service]
Type=simple
User=lk-%i
Group=lk-%i
WorkingDirectory=/opt/loki/runner
# The tenant's whole world is its home. The runner code is read-only and
# shared; the rest of the filesystem is read-only or invisible.
ProtectSystem=strict
ProtectHome=tmpfs
BindPaths=/home/lk-%i
ReadOnlyPaths=/opt/loki/runner
InaccessiblePaths=-/opt/loki/app -/opt/loki/runner/.env -/etc/loki -/opt/orangecat -/opt/kivvi -/opt/botsmann -/opt/datacat-api -/opt/datacat-web -/opt/petvity -/opt/printcraft -/opt/reparaturbonus-zh -/opt/revamp-info -/opt/evig -/opt/sbb-fundbuero -/opt/solon -/opt/surf-your-life -/opt/vitareba -/opt/aoz-wohnen -/opt/supabase -/opt/backups -/opt/monitoring -/opt/_appcron
PrivateTmp=true
NoNewPrivileges=true
# One tenant cannot take the box down: the CX43 carries roughly six to ten
# concurrent agent sessions in all, and the first symptom of growth must be a
# queue on the System page, never a crash.
MemoryMax=3G
CPUQuota=200%
TasksMax=512
# The tenant's engine keys (Settings → Your engine) and nothing else. No
# database password: the runner asks the control plane for what it needs
# with its own token (src/lib/agent-execution/box-workspace.ts).
EnvironmentFile=-/etc/loki/runners/%i.env
Environment=HOME=/home/lk-%i
Environment=PATH=/home/lk-%i/.local/bin:/home/lk-%i/.npm-global/bin:/usr/local/bin:/usr/bin:/bin
Environment=NODE_ENV=production
Environment=LOKI_BOX_PREPARE=true
Environment=LOKI_AGENT_ENV=allowlist
# A tenant never gets a plain shell (src/lib/shell-session.ts runnerOffersShell).
Environment=LOKI_SHELL=off
Environment=LOKI_BOX_DEV_ROOT=/home/lk-%i/dev
Environment=LOKI_RUNNER_PRESENCE_CHANNEL=cloud
Environment=LOKI_WEB_URL=https://loki.orangecat.ch
ExecStart=/opt/loki/runner/node_modules/.bin/tsx scripts/box-runner.ts
Restart=always
RestartSec=5
# One OOM-killed child must not take every agent with it (see the legacy
# unit in install-box-runner.sh for the 2026-09-25 incident).
OOMPolicy=continue
[Install]
WantedBy=multi-user.target