mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-25 07:00:48 +09:00
14 lines
7.8 KiB
JavaScript
14 lines
7.8 KiB
JavaScript
import{_ as a,o as s,c as e,ag as i}from"./chunks/framework.CAXxHpAX.js";const k=JSON.parse('{"title":"计划任务","description":"","frontmatter":{},"headers":[],"relativePath":"zh/getting-started/schedule.md","filePath":"zh/getting-started/schedule.md","lastUpdated":1777012567000}'),n={name:"zh/getting-started/schedule.md"};function d(r,t,l,h,o,p){return s(),e("div",null,[...t[0]||(t[0]=[i(`<h1 id="计划任务" tabindex="-1">计划任务 <a class="header-anchor" href="#计划任务" aria-label="Permalink to "计划任务""></a></h1><p>用 <strong>cron 表达式</strong> 在固定时间让机器人干一件事:发报告、查外网、维护、或任何能交给智能体+工具完成的活。</p><h2 id="是什么" tabindex="-1">是什么 <a class="header-anchor" href="#是什么" aria-label="Permalink to "是什么""></a></h2><p><strong>Schedule</strong> 绑在某个机器人上。到点就把一条自然语言 <strong>command</strong> 交给智能体,由它用工具、技能去执行,结果可发到已接好的渠道。</p><hr><h2 id="字段" tabindex="-1">字段 <a class="header-anchor" href="#字段" aria-label="Permalink to "字段""></a></h2><table tabindex="0"><thead><tr><th>字段</th><th>说明</th></tr></thead><tbody><tr><td><strong>Name</strong></td><td>展示名,如 <code>晨间摘要</code></td></tr><tr><td><strong>Description</strong></td><td>短说明</td></tr><tr><td><strong>Pattern</strong></td><td>五段 cron,如 <code>0 9 * * *</code> 每天 9:00</td></tr><tr><td><strong>Command</strong></td><td>到点时发给智能体的自然语言任务</td></tr><tr><td><strong>Enabled</strong></td><td>是否启用</td></tr><tr><td><strong>Max Calls</strong></td><td>总执行次数上限,空=不限</td></tr><tr><td><strong>Current Calls</strong></td><td>已跑次数</td></tr></tbody></table><hr><h2 id="cron-五段" tabindex="-1">Cron(五段) <a class="header-anchor" href="#cron-五段" aria-label="Permalink to "Cron(五段)""></a></h2><p>在服务器时区下算;默认 Memoh 常用 <strong>UTC</strong>,可用顶层 <code>timezone</code> 改。五段为:分、时、日、月、周。</p><div class="language- vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>┌ 分 0–59</span></span>
|
||
<span class="line"><span>│ ┌ 时 0–23</span></span>
|
||
<span class="line"><span>│ │ ┌ 日 1–31</span></span>
|
||
<span class="line"><span>│ │ │ ┌ 月 1–12</span></span>
|
||
<span class="line"><span>│ │ │ │ ┌ 周 0–6,周日=0</span></span>
|
||
<span class="line"><span>* * * * *</span></span></code></pre></div><table tabindex="0"><thead><tr><th>Pattern</th><th>含义</th></tr></thead><tbody><tr><td><code>0 9 * * *</code></td><td>每天 9:00</td></tr><tr><td><code>*/30 * * * *</code></td><td>每 30 分钟</td></tr><tr><td><code>0 0 * * 1</code></td><td>每周一 0:00</td></tr><tr><td><code>0 8,20 * * *</code></td><td>每天 8:00 和 20:00</td></tr><tr><td><code>0 0 1 * *</code></td><td>每月 1 号 0:00</td></tr></tbody></table><hr><h2 id="看列表" tabindex="-1">看列表 <a class="header-anchor" href="#看列表" aria-label="Permalink to "看列表""></a></h2><p>机器人 <strong>Schedule</strong> tab:名、pattern、是否启用、执行次数等;<strong>Refresh</strong> 重载。</p><hr><h2 id="创建" tabindex="-1">创建 <a class="header-anchor" href="#创建" aria-label="Permalink to "创建""></a></h2><h3 id="让机器人自己建" tabindex="-1">让机器人自己建 <a class="header-anchor" href="#让机器人自己建" aria-label="Permalink to "让机器人自己建""></a></h3><p>机器人有 <code>schedule</code> 工具。你可以说人话,例如让每天 8:00 汇总未读邮件,它会去拼 cron 并登记。</p><h3 id="调-api" tabindex="-1">调 API <a class="header-anchor" href="#调-api" aria-label="Permalink to "调 API""></a></h3><p><code>POST /api/bots/{bot_id}/schedule</code>,例如:</p><div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "name"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Daily Digest"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "description"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Summarize unread emails every morning"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "pattern"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"0 8 * * *"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "command"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">"Summarize my unread emails and send the result to Telegram."</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "enabled"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span></span>
|
||
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> "max_calls"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">null</span></span>
|
||
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">}</span></span></code></pre></div><p>(字段名以当前 API 为准。)</p><hr><h2 id="执行时发生什么" tabindex="-1">执行时发生什么 <a class="header-anchor" href="#执行时发生什么" aria-label="Permalink to "执行时发生什么""></a></h2><ol><li>cron 到点</li><li><code>current_calls</code> +1</li><li>若设了 <code>max_calls</code> 且到顶,任务自动关</li><li>智能体收 <code>command</code> 与计划上下文</li><li>用工具发消息/搜网页等</li><li>结果可发到已连接渠道</li></ol><hr><h2 id="和-heartbeat-对比" tabindex="-1">和 Heartbeat 对比 <a class="header-anchor" href="#和-heartbeat-对比" aria-label="Permalink to "和 Heartbeat 对比""></a></h2><table tabindex="0"><thead><tr><th></th><th>Schedule</th><th>Heartbeat</th></tr></thead><tbody><tr><td>触发</td><td>cron,时间点灵活</td><td>固定<strong>间隔</strong>(分钟)</td></tr><tr><td>内容</td><td>你写的一条自然语言指令</td><td>偏「例行走一圈」的通用轮询</td></tr><tr><td>次数上限</td><td>可设</td><td>无上限那层概念</td></tr><tr><td>适合</td><td>定点的具体事</td><td>笼统的周期自检</td></tr></tbody></table><p><strong>Heartbeat</strong> 当「常转转」<strong>Schedule</strong> 当「几点要干啥」。两者可一起用。</p>`,30)])])}const g=a(n,[["render",d]]);export{k as __pageData,g as default};
|