mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-28 17:31:19 +00:00
* refactor(plugins): trim activation and contract exports * test(plugins): restore fixture cleanup * refactor(plugins): trim install and loader exports * test(plugins): fully reset loader caches * refactor(plugins): trim metadata and catalog exports * test(plugins): preserve catalog trust coverage * refactor(plugins): trim provider and plugin exports * refactor(plugins): trim runtime and tool exports * test(plugins): update dead-export consumers * test(plugins): remove empty dead-export suites * refactor(plugins): align exports with split registry * refactor(plugins): trim drifted loader exports * style(plugins): format test fixtures * refactor(scripts): use supported plugin APIs * refactor(plugins): finish dead export cleanup * chore(deadcode): refresh export baseline * test(cli): mock production memory state * chore(deadcode): sync latest export baseline * fix(tests): keep plugin fixtures inside core * chore(deadcode): refresh rebased export baseline * chore(deadcode): sync current ratchets * fix(plugins): retain reserved slot invariant * fix(plugins): preserve dead-export invariants * test(plugins): use neutral catalog query fixture * test(plugins): satisfy catalog lint * test(plugins): preserve integrity drift coverage * fix(ci): register skill experience live proof
70 lines
2.2 KiB
TypeScript
70 lines
2.2 KiB
TypeScript
// Verifies plugin loader runtime registry behavior.
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import {
|
|
clearPluginRegistryLoadCache,
|
|
loadOpenClawPlugins,
|
|
resolveRuntimePluginRegistry,
|
|
} from "./loader.js";
|
|
import { resetPluginLoaderTestStateForTest } from "./loader.test-fixtures.js";
|
|
import {
|
|
getMemoryEmbeddingProvider,
|
|
registerMemoryEmbeddingProvider,
|
|
} from "./memory-embedding-providers.js";
|
|
import { buildMemoryPromptSection, registerMemoryCapability } from "./memory-state.js";
|
|
import { createEmptyPluginRegistry } from "./registry.js";
|
|
import { setActivePluginRegistry } from "./runtime.js";
|
|
|
|
afterEach(() => {
|
|
resetPluginLoaderTestStateForTest();
|
|
});
|
|
|
|
function requireMemoryEmbeddingProvider(providerId: string) {
|
|
const provider = getMemoryEmbeddingProvider(providerId);
|
|
if (!provider) {
|
|
throw new Error(`expected ${providerId} memory embedding provider`);
|
|
}
|
|
return provider;
|
|
}
|
|
|
|
describe("resolveRuntimePluginRegistry", () => {
|
|
it("falls back to the current active runtime when no explicit load context is provided", () => {
|
|
const registry = createEmptyPluginRegistry();
|
|
setActivePluginRegistry(registry, "startup-registry");
|
|
|
|
expect(resolveRuntimePluginRegistry()).toBe(registry);
|
|
});
|
|
});
|
|
|
|
describe("clearPluginRegistryLoadCache", () => {
|
|
it("preserves plugin-owned runtime registries while invalidating load snapshots", () => {
|
|
registerMemoryEmbeddingProvider({
|
|
id: "still-live",
|
|
create: async () => ({ provider: null }),
|
|
});
|
|
registerMemoryCapability("memory-core", {
|
|
promptBuilder: () => ["still live"],
|
|
});
|
|
|
|
clearPluginRegistryLoadCache();
|
|
|
|
expect(buildMemoryPromptSection({ availableTools: new Set() })).toEqual(["still live"]);
|
|
expect(requireMemoryEmbeddingProvider("still-live").id).toBe("still-live");
|
|
});
|
|
|
|
it("invalidates full-workspace load snapshots", () => {
|
|
const loadOptions = {
|
|
config: {
|
|
plugins: {
|
|
allow: ["demo"],
|
|
},
|
|
},
|
|
workspaceDir: "/tmp/workspace-a",
|
|
};
|
|
const registry = loadOpenClawPlugins(loadOptions);
|
|
|
|
clearPluginRegistryLoadCache();
|
|
|
|
expect(loadOpenClawPlugins(loadOptions)).not.toBe(registry);
|
|
});
|
|
});
|