91
}
92
93
>
function getAgentPluginCandidates(discoveries: readonly IDiscoveredAgentPlugins[]): IAgentPluginCandidate[] {
agentPluginEnablement.ts
94
>
const candidates: IAgentPluginCandidate[] = [];
95
>
for (const discovery of discoveries) {
96
>
for (let pluginOrder = 0; pluginOrder < discovery.plugins.length; pluginOrder++) {
97
>
const plugin = discovery.plugins[pluginOrder];
98
>
candidates.push({
99
>
plugin,
100
>
priority: discovery.priority,
101
>
order: discovery.order,
102
>
pluginOrder,
103
>
canonicalKey: getCanonicalPluginIdentity(plugin),
104
>
});
105
>
}
106
>
}
107
>
108
>
return candidates.sort((a, b) =>
109
>
a.priority - b.priority
110
|| a.order - b.order
111
|| a.pluginOrder - b.pluginOrder
112
|| a.plugin.uri.toString().localeCompare(b.plugin.uri.toString())
114
>
}
115
116
>
function getUniqueAgentPluginCandidates(discoveries: readonly IDiscoveredAgentPlugins[]): IAgentPluginCandidate[] {
agentPluginEnablement.ts
117
>
const unique: IAgentPluginCandidate[] = [];
118
>
const seen = new Set<string>();
119
>
for (const candidate of getAgentPluginCandidates(discoveries)) {
120
>
const key = candidate.plugin.uri.toString();
121
>
if (seen.has(key)) {
122
continue;
123
}
125
>
unique.push(candidate);
126
>
}
127
>
return unique;
128
>
}
129
131
>
return getMarketplaceCanonicalIdentity(plugin.fromMarketplace)
132
>
?? getCopilotCliInstallCanonicalIdentity(plugin)
133
?? `uri:${plugin.uri.toString()}`;
135
136
>
function getMarketplaceCanonicalIdentity(plugin: IMarketplacePlugin | undefined): string | undefined {
agentPluginEnablement.ts
137
>
if (!plugin) {
138
>
return undefined;
139
>
}
140
141
const normalizedName = normalizePluginIdentitySegment(plugin.name);