66 lines
2.8 KiB
Markdown
66 lines
2.8 KiB
Markdown
# pipeline_service
|
||
|
||
产线执行引擎 —— 任务调度、步骤执行、人工任务交互、LLM 桥接。
|
||
|
||
## 功能
|
||
|
||
- **任务执行**:DAG 步骤调度与状态机
|
||
- **人工任务**:审批/输入等待与交互
|
||
- **LLM 桥接**:统一 LLM 调用接口
|
||
- **Agent Loop**:AI Agent 多轮任务执行
|
||
- **意图分类**:自然语言意图识别
|
||
- **产物管理**:步骤输入输出存储
|
||
|
||
## 数据表
|
||
|
||
| 表 | 说明 |
|
||
|---|------|
|
||
| pipeline_tasks | 任务实例 |
|
||
| pipeline_task_steps | 步骤执行记录 |
|
||
| pipeline_artifacts | 步骤产物 |
|
||
| pipeline_human_tasks | 人工任务 |
|
||
| pipeline_step_types | 步骤类型注册 |
|
||
| pipeline_session_settings | 会话设置(多 tab 项目上下文) |
|
||
| pipeline_conversations | 平台会话消息(回放缓存;2026-09-10 归籍本模块——唯一写入方 agent_loop_v2._save_turn,此前是无 models 定义的孤儿表) |
|
||
|
||
## 安装
|
||
|
||
```bash
|
||
cd pkgs/pipeline-service && pip install .
|
||
```
|
||
|
||
## 核心模块
|
||
|
||
| 文件 | 职责 |
|
||
|------|------|
|
||
| `executor.py` | 任务/步骤调度引擎 |
|
||
| `storage.py` | 数据库读写 |
|
||
| `llm_bridge.py` | LLM API 调用 |
|
||
| `agent_loop.py` | AI Agent 多轮执行 |
|
||
| `human.py` | 人工任务处理 |
|
||
| `intent_classifier.py` | 意图识别 |
|
||
| `state.py` | 状态机 |
|
||
| `step_registry.py` | 步骤类型注册表 |
|
||
| `agent_loop_v2.py` | Agent Executor v2(会话 agent 执行引擎) |
|
||
| `workspace.py` | 项目/通用会话工作空间目录管理 |
|
||
| `sdlc_ability.py` | SDLC 产线能力包(工具定义 + handler) |
|
||
|
||
## 通用会话产线隔离(2026-09-05,7 层纵深防御)
|
||
|
||
规范:通用会话(generic=True,agent_chat_generic.dspy)= 纯通用 agent,
|
||
不挂任何产线工具/技能/角色/记忆,不得看到或操作任何产线的项目。
|
||
|
||
隔离层(缺一层即泄漏,详见技能 cockpit-agent-patterns):
|
||
|
||
1. **工具注册表**:ToolRegistry 每 executor 独立实例(禁全局单例,防跨会话残留)
|
||
2. **默认产线回退**:generic 会话 pipeline_id 空不回退 DEFAULT_ABILITY_ID
|
||
3. **产线能力包**:_execute_ability_tool 对 generic 直接拒绝
|
||
4. **工具 schema**:load_agent_config(pipeline-core)generic 时剔除 project/shell 类工具
|
||
5. **执行层兜底**:_dispatch_sdlc_tool 对 generic 拒绝项目管理工具(别名归一后拦截)
|
||
6. **工作空间**:generic 会话文件根 = `_general/{user_id}` 专属目录(generic_workspace_dir),
|
||
_resolve_ws_path 越界保护圈死;run_command 剔除(shell 无法圈禁);
|
||
resolve_upload_dir(pipeline-core)generic=True 上传落同一专属目录
|
||
7. **历史回放**:_load_history / _t_session_search 对 generic 只读写
|
||
`pipeline_id='' OR IS NULL` 的自身历史(与存库端 store_pl='' 对称),
|
||
禁止按 created_by 全量回放(会带出用户各产线对话中的项目信息)
|