mergeon-mcp 1.115.0 → 1.119.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -46
- package/dist/index.js +92 -49
- package/dist/index.js.map +1 -1
- package/dist/tools/advisory.d.ts +3 -0
- package/dist/tools/advisory.js +116 -0
- package/dist/tools/advisory.js.map +1 -0
- package/dist/tools/agents-registry.js +11 -3
- package/dist/tools/agents-registry.js.map +1 -1
- package/dist/tools/ai-tree.d.ts +187 -0
- package/dist/tools/ai-tree.js +112 -0
- package/dist/tools/ai-tree.js.map +1 -0
- package/dist/tools/audit.js +2 -1
- package/dist/tools/audit.js.map +1 -1
- package/dist/tools/ecommerce.js +12 -4
- package/dist/tools/ecommerce.js.map +1 -1
- package/dist/tools/forms.js +35 -1
- package/dist/tools/forms.js.map +1 -1
- package/dist/tools/guia.d.ts +2 -0
- package/dist/tools/guia.js +34 -0
- package/dist/tools/guia.js.map +1 -0
- package/dist/tools/index.js +6 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/plans.js +34 -8
- package/dist/tools/plans.js.map +1 -1
- package/dist/update.d.ts +6 -0
- package/dist/update.js +84 -0
- package/dist/update.js.map +1 -0
- package/dist/verticals.d.ts +1 -1
- package/dist/verticals.js +1 -1
- package/dist/verticals.js.map +1 -1
- package/package.json +1 -1
- package/skills/forms-creation.md +33 -0
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Y Claude usa el MCP para hacerlo directamente contra tu backend de MergeOn.
|
|
|
17
17
|
|
|
18
18
|
1. [¿Qué expone el MCP?](#qué-expone-el-mcp)
|
|
19
19
|
2. [Setup en Claude Desktop / Claude Code](#setup)
|
|
20
|
-
3. [Tools disponibles (
|
|
20
|
+
3. [Tools disponibles (363)](#tools-disponibles)
|
|
21
21
|
4. [Skills incluidos](#skills-incluidos)
|
|
22
22
|
5. [Variables de entorno](#variables-de-entorno)
|
|
23
23
|
6. [Desarrollo local](#desarrollo-local)
|
|
@@ -36,26 +36,13 @@ Cada tool es una función que Claude puede invocar. Internamente, el MCP autenti
|
|
|
36
36
|
|
|
37
37
|
> **Cross-tenant (`ecommerce_id` override):** todas las tools aceptan un parámetro opcional `ecommerce_id` para apuntar a otro tenant (ej. `agent_prompts_update({ wpp_prompt_text: "...", ecommerce_id: "57" })`). La key de ecommerce 1 (superadmin) puede apuntar a **cualquier** tenant; una key de **implementador** puede apuntar a los ecommerces que gestiona; cualquier otra key solo opera sobre el suyo. El backend (`authorize_ecommerce_target`) valida la propiedad y devuelve 403 si no aplica.
|
|
38
38
|
|
|
39
|
-
Las
|
|
39
|
+
Las 363 tools cubren los principales dominios de MergeOn: **CRM, pedidos, productos, conversaciones, flujos de automatización (con catálogo de triggers/conditions/actions descubrible y filtros por reel específico via `media_ids`), calendario, marketing masivo, analytics legacy, analítica de ventas (revenue, top productos, comparativas y filtros por canal), eventos a Meta CAPI (auditoría + reenvío), nurturing/hidratación de leads, formularios dinámicos con tracking codes + UTMs, videos sociales con auto-tracking y funnel de conversión, webhooks entrantes y salientes (incluido el relay de conversaciones a un agente externo), workers, reparto automático de contactos entre asesores con avisos dirigidos por WhatsApp, asesorías del plan que el propio cliente separa en el calendario de quien lo atiende, admin, configuración del agente IA (prompts + tools), business context (conocimiento dinámico para el agente), plantillas de WhatsApp avanzadas, **correo saliente** (desde qué dominio sale, plantillas y bajas), configuración general del ecommerce y el **registro de actividad** (quién cambió qué y cuándo, incluidos los borrados)**.
|
|
40
40
|
|
|
41
|
-
### B.
|
|
41
|
+
### B. Guías (ya vienen dentro)
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
Las guías de experto (escribir la IA, automatizaciones, seguimientos, plantillas, formularios, ventas…) se sirven desde el propio MCP con la tool `guia`. No hay que instalar nada ni tocar el `CLAUDE.md`: se actualizan solas con el paquete. Claude las lee antes de una tarea grande.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
- `prompt-creation` — experto en redactar el prompt del agente de ventas para WhatsApp/Instagram.
|
|
48
|
-
- `flows-creation` — experto en diseñar flows de automatización (post-venta, pautas, notificaciones, chatbots, flows por reel específico).
|
|
49
|
-
- `nurturing-creation` — experto en hidratación de leads (secuencias multi-touch por stage del CRM).
|
|
50
|
-
- `templates-creation` — experto en plantillas oficiales (HSM) avanzadas con headers media, botones, manual_placeholders.
|
|
51
|
-
- `forms-creation` — forms dinámicos en `mergeon.dev/form/{code}`: schema, tracking codes con UTMs, atribución a videos, auto-upsert CRM.
|
|
52
|
-
- `social-tracking` — tracking por reel/post: auto-discovery, funnel comments→DM→leads→órdenes, atribución de revenue por video.
|
|
53
|
-
- `webhooks-usage` — experto en integrar sistemas externos (forms, pasarelas, CRMs) con webhooks entrantes.
|
|
54
|
-
- `sales-analysis` — analista de ventas: cómo combinar `sales_*` para responder bien a "cómo voy".
|
|
55
|
-
- `meta-events-debug` — auditoría de Meta CAPI: por qué no aparece tal venta como Purchase en Events Manager.
|
|
56
|
-
- `reviews-usage` — subir reseñas/testimonios reales (incluidas tarjetas con foto) vía `media_upload` + `reviews_create`.
|
|
57
|
-
- `agent-testing` — QA del agente: simular clientes contra la IA en el sandbox y corregir el prompt con la evidencia.
|
|
58
|
-
- `agent-training` — entrenar la IA con los chats reales del negocio en ciclos que se repiten: fallas de producción, banco de casos que crece, regresión completa y salida controlada.
|
|
45
|
+
El instalador viejo (`npx -p mergeon-mcp mergeon-skills add all`) sigue existiendo para quien quiera tenerlas en su `CLAUDE.md`, pero ya no hace falta.
|
|
59
46
|
|
|
60
47
|
---
|
|
61
48
|
|
|
@@ -79,7 +66,7 @@ Edita `claude_desktop_config.json`:
|
|
|
79
66
|
"mcpServers": {
|
|
80
67
|
"mergeon": {
|
|
81
68
|
"command": "npx",
|
|
82
|
-
"args": ["-y", "mergeon-mcp"],
|
|
69
|
+
"args": ["-y", "mergeon-mcp@latest"],
|
|
83
70
|
"env": {
|
|
84
71
|
"MERGEON_API_KEY": "mk_tu_api_key_aqui"
|
|
85
72
|
}
|
|
@@ -88,49 +75,29 @@ Edita `claude_desktop_config.json`:
|
|
|
88
75
|
}
|
|
89
76
|
```
|
|
90
77
|
|
|
91
|
-
Reinicia Claude Desktop.
|
|
78
|
+
Reinicia Claude Desktop.
|
|
92
79
|
|
|
93
80
|
#### Claude Code
|
|
94
81
|
|
|
95
|
-
Añade el server con el comando:
|
|
96
|
-
|
|
97
82
|
```bash
|
|
98
|
-
claude mcp add mergeon -- npx -y mergeon-mcp
|
|
83
|
+
claude mcp add mergeon -e MERGEON_API_KEY=mk_tu_api_key -- npx -y mergeon-mcp@latest
|
|
99
84
|
```
|
|
100
85
|
|
|
101
86
|
#### Otros clientes (Cursor, Continue, Zed)
|
|
102
87
|
|
|
103
|
-
Cualquier cliente compatible con MCP-stdio funciona
|
|
104
|
-
|
|
105
|
-
### 3. (Recomendado) Instala los skills
|
|
106
|
-
|
|
107
|
-
Lo más simple es instalarlos todos de una vez:
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
cd /ruta/a/tu/proyecto
|
|
111
|
-
npx mergeon-mcp skills add all
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
O uno por uno si prefieres:
|
|
88
|
+
Cualquier cliente compatible con MCP-stdio funciona: comando `npx -y mergeon-mcp@latest` y `MERGEON_API_KEY` como variable de entorno.
|
|
115
89
|
|
|
116
|
-
|
|
117
|
-
npx mergeon-mcp skills add prompt-creation
|
|
118
|
-
npx mergeon-mcp skills add flows-creation
|
|
119
|
-
```
|
|
90
|
+
### 3. Actualizaciones: automáticas
|
|
120
91
|
|
|
121
|
-
|
|
92
|
+
Al arrancar, el MCP mira si npm tiene una versión más nueva. Si la hay, la descarga y la usa ese mismo arranque; basta con reiniciar Claude para tener lo último. Sin internet o si la descarga falla, sigue con la que tiene. Se apaga con `MERGEON_MCP_NO_UPDATE=1`, y nunca corre desde una copia de desarrollo (la que tiene `src/`).
|
|
122
93
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
npx mergeon-mcp skills list
|
|
127
|
-
```
|
|
94
|
+
Con una llave de cliente, las tools exclusivas de MergeOn (las de superadmin) no se muestran.
|
|
128
95
|
|
|
129
96
|
---
|
|
130
97
|
|
|
131
98
|
## Tools disponibles
|
|
132
99
|
|
|
133
|
-
|
|
100
|
+
363 tools organizadas en 43 dominios. Cada nombre corresponde a la cadena exacta que verás en Claude Desktop.
|
|
134
101
|
|
|
135
102
|
> 💡 Los dominios marcados con **(catálogo descubrible)** exponen un tool `<dominio>_get_catalog` que devuelve los enums, shapes y reglas válidas. Llámalo SIEMPRE antes de crear/modificar para no inventar campos.
|
|
136
103
|
|
|
@@ -420,6 +387,21 @@ Para integrar y debuggear, instala el skill `webhooks-usage`.
|
|
|
420
387
|
|
|
421
388
|
> Reparto y avisos son **configuración + flows**, no lógica fija: `assign_advisor` y `notify_advisor` sirven en cualquier flow (`sold`, `lead_status_change`, `query_created`, `human_attention`…), y la config solo aplica cuando el negocio no tiene flows de ese trigger.
|
|
422
389
|
|
|
390
|
+
### Asesorías del plan (6 tools)
|
|
391
|
+
|
|
392
|
+
Las sesiones de acompañamiento que un plan incluye y que el **cliente separa él mismo** desde su panel. Dos lados en el mismo dominio, y conviene no confundirlos: el cupo lo gasta el negocio que PIDE, la cita vive en el calendario del que ATIENDE (su implementador si lo tiene, el soporte directo de MergeOn si no).
|
|
393
|
+
|
|
394
|
+
| Tool | Qué hace |
|
|
395
|
+
|---|---|
|
|
396
|
+
| `advisory_panel_get` | Lo que ve el cliente: cupo del mes, cuántas quedan, quién lo atiende, días agendables y lo que ya pidió. Cuando no puede agendar, `blocked_reason` dice por qué (`unpaid`, `no_plan`, `plan_sin_cupo`, `cupo_agotado`, `sin_soporte`) — cada motivo se arregla distinto. |
|
|
397
|
+
| `advisory_slots` | Horas libres de un día, ya cruzadas contra el Google Calendar de quien atiende. Vacío = ese día está lleno o el negocio no puede agendar. |
|
|
398
|
+
| `advisory_book` | Separa una asesoría: gasta un cupo del mes y crea la cita con enlace de Meet en la agenda de quien atiende. `topic` es obligatorio a propósito. |
|
|
399
|
+
| `advisory_cancel` | La suelta y **devuelve el cupo**. Solo antes de que empiece. |
|
|
400
|
+
| `advisory_support_get` / `advisory_support_set` | El reparto del negocio que ATIENDE: quién entra, con qué cupo relativo, horario y límites. El reparto reparte **clientes, no sesiones**: al primero que abre su panel se le asigna un dueño y se queda, para que su segunda asesoría la atienda el mismo. `members` vacío = nadie puede agendar, y el panel del cliente lo dice. |
|
|
401
|
+
| `advisory_agenda` / `advisory_agenda_set_status` | Lo que este negocio tiene que atender, y marcar qué pasó. `no_show` **no** devuelve el cupo: el cliente reservó media hora del equipo y no llegó. |
|
|
402
|
+
|
|
403
|
+
> El cupo sale del plan **pagado**, no del asignado: en MergeOn se le pone el plan al negocio para que lo pague después, así que lo decide `ecommerce.paid`. La prueba gratuita no da asesorías. El cupo vive en `plans.advisory_sessions_per_month` (columna, no `metadata`: desde que decide un permiso dejó de ser algo que solo se muestra).
|
|
404
|
+
|
|
423
405
|
### Custom Tools (6 tools)
|
|
424
406
|
| Tool | Qué hace |
|
|
425
407
|
|---|---|
|
package/dist/index.js
CHANGED
|
@@ -4,74 +4,117 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { MergeOnClient } from "./client.js";
|
|
6
6
|
import { registerAllTools } from "./tools/index.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
import { ownVersion, runLatestIfNewer } from "./update.js";
|
|
8
|
+
if (process.argv.includes("--version")) {
|
|
9
|
+
console.log(ownVersion());
|
|
10
|
+
process.exit(0);
|
|
11
|
+
}
|
|
12
|
+
// Quien instala el MCP casi nunca es técnico. Estas instrucciones mandan sobre
|
|
13
|
+
// CÓMO habla el modelo; el método detallado de cada tarea vive en las guías
|
|
14
|
+
// (tool `guia`), que viajan con el paquete y se actualizan con él.
|
|
15
|
+
const MERGEON_INSTRUCTIONS = `Hablas con el dueño o el equipo de un negocio que usa MergeOn. Casi nunca es técnico.
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
17
|
+
Cómo hablar:
|
|
18
|
+
- Corto y en sus palabras: dos o tres frases, salvo que pida detalle.
|
|
19
|
+
- Nunca menciones nombres de herramientas, campos, IDs, JSON, códigos de error ni palabras como trigger, payload, endpoint, webhook, CAPI, HSM, tenant o prompt. Habla de su negocio: "la respuesta automática", "el mensaje de bienvenida", "la plantilla", "el seguimiento a los que no compraron", "lo que sabe la IA".
|
|
20
|
+
- Traduce siempre, así:
|
|
21
|
+
· ecommerce, ecommerce_id, tenant → "tu negocio" (nunca digas el número)
|
|
22
|
+
· CAPI, eventos de conversión, Purchase, dataset, píxel → "mandarle las ventas a Meta"
|
|
23
|
+
· WABA, phone_number_id → "tu WhatsApp" ("Business Manager" sí se puede decir, el usuario lo conoce)
|
|
24
|
+
· flow, trigger, action → "automatización", "cuando pase X, se hace Y"
|
|
25
|
+
· nurturing, hidratación, drip → "seguimiento"
|
|
26
|
+
· HSM, template → "plantilla"
|
|
27
|
+
· prompt, business context → "las instrucciones de la IA", "lo que sabe la IA"
|
|
28
|
+
· lead, lead_status, stage → "cliente", "etapa del cliente"
|
|
29
|
+
· webhook, API, token → "la conexión con tu otro sistema"
|
|
30
|
+
- No expliques cómo funciona por dentro. Di qué hiciste y qué cambia para él.
|
|
31
|
+
- Si algo falla, dilo en una frase con lo que se puede hacer. No pegues el error.
|
|
21
32
|
|
|
22
|
-
|
|
33
|
+
Cómo trabajar:
|
|
34
|
+
- Cuando pida algo, hazlo. Si falta un dato del negocio (precio, mensaje, horario, tono), pregúntalo todo junto en UNA sola pregunta.
|
|
35
|
+
- Antes de algo que le escribe a sus clientes o que no se deshace (envíos masivos, borrar, cambiar lo que responde la IA), confirma en una línea.
|
|
36
|
+
- Al terminar: una frase con lo que quedó listo y, si aplica, el siguiente paso sugerido.
|
|
37
|
+
- Para tareas grandes (escribir o entrenar la IA, automatizaciones, seguimientos, plantillas, formularios, análisis de ventas) lee primero la guía del tema con la herramienta guia. Sigue su método, pero no se lo recites al usuario.`;
|
|
38
|
+
// Exclusivas de MergeOn (key del ecommerce 1). A cualquier otra llave le
|
|
39
|
+
// devuelven 403, así que mostrarlas solo suma ruido y tokens.
|
|
40
|
+
const SUPERADMIN_ONLY = new Set([
|
|
41
|
+
"admin_ecommerce_tags_set",
|
|
42
|
+
"admin_ecommerce_hide",
|
|
43
|
+
"admin_whatsapp_link",
|
|
44
|
+
"admin_payouts_mark_paid",
|
|
45
|
+
"admin_subscriptions_list",
|
|
46
|
+
"admin_prompts_get",
|
|
47
|
+
"admin_prompts_update",
|
|
48
|
+
"admin_ecommerce_set_trial",
|
|
49
|
+
"admin_ecommerce_update",
|
|
50
|
+
"admin_subscription_get",
|
|
51
|
+
"admin_subscription_create",
|
|
52
|
+
"admin_subscription_update",
|
|
53
|
+
"admin_ecommerce_set_implementer",
|
|
54
|
+
"admin_billing_fx_set",
|
|
55
|
+
]);
|
|
56
|
+
const client = new MergeOnClient();
|
|
23
57
|
const server = new McpServer({
|
|
24
58
|
name: "mergeon",
|
|
25
|
-
version:
|
|
59
|
+
version: ownVersion(),
|
|
26
60
|
}, { instructions: MERGEON_INSTRUCTIONS });
|
|
27
61
|
// ── Superadmin cross-tenant override ─────────────────────────────────────────
|
|
28
62
|
// Inyecta un parámetro `ecommerce_id` opcional en TODAS las tools y lo enruta al
|
|
29
63
|
// header del client (no al body/query: se quita de los args antes del handler).
|
|
30
|
-
// Solo es efectivo con una key de ecommerce 1 (superadmin)
|
|
31
|
-
//
|
|
32
|
-
//
|
|
64
|
+
// Solo es efectivo con una key de ecommerce 1 (superadmin) o de un implementador
|
|
65
|
+
// sobre sus negocios: el backend (enforce_ecommerce_access) devuelve 403 al resto.
|
|
66
|
+
// Asume ejecución secuencial de tools (MCP stdio).
|
|
33
67
|
const ecommerceIdShape = {
|
|
34
68
|
ecommerce_id: z
|
|
35
69
|
.string()
|
|
36
70
|
.optional()
|
|
37
|
-
.describe("
|
|
71
|
+
.describe("Solo para partners y MergeOn: id del negocio sobre el que actuar. Déjalo vacío para el negocio propio."),
|
|
38
72
|
};
|
|
39
|
-
|
|
40
|
-
server.tool
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
let schemaIdx = -1;
|
|
49
|
-
for (let i = head.length - 1; i >= 0; i--) {
|
|
50
|
-
if (head[i] && typeof head[i] === "object" && !Array.isArray(head[i])) {
|
|
51
|
-
schemaIdx = i;
|
|
52
|
-
break;
|
|
73
|
+
function patchToolRegistration(isSuperadmin) {
|
|
74
|
+
const originalTool = server.tool.bind(server);
|
|
75
|
+
server.tool = (name, ...rest) => {
|
|
76
|
+
if (!isSuperadmin && SUPERADMIN_ONLY.has(name))
|
|
77
|
+
return undefined;
|
|
78
|
+
const handler = rest[rest.length - 1];
|
|
79
|
+
if (typeof handler !== "function") {
|
|
80
|
+
// Forma inesperada: registrar sin tocar.
|
|
81
|
+
return originalTool(name, ...rest);
|
|
53
82
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
83
|
+
const head = rest.slice(0, -1); // [description?, schema?]
|
|
84
|
+
// schema = último objeto plano (ZodRawShape) en head; puede no existir.
|
|
85
|
+
let schemaIdx = -1;
|
|
86
|
+
for (let i = head.length - 1; i >= 0; i--) {
|
|
87
|
+
if (head[i] && typeof head[i] === "object" && !Array.isArray(head[i])) {
|
|
88
|
+
schemaIdx = i;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
60
91
|
}
|
|
61
|
-
|
|
62
|
-
|
|
92
|
+
const wrappedHandler = async (args, extra) => {
|
|
93
|
+
const { ecommerce_id, ...toolArgs } = args ?? {};
|
|
94
|
+
client.setEcommerceOverride(ecommerce_id);
|
|
95
|
+
try {
|
|
96
|
+
return await handler(toolArgs, extra);
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
client.setEcommerceOverride(undefined);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (schemaIdx >= 0) {
|
|
103
|
+
head[schemaIdx] = { ...head[schemaIdx], ...ecommerceIdShape };
|
|
104
|
+
return originalTool(name, ...head, wrappedHandler);
|
|
63
105
|
}
|
|
106
|
+
// Sin schema declarado → añadimos uno con solo ecommerce_id.
|
|
107
|
+
return originalTool(name, ...head, ecommerceIdShape, wrappedHandler);
|
|
64
108
|
};
|
|
65
|
-
|
|
66
|
-
head[schemaIdx] = { ...head[schemaIdx], ...ecommerceIdShape };
|
|
67
|
-
return originalTool(name, ...head, wrappedHandler);
|
|
68
|
-
}
|
|
69
|
-
// Sin schema declarado → añadimos uno con solo ecommerce_id.
|
|
70
|
-
return originalTool(name, ...head, ecommerceIdShape, wrappedHandler);
|
|
71
|
-
};
|
|
72
|
-
registerAllTools(server, client);
|
|
109
|
+
}
|
|
73
110
|
async function main() {
|
|
111
|
+
// Si npm tiene una versión más nueva, corre esa y esta se queda de puente.
|
|
112
|
+
if (await runLatestIfNewer())
|
|
113
|
+
return;
|
|
114
|
+
// Se identifica la llave ANTES de registrar: así se sabe qué tools mostrar.
|
|
74
115
|
await client.initialize();
|
|
116
|
+
patchToolRegistration(client.getEcommerceId() === "1");
|
|
117
|
+
registerAllTools(server, client);
|
|
75
118
|
const transport = new StdioServerTransport();
|
|
76
119
|
await server.connect(transport);
|
|
77
120
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;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AAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
function text(data) {
|
|
3
|
+
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
4
|
+
}
|
|
5
|
+
// Asesorías del plan: las sesiones de acompañamiento que un negocio incluye en
|
|
6
|
+
// su plan y que su administrador separa él mismo desde el panel.
|
|
7
|
+
//
|
|
8
|
+
// Dos cosas que hay que tener claras para no leer mal estas tools:
|
|
9
|
+
//
|
|
10
|
+
// 1. El cupo sale del plan PAGADO. En MergeOn se le asigna el plan al negocio
|
|
11
|
+
// para que lo pague después, así que tener plan no es tener servicio: lo
|
|
12
|
+
// decide `ecommerce.paid`. La prueba gratuita no da asesorías.
|
|
13
|
+
// 2. El negocio que PIDE y el que ATIENDE son distintos. El cupo lo gasta el
|
|
14
|
+
// cliente; la cita vive en el calendario de su implementador (si lo tiene) o
|
|
15
|
+
// del soporte directo de MergeOn. `/panel` es la vista del que pide,
|
|
16
|
+
// `/support` y `/agenda` la del que atiende.
|
|
17
|
+
export function registerAdvisoryTools(server, client) {
|
|
18
|
+
server.tool("advisory_panel_get", "Get this business's plan advisory sessions: how many 30-minute sessions its plan includes this month, how many are left, who will attend them (their implementer if they have one, otherwise someone from MergeOn support), which days are open for booking, and every session already requested. When it can't book, 'blocked_reason' says why — 'unpaid' (plan assigned but not paid), 'no_plan', 'plan_sin_cupo' (plan includes none), 'cupo_agotado' (used them all this month) or 'sin_soporte' (nobody set up to attend). Read this before offering to book anything: each reason is fixed a different way.", {}, async () => text(await client.get("/advisory/panel")));
|
|
19
|
+
server.tool("advisory_slots", "List the free times for one day, already crossed against the Google Calendar of whoever attends this business. Returns an empty list when the business can't book (check advisory_panel_get first to know why) or when that day is full. Times are in the attending team's timezone, not the caller's.", {
|
|
20
|
+
date: z.string().describe("YYYY-MM-DD in the attending team's timezone"),
|
|
21
|
+
}, async ({ date }) => text(await client.get(`/advisory/slots?date=${encodeURIComponent(date)}`)));
|
|
22
|
+
server.tool("advisory_book", "Book one of the plan's advisory sessions. Spends one from this month's quota and creates the appointment in the calendar of whoever attends, with a Google Meet link. 'topic' is required on purpose: half an hour that starts with 'tell me what you need' is worth half, so write what the business actually wants to solve. Fails with a reason in the error when the quota is gone, the plan isn't paid, or someone else took that time while you were asking.", {
|
|
23
|
+
date: z.string().describe("YYYY-MM-DD, must be one of panel.open_dates"),
|
|
24
|
+
time: z.string().describe("HH:MM, must be one returned by advisory_slots for that date"),
|
|
25
|
+
topic: z
|
|
26
|
+
.string()
|
|
27
|
+
.min(3)
|
|
28
|
+
.max(1000)
|
|
29
|
+
.describe("What the business wants to solve. Concrete beats polite: 'the agent isn't offering sizes' over 'need help'"),
|
|
30
|
+
}, async (args) => text(await client.post("/advisory/book", args)));
|
|
31
|
+
server.tool("advisory_cancel", "Cancel a scheduled advisory session and give the month's quota back to the business. Only works before it starts; one that already began or was attended can't be cancelled. Deletes the appointment from the attending team's calendar too.", {
|
|
32
|
+
session_id: z.number().int().describe("Session id from advisory_panel_get"),
|
|
33
|
+
reason: z.string().max(500).optional().describe("Why it's being cancelled. Shows in the record"),
|
|
34
|
+
}, async ({ session_id, reason }) => text(await client.post(`/advisory/${session_id}/cancel`, { reason: reason ?? null })));
|
|
35
|
+
// ── Lado de quien atiende ────────────────────────────────────────────
|
|
36
|
+
server.tool("advisory_support_get", "Get how THIS business attends the advisory sessions of its clients: whether it's on, who is in the rotation with their relative share, the weekly schedule, and the booking limits. Only meaningful for MergeOn (ecommerce 1) and for implementers — any other business gets an empty config, which is the truth: it attends nobody. Read this before changing the rotation so you don't wipe somebody's share.", {}, async () => text(await client.get("/advisory/support")));
|
|
37
|
+
server.tool("advisory_support_set", `Set who attends the advisory sessions of this business's clients, and when. Sends the FULL config, so call advisory_support_get first — anyone left out of 'members' stops receiving new clients.
|
|
38
|
+
|
|
39
|
+
The rotation distributes CLIENTS, not sessions: the first time an eligible client opens its panel it gets an owner and keeps it, so its second session is attended by the same person who took the first. Weights are RELATIVE (2/1/1 means the first gets half the new clients, not that it gets two).
|
|
40
|
+
|
|
41
|
+
Who is in the rotation is an explicit list and not a rule by role, on purpose: "every advisor" would also pull in test users and anyone created tomorrow for a trial. An empty 'members' list means nobody can book, and the client's panel says so instead of silently assigning someone nobody chose.`, {
|
|
42
|
+
enabled: z.boolean().describe("false = clients still see their quota but can't book"),
|
|
43
|
+
members: z
|
|
44
|
+
.array(z.object({
|
|
45
|
+
worker_id: z.number().int().describe("Worker of THIS business. One from another business is rejected"),
|
|
46
|
+
weight: z
|
|
47
|
+
.number()
|
|
48
|
+
.int()
|
|
49
|
+
.min(1)
|
|
50
|
+
.max(100)
|
|
51
|
+
.optional()
|
|
52
|
+
.default(1)
|
|
53
|
+
.describe("Relative share of new clients. Not a cap"),
|
|
54
|
+
is_active: z
|
|
55
|
+
.boolean()
|
|
56
|
+
.optional()
|
|
57
|
+
.default(true)
|
|
58
|
+
.describe("false = stops receiving NEW clients but keeps the ones already assigned"),
|
|
59
|
+
}))
|
|
60
|
+
.describe("The rotation. Empty = nobody attends and no client can book"),
|
|
61
|
+
timezone: z.string().optional().default("America/Bogota"),
|
|
62
|
+
duration_minutes: z
|
|
63
|
+
.number()
|
|
64
|
+
.int()
|
|
65
|
+
.min(5)
|
|
66
|
+
.max(240)
|
|
67
|
+
.optional()
|
|
68
|
+
.default(30)
|
|
69
|
+
.describe("Default length. The client's plan overrides it when the plan defines one"),
|
|
70
|
+
weekly_hours: z
|
|
71
|
+
.record(z.array(z.array(z.string())))
|
|
72
|
+
.optional()
|
|
73
|
+
.describe('Schedule: {"1": [["09:00","12:00"],["14:00","18:00"]]} with 1=Monday … 7=Sunday. No schedule = no slots at all'),
|
|
74
|
+
date_overrides: z
|
|
75
|
+
.record(z.array(z.array(z.string())))
|
|
76
|
+
.optional()
|
|
77
|
+
.describe('Per-date exceptions: {"2027-12-25": []} closes that day'),
|
|
78
|
+
min_notice_minutes: z
|
|
79
|
+
.number()
|
|
80
|
+
.int()
|
|
81
|
+
.min(0)
|
|
82
|
+
.optional()
|
|
83
|
+
.default(240)
|
|
84
|
+
.describe("Minimum notice. 240 = can't book for less than 4 hours from now"),
|
|
85
|
+
max_days_ahead: z.number().int().min(1).max(365).optional().default(30),
|
|
86
|
+
slot_step_minutes: z
|
|
87
|
+
.number()
|
|
88
|
+
.int()
|
|
89
|
+
.min(5)
|
|
90
|
+
.max(240)
|
|
91
|
+
.optional()
|
|
92
|
+
.describe("How often a slot starts. Omit for back-to-back"),
|
|
93
|
+
max_per_day: z
|
|
94
|
+
.number()
|
|
95
|
+
.int()
|
|
96
|
+
.min(0)
|
|
97
|
+
.optional()
|
|
98
|
+
.default(0)
|
|
99
|
+
.describe("Cap per day PER PERSON in the rotation. 0 = no cap"),
|
|
100
|
+
}, async (args) => text(await client.put("/advisory/support", args)));
|
|
101
|
+
server.tool("advisory_agenda", "List the advisory sessions this business has to attend, its clients' ones. Includes the last few days backwards because the open question isn't only what's coming but what happened with Tuesday's: one that already passed still needs someone to mark it. Returns the client's ecommerce_id, who it was assigned to, the topic and the status.", {
|
|
102
|
+
days_back: z
|
|
103
|
+
.number()
|
|
104
|
+
.int()
|
|
105
|
+
.min(0)
|
|
106
|
+
.max(180)
|
|
107
|
+
.optional()
|
|
108
|
+
.default(7)
|
|
109
|
+
.describe("How many days backwards to include"),
|
|
110
|
+
}, async ({ days_back }) => text(await client.get(`/advisory/agenda?days_back=${days_back ?? 7}`)));
|
|
111
|
+
server.tool("advisory_agenda_set_status", "Mark what happened with an advisory session you attend. 'no_show' does NOT give the quota back — the client reserved half an hour of the team and didn't show up. 'completed' doesn't either. 'scheduled' exists to undo a wrong click. To give the quota back, the client has to cancel before it starts (advisory_cancel).", {
|
|
112
|
+
session_id: z.number().int().describe("Session id from advisory_agenda"),
|
|
113
|
+
status: z.enum(["completed", "no_show", "scheduled"]),
|
|
114
|
+
}, async ({ session_id, status }) => text(await client.post(`/advisory/agenda/${session_id}/status?status=${status}`, {})));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=advisory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"advisory.js","sourceRoot":"","sources":["../../src/tools/advisory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,SAAS,IAAI,CAAC,IAAS;IACrB,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACvF,CAAC;AAED,+EAA+E;AAC/E,iEAAiE;AACjE,EAAE;AACF,mEAAmE;AACnE,EAAE;AACF,8EAA8E;AAC9E,4EAA4E;AAC5E,kEAAkE;AAClE,6EAA6E;AAC7E,gFAAgF;AAChF,wEAAwE;AACxE,gDAAgD;AAChD,MAAM,UAAU,qBAAqB,CAAC,MAAiB,EAAE,MAAqB;IAC5E,MAAM,CAAC,IAAI,CACT,oBAAoB,EACpB,mlBAAmlB,EACnlB,EAAE,EACF,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CACtD,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,gBAAgB,EAChB,wSAAwS,EACxS;QACE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;KACzE,EACD,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,wBAAwB,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CA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,CAChG,CAAC;IAEF,MAAM,CAAC,IAAI,CACT,4BAA4B,EAC5B,8TAA8T,EAC9T;QACE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,iCAAiC,CAAC;QACxE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;KACtD,EACD,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,CAC/B,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,oBAAoB,UAAU,kBAAkB,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CACxF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
import { AiTreeSchema } from "./ai-tree.js";
|
|
2
3
|
function text(data) {
|
|
3
4
|
return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] };
|
|
4
5
|
}
|
|
@@ -45,10 +46,15 @@ export function registerAgentsRegistryTools(server, client) {
|
|
|
45
46
|
server.tool("agents_get", "Get one agent by id, including its full prompt_text and the usages it serves.", {
|
|
46
47
|
agent_id: z.number().describe("Agent id (see agents_list)"),
|
|
47
48
|
}, async ({ agent_id }) => text(await client.get(`/ai-agents/${agent_id}`)));
|
|
48
|
-
server.tool("agents_create", "Create a new AI agent
|
|
49
|
-
name: z.string().min(1).max(120).describe("Agent name, e.g. 'Vendedor principal' or '
|
|
50
|
-
prompt_text: z.string().describe("The agent's system prompt"),
|
|
49
|
+
server.tool("agents_create", "Create a new AI agent, of one of two kinds. `kind: 'generative'` (the default, what agents have always been) is a named prompt: the AI writes its own answers. `kind: 'faq'` is a bot ON RAILS: instead of a prompt it carries `tree`, and the AI's only job is to pick which of YOUR written replies applies — it cannot invent a price, change the tone or leak an internal note. Either kind can be plugged into one or more usages. Pass `usages` to put it to work immediately (a usage only has one agent — assigning it here takes it away from whoever had it). Use agents_usages_get first to see what is available and who serves what.", {
|
|
50
|
+
name: z.string().min(1).max(120).describe("Agent name, e.g. 'Vendedor principal' or 'Preguntas frecuentes'"),
|
|
51
|
+
prompt_text: z.string().describe("The agent's system prompt. Leave empty for a 'faq' agent — its brain is the tree"),
|
|
51
52
|
description: z.string().max(500).optional().describe("Short note on what this agent is for"),
|
|
53
|
+
kind: z
|
|
54
|
+
.enum(["generative", "faq"])
|
|
55
|
+
.optional()
|
|
56
|
+
.describe("'faq' = on rails: the AI only picks a branch and never writes. Use it when the business says 'I don't want the AI making things up' or 'it should only answer what I write'"),
|
|
57
|
+
tree: AiTreeSchema.optional().describe("Required for kind 'faq'. Validate it with ai_tree_validate and check it with ai_tree_dry_run BEFORE creating the agent"),
|
|
52
58
|
usages: z.array(UsageEnum).optional().describe("Usages this agent should serve right away"),
|
|
53
59
|
is_active: z.boolean().optional().describe("Inactive agents keep their prompt but stop answering (default true)"),
|
|
54
60
|
}, async (params) => text(await client.post("/ai-agents", params)));
|
|
@@ -57,6 +63,8 @@ export function registerAgentsRegistryTools(server, client) {
|
|
|
57
63
|
name: z.string().min(1).max(120).optional().describe("New name"),
|
|
58
64
|
prompt_text: z.string().optional().describe("New system prompt"),
|
|
59
65
|
description: z.string().max(500).optional().describe("New description"),
|
|
66
|
+
kind: z.enum(["generative", "faq"]).optional().describe("Switch the agent between a written prompt and a rails tree"),
|
|
67
|
+
tree: AiTreeSchema.optional().describe("New tree for a 'faq' agent. REPLACES the whole tree — read the current one with agents_get first, or you will drop branches the business wrote"),
|
|
60
68
|
usages: z.array(UsageEnum).optional().describe("Full replacement set of usages this agent serves"),
|
|
61
69
|
is_active: z.boolean().optional().describe("Enable or disable the agent"),
|
|
62
70
|
}, async ({ agent_id, ...body }) => text(await client.patch(`/ai-agents/${agent_id}`, body)));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents-registry.js","sourceRoot":"","sources":["../../src/tools/agents-registry.ts"],"names":[],"mappings":"A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