

























@@ -29,6 +29,7 @@ import {
2929restoreDetachedTaskLifecycleRuntimeRegistration,
3030} from "../tasks/detached-task-runtime-state.js";
3131import { resolveUserPath } from "../utils.js";
32+import { resolvePluginActivationSourceConfig } from "./activation-source-config.js";
3233import { buildPluginApi } from "./api-builder.js";
3334import { inspectBundleMcpRuntimeSupport } from "./bundle-mcp.js";
3435import {
@@ -833,11 +834,18 @@ function hasExplicitCompatibilityInputs(options: PluginLoadOptions): boolean {
833834function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) {
834835const env = options.env ?? process.env;
835836const cfg = applyTestPluginDefaults(options.config ?? {}, env);
836-const activationSourceConfig = options.activationSourceConfig ?? options.config ?? {};
837+const activationSourceConfig = resolvePluginActivationSourceConfig({
838+config: options.config,
839+activationSourceConfig: options.activationSourceConfig,
840+});
837841const normalized = normalizePluginsConfig(cfg.plugins);
838842const activationSource = createPluginActivationSource({
839843config: activationSourceConfig,
840844});
845+const trustNormalized = mergeTrustPluginConfigFromActivationSource({
846+ normalized,
847+ activationSource,
848+});
841849const onlyPluginIds = normalizePluginIdScope(options.onlyPluginIds);
842850const includeSetupOnlyChannelPlugins = options.includeSetupOnlyChannelPlugins === true;
843851const forceSetupOnlyChannelPlugins = options.forceSetupOnlyChannelPlugins === true;
@@ -848,7 +856,7 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) {
848856const coreGatewayMethodNames = Object.keys(options.coreGatewayHandlers ?? {}).toSorted();
849857const cacheKey = buildCacheKey({
850858workspaceDir: options.workspaceDir,
851-plugins: normalized,
859+plugins: trustNormalized,
852860activationMetadataKey: buildActivationMetadataHash({
853861 activationSource,
854862autoEnabledReasons: options.autoEnabledReasons ?? {},
@@ -868,7 +876,7 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) {
868876return {
869877 env,
870878 cfg,
871- normalized,
879+normalized: trustNormalized,
872880 activationSourceConfig,
873881 activationSource,
874882autoEnabledReasons: options.autoEnabledReasons ?? {},
@@ -884,6 +892,44 @@ function resolvePluginLoadCacheContext(options: PluginLoadOptions = {}) {
884892};
885893}
886894895+function mergeTrustPluginConfigFromActivationSource(params: {
896+normalized: NormalizedPluginsConfig;
897+activationSource: PluginActivationConfigSource;
898+}): NormalizedPluginsConfig {
899+const source = params.activationSource.plugins;
900+const allow = mergePluginTrustList(params.normalized.allow, source.allow);
901+const deny = mergePluginTrustList(params.normalized.deny, source.deny);
902+const loadPaths = mergePluginTrustList(params.normalized.loadPaths, source.loadPaths);
903+if (
904+allow === params.normalized.allow &&
905+deny === params.normalized.deny &&
906+loadPaths === params.normalized.loadPaths
907+) {
908+return params.normalized;
909+}
910+return {
911+ ...params.normalized,
912+ allow,
913+ deny,
914+ loadPaths,
915+};
916+}
917+918+function mergePluginTrustList(runtimeList: string[], sourceList: readonly string[]): string[] {
919+if (sourceList.length === 0) {
920+return runtimeList;
921+}
922+const merged = [...runtimeList];
923+const seen = new Set(merged);
924+for (const entry of sourceList) {
925+if (!seen.has(entry)) {
926+merged.push(entry);
927+seen.add(entry);
928+}
929+}
930+return merged.length === runtimeList.length ? runtimeList : merged;
931+}
932+887933function getCompatibleActivePluginRegistry(
888934options: PluginLoadOptions = {},
889935): PluginRegistry | undefined {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。