UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

47 lines (46 loc) • 1.9 kB
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; import "./session-key-CqAyZeVk.mjs"; import { D as tryResolveAgentOperationAgentId } from "./agent-scope-config-DmXgFGKP.mjs"; import { i as resolveNormalizedRouteBindingMatch, t as normalizeRouteBindingChannelId } from "./binding-scope-C3Xc3l9P.mjs"; import { i as listRouteBindings, r as listConfiguredBindings, t as isRouteBinding } from "./bindings-C2C-UuI7.mjs"; //#region src/routing/bindings.ts function listBoundAccountIds(e, t) { const n = normalizeRouteBindingChannelId(t); if (!n) return []; const r = /* @__PURE__ */ new Set(); for (const t of listRouteBindings(e)) { const e = resolveNormalizedRouteBindingMatch(t, { includeImplicitDefaultAccount: true }); if (!e || e.channelId !== n) continue; r.add(e.accountId); } return Array.from(r).toSorted((e, t) => e.localeCompare(t)); } function resolveDefaultAgentBoundAccountId(e, t) { const n = normalizeRouteBindingChannelId(t); if (!n) return null; const r = tryResolveAgentOperationAgentId(e); if (!r) return null; const i = normalizeAgentId(r); for (const t of listConfiguredBindings(e)) { if (!isRouteBinding(t)) continue; const e = resolveNormalizedRouteBindingMatch(t); if (!e || e.channelId !== n || e.agentId !== i) continue; return e.accountId; } return null; } function buildChannelAccountBindings(e) { const t = /* @__PURE__ */ new Map(); for (const n of listRouteBindings(e)) { const e = resolveNormalizedRouteBindingMatch(n, { includeImplicitDefaultAccount: true }); if (!e) continue; const r = t.get(e.channelId) ?? /* @__PURE__ */ new Map(); const i = r.get(e.agentId) ?? []; if (!i.includes(e.accountId)) i.push(e.accountId); r.set(e.agentId, i); t.set(e.channelId, r); } return t; } //#endregion export { listBoundAccountIds as n, resolveDefaultAgentBoundAccountId as r, buildChannelAccountBindings as t };