Skip to main content
Glama
verifyTask.ts3.7 kB
import { z } from "zod"; import { UUID_V4_REGEX } from "../../utils/regex.js"; import { getTaskById, updateTaskStatus, updateTaskSummary, } from "../../models/taskModel.js"; import { TaskStatus } from "../../types/index.js"; import { getVerifyTaskPrompt } from "../../prompts/index.js"; // 檢驗任務工具 // Task verification tool export const verifyTaskSchema = z.object({ taskId: z .string() .regex(UUID_V4_REGEX, { message: "任務ID格式無效,請提供有效的UUID v4格式", // message: "Invalid task ID format, please provide a valid UUID v4 format", }) .describe("待驗證任務的唯一標識符,必須是系統中存在的有效任務ID"), // .describe("Unique identifier of the task to be verified, must be a valid task ID that exists in the system") summary: z .string() .min(30, { message: "最少30個字", // message: "Minimum 30 characters", }) .describe( "當分數高於或等於 80分時代表任務完成摘要,簡潔描述實施結果和重要決策,當分數低於 80分時代表缺失或需要修正的部分說明,最少30個字" // "When score is 80 or above, this represents task completion summary, briefly describing implementation results and important decisions. When score is below 80, this represents missing or parts that need correction, minimum 30 characters" ), score: z .number() .min(0, { message: "分數不能小於0" }) // .min(0, { message: "Score cannot be less than 0" }) .max(100, { message: "分數不能大於100" }) // .max(100, { message: "Score cannot be greater than 100" }) .describe("針對任務的評分,當評分等於或超過80分時自動完成任務"), // .describe("Score for the task, automatically completes task when score equals or exceeds 80") }); export async function verifyTask({ taskId, summary, score, }: z.infer<typeof verifyTaskSchema>) { const task = await getTaskById(taskId); if (!task) { return { content: [ { type: "text" as const, text: `## 系統錯誤\n\n找不到ID為 \`${taskId}\` 的任務。請使用「list_tasks」工具確認有效的任務ID後再試。`, // text: `## System Error\n\nCannot find task with ID \`${taskId}\`. Please use the "list_tasks" tool to confirm a valid task ID and try again.`, }, ], isError: true, }; } if (task.status !== TaskStatus.IN_PROGRESS) { return { content: [ { type: "text" as const, text: `## 狀態錯誤\n\n任務 "${task.name}" (ID: \`${task.id}\`) 當前狀態為 "${task.status}",不處於進行中狀態,無法進行檢驗。\n\n只有狀態為「進行中」的任務才能進行檢驗。請先使用「execute_task」工具開始任務執行。`, // text: `## Status Error\n\nTask "${task.name}" (ID: \`${task.id}\`) current status is "${task.status}", not in progress state, cannot be verified.\n\nOnly tasks with "In Progress" status can be verified. Please use the "execute_task" tool to start task execution first.`, }, ], isError: true, }; } if (score >= 80) { // 更新任務狀態為已完成,並添加摘要 // Update task status to completed and add summary await updateTaskSummary(taskId, summary); await updateTaskStatus(taskId, TaskStatus.COMPLETED); } // 使用prompt生成器獲取最終prompt // Use prompt generator to get final prompt const prompt = await getVerifyTaskPrompt({ task, score, summary }); return { content: [ { type: "text" as const, text: prompt, }, ], }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cjo4m06/mcp-shrimp-task-manager'

If you have feedback or need assistance with the MCP directory API, please join our Discord server