mirror of
https://github.com/myronblair/jarvis
synced 2026-06-30 17:50:23 -05:00
Agent version tracking — workers tab shows current vs latest version
- Add version column to registered_agents table - Agents send version on registration (Linux 3.1, Windows 3.0, macOS 3.0) - workers_list API returns latest_versions per platform - Workers tab: VERSION column with green check (up-to-date) or red (outdated) - Outdated agents highlight row and show blue UPDATE button - Up-to-date agents show dimmed UPDATE button - Update button dispatches update command immediately Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -79,23 +79,24 @@ switch ($agentAction) {
|
||||
$ipAddress = $data['ip_address'] ?? ($_SERVER['REMOTE_ADDR'] ?? '');
|
||||
$capabilities = $data['capabilities'] ?? [];
|
||||
$agentId = $data['agent_id'] ?? ($hostname . '_' . substr(md5($hostname . $ipAddress), 0, 8));
|
||||
$version = trim($data['version'] ?? '');
|
||||
|
||||
if (!$hostname) agent_error(400, 'hostname required');
|
||||
if (!in_array($agentType, ['linux', 'homeassistant', 'proxmox', 'windows'])) agent_error(400, 'Invalid agent_type');
|
||||
if (!in_array($agentType, ['linux', 'homeassistant', 'proxmox', 'windows', 'macos'])) agent_error(400, 'Invalid agent_type');
|
||||
|
||||
// Upsert agent
|
||||
$existing = JarvisDB::query('SELECT api_key FROM registered_agents WHERE agent_id = ?', [$agentId]);
|
||||
if ($existing) {
|
||||
$apiKey = $existing[0]['api_key'];
|
||||
JarvisDB::query(
|
||||
'UPDATE registered_agents SET hostname=?, agent_type=?, ip_address=?, capabilities=?, last_seen=NOW(), status="online" WHERE agent_id=?',
|
||||
[$hostname, $agentType, $ipAddress, json_encode($capabilities), $agentId]
|
||||
'UPDATE registered_agents SET hostname=?, agent_type=?, ip_address=?, capabilities=?, version=?, last_seen=NOW(), status="online" WHERE agent_id=?',
|
||||
[$hostname, $agentType, $ipAddress, json_encode($capabilities), $version ?: null, $agentId]
|
||||
);
|
||||
} else {
|
||||
$apiKey = generate_api_key();
|
||||
JarvisDB::query(
|
||||
'INSERT INTO registered_agents (agent_id, hostname, agent_type, ip_address, api_key, capabilities, last_seen, status) VALUES (?,?,?,?,?,?,NOW(),"online")',
|
||||
[$agentId, $hostname, $agentType, $ipAddress, $apiKey, json_encode($capabilities)]
|
||||
'INSERT INTO registered_agents (agent_id, hostname, agent_type, ip_address, api_key, capabilities, version, last_seen, status) VALUES (?,?,?,?,?,?,?,NOW(),"online")',
|
||||
[$agentId, $hostname, $agentType, $ipAddress, $apiKey, json_encode($capabilities), $version ?: null]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user