plazbot-cli 0.1.2 → 0.1.4

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.
Files changed (51) hide show
  1. package/.claude/settings.local.json +14 -0
  2. package/CLAUDE.md +92 -0
  3. package/README.md +102 -0
  4. package/dist/cli.js +14 -5
  5. package/dist/commands/agent/ai-config.js +107 -0
  6. package/dist/commands/agent/chat.js +130 -34
  7. package/dist/commands/agent/copy.js +37 -0
  8. package/dist/commands/agent/create.js +80 -17
  9. package/dist/commands/agent/files.js +142 -0
  10. package/dist/commands/agent/index.js +14 -2
  11. package/dist/commands/agent/set.js +127 -0
  12. package/dist/commands/agent/templates.js +240 -0
  13. package/dist/commands/agent/tools.js +161 -0
  14. package/dist/commands/agent/wizard.js +369 -0
  15. package/dist/commands/whatsapp/broadcast.js +97 -0
  16. package/dist/commands/whatsapp/channels.js +86 -0
  17. package/dist/commands/whatsapp/chat.js +74 -0
  18. package/dist/commands/whatsapp/index.js +11 -2
  19. package/dist/commands/whatsapp/send-template.js +51 -14
  20. package/dist/commands/whatsapp/send.js +10 -10
  21. package/dist/commands/whatsapp/widget.js +64 -0
  22. package/dist/utils/banner.js +87 -0
  23. package/dist/utils/logger.js +27 -6
  24. package/dist/utils/ui.js +111 -0
  25. package/package.json +10 -2
  26. package/src/cli.ts +13 -5
  27. package/src/commands/agent/ai-config.ts +112 -0
  28. package/src/commands/agent/chat.ts +149 -40
  29. package/src/commands/agent/copy.ts +40 -0
  30. package/src/commands/agent/create.ts +58 -23
  31. package/src/commands/agent/files.ts +158 -0
  32. package/src/commands/agent/index.ts +14 -2
  33. package/src/commands/agent/set.ts +137 -0
  34. package/src/commands/agent/templates.ts +249 -0
  35. package/src/commands/agent/tools.ts +167 -0
  36. package/src/commands/agent/wizard.ts +475 -0
  37. package/src/commands/whatsapp/broadcast.ts +100 -0
  38. package/src/commands/whatsapp/channels.ts +98 -0
  39. package/src/commands/whatsapp/chat.ts +77 -0
  40. package/src/commands/whatsapp/index.ts +11 -2
  41. package/src/commands/whatsapp/send-template.ts +57 -19
  42. package/src/commands/whatsapp/send.ts +15 -14
  43. package/src/commands/whatsapp/widget.ts +67 -0
  44. package/src/utils/banner.ts +94 -0
  45. package/src/utils/logger.ts +26 -7
  46. package/src/utils/ui.ts +109 -0
  47. package/dist/commands/message/delete-webhook.js +0 -39
  48. package/dist/commands/message/index.js +0 -14
  49. package/dist/commands/message/register-webhook.js +0 -42
  50. package/dist/commands/message/send-template.js +0 -42
  51. package/dist/commands/message/send.js +0 -42
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assignCommand = exports.channelsCommand = void 0;
4
+ const commander_1 = require("commander");
5
+ const plazbot_1 = require("plazbot");
6
+ const credentials_1 = require("../../utils/credentials");
7
+ const logger_1 = require("../../utils/logger");
8
+ const ui_1 = require("../../utils/ui");
9
+ exports.channelsCommand = new commander_1.Command('channels')
10
+ .description('Listar agentes con canales de WhatsApp asignados')
11
+ .option('--dev', 'Usar ambiente de desarrollo', false)
12
+ .action(async (options) => {
13
+ try {
14
+ const credentials = await (0, credentials_1.getStoredCredentials)();
15
+ const agent = new plazbot_1.Agent({
16
+ workspaceId: credentials.workspace,
17
+ apiKey: credentials.apiKey,
18
+ zone: credentials.zone,
19
+ ...(options.dev && { customUrl: "http://localhost:5090" })
20
+ });
21
+ const spinner = (0, ui_1.createSpinner)('Cargando canales...');
22
+ spinner.start();
23
+ const agents = await agent.getAgents();
24
+ spinner.stop();
25
+ console.log((0, ui_1.section)('Canales WhatsApp'));
26
+ const whatsappAgents = (agents || []).filter((a) => a.channels && a.channels.some((c) => c.channel === 'whatsapp'));
27
+ if (whatsappAgents.length === 0) {
28
+ console.log(ui_1.theme.muted('\n No hay agentes con WhatsApp configurado'));
29
+ console.log(ui_1.theme.muted(' Usa el wizard: plazbot agent create\n'));
30
+ return;
31
+ }
32
+ const rows = whatsappAgents.map((a) => {
33
+ const waChannel = a.channels.find((c) => c.channel === 'whatsapp');
34
+ return [
35
+ a.id || a._id,
36
+ a.name,
37
+ waChannel?.key || 'N/A',
38
+ (0, ui_1.statusBadge)(a.enable !== false),
39
+ ];
40
+ });
41
+ console.log((0, ui_1.createTable)(['Agent ID', 'Nombre', 'Numero WhatsApp', 'Estado'], rows));
42
+ }
43
+ catch (error) {
44
+ const message = error instanceof Error ? error.message : 'Error desconocido';
45
+ logger_1.logger.error(message);
46
+ process.exit(1);
47
+ }
48
+ });
49
+ exports.assignCommand = new commander_1.Command('assign')
50
+ .description('Asignar un agente a un numero de WhatsApp')
51
+ .argument('<phone>', 'Numero de WhatsApp')
52
+ .argument('<agentId>', 'ID del agente')
53
+ .option('--dev', 'Usar ambiente de desarrollo', false)
54
+ .action(async (phone, agentId, options) => {
55
+ try {
56
+ const credentials = await (0, credentials_1.getStoredCredentials)();
57
+ const agent = new plazbot_1.Agent({
58
+ workspaceId: credentials.workspace,
59
+ apiKey: credentials.apiKey,
60
+ zone: credentials.zone,
61
+ ...(options.dev && { customUrl: "http://localhost:5090" })
62
+ });
63
+ const spinner = (0, ui_1.createSpinner)('Cargando agente...');
64
+ spinner.start();
65
+ const agentData = await agent.getAgentById({ id: agentId });
66
+ spinner.stop();
67
+ const channels = agentData.channels || [];
68
+ // Verificar si ya tiene este canal
69
+ const existing = channels.findIndex((c) => c.channel === 'whatsapp' && c.key === phone);
70
+ if (existing >= 0) {
71
+ logger_1.logger.warning('Este numero ya esta asignado a este agente');
72
+ return;
73
+ }
74
+ // Agregar canal
75
+ channels.push({ channel: 'whatsapp', key: phone, multianswer: false });
76
+ const updateSpinner = (0, ui_1.createSpinner)('Asignando...');
77
+ updateSpinner.start();
78
+ await agent.updateAgent(agentId, { channels });
79
+ updateSpinner.succeed(`Agente "${agentData.name}" asignado a WhatsApp ${phone}`);
80
+ }
81
+ catch (error) {
82
+ const message = error instanceof Error ? error.message : 'Error desconocido';
83
+ logger_1.logger.error(message);
84
+ process.exit(1);
85
+ }
86
+ });
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.whatsappChatCommand = void 0;
7
+ const commander_1 = require("commander");
8
+ const plazbot_1 = require("plazbot");
9
+ const credentials_1 = require("../../utils/credentials");
10
+ const logger_1 = require("../../utils/logger");
11
+ const ui_1 = require("../../utils/ui");
12
+ const readline_1 = __importDefault(require("readline"));
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ exports.whatsappChatCommand = new commander_1.Command('chat')
15
+ .description('Chat interactivo directo por WhatsApp')
16
+ .argument('<phone>', 'Numero de telefono destino (con codigo de pais)')
17
+ .option('--dev', 'Usar ambiente de desarrollo', false)
18
+ .action(async (phone, options) => {
19
+ try {
20
+ const credentials = await (0, credentials_1.getStoredCredentials)();
21
+ const messageClient = new plazbot_1.Message({
22
+ workspaceId: credentials.workspace,
23
+ apiKey: credentials.apiKey,
24
+ zone: credentials.zone,
25
+ ...(options.dev && { customUrl: "http://localhost:5090" })
26
+ });
27
+ const rl = readline_1.default.createInterface({
28
+ input: process.stdin,
29
+ output: process.stdout,
30
+ });
31
+ console.clear();
32
+ console.log();
33
+ console.log(chalk_1.default.hex('#25D366')(' ┌' + '─'.repeat(50) + '┐'));
34
+ console.log(chalk_1.default.hex('#25D366')(' │') + chalk_1.default.bold(` WhatsApp Chat`).padEnd(60) + chalk_1.default.hex('#25D366')('│'));
35
+ console.log(chalk_1.default.hex('#25D366')(' │') + chalk_1.default.gray(` Destino: ${phone}`).padEnd(60) + chalk_1.default.hex('#25D366')('│'));
36
+ console.log(chalk_1.default.hex('#25D366')(' │') + chalk_1.default.gray(' /exit para salir').padEnd(60) + chalk_1.default.hex('#25D366')('│'));
37
+ console.log(chalk_1.default.hex('#25D366')(' └' + '─'.repeat(50) + '┘'));
38
+ console.log();
39
+ const ask = () => {
40
+ rl.question(chalk_1.default.hex('#25D366')(' > '), async (message) => {
41
+ if (!message.trim()) {
42
+ ask();
43
+ return;
44
+ }
45
+ if (message.toLowerCase() === '/exit') {
46
+ console.log(chalk_1.default.gray('\n Chat terminado.\n'));
47
+ rl.close();
48
+ return;
49
+ }
50
+ try {
51
+ const spinner = (0, ui_1.createSpinner)('Enviando...');
52
+ spinner.start();
53
+ await messageClient.onWhatsappMessage({
54
+ message,
55
+ to: phone,
56
+ });
57
+ spinner.succeed('Enviado');
58
+ ask();
59
+ }
60
+ catch (error) {
61
+ const msg = error instanceof Error ? error.message : 'Error';
62
+ console.log(chalk_1.default.hex('#EF5350')(` ✖ ${msg}`));
63
+ ask();
64
+ }
65
+ });
66
+ };
67
+ ask();
68
+ }
69
+ catch (error) {
70
+ const message = error instanceof Error ? error.message : 'Error desconocido';
71
+ logger_1.logger.error(message);
72
+ process.exit(1);
73
+ }
74
+ });
@@ -6,9 +6,18 @@ const send_1 = require("./send");
6
6
  const send_template_1 = require("./send-template");
7
7
  const register_webhook_1 = require("./register-webhook");
8
8
  const delete_webhook_1 = require("./delete-webhook");
9
+ const broadcast_1 = require("./broadcast");
10
+ const chat_1 = require("./chat");
11
+ const widget_1 = require("./widget");
12
+ const channels_1 = require("./channels");
9
13
  exports.whatsappCommands = new commander_1.Command('whatsapp')
10
- .description('Comandos relacionados con mensajes de WhatsApp')
14
+ .description('Comandos de WhatsApp: mensajes, templates, broadcast y mas')
11
15
  .addCommand(send_1.sendMessageCommand)
12
16
  .addCommand(send_template_1.sendTemplateCommand)
13
17
  .addCommand(register_webhook_1.registerWebhookCommand)
14
- .addCommand(delete_webhook_1.deleteWebhookCommand);
18
+ .addCommand(delete_webhook_1.deleteWebhookCommand)
19
+ .addCommand(broadcast_1.broadcastCommand)
20
+ .addCommand(chat_1.whatsappChatCommand)
21
+ .addCommand(widget_1.widgetCommand)
22
+ .addCommand(channels_1.channelsCommand)
23
+ .addCommand(channels_1.assignCommand);
@@ -5,10 +5,15 @@ const commander_1 = require("commander");
5
5
  const plazbot_1 = require("plazbot");
6
6
  const credentials_1 = require("../../utils/credentials");
7
7
  const logger_1 = require("../../utils/logger");
8
+ const ui_1 = require("../../utils/ui");
8
9
  exports.sendTemplateCommand = new commander_1.Command('send-template')
9
- .description('Envía una plantilla de WhatsApp')
10
- .requiredOption('-p, --phone <number>', 'Número de teléfono del destinatario (con código de país, ej: 51912345678)')
11
- .requiredOption('-t, --template <name>', 'Nombre de la plantilla a enviar')
10
+ .description('Envia un mensaje de template de WhatsApp con variables')
11
+ .requiredOption('-p, --phone <number>', 'Numero de telefono (con codigo de pais)')
12
+ .requiredOption('-t, --template <name>', 'Nombre del template')
13
+ .option('--var <vars...>', 'Variables del body (formato: name=valor)')
14
+ .option('--header-var <vars...>', 'Variables del header (formato: name=valor)')
15
+ .option('--file-url <url>', 'URL del archivo adjunto')
16
+ .option('--file-name <name>', 'Nombre del archivo adjunto')
12
17
  .option('--dev', 'Usar ambiente de desarrollo', false)
13
18
  .action(async (options) => {
14
19
  try {
@@ -19,23 +24,55 @@ exports.sendTemplateCommand = new commander_1.Command('send-template')
19
24
  zone: credentials.zone,
20
25
  ...(options.dev && { customUrl: "http://localhost:5090" })
21
26
  });
22
- logger_1.logger.info('\n📱 Enviando plantilla de WhatsApp...');
23
- logger_1.logger.info(`A: ${options.phone}`);
24
- logger_1.logger.info(`Plantilla: ${options.template}`);
25
- const response = await messageClient.onConversation({
27
+ // Parsear variables
28
+ const variablesBody = parseVariables(options.var);
29
+ const variablesHeader = parseVariables(options.headerVar);
30
+ // Archivo adjunto
31
+ const file = options.fileUrl ? {
32
+ fileUrl: options.fileUrl,
33
+ fileName: options.fileName || 'archivo',
34
+ } : undefined;
35
+ logger_1.logger.title('Enviando template WhatsApp');
36
+ logger_1.logger.label('Destino', options.phone);
37
+ logger_1.logger.label('Template', options.template);
38
+ if (variablesBody.length > 0) {
39
+ logger_1.logger.label('Variables body', variablesBody.map(v => `${v.variable}=${v.value}`).join(', '));
40
+ }
41
+ if (variablesHeader.length > 0) {
42
+ logger_1.logger.label('Variables header', variablesHeader.map(v => `${v.variable}=${v.value}`).join(', '));
43
+ }
44
+ if (file) {
45
+ logger_1.logger.label('Archivo', file.fileUrl);
46
+ }
47
+ const spinner = (0, ui_1.createSpinner)('Enviando...');
48
+ spinner.start();
49
+ const params = {
26
50
  to: options.phone,
27
- template: options.template
28
- });
29
- logger_1.logger.success('Plantilla enviada exitosamente');
30
- logger_1.logger.info('\n📋 Detalles:');
31
- logger_1.logger.info(JSON.stringify(response, null, 2));
51
+ template: options.template,
52
+ };
53
+ if (variablesBody.length > 0)
54
+ params.variablesBody = variablesBody;
55
+ if (variablesHeader.length > 0)
56
+ params.variablesHeader = variablesHeader;
57
+ if (file)
58
+ params.file = file;
59
+ const response = await messageClient.onConversation(params);
60
+ spinner.succeed('Template enviado exitosamente');
32
61
  if (options.dev) {
33
- logger_1.logger.warning('\nAmbiente: desarrollo');
62
+ logger_1.logger.warning('Ambiente: desarrollo');
34
63
  }
35
64
  }
36
65
  catch (error) {
37
- const message = error instanceof Error ? error.message : 'Error desconocido al enviar la plantilla';
66
+ const message = error?.message || 'Error desconocido al enviar el template';
38
67
  logger_1.logger.error(message);
39
68
  process.exit(1);
40
69
  }
41
70
  });
71
+ function parseVariables(vars) {
72
+ if (!vars)
73
+ return [];
74
+ return vars.map(v => {
75
+ const [variable, ...rest] = v.split('=');
76
+ return { variable: variable.trim(), value: rest.join('=').trim() };
77
+ }).filter(v => v.variable && v.value);
78
+ }
@@ -5,14 +5,14 @@ const commander_1 = require("commander");
5
5
  const plazbot_1 = require("plazbot");
6
6
  const credentials_1 = require("../../utils/credentials");
7
7
  const logger_1 = require("../../utils/logger");
8
+ const ui_1 = require("../../utils/ui");
8
9
  exports.sendMessageCommand = new commander_1.Command('send-message')
9
- .description('Envía un mensaje de WhatsApp')
10
- .requiredOption('-t, --to <phone>', 'Número de teléfono del destinatario (con código de país, ej: 51912345678)')
10
+ .description('Envia un mensaje directo de WhatsApp')
11
+ .requiredOption('-t, --to <phone>', 'Numero de telefono (con codigo de pais, ej: 51912345678)')
11
12
  .requiredOption('-m, --message <text>', 'Mensaje a enviar')
12
13
  .option('--dev', 'Usar ambiente de desarrollo', false)
13
14
  .action(async (options) => {
14
15
  try {
15
- // Obtener credenciales guardadas
16
16
  const credentials = await (0, credentials_1.getStoredCredentials)();
17
17
  const messageClient = new plazbot_1.Message({
18
18
  workspaceId: credentials.workspace,
@@ -20,18 +20,18 @@ exports.sendMessageCommand = new commander_1.Command('send-message')
20
20
  zone: credentials.zone,
21
21
  ...(options.dev && { customUrl: "http://localhost:5090" })
22
22
  });
23
- logger_1.logger.info('\n📱 Enviando mensaje de WhatsApp...');
24
- logger_1.logger.info(`A: ${options.to}`);
25
- logger_1.logger.info(`Mensaje: ${options.message}`);
23
+ logger_1.logger.title('Enviando mensaje WhatsApp');
24
+ logger_1.logger.label('Destino', options.to);
25
+ logger_1.logger.label('Mensaje', options.message);
26
+ const spinner = (0, ui_1.createSpinner)('Enviando...');
27
+ spinner.start();
26
28
  const response = await messageClient.onWhatsappMessage({
27
29
  message: options.message,
28
30
  to: options.to
29
31
  });
30
- logger_1.logger.success('Mensaje enviado exitosamente');
31
- logger_1.logger.info('\n📋 Detalles:');
32
- logger_1.logger.info(JSON.stringify(response, null, 2));
32
+ spinner.succeed('Mensaje enviado exitosamente');
33
33
  if (options.dev) {
34
- logger_1.logger.warning('\nAmbiente: desarrollo');
34
+ logger_1.logger.warning('Ambiente: desarrollo');
35
35
  }
36
36
  }
37
37
  catch (error) {
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.widgetCommand = void 0;
4
+ const commander_1 = require("commander");
5
+ const plazbot_1 = require("plazbot");
6
+ const credentials_1 = require("../../utils/credentials");
7
+ const logger_1 = require("../../utils/logger");
8
+ const ui_1 = require("../../utils/ui");
9
+ const widgetGroup = new commander_1.Command('widget')
10
+ .description('Gestionar widget de WhatsApp');
11
+ widgetGroup.command('enable')
12
+ .description('Activar widget de WhatsApp en un agente')
13
+ .argument('<agentId>', 'ID del agente')
14
+ .requiredOption('-u, --url <url>', 'URL de WhatsApp (ej: https://wa.me/51912345678)')
15
+ .option('--dev', 'Usar ambiente de desarrollo', false)
16
+ .action(async (agentId, options) => {
17
+ try {
18
+ const credentials = await (0, credentials_1.getStoredCredentials)();
19
+ const agent = new plazbot_1.Agent({
20
+ workspaceId: credentials.workspace,
21
+ apiKey: credentials.apiKey,
22
+ zone: credentials.zone,
23
+ ...(options.dev && { customUrl: "http://localhost:5090" })
24
+ });
25
+ const spinner = (0, ui_1.createSpinner)('Activando widget WhatsApp...');
26
+ spinner.start();
27
+ await agent.updateAgent(agentId, {
28
+ enableWhatsappWidget: true,
29
+ urlWhatsappWidget: options.url,
30
+ });
31
+ spinner.succeed('Widget WhatsApp activado');
32
+ logger_1.logger.label('URL', options.url);
33
+ }
34
+ catch (error) {
35
+ const message = error instanceof Error ? error.message : 'Error desconocido';
36
+ logger_1.logger.error(message);
37
+ process.exit(1);
38
+ }
39
+ });
40
+ widgetGroup.command('disable')
41
+ .description('Desactivar widget de WhatsApp de un agente')
42
+ .argument('<agentId>', 'ID del agente')
43
+ .option('--dev', 'Usar ambiente de desarrollo', false)
44
+ .action(async (agentId, options) => {
45
+ try {
46
+ const credentials = await (0, credentials_1.getStoredCredentials)();
47
+ const agent = new plazbot_1.Agent({
48
+ workspaceId: credentials.workspace,
49
+ apiKey: credentials.apiKey,
50
+ zone: credentials.zone,
51
+ ...(options.dev && { customUrl: "http://localhost:5090" })
52
+ });
53
+ const spinner = (0, ui_1.createSpinner)('Desactivando widget WhatsApp...');
54
+ spinner.start();
55
+ await agent.updateAgent(agentId, { enableWhatsappWidget: false });
56
+ spinner.succeed('Widget WhatsApp desactivado');
57
+ }
58
+ catch (error) {
59
+ const message = error instanceof Error ? error.message : 'Error desconocido';
60
+ logger_1.logger.error(message);
61
+ process.exit(1);
62
+ }
63
+ });
64
+ exports.widgetCommand = widgetGroup;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.showBanner = showBanner;
7
+ exports.showMiniHeader = showMiniHeader;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const credentials_1 = require("./credentials");
10
+ const VERSION = '0.2.0';
11
+ // ASCII art del logo Plazbot (burbujas de chat)
12
+ const logo = [
13
+ ' ╭──────────╮ ',
14
+ ' │ ● ● ● │ ',
15
+ ' ╰────┬─────╯ ',
16
+ ' ╭─────┴────────╮ ',
17
+ ' │ ╭─╮ ╭─╮ │ ',
18
+ ' │ ╰─╯ ╰─╯ │ ',
19
+ ' │ ╰────╯ │ ',
20
+ ' ╰───────────────╯ ',
21
+ ];
22
+ const coloredLogo = logo.map(line => chalk_1.default.hex('#2E8B57')(line));
23
+ async function showBanner() {
24
+ const width = 70;
25
+ // Intentar cargar credenciales
26
+ let credentials = null;
27
+ try {
28
+ credentials = await (0, credentials_1.getStoredCredentials)();
29
+ }
30
+ catch {
31
+ // No hay credenciales guardadas
32
+ }
33
+ console.log();
34
+ console.log(chalk_1.default.hex('#4CAF50')('─'.repeat(width)));
35
+ console.log();
36
+ // Layout de 2 columnas
37
+ const leftWidth = 30;
38
+ const rightStart = leftWidth + 4;
39
+ // Línea del título
40
+ const title = chalk_1.default.bold.hex('#4CAF50')(` Plazbot CLI v${VERSION}`);
41
+ // Info columna derecha
42
+ const rightColumn = [];
43
+ if (credentials) {
44
+ rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Workspace conectado'));
45
+ rightColumn.push(chalk_1.default.gray(` ${credentials.workspace || 'N/A'}`));
46
+ rightColumn.push(chalk_1.default.gray(` ${credentials.email || ''}`));
47
+ rightColumn.push(chalk_1.default.gray(` Zona: ${credentials.zone || 'N/A'}`));
48
+ rightColumn.push('');
49
+ rightColumn.push(chalk_1.default.hex('#4CAF50')('─'.repeat(35)));
50
+ rightColumn.push('');
51
+ rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Comandos rapidos'));
52
+ rightColumn.push(chalk_1.default.white(' plazbot agent list'));
53
+ rightColumn.push(chalk_1.default.white(' plazbot agent create'));
54
+ rightColumn.push(chalk_1.default.white(' plazbot agent chat -a <id>'));
55
+ rightColumn.push(chalk_1.default.white(' plazbot whatsapp send-message'));
56
+ }
57
+ else {
58
+ rightColumn.push(chalk_1.default.bold.hex('#FFA726')('No conectado'));
59
+ rightColumn.push('');
60
+ rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Para comenzar'));
61
+ rightColumn.push(chalk_1.default.white(' plazbot init -e <email> -k <key> -w <workspace> -z <zone>'));
62
+ rightColumn.push('');
63
+ rightColumn.push(chalk_1.default.hex('#4CAF50')('─'.repeat(35)));
64
+ rightColumn.push('');
65
+ rightColumn.push(chalk_1.default.bold.hex('#4CAF50')('Documentacion'));
66
+ rightColumn.push(chalk_1.default.gray(' https://docs.plazbot.com'));
67
+ }
68
+ // Imprimir título
69
+ console.log(title);
70
+ console.log();
71
+ // Imprimir logo + info lado a lado
72
+ const maxLines = Math.max(coloredLogo.length, rightColumn.length);
73
+ for (let i = 0; i < maxLines; i++) {
74
+ const left = i < coloredLogo.length ? coloredLogo[i] : ' '.repeat(leftWidth);
75
+ const right = i < rightColumn.length ? rightColumn[i] : '';
76
+ // Pad left column
77
+ const paddedLeft = left.replace(/\x1b\[[0-9;]*m/g, '');
78
+ const padding = ' '.repeat(Math.max(0, leftWidth - paddedLeft.length));
79
+ console.log(`${left}${padding} ${right}`);
80
+ }
81
+ console.log();
82
+ console.log(chalk_1.default.hex('#4CAF50')('─'.repeat(width)));
83
+ console.log();
84
+ }
85
+ function showMiniHeader(command) {
86
+ console.log(chalk_1.default.hex('#4CAF50')(`\n Plazbot`) + chalk_1.default.gray(` > ${command}\n`));
87
+ }
@@ -1,24 +1,45 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.logger = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
4
8
  exports.logger = {
5
9
  info: (message) => {
6
- console.log(message);
10
+ console.log(chalk_1.default.white(message));
7
11
  },
8
12
  success: (message) => {
9
- console.log(`\n ${message}`);
13
+ console.log(chalk_1.default.hex('#66BB6A')(`\n ${message}`));
10
14
  },
11
15
  warning: (message) => {
12
- console.log(`\n⚠️ ${message}`);
16
+ console.log(chalk_1.default.hex('#FFA726')(`\n ${message}`));
13
17
  },
14
18
  error: (error) => {
15
19
  const message = error instanceof Error ? error.message : error;
16
- console.error(`\n Error: ${message}`);
20
+ console.error(chalk_1.default.hex('#EF5350')(`\n Error: ${message}`));
17
21
  },
18
22
  divider: (length = 50) => {
19
- console.log('─'.repeat(length));
23
+ console.log(chalk_1.default.gray('─'.repeat(length)));
20
24
  },
21
25
  doubleDivider: (length = 50) => {
22
- console.log('═'.repeat(length));
26
+ console.log(chalk_1.default.gray('═'.repeat(length)));
27
+ },
28
+ label: (key, value) => {
29
+ console.log(` ${chalk_1.default.gray(key + ':')} ${chalk_1.default.white(value)}`);
30
+ },
31
+ title: (text) => {
32
+ console.log(chalk_1.default.bold.hex('#4CAF50')(`\n ${text}`));
33
+ console.log(chalk_1.default.gray(' ' + '─'.repeat(40)));
34
+ },
35
+ dim: (message) => {
36
+ console.log(chalk_1.default.gray(` ${message}`));
37
+ },
38
+ json: (data) => {
39
+ const formatted = JSON.stringify(data, null, 2)
40
+ .split('\n')
41
+ .map(line => ' ' + line)
42
+ .join('\n');
43
+ console.log(chalk_1.default.gray(formatted));
23
44
  }
24
45
  };
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.theme = void 0;
7
+ exports.createSpinner = createSpinner;
8
+ exports.createTable = createTable;
9
+ exports.box = box;
10
+ exports.formatDate = formatDate;
11
+ exports.statusBadge = statusBadge;
12
+ exports.kvPair = kvPair;
13
+ exports.section = section;
14
+ exports.progressBar = progressBar;
15
+ const chalk_1 = __importDefault(require("chalk"));
16
+ const ora_1 = __importDefault(require("ora"));
17
+ const cli_table3_1 = __importDefault(require("cli-table3"));
18
+ // Colores del tema Plazbot
19
+ exports.theme = {
20
+ primary: chalk_1.default.hex('#4CAF50'),
21
+ secondary: chalk_1.default.hex('#2196F3'),
22
+ accent: chalk_1.default.hex('#FFA726'),
23
+ success: chalk_1.default.hex('#66BB6A'),
24
+ error: chalk_1.default.hex('#EF5350'),
25
+ warning: chalk_1.default.hex('#FFA726'),
26
+ muted: chalk_1.default.gray,
27
+ bold: chalk_1.default.bold,
28
+ dim: chalk_1.default.dim,
29
+ };
30
+ // Spinner
31
+ function createSpinner(text) {
32
+ return (0, ora_1.default)({
33
+ text: exports.theme.muted(text),
34
+ spinner: 'dots',
35
+ color: 'green',
36
+ });
37
+ }
38
+ // Tabla formateada
39
+ function createTable(headers, rows) {
40
+ const table = new cli_table3_1.default({
41
+ head: headers.map(h => exports.theme.bold.hex('#4CAF50')(h)),
42
+ style: {
43
+ head: [],
44
+ border: ['gray'],
45
+ },
46
+ chars: {
47
+ 'top': '─', 'top-mid': '┬', 'top-left': '┌', 'top-right': '┐',
48
+ 'bottom': '─', 'bottom-mid': '┴', 'bottom-left': '└', 'bottom-right': '┘',
49
+ 'left': '│', 'left-mid': '├', 'mid': '─', 'mid-mid': '┼',
50
+ 'right': '│', 'right-mid': '┤', 'middle': '│'
51
+ }
52
+ });
53
+ rows.forEach(row => table.push(row));
54
+ return table.toString();
55
+ }
56
+ // Box simple
57
+ function box(content, title) {
58
+ const lines = content.split('\n');
59
+ const maxLen = Math.max(...lines.map(l => stripAnsi(l).length), title ? stripAnsi(title).length + 4 : 0);
60
+ const width = maxLen + 4;
61
+ let result = '';
62
+ if (title) {
63
+ result += exports.theme.muted(' ┌─ ') + exports.theme.primary(title) + exports.theme.muted(' ' + '─'.repeat(Math.max(0, width - stripAnsi(title).length - 5))) + exports.theme.muted('┐') + '\n';
64
+ }
65
+ else {
66
+ result += exports.theme.muted(' ┌' + '─'.repeat(width) + '┐') + '\n';
67
+ }
68
+ for (const line of lines) {
69
+ const pad = ' '.repeat(Math.max(0, maxLen - stripAnsi(line).length));
70
+ result += exports.theme.muted(' │') + ' ' + line + pad + ' ' + exports.theme.muted('│') + '\n';
71
+ }
72
+ result += exports.theme.muted(' └' + '─'.repeat(width) + '┘');
73
+ return result;
74
+ }
75
+ // Strip ANSI codes para calcular longitud real
76
+ function stripAnsi(str) {
77
+ return str.replace(/\x1b\[[0-9;]*m/g, '');
78
+ }
79
+ // Formato de fecha legible
80
+ function formatDate(date) {
81
+ const d = new Date(date);
82
+ return d.toLocaleDateString('es-ES', {
83
+ year: 'numeric',
84
+ month: 'short',
85
+ day: 'numeric',
86
+ hour: '2-digit',
87
+ minute: '2-digit'
88
+ });
89
+ }
90
+ // Status badge
91
+ function statusBadge(enabled) {
92
+ return enabled
93
+ ? exports.theme.success('● activo')
94
+ : exports.theme.error('○ inactivo');
95
+ }
96
+ // Key-value pair formateado
97
+ function kvPair(key, value) {
98
+ return ` ${exports.theme.muted(key + ':')} ${value}`;
99
+ }
100
+ // Sección con título
101
+ function section(title) {
102
+ return '\n' + exports.theme.bold.hex('#4CAF50')(` ${title}`) + '\n' + exports.theme.muted(' ' + '─'.repeat(40));
103
+ }
104
+ // Progress bar simple
105
+ function progressBar(current, total, width = 30) {
106
+ const percent = Math.round((current / total) * 100);
107
+ const filled = Math.round((current / total) * width);
108
+ const empty = width - filled;
109
+ const bar = exports.theme.success('█'.repeat(filled)) + exports.theme.muted('░'.repeat(empty));
110
+ return `${bar} ${exports.theme.bold(percent + '%')} (${current}/${total})`;
111
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plazbot-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI para Plazbot SDK",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
@@ -33,9 +33,17 @@
33
33
  "dependencies": {
34
34
  "@types/inquirer": "^9.0.8",
35
35
  "axios": "^1.6.0",
36
+ "boxen": "^5.1.2",
37
+ "chalk": "^4.1.2",
38
+ "cli-table3": "^0.6.5",
36
39
  "commander": "^12.0.0",
40
+ "figures": "^3.2.0",
41
+ "gradient-string": "^2.0.2",
37
42
  "inquirer": "^12.6.3",
38
- "plazbot": "^1.1.3"
43
+ "marked": "^12.0.2",
44
+ "marked-terminal": "^7.2.1",
45
+ "ora": "^5.4.1",
46
+ "plazbot": "^1.1.7"
39
47
  },
40
48
  "devDependencies": {
41
49
  "@types/node": "^20.0.0",