yiyan-browser-agent 1.0.5 → 1.0.6

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 +10 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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
@@ -135,10 +135,14 @@ class YiyanBrowser {
135
135
 
136
136
  async _navigate(url) {
137
137
  try {
138
- // Wait for network idle instead of fixed timeout
138
+ // Wait for network idle, then extra wait for dynamic content
139
139
  await this.page.goto(url, { waitUntil: 'networkidle', timeout: 30_000 });
140
+ // Give React/Vue SPA time to render
141
+ await this.page.waitForTimeout(800);
140
142
  } catch (err) {
141
143
  logger.warn(`Navigation warning: ${err.message}`);
144
+ // Fallback: longer wait if networkidle fails
145
+ await this.page.waitForTimeout(2000);
142
146
  }
143
147
  }
144
148
 
@@ -149,8 +153,7 @@ class YiyanBrowser {
149
153
  const el = await this.page.waitForSelector(sel, { timeout: 2_000, state: 'visible' });
150
154
  if (el) {
151
155
  await el.click();
152
- // Smart wait for URL change or page update
153
- await this.page.waitForLoadState('domcontentloaded', { timeout: 3_000 }).catch(() => {});
156
+ await this.page.waitForTimeout(500);
154
157
  logger.dim('Started new chat session');
155
158
  return;
156
159
  }
@@ -165,8 +168,9 @@ class YiyanBrowser {
165
168
  // ── Login handling (optimized) ─────────────────────────────────────────────
166
169
 
167
170
  async _ensureLoggedIn() {
168
- // Smart wait for page to be interactive
171
+ // Wait for page to be fully interactive
169
172
  await this.page.waitForLoadState('domcontentloaded', { timeout: 5_000 }).catch(() => {});
173
+ await this.page.waitForTimeout(500);
170
174
 
171
175
  const needsLogin = await this.page.evaluate(() => {
172
176
  const url = window.location.href;
@@ -186,7 +190,6 @@ class YiyanBrowser {
186
190
  if (needsLogin) {
187
191
  this._printLoginBanner();
188
192
  await this._waitForEnter();
189
- // Wait for navigation after login
190
193
  await this.page.waitForNavigation({ waitUntil: 'networkidle', timeout: 30_000 }).catch(() => {});
191
194
  }
192
195
  }
@@ -278,7 +281,8 @@ class YiyanBrowser {
278
281
  async _findInput() {
279
282
  for (const sel of SEL.chatInput) {
280
283
  try {
281
- const el = await this.page.waitForSelector(sel, { timeout: 3_000, state: 'visible' });
284
+ // Increased timeout for initial page load
285
+ const el = await this.page.waitForSelector(sel, { timeout: 8_000, state: 'visible' });
282
286
  if (!el) continue;
283
287
  const tagName = await el.evaluate(e => e.tagName.toLowerCase());
284
288
  const isContentEditable = await el.evaluate(e => e.isContentEditable);