@dorokuma/magpie-gemini-web 0.19.0 → 0.20.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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  本文件按版本倒序记录 `magpie-gemini-web`(0.15.0 起为 `@dorokuma/magpie-gemini-web`)的全部已发布与待发变更,依据本仓 `git log` 与 tag 事实编写。
4
4
 
5
+ ## 0.20.0 - 2026-11-23
6
+
7
+ ### 新增
8
+ - Gemini Web 后端 pin 升级至 **`dorokuma/gemini-web2api-go` `v6.4.0`** 官方预编译二进制:`v6.3.1` 提供 WebChannel 启用前置 6 项与 `Set-Cookie` 主机域过滤;`v6.4.0` 新增 `/v1/responses` 多轮会话与工具调用续接、`stream_idle_timeout_sec` 两阶段沉默超时、`strict_proxy_binding` 严格代理绑定与后台出口下拉校验、`OSID` Cookie 识别诊断、`UpstreamAliases` 与 `ModelConfig.Retired` 淘汰模型框架、浏览器请求头单一来源重构、SIDCC 429 响应体 `identity.hfcr` 退避(`useWC := false` 保持锁定)。
9
+
10
+ ### 文档
11
+ - 中英双语 README 重构与自适应主题 logo(`docs/readme-redesign`,`67968de`)。
12
+
5
13
  ## 0.19.0 - 2026-11-21
6
14
 
7
15
  ### 新增
package/README.en.md CHANGED
@@ -1,12 +1,44 @@
1
- # <img src="docs/logo.svg" width="28" height="28" align="top" alt="" /> magpie-gemini-web
1
+ <div align="center">
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@dorokuma/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web) [![npm downloads](https://img.shields.io/npm/dw/@dorokuma/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/@dorokuma/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/dorokuma/magpie-gemini-web) [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dorokuma/magpie-gemini-web/main/docs/logo-dark.svg" />
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dorokuma/magpie-gemini-web/main/docs/logo-light.svg" />
6
+ <img src="docs/logo.svg" width="64" height="64" alt="magpie-gemini-web" />
7
+ </picture>
4
8
 
5
- [中文](README.md) | English
9
+ # magpie-gemini-web
6
10
 
7
- Use **Google AI Studio** and **Gemini on the web** through your Google account in [Magpie](https://usemagpie.ai/). The plugin runs [AIStudio2API](https://github.com/Mag1cFall/AIStudio2API) and [gemini-web2api-go](https://github.com/zexadev/gemini-web2api-go) locally, providing chat, native function calling, Nano Banana image generation, and Deep Research through OpenAI-compatible and Gemini APIs.
11
+ **Use Google AI Studio and Gemini Web directly inside [Magpie](https://usemagpie.ai/) — one-click incognito login, native tool calling, Nano Banana image generation, Deep Research, and live quota cards.**
8
12
 
9
- > **New model support:** **Google AI Studio (`ai-studio`)** automatically follows official stable backend releases and supports **`gemini-4-hydrogen`** (including the `xhigh` thinking tier) and **`gemini-4-carbon`** (requires an eligible account tier such as Google AI Ultra). **Gemini Web (`gemini-web`)** is backed by [`dorokuma/gemini-web2api-go` `v6.3.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0), which natively supports dedicated `gemini-4-carbon` / `gemini-4-hydrogen` / **`gemini-4-neon`** model IDs (including `-thinking` variants) and mutually recognizes slot upgrades/downgrades under `strict_model`; the `gemini-4-neon` family thinks server-side internally and never emits `reasoning_content`. **Chat and Task modes are separate:** use `gemini-4-neon` / `gemini-4-hydrogen` / `gemini-4-carbon` for everyday conversations (`gemini-4-carbon` and its `-thinking` / `-thinking-medium` variants are chat-only), and the dedicated **`gemini-4-neon-task`** / **`gemini-4-carbon-task`** / **`gemini-4-hydrogen-task`** models for task- and tool-heavy scenarios (they map to Gemini Web's Task mode).
13
+ [![npm version](https://img.shields.io/npm/v/@dorokuma/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web)
14
+ [![npm downloads](https://img.shields.io/npm/dw/@dorokuma/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web)
15
+ [![Magpie Plugin](https://img.shields.io/badge/Magpie-Plugin-3b82f6?style=flat-square)](https://usemagpie.ai/)
16
+ [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-8b5cf6?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/)
17
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-6366f1?style=flat-square)](https://github.com/dorokuma/magpie-gemini-web)
18
+ [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
19
+
20
+ [Quick Start](#quick-start) · [Highlights](#highlights) · [Provider Comparison](#which-provider-should-i-choose) · [Advanced Configuration](#advanced-configuration--operations)
21
+
22
+ [简体中文](README.md) · **English**
23
+
24
+ </div>
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ A[Magpie Desktop] --> B["@dorokuma/magpie-gemini-web"]
29
+ B --> C["AI Studio<br/>Tool Calling / Deep Research / Nano Banana"]
30
+ B --> D["Gemini Web<br/>Web Quota Chat + 5h/7d Usage Cards"]
31
+ C --> E["Local 127.0.0.1 Managed Backends"]
32
+ D --> E
33
+ ```
34
+
35
+ ## Highlights
36
+
37
+ | 🚀 Two Engines, Fully Managed | 🔐 Incognito Sign-in, Session-Safe | 🧠 AI Studio at Full Power |
38
+ | :--- | :--- | :--- |
39
+ | Automatic download with SHA-256 verification; the managed backend starts and stays alive on `127.0.0.1` — no Go install, no port babysitting | A local wizard behind a random token launches a private browser window, keeping your everyday Google session untouched; multi-account `/u/N` supported | Native Function Calling, Deep Research and Nano Banana image generation; tracks the latest official stable release while idle, with automatic rollback on failure |
40
+ | 📊 Gemini Web Quota Cards | 📦 Lossless Package Migration | 💻 Cross-Platform, Ready to Go |
41
+ | Live 5-hour and weekly usage plus reset times synced from the web app; rate limits hot-reload | Move over from the unscoped `magpie-gemini-web` with accounts and cookies fully preserved | Prebuilt backends managed in one click on macOS / Linux / Windows |
10
42
 
11
43
  ## Fork Notice & Acknowledgements
12
44
 
@@ -19,10 +51,9 @@ This project is an actively maintained **fork of [BUKOWSKIREAL/magpie-gemini-web
19
51
  **Key differences from upstream** (full history in [CHANGELOG](CHANGELOG.md)):
20
52
 
21
53
  1. npm package renamed to the scoped **`@dorokuma/magpie-gemini-web`**; the original unscoped `magpie-gemini-web` remains maintained by the upstream author as an independent npm package.
22
- 2. The Gemini Web backend is pinned to the **official Release prebuilt binaries** of `dorokuma/gemini-web2api-go` (currently `v6.3.0`, SHA-256 synced one-way by script); the local patch-and-rebuild pipeline was retired.
54
+ 2. The Gemini Web backend is pinned to the **official Release prebuilt binaries** of `dorokuma/gemini-web2api-go` (the pinned version lives in `lib/backend-release.json`; SHA-256 is synced one-way by script and must not be edited by hand); the local patch-and-rebuild pipeline was retired.
23
55
  3. Gemini Web adds `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon` model IDs (plus the dedicated task-mode models `gemini-4-neon-task` / `gemini-4-carbon-task` / `gemini-4-hydrogen-task`) with slot cross-validation; fixes include phantom session cleanup, AI Studio proxy precedence, and atomic publish/self-healing for update locks.
24
56
 
25
-
26
57
  ## Which Provider Should I Choose?
27
58
 
28
59
  The plugin provides two independent providers that can be used individually or together:
@@ -37,32 +68,68 @@ The plugin provides two independent providers that can be used individually or t
37
68
  | **Image generation** | Nano Banana models, for Magpie's image generation (Magpie v0.1.2075+, see below) | Not supported |
38
69
  | **Sign-in method** | Automatic official installation; confirm an imported account | Local wizard: copy `cookie` from a private/incognito window |
39
70
  | **Usage cards** | Shows models currently on cooldown and recovery times | Syncs **5-hour** & **weekly** usage and reset times from the web |
40
- | **Local backend** | AIStudio2API (automatic installation and stable updates) | gemini-web2api-go (`v6.3.0` pinned binary) |
41
-
42
- ---
71
+ | **Local backend** | AIStudio2API (automatic installation and stable updates) | gemini-web2api-go (pinned version in `lib/backend-release.json`) |
43
72
 
44
73
  ## Quick Start
45
74
 
46
- Install **@dorokuma/magpie-gemini-web** from the Magpie plugin market, then sign in to either (or both) providers below. By default, the plugin downloads the backend, verifies its SHA-256 checksum, and runs it in the background, with no Go installation required.
75
+ ### 1. Install in Magpie
76
+
77
+ Install **`@dorokuma/magpie-gemini-web`** from the Magpie plugin market. The plugin automatically downloads the matching backend, verifies its SHA-256 checksum, and runs it in the background — no Go or other dependencies required.
78
+
79
+ ### 2. Pick a Provider & Sign In
80
+
81
+ | | Google AI Studio (`ai-studio`) | Gemini Web (`gemini-web`) |
82
+ | :--- | :--- | :--- |
83
+ | **Best for** | Agent / coding workloads (native tool calling, image generation, Deep Research) | Everyday chat, web-quota usage cards |
84
+ | **Sign-in flow** | Choose **Add an account and connect** → open the account management page and import a Google account → back on the connection page, pick the account and **Connect to Magpie** | Choose **One-click local setup** → the local wizard launches an incognito browser for sign-in → copy the `cookie` back into the wizard to verify |
85
+ | **Notes** | On first use the plugin installs the latest official stable AIStudio2API automatically | The wizard listens on a random `127.0.0.1` port only; the incognito session is isolated and never kicks your daily Google session out |
86
+
87
+ > [!TIP]
88
+ > Both engines already support the new-generation model families (`gemini-4-neon` / `gemini-4-carbon` / `gemini-4-hydrogen`, including `-thinking` and dedicated task-mode `*-task` variants), but model availability and update channels differ per provider: **AI Studio** automatically follows Google's official model catalog and thinking levels — no plugin release needed; **Gemini Web** serves its Neon / `-thinking` / `*-task` web variants through the locally managed backend, which by default tracks the fixed pin in `lib/backend-release.json` shipped with each plugin release (to try a newer backend early, update the plugin or run your own external backend).
89
+
90
+ > **Why an incognito window?** The Gemini Web backend periodically refreshes the session to keep it alive. If it shared a session with your daily browser, Google would revoke the session and sign your browser out of all Google services. An incognito window (or a dedicated secondary Google account) gives the backend an isolated session. Once signed in, **close the incognito window directly — do not sign out** (signing out invalidates the cookie).
91
+
92
+ Need multiple accounts, usage-card refresh details or the full image-generation guide? See Advanced Configuration below.
93
+
94
+ ## Multiple Accounts & Usage Cards
95
+
96
+ - **Account usage cards:** Individual accounts use their email address. An AI Studio batch gets a separate group card; importing the same group in a different order keeps its identity.
97
+ - *Migrating older Gemini Web accounts:* For accounts added in earlier versions, add a Gemini Web account in Magpie and choose **Add an existing Google account from the local backend** to create individual cards, then remove the old pooled `API key …` card.
98
+ - **Automatic account rotation:** The local backend selects which Google account serves each request (Gemini Web rotates across the pool; AI Studio uses one account until cooldown and switches to the next, with optional account priority order and per-model account bindings configurable in the admin page or via `studio.accountOrder` and `studio.modelAccounts`). Switching cards in Magpie does not change which account the backend picks.
99
+ - **Usage reporting:**
100
+ - `gemini-web`: Available only with the one-click local backend. Usage is read from Google again whenever Magpie asks for it (at most once every 30 seconds per account), so pressing refresh shows the current allowance, including usage from the Gemini app, the website or other devices. On its own, Magpie asks about once a minute while the Usage page or the menu bar's allowances panel is open, whenever it updates allowances shown in the menu bar (every 3 minutes by default), and at most once a minute while it routes requests among accounts; otherwise it doesn't ask. A failed read isn't retried on its own for 10 minutes; pressing refresh in that time retries it at once (press it again if the first press doesn't).
101
+ - `ai-studio`: AI Studio does not report remaining total quota; cards display models currently on cooldown and their recovery times, or prompt when re-authentication is needed.
102
+
103
+ ## Image Generation (AI Studio)
47
104
 
48
- > **Migrating from the legacy package:** since `0.15.0` the npm package is the scoped `@dorokuma/magpie-gemini-web` (previously the unscoped `magpie-gemini-web`). If you installed the old package, remove `magpie-gemini-web` from the Magpie plugin market and install the new one. The local data directory `~/.local/share/magpie-gemini-web`, saved Google accounts, cookies, database and credentials are all preserved—no sign-in or cookie re-import is needed. During the transition, uninstall cleanup recognizes both package names and never mistakes the new plugin for removed. AI Studio automatically follows official stable releases by default. You can disable automatic updates, select your own executable or connect an independent service.
105
+ `ai-studio` lists the Nano Banana image models your account can use (such as `gemini-3.1-flash-image` and `gemini-3-pro-image`), for Magpie's image generation. **This needs Magpie v0.1.2075 or later**, the first to take a plugin's Gemini image models as models that draw.
106
+
107
+ **Drawing from an agent** (pi, Claude Code, Codex and the rest alike):
49
108
 
50
- ### Option 1: Google AI Studio (`ai-studio`)
109
+ 1. **Pick the model to draw with:** Magpie's Settings list these models under **Images → Image generation**. Pick one (such as `ai-studio/gemini-nano-banana-2.1`), or leave it on Automatic. There's no need to tick them in any model list.
110
+ 2. **Give the agent the drawing tool:** click **Give agents Magpie Image…** under that row, tick the agents that should draw in the Library it opens, then start a new session in the agent. With the Library turned off, the row says **Turn on the Library** instead: click that first. From the command line: `magpie library mcp add magpie-image magpie mcp image agents=pi` (several agents separated by commas, as in `agents=pi,claude`).
111
+ 3. **Chat as usual:** keep the agent on its usual chat model and ask it to draw something. It calls the `generate_image` tool, which draws with the model from step 1 and saves the image in the project's `generated-images/` folder; reference images make it an edit.
51
112
 
52
- 1. Sign in to **Google AI Studio** in Magpie and choose **「添加账号并连接(推荐)」** (Add an account and connect).
53
- 2. On first use, the plugin **automatically downloads, verifies and starts the latest stable official AIStudio2API backend**. No manual download, executable path, API key copying or administrator credentials are needed.
54
- 3. Click **「打开账号管理页」** (Open account management) on the connection page, then add a Google account using Chrome import, cookie import or browser login.
55
- 4. Return to the connection page, select the account and click **「连接到 Magpie」** (Connect to Magpie). The existing `ai-studio` provider, models, image generation and usage cards remain available. Repeat sign-in to add more accounts.
113
+ - **Don't pick an image model as the chat model:** Magpie still keeps a plugin's models that draw in its chat model lists ([yetone/magpie#2792](https://github.com/yetone/magpie/issues/2792)). Picked there, they show no picture: an agent such as pi has no place for an image in the model's reply, so the image the model draws is dropped, while the model believes it was shown. They take no tool calls either, and have 32K–128K context windows.
114
+ - **Drawing from the command line:** `magpie tool generate_image "a magpie on a branch, watercolour" --size 16:9 -o magpie.png`; add `--model ai-studio/gemini-3-pro-image` to draw with another model this once. If the terminal can't find the `magpie` command (step 2's command too), click **Add to PATH** on the **Command line** row of Magpie's Settings, then open a new terminal.
115
+ - **Size:** `size` gives the aspect ratio. A ratio (such as `16:9` or `1:4`) is used as it is when the model takes it, else the nearest one it does; a size such as `1536x1024` is made the nearest usual ratio by Magpie first. `quality` makes no difference for these models.
116
+ - If you don't want the image models, turn them off with `studio.imageModels` (see the options below).
56
117
 
57
- If an existing account needs to sign in again, select that account in Magpie, use its **Re-login** action in account management, then return to confirm the connection.
118
+ ## Advanced Configuration & Operations
58
119
 
59
- Subsequent starts reuse the installed executable. **Automatic stable updates are enabled by default:** while Magpie is running, the plugin checks in the background, caching successful release checks for an hour. After downloading and verifying an update, it waits for generation requests (including streams), account login and browser preparation to finish before upgrading and restarting. Accounts, port, credentials and settings remain in place; no new plugin release is needed. Failed checks or downloads leave the current version running. A failed new executable triggers an attempted rollback and blocks repeated attempts to install that archive.
120
+ <a id="ai-studio-backend-auto-update-proxy--advanced-options"></a>
60
121
 
61
- Use `npm run studio:updates -- manual` to manage versions yourself, or `npm run studio:updates -- auto` to resume automatic updates. Custom executables and independent services remain user-managed.
122
+ <details>
123
+ <summary><b>⚙️ AI Studio Backend Auto-Update, Proxy & Advanced Options</b> (install & upgrade, browser preparation, CLI command table)</summary>
62
124
 
63
- Browser login downloads Camoufox (about 1.3 GB with v0.3.7+); Chrome / cookie import can use existing sessions. Magpie limits each connection attempt to 10 minutes. On slow connections, finish preparation in the official account management page: its background download and login tasks continue after Magpie times out. Then start a new connection in Magpie and select the imported account. Alternatively, run `npm run studio:prepare-browser` from the plugin directory before signing in. It waits up to an hour; closing the command does not cancel the backend download. Set `studio.proxy` or `AI_STUDIO_PROXY` if GitHub is unreachable. **「直接打开 Google 登录窗口」** still opens an isolated browser login window. Existing backends with Magpie task correlation can still complete the account connection automatically.
125
+ <br>
64
126
 
65
- Automatic installation supports macOS / Linux x64 and arm64, and Windows x64. macOS / Linux use official CLI archives. The official Windows archive contains a desktop executable, installed beside `.env` and `runtime/` in the data directory to retain its settings. Windows arm64 currently needs a compatible executable selected through the advanced path option (for example, an x64 executable supported by the system), or an independent backend. Unsupported targets receive guidance before a release lookup.
127
+ **Automatic installation & updates:**
128
+ - On first use, the plugin **automatically downloads, verifies and starts the latest stable official AIStudio2API backend**. No manual download, executable path, API key copying or administrator credentials are needed.
129
+ - **Automatic stable updates are enabled by default:** while Magpie is running, the plugin checks in the background, caching successful release checks for an hour. After downloading and verifying an update, it waits for generation requests (including streams), account login and browser preparation to finish before upgrading and restarting. Accounts, port, credentials and settings remain in place; no new plugin release is needed. Failed checks or downloads leave the current version running. A failed new executable triggers an attempted rollback and blocks repeated attempts to install that archive.
130
+ - Use `npm run studio:updates -- manual` to manage versions yourself, or `npm run studio:updates -- auto` to resume automatic updates. Custom executables and independent services remain user-managed.
131
+ - Browser login downloads Camoufox (about 1.3 GB with v0.3.7+); Chrome / cookie import can use existing sessions. Magpie limits each connection attempt to 10 minutes. On slow connections, finish preparation in the official account management page: its background download and login tasks continue after Magpie times out. Then start a new connection in Magpie and select the imported account. Alternatively, run `npm run studio:prepare-browser` from the plugin directory before signing in. It waits up to an hour; closing the command does not cancel the backend download. Set `studio.proxy` or `AI_STUDIO_PROXY` if GitHub is unreachable. **Open the Google sign-in window directly** is still available for an isolated browser login. Existing backends with Magpie task correlation can still complete the account connection automatically.
132
+ - Automatic installation supports macOS / Linux x64 and arm64, and Windows x64. macOS / Linux use official CLI archives. The official Windows archive contains a desktop executable, installed beside `.env` and `runtime/` in the data directory to retain its settings. Windows arm64 currently needs a compatible executable selected through the advanced path option (for example, an x64 executable supported by the system), or an independent backend. Unsupported targets receive guidance before a release lookup.
66
133
 
67
134
  **Existing installations and version selection:**
68
135
 
@@ -75,63 +142,95 @@ Automatic installation supports macOS / Linux x64 and arm64, and Windows x64. ma
75
142
  ```
76
143
 
77
144
  - To choose an official version, stop the service and run `npm run studio:install -- --version v0.3.7`. This verifies the official SHA-256 and selects manual updates to preserve your choice. Run `npm run studio:updates -- auto` to follow stable releases again. Historical installation hashes do not force file restoration, and automatic updates never downgrade a newer running version. Back up the entire data directory before downgrading: older versions may not read data migrated by newer ones.
78
- - **Advanced option:** Select 「指定 AIStudio2API 程序路径(高级)」 (Specify executable path) or run `npm run studio:use -- "/absolute/path/to/aistudio2api"`. Use an executable extracted from an [official archive](https://github.com/Mag1cFall/AIStudio2API/releases), outside the plugin and AI Studio data directories; stop the old service before switching. A missing custom executable produces an error and is never replaced by a download. `studio:use-default` returns to the default directory, reusing its executable or installing the official CLI if absent.
145
+ - **Advanced option:** Select **Specify AIStudio2API executable path (advanced)** or run `npm run studio:use -- "/absolute/path/to/aistudio2api"`. Use an executable extracted from an [official archive](https://github.com/Mag1cFall/AIStudio2API/releases), outside the plugin and AI Studio data directories; stop the old service before switching. A missing custom executable produces an error and is never replaced by a download. `studio:use-default` returns to the default directory, reusing its executable or installing the official CLI if absent.
79
146
  - Existing configurations receive a one-time migration of missing legacy defaults: `SEARCH_MODEL_ALIASES=false`, per-account concurrency / warm worker limit / maximum workers / warm startup concurrency all `1`, `ROUTING_STRATEGY=fill-first`, and `REQUEST_TIMEOUT=30m`, along with the earlier disabled hedging policy. Explicit settings and unknown keys remain intact. Later admin choices, including defaults omitted by upstream Save, are not seeded again.
80
147
  - Fresh installations follow upstream defaults. With v0.3.7+ this enables search model aliases, per-account concurrency 2, 10 warm / 20 maximum workers, round-robin routing, and SpiderMonkey generation. A future version changing the `WAA_BACKEND` default could also require Camoufox or other browser components for generation; choose explicit settings in the admin page if needed.
81
148
  - The plugin maintains the local connection and account access. Other settings belong to the backend, including future configuration keys. Uninstall or `studio:clean` removes downloaded programs from the default directory while retaining accounts and settings. With a custom path, the process, executable and entire data directory are preserved; use `studio:stop` to stop it.
82
149
 
83
- For an independently running service, choose **Connect an existing AIStudio2API (URL + API key)**. With official v0.3.7+, Hydrogen Extra High maps to Magpie's `xhigh` variant.
84
-
85
- ### Option 2: Gemini Web (`gemini-web`)
150
+ **Independent service:** For an independently running service, choose **Connect an existing AIStudio2API (URL + API key)**. With official v0.3.7+, Hydrogen Extra High maps to Magpie's `xhigh` variant.
86
151
 
87
- 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—you can also fill or change it on the local sign-in wizard page.
88
- 2. Magpie opens a **local sign-in wizard** (`127.0.0.1`, random port + random path, loopback only) that walks you through three steps:
89
- 1. Click **「打开无痕窗口登录 Gemini」**; the plugin launches the first detected browser in private mode (Firefox preferred, then Chrome / Brave / Chromium / Edge). If no known browser is found the page shows the link—open <https://gemini.google.com/app> in a private window yourself and sign in to your Google account.
90
- 2. Press `F12` (`⌥⌘I` on macOS), switch to the **Network** tab, reload the page, click any `gemini.google.com` request → **Headers** → **Request Headers**, copy the `cookie` value and paste it back into the wizard.
91
- 3. In the same form enter the **Google account index** (the `N` from `/u/N/app` in the private window's address bar—blank means `0` for a single account) and an optional **proxy URL**, then click **「验证并完成登录」**. Failures are shown in place; fix the fields and retry without starting over.
92
- 3. Once the page shows the bound email, sign-in is complete—**close the private window directly, do not sign out** (signing out invalidates the cookie). Repeat the steps above to add more accounts.
152
+ **When the local service starts and stops:**
153
+ - It starts in the background when the plugin loads (when Magpie opens, for example); after that, a request or a usage card refresh starts it again if it isn't running.
154
+ - It is a process of its own: **quitting Magpie doesn't stop it**, and Magpie picks it up again the next time it opens.
155
+ - To stop it, use `studio:stop` below (or the full command an error gives). A stop lasts until the next request, which starts it again.
93
156
 
94
- > **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.
157
+ When a plugin error asks you to run a command, it includes the full ready-to-copy path. From the plugin directory, you can also run:
95
158
 
96
- > **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.
159
+ | Command | Description |
160
+ | :--- | :--- |
161
+ | `npm run studio:status` | Show local service and account status |
162
+ | `npm run studio:start` / `studio:stop` | Start / stop the local service |
163
+ | `npm run studio:clean` | Clean downloaded programs in the default directory, keeping accounts/config; skipped for custom paths |
164
+ | `npm run studio:use -- <executable>` | Select an official or custom executable; stop the current service before switching |
165
+ | `npm run studio:use-default` | Return to the default directory; reuse its executable or install the official CLI if absent |
166
+ | `npm run studio:login` | Add a Google account |
167
+ | `npm run studio:prepare-browser` | Prepare the login browser before signing in; closing the command leaves the backend download running |
168
+ | `npm run studio:relogin -- [<account>]` | Re-authenticate an expired account (argument optional if only one) |
169
+ | `npm run studio:install -- [--version v0.3.7]` | Install the latest or specified official release after stopping; keep accounts and settings |
170
+ | `npm run studio:install -- --version v0.3.7 --archive <file>` | Install a local official archive; still fetch its checksum from GitHub |
171
+ | `npm run studio:official:smoke` | Check installation, account paths, connection and live file replacement in disposable data, without real Google credentials |
172
+ | `npm run studio:updates -- auto` / `manual` | Enable or disable automatic updates for the default backend; omit the argument to show the policy |
173
+ | `npm run studio:auto-update:smoke` | Verify background upgrades, retained data and executable rollback in a disposable directory |
174
+ | `npm run studio:update:smoke -- v0.3.6` | Explicitly update an isolated older official backend to the latest release and verify restart |
175
+ | `node scripts/studio.mjs import <dir>` | Import existing accounts while the service is stopped |
176
+ | `npm run studio:smoke` | Run a live acceptance check (consumes account quota) |
97
177
 
98
- ---
178
+ **AI Studio upgrades and model selection:**
179
+ - Installation and automatic updates use the latest stable official release for macOS / Linux x64 or arm64, or Windows x64. Release metadata must identify the correct platform archive and SHA-256. Publishing the plugin does not require a custom backend build or pinned Studio artifacts.
180
+ - With 0.3.7+, `MAX_ACCOUNT_SWITCHES`, `DISCOVER_HIDDEN_MODELS`, account order, model bindings and all other valid `.env` keys are preserved. Explicit saved values remain in effect; omitted values use upstream defaults. The plugin no longer seeds fixed worker, hedge-request or generation-backend settings.
181
+ - The default executable is `package/aistudio2api` in the data directory, or `aistudio2api.exe` at its root on Windows. Older managed builds retain their accounts and data and can be automatically replaced with official packages. Historical builds and the 0.3.7 candidate patches remain documented in [docs/studio-release.md](docs/studio-release.md); they do not select the default install or update version.
182
+ - Stop discovers replacement PIDs and checks executable identity. Custom paths also check the account-directory argument to distinguish instances sharing a program. Unverified processes are never signaled; a live process with HTTP down blocks installation and duplicate startup.
183
+ - A missing default executable is installed automatically; an existing one is updated in the background when idle. A missing custom path produces an error. Executable rollback does not undo the backend's own data migrations. Back up the entire data directory, including `auth/` and `runtime/requests.db`, before a manual downgrade.
184
+ - The plugin's default response/stream-idle timeout is 30 minutes, adjustable with `studio.requestTimeoutMs`. Backend deadlines and concurrency follow its defaults or admin settings. Shorter limits can interrupt long replies; the selected backend controls automatic continuation deadlines.
185
+ - `gemini-4-hydrogen` and `gemini-4-carbon` are supported through official v0.3.5–v0.3.8+ catalogs: `gemini-4-hydrogen`'s `extra_high` thinking level maps to Magpie's `xhigh` variant, while `gemini-4-carbon` appears when at least one signed-in account has an eligible tier (such as Google AI Ultra) and is omitted otherwise to avoid 403 errors (enable `DISCOVER_HIDDEN_MODELS` in the admin page to probe frontend-configured models not yet listed publicly).
186
+ - Deep Research models (`deep-research-preview-04-2026`, `deep-research-max-preview-04-2026`) are supported: listed when signed in with a Google AI Pro / Ultra account; the backend adapts asynchronous Interactions tasks onto `/v1/chat/completions` streaming (including reasoning and built-in server-side search), without client `tool_call` (Function Calling) or `temperature`.
187
+ - 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.
99
188
 
100
- ## Multiple Accounts & Usage Cards
189
+ </details>
101
190
 
102
- - **Account usage cards:** Individual accounts use their email address. An AI Studio batch gets a separate group card; importing the same group in a different order keeps its identity.
103
- - *Migrating older Gemini Web accounts:* For accounts added in earlier versions, add a Gemini Web account in Magpie and choose **「添加本地后端里已有的 Google 账号」** (Add an existing Google account from the local backend) to create individual cards, then remove the old pooled `API key …` card.
104
- - **Automatic account rotation:** The local backend selects which Google account serves each request (Gemini Web rotates across the pool; AI Studio uses one account until cooldown and switches to the next, with optional account priority order and per-model account bindings configurable in the admin page or via `studio.accountOrder` and `studio.modelAccounts`). Switching cards in Magpie does not change which account the backend picks.
105
- - **Usage reporting:**
106
- - `gemini-web`: Available only with the one-click local backend. Usage is read from Google again whenever Magpie asks for it (at most once every 30 seconds per account), so pressing refresh shows the current allowance, including usage from the Gemini app, the website or other devices. On its own, Magpie asks about once a minute while the Usage page or the menu bar's allowances panel is open, whenever it updates allowances shown in the menu bar (every 3 minutes by default), and at most once a minute while it routes requests among accounts; otherwise it doesn't ask. A failed read isn't retried on its own for 10 minutes; pressing refresh in that time retries it at once (press it again if the first press doesn't).
107
- - `ai-studio`: AI Studio does not report remaining total quota; cards display models currently on cooldown and their recovery times, or prompt when re-authentication is needed.
191
+ <a id="migrating-from-unscoped-magpie-gemini-web--upstream-rollback"></a>
108
192
 
109
- ---
193
+ <details>
194
+ <summary><b>📦 Migrating from Unscoped magpie-gemini-web & Upstream Rollback</b> (legacy package migration, zexadev rollback channel)</summary>
110
195
 
111
- ## Image Generation (AI Studio)
196
+ <br>
112
197
 
113
- `ai-studio` lists the Nano Banana image models your account can use (such as `gemini-3.1-flash-image` and `gemini-3-pro-image`), for Magpie's image generation. **This needs Magpie v0.1.2075 or later**, the first to take a plugin's Gemini image models as models that draw.
198
+ **Migrating from the legacy package:** since `0.15.0` the npm package is the scoped `@dorokuma/magpie-gemini-web` (previously the unscoped `magpie-gemini-web`). If you installed the old package, remove `magpie-gemini-web` from the Magpie plugin market and install the new one. The local data directory `~/.local/share/magpie-gemini-web`, saved Google accounts, cookies, database and credentials are all preserved—no sign-in or cookie re-import is needed. During the transition, uninstall cleanup recognizes both package names and never mistakes the new plugin for removed.
114
199
 
115
- **Drawing from an agent** (pi, Claude Code, Codex and the rest alike):
200
+ **Gemini Web sign-in troubleshooting:**
201
+ - **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.
202
+ - The missing multi-account index in [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) is fixed. Reimport affected cookies or correct the index in backend account management. The backend natively exposes dedicated `gemini-4-carbon`, `gemini-4-hydrogen`, and `gemini-4-neon` model IDs (including `-thinking` variants; the Neon family thinks server-side internally and never emits `reasoning_content`), and drops the public `gemini-4-argon*` models (the old Argon slot was renamed to 4 Carbon in the upstream catalog and Argon is delisted by Google—use `gemini-4-carbon*` or `gemini-4-neon*`); its `strict_model` slot check mutually recognizes display-name upgrades/downgrades, so paid accounts whose `gemini-3.8-flash` calls are routed to `4 Hydrogen` are identified correctly instead of failing with `429 model_downgraded`.
203
+ - One-click setup pins the prebuilt binaries from the [`dorokuma/gemini-web2api-go` Releases](https://github.com/dorokuma/gemini-web2api-go/releases) by default (one repo, one artifact: six-platform SHA-256 pins live in `lib/backend-release.json`; the plugin no longer patches and rebuilds the backend). Chat requests are timed by silence: while Google queues a request it sends a heartbeat every 60 s, and the backend waits through it for the first words. A try is given up, and retried, only after Google has sent nothing for `request_timeout_sec` (180 s by default), so a long reply that keeps coming is never cut off either.
204
+ - **Upgrading:** On load the plugin detects a stale managed backend process, stops it and upgrades the binary to the version currently pinned in `lib/backend-release.json`, which may interrupt in-flight generation requests. Wait for in-flight requests to finish, or stop the existing process manually (PID in `backend.pid` inside the data directory) before upgrading. Instances not managed or recognizable by the plugin are not guaranteed to auto-update. Config and cookies are preserved.
205
+ - **Rollback to upstream / restore the pinned build** (run in the plugin directory after stopping the backend):
116
206
 
117
- 1. **Pick the model to draw with:** Magpie's Settings list these models under **Images → Image generation**. Pick one (such as `ai-studio/gemini-nano-banana-2.1`), or leave it on Automatic. There's no need to tick them in any model list.
118
- 2. **Give the agent the drawing tool:** click **Give agents Magpie Image…** under that row, tick the agents that should draw in the Library it opens, then start a new session in the agent. With the Library turned off, the row says **Turn on the Library** instead: click that first. From the command line: `magpie library mcp add magpie-image magpie mcp image agents=pi` (several agents separated by commas, as in `agents=pi,claude`).
119
- 3. **Chat as usual:** keep the agent on its usual chat model and ask it to draw something. It calls the `generate_image` tool, which draws with the model from step 1 and saves the image in the project's `generated-images/` folder; reference images make it an edit.
207
+ ```bash
208
+ npm run backend:install:upstream # Roll back and pin to upstream zexadev v4.28.0
209
+ npm run backend:install # Restore the default pinned version (see lib/backend-release.json)
210
+ ```
120
211
 
121
- - **Don't pick an image model as the chat model:** Magpie still keeps a plugin's models that draw in its chat model lists ([yetone/magpie#2792](https://github.com/yetone/magpie/issues/2792)). Picked there, they show no picture: an agent such as pi has no place for an image in the model's reply, so the image the model draws is dropped, while the model believes it was shown. They take no tool calls either, and have 32K–128K context windows.
122
- - **Drawing from the command line:** `magpie tool generate_image "a magpie on a branch, watercolour" --size 16:9 -o magpie.png`; add `--model ai-studio/gemini-3-pro-image` to draw with another model this once. If the terminal can't find the `magpie` command (step 2's command too), click **Add to PATH** on the **Command line** row of Magpie's Settings, then open a new terminal.
123
- - **Size:** `size` gives the aspect ratio. A ratio (such as `16:9` or `1:4`) is used as it is when the model takes it, else the nearest one it does; a size such as `1536x1024` is made the nearest usual ratio by Magpie first. `quality` makes no difference for these models.
124
- - If you don't want the image models, turn them off with `studio.imageModels` (see the options below).
212
+ - For pin sync, verification and smoke procedures, see [docs/backend-release.md](docs/backend-release.md).
125
213
 
126
- ---
214
+ </details>
127
215
 
128
- ## Configuration & Advanced Usage
216
+ <a id="security-local-data-directory--troubleshooting"></a>
129
217
 
130
218
  <details>
131
- <summary><b>⚙️ Plugin Options & Proxy Setup</b> (image input, proxy configuration, custom backends)</summary>
219
+ <summary><b>🔒 Security, Local Data Directory & Troubleshooting</b> (plugin options, proxies, logs & cleanup)</summary>
132
220
 
133
221
  <br>
134
222
 
223
+ **Security & data directories:**
224
+ - Both backends listen on `127.0.0.1` only. Cookies and sessions remain on your machine; Magpie stores only a locally generated API key.
225
+ - **Gemini Web data directory:** `~/.local/share/magpie-gemini-web` (override with `GEMINI_WEB_DATA_DIR`), logs at `backend.log`. Supports macOS, Linux, and Windows (x64 / arm64).
226
+ - **AI Studio data directory:** `~/.local/share/magpie-ai-studio` (override with `AI_STUDIO_DATA_DIR`), logs at `backend.log` (rotated on next start after exceeding 10 MB). Uses port 2048 by default (or picks a free port and saves it in `config.json`). Supports macOS, Linux (x64 / arm64), and Windows x64.
227
+ - **Uninstalling & cleaning downloaded assets:** Removing the plugin in Magpie (or running `npm run studio:clean` / `npm run backend:clean`) stops plugin-managed services and removes their downloaded binaries and archives. **User-managed AIStudio2API processes, executables and data directories are preserved**, for the user to stop and clean.
228
+ - `auth/`, `gemini.db`, `config.json`, `.env`, and `secrets.json` are kept so reinstalling the plugin or sending a new request restores the backend on demand without signing in or importing cookies again; to prevent automatic reinstallation permanently, remove the sign-in in Magpie or delete `config.json` / `secrets.json`.
229
+ - Default data directories are shared per OS user; set separate `AI_STUDIO_DATA_DIR` and `GEMINI_WEB_DATA_DIR` when running multiple isolated Magpie config directories so removing the plugin in one does not clean another's shared binaries.
230
+ - Gemini Web takes at most 2 requests at once per sign-in (AI Studio 1), adjustable in Magpie's provider settings. Google account rate-limiting or flagging cannot be completely ruled out—use at your own risk.
231
+
232
+ **Plugin options & proxy setup:**
233
+
135
234
  Tool calling and image input are enabled by default. Configure plugin options via the CLI:
136
235
 
137
236
  ```bash
@@ -167,11 +266,11 @@ magpie plugin options @dorokuma/magpie-gemini-web '{"studio":{"proxy":"http://12
167
266
  | `studio.imageModels` | `true` | `ai-studio` only | List the Nano Banana image models, for Magpie's image generation; `false` lists text models only |
168
267
 
169
268
  **Using a proxy to reach Google:**
170
- - **AI Studio:** Preferably set it in the local admin page. Choose 「添加账号并连接(推荐)」 in Magpie, select the new-account option, and open the authenticated account management page from the connection page. Save the proxy, then restart the service from the admin page. The plugin keeps the saved value when it restarts the backend. Usage cards show the management address without administrator details, credential file locations or executable paths.
269
+ - **AI Studio:** Preferably set it in the local admin page. Choose **Add an account and connect** in Magpie, select the new-account option, and open the authenticated account management page from the connection page. Save the proxy, then restart the service from the admin page. The plugin keeps the saved value when it restarts the backend. Usage cards show the management address without administrator details, credential file locations or executable paths.
171
270
  - 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).
172
271
  - With none set, the backend goes out directly, or through the system proxy on macOS and Windows.
173
- - **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.
174
- - 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.
272
+ - **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 "proxy exit" line marks it and says what a restart changes.
273
+ - 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.
175
274
  - The listen address, API key and admin credentials are managed by the plugin; changing them in the admin page has no effect.
176
275
  - **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).
177
276
  - *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).
@@ -184,79 +283,11 @@ After upgrading the plugin, run `magpie provider models gemini-web` to refresh a
184
283
 
185
284
  </details>
186
285
 
187
- <details>
188
- <summary><b>🛠️ AI Studio CLI Commands</b> (service status, browser preparation, version management)</summary>
189
-
190
- <br>
191
-
192
- **When the local service starts and stops:**
193
- - It starts in the background when the plugin loads (when Magpie opens, for example); after that, a request or a usage card refresh starts it again if it isn't running.
194
- - It is a process of its own: **quitting Magpie doesn't stop it**, and Magpie picks it up again the next time it opens.
195
- - To stop it, use `studio:stop` below (or the full command an error gives). A stop lasts until the next request, which starts it again.
196
-
197
- When a plugin error asks you to run a command, it includes the full ready-to-copy path. From the plugin directory, you can also run:
198
-
199
- | Command | Description |
200
- | :--- | :--- |
201
- | `npm run studio:status` | Show local service and account status |
202
- | `npm run studio:start` / `studio:stop` | Start / stop the local service |
203
- | `npm run studio:clean` | Clean downloaded programs in the default directory, keeping accounts/config; skipped for custom paths |
204
- | `npm run studio:use -- <executable>` | Select an official or custom executable; stop the current service before switching |
205
- | `npm run studio:use-default` | Return to the default directory; reuse its executable or install the official CLI if absent |
206
- | `npm run studio:login` | Add a Google account |
207
- | `npm run studio:prepare-browser` | Prepare the login browser before signing in; closing the command leaves the backend download running |
208
- | `npm run studio:relogin -- [<account>]` | Re-authenticate an expired account (argument optional if only one) |
209
- | `npm run studio:install -- [--version v0.3.7]` | Install the latest or specified official release after stopping; keep accounts and settings |
210
- | `npm run studio:install -- --version v0.3.7 --archive <file>` | Install a local official archive; still fetch its checksum from GitHub |
211
- | `npm run studio:official:smoke` | Check installation, account paths, connection and live file replacement in disposable data, without real Google credentials |
212
- | `npm run studio:updates -- auto` / `manual` | Enable or disable automatic updates for the default backend; omit the argument to show the policy |
213
- | `npm run studio:auto-update:smoke` | Verify background upgrades, retained data and executable rollback in a disposable directory |
214
- | `npm run studio:update:smoke -- v0.3.6` | Explicitly update an isolated older official backend to the latest release and verify restart |
215
- | `node scripts/studio.mjs import <dir>` | Import existing accounts while the service is stopped |
216
- | `npm run studio:smoke` | Run a live acceptance check (consumes account quota) |
217
-
218
- </details>
219
-
220
- <details>
221
- <summary><b>🔒 Security, Data Directories & Backend Version Management</b> (logs, rollback)</summary>
222
-
223
- <br>
224
-
225
- **Security & data directories:**
226
- - Both backends listen on `127.0.0.1` only. Cookies and sessions remain on your machine; Magpie stores only a locally generated API key.
227
- - **Gemini Web data directory:** `~/.local/share/magpie-gemini-web` (override with `GEMINI_WEB_DATA_DIR`), logs at `backend.log`. Supports macOS, Linux, and Windows (x64 / arm64).
228
- - **AI Studio data directory:** `~/.local/share/magpie-ai-studio` (override with `AI_STUDIO_DATA_DIR`), logs at `backend.log` (rotated on next start after exceeding 10 MB). Uses port 2048 by default (or picks a free port and saves it in `config.json`). Supports macOS, Linux (x64 / arm64), and Windows x64.
229
- - **Uninstalling & cleaning downloaded assets:** Removing the plugin in Magpie (or running `npm run studio:clean` / `npm run backend:clean`) stops plugin-managed services and removes their downloaded binaries and archives. **User-managed AIStudio2API processes, executables and data directories are preserved**, for the user to stop and clean.
230
- - `auth/`, `gemini.db`, `config.json`, `.env`, and `secrets.json` are kept so reinstalling the plugin or sending a new request restores the backend on demand without signing in or importing cookies again; to prevent automatic reinstallation permanently, remove the sign-in in Magpie or delete `config.json` / `secrets.json`.
231
- - Default data directories are shared per OS user; set separate `AI_STUDIO_DATA_DIR` and `GEMINI_WEB_DATA_DIR` when running multiple isolated Magpie config directories so removing the plugin in one does not clean another's shared binaries.
232
- - Gemini Web takes at most 2 requests at once per sign-in (AI Studio 1), adjustable in Magpie's provider settings. Google account rate-limiting or flagging cannot be completely ruled out—use at your own risk.
233
-
234
- **AI Studio upgrades and model selection:**
235
- - Installation and automatic updates use the latest stable official release for macOS / Linux x64 or arm64, or Windows x64. Release metadata must identify the correct platform archive and SHA-256. Publishing the plugin does not require a custom backend build or pinned Studio artifacts.
236
- - With 0.3.7+, `MAX_ACCOUNT_SWITCHES`, `DISCOVER_HIDDEN_MODELS`, account order, model bindings and all other valid `.env` keys are preserved. Explicit saved values remain in effect; omitted values use upstream defaults. The plugin no longer seeds fixed worker, hedge-request or generation-backend settings.
237
- - The default executable is `package/aistudio2api` in the data directory, or `aistudio2api.exe` at its root on Windows. Older managed builds retain their accounts and data and can be automatically replaced with official packages. Historical builds and the 0.3.7 candidate patches remain documented in [docs/studio-release.md](docs/studio-release.md); they do not select the default install or update version.
238
- - Stop discovers replacement PIDs and checks executable identity. Custom paths also check the account-directory argument to distinguish instances sharing a program. Unverified processes are never signaled; a live process with HTTP down blocks installation and duplicate startup.
239
- - A missing default executable is installed automatically; an existing one is updated in the background when idle. A missing custom path produces an error. Executable rollback does not undo the backend's own data migrations. Back up the entire data directory, including `auth/` and `runtime/requests.db`, before a manual downgrade.
240
- - The plugin's default response/stream-idle timeout is 30 minutes, adjustable with `studio.requestTimeoutMs`. Backend deadlines and concurrency follow its defaults or admin settings. Shorter limits can interrupt long replies; the selected backend controls automatic continuation deadlines.
241
- - Source review of the locally installed Magpie `v0.1.1285` (`d783df46`) found no shorter fixed total timeout on this plugin's generation path: `Provider.Do → plugin.Fetch → loader.fetch` bypasses the ordinary HTTP transport's 10-minute response-header timeout. The gateway's 5-minute `IdleTimeout` applies between requests. Clients or reverse proxies can impose shorter limits; this was not a 30-minute end-to-end waiting test.
242
- - `gemini-4-hydrogen` and `gemini-4-carbon` are supported through official v0.3.5–v0.3.8+ catalogs: `gemini-4-hydrogen`'s `extra_high` thinking level maps to Magpie's `xhigh` variant, while `gemini-4-carbon` appears when at least one signed-in account has an eligible tier (such as Google AI Ultra) and is omitted otherwise to avoid 403 errors (enable `DISCOVER_HIDDEN_MODELS` in the admin page to probe frontend-configured models not yet listed publicly).
243
- - Deep Research models (`deep-research-preview-04-2026`, `deep-research-max-preview-04-2026`) are supported: listed when signed in with a Google AI Pro / Ultra account; the backend adapts asynchronous Interactions tasks onto `/v1/chat/completions` streaming (including reasoning and built-in server-side search), without client `tool_call` (Function Calling) or `temperature`.
244
- - 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.
245
-
246
- **Gemini Web optimized backend upgrades & rollback:**
247
- - The missing multi-account index in [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) is fixed. Reimport affected cookies or correct the index in backend account management. Backend [`dorokuma/gemini-web2api-go` `v6.3.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0) natively exposes dedicated `gemini-4-carbon`, `gemini-4-hydrogen`, and `gemini-4-neon` model IDs (including `-thinking` variants; the Neon family thinks server-side internally and never emits `reasoning_content`), and drops the public `gemini-4-argon*` models (the old Argon slot was renamed to 4 Carbon in the upstream catalog and Argon is delisted by Google—use `gemini-4-carbon*` or `gemini-4-neon*`); its `strict_model` slot check mutually recognizes display-name upgrades/downgrades, so paid accounts whose `gemini-3.8-flash` calls are routed to `4 Hydrogen` are identified correctly instead of failing with `429 model_downgraded`.
248
- - One-click setup pins the prebuilt [v6.3.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0) binaries from the backend repository by default (one repo, one artifact: six-platform SHA-256 pins live in `lib/backend-release.json`; the plugin no longer patches and rebuilds the backend). Chat requests are timed by silence: while Google queues a request it sends a heartbeat every 60 s, and the backend waits through it for the first words. A try is given up, and retried, only after Google has sent nothing for `request_timeout_sec` (180 s by default), so a long reply that keeps coming is never cut off either.
249
- - **Upgrading:** On load the plugin detects a stale managed backend process, stops it and upgrades the binary to the pinned `v6.3.0`, which may interrupt in-flight generation requests. Wait for in-flight requests to finish, or stop the existing process manually (PID in `backend.pid` inside the data directory) before upgrading. Instances not managed or recognizable by the plugin are not guaranteed to auto-update. Config and cookies are preserved.
250
- - **Rollback to upstream / restore the pinned build** (run in the plugin directory after stopping the backend):
251
- ```bash
252
- npm run backend:install:upstream # Roll back and pin to upstream zexadev v4.28.0
253
- npm run backend:install # Restore the default pinned v6.3.0
254
- ```
255
- - For pin sync, verification and smoke procedures, see [docs/backend-release.md](docs/backend-release.md).
286
+ ---
256
287
 
257
- </details>
288
+ ## Friends
258
289
 
259
- ---
290
+ [LINUX DO](https://linux.do/) — a sincere, friendly, united and professional tech community.
260
291
 
261
292
  ## License
262
293
 
package/README.md CHANGED
@@ -1,12 +1,44 @@
1
- # <img src="docs/logo.svg" width="28" height="28" align="top" alt="" /> magpie-gemini-web
1
+ <div align="center">
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@dorokuma/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web) [![npm downloads](https://img.shields.io/npm/dw/@dorokuma/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/@dorokuma/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/dorokuma/magpie-gemini-web) [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/dorokuma/magpie-gemini-web/main/docs/logo-dark.svg" />
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/dorokuma/magpie-gemini-web/main/docs/logo-light.svg" />
6
+ <img src="docs/logo.svg" width="64" height="64" alt="magpie-gemini-web" />
7
+ </picture>
4
8
 
5
- 中文 | [English](README.en.md)
9
+ # magpie-gemini-web
6
10
 
7
- 让 [Magpie](https://usemagpie.ai/) 通过你的 Google 账号使用 **Google AI Studio** 与 **Gemini 网页版**。插件在本机自动运行 [AIStudio2API](https://github.com/Mag1cFall/AIStudio2API) 与 [gemini-web2api-go](https://github.com/zexadev/gemini-web2api-go),提供对话、原生工具调用、Nano Banana 图片生成与 Deep Research 等能力。
11
+ **不用自己搭服务器、不用买 API Key,装好插件无痕登录,就能在 [Magpie](https://usemagpie.ai/) 里直接给 Agent 接上稳定好用的 Gemini(原生工具调用、Nano Banana 出图、Deep Research 与实时额度卡片)。**
8
12
 
9
- > **新模型支持说明**:**Google AI Studio (`ai-studio`)** 默认自动跟随官方最新稳定版后端,现已直接支持 **`gemini-4-hydrogen`**(含 `xhigh` 思考档位)与 **`gemini-4-carbon`**(需账号具备对应权益,如 Google AI Ultra)。**Gemini Web (`gemini-web`)** 由后端 [`dorokuma/gemini-web2api-go` `v6.3.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0) 原生支持 `gemini-4-carbon` / `gemini-4-hydrogen` / **`gemini-4-neon`** 专用模型 ID(含 `-thinking` 思考变体),`strict_model` 开启时也能正确互认槽位升降级;`gemini-4-neon` 系列为服务端内部思考模型,回复中不输出 `reasoning_content`。**对话模式与任务模式分离**:日常对话用 `gemini-4-neon` / `gemini-4-hydrogen` / `gemini-4-carbon`(`gemini-4-carbon` 及 `-thinking` / `-thinking-medium` 变体为纯对话模式),任务/工具密集型场景可选独立任务模式模型 **`gemini-4-neon-task`**、**`gemini-4-carbon-task`** 与 **`gemini-4-hydrogen-task`**(对应 Gemini Web 网页端「任务」开关)。
13
+ [![npm version](https://img.shields.io/npm/v/@dorokuma/magpie-gemini-web?style=flat-square&logo=npm&color=4f46e5)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web)
14
+ [![npm downloads](https://img.shields.io/npm/dw/@dorokuma/magpie-gemini-web?style=flat-square&color=06b6d4)](https://www.npmjs.com/package/@dorokuma/magpie-gemini-web)
15
+ [![Magpie Plugin](https://img.shields.io/badge/Magpie-Plugin-3b82f6?style=flat-square)](https://usemagpie.ai/)
16
+ [![Node.js >= 22](https://img.shields.io/badge/node-%3E%3D22-8b5cf6?style=flat-square&logo=node.js&logoColor=white)](https://nodejs.org/)
17
+ [![Platform](https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows-6366f1?style=flat-square)](https://github.com/dorokuma/magpie-gemini-web)
18
+ [![License: MIT](https://img.shields.io/badge/license-MIT-10b981?style=flat-square)](LICENSE)
19
+
20
+ [快速开始](#快速开始) · [核心特性](#核心特性) · [双引擎对比](#双引擎怎么选) · [进阶配置](#进阶配置与运维)
21
+
22
+ **简体中文** · [English](README.en.md)
23
+
24
+ </div>
25
+
26
+ ```mermaid
27
+ flowchart LR
28
+ A[Magpie Desktop] --> B["@dorokuma/magpie-gemini-web"]
29
+ B --> C["AI Studio<br/>Tool Calling / Deep Research / Nano Banana"]
30
+ B --> D["Gemini Web<br/>Web Quota Chat + 5h/7d Usage Cards"]
31
+ C --> E["Local 127.0.0.1 Managed Backends"]
32
+ D --> E
33
+ ```
34
+
35
+ ## 核心特性
36
+
37
+ | 🚀 双引擎全托管 | 🔐 防踢号无痕登录 | 🧠 AI Studio 能力拉满 |
38
+ | :--- | :--- | :--- |
39
+ | 自动下载校验 SHA-256、本机 `127.0.0.1` 自启保活,无需装 Go 或手动管端口 | 随机令牌本地向导页 + 自动拉起无痕浏览器,保护日常 Google 会话,支持多账号 `/u/N` | 原生 Function Calling、Deep Research、Nano Banana 出图,空闲时自动跟随最新稳定版并支持失败自动回滚 |
40
+ | 📊 Gemini Web 额度卡片 | 📦 无损旧包迁移 | 💻 跨平台即装即用 |
41
+ | 同步网页端 5 小时与每周剩余用量及重置时间,限流参数热生效 | 从无作用域 `magpie-gemini-web` 平滑迁移,账号与 Cookie 零丢失 | macOS / Linux / Windows 预编译后端一键托管 |
10
42
 
11
43
  ## Fork 声明与致谢
12
44
 
@@ -19,11 +51,10 @@
19
51
  **与原版的主要差异**(完整历史见 [CHANGELOG](CHANGELOG.md)):
20
52
 
21
53
  1. npm 包名迁移为作用域包 **`@dorokuma/magpie-gemini-web`**;原版无作用域包 `magpie-gemini-web` 仍由原作者维护,两者在 npm 上是相互独立的包。
22
- 2. Gemini Web 后端固定使用 `dorokuma/gemini-web2api-go` 的**官方 Release 预编译二进制**(当前 `v6.3.0`,SHA-256 由脚本单向同步、禁止手改),移除本地补丁重编流水线。
54
+ 2. Gemini Web 后端固定使用 `dorokuma/gemini-web2api-go` 的**官方 Release 预编译二进制**(版本 pin 在 `lib/backend-release.json`,SHA-256 由脚本单向同步、禁止手改),移除本地补丁重编流水线。
23
55
  3. Gemini Web 新增 `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon` 模型 ID(含独立的任务模式模型 `gemini-4-neon-task` / `gemini-4-carbon-task` / `gemini-4-hydrogen-task`)与互认槽位校验;修复幻影会话、AI Studio 代理优先级、更新锁原子发布与自愈等问题。
24
56
 
25
-
26
- ## 怎么选?
57
+ ## 双引擎怎么选?
27
58
 
28
59
  插件提供两个互相独立的 Provider,可按使用场景选择(也可同时配置):
29
60
 
@@ -37,32 +68,68 @@
37
68
  | **图片生成** | Nano Banana 系列模型,供 Magpie 的图片生成使用(需要 Magpie v0.1.2075+,见下文) | 不支持 |
38
69
  | **登录方式** | 自动安装官方后端,导入账号后确认连接 | 本机向导页引导:无痕窗口登录并复制 `cookie` |
39
70
  | **额度卡片** | 显示冷却中的模型与恢复时间 | 同步网页版 **5 小时** 与 **每周** 用量及重置时间 |
40
- | **本地后端** | AIStudio2API(自动安装并跟随官方稳定版) | gemini-web2api-go (`v6.3.0` 固定 pin 二进制) |
41
-
42
- ---
71
+ | **本地后端** | AIStudio2API(自动安装并跟随官方稳定版) | gemini-web2api-go(pin 版本见 `lib/backend-release.json`) |
43
72
 
44
73
  ## 快速开始
45
74
 
46
- 在 Magpie 插件市场安装 **@dorokuma/magpie-gemini-web** 后,按需登录以下任一(或两个)Provider。
75
+ ### 1. 在 Magpie 中安装
47
76
 
48
- > **从旧包迁移**:`0.15.0` 起 npm 包名为作用域包 `@dorokuma/magpie-gemini-web`(此前为无作用域包 `magpie-gemini-web`)。已装旧包的用户请在 Magpie 插件市场卸载旧的 `magpie-gemini-web` 后重新安装新包;本地数据目录 `~/.local/share/magpie-gemini-web`、已保存的 Google 账号、Cookie、数据库和凭据全部保留,无需重新登录或导 Cookie。迁移期卸载清理同时识别新旧两个包名,不会把新插件误判为已卸载。默认由插件下载对应后端、校验 SHA-256 并在后台自启,无需安装 Go 或其它依赖。AI Studio 默认自动跟随官方最新稳定版,也可关闭自动更新、指定自己的程序或连接独立服务。
77
+ 在 Magpie 插件市场安装 **`@dorokuma/magpie-gemini-web`**。插件会自动下载对应后端、校验 SHA-256 并在后台自启,无需安装 Go 或其它依赖。
49
78
 
50
- ### 方式一:Google AI Studio (`ai-studio`)
79
+ ### 2. 选择 Provider 并登录
51
80
 
52
- 1. 在 Magpie 中登录 **Google AI Studio**,选择 **「添加账号并连接(推荐)」**。
53
- 2. 首次使用时,插件会**自动下载、校验并启动官方 AIStudio2API 最新稳定版**。无需手动下载程序、填写路径、复制 API key 或设置管理员密码。
54
- 3. 按连接页提示点击 **「打开账号管理页」**,在后端页面添加 Google 账号,可选择 Chrome 导入、Cookie 导入或浏览器登录。
55
- 4. 返回连接页,选择刚添加的账号并点击 **「连接到 Magpie」**。继续使用原有的 `ai-studio` Provider、模型、图片生成和额度卡片;添加更多账号时重复登录即可。
81
+ | | Google AI Studio (`ai-studio`) | Gemini Web (`gemini-web`) |
82
+ | :--- | :--- | :--- |
83
+ | **推荐用途** | Agent / Coding 主力(原生工具调用、出图、Deep Research) | 日常对话、网页版额度与用量卡片 |
84
+ | **登录步骤** | 登录页选「添加账号并连接(推荐)」→ 打开账号管理页导入 Google 账号 → 回连接页「连接到 Magpie」 | 登录页选「一键配置本地 Gemini Web(推荐)」→ 本机向导页拉起无痕浏览器登录 → 复制 `cookie` 回填验证 |
85
+ | **说明** | 首次使用自动安装官方 AIStudio2API 最新稳定版 | 向导页仅监听 `127.0.0.1` 随机端口;无痕会话独立,不顶掉日常 Google 登录 |
56
86
 
57
- 已有账号提示登录过期时,在 Magpie 中选择该账号,再按连接页指引到管理页点击原账号的「重新登录」,完成后返回确认。
87
+ > [!TIP]
88
+ > 两个引擎均已支持新一代模型系列(`gemini-4-neon` / `gemini-4-carbon` / `gemini-4-hydrogen`,含 `-thinking` 与独立任务模式 `*-task` 变体),但可用模型与更新渠道按 Provider 不同:**AI Studio** 自动跟随 Google 官方模型目录与思考档位,无需等待插件发版;**Gemini Web** 的 Neon / `-thinking` / `*-task` 等 Web 变体由本地托管后端提供,默认跟随随插件发布的 `lib/backend-release.json` 固定 pin(如需抢先体验新版后端,可通过更新插件或自建外部后端实现)。
58
89
 
59
- 以后启动先复用已安装的程序。**默认自动跟随官方最新稳定版**:Magpie 运行期间在后台检查更新,成功检查后缓存一小时;下载校验完成后,等待生成请求(包括流式响应)、账号登录和浏览器准备结束,再更新并重启。账号、端口、凭据和设置保留,无需等待插件发布新版。检查或下载失败时继续使用旧版;新程序启动失败时尝试回滚,并暂停重试该发行包。
90
+ > **为什么必须用无痕窗口?** Gemini Web 后端会定时刷新会话保活。若与日常浏览器共用同一登录会话,Google 会将整个会话作废,导致浏览器退出所有 Google 服务。无痕窗口(或单独 Google 小号)提供独立会话。登录完成后**直接关闭无痕窗口,不要点退出登录**(退出会使 Cookie 失效)。
60
91
 
61
- 需要自行决定版本时,运行 `npm run studio:updates -- manual`;恢复自动更新用 `npm run studio:updates -- auto`。高级路径和独立服务始终由用户管理。
92
+ 需要多账号、额度卡片刷新细节与图片生成完整指引?见下方进阶配置。
62
93
 
63
- 浏览器登录需要下载 Camoufox(v0.3.7+ 约 1.3 GB);Chrome / Cookie 导入可直接使用已有登录状态。Magpie 的单次连接等待上限为 10 分钟。网络较慢时,可先在已打开的官方账号管理页完成下载和登录;该页的后台任务不会因 Magpie 连接超时而取消,准备完成后再回到 Magpie 发起连接并选择已有账号。也可先在插件目录运行 `npm run studio:prepare-browser`,把浏览器下载放在登录计时之外;命令最多等待一小时,退出命令不会停止后端下载。连不上 GitHub 时先设置 `studio.proxy` 或 `AI_STUDIO_PROXY`。**「直接打开 Google 登录窗口」**仍可用于独立浏览器登录。已有后端若提供 Magpie 任务关联能力,仍可自动完成账号连接。
94
+ ## 多账号与额度卡片
64
95
 
65
- 自动安装支持 macOS / Linux 的 x64、arm64 和 Windows x64。macOS / Linux 使用官方 CLI 包;Windows 官方包是桌面可执行文件,默认放在数据目录根部,与 `.env` 和 `runtime/` 相邻,以保留其设置。Windows arm64 尚无官方原生包,请用高级路径选择系统可以运行的兼容程序(例如 x64 程序),或连接独立后端;插件会在查询下载前提示。
96
+ - **账号额度卡片**:单个 Google 账号以邮箱命名;AI Studio 批量导入以账号组建卡,不同组独立统计,重复导入同组不会因账号顺序变化而新增卡片。
97
+ - *旧版迁移(Gemini Web)*:若后端里已有早期版本添加的账号,在登录时选 **「添加本地后端里已有的 Google 账号」** 即可生成独立卡片,随后可删掉旧的 `API key …` 汇总卡片。
98
+ - **账号池自动调度**:请求实际使用哪个账号由本地后端决定(Gemini Web 在账号池中轮流挑选;AI Studio 先用一个,进入冷却再切下一个,可在管理页或通过 `studio.accountOrder`、`studio.modelAccounts` 指定账号优先顺序与模型专属账号池)。在 Magpie 界面切换卡片不会改变后端的账号调度。
99
+ - **用量刷新说明**:
100
+ - `gemini-web`:仅一键配置的本地后端可读取用量。Magpie 每次来查都会向 Google 重新读取(同一账号 30 秒内只读一次),点刷新即显示最新额度,包括在 Gemini 官方 App、网页或其他设备上的用量。Magpie 自己来查的频率:用量页或菜单栏的额度面板开着时约每分钟一次;菜单栏显示任何一家额度时随菜单栏更新(默认每 3 分钟);经 Magpie 转发请求时最多每分钟一次;都没有时不查。读取失败后 10 分钟内不自动重试,这期间点刷新会立即重试,若未生效再点一次。
101
+ - `ai-studio`:AI Studio 不提供剩余总额度,卡片会展示当前账号正在冷却的模型、恢复时间或重新登录提示。
102
+
103
+ ## 图片生成(AI Studio)
104
+
105
+ `ai-studio` 会列出账号可用的 Nano Banana 系列图像模型(如 `gemini-3.1-flash-image`、`gemini-3-pro-image`),供 Magpie 的图片生成使用。**需要 Magpie v0.1.2075 及以上**:从这个版本起,Magpie 才会把插件的 Gemini 图像模型列为出图模型。
106
+
107
+ **让 Agent 出图**(pi、Claude Code、Codex 等都一样):
108
+
109
+ 1. **选画图模型**:Magpie 设置的 **Images → Image generation** 会直接列出这些模型,选中一个(如 `ai-studio/gemini-nano-banana-2.1`),或保持 Automatic(自动)。不用在模型列表里勾选它们。
110
+ 2. **把画图工具交给 Agent**:点这一行下面的 **Give agents Magpie Image…**,在打开的 Library 里勾选要出图的 Agent,然后新开一个 Agent 会话。Library 被关掉时,这里显示的是 **Turn on the Library**,先点它。也可以用命令行:`magpie library mcp add magpie-image magpie mcp image agents=pi`(多个 Agent 用逗号隔开,如 `agents=pi,claude`)。
111
+ 3. **照常对话**:Agent 继续用平常的对话模型,跟它说「画一张……」就行。它会调用 `generate_image` 工具,用第 1 步选的模型出图,图片存进项目的 `generated-images/` 文件夹;带参考图就是改图。
112
+
113
+ - **别把图像模型选成对话模型**:Magpie 目前会把能出图的插件模型也留在对话模型列表里([yetone/magpie#2792](https://github.com/yetone/magpie/issues/2792))。选了也看不到图:pi 等 Agent 的回复里放不下图片,模型画出的图会被直接丢掉,模型却以为已经发出去了。它们也不支持工具调用,上下文只有 32K–128K。
114
+ - **在命令行出图**:`magpie tool generate_image "a magpie on a branch, watercolour" --size 16:9 -o magpie.png`,加 `--model ai-studio/gemini-3-pro-image` 可以临时换模型。终端里找不到 `magpie` 命令时(第 2 步的命令也一样),在 Magpie 设置的 **Command line** 一行点 **Add to PATH**,再开一个新终端。
115
+ - **尺寸**:`size` 决定宽高比:写比例(如 `16:9`、`1:4`)时,模型支持就照用,不支持就取它支持的最接近的比例;写 `1536x1024` 这样的尺寸时,Magpie 先换成最接近的常用比例。`quality` 对这些模型不起作用。
116
+ - 不需要图像模型时,可以用 `studio.imageModels` 关掉(见下方选项)。
117
+
118
+ ## 进阶配置与运维
119
+
120
+ <a id="ai-studio-自动更新代理与高级参数"></a>
121
+
122
+ <details>
123
+ <summary><b>⚙️ AI Studio 自动更新、代理与高级参数</b>(安装升级、浏览器准备、CLI 命令表)</summary>
124
+
125
+ <br>
126
+
127
+ **自动安装与更新:**
128
+ - 首次使用时,插件自动下载、校验并启动官方 AIStudio2API 最新稳定版,无需手动下载程序、填写路径、复制 API key 或设置管理员密码。
129
+ - **默认自动跟随官方最新稳定版**:Magpie 运行期间在后台检查更新,成功检查后缓存一小时;下载校验完成后,等待生成请求(包括流式响应)、账号登录和浏览器准备结束,再更新并重启。账号、端口、凭据和设置保留,无需等待插件发布新版。检查或下载失败时继续使用旧版;新程序启动失败时尝试回滚,并暂停重试该发行包。
130
+ - 需要自行决定版本时,运行 `npm run studio:updates -- manual`;恢复自动更新用 `npm run studio:updates -- auto`。高级路径和独立服务始终由用户管理。
131
+ - 浏览器登录需要下载 Camoufox(v0.3.7+ 约 1.3 GB);Chrome / Cookie 导入可直接使用已有登录状态。Magpie 的单次连接等待上限为 10 分钟。网络较慢时,可先在已打开的官方账号管理页完成下载和登录;该页的后台任务不会因 Magpie 连接超时而取消,准备完成后再回到 Magpie 发起连接并选择已有账号。也可先在插件目录运行 `npm run studio:prepare-browser`,把浏览器下载放在登录计时之外;命令最多等待一小时,退出命令不会停止后端下载。连不上 GitHub 时先设置 `studio.proxy` 或 `AI_STUDIO_PROXY`。**「直接打开 Google 登录窗口」**仍可用于独立浏览器登录。已有后端若提供 Magpie 任务关联能力,仍可自动完成账号连接。
132
+ - 自动安装支持 macOS / Linux 的 x64、arm64 和 Windows x64。macOS / Linux 使用官方 CLI 包;Windows 官方包是桌面可执行文件,默认放在数据目录根部,与 `.env` 和 `runtime/` 相邻,以保留其设置。Windows arm64 尚无官方原生包,请用高级路径选择系统可以运行的兼容程序(例如 x64 程序),或连接独立后端;插件会在查询下载前提示。
66
133
 
67
134
  **已有安装与版本选择:**
68
135
 
@@ -80,58 +147,90 @@
80
147
  - 新安装沿用官方默认值。v0.3.7+ 默认开启搜索模型别名、每账号并发为 2、预热 10/最大 20 个 Worker、使用 round-robin;生成后端当前默认为 SpiderMonkey。以后选用的版本若改变 `WAA_BACKEND` 默认值,生成也可能需要 Camoufox 等浏览器组件;可在管理页明确指定设置。
81
148
  - 插件维护本地连接和账号访问,其余设置由后端管理页控制,包括新版新增的配置项。卸载或 `studio:clean` 会清理默认目录中下载的程序、保留账号与配置;选择自备路径时会保留该进程、程序和整个数据目录,停止请使用 `studio:stop`。
82
149
 
83
- 如果希望独立运行服务,也可选 **「连接已有 AIStudio2API(地址 + API key)」**。连接官方 v0.3.7+ 时,Hydrogen Extra High 会映射为 Magpie 的 `xhigh` 档位。
84
-
85
- ### 方式二:Gemini Web (`gemini-web`)
150
+ **连接独立服务:** 如果希望独立运行服务,也可选 **「连接已有 AIStudio2API(地址 + API key)」**。连接官方 v0.3.7+ 时,Hydrogen Extra High 会映射为 Magpie 的 `xhigh` 档位。
86
151
 
87
- 1. 在 Magpie 中登录 **Gemini Web**,选择 **「一键配置本地 Gemini Web(推荐)」**(若访问 Google 需要代理,可在第一步提示中直接填写代理地址,例如 `http://127.0.0.1:7890`,无需代理或已配置代理池可留空,也可稍后在本机登录向导页填写或修改)。
88
- 2. Magpie 打开**本机登录向导页**(`127.0.0.1` 随机端口 + 随机路径,仅本机可访问),按页面三步走:
89
- 1. 点 **「打开无痕窗口登录 Gemini」**,插件会以无痕 / 隐私模式自动启动检测到的浏览器(优先 Firefox,其次 Chrome / Brave / Chromium / Edge);找不到已知浏览器时页面给出链接,请手动开无痕窗口访问 <https://gemini.google.com/app> 登录 Google 账号;
90
- 2. 按 `F12`(macOS 按 `⌥⌘I`)切到 **Network(网络)**,刷新页面,点击任意 `gemini.google.com` 请求 → **Headers** → **Request Headers**,复制 `cookie` 的值粘贴回向导页;
91
- 3. 在同一表单填写 **Google 账号索引**(对照无痕窗口登录后地址栏 `/u/N/app` 的 `N`,单账号留空按 `0`)与可选的**代理地址**,点 **「验证并完成登录」**。校验失败会直接在页内显示原因,可原地修改后重试,无需取消重来。
92
- 3. 页面显示绑定邮箱后即完成登录,此时**直接关闭无痕窗口,不要点退出登录**(点退出会使 Cookie 失效)。想添加更多账号,重复上述步骤即可。
152
+ **本地服务什么时候启动、停止:**
153
+ - 插件加载时(例如打开 Magpie)会在后台启动本地服务;之后发请求、刷新额度卡片时,服务没在运行也会自动启动。
154
+ - 本地服务是独立进程,**退出 Magpie 不会停止它**,下次打开 Magpie 直接接着用。
155
+ - 停止服务用下表的 `studio:stop`(或报错里给出的完整命令)。停止只是一次性的:下一次请求会再次启动它。
93
156
 
94
- > **升级后提示后端不支持登录时绑定代理?** 旧后台进程可能仍在运行。请按提示先退出 Magpie,停止对应的 `gemini-web2api-go` 进程(Windows:任务管理器 → 详细信息 → `gemini-web2api-go.exe`),再运行提示中的完整安装命令。它会保留账号和配置,并切换到插件的托管后端;如下载需要代理,先设置 `GEMINI_WEB_PROXY`。完成后重新打开 Magpie 登录。
157
+ 当插件报错提示运行命令时,直接复制报错中的完整命令执行即可。在插件目录下也可使用:
95
158
 
96
- > **为什么必须用无痕窗口?** 后端会定时刷新会话来保活。若与日常浏览器共用同一登录会话,Google 会将整个会话作废,导致你的浏览器退出所有 Google 服务。使用无痕窗口(或单独准备 Google 小号)可提供独立会话。
159
+ | 命令 | 作用 |
160
+ | :--- | :--- |
161
+ | `npm run studio:status` | 查看本地服务与账号状态 |
162
+ | `npm run studio:start` / `studio:stop` | 启动 / 停止本地服务 |
163
+ | `npm run studio:clean` | 清理默认目录下载的后端与 Camoufox,保留账号和配置;自备路径跳过清理 |
164
+ | `npm run studio:use -- <程序路径>` | 选择自备 AIStudio2API,可使用官方或自定义版本;切换前须停止服务 |
165
+ | `npm run studio:use-default` | 切回默认安装目录;已有程序继续复用,缺失时自动安装官方版 |
166
+ | `npm run studio:login` | 添加 Google 账号 |
167
+ | `npm run studio:prepare-browser` | 先下载登录浏览器,准备完成后再在 Magpie 发起登录;关闭命令不会取消后台下载 |
168
+ | `npm run studio:relogin -- [<账号>]` | 重新登录过期账号(仅一个账号时可省略参数) |
169
+ | `npm run studio:install -- [--version v0.3.7]` | 停止服务后安装官方最新版或指定版本,保留账号与配置 |
170
+ | `npm run studio:install -- --version v0.3.7 --archive <文件>` | 从本地官方包安装,仍从 GitHub 查询该版本的校验值 |
171
+ | `npm run studio:official:smoke` | 在临时目录验证官方安装、账号目录、连接及运行中替换,不使用真实 Google 凭据 |
172
+ | `npm run studio:updates -- auto` / `manual` | 开启或关闭默认官方后端的自动更新;不带参数查看策略 |
173
+ | `npm run studio:auto-update:smoke` | 在临时目录验证后台自动升级、保留数据和启动失败后的程序回滚 |
174
+ | `npm run studio:update:smoke -- v0.3.6` | 在临时目录将旧官方版实际在线升级到最新版,验证进程与重启 |
175
+ | `node scripts/studio.mjs import <目录>` | 在服务停止状态下导入已有账号 |
176
+ | `npm run studio:smoke` | 发起真实请求验收(会消耗账号额度) |
97
177
 
98
- ---
178
+ **AI Studio 升级与模型范围:**
179
+ - 安装和自动更新来自官方最新稳定版,支持 macOS / Linux x64、arm64 与 Windows x64。读取官方发布元数据,只接受对应平台的安装包及 SHA-256;插件发布不依赖定制后端构建或固定发行哈希。
180
+ - 连接 0.3.7+ 时,`MAX_ACCOUNT_SWITCHES`、`DISCOVER_HIDDEN_MODELS`、账号顺序、模型账号绑定及其他合法 `.env` 键会保留。已有显式设置继续生效,未设置项使用后端默认值;插件不再补入固定的并发、备用请求或生成后端设置。
181
+ - 默认程序为数据目录中的 `package/aistudio2api`,Windows 为根部的 `aistudio2api.exe`。旧托管构建的账号和数据继续保留,自动更新可将其替换为官方包。历史构建和 0.3.7 候选补丁保留在 [docs/studio-release.md](docs/studio-release.md),不参与默认安装和更新决策。
182
+ - 停止时会发现更新后的 PID 并核对程序身份;自备路径还核对账号目录参数,以区分共用同一程序的实例。无法核实身份就不会发送终止信号;HTTP 已关闭但仍有进程运行时,禁止安装替换或重复启动。
183
+ - 默认目录缺少程序时自动安装;已有程序在后台按空闲状态更新。自备路径缺失时明确报错。程序回滚不会撤销后端自身的数据迁移;手动降级前应备份整个数据目录,包括 `auth/`、`runtime/requests.db` 等。
184
+ - 插件默认单次响应等待/流空闲超时为 30 分钟,可用 `studio.requestTimeoutMs` 调整;后端的请求期限与并发数由其默认值或管理页设置决定。较短期限可能中断长回复,上游自动续写期限按所选版本的规则计算。
185
+ - 支持 `gemini-4-hydrogen` 与 `gemini-4-carbon`(随官方 v0.3.5–v0.3.8+ 模型目录自动同步):`gemini-4-hydrogen` 的 `extra_high` 思考档位自动映射为 Magpie 的 `xhigh`;`gemini-4-carbon` 需要已登录账号具备对应权益(如 Google AI Ultra)才会在目录中列出可用通道,无权账号会自动隐藏以避免返回 403(若官网前端已配置但尚未对账号公开列出,可在管理页开启 `DISCOVER_HIDDEN_MODELS`)。
186
+ - 支持 Deep Research 模型(`deep-research-preview-04-2026`、`deep-research-max-preview-04-2026`):需要登录 Google AI Pro / Ultra 账号才会在列表中出现;由后端将异步 Interactions 任务适配到 `/v1/chat/completions` 流式返回(含思考过程与服务端内置联网搜索),不支持客户端 `tool_call`(Function Calling)或 `temperature`。
187
+ - 模型列表过滤 `-build` / `assistant_route` 模型:这类模型附带 Build 写代码助手的系统提示词,不作为普通 Agent 模型提供。升级后可执行 `magpie provider models ai-studio` 刷新列表。
99
188
 
100
- ## 多账号与额度卡片
189
+ </details>
101
190
 
102
- - **账号额度卡片**:单个 Google 账号以邮箱命名;AI Studio 批量导入以账号组建卡,不同组独立统计,重复导入同组不会因账号顺序变化而新增卡片。
103
- - *旧版迁移(Gemini Web)*:若后端里已有早期版本添加的账号,在登录时选 **「添加本地后端里已有的 Google 账号」** 即可生成独立卡片,随后可删掉旧的 `API key …` 汇总卡片。
104
- - **账号池自动调度**:请求实际使用哪个账号由本地后端决定(Gemini Web 在账号池中轮流挑选;AI Studio 先用一个,进入冷却再切下一个,可在管理页或通过 `studio.accountOrder`、`studio.modelAccounts` 指定账号优先顺序与模型专属账号池)。在 Magpie 界面切换卡片不会改变后端的账号调度。
105
- - **用量刷新说明**:
106
- - `gemini-web`:仅一键配置的本地后端可读取用量。Magpie 每次来查都会向 Google 重新读取(同一账号 30 秒内只读一次),点刷新即显示最新额度,包括在 Gemini 官方 App、网页或其他设备上的用量。Magpie 自己来查的频率:用量页或菜单栏的额度面板开着时约每分钟一次;菜单栏显示任何一家额度时随菜单栏更新(默认每 3 分钟);经 Magpie 转发请求时最多每分钟一次;都没有时不查。读取失败后 10 分钟内不自动重试,这期间点刷新会立即重试,若未生效再点一次。
107
- - `ai-studio`:AI Studio 不提供剩余总额度,卡片会展示当前账号正在冷却的模型、恢复时间或重新登录提示。
191
+ <a id="旧包无损迁移与回滚上游后端"></a>
108
192
 
109
- ---
193
+ <details>
194
+ <summary><b>📦 旧包无损迁移与回滚上游后端</b>(无作用域包迁移、zexadev 回滚通道)</summary>
110
195
 
111
- ## 图片生成(AI Studio)
196
+ <br>
112
197
 
113
- `ai-studio` 会列出账号可用的 Nano Banana 系列图像模型(如 `gemini-3.1-flash-image`、`gemini-3-pro-image`),供 Magpie 的图片生成使用。**需要 Magpie v0.1.2075 及以上**:从这个版本起,Magpie 才会把插件的 Gemini 图像模型列为出图模型。
198
+ **从旧包迁移:** `0.15.0` 起 npm 包名为作用域包 `@dorokuma/magpie-gemini-web`(此前为无作用域包 `magpie-gemini-web`)。已装旧包的用户请在 Magpie 插件市场卸载旧的 `magpie-gemini-web` 后重新安装新包;本地数据目录 `~/.local/share/magpie-gemini-web`、已保存的 Google 账号、Cookie、数据库和凭据全部保留,无需重新登录或导 Cookie。迁移期卸载清理同时识别新旧两个包名,不会把新插件误判为已卸载。
114
199
 
115
- **让 Agent 出图**(pi、Claude Code、Codex 等都一样):
200
+ **Gemini Web 登录故障排查:**
201
+ - **升级后提示后端不支持登录时绑定代理?** 旧后台进程可能仍在运行。请按提示先退出 Magpie,停止对应的 `gemini-web2api-go` 进程(Windows:任务管理器 → 详细信息 → `gemini-web2api-go.exe`),再运行提示中的完整安装命令。它会保留账号和配置,并切换到插件的托管后端;如下载需要代理,先设置 `GEMINI_WEB_PROXY`。完成后重新打开 Magpie 登录。
202
+ - [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) 的多账号索引漏传已修复,需重新导入受影响的 Cookie 或在后端账号管理中修正索引。后端已原生收录 `gemini-4-carbon`、`gemini-4-hydrogen` 与 `gemini-4-neon` 模型 ID(含 `-thinking` 思考变体,Neon 系列为服务端内部思考、不输出 `reasoning_content`),同时移除了 Gemini Web 对外 `gemini-4-argon*`(原 Argon 槽位在上游目录中原位改名为 4 Carbon,谷歌已下架 Argon,请改用 `gemini-4-carbon*` 或 `gemini-4-neon*`);`strict_model` 槽位校验按显示名家族互认升级/降级,付费账号请求 `gemini-3.8-flash` 被路由至 `4 Hydrogen` 时也能正确识别,不会误报 `429 model_downgraded`。
203
+ - 插件默认固定使用后端仓 [`dorokuma/gemini-web2api-go` Releases](https://github.com/dorokuma/gemini-web2api-go/releases) 发布的预编译二进制(一仓一制品,6 平台 SHA-256 pin 在 `lib/backend-release.json`,不再由插件仓打补丁重编)。对话请求按上游沉默计时:Google 让请求排队时每 60 秒发一次心跳,后端会一直等到出字;连续 `request_timeout_sec`(默认 180 秒)没有任何数据才放弃这一次并重试,还在出字的长回复也不会被截断。
204
+ - **旧版升级**:插件加载时若识别到托管的旧版后端进程,会自动回收并升级到 `lib/backend-release.json` 当前 pin 的版本,这可能中断正在进行的生成请求;建议升级前先等待在途请求结束,或手动停止旧进程(PID 见数据目录 `backend.pid`)。非插件托管或无法识别的实例不保证自动更新。升级后保留原有配置与账号。
205
+ - **回退官方上游版 / 恢复 pin 版**(停止后端后在插件目录执行):
116
206
 
117
- 1. **选画图模型**:Magpie 设置的 **Images → Image generation** 会直接列出这些模型,选中一个(如 `ai-studio/gemini-nano-banana-2.1`),或保持 Automatic(自动)。不用在模型列表里勾选它们。
118
- 2. **把画图工具交给 Agent**:点这一行下面的 **Give agents Magpie Image…**,在打开的 Library 里勾选要出图的 Agent,然后新开一个 Agent 会话。Library 被关掉时,这里显示的是 **Turn on the Library**,先点它。也可以用命令行:`magpie library mcp add magpie-image magpie mcp image agents=pi`(多个 Agent 用逗号隔开,如 `agents=pi,claude`)。
119
- 3. **照常对话**:Agent 继续用平常的对话模型,跟它说「画一张……」就行。它会调用 `generate_image` 工具,用第 1 步选的模型出图,图片存进项目的 `generated-images/` 文件夹;带参考图就是改图。
207
+ ```bash
208
+ npm run backend:install:upstream # 回退并固定使用上游 zexadev v4.28.0
209
+ npm run backend:install # 恢复默认 pin 版本(见 lib/backend-release.json)
210
+ ```
120
211
 
121
- - **别把图像模型选成对话模型**:Magpie 目前会把能出图的插件模型也留在对话模型列表里([yetone/magpie#2792](https://github.com/yetone/magpie/issues/2792))。选了也看不到图:pi 等 Agent 的回复里放不下图片,模型画出的图会被直接丢掉,模型却以为已经发出去了。它们也不支持工具调用,上下文只有 32K–128K。
122
- - **在命令行出图**:`magpie tool generate_image "a magpie on a branch, watercolour" --size 16:9 -o magpie.png`,加 `--model ai-studio/gemini-3-pro-image` 可以临时换模型。终端里找不到 `magpie` 命令时(第 2 步的命令也一样),在 Magpie 设置的 **Command line** 一行点 **Add to PATH**,再开一个新终端。
123
- - **尺寸**:`size` 决定宽高比:写比例(如 `16:9`、`1:4`)时,模型支持就照用,不支持就取它支持的最接近的比例;写 `1536x1024` 这样的尺寸时,Magpie 先换成最接近的常用比例。`quality` 对这些模型不起作用。
124
- - 不需要图像模型时,可以用 `studio.imageModels` 关掉(见下方选项)。
212
+ - pin 同步、校验与冒烟流程见 [docs/backend-release.md](docs/backend-release.md)。
125
213
 
126
- ---
214
+ </details>
127
215
 
128
- ## 配置与进阶
216
+ <a id="安全隐私本机数据目录与排障"></a>
129
217
 
130
218
  <details>
131
- <summary><b>⚙️ 插件选项与代理配置</b>(开启图片输入、设置代理、连接自建后端)</summary>
219
+ <summary><b>🔒 安全隐私、本机数据目录与排障</b>(插件选项、代理、日志与清理)</summary>
132
220
 
133
221
  <br>
134
222
 
223
+ **安全与数据目录:**
224
+ - 两个后端均只监听 `127.0.0.1`,Cookie 与登录态仅保存在本机,Magpie 仅保存本地生成的随机 API Key。
225
+ - **Gemini Web 数据目录**:`~/.local/share/magpie-gemini-web`(可通过 `GEMINI_WEB_DATA_DIR` 修改),日志位于 `backend.log`。支持 macOS、Linux、Windows(x64 / arm64)。
226
+ - **AI Studio 数据目录**:`~/.local/share/magpie-ai-studio`(可通过 `AI_STUDIO_DATA_DIR` 修改),日志位于 `backend.log`(超 10 MB 下次启动自动轮转)。默认使用 2048 端口,被占用时自动顺延并记录在 `config.json`。支持 macOS、Linux(x64 / arm64)与 Windows x64。
227
+ - **卸载与清理下载资产**:在 Magpie 中删除插件(或运行 `npm run studio:clean`、`npm run backend:clean`)会停止插件托管的本地服务并删除其已下载二进制及安装包。**自备 AIStudio2API 模式会保留该后端进程、程序及整个数据目录**,由用户自行停止和清理。
228
+ - 清理会保留 `auth/`、`gemini.db`、`config.json`、`.env` 与 `secrets.json`,以便重装插件或下次发起请求时自动按需重装后端、免去重新登录或导 Cookie;若要彻底停用自动重装,请在 Magpie 中删除对应登录卡片或一并删除数据目录中的配置文件。
229
+ - 默认数据目录按当前系统用户共享;若在同一账号下隔离运行多个 Magpie 配置目录,请分别设置 `AI_STUDIO_DATA_DIR` 与 `GEMINI_WEB_DATA_DIR`,避免卸载其一时清理共享资产。
230
+ - Gemini Web 每个登录同时最多 2 个请求(AI Studio 为 1),可在 Magpie 的 provider 设置里调整。这是 Magpie 每张卡片的并发限制,后端 Worker 数由上述迁移规则或管理页设置决定;仍无法完全排除 Google 账号风控风险,请自行评估使用。
231
+
232
+ **插件选项与代理配置:**
233
+
135
234
  工具调用与图片输入默认开启。可通过命令行修改插件配置:
136
235
 
137
236
  ```bash
@@ -184,78 +283,6 @@ magpie plugin options @dorokuma/magpie-gemini-web '{"studio":{"proxy":"http://12
184
283
 
185
284
  </details>
186
285
 
187
- <details>
188
- <summary><b>🛠️ AI Studio 命令行工具</b>(查看状态、预下载浏览器、版本管理)</summary>
189
-
190
- <br>
191
-
192
- **本地服务什么时候启动、停止:**
193
- - 插件加载时(例如打开 Magpie)会在后台启动本地服务;之后发请求、刷新额度卡片时,服务没在运行也会自动启动。
194
- - 本地服务是独立进程,**退出 Magpie 不会停止它**,下次打开 Magpie 直接接着用。
195
- - 停止服务用下表的 `studio:stop`(或报错里给出的完整命令)。停止只是一次性的:下一次请求会再次启动它。
196
-
197
- 当插件报错提示运行命令时,直接复制报错中的完整命令执行即可。在插件目录下也可使用:
198
-
199
- | 命令 | 作用 |
200
- | :--- | :--- |
201
- | `npm run studio:status` | 查看本地服务与账号状态 |
202
- | `npm run studio:start` / `studio:stop` | 启动 / 停止本地服务 |
203
- | `npm run studio:clean` | 清理默认目录下载的后端与 Camoufox,保留账号和配置;自备路径跳过清理 |
204
- | `npm run studio:use -- <程序路径>` | 选择自备 AIStudio2API,可使用官方或自定义版本;切换前须停止服务 |
205
- | `npm run studio:use-default` | 切回默认安装目录;已有程序继续复用,缺失时自动安装官方版 |
206
- | `npm run studio:login` | 添加 Google 账号 |
207
- | `npm run studio:prepare-browser` | 先下载登录浏览器,准备完成后再在 Magpie 发起登录;关闭命令不会取消后台下载 |
208
- | `npm run studio:relogin -- [<账号>]` | 重新登录过期账号(仅一个账号时可省略参数) |
209
- | `npm run studio:install -- [--version v0.3.7]` | 停止服务后安装官方最新版或指定版本,保留账号与配置 |
210
- | `npm run studio:install -- --version v0.3.7 --archive <文件>` | 从本地官方包安装,仍从 GitHub 查询该版本的校验值 |
211
- | `npm run studio:official:smoke` | 在临时目录验证官方安装、账号目录、连接及运行中替换,不使用真实 Google 凭据 |
212
- | `npm run studio:updates -- auto` / `manual` | 开启或关闭默认官方后端的自动更新;不带参数查看策略 |
213
- | `npm run studio:auto-update:smoke` | 在临时目录验证后台自动升级、保留数据和启动失败后的程序回滚 |
214
- | `npm run studio:update:smoke -- v0.3.6` | 在临时目录将旧官方版实际在线升级到最新版,验证进程与重启 |
215
- | `node scripts/studio.mjs import <目录>` | 在服务停止状态下导入已有账号 |
216
- | `npm run studio:smoke` | 发起真实请求验收(会消耗账号额度) |
217
-
218
- </details>
219
-
220
- <details>
221
- <summary><b>🔒 安全、数据目录与后端版本管理</b>(日志位置、升级与回退)</summary>
222
-
223
- <br>
224
-
225
- **安全与数据目录:**
226
- - 两个后端均只监听 `127.0.0.1`,Cookie 与登录态仅保存在本机,Magpie 仅保存本地生成的随机 API Key。
227
- - **Gemini Web 数据目录**:`~/.local/share/magpie-gemini-web`(可通过 `GEMINI_WEB_DATA_DIR` 修改),日志位于 `backend.log`。支持 macOS、Linux、Windows(x64 / arm64)。
228
- - **AI Studio 数据目录**:`~/.local/share/magpie-ai-studio`(可通过 `AI_STUDIO_DATA_DIR` 修改),日志位于 `backend.log`(超 10 MB 下次启动自动轮转)。默认使用 2048 端口,被占用时自动顺延并记录在 `config.json`。支持 macOS、Linux(x64 / arm64)与 Windows x64。
229
- - **卸载与清理下载资产**:在 Magpie 中删除插件(或运行 `npm run studio:clean`、`npm run backend:clean`)会停止插件托管的本地服务并删除其已下载二进制及安装包。**自备 AIStudio2API 模式会保留该后端进程、程序及整个数据目录**,由用户自行停止和清理。
230
- - 清理会保留 `auth/`、`gemini.db`、`config.json`、`.env` 与 `secrets.json`,以便重装插件或下次发起请求时自动按需重装后端、免去重新登录或导 Cookie;若要彻底停用自动重装,请在 Magpie 中删除对应登录卡片或一并删除数据目录中的配置文件。
231
- - 默认数据目录按当前系统用户共享;若在同一账号下隔离运行多个 Magpie 配置目录,请分别设置 `AI_STUDIO_DATA_DIR` 与 `GEMINI_WEB_DATA_DIR`,避免卸载其一时清理共享资产。
232
- - Gemini Web 每个登录同时最多 2 个请求(AI Studio 为 1),可在 Magpie 的 provider 设置里调整。这是 Magpie 每张卡片的并发限制,后端 Worker 数由上述迁移规则或管理页设置决定;仍无法完全排除 Google 账号风控风险,请自行评估使用。
233
-
234
- **AI Studio 升级与模型范围:**
235
- - 安装和自动更新来自官方最新稳定版,支持 macOS / Linux x64、arm64 与 Windows x64。读取官方发布元数据,只接受对应平台的安装包及 SHA-256;插件发布不依赖定制后端构建或固定发行哈希。
236
- - 连接 0.3.7+ 时,`MAX_ACCOUNT_SWITCHES`、`DISCOVER_HIDDEN_MODELS`、账号顺序、模型账号绑定及其他合法 `.env` 键会保留。已有显式设置继续生效,未设置项使用后端默认值;插件不再补入固定的并发、备用请求或生成后端设置。
237
- - 默认程序为数据目录中的 `package/aistudio2api`,Windows 为根部的 `aistudio2api.exe`。旧托管构建的账号和数据继续保留,自动更新可将其替换为官方包。历史构建和 0.3.7 候选补丁保留在 [docs/studio-release.md](docs/studio-release.md),不参与默认安装和更新决策。
238
- - 停止时会发现更新后的 PID 并核对程序身份;自备路径还核对账号目录参数,以区分共用同一程序的实例。无法核实身份就不会发送终止信号;HTTP 已关闭但仍有进程运行时,禁止安装替换或重复启动。
239
- - 默认目录缺少程序时自动安装;已有程序在后台按空闲状态更新。自备路径缺失时明确报错。程序回滚不会撤销后端自身的数据迁移;手动降级前应备份整个数据目录,包括 `auth/`、`runtime/requests.db` 等。
240
- - 插件默认单次响应等待/流空闲超时为 30 分钟,可用 `studio.requestTimeoutMs` 调整;后端的请求期限与并发数由其默认值或管理页设置决定。较短期限可能中断长回复,上游自动续写期限按所选版本的规则计算。
241
- - 已核对本机 Magpie `v0.1.1285`(`d783df46`)源码:插件请求走 `Provider.Do → plugin.Fetch → loader.fetch`,绕过普通 HTTP transport 的 10 分钟响应头限制;此插件生成路径没有发现更短的固定总超时。网关 5 分钟 `IdleTimeout` 仅针对请求之间的空闲连接。客户端或反向代理仍可设置更短期限;这不是一次实等 30 分钟的端到端验证。
242
- - 支持 `gemini-4-hydrogen` 与 `gemini-4-carbon`(随官方 v0.3.5–v0.3.8+ 模型目录自动同步):`gemini-4-hydrogen` 的 `extra_high` 思考档位自动映射为 Magpie 的 `xhigh`;`gemini-4-carbon` 需要已登录账号具备对应权益(如 Google AI Ultra)才会在目录中列出可用通道,无权账号会自动隐藏以避免返回 403(若官网前端已配置但尚未对账号公开列出,可在管理页开启 `DISCOVER_HIDDEN_MODELS`)。
243
- - 支持 Deep Research 模型(`deep-research-preview-04-2026`、`deep-research-max-preview-04-2026`):需要登录 Google AI Pro / Ultra 账号才会在列表中出现;由后端将异步 Interactions 任务适配到 `/v1/chat/completions` 流式返回(含思考过程与服务端内置联网搜索),不支持客户端 `tool_call`(Function Calling)或 `temperature`。
244
- - 模型列表过滤 `-build` / `assistant_route` 模型:这类模型附带 Build 写代码助手的系统提示词,不作为普通 Agent 模型提供。升级后可执行 `magpie provider models ai-studio` 刷新列表。
245
-
246
- **Gemini Web 优化后端升级与回退:**
247
- - [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) 的多账号索引漏传已修复,需重新导入受影响的 Cookie 或在后端账号管理中修正索引。后端 [`dorokuma/gemini-web2api-go` `v6.3.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0) 已原生收录 `gemini-4-carbon`、`gemini-4-hydrogen` 与 `gemini-4-neon` 模型 ID(含 `-thinking` 思考变体,Neon 系列为服务端内部思考、不输出 `reasoning_content`),同时移除了 Gemini Web 对外 `gemini-4-argon*`(原 Argon 槽位在上游目录中原位改名为 4 Carbon,谷歌已下架 Argon,请改用 `gemini-4-carbon*` 或 `gemini-4-neon*`);`strict_model` 槽位校验按显示名家族互认升级/降级,付费账号请求 `gemini-3.8-flash` 被路由至 `4 Hydrogen` 时也能正确识别,不会误报 `429 model_downgraded`。
248
- - 插件默认固定使用后端仓发布的 [v6.3.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.3.0) 预编译二进制(一仓一制品,6 平台 SHA-256 pin 在 `lib/backend-release.json`,不再由插件仓打补丁重编)。对话请求按上游沉默计时:Google 让请求排队时每 60 秒发一次心跳,后端会一直等到出字;连续 `request_timeout_sec`(默认 180 秒)没有任何数据才放弃这一次并重试,还在出字的长回复也不会被截断。
249
- - **旧版升级**:插件加载时若识别到托管的旧版后端进程,会自动回收并升级到当前 pin 的 `v6.3.0`,这可能中断正在进行的生成请求;建议升级前先等待在途请求结束,或手动停止旧进程(PID 见数据目录 `backend.pid`)。非插件托管或无法识别的实例不保证自动更新。升级后保留原有配置与账号。
250
- - **回退官方上游版 / 恢复 pin 版**(停止后端后在插件目录执行):
251
- ```bash
252
- npm run backend:install:upstream # 回退并固定使用上游 zexadev v4.28.0
253
- npm run backend:install # 恢复默认 pin 的 v6.3.0
254
- ```
255
- - pin 同步、校验与冒烟流程见 [docs/backend-release.md](docs/backend-release.md)。
256
-
257
- </details>
258
-
259
286
  ---
260
287
 
261
288
  ## 友链
@@ -1,31 +1,31 @@
1
1
  {
2
- "version": "6.3.0",
2
+ "version": "6.4.0",
3
3
  "repository": "dorokuma/gemini-web2api-go",
4
- "tag": "v6.3.0",
4
+ "tag": "v6.4.0",
5
5
  "binaries": {
6
6
  "darwin-x64": {
7
- "asset": "gemini-web2api-go_v6.3.0_darwin_amd64",
8
- "sha256": "5513bdecfa7a04be247fe9d0ff61b770f4b11ce9c9f6ff4faa156bc70b5e6c95"
7
+ "asset": "gemini-web2api-go_v6.4.0_darwin_amd64",
8
+ "sha256": "06c6a17a61da72ff53a93f892f8595cc90f1d999f05d8bcd464a7c22744accf7"
9
9
  },
10
10
  "darwin-arm64": {
11
- "asset": "gemini-web2api-go_v6.3.0_darwin_arm64",
12
- "sha256": "a32bc1b901d00ee1d4d2c538aa9a4607a9f183fcfb345937fb342b0591c69781"
11
+ "asset": "gemini-web2api-go_v6.4.0_darwin_arm64",
12
+ "sha256": "77d96556224b1c8a0586a50594ab575e74052203ad716c9065d57ef750c4f5e1"
13
13
  },
14
14
  "linux-x64": {
15
- "asset": "gemini-web2api-go_v6.3.0_linux_amd64",
16
- "sha256": "31eee309aa4755889be47586714a35b0ad21a60e134fe59ce96810e736462eaa"
15
+ "asset": "gemini-web2api-go_v6.4.0_linux_amd64",
16
+ "sha256": "3c4aebe0de6911556778e3459889bede34d7f844c57355677b89ca729cacde51"
17
17
  },
18
18
  "linux-arm64": {
19
- "asset": "gemini-web2api-go_v6.3.0_linux_arm64",
20
- "sha256": "ed3f1564083a60e89c77f0aea204199debac984075c0c9c03904af60ebbd4874"
19
+ "asset": "gemini-web2api-go_v6.4.0_linux_arm64",
20
+ "sha256": "3645a1033323fdabb9b99973f9d18f462808bf91005bc4ff5885f01e5e78cfb1"
21
21
  },
22
22
  "win32-x64": {
23
- "asset": "gemini-web2api-go_v6.3.0_windows_amd64.exe",
24
- "sha256": "38505c7fc4d4cfb4873be0e3bbedd5a533f625bec94eb7f0c69825b2731abc5f"
23
+ "asset": "gemini-web2api-go_v6.4.0_windows_amd64.exe",
24
+ "sha256": "c4bc753cb465c7169a568ea85c30a1bcf24124eebf66fb2978a43b53b145fe6b"
25
25
  },
26
26
  "win32-arm64": {
27
- "asset": "gemini-web2api-go_v6.3.0_windows_arm64.exe",
28
- "sha256": "fc5fc1819b7e76fe7deb0c2ecd2ef1815ddaabaa257f56b859812badff19cf84"
27
+ "asset": "gemini-web2api-go_v6.4.0_windows_arm64.exe",
28
+ "sha256": "1f08bdf709fd4540508d2bc1dbf964fe62e8a0844954c0bf459419cea61324c0"
29
29
  }
30
30
  }
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorokuma/magpie-gemini-web",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Google AI Studio and Gemini Web provider for Magpie (Gemini 4 Neon / Carbon / Hydrogen in Chat & Task modes, Nano Banana image generation, Deep Research), backed by AIStudio2API and gemini-web2api-go",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",