fix(plugins): preserve gateway-bindable registry reuse

# Conflicts:
#	src/agents/runtime-plugins.test.ts
#	src/agents/runtime-plugins.ts
#	src/plugins/loader.ts
#	src/plugins/tools.ts
This commit is contained in:
Ayaan Zaidi
2026-03-29 09:53:30 +05:30
parent bb9394e123
commit e3faa99c6a
4 changed files with 62 additions and 8 deletions

View File

@@ -15,6 +15,7 @@ type RegistryState = {
httpRoute: RegistrySurfaceState;
channel: RegistrySurfaceState;
key: string | null;
runtimeSubagentMode: "default" | "explicit" | "gateway-bindable";
};
const state: RegistryState = (() => {
@@ -36,6 +37,7 @@ const state: RegistryState = (() => {
version: 0,
},
key: null,
runtimeSubagentMode: "default",
};
}
return globalState[REGISTRY_STATE];
@@ -71,12 +73,17 @@ function syncTrackedSurface(
installSurfaceRegistry(surface, registry, false);
}
export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) {
export function setActivePluginRegistry(
registry: PluginRegistry,
cacheKey?: string,
runtimeSubagentMode: "default" | "explicit" | "gateway-bindable" = "default",
) {
state.activeRegistry = registry;
state.activeVersion += 1;
syncTrackedSurface(state.httpRoute, registry, true);
syncTrackedSurface(state.channel, registry, true);
state.key = cacheKey ?? null;
state.runtimeSubagentMode = runtimeSubagentMode;
}
export function getActivePluginRegistry(): PluginRegistry | null {
@@ -175,6 +182,10 @@ export function getActivePluginRegistryKey(): string | null {
return state.key;
}
export function getActivePluginRuntimeSubagentMode(): "default" | "explicit" | "gateway-bindable" {
return state.runtimeSubagentMode;
}
export function getActivePluginRegistryVersion(): number {
return state.activeVersion;
}
@@ -185,4 +196,5 @@ export function resetPluginRuntimeStateForTest(): void {
installSurfaceRegistry(state.httpRoute, null, false);
installSurfaceRegistry(state.channel, null, false);
state.key = null;
state.runtimeSubagentMode = "default";
}