yiyan-browser-agent 1.0.25 → 1.0.26
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-manager.js +2 -2
- package/src/page-agent.js +10 -3
package/package.json
CHANGED
package/src/browser-manager.js
CHANGED
|
@@ -39,8 +39,8 @@ class BrowserManager {
|
|
|
39
39
|
userAgent: 'Mozilla/5.0 AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36',
|
|
40
40
|
});
|
|
41
41
|
const page = await context.newPage();
|
|
42
|
-
await page.goto(config.YIYAN_URL, { waitUntil: '
|
|
43
|
-
await page.waitForTimeout(
|
|
42
|
+
await page.goto(config.YIYAN_URL, { waitUntil: 'networkidle', timeout: 20000 });
|
|
43
|
+
await page.waitForTimeout(1500); // Extra wait for UI to render
|
|
44
44
|
|
|
45
45
|
logger.success('Connected! New tab opened.');
|
|
46
46
|
return { browser, context, page, isNew: false };
|
package/src/page-agent.js
CHANGED
|
@@ -27,17 +27,24 @@ class PageAgent {
|
|
|
27
27
|
* Send message to Yiyan
|
|
28
28
|
*/
|
|
29
29
|
async sendMessage(text) {
|
|
30
|
+
// Wait for page to be fully loaded
|
|
31
|
+
await this.page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {});
|
|
32
|
+
await this.page.waitForTimeout(1000);
|
|
33
|
+
|
|
30
34
|
// Find input
|
|
31
35
|
let inputEl = null;
|
|
32
36
|
for (const sel of SEL.chatInput) {
|
|
33
37
|
try {
|
|
34
|
-
inputEl = await this.page.waitForSelector(sel, { timeout:
|
|
35
|
-
if (inputEl)
|
|
38
|
+
inputEl = await this.page.waitForSelector(sel, { timeout: 8000, state: 'visible' });
|
|
39
|
+
if (inputEl) {
|
|
40
|
+
logger.dim('Found input: ' + sel);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
36
43
|
} catch {}
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
if (!inputEl) {
|
|
40
|
-
throw new Error('Cannot find input box');
|
|
47
|
+
throw new Error('Cannot find input box. Make sure Yiyan page is loaded.');
|
|
41
48
|
}
|
|
42
49
|
|
|
43
50
|
// Focus and clear
|