From d49ebe7bdee396b31dc31ebcb73adace84997f0c Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Tue, 28 Apr 2026 21:37:17 -0700 Subject: [PATCH] fix(plugins): stage runtime deps for selected slots --- src/plugins/bundled-runtime-deps.test.ts | 40 ++++++++++++++++++++++++ src/plugins/bundled-runtime-deps.ts | 3 ++ 2 files changed, 43 insertions(+) diff --git a/src/plugins/bundled-runtime-deps.test.ts b/src/plugins/bundled-runtime-deps.test.ts index 2abf6fd187e..1aab995ee50 100644 --- a/src/plugins/bundled-runtime-deps.test.ts +++ b/src/plugins/bundled-runtime-deps.test.ts @@ -1013,6 +1013,12 @@ describe("scanBundledPluginRuntimeDeps config policy", () => { includeConfiguredChannels: false, expectedDeps: [], }, + { + name: "includes selected memory slot bundled plugins behind restrictive allowlists", + config: { plugins: { allow: ["browser"], slots: { memory: "alpha" } } }, + includeConfiguredChannels: false, + expectedDeps: ["alpha-runtime@1.0.0"], + }, { name: "does not let explicit plugin entries bypass restrictive allowlists", config: { plugins: { allow: ["browser"], entries: { alpha: { enabled: true } } } }, @@ -2562,6 +2568,40 @@ describe("ensureBundledPluginRuntimeDeps", () => { expect(installRoot).not.toBe(pluginRoot); }); + it("installs runtime deps for the default memory slot bundled plugin", () => { + const packageRoot = makeTempDir(); + const pluginRoot = writeBundledPluginPackage({ + packageRoot, + pluginId: "memory-core", + deps: { chokidar: "^5.0.0" }, + }); + const calls: BundledRuntimeDepsInstallParams[] = []; + + const result = ensureBundledPluginRuntimeDeps({ + env: {}, + config: {}, + installDeps: (params) => { + calls.push(params); + }, + pluginId: "memory-core", + pluginRoot, + }); + + expect(result).toEqual({ + installedSpecs: ["chokidar@^5.0.0"], + retainSpecs: ["chokidar@^5.0.0"], + }); + const installRoot = resolveBundledRuntimeDependencyInstallRoot(pluginRoot, { env: {} }); + expect(calls).toEqual([ + { + installRoot, + missingSpecs: ["chokidar@^5.0.0"], + installSpecs: ["chokidar@^5.0.0"], + }, + ]); + expect(installRoot).not.toBe(pluginRoot); + }); + it("repairs external staged deps even when packaged plugin-local deps are present", () => { const packageRoot = makeTempDir(); const extensionsRoot = path.join(packageRoot, "dist", "extensions"); diff --git a/src/plugins/bundled-runtime-deps.ts b/src/plugins/bundled-runtime-deps.ts index fc930e664ec..b22c3144b24 100644 --- a/src/plugins/bundled-runtime-deps.ts +++ b/src/plugins/bundled-runtime-deps.ts @@ -1420,6 +1420,9 @@ function isBundledPluginConfiguredForRuntimeDeps(params: { } const entry = plugins.entries[params.pluginId]; const manifest = readBundledPluginRuntimeDepsManifest(params.pluginDir, params.manifestCache); + if (plugins.slots.memory === params.pluginId || plugins.slots.contextEngine === params.pluginId) { + return true; + } let hasExplicitChannelDisable = false; let hasConfiguredChannel = false; for (const channelId of manifest.channels) {