Task configuration:
{"task_id": "task02_add_sub_collection", "task_name": "add_sub_collection", "description": "\u5728Zotero\u5206\u7c7b\u4e2d\u4e2d\u6dfb\u52a0\u5b50\u5206\u7c7b", "application_info": {"type": "electron", "name": "zotero", "executable_path": "apps/zotero/app/scripts/build_and_run", "args": ["-r"]}, "task_parameters": {"sub_collection_name": "libos"}, "instruction": "\u5728\u6253\u5f00\u7684zotero\u4e2d\u7684 `MyLibrary` \u7684 `virtualization`\u5206\u7c7b\u4e2d\u6dfb\u52a0\u5b50\u5206\u7c7b\u4e3a `Type-1 Hyperviso`\uff0c\u5982\u679c\u6ca1\u6709`virtualization`\u5206\u7c7b\uff0c\u5219\u5148\u6dfb\u52a0`virtualization`\u5206\u7c7b", "preconditions": {"zotero_running": true}, "instruction_template": "\u5728\u6253\u5f00\u7684zotero\u4e2d\u7684 `MyLibrary` \u7684 `virtualization`\u5206\u7c7b\u4e2d\u6dfb\u52a0\u5b50\u5206\u7c7b\u4e3a `${sub_collection_name}`\uff0c\u5982\u679c\u6ca1\u6709`virtualization`\u5206\u7c7b\uff0c\u5219\u5148\u6dfb\u52a0`virtualization`\u5206\u7c7b", "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, "events": {"sub_collection_added": {"description": "\u6210\u529f\u6dfb\u52a0\u5b50\u5206\u7c7b", "is_key_step": true, "key_step_index": 1, "key_step_name": "\u6210\u529f\u6dfb\u52a0\u5b50\u5206\u7c7b"}}, "mcp_servers": [{"cwd": "/home/agent/zotero-mcp", "command": "uv", "args": ["run", "zotero-mcp"], "env": {"ZOTERO_LOCAL": "true"}}], "pre_process": {"command": "python", "args": ["/home/agent/agent-demo/PC-Canary/tests/tasks/zotero/task02_add_sub_collection/pre_process.py"]}, "context_data": [{"from": "tests/context_data/zotero/task02_add_sub_collection/Zotero", "to": "/home/agent/Zotero"}, {"from": "tests/context_data/zotero/task02_add_sub_collection/.zotero", "to": "/home/agent/.zotero"}]}

Hook script:
// // hookClient.js
// const http = require('http');
// const { URL } = require('url');

// // 基础配置
// const SERVER_HOST = 'localhost';
// const SERVER_PORT = 5001;

// function sendRequest(path, params = {}) {
//     return new Promise((resolve, reject) => {
//         const url = new URL(`http://${SERVER_HOST}:${SERVER_PORT}/${path}`);
//         Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));

//         http.get(url, (res) => {
//             let data = '';
//             res.on('data', chunk => data += chunk);
//             res.on('end', () => resolve(JSON.parse(data)));
//         }).on('error', reject);
//     });
// }

// // 启用 Hook
// async function enableHook(hookName) {
//     return sendRequest(`call/${hookName}`);
// }

// // 禁用 Hook
// async function disableHook(hookName) {
//     return sendRequest(`stop/${hookName}`);
// }

// // 使用示例
// (async () => {
//     try {
//         // 启用 hookAddCollection
//         const enableResult = await enableHook('hookAddSubCollection');
//         console.log('启用结果:', enableResult);
//     } catch (err) {
//         console.error('操作失败:', err);
//     }
// })();

Evaluation handler:
import os
import json
import time
from typing import Dict, Any, Optional, Callable, List
import shutil
import sqlite3
import platform

def message_handler(message: Dict[str, Any], logger: Any, task_parameter: Dict[str, Any]) -> Optional[List[Dict[str, Any]]]:
    event_type = message.get('event_type')
    if event_type == 'sub_collection_added':
        if check_libos_in_virtualization():
            return [
                {"status": "key_step", "index": 1},
                {"status": "success", "reason": "libos 子分类已成功添加"}
            ]
        else:
            return None
    else:
        return [
            {"status": "error", "type": "evaluate_on_completion", "message": "任务没有完成"}
        ]

# 根据操作系统找到 Zotero 数据库路径
def get_zotero_db_path():
    system = platform.system()
    home = os.path.expanduser("~")
    
    if system == 'Windows':
        return os.path.join(home, 'Zotero', 'zotero.sqlite')
    elif system == 'Darwin':  # macOS
        return os.path.join(home, 'Zotero', 'zotero.sqlite')
    elif system == 'Linux':
        return os.path.join(home, 'Zotero', 'zotero.sqlite')
    else:
        raise Exception("不支持的操作系统")

# 检查 virtualization 分类下是否有 libos 子分类
def check_libos_in_virtualization():
    try:
        # 获取原始数据库路径
        original_db_path = get_zotero_db_path()
        if not os.path.exists(original_db_path):
            print(f"Zotero 数据库文件未找到: {original_db_path}")
            return False
        
        # 创建临时数据库副本
        temp_db_path = original_db_path + ".temp"
        print(f"创建数据库临时副本: {temp_db_path}")
        shutil.copy2(original_db_path, temp_db_path)
        
        try:
            # 连接到临时数据库副本
            conn = sqlite3.connect(temp_db_path)
            cursor = conn.cursor()
            
            # 首先找到 virtualization 分类的 ID
            cursor.execute("""
                SELECT collectionID 
                FROM collections 
                WHERE collectionName LIKE '%virtualization%'
            """)
            
            virtualization_ids = cursor.fetchall()
            
            if not virtualization_ids:
                print("未找到 virtualization 分类")
                return False
            
            # 检查是否有任何 virtualization 分类包含 libos 子分类
            has_libos = False
            
            for virtualization_id in virtualization_ids:
                vid = virtualization_id[0]
                
                # 查找该 virtualization 分类下名为 libos 的子分类
                cursor.execute("""
                    SELECT COUNT(*) 
                    FROM collections 
                    WHERE parentCollectionID = ? AND collectionName LIKE '%libos%'
                """, (vid,))
                
                count = cursor.fetchone()[0]
                
                if count > 0:
                    print(f"在 virtualization 分类 (ID: {vid}) 下找到了 libos 子分类")
                    has_libos = True
                    break
            
            conn.close()
            return has_libos
            
        except sqlite3.Error as e:
            print(f"查询数据库时出错: {e}")
            return False
            
        finally:
            # 无论查询是否成功，都删除临时数据库
            if os.path.exists(temp_db_path):
                try:
                    os.remove(temp_db_path)
                    print(f"已删除临时数据库副本")
                except OSError as e:
                    print(f"删除临时数据库时出错: {e}")
    
    except Exception as e:
        print(f"检查 libos 子分类时出错: {e}")
        return False