plazbot-cli 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent.config.json +21 -0
- package/dist/cli.js +22 -0
- package/dist/commands/agent/chat.js +92 -0
- package/dist/commands/agent/create.js +52 -0
- package/dist/commands/agent/delete.js +61 -0
- package/dist/commands/agent/enable-widget.js +55 -0
- package/dist/commands/agent/get.js +161 -0
- package/dist/commands/agent/index.js +22 -0
- package/dist/commands/agent/list.js +47 -0
- package/dist/commands/agent/on-message.js +67 -0
- package/dist/commands/agent/update.js +52 -0
- package/dist/commands/auth/index.js +9 -0
- package/dist/commands/auth/login.js +52 -0
- package/dist/commands/auth/logout.js +23 -0
- package/dist/commands/message/delete-webhook.js +39 -0
- package/dist/commands/message/index.js +14 -0
- package/dist/commands/message/register-webhook.js +42 -0
- package/dist/commands/message/send-template.js +42 -0
- package/dist/commands/message/send.js +42 -0
- package/dist/commands/portal/add-agent.js +58 -0
- package/dist/commands/portal/add-link.js +33 -0
- package/dist/commands/portal/clear-links.js +27 -0
- package/dist/commands/portal/create.js +51 -0
- package/dist/commands/portal/delete.js +58 -0
- package/dist/commands/portal/get.js +66 -0
- package/dist/commands/portal/index.js +22 -0
- package/dist/commands/portal/list.js +65 -0
- package/dist/commands/portal/update.js +79 -0
- package/dist/commands/whatsapp/delete-webhook.js +32 -0
- package/dist/commands/whatsapp/index.js +14 -0
- package/dist/commands/whatsapp/register-webhook.js +35 -0
- package/dist/commands/whatsapp/send-template.js +41 -0
- package/dist/commands/whatsapp/send.js +42 -0
- package/dist/types/agent.js +2 -0
- package/dist/types/auth.js +2 -0
- package/dist/types/common.js +2 -0
- package/dist/types/message.js +2 -0
- package/dist/types/portal.js +2 -0
- package/dist/utils/credentials.js +33 -0
- package/dist/utils/logger.js +24 -0
- package/package.json +47 -0
- package/src/cli.ts +26 -0
- package/src/commands/agent/chat.ts +103 -0
- package/src/commands/agent/create.ts +53 -0
- package/src/commands/agent/delete.ts +64 -0
- package/src/commands/agent/enable-widget.ts +62 -0
- package/src/commands/agent/get.ts +175 -0
- package/src/commands/agent/index.ts +20 -0
- package/src/commands/agent/list.ts +52 -0
- package/src/commands/agent/on-message.ts +75 -0
- package/src/commands/agent/update.ts +53 -0
- package/src/commands/auth/index.ts +8 -0
- package/src/commands/auth/login.ts +56 -0
- package/src/commands/auth/logout.ts +22 -0
- package/src/commands/portal/add-agent.ts +66 -0
- package/src/commands/portal/add-link.ts +39 -0
- package/src/commands/portal/clear-links.ts +26 -0
- package/src/commands/portal/create.ts +55 -0
- package/src/commands/portal/delete.ts +63 -0
- package/src/commands/portal/get.ts +75 -0
- package/src/commands/portal/index.ts +20 -0
- package/src/commands/portal/list.ts +73 -0
- package/src/commands/portal/update.ts +82 -0
- package/src/commands/whatsapp/delete-webhook.ts +37 -0
- package/src/commands/whatsapp/index.ts +12 -0
- package/src/commands/whatsapp/register-webhook.ts +41 -0
- package/src/commands/whatsapp/send-template.ts +44 -0
- package/src/commands/whatsapp/send.ts +46 -0
- package/src/types/agent.ts +63 -0
- package/src/types/auth.ts +8 -0
- package/src/types/common.ts +10 -0
- package/src/types/message.ts +34 -0
- package/src/types/portal.ts +56 -0
- package/src/utils/credentials.ts +37 -0
- package/src/utils/logger.ts +21 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BaseCommandOptions } from './common';
|
|
2
|
+
|
|
3
|
+
export interface PortalCommandOptions extends BaseCommandOptions {
|
|
4
|
+
portalId?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
subtitle?: string;
|
|
8
|
+
logo?: string;
|
|
9
|
+
logoDark?: string;
|
|
10
|
+
access?: "direct" | "form";
|
|
11
|
+
disabled?: string;
|
|
12
|
+
brandOff?: string;
|
|
13
|
+
zone?: "LA" | "EU";
|
|
14
|
+
dev?: boolean;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AddAgentToPortalOptions extends BaseCommandOptions {
|
|
19
|
+
portalId: string;
|
|
20
|
+
agentId: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AddLinkToPortalOptions extends BaseCommandOptions {
|
|
24
|
+
portalId: string;
|
|
25
|
+
text: string;
|
|
26
|
+
url: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PortalLink {
|
|
30
|
+
value: string;
|
|
31
|
+
url: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface PortalAgent {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface Portal {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
url: string;
|
|
43
|
+
access: string;
|
|
44
|
+
disabled: boolean;
|
|
45
|
+
title?: string;
|
|
46
|
+
subtitle?: string;
|
|
47
|
+
logo?: string;
|
|
48
|
+
logodark?: string;
|
|
49
|
+
links?: PortalLink[];
|
|
50
|
+
agents?: PortalAgent[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface PortalResponse {
|
|
54
|
+
success: boolean;
|
|
55
|
+
portal: Portal;
|
|
56
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
|
|
5
|
+
const configDir = path.join(os.homedir(), '.plazbot');
|
|
6
|
+
const configPath = path.join(configDir, 'config.json');
|
|
7
|
+
|
|
8
|
+
interface StoredCredentials {
|
|
9
|
+
email: string;
|
|
10
|
+
apiKey: string;
|
|
11
|
+
workspace: string;
|
|
12
|
+
zone: "LA" | "EU";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function getStoredCredentials(): Promise<StoredCredentials> {
|
|
16
|
+
try {
|
|
17
|
+
const configRaw = await fs.readFile(configPath, 'utf-8');
|
|
18
|
+
const config = JSON.parse(configRaw);
|
|
19
|
+
|
|
20
|
+
if (!config.apiKey || !config.workspace || !config.zone) {
|
|
21
|
+
throw new Error('Credenciales incompletas');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return config;
|
|
25
|
+
} catch (error) {
|
|
26
|
+
throw new Error("No se encontró una sesión activa. Ejecuta 'plazbot init' primero.");
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function saveCredentials(credentials: StoredCredentials): Promise<void> {
|
|
31
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
32
|
+
await fs.writeFile(configPath, JSON.stringify(credentials, null, 2));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function removeCredentials(): Promise<void> {
|
|
36
|
+
await fs.rm(configPath, { force: true });
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const logger = {
|
|
2
|
+
info: (message: string) => {
|
|
3
|
+
console.log(message);
|
|
4
|
+
},
|
|
5
|
+
success: (message: string) => {
|
|
6
|
+
console.log(`\n✅ ${message}`);
|
|
7
|
+
},
|
|
8
|
+
warning: (message: string) => {
|
|
9
|
+
console.log(`\n⚠️ ${message}`);
|
|
10
|
+
},
|
|
11
|
+
error: (error: Error | string) => {
|
|
12
|
+
const message = error instanceof Error ? error.message : error;
|
|
13
|
+
console.error(`\n❌ Error: ${message}`);
|
|
14
|
+
},
|
|
15
|
+
divider: (length: number = 50) => {
|
|
16
|
+
console.log('─'.repeat(length));
|
|
17
|
+
},
|
|
18
|
+
doubleDivider: (length: number = 50) => {
|
|
19
|
+
console.log('═'.repeat(length));
|
|
20
|
+
}
|
|
21
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2020", // O una versión más reciente
|
|
4
|
+
"module": "commonjs", // O "NodeNext" si configuras package.json con "type": "module"
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"moduleResolution": "node" // O "NodeNext"
|
|
12
|
+
},
|
|
13
|
+
"include": ["src/**/*"],
|
|
14
|
+
"exclude": ["node_modules", "**/*.spec.ts"]
|
|
15
|
+
}
|