MCPcopy Create free account
hub / github.com/Noumena-Network/code / installPluginOp

Function installPluginOp

src/services/plugins/pluginOperations.ts:322–419  ·  view source on GitHub ↗
(
  plugin: string,
  scope: InstallableScope = 'user',
)

Source from the content-addressed store, hash-verified

320 * @returns Result indicating success/failure
321 */
322export async function installPluginOp(
323 plugin: string,
324 scope: InstallableScope = 'user',
325): Promise<PluginOperationResult> {
326 assertInstallableScope(scope)
327
328 const { name: pluginName, marketplace: marketplaceName } =
329 parsePluginIdentifier(plugin)
330
331 // ── Search materialized marketplaces for the plugin ──
332 let foundPlugin: PluginMarketplaceEntry | undefined
333 let foundMarketplace: string | undefined
334 let marketplaceInstallLocation: string | undefined
335
336 if (marketplaceName) {
337 const pluginInfo = await getPluginById(plugin)
338 if (pluginInfo) {
339 foundPlugin = pluginInfo.entry
340 foundMarketplace = marketplaceName
341 marketplaceInstallLocation = pluginInfo.marketplaceInstallLocation
342 }
343 } else {
344 const marketplaces = await loadKnownMarketplacesConfig()
345 for (const [mktName, mktConfig] of Object.entries(marketplaces)) {
346 try {
347 const marketplace = await getMarketplace(mktName)
348 const pluginEntry = marketplace.plugins.find(p => p.name === pluginName)
349 if (pluginEntry) {
350 foundPlugin = pluginEntry
351 foundMarketplace = mktName
352 marketplaceInstallLocation = mktConfig.installLocation
353 break
354 }
355 } catch (error) {
356 logError(toError(error))
357 continue
358 }
359 }
360 }
361
362 if (!foundPlugin || !foundMarketplace) {
363 const location = marketplaceName
364 ? `marketplace "${marketplaceName}"`
365 : 'any configured marketplace'
366 return {
367 success: false,
368 message: `Plugin "${pluginName}" not found in ${location}`,
369 }
370 }
371
372 const entry = foundPlugin
373 const pluginId = `${entry.name}@${foundMarketplace}`
374
375 const result = await installResolvedPlugin({
376 pluginId,
377 entry,
378 scope,
379 marketplaceInstallLocation,

Callers 1

installPluginFunction · 0.85

Calls 9

assertInstallableScopeFunction · 0.85
parsePluginIdentifierFunction · 0.85
getPluginByIdFunction · 0.85
installResolvedPluginFunction · 0.85
formatResolutionErrorFunction · 0.85
entriesMethod · 0.80
logErrorFunction · 0.50
toErrorFunction · 0.50

Tested by

no test coverage detected