@coclaw/openclaw-coclaw 0.11.4 → 0.11.6
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/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import nodePath from 'node:path';
|
|
|
3
3
|
|
|
4
4
|
import { checkForUpdate } from './updater-check.js';
|
|
5
5
|
import { spawnUpgradeWorker } from './updater-spawn.js';
|
|
6
|
-
import { resolveStateDir } from './state.js';
|
|
6
|
+
import { readState, resolveStateDir, writeState } from './state.js';
|
|
7
7
|
import { getRuntime } from '../runtime.js';
|
|
8
8
|
import { remoteLog } from '../remote-log.js';
|
|
9
9
|
|
|
@@ -124,6 +124,8 @@ export class AutoUpgradeScheduler {
|
|
|
124
124
|
__pluginId = null;
|
|
125
125
|
__logger = console;
|
|
126
126
|
__opts = {};
|
|
127
|
+
/** 已报告过的 lastUpgrade.ts,用于去重 */
|
|
128
|
+
__lastReportedUpgradeTs = null;
|
|
127
129
|
|
|
128
130
|
/**
|
|
129
131
|
* @param {object} [params]
|
|
@@ -194,6 +196,29 @@ export class AutoUpgradeScheduler {
|
|
|
194
196
|
this.__logger.info?.('[auto-upgrade] Scheduler stopped');
|
|
195
197
|
}
|
|
196
198
|
|
|
199
|
+
/**
|
|
200
|
+
* 检查 lastUpgrade 是否有未报告的结果,若有则 remoteLog 并标记已报告
|
|
201
|
+
*/
|
|
202
|
+
async __reportLastUpgradeResult() {
|
|
203
|
+
try {
|
|
204
|
+
const readStateFn = this.__opts.readStateFn ?? readState;
|
|
205
|
+
const state = await readStateFn();
|
|
206
|
+
const last = state.lastUpgrade;
|
|
207
|
+
if (!last?.ts || last.ts === state.lastReport) return;
|
|
208
|
+
if (last.ts === this.__lastReportedUpgradeTs) return;
|
|
209
|
+
this.__lastReportedUpgradeTs = last.ts;
|
|
210
|
+
remoteLog(`upgrade.result result=${last.result} from=${last.from} to=${last.to}`);
|
|
211
|
+
this.__logger.info?.(`[auto-upgrade] Last upgrade: ${last.from} → ${last.to} result=${last.result}`);
|
|
212
|
+
state.lastReport = last.ts;
|
|
213
|
+
const writeStateFn = this.__opts.writeStateFn ?? writeState;
|
|
214
|
+
await writeStateFn(state);
|
|
215
|
+
}
|
|
216
|
+
catch (err) {
|
|
217
|
+
this.__logger.warn?.(`[auto-upgrade] Report last upgrade result failed: ${err?.message}`);
|
|
218
|
+
remoteLog(`upgrade.report-failed msg=${err?.message}`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
197
222
|
/**
|
|
198
223
|
* 执行一次检查
|
|
199
224
|
*/
|
|
@@ -209,6 +234,9 @@ export class AutoUpgradeScheduler {
|
|
|
209
234
|
return;
|
|
210
235
|
}
|
|
211
236
|
|
|
237
|
+
// 报告上一次升级结果(若有未报告的)
|
|
238
|
+
await this.__reportLastUpgradeResult();
|
|
239
|
+
|
|
212
240
|
this.__logger.info?.('[auto-upgrade] Checking for updates...');
|
|
213
241
|
const result = await checkForUpdate({
|
|
214
242
|
execFileFn: this.__opts.execFileFn,
|
|
@@ -216,6 +244,7 @@ export class AutoUpgradeScheduler {
|
|
|
216
244
|
|
|
217
245
|
if (!result.available) {
|
|
218
246
|
if (result.skipped) {
|
|
247
|
+
remoteLog(`upgrade.skipped version=${result.latestVersion}`);
|
|
219
248
|
this.__logger.info?.(`[auto-upgrade] Version ${result.latestVersion} skipped (previously failed)`);
|
|
220
249
|
} else {
|
|
221
250
|
this.__logger.info?.(`[auto-upgrade] No update available (current: ${result.currentVersion})`);
|
package/src/realtime-bridge.js
CHANGED
|
@@ -951,6 +951,7 @@ export class RealtimeBridge {
|
|
|
951
951
|
const implLabel = preloadResult.impl === 'ndc' ? 'node-datachannel(ndc)' : preloadResult.impl;
|
|
952
952
|
this.logger.info?.(`[coclaw] WebRTC impl: ${implLabel}`);
|
|
953
953
|
remoteLog(`bridge.webrtc-impl impl=${implLabel}`);
|
|
954
|
+
remoteLog(`bridge.started version=${this.__pluginVersion}`);
|
|
954
955
|
await this.__connectIfNeeded();
|
|
955
956
|
}
|
|
956
957
|
|
|
@@ -110,7 +110,7 @@ export async function preloadNdc(deps = {}) {
|
|
|
110
110
|
const log = deps.remoteLog ?? defaultRemoteLog;
|
|
111
111
|
const platform = deps.platform ?? process.platform;
|
|
112
112
|
const arch = deps.arch ?? process.arch;
|
|
113
|
-
const pluginRoot = deps.pluginRoot ?? nodePath.resolve(import.meta.dirname, '
|
|
113
|
+
const pluginRoot = deps.pluginRoot ?? nodePath.resolve(import.meta.dirname, '../..');
|
|
114
114
|
const resolvePaths = deps.resolvePaths ?? defaultResolvePaths;
|
|
115
115
|
const importTimeout = deps.importTimeout ?? DEFAULT_IMPORT_TIMEOUT_MS;
|
|
116
116
|
|