feat: 报销审批流重构与管家计划全链路贯通

- 重构报销状态注册表、审批流路由与平台风险标记
- 完善管家意图规划器与模型计划构建器全链路
- 新增 OCR Worker 脚本、数据库会话管理与通知状态
- 优化文档中心、日志视图、预算中心与员工管理交互
- 增强工作台摘要、图标资源与全局主题样式
- 补充审批路由、状态注册、OCR 服务与管家规划器测试覆盖
This commit is contained in:
caoxiaozhu
2026-06-06 17:19:07 +08:00
parent f60cebadb8
commit e124e4bbcb
162 changed files with 9161 additions and 1941 deletions

View File

@@ -106,6 +106,68 @@ def test_agent_run_service_updates_existing_tool_call() -> None:
assert fetched.tool_calls[0].response_json == {"track_id": "insert_123"}
def test_agent_run_list_uses_lightweight_preview_and_detail_keeps_full_payload() -> None:
with build_session() as db:
service = AgentRunService(db)
run = service.create_run(
agent=AgentName.HERMES.value,
source=AgentRunSource.SCHEDULE.value,
status=AgentRunStatus.SUCCEEDED.value,
ontology_json={
"scenario": "knowledge",
"intent": "sync",
"parse_strategy": "rule_fallback",
"model_invocation_summary": {"tokens": 999},
},
route_json={
"job_type": "knowledge_index_sync",
"phase": "indexing",
"progress": {
"percent": 50,
"total_documents": 2,
"completed_documents": 1,
"documents": [{"id": "doc-1", "text": "x" * 2000}],
},
"knowledge_ingest": {"documents": [{"id": "doc-1", "text": "x" * 2000}]},
},
)
service.record_tool_call(
run_id=run.run_id,
tool_type=AgentToolType.LLM.value,
tool_name="lightrag.index_documents",
request_json={"prompt": "x" * 2000},
response_json={"documents": [{"id": "doc-1", "text": "x" * 2000}]},
status="succeeded",
duration_ms=123,
)
listed = next(item for item in service.list_runs(limit=20) if item.run_id == run.run_id)
detail = service.get_run(run.run_id)
assert listed.ontology_json == {
"scenario": "knowledge",
"intent": "sync",
"parse_strategy": "rule_fallback",
}
assert listed.route_json["job_type"] == "knowledge_index_sync"
assert listed.route_json["phase"] == "indexing"
assert listed.route_json["progress"] == {
"percent": 50,
"total_documents": 2,
"completed_documents": 1,
}
assert "knowledge_ingest" not in listed.route_json
assert len(listed.tool_calls) == 1
assert listed.tool_calls[0].tool_name == "lightrag.index_documents"
assert listed.tool_calls[0].request_json == {}
assert listed.tool_calls[0].response_json == {}
assert detail is not None
assert "knowledge_ingest" in detail.route_json
assert detail.tool_calls[0].request_json["prompt"]
assert detail.tool_calls[0].response_json["documents"]
def test_agent_run_service_summarizes_model_and_tool_failures() -> None:
with build_session() as db:
service = AgentRunService(db)