chore(agent-runner): remove split-out incidental fixes

This commit is contained in:
huanghuoguoguo
2026-06-14 21:20:31 +08:00
parent 9037d7f592
commit 0a71747eec
9 changed files with 14 additions and 167 deletions
@@ -12,7 +12,7 @@ class MCPRouterGroup(group.RouterGroup):
async def initialize(self) -> None:
@self.route('/servers', methods=['GET', 'POST'], auth_type=group.AuthType.USER_TOKEN)
async def _() -> str:
"""List MCP servers or create a new MCP server."""
"""获取MCP服务器列表"""
if quart.request.method == 'GET':
servers = await self.ap.mcp_service.get_mcp_servers(contain_runtime_info=True)
@@ -30,7 +30,7 @@ class MCPRouterGroup(group.RouterGroup):
@self.route('/servers/<server_name>', methods=['GET', 'PUT', 'DELETE'], auth_type=group.AuthType.USER_TOKEN)
async def _(server_name: str) -> str:
"""Get, update, or delete an MCP server configuration."""
"""获取、更新或删除MCP服务器配置"""
from urllib.parse import unquote
server_name = unquote(server_name)
@@ -59,7 +59,7 @@ class MCPRouterGroup(group.RouterGroup):
@self.route('/servers/<server_name>/test', methods=['POST'], auth_type=group.AuthType.USER_TOKEN)
async def _(server_name: str) -> str:
"""Test an MCP server connection."""
"""测试MCP服务器连接"""
from urllib.parse import unquote
server_name = unquote(server_name)
+1 -1
View File
@@ -137,7 +137,7 @@ class MCPService:
await self.ap.tool_mgr.mcp_tool_loader.remove_mcp_server(server_name)
async def test_mcp_server(self, server_name: str, server_data: dict) -> int:
"""Test an MCP server connection and return the task ID."""
"""测试 MCP 服务器连接并返回任务 ID"""
runtime_mcp_session: RuntimeMCPSession | None = None
@@ -1,37 +0,0 @@
"""ensure mcp_servers readme column exists
Revision ID: 8f24d6c9b1a0
Revises: 7b2c1d9e4f30
Create Date: 2026-06-13
"""
from alembic import op
import sqlalchemy as sa
revision = '8f24d6c9b1a0'
down_revision = '7b2c1d9e4f30'
branch_labels = None
depends_on = None
def _table_exists(table_name: str) -> bool:
return table_name in sa.inspect(op.get_bind()).get_table_names()
def _column_exists(table_name: str, column_name: str) -> bool:
return column_name in {column['name'] for column in sa.inspect(op.get_bind()).get_columns(table_name)}
def upgrade() -> None:
if not _table_exists('mcp_servers') or _column_exists('mcp_servers', 'readme'):
return
with op.batch_alter_table('mcp_servers', schema=None) as batch_op:
batch_op.add_column(sa.Column('readme', sa.Text(), nullable=False, server_default=''))
def downgrade() -> None:
if not _table_exists('mcp_servers') or not _column_exists('mcp_servers', 'readme'):
return
with op.batch_alter_table('mcp_servers', schema=None) as batch_op:
batch_op.drop_column('readme')
+7 -18
View File
@@ -206,11 +206,10 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
self,
file_bytes: bytes,
task_context: taskmgr.TaskContext | None,
) -> tuple[str | None, str | None, str | None]:
) -> tuple[str | None, str | None]:
"""Extract plugin identity and dependency metadata from a plugin package."""
plugin_author = None
plugin_name = None
plugin_version = None
try:
with zipfile.ZipFile(io.BytesIO(file_bytes)) as zf:
@@ -219,7 +218,6 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
metadata = manifest.get('metadata', {})
plugin_author = metadata.get('author')
plugin_name = metadata.get('name')
plugin_version = metadata.get('version')
except Exception:
pass
@@ -238,7 +236,7 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
except Exception:
pass
return plugin_author, plugin_name, plugin_version
return plugin_author, plugin_name
async def _install_mcp_from_marketplace(
self,
@@ -377,10 +375,9 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
install_source: PluginInstallSource,
install_info: dict[str, Any],
task_context: taskmgr.TaskContext | None = None,
):
):
plugin_author = install_info.get('plugin_author')
plugin_name = install_info.get('plugin_name')
plugin_file_transferred = False
if install_source == PluginInstallSource.MARKETPLACE:
# Handle marketplace plugin/mcp/skill installation
@@ -475,18 +472,14 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
)
file_bytes = download_resp.content
plugin_author, plugin_name, plugin_version = self._inspect_plugin_package(
plugin_author, plugin_name = self._inspect_plugin_package(
file_bytes,
task_context,
)
if task_context is not None and plugin_author and plugin_name:
task_context.metadata['plugin_name'] = f'{plugin_author}/{plugin_name}'
if task_context is not None and plugin_version:
task_context.metadata['plugin_version'] = plugin_version
file_key = await self.handler.send_file(file_bytes, 'lbpkg')
install_info['plugin_file_key'] = file_key
install_source = PluginInstallSource.LOCAL
plugin_file_transferred = True
self.ap.logger.info(f'Transfered file {file_key} to plugin runtime')
# Continue to install via runtime
else:
@@ -502,14 +495,12 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
mcp_resp.raise_for_status()
raise Exception(f'Failed to get MCP {plugin_author}/{plugin_name}')
if install_source == PluginInstallSource.LOCAL and not plugin_file_transferred:
if install_source == PluginInstallSource.LOCAL:
# transfer file before install
file_bytes = install_info['plugin_file']
plugin_author, plugin_name, plugin_version = self._inspect_plugin_package(file_bytes, task_context)
plugin_author, plugin_name = self._inspect_plugin_package(file_bytes, task_context)
if task_context is not None and plugin_author and plugin_name:
task_context.metadata['plugin_name'] = f'{plugin_author}/{plugin_name}'
if task_context is not None and plugin_version:
task_context.metadata['plugin_version'] = plugin_version
file_key = await self.handler.send_file(file_bytes, 'lbpkg')
install_info['plugin_file_key'] = file_key
del install_info['plugin_file']
@@ -546,11 +537,9 @@ class PluginRuntimeConnector(ManagedRuntimeConnector):
task_context.metadata['download_speed'] = downloaded / elapsed if elapsed > 0 else 0
file_bytes = b''.join(chunks)
plugin_author, plugin_name, plugin_version = self._inspect_plugin_package(file_bytes, task_context)
plugin_author, plugin_name = self._inspect_plugin_package(file_bytes, task_context)
if task_context is not None and plugin_author and plugin_name:
task_context.metadata['plugin_name'] = f'{plugin_author}/{plugin_name}'
if task_context is not None and plugin_version:
task_context.metadata['plugin_version'] = plugin_version
file_key = await self.handler.send_file(file_bytes, 'lbpkg')
install_info['plugin_file_key'] = file_key
self.ap.logger.info(f'Transfered file {file_key} to plugin runtime')
+1 -13
View File
@@ -1,6 +1,5 @@
from __future__ import annotations
import asyncio
import sqlalchemy
import traceback
@@ -85,19 +84,8 @@ class ModelManager:
self.ap.logger.info('LangBot Space Models service is disabled, skipping sync.')
return
sync_timeout = space_config.get('models_sync_timeout')
try:
if sync_timeout:
await asyncio.wait_for(
self.sync_new_models_from_space(),
timeout=float(sync_timeout),
)
else:
await self.sync_new_models_from_space()
except asyncio.TimeoutError:
self.ap.logger.warning(
f'LangBot Space model sync timed out after {sync_timeout}s, skipping startup sync.'
)
await self.sync_new_models_from_space()
except Exception as e:
self.ap.logger.warning('Failed to sync new models from LangBot Space, model list may not be updated.')
self.ap.logger.warning(f' - Error: {e}')