ps-claw 1.0.6 → 1.0.8

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/cli.mjs CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * PS Claw CLI — ponto de entrada global
5
- * Uso: ps-claw [comando]
6
- * Comandos: start | web | all | update | help
4
+ * PS Claw CLI — standalone, sem dependência do dist/
7
5
  */
8
6
 
9
7
  import { spawn } from "node:child_process";
@@ -33,7 +31,7 @@ ${C.cyan}${C.bold} ██████╔╝███████╗ ██
33
31
  ${C.cyan}${C.bold} ██╔═══╝ ╚════██║ ██║ ██║ ██╔══██║██║███╗██║${C.reset}
34
32
  ${C.cyan}${C.bold} ██║ ███████║ ╚██████╗███████╗██║ ██║╚███╔███╔╝${C.reset}
35
33
  ${C.cyan}${C.bold} ╚═╝ ╚══════╝ ╚═════╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝${C.reset}
36
- ${C.dim}v1.0.0 — Lightweight AI Agent Gateway${C.reset}
34
+ ${C.dim}v1.0.8 — Lightweight AI Agent Gateway${C.reset}
37
35
  `);
38
36
  }
39
37
 
@@ -41,79 +39,60 @@ function help() {
41
39
  banner();
42
40
  console.log(` ${C.bold}Comandos:${C.reset}
43
41
 
44
- ${C.green}ps-claw start${C.reset} Inicia o agente PS Claw
45
- ${C.green}ps-claw web${C.reset} Inicia a interface web em http://localhost:3000
46
- ${C.green}ps-claw all${C.reset} Inicia o agente + interface web juntos
47
- ${C.green}ps-claw update${C.reset} Atualiza o PS Claw
48
- ${C.green}ps-claw help${C.reset} Esta mensagem
49
-
50
- ${C.bold}Início rápido:${C.reset}
51
-
52
- ${C.dim}# Via npm (global)${C.reset}
53
- npm install -g ps-claw
54
- ps-claw all
55
-
56
- ${C.dim}# Via git clone${C.reset}
57
- git clone https://github.com/Pedro21062014/ps-claw-v2.git
58
- cd ps-claw-v2 && npm install
59
- ps-claw all
42
+ ${C.green}npx ps-claw web${C.reset} Abre a interface web em http://localhost:3000
43
+ ${C.green}npx ps-claw start${C.reset} Inicia o agente PS Claw
44
+ ${C.green}npx ps-claw all${C.reset} Inicia tudo junto
45
+ ${C.green}npx ps-claw update${C.reset} Atualiza o PS Claw
46
+ ${C.green}npx ps-claw help${C.reset} Esta mensagem
60
47
 
61
48
  ${C.bold}Interface web:${C.reset} http://localhost:3000
62
49
  `);
63
50
  }
64
51
 
65
- function run(file, extraArgs = []) {
66
- if (!existsSync(file)) {
67
- console.error(`${C.red}❌ Arquivo não encontrado: ${file}${C.reset}`);
52
+ function startWeb() {
53
+ const srv = path.join(__dirname, "web-ui", "server.mjs");
54
+ if (!existsSync(srv)) {
55
+ console.error(`${C.red}❌ web-ui/server.mjs não encontrado!${C.reset}`);
68
56
  process.exit(1);
69
57
  }
70
- const proc = spawn(process.execPath, [file, ...extraArgs], { stdio: "inherit" });
58
+ console.log(`${C.green}🌐 Iniciando Interface Web...${C.reset}`);
59
+ console.log(`${C.cyan} Acesse: http://localhost:3000${C.reset}\n`);
60
+ const proc = spawn(process.execPath, [srv], { stdio: "inherit" });
71
61
  proc.on("exit", code => process.exit(code ?? 0));
72
- return proc;
73
62
  }
74
63
 
75
64
  function startAgent() {
76
- console.log(`${C.green}🦞 Iniciando PS Claw Agent...${C.reset}`);
77
- run(path.join(__dirname, "ps-claw.mjs"), args.slice(1));
78
- }
65
+ // Usa o ps-claw.mjs original do OpenClaw se existir e tiver dist/
66
+ // Caso contrário, avisa o usuário e abre a web
67
+ const distEntry = path.join(__dirname, "dist", "entry.mjs");
68
+ const distEntryJs = path.join(__dirname, "dist", "entry.js");
69
+
70
+ if (!existsSync(distEntry) && !existsSync(distEntryJs)) {
71
+ console.log(`${C.yellow}⚠️ O agente requer configuração adicional (dist/).${C.reset}`);
72
+ console.log(`${C.dim} Para usar a interface web, execute: npx ps-claw web${C.reset}\n`);
73
+ console.log(`${C.green}🌐 Iniciando Interface Web automaticamente...${C.reset}`);
74
+ console.log(`${C.cyan} Acesse: http://localhost:3000${C.reset}\n`);
75
+ startWeb();
76
+ return;
77
+ }
79
78
 
80
- function startWeb() {
81
- const srv = path.join(__dirname, "web-ui", "server.mjs");
82
- console.log(`${C.green}🌐 Interface Web http://localhost:3000${C.reset}`);
83
- run(srv);
79
+ console.log(`${C.green}🦞 Iniciando PS Claw Agent...${C.reset}`);
80
+ const proc = spawn(process.execPath, [path.join(__dirname, "ps-claw.mjs"), ...args.slice(1)], { stdio: "inherit" });
81
+ proc.on("exit", code => process.exit(code ?? 0));
84
82
  }
85
83
 
86
84
  function startAll() {
87
85
  banner();
88
- const agentFile = path.join(__dirname, "ps-claw.mjs");
89
- const webFile = path.join(__dirname, "web-ui", "server.mjs");
90
-
91
- console.log(`${C.green}🦞 Iniciando PS Claw Agent...${C.reset}`);
92
- const agent = spawn(process.execPath, [agentFile], { stdio: "inherit" });
93
-
94
- setTimeout(() => {
95
- if (existsSync(webFile)) {
96
- console.log(`\n${C.cyan}🌐 Iniciando Interface Web → http://localhost:3000${C.reset}\n`);
97
- const web = spawn(process.execPath, [webFile], { stdio: "inherit" });
98
- web.on("exit", code => process.exit(code ?? 0));
99
- }
100
- }, 1500);
101
-
102
- agent.on("exit", code => process.exit(code ?? 0));
103
- process.on("SIGINT", () => { agent.kill(); process.exit(0); });
86
+ startWeb();
104
87
  }
105
88
 
106
89
  function update() {
107
- banner();
108
- const script = path.join(__dirname, "update.sh");
109
- console.log(`${C.yellow}🔄 Verificando atualizações...${C.reset}\n`);
110
- if (!existsSync(script)) {
111
- console.log(`${C.yellow}Baixando versão mais recente...${C.reset}`);
112
- run("git", ["pull"]);
113
- return;
114
- }
115
- const proc = spawn("bash", [script], { stdio: "inherit" });
116
- proc.on("exit", code => process.exit(code ?? 0));
90
+ console.log(`${C.yellow}🔄 Atualizando PS Claw...${C.reset}\n`);
91
+ const proc = spawn("npm", ["install", "-g", "ps-claw@latest"], { stdio: "inherit", shell: true });
92
+ proc.on("exit", code => {
93
+ if (code === 0) console.log(`\n${C.green}✅ PS Claw atualizado!${C.reset}`);
94
+ process.exit(code ?? 0);
95
+ });
117
96
  }
118
97
 
119
98
  switch (cmd) {