yiyan-browser-agent 1.8.1 → 1.8.2
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 +20 -26
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -297,12 +297,11 @@ class YiyanBrowser {
|
|
|
297
297
|
if (!appeared) logger.warn('Response may have been delayed — continuing to wait...');
|
|
298
298
|
|
|
299
299
|
// Phase 2: wait for completion
|
|
300
|
-
// 条件:
|
|
300
|
+
// 条件: 思考区域和答案区域都稳定不变
|
|
301
301
|
let lastText = '';
|
|
302
302
|
let lastThinkingText = '';
|
|
303
303
|
let stableCount = 0;
|
|
304
|
-
let
|
|
305
|
-
let lastCheckTime = Date.now();
|
|
304
|
+
let lastStableTime = Date.now();
|
|
306
305
|
let dotCount = 0;
|
|
307
306
|
let hasCompletionMarker = false;
|
|
308
307
|
|
|
@@ -321,28 +320,24 @@ class YiyanBrowser {
|
|
|
321
320
|
return { text, exists: true };
|
|
322
321
|
});
|
|
323
322
|
|
|
324
|
-
// ──
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
logger.dim(`Thinking stable: ${thinkingStableCount}/2 (${thinkingInfo.text.length} chars)`);
|
|
329
|
-
}
|
|
330
|
-
} else if (thinkingInfo.text !== lastThinkingText) {
|
|
331
|
-
lastThinkingText = thinkingInfo.text;
|
|
332
|
-
thinkingStableCount = 0;
|
|
333
|
-
lastCheckTime = Date.now();
|
|
334
|
-
}
|
|
323
|
+
// ── 统一稳定性检测:两者都不变才算稳定 ──
|
|
324
|
+
const thinkingStable = thinkingInfo.text === lastThinkingText;
|
|
325
|
+
const answerStable = text === lastText;
|
|
326
|
+
const hasContent = thinkingInfo.text.length > 5 && text.length > 50;
|
|
335
327
|
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
if (Date.now() -
|
|
328
|
+
if (thinkingStable && answerStable && hasContent) {
|
|
329
|
+
// 两者都稳定且有内容,检查稳定时间
|
|
330
|
+
if (Date.now() - lastStableTime >= stableDelay) {
|
|
339
331
|
stableCount++;
|
|
340
|
-
|
|
332
|
+
lastStableTime = Date.now();
|
|
333
|
+
logger.dim(`Both stable: ${stableCount}/2 (thinking: ${thinkingInfo.text.length} chars, answer: ${text.length} chars)`);
|
|
341
334
|
}
|
|
342
|
-
} else
|
|
335
|
+
} else {
|
|
336
|
+
// 任一变化,重置
|
|
337
|
+
lastThinkingText = thinkingInfo.text;
|
|
343
338
|
lastText = text;
|
|
344
339
|
stableCount = 0;
|
|
345
|
-
|
|
340
|
+
lastStableTime = Date.now();
|
|
346
341
|
}
|
|
347
342
|
|
|
348
343
|
// ── 完成标记检测 ──
|
|
@@ -368,10 +363,10 @@ class YiyanBrowser {
|
|
|
368
363
|
}
|
|
369
364
|
|
|
370
365
|
// ── 完成判断 ──
|
|
371
|
-
// 条件1: 标记出现 +
|
|
372
|
-
// 条件2(备用):
|
|
373
|
-
const condition1 = hasCompletionMarker && stableCount >= 2
|
|
374
|
-
const condition2 = stableCount >=
|
|
366
|
+
// 条件1: 标记出现 + 两者都稳定 2 次
|
|
367
|
+
// 条件2(备用): 两者都稳定 3 次(即使没有完成标记)
|
|
368
|
+
const condition1 = hasCompletionMarker && stableCount >= 2;
|
|
369
|
+
const condition2 = stableCount >= 3;
|
|
375
370
|
|
|
376
371
|
if (condition1 || condition2) {
|
|
377
372
|
// 检查 _isGenerating 作为最终确认
|
|
@@ -383,8 +378,7 @@ class YiyanBrowser {
|
|
|
383
378
|
}
|
|
384
379
|
// _isGenerating 说还在生成,重置计数继续等待
|
|
385
380
|
stableCount = 0;
|
|
386
|
-
|
|
387
|
-
lastCheckTime = Date.now();
|
|
381
|
+
lastStableTime = Date.now();
|
|
388
382
|
}
|
|
389
383
|
|
|
390
384
|
// Progress indicator
|