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

@@ -33,6 +33,34 @@ const isShippingActionChoiceLine = (line: string) =>
const isPlainActionMenuLine = (line: string) =>
/^\s*(?:[-*]\s*)?(?:\*\*)?(?:确认|驳回|重新解析|更正映射|重新匹配|继续处理|重试当前步骤|选择库存文件|上传库存|粘贴库存)(?:\*\*)?\s*(?:[-—-::]|$)/.test(line);
/**
* 规范化运行态提示文案,隐藏“第几次重试/尝试”这类面对业务用户价值较低的过程指标。
*
* 核心逻辑:仅收敛库存 RPA 相关状态短语,保留“已触发 / 已重新触发 / 进行中”这些对下一步决策有帮助的状态,
* 不在前台暴露机械性的第 N 次计数。
*/
export function sanitizeShippingRuntimeStatusText(text: string): string {
return String(text || '')
.replace(
/已手动重新触发\s*RPA\s*库存导出\s*[((]\s*(?:手动第\s*\d+\s*次(?:尝试)?|第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?)\s*[))]\s*[。.]?/gi,
'已重新触发 RPA 库存导出。',
)
.replace(
/已触发\s*RPA\s*库存导出\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
'已触发 RPA 库存导出。',
)
.replace(
/RPA\s*库存导出进行中\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
'RPA 库存导出进行中。',
)
.replace(
/手动第\s*\d+\s*次尝试/gi,
'手动重试',
)
.replace(/\s+([。!?,])/g, '$1')
.trim();
}
/**
* 移除 Agent 正文里重复描述按钮的 1/2/3 编号动作列表。
*
@@ -141,12 +169,21 @@ export function stripShippingActionListByButtons(
text: string,
buttons: Array<Pick<ShippingActionButton, 'label' | 'message'>> | null | undefined,
): string {
const source = String(text || '');
let source = String(text || '');
const normalizedActions = (buttons || [])
.flatMap((button) => [button.label, button.message])
.map((item) => normalizeActionComparableText(String(item || '')))
.filter((item) => item.length >= 2);
if (!normalizedActions.length) return source;
const hasRetryRpaAction = normalizedActions.some((action) => /重试.*rpa|rpa.*重试|重试库存抓取|重试库存导出/.test(action));
const hasInventoryUploadAction = normalizedActions.some((action) => /选择库存文件|上传库存|库存excel|库存文件/.test(action));
if (hasRetryRpaAction && hasInventoryUploadAction) {
source = source
.replace(/若[^。.\n]*(?:无回调|没有回调|未回调|无落盘|没有落盘|无落盘文件)[^。.\n]*(?:手动)?(?:重试|重试\s*RPA)[^。.\n]*(?:上传库存|库存\s*Excel|库存文件)[^。.\n]*[。.]?/gi, '')
.replace(/可(?:手动)?(?:重试|重试\s*RPA)[^。.\n]*(?:上传库存|库存\s*Excel|库存文件)[^。.\n]*[。.]?/gi, '')
.replace(/\n{3,}/g, '\n\n')
.trim();
}
const lines = source.split('\n');
const remove = new Set<number>();
@@ -199,7 +236,7 @@ export function stripShippingActionListByButtons(
*/
export function sanitizeShippingConversationText(text: string, enabled: boolean): string {
if (!enabled) return text;
let result = String(text || '')
let result = sanitizeShippingRuntimeStatusText(String(text || ''))
.replace(
/已回到列映射步骤。?请根据\s*schema_preview\s*提供新的\s*map_json\s*[,,]\s*再调用\s*(?:应用库存字段映射|apply_inventory_mapping)[^。.\n]*[。.]?/gi,
'已回到库存字段确认步骤。请检查系统识别的库存列名,确认无误后继续;如有问题请修改映射。',