mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 19:40:41 +00:00
fix(context-engine): bundle legacy runtime registration
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user