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

+2 -13
View File
@@ -1,7 +1,6 @@
import { type EventType, LIFECYCLE_EVENTS, parseEventPayload } from "@umt/contracts";
import { type DB, type Kysely, sql } from "@umt/db";
import {
createDefaultRegistry,
type LogSink,
OpenWorkflowEngine,
type OutboxRelay,
@@ -12,7 +11,6 @@ import {
} from "@umt/tasks";
import type { Logger } from "pino";
import type { Config } from "./config.ts";
import { HookRegistry } from "./hooks/registry.ts";
import type { EventBusPort } from "./http/sse.ts";
import { assertCapabilityCount, createCapabilityRegistry } from "./modules/agent/capability-registry.ts";
import { createSecretStore, createSettingsReader } from "./modules/auth-settings/provided.ts";
@@ -80,8 +78,8 @@ export function tasksLogSink(logger: Logger): LogSink {
}
/**
* 任务注册表:各模块注册自己的任务;没人注册的 §3.1-8 任务用 @umt/tasks 的空壳兜底
* (outbox 路由到它们时不至于报"未知任务")。同名任务被两个模块注册会在这里报错。
* 任务注册表只收录业务模块的真实实现。同名任务被两个模块注册会在这里报错;
* 没有注册的任务由 TaskRegistry 明确报 UnknownTaskError,不以占位处理器代替。
*/
export function buildTaskRegistry(modules: readonly ServerModule[], ctx: ServerContext): TaskRegistry {
const registry = new TaskRegistry();
@@ -96,7 +94,6 @@ export function buildTaskRegistry(modules: readonly ServerModule[], ctx: ServerC
}
registry.register(...own.all());
}
for (const stub of createDefaultRegistry().all()) if (!registry.has(stub.name)) registry.register(stub);
return registry;
}
@@ -153,13 +150,6 @@ export function collectOutboxRoutes(
return routes;
}
/** 链式钩子注册表:按模块顺序调 registerHooks,执行顺序即注册顺序(ADR-006) */
export function buildHookRegistry(modules: readonly ServerModule[], ctx: ServerContext): HookRegistry {
const hooks = new HookRegistry(ctx.logger?.child({ component: "hooks" }));
for (const m of modules) m.registerHooks?.(hooks.forModule(m.name), ctx);
return hooks;
}
export interface BootstrapOptions {
role: ServerRole;
config: Config;
@@ -204,7 +194,6 @@ export async function bootstrap(opts: BootstrapOptions): Promise<Bootstrapped> {
configureStorage(ctx);
const tasks = buildTaskRegistry(opts.modules, ctx);
for (const m of opts.modules) m.registerCapabilities?.(ctx.capabilities, ctx);
ctx.hooks = buildHookRegistry(opts.modules, ctx);
// 装配了 agent 模块(即完整模块清单)时,首批 14 个能力必须全部挂上处理器
if (opts.modules.some((m) => m.name === "agent")) assertCapabilityCount(ctx.capabilities);
engine.attach(