plazbot-cli 0.2.3 → 0.2.5

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.
@@ -5,6 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runAgentWizard = runAgentWizard;
7
7
  const inquirer_1 = __importDefault(require("inquirer"));
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const axios_1 = __importDefault(require("axios"));
10
+ const ora_1 = __importDefault(require("ora"));
8
11
  const ui_1 = require("../../utils/ui");
9
12
  const MODELS = {
10
13
  openai: ['gpt-4o', 'gpt-4', 'gpt-3.5-turbo', 'o1-preview', 'o1-mini'],
@@ -12,7 +15,157 @@ const MODELS = {
12
15
  gemini: ['gemini-2.0-flash', 'gemini-1.5-pro', 'gemini-1.5-flash'],
13
16
  };
14
17
  const COLORS = ['blue', 'green', 'orange', 'gray', 'white'];
15
- async function runAgentWizard(zone) {
18
+ function getBaseUrl(zone, dev) {
19
+ if (dev)
20
+ return 'http://localhost:5090';
21
+ return zone === 'EU' ? 'https://apieu.plazbot.com' : 'https://api.plazbot.com';
22
+ }
23
+ const CHANNEL_CHOICES = [
24
+ { name: 'WhatsApp', value: 'whatsapp' },
25
+ { name: 'WhatsApp Business', value: 'whatsapp_business' },
26
+ { name: 'Instagram', value: 'instagram' },
27
+ { name: 'Messenger', value: 'facebook' },
28
+ ];
29
+ const CHANNEL_AGENT_MAP = {
30
+ whatsapp: 'whatsapp',
31
+ whatsapp_business: 'whatsapp',
32
+ instagram: 'instagram',
33
+ facebook: 'facebook',
34
+ };
35
+ async function connectChannelFlow(ctx) {
36
+ const channels = [];
37
+ const baseUrl = getBaseUrl(ctx.zone, ctx.dev);
38
+ const headers = {
39
+ 'Authorization': `Bearer ${ctx.apiKey}`,
40
+ 'x-workspace-id': ctx.workspaceId,
41
+ 'Content-Type': 'application/json',
42
+ };
43
+ let addMore = true;
44
+ while (addMore) {
45
+ const { channelType } = await inquirer_1.default.prompt([{
46
+ type: 'list',
47
+ name: 'channelType',
48
+ message: 'Que canal deseas conectar?',
49
+ choices: CHANNEL_CHOICES,
50
+ }]);
51
+ const channelLabel = CHANNEL_CHOICES.find(c => c.value === channelType)?.name || channelType;
52
+ // Generar link de onboarding
53
+ const spinner = (0, ora_1.default)({ text: chalk_1.default.gray('Generando link de conexion...'), spinner: 'dots', color: 'green' }).start();
54
+ try {
55
+ const linkRes = await axios_1.default.post(`${baseUrl}/api/workspace/${ctx.workspaceId}/onboarding-link`, { type: channelType }, { headers });
56
+ if (!linkRes.data?.success) {
57
+ spinner.fail(chalk_1.default.hex('#EF5350')(`Error: ${linkRes.data?.message || 'No se pudo generar el link'}`));
58
+ const { tryManual } = await inquirer_1.default.prompt([{
59
+ type: 'confirm', name: 'tryManual',
60
+ message: 'Deseas ingresar el numero manualmente?', default: false,
61
+ }]);
62
+ if (tryManual) {
63
+ const { key } = await inquirer_1.default.prompt([
64
+ { type: 'input', name: 'key', message: `ID/numero del canal ${channelLabel}:`, validate: (v) => v.length > 0 || 'Requerido' },
65
+ ]);
66
+ channels.push({ channel: CHANNEL_AGENT_MAP[channelType], key, multianswer: false });
67
+ }
68
+ const { more } = await inquirer_1.default.prompt([{ type: 'confirm', name: 'more', message: 'Conectar otro canal?', default: false }]);
69
+ addMore = more;
70
+ continue;
71
+ }
72
+ const shortUrl = linkRes.data.data?.shortUrl || '';
73
+ spinner.stop();
74
+ // Mostrar link en box visual
75
+ console.log();
76
+ console.log(chalk_1.default.hex('#4CAF50')(' ┌' + '─'.repeat(64) + '┐'));
77
+ console.log(chalk_1.default.hex('#4CAF50')(' │') + chalk_1.default.bold(` Envia este link para conectar ${channelLabel}:`).padEnd(74) + chalk_1.default.hex('#4CAF50')('│'));
78
+ console.log(chalk_1.default.hex('#4CAF50')(' │') + ' '.padEnd(64) + chalk_1.default.hex('#4CAF50')('│'));
79
+ console.log(chalk_1.default.hex('#4CAF50')(' │') + chalk_1.default.hex('#22d3ee')(` ${shortUrl}`).padEnd(74) + chalk_1.default.hex('#4CAF50')('│'));
80
+ console.log(chalk_1.default.hex('#4CAF50')(' │') + ' '.padEnd(64) + chalk_1.default.hex('#4CAF50')('│'));
81
+ console.log(chalk_1.default.hex('#4CAF50')(' └' + '─'.repeat(64) + '┘'));
82
+ console.log();
83
+ // Snapshot de integraciones actuales
84
+ let prevIntegrationIds = new Set();
85
+ try {
86
+ const wkRes = await axios_1.default.get(`${baseUrl}/api/workspace/${ctx.workspaceId}`, { headers });
87
+ const integrations = wkRes.data?.integrations || wkRes.data?.data?.integrations || [];
88
+ prevIntegrationIds = new Set(integrations.map((i) => i.id));
89
+ }
90
+ catch {
91
+ // Si falla, se parte de vacio
92
+ }
93
+ // Polling para detectar nueva integracion
94
+ const pollSpinner = (0, ora_1.default)({ text: chalk_1.default.gray('Esperando conexion... (Ctrl+C para cancelar)'), spinner: 'dots', color: 'cyan' }).start();
95
+ const POLL_INTERVAL = 5000;
96
+ const MAX_POLLS = 60; // 5 minutos
97
+ let detected = null;
98
+ for (let i = 0; i < MAX_POLLS; i++) {
99
+ await new Promise(r => setTimeout(r, POLL_INTERVAL));
100
+ try {
101
+ const wkRes = await axios_1.default.get(`${baseUrl}/api/workspace/${ctx.workspaceId}`, { headers });
102
+ const integrations = wkRes.data?.integrations || wkRes.data?.data?.integrations || [];
103
+ // Buscar integraciones nuevas del tipo correcto
104
+ const targetType = channelType === 'whatsapp_business' ? 'whatsapp' : channelType;
105
+ const newOnes = integrations.filter((ig) => !prevIntegrationIds.has(ig.id) && ig.type === targetType);
106
+ if (newOnes.length > 0) {
107
+ detected = newOnes[0];
108
+ break;
109
+ }
110
+ }
111
+ catch {
112
+ // Ignorar errores de poll individual
113
+ }
114
+ const elapsed = Math.floor(((i + 1) * POLL_INTERVAL) / 1000);
115
+ pollSpinner.text = chalk_1.default.gray(`Esperando conexion... ${elapsed}s`);
116
+ }
117
+ if (detected) {
118
+ pollSpinner.succeed(chalk_1.default.hex('#4ade80')(`Conexion detectada: ${detected.aliasName || detected.id} (${channelLabel})`));
119
+ const { associate } = await inquirer_1.default.prompt([{
120
+ type: 'confirm', name: 'associate',
121
+ message: 'Deseas asociar este canal al agente?', default: true,
122
+ }]);
123
+ if (associate) {
124
+ channels.push({
125
+ channel: CHANNEL_AGENT_MAP[channelType],
126
+ key: detected.id,
127
+ multianswer: false,
128
+ });
129
+ console.log(chalk_1.default.hex('#4ade80')(' Canal asociado correctamente.'));
130
+ }
131
+ }
132
+ else {
133
+ pollSpinner.warn(chalk_1.default.hex('#FFA726')('Timeout: no se detecto una conexion.'));
134
+ const { action } = await inquirer_1.default.prompt([{
135
+ type: 'list', name: 'action',
136
+ message: 'Que deseas hacer?',
137
+ choices: [
138
+ { name: 'Ingresar numero/ID manualmente', value: 'manual' },
139
+ { name: 'Saltar este paso', value: 'skip' },
140
+ ],
141
+ }]);
142
+ if (action === 'manual') {
143
+ const { key } = await inquirer_1.default.prompt([
144
+ { type: 'input', name: 'key', message: `ID/numero del canal ${channelLabel}:`, validate: (v) => v.length > 0 || 'Requerido' },
145
+ ]);
146
+ channels.push({ channel: CHANNEL_AGENT_MAP[channelType], key, multianswer: false });
147
+ }
148
+ }
149
+ }
150
+ catch (err) {
151
+ spinner.fail(chalk_1.default.hex('#EF5350')(`Error al generar link: ${err instanceof Error ? err.message : err}`));
152
+ const { tryManual } = await inquirer_1.default.prompt([{
153
+ type: 'confirm', name: 'tryManual',
154
+ message: 'Deseas ingresar el numero manualmente?', default: false,
155
+ }]);
156
+ if (tryManual) {
157
+ const { key } = await inquirer_1.default.prompt([
158
+ { type: 'input', name: 'key', message: `ID/numero del canal ${channelLabel}:`, validate: (v) => v.length > 0 || 'Requerido' },
159
+ ]);
160
+ channels.push({ channel: CHANNEL_AGENT_MAP[channelType], key, multianswer: false });
161
+ }
162
+ }
163
+ const { more } = await inquirer_1.default.prompt([{ type: 'confirm', name: 'more', message: 'Conectar otro canal?', default: false }]);
164
+ addMore = more;
165
+ }
166
+ return channels;
167
+ }
168
+ async function runAgentWizard(zone, workspaceId, apiKey, dev) {
16
169
  console.log((0, ui_1.section)('Crear nuevo agente de IA'));
17
170
  console.log(ui_1.theme.muted(' Responde las siguientes preguntas para configurar tu agente.\n'));
18
171
  // Paso 1: Informacion basica
@@ -283,16 +436,20 @@ async function runAgentWizard(zone) {
283
436
  isDefault: true,
284
437
  });
285
438
  }
286
- // Paso 7: Canal WhatsApp
287
- console.log(ui_1.theme.bold('\n Paso 7/8: Canal WhatsApp'));
288
- const channels = [];
289
- const { addWhatsApp } = await inquirer_1.default.prompt([{
439
+ // Paso 7: Conectar canal
440
+ console.log(ui_1.theme.bold('\n Paso 7/8: Conectar canal'));
441
+ let channels = [];
442
+ const { addChannel } = await inquirer_1.default.prompt([{
290
443
  type: 'confirm',
291
- name: 'addWhatsApp',
292
- message: 'Conectar a un numero de WhatsApp?',
444
+ name: 'addChannel',
445
+ message: 'Deseas conectar un canal (WhatsApp, Instagram, Messenger)?',
293
446
  default: false,
294
447
  }]);
295
- if (addWhatsApp) {
448
+ if (addChannel && workspaceId && apiKey) {
449
+ channels = await connectChannelFlow({ zone, workspaceId, apiKey, dev: dev || false });
450
+ }
451
+ else if (addChannel) {
452
+ // Fallback manual si no hay credenciales para API
296
453
  const wa = await inquirer_1.default.prompt([
297
454
  { type: 'input', name: 'key', message: 'Numero de WhatsApp (con codigo de pais):', validate: (v) => v.length > 0 || 'Requerido' },
298
455
  { type: 'confirm', name: 'multianswer', message: 'Permitir multiples respuestas?', default: false },
@@ -363,7 +520,14 @@ async function runAgentWizard(zone) {
363
520
  console.log((0, ui_1.kvPair)('Servicios', String(config.services.length)));
364
521
  console.log((0, ui_1.kvPair)('Acciones', String(config.actions.length)));
365
522
  console.log((0, ui_1.kvPair)('AI Provider', config.customAIConfig ? config.aiProviders[0]?.provider + ' / ' + config.aiProviders[0]?.model : 'Default (Plazbot)'));
366
- console.log((0, ui_1.kvPair)('Canal WhatsApp', config.channels.length > 0 ? config.channels[0].key : 'No configurado'));
523
+ if (config.channels.length > 0) {
524
+ config.channels.forEach((ch, i) => {
525
+ console.log((0, ui_1.kvPair)(`Canal ${i + 1} (${ch.channel})`, ch.key));
526
+ });
527
+ }
528
+ else {
529
+ console.log((0, ui_1.kvPair)('Canales', 'No configurado'));
530
+ }
367
531
  console.log();
368
532
  return config;
369
533
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plazbot-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "CLI para Plazbot SDK",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
@@ -31,6 +31,7 @@
31
31
  "author": "Kristian Garcia <kristian@plazbot.com>",
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
+ "@microsoft/signalr": "^10.0.0",
34
35
  "@types/inquirer": "^9.0.8",
35
36
  "axios": "^1.6.0",
36
37
  "boxen": "^5.1.2",
@@ -37,7 +37,7 @@ export const createCommand = new Command('create')
37
37
  logger.json(agentConfig);
38
38
  } else {
39
39
  // Modo wizard interactivo
40
- agentConfig = await runAgentWizard(credentials.zone);
40
+ agentConfig = await runAgentWizard(credentials.zone, credentials.workspace, credentials.apiKey, options.dev);
41
41
 
42
42
  const inquirer = await import('inquirer');
43
43
  const { confirm } = await inquirer.default.prompt([{
@@ -70,7 +70,9 @@ export const createCommand = new Command('create')
70
70
  logger.label('Tool Calling', agentConfig.useToolCalling ? 'Activado' : 'Desactivado');
71
71
 
72
72
  if (agentConfig.channels && agentConfig.channels.length > 0) {
73
- logger.label('WhatsApp', agentConfig.channels[0].key);
73
+ agentConfig.channels.forEach((ch: any) => {
74
+ logger.label(`Canal (${ch.channel})`, ch.key);
75
+ });
74
76
  }
75
77
 
76
78
  console.log();
@@ -3,127 +3,158 @@ import { Agent } from 'plazbot';
3
3
  import { getStoredCredentials } from '../../utils/credentials';
4
4
  import { logger } from '../../utils/logger';
5
5
  import { AgentCommandOptions } from '../../types/agent';
6
+ import chalk from 'chalk';
6
7
 
7
8
  export const getCommand = new Command('get')
8
9
  .description('Obtiene información detallada de un agente específico')
9
10
  .argument('<agentId>', 'ID del agente a consultar')
11
+ .option('-w, --workspace <id>', 'Workspace ID (sobreescribe config local)')
12
+ .option('-z, --zone <zone>', 'Zona LA o EU (sobreescribe config local)')
13
+ .option('--raw', 'Mostrar el JSON completo sin formatear', false)
10
14
  .option('--dev', 'Usar ambiente de desarrollo', false)
11
- .action(async (agentId: string, options: AgentCommandOptions) => {
15
+ .action(async (agentId: string, options: AgentCommandOptions & { raw: boolean; workspace?: string; zone?: string }) => {
12
16
  try {
13
- // Obtener credenciales guardadas
14
17
  const credentials = await getStoredCredentials();
15
-
16
- // Crear instancia del agente con las credenciales guardadas
18
+
19
+ const effectiveWorkspace = options.workspace || credentials.workspace;
20
+ const effectiveZone = (options.zone?.toUpperCase() === 'EU' ? 'EU' : options.zone?.toUpperCase() === 'LA' ? 'LA' : credentials.zone) as 'LA' | 'EU';
21
+
22
+ if (options.workspace || options.zone) {
23
+ console.log(chalk.hex('#FFA726')(`\n Modo soporte: workspace=${effectiveWorkspace} zona=${effectiveZone}`));
24
+ }
25
+
17
26
  const agent = new Agent({
18
- workspaceId: credentials.workspace,
27
+ workspaceId: effectiveWorkspace,
19
28
  apiKey: credentials.apiKey,
20
- zone: credentials.zone,
29
+ zone: effectiveZone,
21
30
  ...(options.dev && { customUrl: "http://localhost:5090" })
22
31
  });
23
32
 
24
- // Obtener detalles del agente
25
- const agentData = await agent.getAgentById({ id: agentId });
26
-
27
- logger.info('\nDetalles del Agente:');
28
- logger.doubleDivider();
29
-
30
- // Información básica
31
- logger.info('Información Básica:');
32
- logger.divider();
33
- logger.info(`ID: ${agentData.id}`);
34
- logger.info(`Nombre: ${agentData.name}`);
35
- logger.info(`Descripción: ${agentData.description}`);
36
- logger.info(`Estado: ${agentData.enable ? 'Activo' : 'Inactivo'}`);
37
- logger.info(`Zona: ${agentData.zone}`);
38
- logger.info(`Buffer: ${agentData.buffer}`);
39
- logger.info(`Color: ${agentData.color}`);
40
- logger.info(`Pregunta inicial: ${agentData.question}`);
41
- logger.info(`Zona horaria: ${agentData.timezone}`);
42
- logger.info(`Mostrar en chat: ${agentData.showInChat ? '' : 'No'}`);
43
-
33
+ // El SDK retorna { success, agent: {...} }
34
+ const response: any = await agent.getAgentById({ id: agentId });
35
+ const agentData = response.agent || response.data || response;
36
+
37
+ // Modo JSON crudo
38
+ if (options.raw) {
39
+ console.log(JSON.stringify(agentData, null, 2));
40
+ return;
41
+ }
42
+
43
+ const label = (key: string, value: any) => {
44
+ const v = value !== undefined && value !== null && value !== '' ? String(value) : chalk.gray('—');
45
+ console.log(` ${chalk.gray(key + ':')} ${chalk.white(v)}`);
46
+ };
47
+
48
+ const sectionHeader = (title: string) => {
49
+ console.log();
50
+ console.log(chalk.bold.hex('#4CAF50')(` ${title}`));
51
+ console.log(chalk.gray(' ' + ''.repeat(40)));
52
+ };
53
+
54
+ console.log();
55
+ console.log(chalk.hex('#4CAF50')(' ┌' + '─'.repeat(58) + '┐'));
56
+ console.log(chalk.hex('#4CAF50')(' │') + chalk.bold(` ${agentData.name || 'Agente'}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
57
+ console.log(chalk.hex('#4CAF50')(' │') + chalk.gray(` ${agentId}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
58
+ console.log(chalk.hex('#4CAF50')(' └' + '─'.repeat(58) + '┘'));
59
+
60
+ // Informacion basica
61
+ sectionHeader('Informacion Basica');
62
+ label('ID', agentData.id);
63
+ label('Nombre', agentData.name);
64
+ label('Descripcion', agentData.description);
65
+ label('Estado', agentData.enable ? chalk.hex('#66BB6A')('Activo') : chalk.hex('#EF5350')('Inactivo'));
66
+ label('Zona', agentData.zone);
67
+ label('Buffer', agentData.buffer);
68
+ label('Color', agentData.color);
69
+ label('Pregunta inicial', agentData.question);
70
+ label('Zona horaria', agentData.timezone);
71
+ label('Mostrar en chat', agentData.showInChat ? 'Si' : 'No');
72
+ label('Tool Calling', agentData.useToolCalling ? 'Activado' : 'Desactivado');
73
+
44
74
  // Tags
45
75
  if (agentData.tags && agentData.tags.length > 0) {
46
- logger.info(`\nTags: ${agentData.tags.join(', ')}`);
76
+ label('Tags', agentData.tags.join(', '));
77
+ }
78
+
79
+ // Prompt
80
+ if (agentData.prompt) {
81
+ sectionHeader('Prompt');
82
+ const promptPreview = agentData.prompt.length > 200
83
+ ? agentData.prompt.substring(0, 200) + '...'
84
+ : agentData.prompt;
85
+ console.log(chalk.white(' ' + promptPreview.split('\n').join('\n ')));
47
86
  }
48
87
 
49
88
  // Ejemplos
50
89
  if (agentData.examples && agentData.examples.length > 0) {
51
- logger.info('\nEjemplos:');
52
- logger.divider();
53
- agentData.examples.forEach((example: { value: string; color: string }) => {
54
- logger.info(`- ${example.value} (${example.color})`);
90
+ sectionHeader('Ejemplos');
91
+ agentData.examples.forEach((example: any) => {
92
+ console.log(chalk.white(` - ${example.value || example}`));
55
93
  });
56
94
  }
57
95
 
58
96
  // Instrucciones
59
97
  if (agentData.instructions) {
60
- logger.info('\nInstrucciones:');
61
- logger.divider();
62
- const instructions = agentData.instructions;
63
- logger.info(`Tono: ${instructions.tone}`);
64
- logger.info(`Estilo: ${instructions.style}`);
65
- logger.info(`Personalidad: ${instructions.personality}`);
66
- logger.info(`Objetivo: ${instructions.objective}`);
67
- logger.info(`Idioma: ${instructions.language}`);
68
- logger.info(`Emojis: ${instructions.emojis ? 'Sí' : 'No'}`);
69
- logger.info(`Formato preferido: ${instructions.preferredFormat}`);
70
- logger.info(`Máximo de palabras: ${instructions.maxWords}`);
71
- if (instructions.avoidTopics) {
72
- logger.info(`Temas a evitar: ${instructions.avoidTopics.join(', ')}`);
98
+ sectionHeader('Instrucciones');
99
+ const inst = agentData.instructions;
100
+ label('Tono', inst.tone);
101
+ label('Estilo', inst.style);
102
+ label('Personalidad', inst.personality);
103
+ label('Objetivo', inst.objective);
104
+ label('Idioma', inst.language);
105
+ label('Emojis', inst.emojis ? 'Si' : 'No');
106
+ label('Formato preferido', inst.preferredFormat);
107
+ label('Max palabras', inst.maxWords);
108
+ if (inst.avoidTopics && inst.avoidTopics.length > 0) {
109
+ label('Temas a evitar', inst.avoidTopics.join(', '));
73
110
  }
74
- logger.info(`Responder solo si sabe: ${instructions.respondOnlyIfKnows ? '' : 'No'}`);
75
- logger.info(`Mantener tono entre mensajes: ${instructions.maintainToneBetweenMessages ? '' : 'No'}`);
76
- logger.info(`Saludo: ${instructions.greeting}`);
111
+ label('Solo responder si sabe', inst.respondOnlyIfKnows ? 'Si' : 'No');
112
+ label('Saludo', inst.greeting);
77
113
  }
78
114
 
79
115
  // Persona
80
116
  if (agentData.person) {
81
- logger.info('\nPersona:');
82
- logger.divider();
83
- const person = agentData.person;
84
- logger.info(`Nombre: ${person.name}`);
85
- logger.info(`Rol: ${person.role}`);
86
- logger.info(`Habla en primera persona: ${person.speaksInFirstPerson ? '' : 'No'}`);
87
- logger.info(`Es humano: ${person.isHuman ? 'Sí' : 'No'}`);
117
+ sectionHeader('Persona');
118
+ const p = agentData.person;
119
+ label('Nombre', p.name);
120
+ label('Rol', p.role);
121
+ label('Primera persona', p.speaksInFirstPerson ? 'Si' : 'No');
122
+ label('Es humano', p.isHuman ? 'Si' : 'No');
88
123
  }
89
124
 
90
125
  // Fallbacks
91
126
  if (agentData.fallbacks) {
92
- logger.info('\nFallbacks:');
93
- logger.divider();
94
- const fallbacks = agentData.fallbacks;
95
- logger.info(`Sin respuesta: ${fallbacks.noAnswer}`);
96
- logger.info(`Error de servicio: ${fallbacks.serviceError}`);
97
- logger.info(`No entiende: ${fallbacks.doNotUnderstand}`);
127
+ sectionHeader('Fallbacks');
128
+ const fb = agentData.fallbacks;
129
+ label('Sin respuesta', fb.noAnswer);
130
+ label('Error de servicio', fb.serviceError);
131
+ label('No entiende', fb.doNotUnderstand);
98
132
  }
99
133
 
100
134
  // Reglas
101
135
  if (agentData.rules) {
102
- logger.info('\nReglas:');
103
- logger.divider();
104
- const rules = agentData.rules;
105
- logger.info(`No mencionar precios: ${rules.doNotMentionPrices ? '' : 'No'}`);
106
- logger.info(`No diagnosticar: ${rules.doNotDiagnose ? 'Sí' : 'No'}`);
107
- if (rules.doNotRespondOutsideHours) {
108
- logger.info(`Horario de atención: ${rules.doNotRespondOutsideHours}`);
136
+ sectionHeader('Reglas');
137
+ const r = agentData.rules;
138
+ label('No mencionar precios', r.doNotMentionPrices ? 'Si' : 'No');
139
+ label('No diagnosticar', r.doNotDiagnose ? 'Si' : 'No');
140
+ if (r.doNotRespondOutsideHours) {
141
+ label('Fuera de horario', r.doNotRespondOutsideHours);
109
142
  }
110
143
  }
111
144
 
112
145
  // Servicios
113
146
  if (agentData.services && agentData.services.length > 0) {
114
- logger.info('\nServicios:');
115
- logger.divider();
116
- agentData.services.forEach((service: any, index: number) => {
117
- logger.info(`\nServicio ${index + 1}:`);
118
- logger.info(`Intent: ${service.intent}`);
119
- logger.info(`Referencia: ${service.reference}`);
120
- logger.info(`Habilitado: ${service.enabled ? '' : 'No'}`);
121
- logger.info(`Método: ${service.method}`);
122
- logger.info(`Endpoint: ${service.endpoint}`);
123
- if (service.requiredFields) {
124
- logger.info('Campos requeridos:');
125
- service.requiredFields.forEach((field: any) => {
126
- logger.info(` - ${field.name} (${field.type}): ${field.description}`);
147
+ sectionHeader(`Servicios (${agentData.services.length})`);
148
+ agentData.services.forEach((svc: any, i: number) => {
149
+ console.log(chalk.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || 'Servicio'}`));
150
+ label(' Referencia', svc.reference);
151
+ label(' Habilitado', svc.enabled ? 'Si' : 'No');
152
+ label(' Metodo', svc.method);
153
+ label(' Endpoint', svc.endpoint);
154
+ if (svc.requiredFields && svc.requiredFields.length > 0) {
155
+ console.log(chalk.gray(' Campos:'));
156
+ svc.requiredFields.forEach((f: any) => {
157
+ console.log(chalk.white(` - ${f.name} (${f.type}): ${f.description || ''}`));
127
158
  });
128
159
  }
129
160
  });
@@ -131,21 +162,19 @@ export const getCommand = new Command('get')
131
162
 
132
163
  // Acciones
133
164
  if (agentData.actions && agentData.actions.length > 0) {
134
- logger.info('\nAcciones:');
135
- logger.divider();
136
- agentData.actions.forEach((action: any, index: number) => {
137
- logger.info(`\nAcción ${index + 1}:`);
138
- logger.info(`Intent: ${action.intent}`);
139
- logger.info(`Referencia: ${action.reference}`);
140
- logger.info(`Habilitado: ${action.enabled ? 'Sí' : 'No'}`);
141
- if (action.tags) {
142
- logger.info(`Tags: ${action.tags.join(', ')}`);
165
+ sectionHeader(`Acciones (${agentData.actions.length})`);
166
+ agentData.actions.forEach((act: any, i: number) => {
167
+ console.log(chalk.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || 'Accion'}`));
168
+ label(' Referencia', act.reference);
169
+ label(' Habilitado', act.enabled ? 'Si' : 'No');
170
+ if (act.tags && act.tags.length > 0) {
171
+ label(' Tags', act.tags.join(', '));
143
172
  }
144
- logger.info(`Mensaje de respuesta: ${action.responseMessage}`);
145
- if (action.action) {
146
- logger.info('Sub-acciones:');
147
- action.action.forEach((subAction: any) => {
148
- logger.info(` - ${subAction.type}: ${subAction.value}`);
173
+ label(' Respuesta', act.responseMessage);
174
+ if (act.action && act.action.length > 0) {
175
+ console.log(chalk.gray(' Sub-acciones:'));
176
+ act.action.forEach((sa: any) => {
177
+ console.log(chalk.white(` - ${sa.type}: ${sa.value || ''}`));
149
178
  });
150
179
  }
151
180
  });
@@ -153,19 +182,29 @@ export const getCommand = new Command('get')
153
182
 
154
183
  // Canales
155
184
  if (agentData.channels && agentData.channels.length > 0) {
156
- logger.info('\nCanales:');
157
- logger.divider();
158
- agentData.channels.forEach((channel: { channel: string; key: string }) => {
159
- logger.info(`${channel.channel}: ${channel.key}`);
185
+ sectionHeader(`Canales (${agentData.channels.length})`);
186
+ agentData.channels.forEach((ch: any) => {
187
+ console.log(chalk.white(` ${chalk.hex('#22d3ee')(ch.channel || 'canal')}: ${ch.key || ''}`));
160
188
  });
161
189
  }
162
190
 
163
- logger.doubleDivider();
164
-
191
+ // AI Config
192
+ if (agentData.customAIConfig && agentData.aiProviders && agentData.aiProviders.length > 0) {
193
+ sectionHeader('Modelo IA');
194
+ agentData.aiProviders.forEach((ai: any) => {
195
+ label('Proveedor', ai.provider);
196
+ label('Modelo', ai.model);
197
+ });
198
+ }
199
+
200
+ console.log();
201
+ console.log(chalk.gray(' Usa --raw para ver el JSON completo'));
202
+ console.log();
203
+
165
204
  if (options.dev) {
166
205
  logger.warning('Ambiente: desarrollo');
167
206
  }
168
-
207
+
169
208
  } catch (error) {
170
209
  const message = error instanceof Error ? error.message : 'Error desconocido al obtener el agente';
171
210
  logger.error(message);
@@ -13,6 +13,7 @@ import { templatesCommand } from './templates';
13
13
  import { copyCommand } from './copy';
14
14
  import { filesCommand } from './files';
15
15
  import { setCommand } from './set';
16
+ import { monitorCommand } from './monitor';
16
17
 
17
18
  export const agentCommands = new Command('agent')
18
19
  .description('Comandos relacionados con agentes de IA')
@@ -29,4 +30,5 @@ export const agentCommands = new Command('agent')
29
30
  .addCommand(templatesCommand)
30
31
  .addCommand(copyCommand)
31
32
  .addCommand(filesCommand)
32
- .addCommand(setCommand);
33
+ .addCommand(setCommand)
34
+ .addCommand(monitorCommand);