fix(wechat): route scheduled task cancel and spec updates through Goose MCP
Pass cancel requests to Goose like create instead of inbound title matching, and add scheduled_task_update_spec so format or execution constraints update taskSpec without triggering page delivery guards. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -275,3 +275,67 @@ test('markTaskSucceeded schedules next run for daily task', async () => {
|
||||
assert.ok(result.nextRunAt > Date.parse('2026-07-31T02:00:00+08:00'));
|
||||
assert.equal(updates.length, 1);
|
||||
});
|
||||
|
||||
test('updateTaskSpec replaces or merges taskSpec', async () => {
|
||||
const activeTask = {
|
||||
id: 'task-news',
|
||||
user_id: 'user-1',
|
||||
title: '每日新闻早报页面(5:30)',
|
||||
task_spec: '按旧格式生成新闻页',
|
||||
recurrence: 'daily',
|
||||
hour: 5,
|
||||
minute: 30,
|
||||
weekday: null,
|
||||
timezone: 'Asia/Shanghai',
|
||||
next_run_at: 1780000000000,
|
||||
last_run_at: null,
|
||||
notify_channel: 'both',
|
||||
status: 'active',
|
||||
attempts: 0,
|
||||
last_error: null,
|
||||
last_result_json: null,
|
||||
source_channel: 'agent',
|
||||
source_session_id: null,
|
||||
source_message_id: null,
|
||||
source_text: null,
|
||||
created_at: 1780000000000,
|
||||
updated_at: 1780000000000,
|
||||
};
|
||||
let stored = { ...activeTask };
|
||||
const service = createScheduledTaskService({
|
||||
async query(sql, params) {
|
||||
if (sql.includes('FROM h5_scheduled_tasks') && sql.includes('status IN')) {
|
||||
return [[stored]];
|
||||
}
|
||||
if (sql.includes('UPDATE h5_scheduled_tasks') && sql.includes('task_spec')) {
|
||||
stored = {
|
||||
...stored,
|
||||
task_spec: params[0],
|
||||
title: params[1],
|
||||
updated_at: params[2],
|
||||
};
|
||||
return [{ affectedRows: 1 }];
|
||||
}
|
||||
if (sql.includes('SELECT * FROM h5_scheduled_tasks WHERE id = ? LIMIT 1')) {
|
||||
return [[stored]];
|
||||
}
|
||||
return [[]];
|
||||
},
|
||||
});
|
||||
|
||||
const merged = await service.updateTaskSpec({
|
||||
userId: 'user-1',
|
||||
taskId: 'task-news',
|
||||
taskSpec: '参照 daily-news-0829.html 作为标准格式',
|
||||
mergeTaskSpec: true,
|
||||
});
|
||||
assert.match(merged.taskSpec, /旧格式/u);
|
||||
assert.match(merged.taskSpec, /daily-news-0829/u);
|
||||
|
||||
const replaced = await service.updateTaskSpec({
|
||||
userId: 'user-1',
|
||||
taskId: 'task-news',
|
||||
taskSpec: '全新执行说明',
|
||||
});
|
||||
assert.equal(replaced.taskSpec, '全新执行说明');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user