refactor: rename clawdbot to moltbot with legacy compat

This commit is contained in:
Peter Steinberger
2026-01-27 12:19:58 +00:00
parent 83460df96f
commit 6d16a658e5
1839 changed files with 11250 additions and 11199 deletions
+13 -13
View File
@@ -1,7 +1,7 @@
import path from "node:path";
import { pathToFileURL } from "node:url";
import type { ClawdbotPluginApi } from "../plugins/types.js";
import type { MoltbotPluginApi } from "../plugins/types.js";
import type { HookEntry } from "./types.js";
import { shouldIncludeHook } from "./config.js";
import { loadHookEntriesFromDir } from "./workspace.js";
@@ -14,36 +14,36 @@ export type PluginHookLoadResult = {
errors: string[];
};
function resolveHookDir(api: ClawdbotPluginApi, dir: string): string {
function resolveHookDir(api: MoltbotPluginApi, dir: string): string {
if (path.isAbsolute(dir)) return dir;
return path.resolve(path.dirname(api.source), dir);
}
function normalizePluginHookEntry(api: ClawdbotPluginApi, entry: HookEntry): HookEntry {
function normalizePluginHookEntry(api: MoltbotPluginApi, entry: HookEntry): HookEntry {
return {
...entry,
hook: {
...entry.hook,
source: "clawdbot-plugin",
source: "moltbot-plugin",
pluginId: api.id,
},
clawdbot: {
...entry.clawdbot,
hookKey: entry.clawdbot?.hookKey ?? `${api.id}:${entry.hook.name}`,
events: entry.clawdbot?.events ?? [],
metadata: {
...entry.metadata,
hookKey: entry.metadata?.hookKey ?? `${api.id}:${entry.hook.name}`,
events: entry.metadata?.events ?? [],
},
};
}
async function loadHookHandler(
entry: HookEntry,
api: ClawdbotPluginApi,
api: MoltbotPluginApi,
): Promise<InternalHookHandler | null> {
try {
const url = pathToFileURL(entry.hook.handlerPath).href;
const cacheBustedUrl = `${url}?t=${Date.now()}`;
const mod = (await import(cacheBustedUrl)) as Record<string, unknown>;
const exportName = entry.clawdbot?.export ?? "default";
const exportName = entry.metadata?.export ?? "default";
const handler = mod[exportName];
if (typeof handler === "function") {
return handler as InternalHookHandler;
@@ -57,13 +57,13 @@ async function loadHookHandler(
}
export async function registerPluginHooksFromDir(
api: ClawdbotPluginApi,
api: MoltbotPluginApi,
dir: string,
): Promise<PluginHookLoadResult> {
const resolvedDir = resolveHookDir(api, dir);
const hooks = loadHookEntriesFromDir({
dir: resolvedDir,
source: "clawdbot-plugin",
source: "moltbot-plugin",
pluginId: api.id,
});
@@ -76,7 +76,7 @@ export async function registerPluginHooksFromDir(
for (const entry of hooks) {
const normalizedEntry = normalizePluginHookEntry(api, entry);
const events = normalizedEntry.clawdbot?.events ?? [];
const events = normalizedEntry.metadata?.events ?? [];
if (events.length === 0) {
api.logger.warn?.(`[hooks] ${entry.hook.name} has no events; skipping`);
api.registerHook(events, async () => undefined, {