mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Comprehensive rename of all openclaw references to hanzo-bot equivalents: - Package: openclaw → @hanzo/bot - Binary: openclaw → hanzo-bot - Types: OpenClaw* → Bot* - Env vars: OPENCLAW_* → BOT_* - Android: ai.openclaw.android → ai.hanzo.bot.android - iOS/macOS: ai.openclaw.* → ai.hanzo.* - Swift modules: OpenClaw* → Bot* - Plugins: openclaw.plugin.json → bot.plugin.json - Paths: .openclaw/ → .hanzo/bot/ - URLs: github.com/openclaw → github.com/hanzoai
57 lines
1.4 KiB
JavaScript
Executable File
57 lines
1.4 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
import module from "node:module";
|
|
|
|
// https://nodejs.org/api/module.html#module-compile-cache
|
|
if (module.enableCompileCache && !process.env.NODE_DISABLE_COMPILE_CACHE) {
|
|
try {
|
|
module.enableCompileCache();
|
|
} catch {
|
|
// Ignore errors
|
|
}
|
|
}
|
|
|
|
const isModuleNotFoundError = (err) =>
|
|
err && typeof err === "object" && "code" in err && err.code === "ERR_MODULE_NOT_FOUND";
|
|
|
|
const installProcessWarningFilter = async () => {
|
|
// Keep bootstrap warnings consistent with the TypeScript runtime.
|
|
for (const specifier of ["./dist/warning-filter.js", "./dist/warning-filter.mjs"]) {
|
|
try {
|
|
const mod = await import(specifier);
|
|
if (typeof mod.installProcessWarningFilter === "function") {
|
|
mod.installProcessWarningFilter();
|
|
return;
|
|
}
|
|
} catch (err) {
|
|
if (isModuleNotFoundError(err)) {
|
|
continue;
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
};
|
|
|
|
await installProcessWarningFilter();
|
|
|
|
const tryImport = async (specifier) => {
|
|
try {
|
|
await import(specifier);
|
|
return true;
|
|
} catch (err) {
|
|
// Only swallow missing-module errors; rethrow real runtime errors.
|
|
if (isModuleNotFoundError(err)) {
|
|
return false;
|
|
}
|
|
throw err;
|
|
}
|
|
};
|
|
|
|
if (await tryImport("./dist/entry.js")) {
|
|
// OK
|
|
} else if (await tryImport("./dist/entry.mjs")) {
|
|
// OK
|
|
} else {
|
|
throw new Error("bot: missing dist/entry.(m)js (build output).");
|
|
}
|