
Gas Town 怎么配置 escalation.json 的联系人和路由让 gt escalate 发出邮件或短信【免费下载链接】gastownGas Town - multi-agent workspace manager项目地址: https://gitcode.com/GitHub_Trending/ga/gastownGas Town 的升级escalation机制默认会把问题记录成 escalation bead并按严重级别把 gt 邮件发给 mayor 等内部角色。但如果你希望gt escalate真正把通知发到外部——给你自己发邮件或在 CRITICAL 级别发一条短信——就需要配置~/gt/settings/escalation.json里的routes路由和contacts联系人。本文只覆盖这一个任务让gt escalate命令能发出邮件或短信并验证发送结果。前提是你已经有一个 Gas Town 工作区gt escalate只能在 Gas Town 工作区内运行否则命令会直接报not in a Gas Town workspace。gt install初始化 town 时会自动生成一份带默认路由、空联系人的settings/escalation.json所以通常不需要从零建文件只需要改联系人和路由。配置格式与协议细节的完整说明见 escalation 设计文档。先弄清 routes 和 contacts 两个字段的关系配置文件~/gt/settings/escalation.json的两部分决定了两件事routes按严重级别low / medium / high / critical映射一组动作action动作按顺序执行contacts外部通知通道实际发给谁、通过哪个服务器或 webhook 发。可用动作如下来自 escalation 设计文档动作格式行为beadbead创建 escalation bead始终第一项隐式mail:targetmail:mayor向目标发 gt 内部邮件email:humanemail:human发邮件到contacts.human_emailsms:humansms:human发短信到contacts.human_smsslackslack发布到contacts.slack_webhookloglog写入升级日志文件关键点路由里的email:human和sms:human只是声明要发真正能不能发出去取决于contacts里对应的字段是否填了。缺字段时动作会被跳过并打印警告而不是报错失败见下文验证一节。配置邮件填 SMTP 信息 在 routes 里加 email:human要让某个严重级别触发邮件需要同时满足两处该级别的 route 数组里包含email:humancontacts里填好收件人和 SMTP 服务器。contacts中与邮件相关的字段human_email收件邮箱地址必填否则email:human被跳过smtp_hostSMTP 服务器主机名必填例如代码注释中给出的smtp.gmail.comsmtp_portSMTP 端口缺省为587smtp_from发件地址缺省为gastownlocalhostsmtp_user/smtp_passSMTP 认证的用户名和密码选填配置后发送时使用认证。一个只启用邮件通知的最小配置your.emailexample.com与smtp.example.com为占位符替换为你自己的邮箱和 SMTP 服务器{ type: escalation, version: 1, routes: { medium: [bead, mail:mayor], high: [bead, mail:mayor, email:human], critical: [bead, mail:mayor, email:human] }, contacts: { human_email: your.emailexample.com, smtp_host: smtp.example.com, smtp_port: 587, smtp_from: your.emailexample.com, smtp_user: your.smtp.user, smtp_pass: your.smtp.password }, stale_threshold: 4h, max_reescalations: 2 }上例只把high和critical两个级别接入了邮件medium保持默认的 bead mayor 内部邮件。routes的键只能是 low / medium / high / critical出现其他值会校验失败某个级别不写路由时回退到默认的[bead, mail:mayor]。配置短信填 sms_webhook 在 routes 里加 sms:human短信走的是一个通用的 webhook例如 Twilio 一类的短信网关不是直连运营商。启用条件该级别的 route 数组里包含sms:humancontacts里同时填好human_sms接收短信的电话号码sms_webhook短信网关的 webhook URLGas Town 会向该 URL POST 一个 JSON包含to即human_sms和body两个字段。两个字段缺一不可只填human_sms不填sms_webhook或反过来动作同样会被跳过。默认配置里critical级别本来就带sms:human所以如果只想让 CRITICAL 发短信往往只需要补联系人字段不用动路由。验证先用 --dry-run 看路由再真实发一次确认投递用 --dry-run 检查路由解析结果--dry-run只打印将要执行的动作不创建 bead、不发送邮件适合先确认配置是否被正确读入gt escalate -s CRITICAL test routing --dry-run输出形如以下为文档/实现中的输出结构示例Would create escalation: Severity: critical Description: test routing Actions: bead, mail:mayor, email:human, sms:human Mail targets: mayor检查Actions一行是否包含你期望的email:human/sms:human。如果不包含说明对应级别的 route 没配对回到escalation.json检查routes。真实执行并查看投递结果正式发一条升级用--json输出投递状态gt escalate -s CRITICAL Verify email/SMS routing -m config check --source manual:test --jsonJSON 输出里每个通道一条delivery记录邮件成功时对应记录为已通知runtime_notified为 true失败时带error字段顶层status为ok或partial_failure任一通道出错即 partial_failure。非 JSON 模式下成功时会直接打印 Email sent to 你的邮箱 SMS sent to 你的号码如果配置缺字段不会报致命错误而是打印警告并跳过该动作例如email action email:human skipped: contacts.human_email not configured in settings/escalation.json sms action sms:human skipped: contacts.sms_webhook not configured in settings/escalation.json出现这两类 skipped 警告时按提示去escalation.json的contacts补上对应字段即可。发送失败email send failed: .../sms send failed: ...则通常是 SMTP 认证或 webhook URL 本身的问题命令会输出具体错误信息。最后用列表和关闭命令收尾确认这条测试升级能被追踪gt escalate list # 应看到刚创建的升级 gt escalate ack bead-id # 确认已处理避免后续被 stale 重发 gt escalate close bead-id --reason config check done两个影响发送行为的相邻配置stale_threshold默认4hGo duration 格式未确认未 ack的升级超过该时长后gt escalate stale会把它升级严重级别low→medium→high→critical并按新级别重新执行路由——也就是说一个 medium 的测试升级如果长期不 ack4 小时后被提到 high/critical 时会再次触发邮件甚至短信。测试完请及时 ack 或 close。max_reescalations默认 2限制自动重升级次数0 表示不再重升级。适用边界gt escalate的严重级别只接受 critical、high、medium、lowescalate close的--reason是必填参数。路由配置支持按类别decision / blocked / emergency 等细分但这部分文档标注为 future尚未作为 CLI 参数实现当前只有routescontacts这套按严重级别的路由是生效的。配置文件的协议字段严重级别定义、bead 标签 schema、gt escalate ack/stale/close子命令的完整行为可继续参考 escalation 设计文档配置结构与默认值定义见 internal/config/types.go邮件/短信的实际发送逻辑含缺字段时的跳过行为见 internal/cmd/escalate_impl.go。【免费下载链接】gastownGas Town - multi-agent workspace manager项目地址: https://gitcode.com/GitHub_Trending/ga/gastown创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考