+ {t('app.serverHealthCard.mismatch', 'The install command requested a different level than the agent reports. The agent\'s level is the one in effect.')}
+
+ )}
+
+ {t('app.serverHealthCard.howToChange', 'This level is enforced by the agent and cannot be changed from the panel. To change it, run this on the server as root:')}
+
+
+ {t('app.servers.levelEnforcedByAgent', 'The level is enforced by the agent and can only be changed on the server itself, with')}
+ {' '}{SET_HINT}
+
+
+ );
+};
+
const AddServerModal = ({ groups, onClose, onCreated }) => {
const { t } = useTranslation();
const [mode, setMode] = useState('install');
const [step, setStep] = useState(1);
const [groupId, setGroupId] = useState('');
const [expiresIn, setExpiresIn] = useState(DEFAULT_EXPIRY);
+ const [level, setLevel] = useState(DEFAULT_LEVEL);
const [registrationData, setRegistrationData] = useState(null);
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
@@ -789,6 +884,7 @@ const AddServerModal = ({ groups, onClose, onCreated }) => {
const result = await api.createServer({
expires_in: expiresIn,
group_id: groupId || undefined,
+ requested_level: level,
});
setRegistrationData(result);
setStep(2);
@@ -808,13 +904,15 @@ const AddServerModal = ({ groups, onClose, onCreated }) => {
// the operator sees one line of curl noise, the shell says success, and
// nothing was installed. The `&&` makes a failed fetch stop the command and
// surface curl's non-zero exit (issue #101).
- const linuxInstallScript = registrationData ? `curl -fsSL ${window.location.origin}/api/v1/servers/install.sh -o /tmp/serverkit-agent-install.sh && \\
- sudo bash /tmp/serverkit-agent-install.sh \\
- --server "${window.location.origin}" \\
- --token "${registrationData.registration_token}"` : '';
-
- const windowsInstallScript = registrationData ? `irm ${window.location.origin}/api/v1/servers/install.ps1 | iex
-Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registrationData.registration_token}"` : '';
+ const installCommands = registrationData
+ ? buildInstallCommands({
+ origin: window.location.origin,
+ token: registrationData.registration_token,
+ level,
+ })
+ : { linux: '', windows: '' };
+ const linuxInstallScript = installCommands.linux;
+ const windowsInstallScript = installCommands.windows;
// A right-side drawer, not a centred dialog: this flow is a multi-step
// wizard with install scripts in it, and it always was a drawer — the
@@ -887,6 +985,8 @@ Install-ServerKitAgent -Server "${window.location.origin}" -Token "${registratio
{t('app.servers.generateASingleConnectionStringPaste', "Generate a single connection string. Paste it into the agent's pairing wizard, or use it with the one-liner installer. The agent's hostname becomes the server name on first connect; you can rename it later from the server's Settings tab.")}
+
+
diff --git a/frontend/src/styles/pages/_servers.scss b/frontend/src/styles/pages/_servers.scss
index e880c251..f45ce5d1 100644
--- a/frontend/src/styles/pages/_servers.scss
+++ b/frontend/src/styles/pages/_servers.scss
@@ -2580,3 +2580,46 @@
flex-direction: column;
gap: $space-3;
}
+
+// Permission-level picker in the Add Server drawer
+.level-picker {
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ gap: $space-2;
+
+ &__opt {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: $space-1;
+ padding: $space-3;
+ text-align: start;
+ background: $bg-card;
+ border: 1px solid $border-subtle;
+ border-radius: $radius-control;
+ cursor: pointer;
+ transition: border-color $transition-fast, background $transition-fast;
+
+ &:hover {
+ border-color: $border-active;
+ }
+
+ &.is-active {
+ border-color: var(--accent-dim);
+ background: var(--accent-bg);
+ }
+ }
+
+ &__head {
+ font-size: $text-xs;
+ font-weight: $font-weight-semibold;
+ color: $text-primary;
+ }
+
+ &__desc {
+ font-size: $text-xs;
+ color: $text-tertiary;
+ line-height: 1.45;
+ white-space: normal;
+ }
+}
diff --git a/frontend/src/utils/__tests__/agentPermissionLevel.test.mjs b/frontend/src/utils/__tests__/agentPermissionLevel.test.mjs
new file mode 100644
index 00000000..68e5d4f9
--- /dev/null
+++ b/frontend/src/utils/__tests__/agentPermissionLevel.test.mjs
@@ -0,0 +1,28 @@
+import assert from 'node:assert/strict';
+import test from 'node:test';
+import { buildInstallCommands, normalizeLevel, serverHealth } from '../agentPermissionLevel.js';
+
+const NOW = Date.parse('2026-01-01T12:00:00Z');
+const ago = (s) => new Date(NOW - s * 1000).toISOString();
+
+test('install commands carry the level', () => {
+ const cmds = buildInstallCommands({ origin: 'https://p.example', token: 'T', level: 'protect' });
+ assert.match(cmds.linux, /--level protect$/);
+ assert.match(cmds.windows, /-Level protect$/);
+});
+
+test('unknown level falls back to monitor', () => {
+ assert.equal(normalizeLevel('root'), null);
+ const cmds = buildInstallCommands({ origin: 'o', token: 'T', level: 'root' });
+ assert.match(cmds.linux, /--level monitor$/);
+});
+
+test('health combines status, report age and checks', () => {
+ const base = { status: 'online', last_report_at: ago(30), report_interval_seconds: 60 };
+ assert.equal(serverHealth(base, NOW).code, 'healthy');
+ assert.equal(serverHealth({ ...base, service_checks: [{ name: 'mysql', status: 'down' }] }, NOW).code, 'failing');
+ assert.equal(serverHealth({ ...base, service_checks: [{ name: 'php', status: 'degraded' }] }, NOW).kind, 'amber');
+ assert.equal(serverHealth({ ...base, last_report_at: ago(600) }, NOW).code, 'stale');
+ assert.equal(serverHealth({ ...base, status: 'offline' }, NOW).kind, 'red');
+ assert.equal(serverHealth({ status: 'pending' }, NOW).code, 'pending');
+});
diff --git a/frontend/src/utils/agentPermissionLevel.js b/frontend/src/utils/agentPermissionLevel.js
new file mode 100644
index 00000000..056fbf6c
--- /dev/null
+++ b/frontend/src/utils/agentPermissionLevel.js
@@ -0,0 +1,53 @@
+// Agent permission levels: install-command builder and server health summary.
+// The level is enforced by the agent and only reported to the panel; nothing
+// here (or anywhere in the UI) changes it.
+
+export const PERMISSION_LEVELS = ['monitor', 'protect', 'full'];
+export const DEFAULT_LEVEL = 'monitor';
+
+const MIN_SILENCE_MS = 3 * 60 * 1000;
+
+export function normalizeLevel(level) {
+ return PERMISSION_LEVELS.includes(level) ? level : null;
+}
+
+export function levelKind(level) {
+ if (level === 'monitor') return 'cyan';
+ if (level === 'protect') return 'violet';
+ return 'amber';
+}
+
+export function buildInstallCommands({ origin, token, level }) {
+ const lvl = normalizeLevel(level) || DEFAULT_LEVEL;
+ return {
+ linux: `curl -fsSL ${origin}/api/v1/servers/install.sh -o /tmp/serverkit-agent-install.sh && \\
+ sudo bash /tmp/serverkit-agent-install.sh \\
+ --server "${origin}" \\
+ --token "${token}" \\
+ --level ${lvl}`,
+ windows: `irm ${origin}/api/v1/servers/install.ps1 | iex
+Install-ServerKitAgent -Server "${origin}" -Token "${token}" -Level ${lvl}`,
+ };
+}
+
+// Health = online/offline + report age + failing service checks.
+// -> { kind: Pill kind, code, failing: [check names], degraded: [check names] }
+export function serverHealth(server, now = Date.now()) {
+ const status = server.status || 'pending';
+ if (status === 'pending' || status === 'connecting') {
+ return { kind: 'gray', code: 'pending', failing: [], degraded: [] };
+ }
+ const checks = server.service_checks || [];
+ const failing = checks.filter((c) => c.status === 'down').map((c) => c.name);
+ const degraded = checks.filter((c) => c.status === 'degraded').map((c) => c.name);
+ if (status !== 'online') return { kind: 'red', code: 'offline', failing, degraded };
+
+ const seen = server.last_report_at || server.last_seen;
+ const limit = Math.max(MIN_SILENCE_MS, 3 * 1000 * (server.report_interval_seconds || 0));
+ if (seen && now - new Date(seen).getTime() > limit) {
+ return { kind: 'amber', code: 'stale', failing, degraded };
+ }
+ if (failing.length) return { kind: 'red', code: 'failing', failing, degraded };
+ if (degraded.length) return { kind: 'amber', code: 'degraded', failing, degraded };
+ return { kind: 'green', code: 'healthy', failing, degraded };
+}
From 0aab404e35d4bc2f86ed45887fff79c379195f98 Mon Sep 17 00:00:00 2001
From: Juan Denis
Date: Tue, 3 Nov 2026 00:31:21 -0500
Subject: [PATCH 3/5] refactor(agents): raise typed errors from the report
endpoint
Keeps the hand-shaped error-body ratchet at its ceiling.
Co-Authored-By: Claude Sonnet 5.5
---
backend/app/api/agent_report.py | 15 +++++++++------
backend/app/exceptions.py | 6 ++++++
docs/MIGRATION_INVENTORY.md | 4 ++--
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/backend/app/api/agent_report.py b/backend/app/api/agent_report.py
index 870c74cd..958c2321 100644
--- a/backend/app/api/agent_report.py
+++ b/backend/app/api/agent_report.py
@@ -13,6 +13,9 @@ Auth (no JWT/CSRF; the HMAC is the credential):
from flask import Blueprint, jsonify, request
from app import limiter
+from app.exceptions import (
+ AuthenticationError, PayloadTooLargeError, PermissionDeniedError, ValidationError,
+)
from app.services import agent_health_service, permission_levels
from app.utils.ip_utils import is_ip_allowed
@@ -31,23 +34,23 @@ def _rate_key():
@limiter.limit("30 per minute", key_func=_rate_key)
def report():
if (request.content_length or 0) > MAX_BODY_BYTES:
- return jsonify({'error': 'payload too large'}), 413
+ raise PayloadTooLargeError()
raw = request.get_data(cache=True)
if len(raw) > MAX_BODY_BYTES:
- return jsonify({'error': 'payload too large'}), 413
+ raise PayloadTooLargeError()
server = agent_health_service.authenticate_report(raw, request.headers, MAX_SKEW_SECONDS)
if not server:
- return jsonify({'error': 'authentication failed'}), 401
+ raise AuthenticationError('authentication failed')
if server.allowed_ips and not is_ip_allowed(request.remote_addr, server.allowed_ips):
- return jsonify({'error': 'IP not allowed'}), 403
+ raise PermissionDeniedError('IP not allowed')
body = request.get_json(silent=True)
if not isinstance(body, dict):
- return jsonify({'error': 'JSON object required'}), 400
+ raise ValidationError('JSON object required')
level = body.get('permission_level')
if level not in permission_levels.LEVELS:
- return jsonify({'error': 'permission_level must be monitor, protect or full'}), 400
+ raise ValidationError('permission_level must be monitor, protect or full')
interval = agent_health_service.ingest_report(server, level, body)
return jsonify({'ok': True, 'interval_seconds': interval})
diff --git a/backend/app/exceptions.py b/backend/app/exceptions.py
index 52f896b4..d0dcb47f 100644
--- a/backend/app/exceptions.py
+++ b/backend/app/exceptions.py
@@ -57,6 +57,12 @@ class PermissionDeniedError(ApplicationError, PermissionError):
default_message = 'Access denied'
+class PayloadTooLargeError(ApplicationError):
+ status_code = 413
+ code = 'payload_too_large'
+ default_message = 'Payload too large'
+
+
class NotFoundError(ApplicationError, LookupError):
status_code = 404
code = 'not_found'
diff --git a/docs/MIGRATION_INVENTORY.md b/docs/MIGRATION_INVENTORY.md
index f8323690..a906a013 100644
--- a/docs/MIGRATION_INVENTORY.md
+++ b/docs/MIGRATION_INVENTORY.md
@@ -16,12 +16,12 @@ debt. Regenerate with `python scripts/generate-migration-inventory.py`.
| Routes on bare @jwt_required() | auth_required() / role decorators | 598 | 598 | REGISTERED EXCEPTION: JWT-only is the deliberate default; conversion grants API-key access and happens per route, on decision |
| HTTP statuses chosen by sniffing error text | typed errors from app.exceptions | 0 | 0 | INVARIANT at 0 - migration completed 2026-08-19 |
| API crashes swallowed without recording | app.error_reporting | 0 | 0 | INVARIANT at 0 |
-| Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 855 | 850 | migrate when touched; new endpoints raise |
+| Hand-shaped {'error': ...} bodies in app/api | typed errors + the global handler | 849 | 850 | migrate when touched; new endpoints raise |
| Raw subprocess calls outside the runners | app/utils/system.py runners | 23 | 23 | migrate when touched |
| Controller-boundary violations (routes doing service work) | service layer extraction | 453 | 453 | migrate when touched (first-wave ratchet) |
| raw api.* calls in pages/ | E1: useServerQuery/useServerMutation | 374 | 398 | migrate when touched |
| per-page toast.error extractions in pages/ | E1: query-layer error presentation | 191 | 206 | migrate when touched |
-| hand-rolled form-group blocks | F2: FormField/useForm | 314 | 321 | migrate when touched |
+| hand-rolled form-group blocks | F2: FormField/useForm | 315 | 321 | migrate when touched |
| unencoded ?k=${v} query interpolations in services/api | C4: buildQuery/encoding template | 0 | 0 | INVARIANT at 0 |
| raw setInterval pollers | E2: usePolling/refetchInterval | 7 | 7 | DELIBERATE RESIDUE: clock ticks, socket-fallback hooks, and sibling-repo extension timers - each listed per file |
| direct navigator.clipboard call sites | F3: copyToClipboard | 0 | 0 | INVARIANT at 0 |
From 89cb31535329ea3d85fd835d217043b501c4477f Mon Sep 17 00:00:00 2001
From: Juan Denis
Date: Tue, 3 Nov 2026 00:32:48 -0500
Subject: [PATCH 4/5] chore(agents): re-vendor agent installers with --level
support
Synced from the agent repo's feat/agent-permission-levels branch; the drift
check will pass once that branch is released.
---
scripts/install.ps1 | 103 ++++++++++++++++++++++++++++++++++++++--
scripts/install.sh | 112 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 210 insertions(+), 5 deletions(-)
mode change 100644 => 100755 scripts/install.sh
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 4f3e219b..645fc563 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -30,6 +30,17 @@
.PARAMETER Version
Specific agent version to install (optional, defaults to latest)
+.PARAMETER Level
+ Permission level: monitor (report-only, no inbound commands), protect
+ (security actions only) or full (everything). If omitted: a menu on an
+ interactive console, otherwise full with a warning.
+
+.PARAMETER Reconfigure
+ Required to change the level of an already-installed agent.
+
+.PARAMETER Yes
+ Skip the typed confirmation when reconfiguring.
+
.EXAMPLE
.\install.ps1 -Token "sk_reg_xxx" -Server "https://your-serverkit.com"
@@ -53,7 +64,15 @@ param(
[string]$Name,
[Parameter(Mandatory=$false)]
- [string]$Version = "latest"
+ [string]$Version = "latest",
+
+ [Parameter(Mandatory=$false)]
+ [ValidateSet("monitor", "protect", "full")]
+ [string]$Level,
+
+ [switch]$Reconfigure,
+
+ [switch]$Yes
)
# Configuration
@@ -172,11 +191,61 @@ function New-ConfigDirectory {
}
}
+# Level recorded in an existing config ("" when none; no key = legacy = full).
+function Get-InstalledLevel {
+ $cfg = Join-Path $ConfigDir "config.yaml"
+ if (-not (Test-Path $cfg)) { return "" }
+ $m = Select-String -Path $cfg -Pattern '^\s+level:\s*"?(\w+)"?' | Select-Object -First 1
+ if ($m) { return $m.Matches[0].Groups[1].Value }
+ return "full"
+}
+
+# Refuses to silently change an installed agent's level; returns the level to use.
+function Resolve-Level {
+ param([string]$Level, [bool]$Reconfigure, [bool]$Yes)
+
+ $current = Get-InstalledLevel
+ if ($current) {
+ if (-not $Level) { return $current }
+ if ($Level -eq $current) { return $Level }
+ if (-not $Reconfigure) {
+ Write-ColorOutput "This agent is already installed at level '$current'. Re-run with -Reconfigure to change it to '$Level'." "Error"
+ exit 1
+ }
+ if (-not $Yes) {
+ $answer = Read-Host "Changing level $current -> $Level. Type '$Level' to confirm"
+ if ($answer -ne $Level) {
+ Write-ColorOutput "Confirmation did not match; permission level unchanged (use -Yes for scripted use)" "Error"
+ exit 1
+ }
+ }
+ $script:ChangeLevelFrom = $current
+ return $Level
+ }
+ if ($Level) { return $Level }
+ if ([Environment]::UserInteractive -and -not [Console]::IsInputRedirected) {
+ Write-Host ""
+ Write-Host " Choose what this agent may do on this server:"
+ Write-Host " 1) monitor report-only, accepts no commands from the panel"
+ Write-Host " 2) protect security actions only (firewall, fail2ban, CrowdSec, origin lock)"
+ Write-Host " 3) full everything"
+ switch (Read-Host " Selection [1-3]") {
+ "1" { return "monitor" }
+ "2" { return "protect" }
+ "3" { return "full" }
+ default { Write-ColorOutput "Invalid selection" "Error"; exit 1 }
+ }
+ }
+ Write-ColorOutput "No -Level given and no console: defaulting to FULL control. Pass -Level monitor|protect|full to choose." "Warning"
+ return "full"
+}
+
function Register-Agent {
param(
[string]$Token,
[string]$Server,
- [string]$Name
+ [string]$Name,
+ [string]$Level
)
Write-ColorOutput "Registering agent with ServerKit..." "Info"
@@ -188,6 +257,11 @@ function Register-Agent {
if ($Name) {
$arguments += @("--name", $Name)
}
+ $arguments += @("--level", $Level)
+
+ if ($script:ChangeLevelFrom) {
+ Start-Process -FilePath $agentPath -ArgumentList @("--config", $configPath, "permissions", "set", $Level, "--yes") -Wait -NoNewWindow | Out-Null
+ }
try {
$process = Start-Process -FilePath $agentPath -ArgumentList $arguments -Wait -PassThru -NoNewWindow
@@ -307,7 +381,15 @@ function Install-ServerKitAgent {
[string]$Name,
[Parameter(Mandatory=$false)]
- [string]$Version = "latest"
+ [string]$Version = "latest",
+
+ [Parameter(Mandatory=$false)]
+ [ValidateSet("monitor", "protect", "full")]
+ [string]$Level,
+
+ [switch]$Reconfigure,
+
+ [switch]$Yes
)
# Update script-level variables
@@ -321,19 +403,30 @@ function Install-ServerKitAgent {
exit 1
}
+ $Level = Resolve-Level -Level $Level -Reconfigure $Reconfigure.IsPresent -Yes $Yes.IsPresent
+
Get-LatestVersion
Install-Agent
New-ConfigDirectory
- Register-Agent -Token $Token -Server $Server -Name $Name
+ Register-Agent -Token $Token -Server $Server -Name $Name -Level $Level
Install-WindowsService
Start-AgentService
Add-ToPath
Write-SuccessMessage
+ Write-Host "Permission level: $($Level.ToUpper())" -ForegroundColor Yellow
+ switch ($Level) {
+ "monitor" { Write-Host " Report-only: this agent sends metrics out and accepts NO commands." }
+ "protect" { Write-Host " Security actions only (firewall, fail2ban, CrowdSec, origin lock)." }
+ default { Write-Host " Full control: the panel can run any supported action." }
+ }
+ Write-Host " Change it (elevated prompt, this machine only):"
+ Write-Host " & '$InstallDir\$AgentBinary' permissions set "
+ Write-Host ""
}
# Direct execution with parameters
if ($Token -and $Server) {
- Install-ServerKitAgent -Token $Token -Server $Server -Name $Name -Version $Version
+ Install-ServerKitAgent -Token $Token -Server $Server -Name $Name -Version $Version -Level $Level -Reconfigure:$Reconfigure -Yes:$Yes
}
elseif ($PSBoundParameters.Count -gt 0) {
Write-ColorOutput "Both -Token and -Server parameters are required" "Error"
diff --git a/scripts/install.sh b/scripts/install.sh
old mode 100644
new mode 100755
index 8eb38928..64347495
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -30,8 +30,16 @@
# --server, -s ServerKit server URL (required)
# --name, -n Display name for this server (optional)
# --version, -v Specific agent version to install (optional, defaults to latest)
+# --level, -l Permission level: monitor | protect | full (see below)
+# --reconfigure Allow changing the level of an already-installed agent
+# --yes, -y Skip the typed confirmation when reconfiguring
# --help, -h Show this help message
#
+# Permission levels: monitor = report-only (no inbound commands), protect =
+# security actions only (firewall, fail2ban, CrowdSec, Cloudflare origin lock),
+# full = everything. Omitted: a menu on a terminal; `full` (with a warning)
+# when non-interactive, for compatibility with older install commands.
+#
set -e
@@ -67,6 +75,9 @@ TOKEN=""
SERVER_URL=""
SERVER_NAME=""
VERSION="latest"
+LEVEL=""
+RECONFIGURE=false
+ASSUME_YES=false
# Version injected by the panel when it serves this script (the panel already
# resolves the latest agent release for its update endpoints). Empty means
@@ -108,6 +119,9 @@ show_help() {
echo " --server, -s ServerKit server URL (required)"
echo " --name, -n Display name for this server (optional)"
echo " --version, -v Specific agent version (optional, defaults to latest)"
+ echo " --level, -l Permission level: monitor | protect | full (optional)"
+ echo " --reconfigure Allow changing the level of an already-installed agent"
+ echo " --yes, -y Skip the typed confirmation when reconfiguring"
echo " --help, -h Show this help message"
echo ""
echo "Example:"
@@ -142,6 +156,19 @@ parse_args() {
VERSION="$2"
shift 2
;;
+ --level|-l)
+ [[ $# -ge 2 ]] || log_error "Option $1 requires a value"
+ LEVEL="$(printf '%s' "$2" | tr '[:upper:]' '[:lower:]')"
+ shift 2
+ ;;
+ --reconfigure)
+ RECONFIGURE=true
+ shift
+ ;;
+ --yes|-y)
+ ASSUME_YES=true
+ shift
+ ;;
--help|-h)
show_help
;;
@@ -159,6 +186,72 @@ parse_args() {
if [[ -z "$SERVER_URL" ]]; then
log_error "Server URL is required. Use --server or -s"
fi
+
+ if [[ -n "$LEVEL" ]]; then
+ case "$LEVEL" in
+ monitor|protect|full) ;;
+ *) log_error "Unknown permission level '$LEVEL' (use monitor, protect or full)" ;;
+ esac
+ fi
+}
+
+# Level recorded in an existing config ("" when none; a config without the
+# key is a legacy install, which means full).
+installed_level() {
+ local cfg="${CONFIG_DIR}/config.yaml"
+ [[ -f "$cfg" ]] || return 0
+ local lvl
+ lvl="$(sed -n '/^permissions:/,/^[^ ]/ s/^[[:space:]]*level:[[:space:]]*//p' "$cfg" | head -n1 | tr -d "\"' \r")"
+ printf '%s' "${lvl:-full}"
+}
+
+is_tty() { [[ -t 0 && -t 1 ]]; }
+
+# Refuse to silently change the level of an installed agent; --reconfigure
+# plus a typed confirmation (or --yes) is required.
+check_reconfigure() {
+ local current
+ current="$(installed_level)"
+ [[ -n "$current" ]] || return 0
+ if [[ -z "$LEVEL" ]]; then
+ LEVEL="$current"
+ return 0
+ fi
+ [[ "$LEVEL" != "$current" ]] || return 0
+ if [[ "$RECONFIGURE" != true ]]; then
+ log_error "This agent is already installed at level '$current'. Re-run with --reconfigure to change it to '$LEVEL'."
+ fi
+ if [[ "$ASSUME_YES" != true ]]; then
+ local answer=""
+ if is_tty; then
+ read -r -p " Changing level ${current} -> ${LEVEL}. Type '${LEVEL}' to confirm: " answer
+ fi
+ [[ "$answer" == "$LEVEL" ]] || log_error "Confirmation did not match; permission level unchanged (use --yes for scripted use)"
+ fi
+ CHANGE_LEVEL_FROM="$current"
+}
+
+# Pick a level when none was given: menu on a terminal, else full + warning.
+resolve_level() {
+ [[ -z "$LEVEL" ]] || return 0
+ if is_tty; then
+ echo ""
+ echo " Choose what this agent may do on this server:"
+ echo " 1) monitor report-only, accepts no commands from the panel"
+ echo " 2) protect security actions only (firewall, fail2ban, CrowdSec, origin lock)"
+ echo " 3) full everything (docker, files, terminal, packages, ...)"
+ local choice=""
+ read -r -p " Selection [1-3]: " choice
+ case "$choice" in
+ 1|monitor) LEVEL=monitor ;;
+ 2|protect) LEVEL=protect ;;
+ 3|full) LEVEL=full ;;
+ *) log_error "Invalid selection" ;;
+ esac
+ else
+ log_warn "No --level given and no terminal: defaulting to FULL control. Pass --level monitor|protect|full to choose."
+ LEVEL=full
+ fi
}
check_root() {
@@ -351,6 +444,14 @@ register_agent() {
if [[ -n "$SERVER_NAME" ]]; then
REGISTER_CMD+=(--name "${SERVER_NAME}")
fi
+ REGISTER_CMD+=(--level "${LEVEL}")
+
+ # Re-installing at a different level: apply it locally first so the
+ # register step sees a consistent config.
+ if [[ -n "${CHANGE_LEVEL_FROM:-}" ]]; then
+ "${INSTALL_DIR}/${AGENT_BINARY}" --config "${CONFIG_DIR}/config.yaml" \
+ permissions set "${LEVEL}" --yes >/dev/null 2>&1 || true
+ fi
if ! "${REGISTER_CMD[@]}"; then
log_error "Agent registration failed"
@@ -448,6 +549,15 @@ print_success() {
echo -e "${GREEN}║ Installation completed successfully! ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════════════════════════╝${NC}"
echo ""
+ echo -e "${YELLOW}Permission level: ${LEVEL^^}${NC}"
+ case "$LEVEL" in
+ monitor) echo " Report-only: this agent sends metrics out and accepts NO commands." ;;
+ protect) echo " Security actions only (firewall, fail2ban, CrowdSec, origin lock)." ;;
+ *) echo " Full control: the panel can run any supported action." ;;
+ esac
+ echo " Change it (as root, on this machine only):"
+ echo " ${INSTALL_DIR}/${AGENT_BINARY} permissions set "
+ echo ""
echo "Agent Status:"
echo " Binary: ${INSTALL_DIR}/${AGENT_BINARY}"
echo " Config: ${CONFIG_DIR}/config.yaml"
@@ -466,6 +576,8 @@ main() {
print_banner
parse_args "$@"
check_root
+ check_reconfigure
+ resolve_level
detect_platform
check_dependencies
get_latest_version
From be1968746f8e1810a116a993ff7bf8521bf04367 Mon Sep 17 00:00:00 2001
From: Juan Denis
Date: Tue, 3 Nov 2026 00:59:48 -0500
Subject: [PATCH 5/5] feat(frontend): icon-first permission level picker with
info tooltips
Each level card now shows an illustration, title and allowed/blocked
capability icons; the full explanation moved into an (i) tooltip. The
enforced-by-agent note is a single compact line.
Co-Authored-By: Claude Sonnet 5.5
---
.../components/servers/LevelIllustrations.jsx | 49 +++++++++
frontend/src/i18n/locales/en.json | 5 +-
frontend/src/pages/Servers.jsx | 76 ++++++++++---
frontend/src/styles/pages/_servers.scss | 100 ++++++++++++++++--
.../__tests__/agentPermissionLevel.test.mjs | 12 ++-
frontend/src/utils/agentPermissionLevel.js | 18 ++++
6 files changed, 236 insertions(+), 24 deletions(-)
create mode 100644 frontend/src/components/servers/LevelIllustrations.jsx
diff --git a/frontend/src/components/servers/LevelIllustrations.jsx b/frontend/src/components/servers/LevelIllustrations.jsx
new file mode 100644
index 00000000..bb8671d3
--- /dev/null
+++ b/frontend/src/components/servers/LevelIllustrations.jsx
@@ -0,0 +1,49 @@
+// Small inline illustrations for the permission-level cards. They use
+// currentColor plus the panel accent variables, so they follow the theme.
+const common = {
+ viewBox: '0 0 96 56',
+ height: 56,
+ 'aria-hidden': true,
+ focusable: 'false',
+ fill: 'none',
+ stroke: 'currentColor',
+ strokeWidth: 2,
+ strokeLinecap: 'round',
+ strokeLinejoin: 'round',
+};
+
+const Monitor = () => (
+
+);
+
+const Protect = () => (
+
+);
+
+const Full = () => (
+
+);
+
+const ILLUSTRATIONS = { monitor: Monitor, protect: Protect, full: Full };
+
+const LevelIllustration = ({ level }) => {
+ const Svg = ILLUSTRATIONS[level] || Monitor;
+ return ;
+};
+
+export default LevelIllustration;
diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json
index 02a7c335..a519601d 100644
--- a/frontend/src/i18n/locales/en.json
+++ b/frontend/src/i18n/locales/en.json
@@ -5670,6 +5670,8 @@
"agentFound": "Agent found",
"agentPairedSuccessfully": "Agent paired",
"autoDetectedFromAgentOptional": "Auto-detected from agent (optional)",
+ "capAllowed": "allowed",
+ "capBlocked": "blocked",
"clearSelection": "Clear selection",
"confirmThisFingerprintMatchesTheOne": "Confirm this fingerprint matches the one shown by the agent before continuing.",
"connectionString": "Connection string",
@@ -5704,10 +5706,11 @@
"lastSeen": "Last seen",
"leaveBlankToUseTheAgent": "Leave blank to use the agent's hostname.",
"levelColumn": "Level",
- "levelEnforcedByAgent": "The level is enforced by the agent and can only be changed on the server itself, with",
+ "levelEnforcedShort": "Enforced on the server by the agent. Change with",
"levelFull": "Full",
"levelFullCan": "Everything the agent supports: Docker, files, terminal, packages, services and more.",
"levelFullCannot": "No restrictions. Choose this only for servers you want this panel to fully manage.",
+ "levelInfo": "What can {{level}} do?",
"levelMonitor": "Monitor",
"levelMonitorCan": "Reports CPU, memory, disk and service health (web server, PHP-FPM, database) to this panel.",
"levelMonitorCannot": "Cannot run commands, open a terminal or change anything. The panel cannot send it any instructions.",
diff --git a/frontend/src/pages/Servers.jsx b/frontend/src/pages/Servers.jsx
index 99088d97..485af69b 100644
--- a/frontend/src/pages/Servers.jsx
+++ b/frontend/src/pages/Servers.jsx
@@ -1,6 +1,8 @@
import { useState, useEffect, useCallback, useMemo, useId } from 'react';
import { useNavigate } from 'react-router-dom';
-import { ChevronRight, Folder, Plus, RefreshCw, Server as ServerLucideIcon, X } from 'lucide-react';
+import { Ban, ChevronRight, Container, Cpu, Database, Flame, Folder, HardDrive, Info, Lock, MemoryStick, Plus, RefreshCw, Server as ServerLucideIcon, Terminal, X } from 'lucide-react';
+import { Tooltip, TooltipTrigger, TooltipContent } from '@/components/ui/tooltip';
+import LevelIllustration from '../components/servers/LevelIllustrations';
import api from '../services/api';
import { useToast } from '../contexts/useToast.js';
import EmptyState from '../components/EmptyState';
@@ -30,7 +32,7 @@ import { t } from '../i18n/t';
import { toastError } from '@/utils/errorMessage';
import { formatDate } from '@/utils/intl';
import {
- DEFAULT_LEVEL, PERMISSION_LEVELS, buildInstallCommands, levelKind, serverHealth,
+ DEFAULT_LEVEL, PERMISSION_LEVELS, buildInstallCommands, levelAllows, levelKind, serverHealth,
} from '@/utils/agentPermissionLevel';
// Radix Select items cannot use '' — stands in for "no group".
@@ -820,6 +822,19 @@ const healthLabel = (code) => {
}
};
+const CAPABILITY_ICONS = {
+ cpu: [Cpu, 'CPU'],
+ memory: [MemoryStick, 'Memory'],
+ disk: [HardDrive, 'Disk'],
+ services: [ServerLucideIcon, 'Web server and PHP'],
+ database: [Database, 'Database'],
+ firewall: [Flame, 'Firewall'],
+ ban: [Ban, 'Ban (fail2ban, CrowdSec)'],
+ terminal: [Terminal, 'Terminal'],
+ docker: [Container, 'Docker'],
+ files: [Folder, 'Files'],
+};
+
const LevelPicker = ({ value, onChange }) => {
const { t } = useTranslation();
const copy = {
@@ -836,24 +851,59 @@ const LevelPicker = ({ value, onChange }) => {
cannot: t('app.servers.levelFullCannot', 'No restrictions. Choose this only for servers you want this panel to fully manage.'),
},
};
+ const onKeyDown = (e, level) => {
+ if (e.key === ' ' || e.key === 'Enter') {
+ e.preventDefault();
+ onChange(level);
+ }
+ };
return (
-
- {t('app.servers.levelEnforcedByAgent', 'The level is enforced by the agent and can only be changed on the server itself, with')}
+
+
+ {t('app.servers.levelEnforcedShort', 'Enforced on the server by the agent. Change with')}
{' '}{SET_HINT}