refactor(plugins): extract safety and provenance helpers

This commit is contained in:
Peter Steinberger
2026-02-19 15:24:02 +01:00
parent 775816035e
commit 77c748304b
6 changed files with 282 additions and 152 deletions

View File

@@ -4,6 +4,7 @@ import { resolveUserPath } from "../utils.js";
import { normalizePluginsConfig, type NormalizedPluginsConfig } from "./config-state.js";
import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
import { loadPluginManifest, type PluginManifest } from "./manifest.js";
import { safeRealpathSync } from "./path-safety.js";
import type { PluginConfigUiHint, PluginDiagnostic, PluginKind, PluginOrigin } from "./types.js";
type SeenIdEntry = {
@@ -19,20 +20,6 @@ const PLUGIN_ORIGIN_RANK: Readonly<Record<PluginOrigin, number>> = {
bundled: 3,
};
function safeRealpathSync(rootDir: string, cache: Map<string, string>): string | null {
const cached = cache.get(rootDir);
if (cached) {
return cached;
}
try {
const resolved = fs.realpathSync(rootDir);
cache.set(rootDir, resolved);
return resolved;
} catch {
return null;
}
}
export type PluginManifestRecord = {
id: string;
name?: string;