UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

70 lines (69 loc) • 2.26 kB
import { _ as isVerbose, c as defaultRuntime, i as getLogger, n as writeRootConsoleLine, t as createSubsystemLogger } from "./subsystem-CeOCPr4l.mjs"; import chalk, { Chalk } from "chalk"; //#region packages/terminal-core/src/palette.ts const LOBSTER_PALETTE = { accent: "#FF5A2D", accentBright: "#FF7A3D", accentDim: "#D14A22", info: "#FF8A5B", success: "#2FBF71", warn: "#FFB020", error: "#E23D2D", muted: "#8B7F77" }; //#endregion //#region packages/terminal-core/src/theme.ts const hasForceColor = typeof process.env.FORCE_COLOR === "string" && process.env.FORCE_COLOR.trim().length > 0 && process.env.FORCE_COLOR.trim() !== "0"; const baseChalk = process.env.NO_COLOR && !hasForceColor ? new Chalk({ level: 0 }) : chalk; const hex = (e) => baseChalk.hex(e); /** Shared terminal theme color functions. */ const theme = { accent: hex(LOBSTER_PALETTE.accent), accentBright: hex(LOBSTER_PALETTE.accentBright), accentDim: hex(LOBSTER_PALETTE.accentDim), info: hex(LOBSTER_PALETTE.info), success: hex(LOBSTER_PALETTE.success), warn: hex(LOBSTER_PALETTE.warn), error: hex(LOBSTER_PALETTE.error), muted: hex(LOBSTER_PALETTE.muted), heading: baseChalk.bold.hex(LOBSTER_PALETTE.accent), command: hex(LOBSTER_PALETTE.accentBright), option: hex(LOBSTER_PALETTE.warn) }; //#endregion //#region src/logger.ts const subsystemPrefixRe = /^([a-z][a-z0-9-]{1,20}):\s+(.*)$/i; function splitSubsystem(e) { const t = e.match(subsystemPrefixRe); if (!t) return null; const n = t.at(1); const r = t.at(2); if (n === void 0 || r === void 0) return null; return { subsystem: n, rest: r }; } function logWithSubsystem(e, t, n) { const r = n === defaultRuntime ? splitSubsystem(t) : null; if (r) { createSubsystemLogger(r.subsystem)[e](r.rest); return; } const i = e === "error" ? "error" : "log"; const a = theme[e](t); if (n !== defaultRuntime || !writeRootConsoleLine(i, a)) n[i](a); getLogger()[e](t); } function logWarn(e, t = defaultRuntime) { logWithSubsystem("warn", e, t); } function logError(e, t = defaultRuntime) { logWithSubsystem("error", e, t); } function logDebug(e) { getLogger().debug(e); if (isVerbose()) console.log(theme.muted(e)); } //#endregion export { theme as i, logError as n, logWarn as r, logDebug as t };