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,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
login_1.loginCommand,
|
|
9
|
-
logout_1.logoutCommand,
|
|
10
|
-
status_1.statusCommand
|
|
1
|
+
import { loginCommand } from './login.js';
|
|
2
|
+
import { logoutCommand } from './logout.js';
|
|
3
|
+
import { statusCommand } from './status.js';
|
|
4
|
+
export const authCommands = [
|
|
5
|
+
loginCommand,
|
|
6
|
+
logoutCommand,
|
|
7
|
+
statusCommand
|
|
11
8
|
];
|
|
@@ -1,53 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.
|
|
9
|
-
.requiredOption('-
|
|
10
|
-
.requiredOption('-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { saveCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
export const loginCommand = new Command('init')
|
|
6
|
+
.description('Save the API key and user email locally')
|
|
7
|
+
.option('-e, --email <email>', 'User email (optional)')
|
|
8
|
+
.requiredOption('-k, --api-key <apiKey>', 'User API key')
|
|
9
|
+
.requiredOption('-w, --workspace <workspace>', 'Workspace ID')
|
|
10
|
+
.requiredOption('-z, --zone <zone>', 'Zone (LA or EU)')
|
|
11
|
+
.option('-u, --user-id <userId>', 'User ID for x-user-id (optional, used by studio)')
|
|
12
|
+
.option('--dev', 'Use development environment', false)
|
|
14
13
|
.action(async (options) => {
|
|
15
14
|
try {
|
|
16
15
|
// Limpiar la pantalla
|
|
17
16
|
console.clear();
|
|
18
17
|
// Banner de bienvenida
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
await
|
|
29
|
-
email: options.email,
|
|
18
|
+
logger.info('┌' + '─'.repeat(70) + '┐');
|
|
19
|
+
logger.info('│' + ' Welcome to Plazbot CLI'.padEnd(69) + '│');
|
|
20
|
+
logger.info('│' + ''.padEnd(69) + '│');
|
|
21
|
+
logger.info('│' + ' With this tool you can:'.padEnd(69) + '│');
|
|
22
|
+
logger.info('│' + ' Create and update agents'.padEnd(69) + '│');
|
|
23
|
+
logger.info('│' + ' Manage configurations'.padEnd(69) + '│');
|
|
24
|
+
logger.info('│' + ' Interact with your agents'.padEnd(69) + '│');
|
|
25
|
+
logger.info('│' + ' Activate all their capabilities'.padEnd(69) + '│');
|
|
26
|
+
logger.info('└' + '─'.repeat(70) + '┘\n');
|
|
27
|
+
await saveCredentials({
|
|
28
|
+
email: options.email || '',
|
|
30
29
|
apiKey: options.apiKey,
|
|
31
30
|
workspace: options.workspace,
|
|
32
|
-
zone: options.zone
|
|
31
|
+
zone: options.zone,
|
|
32
|
+
userId: options.userId
|
|
33
33
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
logger.success('Configuration saved successfully:');
|
|
35
|
+
if (options.email)
|
|
36
|
+
logger.label('Email', options.email);
|
|
37
|
+
logger.label('Workspace', options.workspace);
|
|
38
|
+
logger.label('Zone', options.zone);
|
|
39
|
+
if (options.userId)
|
|
40
|
+
logger.label('UserId', options.userId);
|
|
41
|
+
logger.title('You can start by using the following commands');
|
|
42
|
+
logger.dim('plazbot agent list - View your agents');
|
|
43
|
+
logger.dim('plazbot agent templates - Create an agent from a template');
|
|
44
|
+
logger.dim('plazbot agent chat - Chat with an agent');
|
|
45
|
+
logger.dim('plazbot --help - View all commands');
|
|
43
46
|
console.log();
|
|
44
47
|
if (options.dev) {
|
|
45
|
-
|
|
48
|
+
logger.warning('Environment: development');
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
catch (error) {
|
|
49
|
-
const message = error instanceof Error ? error.message : '
|
|
50
|
-
|
|
52
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
53
|
+
logger.error(message);
|
|
51
54
|
process.exit(1);
|
|
52
55
|
}
|
|
53
56
|
});
|
|
57
|
+
addExamples(loginCommand, [
|
|
58
|
+
{ description: 'Save credentials for a LA workspace',
|
|
59
|
+
command: 'plazbot init -e you@company.com -k <jwt> -w wok_AbcDef123 -z LA' },
|
|
60
|
+
{ description: 'Save credentials for an EU workspace',
|
|
61
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z EU' },
|
|
62
|
+
{ description: 'Include userId (used by studio support mode)',
|
|
63
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z LA -u usr_AbcDef123' },
|
|
64
|
+
{ description: 'Target the local backend (dev mode)',
|
|
65
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z LA --dev' },
|
|
66
|
+
]);
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
.description('Elimina la configuración local del usuario')
|
|
9
|
-
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { removeCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
export const logoutCommand = new Command('finish')
|
|
6
|
+
.description('Remove the local user configuration')
|
|
7
|
+
.option('--dev', 'Use development environment', false)
|
|
10
8
|
.action(async (options) => {
|
|
11
9
|
try {
|
|
12
|
-
await
|
|
13
|
-
|
|
10
|
+
await removeCredentials();
|
|
11
|
+
logger.success('You have been signed out successfully');
|
|
14
12
|
if (options.dev) {
|
|
15
|
-
|
|
13
|
+
logger.warning('Environment: development');
|
|
16
14
|
}
|
|
17
15
|
}
|
|
18
16
|
catch (error) {
|
|
19
|
-
const message = error instanceof Error ? error.message : '
|
|
20
|
-
|
|
17
|
+
const message = error instanceof Error ? error.message : 'Unknown error while signing out';
|
|
18
|
+
logger.error(message);
|
|
21
19
|
process.exit(1);
|
|
22
20
|
}
|
|
23
21
|
});
|
|
22
|
+
addExamples(logoutCommand, [
|
|
23
|
+
{ description: 'Remove the local configuration (~/.plazbot/config.json)',
|
|
24
|
+
command: 'plazbot finish' },
|
|
25
|
+
]);
|
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
exports.statusCommand = new commander_1.Command('status')
|
|
9
|
-
.description('Muestra la sesion activa (workspace, email, zona)')
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
import { section } from '../../utils/ui.js';
|
|
6
|
+
export const statusCommand = new Command('status')
|
|
7
|
+
.description('Show the active session (workspace, email, zone)')
|
|
10
8
|
.action(async () => {
|
|
11
9
|
try {
|
|
12
|
-
const credentials = await
|
|
13
|
-
console.log(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
const credentials = await getStoredCredentials();
|
|
11
|
+
console.log(section('Active session'));
|
|
12
|
+
if (credentials.email)
|
|
13
|
+
logger.label('Email', credentials.email);
|
|
14
|
+
logger.label('Workspace', credentials.workspace);
|
|
15
|
+
logger.label('Zone', credentials.zone === 'LA' ? 'Latin America (LA)' : 'Europe (EU)');
|
|
16
|
+
logger.label('API', credentials.zone === 'EU' ? 'https://apieu.plazbot.com' : 'https://api.plazbot.com');
|
|
18
17
|
console.log();
|
|
19
18
|
}
|
|
20
19
|
catch {
|
|
21
|
-
|
|
20
|
+
logger.error("No active session. Run 'plazbot init' to sign in.");
|
|
22
21
|
process.exit(1);
|
|
23
22
|
}
|
|
24
23
|
});
|
|
24
|
+
addExamples(statusCommand, [
|
|
25
|
+
{ description: 'Show the active workspace, email and zone',
|
|
26
|
+
command: 'plazbot status' },
|
|
27
|
+
]);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
.
|
|
11
|
-
.requiredOption('-a, --agent-id <agentId>', 'ID del agente a agregar')
|
|
12
|
-
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Portal, Agent } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
export const addAgentCommand = new Command('add-agent-portal')
|
|
7
|
+
.description('Add an existing agent to a portal')
|
|
8
|
+
.requiredOption('-p, --portal-id <portalId>', 'Portal ID')
|
|
9
|
+
.requiredOption('-a, --agent-id <agentId>', 'ID of the agent to add')
|
|
10
|
+
.option('--dev', 'Use development environment', false)
|
|
13
11
|
.action(async (options) => {
|
|
14
12
|
try {
|
|
15
13
|
// Obtener credenciales guardadas
|
|
16
|
-
const credentials = await
|
|
17
|
-
const portal = new
|
|
14
|
+
const credentials = await getStoredCredentials();
|
|
15
|
+
const portal = new Portal({
|
|
18
16
|
workspaceId: credentials.workspace,
|
|
19
17
|
apiKey: credentials.apiKey,
|
|
20
18
|
zone: credentials.zone,
|
|
@@ -23,7 +21,7 @@ exports.addAgentCommand = new commander_1.Command('add-agent-portal')
|
|
|
23
21
|
// Obtener detalles del portal
|
|
24
22
|
const portalDetails = await portal.getPortal(options.portalId);
|
|
25
23
|
// Crear instancia del agente para obtener sus detalles
|
|
26
|
-
const agent = new
|
|
24
|
+
const agent = new Agent({
|
|
27
25
|
workspaceId: credentials.workspace,
|
|
28
26
|
apiKey: credentials.apiKey,
|
|
29
27
|
zone: credentials.zone,
|
|
@@ -31,23 +29,27 @@ exports.addAgentCommand = new commander_1.Command('add-agent-portal')
|
|
|
31
29
|
});
|
|
32
30
|
// Obtener detalles del agente
|
|
33
31
|
const agentDetails = await agent.getAgentById({ id: options.agentId });
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
logger.title('Operation details');
|
|
33
|
+
logger.label('Portal ID', portalDetails.portal?.id || options.portalId);
|
|
34
|
+
logger.label('Portal Name', portalDetails.portal?.name || 'N/A');
|
|
35
|
+
logger.label('Agent ID', agentDetails.id);
|
|
36
|
+
logger.label('Agent Name', agentDetails.name);
|
|
39
37
|
await portal.addAgentToPortal({
|
|
40
38
|
portalId: options.portalId,
|
|
41
39
|
id: options.agentId
|
|
42
40
|
});
|
|
43
|
-
|
|
41
|
+
logger.success('Agent added to the portal successfully');
|
|
44
42
|
if (options.dev) {
|
|
45
|
-
|
|
43
|
+
logger.warning('Environment: development');
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
catch (error) {
|
|
49
|
-
const message = error instanceof Error ? error.message : '
|
|
50
|
-
|
|
47
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
48
|
+
logger.error(message);
|
|
51
49
|
process.exit(1);
|
|
52
50
|
}
|
|
53
51
|
});
|
|
52
|
+
addExamples(addAgentCommand, [
|
|
53
|
+
{ description: 'Attach an existing agent to a portal',
|
|
54
|
+
command: 'plazbot portal add-agent-portal -p prt_AbcDef123 -a agt_AbcDef123' },
|
|
55
|
+
]);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
.
|
|
11
|
-
.
|
|
12
|
-
.requiredOption('-u, --url <url>', 'URL del enlace')
|
|
13
|
-
.option('--dev', 'Usar entorno de desarrollo')
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Portal } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
export const addLinkCommand = new Command('add-link')
|
|
7
|
+
.description('Add a link to the portal')
|
|
8
|
+
.argument('<portalId>', 'Portal ID')
|
|
9
|
+
.requiredOption('-t, --title <title>', 'Link title')
|
|
10
|
+
.requiredOption('-u, --url <url>', 'Link URL')
|
|
11
|
+
.option('--dev', 'Use development environment')
|
|
14
12
|
.action(async (portalId, options) => {
|
|
15
13
|
try {
|
|
16
|
-
const credentials = await
|
|
17
|
-
const portal = new
|
|
14
|
+
const credentials = await getStoredCredentials();
|
|
15
|
+
const portal = new Portal({
|
|
18
16
|
workspaceId: credentials.workspace,
|
|
19
17
|
apiKey: credentials.apiKey,
|
|
20
18
|
zone: credentials.zone,
|
|
@@ -25,10 +23,16 @@ exports.addLinkCommand = new commander_1.Command('add-link')
|
|
|
25
23
|
value: options.title,
|
|
26
24
|
url: options.url
|
|
27
25
|
});
|
|
28
|
-
|
|
26
|
+
logger.success('Link added successfully');
|
|
29
27
|
}
|
|
30
28
|
catch (error) {
|
|
31
|
-
|
|
29
|
+
logger.error(error.message);
|
|
32
30
|
process.exit(1);
|
|
33
31
|
}
|
|
34
32
|
});
|
|
33
|
+
addExamples(addLinkCommand, [
|
|
34
|
+
{ description: 'Add a documentation link to the portal',
|
|
35
|
+
command: 'plazbot portal add-link prt_AbcDef123 -t "Docs" -u https://docs.example.com' },
|
|
36
|
+
{ description: 'Add a support link',
|
|
37
|
+
command: 'plazbot portal add-link prt_AbcDef123 -t "Contact us" -u https://example.com/contact' },
|
|
38
|
+
]);
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
.argument('<portalId>', 'ID del portal')
|
|
11
|
-
.option('--dev', 'Usar entorno de desarrollo')
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Portal } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
export const clearLinksCommand = new Command('clear-links')
|
|
7
|
+
.description('Remove all links from the portal')
|
|
8
|
+
.argument('<portalId>', 'Portal ID')
|
|
9
|
+
.option('--dev', 'Use development environment')
|
|
12
10
|
.action(async (portalId, options) => {
|
|
13
11
|
try {
|
|
14
|
-
const credentials = await
|
|
15
|
-
const portal = new
|
|
12
|
+
const credentials = await getStoredCredentials();
|
|
13
|
+
const portal = new Portal({
|
|
16
14
|
workspaceId: credentials.workspace,
|
|
17
15
|
apiKey: credentials.apiKey,
|
|
18
16
|
zone: credentials.zone,
|
|
19
17
|
...(options.dev && { customUrl: "http://localhost:5090" })
|
|
20
18
|
});
|
|
21
19
|
await portal.clearLinks(portalId);
|
|
22
|
-
|
|
20
|
+
logger.success('Links removed successfully');
|
|
23
21
|
}
|
|
24
22
|
catch (error) {
|
|
25
|
-
|
|
23
|
+
logger.error(error.message);
|
|
26
24
|
process.exit(1);
|
|
27
25
|
}
|
|
28
26
|
});
|
|
27
|
+
addExamples(clearLinksCommand, [
|
|
28
|
+
{ description: 'Remove every link from a portal',
|
|
29
|
+
command: 'plazbot portal clear-links prt_AbcDef123' },
|
|
30
|
+
]);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
.
|
|
10
|
-
.
|
|
11
|
-
.requiredOption('-t, --title <title>', 'Título de bienvenida del portal')
|
|
12
|
-
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Portal } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
export const createCommand = new Command('create')
|
|
7
|
+
.description('Create a new portal with a simplified configuration')
|
|
8
|
+
.requiredOption('-n, --name <name>', 'Portal name')
|
|
9
|
+
.requiredOption('-t, --title <title>', 'Portal welcome title')
|
|
10
|
+
.option('--dev', 'Use development environment', false)
|
|
13
11
|
.action(async (options) => {
|
|
14
12
|
try {
|
|
15
13
|
// Obtener credenciales guardadas
|
|
16
|
-
const credentials = await
|
|
17
|
-
const portal = new
|
|
14
|
+
const credentials = await getStoredCredentials();
|
|
15
|
+
const portal = new Portal({
|
|
18
16
|
workspaceId: credentials.workspace,
|
|
19
17
|
apiKey: credentials.apiKey,
|
|
20
18
|
zone: credentials.zone,
|
|
@@ -31,17 +29,23 @@ exports.createCommand = new commander_1.Command('create')
|
|
|
31
29
|
disabled: false,
|
|
32
30
|
brandOff: false
|
|
33
31
|
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
logger.success('Portal created successfully');
|
|
33
|
+
logger.title('Portal details');
|
|
34
|
+
logger.label('ID', portalCreated.id);
|
|
35
|
+
logger.label('URL', portalCreated.url);
|
|
38
36
|
if (options.dev) {
|
|
39
|
-
|
|
37
|
+
logger.warning('\nEnvironment: development');
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
40
|
catch (error) {
|
|
43
|
-
const message = error instanceof Error ? error.message : '
|
|
44
|
-
|
|
41
|
+
const message = error instanceof Error ? error.message : 'Unknown error while creating the portal';
|
|
42
|
+
logger.error(message);
|
|
45
43
|
process.exit(1);
|
|
46
44
|
}
|
|
47
45
|
});
|
|
46
|
+
addExamples(createCommand, [
|
|
47
|
+
{ description: 'Create a portal with name and welcome title',
|
|
48
|
+
command: 'plazbot portal create -n "Customer Portal" -t "Welcome to our help center"' },
|
|
49
|
+
{ description: 'Create against the local backend',
|
|
50
|
+
command: 'plazbot portal create -n "Test" -t "Hello" --dev' },
|
|
51
|
+
]);
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.deleteCommand = new commander_1.Command('delete')
|
|
13
|
-
.description('Elimina un portal')
|
|
14
|
-
.argument('<portalId>', 'ID del portal')
|
|
15
|
-
.option('--force', 'Eliminar sin confirmación', false)
|
|
16
|
-
.option('--dev', 'Usar ambiente de desarrollo', false)
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { Portal } from 'plazbot';
|
|
3
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
4
|
+
import { logger } from '../../utils/logger.js';
|
|
5
|
+
import { addExamples } from '../../utils/help.js';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
export const deleteCommand = new Command('delete')
|
|
8
|
+
.description('Delete a portal')
|
|
9
|
+
.argument('<portalId>', 'Portal ID')
|
|
10
|
+
.option('--force', 'Delete without confirmation', false)
|
|
11
|
+
.option('--dev', 'Use development environment', false)
|
|
17
12
|
.action(async (portalId, options) => {
|
|
18
13
|
try {
|
|
19
14
|
// Obtener credenciales guardadas
|
|
20
|
-
const credentials = await
|
|
21
|
-
const portal = new
|
|
15
|
+
const credentials = await getStoredCredentials();
|
|
16
|
+
const portal = new Portal({
|
|
22
17
|
workspaceId: credentials.workspace,
|
|
23
18
|
apiKey: credentials.apiKey,
|
|
24
19
|
zone: credentials.zone,
|
|
@@ -26,32 +21,38 @@ exports.deleteCommand = new commander_1.Command('delete')
|
|
|
26
21
|
});
|
|
27
22
|
// Obtener detalles del portal para mostrar qué se va a eliminar
|
|
28
23
|
const portalDetails = await portal.getPortal(portalId);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
logger.title('Portal to delete');
|
|
25
|
+
logger.label('ID', portalDetails.portal.id);
|
|
26
|
+
logger.label('Name', portalDetails.portal.name);
|
|
27
|
+
logger.label('URL', portalDetails.portal.url);
|
|
33
28
|
if (!options.force) {
|
|
34
|
-
const { confirm } = await
|
|
29
|
+
const { confirm } = await inquirer.prompt([{
|
|
35
30
|
type: 'confirm',
|
|
36
31
|
name: 'confirm',
|
|
37
|
-
message: '
|
|
32
|
+
message: 'Are you sure you want to delete this portal?',
|
|
38
33
|
default: false
|
|
39
34
|
}]);
|
|
40
35
|
if (!confirm) {
|
|
41
|
-
|
|
36
|
+
logger.info('Operation cancelled.');
|
|
42
37
|
return;
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
|
-
|
|
40
|
+
logger.dim('Deleting portal...');
|
|
46
41
|
await portal.deletePortal(portalId);
|
|
47
|
-
|
|
42
|
+
logger.success('Portal deleted successfully');
|
|
48
43
|
if (options.dev) {
|
|
49
|
-
|
|
44
|
+
logger.warning('\nEnvironment: development');
|
|
50
45
|
}
|
|
51
46
|
}
|
|
52
47
|
catch (error) {
|
|
53
|
-
const message = error instanceof Error ? error.message : '
|
|
54
|
-
|
|
48
|
+
const message = error instanceof Error ? error.message : 'Unknown error while deleting the portal';
|
|
49
|
+
logger.error(message);
|
|
55
50
|
process.exit(1);
|
|
56
51
|
}
|
|
57
52
|
});
|
|
53
|
+
addExamples(deleteCommand, [
|
|
54
|
+
{ description: 'Delete a portal with confirmation prompt',
|
|
55
|
+
command: 'plazbot portal delete prt_AbcDef123' },
|
|
56
|
+
{ description: 'Delete without confirmation (use in scripts)',
|
|
57
|
+
command: 'plazbot portal delete prt_AbcDef123 --force' },
|
|
58
|
+
]);
|