@coclaw/openclaw-coclaw 0.2.0 → 0.2.1
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 +3 -3
- package/package.json +2 -2
- package/src/auto-upgrade/updater-spawn.js +3 -4
- package/src/auto-upgrade/updater.js +10 -10
package/README.md
CHANGED
|
@@ -40,15 +40,15 @@ pnpm run uninstall:npm # 卸载 npm 模式
|
|
|
40
40
|
发布前验证 tarball 能正确安装到 OpenClaw 中:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
pnpm run
|
|
44
|
-
pnpm run
|
|
43
|
+
pnpm run release:pre # 全新安装验证(交互式,含手动功能验证)
|
|
44
|
+
pnpm run release:pre -- --upgrade # 升级验证(先装 npm 旧版,再用本地包覆盖)
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
### 发布到 npm
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
50
|
pnpm run release # 默认:verify → 发布 → 轮询确认
|
|
51
|
-
pnpm run release -- --prerelease # 含预发布验证(pack + 安装测试 +
|
|
51
|
+
pnpm run release -- --prerelease # 含预发布验证(pack + 安装测试 + 发布,等同于先手动 release:pre 再 release)
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### 检查发布状态
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coclaw/openclaw-coclaw",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "OpenClaw CoClaw channel plugin for remote chat",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"unlink": "bash ./scripts/unlink.sh",
|
|
59
59
|
"install:npm": "bash ./scripts/install-npm.sh",
|
|
60
60
|
"uninstall:npm": "bash ./scripts/uninstall-npm.sh",
|
|
61
|
-
"
|
|
61
|
+
"release:pre": "bash ./scripts/prerelease.sh",
|
|
62
62
|
"release": "bash ./scripts/release.sh",
|
|
63
63
|
"release:check": "bash ./scripts/release-check.sh",
|
|
64
64
|
"release:versions": "npm view @coclaw/openclaw-coclaw versions --json --registry=https://registry.npmjs.org/ && npm view @coclaw/openclaw-coclaw versions --json"
|
|
@@ -27,15 +27,14 @@ export function getWorkerPath() {
|
|
|
27
27
|
* @param {string} params.pkgName - npm 包名
|
|
28
28
|
* @param {object} [params.opts]
|
|
29
29
|
* @param {Function} [params.opts.spawnFn] - 可注入的 spawn(测试用)
|
|
30
|
-
* @param {
|
|
30
|
+
* @param {object} [params.logger] - 需提供 .info() 方法(如 pino/gateway logger)
|
|
31
31
|
* @returns {{ child: object }}
|
|
32
32
|
*/
|
|
33
33
|
export function spawnUpgradeWorker({ pluginDir, fromVersion, toVersion, pluginId, pkgName, opts, logger }) {
|
|
34
|
-
const log = typeof logger?.log === 'function' ? logger.log.bind(logger) : (logger ?? console.log);
|
|
35
34
|
const doSpawn = opts?.spawnFn ?? nodeSpawn;
|
|
36
35
|
const workerPath = getWorkerPath();
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
logger?.info?.(`[spawner] Spawning upgrade worker: ${fromVersion} → ${toVersion}`);
|
|
39
38
|
|
|
40
39
|
// 将 state dir 传递给 worker,确保 worker 写入正确的路径
|
|
41
40
|
const stateDir = resolveStateDir();
|
|
@@ -57,7 +56,7 @@ export function spawnUpgradeWorker({ pluginDir, fromVersion, toVersion, pluginId
|
|
|
57
56
|
|
|
58
57
|
child.unref();
|
|
59
58
|
|
|
60
|
-
|
|
59
|
+
logger?.info?.(`[spawner] Worker spawned (pid: ${child.pid})`);
|
|
61
60
|
return { child };
|
|
62
61
|
}
|
|
63
62
|
|
|
@@ -38,7 +38,7 @@ export async function isUpgradeLocked(opts) {
|
|
|
38
38
|
try {
|
|
39
39
|
const lock = JSON.parse(raw);
|
|
40
40
|
if (!lock.pid) {
|
|
41
|
-
logger?.
|
|
41
|
+
logger?.info?.('[auto-upgrade] Stale lock removed (missing pid)');
|
|
42
42
|
await fs.rm(lockPath, { force: true }).catch(() => {});
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
@@ -48,7 +48,7 @@ export async function isUpgradeLocked(opts) {
|
|
|
48
48
|
}
|
|
49
49
|
catch {
|
|
50
50
|
// JSON 无效 / PID 已死 → 清理过期锁
|
|
51
|
-
logger?.
|
|
51
|
+
logger?.info?.('[auto-upgrade] Stale lock removed (worker pid no longer alive)');
|
|
52
52
|
await fs.rm(lockPath, { force: true }).catch(() => {});
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
@@ -157,7 +157,7 @@ export class AutoUpgradeScheduler {
|
|
|
157
157
|
|
|
158
158
|
const shouldSkip = this.__opts.shouldSkipFn ?? shouldSkipAutoUpgrade;
|
|
159
159
|
if (shouldSkip(this.__pluginId)) {
|
|
160
|
-
this.__logger.
|
|
160
|
+
this.__logger.info?.('[auto-upgrade] Skipping: not an npm-installed plugin');
|
|
161
161
|
this.__running = false;
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
@@ -165,7 +165,7 @@ export class AutoUpgradeScheduler {
|
|
|
165
165
|
// 默认 5~10 分钟随机延迟,避免多实例同时发起检查
|
|
166
166
|
const initialDelay = this.__opts.initialDelayMs
|
|
167
167
|
?? (INITIAL_DELAY_MS + Math.floor(Math.random() * INITIAL_DELAY_MS));
|
|
168
|
-
this.__logger.
|
|
168
|
+
this.__logger.info?.(`[auto-upgrade] Scheduler started. First check in ${Math.round(initialDelay / 1000)}s`);
|
|
169
169
|
|
|
170
170
|
this.__initialTimer = setTimeout(() => {
|
|
171
171
|
this.__initialTimer = null;
|
|
@@ -190,7 +190,7 @@ export class AutoUpgradeScheduler {
|
|
|
190
190
|
clearInterval(this.__intervalTimer);
|
|
191
191
|
this.__intervalTimer = null;
|
|
192
192
|
}
|
|
193
|
-
this.__logger.
|
|
193
|
+
this.__logger.info?.('[auto-upgrade] Scheduler stopped');
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
/**
|
|
@@ -203,25 +203,25 @@ export class AutoUpgradeScheduler {
|
|
|
203
203
|
// 若上一次 spawn 的 worker 仍在运行,跳过本次检查
|
|
204
204
|
const isLocked = this.__opts.isUpgradeLockedFn ?? isUpgradeLocked;
|
|
205
205
|
if (await isLocked({ logger: this.__logger })) {
|
|
206
|
-
this.__logger.
|
|
206
|
+
this.__logger.info?.('[auto-upgrade] Upgrade worker still running, skipping check');
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
this.__logger.
|
|
210
|
+
this.__logger.info?.('[auto-upgrade] Checking for updates...');
|
|
211
211
|
const result = await checkForUpdate({
|
|
212
212
|
execFileFn: this.__opts.execFileFn,
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
if (!result.available) {
|
|
216
216
|
if (result.skipped) {
|
|
217
|
-
this.__logger.
|
|
217
|
+
this.__logger.info?.(`[auto-upgrade] Version ${result.latestVersion} skipped (previously failed)`);
|
|
218
218
|
} else {
|
|
219
|
-
this.__logger.
|
|
219
|
+
this.__logger.info?.(`[auto-upgrade] No update available (current: ${result.currentVersion})`);
|
|
220
220
|
}
|
|
221
221
|
return;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
this.__logger.
|
|
224
|
+
this.__logger.info?.(`[auto-upgrade] Update available: ${result.currentVersion} → ${result.latestVersion}`);
|
|
225
225
|
|
|
226
226
|
const getInstallPath = this.__opts.getPluginInstallPathFn ?? getPluginInstallPath;
|
|
227
227
|
const pluginDir = getInstallPath(this.__pluginId);
|