fix(scheduled-task): enable worker by default and add WeChat preflight
Memind CI / Test, build, and release guards (push) Has been cancelled

Scheduled automations were saved but never executed because the worker
required an explicit env flag. Follow H5_REMINDER_WORKER_ENABLED when unset,
add WeChat preflight to write tasks deterministically, and surface worker
warnings on create.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-10 19:32:09 +08:00
parent 2313d76eed
commit 049d8a6f80
17 changed files with 602 additions and 14 deletions
+44
View File
@@ -1,8 +1,11 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import {
buildScheduledTaskCreatePayload,
extractScheduledTaskSpec,
isScheduledTaskIntent,
parseScheduledTaskIntent,
resolveOnceRunAtLocal,
shouldUseScheduledTaskAutomation,
} from './scheduled-task-intent.mjs';
import { shouldUseScheduleAssistant } from './schedule-intent.mjs';
@@ -12,6 +15,10 @@ test('detects daily news page automation intent', () => {
const intent = parseScheduledTaskIntent('每天6点帮我做今日新闻页面');
assert.equal(intent.action, 'create_scheduled_task');
assert.equal(intent.recurrence, 'daily');
assert.equal(intent.hour, 6);
assert.equal(intent.minute, 0);
assert.match(intent.taskSpec, /今日新闻页面/u);
assert.equal(intent.needsClarification, undefined);
});
test('detects explicit scheduled task phrase', () => {
@@ -42,6 +49,43 @@ test('parses cancel and list intents', () => {
assert.equal(parseScheduledTaskIntent('看看我的定时自动任务').action, 'list_scheduled_tasks');
});
test('parses one-shot tonight schedule with task spec', () => {
const intent = parseScheduledTaskIntent('我想创建一个定时执行任务,今晚 21:45 分执行做新闻页面');
assert.equal(intent.action, 'create_scheduled_task');
assert.equal(intent.recurrence, 'once');
assert.match(intent.runAtLocal, /^\d{4}-\d{2}-\d{2} 21:45$/);
assert.match(intent.taskSpec, /新闻页面/u);
});
test('buildScheduledTaskCreatePayload maps parsed intent', () => {
const intent = parseScheduledTaskIntent('每天6点帮我做今日新闻页面');
const payload = buildScheduledTaskCreatePayload(intent, {
userId: 'user-1',
sourceMessageId: 'msg-1',
sourceText: '每天6点帮我做今日新闻页面',
});
assert.equal(payload.userId, 'user-1');
assert.equal(payload.recurrence, 'daily');
assert.equal(payload.hour, 6);
assert.match(payload.taskSpec, /今日新闻页面/u);
});
test('extractScheduledTaskSpec keeps executable content', () => {
assert.match(
extractScheduledTaskSpec('每天6点帮我做今日新闻页面'),
/今日新闻页面/u,
);
});
test('resolveOnceRunAtLocal returns future local datetime', () => {
const now = Date.parse('2026-08-11T10:00:00+08:00');
const runAtLocal = resolveOnceRunAtLocal('今晚 21:45 做新闻页', '今晚21:45做新闻页', {
timezone: 'Asia/Shanghai',
now,
});
assert.match(runAtLocal, /^2026-08-11 21:45$/);
});
test('isScheduledTaskIntent excludes none', () => {
assert.equal(isScheduledTaskIntent({ action: 'create_scheduled_task' }), true);
assert.equal(isScheduledTaskIntent({ action: 'none' }), false);