yiyan-browser-agent 1.7.6 → 1.7.7

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 +14 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.7.6",
3
+ "version": "1.7.7",
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
@@ -344,29 +344,30 @@ class YiyanBrowser {
344
344
  hasCompletionMarker = true;
345
345
  }
346
346
 
347
- // ── 完成判断:标记出现 + 连续两次稳定 + _isGenerating 确认 + 思考区域检查 ──
347
+ // ── 完成判断:标记出现 + 连续两次稳定 + 思考区域已消失 ──
348
348
  if (hasCompletionMarker && stableCount >= 2) {
349
- // 检查思考区域是否有内容
350
- const hasThinkingContent = await this.page.evaluate(() => {
349
+ // 检查思考区域是否存在且有内容
350
+ const thinkingStatus = await this.page.evaluate(() => {
351
351
  const thinkingEl = document.querySelector('.container__SPpahQHm, [class*="container__SPpah"]');
352
- if (thinkingEl) {
353
- const s = window.getComputedStyle(thinkingEl);
354
- if (s.display !== 'none' && s.visibility !== 'hidden') {
355
- const text = thinkingEl.innerText || '';
356
- return text.length > 5; // 思考区域有内容
357
- }
358
- }
359
- return false;
352
+ if (!thinkingEl) return { exists: false, hasContent: false };
353
+
354
+ const s = window.getComputedStyle(thinkingEl);
355
+ const isVisible = s.display !== 'none' && s.visibility !== 'hidden';
356
+ const text = thinkingEl.innerText || '';
357
+ const hasContent = text.length > 5;
358
+
359
+ return { exists: true, isVisible, hasContent };
360
360
  });
361
361
 
362
- if (hasThinkingContent) {
363
- // 思考区域有内容,还没完成
362
+ // 思考区域存在且可见且有内容 → 还在思考,继续等待
363
+ if (thinkingStatus.exists && thinkingStatus.isVisible && thinkingStatus.hasContent) {
364
364
  stableCount = 0;
365
365
  lastCheckTime = Date.now();
366
366
  logger.dim('Thinking in progress, continue waiting...');
367
367
  continue;
368
368
  }
369
369
 
370
+ // 思考区域已消失/不可见/无内容 → 检查 _isGenerating
370
371
  if (!await this._isGenerating()) {
371
372
  await this.page.waitForTimeout(500);
372
373
  logger.clearLine();