Launchagent Manager
Description
List, classify, prune LaunchAgents; analyze openclaw.json so the proper gateway LaunchAgent remains connected and tokens match. Keeps only OpenClaw-related agents; can unload/delete others.
LaunchAgent Manager
Manages LaunchAgents in ~/Library/LaunchAgents and analyzes openclaw.json so the gateway LaunchAgent stays correct: loaded when it should be, and tokens matching config vs running gateway.
- - List/prune: Classify agents as OpenClaw (keep) or other (prune). OpenClaw = Label or path contains "openclaw".
- Config check: Read
openclaw.json → gateway port, auth mode, token set; find the gateway plist (e.g. ai.openclaw.gateway); report loaded? running? tokens match? (Uses gateway-guard status when available.) Recommends loading the plist or running gateway-guard ensure --apply if needed. - --fix: With --config, can load the gateway plist if not loaded and run gateway-guard ensure --apply if tokens mismatch.
Usage
- - Ensure gateway stays connected: Run
--config to verify the gateway LaunchAgent is loaded and tokens match; use --config --fix to load plist and sync auth. - List what's running: see OpenClaw vs other agents.
- Remove non-OpenClaw LaunchAgents: prune so only OpenClaw daemons remain.
CODEBLOCK0
- - --list (default) — List all LaunchAgents; show OpenClaw (kept) vs others (prune targets). Shows loaded/unloaded.
- --config — Analyze openclaw.json and gateway LaunchAgent: config path, gateway port, auth, token set; gateway plist label and loaded?; gateway process running?; tokens match (config vs running)? Recommendations if plist not loaded or tokens mismatch. Exit 0 if all ok, 1 if action needed.
- --config --fix — If gateway plist not loaded: run
launchctl load <plist>. If tokens don't match: run gateway-guard ensure --apply --json. Requires gateway-guard skill. - --config --json — Machine-readable report: configpath, gateway, gatewaylaunchagent, gatewayloaded, tokensmatch, gatewayrunning, recommendations.
- --json — For --list:
{ "openclaw": [...], "others": [...] }. - --prune — Operate on non-OpenClaw agents. Without --apply this is a dry-run (show what would be unloaded).
- --prune --dry-run — Only show what would be unloaded.
- --prune --apply — Unload each non-OpenClaw LaunchAgent. Plist files kept unless --delete-plists.
- --prune --apply --delete-plists — Unload and delete plist files (backed up to OPENCLAWHOME/backups/launchagents).
Safety
- - Only user domain is touched:
~/Library/LaunchAgents/. System domain is not modified. - OpenClaw detection is conservative: Label
com.openclaw.* or any ProgramArgument containing "openclaw" → kept. - With --delete-plists, backups are written to
OPENCLAW_HOME/backups/launchagents/ before deletion.
Requirements
- - macOS (launchctl, plist in user LaunchAgents).
- Python 3 with plistlib (standard library).
LaunchAgent 管理器
描述
列出、分类、清理LaunchAgent;分析openclaw.json以确保正确的网关LaunchAgent保持连接且令牌匹配。仅保留与OpenClaw相关的代理;可卸载/删除其他代理。
LaunchAgent 管理器
管理 ~/Library/LaunchAgents 中的LaunchAgent,并分析 openclaw.json,确保 网关LaunchAgent 保持正确状态:在需要时加载,且令牌与配置和运行中的网关匹配。
- - 列出/清理: 将代理分类为OpenClaw(保留)或其他(清理)。OpenClaw = 标签或路径包含openclaw。
- 配置检查: 读取 openclaw.json → 网关端口、认证模式、令牌集;查找网关plist(例如 ai.openclaw.gateway);报告是否已加载?是否正在运行?令牌是否匹配?(可用时使用gateway-guard状态。)建议加载plist或运行gateway-guard ensure --apply(如需要)。
- --fix: 配合 --config,可在网关plist未加载时加载它,并在令牌不匹配时运行gateway-guard ensure --apply。
用法
- - 确保网关保持连接: 运行 --config 验证网关LaunchAgent已加载且令牌匹配;使用 --config --fix 加载plist并同步认证。
- 列出正在运行的内容:查看OpenClaw与其他代理。
- 移除非OpenClaw的LaunchAgent:清理后仅保留OpenClaw守护进程。
bash
python3 /scripts/launchagent_manager.py [--list] [--json]
python3 /scripts/launchagent_manager.py --config [--fix] [--json]
python3 /scripts/launchagent_manager.py --prune [--dry-run]
python3 /scripts/launchagent_manager.py --prune --apply [--delete-plists]
- - --list(默认)— 列出所有LaunchAgent;显示OpenClaw(保留)与其他(清理目标)。显示已加载/未加载状态。
- --config — 分析openclaw.json和网关LaunchAgent:配置路径、网关端口、认证、令牌集;网关plist标签及是否已加载;网关进程是否运行;令牌是否匹配(配置 vs 运行中)?如果plist未加载或令牌不匹配则给出建议。一切正常时退出码为0,需要操作时退出码为1。
- --config --fix — 如果网关plist未加载:运行 launchctl load 。如果令牌不匹配:运行gateway-guard ensure --apply --json。需要gateway-guard技能。
- --config --json — 机器可读报告:configpath、gateway、gatewaylaunchagent、gatewayloaded、tokensmatch、gatewayrunning、recommendations。
- --json — 用于 --list:{ openclaw: [...], others: [...] }。
- --prune — 对非OpenClaw代理进行操作。不带 --apply 时为试运行(显示将被卸载的内容)。
- --prune --dry-run — 仅显示将被卸载的内容。
- --prune --apply — 卸载每个非OpenClaw的LaunchAgent。除非使用 --delete-plists,否则保留plist文件。
- --prune --apply --delete-plists — 卸载并删除plist文件(备份到 OPENCLAWHOME/backups/launchagents)。
安全性
- - 仅操作用户域:~/Library/LaunchAgents/。不修改系统域。
- OpenClaw检测较为保守:标签 com.openclaw.* 或任何包含openclaw的ProgramArgument → 保留。
- 使用 --delete-plists 时,删除前会将备份写入 OPENCLAW_HOME/backups/launchagents/。
要求
- - macOS(launchctl,用户LaunchAgents中的plist)。
- Python 3及plistlib(标准库)。