openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
38 lines (37 loc) • 1.99 kB
JavaScript
import { l as normalizeOptionalString, o as normalizeLowercaseStringOrEmpty } from "./string-coerce-CCIiB4H7.mjs";
import { r as defaultRuntime } from "./runtime-B-SLYP-m.mjs";
import { n as sanitizeTerminalText } from "./safe-text-C80HAQ2e.mjs";
import { t as formatErrorMessage } from "./errors-BKzCeTYb.mjs";
import { n as isRich, r as theme } from "./theme-BOI0xyRZ.mjs";
import { n as runCommandWithRuntime } from "./cli-utils-BPmaaZlG.mjs";
//#region src/cli/nodes-cli/cli-utils.ts
/** Return color helpers that degrade to plain text in non-rich terminals. */
function getNodesTheme() {
const e = isRich();
const color = (t) => (n) => e ? t(n) : n;
return {
rich: e,
heading: color(theme.heading),
ok: color(theme.success),
warn: color(theme.warn),
muted: color(theme.muted),
error: color(theme.error)
};
}
function formatConnectionFlagReminder(e) {
const t = [normalizeOptionalString(e.url) ? "--url" : null, normalizeOptionalString(e.token) ? "--token" : null].filter((e) => e !== null);
return t.length > 0 ? `Reuse the same connection option${t.length === 1 ? "" : "s"} when rerunning: ${t.join(", ")}.` : null;
}
/** Run a node CLI action with standard failure text and authorization hints. */
function runNodesCommand(e, t) {
return runCommandWithRuntime(defaultRuntime, t, (t) => {
const n = formatErrorMessage(t);
const { error: r, warn: i } = getNodesTheme();
defaultRuntime.error(r(sanitizeTerminalText(`nodes ${e} failed: ${n}`)));
const a = normalizeLowercaseStringOrEmpty(n);
if (a.includes("unauthorizedclient") || a.includes("bridge client is not authorized") || a.includes("unsigned bridge clients are not allowed")) defaultRuntime.error(i("peekaboo bridge rejected the client. sign the peekaboo CLI (TeamID Y5PE65HELJ) or launch the host with PEEKABOO_ALLOW_UNSIGNED_SOCKET_CLIENTS=1 for local dev."));
defaultRuntime.exit(1);
});
}
//#endregion
export { getNodesTheme as n, runNodesCommand as r, formatConnectionFlagReminder as t };