mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 16:21:15 +00:00
refactor: move tasks into bundled plugin
This commit is contained in:
@@ -35,6 +35,12 @@ import {
|
||||
getMemoryRuntime,
|
||||
restoreMemoryPluginState,
|
||||
} from "./memory-state.js";
|
||||
import {
|
||||
clearOperationsRuntimeState,
|
||||
getRegisteredOperationsRuntime,
|
||||
getRegisteredOperationsRuntimeOwner,
|
||||
restoreOperationsRuntimeState,
|
||||
} from "./operations-state.js";
|
||||
import { isPathInside, safeStatSync } from "./path-safety.js";
|
||||
import { createPluginRegistry, type PluginRecord, type PluginRegistry } from "./registry.js";
|
||||
import { resolvePluginCacheInputs } from "./roots.js";
|
||||
@@ -116,6 +122,8 @@ type CachedPluginState = {
|
||||
memoryFlushPlanResolver: ReturnType<typeof getMemoryFlushPlanResolver>;
|
||||
memoryPromptBuilder: ReturnType<typeof getMemoryPromptSectionBuilder>;
|
||||
memoryRuntime: ReturnType<typeof getMemoryRuntime>;
|
||||
operationsRuntime: ReturnType<typeof getRegisteredOperationsRuntime>;
|
||||
operationsRuntimeOwner: ReturnType<typeof getRegisteredOperationsRuntimeOwner>;
|
||||
};
|
||||
|
||||
const MAX_PLUGIN_REGISTRY_CACHE_ENTRIES = 128;
|
||||
@@ -136,6 +144,7 @@ const LAZY_RUNTIME_REFLECTION_KEYS = [
|
||||
"logging",
|
||||
"state",
|
||||
"modelAuth",
|
||||
"operations",
|
||||
] as const satisfies readonly (keyof PluginRuntime)[];
|
||||
|
||||
export function clearPluginLoaderCache(): void {
|
||||
@@ -143,6 +152,7 @@ export function clearPluginLoaderCache(): void {
|
||||
openAllowlistWarningCache.clear();
|
||||
clearMemoryEmbeddingProviders();
|
||||
clearMemoryPluginState();
|
||||
clearOperationsRuntimeState();
|
||||
}
|
||||
|
||||
const defaultLogger = () => createSubsystemLogger("plugins");
|
||||
@@ -843,6 +853,10 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
flushPlanResolver: cached.memoryFlushPlanResolver,
|
||||
runtime: cached.memoryRuntime,
|
||||
});
|
||||
restoreOperationsRuntimeState({
|
||||
runtime: cached.operationsRuntime,
|
||||
ownerPluginId: cached.operationsRuntimeOwner,
|
||||
});
|
||||
if (shouldActivate) {
|
||||
activatePluginRegistry(cached.registry, cacheKey, runtimeSubagentMode);
|
||||
}
|
||||
@@ -1336,6 +1350,8 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
const previousMemoryFlushPlanResolver = getMemoryFlushPlanResolver();
|
||||
const previousMemoryPromptBuilder = getMemoryPromptSectionBuilder();
|
||||
const previousMemoryRuntime = getMemoryRuntime();
|
||||
const previousOperationsRuntime = getRegisteredOperationsRuntime();
|
||||
const previousOperationsRuntimeOwner = getRegisteredOperationsRuntimeOwner();
|
||||
|
||||
try {
|
||||
const result = register(api);
|
||||
@@ -1355,6 +1371,10 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
flushPlanResolver: previousMemoryFlushPlanResolver,
|
||||
runtime: previousMemoryRuntime,
|
||||
});
|
||||
restoreOperationsRuntimeState({
|
||||
runtime: previousOperationsRuntime,
|
||||
ownerPluginId: previousOperationsRuntimeOwner,
|
||||
});
|
||||
}
|
||||
registry.plugins.push(record);
|
||||
seenIds.set(pluginId, candidate.origin);
|
||||
@@ -1365,6 +1385,10 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
flushPlanResolver: previousMemoryFlushPlanResolver,
|
||||
runtime: previousMemoryRuntime,
|
||||
});
|
||||
restoreOperationsRuntimeState({
|
||||
runtime: previousOperationsRuntime,
|
||||
ownerPluginId: previousOperationsRuntimeOwner,
|
||||
});
|
||||
recordPluginError({
|
||||
logger,
|
||||
registry,
|
||||
@@ -1404,6 +1428,8 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
|
||||
memoryFlushPlanResolver: getMemoryFlushPlanResolver(),
|
||||
memoryPromptBuilder: getMemoryPromptSectionBuilder(),
|
||||
memoryRuntime: getMemoryRuntime(),
|
||||
operationsRuntime: getRegisteredOperationsRuntime(),
|
||||
operationsRuntimeOwner: getRegisteredOperationsRuntimeOwner(),
|
||||
});
|
||||
}
|
||||
if (shouldActivate) {
|
||||
|
||||
Reference in New Issue
Block a user