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

@@ -72,7 +72,12 @@ export interface ShippingSendHandlerContext {
hasSelectedNoticeCandidates?: () => boolean;
openShippingDuplicateDialog?: (attachmentId?: string) => void;
getParsedIntakeNos?: () => string[];
startOrderExtractionRun?: (query: string, intakeNos: string[], attachments: ReturnType<typeof createChatMessageAttachmentSnapshots>) => Promise<boolean>;
startOrderExtractionRun?: (
query: string,
intakeNos: string[],
attachments: ReturnType<typeof createChatMessageAttachmentSnapshots>,
uploadBatchId?: string,
) => Promise<boolean>;
applyShippingMessageRecovery?: (message: ChatMessage) => Promise<boolean>;
applyShippingBatchSnapshot?: (message: ChatMessage) => boolean;
syncShippingConversationWorkspace: (options?: { preferLatest?: boolean }) => Promise<boolean>;
@@ -214,14 +219,33 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
}
const intakeNos = ctx.getParsedIntakeNos?.() || [];
if (intakeNos.length) {
const userAttachments = createChatMessageAttachmentSnapshots(noticeItems);
const query = trimmed || ctx.t('chat.shippingOrderExtractionDefaultPrompt');
const submittedIntakes = new Set(intakeNos.map((item) => item.trim().toUpperCase()));
const batchIds = new Set(
noticeItems
.filter((item) => item.intakeNo && submittedIntakes.has(item.intakeNo.trim().toUpperCase()))
.map((item) => String(item.uploadBatchId || '').trim())
.filter(Boolean),
);
if (batchIds.size > 1) {
ctx.msg.warning('当前发送批次不一致,请重新上传需要一起识别的文件');
return true;
}
const userAttachments = createChatMessageAttachmentSnapshots(
noticeItems.filter((item) =>
item.intakeNo
&& submittedIntakes.has(item.intakeNo.trim().toUpperCase()),
),
);
// 阶段 2:发送是“授权开始识别”,备注允许为空,不能再偷偷注入默认提示词。
const query = trimmed;
ctx.shippingAutoFlowRequested.value = false;
if (typeof textOrEvent !== 'string') ctx.input.value = '';
try {
const started = await ctx.startOrderExtractionRun?.(query, intakeNos, userAttachments);
const uploadBatchId = [...batchIds][0];
const started = uploadBatchId
? await ctx.startOrderExtractionRun?.(query, intakeNos, userAttachments, uploadBatchId)
: await ctx.startOrderExtractionRun?.(query, intakeNos, userAttachments);
if (!started) return true;
const submittedIntakes = new Set(intakeNos.map((item) => item.trim().toUpperCase()));
ctx.attachments.value = ctx.attachments.value.filter(
(item) => item.kind !== 'shipping_notice'
|| !item.intakeNo