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,233 +0,0 @@
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 { AgentCommandOptions } from '../../types/agent.js';
8
- import chalk from 'chalk';
9
-
10
- export const getCommand = new Command('get')
11
- .description('Get detailed information about a specific agent')
12
- .argument('<agentId>', 'Agent ID to fetch')
13
- .option('-w, --workspace <id>', 'Workspace ID (overrides local config)')
14
- .option('-z, --zone <zone>', 'Zone LA or EU (overrides local config)')
15
- .option('--raw', 'Show full unformatted JSON', false)
16
- .option('--dev', 'Use development environment', false)
17
- .action(async (agentId: string, options: AgentCommandOptions & { raw: boolean; workspace?: string; zone?: string }) => {
18
- try {
19
- const credentials = await getStoredCredentials();
20
-
21
- const effectiveWorkspace = options.workspace || credentials.workspace;
22
- const effectiveZone = (options.zone?.toUpperCase() === 'EU' ? 'EU' : options.zone?.toUpperCase() === 'LA' ? 'LA' : credentials.zone) as 'LA' | 'EU';
23
-
24
- if (options.workspace || options.zone) {
25
- console.log(chalk.hex('#FFA726')(`\n Support mode: workspace=${effectiveWorkspace} zone=${effectiveZone}`));
26
- }
27
-
28
- const agent = new Agent({
29
- workspaceId: effectiveWorkspace,
30
- apiKey: credentials.apiKey,
31
- zone: effectiveZone,
32
- ...(options.dev && { customUrl: "http://localhost:5090" })
33
- });
34
-
35
- // El SDK retorna { success, agent: {...} }
36
- const response: any = await agent.getAgentById({ id: agentId });
37
- const agentData = response.agent || response.data || response;
38
-
39
- // Modo JSON crudo
40
- if (options.raw) {
41
- console.log(JSON.stringify(agentData, null, 2));
42
- return;
43
- }
44
-
45
- const label = (key: string, value: any) => {
46
- const v = value !== undefined && value !== null && value !== '' ? String(value) : chalk.gray('—');
47
- console.log(` ${chalk.gray(key + ':')} ${chalk.white(v)}`);
48
- };
49
-
50
- const sectionHeader = (title: string) => {
51
- console.log();
52
- console.log(chalk.bold.hex('#4CAF50')(` ${title}`));
53
- console.log(chalk.gray(' ' + '─'.repeat(40)));
54
- };
55
-
56
- console.log();
57
- console.log(chalk.hex('#4CAF50')(' ┌' + '─'.repeat(58) + '┐'));
58
- console.log(chalk.hex('#4CAF50')(' │') + chalk.bold(` ${agentData.name || 'Agent'}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
59
- console.log(chalk.hex('#4CAF50')(' │') + chalk.gray(` ${agentId}`).padEnd(68) + chalk.hex('#4CAF50')('│'));
60
- console.log(chalk.hex('#4CAF50')(' └' + '─'.repeat(58) + '┘'));
61
-
62
- // Informacion basica
63
- sectionHeader('Basic Information');
64
- label('ID', agentData.id);
65
- label('Name', agentData.name);
66
- label('Description', agentData.description);
67
- label('Status', agentData.enable ? chalk.hex('#66BB6A')('Active') : chalk.hex('#EF5350')('Inactive'));
68
- label('Zone', agentData.zone);
69
- label('Buffer', agentData.buffer);
70
- label('Color', agentData.color);
71
- label('Initial question', agentData.question);
72
- label('Timezone', agentData.timezone);
73
- label('Show in chat', agentData.showInChat ? 'Yes' : 'No');
74
- label('Tool Calling', agentData.useToolCalling ? 'Enabled' : 'Disabled');
75
-
76
- // Tags
77
- if (agentData.tags && agentData.tags.length > 0) {
78
- label('Tags', agentData.tags.join(', '));
79
- }
80
-
81
- // Prompt
82
- if (agentData.prompt) {
83
- sectionHeader('Prompt');
84
- const promptPreview = agentData.prompt.length > 200
85
- ? agentData.prompt.substring(0, 200) + '...'
86
- : agentData.prompt;
87
- console.log(chalk.white(' ' + promptPreview.split('\n').join('\n ')));
88
- }
89
-
90
- // Ejemplos
91
- if (agentData.examples && agentData.examples.length > 0) {
92
- sectionHeader('Examples');
93
- agentData.examples.forEach((example: any) => {
94
- console.log(chalk.white(` - ${example.value || example}`));
95
- });
96
- }
97
-
98
- // Instrucciones
99
- if (agentData.instructions) {
100
- sectionHeader('Instructions');
101
- const inst = agentData.instructions;
102
- label('Tone', inst.tone);
103
- label('Style', inst.style);
104
- label('Personality', inst.personality);
105
- label('Objective', inst.objective);
106
- label('Language', inst.language);
107
- label('Emojis', inst.emojis ? 'Yes' : 'No');
108
- label('Preferred format', inst.preferredFormat);
109
- label('Max words', inst.maxWords);
110
- if (inst.avoidTopics && inst.avoidTopics.length > 0) {
111
- label('Topics to avoid', inst.avoidTopics.join(', '));
112
- }
113
- label('Only respond if known', inst.respondOnlyIfKnows ? 'Yes' : 'No');
114
- label('Greeting', inst.greeting);
115
- }
116
-
117
- // Persona
118
- if (agentData.person) {
119
- sectionHeader('Persona');
120
- const p = agentData.person;
121
- label('Name', p.name);
122
- label('Role', p.role);
123
- label('First person', p.speaksInFirstPerson ? 'Yes' : 'No');
124
- label('Is human', p.isHuman ? 'Yes' : 'No');
125
- }
126
-
127
- // Fallbacks
128
- if (agentData.fallbacks) {
129
- sectionHeader('Fallbacks');
130
- const fb = agentData.fallbacks;
131
- label('No answer', fb.noAnswer);
132
- label('Service error', fb.serviceError);
133
- label('Does not understand', fb.doNotUnderstand);
134
- }
135
-
136
- // Reglas
137
- if (agentData.rules) {
138
- sectionHeader('Rules');
139
- const r = agentData.rules;
140
- label('Do not mention prices', r.doNotMentionPrices ? 'Yes' : 'No');
141
- label('Do not diagnose', r.doNotDiagnose ? 'Yes' : 'No');
142
- if (r.doNotRespondOutsideHours) {
143
- label('Out of hours', r.doNotRespondOutsideHours);
144
- }
145
- }
146
-
147
- // Servicios
148
- if (agentData.services && agentData.services.length > 0) {
149
- sectionHeader(`Services (${agentData.services.length})`);
150
- agentData.services.forEach((svc: any, i: number) => {
151
- console.log(chalk.hex('#2196F3')(` ${i + 1}. ${svc.intent || svc.reference || 'Service'}`));
152
- label(' Reference', svc.reference);
153
- label(' Enabled', svc.enabled ? 'Yes' : 'No');
154
- label(' Method', svc.method);
155
- label(' Endpoint', svc.endpoint);
156
- if (svc.requiredFields && svc.requiredFields.length > 0) {
157
- console.log(chalk.gray(' Fields:'));
158
- svc.requiredFields.forEach((f: any) => {
159
- console.log(chalk.white(` - ${f.name} (${f.type}): ${f.description || ''}`));
160
- });
161
- }
162
- });
163
- }
164
-
165
- // Acciones
166
- if (agentData.actions && agentData.actions.length > 0) {
167
- sectionHeader(`Actions (${agentData.actions.length})`);
168
- agentData.actions.forEach((act: any, i: number) => {
169
- console.log(chalk.hex('#FFA726')(` ${i + 1}. ${act.intent || act.reference || 'Action'}`));
170
- label(' Reference', act.reference);
171
- label(' Enabled', act.enabled ? 'Yes' : 'No');
172
- if (act.tags && act.tags.length > 0) {
173
- label(' Tags', act.tags.join(', '));
174
- }
175
- label(' Response', act.responseMessage);
176
- if (act.action && act.action.length > 0) {
177
- console.log(chalk.gray(' Sub-actions:'));
178
- act.action.forEach((sa: any) => {
179
- console.log(chalk.white(` - ${sa.type}: ${sa.value || ''}`));
180
- });
181
- }
182
- });
183
- }
184
-
185
- // Canales
186
- if (agentData.channels && agentData.channels.length > 0) {
187
- sectionHeader(`Channels (${agentData.channels.length})`);
188
- agentData.channels.forEach((ch: any) => {
189
- console.log(chalk.white(` ${chalk.hex('#22d3ee')(ch.channel || 'channel')}: ${ch.key || ''}`));
190
- });
191
- }
192
-
193
- // AI Config
194
- if (agentData.customAIConfig && agentData.aiProviders && agentData.aiProviders.length > 0) {
195
- sectionHeader('AI Model');
196
- agentData.aiProviders.forEach((ai: any) => {
197
- label('Provider', ai.provider);
198
- label('Model', ai.model);
199
- });
200
- }
201
-
202
- console.log();
203
- console.log(chalk.gray(' Use --raw to see the full JSON'));
204
- console.log();
205
-
206
- if (options.dev) {
207
- logger.warning('Environment: development');
208
- }
209
-
210
- } catch (error) {
211
- const credentials = await getStoredCredentials().catch(() => null);
212
- if (credentials) {
213
- logger.error(describeAgentLoadError(error, agentId, credentials, {
214
- dev: options.dev,
215
- workspaceOverride: options.workspace,
216
- zoneOverride: options.zone,
217
- }));
218
- } else {
219
- const message = error instanceof Error ? error.message : 'Unknown error while fetching the agent';
220
- logger.error(message);
221
- }
222
- process.exit(1);
223
- }
224
- });
225
-
226
- addExamples(getCommand, [
227
- { description: 'Show the agent in a human-friendly layout',
228
- command: 'plazbot agent get agt_AbcDef123' },
229
- { description: 'Dump the full raw JSON (useful for piping to jq)',
230
- command: 'plazbot agent get agt_AbcDef123 --raw' },
231
- { description: 'Inspect an agent from another workspace (support mode)',
232
- command: 'plazbot agent get agt_AbcDef123 -w wok_Other123 -z LA' },
233
- ]);
@@ -1,55 +0,0 @@
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
-
21
- export const agentCommands = new Command('agent')
22
- .description('Commands related to AI agents')
23
- .addCommand(listCommand)
24
- .addCommand(getCommand)
25
- .addCommand(deleteCommand)
26
- .addCommand(createCommand)
27
- .addCommand(updateCommand)
28
- .addCommand(enableCommand)
29
- .addCommand(chatCommand)
30
- .addCommand(messageCommand)
31
- .addCommand(toolsCommand)
32
- .addCommand(aiConfigCommand)
33
- .addCommand(templatesCommand)
34
- .addCommand(copyCommand)
35
- .addCommand(filesCommand)
36
- .addCommand(setCommand)
37
- .addCommand(monitorCommand)
38
- .addCommand(exportCommand)
39
- .addCommand(crossCopyCommand)
40
- .addCommand(validateCommand);
41
-
42
- addExamples(agentCommands, [
43
- { description: 'List agents in the active workspace',
44
- command: 'plazbot agent list' },
45
- { description: 'Chat interactively with an agent',
46
- command: 'plazbot agent chat agt_AbcDef123' },
47
- { description: 'Create an agent from a JSON template',
48
- command: 'plazbot agent create ./agent.json' },
49
- { description: 'Export an agent and copy it to another workspace',
50
- command: 'plazbot agent cross-copy agt_AbcDef123 --from-workspace wok_Source --to-workspace wok_Target' },
51
- { description: 'Monitor activity of an agent in real time',
52
- command: 'plazbot agent monitor agt_AbcDef123' },
53
- { description: 'Validate a local agent JSON file against the schema',
54
- command: 'plazbot agent validate ./agent.json' },
55
- ]);
@@ -1,58 +0,0 @@
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 { ListAgentsOptions } from '../../types/agent.js';
7
-
8
- export const listCommand = new Command('list')
9
- .description('List all agents in the workspace')
10
- .option('--dev', 'Use development environment (localhost:5090)', false)
11
- .action(async (options: ListAgentsOptions) => {
12
- try {
13
- // Obtener credenciales guardadas
14
- const credentials = await getStoredCredentials();
15
-
16
- // Crear instancia del agente con las credenciales guardadas
17
- const agent = new Agent({
18
- workspaceId: credentials.workspace,
19
- apiKey: credentials.apiKey,
20
- zone: credentials.zone,
21
- ...(options.dev && { customUrl: "http://localhost:5090" })
22
- });
23
-
24
- // Obtener lista de agentes
25
- const agents = await agent.getAgents();
26
-
27
- if (agents.length === 0) {
28
- logger.info('No agents found in this workspace');
29
- return;
30
- }
31
-
32
- logger.info('\nAgents:');
33
- logger.doubleDivider();
34
-
35
- agents.forEach((a: any, index: number) => {
36
- logger.info(`${index + 1}. ID: ${a.id}`);
37
- logger.info(` Name: ${a.name}`);
38
- logger.info(` Status: ${a.enable ? 'Active' : 'Inactive'}`);
39
- logger.info(` Description: ${a.description}`);
40
- logger.info(` Created: ${a.createdAt ? new Date(a.createdAt).toLocaleString() : 'N/A'}`);
41
- logger.divider();
42
- });
43
-
44
- if (options.dev) {
45
- logger.warning('Environment: development');
46
- }
47
-
48
- } catch (error) {
49
- const message = error instanceof Error ? error.message : 'Unknown error while listing agents';
50
- logger.error(message);
51
- process.exit(1);
52
- }
53
- });
54
-
55
- addExamples(listCommand, [
56
- { description: 'List every agent in the active workspace', command: 'plazbot agent list' },
57
- { description: 'List against a local backend (dev mode)', command: 'plazbot agent list --dev' },
58
- ]);