@dorokuma/magpie-gemini-web 0.15.2 → 0.16.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,25 @@
2
2
 
3
3
  本文件按版本倒序记录 `magpie-gemini-web`(0.15.0 起为 `@dorokuma/magpie-gemini-web`)的全部已发布与待发变更,依据本仓 `git log` 与 tag 事实编写。
4
4
 
5
+ ## 0.16.0
6
+
7
+ ### 破坏性变更
8
+ - Gemini Web 后端 pin 升级至 **`dorokuma/gemini-web2api-go` `v6.0.0`** 官方预编译二进制:上游模型目录将原 Argon 的 Mode=8 槽位原位改名为 4 Carbon,**对外 `gemini-4-argon` / `gemini-4-argon-thinking` / `gemini-4-argon-thinking-medium` 三条模型已移除**,请求这些模型名不再被识别。请改用 `gemini-4-carbon*` 或新增的 `gemini-4-neon*`(Argon↔Carbon 的 `strict_model` 同槽互认逻辑保留)。
9
+
10
+ ### 新增
11
+ - **Gemini 4 Neon 模型接入**:Gemini Web 新增 `gemini-4-neon` / `gemini-4-neon-thinking` / `gemini-4-neon-thinking-medium` 三条对外模型(付费号专属,免费号静默降级);Neon 为服务端内部思考模型,回复不输出 `reasoning_content`。
12
+ - `strict_model` 同槽升级豁免降级冷却:请求 `4 Neon Medium` 收到 `4 Neon High` 自报属同槽单向升级,不再误判降级并冷却账号。
13
+
14
+ ### 文档
15
+ - README(中英)与 `package.json` description 更新 Gemini Web 侧模型清单为 Gemini 4 Carbon / Hydrogen / Neon,注明 Neon 服务端内部思考不输出 `reasoning_content`;AI Studio 侧原有模型说明(含 `gemini-4-argon`)不变。
16
+
17
+ ## 0.15.3
18
+
19
+ ### 修复
20
+ - 后端版本感知自愈:`ensureBackend` 收养在跑后端前比对后端自报版本(`GET /` 的 `version`)与盘上二进制期望版本(pin 版本、`argon-build.json` 记录的本地构建版本)。**插件升级现在真正换后端**:旧版只查健康就收养活进程,npm 更新后老后端只要不死就永远顶替新版运行。
21
+ - 陈旧后端正确回收:版本不匹配或盘上二进制不可信时,按「监听端口 + 进程映像归属本数据目录(exe/--config/--db 任一路径落在 dataDir 内)」精确识别并终止旧进程(Linux 走 `/proc`,macOS 走 `ps`,Windows 无此场景),再安装/拉起 pin 版本;同名端口但归属其它数据目录的进程、以及无法识别的占用一律不动。
22
+ - 修复两处静默假成功:旧逻辑在「二进制换了但旧进程仍占端口」时健康检查照样 200,新进程永远起不来而表面一切正常;「占端口者密钥不同(foreign 表象)」时直接报错而非回收,手工/老插件起的后端永久卡死。
23
+
5
24
  ## 0.15.2
6
25
 
7
26
  ### 文档
package/README.en.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
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.
8
8
 
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), **`gemini-4-carbon`** (requires an eligible account tier such as Google AI Ultra), and **`gemini-4-argon`**. **Gemini Web (`gemini-web`)** is backed by [`dorokuma/gemini-web2api-go` `v5.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.0), which natively supports dedicated `gemini-4-carbon` / `gemini-4-hydrogen` model IDs (including `-thinking` variants) and mutually recognizes slot upgrades/downgrades under `strict_model`; signed-in `gemini-4-argon` still has a known hang issue in [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53), so `ai-studio` is recommended.
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), **`gemini-4-carbon`** (requires an eligible account tier such as Google AI Ultra), and **`gemini-4-argon`**. **Gemini Web (`gemini-web`)** is backed by [`dorokuma/gemini-web2api-go` `v6.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.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`. Gemini Web's public models no longer include `gemini-4-argon*` since backend v6.0.0—use `gemini-4-carbon*` or `gemini-4-neon*` instead.
10
10
 
11
11
  ## Fork Notice & Acknowledgements
12
12
 
@@ -19,8 +19,8 @@ This project is an actively maintained **fork of [BUKOWSKIREAL/magpie-gemini-web
19
19
  **Key differences from upstream** (full history in [CHANGELOG](CHANGELOG.md)):
20
20
 
21
21
  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 `v5.0.0`, SHA-256 synced one-way by script); the local patch-and-rebuild pipeline was retired.
23
- 3. Gemini Web adds `gemini-4-carbon` / `gemini-4-hydrogen` model IDs with slot cross-validation; fixes include phantom session cleanup, AI Studio proxy precedence, and atomic publish/self-healing for update locks.
22
+ 2. The Gemini Web backend is pinned to the **official Release prebuilt binaries** of `dorokuma/gemini-web2api-go` (currently `v6.0.0`, SHA-256 synced one-way by script); the local patch-and-rebuild pipeline was retired.
23
+ 3. Gemini Web adds `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon` model IDs with slot cross-validation; fixes include phantom session cleanup, AI Studio proxy precedence, and atomic publish/self-healing for update locks.
24
24
  4. Release process: strict `vX.Y.Z` tags + `make release-check` gate; CI runs `make check`, backend pin online verification, and 6-platform smoke tests.
25
25
 
26
26
 
@@ -31,14 +31,14 @@ The plugin provides two independent providers that can be used individually or t
31
31
  | Feature | Google AI Studio (`ai-studio`) | Gemini Web (`gemini-web`) |
32
32
  | :--- | :--- | :--- |
33
33
  | **Best for** | **Primary use & coding agents (recommended)** | General chat & web quota |
34
- | **Key models** | `gemini-4-carbon` (Ultra / eligible accounts), `gemini-4-hydrogen`, `gemini-4-argon`, `gemini-3.1-pro`, Flash series, Deep Research | `gemini-4-carbon` / `gemini-4-hydrogen` (including `-thinking` variants), `gemini-3.8-flash`, `gemini-3.6-flash`, `gemini-3.5-flash-lite`, `gemini-3.1-pro`, `gemini-4-argon` (see [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53)) |
34
+ | **Key models** | `gemini-4-carbon` (Ultra / eligible accounts), `gemini-4-hydrogen`, `gemini-4-argon`, `gemini-3.1-pro`, Flash series, Deep Research | `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon` (including `-thinking` variants; the Neon family thinks server-side internally and never emits `reasoning_content`), `gemini-3.8-flash`, `gemini-3.6-flash`, `gemini-3.5-flash-lite`, `gemini-3.1-pro` |
35
35
  | **Tool calling** | **Native Function Calling**, reliable | Prompt-emulated (experimental; Flash often skips tools) |
36
- | **Thinking levels** | Supported levels from the model catalog: `minimal` / `low` / `medium` / `high` / `xhigh` (Hydrogen) | `low` (base) / `medium` (`-thinking-medium`, `gemini-4-argon` only) / `high` (`-thinking` extended thinking) |
36
+ | **Thinking levels** | Supported levels from the model catalog: `minimal` / `low` / `medium` / `high` / `xhigh` (Hydrogen) | `low` (base) / `medium` (`-thinking-medium`, Carbon / Neon families) / `high` (`-thinking` extended thinking) |
37
37
  | **Image input** | On by default; chat models read images | On by default; chat models read images (needs a signed-in cookie) |
38
38
  | **Image generation** | Nano Banana models, for Magpie's image generation (Magpie v0.1.2075+, see below) | Not supported |
39
39
  | **Sign-in method** | Automatic official installation; confirm an imported account | Copy `cookie` from a private/incognito window |
40
40
  | **Usage cards** | Shows models currently on cooldown and recovery times | Syncs **5-hour** & **weekly** usage and reset times from the web |
41
- | **Local backend** | AIStudio2API (automatic installation and stable updates) | gemini-web2api-go (`v5.0.0` pinned binary) |
41
+ | **Local backend** | AIStudio2API (automatic installation and stable updates) | gemini-web2api-go (`v6.0.0` pinned binary) |
42
42
 
43
43
  ---
44
44
 
@@ -245,13 +245,13 @@ When a plugin error asks you to run a command, it includes the full ready-to-cop
245
245
  - 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.
246
246
 
247
247
  **Gemini Web optimized backend upgrades & rollback:**
248
- - 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. A successful account check does not guarantee generation; signed-in `gemini-4-argon` hangs remain unresolved upstream (this build still uses StreamGenerate and logs that `web_channel` is ignored when enabled), so prefer `ai-studio` for Argon. Backend [`dorokuma/gemini-web2api-go` `v5.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.0) natively exposes dedicated `gemini-4-carbon` and `gemini-4-hydrogen` model IDs (including `-thinking` variants); 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`.
249
- - One-click setup pins the prebuilt [v5.0.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.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.
250
- - **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.
248
+ - 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.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.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—use `gemini-4-carbon*` or `gemini-4-neon*`, or `ai-studio` for Argon); 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`.
249
+ - One-click setup pins the prebuilt [v6.0.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.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.
250
+ - **Upgrading:** On load the plugin detects a stale managed backend process, stops it and upgrades the binary to the pinned `v6.0.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.
251
251
  - **Rollback to upstream / restore the pinned build** (run in the plugin directory after stopping the backend):
252
252
  ```bash
253
253
  npm run backend:install:upstream # Roll back and pin to upstream zexadev v4.28.0
254
- npm run backend:install # Restore the default pinned v5.0.0
254
+ npm run backend:install # Restore the default pinned v6.0.0
255
255
  ```
256
256
  - For pin sync, verification and smoke procedures, see [docs/backend-release.md](docs/backend-release.md).
257
257
 
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
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 等能力。
8
8
 
9
- > **新模型支持说明**:**Google AI Studio (`ai-studio`)** 默认自动跟随官方最新稳定版后端,现已直接支持 **`gemini-4-hydrogen`**(含 `xhigh` 思考档位)、**`gemini-4-carbon`**(需账号具备对应权益,如 Google AI Ultra)与 **`gemini-4-argon`**。**Gemini Web (`gemini-web`)** 由后端 [`dorokuma/gemini-web2api-go` `v5.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.0) 原生支持 `gemini-4-carbon` / `gemini-4-hydrogen` 专用模型 ID(含 `-thinking` 思考变体),`strict_model` 开启时也能正确互认槽位升降级;登录态 `gemini-4-argon` 仍存在生成挂起已知问题 [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53),建议优先使用 `ai-studio`。
9
+ > **新模型支持说明**:**Google AI Studio (`ai-studio`)** 默认自动跟随官方最新稳定版后端,现已直接支持 **`gemini-4-hydrogen`**(含 `xhigh` 思考档位)、**`gemini-4-carbon`**(需账号具备对应权益,如 Google AI Ultra)与 **`gemini-4-argon`**。**Gemini Web (`gemini-web`)** 由后端 [`dorokuma/gemini-web2api-go` `v6.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.0) 原生支持 `gemini-4-carbon` / `gemini-4-hydrogen` / **`gemini-4-neon`** 专用模型 ID(含 `-thinking` 思考变体),`strict_model` 开启时也能正确互认槽位升降级;`gemini-4-neon` 系列为服务端内部思考模型,回复中不输出 `reasoning_content`;Gemini Web 对外模型自 v6.0.0 起移除 `gemini-4-argon*`,请改用 `gemini-4-carbon*` 或 `gemini-4-neon*`。
10
10
 
11
11
  ## Fork 声明与致谢
12
12
 
@@ -19,8 +19,8 @@
19
19
  **与原版的主要差异**(完整历史见 [CHANGELOG](CHANGELOG.md)):
20
20
 
21
21
  1. npm 包名迁移为作用域包 **`@dorokuma/magpie-gemini-web`**;原版无作用域包 `magpie-gemini-web` 仍由原作者维护,两者在 npm 上是相互独立的包。
22
- 2. Gemini Web 后端固定使用 `dorokuma/gemini-web2api-go` 的**官方 Release 预编译二进制**(当前 `v5.0.0`,SHA-256 由脚本单向同步、禁止手改),移除本地补丁重编流水线。
23
- 3. Gemini Web 新增 `gemini-4-carbon` / `gemini-4-hydrogen` 模型 ID 与互认槽位校验;修复幻影会话、AI Studio 代理优先级、更新锁原子发布与自愈等问题。
22
+ 2. Gemini Web 后端固定使用 `dorokuma/gemini-web2api-go` 的**官方 Release 预编译二进制**(当前 `v6.0.0`,SHA-256 由脚本单向同步、禁止手改),移除本地补丁重编流水线。
23
+ 3. Gemini Web 新增 `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon` 模型 ID 与互认槽位校验;修复幻影会话、AI Studio 代理优先级、更新锁原子发布与自愈等问题。
24
24
  4. 发版流程:tag 严格 `vX.Y.Z` + `make release-check` 门禁,CI 跑 `make check`、后端 pin 联网校验与 6 平台冒烟。
25
25
 
26
26
 
@@ -31,14 +31,14 @@
31
31
  | 对比项 | Google AI Studio (`ai-studio`) | Gemini Web (`gemini-web`) |
32
32
  | :--- | :--- | :--- |
33
33
  | **适用场景** | **推荐主力与 Coding Agent 使用** | 日常对话、使用网页版额度 |
34
- | **主要模型** | `gemini-4-carbon`(Ultra 等有权益账号)、`gemini-4-hydrogen`、`gemini-4-argon`、`gemini-3.1-pro`、Flash 系列、Deep Research | `gemini-4-carbon` / `gemini-4-hydrogen`(含 `-thinking` 变体)、`gemini-3.8-flash`、`gemini-3.6-flash`、`gemini-3.5-flash-lite`、`gemini-3.1-pro`、`gemini-4-argon`(见 [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53)) |
34
+ | **主要模型** | `gemini-4-carbon`(Ultra 等有权益账号)、`gemini-4-hydrogen`、`gemini-4-argon`、`gemini-3.1-pro`、Flash 系列、Deep Research | `gemini-4-carbon` / `gemini-4-hydrogen` / `gemini-4-neon`(含 `-thinking` 变体,Neon 系列为服务端内部思考、不输出 `reasoning_content`)、`gemini-3.8-flash`、`gemini-3.6-flash`、`gemini-3.5-flash-lite`、`gemini-3.1-pro` |
35
35
  | **工具调用** | **原生 Function Calling**,稳定可靠 | 提示词模拟(实验性,Flash 系列常不调工具) |
36
- | **思考档位** | 按模型目录提供 `minimal` / `low` / `medium` / `high` / `xhigh`(Hydrogen)中支持的档位 | `low`(普通)/ `medium`(`-thinking-medium`,仅 `gemini-4-argon`)/ `high`(`-thinking` 扩展思考) |
36
+ | **思考档位** | 按模型目录提供 `minimal` / `low` / `medium` / `high` / `xhigh`(Hydrogen)中支持的档位 | `low`(普通)/ `medium`(`-thinking-medium`,Carbon / Neon 系列)/ `high`(`-thinking` 扩展思考) |
37
37
  | **图片输入** | 默认开启,对话模型可以读图 | 默认开启,对话模型可以读图(需登录态挂 Cookie) |
38
38
  | **图片生成** | Nano Banana 系列模型,供 Magpie 的图片生成使用(需要 Magpie v0.1.2075+,见下文) | 不支持 |
39
39
  | **登录方式** | 自动安装官方后端,导入账号后确认连接 | 用无痕窗口登录并复制 `cookie` |
40
40
  | **额度卡片** | 显示冷却中的模型与恢复时间 | 同步网页版 **5 小时** 与 **每周** 用量及重置时间 |
41
- | **本地后端** | AIStudio2API(自动安装并跟随官方稳定版) | gemini-web2api-go (`v5.0.0` 固定 pin 二进制) |
41
+ | **本地后端** | AIStudio2API(自动安装并跟随官方稳定版) | gemini-web2api-go (`v6.0.0` 固定 pin 二进制) |
42
42
 
43
43
  ---
44
44
 
@@ -245,13 +245,13 @@ magpie plugin options @dorokuma/magpie-gemini-web '{"studio":{"proxy":"http://12
245
245
  - 模型列表过滤 `-build` / `assistant_route` 模型:这类模型附带 Build 写代码助手的系统提示词,不作为普通 Agent 模型提供。升级后可执行 `magpie provider models ai-studio` 刷新列表。
246
246
 
247
247
  **Gemini Web 优化后端升级与回退:**
248
- - [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) 的多账号索引漏传已修复,需重新导入受影响的 Cookie 或在后端账号管理中修正索引。账号检测通过不保证生成成功;登录态 `gemini-4-argon` 生成挂起仍待上游完善协议修复(当前优化版仍固定走 StreamGenerate,启用 `web_channel` 会在日志提示被忽略),建议暂用 `ai-studio` 调用 Argon。后端 [`dorokuma/gemini-web2api-go` `v5.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.0) 已原生收录 `gemini-4-carbon` 与 `gemini-4-hydrogen` 模型 ID(含 `-thinking` 思考变体);`strict_model` 槽位校验按显示名家族互认升级/降级,付费账号请求 `gemini-3.8-flash` 被路由至 `4 Hydrogen` 时也能正确识别,不会误报 `429 model_downgraded`。
249
- - 插件默认固定使用后端仓发布的 [v5.0.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v5.0.0) 预编译二进制(一仓一制品,6 平台 SHA-256 pin 在 `lib/backend-release.json`,不再由插件仓打补丁重编)。对话请求按上游沉默计时:Google 让请求排队时每 60 秒发一次心跳,后端会一直等到出字;连续 `request_timeout_sec`(默认 180 秒)没有任何数据才放弃这一次并重试,还在出字的长回复也不会被截断。
250
- - **旧版升级**:插件不会打断运行中的后端。先停止旧进程(PID 见数据目录 `backend.pid`),下次启动 Magpie 或发请求时会自动更新二进制并保留原有配置与账号。
248
+ - [#53](https://github.com/dorokuma/magpie-gemini-web/issues/53) 的多账号索引漏传已修复,需重新导入受影响的 Cookie 或在后端账号管理中修正索引。后端 [`dorokuma/gemini-web2api-go` `v6.0.0`](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.0) 已原生收录 `gemini-4-carbon`、`gemini-4-hydrogen` 与 `gemini-4-neon` 模型 ID(含 `-thinking` 思考变体,Neon 系列为服务端内部思考、不输出 `reasoning_content`),同时移除了 Gemini Web 对外 `gemini-4-argon*`(原 Argon 槽位在上游目录中原位改名为 4 Carbon,请改用 `gemini-4-carbon*` 或 `gemini-4-neon*`;如需 Argon 请走 `ai-studio`);`strict_model` 槽位校验按显示名家族互认升级/降级,付费账号请求 `gemini-3.8-flash` 被路由至 `4 Hydrogen` 时也能正确识别,不会误报 `429 model_downgraded`。
249
+ - 插件默认固定使用后端仓发布的 [v6.0.0](https://github.com/dorokuma/gemini-web2api-go/releases/tag/v6.0.0) 预编译二进制(一仓一制品,6 平台 SHA-256 pin 在 `lib/backend-release.json`,不再由插件仓打补丁重编)。对话请求按上游沉默计时:Google 让请求排队时每 60 秒发一次心跳,后端会一直等到出字;连续 `request_timeout_sec`(默认 180 秒)没有任何数据才放弃这一次并重试,还在出字的长回复也不会被截断。
250
+ - **旧版升级**:插件加载时若识别到托管的旧版后端进程,会自动回收并升级到当前 pin 的 `v6.0.0`,这可能中断正在进行的生成请求;建议升级前先等待在途请求结束,或手动停止旧进程(PID 见数据目录 `backend.pid`)。非插件托管或无法识别的实例不保证自动更新。升级后保留原有配置与账号。
251
251
  - **回退官方上游版 / 恢复 pin 版**(停止后端后在插件目录执行):
252
252
  ```bash
253
253
  npm run backend:install:upstream # 回退并固定使用上游 zexadev v4.28.0
254
- npm run backend:install # 恢复默认 pin 的 v5.0.0
254
+ npm run backend:install # 恢复默认 pin 的 v6.0.0
255
255
  ```
256
256
  - pin 同步、校验与冒烟流程见 [docs/backend-release.md](docs/backend-release.md)。
257
257
 
@@ -1,31 +1,31 @@
1
1
  {
2
- "version": "5.0.0",
2
+ "version": "6.0.0",
3
3
  "repository": "dorokuma/gemini-web2api-go",
4
- "tag": "v5.0.0",
4
+ "tag": "v6.0.0",
5
5
  "binaries": {
6
6
  "darwin-x64": {
7
- "asset": "gemini-web2api-go_v5.0.0_darwin_amd64",
8
- "sha256": "852af30ffbcfd1402905f855e78d41d54a2f62313085aab420423ea0d855e2c1"
7
+ "asset": "gemini-web2api-go_v6.0.0_darwin_amd64",
8
+ "sha256": "1c4c0bf8c4ca1f55cbb33b2a91bf58216d5c0221536cf23c65487ecbd38db354"
9
9
  },
10
10
  "darwin-arm64": {
11
- "asset": "gemini-web2api-go_v5.0.0_darwin_arm64",
12
- "sha256": "dfdcac8065483176fc42c6387014aa106cfe30175b94c393d7345f596eb26c7a"
11
+ "asset": "gemini-web2api-go_v6.0.0_darwin_arm64",
12
+ "sha256": "8ea0b15abb5ed05dc6ca06d4bcece7e61a58f10007f9f3b78587522293dd6c33"
13
13
  },
14
14
  "linux-x64": {
15
- "asset": "gemini-web2api-go_v5.0.0_linux_amd64",
16
- "sha256": "7a13f0e9c3003732eeb6346d16be191f486d1eaa035d61f1e8751ee287680e2a"
15
+ "asset": "gemini-web2api-go_v6.0.0_linux_amd64",
16
+ "sha256": "28cb08ca44189b4e016b5fbade95b7cadf7b63533f76b8c49532fea25000b3ef"
17
17
  },
18
18
  "linux-arm64": {
19
- "asset": "gemini-web2api-go_v5.0.0_linux_arm64",
20
- "sha256": "c0c468c7c8f85c0772a389586bbc92d7493e27e3b26e5baba0fc749abc427bfe"
19
+ "asset": "gemini-web2api-go_v6.0.0_linux_arm64",
20
+ "sha256": "3e71505323448a0b6f22b1da80ea7291953fe0a3eb01a937cba46b8bc473ccb3"
21
21
  },
22
22
  "win32-x64": {
23
- "asset": "gemini-web2api-go_v5.0.0_windows_amd64.exe",
24
- "sha256": "08ce950afe2eda4a622f9c1560e578bdb13d00477ac9f20cd5bd62036a4345f4"
23
+ "asset": "gemini-web2api-go_v6.0.0_windows_amd64.exe",
24
+ "sha256": "de149314b195e3ae462b7bd68eaeb283fac13731112f032c11f69e4cbd70ad97"
25
25
  },
26
26
  "win32-arm64": {
27
- "asset": "gemini-web2api-go_v5.0.0_windows_arm64.exe",
28
- "sha256": "fb36c3b457e6b372b6a528c19ede49637712d384b4623751174aba1d7d621f26"
27
+ "asset": "gemini-web2api-go_v6.0.0_windows_arm64.exe",
28
+ "sha256": "123f7a7208089f30d975d8b0fa34214570c34c29fdbffd0b9ed775b50698f235"
29
29
  }
30
30
  }
31
31
  }
package/lib/native.mjs CHANGED
@@ -2,7 +2,7 @@ import fs from 'node:fs';
2
2
  import path from 'node:path';
3
3
  import os from 'node:os';
4
4
  import crypto from 'node:crypto';
5
- import { spawn, execFile } from 'node:child_process';
5
+ import { spawn, execFile, execFileSync } from 'node:child_process';
6
6
  import { validateProxyURL } from './setup.mjs';
7
7
  import { verifyProcessIdentity, studioProcessPids, studioListenerPids } from './studio-native.mjs';
8
8
  import { hasProxyCredentials, normalizeCurlProxy, redactProxyCredentials } from './studio-upstream.mjs';
@@ -376,6 +376,133 @@ async function backendState(setup, fetchFn) {
376
376
  return res.ok ? 'up' : 'foreign';
377
377
  }
378
378
 
379
+
380
+ // backendVersion asks the backend at setup for its self-reported version (the same string
381
+ // --version prints). Returns null when the backend is down, foreign, or too old to answer.
382
+ async function backendVersion(setup, fetchFn) {
383
+ try {
384
+ const res = await fetchFn(`${setup.origin}/`, { signal: AbortSignal.timeout(3000) });
385
+ if (!res.ok) return null;
386
+ const data = await res.json();
387
+ return typeof data.version === "string" && data.version ? data.version : null;
388
+ } catch {
389
+ return null;
390
+ }
391
+ }
392
+
393
+ // normalizeVersion strips a leading "v" so "v5.0.0" and "5.0.0" compare equal.
394
+ function normalizeVersion(v) { return typeof v === "string" ? v.replace(/^v/, "") : null; }
395
+
396
+ // expectedBackendVersion returns the version string the running backend should report for the
397
+ // binary on disk: a trusted argon-build.json local build keeps its recorded version, the
398
+ // pinned release keeps its tag version, and anything else falls back to the pin so an
399
+ // untrusted binary is still steered back to the release.
400
+ function expectedBackendVersion(dataDir, platform, arch) {
401
+ const channel = backendChannel(dataDir);
402
+ let fallback = release.version;
403
+ try {
404
+ const binHash = fs.existsSync(binaryPath(dataDir, platform))
405
+ ? computeFileHash(binaryPath(dataDir, platform)) : null;
406
+ if (binHash) {
407
+ try {
408
+ const argon = JSON.parse(fs.readFileSync(path.join(dataDir, "argon-build.json"), "utf8"));
409
+ if (argon.sha256 === binHash && typeof argon.version === "string") return argon.version;
410
+ } catch {}
411
+ try {
412
+ const pin = pinnedBinary(platform, arch, channel);
413
+ if (pin.sha256 === binHash) return release.version;
414
+ } catch {}
415
+ }
416
+ } catch {}
417
+ return fallback;
418
+ }
419
+
420
+ // inDataDirBackendProc
421
+ // using /proc on Linux so a stale binary renamed elsewhere is still recognised.
422
+ // backendOwnedByDataDir reports whether pid is OUR backend: it must both run a
423
+ // gemini-web2api-go image and tie itself to this dataDir — launched from bin/ inside it, or
424
+ // carrying --config/--db inside it. Both halves keep a same-port stranger (another install,
425
+ // or a test fixture pointing its config at a live port) from being killed by mistake.
426
+ function backendOwnedByDataDir(pid, dataDir, platform) {
427
+ const root = path.resolve(dataDir);
428
+ const owned = candidate => {
429
+ if (!candidate) return false;
430
+ const cleaned = candidate.replace(/ \(deleted\)$/, "");
431
+ if (!path.basename(cleaned).startsWith("gemini-web2api-go")) return false;
432
+ const resolved = path.resolve(cleaned);
433
+ const rel = path.relative(root, resolved);
434
+ return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
435
+ };
436
+ const argsInDataDir = cmdline => {
437
+ if (!cmdline) return false;
438
+ return cmdline.split("\0").concat(cmdline.split(/\s+/)).some(a => {
439
+ const v = a.replace(/^--(?:config|db)=/, "");
440
+ if (!v) return false;
441
+ const resolved = path.resolve(v);
442
+ const rel = path.relative(root, resolved);
443
+ return rel !== "" && !rel.startsWith("..") && !path.isAbsolute(rel);
444
+ });
445
+ };
446
+ if (platform === "linux") {
447
+ let exe = "", cmdline = "";
448
+ try { exe = fs.readlinkSync(`/proc/${pid}/exe`); } catch {}
449
+ try { cmdline = fs.readFileSync(`/proc/${pid}/cmdline`, "utf8"); } catch {}
450
+ const arg0 = cmdline.split("\0")[0] || "";
451
+ // The executable image must live under dataDir (bin/, backups kept beside it), AND the
452
+ // process must own this dataDir either by its launch path or by --config/--db inside it.
453
+ return (owned(exe) || owned(arg0)) && (owned(arg0) || argsInDataDir(cmdline));
454
+ }
455
+ if (platform === "darwin") {
456
+ try {
457
+ const cmdline = execFileSync("ps", ["-p", String(pid), "-ww", "-o", "command="], { encoding: "utf8", timeout: 5000 }).trim();
458
+ const arg0 = cmdline.split(/\s+/)[0] || "";
459
+ return owned(arg0) && argsInDataDir(cmdline);
460
+ } catch { return false; }
461
+ }
462
+ // win32 cannot have a stale backend: Windows locks the running image, so the binary can
463
+ // never be replaced underneath a live process — verifyProcessIdentity covers it.
464
+ return false;
465
+ }
466
+
467
+ // staleBackendPids lists live processes listening on setup.origin that are NOT the binary on
468
+ // disk but still look like a gemini-web2api-go image — the leftovers that keep an outdated
469
+ // backend answering health checks after the binary was swapped.
470
+ function staleBackendPids(setup, dataDir, platform, verify) {
471
+ const bin = binaryPath(dataDir, platform);
472
+ const port = Number(new URL(setup.origin).port);
473
+ let listeners = [];
474
+ try { listeners = studioListenerPids(port, platform); } catch {}
475
+ const tracked = recordedBackendPid(dataDir);
476
+ const candidates = [...new Set([...listeners, ...(Number.isInteger(tracked) && tracked > 0 ? [tracked] : [])])];
477
+ // No verify exemption: reaching this point means the answerer is stale (version mismatch)
478
+ // or the backend is being rebuilt — a same-path stale process must go down too.
479
+ return candidates.filter(pid => processAlive(pid) && backendOwnedByDataDir(pid, dataDir, platform));
480
+ }
481
+
482
+ // stopStaleBackend kills backend processes that hold the port but are not the managed binary,
483
+ // so the release build can actually take over the port instead of being adopted-and-masked.
484
+ async function stopStaleBackend(setup, dataDir, platform, verify, fetchFn) {
485
+ const stale = staleBackendPids(setup, dataDir, platform, verify);
486
+ if (!stale.length) return 0;
487
+ for (const pid of stale) { try { process.kill(pid, "SIGTERM"); } catch {} }
488
+ const deadline = Date.now() + 5000;
489
+ while (Date.now() < deadline) {
490
+ if (stale.every(p => !processAlive(p))) break;
491
+ await sleep(100);
492
+ }
493
+ for (const pid of stale) {
494
+ if (processAlive(pid) && backendOwnedByDataDir(pid, dataDir, platform)) {
495
+ try { process.kill(pid, "SIGKILL"); } catch {}
496
+ }
497
+ }
498
+ const closeDeadline = Date.now() + 2000;
499
+ while (Date.now() < closeDeadline) {
500
+ if (await backendState(setup, fetchFn) !== "up") break;
501
+ await sleep(100);
502
+ }
503
+ return stale.length;
504
+ }
505
+
379
506
  const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
380
507
 
381
508
  // withLock serializes setup across plugin hosts (Magpie may run more than one) by a lock file.
@@ -426,23 +553,68 @@ export async function ensureBackend(options = {}) {
426
553
  const arch = options.arch || process.arch;
427
554
  const fetchFn = options.fetchFn || globalThis.fetch;
428
555
  const spawnFn = options.spawnFn || spawn;
556
+ const verify = options.verifyIdentity || verifyProcessIdentity;
429
557
  const startTimeoutMs = options.startTimeoutMs ?? 20000;
430
558
 
559
+ // Adoption is version-aware. A healthy backend is only reused when it reports the version
560
+ // the binary on disk should run; a stale one — including the case where it answers with a
561
+ // different API key and so looks "foreign" — is killed first so the release build can
562
+ // actually take the port. Without this, a plugin upgrade never reaches the backend: the
563
+ // old process keeps answering health checks and the swap silently never happens.
431
564
  let setup = readLocalSetup(dataDir);
432
- if (setup && fs.existsSync(binaryPath(dataDir, platform)) && await backendState(setup, fetchFn) === 'up') {
433
- return setup;
434
- }
565
+ const expectedVersion = expectedBackendVersion(dataDir, platform, arch);
566
+ const matchesExpected = async () => {
567
+ const running = normalizeVersion(await backendVersion(setup, fetchFn));
568
+ const expected = normalizeVersion(expectedVersion);
569
+ if (!running) return 'unknown'; // too old to report — adopt, cannot self-heal
570
+ return running === expected ? 'match' : 'stale';
571
+ };
435
572
 
436
573
  fs.mkdirSync(dataDir, { recursive: true, mode: 0o700 });
437
574
  return withLock(dataDir, async () => {
438
575
  setup = readLocalSetup(dataDir);
439
- if (setup && fs.existsSync(binaryPath(dataDir, platform)) && await backendState(setup, fetchFn) === 'up') {
440
- return setup;
441
- }
442
-
443
576
  const trusted = trustedHashes(dataDir, platform, arch);
444
577
  const binPath = binaryPath(dataDir, platform);
445
- if (!fs.existsSync(binPath) || !trusted.includes(computeFileHash(binPath))) {
578
+ const binTrusted = fs.existsSync(binPath) && trusted.includes(computeFileHash(binPath));
579
+
580
+ if (setup) {
581
+ const state = await backendState(setup, fetchFn);
582
+ if (state === 'up') {
583
+ const verdict = binTrusted ? await matchesExpected() : 'stale';
584
+ if (verdict === 'match' || verdict === 'unknown') return setup;
585
+ // Version mismatch or untrusted binary: kill whatever holds the port before the
586
+ // pinned build is installed and respawned. Nothing killed = the listener is not
587
+ // ours to swap, so keep adopting rather than break a working install.
588
+ const killed = await stopStaleBackend(setup, dataDir, platform, verify, fetchFn);
589
+ if (!killed) return setup;
590
+ if (await backendState(setup, fetchFn) === 'up') {
591
+ // Port still claimed by something we could not identify; never stack a second
592
+ // backend behind it.
593
+ return setup;
594
+ }
595
+ } else if (state === 'foreign' && fs.existsSync(binPath)) {
596
+ // "foreign" here is often still OUR backend — launched by hand or by an older plugin
597
+ // with a different secrets file — holding the port while a pinned build waits. Only
598
+ // images owned by this dataDir are killed; anything else keeps its name. When no
599
+ // binary exists yet we skip the probe entirely: the port cannot be ours anyway, and
600
+ // probing now would consume the caller's network before the download runs.
601
+ const killed = await stopStaleBackend(setup, dataDir, platform, verify, fetchFn);
602
+ if (!killed) {
603
+ throw new Error(`${setup.origin} is already used by another service; change "port" in ${path.join(dataDir, 'config.json')}`);
604
+ }
605
+ const after = await backendState(setup, fetchFn);
606
+ if (after === 'foreign') {
607
+ throw new Error(`${setup.origin} is already used by another service; change "port" in ${path.join(dataDir, 'config.json')}`);
608
+ }
609
+ if (after === 'up') {
610
+ const verdict = binTrusted ? await matchesExpected() : 'stale';
611
+ if (verdict === 'match' || verdict === 'unknown') return setup;
612
+ await stopStaleBackend(setup, dataDir, platform, verify, fetchFn);
613
+ }
614
+ }
615
+ }
616
+
617
+ if (!binTrusted) {
446
618
  await installBackend({ dataDir, platform, arch, fetchFn, channel: backendChannel(dataDir), proxy: options.proxy });
447
619
  } else {
448
620
  ensureDataFiles(dataDir);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dorokuma/magpie-gemini-web",
3
- "version": "0.15.2",
4
- "description": "Google AI Studio and Gemini Web provider for Magpie (Gemini 4 Carbon / Hydrogen / Argon, Nano Banana image generation, Deep Research), backed by AIStudio2API and gemini-web2api-go",
3
+ "version": "0.16.0",
4
+ "description": "Google AI Studio and Gemini Web provider for Magpie (Gemini 4 Carbon / Hydrogen / Neon, Nano Banana image generation, Deep Research), backed by AIStudio2API and gemini-web2api-go",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",
7
7
  "exports": "./index.mjs",