plazbot-cli 0.2.25 → 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.
Files changed (178) hide show
  1. package/CLAUDE.md +34 -5
  2. package/README.md +21 -0
  3. package/dist/cli.js +32 -20
  4. package/dist/commands/agent/ai-config.js +98 -50
  5. package/dist/commands/agent/chat.js +80 -74
  6. package/dist/commands/agent/copy.js +23 -21
  7. package/dist/commands/agent/create.js +42 -72
  8. package/dist/commands/agent/delete.js +29 -30
  9. package/dist/commands/agent/enable-widget.js +30 -26
  10. package/dist/commands/agent/export.js +90 -77
  11. package/dist/commands/agent/files.js +68 -60
  12. package/dist/commands/agent/get.js +101 -87
  13. package/dist/commands/agent/index.js +53 -39
  14. package/dist/commands/agent/list.js +26 -24
  15. package/dist/commands/agent/monitor.js +91 -86
  16. package/dist/commands/agent/on-message.js +40 -37
  17. package/dist/commands/agent/set.js +62 -59
  18. package/dist/commands/agent/templates.js +109 -108
  19. package/dist/commands/agent/tools.js +64 -65
  20. package/dist/commands/agent/update.js +28 -27
  21. package/dist/commands/agent/validate.js +127 -0
  22. package/dist/commands/agent/wizard.js +152 -159
  23. package/dist/commands/auth/index.js +7 -10
  24. package/dist/commands/auth/login.js +50 -37
  25. package/dist/commands/auth/logout.js +16 -14
  26. package/dist/commands/auth/status.js +19 -16
  27. package/dist/commands/portal/add-agent.js +26 -24
  28. package/dist/commands/portal/add-link.js +21 -17
  29. package/dist/commands/portal/clear-links.js +17 -15
  30. package/dist/commands/portal/create.js +25 -21
  31. package/dist/commands/portal/delete.js +31 -30
  32. package/dist/commands/portal/get.js +33 -31
  33. package/dist/commands/portal/index.js +30 -22
  34. package/dist/commands/portal/list.js +34 -30
  35. package/dist/commands/portal/update.js +41 -33
  36. package/dist/commands/whatsapp/broadcast.js +40 -37
  37. package/dist/commands/whatsapp/channels.js +40 -34
  38. package/dist/commands/whatsapp/chat.js +33 -32
  39. package/dist/commands/whatsapp/connect.js +59 -55
  40. package/dist/commands/whatsapp/delete-webhook.js +19 -17
  41. package/dist/commands/whatsapp/index.js +35 -25
  42. package/dist/commands/whatsapp/register-webhook.js +21 -19
  43. package/dist/commands/whatsapp/send-template.js +39 -31
  44. package/dist/commands/whatsapp/send.js +27 -23
  45. package/dist/commands/whatsapp/widget.js +35 -31
  46. package/dist/commands/workers/deploy.js +49 -44
  47. package/dist/commands/workers/index.js +28 -18
  48. package/dist/commands/workers/list.js +43 -35
  49. package/dist/commands/workers/logs.js +38 -32
  50. package/dist/commands/workers/remove.js +38 -37
  51. package/dist/commands/workers/secret.js +63 -58
  52. package/dist/commands/workers/test.js +44 -36
  53. package/dist/schemas/agent.config.schema.json +569 -0
  54. package/dist/studio/api/sseClient.js +97 -0
  55. package/dist/studio/api/studioApi.js +25 -0
  56. package/dist/studio/api/types.js +16 -0
  57. package/dist/studio/components/AgentPanel.js +35 -0
  58. package/dist/studio/components/App.js +214 -0
  59. package/dist/studio/components/ChatLog.js +59 -0
  60. package/dist/studio/components/Footer.js +11 -0
  61. package/dist/studio/components/Header.js +8 -0
  62. package/dist/studio/components/Input.js +15 -0
  63. package/dist/studio/components/Message.js +56 -0
  64. package/dist/studio/components/Suggestions.js +11 -0
  65. package/dist/studio/components/ToolCall.js +33 -0
  66. package/dist/studio/components/WhatsappConnectCard.js +57 -0
  67. package/dist/studio/index.js +42 -0
  68. package/dist/studio/render/json.js +16 -0
  69. package/dist/studio/render/markdown.js +32 -0
  70. package/dist/studio/render/steps.js +58 -0
  71. package/dist/studio/runOneShot.js +96 -0
  72. package/dist/studio/runRepl.js +52 -0
  73. package/dist/studio/slash/handlers.js +199 -0
  74. package/dist/studio/slash/parser.js +46 -0
  75. package/dist/studio/slash/registry.js +16 -0
  76. package/dist/studio/state/store.js +181 -0
  77. package/dist/studio/whatsapp/api.js +63 -0
  78. package/dist/studio/whatsapp/polling.js +77 -0
  79. package/dist/studio/whatsapp/types.js +31 -0
  80. package/dist/types/agent.js +1 -2
  81. package/dist/types/auth.js +1 -2
  82. package/dist/types/common.js +1 -2
  83. package/dist/types/message.js +1 -2
  84. package/dist/types/portal.js +1 -2
  85. package/dist/types/workers.js +1 -2
  86. package/dist/utils/agent-errors.js +46 -0
  87. package/dist/utils/api.js +8 -9
  88. package/dist/utils/banner.js +33 -34
  89. package/dist/utils/credentials.js +12 -20
  90. package/dist/utils/help.js +44 -0
  91. package/dist/utils/logger.js +13 -19
  92. package/dist/utils/ui.js +35 -49
  93. package/package.json +21 -10
  94. package/src/cli.ts +24 -8
  95. package/src/commands/agent/ai-config.ts +89 -34
  96. package/src/commands/agent/chat.ts +49 -37
  97. package/src/commands/agent/copy.ts +19 -13
  98. package/src/commands/agent/create.ts +32 -22
  99. package/src/commands/agent/delete.ts +24 -18
  100. package/src/commands/agent/enable-widget.ts +31 -23
  101. package/src/commands/agent/export.ts +72 -51
  102. package/src/commands/agent/files.ts +51 -39
  103. package/src/commands/agent/get.ts +86 -66
  104. package/src/commands/agent/index.ts +36 -18
  105. package/src/commands/agent/list.ts +22 -16
  106. package/src/commands/agent/monitor.ts +67 -56
  107. package/src/commands/agent/on-message.ts +36 -27
  108. package/src/commands/agent/set.ts +47 -37
  109. package/src/commands/agent/templates.ts +90 -82
  110. package/src/commands/agent/tools.ts +53 -47
  111. package/src/commands/agent/update.ts +28 -20
  112. package/src/commands/agent/validate.ts +135 -0
  113. package/src/commands/agent/wizard.ts +114 -114
  114. package/src/commands/auth/index.ts +3 -3
  115. package/src/commands/auth/login.ts +44 -29
  116. package/src/commands/auth/logout.ts +16 -10
  117. package/src/commands/auth/status.ts +14 -8
  118. package/src/commands/portal/add-agent.ts +23 -17
  119. package/src/commands/portal/add-link.ts +17 -9
  120. package/src/commands/portal/clear-links.ts +13 -7
  121. package/src/commands/portal/create.ts +20 -12
  122. package/src/commands/portal/delete.ts +28 -20
  123. package/src/commands/portal/get.ts +25 -19
  124. package/src/commands/portal/index.ts +22 -10
  125. package/src/commands/portal/list.ts +27 -19
  126. package/src/commands/portal/update.ts +38 -26
  127. package/src/commands/whatsapp/broadcast.ts +28 -18
  128. package/src/commands/whatsapp/channels.ts +31 -20
  129. package/src/commands/whatsapp/chat.ts +20 -12
  130. package/src/commands/whatsapp/connect.ts +48 -36
  131. package/src/commands/whatsapp/delete-webhook.ts +15 -9
  132. package/src/commands/whatsapp/index.ts +24 -10
  133. package/src/commands/whatsapp/register-webhook.ts +16 -10
  134. package/src/commands/whatsapp/send-template.ts +33 -21
  135. package/src/commands/whatsapp/send.ts +23 -15
  136. package/src/commands/whatsapp/widget.ts +25 -17
  137. package/src/commands/workers/deploy.ts +34 -22
  138. package/src/commands/workers/index.ts +21 -7
  139. package/src/commands/workers/list.ts +31 -19
  140. package/src/commands/workers/logs.ts +30 -20
  141. package/src/commands/workers/remove.ts +30 -22
  142. package/src/commands/workers/secret.ts +46 -34
  143. package/src/commands/workers/test.ts +34 -22
  144. package/src/schemas/agent.config.schema.json +569 -0
  145. package/src/studio/api/sseClient.ts +91 -0
  146. package/src/studio/api/studioApi.ts +27 -0
  147. package/src/studio/api/types.ts +96 -0
  148. package/src/studio/components/App.tsx +266 -0
  149. package/src/studio/components/ChatLog.tsx +95 -0
  150. package/src/studio/components/Footer.tsx +38 -0
  151. package/src/studio/components/Header.tsx +39 -0
  152. package/src/studio/components/Input.tsx +32 -0
  153. package/src/studio/components/Message.tsx +87 -0
  154. package/src/studio/components/Suggestions.tsx +26 -0
  155. package/src/studio/components/ToolCall.tsx +58 -0
  156. package/src/studio/components/WhatsappConnectCard.tsx +139 -0
  157. package/src/studio/index.ts +58 -0
  158. package/src/studio/render/markdown.ts +32 -0
  159. package/src/studio/render/steps.ts +57 -0
  160. package/src/studio/runOneShot.ts +114 -0
  161. package/src/studio/runRepl.tsx +76 -0
  162. package/src/studio/slash/handlers.ts +226 -0
  163. package/src/studio/slash/parser.ts +41 -0
  164. package/src/studio/slash/registry.ts +54 -0
  165. package/src/studio/state/store.ts +273 -0
  166. package/src/studio/whatsapp/api.ts +96 -0
  167. package/src/studio/whatsapp/polling.ts +93 -0
  168. package/src/studio/whatsapp/types.ts +80 -0
  169. package/src/types/agent.ts +1 -1
  170. package/src/types/auth.ts +4 -3
  171. package/src/types/portal.ts +1 -1
  172. package/src/types/workers.ts +1 -1
  173. package/src/utils/agent-errors.ts +67 -0
  174. package/src/utils/api.ts +6 -0
  175. package/src/utils/banner.ts +14 -9
  176. package/src/utils/credentials.ts +6 -5
  177. package/src/utils/help.ts +51 -0
  178. 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 { LoginOptions } from '../../types/auth';
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('Guarda la API Key y correo del usuario localmente')
8
- .requiredOption('-e, --email <email>', 'Correo del usuario')
9
- .requiredOption('-k, --api-key <apiKey>', 'API Key del usuario')
10
- .requiredOption('-w, --workspace <workspace>', 'ID del workspace')
11
- .requiredOption('-z, --zone <zone>', 'Zona (LA o EU)')
12
- .option('--dev', 'Usar ambiente de desarrollo', false)
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('│' + ' Bienvenido a Plazbot CLI'.padEnd(69) + '│');
22
+ logger.info('│' + ' Welcome to Plazbot CLI'.padEnd(69) + '│');
21
23
  logger.info('│' + ''.padEnd(69) + '│');
22
- logger.info('│' + ' Con esta herramienta podrás:'.padEnd(69) + '│');
23
- logger.info('│' + ' Crear y actualizar agentes'.padEnd(69) + '│');
24
- logger.info('│' + ' Gestionar configuraciones'.padEnd(69) + '│');
25
- logger.info('│' + ' Interactuar con tus agentes'.padEnd(69) + '│');
26
- logger.info('│' + ' Activar todas sus capacidades'.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) + '│');
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('Configuración guardada exitosamente:');
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('Zona', options.zone);
40
-
41
- logger.title('Puedes comenzar usando los siguientes comandos');
42
- logger.dim('plazbot agent list - Ver tus agentes');
43
- logger.dim('plazbot agent templates - Crear agente desde plantilla');
44
- logger.dim('plazbot agent chat - Chatear con un agente');
45
- logger.dim('plazbot --help - Ver todos los comandos');
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('Ambiente: desarrollo');
53
+ logger.warning('Environment: development');
50
54
  }
51
55
 
52
56
  } catch (error) {
53
- const message = error instanceof Error ? error.message : 'Error desconocido';
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 { BaseCommandOptions } from '../../types/common';
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('Elimina la configuración local del usuario')
8
- .option('--dev', 'Usar ambiente de desarrollo', false)
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('Has cerrado sesión correctamente');
13
-
13
+ logger.success('You have been signed out successfully');
14
+
14
15
  if (options.dev) {
15
- logger.warning('Ambiente: desarrollo');
16
+ logger.warning('Environment: development');
16
17
  }
17
18
  } catch (error) {
18
- const message = error instanceof Error ? error.message : 'Error desconocido al cerrar sesión';
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 { theme, section } from '../../utils/ui';
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('Muestra la sesion activa (workspace, email, zona)')
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('Sesion activa'));
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('Zona', credentials.zone === 'LA' ? 'Latinoamerica (LA)' : 'Europa (EU)');
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 hay sesion activa. Ejecuta 'plazbot init' para conectarte.");
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 { AddAgentToPortalOptions } from '../../types/portal';
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('Agrega un agente existente a un portal')
9
- .requiredOption('-p, --portal-id <portalId>', 'ID del portal')
10
- .requiredOption('-a, --agent-id <agentId>', 'ID del agente a agregar')
11
- .option('--dev', 'Usar ambiente de desarrollo', false)
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('Detalles de la operacion');
39
+ logger.title('Operation details');
39
40
  logger.label('Portal ID', portalDetails.portal?.id || options.portalId);
40
- logger.label('Portal Nombre', portalDetails.portal?.name || 'N/A');
41
- logger.label('Agente ID', agentDetails.id);
42
- logger.label('Agente Nombre', agentDetails.name);
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('Agente agregado exitosamente al portal');
50
-
50
+ logger.success('Agent added to the portal successfully');
51
+
51
52
  if (options.dev) {
52
- logger.warning('Ambiente: desarrollo');
53
+ logger.warning('Environment: development');
53
54
  }
54
55
 
55
56
  } catch (error) {
56
- const message = error instanceof Error ? error.message : 'Error desconocido';
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 { BaseCommandOptions } from '../../types/common'
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('Agregar un enlace al portal')
14
- .argument('<portalId>', 'ID del portal')
15
- .requiredOption('-t, --title <title>', 'Título del enlace')
16
- .requiredOption('-u, --url <url>', 'URL del enlace')
17
- .option('--dev', 'Usar entorno de desarrollo')
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('Enlace agregado exitosamente')
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 { BaseCommandOptions } from '../../types/common';
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('Eliminar todos los enlaces del portal')
9
- .argument('<portalId>', 'ID del portal')
10
- .option('--dev', 'Usar entorno de desarrollo')
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('Enlaces eliminados exitosamente');
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 { PortalCommandOptions } from '../../types/portal';
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('Crea un nuevo portal con configuración simplificada')
9
- .requiredOption('-n, --name <name>', 'Nombre del portal')
10
- .requiredOption('-t, --title <title>', 'Título de bienvenida del portal')
11
- .option('--dev', 'Usar ambiente de desarrollo', false)
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 creado exitosamente');
37
- logger.title('Detalles del portal');
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('\nAmbiente: desarrollo');
43
+ logger.warning('\nEnvironment: development');
43
44
  }
44
45
 
45
46
  } catch (error) {
46
- const message = error instanceof Error ? error.message : 'Error desconocido al crear el portal';
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 { PortalCommandOptions, PortalResponse } from '../../types/portal';
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('Elimina un portal')
10
- .argument('<portalId>', 'ID del portal')
11
- .option('--force', 'Eliminar sin confirmación', false)
12
- .option('--dev', 'Usar ambiente de desarrollo', false)
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 a eliminar');
29
+ logger.title('Portal to delete');
29
30
  logger.label('ID', portalDetails.portal.id);
30
- logger.label('Nombre', portalDetails.portal.name);
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: '¿Estás seguro de que quieres eliminar este portal?',
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('Operación cancelada.');
43
+ logger.info('Operation cancelled.');
43
44
  return;
44
45
  }
45
46
  }
46
47
 
47
- logger.dim('Eliminando portal...');
48
-
48
+ logger.dim('Deleting portal...');
49
+
49
50
  await portal.deletePortal(portalId);
50
-
51
- logger.success('Portal eliminado exitosamente');
52
-
51
+
52
+ logger.success('Portal deleted successfully');
53
+
53
54
  if (options.dev) {
54
- logger.warning('\nAmbiente: desarrollo');
55
+ logger.warning('\nEnvironment: development');
55
56
  }
56
57
 
57
58
  } catch (error) {
58
- const message = error instanceof Error ? error.message : 'Error desconocido al eliminar el portal';
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 { PortalCommandOptions, PortalResponse, PortalLink, PortalAgent } from '../../types/portal';
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('Muestra información detallada de un portal')
9
- .argument('<portalId>', 'ID del portal')
10
- .option('--dev', 'Usar ambiente de desarrollo', false)
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('Detalles del portal');
27
+ logger.title('Portal details');
27
28
  logger.label('ID', portalDetails.id);
28
- logger.label('Nombre', portalDetails.name);
29
+ logger.label('Name', portalDetails.name);
29
30
  logger.label('URL', portalDetails.url);
30
- logger.label('Acceso', portalDetails.access);
31
- logger.label('Estado', portalDetails.disabled ? 'Deshabilitado' : 'Habilitado');
31
+ logger.label('Access', portalDetails.access);
32
+ logger.label('Status', portalDetails.disabled ? 'Disabled' : 'Enabled');
32
33
 
33
34
  if (portalDetails.title) {
34
- logger.label('Titulo', portalDetails.title);
35
+ logger.label('Title', portalDetails.title);
35
36
  }
36
37
  if (portalDetails.subtitle) {
37
- logger.label('Subtitulo', portalDetails.subtitle);
38
+ logger.label('Subtitle', portalDetails.subtitle);
38
39
  }
39
40
 
40
41
  if (portalDetails.logo) {
41
- logger.title('Recursos');
42
+ logger.title('Assets');
42
43
  logger.label('Logo', portalDetails.logo);
43
44
  if (portalDetails.logodark) {
44
- logger.label('Logo (modo oscuro)', portalDetails.logodark);
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('Enlaces');
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('Agentes asociados');
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('\nAmbiente: desarrollo');
64
+ logger.warning('\nEnvironment: development');
64
65
  }
65
66
 
66
67
  } catch (error) {
67
- const message = error instanceof Error ? error.message : 'Error desconocido al obtener detalles del portal';
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 { getCommand } from './get';
3
- import { deleteCommand } from './delete';
4
- import { createCommand } from './create';
5
- import { updateCommand } from './update';
6
- import { addAgentCommand } from './add-agent';
7
- import { listCommand } from './list';
8
- import { addLinkCommand } from './add-link';
9
- import { clearLinksCommand } from './clear-links';
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('Comandos relacionados con portales')
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
+ ]);