gemini-proxy-client 1.0.0 → 1.0.2
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/dist/browser/manager.js +4 -2
- package/dist/commands/start.js +48 -0
- package/package.json +1 -1
package/dist/browser/manager.js
CHANGED
|
@@ -134,10 +134,12 @@ export class BrowserManager {
|
|
|
134
134
|
// 这取决于 Build App 的实现方式
|
|
135
135
|
// 尝试多种方式找到连接按钮
|
|
136
136
|
const buttonSelectors = [
|
|
137
|
+
'button:has-text("Connect WS")', // 实际按钮文字
|
|
138
|
+
'button[aria-label="Connect WebSocket Proxy"]', // aria-label
|
|
139
|
+
'button[title="Connect WebSocket Proxy"]', // title 属性
|
|
137
140
|
'button:has-text("ws connect")',
|
|
138
141
|
'button:has-text("connect")',
|
|
139
|
-
'
|
|
140
|
-
'.connect-button',
|
|
142
|
+
'button.bg-green-500', // 绿色按钮
|
|
141
143
|
];
|
|
142
144
|
let clicked = false;
|
|
143
145
|
for (const selector of buttonSelectors) {
|
package/dist/commands/start.js
CHANGED
|
@@ -2,12 +2,60 @@ import chalk from 'chalk';
|
|
|
2
2
|
import ora from 'ora';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import path from 'path';
|
|
5
|
+
import { execSync } from 'child_process';
|
|
5
6
|
import { BrowserManager } from '../browser/manager.js';
|
|
6
7
|
import { generateToken, ensureDataDir } from '../utils/helpers.js';
|
|
8
|
+
/**
|
|
9
|
+
* 检查 Camoufox 是否已安装
|
|
10
|
+
*/
|
|
11
|
+
function checkCamoufoxInstalled() {
|
|
12
|
+
try {
|
|
13
|
+
// 检查常见的安装路径
|
|
14
|
+
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
15
|
+
const possiblePaths = [
|
|
16
|
+
path.join(homeDir, 'Library', 'Caches', 'camoufox', 'version.json'), // macOS
|
|
17
|
+
path.join(homeDir, '.cache', 'camoufox', 'version.json'), // Linux
|
|
18
|
+
path.join(homeDir, 'AppData', 'Local', 'camoufox', 'version.json'), // Windows
|
|
19
|
+
];
|
|
20
|
+
return possiblePaths.some(p => fs.existsSync(p));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 尝试安装 Camoufox
|
|
28
|
+
*/
|
|
29
|
+
async function installCamoufox() {
|
|
30
|
+
console.log(chalk.yellow('📦 Camoufox 浏览器未安装,正在下载...'));
|
|
31
|
+
console.log(chalk.gray(' 这可能需要几分钟,取决于网络速度'));
|
|
32
|
+
try {
|
|
33
|
+
execSync('npx camoufox-js fetch', {
|
|
34
|
+
stdio: 'inherit',
|
|
35
|
+
timeout: 300000 // 5 分钟超时
|
|
36
|
+
});
|
|
37
|
+
console.log(chalk.green('✅ Camoufox 安装成功!'));
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
console.log(chalk.red('❌ Camoufox 安装失败'));
|
|
42
|
+
console.log(chalk.yellow(' 请手动运行: npx camoufox-js fetch'));
|
|
43
|
+
console.log(chalk.gray(' 如果网络有问题,可以尝试设置代理:'));
|
|
44
|
+
console.log(chalk.gray(' export https_proxy=http://127.0.0.1:7890'));
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
7
48
|
export async function startClient(options) {
|
|
8
49
|
const { server, daemon, dataDir } = options;
|
|
9
50
|
// 确保数据目录存在
|
|
10
51
|
ensureDataDir(dataDir);
|
|
52
|
+
// 检查 Camoufox 是否已安装
|
|
53
|
+
if (!checkCamoufoxInstalled()) {
|
|
54
|
+
const installed = await installCamoufox();
|
|
55
|
+
if (!installed) {
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
11
59
|
// 生成或使用指定的 token
|
|
12
60
|
const token = options.token || generateToken();
|
|
13
61
|
console.log(chalk.cyan('🦊 Gemini Proxy Client'));
|