Implementation:Langgenius Dify PluginLifecycleOps
| Knowledge Sources | |
|---|---|
| Domains | Plugin Management Lifecycle Workspace Governance |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
Concrete tool for upgrading, uninstalling, and governing plugin permissions provided by the Dify plugin service layer.
Description
This module provides four API functions that manage the post-installation lifecycle of plugins. updateFromMarketPlace upgrades an installed plugin to a newer version from the marketplace by submitting both the original and new unique identifiers. updateFromGitHub performs the same upgrade operation sourced from a GitHub repository release, accepting the repository URL, version, package name, and both identifier strings. uninstallPlugin removes an installed plugin from the workspace by its installation ID. updatePermission modifies the workspace-level permission policy that controls who can install and debug plugins. All four functions use HTTP POST operations and require appropriate workspace permissions.
Usage
Use these functions when:
- Implementing an upgrade button that transitions a plugin from its current version to a newer one.
- Building a GitHub-based upgrade flow where users select a new release from a repository.
- Creating an uninstall confirmation flow that removes a plugin and its associated state.
- Designing a workspace settings panel where admins configure install and debug permissions.
Code Reference
Source Location
- Repository: Dify
- File:
web/service/plugins.ts(lines 29-106)
Signature
// Upgrade a plugin from the marketplace
export const updateFromMarketPlace = async (
body: Record<string, string>
): Promise<InstallPackageResponse>
// POST /workspaces/current/plugin/upgrade/marketplace
// Body: { original_plugin_unique_identifier, new_plugin_unique_identifier }
// Upgrade a plugin from a GitHub repository
export const updateFromGitHub = async (
repoUrl: string,
selectedVersion: string,
selectedPackage: string,
originalPlugin: string,
newPlugin: string
): Promise<updatePackageResponse>
// POST /workspaces/current/plugin/upgrade/github
// Body: { repo, version, package, original_plugin_unique_identifier, new_plugin_unique_identifier }
// Uninstall a plugin from the workspace
export const uninstallPlugin = async (
pluginId: string
): Promise<UninstallPluginResponse>
// POST /workspaces/current/plugin/uninstall
// Body: { plugin_installation_id: pluginId }
// Update workspace plugin permissions
export const updatePermission = async (
permissions: Permissions
): Promise<void>
// POST /workspaces/current/plugin/permission/change
// Body: { install_permission: 'everyone' | 'admin', debug_permission: 'everyone' | 'admin' }
Import
import {
updateFromMarketPlace,
updateFromGitHub,
uninstallPlugin,
updatePermission,
} from '@/service/plugins'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| body | Record<string, string> | Yes (marketplace upgrade) | Must contain original_plugin_unique_identifier (currently installed version) and new_plugin_unique_identifier (target version) |
| repoUrl | string | Yes (GitHub upgrade) | Full URL of the GitHub repository hosting the plugin |
| selectedVersion | string | Yes (GitHub upgrade) | Release tag or version string of the target version |
| selectedPackage | string | Yes (GitHub upgrade) | Name of the package file within the GitHub release |
| originalPlugin | string | Yes (GitHub upgrade) | Unique identifier of the currently installed plugin version |
| newPlugin | string | Yes (GitHub upgrade) | Unique identifier of the target plugin version |
| pluginId | string | Yes (uninstall) | Installation ID of the plugin to remove from the workspace |
| permissions | Permissions | Yes (permission update) | Object with install_permission and debug_permission fields, each set to "everyone" or "admin" |
Outputs
| Name | Type | Description |
|---|---|---|
| InstallPackageResponse | object | Contains task ID and status for the marketplace upgrade operation (follows the same async task model as installation) |
| updatePackageResponse | object | Contains task ID and status for the GitHub upgrade operation |
| UninstallPluginResponse | object | Confirmation of the uninstallation with the removed plugin's identifier |
Dependencies
| Dependency | Purpose |
|---|---|
@/service/base (post) |
HTTP POST requests for all lifecycle operations (upgrade, uninstall, permission change) |
Usage Examples
import {
updateFromMarketPlace,
updateFromGitHub,
uninstallPlugin,
updatePermission,
} from '@/service/plugins'
// 1. Upgrade a plugin from the marketplace
const upgradeResult = await updateFromMarketPlace({
original_plugin_unique_identifier: 'langgenius/google-search/0.1.0',
new_plugin_unique_identifier: 'langgenius/google-search/0.2.0',
})
console.log('Upgrade task started:', upgradeResult.task_id)
// 2. Upgrade a plugin from GitHub
const githubUpgrade = await updateFromGitHub(
'https://github.com/langgenius/dify-plugin-google-search',
'v0.2.0',
'google-search.difypkg',
'langgenius/google-search/0.1.0',
'langgenius/google-search/0.2.0',
)
// 3. Uninstall a plugin
const uninstallResult = await uninstallPlugin('installation-uuid-abc123')
console.log('Plugin uninstalled:', uninstallResult)
// 4. Restrict plugin installation to admins only
await updatePermission({
install_permission: 'admin',
debug_permission: 'admin',
})
// 5. Allow all workspace members to install plugins
await updatePermission({
install_permission: 'everyone',
debug_permission: 'admin', // keep debug restricted
})