Task configuration:
{"task_id": "10", "task_name": "check_todo_status", "description": "\u68c0\u67e5Joplin\u4e2d\u6307\u5b9a\u5f85\u529e\u4e8b\u9879\u662f\u5426\u5df2\u5b8c\u6210", "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": {"todo_content": "new_todo"}, "instruction_template": "\u5728Joplin\u4e2d\uff0c\u901a\u8fc7\u590d\u9009\u6846\u5c06\u9898\u76ee\u4e3a ${todo_content} \u7684\u5f85\u529e\u4e8b\u9879\u8bbe\u7f6e\u4e3a\u5df2\u5b8c\u6210", "evaluation_setup": {"scripts": [{"role": "hook", "path": "hooker.js"}, {"role": "handler", "path": "handler.py"}], "timeout": 120, "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\u6307\u5b9a\u5f85\u529e\u4e8b\u9879\u662f\u5426\u5df2\u5b8c\u6210", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u5f85\u529e\u4e8b\u9879\u72b6\u6001\u68c0\u67e5\u5b8c\u6210"}}, "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');
        
        // 获取待办事项列表的函数
        async function evaluateTodos() {
            try {
                // 获取所有待办事项
                const todos = await joplin.data.get(['notes'], {
                    fields: ['title', 'is_todo', 'todo_completed'],
                    page: 1,
                });
                const todoList = todos.items
                    .filter(note => note.is_todo)
                    .map(todo => ({
                        title: todo.title,
                        todo_completed: todo.todo_completed
                    }));
                
                console.log('Current todos:', todoList);
                
                // 使用 postMessage 发送评估消息
                window.postMessage({
                    "event_type": "evaluate_on_completion",
                    "message": "当前待办事项列表: " + todoList.map(t => `${t.title}(${t.todo_completed ? '已完成' : '未完成'})`).join(', '),
                    "data": {
                        "todos": todoList
                    }
                }, '*');
                console.log('Evaluation result sent via postMessage');
            } catch (error) {
                console.error('Error in evaluate handler:', error);
            }
        }
        
        // 监听 evaluate 事件
        socket.on("evaluate", async () => {
            console.log('Task10_checkTodoStatus---------------------------');
            await evaluateTodos();
        });
    }
}); 

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'))
    
    if event_type == "evaluate_on_completion":
        data = message.get("data", {})
        todo_list = data.get("todos", [])
        
        expected_content = task_parameter.get('todo_content', "test_todo")
        
        # 查找指定内容的待办事项
        target_todo = next((todo for todo in todo_list if todo['title'] == expected_content), None)
        
        if target_todo is None:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"未找到内容为 {expected_content} 的待办事项"}]
        
        # 检查待办事项是否已完成
        if target_todo['todo_completed']:
            return [
                {"status": "key_step", "index": 1},
                {"status": "success", "reason": f"待办事项 {expected_content} 已完成"}
            ]
        else:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"待办事项 {expected_content} 未完成"}]
    return None