refactor(agent-runtime, shipping-notice, frontend): 重构上下文体系,修复重试RPA无响应问题

- 替换原有的hxops_context模块为全新的代理运行时上下文平台协议,统一跨业务上下文注入逻辑
- 新增多语言操作繁忙提示文案(覆盖中、繁、英、泰四语),前端绑定页面繁忙状态实现操作阻断
- 调整RPA库存导出重试策略:移除可配置的最大自动重试次数,改为固定单次自动重试,手动重试需用户显式触发
- 优化任务用户态状态展示逻辑,优先展示具体的pending原因而非通用状态文案
- 重构任务焦点切换逻辑,统一事件日志与处理流程,复用switch_batch_focus工具函数
- 修复clearAllHistory函数残留UI问题,确保清空会话后完全复位发货通知相关视图
- 更新OpenAPI文档与静态快照,补充工具使用约束说明
- 新增调试打点日志与问题排查文档,完善全套单元测试与快照校验用例
- 更新RPA脚本的README文档,调整登录方式说明与浏览器 profile 路径配置
- 删除废弃的hxops_context模块,迁移所有相关调用到新的上下文体系
This commit is contained in:
hugo committed 2026-07-03 17:01:42 +08:00
1 parent 60dd0c0f58
commit 8846ce159f
102 files changed
+18289 -9072

No files matched your search

@@ -0,0 +1,75 @@
"""
backend/app/services/agent_runtime_context/schema.py
用途:定义 HXOPS 传递给外部 Agent Runtime 的统一上下文协议常量与类型。
依赖:typing 标准库;不依赖具体业务域,避免平台协议与 shipping/file-check 强耦合。
逻辑:builder/policy/parser 等模块引用本文件的字段名和类型,业务 adapter 只填充 refs/domain 差异。
"""
from __future__ import annotations
from typing import Any, Literal, TypedDict
AGENT_RUNTIME_CONTEXT_INPUT = "agent_runtime_context"
AGENT_RUNTIME_CONTEXT_SCHEMA_VERSION = "1"
AgentCode = Literal["generic", "shipping_notice", "file_check"]
ContextScope = Literal["chat_turn", "task_run", "batch_summary"]
class PlatformContext(TypedDict, total=False):
"""
描述 HXOPS 平台侧会话与请求锚点。
核心逻辑:只放平台身份与请求追踪字段,业务状态放入 refs/domain。
"""
session_id: str
parent_session_id: str
request_id: str
locale: str
trigger_source: str
class DomainContext(TypedDict, total=False):
"""
描述业务域运行态摘要。
核心逻辑:由各业务 adapter 填充 summary/state_hint,供 Dify 理解现场但不替代 HXOPS 状态机。
"""
type: str
summary: str
state_hint: dict[str, Any]
available_actions_hint: list[dict[str, Any]]
class ReferenceContext(TypedDict, total=False):
"""
描述模糊指代解析所需的短期上下文。
核心逻辑:承载 recent_activity_summary/focus_object 等摘要,不传全量 ChatLog。
"""
recent_activity_summary: str
focus_object: dict[str, Any]
last_action_target: dict[str, Any]
last_failed_target: dict[str, Any]
candidates: list[dict[str, Any]]
class AgentRuntimeContext(TypedDict, total=False):
"""
HXOPS Agent Runtime Context 协议对象。
核心逻辑:每次调用外部 Runtime 前重新生成 snapshot,Dify/其他 Runtime 只读取,不作为业务事实源。
"""
schema_version: str
context_id: str
agent_code: str
scope: str
platform: PlatformContext
refs: dict[str, str]
domain: DomainContext
reference_context: ReferenceContext