plazbot-cli 0.2.26 → 0.3.2
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 +86 -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 +22 -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 +93 -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,15 +1,17 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { saveCredentials } from '../../utils/credentials';
|
|
3
|
-
import { logger } from '../../utils/logger';
|
|
4
|
-
import {
|
|
2
|
+
import { saveCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
import { LoginOptions } from '../../types/auth.js';
|
|
5
6
|
|
|
6
7
|
export const loginCommand = new Command('init')
|
|
7
|
-
.description('
|
|
8
|
-
.
|
|
9
|
-
.requiredOption('-k, --api-key <apiKey>', 'API
|
|
10
|
-
.requiredOption('-w, --workspace <workspace>', 'ID
|
|
11
|
-
.requiredOption('-z, --zone <zone>', '
|
|
12
|
-
.option('--
|
|
8
|
+
.description('Save the API key and user email locally')
|
|
9
|
+
.option('-e, --email <email>', 'User email (optional)')
|
|
10
|
+
.requiredOption('-k, --api-key <apiKey>', 'User API key')
|
|
11
|
+
.requiredOption('-w, --workspace <workspace>', 'Workspace ID')
|
|
12
|
+
.requiredOption('-z, --zone <zone>', 'Zone (LA or EU)')
|
|
13
|
+
.option('-u, --user-id <userId>', 'User ID for x-user-id (optional, used by studio)')
|
|
14
|
+
.option('--dev', 'Use development environment', false)
|
|
13
15
|
.action(async (options: LoginOptions) => {
|
|
14
16
|
try {
|
|
15
17
|
// Limpiar la pantalla
|
|
@@ -17,41 +19,54 @@ export const loginCommand = new Command('init')
|
|
|
17
19
|
|
|
18
20
|
// Banner de bienvenida
|
|
19
21
|
logger.info('┌' + '─'.repeat(70) + '┐');
|
|
20
|
-
logger.info('│' + '
|
|
22
|
+
logger.info('│' + ' Welcome to Plazbot CLI'.padEnd(69) + '│');
|
|
21
23
|
logger.info('│' + ''.padEnd(69) + '│');
|
|
22
|
-
logger.info('│' + '
|
|
23
|
-
logger.info('│' + '
|
|
24
|
-
logger.info('│' + '
|
|
25
|
-
logger.info('│' + '
|
|
26
|
-
logger.info('│' + '
|
|
24
|
+
logger.info('│' + ' With this tool you can:'.padEnd(69) + '│');
|
|
25
|
+
logger.info('│' + ' Create and update agents'.padEnd(69) + '│');
|
|
26
|
+
logger.info('│' + ' Manage configurations'.padEnd(69) + '│');
|
|
27
|
+
logger.info('│' + ' Interact with your agents'.padEnd(69) + '│');
|
|
28
|
+
logger.info('│' + ' Activate all their capabilities'.padEnd(69) + '│');
|
|
27
29
|
logger.info('└' + '─'.repeat(70) + '┘\n');
|
|
28
30
|
|
|
29
31
|
await saveCredentials({
|
|
30
|
-
email: options.email,
|
|
32
|
+
email: options.email || '',
|
|
31
33
|
apiKey: options.apiKey,
|
|
32
34
|
workspace: options.workspace,
|
|
33
|
-
zone: options.zone
|
|
35
|
+
zone: options.zone,
|
|
36
|
+
userId: options.userId
|
|
34
37
|
});
|
|
35
38
|
|
|
36
|
-
logger.success('
|
|
37
|
-
logger.label('Email', options.email);
|
|
39
|
+
logger.success('Configuration saved successfully:');
|
|
40
|
+
if (options.email) logger.label('Email', options.email);
|
|
38
41
|
logger.label('Workspace', options.workspace);
|
|
39
|
-
logger.label('
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
logger.
|
|
43
|
-
logger.dim('plazbot agent
|
|
44
|
-
logger.dim('plazbot agent
|
|
45
|
-
logger.dim('plazbot
|
|
42
|
+
logger.label('Zone', options.zone);
|
|
43
|
+
if (options.userId) logger.label('UserId', options.userId);
|
|
44
|
+
|
|
45
|
+
logger.title('You can start by using the following commands');
|
|
46
|
+
logger.dim('plazbot agent list - View your agents');
|
|
47
|
+
logger.dim('plazbot agent templates - Create an agent from a template');
|
|
48
|
+
logger.dim('plazbot agent chat - Chat with an agent');
|
|
49
|
+
logger.dim('plazbot --help - View all commands');
|
|
46
50
|
console.log();
|
|
47
51
|
|
|
48
52
|
if (options.dev) {
|
|
49
|
-
logger.warning('
|
|
53
|
+
logger.warning('Environment: development');
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
} catch (error) {
|
|
53
|
-
const message = error instanceof Error ? error.message : '
|
|
57
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
54
58
|
logger.error(message);
|
|
55
59
|
process.exit(1);
|
|
56
60
|
}
|
|
57
|
-
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
addExamples(loginCommand, [
|
|
64
|
+
{ description: 'Save credentials for a LA workspace',
|
|
65
|
+
command: 'plazbot init -e you@company.com -k <jwt> -w wok_AbcDef123 -z LA' },
|
|
66
|
+
{ description: 'Save credentials for an EU workspace',
|
|
67
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z EU' },
|
|
68
|
+
{ description: 'Include userId (used by studio support mode)',
|
|
69
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z LA -u usr_AbcDef123' },
|
|
70
|
+
{ description: 'Target the local backend (dev mode)',
|
|
71
|
+
command: 'plazbot init -k <jwt> -w wok_AbcDef123 -z LA --dev' },
|
|
72
|
+
]);
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { removeCredentials } from '../../utils/credentials';
|
|
3
|
-
import { logger } from '../../utils/logger';
|
|
4
|
-
import {
|
|
2
|
+
import { removeCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
import { BaseCommandOptions } from '../../types/common.js';
|
|
5
6
|
|
|
6
7
|
export const logoutCommand = new Command('finish')
|
|
7
|
-
.description('
|
|
8
|
-
.option('--dev', '
|
|
8
|
+
.description('Remove the local user configuration')
|
|
9
|
+
.option('--dev', 'Use development environment', false)
|
|
9
10
|
.action(async (options: BaseCommandOptions) => {
|
|
10
11
|
try {
|
|
11
12
|
await removeCredentials();
|
|
12
|
-
logger.success('
|
|
13
|
-
|
|
13
|
+
logger.success('You have been signed out successfully');
|
|
14
|
+
|
|
14
15
|
if (options.dev) {
|
|
15
|
-
logger.warning('
|
|
16
|
+
logger.warning('Environment: development');
|
|
16
17
|
}
|
|
17
18
|
} catch (error) {
|
|
18
|
-
const message = error instanceof Error ? error.message : '
|
|
19
|
+
const message = error instanceof Error ? error.message : 'Unknown error while signing out';
|
|
19
20
|
logger.error(message);
|
|
20
21
|
process.exit(1);
|
|
21
22
|
}
|
|
22
|
-
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
addExamples(logoutCommand, [
|
|
26
|
+
{ description: 'Remove the local configuration (~/.plazbot/config.json)',
|
|
27
|
+
command: 'plazbot finish' },
|
|
28
|
+
]);
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { getStoredCredentials } from '../../utils/credentials';
|
|
3
|
-
import { logger } from '../../utils/logger';
|
|
4
|
-
import {
|
|
2
|
+
import { getStoredCredentials } from '../../utils/credentials.js';
|
|
3
|
+
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { addExamples } from '../../utils/help.js';
|
|
5
|
+
import { theme, section } from '../../utils/ui.js';
|
|
5
6
|
|
|
6
7
|
export const statusCommand = new Command('status')
|
|
7
|
-
.description('
|
|
8
|
+
.description('Show the active session (workspace, email, zone)')
|
|
8
9
|
.action(async () => {
|
|
9
10
|
try {
|
|
10
11
|
const credentials = await getStoredCredentials();
|
|
11
12
|
|
|
12
|
-
console.log(section('
|
|
13
|
-
logger.label('Email', credentials.email);
|
|
13
|
+
console.log(section('Active session'));
|
|
14
|
+
if (credentials.email) logger.label('Email', credentials.email);
|
|
14
15
|
logger.label('Workspace', credentials.workspace);
|
|
15
|
-
logger.label('
|
|
16
|
+
logger.label('Zone', credentials.zone === 'LA' ? 'Latin America (LA)' : 'Europe (EU)');
|
|
16
17
|
logger.label('API', credentials.zone === 'EU' ? 'https://apieu.plazbot.com' : 'https://api.plazbot.com');
|
|
17
18
|
console.log();
|
|
18
19
|
} catch {
|
|
19
|
-
logger.error("No
|
|
20
|
+
logger.error("No active session. Run 'plazbot init' to sign in.");
|
|
20
21
|
process.exit(1);
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
|
|
25
|
+
addExamples(statusCommand, [
|
|
26
|
+
{ description: 'Show the active workspace, email and zone',
|
|
27
|
+
command: 'plazbot status' },
|
|
28
|
+
]);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Portal, 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 { AddAgentToPortalOptions } from '../../types/portal.js';
|
|
6
7
|
|
|
7
8
|
export const addAgentCommand = new Command('add-agent-portal')
|
|
8
|
-
.description('
|
|
9
|
-
.requiredOption('-p, --portal-id <portalId>', 'ID
|
|
10
|
-
.requiredOption('-a, --agent-id <agentId>', 'ID
|
|
11
|
-
.option('--dev', '
|
|
9
|
+
.description('Add an existing agent to a portal')
|
|
10
|
+
.requiredOption('-p, --portal-id <portalId>', 'Portal ID')
|
|
11
|
+
.requiredOption('-a, --agent-id <agentId>', 'ID of the agent to add')
|
|
12
|
+
.option('--dev', 'Use development environment', false)
|
|
12
13
|
.action(async (options: AddAgentToPortalOptions) => {
|
|
13
14
|
try {
|
|
14
15
|
// Obtener credenciales guardadas
|
|
@@ -35,26 +36,31 @@ export const addAgentCommand = new Command('add-agent-portal')
|
|
|
35
36
|
// Obtener detalles del agente
|
|
36
37
|
const agentDetails = await agent.getAgentById({ id: options.agentId });
|
|
37
38
|
|
|
38
|
-
logger.title('
|
|
39
|
+
logger.title('Operation details');
|
|
39
40
|
logger.label('Portal ID', portalDetails.portal?.id || options.portalId);
|
|
40
|
-
logger.label('Portal
|
|
41
|
-
logger.label('
|
|
42
|
-
logger.label('
|
|
43
|
-
|
|
41
|
+
logger.label('Portal Name', portalDetails.portal?.name || 'N/A');
|
|
42
|
+
logger.label('Agent ID', agentDetails.id);
|
|
43
|
+
logger.label('Agent Name', agentDetails.name);
|
|
44
|
+
|
|
44
45
|
await portal.addAgentToPortal({
|
|
45
46
|
portalId: options.portalId,
|
|
46
47
|
id: options.agentId
|
|
47
48
|
});
|
|
48
49
|
|
|
49
|
-
logger.success('
|
|
50
|
-
|
|
50
|
+
logger.success('Agent added to the portal successfully');
|
|
51
|
+
|
|
51
52
|
if (options.dev) {
|
|
52
|
-
logger.warning('
|
|
53
|
+
logger.warning('Environment: development');
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
} catch (error) {
|
|
56
|
-
const message = error instanceof Error ? error.message : '
|
|
57
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
57
58
|
logger.error(message);
|
|
58
59
|
process.exit(1);
|
|
59
60
|
}
|
|
60
|
-
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
addExamples(addAgentCommand, [
|
|
64
|
+
{ description: 'Attach an existing agent to a portal',
|
|
65
|
+
command: 'plazbot portal add-agent-portal -p prt_AbcDef123 -a agt_AbcDef123' },
|
|
66
|
+
]);
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
2
|
import { Portal } 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 { BaseCommandOptions } from '../../types/common.js'
|
|
6
7
|
|
|
7
8
|
interface AddLinkOptions extends BaseCommandOptions {
|
|
8
9
|
title: string
|
|
@@ -10,11 +11,11 @@ interface AddLinkOptions extends BaseCommandOptions {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
export const addLinkCommand = new Command('add-link')
|
|
13
|
-
.description('
|
|
14
|
-
.argument('<portalId>', 'ID
|
|
15
|
-
.requiredOption('-t, --title <title>', '
|
|
16
|
-
.requiredOption('-u, --url <url>', 'URL
|
|
17
|
-
.option('--dev', '
|
|
14
|
+
.description('Add a link to the portal')
|
|
15
|
+
.argument('<portalId>', 'Portal ID')
|
|
16
|
+
.requiredOption('-t, --title <title>', 'Link title')
|
|
17
|
+
.requiredOption('-u, --url <url>', 'Link URL')
|
|
18
|
+
.option('--dev', 'Use development environment')
|
|
18
19
|
.action(async (portalId: string, options: AddLinkOptions) => {
|
|
19
20
|
try {
|
|
20
21
|
const credentials = await getStoredCredentials()
|
|
@@ -31,9 +32,16 @@ export const addLinkCommand = new Command('add-link')
|
|
|
31
32
|
url: options.url
|
|
32
33
|
})
|
|
33
34
|
|
|
34
|
-
logger.success('
|
|
35
|
+
logger.success('Link added successfully')
|
|
35
36
|
} catch (error: unknown) {
|
|
36
37
|
logger.error((error as Error).message)
|
|
37
38
|
process.exit(1)
|
|
38
39
|
}
|
|
39
40
|
})
|
|
41
|
+
|
|
42
|
+
addExamples(addLinkCommand, [
|
|
43
|
+
{ description: 'Add a documentation link to the portal',
|
|
44
|
+
command: 'plazbot portal add-link prt_AbcDef123 -t "Docs" -u https://docs.example.com' },
|
|
45
|
+
{ description: 'Add a support link',
|
|
46
|
+
command: 'plazbot portal add-link prt_AbcDef123 -t "Contact us" -u https://example.com/contact' },
|
|
47
|
+
])
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Portal } 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 { BaseCommandOptions } from '../../types/common.js';
|
|
6
7
|
|
|
7
8
|
export const clearLinksCommand = new Command('clear-links')
|
|
8
|
-
.description('
|
|
9
|
-
.argument('<portalId>', 'ID
|
|
10
|
-
.option('--dev', '
|
|
9
|
+
.description('Remove all links from the portal')
|
|
10
|
+
.argument('<portalId>', 'Portal ID')
|
|
11
|
+
.option('--dev', 'Use development environment')
|
|
11
12
|
.action(async (portalId: string, options: BaseCommandOptions) => {
|
|
12
13
|
try {
|
|
13
14
|
const credentials = await getStoredCredentials();
|
|
@@ -19,9 +20,14 @@ export const clearLinksCommand = new Command('clear-links')
|
|
|
19
20
|
});
|
|
20
21
|
|
|
21
22
|
await portal.clearLinks(portalId);
|
|
22
|
-
logger.success('
|
|
23
|
+
logger.success('Links removed successfully');
|
|
23
24
|
} catch (error: unknown) {
|
|
24
25
|
logger.error((error as Error).message);
|
|
25
26
|
process.exit(1);
|
|
26
27
|
}
|
|
27
28
|
});
|
|
29
|
+
|
|
30
|
+
addExamples(clearLinksCommand, [
|
|
31
|
+
{ description: 'Remove every link from a portal',
|
|
32
|
+
command: 'plazbot portal clear-links prt_AbcDef123' },
|
|
33
|
+
]);
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Portal } 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 { PortalCommandOptions } from '../../types/portal.js';
|
|
6
7
|
|
|
7
8
|
export const createCommand = new Command('create')
|
|
8
|
-
.description('
|
|
9
|
-
.requiredOption('-n, --name <name>', '
|
|
10
|
-
.requiredOption('-t, --title <title>', '
|
|
11
|
-
.option('--dev', '
|
|
9
|
+
.description('Create a new portal with a simplified configuration')
|
|
10
|
+
.requiredOption('-n, --name <name>', 'Portal name')
|
|
11
|
+
.requiredOption('-t, --title <title>', 'Portal welcome title')
|
|
12
|
+
.option('--dev', 'Use development environment', false)
|
|
12
13
|
.action(async (options: PortalCommandOptions & { name: string; title: string }) => {
|
|
13
14
|
try {
|
|
14
15
|
// Obtener credenciales guardadas
|
|
@@ -33,18 +34,25 @@ export const createCommand = new Command('create')
|
|
|
33
34
|
brandOff: false
|
|
34
35
|
});
|
|
35
36
|
|
|
36
|
-
logger.success('Portal
|
|
37
|
-
logger.title('
|
|
37
|
+
logger.success('Portal created successfully');
|
|
38
|
+
logger.title('Portal details');
|
|
38
39
|
logger.label('ID', portalCreated.id);
|
|
39
40
|
logger.label('URL', portalCreated.url);
|
|
40
41
|
|
|
41
42
|
if (options.dev) {
|
|
42
|
-
logger.warning('\
|
|
43
|
+
logger.warning('\nEnvironment: development');
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
} catch (error) {
|
|
46
|
-
const message = error instanceof Error ? error.message : '
|
|
47
|
+
const message = error instanceof Error ? error.message : 'Unknown error while creating the portal';
|
|
47
48
|
logger.error(message);
|
|
48
49
|
process.exit(1);
|
|
49
50
|
}
|
|
50
|
-
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
addExamples(createCommand, [
|
|
54
|
+
{ description: 'Create a portal with name and welcome title',
|
|
55
|
+
command: 'plazbot portal create -n "Customer Portal" -t "Welcome to our help center"' },
|
|
56
|
+
{ description: 'Create against the local backend',
|
|
57
|
+
command: 'plazbot portal create -n "Test" -t "Hello" --dev' },
|
|
58
|
+
]);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Portal } 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 { PortalCommandOptions, PortalResponse } from '../../types/portal.js';
|
|
6
7
|
import inquirer from 'inquirer';
|
|
7
8
|
|
|
8
9
|
export const deleteCommand = new Command('delete')
|
|
9
|
-
.description('
|
|
10
|
-
.argument('<portalId>', 'ID
|
|
11
|
-
.option('--force', '
|
|
12
|
-
.option('--dev', '
|
|
10
|
+
.description('Delete a portal')
|
|
11
|
+
.argument('<portalId>', 'Portal ID')
|
|
12
|
+
.option('--force', 'Delete without confirmation', false)
|
|
13
|
+
.option('--dev', 'Use development environment', false)
|
|
13
14
|
.action(async (portalId: string, options: PortalCommandOptions) => {
|
|
14
15
|
try {
|
|
15
16
|
// Obtener credenciales guardadas
|
|
@@ -25,38 +26,45 @@ export const deleteCommand = new Command('delete')
|
|
|
25
26
|
// Obtener detalles del portal para mostrar qué se va a eliminar
|
|
26
27
|
const portalDetails = await portal.getPortal(portalId) as PortalResponse;
|
|
27
28
|
|
|
28
|
-
logger.title('Portal
|
|
29
|
+
logger.title('Portal to delete');
|
|
29
30
|
logger.label('ID', portalDetails.portal.id);
|
|
30
|
-
logger.label('
|
|
31
|
+
logger.label('Name', portalDetails.portal.name);
|
|
31
32
|
logger.label('URL', portalDetails.portal.url);
|
|
32
|
-
|
|
33
|
+
|
|
33
34
|
if (!options.force) {
|
|
34
35
|
const { confirm } = await inquirer.prompt([{
|
|
35
36
|
type: 'confirm',
|
|
36
37
|
name: 'confirm',
|
|
37
|
-
message: '
|
|
38
|
+
message: 'Are you sure you want to delete this portal?',
|
|
38
39
|
default: false
|
|
39
40
|
}]);
|
|
40
41
|
|
|
41
42
|
if (!confirm) {
|
|
42
|
-
logger.info('
|
|
43
|
+
logger.info('Operation cancelled.');
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
logger.dim('
|
|
48
|
-
|
|
48
|
+
logger.dim('Deleting portal...');
|
|
49
|
+
|
|
49
50
|
await portal.deletePortal(portalId);
|
|
50
|
-
|
|
51
|
-
logger.success('Portal
|
|
52
|
-
|
|
51
|
+
|
|
52
|
+
logger.success('Portal deleted successfully');
|
|
53
|
+
|
|
53
54
|
if (options.dev) {
|
|
54
|
-
logger.warning('\
|
|
55
|
+
logger.warning('\nEnvironment: development');
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
} catch (error) {
|
|
58
|
-
const message = error instanceof Error ? error.message : '
|
|
59
|
+
const message = error instanceof Error ? error.message : 'Unknown error while deleting the portal';
|
|
59
60
|
logger.error(message);
|
|
60
61
|
process.exit(1);
|
|
61
62
|
}
|
|
62
|
-
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
addExamples(deleteCommand, [
|
|
66
|
+
{ description: 'Delete a portal with confirmation prompt',
|
|
67
|
+
command: 'plazbot portal delete prt_AbcDef123' },
|
|
68
|
+
{ description: 'Delete without confirmation (use in scripts)',
|
|
69
|
+
command: 'plazbot portal delete prt_AbcDef123 --force' },
|
|
70
|
+
]);
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { Portal } 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 { PortalCommandOptions, PortalResponse, PortalLink, PortalAgent } from '../../types/portal.js';
|
|
6
7
|
|
|
7
8
|
export const getCommand = new Command('get')
|
|
8
|
-
.description('
|
|
9
|
-
.argument('<portalId>', 'ID
|
|
10
|
-
.option('--dev', '
|
|
9
|
+
.description('Show detailed information for a portal')
|
|
10
|
+
.argument('<portalId>', 'Portal ID')
|
|
11
|
+
.option('--dev', 'Use development environment', false)
|
|
11
12
|
.action(async (portalId: string, options: PortalCommandOptions) => {
|
|
12
13
|
try {
|
|
13
14
|
// Obtener credenciales guardadas
|
|
@@ -23,49 +24,54 @@ export const getCommand = new Command('get')
|
|
|
23
24
|
const response = await portal.getPortal(portalId) as PortalResponse;
|
|
24
25
|
const portalDetails = response.portal;
|
|
25
26
|
|
|
26
|
-
logger.title('
|
|
27
|
+
logger.title('Portal details');
|
|
27
28
|
logger.label('ID', portalDetails.id);
|
|
28
|
-
logger.label('
|
|
29
|
+
logger.label('Name', portalDetails.name);
|
|
29
30
|
logger.label('URL', portalDetails.url);
|
|
30
|
-
logger.label('
|
|
31
|
-
logger.label('
|
|
31
|
+
logger.label('Access', portalDetails.access);
|
|
32
|
+
logger.label('Status', portalDetails.disabled ? 'Disabled' : 'Enabled');
|
|
32
33
|
|
|
33
34
|
if (portalDetails.title) {
|
|
34
|
-
logger.label('
|
|
35
|
+
logger.label('Title', portalDetails.title);
|
|
35
36
|
}
|
|
36
37
|
if (portalDetails.subtitle) {
|
|
37
|
-
logger.label('
|
|
38
|
+
logger.label('Subtitle', portalDetails.subtitle);
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
if (portalDetails.logo) {
|
|
41
|
-
logger.title('
|
|
42
|
+
logger.title('Assets');
|
|
42
43
|
logger.label('Logo', portalDetails.logo);
|
|
43
44
|
if (portalDetails.logodark) {
|
|
44
|
-
logger.label('Logo (
|
|
45
|
+
logger.label('Logo (dark mode)', portalDetails.logodark);
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
if (portalDetails.links && portalDetails.links.length > 0) {
|
|
49
|
-
logger.title('
|
|
50
|
+
logger.title('Links');
|
|
50
51
|
portalDetails.links.forEach((link: PortalLink) => {
|
|
51
52
|
logger.label(link.value, link.url);
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
if (portalDetails.agents && portalDetails.agents.length > 0) {
|
|
56
|
-
logger.title('
|
|
57
|
+
logger.title('Associated agents');
|
|
57
58
|
portalDetails.agents.forEach((agent: PortalAgent) => {
|
|
58
59
|
logger.label(agent.name, agent.id);
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
if (options.dev) {
|
|
63
|
-
logger.warning('\
|
|
64
|
+
logger.warning('\nEnvironment: development');
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
} catch (error) {
|
|
67
|
-
const message = error instanceof Error ? error.message : '
|
|
68
|
+
const message = error instanceof Error ? error.message : 'Unknown error while fetching portal details';
|
|
68
69
|
logger.error(message);
|
|
69
70
|
process.exit(1);
|
|
70
71
|
}
|
|
71
|
-
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
addExamples(getCommand, [
|
|
75
|
+
{ description: 'Show details for a specific portal',
|
|
76
|
+
command: 'plazbot portal get prt_AbcDef123' },
|
|
77
|
+
]);
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
2
|
+
import { addExamples } from '../../utils/help.js';
|
|
3
|
+
import { getCommand } from './get.js';
|
|
4
|
+
import { deleteCommand } from './delete.js';
|
|
5
|
+
import { createCommand } from './create.js';
|
|
6
|
+
import { updateCommand } from './update.js';
|
|
7
|
+
import { addAgentCommand } from './add-agent.js';
|
|
8
|
+
import { listCommand } from './list.js';
|
|
9
|
+
import { addLinkCommand } from './add-link.js';
|
|
10
|
+
import { clearLinksCommand } from './clear-links.js';
|
|
10
11
|
|
|
11
12
|
export const portalCommands = new Command('portal')
|
|
12
|
-
.description('
|
|
13
|
+
.description('Commands related to portals')
|
|
13
14
|
.addCommand(listCommand)
|
|
14
15
|
.addCommand(getCommand)
|
|
15
16
|
.addCommand(deleteCommand)
|
|
@@ -17,4 +18,15 @@ export const portalCommands = new Command('portal')
|
|
|
17
18
|
.addCommand(updateCommand)
|
|
18
19
|
.addCommand(addAgentCommand)
|
|
19
20
|
.addCommand(addLinkCommand)
|
|
20
|
-
.addCommand(clearLinksCommand);
|
|
21
|
+
.addCommand(clearLinksCommand);
|
|
22
|
+
|
|
23
|
+
addExamples(portalCommands, [
|
|
24
|
+
{ description: 'List the portal of the active workspace',
|
|
25
|
+
command: 'plazbot portal list' },
|
|
26
|
+
{ description: 'Create a portal',
|
|
27
|
+
command: 'plazbot portal create -n "Help Center" -t "Welcome"' },
|
|
28
|
+
{ description: 'Attach an agent to a portal',
|
|
29
|
+
command: 'plazbot portal add-agent-portal -p prt_AbcDef123 -a agt_AbcDef123' },
|
|
30
|
+
{ description: 'Add a link to a portal',
|
|
31
|
+
command: 'plazbot portal add-link prt_AbcDef123 -t "Docs" -u https://docs.example.com' },
|
|
32
|
+
]);
|