refactor(agent, shipping): 简化代理模型并完善订单抽取业务

- 移除 Agent 的 exposure_mode 与 internal_executor 相关逻辑,清理关联的过滤、序列化代码
- 删除废弃的 AgentRuntimeBinding 模型及其依赖
- 新增订单抽取上传批次、请求快照等数据库迁移与业务逻辑
- 修复附件完整性检测、订单抽取状态映射问题
- 更新多语言错误文案与前端单元测试配置
- 清理平台配置中不再使用的暴露模式配置
This commit is contained in:
hugo committed 2026-07-28 20:25:48 +08:00
1 parent 1f3ecb87b7
commit 61ac6403c4
159 files changed
+12883 -5099

No files matched your search

+19 -34
View File
@@ -68,17 +68,30 @@ export type ShippingInventoryValidationBatch = {
runs: ShippingInventoryConfigurationTest[];
};
export type ShippingOrderExtractionDiagnosticAutoFreezePolicy = {
mode: string;
enabled: boolean;
selected_profile_code?: string | null;
qualification_status?: string | null;
customer_scope_status?: string | null;
business_scenario_status?: string | null;
customer_confirmation_required: boolean;
evaluated_from_run: boolean;
blocking_reason_codes: string[];
};
export type ShippingOrderExtractionDiagnosticRun = {
run_no: string; status: string; phase: string; conversation_id: string; workflow_run_id?: string | null;
attempt_count: number; current_stage_code?: string | null; created_at?: string | null; started_at?: string | null;
finished_at?: string | null; error_code?: string | null; durations_ms: Record<string, number | null>;
run_no: string; status: string; phase: string; conversation_id: string;
attempt_count: number; current_event_code?: string | null; created_at?: string | null; started_at?: string | null;
candidate_materialized_at?: string | null; finished_at?: string | null; error_code?: string | null; durations_ms: Record<string, number | null>;
result_counts: Record<string, number>;
auto_freeze_policy: ShippingOrderExtractionDiagnosticAutoFreezePolicy;
};
export type ShippingOrderExtractionDiagnosticDetail = {
run: ShippingOrderExtractionDiagnosticRun;
job_attempts: Array<{ job_id: number; status: string; attempts: number; max_attempts: number; created_at?: string | null; started_at?: string | null; finished_at?: string | null; duration_ms?: number | null }>;
units: Array<{ unit_id: number; position: number; unit_type: string; document_type: string; status: string; attempt_count: number; duration_ms?: number | null; error_code?: string | null; route_decisions: Array<{ attempt_no: number; execution_mode: 'deterministic' | 'dify' | 'blocked'; match_status: string; selected_profile_code?: string | null; selected_profile_version?: number | null; auto_create_approved?: boolean | null; candidate_count: number; table_count: number; approved_table_count: number; candidates: Array<{ profile_code: string; version: number; score: number; hard_match: boolean; reason_codes: string[]; missing_required_anchor_ids?: string[] }>; fallback_reason_codes: string[] }> }>;
progress_events: Array<{ event_type: string; node_type?: string | null; stage_code?: string | null; status?: string | null; workflow_run_id?: string | null; node_execution_id?: string | null; occurred_at?: string | null }>;
units: Array<{ unit_id: number; position: number; unit_type: string; document_type: string; status: string; attempt_count: number; duration_ms?: number | null; error_code?: string | null; route_decisions: Array<{ attempt_no: number; execution_mode: 'deterministic' | 'review_required' | 'skipped'; match_status: string; selected_profile_code?: string | null; selected_profile_version?: number | null; auto_create_approved?: boolean | null; candidate_count: number; table_count: number; approved_table_count: number; candidates: Array<{ profile_code: string; version: number; score: number; hard_match: boolean; reason_codes: string[]; missing_required_anchor_ids?: string[] }>; fallback_reason_codes: string[] }> }>;
progress_events: Array<{ sequence_no: number; visibility: 'workspace' | 'admin'; event_code: string; status?: string | null; unit_id?: number | null; document_id?: number | null; reason_code?: string | null; summary?: Record<string, unknown> | null; occurred_at?: string | null }>;
};
export const listShippingOrderExtractionDiagnosticRuns = (page = 1, pageSize = 25, status = '') => {
const params = new URLSearchParams({ page: String(page), page_size: String(pageSize) });
@@ -429,7 +442,6 @@ export interface AdminAgentRegistrySchema {
runtime_providers: string[];
conversation_modes: string[];
dify_app_types: string[];
exposure_modes: string[];
suggested_questions_styles: string[];
default_capabilities: Record<string, boolean>;
tool_run_progress_defaults: {
@@ -451,14 +463,6 @@ export interface AdminAgentRegistrySchema {
default_intent_routes?: string[];
progress_contract?: Record<string, unknown> | null;
handler_config_schema?: Record<string, unknown>;
required_runtime_capabilities?: Record<string, {
label?: string;
required?: boolean;
allowed_runtime_providers?: string[];
allowed_dify_app_types?: string[];
allowed_exposure_modes?: string[];
allowed_effective_roles?: string[];
}>;
}>;
handler_config_schemas: Record<string, unknown>;
content_profile_keys: string[];
@@ -501,30 +505,11 @@ export interface AdminContentProfileOption {
export const listAdminContentProfiles = () =>
requestJson<AdminContentProfileOption[]>('/api/admin/agents/content-profiles', auth());
export const listAdminAgents = (scope?: 'applications' | 'executors') => requestJson<any[]>(
`/api/admin/agents${scope ? `?scope=${scope}` : ''}`,
auth(),
);
export const listAdminAgents = () => requestJson<any[]>('/api/admin/agents', auth());
export const createAdminAgent = (payload: Record<string, unknown>) =>
requestJson('/api/admin/agents', { method: 'POST', ...jsonAuth(), body: JSON.stringify(payload) });
export const updateAdminAgent = (id: number, payload: Record<string, unknown>) =>
requestJson(`/api/admin/agents/${id}`, { method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload) });
export const listAdminAgentRuntimeBindings = (agentId: number) =>
requestJson<import('@/features/admin/types/agent.types').AgentRuntimeBindingRow[]>(
`/api/admin/agents/${agentId}/runtime-bindings`, auth(),
);
export const listApprovedOrderExtractionQualityBatches = (ownerAgentId: number) =>
requestJson<import('@/features/admin/types/agent.types').OrderExtractionQualityBatchOption[]>(
`/api/admin/shipping-notice/order-extraction-quality-batches?owner_agent_id=${ownerAgentId}`, auth(),
);
export const saveAdminAgentRuntimeBinding = (
agentId: number,
capabilityCode: string,
payload: { provider_agent_id: number; enabled: boolean; config: Record<string, unknown> },
) => requestJson<import('@/features/admin/types/agent.types').AgentRuntimeBindingRow>(
`/api/admin/agents/${agentId}/runtime-bindings/${capabilityCode}`,
{ method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload) },
);
export const deleteAdminAgent = (id: number) =>
requestJson(`/api/admin/agents/${id}`, { method: 'DELETE', ...auth() });
@@ -73,25 +73,14 @@ const {
resetColumnWidths,
} = useAgentsTableColumnResize();
const tableHeaderColumns = computed(() => (
activeManagementTab.value === 'executors'
? [
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
{ key: 'executorType', label: t('admin.agent.headers.executorType'), align: 'left' as const },
{ key: 'protocol', label: t('admin.agent.headers.runtimeProtocol'), align: 'left' as const },
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
]
: [
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
]
));
const tableHeaderColumns = computed(() => [
{ key: 'name', label: t('admin.agent.headers.name'), align: 'left' as const },
{ key: 'type', label: t('admin.agent.headers.type'), align: 'left' as const },
{ key: 'aggregation', label: t('admin.agent.headers.aggregation'), align: 'left' as const },
{ key: 'config', label: t('admin.agent.headers.config'), align: 'left' as const },
{ key: 'status', label: t('admin.agent.headers.status'), align: 'left' as const },
{ key: 'actions', label: t('admin.agent.headers.actions'), align: 'right' as const },
]);
const formatAgentCode = (agent: AgentRow) => agent.agent_code || 'generic';
@@ -144,17 +133,6 @@ const formatRuntimeProviderLabel = (agent: AgentRow) => {
};
const showFormDialog = ref(false);
const activeManagementTab = ref<'applications' | 'executors'>('applications');
const visibleAgents = computed(() => agents.value.filter((agent) => (
activeManagementTab.value === 'executors'
? agent.exposure_mode === 'internal'
: agent.exposure_mode !== 'internal'
)));
const emptyStateText = computed(() => (
activeManagementTab.value === 'executors'
? t('admin.agent.executor.empty')
: t('admin.agent.noAgents')
));
/**
* 打开新建应用弹窗并重置表单状态。
@@ -165,16 +143,6 @@ const openCreateDialog = (): void => {
showFormDialog.value = true;
};
const formatExecutorProtocol = (agent: AgentRow) => (
`${formatRuntimeProviderLabel(agent)} · ${agent.dify_app_type === 'workflow' ? 'Workflow' : 'Chatflow'}`
);
/** 打开内部执行器专用注册入口,预置 Dify Workflow 与 internal 可见性。 */
const openCreateInternalExecutorDialog = (): void => {
resetForm('internal_executor');
showFormDialog.value = true;
};
/**
* 打开编辑应用弹窗并载入当前行数据。
* 核心逻辑:复用 selectAgent 的表单映射逻辑,确保列表行、权限弹窗和保存接口使用同一份状态。
@@ -210,41 +178,16 @@ onMounted(() => {
<h2 class="section-title">{{ t('admin.agent.title') }}</h2>
<p class="section-desc mt-1">{{ t('admin.agent.subtitle') }}</p>
</div>
<div class="flex gap-2">
<button v-if="activeManagementTab === 'executors'" type="button" class="btn-primary" @click="openCreateInternalExecutorDialog">
<Plus class="w-5 h-5" />
<span class="font-medium">{{ t('admin.agent.newInternalExecutor') }}</span>
</button>
<button v-else type="button" class="btn-primary" @click="openCreateDialog">
<Plus class="w-5 h-5" />
<span class="font-medium">{{ t('admin.agent.new') }}</span>
</button>
</div>
</div>
<div class="mb-6 flex gap-1 border-b border-default">
<button
type="button"
class="-mb-px border-b-2 px-4 py-2.5 text-sm font-medium transition-colors"
:class="activeManagementTab === 'applications' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
@click="activeManagementTab = 'applications'"
>
{{ t('admin.agent.tabs.applications') }}
</button>
<button
type="button"
class="-mb-px border-b-2 px-4 py-2.5 text-sm font-medium transition-colors"
:class="activeManagementTab === 'executors' ? 'border-brand-600 text-brand-600' : 'border-transparent text-muted hover:text-secondary'"
@click="activeManagementTab = 'executors'"
>
{{ t('admin.agent.tabs.executors') }}
<button type="button" class="btn-primary" @click="openCreateDialog">
<Plus class="w-5 h-5" />
<span class="font-medium">{{ t('admin.agent.new') }}</span>
</button>
</div>
<div class="admin-table-wrap">
<div v-if="visibleAgents.length === 0" class="admin-table-empty">
<div v-if="agents.length === 0" class="admin-table-empty">
<Bot class="w-12 h-12 mx-auto text-muted mb-3" />
<p class="text-lg text-secondary">{{ emptyStateText }}</p>
<p class="text-lg text-secondary">{{ t('admin.agent.noAgents') }}</p>
</div>
<table
v-else
@@ -280,7 +223,7 @@ onMounted(() => {
</thead>
<tbody>
<tr
v-for="agent in visibleAgents"
v-for="agent in agents"
:key="agent.id"
class="group cursor-pointer"
:class="{ 'bg-blue-50/50': selectedAgentId === agent.id }"
@@ -300,22 +243,16 @@ onMounted(() => {
</td>
<td class="px-4 py-4 align-middle">
<div class="agent-list-cell">
<p class="truncate text-sm text-primary" :title="activeManagementTab === 'executors' ? agent.name : formatAgentTypeLabel(agent)">
{{ activeManagementTab === 'executors' ? t('admin.agent.executor.workflowExecutor') : formatAgentTypeLabel(agent) }}
<p class="truncate text-sm text-primary" :title="formatAgentTypeLabel(agent)">
{{ formatAgentTypeLabel(agent) }}
</p>
<p class="truncate text-xs text-muted" :title="formatRuntimeProviderLabel(agent)">
{{ activeManagementTab === 'executors' ? t('admin.agent.executor.internalOnly') : formatRuntimeProviderLabel(agent) }}
{{ formatRuntimeProviderLabel(agent) }}
</p>
</div>
</td>
<td class="px-4 py-4 align-middle">
<div v-if="activeManagementTab === 'executors'" class="agent-list-cell">
<p class="truncate text-sm font-medium text-primary" :title="formatExecutorProtocol(agent)">
{{ formatExecutorProtocol(agent) }}
</p>
<p class="truncate text-xs text-muted">{{ t('admin.agent.executor.internalOnly') }}</p>
</div>
<div v-else class="agent-list-cell">
<div class="agent-list-cell">
<p
class="truncate text-sm font-medium"
:class="agent.is_aggregate ? 'text-brand-700' : 'text-secondary'"
@@ -364,7 +301,6 @@ onMounted(() => {
{{ t('admin.edit') }}
</button>
<button
v-if="agent.exposure_mode !== 'internal'"
type="button"
class="inline-flex shrink-0 items-center justify-center p-2 text-blue-600 bg-blue-50 hover:bg-blue-100 rounded-lg transition-all"
:title="t('admin.agent.manageAccess')"
@@ -66,16 +66,6 @@ const directoryMemberSearch = ref('');
const showDifyFields = computed(() => props.form.runtime_provider === 'dify' || props.form.runtime_provider === 'hybrid');
const showIframeFields = computed(() => props.form.runtime_provider === 'iframe');
const isInternalExecutor = computed(() => props.form.exposure_mode === 'internal');
const dialogTitle = computed(() => {
if (isInternalExecutor.value) {
return props.isEditing ? t('admin.agent.editInternalExecutor') : t('admin.agent.createInternalExecutor');
}
return props.isEditing ? t('admin.agent.edit') : t('admin.agent.create');
});
const dialogSubtitle = computed(() => (
isInternalExecutor.value ? t('admin.agent.executor.formSubtitle') : t('admin.agent.subtitle')
));
const showToolRunProgress = computed(() => (
showDifyFields.value
&& props.form.dify_app_type !== 'workflow'
@@ -218,18 +208,6 @@ watch(
},
);
watch(
() => props.form.exposure_mode,
(exposure) => {
if (exposure === 'internal') {
props.form.runtime_provider = 'dify';
props.form.dify_app_type = 'workflow';
props.form.conversation_mode = 'task_chat';
props.form.welcome_message = '';
props.form.suggested_questions = [];
}
},
);
watch(
() => props.form.is_aggregate,
@@ -282,8 +260,8 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
<div class="flex max-h-[92vh] w-full max-w-5xl flex-col overflow-hidden rounded-2xl border border-default bg-surface shadow-2xl">
<div class="flex items-start justify-between gap-4 border-b border-default px-6 py-5">
<div>
<h3 class="section-title">{{ dialogTitle }}</h3>
<p class="section-desc mt-1">{{ dialogSubtitle }}</p>
<h3 class="section-title">{{ isEditing ? t('admin.agent.edit') : t('admin.agent.create') }}</h3>
<p class="section-desc mt-1">{{ t('admin.agent.subtitle') }}</p>
</div>
<button type="button" class="btn-icon-ds shrink-0" @click="emit('close')">
<X class="h-5 w-5" />
@@ -301,7 +279,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
:placeholder="t('admin.agent.fields.namePlaceholder')"
/>
</div>
<div v-if="!isInternalExecutor" class="space-y-2">
<div class="space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.agentCode') }}</label>
<select v-model="form.agent_code" class="w-full input-field text-sm" @change="handleAgentCodeChange">
<option v-for="entry in typeCatalog" :key="entry.agent_code" :value="entry.agent_code">
@@ -309,7 +287,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</option>
</select>
</div>
<div v-if="!isInternalExecutor" class="space-y-2">
<div class="space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.runtimeProvider') }}</label>
<select v-model="form.runtime_provider" class="w-full input-field text-sm">
<option v-for="provider in runtimeProviders" :key="provider" :value="provider">
@@ -317,7 +295,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</option>
</select>
</div>
<div v-if="!isInternalExecutor" class="space-y-2">
<div class="space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.conversationMode') }}</label>
<select v-model="form.conversation_mode" class="w-full input-field text-sm">
<option v-for="mode in conversationModes" :key="mode" :value="mode">
@@ -326,9 +304,9 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</select>
</div>
<template v-if="showDifyFields">
<div v-if="!isInternalExecutor" class="space-y-2">
<div class="space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">Dify应用类型</label>
<select v-model="form.dify_app_type" class="w-full input-field text-sm" :disabled="isInternalExecutor">
<select v-model="form.dify_app_type" class="w-full input-field text-sm">
<option value="chatflow">Chatflow</option>
<option value="workflow">Workflow</option>
</select>
@@ -356,15 +334,6 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</div>
</template>
<div v-if="isInternalExecutor" class="col-span-1 md:col-span-2 rounded-xl border border-default bg-surface-soft p-4">
<div class="mb-4"><h4 class="text-sm font-semibold text-primary">{{ t('admin.agent.runtimeBinding.executorGovernance') }}</h4></div>
<div class="grid grid-cols-1 gap-4 md:grid-cols-3">
<div class="space-y-2"><label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.runtimeBinding.providerMaxConcurrency') }}</label><input v-model.number="form.executor_provider_max_concurrency" type="number" min="1" max="20" class="w-full input-field text-sm" /></div>
<div class="space-y-2"><label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.runtimeBinding.circuitFailureThreshold') }}</label><input v-model.number="form.executor_circuit_failure_threshold" type="number" min="2" max="20" class="w-full input-field text-sm" /></div>
<div class="space-y-2"><label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.runtimeBinding.circuitCooldown') }}</label><input v-model.number="form.executor_circuit_cooldown_seconds" type="number" min="10" max="600" class="w-full input-field text-sm" /></div>
</div>
</div>
<template v-if="showIframeFields">
<div class="col-span-1 md:col-span-2 space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.iframeUrl') }}</label>
@@ -372,7 +341,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</div>
</template>
<div v-if="!isInternalExecutor" class="col-span-1 md:col-span-2 space-y-2">
<div class="col-span-1 md:col-span-2 space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.description') }}</label>
<input
v-model="form.description"
@@ -382,7 +351,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
/>
</div>
<div v-if="!isInternalExecutor" class="col-span-1 md:col-span-2 space-y-2">
<div class="col-span-1 md:col-span-2 space-y-2">
<label class="text-xs font-bold text-muted uppercase tracking-wider">{{ t('admin.agent.fields.welcomeMessage') }}</label>
<textarea
v-model="form.welcome_message"
@@ -392,7 +361,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
/>
</div>
<div v-if="!isInternalExecutor" class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
<div>
<div class="flex items-center gap-2 text-xs font-bold uppercase tracking-wider text-muted">
@@ -476,7 +445,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</div>
<div
v-if="showIntentFastPathSection && !isInternalExecutor"
v-if="showIntentFastPathSection"
class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4"
>
<div class="mb-4">
@@ -590,12 +559,11 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</div>
<AgentCapabilitiesConfig
v-if="!isInternalExecutor"
:form="form"
:catalog-entry="currentCatalogEntry"
/>
<div v-if="!isInternalExecutor" class="col-span-1 md:col-span-2 space-y-3">
<div class="col-span-1 md:col-span-2 space-y-3">
<div class="flex flex-wrap items-center justify-between gap-3">
<label class="text-xs font-bold text-muted uppercase tracking-wider">常见问题</label>
<button
@@ -655,7 +623,7 @@ const handleTrainingQuestionTypeChange = (form: AgentFormState, index: number) =
</div>
</div>
<div v-if="!isInternalExecutor" class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
<div class="col-span-1 md:col-span-2 rounded-2xl border border-default bg-surface-soft/40 p-4">
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
<div>
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('admin.agent.training.title') }}</div>
@@ -310,13 +310,7 @@ export function useAgentsAdmin() {
const loadAgents = async (): Promise<void> => {
try {
const [applications, executors] = await Promise.all([
listAdminAgents('applications'),
listAdminAgents('executors'),
]);
const byId = new Map<number, AgentRow>();
[...applications, ...executors].forEach((agent) => byId.set(Number(agent.id), agent));
agents.value = [...byId.values()].sort((a, b) => Number(a.id) - Number(b.id));
agents.value = await listAdminAgents();
} catch (e) {
console.error('Error loading agents:', e);
agents.value = [];
@@ -370,18 +364,10 @@ export function useAgentsAdmin() {
isLoading.value = false;
};
const resetForm = (mode: 'user_agent' | 'internal_executor' = 'user_agent'): void => {
const resetForm = (): void => {
selectedAgentId.value = null;
form.value = createEmptyAgentForm(defaultCapabilities());
applyCatalogDefaultsToForm(form.value, typeCatalog.value[0]);
if (mode === 'internal_executor') {
form.value.exposure_mode = 'internal';
form.value.runtime_provider = 'dify';
form.value.dify_app_type = 'workflow';
form.value.conversation_mode = 'task_chat';
form.value.welcome_message = '';
form.value.suggested_questions = [];
}
trainingExamPdfGuides.value = [];
isEditing.value = false;
};
@@ -403,10 +389,6 @@ export function useAgentsAdmin() {
}
isEditing.value = true;
void loadTrainingExamPdfGuides(agent.id);
const governance = asRecord(extra.order_extraction_governance);
form.value.executor_provider_max_concurrency = Number(governance.provider_max_concurrency || 4);
form.value.executor_circuit_failure_threshold = Number(governance.circuit_failure_threshold || 5);
form.value.executor_circuit_cooldown_seconds = Number(governance.circuit_cooldown_seconds || 60);
};
const openDeleteConfirm = (
@@ -507,15 +489,6 @@ export function useAgentsAdmin() {
trainingExtraPatch: {},
typeCatalog: typeCatalog.value,
});
registryPayload.exposure_mode = form.value.exposure_mode;
if (form.value.exposure_mode === 'internal') {
extra_config.order_extraction_governance = {
provider_max_concurrency: form.value.executor_provider_max_concurrency,
circuit_failure_threshold: form.value.executor_circuit_failure_threshold,
circuit_cooldown_seconds: form.value.executor_circuit_cooldown_seconds,
};
registryPayload.extra_config = extra_config;
}
try {
const editingId = isEditing.value ? Number(form.value.id) : null;
@@ -47,14 +47,6 @@ export interface AgentTypeCatalogEntry {
progress_contract?: ProgressContract | null;
handler_config_schema?: Record<string, unknown>;
required_runtime_capabilities?: Record<string, {
label?: string;
required?: boolean;
allowed_runtime_providers?: string[];
allowed_dify_app_types?: string[];
allowed_exposure_modes?: string[];
allowed_effective_roles?: string[];
}>;
}
@@ -394,8 +386,6 @@ export function mapAgentRowToForm(
conversation_mode: agent.conversation_mode || 'chat',
dify_app_type: agent.dify_app_type === 'workflow' ? 'workflow' : 'chatflow',
exposure_mode: agent.exposure_mode === 'internal' ? 'internal' : 'workspace',
effective_role: agent.effective_role === 'internal_executor' ? 'internal_executor' : 'user_agent',
api_base_url: agent.api_base_url || '',
@@ -543,7 +533,6 @@ export function buildAgentRegistryPayload(
conversation_mode: form.conversation_mode,
dify_app_type: form.dify_app_type,
exposure_mode: form.exposure_mode,
dify_app_id: form.dify_app_id,
@@ -95,7 +95,7 @@ export function usePermissionsAdmin() {
const loadAgents = async (): Promise<void> => {
try {
agents.value = await listAdminAgents('applications');
agents.value = await listAdminAgents();
} catch (e) {
console.error('Failed to load agents', e);
agents.value = [];
@@ -31,7 +31,7 @@ const uploadError = ref('');
const fetchAgents = async () => {
try {
agents.value = await listAdminAgents('applications');
agents.value = await listAdminAgents();
if (agents.value.length > 0) {
selectedAgentId.value = agents.value[0].id;
await fetchGuides();
@@ -65,7 +65,7 @@ export function useHotFaqCandidates() {
const loadAgents = async (): Promise<void> => {
try {
agents.value = await listAdminAgents('applications');
agents.value = await listAdminAgents();
} catch {
agents.value = [];
}
@@ -72,7 +72,7 @@ export function useQuestionsAdmin() {
const loadAgents = async (): Promise<void> => {
try {
agents.value = await listAdminAgents('applications');
agents.value = await listAdminAgents();
} catch (e) {
console.error('Failed to load agents', e);
agents.value = [];
@@ -27,6 +27,8 @@ const error = ref('');
const formatTime = (value?: string | null) => value ? new Date(value).toLocaleString() : '-';
const formatDuration = (value?: number | null) => value == null ? '-' : `${(value / 1000).toFixed(value < 10000 ? 1 : 0)} s`;
const translateAutoFreezeReason = (code: string) =>
t(`admin.shippingOrderExtractionRuns.autoFreezeReasonCodes.${code}`, code);
/** 加载安全摘要;服务端已完成管理员鉴权、审计及敏感字段剔除。 */
const load = async () => {
@@ -82,7 +84,7 @@ onMounted(() => { void load(); });
{{ t('admin.shippingOrderExtractionRuns.status') }}
<select v-model="status" class="rounded-md border border-default bg-surface px-2 py-1.5" @change="applyStatus">
<option value="">{{ t('admin.shippingOrderExtractionRuns.allStatuses') }}</option>
<option v-for="value in ['queued', 'running', 'result_persisted', 'completed', 'needs_review', 'failed', 'cancelled']" :key="value" :value="value">
<option v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']" :key="value" :value="value">
{{ t(`admin.shippingOrderExtractionRuns.statuses.${value}`) }}
</option>
</select>
@@ -98,7 +100,7 @@ onMounted(() => { void load(); });
</tr></thead>
<tbody><tr v-if="loading"><td colspan="7" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</td></tr>
<tr v-else-if="!rows.length"><td colspan="7" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</td></tr>
<tr v-for="row in rows" :key="row.run_no" class="border-b border-default last:border-0"><td class="px-4 py-3 font-mono text-xs">{{ row.run_no }}</td><td class="px-4 py-3">{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}</td><td class="px-4 py-3">{{ row.current_stage_code || '-' }}</td><td class="px-4 py-3">{{ row.attempt_count }}</td><td class="px-4 py-3">{{ formatTime(row.created_at) }}</td><td class="px-4 py-3">{{ formatDuration(row.durations_ms.total) }}</td><td class="px-4 py-3"><button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.run_no)">{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}</button></td></tr>
<tr v-for="row in rows" :key="row.run_no" class="border-b border-default last:border-0"><td class="px-4 py-3 font-mono text-xs">{{ row.run_no }}</td><td class="px-4 py-3">{{ t(`admin.shippingOrderExtractionRuns.statuses.${row.status}`) }}</td><td class="px-4 py-3">{{ row.current_event_code || '-' }}</td><td class="px-4 py-3">{{ row.attempt_count }}</td><td class="px-4 py-3">{{ formatTime(row.created_at) }}</td><td class="px-4 py-3">{{ formatDuration(row.durations_ms.total) }}</td><td class="px-4 py-3"><button type="button" class="text-brand-600 hover:underline" @click="openDetail(row.run_no)">{{ t('admin.shippingOrderExtractionRuns.viewDetail') }}</button></td></tr>
</tbody>
</table>
</div>
@@ -108,12 +110,44 @@ onMounted(() => { void load(); });
<aside class="h-full w-full max-w-2xl overflow-y-auto bg-surface p-6 shadow-2xl">
<div class="flex items-center justify-between"><h2 class="text-lg font-bold">{{ t('admin.shippingOrderExtractionRuns.detailTitle') }}</h2><button type="button" class="text-secondary" @click="detail = null">{{ t('admin.close') }}</button></div>
<p v-if="detailLoading" class="mt-6 text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</p>
<template v-else-if="detail"><dl class="mt-5 grid grid-cols-2 gap-3 text-sm"><dt>{{ t('admin.shippingOrderExtractionRuns.runNo') }}</dt><dd class="font-mono text-xs">{{ detail.run.run_no }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.workflowRunId') }}</dt><dd class="font-mono text-xs">{{ detail.run.workflow_run_id || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.errorCode') }}</dt><dd>{{ detail.run.error_code || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</dt><dd>{{ formatDuration(detail.run.durations_ms.total) }}</dd></dl>
<template v-else-if="detail"><dl class="mt-5 grid grid-cols-2 gap-3 text-sm"><dt>{{ t('admin.shippingOrderExtractionRuns.runNo') }}</dt><dd class="font-mono text-xs">{{ detail.run.run_no }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.currentEvent') }}</dt><dd class="font-mono text-xs">{{ detail.run.current_event_code || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.candidateMaterializedAt') }}</dt><dd>{{ formatTime(detail.run.candidate_materialized_at) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.errorCode') }}</dt><dd>{{ detail.run.error_code || '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</dt><dd>{{ formatDuration(detail.run.durations_ms.total) }}</dd></dl>
<section class="mt-6 rounded-lg border border-default p-4 text-sm">
<div class="font-semibold">{{ t('admin.shippingOrderExtractionRuns.autoFreezePolicy') }}</div>
<dl class="mt-3 grid grid-cols-2 gap-x-3 gap-y-2">
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeEnabled') }}</dt>
<dd>{{ t(detail.run.auto_freeze_policy.enabled ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeMode') }}</dt>
<dd>{{ t(`admin.shippingOrderExtractionRuns.autoFreezeModes.${detail.run.auto_freeze_policy.mode}`) }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeQualificationStatus') }}</dt>
<dd>{{ detail.run.auto_freeze_policy.qualification_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeQualificationStatuses.${detail.run.auto_freeze_policy.qualification_status}`) : '-' }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeProfile') }}</dt>
<dd>{{ detail.run.auto_freeze_policy.selected_profile_code || '-' }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatus') }}</dt>
<dd>{{ detail.run.auto_freeze_policy.customer_scope_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeCustomerScopeStatuses.${detail.run.auto_freeze_policy.customer_scope_status}`) : '-' }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatus') }}</dt>
<dd>{{ detail.run.auto_freeze_policy.business_scenario_status ? t(`admin.shippingOrderExtractionRuns.autoFreezeBusinessScenarioStatuses.${detail.run.auto_freeze_policy.business_scenario_status}`) : '-' }}</dd>
<dt>{{ t('admin.shippingOrderExtractionRuns.autoFreezeCustomerConfirmation') }}</dt>
<dd>{{ t(detail.run.auto_freeze_policy.customer_confirmation_required ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd>
</dl>
<div class="mt-3">
<div class="text-xs font-medium text-secondary">{{ t('admin.shippingOrderExtractionRuns.autoFreezeBlockingReasons') }}</div>
<div v-if="detail.run.auto_freeze_policy.blocking_reason_codes.length" class="mt-2 flex flex-wrap gap-2">
<span
v-for="code in detail.run.auto_freeze_policy.blocking_reason_codes"
:key="code"
class="rounded-full border border-default px-2 py-1 text-xs text-secondary"
>
{{ translateAutoFreezeReason(code) }}
</span>
</div>
<div v-else class="mt-2 text-xs text-muted">{{ t('admin.shippingOrderExtractionRuns.autoFreezeNoBlockingReasons') }}</div>
</div>
</section>
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3><div class="mt-2 space-y-2"><div v-for="job in detail.job_attempts" :key="job.job_id" class="rounded-lg border border-default p-3 text-sm"><b>#{{ job.job_id }}</b> · {{ job.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ job.attempts }}/{{ job.max_attempts }} · {{ formatDuration(job.duration_ms) }}</div><p v-if="!detail.job_attempts.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.units') }}</h3><div class="mt-2 space-y-2"><div v-for="unit in detail.units" :key="unit.unit_id" class="rounded-lg border border-default p-3 text-sm"><b>#{{ unit.position + 1 }} {{ unit.unit_type }}</b> · {{ unit.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ unit.attempt_count }} · {{ formatDuration(unit.duration_ms) }}<span v-if="unit.error_code" class="ml-2 font-mono text-xs text-danger">{{ unit.error_code }}</span>
<section v-for="route in unit.route_decisions" :key="`${unit.unit_id}:${route.attempt_no}`" class="mt-3 rounded border border-default bg-slate-50 p-3 text-xs dark:bg-slate-900/40"><h4 class="font-semibold text-primary">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ route.attempt_no }}</h4><dl class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1"><dt>{{ t('admin.shippingOrderExtractionRuns.executionMode') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.executionModes.${route.execution_mode}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.matchStatus') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${route.match_status}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.selectedProfile') }}</dt><dd>{{ route.selected_profile_code ? `${route.selected_profile_code} V${route.selected_profile_version}` : '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.autoCreateApproved') }}</dt><dd>{{ route.auto_create_approved == null ? '-' : t(route.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.fallbackReasons') }}</dt><dd>{{ route.fallback_reason_codes.length ? route.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}</dd></dl><div v-if="route.candidates.length" class="mt-3"><p class="font-medium">{{ t('admin.shippingOrderExtractionRuns.candidates') }}</p><div v-for="candidate in route.candidates" :key="`${candidate.profile_code}:${candidate.version}`" class="mt-1 flex flex-wrap gap-x-2 text-muted"><span>{{ candidate.profile_code }} V{{ candidate.version }}</span><span>{{ candidate.score.toFixed(2) }}</span><span>{{ candidate.hard_match ? t('admin.shippingOrderExtractionRuns.hardMatch') : t('admin.shippingOrderExtractionRuns.hardMismatch') }}</span><span v-if="candidate.missing_required_anchor_ids?.length">{{ t('admin.shippingOrderExtractionRuns.missingAnchors', { ids: candidate.missing_required_anchor_ids.join(', ') }) }}</span></div></div></section>
</div><p v-if="!detail.units.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3><div class="mt-2 space-y-2"><div v-for="event in detail.progress_events" :key="`${event.node_execution_id}:${event.event_type}:${event.occurred_at}`" class="rounded-lg border border-default p-3 text-sm"><b>{{ event.stage_code || event.event_type }}</b><span class="ml-2 text-secondary">{{ event.status || '-' }}</span><span class="ml-2 font-mono text-xs text-muted">{{ event.node_type || '-' }}</span><time class="ml-2 text-xs text-muted">{{ formatTime(event.occurred_at) }}</time></div><p v-if="!detail.progress_events.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3><div class="mt-2 space-y-2"><div v-for="event in detail.progress_events" :key="`${event.sequence_no}:${event.event_code}`" class="rounded-lg border border-default p-3 text-sm"><b>{{ event.event_code }}</b><span class="ml-2 text-secondary">{{ event.status || '-' }}</span><span class="ml-2 font-mono text-xs text-muted">{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span><span v-if="event.reason_code" class="ml-2 font-mono text-xs text-muted">{{ event.reason_code }}</span><time class="ml-2 text-xs text-muted">{{ formatTime(event.occurred_at) }}</time></div><p v-if="!detail.progress_events.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
</template>
</aside>
</div>
@@ -128,7 +128,7 @@ export function useUsersAdmin() {
const loadAgents = async (): Promise<void> => {
try {
agents.value = await listAdminAgents('applications');
agents.value = await listAdminAgents();
} catch (e) {
console.error('Error loading agents:', e);
agents.value = [];
@@ -7,7 +7,6 @@ import type { TrainingQuestionType } from '@/features/chat/training/training.typ
export type AgentRuntimeProvider = 'dify' | 'builtin' | 'hybrid' | 'iframe';
export type AgentConversationMode = 'chat' | 'task_chat' | 'embedded';
export type AgentExposureMode = 'workspace' | 'internal';
export interface AgentCapabilities {
streaming: boolean;
@@ -33,8 +32,6 @@ export interface AgentRow {
runtime_provider?: AgentRuntimeProvider;
conversation_mode?: AgentConversationMode;
dify_app_type?: 'chatflow' | 'workflow';
exposure_mode?: AgentExposureMode;
effective_role?: 'user_agent' | 'internal_executor';
api_base_url?: string;
iframe_url?: string;
welcome_message?: string | null;
@@ -104,8 +101,6 @@ export interface AgentFormState {
runtime_provider: AgentRuntimeProvider;
conversation_mode: AgentConversationMode;
dify_app_type: 'chatflow' | 'workflow';
exposure_mode: AgentExposureMode;
effective_role?: 'user_agent' | 'internal_executor';
api_base_url: string;
iframe_url: string;
welcome_message: string;
@@ -132,9 +127,6 @@ export interface AgentFormState {
training_hr_chat_questions_text: string;
training_question_bank: AgentTrainingQuestionFormItem[];
directory_member_ids: number[];
executor_provider_max_concurrency: number;
executor_circuit_failure_threshold: number;
executor_circuit_cooldown_seconds: number;
}
export const createEmptyTrainingQuestionForm = (): AgentTrainingQuestionFormItem => ({
@@ -158,7 +150,6 @@ export const createEmptyAgentForm = (
runtime_provider: 'dify',
conversation_mode: 'chat',
dify_app_type: 'chatflow',
exposure_mode: 'workspace',
api_base_url: '',
iframe_url: '',
welcome_message: '',
@@ -194,31 +185,4 @@ export const createEmptyAgentForm = (
training_hr_chat_questions_text: '',
training_question_bank: [],
directory_member_ids: [],
executor_provider_max_concurrency: 4,
executor_circuit_failure_threshold: 5,
executor_circuit_cooldown_seconds: 60,
});
export interface OrderExtractionQualityBatchOption {
id: number;
batch_no: string;
approved_at: string | null;
metrics: {
agreed_sample_count: number;
precision: number;
recall: number;
eligible: boolean;
};
}
export interface AgentRuntimeBindingRow {
id: number;
owner_agent_id: number;
capability_code: string;
provider_agent_id: number;
enabled: boolean;
config: {
timeout_seconds?: number;
max_attempts?: number;
};
}
@@ -65,6 +65,12 @@ export interface ShippingOrderDocumentProfile {
qualification_id: number | null;
parser_version?: string;
quality_suite_id?: number | null;
customer_ids?: number[];
business_scenarios?: string[];
customer_scope_configured?: boolean;
business_scenario_scope_configured?: boolean;
requires_customer_confirmation?: boolean;
scope_updated_at?: string | null;
};
}