@@ -58,6 +58,12 @@ import {
5858} from "./memory-state.js" ;
5959import { unwrapDefaultModuleExport } from "./module-export.js" ;
6060import { isPathInside , safeStatSync } from "./path-safety.js" ;
61+ import {
62+ createPluginIdScopeSet ,
63+ hasExplicitPluginIdScope ,
64+ normalizePluginIdScope ,
65+ serializePluginIdScope ,
66+ } from "./plugin-scope.js" ;
6167import { createPluginRegistry , type PluginRecord , type PluginRegistry } from "./registry.js" ;
6268import { resolvePluginCacheInputs } from "./roots.js" ;
6369import {
@@ -360,8 +366,7 @@ function buildCacheKey(params: {
360366 } ,
361367 ] ) ,
362368 ) ;
363- const scopeKey =
364- params . onlyPluginIds === undefined ? "__unscoped__" : JSON . stringify ( params . onlyPluginIds ) ;
369+ const scopeKey = serializePluginIdScope ( params . onlyPluginIds ) ;
365370 const setupOnlyKey = params . includeSetupOnlyChannelPlugins === true ? "setup-only" : "runtime" ;
366371 const startupChannelMode =
367372 params . preferSetupRuntimeForChannelPlugins === true ? "prefer-setup" : "full" ;
@@ -376,14 +381,6 @@ function buildCacheKey(params: {
376381 } ) } ::${ scopeKey } ::${ setupOnlyKey } ::${ startupChannelMode } ::${ moduleLoadMode } ::${ runtimeSubagentMode } ::${ params . pluginSdkResolution ?? "auto" } ::${ gatewayMethodsKey } `;
377382}
378383
379- function normalizeScopedPluginIds ( ids ?: string [ ] ) : string [ ] | undefined {
380- if ( ! ids ) {
381- return undefined ;
382- }
383- const normalized = Array . from ( new Set ( ids . map ( ( id ) => id . trim ( ) ) . filter ( Boolean ) ) ) . toSorted ( ) ;
384- return normalized ;
385- }
386-
387384function matchesScopedPluginRequest ( params : {
388385 onlyPluginIdSet : ReadonlySet < string > | null ;
389386 pluginId : string ;
@@ -451,7 +448,7 @@ function hasExplicitCompatibilityInputs(options: PluginLoadOptions): boolean {
451448 options . autoEnabledReasons !== undefined ||
452449 options . workspaceDir !== undefined ||
453450 options . env !== undefined ||
454- options . onlyPluginIds !== undefined ||
451+ hasExplicitPluginIdScope ( options . onlyPluginIds ) ||
455452 options . runtimeOptions !== undefined ||
456453 options . pluginSdkResolution !== undefined ||
457454 options . coreGatewayHandlers !== undefined ||
@@ -469,7 +466,7 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) {
469466 const activationSource = createPluginActivationSource ( {
470467 config : activationSourceConfig ,
471468 } ) ;
472- const onlyPluginIds = normalizeScopedPluginIds ( options . onlyPluginIds ) ;
469+ const onlyPluginIds = normalizePluginIdScope ( options . onlyPluginIds ) ;
473470 const includeSetupOnlyChannelPlugins = options . includeSetupOnlyChannelPlugins === true ;
474471 const preferSetupRuntimeForChannelPlugins = options . preferSetupRuntimeForChannelPlugins === true ;
475472 const runtimeSubagentMode = resolveRuntimeSubagentMode ( options . runtimeOptions ) ;
@@ -1097,7 +1094,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
10971094 } = resolvePluginLoadCacheContext ( options ) ;
10981095 const logger = options . logger ?? defaultLogger ( ) ;
10991096 const validateOnly = options . mode === "validate" ;
1100- const onlyPluginIdSet = onlyPluginIds ? new Set ( onlyPluginIds ) : null ;
1097+ const onlyPluginIdSet = createPluginIdScopeSet ( onlyPluginIds ) ;
11011098 const cacheEnabled = options . cache !== false ;
11021099 if ( cacheEnabled ) {
11031100 const cached = getCachedPluginRegistry ( cacheKey ) ;
@@ -1833,7 +1830,7 @@ export async function loadOpenClawPluginCliRegistry(
18331830 cache : false ,
18341831 } ) ;
18351832 const logger = options . logger ?? defaultLogger ( ) ;
1836- const onlyPluginIdSet = onlyPluginIds ? new Set ( onlyPluginIds ) : null ;
1833+ const onlyPluginIdSet = createPluginIdScopeSet ( onlyPluginIds ) ;
18371834 const getJiti = createPluginJitiLoader ( options ) ;
18381835 const { registry, registerCli } = createPluginRegistry ( {
18391836 logger,
0 commit comments