Task configuration:
{"task_id": "17", "task_name": "restore_note", "description": "\u68c0\u67e5Joplin\u4e2d\u662f\u5426\u4ece\u56de\u6536\u7ad9\u6062\u590d\u4e86\u6307\u5b9a\u540d\u79f0\u7684\u7b14\u8bb0", "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": {"note_name": "test_note"}, "instruction_template": "\u5728Joplin\u4e2d\u4ece\u56de\u6536\u7ad9\u6062\u590d\u540d\u4e3a ${note_name} \u7684\u7b14\u8bb0", "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\u540d\u79f0\u7684\u7b14\u8bb0\u662f\u5426\u5df2\u4ece\u56de\u6536\u7ad9\u6062\u590d", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u7b14\u8bb0\u6062\u590d\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');
        
        // 监听 evaluate 事件
        socket.on("evaluate", async () => {
            console.log('Task17_restoreNote---------------------------');
            try {
                // 获取所有笔记（包括已删除的笔记）
                const notes = await joplin.data.get(['notes'], {
                    fields: ['id', 'title', 'deleted_time']
                });
                const noteList = notes.items;
                
                // 分离当前笔记和已删除笔记
                const currentNotes = noteList
                    .filter(note => !note.deleted_time)
                    .map(note => note.title);
                
                const deletedNotes = noteList
                    .filter(note => note.deleted_time)
                    .map(note => note.title);
                
                console.log('Current notes:', currentNotes);
                console.log('Deleted notes:', deletedNotes);
                
                // 使用 postMessage 发送评估消息
                window.postMessage({
                    "event_type": "evaluate_on_completion",
                    "message": "当前笔记列表: " + currentNotes.join(', '),
                    "data": {
                        "notes": currentNotes,
                        "deleted_notes": deletedNotes
                    }
                }, '*');
            } 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'))
    
    if event_type == "evaluate_on_completion":
        data = message.get("data", {})
        current_notes = data.get("notes", [])
        deleted_notes = data.get("deleted_notes", [])
        
        expected_note = task_parameter.get('note_name', "test_note")
        
        # 检查笔记是否已从回收站恢复（即在当前笔记列表中，且不在已删除笔记列表中）
        if expected_note in current_notes and expected_note not in deleted_notes:
            return [
                {"status": "key_step", "index": 1},
                {"status": "success", "reason": f"成功从回收站恢复了名为 {expected_note} 的笔记"}
            ]
        elif expected_note in deleted_notes:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"名为 {expected_note} 的笔记仍在回收站中"}]
        else:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"名为 {expected_note} 的笔记不存在"}]
    return None