feat(schedules): per-check cost and model summary on GET /schedules (INT-3)

agent_check items carry agentRuns (last 100 sessions: last/avg cost, 7-day count and cost,
models, recent 3); plan page and home plan band use it instead of fetching agent runs.
Migration 0052 indexes agent_run(created_by, created_at).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
rootandClaude Opus 5.5 committed 2026-09-29 17:55:47 +08:00
1 parent 82df5662f0
commit e681fcedf6
9 files changed
+200 -78

No files matched your search

@@ -0,0 +1,17 @@
import type { Kysely } from "kysely";
import { execDdl } from "../src/migration-helpers.ts";
// INT-3:计划页 GET /schedules 给每个 Agent 巡检汇总最近 100 次会话(created_by = schedule:<id>)的费用与模型。
// biome-ignore lint/suspicious/noExplicitAny: 迁移不依赖应用表类型
export async function up(db: Kysely<any>): Promise<void> {
await execDdl(
db,
`create index if not exists agent_run_created_by_idx on agent_run (created_by, created_at desc) where created_by is not null;`,
);
}
// biome-ignore lint/suspicious/noExplicitAny: 同上
export async function down(db: Kysely<any>): Promise<void> {
await execDdl(db, `drop index if exists agent_run_created_by_idx;`);
}