Skip to content
Back to skills

Scheduled Wake

ASecurity

创建与管理周期性定时任务(每隔 N 分钟/小时、每天固定时刻、每周、cron)以及服务器受限条件监控自唤醒脚本(如机票降价/公开网页变动监控)。

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentsapi

Works with

  • api
  • mcp

Security analysis

A100/100

Scanned December 5, 2026

npx -y skills add Fanzy27/AnywhereAI --skill scheduled-wake --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Scheduled Wake?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Scheduled Wake
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/fanzy27-scheduled-wake/badge)](https://www.skillsdirectory.com/skills/fanzy27-scheduled-wake)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: scheduled-wake
description: 创建与管理周期性定时任务(每隔 N 分钟/小时、每天固定时刻、每周、cron)以及服务器受限条件监控自唤醒脚本(如机票降价/公开网页变动监控)。
whenToUse: 当用户要求设置重复/周期性定时任务,或要求在服务器上定期检查外部公开信息并在满足条件(如价格跌破心理价位、余票/版本发布变动)时自动唤醒时加载。
---
# 技能:周期定时任务与受限条件自唤醒(`scheduled-wake`)

本技能说明总管(Anywhere)如何使用平台原生的 **周期定时任务(`schedule`)** 与 **受限条件自唤醒(`watcher`)** 接口。
严禁绕过平台私自使用系统 `crontab`、`nohup` 死循环或已屏蔽的 `schedule_*` 工具——所有周期任务与条件监控必须通过平台持久化注册,确保界面可见、可暂停/修改/删除、触发日志可观测、通知与现有提醒一致。

---

## 一、快速选型

| 需求类型 | 使用工具 | 典型例子 |
| --- | --- | --- |
| 一次性定时提醒 | `mcp__anywhere__reminder` | 「30 分钟后提醒我开会」「明天 10:00 提醒我续费」 |
| 周期性定时任务 | `mcp__anywhere__schedule` | 「每 2 小时提醒我起身喝水」「每天 09:00 帮我汇总待办」「每周五 17:00 提醒写周报」 |
| 外部条件触发自唤醒 | `mcp__anywhere__watcher` | 「监控上海→东京机票,跌破 ¥1800 就提醒我」「监控某公开页面或 JSON 接口出现新版本时唤醒我」 |

> **说明**:早间简报、每日日报、周/月复盘由平台自身报告调度器管理(可在「设置 → 每日日报 / 通知」开关),不要用 `schedule` 重复创建。

---

## 二、周期定时任务(`mcp__anywhere__schedule`)

支持动作:`list` | `create` | `update` | `pause` | `resume` | `delete` | `preview`。
建完后自动出现在前端「设置 → 通知 → 自定义规则」中,用户和总管均可随时查看、修改、暂停或删除;到点触发后进入统一唤醒队列与消息通知(与一次性提醒体验一致)。

### 1. 按间隔触发(每隔 N 分钟 / 每隔 N 小时)
```json
{
  "action": "create",
  "name": "每两小时喝水与活动提醒",
  "every_hours": 2,
  "text": "提醒用户起身喝水、放松眼睛和颈椎,语气轻松简短。"
}
```
或按分钟(最小 1 分钟,最大 10080 分钟 = 7 天):
```json
{
  "action": "create",
  "name": "部署健康巡检提醒",
  "every_minutes": 15,
  "text": "提醒用户检查发布后指标是否稳定。"
}
```

### 2. 每天 / 每周固定时刻触发(按用户配置的时区,默认 `Asia/Shanghai`)
```json
{
  "action": "create",
  "name": "每日上午优先级核对",
  "time": "09:30",
  "repeat": "daily",
  "text": "提醒用户快速核对今天最重要的三件事。"
}
```
每周指定星期(`0=周日, 1=周一 … 6=周六`):
```json
{
  "action": "create",
  "name": "周五下午周报提醒",
  "time": "17:00",
  "repeat": "weekly",
  "weekdays": [5],
  "text": "提醒用户整理本周进展。"
}
```

### 3. 查看、修改、暂停、恢复、删除、预览
- 查看列表与下次触发时间:`{ "action": "list" }`
- 修改间隔或文案:`{ "action": "update", "id": "rule_xxx", "every_minutes": 30, "text": "..." }`
- 暂停 / 恢复:`{ "action": "pause", "id": "rule_xxx" }` / `{ "action": "resume", "id": "rule_xxx" }`
- 删除:`{ "action": "delete", "id": "rule_xxx" }`
- 仅预览下次触发时刻:`{ "action": "preview", "id": "rule_xxx" }`
- 对应 REST API(同样持久化在 `proactive_rules`):`GET/POST /api/v1/proactive/rules`、`PATCH/DELETE /api/v1/proactive/rules/:id`、`GET /api/v1/proactive/rules/preview`。

---

## 三、受限条件监控与自我唤醒(`mcp__anywhere__watcher`)

支持动作:`list` | `create` | `update` | `pause` | `resume` | `delete` | `run` | `runs`。
监控器由 **Core 服务器原生调度并在隔离沙箱内执行**,无需另起后台进程。

### 四种评估模式(`evaluator_kind`)
1. **`script`(推荐,自定义 JS 检查脚本)**:
   - 脚本为 `async function(ctx)` 函数体,入参 `ctx` 只读冻结,仅提供:
     - `ctx.params`:注册时传入的参数对象(如出发/到达城市、日期范围、人数、心理价位、公开接口 URL)
     - `ctx.state`:上一次检查持久化的状态对象(最多 8 KB,可用于对比历史最低价)
     - `ctx.now`:当前时间戳(ms)
     - `ctx.http.getJson(url, opts?)` / `ctx.http.getText(url, opts?)`:受策略网关保护的只读公开 HTTPS GET
   - 返回纯决策对象:
     ```js
     return {
       wake: true,                 // false 时静默记录 ok_silent,不产生任何噪音
       title: "简短标题",           // 通知与排队预览标题
       summary: "人类可读关键事实", // 唤醒正文与通知内容
       dedupeKey: "去重键",         // 相同去重键在 24h 内不重复打扰
       state: { lastLowest: 1620 },// 持久化到下一次检查(<= 8 KB)
       data: { lowestPrice: 1620 } // 结构化数据(可选,<= 4 KB)
     }
     ```
2. **`json_threshold`(零代码 JSON 阈值)**:配置 `url`、`json_path`(如 `lowest.price`)、`op`(`<` | `<=` | `>` | `>=` | `==` | `!=`)、`threshold`。
3. **`regex_match`(零代码网页正则/数值提取)**:配置 `url`、`regex`、`capture_group`、可选 `min_number`/`max_number`。
4. **`trigger_only`(受限外部回调端点)**:设置 `evaluator_kind: "trigger_only"`(或任意监控器加 `issue_trigger_token: true`),平台一次性返回仅限该监控器使用的 `trigger_token`。外部脚本可调用:
   - `POST /api/v1/watchers/<id>/trigger`
   - Header:`X-Watcher-Token: <trigger_token>`
   - Body:`{ "title": "...", "summary": "...", "dedupeKey": "...", "data": {} }`
   - 该 token **只能**向绑定监控器提交唤醒载荷,受冷却期、每日配额与暂停开关硬约束,无法调用任何工具或读写任何其他资源。

### 实战示例:监控机票公开票价,跌破心理价位时唤醒
```json
{
  "action": "create",
  "name": "上海→东京机票降价监控",
  "evaluator_kind": "script",
  "every_minutes": 30,
  "cooldown_minutes": 180,
  "max_wakes_per_day": 4,
  "allowed_hosts": ["api.example-flights.com"],
  "params": {
    "url": "https://api.example-flights.com/v1/public/fares?from=SHA&to=TYO&start=2026-12-20&end=2026-12-25&pax=2",
    "origin": "上海 (SHA)",
    "destination": "东京 (TYO)",
    "dateRange": "2026-12-20 ~ 2026-12-25",
    "passengers": 2,
    "maxPrice": 1800
  },
  "code": "const res = await ctx.http.getJson(ctx.params.url);\nconst offers = Array.isArray(res?.offers) ? res.offers : [];\nif (offers.length === 0) return { wake: false, summary: '暂无可售航班', state: ctx.state };\noffers.sort((a, b) => a.pricePerPerson - b.pricePerPerson);\nconst best = offers[0];\nconst prev = typeof ctx.state?.lowestPrice === 'number' ? ctx.state.lowestPrice : null;\nconst nextState = { lowestPrice: best.pricePerPerson, bestDate: best.date, checkedAt: ctx.now };\nif (best.pricePerPerson <= ctx.params.maxPrice) {\n  const total = best.pricePerPerson * ctx.params.passengers;\n  return {\n    wake: true,\n    title: `${ctx.params.origin}→${ctx.params.destination} 机票跌破心理价(¥${best.pricePerPerson}/人)`,\n    summary: `${best.date} ${best.flight || ''} 低至 ¥${best.pricePerPerson}/人(${ctx.params.passengers}人共 ¥${total}),低于心理价位 ¥${ctx.params.maxPrice}${prev ? `(上次最低 ¥${prev})` : ''}。`,\n    dedupeKey: `${best.date}:${best.pricePerPerson}`,\n    state: nextState,\n    data: { flight: best.flight, date: best.date, pricePerPerson: best.pricePerPerson, total }\n  };\n}\nreturn { wake: false, summary: `当前最低 ¥${best.pricePerPerson}/人,高于心理价位 ¥${ctx.params.maxPrice}`, state: nextState };"
}
```

### 上线前必做验证与排错
1. **立即干跑验证**(不发真实唤醒、不改状态):
   `watcher(action="run", id="wat_xxx", dry_run=true)`
2. **查看执行历史与失败原因**:
   `watcher(action="runs", id="wat_xxx", limit=10)`
3. **如条件需要调整或停止**:使用 `update` / `pause` / `resume` / `delete`。

---

## 四、硬性安全边界与配额(平台级强制拦截)

任何尝试越权的行为都会在注册或运行时被平台拦截,返回明确错误码(`E_FORBIDDEN` + `policyCode`)并记录到 `watcher_runs`:

1. **只读公开 HTTPS(禁写/禁删)**:仅允许公开 `https://` 的 `GET` / `HEAD` 请求;禁止 `POST`/`PUT`/`PATCH`/`DELETE` 及 `/delete`、`/remove`、`/destroy` 等破坏性路径。
2. **禁止对外发送消息**:屏蔽 Slack/Telegram/Discord/企微/飞书/钉钉/Twilio/SendGrid/Webhook 等消息推送域名与路径。
3. **禁止花钱与交易**:屏蔽支付、下单、预订、转账、退款等域名与路径(`/pay`、`/checkout`、`/order`、`/book`、`/transfer` 等)。
4. **禁止访问本地数据与内网(防越权/防 SSRF/防外传)**:
   - 沙箱无 `fs`、`child_process`、`process`、`require`、`import`、`eval`、`Function`、数据库或 Vault 访问权限;
   - 禁止访问 `localhost`、`127.0.0.0/8`、内网 RFC1918 IP、云元数据 IP(`169.254.169.254`)、`.local`/`.internal`(含 DNS 解析与重定向校验,最多 3 跳);
   - 禁止携带 `Authorization`、`Cookie`、`X-API-Key` 或 URL 账号密码,禁止超长查询串(>1024 字符)或外传平台密钥。
5. **频率与配额限制(防刷爆)**:
   - 最多 30 条启用中的周期定时任务,最多 20 个条件监控器;
   - 监控器单次最多 3 次 GET 请求(单次 10 秒超时、512 KB 响应上限)、VM 同步执行上限 1 秒;
   - 支持冷却期(默认 60 分钟)、相同 `dedupeKey` 24 小时去重、单监控每日唤醒上限(默认 5,最高 24)、全局监控每日唤醒上限 50;
   - **失败可观测**:每次执行落库 `watcher_runs`,连续失败 3 次主动发出异常唤醒,连续失败 10 次自动暂停并告警,绝不静默失效。

---

## 五、向用户回复的检查清单
- 创建前确认关键参数(周期任务的频率/时刻;价格监控的路线、日期、人数、阈值与公开来源)。
- 监控器注册后尽量执行一次 `dry_run=true` 确认数据源可达且脚本无误,再告知用户已启用。
- 回复用户使用自然语言说明触发频率/条件与查看/暂停位置(「设置 → 通知 → 自定义规则」),不暴露内部 `rule_`/`wat_` 编号或脚本实现细节。

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.