mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-24 07:31:44 +00:00
fix: preserve linked install unsafe flag and baseline regressions
This commit is contained in:
@@ -46,17 +46,29 @@ function createModuleLoader() {
|
||||
|
||||
const loadModule = createModuleLoader();
|
||||
|
||||
function resolveContractSurfaceModulePath(rootDir: string | undefined): string | null {
|
||||
function resolveContractSurfaceModulePaths(rootDir: string | undefined): string[] {
|
||||
if (typeof rootDir !== "string" || rootDir.length === 0) {
|
||||
return null;
|
||||
return [];
|
||||
}
|
||||
const modulePaths: string[] = [];
|
||||
for (const basename of CONTRACT_SURFACE_BASENAMES) {
|
||||
const modulePath = path.join(rootDir, basename);
|
||||
if (fs.existsSync(modulePath)) {
|
||||
return modulePath;
|
||||
if (!fs.existsSync(modulePath)) {
|
||||
continue;
|
||||
}
|
||||
const compiledDistModulePath = modulePath.replace(
|
||||
`${path.sep}dist-runtime${path.sep}`,
|
||||
`${path.sep}dist${path.sep}`,
|
||||
);
|
||||
// Prefer the compiled dist module over the dist-runtime shim so Jiti sees
|
||||
// the full named export surface instead of only local wrapper exports.
|
||||
if (compiledDistModulePath !== modulePath && fs.existsSync(compiledDistModulePath)) {
|
||||
modulePaths.push(compiledDistModulePath);
|
||||
continue;
|
||||
}
|
||||
modulePaths.push(modulePath);
|
||||
}
|
||||
return null;
|
||||
return modulePaths;
|
||||
}
|
||||
|
||||
function loadBundledChannelContractSurfaces(): unknown[] {
|
||||
@@ -79,14 +91,18 @@ function loadBundledChannelContractSurfaceEntries(): Array<{
|
||||
if (manifest.origin !== "bundled" || manifest.channels.length === 0) {
|
||||
continue;
|
||||
}
|
||||
const modulePath = resolveContractSurfaceModulePath(manifest.rootDir);
|
||||
if (!modulePath) {
|
||||
const modulePaths = resolveContractSurfaceModulePaths(manifest.rootDir);
|
||||
if (modulePaths.length === 0) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const surface = Object.assign(
|
||||
{},
|
||||
...modulePaths.map((modulePath) => loadModule(modulePath)(modulePath) as object),
|
||||
);
|
||||
surfaces.push({
|
||||
pluginId: manifest.id,
|
||||
surface: loadModule(modulePath)(modulePath),
|
||||
surface,
|
||||
});
|
||||
} catch {
|
||||
continue;
|
||||
|
||||
@@ -897,8 +897,14 @@ function patchConfigForScopedAccount(params: {
|
||||
ensureEnabled: boolean;
|
||||
}): OpenClawConfig {
|
||||
const { cfg, channel, accountId, patch, ensureEnabled } = params;
|
||||
const channelConfig = cfg.channels?.[channel] as
|
||||
| { accounts?: Record<string, unknown> }
|
||||
| undefined;
|
||||
const hasExistingAccounts = Boolean(
|
||||
channelConfig?.accounts && Object.keys(channelConfig.accounts).length > 0,
|
||||
);
|
||||
const seededCfg =
|
||||
accountId === DEFAULT_ACCOUNT_ID
|
||||
accountId === DEFAULT_ACCOUNT_ID || hasExistingAccounts
|
||||
? cfg
|
||||
: moveSingleAccountChannelSectionToDefaultAccount({
|
||||
cfg,
|
||||
|
||||
@@ -567,11 +567,20 @@ function discoverInDirectory(params: {
|
||||
candidates: PluginCandidate[];
|
||||
diagnostics: PluginDiagnostic[];
|
||||
seen: Set<string>;
|
||||
recurseDirectories?: boolean;
|
||||
skipDirectories?: Set<string>;
|
||||
visitedDirectories?: Set<string>;
|
||||
}) {
|
||||
if (!fs.existsSync(params.dir)) {
|
||||
return;
|
||||
}
|
||||
const resolvedDir = safeRealpathSync(params.dir) ?? path.resolve(params.dir);
|
||||
if (params.recurseDirectories) {
|
||||
if (params.visitedDirectories?.has(resolvedDir)) {
|
||||
return;
|
||||
}
|
||||
params.visitedDirectories?.add(resolvedDir);
|
||||
}
|
||||
let entries: fs.Dirent[] = [];
|
||||
try {
|
||||
entries = fs.readdirSync(params.dir, { withFileTypes: true });
|
||||
@@ -695,6 +704,14 @@ function discoverInDirectory(params: {
|
||||
manifest,
|
||||
packageDir: fullPath,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
if (params.recurseDirectories) {
|
||||
discoverInDirectory({
|
||||
...params,
|
||||
dir: fullPath,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -894,6 +911,18 @@ export function discoverOpenClawPlugins(params: {
|
||||
});
|
||||
}
|
||||
if (roots.workspace && workspaceRoot) {
|
||||
discoverInDirectory({
|
||||
dir: workspaceRoot,
|
||||
origin: "workspace",
|
||||
ownershipUid: params.ownershipUid,
|
||||
workspaceDir: workspaceRoot,
|
||||
candidates,
|
||||
diagnostics,
|
||||
seen,
|
||||
recurseDirectories: true,
|
||||
skipDirectories: new Set([".openclaw"]),
|
||||
visitedDirectories: new Set<string>(),
|
||||
});
|
||||
discoverInDirectory({
|
||||
dir: roots.workspace,
|
||||
origin: "workspace",
|
||||
|
||||
Reference in New Issue
Block a user