Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(servers): store the agent's self-reported footprint dirs

Juan Denise93faac2269a
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 31f57954..adc503f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -291,7 +291,9 @@ awaiting a stable release:
browsing a remote agent the quick-access rail now matches that box: Linux
agents get their agent config dir alongside the generic paths, Windows agents
get `ProgramData\ServerKit\Agent` + `C:\Users` instead of Unix paths that
- don't exist there.
+ don't exist there. Agents newer than v1.0.4 self-report their real install
+ and config directories in `system_info` (stored on the server record,
+ migration 047), and the rail prefers those over the installer conventions.
- **Scripts reliability (round 2)** — swept the whole install/update/uninstall/CLI
shell surface for the "benign non-zero under `set -e`/`pipefail`" failure class
behind the July 2 update outage:
diff --git a/backend/app/models/server.py b/backend/app/models/server.py
index ec19c7bd..32ebbfe0 100644
--- a/backend/app/models/server.py
+++ b/backend/app/models/server.py
@@ -121,6 +121,10 @@ class Server(db.Model):
total_memory = db.Column(db.BigInteger) # bytes
total_disk = db.Column(db.BigInteger) # bytes
docker_version = db.Column(db.String(50))
+ # Agent's self-reported footprint (binary dir / config dir) — preferred
+ # over installer-default conventions by target-aware UIs (File Manager).
+ agent_install_dir = db.Column(db.String(255))
+ agent_config_dir = db.Column(db.String(255))
# Security
api_key_hash = db.Column(db.String(256)) # bcrypt hash
@@ -444,6 +448,8 @@ class Server(db.Model):
'total_memory': self.total_memory,
'total_disk': self.total_disk,
'docker_version': self.docker_version,
+ 'agent_install_dir': self.agent_install_dir,
+ 'agent_config_dir': self.agent_config_dir,
'permissions': self.permissions or [],
'allowed_ips': self.allowed_ips or [],
'api_key_last_rotated': self.api_key_last_rotated.isoformat() if self.api_key_last_rotated else None,
diff --git a/backend/app/services/agent_registry.py b/backend/app/services/agent_registry.py
index 640556f0..f30255e3 100644
--- a/backend/app/services/agent_registry.py
+++ b/backend/app/services/agent_registry.py
@@ -1023,6 +1023,8 @@ class AgentRegistry:
server.total_disk = _coalesce(server.total_disk, info.get('total_disk'))
server.docker_version = _coalesce(server.docker_version, info.get('docker_version'))
server.agent_version = _coalesce(server.agent_version, info.get('agent_version'))
+ server.agent_install_dir = _coalesce(server.agent_install_dir, info.get('install_dir'))
+ server.agent_config_dir = _coalesce(server.agent_config_dir, info.get('config_dir'))
db.session.commit()
except Exception:
logger.exception("Error updating system info")
diff --git a/backend/app/services/remote_docker_service.py b/backend/app/services/remote_docker_service.py
index 25fa5e1a..74eb81cc 100644
--- a/backend/app/services/remote_docker_service.py
+++ b/backend/app/services/remote_docker_service.py
@@ -514,6 +514,10 @@ class RemoteDockerService:
# linux/windows/darwin — lets target-aware UIs (File Manager
# quick links) offer paths that exist on that box.
'os_type': server.os_type,
+ # Agent's self-reported footprint (null until an agent that
+ # reports it connects) — preferred over installer conventions.
+ 'agent_install_dir': server.agent_install_dir,
+ 'agent_config_dir': server.agent_config_dir,
})
return servers
diff --git a/backend/migrations/versions/047_agent_footprint_dirs.py b/backend/migrations/versions/047_agent_footprint_dirs.py
new file mode 100644
index 00000000..38613021
--- /dev/null
+++ b/backend/migrations/versions/047_agent_footprint_dirs.py
@@ -0,0 +1,47 @@
+"""Agent self-reported footprint.
+
+Adds:
+- servers.agent_install_dir (running binary's directory)
+- servers.agent_config_dir (directory of the loaded config file)
+
+Both reported by the agent in system_info; target-aware UIs (File Manager
+quick links) prefer them over installer-default conventions.
+
+Idempotent: MigrationService runs _fix_missing_columns() + db.create_all() on boot
+before Alembic, so guard on the live schema.
+
+Revision ID: 047_agent_footprint_dirs
+Revises: 046_drop_legacy_marketplace
+Create Date: 2026-07-02
+"""
+from alembic import op
+import sqlalchemy as sa
+
+revision = '047_agent_footprint_dirs'
+down_revision = '046_drop_legacy_marketplace'
+branch_labels = None
+depends_on = None
+
+_COLUMNS = ('agent_install_dir', 'agent_config_dir')
+
+
+def upgrade():
+ conn = op.get_bind()
+ inspector = sa.inspect(conn)
+ if 'servers' not in set(inspector.get_table_names()):
+ return
+ cols = {c['name'] for c in inspector.get_columns('servers')}
+ for name in _COLUMNS:
+ if name not in cols:
+ op.add_column('servers', sa.Column(name, sa.String(255), nullable=True))
+
+
+def downgrade():
+ conn = op.get_bind()
+ inspector = sa.inspect(conn)
+ if 'servers' not in set(inspector.get_table_names()):
+ return
+ cols = {c['name'] for c in inspector.get_columns('servers')}
+ for name in _COLUMNS:
+ if name in cols:
+ op.drop_column('servers', name)
diff --git a/backend/tests/test_available_servers.py b/backend/tests/test_available_servers.py
index c7486523..94eea056 100644
--- a/backend/tests/test_available_servers.py
+++ b/backend/tests/test_available_servers.py
@@ -41,3 +41,34 @@ def test_available_servers_os_type_null_for_legacy_agents(app):
assert remote
assert 'os_type' in remote[0]
assert remote[0]['os_type'] is None
+
+
+def test_agent_footprint_round_trip(app):
+ """The agent's self-reported install_dir/config_dir (system_info) land on
+ the Server row via update_system_info and surface in /servers/available —
+ the chain the File Manager's per-target quick links ride on."""
+ from app.services.agent_registry import agent_registry
+
+ with app.app_context():
+ server = _make_server(name='Reporting Agent', os_type='linux')
+
+ agent_registry.update_system_info(server.id, {
+ 'install_dir': '/usr/local/bin',
+ 'config_dir': '/etc/serverkit-agent',
+ })
+
+ db.session.refresh(server)
+ assert server.agent_install_dir == '/usr/local/bin'
+ assert server.agent_config_dir == '/etc/serverkit-agent'
+
+ remote = [s for s in RemoteDockerService.get_available_servers()
+ if not s['is_local']]
+ assert remote[0]['agent_install_dir'] == '/usr/local/bin'
+ assert remote[0]['agent_config_dir'] == '/etc/serverkit-agent'
+
+ # A later payload without the keys (transient probe gap) must not
+ # wipe the stored values — same coalesce contract as the other
+ # system_info columns.
+ agent_registry.update_system_info(server.id, {'hostname': 'still-here'})
+ db.session.refresh(server)
+ assert server.agent_config_dir == '/etc/serverkit-agent'
diff --git a/frontend/src/components/TargetPicker.jsx b/frontend/src/components/TargetPicker.jsx
index 7b3bdbe1..94341c34 100644
--- a/frontend/src/components/TargetPicker.jsx
+++ b/frontend/src/components/TargetPicker.jsx
@@ -12,10 +12,11 @@ import { api } from '../services/api';
// pattern as the cron picker.
//
// onChange receives `{ kind: 'local' } | { kind: 'agent', server_id, name,
-// allowedPaths, os_type }` (os_type: linux/windows/darwin or null for agents
-// that predate sysinfo reporting), or `{ kind: <extra.value> }` for any
-// caller-supplied `extraOptions` (e.g. an "S3 bucket" target in the File
-// Manager).
+// allowedPaths, os_type, agentInstallDir, agentConfigDir }` (os_type:
+// linux/windows/darwin, and the agent's self-reported footprint dirs — all
+// null for agents that predate sysinfo reporting), or `{ kind: <extra.value> }`
+// for any caller-supplied `extraOptions` (e.g. an "S3 bucket" target in the
+// File Manager).
export default function TargetPicker({ feature, value, onChange, includeLocal = true, extraOptions = [] }) {
const [servers, setServers] = useState([]);
@@ -54,6 +55,8 @@ export default function TargetPicker({ feature, value, onChange, includeLocal =
name: s.name || s.hostname || s.id,
allowedPaths: s.allowed_paths || [],
os_type: s.os_type || null,
+ agentInstallDir: s.agent_install_dir || null,
+ agentConfigDir: s.agent_config_dir || null,
});
}
diff --git a/frontend/src/pages/FileManager.jsx b/frontend/src/pages/FileManager.jsx
index ac42527b..f502c304 100644
--- a/frontend/src/pages/FileManager.jsx
+++ b/frontend/src/pages/FileManager.jsx
@@ -160,16 +160,29 @@ function FileManager() {
// Per-target rail: agents get their OS's set (unknown os_type — an agent
// predating sysinfo reporting — is treated as linux, the historical
- // behavior); the local host gets the panel set with the resolved Stack dir.
+ // behavior), with the agent's SELF-REPORTED config dir preferred over the
+ // installer convention when the agent sent one (system_info footprint);
+ // the local host gets the panel set with the resolved Stack dir.
const quickAccess = useMemo(() => {
if (isRemote) {
const os = (target.os_type || 'linux').toLowerCase();
- return QUICK_ACCESS_AGENT[os] || QUICK_ACCESS_AGENT.linux;
+ const rail = QUICK_ACCESS_AGENT[os] || QUICK_ACCESS_AGENT.linux;
+ // Windows agents report filepath-style backslashes; the file
+ // wire protocol speaks forward slashes.
+ const configDir = target.agentConfigDir
+ ? target.agentConfigDir.replace(/\\/g, '/').replace(/\/+$/, '')
+ : null;
+ if (!configDir) return rail;
+ return rail.map((q) => {
+ if (q.label === 'Agent') return { ...q, path: configDir };
+ if (q.label === 'Agent logs') return { ...q, path: `${configDir}/logs` };
+ return q;
+ });
}
return QUICK_ACCESS.map((q) =>
q.label === 'Stack' ? { ...q, path: panelInstallDir } : q
);
- }, [isRemote, target.os_type, panelInstallDir]);
+ }, [isRemote, target.os_type, target.agentConfigDir, panelInstallDir]);
// ─── core ────────────────────────────────────────────
const [currentPath, setCurrentPath] = useState(() => searchParams.get('path') || '/home');