yiyan-browser-agent 1.6.7 → 1.6.8

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 +23 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.6.7",
3
+ "version": "1.6.8",
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
@@ -296,33 +296,36 @@ class YiyanBrowser {
296
296
 
297
297
  if (!appeared) logger.warn('Response may have been delayed — continuing to wait...');
298
298
 
299
- // Phase 2: wait for completion
300
- // 主要:dialogCardBottom 出现
301
- // 备用:内容稳定 + _isGenerating() 确认
299
+ // Phase 2: wait for completion (双重条件都必须满足)
300
+ // 条件1: dialogCardBottom 出现
301
+ // 条件2: 内容稳定 + _isGenerating() 确认
302
302
  let lastText = '';
303
303
  let stableStart = null;
304
304
  let stableCount = 0;
305
305
  let dotCount = 0;
306
+ let hasCompletionMarker = false;
306
307
 
307
308
  while (Date.now() - start < timeout) {
308
309
  const text = await this._extractLastMessage();
309
310
 
310
- // ── 稳定性检测(备用退出路径)──
311
+ // ── 稳定性检测 ──
311
312
  if (text !== lastText) {
312
313
  lastText = text;
313
314
  stableStart = null;
314
315
  stableCount = 0;
315
- } else if (text.length > 50) { // 内容足够长才进入稳定检测
316
+ } else if (text.length > 50) {
316
317
  if (!stableStart) stableStart = Date.now();
317
318
  else if (Date.now() - stableStart >= stableDelay) {
318
319
  stableCount++;
319
320
 
320
- // 连续稳定检测 + _isGenerating 确认
321
321
  if (stableCount >= 2) {
322
322
  if (!await this._isGenerating()) {
323
- logger.clearLine();
324
- logger.dim('Stable completion detected');
325
- break;
323
+ // 稳定性检测通过,检查是否同时有完成标记
324
+ if (hasCompletionMarker) {
325
+ logger.clearLine();
326
+ logger.dim('Completion confirmed (stable + marker)');
327
+ break;
328
+ }
326
329
  }
327
330
  stableCount = 0;
328
331
  stableStart = null;
@@ -332,8 +335,8 @@ class YiyanBrowser {
332
335
  }
333
336
  }
334
337
 
335
- // ── 完成标记检测(主要退出路径)──
336
- const hasCompletion = await this.page.evaluate(() => {
338
+ // ── 完成标记检测 ──
339
+ const detected = await this.page.evaluate(() => {
337
340
  const selectors = [
338
341
  '.dialogCardBottom__qoXjps3z',
339
342
  '[class*="dialogCardBottom"]',
@@ -350,11 +353,15 @@ class YiyanBrowser {
350
353
  return false;
351
354
  });
352
355
 
353
- if (hasCompletion) {
354
- await this.page.waitForTimeout(500);
355
- logger.clearLine();
356
- logger.dim('Completion marker detected');
357
- break;
356
+ if (detected) {
357
+ hasCompletionMarker = true;
358
+ // 有标记,检查稳定性是否也通过
359
+ if (stableCount >= 2 && lastText.length > 50) {
360
+ await this.page.waitForTimeout(500);
361
+ logger.clearLine();
362
+ logger.dim('Completion confirmed (marker + stable)');
363
+ break;
364
+ }
358
365
  }
359
366
 
360
367
  // Progress indicator