yiyan-browser-agent 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/browser.js +11 -25
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -367,9 +367,14 @@ class YiyanBrowser {
|
|
|
367
367
|
hasCompletionMarker = true;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
// ──
|
|
371
|
-
|
|
372
|
-
|
|
370
|
+
// ── 完成判断 ──
|
|
371
|
+
// 条件1: 标记出现 + answer稳定 + 思考区域稳定
|
|
372
|
+
// 条件2(备用): 两者都稳定达到 4 次(即使没有完成标记)
|
|
373
|
+
const condition1 = hasCompletionMarker && stableCount >= 2 && thinkingStableCount >= 2;
|
|
374
|
+
const condition2 = stableCount >= 4 && thinkingStableCount >= 4;
|
|
375
|
+
|
|
376
|
+
if (condition1 || condition2) {
|
|
377
|
+
// 检查 _isGenerating 作为最终确认
|
|
373
378
|
if (!await this._isGenerating()) {
|
|
374
379
|
await this.page.waitForTimeout(500);
|
|
375
380
|
logger.clearLine();
|
|
@@ -488,26 +493,7 @@ class YiyanBrowser {
|
|
|
488
493
|
|
|
489
494
|
async _isGenerating() {
|
|
490
495
|
return await this.page.evaluate(() => {
|
|
491
|
-
// ── 1.
|
|
492
|
-
const thinkingSelectors = [
|
|
493
|
-
'.container__SPpahQHm', // Yiyan 思考过程区域
|
|
494
|
-
'[class*="container__SPpah"]',
|
|
495
|
-
'[class*="thinking"]',
|
|
496
|
-
'[class*="Thinking"]',
|
|
497
|
-
'[class*="thought"]',
|
|
498
|
-
];
|
|
499
|
-
for (const sel of thinkingSelectors) {
|
|
500
|
-
const el = document.querySelector(sel);
|
|
501
|
-
if (el) {
|
|
502
|
-
const s = window.getComputedStyle(el);
|
|
503
|
-
// 元素可见且有内容
|
|
504
|
-
if (s.display !== 'none' && s.visibility !== 'hidden' && el.innerText && el.innerText.length > 5) {
|
|
505
|
-
return true; // 思考区域有内容,还在生成
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
// ── 2. 检测停止按钮/生成状态 UI ──
|
|
496
|
+
// ── 1. 检测停止按钮/生成状态 UI ──
|
|
511
497
|
const stopSelectors = [
|
|
512
498
|
'button[aria-label*="Stop" i]',
|
|
513
499
|
'button[aria-label*="停止"]',
|
|
@@ -524,7 +510,7 @@ class YiyanBrowser {
|
|
|
524
510
|
}
|
|
525
511
|
}
|
|
526
512
|
|
|
527
|
-
// ──
|
|
513
|
+
// ── 2. 检测加载动画/typing指示器 ──
|
|
528
514
|
const loaderSelectors = [
|
|
529
515
|
'[class*="typing"]',
|
|
530
516
|
'[class*="loading"]',
|
|
@@ -546,7 +532,7 @@ class YiyanBrowser {
|
|
|
546
532
|
}
|
|
547
533
|
}
|
|
548
534
|
|
|
549
|
-
// ──
|
|
535
|
+
// ── 3. 检测是否缺少完成标记元素 ──
|
|
550
536
|
const completionMarkers = [
|
|
551
537
|
'[class*="dialogCardBottom"]',
|
|
552
538
|
'.dialogCardBottom__qoXjps3z',
|