/**
 * Validation for MCP server task definitions.
 */
/**
 * Validate that an MCP task definition has all required fields.
 */
export function validateMCPTask(task) {
    const errors = [];
    if (!task.id) {
        errors.push({ field: "id", message: "Task ID is required" });
    }
    if (!task.title) {
        errors.push({ field: "title", message: "Task title is required" });
    }
    if (task.serverConfig) {
        const { transport, command, url } = task.serverConfig;
        if (transport === "stdio" && !command) {
            errors.push({
                field: "serverConfig.command",
                message: "Server command is required for stdio transport (e.g., 'node dist/server.js')",
            });
        }
        if ((transport === "sse" || transport === "streamable-http") && !url) {
            errors.push({
                field: "serverConfig.url",
                message: `Server URL is required for ${transport} transport`,
            });
        }
    }
    // Assertions should reference MCP-compatible types
    if (task.assertions) {
        for (const assertion of task.assertions) {
            if (assertion.type === "tool-called" &&
                !("value" in assertion && assertion.value)) {
                errors.push({
                    field: "assertions",
                    message: 'tool-called assertion requires a "value" specifying the tool name',
                });
            }
        }
    }
    return errors;
}
