Skip to content

Commit 900a834

Browse files
committed
refactor(daemon): remove stale launchd helpers
1 parent 9765f73 commit 900a834

3 files changed

Lines changed: 0 additions & 60 deletions

File tree

‎src/commands/doctor-gateway-daemon-flow.test.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ vi.mock("../daemon/launchd.js", async () => {
5858
await vi.importActual<typeof import("../daemon/launchd.js")>("../daemon/launchd.js");
5959
return {
6060
...actual,
61-
isLaunchAgentListed: vi.fn(async () => false),
6261
isLaunchAgentLoaded: vi.fn(async () => false),
6362
launchAgentPlistExists: vi.fn(async () => false),
6463
repairLaunchAgentBootstrap: vi.fn(async () => ({ ok: true, status: "repaired" })),

‎src/daemon/launchd.test.ts‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ import {
1414
disableCurrentOpenClawUpdateLaunchdJob,
1515
disableOpenClawUpdateLaunchdJob,
1616
findStaleOpenClawUpdateLaunchdJobs,
17-
isLaunchAgentListed,
18-
isOpenClawUpdateLaunchdLabel,
1917
parseLaunchctlPrint,
2018
parseLaunchctlListOpenClawUpdateJobs,
2119
readLaunchAgentProgramArguments,
2220
readLaunchAgentRuntime,
2321
repairLaunchAgentBootstrap,
24-
removeOpenClawUpdateLaunchdJob,
2522
restartLaunchAgent,
2623
resolveLaunchAgentPlistPath,
2724
stopLaunchAgent,
@@ -456,22 +453,6 @@ describe("launchd runtime state", () => {
456453
});
457454

458455
describe("launchctl list detection", () => {
459-
it("detects the resolved label in launchctl list", async () => {
460-
state.listOutput = "123 0 ai.openclaw.gateway\n";
461-
const listed = await isLaunchAgentListed({
462-
env: { HOME: "/Users/test", OPENCLAW_PROFILE: "default" },
463-
});
464-
expect(listed).toBe(true);
465-
});
466-
467-
it("returns false when the label is missing", async () => {
468-
state.listOutput = "123 0 com.other.service\n";
469-
const listed = await isLaunchAgentListed({
470-
env: { HOME: "/Users/test", OPENCLAW_PROFILE: "default" },
471-
});
472-
expect(listed).toBe(false);
473-
});
474-
475456
it("parses stale OpenClaw updater jobs from launchctl list", () => {
476457
const jobs = parseLaunchctlListOpenClawUpdateJobs(
477458
[
@@ -542,24 +523,6 @@ describe("launchctl list detection", () => {
542523
},
543524
);
544525

545-
it("recognizes only OpenClaw updater launchd labels", () => {
546-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.update.2026.5.12")).toBe(true);
547-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.manual-update.1717168800")).toBe(true);
548-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.gateway")).toBe(false);
549-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.manual-update.gateway")).toBe(false);
550-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.manual-update.profile")).toBe(false);
551-
expect(isOpenClawUpdateLaunchdLabel("ai.openclaw.manual-updater.1717168800")).toBe(false);
552-
expect(isOpenClawUpdateLaunchdLabel("com.example.update")).toBe(false);
553-
});
554-
555-
it.runIf(process.platform === "darwin")("removes legacy updater launchd jobs", async () => {
556-
await expect(removeOpenClawUpdateLaunchdJob(" ai.openclaw.update.2026.5.12 ")).resolves.toBe(
557-
true,
558-
);
559-
560-
expect(state.launchctlCalls).toContainEqual(["remove", "ai.openclaw.update.2026.5.12"]);
561-
});
562-
563526
it.runIf(process.platform === "darwin")(
564527
"disables the current legacy updater launchd job",
565528
async () => {

‎src/daemon/launchd.ts‎

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ function isCurrentGatewayLaunchdLabel(label: string, env: NodeJS.ProcessEnv): bo
8282
return Boolean(configuredLabel && label === configuredLabel);
8383
}
8484

85-
export function isOpenClawUpdateLaunchdLabel(label: unknown): label is string {
86-
return normalizeOpenClawUpdateLaunchdLabel(label) !== null;
87-
}
88-
8985
function resolveCurrentOpenClawUpdateLaunchdJobLabel(
9086
env: NodeJS.ProcessEnv = process.env,
9187
): string | null {
@@ -339,15 +335,6 @@ export async function findStaleOpenClawUpdateLaunchdJobs(
339335
);
340336
}
341337

342-
export async function removeOpenClawUpdateLaunchdJob(label: string): Promise<boolean> {
343-
const normalizedLabel = normalizeOpenClawUpdateLaunchdLabel(label);
344-
if (process.platform !== "darwin" || !normalizedLabel) {
345-
return false;
346-
}
347-
const result = await execLaunchctl(["remove", assertValidLaunchAgentLabel(normalizedLabel)]);
348-
return result.code === 0;
349-
}
350-
351338
export async function disableOpenClawUpdateLaunchdJob(label: string): Promise<boolean> {
352339
const normalizedLabel = normalizeOpenClawUpdateLaunchdLabel(label);
353340
if (process.platform !== "darwin" || !normalizedLabel) {
@@ -552,15 +539,6 @@ export async function isLaunchAgentLoaded(args: GatewayServiceEnvArgs): Promise<
552539
return res.code === 0;
553540
}
554541

555-
export async function isLaunchAgentListed(args: GatewayServiceEnvArgs): Promise<boolean> {
556-
const label = resolveLaunchAgentLabel({ env: args.env });
557-
const res = await execLaunchctl(["list"]);
558-
if (res.code !== 0) {
559-
return false;
560-
}
561-
return res.stdout.split(/\r?\n/).some((line) => line.trim().split(/\s+/).at(-1) === label);
562-
}
563-
564542
export async function launchAgentPlistExists(env: GatewayServiceEnv): Promise<boolean> {
565543
try {
566544
const plistPath = resolveLaunchAgentPlistPath(env);

0 commit comments

Comments
 (0)