yiyan-browser-agent 1.0.8 → 1.0.9
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 +7 -12
- package/src/config.js +3 -3
package/package.json
CHANGED
package/src/browser.js
CHANGED
|
@@ -242,7 +242,8 @@ class YiyanBrowser {
|
|
|
242
242
|
await this.page.waitForTimeout(100);
|
|
243
243
|
|
|
244
244
|
// Type text character by character (stable, works reliably)
|
|
245
|
-
|
|
245
|
+
// delay: 15ms for faster typing while staying stable
|
|
246
|
+
await this.page.keyboard.type(text, { delay: 15 });
|
|
246
247
|
|
|
247
248
|
// Press Enter to send
|
|
248
249
|
await this.page.keyboard.press('Enter');
|
|
@@ -271,13 +272,6 @@ class YiyanBrowser {
|
|
|
271
272
|
|
|
272
273
|
/**
|
|
273
274
|
* Wait until Yiyan finishes generating and return the response text.
|
|
274
|
-
*
|
|
275
|
-
* Algorithm:
|
|
276
|
-
* 1. Record how many assistant messages are on the page right now.
|
|
277
|
-
* 2. Wait until a new message appears (count goes up).
|
|
278
|
-
* 3. Poll the last message text every 300 ms.
|
|
279
|
-
* 4. When the text has not changed for STABLE_DELAY ms AND
|
|
280
|
-
* no stop/loading indicator is visible → done.
|
|
281
275
|
*/
|
|
282
276
|
async waitForResponse() {
|
|
283
277
|
const timeout = config.RESPONSE_TIMEOUT;
|
|
@@ -288,10 +282,10 @@ class YiyanBrowser {
|
|
|
288
282
|
const initialCount = await this._getMessageCount();
|
|
289
283
|
let appeared = false;
|
|
290
284
|
|
|
291
|
-
for (let i = 0; i <
|
|
285
|
+
for (let i = 0; i < 40; i++) {
|
|
292
286
|
const count = await this._getMessageCount();
|
|
293
287
|
if (count > initialCount) { appeared = true; break; }
|
|
294
|
-
await this.page.waitForTimeout(
|
|
288
|
+
await this.page.waitForTimeout(200);
|
|
295
289
|
}
|
|
296
290
|
|
|
297
291
|
if (!appeared) logger.warn('Response may have been delayed — continuing to wait...');
|
|
@@ -310,8 +304,8 @@ class YiyanBrowser {
|
|
|
310
304
|
} else if (text.length > 0) {
|
|
311
305
|
if (!stableStart) stableStart = Date.now();
|
|
312
306
|
else if (Date.now() - stableStart >= stableDelay) {
|
|
313
|
-
if (!await this._isGenerating()) break;
|
|
314
|
-
stableStart = null;
|
|
307
|
+
if (!await this._isGenerating()) break;
|
|
308
|
+
stableStart = null;
|
|
315
309
|
}
|
|
316
310
|
}
|
|
317
311
|
|
|
@@ -319,6 +313,7 @@ class YiyanBrowser {
|
|
|
319
313
|
dotCount = (dotCount + 1) % 4;
|
|
320
314
|
logger.thinking(`Receiving response${'.'.repeat(dotCount)} (${text.length} chars)`);
|
|
321
315
|
}
|
|
316
|
+
await this.page.waitForTimeout(200);
|
|
322
317
|
|
|
323
318
|
logger.clearLine();
|
|
324
319
|
|
package/src/config.js
CHANGED
|
@@ -12,10 +12,10 @@ const defaults = {
|
|
|
12
12
|
SESSION_DIR : path.join(os.homedir(), '.yiyan-agent', 'session'),
|
|
13
13
|
HEADLESS : false,
|
|
14
14
|
|
|
15
|
-
// Timing (
|
|
15
|
+
// Timing (configurable for speed vs stability tradeoff)
|
|
16
16
|
RESPONSE_TIMEOUT : 180_000,
|
|
17
|
-
STABLE_DELAY :
|
|
18
|
-
SEND_DELAY : 100, // Reduced
|
|
17
|
+
STABLE_DELAY : 1_000, // 1s stability check (faster, may cut off long responses)
|
|
18
|
+
SEND_DELAY : 100, // Reduced for faster operation
|
|
19
19
|
|
|
20
20
|
// Agent
|
|
21
21
|
MAX_ITERATIONS : 40,
|