zrocclaw 0.0.5 → 0.0.7

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/bin/zrocclaw.js CHANGED
@@ -1,2 +1,126 @@
1
1
  #!/usr/bin/env node
2
- require('../dist/index.js');
2
+ const { Command } = require("commander");
3
+ const { execSync } = require("child_process");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const os = require("os");
7
+ const pm2 = require("pm2");
8
+
9
+ const program = new Command();
10
+ const packageJson = require("../package.json");
11
+
12
+ program
13
+ .name("zrocclaw")
14
+ .description(packageJson.description)
15
+ .version(packageJson.version);
16
+
17
+ const PM2_APP_NAME = "zrocclaw-gateway";
18
+
19
+ program
20
+ .command("start")
21
+ .description("启动 ZrocClaw 后台服务")
22
+ .action(() => {
23
+ pm2.connect((err) => {
24
+ if (err) {
25
+ console.error("❌ PM2 连接失败:", err);
26
+ process.exit(2);
27
+ }
28
+
29
+ pm2.describe(PM2_APP_NAME, (err, processDescriptionList) => {
30
+ if (err) {
31
+ console.error("❌ 获取进程状态失败:", err);
32
+ pm2.disconnect();
33
+ return;
34
+ }
35
+
36
+ const isRunning = processDescriptionList && processDescriptionList.some(p => p.pm2_env.status === "online");
37
+ if (isRunning) {
38
+ console.log("⚠️ ZrocClaw 服务已在运行");
39
+ pm2.disconnect();
40
+ return;
41
+ }
42
+
43
+ const serverPath = path.join(__dirname, "../server/server.js");
44
+
45
+ if (!serverPath || !fs.existsSync(serverPath)) {
46
+ console.error("❌ 启动失败:找不到 gateway 启动文件。请确认它已正确安装和编译。");
47
+ pm2.disconnect();
48
+ return;
49
+ }
50
+
51
+ const logDir = path.join(os.homedir(), ".zrocclaw", "log");
52
+ if (!fs.existsSync(logDir)) {
53
+ fs.mkdirSync(logDir, { recursive: true });
54
+ }
55
+
56
+ const outLogPath = path.join(logDir, "pm2out.log");
57
+ const errLogPath = path.join(logDir, "pm2err.log");
58
+
59
+ pm2.start({
60
+ name: PM2_APP_NAME,
61
+ script: serverPath,
62
+ env: {
63
+ NODE_ENV: "production",
64
+ },
65
+ output: outLogPath,
66
+ error: errLogPath,
67
+ merge_logs: true
68
+ }, (err, apps) => {
69
+ pm2.disconnect();
70
+ if (err) {
71
+ console.error("❌ 启动失败:", err);
72
+ return;
73
+ }
74
+ console.log(`✅ ZrocClaw 服务已通过 PM2 在后台启动 (进程名: ${PM2_APP_NAME})`);
75
+ console.log(`🌍 请在浏览器访问体验,默认端口请参考网关配置。`);
76
+ });
77
+ });
78
+ });
79
+ });
80
+
81
+ program
82
+ .command("stop")
83
+ .description("停止 ZrocClaw 服务")
84
+ .action(() => {
85
+ pm2.connect((err) => {
86
+ if (err) {
87
+ console.error("❌ PM2 连接失败:", err);
88
+ process.exit(2);
89
+ }
90
+
91
+ pm2.describe(PM2_APP_NAME, (err, processDescriptionList) => {
92
+ if (err || !processDescriptionList || processDescriptionList.length === 0) {
93
+ console.log("❌ 未找到运行中的 ZrocClaw 服务记录");
94
+ pm2.disconnect();
95
+ return;
96
+ }
97
+
98
+ pm2.stop(PM2_APP_NAME, (err) => {
99
+ if (err) {
100
+ console.error("❌ 停止服务失败:", err);
101
+ pm2.disconnect();
102
+ } else {
103
+ console.log(`✅ ZrocClaw 服务 (进程名: ${PM2_APP_NAME}) 已停止`);
104
+ pm2.delete(PM2_APP_NAME, () => {
105
+ pm2.disconnect();
106
+ });
107
+ }
108
+ });
109
+ });
110
+ });
111
+ });
112
+
113
+ program
114
+ .command("update")
115
+ .description("全局更新 ZrocClaw 到最新版本")
116
+ .action(() => {
117
+ console.log("⏳ 正在检查并更新 ZrocClaw...");
118
+ try {
119
+ execSync("npm install -g zrocclaw@latest", { stdio: "inherit" });
120
+ console.log("✅ 更新完成!");
121
+ } catch (e) {
122
+ console.error("❌ 更新失败,请检查网络或权限");
123
+ }
124
+ });
125
+
126
+ program.parse(process.argv);
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "zrocclaw",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "个人专属浏览器AI助手命令行工具",
5
5
  "bin": {
6
6
  "zrocclaw": "bin/zrocclaw.js"
7
7
  },
8
8
  "files": [
9
- "dist",
10
9
  "bin",
10
+ "server",
11
11
  "README.md"
12
12
  ],
13
- "scripts": {
14
- "dev": "tsup --watch",
15
- "build": "tsup"
16
- },
13
+ "scripts": {},
17
14
  "dependencies": {
18
15
  "commander": "^12.1.0",
16
+ "pm2": "^5.4.3",
19
17
  "cors": "^2.8.6",
20
18
  "dotenv": "^17.3.1",
21
19
  "express": "^5.2.1",
22
20
  "helmet": "^8.1.0",
23
- "http-proxy-middleware": "^3.0.5"
24
- },
25
- "devDependencies": {
26
- "@types/node": "^24.12.0",
27
- "tsup": "^8.5.1",
28
- "typescript": "^5.9.3"
21
+ "http-proxy-middleware": "^3.0.5",
22
+ "@langchain/core": "^1.1.34",
23
+ "@langchain/langgraph": "^1.2.4",
24
+ "@langchain/openai": "^1.3.0",
25
+ "langchain": "^1.2.35",
26
+ "playwright": "^1.58.2",
27
+ "zod": "^4.3.6",
28
+ "@zrocclaw/core": "workspace:*"
29
29
  }
30
30
  }