



















@@ -110,6 +110,9 @@ vi.mock("./doctor-gateway-auth-token.js", () => ({
110110}));
111111112112import {
113+detectExtraGatewayServiceIssues,
114+extraGatewayServiceToHealthFinding,
115+extraGatewayServiceToRepairEffects,
113116maybeRepairGatewayServiceConfig,
114117maybeScanExtraGatewayServices,
115118} from "./doctor-gateway-services.js";
@@ -576,13 +579,14 @@ describe("maybeRepairGatewayServiceConfig", () => {
576579installEntrypoint:
577580"/Users/test/Library/pnpm/global/5/node_modules/.pnpm/openclaw@2026.3.12/node_modules/openclaw/dist/index.js",
578581realpath: async (value: string) => {
579-if (value.includes("/global/5/node_modules/openclaw/")) {
580-return value.replace(
582+const normalized = value.replaceAll("\\", "/").replace(/^[A-Z]:/i, "");
583+if (normalized.includes("/global/5/node_modules/openclaw/")) {
584+return normalized.replace(
581585"/global/5/node_modules/openclaw/",
582586"/global/5/node_modules/.pnpm/openclaw@2026.3.12/node_modules/openclaw/",
583587);
584588}
585-return value;
589+return normalized;
586590},
587591});
588592@@ -1189,6 +1193,83 @@ describe("maybeScanExtraGatewayServices", () => {
11891193expectNoteContaining("custom-gateway.service", "Other gateway-like services detected");
11901194});
119111951196+it("threads deep scans through structured extra gateway service detection", async () => {
1197+mocks.findExtraGatewayServices.mockResolvedValue([]);
1198+1199+await detectExtraGatewayServiceIssues({ deep: true });
1200+1201+expect(mocks.findExtraGatewayServices).toHaveBeenCalledWith(process.env, { deep: true });
1202+});
1203+1204+it("maps intentional extra gateway services to informational structured findings", () => {
1205+expect(
1206+extraGatewayServiceToHealthFinding({
1207+platform: "linux",
1208+label: "custom-gateway.service",
1209+detail: "unit: /etc/systemd/system/custom-gateway.service",
1210+scope: "system",
1211+legacy: false,
1212+}),
1213+).toEqual(
1214+expect.objectContaining({
1215+checkId: "core/doctor/gateway-services/extra",
1216+severity: "info",
1217+source: "linux",
1218+target: "custom-gateway.service",
1219+}),
1220+);
1221+});
1222+1223+it("keeps legacy gateway services warning-level", () => {
1224+expect(
1225+extraGatewayServiceToHealthFinding({
1226+platform: "linux",
1227+label: "openclaw-gateway.service",
1228+detail: "legacy unit",
1229+scope: "user",
1230+legacy: true,
1231+}),
1232+).toEqual(
1233+expect.objectContaining({
1234+checkId: "core/doctor/gateway-services/extra",
1235+severity: "warning",
1236+source: "linux",
1237+target: "openclaw-gateway.service",
1238+}),
1239+);
1240+});
1241+1242+it("maps legacy gateway services to dry-run cleanup effects", () => {
1243+expect(
1244+extraGatewayServiceToRepairEffects({
1245+platform: "linux",
1246+label: "clawdbot-gateway.service",
1247+detail: "unit: /home/test/.config/systemd/user/clawdbot-gateway.service",
1248+scope: "user",
1249+legacy: true,
1250+}),
1251+).toEqual([
1252+{
1253+kind: "service",
1254+action: "would-remove-legacy-gateway-service",
1255+target: "clawdbot-gateway.service",
1256+dryRunSafe: false,
1257+},
1258+]);
1259+});
1260+1261+it("does not report cleanup effects for intentional extra gateway services", () => {
1262+expect(
1263+extraGatewayServiceToRepairEffects({
1264+platform: "linux",
1265+label: "custom-gateway.service",
1266+detail: "unit: /etc/systemd/system/custom-gateway.service",
1267+scope: "system",
1268+legacy: false,
1269+}),
1270+).toEqual([]);
1271+});
1272+11921273it("removes legacy Linux user systemd services", async () => {
11931274mockProcessPlatform("linux");
11941275mocks.findExtraGatewayServices.mockResolvedValue([
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。