set_task_config/set_list_config now echo which fields were set vs cleared, get_list_config/get_task_config return an explicit found=false instead of null, and delete_list/run_task_now/reset_failed_task/remove_task_attachment return a confirmation record — matching the found/ok convention already used by batch_get_tasks and get_task_log.
35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using System.ComponentModel;
|
|
using ClaudeDo.Data.Repositories;
|
|
using ClaudeDo.Worker.Lifecycle;
|
|
using ModelContextProtocol.Server;
|
|
using TaskStatus = ClaudeDo.Data.Models.TaskStatus;
|
|
|
|
namespace ClaudeDo.Worker.External;
|
|
|
|
public sealed record ResetFailedTaskResult(bool Reset, string TaskId);
|
|
|
|
[McpServerToolType]
|
|
public sealed class LifecycleMcpTools
|
|
{
|
|
private readonly TaskRepository _tasks;
|
|
private readonly TaskResetService _reset;
|
|
|
|
public LifecycleMcpTools(TaskRepository tasks, TaskResetService reset)
|
|
{
|
|
_tasks = tasks;
|
|
_reset = reset;
|
|
}
|
|
|
|
[McpServerTool, Description("Reset a failed task: discards its worktree and returns it to Idle so it can be run again. Only Failed tasks are accepted. Returns { reset: true, taskId } on success.")]
|
|
public async Task<ResetFailedTaskResult> ResetFailedTask(string taskId, CancellationToken cancellationToken)
|
|
{
|
|
var task = await _tasks.GetByIdAsync(taskId, cancellationToken)
|
|
?? throw new InvalidOperationException($"Task {taskId} not found.");
|
|
if (task.Status != TaskStatus.Failed)
|
|
throw new InvalidOperationException($"Task {taskId} is {task.Status}, not Failed. Only failed tasks can be reset via this tool.");
|
|
|
|
await _reset.ResetAsync(taskId, cancellationToken);
|
|
return new ResetFailedTaskResult(true, taskId);
|
|
}
|
|
}
|