Fallback to Jiti when bun is unavailable

This commit is contained in:
Tak Hoffman
2026-03-27 15:11:01 -05:00
parent fa89d68e7a
commit c3d45fbb19
2 changed files with 72 additions and 1 deletions

View File

@@ -77,6 +77,13 @@ function shouldRetryViaIsolatedCopy(error: unknown): boolean {
return code === "ERR_MODULE_NOT_FOUND" && message.includes(`${path.sep}node_modules${path.sep}`);
}
function isMissingExecutableError(error: unknown): boolean {
if (!error || typeof error !== "object") {
return false;
}
return "code" in error && error.code === "ENOENT";
}
const SOURCE_FILE_EXTENSIONS = [".ts", ".tsx", ".mts", ".cts", ".js", ".jsx", ".mjs", ".cjs"];
function resolveImportCandidates(basePath: string): string[] {
@@ -232,6 +239,12 @@ export async function loadChannelConfigSurfaceModule(
OPENCLAW_CONFIG_SURFACE_MODULE: path.resolve(candidatePath),
},
});
if (result.error) {
if (isMissingExecutableError(result.error)) {
return null;
}
throw result.error;
}
if (result.status !== 0) {
throw new Error(result.stderr || result.stdout || `bun loader failed for ${candidatePath}`);
}