diff --git a/src/entry.ts b/src/entry.ts index 6f664edced0..f7c038f73a4 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -2,6 +2,7 @@ import { spawn } from "node:child_process"; import process from "node:process"; import { fileURLToPath } from "node:url"; +import { isRootVersionInvocation } from "./cli/argv.js"; import { applyCliProfileEnv, parseCliProfileArgs } from "./cli/profile.js"; import { shouldSkipRespawnForArgv } from "./cli/respawn-policy.js"; import { normalizeWindowsArgv } from "./cli/windows-argv.js"; @@ -114,6 +115,24 @@ if ( return true; } + function tryHandleRootVersionFastPath(argv: string[]): boolean { + if (!isRootVersionInvocation(argv)) { + return false; + } + import("./version.js") + .then(({ VERSION }) => { + console.log(VERSION); + }) + .catch((error) => { + console.error( + "[openclaw] Failed to resolve version:", + error instanceof Error ? (error.stack ?? error.message) : error, + ); + process.exitCode = 1; + }); + return true; + } + process.argv = normalizeWindowsArgv(process.argv); if (!ensureExperimentalWarningSuppressed()) { @@ -130,6 +149,10 @@ if ( process.argv = parsed.argv; } + if (tryHandleRootVersionFastPath(process.argv)) { + return; + } + import("./cli/run-main.js") .then(({ runCli }) => runCli(process.argv)) .catch((error) => {