mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 00:01:24 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -3,14 +3,13 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createJiti } from "jiti";
|
||||
|
||||
import type { MoltbotConfig } from "../config/config.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { GatewayRequestHandler } from "../gateway/server-methods/types.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import { discoverMoltbotPlugins } from "./discovery.js";
|
||||
import { discoverOpenClawPlugins } from "./discovery.js";
|
||||
import { loadPluginManifestRegistry } from "./manifest-registry.js";
|
||||
import {
|
||||
applyTestPluginDefaults,
|
||||
normalizePluginsConfig,
|
||||
resolveEnableState,
|
||||
resolveMemorySlotDecision,
|
||||
@@ -23,8 +22,8 @@ import { createPluginRuntime } from "./runtime/index.js";
|
||||
import { setActivePluginRegistry } from "./runtime.js";
|
||||
import { validateJsonSchemaValue } from "./schema-validator.js";
|
||||
import type {
|
||||
MoltbotPluginDefinition,
|
||||
MoltbotPluginModule,
|
||||
OpenClawPluginDefinition,
|
||||
OpenClawPluginModule,
|
||||
PluginDiagnostic,
|
||||
PluginLogger,
|
||||
} from "./types.js";
|
||||
@@ -32,7 +31,7 @@ import type {
|
||||
export type PluginLoadResult = PluginRegistry;
|
||||
|
||||
export type PluginLoadOptions = {
|
||||
config?: MoltbotConfig;
|
||||
config?: OpenClawConfig;
|
||||
workspaceDir?: string;
|
||||
logger?: PluginLogger;
|
||||
coreGatewayHandlers?: Record<string, GatewayRequestHandler>;
|
||||
@@ -99,8 +98,8 @@ function validatePluginConfig(params: {
|
||||
}
|
||||
|
||||
function resolvePluginModuleExport(moduleExport: unknown): {
|
||||
definition?: MoltbotPluginDefinition;
|
||||
register?: MoltbotPluginDefinition["register"];
|
||||
definition?: OpenClawPluginDefinition;
|
||||
register?: OpenClawPluginDefinition["register"];
|
||||
} {
|
||||
const resolved =
|
||||
moduleExport &&
|
||||
@@ -110,11 +109,11 @@ function resolvePluginModuleExport(moduleExport: unknown): {
|
||||
: moduleExport;
|
||||
if (typeof resolved === "function") {
|
||||
return {
|
||||
register: resolved as MoltbotPluginDefinition["register"],
|
||||
register: resolved as OpenClawPluginDefinition["register"],
|
||||
};
|
||||
}
|
||||
if (resolved && typeof resolved === "object") {
|
||||
const def = resolved as MoltbotPluginDefinition;
|
||||
const def = resolved as OpenClawPluginDefinition;
|
||||
const register = def.register ?? def.activate;
|
||||
return { definition: def, register };
|
||||
}
|
||||
@@ -162,8 +161,8 @@ function pushDiagnostics(diagnostics: PluginDiagnostic[], append: PluginDiagnost
|
||||
diagnostics.push(...append);
|
||||
}
|
||||
|
||||
export function loadMoltbotPlugins(options: PluginLoadOptions = {}): PluginRegistry {
|
||||
const cfg = applyTestPluginDefaults(options.config ?? {});
|
||||
export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegistry {
|
||||
const cfg = options.config ?? {};
|
||||
const logger = options.logger ?? defaultLogger();
|
||||
const validateOnly = options.mode === "validate";
|
||||
const normalized = normalizePluginsConfig(cfg.plugins);
|
||||
@@ -190,7 +189,7 @@ export function loadMoltbotPlugins(options: PluginLoadOptions = {}): PluginRegis
|
||||
coreGatewayHandlers: options.coreGatewayHandlers as Record<string, GatewayRequestHandler>,
|
||||
});
|
||||
|
||||
const discovery = discoverMoltbotPlugins({
|
||||
const discovery = discoverOpenClawPlugins({
|
||||
workspaceDir: options.workspaceDir,
|
||||
extraPaths: normalized.loadPaths,
|
||||
});
|
||||
@@ -209,10 +208,7 @@ export function loadMoltbotPlugins(options: PluginLoadOptions = {}): PluginRegis
|
||||
extensions: [".ts", ".tsx", ".mts", ".cts", ".mtsx", ".ctsx", ".js", ".mjs", ".cjs", ".json"],
|
||||
...(pluginSdkAlias
|
||||
? {
|
||||
alias: {
|
||||
"clawdbot/plugin-sdk": pluginSdkAlias,
|
||||
"moltbot/plugin-sdk": pluginSdkAlias,
|
||||
},
|
||||
alias: { "openclaw/plugin-sdk": pluginSdkAlias },
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
@@ -290,9 +286,9 @@ export function loadMoltbotPlugins(options: PluginLoadOptions = {}): PluginRegis
|
||||
continue;
|
||||
}
|
||||
|
||||
let mod: MoltbotPluginModule | null = null;
|
||||
let mod: OpenClawPluginModule | null = null;
|
||||
try {
|
||||
mod = jiti(candidate.source) as MoltbotPluginModule;
|
||||
mod = jiti(candidate.source) as OpenClawPluginModule;
|
||||
} catch (err) {
|
||||
logger.error(`[plugins] ${record.id} failed to load from ${record.source}: ${String(err)}`);
|
||||
record.status = "error";
|
||||
|
||||
Reference in New Issue
Block a user