mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-07 22:36:02 +00:00
perf: Filter plugins by component types in pipeline extensions (#1821)
* Initial plan * Add component-kind filtering to list_plugins and filter pipeline extensions to only show plugins with Command, EventListener, or Tool components Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> * fix: testing path --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: RockChinQ <45992437+RockChinQ@users.noreply.github.com> Co-authored-by: Junyan Qin <rockchinq@gmail.com>
This commit is contained in:
@@ -284,12 +284,35 @@ class PluginRuntimeConnector:
|
||||
task_context.trace('Cleaning up plugin configuration and storage...')
|
||||
await self.handler.cleanup_plugin_data(plugin_author, plugin_name)
|
||||
|
||||
async def list_plugins(self) -> list[dict[str, Any]]:
|
||||
async def list_plugins(self, component_kinds: list[str] | None = None) -> list[dict[str, Any]]:
|
||||
"""List plugins, optionally filtered by component kinds.
|
||||
|
||||
Args:
|
||||
component_kinds: Optional list of component kinds to filter by.
|
||||
If provided, only plugins that contain at least one
|
||||
component of the specified kinds will be returned.
|
||||
E.g., ['Command', 'EventListener', 'Tool'] for pipeline-related plugins.
|
||||
"""
|
||||
if not self.is_enable_plugin:
|
||||
return []
|
||||
|
||||
plugins = await self.handler.list_plugins()
|
||||
|
||||
# Filter plugins by component kinds if specified
|
||||
if component_kinds is not None:
|
||||
filtered_plugins = []
|
||||
for plugin in plugins:
|
||||
components = plugin.get('components', [])
|
||||
has_matching_component = False
|
||||
for component in components:
|
||||
component_kind = component.get('manifest', {}).get('manifest', {}).get('kind', '')
|
||||
if component_kind in component_kinds:
|
||||
has_matching_component = True
|
||||
break
|
||||
if has_matching_component:
|
||||
filtered_plugins.append(plugin)
|
||||
plugins = filtered_plugins
|
||||
|
||||
# Sort plugins: debug plugins first, then by installation time (newest first)
|
||||
# Get installation timestamps from database in a single query
|
||||
plugin_timestamps = {}
|
||||
|
||||
Reference in New Issue
Block a user