mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-06 14:51:08 +00:00
* fix(plugins): preserve activation provenance * fix(gateway): preserve activation reason metadata * fix(plugins): harden activation state policy
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import type { OpenClawConfig } from "../config/config.js";
|
|
import { applyPluginAutoEnable } from "../config/plugin-auto-enable.js";
|
|
import { resolveRuntimePluginRegistry } from "./loader.js";
|
|
import { getMemoryRuntime } from "./memory-state.js";
|
|
|
|
function ensureMemoryRuntime(cfg?: OpenClawConfig) {
|
|
const current = getMemoryRuntime();
|
|
if (current || !cfg) {
|
|
return current;
|
|
}
|
|
const autoEnabled = applyPluginAutoEnable({ config: cfg, env: process.env });
|
|
resolveRuntimePluginRegistry({
|
|
config: autoEnabled.config,
|
|
activationSourceConfig: cfg,
|
|
autoEnabledReasons: autoEnabled.autoEnabledReasons,
|
|
});
|
|
return getMemoryRuntime();
|
|
}
|
|
|
|
export async function getActiveMemorySearchManager(params: {
|
|
cfg: OpenClawConfig;
|
|
agentId: string;
|
|
purpose?: "default" | "status";
|
|
}) {
|
|
const runtime = ensureMemoryRuntime(params.cfg);
|
|
if (!runtime) {
|
|
return { manager: null, error: "memory plugin unavailable" };
|
|
}
|
|
return await runtime.getMemorySearchManager(params);
|
|
}
|
|
|
|
export function resolveActiveMemoryBackendConfig(params: { cfg: OpenClawConfig; agentId: string }) {
|
|
return ensureMemoryRuntime(params.cfg)?.resolveMemoryBackendConfig(params) ?? null;
|
|
}
|
|
|
|
export async function closeActiveMemorySearchManagers(cfg?: OpenClawConfig): Promise<void> {
|
|
void cfg;
|
|
const runtime = getMemoryRuntime();
|
|
await runtime?.closeAllMemorySearchManagers?.();
|
|
}
|