plazbot-cli 0.2.26 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +53 -52
  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 +39 -31
  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,30 +1,26 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCommand = void 0;
7
- const commander_1 = require("commander");
8
- const plazbot_1 = require("plazbot");
9
- const credentials_1 = require("../../utils/credentials");
10
- const logger_1 = require("../../utils/logger");
11
- const chalk_1 = __importDefault(require("chalk"));
12
- exports.getCommand = new commander_1.Command('get')
13
- .description('Obtiene información detallada de un agente específico')
14
- .argument('<agentId>', 'ID del agente a consultar')
15
- .option('-w, --workspace <id>', 'Workspace ID (sobreescribe config local)')
16
- .option('-z, --zone <zone>', 'Zona LA o EU (sobreescribe config local)')
17
- .option('--raw', 'Mostrar el JSON completo sin formatear', false)
18
- .option('--dev', 'Usar ambiente de desarrollo', false)
1
+ import { Command } from 'commander';
2
+ import { 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 { describeAgentLoadError } from '../../utils/agent-errors.js';
7
+ import chalk from 'chalk';
8
+ export const getCommand = new Command('get')
9
+ .description('Get detailed information about a specific agent')
10
+ .argument('<agentId>', 'Agent ID to fetch')
11
+ .option('-w, --workspace <id>', 'Workspace ID (overrides local config)')
12
+ .option('-z, --zone <zone>', 'Zone LA or EU (overrides local config)')
13
+ .option('--raw', 'Show full unformatted JSON', false)
14
+ .option('--dev', 'Use development environment', false)
19
15
  .action(async (agentId, options) => {
20
16
  try {
21
- const credentials = await (0, credentials_1.getStoredCredentials)();
17
+ const credentials = await getStoredCredentials();
22
18
  const effectiveWorkspace = options.workspace || credentials.workspace;
23
19
  const effectiveZone = (options.zone?.toUpperCase() === 'EU' ? 'EU' : options.zone?.toUpperCase() === 'LA' ? 'LA' : credentials.zone);
24
20
  if (options.workspace || options.zone) {
25
- console.log(chalk_1.default.hex('#FFA726')(`\n Modo soporte: workspace=${effectiveWorkspace} zona=${effectiveZone}`));
21
+ console.log(chalk.hex('#FFA726')(`\n Support mode: workspace=${effectiveWorkspace} zone=${effectiveZone}`));
26
22
  }
27
- const agent = new plazbot_1.Agent({
23
+ const agent = new Agent({
28
24
  workspaceId: effectiveWorkspace,
29
25
  apiKey: credentials.apiKey,
30
26
  zone: effectiveZone,
@@ -39,32 +35,32 @@ exports.getCommand = new commander_1.Command('get')
39
35
  return;
40
36
  }
41
37
  const label = (key, value) => {
42
- const v = value !== undefined && value !== null && value !== '' ? String(value) : chalk_1.default.gray('—');
43
- console.log(` ${chalk_1.default.gray(key + ':')} ${chalk_1.default.white(v)}`);
38
+ const v = value !== undefined && value !== null && value !== '' ? String(value) : chalk.gray('—');
39
+ console.log(` ${chalk.gray(key + ':')} ${chalk.white(v)}`);
44
40
  };
45
41
  const sectionHeader = (title) => {
46
42
  console.log();
47
- console.log(chalk_1.default.bold.hex('#4CAF50')(` ${title}`));
48
- console.log(chalk_1.default.gray(' ' + '─'.repeat(40)));
43
+ console.log(chalk.bold.hex('#4CAF50')(` ${title}`));
44
+ console.log(chalk.gray(' ' + '─'.repeat(40)));
49
45
  };
50
46
  console.log();
51
- console.log(chalk_1.default.hex('#4CAF50')(' ┌' + '─'.repeat(58) + '┐'));
52
- console.log(chalk_1.default.hex('#4CAF50')(' │') + chalk_1.default.bold(` ${agentData.name || 'Agente'}`).padEnd(68) + chalk_1.default.hex('#4CAF50')('│'));
53
- console.log(chalk_1.default.hex('#4CAF50')(' │') + chalk_1.default.gray(` ${agentId}`).padEnd(68) + chalk_1.default.hex('#4CAF50')('│'));
54
- console.log(chalk_1.default.hex('#4CAF50')(' └' + '─'.repeat(58) + '┘'));
47
+ console.log(chalk.hex('#4CAF50')(' ┌' + '─'.repeat(58) + '┐'));
48
+ console.log(chalk.hex('#4CAF50')(' │') + chalk.bold(` ${agentData.name || 'Agent'}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
49
+ console.log(chalk.hex('#4CAF50')(' │') + chalk.gray(` ${agentId}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
50
+ console.log(chalk.hex('#4CAF50')(' └' + '─'.repeat(58) + '┘'));
55
51
  // Informacion basica
56
- sectionHeader('Informacion Basica');
52
+ sectionHeader('Basic Information');
57
53
  label('ID', agentData.id);
58
- label('Nombre', agentData.name);
59
- label('Descripcion', agentData.description);
60
- label('Estado', agentData.enable ? chalk_1.default.hex('#66BB6A')('Activo') : chalk_1.default.hex('#EF5350')('Inactivo'));
61
- label('Zona', agentData.zone);
54
+ label('Name', agentData.name);
55
+ label('Description', agentData.description);
56
+ label('Status', agentData.enable ? chalk.hex('#66BB6A')('Active') : chalk.hex('#EF5350')('Inactive'));
57
+ label('Zone', agentData.zone);
62
58
  label('Buffer', agentData.buffer);
63
59
  label('Color', agentData.color);
64
- label('Pregunta inicial', agentData.question);
65
- label('Zona horaria', agentData.timezone);
66
- label('Mostrar en chat', agentData.showInChat ? 'Si' : 'No');
67
- label('Tool Calling', agentData.useToolCalling ? 'Activado' : 'Desactivado');
60
+ label('Initial question', agentData.question);
61
+ label('Timezone', agentData.timezone);
62
+ label('Show in chat', agentData.showInChat ? 'Yes' : 'No');
63
+ label('Tool Calling', agentData.useToolCalling ? 'Enabled' : 'Disabled');
68
64
  // Tags
69
65
  if (agentData.tags && agentData.tags.length > 0) {
70
66
  label('Tags', agentData.tags.join(', '));
@@ -75,121 +71,139 @@ exports.getCommand = new commander_1.Command('get')
75
71
  const promptPreview = agentData.prompt.length > 200
76
72
  ? agentData.prompt.substring(0, 200) + '...'
77
73
  : agentData.prompt;
78
- console.log(chalk_1.default.white(' ' + promptPreview.split('\n').join('\n ')));
74
+ console.log(chalk.white(' ' + promptPreview.split('\n').join('\n ')));
79
75
  }
80
76
  // Ejemplos
81
77
  if (agentData.examples && agentData.examples.length > 0) {
82
- sectionHeader('Ejemplos');
78
+ sectionHeader('Examples');
83
79
  agentData.examples.forEach((example) => {
84
- console.log(chalk_1.default.white(` - ${example.value || example}`));
80
+ console.log(chalk.white(` - ${example.value || example}`));
85
81
  });
86
82
  }
87
83
  // Instrucciones
88
84
  if (agentData.instructions) {
89
- sectionHeader('Instrucciones');
85
+ sectionHeader('Instructions');
90
86
  const inst = agentData.instructions;
91
- label('Tono', inst.tone);
92
- label('Estilo', inst.style);
93
- label('Personalidad', inst.personality);
94
- label('Objetivo', inst.objective);
95
- label('Idioma', inst.language);
96
- label('Emojis', inst.emojis ? 'Si' : 'No');
97
- label('Formato preferido', inst.preferredFormat);
98
- label('Max palabras', inst.maxWords);
87
+ label('Tone', inst.tone);
88
+ label('Style', inst.style);
89
+ label('Personality', inst.personality);
90
+ label('Objective', inst.objective);
91
+ label('Language', inst.language);
92
+ label('Emojis', inst.emojis ? 'Yes' : 'No');
93
+ label('Preferred format', inst.preferredFormat);
94
+ label('Max words', inst.maxWords);
99
95
  if (inst.avoidTopics && inst.avoidTopics.length > 0) {
100
- label('Temas a evitar', inst.avoidTopics.join(', '));
96
+ label('Topics to avoid', inst.avoidTopics.join(', '));
101
97
  }
102
- label('Solo responder si sabe', inst.respondOnlyIfKnows ? 'Si' : 'No');
103
- label('Saludo', inst.greeting);
98
+ label('Only respond if known', inst.respondOnlyIfKnows ? 'Yes' : 'No');
99
+ label('Greeting', inst.greeting);
104
100
  }
105
101
  // Persona
106
102
  if (agentData.person) {
107
103
  sectionHeader('Persona');
108
104
  const p = agentData.person;
109
- label('Nombre', p.name);
110
- label('Rol', p.role);
111
- label('Primera persona', p.speaksInFirstPerson ? 'Si' : 'No');
112
- label('Es humano', p.isHuman ? 'Si' : 'No');
105
+ label('Name', p.name);
106
+ label('Role', p.role);
107
+ label('First person', p.speaksInFirstPerson ? 'Yes' : 'No');
108
+ label('Is human', p.isHuman ? 'Yes' : 'No');
113
109
  }
114
110
  // Fallbacks
115
111
  if (agentData.fallbacks) {
116
112
  sectionHeader('Fallbacks');
117
113
  const fb = agentData.fallbacks;
118
- label('Sin respuesta', fb.noAnswer);
119
- label('Error de servicio', fb.serviceError);
120
- label('No entiende', fb.doNotUnderstand);
114
+ label('No answer', fb.noAnswer);
115
+ label('Service error', fb.serviceError);
116
+ label('Does not understand', fb.doNotUnderstand);
121
117
  }
122
118
  // Reglas
123
119
  if (agentData.rules) {
124
- sectionHeader('Reglas');
120
+ sectionHeader('Rules');
125
121
  const r = agentData.rules;
126
- label('No mencionar precios', r.doNotMentionPrices ? 'Si' : 'No');
127
- label('No diagnosticar', r.doNotDiagnose ? 'Si' : 'No');
122
+ label('Do not mention prices', r.doNotMentionPrices ? 'Yes' : 'No');
123
+ label('Do not diagnose', r.doNotDiagnose ? 'Yes' : 'No');
128
124
  if (r.doNotRespondOutsideHours) {
129
- label('Fuera de horario', r.doNotRespondOutsideHours);
125
+ label('Out of hours', r.doNotRespondOutsideHours);
130
126
  }
131
127
  }
132
128
  // Servicios
133
129
  if (agentData.services && agentData.services.length > 0) {
134
- sectionHeader(`Servicios (${agentData.services.length})`);
130
+ sectionHeader(`Services (${agentData.services.length})`);
135
131
  agentData.services.forEach((svc, i) => {
136
- console.log(chalk_1.default.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || 'Servicio'}`));
137
- label(' Referencia', svc.reference);
138
- label(' Habilitado', svc.enabled ? 'Si' : 'No');
139
- label(' Metodo', svc.method);
132
+ console.log(chalk.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || 'Service'}`));
133
+ label(' Reference', svc.reference);
134
+ label(' Enabled', svc.enabled ? 'Yes' : 'No');
135
+ label(' Method', svc.method);
140
136
  label(' Endpoint', svc.endpoint);
141
137
  if (svc.requiredFields && svc.requiredFields.length > 0) {
142
- console.log(chalk_1.default.gray(' Campos:'));
138
+ console.log(chalk.gray(' Fields:'));
143
139
  svc.requiredFields.forEach((f) => {
144
- console.log(chalk_1.default.white(` - ${f.name} (${f.type}): ${f.description || ''}`));
140
+ console.log(chalk.white(` - ${f.name} (${f.type}): ${f.description || ''}`));
145
141
  });
146
142
  }
147
143
  });
148
144
  }
149
145
  // Acciones
150
146
  if (agentData.actions && agentData.actions.length > 0) {
151
- sectionHeader(`Acciones (${agentData.actions.length})`);
147
+ sectionHeader(`Actions (${agentData.actions.length})`);
152
148
  agentData.actions.forEach((act, i) => {
153
- console.log(chalk_1.default.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || 'Accion'}`));
154
- label(' Referencia', act.reference);
155
- label(' Habilitado', act.enabled ? 'Si' : 'No');
149
+ console.log(chalk.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || 'Action'}`));
150
+ label(' Reference', act.reference);
151
+ label(' Enabled', act.enabled ? 'Yes' : 'No');
156
152
  if (act.tags && act.tags.length > 0) {
157
153
  label(' Tags', act.tags.join(', '));
158
154
  }
159
- label(' Respuesta', act.responseMessage);
155
+ label(' Response', act.responseMessage);
160
156
  if (act.action && act.action.length > 0) {
161
- console.log(chalk_1.default.gray(' Sub-acciones:'));
157
+ console.log(chalk.gray(' Sub-actions:'));
162
158
  act.action.forEach((sa) => {
163
- console.log(chalk_1.default.white(` - ${sa.type}: ${sa.value || ''}`));
159
+ console.log(chalk.white(` - ${sa.type}: ${sa.value || ''}`));
164
160
  });
165
161
  }
166
162
  });
167
163
  }
168
164
  // Canales
169
165
  if (agentData.channels && agentData.channels.length > 0) {
170
- sectionHeader(`Canales (${agentData.channels.length})`);
166
+ sectionHeader(`Channels (${agentData.channels.length})`);
171
167
  agentData.channels.forEach((ch) => {
172
- console.log(chalk_1.default.white(` ${chalk_1.default.hex('#22d3ee')(ch.channel || 'canal')}: ${ch.key || ''}`));
168
+ console.log(chalk.white(` ${chalk.hex('#22d3ee')(ch.channel || 'channel')}: ${ch.key || ''}`));
173
169
  });
174
170
  }
175
171
  // AI Config
176
172
  if (agentData.customAIConfig && agentData.aiProviders && agentData.aiProviders.length > 0) {
177
- sectionHeader('Modelo IA');
173
+ sectionHeader('AI Model');
178
174
  agentData.aiProviders.forEach((ai) => {
179
- label('Proveedor', ai.provider);
180
- label('Modelo', ai.model);
175
+ label('Provider', ai.provider);
176
+ label('Model', ai.model);
181
177
  });
182
178
  }
183
179
  console.log();
184
- console.log(chalk_1.default.gray(' Usa --raw para ver el JSON completo'));
180
+ console.log(chalk.gray(' Use --raw to see the full JSON'));
185
181
  console.log();
186
182
  if (options.dev) {
187
- logger_1.logger.warning('Ambiente: desarrollo');
183
+ logger.warning('Environment: development');
188
184
  }
189
185
  }
190
186
  catch (error) {
191
- const message = error instanceof Error ? error.message : 'Error desconocido al obtener el agente';
192
- logger_1.logger.error(message);
187
+ const credentials = await getStoredCredentials().catch(() => null);
188
+ if (credentials) {
189
+ logger.error(describeAgentLoadError(error, agentId, credentials, {
190
+ dev: options.dev,
191
+ workspaceOverride: options.workspace,
192
+ zoneOverride: options.zone,
193
+ }));
194
+ }
195
+ else {
196
+ const message = error instanceof Error ? error.message : 'Unknown error while fetching the agent';
197
+ logger.error(message);
198
+ }
193
199
  process.exit(1);
194
200
  }
195
201
  });
202
+ addExamples(getCommand, [
203
+ { description: 'Show the agent in a human-friendly layout',
204
+ command: 'plazbot agent get agt_AbcDef123' },
205
+ { description: 'Dump the full raw JSON (useful for piping to jq)',
206
+ command: 'plazbot agent get agt_AbcDef123 --raw' },
207
+ { description: 'Inspect an agent from another workspace (support mode)',
208
+ command: 'plazbot agent get agt_AbcDef123 -w wok_Other123 -z LA' },
209
+ ]);
@@ -1,39 +1,53 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.agentCommands = void 0;
4
- const commander_1 = require("commander");
5
- const list_1 = require("./list");
6
- const get_1 = require("./get");
7
- const delete_1 = require("./delete");
8
- const create_1 = require("./create");
9
- const update_1 = require("./update");
10
- const enable_widget_1 = require("./enable-widget");
11
- const chat_1 = require("./chat");
12
- const on_message_1 = require("./on-message");
13
- const tools_1 = require("./tools");
14
- const ai_config_1 = require("./ai-config");
15
- const templates_1 = require("./templates");
16
- const copy_1 = require("./copy");
17
- const files_1 = require("./files");
18
- const set_1 = require("./set");
19
- const monitor_1 = require("./monitor");
20
- const export_1 = require("./export");
21
- exports.agentCommands = new commander_1.Command('agent')
22
- .description('Comandos relacionados con agentes de IA')
23
- .addCommand(list_1.listCommand)
24
- .addCommand(get_1.getCommand)
25
- .addCommand(delete_1.deleteCommand)
26
- .addCommand(create_1.createCommand)
27
- .addCommand(update_1.updateCommand)
28
- .addCommand(enable_widget_1.enableCommand)
29
- .addCommand(chat_1.chatCommand)
30
- .addCommand(on_message_1.messageCommand)
31
- .addCommand(tools_1.toolsCommand)
32
- .addCommand(ai_config_1.aiConfigCommand)
33
- .addCommand(templates_1.templatesCommand)
34
- .addCommand(copy_1.copyCommand)
35
- .addCommand(files_1.filesCommand)
36
- .addCommand(set_1.setCommand)
37
- .addCommand(monitor_1.monitorCommand)
38
- .addCommand(export_1.exportCommand)
39
- .addCommand(export_1.crossCopyCommand);
1
+ import { Command } from 'commander';
2
+ import { addExamples } from '../../utils/help.js';
3
+ import { listCommand } from './list.js';
4
+ import { getCommand } from './get.js';
5
+ import { deleteCommand } from './delete.js';
6
+ import { createCommand } from './create.js';
7
+ import { updateCommand } from './update.js';
8
+ import { enableCommand } from './enable-widget.js';
9
+ import { chatCommand } from './chat.js';
10
+ import { messageCommand } from './on-message.js';
11
+ import { toolsCommand } from './tools.js';
12
+ import { aiConfigCommand } from './ai-config.js';
13
+ import { templatesCommand } from './templates.js';
14
+ import { copyCommand } from './copy.js';
15
+ import { filesCommand } from './files.js';
16
+ import { setCommand } from './set.js';
17
+ import { monitorCommand } from './monitor.js';
18
+ import { exportCommand, crossCopyCommand } from './export.js';
19
+ import { validateCommand } from './validate.js';
20
+ export const agentCommands = new Command('agent')
21
+ .description('Commands related to AI agents')
22
+ .addCommand(listCommand)
23
+ .addCommand(getCommand)
24
+ .addCommand(deleteCommand)
25
+ .addCommand(createCommand)
26
+ .addCommand(updateCommand)
27
+ .addCommand(enableCommand)
28
+ .addCommand(chatCommand)
29
+ .addCommand(messageCommand)
30
+ .addCommand(toolsCommand)
31
+ .addCommand(aiConfigCommand)
32
+ .addCommand(templatesCommand)
33
+ .addCommand(copyCommand)
34
+ .addCommand(filesCommand)
35
+ .addCommand(setCommand)
36
+ .addCommand(monitorCommand)
37
+ .addCommand(exportCommand)
38
+ .addCommand(crossCopyCommand)
39
+ .addCommand(validateCommand);
40
+ addExamples(agentCommands, [
41
+ { description: 'List agents in the active workspace',
42
+ command: 'plazbot agent list' },
43
+ { description: 'Chat interactively with an agent',
44
+ command: 'plazbot agent chat agt_AbcDef123' },
45
+ { description: 'Create an agent from a JSON template',
46
+ command: 'plazbot agent create ./agent.json' },
47
+ { description: 'Export an agent and copy it to another workspace',
48
+ command: 'plazbot agent cross-copy agt_AbcDef123 --from-workspace wok_Source --to-workspace wok_Target' },
49
+ { description: 'Monitor activity of an agent in real time',
50
+ command: 'plazbot agent monitor agt_AbcDef123' },
51
+ { description: 'Validate a local agent JSON file against the schema',
52
+ command: 'plazbot agent validate ./agent.json' },
53
+ ]);
@@ -1,19 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.listCommand = void 0;
4
- const commander_1 = require("commander");
5
- const plazbot_1 = require("plazbot");
6
- const credentials_1 = require("../../utils/credentials");
7
- const logger_1 = require("../../utils/logger");
8
- exports.listCommand = new commander_1.Command('list')
9
- .description('Lista todos los agentes del workspace')
10
- .option('--dev', 'Usar ambiente de desarrollo', false)
1
+ import { Command } from 'commander';
2
+ import { Agent } from 'plazbot';
3
+ import { getStoredCredentials } from '../../utils/credentials.js';
4
+ import { logger } from '../../utils/logger.js';
5
+ import { addExamples } from '../../utils/help.js';
6
+ export const listCommand = new Command('list')
7
+ .description('List all agents in the workspace')
8
+ .option('--dev', 'Use development environment (localhost:5090)', false)
11
9
  .action(async (options) => {
12
10
  try {
13
11
  // Obtener credenciales guardadas
14
- const credentials = await (0, credentials_1.getStoredCredentials)();
12
+ const credentials = await getStoredCredentials();
15
13
  // Crear instancia del agente con las credenciales guardadas
16
- const agent = new plazbot_1.Agent({
14
+ const agent = new Agent({
17
15
  workspaceId: credentials.workspace,
18
16
  apiKey: credentials.apiKey,
19
17
  zone: credentials.zone,
@@ -22,26 +20,30 @@ exports.listCommand = new commander_1.Command('list')
22
20
  // Obtener lista de agentes
23
21
  const agents = await agent.getAgents();
24
22
  if (agents.length === 0) {
25
- logger_1.logger.info('No se encontraron agentes en este workspace');
23
+ logger.info('No agents found in this workspace');
26
24
  return;
27
25
  }
28
- logger_1.logger.info('\nLista de Agentes:');
29
- logger_1.logger.doubleDivider();
26
+ logger.info('\nAgents:');
27
+ logger.doubleDivider();
30
28
  agents.forEach((a, index) => {
31
- logger_1.logger.info(`${index + 1}. ID: ${a.id}`);
32
- logger_1.logger.info(` Nombre: ${a.name}`);
33
- logger_1.logger.info(` Estado: ${a.enable ? 'Activo' : 'Inactivo'}`);
34
- logger_1.logger.info(` Descripción: ${a.description}`);
35
- logger_1.logger.info(` Creado: ${a.createdAt ? new Date(a.createdAt).toLocaleString() : 'N/A'}`);
36
- logger_1.logger.divider();
29
+ logger.info(`${index + 1}. ID: ${a.id}`);
30
+ logger.info(` Name: ${a.name}`);
31
+ logger.info(` Status: ${a.enable ? 'Active' : 'Inactive'}`);
32
+ logger.info(` Description: ${a.description}`);
33
+ logger.info(` Created: ${a.createdAt ? new Date(a.createdAt).toLocaleString() : 'N/A'}`);
34
+ logger.divider();
37
35
  });
38
36
  if (options.dev) {
39
- logger_1.logger.warning('Ambiente: desarrollo');
37
+ logger.warning('Environment: development');
40
38
  }
41
39
  }
42
40
  catch (error) {
43
- const message = error instanceof Error ? error.message : 'Error desconocido al listar agentes';
44
- logger_1.logger.error(message);
41
+ const message = error instanceof Error ? error.message : 'Unknown error while listing agents';
42
+ logger.error(message);
45
43
  process.exit(1);
46
44
  }
47
45
  });
46
+ addExamples(listCommand, [
47
+ { description: 'List every agent in the active workspace', command: 'plazbot agent list' },
48
+ { description: 'List against a local backend (dev mode)', command: 'plazbot agent list --dev' },
49
+ ]);