MCPcopy
hub / github.com/ValueCell-ai/ClawX / getChannelBindingMap

Function getChannelBindingMap

electron/utils/agent-config.ts:253–276  ·  view source on GitHub ↗

* Returns a map of channelType -> agentId from bindings. * Account-scoped bindings are preferred; channel-wide bindings serve as fallback. * Multiple agents can own the same channel type (different accounts).

(bindings: unknown)

Source from the content-addressed store, hash-verified

251 * Multiple agents can own the same channel type (different accounts).
252 */
253function getChannelBindingMap(bindings: unknown): {
254 channelToAgent: Map<string, string>;
255 accountToAgent: Map<string, string>;
256} {
257 const channelToAgent = new Map<string, string>();
258 const accountToAgent = new Map<string, string>();
259 if (!Array.isArray(bindings)) return { channelToAgent, accountToAgent };
260
261 for (const binding of bindings) {
262 if (!isChannelBinding(binding)) continue;
263 const agentId = normalizeAgentIdForBinding(binding.agentId!);
264 const channel = binding.match?.channel;
265 if (!agentId || !channel) continue;
266
267 const accountId = binding.match?.accountId;
268 if (accountId) {
269 accountToAgent.set(`${channel}:${accountId}`, agentId);
270 } else {
271 channelToAgent.set(channel, agentId);
272 }
273 }
274
275 return { channelToAgent, accountToAgent };
276}
277
278function upsertBindingsForChannel(
279 bindings: unknown,

Callers 2

buildSnapshotFromConfigFunction · 0.85

Calls 3

isChannelBindingFunction · 0.85
setMethod · 0.65

Tested by

no test coverage detected