refactor: dedupe helpers and source seams

This commit is contained in:
Peter Steinberger
2026-03-24 20:39:45 +00:00
parent ebe18c0379
commit bcd61f0a38
83 changed files with 2795 additions and 4495 deletions

View File

@@ -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"),
);