From 83b28bb5e75978358beceeee0b8719e44b961b61 Mon Sep 17 00:00:00 2001 From: foxhui Date: Thu, 22 Jan 2026 03:17:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20LMA=20=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 8 + src/backend/adapter/lmarena.js | 89 +++++---- src/backend/adapter/lmarena_text.js | 290 ++++++++++++++-------------- src/backend/engine/utils.js | 35 +++- 4 files changed, 237 insertions(+), 185 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55c8485..4a2aec9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.4.9] - 2026-01-22 + +### 🐛 Fixed +- **LMA 超时问题** + - 修复 LMArena 因模型选择界面更新导致的点击超时 +- **提示词输入** + - 长提示词粘贴之前模拟输入时将回车当换行符使用导致误触发送提示词 + ## [3.4.8] - 2026-01-19 ### 🔄 Changed diff --git a/src/backend/adapter/lmarena.js b/src/backend/adapter/lmarena.js index fc7de5b..842b192 100644 --- a/src/backend/adapter/lmarena.js +++ b/src/backend/adapter/lmarena.js @@ -64,17 +64,22 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) { // 2. 选择模型 if (modelId) { logger.debug('适配器', `选择模型: ${modelId}`, meta); - const modelCombobox = page.locator('#chat-area') - .locator('button[role="combobox"][aria-haspopup="dialog"]') - .last(); + // 使用键盘导航展开模型选择框:按两次 Shift+Tab 然后 Enter + await page.keyboard.down('Shift'); + await page.keyboard.press('Tab'); + await page.keyboard.press('Tab'); + await page.keyboard.up('Shift'); + await sleep(100, 200); + await page.keyboard.press('Enter'); - await modelCombobox.waitFor({ state: 'visible', timeout: 10000 }); - await safeClick(page, modelCombobox, { bias: 'button' }); + // 获取模型配置,优先使用 codeName,否则使用 id + const modelConfig = manifest.models.find(m => m.id === modelId); + const searchText = modelConfig?.codeName || modelId; - // 模拟粘贴输入模型 ID + // 模拟粘贴输入模型名称 await page.evaluate((text) => { document.execCommand('insertText', false, text); - }, modelId); + }, searchText); // 等待下拉选项出现后再按回车 try { @@ -191,41 +196,41 @@ export const manifest = { // 模型列表 models: [ - { id: 'gemini-3-pro-image-preview-2k', codeName: '019abc10-e78d-7932-b725-7f1563ed8a12', imagePolicy: 'optional' }, - { id: 'gemini-3-pro-image-preview', codeName: '019aa208-5c19-7162-ae3b-0a9ddbb1e16a', imagePolicy: 'optional' }, - { id: 'hunyuan-image-3.0', codeName: '7766a45c-1b6b-4fb8-9823-2557291e1ddd', imagePolicy: 'forbidden' }, - { id: 'vidu-q2-image', codeName: '019adb32-afa4-749e-9992-39653b52fe13', imagePolicy: 'optional' }, - { id: 'mai-image-1', codeName: '1b407d5c-1806-477c-90a5-e5c5a114f3bc', imagePolicy: 'forbidden' }, - { id: 'imagen-4.0-fast-generate-001', codeName: 'f44fd4f8-af30-480f-8ce2-80b2bdfea55e', imagePolicy: 'forbidden' }, - { id: 'flux-2-pro', codeName: '019abcf4-5600-7a8b-864d-9b8ab7ab7328', imagePolicy: 'optional' }, - { id: 'recraft-v3', codeName: 'b88d5814-1d20-49cc-9eb6-e362f5851661', imagePolicy: 'forbidden' }, - { id: 'flux-2-flex', codeName: '019abed6-d96e-7a2b-bf69-198c28bef281', imagePolicy: 'optional' }, - { id: 'imagen-3.0-generate-002', codeName: '51ad1d79-61e2-414c-99e3-faeb64bb6b1b', imagePolicy: 'forbidden' }, - { id: 'photon', codeName: 'e7c9fa2d-6f5d-40eb-8305-0980b11c7cab', imagePolicy: 'forbidden' }, - { id: 'imagen-4.0-ultra-generate-001', codeName: '019ae6da-6438-7077-9d2d-b311a35645f8', imagePolicy: 'forbidden' }, - { id: 'flux-2-dev', codeName: '019ae6a0-4773-77d5-8ffb-cc35813e063c', imagePolicy: 'optional' }, - { id: 'imagen-4.0-generate-001', codeName: '019ae6da-6788-761a-8253-e0bb2bf2e3a9', imagePolicy: 'forbidden' }, - { id: 'flux-2-max', codeName: '', imagePolicy: 'optional' }, - { id: 'qwen-image-prompt-extend', codeName: '9fe82ee1-c84f-417f-b0e7-cab4ae4cf3f3', imagePolicy: 'forbidden' }, - { id: 'qwen-image-edit', codeName: '995cf221-af30-466d-a809-8e0985f83649', imagePolicy: 'required' }, - { id: 'ideogram-v3-quality', codeName: '73378be5-cdba-49e7-b3d0-027949871aa6', imagePolicy: 'forbidden' }, - { id: 'hunyuan-image-2.1', codeName: 'a9a26426-5377-4efa-bef9-de71e29ad943', imagePolicy: 'forbidden' }, - { id: 'qwen-image-2512', codeName: '', imagePolicy: 'forbidden' }, - { id: 'wan2.5-t2i-preview', codeName: '019a5050-2875-78ed-ae3a-d9a51a438685', imagePolicy: 'forbidden' }, - { id: 'reve-v1.1', codeName: '', imagePolicy: 'required' }, - { id: 'chatgpt-image-latest', codeName: '', imagePolicy: 'optional' }, - { id: 'seedream-4.5', codeName: '019abd43-b052-7eec-aa57-e895e45c9723', imagePolicy: 'optional' }, - { id: 'gpt-image-1-mini', codeName: '0199c238-f8ee-7f7d-afc1-7e28fcfd21cf', imagePolicy: 'optional' }, - { id: 'gpt-image-1', codeName: '6e855f13-55d7-4127-8656-9168a9f4dcc0', imagePolicy: 'optional' }, - { id: 'gemini-2.0-flash-preview-image-generation', codeName: '69bbf7d4-9f44-447e-a868-abc4f7a31810', imagePolicy: 'optional' }, - { id: 'gemini-2.5-flash-image-preview', codeName: '0199ef2a-583f-7088-b704-b75fd169401d', imagePolicy: 'optional' }, - { id: 'seedream-3', codeName: 'd8771262-8248-4372-90d5-eb41910db034', imagePolicy: 'forbidden' }, - { id: 'seedream-4-high-res-fal', codeName: '32974d8d-333c-4d2e-abf3-f258c0ac1310', imagePolicy: 'optional' }, - { id: 'gpt-image-1.5', codeName: '', imagePolicy: 'optional' }, - { id: 'flux-1-kontext-pro', codeName: '28a8f330-3554-448c-9f32-2c0a08ec6477', imagePolicy: 'optional' }, - { id: 'wan2.5-i2i-preview', codeName: '019aeb62-c6ea-788e-88f9-19b1b48325b5', imagePolicy: 'required' }, - { id: 'flux-1-kontext-dev', codeName: 'eb90ae46-a73a-4f27-be8b-40f090592c9a', imagePolicy: 'optional' }, - { id: 'lucid-origin', codeName: '5a3b3520-c87d-481f-953c-1364687b6e8f', imagePolicy: 'forbidden' } + { id: 'gemini-3-pro-image-preview-2k', imagePolicy: 'optional' }, + { id: 'gemini-3-pro-image-preview', codeName: 'gemini-3-pro-image-preview (nano-banana-pro)', imagePolicy: 'optional' }, + { id: 'hunyuan-image-3.0', imagePolicy: 'forbidden' }, + { id: 'vidu-q2-image', imagePolicy: 'optional' }, + { id: 'mai-image-1', imagePolicy: 'forbidden' }, + { id: 'imagen-4.0-fast-generate-001', imagePolicy: 'forbidden' }, + { id: 'flux-2-pro', imagePolicy: 'optional' }, + { id: 'recraft-v3', imagePolicy: 'forbidden' }, + { id: 'flux-2-flex', imagePolicy: 'optional' }, + { id: 'imagen-3.0-generate-002', imagePolicy: 'forbidden' }, + { id: 'photon', imagePolicy: 'forbidden' }, + { id: 'imagen-4.0-ultra-generate-001', imagePolicy: 'forbidden' }, + { id: 'flux-2-dev', imagePolicy: 'optional' }, + { id: 'imagen-4.0-generate-001', imagePolicy: 'forbidden' }, + { id: 'flux-2-max', imagePolicy: 'optional' }, + { id: 'qwen-image-prompt-extend', imagePolicy: 'forbidden' }, + { id: 'qwen-image-edit', imagePolicy: 'required' }, + { id: 'ideogram-v3-quality', imagePolicy: 'forbidden' }, + { id: 'hunyuan-image-2.1', imagePolicy: 'forbidden' }, + { id: 'qwen-image-2512', imagePolicy: 'forbidden' }, + { id: 'wan2.5-t2i-preview', imagePolicy: 'forbidden' }, + { id: 'reve-v1.1', imagePolicy: 'required' }, + { id: 'chatgpt-image-latest', imagePolicy: 'optional' }, + { id: 'seedream-4.5', imagePolicy: 'optional' }, + { id: 'gpt-image-1-mini', imagePolicy: 'optional' }, + { id: 'gpt-image-1', imagePolicy: 'optional' }, + { id: 'gemini-2.0-flash-preview-image-generation', imagePolicy: 'optional' }, + { id: 'gemini-2.5-flash-image-preview', imagePolicy: 'optional' }, + { id: 'seedream-3', imagePolicy: 'forbidden' }, + { id: 'seedream-4-high-res-fal', imagePolicy: 'optional' }, + { id: 'gpt-image-1.5', imagePolicy: 'optional' }, + { id: 'flux-1-kontext-pro', imagePolicy: 'optional' }, + { id: 'wan2.5-i2i-preview', imagePolicy: 'required' }, + { id: 'flux-1-kontext-dev', imagePolicy: 'optional' }, + { id: 'lucid-origin', imagePolicy: 'forbidden' } ], // 无需导航处理器 diff --git a/src/backend/adapter/lmarena_text.js b/src/backend/adapter/lmarena_text.js index b80d688..a4841e9 100644 --- a/src/backend/adapter/lmarena_text.js +++ b/src/backend/adapter/lmarena_text.js @@ -49,17 +49,21 @@ async function generate(context, prompt, imgPaths, modelId, meta = {}) { // 2. 选择模型 if (modelId) { logger.debug('适配器', `选择模型: ${modelId}`, meta); - const modelCombobox = page.locator('#chat-area') - .locator('button[role="combobox"][aria-haspopup="dialog"]') - .last(); + // 使用键盘导航展开模型选择框:按两次 Shift+Tab 然后 Enter + await page.keyboard.down('Shift'); + await page.keyboard.press('Tab'); + await page.keyboard.press('Tab'); + await page.keyboard.up('Shift'); + await sleep(100, 200); + await page.keyboard.press('Enter'); - await modelCombobox.waitFor({ state: 'visible', timeout: 10000 }); - await safeClick(page, modelCombobox, { bias: 'button' }); + // 获取模型配置,优先使用 codeName,否则使用 id + const searchText = modelConfig?.codeName || modelId; - // 模拟粘贴输入模型 ID + // 模拟粘贴输入模型名称 await page.evaluate((text) => { document.execCommand('insertText', false, text); - }, modelId); + }, searchText); // 等待下拉选项出现后再按回车 try { @@ -176,141 +180,147 @@ export const manifest = { // 模型列表(根据最新支持列表整理) models: [ // --- 文本模型 --- - { id: 'claude-opus-4-5-20251101-thinking-32k', codeName: '019ab8b2-9bcf-79b5-9fb5-149a7c67b7c0', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-opus-4-5-20251101', codeName: '019adbec-8396-71cc-87d5-b47f8431a6a6', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemini-3-pro', codeName: '019a98f7-afcd-779f-8dcb-856cc3b3f078', imagePolicy: 'optional', type: 'text' }, - { id: 'grok-4.1-thinking', codeName: '019a9389-a9d3-77a8-afbb-4fe4dd3d8630', imagePolicy: 'forbidden', type: 'text' }, - { id: 'grok-4.1', codeName: '019a9389-a4d8-748d-9939-b4640198302e', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-5.1-high', codeName: '019a8548-a2b1-70ce-b1be-eba096d41f58', imagePolicy: 'optional', type: 'text' }, - { id: 'gemini-2.5-pro', codeName: '0199f060-b306-7e1f-aeae-0ebb4e3f1122', imagePolicy: 'optional', type: 'text' }, - { id: 'claude-sonnet-4-5-20250929-thinking-32k', codeName: 'b0ea1407-2f92-4515-b9cc-b22a6d6c14f2', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-opus-4-1-20250805-thinking-16k', codeName: 'f1a2eb6f-fc30-4806-9e00-1efd0d73cbc4', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-sonnet-4-5-20250929', codeName: '019a2d13-28a5-7205-908c-0a58de904617', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-opus-4-1-20250805', codeName: '96ae95fd-b70d-49c3-91cc-b58c7da1090b', imagePolicy: 'forbidden', type: 'text' }, - { id: 'chatgpt-4o-latest-20250326', codeName: '0199c1e0-3720-742d-91c8-787788b0a19b', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-5.1', codeName: '019a7ebf-0f3f-7518-8899-fca13e32d9dc', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-5-high', codeName: '983bc566-b783-4d28-b24c-3c8b08eb1086', imagePolicy: 'optional', type: 'text' }, - { id: 'o3-2025-04-16', codeName: 'cb0f1e24-e8e9-4745-aabc-b926ffde7475', imagePolicy: 'optional', type: 'text' }, - { id: 'qwen3-max-preview', codeName: '812c93cc-5f88-4cff-b9ca-c11a26599b0e', imagePolicy: 'forbidden', type: 'text' }, - { id: 'grok-4-1-fast-reasoning', codeName: '019aa41a-0a13-714a-beb1-be4a918a4b56', imagePolicy: 'forbidden', type: 'text' }, - { id: 'ernie-5.0-preview-1103', codeName: '019a4ca9-720d-75f5-9012-883ce8ff61df', imagePolicy: 'forbidden', type: 'text' }, - { id: 'kimi-k2-thinking-turbo', codeName: '019a59bc-8bb8-7933-92eb-fe143770c211', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-5-chat', codeName: '4b11c78c-08c8-461c-938e-5fc97d56a40d', imagePolicy: 'optional', type: 'text' }, - { id: 'glm-4.6', codeName: 'f595e6f1-6175-4880-a9eb-377e390819e4', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-max-2025-09-23', codeName: '98ad8b8b-12cd-46cd-98de-99edde7e03eb', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-opus-4-20250514-thinking-16k', codeName: '3b5e9593-3dc0-4492-a3da-19784c4bde75', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-235b-a22b-instruct-2507', codeName: 'ee7cb86e-8601-4585-b1d0-7c7380f8f6f4', imagePolicy: 'forbidden', type: 'text' }, - { id: 'grok-4-fast-chat', codeName: 'grok-4-fast-chat', imagePolicy: 'forbidden', type: 'text' }, - { id: 'deepseek-v3.2-thinking', codeName: '019adb32-bb7a-77eb-882f-b8e3aaa2b2fd', imagePolicy: 'forbidden', type: 'text' }, - { id: 'kimi-k2-0905-preview', codeName: 'b88e983b-9459-473d-8bf1-753932f1679a', imagePolicy: 'forbidden', type: 'text' }, - { id: 'kimi-k2-0711-preview', codeName: '7a3626fc-4e64-4c9e-821f-b449a4b43b6a', imagePolicy: 'forbidden', type: 'text' }, - { id: 'deepseek-v3.2', codeName: '019adb32-b716-7591-9a2f-c6882973e340', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-vl-235b-a22b-instruct', codeName: '716aa8ca-d729-427f-93ab-9579e4a13e98', imagePolicy: 'optional', type: 'text' }, - { id: 'mistral-large-3', codeName: '019acbac-df7c-73dc-9716-ebe040daaa4e', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-4.1-2025-04-14', codeName: '14e9311c-94d2-40c2-8c54-273947e208b0', imagePolicy: 'optional', type: 'text' }, - { id: 'claude-opus-4-20250514', codeName: 'ee116d12-64d6-48a8-88e5-b2d06325cdd2', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mistral-medium-2508', codeName: '27035fb8-a25b-4ec9-8410-34be18328afd', imagePolicy: 'optional', type: 'text' }, - { id: 'grok-4-0709', codeName: 'b9edb8e9-4e98-49e7-8aaf-ae67e9797a11', imagePolicy: 'optional', type: 'text' }, - { id: 'glm-4.5', codeName: 'd079ef40-3b20-4c58-ab5e-243738dbada5', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemini-2.5-flash', codeName: '0199f059-3877-7cfe-bc80-e01b1a4a83de', imagePolicy: 'optional', type: 'text' }, - { id: 'gemini-2.5-flash-preview-09-2025', codeName: 'fc700d46-c4c1-4fec-88b5-f086876ae0bb', imagePolicy: 'optional', type: 'text' }, - { id: 'claude-haiku-4-5-20251001', codeName: '0199e8e9-01ed-73e0-96ba-cf43b286bf10', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-next-80b-a3b-instruct', codeName: '351fe482-eb6c-4536-857b-909e16c0bf52', imagePolicy: 'forbidden', type: 'text' }, - { id: 'longcat-flash-chat', codeName: '6fcbe051-f521-4dc7-8986-c429eb6191bf', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-235b-a22b-no-thinking', codeName: '1a400d9a-f61c-4bc2-89b4-a9b7e77dff12', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-235b-a22b-thinking-2507', codeName: '16b8e53a-cc7b-4608-a29a-20d4dac77cf2', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-vl-235b-a22b-thinking', codeName: '03c511f5-0d35-4751-aae6-24f918b0d49e', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-5-mini-high', codeName: '5fd3caa8-fe4c-41a5-a22c-0025b58f4b42', imagePolicy: 'optional', type: 'text' }, - { id: 'deepseek-v3-0324', codeName: '2f5253e4-75be-473c-bcfc-baeb3df0f8ad', imagePolicy: 'forbidden', type: 'text' }, - { id: 'hunyuan-vision-1.5-thinking', codeName: '6a3a1e04-050e-4cb4-9052-b9ac4bec0c38', imagePolicy: 'optional', type: 'text' }, - { id: 'o4-mini-2025-04-16', codeName: 'f1102bbf-34ca-468f-a9fc-14bcf63f315b', imagePolicy: 'optional', type: 'text' }, - { id: 'claude-sonnet-4-20250514', codeName: 'ac44dd10-0666-451c-b824-386ccfea7bcc', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-3-7-sonnet-20250219-thinking-32k', codeName: 'be98fcfd-345c-4ae1-9a82-a19123ebf1d2', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-coder-480b-a35b-instruct', codeName: 'af033cbd-ec6c-42cc-9afa-e227fc12efe8', imagePolicy: 'forbidden', type: 'text' }, - { id: 'hunyuan-t1-20250711', codeName: 'ba8c2392-4c47-42af-bfee-c6c057615a91', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mistral-medium-2505', codeName: '27b9f8c6-3ee1-464a-9479-a8b3c2a48fd4', imagePolicy: 'optional', type: 'text' }, - { id: 'qwen3-30b-a3b-instruct-2507', codeName: 'a8d1d310-e485-4c50-8f27-4bff18292a99', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-4.1-mini-2025-04-14', codeName: '6a5437a7-c786-467b-b701-17b0bc8c8231', imagePolicy: 'optional', type: 'text' }, - { id: 'gemini-2.5-flash-lite-preview-09-2025-no-thinking', codeName: '75555628-8c14-402a-8d6e-43c19cb40116', imagePolicy: 'optional', type: 'text' }, - { id: 'gemini-2.5-flash-lite-preview-06-17-thinking', codeName: '04ec9a17-c597-49df-acf0-963da275c246', imagePolicy: 'optional', type: 'text' }, - { id: 'qwen3-235b-a22b', codeName: '2595a594-fa54-4299-97cd-2d7380d21c80', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-3-5-sonnet-20241022', codeName: 'f44e280a-7914-43ca-a25d-ecfcc5d48d09', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-3-7-sonnet-20250219', codeName: 'c5a11495-081a-4dc6-8d9a-64a4fd6f7bbc', imagePolicy: 'forbidden', type: 'text' }, - { id: 'glm-4.5-air', codeName: '7bfb254a-5d32-4ce2-b6dc-2c7faf1d5fe8', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-next-80b-a3b-thinking', codeName: '73cf8705-98c8-4b75-8d04-e3746e1c1565', imagePolicy: 'forbidden', type: 'text' }, - { id: 'minimax-m1', codeName: '87e8d160-049e-4b4e-adc4-7f2511348539', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemma-3-27b-it', codeName: '789e245f-eafe-4c72-b563-d135e93988fc', imagePolicy: 'optional', type: 'text' }, - { id: 'grok-3-mini-high', codeName: '149619f1-f1d5-45fd-a53e-7d790f156f20', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemini-2.0-flash-001', codeName: '7a55108b-b997-4cff-a72f-5aa83beee918', imagePolicy: 'optional', type: 'text' }, - { id: 'grok-3-mini-beta', codeName: '7699c8d4-0742-42f9-a117-d10e84688dab', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mistral-small-2506', codeName: 'bbad1d17-6aa5-4321-949c-d11fb6289241', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-oss-120b', codeName: '6ee9f901-17b5-4fbe-9cc2-13c16497c23b', imagePolicy: 'forbidden', type: 'text' }, - { id: 'glm-4.5v', codeName: '9dab0475-a0cc-4524-84a2-3fd25aa8c768', imagePolicy: 'optional', type: 'text' }, - { id: 'command-a-03-2025', codeName: '0f785ba1-efcb-472d-961e-69f7b251c7e3', imagePolicy: 'forbidden', type: 'text' }, - { id: 'amazon-nova-experimental-chat-10-20', codeName: '019a4c75-256c-790b-9088-4694cc63c507', imagePolicy: 'forbidden', type: 'text' }, - { id: 'intellect-3', codeName: '019aebfd-af0e-7f0c-8f0d-96c588e4cd3b', imagePolicy: 'forbidden', type: 'text' }, - { id: 'o3-mini', codeName: 'c680645e-efac-4a81-b0af-da16902b2541', imagePolicy: 'forbidden', type: 'text' }, - { id: 'ling-flash-2.0', codeName: '71f96ca9-4cf8-4be7-bac2-2231613930a6', imagePolicy: 'forbidden', type: 'text' }, - { id: 'minimax-m2', codeName: '019a27e0-e7d8-7b0b-877c-a2106c6eb87d', imagePolicy: 'forbidden', type: 'text' }, - { id: 'step-3', codeName: '1ea13a81-93a7-4804-bcdd-693cd72e302d', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-5-nano-high', codeName: '2dc249b3-98da-44b4-8d1e-6666346a8012', imagePolicy: 'optional', type: 'text' }, - { id: 'nova-2-lite', codeName: '019ae300-83b7-7717-a1e0-31accd1ff6fa', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwq-32b', codeName: '885976d3-d178-48f5-a3f4-6e13e0718872', imagePolicy: 'forbidden', type: 'text' }, - { id: 'llama-4-maverick-17b-128e-instruct', codeName: 'b5ad3ab7-fc56-4ecd-8921-bd56b55c1159', imagePolicy: 'optional', type: 'text' }, - { id: 'qwen3-30b-a3b', codeName: '9a066f6a-7205-4325-8d0b-d81cc4b049c0', imagePolicy: 'forbidden', type: 'text' }, - { id: 'claude-3-5-haiku-20241022', codeName: 'claude-3-5-haiku-20241022', imagePolicy: 'forbidden', type: 'text' }, - { id: 'ring-flash-2.0', codeName: '11ad4114-c868-4fed-b6e7-d535dc9c62f8', imagePolicy: 'forbidden', type: 'text' }, - { id: 'llama-3.3-70b-instruct', codeName: 'dcbd7897-5a37-4a34-93f1-76a24c7bb028', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemma-3n-e4b-it', codeName: '896a3848-ae03-4651-963b-7d8f54b61ae8', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-oss-20b', codeName: 'ec3beb4b-7229-4232-bab9-670ee52dd711', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mercury', codeName: '019a6f77-e20d-7c1d-a7cd-8bd926e7395d', imagePolicy: 'forbidden', type: 'text' }, - { id: 'olmo-3-32b-think', codeName: '019ac2ef-27e1-769f-8258-d131f79e28ef', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mistral-small-3.1-24b-instruct-2503', codeName: '69f5d38a-45f5-4d3a-9320-b866a4035ed9', imagePolicy: 'optional', type: 'text' }, - { id: 'ibm-granite-h-small', codeName: '4ddb69f5-391a-4f78-af92-7d7328c18ab1', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-vl-8b-thinking', codeName: '0199e3d1-a308-77b9-a650-41453e8ef2fb', imagePolicy: 'optional', type: 'text' }, - { id: 'qwen3-vl-8b-instruct', codeName: '0199e3d1-a713-7de2-a5dd-a1583cad9532', imagePolicy: 'optional', type: 'text' }, - { id: 'amazon.nova-pro-v1:0', codeName: 'a14546b5-d78d-4cf6-bb61-ab5b8510a9d6', imagePolicy: 'optional', type: 'text' }, - { id: 'glm-4.6v', codeName: '019b151a-7c3b-72a2-8811-0bf9317c2ef5', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-5.2-high', codeName: '019b1448-dafa-7f92-90c3-50e159c2263c', imagePolicy: 'optional', type: 'text' }, - { id: 'gpt-5.2', codeName: '019b1448-d548-78f4-8b98-788d72cbd057', imagePolicy: 'optional', type: 'text' }, - { id: 'glm-4.6v-flash', codeName: '019b1536-49c0-73b2-8d45-403b8571568d', imagePolicy: 'optional', type: 'text' }, - { id: 'mimo-vl-7b-rl-2508', codeName: '1c0259b5-dff7-48ce-bca1-b6957675463b', imagePolicy: 'optional', type: 'text' }, - { id: 'minimax-m2.1-preview', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mimo-v2-flash (thinking)', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'glm-4.7', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'amazon-nova-experimental-chat-11-10', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'grok-4-1-fast-non-reasoning', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemini-3-flash', codeName: '', imagePolicy: 'optional', type: 'text' }, - { id: 'nvidia-nemotron-3-nano-30b-a3b-bf16', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'olmo-3.1-32b-instruct', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'olmo-3.1-32b-think', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gemini-3-flash (thinking-minimal)', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mimo-v2-flash', codeName: '', imagePolicy: 'optional', type: 'text' }, - { id: 'ernie-5.0-preview-1220', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen3-max-2025-09-26', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'ernie-5.0-preview-1203', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'mimo-7b', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'qwen-vl-max-2025-08-13', codeName: '', imagePolicy: 'optional', type: 'text' }, - { id: 'claude-sonnet-4-20250514-thinking-32k', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'minimax-m2-preview', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'ernie-5.0-preview-1120', codeName: '', imagePolicy: 'forbidden', type: 'text' }, - { id: 'gpt-5-high-new-system-prompt', codeName: '', imagePolicy: 'optional', type: 'text' }, + { id: 'gemini-3-pro', imagePolicy: 'optional', type: 'text' }, + { id: 'grok-4.1-thinking', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemini-3-flash', imagePolicy: 'optional', type: 'text' }, + { id: 'claude-opus-4-5-20251101-thinking-32k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-opus-4-5-20251101', imagePolicy: 'forbidden', type: 'text' }, + { id: 'grok-4.1', imagePolicy: 'forbidden', type: 'text' }, + { id: 'ernie-5.0-0110', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5.1-high', imagePolicy: 'optional', type: 'text' }, + { id: 'gemini-2.5-pro', imagePolicy: 'optional', type: 'text' }, + { id: 'claude-sonnet-4-5-20250929-thinking-32k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'ernie-5.0-preview-1203', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-sonnet-4-5-20250929', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-opus-4-1-20250805-thinking-16k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-opus-4-1-20250805', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5.2', imagePolicy: 'optional', type: 'text' }, + { id: 'chatgpt-4o-latest-20250326', imagePolicy: 'optional', type: 'text' }, + { id: 'glm-4.7', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5.2-high', imagePolicy: 'optional', type: 'text' }, + { id: 'gpt-5.1', imagePolicy: 'optional', type: 'text' }, + { id: 'gpt-5-high', imagePolicy: 'optional', type: 'text' }, + { id: 'qwen3-max-preview', imagePolicy: 'forbidden', type: 'text' }, + { id: 'o3-2025-04-16', imagePolicy: 'optional', type: 'text' }, + { id: 'grok-4-1-fast-reasoning', imagePolicy: 'forbidden', type: 'text' }, + { id: 'kimi-k2-thinking-turbo', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5-chat', imagePolicy: 'optional', type: 'text' }, + { id: 'glm-4.6', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-max-2025-09-23', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-opus-4-20250514-thinking-16k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-235b-a22b-instruct-2507', imagePolicy: 'forbidden', type: 'text' }, + { id: 'grok-4-fast-chat', imagePolicy: 'forbidden', type: 'text' }, + { id: 'deepseek-v3.2-thinking', imagePolicy: 'forbidden', type: 'text' }, + { id: 'deepseek-v3.2', imagePolicy: 'forbidden', type: 'text' }, + { id: 'kimi-k2-0905-preview', imagePolicy: 'forbidden', type: 'text' }, + { id: 'kimi-k2-0711-preview', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-vl-235b-a22b-instruct', imagePolicy: 'optional', type: 'text' }, + { id: 'claude-opus-4-20250514', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-4.1-2025-04-14', imagePolicy: 'optional', type: 'text' }, + { id: 'mistral-medium-2508', imagePolicy: 'optional', type: 'text' }, + { id: 'mistral-large-3', imagePolicy: 'forbidden', type: 'text' }, + { id: 'grok-4-0709', imagePolicy: 'optional', type: 'text' }, + { id: 'glm-4.5', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemini-2.5-flash', imagePolicy: 'optional', type: 'text' }, + { id: 'gemini-2.5-flash-preview-09-2025', imagePolicy: 'optional', type: 'text' }, + { id: 'grok-4-fast-reasoning', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-haiku-4-5-20251001', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-235b-a22b-no-thinking', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-next-80b-a3b-instruct', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-sonnet-4-20250514-thinking-32k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'longcat-flash-chat', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-235b-a22b-thinking-2507', imagePolicy: 'forbidden', type: 'text' }, + { id: 'mimo-v2-flash', imagePolicy: 'optional', type: 'text' }, + { id: 'mimo-v2-flash-thinking', codeName: 'mimo-v2-flash (thinking)', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-vl-235b-a22b-thinking', imagePolicy: 'optional', type: 'text' }, + { id: 'deepseek-v3-0324', imagePolicy: 'forbidden', type: 'text' }, + { id: 'hunyuan-vision-1.5-thinking', imagePolicy: 'optional', type: 'text' }, + { id: 'o4-mini-2025-04-16', imagePolicy: 'optional', type: 'text' }, + { id: 'gpt-5-mini-high', imagePolicy: 'optional', type: 'text' }, + { id: 'claude-sonnet-4-20250514', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-3-7-sonnet-20250219-thinking-32k', imagePolicy: 'forbidden', type: 'text' }, + { id: 'hunyuan-t1-20250711', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-coder-480b-a35b-instruct', imagePolicy: 'forbidden', type: 'text' }, + { id: 'mistral-medium-2505', imagePolicy: 'optional', type: 'text' }, + { id: 'qwen3-30b-a3b-instruct-2507', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-4.1-mini-2025-04-14', imagePolicy: 'optional', type: 'text' }, + { id: 'minimax-m2.1-preview', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemini-2.5-flash-lite-preview-09-2025-no-thinking', imagePolicy: 'optional', type: 'text' }, + { id: 'glm-4.6v', imagePolicy: 'optional', type: 'text' }, + { id: 'gemini-2.5-flash-lite-preview-06-17-thinking', imagePolicy: 'optional', type: 'text' }, + { id: 'qwen3-235b-a22b', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-3-5-sonnet-20241022', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-3-7-sonnet-20250219', imagePolicy: 'forbidden', type: 'text' }, + { id: 'glm-4.5-air', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-next-80b-a3b-thinking', imagePolicy: 'forbidden', type: 'text' }, + { id: 'minimax-m1', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemma-3-27b-it', imagePolicy: 'optional', type: 'text' }, + { id: 'amazon-nova-experimental-chat-11-10', imagePolicy: 'forbidden', type: 'text' }, + { id: 'grok-3-mini-high', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemini-2.0-flash-001', imagePolicy: 'optional', type: 'text' }, + { id: 'grok-3-mini-beta', imagePolicy: 'forbidden', type: 'text' }, + { id: 'mistral-small-2506', imagePolicy: 'optional', type: 'text' }, + { id: 'intellect-3', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-oss-120b', imagePolicy: 'forbidden', type: 'text' }, + { id: 'glm-4.5v', imagePolicy: 'optional', type: 'text' }, + { id: 'command-a-03-2025', imagePolicy: 'forbidden', type: 'text' }, + { id: 'o3-mini', imagePolicy: 'forbidden', type: 'text' }, + { id: 'ling-flash-2.0', imagePolicy: 'forbidden', type: 'text' }, + { id: 'step-3', imagePolicy: 'forbidden', type: 'text' }, + { id: 'minimax-m2', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5-nano-high', imagePolicy: 'optional', type: 'text' }, + { id: 'nova-2-lite', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwq-32b', imagePolicy: 'forbidden', type: 'text' }, + { id: 'llama-4-maverick-17b-128e-instruct', imagePolicy: 'optional', type: 'text' }, + { id: 'qwen3-30b-a3b', imagePolicy: 'forbidden', type: 'text' }, + { id: 'claude-3-5-haiku-20241022', imagePolicy: 'forbidden', type: 'text' }, + { id: 'olmo-3.1-32b-instruct', imagePolicy: 'forbidden', type: 'text' }, + { id: 'ring-flash-2.0', imagePolicy: 'forbidden', type: 'text' }, + { id: 'llama-3.3-70b-instruct', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gemma-3n-e4b-it', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-oss-20b', imagePolicy: 'forbidden', type: 'text' }, + { id: 'nvidia-nemotron-3-nano-30b-a3b-bf16', imagePolicy: 'forbidden', type: 'text' }, + { id: 'mercury', imagePolicy: 'forbidden', type: 'text' }, + { id: 'magistral-medium-2506', imagePolicy: 'forbidden', type: 'text' }, + { id: 'olmo-3-32b-think', imagePolicy: 'forbidden', type: 'text' }, + { id: 'mistral-small-3.1-24b-instruct-2503', imagePolicy: 'optional', type: 'text' }, + { id: 'ibm-granite-h-small', imagePolicy: 'forbidden', type: 'text' }, + { id: 'olmo-3.1-32b-think', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-vl-8b-thinking', imagePolicy: 'optional', type: 'text' }, + { id: 'qwen3-vl-8b-instruct', imagePolicy: 'optional', type: 'text' }, + { id: 'grok-4-1-fast-non-reasoning', imagePolicy: 'forbidden', type: 'text' }, + { id: 'amazon.nova-pro-v1:0', imagePolicy: 'optional', type: 'text' }, + { id: 'gemini-3-flash-thinking-minimal', codeName: 'gemini-3-flash (thinking-minimal)', imagePolicy: 'forbidden', type: 'text' }, + { id: 'amazon-nova-experimental-chat-12-10', imagePolicy: 'forbidden', type: 'text' }, + { id: 'ernie-5.0-preview-1220', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-max-2025-09-26', imagePolicy: 'forbidden', type: 'text' }, + { id: 'glm-4.6v-flash', imagePolicy: 'optional', type: 'text' }, + { id: 'MiMo-7B', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen3-omni-flash', imagePolicy: 'forbidden', type: 'text' }, + { id: 'qwen-vl-max-2025-08-13', imagePolicy: 'optional', type: 'text' }, + { id: 'minimax-m2-preview', imagePolicy: 'forbidden', type: 'text' }, + { id: 'gpt-5-high-new-system-prompt', imagePolicy: 'optional', type: 'text' }, + { id: 'MiMo-VL-7B-RL-2508', imagePolicy: 'optional', type: 'text' }, // --- 搜索模型 --- - { id: 'gemini-3-pro-grounding', codeName: '019abdb7-6957-71c1-96a2-bfa79e8a094f', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'gpt-5.1-search', codeName: '019abdb7-50a5-7c05-9308-4491d069578b', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'grok-4-fast-search', codeName: '9217ac2d-91bc-4391-aa07-b8f9e2cf11f2', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'gemini-2.5-pro-grounding', codeName: 'b222be23-bd55-4b20-930b-a30cc84d3afd', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'o3-search', codeName: 'fbe08e9a-3805-4f9f-a085-7bc38e4b51d1', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'grok-4-search', codeName: '86d767b0-2574-4e47-a256-a22bcace9f56', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'ppl-sonar-reasoning-pro-high', codeName: '24145149-86c9-4690-b7c9-79c7db216e5c', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'claude-opus-4-1-search', codeName: 'd942b564-191c-41c5-ae22-400a930a2cfe', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'gpt-5-search', codeName: 'd14d9b23-1e46-4659-b157-a3804ba7e2ef', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'claude-opus-4-search', codeName: '25bcb878-749e-49f4-ac05-de84d964bcee', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'diffbot-small-xl', codeName: '0862885e-ef53-4d0d-b9c4-4c8f68f453ce', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'grok-4-1-fast-search', codeName: '019af19c-0658-7566-9c60-112ae5bdb8db', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'gpt-5.2-search', codeName: '019b1448-f74a-72de-b25d-8666618f8c5a', imagePolicy: 'forbidden', type: 'text', search: true }, - { id: 'gpt-5.1-search-sp', codeName: '', imagePolicy: 'forbidden', type: 'text', search: true } + { id: 'gemini-3-pro-grounding', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gpt-5.2-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gpt-5.1-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'grok-4-1-fast-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'grok-4-fast-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gemini-2.5-pro-grounding', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'o3-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'ppl-sonar-reasoning-pro-high', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'grok-4-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'claude-opus-4-1-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gpt-5-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'claude-opus-4-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'diffbot-small-xl', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gpt-5.2-search-non-reasoning', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'claude-opus-4-5-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'claude-sonnet-4-5-search', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gpt-5.1-search-sp', imagePolicy: 'forbidden', type: 'text', search: true }, + { id: 'gemini-3-flash-grounding', imagePolicy: 'forbidden', type: 'text', search: true } ], // 无需导航处理器 diff --git a/src/backend/engine/utils.js b/src/backend/engine/utils.js index 3a632dd..7e98510 100644 --- a/src/backend/engine/utils.js +++ b/src/backend/engine/utils.js @@ -228,11 +228,13 @@ export async function safeClick(page, target, options = {}) { const clickCount = options.clickCount || 1; const timeout = options.timeout || TIMEOUTS.ELEMENT_CLICK; const waitStable = options.waitStable !== false; // 默认 true + const selector = typeof target === 'string' ? target : '元素'; const doClick = async () => { let el; // 判断输入类型 + logger.debug('浏览器', `[safeClick] 开始查找: ${selector}`); if (typeof target === 'string') { // CSS selector el = await page.$(target); @@ -246,30 +248,39 @@ export async function safeClick(page, target, options = {}) { el = target; if (!el || !el.asElement()) throw new Error(`Element handle invalid`); } + logger.debug('浏览器', `[safeClick] 已找到元素`); // 确保元素在可视区域内 + logger.debug('浏览器', `[safeClick] 滚动到可视区域...`); await el.scrollIntoViewIfNeeded().catch(() => { }); // 如果开启了布局稳定等待,等待元素位置稳定 if (waitStable) { + logger.debug('浏览器', `[safeClick] 等待元素稳定...`); await waitForElementStable(el); + logger.debug('浏览器', `[safeClick] 元素已稳定`); } // 使用 ghost-cursor 点击 if (page.cursor) { const box = await el.boundingBox(); + logger.debug('浏览器', `[safeClick] boundingBox: ${JSON.stringify(box)}`); if (box) { const { x, y } = getHumanClickPoint(box, options.bias || 'random'); + logger.debug('浏览器', `[safeClick] 移动鼠标到 (${x.toFixed(0)}, ${y.toFixed(0)})...`); await page.cursor.moveTo({ x, y }); + logger.debug('浏览器', `[safeClick] 执行点击...`); await page.mouse.click(x, y, { clickCount }); return; } // 如果无法获取 box,降级到默认点击 + logger.debug('浏览器', `[safeClick] boundingBox 为 null,降级到 cursor.click`); await page.cursor.click(el); return; } // 降级逻辑 + logger.debug('浏览器', `[safeClick] 无 cursor,使用原生 click`); await el.click({ clickCount }); }; @@ -286,7 +297,6 @@ export async function safeClick(page, target, options = {}) { ]); } catch (err) { clearTimeout(timeoutId); - const selector = typeof target === 'string' ? target : '元素'; throw new Error(`点击操作失败 (${selector}): ${err.message}`); } } @@ -417,9 +427,28 @@ export async function humanType(page, target, text, options = {}) { const fakeCount = Math.floor(random(3, 8)); const fakeText = text.substring(0, fakeCount); - // 1. 假装打字几个字符 + // 1. 假装打字几个字符 (需要处理换行符,避免触发发送) for (let i = 0; i < fakeText.length; i++) { - await page.keyboard.type(fakeText[i], { delay: random(30, 100) }); + const char = fakeText[i]; + const nextChar = fakeText[i + 1]; + + // 处理换行符 (避免触发发送) + if (char === '\r' && nextChar === '\n') { + await page.keyboard.down('Shift'); + await page.keyboard.press('Enter'); + await page.keyboard.up('Shift'); + i++; // 跳过 \n + await sleep(30, 100); + continue; + } else if (char === '\n' || char === '\r') { + await page.keyboard.down('Shift'); + await page.keyboard.press('Enter'); + await page.keyboard.up('Shift'); + await sleep(30, 100); + continue; + } + + await page.keyboard.type(char, { delay: random(30, 100) }); } // 2. 停顿思考