Merge branch 'main' into worktree-tidy-jumping-shell

This commit is contained in:
wangjia
2026-06-29 23:32:40 +08:00
6 changed files with 200 additions and 4 deletions
+8
View File
@@ -30,11 +30,14 @@ export interface UserSettings {
budgetUsd: number | null;
budgetPeriod: 'day' | 'month';
model: string | null;
/** 跨所有项目的在途 run 总数上限(全局并发闸);0 = 不限。与 concurrency(新建项目默认值)相互独立。 */
globalConcurrency: number;
}
const SETTINGS_DEFAULT: UserSettings = {
autonomy: 'manual', concurrency: 1, maxRetries: 2, timeoutMs: 1_800_000,
autoApprovePlan: false, autoApproveExec: false,
budgetUsd: null, budgetPeriod: 'month', model: null,
globalConcurrency: 0,
};
const id = (prefix: string): string => `${prefix}_${nanoid(12)}`;
@@ -936,6 +939,11 @@ export class Store {
return new Set(rows.map((r) => r.tid));
}
/** 跨所有项目的在途 run 总数(全局并发闸用;与 inflightTaskIds 同口径=started run,覆盖 executor + planner)。 */
globalInflightCount(): number {
return (this.db.prepare(`SELECT COUNT(*) AS n FROM runs WHERE status = 'started'`).get() as { n: number }).n;
}
/** 所有 started run + 其任务(reap / ingest / reconcile 通用,覆盖 executor + planner + 残留复审 run)。 */
liveRunsWithTask(): Array<{ task: Task; run: Run }> {
const runs = this.db.prepare(`SELECT * FROM runs WHERE status = 'started' ORDER BY started_at`).all() as RunRow[];