OA0 = Omni AI 0
OA0 是一个探索 AI 的论坛
现在注册
已注册用户请  登录
OA0  ›  技能包  ›  restart-guard:在保留上下文的情况下安全重启 OpenClaw 网关

restart-guard:在保留上下文的情况下安全重启 OpenClaw 网关

 
  app ·  2026-02-20 21:16:16 · 3 次点击  · 0 条评论  

名称: restart-guard
版本: 2.1.0
描述: 具备确定性重启的 OpenClaw 网关守护工具,支持上下线状态机验证、源会话主动确认及向后兼容的配置。


Restart Guard

Purpose / 目标

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

Trigger / 触发条件

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

自然语言触发(自动执行,无需用户手动运行脚本):
- “可以重启了”
- “现在重启吧”
- “restart now”
- “go ahead and restart”

Required Preconditions / 前置条件

  • openclaw CLI 可用。
  • 重启配置文件已就位(从示例文件复制到运行路径)。
  • Agent 具备执行 shell 命令的权限。

Workflow / 标准流程

0) Default behavior / 默认行为

当用户仅表达重启意图且未指定渠道细节时:
- 通过 scripts/auto_restart.py 自动执行全流程。
- 默认 --notify-mode origin
- 自动推断源会话 key(从环境/上下文/会话中),无需用户额外输入。
- 自动发现外部渠道并持久化 effective_notify_plan
- 触发前先在源会话预告灾难通知路由与渠道。
- 收到重启事件后,由 net 向用户汇总结果。

1) Discover channels and mode / 发现渠道与模式(可选)

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

询问用户:
- 通知模式(推荐 origin,可选 selectedall
- 若需要,指定渠道与目标

2) Write context / 写入现场

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) Execute restart / 执行重启

推荐单命令入口:

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>

选定渠道模式:

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

4) Postcheck / 事后校验

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

Contract / 契约

  • 事件契约:restart_guard.result.v1
  • 必填字段:status, restart_id
  • 上下文新增字段:
  • restart_id
  • origin_session_key
  • notify_mode
  • channel_selection
  • effective_notify_plan
  • state_timestamps
  • diagnostics_file
  • delivery_status
  • 可选事件字段:
  • severity
  • failure_phase
  • error_code
  • delivery_attempts
  • delivery_route
  • delivery_exhausted
  • diagnostics_file

Notes / 注意事项

  • webui 不再视为禁用通知;主路径是回发到发起会话。
  • 若需按工程级标准复刻实现,请参考 ENHANCED_RESTART_IMPLEMENTATION_SPEC.md
  • 除非用户明确要求细节,否则不要向用户暴露内部脚本步骤。
  • Guardian 遵循严格的成功不变式:
  • down_detected && start_attempted && up_healthy

Failure Handling / 故障处理

  • 若超时或失败,guardian 会写本地诊断文件(restart-diagnostics-<restart_id>.md/json),发送简要摘要,并在预算内重试送达。
  • 固定灾难路由:源会话 -> agent:main:main -> 所有已发现外部渠道
  • 灾难处理结束后(送达成功或预算耗尽)guardian 必须退出,不长期驻留。
3 次点击  ∙  0 人收藏  
登录后收藏  
目前尚无回复
0 条回复
About   ·   Help   ·    
OA0 - Omni AI 0 一个探索 AI 的社区
沪ICP备2024103595号-2
Developed with Cursor