plazbot-cli 0.2.26 → 0.3.1
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.md +34 -5
- package/README.md +21 -0
- package/dist/cli.js +32 -20
- package/dist/commands/agent/ai-config.js +98 -50
- package/dist/commands/agent/chat.js +80 -74
- package/dist/commands/agent/copy.js +23 -21
- package/dist/commands/agent/create.js +42 -72
- package/dist/commands/agent/delete.js +29 -30
- package/dist/commands/agent/enable-widget.js +30 -26
- package/dist/commands/agent/export.js +90 -77
- package/dist/commands/agent/files.js +68 -60
- package/dist/commands/agent/get.js +101 -87
- package/dist/commands/agent/index.js +53 -39
- package/dist/commands/agent/list.js +26 -24
- package/dist/commands/agent/monitor.js +91 -86
- package/dist/commands/agent/on-message.js +40 -37
- package/dist/commands/agent/set.js +62 -59
- package/dist/commands/agent/templates.js +109 -108
- package/dist/commands/agent/tools.js +64 -65
- package/dist/commands/agent/update.js +28 -27
- package/dist/commands/agent/validate.js +127 -0
- package/dist/commands/agent/wizard.js +152 -159
- package/dist/commands/auth/index.js +7 -10
- package/dist/commands/auth/login.js +50 -37
- package/dist/commands/auth/logout.js +16 -14
- package/dist/commands/auth/status.js +19 -16
- package/dist/commands/portal/add-agent.js +26 -24
- package/dist/commands/portal/add-link.js +21 -17
- package/dist/commands/portal/clear-links.js +17 -15
- package/dist/commands/portal/create.js +25 -21
- package/dist/commands/portal/delete.js +31 -30
- package/dist/commands/portal/get.js +33 -31
- package/dist/commands/portal/index.js +30 -22
- package/dist/commands/portal/list.js +34 -30
- package/dist/commands/portal/update.js +41 -33
- package/dist/commands/whatsapp/broadcast.js +40 -37
- package/dist/commands/whatsapp/channels.js +40 -34
- package/dist/commands/whatsapp/chat.js +33 -32
- package/dist/commands/whatsapp/connect.js +53 -52
- package/dist/commands/whatsapp/delete-webhook.js +19 -17
- package/dist/commands/whatsapp/index.js +35 -25
- package/dist/commands/whatsapp/register-webhook.js +21 -19
- package/dist/commands/whatsapp/send-template.js +39 -31
- package/dist/commands/whatsapp/send.js +27 -23
- package/dist/commands/whatsapp/widget.js +35 -31
- package/dist/commands/workers/deploy.js +49 -44
- package/dist/commands/workers/index.js +28 -18
- package/dist/commands/workers/list.js +43 -35
- package/dist/commands/workers/logs.js +38 -32
- package/dist/commands/workers/remove.js +38 -37
- package/dist/commands/workers/secret.js +63 -58
- package/dist/commands/workers/test.js +44 -36
- package/dist/schemas/agent.config.schema.json +569 -0
- package/dist/studio/api/sseClient.js +97 -0
- package/dist/studio/api/studioApi.js +25 -0
- package/dist/studio/api/types.js +16 -0
- package/dist/studio/components/AgentPanel.js +35 -0
- package/dist/studio/components/App.js +214 -0
- package/dist/studio/components/ChatLog.js +59 -0
- package/dist/studio/components/Footer.js +11 -0
- package/dist/studio/components/Header.js +8 -0
- package/dist/studio/components/Input.js +15 -0
- package/dist/studio/components/Message.js +56 -0
- package/dist/studio/components/Suggestions.js +11 -0
- package/dist/studio/components/ToolCall.js +33 -0
- package/dist/studio/components/WhatsappConnectCard.js +57 -0
- package/dist/studio/index.js +42 -0
- package/dist/studio/render/json.js +16 -0
- package/dist/studio/render/markdown.js +32 -0
- package/dist/studio/render/steps.js +58 -0
- package/dist/studio/runOneShot.js +96 -0
- package/dist/studio/runRepl.js +52 -0
- package/dist/studio/slash/handlers.js +199 -0
- package/dist/studio/slash/parser.js +46 -0
- package/dist/studio/slash/registry.js +16 -0
- package/dist/studio/state/store.js +181 -0
- package/dist/studio/whatsapp/api.js +63 -0
- package/dist/studio/whatsapp/polling.js +77 -0
- package/dist/studio/whatsapp/types.js +31 -0
- package/dist/types/agent.js +1 -2
- package/dist/types/auth.js +1 -2
- package/dist/types/common.js +1 -2
- package/dist/types/message.js +1 -2
- package/dist/types/portal.js +1 -2
- package/dist/types/workers.js +1 -2
- package/dist/utils/agent-errors.js +46 -0
- package/dist/utils/api.js +8 -9
- package/dist/utils/banner.js +33 -34
- package/dist/utils/credentials.js +12 -20
- package/dist/utils/help.js +44 -0
- package/dist/utils/logger.js +13 -19
- package/dist/utils/ui.js +35 -49
- package/package.json +21 -10
- package/src/cli.ts +24 -8
- package/src/commands/agent/ai-config.ts +89 -34
- package/src/commands/agent/chat.ts +49 -37
- package/src/commands/agent/copy.ts +19 -13
- package/src/commands/agent/create.ts +32 -22
- package/src/commands/agent/delete.ts +24 -18
- package/src/commands/agent/enable-widget.ts +31 -23
- package/src/commands/agent/export.ts +72 -51
- package/src/commands/agent/files.ts +51 -39
- package/src/commands/agent/get.ts +86 -66
- package/src/commands/agent/index.ts +36 -18
- package/src/commands/agent/list.ts +22 -16
- package/src/commands/agent/monitor.ts +67 -56
- package/src/commands/agent/on-message.ts +36 -27
- package/src/commands/agent/set.ts +47 -37
- package/src/commands/agent/templates.ts +90 -82
- package/src/commands/agent/tools.ts +53 -47
- package/src/commands/agent/update.ts +28 -20
- package/src/commands/agent/validate.ts +135 -0
- package/src/commands/agent/wizard.ts +114 -114
- package/src/commands/auth/index.ts +3 -3
- package/src/commands/auth/login.ts +44 -29
- package/src/commands/auth/logout.ts +16 -10
- package/src/commands/auth/status.ts +14 -8
- package/src/commands/portal/add-agent.ts +23 -17
- package/src/commands/portal/add-link.ts +17 -9
- package/src/commands/portal/clear-links.ts +13 -7
- package/src/commands/portal/create.ts +20 -12
- package/src/commands/portal/delete.ts +28 -20
- package/src/commands/portal/get.ts +25 -19
- package/src/commands/portal/index.ts +22 -10
- package/src/commands/portal/list.ts +27 -19
- package/src/commands/portal/update.ts +38 -26
- package/src/commands/whatsapp/broadcast.ts +28 -18
- package/src/commands/whatsapp/channels.ts +31 -20
- package/src/commands/whatsapp/chat.ts +20 -12
- package/src/commands/whatsapp/connect.ts +39 -31
- package/src/commands/whatsapp/delete-webhook.ts +15 -9
- package/src/commands/whatsapp/index.ts +24 -10
- package/src/commands/whatsapp/register-webhook.ts +16 -10
- package/src/commands/whatsapp/send-template.ts +33 -21
- package/src/commands/whatsapp/send.ts +23 -15
- package/src/commands/whatsapp/widget.ts +25 -17
- package/src/commands/workers/deploy.ts +34 -22
- package/src/commands/workers/index.ts +21 -7
- package/src/commands/workers/list.ts +31 -19
- package/src/commands/workers/logs.ts +30 -20
- package/src/commands/workers/remove.ts +30 -22
- package/src/commands/workers/secret.ts +46 -34
- package/src/commands/workers/test.ts +34 -22
- package/src/schemas/agent.config.schema.json +569 -0
- package/src/studio/api/sseClient.ts +91 -0
- package/src/studio/api/studioApi.ts +27 -0
- package/src/studio/api/types.ts +96 -0
- package/src/studio/components/App.tsx +266 -0
- package/src/studio/components/ChatLog.tsx +95 -0
- package/src/studio/components/Footer.tsx +38 -0
- package/src/studio/components/Header.tsx +39 -0
- package/src/studio/components/Input.tsx +32 -0
- package/src/studio/components/Message.tsx +87 -0
- package/src/studio/components/Suggestions.tsx +26 -0
- package/src/studio/components/ToolCall.tsx +58 -0
- package/src/studio/components/WhatsappConnectCard.tsx +139 -0
- package/src/studio/index.ts +58 -0
- package/src/studio/render/markdown.ts +32 -0
- package/src/studio/render/steps.ts +57 -0
- package/src/studio/runOneShot.ts +114 -0
- package/src/studio/runRepl.tsx +76 -0
- package/src/studio/slash/handlers.ts +226 -0
- package/src/studio/slash/parser.ts +41 -0
- package/src/studio/slash/registry.ts +54 -0
- package/src/studio/state/store.ts +273 -0
- package/src/studio/whatsapp/api.ts +96 -0
- package/src/studio/whatsapp/polling.ts +93 -0
- package/src/studio/whatsapp/types.ts +80 -0
- package/src/types/agent.ts +1 -1
- package/src/types/auth.ts +4 -3
- package/src/types/portal.ts +1 -1
- package/src/types/workers.ts +1 -1
- package/src/utils/agent-errors.ts +67 -0
- package/src/utils/api.ts +6 -0
- package/src/utils/banner.ts +14 -9
- package/src/utils/credentials.ts +6 -5
- package/src/utils/help.ts +51 -0
- package/tsconfig.json +9 -6
|
@@ -1,73 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Agent } from 'plazbot';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
5
|
+
import { logger } from '../../utils/logger.js';
|
|
6
|
+
import { addExamples } from '../../utils/help.js';
|
|
7
|
+
import { createSpinner, section } from '../../utils/ui.js';
|
|
8
|
+
const setGroup = new Command('set')
|
|
9
|
+
.description('Quickly configure agent properties');
|
|
10
|
+
addExamples(setGroup, [
|
|
11
|
+
{ description: 'Replace the agent greeting',
|
|
12
|
+
command: 'plazbot agent set greeting agt_AbcDef123 "Hi! How can I help you today?"' },
|
|
13
|
+
{ description: 'Configure tone, style, language, etc. interactively',
|
|
14
|
+
command: 'plazbot agent set instructions agt_AbcDef123' },
|
|
15
|
+
{ description: 'Define the agent persona (name, role, voice)',
|
|
16
|
+
command: 'plazbot agent set persona agt_AbcDef123' },
|
|
17
|
+
]);
|
|
15
18
|
// Set greeting
|
|
16
19
|
setGroup.command('greeting')
|
|
17
|
-
.description('
|
|
18
|
-
.argument('<agentId>', 'ID
|
|
19
|
-
.argument('<greeting>', '
|
|
20
|
-
.option('--dev', '
|
|
20
|
+
.description('Change the agent greeting')
|
|
21
|
+
.argument('<agentId>', 'Agent ID')
|
|
22
|
+
.argument('<greeting>', 'New greeting')
|
|
23
|
+
.option('--dev', 'Use development environment', false)
|
|
21
24
|
.action(async (agentId, greeting, options) => {
|
|
22
25
|
try {
|
|
23
|
-
const credentials = await
|
|
24
|
-
const agent = new
|
|
26
|
+
const credentials = await getStoredCredentials();
|
|
27
|
+
const agent = new Agent({
|
|
25
28
|
workspaceId: credentials.workspace,
|
|
26
29
|
apiKey: credentials.apiKey,
|
|
27
30
|
zone: credentials.zone,
|
|
28
31
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
29
32
|
});
|
|
30
|
-
const spinner =
|
|
33
|
+
const spinner = createSpinner('Updating greeting...');
|
|
31
34
|
spinner.start();
|
|
32
35
|
await agent.setGreeting(agentId, greeting);
|
|
33
|
-
spinner.succeed('
|
|
34
|
-
|
|
36
|
+
spinner.succeed('Greeting updated');
|
|
37
|
+
logger.label('New greeting', greeting);
|
|
35
38
|
}
|
|
36
39
|
catch (error) {
|
|
37
|
-
const message = error instanceof Error ? error.message : '
|
|
38
|
-
|
|
40
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
41
|
+
logger.error(message);
|
|
39
42
|
process.exit(1);
|
|
40
43
|
}
|
|
41
44
|
});
|
|
42
45
|
// Set instructions (wizard)
|
|
43
46
|
setGroup.command('instructions')
|
|
44
|
-
.description('
|
|
45
|
-
.argument('<agentId>', 'ID
|
|
46
|
-
.option('--dev', '
|
|
47
|
+
.description('Configure agent instructions')
|
|
48
|
+
.argument('<agentId>', 'Agent ID')
|
|
49
|
+
.option('--dev', 'Use development environment', false)
|
|
47
50
|
.action(async (agentId, options) => {
|
|
48
51
|
try {
|
|
49
|
-
const credentials = await
|
|
50
|
-
const agent = new
|
|
52
|
+
const credentials = await getStoredCredentials();
|
|
53
|
+
const agent = new Agent({
|
|
51
54
|
workspaceId: credentials.workspace,
|
|
52
55
|
apiKey: credentials.apiKey,
|
|
53
56
|
zone: credentials.zone,
|
|
54
57
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
55
58
|
});
|
|
56
59
|
// Cargar instrucciones actuales
|
|
57
|
-
const loadSpinner =
|
|
60
|
+
const loadSpinner = createSpinner('Loading...');
|
|
58
61
|
loadSpinner.start();
|
|
59
62
|
const _res1 = await agent.getAgentById({ id: agentId });
|
|
60
63
|
const agentData = _res1.agent || _res1.data || _res1;
|
|
61
64
|
loadSpinner.stop();
|
|
62
65
|
const current = agentData.instructions || {};
|
|
63
|
-
console.log(
|
|
64
|
-
const answers = await
|
|
65
|
-
{ type: 'list', name: 'tone', message: '
|
|
66
|
-
{ type: 'list', name: 'style', message: '
|
|
67
|
-
{ type: 'input', name: 'personality', message: '
|
|
68
|
-
{ type: 'input', name: 'objective', message: '
|
|
69
|
-
{ type: 'list', name: 'language', message: '
|
|
70
|
-
{ type: 'confirm', name: 'emojis', message: '
|
|
66
|
+
console.log(section('Instructions - ' + (agentData.name || agentId)));
|
|
67
|
+
const answers = await inquirer.prompt([
|
|
68
|
+
{ type: 'list', name: 'tone', message: 'Tone:', choices: ['profesional', 'amigable', 'formal', 'casual', 'tecnico', 'empatico'], default: current.tone || 'profesional' },
|
|
69
|
+
{ type: 'list', name: 'style', message: 'Style:', choices: ['conciso', 'detallado', 'conversacional', 'directo'], default: current.style || 'conciso' },
|
|
70
|
+
{ type: 'input', name: 'personality', message: 'Personality:', default: current.personality || '' },
|
|
71
|
+
{ type: 'input', name: 'objective', message: 'Objective:', default: current.objective || '' },
|
|
72
|
+
{ type: 'list', name: 'language', message: 'Language:', choices: ['Espanol', 'English', 'Portugues'], default: current.language || 'Espanol' },
|
|
73
|
+
{ type: 'confirm', name: 'emojis', message: 'Use emojis?', default: current.emojis === true },
|
|
71
74
|
]);
|
|
72
75
|
const instructions = {
|
|
73
76
|
...current,
|
|
@@ -78,52 +81,52 @@ setGroup.command('instructions')
|
|
|
78
81
|
language: answers.language,
|
|
79
82
|
emojis: answers.emojis,
|
|
80
83
|
};
|
|
81
|
-
const spinner =
|
|
84
|
+
const spinner = createSpinner('Saving instructions...');
|
|
82
85
|
spinner.start();
|
|
83
86
|
await agent.setInstructions(agentId, instructions);
|
|
84
|
-
spinner.succeed('
|
|
87
|
+
spinner.succeed('Instructions updated');
|
|
85
88
|
}
|
|
86
89
|
catch (error) {
|
|
87
|
-
const message = error instanceof Error ? error.message : '
|
|
88
|
-
|
|
90
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
91
|
+
logger.error(message);
|
|
89
92
|
process.exit(1);
|
|
90
93
|
}
|
|
91
94
|
});
|
|
92
95
|
// Set persona (wizard)
|
|
93
96
|
setGroup.command('persona')
|
|
94
|
-
.description('
|
|
95
|
-
.argument('<agentId>', 'ID
|
|
96
|
-
.option('--dev', '
|
|
97
|
+
.description('Configure the agent persona')
|
|
98
|
+
.argument('<agentId>', 'Agent ID')
|
|
99
|
+
.option('--dev', 'Use development environment', false)
|
|
97
100
|
.action(async (agentId, options) => {
|
|
98
101
|
try {
|
|
99
|
-
const credentials = await
|
|
100
|
-
const agent = new
|
|
102
|
+
const credentials = await getStoredCredentials();
|
|
103
|
+
const agent = new Agent({
|
|
101
104
|
workspaceId: credentials.workspace,
|
|
102
105
|
apiKey: credentials.apiKey,
|
|
103
106
|
zone: credentials.zone,
|
|
104
107
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
105
108
|
});
|
|
106
|
-
const loadSpinner =
|
|
109
|
+
const loadSpinner = createSpinner('Loading...');
|
|
107
110
|
loadSpinner.start();
|
|
108
111
|
const _res2 = await agent.getAgentById({ id: agentId });
|
|
109
112
|
const agentData = _res2.agent || _res2.data || _res2;
|
|
110
113
|
loadSpinner.stop();
|
|
111
114
|
const current = agentData.person || {};
|
|
112
|
-
console.log(
|
|
113
|
-
const answers = await
|
|
114
|
-
{ type: 'input', name: 'name', message: '
|
|
115
|
-
{ type: 'input', name: 'role', message: '
|
|
116
|
-
{ type: 'confirm', name: 'speaksInFirstPerson', message: '
|
|
115
|
+
console.log(section('Persona - ' + (agentData.name || agentId)));
|
|
116
|
+
const answers = await inquirer.prompt([
|
|
117
|
+
{ type: 'input', name: 'name', message: 'Character name:', default: current.name || '' },
|
|
118
|
+
{ type: 'input', name: 'role', message: 'Role:', default: current.role || '' },
|
|
119
|
+
{ type: 'confirm', name: 'speaksInFirstPerson', message: 'Speak in first person?', default: current.speaksInFirstPerson !== false },
|
|
117
120
|
]);
|
|
118
|
-
const spinner =
|
|
121
|
+
const spinner = createSpinner('Saving persona...');
|
|
119
122
|
spinner.start();
|
|
120
123
|
await agent.setPersona(agentId, answers);
|
|
121
|
-
spinner.succeed('Persona
|
|
124
|
+
spinner.succeed('Persona updated');
|
|
122
125
|
}
|
|
123
126
|
catch (error) {
|
|
124
|
-
const message = error instanceof Error ? error.message : '
|
|
125
|
-
|
|
127
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
128
|
+
logger.error(message);
|
|
126
129
|
process.exit(1);
|
|
127
130
|
}
|
|
128
131
|
});
|
|
129
|
-
|
|
132
|
+
export const setCommand = setGroup;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const plazbot_1 = require("plazbot");
|
|
10
|
-
const credentials_1 = require("../../utils/credentials");
|
|
11
|
-
const logger_1 = require("../../utils/logger");
|
|
12
|
-
const ui_1 = require("../../utils/ui");
|
|
13
|
-
const wizard_1 = require("./wizard");
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import inquirer from 'inquirer';
|
|
3
|
+
import { Agent } from 'plazbot';
|
|
4
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
5
|
+
import { logger } from '../../utils/logger.js';
|
|
6
|
+
import { addExamples } from '../../utils/help.js';
|
|
7
|
+
import { theme, section, kvPair, createTable, createSpinner } from '../../utils/ui.js';
|
|
8
|
+
import { connectChannelFlow } from './wizard.js';
|
|
14
9
|
// Plantilla: Clinica
|
|
15
10
|
const plantillaClinica = {
|
|
16
11
|
"name": "Asistente Clinica Salud",
|
|
@@ -580,57 +575,57 @@ const plantillaVentas = {
|
|
|
580
575
|
// Registro de plantillas con sus placeholders
|
|
581
576
|
const TEMPLATES = [
|
|
582
577
|
{
|
|
583
|
-
name: '
|
|
584
|
-
description: '
|
|
585
|
-
industry: '
|
|
578
|
+
name: 'Sales Assistant',
|
|
579
|
+
description: 'Agent for sales management, quotes and orders',
|
|
580
|
+
industry: 'Sales',
|
|
586
581
|
placeholders: [
|
|
587
|
-
{ key: '[NOMBRE DE LA EMPRESA]', label: '
|
|
588
|
-
{ key: '[DIRECCION COMPLETA]', label: '
|
|
589
|
-
{ key: '[NUMERO DE TELEFONO]', label: '
|
|
582
|
+
{ key: '[NOMBRE DE LA EMPRESA]', label: 'Your company name' },
|
|
583
|
+
{ key: '[DIRECCION COMPLETA]', label: 'Your company address' },
|
|
584
|
+
{ key: '[NUMERO DE TELEFONO]', label: 'Contact phone' },
|
|
590
585
|
],
|
|
591
586
|
config: plantillaVentas,
|
|
592
587
|
},
|
|
593
588
|
{
|
|
594
|
-
name: '
|
|
595
|
-
description: '
|
|
596
|
-
industry: '
|
|
589
|
+
name: 'IT Technical Support',
|
|
590
|
+
description: 'Agent for technical support, tickets and problem resolution',
|
|
591
|
+
industry: 'Technology',
|
|
597
592
|
placeholders: [
|
|
598
|
-
{ key: '[NOMBRE DE LA EMPRESA]', label: '
|
|
599
|
-
{ key: '[NUMERO DE TELEFONO]', label: '
|
|
600
|
-
{ key: '[EMAIL DE SOPORTE]', label: '
|
|
593
|
+
{ key: '[NOMBRE DE LA EMPRESA]', label: 'Your company name' },
|
|
594
|
+
{ key: '[NUMERO DE TELEFONO]', label: 'Support phone' },
|
|
595
|
+
{ key: '[EMAIL DE SOPORTE]', label: 'Support email (e.g. support@company.com)' },
|
|
601
596
|
],
|
|
602
597
|
config: plantillaSoporteIT,
|
|
603
598
|
},
|
|
604
599
|
{
|
|
605
|
-
name: '
|
|
606
|
-
description: '
|
|
607
|
-
industry: '
|
|
600
|
+
name: 'Clinic Assistant',
|
|
601
|
+
description: 'Agent for clinics: medical appointments, schedules and specialties',
|
|
602
|
+
industry: 'Health',
|
|
608
603
|
placeholders: [
|
|
609
|
-
{ key: '[NOMBRE DE LA CLINICA]', label: '
|
|
610
|
-
{ key: '[DIRECCION COMPLETA]', label: '
|
|
611
|
-
{ key: '[NUMERO DE TELEFONO]', label: '
|
|
604
|
+
{ key: '[NOMBRE DE LA CLINICA]', label: 'Your clinic name' },
|
|
605
|
+
{ key: '[DIRECCION COMPLETA]', label: 'Clinic address' },
|
|
606
|
+
{ key: '[NUMERO DE TELEFONO]', label: 'Clinic phone' },
|
|
612
607
|
],
|
|
613
608
|
config: plantillaClinica,
|
|
614
609
|
},
|
|
615
610
|
{
|
|
616
|
-
name: '
|
|
617
|
-
description: '
|
|
618
|
-
industry: '
|
|
611
|
+
name: 'Restaurant Assistant',
|
|
612
|
+
description: 'Agent for restaurants: reservations, menu and delivery',
|
|
613
|
+
industry: 'Gastronomy',
|
|
619
614
|
placeholders: [
|
|
620
|
-
{ key: '[NOMBRE DEL RESTAURANTE]', label: '
|
|
621
|
-
{ key: '[DIRECCION COMPLETA]', label: '
|
|
622
|
-
{ key: '[NUMERO DE TELEFONO]', label: '
|
|
615
|
+
{ key: '[NOMBRE DEL RESTAURANTE]', label: 'Your restaurant name' },
|
|
616
|
+
{ key: '[DIRECCION COMPLETA]', label: 'Restaurant address' },
|
|
617
|
+
{ key: '[NUMERO DE TELEFONO]', label: 'Restaurant phone' },
|
|
623
618
|
],
|
|
624
619
|
config: plantillaRestaurante,
|
|
625
620
|
},
|
|
626
621
|
{
|
|
627
|
-
name: '
|
|
628
|
-
description: '
|
|
629
|
-
industry: '
|
|
622
|
+
name: 'Real Estate Assistant',
|
|
623
|
+
description: 'Agent for real estate: properties, viewings and advisory',
|
|
624
|
+
industry: 'Real Estate',
|
|
630
625
|
placeholders: [
|
|
631
|
-
{ key: '[NOMBRE DE LA INMOBILIARIA]', label: '
|
|
632
|
-
{ key: '[DIRECCION COMPLETA]', label: '
|
|
633
|
-
{ key: '[NUMERO DE TELEFONO]', label: '
|
|
626
|
+
{ key: '[NOMBRE DE LA INMOBILIARIA]', label: 'Your real estate name' },
|
|
627
|
+
{ key: '[DIRECCION COMPLETA]', label: 'Office address' },
|
|
628
|
+
{ key: '[NUMERO DE TELEFONO]', label: 'Contact phone' },
|
|
634
629
|
],
|
|
635
630
|
config: plantillaInmobiliario,
|
|
636
631
|
},
|
|
@@ -658,62 +653,62 @@ function replacePlaceholders(obj, replacements) {
|
|
|
658
653
|
}
|
|
659
654
|
return obj;
|
|
660
655
|
}
|
|
661
|
-
|
|
662
|
-
.description('
|
|
663
|
-
.option('--dev', '
|
|
664
|
-
.option('--json', '
|
|
656
|
+
export const templatesCommand = new Command('templates')
|
|
657
|
+
.description('Create an agent from pre-configured templates')
|
|
658
|
+
.option('--dev', 'Use development environment', false)
|
|
659
|
+
.option('--json', 'Only show the resulting JSON without creating the agent', false)
|
|
665
660
|
.action(async (options) => {
|
|
666
661
|
try {
|
|
667
|
-
console.log(
|
|
668
|
-
console.log(
|
|
662
|
+
console.log(section('Agent templates'));
|
|
663
|
+
console.log(theme.muted(' Create a pre-configured agent in seconds\n'));
|
|
669
664
|
const rows = TEMPLATES.map((t, i) => [
|
|
670
665
|
String(i + 1),
|
|
671
666
|
t.name,
|
|
672
667
|
t.industry,
|
|
673
668
|
t.description,
|
|
674
669
|
]);
|
|
675
|
-
console.log(
|
|
670
|
+
console.log(createTable(['#', 'Name', 'Industry', 'Description'], rows));
|
|
676
671
|
// Paso 1: Seleccionar plantilla
|
|
677
|
-
const { selected } = await
|
|
672
|
+
const { selected } = await inquirer.prompt([{
|
|
678
673
|
type: 'list',
|
|
679
674
|
name: 'selected',
|
|
680
|
-
message: '
|
|
675
|
+
message: 'Select a template:',
|
|
681
676
|
choices: [
|
|
682
677
|
...TEMPLATES.map((t, i) => ({ name: `${t.name} (${t.industry})`, value: i })),
|
|
683
|
-
{ name: '
|
|
678
|
+
{ name: 'Cancel', value: -1 },
|
|
684
679
|
],
|
|
685
680
|
}]);
|
|
686
681
|
if (selected === -1)
|
|
687
682
|
return;
|
|
688
683
|
const template = TEMPLATES[selected];
|
|
689
|
-
console.log(
|
|
690
|
-
console.log(
|
|
691
|
-
console.log(
|
|
692
|
-
console.log(
|
|
693
|
-
console.log(
|
|
684
|
+
console.log(section(`${template.name}`));
|
|
685
|
+
console.log(kvPair('Industry', template.industry));
|
|
686
|
+
console.log(kvPair('Persona', `${template.config.person.name} - ${template.config.person.role}`));
|
|
687
|
+
console.log(kvPair('Actions', String(template.config.actions.length)));
|
|
688
|
+
console.log(kvPair('Tool Calling', 'Enabled'));
|
|
694
689
|
console.log();
|
|
695
690
|
// Paso 2: Personalizar placeholders
|
|
696
|
-
console.log(
|
|
697
|
-
console.log(
|
|
691
|
+
console.log(theme.bold('\n Quick customization'));
|
|
692
|
+
console.log(theme.muted(' Fill in your business details:\n'));
|
|
698
693
|
const placeholderAnswers = {};
|
|
699
694
|
for (const ph of template.placeholders) {
|
|
700
|
-
const { value } = await
|
|
695
|
+
const { value } = await inquirer.prompt([{
|
|
701
696
|
type: 'input',
|
|
702
697
|
name: 'value',
|
|
703
698
|
message: `${ph.label}:`,
|
|
704
|
-
validate: (v) => v.trim().length > 0 || '
|
|
699
|
+
validate: (v) => v.trim().length > 0 || 'This field is required',
|
|
705
700
|
}]);
|
|
706
701
|
placeholderAnswers[ph.key] = value.trim();
|
|
707
702
|
}
|
|
708
703
|
// Paso 3: Canales (WhatsApp, Messenger, Instagram, Telegram)
|
|
709
|
-
console.log(
|
|
710
|
-
const { wantChannels } = await
|
|
704
|
+
console.log(theme.bold('\n Channel connection'));
|
|
705
|
+
const { wantChannels } = await inquirer.prompt([{
|
|
711
706
|
type: 'confirm',
|
|
712
707
|
name: 'wantChannels',
|
|
713
|
-
message: '
|
|
708
|
+
message: 'Connect channels (WhatsApp, Messenger, Instagram, Telegram)?',
|
|
714
709
|
default: true,
|
|
715
710
|
}]);
|
|
716
|
-
const credentials = await
|
|
711
|
+
const credentials = await getStoredCredentials();
|
|
717
712
|
let connectedChannels = [];
|
|
718
713
|
if (wantChannels) {
|
|
719
714
|
const wizardCtx = {
|
|
@@ -722,32 +717,32 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
722
717
|
apiKey: credentials.apiKey,
|
|
723
718
|
dev: !!options.dev,
|
|
724
719
|
};
|
|
725
|
-
connectedChannels = await
|
|
720
|
+
connectedChannels = await connectChannelFlow(wizardCtx);
|
|
726
721
|
}
|
|
727
722
|
// Paso 4: API Key de OpenAI
|
|
728
|
-
console.log(
|
|
729
|
-
const { configureApiKey } = await
|
|
723
|
+
console.log(theme.bold('\n AI configuration'));
|
|
724
|
+
const { configureApiKey } = await inquirer.prompt([{
|
|
730
725
|
type: 'confirm',
|
|
731
726
|
name: 'configureApiKey',
|
|
732
|
-
message: '
|
|
727
|
+
message: 'Configure your OpenAI API Key now? (required for the agent to work)',
|
|
733
728
|
default: true,
|
|
734
729
|
}]);
|
|
735
730
|
let apiToken = '';
|
|
736
731
|
if (configureApiKey) {
|
|
737
|
-
const { key } = await
|
|
732
|
+
const { key } = await inquirer.prompt([{
|
|
738
733
|
type: 'password',
|
|
739
734
|
name: 'key',
|
|
740
|
-
message: 'API Key
|
|
735
|
+
message: 'OpenAI API Key (sk-...):',
|
|
741
736
|
mask: '*',
|
|
742
|
-
validate: (v) => v.trim().length > 0 || '
|
|
737
|
+
validate: (v) => v.trim().length > 0 || 'The API Key is required',
|
|
743
738
|
}]);
|
|
744
739
|
apiToken = key.trim();
|
|
745
740
|
}
|
|
746
741
|
// Paso 5: Zona horaria
|
|
747
|
-
const { timezone } = await
|
|
742
|
+
const { timezone } = await inquirer.prompt([{
|
|
748
743
|
type: 'input',
|
|
749
744
|
name: 'timezone',
|
|
750
|
-
message: '
|
|
745
|
+
message: 'Timezone (e.g. America/Lima, America/Bogota, America/Mexico_City):',
|
|
751
746
|
default: template.config.timezone,
|
|
752
747
|
}]);
|
|
753
748
|
// Construir config final
|
|
@@ -765,78 +760,84 @@ exports.templatesCommand = new commander_1.Command('templates')
|
|
|
765
760
|
}
|
|
766
761
|
// Si es --json, solo mostrar y salir
|
|
767
762
|
if (options.json) {
|
|
768
|
-
console.log(
|
|
769
|
-
|
|
763
|
+
console.log(section('Configuration JSON'));
|
|
764
|
+
logger.json(finalConfig);
|
|
770
765
|
return;
|
|
771
766
|
}
|
|
772
767
|
// Paso 6: Confirmacion
|
|
773
|
-
console.log(
|
|
774
|
-
console.log(
|
|
768
|
+
console.log(section('Summary'));
|
|
769
|
+
console.log(kvPair('Template', template.name));
|
|
775
770
|
for (const ph of template.placeholders) {
|
|
776
|
-
console.log(
|
|
771
|
+
console.log(kvPair(ph.label, placeholderAnswers[ph.key]));
|
|
777
772
|
}
|
|
778
|
-
console.log(
|
|
779
|
-
console.log(
|
|
780
|
-
console.log(
|
|
781
|
-
console.log(
|
|
782
|
-
console.log(
|
|
773
|
+
console.log(kvPair('Channels', connectedChannels.length > 0 ? connectedChannels.map(c => `${c.channel} (${c.key})`).join(', ') : 'Not configured'));
|
|
774
|
+
console.log(kvPair('OpenAI API Key', apiToken ? 'Configured' : 'Not configured (the agent will not work without it)'));
|
|
775
|
+
console.log(kvPair('Timezone', timezone));
|
|
776
|
+
console.log(kvPair('Actions', String(finalConfig.actions.length)));
|
|
777
|
+
console.log(kvPair('AI', `${finalConfig.aiProviders[0].provider} / ${finalConfig.aiProviders[0].model}`));
|
|
783
778
|
console.log();
|
|
784
|
-
const { confirm } = await
|
|
779
|
+
const { confirm } = await inquirer.prompt([{
|
|
785
780
|
type: 'confirm',
|
|
786
781
|
name: 'confirm',
|
|
787
|
-
message: '
|
|
782
|
+
message: 'Create the agent with this configuration?',
|
|
788
783
|
default: true,
|
|
789
784
|
}]);
|
|
790
785
|
if (!confirm) {
|
|
791
|
-
|
|
786
|
+
logger.warning('Creation cancelled');
|
|
792
787
|
return;
|
|
793
788
|
}
|
|
794
789
|
// Paso 7: Crear agente
|
|
795
|
-
const agent = new
|
|
790
|
+
const agent = new Agent({
|
|
796
791
|
workspaceId: credentials.workspace,
|
|
797
792
|
apiKey: credentials.apiKey,
|
|
798
793
|
zone: credentials.zone,
|
|
799
794
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
800
795
|
});
|
|
801
796
|
finalConfig.zone = credentials.zone;
|
|
802
|
-
const spinner =
|
|
797
|
+
const spinner = createSpinner('Creating agent...');
|
|
803
798
|
spinner.start();
|
|
804
799
|
const result = await agent.addAgent(finalConfig);
|
|
805
|
-
spinner.succeed('
|
|
806
|
-
|
|
800
|
+
spinner.succeed('Agent created successfully');
|
|
801
|
+
logger.title('Agent details');
|
|
807
802
|
if (result.agentId) {
|
|
808
|
-
|
|
803
|
+
logger.label('ID', result.agentId);
|
|
809
804
|
}
|
|
810
|
-
|
|
811
|
-
|
|
805
|
+
logger.label('Name', finalConfig.name);
|
|
806
|
+
logger.label('Industry', template.industry);
|
|
812
807
|
if (connectedChannels.length > 0) {
|
|
813
|
-
|
|
808
|
+
logger.label('Channels', connectedChannels.map(c => `${c.channel} (${c.key})`).join(', '));
|
|
814
809
|
}
|
|
815
|
-
|
|
810
|
+
logger.label('Actions', String(finalConfig.actions.length));
|
|
816
811
|
console.log();
|
|
817
|
-
console.log(
|
|
812
|
+
console.log(section('Next steps'));
|
|
818
813
|
if (connectedChannels.length === 0) {
|
|
819
|
-
console.log(
|
|
820
|
-
console.log(
|
|
814
|
+
console.log(theme.bold(' 1.') + ' Connect channels from: ' + theme.success('plazbot agent chat -a <agentId>'));
|
|
815
|
+
console.log(theme.bold(' 2.') + ' Or connect from the platform in Settings > Integrations');
|
|
821
816
|
}
|
|
822
817
|
else {
|
|
823
|
-
console.log(
|
|
818
|
+
console.log(theme.bold(' 1.') + ' Your agent already has channels connected and enabled');
|
|
824
819
|
}
|
|
825
|
-
console.log(
|
|
820
|
+
console.log(theme.bold(` ${connectedChannels.length === 0 ? '3' : '2'}.`) + ' Add your OpenAI API Key if you have not yet');
|
|
826
821
|
console.log();
|
|
827
822
|
if (!apiToken) {
|
|
828
|
-
|
|
829
|
-
|
|
823
|
+
logger.warning('Remember to configure your OpenAI API Key for the agent to work:');
|
|
824
|
+
logger.dim(`plazbot agent ai-config ${result.agentId || '<agentId>'}`);
|
|
830
825
|
console.log();
|
|
831
826
|
}
|
|
832
|
-
|
|
827
|
+
logger.dim('Test agent: plazbot agent chat -a ' + (result.agentId || '<agentId>'));
|
|
833
828
|
if (options.dev) {
|
|
834
|
-
|
|
829
|
+
logger.warning('Environment: development');
|
|
835
830
|
}
|
|
836
831
|
}
|
|
837
832
|
catch (error) {
|
|
838
|
-
const message = error instanceof Error ? error.message : '
|
|
839
|
-
|
|
833
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
834
|
+
logger.error(message);
|
|
840
835
|
process.exit(1);
|
|
841
836
|
}
|
|
842
837
|
});
|
|
838
|
+
addExamples(templatesCommand, [
|
|
839
|
+
{ description: 'Pick a template and create the agent interactively',
|
|
840
|
+
command: 'plazbot agent templates' },
|
|
841
|
+
{ description: 'Preview the resulting JSON without creating the agent',
|
|
842
|
+
command: 'plazbot agent templates --json' },
|
|
843
|
+
]);
|