mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 02:22:25 +00:00
refactor: dedupe helpers and source seams
This commit is contained in:
@@ -7,28 +7,9 @@ import { ensureAgentWorkspace } from "../../agents/workspace.js";
|
||||
import { resolveSessionFilePath, resolveStorePath } from "../../config/sessions/paths.js";
|
||||
import { loadSessionStore, saveSessionStore } from "../../config/sessions/store.js";
|
||||
import { createLazyRuntimeMethod, createLazyRuntimeModule } from "../../shared/lazy-runtime.js";
|
||||
import { defineCachedValue } from "./runtime-cache.js";
|
||||
import type { PluginRuntime } from "./types.js";
|
||||
|
||||
function defineCachedValue<T extends object, K extends PropertyKey>(
|
||||
target: T,
|
||||
key: K,
|
||||
create: () => unknown,
|
||||
): void {
|
||||
let cached: unknown;
|
||||
let ready = false;
|
||||
Object.defineProperty(target, key, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get() {
|
||||
if (!ready) {
|
||||
cached = create();
|
||||
ready = true;
|
||||
}
|
||||
return cached;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const loadEmbeddedPiRuntime = createLazyRuntimeModule(
|
||||
() => import("./runtime-embedded-pi.runtime.js"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user