refactor(core): migrate to Bun and converge acquisition policies and Agent boundaries

This commit is contained in:
root committed 2026-10-13 14:37:03 +08:00
1 parent 3f1c6d02f6
commit 27c0f27434
268 files changed
+7468 -7852

No files matched your search

+8 -8
View File
@@ -3,9 +3,9 @@
// 默认只读(dry-run),输出每张表将删的行数;--apply 才删除(分批、每批单独事务,删得多的表随后 ANALYZE)。
//
// 用法(DATABASE_URL 必须显式给出,脚本不带默认库):
// DATABASE_URL=postgres://umt:***@<host>:5432/umt deno run -A scripts/db-retention.ts [--dry-run] # 看每张表将删多少行
// DATABASE_URL=… deno run -A scripts/db-retention.ts --apply # 执行
// DATABASE_URL=… deno run -A scripts/db-retention.ts --only task_run,pipeline [--apply] # 只处理部分目标
// DATABASE_URL=postgres://umt:***@<host>:5432/umt bun scripts/db-retention.ts [--dry-run] # 看每张表将删多少行
// DATABASE_URL=… bun scripts/db-retention.ts --apply # 执行
// DATABASE_URL=… bun scripts/db-retention.ts --only task_run,pipeline [--apply] # 只处理部分目标
// ENGINE_SCHEMA=openworkflow(缺省)
//
// 不包含:进程心跳(system.heartbeat_cleanup)、图片缓存与 kv_cache(cache 模块)、ANALYZE 任务(--apply 结束时对删过的表各自 ANALYZE)。
@@ -15,20 +15,20 @@ import { withStorageDefaults } from "@umt/contracts";
import { createDb, sql } from "@umt/db";
import { previewJob, RETENTION_JOBS } from "../apps/server/src/modules/system/retention.ts";
const argv = [...Deno.args];
const argv = [...process.argv.slice(2)];
const APPLY = argv.includes("--apply");
if (APPLY && argv.includes("--dry-run")) {
console.error("--apply 与 --dry-run 不能同时给出");
Deno.exit(2);
process.exit(2);
}
const onlyArg = argv.indexOf("--only");
const only = onlyArg >= 0 ? new Set((argv[onlyArg + 1] ?? "").split(",").filter(Boolean)) : null;
const url = Deno.env.get("DATABASE_URL");
const url = process.env.DATABASE_URL;
if (!url) {
console.error("需要 DATABASE_URL(脚本不带默认库)");
Deno.exit(2);
process.exit(2);
}
const engineSchema = Deno.env.get("ENGINE_SCHEMA") ?? "openworkflow";
const engineSchema = process.env.ENGINE_SCHEMA ?? "openworkflow";
const db = createDb({ connectionString: url, max: 2 });
try {