yiyan-browser-agent 1.0.9 → 1.0.10

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 +12 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
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,14 +135,12 @@ class YiyanBrowser {
135
135
 
136
136
  async _navigate(url) {
137
137
  try {
138
- // Wait for network idle, then extra wait for dynamic content
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);
138
+ // Fast navigation - domcontentloaded is faster than networkidle
139
+ await this.page.goto(url, { waitUntil: 'domcontentloaded', timeout: 15_000 });
140
+ await this.page.waitForTimeout(300); // Minimal wait for SPA render
142
141
  } catch (err) {
143
142
  logger.warn(`Navigation warning: ${err.message}`);
144
- // Fallback: longer wait if networkidle fails
145
- await this.page.waitForTimeout(2000);
143
+ await this.page.waitForTimeout(800);
146
144
  }
147
145
  }
148
146
 
@@ -150,10 +148,10 @@ class YiyanBrowser {
150
148
  try {
151
149
  for (const sel of SEL.newChat) {
152
150
  try {
153
- const el = await this.page.waitForSelector(sel, { timeout: 2_000, state: 'visible' });
151
+ const el = await this.page.waitForSelector(sel, { timeout: 1_500, state: 'visible' });
154
152
  if (el) {
155
153
  await el.click();
156
- await this.page.waitForTimeout(500);
154
+ await this.page.waitForTimeout(200);
157
155
  logger.dim('Started new chat session');
158
156
  return;
159
157
  }
@@ -168,9 +166,8 @@ class YiyanBrowser {
168
166
  // ── Login handling (optimized) ─────────────────────────────────────────────
169
167
 
170
168
  async _ensureLoggedIn() {
171
- // Wait for page to be fully interactive
172
- await this.page.waitForLoadState('domcontentloaded', { timeout: 5_000 }).catch(() => {});
173
- await this.page.waitForTimeout(500);
169
+ // Quick check, no unnecessary waiting
170
+ await this.page.waitForTimeout(200);
174
171
 
175
172
  const needsLogin = await this.page.evaluate(() => {
176
173
  const url = window.location.href;
@@ -190,7 +187,7 @@ class YiyanBrowser {
190
187
  if (needsLogin) {
191
188
  this._printLoginBanner();
192
189
  await this._waitForEnter();
193
- await this.page.waitForNavigation({ waitUntil: 'networkidle', timeout: 30_000 }).catch(() => {});
190
+ await this.page.waitForNavigation({ waitUntil: 'domcontentloaded', timeout: 15_000 }).catch(() => {});
194
191
  }
195
192
  }
196
193
 
@@ -235,15 +232,14 @@ class YiyanBrowser {
235
232
 
236
233
  // Focus and select all existing content
237
234
  await el.click({ clickCount: 3, force: true });
238
- await this.page.waitForTimeout(200);
235
+ await this.page.waitForTimeout(100);
239
236
 
240
237
  // Clear by pressing Delete
241
238
  await this.page.keyboard.press('Delete');
242
- await this.page.waitForTimeout(100);
239
+ await this.page.waitForTimeout(50);
243
240
 
244
241
  // Type text character by character (stable, works reliably)
245
- // delay: 15ms for faster typing while staying stable
246
- await this.page.keyboard.type(text, { delay: 15 });
242
+ await this.page.keyboard.type(text, { delay: 10 });
247
243
 
248
244
  // Press Enter to send
249
245
  await this.page.keyboard.press('Enter');