import crypto from "crypto"; import { processMessage } from "../../2-identity/services/pipeline.js"; import { getTenantId } from "../../shared/tenant.js"; export async function handleSimSend(body) { const { chat_id, from_phone, text, location } = body || {}; if (!chat_id || !from_phone || (!text && !location)) { return { status: 400, payload: { ok: false, error: "chat_id, from_phone, and text or location are required" } }; } // Aceptar location share desde el simulator. Mismo formato que el parser de // Evolution: { lat, lng, label? }. const inboundLocation = location && typeof location.lat === "number" && typeof location.lng === "number" ? { lat: location.lat, lng: location.lng, label: location.label || null } : null; const provider = "sim"; const message_id = crypto.randomUUID(); const tenantId = getTenantId(); const result = await processMessage({ tenantId, chat_id, from: from_phone, text: text || "", inboundLocation, provider, message_id, }); return { status: 200, payload: { ok: true, run_id: result.run_id, reply: result.reply } }; }