UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

31 lines (30 loc) • 969 B
import { n as listNodes, o as resolveNodeIdFromList } from "./nodes-utils-B4u6gtyR.mjs"; //#region src/agents/node-exec-availability.ts /** Prepares current node facts for tool discovery without caching connection state. */ async function loadNodeExecAvailability(e) { const t = await listNodes({}, e).catch(() => { e?.throwIfAborted(); return []; }); e?.throwIfAborted(); return { cacheKey: JSON.stringify(t.toSorted((e, t) => e.nodeId.localeCompare(t.nodeId)).map(({ nodeId: e, displayName: t, remoteIp: n, clientId: r, connected: i, commands: a }) => [ e, t, n, r, i === true, a?.includes("system.run") === true ])), isAvailable: (e) => { try { const n = e?.trim() ? resolveNodeIdFromList(t, e) : void 0; return t.some((e) => (!n || e.nodeId === n) && e.connected === true && e.commands?.includes("system.run") === true); } catch { return false; } } }; } //#endregion export { loadNodeExecAvailability as t };