mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-07 07:58:36 +00:00
refactor: remove stale plugin runtime deps reload planning
This commit is contained in:
@@ -20,7 +20,6 @@ export type GatewayReloadPlan = {
|
||||
restartHealthMonitor: boolean;
|
||||
restartChannels: Set<ChannelKind>;
|
||||
disposeMcpRuntimes: boolean;
|
||||
planPluginRuntimeDeps: boolean;
|
||||
noopPaths: string[];
|
||||
};
|
||||
|
||||
@@ -123,24 +122,6 @@ const BASE_RELOAD_RULES_TAIL: ReloadRule[] = [
|
||||
{ prefix: "canvasHost", kind: "restart" },
|
||||
];
|
||||
|
||||
const PLUGIN_RUNTIME_DEPS_PLAN_PREFIXES = [
|
||||
"auth.order",
|
||||
"auth.profiles",
|
||||
"channels",
|
||||
"models.providers",
|
||||
"plugins",
|
||||
"agents.list",
|
||||
"agents.defaults.imageGenerationModel",
|
||||
"agents.defaults.imageModel",
|
||||
"agents.defaults.memorySearch",
|
||||
"agents.defaults.model",
|
||||
"agents.defaults.models",
|
||||
"agents.defaults.musicGenerationModel",
|
||||
"agents.defaults.pdfModel",
|
||||
"agents.defaults.subagents.model",
|
||||
"agents.defaults.videoGenerationModel",
|
||||
] as const;
|
||||
|
||||
let cachedReloadRules: ReloadRule[] | null = null;
|
||||
let cachedRegistry: ReturnType<typeof getActivePluginRegistry> | null = null;
|
||||
let cachedActiveRegistryVersion = -1;
|
||||
@@ -230,12 +211,6 @@ function isPluginInstallTimestampPath(path: string): boolean {
|
||||
return /^plugins\.installs\..+\.(installedAt|resolvedAt)$/.test(path);
|
||||
}
|
||||
|
||||
function shouldPlanPluginRuntimeDepsForPath(path: string): boolean {
|
||||
return PLUGIN_RUNTIME_DEPS_PLAN_PREFIXES.some(
|
||||
(prefix) => path === prefix || path.startsWith(`${prefix}.`),
|
||||
);
|
||||
}
|
||||
|
||||
function getPluginInstallRecords(config: unknown): Record<string, unknown> {
|
||||
if (!isPlainObject(config)) {
|
||||
return {};
|
||||
@@ -313,7 +288,6 @@ export function buildGatewayReloadPlan(
|
||||
restartHealthMonitor: false,
|
||||
restartChannels: new Set(),
|
||||
disposeMcpRuntimes: false,
|
||||
planPluginRuntimeDeps: false,
|
||||
noopPaths: [],
|
||||
};
|
||||
|
||||
@@ -355,9 +329,6 @@ export function buildGatewayReloadPlan(
|
||||
plan.noopPaths.push(path);
|
||||
continue;
|
||||
}
|
||||
if (shouldPlanPluginRuntimeDepsForPath(path)) {
|
||||
plan.planPluginRuntimeDeps = true;
|
||||
}
|
||||
const rule = matchRule(path);
|
||||
if (!rule) {
|
||||
plan.restartGateway = true;
|
||||
|
||||
@@ -214,7 +214,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
);
|
||||
expect(expected.size).toBeGreaterThan(0);
|
||||
expect(plan.restartChannels).toEqual(expected);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(true);
|
||||
});
|
||||
|
||||
it("refreshes channel reload rules when only the tracked channel registry changes", () => {
|
||||
@@ -241,7 +240,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
]);
|
||||
expect(plan.restartGateway).toBe(false);
|
||||
expect(plan.restartHeartbeat).toBe(true);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(true);
|
||||
expect(plan.hotReasons).toEqual(
|
||||
expect.arrayContaining(["models.providers.openai.models", "agents.defaults.model"]),
|
||||
);
|
||||
@@ -259,7 +257,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
const plan = buildGatewayReloadPlan(["agents.defaults.models"]);
|
||||
expect(plan.restartGateway).toBe(false);
|
||||
expect(plan.restartHeartbeat).toBe(true);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(true);
|
||||
expect(plan.hotReasons).toContain("agents.defaults.models");
|
||||
expect(plan.noopPaths).toEqual([]);
|
||||
});
|
||||
@@ -268,7 +265,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
const plan = buildGatewayReloadPlan(["agents.list"]);
|
||||
expect(plan.restartGateway).toBe(false);
|
||||
expect(plan.restartHeartbeat).toBe(true);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(true);
|
||||
expect(plan.hotReasons).toContain("agents.list");
|
||||
expect(plan.noopPaths).toEqual([]);
|
||||
});
|
||||
@@ -279,7 +275,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
"plugins.installs.lossless-claw.installedAt",
|
||||
]);
|
||||
expect(plan.restartGateway).toBe(false);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(false);
|
||||
expect(plan.noopPaths).toEqual([
|
||||
"plugins.installs.lossless-claw.resolvedAt",
|
||||
"plugins.installs.lossless-claw.installedAt",
|
||||
@@ -351,7 +346,6 @@ describe("buildGatewayReloadPlan", () => {
|
||||
it("treats secrets config changes as no-op for gateway restart planning", () => {
|
||||
const plan = buildGatewayReloadPlan(["secrets.providers.default.path"]);
|
||||
expect(plan.restartGateway).toBe(false);
|
||||
expect(plan.planPluginRuntimeDeps).toBe(false);
|
||||
expect(plan.noopPaths).toContain("secrets.providers.default.path");
|
||||
});
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ function isNoopReloadPlan(plan: GatewayReloadPlan): boolean {
|
||||
!plan.restartHeartbeat &&
|
||||
!plan.restartHealthMonitor &&
|
||||
!plan.disposeMcpRuntimes &&
|
||||
!plan.planPluginRuntimeDeps &&
|
||||
plan.restartChannels.size === 0
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ function createReloadPlan(overrides?: Partial<GatewayReloadPlan>): GatewayReload
|
||||
restartHealthMonitor: overrides?.restartHealthMonitor ?? false,
|
||||
restartChannels: overrides?.restartChannels ?? new Set(),
|
||||
disposeMcpRuntimes: overrides?.disposeMcpRuntimes ?? false,
|
||||
planPluginRuntimeDeps: overrides?.planPluginRuntimeDeps ?? false,
|
||||
noopPaths: overrides?.noopPaths ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user