From db23ea1901c61115ac869680ee694e0109be580f Mon Sep 17 00:00:00 2001 From: rever-tecnologia Date: Thu, 18 Dec 2025 09:49:08 -0300 Subject: [PATCH] fix(heartbeat): extrai inventory de metadata quando args.inventory vazio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- convex/machines.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/convex/machines.ts b/convex/machines.ts index 091eca1..cec2657 100644 --- a/convex/machines.ts +++ b/convex/machines.ts @@ -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 | 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)?.["windows"] as Record | 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