A local-first multi-agent app development platform, built on PenguinHarness
feat(schedules): 结束的定时任务移入 schedule/expired/(上游 #1159 移植)
lmliheng1007baf97a4f
diff --git a/changelog/unreleased/2026-10-18-schedule-expired-dir.md b/changelog/unreleased/2026-10-18-schedule-expired-dir.mdnew file mode 100644index 00000000..1c5113be--- /dev/null+++ b/changelog/unreleased/2026-10-18-schedule-expired-dir.md@@ -0,0 +1,50 @@+# Finished scheduled tasks move to `schedule/expired/`++- **Date:** 2026-10-18+- **Type:** feature+- **Scope:** `server`, `web`, `cli`, `docs`, `skills`+- **Breaking:** yes — a one-shot task whose start time has already passed is refused (400) instead of firing once immediately++[中文版](2026-10-18-schedule-expired-dir.zh.md)++Ported from upstream PenguinHarness (#1159, commit `4b10a219`).++The scheduler now archives scheduled tasks that can never fire again: a one-shot task that has+fired (`done`), a one-shot task whose time passed while the server was down (`missed`), and a task+past its `end_at` (`expired`). Each one's file is moved, unchanged, into the agent's+`agent_state/schedule/expired/`, and its SQLite run state is dropped as if the file had been+deleted.++## Details++- Reconcile and the schedule listings both archive. A one-shot task moves right after it fires,+ before `schedule_fired` is sent, so the refetch that event triggers no longer lists it. A task+ with a queued fire stays until that fire is sent.+- An archived task leaves every list and count: the agent's Schedules tab and its card's+ `scheduleCount`, the chat dock's Scheduled tasks panel, the sidebar alarm clock mark, the+ schedules API, `penguin schedule ls`, and the agent's `{{SCHEDULE_LIST}}` roster from its next+ model context.+- When `expired/` already holds a file of that name, the moved file takes a UTC timestamp suffix+ (`<name>.20261015T093000Z.toml`, then `-2`, `-3`…); nothing is overwritten. A failed move is+ recorded as `schedule_archive_failed`, and the task stays listed until a later pass moves it.+- Tasks that are invalid (bound Session deleted) or disabled are not archived.+- Moving a file back into `schedule/` registers it as a new task; one whose times are still past is+ archived again.+- Tasks already settled on disk move on the first reconcile after the upgrade, by the same rule.+- `POST` and `PUT` on the schedules API return 400 for a one-shot task whose `startAt` has+ passed, and for any task whose `endAt` has passed. The CLI and the Web form get the same+ refusal, so `penguin schedule add --start-at now` now needs `--period`.+- The Scheduled tasks panel dropped its **Completed** filter, keeping **All**, **Active** and+ **Paused**.+- The Scheduled tasks, Agents, CLI, Configuration and Server API docs, the CLI help, the Create+ with AI prompt and the `penguin-orchestration` Skill describe the archive and the new refusals.++## Compatibility++- A one-shot task whose `startAt` has already passed used to fire immediately:+ `penguin schedule add <name> --start-at now` without `--period`, and the same request from the+ form or the API. It is now refused with 400; give a future start time.+- Switching a disabled one-shot task back on after its time has passed used to fire it immediately;+ that is now refused too. Change its start time first.+- Files on disk are never rewritten. Tasks already settled move into `expired/` as described+ above.diff --git a/changelog/unreleased/2026-10-18-schedule-expired-dir.zh.md b/changelog/unreleased/2026-10-18-schedule-expired-dir.zh.mdnew file mode 100644index 00000000..0634ea09--- /dev/null+++ b/changelog/unreleased/2026-10-18-schedule-expired-dir.zh.md@@ -0,0 +1,32 @@+# 结束的定时任务移入 `schedule/expired/`++- **Date:** 2026-10-18+- **Type:** feature+- **Scope:** `server`, `web`, `cli`, `docs`, `skills`+- **Breaking:** yes — 开始时间已过的一次性任务改为拒绝(400),不再立即执行一次++[English](2026-10-18-schedule-expired-dir.md)++移植自上游 PenguinHarness(#1159,提交 `4b10a219`)。++调度器现在会归档不会再触发的定时任务:已触发的一次性任务(`done`)、在服务器停机期间错过时间的一次性任务(`missed`),以及已过 `end_at` 的任务(`expired`)。这类任务的文件被原样移入该 Agent 的 `agent_state/schedule/expired/`,其 SQLite 运行状态也像文件被删除一样清除。++## 细节++- 对账与定时任务列表都会执行归档。一次性任务在触发后、发出 `schedule_fired` 之前即被移走,因此这一事件触发的重新拉取不会再列出它。仍有排队待发的触发时,任务等这次触发发出后再移走。+- 归档的任务不再出现在任何列表和计数中:Agent 的定时任务标签页及其卡片的 `scheduleCount`、对话页停靠栏的定时任务面板、侧栏的闹钟标记、schedules API、`penguin schedule ls`,以及自下一个模型上下文起 Agent 的 `{{SCHEDULE_LIST}}` 任务清单。+- `expired/` 里已有同名文件时,移入的文件加上 UTC 时间戳后缀(`<name>.20261015T093000Z.toml`,再冲突则为 `-2`、`-3`…),不覆盖任何文件。移动失败时记录 `schedule_archive_failed`,任务继续留在列表中,直到后续一轮把它移走。+- 无效(绑定的 Session 已删除)与已停用的任务不归档。+- 把文件移回 `schedule/` 即作为新任务登记;时间仍已过去的会再次归档。+- 磁盘上已有的过时任务在升级后的首次对账中按同一规则移走。+- schedules API 的 `POST` 与 `PUT` 对 `startAt` 已过的一次性任务、以及 `endAt` 已过的任务返回 400。CLI 与 Web 表单随之同样拒绝,因此 `penguin schedule add --start-at now` 现在须带 `--period`。+- 定时任务面板去掉了**已完成**筛选,保留**全部**、**生效中**和**已暂停**。+- 定时任务、智能体、CLI、配置与服务器 API 文档,CLI 帮助、「用 AI 创建」的提示词以及 `penguin-orchestration` Skill 写明了归档行为与新的拒绝规则。++## 兼容性++- 开始时间已过的一次性任务过去会立即执行一次:不带 `--period` 的+ `penguin schedule add <name> --start-at now`,以及表单或 API 发出的同样请求。现在一律返回 400,+ 须给出将来的开始时间。+- 重新启用一个时刻已过的停用一次性任务,过去会立即执行;现在同样被拒绝,须先修改开始时间。+- 磁盘上的文件从不改写。已经过时的任务按上文移入 `expired/`。diff --git a/docs/FORK-PROGRESS.md b/docs/FORK-PROGRESS.mdindex bd6502ea..9362076f 100644--- a/docs/FORK-PROGRESS.md+++ b/docs/FORK-PROGRESS.md@@ -962,6 +962,17 @@ mock 路由导入序、`chat-page.tsx` 的旧探针体),自带 4 份用例真界面两态量出的是**行向容器要多少宽度** —— min-content 从 5417 / 5576 / 513 px 降到 120 px。本地化:包 scope 无跨包引用点;changelog 按本仓写法改名到本轮日期并写明移植来源与两处 fork 差异。细节与实测见「第七十轮」一节。+- [x] **5.48 结束的定时任务移入 `schedule/expired/`**(上游 `4b10a219` `#1159`,**2026-10-18 第七十七轮落地**,+ 提交见该节):已触发的一次性任务(`done`)、停机期间错过的一次性任务(`missed`)与已过 `end_at` 的任务+ (`expired`)都不会再触发,现在由对账、列表与「触发之后、`schedule_fired` 之前」三处把文件**原样**移进+ `agent_state/schedule/expired/` 并清掉它的 SQLite 运行状态;`expired/` 里同名时加 UTC 时间戳后缀+ (再冲突为 `-2`、`-3`…),绝不覆盖;移动失败记 `schedule_archive_failed`、下轮再试,任务留着直到移走。+ 无效(绑定的 Session 已删)与停用的任务不归档。列表 / 计数 / `{{SCHEDULE_LIST}}` 因此不再出现它们。+ **写侧同步收紧**:`POST` / `PUT` 对 `startAt` 已过的一次性任务、`endAt` 已过的任何任务返回 400+ (**破坏性**:`--start-at now` 的一次性任务过去会立刻执行一次);Web 的定时任务面板去掉「已完成」筛选。+ 本地化:只因本树把 status 推导放在路由里、标签走 `scheduleFilterLabels()`,两处按本树写法手写解决+ (`scheduleStatus()` 移到 `runtime/scheduler.ts` 由路由导入;标签仍从字典读)。changelog 按本仓写法改名+ 到本轮日期、去掉上游 PR 行、写明移植来源。细节与实测见「第七十七轮」一节。- **量过、本轮没移植的一条**:`#834`(`661a7bb2`,web 3 文件 / +53,把对话页的渲染 Agent 从「当前 Agent」换成「路由 Session 自己的 Agent」)。它在**本树可达的状态里都改变不了行为**,理由是可复现的:`agentOf()` 对未知 id 会回退到 `default_agent`、再回退到列表第一个(`#450` 起就是这样),所以@@ -1621,6 +1632,7 @@ v0.2.2」——它只加台账里 v0.2.2 那一节与两行表格,**跟本轮| 2026-10-17 | 7.1 | **浏览器 e2e 套件重新可信**(不是移植,是修本仓自己的测试设施;两个文件 / +102 −57,只有测试夹具与用例、无用户可见行为):`packages/web/e2e/subagent.spec.mjs` 4 条里 3 条本来就在红 —— 停靠栏打开后占位符与发送按钮各命中**两个**元素(面板里的子会话用的是同一个 `ChatInput`)、工具栏那枚琥珀色点早已改叫 `bg-tone-attention-emphasis`(`Dot` 按 token 上色)、以及一条假设「plain Task 之后拓扑回落到空图」的**陈旧断言**(`extractTopology` 的默认口径是「最近一次真的派生子智能体的 Task」,那条空态文案永不出现),三处都修了,并把最后一条重写成有意义的版本(第二条任务改用 mock 自带的 `run another subagent` 派第二次,用身份条的 `shortSessionId` 断言「钉住 = 第一轮的孩子、关掉标签页重开 = 最新一次派生的孩子」);`packages/web/e2e/mock-llm.mjs` 的标题分支还在找 `concise title`,而提示词早已改说 `You are a title generator.`,分支因此**从未触发**、会话标题一直停在宿主兜底 | 六包 `typecheck` **`EXIT=0`**(六个 `Done`;`gen:ifaces` 报 `src/ifaces.json unchanged`,192 接口 / 587 类型)· `pnpm lint` **0 警告 0 错误**(2397 文件)· 两个改动文件 `prettier --check` 干净 · 逐包 test **`EXIT=0`、0 失败**:core **1396** / 6 跳过(68 文件)· ui **129 文件 / 1043 通过** · cli **561**(38 文件)· web **259 文件 / 3187 通过 / 2 跳过** · server **201 文件 / 2937 通过 / 4 跳过** · hmr 无测试文件 · **本轮主证据(真服务端 + 真浏览器,改前改后两态)**:改前 `subagent.spec.mjs` **3 failed / 3 passed**,改后该文件 **4/4**、`background-subagent.spec.mjs` **2/2** 全绿;整套 76 条的基线由 **26 failed** 变成 **52 passed / 24 failed**(翻绿的除 subagent 那两条,还有 `files-switch.spec.mjs` 那条断言模型标题的)· **反证一(夹具陈旧)**:修 mock 前 `subagent.spec.mjs:117` 正是死在标题断言(收到 `Count the TODO items in the`)· **反证二(新断言非空转)**:把 `chat-page.tsx` 那段复位 effect 删掉、重建 web 产物再跑 → **1 failed**(身份条 `Expected substring "3e1dba72" / Received "General Agent8b8f9e05"`,即重开后仍停在钉住的那一轮),还原后全绿 · 端口只用 8930 / 8931(跑完已停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰;数据只落在 `/root/adelie-fork-data/r72-*` · CI run **`38985516965`**(`a3b35ec4`)**22 个作业全绿** | `12f7c7c1` || 2026-10-17 | 7.2(未完成) | **浏览器 e2e 的 24 条红压到 10 条**(不是移植;**接手的是 11:00 那一轮被 `user_abort` 打断的半成品**,17 个 `packages/web/e2e/*.spec.mjs` / 落在 r73 的 +82 −59 之上再加本轮 +17 −9,只有夹具、无源码、无用户可见行为):r73 那半天把英文旧文案与旧属性改到本树今天的中文与 data 属性上,其中四处对齐的是真实契约(会话级 `thinkingLevel` 由 `PATCH /api/sessions` 落、`stop_reason` 收敛为 `retryable`、成本按 `[¥$]`、行菜单「更多」);本轮又补六处:分组单选「按智能体分组」、权限按钮 `aria-label^="Permissions"` 与共享 Dropdown 的 `ui-glass` 两层、工单「打开会话」的 `data-tooltip`、skills 末两条断言的 data-analysis、时间轴 `.overflow-y-hidden` 与侧栏折叠「行不卸载」、上下文环 unknown 读 aria-label | 只重建 web 产物后跑受影响 18 个文件(40 条,mock 8942 / 服务端 8940 / 数据根 `/root/adelie-fork-data/r73-*`):r73 改动后 **27 过 / 13 红**(24 → 13),本轮再修后 company / draft / skills 实测转绿,**24 → 10**(14 条转绿,每条都有源码依据);六包 `typecheck` **EXIT=0**(六个 `Done`);逐包 test **0 失败** —— core 1396 / 6 跳过 · ui 1043 · server 2937 / 4 跳过 · cli 561 · web 3187 / 2 跳过;还红的 10 条已逐条分诊(3 条 llm-errors 是 403 被判 fatal 的真实行为变化、project-switch 疑似真 bug、其余为夹具未穷尽);端口只用 8940 / 8942 | 见本行提交 || 2026-10-17 | 7.2(仍未完成) | **浏览器 e2e 的 10 条红压到 3 条**(8 条是夹具/探针结论翻转,**只有 dock 拖拽带是真缺陷**:下侧栏边界拖拽带伸到框架外的一半被框架自己的 `overflow-hidden` 裁掉,改 `ResizeHandle` 贴内侧 `top-0`,连同 `dock-panel.tsx` 注释与 ui 单测、一对 changelog;另修 `theme-shots.mjs` 的陈旧键 `concise title`)。逐条:project-switch 夹具只卸了一个技能、layout 的重叠/底色/工作区选择器、outline 量到按钮、compaction 第二层开合、chat 分组折叠与设置对话框与行菜单时序、compact-abort 的斜杠菜单竞态、skills 的标题同文 | 开工复核 26 条里 10 红与台账逐条对上;修完整套 **76 条 73 通过 / 3 失败**,只剩 `llm-errors` 三条;六包 `typecheck` **EXIT=0**(`ifaces.json unchanged`,192 接口 / 587 类型);`npx oxlint` **0 警告 0 错误**(2209 文件);逐包 test 全绿 —— core **1396** / 6 跳过 · ui **1043** · cli **561** · web **3187** / 2 跳过 · server **2937** / 4 跳过(hmr 无测试);真浏览器两态验证 dock 拖拽:改前带子中心命中框架、拖 120 px 高度变化 0,改后命中带子、**276 → 394**;端口只用 8950 / 8952,数据根 `/root/adelie-fork-data/r76-*` | 见本行提交 |+| 2026-10-18 | 5.48 | **结束的定时任务移入 `schedule/expired/`**(上游 `4b10a219` `#1159` 移植,照改动落、不是合分支;27 文件 / +644 −92,含 changelog 一对):`done` / `missed` / `expired` 三种状态统称 settled,文件**原样**移进 `agent_state/schedule/expired/` 并清掉运行状态,三处调用(对账、`listAgent`、`send` 的 `markFired` 之后与 `schedule_fired` 之前);同名不覆盖(UTC 戳后缀,再冲突 `-2`…),移动失败记 `schedule_archive_failed` 留着下轮再试;状态推导从路由搬进 `runtime/scheduler.ts`(`scheduleStatus()` / `isSettledStatus()`);**破坏性**:`POST` / `PUT` 对过去时刻的一次性任务与过去 `end_at` 返回 400(过去 API 写入的这类任务会立刻执行一次);Web 定时任务面板去掉「已完成」筛选、两份词典删 `filterCompleted`;CLI 帮助、AI 创建提示词、`penguin-orchestration` 技能与五份引擎文档(中英)跟上。**本树两处手写解决**:路由里那份 `statusOf()` 改导入共享函数;标签仍走 `scheduleFilterLabels()` 只删 `completed` 键 | 六包 `typecheck` **`EXIT=0`**(`src/ifaces.json unchanged`,192 接口 / 587 类型)· `npx oxlint` **0 警告 0 错误**(2209 文件)· 改动文件 `prettier --check` 干净 · `git diff --check` 干净 · 逐包 test **`EXIT=0`、0 失败**:server **201 文件 / 2946 通过 / 4 跳过**(+9 即本笔新用例)· core **1396** / 6 跳过 · ui **1043** · cli **561** · web **259 文件 / 3187 通过 / 2 跳过** · docs **62** · **真服务(8977,一次性数据根 `r77`)**:过去 `startAt` 的一次性任务 **400**、过去 `endAt` 的周期任务 **400**、合法周期任务 **201**;手写的过期一次性任务在下一次读取时已移入 `expired/`、**字节与原文相同**,`schedule/` 只剩周期任务,`scheduleCount` 与列表都只剩它 · **真界面**:`/schedules` 页与停靠栏面板都只剩 全部 / 生效中 / 已暂停(无「已完成」),两态 console **0 error**、无一条 ≥400,截图 `r77/{schedules-page,dock-schedules}.png` · 端口只用 8977(跑完即停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰 | 见本行提交 |> **2026-10-11 与另一条线的交汇(第三十七轮)**:定时任务触发时(07:00)`git status --short` **不干净**> —— 另一条线(会话 `session-2026-10-05-20-32-50-2ee69aba`)正在做**用户点单**的「回复能复制成纯文本」@@ -10377,3 +10389,74 @@ Escape 再来一次,四次的预算。连跑三次稳定。- 上游 `main` 仍是 **`0eafa6dc`**;桌上候选仍是「本树没有那个文件或常量」。- 卡点原地:**2.2c**(写侧全在桌面壳一侧与既有部署单元)、**3.5**(取哪个桌面壳)、**3.6**(模型 key)、**4.2** / **4.3**(明令不动)、**5.6** / **5.10**(促销搬进 Project 配置 / 新依赖 `mermaid`)。++## 第七十七轮:结束的定时任务移入 `schedule/expired/`(2026-10-18,条目 5.48)++### 开工自检与选活理由++- 同步:开工时 `git status --short` 干净,`main` 停在 `495550f3`,`git fetch origin && git merge --ff-only+ origin/main` = Already up to date(没切分支、没碰 `legacy/main`、没推 upstream)。+- 待办里最靠前的未勾选条目仍是 **2.2c**(剩下的活全在桌面壳一侧与既有部署单元里,本轮纪律不许碰 desktop),+ 其后 **3.5**(取哪个桌面壳要拍板)、**3.6**(模型 key)、**4.1–4.3**(明令不动)、**5.6** / **5.10**+ (要拍板 / 要新依赖)同样不可动;**7.2** 只剩 `llm-errors` 三条且等用户在同一节里给的 A / B 之间选。+- 上游 `main` 这次**往前走了**(上一轮记的 `0eafa6dc` 之后又有 6 笔,尖端 `ace1bca2`),逐笔量过:+ `b733cbdd`(流式文字淡入)要本树没有的 `stream-text.tsx`、`b79238f2`(粘性行的自定义背景)要本树没有的+ `wallpaper.css` / `wallpaper.tsx`、`bf710150`(附件瓦片,+1094)与 `61cd00bb`(切换 Project 的隔离,+ +1383 且重写我们改过的 `project-switch.spec.mjs`)都不是一轮的量、`ace1bca2` 修的是 `#1162` 那笔+ **我们没取**的双重编码(本树没有那些行,补丁无从落);剩下 `4b10a219` 逐字干净、只碰 server / web / cli /+ docs / 一个插件技能,于是选它 —— 而且它正是我们每天在用的那套定时任务。++### 落的是什么++- **归档**:`done`(触发过的一次性任务)、`missed`(停机期间错过的一次性任务)、`expired`(已过 `end_at`)+ 三种状态合称 settled,文件被**原样**移进 `agent_state/schedule/expired/`,其 `schedule_state` 行按「文件被+ 删除」处理。三处调用:对账(`evaluateEntry` 之后)、`listAgent`(`registerEntry` 之后,因此列表里永不出现)、+ `send`(`markFired` 之后、`schedule_fired` 之前,因此那个事件触发的重新拉取看不到它)。仍有排队待发的触发时+ 先发再移。无效与停用的任务不归档。+- **不覆盖**:`expired/` 里同名时改成 `<name>.<UTC 戳>.toml`,再冲突 `-2`、`-3`…;移动失败记+ `schedule_archive_failed`,任务留着,下一轮再试。+- **状态推导搬家**:`statusOf()` 从路由搬进 `runtime/scheduler.ts`,改名 `scheduleStatus()` 并导出,+ 另加 `isSettledStatus()`;路由改为导入它(这是本树与上游唯一的结构差异 —— 上游同一处也这么做,只是我们+ 的路由文件此前把函数放在自己里面)。+- **写侧收紧(破坏性)**:`POST` / `PUT` 对 `startAt` 已过的一次性任务、`endAt` 已过的任何任务返回 400。+ 过去 API 写入的一次性「过去时刻」任务会**立刻执行一次**(上游在同一提交里把这条前提写清楚了);本轮照它的+ 决定改成拒绝,「立刻跑一次」不再提供。+- **Web**:定时任务面板去掉「已完成」筛选(`ScheduleFilter` 三档、`filterBucket` 对 settled 返回 `null`,+ 只留在「全部」里);两份词典删掉 `filterCompleted`。本树的标签走 `scheduleFilterLabels()`(刻意在渲染时+ 读字典,好让切语言时跟着变),所以那一行按本树写法删 `completed` 键,不套上游的内联对象。+- **文案与文档**:CLI 的 `--start-at` 帮助(中英)、Web「用 AI 创建」的提示词(中英)、`penguin-orchestration`+ 技能(插件版本提到 `2026.10.18.1`)、引擎文档的 schedules / agents / cli / configuration / server-api(中英)。++### 验证++- 六包 `typecheck`:**`EXIT=0`**,`gen:ifaces` 报 `src/ifaces.json unchanged`(192 接口 / 587 类型)——+ 本笔不动服务契约(`scheduleStatus` 是运行时函数,不上线格式)。+- `npx oxlint`:**0 警告 0 错误**(2209 文件);改动文件的 `prettier --check` 干净,`git diff --check` 干净。+- 逐包 test:全部 `EXIT=0`、**0 失败** —— server **201 文件 / 2946 通过 / 4 跳过**(比上一轮 +9,正是本笔+ 新增的归档用例)· core **1396** / 6 跳过(68 文件)· ui **1043**(129)· cli **561**(38)· web+ **259 文件 / 3187 通过 / 2 跳过** · docs **62**(8 文件)。+- **真服务 + 真接口**(一次性数据根 `/root/adelie-fork-data/r77`、`localhost:8977`、`ADELIE_SEED_ADMIN_PASSWORD`):+ - `POST …/schedules` 一次性任务 `startAt=2020-01-01` → **400**「start_at is already past: a one-time task needs+ a future start time.」;+ - `POST …/schedules` 周期任务 `startAt=2020-01-01, period=1d, endAt=2021-01-01` → **400**「end_at is already+ past: the task would never fire again.」;+ - 合法周期任务(`startAt=2099, period=1d`)→ **201**,文件落在 `schedule/hourly-report.toml`;+ - **手写**一条过期一次性任务 `schedule/old-once.toml`(`start_at = "2020-01-01T00:00:00Z"`)→ 下一次读取时+ 已移进 `schedule/expired/old-once.toml`,**字节与原文逐字相同**,`schedule/` 下只剩周期任务,Agent 卡片+ `scheduleCount` 从 1(含旧的)变成 **1**(只剩 `hourly-report`),`GET …/schedules` 只返回 `hourly-report`。+- **真界面(真服务 + 真浏览器,Playwright)**:`/schedules` 页面与对话页右侧停靠栏的「定时任务」面板都只剩+ **全部 / 生效中 / 已暂停** 三个筛选项(没有「已完成」);页面列出 `hourly-report 每天 08:00 · 下次 2099 年1月1日+ 08:00`,归档的那条不在任何一处。两态 console 各 **0 error**、**无一条 ≥400**。截图+ `r77/schedules-page.png`、`r77/dock-schedules.png`、探针 `r77/probe.mjs` / `r77/probe-dock.mjs` 都在 scratchpad。+- 端口只用 8977(跑完已停),3003 / 3004 / 4000 / 7364 / 7369 一个没碰;数据只落在 `/root/adelie-fork-data/r77`。+- 没有切版本号、没发 npm、没发安装包、没发发布汇总。++### 下一轮从这里接++- 7.2 仍只剩 `llm-errors` ×3,仍要用户拍板(A:403 配额错误回到可重试;B:三条改写成「致命错误 + 模型页+ CTA」)。同时 `isAuthenticationError()` 的注释与 `isFatalProviderRejection()` 的口径仍互相矛盾,拍板时一起收。+- 上游新尖端 **`ace1bca2`**(本轮拉到):`b733cbdd` / `b79238f2` 要的前置本树没有(`stream-text.tsx`、+ `wallpaper.css` / `wallpaper.tsx`,即上游「自定义背景」那一整套),`bf710150` / `61cd00bb` 各是两轮的+ 量,`ace1bca2` 只修上游自己引入的双重编码 —— 都不适合下一轮直接取。+- 卡点原地:**2.2c**(写侧全在桌面壳一侧与既有部署单元)、**3.5**(取哪个桌面壳)、**3.6**(模型 key)、+ **4.2** / **4.3**(明令不动)、**5.6** / **5.10**(促销搬进 Project 配置 / 新依赖 `mermaid`)。diff --git a/packages/cli/src/i18n.ts b/packages/cli/src/i18n.tsindex 05c81db0..127183e4 100644--- a/packages/cli/src/i18n.ts+++ b/packages/cli/src/i18n.ts@@ -357,7 +357,7 @@ export interface Messages {rmDesc: string;/** --prompt: the text the firing sends. */prompt: string;- /** --start-at: first fire time, ISO 8601 — or the literal `now` for the current instant. */+ /** --start-at: first fire time, ISO 8601 — or the literal `now` for the current instant (a one-shot needs a future time, so `now` only suits a periodic task). */startAt: string;/** --period: fixed interval (30m / 12h / 1d / 7d, minimum 5m); omitted = one-shot. */period: string;@@ -1495,7 +1495,8 @@ const en: Messages = {"Update a scheduled task (read-modify-write: unspecified fields keep their stored values)",rmDesc: "Delete a scheduled task (no prompt; the server's owner authorization applies)",prompt: "The text each firing sends",- startAt: "First fire time (ISO 8601), or the literal `now` for the current instant",+ startAt:+ "First fire time (ISO 8601), or the literal `now` for the current instant; a one-shot task needs a future time, so `now` only works with --period",period: "Fixed interval, minimum 5m (e.g. 30m, 12h, 1d, 7d); omitted = one-shot",endAt: "Stop firing after this instant (ISO 8601)",sessionId: "Bind firings to one session (excludes --workspace / the model pair)",@@ -2595,7 +2596,8 @@ const zh: Messages = {updateDesc: "更新定时任务(读改写:未指定的字段保留存储值)",rmDesc: "删除定时任务(不做确认;服务端的 owner 授权照旧生效)",prompt: "每次触发要发送的内容",- startAt: "首次触发时刻(ISO 8601),或字面量 `now` 表示当前时刻",+ startAt:+ "首次触发时刻(ISO 8601),或字面量 `now` 表示当前时刻;一次性任务须用未来时刻,`now` 只适用于带 --period 的任务",period: "固定间隔,下限 5m(如 30m、12h、1d、7d);省略即一次性任务",endAt: "此时刻之后不再触发(ISO 8601)",sessionId: "绑定到某个会话触发(与 --workspace / 模型对互斥)",diff --git a/packages/docs/content/agents.en.md b/packages/docs/content/agents.en.mdindex 8ccbbdc5..e8d02976 100644--- a/packages/docs/content/agents.en.md+++ b/packages/docs/content/agents.en.md@@ -355,7 +355,7 @@ Only the Project owner can create a task manually.1. On the **Schedules** tab, select **Create manually**. The **New scheduled task** dialog opens.2. In **Name**, enter the task's file name, without `.toml`. You cannot change it later.3. In **Period**, enter how often the task runs, such as `30m`, `12h` or `7d`. Leave it empty for a one-off task. The shortest period is 5 minutes.-4. Set **Start at**, and optionally **End at**.+4. Set **Start at**, and optionally **End at**. A one-off task needs a **Start at** that is still ahead, and **End at** cannot be in the past.5. Under **Target**, choose where the prompt goes:- **New session each time**: every run starts a new Session. Optionally choose a **Model** (the Project default if you choose none) and a **Workspace** (a temporary Workspace if you choose none).- **Bound Session**: every run goes to one existing Session. Choose it in **Session**.@@ -366,7 +366,7 @@ To create a task by describing it instead, select **Create with AI**, or pick on### Manage scheduled tasks-The table shows each task's **Name**, **Status**, **Period**, **Target**, **Next / last fired** and **Queue**. The status is **Active**, **Disabled**, **Expired**, **Done**, **Missed** or **Invalid**; point at **Invalid** to see why.+The table shows each task's **Name**, **Status**, **Period**, **Target**, **Next / last fired** and **Queue**. The status is **Active**, **Disabled**, **Expired**, **Done**, **Missed** or **Invalid**; point at **Invalid** to see why. Done, missed and expired tasks are archived and soon leave the table; see [Finished tasks are archived](/schedules#finished-tasks-are-archived).On each row, the owner can select **Disable** or **Enable**, **Edit**, or **Delete**. Files that cannot be parsed are listed under **Files that failed to parse (skipped by the scheduler)**.diff --git a/packages/docs/content/agents.zh.md b/packages/docs/content/agents.zh.mdindex bf2df079..bd612878 100644--- a/packages/docs/content/agents.zh.md+++ b/packages/docs/content/agents.zh.md@@ -355,7 +355,7 @@ Adelie 依次连接每个 Server 并发现它的工具,不会保存任何内1. 在**定时任务**标签页选择**手动创建**,打开**新建定时任务**对话框。2. 在**名称**中输入任务的文件名,不带 `.toml`。创建后不能修改。3. 在**周期**中输入任务运行频率,例如 `30m`、`12h` 或 `7d`。一次性任务留空。最短周期为 5 分钟。-4. 设置**开始时间**,也可以设置**结束时间**。+4. 设置**开始时间**,也可以设置**结束时间**。一次性任务的**开始时间**必须晚于当前时刻,**结束时间**不能早于当前时刻。5. 在**目标**下选择提示词发到哪里:- **每次新建会话**:每次运行都新建一个 Session。可以再选 **Model**(不选就用 Project 默认值)和 **Workspace**(不选就用临时 Workspace)。- **绑定 Session**:每次运行都发给同一个已有的 Session。在 **Session** 中选择。@@ -366,7 +366,7 @@ Adelie 依次连接每个 Server 并发现它的工具,不会保存任何内### 管理定时任务-表格显示每个任务的**名称**、**状态**、**周期**、**目标**、**下次 / 最近触发**和**排队**。状态可能是**生效**、**停用**、**已过期**、**已完成**、**已错过**或**无效**;指向**无效**可查看原因。+表格显示每个任务的**名称**、**状态**、**周期**、**目标**、**下次 / 最近触发**和**排队**。状态可能是**生效**、**停用**、**已过期**、**已完成**、**已错过**或**无效**;指向**无效**可查看原因。已完成、已错过和已过期的任务会归档,随即移出表格,见[结束的任务会归档](/schedules#结束的任务会归档)。owner 可以在每一行选择**停用**或**启用**、**编辑**、**删除**。无法解析的文件列在「解析失败的文件(已跳过调度)」下。diff --git a/packages/docs/content/cli.en.md b/packages/docs/content/cli.en.mdindex 876cbe10..613879bd 100644--- a/packages/docs/content/cli.en.md+++ b/packages/docs/content/cli.en.md@@ -375,7 +375,7 @@ penguin schedule update <name> [options]penguin schedule rm <name> [--project-id <id>] [--agent-id <id>] [--json] [--server <url>]```-`penguin schedule ls` lists the scheduled tasks of all agents, or of one with `--agent-id`. Columns: agent, name, enabled, start time, period (`once` for one-shot tasks), target (a bound Session's short id, or `new session`), last fired, and a status marker for every state other than active (`expired`, `done`, `missed` or `invalid`). Schedule files that cannot be parsed are listed too, marked `invalid`.+`penguin schedule ls` lists the scheduled tasks of all agents, or of one with `--agent-id`. Columns: agent, name, enabled, start time, period (`once` for one-shot tasks), target (a bound Session's short id, or `new session`), last fired, and a status marker for every state other than active (`expired`, `done`, `missed` or `invalid`). Schedule files that cannot be parsed are listed too, marked `invalid`. Done, missed and expired tasks are archived by the server and soon drop out of the list; see [Finished tasks are archived](/schedules#finished-tasks-are-archived).`add`, `update` and `rm` go through the API, which writes the schedule's TOML file. The file stays the single source of truth, and the CLI acts as a validated writer, the same pattern model config and the vault follow: updates go through the system interface, validation happens at the interface layer, and hand edits stay possible. API errors are printed verbatim, so an agent gets validation right away instead of waiting for the reconcile pass that a hand edit goes through.@@ -384,9 +384,9 @@ Options of `add` and `update`:| Option | Description | Default || --- | --- | --- || `--prompt <text>` | The text each firing sends. Required on `add`. | — |-| `--start-at <ISO\|now>` | First fire time, in ISO 8601 or the literal `now` for the current instant. Required on `add`. | — |+| `--start-at <ISO\|now>` | First fire time, in ISO 8601 or the literal `now` for the current instant. A one-shot task needs a time that is still ahead, so `now` only suits a task with `--period`. Required on `add`. | — || `--period <duration>` | Fixed interval, at least `5m` (for example `30m`, `12h`, `1d`, `7d`). | One-shot |-| `--end-at <ISO>` | Stops firing after this instant. | — |+| `--end-at <ISO>` | Stops firing after this instant, which cannot be in the past. | — || `--session-id <id>` | Binds firings to one Session. Use either this or the new-session options, not both. | — || `--workspace <path>` / `--model-id <id> --provider <group>` | New-session mode: each firing creates a Session on this Workspace and model. The model pair is both-or-neither. | A temporary Workspace; the Project's default model || `--disabled` (`add`) | Creates the task disabled. | Enabled |@@ -399,7 +399,7 @@ Options of `add` and `update`:```bashpenguin schedule add daily-report --prompt "summarize the day" --start-at 2026-09-01T09:00:00Z --period 1d-penguin schedule add once-now --prompt "check the deploy" --start-at now --session-id 402a2e24+penguin schedule add deploy-watch --prompt "check the deploy" --start-at now --period 30m --session-id 402a2e24penguin schedule update daily-report --period 12h --disablepenguin schedule rm daily-report```diff --git a/packages/docs/content/cli.zh.md b/packages/docs/content/cli.zh.mdindex a2ab8431..0c7f9920 100644--- a/packages/docs/content/cli.zh.md+++ b/packages/docs/content/cli.zh.md@@ -375,7 +375,7 @@ penguin schedule update <name> [options]penguin schedule rm <name> [--project-id <id>] [--agent-id <id>] [--json] [--server <url>]```-`penguin schedule ls` 列出所有 Agent 的定时任务,用 `--agent-id` 可只看一个。各列为:Agent、名称、是否启用、开始时间、周期(一次性任务显示 `once`)、目标(绑定的 Session 短 id,或 `new session`)、上次触发时间,以及每个非 active 状态的标记(`expired`、`done`、`missed` 或 `invalid`)。无法解析的定时任务文件也会列出,并标记 `invalid`。+`penguin schedule ls` 列出所有 Agent 的定时任务,用 `--agent-id` 可只看一个。各列为:Agent、名称、是否启用、开始时间、周期(一次性任务显示 `once`)、目标(绑定的 Session 短 id,或 `new session`)、上次触发时间,以及每个非 active 状态的标记(`expired`、`done`、`missed` 或 `invalid`)。无法解析的定时任务文件也会列出,并标记 `invalid`。已完成、已错过和已过期的任务会由服务端归档,随即从列表中消失,见[结束的任务会归档](/schedules#结束的任务会归档)。`add`、`update` 和 `rm` 走 API,由 API 写入定时任务的 TOML 文件。文件始终是唯一事实来源,CLI 是经过校验的写入方——模型配置和 vault 都遵循这一模式:更新经由系统接口,校验发生在接口层,手工编辑依然可行。API 错误原样打印,Agent 立即得到校验结果,不必像手工编辑那样等下一轮对账。@@ -384,9 +384,9 @@ penguin schedule rm <name> [--project-id <id>] [--agent-id <id>] [--json] [--ser| 选项 | 说明 | 默认值 || --- | --- | --- || `--prompt <text>` | 每次触发发送的文本。`add` 必填。 | — |-| `--start-at <ISO\|now>` | 首次触发时间,ISO 8601 格式,或用字面量 `now` 表示当前时刻。`add` 必填。 | — |+| `--start-at <ISO\|now>` | 首次触发时间,ISO 8601 格式,或用字面量 `now` 表示当前时刻。一次性任务的时间必须晚于当前时刻,因此 `now` 只适用于带 `--period` 的任务。`add` 必填。 | — || `--period <duration>` | 固定间隔,至少 `5m`(例如 `30m`、`12h`、`1d`、`7d`)。 | 一次性 |-| `--end-at <ISO>` | 这个时刻之后不再触发。 | — |+| `--end-at <ISO>` | 这个时刻之后不再触发,不能早于当前时刻。 | — || `--session-id <id>` | 把每次触发绑定到一个 Session。只能在它和新建 Session 选项之间二选一。 | — || `--workspace <path>` / `--model-id <id> --provider <group>` | 新建 Session 模式:每次触发都在这个 Workspace 和模型上创建一个 Session。模型对要么都给,要么都不给。 | 临时 Workspace;Project 的默认模型 || `--disabled`(`add`) | 创建时即处于禁用状态。 | 启用 |@@ -399,7 +399,7 @@ penguin schedule rm <name> [--project-id <id>] [--agent-id <id>] [--json] [--ser```bashpenguin schedule add daily-report --prompt "summarize the day" --start-at 2026-09-01T09:00:00Z --period 1d-penguin schedule add once-now --prompt "check the deploy" --start-at now --session-id 402a2e24+penguin schedule add deploy-watch --prompt "check the deploy" --start-at now --period 30m --session-id 402a2e24penguin schedule update daily-report --period 12h --disablepenguin schedule rm daily-report```diff --git a/packages/docs/content/configuration.en.md b/packages/docs/content/configuration.en.mdindex 6d8a75df..584ec71d 100644--- a/packages/docs/content/configuration.en.md+++ b/packages/docs/content/configuration.en.md@@ -516,6 +516,8 @@ Each file `agent_state/schedule/<name>.toml` describes one scheduled task, whichWrite both `provider` and `model_id`, or neither. A lone `model_id` is rejected; with neither, the Project's default model is used.+A task that can never fire again — a one-shot task that has fired or was missed, or a task past `end_at` — is moved, unchanged, into `agent_state/schedule/expired/` by the scheduler; see [Finished tasks are archived](/schedules#finished-tasks-are-archived).+```tomlprompt = "Check yesterday's builds and summarize the failures"enabled = truediff --git a/packages/docs/content/configuration.zh.md b/packages/docs/content/configuration.zh.mdindex ee925c28..7f888e16 100644--- a/packages/docs/content/configuration.zh.md+++ b/packages/docs/content/configuration.zh.md@@ -516,6 +516,8 @@ frontmatter 就只有这三个字段。记忆属于哪个作用域由所在目`provider` 和 `model_id` 要么都写,要么都不写。只写 `model_id` 的文件无效;两者都不写时使用 Project 的默认模型。+不会再触发的任务——已触发或已错过的一次性任务,以及已过 `end_at` 的任务——会由调度器原样移进 `agent_state/schedule/expired/`,见[结束的任务会归档](/schedules#结束的任务会归档)。+```tomlprompt = "Check yesterday's builds and summarize the failures"enabled = truediff --git a/packages/docs/content/schedules.en.md b/packages/docs/content/schedules.en.mdindex 034db8de..4116d341 100644--- a/packages/docs/content/schedules.en.md+++ b/packages/docs/content/schedules.en.md@@ -11,6 +11,7 @@ A scheduled task sends a prompt to an agent at a set time, once or on a repeatin- To see a conversation's tasks, see [Open the Scheduled tasks panel](#open-the-scheduled-tasks-panel).- To add a task, see [Create a task with AI](#create-a-task-with-ai) or [Create a task manually](#create-a-task-manually).- To pause, change or remove a task, see [Turn a task on or off](#turn-a-task-on-or-off) and [Edit or delete a task](#edit-or-delete-a-task).+- To find a task that has finished, see [Finished tasks are archived](#finished-tasks-are-archived).## Open the Scheduled tasks panel@@ -20,7 +21,7 @@ The panel is one of the side panels of the chat page. It is available once the c2. In the top-right corner of the chat toolbar, select **Right sidebar** or **Bottom panel**. You can also use the **Shortcuts** launcher on the conversation's right edge.3. Choose **Scheduled tasks**. If the side panel already shows other panels, select **Add panel** first.-The panel lists the tasks bound to this conversation. The search box matches a task's name and its prompt. The filters are **All**, **Active**, **Paused** and **Completed**; **Completed** covers tasks that are done, expired or missed. Each row shows a state icon, the task name and its schedule in plain words, for example:+The panel lists the tasks bound to this conversation. The search box matches a task's name and its prompt. The filters are **All**, **Active** and **Paused**. Tasks that are done, missed or past their end time leave the list; see [Finished tasks are archived](#finished-tasks-are-archived). Each row shows a state icon, the task name and its schedule in plain words, for example:- "Every day at 08:00 · Next: tomorrow 08:00"- "Every 30 minutes"@@ -54,7 +55,7 @@ Below the list, **Suggestions** offers four ready-made requests: **Daily brief**2. Fill in the form. It is the same form as on the agent's settings page, with **Target** set to **This conversation**:- **Name** (required): the task's file name. It cannot be changed later.- **Period**: `30m`, `12h`, `7d` and so on. Leave it empty for a one-off task.- - **Start at** (required) and, optionally, **End at**.+ - **Start at** (required) and, optionally, **End at**. A one-off task needs a start time that is still ahead, and the end time cannot be in the past: saving refuses either.- **Prompt** (required): what to send to the agent.- **Enabled**: whether the task is on.3. Select **Create**.@@ -72,6 +73,16 @@ In the panel, use the switch on the task's row. The change takes effect at once:1. In the panel, open the **More actions** menu on the task's row.2. Select **Edit**, or select **Delete** and confirm.+## Finished tasks are archived++A task that can never fire again is moved out of the lists: a one-off task that has run, a one-off task whose time passed while the service was stopped, and a task past its end time. The scheduler moves its file, unchanged, into the agent's `agent_state/schedule/expired/` folder. A one-off task moves as soon as it runs. A task with a queued run moves once that run is sent.++An archived task leaves every list and count: this panel, the agent's **Schedules** tab and its card on the **Agents** page, the alarm clock mark, the schedules API and `penguin schedule ls`. The list of scheduled tasks in the agent's system prompt drops it from the next model context. The file stays on disk.++To bring a task back, edit the times in its file so it can fire again, then move the file back into `agent_state/schedule/`, named `<name>.toml`. An archived file carries a time suffix when an older copy was already in `expired/`; drop the suffix when you move it back. A file moved back with its times still past is archived again.++A task that is switched off, or whose conversation was deleted, is not archived: turn it back on or change its target, and it fires again.+## The alarm clock markIn the sidebar's conversation list, a conversation shows an alarm clock icon while it has a bound task that still has a next fire time. The mark appears whichever agent the conversation belongs to and however the list is grouped. It shows no count.@@ -101,8 +112,8 @@ Nothing on the overview creates, edits or deletes a task: creating one picks an- A repeating task runs at most once every 5 minutes: the shortest period is 5 minutes. A shorter period makes the task invalid.- Tasks run only while the Adelie service is running.-- Missed runs are not made up. When a fire time passes while the service is stopped, a repeating task skips it and a one-off task is marked missed.+- Missed runs are not made up. When a fire time passes while the service is stopped, a repeating task skips it and a one-off task is marked missed and archived.## How it works-Each task is a TOML file under the agent's `agent_state/schedule/` directory. The file format is described in the [Configuration Reference](/configuration#schedules). The scheduler checks the files every 30 seconds, so a file you edit by hand takes effect at the next check.+Each task is a TOML file under the agent's `agent_state/schedule/` directory. The file format is described in the [Configuration Reference](/configuration#schedules). The scheduler checks the files every 30 seconds, so a file you edit by hand takes effect at the next check. Archived tasks sit in the `expired/` subfolder, which the scheduler never reads.diff --git a/packages/docs/content/schedules.zh.md b/packages/docs/content/schedules.zh.mdindex d16f6b17..fd70f6c6 100644--- a/packages/docs/content/schedules.zh.md+++ b/packages/docs/content/schedules.zh.md@@ -11,6 +11,7 @@ description: 让 Agent 按设定的时间在对话中执行 Prompt,并在对- 查看一段对话的任务,见[打开定时任务面板](#打开定时任务面板)。- 添加任务,见[用 AI 创建任务](#用-ai-创建任务)或[手动创建任务](#手动创建任务)。- 暂停、修改或移除任务,见[开启或关闭任务](#开启或关闭任务)和[编辑或删除任务](#编辑或删除任务)。+- 查找已经结束的任务,见[结束的任务会归档](#结束的任务会归档)。## 打开定时任务面板@@ -20,7 +21,7 @@ description: 让 Agent 按设定的时间在对话中执行 Prompt,并在对2. 在对话工具栏右上角选择**右侧栏**或**下侧栏**。也可以点对话区右缘的**快捷方式**悬浮球。3. 选择**定时任务**。如果侧栏里已经有别的面板,先选择**添加面板**。-面板列出绑定到这段对话的任务。搜索框同时匹配任务名称和 Prompt。筛选项有**全部**、**生效中**、**已暂停**和**已完成**,其中**已完成**包括已执行完、已过期和已错过的任务。每行显示状态图标、任务名称和一句话描述的执行时间,例如:+面板列出绑定到这段对话的任务。搜索框同时匹配任务名称和 Prompt。筛选项有**全部**、**生效中**和**已暂停**。已执行完、已错过和已过结束时间的任务会移出列表,见[结束的任务会归档](#结束的任务会归档)。每行显示状态图标、任务名称和一句话描述的执行时间,例如:- 「每天 08:00 · 下次 明天 08:00」- 「每 30 分钟」@@ -54,7 +55,7 @@ Project 的所有成员都可以用这种方式创建任务。创建由这段对2. 填写表单。表单与 Agent 设置页上的相同,**目标**固定为**本对话**:- **名称**(必填):任务的文件名,创建后不能修改。- **周期**:如 `30m`、`12h`、`7d`。一次性任务留空。- - **开始时间**(必填),以及可选的**结束时间**。+ - **开始时间**(必填),以及可选的**结束时间**。一次性任务的开始时间必须晚于当前时刻,任何任务的结束时间都不能早于当前时刻,否则无法保存。- **Prompt**(必填):发给 Agent 的内容。- **启用**:任务是否开启。3. 选择**创建**。@@ -72,6 +73,16 @@ Project 的所有成员都可以用这种方式创建任务。创建由这段对1. 在面板中打开任务所在行的**更多操作**菜单。2. 选择**编辑**;或者选择**删除**,再确认。+## 结束的任务会归档++不会再触发的任务会移出列表:已经执行过的一次性任务、在服务停止期间错过时间的一次性任务,以及已过结束时间的任务。调度器把任务文件原样移进该 Agent 的 `agent_state/schedule/expired/` 文件夹。一次性任务执行后随即移走;有排队待发的运行时,等这次运行发出后再移走。++归档的任务不再出现在任何列表和计数里:本面板、Agent 的**定时任务**标签页及其在**智能体**页上的卡片、闹钟标记、schedules API 以及 `penguin schedule ls`。Agent 系统提示词里的定时任务清单也从下一个模型上下文起不再列出它。文件仍保留在磁盘上。++要恢复一个任务,先在文件里把时间改到仍能触发的时刻,再把文件移回 `agent_state/schedule/`,命名为 `<name>.toml`。`expired/` 里已有同名的旧文件时,归档文件名会带上时间后缀,移回时去掉后缀即可。时间仍已过去的文件移回后会再次归档。++已关闭的任务和所绑定对话已被删除的任务不会归档:重新开启或改换目标后,它们会继续触发。+## 闹钟标记侧边栏的对话列表里,只要某段对话绑定的任务还有下一次触发时间,这段对话就会显示一个闹钟图标。不论对话属于哪个 Agent、列表怎样分组,都会显示这个标记,但标记不带数量。@@ -101,8 +112,8 @@ Project 的所有成员都可以用这种方式创建任务。创建由这段对- 周期性任务最快每 5 分钟运行一次,即最短周期为 5 分钟。周期短于 5 分钟的任务会被判为无效。- 定时任务只在 Adelie 服务运行期间执行。-- 错过的运行不会补跑。服务停止期间错过的触发时间,周期性任务直接跳过,一次性任务标记为已错过。+- 错过的运行不会补跑。服务停止期间错过的触发时间,周期性任务直接跳过,一次性任务标记为已错过并归档。## 工作原理-每个任务是 Agent 的 `agent_state/schedule/` 目录下的一个 TOML 文件,文件格式见[配置参考](/configuration#定时任务)。调度器每 30 秒检查一次这些文件,因此手动编辑的文件会在下一次检查时生效。+每个任务是 Agent 的 `agent_state/schedule/` 目录下的一个 TOML 文件,文件格式见[配置参考](/configuration#定时任务)。调度器每 30 秒检查一次这些文件,因此手动编辑的文件会在下一次检查时生效。归档的任务放在 `expired/` 子文件夹里,调度器从不读取它。diff --git a/packages/docs/content/server-api.en.md b/packages/docs/content/server-api.en.mdindex a531149c..6cafe954 100644--- a/packages/docs/content/server-api.en.md+++ b/packages/docs/content/server-api.en.md@@ -557,6 +557,8 @@ Schedule writes are owner only. A task in new-Session mode carries `modelId` and`GET /api/schedules` (with no Project prefix) is the cross-Project read-only overview: one answer holding every Project the caller may reach, each with its own `schedules` and `invalidFiles`, with every row's status derived against one instant. That path has no write verb; a write still names exactly one Project's prefix.+A `POST` or `PUT` is refused with 400 when `startAt` has passed on a one-shot task, or `endAt` has passed on any task. The listings never include a task that is done, missed or expired: the scheduler archives its file into `agent_state/schedule/expired/` (see [Finished tasks are archived](/schedules#finished-tasks-are-archived)), so such a task only shows while a queued fire is still to be sent, or if the move failed.+## BenchmarksBenchmarks belong to the Project, not to an agent: one Benchmark can evaluate any number of agents, and each evaluation names the agent it tested (`agentId`, or `null` for a record that names none). A summary's `agentIds` lists those agents in the order they first appear. The paths below again omit the `/api/projects/:projectId` prefix.diff --git a/packages/docs/content/server-api.zh.md b/packages/docs/content/server-api.zh.mdindex e3bba183..70e6b438 100644--- a/packages/docs/content/server-api.zh.md+++ b/packages/docs/content/server-api.zh.md@@ -557,6 +557,8 @@ interface AgentApiKeyInfo {`GET /api/schedules`(不带 Project 前缀)是跨项目只读总览:返回调用者能访问的每个 Project,各自带上它自己的 `schedules` 与 `invalidFiles`,一次请求读完,所有行的状态按同一时刻计算。这条路径只有 GET,写操作仍然只有一个 Project 的前缀。+一次性任务的 `startAt` 已过,或任何任务的 `endAt` 已过时,`POST` 和 `PUT` 返回 400。列表从不包含已完成、已错过或已过期的任务:调度器会把其文件归档到 `agent_state/schedule/expired/`(见[结束的任务会归档](/schedules#结束的任务会归档)),所以这类任务只在仍有排队待发的触发、或移动失败时才会出现。+## BenchmarkBenchmark 属于 Project,不属于某个 Agent:一个 Benchmark 可以评估任意多个 Agent,每次评估都会记录它测试的 Agent(`agentId`;没有对应 Agent 的记录为 `null`)。汇总中的 `agentIds` 按这些 Agent 首次出现的顺序排列。下面的路径同样省略了 `/api/projects/:projectId` 前缀。diff --git a/packages/server/src/api/types.ts b/packages/server/src/api/types.tsindex 618904c2..a49b8a5c 100644--- a/packages/server/src/api/types.ts+++ b/packages/server/src/api/types.ts@@ -1411,7 +1411,7 @@ export interface AgentSummary {kernelOutdated: boolean;/** Vault key count (number of keys in agent_state/.vault.toml). */vaultKeyCount: number;- /** Schedule count (number of .toml files under agent_state/schedule/, including invalid ones). */+ /** Schedule count (number of .toml files directly under agent_state/schedule/, including invalid ones; archived files under schedule/expired/ are not counted). */scheduleCount: number;/** Installed Skill count (number of agent_state/skills/<name>/ directories with a SKILL.md). */skillCount: number;@@ -4105,7 +4105,11 @@ export interface UsageResponse {// Schedule// ----------------------------------------------------------------------------/** Display-facing schedule status: the file's `enabled` only expresses intent; the rest is derived from runtime state. */+/**+ * Display-facing schedule status: the file's `enabled` only expresses intent; the rest is derived from runtime state.+ * The scheduler archives an agent's settled tasks (done / missed / expired) into `schedule/expired/`, so the agent+ * listings show those three only while a queued fire is still to be sent or when the move failed.+ */export type ScheduleStatus = "active" | "disabled" | "expired" | "done" | "missed" | "invalid";export interface ScheduleItem {diff --git a/packages/server/src/http/routes/schedules.ts b/packages/server/src/http/routes/schedules.tsindex 2705259f..837ae9de 100644--- a/packages/server/src/http/routes/schedules.ts+++ b/packages/server/src/http/routes/schedules.ts@@ -8,6 +8,10 @@* Any member can read; only the owner can modify. The file is declarative intent:* POST/PUT fully replace the file, validation always goes through parseScheduleFile* (same rules as hand-edited files), and writes take effect immediately via reconciliation.+ * Two writes are refused: any task whose end_at is already past (it could never fire, and the+ * scheduler would archive it the moment it landed), and a one-shot whose start_at is already+ * past (it would fire immediately; "run once now" is not offered — user decision 2026-10-15).+ * Settled tasks are archived by the scheduler, so no listing here ever shows one.*/import { createHash } from "node:crypto";import { Hono } from "hono";@@ -54,6 +58,7 @@ import {validateScheduleModelRef,writeScheduleFile,} from "../../runtime/schedule-store.js";+import { scheduleStatus } from "../../runtime/scheduler.js";import { Bind, Component, Use } from "@adelie/core/kernel";import type { Config } from "../../hmr/capabilities.js";import type { Access, ProjectConfigStore } from "../../mechanisms/projects.js";@@ -114,15 +119,6 @@ function nextFireAt(return next !== null ? new Date(next).toISOString() : undefined;}-/** Displayed status precedence: invalid > done/missed (one-shot) > expired > enabled flag. */-function statusOf(def: ScheduleDefinition, state: ScheduleStateRow, nowMs: number): ScheduleStatus {- if (state.invalidReason !== null) return "invalid";- if (def.periodMs === undefined && state.firedOnce) return "done";- if (def.periodMs === undefined && state.missed) return "missed";- if (def.endAtMs !== undefined && nowMs > def.endAtMs) return "expired";- return def.enabled ? "active" : "disabled";-}-function toItem(def: ScheduleDefinition,state: ScheduleStateRow,@@ -141,7 +137,7 @@ function toItem(...(def.workspace !== undefined ? { workspace: def.workspace } : {}),...(def.modelId !== undefined ? { modelId: def.modelId } : {}),...(def.provider !== undefined ? { provider: def.provider } : {}),- status: statusOf(def, state, nowMs),+ status: scheduleStatus(def, state, nowMs),...(state.invalidReason !== null ? { invalidReason: state.invalidReason } : {}),...(next !== undefined ? { nextFireAt: next } : {}),...(state.lastFiredAt !== null ? { lastFiredAt: state.lastFiredAt } : {}),@@ -316,6 +312,16 @@ async function upsert(const raw = serializeSchedule(fields);const parsed = parseScheduleFile(name, raw);if (!parsed.ok) throw badRequest(`Invalid schedule configuration: ${parsed.error}`);+ // A one-shot in the past would fire at once (not offered); a past end_at could never fire.+ const nowMs = Date.now();+ if (parsed.def.periodMs === undefined && parsed.def.startAtMs <= nowMs) {+ throw badRequest("start_at is already past: a one-time task needs a future start time.");+ }+ if (parsed.def.endAtMs !== undefined && parsed.def.endAtMs <= nowMs) {+ throw badRequest(+ "end_at is already past: the task would never fire again. Pick a later end time, or delete the task.",+ );+ }// At save time, verify the (provider, modelId) pair names a configured model (same rules as reconciliation) so we never persist a broken file.// The pairing rule itself is enforced by parseScheduleFile above, which rejects half a reference.const refError = await validateScheduleModelRef(deps.projectConfigService, projectId, parsed.def);diff --git a/packages/server/src/runtime/schedule-file.ts b/packages/server/src/runtime/schedule-file.tsindex 0f3779ec..77bbdd51 100644--- a/packages/server/src/runtime/schedule-file.ts+++ b/packages/server/src/runtime/schedule-file.ts@@ -1,8 +1,9 @@/*** Schedule file parsing, validation, and trigger-time computation.*- * `agent_state/schedule/<name>.toml` is declarative intent; the system never writes it- * back. This module does pure parsing and pure time math only: an invalid file returns+ * `agent_state/schedule/<name>.toml` is declarative intent; the system never rewrites its+ * content (a settled task's file is only moved, unchanged, into `schedule/expired/`). This+ * module does pure parsing and pure time math only: an invalid file returns* an error (the scheduler skips it and records the error); runtime state (fired /* missed / disabled) doesn't live here — it belongs to SQLite (db/repos/schedules.ts).* Docs: /docs/configuration § "Schedules".diff --git a/packages/server/src/runtime/schedule-store.ts b/packages/server/src/runtime/schedule-store.tsindex f770ae51..d38b3e29 100644--- a/packages/server/src/runtime/schedule-store.ts+++ b/packages/server/src/runtime/schedule-store.ts@@ -2,8 +2,10 @@* Schedule file access: `agent_state/schedule/<name>.toml`, where* the filename (a semantic name) is the identity. Reads are fault-tolerant (an invalid* file is recorded as an error and skipped by the caller); writes only go through the- * API routes (the system never rewrites existing file content — PUT is a full-file- * replacement expressing user intent).+ * API routes (the system never rewrites a file's content — PUT is a full-file+ * replacement expressing user intent). The one thing the scheduler does to a file on its+ * own is move a settled task's file, unchanged, into `schedule/expired/`+ * (archiveScheduleFile); nothing reads that subdirectory back.*/import fs from "node:fs/promises";import path from "node:path";@@ -267,6 +269,61 @@ export async function writeScheduleFile(await atomicWriteFile(path.join(dir, `${name}.toml`), raw, { followSymlinks: true });}+/** Subdirectory of `schedule/` that settled task files are archived into (never scanned: every listing reads top-level files only). */+export const EXPIRED_SCHEDULE_DIR = "expired";++/** `20261015T093000Z`: the archive instant as a file-name suffix (UTC, no separators). */+function archiveStamp(nowMs: number): string {+ return new Date(nowMs)+ .toISOString()+ .replace(/\.\d{3}Z$/, "Z")+ .replace(/[-:]/g, "");+}++async function pathExists(file: string): Promise<boolean> {+ try {+ await fs.lstat(file);+ return true;+ } catch {+ return false;+ }+}++/**+ * Archive a settled task: move `<name>.toml`, unchanged, into `schedule/expired/`. It never+ * overwrites — when `expired/<name>.toml` is already there, the moved file becomes+ * `<name>.<UTC stamp>.toml`, then `<name>.<UTC stamp>-2.toml` and so on. Returns false when the+ * source file is already gone; any other failure throws.+ */+export async function archiveScheduleFile(+ root: string,+ projectId: string,+ agentId: string,+ name: string,+ nowMs: number,+): Promise<boolean> {+ const dir = scheduleDir(root, projectId, agentId);+ const source = path.join(dir, `${name}.toml`);+ if (!(await pathExists(source))) return false;+ const archive = path.join(dir, EXPIRED_SCHEDULE_DIR);+ await fs.mkdir(archive, { recursive: true });+ let target = path.join(archive, `${name}.toml`);+ const stamp = archiveStamp(nowMs);+ for (let n = 1; await pathExists(target); n += 1) {+ target = path.join(archive, `${name}.${stamp}${n === 1 ? "" : `-${n}`}.toml`);+ }+ try {+ await fs.rename(source, target);+ } catch (err) {+ // Deleted (or archived by a concurrent pass) since the check above: nothing left to move.+ if ((err as NodeJS.ErrnoException).code === "ENOENT" && !(await pathExists(source))) {+ return false;+ }+ throw err;+ }+ return true;+}+/** Delete a schedule file; returns false if it doesn't exist. */export async function deleteScheduleFile(root: string,diff --git a/packages/server/src/runtime/scheduler.ts b/packages/server/src/runtime/scheduler.tsindex bbba0129..73034165 100644--- a/packages/server/src/runtime/scheduler.ts+++ b/packages/server/src/runtime/scheduler.ts@@ -4,8 +4,8 @@* `schedule/` directory.** Key semantics:- * - Intent vs state are separate: the file is declarative intent (never written back by the system);- * run state lives in SQLite.+ * - Intent vs state are separate: the file is declarative intent (the system never rewrites its+ * content); run state lives in SQLite.* - No backfill for missed fires: any due time earlier than when this scheduler first learned of the* task (startup reconcile / first registration / start_at reset) is skipped — periodic tasks advance* last_slot straight to now, one-shot tasks are marked missed.@@ -13,6 +13,12 @@* the wait only advance, they don't stack), and send once it becomes idle.* - Bound Session deleted: record an error and mark invalid; editing the file re-activates it via reconcile.* - Deleting the file removes the task; reconcile also cleans up its SQLite run state and queue entry.+ * - Settled tasks are archived: a one-shot that fired (done), a one-shot whose time passed unseen+ * (missed) and a task past end_at (expired) can never fire again, so reconcile and the listings+ * move the file unchanged into `schedule/expired/` and drop its run state, as for a deleted file.+ * A one-shot moves right after it fires, before `schedule_fired` goes out, so the refetch that+ * event triggers no longer lists it; a task with a queued fire waits until that fire is sent.+ * Invalid and disabled tasks stay: fixing the target or re-enabling brings them back.** The periodic scan is mtime-gated (trace-index house pattern): the agents-dir* listing and each Agent's parsed schedule files are cached and revalidated by stat,@@ -27,9 +33,14 @@ import { cacheable, statMtime } from "../internal/mtime-gate.js";import type { ErrorSink } from "./error-recorder.js";import type { ScheduleDefinition } from "./schedule-file.js";import { latestSlotAt, slotInWindow } from "./schedule-file.js";-import { ScheduleFileCache, readScheduleFile, validateScheduleModelRef } from "./schedule-store.js";+import {+ ScheduleFileCache,+ archiveScheduleFile,+ readScheduleFile,+ validateScheduleModelRef,+} from "./schedule-store.js";import type { ScheduleConfigSource } from "./schedule-store.js";-import type { ScheduleServerEvent } from "../api/types.js";+import type { ScheduleServerEvent, ScheduleStatus } from "../api/types.js";import { Component, Interface, Use } from "@adelie/core/kernel";import type { ClassCtx } from "@adelie/core/kernel";import { userChannelKey } from "../http/routes/events.js";@@ -88,6 +99,24 @@ interface PendingFire {sessionId: string;}+/** Displayed status precedence: invalid > done/missed (one-shot) > expired > enabled flag. */+export function scheduleStatus(+ def: ScheduleDefinition,+ state: ScheduleStateRow,+ nowMs: number,+): ScheduleStatus {+ if (state.invalidReason !== null) return "invalid";+ if (def.periodMs === undefined && state.firedOnce) return "done";+ if (def.periodMs === undefined && state.missed) return "missed";+ if (def.endAtMs !== undefined && nowMs > def.endAtMs) return "expired";+ return def.enabled ? "active" : "disabled";+}++/** Settled = can never fire again without a file edit (done / missed / expired): the statuses the scheduler archives. */+export function isSettledStatus(status: ScheduleStatus): boolean {+ return status === "done" || status === "missed" || status === "expired";+}+/** In-memory view of a registered task (definition + run state + queued flag). */export interface ScheduleEntryView {def: ScheduleDefinition;@@ -210,6 +239,9 @@ export class Scheduler implements Scheduling {continue;}const state = this.registerEntry(projectId, agentId, owner, file.parsed.def, file.raw);+ // A settled task is archived here too, so no listing ever shows one (a task found already+ // past at its first registration lands here); it stays listed only while it cannot move.+ if (await this.archiveIfSettled(projectId, agentId, file.parsed.def)) continue;entries.push({def: file.parsed.def,state,@@ -330,6 +362,7 @@ export class Scheduler implements Scheduling {}const state = this.registerEntry(projectId, agentId, ownerUserId, def, file.raw);await this.evaluateEntry(projectId, agentId, def, state);+ await this.archiveIfSettled(projectId, agentId, def);}this.cleanupMissing(projectId,@@ -368,6 +401,39 @@ export class Scheduler implements Scheduling {return this.repo.find(projectId, agentId, def.name) ?? row;}+ /**+ * Archive a settled task (done / missed / expired): move its file unchanged into+ * `schedule/expired/` and drop its run state, exactly as if the file had been deleted.+ * Returns true when the task is gone from `schedule/` (archived now, or already gone), false+ * when it stays: not settled, a fire still queued for it (sent first; the send archives it), or+ * the move failed (recorded; the next pass tries again).+ */+ private async archiveIfSettled(+ projectId: string,+ agentId: string,+ def: ScheduleDefinition,+ ): Promise<boolean> {+ const state = this.repo.find(projectId, agentId, def.name);+ if (!state) return true;+ if (!isSettledStatus(scheduleStatus(def, state, this.now()))) return false;+ if (this.pending.has(this.keyOf(projectId, agentId, def.name))) return false;+ try {+ await archiveScheduleFile(this.root, projectId, agentId, def.name, this.now());+ } catch (err) {+ const reason = err instanceof Error ? err.message : String(err);+ this.errors.record({+ source: "schedule",+ err: new Error(`Could not archive ${def.name}.toml into schedule/expired/ — ${reason}`),+ code: "schedule_archive_failed",+ ctx: { projectId, agentId },+ });+ return false;+ }+ this.repo.delete(projectId, agentId, def.name);+ this.files.invalidate(projectId, agentId);+ return true;+ }+/** Clean up run state and queue entries for deleted files (deleting a file removes the task). */private cleanupMissing(projectId: string, agentId: string, presentNames: string[]): void {const removed = this.repo.deleteMissing(projectId, agentId, presentNames);@@ -477,6 +543,10 @@ export class Scheduler implements Scheduling {return;}this.repo.markFired(projectId, agentId, def.name, firedAt, def.periodMs === undefined);+ // A one-shot is settled the moment it fires (as is a periodic task whose last fire went out+ // after end_at): archive it before the event, or the refetch the event triggers would still+ // list it as done.+ await this.archiveIfSettled(projectId, agentId, def);this.notifyFor(state, {type: "schedule_fired",projectId,diff --git a/packages/server/src/services/agent-service.ts b/packages/server/src/services/agent-service.tsindex 10311a48..a594756d 100644--- a/packages/server/src/services/agent-service.ts+++ b/packages/server/src/services/agent-service.ts@@ -81,7 +81,7 @@ export interface AgentListItem {kernelOutdated: boolean;/** Number of vault keys. */vaultKeyCount: number;- /** Number of scheduled tasks (count of .toml files under schedule/, including invalid ones). */+ /** Number of scheduled tasks (count of .toml files directly under schedule/, including invalid ones; archived files under schedule/expired/ are not counted). */scheduleCount: number;/** Number of installed Skills (count of skills/<name>/ directories that contain a SKILL.md). */skillCount: number;@@ -191,7 +191,7 @@ export class AgentService implements AgentLifecycle {}}- /** Number of scheduled tasks: count of .toml files under schedule/ (0 if the directory doesn't exist). */+ /** Number of scheduled tasks: count of .toml files directly under schedule/ (0 if the directory doesn't exist). The expired/ subdirectory of archived files is not a .toml name, so it is never counted. */private async scheduleCount(projectId: string, agentId: string): Promise<number> {try {const names = await fs.readdir(scheduleDir(this.root, projectId, agentId));diff --git a/packages/server/test/scheduler.test.ts b/packages/server/test/scheduler.test.tsindex 1dd31ba6..acc3fcd6 100644--- a/packages/server/test/scheduler.test.ts+++ b/packages/server/test/scheduler.test.ts@@ -1,12 +1,23 @@/*** Scheduler runtime semantics: missed slots are not- * backfilled; a one-shot task registered after its time is marked missed- * immediately; periodic stepping never fires twice for the same slot; a busy+ * backfilled; periodic stepping never fires twice for the same slot; a busy* target queues and sends once idle; a deleted bound Session marks the task* invalid, recoverable by editing the file; deleting the file clears the run* state; new-Session mode; event notifications.+ *+ * Archiving settled tasks into `schedule/expired/`:+ * - A fired one-shot is archived before `schedule_fired` reaches the user, and it is gone from the+ * listing and from SQLite; it never fires again.+ * - A one-shot found already past at registration is archived, not listed as missed.+ * - A periodic task past end_at is archived by the reconcile pass.+ * - An expired periodic task with a queued fire stays until that fire is sent, then is archived.+ * - Disabled and invalid tasks stay, even once their time has passed.+ * - A clash in `expired/` keeps every file: the newcomer takes a timestamped name.+ * - A file moved back with its time still past is archived again, without firing twice.+ * - When the move fails, the error is recorded, the task stays listed, and a later pass archives it.* All tests use doubles and a controlled clock — no real LLM / core Session.*/+import { existsSync } from "node:fs";import fs from "node:fs/promises";import path from "node:path";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";@@ -48,6 +59,8 @@ describe("scheduler", () => {source?: "schedule";}>;let events: Array<{ userId: string; event: ScheduleServerEvent }>;+ /** Runs inside the notification itself: what a client refetching on the event would see. */+ let onNotify: ((event: ScheduleServerEvent) => void) | null;let errors: ErrorRecordArgs[];let scheduler: Scheduler;@@ -81,6 +94,7 @@ describe("scheduler", () => {started = [];created = [];events = [];+ onNotify = null;errors = [];let seq = 0;scheduler = wire(Scheduler, {@@ -105,7 +119,10 @@ describe("scheduler", () => {},projectConfig: wire(ProjectConfigService, { paths: { root } }),errors: { record: (args: ErrorRecordArgs) => void errors.push(args) },- notify: (userId: string, event: ScheduleServerEvent) => void events.push({ userId, event }),+ notify: (userId: string, event: ScheduleServerEvent) => {+ onNotify?.(event);+ events.push({ userId, event });+ },now: () => nowMs,});await fs.mkdir(scheduleDir(root, P, A), { recursive: true });@@ -142,6 +159,26 @@ describe("scheduler", () => {return new Date(ms).toISOString();}+ const expiredDir = (): string => path.join(scheduleDir(root, P, A), "expired");++ /** Task names the scheduler lists (the routes' view). */+ async function listed(): Promise<string[]> {+ return (await scheduler.listAgent(P, A)).entries.map((e) => e.def.name);+ }++ /** File names under `schedule/expired/`, sorted. */+ async function archived(): Promise<string[]> {+ try {+ return (await fs.readdir(expiredDir())).sort();+ } catch {+ return [];+ }+ }++ function inSchedule(name: string): boolean {+ return existsSync(path.join(scheduleDir(root, P, A), `${name}.toml`));+ }+/*** Ages the given paths' mtimes past the mtime gate's FRESH_MS window (fresh mtimes are* deliberately never cached as clean), so steady-state assertions see a tree that looks@@ -270,32 +307,207 @@ describe("scheduler", () => {expect(state?.lastFiredAt).toBe(iso(T0 + 30 * MIN));});- it("one-shot task: fires once when the future slot arrives; already expired at registration is marked missed and never fires", async () => {+ it("a fired one-shot is archived before schedule_fired reaches the user, gone from the listing and from SQLite", async () => {insertSession("session-1");- await writeFile("future", [+ const lines = [`prompt = "f"`,`enabled = true`,`start_at = "${iso(T0 + 10 * MIN)}"`,`session_id = "session-1"`,- ]);+ ];+ await writeFile("future", lines);+ await scheduler.tickOnce();+ expect(await listed()).toEqual(["future"]);++ // What a client refetching on the event would find at that very moment.+ let seenAtEvent: { inSchedule: boolean; hasRunState: boolean } | null = null;+ onNotify = (event) => {+ if (event.type !== "schedule_fired") return;+ seenAtEvent = {+ inSchedule: inSchedule("future"),+ hasRunState: repo.find(P, A, "future") !== null,+ };+ };+ nowMs = T0 + 11 * MIN;+ await scheduler.tickOnce();+ expect(started).toHaveLength(1);+ expect(events.map((e) => e.event.type)).toEqual(["schedule_fired"]);+ expect(seenAtEvent).toEqual({ inSchedule: false, hasRunState: false });+ // Moved unchanged; the run state is dropped as for a deleted file.+ expect(await archived()).toEqual(["future.toml"]);+ expect(await fs.readFile(path.join(expiredDir(), "future.toml"), "utf8")).toBe(+ lines.join("\n"),+ );+ expect(repo.find(P, A, "future")).toBeNull();+ expect(await listed()).toEqual([]);++ nowMs = T0 + 60 * MIN;+ await scheduler.tickOnce();+ expect(started).toHaveLength(1);+ });++ it("a one-shot found already past at registration is archived, not listed as missed", async () => {+ insertSession("session-1");await writeFile("stale", [`prompt = "s"`,`enabled = true`,`start_at = "${iso(T0 - 10 * MIN)}"`,`session_id = "session-1"`,]);+ expect(await scheduler.listAgent(P, A)).toEqual({ entries: [], invalid: [] });+ expect(await archived()).toEqual(["stale.toml"]);+ expect(inSchedule("stale")).toBe(false);+ expect(repo.find(P, A, "stale")).toBeNull();+ expect(started).toHaveLength(0);+ });++ it("a periodic task past end_at is archived by the reconcile pass", async () => {+ insertSession("session-1");+ await writeFile("window", [+ `prompt = "w"`,+ `enabled = true`,+ `start_at = "${iso(T0 + MIN)}"`,+ `period = "5m"`,+ `end_at = "${iso(T0 + 20 * MIN)}"`,+ `session_id = "session-1"`,+ ]);+ await scheduler.tickOnce();+ nowMs = T0 + 20 * MIN; // Still inside the window (end_at is inclusive): stays.+ await scheduler.tickOnce();+ expect(inSchedule("window")).toBe(true);++ nowMs = T0 + 21 * MIN;+ await scheduler.tickOnce();+ expect(await archived()).toEqual(["window.toml"]);+ expect(repo.find(P, A, "window")).toBeNull();+ expect(await listed()).toEqual([]);+ });++ it("an expired periodic task with a queued fire stays until that fire is sent, then is archived", async () => {+ insertSession("session-1");+ busy.add("session-1");+ await writeFile("late", [+ `prompt = "late"`,+ `enabled = true`,+ `start_at = "${iso(T0)}"`,+ `period = "5m"`,+ `end_at = "${iso(T0 + 7 * MIN)}"`,+ `session_id = "session-1"`,+ ]);+ nowMs = T0 - MIN;+ await scheduler.tickOnce();+ nowMs = T0 + 5 * MIN; // Due while the Session is busy: queued.+ await scheduler.tickOnce();+ expect(events.map((e) => e.event.type)).toEqual(["schedule_queued"]);++ nowMs = T0 + 10 * MIN; // Past end_at, the fire still waiting: the task must not move yet.+ await scheduler.tickOnce();+ expect(inSchedule("late")).toBe(true);+ const [entry] = (await scheduler.listAgent(P, A)).entries;+ expect(entry).toMatchObject({ def: { name: "late" }, queued: true });++ busy.delete("session-1");+ await scheduler.tickOnce();+ expect(started.map((s) => s.sessionId)).toEqual(["session-1"]);+ expect(events.map((e) => e.event.type)).toEqual(["schedule_queued", "schedule_fired"]);+ expect(await archived()).toEqual(["late.toml"]);+ expect(repo.find(P, A, "late")).toBeNull();+ });++ it("disabled and invalid tasks stay listed, even once their time has passed", async () => {+ insertSession("session-1");+ await writeFile("paused", [+ `prompt = "p"`,+ `enabled = false`,+ `start_at = "${iso(T0 + 5 * MIN)}"`,+ `session_id = "session-1"`,+ ]);+ await writeFile("ghost", [+ `prompt = "g"`,+ `enabled = true`,+ `start_at = "${iso(T0 + MIN)}"`,+ `period = "5m"`,+ `end_at = "${iso(T0 + 10 * MIN)}"`,+ `session_id = "session-gone"`,+ ]);+ await scheduler.tickOnce();+ nowMs = T0 + MIN; // ghost's Session is gone: invalid.await scheduler.tickOnce();+ nowMs = T0 + 30 * MIN; // Past paused's one-shot time and past ghost's end_at.+ await scheduler.tickOnce();+ expect(await listed()).toEqual(["ghost", "paused"]);+ expect(await archived()).toEqual([]);+ expect(repo.find(P, A, "ghost")?.invalidReason).toBe("session_missing");expect(started).toHaveLength(0);- expect(repo.find(P, A, "stale")?.missed).toBe(true);+ });- nowMs = T0 + 11 * MIN;+ it("a clash in expired/ keeps every file: the newcomer takes a timestamped name", async () => {+ const stale = (prompt: string) => [+ `prompt = "${prompt}"`,+ `enabled = true`,+ `start_at = "${iso(T0 - 10 * MIN)}"`,+ ];+ await fs.mkdir(expiredDir(), { recursive: true });+ await fs.writeFile(path.join(expiredDir(), "stale.toml"), "older", "utf8");+ await writeFile("stale", stale("second"));+ await listed();+ await writeFile("stale", stale("third"));+ await listed();+ expect(await archived()).toEqual([+ "stale.20260716T090000Z-2.toml",+ "stale.20260716T090000Z.toml",+ "stale.toml",+ ]);+ const read = (f: string) => fs.readFile(path.join(expiredDir(), f), "utf8");+ expect(await read("stale.toml")).toBe("older");+ expect(await read("stale.20260716T090000Z.toml")).toContain("second");+ expect(await read("stale.20260716T090000Z-2.toml")).toContain("third");+ });++ it("a file moved back with its time still past is archived again, without firing twice", async () => {+ insertSession("session-1");+ await writeFile("once", [+ `prompt = "o"`,+ `enabled = true`,+ `start_at = "${iso(T0 + MIN)}"`,+ `session_id = "session-1"`,+ ]);+ await scheduler.tickOnce();+ nowMs = T0 + 2 * MIN;await scheduler.tickOnce();expect(started).toHaveLength(1);- expect(repo.find(P, A, "future")?.firedOnce).toBe(true);+ expect(await archived()).toEqual(["once.toml"]);- nowMs = T0 + 60 * MIN;+ // Moving it back registers it as a new task, whose time is already past.+ await fs.rename(+ path.join(expiredDir(), "once.toml"),+ path.join(scheduleDir(root, P, A), "once.toml"),+ );+ nowMs = T0 + 3 * MIN;await scheduler.tickOnce();expect(started).toHaveLength(1);+ expect(inSchedule("once")).toBe(false);+ expect(await archived()).toEqual(["once.toml"]);+ expect(await listed()).toEqual([]);+ });++ it("when the move fails, the error is recorded, the task stays listed, and a later pass archives it", async () => {+ await writeFile("stale", [+ `prompt = "s"`,+ `enabled = true`,+ `start_at = "${iso(T0 - 10 * MIN)}"`,+ ]);+ // A plain file where the archive directory should be: the move cannot happen.+ await fs.writeFile(expiredDir(), "in the way", "utf8");+ const { entries } = await scheduler.listAgent(P, A);+ expect(entries.map((e) => [e.def.name, e.state.missed])).toEqual([["stale", true]]);+ expect(errors.some((e) => e.code === "schedule_archive_failed")).toBe(true);+ expect(inSchedule("stale")).toBe(true);++ await fs.unlink(expiredDir());+ await scheduler.tickOnce();+ expect(await archived()).toEqual(["stale.toml"]);+ expect(await listed()).toEqual([]);});it("busy queueing: a running target queues and notifies, sends once idle; repeated slots don't stack", async () => {diff --git a/packages/server/test/schedules.test.ts b/packages/server/test/schedules.test.tsindex a5dd08c1..d90d9d41 100644--- a/packages/server/test/schedules.test.ts+++ b/packages/server/test/schedules.test.ts@@ -1,14 +1,19 @@/*** Integration tests for the schedule routes: CRUD and permissions (any member can read, only the owner can* modify, outsiders get 404), 400 validation, 409 on name collision, hand-edited- * invalid files landing in invalidFiles, expired one-shot tasks marked missed- * during reconciliation, and the on-disk file shape.+ * invalid files landing in invalidFiles, and the on-disk file shape.+ *+ * - A write that could never fire — a one-shot whose start_at is past, or a task whose end_at is+ * past — is refused with 400 on POST and PUT, and nothing is written.+ * - Settled tasks are archived into schedule/expired/: absent from the agent and Project listings+ * and from the agent card's scheduleCount.*/import fs from "node:fs/promises";import path from "node:path";import { afterEach, beforeEach, describe, expect, it } from "vitest";import { scheduleDir } from "@adelie/core";import type {+ AgentsResponse,AllProjectSchedulesResponse,ProjectCreateResponse,ProjectSchedulesResponse,@@ -19,6 +24,7 @@ import { apiClient, createTestApp, provisionUser } from "./helpers.js";import type { TestApp } from "./helpers.js";const FUTURE = "2099-01-01T09:00:00Z";+const PAST = "2020-01-01T00:00:00Z";describe("schedules api", () => {let t: TestApp;@@ -172,21 +178,112 @@ describe("schedules api", () => {expect(list.invalidFiles).toEqual([]);});- it("hand-edited files: invalid ones land in invalidFiles; expired one-shots are marked missed during reconciliation", async () => {+ it("hand-edited files: invalid ones land in invalidFiles; a valid one is listed with the Project owner as its creator", async () => {const dir = scheduleDir(t.root, projectId, "default_agent");await fs.mkdir(dir, { recursive: true });await fs.writeFile(path.join(dir, "broken.toml"), "not = toml =", "utf8");await fs.writeFile(- path.join(dir, "stale.toml"),- `prompt = "s"\nenabled = true\nstart_at = "2020-01-01T00:00:00Z"\n`,+ path.join(dir, "hand.toml"),+ `prompt = "h"\nenabled = true\nstart_at = "${FUTURE}"\n`,"utf8",);const list = (await (await owner.get(base)).json()) as SchedulesResponse;expect(list.invalidFiles.map((f) => f.name)).toEqual(["broken"]);- const stale = list.schedules.find((s) => s.name === "stale");- expect(stale?.status).toBe("missed");- // For a hand-edited file, the creator falls back to the Project owner.- expect(stale?.creatorUserId).toBe("owner_a");+ expect(list.schedules.map((s) => [s.name, s.status, s.creatorUserId])).toEqual([+ // For a hand-edited file, the creator falls back to the Project owner.+ ["hand", "active", "owner_a"],+ ]);+ });++ it("a one-shot whose start_at is past, or a task whose end_at is past, is refused with 400 and writes nothing", async () => {+ const refusal = async (res: Response): Promise<[number, string]> => [+ res.status,+ ((await res.json()) as { error: { message: string } }).error.message,+ ];+ expect(+ await refusal(+ await owner.post(base, { name: "late", prompt: "p", enabled: true, startAt: PAST }),+ ),+ ).toEqual([400, expect.stringContaining("start_at is already past")]);+ expect(+ await refusal(+ await owner.post(base, {+ name: "over",+ prompt: "p",+ enabled: true,+ startAt: PAST,+ period: "1d",+ endAt: "2021-01-01T00:00:00Z",+ }),+ ),+ ).toEqual([400, expect.stringContaining("end_at is already past")]);+ // A periodic task may start in the past: later slots are still ahead of it. (Disabled here+ // only so the test does not fire it.)+ expect(+ (+ await owner.post(base, {+ name: "daily",+ prompt: "p",+ enabled: false,+ startAt: PAST,+ period: "1d",+ })+ ).status,+ ).toBe(201);+ // PUT is held to the same rule, and the stored file is left as it was.+ const file = path.join(scheduleDir(t.root, projectId, "default_agent"), "daily.toml");+ const before = await fs.readFile(file, "utf8");+ expect(+ await refusal(+ await owner.put(`${base}/daily`, { prompt: "p2", enabled: true, startAt: PAST }),+ ),+ ).toEqual([400, expect.stringContaining("start_at is already past")]);+ expect(await fs.readFile(file, "utf8")).toBe(before);+ const list = (await (await owner.get(base)).json()) as SchedulesResponse;+ expect(list.schedules.map((s) => s.name)).toEqual(["daily"]);+ });++ it("settled tasks are archived: absent from the agent and Project listings and from the agent card's count", async () => {+ expect(+ (+ await owner.post(base, {+ name: "live",+ prompt: "p",+ enabled: true,+ startAt: FUTURE,+ period: "30m",+ })+ ).status,+ ).toBe(201);+ // Hand-edited files the API would refuse: a one-shot already past, a task past end_at.+ const dir = scheduleDir(t.root, projectId, "default_agent");+ await fs.writeFile(+ path.join(dir, "stale.toml"),+ `prompt = "s"\nenabled = true\nstart_at = "${PAST}"\n`,+ "utf8",+ );+ await fs.writeFile(+ path.join(dir, "over.toml"),+ `prompt = "o"\nenabled = true\nstart_at = "${PAST}"\nperiod = "1d"\nend_at = "2021-01-01T00:00:00Z"\n`,+ "utf8",+ );++ const project = (await (+ await member.get(`/api/projects/${projectId}/schedules`)+ ).json()) as ProjectSchedulesResponse;+ expect(project.schedules.map((s) => s.name)).toEqual(["live"]);+ const agent = (await (await member.get(base)).json()) as SchedulesResponse;+ expect(agent.schedules.map((s) => s.name)).toEqual(["live"]);+ expect((await owner.get(`${base}/stale`)).status).toBe(404);+ const cards = (await (+ await member.get(`/api/projects/${projectId}/agents`)+ ).json()) as AgentsResponse;+ expect(cards.agents.find((a) => a.agentId === "default_agent")?.scheduleCount).toBe(1);+ // The files are kept, unchanged, under schedule/expired/.+ expect((await fs.readdir(path.join(dir, "expired"))).sort()).toEqual([+ "over.toml",+ "stale.toml",+ ]);});it("a hand-edited file is reconciled past a warm mtime cache (an in-place edit moves only the file's mtime)", async () => {diff --git a/packages/web/src/features/schedules/schedule-panel-state.ts b/packages/web/src/features/schedules/schedule-panel-state.tsindex 34c846f1..62d18de0 100644--- a/packages/web/src/features/schedules/schedule-panel-state.ts+++ b/packages/web/src/features/schedules/schedule-panel-state.ts@@ -8,9 +8,9 @@import type { ScheduleItem, ScheduleStatus } from "@adelie/server/api";import { S } from "../../lib/strings";-export type ScheduleFilter = "all" | "active" | "paused" | "completed";+export type ScheduleFilter = "all" | "active" | "paused";-export const SCHEDULE_FILTERS: readonly ScheduleFilter[] = ["all", "active", "paused", "completed"];+export const SCHEDULE_FILTERS: readonly ScheduleFilter[] = ["all", "active", "paused"];/** The chips' wording, from the active dictionary (read at render time, so a locale switch relabels them). */export function scheduleFilterLabels(): Record<ScheduleFilter, string> {@@ -18,14 +18,14 @@ export function scheduleFilterLabels(): Record<ScheduleFilter, string> {all: S.schedule.filterAll,active: S.schedule.filterActive,paused: S.schedule.filterPaused,- completed: S.schedule.filterCompleted,};}/**- * The chip a status sits under. `disabled` is "paused" — the switch on the row resumes it —- * and every settled state is "completed". An invalid file fits no chip: it shows under "all"- * only, with its reason on the row.+ * The chip a status sits under. `disabled` is "paused" — the switch on the row resumes it. The+ * scheduler archives settled tasks (done / expired / missed) out of the list, so they have no+ * chip: one still listed (a queued fire not yet sent, or an archive move that failed) shows+ * under "all" only, like an invalid file, which also carries its reason on the row.*/export function filterBucket(status: ScheduleStatus): Exclude<ScheduleFilter, "all"> | null {switch (status) {@@ -36,7 +36,6 @@ export function filterBucket(status: ScheduleStatus): Exclude<ScheduleFilter, "acase "done":case "expired":case "missed":- return "completed";case "invalid":return null;}diff --git a/packages/web/src/features/schedules/schedule-panel.tsx b/packages/web/src/features/schedules/schedule-panel.tsxindex 4be188e6..a953a9fb 100644--- a/packages/web/src/features/schedules/schedule-panel.tsx+++ b/packages/web/src/features/schedules/schedule-panel.tsx@@ -170,7 +170,7 @@ export function SchedulePanel({ session, active, onPrefillComposer }: SchedulePaonChange={setQuery}/><Segmented- cols={4}+ cols={3}options={SCHEDULE_FILTERS.map((value) => ({ value, label: filterLabels[value] }))}value={filter}onChange={setFilter}diff --git a/packages/web/src/lib/strings-en.ts b/packages/web/src/lib/strings-en.tsindex ee26da3b..7ecc0b7c 100644--- a/packages/web/src/lib/strings-en.ts+++ b/packages/web/src/lib/strings-en.ts@@ -2357,7 +2357,6 @@ export const en: Strings = {filterAll: "All",filterActive: "Active",filterPaused: "Paused",- filterCompleted: "Completed",panelEmpty: "No scheduled tasks in this conversation yet",panelNoMatch: "No matching scheduled tasks",/** The panel's body on the draft page, where no Session exists yet. */@@ -2425,7 +2424,7 @@ export const en: Strings = {* the file branch, so they are never read as flags of the command beside them.*/aiCreateTail: (agentId: string): string =>- `Create this scheduled task for agent \`${agentId}\`. Either run \`penguin schedule add <name> --agent-id ${agentId} --prompt "<the request>" --start-at <ISO 8601 or now>\`, adding \`--period <30m | 12h | 7d>\` when it repeats and \`--end-at <ISO 8601>\` when the request has a natural end — without \`--agent-id\` the task lands on whichever agent is running this conversation rather than on that one; or write the TOML file under that agent's agent_state/schedule/ yourself, with a semantic file name and the \`start_at\`, \`period\` and \`end_at\` keys. Use the new-Session mode unless the user names a Session. Then confirm the schedule you set in one line.`,+ `Create this scheduled task for agent \`${agentId}\`. Either run \`penguin schedule add <name> --agent-id ${agentId} --prompt "<the request>" --start-at <future ISO 8601, or now with --period>\`, adding \`--period <30m | 12h | 7d>\` when it repeats and \`--end-at <ISO 8601>\` when the request has a natural end — without \`--agent-id\` the task lands on whichever agent is running this conversation rather than on that one; or write the TOML file under that agent's agent_state/schedule/ yourself, with a semantic file name and the \`start_at\`, \`period\` and \`end_at\` keys. Use the new-Session mode unless the user names a Session. Then confirm the schedule you set in one line.`,/** The suggestion rows (name / schedule hint / one-line description) and the prompt each prefills — one phrased for this conversation, one for an agent as a whole. */suggestionsTitle: "Suggestions",suggestions: {diff --git a/packages/web/src/lib/strings.ts b/packages/web/src/lib/strings.tsindex 5a7c8611..45a0383f 100644--- a/packages/web/src/lib/strings.ts+++ b/packages/web/src/lib/strings.ts@@ -2408,7 +2408,6 @@ export const zh = {filterAll: "全部",filterActive: "生效中",filterPaused: "已暂停",- filterCompleted: "已完成",panelEmpty: "这段对话还没有定时任务",panelNoMatch: "没有匹配的定时任务",/** The panel's body on the draft page, where no Session exists yet. */@@ -2473,7 +2472,7 @@ export const zh = {* the file branch, so they are never read as flags of the command beside them.*/aiCreateTail: (agentId: string): string =>- `请为 Agent「${agentId}」创建这个定时任务。可以执行 \`penguin schedule add <名称> --agent-id ${agentId} --prompt "<请求内容>" --start-at <ISO 8601 或 now>\`,需要重复执行时加 \`--period <30m | 12h | 7d>\`,请求有自然终点时加 \`--end-at <ISO 8601>\`——不写 \`--agent-id\` 时任务会落到运行本对话的那个 Agent 上,而不是它;也可以直接在该 Agent 的 agent_state/schedule/ 下写 TOML 文件,文件名取有意义的英文名,用 \`start_at\`、\`period\`、\`end_at\` 这几个键。除非用户指定了 Session,否则采用每次新建 Session 的模式。创建后用一行确认你设定的时间安排。`,+ `请为 Agent「${agentId}」创建这个定时任务。可以执行 \`penguin schedule add <名称> --agent-id ${agentId} --prompt "<请求内容>" --start-at <未来的 ISO 8601 时刻,带 --period 时也可用 now>\`,需要重复执行时加 \`--period <30m | 12h | 7d>\`,请求有自然终点时加 \`--end-at <ISO 8601>\`——不写 \`--agent-id\` 时任务会落到运行本对话的那个 Agent 上,而不是它;也可以直接在该 Agent 的 agent_state/schedule/ 下写 TOML 文件,文件名取有意义的英文名,用 \`start_at\`、\`period\`、\`end_at\` 这几个键。除非用户指定了 Session,否则采用每次新建 Session 的模式。创建后用一行确认你设定的时间安排。`,/** The suggestion rows (name / schedule hint / one-line description) and the prompt each prefills — one phrased for this conversation, one for an agent as a whole. */suggestionsTitle: "建议",suggestions: {diff --git a/packages/web/test/schedule-panel-state.test.ts b/packages/web/test/schedule-panel-state.test.tsindex dc5e3323..be8b0c40 100644--- a/packages/web/test/schedule-panel-state.test.ts+++ b/packages/web/test/schedule-panel-state.test.ts@@ -90,15 +90,15 @@ describe("pendingScheduleSessions", () => {});describe("filterBucket / scheduleGlyph", () => {- it("buckets every display status under exactly one chip, invalid under none", () => {+ it("puts an armed task under 'active' and a switched-off one under 'paused'; a settled task or an invalid file fits no chip", () => {expect(filterBucket("active")).toBe("active");expect(filterBucket("disabled")).toBe("paused");- expect(filterBucket("done")).toBe("completed");- expect(filterBucket("expired")).toBe("completed");- expect(filterBucket("missed")).toBe("completed");- expect(filterBucket("invalid")).toBeNull();+ // The scheduler archives settled tasks; one still listed shows under "all" only.+ for (const status of ["done", "expired", "missed", "invalid"] as const) {+ expect(filterBucket(status), status).toBeNull();+ }// Every non-"all" chip is a bucket some status lands in.- const landed = (["active", "disabled", "done"] as const).map((s) => filterBucket(s));+ const landed = (["active", "disabled"] as const).map((s) => filterBucket(s));for (const chip of SCHEDULE_FILTERS.filter((f) => f !== "all")) {expect(landed).toContain(chip);}@@ -128,15 +128,16 @@ describe("matchesQuery / filterSchedules", () => {expect(matchesQuery(items[2]!, " ")).toBe(true);});- it("combines the chip and the query, and shows an invalid file under 'all' only", () => {+ it("combines the chip and the query, and shows a settled task or an invalid file under 'all' only", () => {expect(filterSchedules(items, "all", "").map((i) => i.name)).toEqual(["daily_brief","watch_docs","reminder","broken",]);+ expect(filterSchedules(items, "active", "").map((i) => i.name)).toEqual(["daily_brief"]);expect(filterSchedules(items, "paused", "").map((i) => i.name)).toEqual(["watch_docs"]);- expect(filterSchedules(items, "completed", "kim").map((i) => i.name)).toEqual(["reminder"]);+ expect(filterSchedules(items, "all", "kim").map((i) => i.name)).toEqual(["reminder"]);expect(filterSchedules(items, "active", "docs")).toEqual([]);});});diff --git a/plugins/agent-development/plugin.json b/plugins/agent-development/plugin.jsonindex c80ab61f..cd848758 100644--- a/plugins/agent-development/plugin.json+++ b/plugins/agent-development/plugin.json@@ -3,6 +3,6 @@"description_zh": "基于 Adelie 的智能体开发:用 SDK 构建应用或经 Agent API 接入智能体、经统一的 LLM API 调用任意模型、管理模型与密钥、编排智能体/会话/成本/定时任务。","short_description": "SDK, Agent API, unified LLM API, config and orchestration.","short_description_zh": "SDK、Agent API、统一 LLM API、配置与编排。",- "version": "2026.10.17.2",+ "version": "2026.10.18.1","category": "ai-app-development"}diff --git a/plugins/agent-development/skills/penguin-orchestration/SKILL.md b/plugins/agent-development/skills/penguin-orchestration/SKILL.mdindex 8b7e8417..54bc742c 100644--- a/plugins/agent-development/skills/penguin-orchestration/SKILL.md+++ b/plugins/agent-development/skills/penguin-orchestration/SKILL.md@@ -127,7 +127,7 @@ penguin schedule update daily-report --period 12h # adjust; --enable/--disablpenguin schedule rm daily-report # remove — no confirmation prompt```-- `--agent-id` defaults to yourself from the caller env, so this schedules the current agent. `--start-at` takes ISO 8601 or `now`; `--period` is at least 5m (`30m`/`12h`/`1d`/`7d`), omit it for a one-shot; `--end-at` bounds recurrence. Target the session you are in — `--session-id "$ADELIE_SESSION_ID"` — unless the user asked for somewhere else: the prompt then arrives in this conversation, with its context. Leave the target off when the user wants a separate session, or when the task is better off starting clean (a nightly report that should not inherit this conversation); each firing then opens a new session, which `--workspace <path>` and the `--model-id` + `--provider` pair configure.+- `--agent-id` defaults to yourself from the caller env, so this schedules the current agent. `--start-at` takes ISO 8601 or `now`; `--period` is at least 5m (`30m`/`12h`/`1d`/`7d`), omit it for a one-shot, which needs a future `--start-at` (`now` is refused there); `--end-at` bounds recurrence. Target the session you are in — `--session-id "$ADELIE_SESSION_ID"` — unless the user asked for somewhere else: the prompt then arrives in this conversation, with its context. Leave the target off when the user wants a separate session, or when the task is better off starting clean (a nightly report that should not inherit this conversation); each firing then opens a new session, which `--workspace <path>` and the `--model-id` + `--provider` pair configure.- `add` creates the schedule **enabled** (`--disabled` stages it off) — deliberately diverging from the raw file, where `enabled` defaults to false. `update` is read-modify-write: unspecified fields keep their stored values, and switching the target form clears the other one.- In `schedule ls`, read: the AGENT column (without `--agent-id` the listing spans agents), `enabled` (a disabled entry never fires), `startAt` (first firing), `period` (absent means one-shot), the target — an existing session versus a new session per firing — and `lastFiredAt`.- The CLI writes through the schedules API, so mistakes are rejected synchronously. The TOML file stays the single source of truth — `<app_data_dir>/agents/<agent_id>/agent_state/schedule/<name>.toml`, fields mirroring the flags (`prompt`, `enabled` — false by default in the file, `start_at`, `period`, `end_at`, `session_id` / `workspace`+`provider`+`model_id`) — and remains editable with file tools; your system prompt's schedule roster lists yours. A hand edit is only validated by the periodic reconcile (roughly every 30s), with errors landing in error records rather than your terminal — prefer the CLI.