mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-04 15:30:21 +00:00
feat(plugins): add compatible bundle support
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
resolveOpenClawMetadata,
|
||||
resolveHookInvocationPolicy,
|
||||
} from "./frontmatter.js";
|
||||
import { resolvePluginHookDirs } from "./plugin-hooks.js";
|
||||
import type {
|
||||
Hook,
|
||||
HookEligibilityContext,
|
||||
@@ -242,6 +243,10 @@ function loadHookEntries(
|
||||
const extraDirs = extraDirsRaw
|
||||
.map((d) => (typeof d === "string" ? d.trim() : ""))
|
||||
.filter(Boolean);
|
||||
const pluginHookDirs = resolvePluginHookDirs({
|
||||
workspaceDir,
|
||||
config: opts?.config,
|
||||
});
|
||||
|
||||
const bundledHooks = bundledHooksDir
|
||||
? loadHooksFromDir({
|
||||
@@ -256,6 +261,13 @@ function loadHookEntries(
|
||||
source: "openclaw-workspace", // Extra dirs treated as workspace
|
||||
});
|
||||
});
|
||||
const pluginHooks = pluginHookDirs.flatMap(({ dir, pluginId }) =>
|
||||
loadHooksFromDir({
|
||||
dir,
|
||||
source: "openclaw-plugin",
|
||||
pluginId,
|
||||
}),
|
||||
);
|
||||
const managedHooks = loadHooksFromDir({
|
||||
dir: managedHooksDir,
|
||||
source: "openclaw-managed",
|
||||
@@ -266,13 +278,16 @@ function loadHookEntries(
|
||||
});
|
||||
|
||||
const merged = new Map<string, Hook>();
|
||||
// Precedence: extra < bundled < managed < workspace (workspace wins)
|
||||
// Precedence: extra < bundled < plugin < managed < workspace (workspace wins)
|
||||
for (const hook of extraHooks) {
|
||||
merged.set(hook.name, hook);
|
||||
}
|
||||
for (const hook of bundledHooks) {
|
||||
merged.set(hook.name, hook);
|
||||
}
|
||||
for (const hook of pluginHooks) {
|
||||
merged.set(hook.name, hook);
|
||||
}
|
||||
for (const hook of managedHooks) {
|
||||
merged.set(hook.name, hook);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user