MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / buildAccountGroups

Function buildAccountGroups

packages/react/src/components/tool-tree.tsx:75–113  ·  view source on GitHub ↗
(tools: readonly ToolSummary[])

Source from the content-addressed store, hash-verified

73 * Pure — unit-testable without React.
74 */
75export const buildAccountGroups = (tools: readonly ToolSummary[]): readonly AccountGroup[] => {
76 const byKey = new Map<
77 string,
78 { owner: Owner; integration: string; connection: string; tools: ToolSummary[] }
79 >();
80 for (const tool of tools) {
81 const owner: Owner = tool.owner ?? "org";
82 const integration = tool.integration ?? "";
83 const connection = tool.connection ?? "";
84 const key = `${owner}:${integration}:${connection}`;
85 let group = byKey.get(key);
86 if (!group) {
87 group = { owner, integration, connection, tools: [] };
88 byKey.set(key, group);
89 }
90 group.tools.push(tool);
91 }
92 // Workspace (org) sorts before Personal (user); then by connection name.
93 const ownerRank = (owner: Owner): number => (owner === "org" ? 0 : 1);
94 return [...byKey.values()]
95 .sort(
96 (a, b) =>
97 ownerRank(a.owner) - ownerRank(b.owner) ||
98 a.integration.localeCompare(b.integration) ||
99 a.connection.localeCompare(b.connection),
100 )
101 .map((group) => ({
102 key: `${group.owner}:${group.integration}:${group.connection}`,
103 owner: group.owner,
104 integration: group.integration,
105 connection: group.connection,
106 label: group.connection
107 ? `${ownerLabel(group.owner)} · ${
108 group.integration ? `${group.integration} / ` : ""
109 }${group.connection}`
110 : ownerLabel(group.owner),
111 tools: group.tools,
112 }));
113};
114
115// What the dot looks like for a given effective policy. Always-run as
116// a plugin default is silent (the safe state — no point cluttering every

Callers 2

tool-tree.test.tsFile · 0.90
ToolTreeFunction · 0.85

Calls 6

ownerLabelFunction · 0.90
setMethod · 0.80
pushMethod · 0.80
valuesMethod · 0.80
ownerRankFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected