openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
63 lines (62 loc) • 2.75 kB
JavaScript
import { r as listChannelPlugins } from "./registry-ByqVE5S3.mjs";
import "./plugins-BoMiRtiY.mjs";
import { i as ChannelsStatusResultSchema } from "./channels-DqocFXd1.mjs";
import { n as DEFAULT_CHANNEL_STALE_EVENT_THRESHOLD_MS, r as evaluateChannelHealth, t as DEFAULT_CHANNEL_CONNECT_GRACE_MS } from "./channel-health-policy-Czg3cLcH.mjs";
import { Value } from "typebox/value";
//#region src/infra/channels-status-issues.ts
const RUNTIME_ISSUE_MESSAGES = /* @__PURE__ */ new Map([
["not-running", "Channel is enabled and configured, but its runtime is not running."],
["disconnected", "Channel reports running, but the runtime is disconnected."],
["stale-socket", "Channel reports connected, but transport activity is stale; inbound delivery may be broken."],
["stuck", "Channel runtime appears stuck with stale run activity."]
]);
/** Collects generic and plugin-specific issues from a channels status payload. */
function collectChannelStatusIssues(e, t) {
if (Array.isArray(e.statusIssues) && Value.Check(ChannelsStatusResultSchema.properties.statusIssues, e.statusIssues)) return e.statusIssues;
const n = [];
const r = e.channelAccounts;
for (const e of t ?? listChannelPlugins()) {
const t = r?.[e.id];
if (!Array.isArray(t)) continue;
const i = t;
const a = e.id;
const o = Date.now();
for (const e of i) {
if (e.enabled === false || e.configured === false) continue;
const t = typeof e.accountId === "string" && e.accountId.trim() ? e.accountId : "default";
if (e.ingressUnavailable === true && !e.terminalDisconnect) {
n.push({
channel: a,
accountId: t,
kind: "runtime",
message: "Channel cannot admit inbound events; its durable ingress queue is unavailable. Outbound may still work.",
fix: "check openclaw logs for the ingress failure, then rerun openclaw doctor"
});
continue;
}
const r = evaluateChannelHealth(e, {
channelId: a,
now: o,
channelConnectGraceMs: DEFAULT_CHANNEL_CONNECT_GRACE_MS,
staleEventThresholdMs: DEFAULT_CHANNEL_STALE_EVENT_THRESHOLD_MS
});
if (r.healthy) continue;
if (r.reason === "not-running" && e.running !== false) continue;
const i = r.reason === "terminal-disconnect" || r.reason === "blocked";
const s = i ? e.lastError || "Channel runtime is blocked and needs operator action." : RUNTIME_ISSUE_MESSAGES.get(r.reason);
if (s === void 0) continue;
n.push({
channel: a,
accountId: t,
kind: "runtime",
message: s,
fix: i ? "resolve the reported channel error, then restart the channel" : "restart the channel or gateway"
});
}
const s = e.status?.collectStatusIssues;
if (s) n.push(...s(i));
}
return n;
}
//#endregion
export { collectChannelStatusIssues as t };