refactor(runtime): harden channel-registry cache invalidation and split outbound delivery flow

This commit is contained in:
Peter Steinberger
2026-03-03 00:05:12 +00:00
parent d6491d8d71
commit 1d0a4d1be2
4 changed files with 254 additions and 140 deletions

View File

@@ -5,6 +5,7 @@ const REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
type RegistryState = {
registry: PluginRegistry | null;
key: string | null;
version: number;
};
const state: RegistryState = (() => {
@@ -15,6 +16,7 @@ const state: RegistryState = (() => {
globalState[REGISTRY_STATE] = {
registry: createEmptyPluginRegistry(),
key: null,
version: 0,
};
}
return globalState[REGISTRY_STATE];
@@ -23,6 +25,7 @@ const state: RegistryState = (() => {
export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) {
state.registry = registry;
state.key = cacheKey ?? null;
state.version += 1;
}
export function getActivePluginRegistry(): PluginRegistry | null {
@@ -32,6 +35,7 @@ export function getActivePluginRegistry(): PluginRegistry | null {
export function requireActivePluginRegistry(): PluginRegistry {
if (!state.registry) {
state.registry = createEmptyPluginRegistry();
state.version += 1;
}
return state.registry;
}
@@ -39,3 +43,7 @@ export function requireActivePluginRegistry(): PluginRegistry {
export function getActivePluginRegistryKey(): string | null {
return state.key;
}
export function getActivePluginRegistryVersion(): number {
return state.version;
}