refactor: remove mac attach-only setting

This commit is contained in:
Peter Steinberger
2026-01-12 04:38:42 +00:00
parent 8e1cdf3a1f
commit 51d5f16770
15 changed files with 18 additions and 126 deletions

View File

@@ -133,30 +133,10 @@ function noteOpencodeProviderOverrides(cfg: ClawdbotConfig) {
note(lines.join("\n"), "OpenCode Zen");
}
const MAC_APP_BUNDLE_ID = "com.clawdbot.mac";
const MAC_ATTACH_EXISTING_ONLY_KEY = "clawdbot.gateway.attachExistingOnly";
function resolveHomeDir(): string {
return process.env.HOME ?? os.homedir();
}
async function readMacAttachExistingOnly(): Promise<boolean | null> {
const result = await runCommandWithTimeout(
[
"/usr/bin/defaults",
"read",
MAC_APP_BUNDLE_ID,
MAC_ATTACH_EXISTING_ONLY_KEY,
],
{ timeoutMs: 2000 },
).catch(() => null);
if (!result || result.code !== 0) return null;
const raw = result.stdout.trim().toLowerCase();
if (["1", "true", "yes"].includes(raw)) return true;
if (["0", "false", "no"].includes(raw)) return false;
return null;
}
async function noteMacLaunchAgentOverrides() {
if (process.platform !== "darwin") return;
const markerPath = path.join(
@@ -165,17 +145,12 @@ async function noteMacLaunchAgentOverrides() {
"disable-launchagent",
);
const hasMarker = fs.existsSync(markerPath);
const attachOnly = await readMacAttachExistingOnly();
if (!hasMarker && attachOnly !== true) return;
if (!hasMarker) return;
const lines = [
hasMarker ? `- LaunchAgent writes are disabled via ${markerPath}.` : null,
attachOnly === true
? `- macOS app is set to Attach-only (${MAC_APP_BUNDLE_ID}:${MAC_ATTACH_EXISTING_ONLY_KEY}=true).`
: null,
`- LaunchAgent writes are disabled via ${markerPath}.`,
"- To restore default behavior:",
` rm ${markerPath}`,
` defaults write ${MAC_APP_BUNDLE_ID} ${MAC_ATTACH_EXISTING_ONLY_KEY} -bool NO`,
].filter((line): line is string => Boolean(line));
note(lines.join("\n"), "Gateway (macOS)");
}