gemini-proxy-client 1.0.2 → 1.0.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.
@@ -129,9 +129,7 @@ export class BrowserManager {
129
129
  if (!this.page)
130
130
  throw new Error('Browser not launched');
131
131
  // 等待页面完全加载
132
- await sleep(2000);
133
- // 查找并修改 WebSocket 连接地址 (如果需要)
134
- // 这取决于 Build App 的实现方式
132
+ await sleep(5000);
135
133
  // 尝试多种方式找到连接按钮
136
134
  const buttonSelectors = [
137
135
  'button:has-text("Connect WS")', // 实际按钮文字
@@ -142,14 +140,16 @@ export class BrowserManager {
142
140
  'button.bg-green-500', // 绿色按钮
143
141
  ];
144
142
  let clicked = false;
143
+ // 先尝试设置服务器地址 (如果有输入框)
144
+ await this.setServerAddress();
145
145
  for (const selector of buttonSelectors) {
146
146
  try {
147
- const button = await this.page.$(selector);
147
+ // 使用 waitForSelector 等待按钮出现
148
+ const button = await this.page.waitForSelector(selector, { timeout: 3000 });
148
149
  if (button) {
149
- // 先尝试设置服务器地址 (如果有输入框)
150
- await this.setServerAddress();
151
150
  await button.click();
152
151
  clicked = true;
152
+ console.log(chalk.green(`✅ 找到并点击了按钮: ${selector}`));
153
153
  break;
154
154
  }
155
155
  }
@@ -158,15 +158,9 @@ export class BrowserManager {
158
158
  }
159
159
  }
160
160
  if (!clicked) {
161
- // 如果找不到按钮,可能需要通过其他方式触发连接
162
- // 尝试在页面中执行 JavaScript
163
- await this.page.evaluate(({ serverUrl, token }) => {
164
- // 尝试找到全局的连接函数或 WebSocket 实例
165
- const wsUrl = `${serverUrl}?auth_token=${token}`;
166
- console.log('Attempting to connect to:', wsUrl);
167
- // 这里的实现取决于 Build App 的具体代码结构
168
- // 可能需要根据实际情况调整
169
- }, { serverUrl: this.options.serverUrl, token: this.options.token });
161
+ // 打印页面上所有按钮,帮助调试
162
+ const buttons = await this.page.$$eval('button', (btns) => btns.map(b => ({ text: b.textContent?.trim(), class: b.className, title: b.title })));
163
+ console.log(chalk.gray('页面上的按钮:'), JSON.stringify(buttons, null, 2));
170
164
  console.log(chalk.yellow('⚠️ 未找到连接按钮,请手动点击连接'));
171
165
  }
172
166
  // 等待连接建立
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gemini-proxy-client",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Gemini Proxy Build App 客户端 - 使用 Camoufox 自动保持连接",
5
5
  "main": "dist/index.js",
6
6
  "bin": {