openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
148 lines (147 loc) • 6.07 kB
JavaScript
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs";
import { s as redactSensitiveText } from "./redact-Mj7pppxC.mjs";
import { b as resolveGatewayPort } from "./paths-DAcAg5aV.mjs";
import { t as VERSION } from "./version-GlxUMdxI.mjs";
import { c as normalizeUpdateChannel, d as resolveUpdateChannelDisplay } from "./update-channels-CDc4OFaS.mjs";
import "./config-CMA-J084.mjs";
import { i as projectGatewayUrlForDiagnostics } from "./connection-details-BWzGtdxz.mjs";
import { r as formatDurationPrecise } from "./format-duration-iMnO_MN6.mjs";
import { i as formatGitInstallLabel } from "./update-check-BfPo_IXH.mjs";
import "./format-relative-JG-kbkDF.mjs";
import { n as resolveControlUiLinks } from "./control-ui-links-tAtEMm92.mjs";
import { a as resolveUpdateAvailability, n as formatUpdateOneLiner } from "./status.update-pTxb85fr.mjs";
//#region src/commands/status-all/format.ts
function resolveStatusUpdateChannelInfo(e) {
return resolveUpdateChannelDisplay({
configChannel: normalizeUpdateChannel(e.updateConfigChannel),
currentVersion: VERSION,
installKind: e.update.installKind ?? "unknown",
gitTag: e.update.git?.tag ?? null,
gitBranch: e.update.git?.branch ?? null
});
}
function buildStatusUpdateSurface(e) {
return {
channelLabel: resolveStatusUpdateChannelInfo(e).label,
gitLabel: formatGitInstallLabel(e.update),
updateLine: formatUpdateOneLiner(e.update).replace(/^Update:\s*/i, ""),
updateAvailable: resolveUpdateAvailability(e.update).available
};
}
function formatStatusServiceValue(e) {
const t = e.loadState?.status === "unknown" ? e.loadState.detail : e.runtime?.status === "unknown" ? e.runtime.detail : void 0;
const n = e.loadState?.status === "unknown" || Boolean(t);
if (e.installed === false && !n && !e.runtime?.systemd?.startRefusal) return `${e.label} not installed`;
const r = e.managedByOpenClaw ? "installed · " : "";
const i = t ? `${e.loadedText} (inspection failed: ${redactSensitiveText(t, { mode: "tools" })})` : e.loadedText;
const a = e.runtimeShort ? ` · ${e.runtimeShort}` : [e.runtime?.status ? ` · ${e.runtime.status}` : "", e.runtime?.pid ? ` (pid ${e.runtime.pid})` : ""].join("");
const o = n ? redactSensitiveText(a, { mode: "tools" }) : a;
const s = e.installationDrift ? ` · ${e.installationDrift}` : "";
return `${e.label} ${r}${i}${o}${s}`;
}
function buildStatusOverviewSurfaceRows(e) {
const t = buildStatusUpdateSurface({
updateConfigChannel: e.cfg.update?.channel,
update: e.update
});
const n = e.decorateOk ?? ((e) => e);
const r = e.decorateWarn ?? ((e) => e);
const i = projectGatewayUrlForDiagnostics(e.gatewayConnection.url);
const a = e.remoteUrlMissing ? `fallback ${i}` : i;
const o = e.gatewayConnection.urlSource ? `${a} (${e.gatewayConnection.urlSource})` : a;
const s = e.remoteUrlMissing ? "misconfigured (remote.url missing)" : e.gatewayProbe?.startupPhase ? `still starting (phase ${e.gatewayProbe.startupPhase})` : e.gatewayReachable ? `reachable ${formatDurationPrecise(e.gatewayProbe?.connectLatencyMs ?? 0)}` : e.gatewayProbe?.error ? `unreachable (${e.gatewayProbe.error})` : "unreachable";
const c = e.gatewayReachable ? `auth ${formatGatewayAuthUsed(e.gatewayProbeAuth)}` : "";
const l = `${e.gatewayMode}${e.remoteUrlMissing ? " (remote.url missing)" : ""}`;
const u = formatGatewaySelfSummary(e.gatewaySelf);
const d = e.nodeOnlyGateway?.gatewayValue ?? `${l} · ${o} · ${e.remoteUrlMissing ? r(s) : e.gatewayReachable ? n(s) : r(s)}${e.gatewayReachable && !e.remoteUrlMissing && c ? ` · ${c}` : ""}${u ? ` · ${u}` : ""}`;
const f = e.advertisedControlUiLinks?.httpUrl ?? (e.cfg.gateway?.controlUi?.enabled ?? true ? resolveControlUiLinks({
port: resolveGatewayPort(e.cfg),
bind: e.cfg.gateway?.bind,
customBindHost: e.cfg.gateway?.customBindHost,
basePath: e.cfg.gateway?.controlUi?.basePath,
tlsEnabled: e.cfg.gateway?.tls?.enabled === true
}).httpUrl : null);
const p = formatStatusServiceValue(e.gatewayService);
const m = formatStatusServiceValue(e.nodeService);
const h = e.decorateTailscaleOff ?? ((e) => e);
const g = e.decorateTailscaleWarn ?? ((e) => e);
let _;
if (e.tailscaleMode === "off") {
const t = e.includeDnsNameWhenOff ? e.tailscaleDns : null;
_ = h(t ? `off · ${t}` : "off");
} else {
const t = e.tailscaleDns && e.tailscaleHttpsUrl;
const n = [
e.tailscaleMode,
e.includeBackendStateWhenOn ? "unknown" : null,
...t ? [e.tailscaleDns, e.tailscaleHttpsUrl] : ["magicdns unknown"]
].filter(Boolean).join(" · ");
_ = t ? n : g(n);
}
const v = e.gatewayAuthWarningValue !== void 0 ? e.gatewayAuthWarningValue : e.gatewayProbeAuthWarning;
const y = u ?? e.gatewaySelfFallbackValue;
const b = [
...e.prefixRows ?? [],
{
Item: "Dashboard",
Value: normalizeOptionalString(f) ?? "disabled"
},
{
Item: "Tailscale exposure",
Value: _
},
{
Item: "Channel",
Value: t.channelLabel
}
];
if (t.gitLabel) b.push({
Item: "Git",
Value: t.gitLabel
});
b.push({
Item: "Update",
Value: e.updateValue ?? t.updateLine
}, {
Item: "Gateway",
Value: d
});
if (v) b.push({
Item: "Gateway auth warning",
Value: v
});
b.push(...e.middleRows ?? []);
if (y != null) b.push({
Item: "Gateway self",
Value: y
});
b.push({
Item: "Gateway service",
Value: p
}, {
Item: "Node service",
Value: m
}, {
Item: "Agents",
Value: e.agentsValue
}, ...e.suffixRows ?? []);
return b;
}
function formatGatewayAuthUsed(e) {
const t = Boolean(e?.token?.trim());
const n = Boolean(e?.password?.trim());
if (t && n) return "token+password";
if (t) return "token";
if (n) return "password";
return "none";
}
function formatGatewaySelfSummary(e) {
return e?.host || e?.ip || e?.version || e?.platform ? [
e.host ? e.host : null,
e.ip ? `(${e.ip})` : null,
e.version ? `app ${e.version}` : null,
e.platform ? e.platform : null
].filter(Boolean).join(" ") : null;
}
//#endregion
export { buildStatusUpdateSurface as n, resolveStatusUpdateChannelInfo as r, buildStatusOverviewSurfaceRows as t };