feat: 新增数字员工管理页面与工作台首页重构
后端优化 agent 资产种子初始化和常量配置,前端新增数字员工 视图和调度对话框组件,重构个人工作台首页布局和洞察面板, 完善审计页面数字员工详情和运行时模型,优化侧边栏导航和图 标配置,新增工作台摘要和工作台数据模块,补充单元测试。
This commit is contained in:
@@ -9,7 +9,6 @@ from app.core.agent_enums import (
|
||||
AgentAssetDomain,
|
||||
AgentAssetStatus,
|
||||
AgentAssetType,
|
||||
AgentName,
|
||||
AgentReviewStatus,
|
||||
)
|
||||
from app.core.logging import get_logger
|
||||
@@ -27,17 +26,46 @@ from app.services.agent_foundation_constants import (
|
||||
COMPANY_COMMUNICATION_RULE_VERSION,
|
||||
COMPANY_TRAVEL_RULE_SCENARIO_JSON,
|
||||
COMPANY_TRAVEL_RULE_VERSION,
|
||||
DIGITAL_EMPLOYEE_SKILL_CATEGORIES,
|
||||
DIGITAL_EMPLOYEE_TASK_CATEGORY_MAP,
|
||||
)
|
||||
|
||||
logger = get_logger("app.services.agent_foundation")
|
||||
|
||||
|
||||
class AgentFoundationAssetTopUpMixin:
|
||||
def _sync_digital_employee_skill_categories(self) -> None:
|
||||
category_options = list(DIGITAL_EMPLOYEE_SKILL_CATEGORIES)
|
||||
has_changes = False
|
||||
|
||||
for code, category in DIGITAL_EMPLOYEE_TASK_CATEGORY_MAP.items():
|
||||
asset = self.db.scalar(select(AgentAsset).where(AgentAsset.code == code))
|
||||
if asset is None:
|
||||
continue
|
||||
|
||||
config_json = dict(asset.config_json or {})
|
||||
changed = False
|
||||
if config_json.get("skill_category") != category:
|
||||
config_json["skill_category"] = category
|
||||
changed = True
|
||||
if config_json.get("skill_category_options") != category_options:
|
||||
config_json["skill_category_options"] = category_options
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
asset.config_json = config_json
|
||||
self.db.add(asset)
|
||||
has_changes = True
|
||||
|
||||
if has_changes:
|
||||
self.db.commit()
|
||||
|
||||
def _top_up_agent_assets(self, existing_codes: set[str]) -> None:
|
||||
|
||||
self._remove_legacy_rule_assets()
|
||||
|
||||
existing_codes = set(self.db.scalars(select(AgentAsset.code)).all())
|
||||
self._sync_digital_employee_skill_categories()
|
||||
|
||||
attachment_rule = self.db.scalar(
|
||||
select(AgentAsset).where(AgentAsset.code == ATTACHMENT_RULE_ASSET_CODE)
|
||||
@@ -557,18 +585,16 @@ class AgentFoundationAssetTopUpMixin:
|
||||
reviewer="顾承宇",
|
||||
status=AgentAssetStatus.ACTIVE.value,
|
||||
current_version="v1.0.0",
|
||||
config_json={"cron": "0 10 * * 1", "agent": AgentName.HERMES.value},
|
||||
config_json=self._digital_employee_task_config("task.hermes.weekly_ar_summary", "0 10 * * 1"),
|
||||
)
|
||||
|
||||
self._ensure_asset_version(
|
||||
asset,
|
||||
version="v1.0.0",
|
||||
content=self._json_content(
|
||||
{
|
||||
"task_type": "weekly_ar_summary",
|
||||
"schedule": "0 10 * * 1",
|
||||
"target_agent": AgentName.HERMES.value,
|
||||
}
|
||||
content=self._digital_employee_task_content(
|
||||
"task.hermes.weekly_ar_summary",
|
||||
"weekly_ar_summary",
|
||||
"0 10 * * 1",
|
||||
),
|
||||
content_type=AgentAssetContentType.JSON.value,
|
||||
change_note="初始化应收账龄汇总任务。",
|
||||
@@ -588,18 +614,16 @@ class AgentFoundationAssetTopUpMixin:
|
||||
reviewer="顾承宇",
|
||||
status=AgentAssetStatus.ACTIVE.value,
|
||||
current_version="v1.0.0",
|
||||
config_json={"cron": "0 18 * * *", "agent": AgentName.HERMES.value},
|
||||
config_json=self._digital_employee_task_config("task.hermes.rule_review_digest", "0 18 * * *"),
|
||||
)
|
||||
|
||||
self._ensure_asset_version(
|
||||
asset,
|
||||
version="v1.0.0",
|
||||
content=self._json_content(
|
||||
{
|
||||
"task_type": "rule_review_digest",
|
||||
"schedule": "0 18 * * *",
|
||||
"target_agent": AgentName.HERMES.value,
|
||||
}
|
||||
content=self._digital_employee_task_content(
|
||||
"task.hermes.rule_review_digest",
|
||||
"rule_review_digest",
|
||||
"0 18 * * *",
|
||||
),
|
||||
content_type=AgentAssetContentType.JSON.value,
|
||||
change_note="初始化规则待审摘要任务。",
|
||||
@@ -619,20 +643,18 @@ class AgentFoundationAssetTopUpMixin:
|
||||
reviewer="顾承宇",
|
||||
status=AgentAssetStatus.ACTIVE.value,
|
||||
current_version="v1.0.0",
|
||||
config_json={"cron": "0 0 * * *", "agent": AgentName.HERMES.value},
|
||||
config_json=self._digital_employee_task_config("task.hermes.knowledge_index_sync", "0 0 * * *"),
|
||||
)
|
||||
|
||||
self._ensure_asset_version(
|
||||
asset,
|
||||
version="v1.0.0",
|
||||
content=self._json_content(
|
||||
{
|
||||
"task_type": "knowledge_index_sync",
|
||||
"schedule": "0 0 * * *",
|
||||
"target_agent": AgentName.HERMES.value,
|
||||
"folder": "报销制度",
|
||||
"changed_only": True,
|
||||
}
|
||||
content=self._digital_employee_task_content(
|
||||
"task.hermes.knowledge_index_sync",
|
||||
"knowledge_index_sync",
|
||||
"0 0 * * *",
|
||||
folder="报销制度",
|
||||
changed_only=True,
|
||||
),
|
||||
content_type=AgentAssetContentType.JSON.value,
|
||||
change_note="初始化制度知识与规则草稿形成任务。",
|
||||
|
||||
Reference in New Issue
Block a user