zrocclaw 0.0.10 → 0.0.12
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/README.md +48 -0
- package/package.json +13 -1
- package/server/server.js +24 -4
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# zrocclaw CLI
|
|
2
|
+
|
|
3
|
+
ZrocClaw 官方命令行工具,用于快速启动和管理你的专属浏览器 AI 助手后台服务。
|
|
4
|
+
|
|
5
|
+
## 简介
|
|
6
|
+
|
|
7
|
+
本工具提供了简易的命令,底层依赖 `pm2` 来守护后台进程,帮助你一键启动、停止、或更新 ZrocClaw 服务。
|
|
8
|
+
|
|
9
|
+
## 安装
|
|
10
|
+
|
|
11
|
+
推荐进行全局安装,以便在任何终端路径下均可执行:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install -g zrocclaw
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 使用说明
|
|
18
|
+
|
|
19
|
+
安装完成后,你可以通过 `zrocclaw` 命令来管理后台服务。
|
|
20
|
+
|
|
21
|
+
### 启动服务
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
zrocclaw start
|
|
25
|
+
```
|
|
26
|
+
该命令会使用 PM2 在后台启动 ZrocClaw 网关服务。启动成功后,你可以通过以下地址访问服务:
|
|
27
|
+
- 💬 **对话界面**: [http://127.0.0.1:18302/web/#/chat](http://127.0.0.1:18302/web/#/chat)
|
|
28
|
+
- 🔍 **健康检查**: [http://127.0.0.1:18302/health](http://127.0.0.1:18302/health)
|
|
29
|
+
|
|
30
|
+
### 停止服务
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
zrocclaw stop
|
|
34
|
+
```
|
|
35
|
+
当你不再需要使用 ZrocClaw,或者需要彻底关闭后台驻留的服务时,可以运行该命令。它会停止并清理对应的 PM2 进程记录。
|
|
36
|
+
|
|
37
|
+
### 更新版本
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
zrocclaw update
|
|
41
|
+
```
|
|
42
|
+
一键将全局安装的 `zrocclaw` 更新到最新版本。
|
|
43
|
+
|
|
44
|
+
## 常见问题与日志排查
|
|
45
|
+
|
|
46
|
+
如果启动失败或服务运行异常,ZrocClaw 的 PM2 日志会默认输出到你的用户目录下,方便排查:
|
|
47
|
+
- 运行日志:`~/.zrocclaw/log/pm2out.log`
|
|
48
|
+
- 错误日志:`~/.zrocclaw/log/pm2err.log`
|
package/package.json
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zrocclaw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "个人专属浏览器AI助手命令行工具",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"zrocclaw",
|
|
7
|
+
"ai",
|
|
8
|
+
"assistant",
|
|
9
|
+
"browser",
|
|
10
|
+
"agent",
|
|
11
|
+
"automation",
|
|
12
|
+
"langchain",
|
|
13
|
+
"playwright",
|
|
14
|
+
"cli",
|
|
15
|
+
"openclaw"
|
|
16
|
+
],
|
|
5
17
|
"bin": {
|
|
6
18
|
"zrocclaw": "bin/zrocclaw.js"
|
|
7
19
|
},
|
package/server/server.js
CHANGED
|
@@ -30,7 +30,7 @@ var import_helmet = __toESM(require("helmet"));
|
|
|
30
30
|
// src/routes/config.ts
|
|
31
31
|
var import_express = require("express");
|
|
32
32
|
|
|
33
|
-
// ../../packages/core/dist/chunk-
|
|
33
|
+
// ../../packages/core/dist/chunk-46XX2E7T.mjs
|
|
34
34
|
var os = __toESM(require("os"), 1);
|
|
35
35
|
var path = __toESM(require("path"), 1);
|
|
36
36
|
var fs = __toESM(require("fs"), 1);
|
|
@@ -75,6 +75,10 @@ function getWorkspacePath(subPath) {
|
|
|
75
75
|
const workspacePath = path.join(getBasePath(), "workspace");
|
|
76
76
|
return resolveAndEnsurePath(workspacePath, subPath);
|
|
77
77
|
}
|
|
78
|
+
function getHistoryPath(subPath) {
|
|
79
|
+
const historyPath = path.join(getConfigPath(), "history");
|
|
80
|
+
return resolveAndEnsurePath(historyPath, subPath);
|
|
81
|
+
}
|
|
78
82
|
var SessionModel = class _SessionModel {
|
|
79
83
|
static instance;
|
|
80
84
|
filePath;
|
|
@@ -83,7 +87,8 @@ var SessionModel = class _SessionModel {
|
|
|
83
87
|
this.filePath = import_path.default.join(getConfigPath(), "session.json");
|
|
84
88
|
this.data = {
|
|
85
89
|
sessionId: null,
|
|
86
|
-
sessionData: []
|
|
90
|
+
sessionData: [],
|
|
91
|
+
history: []
|
|
87
92
|
};
|
|
88
93
|
this.load();
|
|
89
94
|
}
|
|
@@ -100,7 +105,8 @@ var SessionModel = class _SessionModel {
|
|
|
100
105
|
const parsed = JSON.parse(fileContent);
|
|
101
106
|
this.data = {
|
|
102
107
|
sessionId: parsed.sessionId ?? this.data.sessionId,
|
|
103
|
-
sessionData: Array.isArray(parsed.sessionData) ? parsed.sessionData : []
|
|
108
|
+
sessionData: Array.isArray(parsed.sessionData) ? parsed.sessionData : [],
|
|
109
|
+
history: Array.isArray(parsed.history) ? parsed.history : []
|
|
104
110
|
};
|
|
105
111
|
} catch (error) {
|
|
106
112
|
console.error("Failed to parse session.json:", error);
|
|
@@ -138,6 +144,20 @@ var SessionModel = class _SessionModel {
|
|
|
138
144
|
addSessionItem(item) {
|
|
139
145
|
this.load();
|
|
140
146
|
this.data.sessionData.push(item);
|
|
147
|
+
if (this.data.sessionData.length > 100) {
|
|
148
|
+
const sessionId = this.data.sessionId ?? "session";
|
|
149
|
+
const index = (this.data.history?.length ?? 0) + 1;
|
|
150
|
+
const filename = `${sessionId}${index}.json`;
|
|
151
|
+
const historyFilePath = getHistoryPath(filename);
|
|
152
|
+
const toArchive = this.data.sessionData.slice(0, 70);
|
|
153
|
+
try {
|
|
154
|
+
import_fs.default.writeFileSync(historyFilePath, JSON.stringify(toArchive, null, 2), "utf-8");
|
|
155
|
+
this.data.history.push(filename);
|
|
156
|
+
this.data.sessionData = this.data.sessionData.slice(70);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error("Failed to archive session history:", error);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
141
161
|
this.save();
|
|
142
162
|
}
|
|
143
163
|
};
|
|
@@ -357,7 +377,7 @@ var PlaywrightExecutor = class {
|
|
|
357
377
|
}
|
|
358
378
|
};
|
|
359
379
|
|
|
360
|
-
// ../../packages/core/dist/chunk-
|
|
380
|
+
// ../../packages/core/dist/chunk-RBTGQCL7.mjs
|
|
361
381
|
var import_openai = require("@langchain/openai");
|
|
362
382
|
var import_langchain = require("langchain");
|
|
363
383
|
var import_messages = require("@langchain/core/messages");
|