mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-21 16:05:19 +08:00
feat(agent-runner): finalize 4.x processor integration
This commit is contained in:
@@ -17,7 +17,7 @@ AGENT_DEFAULT_EVENT_PATTERNS = ['*']
|
||||
|
||||
|
||||
class AgentService:
|
||||
"""Unified product surface for Agent processors and Pipelines."""
|
||||
"""Unified processor facade for the peer Agent and Pipeline types."""
|
||||
|
||||
ap: app.Application
|
||||
|
||||
|
||||
@@ -200,16 +200,10 @@ class PipelineService:
|
||||
return pipeline_data['uuid']
|
||||
|
||||
async def update_pipeline(self, pipeline_uuid: str, pipeline_data: dict) -> None:
|
||||
from ....agent.runner.config_migration import ConfigMigration
|
||||
|
||||
pipeline_data = pipeline_data.copy()
|
||||
for protected_field in ('uuid', 'for_version', 'stages', 'is_default'):
|
||||
pipeline_data.pop(protected_field, None)
|
||||
|
||||
# Migrate config to new format before saving
|
||||
if 'config' in pipeline_data:
|
||||
pipeline_data['config'] = ConfigMigration.migrate_pipeline_config(pipeline_data['config'])
|
||||
|
||||
await self.ap.persistence_mgr.execute_async(
|
||||
sqlalchemy.update(persistence_pipeline.LegacyPipeline)
|
||||
.where(persistence_pipeline.LegacyPipeline.uuid == pipeline_uuid)
|
||||
|
||||
@@ -164,32 +164,32 @@ class LangBotMCPServer:
|
||||
await ap.pipeline_service.delete_pipeline(pipeline_uuid)
|
||||
return _dump({'ok': True})
|
||||
|
||||
# ----- Agents -------------------------------------------------- #
|
||||
# ----- Processors ---------------------------------------------- #
|
||||
@mcp.tool(description='List product-level processors, including Agents and Pipelines.')
|
||||
async def list_agents() -> str:
|
||||
async def list_processors() -> str:
|
||||
return _dump(await ap.agent_service.get_agents())
|
||||
|
||||
@mcp.tool(description='Get a product-level Agent or Pipeline by UUID.')
|
||||
async def get_agent(agent_uuid: str) -> str:
|
||||
return _dump(await ap.agent_service.get_agent(agent_uuid))
|
||||
@mcp.tool(description='Get an Agent or Pipeline processor by UUID.')
|
||||
async def get_processor(processor_uuid: str) -> str:
|
||||
return _dump(await ap.agent_service.get_agent(processor_uuid))
|
||||
|
||||
@mcp.tool(
|
||||
description=(
|
||||
'Create an Agent processor or Pipeline. `agent_data` matches '
|
||||
'POST /api/v1/agents; set kind to `agent` or `pipeline`. Returns the new UUID and kind.'
|
||||
'Create an Agent or Pipeline processor. Set `processor_data.kind` to '
|
||||
'`agent` or `pipeline`. Returns the new UUID and kind.'
|
||||
)
|
||||
)
|
||||
async def create_agent(agent_data: dict) -> str:
|
||||
return _dump(await ap.agent_service.create_agent(agent_data))
|
||||
async def create_processor(processor_data: dict) -> str:
|
||||
return _dump(await ap.agent_service.create_agent(processor_data))
|
||||
|
||||
@mcp.tool(description='Update an Agent processor or Pipeline by UUID.')
|
||||
async def update_agent(agent_uuid: str, agent_data: dict) -> str:
|
||||
await ap.agent_service.update_agent(agent_uuid, agent_data)
|
||||
@mcp.tool(description='Update an Agent or Pipeline processor by UUID.')
|
||||
async def update_processor(processor_uuid: str, processor_data: dict) -> str:
|
||||
await ap.agent_service.update_agent(processor_uuid, processor_data)
|
||||
return _dump({'ok': True})
|
||||
|
||||
@mcp.tool(description='Delete an Agent processor or Pipeline by UUID.')
|
||||
async def delete_agent(agent_uuid: str) -> str:
|
||||
await ap.agent_service.delete_agent(agent_uuid)
|
||||
@mcp.tool(description='Delete an Agent or Pipeline processor by UUID.')
|
||||
async def delete_processor(processor_uuid: str) -> str:
|
||||
await ap.agent_service.delete_agent(processor_uuid)
|
||||
return _dump({'ok': True})
|
||||
|
||||
# ----- Models -------------------------------------------------- #
|
||||
|
||||
Reference in New Issue
Block a user