fix: /task 弹窗 widget url 用 base_url 拼完整绝对路径(前端 absurl 需完整 URL)
This commit is contained in:
parent
20395a78b6
commit
6add7ff4fa
@ -62,6 +62,7 @@ class AgentExecutor:
|
|||||||
workspace_dir: str = "",
|
workspace_dir: str = "",
|
||||||
model_name: str = None,
|
model_name: str = None,
|
||||||
role: str = "", # 产线内角色(可选,如 develop/design;驾驶舱 agent 为空)
|
role: str = "", # 产线内角色(可选,如 develop/design;驾驶舱 agent 为空)
|
||||||
|
base_url: str = "", # 请求 base_url(scheme://host/),供 slash 命令生成 widget 绝对 URL
|
||||||
):
|
):
|
||||||
self.config = config
|
self.config = config
|
||||||
self.project_id = project_id
|
self.project_id = project_id
|
||||||
@ -71,6 +72,7 @@ class AgentExecutor:
|
|||||||
self.role = role # 产线内角色(技能/工具/prompt 按角色加载)
|
self.role = role # 产线内角色(技能/工具/prompt 按角色加载)
|
||||||
self.workspace_dir = workspace_dir or WORKSPACE_BASE
|
self.workspace_dir = workspace_dir or WORKSPACE_BASE
|
||||||
self.model_name = model_name or config.model_name
|
self.model_name = model_name or config.model_name
|
||||||
|
self.base_url = base_url
|
||||||
|
|
||||||
# 运行状态
|
# 运行状态
|
||||||
self._msgs: List[dict] = [] # LLM 消息数组
|
self._msgs: List[dict] = [] # LLM 消息数组
|
||||||
@ -653,10 +655,11 @@ class AgentExecutor:
|
|||||||
}
|
}
|
||||||
|
|
||||||
def _build_slash_ctx(self) -> dict:
|
def _build_slash_ctx(self) -> dict:
|
||||||
"""构造传给 slash 命令 handler 的上下文(含 executor 引用 + role)。"""
|
"""构造传给 slash 命令 handler 的上下文(含 executor 引用 + role + base_url)。"""
|
||||||
ctx = self._build_ctx()
|
ctx = self._build_ctx()
|
||||||
ctx["executor"] = self
|
ctx["executor"] = self
|
||||||
ctx["role"] = self.role
|
ctx["role"] = self.role
|
||||||
|
ctx["base_url"] = getattr(self, "base_url", "") or ""
|
||||||
return ctx
|
return ctx
|
||||||
|
|
||||||
async def _execute_ability_tool(self, tool_name: str, params: dict) -> Optional[str]:
|
async def _execute_ability_tool(self, tool_name: str, params: dict) -> Optional[str]:
|
||||||
|
|||||||
@ -109,7 +109,8 @@ class Gateway:
|
|||||||
# ── 统一消息入口 ──
|
# ── 统一消息入口 ──
|
||||||
|
|
||||||
async def run_message(self, channel: str, user_id: str, content: str,
|
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 事件流。
|
"""统一消息入口:解析上下文 → 加载产线能力 → AgentExecutor 执行 → yield 事件流。
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -153,7 +154,8 @@ class Gateway:
|
|||||||
if ctx.get("default_llm_name"):
|
if ctx.get("default_llm_name"):
|
||||||
config.model_name = ctx["default_llm_name"]
|
config.model_name = ctx["default_llm_name"]
|
||||||
executor = AgentExecutor(
|
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. 转发标准化事件流
|
# 4. 转发标准化事件流
|
||||||
async for chunk in executor.run(content, history=history):
|
async for chunk in executor.run(content, history=history):
|
||||||
|
|||||||
@ -1477,6 +1477,9 @@ async def _slash_tasks(args, ctx):
|
|||||||
|
|
||||||
async def _slash_task(args, ctx):
|
async def _slash_task(args, ctx):
|
||||||
"""任务树 + 输入输出(ResourceBrowser 弹窗)。返回 widget dict,前端 AgentOut 检测 widgettype 渲染。"""
|
"""任务树 + 输入输出(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 {
|
return {
|
||||||
"widgettype": "PopupWindow",
|
"widgettype": "PopupWindow",
|
||||||
"options": {
|
"options": {
|
||||||
@ -1492,7 +1495,7 @@ async def _slash_task(args, ctx):
|
|||||||
"tree_options": {
|
"tree_options": {
|
||||||
"widgettype": "Tree",
|
"widgettype": "Tree",
|
||||||
"options": {
|
"options": {
|
||||||
"dataurl": "/pipeline-sdlc/api/task_tree.dspy",
|
"dataurl": tree_url,
|
||||||
"textField": "label",
|
"textField": "label",
|
||||||
"idField": "id",
|
"idField": "id",
|
||||||
"cfontsize": 1.0,
|
"cfontsize": 1.0,
|
||||||
@ -1500,7 +1503,7 @@ async def _slash_task(args, ctx):
|
|||||||
},
|
},
|
||||||
"browser_options": {
|
"browser_options": {
|
||||||
"widgettype": "urlwidget",
|
"widgettype": "urlwidget",
|
||||||
"options": {"url": "/pipeline-sdlc/api/task_io.dspy"},
|
"options": {"url": io_url},
|
||||||
},
|
},
|
||||||
"tree_width": "300px",
|
"tree_width": "300px",
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user