diff --git a/docs/agent-runner-pluginization/PHASE0_INTEGRATION_RECORD.md b/docs/agent-runner-pluginization/PHASE0_INTEGRATION_RECORD.md deleted file mode 100644 index 981981c2..00000000 --- a/docs/agent-runner-pluginization/PHASE0_INTEGRATION_RECORD.md +++ /dev/null @@ -1,63 +0,0 @@ -# Agent Runner Pluginization Phase 0 Integration Test Record - -## Test Summary - -**Status**: PASSED - -**Date**: 2026-05-10 10:09 - -## Test Configuration - -- **LangBot Branch**: feat/agent-runner-plugin -- **SDK Branch**: feat/agent-runner-plugin -- **Runner Repo**: langbot-agent-runner (new) - -## Test Scenario - -- **Selected Runner**: `plugin:langbot/local-agent/default` -- **Input**: `1` -- **Expected Output**: `[stub] Echo: 1` -- **Actual Output**: `[stub] Echo: 1` - -## Verified Chain - -``` -Frontend selects plugin:langbot/local-agent/default - -> LangBot pipeline - -> AgentRunOrchestrator - -> SDK runtime RUN_AGENT - -> langbot-agent-runner/local-agent DefaultAgentRunner - -> AgentRunResult - -> LangBot response -``` - -## Key Components Verified - -### LangBot Host -- AgentRunOrchestrator resolves runner ID via ConfigMigration -- AgentRunContextBuilder builds SDK v1 context -- AgentResultNormalizer normalizes SDK v1 results -- ChatMessageHandler delegates to orchestrator (single resp_message_id, streaming pop/append) - -### SDK Runtime -- RUN_AGENT action dispatches to plugin runner -- AgentRunner component manifest parsing -- LIST_AGENT_RUNNERS returns runner metadata - -### langbot-agent-runner Plugin -- DefaultAgentRunner stub implementation -- AgentRunner manifest with protocol_version, capabilities, permissions -- Echo response validates SDK v1 result format - -## Next Steps (Phase 1) - -1. Implement real Dify runner (external API runner validation) -2. Update frontend to save `ai.runner.id` + `ai.runner_config` -3. Add persistence migration for old config format -4. Update pipeline templates -5. Add proxy action secondary permission validation - -## Related Documents - -- [IMPLEMENTATION_PLAN.md](./IMPLEMENTATION_PLAN.md) -- [OFFICIAL_RUNNER_PLUGINS.md](./OFFICIAL_RUNNER_PLUGINS.md) \ No newline at end of file diff --git a/docs/agent-runner-pluginization/PROGRESS.md b/docs/agent-runner-pluginization/PROGRESS.md new file mode 100644 index 00000000..7251dd2a --- /dev/null +++ b/docs/agent-runner-pluginization/PROGRESS.md @@ -0,0 +1,94 @@ +# Agent Runner 插件化实现进度 + +本文档跟踪 Agent Runner 插件化的实现状态,便于快速了解当前进度。 + +## 总体进度 + +**当前阶段**: Phase 3 进行中 + +| Phase | 描述 | 状态 | +|-------|------|------| +| Phase 0 | PoC 验证 | ✅ 完成 | +| Phase 1 | 核心架构(Registry、Orchestrator、上下文模型) | ✅ 完成 | +| Phase 2 | 权限、能力声明、资源注入 | ✅ 完成 | +| Phase 3 | 内置 runner 迁移到插件 | ✅ 完成(7/7) | +| Phase 4 | EBA 事件支持 | 🔲 未开始 | + +--- + +## 详细状态 + +### SDK 侧 (`langbot-plugin-sdk`) + +| 组件 | 状态 | 备注 | +|------|------|------| +| `AgentRunner` 组件 | ✅ | `api/definition/components/agent_runner/runner.py` | +| `AgentRunContext` | ✅ | `api/entities/builtin/agent_runner/context.py` | +| `AgentRunResult` | ✅ | `api/entities/builtin/agent_runner/result.py` | +| `AgentRunnerCapabilities` | ✅ | `api/entities/builtin/agent_runner/capabilities.py` | +| `AgentRunnerPermissions` | ✅ | `api/entities/builtin/agent_runner/permissions.py` | +| EBA 事件模型 (Event/Actor/Subject) | ✅ | `api/entities/builtin/agent_runner/event.py` | +| `LIST_AGENT_RUNNERS` action | ✅ | `runtime/io/handlers/control.py` | +| `RUN_AGENT` action | ✅ | `runtime/io/handlers/control.py` | +| `AgentRunAPIProxy` | ✅ | `api/proxies/agent_run_api.py` | + +### LangBot 侧 + +| 组件 | 状态 | 备注 | +|------|------|------| +| `AgentRunnerRegistry` | ✅ | `pkg/agent/runner/registry.py` | +| `AgentRunOrchestrator` | ✅ | `pkg/agent/runner/orchestrator.py` | +| `AgentRunnerDescriptor` | ✅ | `pkg/agent/runner/descriptor.py` | +| `AgentResourceBuilder` | ✅ | `pkg/agent/runner/resource_builder.py` | +| `AgentRunContextBuilder` | ✅ | `pkg/agent/runner/context_builder.py` | +| `AgentResultNormalizer` | ✅ | `pkg/agent/runner/result_normalizer.py` | +| `ConfigMigration` | ✅ | `pkg/agent/runner/config_migration.py` | +| `ChatMessageHandler` 集成 | ✅ | 使用 orchestrator 替代 wrapper | +| `PipelineService` 集成 | ✅ | 从 registry 获取 runner metadata | +| Plugin connector | ✅ | `list_agent_runners()` / `run_agent()` | + +### 官方插件 + +> 插件仓库:`/home/glwuy/langbot-app/langbot-agent-runner/` (monorepo) + +| 插件 | 状态 | 备注 | +|------|------|------| +| `local-agent` | ✅ 已完成 | 核心功能:模型、工具、知识库、流式、会话 | +| `dify-agent` | ✅ 已完成 | 支持 chat/agent/workflow 三种应用类型 | +| `n8n-agent` | ✅ 已完成 | Webhook 调用,支持 basic/jwt/header 认证 | +| `coze-agent` | ✅ 已完成 | 多模态输入,思维链处理 | +| `dashscope-agent` | ✅ 已完成 | 阿里云百炼,支持 agent/workflow 两种模式 | +| `langflow-agent` | ✅ 已完成 | SSE 流式,tweaks 配置支持 | +| `tbox-agent` | ✅ 已完成 | 蚂蚁百宝箱,多模态输入 | + +**注意**: LangBot 内置的旧 runner(`pkg/provider/runners/`)已标记为 legacy,文件顶部添加了 DEPRECATED 注释。 + +--- + +## 待办事项 + +### 高优先级 + +- [ ] 工具详情 API — local-agent runner 有 TODO 注释 + +### 低优先级 / 未来 + +- [ ] EBA 完整集成 — event context 未在 context builder 中填充 +- [ ] 平台 API 动作执行 — `action.requested` 结果类型存在但未执行 + +--- + +## 关键决策记录 + +| 日期 | 决策 | +|------|------| +| 2026-05-10 | Phase 0 集成测试通过,SDK v1 协议验证成功 | +| 2026-05-13 | Phase 3 完成:所有 7 个官方 runner 插件迁移完成 | + +--- + +## 相关文档 + +- [README.md](./README.md) — 总体设计 +- [OFFICIAL_RUNNER_PLUGINS.md](./OFFICIAL_RUNNER_PLUGINS.md) — 官方插件仓库计划 +- [IMPLEMENTATION_PLAN.md](./IMPLEMENTATION_PLAN.md) — 具体实施细节 diff --git a/src/langbot/pkg/provider/runners/cozeapi.py b/src/langbot/pkg/provider/runners/cozeapi.py index 26980f81..00eacaaf 100644 --- a/src/langbot/pkg/provider/runners/cozeapi.py +++ b/src/langbot/pkg/provider/runners/cozeapi.py @@ -1,3 +1,12 @@ +""" +Legacy Coze API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/coze-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/coze-agent/ +""" + from __future__ import annotations import typing diff --git a/src/langbot/pkg/provider/runners/dashscopeapi.py b/src/langbot/pkg/provider/runners/dashscopeapi.py index a2c593cc..6b3cf4e3 100644 --- a/src/langbot/pkg/provider/runners/dashscopeapi.py +++ b/src/langbot/pkg/provider/runners/dashscopeapi.py @@ -1,3 +1,12 @@ +""" +Legacy DashScope (阿里云百炼) API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/dashscope-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/dashscope-agent/ +""" + from __future__ import annotations import typing diff --git a/src/langbot/pkg/provider/runners/difysvapi.py b/src/langbot/pkg/provider/runners/difysvapi.py index 039bf33a..40d6c463 100644 --- a/src/langbot/pkg/provider/runners/difysvapi.py +++ b/src/langbot/pkg/provider/runners/difysvapi.py @@ -1,3 +1,12 @@ +""" +Legacy Dify Service API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/dify-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/dify-agent/ +""" + from __future__ import annotations import typing diff --git a/src/langbot/pkg/provider/runners/langflowapi.py b/src/langbot/pkg/provider/runners/langflowapi.py index 8995476d..5bff7891 100644 --- a/src/langbot/pkg/provider/runners/langflowapi.py +++ b/src/langbot/pkg/provider/runners/langflowapi.py @@ -1,3 +1,12 @@ +""" +Legacy Langflow API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/langflow-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/langflow-agent/ +""" + from __future__ import annotations import typing diff --git a/src/langbot/pkg/provider/runners/localagent.py b/src/langbot/pkg/provider/runners/localagent.py index b48e9cc3..4d553dd2 100644 --- a/src/langbot/pkg/provider/runners/localagent.py +++ b/src/langbot/pkg/provider/runners/localagent.py @@ -1,3 +1,12 @@ +""" +Legacy Local Agent Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/local-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-local-agent/ +""" + from __future__ import annotations import json @@ -11,8 +20,8 @@ import langbot_plugin.api.entities.builtin.rag.context as rag_context rag_combined_prompt_template = """ -The following are relevant context entries retrieved from the knowledge base. -Please use them to answer the user's message. +The following are relevant context entries retrieved from the knowledge base. +Please use them to answer the user's message. Respond in the same language as the user's input. diff --git a/src/langbot/pkg/provider/runners/n8nsvapi.py b/src/langbot/pkg/provider/runners/n8nsvapi.py index 543fd7ef..252dbe69 100644 --- a/src/langbot/pkg/provider/runners/n8nsvapi.py +++ b/src/langbot/pkg/provider/runners/n8nsvapi.py @@ -1,3 +1,12 @@ +""" +Legacy n8n Service API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/n8n-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/n8n-agent/ +""" + from __future__ import annotations import typing diff --git a/src/langbot/pkg/provider/runners/tboxapi.py b/src/langbot/pkg/provider/runners/tboxapi.py index 0fb22a64..fc7a19da 100644 --- a/src/langbot/pkg/provider/runners/tboxapi.py +++ b/src/langbot/pkg/provider/runners/tboxapi.py @@ -1,3 +1,12 @@ +""" +Legacy Tbox (蚂蚁百宝箱) API Runner. + +DEPRECATED: This runner has been migrated to the AgentRunner plugin format. +Use the official `langbot/tbox-agent` plugin instead. + +Migration target: /home/glwuy/langbot-app/langbot-agent-runner/tbox-agent/ +""" + from __future__ import annotations import typing