Add smart ACK provider for WeChat MP replies

Replace fixed ackText with a rule-based AckProvider that picks
response templates by message type and intent (translate, summary,
rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync,
zero I/O, auto-falls back to config.ackText on any error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
john
2026-06-26 15:19:03 +08:00
parent 9ed4fd48d7
commit 9b4a25799f
162 changed files with 17276 additions and 2054 deletions
+60
View File
@@ -52,3 +52,63 @@ test('schedule reminder worker sends due daily todo digest', async () => {
assert.deepEqual(sent, [{ userId: 'user-1', text: '6月18日 待办记录\n\n1. 开会' }]);
assert.deepEqual(calls, ['list', 'lock:sub-1', 'digest:user-1', 'log:success', 'sent:sub-1']);
});
test('schedule reminder worker sends due balance alert for same user only', async () => {
const sent = [];
const alerts = [];
const worker = startScheduleReminderWorker({
intervalMs: 60_000,
scheduleService: {
async listDueDigestSubscriptions() {
return [];
},
async lockDigestSubscription() {
return null;
},
async listDueBalanceAlerts() {
return [
{
id: 'alert-1',
userId: 'user-1',
thresholdCents: 2000,
channel: 'wechat',
attempts: 0,
},
];
},
async lockBalanceAlert(id) {
return { id, userId: 'user-1', thresholdCents: 2000, channel: 'wechat', attempts: 0 };
},
async getUserWalletSnapshot(userId) {
return userId === 'user-1' ? { balanceCents: 1500 } : { balanceCents: 9999 };
},
async logDelivery(input) {
alerts.push(`log:${input.status}:${input.userId}`);
},
async markBalanceAlertSent(input) {
alerts.push(`sent:${input.id}`);
},
async markBalanceAlertFailed() {
alerts.push('failed');
},
async buildTodoDigestText() {
return '';
},
async markDigestSent() {},
async markDigestFailed() {},
},
async sendWechatTextToUser(userId, text) {
sent.push({ userId, text });
},
logger: { warn() {} },
runOnStart: false,
});
await worker.runOnce();
worker.stop();
assert.deepEqual(sent, [
{ userId: 'user-1', text: '余额不足提醒\n\n你的账户余额已低于 20.00 元,请及时充值。' },
]);
assert.deepEqual(alerts, ['log:success:user-1', 'sent:alert-1']);
});