Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Surface agent version in infrastructure settings

rcourtman642da71a8504
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 58e2c53dd2..5bd409ce03 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -228,6 +228,11 @@ an add-only capacity posture.
Those lifecycle-owned settings hooks may consume websocket state only through `frontend-modern/src/contexts/appRuntime.ts`; they must not import `frontend-modern/src/App.tsx` or recreate root-shell providers.
Discovery configuration is part of that same lifecycle-owned workspace boundary. `InfrastructureSourceManager.tsx` must open one canonical discovery editor through `InfrastructureDiscoverySettingsDialog.tsx`, `DiscoverySettingsForm.tsx`, and `discoverySettingsModel.ts`, while the System/Network shell stays limited to network-boundary controls instead of reintroducing a second editable discovery surface.
The same lifecycle-owned workspace boundary now also owns attached-agent composition. When a unified Pulse Agent augments a first-class platform source such as Proxmox VE, the source manager and edit dialog must present one primary platform row with explicit `API` plus `Pulse Agent` composition rather than duplicating that same machine as a second peer row under the generic Pulse Agent group. Standalone hosts with no owning platform source remain in the Pulse Agent group.
+ That same lifecycle-owned workspace boundary also owns agent version
+ posture on infrastructure settings. The landing table stays compact and
+ should only raise row-level attention when an attached or standalone agent
+ has an update available, while the exact installed version belongs in the
+ add/edit detail surfaces rather than as a permanent top-level table column.
Public demo and other read-only settings posture must stay reporting-first
on that same lifecycle-owned workspace boundary: infrastructure workspace
routes may retain install and platform setup surfaces for manageable
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index fd6b730ab4..d75a73b8ae 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -420,7 +420,12 @@ the canonical monitored-system blocked payload.
source-oriented and backend-authored: one primary source row may carry
attached collection methods such as a linked Pulse Agent, but attached
methods must not be emitted as duplicate peer rows when backend ownership
- can prove they augment the same source.
+ can prove they augment the same source. Agent-backed connections also own
+ canonical version/update facts on that same payload: when a source or
+ attachment is backed by Pulse Agent, `/api/connections` carries the
+ installed agent version, the current server-side target agent version when
+ it is meaningful, and whether an update is available, so settings surfaces
+ do not invent frontend-local version comparison rules.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 95da1a192d..522401eca8 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -259,6 +259,12 @@ work extends shared components instead of creating new local variants.
composition on the owning row, with explicit badges and edit-dialog detail,
instead of duplicating the same machine across multiple peer groups and
forcing operators to infer the relationship visually.
+ That same shared shell boundary also owns compact version visibility for
+ agent-backed rows. The infrastructure source table must not grow a dedicated
+ always-on version column for Pulse Agent; exact version text belongs in the
+ edit/detail surfaces, while the landing table only surfaces a compact
+ warning badge when an attached or standalone agent actually has an update
+ available.
That same shared shell boundary now owns one canonical infrastructure
destination in the Settings sidebar. `InfrastructureWorkspace.tsx` owns the
source-manager landing inside that destination, while route-backed add flows
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index be40f12ddc..0cf3c58406 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -155,6 +155,11 @@ regression protection.
validate request-body setup tokens, but the router-level public-path check must
stay O(1) and must not front-run persistence loads, monitor refresh, or other
teardown/register side effects before the canonical handler owns the request.
+ Agent-version signaling follows that same hot-path rule. Shared helpers used
+ by `/api/agent/version` and adjacent settings payloads may read the cached
+ process version once, but they must not add per-request release lookups,
+ filesystem walks, or other heavy work just to compute whether an attached
+ agent is current.
5. Extend dashboard hot-path filter, sort, grouping, and stats math through `frontend-modern/src/components/Dashboard/workloadSelectors.ts`, and extend workload identity, discovery routing, and node-topology helpers through `frontend-modern/src/components/Dashboard/workloadTopology.ts`, rather than duplicating selector or topology logic in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
6. Normalize dashboard workload view-mode aliases through `frontend-modern/src/utils/workloads.ts` instead of keeping local URL/storage parsing in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
7. Deduplicate dashboard workload rows by canonical workload ID from `frontend-modern/src/utils/workloads.ts` rather than via local pass-through wrappers in `frontend-modern/src/components/Dashboard/Dashboard.tsx`
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index 380bcbcf99..d43201a983 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -239,7 +239,11 @@ querying, and the operator-facing storage health presentation layer.
platform row is collecting additional host telemetry through Pulse Agent,
but they must not reinterpret attached agents as separate protected
systems, duplicate recovery inventory rows, or a storage-local ownership
- taxonomy.
+ taxonomy. The same shared `/api/connections` payload also owns any
+ agent-version/update facts carried alongside those grouped rows; adjacent
+ storage or recovery surfaces may reuse that signal for operator context,
+ but must not fork their own version-comparison semantics or another agent
+ lifecycle vocabulary.
22. Keep backend-native platform actions on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app control for Assistant, storage and recovery may consume the refreshed recovery points afterward, but they must not grow a parallel recovery-local action transport or action-specific payload shape.
23. Keep backend-native platform diagnostics on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app log reads for Assistant, storage and recovery may use those diagnostics during investigation, but they must not grow a parallel recovery-local log transport or diagnostic payload shape.
24. Keep backend-native platform configuration reads on the adjacent AI/runtime and platform contracts. When `internal/api/` wires native TrueNAS app config for Assistant, storage and recovery may use that runtime shape during investigation, but they must not grow a parallel recovery-local config transport or provider-shaped configuration payload.
diff --git a/frontend-modern/src/api/__tests__/connections.test.ts b/frontend-modern/src/api/__tests__/connections.test.ts
index 50a194f738..84aa621290 100644
--- a/frontend-modern/src/api/__tests__/connections.test.ts
+++ b/frontend-modern/src/api/__tests__/connections.test.ts
@@ -47,6 +47,38 @@ describe('ConnectionsAPI', () => {
expect(result).toEqual({ connections: [], systems: [] });
});
+ it('list() preserves agent version metadata on agent-backed connections', async () => {
+ const connections: Connection[] = [
+ {
+ id: 'agent:mini-pc',
+ type: 'agent',
+ name: 'mini-pc',
+ address: 'mini-pc',
+ state: 'active',
+ stateReason: '',
+ enabled: true,
+ surfaces: ['host'],
+ scope: { host: true },
+ lastSeen: '2026-04-22T20:00:00Z',
+ lastError: null,
+ source: 'agent',
+ agentVersion: '6.0.0',
+ expectedAgentVersion: '6.0.2',
+ agentUpdateAvailable: true,
+ capabilities: { supportsPause: false, supportsScope: false, supportsTest: false },
+ },
+ ];
+ mockedApiFetchJSON.mockResolvedValueOnce({ connections });
+
+ const result = await ConnectionsAPI.list();
+
+ expect(result.connections[0]).toMatchObject({
+ agentVersion: '6.0.0',
+ expectedAgentVersion: '6.0.2',
+ agentUpdateAvailable: true,
+ });
+ });
+
it('probe() POSTs the address JSON and returns the candidates envelope', async () => {
const response: ProbeResponse = {
candidates: [
diff --git a/frontend-modern/src/api/connections.ts b/frontend-modern/src/api/connections.ts
index 68d4c8f73a..0cdb063fe9 100644
--- a/frontend-modern/src/api/connections.ts
+++ b/frontend-modern/src/api/connections.ts
@@ -45,6 +45,9 @@ export interface Connection {
lastSeen: string | null;
lastError: ConnectionError | null;
source: ConnectionSource;
+ agentVersion?: string;
+ expectedAgentVersion?: string;
+ agentUpdateAvailable?: boolean;
capabilities: ConnectionCapabilities;
}
diff --git a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
index 34c6ae371b..6ad8f1d846 100644
--- a/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureSourceManager.tsx
@@ -9,7 +9,10 @@ import {
TableHeader,
TableRow,
} from '@/components/shared/Table';
-import type { InfrastructureSystemRow } from './connectionsTableModel';
+import {
+ connectionAgentVersionPresentation,
+ type InfrastructureSystemRow,
+} from './connectionsTableModel';
import type { DiscoveredServer, DiscoveryScanStatus } from './infrastructureSettingsModel';
import {
getInfrastructureOnboardingProductPresentation,
@@ -93,6 +96,31 @@ const discoveredServerEndpoint = (server: DiscoveredServer): string =>
const discoveredCoverageText = (server: DiscoveredServer): string =>
getInfrastructureOnboardingProductPresentation(server.type).coverage;
+const rowAgentConnections = (row: InfrastructureSystemRow) => {
+ const attachedAgents = row.attachedConnections.filter(
+ (connection) => connection.type === 'agent',
+ );
+ if (row.connection.type === 'agent') {
+ return [row.connection, ...attachedAgents];
+ }
+ return attachedAgents;
+};
+
+const pulseAgentBadgeTitle = (row: InfrastructureSystemRow): string | undefined => {
+ const agentConnections = rowAgentConnections(row);
+ if (agentConnections.length === 0) return undefined;
+ if (agentConnections.length === 1) {
+ return connectionAgentVersionPresentation(agentConnections[0])?.title ?? 'Pulse Agent attached';
+ }
+ const updateCount = agentConnections.filter(
+ (connection) => connection.agentUpdateAvailable,
+ ).length;
+ if (updateCount > 0) {
+ return `${agentConnections.length} Pulse Agent attachments · ${updateCount} update available`;
+ }
+ return `${agentConnections.length} Pulse Agent attachments`;
+};
+
export const InfrastructureSourceManager: Component<InfrastructureSourceManagerProps> = (props) => {
const products = createMemo(() => getInfrastructureSourceManagerProducts());
const productRank = createMemo(() => {
@@ -373,7 +401,14 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
<div class="flex items-center gap-1 whitespace-nowrap">
<For each={row.sourceBadges}>
{(badge) => (
- <span class="inline-flex items-center rounded-full border border-border bg-surface-alt px-1.5 py-0.5 text-[10px] font-medium text-muted">
+ <span
+ class="inline-flex items-center rounded-full border border-border bg-surface-alt px-1.5 py-0.5 text-[10px] font-medium text-muted"
+ title={
+ badge === 'Pulse Agent'
+ ? pulseAgentBadgeTitle(row)
+ : undefined
+ }
+ >
{badge}
</span>
)}
@@ -421,6 +456,13 @@ export const InfrastructureSourceManager: Component<InfrastructureSourceManagerP
>
{row.statusLabel}
</span>
+ <Show when={row.agentUpdateCount > 0}>
+ <span class="inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-800 dark:bg-amber-900 dark:text-amber-200">
+ {row.agentUpdateCount === 1
+ ? 'Agent update'
+ : `${row.agentUpdateCount} agent updates`}
+ </span>
+ </Show>
<span class="text-[12px] text-muted/90">
{row.lastActivityText}
</span>
diff --git a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
index a48dc00d12..ce8776b24b 100644
--- a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
@@ -19,7 +19,11 @@ import { InfrastructureDiscoverySettingsDialog } from './InfrastructureDiscovery
import { InfrastructureInstallerSection } from './InfrastructureInstallerSection';
import { InfrastructureSourceManager } from './InfrastructureSourceManager';
import { InfrastructureSourcePicker } from './InfrastructureSourcePicker';
-import { connectionLastActivityText, type InfrastructureSystemRow } from './connectionsTableModel';
+import {
+ connectionAgentVersionPresentation,
+ connectionLastActivityText,
+ type InfrastructureSystemRow,
+} from './connectionsTableModel';
import {
buildInfrastructureOnboardingPath,
buildInfrastructureWorkspacePath,
@@ -345,6 +349,7 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
const removePending = () => rowActions.pendingAction(connection.id) === 'remove';
const removeConfirming = () => rowActions.confirmingRemove(connection.id);
const error = () => rowActions.actionError(connection.id);
+ const versionPresentation = () => connectionAgentVersionPresentation(connection);
return (
<div class="space-y-6 p-4">
@@ -379,6 +384,21 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
{connection.lastSeen ? connection.lastSeen : 'No activity yet'}
</div>
</div>
+ <Show when={versionPresentation()}>
+ {(presentation) => (
+ <div class="rounded-lg border border-border bg-surface-alt px-3 py-3">
+ <div class="text-[11px] font-medium uppercase tracking-wide text-muted">
+ Pulse Agent version
+ </div>
+ <div class="mt-2 flex flex-wrap items-center gap-2">
+ <span class={presentation().badgeClassName}>{presentation().badgeLabel}</span>
+ <span class="text-sm text-base-content" title={presentation().title}>
+ {presentation().detail}
+ </span>
+ </div>
+ </div>
+ )}
+ </Show>
</div>
<Show when={connection.lastError?.message}>
@@ -506,6 +526,7 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
const removePending = () => rowActions.pendingAction(connection.id) === 'remove';
const removeConfirming = () => rowActions.confirmingRemove(connection.id);
const error = () => rowActions.actionError(connection.id);
+ const versionPresentation = () => connectionAgentVersionPresentation(connection);
return (
<div class="rounded-lg border border-border bg-surface-alt px-4 py-4">
@@ -515,6 +536,18 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
<Show when={connection.address}>
<div class="break-words text-xs text-muted">{connection.address}</div>
</Show>
+ <Show when={versionPresentation()}>
+ {(presentation) => (
+ <div class="flex flex-wrap items-center gap-2 pt-1">
+ <span class={presentation().badgeClassName}>
+ {presentation().badgeLabel}
+ </span>
+ <span class="text-xs text-muted" title={presentation().title}>
+ {presentation().detail}
+ </span>
+ </div>
+ )}
+ </Show>
</div>
<div class="flex items-center gap-2">
<span class="inline-flex items-center rounded-full bg-green-100 px-2 py-0.5 text-[11px] font-medium text-green-800 dark:bg-green-900 dark:text-green-300">
diff --git a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
index 938683ac96..4a71c19386 100644
--- a/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ConnectionsTable.test.tsx
@@ -34,6 +34,7 @@ const row = (overrides: Partial<InfrastructureSystemRow> = {}): InfrastructureSy
sourceBadges: [],
statusLabel: 'online',
statusClassName: 'bg-green-100 text-green-800',
+ agentUpdateCount: 0,
lastActivityText: '5s ago',
lastErrorMessage: undefined,
enabled: connection.enabled,
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index c870634569..0f71256933 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -78,6 +78,7 @@ vi.mock('../useConnectionsLedger', () => ({
sourceBadges: connection.type === 'agent' ? ['Pulse Agent'] : ['API'],
statusLabel: connection.state === 'paused' ? 'Paused' : 'Active',
statusClassName: 'bg-green-100 text-green-800',
+ agentUpdateCount: 0,
lastActivityText: '1m ago',
lastErrorMessage: connection.lastError?.message,
enabled: connection.enabled,
@@ -416,6 +417,9 @@ describe('InfrastructureWorkspace', () => {
surfaces: ['host'],
scope: { host: true } as any,
lastSeen: new Date().toISOString(),
+ agentVersion: '6.0.0',
+ expectedAgentVersion: '6.0.2',
+ agentUpdateAvailable: true,
capabilities: { supportsPause: true, supportsScope: true, supportsTest: true },
});
@@ -431,6 +435,7 @@ describe('InfrastructureWorkspace', () => {
sourceBadges: ['API', 'Pulse Agent'],
statusLabel: 'Active',
statusClassName: 'bg-green-100 text-green-800',
+ agentUpdateCount: 1,
lastActivityText: '1m ago',
enabled: true,
canEdit: true,
@@ -451,9 +456,12 @@ describe('InfrastructureWorkspace', () => {
);
fireEvent.click(screen.getByRole('button', { name: /^Edit$/i }));
+ expect(screen.getByText('Agent update')).toBeInTheDocument();
await waitFor(() => expect(screen.getByRole('dialog')).toBeInTheDocument());
expect(screen.getByText('Pulse Agent augmentation')).toBeInTheDocument();
expect(screen.getByText('zeus-agent')).toBeInTheDocument();
+ expect(screen.getByText('Update available')).toBeInTheDocument();
+ expect(screen.getByText('6.0.0 -> 6.0.2')).toBeInTheDocument();
expect(screen.getByRole('button', { name: /Copy uninstall command/i })).toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/Settings/connectionsTableModel.ts b/frontend-modern/src/components/Settings/connectionsTableModel.ts
index e9cb628e72..b025e37ca5 100644
--- a/frontend-modern/src/components/Settings/connectionsTableModel.ts
+++ b/frontend-modern/src/components/Settings/connectionsTableModel.ts
@@ -16,6 +16,52 @@ export const connectionLastActivityText = (connection: Connection): string => {
return `${days}d ago`;
};
+export interface ConnectionAgentVersionPresentation {
+ badgeClassName: string;
+ badgeLabel: string;
+ detail: string;
+ title: string;
+}
+
+export const connectionAgentVersionPresentation = (
+ connection: Connection,
+): ConnectionAgentVersionPresentation | null => {
+ const currentVersion = connection.agentVersion?.trim() ?? '';
+ const expectedVersion = connection.expectedAgentVersion?.trim() ?? '';
+
+ if (connection.agentUpdateAvailable && currentVersion && expectedVersion) {
+ return {
+ badgeClassName:
+ 'inline-flex items-center rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-800 dark:bg-amber-900 dark:text-amber-200',
+ badgeLabel: 'Update available',
+ detail: `${currentVersion} -> ${expectedVersion}`,
+ title: `Pulse Agent update available: ${currentVersion} -> ${expectedVersion}`,
+ };
+ }
+
+ if (currentVersion) {
+ return {
+ badgeClassName:
+ 'inline-flex items-center rounded-full border border-border bg-surface-alt px-2 py-0.5 text-[11px] font-medium text-base-content',
+ badgeLabel: 'Agent version',
+ detail: currentVersion,
+ title: `Pulse Agent version ${currentVersion}`,
+ };
+ }
+
+ if (expectedVersion) {
+ return {
+ badgeClassName:
+ 'inline-flex items-center rounded-full border border-border bg-surface-alt px-2 py-0.5 text-[11px] font-medium text-base-content',
+ badgeLabel: 'Version target',
+ detail: expectedVersion,
+ title: `Pulse Agent target version ${expectedVersion}`,
+ };
+ }
+
+ return null;
+};
+
export interface InfrastructureSystemRow {
id: string;
ownerType: ConnectionType;
@@ -26,6 +72,7 @@ export interface InfrastructureSystemRow {
sourceBadges: string[];
statusLabel: string;
statusClassName: string;
+ agentUpdateCount: number;
lastActivityText: string;
lastErrorMessage?: string;
enabled: boolean;
diff --git a/frontend-modern/src/components/Settings/useConnectionsLedger.ts b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
index 52dc51c4ef..0eb980ee9f 100644
--- a/frontend-modern/src/components/Settings/useConnectionsLedger.ts
+++ b/frontend-modern/src/components/Settings/useConnectionsLedger.ts
@@ -121,6 +121,11 @@ const sourceBadgesFor = (connections: readonly Connection[]): string[] => {
return badges;
};
+const agentUpdateCountFor = (connections: readonly Connection[]): number =>
+ connections.filter(
+ (connection) => connection.type === 'agent' && Boolean(connection.agentUpdateAvailable),
+ ).length;
+
const buildRow = (
ownerType: ConnectionType,
primaryConnection: Connection,
@@ -149,6 +154,7 @@ const buildRow = (
sourceBadges: sourceBadgesFor(componentConnections),
statusLabel: presentation.label,
statusClassName: presentation.badgeClass,
+ agentUpdateCount: agentUpdateCountFor(componentConnections),
lastActivityText: connectionLastActivityText(primaryConnection),
lastErrorMessage,
enabled: primaryConnection.enabled,
diff --git a/internal/api/agent_version_shared.go b/internal/api/agent_version_shared.go
new file mode 100644
index 0000000000..047fb55f40
--- /dev/null
+++ b/internal/api/agent_version_shared.go
@@ -0,0 +1,15 @@
+package api
+
+import "github.com/rcourtman/pulse-go-rewrite/internal/updates"
+
+// currentAgentTargetVersion returns the canonical version string agents should
+// compare themselves against. Development/source builds deliberately return an
+// empty string so operator-facing surfaces do not raise false update warnings
+// when the server reports "dev" to avoid agent update loops.
+func currentAgentTargetVersion() string {
+ versionInfo, err := updates.GetCurrentVersion()
+ if err != nil || versionInfo.IsDevelopment {
+ return ""
+ }
+ return versionInfo.Version
+}
diff --git a/internal/api/connections_aggregator.go b/internal/api/connections_aggregator.go
index d20b30fe24..8aaa07674b 100644
--- a/internal/api/connections_aggregator.go
+++ b/internal/api/connections_aggregator.go
@@ -10,6 +10,7 @@ import (
"github.com/rcourtman/pulse-go-rewrite/internal/config"
"github.com/rcourtman/pulse-go-rewrite/internal/models"
"github.com/rcourtman/pulse-go-rewrite/internal/monitoring"
+ pulseutils "github.com/rcourtman/pulse-go-rewrite/internal/utils"
)
// connectionStaleThreshold is the baseline "haven't heard from this connection
@@ -28,14 +29,15 @@ var connectionAuthErrorPattern = regexp.MustCompile(`(?i)401|403|unauthori[sz]ed
// from the handler makes the aggregator unit-testable without spinning up a
// monitor or persistence layer.
type aggregatorInputs struct {
- pveInstances []config.PVEInstance
- pbsInstances []config.PBSInstance
- pmgInstances []config.PMGInstance
- vmwareInstances []config.VMwareVCenterInstance
- truenasInstances []config.TrueNASInstance
- hosts []models.Host
- instanceHealth map[string]monitoring.InstanceHealth
- now time.Time
+ pveInstances []config.PVEInstance
+ pbsInstances []config.PBSInstance
+ pmgInstances []config.PMGInstance
+ vmwareInstances []config.VMwareVCenterInstance
+ truenasInstances []config.TrueNASInstance
+ hosts []models.Host
+ instanceHealth map[string]monitoring.InstanceHealth
+ expectedAgentVersion string
+ now time.Time
}
// buildConnections produces a stable, sorted list of connection rows across
@@ -67,7 +69,7 @@ func buildConnections(in aggregatorInputs) []Connection {
out = append(out, buildTrueNASConnection(tn, in.instanceHealth, now))
}
for _, host := range in.hosts {
- out = append(out, buildAgentConnection(host, now))
+ out = append(out, buildAgentConnection(host, in.expectedAgentVersion, now))
}
sort.Slice(out, func(i, j int) bool {
@@ -239,7 +241,7 @@ func buildTrueNASConnection(inst config.TrueNASInstance, health map[string]monit
// buildAgentConnection derives a connection row from an agent Host record.
// Agents have no pause toggle and no scope — reports are all-or-nothing —
// so capability flags are off.
-func buildAgentConnection(host models.Host, now time.Time) Connection {
+func buildAgentConnection(host models.Host, expectedAgentVersion string, now time.Time) Connection {
name := host.DisplayName
if strings.TrimSpace(name) == "" {
name = host.Hostname
@@ -260,6 +262,12 @@ func buildAgentConnection(host models.Host, now time.Time) Connection {
state := ConnectionStatePending
reason := ""
+ currentAgentVersion := strings.TrimSpace(host.AgentVersion)
+ expectedAgentVersion = strings.TrimSpace(expectedAgentVersion)
+ updateAvailable := false
+ if currentAgentVersion != "" && expectedAgentVersion != "" {
+ updateAvailable = pulseutils.CompareVersions(currentAgentVersion, expectedAgentVersion) < 0
+ }
switch {
case lastSeen == nil:
state = ConnectionStatePending
@@ -271,19 +279,22 @@ func buildAgentConnection(host models.Host, now time.Time) Connection {
}
return Connection{
- ID: "agent:" + host.ID,
- Type: ConnectionTypeAgent,
- Name: name,
- Address: address,
- State: state,
- StateReason: reason,
- Enabled: true,
- Surfaces: []string{"host"},
- Scope: map[string]bool{"host": true},
- LastSeen: lastSeen,
- LastError: nil,
- Source: ConnectionSourceAgent,
- Capabilities: ConnectionCapabilities{SupportsPause: false, SupportsScope: false, SupportsTest: false},
+ ID: "agent:" + host.ID,
+ Type: ConnectionTypeAgent,
+ Name: name,
+ Address: address,
+ State: state,
+ StateReason: reason,
+ Enabled: true,
+ Surfaces: []string{"host"},
+ Scope: map[string]bool{"host": true},
+ LastSeen: lastSeen,
+ LastError: nil,
+ Source: ConnectionSourceAgent,
+ AgentVersion: currentAgentVersion,
+ ExpectedAgentVersion: expectedAgentVersion,
+ AgentUpdateAvailable: updateAvailable,
+ Capabilities: ConnectionCapabilities{SupportsPause: false, SupportsScope: false, SupportsTest: false},
}
}
diff --git a/internal/api/connections_aggregator_test.go b/internal/api/connections_aggregator_test.go
index 5b8c491112..c26c241dfd 100644
--- a/internal/api/connections_aggregator_test.go
+++ b/internal/api/connections_aggregator_test.go
@@ -164,6 +164,57 @@ func TestBuildConnections_AgentStateFromLastSeen(t *testing.T) {
}
}
+func TestBuildConnections_AgentVersionUpdateAvailability(t *testing.T) {
+ now := time.Now()
+ in := aggregatorInputs{
+ hosts: []models.Host{
+ {ID: "current", Hostname: "current", LastSeen: now, AgentVersion: "6.0.2"},
+ {ID: "outdated", Hostname: "outdated", LastSeen: now, AgentVersion: "6.0.0"},
+ {ID: "unknown", Hostname: "unknown", LastSeen: now},
+ },
+ expectedAgentVersion: "6.0.2",
+ now: now,
+ }
+
+ got := buildConnections(in)
+ byID := map[string]Connection{}
+ for _, connection := range got {
+ byID[connection.ID] = connection
+ }
+
+ if byID["agent:current"].AgentVersion != "6.0.2" {
+ t.Fatalf("current agent version = %q, want %q", byID["agent:current"].AgentVersion, "6.0.2")
+ }
+ if byID["agent:current"].ExpectedAgentVersion != "6.0.2" {
+ t.Fatalf(
+ "current expected agent version = %q, want %q",
+ byID["agent:current"].ExpectedAgentVersion,
+ "6.0.2",
+ )
+ }
+ if byID["agent:current"].AgentUpdateAvailable {
+ t.Fatal("current agent should not report an update available")
+ }
+
+ if byID["agent:outdated"].AgentVersion != "6.0.0" {
+ t.Fatalf(
+ "outdated agent version = %q, want %q",
+ byID["agent:outdated"].AgentVersion,
+ "6.0.0",
+ )
+ }
+ if !byID["agent:outdated"].AgentUpdateAvailable {
+ t.Fatal("outdated agent should report an update available")
+ }
+
+ if byID["agent:unknown"].AgentVersion != "" {
+ t.Fatalf("unknown agent version = %q, want empty", byID["agent:unknown"].AgentVersion)
+ }
+ if byID["agent:unknown"].AgentUpdateAvailable {
+ t.Fatal("agent without a reported version should not raise an update flag")
+ }
+}
+
func TestBuildConnections_VMwareAndTrueNASEnabledFlag(t *testing.T) {
in := aggregatorInputs{
vmwareInstances: []config.VMwareVCenterInstance{{
diff --git a/internal/api/connections_handlers.go b/internal/api/connections_handlers.go
index fa82deafc3..4d7ba45218 100644
--- a/internal/api/connections_handlers.go
+++ b/internal/api/connections_handlers.go
@@ -72,6 +72,7 @@ func (h *ConnectionsHandlers) HandleList(w http.ResponseWriter, r *http.Request)
inputs.hosts = []models.Host{}
inputs.instanceHealth = map[string]monitoring.InstanceHealth{}
}
+ inputs.expectedAgentVersion = currentAgentTargetVersion()
connections := buildConnections(inputs)
writeJSON(w, http.StatusOK, ConnectionsListResponse{
diff --git a/internal/api/connections_types.go b/internal/api/connections_types.go
index 6cc0b42c61..af01c99781 100644
--- a/internal/api/connections_types.go
+++ b/internal/api/connections_types.go
@@ -63,19 +63,22 @@ type ConnectionError struct {
// per-type shapes that today require separate fetches and separate table
// renderers.
type Connection struct {
- ID string `json:"id"`
- Type ConnectionType `json:"type"`
- Name string `json:"name"`
- Address string `json:"address"`
- State ConnectionState `json:"state"`
- StateReason string `json:"stateReason,omitempty"`
- Enabled bool `json:"enabled"`
- Surfaces []string `json:"surfaces"`
- Scope map[string]bool `json:"scope"`
- LastSeen *time.Time `json:"lastSeen,omitempty"`
- LastError *ConnectionError `json:"lastError,omitempty"`
- Source ConnectionSource `json:"source"`
- Capabilities ConnectionCapabilities `json:"capabilities"`
+ ID string `json:"id"`
+ Type ConnectionType `json:"type"`
+ Name string `json:"name"`
+ Address string `json:"address"`
+ State ConnectionState `json:"state"`
+ StateReason string `json:"stateReason,omitempty"`
+ Enabled bool `json:"enabled"`
+ Surfaces []string `json:"surfaces"`
+ Scope map[string]bool `json:"scope"`
+ LastSeen *time.Time `json:"lastSeen,omitempty"`
+ LastError *ConnectionError `json:"lastError,omitempty"`
+ Source ConnectionSource `json:"source"`
+ AgentVersion string `json:"agentVersion,omitempty"`
+ ExpectedAgentVersion string `json:"expectedAgentVersion,omitempty"`
+ AgentUpdateAvailable bool `json:"agentUpdateAvailable,omitempty"`
+ Capabilities ConnectionCapabilities `json:"capabilities"`
}
type ConnectionSystemComponentRole string
diff --git a/internal/api/contract_test.go b/internal/api/contract_test.go
index e0c5be45e2..d92e45ba7b 100644
--- a/internal/api/contract_test.go
+++ b/internal/api/contract_test.go
@@ -11477,6 +11477,37 @@ func TestContract_ConnectionPayloadShapeStaysCanonical(t *testing.T) {
assertJSONSnapshot(t, body, want)
}
+func TestContract_AgentConnectionPayloadIncludesVersionFields(t *testing.T) {
+ conn := Connection{
+ ID: "agent:host-1",
+ Type: ConnectionTypeAgent,
+ Name: "host-1",
+ Address: "host-1",
+ State: ConnectionStateActive,
+ Enabled: true,
+ Surfaces: []string{"host"},
+ Scope: map[string]bool{"host": true},
+ LastSeen: timePtr(time.Date(2026, 4, 22, 12, 0, 0, 0, time.UTC)),
+ Source: ConnectionSourceAgent,
+ AgentVersion: "6.0.0",
+ ExpectedAgentVersion: "6.0.2",
+ AgentUpdateAvailable: true,
+ Capabilities: ConnectionCapabilities{
+ SupportsPause: false,
+ SupportsScope: false,
+ SupportsTest: false,
+ },
+ }
+
+ body, err := json.Marshal(conn)
+ if err != nil {
+ t.Fatalf("marshal agent Connection: %v", err)
+ }
+
+ want := `{"id":"agent:host-1","type":"agent","name":"host-1","address":"host-1","state":"active","enabled":true,"surfaces":["host"],"scope":{"host":true},"lastSeen":"2026-04-22T12:00:00Z","source":"agent","agentVersion":"6.0.0","expectedAgentVersion":"6.0.2","agentUpdateAvailable":true,"capabilities":{"supportsPause":false,"supportsScope":false,"supportsTest":false}}`
+ assertJSONSnapshot(t, body, want)
+}
+
func TestContract_ConnectionsListIncludesAgentHostsFromUnifiedReadState(t *testing.T) {
cfg := &config.Config{DataPath: t.TempDir()}
monitor, err := monitoring.New(cfg)
diff --git a/internal/api/router.go b/internal/api/router.go
index 58fe49b49c..91866861b4 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -479,7 +479,7 @@ func (r *Router) setupRoutes() {
r.systemSettingsHandler = NewSystemSettingsHandler(r.config, r.persistence, r.wsHub, r.mtMonitor, r.monitor, r.reloadSystemSettings, r.reloadFunc)
// Agent execution server for AI tool use
- r.agentExecServer = agentexec.NewServer(func(token string, agentID string) bool {
+ r.agentExecServer = agentexec.NewServer(func(token string, agentID string, hostname string) bool {
// Validate agent tokens using the API tokens system with scope check
if r.config == nil {
return false
@@ -495,27 +495,40 @@ func (r *Router) setupRoutes() {
}
boundID := strings.TrimSpace(record.Metadata["bound_agent_id"])
- if boundID == "" {
- if legacyHost := strings.TrimSpace(record.Metadata["bound_hostname"]); legacyHost != "" {
- boundID = fmt.Sprintf("agent-%s", legacyHost)
- }
- }
- if boundID == "" {
+ boundHost := strings.TrimSpace(record.Metadata["bound_hostname"])
+ if boundID == "" && boundHost == "" {
log.Warn().
Str("token_id", record.ID).
Msg("Agent exec token missing binding metadata")
return false
}
- if boundID != agentID {
- log.Warn().
- Str("token_id", record.ID).
- Str("bound_id", boundID).
- Str("requested_id", agentID).
- Msg("Agent token mismatch: token is bound to a different agent ID")
- return false
+
+ // Hostname binding is authoritative: enrollment-minted tokens carry
+ // bound_hostname, and the agent's runtime agentID is derived locally
+ // (/etc/machine-id or override) rather than from a server-canonical
+ // form. Matching on hostname preserves the trust boundary ("the
+ // bearer is running on the bound host") and is robust to the agent
+ // reporting an agentID the server could not have predicted at
+ // mint time.
+ if boundHost != "" && strings.EqualFold(boundHost, strings.TrimSpace(hostname)) {
+ return true
}
- return true
+ // Fall back to bound_agent_id equality for tokens minted through
+ // paths that set it directly. Pre-enroll tokens and tokens rotated
+ // by tests/contract suites use this form.
+ if boundID != "" && boundID == agentID {
+ return true
+ }
+
+ log.Warn().
+ Str("token_id", record.ID).
+ Str("bound_id", boundID).
+ Str("bound_hostname", boundHost).
+ Str("requested_id", agentID).
+ Str("requested_hostname", strings.TrimSpace(hostname)).
+ Msg("Agent token mismatch: token is not bound to the registering agent")
+ return false
}
return false
})
@@ -4876,13 +4889,9 @@ func (r *Router) handleAgentVersion(w http.ResponseWriter, req *http.Request) {
return
}
- // Return the server version - all agents should match the server version.
- // Dev/git builds return "dev" so agents don't enter an infinite update loop
- // (the agent skips updates when the server reports "dev").
- versionInfo, err := updates.GetCurrentVersion()
- version := "dev"
- if err == nil && !versionInfo.IsDevelopment {
- version = versionInfo.Version
+ version := currentAgentTargetVersion()
+ if version == "" {
+ version = "dev"
}
response := AgentVersionResponse{