(home: string = KIMI_CODE_HOME)
| 6 | import { listCronTasks } from '../lib/cron-store'; |
| 7 | |
| 8 | export function cronRoute(home: string = KIMI_CODE_HOME): Hono { |
| 9 | const r = new Hono(); |
| 10 | r.get('/:id/cron', async (c) => { |
| 11 | const id = c.req.param('id'); |
| 12 | const detail = await readSessionDetail(home, id); |
| 13 | if (!detail) { |
| 14 | return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404); |
| 15 | } |
| 16 | // Cron jobs are persisted under each (non-sub) agent's homedir at |
| 17 | // `<homedir>/cron`, not the session root. Aggregate across agents; sub |
| 18 | // agents have no cron directory and simply contribute nothing. |
| 19 | const cron: CronTask[] = []; |
| 20 | const seen = new Set<string>(); |
| 21 | for (const agent of detail.agents) { |
| 22 | for (const job of await listCronTasks(agent.homedir)) { |
| 23 | if (seen.has(job.id)) continue; |
| 24 | seen.add(job.id); |
| 25 | cron.push(job); |
| 26 | } |
| 27 | } |
| 28 | cron.sort((a, b) => a.createdAt - b.createdAt); |
| 29 | return c.json({ sessionId: id, cron }); |
| 30 | }); |
| 31 | return r; |
| 32 | } |
no test coverage detected