feat(wechat): add Intent Transaction Layer with unified task schema
Introduce Draft → Confirm → Commit flow for WeChat schedule intents behind feature flags, plus h5_tasks dual-write/read aggregation and rollout scripts so reminders and automations get explicit user confirmation before persisting. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -184,19 +184,40 @@ async function testWechatHandlerIsolation() {
|
||||
}
|
||||
|
||||
const agentReply = await handleWechatScheduleIntent({
|
||||
intent: { agentText: '今天10点提醒我吃药', msgId: 'msg-agent' },
|
||||
intent: { agentText: '明天早上六点去跑步,五点半提醒我', msgId: 'msg-agent' },
|
||||
user: { userId: 'user-1' },
|
||||
scheduleService,
|
||||
});
|
||||
if (agentReply === null) {
|
||||
pass('服务号一次性提醒', '仍 fall through 给 Agent(schedule_agent)');
|
||||
pass('服务号复杂提醒', '仍 fall through 给 Agent(多时间点)');
|
||||
} else {
|
||||
fail('服务号一次性提醒', `expected null, got ${agentReply}`);
|
||||
fail('服务号复杂提醒', `expected null, got ${agentReply}`);
|
||||
}
|
||||
|
||||
const directReply = await handleWechatScheduleIntent({
|
||||
intent: { agentText: '今天10点提醒我吃药', msgId: 'msg-direct' },
|
||||
user: { userId: 'user-1' },
|
||||
scheduleService: {
|
||||
...scheduleService,
|
||||
async createItem(payload) {
|
||||
calls.push(['createItem', payload.title]);
|
||||
return { id: 'item-direct', ...payload };
|
||||
},
|
||||
async createReminder(payload) {
|
||||
calls.push(['createReminder', payload.itemId]);
|
||||
return { id: 'reminder-direct', ...payload };
|
||||
},
|
||||
},
|
||||
});
|
||||
if (directReply?.includes('已设置提醒') && calls.some((entry) => entry[0] === 'createReminder')) {
|
||||
pass('服务号简单提醒', '规则路径直接 createItem + createReminder');
|
||||
} else {
|
||||
fail('服务号简单提醒', JSON.stringify({ directReply, calls }));
|
||||
}
|
||||
|
||||
const intent = parseScheduleIntent('今天10点提醒我吃药');
|
||||
if (shouldUseScheduleAssistant('今天10点提醒我吃药')) {
|
||||
pass('意图路由', `一次性提醒走 Agent 路径(parseScheduleIntent=${intent.action},由 prompt 加载 schedule-assistant)`);
|
||||
if (intent.action === 'create_timed_reminder') {
|
||||
pass('意图路由', '简单一次性提醒走规则 preflight(create_timed_reminder)');
|
||||
} else {
|
||||
fail('意图路由', JSON.stringify(intent));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user