mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 22:40:21 +00:00
Plugins: extract loader host state
This commit is contained in:
@@ -43,6 +43,7 @@ This is an implementation checklist, not a future-design spec.
|
||||
| Loader post-import planning and register execution | `src/plugins/loader.ts` | `src/extension-host/loader-register.ts` | `partial` | Definition application, post-import validation planning, and `register(...)` execution now delegate through host-owned loader-register helpers while preserving current plugin behavior. |
|
||||
| Loader per-candidate orchestration | `src/plugins/loader.ts` | `src/extension-host/loader-flow.ts` | `partial` | The per-candidate load flow now runs through a host-owned orchestrator that composes planning, import, runtime validation, register execution, and record-state helpers. |
|
||||
| Loader top-level load orchestration | `src/plugins/loader.ts` | `src/extension-host/loader-orchestrator.ts` | `partial` | High-level load entry and compatibility facade behavior now route through a host-owned loader orchestrator while `src/plugins/loader.ts` remains the external compatibility surface. |
|
||||
| Loader host process state | mixed inside `src/plugins/loader.ts` and `src/extension-host/loader-orchestrator.ts` | `src/extension-host/loader-host-state.ts` | `partial` | Shared discovery warning-cache state and loader reset behavior now delegate through a host-owned loader-host-state helper. |
|
||||
| Loader preflight and cache-hit setup | mixed inside `src/plugins/loader.ts` and `src/extension-host/loader-orchestrator.ts` | `src/extension-host/loader-preflight.ts` | `partial` | Test-default application, config normalization, cache-key construction, cache-hit activation, and command-clear preflight now delegate through a host-owned loader-preflight helper. |
|
||||
| Loader post-preflight pipeline composition | mixed inside `src/plugins/loader.ts` and `src/extension-host/loader-orchestrator.ts` | `src/extension-host/loader-pipeline.ts` | `partial` | Post-preflight execution setup and session-run composition now delegate through a host-owned loader-pipeline helper. |
|
||||
| Loader execution setup composition | mixed inside `src/plugins/loader.ts` and `src/extension-host/loader-orchestrator.ts` | `src/extension-host/loader-execution.ts` | `partial` | Runtime creation, registry creation, bootstrap setup, module-loader creation, and session creation now delegate through a host-owned loader-execution helper. |
|
||||
|
||||
16
src/extension-host/loader-host-state.test.ts
Normal file
16
src/extension-host/loader-host-state.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
clearExtensionHostLoaderHostState,
|
||||
getExtensionHostDiscoveryWarningCache,
|
||||
} from "./loader-host-state.js";
|
||||
|
||||
describe("extension host loader host state", () => {
|
||||
it("clears the shared discovery warning cache", () => {
|
||||
const warningCache = getExtensionHostDiscoveryWarningCache();
|
||||
warningCache.add("warn-key");
|
||||
|
||||
clearExtensionHostLoaderHostState();
|
||||
|
||||
expect(getExtensionHostDiscoveryWarningCache().size).toBe(0);
|
||||
});
|
||||
});
|
||||
12
src/extension-host/loader-host-state.ts
Normal file
12
src/extension-host/loader-host-state.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { clearExtensionHostRegistryCache } from "./loader-cache.js";
|
||||
|
||||
const extensionHostDiscoveryWarningCache = new Set<string>();
|
||||
|
||||
export function getExtensionHostDiscoveryWarningCache(): Set<string> {
|
||||
return extensionHostDiscoveryWarningCache;
|
||||
}
|
||||
|
||||
export function clearExtensionHostLoaderHostState(): void {
|
||||
clearExtensionHostRegistryCache();
|
||||
extensionHostDiscoveryWarningCache.clear();
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { clearExtensionHostRegistryCache } from "../extension-host/loader-cache.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { clearPluginCommands } from "../plugins/commands.js";
|
||||
import type { PluginRegistry } from "../plugins/registry.js";
|
||||
import { createPluginRuntime, type CreatePluginRuntimeOptions } from "../plugins/runtime/index.js";
|
||||
import type { PluginLogger } from "../plugins/types.js";
|
||||
import {
|
||||
clearExtensionHostLoaderHostState,
|
||||
getExtensionHostDiscoveryWarningCache,
|
||||
} from "./loader-host-state.js";
|
||||
import { executeExtensionHostLoaderPipeline } from "./loader-pipeline.js";
|
||||
import { prepareExtensionHostLoaderPreflight } from "./loader-preflight.js";
|
||||
|
||||
@@ -22,13 +25,10 @@ export type ExtensionHostPluginLoadOptions = {
|
||||
mode?: "full" | "validate";
|
||||
};
|
||||
|
||||
const openAllowlistWarningCache = new Set<string>();
|
||||
|
||||
const defaultLogger = () => createSubsystemLogger("plugins");
|
||||
|
||||
export function clearExtensionHostLoaderState(): void {
|
||||
clearExtensionHostRegistryCache();
|
||||
openAllowlistWarningCache.clear();
|
||||
clearExtensionHostLoaderHostState();
|
||||
}
|
||||
|
||||
export function loadExtensionHostPluginRegistry(
|
||||
@@ -49,7 +49,7 @@ export function loadExtensionHostPluginRegistry(
|
||||
cache: options.cache,
|
||||
coreGatewayHandlers: options.coreGatewayHandlers,
|
||||
runtimeOptions: options.runtimeOptions,
|
||||
warningCache: openAllowlistWarningCache,
|
||||
warningCache: getExtensionHostDiscoveryWarningCache(),
|
||||
createRuntime: createPluginRuntime,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user