openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
50 lines (49 loc) • 2.12 kB
JavaScript
import { t as ErrorCodes } from "./gateway-error-details-w0nAGBBp.js";
import { d as errorShape } from "./error-codes-Bo8q2D1o.js";
import { n as getDiagnosticStabilitySnapshot, r as normalizeDiagnosticStabilityQuery } from "./diagnostic-stability-CLaOJzMC.js";
import { t as STATIC_COMMAND_LANES } from "./lanes-B4K7rhXK.js";
import { a as getCommandLaneSnapshot, d as listCommandLaneTotals } from "./command-queue-C3Fv2rcU.js";
import { n as getBackgroundWorkSnapshot, r as isBackgroundWorkLane } from "./background-work-DAaUk-Kp.js";
//#region src/process/command-lane-diagnostics.ts
const STATIC_COMMAND_LANE_SET = new Set(STATIC_COMMAND_LANES);
function getCommandLaneDiagnostics() {
const lanes = [...STATIC_COMMAND_LANES].toSorted().map((lane) => lane === "background" ? getBackgroundWorkSnapshot() : getCommandLaneSnapshot(lane)).filter((lane) => lane.maxConcurrent > 0 || lane.activeCount > 0 || lane.queuedCount > 0);
const dynamic = {
laneCount: 0,
activeCount: 0,
queuedCount: 0,
queuedLaneCount: 0
};
for (const totals of listCommandLaneTotals()) {
if (STATIC_COMMAND_LANE_SET.has(totals.lane) || isBackgroundWorkLane(totals.lane)) continue;
dynamic.laneCount += 1;
dynamic.activeCount += totals.activeCount;
dynamic.queuedCount += totals.queuedCount;
if (totals.queuedCount > 0) dynamic.queuedLaneCount += 1;
}
return {
lanes,
dynamic: dynamic.laneCount > 0 ? dynamic : null
};
}
//#endregion
//#region src/gateway/server-methods/diagnostics.ts
/** Gateway handler for payload-free stability diagnostics. */
const diagnosticsHandlers = {
"diagnostics.lanes": ({ respond }) => {
respond(true, {
ts: Date.now(),
...getCommandLaneDiagnostics()
}, void 0);
},
"diagnostics.stability": async ({ params, respond }) => {
try {
const query = normalizeDiagnosticStabilityQuery(params);
respond(true, getDiagnosticStabilitySnapshot(query), void 0);
} catch (err) {
respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, err instanceof Error ? err.message : "invalid diagnostics.stability params"));
}
}
};
//#endregion
export { diagnosticsHandlers };