Hub 2.19.0: the server agent's releases; Update agent picks one

- AgentRelease (migration 20261123150000_agent_release): the agent's releases, apart from the
  products' so licences and billing are untouched.
- Release sources can be for the Server agent; the defaults include it (monorepo agent@ tags,
  apps/agent/WHATS-NEW.md). Same sync rules as products. A saved list without it gets an
  "Add the agent's source" button on the Releases page.
- GET /api/admin/agent-releases; server summaries carry agentLatest; update-agent jobs go to a
  known agent release, the latest when none is asked for (agentTag).
- Update agent is a ReleaseSelect with the chosen version's notes; the Servers list and a server's
  page say when a newer agent is out; the Releases page shows agent releases (Server agent filter,
  Everything newest first by date).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-23 13:18:56 +02:00
co-authored by Claude Opus 5.5
parent 44fac310eb
commit 65637711c6
19 changed files with 292 additions and 50 deletions
+5 -2
View File
@@ -11,6 +11,7 @@ const { audit } = require('../utils/audit');
const { getSettings, setSettings } = require('../utils/settings');
const servers = require('../utils/servers');
const jobs = require('../utils/jobs');
const { latestAgentVersion } = require('../utils/releases');
const { pageOf, paged } = require('../utils/paging');
const router = express.Router();
@@ -79,7 +80,9 @@ router.get('/servers', wrap(async (req, res) => {
const since = new Date(Date.now() - 24 * 60 * 60 * 1000);
const day = await prisma.serverStat.groupBy({ by: ['serverId'], where: { at: { gt: since } }, _avg: { cpuPercent: true, ramUsedPercent: true }, _max: { cpuPeak: true, ramPeak: true } });
const byServer = new Map(day.map(d => [d.serverId, { cpuAvg: d._avg.cpuPercent, ramAvg: d._avg.ramUsedPercent, cpuPeak: d._max.cpuPeak, ramPeak: d._max.ramPeak }]));
res.json({ servers: list.map(s => ({ ...serverSummary(s), lastDay: byServer.get(s.id) || null })) });
// Hub 2.19.0: the newest agent release, so each server can say when it's behind.
const agentLatest = await latestAgentVersion();
res.json({ servers: list.map(s => ({ ...serverSummary(s), agentLatest, lastDay: byServer.get(s.id) || null })) });
}));
router.post('/servers/join-token', wrap(async (req, res) => {
@@ -97,7 +100,7 @@ router.get('/servers/:id', wrap(async (req, res) => {
const stats = bucketStats(rows, { '24h': 0, '7d': 60, '90d': 360 }[range]);
const recentJobs = await prisma.job.findMany({ where: { serverId: s.id }, orderBy: { createdAt: 'desc' }, take: 25, select: { id: true, type: true, status: true, args: true, notBefore: true, finishedAt: true, message: true, deploymentId: true } });
res.json(jsonSafe({
server: serverSummary(s),
server: { ...serverSummary(s), agentLatest: await latestAgentVersion() },
config: masked(servers.serverConfig(s)),
processes: s.lastStats?.processes || [],
stats: stats.map(x => ({ at: x.at, cpuPercent: x.cpuPercent, cpuPeak: x.cpuPeak, ramUsedPercent: x.ramUsedPercent, ramPeak: x.ramPeak, diskUsedPercent: x.diskUsedPercent })),