mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 02:00:26 +00:00
refactor: rename to openclaw
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import process from "node:process";
|
||||
import type { GatewayLockHandle } from "../infra/gateway-lock.js";
|
||||
|
||||
declare const __CLAWDBOT_VERSION__: string;
|
||||
declare const __OPENCLAW_VERSION__: string | undefined;
|
||||
|
||||
const BUNDLED_VERSION =
|
||||
(typeof __CLAWDBOT_VERSION__ === "string" && __CLAWDBOT_VERSION__) ||
|
||||
process.env.CLAWDBOT_BUNDLED_VERSION ||
|
||||
(typeof __OPENCLAW_VERSION__ === "string" && __OPENCLAW_VERSION__) ||
|
||||
process.env.OPENCLAW_BUNDLED_VERSION ||
|
||||
"0.0.0";
|
||||
|
||||
function argValue(args: string[], flag: string): string | undefined {
|
||||
@@ -26,7 +26,7 @@ type GatewayWsLogStyle = "auto" | "full" | "compact";
|
||||
|
||||
async function main() {
|
||||
if (hasFlag(args, "--version") || hasFlag(args, "-v")) {
|
||||
// Match `moltbot --version` behavior for Swift env/version checks.
|
||||
// Match `openclaw --version` behavior for Swift env/version checks.
|
||||
// Keep output a single line.
|
||||
console.log(BUNDLED_VERSION);
|
||||
process.exit(0);
|
||||
@@ -75,6 +75,7 @@ async function main() {
|
||||
const cfg = loadConfig();
|
||||
const portRaw =
|
||||
argValue(args, "--port") ??
|
||||
process.env.OPENCLAW_GATEWAY_PORT ??
|
||||
process.env.CLAWDBOT_GATEWAY_PORT ??
|
||||
(typeof cfg.gateway?.port === "number" ? String(cfg.gateway.port) : "") ??
|
||||
"18789";
|
||||
@@ -86,6 +87,7 @@ async function main() {
|
||||
|
||||
const bindRaw =
|
||||
argValue(args, "--bind") ??
|
||||
process.env.OPENCLAW_GATEWAY_BIND ??
|
||||
process.env.CLAWDBOT_GATEWAY_BIND ??
|
||||
cfg.gateway?.bind ??
|
||||
"loopback";
|
||||
@@ -103,7 +105,9 @@ async function main() {
|
||||
}
|
||||
|
||||
const token = argValue(args, "--token");
|
||||
if (token) process.env.CLAWDBOT_GATEWAY_TOKEN = token;
|
||||
if (token) {
|
||||
process.env.OPENCLAW_GATEWAY_TOKEN = token;
|
||||
}
|
||||
|
||||
let server: Awaited<ReturnType<typeof startGatewayServer>> | null = null;
|
||||
let lock: GatewayLockHandle | null = null;
|
||||
@@ -211,7 +215,7 @@ async function main() {
|
||||
|
||||
void main().catch((err) => {
|
||||
console.error(
|
||||
"[moltbot] Gateway daemon failed:",
|
||||
"[openclaw] Gateway daemon failed:",
|
||||
err instanceof Error ? (err.stack ?? err.message) : err,
|
||||
);
|
||||
process.exit(1);
|
||||
|
||||
@@ -15,8 +15,8 @@ describe("parseRelaySmokeTest", () => {
|
||||
});
|
||||
|
||||
it("parses env var smoke mode only when no args", () => {
|
||||
expect(parseRelaySmokeTest([], { CLAWDBOT_SMOKE_QR: "1" })).toBe("qr");
|
||||
expect(parseRelaySmokeTest(["send"], { CLAWDBOT_SMOKE_QR: "1" })).toBe(null);
|
||||
expect(parseRelaySmokeTest([], { OPENCLAW_SMOKE_QR: "1" })).toBe("qr");
|
||||
expect(parseRelaySmokeTest(["send"], { OPENCLAW_SMOKE_QR: "1" })).toBe(null);
|
||||
});
|
||||
|
||||
it("rejects unknown smoke values", () => {
|
||||
|
||||
@@ -15,7 +15,7 @@ export function parseRelaySmokeTest(args: string[], env: NodeJS.ProcessEnv): Rel
|
||||
|
||||
// Back-compat: only run env-based smoke mode when no CLI args are present,
|
||||
// to avoid surprising early-exit when users set env vars globally.
|
||||
if (args.length === 0 && (env.CLAWDBOT_SMOKE_QR === "1" || env.CLAWDBOT_SMOKE === "qr")) {
|
||||
if (args.length === 0 && (env.OPENCLAW_SMOKE_QR === "1" || env.OPENCLAW_SMOKE === "qr")) {
|
||||
return "qr";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
import process from "node:process";
|
||||
|
||||
declare const __CLAWDBOT_VERSION__: string | undefined;
|
||||
declare const __OPENCLAW_VERSION__: string | undefined;
|
||||
|
||||
const BUNDLED_VERSION =
|
||||
(typeof __CLAWDBOT_VERSION__ === "string" && __CLAWDBOT_VERSION__) ||
|
||||
process.env.CLAWDBOT_BUNDLED_VERSION ||
|
||||
(typeof __OPENCLAW_VERSION__ === "string" && __OPENCLAW_VERSION__) ||
|
||||
process.env.OPENCLAW_BUNDLED_VERSION ||
|
||||
"0.0.0";
|
||||
|
||||
function hasFlag(args: string[], flag: string): boolean {
|
||||
@@ -47,8 +47,8 @@ async function main() {
|
||||
const { loadDotEnv } = await import("../infra/dotenv.js");
|
||||
loadDotEnv({ quiet: true });
|
||||
|
||||
const { ensureMoltbotCliOnPath } = await import("../infra/path-env.js");
|
||||
ensureMoltbotCliOnPath();
|
||||
const { ensureOpenClawCliOnPath } = await import("../infra/path-env.js");
|
||||
ensureOpenClawCliOnPath();
|
||||
|
||||
const { enableConsoleCapture } = await import("../logging.js");
|
||||
enableConsoleCapture();
|
||||
@@ -64,7 +64,7 @@ async function main() {
|
||||
installUnhandledRejectionHandler();
|
||||
|
||||
process.on("uncaughtException", (error) => {
|
||||
console.error("[moltbot] Uncaught exception:", formatUncaughtError(error));
|
||||
console.error("[openclaw] Uncaught exception:", formatUncaughtError(error));
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
@@ -72,6 +72,9 @@ async function main() {
|
||||
}
|
||||
|
||||
void main().catch((err) => {
|
||||
console.error("[moltbot] Relay failed:", err instanceof Error ? (err.stack ?? err.message) : err);
|
||||
console.error(
|
||||
"[openclaw] Relay failed:",
|
||||
err instanceof Error ? (err.stack ?? err.message) : err,
|
||||
);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user