yiyan-browser-agent 1.7.4 → 1.7.5

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/browser.js +24 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "AI coding agent powered by Yiyan (文心一言) via browser automation — no API key needed",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/browser.js CHANGED
@@ -534,7 +534,26 @@ class YiyanBrowser {
534
534
 
535
535
  async _isGenerating() {
536
536
  return await this.page.evaluate(() => {
537
- // ── 1. 检测停止按钮/生成状态 UI ──
537
+ // ── 1. 检测思考过程区域(最重要)──
538
+ const thinkingSelectors = [
539
+ '.container__SPpahQHm', // Yiyan 思考过程区域
540
+ '[class*="container__SPpah"]',
541
+ '[class*="thinking"]',
542
+ '[class*="Thinking"]',
543
+ '[class*="thought"]',
544
+ ];
545
+ for (const sel of thinkingSelectors) {
546
+ const el = document.querySelector(sel);
547
+ if (el) {
548
+ const s = window.getComputedStyle(el);
549
+ // 元素可见且有内容
550
+ if (s.display !== 'none' && s.visibility !== 'hidden' && el.innerText && el.innerText.length > 5) {
551
+ return true; // 思考区域有内容,还在生成
552
+ }
553
+ }
554
+ }
555
+
556
+ // ── 2. 检测停止按钮/生成状态 UI ──
538
557
  const stopSelectors = [
539
558
  'button[aria-label*="Stop" i]',
540
559
  'button[aria-label*="停止"]',
@@ -551,7 +570,7 @@ class YiyanBrowser {
551
570
  }
552
571
  }
553
572
 
554
- // ── 2. 检测加载动画/typing指示器 ──
573
+ // ── 3. 检测加载动画/typing指示器 ──
555
574
  const loaderSelectors = [
556
575
  '[class*="typing"]',
557
576
  '[class*="loading"]',
@@ -573,11 +592,10 @@ class YiyanBrowser {
573
592
  }
574
593
  }
575
594
 
576
- // ── 3. 检测是否缺少完成标记元素 ──
577
- // dialogCardBottom 是 Yiyan 响应完成后的底部操作区域
595
+ // ── 4. 检测是否缺少完成标记元素 ──
578
596
  const completionMarkers = [
579
- '[class*="dialogCardBottom"]', // Yiyan 对话卡片底部
580
- '.dialogCardBottom__qoXjps3z', // Yiyan 特定 class
597
+ '[class*="dialogCardBottom"]',
598
+ '.dialogCardBottom__qoXjps3z',
581
599
  '[class*="copy-btn"]',
582
600
  '[class*="copyBtn"]',
583
601
  '[aria-label*="Copy" i]',