Files
clawdbot/src/version.ts
2026-01-04 14:38:51 +00:00

23 lines
689 B
TypeScript

import { createRequire } from "node:module";
declare const __CLAWDBOT_VERSION__: string | undefined;
function readVersionFromPackageJson(): string | null {
try {
const require = createRequire(import.meta.url);
const pkg = require("../package.json") as { version?: string };
return pkg.version ?? null;
} catch {
return null;
}
}
// Single source of truth for the current clawdbot version.
// - Embedded/bundled builds: injected define or env var.
// - Dev/npm builds: package.json.
export const VERSION =
(typeof __CLAWDBOT_VERSION__ === "string" && __CLAWDBOT_VERSION__) ||
process.env.CLAWDBOT_BUNDLED_VERSION ||
readVersionFromPackageJson() ||
"0.0.0";