Task configuration:
{"task_id": "06", "task_name": "update_editor_type", "description": "\u5728Joplin\u4e2d\u4fee\u6539\u5f53\u524d\u754c\u9762\u4e3a\u5bcc\u6587\u672c\u7f16\u8f91\u5668", "application_info": {"name": "joplin", "executable_path": "/workspace/PC-Canary/apps/joplin/Joplin-3.3.12.AppImage", "args": ["--env", "dev", "--profile", "/workspace/PC-Canary/apps/joplin/joplindev-desktop"]}, "task_parameters": {"editor_type": "richtext"}, "instruction_template": "\u5728Joplin\u4e2d\u4fee\u6539\u5f53\u524d\u754c\u9762\u4e3a\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u6a21\u5f0f", "evaluation_setup": {"scripts": [{"role": "hook", "path": "hooker.js"}, {"role": "handler", "path": "handler.py"}], "timeout": 15, "evaluator_type": "IpcInjector", "evaluate_on_completion": true}, "total_key_steps": 1, "preconditions": {"joplin_running": true}, "events": {"evaluate_on_completion": {"description": "\u5728\u4efb\u52a1\u7ed3\u675f\u65f6\u5224\u65ad\u7f16\u8f91\u5668\u7c7b\u578b\u662f\u5426\u4e3a\u5bcc\u6587\u672c\u7f16\u8f91\u5668", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u754c\u9762\u5df2\u6210\u529f\u5207\u6362\u4e3a\u5bcc\u6587\u672c\u7f16\u8f91\u5668"}}, "mcp_servers": [{"command": "/home/user/.local/bin/uv", "args": ["--directory", "/home/user/Desktop/joplin-mcp-server", "run", "src/mcp/joplin_mcp.py"]}]}

Hook script:
// 使用 Joplin 插件 API 来处理通信
joplin.plugins.register({
    onStart: async function() {
        console.log('Joplin plugin started - Task06 Editor Type');
        
        // 监听 evaluate 事件
        socket.on("evaluate", async () => {
            console.log('Task06_updateEditorType---------------------------');
            try {
                let currentEditorType = 'markdown'; // 默认值
                
                // 尝试获取编辑器相关设置
                try {
                    // 检查是否启用了富文本编辑器
                    // 在 Joplin 中，editor.codeView 控制是否显示代码视图
                    // false 表示使用富文本/WYSIWYG 编辑器，true 表示使用 Markdown 编辑器
                    const codeViewEnabled = await joplin.settings.globalValue('editor.codeView');
                    
                    console.log('Code view enabled:', codeViewEnabled);
                    
                    // 根据设置判断当前编辑器类型
                    if (codeViewEnabled === false) {
                        currentEditorType = 'richtext';
                    } else {
                        currentEditorType = 'markdown';
                    }
                } catch (settingsError) {
                    console.error('Error reading editor settings:', settingsError);
                    
                    // 备用方案：检查当前活动的编辑器元素
                    const editorElement = document.querySelector('.ql-editor, .richtext-editor, .cm-editor');
                    if (editorElement && (editorElement.classList.contains('ql-editor') || editorElement.classList.contains('richtext-editor'))) {
                        currentEditorType = 'richtext';
                    }
                }
                
                console.log('Current editor type:', currentEditorType);
                
                // 使用 postMessage 发送评估消息
                window.postMessage({
                    "event_type": "evaluate_on_completion",
                    "message": "任务结束时Joplin的编辑器类型是" + currentEditorType,
                    "data": currentEditorType
                }, '*');
                console.log('Evaluation result sent via postMessage');
            } catch (error) {
                console.error('Error in evaluate handler:', error);
            }
        });
    }
});

Evaluation handler:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
joplin修改编辑器类型的事件处理器
负责处理钩子脚本产生的事件并更新评估指标
"""

from typing import Dict, Any, Optional, List

def message_handler(message: Dict[str, Any], logger, task_parameter: Dict[str, Any]) -> Optional[List[Dict[str, Any]]]:    
    event_type = message.get('event_type')
    logger.info(message.get('message'))
    
    # 打印完整的参数信息
    logger.info("="*50)
    logger.info("参数调试信息:")
    logger.info(f"task_parameter 类型: {type(task_parameter)}")
    logger.info(f"task_parameter 内容: {task_parameter}")
    logger.info("="*50)
    
    if event_type == "evaluate_on_completion":
        current_editor_type = message.get("data")
        expected_editor_type = task_parameter.get('editor_type', "richtext")
        
        logger.info(f"正在检测编辑器类型是否为: {expected_editor_type}")
        logger.info(f"当前Joplin编辑器类型为: {current_editor_type}")
        
        if current_editor_type == expected_editor_type:
            return [
                {"status": "key_step", "index": 1},
                {"status": "success", "reason": f"编辑器类型已经成功设置为{expected_editor_type}"}
            ]
        else:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"编辑器类型不匹配，期望：{expected_editor_type}，实际：{current_editor_type}"}]
    return None