yiyan-browser-agent 1.7.2 → 1.7.3

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 +11 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yiyan-browser-agent",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
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
@@ -444,11 +444,15 @@ class YiyanBrowser {
444
444
  return result.trim();
445
445
  }
446
446
 
447
- const directSelectors = [
448
- // Yiyan specific: answer text container (highest priority)
449
- '#answer_text_id',
450
- '[id="answer_text_id"]',
451
- // Generic selectors
447
+ // ── 优先:仅从 answer_text_id 提取内容 ──
448
+ const answerEl = document.querySelector('#answer_text_id');
449
+ if (answerEl) {
450
+ const t = getFullText(answerEl);
451
+ if (t.length > 0) return t;
452
+ }
453
+
454
+ // ── 备用:其他选择器(仅当 answer_text_id 不存在时)──
455
+ const backupSelectors = [
452
456
  '[class*="answer"]',
453
457
  '[class*="response"]',
454
458
  '[class*="message"][class*="content"]',
@@ -462,12 +466,12 @@ class YiyanBrowser {
462
466
  '[class*="message-content"]:last-child',
463
467
  ];
464
468
 
465
- for (const sel of directSelectors) {
469
+ for (const sel of backupSelectors) {
466
470
  try {
467
471
  const els = document.querySelectorAll(sel);
468
472
  if (els.length > 0) {
469
473
  const t = getFullText(els[els.length - 1]);
470
- if (t.length > 10) return t;
474
+ if (t.length > 5) return t;
471
475
  }
472
476
  } catch {}
473
477
  }