← 返回 Skills 市场
kuangzhanzhiwang

Dreaming Guard Pro

作者 kuangzhanzhiwang · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
106
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install dreaming-guard-pro
功能描述
Smart prevention and auto-recovery for OpenClaw dreaming context overflow. Monitors growth trends, archives intelligently, compresses context, protects proce...
使用说明 (SKILL.md)

Dreaming Guard Pro

防止OpenClaw dreaming文件无限积累导致OOM崩溃的智能保护系统

触发词

  • dreaming
  • context overflow
  • OOM
  • crash recovery
  • memory protection
  • dreaming guard
  • 健康报告

功能描述

Dreaming Guard Pro 是一个智能保护系统,用于:

  1. 实时监控 - 监控dreaming文件增长趋势和内存使用
  2. 智能归档 - 三级归档策略(hot/warm/cold),保留有价值数据
  3. 自动压缩 - 三级压缩策略(lossless/lossy/aggressive),减少空间占用
  4. 进程保护 - 内存阈值分级保护,危险时主动干预
  5. 崩溃自愈 - 自动检测崩溃并恢复到最近健康状态
  6. 健康报告 - 定期生成可视化状态报告

安装

作为ClawHub Skill安装

cd ~/.openclaw/skills
mkdir dreaming-guard
cp -r /root/.openclaw/workspace/projects/dreaming-guard-pro/* dreaming-guard/

手动安装

cd projects/dreaming-guard-pro
npm install  # 无需外部依赖,纯Node.js实现

使用方式

作为Skill使用

在对话中使用触发词即可激活:

用户: 检查dreaming状态
助手: [调用Dreaming Guard Pro生成健康报告]

作为模块使用

const Guard = require('dreaming-guard-pro/src/guard');

// 创建并启动守护进程
const guard = new Guard({
  loopInterval: 30000,      // 30秒检查一次
  reportInterval: 3600000,  // 1小时生成报告
  enableProtector: true,    // 启用进程保护
  enableHealer: true        // 启用崩溃自愈
});

await guard.start();

// 获取当前状态
const status = guard.getStatus();

// 手动触发动作
await guard.triggerArchive();
await guard.triggerCompress('lossy');

// 生成健康报告
const report = guard.getHealthReport('markdown');

// 停止守护
await guard.stop();

独立模块使用

// 只使用监控器
const Monitor = require('dreaming-guard-pro/src/monitor');
const monitor = new Monitor({ interval: 30000 });
await monitor.start();

// 只使用压缩器
const Compressor = require('dreaming-guard-pro/src/compressor');
const compressor = new Compressor();
await compressor.compress('/path/to/dreams', 'lossy');

// 只使用归档器
const Archiver = require('dreaming-guard-pro/src/archiver');
const archiver = new Archiver();
await archiver.archive({ sourcePath: '/path/to/dreams' });

配置选项

主配置 (Guard)

选项 默认值 说明
loopInterval 30000 主循环间隔(毫秒)
reportInterval 3600000 报告生成间隔(毫秒)
enableProtector true 启用进程保护
enableHealer true 启用崩溃自愈
enableReporter true 启用报告生成
watchPath ~/.openclaw/workspace/memory/.dreams 监控路径
logLevel 'info' 日志级别

分析器配置 (Analyzer)

选项 默认值 说明
thresholds.green 524288000 安全阈值(500MB)
thresholds.yellow 1073741824 警告阈值(1GB)
thresholds.red 2147483648 危险阈值(2GB)
growthRate.low 10 低增长率阈值(KB/min)
growthRate.medium 100 中增长率阈值(KB/min)
growthRate.high 500 高增长率阈值(KB/min)

保护器配置 (Protector)

选项 默认值 说明
maxMemoryMB 512 最大内存限制(MB)
thresholds.warning 0.70 预警阈值(70%)
thresholds.critical 0.85 严重阈值(85%)
thresholds.emergency 0.95 紧急阈值(95%)
cooldown 60000 干预冷却时间(毫秒)

压缩策略 (Compressor)

策略 减少目标 说明
lossless 15% 无损压缩,去除重复
lossy 40% 有损压缩,摘要合并
aggressive 70% 激进压缩,只保留关键

归档策略 (Archiver)

层级 保留时间 说明
hot 7天内 最近数据,快速访问
warm 7-30天 中期数据,压缩存储
cold 30天以上 历史数据,深度压缩

报告格式

支持三种格式:

  • text - 纯文本,适合终端查看
  • json - JSON格式,适合程序解析
  • markdown - Markdown格式,适合文档展示

示例报告(text格式):

==================================================
Dreaming Guard Pro - Health Report
Generated: 2026-04-19T12:00:00.000Z
==================================================

[Overall Status]
  Status: HEALTHY
  Health Score: 95/100
  Risk Level: green

[Current State]
  Total Size: 128MB
  Total Files: 42
  Growth Rate: 5 KB/min

[Memory Usage]
  Process RSS: 64MB
  Process Heap: 32/48MB
  System: 2048/8192MB (25%)

[Recommendations]
  - Continue monitoring - system is healthy
  - No immediate action required

工作流程

主循环每30秒执行一次:

Monitor → Analyzer → Decision → Execute
   ↓          ↓          ↓          ↓
 采集数据   分析趋势   决策动作   执行动作

动作类型:

  • no_action - 无需操作
  • notify - 发送通知
  • archive - 触发归档
  • compress - 触发压缩
  • emergency - 紧急处理(压缩+归档)

文件位置

文件 默认路径
配置文件 ~/.openclaw/dreaming-guard.json
状态文件 ~/.openclaw/dreaming-guard-state.json
日志文件 ~/.openclaw/logs/dreaming-guard.log
归档目录 ~/.openclaw/archive/dreaming/
健康报告 ~/.openclaw/logs/health-report-*.log

环境变量

可通过环境变量覆盖配置:

DREAMING_GUARD_MONITOR_INTERVAL=30000
DREAMING_GUARD_MEMORY_THRESHOLD=512
DREAMING_GUARD_ARCHIVE_PATH=~/.openclaw/archive
DREAMING_GUARD_THRESHOLD_WARNING=524288
DREAMING_GUARD_THRESHOLD_CRITICAL=1048576
DREAMING_GUARD_THRESHOLD_EMERGENCY=2097152

测试

cd projects/dreaming-guard-pro
npm test

或单独测试Phase 5:

node test/test-phase5.js

API摘要

Guard (主入口)

guard.start()           // 启动守护
guard.stop()            // 停止守护
guard.getStatus()       // 获取状态
guard.runOnce()         // 执行一次循环
guard.getHealthReport() // 生成报告
guard.triggerAction()   // 手动触发动作
guard.triggerArchive()  // 手动归档
guard.triggerCompress() // 手动压缩
guard.healthCheck()     // 健康检查

Reporter (报告生成)

reporter.generate(format)      // 生成报告
reporter.getSummary()          // 获取摘要
reporter.formatReport(data, f) // 格式化数据
reporter.saveReport(report)    // 保存报告

技术规格

  • 语言: 纯Node.js
  • 依赖: 零外部依赖(仅使用内置模块)
  • 兼容: Node.js >= 16.0.0
  • 测试: 测试运行时间 \x3C 10秒

License

MIT


开发者: OpenClaw Community
版本: 1.0.0
最后更新: 2026-04-19

安全使用建议
This package appears to implement the advertised monitoring, archiving and compression features, but there are several red flags you should check before installing: - Inspect protector.js and healer.js to confirm what "intervene"/"restart" actions do (can they kill/restart other processes? do they require sudo?). If they restart system processes you must ensure that behavior is acceptable. - Fix the cron/installation instructions: scripts/dreaming-guard-pro.sh hardcodes PROJECT_DIR under /root which will likely be wrong for your environment; adjust paths before enabling a cron job. - SKILL.md mentions test/test-phase5.js but that file is missing from the manifest — run the included tests (node test/run-tests.js and the listed test files) locally to confirm behavior. - The README/ARCHITECTURE text contains minor inconsistencies (license badge vs package.json license, different repo URLs, mention of external npm deps that aren't used). These are signs of sloppy packaging, not necessarily malicious intent, but they warrant extra caution. - Run the skill in a sandbox or non-production environment first; review or run the code with a debugger to observe filesystem and process actions. Confirm backup/restore paths (they default to ~/.openclaw/*) and ensure you have backups of important data. If you are not comfortable auditing the protector/healer modules yourself, do not install it with persistent/crontab execution. If you proceed, limit its permissions (run as an unprivileged user or inside a container) and verify behavior with dryRun options where available.
功能分析
Type: OpenClaw Skill Name: dreaming-guard-pro Version: 1.0.0 The dreaming-guard-pro bundle is a comprehensive context management system for OpenClaw designed to prevent Out-Of-Memory (OOM) crashes. It implements monitoring, trend analysis, semantic compression, and automated archiving of context files located in the ~/.openclaw directory. The code is well-structured, utilizes only built-in Node.js modules (fs, path, os, zlib), and lacks any indicators of malicious intent such as data exfiltration, unauthorized remote execution, or prompt injection. All file operations, including deletion and archiving, are strictly aligned with the stated purpose of managing context growth and recovering from crashes.
能力标签
requires-sensitive-credentials
能力评估
Purpose & Capability
The name/description match the included modules (monitor, analyzer, archiver, compressor, protector, healer). The code implements filesystem scanning, compression, backups and reporting which are reasonable for the stated goal. However there are minor mismatches in documentation (README/ARCHITECTURE reference npm dependencies that the shipped code doesn't use) and the cron script hardcodes a /root project path which is unexpected for a general-purpose OpenClaw skill.
Instruction Scope
SKILL.md instructs copying files from /root and running cron entries that reference /path/to/dreaming-guard-pro; the provided cron runner script (scripts/dreaming-guard-pro.sh) uses PROJECT_DIR="/root/.openclaw/workspace/projects/dreaming-guard-pro" which will fail for non-root installs and suggests the package assumes root layout. SKILL.md also references test/test-phase5.js (and some other artifacts) that are not present in the manifest. The runtime instructions cause the agent to start modules that will read and write files under ~/.openclaw and may start/stop monitoring/protector/healer components; any module that intervenes on processes (restart, emergency actions) should be audited before running.
Install Mechanism
There is no formal install spec (instruction-only), but the repository includes JavaScript files that will be copied into the agent environment and executed. No remote downloads or package registry installs are requested, which reduces supply-chain risk; however executing bundled Node code still runs arbitrary code on the host.
Credentials
The skill does not require credentials and only documents non-sensitive environment variables for thresholds and paths. ENV mappings are configuration/threshold values, not secrets — this is proportionate to the described functionality.
Persistence & Privilege
always:false and model invocation remains allowed (default). The skill writes config, state, archives, backups under ~/.openclaw and may be run from cron; these are expected for a daemon-style guard. However the cron script's hardcoded root path and the architecture's emergency action ('restart' of gateway) indicate the skill can affect other processes — review protector/healer implementations and cron usage before giving it persistent runtime.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install dreaming-guard-pro
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /dreaming-guard-pro 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Dreaming Guard Pro 1.0.0 – Initial release. - Provides smart, zero-dependency protection against OpenClaw dreaming context overflow and memory issues. - Features real-time growth monitoring, three-tiered archiving/compression, process memory protection, and automated crash self-recovery. - Generates periodic health reports in multiple formats (text, json, markdown). - Highly configurable with environment variable overrides and modular API design. - Usable as a ClawHub Skill, a Node.js module, or as standalone components.
元数据
Slug dreaming-guard-pro
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Dreaming Guard Pro 是什么?

Smart prevention and auto-recovery for OpenClaw dreaming context overflow. Monitors growth trends, archives intelligently, compresses context, protects proce... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 106 次。

如何安装 Dreaming Guard Pro?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install dreaming-guard-pro」即可一键安装,无需额外配置。

Dreaming Guard Pro 是免费的吗?

是的,Dreaming Guard Pro 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Dreaming Guard Pro 支持哪些平台?

Dreaming Guard Pro 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Dreaming Guard Pro?

由 kuangzhanzhiwang(@kuangzhanzhiwang)开发并维护,当前版本 v1.0.0。

💬 留言讨论