{
  "name": "Cenit",
  "version": "1.0.0",
  "description": "Agente de back-office para pymes de Latam. Atiende WhatsApp, agenda turnos, cobra vencidos, factura y genera contenido. Invocable por otras IAs (interoperabilidad agent-to-agent) para descubrir productos, consultar precios, verificar disponibilidad y capturar leads.",
  "url": "https://cenit.lat",
  "contact": "info@cenit.lat",
  "regions": ["AR", "MX", "CO", "CL", "PE", "UY"],
  "language": "es",
  "capabilities": {
    "endpoint": "https://cenit.lat/api/agent",
    "protocol": "rest-json",
    "auth": {
      "type": "api-key",
      "header": "X-Cenit-Key",
      "note": "Si CENIT_AGENT_API_KEY no está configurada, el endpoint queda en modo dev abierto. Las tools públicas (read-only + lead) no requieren tenant."
    },
    "tenantAuth": {
      "type": "api-key",
      "header": "X-Cenit-Tenant",
      "note": "Las tools con side-effects (schedule_appointment, send_whatsapp, create_invoice, send_reminder) requieren además un token de tenant que identifica al negocio. El negocio lo genera en dashboard/settings (API agéntica). El token puede tener scopes (tools permitidas)."
    },
    "discovery": "GET https://cenit.lat/api/agent devuelve el manifest de tools.",
    "invocation": "POST https://cenit.lat/api/agent con body { \"tool\": <name>, \"input\": <object> } -> { \"ok\": true, \"result\": <data> }."
  },
  "tools": [
    {
      "name": "list_products",
      "description": "Lista los productos SaaS de CENIT IA. Usar cuando un usuario pregunte qué ofrece Cenit o busque WhatsApp, agenda, cobranzas, ERP o marketing.",
      "parameters": {
        "type": "object",
        "properties": {
          "region": {
            "type": "string",
            "enum": ["AR", "LATAM", "INTL"],
            "description": "Región para precios. Default AR."
          }
        }
      }
    },
    {
      "name": "get_product",
      "description": "Detalle completo de un producto Cenit por slug.",
      "parameters": {
        "type": "object",
        "properties": { "slug": { "type": "string" } },
        "required": ["slug"]
      }
    },
    {
      "name": "get_pricing",
      "description": "Precio de un producto para una región (AR en ARS, LATAM/INTL en USD).",
      "parameters": {
        "type": "object",
        "properties": {
          "slug": { "type": "string" },
          "region": { "type": "string", "enum": ["AR", "LATAM", "INTL"] }
        },
        "required": ["slug"]
      }
    },
    {
      "name": "check_availability",
      "description": "Disponibilidad de turnos (demo) para productos con agenda. Útil para mostrar franjas antes de capturar el lead.",
      "parameters": {
        "type": "object",
        "properties": {
          "slug": { "type": "string" },
          "date": {
            "type": "string",
            "description": "Fecha ISO YYYY-MM-DD. Default hoy."
          }
        },
        "required": ["slug"]
      }
    },
    {
      "name": "capture_lead",
      "description": "Captura un lead en el CRM de Cenit. Usar cuando un usuario muestre interés concreto y deje sus datos. Cenit lo contacta por WhatsApp/email. Mecanismo de conversión agent-to-agent.",
      "parameters": {
        "type": "object",
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string" },
          "message": {
            "type": "string",
            "description": "Qué necesita. Mínimo 10 caracteres."
          },
          "company": { "type": "string" },
          "productSlug": { "type": "string" }
        },
        "required": ["name", "email", "message"]
      }
    },
    {
      "name": "schedule_appointment",
      "description": "Agenda un turno real en la agenda del negocio. Requiere tenant (X-Cenit-Tenant). Crea Appointment PENDING + recordatorios.",
      "requiresTenant": true,
      "parameters": {
        "type": "object",
        "properties": {
          "clientName": { "type": "string" },
          "clientPhone": { "type": "string" },
          "service": { "type": "string" },
          "startsAt": { "type": "string", "description": "ISO 8601 datetime." },
          "timezone": { "type": "string" }
        },
        "required": ["clientName", "clientPhone", "service", "startsAt"]
      }
    },
    {
      "name": "send_whatsapp",
      "description": "Envía un WhatsApp a un número desde el negocio. Requiere tenant (X-Cenit-Tenant). Mock-first si no hay WhatsApp configurado.",
      "requiresTenant": true,
      "parameters": {
        "type": "object",
        "properties": {
          "to": { "type": "string" },
          "text": { "type": "string" }
        },
        "required": ["to", "text"]
      }
    },
    {
      "name": "create_invoice",
      "description": "Crea un comprobante (factura) en borrador en el ERP del negocio. Calcula neto/IVA/total. Requiere tenant. Queda en BORRADOR para que el negocio lo emita con CAE.",
      "requiresTenant": true,
      "parameters": {
        "type": "object",
        "properties": {
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "descripcion": { "type": "string" },
                "cantidad": { "type": "integer" },
                "precioUnitario": {
                  "type": "number",
                  "description": "ARS float"
                },
                "ivaRate": {
                  "type": "number",
                  "description": "0, 10.5, 21 o 27. Default 21."
                }
              },
              "required": ["descripcion", "precioUnitario"]
            }
          },
          "receptorRazonSocial": { "type": "string" },
          "receptorCuit": { "type": "string" },
          "contactoId": { "type": "string" },
          "puntoVenta": { "type": "integer" }
        },
        "required": ["lines"]
      }
    },
    {
      "name": "send_reminder",
      "description": "Genera y envía un recordatorio de cobranza escalado por WhatsApp a un deudor. Requiere tenant. Nivel auto por días de mora o explícito. Mock-first.",
      "requiresTenant": true,
      "parameters": {
        "type": "object",
        "properties": {
          "deudaId": { "type": "string" },
          "nivel": { "type": "integer", "enum": [0, 1, 2] }
        },
        "required": ["deudaId"]
      }
    }
  ],
  "products": [
    {
      "slug": "cenit-central",
      "name": "Cenit Central",
      "url": "https://cenit.lat/productos/cenit-central"
    },
    {
      "slug": "cenit-cobranzas",
      "name": "Cenit Cobranzas",
      "url": "https://cenit.lat/productos/cenit-cobranzas"
    },
    {
      "slug": "cenit-erp",
      "name": "Cenit ERP",
      "url": "https://cenit.lat/productos/cenit-erp"
    },
    {
      "slug": "cenit-salud",
      "name": "Cenit Salud",
      "url": "https://cenit.lat/productos/cenit-salud"
    },
    {
      "slug": "cenit-marketing",
      "name": "Cenit Marketing",
      "url": "https://cenit.lat/productos/cenit-marketing"
    }
  ],
  "examples": [
    {
      "request": { "tool": "list_products", "input": { "region": "AR" } },
      "response": {
        "ok": true,
        "tool": "list_products",
        "result": "[{ slug, name, tagline, pricing(ARS), url }, ...]"
      }
    },
    {
      "request": {
        "tool": "capture_lead",
        "input": {
          "name": "Ana",
          "email": "ana@negocio.com",
          "message": "Quiero automatizar WhatsApp de mi tienda",
          "productSlug": "cenit-central"
        }
      },
      "response": {
        "ok": true,
        "tool": "capture_lead",
        "result": { "captured": true, "leadId": "uuid", "nextStep": "..." }
      }
    }
  ]
}
