squad-openclaw 2026.2.2014 → 2026.2.2017
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/dist/index.js +71 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1234,6 +1234,46 @@ var updateInProgress = false;
|
|
|
1234
1234
|
var VERIFY_TIMEOUT_MS = 2e4;
|
|
1235
1235
|
var VERIFY_INTERVAL_MS = 500;
|
|
1236
1236
|
var RESTART_BUFFER_MS = 5e3;
|
|
1237
|
+
function readInstalledVersionFromConfig() {
|
|
1238
|
+
try {
|
|
1239
|
+
const raw = fs5.readFileSync(CONFIG_PATH, "utf-8");
|
|
1240
|
+
const cfg = JSON.parse(raw);
|
|
1241
|
+
const v = cfg?.plugins?.installs?.[PACKAGE_NAME]?.version;
|
|
1242
|
+
return typeof v === "string" ? v : null;
|
|
1243
|
+
} catch {
|
|
1244
|
+
return null;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
function reconcileInstallMetadata(verification) {
|
|
1248
|
+
if (!verification.installPath || !verification.packageVersion) return;
|
|
1249
|
+
try {
|
|
1250
|
+
const raw = fs5.readFileSync(CONFIG_PATH, "utf-8");
|
|
1251
|
+
const config = JSON.parse(raw);
|
|
1252
|
+
if (!config.plugins || typeof config.plugins !== "object") config.plugins = {};
|
|
1253
|
+
if (!config.plugins.installs || typeof config.plugins.installs !== "object") {
|
|
1254
|
+
config.plugins.installs = {};
|
|
1255
|
+
}
|
|
1256
|
+
if (!config.plugins.entries || typeof config.plugins.entries !== "object") {
|
|
1257
|
+
config.plugins.entries = {};
|
|
1258
|
+
}
|
|
1259
|
+
const current = config.plugins.installs[PACKAGE_NAME] ?? {};
|
|
1260
|
+
config.plugins.installs[PACKAGE_NAME] = {
|
|
1261
|
+
...current,
|
|
1262
|
+
source: "npm",
|
|
1263
|
+
spec: PACKAGE_NAME,
|
|
1264
|
+
installPath: verification.installPath,
|
|
1265
|
+
version: verification.packageVersion,
|
|
1266
|
+
installedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
1267
|
+
};
|
|
1268
|
+
const entry = config.plugins.entries[PACKAGE_NAME] ?? {};
|
|
1269
|
+
config.plugins.entries[PACKAGE_NAME] = {
|
|
1270
|
+
...entry,
|
|
1271
|
+
enabled: true
|
|
1272
|
+
};
|
|
1273
|
+
fs5.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), "utf-8");
|
|
1274
|
+
} catch {
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1237
1277
|
function getCurrentVersion() {
|
|
1238
1278
|
const thisFile = fileURLToPath(import.meta.url);
|
|
1239
1279
|
const pkgPath = path6.resolve(path6.dirname(thisFile), "..", "package.json");
|
|
@@ -1270,6 +1310,16 @@ function runDoctorFixSilently() {
|
|
|
1270
1310
|
function sleep(ms) {
|
|
1271
1311
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1272
1312
|
}
|
|
1313
|
+
function compareVersions(a, b) {
|
|
1314
|
+
const pa = a.split(".").map((x) => Number(x) || 0);
|
|
1315
|
+
const pb = b.split(".").map((x) => Number(x) || 0);
|
|
1316
|
+
const len = Math.max(pa.length, pb.length);
|
|
1317
|
+
for (let i = 0; i < len; i++) {
|
|
1318
|
+
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
|
1319
|
+
if (d !== 0) return d;
|
|
1320
|
+
}
|
|
1321
|
+
return 0;
|
|
1322
|
+
}
|
|
1273
1323
|
function verifyInstalledPluginState() {
|
|
1274
1324
|
let configRaw;
|
|
1275
1325
|
try {
|
|
@@ -1370,16 +1420,6 @@ function verifyInstalledPluginState() {
|
|
|
1370
1420
|
requiredFilesMissing: []
|
|
1371
1421
|
};
|
|
1372
1422
|
}
|
|
1373
|
-
if (configVersion && configVersion !== packageVersion) {
|
|
1374
|
-
return {
|
|
1375
|
-
ok: false,
|
|
1376
|
-
reason: `Version mismatch: config=${configVersion}, package=${packageVersion}`,
|
|
1377
|
-
installPath,
|
|
1378
|
-
configVersion,
|
|
1379
|
-
packageVersion,
|
|
1380
|
-
requiredFilesMissing: []
|
|
1381
|
-
};
|
|
1382
|
-
}
|
|
1383
1423
|
return {
|
|
1384
1424
|
ok: true,
|
|
1385
1425
|
installPath,
|
|
@@ -1436,6 +1476,13 @@ function registerVersionMethods(api) {
|
|
|
1436
1476
|
updateInProgress = true;
|
|
1437
1477
|
try {
|
|
1438
1478
|
const before = getCurrentVersion();
|
|
1479
|
+
const beforeInstalledVersion = readInstalledVersionFromConfig();
|
|
1480
|
+
let latestVersion = null;
|
|
1481
|
+
try {
|
|
1482
|
+
latestVersion = await fetchLatestVersion();
|
|
1483
|
+
} catch {
|
|
1484
|
+
latestVersion = null;
|
|
1485
|
+
}
|
|
1439
1486
|
let updateOutput = "";
|
|
1440
1487
|
let configBackup = null;
|
|
1441
1488
|
try {
|
|
@@ -1487,6 +1534,18 @@ function registerVersionMethods(api) {
|
|
|
1487
1534
|
});
|
|
1488
1535
|
return;
|
|
1489
1536
|
}
|
|
1537
|
+
reconcileInstallMetadata(verification);
|
|
1538
|
+
const verificationAfterReconcile = verifyInstalledPluginState();
|
|
1539
|
+
if (beforeInstalledVersion && verificationAfterReconcile.packageVersion && beforeInstalledVersion === verificationAfterReconcile.packageVersion) {
|
|
1540
|
+
const alreadyLatest = !!latestVersion && compareVersions(verificationAfterReconcile.packageVersion, latestVersion) >= 0;
|
|
1541
|
+
respond(false, {
|
|
1542
|
+
error: alreadyLatest ? `Already at latest version (${verificationAfterReconcile.packageVersion}).` : `Update command completed but installed version did not change (${verificationAfterReconcile.packageVersion}).`,
|
|
1543
|
+
output: updateOutput.slice(0, 500),
|
|
1544
|
+
verification: verificationAfterReconcile,
|
|
1545
|
+
latestVersion
|
|
1546
|
+
});
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1490
1549
|
const after = getCurrentVersion();
|
|
1491
1550
|
respond(true, {
|
|
1492
1551
|
previousVersion: before,
|
|
@@ -1494,7 +1553,8 @@ function registerVersionMethods(api) {
|
|
|
1494
1553
|
updated: true,
|
|
1495
1554
|
restartRequired: true,
|
|
1496
1555
|
restartInMs: RESTART_BUFFER_MS,
|
|
1497
|
-
verification,
|
|
1556
|
+
verification: verificationAfterReconcile,
|
|
1557
|
+
latestVersion,
|
|
1498
1558
|
output: updateOutput.slice(0, 500)
|
|
1499
1559
|
});
|
|
1500
1560
|
await sleep(RESTART_BUFFER_MS);
|
package/package.json
CHANGED