Task configuration:
{"task_id": "16", "task_name": "append_note", "description": "\u68c0\u67e5Joplin\u4e2d\u662f\u5426\u5728\u6307\u5b9a\u7b14\u8bb0\u540e\u6dfb\u52a0\u4e86\u6307\u5b9a\u6587\u5b57", "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", "append_text": "Hello World"}, "instruction_template": "\u5728Joplin\u4e2d\u540d\u4e3a ${note_name} \u7684\u7b14\u8bb0\u540e\u6dfb\u52a0\u4e00\u6bb5\u6587\u5b57\uff1a${append_text}", "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\u7b14\u8bb0\u662f\u5426\u5305\u542b\u6dfb\u52a0\u7684\u6587\u5b57", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u7b14\u8bb0\u6dfb\u52a0\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('Task16_appendNote---------------------------');
            try {
                // 获取所有笔记
                const notes = await joplin.data.get(['notes']);
                const noteList = notes.items;
                console.log('Raw note list:', noteList);
                
                // 获取笔记内容和标题
                const notesWithContent = await Promise.all(noteList.map(async note => {
                    try {
                        // 获取笔记内容，显式指定需要获取的字段
                        const noteContent = await joplin.data.get(['notes', note.id], { fields: ['id', 'title', 'body'] });
                        console.log(`Note ${note.title} content:`, noteContent);
                        return {
                            title: note.title,
                            body: noteContent.body || ''  // 确保body字段存在
                        };
                    } catch (error) {
                        console.error(`Error getting content for note ${note.title}:`, error);
                        return {
                            title: note.title,
                            body: ''
                        };
                    }
                }));
                
                console.log('Notes with content:', notesWithContent);
                
                // 使用 postMessage 发送评估消息
                window.postMessage({
                    "event_type": "evaluate_on_completion",
                    "message": "当前笔记列表: " + notesWithContent.map(note => note.title).join(', '),
                    "data": {
                        "notes": notesWithContent
                    }
                }, '*');
                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添加笔记内容的事件处理器
负责处理钩子脚本产生的事件并更新评估指标
"""

import json
import os
from typing import Dict, Any, Optional, List

def load_config_defaults() -> Dict[str, Any]:
    """从config.json加载默认参数值"""
    config_path = os.path.join(os.path.dirname(__file__), 'config.json')
    with open(config_path, 'r', encoding='utf-8') as f:
        config = json.load(f)
    return config.get('task_parameters', {})

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", {})
        notes = data.get("notes", [])
        
        # 从config.json加载默认值
        config_defaults = load_config_defaults()
        expected_note = task_parameter.get('note_name', config_defaults.get('note_name'))
        expected_text = task_parameter.get('append_text', config_defaults.get('append_text'))
        
        # 查找指定名称的笔记
        target_note = next((note for note in notes if note.get("title") == expected_note), None)
        
        if not target_note:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"名为 {expected_note} 的笔记不存在"}]
        
        # 检查笔记内容是否包含指定文字
        note_body = target_note.get("body", "")
        if expected_text in note_body:
            return [
                {"status": "key_step", "index": 1},
                {"status": "success", "reason": f"成功在笔记 {expected_note} 中添加了文字：{expected_text}"}
            ]
        else:
            return [{"status": "error", "type": "evaluate_on_completion", "message": f"笔记 {expected_note} 中未找到指定文字：{expected_text}"}]
    return None