mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 16:24:58 +00:00
refactor(plugins): share empty registry factory
This commit is contained in:
@@ -1,22 +1,7 @@
|
|||||||
import type { PluginRegistry } from "../../../plugins/registry.js";
|
import { createEmptyPluginRegistry, type PluginRegistry } from "../../../plugins/registry.js";
|
||||||
|
|
||||||
export const createTestRegistry = (overrides: Partial<PluginRegistry> = {}): PluginRegistry => {
|
export const createTestRegistry = (overrides: Partial<PluginRegistry> = {}): PluginRegistry => {
|
||||||
const base: PluginRegistry = {
|
const merged = { ...createEmptyPluginRegistry(), ...overrides };
|
||||||
plugins: [],
|
|
||||||
tools: [],
|
|
||||||
hooks: [],
|
|
||||||
typedHooks: [],
|
|
||||||
channels: [],
|
|
||||||
providers: [],
|
|
||||||
gatewayHandlers: {},
|
|
||||||
httpHandlers: [],
|
|
||||||
httpRoutes: [],
|
|
||||||
cliRegistrars: [],
|
|
||||||
services: [],
|
|
||||||
commands: [],
|
|
||||||
diagnostics: [],
|
|
||||||
};
|
|
||||||
const merged = { ...base, ...overrides };
|
|
||||||
return {
|
return {
|
||||||
...merged,
|
...merged,
|
||||||
gatewayHandlers: merged.gatewayHandlers ?? {},
|
gatewayHandlers: merged.gatewayHandlers ?? {},
|
||||||
|
|||||||
@@ -143,8 +143,8 @@ export type PluginRegistryParams = {
|
|||||||
runtime: PluginRuntime;
|
runtime: PluginRuntime;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
export function createEmptyPluginRegistry(): PluginRegistry {
|
||||||
const registry: PluginRegistry = {
|
return {
|
||||||
plugins: [],
|
plugins: [],
|
||||||
tools: [],
|
tools: [],
|
||||||
hooks: [],
|
hooks: [],
|
||||||
@@ -159,6 +159,10 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
|||||||
commands: [],
|
commands: [],
|
||||||
diagnostics: [],
|
diagnostics: [],
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||||
|
const registry = createEmptyPluginRegistry();
|
||||||
const coreGatewayMethods = new Set(Object.keys(registryParams.coreGatewayHandlers ?? {}));
|
const coreGatewayMethods = new Set(Object.keys(registryParams.coreGatewayHandlers ?? {}));
|
||||||
|
|
||||||
const pushDiagnostic = (diag: PluginDiagnostic) => {
|
const pushDiagnostic = (diag: PluginDiagnostic) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user