mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 16:21:15 +00:00
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:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user