mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-07 13:21:25 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -8,17 +8,17 @@ import type {
|
||||
import { registerInternalHook } from "../hooks/internal-hooks.js";
|
||||
import { resolveUserPath } from "../utils.js";
|
||||
import type {
|
||||
MoltbotPluginApi,
|
||||
MoltbotPluginChannelRegistration,
|
||||
MoltbotPluginCliRegistrar,
|
||||
MoltbotPluginCommandDefinition,
|
||||
MoltbotPluginHttpHandler,
|
||||
MoltbotPluginHttpRouteHandler,
|
||||
MoltbotPluginHookOptions,
|
||||
OpenClawPluginApi,
|
||||
OpenClawPluginChannelRegistration,
|
||||
OpenClawPluginCliRegistrar,
|
||||
OpenClawPluginCommandDefinition,
|
||||
OpenClawPluginHttpHandler,
|
||||
OpenClawPluginHttpRouteHandler,
|
||||
OpenClawPluginHookOptions,
|
||||
ProviderPlugin,
|
||||
MoltbotPluginService,
|
||||
MoltbotPluginToolContext,
|
||||
MoltbotPluginToolFactory,
|
||||
OpenClawPluginService,
|
||||
OpenClawPluginToolContext,
|
||||
OpenClawPluginToolFactory,
|
||||
PluginConfigUiHint,
|
||||
PluginDiagnostic,
|
||||
PluginLogger,
|
||||
@@ -36,7 +36,7 @@ import { normalizePluginHttpPath } from "./http-path.js";
|
||||
|
||||
export type PluginToolRegistration = {
|
||||
pluginId: string;
|
||||
factory: MoltbotPluginToolFactory;
|
||||
factory: OpenClawPluginToolFactory;
|
||||
names: string[];
|
||||
optional: boolean;
|
||||
source: string;
|
||||
@@ -44,21 +44,21 @@ export type PluginToolRegistration = {
|
||||
|
||||
export type PluginCliRegistration = {
|
||||
pluginId: string;
|
||||
register: MoltbotPluginCliRegistrar;
|
||||
register: OpenClawPluginCliRegistrar;
|
||||
commands: string[];
|
||||
source: string;
|
||||
};
|
||||
|
||||
export type PluginHttpRegistration = {
|
||||
pluginId: string;
|
||||
handler: MoltbotPluginHttpHandler;
|
||||
handler: OpenClawPluginHttpHandler;
|
||||
source: string;
|
||||
};
|
||||
|
||||
export type PluginHttpRouteRegistration = {
|
||||
pluginId?: string;
|
||||
path: string;
|
||||
handler: MoltbotPluginHttpRouteHandler;
|
||||
handler: OpenClawPluginHttpRouteHandler;
|
||||
source?: string;
|
||||
};
|
||||
|
||||
@@ -84,13 +84,13 @@ export type PluginHookRegistration = {
|
||||
|
||||
export type PluginServiceRegistration = {
|
||||
pluginId: string;
|
||||
service: MoltbotPluginService;
|
||||
service: OpenClawPluginService;
|
||||
source: string;
|
||||
};
|
||||
|
||||
export type PluginCommandRegistration = {
|
||||
pluginId: string;
|
||||
command: MoltbotPluginCommandDefinition;
|
||||
command: OpenClawPluginCommandDefinition;
|
||||
source: string;
|
||||
};
|
||||
|
||||
@@ -167,13 +167,13 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
|
||||
const registerTool = (
|
||||
record: PluginRecord,
|
||||
tool: AnyAgentTool | MoltbotPluginToolFactory,
|
||||
tool: AnyAgentTool | OpenClawPluginToolFactory,
|
||||
opts?: { name?: string; names?: string[]; optional?: boolean },
|
||||
) => {
|
||||
const names = opts?.names ?? (opts?.name ? [opts.name] : []);
|
||||
const optional = opts?.optional === true;
|
||||
const factory: MoltbotPluginToolFactory =
|
||||
typeof tool === "function" ? tool : (_ctx: MoltbotPluginToolContext) => tool;
|
||||
const factory: OpenClawPluginToolFactory =
|
||||
typeof tool === "function" ? tool : (_ctx: OpenClawPluginToolContext) => tool;
|
||||
|
||||
if (typeof tool !== "function") {
|
||||
names.push(tool.name);
|
||||
@@ -196,8 +196,8 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
record: PluginRecord,
|
||||
events: string | string[],
|
||||
handler: Parameters<typeof registerInternalHook>[1],
|
||||
opts: MoltbotPluginHookOptions | undefined,
|
||||
config: MoltbotPluginApi["config"],
|
||||
opts: OpenClawPluginHookOptions | undefined,
|
||||
config: OpenClawPluginApi["config"],
|
||||
) => {
|
||||
const eventList = Array.isArray(events) ? events : [events];
|
||||
const normalizedEvents = eventList.map((event) => event.trim()).filter(Boolean);
|
||||
@@ -221,7 +221,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
...entry.hook,
|
||||
name,
|
||||
description,
|
||||
source: "moltbot-plugin",
|
||||
source: "openclaw-plugin",
|
||||
pluginId: record.id,
|
||||
},
|
||||
metadata: {
|
||||
@@ -233,7 +233,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
hook: {
|
||||
name,
|
||||
description,
|
||||
source: "moltbot-plugin",
|
||||
source: "openclaw-plugin",
|
||||
pluginId: record.id,
|
||||
filePath: record.source,
|
||||
baseDir: path.dirname(record.source),
|
||||
@@ -282,7 +282,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
record.gatewayMethods.push(trimmed);
|
||||
};
|
||||
|
||||
const registerHttpHandler = (record: PluginRecord, handler: MoltbotPluginHttpHandler) => {
|
||||
const registerHttpHandler = (record: PluginRecord, handler: OpenClawPluginHttpHandler) => {
|
||||
record.httpHandlers += 1;
|
||||
registry.httpHandlers.push({
|
||||
pluginId: record.id,
|
||||
@@ -293,7 +293,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
|
||||
const registerHttpRoute = (
|
||||
record: PluginRecord,
|
||||
params: { path: string; handler: MoltbotPluginHttpRouteHandler },
|
||||
params: { path: string; handler: OpenClawPluginHttpRouteHandler },
|
||||
) => {
|
||||
const normalizedPath = normalizePluginHttpPath(params.path);
|
||||
if (!normalizedPath) {
|
||||
@@ -325,11 +325,11 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
|
||||
const registerChannel = (
|
||||
record: PluginRecord,
|
||||
registration: MoltbotPluginChannelRegistration | ChannelPlugin,
|
||||
registration: OpenClawPluginChannelRegistration | ChannelPlugin,
|
||||
) => {
|
||||
const normalized =
|
||||
typeof (registration as MoltbotPluginChannelRegistration).plugin === "object"
|
||||
? (registration as MoltbotPluginChannelRegistration)
|
||||
typeof (registration as OpenClawPluginChannelRegistration).plugin === "object"
|
||||
? (registration as OpenClawPluginChannelRegistration)
|
||||
: { plugin: registration as ChannelPlugin };
|
||||
const plugin = normalized.plugin;
|
||||
const id = typeof plugin?.id === "string" ? plugin.id.trim() : String(plugin?.id ?? "").trim();
|
||||
@@ -382,7 +382,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
|
||||
const registerCli = (
|
||||
record: PluginRecord,
|
||||
registrar: MoltbotPluginCliRegistrar,
|
||||
registrar: OpenClawPluginCliRegistrar,
|
||||
opts?: { commands?: string[] },
|
||||
) => {
|
||||
const commands = (opts?.commands ?? []).map((cmd) => cmd.trim()).filter(Boolean);
|
||||
@@ -395,7 +395,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
});
|
||||
};
|
||||
|
||||
const registerService = (record: PluginRecord, service: MoltbotPluginService) => {
|
||||
const registerService = (record: PluginRecord, service: OpenClawPluginService) => {
|
||||
const id = service.id.trim();
|
||||
if (!id) return;
|
||||
record.services.push(id);
|
||||
@@ -406,7 +406,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
});
|
||||
};
|
||||
|
||||
const registerCommand = (record: PluginRecord, command: MoltbotPluginCommandDefinition) => {
|
||||
const registerCommand = (record: PluginRecord, command: OpenClawPluginCommandDefinition) => {
|
||||
const name = command.name.trim();
|
||||
if (!name) {
|
||||
pushDiagnostic({
|
||||
@@ -464,10 +464,10 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
const createApi = (
|
||||
record: PluginRecord,
|
||||
params: {
|
||||
config: MoltbotPluginApi["config"];
|
||||
config: OpenClawPluginApi["config"];
|
||||
pluginConfig?: Record<string, unknown>;
|
||||
},
|
||||
): MoltbotPluginApi => {
|
||||
): OpenClawPluginApi => {
|
||||
return {
|
||||
id: record.id,
|
||||
name: record.name,
|
||||
|
||||
Reference in New Issue
Block a user