plazbot-cli 0.3.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/README.md +38 -2
  2. package/dist/commands/auth/browser-login.js +121 -0
  3. package/dist/commands/auth/index.js +5 -1
  4. package/dist/commands/auth/login.js +1 -3
  5. package/dist/commands/auth/logout.js +4 -3
  6. package/dist/commands/auth/status.js +8 -5
  7. package/dist/commands/auth/workspace.js +73 -0
  8. package/dist/commands/whatsapp/connect-flow.js +137 -0
  9. package/dist/commands/whatsapp/connect.js +26 -160
  10. package/dist/commands/whatsapp/index.js +4 -0
  11. package/dist/commands/whatsapp/setup.js +242 -0
  12. package/dist/studio/components/App.js +1 -1
  13. package/dist/studio/runOneShot.js +2 -2
  14. package/dist/studio/runRepl.js +1 -1
  15. package/dist/utils/agent-errors.js +2 -2
  16. package/dist/utils/banner.js +10 -9
  17. package/dist/utils/credentials.js +31 -3
  18. package/dist/utils/open-browser.js +17 -0
  19. package/package.json +14 -6
  20. package/.claude/settings.local.json +0 -19
  21. package/CLAUDE.md +0 -121
  22. package/agent.config.json +0 -21
  23. package/dist/studio/components/AgentPanel.js +0 -35
  24. package/dist/studio/render/json.js +0 -16
  25. package/dist/studio/whatsapp/api.js +0 -63
  26. package/dist/studio/whatsapp/polling.js +0 -77
  27. package/dist/studio/whatsapp/types.js +0 -31
  28. package/src/cli.ts +0 -57
  29. package/src/commands/agent/ai-config.ts +0 -164
  30. package/src/commands/agent/chat.ts +0 -225
  31. package/src/commands/agent/copy.ts +0 -46
  32. package/src/commands/agent/create.ts +0 -103
  33. package/src/commands/agent/delete.ts +0 -71
  34. package/src/commands/agent/enable-widget.ts +0 -67
  35. package/src/commands/agent/export.ts +0 -430
  36. package/src/commands/agent/files.ts +0 -171
  37. package/src/commands/agent/get.ts +0 -233
  38. package/src/commands/agent/index.ts +0 -55
  39. package/src/commands/agent/list.ts +0 -58
  40. package/src/commands/agent/monitor.ts +0 -375
  41. package/src/commands/agent/on-message.ts +0 -82
  42. package/src/commands/agent/set.ts +0 -149
  43. package/src/commands/agent/templates.ts +0 -892
  44. package/src/commands/agent/tools.ts +0 -168
  45. package/src/commands/agent/update.ts +0 -61
  46. package/src/commands/agent/validate.ts +0 -135
  47. package/src/commands/agent/wizard.ts +0 -756
  48. package/src/commands/auth/index.ts +0 -10
  49. package/src/commands/auth/login.ts +0 -72
  50. package/src/commands/auth/logout.ts +0 -28
  51. package/src/commands/auth/status.ts +0 -28
  52. package/src/commands/portal/add-agent.ts +0 -66
  53. package/src/commands/portal/add-link.ts +0 -47
  54. package/src/commands/portal/clear-links.ts +0 -33
  55. package/src/commands/portal/create.ts +0 -58
  56. package/src/commands/portal/delete.ts +0 -70
  57. package/src/commands/portal/get.ts +0 -77
  58. package/src/commands/portal/index.ts +0 -32
  59. package/src/commands/portal/list.ts +0 -79
  60. package/src/commands/portal/update.ts +0 -93
  61. package/src/commands/whatsapp/broadcast.ts +0 -110
  62. package/src/commands/whatsapp/channels.ts +0 -109
  63. package/src/commands/whatsapp/chat.ts +0 -85
  64. package/src/commands/whatsapp/connect.ts +0 -220
  65. package/src/commands/whatsapp/delete-webhook.ts +0 -43
  66. package/src/commands/whatsapp/index.ts +0 -37
  67. package/src/commands/whatsapp/register-webhook.ts +0 -47
  68. package/src/commands/whatsapp/send-template.ts +0 -94
  69. package/src/commands/whatsapp/send.ts +0 -55
  70. package/src/commands/whatsapp/widget.ts +0 -75
  71. package/src/commands/workers/deploy.ts +0 -156
  72. package/src/commands/workers/index.ts +0 -30
  73. package/src/commands/workers/list.ts +0 -105
  74. package/src/commands/workers/logs.ts +0 -99
  75. package/src/commands/workers/remove.ts +0 -103
  76. package/src/commands/workers/secret.ts +0 -191
  77. package/src/commands/workers/test.ts +0 -145
  78. package/src/schemas/agent.config.schema.json +0 -569
  79. package/src/studio/api/sseClient.ts +0 -91
  80. package/src/studio/api/studioApi.ts +0 -27
  81. package/src/studio/api/types.ts +0 -96
  82. package/src/studio/components/App.tsx +0 -274
  83. package/src/studio/components/ChatLog.tsx +0 -121
  84. package/src/studio/components/ConnectCard.tsx +0 -171
  85. package/src/studio/components/Footer.tsx +0 -38
  86. package/src/studio/components/Header.tsx +0 -39
  87. package/src/studio/components/Input.tsx +0 -176
  88. package/src/studio/components/Message.tsx +0 -87
  89. package/src/studio/components/Suggestions.tsx +0 -26
  90. package/src/studio/components/ToolCall.tsx +0 -58
  91. package/src/studio/connect/api.ts +0 -98
  92. package/src/studio/connect/polling.ts +0 -94
  93. package/src/studio/connect/types.ts +0 -141
  94. package/src/studio/index.ts +0 -58
  95. package/src/studio/render/markdown.ts +0 -93
  96. package/src/studio/render/steps.ts +0 -57
  97. package/src/studio/runOneShot.ts +0 -114
  98. package/src/studio/runRepl.tsx +0 -82
  99. package/src/studio/slash/handlers.ts +0 -226
  100. package/src/studio/slash/parser.ts +0 -41
  101. package/src/studio/slash/registry.ts +0 -54
  102. package/src/studio/state/store.ts +0 -279
  103. package/src/types/agent.ts +0 -63
  104. package/src/types/auth.ts +0 -9
  105. package/src/types/common.ts +0 -10
  106. package/src/types/message.ts +0 -34
  107. package/src/types/portal.ts +0 -56
  108. package/src/types/workers.ts +0 -86
  109. package/src/utils/agent-errors.ts +0 -67
  110. package/src/utils/api.ts +0 -35
  111. package/src/utils/banner.ts +0 -99
  112. package/src/utils/credentials.ts +0 -38
  113. package/src/utils/help.ts +0 -51
  114. package/src/utils/logger.ts +0 -40
  115. package/src/utils/ui.ts +0 -109
  116. package/tsconfig.json +0 -18
@@ -1,10 +0,0 @@
1
- import { Command } from 'commander';
2
- import { loginCommand } from './login.js';
3
- import { logoutCommand } from './logout.js';
4
- import { statusCommand } from './status.js';
5
-
6
- export const authCommands: Command[] = [
7
- loginCommand,
8
- logoutCommand,
9
- statusCommand
10
- ];
@@ -1,72 +0,0 @@
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
- import { LoginOptions } from '../../types/auth.js';
6
-
7
- export const loginCommand = new Command('init')
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)
15
- .action(async (options: LoginOptions) => {
16
- try {
17
- // Limpiar la pantalla
18
- console.clear();
19
-
20
- // Banner de bienvenida
21
- logger.info('┌' + '─'.repeat(70) + '┐');
22
- logger.info('│' + ' Welcome to Plazbot CLI'.padEnd(69) + '│');
23
- logger.info('│' + ''.padEnd(69) + '│');
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) + '│');
29
- logger.info('└' + '─'.repeat(70) + '┘\n');
30
-
31
- await saveCredentials({
32
- email: options.email || '',
33
- apiKey: options.apiKey,
34
- workspace: options.workspace,
35
- zone: options.zone,
36
- userId: options.userId
37
- });
38
-
39
- logger.success('Configuration saved successfully:');
40
- if (options.email) logger.label('Email', options.email);
41
- logger.label('Workspace', options.workspace);
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');
50
- console.log();
51
-
52
- if (options.dev) {
53
- logger.warning('Environment: development');
54
- }
55
-
56
- } catch (error) {
57
- const message = error instanceof Error ? error.message : 'Unknown error';
58
- logger.error(message);
59
- process.exit(1);
60
- }
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,28 +0,0 @@
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
- import { BaseCommandOptions } from '../../types/common.js';
6
-
7
- export const logoutCommand = new Command('finish')
8
- .description('Remove the local user configuration')
9
- .option('--dev', 'Use development environment', false)
10
- .action(async (options: BaseCommandOptions) => {
11
- try {
12
- await removeCredentials();
13
- logger.success('You have been signed out successfully');
14
-
15
- if (options.dev) {
16
- logger.warning('Environment: development');
17
- }
18
- } catch (error) {
19
- const message = error instanceof Error ? error.message : 'Unknown error while signing out';
20
- logger.error(message);
21
- process.exit(1);
22
- }
23
- });
24
-
25
- addExamples(logoutCommand, [
26
- { description: 'Remove the local configuration (~/.plazbot/config.json)',
27
- command: 'plazbot finish' },
28
- ]);
@@ -1,28 +0,0 @@
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 { theme, section } from '../../utils/ui.js';
6
-
7
- export const statusCommand = new Command('status')
8
- .description('Show the active session (workspace, email, zone)')
9
- .action(async () => {
10
- try {
11
- const credentials = await getStoredCredentials();
12
-
13
- console.log(section('Active session'));
14
- if (credentials.email) logger.label('Email', credentials.email);
15
- logger.label('Workspace', credentials.workspace);
16
- logger.label('Zone', credentials.zone === 'LA' ? 'Latin America (LA)' : 'Europe (EU)');
17
- logger.label('API', credentials.zone === 'EU' ? 'https://apieu.plazbot.com' : 'https://api.plazbot.com');
18
- console.log();
19
- } catch {
20
- logger.error("No active session. Run 'plazbot init' to sign in.");
21
- process.exit(1);
22
- }
23
- });
24
-
25
- addExamples(statusCommand, [
26
- { description: 'Show the active workspace, email and zone',
27
- command: 'plazbot status' },
28
- ]);
@@ -1,66 +0,0 @@
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
- import { AddAgentToPortalOptions } from '../../types/portal.js';
7
-
8
- export const addAgentCommand = new Command('add-agent-portal')
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)
13
- .action(async (options: AddAgentToPortalOptions) => {
14
- try {
15
- // Obtener credenciales guardadas
16
- const credentials = await getStoredCredentials();
17
-
18
- const portal = new Portal({
19
- workspaceId: credentials.workspace,
20
- apiKey: credentials.apiKey,
21
- zone: credentials.zone,
22
- ...(options.dev && { customUrl: "http://localhost:5090" })
23
- });
24
-
25
- // Obtener detalles del portal
26
- const portalDetails = await portal.getPortal(options.portalId);
27
-
28
- // Crear instancia del agente para obtener sus detalles
29
- const agent = new Agent({
30
- workspaceId: credentials.workspace,
31
- apiKey: credentials.apiKey,
32
- zone: credentials.zone,
33
- ...(options.dev && { customUrl: "http://localhost:5090" })
34
- });
35
-
36
- // Obtener detalles del agente
37
- const agentDetails = await agent.getAgentById({ id: options.agentId });
38
-
39
- logger.title('Operation details');
40
- logger.label('Portal ID', portalDetails.portal?.id || options.portalId);
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
-
45
- await portal.addAgentToPortal({
46
- portalId: options.portalId,
47
- id: options.agentId
48
- });
49
-
50
- logger.success('Agent added to the portal successfully');
51
-
52
- if (options.dev) {
53
- logger.warning('Environment: development');
54
- }
55
-
56
- } catch (error) {
57
- const message = error instanceof Error ? error.message : 'Unknown error';
58
- logger.error(message);
59
- process.exit(1);
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,47 +0,0 @@
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 { BaseCommandOptions } from '../../types/common.js'
7
-
8
- interface AddLinkOptions extends BaseCommandOptions {
9
- title: string
10
- url: string
11
- }
12
-
13
- export const addLinkCommand = new Command('add-link')
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')
19
- .action(async (portalId: string, options: AddLinkOptions) => {
20
- try {
21
- const credentials = await getStoredCredentials()
22
- const portal = new Portal({
23
- workspaceId: credentials.workspace,
24
- apiKey: credentials.apiKey,
25
- zone: credentials.zone,
26
- ...(options.dev && { customUrl: "http://localhost:5090" })
27
- })
28
-
29
- await portal.addLinkToPortal({
30
- portalId,
31
- value: options.title,
32
- url: options.url
33
- })
34
-
35
- logger.success('Link added successfully')
36
- } catch (error: unknown) {
37
- logger.error((error as Error).message)
38
- process.exit(1)
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,33 +0,0 @@
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 { BaseCommandOptions } from '../../types/common.js';
7
-
8
- export const clearLinksCommand = new Command('clear-links')
9
- .description('Remove all links from the portal')
10
- .argument('<portalId>', 'Portal ID')
11
- .option('--dev', 'Use development environment')
12
- .action(async (portalId: string, options: BaseCommandOptions) => {
13
- try {
14
- const credentials = await getStoredCredentials();
15
- const portal = new Portal({
16
- workspaceId: credentials.workspace,
17
- apiKey: credentials.apiKey,
18
- zone: credentials.zone,
19
- ...(options.dev && { customUrl: "http://localhost:5090" })
20
- });
21
-
22
- await portal.clearLinks(portalId);
23
- logger.success('Links removed successfully');
24
- } catch (error: unknown) {
25
- logger.error((error as Error).message);
26
- process.exit(1);
27
- }
28
- });
29
-
30
- addExamples(clearLinksCommand, [
31
- { description: 'Remove every link from a portal',
32
- command: 'plazbot portal clear-links prt_AbcDef123' },
33
- ]);
@@ -1,58 +0,0 @@
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 { PortalCommandOptions } from '../../types/portal.js';
7
-
8
- export const createCommand = new Command('create')
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)
13
- .action(async (options: PortalCommandOptions & { name: string; title: string }) => {
14
- try {
15
- // Obtener credenciales guardadas
16
- const credentials = await getStoredCredentials();
17
-
18
- const portal = new Portal({
19
- workspaceId: credentials.workspace,
20
- apiKey: credentials.apiKey,
21
- zone: credentials.zone,
22
- ...(options.dev && { customUrl: "http://localhost:5090" })
23
- });
24
-
25
- const portalCreated = await portal.addPortal({
26
- name: options.name,
27
- title: options.title,
28
- zone: credentials.zone as "LA" | "EU",
29
- subtitle: "",
30
- logo: "",
31
- logodark: "",
32
- access: "direct",
33
- disabled: false,
34
- brandOff: false
35
- });
36
-
37
- logger.success('Portal created successfully');
38
- logger.title('Portal details');
39
- logger.label('ID', portalCreated.id);
40
- logger.label('URL', portalCreated.url);
41
-
42
- if (options.dev) {
43
- logger.warning('\nEnvironment: development');
44
- }
45
-
46
- } catch (error) {
47
- const message = error instanceof Error ? error.message : 'Unknown error while creating the portal';
48
- logger.error(message);
49
- process.exit(1);
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,70 +0,0 @@
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 { PortalCommandOptions, PortalResponse } from '../../types/portal.js';
7
- import inquirer from 'inquirer';
8
-
9
- export const deleteCommand = new Command('delete')
10
- .description('Delete a portal')
11
- .argument('<portalId>', 'Portal ID')
12
- .option('--force', 'Delete without confirmation', false)
13
- .option('--dev', 'Use development environment', false)
14
- .action(async (portalId: string, options: PortalCommandOptions) => {
15
- try {
16
- // Obtener credenciales guardadas
17
- const credentials = await getStoredCredentials();
18
-
19
- const portal = new Portal({
20
- workspaceId: credentials.workspace,
21
- apiKey: credentials.apiKey,
22
- zone: credentials.zone,
23
- ...(options.dev && { customUrl: "http://localhost:5090" })
24
- });
25
-
26
- // Obtener detalles del portal para mostrar qué se va a eliminar
27
- const portalDetails = await portal.getPortal(portalId) as PortalResponse;
28
-
29
- logger.title('Portal to delete');
30
- logger.label('ID', portalDetails.portal.id);
31
- logger.label('Name', portalDetails.portal.name);
32
- logger.label('URL', portalDetails.portal.url);
33
-
34
- if (!options.force) {
35
- const { confirm } = await inquirer.prompt([{
36
- type: 'confirm',
37
- name: 'confirm',
38
- message: 'Are you sure you want to delete this portal?',
39
- default: false
40
- }]);
41
-
42
- if (!confirm) {
43
- logger.info('Operation cancelled.');
44
- return;
45
- }
46
- }
47
-
48
- logger.dim('Deleting portal...');
49
-
50
- await portal.deletePortal(portalId);
51
-
52
- logger.success('Portal deleted successfully');
53
-
54
- if (options.dev) {
55
- logger.warning('\nEnvironment: development');
56
- }
57
-
58
- } catch (error) {
59
- const message = error instanceof Error ? error.message : 'Unknown error while deleting the portal';
60
- logger.error(message);
61
- process.exit(1);
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,77 +0,0 @@
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 { PortalCommandOptions, PortalResponse, PortalLink, PortalAgent } from '../../types/portal.js';
7
-
8
- export const getCommand = new Command('get')
9
- .description('Show detailed information for a portal')
10
- .argument('<portalId>', 'Portal ID')
11
- .option('--dev', 'Use development environment', false)
12
- .action(async (portalId: string, options: PortalCommandOptions) => {
13
- try {
14
- // Obtener credenciales guardadas
15
- const credentials = await getStoredCredentials();
16
-
17
- const portal = new Portal({
18
- workspaceId: credentials.workspace,
19
- apiKey: credentials.apiKey,
20
- zone: credentials.zone,
21
- ...(options.dev && { customUrl: "http://localhost:5090" })
22
- });
23
-
24
- const response = await portal.getPortal(portalId) as PortalResponse;
25
- const portalDetails = response.portal;
26
-
27
- logger.title('Portal details');
28
- logger.label('ID', portalDetails.id);
29
- logger.label('Name', portalDetails.name);
30
- logger.label('URL', portalDetails.url);
31
- logger.label('Access', portalDetails.access);
32
- logger.label('Status', portalDetails.disabled ? 'Disabled' : 'Enabled');
33
-
34
- if (portalDetails.title) {
35
- logger.label('Title', portalDetails.title);
36
- }
37
- if (portalDetails.subtitle) {
38
- logger.label('Subtitle', portalDetails.subtitle);
39
- }
40
-
41
- if (portalDetails.logo) {
42
- logger.title('Assets');
43
- logger.label('Logo', portalDetails.logo);
44
- if (portalDetails.logodark) {
45
- logger.label('Logo (dark mode)', portalDetails.logodark);
46
- }
47
- }
48
-
49
- if (portalDetails.links && portalDetails.links.length > 0) {
50
- logger.title('Links');
51
- portalDetails.links.forEach((link: PortalLink) => {
52
- logger.label(link.value, link.url);
53
- });
54
- }
55
-
56
- if (portalDetails.agents && portalDetails.agents.length > 0) {
57
- logger.title('Associated agents');
58
- portalDetails.agents.forEach((agent: PortalAgent) => {
59
- logger.label(agent.name, agent.id);
60
- });
61
- }
62
-
63
- if (options.dev) {
64
- logger.warning('\nEnvironment: development');
65
- }
66
-
67
- } catch (error) {
68
- const message = error instanceof Error ? error.message : 'Unknown error while fetching portal details';
69
- logger.error(message);
70
- process.exit(1);
71
- }
72
- });
73
-
74
- addExamples(getCommand, [
75
- { description: 'Show details for a specific portal',
76
- command: 'plazbot portal get prt_AbcDef123' },
77
- ]);
@@ -1,32 +0,0 @@
1
- import { Command } from 'commander';
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';
11
-
12
- export const portalCommands = new Command('portal')
13
- .description('Commands related to portals')
14
- .addCommand(listCommand)
15
- .addCommand(getCommand)
16
- .addCommand(deleteCommand)
17
- .addCommand(createCommand)
18
- .addCommand(updateCommand)
19
- .addCommand(addAgentCommand)
20
- .addCommand(addLinkCommand)
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
- ]);
@@ -1,79 +0,0 @@
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 { PortalCommandOptions } from '../../types/portal.js';
7
-
8
- export const listCommand = new Command('list')
9
- .description('Show the portal associated with the workspace')
10
- .option('--dev', 'Use development environment', false)
11
- .action(async (options: PortalCommandOptions) => {
12
- try {
13
- // Obtener credenciales guardadas
14
- const credentials = await getStoredCredentials();
15
-
16
- const portal = new Portal({
17
- workspaceId: credentials.workspace,
18
- apiKey: credentials.apiKey,
19
- zone: credentials.zone,
20
- ...(options.dev && { customUrl: "http://localhost:5090" })
21
- });
22
-
23
- const response = await portal.getExistsPortal();
24
- const portalDetails = response.portal;
25
-
26
- logger.title('Portal found');
27
- logger.label('ID', portalDetails.id);
28
- logger.label('Name', portalDetails.name);
29
- logger.label('URL', portalDetails.url);
30
- logger.label('Access', portalDetails.access || 'N/A');
31
- logger.label('Status', portalDetails.disabled ? 'Disabled' : 'Enabled');
32
-
33
- if (portalDetails.title) {
34
- logger.label('Title', portalDetails.title);
35
- }
36
- if (portalDetails.subtitle) {
37
- logger.label('Subtitle', portalDetails.subtitle);
38
- }
39
-
40
- if (portalDetails.logo) {
41
- logger.title('Assets');
42
- logger.label('Logo', portalDetails.logo);
43
- if (portalDetails.logodark) {
44
- logger.label('Logo (dark mode)', portalDetails.logodark);
45
- }
46
- }
47
-
48
- const portalAny = portalDetails as any;
49
- if (portalAny.links && portalAny.links.length > 0) {
50
- logger.title('Links');
51
- portalAny.links.forEach((link: { value: string; url: string }) => {
52
- logger.label(link.value, link.url);
53
- });
54
- }
55
-
56
- if (portalAny.agents && portalAny.agents.length > 0) {
57
- logger.title('Associated agents');
58
- portalAny.agents.forEach((agent: { name: string; id: string }) => {
59
- logger.label(agent.name, agent.id);
60
- });
61
- }
62
-
63
- if (options.dev) {
64
- logger.warning('\nEnvironment: development');
65
- }
66
-
67
- } catch (error) {
68
- const message = error instanceof Error ? error.message : 'Unknown error while listing the portal';
69
- logger.error(message);
70
- process.exit(1);
71
- }
72
- });
73
-
74
- addExamples(listCommand, [
75
- { description: 'Show the portal of the active workspace',
76
- command: 'plazbot portal list' },
77
- { description: 'Use the development backend',
78
- command: 'plazbot portal list --dev' },
79
- ]);