吸收数字员工入口路由策略下发

This commit is contained in:
baiyanyun
2026-06-11 17:44:16 +08:00
parent 43418d0453
commit d292c34579
16 changed files with 1195 additions and 190 deletions

View File

@@ -14,6 +14,7 @@ import {
pullApprovalUpdates,
pullPlanStepDispatchPolicy,
pullRiskApprovalPolicy,
pullRouteDecisionPolicy,
recordApprovalAction,
restartManagedService,
} from '@/lib/api';
@@ -1414,6 +1415,28 @@ export default function CommandDeck({ onNavigate }: { onNavigate: (target: Digit
}
}, [fetchProjection]);
const refreshRouteDecisionPolicy = useCallback(async () => {
setActionBusy('pull_route_decision_policy');
setActionError(null);
setActionNotice(null);
try {
const result = await pullRouteDecisionPolicy();
if (!mountedRef.current) return;
await fetchProjection();
if (!mountedRef.current) return;
const policy = result.policy;
setActionNotice(result.ok
? `入口路由策略已拉取:阻断 ${policy.blocked_intents.length} 类,审批 ${policy.approval_required_intents.length} 类。`
: `入口路由策略拉取失败,已沿用本地策略:${result.error || '未知错误'}`);
} catch (error) {
if (mountedRef.current) {
setActionError(error instanceof Error ? error.message : '拉取入口路由策略失败');
}
} finally {
if (mountedRef.current) setActionBusy(null);
}
}, [fetchProjection]);
const refreshApprovalUpdates = useCallback(async () => {
setActionBusy('pull_approval_updates');
setActionError(null);
@@ -2103,6 +2126,16 @@ export default function CommandDeck({ onNavigate }: { onNavigate: (target: Digit
<ShieldAlert size={13} aria-hidden="true" />
<span>{actionBusy === 'pull_risk_approval_policy' ? '拉取中...' : '风险策略'}</span>
</button>
<button
type="button"
className="de-btn-secondary de-btn-sm"
disabled={projectionLoading || actionBusy === 'pull_route_decision_policy'}
onClick={refreshRouteDecisionPolicy}
title="从管理端拉取入口路由策略"
>
<MessageSquare size={13} aria-hidden="true" />
<span>{actionBusy === 'pull_route_decision_policy' ? '拉取中...' : '路由策略'}</span>
</button>
<button
type="button"
className="de-btn-secondary de-btn-sm"
@@ -2325,7 +2358,13 @@ export default function CommandDeck({ onNavigate }: { onNavigate: (target: Digit
<span><em></em><strong>{routeSummary.total}</strong></span>
<span><em></em><strong>{routeSummary.mapped_count}</strong></span>
<span className={routeSummary.attention_count > 0 ? 'is-warning' : ''}><em></em><strong>{routeSummary.attention_count}</strong></span>
<small>{latestRoute ? `${latestRoute.route_kind} / ${latestRoute.intent_kind} · ${latestRoute.status_label}` : '暂无路由决策'}</small>
{(routeSummary.blocked_count ?? 0) > 0 && <span className="is-warning"><em></em><strong>{routeSummary.blocked_count}</strong></span>}
{(routeSummary.approval_required_count ?? 0) > 0 && <span className="is-warning"><em></em><strong>{routeSummary.approval_required_count}</strong></span>}
<small>
{latestRoute ? `${latestRoute.route_kind} / ${latestRoute.intent_kind} · ${latestRoute.status_label}` : '暂无路由决策'}
{routeSummary.policy_source ? ` · 策略${routeSummary.policy_source === 'remote' ? '远端' : '本地'}` : ''}
{routeSummary.policy_last_pull_error ? ` · 拉取失败` : ''}
</small>
</div>
)}