Path: blob/main/src/vs/workbench/contrib/chat/common/plugins/pluginInstallService.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { CancellationToken } from '../../../../../base/common/cancellation.js';6import { URI } from '../../../../../base/common/uri.js';7import { createDecorator } from '../../../../../platform/instantiation/common/instantiation.js';8import { IMarketplacePlugin } from './pluginMarketplaceService.js';910export const IPluginInstallService = createDecorator<IPluginInstallService>('pluginInstallService');1112export interface IUpdateAllPluginsOptions {13/**14* When `true`, also re-installs npm/pip packages that have no pinned15* version. Defaults to `false` to avoid interactive terminal prompts16* during background updates.17*/18readonly force?: boolean;1920/**21* When `true`, suppresses the progress notification. An info22* notification is still shown listing any plugins that were23* updated, and error notifications are shown on failure.24*/25readonly silent?: boolean;26}2728export interface IUpdateAllPluginsResult {29/** Names of plugins/marketplaces that were updated successfully. */30readonly updatedNames: readonly string[];31/** Names of plugins/marketplaces that failed to update. */32readonly failedNames: readonly string[];33}3435export interface IInstallPluginFromSourceOptions {36/**37* When set, targets a specific plugin by name within the marketplace38* instead of installing all or prompting the user. The matched plugin39* is installed and returned in the result.40*/41readonly plugin?: string;42}4344export interface IInstallPluginFromSourceResult {45readonly success: boolean;46readonly message?: string;47/**48* When {@link IInstallPluginFromSourceOptions.plugin} is set and the49* plugin was found, this contains the discovered marketplace plugin.50*/51readonly matchedPlugin?: IMarketplacePlugin;52}5354export interface IPluginInstallService {55readonly _serviceBrand: undefined;5657/**58* Clones the marketplace repository (if not already cached) and registers59* the plugin in the marketplace service's installed plugins storage.60*/61installPlugin(plugin: IMarketplacePlugin): Promise<void>;6263/**64* Installs a plugin directly from a source location string. Accepts65* GitHub shorthand (`owner/repo`) or a full git clone URL. Clones the66* repository, reads marketplace metadata to discover plugins, and67* registers the selected plugin.68*69* When {@link IInstallPluginFromSourceOptions.plugin} is set, targets70* a specific plugin, installs it, and returns it.71*/72installPluginFromSource(source: string, options?: IInstallPluginFromSourceOptions): Promise<void>;7374/**75* Synchronously validates the format of a plugin source string.76* Returns an error message if the format is invalid, or undefined if valid.77*/78validatePluginSource(source: string): string | undefined;7980/**81* Installs a plugin from an already-validated source string.82* Handles trust, cloning, scanning, and registration. Returns a result83* with an optional error message (e.g. no plugins found).84*85* When {@link IInstallPluginFromSourceOptions.plugin} is set, targets86* a specific plugin, installs it, and returns it in87* {@link IInstallPluginFromSourceResult.matchedPlugin}.88*/89installPluginFromValidatedSource(source: string, options?: IInstallPluginFromSourceOptions): Promise<IInstallPluginFromSourceResult>;9091/**92* Pulls the latest changes for an already-cloned marketplace repository.93*/94updatePlugin(plugin: IMarketplacePlugin): Promise<boolean>;9596/**97* Updates all installed plugins. First pulls each unique marketplace98* repository, then updates non-relative-path plugins individually99* (git pull, npm install, pip install, etc.).100*/101updateAllPlugins(options: IUpdateAllPluginsOptions, token: CancellationToken): Promise<IUpdateAllPluginsResult>;102103/**104* Returns the URI where a marketplace plugin would be installed on disk.105* Used to determine whether a marketplace plugin is already installed.106*/107getPluginInstallUri(plugin: IMarketplacePlugin): URI;108}109110111