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
@@ -1,4 +1,37 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
37
  };
@@ -8,14 +41,15 @@ const commander_1 = require("commander");
8
41
  const plazbot_1 = require("plazbot");
9
42
  const credentials_1 = require("../../utils/credentials");
10
43
  const logger_1 = require("../../utils/logger");
44
+ const ui_1 = require("../../utils/ui");
45
+ const wizard_1 = require("./wizard");
11
46
  const promises_1 = __importDefault(require("fs/promises"));
12
47
  exports.createCommand = new commander_1.Command('create')
13
- .description('Crea un nuevo agente en Plazbot usando el archivo de configuración')
14
- .argument('<configPath>', 'Ruta al archivo de configuración JSON')
48
+ .description('Crea un nuevo agente de IA (wizard interactivo o archivo JSON)')
49
+ .argument('[configPath]', 'Ruta al archivo de configuracion JSON (opcional)')
15
50
  .option('--dev', 'Usar ambiente de desarrollo', false)
16
51
  .action(async (configPath, options) => {
17
52
  try {
18
- // Obtener credenciales guardadas
19
53
  const credentials = await (0, credentials_1.getStoredCredentials)();
20
54
  const agent = new plazbot_1.Agent({
21
55
  workspaceId: credentials.workspace,
@@ -23,25 +57,54 @@ exports.createCommand = new commander_1.Command('create')
23
57
  zone: credentials.zone,
24
58
  ...(options.dev && { customUrl: "http://localhost:5090" })
25
59
  });
26
- // Leer archivo de configuración
27
60
  let agentConfig;
28
- try {
29
- const fileContent = await promises_1.default.readFile(configPath, 'utf-8');
30
- agentConfig = JSON.parse(fileContent);
61
+ if (configPath) {
62
+ // Modo archivo: leer JSON
63
+ try {
64
+ const fileContent = await promises_1.default.readFile(configPath, 'utf-8');
65
+ agentConfig = JSON.parse(fileContent);
66
+ }
67
+ catch (error) {
68
+ const errorMessage = error instanceof Error ? error.message : 'Error desconocido';
69
+ throw new Error(`Error al leer el archivo de configuracion: ${errorMessage}`);
70
+ }
71
+ logger_1.logger.title('Creando agente desde archivo');
72
+ logger_1.logger.json(agentConfig);
31
73
  }
32
- catch (error) {
33
- const errorMessage = error instanceof Error ? error.message : 'Error desconocido';
34
- throw new Error(`Error al leer el archivo de configuración: ${errorMessage}`);
74
+ else {
75
+ // Modo wizard interactivo
76
+ agentConfig = await (0, wizard_1.runAgentWizard)(credentials.zone);
77
+ const inquirer = await Promise.resolve().then(() => __importStar(require('inquirer')));
78
+ const { confirm } = await inquirer.default.prompt([{
79
+ type: 'confirm',
80
+ name: 'confirm',
81
+ message: 'Crear el agente con esta configuracion?',
82
+ default: true,
83
+ }]);
84
+ if (!confirm) {
85
+ logger_1.logger.warning('Creacion cancelada');
86
+ return;
87
+ }
35
88
  }
36
- logger_1.logger.info('\n🤖 Creando nuevo agente...');
37
- logger_1.logger.info('Configuración:');
38
- logger_1.logger.info(JSON.stringify(agentConfig, null, 2));
89
+ const spinner = (0, ui_1.createSpinner)('Creando agente...');
90
+ spinner.start();
39
91
  const result = await agent.addAgent(agentConfig);
40
- logger_1.logger.success('Agente creado exitosamente');
41
- logger_1.logger.info('\n📋 Detalles del agente:');
42
- logger_1.logger.info(JSON.stringify(result, null, 2));
92
+ spinner.succeed('Agente creado exitosamente');
93
+ logger_1.logger.title('Detalles del agente');
94
+ if (result.agentId) {
95
+ logger_1.logger.label('ID', result.agentId);
96
+ }
97
+ if (agentConfig.name) {
98
+ logger_1.logger.label('Nombre', agentConfig.name);
99
+ }
100
+ logger_1.logger.label('Tool Calling', agentConfig.useToolCalling ? 'Activado' : 'Desactivado');
101
+ if (agentConfig.channels && agentConfig.channels.length > 0) {
102
+ logger_1.logger.label('WhatsApp', agentConfig.channels[0].key);
103
+ }
104
+ console.log();
105
+ logger_1.logger.dim('Siguiente paso: plazbot agent chat -a ' + (result.agentId || '<agentId>'));
43
106
  if (options.dev) {
44
- logger_1.logger.warning('\nAmbiente: desarrollo');
107
+ logger_1.logger.warning('Ambiente: desarrollo');
45
108
  }
46
109
  }
47
110
  catch (error) {
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filesCommand = 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 filesGroup = new commander_1.Command('files')
10
+ .description('Gestionar archivos de la base de conocimiento del agente');
11
+ // Listar archivos
12
+ filesGroup.command('list')
13
+ .description('Listar archivos del agente')
14
+ .argument('<agentId>', 'ID del agente')
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)('Cargando archivos...');
26
+ spinner.start();
27
+ const agentData = await agent.getAgentById({ id: agentId });
28
+ spinner.stop();
29
+ const files = agentData.files || [];
30
+ console.log((0, ui_1.section)('Archivos - ' + (agentData.name || agentId)));
31
+ if (files.length === 0) {
32
+ console.log(ui_1.theme.muted('\n No hay archivos en la base de conocimiento'));
33
+ console.log(ui_1.theme.muted(' Usa: plazbot agent files add <agentId> --url <url>\n'));
34
+ return;
35
+ }
36
+ const rows = files.map((f) => [
37
+ f.fileId || f.id || 'N/A',
38
+ f.name || f.reference || 'Sin nombre',
39
+ (f.tags || []).join(', ') || '-',
40
+ ]);
41
+ console.log((0, ui_1.createTable)(['ID', 'Nombre', 'Tags'], 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
+ // Agregar archivo
50
+ filesGroup.command('add')
51
+ .description('Agregar archivo a la base de conocimiento')
52
+ .argument('<agentId>', 'ID del agente')
53
+ .requiredOption('-u, --url <url>', 'URL del archivo (PDF, DOC, DOCX)')
54
+ .option('-r, --reference <name>', 'Nombre de referencia', 'documento')
55
+ .option('-t, --tags <tags>', 'Tags separados por coma', '')
56
+ .option('--dev', 'Usar ambiente de desarrollo', false)
57
+ .action(async (agentId, options) => {
58
+ try {
59
+ const credentials = await (0, credentials_1.getStoredCredentials)();
60
+ const agent = new plazbot_1.Agent({
61
+ workspaceId: credentials.workspace,
62
+ apiKey: credentials.apiKey,
63
+ zone: credentials.zone,
64
+ ...(options.dev && { customUrl: "http://localhost:5090" })
65
+ });
66
+ const spinner = (0, ui_1.createSpinner)('Subiendo archivo...');
67
+ spinner.start();
68
+ const tags = options.tags ? options.tags.split(',').map((t) => t.trim()) : [];
69
+ const result = await agent.addFile({
70
+ fileUrl: options.url,
71
+ reference: options.reference,
72
+ agentId,
73
+ tags,
74
+ });
75
+ spinner.succeed('Archivo agregado');
76
+ if (result?.fileId || result?.id) {
77
+ logger_1.logger.label('File ID', result.fileId || result.id);
78
+ logger_1.logger.dim('El archivo esta siendo procesado. Verifica con:');
79
+ logger_1.logger.dim(`plazbot agent files status ${result.fileId || result.id}`);
80
+ }
81
+ }
82
+ catch (error) {
83
+ const message = error instanceof Error ? error.message : 'Error desconocido';
84
+ logger_1.logger.error(message);
85
+ process.exit(1);
86
+ }
87
+ });
88
+ // Verificar estado
89
+ filesGroup.command('status')
90
+ .description('Verificar estado de procesamiento de un archivo')
91
+ .argument('<fileId>', 'ID del archivo')
92
+ .option('--dev', 'Usar ambiente de desarrollo', false)
93
+ .action(async (fileId, options) => {
94
+ try {
95
+ const credentials = await (0, credentials_1.getStoredCredentials)();
96
+ const agent = new plazbot_1.Agent({
97
+ workspaceId: credentials.workspace,
98
+ apiKey: credentials.apiKey,
99
+ zone: credentials.zone,
100
+ ...(options.dev && { customUrl: "http://localhost:5090" })
101
+ });
102
+ const spinner = (0, ui_1.createSpinner)('Verificando...');
103
+ spinner.start();
104
+ const result = await agent.validateFile({ fileId });
105
+ spinner.stop();
106
+ logger_1.logger.title('Estado del archivo');
107
+ logger_1.logger.label('File ID', fileId);
108
+ logger_1.logger.label('Estado', result?.status || result?.stateId === 2 ? 'Completado' : 'En proceso');
109
+ }
110
+ catch (error) {
111
+ const message = error instanceof Error ? error.message : 'Error desconocido';
112
+ logger_1.logger.error(message);
113
+ process.exit(1);
114
+ }
115
+ });
116
+ // Eliminar archivo
117
+ filesGroup.command('delete')
118
+ .description('Eliminar archivo de la base de conocimiento')
119
+ .argument('<agentId>', 'ID del agente')
120
+ .argument('<fileId>', 'ID del archivo')
121
+ .option('--dev', 'Usar ambiente de desarrollo', false)
122
+ .action(async (agentId, fileId, options) => {
123
+ try {
124
+ const credentials = await (0, credentials_1.getStoredCredentials)();
125
+ const agent = new plazbot_1.Agent({
126
+ workspaceId: credentials.workspace,
127
+ apiKey: credentials.apiKey,
128
+ zone: credentials.zone,
129
+ ...(options.dev && { customUrl: "http://localhost:5090" })
130
+ });
131
+ const spinner = (0, ui_1.createSpinner)('Eliminando archivo...');
132
+ spinner.start();
133
+ await agent.deleteFile({ fileId, agentId });
134
+ spinner.succeed('Archivo eliminado');
135
+ }
136
+ catch (error) {
137
+ const message = error instanceof Error ? error.message : 'Error desconocido';
138
+ logger_1.logger.error(message);
139
+ process.exit(1);
140
+ }
141
+ });
142
+ exports.filesCommand = filesGroup;
@@ -10,8 +10,14 @@ const update_1 = require("./update");
10
10
  const enable_widget_1 = require("./enable-widget");
11
11
  const chat_1 = require("./chat");
12
12
  const on_message_1 = require("./on-message");
13
+ const tools_1 = require("./tools");
14
+ const ai_config_1 = require("./ai-config");
15
+ const templates_1 = require("./templates");
16
+ const copy_1 = require("./copy");
17
+ const files_1 = require("./files");
18
+ const set_1 = require("./set");
13
19
  exports.agentCommands = new commander_1.Command('agent')
14
- .description('Comandos relacionados con agentes')
20
+ .description('Comandos relacionados con agentes de IA')
15
21
  .addCommand(list_1.listCommand)
16
22
  .addCommand(get_1.getCommand)
17
23
  .addCommand(delete_1.deleteCommand)
@@ -19,4 +25,10 @@ exports.agentCommands = new commander_1.Command('agent')
19
25
  .addCommand(update_1.updateCommand)
20
26
  .addCommand(enable_widget_1.enableCommand)
21
27
  .addCommand(chat_1.chatCommand)
22
- .addCommand(on_message_1.messageCommand);
28
+ .addCommand(on_message_1.messageCommand)
29
+ .addCommand(tools_1.toolsCommand)
30
+ .addCommand(ai_config_1.aiConfigCommand)
31
+ .addCommand(templates_1.templatesCommand)
32
+ .addCommand(copy_1.copyCommand)
33
+ .addCommand(files_1.filesCommand)
34
+ .addCommand(set_1.setCommand);
@@ -0,0 +1,127 @@
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.setCommand = void 0;
7
+ const commander_1 = require("commander");
8
+ const plazbot_1 = require("plazbot");
9
+ const inquirer_1 = __importDefault(require("inquirer"));
10
+ const credentials_1 = require("../../utils/credentials");
11
+ const logger_1 = require("../../utils/logger");
12
+ const ui_1 = require("../../utils/ui");
13
+ const setGroup = new commander_1.Command('set')
14
+ .description('Configurar rapidamente propiedades del agente');
15
+ // Set greeting
16
+ setGroup.command('greeting')
17
+ .description('Cambiar el saludo del agente')
18
+ .argument('<agentId>', 'ID del agente')
19
+ .argument('<greeting>', 'Nuevo saludo')
20
+ .option('--dev', 'Usar ambiente de desarrollo', false)
21
+ .action(async (agentId, greeting, options) => {
22
+ try {
23
+ const credentials = await (0, credentials_1.getStoredCredentials)();
24
+ const agent = new plazbot_1.Agent({
25
+ workspaceId: credentials.workspace,
26
+ apiKey: credentials.apiKey,
27
+ zone: credentials.zone,
28
+ ...(options.dev && { customUrl: "http://localhost:5090" })
29
+ });
30
+ const spinner = (0, ui_1.createSpinner)('Actualizando saludo...');
31
+ spinner.start();
32
+ await agent.setGreeting(agentId, greeting);
33
+ spinner.succeed('Saludo actualizado');
34
+ logger_1.logger.label('Nuevo saludo', greeting);
35
+ }
36
+ catch (error) {
37
+ const message = error instanceof Error ? error.message : 'Error desconocido';
38
+ logger_1.logger.error(message);
39
+ process.exit(1);
40
+ }
41
+ });
42
+ // Set instructions (wizard)
43
+ setGroup.command('instructions')
44
+ .description('Configurar instrucciones del agente')
45
+ .argument('<agentId>', 'ID del agente')
46
+ .option('--dev', 'Usar ambiente de desarrollo', false)
47
+ .action(async (agentId, options) => {
48
+ try {
49
+ const credentials = await (0, credentials_1.getStoredCredentials)();
50
+ const agent = new plazbot_1.Agent({
51
+ workspaceId: credentials.workspace,
52
+ apiKey: credentials.apiKey,
53
+ zone: credentials.zone,
54
+ ...(options.dev && { customUrl: "http://localhost:5090" })
55
+ });
56
+ // Cargar instrucciones actuales
57
+ const loadSpinner = (0, ui_1.createSpinner)('Cargando...');
58
+ loadSpinner.start();
59
+ const agentData = await agent.getAgentById({ id: agentId });
60
+ loadSpinner.stop();
61
+ const current = agentData.instructions || {};
62
+ console.log((0, ui_1.section)('Instrucciones - ' + (agentData.name || agentId)));
63
+ const answers = await inquirer_1.default.prompt([
64
+ { type: 'list', name: 'tone', message: 'Tono:', choices: ['profesional', 'amigable', 'formal', 'casual', 'tecnico', 'empatico'], default: current.tone || 'profesional' },
65
+ { type: 'list', name: 'style', message: 'Estilo:', choices: ['conciso', 'detallado', 'conversacional', 'directo'], default: current.style || 'conciso' },
66
+ { type: 'input', name: 'personality', message: 'Personalidad:', default: current.personality || '' },
67
+ { type: 'input', name: 'objective', message: 'Objetivo:', default: current.objective || '' },
68
+ { type: 'list', name: 'language', message: 'Idioma:', choices: ['Espanol', 'English', 'Portugues'], default: current.language || 'Espanol' },
69
+ { type: 'confirm', name: 'useEmojis', message: 'Usar emojis?', default: current.useEmojis === 'si' },
70
+ ]);
71
+ const instructions = {
72
+ ...current,
73
+ tone: answers.tone,
74
+ style: answers.style,
75
+ personality: answers.personality,
76
+ objective: answers.objective,
77
+ language: answers.language,
78
+ useEmojis: answers.useEmojis ? 'si' : 'no',
79
+ };
80
+ const spinner = (0, ui_1.createSpinner)('Guardando instrucciones...');
81
+ spinner.start();
82
+ await agent.setInstructions(agentId, instructions);
83
+ spinner.succeed('Instrucciones actualizadas');
84
+ }
85
+ catch (error) {
86
+ const message = error instanceof Error ? error.message : 'Error desconocido';
87
+ logger_1.logger.error(message);
88
+ process.exit(1);
89
+ }
90
+ });
91
+ // Set persona (wizard)
92
+ setGroup.command('persona')
93
+ .description('Configurar la persona del agente')
94
+ .argument('<agentId>', 'ID del agente')
95
+ .option('--dev', 'Usar ambiente de desarrollo', false)
96
+ .action(async (agentId, options) => {
97
+ try {
98
+ const credentials = await (0, credentials_1.getStoredCredentials)();
99
+ const agent = new plazbot_1.Agent({
100
+ workspaceId: credentials.workspace,
101
+ apiKey: credentials.apiKey,
102
+ zone: credentials.zone,
103
+ ...(options.dev && { customUrl: "http://localhost:5090" })
104
+ });
105
+ const loadSpinner = (0, ui_1.createSpinner)('Cargando...');
106
+ loadSpinner.start();
107
+ const agentData = await agent.getAgentById({ id: agentId });
108
+ loadSpinner.stop();
109
+ const current = agentData.person || {};
110
+ console.log((0, ui_1.section)('Persona - ' + (agentData.name || agentId)));
111
+ const answers = await inquirer_1.default.prompt([
112
+ { type: 'input', name: 'name', message: 'Nombre del personaje:', default: current.name || '' },
113
+ { type: 'input', name: 'role', message: 'Rol:', default: current.role || '' },
114
+ { type: 'confirm', name: 'firstPerson', message: 'Hablar en primera persona?', default: current.firstPerson !== false },
115
+ ]);
116
+ const spinner = (0, ui_1.createSpinner)('Guardando persona...');
117
+ spinner.start();
118
+ await agent.setPersona(agentId, answers);
119
+ spinner.succeed('Persona actualizada');
120
+ }
121
+ catch (error) {
122
+ const message = error instanceof Error ? error.message : 'Error desconocido';
123
+ logger_1.logger.error(message);
124
+ process.exit(1);
125
+ }
126
+ });
127
+ exports.setCommand = setGroup;
@@ -0,0 +1,240 @@
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.templatesCommand = void 0;
7
+ const commander_1 = require("commander");
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const logger_1 = require("../../utils/logger");
10
+ const ui_1 = require("../../utils/ui");
11
+ const TEMPLATES = [
12
+ {
13
+ name: 'Asistente de Ventas',
14
+ description: 'Agente especializado en atencion al cliente y ventas',
15
+ industry: 'Ventas',
16
+ config: {
17
+ name: 'Asistente de Ventas',
18
+ prompt: 'Eres un asistente de ventas profesional y amigable. Tu objetivo es ayudar a los clientes a encontrar los productos o servicios que necesitan, responder sus preguntas y guiarlos en el proceso de compra.',
19
+ buffer: 10,
20
+ color: 'blue',
21
+ useToolCalling: true,
22
+ instructions: {
23
+ tone: 'amigable',
24
+ style: 'conversacional',
25
+ personality: 'Entusiasta y servicial',
26
+ objective: 'Ayudar al cliente a encontrar el producto ideal y cerrar la venta',
27
+ language: 'Espanol',
28
+ emojis: true,
29
+ },
30
+ person: { name: 'Ana', role: 'Asesora de ventas', speaksInFirstPerson: true },
31
+ fallbacks: {
32
+ noAnswer: 'No tengo informacion sobre eso, pero puedo conectarte con un asesor especializado.',
33
+ serviceError: 'Disculpa, estamos experimentando dificultades. Un asesor te atendera pronto.',
34
+ doNotUnderstand: 'Podrias darme mas detalles sobre lo que buscas?',
35
+ },
36
+ actions: [
37
+ { intent: 'derivar_asesor', reference: 'hablar con humano, asesor, agente', enabled: true, requiredFields: [], responseMessage: 'Te conecto con un asesor ahora mismo.', action: [{ type: 'action.agentShutDown', value: '' }] },
38
+ { intent: 'etiquetar_interesado', reference: 'interesado, quiere comprar', enabled: true, requiredFields: [], responseMessage: '', action: [{ type: 'action.tag', value: 'interesado' }] },
39
+ ],
40
+ services: [],
41
+ channels: [],
42
+ examples: [
43
+ { value: 'Usuario: Hola, quiero informacion sobre sus productos\nAgente: Hola! Con gusto te ayudo. Que tipo de producto estas buscando?', color: 'blue' },
44
+ { value: 'Usuario: Cuanto cuesta?\nAgente: El precio depende del plan que elijas. Te cuento las opciones disponibles...', color: 'blue' },
45
+ ],
46
+ tags: ['ventas', 'atencion-cliente'],
47
+ },
48
+ },
49
+ {
50
+ name: 'Soporte Tecnico IT',
51
+ description: 'Agente para soporte tecnico y resolucion de problemas',
52
+ industry: 'Tecnologia',
53
+ config: {
54
+ name: 'Soporte Tecnico',
55
+ prompt: 'Eres un agente de soporte tecnico especializado. Tu objetivo es diagnosticar problemas tecnicos, guiar al usuario paso a paso en la solucion y escalar cuando sea necesario.',
56
+ buffer: 8,
57
+ color: 'green',
58
+ useToolCalling: true,
59
+ instructions: {
60
+ tone: 'profesional',
61
+ style: 'detallado',
62
+ personality: 'Paciente y tecnico',
63
+ objective: 'Resolver problemas tecnicos del usuario de forma eficiente',
64
+ language: 'Espanol',
65
+ emojis: false,
66
+ },
67
+ person: { name: 'Carlos', role: 'Especialista de soporte', speaksInFirstPerson: true },
68
+ fallbacks: {
69
+ noAnswer: 'No puedo resolver este caso automaticamente. Voy a escalarlo a un tecnico especializado.',
70
+ serviceError: 'Hay un problema con nuestros sistemas. Un tecnico te contactara pronto.',
71
+ doNotUnderstand: 'Puedes describir el problema con mas detalle? Que mensaje de error ves?',
72
+ },
73
+ actions: [
74
+ { intent: 'escalar_ticket', reference: 'escalar, tecnico, no funciona', enabled: true, requiredFields: [], responseMessage: 'Escalando tu caso a un tecnico especializado.', action: [{ type: 'action.agentShutDown', value: '' }] },
75
+ { intent: 'etiquetar_urgente', reference: 'urgente, critico, caido', enabled: true, requiredFields: [], responseMessage: '', action: [{ type: 'action.tag', value: 'urgente' }] },
76
+ ],
77
+ services: [],
78
+ channels: [],
79
+ examples: [],
80
+ tags: ['soporte', 'IT'],
81
+ },
82
+ },
83
+ {
84
+ name: 'Asistente de Clinica',
85
+ description: 'Agente para clinicas medicas: citas, horarios e informacion',
86
+ industry: 'Salud',
87
+ config: {
88
+ name: 'Asistente de Clinica',
89
+ prompt: 'Eres un asistente virtual de una clinica medica. Tu objetivo es ayudar a los pacientes a agendar citas, consultar horarios de atencion, y proporcionar informacion general sobre los servicios de la clinica. NUNCA des diagnosticos medicos ni recomendaciones de tratamiento.',
90
+ buffer: 5,
91
+ color: 'green',
92
+ useToolCalling: true,
93
+ instructions: {
94
+ tone: 'empatico',
95
+ style: 'conciso',
96
+ personality: 'Amable y profesional',
97
+ objective: 'Facilitar la gestion de citas y brindar informacion de la clinica',
98
+ language: 'Espanol',
99
+ emojis: true,
100
+ },
101
+ person: { name: 'Sofia', role: 'Asistente de clinica', speaksInFirstPerson: true },
102
+ fallbacks: {
103
+ noAnswer: 'No tengo esa informacion. Te recomiendo llamar directamente a la clinica.',
104
+ serviceError: 'Disculpa, nuestro sistema esta temporalmente fuera de servicio.',
105
+ doNotUnderstand: 'Podrias repetir tu consulta? Estoy aqui para ayudarte con citas, horarios o informacion de la clinica.',
106
+ },
107
+ actions: [
108
+ { intent: 'derivar_recepcion', reference: 'hablar con recepcion, persona real', enabled: true, requiredFields: [], responseMessage: 'Te conecto con recepcion ahora.', action: [{ type: 'action.agentShutDown', value: '' }] },
109
+ ],
110
+ services: [],
111
+ channels: [],
112
+ examples: [],
113
+ tags: ['clinica', 'salud', 'citas'],
114
+ },
115
+ },
116
+ {
117
+ name: 'Asistente de Restaurante',
118
+ description: 'Agente para restaurantes: menu, reservas y pedidos',
119
+ industry: 'Gastronomia',
120
+ config: {
121
+ name: 'Asistente de Restaurante',
122
+ prompt: 'Eres un asistente virtual de un restaurante. Tu objetivo es ayudar a los clientes con informacion del menu, tomar reservas, informar sobre horarios de atencion y responder consultas generales sobre el restaurante.',
123
+ buffer: 5,
124
+ color: 'orange',
125
+ useToolCalling: true,
126
+ instructions: {
127
+ tone: 'amigable',
128
+ style: 'conversacional',
129
+ personality: 'Calido y entusiasta sobre la comida',
130
+ objective: 'Brindar informacion del restaurante y facilitar reservas',
131
+ language: 'Espanol',
132
+ emojis: true,
133
+ },
134
+ person: { name: 'Marco', role: 'Anfitrion virtual', speaksInFirstPerson: true },
135
+ fallbacks: {
136
+ noAnswer: 'No tengo esa informacion. Te recomiendo llamar al restaurante.',
137
+ serviceError: 'Disculpa, nuestro sistema tiene problemas. Llamanos para hacer tu reserva.',
138
+ doNotUnderstand: 'Perdon, no entendi. Puedo ayudarte con el menu, reservas u horarios.',
139
+ },
140
+ actions: [],
141
+ services: [],
142
+ channels: [],
143
+ examples: [
144
+ { value: 'Usuario: Quiero hacer una reserva\nAgente: Con gusto! Para cuantas personas y que dia tienes en mente?', color: 'orange' },
145
+ ],
146
+ tags: ['restaurante', 'reservas'],
147
+ },
148
+ },
149
+ {
150
+ name: 'Asistente Inmobiliario',
151
+ description: 'Agente para inmobiliarias: propiedades, visitas y consultas',
152
+ industry: 'Inmobiliario',
153
+ config: {
154
+ name: 'Asistente Inmobiliario',
155
+ prompt: 'Eres un asistente virtual de una inmobiliaria. Tu objetivo es ayudar a los clientes a encontrar propiedades que se ajusten a sus necesidades, agendar visitas y responder consultas sobre el proceso de compra o alquiler.',
156
+ buffer: 8,
157
+ color: 'blue',
158
+ useToolCalling: true,
159
+ instructions: {
160
+ tone: 'profesional',
161
+ style: 'detallado',
162
+ personality: 'Conocedor y confiable',
163
+ objective: 'Ayudar al cliente a encontrar la propiedad ideal',
164
+ language: 'Espanol',
165
+ emojis: true,
166
+ },
167
+ person: { name: 'Diego', role: 'Asesor inmobiliario', speaksInFirstPerson: true },
168
+ fallbacks: {
169
+ noAnswer: 'No tengo informacion sobre esa propiedad. Dejame conectarte con un asesor.',
170
+ serviceError: 'Nuestro sistema esta temporalmente fuera de servicio. Un asesor te contactara.',
171
+ doNotUnderstand: 'Podrias darme mas detalles? Que tipo de propiedad buscas?',
172
+ },
173
+ actions: [
174
+ { intent: 'derivar_asesor', reference: 'asesor, visita, contactar', enabled: true, requiredFields: [], responseMessage: 'Te conecto con un asesor inmobiliario.', action: [{ type: 'action.agentShutDown', value: '' }] },
175
+ { intent: 'etiquetar_interesado', reference: 'interesado, quiere comprar, quiere alquilar', enabled: true, requiredFields: [], responseMessage: '', action: [{ type: 'action.tag', value: 'interesado' }] },
176
+ ],
177
+ services: [],
178
+ channels: [],
179
+ examples: [],
180
+ tags: ['inmobiliario', 'propiedades'],
181
+ },
182
+ },
183
+ ];
184
+ exports.templatesCommand = new commander_1.Command('templates')
185
+ .description('Ver y usar plantillas de agentes pre-configurados')
186
+ .option('--dev', 'Usar ambiente de desarrollo', false)
187
+ .action(async () => {
188
+ try {
189
+ console.log((0, ui_1.section)('Plantillas de agentes'));
190
+ console.log(ui_1.theme.muted(' Selecciona una plantilla para crear un agente pre-configurado\n'));
191
+ const rows = TEMPLATES.map((t, i) => [
192
+ String(i + 1),
193
+ t.name,
194
+ t.industry,
195
+ t.description,
196
+ ]);
197
+ console.log((0, ui_1.createTable)(['#', 'Nombre', 'Industria', 'Descripcion'], rows));
198
+ const { selected } = await inquirer_1.default.prompt([{
199
+ type: 'list',
200
+ name: 'selected',
201
+ message: 'Selecciona una plantilla:',
202
+ choices: [
203
+ ...TEMPLATES.map((t, i) => ({ name: `${t.name} (${t.industry})`, value: i })),
204
+ { name: 'Cancelar', value: -1 },
205
+ ],
206
+ }]);
207
+ if (selected === -1)
208
+ return;
209
+ const template = TEMPLATES[selected];
210
+ console.log((0, ui_1.section)(template.name));
211
+ console.log((0, ui_1.kvPair)('Industria', template.industry));
212
+ console.log((0, ui_1.kvPair)('Descripcion', template.description));
213
+ console.log((0, ui_1.kvPair)('Tool Calling', template.config.useToolCalling ? 'Si' : 'No'));
214
+ console.log((0, ui_1.kvPair)('Acciones', String(template.config.actions.length)));
215
+ console.log((0, ui_1.kvPair)('Persona', `${template.config.person.name} - ${template.config.person.role}`));
216
+ console.log();
217
+ const { action } = await inquirer_1.default.prompt([{
218
+ type: 'list',
219
+ name: 'action',
220
+ message: 'Que deseas hacer?',
221
+ choices: [
222
+ { name: 'Crear agente con esta plantilla', value: 'create' },
223
+ { name: 'Ver JSON completo', value: 'json' },
224
+ { name: 'Cancelar', value: 'cancel' },
225
+ ],
226
+ }]);
227
+ if (action === 'json') {
228
+ logger_1.logger.json(template.config);
229
+ }
230
+ if (action === 'create') {
231
+ logger_1.logger.success(`Usa: plazbot agent create y selecciona la plantilla "${template.name}" durante el wizard`);
232
+ logger_1.logger.dim('O exporta el JSON: plazbot agent templates (selecciona Ver JSON)');
233
+ }
234
+ }
235
+ catch (error) {
236
+ const message = error instanceof Error ? error.message : 'Error desconocido';
237
+ logger_1.logger.error(message);
238
+ process.exit(1);
239
+ }
240
+ });