Files
openclaw/src/plugins/externalized-bundled-plugins.ts
Vincent Koc c070509b7f fix(security): bound archive and MIME parser work (#71561)
* fix(security): bound archive and MIME parser work

* fix(security): harden zip preflight accounting

* fix(plugins): keep update channel sync on bundled path helpers

* fix(lint): avoid boolean literal comparisons

* fix(lint): keep agent spawn assertion immutable

* test(auto-reply): relax slow model directive regression timeout
2026-04-25 06:22:56 -07:00

53 lines
1.8 KiB
TypeScript

export type ExternalizedBundledPluginBridge = {
/** Plugin id used while the plugin was bundled in core. */
bundledPluginId: string;
/** Plugin id declared by the external package. Defaults to bundledPluginId. */
pluginId?: string;
/** npm spec OpenClaw should install when migrating the bundled plugin out. */
npmSpec: string;
/** Bundled directory name, when it differs from bundledPluginId. */
bundledDirName?: string;
/** Previous bundled manifest default enablement from the persisted registry. */
enabledByDefault?: boolean;
/** Legacy ids that should be treated as this plugin during enablement checks. */
legacyPluginIds?: readonly string[];
/** Channel ids that imply this plugin is enabled when configured. */
channelIds?: readonly string[];
/** Plugin ids this external package supersedes for channel selection. */
preferOver?: readonly string[];
};
function normalizePluginId(value: string | undefined): string {
return value?.trim() ?? "";
}
export function getExternalizedBundledPluginTargetId(
bridge: ExternalizedBundledPluginBridge,
): string {
return normalizePluginId(bridge.pluginId) || normalizePluginId(bridge.bundledPluginId);
}
export function getExternalizedBundledPluginLookupIds(
bridge: ExternalizedBundledPluginBridge,
): readonly string[] {
return Array.from(
new Set(
[
bridge.bundledPluginId,
bridge.pluginId,
...(bridge.legacyPluginIds ?? []),
...(bridge.channelIds ?? []),
]
.map(normalizePluginId)
.filter(Boolean),
),
);
}
export function getExternalizedBundledPluginLegacyPathSuffix(
bridge: ExternalizedBundledPluginBridge,
): string {
const bundledDirName = bridge.bundledDirName ?? bridge.bundledPluginId;
return ["extensions", bundledDirName].join("/");
}