




















@@ -1,6 +1,9 @@
11import { describe, expect, it, vi } from "vitest";
22import type { OpenClawConfig } from "../config/config.js";
33import {
4+collectMacLaunchAgentOverrideWarning,
5+collectMacLaunchctlGatewayEnvOverrideWarning,
6+collectMacStaleOpenClawUpdateLaunchdJobsWarning,
47noteMacLaunchctlGatewayEnvOverrides,
58noteMacStaleOpenClawUpdateLaunchdJobs,
69} from "./doctor-platform-notes.js";
@@ -14,6 +17,29 @@ function requireNoteCall(noteFn: { mock: { calls: unknown[][] } }, index = 0): u
1417}
15181619describe("noteMacLaunchctlGatewayEnvOverrides", () => {
20+it("collects clear unsetenv instructions for token override", async () => {
21+const getenv = vi.fn(async (name: string) =>
22+name === "OPENCLAW_GATEWAY_TOKEN" ? "launchctl-token" : undefined,
23+);
24+const cfg = {
25+gateway: {
26+auth: {
27+token: "config-token",
28+},
29+},
30+} as OpenClawConfig;
31+32+const warning = await collectMacLaunchctlGatewayEnvOverrideWarning(cfg, {
33+platform: "darwin",
34+ getenv,
35+});
36+37+expect(warning).toContain("Host-wide launchctl gateway auth overrides detected");
38+expect(warning).toContain("OPENCLAW_GATEWAY_TOKEN");
39+expect(warning).toContain("launchctl unsetenv OPENCLAW_GATEWAY_TOKEN");
40+expect(warning).not.toContain("OPENCLAW_GATEWAY_PASSWORD");
41+});
42+1743it("prints clear unsetenv instructions for token override", async () => {
1844const noteFn = vi.fn();
1945const getenv = vi.fn(async (name: string) =>
@@ -96,6 +122,26 @@ describe("noteMacLaunchctlGatewayEnvOverrides", () => {
96122});
9712398124describe("noteMacStaleOpenClawUpdateLaunchdJobs", () => {
125+it("collects stale updater job cleanup guidance on macOS", async () => {
126+const findJobs = vi.fn(async () => [
127+{
128+label: "ai.openclaw.update.2026.5.12",
129+lastExitStatus: 127,
130+},
131+]);
132+133+const warning = await collectMacStaleOpenClawUpdateLaunchdJobsWarning({
134+platform: "darwin",
135+ findJobs,
136+});
137+138+expect(findJobs).toHaveBeenCalledTimes(1);
139+expect(warning).toContain("Stale OpenClaw updater launchd job(s) detected");
140+expect(warning).toContain("ai.openclaw.update.2026.5.12");
141+expect(warning).toContain("launchctl remove <label>");
142+expect(warning).toContain("openclaw gateway restart");
143+});
144+99145it("prints stale updater job cleanup guidance on macOS", async () => {
100146const noteFn = vi.fn();
101147const findJobs = vi.fn(async () => [
@@ -133,3 +179,27 @@ describe("noteMacStaleOpenClawUpdateLaunchdJobs", () => {
133179expect(noteFn).not.toHaveBeenCalled();
134180});
135181});
182+183+describe("collectMacLaunchAgentOverrideWarning", () => {
184+it("collects guidance when launch agent writes are disabled", () => {
185+const warning = collectMacLaunchAgentOverrideWarning({
186+platform: "darwin",
187+homeDir: "/Users/tester",
188+exists: (candidate) => candidate.includes("disable-launchagent"),
189+});
190+191+expect(warning).toContain("LaunchAgent writes are disabled");
192+expect(warning).toContain("rm ");
193+expect(warning).toContain("disable-launchagent");
194+});
195+196+it("does nothing when launch agent writes are not disabled", () => {
197+expect(
198+collectMacLaunchAgentOverrideWarning({
199+platform: "darwin",
200+homeDir: "/Users/tester",
201+exists: () => false,
202+}),
203+).toBeNull();
204+});
205+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。