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:
john
2026-08-24 15:59:17 +08:00
parent b93c92a3e2
commit d58dc2a251
45 changed files with 4972 additions and 30 deletions
+26 -5
View File
@@ -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 给 Agentschedule_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('意图路由', '简单一次性提醒走规则 preflightcreate_timed_reminder');
} else {
fail('意图路由', JSON.stringify(intent));
}