openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
32 lines (31 loc) • 1.13 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { r as truncateUtf16Safe } from "./utf16-slice-CuDyEXgS.mjs";
import { t as DARWIN_SYSTEM_PROBE_TIMEOUT_MS } from "./os-summary-CMRUbVgk.mjs";
import { readFileSync } from "node:fs";
import os from "node:os";
import { spawnSync } from "node:child_process";
//#region src/infra/machine-model.ts
const models = /* @__PURE__ */ new Map();
function resolveMachineModelIdentifier(e = os.platform()) {
if (models.has(e)) return models.get(e);
let t;
if (e === "darwin") {
const e = spawnSync("sysctl", ["-n", "hw.model"], {
encoding: "utf-8",
timeout: DARWIN_SYSTEM_PROBE_TIMEOUT_MS,
killSignal: "SIGKILL"
});
t = normalizeOptionalString(e.stdout);
} else if (e === "linux") for (const e of ["/sys/devices/virtual/dmi/id/product_name", "/proc/device-tree/model"]) try {
const n = readFileSync(e, "utf-8");
t = normalizeOptionalString(n.trim().replace(/\0+$/, ""));
if (t) {
t = truncateUtf16Safe(t, 64);
break;
}
} catch {}
models.set(e, t);
return t;
}
//#endregion
export { resolveMachineModelIdentifier as t };