fix(matrix): stop discovering runtime helper as plugin entry

This commit is contained in:
Peter Steinberger 2026-03-29 21:00:28 +01:00
parent dc192d7b2f
commit d330782ed1
No known key found for this signature in database
2 changed files with 30 additions and 2 deletions

View File

@ -24,8 +24,7 @@
},
"openclaw": {
"extensions": [
"./index.ts",
"./src/plugin-entry.runtime.ts"
"./index.ts"
],
"setupEntry": "./setup-entry.ts",
"channel": {

View File

@ -12,6 +12,7 @@ const REPO_ROOT = resolve(ROOT_DIR, "..");
const EXTENSIONS_DIR = resolve(REPO_ROOT, BUNDLED_PLUGIN_ROOT_DIR);
const CORE_PLUGIN_ENTRY_IMPORT_RE =
/import\s*\{[^}]*\bdefinePluginEntry\b[^}]*\}\s*from\s*"openclaw\/plugin-sdk\/core"/;
const RUNTIME_ENTRY_HELPER_RE = /(^|\/)plugin-entry\.runtime\.[cm]?[jt]s$/;
describe("plugin entry guardrails", () => {
it("keeps bundled extension entry modules off direct definePluginEntry imports from core", () => {
@ -34,4 +35,32 @@ describe("plugin entry guardrails", () => {
expect(failures).toEqual([]);
});
it("does not advertise runtime helper sidecars as bundled plugin entry extensions", () => {
const failures: string[] = [];
for (const entry of readdirSync(EXTENSIONS_DIR, { withFileTypes: true })) {
if (!entry.isDirectory()) {
continue;
}
const packageJsonPath = resolve(EXTENSIONS_DIR, entry.name, "package.json");
try {
const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
openclaw?: { extensions?: unknown };
};
const extensions = Array.isArray(pkg.openclaw?.extensions) ? pkg.openclaw.extensions : [];
if (
extensions.some(
(candidate) => typeof candidate === "string" && RUNTIME_ENTRY_HELPER_RE.test(candidate),
)
) {
failures.push(bundledPluginFile(entry.name, "package.json"));
}
} catch {
// Skip directories without package metadata.
}
}
expect(failures).toEqual([]);
});
});