mateclaw-openclaw-plugin 0.1.0 → 0.1.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/package.json +1 -1
- package/src/cli.mjs +30 -4
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -296,6 +296,11 @@ function countDoctorWarnings(checks) {
|
|
|
296
296
|
return checks.filter((item) => item.status === 'warn').length;
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
function hasOnlyGatewayHealthFailures(checks) {
|
|
300
|
+
const failures = checks.filter((item) => item.status === 'fail');
|
|
301
|
+
return failures.length > 0 && failures.every((item) => item.id === 'gateway-health');
|
|
302
|
+
}
|
|
303
|
+
|
|
299
304
|
async function isPortAvailable(port, host) {
|
|
300
305
|
return await new Promise((resolve) => {
|
|
301
306
|
const server = net.createServer();
|
|
@@ -404,7 +409,9 @@ async function startGatewayIfNeeded(openclawBin, openclawUrl) {
|
|
|
404
409
|
};
|
|
405
410
|
}
|
|
406
411
|
|
|
407
|
-
async function collectDoctorReport(options) {
|
|
412
|
+
async function collectDoctorReport(options, reportOptions = {}) {
|
|
413
|
+
const rawTimeout = Number.parseInt(`${reportOptions.gatewayHealthTimeoutMs ?? ''}`, 10);
|
|
414
|
+
const gatewayHealthTimeoutMs = Number.isFinite(rawTimeout) && rawTimeout > 0 ? rawTimeout : 8000;
|
|
408
415
|
const openclawBin = resolveOpenClawBin(options);
|
|
409
416
|
const configPath = resolveOpenClawConfigPath(options);
|
|
410
417
|
const openclawUrl = stripTrailingSlash(
|
|
@@ -429,7 +436,7 @@ async function collectDoctorReport(options) {
|
|
|
429
436
|
const versionResult = versionProbe.ok ? versionProbe : (fallbackVersionProbe || versionProbe);
|
|
430
437
|
|
|
431
438
|
const gatewayStatusResult = runOpenClawCommand(openclawBin, ['gateway', 'status', '--json'], 45000);
|
|
432
|
-
const gatewayHealth = await waitForGatewayHealthy(openclawUrl,
|
|
439
|
+
const gatewayHealth = await waitForGatewayHealthy(openclawUrl, gatewayHealthTimeoutMs);
|
|
433
440
|
|
|
434
441
|
const listenHost = options.host || process.env.MATECLAW_CONNECTOR_HOST || DEFAULT_LISTEN_HOST;
|
|
435
442
|
const preferredPort = parsePortOrDefault(
|
|
@@ -659,6 +666,7 @@ async function collectDoctorReport(options) {
|
|
|
659
666
|
configPath,
|
|
660
667
|
preferredPort,
|
|
661
668
|
listenHost,
|
|
669
|
+
gatewayHealthTimeoutMs,
|
|
662
670
|
};
|
|
663
671
|
}
|
|
664
672
|
|
|
@@ -976,10 +984,28 @@ async function runInstall(options) {
|
|
|
976
984
|
}
|
|
977
985
|
}
|
|
978
986
|
|
|
979
|
-
const after = await collectDoctorReport(installOptions
|
|
987
|
+
const after = await collectDoctorReport(installOptions, {
|
|
988
|
+
gatewayHealthTimeoutMs: 30000,
|
|
989
|
+
});
|
|
980
990
|
printDoctorReport(after, 'Post-fix Doctor');
|
|
981
991
|
|
|
982
|
-
|
|
992
|
+
let postFixFailures = countDoctorFailures(after.checks);
|
|
993
|
+
if (!dryRun && postFixFailures > 0 && hasOnlyGatewayHealthFailures(after.checks)) {
|
|
994
|
+
console.log('[WARN] Post-fix doctor only reports gateway health timeout, retrying with extended wait...');
|
|
995
|
+
const extendedProbe = await waitForGatewayHealthy(openclawUrl, 45000);
|
|
996
|
+
if (extendedProbe.ok) {
|
|
997
|
+
console.log('[PASS] Gateway health recovered after extended wait. Continuing install.');
|
|
998
|
+
postFixFailures = 0;
|
|
999
|
+
} else {
|
|
1000
|
+
const statusProbe = runOpenClawCommand(openclawBin, ['gateway', 'status', '--json'], 45000);
|
|
1001
|
+
if (statusProbe.ok) {
|
|
1002
|
+
console.log('[WARN] Gateway status is healthy but /health probe is still slow. Continuing install.');
|
|
1003
|
+
postFixFailures = 0;
|
|
1004
|
+
} else {
|
|
1005
|
+
console.log(`[WARN] Extended gateway probe failed: ${extendedProbe.detail}`);
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
983
1009
|
if (postFixFailures > 0) {
|
|
984
1010
|
if (dryRun) {
|
|
985
1011
|
console.log('[WARN] Dry-run detected blocking failures after auto-fix. Fix them before real install.');
|