返回顶部
s

swarm-janitor集群清理

Enterprise-grade OpenClaw skill for cleaning up orphaned subagent processes, archiving transcripts to SuperMemory, and freeing disk space without losing work. Features dry-run mode, configurable retention policies, and comprehensive safety checks.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 0.1.0
安全检测
已通过
1,274
下载量
免费
免费
2
收藏
概述
安装方式
版本历史

swarm-janitor

Swarm Janitor

面向OpenClaw子代理管理的企业级清理工具。

功能概述

自动识别并清理孤立子代理会话,同时通过SuperMemory归档保留重要工作。

核心功能

  • - 扫描:分析会话目录中的孤立/遗弃子代理
  • 归档:删除前将记录保存至SuperMemory
  • 清理:安全移除孤立会话以释放磁盘空间
  • 报告:生成详细的清理报告

安全优先

本工具实现多层安全机制:

  • - ✅ 绝不删除活跃会话 — 检查进程状态
  • 试运行模式 — 执行前预览变更
  • SuperMemory备份 — 删除前归档记录
  • 可配置保留策略 — 自定义时间阈值
  • 详细日志记录 — 完整操作审计追踪

快速开始

bash

预览待清理内容(试运行)


python3 scripts/swarm_janitor.py --dry-run

将旧会话归档至SuperMemory后清理

python3 scripts/swarm_janitor.py --archive --clean

自定义保留期限(7天替代默认3天)

python3 scripts/swarm_janitor.py --retention-days 7 --clean

安装指南

  1. 1. 将本工具复制到OpenClaw工作区:
bash cp -r skills/swarm-janitor ~/.openclaw/workspace/skills/
  1. 2. 配置保留策略(可选):
bash # 编辑配置文件自定义设置 nano references/config.yaml
  1. 3. 执行首次扫描:
bash python3 ~/.openclaw/workspace/skills/swarm-janitor/scripts/swarm_janitor.py --dry-run

使用模式

日常维护(Cron定时任务)

cron

每天凌晨3点运行,归档超过3天的会话


0 3 * python3 ~/.openclaw/workspace/skills/swarm-janitor/scripts/swarm_janitor.py --archive --clean --retention-days 3 >> /var/log/swarm-janitor.log 2>&1

手动清理

bash

查看将被删除的内容


python3 scripts/swarm_janitor.py --dry-run --verbose

将记录归档至SuperMemory

python3 scripts/swarm_janitor.py --archive

不归档直接清理(不推荐)

python3 scripts/swarm_janitor.py --clean --no-archive

生成完整报告

python3 scripts/swarm_janitor.py --report --output json

紧急清理

bash

激进清理,保留期限设为1天


python3 scripts/swarm_janitor.py --clean --retention-days 1 --force

配置说明

详见 references/config.yaml

  • - 保留策略
  • 归档目标
  • 安全阈值
  • 日志选项

工作原理

  1. 1. 发现:扫描 ~/.openclaw/agents/main/sessions/
  2. 分析:判断会话时长、活动状态、大小
  3. 分类:识别孤立会话与活跃会话
  4. 归档:将记录保存至SuperMemory(如启用)
  5. 清理:安全移除孤立会话文件
  6. 报告:生成操作摘要

安全机制

检查项说明
进程检查验证无活跃进程占用会话
时长验证
仅处理超过阈值的会话 | | 大小限制 | 对异常大文件删除发出警告 | | 默认试运行 | 预览模式为默认设置,需显式确认操作 | | 先备份后删除 | 删除前先归档至SuperMemory |

故障排除

问:提示权限不足
答:确保您对会话目录拥有写入权限

问:无法检测到会话
答:检查config.yaml中的路径是否与您的OpenClaw安装目录匹配

问:SuperMemory归档失败
答:确认SuperMemory工具已配置有效的API密钥

企业级特性

  • - 审计日志:所有操作均记录时间戳
  • 可配置策略:基于YAML的配置管理
  • 指标导出:支持JSON/CSV格式输出用于监控
  • 试运行模式:应用前测试变更效果
  • 保留策略:基于时长和数量的规则

许可证

MIT - 由OpenClawdad (Redclay) 为OpenClaw社区创建

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 swarm-janitor-1776356703 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 swarm-janitor-1776356703 技能

通过命令行安装

skillhub install swarm-janitor-1776356703

下载

⬇ 下载 swarm-janitor v0.1.0(免费)

文件大小: 3.3 KB | 发布时间: 2026-4-17 15:37

v0.1.0 最新 2026-4-17 15:37
Initial release of swarm-janitor.

- Automatically scans and cleans up orphaned OpenClaw subagent sessions.
- Safely archives transcripts to SuperMemory before deletion.
- Features dry-run mode, configurable retention policies, and robust safety checks.
- Generates detailed cleanup reports and logs all actions for auditability.
- Supports enterprise needs with flexible configuration, metrics export, and cron-based automation.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部