fix: repair version detection platform query format

- Fix GetLatestVersionByTypeAndArch to separate platform/architecture
- Query now correctly uses platform='linux' and architecture='amd64'
- Resolves UI showing 'no packages available' despite updates existing
This commit is contained in:
Fimeg
2025-11-10 20:11:32 -05:00
parent e6ac0b1ec4
commit 1f2b1b7179
7 changed files with 412 additions and 34 deletions

View File

@@ -73,6 +73,23 @@ export function AgentUpdatesModal({
const pkg = packages.find(p => p.id === packageId);
if (!pkg) throw new Error('Package not found');
// For single agent updates, use individual update with nonce for security
if (selectedAgentIds.length === 1) {
const agentId = selectedAgentIds[0];
// Generate nonce for security
const nonceData = await agentApi.generateUpdateNonce(agentId, pkg.version);
console.log('[UI] Update nonce generated for single agent:', nonceData);
// Use individual update endpoint with nonce
return agentApi.updateAgent(agentId, {
version: pkg.version,
platform: pkg.platform,
nonce: nonceData.update_nonce
});
}
// For multiple agents, use bulk update
const updateData = {
agent_ids: selectedAgentIds,
version: pkg.version,
@@ -82,7 +99,9 @@ export function AgentUpdatesModal({
return agentApi.updateMultipleAgents(updateData);
},
onSuccess: (data) => {
toast.success(`Update initiated for ${data.updated?.length || 0} agent(s)`);
const count = selectedAgentIds.length;
const message = count === 1 ? 'Update initiated for agent' : `Update initiated for ${count} agents`;
toast.success(message);
setIsUpdating(false);
onAgentsUpdated();
onClose();

View File

@@ -172,6 +172,24 @@ export const agentApi = {
return response.data;
},
// Check if update available for agent
checkForUpdateAvailable: async (agentId: string): Promise<{ hasUpdate: boolean; currentVersion: string; latestVersion?: string; reason?: string; platform?: string }> => {
const response = await api.get(`/agents/${agentId}/updates/available`);
return response.data;
},
// Get update status for agent
getUpdateStatus: async (agentId: string): Promise<{ status: string; progress?: number; error?: string }> => {
const response = await api.get(`/agents/${agentId}/updates/status`);
return response.data;
},
// Generate update nonce for agent (new security feature)
generateUpdateNonce: async (agentId: string, targetVersion: string): Promise<{ agent_id: string; target_version: string; update_nonce: string; expires_at: number; expires_in_seconds: number }> => {
const response = await api.post(`/agents/${agentId}/update-nonce?target_version=${targetVersion}`);
return response.data;
},
// Update multiple agents (bulk)
updateMultipleAgents: async (updateData: {
agent_ids: string[];