mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-29 18:12:52 +00:00
fix(memory): share embedding providers across plugin runtime splits (#55945)
Merged via squash.
Prepared head SHA: e913806211
Co-authored-by: glitch418x <189487110+glitch418x@users.noreply.github.com>
Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com>
Reviewed-by: @altaywtf
This commit is contained in:
@@ -11,6 +11,8 @@ import {
|
||||
type MemoryEmbeddingProviderAdapter,
|
||||
} from "./memory-embedding-providers.js";
|
||||
|
||||
const MEMORY_EMBEDDING_PROVIDERS_KEY = Symbol.for("openclaw.memoryEmbeddingProviders");
|
||||
|
||||
function createAdapter(id: string): MemoryEmbeddingProviderAdapter {
|
||||
return {
|
||||
id,
|
||||
@@ -81,4 +83,18 @@ describe("memory embedding provider registry", () => {
|
||||
|
||||
expect(listMemoryEmbeddingProviders()).toEqual([]);
|
||||
});
|
||||
|
||||
it("stores adapters in a process-global singleton map", () => {
|
||||
const alpha = createAdapter("alpha");
|
||||
registerMemoryEmbeddingProvider(alpha, { ownerPluginId: "memory-core" });
|
||||
|
||||
const globalRegistry = (globalThis as Record<PropertyKey, unknown>)[
|
||||
MEMORY_EMBEDDING_PROVIDERS_KEY
|
||||
] as Map<string, { adapter: MemoryEmbeddingProviderAdapter; ownerPluginId?: string }>;
|
||||
|
||||
expect(globalRegistry.get("alpha")).toEqual({
|
||||
adapter: alpha,
|
||||
ownerPluginId: "memory-core",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user