Download apps/vis/server/src/routes/cron.ts from SaylorTwift/kimi-code: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vis/server/src/routes/cron.ts
- Command line
-
hf download hf://SaylorTwift/kimi-code/apps/vis/server/src/routes/cron.ts
-
curl -L -o cron.ts https://huggingface.co/SaylorTwift/kimi-code/resolve/main/apps/vis/server/src/routes/cron.ts
1.17 kB
| import { Hono } from 'hono'; | |
| import { KIMI_CODE_HOME } from '../config'; | |
| import type { CronTask } from '../lib/agent-record-types'; | |
| import { readSessionDetail } from '../lib/session-store'; | |
| import { listCronTasks } from '../lib/cron-store'; | |
| export function cronRoute(home: string = KIMI_CODE_HOME): Hono { | |
| const r = new Hono(); | |
| r.get('/:id/cron', async (c) => { | |
| const id = c.req.param('id'); | |
| const detail = await readSessionDetail(home, id); | |
| if (!detail) { | |
| return c.json({ error: 'session not found', code: 'NOT_FOUND' }, 404); | |
| } | |
| // Cron state is per-agent (wire records in each agent's `wire.jsonl`, | |
| // plus legacy `<homedir>/cron/*.json` files), not the session root. | |
| // Aggregate across agents; sub agents simply contribute nothing. | |
| const cron: CronTask[] = []; | |
| const seen = new Set<string>(); | |
| for (const agent of detail.agents) { | |
| for (const job of await listCronTasks(agent.homedir)) { | |
| if (seen.has(job.id)) continue; | |
| seen.add(job.id); | |
| cron.push(job); | |
| } | |
| } | |
| cron.sort((a, b) => a.createdAt - b.createdAt); | |
| return c.json({ sessionId: id, cron }); | |
| }); | |
| return r; | |
| } | |