plazbot-cli 0.1.3 → 0.2.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/.claude/settings.local.json +15 -0
- package/CLAUDE.md +92 -0
- package/README.md +1 -1
- package/dist/cli.js +14 -5
- package/dist/commands/agent/ai-config.js +103 -0
- package/dist/commands/agent/chat.js +130 -34
- package/dist/commands/agent/copy.js +37 -0
- package/dist/commands/agent/create.js +80 -17
- package/dist/commands/agent/delete.js +3 -3
- package/dist/commands/agent/enable-widget.js +1 -1
- package/dist/commands/agent/files.js +142 -0
- package/dist/commands/agent/get.js +1 -2
- package/dist/commands/agent/index.js +14 -2
- package/dist/commands/agent/list.js +6 -6
- package/dist/commands/agent/set.js +127 -0
- package/dist/commands/agent/templates.js +803 -0
- package/dist/commands/agent/tools.js +155 -0
- package/dist/commands/agent/wizard.js +369 -0
- package/dist/commands/portal/add-agent.js +4 -4
- package/dist/commands/portal/list.js +5 -4
- package/dist/commands/whatsapp/broadcast.js +97 -0
- package/dist/commands/whatsapp/channels.js +86 -0
- package/dist/commands/whatsapp/chat.js +74 -0
- package/dist/commands/whatsapp/index.js +11 -2
- package/dist/commands/whatsapp/send-template.js +51 -14
- package/dist/commands/whatsapp/send.js +10 -10
- package/dist/commands/whatsapp/widget.js +64 -0
- package/dist/utils/banner.js +87 -0
- package/dist/utils/logger.js +27 -6
- package/dist/utils/ui.js +111 -0
- package/package.json +10 -2
- package/src/cli.ts +13 -5
- package/src/commands/agent/ai-config.ts +108 -0
- package/src/commands/agent/chat.ts +149 -40
- package/src/commands/agent/copy.ts +40 -0
- package/src/commands/agent/create.ts +58 -23
- package/src/commands/agent/delete.ts +3 -3
- package/src/commands/agent/enable-widget.ts +1 -1
- package/src/commands/agent/files.ts +158 -0
- package/src/commands/agent/get.ts +1 -2
- package/src/commands/agent/index.ts +14 -2
- package/src/commands/agent/list.ts +7 -7
- package/src/commands/agent/set.ts +137 -0
- package/src/commands/agent/templates.ts +843 -0
- package/src/commands/agent/tools.ts +161 -0
- package/src/commands/agent/wizard.ts +475 -0
- package/src/commands/portal/add-agent.ts +4 -4
- package/src/commands/portal/list.ts +5 -4
- package/src/commands/whatsapp/broadcast.ts +100 -0
- package/src/commands/whatsapp/channels.ts +98 -0
- package/src/commands/whatsapp/chat.ts +77 -0
- package/src/commands/whatsapp/index.ts +11 -2
- package/src/commands/whatsapp/send-template.ts +57 -19
- package/src/commands/whatsapp/send.ts +15 -14
- package/src/commands/whatsapp/widget.ts +67 -0
- package/src/utils/banner.ts +94 -0
- package/src/utils/logger.ts +26 -7
- package/src/utils/ui.ts +109 -0
- package/dist/commands/message/delete-webhook.js +0 -39
- package/dist/commands/message/index.js +0 -14
- package/dist/commands/message/register-webhook.js +0 -42
- package/dist/commands/message/send-template.js +0 -42
- package/dist/commands/message/send.js +0 -42
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Agent } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials';
|
|
4
|
+
import { logger } from '../../utils/logger';
|
|
5
|
+
import { createSpinner, createTable, theme, section, statusBadge } from '../../utils/ui';
|
|
6
|
+
import { AgentCommandOptions } from '../../types/agent';
|
|
7
|
+
|
|
8
|
+
const filesGroup = new Command('files')
|
|
9
|
+
.description('Gestionar archivos de la base de conocimiento del agente');
|
|
10
|
+
|
|
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: string, options: AgentCommandOptions) => {
|
|
17
|
+
try {
|
|
18
|
+
const credentials = await getStoredCredentials();
|
|
19
|
+
const agent = new Agent({
|
|
20
|
+
workspaceId: credentials.workspace,
|
|
21
|
+
apiKey: credentials.apiKey,
|
|
22
|
+
zone: credentials.zone,
|
|
23
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const spinner = createSpinner('Cargando archivos...');
|
|
27
|
+
spinner.start();
|
|
28
|
+
const agentData = await agent.getAgentById({ id: agentId });
|
|
29
|
+
spinner.stop();
|
|
30
|
+
|
|
31
|
+
const files = (agentData as any).files || [];
|
|
32
|
+
console.log(section('Archivos - ' + (agentData.name || agentId)));
|
|
33
|
+
|
|
34
|
+
if (files.length === 0) {
|
|
35
|
+
console.log(theme.muted('\n No hay archivos en la base de conocimiento'));
|
|
36
|
+
console.log(theme.muted(' Usa: plazbot agent files add <agentId> --url <url>\n'));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const rows = files.map((f: any) => [
|
|
41
|
+
f.fileId || f.id || 'N/A',
|
|
42
|
+
f.name || f.reference || 'Sin nombre',
|
|
43
|
+
(f.tags || []).join(', ') || '-',
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
console.log(createTable(['ID', 'Nombre', 'Tags'], rows));
|
|
47
|
+
|
|
48
|
+
} catch (error) {
|
|
49
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
50
|
+
logger.error(message);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Agregar archivo
|
|
56
|
+
filesGroup.command('add')
|
|
57
|
+
.description('Agregar archivo a la base de conocimiento')
|
|
58
|
+
.argument('<agentId>', 'ID del agente')
|
|
59
|
+
.requiredOption('-u, --url <url>', 'URL del archivo (PDF, DOC, DOCX)')
|
|
60
|
+
.option('-r, --reference <name>', 'Nombre de referencia', 'documento')
|
|
61
|
+
.option('-t, --tags <tags>', 'Tags separados por coma', '')
|
|
62
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
63
|
+
.action(async (agentId: string, options: any) => {
|
|
64
|
+
try {
|
|
65
|
+
const credentials = await getStoredCredentials();
|
|
66
|
+
const agent = new Agent({
|
|
67
|
+
workspaceId: credentials.workspace,
|
|
68
|
+
apiKey: credentials.apiKey,
|
|
69
|
+
zone: credentials.zone,
|
|
70
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const spinner = createSpinner('Subiendo archivo...');
|
|
74
|
+
spinner.start();
|
|
75
|
+
|
|
76
|
+
const tags = options.tags ? options.tags.split(',').map((t: string) => t.trim()) : [];
|
|
77
|
+
const result = await agent.addFile({
|
|
78
|
+
fileUrl: options.url,
|
|
79
|
+
reference: options.reference,
|
|
80
|
+
agentId,
|
|
81
|
+
tags,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
spinner.succeed('Archivo agregado');
|
|
85
|
+
|
|
86
|
+
if (result?.fileId) {
|
|
87
|
+
logger.label('File ID', result.fileId);
|
|
88
|
+
logger.dim('El archivo esta siendo procesado. Verifica con:');
|
|
89
|
+
logger.dim(`plazbot agent files status ${result.fileId}`);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
} catch (error) {
|
|
93
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
94
|
+
logger.error(message);
|
|
95
|
+
process.exit(1);
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Verificar estado
|
|
100
|
+
filesGroup.command('status')
|
|
101
|
+
.description('Verificar estado de procesamiento de un archivo')
|
|
102
|
+
.argument('<fileId>', 'ID del archivo')
|
|
103
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
104
|
+
.action(async (fileId: string, options: AgentCommandOptions) => {
|
|
105
|
+
try {
|
|
106
|
+
const credentials = await getStoredCredentials();
|
|
107
|
+
const agent = new Agent({
|
|
108
|
+
workspaceId: credentials.workspace,
|
|
109
|
+
apiKey: credentials.apiKey,
|
|
110
|
+
zone: credentials.zone,
|
|
111
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const spinner = createSpinner('Verificando...');
|
|
115
|
+
spinner.start();
|
|
116
|
+
const result = await agent.validateFile({ fileId });
|
|
117
|
+
spinner.stop();
|
|
118
|
+
|
|
119
|
+
logger.title('Estado del archivo');
|
|
120
|
+
logger.label('File ID', fileId);
|
|
121
|
+
logger.label('Estado', result?.status ? 'Completado' : 'En proceso');
|
|
122
|
+
|
|
123
|
+
} catch (error) {
|
|
124
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
125
|
+
logger.error(message);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Eliminar archivo
|
|
131
|
+
filesGroup.command('delete')
|
|
132
|
+
.description('Eliminar archivo de la base de conocimiento')
|
|
133
|
+
.argument('<agentId>', 'ID del agente')
|
|
134
|
+
.argument('<fileId>', 'ID del archivo')
|
|
135
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
136
|
+
.action(async (agentId: string, fileId: string, options: AgentCommandOptions) => {
|
|
137
|
+
try {
|
|
138
|
+
const credentials = await getStoredCredentials();
|
|
139
|
+
const agent = new Agent({
|
|
140
|
+
workspaceId: credentials.workspace,
|
|
141
|
+
apiKey: credentials.apiKey,
|
|
142
|
+
zone: credentials.zone,
|
|
143
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const spinner = createSpinner('Eliminando archivo...');
|
|
147
|
+
spinner.start();
|
|
148
|
+
await agent.deleteFile({ fileId, agentId });
|
|
149
|
+
spinner.succeed('Archivo eliminado');
|
|
150
|
+
|
|
151
|
+
} catch (error) {
|
|
152
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
153
|
+
logger.error(message);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
export const filesCommand = filesGroup;
|
|
@@ -22,8 +22,7 @@ export const getCommand = new Command('get')
|
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
// Obtener detalles del agente
|
|
25
|
-
const
|
|
26
|
-
const agentData = agentDetails.agent;
|
|
25
|
+
const agentData = await agent.getAgentById({ id: agentId });
|
|
27
26
|
|
|
28
27
|
logger.info('\nDetalles del Agente:');
|
|
29
28
|
logger.doubleDivider();
|
|
@@ -7,9 +7,15 @@ import { updateCommand } from './update';
|
|
|
7
7
|
import { enableCommand } from './enable-widget';
|
|
8
8
|
import { chatCommand } from './chat';
|
|
9
9
|
import { messageCommand } from './on-message';
|
|
10
|
+
import { toolsCommand } from './tools';
|
|
11
|
+
import { aiConfigCommand } from './ai-config';
|
|
12
|
+
import { templatesCommand } from './templates';
|
|
13
|
+
import { copyCommand } from './copy';
|
|
14
|
+
import { filesCommand } from './files';
|
|
15
|
+
import { setCommand } from './set';
|
|
10
16
|
|
|
11
17
|
export const agentCommands = new Command('agent')
|
|
12
|
-
.description('Comandos relacionados con agentes')
|
|
18
|
+
.description('Comandos relacionados con agentes de IA')
|
|
13
19
|
.addCommand(listCommand)
|
|
14
20
|
.addCommand(getCommand)
|
|
15
21
|
.addCommand(deleteCommand)
|
|
@@ -17,4 +23,10 @@ export const agentCommands = new Command('agent')
|
|
|
17
23
|
.addCommand(updateCommand)
|
|
18
24
|
.addCommand(enableCommand)
|
|
19
25
|
.addCommand(chatCommand)
|
|
20
|
-
.addCommand(messageCommand)
|
|
26
|
+
.addCommand(messageCommand)
|
|
27
|
+
.addCommand(toolsCommand)
|
|
28
|
+
.addCommand(aiConfigCommand)
|
|
29
|
+
.addCommand(templatesCommand)
|
|
30
|
+
.addCommand(copyCommand)
|
|
31
|
+
.addCommand(filesCommand)
|
|
32
|
+
.addCommand(setCommand);
|
|
@@ -2,7 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { Agent } from 'plazbot';
|
|
3
3
|
import { getStoredCredentials } from '../../utils/credentials';
|
|
4
4
|
import { logger } from '../../utils/logger';
|
|
5
|
-
import { ListAgentsOptions
|
|
5
|
+
import { ListAgentsOptions } from '../../types/agent';
|
|
6
6
|
|
|
7
7
|
export const listCommand = new Command('list')
|
|
8
8
|
.description('Lista todos los agentes del workspace')
|
|
@@ -31,12 +31,12 @@ export const listCommand = new Command('list')
|
|
|
31
31
|
logger.info('\nLista de Agentes:');
|
|
32
32
|
logger.doubleDivider();
|
|
33
33
|
|
|
34
|
-
agents.forEach((
|
|
35
|
-
logger.info(`${index + 1}. ID: ${
|
|
36
|
-
logger.info(` Nombre: ${
|
|
37
|
-
logger.info(` Estado: ${
|
|
38
|
-
logger.info(` Descripción: ${
|
|
39
|
-
logger.info(` Creado: ${new Date(
|
|
34
|
+
agents.forEach((a: any, index: number) => {
|
|
35
|
+
logger.info(`${index + 1}. ID: ${a.id}`);
|
|
36
|
+
logger.info(` Nombre: ${a.name}`);
|
|
37
|
+
logger.info(` Estado: ${a.enable ? '✅ Activo' : '❌ Inactivo'}`);
|
|
38
|
+
logger.info(` Descripción: ${a.description}`);
|
|
39
|
+
logger.info(` Creado: ${a.createdAt ? new Date(a.createdAt).toLocaleString() : 'N/A'}`);
|
|
40
40
|
logger.divider();
|
|
41
41
|
});
|
|
42
42
|
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Agent } from 'plazbot';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { getStoredCredentials } from '../../utils/credentials';
|
|
5
|
+
import { logger } from '../../utils/logger';
|
|
6
|
+
import { createSpinner, theme, section, kvPair } from '../../utils/ui';
|
|
7
|
+
import { AgentCommandOptions } from '../../types/agent';
|
|
8
|
+
|
|
9
|
+
const setGroup = new Command('set')
|
|
10
|
+
.description('Configurar rapidamente propiedades del agente');
|
|
11
|
+
|
|
12
|
+
// Set greeting
|
|
13
|
+
setGroup.command('greeting')
|
|
14
|
+
.description('Cambiar el saludo del agente')
|
|
15
|
+
.argument('<agentId>', 'ID del agente')
|
|
16
|
+
.argument('<greeting>', 'Nuevo saludo')
|
|
17
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
18
|
+
.action(async (agentId: string, greeting: string, options: AgentCommandOptions) => {
|
|
19
|
+
try {
|
|
20
|
+
const credentials = await getStoredCredentials();
|
|
21
|
+
const agent = new Agent({
|
|
22
|
+
workspaceId: credentials.workspace,
|
|
23
|
+
apiKey: credentials.apiKey,
|
|
24
|
+
zone: credentials.zone,
|
|
25
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const spinner = createSpinner('Actualizando saludo...');
|
|
29
|
+
spinner.start();
|
|
30
|
+
await agent.setGreeting(agentId, greeting);
|
|
31
|
+
spinner.succeed('Saludo actualizado');
|
|
32
|
+
logger.label('Nuevo saludo', greeting);
|
|
33
|
+
|
|
34
|
+
} catch (error) {
|
|
35
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
36
|
+
logger.error(message);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Set instructions (wizard)
|
|
42
|
+
setGroup.command('instructions')
|
|
43
|
+
.description('Configurar instrucciones del agente')
|
|
44
|
+
.argument('<agentId>', 'ID del agente')
|
|
45
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
46
|
+
.action(async (agentId: string, options: AgentCommandOptions) => {
|
|
47
|
+
try {
|
|
48
|
+
const credentials = await getStoredCredentials();
|
|
49
|
+
const agent = new Agent({
|
|
50
|
+
workspaceId: credentials.workspace,
|
|
51
|
+
apiKey: credentials.apiKey,
|
|
52
|
+
zone: credentials.zone,
|
|
53
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Cargar instrucciones actuales
|
|
57
|
+
const loadSpinner = createSpinner('Cargando...');
|
|
58
|
+
loadSpinner.start();
|
|
59
|
+
const agentData = await agent.getAgentById({ id: agentId });
|
|
60
|
+
loadSpinner.stop();
|
|
61
|
+
|
|
62
|
+
const current = agentData.instructions || {};
|
|
63
|
+
console.log(section('Instrucciones - ' + (agentData.name || agentId)));
|
|
64
|
+
|
|
65
|
+
const answers = await (inquirer as any).prompt([
|
|
66
|
+
{ type: 'list', name: 'tone', message: 'Tono:', choices: ['profesional', 'amigable', 'formal', 'casual', 'tecnico', 'empatico'], default: current.tone || 'profesional' },
|
|
67
|
+
{ type: 'list', name: 'style', message: 'Estilo:', choices: ['conciso', 'detallado', 'conversacional', 'directo'], default: current.style || 'conciso' },
|
|
68
|
+
{ type: 'input', name: 'personality', message: 'Personalidad:', default: current.personality || '' },
|
|
69
|
+
{ type: 'input', name: 'objective', message: 'Objetivo:', default: current.objective || '' },
|
|
70
|
+
{ type: 'list', name: 'language', message: 'Idioma:', choices: ['Espanol', 'English', 'Portugues'], default: current.language || 'Espanol' },
|
|
71
|
+
{ type: 'confirm', name: 'emojis', message: 'Usar emojis?', default: current.emojis === true },
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
const instructions = {
|
|
75
|
+
...current,
|
|
76
|
+
tone: answers.tone,
|
|
77
|
+
style: answers.style,
|
|
78
|
+
personality: answers.personality,
|
|
79
|
+
objective: answers.objective,
|
|
80
|
+
language: answers.language,
|
|
81
|
+
emojis: answers.emojis,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const spinner = createSpinner('Guardando instrucciones...');
|
|
85
|
+
spinner.start();
|
|
86
|
+
await agent.setInstructions(agentId, instructions);
|
|
87
|
+
spinner.succeed('Instrucciones actualizadas');
|
|
88
|
+
|
|
89
|
+
} catch (error) {
|
|
90
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
91
|
+
logger.error(message);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// Set persona (wizard)
|
|
97
|
+
setGroup.command('persona')
|
|
98
|
+
.description('Configurar la persona del agente')
|
|
99
|
+
.argument('<agentId>', 'ID del agente')
|
|
100
|
+
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
101
|
+
.action(async (agentId: string, options: AgentCommandOptions) => {
|
|
102
|
+
try {
|
|
103
|
+
const credentials = await getStoredCredentials();
|
|
104
|
+
const agent = new Agent({
|
|
105
|
+
workspaceId: credentials.workspace,
|
|
106
|
+
apiKey: credentials.apiKey,
|
|
107
|
+
zone: credentials.zone,
|
|
108
|
+
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const loadSpinner = createSpinner('Cargando...');
|
|
112
|
+
loadSpinner.start();
|
|
113
|
+
const agentData = await agent.getAgentById({ id: agentId });
|
|
114
|
+
loadSpinner.stop();
|
|
115
|
+
|
|
116
|
+
const current = agentData.person || {};
|
|
117
|
+
console.log(section('Persona - ' + (agentData.name || agentId)));
|
|
118
|
+
|
|
119
|
+
const answers = await (inquirer as any).prompt([
|
|
120
|
+
{ type: 'input', name: 'name', message: 'Nombre del personaje:', default: current.name || '' },
|
|
121
|
+
{ type: 'input', name: 'role', message: 'Rol:', default: current.role || '' },
|
|
122
|
+
{ type: 'confirm', name: 'speaksInFirstPerson', message: 'Hablar en primera persona?', default: current.speaksInFirstPerson !== false },
|
|
123
|
+
]);
|
|
124
|
+
|
|
125
|
+
const spinner = createSpinner('Guardando persona...');
|
|
126
|
+
spinner.start();
|
|
127
|
+
await agent.setPersona(agentId, answers);
|
|
128
|
+
spinner.succeed('Persona actualizada');
|
|
129
|
+
|
|
130
|
+
} catch (error) {
|
|
131
|
+
const message = error instanceof Error ? error.message : 'Error desconocido';
|
|
132
|
+
logger.error(message);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
export const setCommand = setGroup;
|