网淘吧来吧,欢迎您!

Restart Guard技能使用说明

2026-04-01 新闻来源:网淘吧 围观:14
电脑广告
手机广告

重启守护

目标

安全重启网关,保留上下文,并保证重启后可主动回报到用户会话。
触发条件

当任务涉及 OpenClaw 网关重启、看门狗恢复、重启后回报时使用。

自然语言触发(必须自动执行,不让用户手工跑脚本):
"可以重启了"

Restart Guard

"现在重启吧"

  • "restart now"
  • "go ahead and restart"
  • 前置条件
  • openclaw

CLI 可用。

  • 重启配置存在(
  • “现在重启吧”
  • “restart now”
  • “go ahead and restart”

Required Preconditions / 前置条件

  • openclawCLI is available.
  • Restart config exists (config.example.yamlconfig/restart-guard.yaml.example(已复制到运行时路径)。
  • Agent 可以执行 shell 命令。
  • openclawCLI 可用。
  • 重启配置文件存在(从示例拷贝到运行路径)。
  • agent 具备执行命令能力。

Workflow / 标准流程

0) Default behavior / 默认行为

当用户表达重启意图但未指定渠道详情时:

  • 通过以下脚本自动运行完整流程:scripts/auto_restart.py
  • 默认--notify-mode origin
  • 自动推断原始会话密钥(环境/上下文/会话),无需用户输入。
  • 自动发现外部渠道并持久化effective_notify_plan
  • 在触发前,主动向源会话预告灾难通知路由与渠道。
  • 重启事件到达后,由网络向用户汇总结果。

当用户仅表达重启意图且未指定渠道细节时:

  • 使用scripts/auto_restart.py自动执行全流程。
  • 默认--notify-mode origin
  • 自动推断源会话 key(env/context/sessions),无需用户补参数。
  • 自动发现外部渠道并写入effective_notify_plan
  • 触发前先在源会话预告灾难通知路由与渠道。
  • 收到重启事件后,由 net 向用户汇总结果。

1) 发现渠道与模式 / 发现渠道与模式(可选)

python3 <skill-dir>/scripts/discover_channels.py --config <config-path> --json

询问用户:

  • 通知模式(源会话推荐,或选定全部
  • 若需要,选择渠道/目标

询问用户:

  • 通知模式(推荐)原始,可选已选择全部
  • 若需要,指定渠道与目标

2)写入现场

python3 <skill-dir>/scripts/write_context.py \
  --config <config-path> \
  --reason "config change" \
  --verify 'openclaw health --json' 'ok' \
  --resume "report restart result to user"

3)执行重启

推荐单命令入口:

python3 <skill-dir>/scripts/auto_restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode origin

选择渠道模式:

python3 <skill-dir>/scripts/auto_restart.py \
  --config <config-path> \
  --reason "配置变更" \
  --notify-mode origin
python3 <skill-dir>/scripts/restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode origin \
  --origin-session-key <session-key>

4)事后校验

python3 <skill-dir>/scripts/restart.py \
  --config <config-path> \
  --reason "config change" \
  --notify-mode selected \
  --channel telegram \
  --target 726647436

契约

python3 <skill-dir>/scripts/postcheck.py --config <config-path>

事件契约:

  • 重启保护结果.v1必填字段:
  • 状态重启ID现场添加:
  • 重启ID
    • 原始会话密钥
    • origin_session_key
    • 通知模式
    • 通道选择
    • 有效通知方案
    • 状态时间戳
    • 诊断文件
    • 投递状态
  • 可选事件字段:
    • 严重性
    • 故障阶段
    • 错误代码
    • 投递尝试次数
    • 投递路由
    • 投递已穷尽
    • 诊断文件

注意事项

  • webui不再视为禁用通知;主路径是回发到发起会话。
  • webui不再视为禁用通知;主路径是回发到发起会话。
  • 校验/诊断命令以严格非 shell 模式执行。
  • 校验/诊断命令以严格非 shell 模式执行(包含管道等 shell 元字符会被拒绝)。
  • 有关实现级别的复制详细信息,请参阅ENHANCED_RESTART_IMPLEMENTATION_SPEC.md.
  • 若需按工程级标准复刻实现,请参考ENHANCED_RESTART_IMPLEMENTATION_SPEC.md
  • Do not expose internal scripts/steps unless user explicitly asks for internals.
  • 除非用户明确要求细节,否则不要向用户暴露内部脚本步骤。
  • Guardian uses strict success invariant:
    • down_detected && start_attempted && up_healthy
  • Guardian success requires strict invariant:
    • down_detected && start_attempted && up_healthy

Failure Handling / 故障处理

  • On timeout/failure, guardian writes local diagnostics file (restart-diagnostics-<restart_id>.md/json), sends concise summary, and retries delivery within budget.
  • 若超时或失败,guardian 会写本地诊断文件(restart-diagnostics-<restart_id>.md/json),发送简要摘要,并在预算内重试送达。
  • Fixed disaster route:origin session -> agent:main:main -> all discovered external channels.
  • Fixed Disaster Routing:Source Session -> agent:main:main -> All Discovered External Channels.
  • Guardian exits after successful delivery or budget exhaustion; no long-lived watchdog process after disaster handling.
  • After disaster handling concludes (successful delivery or budget exhaustion), the guardian must exit without long-term residency.

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部

相关文章

您是本站第394024名访客 今日有1篇新文章/评论