mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
fix: persist agent version on every heartbeat
update_agent_seen() now updates version column when agents include it in their heartbeat payload. Previously version was only stored on registration, leaving the Workers tab showing NULL for agents that hadn't re-registered since v3.1. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+13
-6
@@ -37,11 +37,18 @@ function get_agent_by_key(string $key): ?array {
|
||||
return $rows[0] ?? null;
|
||||
}
|
||||
|
||||
function update_agent_seen(string $agentId, string $status = 'online'): void {
|
||||
JarvisDB::query(
|
||||
'UPDATE registered_agents SET last_seen = NOW(), status = ? WHERE agent_id = ?',
|
||||
[$status, $agentId]
|
||||
);
|
||||
function update_agent_seen(string $agentId, string $status = 'online', ?string $version = null): void {
|
||||
if ($version !== null) {
|
||||
JarvisDB::query(
|
||||
'UPDATE registered_agents SET last_seen = NOW(), status = ?, version = ? WHERE agent_id = ?',
|
||||
[$status, $version, $agentId]
|
||||
);
|
||||
} else {
|
||||
JarvisDB::query(
|
||||
'UPDATE registered_agents SET last_seen = NOW(), status = ? WHERE agent_id = ?',
|
||||
[$status, $agentId]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Auth (all actions except register) ───────────────────────────────────────
|
||||
@@ -104,7 +111,7 @@ switch ($agentAction) {
|
||||
|
||||
// ── HEARTBEAT ────────────────────────────────────────────────────────────
|
||||
case 'heartbeat':
|
||||
update_agent_seen($agent['agent_id']);
|
||||
update_agent_seen($agent['agent_id'], 'online', trim($data['version'] ?? '') ?: null);
|
||||
|
||||
// Return any pending commands for this agent
|
||||
$commands = JarvisDB::query(
|
||||
|
||||
Reference in New Issue
Block a user