magpie-gemini-web 0.5.6 → 0.7.0

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/README.en.md CHANGED
@@ -1,4 +1,6 @@
1
- # magpie-gemini-web
1
+ # <img src="docs/logo.svg" width="28" height="28" align="top" alt="" /> magpie-gemini-web
2
+
3
+ [![npm version](https://img.shields.io/npm/v/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/magpie-gemini-web) [![npm downloads](https://img.shields.io/npm/dw/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/magpie-gemini-web) [![Magpie Plugin](https://img.shields.io/badge/Magpie-Plugin-3b82f6?style=flat-square)](https://usemagpie.ai/) [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-8b5cf6?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/) [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-6366f1?style=flat-square)](https://github.com/BUKOWSKIREAL/magpie-gemini-web) [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
2
4
 
3
5
  [中文](README.md) | English
4
6
 
@@ -14,10 +16,10 @@ The plugin provides two independent providers that can be used individually or t
14
16
  | :--- | :--- | :--- |
15
17
  | **Best for** | **Coding agents (recommended)** | General chat, web-only models & web quota |
16
18
  | **Tool calling** | **Native Function Calling**, reliable | Prompt-emulated (experimental; Flash often skips tools) |
17
- | **Thinking levels** | `minimal` / `low` / `medium` / `high` (`minimal` is fastest & cheapest) | `low` (base) / `high` (`-thinking` extended thinking) |
19
+ | **Thinking levels** | Supported levels from the model catalog: `minimal` / `low` / `medium` / `high` | `low` (base) / `medium` (`-thinking-medium`, `gemini-4-argon` only) / `high` (`-thinking` extended thinking) |
18
20
  | **Sign-in method** | Sign in directly in an isolated popup browser window | Copy `cookie` from a private/incognito window |
19
21
  | **Usage cards** | Shows models currently on cooldown and recovery times | Syncs **5-hour** & **weekly** usage and reset times from the web |
20
- | **Local backend** | AIStudio2API (`v0.2.14`) | gemini-web2api-go (`4.22.0-magpie.1` optimized build) |
22
+ | **Local backend** | AIStudio2API (`v0.2.17`) | gemini-web2api-go (`4.26.0-magpie.1` optimized build) |
21
23
 
22
24
  ---
23
25
 
@@ -29,12 +31,12 @@ Install **magpie-gemini-web** from the Magpie plugin market, then sign in to eit
29
31
 
30
32
  1. Sign in to **Google AI Studio** in Magpie and choose **「用 Google 账号登录(推荐)」** (Sign in with a Google account).
31
33
  2. Sign in to your Google account in the separate login window that opens (your regular browser is unaffected), then close the window.
32
- > On first run, the local service (~25 MB) and the login browser Camoufox (~300 MB) are downloaded first, so the window may take a few minutes to appear. While they download, Magpie opens a progress page in your browser. Magpie waits at most 10 minutes, downloads included, so finish signing in promptly; if GitHub is unreachable, set `studio.proxy` first (see plugin options and proxy settings below).
34
+ > On first run, the local service (~30 MB) and the login browser Camoufox (~300 MB) are downloaded first, so the window may take a few minutes to appear. While they download, Magpie opens a progress page in your browser. Magpie waits at most 10 minutes, downloads included, so finish signing in promptly; if GitHub is unreachable, set `studio.proxy` first (see plugin options and proxy settings below).
33
35
  3. **Managing accounts:** Choose "Sign in with a Google account" again at any time to **add a new account**, create a card for an existing local account, or **re-authenticate** an expired account.
34
36
 
35
37
  ### Option 2: Gemini Web (`gemini-web`)
36
38
 
37
- 1. Sign in to **Gemini Web** in Magpie and choose **「一键配置本地 Gemini Web(推荐)」** (One-click local setup).
39
+ 1. Sign in to **Gemini Web** in Magpie and choose **「一键配置本地 Gemini Web(推荐)」** (One-click local setup). If you need a proxy to reach Google, enter its URL (e.g. `http://127.0.0.1:7890`) when prompted at the start of sign-in, or leave it blank for direct connection / existing proxy pool.
38
40
  2. Copy your cookie using a **private / incognito window** (Firefox recommended):
39
41
  1. Open <https://gemini.google.com/app> in the private window and sign in to your Google account.
40
42
  2. Press `F12` (`⌥⌘I` on macOS), switch to the **Network** tab, and reload the page.
@@ -42,6 +44,8 @@ Install **magpie-gemini-web** from the Magpie plugin market, then sign in to eit
42
44
  4. **Close the private window directly—do not sign out** (signing out invalidates the cookie).
43
45
  3. The plugin verifies the account and completes sign-in. Repeat the steps above to add more accounts.
44
46
 
47
+ > **Backend upgrade required during sign-in?** An older background process may still be running. Exit Magpie, stop the matching `gemini-web2api-go` process (Windows: Task Manager → Details → `gemini-web2api-go.exe`), then run the full installation command shown in the error. It preserves accounts and configuration and selects the plugin's managed backend. Set `GEMINI_WEB_PROXY` first if the download needs a proxy. Reopen Magpie and sign in after installation.
48
+
45
49
  > **Why is a private window required?** The backend periodically refreshes this session to keep it alive. If it shares a session with your daily browser, Google will revoke the session and sign your browser out of all Google services. A private window (or a dedicated secondary Google account) gives the backend an isolated session.
46
50
 
47
51
  ---
@@ -84,6 +88,7 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
84
88
  | `allowImages` | `false` | Shared (override via `studio.allowImages`) | Allow image input |
85
89
  | `requestTimeoutMs` / `modelTimeoutMs` | Web: `240000` / `10000`; Studio: `1800000` / `10000` | Shared (override via `studio.*`) | Timeout (ms) per backend wait or model list fetch; resets on stream data, explicit settings take precedence |
86
90
  | `stripCitations` | `true` | `gemini-web` only | Strip `[cite: 1]` and `[cite_start]` markers from replies and tool arguments (not supported on AI Studio) |
91
+ | `proxy` | none | `gemini-web` only | Proxy for the managed Gemini Web backend to reach Google (`http` / `https` / `socks5` / `socks5h`), or set `GEMINI_WEB_PROXY` env var / enter during sign-in |
87
92
  | `baseURL` | `http://127.0.0.1:8083/v1` | `gemini-web` only | Default Gemini Web backend URL |
88
93
  | `contextLimit` / `outputLimit` | `1000000` / `8192` | `gemini-web` only | Context and output limits reported to clients |
89
94
  | `studio.proxy` | none | `ai-studio` only | Proxy for reaching Google (`http` / `https` / `socks5`), or set `AI_STUDIO_PROXY` env var; when set, it takes precedence over the proxy saved in the admin page. An empty value counts as unset |
@@ -93,11 +98,11 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
93
98
  **Using a proxy to reach Google:**
94
99
  - **AI Studio:** Preferably set it in the local admin page. Open the address on the usage card's "管理页" (admin page) line (default `http://127.0.0.1:2048`) and sign in as `magpie` with `adminPassword` from `config.json` in the data directory. Save the proxy, then restart the service from the admin page. The plugin keeps the saved value when it restarts the backend.
95
100
  - Alternatively, `studio.proxy` or `AI_STUDIO_PROXY` take precedence over the saved proxy. A change applies after the local service restarts (`npm run studio:stop`; the next request starts it again).
96
- - With none set, the backend goes out directly, or on Windows through the system proxy (Windows proxy settings).
101
+ - With none set, the backend goes out directly, or through the system proxy on macOS and Windows.
97
102
  - **The backend uses neither Magpie's proxies (including the provider proxy set for `ai-studio`) nor `HTTPS_PROXY` and similar variables**: it keeps running after Magpie quits, when a proxy borrowed from Magpie may be gone. Use one of the options above. A backend started by a plugin version from before this fix may still be using a proxy from the environment it was started in (Magpie's, for example); the "代理出口" line marks it and says what a restart changes.
98
103
  - The usage card's "代理出口" (proxy) line, the Google sign-in instructions and failure messages, and `npm run studio:status` show the proxy the backend actually uses, where it comes from, and whether a new setting still needs a restart.
99
104
  - The listen address, API key and admin credentials are managed by the plugin; changing them in the admin page has no effect.
100
- - **Gemini Web:** The backend ignores `HTTP_PROXY`. Add your proxy to the proxy pool in the local admin panel at `http://127.0.0.1:8083/admin` (password is `adminToken` in `secrets.json` inside the data directory).
105
+ - **Gemini Web:** The backend ignores system proxies and `HTTP_PROXY`. Enter your proxy URL when prompted at the start of "One-click local setup", set the `proxy` plugin option or `GEMINI_WEB_PROXY` environment variable, or add it to the proxy pool in the local admin panel at `http://127.0.0.1:8083/admin` (password is `adminToken` in `secrets.json` inside the data directory).
101
106
  - *Note:* When using a proxy pool, send one request with a newly added account so the backend binds it to a proxy, then re-add it via "Add an existing Google account from the local backend" to load its email and usage (SOCKS proxies are not supported for usage reads).
102
107
 
103
108
  **Connecting a self-hosted backend:**
@@ -144,7 +149,7 @@ When a plugin error asks you to run a command, it includes the full ready-to-cop
144
149
  - Concurrency is capped at 1, but Google account rate-limiting or flagging cannot be completely ruled out—use at your own risk.
145
150
 
146
151
  **AI Studio upgrades and model selection:**
147
- - The plugin pins SHA-256-verified `v0.2.14-magpie.1`, based on upstream `v0.2.14`. Upgrade the plugin to update the backend. Official releases at or below that upstream version, and managed backends an older plugin installed, are upgraded on the next managed startup, preserving accounts, port and sign-in credentials.
152
+ - The plugin pins SHA-256-verified `v0.2.17-magpie.1`, based on upstream `v0.2.17`. Upgrade the plugin to update the backend. Official releases at or below that upstream version, and managed backends an older plugin installed, are upgraded on the next managed startup, preserving accounts, port and sign-in credentials.
148
153
  - **Online updates are disabled in the managed backend on macOS, Linux, and Windows.** The admin page says updates are managed by magpie-gemini-web; the update endpoint returns HTTP 409 and update checks do not contact GitHub. Independently managed external servers are unaffected. See [docs/studio-release.md](docs/studio-release.md) for how the managed build is made and reproduced.
149
154
  - Managed Unix installs still attempt to set `package/` to `0555` as additional file protection. Permission failures do not block service, and disabling online updates does not depend on permissions. To reset by manually deleting the data directory, stop the service first, then run `chmod -R u+w "<data-dir>/package"` before deleting it; replace `<data-dir>` with the actual path.
150
155
  - If a newer or custom version is installed, the plugin reports a conflict with `stop`, `install`, and `start` commands carrying the correct `--data-dir`. Stop can recover a changed listener PID and verifies its executable path before signaling it. If HTTP is down but the process is still alive, the plugin refuses to reinstall or launch a second process.
@@ -154,11 +159,11 @@ When a plugin error asks you to run a command, it includes the full ready-to-cop
154
159
  - Models with `-build` or `assistant_route` are filtered out: they inject the Build coding assistant's own system prompt and are not offered as ordinary Agent models. Refresh with `magpie provider models ai-studio` after upgrading.
155
160
 
156
161
  **Gemini Web optimized backend upgrades & rollback:**
157
- - One-click setup uses [4.22.0-magpie.1](https://github.com/BUKOWSKIREAL/magpie-gemini-web/releases/tag/backend-v4.22.0-magpie.1) by default (built from pinned upstream v4.22.0 with XSRF caching, request cancellation propagation, early tool-call completion, and Argon model verification).
162
+ - One-click setup uses [4.26.0-magpie.1](https://github.com/BUKOWSKIREAL/magpie-gemini-web/releases/tag/backend-v4.26.0-magpie.1) by default (built from pinned upstream v4.26.0 with XSRF caching, request cancellation propagation, early tool-call completion, and Argon model verification).
158
163
  - **Upgrading:** Running backends are not interrupted automatically. Stop the existing process (PID in `backend.pid` inside the data directory); the next Magpie launch or request will upgrade the binary while preserving config and cookies.
159
164
  - **Rollback to upstream / restore optimized build** (run in the plugin directory after stopping the backend):
160
165
  ```bash
161
- npm run backend:install:upstream # Roll back and pin to official v4.22.0
166
+ npm run backend:install:upstream # Roll back and pin to official v4.26.0
162
167
  npm run backend:install # Restore default optimized build
163
168
  ```
164
169
  - For reproducible builds and release procedures, see [docs/backend-release.md](docs/backend-release.md).
@@ -173,3 +178,17 @@ On macOS, Gemini Web sign-in includes an experimental **macOS Native Task** opti
173
178
  ## License
174
179
 
175
180
  MIT. The upstream `gemini-web2api-go` project is also MIT (see `LICENSE-UPSTREAM`).
181
+
182
+ ---
183
+
184
+ ## Star History
185
+
186
+ <p align="center">
187
+ <a href="https://www.star-history.com/#BUKOWSKIREAL/magpie-gemini-web&amp;Date">
188
+ <picture>
189
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date&amp;theme=dark" />
190
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date" />
191
+ <img alt="GitHub star history for magpie-gemini-web" src="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date" width="800" />
192
+ </picture>
193
+ </a>
194
+ </p>
package/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # magpie-gemini-web
1
+ # <img src="docs/logo.svg" width="28" height="28" align="top" alt="" /> magpie-gemini-web
2
+
3
+ [![npm version](https://img.shields.io/npm/v/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/magpie-gemini-web) [![npm downloads](https://img.shields.io/npm/dw/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/magpie-gemini-web) [![Magpie Plugin](https://img.shields.io/badge/Magpie-Plugin-3b82f6?style=flat-square)](https://usemagpie.ai/) [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-8b5cf6?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/) [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-6366f1?style=flat-square)](https://github.com/BUKOWSKIREAL/magpie-gemini-web) [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
2
4
 
3
5
  中文 | [English](README.en.md)
4
6
 
@@ -14,10 +16,10 @@
14
16
  | :--- | :--- | :--- |
15
17
  | **适用场景** | **推荐 Coding Agent 使用** | 日常对话、使用网页版专属模型与额度 |
16
18
  | **工具调用** | **原生 Function Calling**,稳定可靠 | 提示词模拟(实验性,Flash 系列常不调工具) |
17
- | **思考档位** | `minimal` / `low` / `medium` / `high` 四档(`minimal` 最快最省) | `low`(普通)/ `high`(`-thinking` 扩展思考)两档 |
19
+ | **思考档位** | 按模型目录提供 `minimal` / `low` / `medium` / `high` 中支持的档位 | `low`(普通)/ `medium`(`-thinking-medium`,仅 `gemini-4-argon`)/ `high`(`-thinking` 扩展思考) |
18
20
  | **登录方式** | 弹出独立浏览器窗口直接登录 Google | 用无痕窗口登录并复制 `cookie` |
19
21
  | **额度卡片** | 显示冷却中的模型与恢复时间 | 同步网页版 **5 小时** 与 **每周** 用量及重置时间 |
20
- | **本地后端** | AIStudio2API (`v0.2.14`) | gemini-web2api-go (`4.22.0-magpie.1` 优化版) |
22
+ | **本地后端** | AIStudio2API (`v0.2.17`) | gemini-web2api-go (`4.26.0-magpie.1` 优化版) |
21
23
 
22
24
  ---
23
25
 
@@ -29,12 +31,12 @@
29
31
 
30
32
  1. 在 Magpie 中登录 **Google AI Studio**,选择 **「用 Google 账号登录(推荐)」**。
31
33
  2. 在弹出的独立登录窗口中登录 Google 账号(不影响日常浏览器),完成后直接关闭窗口。
32
- > 首次使用要先下载本地服务(约 25 MB)和登录浏览器 Camoufox(约 300 MB),弹窗可能需要等几分钟才出现。需要下载时,Magpie 会在浏览器里打开一个进度页,显示下载进度。Magpie 最多等 10 分钟(下载的时间也算在内),请尽快完成登录;连不上 GitHub 时,先按下面「插件选项与代理配置」设置 `studio.proxy`。
34
+ > 首次使用要先下载本地服务(约 30 MB)和登录浏览器 Camoufox(约 300 MB),弹窗可能需要等几分钟才出现。需要下载时,Magpie 会在浏览器里打开一个进度页,显示下载进度。Magpie 最多等 10 分钟(下载的时间也算在内),请尽快完成登录;连不上 GitHub 时,先按下面「插件选项与代理配置」设置 `studio.proxy`。
33
35
  3. **后续管理**:再次点击「用 Google 账号登录」,可选择**添加新账号**、为本机已有账号建卡,或为过期账号**重新登录**。
34
36
 
35
37
  ### 方式二:Gemini Web (`gemini-web`)
36
38
 
37
- 1. 在 Magpie 中登录 **Gemini Web**,选择 **「一键配置本地 Gemini Web(推荐)」**。
39
+ 1. 在 Magpie 中登录 **Gemini Web**,选择 **「一键配置本地 Gemini Web(推荐)」**(若访问 Google 需要代理,可在第一步提示中直接填写代理地址,例如 `http://127.0.0.1:7890`,无需代理或已配置代理池可留空)。
38
40
  2. 打开浏览器**无痕 / 隐私窗口**(推荐 Firefox)获取 Cookie:
39
41
  1. 访问 <https://gemini.google.com/app> 并登录 Google 账号;
40
42
  2. 按 `F12`(macOS 按 `⌥⌘I`)切到 **Network(网络)**,刷新页面;
@@ -42,6 +44,8 @@
42
44
  4. **直接关闭无痕窗口,不要点退出登录**(点退出会使 Cookie 失效)。
43
45
  3. 插件验证账号可用后即完成登录。想添加更多账号,重复上述步骤即可。
44
46
 
47
+ > **升级后提示后端不支持登录时绑定代理?** 旧后台进程可能仍在运行。请按提示先退出 Magpie,停止对应的 `gemini-web2api-go` 进程(Windows:任务管理器 → 详细信息 → `gemini-web2api-go.exe`),再运行提示中的完整安装命令。它会保留账号和配置,并切换到插件的托管后端;如下载需要代理,先设置 `GEMINI_WEB_PROXY`。完成后重新打开 Magpie 登录。
48
+
45
49
  > **为什么必须用无痕窗口?** 后端会定时刷新会话来保活。若与日常浏览器共用同一登录会话,Google 会将整个会话作废,导致你的浏览器退出所有 Google 服务。使用无痕窗口(或单独准备 Google 小号)可提供独立会话。
46
50
 
47
51
  ---
@@ -84,6 +88,7 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
84
88
  | `allowImages` | `false` | 共用(可用 `studio.allowImages` 单独覆盖) | 允许图片输入 |
85
89
  | `requestTimeoutMs` / `modelTimeoutMs` | Web:`240000` / `10000`;Studio:`1800000` / `10000` | 共用(`studio.*` 可覆盖) | 单次等待后端 / 拉取模型列表的超时(毫秒);收到流数据后重新计时,显式配置优先 |
86
90
  | `stripCitations` | `true` | 仅 `gemini-web` | 剥离回复与工具参数中的 `[cite: 1]`、`[cite_start]` 标记(AI Studio 不支持剥离) |
91
+ | `proxy` | 无 | 仅 `gemini-web` | 一键配置后端访问 Google 的代理(`http` / `https` / `socks5` / `socks5h`),也可用环境变量 `GEMINI_WEB_PROXY` 或在登录第一步填写 |
87
92
  | `baseURL` | `http://127.0.0.1:8083/v1` | 仅 `gemini-web` | Gemini Web 默认后端地址 |
88
93
  | `contextLimit` / `outputLimit` | `1000000` / `8192` | 仅 `gemini-web` | 向客户端声明的上下文 / 输出上限 |
89
94
  | `studio.proxy` | 无 | 仅 `ai-studio` | 访问 Google 的代理(`http` / `https` / `socks5`),也可用环境变量 `AI_STUDIO_PROXY`;设置后优先于管理页里保存的代理,留空等于不设置 |
@@ -93,11 +98,11 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
93
98
  **配置代理访问 Google:**
94
99
  - **AI Studio**:推荐在本地管理页设置。打开额度卡片「管理页」一行里的地址(默认 `http://127.0.0.1:2048`),用户名 `magpie`,密码是数据目录 `config.json` 里的 `adminPassword`;保存代理后在管理页重启服务即可生效,之后插件重启后端也不会覆盖它。
95
100
  - 也可以用上表的 `studio.proxy` 或环境变量 `AI_STUDIO_PROXY`,它们优先于管理页里保存的代理。改了要重启本地服务才生效(`npm run studio:stop`,下一次请求会自动启动)。
96
- - 都没设置时,后端直连;Windows 上会使用系统代理(Windows 的「代理」设置)。
101
+ - 都没设置时,后端直连;macOS 和 Windows 上会使用已配置的系统代理。
97
102
  - **后端不使用 Magpie 的代理(包括给 `ai-studio` 设置的供应商代理),也不读取 `HTTPS_PROXY` 等环境变量**:它在 Magpie 退出后仍会运行,借用 Magpie 的代理到时可能已经失效。请用上面两种方式之一设置。加入这项修复之前的插件版本启动的后端,可能还在用启动时环境变量里的代理(比如 Magpie 的);「代理出口」一行会标出来,并说明重启后会怎样。
98
103
  - 额度卡片的「代理出口」一行会显示后端当前实际使用的代理、它来自哪里,以及新设置是否还要重启才生效;登录 Google 时的说明、登录失败的提示和 `npm run studio:status` 也会显示。
99
104
  - 监听地址、API Key、管理员账号等由插件管理,在管理页修改不会生效。
100
- - **Gemini Web**:后端不读取 `HTTP_PROXY`,请打开本地管理面板 `http://127.0.0.1:8083/admin` 在代理池中添加(登录口令为数据目录 `secrets.json` 中的 `adminToken`)。
105
+ - **Gemini Web**:后端不读取系统代理或 `HTTP_PROXY`。可在「一键配置本地 Gemini Web」登录第一步直接填写代理地址,或设置插件选项 `proxy` / 环境变量 `GEMINI_WEB_PROXY`,也可以打开本地管理面板 `http://127.0.0.1:8083/admin` 在代理池中添加(登录口令为数据目录 `secrets.json` 中的 `adminToken`)。
101
106
  - *注意*:配置代理池后,新添加的账号需先发送一次请求以绑定代理,再通过「添加本地后端里已有的 Google 账号」重新添加,才能正常读取邮箱和用量(不支持通过 SOCKS 代理读取用量)。
102
107
 
103
108
  **连接自建后端:**
@@ -144,7 +149,7 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
144
149
  - 插件将请求并发限制为 1,但仍无法完全排除 Google 账号风控风险,请自行评估使用。
145
150
 
146
151
  **AI Studio 升级与模型范围:**
147
- - 插件固定使用经过 SHA-256 校验的 `v0.2.14-magpie.1`(基于上游 `v0.2.14`),通过升级插件更新后端。同基线或更旧的官方版、以及旧版插件装的托管后端,在下次管理启动时自动升级,保留账号、端口与登录凭据。
152
+ - 插件固定使用经过 SHA-256 校验的 `v0.2.17-magpie.1`(基于上游 `v0.2.17`),通过升级插件更新后端。同基线或更旧的官方版、以及旧版插件装的托管后端,在下次管理启动时自动升级,保留账号、端口与登录凭据。
148
153
  - **托管后端已在 macOS、Linux、Windows 统一禁用在线更新**:管理页提示“更新由 magpie-gemini-web 管理”,更新接口返回 HTTP 409,检查更新也不会访问 GitHub。用户自行连接的外部服务不受影响。托管构建方式和可复现构建流程见 [docs/studio-release.md](docs/studio-release.md)。
149
154
  - Unix 的 `package/` 仍尽力设置为 `0555`,作为额外的文件保护;权限设置失败不阻断服务,在线更新的禁用也不依赖该权限。若要手动删除数据目录来重置,请先停止服务,再运行 `chmod -R u+w "<数据目录>/package"` 恢复可写权限,然后删除;将 `<数据目录>` 替换为实际路径。
150
155
  - 若自行更新到更新版或定制版,插件会提示版本冲突,并提供带正确 `--data-dir` 的 `stop`、`install`、`start` 命令。停止时会找回更新后的监听进程 PID,并核对可执行文件路径;无法核实身份就不会发送终止信号。HTTP 端口关闭但进程尚未退出时,插件不会重装或启动第二个进程。
@@ -154,11 +159,11 @@ magpie plugin options magpie-gemini-web '{"studio":{"proxy":"http://127.0.0.1:78
154
159
  - 模型列表过滤 `-build` / `assistant_route` 模型:这类模型附带 Build 写代码助手的系统提示词,不作为普通 Agent 模型提供。升级后可执行 `magpie provider models ai-studio` 刷新列表。
155
160
 
156
161
  **Gemini Web 优化后端升级与回退:**
157
- - 插件默认使用本仓库发布的 [4.22.0-magpie.1](https://github.com/BUKOWSKIREAL/magpie-gemini-web/releases/tag/backend-v4.22.0-magpie.1)(基于上游 v4.22.0 集成 XSRF 缓存、请求取消传播、工具调用提前收尾与 Argon 校验补丁)。
162
+ - 插件默认使用本仓库发布的 [4.26.0-magpie.1](https://github.com/BUKOWSKIREAL/magpie-gemini-web/releases/tag/backend-v4.26.0-magpie.1)(基于上游 v4.26.0 集成 XSRF 缓存、请求取消传播、工具调用提前收尾与 Argon 校验补丁)。
158
163
  - **旧版升级**:插件不会打断运行中的后端。先停止旧进程(PID 见数据目录 `backend.pid`),下次启动 Magpie 或发请求时会自动更新二进制并保留原有配置与账号。
159
164
  - **回退官方版 / 恢复优化版**(停止后端后在插件目录执行):
160
165
  ```bash
161
- npm run backend:install:upstream # 回退并固定使用官方 v4.22.0
166
+ npm run backend:install:upstream # 回退并固定使用官方 v4.26.0
162
167
  npm run backend:install # 恢复默认优化版
163
168
  ```
164
169
  - 源码复现构建与发布流程见 [docs/backend-release.md](docs/backend-release.md)。
@@ -177,3 +182,17 @@ macOS 用户登录 Gemini Web 时会额外看到「macOS 原生 Task(实验性
177
182
  ## 许可证
178
183
 
179
184
  MIT。上游 `gemini-web2api-go` 同为 MIT(见 `LICENSE-UPSTREAM`)。
185
+
186
+ ---
187
+
188
+ ## Star 趋势
189
+
190
+ <p align="center">
191
+ <a href="https://www.star-history.com/#BUKOWSKIREAL/magpie-gemini-web&amp;Date">
192
+ <picture>
193
+ <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date&amp;theme=dark" />
194
+ <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date" />
195
+ <img alt="magpie-gemini-web 的 GitHub Star 增长趋势" src="https://api.star-history.com/svg?repos=BUKOWSKIREAL/magpie-gemini-web&amp;type=Date" width="800" />
196
+ </picture>
197
+ </a>
198
+ </p>
@@ -28,4 +28,6 @@ The metadata records `CGO_ENABLED=0`, the exact Go toolchain, upstream commit, p
28
28
 
29
29
  Existing running processes are left alone to avoid interrupting requests. Once an old official backend is stopped, automatic startup installs the optimized build while preserving configuration, secrets and the database. A download or checksum failure keeps the old file and never starts an unverified replacement.
30
30
 
31
- An explicit `npm run backend:install:upstream` installs the pinned upstream v4.22.0 and persists `upstream` in `backend-channel.json`. Automatic startup respects that choice. `npm run backend:install` returns to the optimized channel. Stop a running backend before replacing it, particularly on Windows. Explicit local Argon builds remain trusted through their existing build manifest.
31
+ New cookie imports require the running backend to advertise `capabilities.account_proxy_binding: true` at `/`. The plugin checks this before changing the proxy pool and again before submitting a cookie, so a reused older or upstream backend cannot silently ignore `proxy_id`. Unsupported builds receive instructions to stop the old process and run the installed plugin's CLI with `install --data-dir=<path>`. This explicitly selects the optimized channel, including for previous upstream or custom-build installations. The check does not interrupt existing conversations. Release smoke verifies the capability and actual proxy selection; version strings alone do not establish support.
32
+
33
+ An explicit `npm run backend:install:upstream` installs the pinned upstream v4.26.0 and persists `upstream` in `backend-channel.json`. Automatic startup respects that choice. `npm run backend:install` returns to the optimized channel. Stop a running backend before replacing it, particularly on Windows. Explicit local Argon builds remain trusted through their existing build manifest.
package/docs/logo.svg ADDED
@@ -0,0 +1,16 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
2
+ <defs>
3
+ <linearGradient id="a" x1="2" y1="3" x2="20" y2="21" gradientUnits="userSpaceOnUse">
4
+ <stop offset="0%" stop-color="#06B6D4"/>
5
+ <stop offset="50%" stop-color="#3B82F6"/>
6
+ <stop offset="100%" stop-color="#8B5CF6"/>
7
+ </linearGradient>
8
+ <linearGradient id="b" x1="14" y1="2" x2="22" y2="10" gradientUnits="userSpaceOnUse">
9
+ <stop offset="0%" stop-color="#8B5CF6"/>
10
+ <stop offset="100%" stop-color="#EC4899"/>
11
+ </linearGradient>
12
+ </defs>
13
+ <path d="M10 3.2C10.35 3.2 10.62 3.45 10.72 3.8C11.45 6.85 13.15 8.55 16.2 9.28C16.55 9.38 16.8 9.65 16.8 10C16.8 10.35 16.55 10.62 16.2 10.72C13.15 11.45 11.45 13.15 10.72 16.2C10.62 16.55 10.35 16.8 10 16.8C9.65 16.8 9.38 16.55 9.28 16.2C8.55 13.15 6.85 11.45 3.8 10.72C3.45 10.62 3.2 10.35 3.2 10C3.2 9.65 3.45 9.38 3.8 9.28C6.85 8.55 8.55 6.85 9.28 3.8C9.38 3.45 9.65 3.2 10 3.2Z" transform="translate(-0.5 2.5) scale(1.12)" fill="url(#a)"/>
14
+ <path d="M18.2 1.8C18.42 1.8 18.6 1.95 18.66 2.16C19.08 3.82 20.02 4.76 21.68 5.18C21.89 5.24 22.04 5.42 22.04 5.64C22.04 5.86 21.89 6.04 21.68 6.1C20.02 6.52 19.08 7.46 18.66 9.12C18.6 9.33 18.42 9.48 18.2 9.48C17.98 9.48 17.8 9.33 17.74 9.12C17.32 7.46 16.38 6.52 14.72 6.1C14.51 6.04 14.36 5.86 14.36 5.64C14.36 5.42 14.51 5.24 14.72 5.18C16.38 4.76 17.32 3.82 17.74 2.16C17.8 1.95 17.98 1.8 18.2 1.8Z" fill="url(#b)"/>
15
+ <circle cx="17.8" cy="18.2" r="1.35" fill="#6366F1"/>
16
+ </svg>
@@ -1,49 +1,108 @@
1
1
  # AI Studio 托管后端构建
2
2
 
3
- 插件使用 `0.2.14-magpie.1`,基于 AIStudio2API `v0.2.14` 的固定 commit。上游版本、commit、Go 工具链、安装包及二进制 SHA-256 均记录在 `lib/studio-release.json`。`upstream.camoufox` 是这个 commit 要求的 Camoufox 版本(上游 `internal/camoufoxnative/download.go` 里的 `camoufoxRelease`),插件靠它判断登录时要不要重新下载 Camoufox;更新上游 commit 时要一起改,构建脚本发现不一致会报错。MIT 许可见 `LICENSE-AISTUDIO`。
3
+ 插件使用 `0.2.17-magpie.1`,基于 AIStudio2API `v0.2.17` 的固定 commit。上游版本、commit、Go 版本、C 工具链(`toolchains`)、补丁列表、安装包及二进制 SHA-256 均记录在 `lib/studio-release.json`。`upstream.camoufox` 是这个 commit 要求的 Camoufox 版本(上游 `internal/camoufoxnative/download.go` 里的 `camoufoxRelease`),更新上游 commit 时要一起核对,构建脚本发现不一致会报错。MIT 许可见 `LICENSE-AISTUDIO`。
4
+
5
+ ## 升级兼容
6
+
7
+ - 上游 v0.2.17 改用需要 CGO 的原生 SQLite。账号和配置沿用原目录;首次打开旧数据库会整理空闲页。降级前应停止服务并备份完整数据目录,旧版不保证能读取迁移后的数据。
8
+ - 上游会删除旧的请求正文 `bodies` 表。`patches/studio-0.2.17-preserve-request-bodies.patch` 改为在事务内压缩并迁移到 `request_bodies`,已有新版同 ID 记录优先,成功后才删除旧表;失败回滚。补丁包含旧正文读取、重复打开及迁移失败回滚测试,随上游测试一起运行。
9
+ - 新增的 `FIRST_EVENT_HEDGE` 保留管理页保存的值,同时隔离宿主环境同名变量。默认仍由上游设为 `off`。备用请求需要空闲账号和 Worker;插件默认单 Worker,不自动提高并发。
10
+ - 模型档位优先使用 `/v1/models` 返回的 `thinking_levels`;旧外部服务未返回该字段时沿用四档。Playground 通道、纯 Go WAA、托管更新限制及插件默认并发保持原设置。
11
+ - macOS 与 Windows 都可能使用系统代理;显式代理及管理页设置仍优先,宿主的 `HTTP_PROXY` 等变量不传入服务。
4
12
 
5
13
  ## 在线更新策略
6
14
 
7
- 上游从 v0.2.14 起支持由分发方管理更新,不再需要补丁。构建时通过 `-ldflags` 写入两个值:
15
+ 上游从 v0.2.14 起原生支持分发方管理更新。构建时通过 `-ldflags` 写入两个值:
16
+
17
+ - `internal/app.version=v0.2.17-magpie.1`:明确的版本标识。同基线或更旧的官方版、以及更旧的托管版需要升级;更新的官方版、更新的托管版或不认识的定制版仍提示冲突。
18
+ - `internal/app.managedBy=magpie-gemini-web`:`GET /api/update`(包括 `?refresh=1`)只返回本地版本、`mode: managed` 和 `managed_by`,不访问 GitHub;`POST /api/update` 返回 HTTP 409,不下载、不替换文件、不重启。管理页显示“更新由 magpie-gemini-web 管理”。
8
19
 
9
- - `internal/app.version=v0.2.14-magpie.1`:明确的版本标识。插件把同基线或更旧的官方版、以及更旧的托管版(`-magpie.N` 的基线更低,或同基线但 N 更小)视为需要升级;更新的官方版、更新的托管版或不认识的定制版仍提示冲突。
10
- - `internal/app.managedBy=magpie-gemini-web`:更新模式为 `managed`。`GET /api/update`(包括 `?refresh=1`)只返回本地版本、`mode: managed` 和 `managed_by`,不访问 GitHub;`POST /api/update` 返回 HTTP 409,说明更新由 magpie-gemini-web 管理,不下载、不替换文件、不重启。这两个值在链接时写死,没有环境变量或管理页开关,在所有构建平台相同。
11
- - 管理页版本面板显示当前版本和"更新由 magpie-gemini-web 管理",不显示检查更新或安装按钮。上游的在线更新代码仍然编译在内,但托管模式下走不到;`studio:managed:smoke` 用真实二进制验证这一点。
12
- - 构建不带 `desktop` 标签,即上游的命令行版,不包含桌面窗口。
13
- - 普通插件升级、账户登录、模型调用及管理功能继续保留。用户自行连接的外部 AIStudio2API 服务不受影响。
20
+ 构建不带 `desktop` 标签,不包含桌面窗口。普通插件升级、账户登录、模型调用及管理功能继续保留,用户自行连接的外部服务不受影响。
14
21
 
15
22
  ## 复现构建
16
23
 
17
- 维护者需要 Git、tar、Node.js 26.8.2(构建页面用)、Go 1.27.1。Windows 使用 Git Bash 执行以下命令,安装包运行和解压使用 Windows 自带 PowerShell。最终用户不需要这些构建工具。
24
+ 维护者需要 Git、tar、curl、Node.js 26.8.2、Go 1.27.1,以及 `lib/studio-release.json` 的 `toolchains` 固定的 C 工具链。SQLite 需要 CGO,C 工具链因此也是 pin 的一部分:
25
+
26
+ | 目标 | 工具链 | 跨机器字节一致 |
27
+ |---|---|---|
28
+ | Linux x64/arm64 | Zig `toolchains.zig`,musl 静态链接,不依赖构建机器的 glibc | 是:Zig 是自带 libc 的交叉编译器,任何主机产物相同 |
29
+ | Windows x64 | llvm-mingw `toolchains.llvmMingw`(Clang + LLD + UCRT),静态链接,PE 时间戳为 0 | 是:同上;构建脚本自动下载并按 SHA-256 校验 |
30
+ | macOS arm64/x64 | Xcode `toolchains.xcode`,最低目标 macOS 13(与 Go 1.27 一致),只能在 macOS 上构建 | 仅在同一 Xcode 下:Apple 链接器和 SDK 随 Xcode 变化 |
31
+
32
+ - Zig 默认从 PATH 查找,也可用 `STUDIO_ZIG=/absolute/path/to/zig` 指定。
33
+ - llvm-mingw 首次使用时下载到 `studio-build/toolchains/`(macOS、Linux x64、Windows x64 主机各有固定的归档及 SHA-256),之后复用。`STUDIO_MINGW_CC` 可指定其他 `x86_64-w64-mingw32-clang`,但 `--verify` / `--write-pins` 要求其版本与 pin 一致。
34
+ - Xcode 用 `DEVELOPER_DIR=/Applications/Xcode_<版本>.app/Contents/Developer` 选择,不需要改系统默认。不要用 beta 版 Xcode 制作发布包。
35
+ - 所有目标都以 `-trimpath -buildvcs=false -ldflags=-buildid=` 编译:Go 默认的 build ID 会哈希 C 编译器路径等构建输入,导致不同机器上内容相同的程序哈希不同。
36
+ - Windows 使用 Git Bash 执行命令,安装包运行和解压使用 Windows 自带 PowerShell。最终用户不需要构建工具。
37
+
38
+ `--verify` 和 `--write-pins` 会在开始构建前检查每个目标的工具链是否与 pin 一致,不一致时几秒内报错并说明需要的版本;不带这两个参数的普通构建只给出警告。
18
39
 
19
40
  ```bash
20
- # 按固定源代码构建所有五个平台,并核对现有 pin。
41
+ # 构建所有五个平台并核对现有 pin(macOS 目标需要固定的 Xcode)。
21
42
  npm run studio:release:build
22
43
 
23
- # 仅构建当前平台。
44
+ # 只构建当前平台,或用逗号指定多个目标(Linux/Windows 目标不要求固定的 Xcode)。
24
45
  node scripts/studio-release.mjs --target=host --verify
46
+ node scripts/studio-release.mjs --target=linux-x64,linux-arm64,win32-x64 --verify
25
47
 
26
- # 制作新版本:审查上游源码后重新生成所有平台 pin。
27
- node scripts/studio-release.mjs --write-pins
28
-
29
- # 可复用本地上游 git 仓库,但始终导出固定 commit,不使用工作区修改。
48
+ # 可复用本地仓库;始终导出固定 commit,再应用清单中的补丁,不使用工作区修改。
30
49
  node scripts/studio-release.mjs --source=/path/to/AIStudio2API --verify
31
50
  ```
32
51
 
33
- 输出在 `studio-build/release/`,不进入 npm 包。包含 macOS x64/arm64、Linux x64/arm64、Windows x64 安装包,以及构建记录、SHA256SUMS 和上游许可证。每个安装包携带许可证和托管升级说明。Go 的标准 tar/zip/gzip 写入器固定文件顺序、权限与时间;编译使用 `-trimpath -buildvcs=false`。
52
+ 输出在 `studio-build/release/`,不进入 npm 包。包含安装包、构建记录、SHA256SUMS 和上游许可证。构建记录包含固定工具链、实际编译器版本及补丁 SHA-256;`--verify` 失败时也会写入,便于对比差异。安装包固定文件顺序、权限与时间。前端 `.gz` 资源通过 `scripts/studio-regzip.go` 重新压缩,消除 Node zlib 跨平台差异。
53
+
54
+ ## 生成 pin
55
+
56
+ 正式 pin 由 CI 生成,因为 macOS 产物只能在固定的 Xcode 下复现,而 GitHub runner 上有固定版本的 Xcode。修改上游 commit、补丁或工具链后:
57
+
58
+ 1. 审查源码和补丁,更新 `lib/studio-release.json` 的版本、上游及 `toolchains`,提交并推送。
59
+ 2. 手动运行 **Verify managed AI Studio release** 并勾选 `write_pins`(候选模式):
60
+
61
+ ```bash
62
+ gh workflow run studio.yml --ref <分支> -f write_pins=true
63
+ ```
64
+
65
+ 每个 runner 构建、测试、记录自己平台的哈希;`Collect candidate pins` 作业用 `scripts/studio-pins.mjs` 校验所有构建记录来自同一源码、补丁和工具链,再把五个平台合并成 `candidate-pins` 产物,并在作业摘要中给出 diff。
66
+ 3. 下载产物覆盖清单后提交(`gh run download` 不覆盖已有文件,所以先下载到临时目录):
67
+
68
+ ```bash
69
+ dir="$(mktemp -d)" && gh run download <run-id> --name candidate-pins --dir "$dir" \
70
+ && cp "$dir/studio-release.json" lib/studio-release.json
71
+ ```
72
+
73
+ 4. 推送后,PR 上的验证会在全新 runner 上重新构建并严格比对。这一步证明 pin 可以复现,而不只是记录了一次构建结果。
74
+
75
+ Linux 和 Windows 的 pin 也可以在本机生成(`--target=linux-x64,linux-arm64,win32-x64 --write-pins`),结果应与 CI 相同。不同来源的 pin 不一致说明工具链没有真正固定,应查明原因,不要直接覆盖。候选模式的产物以 `candidate-` 开头,`publish-studio.yml` 只接受 `studio-` 开头的验证产物,因此候选构建不会被上传到 release。
34
76
 
35
77
  ## 验证与发布
36
78
 
37
79
  ```bash
38
- # 在独立临时数据目录中安装当前平台真实安装包,无需 Google 账号。
80
+ # 在独立临时数据目录安装当前平台真实安装包,无需 Google 账号。
39
81
  npm run studio:managed:smoke
40
82
 
41
- # 可选:让插件离线恢复测试使用刚构建的安装包。
83
+ # 让插件离线恢复测试使用刚构建的安装包。
42
84
  AI_STUDIO_TEST_ARCHIVE=/absolute/path/to/archive.tar.gz npm test
43
85
  ```
44
86
 
45
- 真实安装验证检查启动、版本、GET 更新状态、POST 更新返回 409、二进制及 PID 不变、管理页面显示托管提示、停止与状态。`.github/workflows/studio.yml` 在五种系统/架构上重新构建、对比 SHA-256 并运行该验证;本机交叉编译不代替 Windows 真机验证。
87
+ 真实安装验证检查旧版请求正文迁移及重启后可读、管理页保存的备用请求设置、启动、版本、GET 更新状态、POST 更新返回 409、二进制及 PID 不变、管理页面显示托管提示、停止与状态。`.github/workflows/studio.yml` 在五种系统/架构的原生 runner 上重新构建、对比 SHA-256 并运行该验证;本机交叉编译不能代替 Linux/Windows 真机验证。
88
+
89
+ ## 本次升级验证(2026-10-29)
46
90
 
47
- 发布时先审查构建记录和各平台 CI 结果,再将安装包及许可证上传到本仓库 `studio-v0.2.14-magpie.1` release。该 release 可公开下载后,才能发布引用它的插件版本,否则新安装会遇到 404。构建脚本及 CI 不自动发布 release,也不发布 npm 包。
91
+ - 上游前端 lint/build、Go 测试(含迁移补丁测试)通过;插件完整测试 207 项通过,无跳过。
92
+ - Linux 二进制为静态链接,Windows 二进制只导入 UCRT 与 KERNEL32、PE 时间戳为 0;npm 打包检查包含迁移补丁,排除构建产物。
93
+ - 跨机器一致性:Linux 与 Windows 的 pin 在 macOS arm64 本机交叉编译生成,CI 的 Linux x64/arm64 和 Windows x64 runner 原生重建后哈希完全一致;CI 候选构建得到的这三个平台哈希也与本机相同。macOS 的 pin 由 CI 在 Xcode 26.3 下生成,另一次独立的 CI 构建得到相同的 darwin-arm64 哈希。
94
+ - 五个平台都在 CI 原生 runner 上通过真实安装冒烟验证(含旧请求正文迁移及重启)和插件测试。
95
+ - 新版 Google 登录/生成端到端验证尚未完成。
96
+ - 此分支未发布后端 release 或 npm 包。本机日常后端仍使用 `0.2.16-magpie.1`,新版仅在临时数据目录运行。
97
+
98
+ 发布前必须审查各平台 CI 与构建记录,再将安装包及许可证上传到本仓库 `studio-v0.2.17-magpie.1` release。该 release 可公开下载后,才能发布引用它的插件版本,否则新安装会遇到 404。构建脚本及验证 CI 不自动发布 release 或 npm 包。
99
+
100
+ 本地试用建议使用独立数据目录:
101
+
102
+ ```bash
103
+ node scripts/studio.mjs install --data-dir /path/to/studio-017-trial --archive /absolute/path/to/archive
104
+ node scripts/studio.mjs start --data-dir /path/to/studio-017-trial
105
+ node scripts/studio.mjs stop --data-dir /path/to/studio-017-trial
106
+ ```
48
107
 
49
- 本地试用无需发布:先停止当前托管后端,再执行 `node scripts/studio.mjs install --archive /absolute/path/to/archive` 和 `node scripts/studio.mjs start`。可用 `--data-dir` 指定目录。修改前备份账号和配置;该版本与上游 v0.2.14 使用相同的数据格式。v0.2.14 对数据的改动都是新增的(账号记录的可选字段、新的 `runtime/prompts.db`、`.env` 的新设置),用真实账号验证过:`v0.2.13-magpie.1` 的数据可以直接被它读取,用它运行过之后退回 `v0.2.13-magpie.1` 也能正常使用。
108
+ 使用现有账号数据测试前,先停止旧服务并备份;不要让两个进程同时写同一个数据目录。
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { normalizeBaseURL, settings, credentials, listModels, forward, UNREACHABLE_HEADER } from './lib/backend.mjs';
1
+ import { normalizeBaseURL, settings, credentials, listModels, forward, UNREACHABLE_HEADER, PLUGIN_ICON } from './lib/backend.mjs';
2
2
  import { ensureBackend, localBackend } from './lib/native.mjs';
3
- import { parseCookieInput, importCookie } from './lib/setup.mjs';
3
+ import { parseCookieInput, importCookie, ensureProxy, validateProxyURL, requireLoginBackend } from './lib/setup.mjs';
4
4
  import { usage, poolChoices, poolAccounts, accountEmail } from './lib/usage.mjs';
5
5
  import { taskSupported, taskMethod, taskLoader, taskModels, isTaskAuth } from './lib/task.mjs';
6
6
 
@@ -55,7 +55,7 @@ async function forwardManaged(input, init, getAuth, opts) {
55
55
  }
56
56
  if (!managedBackend(c.baseURL)) return res;
57
57
  try {
58
- await ensureBackend();
58
+ await ensureBackend({ proxy: opts.proxy });
59
59
  } catch {
60
60
  return res;
61
61
  }
@@ -68,11 +68,30 @@ export const GeminiWebPlugin = async (_input, options = {}) => {
68
68
  }
69
69
  const { studio: _studio, ...webOptions } = options;
70
70
  const opts = settings(webOptions);
71
+ const proxyPrompt = {
72
+ type: 'text',
73
+ key: 'proxy',
74
+ message: '访问 Google 的代理地址(无需代理或已在代理池配置可留空)',
75
+ placeholder: opts.proxy || 'http://127.0.0.1:7890',
76
+ validate: value => {
77
+ try {
78
+ validateProxyURL(value);
79
+ } catch (e) {
80
+ return e.message;
81
+ }
82
+ }
83
+ };
71
84
 
72
85
  // Bring a backend set up earlier back after Magpie or the computer restarts. Not awaited:
73
86
  // requests that arrive first start it themselves through forwardManaged.
74
87
  if (localBackend()) {
75
- ensureBackend().catch(err => console.error(`[gemini-web] could not start the local backend: ${err.message}`));
88
+ ensureBackend({ proxy: opts.proxy })
89
+ .then(async local => {
90
+ if (!opts.proxy) return;
91
+ await requireLoginBackend(local);
92
+ await ensureProxy(local, opts.proxy);
93
+ })
94
+ .catch(err => console.error(`[gemini-web] could not start the local backend: ${err.message}`));
76
95
  }
77
96
 
78
97
  return {
@@ -82,24 +101,34 @@ export const GeminiWebPlugin = async (_input, options = {}) => {
82
101
  },
83
102
  auth: {
84
103
  provider: ID,
104
+ icon: PLUGIN_ICON,
85
105
  maxConcurrency: 1,
86
106
  methods: [{
87
107
  type: 'oauth',
88
108
  label: '一键配置本地 Gemini Web(推荐)',
89
- // Installs and starts the pinned backend, then takes the Gemini cookie the user pastes.
109
+ prompts: [proxyPrompt],
110
+ ask(inputs) {
111
+ return inputs && 'proxy' in inputs ? null : proxyPrompt;
112
+ },
113
+ // Installs and starts the pinned backend while the user copies the Gemini cookie; the
114
+ // callback then waits for it, configures its proxy pool when a proxy URL is given, and
115
+ // imports the cookie (importCookie checks the backend can bind the account to a proxy).
90
116
  // The result carries the backend's own API key, so Magpie saves an API-key sign-in,
91
117
  // one for each Google account (see signInFor).
92
- async authorize() {
93
- const local = await ensureBackend();
118
+ async authorize(inputs) {
119
+ const proxy = validateProxyURL(inputs?.proxy || opts.proxy || '');
120
+ const ready = ensureBackend({ proxy });
121
+ ready.catch(() => {});
94
122
  return {
95
123
  url: GEMINI_URL,
96
124
  method: 'code',
97
125
  instructions: COOKIE_STEPS,
98
126
  async callback(code) {
99
- let cookie, added;
127
+ let local, cookie, added;
100
128
  try {
101
129
  cookie = parseCookieInput(code);
102
- added = await importCookie(local, cookie);
130
+ local = await ready;
131
+ added = await importCookie(local, cookie, proxy ? { proxy } : {});
103
132
  } catch (err) {
104
133
  return { type: 'failed', error: err.message };
105
134
  }
@@ -206,7 +235,7 @@ export const GeminiWebPlugin = async (_input, options = {}) => {
206
235
  return await listModels(c, opts);
207
236
  } catch (err) {
208
237
  if (!err.unreachable || !managedBackend(c.baseURL)) throw err;
209
- await ensureBackend();
238
+ await ensureBackend({ proxy: opts.proxy });
210
239
  return listModels(c, opts);
211
240
  }
212
241
  }
@@ -1,36 +1,36 @@
1
1
  {
2
- "version": "4.22.0-magpie.1",
2
+ "version": "4.26.0-magpie.1",
3
3
  "repository": "BUKOWSKIREAL/magpie-gemini-web",
4
- "tag": "backend-v4.22.0-magpie.1",
4
+ "tag": "backend-v4.26.0-magpie.1",
5
5
  "upstream": {
6
6
  "repository": "https://github.com/zexadev/gemini-web2api-go.git",
7
- "commit": "a65b1d1a5ac614c1b455857334b4f1c73ab8fcfb"
7
+ "commit": "7ce02d89512058b2bd147fb2dc4e40187f5135ad"
8
8
  },
9
9
  "goVersion": "1.27.1",
10
10
  "binaries": {
11
11
  "darwin-arm64": {
12
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_darwin_arm64",
13
- "sha256": "833dd54e7c0df927afc1d4e0f6443bcc03b7f0a4d04d24cdfde47d5dd27349c5"
12
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_darwin_arm64",
13
+ "sha256": "ae2581dfba30d7566c2c55cd53b0b65c56aab5e5f592ccac983a65c4444f069e"
14
14
  },
15
15
  "darwin-x64": {
16
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_darwin_amd64",
17
- "sha256": "d65b053a0e5f8e1065ea35835b3a7d12f783d97964c02bef49679df7ead92fd4"
16
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_darwin_amd64",
17
+ "sha256": "e220a5c53284c0c17ca9bc1a3e454448c95b84155fc460c17e0c8fcbae3b9d88"
18
18
  },
19
19
  "linux-x64": {
20
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_linux_amd64",
21
- "sha256": "94f082e666b34051f191959de3f2cd601078d117b1d3ededcdcd6b2201c48ef9"
20
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_linux_amd64",
21
+ "sha256": "cbbb9784823301f4f90e44d33a087d4d745770f4f35d77735fbae370087a7a43"
22
22
  },
23
23
  "linux-arm64": {
24
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_linux_arm64",
25
- "sha256": "4a7cbca2771acc9e836a5a986e11b3b247baf77e9900262cb588b515a1161aaa"
24
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_linux_arm64",
25
+ "sha256": "cf503f30ed3cfd358de926cf58b455b9ce7951dfa51b24584bd11559e9cfe7c0"
26
26
  },
27
27
  "win32-x64": {
28
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_windows_amd64.exe",
29
- "sha256": "61d279d50c6c09ffe81ed059a557077900948d0ae598e4c4b3a5d5c213ad5e5c"
28
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_windows_amd64.exe",
29
+ "sha256": "e0d0bc52acd1c0c7dc7d1bdc8eb3da09dee2be8ed9a36173ab3be1bf4c58f667"
30
30
  },
31
31
  "win32-arm64": {
32
- "asset": "gemini-web2api-go_v4.22.0-magpie.1_windows_arm64.exe",
33
- "sha256": "20bad088b114d3dc989830ff35f7e56c1e0026caf9721b739fe982f5fd3d1880"
32
+ "asset": "gemini-web2api-go_v4.26.0-magpie.1_windows_arm64.exe",
33
+ "sha256": "d038049af66365f0a6ab634664ca3d3715dd26e42d67f4c7f0b4f2ccba64f143"
34
34
  }
35
35
  }
36
36
  }