@lark-apaas/openclaw-scripts-diagnose-cli 0.1.1-alpha.31 → 0.1.1-alpha.32
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.cjs +34 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -869,12 +869,17 @@ let GatewayRule = class GatewayRule extends DiagnoseRule {
|
|
|
869
869
|
_GatewayRule = this;
|
|
870
870
|
}
|
|
871
871
|
static DEFAULT_PORT = 18789;
|
|
872
|
+
static DEFAULT_MODE = "local";
|
|
873
|
+
static DEFAULT_BIND = "loopback";
|
|
872
874
|
static DEFAULT_AUTH_MODE = "token";
|
|
873
875
|
static DEFAULT_AUTH_TOKEN = {
|
|
874
876
|
source: "file",
|
|
875
877
|
provider: "miaoda-secret-provider",
|
|
876
878
|
id: "/gateway_auth_token"
|
|
877
879
|
};
|
|
880
|
+
/** Required entries in gateway.trustedProxies. Repair appends any missing
|
|
881
|
+
* entries while preserving caller-added extras (no overwrite). */
|
|
882
|
+
static DEFAULT_TRUSTED_PROXIES = ["::1", "127.0.0.1"];
|
|
878
883
|
validate(ctx) {
|
|
879
884
|
const gateway = ctx.config.gateway;
|
|
880
885
|
if (!gateway || typeof gateway !== "object") return {
|
|
@@ -886,6 +891,14 @@ let GatewayRule = class GatewayRule extends DiagnoseRule {
|
|
|
886
891
|
pass: false,
|
|
887
892
|
message: "gateway.port mismatch: got " + gw.port + ", expected " + _GatewayRule.DEFAULT_PORT
|
|
888
893
|
};
|
|
894
|
+
if (gw.mode !== _GatewayRule.DEFAULT_MODE) return {
|
|
895
|
+
pass: false,
|
|
896
|
+
message: "gateway.mode mismatch: got " + gw.mode + ", expected " + _GatewayRule.DEFAULT_MODE
|
|
897
|
+
};
|
|
898
|
+
if (gw.bind !== _GatewayRule.DEFAULT_BIND) return {
|
|
899
|
+
pass: false,
|
|
900
|
+
message: "gateway.bind mismatch: got " + gw.bind + ", expected " + _GatewayRule.DEFAULT_BIND
|
|
901
|
+
};
|
|
889
902
|
const auth = gw.auth;
|
|
890
903
|
if (!auth || typeof auth !== "object") return {
|
|
891
904
|
pass: false,
|
|
@@ -920,10 +933,22 @@ let GatewayRule = class GatewayRule extends DiagnoseRule {
|
|
|
920
933
|
pass: false,
|
|
921
934
|
message: "gateway.controlUi.dangerouslyDisableDeviceAuth must be true, got " + controlUi.dangerouslyDisableDeviceAuth
|
|
922
935
|
};
|
|
936
|
+
const proxies = gw.trustedProxies;
|
|
937
|
+
if (!Array.isArray(proxies)) return {
|
|
938
|
+
pass: false,
|
|
939
|
+
message: "gateway.trustedProxies missing or not an array"
|
|
940
|
+
};
|
|
941
|
+
const missing = _GatewayRule.DEFAULT_TRUSTED_PROXIES.filter((p) => !proxies.includes(p));
|
|
942
|
+
if (missing.length > 0) return {
|
|
943
|
+
pass: false,
|
|
944
|
+
message: "gateway.trustedProxies missing: " + JSON.stringify(missing)
|
|
945
|
+
};
|
|
923
946
|
return { pass: true };
|
|
924
947
|
}
|
|
925
948
|
repair(ctx) {
|
|
926
949
|
setNestedValue(ctx.config, ["gateway", "port"], _GatewayRule.DEFAULT_PORT);
|
|
950
|
+
setNestedValue(ctx.config, ["gateway", "mode"], _GatewayRule.DEFAULT_MODE);
|
|
951
|
+
setNestedValue(ctx.config, ["gateway", "bind"], _GatewayRule.DEFAULT_BIND);
|
|
927
952
|
setNestedValue(ctx.config, [
|
|
928
953
|
"gateway",
|
|
929
954
|
"auth",
|
|
@@ -939,6 +964,14 @@ let GatewayRule = class GatewayRule extends DiagnoseRule {
|
|
|
939
964
|
"controlUi",
|
|
940
965
|
"dangerouslyDisableDeviceAuth"
|
|
941
966
|
], true);
|
|
967
|
+
const gw = ctx.config.gateway ?? {};
|
|
968
|
+
const current = Array.isArray(gw.trustedProxies) ? gw.trustedProxies.slice() : [];
|
|
969
|
+
const seen = new Set(current.map((v) => String(v)));
|
|
970
|
+
for (const p of _GatewayRule.DEFAULT_TRUSTED_PROXIES) if (!seen.has(p)) {
|
|
971
|
+
current.push(p);
|
|
972
|
+
seen.add(p);
|
|
973
|
+
}
|
|
974
|
+
setNestedValue(ctx.config, ["gateway", "trustedProxies"], current);
|
|
942
975
|
}
|
|
943
976
|
};
|
|
944
977
|
GatewayRule = _GatewayRule = __decorate([Rule({
|
|
@@ -2762,7 +2795,7 @@ async function runDoctor(rawCtx, opts) {
|
|
|
2762
2795
|
//#region src/help.ts
|
|
2763
2796
|
const BIN = "mclaw-diagnose";
|
|
2764
2797
|
function versionBanner() {
|
|
2765
|
-
return `v0.1.1-alpha.
|
|
2798
|
+
return `v0.1.1-alpha.32`;
|
|
2766
2799
|
}
|
|
2767
2800
|
const COMMANDS = [
|
|
2768
2801
|
{
|
package/package.json
CHANGED