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,18 +1,30 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Agent } from 'plazbot';
|
|
3
|
-
import { getStoredCredentials } from '../../utils/credentials';
|
|
4
|
-
import { logger } from '../../utils/logger';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
import { createSpinner, createTable, theme, section, statusBadge } from '../../utils/ui.js';
|
|
7
|
+
import { AgentCommandOptions } from '../../types/agent.js';
|
|
7
8
|
|
|
8
9
|
const filesGroup = new Command('files')
|
|
9
|
-
.description('
|
|
10
|
+
.description('Manage files in the agent knowledge base');
|
|
11
|
+
|
|
12
|
+
addExamples(filesGroup, [
|
|
13
|
+
{ description: 'List the knowledge-base files of an agent',
|
|
14
|
+
command: 'plazbot agent files list agt_AbcDef123' },
|
|
15
|
+
{ description: 'Add a remote PDF/DOC to the knowledge base',
|
|
16
|
+
command: 'plazbot agent files add agt_AbcDef123 -u https://files.example.com/manual.pdf -r manual -t docs,onboarding' },
|
|
17
|
+
{ description: 'Check whether a file finished processing',
|
|
18
|
+
command: 'plazbot agent files status file_AbcDef123' },
|
|
19
|
+
{ description: 'Remove a file from the knowledge base',
|
|
20
|
+
command: 'plazbot agent files delete agt_AbcDef123 file_AbcDef123' },
|
|
21
|
+
]);
|
|
10
22
|
|
|
11
23
|
// Listar archivos
|
|
12
24
|
filesGroup.command('list')
|
|
13
|
-
.description('
|
|
14
|
-
.argument('<agentId>', 'ID
|
|
15
|
-
.option('--dev', '
|
|
25
|
+
.description('List agent files')
|
|
26
|
+
.argument('<agentId>', 'Agent ID')
|
|
27
|
+
.option('--dev', 'Use development environment', false)
|
|
16
28
|
.action(async (agentId: string, options: AgentCommandOptions) => {
|
|
17
29
|
try {
|
|
18
30
|
const credentials = await getStoredCredentials();
|
|
@@ -23,31 +35,31 @@ filesGroup.command('list')
|
|
|
23
35
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
24
36
|
});
|
|
25
37
|
|
|
26
|
-
const spinner = createSpinner('
|
|
38
|
+
const spinner = createSpinner('Loading files...');
|
|
27
39
|
spinner.start();
|
|
28
40
|
const _res: any = await agent.getAgentById({ id: agentId });
|
|
29
41
|
const agentData = _res.agent || _res.data || _res;
|
|
30
42
|
spinner.stop();
|
|
31
43
|
|
|
32
44
|
const files = (agentData as any).files || [];
|
|
33
|
-
console.log(section('
|
|
45
|
+
console.log(section('Files - ' + (agentData.name || agentId)));
|
|
34
46
|
|
|
35
47
|
if (files.length === 0) {
|
|
36
|
-
console.log(theme.muted('\n No
|
|
37
|
-
console.log(theme.muted('
|
|
48
|
+
console.log(theme.muted('\n No files in the knowledge base'));
|
|
49
|
+
console.log(theme.muted(' Use: plazbot agent files add <agentId> --url <url>\n'));
|
|
38
50
|
return;
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
const rows = files.map((f: any) => [
|
|
42
54
|
f.fileId || f.id || 'N/A',
|
|
43
|
-
f.name || f.reference || '
|
|
55
|
+
f.name || f.reference || 'Untitled',
|
|
44
56
|
(f.tags || []).join(', ') || '-',
|
|
45
57
|
]);
|
|
46
58
|
|
|
47
|
-
console.log(createTable(['ID', '
|
|
59
|
+
console.log(createTable(['ID', 'Name', 'Tags'], rows));
|
|
48
60
|
|
|
49
61
|
} catch (error) {
|
|
50
|
-
const message = error instanceof Error ? error.message : '
|
|
62
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
51
63
|
logger.error(message);
|
|
52
64
|
process.exit(1);
|
|
53
65
|
}
|
|
@@ -55,12 +67,12 @@ filesGroup.command('list')
|
|
|
55
67
|
|
|
56
68
|
// Agregar archivo
|
|
57
69
|
filesGroup.command('add')
|
|
58
|
-
.description('
|
|
59
|
-
.argument('<agentId>', 'ID
|
|
60
|
-
.requiredOption('-u, --url <url>', 'URL
|
|
61
|
-
.option('-r, --reference <name>', '
|
|
62
|
-
.option('-t, --tags <tags>', '
|
|
63
|
-
.option('--dev', '
|
|
70
|
+
.description('Add a file to the knowledge base')
|
|
71
|
+
.argument('<agentId>', 'Agent ID')
|
|
72
|
+
.requiredOption('-u, --url <url>', 'File URL (PDF, DOC, DOCX)')
|
|
73
|
+
.option('-r, --reference <name>', 'Reference name', 'documento')
|
|
74
|
+
.option('-t, --tags <tags>', 'Comma-separated tags', '')
|
|
75
|
+
.option('--dev', 'Use development environment', false)
|
|
64
76
|
.action(async (agentId: string, options: any) => {
|
|
65
77
|
try {
|
|
66
78
|
const credentials = await getStoredCredentials();
|
|
@@ -71,7 +83,7 @@ filesGroup.command('add')
|
|
|
71
83
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
72
84
|
});
|
|
73
85
|
|
|
74
|
-
const spinner = createSpinner('
|
|
86
|
+
const spinner = createSpinner('Uploading file...');
|
|
75
87
|
spinner.start();
|
|
76
88
|
|
|
77
89
|
const tags = options.tags ? options.tags.split(',').map((t: string) => t.trim()) : [];
|
|
@@ -82,16 +94,16 @@ filesGroup.command('add')
|
|
|
82
94
|
tags,
|
|
83
95
|
});
|
|
84
96
|
|
|
85
|
-
spinner.succeed('
|
|
97
|
+
spinner.succeed('File added');
|
|
86
98
|
|
|
87
99
|
if (result?.fileId) {
|
|
88
100
|
logger.label('File ID', result.fileId);
|
|
89
|
-
logger.dim('
|
|
101
|
+
logger.dim('The file is being processed. Check status with:');
|
|
90
102
|
logger.dim(`plazbot agent files status ${result.fileId}`);
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
} catch (error) {
|
|
94
|
-
const message = error instanceof Error ? error.message : '
|
|
106
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
95
107
|
logger.error(message);
|
|
96
108
|
process.exit(1);
|
|
97
109
|
}
|
|
@@ -99,9 +111,9 @@ filesGroup.command('add')
|
|
|
99
111
|
|
|
100
112
|
// Verificar estado
|
|
101
113
|
filesGroup.command('status')
|
|
102
|
-
.description('
|
|
103
|
-
.argument('<fileId>', 'ID
|
|
104
|
-
.option('--dev', '
|
|
114
|
+
.description('Check the processing status of a file')
|
|
115
|
+
.argument('<fileId>', 'File ID')
|
|
116
|
+
.option('--dev', 'Use development environment', false)
|
|
105
117
|
.action(async (fileId: string, options: AgentCommandOptions) => {
|
|
106
118
|
try {
|
|
107
119
|
const credentials = await getStoredCredentials();
|
|
@@ -112,17 +124,17 @@ filesGroup.command('status')
|
|
|
112
124
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
113
125
|
});
|
|
114
126
|
|
|
115
|
-
const spinner = createSpinner('
|
|
127
|
+
const spinner = createSpinner('Checking...');
|
|
116
128
|
spinner.start();
|
|
117
129
|
const result = await agent.validateFile({ fileId });
|
|
118
130
|
spinner.stop();
|
|
119
131
|
|
|
120
|
-
logger.title('
|
|
132
|
+
logger.title('File status');
|
|
121
133
|
logger.label('File ID', fileId);
|
|
122
|
-
logger.label('
|
|
134
|
+
logger.label('Status', result?.status ? 'Completed' : 'Processing');
|
|
123
135
|
|
|
124
136
|
} catch (error) {
|
|
125
|
-
const message = error instanceof Error ? error.message : '
|
|
137
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
126
138
|
logger.error(message);
|
|
127
139
|
process.exit(1);
|
|
128
140
|
}
|
|
@@ -130,10 +142,10 @@ filesGroup.command('status')
|
|
|
130
142
|
|
|
131
143
|
// Eliminar archivo
|
|
132
144
|
filesGroup.command('delete')
|
|
133
|
-
.description('
|
|
134
|
-
.argument('<agentId>', 'ID
|
|
135
|
-
.argument('<fileId>', 'ID
|
|
136
|
-
.option('--dev', '
|
|
145
|
+
.description('Delete a file from the knowledge base')
|
|
146
|
+
.argument('<agentId>', 'Agent ID')
|
|
147
|
+
.argument('<fileId>', 'File ID')
|
|
148
|
+
.option('--dev', 'Use development environment', false)
|
|
137
149
|
.action(async (agentId: string, fileId: string, options: AgentCommandOptions) => {
|
|
138
150
|
try {
|
|
139
151
|
const credentials = await getStoredCredentials();
|
|
@@ -144,13 +156,13 @@ filesGroup.command('delete')
|
|
|
144
156
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
145
157
|
});
|
|
146
158
|
|
|
147
|
-
const spinner = createSpinner('
|
|
159
|
+
const spinner = createSpinner('Deleting file...');
|
|
148
160
|
spinner.start();
|
|
149
161
|
await agent.deleteFile({ fileId, agentId });
|
|
150
|
-
spinner.succeed('
|
|
162
|
+
spinner.succeed('File deleted');
|
|
151
163
|
|
|
152
164
|
} catch (error) {
|
|
153
|
-
const message = error instanceof Error ? error.message : '
|
|
165
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
154
166
|
logger.error(message);
|
|
155
167
|
process.exit(1);
|
|
156
168
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Agent } from 'plazbot';
|
|
3
|
-
import { getStoredCredentials } from '../../utils/credentials';
|
|
4
|
-
import { logger } from '../../utils/logger';
|
|
5
|
-
import {
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
import { describeAgentLoadError } from '../../utils/agent-errors.js';
|
|
7
|
+
import { AgentCommandOptions } from '../../types/agent.js';
|
|
6
8
|
import chalk from 'chalk';
|
|
7
9
|
|
|
8
10
|
export const getCommand = new Command('get')
|
|
9
|
-
.description('
|
|
10
|
-
.argument('<agentId>', 'ID
|
|
11
|
-
.option('-w, --workspace <id>', 'Workspace ID (
|
|
12
|
-
.option('-z, --zone <zone>', '
|
|
13
|
-
.option('--raw', '
|
|
14
|
-
.option('--dev', '
|
|
11
|
+
.description('Get detailed information about a specific agent')
|
|
12
|
+
.argument('<agentId>', 'Agent ID to fetch')
|
|
13
|
+
.option('-w, --workspace <id>', 'Workspace ID (overrides local config)')
|
|
14
|
+
.option('-z, --zone <zone>', 'Zone LA or EU (overrides local config)')
|
|
15
|
+
.option('--raw', 'Show full unformatted JSON', false)
|
|
16
|
+
.option('--dev', 'Use development environment', false)
|
|
15
17
|
.action(async (agentId: string, options: AgentCommandOptions & { raw: boolean; workspace?: string; zone?: string }) => {
|
|
16
18
|
try {
|
|
17
19
|
const credentials = await getStoredCredentials();
|
|
@@ -20,7 +22,7 @@ export const getCommand = new Command('get')
|
|
|
20
22
|
const effectiveZone = (options.zone?.toUpperCase() === 'EU' ? 'EU' : options.zone?.toUpperCase() === 'LA' ? 'LA' : credentials.zone) as 'LA' | 'EU';
|
|
21
23
|
|
|
22
24
|
if (options.workspace || options.zone) {
|
|
23
|
-
console.log(chalk.hex('#FFA726')(`\n
|
|
25
|
+
console.log(chalk.hex('#FFA726')(`\n Support mode: workspace=${effectiveWorkspace} zone=${effectiveZone}`));
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const agent = new Agent({
|
|
@@ -53,23 +55,23 @@ export const getCommand = new Command('get')
|
|
|
53
55
|
|
|
54
56
|
console.log();
|
|
55
57
|
console.log(chalk.hex('#4CAF50')(' ┌' + '─'.repeat(58) + '┐'));
|
|
56
|
-
console.log(chalk.hex('#4CAF50')(' │') + chalk.bold(` ${agentData.name || '
|
|
58
|
+
console.log(chalk.hex('#4CAF50')(' │') + chalk.bold(` ${agentData.name || 'Agent'}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
|
|
57
59
|
console.log(chalk.hex('#4CAF50')(' │') + chalk.gray(` ${agentId}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
|
|
58
60
|
console.log(chalk.hex('#4CAF50')(' └' + '─'.repeat(58) + '┘'));
|
|
59
61
|
|
|
60
62
|
// Informacion basica
|
|
61
|
-
sectionHeader('
|
|
63
|
+
sectionHeader('Basic Information');
|
|
62
64
|
label('ID', agentData.id);
|
|
63
|
-
label('
|
|
64
|
-
label('
|
|
65
|
-
label('
|
|
66
|
-
label('
|
|
65
|
+
label('Name', agentData.name);
|
|
66
|
+
label('Description', agentData.description);
|
|
67
|
+
label('Status', agentData.enable ? chalk.hex('#66BB6A')('Active') : chalk.hex('#EF5350')('Inactive'));
|
|
68
|
+
label('Zone', agentData.zone);
|
|
67
69
|
label('Buffer', agentData.buffer);
|
|
68
70
|
label('Color', agentData.color);
|
|
69
|
-
label('
|
|
70
|
-
label('
|
|
71
|
-
label('
|
|
72
|
-
label('Tool Calling', agentData.useToolCalling ? '
|
|
71
|
+
label('Initial question', agentData.question);
|
|
72
|
+
label('Timezone', agentData.timezone);
|
|
73
|
+
label('Show in chat', agentData.showInChat ? 'Yes' : 'No');
|
|
74
|
+
label('Tool Calling', agentData.useToolCalling ? 'Enabled' : 'Disabled');
|
|
73
75
|
|
|
74
76
|
// Tags
|
|
75
77
|
if (agentData.tags && agentData.tags.length > 0) {
|
|
@@ -87,7 +89,7 @@ export const getCommand = new Command('get')
|
|
|
87
89
|
|
|
88
90
|
// Ejemplos
|
|
89
91
|
if (agentData.examples && agentData.examples.length > 0) {
|
|
90
|
-
sectionHeader('
|
|
92
|
+
sectionHeader('Examples');
|
|
91
93
|
agentData.examples.forEach((example: any) => {
|
|
92
94
|
console.log(chalk.white(` - ${example.value || example}`));
|
|
93
95
|
});
|
|
@@ -95,64 +97,64 @@ export const getCommand = new Command('get')
|
|
|
95
97
|
|
|
96
98
|
// Instrucciones
|
|
97
99
|
if (agentData.instructions) {
|
|
98
|
-
sectionHeader('
|
|
100
|
+
sectionHeader('Instructions');
|
|
99
101
|
const inst = agentData.instructions;
|
|
100
|
-
label('
|
|
101
|
-
label('
|
|
102
|
-
label('
|
|
103
|
-
label('
|
|
104
|
-
label('
|
|
105
|
-
label('Emojis', inst.emojis ? '
|
|
106
|
-
label('
|
|
107
|
-
label('Max
|
|
102
|
+
label('Tone', inst.tone);
|
|
103
|
+
label('Style', inst.style);
|
|
104
|
+
label('Personality', inst.personality);
|
|
105
|
+
label('Objective', inst.objective);
|
|
106
|
+
label('Language', inst.language);
|
|
107
|
+
label('Emojis', inst.emojis ? 'Yes' : 'No');
|
|
108
|
+
label('Preferred format', inst.preferredFormat);
|
|
109
|
+
label('Max words', inst.maxWords);
|
|
108
110
|
if (inst.avoidTopics && inst.avoidTopics.length > 0) {
|
|
109
|
-
label('
|
|
111
|
+
label('Topics to avoid', inst.avoidTopics.join(', '));
|
|
110
112
|
}
|
|
111
|
-
label('
|
|
112
|
-
label('
|
|
113
|
+
label('Only respond if known', inst.respondOnlyIfKnows ? 'Yes' : 'No');
|
|
114
|
+
label('Greeting', inst.greeting);
|
|
113
115
|
}
|
|
114
116
|
|
|
115
117
|
// Persona
|
|
116
118
|
if (agentData.person) {
|
|
117
119
|
sectionHeader('Persona');
|
|
118
120
|
const p = agentData.person;
|
|
119
|
-
label('
|
|
120
|
-
label('
|
|
121
|
-
label('
|
|
122
|
-
label('
|
|
121
|
+
label('Name', p.name);
|
|
122
|
+
label('Role', p.role);
|
|
123
|
+
label('First person', p.speaksInFirstPerson ? 'Yes' : 'No');
|
|
124
|
+
label('Is human', p.isHuman ? 'Yes' : 'No');
|
|
123
125
|
}
|
|
124
126
|
|
|
125
127
|
// Fallbacks
|
|
126
128
|
if (agentData.fallbacks) {
|
|
127
129
|
sectionHeader('Fallbacks');
|
|
128
130
|
const fb = agentData.fallbacks;
|
|
129
|
-
label('
|
|
130
|
-
label('
|
|
131
|
-
label('
|
|
131
|
+
label('No answer', fb.noAnswer);
|
|
132
|
+
label('Service error', fb.serviceError);
|
|
133
|
+
label('Does not understand', fb.doNotUnderstand);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
// Reglas
|
|
135
137
|
if (agentData.rules) {
|
|
136
|
-
sectionHeader('
|
|
138
|
+
sectionHeader('Rules');
|
|
137
139
|
const r = agentData.rules;
|
|
138
|
-
label('
|
|
139
|
-
label('
|
|
140
|
+
label('Do not mention prices', r.doNotMentionPrices ? 'Yes' : 'No');
|
|
141
|
+
label('Do not diagnose', r.doNotDiagnose ? 'Yes' : 'No');
|
|
140
142
|
if (r.doNotRespondOutsideHours) {
|
|
141
|
-
label('
|
|
143
|
+
label('Out of hours', r.doNotRespondOutsideHours);
|
|
142
144
|
}
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// Servicios
|
|
146
148
|
if (agentData.services && agentData.services.length > 0) {
|
|
147
|
-
sectionHeader(`
|
|
149
|
+
sectionHeader(`Services (${agentData.services.length})`);
|
|
148
150
|
agentData.services.forEach((svc: any, i: number) => {
|
|
149
|
-
console.log(chalk.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || '
|
|
150
|
-
label('
|
|
151
|
-
label('
|
|
152
|
-
label('
|
|
151
|
+
console.log(chalk.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || 'Service'}`));
|
|
152
|
+
label(' Reference', svc.reference);
|
|
153
|
+
label(' Enabled', svc.enabled ? 'Yes' : 'No');
|
|
154
|
+
label(' Method', svc.method);
|
|
153
155
|
label(' Endpoint', svc.endpoint);
|
|
154
156
|
if (svc.requiredFields && svc.requiredFields.length > 0) {
|
|
155
|
-
console.log(chalk.gray('
|
|
157
|
+
console.log(chalk.gray(' Fields:'));
|
|
156
158
|
svc.requiredFields.forEach((f: any) => {
|
|
157
159
|
console.log(chalk.white(` - ${f.name} (${f.type}): ${f.description || ''}`));
|
|
158
160
|
});
|
|
@@ -162,17 +164,17 @@ export const getCommand = new Command('get')
|
|
|
162
164
|
|
|
163
165
|
// Acciones
|
|
164
166
|
if (agentData.actions && agentData.actions.length > 0) {
|
|
165
|
-
sectionHeader(`
|
|
167
|
+
sectionHeader(`Actions (${agentData.actions.length})`);
|
|
166
168
|
agentData.actions.forEach((act: any, i: number) => {
|
|
167
|
-
console.log(chalk.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || '
|
|
168
|
-
label('
|
|
169
|
-
label('
|
|
169
|
+
console.log(chalk.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || 'Action'}`));
|
|
170
|
+
label(' Reference', act.reference);
|
|
171
|
+
label(' Enabled', act.enabled ? 'Yes' : 'No');
|
|
170
172
|
if (act.tags && act.tags.length > 0) {
|
|
171
173
|
label(' Tags', act.tags.join(', '));
|
|
172
174
|
}
|
|
173
|
-
label('
|
|
175
|
+
label(' Response', act.responseMessage);
|
|
174
176
|
if (act.action && act.action.length > 0) {
|
|
175
|
-
console.log(chalk.gray(' Sub-
|
|
177
|
+
console.log(chalk.gray(' Sub-actions:'));
|
|
176
178
|
act.action.forEach((sa: any) => {
|
|
177
179
|
console.log(chalk.white(` - ${sa.type}: ${sa.value || ''}`));
|
|
178
180
|
});
|
|
@@ -182,32 +184,50 @@ export const getCommand = new Command('get')
|
|
|
182
184
|
|
|
183
185
|
// Canales
|
|
184
186
|
if (agentData.channels && agentData.channels.length > 0) {
|
|
185
|
-
sectionHeader(`
|
|
187
|
+
sectionHeader(`Channels (${agentData.channels.length})`);
|
|
186
188
|
agentData.channels.forEach((ch: any) => {
|
|
187
|
-
console.log(chalk.white(` ${chalk.hex('#22d3ee')(ch.channel || '
|
|
189
|
+
console.log(chalk.white(` ${chalk.hex('#22d3ee')(ch.channel || 'channel')}: ${ch.key || ''}`));
|
|
188
190
|
});
|
|
189
191
|
}
|
|
190
192
|
|
|
191
193
|
// AI Config
|
|
192
194
|
if (agentData.customAIConfig && agentData.aiProviders && agentData.aiProviders.length > 0) {
|
|
193
|
-
sectionHeader('
|
|
195
|
+
sectionHeader('AI Model');
|
|
194
196
|
agentData.aiProviders.forEach((ai: any) => {
|
|
195
|
-
label('
|
|
196
|
-
label('
|
|
197
|
+
label('Provider', ai.provider);
|
|
198
|
+
label('Model', ai.model);
|
|
197
199
|
});
|
|
198
200
|
}
|
|
199
201
|
|
|
200
202
|
console.log();
|
|
201
|
-
console.log(chalk.gray('
|
|
203
|
+
console.log(chalk.gray(' Use --raw to see the full JSON'));
|
|
202
204
|
console.log();
|
|
203
205
|
|
|
204
206
|
if (options.dev) {
|
|
205
|
-
logger.warning('
|
|
207
|
+
logger.warning('Environment: development');
|
|
206
208
|
}
|
|
207
209
|
|
|
208
210
|
} catch (error) {
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
+
const credentials = await getStoredCredentials().catch(() => null);
|
|
212
|
+
if (credentials) {
|
|
213
|
+
logger.error(describeAgentLoadError(error, agentId, credentials, {
|
|
214
|
+
dev: options.dev,
|
|
215
|
+
workspaceOverride: options.workspace,
|
|
216
|
+
zoneOverride: options.zone,
|
|
217
|
+
}));
|
|
218
|
+
} else {
|
|
219
|
+
const message = error instanceof Error ? error.message : 'Unknown error while fetching the agent';
|
|
220
|
+
logger.error(message);
|
|
221
|
+
}
|
|
211
222
|
process.exit(1);
|
|
212
223
|
}
|
|
213
|
-
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
addExamples(getCommand, [
|
|
227
|
+
{ description: 'Show the agent in a human-friendly layout',
|
|
228
|
+
command: 'plazbot agent get agt_AbcDef123' },
|
|
229
|
+
{ description: 'Dump the full raw JSON (useful for piping to jq)',
|
|
230
|
+
command: 'plazbot agent get agt_AbcDef123 --raw' },
|
|
231
|
+
{ description: 'Inspect an agent from another workspace (support mode)',
|
|
232
|
+
command: 'plazbot agent get agt_AbcDef123 -w wok_Other123 -z LA' },
|
|
233
|
+
]);
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
2
|
+
import { addExamples } from '../../utils/help.js';
|
|
3
|
+
import { listCommand } from './list.js';
|
|
4
|
+
import { getCommand } from './get.js';
|
|
5
|
+
import { deleteCommand } from './delete.js';
|
|
6
|
+
import { createCommand } from './create.js';
|
|
7
|
+
import { updateCommand } from './update.js';
|
|
8
|
+
import { enableCommand } from './enable-widget.js';
|
|
9
|
+
import { chatCommand } from './chat.js';
|
|
10
|
+
import { messageCommand } from './on-message.js';
|
|
11
|
+
import { toolsCommand } from './tools.js';
|
|
12
|
+
import { aiConfigCommand } from './ai-config.js';
|
|
13
|
+
import { templatesCommand } from './templates.js';
|
|
14
|
+
import { copyCommand } from './copy.js';
|
|
15
|
+
import { filesCommand } from './files.js';
|
|
16
|
+
import { setCommand } from './set.js';
|
|
17
|
+
import { monitorCommand } from './monitor.js';
|
|
18
|
+
import { exportCommand, crossCopyCommand } from './export.js';
|
|
19
|
+
import { validateCommand } from './validate.js';
|
|
18
20
|
|
|
19
21
|
export const agentCommands = new Command('agent')
|
|
20
|
-
.description('
|
|
22
|
+
.description('Commands related to AI agents')
|
|
21
23
|
.addCommand(listCommand)
|
|
22
24
|
.addCommand(getCommand)
|
|
23
25
|
.addCommand(deleteCommand)
|
|
@@ -34,4 +36,20 @@ export const agentCommands = new Command('agent')
|
|
|
34
36
|
.addCommand(setCommand)
|
|
35
37
|
.addCommand(monitorCommand)
|
|
36
38
|
.addCommand(exportCommand)
|
|
37
|
-
.addCommand(crossCopyCommand)
|
|
39
|
+
.addCommand(crossCopyCommand)
|
|
40
|
+
.addCommand(validateCommand);
|
|
41
|
+
|
|
42
|
+
addExamples(agentCommands, [
|
|
43
|
+
{ description: 'List agents in the active workspace',
|
|
44
|
+
command: 'plazbot agent list' },
|
|
45
|
+
{ description: 'Chat interactively with an agent',
|
|
46
|
+
command: 'plazbot agent chat agt_AbcDef123' },
|
|
47
|
+
{ description: 'Create an agent from a JSON template',
|
|
48
|
+
command: 'plazbot agent create ./agent.json' },
|
|
49
|
+
{ description: 'Export an agent and copy it to another workspace',
|
|
50
|
+
command: 'plazbot agent cross-copy agt_AbcDef123 --from-workspace wok_Source --to-workspace wok_Target' },
|
|
51
|
+
{ description: 'Monitor activity of an agent in real time',
|
|
52
|
+
command: 'plazbot agent monitor agt_AbcDef123' },
|
|
53
|
+
{ description: 'Validate a local agent JSON file against the schema',
|
|
54
|
+
command: 'plazbot agent validate ./agent.json' },
|
|
55
|
+
]);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Agent } from 'plazbot';
|
|
3
|
-
import { getStoredCredentials } from '../../utils/credentials';
|
|
4
|
-
import { logger } from '../../utils/logger';
|
|
5
|
-
import {
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
import { ListAgentsOptions } from '../../types/agent.js';
|
|
6
7
|
|
|
7
8
|
export const listCommand = new Command('list')
|
|
8
|
-
.description('
|
|
9
|
-
.option('--dev', '
|
|
9
|
+
.description('List all agents in the workspace')
|
|
10
|
+
.option('--dev', 'Use development environment (localhost:5090)', false)
|
|
10
11
|
.action(async (options: ListAgentsOptions) => {
|
|
11
12
|
try {
|
|
12
13
|
// Obtener credenciales guardadas
|
|
@@ -24,29 +25,34 @@ export const listCommand = new Command('list')
|
|
|
24
25
|
const agents = await agent.getAgents();
|
|
25
26
|
|
|
26
27
|
if (agents.length === 0) {
|
|
27
|
-
logger.info('No
|
|
28
|
+
logger.info('No agents found in this workspace');
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
logger.info('\
|
|
32
|
+
logger.info('\nAgents:');
|
|
32
33
|
logger.doubleDivider();
|
|
33
|
-
|
|
34
|
+
|
|
34
35
|
agents.forEach((a: any, index: number) => {
|
|
35
36
|
logger.info(`${index + 1}. ID: ${a.id}`);
|
|
36
|
-
logger.info(`
|
|
37
|
-
logger.info(`
|
|
38
|
-
logger.info(`
|
|
39
|
-
logger.info(`
|
|
37
|
+
logger.info(` Name: ${a.name}`);
|
|
38
|
+
logger.info(` Status: ${a.enable ? 'Active' : 'Inactive'}`);
|
|
39
|
+
logger.info(` Description: ${a.description}`);
|
|
40
|
+
logger.info(` Created: ${a.createdAt ? new Date(a.createdAt).toLocaleString() : 'N/A'}`);
|
|
40
41
|
logger.divider();
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
if (options.dev) {
|
|
44
|
-
logger.warning('
|
|
45
|
+
logger.warning('Environment: development');
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
+
|
|
47
48
|
} catch (error) {
|
|
48
|
-
const message = error instanceof Error ? error.message : '
|
|
49
|
+
const message = error instanceof Error ? error.message : 'Unknown error while listing agents';
|
|
49
50
|
logger.error(message);
|
|
50
51
|
process.exit(1);
|
|
51
52
|
}
|
|
52
|
-
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
addExamples(listCommand, [
|
|
56
|
+
{ description: 'List every agent in the active workspace', command: 'plazbot agent list' },
|
|
57
|
+
{ description: 'List against a local backend (dev mode)', command: 'plazbot agent list --dev' },
|
|
58
|
+
]);
|