Files
memind/agent-side-effect-tools.test.mjs
T

44 lines
1.3 KiB
JavaScript
Raw Normal View History

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);
});