mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-07 23:31:07 +00:00
feat(plugins): surface imported runtime state in status tooling (#59659)
* feat(plugins): surface imported runtime state * fix(plugins): keep status imports snapshot-only * fix(plugins): keep status snapshots manifest-only * fix(plugins): restore doctor load checks * refactor(plugins): split snapshot and diagnostics reports * fix(plugins): track imported erroring modules * fix(plugins): keep hot metadata where required * fix(plugins): keep hot doctor and write targeting * fix(plugins): track throwing module imports
This commit is contained in:
@@ -16,6 +16,7 @@ type RegistryState = {
|
||||
channel: RegistrySurfaceState;
|
||||
key: string | null;
|
||||
runtimeSubagentMode: "default" | "explicit" | "gateway-bindable";
|
||||
importedPluginIds: Set<string>;
|
||||
};
|
||||
|
||||
const state: RegistryState = (() => {
|
||||
@@ -38,11 +39,16 @@ const state: RegistryState = (() => {
|
||||
},
|
||||
key: null,
|
||||
runtimeSubagentMode: "default",
|
||||
importedPluginIds: new Set<string>(),
|
||||
};
|
||||
}
|
||||
return globalState[REGISTRY_STATE];
|
||||
})();
|
||||
|
||||
export function recordImportedPluginId(pluginId: string): void {
|
||||
state.importedPluginIds.add(pluginId);
|
||||
}
|
||||
|
||||
function installSurfaceRegistry(
|
||||
surface: RegistrySurfaceState,
|
||||
registry: PluginRegistry | null,
|
||||
@@ -190,6 +196,39 @@ export function getActivePluginRegistryVersion(): number {
|
||||
return state.activeVersion;
|
||||
}
|
||||
|
||||
function collectLoadedPluginIds(
|
||||
registry: PluginRegistry | null | undefined,
|
||||
ids: Set<string>,
|
||||
): void {
|
||||
if (!registry) {
|
||||
return;
|
||||
}
|
||||
for (const plugin of registry.plugins) {
|
||||
if (plugin.status === "loaded" && plugin.format !== "bundle") {
|
||||
ids.add(plugin.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns plugin ids that were imported by plugin runtime or registry loading in
|
||||
* the current process.
|
||||
*
|
||||
* This is a process-level view, not a fresh import trace: cached registry reuse
|
||||
* still counts because the plugin code was loaded earlier in this process.
|
||||
* Explicit loader import tracking covers plugins that were imported but later
|
||||
* ended in an error state during registration.
|
||||
* Bundle-format plugins are excluded because they can be "loaded" from metadata
|
||||
* without importing any JS entrypoint.
|
||||
*/
|
||||
export function listImportedRuntimePluginIds(): string[] {
|
||||
const imported = new Set(state.importedPluginIds);
|
||||
collectLoadedPluginIds(state.activeRegistry, imported);
|
||||
collectLoadedPluginIds(state.channel.registry, imported);
|
||||
collectLoadedPluginIds(state.httpRoute.registry, imported);
|
||||
return [...imported].toSorted((left, right) => left.localeCompare(right));
|
||||
}
|
||||
|
||||
export function resetPluginRuntimeStateForTest(): void {
|
||||
state.activeRegistry = null;
|
||||
state.activeVersion += 1;
|
||||
@@ -197,4 +236,5 @@ export function resetPluginRuntimeStateForTest(): void {
|
||||
installSurfaceRegistry(state.channel, null, false);
|
||||
state.key = null;
|
||||
state.runtimeSubagentMode = "default";
|
||||
state.importedPluginIds.clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user