fix(context-engine): bundle legacy runtime registration

This commit is contained in:
Peter Steinberger
2026-04-11 17:50:43 +01:00
parent 9aa9c3ff62
commit e26edee39e
3 changed files with 92 additions and 28 deletions

View File

@@ -1,32 +1,8 @@
import { LegacyContextEngine } from "./legacy.js";
import { registerContextEngineForOwner } from "./registry.js";
import type { ContextEngine } from "./types.js";
type LegacyContextEngineModule = {
LegacyContextEngine: new () => ContextEngine;
};
async function loadLegacyContextEngineModule(): Promise<LegacyContextEngineModule> {
try {
return (await import("./legacy.js")) as LegacyContextEngineModule;
} catch {
try {
return (await import("./legacy.ts")) as LegacyContextEngineModule;
} catch {
throw new Error("Failed to load legacy context engine runtime.");
}
}
}
export function registerLegacyContextEngine(): void {
registerContextEngineForOwner(
"legacy",
async () => {
const { LegacyContextEngine } = await loadLegacyContextEngineModule();
return new LegacyContextEngine();
},
"core",
{
allowSameOwnerRefresh: true,
},
);
registerContextEngineForOwner("legacy", async () => new LegacyContextEngine(), "core", {
allowSameOwnerRefresh: true,
});
}