用途
该技能为 aiter 提供通知与告警能力,用于在任务完成、监控检查、部署等场景下向不同目标发送通知。支持三种目标:应用(操作系统通知,默认)、IM 频道和 Webhook 端点。
主要能力
发送通知
基础通知(操作系统/应用通知):
aiter notify send --message "Build completed successfully!"
带标题和优先级:
# 普通优先级(默认)
aiter notify send --title "Build Status" --message "All tests passed" --priority normal
# 高优先级(绕过免打扰)
aiter notify send --title "ALERT" --message "Production API returning 500 errors" --priority high
# 低优先级(静默,无声音)
aiter notify send --title "Info" --message "Daily backup completed" --priority low
发送到指定目标:
# 操作系统通知(默认)
aiter notify send --message "Done!" --target app
# IM 频道
aiter notify send --message "Deploy complete" --target im --channelId channel-abc123
# Webhook 端点
aiter notify send --message "Metric alert" --target webhook --webhookUrl "https://my-api.com/alerts"
优先级级别
| 优先级 | 行为 |
|---|---|
| low | 静默通知,无声音,在历史中批量记录 |
| normal | 标准通知,带声音 |
| high | 绕过免打扰,始终立即送达 |
高优先级应谨慎使用,仅用于:生产错误和中断、安全告警、逾期关键任务、影响用户的监控检查失败。
通知配置
查看当前配置:
aiter notify config
设置免打扰时段:
aiter notify config \
--action set \
--quietHoursStart "22:00" \
--quietHoursEnd "08:00"
免打扰期间:low 和 normal 通知排队;high 通知立即送达;排队通知在免打扰结束后送达。
设置默认目标:
aiter notify config --action set --defaultTarget im
通知历史
# 查看最近 20 条通知
aiter notify history --limit 20
返回示例:
{
"success": true,
"data": [
{
"id": "notif-123",
"title": "Build Status",
"message": "All tests passed",
"priority": "normal",
"target": "app",
"timestamp": "2024-01-15T10:30:00Z",
"delivered": true
}
]
}
使用方式与集成模式
监控 → 告警 → 修复
# 检查健康状态
STATUS_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://api.example.com/health)
if [ "$STATUS_CODE" != "200" ]; then
# 高优先级告警
aiter notify send \
--title "API Health Check Failed" \
--message "API returned $STATUS_CODE. Attempting restart..." \
--priority high
# 尝试修复
pm2 restart api-server
# 后续通知
sleep 10
RETRY_CODE=$(curl -s -o /dev/null -w "%{http_code}" https://api.example.com/health)
if [ "$RETRY_CODE" = "200" ]; then
aiter notify send --message "API recovered after restart" --priority normal
else
aiter notify send --title "CRITICAL" --message "API still down after restart. Manual intervention required." --priority high
fi
fi
任务完成通知
# 长时间任务完成后
aiter notify send \
--title "Task Complete" \
--message "Orchestration 'E-commerce Platform' finished. 6/6 tasks done." \
--priority normal
# 如果配置了 IM 频道,也通过 IM 通知
CHANNEL_ID=$(cat .aiter/memory/config.md | grep "defaultChannel:" | awk '{print $2}')
if [ -n "$CHANNEL_ID" ]; then
aiter message send --channel $CHANNEL_ID --text "Task complete: E-commerce Platform orchestration finished." --format markdown
fi
定时汇总通知
结合 cron 实现周期性汇总:
# 发送每日汇总的 cron 任务
aiter cron add \
--name "Daily Summary" \
--projectId $PROJECT_ID \
--command "echo '[HEARTBEAT] Generate daily summary notification'" \
--expression "0 18 * * MON-FRI" \
--notify true
适用场景
- 构建、部署、测试等任务完成后的状态通知
- 生产环境 API 健康检查失败告警与自动修复流程
- 安全告警、逾期关键任务提醒
- 通过 IM 频道或 Webhook 将通知转发到团队协作工具或自有服务
- 结合 cron 发送每日/每周汇总
限制
资料未提供关于平台支持范围、依赖环境、安装方式、收费模式及性能上限的说明。