forked from wangziqi/gongxue-base
feat(ai): 业务上下文感知与 A2UI 链路统一
- 新增代码内业务上下文元数据层(实体字典 + 三大闭环工作流) - 新增 get_business_context / get_entity_schema / get_pending_tasks 运行时工具 - SYSTEM_PROMPT 与技能目录改为先查业务流程/待办再执行 - A2UI 增加 ai_a2ui_submissions 幂等表、表单过期、ui.artifact 事件 - 提交回灌携带 submissionId / fieldErrors / 下一步建议 - 前端 uiArtifacts 归一化与过期表单禁用
This commit is contained in:
@@ -78,6 +78,52 @@ describe('AI chat history mapper', () => {
|
||||
expect(mapped.message.forms?.[0]).toMatchObject({ id: 'form-9', title: '新增学生' });
|
||||
});
|
||||
|
||||
it('restores uiArtifacts from message metadata and derives legacy lists', () => {
|
||||
const mapped = mapHistoryMessage({
|
||||
id: 8,
|
||||
role: 'assistant',
|
||||
content: '请处理',
|
||||
reasoningContent: null,
|
||||
status: 'completed',
|
||||
errorCode: null,
|
||||
createdAt: '2026-07-23T00:00:00.000Z',
|
||||
metadata: {
|
||||
uiArtifacts: [
|
||||
{
|
||||
id: 'form-10',
|
||||
type: 'form',
|
||||
status: 'submitted',
|
||||
messageId: 8,
|
||||
conversationId: 3,
|
||||
payload: {
|
||||
id: 'form-10',
|
||||
title: '新增学生',
|
||||
status: 'submitted',
|
||||
fields: [],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'review-10',
|
||||
type: 'review',
|
||||
status: 'expired',
|
||||
messageId: 8,
|
||||
conversationId: 3,
|
||||
payload: {
|
||||
id: 'review-10',
|
||||
title: '旧预览',
|
||||
status: 'expired',
|
||||
sections: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(mapped.message.uiArtifacts).toHaveLength(2);
|
||||
expect(mapped.message.forms?.[0]).toMatchObject({ id: 'form-10', status: 'submitted' });
|
||||
expect(mapped.message.reviews?.[0]).toMatchObject({ id: 'review-10', status: 'expired' });
|
||||
});
|
||||
|
||||
it('restores a persisted A2UI review from message metadata', () => {
|
||||
const mapped = mapHistoryMessage({
|
||||
id: 6,
|
||||
|
||||
Reference in New Issue
Block a user