























@@ -164,6 +164,154 @@ describe("getCompatibleActivePluginRegistry", () => {
164164}),
165165).toBeUndefined();
166166});
167+168+it("reuses a scoped gateway-bindable registry for an unscoped default-mode request", () => {
169+const registry = createEmptyPluginRegistry();
170+registry.plugins.push(
171+{ id: "acpx" } as (typeof registry.plugins)[number],
172+{ id: "telegram" } as (typeof registry.plugins)[number],
173+);
174+const startupOptions = {
175+config: {
176+plugins: {
177+allow: ["acpx", "telegram"],
178+},
179+},
180+workspaceDir: "/tmp/workspace-a",
181+onlyPluginIds: ["acpx", "telegram"],
182+runtimeOptions: {
183+allowGatewaySubagentBinding: true,
184+},
185+};
186+const { cacheKey } = __testing.resolvePluginLoadCacheContext(startupOptions);
187+setActivePluginRegistry(registry, cacheKey, "gateway-bindable");
188+189+expect(
190+__testing.getCompatibleActivePluginRegistry({
191+config: startupOptions.config,
192+workspaceDir: "/tmp/workspace-a",
193+}),
194+).toBe(registry);
195+});
196+197+it("reuses a scoped gateway-bindable registry for an unscoped snapshot-mode request", () => {
198+const registry = createEmptyPluginRegistry();
199+registry.plugins.push(
200+{ id: "acpx" } as (typeof registry.plugins)[number],
201+{ id: "telegram" } as (typeof registry.plugins)[number],
202+);
203+const startupOptions = {
204+config: {
205+plugins: {
206+allow: ["acpx", "telegram"],
207+},
208+},
209+workspaceDir: "/tmp/workspace-a",
210+onlyPluginIds: ["acpx", "telegram"],
211+runtimeOptions: {
212+allowGatewaySubagentBinding: true,
213+},
214+};
215+const { cacheKey } = __testing.resolvePluginLoadCacheContext(startupOptions);
216+setActivePluginRegistry(registry, cacheKey, "gateway-bindable");
217+218+expect(
219+__testing.getCompatibleActivePluginRegistry({
220+config: startupOptions.config,
221+workspaceDir: "/tmp/workspace-a",
222+activate: false,
223+}),
224+).toBe(registry);
225+});
226+227+it("does not reuse a scoped registry when plugin IDs differ", () => {
228+const registry = createEmptyPluginRegistry();
229+registry.plugins.push({ id: "acpx" } as (typeof registry.plugins)[number]);
230+const startupOptions = {
231+config: {
232+plugins: {
233+allow: ["acpx", "telegram"],
234+},
235+},
236+workspaceDir: "/tmp/workspace-a",
237+onlyPluginIds: ["acpx", "telegram"],
238+runtimeOptions: {
239+allowGatewaySubagentBinding: true,
240+},
241+};
242+const { cacheKey } = __testing.resolvePluginLoadCacheContext(startupOptions);
243+setActivePluginRegistry(registry, cacheKey, "gateway-bindable");
244+245+expect(
246+__testing.getCompatibleActivePluginRegistry({
247+config: startupOptions.config,
248+workspaceDir: "/tmp/workspace-a",
249+}),
250+).toBeUndefined();
251+});
252+253+it("does not reuse a scoped gateway-bindable registry for an explicit subagent request", () => {
254+const registry = createEmptyPluginRegistry();
255+registry.plugins.push(
256+{ id: "acpx" } as (typeof registry.plugins)[number],
257+{ id: "telegram" } as (typeof registry.plugins)[number],
258+);
259+const startupOptions = {
260+config: {
261+plugins: {
262+allow: ["acpx", "telegram"],
263+},
264+},
265+workspaceDir: "/tmp/workspace-a",
266+onlyPluginIds: ["acpx", "telegram"],
267+runtimeOptions: {
268+allowGatewaySubagentBinding: true,
269+},
270+};
271+const { cacheKey } = __testing.resolvePluginLoadCacheContext(startupOptions);
272+setActivePluginRegistry(registry, cacheKey, "gateway-bindable");
273+274+expect(
275+__testing.getCompatibleActivePluginRegistry({
276+config: startupOptions.config,
277+workspaceDir: "/tmp/workspace-a",
278+runtimeOptions: {
279+subagent: {} as CreatePluginRuntimeOptions["subagent"],
280+},
281+}),
282+).toBeUndefined();
283+});
284+285+it("reuses a scoped startup registry when only the request omits gateway methods", () => {
286+const registry = createEmptyPluginRegistry();
287+registry.plugins.push(
288+{ id: "acpx" } as (typeof registry.plugins)[number],
289+{ id: "telegram" } as (typeof registry.plugins)[number],
290+);
291+registry.coreGatewayMethodNames = ["sessions.get", "sessions.list"];
292+const startupOptions = {
293+config: {
294+plugins: {
295+allow: ["acpx", "telegram"],
296+},
297+},
298+workspaceDir: "/tmp/workspace-a",
299+onlyPluginIds: ["acpx", "telegram"],
300+coreGatewayMethodNames: ["sessions.get", "sessions.list"],
301+runtimeOptions: {
302+allowGatewaySubagentBinding: true,
303+},
304+};
305+const { cacheKey } = __testing.resolvePluginLoadCacheContext(startupOptions);
306+setActivePluginRegistry(registry, cacheKey, "gateway-bindable");
307+308+expect(
309+__testing.getCompatibleActivePluginRegistry({
310+config: startupOptions.config,
311+workspaceDir: "/tmp/workspace-a",
312+}),
313+).toBe(registry);
314+});
167315});
168316169317describe("resolveRuntimePluginRegistry", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。