mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 12:30:22 +00:00
fix(context-engine): restore bundled legacy engine loading (#64936)
This commit is contained in:
@@ -1,21 +1,20 @@
|
|||||||
import { registerContextEngineForOwner } from "./registry.js";
|
import { registerContextEngineForOwner } from "./registry.js";
|
||||||
import type { ContextEngine } from "./types.js";
|
import type { ContextEngine } from "./types.js";
|
||||||
|
|
||||||
const LEGACY_CONTEXT_ENGINE_CANDIDATES = ["./legacy.js", "./legacy.ts"] as const;
|
|
||||||
|
|
||||||
type LegacyContextEngineModule = {
|
type LegacyContextEngineModule = {
|
||||||
LegacyContextEngine: new () => ContextEngine;
|
LegacyContextEngine: new () => ContextEngine;
|
||||||
};
|
};
|
||||||
|
|
||||||
async function loadLegacyContextEngineModule(): Promise<LegacyContextEngineModule> {
|
async function loadLegacyContextEngineModule(): Promise<LegacyContextEngineModule> {
|
||||||
for (const candidate of LEGACY_CONTEXT_ENGINE_CANDIDATES) {
|
try {
|
||||||
|
return (await import("./legacy.js")) as LegacyContextEngineModule;
|
||||||
|
} catch {
|
||||||
try {
|
try {
|
||||||
return (await import(candidate)) as LegacyContextEngineModule;
|
return (await import("./legacy.ts")) as LegacyContextEngineModule;
|
||||||
} catch {
|
} catch {
|
||||||
// Try runtime/source candidates in order.
|
throw new Error("Failed to load legacy context engine runtime.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error("Failed to load legacy context engine runtime.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function registerLegacyContextEngine(): void {
|
export function registerLegacyContextEngine(): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user