diff --git a/pipeline_service/agent_loop_v2.py b/pipeline_service/agent_loop_v2.py index 76405a8..1a04f26 100644 --- a/pipeline_service/agent_loop_v2.py +++ b/pipeline_service/agent_loop_v2.py @@ -62,6 +62,7 @@ class AgentExecutor: workspace_dir: str = "", model_name: str = None, role: str = "", # 产线内角色(可选,如 develop/design;驾驶舱 agent 为空) + base_url: str = "", # 请求 base_url(scheme://host/),供 slash 命令生成 widget 绝对 URL ): self.config = config self.project_id = project_id @@ -71,6 +72,7 @@ class AgentExecutor: self.role = role # 产线内角色(技能/工具/prompt 按角色加载) self.workspace_dir = workspace_dir or WORKSPACE_BASE self.model_name = model_name or config.model_name + self.base_url = base_url # 运行状态 self._msgs: List[dict] = [] # LLM 消息数组 @@ -653,10 +655,11 @@ class AgentExecutor: } def _build_slash_ctx(self) -> dict: - """构造传给 slash 命令 handler 的上下文(含 executor 引用 + role)。""" + """构造传给 slash 命令 handler 的上下文(含 executor 引用 + role + base_url)。""" ctx = self._build_ctx() ctx["executor"] = self ctx["role"] = self.role + ctx["base_url"] = getattr(self, "base_url", "") or "" return ctx async def _execute_ability_tool(self, tool_name: str, params: dict) -> Optional[str]: diff --git a/pipeline_service/gateway.py b/pipeline_service/gateway.py index 491fbcb..056dad5 100644 --- a/pipeline_service/gateway.py +++ b/pipeline_service/gateway.py @@ -109,7 +109,8 @@ class Gateway: # ── 统一消息入口 ── async def run_message(self, channel: str, user_id: str, content: str, - history=None, role: str = "", generic: bool = False) -> AsyncGenerator[str, None]: + history=None, role: str = "", generic: bool = False, + base_url: str = "") -> AsyncGenerator[str, None]: """统一消息入口:解析上下文 → 加载产线能力 → AgentExecutor 执行 → yield 事件流。 Args: @@ -153,7 +154,8 @@ class Gateway: if ctx.get("default_llm_name"): config.model_name = ctx["default_llm_name"] executor = AgentExecutor( - config=config, project_id=ctx["pid"], user_id=user_id, role=role) + config=config, project_id=ctx["pid"], user_id=user_id, role=role, + base_url=base_url) # 4. 转发标准化事件流 async for chunk in executor.run(content, history=history): diff --git a/pipeline_service/sdlc_ability.py b/pipeline_service/sdlc_ability.py index 86bf83f..a3c3d67 100644 --- a/pipeline_service/sdlc_ability.py +++ b/pipeline_service/sdlc_ability.py @@ -1477,6 +1477,9 @@ async def _slash_tasks(args, ctx): async def _slash_task(args, ctx): """任务树 + 输入输出(ResourceBrowser 弹窗)。返回 widget dict,前端 AgentOut 检测 widgettype 渲染。""" + base = (ctx.get("base_url") or "").rstrip("/") + tree_url = f"{base}/pipeline-sdlc/api/task_tree.dspy" + io_url = f"{base}/pipeline-sdlc/api/task_io.dspy" return { "widgettype": "PopupWindow", "options": { @@ -1492,7 +1495,7 @@ async def _slash_task(args, ctx): "tree_options": { "widgettype": "Tree", "options": { - "dataurl": "/pipeline-sdlc/api/task_tree.dspy", + "dataurl": tree_url, "textField": "label", "idField": "id", "cfontsize": 1.0, @@ -1500,7 +1503,7 @@ async def _slash_task(args, ctx): }, "browser_options": { "widgettype": "urlwidget", - "options": {"url": "/pipeline-sdlc/api/task_io.dspy"}, + "options": {"url": io_url}, }, "tree_width": "300px", },