fix(heartbeat): extrai inventory de metadata quando args.inventory vazio
Some checks failed
CI/CD Web + Desktop / Detect changes (push) Successful in 4s
CI/CD Web + Desktop / Deploy (VPS Linux) (push) Successful in 2m54s
CI/CD Web + Desktop / Deploy Convex functions (push) Failing after 41s
Quality Checks / Lint, Test and Build (push) Has been cancelled

O agente envia o inventory dentro de metadata, não diretamente em args.inventory.
Agora o backend verifica ambos os lugares.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
rever-tecnologia 2025-12-18 09:49:08 -03:00
parent f39bd46c2b
commit db23ea1901

View file

@ -1018,10 +1018,27 @@ export const heartbeat = mutation({
}
}
const sanitizedInventory = sanitizeInventoryPayload(args.inventory)
// Extrair inventory de args.inventory ou de args.metadata.inventory (agente envia em metadata)
const rawInventory = args.inventory ?? (incomingMeta?.["inventory"] as Record<string, unknown> | undefined)
const sanitizedInventory = sanitizeInventoryPayload(rawInventory)
const currentInventory = ensureRecord(currentMetadata.inventory)
const incomingInventoryHash = hashJson(sanitizedInventory)
const currentInventoryHash = typeof currentMetadata["inventoryHash"] === "string" ? currentMetadata["inventoryHash"] : null
// DEBUG: log para verificar dados extended
if (sanitizedInventory?.["extended"]) {
console.log("[heartbeat] extended keys:", Object.keys(sanitizedInventory["extended"] as object))
const win = (sanitizedInventory["extended"] as Record<string, unknown>)?.["windows"] as Record<string, unknown> | undefined
if (win) {
console.log("[heartbeat] windows keys:", Object.keys(win))
if (win["bootInfo"]) {
console.log("[heartbeat] bootInfo:", JSON.stringify(win["bootInfo"]))
}
}
} else {
console.log("[heartbeat] no extended in sanitizedInventory, source:", args.inventory ? "args.inventory" : incomingMeta?.["inventory"] ? "metadata.inventory" : "none")
}
if (sanitizedInventory && incomingInventoryHash && incomingInventoryHash !== currentInventoryHash) {
metadataPatch.inventory = mergeInventory(currentInventory, sanitizedInventory)
metadataPatch.inventoryHash = incomingInventoryHash