Files
memind/agent-side-effect-tools.test.mjs
T
john a1a921eba6 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>
2026-08-29 09:47:39 +08:00

44 lines
1.3 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
commitAgentSideEffectTool,
executeScheduledTaskUpdateSpecTool,
} from './agent-side-effect-tools.mjs';
test('executeScheduledTaskUpdateSpecTool delegates to scheduledTaskService.updateTaskSpec', async () => {
const calls = [];
const task = await executeScheduledTaskUpdateSpecTool({
taskId: 'task-1',
taskSpec: '新规范',
mergeTaskSpec: true,
}, {
userId: 'user-1',
scheduledTaskService: {
async updateTaskSpec(payload) {
calls.push(payload);
return { id: 'task-1', taskSpec: 'merged spec', title: '新闻' };
},
},
});
assert.equal(calls[0].taskId, 'task-1');
assert.equal(calls[0].mergeTaskSpec, true);
assert.equal(task.title, '新闻');
});
test('commitAgentSideEffectTool supports scheduled_task_update_spec', async () => {
const committed = await commitAgentSideEffectTool('scheduled_task_update_spec', {
taskId: 'task-1',
taskSpec: '标准格式说明',
mergeTaskSpec: true,
}, {
userId: 'user-1',
scheduledTaskService: {
async updateTaskSpec() {
return { id: 'task-1', taskSpec: '标准格式说明', status: 'active' };
},
},
});
assert.equal(committed.kind, 'scheduled_task');
assert.equal(committed.updated, true);
});