mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 09:07:39 +00:00
refactor(plugins): reuse createEmptyPluginRegistry
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import type { CanvasHostServer } from "../canvas-host/server.js";
|
import type { CanvasHostServer } from "../canvas-host/server.js";
|
||||||
import type { PluginRegistry } from "../plugins/registry.js";
|
|
||||||
import type { PluginServicesHandle } from "../plugins/services.js";
|
import type { PluginServicesHandle } from "../plugins/services.js";
|
||||||
import type { RuntimeEnv } from "../runtime.js";
|
import type { RuntimeEnv } from "../runtime.js";
|
||||||
import type { ControlUiRootState } from "./control-ui.js";
|
import type { ControlUiRootState } from "./control-ui.js";
|
||||||
@@ -45,6 +44,7 @@ import { scheduleGatewayUpdateCheck } from "../infra/update-startup.js";
|
|||||||
import { startDiagnosticHeartbeat, stopDiagnosticHeartbeat } from "../logging/diagnostic.js";
|
import { startDiagnosticHeartbeat, stopDiagnosticHeartbeat } from "../logging/diagnostic.js";
|
||||||
import { createSubsystemLogger, runtimeForLogger } from "../logging/subsystem.js";
|
import { createSubsystemLogger, runtimeForLogger } from "../logging/subsystem.js";
|
||||||
import { getGlobalHookRunner, runGlobalGatewayStopSafely } from "../plugins/hook-runner-global.js";
|
import { getGlobalHookRunner, runGlobalGatewayStopSafely } from "../plugins/hook-runner-global.js";
|
||||||
|
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||||
import { getTotalQueueSize } from "../process/command-queue.js";
|
import { getTotalQueueSize } from "../process/command-queue.js";
|
||||||
import { runOnboardingWizard } from "../wizard/onboarding.js";
|
import { runOnboardingWizard } from "../wizard/onboarding.js";
|
||||||
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
|
import { createAuthRateLimiter, type AuthRateLimiter } from "./auth-rate-limit.js";
|
||||||
@@ -239,21 +239,7 @@ export async function startGatewayServer(
|
|||||||
const defaultAgentId = resolveDefaultAgentId(cfgAtStart);
|
const defaultAgentId = resolveDefaultAgentId(cfgAtStart);
|
||||||
const defaultWorkspaceDir = resolveAgentWorkspaceDir(cfgAtStart, defaultAgentId);
|
const defaultWorkspaceDir = resolveAgentWorkspaceDir(cfgAtStart, defaultAgentId);
|
||||||
const baseMethods = listGatewayMethods();
|
const baseMethods = listGatewayMethods();
|
||||||
const emptyPluginRegistry: PluginRegistry = {
|
const emptyPluginRegistry = createEmptyPluginRegistry();
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
hooks: [],
|
|
||||||
typedHooks: [],
|
|
||||||
channels: [],
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
commands: [],
|
|
||||||
diagnostics: [],
|
|
||||||
};
|
|
||||||
const { pluginRegistry, gatewayMethods: baseGatewayMethods } = minimalTestGateway
|
const { pluginRegistry, gatewayMethods: baseGatewayMethods } = minimalTestGateway
|
||||||
? { pluginRegistry: emptyPluginRegistry, gatewayMethods: baseMethods }
|
? { pluginRegistry: emptyPluginRegistry, gatewayMethods: baseMethods }
|
||||||
: loadGatewayPlugins({
|
: loadGatewayPlugins({
|
||||||
|
|||||||
@@ -1,20 +1,4 @@
|
|||||||
import type { PluginRegistry } from "./registry.js";
|
import { createEmptyPluginRegistry, type PluginRegistry } from "./registry.js";
|
||||||
|
|
||||||
const createEmptyRegistry = (): PluginRegistry => ({
|
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
hooks: [],
|
|
||||||
typedHooks: [],
|
|
||||||
channels: [],
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
commands: [],
|
|
||||||
diagnostics: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
|
const REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
|
||||||
|
|
||||||
@@ -29,7 +13,7 @@ const state: RegistryState = (() => {
|
|||||||
};
|
};
|
||||||
if (!globalState[REGISTRY_STATE]) {
|
if (!globalState[REGISTRY_STATE]) {
|
||||||
globalState[REGISTRY_STATE] = {
|
globalState[REGISTRY_STATE] = {
|
||||||
registry: createEmptyRegistry(),
|
registry: createEmptyPluginRegistry(),
|
||||||
key: null,
|
key: null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -47,7 +31,7 @@ export function getActivePluginRegistry(): PluginRegistry | null {
|
|||||||
|
|
||||||
export function requireActivePluginRegistry(): PluginRegistry {
|
export function requireActivePluginRegistry(): PluginRegistry {
|
||||||
if (!state.registry) {
|
if (!state.registry) {
|
||||||
state.registry = createEmptyRegistry();
|
state.registry = createEmptyPluginRegistry();
|
||||||
}
|
}
|
||||||
return state.registry;
|
return state.registry;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user