mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:10:45 +00:00
fix(matrix): require trusted wrapper package roots
This commit is contained in:
@@ -38,11 +38,26 @@ function readPackageJson(packageRoot) {
|
||||
}
|
||||
}
|
||||
|
||||
function hasTrustedOpenClawRootIndicator(packageRoot, packageJson) {
|
||||
const packageExports = packageJson?.exports ?? {};
|
||||
if (!Object.prototype.hasOwnProperty.call(packageExports, "./plugin-sdk")) {
|
||||
return false;
|
||||
}
|
||||
const hasCliEntryExport = Object.prototype.hasOwnProperty.call(packageExports, "./cli-entry");
|
||||
const hasOpenClawBin =
|
||||
(typeof packageJson?.bin === "string" && packageJson.bin.includes("openclaw")) ||
|
||||
(typeof packageJson?.bin === "object" &&
|
||||
packageJson.bin !== null &&
|
||||
typeof packageJson.bin.openclaw === "string");
|
||||
const hasOpenClawEntrypoint = fs.existsSync(path.join(packageRoot, "openclaw.mjs"));
|
||||
return hasCliEntryExport || hasOpenClawBin || hasOpenClawEntrypoint;
|
||||
}
|
||||
|
||||
function findOpenClawPackageRoot(startDir) {
|
||||
let cursor = path.resolve(startDir);
|
||||
for (let i = 0; i < 12; i += 1) {
|
||||
const pkg = readPackageJson(cursor);
|
||||
if (pkg?.name === "openclaw" && pkg.exports?.["./plugin-sdk"]) {
|
||||
if (pkg?.name === "openclaw" && hasTrustedOpenClawRootIndicator(cursor, pkg)) {
|
||||
return { packageRoot: cursor, packageJson: pkg };
|
||||
}
|
||||
const parent = path.dirname(cursor);
|
||||
|
||||
Reference in New Issue
Block a user