feat: get plugin info

This commit is contained in:
Junyan Qin
2025-07-13 22:14:22 +08:00
parent 4380041c7f
commit e0abd19636
3 changed files with 19 additions and 4 deletions

View File

@@ -50,10 +50,10 @@ class PluginsRouterGroup(group.RouterGroup):
)
async def _(author: str, plugin_name: str) -> str:
if quart.request.method == 'GET':
plugin = self.ap.plugin_mgr.get_plugin(author, plugin_name)
plugin = await self.ap.plugin_connector.get_plugin_info(author, plugin_name)
if plugin is None:
return self.http_status(404, -1, 'plugin not found')
return self.success(data={'plugin': plugin.model_dump()})
return self.success(data={'plugin': plugin})
elif quart.request.method == 'DELETE':
ctx = taskmgr.TaskContext.new()
wrapper = self.ap.task_mgr.create_user_task(
@@ -72,11 +72,11 @@ class PluginsRouterGroup(group.RouterGroup):
auth_type=group.AuthType.USER_TOKEN,
)
async def _(author: str, plugin_name: str) -> quart.Response:
plugin = self.ap.plugin_mgr.get_plugin(author, plugin_name)
plugin = await self.ap.plugin_connector.get_plugin_info(author, plugin_name)
if plugin is None:
return self.http_status(404, -1, 'plugin not found')
if quart.request.method == 'GET':
return self.success(data={'config': plugin.plugin_config})
return self.success(data={'config': plugin['plugin_config']})
elif quart.request.method == 'PUT':
data = await quart.request.json

View File

@@ -98,6 +98,9 @@ class PluginRuntimeConnector:
async def list_plugins(self) -> list[dict[str, Any]]:
return await self.handler.list_plugins()
async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any]:
return await self.handler.get_plugin_info(author, plugin_name)
async def emit_event(
self,
event: events.BaseEventModel,

View File

@@ -372,6 +372,18 @@ class RuntimeConnectionHandler(handler.Handler):
return result['plugins']
async def get_plugin_info(self, author: str, plugin_name: str) -> dict[str, Any]:
"""Get plugin"""
result = await self.call_action(
LangBotToRuntimeAction.GET_PLUGIN_INFO,
{
'author': author,
'plugin_name': plugin_name,
},
timeout=10,
)
return result['plugin']
async def emit_event(
self,
event_context: dict[str, Any],