Files
ops-assistant/docs/module-adapter-template.md
T
openclaw 81939825d1 feat: 模块化命令框架 + runbook 严格断言与查询结果回传
- core/module: 命令模板、门控(feature flag/confirm/dry-run)、ecode 错误标签、ResultFormatter
- runbook executor: http.get/http.post/assert.json(expect_success 严格断言)、目标主机管理、任务落库、最终 stdout 直接回传
- cf 模块: /cf dns list 支持域名自动解析 zone_id;dns list/zones/workers list 格式化回传;API success:false 判真失败
- 全部 CF/CPA runbook 接入严格断言,杜绝假阳性 success
- 新增 cpa/cfdav/mail/sub 模块与 runbooks;QQ 订阅到期提醒调度
- Web 后台: 模块设置(CF/CPA/cfdav/AI)、OPS 任务、渠道管理、审计页
2026-09-13 07:42:17 +08:00

38 lines
992 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Module Adapter Template
目标:新功能模块以最小改动接入 `ops-assistant`。
## 必备文件
- `internal/module/<name>/module.go`
- `runbooks/<name>_*.yaml`
## 推荐实现
1. 在 `module.go` 内解析命令前缀(如 `/cf`)
2. 构建 `core/module.Request`
3. 统一调用 `core/module.Runner.Run(...)`
4. 所有 gate(flag/confirm/dry-run)通过 `Request.Gate` 声明
## 最小示例(伪代码)
```go
req := coremodule.Request{
RunbookName: "cf_dns_upsert",
Inputs: map[string]string{"zone": zone, "name": name},
Meta: runbook.RunMeta{Target:"cf", RiskLevel:"medium"},
Gate: coremodule.Gate{NeedFlag:"allow_cf_write", RequireConfirm:true, ExpectedToken:"YES_CF", AllowDryRun:true},
DryRun: dryRun,
ConfirmToken: confirm,
}
jobID, out, err := runner.Run(cmd.Raw, userID, req)
```
## 接入检查
- [ ] 命令不直接执行 shell/ssh
- [ ] 使用统一 Runner
- [ ] 风险操作有 Gate
- [ ] 返回 job_id 可追踪
- [ ] runbook step 可审计