2629 lines
100 KiB
React
2629 lines
100 KiB
React
/*
|
||
Copyright (C) 2025 QuantumNous
|
||
|
||
This program is free software: you can redistribute it and/or modify
|
||
it under the terms of the GNU Affero General Public License as
|
||
published by the Free Software Foundation, either version 3 of the
|
||
License, or (at your option) any later version.
|
||
|
||
This program is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
GNU Affero General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Affero General Public License
|
||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
For commercial licensing, please contact support@quantumnous.com
|
||
*/
|
||
|
||
import { ConsolePageActions } from '../../components/console/ConsolePageContainer';
|
||
import React, {
|
||
useCallback,
|
||
useEffect,
|
||
useMemo,
|
||
useRef,
|
||
useState,
|
||
} from 'react';
|
||
import {
|
||
Banner,
|
||
Button,
|
||
Collapse,
|
||
Input,
|
||
InputNumber,
|
||
Modal,
|
||
Select,
|
||
Skeleton,
|
||
Switch,
|
||
TabPane,
|
||
Tabs,
|
||
Tag,
|
||
TextArea,
|
||
Toast,
|
||
Typography,
|
||
} from '@/components/ui';
|
||
import {
|
||
Activity,
|
||
BadgeCheck,
|
||
Bot,
|
||
Cpu,
|
||
Plus,
|
||
RefreshCw,
|
||
Scale,
|
||
ShieldCheck,
|
||
} from 'lucide-react';
|
||
import { useTranslation } from 'react-i18next';
|
||
import { API, isRoot, showError } from '../../helpers';
|
||
import './expert-platform.css';
|
||
|
||
const { Text } = Typography;
|
||
|
||
// 与后端 expertKeyPattern 逐字一致:必须以小写字母开头(专家标识与步骤
|
||
// 标识共用同一正则)
|
||
const keyPattern = /^[a-z][a-z0-9_-]{2,63}$/;
|
||
|
||
const csvList = (value) =>
|
||
String(value || '')
|
||
.split(/[,,]/)
|
||
.map((item) => item.trim())
|
||
.filter(Boolean);
|
||
|
||
// 傻瓜式核心:英文文案留空时自动复用中文(后端要求双语非空)
|
||
const orZh = (en, zh) => (String(en || '').trim() ? String(en).trim() : zh);
|
||
|
||
// 专家自检的检查项标签与阻断结论。detail 里带数字的两项(技能数、候选模型数)
|
||
// 由前端自己拼,后端只给计数——否则英文用户会看到后端拼好的中文句子。
|
||
const diagnoseCheckLabels = {
|
||
version_status: '版本状态',
|
||
output_contract: '输出契约',
|
||
step_plan: '步骤计划',
|
||
skills: '审核技能',
|
||
model_sequence: '模型候选',
|
||
};
|
||
|
||
const diagnoseBlockingHints = {
|
||
no_available_model:
|
||
'没有任何候选模型可派发:请在「模型能力」里登记满足该专家输出上限的渠道。',
|
||
not_published: '该版本尚未发布,成员在专家广场看不到它。',
|
||
invalid_output_contract:
|
||
'输出契约不是合法 JSON,任务会以 invalid_snapshot 失败。',
|
||
};
|
||
|
||
const diagnoseCheckDetail = (check, diagnosis, t) => {
|
||
if (check.key === 'skills')
|
||
return t('已绑定 {{count}} 个已发布技能', {
|
||
count: diagnosis.skill_count || 0,
|
||
});
|
||
if (check.key === 'model_sequence')
|
||
return t('分组 {{group}} 下有 {{count}} 个候选模型', {
|
||
group: diagnosis.group || 'default',
|
||
count: diagnosis.candidate_count || 0,
|
||
});
|
||
return check.detail ? t(check.detail) : '';
|
||
};
|
||
|
||
// 版本按号倒序:最新版本永远排在最前(列表与「编辑」取基线共用一套顺序)
|
||
const sortVersionsDesc = (list) =>
|
||
[...(list || [])].sort((a, b) => (b.version || 0) - (a.version || 0));
|
||
|
||
// 后端只允许发布 draft/pending_review,被取代的版本会 422
|
||
const publishableVersions = (list) =>
|
||
sortVersionsDesc(list).filter(
|
||
(item) => item.status === 'draft' || item.status === 'pending_review',
|
||
);
|
||
|
||
const publishedVersions = (list) =>
|
||
sortVersionsDesc(list).filter((item) => item.status === 'published');
|
||
|
||
// 版本历史条:只读徽章,不再带行内按钮——所有动作统一收到卡片底部的
|
||
// 单行动作区,否则「编辑」与「紧急停用」会被拆成上下两行。
|
||
const VersionStrip = ({ versions, labelOf, max = 6 }) => {
|
||
const sorted = sortVersionsDesc(versions);
|
||
if (sorted.length === 0) return null;
|
||
const rest = sorted.length - max;
|
||
return (
|
||
<div className='expert-version-strip'>
|
||
{sorted.slice(0, max).map((version) => (
|
||
<span
|
||
key={version.id}
|
||
className='expert-version-chip'
|
||
title={`v${version.version} · ${labelOf(version)}`}
|
||
>
|
||
<i aria-hidden='true' className={`expert-dot is-${version.status}`} />
|
||
<b>v{version.version}</b>
|
||
<span>{labelOf(version)}</span>
|
||
</span>
|
||
))}
|
||
{rest > 0 && <span className='expert-version-chip is-more'>+{rest}</span>}
|
||
</div>
|
||
);
|
||
};
|
||
|
||
const parseJsonArray = (raw) => {
|
||
try {
|
||
const parsed = JSON.parse(raw || '[]');
|
||
return Array.isArray(parsed) ? parsed : [];
|
||
} catch {
|
||
return [];
|
||
}
|
||
};
|
||
|
||
const parseJsonObject = (raw) => {
|
||
try {
|
||
const parsed = JSON.parse(raw || '{}');
|
||
return parsed && typeof parsed === 'object' ? parsed : {};
|
||
} catch {
|
||
return {};
|
||
}
|
||
};
|
||
|
||
const DEFAULT_INPUT_SCHEMA = JSON.stringify(
|
||
{
|
||
type: 'object',
|
||
properties: { task: { type: 'string' } },
|
||
required: ['task'],
|
||
},
|
||
null,
|
||
2,
|
||
);
|
||
|
||
// uid 仅作 React key(值受控,index key 会让删除中间步骤时焦点/IME 落错卡片)
|
||
const newStep = () => ({
|
||
uid: Math.random().toString(36).slice(2, 10),
|
||
key: '',
|
||
name_zh: '',
|
||
name_en: '',
|
||
instruction_zh: '',
|
||
instruction_en: '',
|
||
max_output_tokens: 0,
|
||
});
|
||
|
||
const defaultSteps = () => [
|
||
{
|
||
...newStep(),
|
||
key: 'primary',
|
||
name_zh: '生成交付物',
|
||
instruction_zh: '根据任务生成最终交付物。',
|
||
},
|
||
];
|
||
|
||
const emptyForm = () => ({
|
||
expert_key: '',
|
||
name_zh: '',
|
||
name_en: '',
|
||
description_zh: '',
|
||
description_en: '',
|
||
scenario_zh: '',
|
||
scenario_en: '',
|
||
system_prompt_zh: '',
|
||
system_prompt_en: '',
|
||
default_model: '',
|
||
fallback_models: [],
|
||
required_sections_zh: '结论',
|
||
required_sections_en: '',
|
||
// 表单不暴露但迭代旧版本时必须原样保留的契约字段(否则编辑一次就被
|
||
// 静默重置成 markdown/[])
|
||
contract_type: 'markdown',
|
||
required_table_columns: [],
|
||
forbidden_placeholders: 'TODO',
|
||
require_citations: false,
|
||
repair_once: true,
|
||
artifact_mode: 'inline',
|
||
file_name: '',
|
||
content_type: '',
|
||
max_output_tokens: 2048,
|
||
max_total_output_tokens: 4096,
|
||
max_step_quota: 100000,
|
||
max_task_quota: 200000,
|
||
default_language: 'zh',
|
||
safety_policy_ref: 'platform-default',
|
||
input_schema: DEFAULT_INPUT_SCHEMA,
|
||
});
|
||
|
||
// 后端校验失败返回英文 err.Error();前端预检拦不住的路径(高级 JSON、
|
||
// 竞态下能力被撤)按子串映射成中文,兜底显示原文
|
||
const expertErrorPatterns = [
|
||
[
|
||
'no registered channel capability',
|
||
'有模型缺少已登记的渠道能力,请先在「登记模型能力」完成登记',
|
||
],
|
||
[
|
||
'no verified channel satisfying',
|
||
'已验证渠道不满足该专家的输出或上下文要求,请调低单步输出上限或更新渠道能力登记',
|
||
],
|
||
['at least one approved Skill', '平台专家至少需要绑定一个已审核 Skill'],
|
||
['expert key is immutable', '专家标识不可修改,如需更换请新建专家'],
|
||
['aligned zh/en sections', '中英文必含章节数量必须一致'],
|
||
[
|
||
'expert_key must contain',
|
||
'专家标识需以小写字母开头,3~64 位小写字母、数字、下划线或连字符',
|
||
],
|
||
['step_plan item', '步骤配置无效:步骤标识需以小写字母开头且不重复'],
|
||
[
|
||
'output_contract contains an invalid item',
|
||
'必含章节或占位词有空项或超过 128 字',
|
||
],
|
||
['is unavailable or forbidden', '绑定的 Skill 已不可用,请刷新后重新选择'],
|
||
['unavailable for publishing', '该版本状态已变化,无法发布,请刷新后重试'],
|
||
];
|
||
const localizeExpertError = (message) => {
|
||
const raw = String(message || '');
|
||
const hit = expertErrorPatterns.find(([needle]) => raw.includes(needle));
|
||
return hit ? hit[1] : raw;
|
||
};
|
||
|
||
// 版本状态中文化:员工/管理员都不该读英文裸枚举
|
||
const versionStatusMeta = {
|
||
draft: { label: '草稿', color: 'orange' },
|
||
pending_review: { label: '待审核', color: 'orange' },
|
||
published: { label: '已发布', color: 'green' },
|
||
superseded: { label: '已被取代', color: 'grey' },
|
||
revoked: { label: '已停用', color: 'red' },
|
||
};
|
||
|
||
// 对账案件状态:后端返回英文枚举,界面统一转中文(禁止英文直显)
|
||
const reconciliationStatusMeta = {
|
||
pending: { label: '待核对' },
|
||
manual: { label: '待人工处置' },
|
||
resolved: { label: '已结案' },
|
||
expired: { label: '已过期' },
|
||
};
|
||
|
||
const emptyCapability = (modelName = '') => ({
|
||
channel_id: 0,
|
||
model_name: modelName,
|
||
supports_tools: false,
|
||
context_window: 131072,
|
||
max_output_tokens: 8192,
|
||
tokenizer: '',
|
||
data_region: '',
|
||
embedding_space_id: 0,
|
||
});
|
||
|
||
const ExpertPlatform = () => {
|
||
const { t } = useTranslation();
|
||
const [experts, setExperts] = useState([]);
|
||
const [organizationReviews, setOrganizationReviews] = useState([]);
|
||
const [skills, setSkills] = useState([]);
|
||
const [capabilities, setCapabilities] = useState([]);
|
||
const [channels, setChannels] = useState([]);
|
||
const [enabledModels, setEnabledModels] = useState([]);
|
||
const [reconciliations, setReconciliations] = useState([]);
|
||
const [reconciliationRunBilling, setReconciliationRunBilling] = useState({});
|
||
const [deliveryHealth, setDeliveryHealth] = useState(null);
|
||
// 首屏骨架 + 可读的中文错误态(原来失败是整页空白 + 未捕获的 Promise)
|
||
const [loading, setLoading] = useState(true);
|
||
const [loadError, setLoadError] = useState('');
|
||
|
||
const [editorOpen, setEditorOpen] = useState(false);
|
||
const [editorSaving, setEditorSaving] = useState(false);
|
||
const [editorMeta, setEditorMeta] = useState({
|
||
definitionId: 0,
|
||
baseLabel: '',
|
||
});
|
||
const [form, setForm] = useState(emptyForm());
|
||
const [steps, setSteps] = useState(defaultSteps());
|
||
const [selectedSkills, setSelectedSkills] = useState([]);
|
||
const [advanced, setAdvanced] = useState(false);
|
||
const [payload, setPayload] = useState('');
|
||
|
||
// 自检/实测都是慢请求(实测最长 45 秒)。管理员在等待期间换一张卡片再点
|
||
// 「测试」时,先发的响应可能后到——没有这道代次守卫,A 的自检结论会落进
|
||
// B 的弹窗,管理员会照着错的专家去登记模型能力。
|
||
const diagnoseRequestRef = useRef(0);
|
||
const [diagnoseOpen, setDiagnoseOpen] = useState(false);
|
||
const [diagnoseTarget, setDiagnoseTarget] = useState(null);
|
||
const [diagnoseLoading, setDiagnoseLoading] = useState(false);
|
||
const [diagnosis, setDiagnosis] = useState(null);
|
||
const [connectivity, setConnectivity] = useState(null);
|
||
const [connectivityLoading, setConnectivityLoading] = useState(false);
|
||
const [capabilityOpen, setCapabilityOpen] = useState(false);
|
||
const [capabilitySaving, setCapabilitySaving] = useState(false);
|
||
const [capLockChannel, setCapLockChannel] = useState(false);
|
||
const [capForm, setCapForm] = useState(emptyCapability());
|
||
|
||
const [reconciliationOpen, setReconciliationOpen] = useState(false);
|
||
const [resolutionMode, setResolutionMode] = useState('resolve');
|
||
const [selectedCase, setSelectedCase] = useState(null);
|
||
const [resolution, setResolution] = useState({
|
||
actual_quota: 0,
|
||
resolution_type: 'provider_confirmed',
|
||
reason: '',
|
||
});
|
||
const [replayTarget, setReplayTarget] = useState(null);
|
||
const [replayReason, setReplayReason] = useState('');
|
||
|
||
// 主数据拉取。5 条主请求带 skipErrorHandler:错误由页面自己转成中文
|
||
// 错误态(全局拦截器直接弹的是后端英文 message)。
|
||
const fetchAll = useCallback(async () => {
|
||
const primary = { skipErrorHandler: true };
|
||
const [
|
||
expertResponse,
|
||
organizationReviewResponse,
|
||
skillResponse,
|
||
capabilityResponse,
|
||
reconciliationResponse,
|
||
operationsResponse,
|
||
channelResponse,
|
||
enabledResponse,
|
||
] = await Promise.all([
|
||
API.get('/api/skill-platform/experts', primary),
|
||
API.get('/api/skill-platform/experts/review-queue', primary),
|
||
API.get('/api/skill-platform/expert-skills', primary),
|
||
API.get('/api/skill-platform/model-capabilities', primary),
|
||
API.get('/api/skill-platform/reconciliation', primary),
|
||
API.get('/api/skill-platform/operations/outbox').catch(() => null),
|
||
// 渠道与全局模型清单只服务下拉选择;拉取失败页面仍可用(可手输)
|
||
API.get('/api/channel/?p=1&page_size=100&status=1&id_sort=true').catch(
|
||
() => null,
|
||
),
|
||
API.get('/api/channel/models_enabled').catch(() => null),
|
||
]);
|
||
if (expertResponse.data?.success)
|
||
setExperts(expertResponse.data.data || []);
|
||
if (organizationReviewResponse.data?.success)
|
||
setOrganizationReviews(organizationReviewResponse.data.data || []);
|
||
if (skillResponse.data?.success) setSkills(skillResponse.data.data || []);
|
||
if (capabilityResponse.data?.success)
|
||
setCapabilities(capabilityResponse.data.data || []);
|
||
if (reconciliationResponse.data?.success) {
|
||
setReconciliations(reconciliationResponse.data.data || []);
|
||
setReconciliationRunBilling(
|
||
reconciliationResponse.data.run_billing || {},
|
||
);
|
||
}
|
||
if (operationsResponse?.data?.success)
|
||
setDeliveryHealth(operationsResponse.data.data || null);
|
||
if (channelResponse?.data?.success)
|
||
setChannels(channelResponse.data.data?.items || []);
|
||
if (enabledResponse?.data?.success)
|
||
setEnabledModels(enabledResponse.data.data || []);
|
||
// 主请求 success:false 也算失败:否则页面会安静地停在空白卡片区
|
||
const rejected = [
|
||
expertResponse,
|
||
organizationReviewResponse,
|
||
skillResponse,
|
||
capabilityResponse,
|
||
reconciliationResponse,
|
||
].find((response) => !response?.data?.success);
|
||
if (rejected) throw new Error(rejected?.data?.message || '');
|
||
}, []);
|
||
|
||
const load = useCallback(
|
||
async ({ silent = false } = {}) => {
|
||
if (!silent) setLoading(true);
|
||
try {
|
||
await fetchAll();
|
||
setLoadError('');
|
||
} catch (error) {
|
||
// 401 必须交回 showError:那里是全局唯一的「清会话 + 跳 /org/login」
|
||
// 路径。页面自己把它兜成错误态,等于把过期会话变成永远刷不出来的死页
|
||
// (重试按钮每次都 401),文案还会把原因误导成网络问题。
|
||
if (error?.response?.status === 401) {
|
||
showError(error);
|
||
return;
|
||
}
|
||
// skipErrorHandler 同时也跳过了 showError 里的 console.error,
|
||
// 失败路径要自己留一条排障线索。
|
||
console.error('[expert-platform] 主数据加载失败', error);
|
||
const detail = error?.response?.data?.message || error?.message || '';
|
||
setLoadError(detail);
|
||
} finally {
|
||
setLoading(false);
|
||
}
|
||
},
|
||
[fetchAll],
|
||
);
|
||
|
||
useEffect(() => {
|
||
void load();
|
||
}, [load]);
|
||
|
||
const verifiedByModel = useMemo(() => {
|
||
const counts = {};
|
||
capabilities.forEach((item) => {
|
||
if (item.status !== 'verified') return;
|
||
counts[item.model_name] = (counts[item.model_name] || 0) + 1;
|
||
});
|
||
return counts;
|
||
}, [capabilities]);
|
||
|
||
// 顶部概览:全部由已拉取的数据派生,不额外发请求
|
||
const pendingReconciliations = useMemo(
|
||
() =>
|
||
reconciliations.filter(
|
||
(item) => item.status === 'pending' || item.status === 'manual',
|
||
).length,
|
||
[reconciliations],
|
||
);
|
||
const pendingOrgReviews = useMemo(
|
||
() =>
|
||
organizationReviews.reduce(
|
||
(sum, view) =>
|
||
sum +
|
||
(view.versions || []).filter(
|
||
(version) => version.status === 'pending_review',
|
||
).length,
|
||
0,
|
||
),
|
||
[organizationReviews],
|
||
);
|
||
const publishedExperts = useMemo(
|
||
() =>
|
||
experts.filter((view) => view.definition.status === 'published').length,
|
||
[experts],
|
||
);
|
||
const verifiedCapabilities = useMemo(
|
||
() => capabilities.filter((item) => item.status === 'verified').length,
|
||
[capabilities],
|
||
);
|
||
const deadLetterTotal = useMemo(
|
||
() =>
|
||
(deliveryHealth?.topics || []).reduce(
|
||
(sum, topic) => sum + (topic.dead_letter || 0),
|
||
0,
|
||
),
|
||
[deliveryHealth],
|
||
);
|
||
|
||
const modelOptions = useMemo(() => {
|
||
const names = new Set(enabledModels);
|
||
capabilities.forEach((item) => names.add(item.model_name));
|
||
return [...names].sort().map((name) => ({
|
||
value: name,
|
||
label: verifiedByModel[name]
|
||
? `${name} · ${t('{{count}} 渠道已验证', { count: verifiedByModel[name] })}`
|
||
: `${name} · ${t('未登记渠道能力')}`,
|
||
}));
|
||
}, [capabilities, enabledModels, verifiedByModel, t]);
|
||
|
||
const update = (key, value) =>
|
||
setForm((current) => ({ ...current, [key]: value }));
|
||
const updateStep = (index, key, value) =>
|
||
setSteps((current) =>
|
||
current.map((step, i) =>
|
||
i === index ? { ...step, [key]: value } : step,
|
||
),
|
||
);
|
||
|
||
// 后端 validateBrainModelCapabilities 的完整条件:每个模型(默认+降级)
|
||
// 都要有 verified 且 context_window > 专家输出上限、能力 max_output 为 0
|
||
// 或 ≥ 专家输出上限的渠道。预检必须镜像全部维度,否则放行后是英文 422。
|
||
const capabilityUsable = useCallback(
|
||
(name, maxOutput) =>
|
||
capabilities.some(
|
||
(item) =>
|
||
item.model_name === name &&
|
||
item.status === 'verified' &&
|
||
(item.verified_at || 0) > 0 &&
|
||
item.context_window > maxOutput &&
|
||
(!item.max_output_tokens || item.max_output_tokens >= maxOutput),
|
||
),
|
||
[capabilities],
|
||
);
|
||
const editorModels = [form.default_model, ...(form.fallback_models || [])]
|
||
.map((name) => String(name || '').trim())
|
||
.filter(Boolean);
|
||
const editorMissingModels = editorModels.filter(
|
||
(name) => !capabilityUsable(name, Number(form.max_output_tokens) || 2048),
|
||
);
|
||
|
||
// 组装请求体:表单 → SaveBrainExpertVersionRequest。所有可留空项在这里
|
||
// 填默认值/复用中文,限额自动抬升到后端校验能通过的最小合法值。
|
||
const assembleRequest = () => {
|
||
const maxOutput = Number(form.max_output_tokens) || 2048;
|
||
const stepQuota = Number(form.max_step_quota) || 100000;
|
||
const usedKeys = new Set();
|
||
const stepPlan = steps.map((step, index) => {
|
||
let key = String(step.key || '').trim();
|
||
if (!keyPattern.test(key) || usedKeys.has(key)) {
|
||
// 自动生成的替换 key 也要回查去重:历史版本可能已占用 step-N 字面量
|
||
let counter = index + 1;
|
||
key = `step-${counter}`;
|
||
while (usedKeys.has(key)) {
|
||
counter += 1;
|
||
key = `step-${counter}`;
|
||
}
|
||
}
|
||
usedKeys.add(key);
|
||
const nameZh =
|
||
String(step.name_zh || '').trim() || `${t('步骤')} ${index + 1}`;
|
||
const instructionZh = String(step.instruction_zh || '').trim();
|
||
const stepTokens = Number(step.max_output_tokens) || 0;
|
||
return {
|
||
key,
|
||
name_zh: nameZh,
|
||
name_en: orZh(step.name_en, nameZh),
|
||
instruction_zh: instructionZh,
|
||
instruction_en: orZh(step.instruction_en, instructionZh),
|
||
max_output_tokens: stepTokens > 0 ? stepTokens : maxOutput,
|
||
};
|
||
});
|
||
const sectionsZh = csvList(form.required_sections_zh);
|
||
const sectionsEn = csvList(form.required_sections_en);
|
||
const finalSectionsZh = sectionsZh.length ? sectionsZh : ['结论'];
|
||
let inputSchema;
|
||
try {
|
||
inputSchema = JSON.parse(form.input_schema);
|
||
} catch {
|
||
inputSchema = JSON.parse(DEFAULT_INPUT_SCHEMA);
|
||
}
|
||
return {
|
||
definition_id: editorMeta.definitionId || 0,
|
||
expert_key: String(form.expert_key || '')
|
||
.trim()
|
||
.toLowerCase(),
|
||
name_zh: String(form.name_zh || '').trim(),
|
||
name_en: orZh(form.name_en, String(form.name_zh || '').trim()),
|
||
description_zh: String(form.description_zh || '').trim(),
|
||
description_en: orZh(
|
||
form.description_en,
|
||
String(form.description_zh || '').trim(),
|
||
),
|
||
scenario_zh: String(form.scenario_zh || '').trim(),
|
||
scenario_en: orZh(
|
||
form.scenario_en,
|
||
String(form.scenario_zh || '').trim(),
|
||
),
|
||
system_prompt_zh: String(form.system_prompt_zh || '').trim(),
|
||
system_prompt_en: orZh(
|
||
form.system_prompt_en,
|
||
String(form.system_prompt_zh || '').trim(),
|
||
),
|
||
default_model: String(form.default_model || '').trim(),
|
||
fallback_models: (form.fallback_models || []).filter(Boolean),
|
||
input_schema: inputSchema,
|
||
output_contract: {
|
||
type: form.contract_type || 'markdown',
|
||
required_sections_zh: finalSectionsZh,
|
||
required_sections_en: sectionsEn.length ? sectionsEn : finalSectionsZh,
|
||
required_table_columns: Array.isArray(form.required_table_columns)
|
||
? form.required_table_columns
|
||
: [],
|
||
require_citations: Boolean(form.require_citations),
|
||
forbidden_placeholders: csvList(form.forbidden_placeholders),
|
||
repair_once: form.repair_once !== false,
|
||
artifact_mode: form.artifact_mode || 'inline',
|
||
file_name: form.artifact_mode === 'file' ? form.file_name : '',
|
||
content_type: form.artifact_mode === 'file' ? form.content_type : '',
|
||
},
|
||
step_plan: stepPlan,
|
||
max_output_tokens: maxOutput,
|
||
max_total_output_tokens: Math.max(
|
||
Number(form.max_total_output_tokens) || 0,
|
||
maxOutput,
|
||
),
|
||
max_step_quota: stepQuota,
|
||
max_task_quota: Math.max(
|
||
Number(form.max_task_quota) || 0,
|
||
stepPlan.length * stepQuota,
|
||
),
|
||
default_language: form.default_language === 'en' ? 'en' : 'zh',
|
||
safety_policy_ref:
|
||
String(form.safety_policy_ref || '').trim() || 'platform-default',
|
||
skill_ids: selectedSkills,
|
||
};
|
||
};
|
||
|
||
// 前端预检:镜像后端硬校验,把英文报错换成到字段的中文指引
|
||
const validateForm = () => {
|
||
if (
|
||
!keyPattern.test(
|
||
String(form.expert_key || '')
|
||
.trim()
|
||
.toLowerCase(),
|
||
)
|
||
)
|
||
return t(
|
||
'专家标识需以小写字母开头,3~64 位小写字母、数字、下划线或连字符',
|
||
);
|
||
if (!String(form.name_zh || '').trim()) return t('请填写中文名称');
|
||
if (!String(form.description_zh || '').trim()) return t('请填写中文描述');
|
||
if (!String(form.scenario_zh || '').trim()) return t('请填写适用场景');
|
||
if (!String(form.system_prompt_zh || '').trim())
|
||
return t('请填写系统提示词');
|
||
if (
|
||
[...String(form.system_prompt_zh || '')].length > 6000 ||
|
||
[...String(form.system_prompt_en || '')].length > 6000
|
||
)
|
||
return t('系统提示词不能超过 6000 字');
|
||
if (!String(form.default_model || '').trim()) return t('请选择默认模型');
|
||
const maxOutput = Number(form.max_output_tokens) || 0;
|
||
if (maxOutput <= 0 || maxOutput > 65536)
|
||
return t('单步输出上限需在 1~65536 之间');
|
||
if ((Number(form.max_step_quota) || 0) <= 0)
|
||
return t('单步额度上限必须大于 0');
|
||
// 镜像后端 validateBrainInputSchema:object + 1~50 个属性
|
||
try {
|
||
const schema = JSON.parse(form.input_schema);
|
||
const properties =
|
||
schema && schema.type === 'object' ? schema.properties : null;
|
||
const propertyCount =
|
||
properties && typeof properties === 'object'
|
||
? Object.keys(properties).length
|
||
: 0;
|
||
if (propertyCount === 0 || propertyCount > 50)
|
||
return t('输入 Schema 需为 object 且定义 1~50 个属性');
|
||
} catch {
|
||
return t('输入 Schema 必须是合法 JSON');
|
||
}
|
||
if (steps.length > 12) return t('步骤计划最多 12 步');
|
||
for (let index = 0; index < steps.length; index += 1) {
|
||
if (!String(steps[index].instruction_zh || '').trim())
|
||
return t('第 {{n}} 步缺少执行指令', { n: index + 1 });
|
||
const stepTokens = Number(steps[index].max_output_tokens) || 0;
|
||
if (stepTokens > maxOutput)
|
||
return t('第 {{n}} 步输出上限超过专家上限', { n: index + 1 });
|
||
}
|
||
// 后端硬校验:平台专家至少绑定一个已审核 Skill;章节数量/长度限制
|
||
if (selectedSkills.length === 0)
|
||
return t('平台专家至少需要绑定一个已审核 Skill');
|
||
const sectionsZhList = csvList(form.required_sections_zh);
|
||
const sectionsEnList = csvList(form.required_sections_en);
|
||
if (sectionsZhList.length > 30) return t('必含章节最多 30 条');
|
||
if (
|
||
[
|
||
...sectionsZhList,
|
||
...sectionsEnList,
|
||
...csvList(form.forbidden_placeholders),
|
||
].some((item) => [...item].length > 128)
|
||
)
|
||
return t('章节与占位词单项不能超过 128 字');
|
||
if (
|
||
sectionsEnList.length > 0 &&
|
||
sectionsEnList.length !== (sectionsZhList.length || 1)
|
||
)
|
||
return t('中英文必含章节数量必须一致');
|
||
return null;
|
||
};
|
||
|
||
const hydrateFromRequest = (parsed) => {
|
||
const contract = parsed.output_contract || {};
|
||
setForm({
|
||
expert_key: parsed.expert_key || '',
|
||
name_zh: parsed.name_zh || '',
|
||
name_en: parsed.name_en || '',
|
||
description_zh: parsed.description_zh || '',
|
||
description_en: parsed.description_en || '',
|
||
scenario_zh: parsed.scenario_zh || '',
|
||
scenario_en: parsed.scenario_en || '',
|
||
system_prompt_zh: parsed.system_prompt_zh || '',
|
||
system_prompt_en: parsed.system_prompt_en || '',
|
||
default_model: parsed.default_model || '',
|
||
fallback_models: Array.isArray(parsed.fallback_models)
|
||
? parsed.fallback_models
|
||
: [],
|
||
required_sections_zh: (contract.required_sections_zh || []).join(', '),
|
||
required_sections_en: (contract.required_sections_en || []).join(', '),
|
||
forbidden_placeholders: (contract.forbidden_placeholders || []).join(
|
||
', ',
|
||
),
|
||
require_citations: Boolean(contract.require_citations),
|
||
repair_once: contract.repair_once !== false,
|
||
contract_type: contract.type || 'markdown',
|
||
required_table_columns: Array.isArray(contract.required_table_columns)
|
||
? contract.required_table_columns
|
||
: [],
|
||
artifact_mode: contract.artifact_mode || 'inline',
|
||
file_name: contract.file_name || '',
|
||
content_type: contract.content_type || '',
|
||
max_output_tokens: parsed.max_output_tokens || 2048,
|
||
max_total_output_tokens: parsed.max_total_output_tokens || 4096,
|
||
max_step_quota: parsed.max_step_quota || 100000,
|
||
max_task_quota: parsed.max_task_quota || 200000,
|
||
default_language: parsed.default_language === 'en' ? 'en' : 'zh',
|
||
safety_policy_ref: parsed.safety_policy_ref || 'platform-default',
|
||
input_schema: JSON.stringify(
|
||
parsed.input_schema || JSON.parse(DEFAULT_INPUT_SCHEMA),
|
||
null,
|
||
2,
|
||
),
|
||
});
|
||
const stepPlan = Array.isArray(parsed.step_plan) ? parsed.step_plan : [];
|
||
setSteps(
|
||
stepPlan.length
|
||
? stepPlan.map((step) => ({
|
||
...newStep(),
|
||
key: step.key || '',
|
||
name_zh: step.name_zh || '',
|
||
name_en: step.name_en || '',
|
||
instruction_zh: step.instruction_zh || '',
|
||
instruction_en: step.instruction_en || '',
|
||
max_output_tokens: step.max_output_tokens || 0,
|
||
}))
|
||
: defaultSteps(),
|
||
);
|
||
if (Array.isArray(parsed.skill_ids)) setSelectedSkills(parsed.skill_ids);
|
||
};
|
||
|
||
const toggleAdvanced = () => {
|
||
if (!advanced) {
|
||
setPayload(JSON.stringify(assembleRequest(), null, 2));
|
||
setAdvanced(true);
|
||
return;
|
||
}
|
||
try {
|
||
hydrateFromRequest(JSON.parse(payload));
|
||
setAdvanced(false);
|
||
} catch {
|
||
Toast.error(t('JSON 无法解析,已保留原文'));
|
||
}
|
||
};
|
||
|
||
const openCreate = () => {
|
||
setEditorMeta({ definitionId: 0, baseLabel: '' });
|
||
setForm(emptyForm());
|
||
setSteps(defaultSteps());
|
||
setSelectedSkills([]);
|
||
setAdvanced(false);
|
||
setEditorOpen(true);
|
||
};
|
||
|
||
const openIterate = async (view) => {
|
||
const versions = [...(view.versions || [])].sort(
|
||
(a, b) => b.version - a.version,
|
||
);
|
||
// 「编辑」从最新版本续写(含未发布草稿),而不是从线上版本另起——
|
||
// 否则存过草稿再进来会丢上次的修改
|
||
const base = versions[0] || view.current;
|
||
if (!base) {
|
||
// 定义存在但一个版本都没有:保住 definition_id 与 expert_key,
|
||
// 否则会与 (organization_id, expert_key) 唯一索引冲突
|
||
setEditorMeta({ definitionId: view.definition.id, baseLabel: '' });
|
||
setForm({ ...emptyForm(), expert_key: view.definition.expert_key });
|
||
setSteps(defaultSteps());
|
||
setSelectedSkills([]);
|
||
setAdvanced(false);
|
||
setEditorOpen(true);
|
||
return;
|
||
}
|
||
try {
|
||
const response = await API.get(
|
||
`/api/skill-platform/experts/versions/${base.id}`,
|
||
// 全局拦截器会先弹一次英文/重复错误,本地 catch 统一提示
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || t('版本详情加载失败'));
|
||
const detail = response.data.data || {};
|
||
const version = detail.version || {};
|
||
const contract = parseJsonObject(version.output_contract);
|
||
setEditorMeta({
|
||
definitionId: view.definition.id,
|
||
baseLabel: `v${version.version}`,
|
||
});
|
||
setForm({
|
||
expert_key: version.expert_key || view.definition.expert_key,
|
||
name_zh: version.name_zh || '',
|
||
name_en: version.name_en || '',
|
||
description_zh: version.description_zh || '',
|
||
description_en: version.description_en || '',
|
||
scenario_zh: version.scenario_zh || '',
|
||
scenario_en: version.scenario_en || '',
|
||
system_prompt_zh: detail.system_prompt_zh || '',
|
||
system_prompt_en: detail.system_prompt_en || '',
|
||
default_model: version.default_model || '',
|
||
fallback_models: parseJsonArray(version.fallback_models),
|
||
required_sections_zh: (contract.required_sections_zh || []).join(', '),
|
||
required_sections_en: (contract.required_sections_en || []).join(', '),
|
||
forbidden_placeholders: (contract.forbidden_placeholders || []).join(
|
||
', ',
|
||
),
|
||
require_citations: Boolean(contract.require_citations),
|
||
repair_once: contract.repair_once !== false,
|
||
contract_type: contract.type || 'markdown',
|
||
required_table_columns: Array.isArray(contract.required_table_columns)
|
||
? contract.required_table_columns
|
||
: [],
|
||
artifact_mode: contract.artifact_mode || 'inline',
|
||
file_name: contract.file_name || '',
|
||
content_type: contract.content_type || '',
|
||
max_output_tokens: version.max_output_tokens || 2048,
|
||
max_total_output_tokens:
|
||
version.max_total_output_tokens || version.max_output_tokens || 4096,
|
||
max_step_quota: version.max_step_quota || 100000,
|
||
max_task_quota: version.max_task_quota || 200000,
|
||
default_language: version.default_language === 'en' ? 'en' : 'zh',
|
||
safety_policy_ref: version.safety_policy_ref || 'platform-default',
|
||
input_schema: version.input_schema || DEFAULT_INPUT_SCHEMA,
|
||
});
|
||
const stepPlan = parseJsonArray(version.step_plan);
|
||
setSteps(
|
||
stepPlan.length
|
||
? stepPlan.map((step) => ({
|
||
...newStep(),
|
||
key: step.key || '',
|
||
name_zh: step.name_zh || '',
|
||
name_en: step.name_en || '',
|
||
instruction_zh: step.instruction_zh || '',
|
||
instruction_en: step.instruction_en || '',
|
||
max_output_tokens: step.max_output_tokens || 0,
|
||
}))
|
||
: defaultSteps(),
|
||
);
|
||
setSelectedSkills(detail.skill_ids || []);
|
||
setAdvanced(false);
|
||
setEditorOpen(true);
|
||
} catch (error) {
|
||
Toast.error(
|
||
error?.response?.data?.message ||
|
||
error?.message ||
|
||
t('版本详情加载失败'),
|
||
);
|
||
}
|
||
};
|
||
|
||
// publishAfter=true 时创建成功后直接串发布(傻瓜式一步到位);
|
||
// 发布失败不吞:草稿已落库,提示可稍后在专家卡上手动发布。
|
||
const createVersion = async (publishAfter = false) => {
|
||
// Semi Button 的 loading 不拦截点击:无重入守卫时双击/两个按钮先后点
|
||
// 会连发两个 POST,产生重复版本
|
||
if (editorSaving) return;
|
||
let requestBody;
|
||
if (advanced) {
|
||
try {
|
||
requestBody = JSON.parse(payload);
|
||
} catch {
|
||
Toast.error(t('配置必须是合法 JSON'));
|
||
return;
|
||
}
|
||
// JSON 里显式写了 skill_ids 就以 JSON 为准,否则用上方选择器的值
|
||
if (!Array.isArray(requestBody.skill_ids))
|
||
requestBody.skill_ids = selectedSkills;
|
||
if (editorMeta.definitionId)
|
||
requestBody.definition_id = editorMeta.definitionId;
|
||
} else {
|
||
const problem = validateForm();
|
||
if (problem) {
|
||
Toast.error(problem);
|
||
return;
|
||
}
|
||
requestBody = assembleRequest();
|
||
}
|
||
// 后端保存(含草稿)就会硬校验每个模型都有满足限额的已验证渠道——
|
||
// 这里直接拦下并引导去登记,而不是许诺一个后端必拒的「仍保存」
|
||
const candidates = [
|
||
requestBody.default_model,
|
||
...(requestBody.fallback_models || []),
|
||
].filter(Boolean);
|
||
const requestMaxOutput = Number(requestBody.max_output_tokens) || 2048;
|
||
const missingModels = candidates.filter(
|
||
(name) => !capabilityUsable(name, requestMaxOutput),
|
||
);
|
||
if (missingModels.length > 0) {
|
||
Modal.confirm({
|
||
title: t('所选模型尚未登记渠道能力'),
|
||
content: t(
|
||
'默认与降级序列中的每个模型都必须有满足输出上限的已验证渠道,否则无法保存。缺失:{{models}}',
|
||
{ models: missingModels.join('、') },
|
||
),
|
||
okText: t('去登记模型能力'),
|
||
cancelText: t('返回修改'),
|
||
onOk: () => openCapability(missingModels[0]),
|
||
});
|
||
return;
|
||
}
|
||
// brainError 用非 2xx 状态返回,axios 会 reject:必须 skipErrorHandler
|
||
// 自己接住,否则全局拦截器直显英文 err.Error() 且本地分支成死代码
|
||
setEditorSaving(true);
|
||
try {
|
||
let created;
|
||
try {
|
||
const response = await API.post(
|
||
'/api/skill-platform/experts/versions',
|
||
requestBody,
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
created = response.data.data;
|
||
} catch (error) {
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(message ? t(localizeExpertError(message)) : t('保存失败'));
|
||
return;
|
||
}
|
||
if (publishAfter && created?.id) {
|
||
try {
|
||
const publishResponse = await API.post(
|
||
`/api/skill-platform/experts/versions/${created.id}/publish`,
|
||
{},
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!publishResponse.data?.success)
|
||
throw new Error(publishResponse.data?.message || '');
|
||
Toast.success(t('新版本已发布,员工端立即生效'));
|
||
} catch (error) {
|
||
// 草稿已落库:提示后仍要关编辑器并刷新,避免误以为没保存而重试
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(
|
||
message
|
||
? t(localizeExpertError(message))
|
||
: t('发布失败,草稿已保存,可稍后在专家卡上发布'),
|
||
);
|
||
}
|
||
} else {
|
||
Toast.success(t('草稿已保存,发布后员工可见'));
|
||
}
|
||
setEditorOpen(false);
|
||
await load({ silent: true });
|
||
} finally {
|
||
setEditorSaving(false);
|
||
}
|
||
};
|
||
|
||
const publish = async (id) => {
|
||
try {
|
||
const response = await API.post(
|
||
`/api/skill-platform/experts/versions/${id}/publish`,
|
||
{},
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
Toast.success(t('已发布'));
|
||
} catch (error) {
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(message ? t(localizeExpertError(message)) : t('发布失败'));
|
||
return;
|
||
}
|
||
await load({ silent: true });
|
||
};
|
||
const revoke = async (id) => {
|
||
try {
|
||
const response = await API.post(
|
||
`/api/skill-platform/experts/versions/${id}/revoke`,
|
||
{ reason: 'Platform security revocation' },
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
Toast.success(t('已停用'));
|
||
} catch (error) {
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(message ? t(localizeExpertError(message)) : t('停用失败'));
|
||
return;
|
||
}
|
||
await load({ silent: true });
|
||
};
|
||
|
||
// 专家自检 + 连通性实测:自检只读库(秒回),实测才真正打上游。
|
||
// 被测版本取当前发布版本;没有发布版本时退到最新版本,让草稿也能先验配置。
|
||
const diagnoseVersionOf = (view) =>
|
||
view.current || sortVersionsDesc(view.versions)[0] || null;
|
||
|
||
const openDiagnose = async (view) => {
|
||
const version = diagnoseVersionOf(view);
|
||
if (!version) {
|
||
Toast.error(t('该专家还没有任何版本可测'));
|
||
return;
|
||
}
|
||
setDiagnoseTarget({
|
||
id: version.id,
|
||
name: view.current?.name_zh || view.definition.expert_key,
|
||
version: version.version,
|
||
});
|
||
setDiagnosis(null);
|
||
setConnectivity(null);
|
||
// 新代次要连 loading 一起接管:上一次实测的 finally 会因代次不符而跳过收尾,
|
||
// 不在这里复位就会让新弹窗的「实测连通性」永远转圈、永远点不动。
|
||
setConnectivityLoading(false);
|
||
setDiagnoseOpen(true);
|
||
setDiagnoseLoading(true);
|
||
const generation = ++diagnoseRequestRef.current;
|
||
try {
|
||
const response = await API.get(
|
||
`/api/skill-platform/experts/versions/${version.id}/diagnose`,
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (diagnoseRequestRef.current !== generation) return;
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
setDiagnosis(response.data.data);
|
||
} catch (error) {
|
||
if (diagnoseRequestRef.current !== generation) return;
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(
|
||
message ? t(localizeExpertError(message)) : t('专家自检失败'),
|
||
);
|
||
setDiagnoseOpen(false);
|
||
} finally {
|
||
// loading 只由最新一次请求收尾,否则过期响应会把仍在进行的自检提前收干净
|
||
if (diagnoseRequestRef.current === generation) setDiagnoseLoading(false);
|
||
}
|
||
};
|
||
|
||
const runConnectivityTest = async () => {
|
||
if (!diagnoseTarget) return;
|
||
setConnectivityLoading(true);
|
||
// 与自检共用同一个代次:期间换了专家,这次实测结果一律丢弃
|
||
const generation = diagnoseRequestRef.current;
|
||
try {
|
||
const response = await API.post(
|
||
`/api/skill-platform/experts/versions/${diagnoseTarget.id}/connectivity-test`,
|
||
{},
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (diagnoseRequestRef.current !== generation) return;
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
setConnectivity(response.data.data);
|
||
} catch (error) {
|
||
if (diagnoseRequestRef.current !== generation) return;
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(
|
||
message ? t(localizeExpertError(message)) : t('连通性实测失败'),
|
||
);
|
||
} finally {
|
||
if (diagnoseRequestRef.current === generation)
|
||
setConnectivityLoading(false);
|
||
}
|
||
};
|
||
|
||
const openCapability = (modelName = '') => {
|
||
setCapForm(emptyCapability(modelName));
|
||
setCapLockChannel(false);
|
||
setCapabilityOpen(true);
|
||
};
|
||
const openCapabilityEdit = (item) => {
|
||
// upsert 冲突键是 (model, channel):编辑态放开渠道会变成"新建一行、
|
||
// 旧行残留 verified 继续参与派发",所以锁死渠道
|
||
setCapLockChannel(true);
|
||
setCapForm({
|
||
channel_id: item.channel_id,
|
||
model_name: item.model_name,
|
||
supports_tools: Boolean(item.supports_tools),
|
||
context_window: item.context_window || 131072,
|
||
max_output_tokens: item.max_output_tokens || 0,
|
||
tokenizer: item.tokenizer || '',
|
||
data_region: item.data_region || '',
|
||
embedding_space_id: item.embedding_space_id || 0,
|
||
});
|
||
setCapabilityOpen(true);
|
||
};
|
||
|
||
const channelModelOptions = useMemo(() => {
|
||
const channel = channels.find((item) => item.id === capForm.channel_id);
|
||
const names = new Set(csvList(channel?.models));
|
||
if (capForm.model_name) names.add(capForm.model_name);
|
||
return [...names].sort().map((name) => ({ value: name, label: name }));
|
||
}, [channels, capForm.channel_id, capForm.model_name]);
|
||
|
||
const saveCapability = async () => {
|
||
if (capabilitySaving) return;
|
||
if (
|
||
!capForm.channel_id ||
|
||
!String(capForm.model_name || '').trim() ||
|
||
!(Number(capForm.context_window) > 0)
|
||
) {
|
||
Toast.error(t('请选择渠道、模型并填写上下文窗口'));
|
||
return;
|
||
}
|
||
setCapabilitySaving(true);
|
||
try {
|
||
const response = await API.put(
|
||
'/api/skill-platform/model-capabilities',
|
||
{
|
||
...capForm,
|
||
model_name: String(capForm.model_name).trim(),
|
||
channel_id: Number(capForm.channel_id),
|
||
context_window: Number(capForm.context_window),
|
||
max_output_tokens: Number(capForm.max_output_tokens) || 0,
|
||
embedding_space_id: Number(capForm.embedding_space_id) || 0,
|
||
},
|
||
{ skipErrorHandler: true },
|
||
);
|
||
if (!response.data?.success)
|
||
throw new Error(response.data?.message || '');
|
||
Toast.success(t('模型能力已登记并标记为已验证'));
|
||
setCapabilityOpen(false);
|
||
await load({ silent: true });
|
||
} catch (error) {
|
||
const message = error?.response?.data?.message || error?.message;
|
||
Toast.error(message ? t(localizeExpertError(message)) : t('保存失败'));
|
||
} finally {
|
||
setCapabilitySaving(false);
|
||
}
|
||
};
|
||
|
||
const openReconciliation = (item, mode = 'resolve') => {
|
||
setSelectedCase(item);
|
||
setResolutionMode(mode);
|
||
setResolution({
|
||
actual_quota: 0,
|
||
resolution_type: 'provider_confirmed',
|
||
reason: '',
|
||
});
|
||
setReconciliationOpen(true);
|
||
};
|
||
|
||
const resolveReconciliation = () => {
|
||
if (!selectedCase) return;
|
||
const reason = resolution.reason.trim();
|
||
if (reason.length < 4) {
|
||
Toast.error(t('处置原因至少需要 4 个字符'));
|
||
return;
|
||
}
|
||
if (
|
||
resolution.resolution_type === 'confirmed_zero' &&
|
||
resolution.actual_quota !== 0
|
||
) {
|
||
Toast.error(t('确认零用量时实际配额必须为 0'));
|
||
return;
|
||
}
|
||
Modal.confirm({
|
||
title: t('二次确认对账处置'),
|
||
content: t(
|
||
'该操作会写入不可变结算流水并结束预留,提交后不能撤销。请确认已核对供应商证据。',
|
||
),
|
||
okType: 'danger',
|
||
onOk: async () => {
|
||
const response = await API.post(
|
||
`/api/skill-platform/reconciliation/${selectedCase.id}/${resolutionMode}`,
|
||
{ ...resolution, reason },
|
||
{ headers: { 'X-Audit-Confirm': 'true' } },
|
||
);
|
||
if (!response.data?.success) {
|
||
Toast.error(response.data?.message || t('对账处置失败'));
|
||
throw new Error(response.data?.message || 'reconciliation failed');
|
||
}
|
||
Toast.success(t('对账处置已完成'));
|
||
setReconciliationOpen(false);
|
||
setSelectedCase(null);
|
||
await load({ silent: true });
|
||
},
|
||
});
|
||
};
|
||
|
||
const replayOutbox = () => {
|
||
if (!replayTarget || replayReason.trim().length < 4) {
|
||
Toast.error(t('重放原因至少需要 4 个字符'));
|
||
return;
|
||
}
|
||
Modal.confirm({
|
||
title: t('二次确认重放'),
|
||
content: t(
|
||
'重放会重新投递已有权威记录,不会重新结算。请确认目标系统已经恢复。',
|
||
),
|
||
okType: 'danger',
|
||
onOk: async () => {
|
||
const response = await API.post(
|
||
`/api/skill-platform/operations/outbox/${replayTarget.topic}/${replayTarget.id}/replay`,
|
||
{ reason: replayReason.trim() },
|
||
{ headers: { 'X-Audit-Confirm': 'true' } },
|
||
);
|
||
if (!response.data?.success) {
|
||
Toast.error(response.data?.message || t('重放失败'));
|
||
throw new Error(response.data?.message || 'replay failed');
|
||
}
|
||
Toast.success(t('死信已重新进入待处理队列'));
|
||
setReplayTarget(null);
|
||
setReplayReason('');
|
||
await load({ silent: true });
|
||
},
|
||
});
|
||
};
|
||
|
||
const expertCardModels = (current) =>
|
||
[current.default_model, ...parseJsonArray(current.fallback_models)].filter(
|
||
Boolean,
|
||
);
|
||
|
||
const versionStatusLabel = (status) =>
|
||
t(versionStatusMeta[status]?.label || status);
|
||
const capabilityStatusLabel = (status) => {
|
||
if (status === 'verified') return t('已验证');
|
||
// 未知枚举回落原值:断言成"待验证"会在后端新增状态时静默误标
|
||
return status ? t(status) : t('待验证');
|
||
};
|
||
const reconciliationStatusLabel = (status) =>
|
||
t(reconciliationStatusMeta[status]?.label || status);
|
||
|
||
const tabLabel = (text, count, alert = false) => (
|
||
<span className='expert-tab-label'>
|
||
{text}
|
||
<em className={alert && count > 0 ? 'is-alert' : ''}>{count}</em>
|
||
</span>
|
||
);
|
||
|
||
// 首屏骨架:卡片外壳沿用正式布局,避免加载完成时高度跳动
|
||
const renderSkeletonGrid = () => (
|
||
<section className='expert-grid' aria-busy='true'>
|
||
{Array.from({ length: 6 }, (_, index) => (
|
||
<div className='expert-card expert-skeleton' key={index}>
|
||
<Skeleton
|
||
loading
|
||
active
|
||
placeholder={
|
||
<div style={{ display: 'grid', gap: 12 }}>
|
||
<Skeleton.Title style={{ width: '58%' }} />
|
||
<Skeleton.Paragraph rows={2} />
|
||
<Skeleton.Button style={{ width: 88, height: 24 }} />
|
||
</div>
|
||
}
|
||
/>
|
||
</div>
|
||
))}
|
||
</section>
|
||
);
|
||
|
||
const renderEmpty = (icon, title, description, action = null) => (
|
||
<div className='expert-empty'>
|
||
<div className='expert-empty-icon'>{icon}</div>
|
||
<h3>{title}</h3>
|
||
<p>{description}</p>
|
||
{action}
|
||
</div>
|
||
);
|
||
|
||
return (
|
||
<section className='expert-platform-page'>
|
||
<div className='expert-platform-shell'>
|
||
<ConsolePageActions>
|
||
<Button
|
||
icon={<RefreshCw size={16} />}
|
||
loading={loading}
|
||
onClick={() => void load()}
|
||
>
|
||
{t('刷新')}
|
||
</Button>
|
||
<Button icon={<Cpu size={16} />} onClick={() => openCapability()}>
|
||
{t('登记模型能力')}
|
||
</Button>
|
||
<Button
|
||
theme='solid'
|
||
type='primary'
|
||
icon={<Plus size={16} />}
|
||
onClick={openCreate}
|
||
>
|
||
{t('创建专家')}
|
||
</Button>
|
||
</ConsolePageActions>
|
||
|
||
{loadError !== '' && (
|
||
<Banner
|
||
className='expert-error'
|
||
type='danger'
|
||
closeIcon={null}
|
||
description={
|
||
<div className='expert-error-body'>
|
||
<span>
|
||
{t('平台专家数据加载失败,请重试或联系平台运维。')}
|
||
{loadError ? `(${loadError})` : ''}
|
||
</span>
|
||
<Button size='small' onClick={() => void load()}>
|
||
{t('重新加载')}
|
||
</Button>
|
||
</div>
|
||
}
|
||
/>
|
||
)}
|
||
|
||
<section className='expert-metrics' aria-label={t('平台专家概览')}>
|
||
<div className='expert-metric'>
|
||
<Bot size={20} />
|
||
<div className='expert-metric-copy'>
|
||
<strong>{loading ? '—' : experts.length}</strong>
|
||
<span>{t('专家模板')}</span>
|
||
</div>
|
||
</div>
|
||
<div className='expert-metric'>
|
||
<BadgeCheck size={20} />
|
||
<div className='expert-metric-copy'>
|
||
<strong>{loading ? '—' : publishedExperts}</strong>
|
||
<span>{t('已发布上线')}</span>
|
||
</div>
|
||
</div>
|
||
<div className='expert-metric'>
|
||
<ShieldCheck size={20} />
|
||
<div className='expert-metric-copy'>
|
||
<strong>{loading ? '—' : pendingOrgReviews}</strong>
|
||
<span>{t('企业专家待审核')}</span>
|
||
</div>
|
||
</div>
|
||
<div className='expert-metric'>
|
||
<Cpu size={20} />
|
||
<div className='expert-metric-copy'>
|
||
<strong>
|
||
{loading ? '—' : verifiedCapabilities}
|
||
{loading ? null : <small>/{capabilities.length}</small>}
|
||
</strong>
|
||
<span>{t('已验证模型能力')}</span>
|
||
</div>
|
||
</div>
|
||
<div className='expert-metric'>
|
||
<Scale size={20} />
|
||
<div className='expert-metric-copy'>
|
||
<strong>{loading ? '—' : pendingReconciliations}</strong>
|
||
<span>{t('待对账案件')}</span>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<Tabs type='line' className='expert-tabs' lazyRender>
|
||
<TabPane
|
||
tab={tabLabel(t('专家模板'), experts.length)}
|
||
itemKey='experts'
|
||
>
|
||
{loading ? (
|
||
renderSkeletonGrid()
|
||
) : (
|
||
<section className='expert-grid'>
|
||
{experts.map((view) => (
|
||
<article className='expert-card' key={view.definition.id}>
|
||
<div className='expert-card-head'>
|
||
<div className='expert-card-title'>
|
||
<h3>
|
||
{view.current?.name_zh || view.definition.expert_key}
|
||
</h3>
|
||
{/* 没有中文名时标题本身就是 expert_key,不再重复一行 */}
|
||
{view.current?.name_zh && (
|
||
<span className='expert-card-key'>
|
||
{view.definition.expert_key}
|
||
</span>
|
||
)}
|
||
</div>
|
||
<Tag
|
||
shape='circle'
|
||
color={versionStatusMeta[view.definition.status]?.color}
|
||
>
|
||
{versionStatusLabel(view.definition.status)}
|
||
</Tag>
|
||
</div>
|
||
<p
|
||
className='expert-card-desc'
|
||
title={view.current?.description_zh || undefined}
|
||
>
|
||
{view.current?.description_zh ||
|
||
t('该专家还没有已发布版本,编辑后发布即可上线。')}
|
||
</p>
|
||
{view.current && (
|
||
<div className='expert-card-models'>
|
||
{expertCardModels(view.current).map((name) => {
|
||
// 按该专家自己的输出上限判定,与后端派发条件一致
|
||
const usable = capabilityUsable(
|
||
name,
|
||
view.current.max_output_tokens || 2048,
|
||
);
|
||
return (
|
||
<span
|
||
key={name}
|
||
className={`expert-model-badge ${usable ? 'is-ok' : 'is-missing'}`}
|
||
title={
|
||
usable
|
||
? t('{{count}} 渠道已验证', {
|
||
count: verifiedByModel[name],
|
||
})
|
||
: t(
|
||
'没有满足该专家输出上限的已验证渠道,任务无法派发到该模型',
|
||
)
|
||
}
|
||
>
|
||
{name}
|
||
{usable
|
||
? ` · ${verifiedByModel[name]}`
|
||
: ` · ${t('不可用')}`}
|
||
</span>
|
||
);
|
||
})}
|
||
</div>
|
||
)}
|
||
<VersionStrip
|
||
versions={view.versions}
|
||
labelOf={(version) => versionStatusLabel(version.status)}
|
||
/>
|
||
{/* 动作全部落在同一行:次要动作在左,主动作「编辑」压右 */}
|
||
<div className='expert-card-foot'>
|
||
{publishableVersions(view.versions).map((version) => (
|
||
<Button
|
||
key={version.id}
|
||
size='small'
|
||
onClick={() => publish(version.id)}
|
||
>
|
||
{t('发布')} v{version.version}
|
||
</Button>
|
||
))}
|
||
{publishedVersions(view.versions).map((version) => (
|
||
<Button
|
||
key={version.id}
|
||
size='small'
|
||
type='danger'
|
||
onClick={() => revoke(version.id)}
|
||
>
|
||
{t('紧急停用')} v{version.version}
|
||
</Button>
|
||
))}
|
||
<Button
|
||
size='small'
|
||
onClick={() => void openDiagnose(view)}
|
||
>
|
||
{t('测试')}
|
||
</Button>
|
||
<Button
|
||
theme='solid'
|
||
size='small'
|
||
onClick={() => void openIterate(view)}
|
||
>
|
||
{t('编辑')}
|
||
</Button>
|
||
</div>
|
||
</article>
|
||
))}
|
||
{experts.length === 0 &&
|
||
renderEmpty(
|
||
<Bot size={22} />,
|
||
t('还没有配置任何专家'),
|
||
t(
|
||
'专家模板决定云端大脑如何拆解任务、调用哪些模型。先登记模型能力,再创建第一个专家。',
|
||
),
|
||
<Button
|
||
theme='solid'
|
||
type='primary'
|
||
icon={<Plus size={16} />}
|
||
onClick={openCreate}
|
||
>
|
||
{t('创建专家')}
|
||
</Button>,
|
||
)}
|
||
</section>
|
||
)}
|
||
</TabPane>
|
||
<TabPane
|
||
tab={tabLabel(t('企业专家审核'), pendingOrgReviews, true)}
|
||
itemKey='organization-reviews'
|
||
>
|
||
{loading ? (
|
||
renderSkeletonGrid()
|
||
) : (
|
||
<section className='expert-grid'>
|
||
{organizationReviews.map((view) => (
|
||
<article className='expert-card' key={view.definition.id}>
|
||
<div className='expert-card-head'>
|
||
<div className='expert-card-title'>
|
||
<h3>{view.definition.expert_key}</h3>
|
||
<span className='expert-card-key'>
|
||
{t('企业')} #{view.definition.organization_id}
|
||
</span>
|
||
</div>
|
||
<Tag shape='circle' color='orange'>
|
||
{t('待审核')}
|
||
</Tag>
|
||
</div>
|
||
<VersionStrip
|
||
versions={(view.versions || []).filter(
|
||
(version) => version.status === 'pending_review',
|
||
)}
|
||
labelOf={(version) => version.name_zh || t('待审核')}
|
||
/>
|
||
<div className='expert-card-foot'>
|
||
{(view.versions || [])
|
||
.filter(
|
||
(version) => version.status === 'pending_review',
|
||
)
|
||
.map((version) => (
|
||
<Button
|
||
key={version.id}
|
||
size='small'
|
||
theme='solid'
|
||
onClick={() => publish(version.id)}
|
||
>
|
||
{t('审核并发布')} v{version.version}
|
||
</Button>
|
||
))}
|
||
</div>
|
||
</article>
|
||
))}
|
||
{organizationReviews.length === 0 &&
|
||
renderEmpty(
|
||
<ShieldCheck size={22} />,
|
||
t('没有待审核的企业专家'),
|
||
t(
|
||
'企业自建的专家版本提交审核后会出现在这里,由平台统一放行。',
|
||
),
|
||
)}
|
||
</section>
|
||
)}
|
||
</TabPane>
|
||
<TabPane
|
||
tab={tabLabel(t('模型能力'), capabilities.length)}
|
||
itemKey='caps'
|
||
>
|
||
{loading ? (
|
||
renderSkeletonGrid()
|
||
) : (
|
||
<section className='expert-grid'>
|
||
{capabilities.map((item) => (
|
||
<article
|
||
className='expert-card'
|
||
key={`${item.model_name}-${item.channel_id}`}
|
||
>
|
||
<div className='expert-card-head'>
|
||
<div className='expert-card-title'>
|
||
<h3>{item.model_name}</h3>
|
||
<span className='expert-card-key'>
|
||
channel #{item.channel_id}
|
||
</span>
|
||
</div>
|
||
<Tag
|
||
shape='circle'
|
||
color={item.status === 'verified' ? 'green' : 'orange'}
|
||
title={item.status}
|
||
>
|
||
{capabilityStatusLabel(item.status)}
|
||
</Tag>
|
||
</div>
|
||
<div className='expert-card-meta'>
|
||
<span>
|
||
{t('上下文窗口')}{' '}
|
||
{Number(item.context_window || 0).toLocaleString()}
|
||
</span>
|
||
<span>
|
||
{t('输出上限')}{' '}
|
||
{item.max_output_tokens
|
||
? Number(item.max_output_tokens).toLocaleString()
|
||
: t('不限')}
|
||
</span>
|
||
</div>
|
||
<div className='expert-card-tags'>
|
||
<Tag
|
||
size='small'
|
||
color={item.supports_tools ? 'green' : 'grey'}
|
||
>
|
||
{item.supports_tools
|
||
? t('支持工具调用')
|
||
: t('不支持工具调用')}
|
||
</Tag>
|
||
<Tag size='small'>
|
||
{item.data_region || t('未标注数据区域')}
|
||
</Tag>
|
||
</div>
|
||
<div className='expert-card-foot'>
|
||
<Button
|
||
size='small'
|
||
onClick={() => openCapabilityEdit(item)}
|
||
>
|
||
{t('更新')}
|
||
</Button>
|
||
</div>
|
||
</article>
|
||
))}
|
||
{capabilities.length === 0 &&
|
||
renderEmpty(
|
||
<Cpu size={22} />,
|
||
t('还没有登记任何模型能力'),
|
||
t(
|
||
'云端大脑任务只会派发到已验证的「模型 × 渠道」组合,先登记第一条能力。',
|
||
),
|
||
<Button
|
||
theme='solid'
|
||
type='primary'
|
||
icon={<Plus size={16} />}
|
||
onClick={() => openCapability()}
|
||
>
|
||
{t('登记模型能力')}
|
||
</Button>,
|
||
)}
|
||
</section>
|
||
)}
|
||
</TabPane>
|
||
<TabPane
|
||
tab={tabLabel(t('待对账'), pendingReconciliations, true)}
|
||
itemKey='reconciliation'
|
||
>
|
||
{loading ? (
|
||
renderSkeletonGrid()
|
||
) : (
|
||
<section className='expert-grid'>
|
||
{reconciliations.map((item) => (
|
||
<article className='expert-card' key={item.id}>
|
||
<div className='expert-card-head'>
|
||
<div className='expert-card-title'>
|
||
<h3>{item.workload_type}</h3>
|
||
<Text
|
||
className='expert-card-key'
|
||
size='small'
|
||
copyable={{ text: item.workload_id }}
|
||
>
|
||
{item.workload_id}
|
||
</Text>
|
||
</div>
|
||
<Tag
|
||
shape='circle'
|
||
color={
|
||
item.status === 'resolved'
|
||
? 'green'
|
||
: item.status === 'expired'
|
||
? 'red'
|
||
: 'orange'
|
||
}
|
||
>
|
||
{reconciliationStatusLabel(item.status)}
|
||
</Tag>
|
||
</div>
|
||
<p className='expert-card-desc' title={item.reason}>
|
||
{item.reason || t('未提供案件原因')}
|
||
</p>
|
||
<div className='expert-card-meta'>
|
||
<span>
|
||
{t('企业')} #{item.organization_id || '-'}
|
||
</span>
|
||
<span>
|
||
{t('创建时间')}{' '}
|
||
{new Date(item.created_at * 1000).toLocaleString()}
|
||
</span>
|
||
</div>
|
||
{/* Resolve/adjust are RootAuth on the backend; hiding them
|
||
for other admins avoids a full form flow that can only
|
||
end in a permission rejection. */}
|
||
{isRoot() &&
|
||
(item.status === 'pending' ||
|
||
item.status === 'manual') && (
|
||
<div className='expert-card-foot'>
|
||
<Button
|
||
theme='solid'
|
||
type='danger'
|
||
size='small'
|
||
onClick={() => openReconciliation(item)}
|
||
>
|
||
{item.workload_type === 'connector-write'
|
||
? t('确认已跟进并关闭')
|
||
: t('审核并处置')}
|
||
</Button>
|
||
</div>
|
||
)}
|
||
{isRoot() &&
|
||
item.status === 'expired' &&
|
||
item.workload_type !== 'connector-write' && (
|
||
<div className='expert-card-foot'>
|
||
<Button
|
||
size='small'
|
||
onClick={() => openReconciliation(item, 'adjust')}
|
||
>
|
||
{t('录入迟到的供应商用量')}
|
||
</Button>
|
||
</div>
|
||
)}
|
||
</article>
|
||
))}
|
||
{reconciliations.length === 0 &&
|
||
renderEmpty(
|
||
<Scale size={22} />,
|
||
t('暂无对账案件'),
|
||
t(
|
||
'未知用量案件会在这里等待平台运营核对,当前结算链路干净。',
|
||
),
|
||
)}
|
||
</section>
|
||
)}
|
||
</TabPane>
|
||
{deliveryHealth && (
|
||
<TabPane
|
||
tab={tabLabel(t('投递健康'), deadLetterTotal, true)}
|
||
itemKey='delivery-health'
|
||
>
|
||
<section className='expert-grid'>
|
||
{(deliveryHealth.topics || []).map((topic) => (
|
||
<article className='expert-card' key={topic.topic}>
|
||
<div className='expert-card-head'>
|
||
<div className='expert-card-title'>
|
||
<h3>{topic.topic}</h3>
|
||
</div>
|
||
<Tag
|
||
shape='circle'
|
||
color={topic.dead_letter > 0 ? 'red' : 'green'}
|
||
>
|
||
{topic.dead_letter > 0 ? t('存在死信') : t('投递正常')}
|
||
</Tag>
|
||
</div>
|
||
<div className='expert-card-meta'>
|
||
<span>
|
||
{t('待处理')} {topic.pending}
|
||
</span>
|
||
<span>
|
||
{t('处理中')} {topic.processing}
|
||
</span>
|
||
<span>
|
||
{t('最老积压')} {topic.oldest_backlog_age_seconds}s
|
||
</span>
|
||
</div>
|
||
{(topic.dead_letters || []).map((item) => (
|
||
<div className='expert-dead-row' key={item.id}>
|
||
<div className='expert-dead-copy'>
|
||
<Text size='small' copyable={{ text: item.key }}>
|
||
{item.key}
|
||
</Text>
|
||
<p>{item.error_message || t('未知投递错误')}</p>
|
||
</div>
|
||
{/* The replay endpoint only supports billing/trace;
|
||
capability dead letters are replayed from the
|
||
organization-side skill outbox instead. */}
|
||
{isRoot() &&
|
||
(topic.topic === 'billing' ||
|
||
topic.topic === 'trace') && (
|
||
<Button
|
||
size='small'
|
||
type='danger'
|
||
onClick={() => {
|
||
setReplayReason('');
|
||
setReplayTarget({
|
||
topic: topic.topic,
|
||
...item,
|
||
});
|
||
}}
|
||
>
|
||
{t('审核重放')}
|
||
</Button>
|
||
)}
|
||
</div>
|
||
))}
|
||
{(topic.dead_letters || []).length === 0 && (
|
||
<p className='expert-card-desc'>
|
||
{t('该主题当前没有死信,投递链路健康。')}
|
||
</p>
|
||
)}
|
||
</article>
|
||
))}
|
||
{(deliveryHealth.topics || []).length === 0 &&
|
||
renderEmpty(
|
||
<Activity size={22} />,
|
||
t('暂无投递主题'),
|
||
t(
|
||
'结算与追踪事件开始投递后,这里会展示各主题的积压与死信。',
|
||
),
|
||
)}
|
||
</section>
|
||
</TabPane>
|
||
)}
|
||
</Tabs>
|
||
</div>
|
||
<Modal
|
||
title={
|
||
editorMeta.definitionId
|
||
? t('基于 {{base}} 新建版本', {
|
||
base: editorMeta.baseLabel || t('当前版本'),
|
||
})
|
||
: t('创建专家')
|
||
}
|
||
visible={editorOpen}
|
||
onCancel={() => setEditorOpen(false)}
|
||
footer={
|
||
<div className='expert-editor-footer'>
|
||
<Button
|
||
disabled={editorSaving}
|
||
onClick={() => setEditorOpen(false)}
|
||
>
|
||
{t('取消')}
|
||
</Button>
|
||
<Button
|
||
loading={editorSaving}
|
||
disabled={editorSaving}
|
||
onClick={() => void createVersion(false)}
|
||
>
|
||
{t('保存草稿')}
|
||
</Button>
|
||
<Button
|
||
theme='solid'
|
||
type='primary'
|
||
loading={editorSaving}
|
||
disabled={editorSaving}
|
||
onClick={() => void createVersion(true)}
|
||
>
|
||
{t('保存并发布')}
|
||
</Button>
|
||
</div>
|
||
}
|
||
width={920}
|
||
bodyStyle={{ maxHeight: '68vh', overflow: 'auto' }}
|
||
>
|
||
<div className='expert-editor-form'>
|
||
<div className='expert-editor-toolbar'>
|
||
{/* 高级 JSON 模式下隐藏:两个事实源并存会互相覆盖,JSON 里的
|
||
skill_ids 是该模式下的唯一事实源 */}
|
||
{!advanced && (
|
||
<Select
|
||
multiple
|
||
filter
|
||
value={selectedSkills}
|
||
onChange={setSelectedSkills}
|
||
placeholder={t('绑定已审核 Skill(至少 1 个)')}
|
||
optionList={skills.map((item) => ({
|
||
value: item.id,
|
||
label: `${item.name_zh} · v${item.version}`,
|
||
}))}
|
||
/>
|
||
)}
|
||
<Button onClick={toggleAdvanced}>
|
||
{advanced ? t('返回表单') : t('高级 JSON')}
|
||
</Button>
|
||
</div>
|
||
{advanced ? (
|
||
<TextArea
|
||
autosize={{ minRows: 20, maxRows: 30 }}
|
||
value={payload}
|
||
onChange={setPayload}
|
||
/>
|
||
) : (
|
||
<>
|
||
<p className='expert-editor-hint'>
|
||
{t(
|
||
'只需填写中文内容与默认模型;英文文案留空时自动复用中文,限额与输出契约都有可用默认值。',
|
||
)}
|
||
</p>
|
||
<Tabs type='line'>
|
||
<TabPane tab={t('基础信息')} itemKey='basic'>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('专家标识(唯一,小写)')}
|
||
<Input
|
||
value={form.expert_key}
|
||
disabled={Boolean(editorMeta.definitionId)}
|
||
onChange={(value) => update('expert_key', value)}
|
||
placeholder='sales_proposal'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('默认语言')}
|
||
<Select
|
||
value={form.default_language}
|
||
onChange={(value) => update('default_language', value)}
|
||
optionList={[
|
||
{ value: 'zh', label: '中文' },
|
||
{ value: 'en', label: 'English' },
|
||
]}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('中文名称')}
|
||
<Input
|
||
value={form.name_zh}
|
||
onChange={(value) => update('name_zh', value)}
|
||
placeholder={t('如:销售方案专家')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('适用场景')}
|
||
<Input
|
||
value={form.scenario_zh}
|
||
onChange={(value) => update('scenario_zh', value)}
|
||
placeholder={t('如:售前方案、客户沟通稿、POC 计划')}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('中文描述')}
|
||
<Input
|
||
value={form.description_zh}
|
||
onChange={(value) => update('description_zh', value)}
|
||
placeholder={t('一句话说明该专家产出什么成果')}
|
||
/>
|
||
</label>
|
||
</div>
|
||
<Collapse>
|
||
<Collapse.Panel
|
||
header={t('英文文案(可选,留空自动复用中文)')}
|
||
itemKey='en'
|
||
>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('英文名称')}
|
||
<Input
|
||
value={form.name_en}
|
||
onChange={(value) => update('name_en', value)}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('英文场景')}
|
||
<Input
|
||
value={form.scenario_en}
|
||
onChange={(value) => update('scenario_en', value)}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('英文描述')}
|
||
<Input
|
||
value={form.description_en}
|
||
onChange={(value) =>
|
||
update('description_en', value)
|
||
}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</Collapse.Panel>
|
||
</Collapse>
|
||
</TabPane>
|
||
<TabPane tab={t('模型')} itemKey='model'>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('默认模型')}
|
||
<Select
|
||
// 同下:allowCreate 不响应 optionList 更新,数据到位后重挂载
|
||
key={`default-model-${modelOptions.length}`}
|
||
filter
|
||
allowCreate
|
||
showClear
|
||
value={form.default_model || undefined}
|
||
onChange={(value) =>
|
||
update('default_model', value || '')
|
||
}
|
||
optionList={modelOptions}
|
||
placeholder={t('选择或输入模型名')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('降级模型序列(可选)')}
|
||
<Select
|
||
key={`fallback-models-${modelOptions.length}`}
|
||
multiple
|
||
filter
|
||
allowCreate
|
||
value={form.fallback_models}
|
||
onChange={(value) =>
|
||
update('fallback_models', value || [])
|
||
}
|
||
optionList={modelOptions}
|
||
placeholder={t('默认模型不可用时按顺序回退')}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('安全策略标识')}
|
||
<Input
|
||
value={form.safety_policy_ref}
|
||
onChange={(value) => update('safety_policy_ref', value)}
|
||
/>
|
||
</label>
|
||
</div>
|
||
{editorMissingModels.length > 0 && (
|
||
<Banner
|
||
type='warning'
|
||
closeIcon={null}
|
||
description={
|
||
<span>
|
||
{t(
|
||
'以下模型缺少满足输出上限的已验证渠道,保存会被拒绝:{{models}}',
|
||
{ models: editorMissingModels.join('、') },
|
||
)}{' '}
|
||
<Button
|
||
size='small'
|
||
onClick={() =>
|
||
openCapability(editorMissingModels[0])
|
||
}
|
||
>
|
||
{t('去登记模型能力')}
|
||
</Button>
|
||
</span>
|
||
}
|
||
/>
|
||
)}
|
||
</TabPane>
|
||
<TabPane tab={t('提示词与步骤')} itemKey='prompt'>
|
||
<div className='expert-editor-form'>
|
||
<label>
|
||
{t('中文系统提示词')}
|
||
<TextArea
|
||
autosize={{ minRows: 6, maxRows: 14 }}
|
||
maxCount={6000}
|
||
value={form.system_prompt_zh}
|
||
onChange={(value) => update('system_prompt_zh', value)}
|
||
placeholder={t(
|
||
'定义专家的身份、工作方式与产出标准。任务执行时会自动叠加绑定 Skill 的提示词。',
|
||
)}
|
||
/>
|
||
</label>
|
||
<Collapse>
|
||
<Collapse.Panel
|
||
header={t('英文提示词(可选,留空自动复用中文)')}
|
||
itemKey='prompt-en'
|
||
>
|
||
<TextArea
|
||
autosize={{ minRows: 4, maxRows: 12 }}
|
||
maxCount={6000}
|
||
value={form.system_prompt_en}
|
||
onChange={(value) =>
|
||
update('system_prompt_en', value)
|
||
}
|
||
/>
|
||
</Collapse.Panel>
|
||
</Collapse>
|
||
{steps.map((step, index) => (
|
||
<div className='expert-step-card' key={step.uid || index}>
|
||
<div className='expert-step-head'>
|
||
<strong>{t('第 {{n}} 步', { n: index + 1 })}</strong>
|
||
{steps.length > 1 && (
|
||
<Button
|
||
size='small'
|
||
type='danger'
|
||
onClick={() =>
|
||
setSteps((current) =>
|
||
current.filter((_, i) => i !== index),
|
||
)
|
||
}
|
||
>
|
||
{t('删除')}
|
||
</Button>
|
||
)}
|
||
</div>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('步骤名称')}
|
||
<Input
|
||
value={step.name_zh}
|
||
onChange={(value) =>
|
||
updateStep(index, 'name_zh', value)
|
||
}
|
||
placeholder={t('如:整理事实、生成初稿')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('本步输出上限(0 = 跟随专家上限)')}
|
||
<InputNumber
|
||
min={0}
|
||
max={65536}
|
||
value={step.max_output_tokens}
|
||
onChange={(value) =>
|
||
updateStep(
|
||
index,
|
||
'max_output_tokens',
|
||
Number(value) || 0,
|
||
)
|
||
}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('执行指令')}
|
||
<TextArea
|
||
autosize={{ minRows: 2, maxRows: 6 }}
|
||
value={step.instruction_zh}
|
||
onChange={(value) =>
|
||
updateStep(index, 'instruction_zh', value)
|
||
}
|
||
placeholder={t(
|
||
'这一步要专家做什么、产出什么中间结果',
|
||
)}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</div>
|
||
))}
|
||
<div>
|
||
<Button
|
||
disabled={steps.length >= 12}
|
||
onClick={() =>
|
||
setSteps((current) => [...current, newStep()])
|
||
}
|
||
>
|
||
{t('添加步骤')}
|
||
</Button>
|
||
<span className='expert-editor-hint'>
|
||
{' '}
|
||
{t('最多 12 步;上一步产出会进入下一步的上下文。')}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</TabPane>
|
||
<TabPane tab={t('契约与限额')} itemKey='contract'>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('产物必含章节(逗号分隔)')}
|
||
<Input
|
||
value={form.required_sections_zh}
|
||
onChange={(value) =>
|
||
update('required_sections_zh', value)
|
||
}
|
||
placeholder={t('如:核心结论, 关键进展, 风险与问题')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('禁止出现的占位词')}
|
||
<Input
|
||
value={form.forbidden_placeholders}
|
||
onChange={(value) =>
|
||
update('forbidden_placeholders', value)
|
||
}
|
||
placeholder='TODO, XXX'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('要求引用企业知识出处')}
|
||
<Switch
|
||
checked={form.require_citations}
|
||
onChange={(value) => update('require_citations', value)}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('允许一次自动契约修复')}
|
||
<Switch
|
||
checked={form.repair_once}
|
||
onChange={(value) => update('repair_once', value)}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('产物形态')}
|
||
<Select
|
||
value={form.artifact_mode}
|
||
onChange={(value) => update('artifact_mode', value)}
|
||
optionList={[
|
||
{ value: 'inline', label: t('文档(页面展示)') },
|
||
{ value: 'file', label: t('文件(生成下载)') },
|
||
]}
|
||
/>
|
||
</label>
|
||
{form.artifact_mode === 'file' && (
|
||
<>
|
||
<label>
|
||
{t('文件名')}
|
||
<Input
|
||
value={form.file_name}
|
||
onChange={(value) => update('file_name', value)}
|
||
placeholder='report.md'
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('文件类型 (MIME)')}
|
||
<Input
|
||
value={form.content_type}
|
||
onChange={(value) => update('content_type', value)}
|
||
placeholder='text/markdown'
|
||
/>
|
||
</label>
|
||
</>
|
||
)}
|
||
<label>
|
||
{t('单步输出上限 (tokens)')}
|
||
<InputNumber
|
||
min={1}
|
||
max={65536}
|
||
value={form.max_output_tokens}
|
||
onChange={(value) =>
|
||
update('max_output_tokens', Number(value) || 0)
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('任务输出总上限 (tokens)')}
|
||
<InputNumber
|
||
min={1}
|
||
value={form.max_total_output_tokens}
|
||
onChange={(value) =>
|
||
update('max_total_output_tokens', Number(value) || 0)
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('单步额度上限 (quota)')}
|
||
<InputNumber
|
||
min={1}
|
||
value={form.max_step_quota}
|
||
onChange={(value) =>
|
||
update('max_step_quota', Number(value) || 0)
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('任务额度上限 (quota)')}
|
||
<InputNumber
|
||
min={1}
|
||
value={form.max_task_quota}
|
||
onChange={(value) =>
|
||
update('max_task_quota', Number(value) || 0)
|
||
}
|
||
/>
|
||
</label>
|
||
</div>
|
||
<p className='expert-editor-hint'>
|
||
{t(
|
||
'保存时会自动抬升:任务输出总上限 ≥ 单步上限,任务额度 ≥ 步骤数 × 单步额度。',
|
||
)}
|
||
</p>
|
||
<Collapse>
|
||
<Collapse.Panel
|
||
header={t('高级:英文章节与输入 Schema')}
|
||
itemKey='advanced'
|
||
>
|
||
<div className='expert-editor-grid'>
|
||
<label className='wide'>
|
||
{t('英文必含章节(逗号分隔,留空复用中文)')}
|
||
<Input
|
||
value={form.required_sections_en}
|
||
onChange={(value) =>
|
||
update('required_sections_en', value)
|
||
}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('输入 Schema (JSON)')}
|
||
<TextArea
|
||
autosize={{ minRows: 4, maxRows: 10 }}
|
||
value={form.input_schema}
|
||
onChange={(value) => update('input_schema', value)}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</Collapse.Panel>
|
||
</Collapse>
|
||
</TabPane>
|
||
</Tabs>
|
||
</>
|
||
)}
|
||
</div>
|
||
</Modal>
|
||
<Modal
|
||
title={t('专家可用性测试')}
|
||
visible={diagnoseOpen}
|
||
onCancel={() => setDiagnoseOpen(false)}
|
||
footer={
|
||
<div className='expert-diagnose-footer'>
|
||
<Button onClick={() => setDiagnoseOpen(false)}>{t('关闭')}</Button>
|
||
<Button
|
||
theme='solid'
|
||
type='primary'
|
||
loading={connectivityLoading}
|
||
disabled={!diagnosis?.preferred_model}
|
||
onClick={() => void runConnectivityTest()}
|
||
>
|
||
{t('实测连通性')}
|
||
</Button>
|
||
</div>
|
||
}
|
||
width={720}
|
||
>
|
||
{diagnoseLoading || !diagnosis ? (
|
||
<Skeleton
|
||
loading
|
||
active
|
||
placeholder={<Skeleton.Paragraph rows={4} />}
|
||
/>
|
||
) : (
|
||
<div className='expert-diagnose'>
|
||
<Banner
|
||
type={diagnosis.ready ? 'success' : 'danger'}
|
||
closeIcon={null}
|
||
description={
|
||
diagnosis.ready
|
||
? t('按你当前的分组与等级,这个专家可以创建任务。')
|
||
: t(
|
||
diagnoseBlockingHints[diagnosis.blocking_code] ||
|
||
'按你当前的分组与等级,这个专家现在无法创建任务。',
|
||
)
|
||
}
|
||
/>
|
||
<p className='expert-diagnose-scope'>
|
||
{t(
|
||
'自检按你自己的分组与等级评估;企业成员受各自分组/等级过滤,结果可能不同。',
|
||
)}
|
||
</p>
|
||
<ul className='expert-diagnose-checks'>
|
||
{(diagnosis.checks || []).map((check) => (
|
||
<li
|
||
key={check.key}
|
||
className={check.ok ? 'is-ok' : 'is-blocked'}
|
||
>
|
||
<span>{t(diagnoseCheckLabels[check.key] || check.key)}</span>
|
||
<small>{diagnoseCheckDetail(check, diagnosis, t)}</small>
|
||
</li>
|
||
))}
|
||
</ul>
|
||
<div className='expert-diagnose-models'>
|
||
<h4>{t('候选模型')}</h4>
|
||
{(diagnosis.models || []).length === 0 && (
|
||
<p className='expert-diagnose-empty'>
|
||
{t('该专家没有任何候选模型,请先在专家里配置默认模型。')}
|
||
</p>
|
||
)}
|
||
{(diagnosis.models || []).map((row) => (
|
||
<div
|
||
key={row.model}
|
||
className={`expert-diagnose-model ${row.ok ? 'is-ok' : 'is-blocked'}`}
|
||
>
|
||
<strong>
|
||
{row.model}
|
||
{row.preferred && <em>{t('首选')}</em>}
|
||
</strong>
|
||
<small>
|
||
{row.ok
|
||
? t('{{count}} 个已验证渠道', {
|
||
count: (row.channel_ids || []).length,
|
||
})
|
||
: t(row.reason || '不可用')}
|
||
</small>
|
||
</div>
|
||
))}
|
||
</div>
|
||
{connectivity && (
|
||
<div className='expert-diagnose-connectivity'>
|
||
<h4>
|
||
{t('连通性实测')} · {connectivity.model}
|
||
</h4>
|
||
{(connectivity.results || []).map((row) => (
|
||
<div
|
||
key={row.channel_id}
|
||
className={`expert-diagnose-model ${row.success ? 'is-ok' : 'is-blocked'}`}
|
||
>
|
||
<strong>
|
||
{row.channel_name || `#${row.channel_id}`}
|
||
<em>{`#${row.channel_id}`}</em>
|
||
</strong>
|
||
<small>
|
||
{row.success
|
||
? `${t('通过')} · ${Number(row.time || 0).toFixed(2)}s`
|
||
: row.message || t('失败')}
|
||
</small>
|
||
</div>
|
||
))}
|
||
{connectivity.untested_channels > 0 && (
|
||
<p className='expert-diagnose-empty'>
|
||
{t('还有 {{count}} 个渠道未测(单次最多测 3 个)', {
|
||
count: connectivity.untested_channels,
|
||
})}
|
||
</p>
|
||
)}
|
||
</div>
|
||
)}
|
||
</div>
|
||
)}
|
||
</Modal>
|
||
<Modal
|
||
title={t('登记模型能力')}
|
||
visible={capabilityOpen}
|
||
onCancel={() => setCapabilityOpen(false)}
|
||
onOk={saveCapability}
|
||
okText={t('登记为已验证')}
|
||
confirmLoading={capabilitySaving}
|
||
width={640}
|
||
>
|
||
<div className='expert-editor-form'>
|
||
<p className='expert-editor-hint'>
|
||
{t(
|
||
'声明某个渠道能以要求的上下文与工具能力承载某个模型;云端大脑任务只会派发到已验证的「模型 × 渠道」组合。',
|
||
)}
|
||
</p>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('渠道')}
|
||
<Select
|
||
filter
|
||
disabled={capLockChannel}
|
||
value={capForm.channel_id || undefined}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
channel_id: value || 0,
|
||
}))
|
||
}
|
||
optionList={channels.map((channel) => ({
|
||
value: channel.id,
|
||
label: `#${channel.id} · ${channel.name}`,
|
||
}))}
|
||
placeholder={t('选择已启用渠道')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('模型')}
|
||
<Select
|
||
// Semi 限制:allowCreate 开启后不响应 optionList 动态更新,
|
||
// 换渠道后新模型列表会被旧空列表覆盖——用 key 强制重挂载
|
||
key={`cap-model-${capForm.channel_id}`}
|
||
filter
|
||
allowCreate
|
||
value={capForm.model_name || undefined}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
model_name: value || '',
|
||
}))
|
||
}
|
||
optionList={channelModelOptions}
|
||
placeholder={t('先选渠道,再从其模型中选择')}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('上下文窗口 (tokens)')}
|
||
<InputNumber
|
||
min={1}
|
||
value={capForm.context_window}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
context_window: Number(value) || 0,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('最大输出 (0 = 不限制)')}
|
||
<InputNumber
|
||
min={0}
|
||
value={capForm.max_output_tokens}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
max_output_tokens: Number(value) || 0,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
<label className='wide'>
|
||
{t('支持工具调用(专家挂业务系统时必须开启)')}
|
||
<Switch
|
||
checked={capForm.supports_tools}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
supports_tools: value,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
</div>
|
||
<Collapse>
|
||
<Collapse.Panel header={t('高级(可选)')} itemKey='cap-advanced'>
|
||
<div className='expert-editor-grid'>
|
||
<label>
|
||
{t('分词器')}
|
||
<Input
|
||
value={capForm.tokenizer}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
tokenizer: value,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('数据区域')}
|
||
<Input
|
||
value={capForm.data_region}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
data_region: value,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
{t('向量空间 ID')}
|
||
<InputNumber
|
||
min={0}
|
||
value={capForm.embedding_space_id}
|
||
onChange={(value) =>
|
||
setCapForm((current) => ({
|
||
...current,
|
||
embedding_space_id: Number(value) || 0,
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</Collapse.Panel>
|
||
</Collapse>
|
||
</div>
|
||
</Modal>
|
||
<Modal
|
||
title={
|
||
resolutionMode === 'adjust' ? t('追加结算调整') : t('审核对账案件')
|
||
}
|
||
visible={reconciliationOpen}
|
||
onCancel={() => setReconciliationOpen(false)}
|
||
onOk={resolveReconciliation}
|
||
okText={t('进入二次确认')}
|
||
width={680}
|
||
>
|
||
<div className='expert-modal-form'>
|
||
<Text copyable>{selectedCase?.request_id}</Text>
|
||
{selectedCase?.workload_type === 'agent-worker' &&
|
||
reconciliationRunBilling[selectedCase?.workload_id] && (
|
||
<Text type='warning'>
|
||
{t(
|
||
'“实际配额”按任务全生命周期总额录入(含先前各步已结算部分)。当前已结算',
|
||
)}
|
||
:{' '}
|
||
{
|
||
reconciliationRunBilling[selectedCase.workload_id]
|
||
.effective_quota
|
||
}{' '}
|
||
· {t('预留')}:{' '}
|
||
{
|
||
reconciliationRunBilling[selectedCase.workload_id]
|
||
.reserved_quota
|
||
}
|
||
</Text>
|
||
)}
|
||
{selectedCase?.workload_type === 'connector-write' && (
|
||
<Text type='tertiary'>
|
||
{t(
|
||
'该类案件不涉及额度结算:确认已核对远端系统结果后填写原因关闭即可。',
|
||
)}
|
||
</Text>
|
||
)}
|
||
<label
|
||
style={
|
||
selectedCase?.workload_type === 'connector-write'
|
||
? { display: 'none' }
|
||
: undefined
|
||
}
|
||
>
|
||
<Text>{t('处置类型')}</Text>
|
||
<Select
|
||
style={{ width: '100%' }}
|
||
value={resolution.resolution_type}
|
||
disabled={resolutionMode === 'adjust'}
|
||
onChange={(value) =>
|
||
setResolution((current) => ({
|
||
...current,
|
||
resolution_type: value,
|
||
actual_quota:
|
||
value === 'confirmed_zero' ? 0 : current.actual_quota,
|
||
}))
|
||
}
|
||
optionList={[
|
||
{
|
||
value: 'provider_confirmed',
|
||
label: t('供应商已确认'),
|
||
},
|
||
{ value: 'confirmed_zero', label: t('确认零用量') },
|
||
{
|
||
value: 'conservative_estimate',
|
||
label: t('保守估算'),
|
||
},
|
||
]}
|
||
/>
|
||
</label>
|
||
<label
|
||
style={
|
||
selectedCase?.workload_type === 'connector-write'
|
||
? { display: 'none' }
|
||
: undefined
|
||
}
|
||
>
|
||
<Text>{t('实际配额')}</Text>
|
||
<InputNumber
|
||
min={0}
|
||
precision={0}
|
||
style={{ width: '100%' }}
|
||
disabled={resolution.resolution_type === 'confirmed_zero'}
|
||
value={resolution.actual_quota}
|
||
onChange={(value) =>
|
||
setResolution((current) => ({
|
||
...current,
|
||
actual_quota: Number(value || 0),
|
||
}))
|
||
}
|
||
/>
|
||
</label>
|
||
<label>
|
||
<Text>{t('处置原因')}</Text>
|
||
<TextArea
|
||
autosize={{ minRows: 4, maxRows: 8 }}
|
||
maxCount={500}
|
||
value={resolution.reason}
|
||
onChange={(value) =>
|
||
setResolution((current) => ({ ...current, reason: value }))
|
||
}
|
||
placeholder={t('记录证据来源和判断依据(至少 4 个字符)')}
|
||
/>
|
||
</label>
|
||
</div>
|
||
</Modal>
|
||
<Modal
|
||
title={t('审核死信重放')}
|
||
visible={Boolean(replayTarget)}
|
||
onCancel={() => setReplayTarget(null)}
|
||
onOk={replayOutbox}
|
||
okText={t('进入二次确认')}
|
||
>
|
||
<div className='expert-modal-form'>
|
||
<Text copyable>{replayTarget?.key}</Text>
|
||
<TextArea
|
||
autosize={{ minRows: 4, maxRows: 8 }}
|
||
maxCount={500}
|
||
value={replayReason}
|
||
onChange={setReplayReason}
|
||
placeholder={t('记录目标恢复证据和重放原因(至少 4 个字符)')}
|
||
/>
|
||
</div>
|
||
</Modal>
|
||
</section>
|
||
);
|
||
};
|
||
|
||
export default ExpertPlatform;
|